@markless/serializer 0.4.0 → 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.
- package/dist/decode-client.d.ts +4 -5
- package/dist/decode-client.js +2 -1
- package/dist/decode.d.ts +2 -2
- package/dist/decode.js +1 -0
- package/dist/index.d.ts +33 -26
- package/dist/index.js +71 -5
- package/dist/protocol-B3YIo3hD.d.ts +647 -0
- package/dist/protocol-BbWeZfik.js +91 -0
- package/dist/{protocol-validation-storage-DGj6FaG-.d.ts → protocol-validation-storage-C9YES3Zy.d.ts} +1 -2
- package/dist/{protocol-validation-storage-C4NuHqQw.js → protocol-validation-storage-DhyQ9fEO.js} +122 -13
- package/dist/protocol-validation.d.ts +1 -1
- package/dist/protocol-validation.js +1 -1
- package/dist/protocol.d.ts +2 -2
- package/dist/protocol.js +2 -2
- package/dist/{value-BJ6YNKDd.d.ts → value-CRkHmkRz.d.ts} +17 -1
- package/package.json +1 -1
- package/dist/protocol-BwMZfNSA.js +0 -56
- package/dist/protocol-CGsMO85z.d.ts +0 -363
- /package/dist/{value-decode-extensions-Bf-pgKHA.js → value-decode-extensions-xfgotsAg.js} +0 -0
package/dist/decode-client.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
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 {
|
|
9
|
+
export type { SerializedGraphPayload, SerializedRecord, SerializedSlot };
|
package/dist/decode-client.js
CHANGED
|
@@ -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-
|
|
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 {
|
|
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 { C as
|
|
2
|
-
import { a as
|
|
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-
|
|
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;
|
|
@@ -48,11 +48,11 @@ type ProtocolStatePayloadInput = {
|
|
|
48
48
|
readonly sharedDefinitions?: ProtocolStatePayload['sharedDefinitions'];
|
|
49
49
|
readonly storage?: ProtocolStatePayload['storage'];
|
|
50
50
|
};
|
|
51
|
-
type ProtocolStateSerializationDiagnostic = SerializationDiagnostic & {
|
|
51
|
+
export type ProtocolStateSerializationDiagnostic = SerializationDiagnostic & {
|
|
52
52
|
readonly graphNodeId: string;
|
|
53
53
|
readonly cellName: string;
|
|
54
54
|
};
|
|
55
|
-
declare class ProtocolStateSerializationError extends Error implements ProtocolStateSerializationDiagnostic {
|
|
55
|
+
export declare class ProtocolStateSerializationError extends Error implements ProtocolStateSerializationDiagnostic {
|
|
56
56
|
readonly code: SerializationDiagnostic['code'];
|
|
57
57
|
readonly severity: SerializationDiagnostic['severity'];
|
|
58
58
|
readonly phase: SerializationDiagnostic['phase'];
|
|
@@ -67,40 +67,47 @@ declare class ProtocolStateSerializationError extends Error implements ProtocolS
|
|
|
67
67
|
readonly cellName: string;
|
|
68
68
|
constructor(diagnostic: ProtocolStateSerializationDiagnostic);
|
|
69
69
|
}
|
|
70
|
-
declare function createProtocolStatePayload(input: ProtocolStatePayloadInput): ProtocolStatePayload;
|
|
71
|
-
declare function serializeRuntimeStateCells(cells: ProtocolStatePayload['cells']): ProtocolStatePayload['cells'];
|
|
72
|
-
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'];
|
|
73
73
|
//#endregion
|
|
74
74
|
//#region src/resume-record-merge.d.ts
|
|
75
75
|
type ResumeRecordSet = {
|
|
76
76
|
readonly state: ProtocolStatePayload;
|
|
77
77
|
readonly view: ProtocolViewPayload;
|
|
78
78
|
};
|
|
79
|
-
declare function mergeResumeRecordDelta(baseline: ResumeRecordSet, delta: ResumeRecordSet): ResumeRecordSet;
|
|
79
|
+
export declare function mergeResumeRecordDelta(baseline: ResumeRecordSet, delta: ResumeRecordSet): ResumeRecordSet;
|
|
80
80
|
//#endregion
|
|
81
81
|
//#region src/resume-record-delta.d.ts
|
|
82
|
-
type ResumeRecordDeltaClassification = {
|
|
82
|
+
export type ResumeRecordDeltaClassification = {
|
|
83
83
|
readonly kind: 'empty';
|
|
84
84
|
} | {
|
|
85
85
|
readonly kind: 'divergent';
|
|
86
86
|
readonly delta: ResumeRecordSet;
|
|
87
87
|
};
|
|
88
|
-
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;
|
|
89
94
|
//#endregion
|
|
90
95
|
//#region src/storage-key.d.ts
|
|
91
|
-
declare function isValidStorageKey(value: string): boolean;
|
|
96
|
+
export declare function isValidStorageKey(value: string): boolean;
|
|
92
97
|
//#endregion
|
|
93
98
|
//#region src/storage-slot.d.ts
|
|
94
|
-
declare const STORAGE_SLOT_SYMBOL_KEY = "tsrx.storage/1";
|
|
95
|
-
declare function storageAttributeName(driverKey: string): string;
|
|
96
|
-
|
|
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 = {
|
|
97
104
|
readonly slotKey: string;
|
|
98
105
|
readonly driverKey: string;
|
|
99
106
|
readonly fallback: string;
|
|
100
107
|
};
|
|
101
|
-
declare function storageSlotEntryKey(moduleId: string, key: string): string;
|
|
102
|
-
declare function storageSlotEntryKeyFromGraphNodeId(graphNodeId: string): string;
|
|
103
|
-
declare function createStorageSeedMetadata(moduleId: string, driverKey: string, fallback: string): StorageSeedMetadata;
|
|
104
|
-
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;
|
|
105
112
|
//#endregion
|
|
106
|
-
export { ASYNC_BOUNDARY_ARM, ASYNC_PROTOCOL_VERSION, DecodedPayloadScripts, EncodedPayloadScripts, PROTOCOL_EVENT_ACTION_KIND, PROTOCOL_PAGE_SPACE_ID_PREFIXES, PROTOCOL_PROPS_GRAPH_NODE_ID, PROTOCOL_PROP_GRAPH_NODE_PREFIX, ProtocolArmBranchRecord, ProtocolArmRecordSet, ProtocolAsyncBoundaryArm,
|
|
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
|
|
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-
|
|
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(
|
|
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 === "
|
|
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";
|
|
@@ -554,6 +589,12 @@ const STORAGE_SLOT_SYMBOL_KEY = "tsrx.storage/1";
|
|
|
554
589
|
function storageAttributeName(driverKey) {
|
|
555
590
|
return `data-${driverKey.replace(/[^A-Za-z0-9-]+/g, "-")}`;
|
|
556
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
|
+
}
|
|
557
598
|
function storageSlotEntryKey(moduleId, key) {
|
|
558
599
|
return `${moduleId}#${key}`;
|
|
559
600
|
}
|
|
@@ -575,4 +616,29 @@ function createStorageSeedMetadataFromGraphNodeId(graphNodeId, driverKey, fallba
|
|
|
575
616
|
};
|
|
576
617
|
}
|
|
577
618
|
//#endregion
|
|
578
|
-
|
|
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 };
|