@openelement/protocol 1.0.0-alpha.14 → 1.0.0-alpha.16

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/README.md CHANGED
@@ -10,26 +10,28 @@ into the others' graphs.
10
10
 
11
11
  | Subpath | Import it for |
12
12
  | -------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
13
- | `@openelement/protocol` | The umbrella re-export of every contract below. |
13
+ | `@openelement/protocol` | The umbrella re-export of the shared contracts. |
14
14
  | `@openelement/protocol/app-model` | Host-agnostic route and asset contracts shared by app and build drivers (the route tree node, matched-path shapes). |
15
15
  | `@openelement/protocol/client-assets` | The client asset manifest protocol (#1471): compile-time island identity joined with build output for per-page script wiring. |
16
16
  | `@openelement/protocol/data` | The platform-neutral data adapter protocol. |
17
+ | `@openelement/protocol/diagnostics` | The machine-readable diagnostics envelope (#1612): one JSON shape every build failure answers on, the `openelement.diagnostics/1` report format, and the fail-closed parser. |
17
18
  | `@openelement/protocol/errors` | The single declaration site of the error contract (#1386): coded error classes, phase catalogs (`RuntimeErrorCode`, `KernelErrorCode`, ...). |
18
19
  | `@openelement/protocol/forbidden-sinks`| The one canonical deny list for every Part Program boundary (compiler, validator, server): sink names that fail closed. |
19
- | `@openelement/protocol/framework` | Framework, build, app-shell, routing, and plugin metadata contracts. |
20
+ | `@openelement/protocol/framework` | Framework, build, layout, routing, and plugin metadata contracts. |
20
21
  | `@openelement/protocol/island` | Island contracts (`IslandOptions`, hydration options). |
21
22
  | `@openelement/protocol/island-admission` | The single definition of the router's island admission descriptor. |
22
23
  | `@openelement/protocol/manifest` | CEM manifest and compatibility contract types. |
23
24
  | `@openelement/protocol/module-descriptors` | Binding-identity module descriptors shared by the compiler's semantic core and its hosts (#1557 package split). |
24
25
  | `@openelement/protocol/module-vocabulary` | The router's module-scan vocabulary injected into the element semantic core. |
25
- | `@openelement/protocol/part-program` | Serializable Part Program v1: the compiled element's exchange artifact (template, parts, regions, locations, source map, metadata) + validator. |
26
+ | `@openelement/protocol/part-program` | Serializable Part Program v2: the compiled element's exchange artifact (template, parts, blocks, locations, source map, metadata) + validator. |
26
27
  | `@openelement/protocol/policy` | Numeric build/runtime admission budgets (stream bounds, composition depth, action body limit, timeouts). |
27
28
  | `@openelement/protocol/registry-markers` | SSR customElements registry marker contract (#965). |
28
- | `@openelement/protocol/render` | Render pipeline types (`RenderOutput`, SSR admission decisions). |
29
+ | `@openelement/protocol/render` | Render pipeline types (render errors, hydration hints, SSR admission decisions). |
29
30
  | `@openelement/protocol/runtime` | Runtime adapter protocol. |
31
+ | `@openelement/protocol/server-only` | Side-effect import that marks an application module as server-only in Router browser builds and dev. |
30
32
  | `@openelement/protocol/signal` | Signal contracts (`Signal`, `ReadonlySignal`, brands). |
31
33
  | `@openelement/protocol/ssg` | SSG engine contracts (route manifests, island declarations, stream route manifests). |
32
- | `@openelement/protocol/stream-frame-policy` | The canonical deny lists a deferred text/Region Part frame must satisfy for the browser installer to accept it. |
34
+ | `@openelement/protocol/stream-frame-policy` | The canonical deny lists a deferred text/Block Part frame must satisfy for the browser installer to accept it. |
33
35
  | `@openelement/protocol/style-sheet` | The cross-environment `StyleSheet` abstraction contract. |
34
36
  | `@openelement/protocol/void-tags` | The one canonical HTML void-element set for every serializer, validator, and compiler (#1220). |
35
37
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openelement/protocol",
3
- "version": "1.0.0-alpha.14",
3
+ "version": "1.0.0-alpha.16",
4
4
  "type": "module",
5
5
  "main": "./src/index.js",
6
6
  "types": "./src/index.d.ts",
@@ -25,6 +25,11 @@
25
25
  "import": "./src/data.js",
26
26
  "default": "./src/data.js"
27
27
  },
28
+ "./diagnostics": {
29
+ "types": "./src/diagnostics.d.ts",
30
+ "import": "./src/diagnostics.js",
31
+ "default": "./src/diagnostics.js"
32
+ },
28
33
  "./errors": {
29
34
  "types": "./src/errors.d.ts",
30
35
  "import": "./src/errors.js",
@@ -90,6 +95,11 @@
90
95
  "import": "./src/runtime.js",
91
96
  "default": "./src/runtime.js"
92
97
  },
98
+ "./server-only": {
99
+ "types": "./src/server-only.d.ts",
100
+ "import": "./src/server-only.js",
101
+ "default": "./src/server-only.js"
102
+ },
93
103
  "./signal": {
94
104
  "types": "./src/signal.d.ts",
95
105
  "import": "./src/signal.js",
@@ -6,6 +6,7 @@ const EMPTY_CLIENT_ASSET_MANIFEST = {
6
6
  shared: [],
7
7
  styles: []
8
8
  };
9
+ Object.freeze(EMPTY_CLIENT_ASSET_MANIFEST);
9
10
  /**
10
11
  * Serialize the manifest as the generated dist/server/client-assets.js
11
12
  * module: pure structured data, no injection logic — consumers derive what
@@ -0,0 +1,93 @@
1
+ import { OpenElementError } from "./errors.js";
2
+ //#region src/diagnostics.d.ts
3
+ /**
4
+ * How severe one diagnostic is. `error` fails the build, `warning` reports a
5
+ * recoverable defect, `info` is reserved for advisories. The build report's
6
+ * `ok` flag derives from this: any `error` diagnostic makes the report not-ok.
7
+ */
8
+ export type DiagnosticSeverity = 'error' | 'warning' | 'info';
9
+ /**
10
+ * The pipeline phase a diagnostic was raised in — the same vocabulary the
11
+ * error contract's {@linkcode ErrorPhase} uses, so a producer's code, phase
12
+ * and envelope cannot disagree about where a failure happened.
13
+ */
14
+ export type DiagnosticPhase = 'render' | 'ssr' | 'csr' | 'build' | 'navigation' | 'validation' | 'unknown';
15
+ /**
16
+ * One machine-readable diagnostic: the producer's stable code, where the
17
+ * failure sits (`file`, `line`, `column` — absent when the producer has no
18
+ * source location, e.g. a configuration refusal), what happened
19
+ * (`message`), and when known, the fix (`hint`).
20
+ *
21
+ * `line`/`column` are 1-based, matching the diagnostics the compiler records
22
+ * from TypeScript source positions. Unknown envelope fields are tolerated on
23
+ * the wire (forward compat); the required core is exactly these fields.
24
+ */
25
+ export interface DiagnosticEnvelope {
26
+ /** The producer's own stable code (`OEC9020`, `OE_PRESET_*`, `OE_SSG_*`). */
27
+ code: string;
28
+ severity: DiagnosticSeverity;
29
+ phase: DiagnosticPhase;
30
+ /** What happened, in the producer's own words. */
31
+ message: string;
32
+ /** The source file (or module specifier) the diagnostic points at. */
33
+ file?: string;
34
+ /** 1-based authored line, when the producer has a source location. */
35
+ line?: number;
36
+ /** 1-based authored column, when the producer has a source location. */
37
+ column?: number;
38
+ /** The fix, when the producer can name one. */
39
+ hint?: string;
40
+ }
41
+ /**
42
+ * The `format` discriminator every report carries. Consumers branch on it
43
+ * instead of guessing: a future shape change mints a new tag rather than
44
+ * reinterpreting old bytes.
45
+ */
46
+ export declare const DIAGNOSTIC_REPORT_FORMAT = "openelement.diagnostics/1";
47
+ /** One format tag value (kept as a type for the report's `format` field). */
48
+ export type DiagnosticReportFormat = typeof DIAGNOSTIC_REPORT_FORMAT;
49
+ /**
50
+ * One build exit's diagnostics: the format tag, whether the run is clean
51
+ * (`ok` is false the moment any diagnostic carries severity `error`), and
52
+ * every diagnostic the exit collected. This is the document the CLI writes to
53
+ * the stream and the diagnostics file — one aggregate containing every code.
54
+ */
55
+ export interface DiagnosticReport {
56
+ format: DiagnosticReportFormat;
57
+ ok: boolean;
58
+ diagnostics: DiagnosticEnvelope[];
59
+ }
60
+ /**
61
+ * Assemble the exit's report. `ok` derives from the diagnostics' severities,
62
+ * never from a caller's optimism: one `error` severity is enough to fail it.
63
+ */
64
+ export declare function diagnosticReport(diagnostics: DiagnosticEnvelope[]): DiagnosticReport;
65
+ /** Serialize a report for the stream/file channel: one line, no trailing newline. */
66
+ export declare function serializeDiagnosticReport(report: DiagnosticReport): string;
67
+ /**
68
+ * Raised by {@linkcode parseDiagnosticReport} when the text is not a
69
+ * consumable report. Fail closed: a consumer that catches this knows the
70
+ * channel answered garbage — never a half-valid report.
71
+ */
72
+ export declare class DiagnosticReportParseError extends Error {
73
+ /** Every structural problem found, in input order. */
74
+ readonly problems: string[];
75
+ constructor(problems: string[]);
76
+ }
77
+ /**
78
+ * Parse one report off the wire. Fails closed: truncated JSON, a foreign
79
+ * format tag, or any structurally broken diagnostic raises
80
+ * {@linkcode DiagnosticReportParseError} instead of returning a partial
81
+ * report a consumer might mistake for the truth.
82
+ */
83
+ export declare function parseDiagnosticReport(text: string): DiagnosticReport;
84
+ /**
85
+ * Map the one error dialect ({@linkcode OpenElementError} — every producer's
86
+ * raiser goes through it) onto the envelope. The error's code, severity and
87
+ * phase ARE the envelope's; the message carries verbatim. Producers with a
88
+ * fix pass it as `hint`.
89
+ */
90
+ export declare function errorToEnvelope(error: OpenElementError, options?: {
91
+ hint?: string;
92
+ }): DiagnosticEnvelope;
93
+ //#endregion
@@ -0,0 +1,114 @@
1
+ //#region src/diagnostics.ts
2
+ /**
3
+ * The `format` discriminator every report carries. Consumers branch on it
4
+ * instead of guessing: a future shape change mints a new tag rather than
5
+ * reinterpreting old bytes.
6
+ */
7
+ const DIAGNOSTIC_REPORT_FORMAT = "openelement.diagnostics/1";
8
+ /**
9
+ * Assemble the exit's report. `ok` derives from the diagnostics' severities,
10
+ * never from a caller's optimism: one `error` severity is enough to fail it.
11
+ */
12
+ function diagnosticReport(diagnostics) {
13
+ return {
14
+ format: DIAGNOSTIC_REPORT_FORMAT,
15
+ ok: !diagnostics.some((diagnostic) => diagnostic.severity === "error"),
16
+ diagnostics
17
+ };
18
+ }
19
+ /** Serialize a report for the stream/file channel: one line, no trailing newline. */
20
+ function serializeDiagnosticReport(report) {
21
+ return JSON.stringify(report);
22
+ }
23
+ /**
24
+ * Raised by {@linkcode parseDiagnosticReport} when the text is not a
25
+ * consumable report. Fail closed: a consumer that catches this knows the
26
+ * channel answered garbage — never a half-valid report.
27
+ */
28
+ var DiagnosticReportParseError = class extends Error {
29
+ /** Every structural problem found, in input order. */
30
+ problems;
31
+ constructor(problems) {
32
+ super(problems.length === 1 ? `malformed diagnostics report: ${problems[0]}` : `malformed diagnostics report (${problems.length} problems): ${problems.join("; ")}`);
33
+ this.name = "DiagnosticReportParseError";
34
+ this.problems = problems;
35
+ }
36
+ };
37
+ /** One structural validation failure: where in the report, and what was wrong. */
38
+ function problem(at, expected) {
39
+ return `${at}: expected ${expected}`;
40
+ }
41
+ /**
42
+ * Validate one envelope entry. Structure only — the code (and, for forward
43
+ * compat, the severity/phase spellings) are the producers' vocabulary and are
44
+ * never policed here; the field PRESENCE and PRIMITIVE TYPES are.
45
+ * Unknown fields pass through untouched, so a future producer's extra fields
46
+ * survive the round trip.
47
+ */
48
+ function parseEnvelope(value, at) {
49
+ if (typeof value !== "object" || value === null || Array.isArray(value)) throw new DiagnosticReportParseError([problem(at, "a diagnostic object")]);
50
+ const record = value;
51
+ const problems = [];
52
+ if (typeof record.code !== "string" || record.code.length === 0) problems.push(problem(`${at}.code`, "a non-empty string"));
53
+ if (typeof record.severity !== "string" || record.severity.length === 0) problems.push(problem(`${at}.severity`, "a non-empty string"));
54
+ if (typeof record.phase !== "string" || record.phase.length === 0) problems.push(problem(`${at}.phase`, "a non-empty string"));
55
+ if (typeof record.message !== "string") problems.push(problem(`${at}.message`, "a string"));
56
+ for (const field of ["file", "hint"]) {
57
+ const value = record[field];
58
+ if (value !== void 0 && typeof value !== "string") problems.push(problem(`${at}.${field}`, "a string when present"));
59
+ }
60
+ for (const field of ["line", "column"]) {
61
+ const value = record[field];
62
+ if (value !== void 0 && (typeof value !== "number" || !Number.isInteger(value) || value < 1)) problems.push(problem(`${at}.${field}`, "a positive integer when present"));
63
+ }
64
+ if (problems.length > 0) throw new DiagnosticReportParseError(problems);
65
+ return record;
66
+ }
67
+ /**
68
+ * Parse one report off the wire. Fails closed: truncated JSON, a foreign
69
+ * format tag, or any structurally broken diagnostic raises
70
+ * {@linkcode DiagnosticReportParseError} instead of returning a partial
71
+ * report a consumer might mistake for the truth.
72
+ */
73
+ function parseDiagnosticReport(text) {
74
+ let parsed;
75
+ try {
76
+ parsed = JSON.parse(text);
77
+ } catch (cause) {
78
+ throw new DiagnosticReportParseError([`not JSON: ${cause instanceof Error ? cause.message : String(cause)}`]);
79
+ }
80
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) throw new DiagnosticReportParseError([problem("report", "a JSON object")]);
81
+ const record = parsed;
82
+ const problems = [];
83
+ if (record.format !== "openelement.diagnostics/1") problems.push(problem("report.format", `the literal "${DIAGNOSTIC_REPORT_FORMAT}" (got ${JSON.stringify(record.format)})`));
84
+ if (typeof record.ok !== "boolean") problems.push(problem("report.ok", "a boolean"));
85
+ if (!Array.isArray(record.diagnostics)) problems.push(problem("report.diagnostics", "an array"));
86
+ if (problems.length > 0) throw new DiagnosticReportParseError(problems);
87
+ const diagnostics = record.diagnostics.map((entry, index) => parseEnvelope(entry, `report.diagnostics[${index}]`));
88
+ const expected = diagnosticReport(diagnostics).ok;
89
+ const hasUnknownSeverity = diagnostics.some(({ severity }) => severity !== "error" && severity !== "warning" && severity !== "info");
90
+ if (record.ok !== expected && (!expected || !hasUnknownSeverity)) throw new DiagnosticReportParseError([problem("report.ok", expected ? "true when no error is present" : "false when an error is present")]);
91
+ return {
92
+ ...record,
93
+ format: record.format,
94
+ ok: record.ok,
95
+ diagnostics
96
+ };
97
+ }
98
+ /**
99
+ * Map the one error dialect ({@linkcode OpenElementError} — every producer's
100
+ * raiser goes through it) onto the envelope. The error's code, severity and
101
+ * phase ARE the envelope's; the message carries verbatim. Producers with a
102
+ * fix pass it as `hint`.
103
+ */
104
+ function errorToEnvelope(error, options = {}) {
105
+ return {
106
+ code: error.code,
107
+ severity: error.severity,
108
+ phase: error.phase,
109
+ message: error.message,
110
+ ...options.hint !== void 0 ? { hint: options.hint } : {}
111
+ };
112
+ }
113
+ //#endregion
114
+ export { DIAGNOSTIC_REPORT_FORMAT, DiagnosticReportParseError, diagnosticReport, errorToEnvelope, parseDiagnosticReport, serializeDiagnosticReport };
package/src/errors.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * Every failure raised by this package is an {@linkcode OpenElementError}
7
7
  * carrying `code`, `severity`, `phase` and `recoverable`; the dedicated
8
- * exception classes below (`PartProgramClaimError`,
8
+ * exception classes below (`PartProgramHydrationError`,
9
9
  * `CompiledProgramValidationError`, `EachKeyError`) only ADD their own
10
10
  * provenance fields on top of that contract, so a consumer catches by code
11
11
  * through the one class.
@@ -82,7 +82,7 @@ export type ErrorTelemetryHook = (error: OpenElementError) => void;
82
82
  * reject data before any DOM work starts.
83
83
  */
84
84
  export declare const ProgramErrorCode: {
85
- /** A Part Program v1 failed structural validation. */
85
+ /** A Part Program v2 failed structural validation. */
86
86
  readonly INVALID_PROGRAM: "OE_PROGRAM_INVALID";
87
87
  /** A Part Program cannot be serialized to JSON, so it is not a wire artifact. */
88
88
  readonly NOT_SERIALIZABLE: "OE_PROGRAM_NOT_SERIALIZABLE";
@@ -103,7 +103,7 @@ export declare const EachKeyErrorCode: {
103
103
  readonly ITEM_NOT_A_RECORD: "OE_EACH_ITEM_NOT_A_RECORD";
104
104
  /** A key value cannot round-trip (an object, function or symbol has no stable identity). */
105
105
  readonly KEY_NOT_ROUND_TRIPPABLE: "OE_EACH_KEY_NOT_ROUND_TRIPPABLE";
106
- /** Two items in one list Region derived the same key. */
106
+ /** Two items in one list Block derived the same key. */
107
107
  readonly DUPLICATE_KEY: "OE_EACH_KEY_DUPLICATE";
108
108
  };
109
109
  /**
@@ -111,7 +111,7 @@ export declare const EachKeyErrorCode: {
111
111
  * built into fresh DOM, or re-read on a signal write (phase `render`).
112
112
  */
113
113
  export declare const RuntimeErrorCode: {
114
- /** A list Region's signal does not hold an array. */
114
+ /** A list Block's signal does not hold an array. */
115
115
  readonly LIST_VALUE_NOT_ARRAY: "OE_RUNTIME_LIST_VALUE_NOT_ARRAY";
116
116
  /** render() reads a signal that is not registered on the host. */
117
117
  readonly HOST_SIGNAL_MISSING: "OE_RUNTIME_HOST_SIGNAL_MISSING";
@@ -129,9 +129,9 @@ export declare const RuntimeErrorCode: {
129
129
  readonly PATH_UNRESOLVED: "OE_RUNTIME_PATH_UNRESOLVED";
130
130
  /** A compiled node path resolved to a non-element node. */
131
131
  readonly PATH_NOT_ELEMENT: "OE_RUNTIME_PATH_NOT_ELEMENT";
132
- /** An item value/attribute slot appears outside an `each` Region. */
132
+ /** An item value/attribute slot appears outside an `each` Block. */
133
133
  readonly ITEM_SLOT_OUTSIDE_REGION: "OE_RUNTIME_ITEM_SLOT_OUTSIDE_REGION";
134
- /** An item slot found no owning `each` Region. */
134
+ /** An item slot found no owning `each` Block. */
135
135
  readonly ITEM_SLOT_WITHOUT_REGION: "OE_RUNTIME_ITEM_SLOT_WITHOUT_REGION";
136
136
  /** An item slot has no owner document to create nodes from. */
137
137
  readonly ITEM_SLOT_WITHOUT_DOCUMENT: "OE_RUNTIME_ITEM_SLOT_WITHOUT_DOCUMENT";
@@ -139,10 +139,21 @@ export declare const RuntimeErrorCode: {
139
139
  readonly ROOT_WITHOUT_DOCUMENT: "OE_RUNTIME_ROOT_WITHOUT_DOCUMENT";
140
140
  /** Fresh-DOM creation was handed a root that is not empty. */
141
141
  readonly FRESH_ROOT_NOT_EMPTY: "OE_RUNTIME_FRESH_ROOT_NOT_EMPTY";
142
+ /**
143
+ * `claimRecipe` was asked to claim a recipe that has no generated claim.
144
+ * This is a caller/recipe-shape failure, not a DOM mismatch.
145
+ */
146
+ readonly LEAF_CLAIM_UNAVAILABLE: "OE_RUNTIME_LEAF_CLAIM_UNAVAILABLE";
147
+ /**
148
+ * A static sibling-range directory did not match its declaration, was
149
+ * claimed out of order, or was reclaimed after commitment. Detail lives in
150
+ * the message; cases do not each get a code. Not `LEAF_CLAIM_UNAVAILABLE`.
151
+ */
152
+ readonly STATIC_RANGE_MISMATCH: "OE_RUNTIME_STATIC_RANGE_MISMATCH";
142
153
  /** A fixed Part has no serialized anchor to bind. */
143
154
  readonly SERIALIZED_ANCHOR_MISSING: "OE_RUNTIME_SERIALIZED_ANCHOR_MISSING";
144
- /** A when/each Region Part needs the Region builders, which this entry does not install (#1548). */
145
- readonly REGION_BUILDERS_MISSING: "OE_RUNTIME_REGION_BUILDERS_MISSING";
155
+ /** A when/each Block Part needs the Block builders, which this entry does not install (#1548). */
156
+ readonly BLOCK_BUILDERS_MISSING: "OE_RUNTIME_BLOCK_BUILDERS_MISSING";
146
157
  };
147
158
  /** Element-lifecycle failures: the kernel was driven outside its contract (phase `csr`). */
148
159
  export declare const KernelErrorCode: {
@@ -150,7 +161,7 @@ export declare const KernelErrorCode: {
150
161
  readonly DISPOSED: "OE_KERNEL_DISPOSED";
151
162
  /** `__partProgram.tag` does not match the host element's tag. */
152
163
  readonly TAG_MISMATCH: "OE_KERNEL_TAG_MISMATCH";
153
- /** Existing DOM needs the claim executor, which this entry does not install. */
164
+ /** Existing DOM needs the hydration executor, which this entry does not install. */
154
165
  readonly CLAIM_EXECUTOR_MISSING: "OE_KERNEL_CLAIM_EXECUTOR_MISSING";
155
166
  /** A supplied root is not owned by the element it was passed for. */
156
167
  readonly ROOT_NOT_OWNED: "OE_KERNEL_ROOT_NOT_OWNED";
@@ -164,22 +175,36 @@ export declare const ContextErrorCode: {
164
175
  };
165
176
  /** Compiled-style application failures (phase `csr`). */
166
177
  export declare const StyleErrorCode: {
167
- /** The shadow root has no `adoptedStyleSheets` support. */
168
- readonly ADOPTED_STYLES_UNSUPPORTED: "OE_STYLES_ADOPTED_SHEETS_UNSUPPORTED";
169
- /** A light-DOM style sink needs an owner document with a usable head. */
170
- readonly LIGHT_SINK_WITHOUT_DOCUMENT: "OE_STYLES_LIGHT_SINK_WITHOUT_DOCUMENT";
178
+ /** The target root (shadow root or document) has no `adoptedStyleSheets` support. */
179
+ readonly ADOPTED_STYLES_UNSUPPORTED: "OE_STYLES_ADOPTED_STYLES_UNSUPPORTED";
180
+ /** A generated sheet adapter could not fill its sheet (request or replace failed). */
181
+ readonly SHEET_LOAD_FAILED: "OE_STYLES_SHEET_LOAD_FAILED";
182
+ /**
183
+ * A component stylesheet resource href is not a site-absolute path or an
184
+ * absolute http(s) URL — the one shape rule both stylesheet-link sinks (the
185
+ * document head and a DSD template) enforce.
186
+ */
187
+ readonly INVALID_STYLE_HREF: "OE_STYLES_INVALID_HREF";
188
+ /**
189
+ * A URL-less (author-owned in-memory, or shim) stylesheet's rules could not
190
+ * be read while serializing server output (phase `ssr`): the sheet is
191
+ * skipped and reported, and the renderer never invents an external URL for
192
+ * author-owned data. A cross-origin `CSSStyleSheet` handed to
193
+ * `static styles` is the reachable cause.
194
+ */
195
+ readonly SHEET_RULES_UNREADABLE: "OE_STYLES_SHEET_RULES_UNREADABLE";
171
196
  };
172
197
  /**
173
198
  * Claim failures: the existing DOM does not match the program that would own
174
199
  * it. The value shipped in 1.0.0-alpha.3 and is kept verbatim; consumers match
175
- * on it, and `PartProgramClaimError` is its only raiser.
200
+ * on it, and `PartProgramHydrationError` is its only raiser.
176
201
  */
177
202
  export declare const ClaimErrorCode: {
178
203
  /** Claimed DOM structure or node identity drifted from the compiled program. */
179
204
  readonly STRUCTURE_MISMATCH: "OPEN_ELEMENT_COMPILED_CLAIM_MISMATCH";
180
205
  /** A pre-upgrade event capture argument was neither an array nor a capture object. */
181
206
  readonly PRE_UPGRADE_EVENTS_INVALID: "OE_CLAIM_PRE_UPGRADE_EVENTS_INVALID";
182
- /** Bounded recovery met a dynamic node inside a static Region. */
207
+ /** Bounded recovery met a dynamic node inside a static Block. */
183
208
  readonly DYNAMIC_NODE_IN_STATIC_REGION: "OE_CLAIM_DYNAMIC_NODE_IN_STATIC_REGION";
184
209
  /** An each item template carries Part anchors, which cannot be rebuilt statically. */
185
210
  readonly ITEM_TEMPLATE_ANCHOR: "OE_CLAIM_ITEM_TEMPLATE_ANCHOR";
@@ -212,6 +237,19 @@ export declare const AuthoringErrorCode: {
212
237
  readonly INVALID_TAG_NAME: "OE_INVALID_TAG_NAME";
213
238
  /** A `wrapInDocument` meta entry uses an attribute name HTML forbids. */
214
239
  readonly UNSAFE_META_ATTRIBUTE: "OE_UNSAFE_META_ATTRIBUTE";
240
+ /**
241
+ * A server constructor (`__h`) attribute name is unsafe: it fails the one
242
+ * canonical safe-attribute-name predicate (event handlers and forbidden
243
+ * sinks included). The compiler-generated call sites cannot produce one —
244
+ * the runtime check is the boundary for direct helper misuse.
245
+ */
246
+ readonly UNSAFE_ATTRIBUTE_NAME: "OE_UNSAFE_ATTRIBUTE_NAME";
247
+ /**
248
+ * A URL-carrying attribute value (`href`, `src`, `action`, `formaction`,
249
+ * `xlink:href`) carries a script-bearing scheme, screened by the ONE shared
250
+ * stream-frame URL policy. The value never reaches markup.
251
+ */
252
+ readonly UNSAFE_URL_SINK: "OE_UNSAFE_URL_SINK";
215
253
  /** A `wrapInDocument` structuredData entry is not a JSON-LD document. */
216
254
  readonly INVALID_STRUCTURED_DATA: "OE_INVALID_STRUCTURED_DATA";
217
255
  /** An `html` sink received a string that was not marked trusted. */
@@ -243,6 +281,22 @@ export declare const FacadeErrorCode: {
243
281
  readonly STREAM_TYPE_MISMATCH: "OE_STREAM_TYPE_MISMATCH";
244
282
  /** An `HTMLElement` member was reached during SSR, where no DOM exists. */
245
283
  readonly SSR_DOM_ACCESS_UNSUPPORTED: "SSR_DOM_ACCESS_UNSUPPORTED";
284
+ /** A deferred shell read a pending property before it resolved. */
285
+ readonly STREAM_PENDING_READ: "OE_STREAM_PENDING_READ";
286
+ /** A deferred seed value is not JSON-safe (cyclic, bigint, or class instance). */
287
+ readonly STREAM_VALUE_NOT_SERIALIZABLE: "OE_STREAM_VALUE_NOT_SERIALIZABLE";
288
+ /** A deferred route manifest is malformed. */
289
+ readonly STREAM_MANIFEST_MALFORMED: "OE_STREAM_MANIFEST_MALFORMED";
290
+ /** A deferred route manifest does not match the compiled program. */
291
+ readonly STREAM_MANIFEST_MISMATCH: "OE_STREAM_MANIFEST_MISMATCH";
292
+ /** A reserved property name cannot enter a deferred seed. */
293
+ readonly STREAM_RESERVED_PROPERTY: "OE_STREAM_RESERVED_PROPERTY";
294
+ /** A deferred manifest or seed exceeds its bounded budget. */
295
+ readonly STREAM_BUDGET_EXCEEDED: "OE_STREAM_BUDGET_EXCEEDED";
296
+ /** A deferred field or Part owner is invalid or not deferrable. */
297
+ readonly STREAM_FIELD_INVALID: "OE_STREAM_FIELD_INVALID";
298
+ /** An unknown deferred field was resolved or serialized. */
299
+ readonly STREAM_UNKNOWN_FIELD: "OE_STREAM_UNKNOWN_FIELD";
246
300
  };
247
301
  /**
248
302
  * One framework failure: {@linkcode OpenElementError} with the caller's code
package/src/errors.js CHANGED
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * Every failure raised by this package is an {@linkcode OpenElementError}
7
7
  * carrying `code`, `severity`, `phase` and `recoverable`; the dedicated
8
- * exception classes below (`PartProgramClaimError`,
8
+ * exception classes below (`PartProgramHydrationError`,
9
9
  * `CompiledProgramValidationError`, `EachKeyError`) only ADD their own
10
10
  * provenance fields on top of that contract, so a consumer catches by code
11
11
  * through the one class.
@@ -86,7 +86,7 @@ var OpenElementError = class extends Error {
86
86
  * reject data before any DOM work starts.
87
87
  */
88
88
  const ProgramErrorCode = {
89
- /** A Part Program v1 failed structural validation. */
89
+ /** A Part Program v2 failed structural validation. */
90
90
  INVALID_PROGRAM: "OE_PROGRAM_INVALID",
91
91
  /** A Part Program cannot be serialized to JSON, so it is not a wire artifact. */
92
92
  NOT_SERIALIZABLE: "OE_PROGRAM_NOT_SERIALIZABLE",
@@ -107,7 +107,7 @@ const EachKeyErrorCode = {
107
107
  ITEM_NOT_A_RECORD: "OE_EACH_ITEM_NOT_A_RECORD",
108
108
  /** A key value cannot round-trip (an object, function or symbol has no stable identity). */
109
109
  KEY_NOT_ROUND_TRIPPABLE: "OE_EACH_KEY_NOT_ROUND_TRIPPABLE",
110
- /** Two items in one list Region derived the same key. */
110
+ /** Two items in one list Block derived the same key. */
111
111
  DUPLICATE_KEY: "OE_EACH_KEY_DUPLICATE"
112
112
  };
113
113
  /**
@@ -115,7 +115,7 @@ const EachKeyErrorCode = {
115
115
  * built into fresh DOM, or re-read on a signal write (phase `render`).
116
116
  */
117
117
  const RuntimeErrorCode = {
118
- /** A list Region's signal does not hold an array. */
118
+ /** A list Block's signal does not hold an array. */
119
119
  LIST_VALUE_NOT_ARRAY: "OE_RUNTIME_LIST_VALUE_NOT_ARRAY",
120
120
  /** render() reads a signal that is not registered on the host. */
121
121
  HOST_SIGNAL_MISSING: "OE_RUNTIME_HOST_SIGNAL_MISSING",
@@ -133,9 +133,9 @@ const RuntimeErrorCode = {
133
133
  PATH_UNRESOLVED: "OE_RUNTIME_PATH_UNRESOLVED",
134
134
  /** A compiled node path resolved to a non-element node. */
135
135
  PATH_NOT_ELEMENT: "OE_RUNTIME_PATH_NOT_ELEMENT",
136
- /** An item value/attribute slot appears outside an `each` Region. */
136
+ /** An item value/attribute slot appears outside an `each` Block. */
137
137
  ITEM_SLOT_OUTSIDE_REGION: "OE_RUNTIME_ITEM_SLOT_OUTSIDE_REGION",
138
- /** An item slot found no owning `each` Region. */
138
+ /** An item slot found no owning `each` Block. */
139
139
  ITEM_SLOT_WITHOUT_REGION: "OE_RUNTIME_ITEM_SLOT_WITHOUT_REGION",
140
140
  /** An item slot has no owner document to create nodes from. */
141
141
  ITEM_SLOT_WITHOUT_DOCUMENT: "OE_RUNTIME_ITEM_SLOT_WITHOUT_DOCUMENT",
@@ -143,10 +143,21 @@ const RuntimeErrorCode = {
143
143
  ROOT_WITHOUT_DOCUMENT: "OE_RUNTIME_ROOT_WITHOUT_DOCUMENT",
144
144
  /** Fresh-DOM creation was handed a root that is not empty. */
145
145
  FRESH_ROOT_NOT_EMPTY: "OE_RUNTIME_FRESH_ROOT_NOT_EMPTY",
146
+ /**
147
+ * `claimRecipe` was asked to claim a recipe that has no generated claim.
148
+ * This is a caller/recipe-shape failure, not a DOM mismatch.
149
+ */
150
+ LEAF_CLAIM_UNAVAILABLE: "OE_RUNTIME_LEAF_CLAIM_UNAVAILABLE",
151
+ /**
152
+ * A static sibling-range directory did not match its declaration, was
153
+ * claimed out of order, or was reclaimed after commitment. Detail lives in
154
+ * the message; cases do not each get a code. Not `LEAF_CLAIM_UNAVAILABLE`.
155
+ */
156
+ STATIC_RANGE_MISMATCH: "OE_RUNTIME_STATIC_RANGE_MISMATCH",
146
157
  /** A fixed Part has no serialized anchor to bind. */
147
158
  SERIALIZED_ANCHOR_MISSING: "OE_RUNTIME_SERIALIZED_ANCHOR_MISSING",
148
- /** A when/each Region Part needs the Region builders, which this entry does not install (#1548). */
149
- REGION_BUILDERS_MISSING: "OE_RUNTIME_REGION_BUILDERS_MISSING"
159
+ /** A when/each Block Part needs the Block builders, which this entry does not install (#1548). */
160
+ BLOCK_BUILDERS_MISSING: "OE_RUNTIME_BLOCK_BUILDERS_MISSING"
150
161
  };
151
162
  /** Element-lifecycle failures: the kernel was driven outside its contract (phase `csr`). */
152
163
  const KernelErrorCode = {
@@ -154,7 +165,7 @@ const KernelErrorCode = {
154
165
  DISPOSED: "OE_KERNEL_DISPOSED",
155
166
  /** `__partProgram.tag` does not match the host element's tag. */
156
167
  TAG_MISMATCH: "OE_KERNEL_TAG_MISMATCH",
157
- /** Existing DOM needs the claim executor, which this entry does not install. */
168
+ /** Existing DOM needs the hydration executor, which this entry does not install. */
158
169
  CLAIM_EXECUTOR_MISSING: "OE_KERNEL_CLAIM_EXECUTOR_MISSING",
159
170
  /** A supplied root is not owned by the element it was passed for. */
160
171
  ROOT_NOT_OWNED: "OE_KERNEL_ROOT_NOT_OWNED",
@@ -167,22 +178,36 @@ const ContextErrorCode = {
167
178
  SERVICE_DISPOSED: "OE_CONTEXT_SERVICE_DISPOSED" };
168
179
  /** Compiled-style application failures (phase `csr`). */
169
180
  const StyleErrorCode = {
170
- /** The shadow root has no `adoptedStyleSheets` support. */
171
- ADOPTED_STYLES_UNSUPPORTED: "OE_STYLES_ADOPTED_SHEETS_UNSUPPORTED",
172
- /** A light-DOM style sink needs an owner document with a usable head. */
173
- LIGHT_SINK_WITHOUT_DOCUMENT: "OE_STYLES_LIGHT_SINK_WITHOUT_DOCUMENT"
181
+ /** The target root (shadow root or document) has no `adoptedStyleSheets` support. */
182
+ ADOPTED_STYLES_UNSUPPORTED: "OE_STYLES_ADOPTED_STYLES_UNSUPPORTED",
183
+ /** A generated sheet adapter could not fill its sheet (request or replace failed). */
184
+ SHEET_LOAD_FAILED: "OE_STYLES_SHEET_LOAD_FAILED",
185
+ /**
186
+ * A component stylesheet resource href is not a site-absolute path or an
187
+ * absolute http(s) URL — the one shape rule both stylesheet-link sinks (the
188
+ * document head and a DSD template) enforce.
189
+ */
190
+ INVALID_STYLE_HREF: "OE_STYLES_INVALID_HREF",
191
+ /**
192
+ * A URL-less (author-owned in-memory, or shim) stylesheet's rules could not
193
+ * be read while serializing server output (phase `ssr`): the sheet is
194
+ * skipped and reported, and the renderer never invents an external URL for
195
+ * author-owned data. A cross-origin `CSSStyleSheet` handed to
196
+ * `static styles` is the reachable cause.
197
+ */
198
+ SHEET_RULES_UNREADABLE: "OE_STYLES_SHEET_RULES_UNREADABLE"
174
199
  };
175
200
  /**
176
201
  * Claim failures: the existing DOM does not match the program that would own
177
202
  * it. The value shipped in 1.0.0-alpha.3 and is kept verbatim; consumers match
178
- * on it, and `PartProgramClaimError` is its only raiser.
203
+ * on it, and `PartProgramHydrationError` is its only raiser.
179
204
  */
180
205
  const ClaimErrorCode = {
181
206
  /** Claimed DOM structure or node identity drifted from the compiled program. */
182
207
  STRUCTURE_MISMATCH: "OPEN_ELEMENT_COMPILED_CLAIM_MISMATCH",
183
208
  /** A pre-upgrade event capture argument was neither an array nor a capture object. */
184
209
  PRE_UPGRADE_EVENTS_INVALID: "OE_CLAIM_PRE_UPGRADE_EVENTS_INVALID",
185
- /** Bounded recovery met a dynamic node inside a static Region. */
210
+ /** Bounded recovery met a dynamic node inside a static Block. */
186
211
  DYNAMIC_NODE_IN_STATIC_REGION: "OE_CLAIM_DYNAMIC_NODE_IN_STATIC_REGION",
187
212
  /** An each item template carries Part anchors, which cannot be rebuilt statically. */
188
213
  ITEM_TEMPLATE_ANCHOR: "OE_CLAIM_ITEM_TEMPLATE_ANCHOR"
@@ -215,6 +240,19 @@ const AuthoringErrorCode = {
215
240
  INVALID_TAG_NAME: "OE_INVALID_TAG_NAME",
216
241
  /** A `wrapInDocument` meta entry uses an attribute name HTML forbids. */
217
242
  UNSAFE_META_ATTRIBUTE: "OE_UNSAFE_META_ATTRIBUTE",
243
+ /**
244
+ * A server constructor (`__h`) attribute name is unsafe: it fails the one
245
+ * canonical safe-attribute-name predicate (event handlers and forbidden
246
+ * sinks included). The compiler-generated call sites cannot produce one —
247
+ * the runtime check is the boundary for direct helper misuse.
248
+ */
249
+ UNSAFE_ATTRIBUTE_NAME: "OE_UNSAFE_ATTRIBUTE_NAME",
250
+ /**
251
+ * A URL-carrying attribute value (`href`, `src`, `action`, `formaction`,
252
+ * `xlink:href`) carries a script-bearing scheme, screened by the ONE shared
253
+ * stream-frame URL policy. The value never reaches markup.
254
+ */
255
+ UNSAFE_URL_SINK: "OE_UNSAFE_URL_SINK",
218
256
  /** A `wrapInDocument` structuredData entry is not a JSON-LD document. */
219
257
  INVALID_STRUCTURED_DATA: "OE_INVALID_STRUCTURED_DATA",
220
258
  /** An `html` sink received a string that was not marked trusted. */
@@ -245,7 +283,23 @@ const FacadeErrorCode = {
245
283
  /** A streamed seed property's type disagrees with the compiled property record. */
246
284
  STREAM_TYPE_MISMATCH: "OE_STREAM_TYPE_MISMATCH",
247
285
  /** An `HTMLElement` member was reached during SSR, where no DOM exists. */
248
- SSR_DOM_ACCESS_UNSUPPORTED: "SSR_DOM_ACCESS_UNSUPPORTED"
286
+ SSR_DOM_ACCESS_UNSUPPORTED: "SSR_DOM_ACCESS_UNSUPPORTED",
287
+ /** A deferred shell read a pending property before it resolved. */
288
+ STREAM_PENDING_READ: "OE_STREAM_PENDING_READ",
289
+ /** A deferred seed value is not JSON-safe (cyclic, bigint, or class instance). */
290
+ STREAM_VALUE_NOT_SERIALIZABLE: "OE_STREAM_VALUE_NOT_SERIALIZABLE",
291
+ /** A deferred route manifest is malformed. */
292
+ STREAM_MANIFEST_MALFORMED: "OE_STREAM_MANIFEST_MALFORMED",
293
+ /** A deferred route manifest does not match the compiled program. */
294
+ STREAM_MANIFEST_MISMATCH: "OE_STREAM_MANIFEST_MISMATCH",
295
+ /** A reserved property name cannot enter a deferred seed. */
296
+ STREAM_RESERVED_PROPERTY: "OE_STREAM_RESERVED_PROPERTY",
297
+ /** A deferred manifest or seed exceeds its bounded budget. */
298
+ STREAM_BUDGET_EXCEEDED: "OE_STREAM_BUDGET_EXCEEDED",
299
+ /** A deferred field or Part owner is invalid or not deferrable. */
300
+ STREAM_FIELD_INVALID: "OE_STREAM_FIELD_INVALID",
301
+ /** An unknown deferred field was resolved or serialized. */
302
+ STREAM_UNKNOWN_FIELD: "OE_STREAM_UNKNOWN_FIELD"
249
303
  };
250
304
  /**
251
305
  * One framework failure: {@linkcode OpenElementError} with the caller's code
@@ -50,7 +50,7 @@ function forbiddenSinkReason(kind, name) {
50
50
  if (FORBIDDEN_PROPERTY_NAMES.has(name.toLowerCase())) return `unsafe property sink name ${JSON.stringify(name)}`;
51
51
  return null;
52
52
  case "tag":
53
- if (RAW_TEXT_TAGS.has(name)) return `raw-text element <${name}> is outside the compiled Part Program grammar`;
53
+ if (RAW_TEXT_TAGS.has(name.toLowerCase())) return `raw-text element <${name}> is outside the compiled Part Program grammar`;
54
54
  return null;
55
55
  default: return `unknown sink kind ${JSON.stringify(String(kind))}`;
56
56
  }