@markless/serializer 0.7.0 → 0.8.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,7 +1,7 @@
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";
1
+ import { $ as PROTOCOL_VISIBLE_EVENT_NAME, A as formatEventHostEntries, B as STORAGE_PROTOCOL_VERSION, C as PROTOCOL_EVENT_HOST_ENTRY_SEPARATOR, D as ProtocolConstantSyncPolicyCode, E as PROTOCOL_SYNC_POLICY_TABLE_TYPE, F as PROTOCOL_TEMPLATE_CONTENT_TAG, G as protocolRowSegment, H as protocolInstanceQualifies, I as ASYNC_PROTOCOL_VERSION, J as PROTOCOL_CONTAINER_END_COMMENT, K as protocolStateVersion, L as PROTOCOL_EVENT_ACTION_KIND, M as syncPolicyNeverActs, N as PROTOCOL_DECLARATIVE_SHADOW_ROOT_ATTRIBUTE, O as ProtocolEventHostEntry, P as PROTOCOL_RAW_TEXT_TAGS, Q as PROTOCOL_IDLE_EVENT_NAME, R as PROTOCOL_PAGE_SPACE_ID_PREFIXES, S as PROTOCOL_EVENT_HOST_DELEGATED_REF, T as PROTOCOL_EVENT_HOST_REF_SEPARATOR, U as protocolInstanceSegment, V as protocolInstancePath, W as protocolProjectionSegment, X as PROTOCOL_CONTAINER_START_COMMENT, Y as PROTOCOL_CONTAINER_HOST_NODE_ID, Z as PROTOCOL_LOCATOR_PATHS_ATTRIBUTE, _ as ProtocolViewPayload, a as ProtocolBranchIdrefSite, b as protocolEventDispatchesMarkless, c as ProtocolEventActionKind, d as ProtocolRowTemplateSlotValue, et as ASYNC_BOUNDARY_ARM, f as ProtocolStatePayload, g as ProtocolSyncPolicyCondition, h as ProtocolSyncPolicyBranch, i as ProtocolBranchContentRead, j as parseEventHostEntries, k as constantSyncPolicyCode, l as ProtocolEventRecord, m as ProtocolSyncPolicy, n as ProtocolArmRecordSet, o as ProtocolComposedGraphProp, p as ProtocolStreamedArmPatch, q as PROTOCOL_PROP_GRAPH_NODE_PREFIX, r as ProtocolAsyncBoundaryArm, s as ProtocolEventAction, t as ProtocolArmBranchRecord, u as ProtocolPayloadScripts, v as protocolElementHandleReadId, w as PROTOCOL_EVENT_HOST_POLICY_SEPARATOR, x as PROTOCOL_EVENT_HOST_ATTRIBUTE, y as protocolEventActionKind, z as PROTOCOL_PROPS_GRAPH_NODE_ID } from "./protocol-D8nfDFJd.js";
2
2
  import { a as PROTOCOL_TEMPLATED_LISTS, i as expandRecordTemplates, n as ProtocolTemplatedRecords, o as RuntimePayloadType$1, r as decodeProtocolPayloadLists } from "./protocol-record-templates-pAcSQYqD.js";
3
3
  import { a as SerializedPrimitive, c as TypedArrayName, d as serializeGraphValue, f as deserializeGraphValue, i as SerializedGraphPayload, l as jsonSourceWithNonFiniteNumbers, n as SerializationDiagnostic, o as SerializedRecord, r as SerializationResult, s as SerializedSlot, t as NonFiniteNumberName, u as nonFiniteName } from "./value-CRkHmkRz.js";
4
- 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";
4
+ 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-CLv0E9Gp.js";
5
5
  //#region src/payload-scripts.d.ts
