@markless/serializer 0.3.3 → 0.4.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/index.d.ts CHANGED
@@ -1,6 +1,6 @@
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";
1
+ import { C as protocolInstanceQualifies, D as protocolStateVersion, E as protocolRowSegment, O as ASYNC_BOUNDARY_ARM, S as protocolInstancePath, T as protocolProjectionSegment, _ as PROTOCOL_EVENT_ACTION_KIND, a as ProtocolEventActionKind, b as PROTOCOL_PROP_GRAPH_NODE_PREFIX, c as ProtocolStatePayload, d as ProtocolSyncPolicyBranch, f as ProtocolSyncPolicyCondition, g as ASYNC_PROTOCOL_VERSION, h as protocolEventDispatchesMarkless, i as ProtocolEventAction, l as ProtocolStreamedArmPatch, m as protocolEventActionKind, n as ProtocolArmRecordSet, o as ProtocolEventRecord, p as ProtocolViewPayload, r as ProtocolAsyncBoundaryArm, s as ProtocolPayloadScripts, t as ProtocolArmBranchRecord, u as ProtocolSyncPolicy, v as PROTOCOL_PAGE_SPACE_ID_PREFIXES, w as protocolInstanceSegment, x as STORAGE_PROTOCOL_VERSION, y as PROTOCOL_PROPS_GRAPH_NODE_ID } from "./protocol-CGsMO85z.js";
2
2
  import { a as SerializedRecord, c as serializeGraphValue, i as SerializedPrimitive, l as deserializeGraphValue, n as SerializationResult, o as SerializedSlot, r as SerializedGraphPayload, s as TypedArrayName, t as SerializationDiagnostic } from "./value-BJ6YNKDd.js";
3
- import { a as RuntimePayloadError, c as assertProtocolStateCellPayload, d as decodePayloadScriptsWithVersion, f as invalidPayloadShapeError, i as RuntimePayloadDiagnostic, l as assertProtocolStatePayload, m as payloadScriptSelector, n as DecodedPayloadScripts, o as RuntimePayloadErrorCode, p as payloadInvalidError, r as EncodedPayloadScripts, s as RuntimePayloadType, t as decodePayloadScripts, u as assertProtocolViewPayload } from "./protocol-validation-storage-DogbS8xp.js";
3
+ import { a as RuntimePayloadError, c as assertProtocolStateCellPayload, d as decodePayloadScriptsWithVersion, f as invalidPayloadShapeError, i as RuntimePayloadDiagnostic, l as assertProtocolStatePayload, m as payloadScriptSelector, n as DecodedPayloadScripts, o as RuntimePayloadErrorCode, p as payloadInvalidError, r as EncodedPayloadScripts, s as RuntimePayloadType, t as decodePayloadScripts, u as assertProtocolViewPayload } from "./protocol-validation-storage-DGj6FaG-.js";
4
4
 
5
5
  //#region src/payload-scripts.d.ts
