@markless/serializer 0.2.1 → 0.3.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/README.md +1 -1
- package/dist/decode-client.d.ts +1 -1
- package/dist/decode-client.js +1 -1
- package/dist/decode.d.ts +1 -1
- package/dist/index.d.ts +23 -5
- package/dist/index.js +176 -3
- package/dist/protocol--6NOPwgQ.d.ts +287 -0
- package/dist/protocol-Bzvnaz87.js +28 -0
- package/dist/protocol-validation-storage-C9wAbNbb.d.ts +59 -0
- package/dist/{protocol-validation-DoQNwYjl.js → protocol-validation-storage-DBEF2IjR.js} +51 -50
- package/dist/protocol-validation.d.ts +2 -55
- package/dist/protocol-validation.js +2 -3
- package/dist/protocol.d.ts +2 -257
- package/dist/protocol.js +2 -5
- package/dist/{value-h64yUmxK.d.ts → value-BJ6YNKDd.d.ts} +4 -1
- package/package.json +21 -9
- /package/dist/{value-decode-extensions-9I1L0f-F.js → value-decode-extensions-Bf-pgKHA.js} +0 -0
package/README.md
CHANGED
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
Markless serialization tiers and the resumability payload protocol. Internal
|
|
4
4
|
implementation package of `@markless/core`.
|
|
5
5
|
|
|
6
|
-
See the repository for documentation: https://github.com/
|
|
6
|
+
See the repository for documentation: https://github.com/compiled-run/markless
|
package/dist/decode-client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as SerializedRecord, o as SerializedSlot, r as SerializedGraphPayload } from "./value-
|
|
1
|
+
import { a as SerializedRecord, o as SerializedSlot, r as SerializedGraphPayload } from "./value-BJ6YNKDd.js";
|
|
2
2
|
|
|
3
3
|
//#region src/value-decode-client.d.ts
|
|
4
4
|
type ValueDecodeExtensions = {
|
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-Bf-pgKHA.js")).valueDecodeExtensions : void 0);
|
|
4
4
|
}
|
|
5
5
|
function deserializeGraphValueWithExtensions(payload, extensions) {
|
|
6
6
|
const shells = /* @__PURE__ */ new Map();
|
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-
|
|
1
|
+
import { a as SerializedRecord, l as deserializeGraphValue, o as SerializedSlot, r as SerializedGraphPayload } from "./value-BJ6YNKDd.js";
|
|
2
2
|
export { SerializedGraphPayload, SerializedRecord, SerializedSlot, deserializeGraphValue };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ASYNC_PROTOCOL_VERSION,
|
|
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-
|
|
3
|
-
import {
|
|
1
|
+
import { _ as ASYNC_PROTOCOL_VERSION, a as ProtocolEventAction, 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 ASYNC_BOUNDARY_ARM } from "./protocol--6NOPwgQ.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-C9wAbNbb.js";
|
|
4
4
|
|
|
5
5
|
//#region src/payload-scripts.d.ts
|
|
6
6
|
type RenderPayloadScriptsInput = {
|
|
@@ -70,10 +70,28 @@ declare function createProtocolStatePayload(input: ProtocolStatePayloadInput): P
|
|
|
70
70
|
declare function serializeRuntimeStateCells(cells: ProtocolStatePayload['cells']): ProtocolStatePayload['cells'];
|
|
71
71
|
declare function serializeRuntimeAsyncSnapshots(computed: ProtocolStatePayload['computed']): ProtocolStatePayload['computed'];
|
|
72
72
|
//#endregion
|
|
73
|
+
//#region src/resume-record-merge.d.ts
|
|
74
|
+
type ResumeRecordSet = {
|
|
75
|
+
readonly state: ProtocolStatePayload;
|
|
76
|
+
readonly view: ProtocolViewPayload;
|
|
77
|
+
};
|
|
78
|
+
declare function mergeResumeRecordDelta(baseline: ResumeRecordSet, delta: ResumeRecordSet): ResumeRecordSet;
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region src/resume-record-delta.d.ts
|
|
81
|
+
type ResumeRecordDeltaClassification = {
|
|
82
|
+
readonly kind: 'empty';
|
|
83
|
+
} | {
|
|
84
|
+
readonly kind: 'divergent';
|
|
85
|
+
readonly delta: ResumeRecordSet;
|
|
86
|
+
};
|
|
87
|
+
declare function classifyResumeRecordDelta(baseline: ResumeRecordSet, request: ResumeRecordSet): ResumeRecordDeltaClassification;
|
|
88
|
+
//#endregion
|
|
89
|
+
//#region src/storage-key.d.ts
|
|
90
|
+
declare function isValidStorageKey(value: string): boolean;
|
|
91
|
+
//#endregion
|
|
73
92
|
//#region src/storage-slot.d.ts
|
|
74
93
|
declare const STORAGE_SLOT_SYMBOL_KEY = "tsrx.storage/1";
|
|
75
94
|
declare function storageAttributeName(driverKey: string): string;
|
|
76
|
-
declare function isValidStorageKey(value: string): boolean;
|
|
77
95
|
type StorageSeedMetadata = {
|
|
78
96
|
readonly slotKey: string;
|
|
79
97
|
readonly driverKey: string;
|
|
@@ -84,4 +102,4 @@ declare function storageSlotEntryKeyFromGraphNodeId(graphNodeId: string): string
|
|
|
84
102
|
declare function createStorageSeedMetadata(moduleId: string, driverKey: string, fallback: string): StorageSeedMetadata;
|
|
85
103
|
declare function createStorageSeedMetadataFromGraphNodeId(graphNodeId: string, driverKey: string, fallback: string): StorageSeedMetadata;
|
|
86
104
|
//#endregion
|
|
87
|
-
export { ASYNC_PROTOCOL_VERSION, DecodedPayloadScripts, EncodedPayloadScripts, ProtocolArmBranchRecord, ProtocolArmRecordSet, ProtocolAsyncComputedSnapshotInput, ProtocolPayloadScripts, ProtocolStatePayload, ProtocolStatePayloadInput, ProtocolStateSerializationDiagnostic, ProtocolStateSerializationError, ProtocolSyncPolicy, ProtocolSyncPolicyBranch, ProtocolSyncPolicyCondition, ProtocolViewPayload, RenderPayloadScriptsInput, RenderedPayloadScripts, RuntimePayloadDiagnostic, RuntimePayloadError, RuntimePayloadErrorCode, RuntimePayloadType, STORAGE_PROTOCOL_VERSION, STORAGE_SLOT_SYMBOL_KEY, SerializationDiagnostic, SerializationResult, SerializedGraphPayload, SerializedPrimitive, SerializedRecord, SerializedSlot, StorageSeedMetadata, TypedArrayName, assertProtocolStateCellPayload, assertProtocolStatePayload, assertProtocolViewPayload, createProtocolStatePayload, createStorageSeedMetadata, createStorageSeedMetadataFromGraphNodeId, decodePayloadScripts, deserializeGraphValue, isValidStorageKey, payloadInvalidError, payloadScriptSelector, renderPayloadScripts, serializeGraphValue, serializeRuntimeAsyncSnapshots, serializeRuntimeStateCells, storageAttributeName, storageSlotEntryKey, storageSlotEntryKeyFromGraphNodeId };
|
|
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, renderPayloadScripts, serializeGraphValue, serializeRuntimeAsyncSnapshots, serializeRuntimeStateCells, storageAttributeName, storageSlotEntryKey, storageSlotEntryKeyFromGraphNodeId };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ASYNC_PROTOCOL_VERSION, STORAGE_PROTOCOL_VERSION } from "./protocol.js";
|
|
1
|
+
import { a as ASYNC_PROTOCOL_VERSION, i as ASYNC_BOUNDARY_ARM, n as protocolEventActionKind, o as STORAGE_PROTOCOL_VERSION, r as protocolEventDispatchesMarkless, t as PROTOCOL_EVENT_ACTION_KIND } from "./protocol-Bzvnaz87.js";
|
|
2
2
|
import { deserializeGraphValue } from "./decode.js";
|
|
3
|
-
import { a as
|
|
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-DBEF2IjR.js";
|
|
4
4
|
//#region src/payload-scripts.ts
|
|
5
5
|
function renderPayloadScripts(input) {
|
|
6
6
|
return {
|
|
@@ -401,4 +401,177 @@ function protocolStateSerializationError(cell, diagnostic) {
|
|
|
401
401
|
});
|
|
402
402
|
}
|
|
403
403
|
//#endregion
|
|
404
|
-
|
|
404
|
+
//#region src/resume-record-merge.ts
|
|
405
|
+
function mergeResumeRecordDelta(baseline, delta) {
|
|
406
|
+
assertMatchingVersion$1(baseline.state.version, delta.state.version, "state");
|
|
407
|
+
assertMatchingVersion$1(baseline.view.version, delta.view.version, "view");
|
|
408
|
+
return {
|
|
409
|
+
state: {
|
|
410
|
+
...baseline.state,
|
|
411
|
+
cells: mergeRecords(baseline.state.cells, delta.state.cells, (record) => record.graphNodeId),
|
|
412
|
+
computed: mergeRecords(baseline.state.computed, delta.state.computed, (record) => record.graphNodeId),
|
|
413
|
+
...mergeOptionalRecords(baseline.state, delta.state, "sharedDefinitions", (record) => record.id),
|
|
414
|
+
...mergeOptionalRecords(baseline.state, delta.state, "storage", (record) => record.graphNodeId)
|
|
415
|
+
},
|
|
416
|
+
view: {
|
|
417
|
+
...baseline.view,
|
|
418
|
+
...mergeAsyncRunners(baseline.view, delta.view),
|
|
419
|
+
locators: mergeRecords(baseline.view.locators, delta.view.locators, (record) => record.hostNodeId),
|
|
420
|
+
events: mergeRecords(baseline.view.events, delta.view.events, (record) => `${record.hostNodeId}\0${record.eventName}`),
|
|
421
|
+
domUpdates: mergeRecords(baseline.view.domUpdates, delta.view.domUpdates, (record) => `${record.hostNodeId}\0${record.graphNodeId}\0${record.source}`),
|
|
422
|
+
behaviors: mergeRecords(baseline.view.behaviors, delta.view.behaviors, (record) => `${record.hostNodeId}\0${record.source}`),
|
|
423
|
+
elementHandles: mergeRecords(baseline.view.elementHandles, delta.view.elementHandles, (record) => `${record.hostNodeId}\0${record.handleId}`),
|
|
424
|
+
...mergeOptionalRecords(baseline.view, delta.view, "keyedRepeats", (record) => record.id),
|
|
425
|
+
...mergeOptionalRecords(baseline.view, delta.view, "branches", (record) => record.id),
|
|
426
|
+
asyncBoundaries: mergeRecords(baseline.view.asyncBoundaries, delta.view.asyncBoundaries, (record) => record.id)
|
|
427
|
+
}
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
function mergeRecords(baseline, delta, key) {
|
|
431
|
+
const byKey = uniqueRecords$1(delta, key, "payload record");
|
|
432
|
+
const merged = baseline.map((record) => byKey.get(key(record)) ?? record);
|
|
433
|
+
const baselineKeys = new Set(baseline.map(key));
|
|
434
|
+
for (const record of delta) if (!baselineKeys.has(key(record))) merged.push(record);
|
|
435
|
+
return merged;
|
|
436
|
+
}
|
|
437
|
+
function uniqueRecords$1(records, key, source) {
|
|
438
|
+
const result = /* @__PURE__ */ new Map();
|
|
439
|
+
for (const record of records) {
|
|
440
|
+
const recordKey = key(record);
|
|
441
|
+
if (result.has(recordKey)) throw new Error(`MARKLESS_RESUME_RECORD_DELTA_DUPLICATE_KEY: ${source} ${recordKey}.`);
|
|
442
|
+
result.set(recordKey, record);
|
|
443
|
+
}
|
|
444
|
+
return result;
|
|
445
|
+
}
|
|
446
|
+
function mergeOptionalRecords(baseline, delta, property, key) {
|
|
447
|
+
if (!(property in delta)) return {};
|
|
448
|
+
return { [property]: mergeRecords(baseline[property] ?? [], delta[property] ?? [], key) };
|
|
449
|
+
}
|
|
450
|
+
function mergeAsyncRunners(baseline, delta) {
|
|
451
|
+
if (!("asyncRunners" in delta)) return {};
|
|
452
|
+
return { asyncRunners: {
|
|
453
|
+
...baseline.asyncRunners,
|
|
454
|
+
...delta.asyncRunners
|
|
455
|
+
} };
|
|
456
|
+
}
|
|
457
|
+
function assertMatchingVersion$1(baseline, delta, payload) {
|
|
458
|
+
if (baseline !== delta) throw new Error(`MARKLESS_RESUME_RECORD_DELTA_VERSION_MISMATCH: ${payload} ${baseline} !== ${delta}.`);
|
|
459
|
+
}
|
|
460
|
+
//#endregion
|
|
461
|
+
//#region src/resume-record-delta.ts
|
|
462
|
+
function classifyResumeRecordDelta(baseline, request) {
|
|
463
|
+
durableComparisonValue(baseline, "build baseline");
|
|
464
|
+
durableComparisonValue(request, "request records");
|
|
465
|
+
assertMatchingVersion(baseline.state.version, request.state.version, "state");
|
|
466
|
+
assertMatchingVersion(baseline.view.version, request.view.version, "view");
|
|
467
|
+
const delta = {
|
|
468
|
+
state: {
|
|
469
|
+
version: request.state.version,
|
|
470
|
+
cells: divergentRecords(baseline.state.cells, request.state.cells, stateCellKey, "state cell"),
|
|
471
|
+
computed: divergentRecords(baseline.state.computed, request.state.computed, stateComputedKey, "computed"),
|
|
472
|
+
...optionalRecordDelta(baseline.state, request.state, "sharedDefinitions", (record) => record.id, "shared definition"),
|
|
473
|
+
...optionalRecordDelta(baseline.state, request.state, "storage", (record) => record.graphNodeId, "storage")
|
|
474
|
+
},
|
|
475
|
+
view: {
|
|
476
|
+
version: request.view.version,
|
|
477
|
+
...asyncRunnerDelta(baseline.view, request.view),
|
|
478
|
+
locators: divergentRecords(baseline.view.locators, request.view.locators, (record) => record.hostNodeId, "view locator"),
|
|
479
|
+
events: divergentRecords(baseline.view.events, request.view.events, (record) => `${record.hostNodeId}\0${record.eventName}`, "view event"),
|
|
480
|
+
domUpdates: divergentRecords(baseline.view.domUpdates, request.view.domUpdates, (record) => `${record.hostNodeId}\0${record.graphNodeId}\0${record.source}`, "DOM update"),
|
|
481
|
+
behaviors: divergentRecords(baseline.view.behaviors, request.view.behaviors, (record) => `${record.hostNodeId}\0${record.source}`, "behavior"),
|
|
482
|
+
elementHandles: divergentRecords(baseline.view.elementHandles, request.view.elementHandles, (record) => `${record.hostNodeId}\0${record.handleId}`, "element handle"),
|
|
483
|
+
...optionalRecordDelta(baseline.view, request.view, "keyedRepeats", (record) => record.id, "keyed repeat"),
|
|
484
|
+
...optionalRecordDelta(baseline.view, request.view, "branches", (record) => record.id, "branch"),
|
|
485
|
+
asyncBoundaries: divergentRecords(baseline.view.asyncBoundaries, request.view.asyncBoundaries, (record) => record.id, "async boundary")
|
|
486
|
+
}
|
|
487
|
+
};
|
|
488
|
+
return hasDeltaRecords(delta) ? {
|
|
489
|
+
kind: "divergent",
|
|
490
|
+
delta
|
|
491
|
+
} : { kind: "empty" };
|
|
492
|
+
}
|
|
493
|
+
function stateCellKey(record) {
|
|
494
|
+
return record.graphNodeId;
|
|
495
|
+
}
|
|
496
|
+
function stateComputedKey(record) {
|
|
497
|
+
return record.graphNodeId;
|
|
498
|
+
}
|
|
499
|
+
function divergentRecords(baseline, request, key, label) {
|
|
500
|
+
const baselineByKey = uniqueRecords(baseline, key, `build baseline ${label}`);
|
|
501
|
+
const requestByKey = uniqueRecords(request, key, `request ${label}`);
|
|
502
|
+
for (const baselineKey of baselineByKey.keys()) if (!requestByKey.has(baselineKey)) throw new Error(`MARKLESS_RESUME_RECORD_DELTA_REMOVAL_UNSUPPORTED: ${label} ${baselineKey}.`);
|
|
503
|
+
return request.filter((record) => {
|
|
504
|
+
const baselineRecord = baselineByKey.get(key(record));
|
|
505
|
+
return baselineRecord === void 0 || durableComparisonValue(baselineRecord, `build baseline ${label}`) !== durableComparisonValue(record, `request ${label}`);
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
function uniqueRecords(records, key, source) {
|
|
509
|
+
const result = /* @__PURE__ */ new Map();
|
|
510
|
+
for (const record of records) {
|
|
511
|
+
const recordKey = key(record);
|
|
512
|
+
if (result.has(recordKey)) throw new Error(`MARKLESS_RESUME_RECORD_DELTA_DUPLICATE_KEY: ${source} ${recordKey}.`);
|
|
513
|
+
result.set(recordKey, record);
|
|
514
|
+
}
|
|
515
|
+
return result;
|
|
516
|
+
}
|
|
517
|
+
function optionalRecordDelta(baseline, request, property, key, label) {
|
|
518
|
+
const baselineRecords = baseline[property];
|
|
519
|
+
const requestRecords = request[property];
|
|
520
|
+
if (requestRecords === void 0) {
|
|
521
|
+
if (baselineRecords !== void 0) throw new Error(`MARKLESS_RESUME_RECORD_DELTA_REMOVAL_UNSUPPORTED: ${label} set.`);
|
|
522
|
+
return {};
|
|
523
|
+
}
|
|
524
|
+
return { [property]: divergentRecords(baselineRecords ?? [], requestRecords, key, label) };
|
|
525
|
+
}
|
|
526
|
+
function asyncRunnerDelta(baseline, request) {
|
|
527
|
+
if (request.asyncRunners === void 0) {
|
|
528
|
+
if (baseline.asyncRunners !== void 0) throw new Error("MARKLESS_RESUME_RECORD_DELTA_REMOVAL_UNSUPPORTED: async runner set.");
|
|
529
|
+
return {};
|
|
530
|
+
}
|
|
531
|
+
const delta = {};
|
|
532
|
+
for (const key of Object.keys(baseline.asyncRunners ?? {})) if (!(key in request.asyncRunners)) throw new Error(`MARKLESS_RESUME_RECORD_DELTA_REMOVAL_UNSUPPORTED: async runner ${key}.`);
|
|
533
|
+
for (const [key, value] of Object.entries(request.asyncRunners)) if (baseline.asyncRunners?.[key] !== value) delta[key] = value;
|
|
534
|
+
return { asyncRunners: delta };
|
|
535
|
+
}
|
|
536
|
+
function hasDeltaRecords(delta) {
|
|
537
|
+
return delta.state.cells.length > 0 || delta.state.computed.length > 0 || (delta.state.sharedDefinitions?.length ?? 0) > 0 || (delta.state.storage?.length ?? 0) > 0 || Object.keys(delta.view.asyncRunners ?? {}).length > 0 || delta.view.locators.length > 0 || delta.view.events.length > 0 || delta.view.domUpdates.length > 0 || delta.view.behaviors.length > 0 || delta.view.elementHandles.length > 0 || (delta.view.keyedRepeats?.length ?? 0) > 0 || (delta.view.branches?.length ?? 0) > 0 || delta.view.asyncBoundaries.length > 0;
|
|
538
|
+
}
|
|
539
|
+
function assertMatchingVersion(baseline, request, payload) {
|
|
540
|
+
if (baseline !== request) throw new Error(`MARKLESS_RESUME_RECORD_DELTA_VERSION_MISMATCH: ${payload} ${baseline} !== ${request}.`);
|
|
541
|
+
}
|
|
542
|
+
function durableComparisonValue(value, source) {
|
|
543
|
+
const result = serializeGraphValue(value);
|
|
544
|
+
if (!result.ok) {
|
|
545
|
+
const diagnostic = result.diagnostics[0];
|
|
546
|
+
throw new Error(`MARKLESS_RESUME_RECORD_DIVERGENCE_UNSERIALIZABLE: ${source} contains ${diagnostic?.valueKind ?? "unsupported"} at ${diagnostic?.statePath ?? "<root>"}.`);
|
|
547
|
+
}
|
|
548
|
+
return JSON.stringify(result.payload);
|
|
549
|
+
}
|
|
550
|
+
//#endregion
|
|
551
|
+
//#region src/storage-slot.ts
|
|
552
|
+
const STORAGE_SLOT_SYMBOL_KEY = "tsrx.storage/1";
|
|
553
|
+
function storageAttributeName(driverKey) {
|
|
554
|
+
return `data-${driverKey.replace(/[^A-Za-z0-9-]+/g, "-")}`;
|
|
555
|
+
}
|
|
556
|
+
function storageSlotEntryKey(moduleId, key) {
|
|
557
|
+
return `${moduleId}#${key}`;
|
|
558
|
+
}
|
|
559
|
+
function storageSlotEntryKeyFromGraphNodeId(graphNodeId) {
|
|
560
|
+
return graphNodeId.startsWith("storage:") ? graphNodeId.slice(8) : graphNodeId;
|
|
561
|
+
}
|
|
562
|
+
function createStorageSeedMetadata(moduleId, driverKey, fallback) {
|
|
563
|
+
return {
|
|
564
|
+
slotKey: storageSlotEntryKey(moduleId, driverKey),
|
|
565
|
+
driverKey,
|
|
566
|
+
fallback
|
|
567
|
+
};
|
|
568
|
+
}
|
|
569
|
+
function createStorageSeedMetadataFromGraphNodeId(graphNodeId, driverKey, fallback) {
|
|
570
|
+
return {
|
|
571
|
+
slotKey: storageSlotEntryKeyFromGraphNodeId(graphNodeId),
|
|
572
|
+
driverKey,
|
|
573
|
+
fallback
|
|
574
|
+
};
|
|
575
|
+
}
|
|
576
|
+
//#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, renderPayloadScripts, serializeGraphValue, serializeRuntimeAsyncSnapshots, serializeRuntimeStateCells, storageAttributeName, storageSlotEntryKey, storageSlotEntryKeyFromGraphNodeId };
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
//#region src/async-boundary-arm.d.ts
|
|
2
|
+
declare const ASYNC_BOUNDARY_ARM: {
|
|
3
|
+
readonly try: 0;
|
|
4
|
+
readonly pending: 1;
|
|
5
|
+
readonly catch: 2;
|
|
6
|
+
};
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region src/protocol-constants.d.ts
|
|
9
|
+
declare const ASYNC_PROTOCOL_VERSION = 1;
|
|
10
|
+
declare const STORAGE_PROTOCOL_VERSION = 2;
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/protocol.d.ts
|
|
13
|
+
type ProtocolAsyncBoundaryArm = (typeof ASYNC_BOUNDARY_ARM)[keyof typeof ASYNC_BOUNDARY_ARM];
|
|
14
|
+
type ProtocolSyncPolicyCondition = {
|
|
15
|
+
readonly type: 'and';
|
|
16
|
+
readonly conditions: ReadonlyArray<ProtocolSyncPolicyCondition>;
|
|
17
|
+
} | {
|
|
18
|
+
readonly type: 'or';
|
|
19
|
+
readonly conditions: ReadonlyArray<ProtocolSyncPolicyCondition>;
|
|
20
|
+
} | {
|
|
21
|
+
readonly type: 'not';
|
|
22
|
+
readonly condition: ProtocolSyncPolicyCondition;
|
|
23
|
+
} | {
|
|
24
|
+
readonly type: 'graph-truthy';
|
|
25
|
+
readonly graphNodeId: string;
|
|
26
|
+
readonly path?: ReadonlyArray<string>;
|
|
27
|
+
} | {
|
|
28
|
+
readonly type: 'constant-truthy';
|
|
29
|
+
readonly value: unknown;
|
|
30
|
+
} | {
|
|
31
|
+
readonly type: 'event-equals';
|
|
32
|
+
readonly field: string;
|
|
33
|
+
readonly value: unknown;
|
|
34
|
+
};
|
|
35
|
+
type ProtocolSyncPolicyBranch = {
|
|
36
|
+
readonly when: ProtocolSyncPolicyCondition;
|
|
37
|
+
readonly actions: ReadonlyArray<'preventDefault' | 'stopPropagation'>;
|
|
38
|
+
};
|
|
39
|
+
type ProtocolSyncPolicy = ProtocolSyncPolicyBranch | {
|
|
40
|
+
readonly branches: ReadonlyArray<ProtocolSyncPolicyBranch>;
|
|
41
|
+
};
|
|
42
|
+
declare const PROTOCOL_EVENT_ACTION_KIND: {
|
|
43
|
+
readonly event: "event";
|
|
44
|
+
readonly externalDelegate: "external-delegate";
|
|
45
|
+
};
|
|
46
|
+
type ProtocolEventActionKind = (typeof PROTOCOL_EVENT_ACTION_KIND)[keyof typeof PROTOCOL_EVENT_ACTION_KIND];
|
|
47
|
+
type ProtocolEventAction = {
|
|
48
|
+
readonly kind: typeof PROTOCOL_EVENT_ACTION_KIND.externalDelegate;
|
|
49
|
+
readonly owner: string;
|
|
50
|
+
};
|
|
51
|
+
type ProtocolEventRecord = {
|
|
52
|
+
readonly hostNodeId: string;
|
|
53
|
+
readonly eventName: string;
|
|
54
|
+
readonly syncPolicy?: ProtocolSyncPolicy;
|
|
55
|
+
readonly symbolIds: ReadonlyArray<string>;
|
|
56
|
+
readonly action?: ProtocolEventAction;
|
|
57
|
+
};
|
|
58
|
+
declare function protocolEventActionKind(record: Pick<ProtocolEventRecord, 'action'>): ProtocolEventActionKind;
|
|
59
|
+
declare function protocolEventDispatchesMarkless(record: Pick<ProtocolEventRecord, 'action'>): boolean;
|
|
60
|
+
type ProtocolStatePayload = {
|
|
61
|
+
readonly version: typeof ASYNC_PROTOCOL_VERSION | typeof STORAGE_PROTOCOL_VERSION;
|
|
62
|
+
readonly cells: ReadonlyArray<{
|
|
63
|
+
readonly graphNodeId: string;
|
|
64
|
+
readonly name: string;
|
|
65
|
+
readonly valueKind: 'scalar' | 'object' | 'array' | 'unknown';
|
|
66
|
+
readonly value?: unknown;
|
|
67
|
+
readonly directValue?: unknown;
|
|
68
|
+
}>;
|
|
69
|
+
readonly computed: ReadonlyArray<{
|
|
70
|
+
readonly graphNodeId: string;
|
|
71
|
+
readonly name: string;
|
|
72
|
+
readonly async: boolean;
|
|
73
|
+
readonly deriveSymbolId?: string;
|
|
74
|
+
readonly dependencies?: ReadonlyArray<{
|
|
75
|
+
readonly graphNodeId: string;
|
|
76
|
+
readonly path: ReadonlyArray<string>;
|
|
77
|
+
}>;
|
|
78
|
+
readonly snapshot?: {
|
|
79
|
+
readonly status: 'idle';
|
|
80
|
+
readonly version: 0;
|
|
81
|
+
} | {
|
|
82
|
+
readonly status: 'pending';
|
|
83
|
+
readonly version: number;
|
|
84
|
+
readonly key: unknown;
|
|
85
|
+
} | {
|
|
86
|
+
readonly status: 'fulfilled';
|
|
87
|
+
readonly version: number;
|
|
88
|
+
readonly key: unknown;
|
|
89
|
+
readonly value: unknown;
|
|
90
|
+
} | {
|
|
91
|
+
readonly status: 'rejected';
|
|
92
|
+
readonly version: number;
|
|
93
|
+
readonly key: unknown;
|
|
94
|
+
readonly error: unknown;
|
|
95
|
+
};
|
|
96
|
+
}>;
|
|
97
|
+
readonly sharedDefinitions?: ReadonlyArray<{
|
|
98
|
+
readonly id: string;
|
|
99
|
+
readonly name: string;
|
|
100
|
+
readonly exportedName: string;
|
|
101
|
+
readonly scope?: 'request' | 'container' | 'page';
|
|
102
|
+
readonly version: number;
|
|
103
|
+
readonly graphNodeIds: ReadonlyArray<string>;
|
|
104
|
+
readonly dependencies?: ReadonlyArray<{
|
|
105
|
+
readonly definitionId: string;
|
|
106
|
+
readonly definitionName: string;
|
|
107
|
+
}>;
|
|
108
|
+
readonly returnProperties?: ReadonlyArray<{
|
|
109
|
+
readonly kind: 'graph';
|
|
110
|
+
readonly name: string;
|
|
111
|
+
readonly graphNodeId: string;
|
|
112
|
+
readonly path: ReadonlyArray<string>;
|
|
113
|
+
} | {
|
|
114
|
+
readonly kind: 'method';
|
|
115
|
+
readonly name: string;
|
|
116
|
+
}>;
|
|
117
|
+
}>;
|
|
118
|
+
readonly storage?: ReadonlyArray<{
|
|
119
|
+
readonly graphNodeId: string;
|
|
120
|
+
readonly key: string;
|
|
121
|
+
}>;
|
|
122
|
+
};
|
|
123
|
+
type ProtocolArmBranchRecord = {
|
|
124
|
+
readonly id: string;
|
|
125
|
+
readonly testReads: ReadonlyArray<{
|
|
126
|
+
readonly source: string;
|
|
127
|
+
readonly graphNodeId: string;
|
|
128
|
+
readonly path: ReadonlyArray<string>;
|
|
129
|
+
}>;
|
|
130
|
+
readonly symbolId?: string;
|
|
131
|
+
readonly armTests?: ReadonlyArray<unknown>;
|
|
132
|
+
readonly declaredEmptyArms?: ReadonlyArray<number>;
|
|
133
|
+
readonly startAnchor?: {
|
|
134
|
+
readonly strategy: 'arm-branch-comment';
|
|
135
|
+
readonly index: number;
|
|
136
|
+
};
|
|
137
|
+
readonly endAnchor?: {
|
|
138
|
+
readonly strategy: 'arm-branch-comment';
|
|
139
|
+
readonly index: number;
|
|
140
|
+
};
|
|
141
|
+
readonly armRecords?: NonNullable<ProtocolViewPayload['branches']>[number]['armRecords'];
|
|
142
|
+
};
|
|
143
|
+
type ProtocolArmRecordSet = {
|
|
144
|
+
readonly locators: ReadonlyArray<{
|
|
145
|
+
readonly hostNodeId: string;
|
|
146
|
+
readonly strategy: 'arm-relative';
|
|
147
|
+
readonly index: number;
|
|
148
|
+
readonly tagName: string;
|
|
149
|
+
}>;
|
|
150
|
+
readonly events: ProtocolViewPayload['events'];
|
|
151
|
+
readonly domUpdates?: ProtocolViewPayload['domUpdates'];
|
|
152
|
+
readonly behaviors: ProtocolViewPayload['behaviors'];
|
|
153
|
+
readonly elementHandles: ProtocolViewPayload['elementHandles'];
|
|
154
|
+
readonly keyedRepeats?: ProtocolViewPayload['keyedRepeats'];
|
|
155
|
+
readonly branches?: ReadonlyArray<ProtocolArmBranchRecord>;
|
|
156
|
+
};
|
|
157
|
+
type ProtocolStreamedArmPatch = readonly [arm: ProtocolAsyncBoundaryArm, records: ProtocolArmRecordSet];
|
|
158
|
+
type ProtocolViewPayload = {
|
|
159
|
+
readonly version: typeof ASYNC_PROTOCOL_VERSION;
|
|
160
|
+
readonly asyncRunners?: Readonly<Record<string, string>>;
|
|
161
|
+
readonly locators: ReadonlyArray<{
|
|
162
|
+
readonly hostNodeId: string;
|
|
163
|
+
readonly strategy: 'dom-order';
|
|
164
|
+
readonly index: number;
|
|
165
|
+
readonly tagName: string;
|
|
166
|
+
}>;
|
|
167
|
+
readonly events: ReadonlyArray<ProtocolEventRecord>;
|
|
168
|
+
readonly domUpdates: ReadonlyArray<{
|
|
169
|
+
readonly hostNodeId: string;
|
|
170
|
+
readonly source: string;
|
|
171
|
+
readonly graphNodeId: string;
|
|
172
|
+
readonly path: ReadonlyArray<string>;
|
|
173
|
+
readonly target?: {
|
|
174
|
+
readonly kind: 'text';
|
|
175
|
+
readonly prefix?: string;
|
|
176
|
+
readonly suffix?: string;
|
|
177
|
+
readonly trueValue?: string;
|
|
178
|
+
readonly falseValue?: string;
|
|
179
|
+
} | {
|
|
180
|
+
readonly kind: 'attribute';
|
|
181
|
+
readonly name: string;
|
|
182
|
+
} | {
|
|
183
|
+
readonly kind: 'property';
|
|
184
|
+
readonly name: string;
|
|
185
|
+
} | {
|
|
186
|
+
readonly kind: 'class';
|
|
187
|
+
readonly trueValue?: string;
|
|
188
|
+
readonly falseValue?: string;
|
|
189
|
+
} | {
|
|
190
|
+
readonly kind: 'style';
|
|
191
|
+
};
|
|
192
|
+
readonly symbolId?: string;
|
|
193
|
+
}>;
|
|
194
|
+
readonly behaviors: ReadonlyArray<{
|
|
195
|
+
readonly hostNodeId: string;
|
|
196
|
+
readonly source: string;
|
|
197
|
+
readonly functionSource: string;
|
|
198
|
+
readonly inputSources: ReadonlyArray<string>;
|
|
199
|
+
readonly inputValues?: ReadonlyArray<unknown>;
|
|
200
|
+
readonly inputGraphReads?: ReadonlyArray<{
|
|
201
|
+
readonly inputIndex: number;
|
|
202
|
+
readonly source: string;
|
|
203
|
+
readonly graphNodeId: string;
|
|
204
|
+
readonly path: ReadonlyArray<string>;
|
|
205
|
+
}>;
|
|
206
|
+
readonly symbolId?: string;
|
|
207
|
+
}>;
|
|
208
|
+
readonly elementHandles: ReadonlyArray<{
|
|
209
|
+
readonly hostNodeId: string;
|
|
210
|
+
readonly handleId: string;
|
|
211
|
+
readonly name: string;
|
|
212
|
+
}>;
|
|
213
|
+
readonly keyedRepeats?: ReadonlyArray<{
|
|
214
|
+
readonly id: string;
|
|
215
|
+
readonly parentHostNodeId: string;
|
|
216
|
+
readonly collectionGraphNodeId?: string;
|
|
217
|
+
readonly collectionPath: ReadonlyArray<string>;
|
|
218
|
+
readonly keyPath: ReadonlyArray<string>;
|
|
219
|
+
readonly itemName: string;
|
|
220
|
+
readonly rowElementCount: number;
|
|
221
|
+
readonly rowEvents: ReadonlyArray<{
|
|
222
|
+
readonly hostPath: ReadonlyArray<number>;
|
|
223
|
+
readonly eventName: string;
|
|
224
|
+
readonly symbolIds: ReadonlyArray<string>;
|
|
225
|
+
readonly syncPolicy?: ProtocolSyncPolicy;
|
|
226
|
+
}>;
|
|
227
|
+
}>;
|
|
228
|
+
readonly branches?: ReadonlyArray<{
|
|
229
|
+
readonly id: string;
|
|
230
|
+
readonly startAnchor: {
|
|
231
|
+
readonly strategy: 'dom-order-comment';
|
|
232
|
+
readonly index: number;
|
|
233
|
+
};
|
|
234
|
+
readonly endAnchor: {
|
|
235
|
+
readonly strategy: 'dom-order-comment';
|
|
236
|
+
readonly index: number;
|
|
237
|
+
};
|
|
238
|
+
readonly symbolId?: string;
|
|
239
|
+
readonly armTests?: ReadonlyArray<unknown>;
|
|
240
|
+
readonly armRecords?: ReadonlyArray<{
|
|
241
|
+
readonly events: ReadonlyArray<{
|
|
242
|
+
readonly hostPath: ReadonlyArray<number>;
|
|
243
|
+
readonly eventName: string;
|
|
244
|
+
readonly symbolIds: ReadonlyArray<string>;
|
|
245
|
+
readonly syncPolicy?: ProtocolSyncPolicy;
|
|
246
|
+
readonly action?: ProtocolEventAction;
|
|
247
|
+
}>;
|
|
248
|
+
readonly domUpdates: ReadonlyArray<Record<string, unknown>>;
|
|
249
|
+
readonly behaviors: ReadonlyArray<Record<string, unknown>>;
|
|
250
|
+
readonly elementHandles: ReadonlyArray<Record<string, unknown>>;
|
|
251
|
+
}>;
|
|
252
|
+
readonly testReads?: ReadonlyArray<{
|
|
253
|
+
readonly source: string;
|
|
254
|
+
readonly graphNodeId: string;
|
|
255
|
+
readonly path: ReadonlyArray<string>;
|
|
256
|
+
}>;
|
|
257
|
+
}>;
|
|
258
|
+
readonly asyncBoundaries: ReadonlyArray<{
|
|
259
|
+
readonly id: string;
|
|
260
|
+
readonly runnerGraphNodeId: string | null;
|
|
261
|
+
readonly initiallyServedArm: ProtocolAsyncBoundaryArm;
|
|
262
|
+
readonly updateSymbolId?: string;
|
|
263
|
+
readonly armRecords?: ProtocolArmRecordSet | ReadonlyArray<ProtocolArmRecordSet>;
|
|
264
|
+
readonly startAnchor: {
|
|
265
|
+
readonly strategy: 'dom-order-comment';
|
|
266
|
+
readonly index: number;
|
|
267
|
+
};
|
|
268
|
+
readonly endAnchor: {
|
|
269
|
+
readonly strategy: 'dom-order-comment';
|
|
270
|
+
readonly index: number;
|
|
271
|
+
};
|
|
272
|
+
readonly asyncReads: ReadonlyArray<{
|
|
273
|
+
readonly source: string;
|
|
274
|
+
readonly graphNodeId: string;
|
|
275
|
+
readonly path: ReadonlyArray<string>;
|
|
276
|
+
readonly runnerSymbolId?: string;
|
|
277
|
+
}>;
|
|
278
|
+
}>;
|
|
279
|
+
};
|
|
280
|
+
type ProtocolPayloadScripts = {
|
|
281
|
+
readonly state: ProtocolStatePayload;
|
|
282
|
+
readonly view: ProtocolViewPayload;
|
|
283
|
+
readonly stateScript: string;
|
|
284
|
+
readonly viewScript: string;
|
|
285
|
+
};
|
|
286
|
+
//#endregion
|
|
287
|
+
export { ASYNC_PROTOCOL_VERSION as _, ProtocolEventAction as a, ProtocolPayloadScripts as c, ProtocolSyncPolicy as d, ProtocolSyncPolicyBranch as f, protocolEventDispatchesMarkless as g, protocolEventActionKind as h, ProtocolAsyncBoundaryArm as i, ProtocolStatePayload as l, ProtocolViewPayload as m, ProtocolArmBranchRecord as n, ProtocolEventActionKind as o, ProtocolSyncPolicyCondition as p, ProtocolArmRecordSet as r, ProtocolEventRecord as s, PROTOCOL_EVENT_ACTION_KIND as t, ProtocolStreamedArmPatch as u, STORAGE_PROTOCOL_VERSION as v, ASYNC_BOUNDARY_ARM as y };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//#region src/protocol-constants.ts
|
|
2
|
+
const ASYNC_PROTOCOL_VERSION = 1;
|
|
3
|
+
const STORAGE_PROTOCOL_VERSION = 2;
|
|
4
|
+
//#endregion
|
|
5
|
+
//#region src/async-boundary-arm.ts
|
|
6
|
+
const ASYNC_BOUNDARY_ARM = {
|
|
7
|
+
try: 0,
|
|
8
|
+
pending: 1,
|
|
9
|
+
catch: 2
|
|
10
|
+
};
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/protocol.ts
|
|
13
|
+
const PROTOCOL_EVENT_ACTION_KIND = {
|
|
14
|
+
event: "event",
|
|
15
|
+
externalDelegate: "external-delegate"
|
|
16
|
+
};
|
|
17
|
+
function protocolEventActionKind(record) {
|
|
18
|
+
return record.action?.kind ?? PROTOCOL_EVENT_ACTION_KIND.event;
|
|
19
|
+
}
|
|
20
|
+
const PROTOCOL_EVENT_ACTION_DISPATCHES_MARKLESS = {
|
|
21
|
+
[PROTOCOL_EVENT_ACTION_KIND.event]: true,
|
|
22
|
+
[PROTOCOL_EVENT_ACTION_KIND.externalDelegate]: false
|
|
23
|
+
};
|
|
24
|
+
function protocolEventDispatchesMarkless(record) {
|
|
25
|
+
return PROTOCOL_EVENT_ACTION_DISPATCHES_MARKLESS[protocolEventActionKind(record)];
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { ASYNC_PROTOCOL_VERSION as a, ASYNC_BOUNDARY_ARM as i, protocolEventActionKind as n, STORAGE_PROTOCOL_VERSION as o, protocolEventDispatchesMarkless as r, PROTOCOL_EVENT_ACTION_KIND as t };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { l as ProtocolStatePayload, m as ProtocolViewPayload } from "./protocol--6NOPwgQ.js";
|
|
2
|
+
|
|
3
|
+
//#region src/protocol-validation.d.ts
|
|
4
|
+
type EncodedPayloadScripts = {
|
|
5
|
+
readonly stateScript: string;
|
|
6
|
+
readonly viewScript: string;
|
|
7
|
+
};
|
|
8
|
+
type DecodedPayloadScripts = {
|
|
9
|
+
readonly state: ProtocolStatePayload;
|
|
10
|
+
readonly view: ProtocolViewPayload;
|
|
11
|
+
};
|
|
12
|
+
type RuntimePayloadType = 'markless/state' | 'markless/view';
|
|
13
|
+
type RuntimePayloadErrorCode = 'MARKLESS_PAYLOAD_INVALID' | 'MARKLESS_PROTOCOL_VERSION_MISMATCH';
|
|
14
|
+
type RuntimePayloadDiagnostic = {
|
|
15
|
+
readonly code: RuntimePayloadErrorCode;
|
|
16
|
+
readonly severity: 'error';
|
|
17
|
+
readonly phase: 'payload';
|
|
18
|
+
readonly title: string;
|
|
19
|
+
readonly message: string;
|
|
20
|
+
readonly why: string;
|
|
21
|
+
readonly payloadType: RuntimePayloadType;
|
|
22
|
+
readonly payloadScript: string;
|
|
23
|
+
readonly expectedVersion?: number;
|
|
24
|
+
readonly actualVersion?: unknown;
|
|
25
|
+
readonly suggestions: ReadonlyArray<{
|
|
26
|
+
readonly message: string;
|
|
27
|
+
}>;
|
|
28
|
+
readonly docsUrl: string;
|
|
29
|
+
};
|
|
30
|
+
declare class RuntimePayloadError extends Error implements RuntimePayloadDiagnostic {
|
|
31
|
+
readonly code: RuntimePayloadErrorCode;
|
|
32
|
+
readonly severity: 'error';
|
|
33
|
+
readonly phase: 'payload';
|
|
34
|
+
readonly title: string;
|
|
35
|
+
readonly why: string;
|
|
36
|
+
readonly payloadType: RuntimePayloadType;
|
|
37
|
+
readonly payloadScript: string;
|
|
38
|
+
readonly expectedVersion?: number;
|
|
39
|
+
readonly actualVersion?: unknown;
|
|
40
|
+
readonly suggestions: ReadonlyArray<{
|
|
41
|
+
readonly message: string;
|
|
42
|
+
}>;
|
|
43
|
+
readonly docsUrl: string;
|
|
44
|
+
constructor(diagnostic: RuntimePayloadDiagnostic);
|
|
45
|
+
}
|
|
46
|
+
declare function decodePayloadScriptsWithVersion(input: EncodedPayloadScripts, allowStorage: boolean): DecodedPayloadScripts;
|
|
47
|
+
declare function assertProtocolStatePayload(payload: unknown): asserts payload is ProtocolStatePayload;
|
|
48
|
+
declare function assertProtocolStateCellPayload(cell: unknown, context: string): asserts cell is ProtocolStatePayload['cells'][number];
|
|
49
|
+
declare function assertProtocolViewPayload(payload: unknown): asserts payload is ProtocolViewPayload;
|
|
50
|
+
declare function payloadInvalidError(payloadType: RuntimePayloadType, message: string, why: string, suggestions: ReadonlyArray<{
|
|
51
|
+
readonly message: string;
|
|
52
|
+
}>): RuntimePayloadError;
|
|
53
|
+
declare function invalidPayloadShapeError(payloadType: RuntimePayloadType, message: string): RuntimePayloadError;
|
|
54
|
+
declare function payloadScriptSelector(type: RuntimePayloadType): string;
|
|
55
|
+
//#endregion
|
|
56
|
+
//#region src/protocol-validation-storage.d.ts
|
|
57
|
+
declare function decodePayloadScripts(input: EncodedPayloadScripts): DecodedPayloadScripts;
|
|
58
|
+
//#endregion
|
|
59
|
+
export { RuntimePayloadError as a, assertProtocolStateCellPayload as c, decodePayloadScriptsWithVersion as d, invalidPayloadShapeError as f, RuntimePayloadDiagnostic as i, assertProtocolStatePayload as l, payloadScriptSelector as m, DecodedPayloadScripts as n, RuntimePayloadErrorCode as o, payloadInvalidError as p, EncodedPayloadScripts as r, RuntimePayloadType as s, decodePayloadScripts as t, assertProtocolViewPayload as u };
|
|
@@ -1,34 +1,4 @@
|
|
|
1
|
-
import "./protocol.js";
|
|
2
|
-
//#region src/storage-slot.ts
|
|
3
|
-
const STORAGE_SLOT_SYMBOL_KEY = "tsrx.storage/1";
|
|
4
|
-
function storageAttributeName(driverKey) {
|
|
5
|
-
return `data-${driverKey.replace(/[^A-Za-z0-9-]+/g, "-")}`;
|
|
6
|
-
}
|
|
7
|
-
const STORAGE_KEY_PATTERN = /^[A-Za-z0-9$_:.-]+$/;
|
|
8
|
-
function isValidStorageKey(value) {
|
|
9
|
-
return STORAGE_KEY_PATTERN.test(value);
|
|
10
|
-
}
|
|
11
|
-
function storageSlotEntryKey(moduleId, key) {
|
|
12
|
-
return `${moduleId}#${key}`;
|
|
13
|
-
}
|
|
14
|
-
function storageSlotEntryKeyFromGraphNodeId(graphNodeId) {
|
|
15
|
-
return graphNodeId.startsWith("storage:") ? graphNodeId.slice(8) : graphNodeId;
|
|
16
|
-
}
|
|
17
|
-
function createStorageSeedMetadata(moduleId, driverKey, fallback) {
|
|
18
|
-
return {
|
|
19
|
-
slotKey: storageSlotEntryKey(moduleId, driverKey),
|
|
20
|
-
driverKey,
|
|
21
|
-
fallback
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
function createStorageSeedMetadataFromGraphNodeId(graphNodeId, driverKey, fallback) {
|
|
25
|
-
return {
|
|
26
|
-
slotKey: storageSlotEntryKeyFromGraphNodeId(graphNodeId),
|
|
27
|
-
driverKey,
|
|
28
|
-
fallback
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
//#endregion
|
|
1
|
+
import { i as ASYNC_BOUNDARY_ARM, t as PROTOCOL_EVENT_ACTION_KIND } from "./protocol-Bzvnaz87.js";
|
|
32
2
|
//#region src/protocol-validation.ts
|
|
33
3
|
var RuntimePayloadError = class extends Error {
|
|
34
4
|
constructor(diagnostic) {
|
|
@@ -39,12 +9,12 @@ var RuntimePayloadError = class extends Error {
|
|
|
39
9
|
}, diagnostic, { name: "RuntimePayloadError" });
|
|
40
10
|
}
|
|
41
11
|
};
|
|
42
|
-
function
|
|
12
|
+
function decodePayloadScriptsWithVersion(input, allowStorage) {
|
|
43
13
|
const state = parseDataScript(input.stateScript, "markless/state");
|
|
44
14
|
const view = parseDataScript(input.viewScript, "markless/view");
|
|
45
15
|
assertProtocolStatePayload(state);
|
|
46
16
|
assertProtocolViewPayload(view);
|
|
47
|
-
assertProtocolVersion(state.version, "markless/state");
|
|
17
|
+
assertProtocolVersion(state.version, "markless/state", allowStorage);
|
|
48
18
|
assertProtocolVersion(view.version, "markless/view");
|
|
49
19
|
return {
|
|
50
20
|
state,
|
|
@@ -76,7 +46,6 @@ function assertProtocolStatePayload(payload) {
|
|
|
76
46
|
assertOptionalAsyncComputedSnapshot(computed, context);
|
|
77
47
|
}
|
|
78
48
|
assertOptionalSharedDefinitions(payload);
|
|
79
|
-
assertStorageRecords(payload);
|
|
80
49
|
}
|
|
81
50
|
function assertProtocolStateCellPayload(cell, context) {
|
|
82
51
|
assertRecordShape(cell, context);
|
|
@@ -110,6 +79,7 @@ function assertProtocolViewPayload(payload) {
|
|
|
110
79
|
assertStringField(event, "hostNodeId", context);
|
|
111
80
|
assertStringField(event, "eventName", context);
|
|
112
81
|
assertStringArrayField(event, "symbolIds", context);
|
|
82
|
+
assertOptionalEventAction(event.action, `${context}.action`);
|
|
113
83
|
if (event.syncPolicy !== void 0) assertSyncPolicy(event.syncPolicy, `${context}.syncPolicy`);
|
|
114
84
|
}
|
|
115
85
|
for (const [index, domUpdate] of domUpdates.entries()) {
|
|
@@ -144,6 +114,8 @@ function assertProtocolViewPayload(payload) {
|
|
|
144
114
|
const context = `markless/view asyncBoundary[${index}]`;
|
|
145
115
|
assertRecordShape(boundary, context);
|
|
146
116
|
assertStringField(boundary, "id", context);
|
|
117
|
+
assertNullableStringField(boundary, "runnerGraphNodeId", context);
|
|
118
|
+
assertAsyncBoundaryArm(boundary.initiallyServedArm, context);
|
|
147
119
|
assertCommentAnchor(boundary.startAnchor, `${context}.startAnchor`);
|
|
148
120
|
assertCommentAnchor(boundary.endAnchor, `${context}.endAnchor`);
|
|
149
121
|
assertAsyncBoundaryReads(boundary.asyncReads, context);
|
|
@@ -151,22 +123,26 @@ function assertProtocolViewPayload(payload) {
|
|
|
151
123
|
assertOptionalKeyedRepeats(payload);
|
|
152
124
|
assertOptionalBranches(payload);
|
|
153
125
|
}
|
|
154
|
-
|
|
155
|
-
|
|
126
|
+
const EVENT_ACTION_VALIDATORS = {
|
|
127
|
+
[PROTOCOL_EVENT_ACTION_KIND.event]: () => {},
|
|
128
|
+
[PROTOCOL_EVENT_ACTION_KIND.externalDelegate]: (action, context) => assertStringField(action, "owner", context)
|
|
129
|
+
};
|
|
130
|
+
function assertOptionalEventAction(value, context) {
|
|
131
|
+
if (value === void 0) return;
|
|
132
|
+
assertRecordShape(value, context);
|
|
133
|
+
assertStringField(value, "kind", context);
|
|
134
|
+
const validate = EVENT_ACTION_VALIDATORS[value.kind];
|
|
135
|
+
if (!validate) throw invalidPayloadShapeError(contextPayloadType(context), `Invalid ${context}: unknown event action kind.`);
|
|
136
|
+
validate(value, context);
|
|
137
|
+
}
|
|
138
|
+
function assertNullableStringField(record, field, context) {
|
|
139
|
+
if (record[field] !== null && typeof record[field] !== "string") throw invalidPayloadShapeError(contextPayloadType(context), `Invalid ${context}: expected ${field} string or null.`);
|
|
156
140
|
}
|
|
157
|
-
function
|
|
158
|
-
if (
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
for (const [index, entry] of storage.entries()) {
|
|
163
|
-
const context = `markless/state storage[${index}]`;
|
|
164
|
-
assertRecordShape(entry, context);
|
|
165
|
-
assertStringField(entry, "graphNodeId", context);
|
|
166
|
-
assertStringField(entry, "key", context);
|
|
167
|
-
if (!cellIds.has(entry.graphNodeId)) throw invalidPayloadShapeError("markless/state", `Invalid ${context}: graphNodeId must match a state cell.`);
|
|
168
|
-
if (!isValidStorageKey(entry.key)) throw invalidPayloadShapeError("markless/state", `Invalid ${context}: key must be a verbatim key or a derived markless:<identifier>.`);
|
|
169
|
-
}
|
|
141
|
+
function assertAsyncBoundaryArm(value, context) {
|
|
142
|
+
if (!Object.values(ASYNC_BOUNDARY_ARM).includes(value)) throw invalidPayloadShapeError(contextPayloadType(context), `Invalid ${context}: expected initiallyServedArm to name a protocol async boundary arm.`);
|
|
143
|
+
}
|
|
144
|
+
function assertProtocolVersion(version, type, allowStorage = false) {
|
|
145
|
+
if (version !== 1 && !(allowStorage && type === "markless/state" && version === 2)) throw protocolVersionMismatchError(type, version);
|
|
170
146
|
}
|
|
171
147
|
function isRecord(value) {
|
|
172
148
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -696,4 +672,29 @@ function payloadScriptSelector(type) {
|
|
|
696
672
|
return `script[type="${type}"]`;
|
|
697
673
|
}
|
|
698
674
|
//#endregion
|
|
699
|
-
|
|
675
|
+
//#region src/storage-key.ts
|
|
676
|
+
const STORAGE_KEY_PATTERN = /^[A-Za-z0-9$_:.-]+$/;
|
|
677
|
+
function isValidStorageKey(value) {
|
|
678
|
+
return STORAGE_KEY_PATTERN.test(value);
|
|
679
|
+
}
|
|
680
|
+
//#endregion
|
|
681
|
+
//#region src/protocol-validation-storage.ts
|
|
682
|
+
function decodePayloadScripts(input) {
|
|
683
|
+
const decoded = decodePayloadScriptsWithVersion(input, true);
|
|
684
|
+
if (decoded.state.version !== 2) return decoded;
|
|
685
|
+
const cellIds = new Set(decoded.state.cells.map((cell) => cell.graphNodeId));
|
|
686
|
+
const storage = decoded.state.storage;
|
|
687
|
+
if (!Array.isArray(storage)) throw invalidPayloadShapeError("markless/state", "Invalid markless/state payload: expected storage array.");
|
|
688
|
+
for (const [index, entry] of storage.entries()) {
|
|
689
|
+
const context = `markless/state storage[${index}]`;
|
|
690
|
+
if (typeof entry !== "object" || entry === null || Array.isArray(entry)) throw invalidPayloadShapeError("markless/state", `Invalid ${context}: expected object.`);
|
|
691
|
+
const record = entry;
|
|
692
|
+
if (typeof record.graphNodeId !== "string") throw invalidPayloadShapeError("markless/state", `Invalid ${context}: expected graphNodeId string.`);
|
|
693
|
+
if (typeof record.key !== "string") throw invalidPayloadShapeError("markless/state", `Invalid ${context}: expected key string.`);
|
|
694
|
+
if (!cellIds.has(record.graphNodeId)) throw invalidPayloadShapeError("markless/state", `Invalid ${context}: graphNodeId must match a state cell.`);
|
|
695
|
+
if (!isValidStorageKey(record.key)) throw invalidPayloadShapeError("markless/state", `Invalid ${context}: key must be a verbatim key or a derived markless:<identifier>.`);
|
|
696
|
+
}
|
|
697
|
+
return decoded;
|
|
698
|
+
}
|
|
699
|
+
//#endregion
|
|
700
|
+
export { assertProtocolStatePayload as a, invalidPayloadShapeError as c, assertProtocolStateCellPayload as i, payloadInvalidError as l, isValidStorageKey as n, assertProtocolViewPayload as o, RuntimePayloadError as r, decodePayloadScriptsWithVersion as s, decodePayloadScripts as t, payloadScriptSelector as u };
|
|
@@ -1,55 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
//#region src/protocol-validation.d.ts
|
|
4
|
-
type EncodedPayloadScripts = {
|
|
5
|
-
readonly stateScript: string;
|
|
6
|
-
readonly viewScript: string;
|
|
7
|
-
};
|
|
8
|
-
type DecodedPayloadScripts = {
|
|
9
|
-
readonly state: ProtocolStatePayload;
|
|
10
|
-
readonly view: ProtocolViewPayload;
|
|
11
|
-
};
|
|
12
|
-
type RuntimePayloadType = 'markless/state' | 'markless/view';
|
|
13
|
-
type RuntimePayloadErrorCode = 'MARKLESS_PAYLOAD_INVALID' | 'MARKLESS_PROTOCOL_VERSION_MISMATCH';
|
|
14
|
-
type RuntimePayloadDiagnostic = {
|
|
15
|
-
readonly code: RuntimePayloadErrorCode;
|
|
16
|
-
readonly severity: 'error';
|
|
17
|
-
readonly phase: 'payload';
|
|
18
|
-
readonly title: string;
|
|
19
|
-
readonly message: string;
|
|
20
|
-
readonly why: string;
|
|
21
|
-
readonly payloadType: RuntimePayloadType;
|
|
22
|
-
readonly payloadScript: string;
|
|
23
|
-
readonly expectedVersion?: number;
|
|
24
|
-
readonly actualVersion?: unknown;
|
|
25
|
-
readonly suggestions: ReadonlyArray<{
|
|
26
|
-
readonly message: string;
|
|
27
|
-
}>;
|
|
28
|
-
readonly docsUrl: string;
|
|
29
|
-
};
|
|
30
|
-
declare class RuntimePayloadError extends Error implements RuntimePayloadDiagnostic {
|
|
31
|
-
readonly code: RuntimePayloadErrorCode;
|
|
32
|
-
readonly severity: 'error';
|
|
33
|
-
readonly phase: 'payload';
|
|
34
|
-
readonly title: string;
|
|
35
|
-
readonly why: string;
|
|
36
|
-
readonly payloadType: RuntimePayloadType;
|
|
37
|
-
readonly payloadScript: string;
|
|
38
|
-
readonly expectedVersion?: number;
|
|
39
|
-
readonly actualVersion?: unknown;
|
|
40
|
-
readonly suggestions: ReadonlyArray<{
|
|
41
|
-
readonly message: string;
|
|
42
|
-
}>;
|
|
43
|
-
readonly docsUrl: string;
|
|
44
|
-
constructor(diagnostic: RuntimePayloadDiagnostic);
|
|
45
|
-
}
|
|
46
|
-
declare function decodePayloadScripts(input: EncodedPayloadScripts): DecodedPayloadScripts;
|
|
47
|
-
declare function assertProtocolStatePayload(payload: unknown): asserts payload is ProtocolStatePayload;
|
|
48
|
-
declare function assertProtocolStateCellPayload(cell: unknown, context: string): asserts cell is ProtocolStatePayload['cells'][number];
|
|
49
|
-
declare function assertProtocolViewPayload(payload: unknown): asserts payload is ProtocolViewPayload;
|
|
50
|
-
declare function payloadInvalidError(payloadType: RuntimePayloadType, message: string, why: string, suggestions: ReadonlyArray<{
|
|
51
|
-
readonly message: string;
|
|
52
|
-
}>): RuntimePayloadError;
|
|
53
|
-
declare function payloadScriptSelector(type: RuntimePayloadType): string;
|
|
54
|
-
//#endregion
|
|
55
|
-
export { DecodedPayloadScripts, EncodedPayloadScripts, RuntimePayloadDiagnostic, RuntimePayloadError, RuntimePayloadErrorCode, RuntimePayloadType, assertProtocolStateCellPayload, assertProtocolStatePayload, assertProtocolViewPayload, decodePayloadScripts, payloadInvalidError, payloadScriptSelector };
|
|
1
|
+
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-C9wAbNbb.js";
|
|
2
|
+
export { DecodedPayloadScripts, EncodedPayloadScripts, RuntimePayloadDiagnostic, RuntimePayloadError, RuntimePayloadErrorCode, RuntimePayloadType, assertProtocolStateCellPayload, assertProtocolStatePayload, assertProtocolViewPayload, decodePayloadScripts, decodePayloadScriptsWithVersion, invalidPayloadShapeError, payloadInvalidError, payloadScriptSelector };
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import "./protocol.js";
|
|
2
|
-
|
|
3
|
-
export { RuntimePayloadError, assertProtocolStateCellPayload, assertProtocolStatePayload, assertProtocolViewPayload, decodePayloadScripts, payloadInvalidError, payloadScriptSelector };
|
|
1
|
+
import { a as assertProtocolStatePayload, c as invalidPayloadShapeError, i as assertProtocolStateCellPayload, l as payloadInvalidError, o as assertProtocolViewPayload, r as RuntimePayloadError, s as decodePayloadScriptsWithVersion, t as decodePayloadScripts, u as payloadScriptSelector } from "./protocol-validation-storage-DBEF2IjR.js";
|
|
2
|
+
export { RuntimePayloadError, assertProtocolStateCellPayload, assertProtocolStatePayload, assertProtocolViewPayload, decodePayloadScripts, decodePayloadScriptsWithVersion, invalidPayloadShapeError, payloadInvalidError, payloadScriptSelector };
|
package/dist/protocol.d.ts
CHANGED
|
@@ -1,257 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
declare const STORAGE_PROTOCOL_VERSION = 2;
|
|
4
|
-
type ProtocolSyncPolicyCondition = {
|
|
5
|
-
readonly type: 'and';
|
|
6
|
-
readonly conditions: ReadonlyArray<ProtocolSyncPolicyCondition>;
|
|
7
|
-
} | {
|
|
8
|
-
readonly type: 'or';
|
|
9
|
-
readonly conditions: ReadonlyArray<ProtocolSyncPolicyCondition>;
|
|
10
|
-
} | {
|
|
11
|
-
readonly type: 'not';
|
|
12
|
-
readonly condition: ProtocolSyncPolicyCondition;
|
|
13
|
-
} | {
|
|
14
|
-
readonly type: 'graph-truthy';
|
|
15
|
-
readonly graphNodeId: string;
|
|
16
|
-
readonly path?: ReadonlyArray<string>;
|
|
17
|
-
} | {
|
|
18
|
-
readonly type: 'constant-truthy';
|
|
19
|
-
readonly value: unknown;
|
|
20
|
-
} | {
|
|
21
|
-
readonly type: 'event-equals';
|
|
22
|
-
readonly field: string;
|
|
23
|
-
readonly value: unknown;
|
|
24
|
-
};
|
|
25
|
-
type ProtocolSyncPolicyBranch = {
|
|
26
|
-
readonly when: ProtocolSyncPolicyCondition;
|
|
27
|
-
readonly actions: ReadonlyArray<'preventDefault' | 'stopPropagation'>;
|
|
28
|
-
};
|
|
29
|
-
type ProtocolSyncPolicy = ProtocolSyncPolicyBranch | {
|
|
30
|
-
readonly branches: ReadonlyArray<ProtocolSyncPolicyBranch>;
|
|
31
|
-
};
|
|
32
|
-
type ProtocolStatePayload = {
|
|
33
|
-
readonly version: typeof ASYNC_PROTOCOL_VERSION | typeof STORAGE_PROTOCOL_VERSION;
|
|
34
|
-
readonly cells: ReadonlyArray<{
|
|
35
|
-
readonly graphNodeId: string;
|
|
36
|
-
readonly name: string;
|
|
37
|
-
readonly valueKind: 'scalar' | 'object' | 'array' | 'unknown';
|
|
38
|
-
readonly value?: unknown;
|
|
39
|
-
readonly directValue?: unknown;
|
|
40
|
-
}>;
|
|
41
|
-
readonly computed: ReadonlyArray<{
|
|
42
|
-
readonly graphNodeId: string;
|
|
43
|
-
readonly name: string;
|
|
44
|
-
readonly async: boolean;
|
|
45
|
-
readonly dependencies?: ReadonlyArray<{
|
|
46
|
-
readonly graphNodeId: string;
|
|
47
|
-
readonly path: ReadonlyArray<string>;
|
|
48
|
-
}>;
|
|
49
|
-
readonly snapshot?: {
|
|
50
|
-
readonly status: 'idle';
|
|
51
|
-
readonly version: 0;
|
|
52
|
-
} | {
|
|
53
|
-
readonly status: 'pending';
|
|
54
|
-
readonly version: number;
|
|
55
|
-
readonly key: unknown;
|
|
56
|
-
} | {
|
|
57
|
-
readonly status: 'fulfilled';
|
|
58
|
-
readonly version: number;
|
|
59
|
-
readonly key: unknown;
|
|
60
|
-
readonly value: unknown;
|
|
61
|
-
} | {
|
|
62
|
-
readonly status: 'rejected';
|
|
63
|
-
readonly version: number;
|
|
64
|
-
readonly key: unknown;
|
|
65
|
-
readonly error: unknown;
|
|
66
|
-
};
|
|
67
|
-
}>;
|
|
68
|
-
readonly sharedDefinitions?: ReadonlyArray<{
|
|
69
|
-
readonly id: string;
|
|
70
|
-
readonly name: string;
|
|
71
|
-
readonly exportedName: string;
|
|
72
|
-
readonly scope?: 'request' | 'container' | 'page';
|
|
73
|
-
readonly version: number;
|
|
74
|
-
readonly graphNodeIds: ReadonlyArray<string>;
|
|
75
|
-
readonly dependencies?: ReadonlyArray<{
|
|
76
|
-
readonly definitionId: string;
|
|
77
|
-
readonly definitionName: string;
|
|
78
|
-
}>;
|
|
79
|
-
readonly returnProperties?: ReadonlyArray<{
|
|
80
|
-
readonly kind: 'graph';
|
|
81
|
-
readonly name: string;
|
|
82
|
-
readonly graphNodeId: string;
|
|
83
|
-
readonly path: ReadonlyArray<string>;
|
|
84
|
-
} | {
|
|
85
|
-
readonly kind: 'method';
|
|
86
|
-
readonly name: string;
|
|
87
|
-
}>;
|
|
88
|
-
}>;
|
|
89
|
-
readonly storage?: ReadonlyArray<{
|
|
90
|
-
readonly graphNodeId: string;
|
|
91
|
-
readonly key: string;
|
|
92
|
-
}>;
|
|
93
|
-
};
|
|
94
|
-
type ProtocolArmBranchRecord = {
|
|
95
|
-
readonly id: string;
|
|
96
|
-
readonly testReads: ReadonlyArray<{
|
|
97
|
-
readonly source: string;
|
|
98
|
-
readonly graphNodeId: string;
|
|
99
|
-
readonly path: ReadonlyArray<string>;
|
|
100
|
-
}>;
|
|
101
|
-
readonly symbolId?: string;
|
|
102
|
-
readonly armTests?: ReadonlyArray<unknown>;
|
|
103
|
-
readonly declaredEmptyArms?: ReadonlyArray<number>;
|
|
104
|
-
readonly startAnchor?: {
|
|
105
|
-
readonly strategy: 'arm-branch-comment';
|
|
106
|
-
readonly index: number;
|
|
107
|
-
};
|
|
108
|
-
readonly endAnchor?: {
|
|
109
|
-
readonly strategy: 'arm-branch-comment';
|
|
110
|
-
readonly index: number;
|
|
111
|
-
};
|
|
112
|
-
readonly armRecords?: NonNullable<ProtocolViewPayload['branches']>[number]['armRecords'];
|
|
113
|
-
};
|
|
114
|
-
type ProtocolArmRecordSet = {
|
|
115
|
-
readonly locators: ReadonlyArray<{
|
|
116
|
-
readonly hostNodeId: string;
|
|
117
|
-
readonly strategy: 'arm-relative';
|
|
118
|
-
readonly index: number;
|
|
119
|
-
readonly tagName: string;
|
|
120
|
-
}>;
|
|
121
|
-
readonly events: ProtocolViewPayload['events'];
|
|
122
|
-
readonly behaviors: ProtocolViewPayload['behaviors'];
|
|
123
|
-
readonly elementHandles: ProtocolViewPayload['elementHandles'];
|
|
124
|
-
readonly branches?: ReadonlyArray<ProtocolArmBranchRecord>;
|
|
125
|
-
};
|
|
126
|
-
type ProtocolViewPayload = {
|
|
127
|
-
readonly version: typeof ASYNC_PROTOCOL_VERSION;
|
|
128
|
-
readonly asyncRunners?: Readonly<Record<string, string>>;
|
|
129
|
-
readonly locators: ReadonlyArray<{
|
|
130
|
-
readonly hostNodeId: string;
|
|
131
|
-
readonly strategy: 'dom-order';
|
|
132
|
-
readonly index: number;
|
|
133
|
-
readonly tagName: string;
|
|
134
|
-
}>;
|
|
135
|
-
readonly events: ReadonlyArray<{
|
|
136
|
-
readonly hostNodeId: string;
|
|
137
|
-
readonly eventName: string;
|
|
138
|
-
readonly syncPolicy?: ProtocolSyncPolicy;
|
|
139
|
-
readonly symbolIds: ReadonlyArray<string>;
|
|
140
|
-
}>;
|
|
141
|
-
readonly domUpdates: ReadonlyArray<{
|
|
142
|
-
readonly hostNodeId: string;
|
|
143
|
-
readonly source: string;
|
|
144
|
-
readonly graphNodeId: string;
|
|
145
|
-
readonly path: ReadonlyArray<string>;
|
|
146
|
-
readonly target?: {
|
|
147
|
-
readonly kind: 'text';
|
|
148
|
-
readonly prefix?: string;
|
|
149
|
-
readonly suffix?: string;
|
|
150
|
-
readonly trueValue?: string;
|
|
151
|
-
readonly falseValue?: string;
|
|
152
|
-
} | {
|
|
153
|
-
readonly kind: 'attribute';
|
|
154
|
-
readonly name: string;
|
|
155
|
-
} | {
|
|
156
|
-
readonly kind: 'property';
|
|
157
|
-
readonly name: string;
|
|
158
|
-
} | {
|
|
159
|
-
readonly kind: 'class';
|
|
160
|
-
readonly trueValue?: string;
|
|
161
|
-
readonly falseValue?: string;
|
|
162
|
-
} | {
|
|
163
|
-
readonly kind: 'style';
|
|
164
|
-
};
|
|
165
|
-
readonly symbolId?: string;
|
|
166
|
-
}>;
|
|
167
|
-
readonly behaviors: ReadonlyArray<{
|
|
168
|
-
readonly hostNodeId: string;
|
|
169
|
-
readonly source: string;
|
|
170
|
-
readonly functionSource: string;
|
|
171
|
-
readonly inputSources: ReadonlyArray<string>;
|
|
172
|
-
readonly inputValues?: ReadonlyArray<unknown>;
|
|
173
|
-
readonly inputGraphReads?: ReadonlyArray<{
|
|
174
|
-
readonly inputIndex: number;
|
|
175
|
-
readonly source: string;
|
|
176
|
-
readonly graphNodeId: string;
|
|
177
|
-
readonly path: ReadonlyArray<string>;
|
|
178
|
-
}>;
|
|
179
|
-
readonly symbolId?: string;
|
|
180
|
-
}>;
|
|
181
|
-
readonly elementHandles: ReadonlyArray<{
|
|
182
|
-
readonly hostNodeId: string;
|
|
183
|
-
readonly handleId: string;
|
|
184
|
-
readonly name: string;
|
|
185
|
-
}>;
|
|
186
|
-
readonly keyedRepeats?: ReadonlyArray<{
|
|
187
|
-
readonly id: string;
|
|
188
|
-
readonly parentHostNodeId: string;
|
|
189
|
-
readonly collectionGraphNodeId?: string;
|
|
190
|
-
readonly collectionPath: ReadonlyArray<string>;
|
|
191
|
-
readonly keyPath: ReadonlyArray<string>;
|
|
192
|
-
readonly itemName: string;
|
|
193
|
-
readonly rowElementCount: number;
|
|
194
|
-
readonly rowEvents: ReadonlyArray<{
|
|
195
|
-
readonly hostPath: ReadonlyArray<number>;
|
|
196
|
-
readonly eventName: string;
|
|
197
|
-
readonly symbolIds: ReadonlyArray<string>;
|
|
198
|
-
readonly syncPolicy?: ProtocolSyncPolicy;
|
|
199
|
-
}>;
|
|
200
|
-
}>;
|
|
201
|
-
readonly branches?: ReadonlyArray<{
|
|
202
|
-
readonly id: string;
|
|
203
|
-
readonly startAnchor: {
|
|
204
|
-
readonly strategy: 'dom-order-comment';
|
|
205
|
-
readonly index: number;
|
|
206
|
-
};
|
|
207
|
-
readonly endAnchor: {
|
|
208
|
-
readonly strategy: 'dom-order-comment';
|
|
209
|
-
readonly index: number;
|
|
210
|
-
};
|
|
211
|
-
readonly symbolId?: string;
|
|
212
|
-
readonly armTests?: ReadonlyArray<unknown>;
|
|
213
|
-
readonly armRecords?: ReadonlyArray<{
|
|
214
|
-
readonly events: ReadonlyArray<{
|
|
215
|
-
readonly hostPath: ReadonlyArray<number>;
|
|
216
|
-
readonly eventName: string;
|
|
217
|
-
readonly symbolIds: ReadonlyArray<string>;
|
|
218
|
-
readonly syncPolicy?: ProtocolSyncPolicy;
|
|
219
|
-
}>;
|
|
220
|
-
readonly domUpdates: ReadonlyArray<Record<string, unknown>>;
|
|
221
|
-
readonly behaviors: ReadonlyArray<Record<string, unknown>>;
|
|
222
|
-
readonly elementHandles: ReadonlyArray<Record<string, unknown>>;
|
|
223
|
-
}>;
|
|
224
|
-
readonly testReads?: ReadonlyArray<{
|
|
225
|
-
readonly source: string;
|
|
226
|
-
readonly graphNodeId: string;
|
|
227
|
-
readonly path: ReadonlyArray<string>;
|
|
228
|
-
}>;
|
|
229
|
-
}>;
|
|
230
|
-
readonly asyncBoundaries: ReadonlyArray<{
|
|
231
|
-
readonly id: string;
|
|
232
|
-
readonly updateSymbolId?: string;
|
|
233
|
-
readonly armRecords?: ProtocolArmRecordSet | ReadonlyArray<ProtocolArmRecordSet>;
|
|
234
|
-
readonly startAnchor: {
|
|
235
|
-
readonly strategy: 'dom-order-comment';
|
|
236
|
-
readonly index: number;
|
|
237
|
-
};
|
|
238
|
-
readonly endAnchor: {
|
|
239
|
-
readonly strategy: 'dom-order-comment';
|
|
240
|
-
readonly index: number;
|
|
241
|
-
};
|
|
242
|
-
readonly asyncReads: ReadonlyArray<{
|
|
243
|
-
readonly source: string;
|
|
244
|
-
readonly graphNodeId: string;
|
|
245
|
-
readonly path: ReadonlyArray<string>;
|
|
246
|
-
readonly runnerSymbolId?: string;
|
|
247
|
-
}>;
|
|
248
|
-
}>;
|
|
249
|
-
};
|
|
250
|
-
type ProtocolPayloadScripts = {
|
|
251
|
-
readonly state: ProtocolStatePayload;
|
|
252
|
-
readonly view: ProtocolViewPayload;
|
|
253
|
-
readonly stateScript: string;
|
|
254
|
-
readonly viewScript: string;
|
|
255
|
-
};
|
|
256
|
-
//#endregion
|
|
257
|
-
export { ASYNC_PROTOCOL_VERSION, ProtocolArmBranchRecord, ProtocolArmRecordSet, ProtocolPayloadScripts, ProtocolStatePayload, ProtocolSyncPolicy, ProtocolSyncPolicyBranch, ProtocolSyncPolicyCondition, ProtocolViewPayload, STORAGE_PROTOCOL_VERSION };
|
|
1
|
+
import { _ as ASYNC_PROTOCOL_VERSION, a as ProtocolEventAction, 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 ASYNC_BOUNDARY_ARM } from "./protocol--6NOPwgQ.js";
|
|
2
|
+
export { ASYNC_BOUNDARY_ARM, ASYNC_PROTOCOL_VERSION, PROTOCOL_EVENT_ACTION_KIND, ProtocolArmBranchRecord, ProtocolArmRecordSet, ProtocolAsyncBoundaryArm, ProtocolEventAction, ProtocolEventActionKind, ProtocolEventRecord, ProtocolPayloadScripts, ProtocolStatePayload, ProtocolStreamedArmPatch, ProtocolSyncPolicy, ProtocolSyncPolicyBranch, ProtocolSyncPolicyCondition, ProtocolViewPayload, STORAGE_PROTOCOL_VERSION, protocolEventActionKind, protocolEventDispatchesMarkless };
|
package/dist/protocol.js
CHANGED
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const STORAGE_PROTOCOL_VERSION = 2;
|
|
4
|
-
//#endregion
|
|
5
|
-
export { ASYNC_PROTOCOL_VERSION, STORAGE_PROTOCOL_VERSION };
|
|
1
|
+
import { a as ASYNC_PROTOCOL_VERSION, i as ASYNC_BOUNDARY_ARM, n as protocolEventActionKind, o as STORAGE_PROTOCOL_VERSION, r as protocolEventDispatchesMarkless, t as PROTOCOL_EVENT_ACTION_KIND } from "./protocol-Bzvnaz87.js";
|
|
2
|
+
export { ASYNC_BOUNDARY_ARM, ASYNC_PROTOCOL_VERSION, PROTOCOL_EVENT_ACTION_KIND, STORAGE_PROTOCOL_VERSION, protocolEventActionKind, protocolEventDispatchesMarkless };
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
//#region src/value-constants.d.ts
|
|
2
|
+
declare const GRAPH_VALUE_PROTOCOL_VERSION = 1;
|
|
3
|
+
//#endregion
|
|
1
4
|
//#region src/value-decode.d.ts
|
|
2
5
|
declare function deserializeGraphValue(payload: SerializedGraphPayload): unknown;
|
|
3
6
|
//#endregion
|
|
@@ -70,7 +73,7 @@ type SerializedRecord = {
|
|
|
70
73
|
};
|
|
71
74
|
type TypedArrayName = 'Int8Array' | 'Uint8Array' | 'Uint8ClampedArray' | 'Int16Array' | 'Uint16Array' | 'Int32Array' | 'Uint32Array' | 'Float32Array' | 'Float64Array' | 'BigInt64Array' | 'BigUint64Array';
|
|
72
75
|
type SerializedGraphPayload = {
|
|
73
|
-
readonly version:
|
|
76
|
+
readonly version: typeof GRAPH_VALUE_PROTOCOL_VERSION;
|
|
74
77
|
readonly root: SerializedSlot;
|
|
75
78
|
readonly records: ReadonlyArray<SerializedRecord>;
|
|
76
79
|
};
|
package/package.json
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markless/serializer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Markless serialization tiers and resumability payload protocol.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "git+https://github.com/
|
|
8
|
+
"url": "git+https://github.com/compiled-run/markless.git",
|
|
9
9
|
"directory": "packages/serializer"
|
|
10
10
|
},
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist"
|
|
13
|
+
],
|
|
15
14
|
"type": "module",
|
|
16
15
|
"sideEffects": false,
|
|
17
16
|
"exports": {
|
|
@@ -19,10 +18,22 @@
|
|
|
19
18
|
"types": "./dist/index.d.ts",
|
|
20
19
|
"default": "./dist/index.js"
|
|
21
20
|
},
|
|
21
|
+
"./async-boundary-arm": {
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"default": "./dist/index.js"
|
|
24
|
+
},
|
|
22
25
|
"./decode": {
|
|
23
26
|
"types": "./dist/decode.d.ts",
|
|
24
27
|
"default": "./dist/decode.js"
|
|
25
28
|
},
|
|
29
|
+
"./resume-record-delta": {
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
|
+
"default": "./dist/index.js"
|
|
32
|
+
},
|
|
33
|
+
"./resume-record-merge": {
|
|
34
|
+
"types": "./dist/index.d.ts",
|
|
35
|
+
"default": "./dist/index.js"
|
|
36
|
+
},
|
|
26
37
|
"./decode-client": {
|
|
27
38
|
"types": "./dist/decode-client.d.ts",
|
|
28
39
|
"default": "./dist/decode-client.js"
|
|
@@ -36,8 +47,9 @@
|
|
|
36
47
|
"default": "./dist/protocol-validation.js"
|
|
37
48
|
}
|
|
38
49
|
},
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
|
|
50
|
+
"publishConfig": {
|
|
51
|
+
"access": "public",
|
|
52
|
+
"provenance": true
|
|
53
|
+
},
|
|
42
54
|
"scripts": {}
|
|
43
55
|
}
|
|
File without changes
|