@openelement/protocol 0.41.0-beta.3 → 1.0.0-alpha.11
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/LICENSE +21 -0
- package/README.md +42 -0
- package/package.json +90 -51
- package/src/app-model.d.ts +19 -0
- package/src/app-model.js +1 -0
- package/src/client-assets.d.ts +44 -0
- package/src/client-assets.js +24 -0
- package/src/data.d.ts +81 -11
- package/src/data.js +11 -7
- package/src/errors.d.ts +253 -14
- package/src/errors.js +275 -15
- package/src/forbidden-sinks.d.ts +60 -0
- package/src/forbidden-sinks.js +81 -0
- package/src/framework.d.ts +183 -99
- package/src/framework.js +13 -5
- package/src/index.d.ts +21 -19
- package/src/index.js +21 -20
- package/src/island-admission.d.ts +5 -0
- package/src/island-admission.js +9 -0
- package/src/island.d.ts +32 -19
- package/src/island.js +1 -4
- package/src/manifest.d.ts +15 -27
- package/src/manifest.js +1 -4
- package/src/module-descriptors.d.ts +40 -0
- package/src/module-descriptors.js +1 -0
- package/src/module-vocabulary.d.ts +5 -0
- package/src/module-vocabulary.js +21 -0
- package/src/part-program.d.ts +407 -0
- package/src/part-program.js +758 -0
- package/src/policy.d.ts +64 -0
- package/src/policy.js +65 -0
- package/src/registry-markers.d.ts +39 -0
- package/src/registry-markers.js +40 -0
- package/src/render.d.ts +29 -123
- package/src/render.js +1 -7
- package/src/runtime.d.ts +13 -4
- package/src/runtime.js +1 -8
- package/src/signal.d.ts +31 -7
- package/src/signal.js +5 -6
- package/src/ssg.d.ts +317 -151
- package/src/ssg.js +1 -7
- package/src/stream-frame-policy.d.ts +49 -0
- package/src/stream-frame-policy.js +108 -0
- package/src/style-sheet.d.ts +5 -1
- package/src/style-sheet.js +1 -8
- package/src/void-tags.d.ts +18 -0
- package/src/void-tags.js +34 -0
- package/src/context.d.ts +0 -25
- package/src/context.js +0 -7
- package/src/hydration-markers.d.ts +0 -25
- package/src/hydration-markers.js +0 -26
- package/src/isr.d.ts +0 -30
- package/src/isr.js +0 -4
- package/src/prop.d.ts +0 -46
- package/src/prop.js +0 -6
- package/src/vnode.d.ts +0 -19
- package/src/vnode.js +0 -9
package/src/errors.d.ts
CHANGED
|
@@ -1,23 +1,262 @@
|
|
|
1
|
+
//#region src/errors.d.ts
|
|
1
2
|
/**
|
|
2
|
-
*
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
3
|
+
* errors.ts — the single declaration site of the openElement error contract
|
|
4
|
+
* (#1386 item 3).
|
|
5
|
+
*
|
|
6
|
+
* Every failure raised by this package is an {@linkcode OpenElementError}
|
|
7
|
+
* carrying `code`, `severity`, `phase` and `recoverable`; the dedicated
|
|
8
|
+
* exception classes below (`PartProgramClaimError`,
|
|
9
|
+
* `CompiledProgramValidationError`, `EachKeyError`) only ADD their own
|
|
10
|
+
* provenance fields on top of that contract, so a consumer catches by code
|
|
11
|
+
* through the one class.
|
|
12
|
+
*
|
|
13
|
+
* The class lives here, not in `../core/errors.ts`, because this module is
|
|
14
|
+
* import-free: the semantic core and the canonical Part Program protocol may
|
|
15
|
+
* import it without gaining host, bundler, or mutable module state, and
|
|
16
|
+
* `../core/errors.ts` re-exports it for the rest of the package.
|
|
17
|
+
*
|
|
18
|
+
* ## Code families
|
|
19
|
+
*
|
|
20
|
+
* `ErrorCode` is the legacy documented set that the documentation site's error
|
|
21
|
+
* catalog reads by name (the generated error-code and error-reference pages).
|
|
22
|
+
* The `*ErrorCode` tables below are the completed dialect's catalogue, one
|
|
23
|
+
* table per failure surface — the shape `@openelement/router` already uses in
|
|
24
|
+
* `src/internal/error-codes.ts`. Codes are stable: `OPEN_ELEMENT_COMPILED_*`
|
|
25
|
+
* values shipped in 1.0.0-alpha.3 and are kept verbatim so a consumer matching
|
|
26
|
+
* on them keeps working; every new code uses the `OE_` prefix.
|
|
27
|
+
*/
|
|
28
|
+
/** Well-known error code constants for reference. String values are always accepted. */
|
|
29
|
+
export declare const ErrorCode: {
|
|
30
|
+
readonly SSR_RENDER_ERROR: "SSR_RENDER_ERROR";
|
|
31
|
+
readonly BOUNDARY_CAUGHT: "BOUNDARY_CAUGHT";
|
|
32
|
+
readonly UNKNOWN: "UNKNOWN";
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Default code for {@linkcode RenderError}. Deliberately NOT a member of
|
|
36
|
+
* {@linkcode ErrorCode}: that object is the scan target of the documentation
|
|
37
|
+
* site's error catalog, which requires every member to carry a phase/severity
|
|
38
|
+
* family rule. `RENDER_ERROR` is the pre-dialect
|
|
39
|
+
* value `RenderError` has always defaulted to — kept verbatim so callers that
|
|
40
|
+
* observe it keep working, and kept out of the catalogue because it is not a
|
|
41
|
+
* failure this package classifies, only a constructor default a caller may
|
|
42
|
+
* override.
|
|
43
|
+
*/
|
|
44
|
+
export declare const DEFAULT_RENDER_ERROR_CODE = "RENDER_ERROR";
|
|
45
|
+
/** Error message prefix for all openElement errors. */
|
|
46
|
+
export declare const ERROR_PREFIX = "[openElement]";
|
|
47
|
+
/**
|
|
48
|
+
* Whether the authored error prose is kept: `true` everywhere except a
|
|
49
|
+
* production client build, the one context that defines
|
|
50
|
+
* `OE_RUNTIME_MESSAGES` to `false`. Stripping is a payload decision, so it
|
|
51
|
+
* belongs to the browser bundle only — server-side failures keep their prose.
|
|
52
|
+
*/
|
|
53
|
+
export declare const RUNTIME_MESSAGES_ENABLED: boolean;
|
|
54
|
+
/** How severe a framework error is. */
|
|
15
55
|
export type ErrorSeverity = 'error' | 'warning';
|
|
56
|
+
/** The pipeline phase an error was raised in. */
|
|
16
57
|
export type ErrorPhase = 'render' | 'ssr' | 'csr' | 'build' | 'navigation' | 'validation' | 'unknown';
|
|
17
|
-
/**
|
|
58
|
+
/** Constructor options for {@linkcode OpenElementError}; every field is defaulted. */
|
|
59
|
+
export interface OpenElementErrorOptions {
|
|
60
|
+
cause?: Error;
|
|
61
|
+
code?: string;
|
|
62
|
+
statusCode?: number;
|
|
63
|
+
severity?: ErrorSeverity;
|
|
64
|
+
phase?: ErrorPhase;
|
|
65
|
+
recoverable?: boolean;
|
|
66
|
+
}
|
|
67
|
+
/** Framework error carrying a stable code, severity, phase and recoverability contract. */
|
|
68
|
+
export declare class OpenElementError extends Error {
|
|
18
69
|
readonly code: string;
|
|
19
70
|
readonly severity: ErrorSeverity;
|
|
20
71
|
readonly phase: ErrorPhase;
|
|
21
72
|
readonly recoverable: boolean;
|
|
73
|
+
readonly statusCode?: number;
|
|
74
|
+
constructor(message: string, options?: OpenElementErrorOptions);
|
|
75
|
+
toJSON(): Record<string, unknown>;
|
|
22
76
|
}
|
|
77
|
+
/** Callback receiving every reported {@linkcode OpenElementError} for telemetry. */
|
|
23
78
|
export type ErrorTelemetryHook = (error: OpenElementError) => void;
|
|
79
|
+
/**
|
|
80
|
+
* Program-shape failures: a Part Program (or one of its records) is malformed,
|
|
81
|
+
* or carries a value the wire format cannot express. Phase `validation`: these
|
|
82
|
+
* reject data before any DOM work starts.
|
|
83
|
+
*/
|
|
84
|
+
export declare const ProgramErrorCode: {
|
|
85
|
+
/** A Part Program v1 failed structural validation. */
|
|
86
|
+
readonly INVALID_PROGRAM: "OE_PROGRAM_INVALID";
|
|
87
|
+
/** A Part Program cannot be serialized to JSON, so it is not a wire artifact. */
|
|
88
|
+
readonly NOT_SERIALIZABLE: "OE_PROGRAM_NOT_SERIALIZABLE";
|
|
89
|
+
/** A compiled server/claim slot names a field the contract does not define. */
|
|
90
|
+
readonly INVALID_SLOT: "OE_PROGRAM_INVALID_SLOT";
|
|
91
|
+
/** A source-map segment carries a non-integer or out-of-range position. */
|
|
92
|
+
readonly INVALID_SOURCE_SEGMENT: "OE_PROGRAM_INVALID_SOURCE_SEGMENT";
|
|
93
|
+
/** A `when` test carries a threshold that is not a numeric literal. */
|
|
94
|
+
readonly NON_NUMERIC_CONDITION: "OE_PROGRAM_NON_NUMERIC_CONDITION";
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Keyed-list identity failures. Shared by the server serializer and the client
|
|
98
|
+
* runtime (see `internal/compiled/each-key.ts`), so both executors reject the
|
|
99
|
+
* same data with the same code.
|
|
100
|
+
*/
|
|
101
|
+
export declare const EachKeyErrorCode: {
|
|
102
|
+
/** A keyed list item is not an object carrying the declared key field. */
|
|
103
|
+
readonly ITEM_NOT_A_RECORD: "OE_EACH_ITEM_NOT_A_RECORD";
|
|
104
|
+
/** A key value cannot round-trip (an object, function or symbol has no stable identity). */
|
|
105
|
+
readonly KEY_NOT_ROUND_TRIPPABLE: "OE_EACH_KEY_NOT_ROUND_TRIPPABLE";
|
|
106
|
+
/** Two items in one list Region derived the same key. */
|
|
107
|
+
readonly DUPLICATE_KEY: "OE_EACH_KEY_DUPLICATE";
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* Runtime execution failures raised while a compiled program is serialized,
|
|
111
|
+
* built into fresh DOM, or re-read on a signal write (phase `render`).
|
|
112
|
+
*/
|
|
113
|
+
export declare const RuntimeErrorCode: {
|
|
114
|
+
/** A list Region's signal does not hold an array. */
|
|
115
|
+
readonly LIST_VALUE_NOT_ARRAY: "OE_RUNTIME_LIST_VALUE_NOT_ARRAY";
|
|
116
|
+
/** render() reads a signal that is not registered on the host. */
|
|
117
|
+
readonly HOST_SIGNAL_MISSING: "OE_RUNTIME_HOST_SIGNAL_MISSING";
|
|
118
|
+
/** An event Part names a handler the host does not provide. */
|
|
119
|
+
readonly HOST_HANDLER_MISSING: "OE_RUNTIME_HOST_HANDLER_MISSING";
|
|
120
|
+
/** A ref Part names a ref the host does not provide. */
|
|
121
|
+
readonly HOST_REF_MISSING: "OE_RUNTIME_HOST_REF_MISSING";
|
|
122
|
+
/** A signal's `subscribe` returned something that is not an unsubscribe function. */
|
|
123
|
+
readonly SUBSCRIPTION_INVALID: "OE_RUNTIME_SUBSCRIPTION_INVALID";
|
|
124
|
+
/** A Part index in the program has no Part record. */
|
|
125
|
+
readonly PART_MISSING: "OE_RUNTIME_PART_MISSING";
|
|
126
|
+
/** A fixed Part was used where a dynamic anchor is required. */
|
|
127
|
+
readonly FIXED_PART_AS_ANCHOR: "OE_RUNTIME_FIXED_PART_AS_ANCHOR";
|
|
128
|
+
/** A compiled node path does not resolve in the DOM. */
|
|
129
|
+
readonly PATH_UNRESOLVED: "OE_RUNTIME_PATH_UNRESOLVED";
|
|
130
|
+
/** A compiled node path resolved to a non-element node. */
|
|
131
|
+
readonly PATH_NOT_ELEMENT: "OE_RUNTIME_PATH_NOT_ELEMENT";
|
|
132
|
+
/** An item value/attribute slot appears outside an `each` Region. */
|
|
133
|
+
readonly ITEM_SLOT_OUTSIDE_REGION: "OE_RUNTIME_ITEM_SLOT_OUTSIDE_REGION";
|
|
134
|
+
/** An item slot found no owning `each` Region. */
|
|
135
|
+
readonly ITEM_SLOT_WITHOUT_REGION: "OE_RUNTIME_ITEM_SLOT_WITHOUT_REGION";
|
|
136
|
+
/** An item slot has no owner document to create nodes from. */
|
|
137
|
+
readonly ITEM_SLOT_WITHOUT_DOCUMENT: "OE_RUNTIME_ITEM_SLOT_WITHOUT_DOCUMENT";
|
|
138
|
+
/** The mount root has no ownerDocument. */
|
|
139
|
+
readonly ROOT_WITHOUT_DOCUMENT: "OE_RUNTIME_ROOT_WITHOUT_DOCUMENT";
|
|
140
|
+
/** Fresh-DOM creation was handed a root that is not empty. */
|
|
141
|
+
readonly FRESH_ROOT_NOT_EMPTY: "OE_RUNTIME_FRESH_ROOT_NOT_EMPTY";
|
|
142
|
+
/** A fixed Part has no serialized anchor to bind. */
|
|
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";
|
|
146
|
+
};
|
|
147
|
+
/** Element-lifecycle failures: the kernel was driven outside its contract (phase `csr`). */
|
|
148
|
+
export declare const KernelErrorCode: {
|
|
149
|
+
/** The kernel was used after `destroy()`. */
|
|
150
|
+
readonly DISPOSED: "OE_KERNEL_DISPOSED";
|
|
151
|
+
/** `__partProgram.tag` does not match the host element's tag. */
|
|
152
|
+
readonly TAG_MISMATCH: "OE_KERNEL_TAG_MISMATCH";
|
|
153
|
+
/** Existing DOM needs the claim executor, which this entry does not install. */
|
|
154
|
+
readonly CLAIM_EXECUTOR_MISSING: "OE_KERNEL_CLAIM_EXECUTOR_MISSING";
|
|
155
|
+
/** A supplied root is not owned by the element it was passed for. */
|
|
156
|
+
readonly ROOT_NOT_OWNED: "OE_KERNEL_ROOT_NOT_OWNED";
|
|
157
|
+
/** The requested root mode needs `attachShadow()`, which the host lacks. */
|
|
158
|
+
readonly ATTACH_SHADOW_REQUIRED: "OE_KERNEL_ATTACH_SHADOW_REQUIRED";
|
|
159
|
+
};
|
|
160
|
+
/** Community-context service lifecycle failures (phase `csr`). */
|
|
161
|
+
export declare const ContextErrorCode: {
|
|
162
|
+
/** The compiled element's context service was used after disconnect disposal. */
|
|
163
|
+
readonly SERVICE_DISPOSED: "OE_CONTEXT_SERVICE_DISPOSED";
|
|
164
|
+
};
|
|
165
|
+
/** Compiled-style application failures (phase `csr`). */
|
|
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";
|
|
171
|
+
};
|
|
172
|
+
/**
|
|
173
|
+
* Claim failures: the existing DOM does not match the program that would own
|
|
174
|
+
* 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.
|
|
176
|
+
*/
|
|
177
|
+
export declare const ClaimErrorCode: {
|
|
178
|
+
/** Claimed DOM structure or node identity drifted from the compiled program. */
|
|
179
|
+
readonly STRUCTURE_MISMATCH: "OPEN_ELEMENT_COMPILED_CLAIM_MISMATCH";
|
|
180
|
+
/** A pre-upgrade event capture argument was neither an array nor a capture object. */
|
|
181
|
+
readonly PRE_UPGRADE_EVENTS_INVALID: "OE_CLAIM_PRE_UPGRADE_EVENTS_INVALID";
|
|
182
|
+
/** Bounded recovery met a dynamic node inside a static Region. */
|
|
183
|
+
readonly DYNAMIC_NODE_IN_STATIC_REGION: "OE_CLAIM_DYNAMIC_NODE_IN_STATIC_REGION";
|
|
184
|
+
/** An each item template carries Part anchors, which cannot be rebuilt statically. */
|
|
185
|
+
readonly ITEM_TEMPLATE_ANCHOR: "OE_CLAIM_ITEM_TEMPLATE_ANCHOR";
|
|
186
|
+
};
|
|
187
|
+
/**
|
|
188
|
+
* Compiled server/claim validation failures. The value shipped in
|
|
189
|
+
* 1.0.0-alpha.3 and is kept verbatim; `CompiledProgramValidationError` is its
|
|
190
|
+
* only raiser.
|
|
191
|
+
*/
|
|
192
|
+
export declare const ServerErrorCode: {
|
|
193
|
+
/** A Part Program failed the compiled server/claim grammar. */
|
|
194
|
+
readonly PROGRAM_INVALID: "OPEN_ELEMENT_COMPILED_PROGRAM_INVALID";
|
|
195
|
+
/** A Part Program was refused for a security-relevant reason. */
|
|
196
|
+
readonly SINK_REFUSED: "OE_SERVER_SINK_REFUSED";
|
|
197
|
+
};
|
|
198
|
+
/**
|
|
199
|
+
* Compiler (build-time) failures. The per-diagnostic `OEC####` codes stay on
|
|
200
|
+
* each diagnostic; these classify the family so a build failure is catchable
|
|
201
|
+
* as one thing.
|
|
202
|
+
*/
|
|
203
|
+
export declare const CompilerErrorCode: {
|
|
204
|
+
/** One or more source-located diagnostics stopped the compile. */
|
|
205
|
+
readonly DIAGNOSTICS: "OE_COMPILER_DIAGNOSTICS";
|
|
206
|
+
/** A compile step was handed source it cannot analyse. */
|
|
207
|
+
readonly INVALID_SOURCE: "OE_COMPILER_INVALID_SOURCE";
|
|
208
|
+
};
|
|
209
|
+
/** Attribute/authoring-surface failures (phase `validation`). */
|
|
210
|
+
export declare const AuthoringErrorCode: {
|
|
211
|
+
/** A tag name is not a valid custom element name. */
|
|
212
|
+
readonly INVALID_TAG_NAME: "OE_INVALID_TAG_NAME";
|
|
213
|
+
/** A `wrapInDocument` meta entry uses an attribute name HTML forbids. */
|
|
214
|
+
readonly UNSAFE_META_ATTRIBUTE: "OE_UNSAFE_META_ATTRIBUTE";
|
|
215
|
+
/** A `wrapInDocument` structuredData entry is not a JSON-LD document. */
|
|
216
|
+
readonly INVALID_STRUCTURED_DATA: "OE_INVALID_STRUCTURED_DATA";
|
|
217
|
+
/** An `html` sink received a string that was not marked trusted. */
|
|
218
|
+
readonly UNTRUSTED_HTML_SINK: "OE_UNTRUSTED_HTML_SINK";
|
|
219
|
+
/** The `params` attribute exceeds the documented size limit. */
|
|
220
|
+
readonly PARAMS_ATTRIBUTE_TOO_LARGE: "OE_PARAMS_ATTRIBUTE_TOO_LARGE";
|
|
221
|
+
};
|
|
222
|
+
/** SSR/bootstrap failures raised by the public entries (phase `ssr` / `csr`). */
|
|
223
|
+
export declare const FacadeErrorCode: {
|
|
224
|
+
/**
|
|
225
|
+
* No usable compiled Part Program for the requested class or tag: an
|
|
226
|
+
* uncompiled class, an unregistered tag, or a tag that disagrees with the
|
|
227
|
+
* compiled program's own tag. One code because it is one condition from the
|
|
228
|
+
* caller's side — the class and the program do not describe the same
|
|
229
|
+
* element — and because this value shipped in 1.0.0-alpha.3.
|
|
230
|
+
*/
|
|
231
|
+
readonly PROGRAM_MISSING: "OE_PROGRAM_MISSING";
|
|
232
|
+
/** Nested element expansion exceeded the depth bound (cyclic composition). */
|
|
233
|
+
readonly COMPOSITION_DEPTH: "OE_SSR_COMPOSITION_DEPTH";
|
|
234
|
+
/** A compiled property is marked computed but has no `__computedFields` factory. */
|
|
235
|
+
readonly COMPUTED_FACTORY_MISSING: "OE_COMPUTED_FACTORY_MISSING";
|
|
236
|
+
/** A computed property is read-only and was assigned to. */
|
|
237
|
+
readonly COMPUTED_READONLY: "OE_COMPUTED_READONLY";
|
|
238
|
+
/** The compiled class names a handler the instance does not implement. */
|
|
239
|
+
readonly HANDLER_MISSING: "OE_HANDLER_MISSING";
|
|
240
|
+
/** JSX ran outside the compiler pipeline, where the factory was removed. */
|
|
241
|
+
readonly JSX_OUTSIDE_COMPILER: "OE_JSX_OUTSIDE_COMPILER";
|
|
242
|
+
/** A streamed seed property's type disagrees with the compiled property record. */
|
|
243
|
+
readonly STREAM_TYPE_MISMATCH: "OE_STREAM_TYPE_MISMATCH";
|
|
244
|
+
/** An `HTMLElement` member was reached during SSR, where no DOM exists. */
|
|
245
|
+
readonly SSR_DOM_ACCESS_UNSUPPORTED: "SSR_DOM_ACCESS_UNSUPPORTED";
|
|
246
|
+
};
|
|
247
|
+
/**
|
|
248
|
+
* One framework failure: {@linkcode OpenElementError} with the caller's code
|
|
249
|
+
* and the phase/severity/recoverability that phase implies. Every throw site in
|
|
250
|
+
* this package goes through this factory (or the `*ErrorCode` tables above) so
|
|
251
|
+
* a code, a phase and a recoverability answer cannot drift per site.
|
|
252
|
+
*/
|
|
253
|
+
export declare function frameworkError(code: string, message: string, options?: Omit<OpenElementErrorOptions, 'code'>): OpenElementError;
|
|
254
|
+
/**
|
|
255
|
+
* Raise one framework failure and never return: the throwing companion of
|
|
256
|
+
* {@linkcode frameworkError}. The per-module `fail(code, message)`
|
|
257
|
+
* micro-factories bind their failure surface's fixed {@linkcode ErrorPhase}
|
|
258
|
+
* here — one implementation, the phase as a parameter — so a code and a phase
|
|
259
|
+
* cannot drift apart per throw site.
|
|
260
|
+
*/
|
|
261
|
+
export declare function raiseFrameworkError(phase: ErrorPhase, code: string, message: string): never;
|
|
262
|
+
//#endregion
|
package/src/errors.js
CHANGED
|
@@ -1,16 +1,276 @@
|
|
|
1
|
+
//#region src/errors.ts
|
|
1
2
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
3
|
+
* errors.ts — the single declaration site of the openElement error contract
|
|
4
|
+
* (#1386 item 3).
|
|
5
|
+
*
|
|
6
|
+
* Every failure raised by this package is an {@linkcode OpenElementError}
|
|
7
|
+
* carrying `code`, `severity`, `phase` and `recoverable`; the dedicated
|
|
8
|
+
* exception classes below (`PartProgramClaimError`,
|
|
9
|
+
* `CompiledProgramValidationError`, `EachKeyError`) only ADD their own
|
|
10
|
+
* provenance fields on top of that contract, so a consumer catches by code
|
|
11
|
+
* through the one class.
|
|
12
|
+
*
|
|
13
|
+
* The class lives here, not in `../core/errors.ts`, because this module is
|
|
14
|
+
* import-free: the semantic core and the canonical Part Program protocol may
|
|
15
|
+
* import it without gaining host, bundler, or mutable module state, and
|
|
16
|
+
* `../core/errors.ts` re-exports it for the rest of the package.
|
|
17
|
+
*
|
|
18
|
+
* ## Code families
|
|
19
|
+
*
|
|
20
|
+
* `ErrorCode` is the legacy documented set that the documentation site's error
|
|
21
|
+
* catalog reads by name (the generated error-code and error-reference pages).
|
|
22
|
+
* The `*ErrorCode` tables below are the completed dialect's catalogue, one
|
|
23
|
+
* table per failure surface — the shape `@openelement/router` already uses in
|
|
24
|
+
* `src/internal/error-codes.ts`. Codes are stable: `OPEN_ELEMENT_COMPILED_*`
|
|
25
|
+
* values shipped in 1.0.0-alpha.3 and are kept verbatim so a consumer matching
|
|
26
|
+
* on them keeps working; every new code uses the `OE_` prefix.
|
|
27
|
+
*/
|
|
28
|
+
/** Well-known error code constants for reference. String values are always accepted. */
|
|
29
|
+
const ErrorCode = {
|
|
30
|
+
SSR_RENDER_ERROR: "SSR_RENDER_ERROR",
|
|
31
|
+
BOUNDARY_CAUGHT: "BOUNDARY_CAUGHT",
|
|
32
|
+
UNKNOWN: "UNKNOWN"
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Default code for {@linkcode RenderError}. Deliberately NOT a member of
|
|
36
|
+
* {@linkcode ErrorCode}: that object is the scan target of the documentation
|
|
37
|
+
* site's error catalog, which requires every member to carry a phase/severity
|
|
38
|
+
* family rule. `RENDER_ERROR` is the pre-dialect
|
|
39
|
+
* value `RenderError` has always defaulted to — kept verbatim so callers that
|
|
40
|
+
* observe it keep working, and kept out of the catalogue because it is not a
|
|
41
|
+
* failure this package classifies, only a constructor default a caller may
|
|
42
|
+
* override.
|
|
43
|
+
*/
|
|
44
|
+
const DEFAULT_RENDER_ERROR_CODE = "RENDER_ERROR";
|
|
45
|
+
/** Error message prefix for all openElement errors. */
|
|
46
|
+
const ERROR_PREFIX = "[openElement]";
|
|
47
|
+
/**
|
|
48
|
+
* Whether the authored error prose is kept: `true` everywhere except a
|
|
49
|
+
* production client build, the one context that defines
|
|
50
|
+
* `OE_RUNTIME_MESSAGES` to `false`. Stripping is a payload decision, so it
|
|
51
|
+
* belongs to the browser bundle only — server-side failures keep their prose.
|
|
52
|
+
*/
|
|
53
|
+
const RUNTIME_MESSAGES_ENABLED = typeof OE_RUNTIME_MESSAGES === "boolean" ? OE_RUNTIME_MESSAGES : true;
|
|
54
|
+
/** Framework error carrying a stable code, severity, phase and recoverability contract. */
|
|
55
|
+
var OpenElementError = class extends Error {
|
|
56
|
+
code;
|
|
57
|
+
severity;
|
|
58
|
+
phase;
|
|
59
|
+
recoverable;
|
|
60
|
+
statusCode;
|
|
61
|
+
constructor(message, options = {}) {
|
|
62
|
+
super(message, options.cause ? { cause: options.cause } : void 0);
|
|
63
|
+
this.name = "OpenElementError";
|
|
64
|
+
this.code = options.code ?? ErrorCode.UNKNOWN;
|
|
65
|
+
this.severity = options.severity ?? "error";
|
|
66
|
+
this.phase = options.phase ?? "unknown";
|
|
67
|
+
this.recoverable = options.recoverable ?? false;
|
|
68
|
+
this.statusCode = options.statusCode;
|
|
69
|
+
}
|
|
70
|
+
toJSON() {
|
|
71
|
+
return {
|
|
72
|
+
name: this.name,
|
|
73
|
+
code: this.code,
|
|
74
|
+
message: this.message,
|
|
75
|
+
severity: this.severity,
|
|
76
|
+
phase: this.phase,
|
|
77
|
+
recoverable: this.recoverable,
|
|
78
|
+
statusCode: this.statusCode,
|
|
79
|
+
cause: this.cause instanceof Error ? this.cause.message : this.cause
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Program-shape failures: a Part Program (or one of its records) is malformed,
|
|
85
|
+
* or carries a value the wire format cannot express. Phase `validation`: these
|
|
86
|
+
* reject data before any DOM work starts.
|
|
87
|
+
*/
|
|
88
|
+
const ProgramErrorCode = {
|
|
89
|
+
/** A Part Program v1 failed structural validation. */
|
|
90
|
+
INVALID_PROGRAM: "OE_PROGRAM_INVALID",
|
|
91
|
+
/** A Part Program cannot be serialized to JSON, so it is not a wire artifact. */
|
|
92
|
+
NOT_SERIALIZABLE: "OE_PROGRAM_NOT_SERIALIZABLE",
|
|
93
|
+
/** A compiled server/claim slot names a field the contract does not define. */
|
|
94
|
+
INVALID_SLOT: "OE_PROGRAM_INVALID_SLOT",
|
|
95
|
+
/** A source-map segment carries a non-integer or out-of-range position. */
|
|
96
|
+
INVALID_SOURCE_SEGMENT: "OE_PROGRAM_INVALID_SOURCE_SEGMENT",
|
|
97
|
+
/** A `when` test carries a threshold that is not a numeric literal. */
|
|
98
|
+
NON_NUMERIC_CONDITION: "OE_PROGRAM_NON_NUMERIC_CONDITION"
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Keyed-list identity failures. Shared by the server serializer and the client
|
|
102
|
+
* runtime (see `internal/compiled/each-key.ts`), so both executors reject the
|
|
103
|
+
* same data with the same code.
|
|
104
|
+
*/
|
|
105
|
+
const EachKeyErrorCode = {
|
|
106
|
+
/** A keyed list item is not an object carrying the declared key field. */
|
|
107
|
+
ITEM_NOT_A_RECORD: "OE_EACH_ITEM_NOT_A_RECORD",
|
|
108
|
+
/** A key value cannot round-trip (an object, function or symbol has no stable identity). */
|
|
109
|
+
KEY_NOT_ROUND_TRIPPABLE: "OE_EACH_KEY_NOT_ROUND_TRIPPABLE",
|
|
110
|
+
/** Two items in one list Region derived the same key. */
|
|
111
|
+
DUPLICATE_KEY: "OE_EACH_KEY_DUPLICATE"
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* Runtime execution failures raised while a compiled program is serialized,
|
|
115
|
+
* built into fresh DOM, or re-read on a signal write (phase `render`).
|
|
116
|
+
*/
|
|
117
|
+
const RuntimeErrorCode = {
|
|
118
|
+
/** A list Region's signal does not hold an array. */
|
|
119
|
+
LIST_VALUE_NOT_ARRAY: "OE_RUNTIME_LIST_VALUE_NOT_ARRAY",
|
|
120
|
+
/** render() reads a signal that is not registered on the host. */
|
|
121
|
+
HOST_SIGNAL_MISSING: "OE_RUNTIME_HOST_SIGNAL_MISSING",
|
|
122
|
+
/** An event Part names a handler the host does not provide. */
|
|
123
|
+
HOST_HANDLER_MISSING: "OE_RUNTIME_HOST_HANDLER_MISSING",
|
|
124
|
+
/** A ref Part names a ref the host does not provide. */
|
|
125
|
+
HOST_REF_MISSING: "OE_RUNTIME_HOST_REF_MISSING",
|
|
126
|
+
/** A signal's `subscribe` returned something that is not an unsubscribe function. */
|
|
127
|
+
SUBSCRIPTION_INVALID: "OE_RUNTIME_SUBSCRIPTION_INVALID",
|
|
128
|
+
/** A Part index in the program has no Part record. */
|
|
129
|
+
PART_MISSING: "OE_RUNTIME_PART_MISSING",
|
|
130
|
+
/** A fixed Part was used where a dynamic anchor is required. */
|
|
131
|
+
FIXED_PART_AS_ANCHOR: "OE_RUNTIME_FIXED_PART_AS_ANCHOR",
|
|
132
|
+
/** A compiled node path does not resolve in the DOM. */
|
|
133
|
+
PATH_UNRESOLVED: "OE_RUNTIME_PATH_UNRESOLVED",
|
|
134
|
+
/** A compiled node path resolved to a non-element node. */
|
|
135
|
+
PATH_NOT_ELEMENT: "OE_RUNTIME_PATH_NOT_ELEMENT",
|
|
136
|
+
/** An item value/attribute slot appears outside an `each` Region. */
|
|
137
|
+
ITEM_SLOT_OUTSIDE_REGION: "OE_RUNTIME_ITEM_SLOT_OUTSIDE_REGION",
|
|
138
|
+
/** An item slot found no owning `each` Region. */
|
|
139
|
+
ITEM_SLOT_WITHOUT_REGION: "OE_RUNTIME_ITEM_SLOT_WITHOUT_REGION",
|
|
140
|
+
/** An item slot has no owner document to create nodes from. */
|
|
141
|
+
ITEM_SLOT_WITHOUT_DOCUMENT: "OE_RUNTIME_ITEM_SLOT_WITHOUT_DOCUMENT",
|
|
142
|
+
/** The mount root has no ownerDocument. */
|
|
143
|
+
ROOT_WITHOUT_DOCUMENT: "OE_RUNTIME_ROOT_WITHOUT_DOCUMENT",
|
|
144
|
+
/** Fresh-DOM creation was handed a root that is not empty. */
|
|
145
|
+
FRESH_ROOT_NOT_EMPTY: "OE_RUNTIME_FRESH_ROOT_NOT_EMPTY",
|
|
146
|
+
/** A fixed Part has no serialized anchor to bind. */
|
|
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"
|
|
150
|
+
};
|
|
151
|
+
/** Element-lifecycle failures: the kernel was driven outside its contract (phase `csr`). */
|
|
152
|
+
const KernelErrorCode = {
|
|
153
|
+
/** The kernel was used after `destroy()`. */
|
|
154
|
+
DISPOSED: "OE_KERNEL_DISPOSED",
|
|
155
|
+
/** `__partProgram.tag` does not match the host element's tag. */
|
|
156
|
+
TAG_MISMATCH: "OE_KERNEL_TAG_MISMATCH",
|
|
157
|
+
/** Existing DOM needs the claim executor, which this entry does not install. */
|
|
158
|
+
CLAIM_EXECUTOR_MISSING: "OE_KERNEL_CLAIM_EXECUTOR_MISSING",
|
|
159
|
+
/** A supplied root is not owned by the element it was passed for. */
|
|
160
|
+
ROOT_NOT_OWNED: "OE_KERNEL_ROOT_NOT_OWNED",
|
|
161
|
+
/** The requested root mode needs `attachShadow()`, which the host lacks. */
|
|
162
|
+
ATTACH_SHADOW_REQUIRED: "OE_KERNEL_ATTACH_SHADOW_REQUIRED"
|
|
163
|
+
};
|
|
164
|
+
/** Community-context service lifecycle failures (phase `csr`). */
|
|
165
|
+
const ContextErrorCode = {
|
|
166
|
+
/** The compiled element's context service was used after disconnect disposal. */
|
|
167
|
+
SERVICE_DISPOSED: "OE_CONTEXT_SERVICE_DISPOSED" };
|
|
168
|
+
/** Compiled-style application failures (phase `csr`). */
|
|
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"
|
|
174
|
+
};
|
|
175
|
+
/**
|
|
176
|
+
* Claim failures: the existing DOM does not match the program that would own
|
|
177
|
+
* 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.
|
|
179
|
+
*/
|
|
180
|
+
const ClaimErrorCode = {
|
|
181
|
+
/** Claimed DOM structure or node identity drifted from the compiled program. */
|
|
182
|
+
STRUCTURE_MISMATCH: "OPEN_ELEMENT_COMPILED_CLAIM_MISMATCH",
|
|
183
|
+
/** A pre-upgrade event capture argument was neither an array nor a capture object. */
|
|
184
|
+
PRE_UPGRADE_EVENTS_INVALID: "OE_CLAIM_PRE_UPGRADE_EVENTS_INVALID",
|
|
185
|
+
/** Bounded recovery met a dynamic node inside a static Region. */
|
|
186
|
+
DYNAMIC_NODE_IN_STATIC_REGION: "OE_CLAIM_DYNAMIC_NODE_IN_STATIC_REGION",
|
|
187
|
+
/** An each item template carries Part anchors, which cannot be rebuilt statically. */
|
|
188
|
+
ITEM_TEMPLATE_ANCHOR: "OE_CLAIM_ITEM_TEMPLATE_ANCHOR"
|
|
189
|
+
};
|
|
190
|
+
/**
|
|
191
|
+
* Compiled server/claim validation failures. The value shipped in
|
|
192
|
+
* 1.0.0-alpha.3 and is kept verbatim; `CompiledProgramValidationError` is its
|
|
193
|
+
* only raiser.
|
|
194
|
+
*/
|
|
195
|
+
const ServerErrorCode = {
|
|
196
|
+
/** A Part Program failed the compiled server/claim grammar. */
|
|
197
|
+
PROGRAM_INVALID: "OPEN_ELEMENT_COMPILED_PROGRAM_INVALID",
|
|
198
|
+
/** A Part Program was refused for a security-relevant reason. */
|
|
199
|
+
SINK_REFUSED: "OE_SERVER_SINK_REFUSED"
|
|
200
|
+
};
|
|
201
|
+
/**
|
|
202
|
+
* Compiler (build-time) failures. The per-diagnostic `OEC####` codes stay on
|
|
203
|
+
* each diagnostic; these classify the family so a build failure is catchable
|
|
204
|
+
* as one thing.
|
|
205
|
+
*/
|
|
206
|
+
const CompilerErrorCode = {
|
|
207
|
+
/** One or more source-located diagnostics stopped the compile. */
|
|
208
|
+
DIAGNOSTICS: "OE_COMPILER_DIAGNOSTICS",
|
|
209
|
+
/** A compile step was handed source it cannot analyse. */
|
|
210
|
+
INVALID_SOURCE: "OE_COMPILER_INVALID_SOURCE"
|
|
211
|
+
};
|
|
212
|
+
/** Attribute/authoring-surface failures (phase `validation`). */
|
|
213
|
+
const AuthoringErrorCode = {
|
|
214
|
+
/** A tag name is not a valid custom element name. */
|
|
215
|
+
INVALID_TAG_NAME: "OE_INVALID_TAG_NAME",
|
|
216
|
+
/** A `wrapInDocument` meta entry uses an attribute name HTML forbids. */
|
|
217
|
+
UNSAFE_META_ATTRIBUTE: "OE_UNSAFE_META_ATTRIBUTE",
|
|
218
|
+
/** A `wrapInDocument` structuredData entry is not a JSON-LD document. */
|
|
219
|
+
INVALID_STRUCTURED_DATA: "OE_INVALID_STRUCTURED_DATA",
|
|
220
|
+
/** An `html` sink received a string that was not marked trusted. */
|
|
221
|
+
UNTRUSTED_HTML_SINK: "OE_UNTRUSTED_HTML_SINK",
|
|
222
|
+
/** The `params` attribute exceeds the documented size limit. */
|
|
223
|
+
PARAMS_ATTRIBUTE_TOO_LARGE: "OE_PARAMS_ATTRIBUTE_TOO_LARGE"
|
|
224
|
+
};
|
|
225
|
+
/** SSR/bootstrap failures raised by the public entries (phase `ssr` / `csr`). */
|
|
226
|
+
const FacadeErrorCode = {
|
|
227
|
+
/**
|
|
228
|
+
* No usable compiled Part Program for the requested class or tag: an
|
|
229
|
+
* uncompiled class, an unregistered tag, or a tag that disagrees with the
|
|
230
|
+
* compiled program's own tag. One code because it is one condition from the
|
|
231
|
+
* caller's side — the class and the program do not describe the same
|
|
232
|
+
* element — and because this value shipped in 1.0.0-alpha.3.
|
|
233
|
+
*/
|
|
234
|
+
PROGRAM_MISSING: "OE_PROGRAM_MISSING",
|
|
235
|
+
/** Nested element expansion exceeded the depth bound (cyclic composition). */
|
|
236
|
+
COMPOSITION_DEPTH: "OE_SSR_COMPOSITION_DEPTH",
|
|
237
|
+
/** A compiled property is marked computed but has no `__computedFields` factory. */
|
|
238
|
+
COMPUTED_FACTORY_MISSING: "OE_COMPUTED_FACTORY_MISSING",
|
|
239
|
+
/** A computed property is read-only and was assigned to. */
|
|
240
|
+
COMPUTED_READONLY: "OE_COMPUTED_READONLY",
|
|
241
|
+
/** The compiled class names a handler the instance does not implement. */
|
|
242
|
+
HANDLER_MISSING: "OE_HANDLER_MISSING",
|
|
243
|
+
/** JSX ran outside the compiler pipeline, where the factory was removed. */
|
|
244
|
+
JSX_OUTSIDE_COMPILER: "OE_JSX_OUTSIDE_COMPILER",
|
|
245
|
+
/** A streamed seed property's type disagrees with the compiled property record. */
|
|
246
|
+
STREAM_TYPE_MISMATCH: "OE_STREAM_TYPE_MISMATCH",
|
|
247
|
+
/** An `HTMLElement` member was reached during SSR, where no DOM exists. */
|
|
248
|
+
SSR_DOM_ACCESS_UNSUPPORTED: "SSR_DOM_ACCESS_UNSUPPORTED"
|
|
249
|
+
};
|
|
250
|
+
/**
|
|
251
|
+
* One framework failure: {@linkcode OpenElementError} with the caller's code
|
|
252
|
+
* and the phase/severity/recoverability that phase implies. Every throw site in
|
|
253
|
+
* this package goes through this factory (or the `*ErrorCode` tables above) so
|
|
254
|
+
* a code, a phase and a recoverability answer cannot drift per site.
|
|
255
|
+
*/
|
|
256
|
+
function frameworkError(code, message, options = {}) {
|
|
257
|
+
return new OpenElementError(message, {
|
|
258
|
+
severity: "error",
|
|
259
|
+
recoverable: false,
|
|
260
|
+
phase: "render",
|
|
261
|
+
...options,
|
|
262
|
+
code
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Raise one framework failure and never return: the throwing companion of
|
|
267
|
+
* {@linkcode frameworkError}. The per-module `fail(code, message)`
|
|
268
|
+
* micro-factories bind their failure surface's fixed {@linkcode ErrorPhase}
|
|
269
|
+
* here — one implementation, the phase as a parameter — so a code and a phase
|
|
270
|
+
* cannot drift apart per throw site.
|
|
271
|
+
*/
|
|
272
|
+
function raiseFrameworkError(phase, code, message) {
|
|
273
|
+
throw frameworkError(code, message, { phase });
|
|
274
|
+
}
|
|
275
|
+
//#endregion
|
|
276
|
+
export { AuthoringErrorCode, ClaimErrorCode, CompilerErrorCode, ContextErrorCode, DEFAULT_RENDER_ERROR_CODE, ERROR_PREFIX, EachKeyErrorCode, ErrorCode, FacadeErrorCode, KernelErrorCode, OpenElementError, ProgramErrorCode, RUNTIME_MESSAGES_ENABLED, RuntimeErrorCode, ServerErrorCode, StyleErrorCode, frameworkError, raiseFrameworkError };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
//#region src/forbidden-sinks.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Forbidden sink names — the ONE canonical deny list for every Part Program
|
|
4
|
+
* boundary: the compiler semantic core, the protocol validator
|
|
5
|
+
* (internal/protocol/part-program.ts), and the compiled server/claim
|
|
6
|
+
* validator (internal/compiled/server/shared.ts).
|
|
7
|
+
*
|
|
8
|
+
* This module is import-free and host-free by design (same base-of-graph
|
|
9
|
+
* contract as void-tags.ts): all consumers import it, so a new
|
|
10
|
+
* forbidden sink cannot be enforced on one boundary and missed on another.
|
|
11
|
+
* This module owns the named-sink deny lists and the attribute-name policy
|
|
12
|
+
* built on them (the one shared safe-attribute-name predicate and the one
|
|
13
|
+
* camelCase→kebab-case casing rule); consumers delegate so the
|
|
14
|
+
* boundary cannot diverge.
|
|
15
|
+
*
|
|
16
|
+
* The lists are fail closed and case-insensitive (attribute and property
|
|
17
|
+
* names are compared lowercase, matching the HTML parser's name folding):
|
|
18
|
+
*
|
|
19
|
+
* - `FORBIDDEN_ATTRIBUTE_NAMES`: attribute names that must never be a static
|
|
20
|
+
* attribute or an `attr`/`bool` sink. `srcdoc` smuggles a full HTML
|
|
21
|
+
* document past attribute escaping; `innerHTML` is admissible only through
|
|
22
|
+
* the dedicated trusted-HTML `html` Part, never as a plain
|
|
23
|
+
* attribute name.
|
|
24
|
+
* - `FORBIDDEN_PROPERTY_NAMES`: `prop` sink names that would re-prototype or
|
|
25
|
+
* re-construct the target element (prototype-pollution primitives).
|
|
26
|
+
* - `RAW_TEXT_TAGS`: raw-text elements are outside the compiled grammar —
|
|
27
|
+
* their content cannot be escaped by the serializer.
|
|
28
|
+
*/
|
|
29
|
+
export declare const FORBIDDEN_ATTRIBUTE_NAMES: ReadonlySet<string>;
|
|
30
|
+
/** Property names the compiler refuses as @property declarations. */
|
|
31
|
+
export declare const FORBIDDEN_PROPERTY_NAMES: ReadonlySet<string>;
|
|
32
|
+
/** Elements whose text content must never be interpolated as markup. */
|
|
33
|
+
export declare const RAW_TEXT_TAGS: ReadonlySet<string>;
|
|
34
|
+
/** Sink categories the canonical deny list classifies. */
|
|
35
|
+
export type ForbiddenSinkKind = 'attr' | 'bool' | 'prop' | 'tag';
|
|
36
|
+
/**
|
|
37
|
+
* Return a human-readable reason when `name` is a forbidden sink of `kind`,
|
|
38
|
+
* or null when the name is admissible. Unknown kinds fail closed with a
|
|
39
|
+
* reason instead of being waved through.
|
|
40
|
+
*/
|
|
41
|
+
export declare function forbiddenSinkReason(kind: ForbiddenSinkKind, name: string): string | null;
|
|
42
|
+
/**
|
|
43
|
+
* The one safe-attribute-name predicate (#1033, #602). Attribute *names* are
|
|
44
|
+
* not escaped on any render path, so a name must be valid HTML attribute-name
|
|
45
|
+
* grammar (blocks quote/space injection), must not be an event handler
|
|
46
|
+
* (`on*`, case-insensitive), and must not be a forbidden sink (`innerhtml`/
|
|
47
|
+
* `srcdoc` — case-insensitive). Every boundary that admits an attribute name
|
|
48
|
+
* — the compiler semantic core, the Part Program validator, the compiled
|
|
49
|
+
* server validator, and the SSR head/meta name checks — delegates here, so
|
|
50
|
+
* the rules cannot diverge per path.
|
|
51
|
+
*/
|
|
52
|
+
export declare function isSafeAttributeName(name: string): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* The one camelCase → kebab-case casing rule for custom-element attribute
|
|
55
|
+
* names, so `<x-el itemCount={5}>` round-trips as `item-count` on every
|
|
56
|
+
* boundary that derives an attribute name from a prop name: the compiler's
|
|
57
|
+
* property metadata, the SSR serializer, and the client attribute handling.
|
|
58
|
+
*/
|
|
59
|
+
export declare function camelToKebab(str: string): string;
|
|
60
|
+
//#endregion
|