@markless/serializer 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/decode-client.d.ts +4 -5
- package/dist/decode-client.js +2 -1
- package/dist/decode.d.ts +2 -2
- package/dist/decode.js +1 -0
- package/dist/index.d.ts +33 -26
- package/dist/index.js +71 -5
- package/dist/protocol-B3YIo3hD.d.ts +647 -0
- package/dist/protocol-BbWeZfik.js +91 -0
- package/dist/{protocol-validation-storage-DGj6FaG-.d.ts → protocol-validation-storage-C9YES3Zy.d.ts} +1 -2
- package/dist/{protocol-validation-storage-C4NuHqQw.js → protocol-validation-storage-DhyQ9fEO.js} +122 -13
- package/dist/protocol-validation.d.ts +1 -1
- package/dist/protocol-validation.js +1 -1
- package/dist/protocol.d.ts +2 -2
- package/dist/protocol.js +2 -2
- package/dist/{value-BJ6YNKDd.d.ts → value-CRkHmkRz.d.ts} +17 -1
- package/package.json +1 -1
- package/dist/protocol-BwMZfNSA.js +0 -56
- package/dist/protocol-CGsMO85z.d.ts +0 -363
- /package/dist/{value-decode-extensions-Bf-pgKHA.js → value-decode-extensions-xfgotsAg.js} +0 -0
|
@@ -0,0 +1,91 @@
|
|
|
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-sync-policy-host.ts
|
|
14
|
+
/**
|
|
15
|
+
* The attribute the server writes on each element whose event record carries a
|
|
16
|
+
* sync policy (preventDefault, stopPropagation), valued with that record's
|
|
17
|
+
* hostNodeId. The inline boot finds the policy from the event's own target up
|
|
18
|
+
* to the nearest marked element, so it never needs the element's position.
|
|
19
|
+
*/
|
|
20
|
+
const PROTOCOL_SYNC_POLICY_HOST_ATTRIBUTE = "data-markless-sync";
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/protocol-constants.ts
|
|
23
|
+
const ASYNC_PROTOCOL_VERSION = 1;
|
|
24
|
+
const STORAGE_PROTOCOL_VERSION = 2;
|
|
25
|
+
function protocolStateVersion(storage) {
|
|
26
|
+
return (storage?.length ?? 0) > 0 ? 2 : 1;
|
|
27
|
+
}
|
|
28
|
+
const PROTOCOL_EVENT_ACTION_KIND = {
|
|
29
|
+
event: "event",
|
|
30
|
+
externalDelegate: "external-delegate"
|
|
31
|
+
};
|
|
32
|
+
const PROTOCOL_INSTANCE_PATH = /^(?:[cpm]\d+:|r:[^:]*:)+/;
|
|
33
|
+
function protocolInstanceSegment(edgeIndex) {
|
|
34
|
+
return `c${edgeIndex}:`;
|
|
35
|
+
}
|
|
36
|
+
function protocolProjectionSegment(edgeIndex) {
|
|
37
|
+
return `p${edgeIndex}:`;
|
|
38
|
+
}
|
|
39
|
+
/** One keyed `@for` row's identity segment. The key is identity, never the index. */
|
|
40
|
+
function protocolRowSegment(key) {
|
|
41
|
+
return `r:${encodeURIComponent(String(key))}:`;
|
|
42
|
+
}
|
|
43
|
+
/** The leading instance path of a composed id, or '' when the id is page-local. */
|
|
44
|
+
function protocolInstancePath(id) {
|
|
45
|
+
return PROTOCOL_INSTANCE_PATH.exec(id)?.[0] ?? "";
|
|
46
|
+
}
|
|
47
|
+
const PROTOCOL_PROPS_GRAPH_NODE_ID = "prop:props";
|
|
48
|
+
const PROTOCOL_PROP_GRAPH_NODE_PREFIX = "prop:";
|
|
49
|
+
const PROTOCOL_INSTANCE_QUALIFIABLE = [
|
|
50
|
+
"prop:",
|
|
51
|
+
"state:",
|
|
52
|
+
"computed:",
|
|
53
|
+
"element:"
|
|
54
|
+
];
|
|
55
|
+
const PROTOCOL_PAGE_SPACE_ID_PREFIXES = ["shared:", "storage:"];
|
|
56
|
+
function protocolInstanceQualifies(graphNodeId) {
|
|
57
|
+
const local = graphNodeId.slice(protocolInstancePath(graphNodeId).length);
|
|
58
|
+
if (PROTOCOL_PAGE_SPACE_ID_PREFIXES.some((prefix) => local.startsWith(prefix))) return false;
|
|
59
|
+
return PROTOCOL_INSTANCE_QUALIFIABLE.some((prefix) => local.startsWith(prefix)) ? true : void 0;
|
|
60
|
+
}
|
|
61
|
+
//#endregion
|
|
62
|
+
//#region src/async-boundary-arm.ts
|
|
63
|
+
const ASYNC_BOUNDARY_ARM = {
|
|
64
|
+
try: 0,
|
|
65
|
+
pending: 1,
|
|
66
|
+
catch: 2
|
|
67
|
+
};
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region src/protocol.ts
|
|
70
|
+
function protocolEventActionKind(record) {
|
|
71
|
+
return record.action?.kind ?? PROTOCOL_EVENT_ACTION_KIND.event;
|
|
72
|
+
}
|
|
73
|
+
function protocolEventDispatchesMarkless(record) {
|
|
74
|
+
return protocolEventActionKind(record) === PROTOCOL_EVENT_ACTION_KIND.event;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* The graph read id an arm-update symbol asks under for a minted element() id.
|
|
78
|
+
*
|
|
79
|
+
* A minted id is `idPrefix + handle` where the prefix is the rendered widget's
|
|
80
|
+
* instance token, a seed-map value no flip can reach. The render that served the
|
|
81
|
+
* arm resolves the id and files it on the branch record under this key; the
|
|
82
|
+
* symbol asks for it through the read channel it already has, so the mint keeps
|
|
83
|
+
* exactly one spelling. Resume matches the key as a SUFFIX of the id it is
|
|
84
|
+
* handed, because a composed symbol's reads arrive with the instance path
|
|
85
|
+
* prepended — that is why the key carries the namespace and not the bare handle.
|
|
86
|
+
*/
|
|
87
|
+
function protocolElementHandleReadId(handleGraphNodeId) {
|
|
88
|
+
return `markless:element-handle-id|${handleGraphNodeId}`;
|
|
89
|
+
}
|
|
90
|
+
//#endregion
|
|
91
|
+
export { PROTOCOL_SYNC_POLICY_HOST_ATTRIBUTE as _, ASYNC_PROTOCOL_VERSION as a, PROTOCOL_VISIBLE_EVENT_NAME as b, PROTOCOL_PROPS_GRAPH_NODE_ID as c, protocolInstancePath as d, protocolInstanceQualifies as f, protocolStateVersion as g, protocolRowSegment as h, ASYNC_BOUNDARY_ARM as i, PROTOCOL_PROP_GRAPH_NODE_PREFIX as l, protocolProjectionSegment as m, protocolEventActionKind as n, PROTOCOL_EVENT_ACTION_KIND as o, protocolInstanceSegment as p, protocolEventDispatchesMarkless as r, PROTOCOL_PAGE_SPACE_ID_PREFIXES as s, protocolElementHandleReadId as t, STORAGE_PROTOCOL_VERSION as u, PROTOCOL_LOCATOR_PATHS_ATTRIBUTE as v, PROTOCOL_IDLE_EVENT_NAME as y };
|
package/dist/{protocol-validation-storage-DGj6FaG-.d.ts → protocol-validation-storage-C9YES3Zy.d.ts}
RENAMED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { _ as ProtocolViewPayload, f as ProtocolStatePayload } from "./protocol-B3YIo3hD.js";
|
|
3
2
|
//#region src/protocol-validation.d.ts
|
|
4
3
|
type EncodedPayloadScripts = {
|
|
5
4
|
readonly stateScript: string;
|
package/dist/{protocol-validation-storage-C4NuHqQw.js → protocol-validation-storage-DhyQ9fEO.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as ASYNC_BOUNDARY_ARM, o as PROTOCOL_EVENT_ACTION_KIND } from "./protocol-BbWeZfik.js";
|
|
2
2
|
//#region src/protocol-validation.ts
|
|
3
3
|
var RuntimePayloadError = class extends Error {
|
|
4
4
|
constructor(diagnostic) {
|
|
@@ -44,6 +44,8 @@ function assertProtocolStatePayload(payload) {
|
|
|
44
44
|
assertBooleanField(computed, "async", context);
|
|
45
45
|
assertOptionalComputedDependencies(computed, context);
|
|
46
46
|
assertOptionalAsyncComputedSnapshot(computed, context);
|
|
47
|
+
if ("value" in computed) assertSerializedGraphPayload(computed.value, `${context}.value`);
|
|
48
|
+
if ("directValue" in computed) throw invalidPayloadShapeError(contextPayloadType(context), `Invalid ${context}: live directValue computeds must be serialized before serving.`);
|
|
47
49
|
}
|
|
48
50
|
assertOptionalSharedDefinitions(payload);
|
|
49
51
|
}
|
|
@@ -86,7 +88,7 @@ function assertProtocolViewPayload(payload) {
|
|
|
86
88
|
const context = `markless/view domUpdate[${index}]`;
|
|
87
89
|
assertRecordShape(domUpdate, context);
|
|
88
90
|
assertStringField(domUpdate, "hostNodeId", context);
|
|
89
|
-
|
|
91
|
+
assertOptionalStringField(domUpdate, "source", context);
|
|
90
92
|
assertStringField(domUpdate, "graphNodeId", context);
|
|
91
93
|
assertStringArrayField(domUpdate, "path", context);
|
|
92
94
|
assertOptionalDomUpdateTarget(domUpdate.target, `${context}.target`);
|
|
@@ -132,7 +134,8 @@ function assertOptionalEventAction(value, context) {
|
|
|
132
134
|
if (value === void 0) return;
|
|
133
135
|
assertRecordShape(value, context);
|
|
134
136
|
assertStringField(value, "kind", context);
|
|
135
|
-
const
|
|
137
|
+
const kind = value.kind;
|
|
138
|
+
const validate = EVENT_ACTION_VALIDATORS[kind];
|
|
136
139
|
if (!validate) throw invalidPayloadShapeError(contextPayloadType(context), `Invalid ${context}: unknown event action kind.`);
|
|
137
140
|
validate(value, context);
|
|
138
141
|
}
|
|
@@ -178,6 +181,9 @@ function assertNonNegativeIntegerArrayField(record, key, context) {
|
|
|
178
181
|
function assertOptionalStringArrayField(record, key, context) {
|
|
179
182
|
if (record[key] !== void 0) assertStringArrayField(record, key, context);
|
|
180
183
|
}
|
|
184
|
+
function assertArrayField(record, key, context) {
|
|
185
|
+
if (!Array.isArray(record[key])) throw invalidPayloadShapeError(contextPayloadType(context), `Invalid ${context}: expected ${key} array.`);
|
|
186
|
+
}
|
|
181
187
|
function assertOptionalArrayField(record, key, context) {
|
|
182
188
|
if (record[key] !== void 0 && !Array.isArray(record[key])) throw invalidPayloadShapeError(contextPayloadType(context), `Invalid ${context}: expected ${key} array.`);
|
|
183
189
|
}
|
|
@@ -189,9 +195,18 @@ function assertOptionalKeyedRepeats(record) {
|
|
|
189
195
|
assertRecordShape(repeat, context);
|
|
190
196
|
assertStringField(repeat, "id", context);
|
|
191
197
|
assertStringField(repeat, "parentHostNodeId", context);
|
|
198
|
+
assertOptionalStringField(repeat, "ownerHostNodeId", context);
|
|
199
|
+
assertOptionalStringField(repeat, "instancePath", context);
|
|
200
|
+
assertOptionalEnclosingRow(repeat, `${context}.enclosingRow`);
|
|
192
201
|
assertOptionalStringField(repeat, "collectionGraphNodeId", context);
|
|
193
202
|
assertStringArrayField(repeat, "collectionPath", context);
|
|
194
203
|
assertStringArrayField(repeat, "keyPath", context);
|
|
204
|
+
if (repeat.indexKey !== void 0 && repeat.indexKey !== true) throw invalidPayloadShapeError("markless/view", `Invalid ${context}: expected indexKey true when present.`);
|
|
205
|
+
if (repeat.branchArm !== void 0) {
|
|
206
|
+
assertRecordShape(repeat.branchArm, `${context}.branchArm`);
|
|
207
|
+
assertStringField(repeat.branchArm, "branchId", `${context}.branchArm`);
|
|
208
|
+
assertNonNegativeIntegerField(repeat.branchArm, "arm", `${context}.branchArm`);
|
|
209
|
+
}
|
|
195
210
|
assertStringField(repeat, "itemName", context);
|
|
196
211
|
assertNonNegativeIntegerField(repeat, "rowElementCount", context);
|
|
197
212
|
if (repeat.rowStartOffset !== void 0) assertNonNegativeIntegerField(repeat, "rowStartOffset", context);
|
|
@@ -199,22 +214,82 @@ function assertOptionalKeyedRepeats(record) {
|
|
|
199
214
|
assertOptionalRowElementHandles(repeat, `${context}.rowElementHandles`);
|
|
200
215
|
assertOptionalEmptyArm(repeat, `${context}.emptyArm`);
|
|
201
216
|
assertOptionalRowTemplate(repeat, `${context}.rowTemplate`);
|
|
202
|
-
|
|
217
|
+
assertOptionalPropRoutes(repeat, `${context}.propRoutes`);
|
|
218
|
+
assertOptionalRowComponent(repeat, `${context}.rowComponent`);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
function assertOptionalEnclosingRow(record, context) {
|
|
222
|
+
const enclosingRow = record.enclosingRow;
|
|
223
|
+
if (enclosingRow === void 0) return;
|
|
224
|
+
assertRecordShape(enclosingRow, context);
|
|
225
|
+
assertStringField(enclosingRow, "repeatId", context);
|
|
226
|
+
assertNonNegativeIntegerArrayField(enclosingRow, "parentHostPath", context);
|
|
227
|
+
assertOptionalStringArrayField(enclosingRow, "itemPath", context);
|
|
228
|
+
}
|
|
229
|
+
function assertOptionalPropRoutes(record, context) {
|
|
230
|
+
const routes = record.propRoutes;
|
|
231
|
+
if (routes === void 0) return;
|
|
232
|
+
if (!Array.isArray(routes)) throw invalidPayloadShapeError(contextPayloadType(context), `Invalid ${context}: expected array.`);
|
|
233
|
+
for (const [index, route] of routes.entries()) {
|
|
234
|
+
const routeContext = `${context}[${index}]`;
|
|
235
|
+
assertRecordShape(route, routeContext);
|
|
236
|
+
assertStringField(route, "name", routeContext);
|
|
237
|
+
assertStringField(route, "graphNodeId", routeContext);
|
|
238
|
+
assertStringArrayField(route, "path", routeContext);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
function assertOptionalRowComponent(record, context) {
|
|
242
|
+
const rowComponent = record.rowComponent;
|
|
243
|
+
if (rowComponent === void 0) return;
|
|
244
|
+
assertRecordShape(rowComponent, context);
|
|
245
|
+
if (rowComponent.rowChunkId === void 0) assertStringField(rowComponent, "componentEdgeId", context);
|
|
246
|
+
else assertStringField(rowComponent, "rowChunkId", context);
|
|
247
|
+
assertStringField(rowComponent, "componentName", context);
|
|
248
|
+
assertOptionalStringField(rowComponent, "itemPropName", context);
|
|
249
|
+
if (rowComponent.slotPath !== void 0) assertNonNegativeIntegerArrayField(rowComponent, "slotPath", context);
|
|
203
250
|
}
|
|
204
251
|
function assertOptionalRowTemplate(record, context) {
|
|
205
252
|
const template = record.rowTemplate;
|
|
206
253
|
if (template === void 0) return;
|
|
207
254
|
assertRecordShape(template, context);
|
|
208
255
|
assertStringField(template, "html", context);
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
256
|
+
assertOptionalStringField(template, "componentName", context);
|
|
257
|
+
assertOptionalRowTemplateSlots(template.textSlots, `${context}.textSlots`);
|
|
258
|
+
assertOptionalRowTemplateSlots(template.attributeSlots, `${context}.attributeSlots`, true);
|
|
259
|
+
if ([...template.textSlots ?? [], ...template.attributeSlots ?? []].some((slot) => slot.source !== void 0) !== (template.componentName !== void 0)) throw invalidPayloadShapeError(contextPayloadType(context), `Invalid ${context}: expected componentName exactly when a slot carries source.`);
|
|
260
|
+
}
|
|
261
|
+
function assertOptionalRowTemplateSlots(slots, context, named = false) {
|
|
262
|
+
if (slots === void 0) return;
|
|
263
|
+
if (!Array.isArray(slots)) throw invalidPayloadShapeError(contextPayloadType(context), `Invalid ${context}: expected array.`);
|
|
264
|
+
for (const [index, slot] of slots.entries()) {
|
|
265
|
+
const slotContext = `${context}[${index}]`;
|
|
214
266
|
assertRecordShape(slot, slotContext);
|
|
215
267
|
assertNonNegativeIntegerArrayField(slot, "path", slotContext);
|
|
216
|
-
|
|
268
|
+
if (named) assertStringField(slot, "name", slotContext);
|
|
269
|
+
assertRowTemplateSlotValue(slot, slotContext);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
function assertRowTemplateSlotValue(slot, context) {
|
|
273
|
+
const fromItem = slot.itemPath !== void 0, fromGraph = slot.graphNodeId !== void 0 || slot.graphPath !== void 0, fromSource = slot.source !== void 0;
|
|
274
|
+
if (Number(fromItem) + Number(fromGraph) + Number(fromSource) !== 1) throw invalidPayloadShapeError(contextPayloadType(context), `Invalid ${context}: expected exactly one of itemPath, graphNodeId with graphPath, or source.`);
|
|
275
|
+
if (slot.reads !== void 0 && !fromSource) throw invalidPayloadShapeError(contextPayloadType(context), `Invalid ${context}: reads belongs to a source slot.`);
|
|
276
|
+
if (fromItem) {
|
|
277
|
+
assertStringArrayField(slot, "itemPath", context);
|
|
278
|
+
return;
|
|
217
279
|
}
|
|
280
|
+
if (fromSource) {
|
|
281
|
+
assertStringField(slot, "source", context);
|
|
282
|
+
if (slot.reads === void 0) return;
|
|
283
|
+
if (!Array.isArray(slot.reads)) throw invalidPayloadShapeError(contextPayloadType(context), `Invalid ${context}.reads: expected array.`);
|
|
284
|
+
for (const [index, read] of slot.reads.entries()) {
|
|
285
|
+
assertRecordShape(read, `${context}.reads[${index}]`);
|
|
286
|
+
assertStringField(read, "graphNodeId", `${context}.reads[${index}]`);
|
|
287
|
+
assertStringArrayField(read, "path", `${context}.reads[${index}]`);
|
|
288
|
+
}
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
assertStringField(slot, "graphNodeId", context);
|
|
292
|
+
assertStringArrayField(slot, "graphPath", context);
|
|
218
293
|
}
|
|
219
294
|
function assertOptionalEmptyArm(record, context) {
|
|
220
295
|
const arm = record.emptyArm;
|
|
@@ -251,8 +326,33 @@ function assertOptionalBranches(record) {
|
|
|
251
326
|
assertCommentAnchor(branch.endAnchor, `${context}.endAnchor`);
|
|
252
327
|
assertOptionalStringField(branch, "symbolId", context);
|
|
253
328
|
assertOptionalGraphReads(branch, "testReads", context);
|
|
329
|
+
assertOptionalGraphReads(branch, "contentReads", context);
|
|
254
330
|
if (branch.armTests !== void 0 && !Array.isArray(branch.armTests)) throw invalidPayloadShapeError(contextPayloadType(context), `Invalid ${context}: expected armTests array.`);
|
|
255
331
|
assertOptionalBranchArmRecords(branch, context);
|
|
332
|
+
assertOptionalServedArmRecords(branch, context);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
function assertOptionalServedArmRecords(record, context) {
|
|
336
|
+
if (record.servedArmRecords === void 0) return;
|
|
337
|
+
if (record.escalates !== true) throw invalidPayloadShapeError(contextPayloadType(context), `Invalid ${context}: servedArmRecords requires escalates.`);
|
|
338
|
+
const armContext = `${context}.servedArmRecords`;
|
|
339
|
+
assertRecordShape(record.servedArmRecords, armContext);
|
|
340
|
+
const arm = record.servedArmRecords;
|
|
341
|
+
assertArrayField(arm, "events", armContext);
|
|
342
|
+
assertArrayField(arm, "behaviors", armContext);
|
|
343
|
+
assertArrayField(arm, "elementHandles", armContext);
|
|
344
|
+
assertOptionalArrayField(arm, "domUpdates", armContext);
|
|
345
|
+
assertOptionalArrayField(arm, "keyedRepeats", armContext);
|
|
346
|
+
assertOptionalArrayField(arm, "branches", armContext);
|
|
347
|
+
assertArrayField(arm, "locators", armContext);
|
|
348
|
+
for (const [index, locator] of arm.locators.entries()) {
|
|
349
|
+
const locatorContext = `${armContext}.locators[${index}]`;
|
|
350
|
+
assertRecordShape(locator, locatorContext);
|
|
351
|
+
const entry = locator;
|
|
352
|
+
assertStringField(entry, "hostNodeId", locatorContext);
|
|
353
|
+
assertStringField(entry, "tagName", locatorContext);
|
|
354
|
+
if ("strategy" in entry) throw invalidPayloadShapeError(contextPayloadType(locatorContext), `Invalid ${locatorContext}: an arm-relative locator carries no strategy.`);
|
|
355
|
+
assertNonNegativeIntegerField(entry, "index", locatorContext);
|
|
256
356
|
}
|
|
257
357
|
}
|
|
258
358
|
function assertOptionalBranchArmRecords(record, context) {
|
|
@@ -285,7 +385,7 @@ function assertOptionalGraphReads(record, key, context) {
|
|
|
285
385
|
for (const [index, read] of reads.entries()) {
|
|
286
386
|
const readContext = `${context}.${key}[${index}]`;
|
|
287
387
|
assertRecordShape(read, readContext);
|
|
288
|
-
|
|
388
|
+
assertOptionalStringField(read, "source", readContext);
|
|
289
389
|
assertStringField(read, "graphNodeId", readContext);
|
|
290
390
|
assertStringArrayField(read, "path", readContext);
|
|
291
391
|
}
|
|
@@ -297,7 +397,7 @@ function assertOptionalBehaviorInputGraphReads(record, context) {
|
|
|
297
397
|
const readContext = `${context}.inputGraphReads[${index}]`;
|
|
298
398
|
assertRecordShape(read, readContext);
|
|
299
399
|
assertNonNegativeIntegerField(read, "inputIndex", readContext);
|
|
300
|
-
|
|
400
|
+
assertOptionalStringField(read, "source", readContext);
|
|
301
401
|
assertStringField(read, "graphNodeId", readContext);
|
|
302
402
|
assertStringArrayField(read, "path", readContext);
|
|
303
403
|
}
|
|
@@ -552,6 +652,11 @@ function assertSerializedSlot(value, context) {
|
|
|
552
652
|
assertBigIntString(value.value, context);
|
|
553
653
|
return;
|
|
554
654
|
}
|
|
655
|
+
if (value.$type === "number") {
|
|
656
|
+
assertStringField(value, "value", context);
|
|
657
|
+
assertNonFiniteNumberName(value.value, context);
|
|
658
|
+
return;
|
|
659
|
+
}
|
|
555
660
|
if (value.$type === "date" || value.$type === "url") {
|
|
556
661
|
assertStringField(value, "value", context);
|
|
557
662
|
if (value.$type === "date") assertIsoDateString(value.value, context);
|
|
@@ -573,6 +678,10 @@ function assertBigIntString(value, context) {
|
|
|
573
678
|
if (typeof value === "string" && /^-?(0|[1-9]\d*)$/.test(value)) return;
|
|
574
679
|
throw invalidPayloadShapeError(contextPayloadType(context), `Invalid ${context}: expected bigint string.`);
|
|
575
680
|
}
|
|
681
|
+
function assertNonFiniteNumberName(value, context) {
|
|
682
|
+
if (value === "Infinity" || value === "-Infinity" || value === "NaN") return;
|
|
683
|
+
throw invalidPayloadShapeError(contextPayloadType(context), `Invalid ${context}: expected non-finite number name.`);
|
|
684
|
+
}
|
|
576
685
|
function assertIsoDateString(value, context) {
|
|
577
686
|
if (typeof value === "string") {
|
|
578
687
|
const date = new Date(value);
|
|
@@ -607,7 +716,7 @@ function assertAsyncBoundaryReads(value, context) {
|
|
|
607
716
|
for (const [index, read] of value.entries()) {
|
|
608
717
|
const readContext = `${context}.asyncRead[${index}]`;
|
|
609
718
|
assertRecordShape(read, readContext);
|
|
610
|
-
|
|
719
|
+
assertOptionalStringField(read, "source", readContext);
|
|
611
720
|
assertStringField(read, "graphNodeId", readContext);
|
|
612
721
|
assertStringArrayField(read, "path", readContext);
|
|
613
722
|
assertOptionalStringField(read, "runnerSymbolId", readContext);
|
|
@@ -1,2 +1,2 @@
|
|
|
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-
|
|
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-C9YES3Zy.js";
|
|
2
2
|
export { DecodedPayloadScripts, EncodedPayloadScripts, RuntimePayloadDiagnostic, RuntimePayloadError, RuntimePayloadErrorCode, RuntimePayloadType, assertProtocolStateCellPayload, assertProtocolStatePayload, assertProtocolViewPayload, decodePayloadScripts, decodePayloadScriptsWithVersion, invalidPayloadShapeError, payloadInvalidError, payloadScriptSelector };
|
|
@@ -1,2 +1,2 @@
|
|
|
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-
|
|
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-DhyQ9fEO.js";
|
|
2
2
|
export { RuntimePayloadError, assertProtocolStateCellPayload, assertProtocolStatePayload, assertProtocolViewPayload, decodePayloadScripts, decodePayloadScriptsWithVersion, invalidPayloadShapeError, payloadInvalidError, payloadScriptSelector };
|
package/dist/protocol.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as
|
|
2
|
-
export { ASYNC_BOUNDARY_ARM, ASYNC_PROTOCOL_VERSION, PROTOCOL_EVENT_ACTION_KIND, PROTOCOL_PAGE_SPACE_ID_PREFIXES, PROTOCOL_PROPS_GRAPH_NODE_ID, PROTOCOL_PROP_GRAPH_NODE_PREFIX, ProtocolArmBranchRecord, ProtocolArmRecordSet, ProtocolAsyncBoundaryArm, ProtocolEventAction, ProtocolEventActionKind, ProtocolEventRecord, ProtocolPayloadScripts, ProtocolStatePayload, ProtocolStreamedArmPatch, ProtocolSyncPolicy, ProtocolSyncPolicyBranch, ProtocolSyncPolicyCondition, ProtocolViewPayload, STORAGE_PROTOCOL_VERSION, protocolEventActionKind, protocolEventDispatchesMarkless, protocolInstancePath, protocolInstanceQualifies, protocolInstanceSegment, protocolProjectionSegment, protocolRowSegment, protocolStateVersion };
|
|
1
|
+
import { A as protocolProjectionSegment, C as PROTOCOL_PAGE_SPACE_ID_PREFIXES, D as protocolInstancePath, E as STORAGE_PROTOCOL_VERSION, F as PROTOCOL_IDLE_EVENT_NAME, I as PROTOCOL_VISIBLE_EVENT_NAME, L as ASYNC_BOUNDARY_ARM, M as protocolStateVersion, N as PROTOCOL_SYNC_POLICY_HOST_ATTRIBUTE, O as protocolInstanceQualifies, P as PROTOCOL_LOCATOR_PATHS_ATTRIBUTE, S as PROTOCOL_EVENT_ACTION_KIND, T as PROTOCOL_PROP_GRAPH_NODE_PREFIX, _ as ProtocolViewPayload, a as ProtocolBranchIdrefSite, b as protocolEventDispatchesMarkless, c as ProtocolEventActionKind, d as ProtocolRowTemplateSlotValue, f as ProtocolStatePayload, g as ProtocolSyncPolicyCondition, h as ProtocolSyncPolicyBranch, i as ProtocolBranchContentRead, j as protocolRowSegment, k as protocolInstanceSegment, l as ProtocolEventRecord, m as ProtocolSyncPolicy, n as ProtocolArmRecordSet, o as ProtocolComposedGraphProp, p as ProtocolStreamedArmPatch, r as ProtocolAsyncBoundaryArm, s as ProtocolEventAction, t as ProtocolArmBranchRecord, u as ProtocolPayloadScripts, v as protocolElementHandleReadId, w as PROTOCOL_PROPS_GRAPH_NODE_ID, x as ASYNC_PROTOCOL_VERSION, y as protocolEventActionKind } from "./protocol-B3YIo3hD.js";
|
|
2
|
+
export { ASYNC_BOUNDARY_ARM, ASYNC_PROTOCOL_VERSION, PROTOCOL_EVENT_ACTION_KIND, PROTOCOL_IDLE_EVENT_NAME, PROTOCOL_LOCATOR_PATHS_ATTRIBUTE, PROTOCOL_PAGE_SPACE_ID_PREFIXES, PROTOCOL_PROPS_GRAPH_NODE_ID, PROTOCOL_PROP_GRAPH_NODE_PREFIX, PROTOCOL_SYNC_POLICY_HOST_ATTRIBUTE, PROTOCOL_VISIBLE_EVENT_NAME, ProtocolArmBranchRecord, ProtocolArmRecordSet, ProtocolAsyncBoundaryArm, ProtocolBranchContentRead, ProtocolBranchIdrefSite, ProtocolComposedGraphProp, ProtocolEventAction, ProtocolEventActionKind, ProtocolEventRecord, ProtocolPayloadScripts, ProtocolRowTemplateSlotValue, ProtocolStatePayload, ProtocolStreamedArmPatch, ProtocolSyncPolicy, ProtocolSyncPolicyBranch, ProtocolSyncPolicyCondition, ProtocolViewPayload, STORAGE_PROTOCOL_VERSION, protocolElementHandleReadId, protocolEventActionKind, protocolEventDispatchesMarkless, protocolInstancePath, protocolInstanceQualifies, protocolInstanceSegment, protocolProjectionSegment, protocolRowSegment, protocolStateVersion };
|
package/dist/protocol.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { ASYNC_BOUNDARY_ARM, ASYNC_PROTOCOL_VERSION, PROTOCOL_EVENT_ACTION_KIND, PROTOCOL_PAGE_SPACE_ID_PREFIXES, PROTOCOL_PROPS_GRAPH_NODE_ID, PROTOCOL_PROP_GRAPH_NODE_PREFIX, STORAGE_PROTOCOL_VERSION, protocolEventActionKind, protocolEventDispatchesMarkless, protocolInstancePath, protocolInstanceQualifies, protocolInstanceSegment, protocolProjectionSegment, protocolRowSegment, protocolStateVersion };
|
|
1
|
+
import { _ as PROTOCOL_SYNC_POLICY_HOST_ATTRIBUTE, a as ASYNC_PROTOCOL_VERSION, b as PROTOCOL_VISIBLE_EVENT_NAME, c as PROTOCOL_PROPS_GRAPH_NODE_ID, d as protocolInstancePath, f as protocolInstanceQualifies, g as protocolStateVersion, h as protocolRowSegment, i as ASYNC_BOUNDARY_ARM, l as PROTOCOL_PROP_GRAPH_NODE_PREFIX, m as protocolProjectionSegment, n as protocolEventActionKind, o as PROTOCOL_EVENT_ACTION_KIND, p as protocolInstanceSegment, r as protocolEventDispatchesMarkless, s as PROTOCOL_PAGE_SPACE_ID_PREFIXES, t as protocolElementHandleReadId, u as STORAGE_PROTOCOL_VERSION, v as PROTOCOL_LOCATOR_PATHS_ATTRIBUTE, y as PROTOCOL_IDLE_EVENT_NAME } from "./protocol-BbWeZfik.js";
|
|
2
|
+
export { ASYNC_BOUNDARY_ARM, ASYNC_PROTOCOL_VERSION, PROTOCOL_EVENT_ACTION_KIND, PROTOCOL_IDLE_EVENT_NAME, PROTOCOL_LOCATOR_PATHS_ATTRIBUTE, PROTOCOL_PAGE_SPACE_ID_PREFIXES, PROTOCOL_PROPS_GRAPH_NODE_ID, PROTOCOL_PROP_GRAPH_NODE_PREFIX, PROTOCOL_SYNC_POLICY_HOST_ATTRIBUTE, PROTOCOL_VISIBLE_EVENT_NAME, STORAGE_PROTOCOL_VERSION, protocolElementHandleReadId, protocolEventActionKind, protocolEventDispatchesMarkless, protocolInstancePath, protocolInstanceQualifies, protocolInstanceSegment, protocolProjectionSegment, protocolRowSegment, protocolStateVersion };
|
|
@@ -10,7 +10,12 @@ type SerializedPrimitive = null | string | number | boolean | {
|
|
|
10
10
|
} | {
|
|
11
11
|
readonly $type: 'bigint';
|
|
12
12
|
readonly value: string;
|
|
13
|
+
} | {
|
|
14
|
+
readonly $type: 'number';
|
|
15
|
+
readonly value: NonFiniteNumberName;
|
|
13
16
|
};
|
|
17
|
+
/** JSON has no form for these, so a bare number slot would print as `null`. */
|
|
18
|
+
type NonFiniteNumberName = 'Infinity' | '-Infinity' | 'NaN';
|
|
14
19
|
type SerializedSlot = SerializedPrimitive | {
|
|
15
20
|
readonly $ref: number;
|
|
16
21
|
} | {
|
|
@@ -101,5 +106,16 @@ type SerializationResult = {
|
|
|
101
106
|
readonly diagnostics: ReadonlyArray<SerializationDiagnostic>;
|
|
102
107
|
};
|
|
103
108
|
declare function serializeGraphValue(value: unknown): SerializationResult;
|
|
109
|
+
declare function nonFiniteName(value: number): NonFiniteNumberName;
|
|
110
|
+
/**
|
|
111
|
+
* A value printed as the JavaScript that denotes it, where JSON would print a
|
|
112
|
+
* non-finite number as `null`.
|
|
113
|
+
*
|
|
114
|
+
* Emitted modules are JavaScript, so the name this module gives `Infinity` /
|
|
115
|
+
* `-Infinity` / `NaN` denotes those values exactly. A payload with no non-finite
|
|
116
|
+
* number returns `JSON.stringify`'s own bytes, and `undefined` where
|
|
117
|
+
* `JSON.stringify` returns nothing.
|
|
118
|
+
*/
|
|
119
|
+
declare function jsonSourceWithNonFiniteNumbers(value: unknown): string | undefined;
|
|
104
120
|
//#endregion
|
|
105
|
-
export {
|
|
121
|
+
export { SerializedPrimitive as a, TypedArrayName as c, serializeGraphValue as d, deserializeGraphValue as f, SerializedGraphPayload as i, jsonSourceWithNonFiniteNumbers as l, SerializationDiagnostic as n, SerializedRecord as o, SerializationResult as r, SerializedSlot as s, NonFiniteNumberName as t, nonFiniteName as u };
|
package/package.json
CHANGED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
//#region src/protocol-constants.ts
|
|
2
|
-
const ASYNC_PROTOCOL_VERSION = 1;
|
|
3
|
-
const STORAGE_PROTOCOL_VERSION = 2;
|
|
4
|
-
function protocolStateVersion(storage) {
|
|
5
|
-
return (storage?.length ?? 0) > 0 ? 2 : 1;
|
|
6
|
-
}
|
|
7
|
-
const PROTOCOL_EVENT_ACTION_KIND = {
|
|
8
|
-
event: "event",
|
|
9
|
-
externalDelegate: "external-delegate"
|
|
10
|
-
};
|
|
11
|
-
const PROTOCOL_INSTANCE_PATH = /^(?:[cp]\d+:|r:[^:]*:)+/;
|
|
12
|
-
function protocolInstanceSegment(edgeIndex) {
|
|
13
|
-
return `c${edgeIndex}:`;
|
|
14
|
-
}
|
|
15
|
-
function protocolProjectionSegment(edgeIndex) {
|
|
16
|
-
return `p${edgeIndex}:`;
|
|
17
|
-
}
|
|
18
|
-
/** One keyed `@for` row's identity segment. The key is identity, never the index. */
|
|
19
|
-
function protocolRowSegment(key) {
|
|
20
|
-
return `r:${encodeURIComponent(String(key))}:`;
|
|
21
|
-
}
|
|
22
|
-
/** The leading instance path of a composed id, or '' when the id is page-local. */
|
|
23
|
-
function protocolInstancePath(id) {
|
|
24
|
-
return PROTOCOL_INSTANCE_PATH.exec(id)?.[0] ?? "";
|
|
25
|
-
}
|
|
26
|
-
const PROTOCOL_PROPS_GRAPH_NODE_ID = "prop:props";
|
|
27
|
-
const PROTOCOL_PROP_GRAPH_NODE_PREFIX = "prop:";
|
|
28
|
-
const PROTOCOL_INSTANCE_QUALIFIABLE = [
|
|
29
|
-
"prop:",
|
|
30
|
-
"state:",
|
|
31
|
-
"computed:",
|
|
32
|
-
"element:"
|
|
33
|
-
];
|
|
34
|
-
const PROTOCOL_PAGE_SPACE_ID_PREFIXES = ["shared:", "storage:"];
|
|
35
|
-
function protocolInstanceQualifies(graphNodeId) {
|
|
36
|
-
const local = graphNodeId.slice(protocolInstancePath(graphNodeId).length);
|
|
37
|
-
if (PROTOCOL_PAGE_SPACE_ID_PREFIXES.some((prefix) => local.startsWith(prefix))) return false;
|
|
38
|
-
return PROTOCOL_INSTANCE_QUALIFIABLE.some((prefix) => local.startsWith(prefix)) ? true : void 0;
|
|
39
|
-
}
|
|
40
|
-
//#endregion
|
|
41
|
-
//#region src/async-boundary-arm.ts
|
|
42
|
-
const ASYNC_BOUNDARY_ARM = {
|
|
43
|
-
try: 0,
|
|
44
|
-
pending: 1,
|
|
45
|
-
catch: 2
|
|
46
|
-
};
|
|
47
|
-
//#endregion
|
|
48
|
-
//#region src/protocol.ts
|
|
49
|
-
function protocolEventActionKind(record) {
|
|
50
|
-
return record.action?.kind ?? PROTOCOL_EVENT_ACTION_KIND.event;
|
|
51
|
-
}
|
|
52
|
-
function protocolEventDispatchesMarkless(record) {
|
|
53
|
-
return protocolEventActionKind(record) === PROTOCOL_EVENT_ACTION_KIND.event;
|
|
54
|
-
}
|
|
55
|
-
//#endregion
|
|
56
|
-
export { PROTOCOL_EVENT_ACTION_KIND as a, PROTOCOL_PROP_GRAPH_NODE_PREFIX as c, protocolInstanceQualifies as d, protocolInstanceSegment as f, protocolStateVersion as h, ASYNC_PROTOCOL_VERSION as i, STORAGE_PROTOCOL_VERSION as l, protocolRowSegment as m, protocolEventDispatchesMarkless as n, PROTOCOL_PAGE_SPACE_ID_PREFIXES as o, protocolProjectionSegment as p, ASYNC_BOUNDARY_ARM as r, PROTOCOL_PROPS_GRAPH_NODE_ID as s, protocolEventActionKind as t, protocolInstancePath as u };
|