6
6
  export type RenderPayloadScriptsInput = {
7
7
  readonly state: ProtocolStatePayload;
@@ -123,4 +123,4 @@ export declare function storageSlotEntryKeyFromGraphNodeId(graphNodeId: string):
123
123
  export declare function createStorageSeedMetadata(moduleId: string, driverKey: string, fallback: string): StorageSeedMetadata;
124
124
  export declare function createStorageSeedMetadataFromGraphNodeId(graphNodeId: string, driverKey: string, fallback: string): StorageSeedMetadata;
125
125
  //#endregion
126
- export { ASYNC_BOUNDARY_ARM, ASYNC_PROTOCOL_VERSION, DecodedPayloadScripts, EncodedPayloadScripts, NonFiniteNumberName, 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_TEMPLATED_LISTS, PROTOCOL_VISIBLE_EVENT_NAME, ProtocolArmBranchRecord, ProtocolArmRecordSet, ProtocolAsyncBoundaryArm, ProtocolBranchContentRead, ProtocolBranchIdrefSite, ProtocolComposedGraphProp, ProtocolEventAction, ProtocolEventActionKind, ProtocolEventRecord, ProtocolPayloadScripts, ProtocolRowTemplateSlotValue, ProtocolStatePayload, ProtocolStreamedArmPatch, ProtocolSyncPolicy, ProtocolSyncPolicyBranch, ProtocolSyncPolicyCondition, type ProtocolTemplatedRecords, ProtocolViewPayload, type ResumeRecordSet, RuntimePayloadDiagnostic, RuntimePayloadError, RuntimePayloadErrorCode, RuntimePayloadType, STORAGE_PROTOCOL_VERSION, SerializationDiagnostic, SerializationResult, SerializedGraphPayload, SerializedPrimitive, SerializedRecord, SerializedSlot, TypedArrayName, assertProtocolStateCellPayload, assertProtocolStatePayload, assertProtocolViewPayload, decodePayloadScripts, decodePayloadScriptsWithVersion, decodeProtocolPayloadLists, deserializeGraphValue, expandRecordTemplates, invalidPayloadShapeError, jsonSourceWithNonFiniteNumbers, nonFiniteName, payloadInvalidError, payloadScriptSelector, protocolElementHandleReadId, protocolEventActionKind, protocolEventDispatchesMarkless, protocolInstancePath, protocolInstanceQualifies, protocolInstanceSegment, protocolProjectionSegment, protocolRowSegment, protocolStateVersion, serializeGraphValue };
126
+ export { ASYNC_BOUNDARY_ARM, ASYNC_PROTOCOL_VERSION, DecodedPayloadScripts, EncodedPayloadScripts, NonFiniteNumberName, PROTOCOL_CONTAINER_END_COMMENT, PROTOCOL_CONTAINER_HOST_NODE_ID, PROTOCOL_CONTAINER_START_COMMENT, PROTOCOL_DECLARATIVE_SHADOW_ROOT_ATTRIBUTE, PROTOCOL_EVENT_ACTION_KIND, PROTOCOL_EVENT_HOST_ATTRIBUTE, PROTOCOL_EVENT_HOST_DELEGATED_REF, PROTOCOL_EVENT_HOST_ENTRY_SEPARATOR, PROTOCOL_EVENT_HOST_POLICY_SEPARATOR, PROTOCOL_EVENT_HOST_REF_SEPARATOR, PROTOCOL_IDLE_EVENT_NAME, PROTOCOL_LOCATOR_PATHS_ATTRIBUTE, PROTOCOL_PAGE_SPACE_ID_PREFIXES, PROTOCOL_PROPS_GRAPH_NODE_ID, PROTOCOL_PROP_GRAPH_NODE_PREFIX, PROTOCOL_RAW_TEXT_TAGS, PROTOCOL_SYNC_POLICY_TABLE_TYPE, PROTOCOL_TEMPLATED_LISTS, PROTOCOL_TEMPLATE_CONTENT_TAG, PROTOCOL_VISIBLE_EVENT_NAME, ProtocolArmBranchRecord, ProtocolArmRecordSet, ProtocolAsyncBoundaryArm, ProtocolBranchContentRead, ProtocolBranchIdrefSite, ProtocolComposedGraphProp, type ProtocolConstantSyncPolicyCode, ProtocolEventAction, ProtocolEventActionKind, type ProtocolEventHostEntry, ProtocolEventRecord, ProtocolPayloadScripts, ProtocolRowTemplateSlotValue, ProtocolStatePayload, ProtocolStreamedArmPatch, ProtocolSyncPolicy, ProtocolSyncPolicyBranch, ProtocolSyncPolicyCondition, type ProtocolTemplatedRecords, ProtocolViewPayload, type ResumeRecordSet, RuntimePayloadDiagnostic, RuntimePayloadError, RuntimePayloadErrorCode, RuntimePayloadType, STORAGE_PROTOCOL_VERSION, SerializationDiagnostic, SerializationResult, SerializedGraphPayload, SerializedPrimitive, SerializedRecord, SerializedSlot, TypedArrayName, assertProtocolStateCellPayload, assertProtocolStatePayload, assertProtocolViewPayload, constantSyncPolicyCode, decodePayloadScripts, decodePayloadScriptsWithVersion, decodeProtocolPayloadLists, deserializeGraphValue, expandRecordTemplates, formatEventHostEntries, invalidPayloadShapeError, jsonSourceWithNonFiniteNumbers, nonFiniteName, parseEventHostEntries, payloadInvalidError, payloadScriptSelector, protocolElementHandleReadId, protocolEventActionKind, protocolEventDispatchesMarkless, protocolInstancePath, protocolInstanceQualifies, protocolInstanceSegment, protocolProjectionSegment, protocolRowSegment, protocolStateVersion, serializeGraphValue, syncPolicyNeverActs };
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
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";
1
+ import { A as PROTOCOL_CONTAINER_END_COMMENT, C as protocolInstancePath, D as protocolRowSegment, E as protocolProjectionSegment, F as PROTOCOL_VISIBLE_EVENT_NAME, M as PROTOCOL_CONTAINER_START_COMMENT, N as PROTOCOL_LOCATOR_PATHS_ATTRIBUTE, O as protocolStateVersion, P as PROTOCOL_IDLE_EVENT_NAME, S as STORAGE_PROTOCOL_VERSION, T as protocolInstanceSegment, _ as ASYNC_BOUNDARY_ARM, a as PROTOCOL_EVENT_HOST_DELEGATED_REF, b as PROTOCOL_PAGE_SPACE_ID_PREFIXES, c as PROTOCOL_EVENT_HOST_REF_SEPARATOR, d as formatEventHostEntries, f as parseEventHostEntries, g as PROTOCOL_TEMPLATE_CONTENT_TAG, h as PROTOCOL_RAW_TEXT_TAGS, i as PROTOCOL_EVENT_HOST_ATTRIBUTE, j as PROTOCOL_CONTAINER_HOST_NODE_ID, k as PROTOCOL_PROP_GRAPH_NODE_PREFIX, l as PROTOCOL_SYNC_POLICY_TABLE_TYPE, m as PROTOCOL_DECLARATIVE_SHADOW_ROOT_ATTRIBUTE, n as protocolEventActionKind, o as PROTOCOL_EVENT_HOST_ENTRY_SEPARATOR, p as syncPolicyNeverActs, r as protocolEventDispatchesMarkless, s as PROTOCOL_EVENT_HOST_POLICY_SEPARATOR, t as protocolElementHandleReadId, u as constantSyncPolicyCode, v as ASYNC_PROTOCOL_VERSION, w as protocolInstanceQualifies, x as PROTOCOL_PROPS_GRAPH_NODE_ID, y as PROTOCOL_EVENT_ACTION_KIND } from "./protocol-B57uFVtf.js";
2
2
  import { deserializeGraphValue } from "./decode.js";
3
3
  import { i as PROTOCOL_RECORD_KEYS, n as expandRecordTemplates, r as PROTOCOL_TEMPLATED_LISTS, t as decodeProtocolPayloadLists } from "./protocol-record-templates-B0Ay3OCd.js";
4
- 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-D9VzvR9i.js";
4
+ 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-DYrHI-d6.js";
5
5
  //#region src/payload-scripts.ts
6
6
  function renderPayloadScripts(input, encodeLists) {
7
7
  return {
@@ -755,4 +755,4 @@ function createStorageCookieReader(cookieHeader) {
755
755
  return (driverKey) => values.get(storageCookieName(driverKey));
756
756
  }
757
757
  //#endregion
758
- 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_TEMPLATED_LISTS, PROTOCOL_VISIBLE_EVENT_NAME, ProtocolStateSerializationError, RuntimePayloadError, STORAGE_PROTOCOL_VERSION, STORAGE_RENDER_CONTEXT_READER, STORAGE_SLOT_SYMBOL_KEY, assertProtocolStateCellPayload, assertProtocolStatePayload, assertProtocolViewPayload, classifyResumeRecordDelta, createProtocolStatePayload, createStorageCookieReader, createStorageSeedMetadata, createStorageSeedMetadataFromGraphNodeId, decodePayloadScripts, decodePayloadScriptsWithVersion, decodeProtocolPayloadLists, decodeStorageCookieValue, deserializeGraphValue, encodeProtocolPayloadLists, encodeRecordTemplates, escapeScriptJson, expandRecordTemplates, invalidPayloadShapeError, isValidStorageKey, jsonSourceWithNonFiniteNumbers, mergeResumeRecordDelta, nonFiniteName, payloadInvalidError, payloadScriptSelector, protocolElementHandleReadId, protocolEventActionKind, protocolEventDispatchesMarkless, protocolInstancePath, protocolInstanceQualifies, protocolInstanceSegment, protocolProjectionSegment, protocolRowSegment, protocolStateVersion, renderPayloadScripts, serializeGraphValue, serializeRuntimeAsyncSnapshots, serializeRuntimeStateCells, storageAttributeName, storageCookieAssignment, storageCookieName, storageSlotEntryKey, storageSlotEntryKeyFromGraphNodeId };
758
+ export { ASYNC_BOUNDARY_ARM, ASYNC_PROTOCOL_VERSION, PROTOCOL_CONTAINER_END_COMMENT, PROTOCOL_CONTAINER_HOST_NODE_ID, PROTOCOL_CONTAINER_START_COMMENT, PROTOCOL_DECLARATIVE_SHADOW_ROOT_ATTRIBUTE, PROTOCOL_EVENT_ACTION_KIND, PROTOCOL_EVENT_HOST_ATTRIBUTE, PROTOCOL_EVENT_HOST_DELEGATED_REF, PROTOCOL_EVENT_HOST_ENTRY_SEPARATOR, PROTOCOL_EVENT_HOST_POLICY_SEPARATOR, PROTOCOL_EVENT_HOST_REF_SEPARATOR, PROTOCOL_IDLE_EVENT_NAME, PROTOCOL_LOCATOR_PATHS_ATTRIBUTE, PROTOCOL_PAGE_SPACE_ID_PREFIXES, PROTOCOL_PROPS_GRAPH_NODE_ID, PROTOCOL_PROP_GRAPH_NODE_PREFIX, PROTOCOL_RAW_TEXT_TAGS, PROTOCOL_SYNC_POLICY_TABLE_TYPE, PROTOCOL_TEMPLATED_LISTS, PROTOCOL_TEMPLATE_CONTENT_TAG, PROTOCOL_VISIBLE_EVENT_NAME, ProtocolStateSerializationError, RuntimePayloadError, STORAGE_PROTOCOL_VERSION, STORAGE_RENDER_CONTEXT_READER, STORAGE_SLOT_SYMBOL_KEY, assertProtocolStateCellPayload, assertProtocolStatePayload, assertProtocolViewPayload, classifyResumeRecordDelta, constantSyncPolicyCode, createProtocolStatePayload, createStorageCookieReader, createStorageSeedMetadata, createStorageSeedMetadataFromGraphNodeId, decodePayloadScripts, decodePayloadScriptsWithVersion, decodeProtocolPayloadLists, decodeStorageCookieValue, deserializeGraphValue, encodeProtocolPayloadLists, encodeRecordTemplates, escapeScriptJson, expandRecordTemplates, formatEventHostEntries, invalidPayloadShapeError, isValidStorageKey, jsonSourceWithNonFiniteNumbers, mergeResumeRecordDelta, nonFiniteName, parseEventHostEntries, payloadInvalidError, payloadScriptSelector, protocolElementHandleReadId, protocolEventActionKind, protocolEventDispatchesMarkless, protocolInstancePath, protocolInstanceQualifies, protocolInstanceSegment, protocolProjectionSegment, protocolRowSegment, protocolStateVersion, renderPayloadScripts, serializeGraphValue, serializeRuntimeAsyncSnapshots, serializeRuntimeStateCells, storageAttributeName, storageCookieAssignment, storageCookieName, storageSlotEntryKey, storageSlotEntryKeyFromGraphNodeId, syncPolicyNeverActs };
@@ -0,0 +1,165 @@
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-page-markers.ts
14
+ const PROTOCOL_CONTAINER_START_COMMENT = "markless:page-start";
15
+ const PROTOCOL_CONTAINER_END_COMMENT = "markless:page-end";
16
+ const PROTOCOL_CONTAINER_HOST_NODE_ID = "container";
17
+ //#endregion
18
+ //#region src/protocol-prop-prefix.ts
19
+ const PROTOCOL_PROP_GRAPH_NODE_PREFIX = "prop:";
20
+ //#endregion
21
+ //#region src/protocol-constants.ts
22
+ const ASYNC_PROTOCOL_VERSION = 1;
23
+ const STORAGE_PROTOCOL_VERSION = 2;
24
+ function protocolStateVersion(storage) {
25
+ return (storage?.length ?? 0) > 0 ? 2 : 1;
26
+ }
27
+ const PROTOCOL_EVENT_ACTION_KIND = {
28
+ event: "event",
29
+ externalDelegate: "external-delegate"
30
+ };
31
+ const PROTOCOL_INSTANCE_PATH = /^(?:[cpm]\d+:|r:[^:]*:)+/;
32
+ function protocolInstanceSegment(edgeIndex) {
33
+ return `c${edgeIndex}:`;
34
+ }
35
+ function protocolProjectionSegment(edgeIndex) {
36
+ return `p${edgeIndex}:`;
37
+ }
38
+ /** One keyed `@for` row's identity segment. The key is identity, never the index. */
39
+ function protocolRowSegment(key) {
40
+ return `r:${encodeURIComponent(String(key))}:`;
41
+ }
42
+ /** The leading instance path of a composed id, or '' when the id is page-local. */
43
+ function protocolInstancePath(id) {
44
+ return PROTOCOL_INSTANCE_PATH.exec(id)?.[0] ?? "";
45
+ }
46
+ const PROTOCOL_PROPS_GRAPH_NODE_ID = "prop:props";
47
+ const PROTOCOL_INSTANCE_QUALIFIABLE = [
48
+ "prop:",
49
+ "state:",
50
+ "computed:",
51
+ "element:"
52
+ ];
53
+ const PROTOCOL_PAGE_SPACE_ID_PREFIXES = ["shared:", "storage:"];
54
+ function protocolInstanceQualifies(graphNodeId) {
55
+ const local = graphNodeId.slice(protocolInstancePath(graphNodeId).length);
56
+ if (PROTOCOL_PAGE_SPACE_ID_PREFIXES.some((prefix) => local.startsWith(prefix))) return false;
57
+ return PROTOCOL_INSTANCE_QUALIFIABLE.some((prefix) => local.startsWith(prefix)) ? true : void 0;
58
+ }
59
+ //#endregion
60
+ //#region src/async-boundary-arm.ts
61
+ const ASYNC_BOUNDARY_ARM = {
62
+ try: 0,
63
+ pending: 1,
64
+ catch: 2
65
+ };
66
+ //#endregion
67
+ //#region src/protocol-detached-content.ts
68
+ /**
69
+ * Elements whose content the HTML parser keeps out of document order: `<template>` parses its
70
+ * content into `template.content`, and the raw-text elements parse theirs as text (`<noscript>`
71
+ * with scripting on). Nothing inside one is an element the DOM-order census can count, so the
72
+ * compiler mints no host for it and the served-tree reader skips it.
73
+ */
74
+ const PROTOCOL_TEMPLATE_CONTENT_TAG = "template";
75
+ /** A `<template>` carrying this attribute is consumed by the parser into a shadow root: the element itself is gone too. */
76
+ const PROTOCOL_DECLARATIVE_SHADOW_ROOT_ATTRIBUTE = "shadowrootmode";
77
+ const PROTOCOL_RAW_TEXT_TAGS = /* @__PURE__ */ new Set([
78
+ "script",
79
+ "style",
80
+ "textarea",
81
+ "title",
82
+ "xmp",
83
+ "iframe",
84
+ "noembed",
85
+ "noframes",
86
+ "noscript"
87
+ ]);
88
+ //#endregion
89
+ //#region src/protocol-event-host.ts
90
+ /**
91
+ * The attribute the server writes on each served element that hosts an event
92
+ * record. The inline boot reads it from the event target up, so it finds a
93
+ * press's handler and sync policy without parsing a payload or knowing the
94
+ * element's position. Grammar: entries joined by `;`, each
95
+ * `name[:ref][!policy]`, where `ref` is the record's index in its region's event
96
+ * list (or `-` for an event an external delegate owns) and `policy` is `p`, `s`,
97
+ * `ps` or an index into the container's sync-policy table.
98
+ */
99
+ const PROTOCOL_EVENT_HOST_ATTRIBUTE = "m:on";
100
+ /** The inert script holding each distinct conditional sync policy of a container once. */
101
+ const PROTOCOL_SYNC_POLICY_TABLE_TYPE = "markless/policy";
102
+ const PROTOCOL_EVENT_HOST_ENTRY_SEPARATOR = ";";
103
+ const PROTOCOL_EVENT_HOST_REF_SEPARATOR = ":";
104
+ const PROTOCOL_EVENT_HOST_POLICY_SEPARATOR = "!";
105
+ const PROTOCOL_EVENT_HOST_DELEGATED_REF = "-";
106
+ function formatEventHostEntries(entries) {
107
+ return entries.map((entry) => entry.name + (entry.ref === void 0 ? "" : ":" + entry.ref) + (entry.policy === void 0 ? "" : "!" + entry.policy)).join(";");
108
+ }
109
+ function parseEventHostEntries(value) {
110
+ return value.split(";").filter(Boolean).map((text) => {
111
+ const [head = "", policy] = text.split("!");
112
+ const [name = "", ref] = head.split(":");
113
+ return {
114
+ name,
115
+ ...ref === void 0 ? {} : { ref: ref === "-" ? ref : Number(ref) },
116
+ ...policy === void 0 ? {} : { policy: policy === "p" || policy === "s" || policy === "ps" ? policy : Number(policy) }
117
+ };
118
+ });
119
+ }
120
+ /**
121
+ * The inline spelling of a policy that acts on every event, or undefined when the
122
+ * policy reads the event or the graph and so needs the table.
123
+ */
124
+ function constantSyncPolicyCode(policy) {
125
+ const branches = "branches" in policy ? policy.branches : [policy];
126
+ let prevent = false;
127
+ let stop = false;
128
+ for (const branch of branches) {
129
+ if (branch.when.type !== "constant-truthy") return void 0;
130
+ if (!branch.when.value) continue;
131
+ prevent ||= branch.actions.includes("preventDefault");
132
+ stop ||= branch.actions.includes("stopPropagation");
133
+ }
134
+ if (prevent && stop) return "ps";
135
+ if (prevent) return "p";
136
+ if (stop) return "s";
137
+ }
138
+ /** Whether a policy can never act, so its host needs no policy entry at all. */
139
+ function syncPolicyNeverActs(policy) {
140
+ return ("branches" in policy ? policy.branches : [policy]).every((branch) => branch.actions.length === 0 || branch.when.type === "constant-truthy" && !branch.when.value);
141
+ }
142
+ //#endregion
143
+ //#region src/protocol.ts
144
+ function protocolEventActionKind(record) {
145
+ return record.action?.kind ?? PROTOCOL_EVENT_ACTION_KIND.event;
146
+ }
147
+ function protocolEventDispatchesMarkless(record) {
148
+ return protocolEventActionKind(record) === PROTOCOL_EVENT_ACTION_KIND.event;
149
+ }
150
+ /**
151
+ * The graph read id an arm-update symbol asks under for a minted element() id.
152
+ *
153
+ * A minted id is `idPrefix + handle` where the prefix is the rendered widget's
154
+ * instance token, a seed-map value no flip can reach. The render that served the
155
+ * arm resolves the id and files it on the branch record under this key; the
156
+ * symbol asks for it through the read channel it already has, so the mint keeps
157
+ * exactly one spelling. Resume matches the key as a SUFFIX of the id it is
158
+ * handed, because a composed symbol's reads arrive with the instance path
159
+ * prepended — that is why the key carries the namespace and not the bare handle.
160
+ */
161
+ function protocolElementHandleReadId(handleGraphNodeId) {
162
+ return `markless:element-handle-id|${handleGraphNodeId}`;
163
+ }
164
+ //#endregion
165
+ export { PROTOCOL_CONTAINER_END_COMMENT as A, protocolInstancePath as C, protocolRowSegment as D, protocolProjectionSegment as E, PROTOCOL_VISIBLE_EVENT_NAME as F, PROTOCOL_CONTAINER_START_COMMENT as M, PROTOCOL_LOCATOR_PATHS_ATTRIBUTE as N, protocolStateVersion as O, PROTOCOL_IDLE_EVENT_NAME as P, STORAGE_PROTOCOL_VERSION as S, protocolInstanceSegment as T, ASYNC_BOUNDARY_ARM as _, PROTOCOL_EVENT_HOST_DELEGATED_REF as a, PROTOCOL_PAGE_SPACE_ID_PREFIXES as b, PROTOCOL_EVENT_HOST_REF_SEPARATOR as c, formatEventHostEntries as d, parseEventHostEntries as f, PROTOCOL_TEMPLATE_CONTENT_TAG as g, PROTOCOL_RAW_TEXT_TAGS as h, PROTOCOL_EVENT_HOST_ATTRIBUTE as i, PROTOCOL_CONTAINER_HOST_NODE_ID as j, PROTOCOL_PROP_GRAPH_NODE_PREFIX as k, PROTOCOL_SYNC_POLICY_TABLE_TYPE as l, PROTOCOL_DECLARATIVE_SHADOW_ROOT_ATTRIBUTE as m, protocolEventActionKind as n, PROTOCOL_EVENT_HOST_ENTRY_SEPARATOR as o, syncPolicyNeverActs as p, protocolEventDispatchesMarkless as r, PROTOCOL_EVENT_HOST_POLICY_SEPARATOR as s, protocolElementHandleReadId as t, constantSyncPolicyCode as u, ASYNC_PROTOCOL_VERSION as v, protocolInstanceQualifies as w, PROTOCOL_PROPS_GRAPH_NODE_ID as x, PROTOCOL_EVENT_ACTION_KIND as y };
@@ -22,15 +22,6 @@ declare const PROTOCOL_CONTAINER_START_COMMENT = "markless:page-start";
22
22
  declare const PROTOCOL_CONTAINER_END_COMMENT = "markless:page-end";
23
23
  declare const PROTOCOL_CONTAINER_HOST_NODE_ID = "container";
24
24
  //#endregion
25
- //#region src/protocol-sync-policy-host.d.ts
26
- /**
27
- * The attribute the server writes on each element whose event record carries a
28
- * sync policy (preventDefault, stopPropagation), valued with that record's
29
- * hostNodeId. The inline boot finds the policy from the event's own target up
30
- * to the nearest marked element, so it never needs the element's position.
31
- */
32
- declare const PROTOCOL_SYNC_POLICY_HOST_ATTRIBUTE = "data-markless-sync";
33
- //#endregion
34
25
  //#region src/protocol-prop-prefix.d.ts
35
26
  declare const PROTOCOL_PROP_GRAPH_NODE_PREFIX = "prop:";
36
27
  //#endregion
@@ -52,6 +43,51 @@ declare const PROTOCOL_PROPS_GRAPH_NODE_ID = "prop:props";
52
43
  declare const PROTOCOL_PAGE_SPACE_ID_PREFIXES: string[];
53
44
  declare function protocolInstanceQualifies(graphNodeId: string): boolean | undefined;
54
45
  //#endregion
46
+ //#region src/protocol-detached-content.d.ts
47
+ /**
48
+ * Elements whose content the HTML parser keeps out of document order: `<template>` parses its
49
+ * content into `template.content`, and the raw-text elements parse theirs as text (`<noscript>`
50
+ * with scripting on). Nothing inside one is an element the DOM-order census can count, so the
51
+ * compiler mints no host for it and the served-tree reader skips it.
52
+ */
53
+ declare const PROTOCOL_TEMPLATE_CONTENT_TAG = "template";
54
+ /** A `<template>` carrying this attribute is consumed by the parser into a shadow root: the element itself is gone too. */
55
+ declare const PROTOCOL_DECLARATIVE_SHADOW_ROOT_ATTRIBUTE = "shadowrootmode";
56
+ declare const PROTOCOL_RAW_TEXT_TAGS: ReadonlySet<string>;
57
+ //#endregion
58
+ //#region src/protocol-event-host.d.ts
59
+ /**
60
+ * The attribute the server writes on each served element that hosts an event
61
+ * record. The inline boot reads it from the event target up, so it finds a
62
+ * press's handler and sync policy without parsing a payload or knowing the
63
+ * element's position. Grammar: entries joined by `;`, each
64
+ * `name[:ref][!policy]`, where `ref` is the record's index in its region's event
65
+ * list (or `-` for an event an external delegate owns) and `policy` is `p`, `s`,
66
+ * `ps` or an index into the container's sync-policy table.
67
+ */
68
+ declare const PROTOCOL_EVENT_HOST_ATTRIBUTE = "m:on";
69
+ /** The inert script holding each distinct conditional sync policy of a container once. */
70
+ declare const PROTOCOL_SYNC_POLICY_TABLE_TYPE = "markless/policy";
71
+ declare const PROTOCOL_EVENT_HOST_ENTRY_SEPARATOR = ";";
72
+ declare const PROTOCOL_EVENT_HOST_REF_SEPARATOR = ":";
73
+ declare const PROTOCOL_EVENT_HOST_POLICY_SEPARATOR = "!";
74
+ declare const PROTOCOL_EVENT_HOST_DELEGATED_REF = "-";
75
+ type ProtocolConstantSyncPolicyCode = 'p' | 's' | 'ps';
76
+ type ProtocolEventHostEntry = {
77
+ readonly name: string;
78
+ readonly ref?: number | typeof PROTOCOL_EVENT_HOST_DELEGATED_REF;
79
+ readonly policy?: ProtocolConstantSyncPolicyCode | number;
80
+ };
81
+ declare function formatEventHostEntries(entries: ReadonlyArray<ProtocolEventHostEntry>): string;
82
+ declare function parseEventHostEntries(value: string): ProtocolEventHostEntry[];
83
+ /**
84
+ * The inline spelling of a policy that acts on every event, or undefined when the
85
+ * policy reads the event or the graph and so needs the table.
86
+ */
87
+ declare function constantSyncPolicyCode(policy: ProtocolSyncPolicy): ProtocolConstantSyncPolicyCode | undefined;
88
+ /** Whether a policy can never act, so its host needs no policy entry at all. */
89
+ declare function syncPolicyNeverActs(policy: ProtocolSyncPolicy): boolean;
90
+ //#endregion
55
91
  //#region src/protocol.d.ts
56
92
  type ProtocolAsyncBoundaryArm = (typeof ASYNC_BOUNDARY_ARM)[keyof typeof ASYNC_BOUNDARY_ARM];
57
93
  type ProtocolSyncPolicyCondition = {
@@ -665,4 +701,4 @@ type ProtocolPayloadScripts = {
665
701
  readonly viewScript: string;
666
702
  };
667
703
  //#endregion
668
- export { protocolRowSegment as A, ASYNC_BOUNDARY_ARM as B, PROTOCOL_PAGE_SPACE_ID_PREFIXES as C, protocolInstanceQualifies as D, protocolInstancePath as E, PROTOCOL_CONTAINER_HOST_NODE_ID as F, PROTOCOL_CONTAINER_START_COMMENT as I, PROTOCOL_LOCATOR_PATHS_ATTRIBUTE as L, PROTOCOL_PROP_GRAPH_NODE_PREFIX as M, PROTOCOL_SYNC_POLICY_HOST_ATTRIBUTE as N, protocolInstanceSegment as O, PROTOCOL_CONTAINER_END_COMMENT as P, PROTOCOL_IDLE_EVENT_NAME as R, PROTOCOL_EVENT_ACTION_KIND as S, STORAGE_PROTOCOL_VERSION as T, ProtocolViewPayload as _, ProtocolBranchIdrefSite as a, protocolEventDispatchesMarkless as b, ProtocolEventActionKind as c, ProtocolRowTemplateSlotValue as d, ProtocolStatePayload as f, ProtocolSyncPolicyCondition as g, ProtocolSyncPolicyBranch as h, ProtocolBranchContentRead as i, protocolStateVersion as j, protocolProjectionSegment as k, ProtocolEventRecord as l, ProtocolSyncPolicy as m, ProtocolArmRecordSet as n, ProtocolComposedGraphProp as o, ProtocolStreamedArmPatch as p, ProtocolAsyncBoundaryArm as r, ProtocolEventAction as s, ProtocolArmBranchRecord as t, ProtocolPayloadScripts as u, protocolElementHandleReadId as v, PROTOCOL_PROPS_GRAPH_NODE_ID as w, ASYNC_PROTOCOL_VERSION as x, protocolEventActionKind as y, PROTOCOL_VISIBLE_EVENT_NAME as z };
704
+ export { PROTOCOL_VISIBLE_EVENT_NAME as $, formatEventHostEntries as A, STORAGE_PROTOCOL_VERSION as B, PROTOCOL_EVENT_HOST_ENTRY_SEPARATOR as C, ProtocolConstantSyncPolicyCode as D, PROTOCOL_SYNC_POLICY_TABLE_TYPE as E, PROTOCOL_TEMPLATE_CONTENT_TAG as F, protocolRowSegment as G, protocolInstanceQualifies as H, ASYNC_PROTOCOL_VERSION as I, PROTOCOL_CONTAINER_END_COMMENT as J, protocolStateVersion as K, PROTOCOL_EVENT_ACTION_KIND as L, syncPolicyNeverActs as M, PROTOCOL_DECLARATIVE_SHADOW_ROOT_ATTRIBUTE as N, ProtocolEventHostEntry as O, PROTOCOL_RAW_TEXT_TAGS as P, PROTOCOL_IDLE_EVENT_NAME as Q, PROTOCOL_PAGE_SPACE_ID_PREFIXES as R, PROTOCOL_EVENT_HOST_DELEGATED_REF as S, PROTOCOL_EVENT_HOST_REF_SEPARATOR as T, protocolInstanceSegment as U, protocolInstancePath as V, protocolProjectionSegment as W, PROTOCOL_CONTAINER_START_COMMENT as X, PROTOCOL_CONTAINER_HOST_NODE_ID as Y, PROTOCOL_LOCATOR_PATHS_ATTRIBUTE as Z, ProtocolViewPayload as _, ProtocolBranchIdrefSite as a, protocolEventDispatchesMarkless as b, ProtocolEventActionKind as c, ProtocolRowTemplateSlotValue as d, ASYNC_BOUNDARY_ARM as et, ProtocolStatePayload as f, ProtocolSyncPolicyCondition as g, ProtocolSyncPolicyBranch as h, ProtocolBranchContentRead as i, parseEventHostEntries as j, constantSyncPolicyCode as k, ProtocolEventRecord as l, ProtocolSyncPolicy as m, ProtocolArmRecordSet as n, ProtocolComposedGraphProp as o, ProtocolStreamedArmPatch as p, PROTOCOL_PROP_GRAPH_NODE_PREFIX as q, ProtocolAsyncBoundaryArm as r, ProtocolEventAction as s, ProtocolArmBranchRecord as t, ProtocolPayloadScripts as u, protocolElementHandleReadId as v, PROTOCOL_EVENT_HOST_POLICY_SEPARATOR as w, PROTOCOL_EVENT_HOST_ATTRIBUTE as x, protocolEventActionKind as y, PROTOCOL_PROPS_GRAPH_NODE_ID as z };
@@ -1,4 +1,4 @@
1
- import { _ as ProtocolViewPayload, f as ProtocolStatePayload } from "./protocol-BNO5JLsK.js";
1
+ import { _ as ProtocolViewPayload, f as ProtocolStatePayload } from "./protocol-D8nfDFJd.js";
2
2
  //#region src/protocol-validation.d.ts
3
3
  type EncodedPayloadScripts = {
4
4
  readonly stateScript: string;
@@ -1,4 +1,4 @@
1
- import { i as ASYNC_BOUNDARY_ARM, o as PROTOCOL_EVENT_ACTION_KIND } from "./protocol-9Mv28nr_.js";
1
+ import { _ as ASYNC_BOUNDARY_ARM, y as PROTOCOL_EVENT_ACTION_KIND } from "./protocol-B57uFVtf.js";
2
2
  import { t as decodeProtocolPayloadLists } from "./protocol-record-templates-B0Ay3OCd.js";
3
3
  //#region src/protocol-validation.ts
4
4
  var RuntimePayloadError = class extends Error {
@@ -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-B4dATVQ_.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-CLv0E9Gp.js";
2
2
  export { DecodedPayloadScripts, EncodedPayloadScripts, RuntimePayloadDiagnostic, RuntimePayloadError, RuntimePayloadErrorCode, RuntimePayloadType, assertProtocolStateCellPayload, assertProtocolStatePayload, assertProtocolViewPayload, decodePayloadScripts, decodePayloadScriptsWithVersion, invalidPayloadShapeError, payloadInvalidError, payloadScriptSelector };
@@ -1,2 +1 @@
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-D9VzvR9i.js";
2
- export { RuntimePayloadError, assertProtocolStateCellPayload, assertProtocolStatePayload, assertProtocolViewPayload, decodePayloadScripts, decodePayloadScriptsWithVersion, invalidPayloadShapeError, payloadInvalidError, payloadScriptSelector };
1
+ export { r as RuntimePayloadError, i as assertProtocolStateCellPayload, a as assertProtocolStatePayload, o as assertProtocolViewPayload, t as decodePayloadScripts, s as decodePayloadScriptsWithVersion, c as invalidPayloadShapeError, l as payloadInvalidError, u as payloadScriptSelector } from "./protocol-validation-storage-DYrHI-d6.js";
@@ -1,2 +1,2 @@
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 };
1
+ import { $ as PROTOCOL_VISIBLE_EVENT_NAME, A as formatEventHostEntries, B as STORAGE_PROTOCOL_VERSION, C as PROTOCOL_EVENT_HOST_ENTRY_SEPARATOR, D as ProtocolConstantSyncPolicyCode, E as PROTOCOL_SYNC_POLICY_TABLE_TYPE, F as PROTOCOL_TEMPLATE_CONTENT_TAG, G as protocolRowSegment, H as protocolInstanceQualifies, I as ASYNC_PROTOCOL_VERSION, J as PROTOCOL_CONTAINER_END_COMMENT, K as protocolStateVersion, L as PROTOCOL_EVENT_ACTION_KIND, M as syncPolicyNeverActs, N as PROTOCOL_DECLARATIVE_SHADOW_ROOT_ATTRIBUTE, O as ProtocolEventHostEntry, P as PROTOCOL_RAW_TEXT_TAGS, Q as PROTOCOL_IDLE_EVENT_NAME, R as PROTOCOL_PAGE_SPACE_ID_PREFIXES, S as PROTOCOL_EVENT_HOST_DELEGATED_REF, T as PROTOCOL_EVENT_HOST_REF_SEPARATOR, U as protocolInstanceSegment, V as protocolInstancePath, W as protocolProjectionSegment, X as PROTOCOL_CONTAINER_START_COMMENT, Y as PROTOCOL_CONTAINER_HOST_NODE_ID, Z as PROTOCOL_LOCATOR_PATHS_ATTRIBUTE, _ as ProtocolViewPayload, a as ProtocolBranchIdrefSite, b as protocolEventDispatchesMarkless, c as ProtocolEventActionKind, d as ProtocolRowTemplateSlotValue, et as ASYNC_BOUNDARY_ARM, f as ProtocolStatePayload, g as ProtocolSyncPolicyCondition, h as ProtocolSyncPolicyBranch, i as ProtocolBranchContentRead, j as parseEventHostEntries, k as constantSyncPolicyCode, l as ProtocolEventRecord, m as ProtocolSyncPolicy, n as ProtocolArmRecordSet, o as ProtocolComposedGraphProp, p as ProtocolStreamedArmPatch, q as PROTOCOL_PROP_GRAPH_NODE_PREFIX, r as ProtocolAsyncBoundaryArm, s as ProtocolEventAction, t as ProtocolArmBranchRecord, u as ProtocolPayloadScripts, v as protocolElementHandleReadId, w as PROTOCOL_EVENT_HOST_POLICY_SEPARATOR, x as PROTOCOL_EVENT_HOST_ATTRIBUTE, y as protocolEventActionKind, z as PROTOCOL_PROPS_GRAPH_NODE_ID } from "./protocol-D8nfDFJd.js";
2
+ export { ASYNC_BOUNDARY_ARM, ASYNC_PROTOCOL_VERSION, PROTOCOL_CONTAINER_END_COMMENT, PROTOCOL_CONTAINER_HOST_NODE_ID, PROTOCOL_CONTAINER_START_COMMENT, PROTOCOL_DECLARATIVE_SHADOW_ROOT_ATTRIBUTE, PROTOCOL_EVENT_ACTION_KIND, PROTOCOL_EVENT_HOST_ATTRIBUTE, PROTOCOL_EVENT_HOST_DELEGATED_REF, PROTOCOL_EVENT_HOST_ENTRY_SEPARATOR, PROTOCOL_EVENT_HOST_POLICY_SEPARATOR, PROTOCOL_EVENT_HOST_REF_SEPARATOR, PROTOCOL_IDLE_EVENT_NAME, PROTOCOL_LOCATOR_PATHS_ATTRIBUTE, PROTOCOL_PAGE_SPACE_ID_PREFIXES, PROTOCOL_PROPS_GRAPH_NODE_ID, PROTOCOL_PROP_GRAPH_NODE_PREFIX, PROTOCOL_RAW_TEXT_TAGS, PROTOCOL_SYNC_POLICY_TABLE_TYPE, PROTOCOL_TEMPLATE_CONTENT_TAG, PROTOCOL_VISIBLE_EVENT_NAME, ProtocolArmBranchRecord, ProtocolArmRecordSet, ProtocolAsyncBoundaryArm, ProtocolBranchContentRead, ProtocolBranchIdrefSite, ProtocolComposedGraphProp, type ProtocolConstantSyncPolicyCode, ProtocolEventAction, ProtocolEventActionKind, type ProtocolEventHostEntry, ProtocolEventRecord, ProtocolPayloadScripts, ProtocolRowTemplateSlotValue, ProtocolStatePayload, ProtocolStreamedArmPatch, ProtocolSyncPolicy, ProtocolSyncPolicyBranch, ProtocolSyncPolicyCondition, ProtocolViewPayload, STORAGE_PROTOCOL_VERSION, constantSyncPolicyCode, formatEventHostEntries, parseEventHostEntries, protocolElementHandleReadId, protocolEventActionKind, protocolEventDispatchesMarkless, protocolInstancePath, protocolInstanceQualifies, protocolInstanceSegment, protocolProjectionSegment, protocolRowSegment, protocolStateVersion, syncPolicyNeverActs };
package/dist/protocol.js CHANGED
@@ -1,2 +1 @@
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 };
1
+ export { _ as ASYNC_BOUNDARY_ARM, v as ASYNC_PROTOCOL_VERSION, A as PROTOCOL_CONTAINER_END_COMMENT, j as PROTOCOL_CONTAINER_HOST_NODE_ID, M as PROTOCOL_CONTAINER_START_COMMENT, m as PROTOCOL_DECLARATIVE_SHADOW_ROOT_ATTRIBUTE, y as PROTOCOL_EVENT_ACTION_KIND, i as PROTOCOL_EVENT_HOST_ATTRIBUTE, a as PROTOCOL_EVENT_HOST_DELEGATED_REF, o as PROTOCOL_EVENT_HOST_ENTRY_SEPARATOR, s as PROTOCOL_EVENT_HOST_POLICY_SEPARATOR, c as PROTOCOL_EVENT_HOST_REF_SEPARATOR, P as PROTOCOL_IDLE_EVENT_NAME, N as PROTOCOL_LOCATOR_PATHS_ATTRIBUTE, b as PROTOCOL_PAGE_SPACE_ID_PREFIXES, x as PROTOCOL_PROPS_GRAPH_NODE_ID, k as PROTOCOL_PROP_GRAPH_NODE_PREFIX, h as PROTOCOL_RAW_TEXT_TAGS, l as PROTOCOL_SYNC_POLICY_TABLE_TYPE, g as PROTOCOL_TEMPLATE_CONTENT_TAG, F as PROTOCOL_VISIBLE_EVENT_NAME, S as STORAGE_PROTOCOL_VERSION, u as constantSyncPolicyCode, d as formatEventHostEntries, f as parseEventHostEntries, t as protocolElementHandleReadId, n as protocolEventActionKind, r as protocolEventDispatchesMarkless, C as protocolInstancePath, w as protocolInstanceQualifies, T as protocolInstanceSegment, E as protocolProjectionSegment, D as protocolRowSegment, O as protocolStateVersion, p as syncPolicyNeverActs } from "./protocol-B57uFVtf.js";
@@ -1,2 +1 @@
1
- import { n as expandRecordTemplates, r as PROTOCOL_TEMPLATED_LISTS, t as decodeProtocolPayloadLists } from "./protocol-record-templates-B0Ay3OCd.js";
2
- export { PROTOCOL_TEMPLATED_LISTS, decodeProtocolPayloadLists, expandRecordTemplates };
1
+ export { r as PROTOCOL_TEMPLATED_LISTS, t as decodeProtocolPayloadLists, n as expandRecordTemplates } from "./protocol-record-templates-B0Ay3OCd.js";
@@ -0,0 +1,35 @@
1
+ //#region src/render-data-hosts.d.ts
2
+ /**
3
+ * Render data names the elements of a chunk that something addresses (a handler,
4
+ * an update, a handle, a list or arm anchor). Every other element is static text
5
+ * in the chunk's markup that only has to be counted, so the compiler folds those
6
+ * into `inertElements` and renderers walk the chunk in coordinate order with the
7
+ * counts in between, which keeps DOM-order indexes exact.
8
+ */
9
+ type Coordinate = {
10
+ readonly coordinate: {
11
+ readonly path: ReadonlyArray<number>;
12
+ };
13
+ };
14
+ export type RenderDataChunkHosts<Host extends Coordinate, Slot extends Coordinate> = {
15
+ readonly hosts: ReadonlyArray<Host>;
16
+ readonly slots: ReadonlyArray<Slot>;
17
+ /** Unaddressed elements before each host and slot in coordinate order, then after the last. */
18
+ readonly inertElements?: ReadonlyArray<number>;
19
+ };
20
+ export type RenderDataChunkEntry<Host, Slot> = {
21
+ readonly kind: 'host';
22
+ readonly host: Host;
23
+ readonly inertBefore: number;
24
+ } | {
25
+ readonly kind: 'slot';
26
+ readonly slot: Slot;
27
+ readonly inertBefore: number;
28
+ };
29
+ /** The chunk's hosts and slots in document order (a parent before what it holds), each with the unaddressed elements before it. */
30
+ export declare function chunkCoordinateOrder<Host extends Coordinate, Slot extends Coordinate>(chunk: RenderDataChunkHosts<Host, Slot>): {
31
+ readonly entries: ReadonlyArray<RenderDataChunkEntry<Host, Slot>>;
32
+ readonly inertAfter: number;
33
+ };
34
+ //#endregion
35
+ export {};
@@ -0,0 +1,37 @@
1
+ //#region src/render-data-hosts.ts
2
+ function compareRenderCoordinates(left, right) {
3
+ for (let index = 0; index < Math.min(left.length, right.length); index++) {
4
+ const difference = left[index] - right[index];
5
+ if (difference !== 0) return difference;
6
+ }
7
+ return left.length - right.length;
8
+ }
9
+ /** The chunk's hosts and slots in document order (a parent before what it holds), each with the unaddressed elements before it. */
10
+ function chunkCoordinateOrder(chunk) {
11
+ const inert = chunk.inertElements;
12
+ const entries = [...chunk.hosts.map((host) => ({
13
+ path: host.coordinate.path,
14
+ order: 0,
15
+ host,
16
+ slot: void 0
17
+ })), ...chunk.slots.map((slot, order) => ({
18
+ path: slot.coordinate.path,
19
+ order: order + 1,
20
+ host: void 0,
21
+ slot
22
+ }))].sort((left, right) => compareRenderCoordinates(left.path, right.path) || left.order - right.order).map((entry, index) => entry.host ? {
23
+ kind: "host",
24
+ host: entry.host,
25
+ inertBefore: inert?.[index] ?? 0
26
+ } : {
27
+ kind: "slot",
28
+ slot: entry.slot,
29
+ inertBefore: inert?.[index] ?? 0
30
+ });
31
+ return {
32
+ entries,
33
+ inertAfter: inert?.[entries.length] ?? 0
34
+ };
35
+ }
36
+ //#endregion
37
+ export { chunkCoordinateOrder };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markless/serializer",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "Markless serialization tiers and resumability payload protocol.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -46,6 +46,10 @@
46
46
  "types": "./dist/record-templates.d.ts",
47
47
  "default": "./dist/record-templates.js"
48
48
  },
49
+ "./render-data-hosts": {
50
+ "types": "./dist/render-data-hosts.d.ts",
51
+ "default": "./dist/render-data-hosts.js"
52
+ },
49
53
  "./protocol-validation": {
50
54
  "types": "./dist/protocol-validation.d.ts",
51
55
  "default": "./dist/protocol-validation.js"
@@ -1,98 +0,0 @@
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-page-markers.ts
14
- const PROTOCOL_CONTAINER_START_COMMENT = "markless:page-start";
15
- const PROTOCOL_CONTAINER_END_COMMENT = "markless:page-end";
16
- const PROTOCOL_CONTAINER_HOST_NODE_ID = "container";
17
- //#endregion
18
- //#region src/protocol-sync-policy-host.ts
19
- /**
20
- * The attribute the server writes on each element whose event record carries a
21
- * sync policy (preventDefault, stopPropagation), valued with that record's
22
- * hostNodeId. The inline boot finds the policy from the event's own target up
23
- * to the nearest marked element, so it never needs the element's position.
24
- */
25
- const PROTOCOL_SYNC_POLICY_HOST_ATTRIBUTE = "data-markless-sync";
26
- //#endregion
27
- //#region src/protocol-prop-prefix.ts
28
- const PROTOCOL_PROP_GRAPH_NODE_PREFIX = "prop:";
29
- //#endregion
30
- //#region src/protocol-constants.ts
31
- const ASYNC_PROTOCOL_VERSION = 1;
32
- const STORAGE_PROTOCOL_VERSION = 2;
33
- function protocolStateVersion(storage) {
34
- return (storage?.length ?? 0) > 0 ? 2 : 1;
35
- }
36
- const PROTOCOL_EVENT_ACTION_KIND = {
37
- event: "event",
38
- externalDelegate: "external-delegate"
39
- };
40
- const PROTOCOL_INSTANCE_PATH = /^(?:[cpm]\d+:|r:[^:]*:)+/;
41
- function protocolInstanceSegment(edgeIndex) {
42
- return `c${edgeIndex}:`;
43
- }
44
- function protocolProjectionSegment(edgeIndex) {
45
- return `p${edgeIndex}:`;
46
- }
47
- /** One keyed `@for` row's identity segment. The key is identity, never the index. */
48
- function protocolRowSegment(key) {
49
- return `r:${encodeURIComponent(String(key))}:`;
50
- }
51
- /** The leading instance path of a composed id, or '' when the id is page-local. */
52
- function protocolInstancePath(id) {
53
- return PROTOCOL_INSTANCE_PATH.exec(id)?.[0] ?? "";
54
- }
55
- const PROTOCOL_PROPS_GRAPH_NODE_ID = "prop:props";
56
- const PROTOCOL_INSTANCE_QUALIFIABLE = [
57
- "prop:",
58
- "state:",
59
- "computed:",
60
- "element:"
61
- ];
62
- const PROTOCOL_PAGE_SPACE_ID_PREFIXES = ["shared:", "storage:"];
63
- function protocolInstanceQualifies(graphNodeId) {
64
- const local = graphNodeId.slice(protocolInstancePath(graphNodeId).length);
65
- if (PROTOCOL_PAGE_SPACE_ID_PREFIXES.some((prefix) => local.startsWith(prefix))) return false;
66
- return PROTOCOL_INSTANCE_QUALIFIABLE.some((prefix) => local.startsWith(prefix)) ? true : void 0;
67
- }
68
- //#endregion
69
- //#region src/async-boundary-arm.ts
70
- const ASYNC_BOUNDARY_ARM = {
71
- try: 0,
72
- pending: 1,
73
- catch: 2
74
- };
75
- //#endregion
76
- //#region src/protocol.ts
77
- function protocolEventActionKind(record) {
78
- return record.action?.kind ?? PROTOCOL_EVENT_ACTION_KIND.event;
79
- }
80
- function protocolEventDispatchesMarkless(record) {
81
- return protocolEventActionKind(record) === PROTOCOL_EVENT_ACTION_KIND.event;
82
- }
83
- /**
84
- * The graph read id an arm-update symbol asks under for a minted element() id.
85
- *
86
- * A minted id is `idPrefix + handle` where the prefix is the rendered widget's
87
- * instance token, a seed-map value no flip can reach. The render that served the
88
- * arm resolves the id and files it on the branch record under this key; the
89
- * symbol asks for it through the read channel it already has, so the mint keeps
90
- * exactly one spelling. Resume matches the key as a SUFFIX of the id it is
91
- * handed, because a composed symbol's reads arrive with the instance path
92
- * prepended — that is why the key carries the namespace and not the bare handle.
93
- */
94
- function protocolElementHandleReadId(handleGraphNodeId) {
95
- return `markless:element-handle-id|${handleGraphNodeId}`;
96
- }
97
- //#endregion
98
- export { PROTOCOL_VISIBLE_EVENT_NAME as C, PROTOCOL_IDLE_EVENT_NAME as S, PROTOCOL_SYNC_POLICY_HOST_ATTRIBUTE as _, ASYNC_PROTOCOL_VERSION as a, PROTOCOL_CONTAINER_START_COMMENT as b, PROTOCOL_PROPS_GRAPH_NODE_ID as c, protocolInstanceQualifies as d, protocolInstanceSegment as f, PROTOCOL_PROP_GRAPH_NODE_PREFIX as g, protocolStateVersion as h, ASYNC_BOUNDARY_ARM as i, STORAGE_PROTOCOL_VERSION as l, protocolRowSegment as m, protocolEventActionKind as n, PROTOCOL_EVENT_ACTION_KIND as o, protocolProjectionSegment as p, protocolEventDispatchesMarkless as r, PROTOCOL_PAGE_SPACE_ID_PREFIXES as s, protocolElementHandleReadId as t, protocolInstancePath as u, PROTOCOL_CONTAINER_END_COMMENT as v, PROTOCOL_LOCATOR_PATHS_ATTRIBUTE as x, PROTOCOL_CONTAINER_HOST_NODE_ID as y };