6
6
  type RenderPayloadScriptsInput = {
@@ -44,6 +44,7 @@ type ProtocolStatePayloadInput = {
44
44
  readonly computed?: ReadonlyArray<Omit<ProtocolStatePayload['computed'][number], 'snapshot'> & {
45
45
  readonly snapshot?: ProtocolAsyncComputedSnapshotInput;
46
46
  }>;
47
+ readonly sharedSeeds?: ProtocolStatePayload['sharedSeeds'];
47
48
  readonly sharedDefinitions?: ProtocolStatePayload['sharedDefinitions'];
48
49
  readonly storage?: ProtocolStatePayload['storage'];
49
50
  };
@@ -102,4 +103,4 @@ declare function storageSlotEntryKeyFromGraphNodeId(graphNodeId: string): string
102
103
  declare function createStorageSeedMetadata(moduleId: string, driverKey: string, fallback: string): StorageSeedMetadata;
103
104
  declare function createStorageSeedMetadataFromGraphNodeId(graphNodeId: string, driverKey: string, fallback: string): StorageSeedMetadata;
104
105
  //#endregion
105
- export { ASYNC_BOUNDARY_ARM, ASYNC_PROTOCOL_VERSION, DecodedPayloadScripts, EncodedPayloadScripts, PROTOCOL_EVENT_ACTION_KIND, ProtocolArmBranchRecord, ProtocolArmRecordSet, ProtocolAsyncBoundaryArm, ProtocolAsyncComputedSnapshotInput, ProtocolEventAction, ProtocolEventActionKind, ProtocolEventRecord, ProtocolPayloadScripts, ProtocolStatePayload, ProtocolStatePayloadInput, ProtocolStateSerializationDiagnostic, ProtocolStateSerializationError, ProtocolStreamedArmPatch, ProtocolSyncPolicy, ProtocolSyncPolicyBranch, ProtocolSyncPolicyCondition, ProtocolViewPayload, RenderPayloadScriptsInput, RenderedPayloadScripts, ResumeRecordDeltaClassification, type ResumeRecordSet, RuntimePayloadDiagnostic, RuntimePayloadError, RuntimePayloadErrorCode, RuntimePayloadType, STORAGE_PROTOCOL_VERSION, STORAGE_SLOT_SYMBOL_KEY, SerializationDiagnostic, SerializationResult, SerializedGraphPayload, SerializedPrimitive, SerializedRecord, SerializedSlot, StorageSeedMetadata, TypedArrayName, assertProtocolStateCellPayload, assertProtocolStatePayload, assertProtocolViewPayload, classifyResumeRecordDelta, createProtocolStatePayload, createStorageSeedMetadata, createStorageSeedMetadataFromGraphNodeId, decodePayloadScripts, decodePayloadScriptsWithVersion, deserializeGraphValue, invalidPayloadShapeError, isValidStorageKey, mergeResumeRecordDelta, payloadInvalidError, payloadScriptSelector, protocolEventActionKind, protocolEventDispatchesMarkless, protocolStateVersion, renderPayloadScripts, serializeGraphValue, serializeRuntimeAsyncSnapshots, serializeRuntimeStateCells, storageAttributeName, storageSlotEntryKey, storageSlotEntryKeyFromGraphNodeId };
106
+ export { ASYNC_BOUNDARY_ARM, ASYNC_PROTOCOL_VERSION, DecodedPayloadScripts, EncodedPayloadScripts, PROTOCOL_EVENT_ACTION_KIND, PROTOCOL_PAGE_SPACE_ID_PREFIXES, PROTOCOL_PROPS_GRAPH_NODE_ID, PROTOCOL_PROP_GRAPH_NODE_PREFIX, ProtocolArmBranchRecord, ProtocolArmRecordSet, ProtocolAsyncBoundaryArm, ProtocolAsyncComputedSnapshotInput, ProtocolEventAction, ProtocolEventActionKind, ProtocolEventRecord, ProtocolPayloadScripts, ProtocolStatePayload, ProtocolStatePayloadInput, ProtocolStateSerializationDiagnostic, ProtocolStateSerializationError, ProtocolStreamedArmPatch, ProtocolSyncPolicy, ProtocolSyncPolicyBranch, ProtocolSyncPolicyCondition, ProtocolViewPayload, RenderPayloadScriptsInput, RenderedPayloadScripts, ResumeRecordDeltaClassification, type ResumeRecordSet, RuntimePayloadDiagnostic, RuntimePayloadError, RuntimePayloadErrorCode, RuntimePayloadType, STORAGE_PROTOCOL_VERSION, STORAGE_SLOT_SYMBOL_KEY, SerializationDiagnostic, SerializationResult, SerializedGraphPayload, SerializedPrimitive, SerializedRecord, SerializedSlot, StorageSeedMetadata, TypedArrayName, assertProtocolStateCellPayload, assertProtocolStatePayload, assertProtocolViewPayload, classifyResumeRecordDelta, createProtocolStatePayload, createStorageSeedMetadata, createStorageSeedMetadataFromGraphNodeId, decodePayloadScripts, decodePayloadScriptsWithVersion, deserializeGraphValue, invalidPayloadShapeError, isValidStorageKey, mergeResumeRecordDelta, payloadInvalidError, payloadScriptSelector, protocolEventActionKind, protocolEventDispatchesMarkless, protocolInstancePath, protocolInstanceQualifies, protocolInstanceSegment, protocolProjectionSegment, protocolRowSegment, protocolStateVersion, renderPayloadScripts, serializeGraphValue, serializeRuntimeAsyncSnapshots, serializeRuntimeStateCells, storageAttributeName, storageSlotEntryKey, storageSlotEntryKeyFromGraphNodeId };
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
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";
1
+ import { a as PROTOCOL_EVENT_ACTION_KIND, c as PROTOCOL_PROP_GRAPH_NODE_PREFIX, d as protocolInstanceQualifies, f as protocolInstanceSegment, h as protocolStateVersion, i as ASYNC_PROTOCOL_VERSION, l as STORAGE_PROTOCOL_VERSION, m as protocolRowSegment, n as protocolEventDispatchesMarkless, o as PROTOCOL_PAGE_SPACE_ID_PREFIXES, p as protocolProjectionSegment, r as ASYNC_BOUNDARY_ARM, s as PROTOCOL_PROPS_GRAPH_NODE_ID, t as protocolEventActionKind, u as protocolInstancePath } from "./protocol-BwMZfNSA.js";
2
2
  import { deserializeGraphValue } from "./decode.js";
3
- import { a as assertProtocolStatePayload, c as invalidPayloadShapeError, i as assertProtocolStateCellPayload, l as payloadInvalidError, n as isValidStorageKey, o as assertProtocolViewPayload, r as RuntimePayloadError, s as decodePayloadScriptsWithVersion, t as decodePayloadScripts, u as payloadScriptSelector } from "./protocol-validation-storage-BQ8D2S5j.js";
3
+ import { a as assertProtocolStatePayload, c as invalidPayloadShapeError, i as assertProtocolStateCellPayload, l as payloadInvalidError, n as isValidStorageKey, o as assertProtocolViewPayload, r as RuntimePayloadError, s as decodePayloadScriptsWithVersion, t as decodePayloadScripts, u as payloadScriptSelector } from "./protocol-validation-storage-C4NuHqQw.js";
4
4
  //#region src/payload-scripts.ts
5
5
  function renderPayloadScripts(input) {
6
6
  return {
@@ -303,6 +303,7 @@ function createProtocolStatePayload(input) {
303
303
  };
304
304
  }),
305
305
  computed: (input.computed ?? []).map(serializeComputedSnapshot),
306
+ ...input.sharedSeeds?.length ? { sharedSeeds: input.sharedSeeds } : {},
306
307
  sharedDefinitions: input.sharedDefinitions,
307
308
  ...storage.length > 0 ? { storage } : {}
308
309
  };
