@markless/serializer 0.4.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/decode-client.d.ts +4 -5
- package/dist/decode-client.js +2 -1
- package/dist/decode.d.ts +2 -2
- package/dist/decode.js +1 -0
- package/dist/index.d.ts +33 -26
- package/dist/index.js +71 -5
- package/dist/protocol-9Mv28nr_.js +98 -0
- package/dist/protocol-BNO5JLsK.d.ts +668 -0
- package/dist/{protocol-validation-storage-DGj6FaG-.d.ts → protocol-validation-storage-B4dATVQ_.d.ts} +1 -2
- package/dist/{protocol-validation-storage-C4NuHqQw.js → protocol-validation-storage-ycVVe95T.js} +123 -13
- package/dist/protocol-validation.d.ts +1 -1
- package/dist/protocol-validation.js +1 -1
- package/dist/protocol.d.ts +2 -2
- package/dist/protocol.js +2 -2
- package/dist/{value-BJ6YNKDd.d.ts → value-CRkHmkRz.d.ts} +17 -1
- package/package.json +1 -1
- package/dist/protocol-BwMZfNSA.js +0 -56
- package/dist/protocol-CGsMO85z.d.ts +0 -363
- /package/dist/{value-decode-extensions-Bf-pgKHA.js → value-decode-extensions-xfgotsAg.js} +0 -0
package/dist/{protocol-validation-storage-C4NuHqQw.js → protocol-validation-storage-ycVVe95T.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as ASYNC_BOUNDARY_ARM, o as PROTOCOL_EVENT_ACTION_KIND } from "./protocol-9Mv28nr_.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,32 +195,102 @@ 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);
|
|
213
|
+
if (repeat.rowEndOffset !== void 0) assertNonNegativeIntegerField(repeat, "rowEndOffset", context);
|
|
198
214
|
assertRowEvents(repeat.rowEvents, `${context}.rowEvents`);
|
|
199
215
|
assertOptionalRowElementHandles(repeat, `${context}.rowElementHandles`);
|
|
200
216
|
assertOptionalEmptyArm(repeat, `${context}.emptyArm`);
|
|
201
217
|
assertOptionalRowTemplate(repeat, `${context}.rowTemplate`);
|
|
202
|
-
|
|
218
|
+
assertOptionalPropRoutes(repeat, `${context}.propRoutes`);
|
|
219
|
+
assertOptionalRowComponent(repeat, `${context}.rowComponent`);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
function assertOptionalEnclosingRow(record, context) {
|
|
223
|
+
const enclosingRow = record.enclosingRow;
|
|
224
|
+
if (enclosingRow === void 0) return;
|
|
225
|
+
assertRecordShape(enclosingRow, context);
|
|
226
|
+
assertStringField(enclosingRow, "repeatId", context);
|
|
227
|
+
assertNonNegativeIntegerArrayField(enclosingRow, "parentHostPath", context);
|
|
228
|
+
assertOptionalStringArrayField(enclosingRow, "itemPath", context);
|
|
229
|
+
}
|
|
230
|
+
function assertOptionalPropRoutes(record, context) {
|
|
231
|
+
const routes = record.propRoutes;
|
|
232
|
+
if (routes === void 0) return;
|
|
233
|
+
if (!Array.isArray(routes)) throw invalidPayloadShapeError(contextPayloadType(context), `Invalid ${context}: expected array.`);
|
|
234
|
+
for (const [index, route] of routes.entries()) {
|
|
235
|
+
const routeContext = `${context}[${index}]`;
|
|
236
|
+
assertRecordShape(route, routeContext);
|
|
237
|
+
assertStringField(route, "name", routeContext);
|
|
238
|
+
assertStringField(route, "graphNodeId", routeContext);
|
|
239
|
+
assertStringArrayField(route, "path", routeContext);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
function assertOptionalRowComponent(record, context) {
|
|
243
|
+
const rowComponent = record.rowComponent;
|
|
244
|
+
if (rowComponent === void 0) return;
|
|
245
|
+
assertRecordShape(rowComponent, context);
|
|
246
|
+
if (rowComponent.rowChunkId === void 0) assertStringField(rowComponent, "componentEdgeId", context);
|
|
247
|
+
else assertStringField(rowComponent, "rowChunkId", context);
|
|
248
|
+
assertStringField(rowComponent, "componentName", context);
|
|
249
|
+
assertOptionalStringField(rowComponent, "itemPropName", context);
|
|
250
|
+
if (rowComponent.slotPath !== void 0) assertNonNegativeIntegerArrayField(rowComponent, "slotPath", context);
|
|
203
251
|
}
|
|
204
252
|
function assertOptionalRowTemplate(record, context) {
|
|
205
253
|
const template = record.rowTemplate;
|
|
206
254
|
if (template === void 0) return;
|
|
207
255
|
assertRecordShape(template, context);
|
|
208
256
|
assertStringField(template, "html", context);
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
257
|
+
assertOptionalStringField(template, "componentName", context);
|
|
258
|
+
assertOptionalRowTemplateSlots(template.textSlots, `${context}.textSlots`);
|
|
259
|
+
assertOptionalRowTemplateSlots(template.attributeSlots, `${context}.attributeSlots`, true);
|
|
260
|
+
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.`);
|
|
261
|
+
}
|
|
262
|
+
function assertOptionalRowTemplateSlots(slots, context, named = false) {
|
|
263
|
+
if (slots === void 0) return;
|
|
264
|
+
if (!Array.isArray(slots)) throw invalidPayloadShapeError(contextPayloadType(context), `Invalid ${context}: expected array.`);
|
|
265
|
+
for (const [index, slot] of slots.entries()) {
|
|
266
|
+
const slotContext = `${context}[${index}]`;
|
|
214
267
|
assertRecordShape(slot, slotContext);
|
|
215
268
|
assertNonNegativeIntegerArrayField(slot, "path", slotContext);
|
|
216
|
-
|
|
269
|
+
if (named) assertStringField(slot, "name", slotContext);
|
|
270
|
+
assertRowTemplateSlotValue(slot, slotContext);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
function assertRowTemplateSlotValue(slot, context) {
|
|
274
|
+
const fromItem = slot.itemPath !== void 0, fromGraph = slot.graphNodeId !== void 0 || slot.graphPath !== void 0, fromSource = slot.source !== void 0;
|
|
275
|
+
if (Number(fromItem) + Number(fromGraph) + Number(fromSource) !== 1) throw invalidPayloadShapeError(contextPayloadType(context), `Invalid ${context}: expected exactly one of itemPath, graphNodeId with graphPath, or source.`);
|
|
276
|
+
if (slot.reads !== void 0 && !fromSource) throw invalidPayloadShapeError(contextPayloadType(context), `Invalid ${context}: reads belongs to a source slot.`);
|
|
277
|
+
if (fromItem) {
|
|
278
|
+
assertStringArrayField(slot, "itemPath", context);
|
|
279
|
+
return;
|
|
217
280
|
}
|
|
281
|
+
if (fromSource) {
|
|
282
|
+
assertStringField(slot, "source", context);
|
|
283
|
+
if (slot.reads === void 0) return;
|
|
284
|
+
if (!Array.isArray(slot.reads)) throw invalidPayloadShapeError(contextPayloadType(context), `Invalid ${context}.reads: expected array.`);
|
|
285
|
+
for (const [index, read] of slot.reads.entries()) {
|
|
286
|
+
assertRecordShape(read, `${context}.reads[${index}]`);
|
|
287
|
+
assertStringField(read, "graphNodeId", `${context}.reads[${index}]`);
|
|
288
|
+
assertStringArrayField(read, "path", `${context}.reads[${index}]`);
|
|
289
|
+
}
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
assertStringField(slot, "graphNodeId", context);
|
|
293
|
+
assertStringArrayField(slot, "graphPath", context);
|
|
218
294
|
}
|
|
219
295
|
function assertOptionalEmptyArm(record, context) {
|
|
220
296
|
const arm = record.emptyArm;
|
|
@@ -251,8 +327,33 @@ function assertOptionalBranches(record) {
|
|
|
251
327
|
assertCommentAnchor(branch.endAnchor, `${context}.endAnchor`);
|
|
252
328
|
assertOptionalStringField(branch, "symbolId", context);
|
|
253
329
|
assertOptionalGraphReads(branch, "testReads", context);
|
|
330
|
+
assertOptionalGraphReads(branch, "contentReads", context);
|
|
254
331
|
if (branch.armTests !== void 0 && !Array.isArray(branch.armTests)) throw invalidPayloadShapeError(contextPayloadType(context), `Invalid ${context}: expected armTests array.`);
|
|
255
332
|
assertOptionalBranchArmRecords(branch, context);
|
|
333
|
+
assertOptionalServedArmRecords(branch, context);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
function assertOptionalServedArmRecords(record, context) {
|
|
337
|
+
if (record.servedArmRecords === void 0) return;
|
|
338
|
+
if (record.escalates !== true) throw invalidPayloadShapeError(contextPayloadType(context), `Invalid ${context}: servedArmRecords requires escalates.`);
|
|
339
|
+
const armContext = `${context}.servedArmRecords`;
|
|
340
|
+
assertRecordShape(record.servedArmRecords, armContext);
|
|
341
|
+
const arm = record.servedArmRecords;
|
|
342
|
+
assertArrayField(arm, "events", armContext);
|
|
343
|
+
assertArrayField(arm, "behaviors", armContext);
|
|
344
|
+
assertArrayField(arm, "elementHandles", armContext);
|
|
345
|
+
assertOptionalArrayField(arm, "domUpdates", armContext);
|
|
346
|
+
assertOptionalArrayField(arm, "keyedRepeats", armContext);
|
|
347
|
+
assertOptionalArrayField(arm, "branches", armContext);
|
|
348
|
+
assertArrayField(arm, "locators", armContext);
|
|
349
|
+
for (const [index, locator] of arm.locators.entries()) {
|
|
350
|
+
const locatorContext = `${armContext}.locators[${index}]`;
|
|
351
|
+
assertRecordShape(locator, locatorContext);
|
|
352
|
+
const entry = locator;
|
|
353
|
+
assertStringField(entry, "hostNodeId", locatorContext);
|
|
354
|
+
assertStringField(entry, "tagName", locatorContext);
|
|
355
|
+
if ("strategy" in entry) throw invalidPayloadShapeError(contextPayloadType(locatorContext), `Invalid ${locatorContext}: an arm-relative locator carries no strategy.`);
|
|
356
|
+
assertNonNegativeIntegerField(entry, "index", locatorContext);
|
|
256
357
|
}
|
|
257
358
|
}
|
|
258
359
|
function assertOptionalBranchArmRecords(record, context) {
|
|
@@ -285,7 +386,7 @@ function assertOptionalGraphReads(record, key, context) {
|
|
|
285
386
|
for (const [index, read] of reads.entries()) {
|
|
286
387
|
const readContext = `${context}.${key}[${index}]`;
|
|
287
388
|
assertRecordShape(read, readContext);
|
|
288
|
-
|
|
389
|
+
assertOptionalStringField(read, "source", readContext);
|
|
289
390
|
assertStringField(read, "graphNodeId", readContext);
|
|
290
391
|
assertStringArrayField(read, "path", readContext);
|
|
291
392
|
}
|
|
@@ -297,7 +398,7 @@ function assertOptionalBehaviorInputGraphReads(record, context) {
|
|
|
297
398
|
const readContext = `${context}.inputGraphReads[${index}]`;
|
|
298
399
|
assertRecordShape(read, readContext);
|
|
299
400
|
assertNonNegativeIntegerField(read, "inputIndex", readContext);
|
|
300
|
-
|
|
401
|
+
assertOptionalStringField(read, "source", readContext);
|
|
301
402
|
assertStringField(read, "graphNodeId", readContext);
|
|
302
403
|
assertStringArrayField(read, "path", readContext);
|
|
303
404
|
}
|
|
@@ -552,6 +653,11 @@ function assertSerializedSlot(value, context) {
|
|
|
552
653
|
assertBigIntString(value.value, context);
|
|
553
654
|
return;
|
|
554
655
|
}
|
|
656
|
+
if (value.$type === "number") {
|
|
657
|
+
assertStringField(value, "value", context);
|
|
658
|
+
assertNonFiniteNumberName(value.value, context);
|
|
659
|
+
return;
|
|
660
|
+
}
|
|
555
661
|
if (value.$type === "date" || value.$type === "url") {
|
|
556
662
|
assertStringField(value, "value", context);
|
|
557
663
|
if (value.$type === "date") assertIsoDateString(value.value, context);
|
|
@@ -573,6 +679,10 @@ function assertBigIntString(value, context) {
|
|
|
573
679
|
if (typeof value === "string" && /^-?(0|[1-9]\d*)$/.test(value)) return;
|
|
574
680
|
throw invalidPayloadShapeError(contextPayloadType(context), `Invalid ${context}: expected bigint string.`);
|
|
575
681
|
}
|
|
682
|
+
function assertNonFiniteNumberName(value, context) {
|
|
683
|
+
if (value === "Infinity" || value === "-Infinity" || value === "NaN") return;
|
|
684
|
+
throw invalidPayloadShapeError(contextPayloadType(context), `Invalid ${context}: expected non-finite number name.`);
|
|
685
|
+
}
|
|
576
686
|
function assertIsoDateString(value, context) {
|
|
577
687
|
if (typeof value === "string") {
|
|
578
688
|
const date = new Date(value);
|
|
@@ -607,7 +717,7 @@ function assertAsyncBoundaryReads(value, context) {
|
|
|
607
717
|
for (const [index, read] of value.entries()) {
|
|
608
718
|
const readContext = `${context}.asyncRead[${index}]`;
|
|
609
719
|
assertRecordShape(read, readContext);
|
|
610
|
-
|
|
720
|
+
assertOptionalStringField(read, "source", readContext);
|
|
611
721
|
assertStringField(read, "graphNodeId", readContext);
|
|
612
722
|
assertStringArrayField(read, "path", readContext);
|
|
613
723
|
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-B4dATVQ_.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-ycVVe95T.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 protocolRowSegment, B as ASYNC_BOUNDARY_ARM, C as PROTOCOL_PAGE_SPACE_ID_PREFIXES, D as protocolInstanceQualifies, E as protocolInstancePath, F as PROTOCOL_CONTAINER_HOST_NODE_ID, I as PROTOCOL_CONTAINER_START_COMMENT, L as PROTOCOL_LOCATOR_PATHS_ATTRIBUTE, M as PROTOCOL_PROP_GRAPH_NODE_PREFIX, N as PROTOCOL_SYNC_POLICY_HOST_ATTRIBUTE, O as protocolInstanceSegment, P as PROTOCOL_CONTAINER_END_COMMENT, R as PROTOCOL_IDLE_EVENT_NAME, S as PROTOCOL_EVENT_ACTION_KIND, T as STORAGE_PROTOCOL_VERSION, _ as ProtocolViewPayload, a as ProtocolBranchIdrefSite, b as protocolEventDispatchesMarkless, c as ProtocolEventActionKind, d as ProtocolRowTemplateSlotValue, f as ProtocolStatePayload, g as ProtocolSyncPolicyCondition, h as ProtocolSyncPolicyBranch, i as ProtocolBranchContentRead, j as protocolStateVersion, k as protocolProjectionSegment, l as ProtocolEventRecord, m as ProtocolSyncPolicy, n as ProtocolArmRecordSet, o as ProtocolComposedGraphProp, p as ProtocolStreamedArmPatch, r as ProtocolAsyncBoundaryArm, s as ProtocolEventAction, t as ProtocolArmBranchRecord, u as ProtocolPayloadScripts, v as protocolElementHandleReadId, w as PROTOCOL_PROPS_GRAPH_NODE_ID, x as ASYNC_PROTOCOL_VERSION, y as protocolEventActionKind, z as PROTOCOL_VISIBLE_EVENT_NAME } from "./protocol-BNO5JLsK.js";
|
|
2
|
+
export { ASYNC_BOUNDARY_ARM, ASYNC_PROTOCOL_VERSION, PROTOCOL_CONTAINER_END_COMMENT, PROTOCOL_CONTAINER_HOST_NODE_ID, PROTOCOL_CONTAINER_START_COMMENT, PROTOCOL_EVENT_ACTION_KIND, PROTOCOL_IDLE_EVENT_NAME, PROTOCOL_LOCATOR_PATHS_ATTRIBUTE, PROTOCOL_PAGE_SPACE_ID_PREFIXES, PROTOCOL_PROPS_GRAPH_NODE_ID, PROTOCOL_PROP_GRAPH_NODE_PREFIX, PROTOCOL_SYNC_POLICY_HOST_ATTRIBUTE, PROTOCOL_VISIBLE_EVENT_NAME, 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 { C as PROTOCOL_VISIBLE_EVENT_NAME, S as PROTOCOL_IDLE_EVENT_NAME, _ as PROTOCOL_SYNC_POLICY_HOST_ATTRIBUTE, a as ASYNC_PROTOCOL_VERSION, b as PROTOCOL_CONTAINER_START_COMMENT, c as PROTOCOL_PROPS_GRAPH_NODE_ID, d as protocolInstanceQualifies, f as protocolInstanceSegment, g as PROTOCOL_PROP_GRAPH_NODE_PREFIX, h as protocolStateVersion, i as ASYNC_BOUNDARY_ARM, l as STORAGE_PROTOCOL_VERSION, m as protocolRowSegment, n as protocolEventActionKind, o as PROTOCOL_EVENT_ACTION_KIND, p as protocolProjectionSegment, r as protocolEventDispatchesMarkless, s as PROTOCOL_PAGE_SPACE_ID_PREFIXES, t as protocolElementHandleReadId, u as protocolInstancePath, v as PROTOCOL_CONTAINER_END_COMMENT, x as PROTOCOL_LOCATOR_PATHS_ATTRIBUTE, y as PROTOCOL_CONTAINER_HOST_NODE_ID } from "./protocol-9Mv28nr_.js";
|
|
2
|
+
export { ASYNC_BOUNDARY_ARM, ASYNC_PROTOCOL_VERSION, PROTOCOL_CONTAINER_END_COMMENT, PROTOCOL_CONTAINER_HOST_NODE_ID, PROTOCOL_CONTAINER_START_COMMENT, PROTOCOL_EVENT_ACTION_KIND, PROTOCOL_IDLE_EVENT_NAME, PROTOCOL_LOCATOR_PATHS_ATTRIBUTE, PROTOCOL_PAGE_SPACE_ID_PREFIXES, PROTOCOL_PROPS_GRAPH_NODE_ID, PROTOCOL_PROP_GRAPH_NODE_PREFIX, PROTOCOL_SYNC_POLICY_HOST_ATTRIBUTE, PROTOCOL_VISIBLE_EVENT_NAME, 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 };
|