@openelement/protocol 1.0.0-alpha.13 → 1.0.0-alpha.15

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
@@ -14,22 +14,23 @@ into the others' graphs.
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. |
30
31
  | `@openelement/protocol/signal` | Signal contracts (`Signal`, `ReadonlySignal`, brands). |
31
32
  | `@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. |
33
+ | `@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
34
  | `@openelement/protocol/style-sheet` | The cross-environment `StyleSheet` abstraction contract. |
34
35
  | `@openelement/protocol/void-tags` | The one canonical HTML void-element set for every serializer, validator, and compiler (#1220). |
35
36
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openelement/protocol",
3
- "version": "1.0.0-alpha.13",
3
+ "version": "1.0.0-alpha.15",
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",
@@ -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,110 @@
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
+ return {
89
+ format: record.format,
90
+ ok: record.ok,
91
+ diagnostics
92
+ };
93
+ }
94
+ /**
95
+ * Map the one error dialect ({@linkcode OpenElementError} — every producer's
96
+ * raiser goes through it) onto the envelope. The error's code, severity and
97
+ * phase ARE the envelope's; the message carries verbatim. Producers with a
98
+ * fix pass it as `hint`.
99
+ */
100
+ function errorToEnvelope(error, options = {}) {
101
+ return {
102
+ code: error.code,
103
+ severity: error.severity,
104
+ phase: error.phase,
105
+ message: error.message,
106
+ ...options.hint !== void 0 ? { hint: options.hint } : {}
107
+ };
108
+ }
109
+ //#endregion
110
+ 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";
@@ -141,8 +141,8 @@ export declare const RuntimeErrorCode: {
141
141
  readonly FRESH_ROOT_NOT_EMPTY: "OE_RUNTIME_FRESH_ROOT_NOT_EMPTY";
142
142
  /** A fixed Part has no serialized anchor to bind. */
143
143
  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";
144
+ /** A when/each Block Part needs the Block builders, which this entry does not install (#1548). */
145
+ readonly BLOCK_BUILDERS_MISSING: "OE_RUNTIME_BLOCK_BUILDERS_MISSING";
146
146
  };
147
147
  /** Element-lifecycle failures: the kernel was driven outside its contract (phase `csr`). */