@@ -574,4 +575,4 @@ function createStorageSeedMetadataFromGraphNodeId(graphNodeId, driverKey, fallba
574
575
  };
575
576
  }
576
577
  //#endregion
577
- export { ASYNC_BOUNDARY_ARM, ASYNC_PROTOCOL_VERSION, PROTOCOL_EVENT_ACTION_KIND, ProtocolStateSerializationError, RuntimePayloadError, STORAGE_PROTOCOL_VERSION, STORAGE_SLOT_SYMBOL_KEY, assertProtocolStateCellPayload, assertProtocolStatePayload, assertProtocolViewPayload, classifyResumeRecordDelta, createProtocolStatePayload, createStorageSeedMetadata, createStorageSeedMetadataFromGraphNodeId, decodePayloadScripts, decodePayloadScriptsWithVersion, deserializeGraphValue, invalidPayloadShapeError, isValidStorageKey, mergeResumeRecordDelta, payloadInvalidError, payloadScriptSelector, protocolEventActionKind, protocolEventDispatchesMarkless, protocolStateVersion, renderPayloadScripts, serializeGraphValue, serializeRuntimeAsyncSnapshots, serializeRuntimeStateCells, storageAttributeName, storageSlotEntryKey, storageSlotEntryKeyFromGraphNodeId };
578
+ 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, ProtocolStateSerializationError, RuntimePayloadError, STORAGE_PROTOCOL_VERSION, STORAGE_SLOT_SYMBOL_KEY, assertProtocolStateCellPayload, assertProtocolStatePayload, assertProtocolViewPayload, classifyResumeRecordDelta, createProtocolStatePayload, createStorageSeedMetadata, createStorageSeedMetadataFromGraphNodeId, decodePayloadScripts, decodePayloadScriptsWithVersion, deserializeGraphValue, invalidPayloadShapeError, isValidStorageKey, mergeResumeRecordDelta, payloadInvalidError, payloadScriptSelector, protocolEventActionKind, protocolEventDispatchesMarkless, protocolInstancePath, protocolInstanceQualifies, protocolInstanceSegment, protocolProjectionSegment, protocolRowSegment, protocolStateVersion, renderPayloadScripts, serializeGraphValue, serializeRuntimeAsyncSnapshots, serializeRuntimeStateCells, storageAttributeName, storageSlotEntryKey, storageSlotEntryKeyFromGraphNodeId };
@@ -0,0 +1,56 @@
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 };
@@ -9,6 +9,20 @@ declare const ASYNC_BOUNDARY_ARM: {
9
9
  declare const ASYNC_PROTOCOL_VERSION = 1;
10
10
  declare const STORAGE_PROTOCOL_VERSION = 2;
11
11
  declare function protocolStateVersion(storage: readonly unknown[] | undefined): typeof ASYNC_PROTOCOL_VERSION | typeof STORAGE_PROTOCOL_VERSION;
12
+ declare const PROTOCOL_EVENT_ACTION_KIND: {
13
+ readonly event: "event";
14
+ readonly externalDelegate: "external-delegate";
15
+ };
16
+ declare function protocolInstanceSegment(edgeIndex: number): string;
17
+ declare function protocolProjectionSegment(edgeIndex: number): string;
18
+ /** One keyed `@for` row's identity segment. The key is identity, never the index. */
19
+ declare function protocolRowSegment(key: unknown): string;
20
+ /** The leading instance path of a composed id, or '' when the id is page-local. */
21
+ declare function protocolInstancePath(id: string): string;
22
+ declare const PROTOCOL_PROPS_GRAPH_NODE_ID = "prop:props";
23
+ declare const PROTOCOL_PROP_GRAPH_NODE_PREFIX = "prop:";
24
+ declare const PROTOCOL_PAGE_SPACE_ID_PREFIXES: string[];
25
+ declare function protocolInstanceQualifies(graphNodeId: string): boolean | undefined;
12
26
  //#endregion
13
27
  //#region src/protocol.d.ts
14
28
  type ProtocolAsyncBoundaryArm = (typeof ASYNC_BOUNDARY_ARM)[keyof typeof ASYNC_BOUNDARY_ARM];
@@ -40,10 +54,6 @@ type ProtocolSyncPolicyBranch = {
40
54
  type ProtocolSyncPolicy = ProtocolSyncPolicyBranch | {
41
55
  readonly branches: ReadonlyArray<ProtocolSyncPolicyBranch>;
42
56
  };
43
- declare const PROTOCOL_EVENT_ACTION_KIND: {
44
- readonly event: "event";
45
- readonly externalDelegate: "external-delegate";
46
- };
47
57
  type ProtocolEventActionKind = (typeof PROTOCOL_EVENT_ACTION_KIND)[keyof typeof PROTOCOL_EVENT_ACTION_KIND];
48
58
  type ProtocolEventAction = {
49
59
  readonly kind: typeof PROTOCOL_EVENT_ACTION_KIND.externalDelegate;
@@ -95,13 +105,26 @@ type ProtocolStatePayload = {
95
105
  readonly error: unknown;
96
106
  };
97
107
  }>;
108
+ readonly sharedSeeds?: ReadonlyArray<{
109
+ readonly graphNodeId: string;
110
+ readonly deriveSymbolId: string;
111
+ readonly dependencies: ReadonlyArray<{
112
+ readonly graphNodeId: string;
113
+ readonly path: ReadonlyArray<string>;
114
+ readonly reads: {
115
+ readonly graphNodeId: string;
116
+ readonly path: ReadonlyArray<string>;
117
+ };
118
+ }>;
119
+ }>;
98
120
  readonly sharedDefinitions?: ReadonlyArray<{
99
121
  readonly id: string;
100
122
  readonly name: string;
101
123
  readonly exportedName: string;
102
- readonly scope?: 'request' | 'container' | 'page';
124
+ readonly scope?: 'request' | 'container' | 'page' | 'widget';
103
125
  readonly version: number;
104
126
  readonly graphNodeIds: ReadonlyArray<string>;
127
+ readonly projectionIds?: ReadonlyArray<string>;
105
128
  readonly dependencies?: ReadonlyArray<{
106
129
  readonly definitionId: string;
107
130
  readonly definitionName: string;
@@ -209,7 +232,8 @@ type ProtocolViewPayload = {
209
232
  readonly elementHandles: ReadonlyArray<{
210
233
  readonly hostNodeId: string;
211
234
  readonly handleId: string;
212
- readonly name: string;
235
+ readonly name: string; /** Declared `element<T[]>()`: this handle names an ordered set, and a read answers an array. */
236
+ readonly plural?: boolean;
213
237
  }>;
214
238
  readonly keyedRepeats?: ReadonlyArray<{
215
239
  readonly id: string;
@@ -219,6 +243,57 @@ type ProtocolViewPayload = {
219
243
  readonly keyPath: ReadonlyArray<string>;
220
244
  readonly itemName: string;
221
245
  readonly rowElementCount: number;
246
+ /**
247
+ * Element children of the parent that stand before the rows. Rows occupy
248
+ * `[rowStartOffset, rowStartOffset + items.length)` among the parent's child
249
+ * elements; a repeat whose rows begin at 0 omits the field. A repeat whose
250
+ * prefix has no compile-time element count ships no record at all.
251
+ */
252
+ readonly rowStartOffset?: number;
253
+ /**
254
+ * The `@empty` arm's finished markup, for the mint that raises it when the
255
+ * collection empties after resume and takes it back out when a row returns.
256
+ * Carried only for a repeat that HAS an `@empty` arm whose markup is fully
257
+ * static and whose elements no record names: everything else would need
258
+ * wiring the mint cannot do, so it ships nothing and the served behaviour
259
+ * stands. A repeat with no `@empty` arm omits the field entirely.
260
+ */
261
+ readonly emptyArm?: {
262
+ readonly html: string;
263
+ };
264
+ /**
265
+ * One row's compiled markup, for the mint that builds a row the server never
266
+ * rendered - an item appended to the collection after resume.
267
+ *
268
+ * `html` is the row chunk's statics joined, slot markers KEPT: the marker
269
+ * comments are where the row's own text lives, so the mint finds each text
270
+ * position by walking to it rather than by re-parsing. `textSlots` names
271
+ * those positions - `path` is FRAGMENT-relative (`[0]` is the row root),
272
+ * `itemPath` is the property path to read off the item - and is omitted
273
+ * when the row has none, which is the fully static row.
274
+ *
275
+ * Carried only for a row the client can finish alone: static markup, or
276
+ * markup whose every slot is text read off the repeated item. A row holding
277
+ * anything else - a value from outside the row, an attribute, a nested
278
+ * construct, a component - needs wiring the mint cannot do, so it ships
279
+ * nothing and the served behaviour stands.
280
+ *
281
+ * Pay-per-use: a repeat whose row is not mintable emits no field at all, so
282
+ * its record is byte-identical to what it was before this existed.
283
+ */
284
+ readonly rowTemplate?: {
285
+ readonly html: string;
286
+ readonly textSlots?: ReadonlyArray<{
287
+ readonly path: ReadonlyArray<number>;
288
+ readonly itemPath: ReadonlyArray<string>;
289
+ }>;
290
+ };
291
+ readonly rowElementHandles?: ReadonlyArray<{
292
+ readonly hostPath: ReadonlyArray<number>;
293
+ readonly handleId: string;
294
+ readonly name: string;
295
+ readonly plural?: boolean;
296
+ }>;
222
297
  readonly rowEvents: ReadonlyArray<{
223
298
  readonly hostPath: ReadonlyArray<number>;
224
299
  readonly eventName: string;
@@ -285,4 +360,4 @@ type ProtocolPayloadScripts = {
285
360
  readonly viewScript: string;
286
361
  };
287
362
  //#endregion
288
- export { ASYNC_PROTOCOL_VERSION as _, ProtocolEventAction as a, ASYNC_BOUNDARY_ARM as b, ProtocolPayloadScripts as c, ProtocolSyncPolicy as d, ProtocolSyncPolicyBranch as f, protocolEventDispatchesMarkless as g, protocolEventActionKind as h, ProtocolAsyncBoundaryArm as i, ProtocolStatePayload as l, ProtocolViewPayload as m, ProtocolArmBranchRecord as n, ProtocolEventActionKind as o, ProtocolSyncPolicyCondition as p, ProtocolArmRecordSet as r, ProtocolEventRecord as s, PROTOCOL_EVENT_ACTION_KIND as t, ProtocolStreamedArmPatch as u, STORAGE_PROTOCOL_VERSION as v, protocolStateVersion as y };
363
+ export { protocolInstanceQualifies as C, protocolStateVersion as D, protocolRowSegment as E, ASYNC_BOUNDARY_ARM as O, protocolInstancePath as S, protocolProjectionSegment as T, PROTOCOL_EVENT_ACTION_KIND as _, ProtocolEventActionKind as a, PROTOCOL_PROP_GRAPH_NODE_PREFIX as b, ProtocolStatePayload as c, ProtocolSyncPolicyBranch as d, ProtocolSyncPolicyCondition as f, ASYNC_PROTOCOL_VERSION as g, protocolEventDispatchesMarkless as h, ProtocolEventAction as i, ProtocolStreamedArmPatch as l, protocolEventActionKind as m, ProtocolArmRecordSet as n, ProtocolEventRecord as o, ProtocolViewPayload as p, ProtocolAsyncBoundaryArm as r, ProtocolPayloadScripts as s, ProtocolArmBranchRecord as t, ProtocolSyncPolicy as u, PROTOCOL_PAGE_SPACE_ID_PREFIXES as v, protocolInstanceSegment as w, STORAGE_PROTOCOL_VERSION as x, PROTOCOL_PROPS_GRAPH_NODE_ID as y };
@@ -1,4 +1,4 @@
1
- import { i as ASYNC_BOUNDARY_ARM, t as PROTOCOL_EVENT_ACTION_KIND } from "./protocol-BX4yw9bm.js";
1
+ import { a as PROTOCOL_EVENT_ACTION_KIND, r as ASYNC_BOUNDARY_ARM } from "./protocol-BwMZfNSA.js";
2
2
  //#region src/protocol-validation.ts
3
3
  var RuntimePayloadError = class extends Error {
4
4
  constructor(diagnostic) {
@@ -109,6 +109,7 @@ function assertProtocolViewPayload(payload) {
109
109
  assertStringField(handle, "hostNodeId", context);
110
110
  assertStringField(handle, "handleId", context);
111
111
  assertStringField(handle, "name", context);
112
+ assertOptionalBooleanField(handle, "plural", context);
112
113
  }
113
114
  for (const [index, boundary] of asyncBoundaries.entries()) {
114
115
  const context = `markless/view asyncBoundary[${index}]`;
@@ -193,8 +194,51 @@ function assertOptionalKeyedRepeats(record) {
193
194
  assertStringArrayField(repeat, "keyPath", context);
194
195
  assertStringField(repeat, "itemName", context);
195
196
  assertNonNegativeIntegerField(repeat, "rowElementCount", context);
197
+ if (repeat.rowStartOffset !== void 0) assertNonNegativeIntegerField(repeat, "rowStartOffset", context);
196
198
  assertRowEvents(repeat.rowEvents, `${context}.rowEvents`);
197
- }
199
+ assertOptionalRowElementHandles(repeat, `${context}.rowElementHandles`);
200
+ assertOptionalEmptyArm(repeat, `${context}.emptyArm`);
201
+ assertOptionalRowTemplate(repeat, `${context}.rowTemplate`);
202
+ }
203
+ }
204
+ function assertOptionalRowTemplate(record, context) {
205
+ const template = record.rowTemplate;
206
+ if (template === void 0) return;
207
+ assertRecordShape(template, context);
208
+ assertStringField(template, "html", context);
209
+ const textSlots = template.textSlots;
210
+ if (textSlots === void 0) return;
211
+ if (!Array.isArray(textSlots)) throw invalidPayloadShapeError(contextPayloadType(context), `Invalid ${context}: expected textSlots array.`);
212
+ for (const [index, slot] of textSlots.entries()) {
213
+ const slotContext = `${context}.textSlots[${index}]`;
214
+ assertRecordShape(slot, slotContext);
215
+ assertNonNegativeIntegerArrayField(slot, "path", slotContext);
216
+ assertStringArrayField(slot, "itemPath", slotContext);
217
+ }
218
+ }
219
+ function assertOptionalEmptyArm(record, context) {
220
+ const arm = record.emptyArm;
221
+ if (arm === void 0) return;
222
+ assertRecordShape(arm, context);
223
+ assertStringField(arm, "html", context);
224
+ }
225
+ function assertOptionalRowElementHandles(record, context) {
226
+ const handles = record.rowElementHandles;
227
+ if (handles === void 0) return;
228
+ if (!Array.isArray(handles)) throw invalidPayloadShapeError(contextPayloadType(context), `Invalid ${context}: expected array.`);
229
+ for (const [index, handle] of handles.entries()) {
230
+ const handleContext = `${context}[${index}]`;
231
+ assertRecordShape(handle, handleContext);
232
+ assertNonNegativeIntegerArrayField(handle, "hostPath", handleContext);
233
+ assertStringField(handle, "handleId", handleContext);
234
+ assertStringField(handle, "name", handleContext);
235
+ assertOptionalBooleanField(handle, "plural", handleContext);
236
+ }
237
+ }
238
+ function assertOptionalBooleanField(record, key, context) {
239
+ const value = record[key];
240
+ if (value === void 0 || typeof value === "boolean") return;
241
+ throw invalidPayloadShapeError(contextPayloadType(context), `Invalid ${context}: expected ${key} boolean.`);
198
242
  }
199
243
  function assertOptionalBranches(record) {
200
244
  if (record.branches === void 0) return;
@@ -280,14 +324,15 @@ function assertOptionalSharedDefinitions(record) {
280
324
  assertOptionalSharedScope(definition, context);
281
325
  assertNonNegativeIntegerField(definition, "version", context);
282
326
  assertStringArrayField(definition, "graphNodeIds", context);
327
+ assertOptionalStringArrayField(definition, "projectionIds", context);
283
328
  assertOptionalSharedDependencies(definition, context);
284
329
  assertOptionalSharedReturnProperties(definition, context);
285
330
  }
286
331
  }
287
332
  function assertOptionalSharedScope(record, context) {
288
333
  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.`);
334
+ if (record.scope === "widget" || record.scope === "request" || record.scope === "container" || record.scope === "page") return;
335
+ throw invalidPayloadShapeError(contextPayloadType(context), `Invalid ${context}: expected scope widget, request, container, or page.`);
291
336
  }
292
337
  function assertOptionalSharedDependencies(record, context) {
293
338
  if (record.dependencies === void 0) return;
@@ -1,4 +1,4 @@
1
- import { l as ProtocolStatePayload, m as ProtocolViewPayload } from "./protocol-BfzeLgjZ.js";
1
+ import { c as ProtocolStatePayload, p as ProtocolViewPayload } from "./protocol-CGsMO85z.js";
2
2
 
3
3
  //#region src/protocol-validation.d.ts
4
4
  type EncodedPayloadScripts = {
@@ -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-DGj6FaG-.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-C4NuHqQw.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 { C as protocolInstanceQualifies, D as protocolStateVersion, E as protocolRowSegment, O as ASYNC_BOUNDARY_ARM, S as protocolInstancePath, T as protocolProjectionSegment, _ as PROTOCOL_EVENT_ACTION_KIND, a as ProtocolEventActionKind, b as PROTOCOL_PROP_GRAPH_NODE_PREFIX, c as ProtocolStatePayload, d as ProtocolSyncPolicyBranch, f as ProtocolSyncPolicyCondition, g as ASYNC_PROTOCOL_VERSION, h as protocolEventDispatchesMarkless, i as ProtocolEventAction, l as ProtocolStreamedArmPatch, m as protocolEventActionKind, n as ProtocolArmRecordSet, o as ProtocolEventRecord, p as ProtocolViewPayload, r as ProtocolAsyncBoundaryArm, s as ProtocolPayloadScripts, t as ProtocolArmBranchRecord, u as ProtocolSyncPolicy, v as PROTOCOL_PAGE_SPACE_ID_PREFIXES, w as protocolInstanceSegment, x as STORAGE_PROTOCOL_VERSION, y as PROTOCOL_PROPS_GRAPH_NODE_ID } from "./protocol-CGsMO85z.js";
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 };
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 { a as PROTOCOL_EVENT_ACTION_KIND, c as PROTOCOL_PROP_GRAPH_NODE_PREFIX, d as protocolInstanceQualifies, f as protocolInstanceSegment, h as protocolStateVersion, i as ASYNC_PROTOCOL_VERSION, l as STORAGE_PROTOCOL_VERSION, m as protocolRowSegment, n as protocolEventDispatchesMarkless, o as PROTOCOL_PAGE_SPACE_ID_PREFIXES, p as protocolProjectionSegment, r as ASYNC_BOUNDARY_ARM, s as PROTOCOL_PROPS_GRAPH_NODE_ID, t as protocolEventActionKind, u as protocolInstancePath } from "./protocol-BwMZfNSA.js";
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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markless/serializer",
3
- "version": "0.3.3",
3
+ "version": "0.4.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 };