@markless/serializer 0.3.3 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,9 @@
1
- import { a as SerializedRecord, o as SerializedSlot, r as SerializedGraphPayload } from "./value-BJ6YNKDd.js";
2
-
1
+ import { i as SerializedGraphPayload, o as SerializedRecord, s as SerializedSlot } from "./value-CRkHmkRz.js";
3
2
  //#region src/value-decode-client.d.ts
4
- type ValueDecodeExtensions = {
3
+ export type ValueDecodeExtensions = {
5
4
  readonly recordShell: (record: SerializedRecord, shells: ReadonlyMap<number, unknown>) => unknown;
6
5
  readonly slot: (slot: SerializedSlot) => unknown;
7
6
  };
8
- declare function deserializeGraphValueForClient(payload: SerializedGraphPayload): Promise<unknown>;
7
+ export declare function deserializeGraphValueForClient(payload: SerializedGraphPayload): Promise<unknown>;
9
8
  //#endregion
10
- export { type SerializedGraphPayload, type SerializedRecord, type SerializedSlot, ValueDecodeExtensions, deserializeGraphValueForClient };
9
+ export type { SerializedGraphPayload, SerializedRecord, SerializedSlot };
@@ -1,6 +1,6 @@
1
1
  //#region src/value-decode-client.ts
2
2
  async function deserializeGraphValueForClient(payload) {
3
- return deserializeGraphValueWithExtensions(payload, payloadNeedsExtendedDecoders(payload) ? (await import("./value-decode-extensions-Bf-pgKHA.js")).valueDecodeExtensions : void 0);
3
+ return deserializeGraphValueWithExtensions(payload, payloadNeedsExtendedDecoders(payload) ? (await import("./value-decode-extensions-xfgotsAg.js")).valueDecodeExtensions : void 0);
4
4
  }
5
5
  function deserializeGraphValueWithExtensions(payload, extensions) {
6
6
  const shells = /* @__PURE__ */ new Map();
@@ -43,6 +43,7 @@ function decodeSlot(slot, shells, extensions) {
43
43
  if ("$ref" in slot) return shells.get(slot.$ref);
44
44
  if (slot.$type === "undefined") return void 0;
45
45
  if (slot.$type === "bigint") return BigInt(slot.value);
46
+ if (slot.$type === "number") return Number(slot.value);
46
47
  if (slot.$type === "date") return new Date(slot.value);
47
48
  return extensions?.slot(slot);
48
49
  }
package/dist/decode.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as SerializedRecord, l as deserializeGraphValue, o as SerializedSlot, r as SerializedGraphPayload } from "./value-BJ6YNKDd.js";
2
- export { SerializedGraphPayload, SerializedRecord, SerializedSlot, deserializeGraphValue };
1
+ import { f as deserializeGraphValue, i as SerializedGraphPayload, o as SerializedRecord, s as SerializedSlot } from "./value-CRkHmkRz.js";
2
+ export { type SerializedGraphPayload, type SerializedRecord, type SerializedSlot, deserializeGraphValue };
package/dist/decode.js CHANGED
@@ -41,6 +41,7 @@ function decodeSlot(slot, shells) {
41
41
  if ("$ref" in slot) return shells.get(slot.$ref);
42
42
  if (slot.$type === "undefined") return void 0;
43
43
  if (slot.$type === "bigint") return BigInt(slot.value);
44
+ if (slot.$type === "number") return Number(slot.value);
44
45
  if (slot.$type === "date") return new Date(slot.value);
45
46
  if (slot.$type === "regexp") return new RegExp(slot.source, slot.flags);
46
47
  if (slot.$type === "url") return new URL(slot.value);
package/dist/index.d.ts CHANGED
@@ -1,22 +1,22 @@
1
- import { _ as ASYNC_PROTOCOL_VERSION, a as ProtocolEventAction, b as ASYNC_BOUNDARY_ARM, c as ProtocolPayloadScripts, d as ProtocolSyncPolicy, f as ProtocolSyncPolicyBranch, g as protocolEventDispatchesMarkless, h as protocolEventActionKind, i as ProtocolAsyncBoundaryArm, l as ProtocolStatePayload, m as ProtocolViewPayload, n as ProtocolArmBranchRecord, o as ProtocolEventActionKind, p as ProtocolSyncPolicyCondition, r as ProtocolArmRecordSet, s as ProtocolEventRecord, t as PROTOCOL_EVENT_ACTION_KIND, u as ProtocolStreamedArmPatch, v as STORAGE_PROTOCOL_VERSION, y as protocolStateVersion } from "./protocol-BfzeLgjZ.js";
2
- import { a as SerializedRecord, c as serializeGraphValue, i as SerializedPrimitive, l as deserializeGraphValue, n as SerializationResult, o as SerializedSlot, r as SerializedGraphPayload, s as TypedArrayName, t as SerializationDiagnostic } from "./value-BJ6YNKDd.js";
3
- import { a as RuntimePayloadError, c as assertProtocolStateCellPayload, d as decodePayloadScriptsWithVersion, f as invalidPayloadShapeError, i as RuntimePayloadDiagnostic, l as assertProtocolStatePayload, m as payloadScriptSelector, n as DecodedPayloadScripts, o as RuntimePayloadErrorCode, p as payloadInvalidError, r as EncodedPayloadScripts, s as RuntimePayloadType, t as decodePayloadScripts, u as assertProtocolViewPayload } from "./protocol-validation-storage-DogbS8xp.js";
4
-
1
+ import { A as protocolProjectionSegment, C as PROTOCOL_PAGE_SPACE_ID_PREFIXES, D as protocolInstancePath, E as STORAGE_PROTOCOL_VERSION, F as PROTOCOL_IDLE_EVENT_NAME, I as PROTOCOL_VISIBLE_EVENT_NAME, L as ASYNC_BOUNDARY_ARM, M as protocolStateVersion, N as PROTOCOL_SYNC_POLICY_HOST_ATTRIBUTE, O as protocolInstanceQualifies, P as PROTOCOL_LOCATOR_PATHS_ATTRIBUTE, S as PROTOCOL_EVENT_ACTION_KIND, T as PROTOCOL_PROP_GRAPH_NODE_PREFIX, _ as ProtocolViewPayload, a as ProtocolBranchIdrefSite, b as protocolEventDispatchesMarkless, c as ProtocolEventActionKind, d as ProtocolRowTemplateSlotValue, f as ProtocolStatePayload, g as ProtocolSyncPolicyCondition, h as ProtocolSyncPolicyBranch, i as ProtocolBranchContentRead, j as protocolRowSegment, k as protocolInstanceSegment, l as ProtocolEventRecord, m as ProtocolSyncPolicy, n as ProtocolArmRecordSet, o as ProtocolComposedGraphProp, p as ProtocolStreamedArmPatch, r as ProtocolAsyncBoundaryArm, s as ProtocolEventAction, t as ProtocolArmBranchRecord, u as ProtocolPayloadScripts, v as protocolElementHandleReadId, w as PROTOCOL_PROPS_GRAPH_NODE_ID, x as ASYNC_PROTOCOL_VERSION, y as protocolEventActionKind } from "./protocol-B3YIo3hD.js";
2
+ import { a as SerializedPrimitive, c as TypedArrayName, d as serializeGraphValue, f as deserializeGraphValue, i as SerializedGraphPayload, l as jsonSourceWithNonFiniteNumbers, n as SerializationDiagnostic, o as SerializedRecord, r as SerializationResult, s as SerializedSlot, t as NonFiniteNumberName, u as nonFiniteName } from "./value-CRkHmkRz.js";
3
+ import { a as RuntimePayloadError, c as assertProtocolStateCellPayload, d as decodePayloadScriptsWithVersion, f as invalidPayloadShapeError, i as RuntimePayloadDiagnostic, l as assertProtocolStatePayload, m as payloadScriptSelector, n as DecodedPayloadScripts, o as RuntimePayloadErrorCode, p as payloadInvalidError, r as EncodedPayloadScripts, s as RuntimePayloadType, t as decodePayloadScripts, u as assertProtocolViewPayload } from "./protocol-validation-storage-C9YES3Zy.js";
5
4
  //#region src/payload-scripts.d.ts
6
- type RenderPayloadScriptsInput = {
5
+ export type RenderPayloadScriptsInput = {
7
6
  readonly state: ProtocolStatePayload;
8
7
  readonly view: ProtocolViewPayload;
9
8
  };
10
- type RenderedPayloadScripts = {
9
+ export type RenderedPayloadScripts = {
11
10
  readonly state: ProtocolStatePayload;
12
11
  readonly view: ProtocolViewPayload;
13
12
  readonly stateScript: string;
14
13
  readonly viewScript: string;
15
14
  };
16
- declare function renderPayloadScripts(input: RenderPayloadScriptsInput): RenderedPayloadScripts;
15
+ export declare function renderPayloadScripts(input: RenderPayloadScriptsInput): RenderedPayloadScripts;
16
+ export declare function escapeScriptJson(value: string): string;
17
17
  //#endregion
18
18
  //#region src/protocol-state.d.ts
19
- type ProtocolAsyncComputedSnapshotInput = {
19
+ export type ProtocolAsyncComputedSnapshotInput = {
20
20
  readonly status: 'idle';
21
21
  readonly version: 0;
22
22
  } | {
@@ -34,7 +34,7 @@ type ProtocolAsyncComputedSnapshotInput = {
34
34
  readonly key: unknown;
35
35
  readonly error: unknown;
36
36
  };
37
- type ProtocolStatePayloadInput = {
37
+ export type ProtocolStatePayloadInput = {
38
38
  readonly cells: ReadonlyArray<{
39
39
  readonly graphNodeId: string;
40
40
  readonly name: string;
@@ -44,14 +44,15 @@ type ProtocolStatePayloadInput = {
44
44
  readonly computed?: ReadonlyArray<Omit<ProtocolStatePayload['computed'][number], 'snapshot'> & {
45
45
  readonly snapshot?: ProtocolAsyncComputedSnapshotInput;
46
46
  }>;
47
+ readonly sharedSeeds?: ProtocolStatePayload['sharedSeeds'];
47
48
  readonly sharedDefinitions?: ProtocolStatePayload['sharedDefinitions'];
48
49
  readonly storage?: ProtocolStatePayload['storage'];
49
50
  };
50
- type ProtocolStateSerializationDiagnostic = SerializationDiagnostic & {
51
+ export type ProtocolStateSerializationDiagnostic = SerializationDiagnostic & {
51
52
  readonly graphNodeId: string;
52
53
  readonly cellName: string;
53
54
  };
54
- declare class ProtocolStateSerializationError extends Error implements ProtocolStateSerializationDiagnostic {
55
+ export declare class ProtocolStateSerializationError extends Error implements ProtocolStateSerializationDiagnostic {
55
56
  readonly code: SerializationDiagnostic['code'];
56
57
  readonly severity: SerializationDiagnostic['severity'];
57
58
  readonly phase: SerializationDiagnostic['phase'];
@@ -66,40 +67,47 @@ declare class ProtocolStateSerializationError extends Error implements ProtocolS
66
67
  readonly cellName: string;
67
68
  constructor(diagnostic: ProtocolStateSerializationDiagnostic);
68
69
  }
69
- declare function createProtocolStatePayload(input: ProtocolStatePayloadInput): ProtocolStatePayload;
70
- declare function serializeRuntimeStateCells(cells: ProtocolStatePayload['cells']): ProtocolStatePayload['cells'];
71
- declare function serializeRuntimeAsyncSnapshots(computed: ProtocolStatePayload['computed']): ProtocolStatePayload['computed'];
70
+ export declare function createProtocolStatePayload(input: ProtocolStatePayloadInput): ProtocolStatePayload;
71
+ export declare function serializeRuntimeStateCells(cells: ProtocolStatePayload['cells']): ProtocolStatePayload['cells'];
72
+ export declare function serializeRuntimeAsyncSnapshots(computed: ProtocolStatePayload['computed']): ProtocolStatePayload['computed'];
72
73
  //#endregion
73
74
  //#region src/resume-record-merge.d.ts
74
75
  type ResumeRecordSet = {
75
76
  readonly state: ProtocolStatePayload;
76
77
  readonly view: ProtocolViewPayload;
77
78
  };
78
- declare function mergeResumeRecordDelta(baseline: ResumeRecordSet, delta: ResumeRecordSet): ResumeRecordSet;
79
+ export declare function mergeResumeRecordDelta(baseline: ResumeRecordSet, delta: ResumeRecordSet): ResumeRecordSet;
79
80
  //#endregion
80
81
  //#region src/resume-record-delta.d.ts
81
- type ResumeRecordDeltaClassification = {
82
+ export type ResumeRecordDeltaClassification = {
82
83
  readonly kind: 'empty';
83
84
  } | {
84
85
  readonly kind: 'divergent';
85
86
  readonly delta: ResumeRecordSet;
86
87
  };
87
- declare function classifyResumeRecordDelta(baseline: ResumeRecordSet, request: ResumeRecordSet): ResumeRecordDeltaClassification;
88
+ export declare function classifyResumeRecordDelta(baseline: ResumeRecordSet, request: ResumeRecordSet): ResumeRecordDeltaClassification;
89
+ //#endregion
90
+ //#region src/storage-cookie.d.ts
91
+ export declare function decodeStorageCookieValue(raw: string): string | undefined;
92
+ export declare const STORAGE_RENDER_CONTEXT_READER = "storageValue";
93
+ export declare function createStorageCookieReader(cookieHeader: string | null | undefined): (driverKey: string) => string | undefined;
88
94
  //#endregion
89
95
  //#region src/storage-key.d.ts
90
- declare function isValidStorageKey(value: string): boolean;
96
+ export declare function isValidStorageKey(value: string): boolean;
91
97
  //#endregion
92
98
  //#region src/storage-slot.d.ts
93
- declare const STORAGE_SLOT_SYMBOL_KEY = "tsrx.storage/1";
94
- declare function storageAttributeName(driverKey: string): string;
95
- type StorageSeedMetadata = {
99
+ export declare const STORAGE_SLOT_SYMBOL_KEY = "tsrx.storage/1";
100
+ export declare function storageAttributeName(driverKey: string): string;
101
+ export declare function storageCookieName(driverKey: string): string;
102
+ export declare function storageCookieAssignment(driverKey: string, value: string, secure: boolean): string;
103
+ export type StorageSeedMetadata = {
96
104
  readonly slotKey: string;
97
105
  readonly driverKey: string;
98
106
  readonly fallback: string;
99
107
  };
100
- declare function storageSlotEntryKey(moduleId: string, key: string): string;
101
- declare function storageSlotEntryKeyFromGraphNodeId(graphNodeId: string): string;
102
- declare function createStorageSeedMetadata(moduleId: string, driverKey: string, fallback: string): StorageSeedMetadata;
103
- declare function createStorageSeedMetadataFromGraphNodeId(graphNodeId: string, driverKey: string, fallback: string): StorageSeedMetadata;
108
+ export declare function storageSlotEntryKey(moduleId: string, key: string): string;
109
+ export declare function storageSlotEntryKeyFromGraphNodeId(graphNodeId: string): string;
110
+ export declare function createStorageSeedMetadata(moduleId: string, driverKey: string, fallback: string): StorageSeedMetadata;
111
+ export declare function createStorageSeedMetadataFromGraphNodeId(graphNodeId: string, driverKey: string, fallback: string): StorageSeedMetadata;
104
112
  //#endregion
105
- export { ASYNC_BOUNDARY_ARM, ASYNC_PROTOCOL_VERSION, DecodedPayloadScripts, EncodedPayloadScripts, PROTOCOL_EVENT_ACTION_KIND, ProtocolArmBranchRecord, ProtocolArmRecordSet, ProtocolAsyncBoundaryArm, ProtocolAsyncComputedSnapshotInput, ProtocolEventAction, ProtocolEventActionKind, ProtocolEventRecord, ProtocolPayloadScripts, ProtocolStatePayload, ProtocolStatePayloadInput, ProtocolStateSerializationDiagnostic, ProtocolStateSerializationError, ProtocolStreamedArmPatch, ProtocolSyncPolicy, ProtocolSyncPolicyBranch, ProtocolSyncPolicyCondition, ProtocolViewPayload, RenderPayloadScriptsInput, RenderedPayloadScripts, ResumeRecordDeltaClassification, type ResumeRecordSet, RuntimePayloadDiagnostic, RuntimePayloadError, RuntimePayloadErrorCode, RuntimePayloadType, STORAGE_PROTOCOL_VERSION, STORAGE_SLOT_SYMBOL_KEY, SerializationDiagnostic, SerializationResult, SerializedGraphPayload, SerializedPrimitive, SerializedRecord, SerializedSlot, StorageSeedMetadata, TypedArrayName, assertProtocolStateCellPayload, assertProtocolStatePayload, assertProtocolViewPayload, classifyResumeRecordDelta, createProtocolStatePayload, createStorageSeedMetadata, createStorageSeedMetadataFromGraphNodeId, decodePayloadScripts, decodePayloadScriptsWithVersion, deserializeGraphValue, invalidPayloadShapeError, isValidStorageKey, mergeResumeRecordDelta, payloadInvalidError, payloadScriptSelector, protocolEventActionKind, protocolEventDispatchesMarkless, protocolStateVersion, renderPayloadScripts, serializeGraphValue, serializeRuntimeAsyncSnapshots, serializeRuntimeStateCells, storageAttributeName, storageSlotEntryKey, storageSlotEntryKeyFromGraphNodeId };
113
+ export { ASYNC_BOUNDARY_ARM, ASYNC_PROTOCOL_VERSION, DecodedPayloadScripts, EncodedPayloadScripts, NonFiniteNumberName, PROTOCOL_EVENT_ACTION_KIND, PROTOCOL_IDLE_EVENT_NAME, PROTOCOL_LOCATOR_PATHS_ATTRIBUTE, PROTOCOL_PAGE_SPACE_ID_PREFIXES, PROTOCOL_PROPS_GRAPH_NODE_ID, PROTOCOL_PROP_GRAPH_NODE_PREFIX, PROTOCOL_SYNC_POLICY_HOST_ATTRIBUTE, PROTOCOL_VISIBLE_EVENT_NAME, ProtocolArmBranchRecord, ProtocolArmRecordSet, ProtocolAsyncBoundaryArm, ProtocolBranchContentRead, ProtocolBranchIdrefSite, ProtocolComposedGraphProp, ProtocolEventAction, ProtocolEventActionKind, ProtocolEventRecord, ProtocolPayloadScripts, ProtocolRowTemplateSlotValue, ProtocolStatePayload, ProtocolStreamedArmPatch, ProtocolSyncPolicy, ProtocolSyncPolicyBranch, ProtocolSyncPolicyCondition, ProtocolViewPayload, type ResumeRecordSet, RuntimePayloadDiagnostic, RuntimePayloadError, RuntimePayloadErrorCode, RuntimePayloadType, STORAGE_PROTOCOL_VERSION, SerializationDiagnostic, SerializationResult, SerializedGraphPayload, SerializedPrimitive, SerializedRecord, SerializedSlot, TypedArrayName, assertProtocolStateCellPayload, assertProtocolStatePayload, assertProtocolViewPayload, decodePayloadScripts, decodePayloadScriptsWithVersion, deserializeGraphValue, invalidPayloadShapeError, jsonSourceWithNonFiniteNumbers, nonFiniteName, payloadInvalidError, payloadScriptSelector, protocolElementHandleReadId, protocolEventActionKind, protocolEventDispatchesMarkless, protocolInstancePath, protocolInstanceQualifies, protocolInstanceSegment, protocolProjectionSegment, protocolRowSegment, protocolStateVersion, serializeGraphValue };
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { a as ASYNC_PROTOCOL_VERSION, i as ASYNC_BOUNDARY_ARM, n as protocolEventActionKind, o as STORAGE_PROTOCOL_VERSION, r as protocolEventDispatchesMarkless, s as protocolStateVersion, t as PROTOCOL_EVENT_ACTION_KIND } from "./protocol-BX4yw9bm.js";
1
+ import { _ as PROTOCOL_SYNC_POLICY_HOST_ATTRIBUTE, a as ASYNC_PROTOCOL_VERSION, b as PROTOCOL_VISIBLE_EVENT_NAME, c as PROTOCOL_PROPS_GRAPH_NODE_ID, d as protocolInstancePath, f as protocolInstanceQualifies, g as protocolStateVersion, h as protocolRowSegment, i as ASYNC_BOUNDARY_ARM, l as PROTOCOL_PROP_GRAPH_NODE_PREFIX, m as protocolProjectionSegment, n as protocolEventActionKind, o as PROTOCOL_EVENT_ACTION_KIND, p as protocolInstanceSegment, r as protocolEventDispatchesMarkless, s as PROTOCOL_PAGE_SPACE_ID_PREFIXES, t as protocolElementHandleReadId, u as STORAGE_PROTOCOL_VERSION, v as PROTOCOL_LOCATOR_PATHS_ATTRIBUTE, y as PROTOCOL_IDLE_EVENT_NAME } from "./protocol-BbWeZfik.js";
2
2
  import { deserializeGraphValue } from "./decode.js";
3
- import { a as assertProtocolStatePayload, c as invalidPayloadShapeError, i as assertProtocolStateCellPayload, l as payloadInvalidError, n as isValidStorageKey, o as assertProtocolViewPayload, r as RuntimePayloadError, s as decodePayloadScriptsWithVersion, t as decodePayloadScripts, u as payloadScriptSelector } from "./protocol-validation-storage-BQ8D2S5j.js";
3
+ import { a as assertProtocolStatePayload, c as invalidPayloadShapeError, i as assertProtocolStateCellPayload, l as payloadInvalidError, n as isValidStorageKey, o as assertProtocolViewPayload, r as RuntimePayloadError, s as decodePayloadScriptsWithVersion, t as decodePayloadScripts, u as payloadScriptSelector } from "./protocol-validation-storage-DhyQ9fEO.js";
4
4
  //#region src/payload-scripts.ts
5
5
  function renderPayloadScripts(input) {
6
6
  return {
@@ -14,7 +14,7 @@ function renderDataScript(type, payload) {
14
14
  return `<script type="${type}">${escapeScriptJson(JSON.stringify(payload))}<\/script>`;
15
15
  }
16
16
  function escapeScriptJson(value) {
17
- return value.replace(/</g, "\\u003C");
17
+ return value.replace(/<(?=[/!])/g, "\\u003C");
18
18
  }
19
19
  //#endregion
20
20
  //#region src/value.ts
@@ -39,7 +39,11 @@ function serializeGraphValue(value) {
39
39
  }
40
40
  function encodeSlot(value, path, seen, records, diagnostics) {
41
41
  if (value === null) return null;
42
- if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") return value;
42
+ if (typeof value === "number") return Number.isFinite(value) ? value : {
43
+ $type: "number",
44
+ value: nonFiniteName(value)
45
+ };
46
+ if (typeof value === "string" || typeof value === "boolean") return value;
43
47
  if (typeof value === "undefined") return { $type: "undefined" };
44
48
  if (typeof value === "bigint") return {
45
49
  $type: "bigint",
@@ -193,6 +197,37 @@ function encodeSlot(value, path, seen, records, diagnostics) {
193
197
  }
194
198
  return { $ref: id };
195
199
  }
200
+ function nonFiniteName(value) {
201
+ if (Number.isNaN(value)) return "NaN";
202
+ return value > 0 ? "Infinity" : "-Infinity";
203
+ }
204
+ /**
205
+ * A value printed as the JavaScript that denotes it, where JSON would print a
206
+ * non-finite number as `null`.
207
+ *
208
+ * Emitted modules are JavaScript, so the name this module gives `Infinity` /
209
+ * `-Infinity` / `NaN` denotes those values exactly. A payload with no non-finite
210
+ * number returns `JSON.stringify`'s own bytes, and `undefined` where
211
+ * `JSON.stringify` returns nothing.
212
+ */
213
+ function jsonSourceWithNonFiniteNumbers(value) {
214
+ let found = false;
215
+ const json = JSON.stringify(value, (_key, entry) => {
216
+ if (typeof entry === "number" && !Number.isFinite(entry)) found = true;
217
+ return entry;
218
+ });
219
+ if (!found) return json;
220
+ const tokens = [];
221
+ let placeholder = " markless-non-finite";
222
+ while (json !== void 0 && json.includes(placeholder)) placeholder += "_";
223
+ const tagged = JSON.stringify(value, (_key, entry) => {
224
+ if (typeof entry !== "number" || Number.isFinite(entry)) return entry;
225
+ tokens.push(nonFiniteName(entry));
226
+ return `${placeholder}${String(tokens.length - 1)}`;
227
+ });
228
+ if (tagged === void 0) return void 0;
229
+ return tokens.reduce((source, name, index) => source.replace(JSON.stringify(`${placeholder}${String(index)}`), name), tagged);
230
+ }
196
231
  function typedArrayName(value) {
197
232
  if (value instanceof Int8Array) return "Int8Array";
198
233
  if (value instanceof Uint8Array) return "Uint8Array";
@@ -303,6 +338,7 @@ function createProtocolStatePayload(input) {
303
338
  };
304
339
  }),
305
340
  computed: (input.computed ?? []).map(serializeComputedSnapshot),
341
+ ...input.sharedSeeds?.length ? { sharedSeeds: input.sharedSeeds } : {},
306
342
  sharedDefinitions: input.sharedDefinitions,
307
343
  ...storage.length > 0 ? { storage } : {}
308
344
  };
@@ -553,6 +589,12 @@ const STORAGE_SLOT_SYMBOL_KEY = "tsrx.storage/1";
553
589
  function storageAttributeName(driverKey) {
554
590
  return `data-${driverKey.replace(/[^A-Za-z0-9-]+/g, "-")}`;
555
591
  }
592
+ function storageCookieName(driverKey) {
593
+ return `markless-${encodeURIComponent(driverKey)}`;
594
+ }
595
+ function storageCookieAssignment(driverKey, value, secure) {
596
+ return `${storageCookieName(driverKey)}=${encodeURIComponent(value)};path=/;max-age=34560000;samesite=lax${secure ? ";secure" : ""}`;
597
+ }
556
598
  function storageSlotEntryKey(moduleId, key) {
557
599
  return `${moduleId}#${key}`;
558
600
  }
@@ -574,4 +616,29 @@ function createStorageSeedMetadataFromGraphNodeId(graphNodeId, driverKey, fallba
574
616
  };
575
617
  }
576
618
  //#endregion
577
- export { ASYNC_BOUNDARY_ARM, ASYNC_PROTOCOL_VERSION, PROTOCOL_EVENT_ACTION_KIND, ProtocolStateSerializationError, RuntimePayloadError, STORAGE_PROTOCOL_VERSION, STORAGE_SLOT_SYMBOL_KEY, assertProtocolStateCellPayload, assertProtocolStatePayload, assertProtocolViewPayload, classifyResumeRecordDelta, createProtocolStatePayload, createStorageSeedMetadata, createStorageSeedMetadataFromGraphNodeId, decodePayloadScripts, decodePayloadScriptsWithVersion, deserializeGraphValue, invalidPayloadShapeError, isValidStorageKey, mergeResumeRecordDelta, payloadInvalidError, payloadScriptSelector, protocolEventActionKind, protocolEventDispatchesMarkless, protocolStateVersion, renderPayloadScripts, serializeGraphValue, serializeRuntimeAsyncSnapshots, serializeRuntimeStateCells, storageAttributeName, storageSlotEntryKey, storageSlotEntryKeyFromGraphNodeId };
619
+ //#region src/storage-cookie.ts
620
+ const STORAGE_COOKIE_VALUE_LIMIT = 4096;
621
+ function decodeStorageCookieValue(raw) {
622
+ if (raw.length > STORAGE_COOKIE_VALUE_LIMIT) return void 0;
623
+ try {
624
+ return decodeURIComponent(raw);
625
+ } catch {
626
+ return;
627
+ }
628
+ }
629
+ const STORAGE_RENDER_CONTEXT_READER = "storageValue";
630
+ function createStorageCookieReader(cookieHeader) {
631
+ const prefix = storageCookieName("");
632
+ const values = /* @__PURE__ */ new Map();
633
+ for (const part of (cookieHeader ?? "").split(";")) {
634
+ const separator = part.indexOf("=");
635
+ if (separator < 0) continue;
636
+ const name = part.slice(0, separator).trim();
637
+ if (!name.startsWith(prefix) || values.has(name)) continue;
638
+ const value = decodeStorageCookieValue(part.slice(separator + 1).trim());
639
+ if (value !== void 0) values.set(name, value);
640
+ }
641
+ return (driverKey) => values.get(storageCookieName(driverKey));
642
+ }
643
+ //#endregion
644
+ export { ASYNC_BOUNDARY_ARM, ASYNC_PROTOCOL_VERSION, PROTOCOL_EVENT_ACTION_KIND, PROTOCOL_IDLE_EVENT_NAME, PROTOCOL_LOCATOR_PATHS_ATTRIBUTE, PROTOCOL_PAGE_SPACE_ID_PREFIXES, PROTOCOL_PROPS_GRAPH_NODE_ID, PROTOCOL_PROP_GRAPH_NODE_PREFIX, PROTOCOL_SYNC_POLICY_HOST_ATTRIBUTE, PROTOCOL_VISIBLE_EVENT_NAME, ProtocolStateSerializationError, RuntimePayloadError, STORAGE_PROTOCOL_VERSION, STORAGE_RENDER_CONTEXT_READER, STORAGE_SLOT_SYMBOL_KEY, assertProtocolStateCellPayload, assertProtocolStatePayload, assertProtocolViewPayload, classifyResumeRecordDelta, createProtocolStatePayload, createStorageCookieReader, createStorageSeedMetadata, createStorageSeedMetadataFromGraphNodeId, decodePayloadScripts, decodePayloadScriptsWithVersion, decodeStorageCookieValue, deserializeGraphValue, escapeScriptJson, invalidPayloadShapeError, isValidStorageKey, jsonSourceWithNonFiniteNumbers, mergeResumeRecordDelta, nonFiniteName, payloadInvalidError, payloadScriptSelector, protocolElementHandleReadId, protocolEventActionKind, protocolEventDispatchesMarkless, protocolInstancePath, protocolInstanceQualifies, protocolInstanceSegment, protocolProjectionSegment, protocolRowSegment, protocolStateVersion, renderPayloadScripts, serializeGraphValue, serializeRuntimeAsyncSnapshots, serializeRuntimeStateCells, storageAttributeName, storageCookieAssignment, storageCookieName, storageSlotEntryKey, storageSlotEntryKeyFromGraphNodeId };