@markless/serializer 0.4.0 → 0.6.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-9Mv28nr_.js +98 -0
- package/dist/protocol-BNO5JLsK.d.ts +668 -0
- package/dist/{protocol-validation-storage-DGj6FaG-.d.ts → protocol-validation-storage-B4dATVQ_.d.ts} +1 -2
- package/dist/{protocol-validation-storage-C4NuHqQw.js → protocol-validation-storage-ycVVe95T.js} +123 -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 protocolRowSegment, B as ASYNC_BOUNDARY_ARM, C as PROTOCOL_PAGE_SPACE_ID_PREFIXES, D as protocolInstanceQualifies, E as protocolInstancePath, F as PROTOCOL_CONTAINER_HOST_NODE_ID, I as PROTOCOL_CONTAINER_START_COMMENT, L as PROTOCOL_LOCATOR_PATHS_ATTRIBUTE, M as PROTOCOL_PROP_GRAPH_NODE_PREFIX, N as PROTOCOL_SYNC_POLICY_HOST_ATTRIBUTE, O as protocolInstanceSegment, P as PROTOCOL_CONTAINER_END_COMMENT, R as PROTOCOL_IDLE_EVENT_NAME, S as PROTOCOL_EVENT_ACTION_KIND, T as STORAGE_PROTOCOL_VERSION, _ 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 protocolStateVersion, k as protocolProjectionSegment, 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, z as PROTOCOL_VISIBLE_EVENT_NAME } from "./protocol-BNO5JLsK.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-B4dATVQ_.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_CONTAINER_END_COMMENT, PROTOCOL_CONTAINER_HOST_NODE_ID, PROTOCOL_CONTAINER_START_COMMENT, 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 { C as PROTOCOL_VISIBLE_EVENT_NAME, S as PROTOCOL_IDLE_EVENT_NAME, _ as PROTOCOL_SYNC_POLICY_HOST_ATTRIBUTE, a as ASYNC_PROTOCOL_VERSION, b as PROTOCOL_CONTAINER_START_COMMENT, c as PROTOCOL_PROPS_GRAPH_NODE_ID, d as protocolInstanceQualifies, f as protocolInstanceSegment, g as PROTOCOL_PROP_GRAPH_NODE_PREFIX, h as protocolStateVersion, i as ASYNC_BOUNDARY_ARM, l as STORAGE_PROTOCOL_VERSION, m as protocolRowSegment, n as protocolEventActionKind, o as PROTOCOL_EVENT_ACTION_KIND, p as protocolProjectionSegment, r as protocolEventDispatchesMarkless, s as PROTOCOL_PAGE_SPACE_ID_PREFIXES, t as protocolElementHandleReadId, u as protocolInstancePath, v as PROTOCOL_CONTAINER_END_COMMENT, x as PROTOCOL_LOCATOR_PATHS_ATTRIBUTE, y as PROTOCOL_CONTAINER_HOST_NODE_ID } from "./protocol-9Mv28nr_.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-ycVVe95T.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_CONTAINER_END_COMMENT, PROTOCOL_CONTAINER_HOST_NODE_ID, PROTOCOL_CONTAINER_START_COMMENT, 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 };
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
//#region src/protocol-event-names.ts
|
|
2
|
+
const PROTOCOL_VISIBLE_EVENT_NAME = "visible";
|
|
3
|
+
const PROTOCOL_IDLE_EVENT_NAME = "idle";
|
|
4
|
+
//#endregion
|
|
5
|
+
//#region src/protocol-locator-paths.ts
|
|
6
|
+
/**
|
|
7
|
+
* The container attribute that lets resume find each located element by its
|
|
8
|
+
* position under its parent, so a node a third-party script adds or swaps
|
|
9
|
+
* elsewhere cannot shift it. Format: protocol-locator-paths-format.ts.
|
|
10
|
+
*/
|
|
11
|
+
const PROTOCOL_LOCATOR_PATHS_ATTRIBUTE = "data-markless-paths";
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region src/protocol-page-markers.ts
|
|
14
|
+
const PROTOCOL_CONTAINER_START_COMMENT = "markless:page-start";
|
|
15
|
+
const PROTOCOL_CONTAINER_END_COMMENT = "markless:page-end";
|
|
16
|
+
const PROTOCOL_CONTAINER_HOST_NODE_ID = "container";
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/protocol-sync-policy-host.ts
|
|
19
|
+
/**
|
|
20
|
+
* The attribute the server writes on each element whose event record carries a
|
|
21
|
+
* sync policy (preventDefault, stopPropagation), valued with that record's
|
|
22
|
+
* hostNodeId. The inline boot finds the policy from the event's own target up
|
|
23
|
+
* to the nearest marked element, so it never needs the element's position.
|
|
24
|
+
*/
|
|
25
|
+
const PROTOCOL_SYNC_POLICY_HOST_ATTRIBUTE = "data-markless-sync";
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region src/protocol-prop-prefix.ts
|
|
28
|
+
const PROTOCOL_PROP_GRAPH_NODE_PREFIX = "prop:";
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/protocol-constants.ts
|
|
31
|
+
const ASYNC_PROTOCOL_VERSION = 1;
|
|
32
|
+
const STORAGE_PROTOCOL_VERSION = 2;
|
|
33
|
+
function protocolStateVersion(storage) {
|
|
34
|
+
return (storage?.length ?? 0) > 0 ? 2 : 1;
|
|
35
|
+
}
|
|
36
|
+
const PROTOCOL_EVENT_ACTION_KIND = {
|
|
37
|
+
event: "event",
|
|
38
|
+
externalDelegate: "external-delegate"
|
|
39
|
+
};
|
|
40
|
+
const PROTOCOL_INSTANCE_PATH = /^(?:[cpm]\d+:|r:[^:]*:)+/;
|
|
41
|
+
function protocolInstanceSegment(edgeIndex) {
|
|
42
|
+
return `c${edgeIndex}:`;
|
|
43
|
+
}
|
|
44
|
+
function protocolProjectionSegment(edgeIndex) {
|
|
45
|
+
return `p${edgeIndex}:`;
|
|
46
|
+
}
|
|
47
|
+
/** One keyed `@for` row's identity segment. The key is identity, never the index. */
|
|
48
|
+
function protocolRowSegment(key) {
|
|
49
|
+
return `r:${encodeURIComponent(String(key))}:`;
|
|
50
|
+
}
|
|
51
|
+
/** The leading instance path of a composed id, or '' when the id is page-local. */
|
|
52
|
+
function protocolInstancePath(id) {
|
|
53
|
+
return PROTOCOL_INSTANCE_PATH.exec(id)?.[0] ?? "";
|
|
54
|
+
}
|
|
55
|
+
const PROTOCOL_PROPS_GRAPH_NODE_ID = "prop:props";
|
|
56
|
+
const PROTOCOL_INSTANCE_QUALIFIABLE = [
|
|
57
|
+
"prop:",
|
|
58
|
+
"state:",
|
|
59
|
+
"computed:",
|
|
60
|
+
"element:"
|
|
61
|
+
];
|
|
62
|
+
const PROTOCOL_PAGE_SPACE_ID_PREFIXES = ["shared:", "storage:"];
|
|
63
|
+
function protocolInstanceQualifies(graphNodeId) {
|
|
64
|
+
const local = graphNodeId.slice(protocolInstancePath(graphNodeId).length);
|
|
65
|
+
if (PROTOCOL_PAGE_SPACE_ID_PREFIXES.some((prefix) => local.startsWith(prefix))) return false;
|
|
66
|
+
return PROTOCOL_INSTANCE_QUALIFIABLE.some((prefix) => local.startsWith(prefix)) ? true : void 0;
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region src/async-boundary-arm.ts
|
|
70
|
+
const ASYNC_BOUNDARY_ARM = {
|
|
71
|
+
try: 0,
|
|
72
|
+
pending: 1,
|
|
73
|
+
catch: 2
|
|
74
|
+
};
|
|
75
|
+
//#endregion
|
|
76
|
+
//#region src/protocol.ts
|
|
77
|
+
function protocolEventActionKind(record) {
|
|
78
|
+
return record.action?.kind ?? PROTOCOL_EVENT_ACTION_KIND.event;
|
|
79
|
+
}
|
|
80
|
+
function protocolEventDispatchesMarkless(record) {
|
|
81
|
+
return protocolEventActionKind(record) === PROTOCOL_EVENT_ACTION_KIND.event;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* The graph read id an arm-update symbol asks under for a minted element() id.
|
|
85
|
+
*
|
|
86
|
+
* A minted id is `idPrefix + handle` where the prefix is the rendered widget's
|
|
87
|
+
* instance token, a seed-map value no flip can reach. The render that served the
|
|
88
|
+
* arm resolves the id and files it on the branch record under this key; the
|
|
89
|
+
* symbol asks for it through the read channel it already has, so the mint keeps
|
|
90
|
+
* exactly one spelling. Resume matches the key as a SUFFIX of the id it is
|
|
91
|
+
* handed, because a composed symbol's reads arrive with the instance path
|
|
92
|
+
* prepended — that is why the key carries the namespace and not the bare handle.
|
|
93
|
+
*/
|
|
94
|
+
function protocolElementHandleReadId(handleGraphNodeId) {
|
|
95
|
+
return `markless:element-handle-id|${handleGraphNodeId}`;
|
|
96
|
+
}
|
|
97
|
+
//#endregion
|
|
98
|
+
export { PROTOCOL_VISIBLE_EVENT_NAME as C, PROTOCOL_IDLE_EVENT_NAME as S, PROTOCOL_SYNC_POLICY_HOST_ATTRIBUTE as _, ASYNC_PROTOCOL_VERSION as a, PROTOCOL_CONTAINER_START_COMMENT as b, PROTOCOL_PROPS_GRAPH_NODE_ID as c, protocolInstanceQualifies as d, protocolInstanceSegment as f, PROTOCOL_PROP_GRAPH_NODE_PREFIX as g, protocolStateVersion as h, ASYNC_BOUNDARY_ARM as i, STORAGE_PROTOCOL_VERSION as l, protocolRowSegment as m, protocolEventActionKind as n, PROTOCOL_EVENT_ACTION_KIND as o, protocolProjectionSegment as p, protocolEventDispatchesMarkless as r, PROTOCOL_PAGE_SPACE_ID_PREFIXES as s, protocolElementHandleReadId as t, protocolInstancePath as u, PROTOCOL_CONTAINER_END_COMMENT as v, PROTOCOL_LOCATOR_PATHS_ATTRIBUTE as x, PROTOCOL_CONTAINER_HOST_NODE_ID as y };
|