@markless/serializer 0.3.3 → 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.
@@ -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 };
@@ -1,5 +1,4 @@
1
- import { l as ProtocolStatePayload, m as ProtocolViewPayload } from "./protocol-BfzeLgjZ.js";
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;
@@ -1,4 +1,4 @@
1
- import { i as ASYNC_BOUNDARY_ARM, t as PROTOCOL_EVENT_ACTION_KIND } from "./protocol-BX4yw9bm.js";
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
- assertStringField(domUpdate, "source", context);
91
+ assertOptionalStringField(domUpdate, "source", context);
90
92
  assertStringField(domUpdate, "graphNodeId", context);
91
93
  assertStringArrayField(domUpdate, "path", context);
92
94
  assertOptionalDomUpdateTarget(domUpdate.target, `${context}.target`);
@@ -109,6 +111,7 @@ function assertProtocolViewPayload(payload) {
109
111
  assertStringField(handle, "hostNodeId", context);
110
112
  assertStringField(handle, "handleId", context);
111
113
  assertStringField(handle, "name", context);
114
+ assertOptionalBooleanField(handle, "plural", context);
112
115
  }
113
116
  for (const [index, boundary] of asyncBoundaries.entries()) {
114
117
  const context = `markless/view asyncBoundary[${index}]`;
@@ -131,7 +134,8 @@ function assertOptionalEventAction(value, context) {
131
134
  if (value === void 0) return;
132
135
  assertRecordShape(value, context);
133
136
  assertStringField(value, "kind", context);
134
- const validate = EVENT_ACTION_VALIDATORS[value.kind];
137
+ const kind = value.kind;
138
+ const validate = EVENT_ACTION_VALIDATORS[kind];
135
139
  if (!validate) throw invalidPayloadShapeError(contextPayloadType(context), `Invalid ${context}: unknown event action kind.`);
136
140
  validate(value, context);
137
141
  }
@@ -177,6 +181,9 @@ function assertNonNegativeIntegerArrayField(record, key, context) {
177
181
  function assertOptionalStringArrayField(record, key, context) {
178
182
  if (record[key] !== void 0) assertStringArrayField(record, key, context);
179
183
  }
184
+ function assertArrayField(record, key, context) {
185
+ if (!Array.isArray(record[key])) throw invalidPayloadShapeError(contextPayloadType(context), `Invalid ${context}: expected ${key} array.`);
186
+ }
180
187
  function assertOptionalArrayField(record, key, context) {
181
188
  if (record[key] !== void 0 && !Array.isArray(record[key])) throw invalidPayloadShapeError(contextPayloadType(context), `Invalid ${context}: expected ${key} array.`);
182
189
  }
@@ -188,13 +195,125 @@ function assertOptionalKeyedRepeats(record) {
188
195
  assertRecordShape(repeat, context);
189
196
  assertStringField(repeat, "id", context);
190
197
  assertStringField(repeat, "parentHostNodeId", context);
198
+ assertOptionalStringField(repeat, "ownerHostNodeId", context);
199
+ assertOptionalStringField(repeat, "instancePath", context);
200
+ assertOptionalEnclosingRow(repeat, `${context}.enclosingRow`);
191
201
  assertOptionalStringField(repeat, "collectionGraphNodeId", context);
192
202
  assertStringArrayField(repeat, "collectionPath", context);
193
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
+ }
194
210
  assertStringField(repeat, "itemName", context);
195
211
  assertNonNegativeIntegerField(repeat, "rowElementCount", context);
212
+ if (repeat.rowStartOffset !== void 0) assertNonNegativeIntegerField(repeat, "rowStartOffset", context);
196
213
  assertRowEvents(repeat.rowEvents, `${context}.rowEvents`);
214
+ assertOptionalRowElementHandles(repeat, `${context}.rowElementHandles`);
215
+ assertOptionalEmptyArm(repeat, `${context}.emptyArm`);
216
+ assertOptionalRowTemplate(repeat, `${context}.rowTemplate`);
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);
250
+ }
251
+ function assertOptionalRowTemplate(record, context) {
252
+ const template = record.rowTemplate;
253
+ if (template === void 0) return;
254
+ assertRecordShape(template, context);
255
+ assertStringField(template, "html", context);
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}]`;
266
+ assertRecordShape(slot, slotContext);
267
+ assertNonNegativeIntegerArrayField(slot, "path", slotContext);
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;
197
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);
293
+ }
294
+ function assertOptionalEmptyArm(record, context) {
295
+ const arm = record.emptyArm;
296
+ if (arm === void 0) return;
297
+ assertRecordShape(arm, context);
298
+ assertStringField(arm, "html", context);
299
+ }
300
+ function assertOptionalRowElementHandles(record, context) {
301
+ const handles = record.rowElementHandles;
302
+ if (handles === void 0) return;
303
+ if (!Array.isArray(handles)) throw invalidPayloadShapeError(contextPayloadType(context), `Invalid ${context}: expected array.`);
304
+ for (const [index, handle] of handles.entries()) {
305
+ const handleContext = `${context}[${index}]`;
306
+ assertRecordShape(handle, handleContext);
307
+ assertNonNegativeIntegerArrayField(handle, "hostPath", handleContext);
308
+ assertStringField(handle, "handleId", handleContext);
309
+ assertStringField(handle, "name", handleContext);
310
+ assertOptionalBooleanField(handle, "plural", handleContext);
311
+ }
312
+ }
313
+ function assertOptionalBooleanField(record, key, context) {
314
+ const value = record[key];
315
+ if (value === void 0 || typeof value === "boolean") return;
316
+ throw invalidPayloadShapeError(contextPayloadType(context), `Invalid ${context}: expected ${key} boolean.`);
198
317
  }
199
318
  function assertOptionalBranches(record) {
200
319
  if (record.branches === void 0) return;
@@ -207,8 +326,33 @@ function assertOptionalBranches(record) {
207
326
  assertCommentAnchor(branch.endAnchor, `${context}.endAnchor`);
208
327
  assertOptionalStringField(branch, "symbolId", context);
209
328
  assertOptionalGraphReads(branch, "testReads", context);
329
+ assertOptionalGraphReads(branch, "contentReads", context);
210
330
  if (branch.armTests !== void 0 && !Array.isArray(branch.armTests)) throw invalidPayloadShapeError(contextPayloadType(context), `Invalid ${context}: expected armTests array.`);
211
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);
212
356
  }
213
357
  }
214
358
  function assertOptionalBranchArmRecords(record, context) {
@@ -241,7 +385,7 @@ function assertOptionalGraphReads(record, key, context) {
241
385
  for (const [index, read] of reads.entries()) {
242
386
  const readContext = `${context}.${key}[${index}]`;
243
387
  assertRecordShape(read, readContext);
244
- assertStringField(read, "source", readContext);
388
+ assertOptionalStringField(read, "source", readContext);
245
389
  assertStringField(read, "graphNodeId", readContext);
246
390
  assertStringArrayField(read, "path", readContext);
247
391
  }
@@ -253,7 +397,7 @@ function assertOptionalBehaviorInputGraphReads(record, context) {
253
397
  const readContext = `${context}.inputGraphReads[${index}]`;
254
398
  assertRecordShape(read, readContext);
255
399
  assertNonNegativeIntegerField(read, "inputIndex", readContext);
256
- assertStringField(read, "source", readContext);
400
+ assertOptionalStringField(read, "source", readContext);
257
401
  assertStringField(read, "graphNodeId", readContext);
258
402
  assertStringArrayField(read, "path", readContext);
259
403
  }
@@ -280,14 +424,15 @@ function assertOptionalSharedDefinitions(record) {
280
424
  assertOptionalSharedScope(definition, context);
281
425
  assertNonNegativeIntegerField(definition, "version", context);
282
426
  assertStringArrayField(definition, "graphNodeIds", context);
427
+ assertOptionalStringArrayField(definition, "projectionIds", context);
283
428
  assertOptionalSharedDependencies(definition, context);
284
429
  assertOptionalSharedReturnProperties(definition, context);
285
430
  }
286
431
  }
287
432
  function assertOptionalSharedScope(record, context) {
288
433
  if (record.scope === void 0) return;
289
- if (record.scope === "request" || record.scope === "container" || record.scope === "page") return;
290
- throw invalidPayloadShapeError(contextPayloadType(context), `Invalid ${context}: expected scope request, container, or page.`);
434
+ if (record.scope === "widget" || record.scope === "request" || record.scope === "container" || record.scope === "page") return;
435
+ throw invalidPayloadShapeError(contextPayloadType(context), `Invalid ${context}: expected scope widget, request, container, or page.`);
291
436
  }
292
437
  function assertOptionalSharedDependencies(record, context) {
293
438
  if (record.dependencies === void 0) return;
@@ -507,6 +652,11 @@ function assertSerializedSlot(value, context) {
507
652
  assertBigIntString(value.value, context);
508
653
  return;
509
654
  }
655
+ if (value.$type === "number") {
656
+ assertStringField(value, "value", context);
657
+ assertNonFiniteNumberName(value.value, context);
658
+ return;
659
+ }
510
660
  if (value.$type === "date" || value.$type === "url") {
511
661
  assertStringField(value, "value", context);
512
662
  if (value.$type === "date") assertIsoDateString(value.value, context);
@@ -528,6 +678,10 @@ function assertBigIntString(value, context) {
528
678
  if (typeof value === "string" && /^-?(0|[1-9]\d*)$/.test(value)) return;
529
679
  throw invalidPayloadShapeError(contextPayloadType(context), `Invalid ${context}: expected bigint string.`);
530
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
+ }
531
685
  function assertIsoDateString(value, context) {
532
686
  if (typeof value === "string") {
533
687
  const date = new Date(value);
@@ -562,7 +716,7 @@ function assertAsyncBoundaryReads(value, context) {
562
716
  for (const [index, read] of value.entries()) {
563
717
  const readContext = `${context}.asyncRead[${index}]`;
564
718
  assertRecordShape(read, readContext);
565
- assertStringField(read, "source", readContext);
719
+ assertOptionalStringField(read, "source", readContext);
566
720
  assertStringField(read, "graphNodeId", readContext);
567
721
  assertStringArrayField(read, "path", readContext);
568
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-DogbS8xp.js";
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-BQ8D2S5j.js";
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 };
@@ -1,2 +1,2 @@
1
- import { _ as ASYNC_PROTOCOL_VERSION, a as ProtocolEventAction, b as ASYNC_BOUNDARY_ARM, 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 protocolStateVersion } from "./protocol-BfzeLgjZ.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, 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 ASYNC_PROTOCOL_VERSION, i as ASYNC_BOUNDARY_ARM, n as protocolEventActionKind, o as STORAGE_PROTOCOL_VERSION, r as protocolEventDispatchesMarkless, s as protocolStateVersion, t as PROTOCOL_EVENT_ACTION_KIND } from "./protocol-BX4yw9bm.js";
2
- export { ASYNC_BOUNDARY_ARM, ASYNC_PROTOCOL_VERSION, PROTOCOL_EVENT_ACTION_KIND, STORAGE_PROTOCOL_VERSION, protocolEventActionKind, protocolEventDispatchesMarkless, 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 { SerializedRecord as a, serializeGraphValue as c, SerializedPrimitive as i, deserializeGraphValue as l, SerializationResult as n, SerializedSlot as o, SerializedGraphPayload as r, TypedArrayName as s, SerializationDiagnostic as t };
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,6 +1,6 @@
1
1
  {
2
2
  "name": "@markless/serializer",
3
- "version": "0.3.3",
3
+ "version": "0.5.0",
4
4
  "description": "Markless serialization tiers and resumability payload protocol.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -1,31 +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
- //#endregion
8
- //#region src/async-boundary-arm.ts
9
- const ASYNC_BOUNDARY_ARM = {
10
- try: 0,
11
- pending: 1,
12
- catch: 2
13
- };
14
- //#endregion
15
- //#region src/protocol.ts
16
- const PROTOCOL_EVENT_ACTION_KIND = {
17
- event: "event",
18
- externalDelegate: "external-delegate"
19
- };
20
- function protocolEventActionKind(record) {
21
- return record.action?.kind ?? PROTOCOL_EVENT_ACTION_KIND.event;
22
- }
23
- const PROTOCOL_EVENT_ACTION_DISPATCHES_MARKLESS = {
24
- [PROTOCOL_EVENT_ACTION_KIND.event]: true,
25
- [PROTOCOL_EVENT_ACTION_KIND.externalDelegate]: false
26
- };
27
- function protocolEventDispatchesMarkless(record) {
28
- return PROTOCOL_EVENT_ACTION_DISPATCHES_MARKLESS[protocolEventActionKind(record)];
29
- }
30
- //#endregion
31
- export { ASYNC_PROTOCOL_VERSION as a, ASYNC_BOUNDARY_ARM as i, protocolEventActionKind as n, STORAGE_PROTOCOL_VERSION as o, protocolEventDispatchesMarkless as r, protocolStateVersion as s, PROTOCOL_EVENT_ACTION_KIND as t };