@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 +7 -5
- package/package.json +11 -1
- package/src/client-assets.js +1 -0
- package/src/diagnostics.d.ts +93 -0
- package/src/diagnostics.js +114 -0
- package/src/errors.d.ts +69 -15
- package/src/errors.js +70 -16
- package/src/forbidden-sinks.js +1 -1
- package/src/framework.d.ts +54 -33
- package/src/index.d.ts +11 -9
- package/src/index.js +6 -4
- package/src/island.d.ts +14 -0
- package/src/manifest.d.ts +59 -0
- package/src/module-vocabulary.js +9 -17
- package/src/part-program.d.ts +13 -27
- package/src/part-program.js +93 -67
- package/src/policy.d.ts +2 -2
- package/src/policy.js +2 -2
- package/src/registry-markers.d.ts +14 -1
- package/src/registry-markers.js +15 -2
- package/src/render.d.ts +2 -22
- package/src/server-only.d.ts +1 -0
- package/src/server-only.js +1 -0
- package/src/ssg.d.ts +81 -29
- package/src/stream-frame-policy.d.ts +1 -1
- package/src/stream-frame-policy.js +1 -1
- package/src/style-sheet.d.ts +60 -1
- package/src/style-sheet.js +62 -1
package/src/framework.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//#region src/framework.d.ts
|
|
2
2
|
/**
|
|
3
|
-
* framework.ts - Framework, build,
|
|
3
|
+
* framework.ts - Framework, build, layout, routing, and plugin
|
|
4
4
|
* metadata contracts.
|
|
5
5
|
*/
|
|
6
6
|
/** Branded type: a string that has been HTML-escaped (safe for text content) */
|
|
@@ -76,18 +76,18 @@ export interface LocalePath {
|
|
|
76
76
|
isDefaultLocalePath: boolean;
|
|
77
77
|
}
|
|
78
78
|
/**
|
|
79
|
-
*
|
|
80
|
-
* `'default'` uses the built-in
|
|
79
|
+
* Layout declaration: `false` disables the layout entirely,
|
|
80
|
+
* `'default'` uses the built-in layout, and the object form names a tag with the
|
|
81
81
|
* module path that defines it (`import`, resolved like a
|
|
82
|
-
* {@link FrameworkOptions.middleware.use} entry) plus the compiled
|
|
82
|
+
* {@link FrameworkOptions.middleware.use} entry) plus the compiled layout
|
|
83
83
|
* properties the router injects per route.
|
|
84
84
|
*/
|
|
85
|
-
export type
|
|
85
|
+
export type LayoutConfig = false | 'default' | {
|
|
86
86
|
tagName: string;
|
|
87
87
|
import: string;
|
|
88
88
|
props?: Record<string, unknown>;
|
|
89
89
|
};
|
|
90
|
-
type LayoutsConfig = Record<string,
|
|
90
|
+
type LayoutsConfig = Record<string, LayoutConfig | undefined>;
|
|
91
91
|
/**
|
|
92
92
|
* One route admitted by the scanner: URL `path`, source `filePath`, the
|
|
93
93
|
* route `type`, the generated variable name (`varName`) the entry binds it to,
|
|
@@ -110,6 +110,17 @@ export interface RouteEntry {
|
|
|
110
110
|
* registration tag.
|
|
111
111
|
*/
|
|
112
112
|
definePage?: boolean;
|
|
113
|
+
/**
|
|
114
|
+
* The server function page fact (alpha15 server lane): the exported server
|
|
115
|
+
* function component the route's `export default definePage(Component)` was
|
|
116
|
+
* called over. Present only when the argument is a plain identifier
|
|
117
|
+
* resolving to a component THIS module declares — an inline arrow or an
|
|
118
|
+
* unexported local never records it (the R1 admission rule mirrored, so a
|
|
119
|
+
* shape whose JSX would escape to runtime is never admitted). The generated
|
|
120
|
+
* entry registers nothing for the route and renders it through the
|
|
121
|
+
* descriptor's compiled render function.
|
|
122
|
+
*/
|
|
123
|
+
functionPage?: string;
|
|
113
124
|
/** Source text captured during scanning when includeSource is enabled. */
|
|
114
125
|
source?: string;
|
|
115
126
|
/**
|
|
@@ -139,10 +150,9 @@ export interface RouteEntry {
|
|
|
139
150
|
*/
|
|
140
151
|
export type Middleware = (request: Request, next: () => Promise<Response>) => Promise<Response>;
|
|
141
152
|
/**
|
|
142
|
-
* The adapter-facing framework options: where routes
|
|
143
|
-
* live,
|
|
144
|
-
*
|
|
145
|
-
* request-time middleware switches.
|
|
153
|
+
* The adapter-facing framework options: where routes and islands
|
|
154
|
+
* live, the default layout and named-layout declarations, the document
|
|
155
|
+
* `<html>`/head injection channels, and the request-time middleware switches.
|
|
146
156
|
*
|
|
147
157
|
* Every field is optional; the adapter applies its documented default. This is
|
|
148
158
|
* the type an application config file's default export is checked against, so
|
|
@@ -150,29 +160,40 @@ export type Middleware = (request: Request, next: () => Promise<Response>) => Pr
|
|
|
150
160
|
*/
|
|
151
161
|
export interface FrameworkOptions {
|
|
152
162
|
/**
|
|
153
|
-
* Page renderer selection
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
* @lit-labs/ssr and hydrates them with @lit-labs/ssr-client. Routing,
|
|
157
|
-
* loaders, actions, form enhancement and morphing are shared; only page
|
|
158
|
-
* rendering and the client claim layer fork. 'lit' currently requires
|
|
159
|
-
* `appShell: false` (no compiled shell); the build fails closed otherwise.
|
|
163
|
+
* Page renderer selection. The compiled native renderer is the only one
|
|
164
|
+
* supported; omit this key. A retired `'lit'` value is rejected with an
|
|
165
|
+
* explicit migration error at the config boundary (ADR-0152, 2026-11-08).
|
|
160
166
|
*/
|
|
161
|
-
renderer?: 'native'
|
|
167
|
+
renderer?: 'native';
|
|
162
168
|
/** Directory the route scanner walks, relative to the Vite root. Defaults to `app/routes`. */
|
|
163
169
|
routesDir?: string;
|
|
164
170
|
/** Directory island modules are discovered in. Defaults to `app/islands`. */
|
|
165
171
|
islandsDir?: string;
|
|
166
|
-
/**
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
172
|
+
/**
|
|
173
|
+
* How the build admits component packages whose modules the application
|
|
174
|
+
* imports.
|
|
175
|
+
*
|
|
176
|
+
* - omitted or `'auto'` (the default): the scan derives the admitted set at
|
|
177
|
+
* scan time — every package-owned element module the app's routes, pages,
|
|
178
|
+
* layouts, islands and components really reach (bundler-resolved) is
|
|
179
|
+
* attributed to its owner package (nearest `package.json`), and a package
|
|
180
|
+
* with a valid OpenElement manifest is admitted. An array value merges with
|
|
181
|
+
* the derivation; an explicit entry outranks a derived claim when two
|
|
182
|
+
* packages claim the same tag.
|
|
183
|
+
* - `'manual'`: derivation off — the pre-auto behavior. Nothing is admitted
|
|
184
|
+
* unless listed, and an imported-but-unlisted component package is
|
|
185
|
+
* reported with the explicit fix.
|
|
186
|
+
* - `string[]`: admitted explicitly, on top of the derivation (auto mode).
|
|
187
|
+
*
|
|
188
|
+
* A package whose modules the app imports but which carries no valid
|
|
189
|
+
* manifest is never admitted (there is nothing to admit) and is reported —
|
|
190
|
+
* the one true mistake class the report keeps under auto.
|
|
191
|
+
*/
|
|
192
|
+
packageIslands?: string[] | 'auto' | 'manual';
|
|
193
|
+
/** Layout declaration; `false` disables the layout, `'default'` uses the built-in one. */
|
|
194
|
+
layout?: LayoutConfig;
|
|
195
|
+
/** Named layout declarations keyed by layout name. */
|
|
173
196
|
layouts?: LayoutsConfig;
|
|
174
|
-
/** Build mode. 'ssg' (default) generates static HTML. */
|
|
175
|
-
mode?: 'ssg';
|
|
176
197
|
/** @dangerous injected as-is, only use with controlled content */
|
|
177
198
|
headExtras?: string;
|
|
178
199
|
/** Document `<html>` attributes: the `lang` the document declares and the default `<title>`. */
|
|
@@ -240,7 +261,7 @@ export interface FrameworkOptions {
|
|
|
240
261
|
};
|
|
241
262
|
/** Request-time middleware switches, composed outside the framework handler. */
|
|
242
263
|
middleware?: {
|
|
243
|
-
/**
|
|
264
|
+
/** Built-in CORS middleware. Default-ON; pass `false` to disable. */
|
|
244
265
|
cors?: boolean;
|
|
245
266
|
/**
|
|
246
267
|
* Static CORS allowlist data, serialized into the generated entry as JSON.
|
|
@@ -252,15 +273,15 @@ export interface FrameworkOptions {
|
|
|
252
273
|
* `(origin: string) => string | undefined`. The generated entry imports
|
|
253
274
|
* the module — the callback is never serialized — so it may close over
|
|
254
275
|
* module scope and import dependencies. Resolved with the same idiom as
|
|
255
|
-
* `
|
|
276
|
+
* `layout.import` (e.g. './app/cors-origin.ts'). Mutually exclusive
|
|
256
277
|
* with `corsOrigin`.
|
|
257
278
|
*/
|
|
258
279
|
corsOriginModule?: string;
|
|
259
|
-
/** Emit and honor a per-request id header. */
|
|
280
|
+
/** Emit and honor a per-request id header. Default-ON; pass `false` to disable. */
|
|
260
281
|
requestId?: boolean;
|
|
261
|
-
/** Log each request through the built-in logger. */
|
|
282
|
+
/** Log each request through the built-in logger. Default-ON; pass `false` to disable. */
|
|
262
283
|
logger?: boolean;
|
|
263
|
-
/** Attach the built-in security response headers. */
|
|
284
|
+
/** Attach the built-in security response headers. Default-ON; pass `false` to disable. */
|
|
264
285
|
securityHeaders?: boolean;
|
|
265
286
|
/** Content-Security-Policy emission: the policy string, nonce generation, and report-only mode. */
|
|
266
287
|
csp?: {
|
|
@@ -272,7 +293,7 @@ export interface FrameworkOptions {
|
|
|
272
293
|
* Fetch middleware chain (#858), composed around the
|
|
273
294
|
* framework handler in onion order (`use[0]` outermost), outside all
|
|
274
295
|
* built-in middleware above. Each entry is a MODULE PATH (same resolution
|
|
275
|
-
* idiom as `
|
|
296
|
+
* idiom as `layout.import`, e.g. './app/middleware/auth.ts') whose
|
|
276
297
|
* default export is a {@link Middleware}; the generated entry emits
|
|
277
298
|
* `import * as __mw_N from '<path>'` and composes `__mw_N.default` in
|
|
278
299
|
* configured order.
|
package/src/index.d.ts
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
import { OpenElementRouteKind, OpenElementRouteNode } from "./app-model.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { CompatibilityClassification, CompatibilityTier, ComponentLayer, FrameworkOptions, HYDRATION_STRATEGIES, HydrationStrategy, LayoutConfig, LocalePath, Middleware, OpenElementBlogOptions, OpenElementBuildContextLike, OpenElementHeaderNavLink, OpenElementI18nContextOptions, OpenElementNavSection, RouteEntry, SafeHtml, SpecialFileType, StrategySource, UnsafeHtml } from "./framework.js";
|
|
3
|
+
import { AuthoringErrorCode, ClaimErrorCode, CompilerErrorCode, ContextErrorCode, DEFAULT_RENDER_ERROR_CODE, ERROR_PREFIX, EachKeyErrorCode, ErrorCode, ErrorPhase, ErrorSeverity, ErrorTelemetryHook, FacadeErrorCode, KernelErrorCode, OpenElementError, OpenElementErrorOptions, ProgramErrorCode, RUNTIME_MESSAGES_ENABLED, RuntimeErrorCode, ServerErrorCode, StyleErrorCode, frameworkError, raiseFrameworkError } from "./errors.js";
|
|
4
|
+
import { HydrationHint, RenderError, SsrAdmissionDecision } from "./render.js";
|
|
4
5
|
import { VOID_TAGS } from "./void-tags.js";
|
|
5
|
-
import {
|
|
6
|
-
import { ApiRouteDecl,
|
|
6
|
+
import { CemPropertyMetadata, CompiledCemMetadata, CompiledElementMetadata, CompiledPropertyMetadata, ConditionOperator, DATA_OE_LIGHT, ItemEventBinding, PART_PROGRAM_VERSION, PartProgram, PartProgramV2, ProgramAttrPart, ProgramBlockRecord, ProgramBoolPart, ProgramClassPart, ProgramCondition, ProgramDependencyRecord, ProgramEachPart, ProgramElementNode, ProgramEventAction, ProgramEventPart, ProgramHtmlPart, ProgramItemValueNode, ProgramLocation, ProgramLocationRecord, ProgramPart, ProgramPartAnchorNode, ProgramPosition, ProgramPropPart, ProgramRefPart, ProgramRoot, ProgramSourceKind, ProgramSourceMap, ProgramSourceRange, ProgramSourceRecord, ProgramStylePart, ProgramTextNode, ProgramTextPart, ProgramTreeNode, ProgramWhenPart, PropertyValueType, RootMode, STATIC_STYLES_MARKER, SerializableValue, conditionLiteralAllowed, isAttributeName, partAnchorEndMarker, partAnchorMarker, validatePartProgram } from "./part-program.js";
|
|
7
|
+
import { ApiRouteDecl, BuildArtifacts, BuildClientAsset, BuildI18nOptions, BuildIslandInput, BuildManifestArtifact, BuildOutputOptions, BuildPackageIslandOptions, BuildPageArtifact, BuildPlan, BuildRouteInput, ClientIslandEntry, CorsOriginConfig, CspConfig, DocumentConfig, EntryDescriptor, ImportDecl, IslandDecl, IslandDeliveryStrategy, IslandModuleIdentity, LayoutDecl, LayoutPlan, MiddlewareDecl, MiddlewareScopeDecl, PageRouteDecl, RendererDecl, ResolvedLayout, RouteInfoEntry, SpeculationRulesOptions, SsgBehaviorOptions, SsgPageOutput, SsgRenderEvidence, SsgRenderOptions, SsgRenderSummary, SsrAdmissionPlan, SsrBundle, StaticComponentDecl, StreamRouteManifest } from "./ssg.js";
|
|
7
8
|
import { ClientAssetManifest, ClientIslandAsset, EMPTY_CLIENT_ASSET_MANIFEST, serializeClientAssetsModule } from "./client-assets.js";
|
|
8
9
|
import { ACTION_FETCH_HEADER, Action, ActionContext, ActionResult, Loader, LoaderContext, PROBLEM_JSON_MEDIA_TYPE, ProblemDetails, ServerRouteContext, ServerRouteMetadata } from "./data.js";
|
|
9
|
-
import {
|
|
10
|
+
import { DIAGNOSTIC_REPORT_FORMAT, DiagnosticEnvelope, DiagnosticPhase, DiagnosticReport, DiagnosticReportFormat, DiagnosticReportParseError, DiagnosticSeverity, diagnosticReport, errorToEnvelope, parseDiagnosticReport, serializeDiagnosticReport } from "./diagnostics.js";
|
|
10
11
|
import { FORBIDDEN_ATTRIBUTE_NAMES, FORBIDDEN_PROPERTY_NAMES, ForbiddenSinkKind, RAW_TEXT_TAGS, camelToKebab, forbiddenSinkReason, isSafeAttributeName } from "./forbidden-sinks.js";
|
|
12
|
+
import { ModuleVocabularyDescriptor, StaticSidecarDescriptor } from "./module-descriptors.js";
|
|
11
13
|
import { ISLAND_ADMISSION } from "./island-admission.js";
|
|
12
14
|
import { IslandOptions, IslandTransformOptions, IslandTransformResult } from "./island.js";
|
|
13
|
-
import { CemCompatibilityReport, OpenElementAttribute, OpenElementCssPart, OpenElementDeclaration, OpenElementEvent, OpenElementExtensions, OpenElementPackageManifest, OpenElementSlot } from "./manifest.js";
|
|
15
|
+
import { CemCompatibilityReport, OpenElementAttribute, OpenElementCssPart, OpenElementDeclaration, OpenElementEvent, OpenElementExtensions, OpenElementPackageManifest, OpenElementSlot, OpenElementTailwindDeclaration } from "./manifest.js";
|
|
14
16
|
import { ROUTER_MODULE_VOCABULARY } from "./module-vocabulary.js";
|
|
15
17
|
import { IDLE_FALLBACK_TIMEOUT_MS, MAX_ACTION_BODY_BYTES, MAX_COMPOSITION_DEPTH, STREAM_MAX_FIELDS, STREAM_MAX_OWNERS, STREAM_MAX_PAYLOAD_LENGTH, STREAM_MAX_SEED_PROPERTIES, STREAM_TIMEOUT_MS } from "./policy.js";
|
|
16
|
-
import { ENTRY_REGISTRATION_OWNERS, SSR_REGISTRY_ORIGINAL_DEFINE, SSR_REGISTRY_STUB_MARKER } from "./registry-markers.js";
|
|
18
|
+
import { ENTRY_REGISTRATION_OWNERS, SSR_REGISTRY_GENERATED_HOSTS, SSR_REGISTRY_ORIGINAL_DEFINE, SSR_REGISTRY_STUB_MARKER } from "./registry-markers.js";
|
|
17
19
|
import { OpenElementRequestHandler, RuntimeAdapter, RuntimeAdapterOptions, RuntimeContext } from "./runtime.js";
|
|
18
20
|
import { ReadonlySignal, SIGNAL_BRAND, Signal, SignalEngine, SignalLike, Unsubscribe, WritableSignal } from "./signal.js";
|
|
19
21
|
import { STREAM_FRAME_FORBIDDEN_TAGS, STREAM_FRAME_UNSAFE_URL, STREAM_FRAME_URL_ATTRIBUTES, STREAM_FRAME_URL_CONTROL_MAX, unsafeStreamFrameAttribute } from "./stream-frame-policy.js";
|
|
20
|
-
import { StyleSheetLike, StyleSheetRule } from "./style-sheet.js";
|
|
21
|
-
export { ACTION_FETCH_HEADER, Action, ActionContext, ActionResult, ApiRouteDecl,
|
|
22
|
+
import { NESTED_HOST_EXPANDER, STYLE_SHEET_LIVE, STYLE_SHEET_READY, STYLE_SHEET_URL, StyleSheetLike, StyleSheetRule } from "./style-sheet.js";
|
|
23
|
+
export { ACTION_FETCH_HEADER, Action, ActionContext, ActionResult, ApiRouteDecl, AuthoringErrorCode, BuildArtifacts, BuildClientAsset, BuildI18nOptions, BuildIslandInput, BuildManifestArtifact, BuildOutputOptions, BuildPackageIslandOptions, BuildPageArtifact, BuildPlan, BuildRouteInput, CemCompatibilityReport, CemPropertyMetadata, ClaimErrorCode, ClientAssetManifest, ClientIslandAsset, ClientIslandEntry, CompatibilityClassification, CompatibilityTier, CompiledCemMetadata, CompiledElementMetadata, CompiledPropertyMetadata, CompilerErrorCode, ComponentLayer, ConditionOperator, ContextErrorCode, CorsOriginConfig, CspConfig, DATA_OE_LIGHT, DEFAULT_RENDER_ERROR_CODE, DIAGNOSTIC_REPORT_FORMAT, DiagnosticEnvelope, DiagnosticPhase, DiagnosticReport, DiagnosticReportFormat, DiagnosticReportParseError, DiagnosticSeverity, DocumentConfig, EMPTY_CLIENT_ASSET_MANIFEST, ENTRY_REGISTRATION_OWNERS, ERROR_PREFIX, EachKeyErrorCode, EntryDescriptor, ErrorCode, ErrorPhase, ErrorSeverity, ErrorTelemetryHook, FORBIDDEN_ATTRIBUTE_NAMES, FORBIDDEN_PROPERTY_NAMES, FacadeErrorCode, ForbiddenSinkKind, FrameworkOptions, HYDRATION_STRATEGIES, HydrationHint, HydrationStrategy, IDLE_FALLBACK_TIMEOUT_MS, ISLAND_ADMISSION, ImportDecl, IslandDecl, IslandDeliveryStrategy, IslandModuleIdentity, IslandOptions, IslandTransformOptions, IslandTransformResult, ItemEventBinding, KernelErrorCode, LayoutConfig, LayoutDecl, LayoutPlan, Loader, LoaderContext, LocalePath, MAX_ACTION_BODY_BYTES, MAX_COMPOSITION_DEPTH, Middleware, MiddlewareDecl, MiddlewareScopeDecl, ModuleVocabularyDescriptor, NESTED_HOST_EXPANDER, OpenElementAttribute, OpenElementBlogOptions, OpenElementBuildContextLike, OpenElementCssPart, OpenElementDeclaration, OpenElementError, OpenElementErrorOptions, OpenElementEvent, OpenElementExtensions, OpenElementHeaderNavLink, OpenElementI18nContextOptions, OpenElementNavSection, OpenElementPackageManifest, OpenElementRequestHandler, OpenElementRouteKind, OpenElementRouteNode, OpenElementSlot, OpenElementTailwindDeclaration, PART_PROGRAM_VERSION, PROBLEM_JSON_MEDIA_TYPE, PageRouteDecl, PartProgram, PartProgramV2, ProblemDetails, ProgramAttrPart, ProgramBlockRecord, ProgramBoolPart, ProgramClassPart, ProgramCondition, ProgramDependencyRecord, ProgramEachPart, ProgramElementNode, ProgramErrorCode, ProgramEventAction, ProgramEventPart, ProgramHtmlPart, ProgramItemValueNode, ProgramLocation, ProgramLocationRecord, ProgramPart, ProgramPartAnchorNode, ProgramPosition, ProgramPropPart, ProgramRefPart, ProgramRoot, ProgramSourceKind, ProgramSourceMap, ProgramSourceRange, ProgramSourceRecord, ProgramStylePart, ProgramTextNode, ProgramTextPart, ProgramTreeNode, ProgramWhenPart, PropertyValueType, RAW_TEXT_TAGS, ROUTER_MODULE_VOCABULARY, RUNTIME_MESSAGES_ENABLED, ReadonlySignal, RenderError, RendererDecl, ResolvedLayout, RootMode, RouteEntry, RouteInfoEntry, RuntimeAdapter, RuntimeAdapterOptions, RuntimeContext, RuntimeErrorCode, SIGNAL_BRAND, SSR_REGISTRY_GENERATED_HOSTS, SSR_REGISTRY_ORIGINAL_DEFINE, SSR_REGISTRY_STUB_MARKER, STATIC_STYLES_MARKER, STREAM_FRAME_FORBIDDEN_TAGS, STREAM_FRAME_UNSAFE_URL, STREAM_FRAME_URL_ATTRIBUTES, STREAM_FRAME_URL_CONTROL_MAX, STREAM_MAX_FIELDS, STREAM_MAX_OWNERS, STREAM_MAX_PAYLOAD_LENGTH, STREAM_MAX_SEED_PROPERTIES, STREAM_TIMEOUT_MS, STYLE_SHEET_LIVE, STYLE_SHEET_READY, STYLE_SHEET_URL, SafeHtml, SerializableValue, ServerErrorCode, ServerRouteContext, ServerRouteMetadata, Signal, SignalEngine, SignalLike, SpecialFileType, SpeculationRulesOptions, SsgBehaviorOptions, SsgPageOutput, SsgRenderEvidence, SsgRenderOptions, SsgRenderSummary, SsrAdmissionDecision, SsrAdmissionPlan, SsrBundle, StaticComponentDecl, StaticSidecarDescriptor, StrategySource, StreamRouteManifest, StyleErrorCode, StyleSheetLike, StyleSheetRule, UnsafeHtml, Unsubscribe, VOID_TAGS, WritableSignal, camelToKebab, conditionLiteralAllowed, diagnosticReport, errorToEnvelope, forbiddenSinkReason, frameworkError, isAttributeName, isSafeAttributeName, parseDiagnosticReport, partAnchorEndMarker, partAnchorMarker, raiseFrameworkError, serializeClientAssetsModule, serializeDiagnosticReport, unsafeStreamFrameAttribute, validatePartProgram };
|
package/src/index.js
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
import "./app-model.js";
|
|
2
2
|
import { EMPTY_CLIENT_ASSET_MANIFEST, serializeClientAssetsModule } from "./client-assets.js";
|
|
3
3
|
import { ACTION_FETCH_HEADER, PROBLEM_JSON_MEDIA_TYPE } from "./data.js";
|
|
4
|
+
import { DIAGNOSTIC_REPORT_FORMAT, DiagnosticReportParseError, diagnosticReport, errorToEnvelope, parseDiagnosticReport, serializeDiagnosticReport } from "./diagnostics.js";
|
|
4
5
|
import { AuthoringErrorCode, ClaimErrorCode, CompilerErrorCode, ContextErrorCode, DEFAULT_RENDER_ERROR_CODE, ERROR_PREFIX, EachKeyErrorCode, ErrorCode, FacadeErrorCode, KernelErrorCode, OpenElementError, ProgramErrorCode, RUNTIME_MESSAGES_ENABLED, RuntimeErrorCode, ServerErrorCode, StyleErrorCode, frameworkError, raiseFrameworkError } from "./errors.js";
|
|
5
6
|
import { FORBIDDEN_ATTRIBUTE_NAMES, FORBIDDEN_PROPERTY_NAMES, RAW_TEXT_TAGS, camelToKebab, forbiddenSinkReason, isSafeAttributeName } from "./forbidden-sinks.js";
|
|
6
7
|
import { HYDRATION_STRATEGIES } from "./framework.js";
|
|
7
8
|
import { ISLAND_ADMISSION } from "./island-admission.js";
|
|
8
9
|
import "./island.js";
|
|
9
10
|
import "./manifest.js";
|
|
11
|
+
import "./module-descriptors.js";
|
|
10
12
|
import { ROUTER_MODULE_VOCABULARY } from "./module-vocabulary.js";
|
|
11
13
|
import { VOID_TAGS } from "./void-tags.js";
|
|
12
|
-
import {
|
|
14
|
+
import { DATA_OE_LIGHT, PART_PROGRAM_VERSION, STATIC_STYLES_MARKER, conditionLiteralAllowed, isAttributeName, partAnchorEndMarker, partAnchorMarker, validatePartProgram } from "./part-program.js";
|
|
13
15
|
import { IDLE_FALLBACK_TIMEOUT_MS, MAX_ACTION_BODY_BYTES, MAX_COMPOSITION_DEPTH, STREAM_MAX_FIELDS, STREAM_MAX_OWNERS, STREAM_MAX_PAYLOAD_LENGTH, STREAM_MAX_SEED_PROPERTIES, STREAM_TIMEOUT_MS } from "./policy.js";
|
|
14
|
-
import { ENTRY_REGISTRATION_OWNERS, SSR_REGISTRY_ORIGINAL_DEFINE, SSR_REGISTRY_STUB_MARKER } from "./registry-markers.js";
|
|
16
|
+
import { ENTRY_REGISTRATION_OWNERS, SSR_REGISTRY_GENERATED_HOSTS, SSR_REGISTRY_ORIGINAL_DEFINE, SSR_REGISTRY_STUB_MARKER } from "./registry-markers.js";
|
|
15
17
|
import "./render.js";
|
|
16
18
|
import "./runtime.js";
|
|
17
19
|
import { SIGNAL_BRAND } from "./signal.js";
|
|
18
20
|
import "./ssg.js";
|
|
19
21
|
import { STREAM_FRAME_FORBIDDEN_TAGS, STREAM_FRAME_UNSAFE_URL, STREAM_FRAME_URL_ATTRIBUTES, STREAM_FRAME_URL_CONTROL_MAX, unsafeStreamFrameAttribute } from "./stream-frame-policy.js";
|
|
20
|
-
import "./style-sheet.js";
|
|
21
|
-
export { ACTION_FETCH_HEADER, AuthoringErrorCode,
|
|
22
|
+
import { NESTED_HOST_EXPANDER, STYLE_SHEET_LIVE, STYLE_SHEET_READY, STYLE_SHEET_URL } from "./style-sheet.js";
|
|
23
|
+
export { ACTION_FETCH_HEADER, AuthoringErrorCode, ClaimErrorCode, CompilerErrorCode, ContextErrorCode, DATA_OE_LIGHT, DEFAULT_RENDER_ERROR_CODE, DIAGNOSTIC_REPORT_FORMAT, DiagnosticReportParseError, EMPTY_CLIENT_ASSET_MANIFEST, ENTRY_REGISTRATION_OWNERS, ERROR_PREFIX, EachKeyErrorCode, ErrorCode, FORBIDDEN_ATTRIBUTE_NAMES, FORBIDDEN_PROPERTY_NAMES, FacadeErrorCode, HYDRATION_STRATEGIES, IDLE_FALLBACK_TIMEOUT_MS, ISLAND_ADMISSION, KernelErrorCode, MAX_ACTION_BODY_BYTES, MAX_COMPOSITION_DEPTH, NESTED_HOST_EXPANDER, OpenElementError, PART_PROGRAM_VERSION, PROBLEM_JSON_MEDIA_TYPE, ProgramErrorCode, RAW_TEXT_TAGS, ROUTER_MODULE_VOCABULARY, RUNTIME_MESSAGES_ENABLED, RuntimeErrorCode, SIGNAL_BRAND, SSR_REGISTRY_GENERATED_HOSTS, SSR_REGISTRY_ORIGINAL_DEFINE, SSR_REGISTRY_STUB_MARKER, STATIC_STYLES_MARKER, STREAM_FRAME_FORBIDDEN_TAGS, STREAM_FRAME_UNSAFE_URL, STREAM_FRAME_URL_ATTRIBUTES, STREAM_FRAME_URL_CONTROL_MAX, STREAM_MAX_FIELDS, STREAM_MAX_OWNERS, STREAM_MAX_PAYLOAD_LENGTH, STREAM_MAX_SEED_PROPERTIES, STREAM_TIMEOUT_MS, STYLE_SHEET_LIVE, STYLE_SHEET_READY, STYLE_SHEET_URL, ServerErrorCode, StyleErrorCode, VOID_TAGS, camelToKebab, conditionLiteralAllowed, diagnosticReport, errorToEnvelope, forbiddenSinkReason, frameworkError, isAttributeName, isSafeAttributeName, parseDiagnosticReport, partAnchorEndMarker, partAnchorMarker, raiseFrameworkError, serializeClientAssetsModule, serializeDiagnosticReport, unsafeStreamFrameAttribute, validatePartProgram };
|
package/src/island.d.ts
CHANGED
|
@@ -35,6 +35,20 @@ export interface IslandTransformOptions {
|
|
|
35
35
|
islandsDir: string;
|
|
36
36
|
/** Absolute or relative file path of the source being processed */
|
|
37
37
|
filePath: string;
|
|
38
|
+
/**
|
|
39
|
+
* Layout-convention admission (alpha15 R batch 3): the resolved layout
|
|
40
|
+
* module the router convention owns (`app/layout.tsx`, tag `app-layout`,
|
|
41
|
+
* or a project-relative custom `layout: { import }` override). The gate
|
|
42
|
+
* admits this one path with its resolved tag even though it lives outside
|
|
43
|
+
* `islandsDir`. Absent when the project configures no layout module
|
|
44
|
+
* (`layout: false`, or the deletable convention file is gone).
|
|
45
|
+
*/
|
|
46
|
+
layout?: {
|
|
47
|
+
/** Project-relative layout module path (e.g. "app/layout.tsx") */
|
|
48
|
+
path: string;
|
|
49
|
+
/** Resolved layout tag (e.g. "app-layout") */
|
|
50
|
+
tagName: string;
|
|
51
|
+
};
|
|
38
52
|
}
|
|
39
53
|
/** The island transform output: rewritten source plus extracted facts. */
|
|
40
54
|
export interface IslandTransformResult {
|
package/src/manifest.d.ts
CHANGED
|
@@ -25,6 +25,33 @@ export interface OpenElementCssPart {
|
|
|
25
25
|
name: string;
|
|
26
26
|
description?: string;
|
|
27
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* A declaration's utility-compilation requirement and the package-owned style
|
|
30
|
+
* sources that requirement compiles (the declared-compilation contract; see
|
|
31
|
+
* the router's `style-plan` module for the resolution rules).
|
|
32
|
+
*
|
|
33
|
+
* `required` is the mandatory-compilation dependency: the component's
|
|
34
|
+
* presentation cannot be delivered without the compile, so an application that
|
|
35
|
+
* disables the entry (`tailwind: false`) fails the build with a coded
|
|
36
|
+
* diagnostic instead of shipping an unstyled component. Merely offering a theme
|
|
37
|
+
* source is NOT a requirement — leave `required` unset for a source a consumer
|
|
38
|
+
* may adopt on its own.
|
|
39
|
+
*
|
|
40
|
+
* `sources` are package-relative paths (e.g. `./theme.css`) resolved against
|
|
41
|
+
* THIS package, so a consumer never repeats the owner's declaration. They must
|
|
42
|
+
* exist in the installed package (i.e. ship in the tarball).
|
|
43
|
+
*
|
|
44
|
+
* `dialect` names the CLASS LANGUAGE this component's utility tokens are
|
|
45
|
+
* written in, not the engine that compiles them: the declaration stays
|
|
46
|
+
* provider-neutral, and a selected provider that does not implement the
|
|
47
|
+
* dialect fails the build before any compile. Omitted means `tailwind4` — the
|
|
48
|
+
* language every declaration written before this field existed uses.
|
|
49
|
+
*/
|
|
50
|
+
export interface OpenElementTailwindDeclaration {
|
|
51
|
+
required?: boolean;
|
|
52
|
+
sources?: string[];
|
|
53
|
+
dialect?: 'tailwind4';
|
|
54
|
+
}
|
|
28
55
|
/** The openElement-specific extension block of a package manifest declaration. */
|
|
29
56
|
export interface OpenElementExtensions {
|
|
30
57
|
ssr?: boolean;
|
|
@@ -35,6 +62,38 @@ export interface OpenElementExtensions {
|
|
|
35
62
|
status?: 'stable' | 'experimental';
|
|
36
63
|
module?: string;
|
|
37
64
|
export?: string;
|
|
65
|
+
tailwind?: OpenElementTailwindDeclaration;
|
|
66
|
+
/**
|
|
67
|
+
* The host root a generated-element declaration was compiled with. Absent for
|
|
68
|
+
* a class declaration (its descriptor owns the root) and for a generated
|
|
69
|
+
* declaration whose sidecar declares none (the descriptor default is light).
|
|
70
|
+
*/
|
|
71
|
+
root?: 'light' | 'shadow' | 'closed';
|
|
72
|
+
/**
|
|
73
|
+
* The authored package-relative `.css` specifiers a generated SHADOW host
|
|
74
|
+
* declares, published so a consuming build can emit the sheet and hand its
|
|
75
|
+
* URL to the DSD style-link carrier. Absent when the component declares none;
|
|
76
|
+
* class declarations deliver their sheets through `static styles` instead.
|
|
77
|
+
*/
|
|
78
|
+
styles?: readonly string[];
|
|
79
|
+
/**
|
|
80
|
+
* The compiler-emitted SSR host producer's export name
|
|
81
|
+
* (`<Component>__ssrHost`) for a generated declaration whose root is
|
|
82
|
+
* `shadow`.
|
|
83
|
+
*
|
|
84
|
+
* A consuming build cannot otherwise learn it: the name is the compiler's
|
|
85
|
+
* return-only `ssrHostExport` metadata, and re-deriving it from a naming
|
|
86
|
+
* convention inside the router would be exactly the drift ADR-0182 forbids
|
|
87
|
+
* ("read the compiler's return value, never re-derive it"). With it, a
|
|
88
|
+
* package island can be paired through the SAME `__registerSsrIsland` channel
|
|
89
|
+
* a local island uses, so its SSR emits the DSD template and the client can
|
|
90
|
+
* claim it.
|
|
91
|
+
*
|
|
92
|
+
* Absent for a class declaration and for a LIGHT-root generated declaration
|
|
93
|
+
* (a light root serializes through the shell-attached `__ssr` static instead,
|
|
94
|
+
* which the entry resolves from the class).
|
|
95
|
+
*/
|
|
96
|
+
ssrHostExport?: string;
|
|
38
97
|
}
|
|
39
98
|
/** One custom element declaration in a package manifest: tag, members and delivery metadata. */
|
|
40
99
|
export interface OpenElementDeclaration {
|
package/src/module-vocabulary.js
CHANGED
|
@@ -1,21 +1,13 @@
|
|
|
1
1
|
//#region src/module-vocabulary.ts
|
|
2
2
|
/** The module vocabulary router injects into `analyzeModuleSemantics`. */
|
|
3
|
-
const ROUTER_MODULE_VOCABULARY = [
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
kind: "page-definition"
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
moduleSpecifier: "@openelement/router",
|
|
16
|
-
exportName: "defineElement",
|
|
17
|
-
kind: "element-registration"
|
|
18
|
-
}
|
|
19
|
-
];
|
|
3
|
+
const ROUTER_MODULE_VOCABULARY = [{
|
|
4
|
+
moduleSpecifier: "@openelement/router",
|
|
5
|
+
exportName: "definePage",
|
|
6
|
+
kind: "page-definition"
|
|
7
|
+
}, {
|
|
8
|
+
moduleSpecifier: "@openelement/router",
|
|
9
|
+
exportName: "defineElement",
|
|
10
|
+
kind: "element-registration"
|
|
11
|
+
}];
|
|
20
12
|
//#endregion
|
|
21
13
|
export { ROUTER_MODULE_VOCABULARY };
|
package/src/part-program.d.ts
CHANGED
|
@@ -1,21 +1,7 @@
|
|
|
1
1
|
import { VOID_TAGS } from "./void-tags.js";
|
|
2
2
|
//#region src/part-program.d.ts
|
|
3
|
-
/** The Part Program IR version this package defines (currently
|
|
4
|
-
export declare const PART_PROGRAM_VERSION:
|
|
5
|
-
/**
|
|
6
|
-
* Version of the compiled-module ABI: the statics a generated module carries
|
|
7
|
-
* (`__partProgram`, `__compiledProperties`, `__elementMetadata`,
|
|
8
|
-
* `__observedAttributes`, `__computedFields`) and the runtime facade binds.
|
|
9
|
-
* Bump when the generated-module contract changes shape; generated artifacts
|
|
10
|
-
* stamp both this and PART_PROGRAM_VERSION so consumers can tell format drift
|
|
11
|
-
* from release drift.
|
|
12
|
-
*
|
|
13
|
-
* v2: platform lifecycle callback bodies are emitted inside a
|
|
14
|
-
* boundary-capture wrapper calling the base class's `_captureError` — a
|
|
15
|
-
* generated module now requires a runtime facade carrying that protected
|
|
16
|
-
* method (the v1 shape emitted the bodies verbatim).
|
|
17
|
-
*/
|
|
18
|
-
export declare const COMPILED_MODULE_ABI_VERSION: 2;
|
|
3
|
+
/** The Part Program IR version this package defines (currently v2). */
|
|
4
|
+
export declare const PART_PROGRAM_VERSION: 2;
|
|
19
5
|
/** How the compiled component attaches its root: light DOM or a shadow root. */
|
|
20
6
|
export type RootMode = 'light' | 'shadow-open' | 'shadow-closed';
|
|
21
7
|
/** The root of one program tree: element, part anchor, or text. */
|
|
@@ -227,7 +213,7 @@ export interface ProgramCondition {
|
|
|
227
213
|
value: number | string | boolean;
|
|
228
214
|
}
|
|
229
215
|
/**
|
|
230
|
-
* Operator/literal compatibility for when-
|
|
216
|
+
* Operator/literal compatibility for when-Block tests (issue #1372). Both
|
|
231
217
|
* wire validators (this module and the server serializer's shared validator)
|
|
232
218
|
* close the space through this one predicate:
|
|
233
219
|
* - ordering operators require a finite numeric literal;
|
|
@@ -246,8 +232,8 @@ export interface ProgramWhenPart {
|
|
|
246
232
|
location: ProgramLocation;
|
|
247
233
|
}
|
|
248
234
|
/**
|
|
249
|
-
* An event binding scoped to each item of an `each`
|
|
250
|
-
* attaches this listener to every item root node created by the
|
|
235
|
+
* An event binding scoped to each item of an `each` block. The runtime
|
|
236
|
+
* attaches this listener to every item root node created by the block,
|
|
251
237
|
* making per-item handlers (onClick={this.select(row.id)}) expressible
|
|
252
238
|
* without fixed-path event parts.
|
|
253
239
|
*/
|
|
@@ -283,8 +269,8 @@ export interface ProgramEachPart {
|
|
|
283
269
|
}
|
|
284
270
|
/** The discriminated union of dynamic parts a program instantiates. */
|
|
285
271
|
export type ProgramPart = ProgramTextPart | ProgramPropPart | ProgramAttrPart | ProgramBoolPart | ProgramClassPart | ProgramStylePart | ProgramHtmlPart | ProgramRefPart | ProgramEventPart | ProgramWhenPart | ProgramEachPart;
|
|
286
|
-
/** One
|
|
287
|
-
export interface
|
|
272
|
+
/** One block the program tracks: the boundaries of a dynamic subtree. */
|
|
273
|
+
export interface ProgramBlockRecord {
|
|
288
274
|
id: string;
|
|
289
275
|
index: number;
|
|
290
276
|
kind: 'when' | 'each';
|
|
@@ -355,13 +341,13 @@ export interface CompiledElementMetadata {
|
|
|
355
341
|
cem: CompiledCemMetadata;
|
|
356
342
|
}
|
|
357
343
|
/** The one deterministic program consumed by all execution modes. */
|
|
358
|
-
export interface
|
|
344
|
+
export interface PartProgramV2 {
|
|
359
345
|
version: typeof PART_PROGRAM_VERSION;
|
|
360
346
|
tag: string;
|
|
361
347
|
root: ProgramRoot;
|
|
362
348
|
template: ProgramTreeNode[];
|
|
363
349
|
parts: ProgramPart[];
|
|
364
|
-
|
|
350
|
+
blocks: ProgramBlockRecord[];
|
|
365
351
|
dependencies: ProgramDependencyRecord[];
|
|
366
352
|
locations: ProgramLocationRecord[];
|
|
367
353
|
/**
|
|
@@ -373,15 +359,15 @@ export interface PartProgramV1 {
|
|
|
373
359
|
sourceMap: ProgramSourceMap;
|
|
374
360
|
metadata: CompiledElementMetadata;
|
|
375
361
|
}
|
|
376
|
-
/** The serializable Part Program
|
|
377
|
-
export type PartProgram =
|
|
362
|
+
/** The serializable Part Program v2: one compiled component as data. */
|
|
363
|
+
export type PartProgram = PartProgramV2;
|
|
378
364
|
/** Anchor marker payloads shared by seed runtime consumers. */
|
|
379
365
|
export declare function partAnchorMarker(index: number): string;
|
|
380
366
|
/** The comment marker closing a part anchor in serialized program markup. */
|
|
381
367
|
export declare function partAnchorEndMarker(index: number): string;
|
|
382
368
|
/**
|
|
383
369
|
* The one `<style>` element the server serializer emits as the first DSD
|
|
384
|
-
* template child when the class carries static styles (
|
|
370
|
+
* template child when the class carries static styles (renderToString
|
|
385
371
|
* parity — pages never upgrade, so their styles must ship in the payload).
|
|
386
372
|
* The claim path skips exactly this marked node; a marked node on a
|
|
387
373
|
* style-less class is claim drift and fails closed.
|
|
@@ -403,7 +389,7 @@ export declare const DATA_OE_LIGHT = "data-oe-light";
|
|
|
403
389
|
*/
|
|
404
390
|
export declare function isAttributeName(value: unknown): value is string;
|
|
405
391
|
/**
|
|
406
|
-
* Validate an unknown value as a Part Program
|
|
392
|
+
* Validate an unknown value as a Part Program v2. The validator is intentionally
|
|
407
393
|
* strict: unknown instruction kinds, missing ownership records and unsafe paths
|
|
408
394
|
* fail before a runtime can guess at their meaning.
|
|
409
395
|
*/
|