148
148
  export declare const KernelErrorCode: {
@@ -150,7 +150,7 @@ export declare const KernelErrorCode: {
150
150
  readonly DISPOSED: "OE_KERNEL_DISPOSED";
151
151
  /** `__partProgram.tag` does not match the host element's tag. */
152
152
  readonly TAG_MISMATCH: "OE_KERNEL_TAG_MISMATCH";
153
- /** Existing DOM needs the claim executor, which this entry does not install. */
153
+ /** Existing DOM needs the hydration executor, which this entry does not install. */
154
154
  readonly CLAIM_EXECUTOR_MISSING: "OE_KERNEL_CLAIM_EXECUTOR_MISSING";
155
155
  /** A supplied root is not owned by the element it was passed for. */
156
156
  readonly ROOT_NOT_OWNED: "OE_KERNEL_ROOT_NOT_OWNED";
@@ -164,22 +164,36 @@ export declare const ContextErrorCode: {
164
164
  };
165
165
  /** Compiled-style application failures (phase `csr`). */
166
166
  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";
167
+ /** The target root (shadow root or document) has no `adoptedStyleSheets` support. */
168
+ readonly ADOPTED_STYLES_UNSUPPORTED: "OE_STYLES_ADOPTED_STYLES_UNSUPPORTED";
169
+ /** A generated sheet adapter could not fill its sheet (request or replace failed). */
170
+ readonly SHEET_LOAD_FAILED: "OE_STYLES_SHEET_LOAD_FAILED";
171
+ /**
172
+ * A component stylesheet resource href is not a site-absolute path or an
173
+ * absolute http(s) URL — the one shape rule both stylesheet-link sinks (the
174
+ * document head and a DSD template) enforce.
175
+ */
176
+ readonly INVALID_STYLE_HREF: "OE_STYLES_INVALID_HREF";
177
+ /**
178
+ * A URL-less (author-owned in-memory, or shim) stylesheet's rules could not
179
+ * be read while serializing server output (phase `ssr`): the sheet is
180
+ * skipped and reported, and the renderer never invents an external URL for
181
+ * author-owned data. A cross-origin `CSSStyleSheet` handed to
182
+ * `static styles` is the reachable cause.
183
+ */
184
+ readonly SHEET_RULES_UNREADABLE: "OE_STYLES_SHEET_RULES_UNREADABLE";
171
185
  };
172
186
  /**
173
187
  * Claim failures: the existing DOM does not match the program that would own
174
188
  * 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.
189
+ * on it, and `PartProgramHydrationError` is its only raiser.
176
190
  */
177
191
  export declare const ClaimErrorCode: {
178
192
  /** Claimed DOM structure or node identity drifted from the compiled program. */
179
193
  readonly STRUCTURE_MISMATCH: "OPEN_ELEMENT_COMPILED_CLAIM_MISMATCH";
180
194
  /** A pre-upgrade event capture argument was neither an array nor a capture object. */
181
195
  readonly PRE_UPGRADE_EVENTS_INVALID: "OE_CLAIM_PRE_UPGRADE_EVENTS_INVALID";
182
- /** Bounded recovery met a dynamic node inside a static Region. */
196
+ /** Bounded recovery met a dynamic node inside a static Block. */
183
197
  readonly DYNAMIC_NODE_IN_STATIC_REGION: "OE_CLAIM_DYNAMIC_NODE_IN_STATIC_REGION";
184
198
  /** An each item template carries Part anchors, which cannot be rebuilt statically. */
185
199
  readonly ITEM_TEMPLATE_ANCHOR: "OE_CLAIM_ITEM_TEMPLATE_ANCHOR";
@@ -212,6 +226,19 @@ export declare const AuthoringErrorCode: {
212
226
  readonly INVALID_TAG_NAME: "OE_INVALID_TAG_NAME";
213
227
  /** A `wrapInDocument` meta entry uses an attribute name HTML forbids. */
214
228
  readonly UNSAFE_META_ATTRIBUTE: "OE_UNSAFE_META_ATTRIBUTE";
229
+ /**
230
+ * A server constructor (`__h`) attribute name is unsafe: it fails the one
231
+ * canonical safe-attribute-name predicate (event handlers and forbidden
232
+ * sinks included). The compiler-generated call sites cannot produce one —
233
+ * the runtime check is the boundary for direct helper misuse.
234
+ */
235
+ readonly UNSAFE_ATTRIBUTE_NAME: "OE_UNSAFE_ATTRIBUTE_NAME";
236
+ /**
237
+ * A URL-carrying attribute value (`href`, `src`, `action`, `formaction`,
238
+ * `xlink:href`) carries a script-bearing scheme, screened by the ONE shared
239
+ * stream-frame URL policy. The value never reaches markup.
240
+ */
241
+ readonly UNSAFE_URL_SINK: "OE_UNSAFE_URL_SINK";
215
242
  /** A `wrapInDocument` structuredData entry is not a JSON-LD document. */
216
243
  readonly INVALID_STRUCTURED_DATA: "OE_INVALID_STRUCTURED_DATA";
217
244
  /** An `html` sink received a string that was not marked trusted. */
@@ -243,6 +270,22 @@ export declare const FacadeErrorCode: {
243
270
  readonly STREAM_TYPE_MISMATCH: "OE_STREAM_TYPE_MISMATCH";
244
271
  /** An `HTMLElement` member was reached during SSR, where no DOM exists. */
245
272
  readonly SSR_DOM_ACCESS_UNSUPPORTED: "SSR_DOM_ACCESS_UNSUPPORTED";
273
+ /** A deferred shell read a pending property before it resolved. */
274
+ readonly STREAM_PENDING_READ: "OE_STREAM_PENDING_READ";
275
+ /** A deferred seed value is not JSON-safe (cyclic, bigint, or class instance). */
276
+ readonly STREAM_VALUE_NOT_SERIALIZABLE: "OE_STREAM_VALUE_NOT_SERIALIZABLE";
277
+ /** A deferred route manifest is malformed. */
278
+ readonly STREAM_MANIFEST_MALFORMED: "OE_STREAM_MANIFEST_MALFORMED";
279
+ /** A deferred route manifest does not match the compiled program. */
280
+ readonly STREAM_MANIFEST_MISMATCH: "OE_STREAM_MANIFEST_MISMATCH";
281
+ /** A reserved property name cannot enter a deferred seed. */
282
+ readonly STREAM_RESERVED_PROPERTY: "OE_STREAM_RESERVED_PROPERTY";
283
+ /** A deferred manifest or seed exceeds its bounded budget. */
284
+ readonly STREAM_BUDGET_EXCEEDED: "OE_STREAM_BUDGET_EXCEEDED";
285
+ /** A deferred field or Part owner is invalid or not deferrable. */
286
+ readonly STREAM_FIELD_INVALID: "OE_STREAM_FIELD_INVALID";
287
+ /** An unknown deferred field was resolved or serialized. */
288
+ readonly STREAM_UNKNOWN_FIELD: "OE_STREAM_UNKNOWN_FIELD";
246
289
  };
247
290
  /**
248
291
  * 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",
@@ -145,8 +145,8 @@ const RuntimeErrorCode = {
145
145
  FRESH_ROOT_NOT_EMPTY: "OE_RUNTIME_FRESH_ROOT_NOT_EMPTY",
146
146
  /** A fixed Part has no serialized anchor to bind. */
147
147
  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"
148
+ /** A when/each Block Part needs the Block builders, which this entry does not install (#1548). */
149
+ BLOCK_BUILDERS_MISSING: "OE_RUNTIME_BLOCK_BUILDERS_MISSING"
150
150
  };
151
151
  /** Element-lifecycle failures: the kernel was driven outside its contract (phase `csr`). */
152
152
  const KernelErrorCode = {
@@ -154,7 +154,7 @@ const KernelErrorCode = {
154
154
  DISPOSED: "OE_KERNEL_DISPOSED",
155
155
  /** `__partProgram.tag` does not match the host element's tag. */
156
156
  TAG_MISMATCH: "OE_KERNEL_TAG_MISMATCH",
157
- /** Existing DOM needs the claim executor, which this entry does not install. */
157
+ /** Existing DOM needs the hydration executor, which this entry does not install. */
158
158
  CLAIM_EXECUTOR_MISSING: "OE_KERNEL_CLAIM_EXECUTOR_MISSING",
159
159
  /** A supplied root is not owned by the element it was passed for. */
160
160
  ROOT_NOT_OWNED: "OE_KERNEL_ROOT_NOT_OWNED",
@@ -167,22 +167,36 @@ const ContextErrorCode = {
167
167
  SERVICE_DISPOSED: "OE_CONTEXT_SERVICE_DISPOSED" };
168
168
  /** Compiled-style application failures (phase `csr`). */
169
169
  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"
170
+ /** The target root (shadow root or document) has no `adoptedStyleSheets` support. */
171
+ ADOPTED_STYLES_UNSUPPORTED: "OE_STYLES_ADOPTED_STYLES_UNSUPPORTED",
172
+ /** A generated sheet adapter could not fill its sheet (request or replace failed). */
173
+ SHEET_LOAD_FAILED: "OE_STYLES_SHEET_LOAD_FAILED",
174
+ /**
175
+ * A component stylesheet resource href is not a site-absolute path or an
176
+ * absolute http(s) URL — the one shape rule both stylesheet-link sinks (the
177
+ * document head and a DSD template) enforce.
178
+ */
179
+ INVALID_STYLE_HREF: "OE_STYLES_INVALID_HREF",
180
+ /**
181
+ * A URL-less (author-owned in-memory, or shim) stylesheet's rules could not
182
+ * be read while serializing server output (phase `ssr`): the sheet is
183
+ * skipped and reported, and the renderer never invents an external URL for
184
+ * author-owned data. A cross-origin `CSSStyleSheet` handed to
185
+ * `static styles` is the reachable cause.
186
+ */
187
+ SHEET_RULES_UNREADABLE: "OE_STYLES_SHEET_RULES_UNREADABLE"
174
188
  };
175
189
  /**
176
190
  * Claim failures: the existing DOM does not match the program that would own
177
191
  * 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.
192
+ * on it, and `PartProgramHydrationError` is its only raiser.
179
193
  */
180
194
  const ClaimErrorCode = {
181
195
  /** Claimed DOM structure or node identity drifted from the compiled program. */
182
196
  STRUCTURE_MISMATCH: "OPEN_ELEMENT_COMPILED_CLAIM_MISMATCH",
183
197
  /** A pre-upgrade event capture argument was neither an array nor a capture object. */
184
198
  PRE_UPGRADE_EVENTS_INVALID: "OE_CLAIM_PRE_UPGRADE_EVENTS_INVALID",
185
- /** Bounded recovery met a dynamic node inside a static Region. */
199
+ /** Bounded recovery met a dynamic node inside a static Block. */
186
200
  DYNAMIC_NODE_IN_STATIC_REGION: "OE_CLAIM_DYNAMIC_NODE_IN_STATIC_REGION",
187
201
  /** An each item template carries Part anchors, which cannot be rebuilt statically. */
188
202
  ITEM_TEMPLATE_ANCHOR: "OE_CLAIM_ITEM_TEMPLATE_ANCHOR"
@@ -215,6 +229,19 @@ const AuthoringErrorCode = {
215
229
  INVALID_TAG_NAME: "OE_INVALID_TAG_NAME",
216
230
  /** A `wrapInDocument` meta entry uses an attribute name HTML forbids. */
217
231
  UNSAFE_META_ATTRIBUTE: "OE_UNSAFE_META_ATTRIBUTE",
232
+ /**
233
+ * A server constructor (`__h`) attribute name is unsafe: it fails the one
234
+ * canonical safe-attribute-name predicate (event handlers and forbidden
235
+ * sinks included). The compiler-generated call sites cannot produce one —
236
+ * the runtime check is the boundary for direct helper misuse.
237
+ */
238
+ UNSAFE_ATTRIBUTE_NAME: "OE_UNSAFE_ATTRIBUTE_NAME",
239
+ /**
240
+ * A URL-carrying attribute value (`href`, `src`, `action`, `formaction`,
241
+ * `xlink:href`) carries a script-bearing scheme, screened by the ONE shared
242
+ * stream-frame URL policy. The value never reaches markup.
243
+ */
244
+ UNSAFE_URL_SINK: "OE_UNSAFE_URL_SINK",
218
245
  /** A `wrapInDocument` structuredData entry is not a JSON-LD document. */
219
246
  INVALID_STRUCTURED_DATA: "OE_INVALID_STRUCTURED_DATA",
220
247
  /** An `html` sink received a string that was not marked trusted. */
@@ -245,7 +272,23 @@ const FacadeErrorCode = {
245
272
  /** A streamed seed property's type disagrees with the compiled property record. */
246
273
  STREAM_TYPE_MISMATCH: "OE_STREAM_TYPE_MISMATCH",
247
274
  /** An `HTMLElement` member was reached during SSR, where no DOM exists. */
248
- SSR_DOM_ACCESS_UNSUPPORTED: "SSR_DOM_ACCESS_UNSUPPORTED"
275
+ SSR_DOM_ACCESS_UNSUPPORTED: "SSR_DOM_ACCESS_UNSUPPORTED",
276
+ /** A deferred shell read a pending property before it resolved. */
277
+ STREAM_PENDING_READ: "OE_STREAM_PENDING_READ",
278
+ /** A deferred seed value is not JSON-safe (cyclic, bigint, or class instance). */
279
+ STREAM_VALUE_NOT_SERIALIZABLE: "OE_STREAM_VALUE_NOT_SERIALIZABLE",
280
+ /** A deferred route manifest is malformed. */
281
+ STREAM_MANIFEST_MALFORMED: "OE_STREAM_MANIFEST_MALFORMED",
282
+ /** A deferred route manifest does not match the compiled program. */
283
+ STREAM_MANIFEST_MISMATCH: "OE_STREAM_MANIFEST_MISMATCH",
284
+ /** A reserved property name cannot enter a deferred seed. */
285
+ STREAM_RESERVED_PROPERTY: "OE_STREAM_RESERVED_PROPERTY",
286
+ /** A deferred manifest or seed exceeds its bounded budget. */
287
+ STREAM_BUDGET_EXCEEDED: "OE_STREAM_BUDGET_EXCEEDED",
288
+ /** A deferred field or Part owner is invalid or not deferrable. */
289
+ STREAM_FIELD_INVALID: "OE_STREAM_FIELD_INVALID",
290
+ /** An unknown deferred field was resolved or serialized. */
291
+ STREAM_UNKNOWN_FIELD: "OE_STREAM_UNKNOWN_FIELD"
249
292
  };
250
293
  /**
251
294
  * 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
  }