API 参考
查阅 v1.0.0-alpha.16 的导入路径、签名和配置选项。
从路由和组件开始
6 个受支持的包
@openelement/protocol
@openelement/protocol编译模板、渲染、路由和错误共用的类型。
应用通常从 router 或 element 包导入这些类型。@openelement/element
@openelement/element将组件函数编译为浏览器原生自定义元素后,用这个运行时渲染和运行它们。
用组件函数编写自定义元素,并导出其配置。从包根导入 `signal` 管理响应式状态,用 `StyleSheet` 编写组件样式。@openelement/compiler
@openelement/compiler在构建时编译 TSX 组件函数。
不使用 router 构建组件时,将它安装为开发依赖。通常通过 `@openelement/router` 构建驱动;独立插件在 `@openelement/compiler/vite`。@openelement/router
@openelement/router应用与构建面:页面、路由、island、请求/渲染语义、Vite 集成、静态生成与 Nitro 输出。
用 `definePage` 与 `defineIslandConfig` 进行应用创作。构建使用 `@openelement/router/vite` 的 `openPipeline()`/`openElement()` 或生成的构建任务。插件顺序、manifest 与内容扫描属于 router 的实现细节。@openelement/create
@openelement/create生成起步应用并安装依赖。
生成的项目暴露 `dev`、`check`、`test`、`build`、`start` 与 `preview`。@openelement/ui
@openelement/ui可选的现成自定义元素,包括按钮、输入框和对话框。
导出的符号
用 Page Up 或 Page Down 翻页,用 ↑ 或 ↓ 选择导出项。按 Tab 进入长签名、说明或链接,用 ← 或 → 横向阅读签名,按 Esc 返回列表。打开“随页面滚动此列表”可用页面的滚动条浏览。
@openelement/protocol
433 个导出处理页面路由的表单提交。
Action<T, Env, Platform, Route>英文源码说明
Route action: handles form submissions for a page route.
packages/protocol/src/data.ts:64选择表单 action 的响应通道。true 返回序列化结果,enhance 返回与无脚本提交相同的 HTML。
"x-openelement-action"英文源码说明
Request header selecting the action response channel: `true` marks a programmatic caller and selects the serialized ActionResult union; `enhance` marks the built-in morph enhancement and selects the same full-HTML responses the no-JS path receives.
packages/protocol/src/data.ts:125传给路由 action 的上下文,包含 loader 上下文。
ActionContext<Env, Platform, Route>英文源码说明
Context passed to a route action function (extends loader context).
packages/protocol/src/data.ts:47脚本提交表单时返回的联合类型。校验失败返回 failure,成功提交返回 redirect;协议错误使用 ProblemDetails。
ActionResult<Failure>英文源码说明
Wire shape returned to the JavaScript form-enhancement path. The no-JS path never sees this: it gets the equivalent semantics as plain HTTP (303 on success, 422 with the re-rendered form on validation failure, redirect/error as status codes). Success carries no data envelope. The application-loop contract makes a successful non-GET action answer 303 (PRG) — the framework never answers 200 with a rendered page, or with a success document, for a successful mutation — so the fetch channel answers `{ type: 'redirect' }` naming the PRG target and the authored return value is discarded by design. Success data travels the PRG target instead (query state the loader re-runs with, which the props projector then maps; see the router guide's "Form actions" section). The union previously declared a `{ type: 'success' }` member that no code path ever emitted — removed so the type matches the wire. Error outcomes (CSRF 403, unknown action 404, unparseable body 400, unexpected 500) are NOT part of this union: since #863 they answer RFC 9457 Problem Details with the PROBLEM_JSON_MEDIA_TYPE content type — see ProblemDetails.
packages/protocol/src/data.ts:92生成入口描述符中的一条 API 路由声明。
ApiRouteDecl英文源码说明
One API route declaration in the generated entry descriptor.
packages/protocol/src/ssg.ts:163编写组件的属性或声明时可能遇到的校验错误码。
{ readonly INVALID_TAG_NAME: "OE_INVALID_TAG_NAME"; readonly UNSAFE_META_ATTRIBUTE: "OE_UNSAFE_META_ATTRIBUTE"; readonly UNSAFE_ATTRIBUTE_NAME: "OE_UNSAFE_ATTRIBUTE_NAME"; readonly UNSAFE_URL_SINK: "OE_UNSAFE_URL_SINK";…英文源码说明
Attribute/authoring-surface failures (phase `validation`).
packages/protocol/src/errors.ts:301openElement 构建流程返回的产物。
BuildArtifacts英文源码说明
Result returned by the OpenElement build pipeline.
packages/protocol/src/ssg.ts:565构建流水线输出的一项客户端资源。
BuildClientAsset英文源码说明
A single client asset emitted by the build pipeline.
packages/protocol/src/ssg.ts:558构建流水线的国际化配置。
BuildI18nOptions英文源码说明
i18n configuration for the build pipeline.
packages/protocol/src/ssg.ts:511构建流水线接收的一项交互岛输入。
BuildIslandInput英文源码说明
A single island input to the build pipeline.
packages/protocol/src/ssg.ts:492构建流水线输出的清单产物。
BuildManifestArtifact英文源码说明
Manifest produced by the build pipeline.
packages/protocol/src/ssg.ts:547构建流水线的输出配置。
BuildOutputOptions英文源码说明
Output configuration for the build pipeline.
packages/protocol/src/ssg.ts:501构建流水线中由包提供的交互岛的配置。
BuildPackageIslandOptions英文源码说明
Package island configuration for the build pipeline.
packages/protocol/src/ssg.ts:517一份生成的 HTML 页面产物。
BuildPageArtifact英文源码说明
A single generated HTML page artifact.
packages/protocol/src/ssg.ts:539openElement 构建流水线接收的框架无关构建计划。
BuildPlan英文源码说明
Framework-agnostic plan consumed by the OpenElement build pipeline.
packages/protocol/src/ssg.ts:523构建流水线接收的一条路由输入。
BuildRouteInput英文源码说明
A single route input to the build pipeline.
packages/protocol/src/ssg.ts:474(str: string): string英文源码说明
The one camelCase → kebab-case casing rule for custom-element attribute names, so `<x-el itemCount={5}>` round-trips as `item-count` on every boundary that derives an attribute name from a prop name: the compiler's property metadata, the SSR serializer, and the client attribute handling.
packages/protocol/src/forbidden-sinks.ts:95针对一份自定义元素清单的兼容性分类报告。
CemCompatibilityReport英文源码说明
The compatibility classification report for one custom element manifest.
packages/protocol/src/manifest.ts:146编译生成的自定义元素清单中的单个属性记录。
CemPropertyMetadata英文源码说明
One property entry of the compiled custom-elements-manifest metadata.
packages/protocol/src/part-program.ts:381现有 DOM 与即将接管它的程序不匹配时使用的错误码。
{ readonly STRUCTURE_MISMATCH: "OPEN_ELEMENT_COMPILED_CLAIM_MISMATCH"; readonly PRE_UPGRADE_EVENTS_INVALID: "OE_CLAIM_PRE_UPGRADE_EVENTS_INVALID"; readonly DYNAMIC_NODE_IN_STATIC_REGION: "OE_CLAIM_DYNAMIC_NODE_IN_STATIC…英文源码说明
Claim failures: the existing DOM does not match the program that would own it. The value shipped in 1.0.0-alpha.3 and is kept verbatim; consumers match on it, and `PartProgramHydrationError` is its only raiser.
packages/protocol/src/errors.ts:265客户端构建的交付清单,以交互岛标识为索引。
ClientAssetManifest英文源码说明
The Phase 2 client build's delivery manifest, keyed by island identity.
packages/protocol/src/client-assets.ts:36一个编译期交互岛标识对应的客户端资源。
ClientIslandAsset英文源码说明
The client asset one compile-time island identity resolves to.
packages/protocol/src/client-assets.ts:19传给入口生成器的客户端交互岛条目结构。
ClientIslandEntry英文源码说明
Client island entry shape passed to entry generator.
packages/protocol/src/ssg.ts:105兼容性扫描为每个标签记录分级、原因、来源和对应的 SSR、DSD 与 hydration 判定依据。
CompatibilityClassification英文源码说明
The per-tag verdict the compatibility scanner records: the tier a discovered tag was classified as, the human-readable `reason`, where the tag was found (`source`), and the SSR/DSD/hydration facts the verdict was derived from.
packages/protocol/src/framework.ts:347标签的构建兼容级别,区分服务端渲染、仅浏览器渲染、实验支持和拒绝构建。
CompatibilityTier英文源码说明
How far a discovered tag may participate in the build: 'ssr-capable' renders and hydrates, 'client-only' ships to the browser without server output, 'experimental-dom' is admitted with a downgraded guarantee, and 'rejected' fails the build.
packages/protocol/src/framework.ts:340一个组件编译生成的自定义元素清单元数据。
CompiledCemMetadata英文源码说明
The compiled custom-elements-manifest metadata block of one component.
packages/protocol/src/part-program.ts:390程序提供给工具读取的编译元素元数据。
CompiledElementMetadata英文源码说明
The compiled element metadata the program carries for tooling consumers.
packages/protocol/src/part-program.ts:399编译后的单个 @property 声明,记录名称、类型和反射设置。
CompiledPropertyMetadata英文源码说明
One compiled
packages/protocol/src/part-program.ts:362编译期间使用的错误码。
{ readonly DIAGNOSTICS: "OE_COMPILER_DIAGNOSTICS"; readonly INVALID_SOURCE: "OE_COMPILER_INVALID_SOURCE"; }英文源码说明
Compiler (build-time) failures. The per-diagnostic `OEC####` codes stay on each diagnostic; these classify the family so a build failure is catchable as one thing.
packages/protocol/src/errors.ts:293组件的交付层级,区分静态 DSD、带交互岛的 DSD、仅客户端交互岛和 Light DOM。
ComponentLayer英文源码说明
The delivery layer a component belongs to: fully static DSD markup ('dsd-static'), DSD markup with a client island ('dsd-interactive'), a client-only island with no SSR output ('pure-island'), or a light-DOM element ('light-dom'). Recorded per component in the build manifest and consumed by the hydration scheduler.
packages/protocol/src/framework.ts:23判断比较运算符与 when 区块中的字面量类型是否兼容。
(op: unknown, value: unknown): boolean英文源码说明
Operator/literal compatibility for when-Block tests (issue #1372). Both wire validators (this module and the server serializer's shared validator) close the space through this one predicate: - ordering operators require a finite numeric literal; - `equals`/`not-equals` admit a finite number, string, or boolean; - `truthy` admits exactly `true` or `false` (the recorded expectation).
packages/protocol/src/part-program.ts:260编译程序的条件表达式所支持的比较运算符。
ConditionOperator英文源码说明
The comparison operators a program condition supports.
packages/protocol/src/part-program.ts:236Context Community Protocol 服务的生命周期错误码,发生在 csr 阶段。
{ readonly SERVICE_DISPOSED: "OE_CONTEXT_SERVICE_DISPOSED"; }英文源码说明
Community-context service lifecycle failures (phase `csr`).
packages/protocol/src/errors.ts:233API 路由声明的 CORS 来源策略。
CorsOriginConfig英文源码说明
The CORS origin policy an API route declares.
packages/protocol/src/ssg.ts:130路由或文档声明的内容安全策略(CSP)指令。
CspConfig英文源码说明
The content-security-policy directives a route or document declares.
packages/protocol/src/ssg.ts:133标识由服务端渲染的 Light DOM 宿主标签的内部属性。
"data-oe-light"英文源码说明
Internal SSR provenance marker on light-mode host tags (#1148). Present only when the host's light subtree was server-rendered under the in-place activation contract: the client binds the existing DOM instead of clearing it, and a parent's activation walk prunes the nested host's subtree. Client rendering never writes it and it is never removed. The writer (internal/compiled/server) and readers (internal/compiled/runtime) import this constant; nothing writes the literal.
packages/protocol/src/part-program.ts:459RenderError 使用的默认错误码。
"RENDER_ERROR"英文源码说明
Default code for {@linkcode RenderError }. Deliberately NOT a member of {@linkcode ErrorCode}: that object is the scan target of the documentation site's error catalog, which requires every member to carry a phase/severity family rule. `RENDER_ERROR` is the pre-dialect value `RenderError` has always defaulted to — kept verbatim so callers that observe it keep working, and kept out of the catalogue because it is not a failure this package classifies, only a constructor default a caller may override.
packages/protocol/src/errors.ts:47用于识别诊断报告格式的 format 字段值。
"openelement.diagnostics/1"英文源码说明
The `format` discriminator every report carries. Consumers branch on it instead of guessing: a future shape change mints a new tag rather than reinterpreting old bytes.
packages/protocol/src/diagnostics.ts:84DiagnosticEnvelope英文源码说明
One machine-readable diagnostic: the producer's stable code, where the failure sits (`file`, `line`, `column` — absent when the producer has no source location, e.g. a configuration refusal), what happened (`message`), and when known, the fix (`hint`). `line`/`column` are 1-based, matching the diagnostics the compiler records from TypeScript source positions. Unknown envelope fields are tolerated on the wire (forward compat); the required core is exactly these fields.
packages/protocol/src/diagnostics.ts:60DiagnosticPhase英文源码说明
The pipeline phase a diagnostic was raised in — the same vocabulary the error contract's {@linkcode ErrorPhase } uses, so a producer's code, phase and envelope cannot disagree about where a failure happened.
packages/protocol/src/diagnostics.ts:39组装构建退出报告。只要一个诊断的严重级别为 error,报告即标为失败。
(diagnostics: DiagnosticEnvelope[]): DiagnosticReport英文源码说明
Assemble the exit's report. `ok` derives from the diagnostics' severities, never from a caller's optimism: one `error` severity is enough to fail it.
packages/protocol/src/diagnostics.ts:105DiagnosticReport英文源码说明
One build exit's diagnostics: the format tag, whether the run is clean (`ok` is false the moment any diagnostic carries severity `error`), and every diagnostic the exit collected. This is the document the CLI writes to the stream and the diagnostics file — one aggregate containing every code.
packages/protocol/src/diagnostics.ts:95诊断报告 format 字段使用的格式标识类型。
"openelement.diagnostics/1"英文源码说明
One format tag value (kept as a type for the report's `format` field).
packages/protocol/src/diagnostics.ts:87parseDiagnosticReport 发现文本不是可读取的诊断报告时抛出的错误。
class DiagnosticReportParseError extends Error英文源码说明
Raised by {@linkcode parseDiagnosticReport} when the text is not a consumable report. Fail closed: a consumer that catches this knows the channel answered garbage — never a half-valid report.
packages/protocol/src/diagnostics.ts:123区分导致构建失败的 error、可恢复问题 warning 和提示信息 info。
DiagnosticSeverity英文源码说明
How severe one diagnostic is. `error` fails the build, `warning` reports a recoverable defect, `info` is reserved for advisories. The build report's `ok` flag derives from this: any `error` diagnostic makes the report not-ok.
packages/protocol/src/diagnostics.ts:32构建时写入生成入口的文档级配置。
DocumentConfig英文源码说明
The document-level facts a build bakes into the generated entry.
packages/protocol/src/ssg.ts:286带键列表无法确定条目身份时使用的错误码。
{ readonly ITEM_NOT_A_RECORD: "OE_EACH_ITEM_NOT_A_RECORD"; readonly KEY_NOT_ROUND_TRIPPABLE: "OE_EACH_KEY_NOT_ROUND_TRIPPABLE"; readonly DUPLICATE_KEY: "OE_EACH_KEY_DUPLICATE"; }英文源码说明
Keyed-list identity failures. Shared by the server serializer and the client runtime (see `internal/compiled/each-key.ts`), so both executors reject the same data with the same code.
packages/protocol/src/errors.ts:159没有客户端包的项目使用的资源清单。
ClientAssetManifest英文源码说明
The manifest a project without a client bundle carries.
packages/protocol/src/client-assets.ts:54"__openEntryDefined"英文源码说明
Property on the stub holding the generated entry's registration-ownership map (tag -> class it registered): a route module that self-registers its tag wins over the entry's registration, and on dev re-evaluation a fresh self-registered class must still win (#952).
packages/protocol/src/registry-markers.ts:30一个生成入口的完整构建描述,包含路由、交互岛、渲染器、中间件、文档和布局计划。
EntryDescriptor英文源码说明
The full build-time description of one generated entry: routes, islands, renderers, middleware, document, and layout plans.
packages/protocol/src/ssg.ts:321openElement 错误消息使用的前缀。
"[openElement]"英文源码说明
Error message prefix for all openElement errors.
packages/protocol/src/errors.ts:50常用错误码常量。调用方也可以传入字符串错误码。
{ readonly SSR_RENDER_ERROR: "SSR_RENDER_ERROR"; readonly BOUNDARY_CAUGHT: "BOUNDARY_CAUGHT"; readonly UNKNOWN: "UNKNOWN"; }英文源码说明
Well-known error code constants for reference. String values are always accepted.
packages/protocol/src/errors.ts:31发生错误时所在的执行阶段。
ErrorPhase英文源码说明
The pipeline phase an error was raised in.
packages/protocol/src/errors.ts:80框架错误的严重程度。
ErrorSeverity英文源码说明
How severe a framework error is.
packages/protocol/src/errors.ts:78接收所有通过错误遥测渠道上报的 OpenElementError。
ErrorTelemetryHook英文源码说明
Callback receiving every reported {@linkcode OpenElementError} for telemetry.
packages/protocol/src/errors.ts:132将 OpenElementError 转换为统一的诊断记录结构。
(error: OpenElementError, options?: { hint?: string; }): DiagnosticEnvelope英文源码说明
Map the one error dialect ({@linkcode OpenElementError} — every producer's raiser goes through it) onto the envelope. The error's code, severity and phase ARE the envelope's; the message carries verbatim. Producers with a fix pass it as `hint`.
packages/protocol/src/diagnostics.ts:256公开入口在 SSR 渲染或客户端启动时使用的错误码。
{ readonly PROGRAM_MISSING: "OE_PROGRAM_MISSING"; readonly COMPOSITION_DEPTH: "OE_SSR_COMPOSITION_DEPTH"; readonly COMPUTED_FACTORY_MISSING: "OE_COMPUTED_FACTORY_MISSING"; readonly COMPUTED_READONLY: "OE_COMPUTED_READON…英文源码说明
SSR/bootstrap failures raised by the public entries (phase `ssr` / `csr`).
packages/protocol/src/errors.ts:328ReadonlySet<string>英文源码说明
Forbidden sink names — the ONE canonical deny list for every Part Program boundary: the compiler semantic core, the protocol validator (internal/protocol/part-program.ts), and the compiled server/claim validator (internal/compiled/server/shared.ts). This module is import-free and host-free by design (same base-of-graph contract as void-tags.ts): all consumers import it, so a new forbidden sink cannot be enforced on one boundary and missed on another. This module owns the named-sink deny lists and the attribute-name policy built on them (the one shared safe-attribute-name predicate and the one camelCase→kebab-case casing rule); consumers delegate so the boundary cannot diverge. The lists are fail closed and case-insensitive (attribute and property names are compared lowercase, matching the HTML parser's name folding): - `FORBIDDEN_ATTRIBUTE_NAMES`: attribute names that must never be a static attribute or an `attr`/`bool` sink. `srcdoc` smuggles a full HTML document past attribute escaping; `innerHTML` is admissible only through the dedicated trusted-HTML `html` Part, never as a plain attribute name. - `FORBIDDEN_PROPERTY_NAMES`: `prop` sink names that would re-prototype or re-construct the target element (prototype-pollution primitives). - `RAW_TEXT_TAGS`: raw-text elements are outside the compiled grammar — their content cannot be escaped by the serializer.
packages/protocol/src/forbidden-sinks.ts:28编译器不允许用作 @property 声明的属性名集合。
ReadonlySet<string>英文源码说明
Property names the compiler refuses as
packages/protocol/src/forbidden-sinks.ts:31统一禁用规则检查的写入目标类别。
ForbiddenSinkKind英文源码说明
Sink categories the canonical deny list classifies.
packages/protocol/src/forbidden-sinks.ts:41返回指定类别下某名称不允许写入的原因,名称可用时返回 null。
(kind: ForbiddenSinkKind, name: string): string | null英文源码说明
Return a human-readable reason when `name` is a forbidden sink of `kind`, or null when the name is admissible. Unknown kinds fail closed with a reason instead of being waved through.
packages/protocol/src/forbidden-sinks.ts:48创建 OpenElementError,使用调用方指定的错误码和阶段,并据此确定级别与可恢复性。
(code: string, message: string, options?: Omit<OpenElementErrorOptions, "code">): OpenElementError英文源码说明
One framework failure: {@linkcode OpenElementError} with the caller's code and the phase/severity/recoverability that phase implies. Every throw site in this package goes through this factory (or the `*ErrorCode` tables above) so a code, a phase and a recoverability answer cannot drift per site.
packages/protocol/src/errors.ts:375FrameworkOptions英文源码说明
The adapter-facing framework options: where routes and islands live, the default layout and named-layout declarations, the document `<html>`/head injection channels, and the request-time middleware switches. Every field is optional; the adapter applies its documented default. This is the type an application config file's default export is checked against, so the rendered option table and the actual config surface cannot drift.
packages/protocol/src/framework.ts:180运行时支持的 hydration 策略列表,以及 HydrationStrategy 联合类型的来源。
readonly ["load", "idle", "visible", "only", "none"]英文源码说明
Runtime list of supported hydration strategies; the single source of truth for the `HydrationStrategy` union. Consumed by island/registry validation and re-exported from the element root for app and build adapters.
packages/protocol/src/framework.ts:28组件或路由携带的水合加载提示。
HydrationHint英文源码说明
The hydration delivery hint a component or route carries.
packages/protocol/src/render.ts:26控制交互岛何时启用,也可跳过浏览器 hydration。
"load" | "idle" | "visible" | "only" | "none"英文源码说明
Island hydration trigger: 'load' | 'idle' | 'visible' | 'only'.
packages/protocol/src/framework.ts:30环境缺少 requestIdleCallback 和 requestAnimationFrame 时,空闲 hydration 的备用延时(毫秒)。
50英文源码说明
Idle-hydration scheduling fallback (milliseconds) when neither `requestIdleCallback` nor `requestAnimationFrame` is available.
packages/protocol/src/policy.ts:70生成入口输出的一条模块导入声明。
ImportDecl英文源码说明
One module import the generated entry emits.
packages/protocol/src/ssg.ts:123线格式校验器用来检查属性名的入口,采用统一校验规则。
(value: unknown): value is string英文源码说明
The wire-validator face of the one canonical attribute-name predicate (delegates to `./forbidden-sinks.ts`); exported for parity tests.
packages/protocol/src/part-program.ts:501路由器交给元素编译器的静态配置识别描述符。
StaticSidecarDescriptor英文源码说明
The static-sidecar descriptor router injects into the element compiler.
packages/protocol/src/island-admission.ts:18构建纳入的一个交互岛的声明,包括标签名、模块路径和加载方式。
IslandDecl英文源码说明
One island the build admits: tag, module path, and delivery facts.
packages/protocol/src/ssg.ts:195由适配器决定的浏览器交付策略,可依据媒体查询决定是否交付。
IslandDeliveryStrategy英文源码说明
Adapter-owned browser delivery strategy, including media-query admission.
packages/protocol/src/ssg.ts:31交互岛记录共用的模块标识,包含注册标签、模块路径及包来源信息。
IslandModuleIdentity英文源码说明
Shared island module identity (CL-3 convergence: one base, three shapes). Every island record names the same module the same way — the tag it registers as, the module path that owns it, and whether that module is a package (CEM-derived named export) rather than a local file (default export) — so a rename of the identity touches one declaration, not three. The delivery-strategy fields intentionally stay per-shape (`strategy` on the client entry vs `hydrate` on the build decls): they are different stages' vocabularies, not one field spelled two ways.
packages/protocol/src/ssg.ts:98交互岛的交付选项,包括 hydration 策略和是否参与 SSR 或 DSD。
IslandOptions英文源码说明
Per-island delivery options (hydration strategy, SSR/DSD participation).
packages/protocol/src/island.ts:8构建时转换交互岛源码所用的选项。
IslandTransformOptions英文源码说明
Options for the build-time island source transform.
packages/protocol/src/island.ts:42交互岛转换的结果,包括改写的源码和提取的信息。
IslandTransformResult英文源码说明
The island transform output: rewritten source plus extracted facts.
packages/protocol/src/island.ts:64统一检查属性名称是否符合安全规则。
(name: string): boolean英文源码说明
The one safe-attribute-name predicate (#1033, #602). Attribute *names* are not escaped on any render path, so a name must be valid HTML attribute-name grammar (blocks quote/space injection), must not be an event handler (`on*`, case-insensitive), and must not be a forbidden sink (`innerhtml`/ `srcdoc` — case-insensitive). Every boundary that admits an attribute name — the compiler semantic core, the Part Program validator, the compiled server validator, and the SSR head/meta name checks — delegates here, so the rules cannot diverge per path.
packages/protocol/src/forbidden-sinks.ts:81每个 each 区块条目内独立生效的事件绑定。
ItemEventBinding英文源码说明
An event binding scoped to each item of an `each` block. The runtime attaches this listener to every item root node created by the block, making per-item handlers (onClick={this.select(row.id)}) expressible without fixed-path event parts.
packages/protocol/src/part-program.ts:295自定义元素在客户端运行期间违反内核生命周期契约时使用的错误码。
{ readonly DISPOSED: "OE_KERNEL_DISPOSED"; readonly TAG_MISMATCH: "OE_KERNEL_TAG_MISMATCH"; readonly CLAIM_EXECUTOR_MISSING: "OE_KERNEL_CLAIM_EXECUTOR_MISSING"; readonly ROOT_NOT_OWNED: "OE_KERNEL_ROOT_NOT_OWNED"; reado…英文源码说明
Element-lifecycle failures: the kernel was driven outside its contract (phase `csr`).
packages/protocol/src/errors.ts:219为路由选择内置布局、指定自定义布局及其模块和属性,或关闭布局。
LayoutConfig英文源码说明
Layout declaration: `false` disables the layout entirely, `'default'` uses the built-in layout, and the object form names a tag with the module path that defines it (`import`, resolved like a {@link FrameworkOptions.middleware.use } entry) plus the compiled layout properties the router injects per route.
packages/protocol/src/framework.ts:96构建解析出的布局模块声明,包含标签名、导入路径和序列化属性。
LayoutDecl英文源码说明
The layout module a build resolves: tag, import path, and serialized props.
packages/protocol/src/ssg.ts:294构建最终交付的布局计划,包含默认布局和具名布局。
LayoutPlan英文源码说明
The resolved layouts a build ships: the default layout plus named layouts.
packages/protocol/src/ssg.ts:315为页面路由获取数据的 loader。
Loader<T, Env, Platform, Route>英文源码说明
Route loader: fetches data for a page route.
packages/protocol/src/data.ts:56传给动态路由 loader 的请求上下文。
LoaderContext<Env, Platform, Route>英文源码说明
Context passed to a request-time ('dynamic') route loader.
packages/protocol/src/data.ts:40随语言解析的路径契约。
LocalePath英文源码说明
Locale-aware resolved path contract.
packages/protocol/src/framework.ts:82生成的服务端入口对 POST action 请求体施加的字节上限。需要上传更大文件时,可使用配置了明确上限的 API 路由。
number英文源码说明
Request-body bound (bytes) the generated entry applies to action POST routes; larger uploads belong on API routes with explicit limits.
packages/protocol/src/policy.ts:57renderToString 允许展开的嵌套元素层数,避免循环组合导致无穷递归。
8英文源码说明
Nested element expansion depth bound for `renderToString`: cyclic component composition fails closed instead of recursing without end.
packages/protocol/src/policy.ts:51基于标准 Request 和 Response 的洋葱式中间件。可直接返回响应,也可在 next() 返回后处理响应。
Middleware英文源码说明
Fetch middleware contract (#858): WinterCG shape, dialect-free — no Hono/h3 context object. Composed at the handler boundary in onion order (`use[0]` is outermost: it sees the request first and the response last), so it runs with identical semantics in the dev server, the `start` CLI, the e2e fixture server, and the Nitro production entry. A middleware may short-circuit by returning a Response without calling `next()`, or post-process the Response that `next()` returns. Module contract: a Middleware is the DEFAULT EXPORT of a module referenced from `middleware.use` by path (e.g. './app/middleware/auth.ts'). The generated server entry imports the module, so the middleware may close over module scope and import local helpers and third-party packages — it is a real module in the server module graph, never serialized source.
packages/protocol/src/framework.ts:169由生成入口纳入执行链的一个中间件模块声明。
MiddlewareDecl英文源码说明
One middleware module the generated entry composes.
packages/protocol/src/ssg.ts:140一个中间件的适用范围,可覆盖全部路由或一组具名路由。
MiddlewareScopeDecl英文源码说明
The scope one middleware applies to (all routes or a named route set).
packages/protocol/src/ssg.ts:279描述模块扫描识别的导出绑定,以及调用该绑定时登记的事实。
ModuleVocabularyDescriptor英文源码说明
One module-scan vocabulary entry the host admits: a binding identity (module specifier + exported name, aliases followed) plus the fact a canonical call of that binding contributes. Plain data — the scan consumes the descriptors without learning the caller's package vocabulary, the same direction as the compiler's {@link StaticSidecarDescriptor} admission (#1473 item 3).
packages/protocol/src/module-descriptors.ts:33编译器内部字段,用于在渲染的宿主记录中存放展开嵌套宿主的函数。
"__oe_nestedHost"英文源码说明
The compiler-private field a render's host record carries the nested-host expander under (P-6, 2026-11-21). A generated component's SSR producer routes every custom-element tag through the runtime's ONE `nestedHost` helper, which reads the expander off this record. The LIGHT root's producer has always supplied it; the SHADOW host producer did not, so a shadow page's inner components stayed bare tags while the class lane and the light lane both expanded theirs. It lives in the protocol for the same reason the sheet keys above do: the COMPILER emits the record and the RUNTIME reads it, and the compiler must not depend on an element-internal subpath to spell it. One literal, two ends.
packages/protocol/src/style-sheet.ts:80自定义元素声明中记录的一个 attribute。
OpenElementAttribute英文源码说明
One documented attribute of a custom element declaration.
packages/protocol/src/manifest.ts:15构建上下文中可选的博客内容目录和 URL 基础路径。
OpenElementBlogOptions英文源码说明
Blog options stored in the build context by
packages/protocol/src/framework.ts:37供子插件使用的最小构建上下文接口。
OpenElementBuildContextLike英文源码说明
Minimal build context interface that sub-plugins can use.
packages/protocol/src/framework.ts:62自定义元素声明中记录的一个 CSS part。
OpenElementCssPart英文源码说明
One documented CSS part of a custom element declaration.
packages/protocol/src/manifest.ts:38包清单中的自定义元素声明,包括标签名、成员和交付信息。
OpenElementDeclaration英文源码说明
One custom element declaration in a package manifest: tag, members and delivery metadata.
packages/protocol/src/manifest.ts:116框架错误,提供稳定错误码、严重程度、发生阶段和可恢复性。
class OpenElementError extends Error英文源码说明
Framework error carrying a stable code, severity, phase and recoverability contract.
packages/protocol/src/errors.ts:100OpenElementError 的构造选项,每个字段都有默认值。
OpenElementErrorOptions英文源码说明
Constructor options for {@linkcode OpenElementError}; every field is defaulted.
packages/protocol/src/errors.ts:90自定义元素声明中记录的一个自定义事件。
OpenElementEvent英文源码说明
One documented custom event of a custom element declaration.
packages/protocol/src/manifest.ts:25包清单声明中的 openElement 扩展字段。
OpenElementExtensions英文源码说明
The openElement-specific extension block of a package manifest declaration.
packages/protocol/src/manifest.ts:72由 @openelement/i18n 保存到构建上下文的国际化配置。
OpenElementI18nContextOptions英文源码说明
i18n options stored in the build context by
packages/protocol/src/framework.ts:55包级组件清单,记录其中声明的组件。
OpenElementPackageManifest英文源码说明
Package manifest of component declarations (not a Custom Elements Manifest).
packages/protocol/src/manifest.ts:129供运行时适配器和生成入口使用的统一请求处理函数,基于标准 Request 和 Response。
OpenElementRequestHandler<Env>英文源码说明
The host-neutral request handler every runtime adapter and generated server entry exposes: a WinterCG `(request, context?) => Response` with no server engine dialect baked in.
packages/protocol/src/runtime.ts:27应用与构建驱动共享的路由类别。
OpenElementRouteKind英文源码说明
Host-agnostic route and asset contracts shared by app and build drivers.
packages/protocol/src/app-model.ts:2路由树节点,记录匹配路径、路由类型、源码与模块路径、可选的标签和参数,以及子路由。
OpenElementRouteNode英文源码说明
One node of the host-agnostic route tree: the matched URL `path` and route kind, the source and module paths the drivers resolve, the optional registered tag and param names, and the nested `children`.
packages/protocol/src/app-model.ts:9自定义元素声明中记录的一个插槽。
OpenElementSlot英文源码说明
One documented slot of a custom element declaration.
packages/protocol/src/manifest.ts:32OpenElementTailwindDeclaration英文源码说明
A declaration's utility-compilation requirement and the package-owned style sources that requirement compiles (the declared-compilation contract; see the router's `style-plan` module for the resolution rules). `required` is the mandatory-compilation dependency: the component's presentation cannot be delivered without the compile, so an application that disables the entry (`tailwind: false`) fails the build with a coded diagnostic instead of shipping an unstyled component. Merely offering a theme source is NOT a requirement — leave `required` unset for a source a consumer may adopt on its own. `sources` are package-relative paths (e.g. `./theme.css`) resolved against THIS package, so a consumer never repeats the owner's declaration. They must exist in the installed package (i.e. ship in the tarball). `dialect` names the CLASS LANGUAGE this component's utility tokens are written in, not the engine that compiles them: the declaration stays provider-neutral, and a selected provider that does not implement the dialect fails the build before any compile. Omitted means `tailwind4` — the language every declaration written before this field existed uses.
packages/protocol/src/manifest.ts:65生成入口描述符中的一条页面路由声明。
PageRouteDecl英文源码说明
One page route declaration in the generated entry descriptor.
packages/protocol/src/ssg.ts:172解析线格式中的一份诊断报告。
(text: string): DiagnosticReport英文源码说明
Parse one report off the wire. Fails closed: truncated JSON, a foreign format tag, or any structurally broken diagnostic raises {@linkcode DiagnosticReportParseError} instead of returning a partial report a consumer might mistake for the truth.
packages/protocol/src/diagnostics.ts:193当前包定义的 Part Program 中间表示版本。
2英文源码说明
The Part Program IR version this package defines (currently v2).
packages/protocol/src/part-program.ts:23序列化程序标记中结束 Part 锚点的注释文本。
(index: number): string英文源码说明
The comment marker closing a part anchor in serialized program markup.
packages/protocol/src/part-program.ts:437初始数据运行时共用的锚点标记内容。
(index: number): string英文源码说明
Anchor marker payloads shared by seed runtime consumers.
packages/protocol/src/part-program.ts:432可序列化的 Part Program v2,用数据表示一个编译后的组件。
PartProgramV2英文源码说明
The serializable Part Program v2: one compiled component as data.
packages/protocol/src/part-program.ts:429所有执行模式共享的确定性程序格式。
PartProgramV2英文源码说明
The one deterministic program consumed by all execution modes.
packages/protocol/src/part-program.ts:409RFC 9457 Problem Details 错误响应使用的媒体类型。
"application/problem+json"英文源码说明
Media type of the RFC 9457 action error channel (#863).
packages/protocol/src/data.ts:117表单 action 的协议错误使用的 RFC 9457 文档,按 application/problem+json 返回。detail 提供具体错误说明。
ProblemDetails英文源码说明
RFC 9457 Problem Details document (#863): the action error channel answers `application/problem+json` instead of the bespoke `{ type: 'error', error: { message } }` JSON, so HTTP tooling recognizes failures natively. With `type: 'about:blank'`, `title` is the HTTP reason phrase and `detail` carries the specific explanation. The wire shape is alpha-unfrozen; the 1.0 acceptance freezes it in this problem+json form.
packages/protocol/src/data.ts:105将信号值写入字符串型 DOM 特性的绑定。
ProgramAttrPart英文源码说明
String attribute sink bound to a Signal.
packages/protocol/src/part-program.ts:154记录编译程序所追踪的一个动态子树块及其边界。
ProgramBlockRecord英文源码说明
One block the program tracks: the boundaries of a dynamic subtree.
packages/protocol/src/part-program.ts:342将信号值写入布尔型 DOM 特性的绑定。
ProgramBoolPart英文源码说明
Boolean attribute sink bound to a Signal.
packages/protocol/src/part-program.ts:164将类名绑定到专用写入目标,明确该绑定对类名的归属。
ProgramClassPart英文源码说明
Specialized fixed sinks make ownership explicit for class and style text.
packages/protocol/src/part-program.ts:174`when` 条件绑定中的一个条件子句。
ProgramCondition英文源码说明
One condition clause of a when part.
packages/protocol/src/part-program.ts:246编译后的模块图记录的一项依赖。
ProgramDependencyRecord英文源码说明
One module dependency the compiled module graph records.
packages/protocol/src/part-program.ts:352读取绑定信号的列表,按列表项重复渲染模板。
ProgramEachPart英文源码说明
A list part: repeats its template node per item of a bound signal.
packages/protocol/src/part-program.ts:310编译程序树中的静态元素节点。
ProgramElementNode英文源码说明
A static element node of the program tree.
packages/protocol/src/part-program.ts:90Part Program 或内部记录格式错误,或包含线格式无法表达的值时使用的错误码。
{ readonly INVALID_PROGRAM: "OE_PROGRAM_INVALID"; readonly NOT_SERIALIZABLE: "OE_PROGRAM_NOT_SERIALIZABLE"; readonly INVALID_SLOT: "OE_PROGRAM_INVALID_SLOT"; readonly INVALID_SOURCE_SEGMENT: "OE_PROGRAM_INVALID_SOURCE_S…英文源码说明
Program-shape failures: a Part Program (or one of its records) is malformed, or carries a value the wire format cannot express. Phase `validation`: these reject data before any DOM work starts.
packages/protocol/src/errors.ts:141一次事件绑定所分派的操作。
ProgramEventAction英文源码说明
The action one event part dispatches.
packages/protocol/src/part-program.ts:217将 DOM 事件的监听器连接到对应操作的绑定。
ProgramEventPart英文源码说明
An event binding part: listener wiring between DOM event and action.
packages/protocol/src/part-program.ts:225接收 `TrustedHtml` 信号值,并用其中的 HTML 替换目标元素的内容。
ProgramHtmlPart英文源码说明
Trusted-HTML content sink (alpha.9). The signal value must carry the runtime TrustedHtml capability; its HTML replaces the target element's content. The target's subtree is opaque to the claim path. The compiler emits this only for an explicit `innerHTML={this.<field>}` sink on an otherwise childless element — there is no implicit or discovery path to raw HTML.
packages/protocol/src/part-program.ts:199ProgramItemValueNode英文源码说明
Item-value text slot; valid only inside an `each` item template. `field` names the item field rendered by this slot — multi-field item templates carry one slot per field, and the compiler always emits it.
packages/protocol/src/part-program.ts:123由编译器标定的一个动态写入目标或范围锚点的准确位置。
ProgramLocation英文源码说明
Exact compiler-owned location for one dynamic sink or range anchor.
packages/protocol/src/part-program.ts:76无需读取绑定本身即可核查其标识与位置的记录。
ProgramLocationRecord英文源码说明
A location record also makes the identity auditable without inspecting parts.
packages/protocol/src/part-program.ts:84可由编译程序实例化的各类动态绑定的可辨识联合类型。
ProgramPart英文源码说明
The discriminated union of dynamic parts a program instantiates.
packages/protocol/src/part-program.ts:328标记编译程序树中动态绑定位置的锚点节点。
ProgramPartAnchorNode英文源码说明
The anchor node marking where a part binds in the tree.
packages/protocol/src/part-program.ts:112记录绑定相对于锚点的位置,包括偏移、行和列。
ProgramPosition英文源码说明
Where a part sits relative to its anchor.
packages/protocol/src/part-program.ts:45将信号值写入 DOM 属性,并保留 `path` 供读取初始数据的代码使用。
ProgramPropPart英文源码说明
DOM property sink bound to a Signal; `path` is retained for seed consumers.
packages/protocol/src/part-program.ts:144可序列化的具名引用位置,其引用值由生成的类提供。
ProgramRefPart英文源码说明
A named ref slot is serializable; the generated class supplies the ref value.
packages/protocol/src/part-program.ts:208描述一个编译程序树的根,树可包含元素、绑定锚点或文本。
ProgramRoot英文源码说明
The root of one program tree: element, part anchor, or text.
packages/protocol/src/part-program.ts:29标明程序源映射记录所对应的源代码实体类型。
ProgramSourceKind英文源码说明
The kind of source record a program source map entry carries.
packages/protocol/src/part-program.ts:59将源码片段的位置映射到编译器输出的记录。
ProgramSourceMap英文源码说明
The program source map: authored spans projected onto emitted records.
packages/protocol/src/part-program.ts:69源码中的半开区间 `[start, end)`,包含起点且排除终点。
ProgramSourceRange英文源码说明
A half-open [start, end) range into the authored source text.
packages/protocol/src/part-program.ts:52记录一个生成节点或绑定在源码中的出处。
ProgramSourceRecord英文源码说明
One source-map record: the authored origin of one emitted node or part.
packages/protocol/src/part-program.ts:62用于样式的编译绑定。
ProgramStylePart英文源码说明
A style binding part.
packages/protocol/src/part-program.ts:183编译程序树中的静态文本节点。
ProgramTextNode英文源码说明
A static text node of the program tree.
packages/protocol/src/part-program.ts:106绑定到单个信号的文本插值。
ProgramTextPart英文源码说明
A text interpolation part bound to one signal.
packages/protocol/src/part-program.ts:136静态程序树节点的可辨识联合类型。
ProgramTreeNode英文源码说明
The discriminated union of static tree nodes.
packages/protocol/src/part-program.ts:129按条件切换模板分支的动态绑定。
ProgramWhenPart英文源码说明
A conditional part: swaps template branches on a condition.
packages/protocol/src/part-program.ts:279编译属性默认值序列化后所带的值类型标记。
PropertyValueType英文源码说明
The serialized value-type tag of a compiled property default.
packages/protocol/src/part-program.ts:359构造并抛出框架错误,是 frameworkError 的抛出形式。
(phase: ErrorPhase, code: string, message: string): never英文源码说明
Raise one framework failure and never return: the throwing companion of {@linkcode frameworkError}. The per-module `fail(code, message)` micro-factories bind their failure surface's fixed {@linkcode ErrorPhase} here — one implementation, the phase as a parameter — so a code and a phase cannot drift apart per throw site.
packages/protocol/src/errors.ts:396文本内容不可插入为标记的 HTML 元素标签集合。
ReadonlySet<string>英文源码说明
Elements whose text content must never be interpolated as markup.
packages/protocol/src/forbidden-sinks.ts:38computed 等派生值使用的只读信号接口。
ReadonlySignal<T>英文源码说明
Read-only signal protocol used by computed values.
packages/protocol/src/signal.ts:26一条页面渲染器模块注册记录。
RendererDecl英文源码说明
One page renderer module registration.
packages/protocol/src/ssg.ts:271SSR 流水线报告的一条渲染错误记录。
RenderError英文源码说明
One render failure record the SSR pipeline reports.
packages/protocol/src/render.ts:16布局计划中一个位置的解析结果,可为 `false`(禁用)或完整声明。
ResolvedLayout英文源码说明
The resolved layout for one plan slot: disabled (false) or a full declaration.
packages/protocol/src/ssg.ts:312指定编译组件将内容挂载到 Light DOM、开放 Shadow Root 或封闭 Shadow Root。
RootMode英文源码说明
How the compiled component attaches its root: light DOM or a shadow root.
packages/protocol/src/part-program.ts:26扫描后入选的路由,记录 URL 路径、源文件、类型、生成入口使用的变量名和可选注册标签。
RouteEntry英文源码说明
One route admitted by the scanner: URL `path`, source `filePath`, the route `type`, the generated variable name (`varName`) the entry binds it to, and the optional registration tag. {@link RouteEntry.definePage} and {@link RouteEntry.hasEnhancedForms} carry the two source-derived admission facts the generated entries branch on.
packages/protocol/src/framework.ts:113生成的 SSG 入口模块通过 `routeInfo` 输出的一条路由元数据。
RouteInfoEntry英文源码说明
A single route metadata entry emitted as `routeInfo` by the generated SSG entry module (see entry-render-ssg.ts).
packages/protocol/src/ssg.ts:395路由器传给 analyzeModuleSemantics 的模块扫描识别规则。
readonly ModuleVocabularyDescriptor[]英文源码说明
The module vocabulary router injects into `analyzeModuleSemantics`.
packages/protocol/src/module-vocabulary.ts:17控制是否保留原始错误消息,生产客户端构建会关闭,其他场景保留。
boolean英文源码说明
Whether the authored error prose is kept: `true` everywhere except a production client build, the one context that defines `OE_RUNTIME_MESSAGES` to `false`. Stripping is a payload decision, so it belongs to the browser bundle only — server-side failures keep their prose.
packages/protocol/src/errors.ts:72宿主运行时适配器,向服务器引擎提供接收请求的 `fetch` 处理器。
RuntimeAdapter<Env>英文源码说明
A host runtime adapter: exposes the fetch handler a server engine dispatches to.
packages/protocol/src/runtime.ts:32构造运行时适配器时传入的选项。
RuntimeAdapterOptions<Env>英文源码说明
Options one runtime adapter is constructed with.
packages/protocol/src/runtime.ts:39运行时适配器的上下文契约,用来隔离框架和部署环境。
RuntimeContext<Env>英文源码说明
runtime.ts - Runtime adapter protocol. Replacement boundary for Nitro, Workers, Node, Deno, or future fetch-compatible runtimes. Preserves openElement semantics while leaving concrete server engines outside this package.
packages/protocol/src/runtime.ts:9编译程序序列化、创建 DOM 或信号更新时运行失败所用的错误码。
{ readonly LIST_VALUE_NOT_ARRAY: "OE_RUNTIME_LIST_VALUE_NOT_ARRAY"; readonly HOST_SIGNAL_MISSING: "OE_RUNTIME_HOST_SIGNAL_MISSING"; readonly HOST_HANDLER_MISSING: "OE_RUNTIME_HOST_HANDLER_MISSING"; readonly HOST_REF_MIS…英文源码说明
Runtime execution failures raised while a compiled program is serialized, built into fresh DOM, or re-read on a signal write (phase `render`).
packages/protocol/src/errors.ts:172表示已完成 HTML 转义,可作为文本内容使用的字符串类型。
SafeHtml英文源码说明
Branded type: a string that has been HTML-escaped (safe for text content)
packages/protocol/src/framework.ts:9编译属性的默认值可采用的 JSON 可序列化类型。
SerializableValue英文源码说明
The JSON-serializable value shape a compiled property default admits.
packages/protocol/src/part-program.ts:36(manifest: ClientAssetManifest): string英文源码说明
Serialize the manifest as the generated dist/server/client-assets.js module: pure structured data, no injection logic — consumers derive what they need from these values.
packages/protocol/src/client-assets.ts:68将报告序列化为供流或文件读取的一行文本,末尾不含换行。
(report: DiagnosticReport): string英文源码说明
Serialize a report for the stream/file channel: one line, no trailing newline.
packages/protocol/src/diagnostics.ts:114编译后服务端渲染和 DOM 接管校验失败时使用的错误码,仅由 CompiledProgramValidationError 抛出。
{ readonly PROGRAM_INVALID: "OPEN_ELEMENT_COMPILED_PROGRAM_INVALID"; readonly SINK_REFUSED: "OE_SERVER_SINK_REFUSED"; }英文源码说明
Compiled server/claim validation failures. The value shipped in 1.0.0-alpha.3 and is kept verbatim; `CompiledProgramValidationError` is its only raiser.
packages/protocol/src/errors.ts:281请求时渲染和静态站点生成共用的服务端路由上下文。
ServerRouteContext<Env, Platform, Route>英文源码说明
Canonical request-time/SSG server route context.
packages/protocol/src/data.ts:25动态路由 loader 接收的服务端上下文,包括标准请求、路由参数、宿主环境和平台对象。
ServerRouteMetadata英文源码说明
Context passed to a request-time ('dynamic') route loader. This is the server contract: the loader runs on the server with the Web-standard request, matched route params, the host environment and the platform object, and signals validation failure via fail()/redirect().
packages/protocol/src/data.ts:19接受可写信号或只读信号的 API 所用类型。
Signal<T>英文源码说明
Alias for APIs that accept either writable or read-only signals.
packages/protocol/src/signal.ts:31标识当前配置的响应式引擎所创建的信号,供运行时和类型系统识别。
typeof SIGNAL_BRAND英文源码说明
Runtime/type brand for signals created by the configured reactive engine.
packages/protocol/src/signal.ts:11框架内置适配器使用的信号引擎协议。
SignalEngine英文源码说明
Signal engine protocol used by the framework's built-in adapter. This is a deliberate internal seam, not a public compatibility contract: the framework layer talks to signals only through this narrow interface so its call sites stay implementation-agnostic. The package ships and verifies exactly one engine implementation (`preact-engine`, backed by `@preact/signals-core`). Preact's own API is not Element public API, and arbitrary third-party engines are not promised; any future engine would be added behind this protocol rather than inline (charter decision — see #723).
packages/protocol/src/signal.ts:46渲染器和绑定接受的最简信号对象接口。
SignalLike<T>英文源码说明
Minimal signal-like object accepted by renderers and bindings.
packages/protocol/src/signal.ts:14路由扫描器按文件名识别的特殊类型,包括 renderer 和 middleware。
SpecialFileType英文源码说明
Special file kinds the route scanner recognizes by filename: `renderer` and `middleware`.
packages/protocol/src/framework.ts:79静态生成后处理使用的 Speculation Rules 配置。
SpeculationRulesOptions英文源码说明
Speculation Rules configuration for SSG post-processing
packages/protocol/src/ssg.ts:448面向应用的静态站点生成构建选项。
SsgBehaviorOptions英文源码说明
User-facing SSG build behavior switches (OpenElementOptions['ssg']).
packages/protocol/src/ssg.ts:63`renderRoute()` 返回的单页渲染诊断结果。
SsgPageOutput英文源码说明
Per-page render diagnostics returned by renderRoute()
packages/protocol/src/ssg.ts:368SSG 引擎为每次构建输出的渲染审计记录。
SsgRenderEvidence英文源码说明
The per-build render evidence record the SSG engine emits for audit.
packages/protocol/src/ssg.ts:426传给共用 SSG 渲染流水线的选项。
SsgRenderOptions英文源码说明
Options passed to the shared SSG render pipeline.
packages/protocol/src/ssg.ts:36`ssgRender()` 返回的一次 SSG 渲染汇总。
SsgRenderSummary英文源码说明
Summary of an SSG render run, returned by ssgRender().
packages/protocol/src/ssg.ts:72"__openElementGeneratedHosts"英文源码说明
Property on the SSR registry holding the generated-entry host pairing table (tag -> the compiler-emitted generated host renderer): written atomically by the registry guard together with the class registration (M11) and read by `@openelement/element`'s server serializer nested-composition seam. It lives on the registry (not on the class and not on the module namespace) for the same reasons the ownership markers do: one writer (the generated entry's guard), one reader (Element's serializer), no class static / suffix scan / runtime module-shape read, and the pairing survives vite dev SSR module re-evaluations together with the class it belongs to.
packages/protocol/src/registry-markers.ts:54标识 SSR 注册表中保存的原始 `define` 方法,生成入口在安装幂等包装前将它捕获。
"__openElementOrigDefine"英文源码说明
Property on the SSR registry holding the TRUE original `define` method, captured before the generated entry installs its idempotent wrapper. The registry outlives vite dev SSR module re-evaluations, so without this the second evaluation would capture the already-wrapped `define` as its "original" and every forced re-registration would silently early-return through the previous wrapper (#952 dev re-evaluation).
packages/protocol/src/registry-markers.ts:40在 SSR `customElements` 模拟注册表上标记 `true`,表明该注册表允许重新定义元素。
"__openElementSsrStub"英文源码说明
Marker property set to `true` on the SSR customElements stub. Readers must treat the marked registry as re-definable.
packages/protocol/src/registry-markers.ts:22构建对自定义元素的 SSR 判定,记录模块路径、发现来源、渲染方式及原因。
SsrAdmissionDecision英文源码说明
The build's admission verdict for one discovered tag: where the declaration lives (`modulePath`), how it was discovered (`source`), which render path it is admitted to, and the reason recorded for the manifest.
packages/protocol/src/render.ts:37构建时按组件标签记录的 SSR 准入决策。
SsrAdmissionPlan英文源码说明
The build-time SSR admission decisions per component tag.
packages/protocol/src/ssg.ts:253SSG 引擎执行流式渲染时读取的服务端包信息。
SsrBundle英文源码说明
The server bundle facts the SSG engine consumes for stream rendering.
packages/protocol/src/ssg.ts:417"data-oe-static-styles"英文源码说明
The one `<style>` element the server serializer emits as the first DSD template child when the class carries static styles (renderToString parity — pages never upgrade, so their styles must ship in the payload). The claim path skips exactly this marked node; a marked node on a style-less class is claim drift and fails closed.
packages/protocol/src/part-program.ts:448从路由的本地导入图发现的静态编译组件声明,供构建纳入递归 SSR 或 SSG,且不会添加水合或浏览器入口。
StaticComponentDecl英文源码说明
Build-host-only compiled component reached through a route's local import graph. These components participate in recursive SSR/SSG expansion but are not client islands and therefore add no hydration or browser entry.
packages/protocol/src/ssg.ts:217告诉元素编译器哪一项与组件放在同一模块的声明属于静态策略。
StaticSidecarDescriptor英文源码说明
One static-sidecar descriptor the host injects into the element compiler: the admission granted is a colocated static policy statement (#1473 item 3, the static-sidecar admission pattern).
packages/protocol/src/module-descriptors.ts:16交互岛最终采用的 hydration 策略的来源。
StrategySource英文源码说明
Where an island's resolved hydration strategy came from.
packages/protocol/src/framework.ts:32浏览器拒绝装入所属 Part 范围的流式片段所禁用的标签。
readonly ["script", "style", "template", "iframe", "object", "embed", "base", "meta", "link"]英文源码说明
Tags a deferred frame cannot safely install into an owned Part range: the browser installer rejects any frame whose markup carries one of these.
packages/protocol/src/stream-frame-policy.ts:26流式片段的 URL 属性不可使用的协议。
RegExp英文源码说明
Schemes that make a URL attribute unsafe in a streamed frame.
packages/protocol/src/stream-frame-policy.ts:60流式片段中需要检查 URL 协议的属性名。
readonly ["href", "src", "action", "formaction", "xlink:href"]英文源码说明
URL-carrying attributes the frame check screens for script-bearing scheme obfuscation; only these attribute names are value-screened.
packages/protocol/src/stream-frame-policy.ts:42检查 URL 协议前,会移除码点低于或等于此值的控制字符。
32英文源码说明
Control characters at or below this code point are stripped before the URL-scheme test, so tab/newline/control obfuscation cannot smuggle a scheme past admission.
packages/protocol/src/stream-frame-policy.ts:55一个流式路由允许在清单中声明的延迟字段数上限。
32英文源码说明
Deferred fields (declared streamed properties) one stream route's manifest may carry. The build scan, the server executor, and the browser seed contract enforce the same bound.
packages/protocol/src/policy.ts:24一个流式路由清单可以引用的 Part 和 Block 所有者数量上限。
64英文源码说明
Part/Block owners one stream route's manifest may address in total across all deferred fields.
packages/protocol/src/policy.ts:30流式载荷的最大序列化长度,以 UTF-16 码元计。
number英文源码说明
Serialized stream payload bound, as a string length in UTF-16 code units: one seed attribute or one deferred frame's markup may not exceed it. The server checks the JSON text and the rendered range before emitting; the browser checks the attribute before parsing.
packages/protocol/src/policy.ts:45流式 hydration 初始数据可携带的带类型属性数量上限。
64英文源码说明
Typed properties one streamed seed may carry: the browser seed contract rejects the WHOLE seed above this count, so an oversized component would silently fail to hydrate instead of failing loud at the server.
packages/protocol/src/policy.ts:37流式响应等待延迟字段完成的时间上限(毫秒)。
30000英文源码说明
Deferred-field resolution budget (milliseconds) for one streamed response: fields still pending when it expires are failed in place and the stream ends with the shell and whatever resolved.
packages/protocol/src/policy.ts:64构建时绑定到某个编译页面程序的路由信息。
StreamRouteManifest英文源码说明
Build-only route projection bound to a specific compiled page program.
packages/protocol/src/ssg.ts:13用来标记可在开发期间热更新的样式表资源的键。
"__openElementStyleSheetLive"英文源码说明
The one key marking a sheet whose bytes are a LIVE resource rather than an immutable one (alpha15 S lane, S-C1.3). The dev server serves an authored sheet from a mutable endpoint that hot-updates: the sheet object is the copy the live resource re-fills through `replace()`, so every root that adopted it re-renders on an edit. A root whose serialized markup declares the same URL therefore still ADOPTS this sheet — the declarative `<link>` stays the first-paint / no-JavaScript delivery, and the adopted object is the one an edit reaches. Without that, a CSS-only edit could only be delivered by re-fetching the link, which is a DOM write this protocol does not perform. Production sheets never carry this key: their URL is content-addressed, so the link and the sheet can never disagree and one delivery is the whole story. Build-time and runtime cannot drift because the dev adapter generator interpolates this exact name.
packages/protocol/src/style-sheet.ts:64"__openElementStyleReady"英文源码说明
The one key under which a sheet carries its readiness promise: the generated client style adapter records it on the sheet it exports, and the element runtime reads the same key to hand styles to roots that are already connected. Build-time and runtime cannot drift because the adapter generator interpolates this exact name. The promise settles once. Fulfillment means the rules were installed through `replace()`; rejection carries the load or replacement failure and keeps its rejected state — an observer may attach its own catch, it must never convert the promise into a fulfilled one.
packages/protocol/src/style-sheet.ts:31"__openElementStyleSheetUrl"英文源码说明
The one key under which a sheet carries the URL of the external CSS resource that delivers its rules: the generated client style adapter records the emitted asset URL on the sheet it exports, and the element runtime compares it against the declarative `<link rel="stylesheet" data-oe-static-styles>` nodes an SSR/DSD template already carries (alpha15 S lane). A root whose serialized markup already references the sheet's URL keeps that link as the delivery and does NOT adopt a second constructable copy — one stylesheet resource, one delivery, no duplicate application. Build-time and runtime cannot drift because the adapter generator interpolates this exact name.
packages/protocol/src/style-sheet.ts:44客户端应用编译样式失败时使用的错误码。
{ readonly ADOPTED_STYLES_UNSUPPORTED: "OE_STYLES_ADOPTED_STYLES_UNSUPPORTED"; readonly SHEET_LOAD_FAILED: "OE_STYLES_SHEET_LOAD_FAILED"; readonly INVALID_STYLE_HREF: "OE_STYLES_INVALID_HREF"; readonly SHEET_RULES_UNREA…英文源码说明
Compiled-style application failures (phase `csr`).
packages/protocol/src/errors.ts:239原生样式表与兼容实现共用的最小接口,包括 replaceSync 和 cssRules。
StyleSheetLike英文源码说明
Minimal stylesheet contract (replaceSync + cssRules) satisfied by native and shim sheets.
packages/protocol/src/style-sheet.ts:14浏览器与 SSR 环境共用的 `CSSStyleSheet` 抽象。
StyleSheetRule英文源码说明
Cross-environment CSSStyleSheet abstraction. In browsers this delegates to the native CSSStyleSheet API. In SSR runtimes it falls back to a minimal in-memory implementation that exposes the subset used by OpenElement and renderToString().
packages/protocol/src/style-sheet.ts:9标识尚未转义、未被信任的 HTML 字符串。
UnsafeHtml英文源码说明
Branded type: a string that is intentionally raw/untrusted HTML
packages/protocol/src/framework.ts:12判断 Part Program 中的静态属性是否会使流式片段无法通过安装校验。
(name: string, value: string): boolean英文源码说明
Whether a static attribute (name/value as authored into the Part Program) makes a streamed frame unsafely installable: event-handler, seed-spoofing, and srcdoc names fail outright, and URL-carrying names fail when the entity-decoded, control-stripped value carries a script scheme.
packages/protocol/src/stream-frame-policy.ts:113订阅和响应式副作用返回的取消订阅函数。
Unsubscribe英文源码说明
Unsubscribe function returned by subscriptions and effects.
packages/protocol/src/signal.ts:8校验数据是否符合 Part Program v2,以及指令、所有权记录和路径是否合法。
(raw: unknown): asserts raw is PartProgram英文源码说明
Validate an unknown value as a Part Program v2. The validator is intentionally strict: unknown instruction kinds, missing ownership records and unsafe paths fail before a runtime can guess at their meaning.
packages/protocol/src/part-program.ts:911由编译器、序列化器与校验器共用的 HTML 空元素标签集合。
ReadonlySet<string>英文源码说明
HTML void elements — the ONE canonical tag set for every serializer, validator, and compiler in the workspace (issue #1220, M4). This module is import-free and host-free by design: it sits at the base of the module graph so the DOM runtime (internal/core/html-escape.ts), the Part Program exchange artifact (internal/protocol/part-program.ts), and the compiler semantic core can all consume the same definition without an import cycle or a second source of truth. Content is the full HTML Standard void-element list, `param` included. Do not redefine this set anywhere else; internal/core/html-escape.ts and internal/protocol/part-program.ts re-export it, and __tests__/void-tags-convergence.test.ts enforces the single owner.
packages/protocol/src/void-tags.ts:16openElement 集成使用的可写信号协议。
WritableSignal<T>英文源码说明
Writable signal protocol used by openElement integrations.
packages/protocol/src/signal.ts:21应用与构建驱动共享的路由类别。
OpenElementRouteKind英文源码说明
Host-agnostic route and asset contracts shared by app and build drivers.
packages/protocol/src/app-model.ts:2路由树节点,记录匹配路径、路由类型、源码与模块路径、可选的标签和参数,以及子路由。
OpenElementRouteNode英文源码说明
One node of the host-agnostic route tree: the matched URL `path` and route kind, the source and module paths the drivers resolve, the optional registered tag and param names, and the nested `children`.
packages/protocol/src/app-model.ts:9客户端构建的交付清单,以交互岛标识为索引。
ClientAssetManifest英文源码说明
The Phase 2 client build's delivery manifest, keyed by island identity.
packages/protocol/src/client-assets.ts:36一个编译期交互岛标识对应的客户端资源。
ClientIslandAsset英文源码说明
The client asset one compile-time island identity resolves to.
packages/protocol/src/client-assets.ts:19没有客户端包的项目使用的资源清单。
ClientAssetManifest英文源码说明
The manifest a project without a client bundle carries.
packages/protocol/src/client-assets.ts:54(manifest: ClientAssetManifest): string英文源码说明
Serialize the manifest as the generated dist/server/client-assets.js module: pure structured data, no injection logic — consumers derive what they need from these values.
packages/protocol/src/client-assets.ts:68处理页面路由的表单提交。
Action<T, Env, Platform, Route>英文源码说明
Route action: handles form submissions for a page route.
packages/protocol/src/data.ts:64选择表单 action 的响应通道。true 返回序列化结果,enhance 返回与无脚本提交相同的 HTML。
"x-openelement-action"英文源码说明
Request header selecting the action response channel: `true` marks a programmatic caller and selects the serialized ActionResult union; `enhance` marks the built-in morph enhancement and selects the same full-HTML responses the no-JS path receives.
packages/protocol/src/data.ts:125传给路由 action 的上下文,包含 loader 上下文。
ActionContext<Env, Platform, Route>英文源码说明
Context passed to a route action function (extends loader context).
packages/protocol/src/data.ts:47脚本提交表单时返回的联合类型。校验失败返回 failure,成功提交返回 redirect;协议错误使用 ProblemDetails。
ActionResult<Failure>英文源码说明
Wire shape returned to the JavaScript form-enhancement path. The no-JS path never sees this: it gets the equivalent semantics as plain HTTP (303 on success, 422 with the re-rendered form on validation failure, redirect/error as status codes). Success carries no data envelope. The application-loop contract makes a successful non-GET action answer 303 (PRG) — the framework never answers 200 with a rendered page, or with a success document, for a successful mutation — so the fetch channel answers `{ type: 'redirect' }` naming the PRG target and the authored return value is discarded by design. Success data travels the PRG target instead (query state the loader re-runs with, which the props projector then maps; see the router guide's "Form actions" section). The union previously declared a `{ type: 'success' }` member that no code path ever emitted — removed so the type matches the wire. Error outcomes (CSRF 403, unknown action 404, unparseable body 400, unexpected 500) are NOT part of this union: since #863 they answer RFC 9457 Problem Details with the PROBLEM_JSON_MEDIA_TYPE content type — see ProblemDetails.
packages/protocol/src/data.ts:92为页面路由获取数据的 loader。
Loader<T, Env, Platform, Route>英文源码说明
Route loader: fetches data for a page route.
packages/protocol/src/data.ts:56传给动态路由 loader 的请求上下文。
LoaderContext<Env, Platform, Route>英文源码说明
Context passed to a request-time ('dynamic') route loader.
packages/protocol/src/data.ts:40RFC 9457 Problem Details 错误响应使用的媒体类型。
"application/problem+json"英文源码说明
Media type of the RFC 9457 action error channel (#863).
packages/protocol/src/data.ts:117表单 action 的协议错误使用的 RFC 9457 文档,按 application/problem+json 返回。detail 提供具体错误说明。
ProblemDetails英文源码说明
RFC 9457 Problem Details document (#863): the action error channel answers `application/problem+json` instead of the bespoke `{ type: 'error', error: { message } }` JSON, so HTTP tooling recognizes failures natively. With `type: 'about:blank'`, `title` is the HTTP reason phrase and `detail` carries the specific explanation. The wire shape is alpha-unfrozen; the 1.0 acceptance freezes it in this problem+json form.
packages/protocol/src/data.ts:105请求时渲染和静态站点生成共用的服务端路由上下文。
ServerRouteContext<Env, Platform, Route>英文源码说明
Canonical request-time/SSG server route context.
packages/protocol/src/data.ts:25动态路由 loader 接收的服务端上下文,包括标准请求、路由参数、宿主环境和平台对象。
ServerRouteMetadata英文源码说明
Context passed to a request-time ('dynamic') route loader. This is the server contract: the loader runs on the server with the Web-standard request, matched route params, the host environment and the platform object, and signals validation failure via fail()/redirect().
packages/protocol/src/data.ts:19用于识别诊断报告格式的 format 字段值。
"openelement.diagnostics/1"英文源码说明
The `format` discriminator every report carries. Consumers branch on it instead of guessing: a future shape change mints a new tag rather than reinterpreting old bytes.
packages/protocol/src/diagnostics.ts:84DiagnosticEnvelope英文源码说明
One machine-readable diagnostic: the producer's stable code, where the failure sits (`file`, `line`, `column` — absent when the producer has no source location, e.g. a configuration refusal), what happened (`message`), and when known, the fix (`hint`). `line`/`column` are 1-based, matching the diagnostics the compiler records from TypeScript source positions. Unknown envelope fields are tolerated on the wire (forward compat); the required core is exactly these fields.
packages/protocol/src/diagnostics.ts:60DiagnosticPhase英文源码说明
The pipeline phase a diagnostic was raised in — the same vocabulary the error contract's {@linkcode ErrorPhase } uses, so a producer's code, phase and envelope cannot disagree about where a failure happened.
packages/protocol/src/diagnostics.ts:39组装构建退出报告。只要一个诊断的严重级别为 error,报告即标为失败。
(diagnostics: DiagnosticEnvelope[]): DiagnosticReport英文源码说明
Assemble the exit's report. `ok` derives from the diagnostics' severities, never from a caller's optimism: one `error` severity is enough to fail it.
packages/protocol/src/diagnostics.ts:105DiagnosticReport英文源码说明
One build exit's diagnostics: the format tag, whether the run is clean (`ok` is false the moment any diagnostic carries severity `error`), and every diagnostic the exit collected. This is the document the CLI writes to the stream and the diagnostics file — one aggregate containing every code.
packages/protocol/src/diagnostics.ts:95诊断报告 format 字段使用的格式标识类型。
"openelement.diagnostics/1"英文源码说明
One format tag value (kept as a type for the report's `format` field).
packages/protocol/src/diagnostics.ts:87parseDiagnosticReport 发现文本不是可读取的诊断报告时抛出的错误。
class DiagnosticReportParseError extends Error英文源码说明
Raised by {@linkcode parseDiagnosticReport} when the text is not a consumable report. Fail closed: a consumer that catches this knows the channel answered garbage — never a half-valid report.
packages/protocol/src/diagnostics.ts:123区分导致构建失败的 error、可恢复问题 warning 和提示信息 info。
DiagnosticSeverity英文源码说明
How severe one diagnostic is. `error` fails the build, `warning` reports a recoverable defect, `info` is reserved for advisories. The build report's `ok` flag derives from this: any `error` diagnostic makes the report not-ok.
packages/protocol/src/diagnostics.ts:32将 OpenElementError 转换为统一的诊断记录结构。
(error: OpenElementError, options?: { hint?: string; }): DiagnosticEnvelope英文源码说明
Map the one error dialect ({@linkcode OpenElementError} — every producer's raiser goes through it) onto the envelope. The error's code, severity and phase ARE the envelope's; the message carries verbatim. Producers with a fix pass it as `hint`.
packages/protocol/src/diagnostics.ts:256解析线格式中的一份诊断报告。
(text: string): DiagnosticReport英文源码说明
Parse one report off the wire. Fails closed: truncated JSON, a foreign format tag, or any structurally broken diagnostic raises {@linkcode DiagnosticReportParseError} instead of returning a partial report a consumer might mistake for the truth.
packages/protocol/src/diagnostics.ts:193将报告序列化为供流或文件读取的一行文本,末尾不含换行。
(report: DiagnosticReport): string英文源码说明
Serialize a report for the stream/file channel: one line, no trailing newline.
packages/protocol/src/diagnostics.ts:114编写组件的属性或声明时可能遇到的校验错误码。
{ readonly INVALID_TAG_NAME: "OE_INVALID_TAG_NAME"; readonly UNSAFE_META_ATTRIBUTE: "OE_UNSAFE_META_ATTRIBUTE"; readonly UNSAFE_ATTRIBUTE_NAME: "OE_UNSAFE_ATTRIBUTE_NAME"; readonly UNSAFE_URL_SINK: "OE_UNSAFE_URL_SINK";…英文源码说明
Attribute/authoring-surface failures (phase `validation`).
packages/protocol/src/errors.ts:301现有 DOM 与即将接管它的程序不匹配时使用的错误码。
{ readonly STRUCTURE_MISMATCH: "OPEN_ELEMENT_COMPILED_CLAIM_MISMATCH"; readonly PRE_UPGRADE_EVENTS_INVALID: "OE_CLAIM_PRE_UPGRADE_EVENTS_INVALID"; readonly DYNAMIC_NODE_IN_STATIC_REGION: "OE_CLAIM_DYNAMIC_NODE_IN_STATIC…英文源码说明
Claim failures: the existing DOM does not match the program that would own it. The value shipped in 1.0.0-alpha.3 and is kept verbatim; consumers match on it, and `PartProgramHydrationError` is its only raiser.
packages/protocol/src/errors.ts:265编译期间使用的错误码。
{ readonly DIAGNOSTICS: "OE_COMPILER_DIAGNOSTICS"; readonly INVALID_SOURCE: "OE_COMPILER_INVALID_SOURCE"; }英文源码说明
Compiler (build-time) failures. The per-diagnostic `OEC####` codes stay on each diagnostic; these classify the family so a build failure is catchable as one thing.
packages/protocol/src/errors.ts:293Context Community Protocol 服务的生命周期错误码,发生在 csr 阶段。
{ readonly SERVICE_DISPOSED: "OE_CONTEXT_SERVICE_DISPOSED"; }英文源码说明
Community-context service lifecycle failures (phase `csr`).
packages/protocol/src/errors.ts:233RenderError 使用的默认错误码。
"RENDER_ERROR"英文源码说明
Default code for {@linkcode RenderError }. Deliberately NOT a member of {@linkcode ErrorCode}: that object is the scan target of the documentation site's error catalog, which requires every member to carry a phase/severity family rule. `RENDER_ERROR` is the pre-dialect value `RenderError` has always defaulted to — kept verbatim so callers that observe it keep working, and kept out of the catalogue because it is not a failure this package classifies, only a constructor default a caller may override.
packages/protocol/src/errors.ts:47带键列表无法确定条目身份时使用的错误码。
{ readonly ITEM_NOT_A_RECORD: "OE_EACH_ITEM_NOT_A_RECORD"; readonly KEY_NOT_ROUND_TRIPPABLE: "OE_EACH_KEY_NOT_ROUND_TRIPPABLE"; readonly DUPLICATE_KEY: "OE_EACH_KEY_DUPLICATE"; }英文源码说明
Keyed-list identity failures. Shared by the server serializer and the client runtime (see `internal/compiled/each-key.ts`), so both executors reject the same data with the same code.
packages/protocol/src/errors.ts:159openElement 错误消息使用的前缀。
"[openElement]"英文源码说明
Error message prefix for all openElement errors.
packages/protocol/src/errors.ts:50常用错误码常量。调用方也可以传入字符串错误码。
{ readonly SSR_RENDER_ERROR: "SSR_RENDER_ERROR"; readonly BOUNDARY_CAUGHT: "BOUNDARY_CAUGHT"; readonly UNKNOWN: "UNKNOWN"; }英文源码说明
Well-known error code constants for reference. String values are always accepted.
packages/protocol/src/errors.ts:31发生错误时所在的执行阶段。
ErrorPhase英文源码说明
The pipeline phase an error was raised in.
packages/protocol/src/errors.ts:80框架错误的严重程度。
ErrorSeverity英文源码说明
How severe a framework error is.
packages/protocol/src/errors.ts:78接收所有通过错误遥测渠道上报的 OpenElementError。
ErrorTelemetryHook英文源码说明
Callback receiving every reported {@linkcode OpenElementError} for telemetry.
packages/protocol/src/errors.ts:132公开入口在 SSR 渲染或客户端启动时使用的错误码。
{ readonly PROGRAM_MISSING: "OE_PROGRAM_MISSING"; readonly COMPOSITION_DEPTH: "OE_SSR_COMPOSITION_DEPTH"; readonly COMPUTED_FACTORY_MISSING: "OE_COMPUTED_FACTORY_MISSING"; readonly COMPUTED_READONLY: "OE_COMPUTED_READON…英文源码说明
SSR/bootstrap failures raised by the public entries (phase `ssr` / `csr`).
packages/protocol/src/errors.ts:328创建 OpenElementError,使用调用方指定的错误码和阶段,并据此确定级别与可恢复性。
(code: string, message: string, options?: Omit<OpenElementErrorOptions, "code">): OpenElementError英文源码说明
One framework failure: {@linkcode OpenElementError} with the caller's code and the phase/severity/recoverability that phase implies. Every throw site in this package goes through this factory (or the `*ErrorCode` tables above) so a code, a phase and a recoverability answer cannot drift per site.
packages/protocol/src/errors.ts:375自定义元素在客户端运行期间违反内核生命周期契约时使用的错误码。
{ readonly DISPOSED: "OE_KERNEL_DISPOSED"; readonly TAG_MISMATCH: "OE_KERNEL_TAG_MISMATCH"; readonly CLAIM_EXECUTOR_MISSING: "OE_KERNEL_CLAIM_EXECUTOR_MISSING"; readonly ROOT_NOT_OWNED: "OE_KERNEL_ROOT_NOT_OWNED"; reado…英文源码说明
Element-lifecycle failures: the kernel was driven outside its contract (phase `csr`).
packages/protocol/src/errors.ts:219框架错误,提供稳定错误码、严重程度、发生阶段和可恢复性。
class OpenElementError extends Error英文源码说明
Framework error carrying a stable code, severity, phase and recoverability contract.
packages/protocol/src/errors.ts:100OpenElementError 的构造选项,每个字段都有默认值。
OpenElementErrorOptions英文源码说明
Constructor options for {@linkcode OpenElementError}; every field is defaulted.
packages/protocol/src/errors.ts:90Part Program 或内部记录格式错误,或包含线格式无法表达的值时使用的错误码。
{ readonly INVALID_PROGRAM: "OE_PROGRAM_INVALID"; readonly NOT_SERIALIZABLE: "OE_PROGRAM_NOT_SERIALIZABLE"; readonly INVALID_SLOT: "OE_PROGRAM_INVALID_SLOT"; readonly INVALID_SOURCE_SEGMENT: "OE_PROGRAM_INVALID_SOURCE_S…英文源码说明
Program-shape failures: a Part Program (or one of its records) is malformed, or carries a value the wire format cannot express. Phase `validation`: these reject data before any DOM work starts.
packages/protocol/src/errors.ts:141构造并抛出框架错误,是 frameworkError 的抛出形式。
(phase: ErrorPhase, code: string, message: string): never英文源码说明
Raise one framework failure and never return: the throwing companion of {@linkcode frameworkError}. The per-module `fail(code, message)` micro-factories bind their failure surface's fixed {@linkcode ErrorPhase} here — one implementation, the phase as a parameter — so a code and a phase cannot drift apart per throw site.
packages/protocol/src/errors.ts:396控制是否保留原始错误消息,生产客户端构建会关闭,其他场景保留。
boolean英文源码说明
Whether the authored error prose is kept: `true` everywhere except a production client build, the one context that defines `OE_RUNTIME_MESSAGES` to `false`. Stripping is a payload decision, so it belongs to the browser bundle only — server-side failures keep their prose.
packages/protocol/src/errors.ts:72编译程序序列化、创建 DOM 或信号更新时运行失败所用的错误码。
{ readonly LIST_VALUE_NOT_ARRAY: "OE_RUNTIME_LIST_VALUE_NOT_ARRAY"; readonly HOST_SIGNAL_MISSING: "OE_RUNTIME_HOST_SIGNAL_MISSING"; readonly HOST_HANDLER_MISSING: "OE_RUNTIME_HOST_HANDLER_MISSING"; readonly HOST_REF_MIS…英文源码说明
Runtime execution failures raised while a compiled program is serialized, built into fresh DOM, or re-read on a signal write (phase `render`).
packages/protocol/src/errors.ts:172编译后服务端渲染和 DOM 接管校验失败时使用的错误码,仅由 CompiledProgramValidationError 抛出。
{ readonly PROGRAM_INVALID: "OPEN_ELEMENT_COMPILED_PROGRAM_INVALID"; readonly SINK_REFUSED: "OE_SERVER_SINK_REFUSED"; }英文源码说明
Compiled server/claim validation failures. The value shipped in 1.0.0-alpha.3 and is kept verbatim; `CompiledProgramValidationError` is its only raiser.
packages/protocol/src/errors.ts:281客户端应用编译样式失败时使用的错误码。
{ readonly ADOPTED_STYLES_UNSUPPORTED: "OE_STYLES_ADOPTED_STYLES_UNSUPPORTED"; readonly SHEET_LOAD_FAILED: "OE_STYLES_SHEET_LOAD_FAILED"; readonly INVALID_STYLE_HREF: "OE_STYLES_INVALID_HREF"; readonly SHEET_RULES_UNREA…英文源码说明
Compiled-style application failures (phase `csr`).
packages/protocol/src/errors.ts:239(str: string): string英文源码说明
The one camelCase → kebab-case casing rule for custom-element attribute names, so `<x-el itemCount={5}>` round-trips as `item-count` on every boundary that derives an attribute name from a prop name: the compiler's property metadata, the SSR serializer, and the client attribute handling.
packages/protocol/src/forbidden-sinks.ts:95ReadonlySet<string>英文源码说明
Forbidden sink names — the ONE canonical deny list for every Part Program boundary: the compiler semantic core, the protocol validator (internal/protocol/part-program.ts), and the compiled server/claim validator (internal/compiled/server/shared.ts). This module is import-free and host-free by design (same base-of-graph contract as void-tags.ts): all consumers import it, so a new forbidden sink cannot be enforced on one boundary and missed on another. This module owns the named-sink deny lists and the attribute-name policy built on them (the one shared safe-attribute-name predicate and the one camelCase→kebab-case casing rule); consumers delegate so the boundary cannot diverge. The lists are fail closed and case-insensitive (attribute and property names are compared lowercase, matching the HTML parser's name folding): - `FORBIDDEN_ATTRIBUTE_NAMES`: attribute names that must never be a static attribute or an `attr`/`bool` sink. `srcdoc` smuggles a full HTML document past attribute escaping; `innerHTML` is admissible only through the dedicated trusted-HTML `html` Part, never as a plain attribute name. - `FORBIDDEN_PROPERTY_NAMES`: `prop` sink names that would re-prototype or re-construct the target element (prototype-pollution primitives). - `RAW_TEXT_TAGS`: raw-text elements are outside the compiled grammar — their content cannot be escaped by the serializer.
packages/protocol/src/forbidden-sinks.ts:28编译器不允许用作 @property 声明的属性名集合。
ReadonlySet<string>英文源码说明
Property names the compiler refuses as
packages/protocol/src/forbidden-sinks.ts:31统一禁用规则检查的写入目标类别。
ForbiddenSinkKind英文源码说明
Sink categories the canonical deny list classifies.
packages/protocol/src/forbidden-sinks.ts:41返回指定类别下某名称不允许写入的原因,名称可用时返回 null。
(kind: ForbiddenSinkKind, name: string): string | null英文源码说明
Return a human-readable reason when `name` is a forbidden sink of `kind`, or null when the name is admissible. Unknown kinds fail closed with a reason instead of being waved through.
packages/protocol/src/forbidden-sinks.ts:48统一检查属性名称是否符合安全规则。
(name: string): boolean英文源码说明
The one safe-attribute-name predicate (#1033, #602). Attribute *names* are not escaped on any render path, so a name must be valid HTML attribute-name grammar (blocks quote/space injection), must not be an event handler (`on*`, case-insensitive), and must not be a forbidden sink (`innerhtml`/ `srcdoc` — case-insensitive). Every boundary that admits an attribute name — the compiler semantic core, the Part Program validator, the compiled server validator, and the SSR head/meta name checks — delegates here, so the rules cannot diverge per path.
packages/protocol/src/forbidden-sinks.ts:81文本内容不可插入为标记的 HTML 元素标签集合。
ReadonlySet<string>英文源码说明
Elements whose text content must never be interpolated as markup.
packages/protocol/src/forbidden-sinks.ts:38兼容性扫描为每个标签记录分级、原因、来源和对应的 SSR、DSD 与 hydration 判定依据。
CompatibilityClassification英文源码说明
The per-tag verdict the compatibility scanner records: the tier a discovered tag was classified as, the human-readable `reason`, where the tag was found (`source`), and the SSR/DSD/hydration facts the verdict was derived from.
packages/protocol/src/framework.ts:347标签的构建兼容级别,区分服务端渲染、仅浏览器渲染、实验支持和拒绝构建。
CompatibilityTier英文源码说明
How far a discovered tag may participate in the build: 'ssr-capable' renders and hydrates, 'client-only' ships to the browser without server output, 'experimental-dom' is admitted with a downgraded guarantee, and 'rejected' fails the build.
packages/protocol/src/framework.ts:340组件的交付层级,区分静态 DSD、带交互岛的 DSD、仅客户端交互岛和 Light DOM。
ComponentLayer英文源码说明
The delivery layer a component belongs to: fully static DSD markup ('dsd-static'), DSD markup with a client island ('dsd-interactive'), a client-only island with no SSR output ('pure-island'), or a light-DOM element ('light-dom'). Recorded per component in the build manifest and consumed by the hydration scheduler.
packages/protocol/src/framework.ts:23FrameworkOptions英文源码说明
The adapter-facing framework options: where routes and islands live, the default layout and named-layout declarations, the document `<html>`/head injection channels, and the request-time middleware switches. Every field is optional; the adapter applies its documented default. This is the type an application config file's default export is checked against, so the rendered option table and the actual config surface cannot drift.
packages/protocol/src/framework.ts:180运行时支持的 hydration 策略列表,以及 HydrationStrategy 联合类型的来源。
readonly ["load", "idle", "visible", "only", "none"]英文源码说明
Runtime list of supported hydration strategies; the single source of truth for the `HydrationStrategy` union. Consumed by island/registry validation and re-exported from the element root for app and build adapters.
packages/protocol/src/framework.ts:28控制交互岛何时启用,也可跳过浏览器 hydration。
"load" | "idle" | "visible" | "only" | "none"英文源码说明
Island hydration trigger: 'load' | 'idle' | 'visible' | 'only'.
packages/protocol/src/framework.ts:30为路由选择内置布局、指定自定义布局及其模块和属性,或关闭布局。
LayoutConfig英文源码说明
Layout declaration: `false` disables the layout entirely, `'default'` uses the built-in layout, and the object form names a tag with the module path that defines it (`import`, resolved like a {@link FrameworkOptions.middleware.use } entry) plus the compiled layout properties the router injects per route.
packages/protocol/src/framework.ts:96随语言解析的路径契约。
LocalePath英文源码说明
Locale-aware resolved path contract.
packages/protocol/src/framework.ts:82基于标准 Request 和 Response 的洋葱式中间件。可直接返回响应,也可在 next() 返回后处理响应。
Middleware英文源码说明
Fetch middleware contract (#858): WinterCG shape, dialect-free — no Hono/h3 context object. Composed at the handler boundary in onion order (`use[0]` is outermost: it sees the request first and the response last), so it runs with identical semantics in the dev server, the `start` CLI, the e2e fixture server, and the Nitro production entry. A middleware may short-circuit by returning a Response without calling `next()`, or post-process the Response that `next()` returns. Module contract: a Middleware is the DEFAULT EXPORT of a module referenced from `middleware.use` by path (e.g. './app/middleware/auth.ts'). The generated server entry imports the module, so the middleware may close over module scope and import local helpers and third-party packages — it is a real module in the server module graph, never serialized source.
packages/protocol/src/framework.ts:169构建上下文中可选的博客内容目录和 URL 基础路径。
OpenElementBlogOptions英文源码说明
Blog options stored in the build context by
packages/protocol/src/framework.ts:37供子插件使用的最小构建上下文接口。
OpenElementBuildContextLike英文源码说明
Minimal build context interface that sub-plugins can use.
packages/protocol/src/framework.ts:62由 @openelement/i18n 保存到构建上下文的国际化配置。
OpenElementI18nContextOptions英文源码说明
i18n options stored in the build context by
packages/protocol/src/framework.ts:55扫描后入选的路由,记录 URL 路径、源文件、类型、生成入口使用的变量名和可选注册标签。
RouteEntry英文源码说明
One route admitted by the scanner: URL `path`, source `filePath`, the route `type`, the generated variable name (`varName`) the entry binds it to, and the optional registration tag. {@link RouteEntry.definePage} and {@link RouteEntry.hasEnhancedForms} carry the two source-derived admission facts the generated entries branch on.
packages/protocol/src/framework.ts:113表示已完成 HTML 转义,可作为文本内容使用的字符串类型。
SafeHtml英文源码说明
Branded type: a string that has been HTML-escaped (safe for text content)
packages/protocol/src/framework.ts:9路由扫描器按文件名识别的特殊类型,包括 renderer 和 middleware。
SpecialFileType英文源码说明
Special file kinds the route scanner recognizes by filename: `renderer` and `middleware`.
packages/protocol/src/framework.ts:79交互岛最终采用的 hydration 策略的来源。
StrategySource英文源码说明
Where an island's resolved hydration strategy came from.
packages/protocol/src/framework.ts:32标识尚未转义、未被信任的 HTML 字符串。
UnsafeHtml英文源码说明
Branded type: a string that is intentionally raw/untrusted HTML
packages/protocol/src/framework.ts:12交互岛的交付选项,包括 hydration 策略和是否参与 SSR 或 DSD。
IslandOptions英文源码说明
Per-island delivery options (hydration strategy, SSR/DSD participation).
packages/protocol/src/island.ts:8构建时转换交互岛源码所用的选项。
IslandTransformOptions英文源码说明
Options for the build-time island source transform.
packages/protocol/src/island.ts:42交互岛转换的结果,包括改写的源码和提取的信息。
IslandTransformResult英文源码说明
The island transform output: rewritten source plus extracted facts.
packages/protocol/src/island.ts:64路由器交给元素编译器的静态配置识别描述符。
StaticSidecarDescriptor英文源码说明
The static-sidecar descriptor router injects into the element compiler.
packages/protocol/src/island-admission.ts:18针对一份自定义元素清单的兼容性分类报告。
CemCompatibilityReport英文源码说明
The compatibility classification report for one custom element manifest.
packages/protocol/src/manifest.ts:146兼容性扫描为每个标签记录分级、原因、来源和对应的 SSR、DSD 与 hydration 判定依据。
CompatibilityClassification英文源码说明
The per-tag verdict the compatibility scanner records: the tier a discovered tag was classified as, the human-readable `reason`, where the tag was found (`source`), and the SSR/DSD/hydration facts the verdict was derived from.
packages/protocol/src/framework.ts:347标签的构建兼容级别,区分服务端渲染、仅浏览器渲染、实验支持和拒绝构建。
CompatibilityTier英文源码说明
How far a discovered tag may participate in the build: 'ssr-capable' renders and hydrates, 'client-only' ships to the browser without server output, 'experimental-dom' is admitted with a downgraded guarantee, and 'rejected' fails the build.
packages/protocol/src/framework.ts:340自定义元素声明中记录的一个 attribute。
OpenElementAttribute英文源码说明
One documented attribute of a custom element declaration.
packages/protocol/src/manifest.ts:15自定义元素声明中记录的一个 CSS part。
OpenElementCssPart英文源码说明
One documented CSS part of a custom element declaration.
packages/protocol/src/manifest.ts:38包清单中的自定义元素声明,包括标签名、成员和交付信息。
OpenElementDeclaration英文源码说明
One custom element declaration in a package manifest: tag, members and delivery metadata.
packages/protocol/src/manifest.ts:116自定义元素声明中记录的一个自定义事件。
OpenElementEvent英文源码说明
One documented custom event of a custom element declaration.
packages/protocol/src/manifest.ts:25包清单声明中的 openElement 扩展字段。
OpenElementExtensions英文源码说明
The openElement-specific extension block of a package manifest declaration.
packages/protocol/src/manifest.ts:72包级组件清单,记录其中声明的组件。
OpenElementPackageManifest英文源码说明
Package manifest of component declarations (not a Custom Elements Manifest).
packages/protocol/src/manifest.ts:129自定义元素声明中记录的一个插槽。
OpenElementSlot英文源码说明
One documented slot of a custom element declaration.
packages/protocol/src/manifest.ts:32OpenElementTailwindDeclaration英文源码说明
A declaration's utility-compilation requirement and the package-owned style sources that requirement compiles (the declared-compilation contract; see the router's `style-plan` module for the resolution rules). `required` is the mandatory-compilation dependency: the component's presentation cannot be delivered without the compile, so an application that disables the entry (`tailwind: false`) fails the build with a coded diagnostic instead of shipping an unstyled component. Merely offering a theme source is NOT a requirement — leave `required` unset for a source a consumer may adopt on its own. `sources` are package-relative paths (e.g. `./theme.css`) resolved against THIS package, so a consumer never repeats the owner's declaration. They must exist in the installed package (i.e. ship in the tarball). `dialect` names the CLASS LANGUAGE this component's utility tokens are written in, not the engine that compiles them: the declaration stays provider-neutral, and a selected provider that does not implement the dialect fails the build before any compile. Omitted means `tailwind4` — the language every declaration written before this field existed uses.
packages/protocol/src/manifest.ts:65描述模块扫描识别的导出绑定,以及调用该绑定时登记的事实。
ModuleVocabularyDescriptor英文源码说明
One module-scan vocabulary entry the host admits: a binding identity (module specifier + exported name, aliases followed) plus the fact a canonical call of that binding contributes. Plain data — the scan consumes the descriptors without learning the caller's package vocabulary, the same direction as the compiler's {@link StaticSidecarDescriptor} admission (#1473 item 3).
packages/protocol/src/module-descriptors.ts:33告诉元素编译器哪一项与组件放在同一模块的声明属于静态策略。
StaticSidecarDescriptor英文源码说明
One static-sidecar descriptor the host injects into the element compiler: the admission granted is a colocated static policy statement (#1473 item 3, the static-sidecar admission pattern).
packages/protocol/src/module-descriptors.ts:16路由器传给 analyzeModuleSemantics 的模块扫描识别规则。
readonly ModuleVocabularyDescriptor[]英文源码说明
The module vocabulary router injects into `analyzeModuleSemantics`.
packages/protocol/src/module-vocabulary.ts:17编译生成的自定义元素清单中的单个属性记录。
CemPropertyMetadata英文源码说明
One property entry of the compiled custom-elements-manifest metadata.
packages/protocol/src/part-program.ts:381一个组件编译生成的自定义元素清单元数据。
CompiledCemMetadata英文源码说明
The compiled custom-elements-manifest metadata block of one component.
packages/protocol/src/part-program.ts:390程序提供给工具读取的编译元素元数据。
CompiledElementMetadata英文源码说明
The compiled element metadata the program carries for tooling consumers.
packages/protocol/src/part-program.ts:399编译后的单个 @property 声明,记录名称、类型和反射设置。
CompiledPropertyMetadata英文源码说明
One compiled
packages/protocol/src/part-program.ts:362判断比较运算符与 when 区块中的字面量类型是否兼容。
(op: unknown, value: unknown): boolean英文源码说明
Operator/literal compatibility for when-Block tests (issue #1372). Both wire validators (this module and the server serializer's shared validator) close the space through this one predicate: - ordering operators require a finite numeric literal; - `equals`/`not-equals` admit a finite number, string, or boolean; - `truthy` admits exactly `true` or `false` (the recorded expectation).
packages/protocol/src/part-program.ts:260编译程序的条件表达式所支持的比较运算符。
ConditionOperator英文源码说明
The comparison operators a program condition supports.
packages/protocol/src/part-program.ts:236标识由服务端渲染的 Light DOM 宿主标签的内部属性。
"data-oe-light"英文源码说明
Internal SSR provenance marker on light-mode host tags (#1148). Present only when the host's light subtree was server-rendered under the in-place activation contract: the client binds the existing DOM instead of clearing it, and a parent's activation walk prunes the nested host's subtree. Client rendering never writes it and it is never removed. The writer (internal/compiled/server) and readers (internal/compiled/runtime) import this constant; nothing writes the literal.
packages/protocol/src/part-program.ts:459线格式校验器用来检查属性名的入口,采用统一校验规则。
(value: unknown): value is string英文源码说明
The wire-validator face of the one canonical attribute-name predicate (delegates to `./forbidden-sinks.ts`); exported for parity tests.
packages/protocol/src/part-program.ts:501每个 each 区块条目内独立生效的事件绑定。
ItemEventBinding英文源码说明
An event binding scoped to each item of an `each` block. The runtime attaches this listener to every item root node created by the block, making per-item handlers (onClick={this.select(row.id)}) expressible without fixed-path event parts.
packages/protocol/src/part-program.ts:295当前包定义的 Part Program 中间表示版本。
2英文源码说明
The Part Program IR version this package defines (currently v2).
packages/protocol/src/part-program.ts:23序列化程序标记中结束 Part 锚点的注释文本。
(index: number): string英文源码说明
The comment marker closing a part anchor in serialized program markup.
packages/protocol/src/part-program.ts:437初始数据运行时共用的锚点标记内容。
(index: number): string英文源码说明
Anchor marker payloads shared by seed runtime consumers.
packages/protocol/src/part-program.ts:432可序列化的 Part Program v2,用数据表示一个编译后的组件。
PartProgramV2英文源码说明
The serializable Part Program v2: one compiled component as data.
packages/protocol/src/part-program.ts:429所有执行模式共享的确定性程序格式。
PartProgramV2英文源码说明
The one deterministic program consumed by all execution modes.
packages/protocol/src/part-program.ts:409将信号值写入字符串型 DOM 特性的绑定。
ProgramAttrPart英文源码说明
String attribute sink bound to a Signal.
packages/protocol/src/part-program.ts:154记录编译程序所追踪的一个动态子树块及其边界。
ProgramBlockRecord英文源码说明
One block the program tracks: the boundaries of a dynamic subtree.
packages/protocol/src/part-program.ts:342将信号值写入布尔型 DOM 特性的绑定。
ProgramBoolPart英文源码说明
Boolean attribute sink bound to a Signal.
packages/protocol/src/part-program.ts:164将类名绑定到专用写入目标,明确该绑定对类名的归属。
ProgramClassPart英文源码说明
Specialized fixed sinks make ownership explicit for class and style text.
packages/protocol/src/part-program.ts:174`when` 条件绑定中的一个条件子句。
ProgramCondition英文源码说明
One condition clause of a when part.
packages/protocol/src/part-program.ts:246编译后的模块图记录的一项依赖。
ProgramDependencyRecord英文源码说明
One module dependency the compiled module graph records.
packages/protocol/src/part-program.ts:352读取绑定信号的列表,按列表项重复渲染模板。
ProgramEachPart英文源码说明
A list part: repeats its template node per item of a bound signal.
packages/protocol/src/part-program.ts:310编译程序树中的静态元素节点。
ProgramElementNode英文源码说明
A static element node of the program tree.
packages/protocol/src/part-program.ts:90一次事件绑定所分派的操作。
ProgramEventAction英文源码说明
The action one event part dispatches.
packages/protocol/src/part-program.ts:217将 DOM 事件的监听器连接到对应操作的绑定。
ProgramEventPart英文源码说明
An event binding part: listener wiring between DOM event and action.
packages/protocol/src/part-program.ts:225接收 `TrustedHtml` 信号值,并用其中的 HTML 替换目标元素的内容。
ProgramHtmlPart英文源码说明
Trusted-HTML content sink (alpha.9). The signal value must carry the runtime TrustedHtml capability; its HTML replaces the target element's content. The target's subtree is opaque to the claim path. The compiler emits this only for an explicit `innerHTML={this.<field>}` sink on an otherwise childless element — there is no implicit or discovery path to raw HTML.
packages/protocol/src/part-program.ts:199ProgramItemValueNode英文源码说明
Item-value text slot; valid only inside an `each` item template. `field` names the item field rendered by this slot — multi-field item templates carry one slot per field, and the compiler always emits it.
packages/protocol/src/part-program.ts:123由编译器标定的一个动态写入目标或范围锚点的准确位置。
ProgramLocation英文源码说明
Exact compiler-owned location for one dynamic sink or range anchor.
packages/protocol/src/part-program.ts:76无需读取绑定本身即可核查其标识与位置的记录。
ProgramLocationRecord英文源码说明
A location record also makes the identity auditable without inspecting parts.
packages/protocol/src/part-program.ts:84可由编译程序实例化的各类动态绑定的可辨识联合类型。
ProgramPart英文源码说明
The discriminated union of dynamic parts a program instantiates.
packages/protocol/src/part-program.ts:328标记编译程序树中动态绑定位置的锚点节点。
ProgramPartAnchorNode英文源码说明
The anchor node marking where a part binds in the tree.
packages/protocol/src/part-program.ts:112记录绑定相对于锚点的位置,包括偏移、行和列。
ProgramPosition英文源码说明
Where a part sits relative to its anchor.
packages/protocol/src/part-program.ts:45将信号值写入 DOM 属性,并保留 `path` 供读取初始数据的代码使用。
ProgramPropPart英文源码说明
DOM property sink bound to a Signal; `path` is retained for seed consumers.
packages/protocol/src/part-program.ts:144可序列化的具名引用位置,其引用值由生成的类提供。
ProgramRefPart英文源码说明
A named ref slot is serializable; the generated class supplies the ref value.
packages/protocol/src/part-program.ts:208描述一个编译程序树的根,树可包含元素、绑定锚点或文本。
ProgramRoot英文源码说明
The root of one program tree: element, part anchor, or text.
packages/protocol/src/part-program.ts:29标明程序源映射记录所对应的源代码实体类型。
ProgramSourceKind英文源码说明
The kind of source record a program source map entry carries.
packages/protocol/src/part-program.ts:59将源码片段的位置映射到编译器输出的记录。
ProgramSourceMap英文源码说明
The program source map: authored spans projected onto emitted records.
packages/protocol/src/part-program.ts:69源码中的半开区间 `[start, end)`,包含起点且排除终点。
ProgramSourceRange英文源码说明
A half-open [start, end) range into the authored source text.
packages/protocol/src/part-program.ts:52记录一个生成节点或绑定在源码中的出处。
ProgramSourceRecord英文源码说明
One source-map record: the authored origin of one emitted node or part.
packages/protocol/src/part-program.ts:62用于样式的编译绑定。
ProgramStylePart英文源码说明
A style binding part.
packages/protocol/src/part-program.ts:183编译程序树中的静态文本节点。
ProgramTextNode英文源码说明
A static text node of the program tree.
packages/protocol/src/part-program.ts:106绑定到单个信号的文本插值。
ProgramTextPart英文源码说明
A text interpolation part bound to one signal.
packages/protocol/src/part-program.ts:136静态程序树节点的可辨识联合类型。
ProgramTreeNode英文源码说明
The discriminated union of static tree nodes.
packages/protocol/src/part-program.ts:129按条件切换模板分支的动态绑定。
ProgramWhenPart英文源码说明
A conditional part: swaps template branches on a condition.
packages/protocol/src/part-program.ts:279编译属性默认值序列化后所带的值类型标记。
PropertyValueType英文源码说明
The serialized value-type tag of a compiled property default.
packages/protocol/src/part-program.ts:359指定编译组件将内容挂载到 Light DOM、开放 Shadow Root 或封闭 Shadow Root。
RootMode英文源码说明
How the compiled component attaches its root: light DOM or a shadow root.
packages/protocol/src/part-program.ts:26编译属性的默认值可采用的 JSON 可序列化类型。
SerializableValue英文源码说明
The JSON-serializable value shape a compiled property default admits.
packages/protocol/src/part-program.ts:36"data-oe-static-styles"英文源码说明
The one `<style>` element the server serializer emits as the first DSD template child when the class carries static styles (renderToString parity — pages never upgrade, so their styles must ship in the payload). The claim path skips exactly this marked node; a marked node on a style-less class is claim drift and fails closed.
packages/protocol/src/part-program.ts:448校验数据是否符合 Part Program v2,以及指令、所有权记录和路径是否合法。
(raw: unknown): asserts raw is PartProgram英文源码说明
Validate an unknown value as a Part Program v2. The validator is intentionally strict: unknown instruction kinds, missing ownership records and unsafe paths fail before a runtime can guess at their meaning.
packages/protocol/src/part-program.ts:911由编译器、序列化器与校验器共用的 HTML 空元素标签集合。
ReadonlySet<string>英文源码说明
HTML void elements — the ONE canonical tag set for every serializer, validator, and compiler in the workspace (issue #1220, M4). This module is import-free and host-free by design: it sits at the base of the module graph so the DOM runtime (internal/core/html-escape.ts), the Part Program exchange artifact (internal/protocol/part-program.ts), and the compiler semantic core can all consume the same definition without an import cycle or a second source of truth. Content is the full HTML Standard void-element list, `param` included. Do not redefine this set anywhere else; internal/core/html-escape.ts and internal/protocol/part-program.ts re-export it, and __tests__/void-tags-convergence.test.ts enforces the single owner.
packages/protocol/src/void-tags.ts:16环境缺少 requestIdleCallback 和 requestAnimationFrame 时,空闲 hydration 的备用延时(毫秒)。
50英文源码说明
Idle-hydration scheduling fallback (milliseconds) when neither `requestIdleCallback` nor `requestAnimationFrame` is available.
packages/protocol/src/policy.ts:70生成的服务端入口对 POST action 请求体施加的字节上限。需要上传更大文件时,可使用配置了明确上限的 API 路由。
number英文源码说明
Request-body bound (bytes) the generated entry applies to action POST routes; larger uploads belong on API routes with explicit limits.
packages/protocol/src/policy.ts:57renderToString 允许展开的嵌套元素层数,避免循环组合导致无穷递归。
8英文源码说明
Nested element expansion depth bound for `renderToString`: cyclic component composition fails closed instead of recursing without end.
packages/protocol/src/policy.ts:51一个流式路由允许在清单中声明的延迟字段数上限。
32英文源码说明
Deferred fields (declared streamed properties) one stream route's manifest may carry. The build scan, the server executor, and the browser seed contract enforce the same bound.
packages/protocol/src/policy.ts:24一个流式路由清单可以引用的 Part 和 Block 所有者数量上限。
64英文源码说明
Part/Block owners one stream route's manifest may address in total across all deferred fields.
packages/protocol/src/policy.ts:30流式载荷的最大序列化长度,以 UTF-16 码元计。
number英文源码说明
Serialized stream payload bound, as a string length in UTF-16 code units: one seed attribute or one deferred frame's markup may not exceed it. The server checks the JSON text and the rendered range before emitting; the browser checks the attribute before parsing.
packages/protocol/src/policy.ts:45流式 hydration 初始数据可携带的带类型属性数量上限。
64英文源码说明
Typed properties one streamed seed may carry: the browser seed contract rejects the WHOLE seed above this count, so an oversized component would silently fail to hydrate instead of failing loud at the server.
packages/protocol/src/policy.ts:37流式响应等待延迟字段完成的时间上限(毫秒)。
30000英文源码说明
Deferred-field resolution budget (milliseconds) for one streamed response: fields still pending when it expires are failed in place and the stream ends with the shell and whatever resolved.
packages/protocol/src/policy.ts:64"__openEntryDefined"英文源码说明
Property on the stub holding the generated entry's registration-ownership map (tag -> class it registered): a route module that self-registers its tag wins over the entry's registration, and on dev re-evaluation a fresh self-registered class must still win (#952).
packages/protocol/src/registry-markers.ts:30"__openElementGeneratedHosts"英文源码说明
Property on the SSR registry holding the generated-entry host pairing table (tag -> the compiler-emitted generated host renderer): written atomically by the registry guard together with the class registration (M11) and read by `@openelement/element`'s server serializer nested-composition seam. It lives on the registry (not on the class and not on the module namespace) for the same reasons the ownership markers do: one writer (the generated entry's guard), one reader (Element's serializer), no class static / suffix scan / runtime module-shape read, and the pairing survives vite dev SSR module re-evaluations together with the class it belongs to.
packages/protocol/src/registry-markers.ts:54标识 SSR 注册表中保存的原始 `define` 方法,生成入口在安装幂等包装前将它捕获。
"__openElementOrigDefine"英文源码说明
Property on the SSR registry holding the TRUE original `define` method, captured before the generated entry installs its idempotent wrapper. The registry outlives vite dev SSR module re-evaluations, so without this the second evaluation would capture the already-wrapped `define` as its "original" and every forced re-registration would silently early-return through the previous wrapper (#952 dev re-evaluation).
packages/protocol/src/registry-markers.ts:40在 SSR `customElements` 模拟注册表上标记 `true`,表明该注册表允许重新定义元素。
"__openElementSsrStub"英文源码说明
Marker property set to `true` on the SSR customElements stub. Readers must treat the marked registry as re-definable.
packages/protocol/src/registry-markers.ts:22组件或路由携带的水合加载提示。
HydrationHint英文源码说明
The hydration delivery hint a component or route carries.
packages/protocol/src/render.ts:26SSR 流水线报告的一条渲染错误记录。
RenderError英文源码说明
One render failure record the SSR pipeline reports.
packages/protocol/src/render.ts:16构建对自定义元素的 SSR 判定,记录模块路径、发现来源、渲染方式及原因。
SsrAdmissionDecision英文源码说明
The build's admission verdict for one discovered tag: where the declaration lives (`modulePath`), how it was discovered (`source`), which render path it is admitted to, and the reason recorded for the manifest.
packages/protocol/src/render.ts:37供运行时适配器和生成入口使用的统一请求处理函数,基于标准 Request 和 Response。
OpenElementRequestHandler<Env>英文源码说明
The host-neutral request handler every runtime adapter and generated server entry exposes: a WinterCG `(request, context?) => Response` with no server engine dialect baked in.
packages/protocol/src/runtime.ts:27宿主运行时适配器,向服务器引擎提供接收请求的 `fetch` 处理器。
RuntimeAdapter<Env>英文源码说明
A host runtime adapter: exposes the fetch handler a server engine dispatches to.
packages/protocol/src/runtime.ts:32构造运行时适配器时传入的选项。
RuntimeAdapterOptions<Env>英文源码说明
Options one runtime adapter is constructed with.
packages/protocol/src/runtime.ts:39运行时适配器的上下文契约,用来隔离框架和部署环境。
RuntimeContext<Env>英文源码说明
runtime.ts - Runtime adapter protocol. Replacement boundary for Nitro, Workers, Node, Deno, or future fetch-compatible runtimes. Preserves openElement semantics while leaving concrete server engines outside this package.
packages/protocol/src/runtime.ts:9computed 等派生值使用的只读信号接口。
ReadonlySignal<T>英文源码说明
Read-only signal protocol used by computed values.
packages/protocol/src/signal.ts:26接受可写信号或只读信号的 API 所用类型。
Signal<T>英文源码说明
Alias for APIs that accept either writable or read-only signals.
packages/protocol/src/signal.ts:31标识当前配置的响应式引擎所创建的信号,供运行时和类型系统识别。
typeof SIGNAL_BRAND英文源码说明
Runtime/type brand for signals created by the configured reactive engine.
packages/protocol/src/signal.ts:11框架内置适配器使用的信号引擎协议。
SignalEngine英文源码说明
Signal engine protocol used by the framework's built-in adapter. This is a deliberate internal seam, not a public compatibility contract: the framework layer talks to signals only through this narrow interface so its call sites stay implementation-agnostic. The package ships and verifies exactly one engine implementation (`preact-engine`, backed by `@preact/signals-core`). Preact's own API is not Element public API, and arbitrary third-party engines are not promised; any future engine would be added behind this protocol rather than inline (charter decision — see #723).
packages/protocol/src/signal.ts:46渲染器和绑定接受的最简信号对象接口。
SignalLike<T>英文源码说明
Minimal signal-like object accepted by renderers and bindings.
packages/protocol/src/signal.ts:14订阅和响应式副作用返回的取消订阅函数。
Unsubscribe英文源码说明
Unsubscribe function returned by subscriptions and effects.
packages/protocol/src/signal.ts:8openElement 集成使用的可写信号协议。
WritableSignal<T>英文源码说明
Writable signal protocol used by openElement integrations.
packages/protocol/src/signal.ts:21生成入口描述符中的一条 API 路由声明。
ApiRouteDecl英文源码说明
One API route declaration in the generated entry descriptor.
packages/protocol/src/ssg.ts:163openElement 构建流程返回的产物。
BuildArtifacts英文源码说明
Result returned by the OpenElement build pipeline.
packages/protocol/src/ssg.ts:565构建流水线输出的一项客户端资源。
BuildClientAsset英文源码说明
A single client asset emitted by the build pipeline.
packages/protocol/src/ssg.ts:558构建流水线的国际化配置。
BuildI18nOptions英文源码说明
i18n configuration for the build pipeline.
packages/protocol/src/ssg.ts:511构建流水线接收的一项交互岛输入。
BuildIslandInput英文源码说明
A single island input to the build pipeline.
packages/protocol/src/ssg.ts:492构建流水线输出的清单产物。
BuildManifestArtifact英文源码说明
Manifest produced by the build pipeline.
packages/protocol/src/ssg.ts:547构建流水线的输出配置。
BuildOutputOptions英文源码说明
Output configuration for the build pipeline.
packages/protocol/src/ssg.ts:501构建流水线中由包提供的交互岛的配置。
BuildPackageIslandOptions英文源码说明
Package island configuration for the build pipeline.
packages/protocol/src/ssg.ts:517一份生成的 HTML 页面产物。
BuildPageArtifact英文源码说明
A single generated HTML page artifact.
packages/protocol/src/ssg.ts:539openElement 构建流水线接收的框架无关构建计划。
BuildPlan英文源码说明
Framework-agnostic plan consumed by the OpenElement build pipeline.
packages/protocol/src/ssg.ts:523构建流水线接收的一条路由输入。
BuildRouteInput英文源码说明
A single route input to the build pipeline.
packages/protocol/src/ssg.ts:474传给入口生成器的客户端交互岛条目结构。
ClientIslandEntry英文源码说明
Client island entry shape passed to entry generator.
packages/protocol/src/ssg.ts:105API 路由声明的 CORS 来源策略。
CorsOriginConfig英文源码说明
The CORS origin policy an API route declares.
packages/protocol/src/ssg.ts:130路由或文档声明的内容安全策略(CSP)指令。
CspConfig英文源码说明
The content-security-policy directives a route or document declares.
packages/protocol/src/ssg.ts:133构建时写入生成入口的文档级配置。
DocumentConfig英文源码说明
The document-level facts a build bakes into the generated entry.
packages/protocol/src/ssg.ts:286一个生成入口的完整构建描述,包含路由、交互岛、渲染器、中间件、文档和布局计划。
EntryDescriptor英文源码说明
The full build-time description of one generated entry: routes, islands, renderers, middleware, document, and layout plans.
packages/protocol/src/ssg.ts:321生成入口输出的一条模块导入声明。
ImportDecl英文源码说明
One module import the generated entry emits.
packages/protocol/src/ssg.ts:123构建纳入的一个交互岛的声明,包括标签名、模块路径和加载方式。
IslandDecl英文源码说明
One island the build admits: tag, module path, and delivery facts.
packages/protocol/src/ssg.ts:195由适配器决定的浏览器交付策略,可依据媒体查询决定是否交付。
IslandDeliveryStrategy英文源码说明
Adapter-owned browser delivery strategy, including media-query admission.
packages/protocol/src/ssg.ts:31交互岛记录共用的模块标识,包含注册标签、模块路径及包来源信息。
IslandModuleIdentity英文源码说明
Shared island module identity (CL-3 convergence: one base, three shapes). Every island record names the same module the same way — the tag it registers as, the module path that owns it, and whether that module is a package (CEM-derived named export) rather than a local file (default export) — so a rename of the identity touches one declaration, not three. The delivery-strategy fields intentionally stay per-shape (`strategy` on the client entry vs `hydrate` on the build decls): they are different stages' vocabularies, not one field spelled two ways.
packages/protocol/src/ssg.ts:98构建解析出的布局模块声明,包含标签名、导入路径和序列化属性。
LayoutDecl英文源码说明
The layout module a build resolves: tag, import path, and serialized props.
packages/protocol/src/ssg.ts:294构建最终交付的布局计划,包含默认布局和具名布局。
LayoutPlan英文源码说明
The resolved layouts a build ships: the default layout plus named layouts.
packages/protocol/src/ssg.ts:315由生成入口纳入执行链的一个中间件模块声明。
MiddlewareDecl英文源码说明
One middleware module the generated entry composes.
packages/protocol/src/ssg.ts:140一个中间件的适用范围,可覆盖全部路由或一组具名路由。
MiddlewareScopeDecl英文源码说明
The scope one middleware applies to (all routes or a named route set).
packages/protocol/src/ssg.ts:279生成入口描述符中的一条页面路由声明。
PageRouteDecl英文源码说明
One page route declaration in the generated entry descriptor.
packages/protocol/src/ssg.ts:172一条页面渲染器模块注册记录。
RendererDecl英文源码说明
One page renderer module registration.
packages/protocol/src/ssg.ts:271布局计划中一个位置的解析结果,可为 `false`(禁用)或完整声明。
ResolvedLayout英文源码说明
The resolved layout for one plan slot: disabled (false) or a full declaration.
packages/protocol/src/ssg.ts:312生成的 SSG 入口模块通过 `routeInfo` 输出的一条路由元数据。
RouteInfoEntry英文源码说明
A single route metadata entry emitted as `routeInfo` by the generated SSG entry module (see entry-render-ssg.ts).
packages/protocol/src/ssg.ts:395静态生成后处理使用的 Speculation Rules 配置。
SpeculationRulesOptions英文源码说明
Speculation Rules configuration for SSG post-processing
packages/protocol/src/ssg.ts:448面向应用的静态站点生成构建选项。
SsgBehaviorOptions英文源码说明
User-facing SSG build behavior switches (OpenElementOptions['ssg']).
packages/protocol/src/ssg.ts:63`renderRoute()` 返回的单页渲染诊断结果。
SsgPageOutput英文源码说明
Per-page render diagnostics returned by renderRoute()
packages/protocol/src/ssg.ts:368SSG 引擎为每次构建输出的渲染审计记录。
SsgRenderEvidence英文源码说明
The per-build render evidence record the SSG engine emits for audit.
packages/protocol/src/ssg.ts:426传给共用 SSG 渲染流水线的选项。
SsgRenderOptions英文源码说明
Options passed to the shared SSG render pipeline.
packages/protocol/src/ssg.ts:36`ssgRender()` 返回的一次 SSG 渲染汇总。
SsgRenderSummary英文源码说明
Summary of an SSG render run, returned by ssgRender().
packages/protocol/src/ssg.ts:72构建时按组件标签记录的 SSR 准入决策。
SsrAdmissionPlan英文源码说明
The build-time SSR admission decisions per component tag.
packages/protocol/src/ssg.ts:253SSG 引擎执行流式渲染时读取的服务端包信息。
SsrBundle英文源码说明
The server bundle facts the SSG engine consumes for stream rendering.
packages/protocol/src/ssg.ts:417从路由的本地导入图发现的静态编译组件声明,供构建纳入递归 SSR 或 SSG,且不会添加水合或浏览器入口。
StaticComponentDecl英文源码说明
Build-host-only compiled component reached through a route's local import graph. These components participate in recursive SSR/SSG expansion but are not client islands and therefore add no hydration or browser entry.
packages/protocol/src/ssg.ts:217构建时绑定到某个编译页面程序的路由信息。
StreamRouteManifest英文源码说明
Build-only route projection bound to a specific compiled page program.
packages/protocol/src/ssg.ts:13浏览器拒绝装入所属 Part 范围的流式片段所禁用的标签。
readonly ["script", "style", "template", "iframe", "object", "embed", "base", "meta", "link"]英文源码说明
Tags a deferred frame cannot safely install into an owned Part range: the browser installer rejects any frame whose markup carries one of these.
packages/protocol/src/stream-frame-policy.ts:26流式片段的 URL 属性不可使用的协议。
RegExp英文源码说明
Schemes that make a URL attribute unsafe in a streamed frame.
packages/protocol/src/stream-frame-policy.ts:60流式片段中需要检查 URL 协议的属性名。
readonly ["href", "src", "action", "formaction", "xlink:href"]英文源码说明
URL-carrying attributes the frame check screens for script-bearing scheme obfuscation; only these attribute names are value-screened.
packages/protocol/src/stream-frame-policy.ts:42检查 URL 协议前,会移除码点低于或等于此值的控制字符。
32英文源码说明
Control characters at or below this code point are stripped before the URL-scheme test, so tab/newline/control obfuscation cannot smuggle a scheme past admission.
packages/protocol/src/stream-frame-policy.ts:55判断 Part Program 中的静态属性是否会使流式片段无法通过安装校验。
(name: string, value: string): boolean英文源码说明
Whether a static attribute (name/value as authored into the Part Program) makes a streamed frame unsafely installable: event-handler, seed-spoofing, and srcdoc names fail outright, and URL-carrying names fail when the entity-decoded, control-stripped value carries a script scheme.
packages/protocol/src/stream-frame-policy.ts:113编译器内部字段,用于在渲染的宿主记录中存放展开嵌套宿主的函数。
"__oe_nestedHost"英文源码说明
The compiler-private field a render's host record carries the nested-host expander under (P-6, 2026-11-21). A generated component's SSR producer routes every custom-element tag through the runtime's ONE `nestedHost` helper, which reads the expander off this record. The LIGHT root's producer has always supplied it; the SHADOW host producer did not, so a shadow page's inner components stayed bare tags while the class lane and the light lane both expanded theirs. It lives in the protocol for the same reason the sheet keys above do: the COMPILER emits the record and the RUNTIME reads it, and the compiler must not depend on an element-internal subpath to spell it. One literal, two ends.
packages/protocol/src/style-sheet.ts:80用来标记可在开发期间热更新的样式表资源的键。
"__openElementStyleSheetLive"英文源码说明
The one key marking a sheet whose bytes are a LIVE resource rather than an immutable one (alpha15 S lane, S-C1.3). The dev server serves an authored sheet from a mutable endpoint that hot-updates: the sheet object is the copy the live resource re-fills through `replace()`, so every root that adopted it re-renders on an edit. A root whose serialized markup declares the same URL therefore still ADOPTS this sheet — the declarative `<link>` stays the first-paint / no-JavaScript delivery, and the adopted object is the one an edit reaches. Without that, a CSS-only edit could only be delivered by re-fetching the link, which is a DOM write this protocol does not perform. Production sheets never carry this key: their URL is content-addressed, so the link and the sheet can never disagree and one delivery is the whole story. Build-time and runtime cannot drift because the dev adapter generator interpolates this exact name.
packages/protocol/src/style-sheet.ts:64"__openElementStyleReady"英文源码说明
The one key under which a sheet carries its readiness promise: the generated client style adapter records it on the sheet it exports, and the element runtime reads the same key to hand styles to roots that are already connected. Build-time and runtime cannot drift because the adapter generator interpolates this exact name. The promise settles once. Fulfillment means the rules were installed through `replace()`; rejection carries the load or replacement failure and keeps its rejected state — an observer may attach its own catch, it must never convert the promise into a fulfilled one.
packages/protocol/src/style-sheet.ts:31"__openElementStyleSheetUrl"英文源码说明
The one key under which a sheet carries the URL of the external CSS resource that delivers its rules: the generated client style adapter records the emitted asset URL on the sheet it exports, and the element runtime compares it against the declarative `<link rel="stylesheet" data-oe-static-styles>` nodes an SSR/DSD template already carries (alpha15 S lane). A root whose serialized markup already references the sheet's URL keeps that link as the delivery and does NOT adopt a second constructable copy — one stylesheet resource, one delivery, no duplicate application. Build-time and runtime cannot drift because the adapter generator interpolates this exact name.
packages/protocol/src/style-sheet.ts:44原生样式表与兼容实现共用的最小接口,包括 replaceSync 和 cssRules。
StyleSheetLike英文源码说明
Minimal stylesheet contract (replaceSync + cssRules) satisfied by native and shim sheets.
packages/protocol/src/style-sheet.ts:14浏览器与 SSR 环境共用的 `CSSStyleSheet` 抽象。
StyleSheetRule英文源码说明
Cross-environment CSSStyleSheet abstraction. In browsers this delegates to the native CSSStyleSheet API. In SSR runtimes it falls back to a minimal in-memory implementation that exposes the subset used by OpenElement and renderToString().
packages/protocol/src/style-sheet.ts:9由编译器、序列化器与校验器共用的 HTML 空元素标签集合。
ReadonlySet<string>英文源码说明
HTML void elements — the ONE canonical tag set for every serializer, validator, and compiler in the workspace (issue #1220, M4). This module is import-free and host-free by design: it sits at the base of the module graph so the DOM runtime (internal/core/html-escape.ts), the Part Program exchange artifact (internal/protocol/part-program.ts), and the compiler semantic core can all consume the same definition without an import cycle or a second source of truth. Content is the full HTML Standard void-element list, `param` included. Do not redefine this set anywhere else; internal/core/html-escape.ts and internal/protocol/part-program.ts re-export it, and __tests__/void-tags-convergence.test.ts enforces the single owner.
packages/protocol/src/void-tags.ts:16↑ ↓ 选择 · Tab 查看 · Esc 返回
@openelement/element
441 个导出为当前服务端进程设置已生成的样式表 URL。
(urls: readonly string[] | null | undefined, islandEntries?: ReadonlyArray<readonly [string, readonly string[] | null]> | null): void英文源码说明
Set the emitted stylesheet URLs for this server process. Called by the router's generated SSR/SSG entry (build time and request-time startup) with the base-joined asset addresses Phase 2 emitted. The optional `islandEntries` half carries the per-tag URLs of generated SHADOW hosts (M09-2e / #1803) through the SAME channel: one setter, one entry import, no second public seam. A `null` URL list is the explicit "declared but carrier unavailable" state the nested renderer fails closed on.
packages/element/src/internal/compiled/server/style-links.ts:34处理页面路由的表单提交。
Action<T, Env, Platform, Route>英文源码说明
Route action: handles form submissions for a page route.
packages/protocol/src/data.ts:64选择表单 action 的响应通道。true 返回序列化结果,enhance 返回与无脚本提交相同的 HTML。
"x-openelement-action"英文源码说明
Request header selecting the action response channel: `true` marks a programmatic caller and selects the serialized ActionResult union; `enhance` marks the built-in morph enhancement and selects the same full-HTML responses the no-JS path receives.
packages/protocol/src/data.ts:125传给路由 action 的上下文,包含 loader 上下文。
ActionContext<Env, Platform, Route>英文源码说明
Context passed to a route action function (extends loader context).
packages/protocol/src/data.ts:47脚本提交表单时返回的联合类型。校验失败返回 failure,成功提交返回 redirect;协议错误使用 ProblemDetails。
ActionResult<Failure>英文源码说明
Wire shape returned to the JavaScript form-enhancement path. The no-JS path never sees this: it gets the equivalent semantics as plain HTTP (303 on success, 422 with the re-rendered form on validation failure, redirect/error as status codes). Success carries no data envelope. The application-loop contract makes a successful non-GET action answer 303 (PRG) — the framework never answers 200 with a rendered page, or with a success document, for a successful mutation — so the fetch channel answers `{ type: 'redirect' }` naming the PRG target and the authored return value is discarded by design. Success data travels the PRG target instead (query state the loader re-runs with, which the props projector then maps; see the router guide's "Form actions" section). The union previously declared a `{ type: 'success' }` member that no code path ever emitted — removed so the type matches the wire. Error outcomes (CSRF 403, unknown action 404, unparseable body 400, unexpected 500) are NOT part of this union: since #863 they answer RFC 9457 Problem Details with the PROBLEM_JSON_MEDIA_TYPE content type — see ProblemDetails.
packages/protocol/src/data.ts:92检查名称是否符合自定义元素的标签名规则。
(tagName: string): void英文源码说明
Assert that a tag name is a valid custom element name.
packages/element/src/internal/core/tag-utils.ts:50收集宿主对象上所有公开的自有属性。
(host: object): Record<string, unknown>英文源码说明
Collect all public (non-internal) own properties from a host object. Keys starting with `__openElement` are framework-internal and excluded. Uses Reflect.get for safe access (respects getters); a getter that throws is skipped with a warning so one bad prop cannot take the tree down.
packages/element/src/internal/core/props-utils.ts:41兼容性扫描为每个标签记录分级、原因、来源和对应的 SSR、DSD 与 hydration 判定依据。
CompatibilityClassification英文源码说明
The per-tag verdict the compatibility scanner records: the tier a discovered tag was classified as, the human-readable `reason`, where the tag was found (`source`), and the SSR/DSD/hydration facts the verdict was derived from.
packages/protocol/src/framework.ts:347标签的构建兼容级别,区分服务端渲染、仅浏览器渲染、实验支持和拒绝构建。
CompatibilityTier英文源码说明
How far a discovered tag may participate in the build: 'ssr-capable' renders and hydrates, 'client-only' ships to the browser without server output, 'experimental-dom' is admitted with a downgraded guarantee, and 'rejected' fails the build.
packages/protocol/src/framework.ts:340组件的交付层级,区分静态 DSD、带交互岛的 DSD、仅客户端交互岛和 Light DOM。
ComponentLayer英文源码说明
The delivery layer a component belongs to: fully static DSD markup ('dsd-static'), DSD markup with a client island ('dsd-interactive'), a client-only island with no SSR output ('pure-island'), or a light-DOM element ('light-dom'). Recorded per component in the build manifest and consumed by the hydration scheduler.
packages/protocol/src/framework.ts:23根据依赖计算一个只读响应式值。
<T>(fn: () => T): ReadonlySignal<T>英文源码说明
Create a derived read-only signal recomputed from its dependencies.
packages/element/src/internal/signal/framework.ts:23将上下文投影为消费端的响应式值。传入宿主时,消费端负责通过 releaseConsumedContext 释放订阅。
<T>(context: Context<T>, host?: HTMLElement): WritableSignal<T>英文源码说明
Consumer-local reactive projection of a protocol context value. When a `host` is given, the returned signal is bridged to the nearest provider through one Community Context Protocol subscription. That bridge is owned by the CALLER: a long-lived consumer must release it when it tears down (typically `disconnectedCallback`) with {@linkcode releaseConsumedContext}, exactly once. Releasing detaches the provider bridge, so the provider no longer retains or updates the local signal; the local signal itself stays usable with its last value. A call after a successful release is a no-op, and a signal created without a `host` has no bridge to release.
packages/element/src/internal/core/signal-context.ts:183上下文令牌,包含协议使用的键和默认值。
Context<T>英文源码说明
A typed context token: protocol identity (`key`) plus its default value.
packages/element/src/internal/core/signal-context.ts:13创建供提供方与消费方共享的带类型上下文令牌。
<T>(key: symbol, defaultValue: T): Context<T>英文源码说明
Create a typed context token shared between provider and consumer elements.
packages/element/src/internal/core/signal-context.ts:58为一次服务端渲染创建文档级样式表收集器。
(): DocumentStyleResources英文源码说明
Create the per-render document stylesheet collection.
packages/element/src/internal/core/html-escape.ts:133创建在每条消息前加上标签的日志记录器。
(tag: string): Logger英文源码说明
Create a {@link Logger} that prefixes every message with `[tag]`.
packages/element/src/internal/core/logger.ts:18从不可信属性复制数据时必须排除的对象原型键。
ReadonlySet<string>英文源码说明
Object prototype keys that must never be injected from untrusted props.
packages/element/src/internal/core/security.ts:25在指定根节点及其嵌套 Shadow Root 中查找匹配 ID 的元素,返回首个匹配项。
(id: string, root?: Document | ShadowRoot): HTMLElement | null英文源码说明
Resolve `id` (a `#hash` or bare id) against `root` and, when the id is not in that root's own tree, recurse into every nested shadow root. Returns the first match or `null`; a malformed percent-encoded id is not an error.
packages/element/src/internal/core/deep-fragment.ts:20使用相同的文档序列化规则生成流式响应的首尾片段,保留正文容器供流写入。
(options?: DocumentWrapOptions): { prefix: string; suffix: string; }英文源码说明
The same document serialization boundary, with only body wrappers left open.
packages/element/src/internal/core/html-escape.ts:205记录一次服务端渲染所发现的文档级样式表,供组件序列化与文档 head 共用。
DocumentStyleResources英文源码说明
The document-level stylesheet resources ONE server render discovered (alpha15 S lane, S-C1.2). A light-root component's DOM lives in the document, so its sheet cannot ride the component's own subtree the way a shadow template's link does: the document owns it. This object is the one carrier between the two halves of that render — the compiled serializer, which discovers a component's external sheets while serializing the component, and the document serializer, which writes the head. It is created per render and never shared, so one page's stylesheets can never reach another page's head.
packages/element/src/internal/core/html-escape.ts:125运行副作用,并在使用的信号发生变化时重新执行和订阅。
(fn: () => void | Unsubscribe): Unsubscribe英文源码说明
Run a side effect that re-subscribes whenever its signal dependencies change.
packages/element/src/internal/signal/framework.ts:27在元素升级前捕获发往待启用交互岛的用户操作,接管 DOM 成功后重放。
(root?: EventTarget, pendingTags?: readonly string[]): void英文源码说明
Install the bounded pre-upgrade interaction capture on an owning root (default: the document). Generated client entries call this with their declared island tags before any compiled element upgrades; after a successful claim the element replays the captured events whose targets live inside its root (compiled claim capture/replay, internal/compiled/runtime.ts). Idempotent per root (repeat calls merge tags, never reinstall listeners) and a no-op where no DOM exists (SSR). Invariant: the capture itself — one fixed listener set per owning root, installed once per page — is page-lifetime by design and is NOT the leak. The M1 leak was retained event-target records; each element releases exactly its own records at its activation decision (success or failure), while records owned by still-pending elements survive for their delayed/lazy upgrade (#1170). Boundedness: the facade capture passes the declared-island filter, so only interactions under a still-pending DECLARED island tag enter the queue — ordinary events and undeclared third-party custom elements are skipped (nested pending declared islands still capture through their own unsettled host). With no tags declared the legacy dash heuristic applies. The shared queue carries a hard capacity cap (fail closed), detached records are swept when a claim root adopts its share (and under queue pressure), and each activation decision deterministically empties that root's own bucket, so post-hydration traffic and removals never grow retention.
packages/element/src/internal/compiled/runtime/pre-upgrade-events.ts:662openElement 错误消息使用的前缀。
"[openElement]"英文源码说明
Error message prefix for all openElement errors.
packages/protocol/src/errors.ts:50接收所有通过错误遥测渠道上报的 OpenElementError。
ErrorTelemetryHook英文源码说明
Callback receiving every reported {@linkcode OpenElementError} for telemetry.
packages/protocol/src/errors.ts:132对 HTML 属性值进行转义。
(value: string): string英文源码说明
Escape an HTML attribute value. Delegates to `escapeHtml` so both share the single `ESCAPE_MAP` and the same single-pass replacement (consolidated in #633). Empty-value conventions remain intentionally distinct by design: - `escapeHtml` returns '' for non-string input. - `escapeAttrValue` (below) coerces via `String()` and is the boundary meant for unknown/variable attribute values.
packages/element/src/internal/core/html-escape.ts:55对文本中的五个 HTML 特殊字符进行转义。
(str: string): string英文源码说明
Escape the five HTML-significant characters in text content.
packages/element/src/internal/core/html-escape.ts:39将未知类型的异常值格式化为可读的字符串。
(e: unknown): string英文源码说明
Format an unknown thrown value as a human-readable string.
packages/element/src/internal/core/errors.ts:52FrameworkOptions英文源码说明
The adapter-facing framework options: where routes and islands live, the default layout and named-layout declarations, the document `<html>`/head injection channels, and the request-time middleware switches. Every field is optional; the adapter applies its documented default. This is the type an application config file's default export is checked against, so the rendered option table and the actual config surface cannot drift.
packages/protocol/src/framework.ts:180运行时支持的 hydration 策略列表,以及 HydrationStrategy 联合类型的来源。
readonly ["load", "idle", "visible", "only", "none"]英文源码说明
Runtime list of supported hydration strategies; the single source of truth for the `HydrationStrategy` union. Consumed by island/registry validation and re-exported from the element root for app and build adapters.
packages/protocol/src/framework.ts:28控制交互岛何时启用,也可跳过浏览器 hydration。
"load" | "idle" | "visible" | "only" | "none"英文源码说明
Island hydration trigger: 'load' | 'idle' | 'visible' | 'only'.
packages/protocol/src/framework.ts:30环境缺少 requestIdleCallback 和 requestAnimationFrame 时,空闲 hydration 的备用延时(毫秒)。
50英文源码说明
Idle-hydration scheduling fallback (milliseconds) when neither `requestIdleCallback` nor `requestAnimationFrame` is available.
packages/protocol/src/policy.ts:70将调用方提供的属性写入目标对象,跳过受保护的键,并容忍只读属性。
(target: Record<string, unknown>, props: Record<string, unknown>, tagName: string, log?: { warn(message: string): void; debug(message: string): void; }): void英文源码说明
Safely assign caller-supplied props onto a target object, skipping keys that could enable prototype pollution and tolerating read-only properties. The canonical guarded assigner for the canonical dangerous-key rule (#903, #1214): the
packages/element/src/internal/core/security.ts:131判断属性键是否为框架在写入属性时必须拒绝的对象原型键。
(key: string): boolean英文源码说明
Shared dangerous-key predicate (#903, #1214). Prototype-internal keys must never be injected from untrusted props on ANY path: host prop collection (collectPublicProps / normalizePublicProps in props-utils.ts), guarded assignment (injectPropsSafe below — the SPA bootstrap page-projection write boundary in
packages/element/src/internal/core/security.ts:53交互岛的交付选项,包括 hydration 策略和是否参与 SSR 或 DSD。
IslandOptions英文源码说明
Per-island delivery options (hydration strategy, SSR/DSD participation).
packages/protocol/src/island.ts:8服务端渲染检查属性名时调用的公共校验入口,规则和协议层一致。
(name: string): boolean英文源码说明
Shared safe-attribute-name predicate (#1033): the SSR face of the one canonical predicate in `../protocol/forbidden-sinks.ts`. A name must be valid HTML attribute-name grammar (blocks quote/space injection, #602), must not be an event handler (`on*`, case-insensitive), and must not be a forbidden sink (`innerhtml`/`srcdoc`). The compiler, protocol validator, and server serializer enforce the same predicate with their own failure strategies; every path delegates to the single implementation, so the boundary cannot diverge.
packages/element/src/internal/core/security.ts:67判断字符串是否符合 HTML 自定义元素的标签名规则。
(tagName: string): boolean英文源码说明
Check if a tag name is a valid custom element name per HTML spec.
packages/element/src/internal/core/tag-utils.ts:38为路由选择内置布局、指定自定义布局及其模块和属性,或关闭布局。
LayoutConfig英文源码说明
Layout declaration: `false` disables the layout entirely, `'default'` uses the built-in layout, and the object form names a tag with the module path that defines it (`import`, resolved like a {@link FrameworkOptions.middleware.use } entry) plus the compiled layout properties the router injects per route.
packages/protocol/src/framework.ts:96为页面路由获取数据的 loader。
Loader<T, Env, Platform, Route>英文源码说明
Route loader: fetches data for a page route.
packages/protocol/src/data.ts:56传给动态路由 loader 的请求上下文。
LoaderContext<Env, Platform, Route>英文源码说明
Context passed to a request-time ('dynamic') route loader.
packages/protocol/src/data.ts:40随语言解析的路径契约。
LocalePath英文源码说明
Locale-aware resolved path contract.
packages/protocol/src/framework.ts:82带标签的控制台日志接口。
Logger英文源码说明
logger.ts - Tagged console logger. Lightweight scoped logger. Returns plain functions so it is tree-shakable and has zero class overhead.
packages/element/src/internal/core/logger.ts:10生成的服务端入口对 POST action 请求体施加的字节上限。需要上传更大文件时,可使用配置了明确上限的 API 路由。
number英文源码说明
Request-body bound (bytes) the generated entry applies to action POST routes; larger uploads belong on API routes with explicit limits.
packages/protocol/src/policy.ts:57renderToString 允许展开的嵌套元素层数,避免循环组合导致无穷递归。
8英文源码说明
Nested element expansion depth bound for `renderToString`: cyclic component composition fails closed instead of recursing without end.
packages/protocol/src/policy.ts:51基于标准 Request 和 Response 的洋葱式中间件。可直接返回响应,也可在 next() 返回后处理响应。
Middleware英文源码说明
Fetch middleware contract (#858): WinterCG shape, dialect-free — no Hono/h3 context object. Composed at the handler boundary in onion order (`use[0]` is outermost: it sees the request first and the response last), so it runs with identical semantics in the dev server, the `start` CLI, the e2e fixture server, and the Nitro production entry. A middleware may short-circuit by returning a Response without calling `next()`, or post-process the Response that `next()` returns. Module contract: a Middleware is the DEFAULT EXPORT of a module referenced from `middleware.use` by path (e.g. './app/middleware/auth.ts'). The generated server entry imports the module, so the middleware may close over module scope and import local helpers and third-party packages — it is a real module in the server module graph, never serialized source.
packages/protocol/src/framework.ts:169生成的自定义元素每次连接时运行回调,包括重新连接。若回调返回清理函数,元素断开时会调用它。
(callback: (env: { readonly host: HTMLElement; readonly signal: AbortSignal; readonly states: CustomStateSet; }) => void | (() => void)): void英文源码说明
Compiler-recognized connect intrinsic: runs the callback on every connection of the generated element (initial mount and each reconnect) and releases the optional returned cleanup at that disconnection. Erased by the compiler; calling it at runtime fails closed. The callback may keep the original zero-argument form or declare ONE `env` parameter. `env.host` is the generated element the connection belongs to (for a depth-1 retained hostless child: its nearest ancestor generated element), and `env.signal` aborts at the START of that disconnection, before any registered cleanup runs; a reconnect gets a fresh, un-aborted signal. The parameter's type is the author-facing contract only — the compiler erases it and passes the value from the connection scope the callback runs in.
packages/element/src/internal/core/compile-lifecycle.ts:58在生成的元素实例最终销毁时运行一次回调,调用顺序在该连接的清理函数之后。
(callback: (env: { readonly host: HTMLElement; readonly signal: AbortSignal; readonly states: CustomStateSet; }) => void): void英文源码说明
Compiler-recognized dispose intrinsic: runs the callback exactly once when the generated element instance is torn down (explicit `dispose()`), after that connection's connect-cleanups. Erased by the compiler; calling it at runtime fails closed. The callback may keep the original zero-argument form or declare ONE `env` parameter whose `signal` is the instance-lifetime teardown signal: it is aborted at the start of teardown, before this and every other disposal callback runs, so `env.signal.aborted` is `true` inside the callback.
packages/element/src/internal/core/compile-lifecycle.ts:80处理当前生成元素在连接、接管服务端标记、更新或处理 DOM 事件时抛出的同步错误。
(callback: (env: { readonly host: HTMLElement; readonly signal: AbortSignal; readonly states: CustomStateSet; readonly error: unknown; }) => void): void英文源码说明
Compiler-recognized error intrinsic (`16b-EB`): the author-facing error boundary of ONE generated element. The callback runs when a value escapes from the element's own work — the connect/claim pass (mount, claim, setup and the `onConnect` replay) and an UPDATE-phase write (a tracked slot refresh or a DOM event handler dispatched inside the compiled body). Erased by the compiler; calling it at runtime fails closed. `env.host` is the generated element the failing work belongs to (the nearest ancestor generated element for a depth-1 retained hostless child), `env.signal` is the per-connection `LifetimeScope` signal for a connect-phase failure and the instance-lifetime teardown signal otherwise, `env.states` is the element's `CustomStateSet`, and `env.error` is the thrown value EXACTLY as it was thrown (never wrapped or replaced). The callback may keep the zero-argument form. A catching handler changes only whether the error escapes: a connect-phase failure still leaves the element in its defined post-failure state (no projection, no listeners, a later reconnect retries from scratch), and an update-phase failure leaves the previously written DOM in place with the subscription still live for the next write. A handler that itself throws REPLACES the original error — that new throw is what surfaces. With no registered handler the pre-existing rethrow/rollback behaviour is unchanged. The callback is CLIENT-owned: it is erased into the compiled module and never runs during `__ssr` (a server render has no element, no connection scope and no handler registry; a producer throw fails the render, exactly as before).
packages/element/src/internal/core/compile-lifecycle.ts:144元素的已声明属性写入新值后运行回调,包括 attribute 和 property 写入。
(callback: (event: { readonly host: HTMLElement; readonly signal: AbortSignal; readonly states: CustomStateSet; readonly name: string; readonly value: unknown; }) => void): void英文源码说明
Compiler-recognized change intrinsic: runs the callback after a DECLARED property of this generated element commits a new value, for an attribute write and for a property write, and never at setup. Erased by the compiler — the callback is registered on the element-lifetime instance owner through the compiler-private host record; calling it at runtime fails closed. `event.host` is the generated element (the nearest ancestor generated element for a depth-1 retained hostless child), `event.signal` is the instance-lifetime teardown signal, and `event.name`/`event.value` are the changed row and its committed value. The callback may keep the zero-argument form.
packages/element/src/internal/core/compile-lifecycle.ts:103自定义元素声明中记录的一个 attribute。
OpenElementAttribute英文源码说明
One documented attribute of a custom element declaration.
packages/protocol/src/manifest.ts:15自定义元素声明中记录的一个 CSS part。
OpenElementCssPart英文源码说明
One documented CSS part of a custom element declaration.
packages/protocol/src/manifest.ts:38包清单中的自定义元素声明,包括标签名、成员和交付信息。
OpenElementDeclaration英文源码说明
One custom element declaration in a package manifest: tag, members and delivery metadata.
packages/protocol/src/manifest.ts:116框架错误,提供稳定错误码、严重程度、发生阶段和可恢复性。
class OpenElementError extends Error英文源码说明
Framework error carrying a stable code, severity, phase and recoverability contract.
packages/protocol/src/errors.ts:100自定义元素声明中记录的一个自定义事件。
OpenElementEvent英文源码说明
One documented custom event of a custom element declaration.
packages/protocol/src/manifest.ts:25包级组件清单,记录其中声明的组件。
OpenElementPackageManifest英文源码说明
Package manifest of component declarations (not a Custom Elements Manifest).
packages/protocol/src/manifest.ts:129应用与构建驱动共享的路由类别。
OpenElementRouteKind英文源码说明
Host-agnostic route and asset contracts shared by app and build drivers.
packages/protocol/src/app-model.ts:2路由树节点,记录匹配路径、路由类型、源码与模块路径、可选的标签和参数,以及子路由。
OpenElementRouteNode英文源码说明
One node of the host-agnostic route tree: the matched URL `path` and route kind, the source and module paths the drivers resolve, the optional registered tag and param names, and the nested `children`.
packages/protocol/src/app-model.ts:9自定义元素声明中记录的一个插槽。
OpenElementSlot英文源码说明
One documented slot of a custom element declaration.
packages/protocol/src/manifest.ts:32RFC 9457 Problem Details 错误响应使用的媒体类型。
"application/problem+json"英文源码说明
Media type of the RFC 9457 action error channel (#863).
packages/protocol/src/data.ts:117表单 action 的协议错误使用的 RFC 9457 文档,按 application/problem+json 返回。detail 提供具体错误说明。
ProblemDetails英文源码说明
RFC 9457 Problem Details document (#863): the action error channel answers `application/problem+json` instead of the bespoke `{ type: 'error', error: { message } }` JSON, so HTTP tooling recognizes failures natively. With `type: 'about:blank'`, `title` is the HTTP reason phrase and `detail` carries the specific explanation. The wire shape is alpha-unfrozen; the 1.0 acceptance freezes it in this problem+json form.
packages/protocol/src/data.ts:105提供普通的协议上下文值。用于提供值的 Signal 仍由 openElement 内部持有。
<T>(host: HTMLElement, context: Context<T>, value: T): Unsubscribe英文源码说明
Provide a plain protocol value; the provider Signal remains OE-private. The returned handle owns exactly one provider record. A repeated call for the same host and {@linkcode Context.key} disposes the previous record (its request listener and mapping) before publishing the replacement, so repeated provides and reconnect cycles never accumulate listeners; the replaced handle becomes a no-op. Releasing removes only the current record and is idempotent.
packages/element/src/internal/core/signal-context.ts:131computed 等派生值使用的只读信号接口。
ReadonlySignal<T>英文源码说明
Read-only signal protocol used by computed values.
packages/protocol/src/signal.ts:26为组件内的一个原生 DOM 节点创建可复用句柄。通过 JSX 的 ref 属性设置,current 随节点连接和断开更新。
<T extends globalThis.Element = Element>(callback?: (element: T | null) => void | (() => void)): { (element: globalThis.Element | null): void; readonly current: T | null; }英文源码说明
Compiler-recognized node-handle factory (`16b-REF`): declares a REF HANDLE for one intrinsic DOM node of this component. The returned value is handed to that node's existing JSX `ref` attribute: ```tsx const field = ref<HTMLInputElement>((element) => { element?.focus(); return () => {/* detach cleanup *\/}; }); // … return <input ref={field} />; ``` The handle is the same object for the whole element lifetime: the compiler erases this call into the retained instance factory, so a reconnect, a claim of server DOM and an update all observe one handle rather than a per-pass copy. It is a REF CHANNEL VALUE, not a reactive source: `current` is written when the node attaches, cleared when it detaches, and it notifies nothing — a tracked slot reading `current` would be a one-shot value, which is why the compiler admits a handle ONLY in a `ref` attribute expression. The optional callback is the attach/detach notification the existing `ref` channel already defines: called with the element on attach, and with `null` on detach AFTER the cleanup it returned has run. Because the handle rides the same `ref` channel, the cleanup ordering, the once-per-detach rule and the scope ownership are the existing ones — this intrinsic adds no second attachment mechanism. Erased by the compiler; calling it at runtime fails closed.
packages/element/src/internal/core/compile-lifecycle.ts:187释放某次带宿主的 consumeContext 创建的提供者订阅。
(signalValue: SignalLike<unknown>): void英文源码说明
Release the provider bridge created by one hosted {@linkcode consumeContext} call. The bridge is deregistered only AFTER its cleanup returns: a throwing unsubscribe must not leave the signal in a state where the bridge is gone from the bookkeeping but still attached to the provider (unretryable). If cleanup throws, the entry stays registered and the error propagates verbatim, so the caller can retry the release — for example from a `disconnectedCallback` that runs again — once the provider's unsubscribe succeeds. A second call after a successful release is a no-op, and a signal without a bridge (including a signal created without a `host`) is always a no-op.
packages/element/src/internal/core/signal-context.ts:208可恢复的渲染错误,携带出错组件的文件路径与标签名。
class RenderError extends OpenElementError英文源码说明
Recoverable render-phase error carrying the failing component path and tag.
packages/element/src/internal/core/errors.ts:95在服务端渲染一个已编译的元素,直接返回序列化后的声明式 Shadow DOM HTML。
(input: string | CustomElementConstructor, options?: RenderToStringOptions): string英文源码说明
Server-render one compiled element through canonical Element composition: returns the serialized DSD `html` string directly.
packages/element/src/public-runtime.ts:945一次 renderToString 调用的选项,包括组件类、属性值、诊断上下文、可渲染的嵌套标签和插槽内容。
RenderToStringOptions英文源码说明
Options for one `renderToString()` call: the compiled component class to serialize, the values projected onto its compiled properties, optional route/source diagnostics metadata, the nested compiled tags the build admitted, and trusted parent-owned light children keyed by slot name.
packages/element/src/public-runtime.ts:170将框架错误交给遥测钩子,无钩子时写入 console.error。
(error: OpenElementError): void英文源码说明
Report an {@linkcode OpenElementError} to the telemetry hook, or console.error when none is installed.
packages/element/src/internal/core/errors.ts:139扫描后入选的路由,记录 URL 路径、源文件、类型、生成入口使用的变量名和可选注册标签。
RouteEntry英文源码说明
One route admitted by the scanner: URL `path`, source `filePath`, the route `type`, the generated variable name (`varName`) the entry binds it to, and the optional registration tag. {@link RouteEntry.definePage} and {@link RouteEntry.hasEnhancedForms} carry the two source-derived admission facts the generated entries branch on.
packages/protocol/src/framework.ts:113请求时渲染和静态站点生成共用的服务端路由上下文。
ServerRouteContext<Env, Platform, Route>英文源码说明
Canonical request-time/SSG server route context.
packages/protocol/src/data.ts:25动态路由 loader 接收的服务端上下文,包括标准请求、路由参数、宿主环境和平台对象。
ServerRouteMetadata英文源码说明
Context passed to a request-time ('dynamic') route loader. This is the server contract: the loader runs on the server with the Web-standard request, matched route params, the host environment and the platform object, and signals validation failure via fail()/redirect().
packages/protocol/src/data.ts:19安装或替换整个进程使用的错误遥测钩子。
(hook: ErrorTelemetryHook): void英文源码说明
Install the process-wide error telemetry hook (replaceable for tests, HMR, multi-app pages).
packages/element/src/internal/core/errors.ts:127创建可读写的响应式状态。
<T>(initialValue: T): WritableSignal<T>英文源码说明
Create a writable signal through the selected signal engine.
packages/element/src/internal/signal/framework.ts:19接受可写信号或只读信号的 API 所用类型。
Signal<T>英文源码说明
Alias for APIs that accept either writable or read-only signals.
packages/protocol/src/signal.ts:31路由扫描器按文件名识别的特殊类型,包括 renderer 和 middleware。
SpecialFileType英文源码说明
Special file kinds the route scanner recognizes by filename: `renderer` and `middleware`.
packages/protocol/src/framework.ts:79构建对自定义元素的 SSR 判定,记录模块路径、发现来源、渲染方式及原因。
SsrAdmissionDecision英文源码说明
The build's admission verdict for one discovered tag: where the declaration lives (`modulePath`), how it was discovered (`source`), which render path it is admitted to, and the reason recorded for the manifest.
packages/protocol/src/render.ts:37浏览器拒绝装入所属 Part 范围的流式片段所禁用的标签。
readonly ["script", "style", "template", "iframe", "object", "embed", "base", "meta", "link"]英文源码说明
Tags a deferred frame cannot safely install into an owned Part range: the browser installer rejects any frame whose markup carries one of these.
packages/protocol/src/stream-frame-policy.ts:26流式片段的 URL 属性不可使用的协议。
RegExp英文源码说明
Schemes that make a URL attribute unsafe in a streamed frame.
packages/protocol/src/stream-frame-policy.ts:60流式片段中需要检查 URL 协议的属性名。
readonly ["href", "src", "action", "formaction", "xlink:href"]英文源码说明
URL-carrying attributes the frame check screens for script-bearing scheme obfuscation; only these attribute names are value-screened.
packages/protocol/src/stream-frame-policy.ts:42检查 URL 协议前,会移除码点低于或等于此值的控制字符。
32英文源码说明
Control characters at or below this code point are stripped before the URL-scheme test, so tab/newline/control obfuscation cannot smuggle a scheme past admission.
packages/protocol/src/stream-frame-policy.ts:55一个流式路由允许在清单中声明的延迟字段数上限。
32英文源码说明
Deferred fields (declared streamed properties) one stream route's manifest may carry. The build scan, the server executor, and the browser seed contract enforce the same bound.
packages/protocol/src/policy.ts:24一个流式路由清单可以引用的 Part 和 Block 所有者数量上限。
64英文源码说明
Part/Block owners one stream route's manifest may address in total across all deferred fields.
packages/protocol/src/policy.ts:30流式载荷的最大序列化长度,以 UTF-16 码元计。
number英文源码说明
Serialized stream payload bound, as a string length in UTF-16 code units: one seed attribute or one deferred frame's markup may not exceed it. The server checks the JSON text and the rendered range before emitting; the browser checks the attribute before parsing.
packages/protocol/src/policy.ts:45流式 hydration 初始数据可携带的带类型属性数量上限。
64英文源码说明
Typed properties one streamed seed may carry: the browser seed contract rejects the WHOLE seed above this count, so an oversized component would silently fail to hydrate instead of failing loud at the server.
packages/protocol/src/policy.ts:37流式响应等待延迟字段完成的时间上限(毫秒)。
30000英文源码说明
Deferred-field resolution budget (milliseconds) for one streamed response: fields still pending when it expires are failed in place and the stream ends with the shell and whatever resolved.
packages/protocol/src/policy.ts:64可跨执行环境使用的样式表构造器,按环境选择原生 CSSStyleSheet 或兼容实现。
new () => StyleSheetLike英文源码说明
Cross-realm StyleSheet constructor: the native CSSStyleSheet or the internal shim.
packages/element/src/internal/core/style-sheet.ts:110原生样式表与兼容实现共用的最小接口,包括 replaceSync 和 cssRules。
StyleSheetLike英文源码说明
Minimal stylesheet contract (replaceSync + cssRules) satisfied by native and shim sheets.
packages/protocol/src/style-sheet.ts:14将 HTML 字符串标记为可信,以便显式传给 innerHTML。序列化时不会保留可信标记。
(html: string): TrustedHtml英文源码说明
Mark an HTML string as trusted for explicit `innerHTML` sinks (the trust does not serialize).
packages/element/src/internal/core/security.ts:88标识应用已明确审查并信任的 HTML。
TrustedHtml英文源码说明
Opaque capability marking HTML the application has explicitly vetted as trusted.
packages/element/src/internal/core/security.ts:83判断 Part Program 中的静态属性是否会使流式片段无法通过安装校验。
(name: string, value: string): boolean英文源码说明
Whether a static attribute (name/value as authored into the Part Program) makes a streamed frame unsafely installable: event-handler, seed-spoofing, and srcdoc names fail outright, and URL-carrying names fail when the entity-decoded, control-stripped value carries a script scheme.
packages/protocol/src/stream-frame-policy.ts:113订阅最近提供者的上下文,返回由实例持有的信号。没有提供者时读到令牌的默认值。
<T>(context: { readonly key: symbol; readonly defaultValue: T; }): { readonly value: T; subscribe(fn: (value: T) => void): () => void; }英文源码说明
Compiler-recognized CONSUMER intrinsic (`16b-CTX`): declares a tracked consumer of `context` for this component and returns the signal its value lives in. ```tsx const theme = useContext(ThemeContext); return <p>{theme.value}</p>; // a tracked slot: refreshes on provider change ``` The returned signal is ONE persistent consumer-local signal: the compiler erases this call into the component's retained setup record, so a reconnect re-reads the nearest provider into the SAME object and a tracked slot keeps exactly one subscription target for the whole element lifetime. Lookup follows the nearest owning component, so an inner provider shadows an outer one and a component with no ancestor provider reads the context's declared default. Reading `.value` in a tracked slot is the supported use — this is the lane's reactive channel, unlike `ref`'s `current`. Reading it inside a handler also works (the signal is live), but only tracked slots refresh. Erased by the compiler; calling it at runtime fails closed.
packages/element/src/internal/core/compile-lifecycle.ts:285获取当前组件所在的自定义元素。用于在组件中访问宿主节点。
(): HTMLElement英文源码说明
Compiler-recognized HOST-ACCESS intrinsic (`16b-REF`, `useHost`). ```tsx const host = useHost(); // … host is this instance's owning element (the custom element). ``` It exposes the SAME fact the lifecycle/change/error callbacks already receive as `env.host` — the owning generated element for a root, the nearest enclosing generated element host for a depth-1 retained hostless child — through the expression position instead of a callback parameter. There is therefore no new runtime channel and no second host lookup: the compiler erases the call into a read of the host-element field the retained setup factory already receives. The read is NOT reactive: the element identity never changes for an instance, so a derived node capturing it can never go stale. That is also why it carries no lifecycle ownership — it allocates nothing and needs no cleanup. Erased by the compiler; calling it at runtime fails closed.
packages/element/src/internal/core/compile-lifecycle.ts:218为渲染后的 HTML 补上文档类型、head 和 body,支持 CSP nonce 与开发脚本。
(html: string, options?: DocumentWrapOptions): string英文源码说明
Wrap rendered HTML in a full HTML document. Adds DOCTYPE, head (title, meta, preload), and body. Supports CSP nonce and dev scripts (e.g. Vite client, route module registration).
packages/element/src/internal/core/html-escape.ts:199选择表单 action 的响应通道。true 返回序列化结果,enhance 返回与无脚本提交相同的 HTML。
"x-openelement-action"英文源码说明
Request header selecting the action response channel: `true` marks a programmatic caller and selects the serialized ActionResult union; `enhance` marks the built-in morph enhancement and selects the same full-HTML responses the no-JS path receives.
packages/protocol/src/data.ts:125检查名称是否符合自定义元素的标签名规则。
(tagName: string): void英文源码说明
Assert that a tag name is a valid custom element name.
packages/element/src/internal/core/tag-utils.ts:50从不可信属性复制数据时必须排除的对象原型键。
ReadonlySet<string>英文源码说明
Object prototype keys that must never be injected from untrusted props.
packages/element/src/internal/core/security.ts:25openElement 错误消息使用的前缀。
"[openElement]"英文源码说明
Error message prefix for all openElement errors.
packages/protocol/src/errors.ts:50运行时支持的 hydration 策略列表,以及 HydrationStrategy 联合类型的来源。
readonly ["load", "idle", "visible", "only", "none"]英文源码说明
Runtime list of supported hydration strategies; the single source of truth for the `HydrationStrategy` union. Consumed by island/registry validation and re-exported from the element root for app and build adapters.
packages/protocol/src/framework.ts:28控制交互岛何时启用,也可跳过浏览器 hydration。
"load" | "idle" | "visible" | "only" | "none"英文源码说明
Island hydration trigger: 'load' | 'idle' | 'visible' | 'only'.
packages/protocol/src/framework.ts:30将调用方提供的属性写入目标对象,跳过受保护的键,并容忍只读属性。
(target: Record<string, unknown>, props: Record<string, unknown>, tagName: string, log?: { warn(message: string): void; debug(message: string): void; }): void英文源码说明
Safely assign caller-supplied props onto a target object, skipping keys that could enable prototype pollution and tolerating read-only properties. The canonical guarded assigner for the canonical dangerous-key rule (#903, #1214): the
packages/element/src/internal/core/security.ts:131判断属性键是否为框架在写入属性时必须拒绝的对象原型键。
(key: string): boolean英文源码说明
Shared dangerous-key predicate (#903, #1214). Prototype-internal keys must never be injected from untrusted props on ANY path: host prop collection (collectPublicProps / normalizePublicProps in props-utils.ts), guarded assignment (injectPropsSafe below — the SPA bootstrap page-projection write boundary in
packages/element/src/internal/core/security.ts:53服务端渲染检查属性名时调用的公共校验入口,规则和协议层一致。
(name: string): boolean英文源码说明
Shared safe-attribute-name predicate (#1033): the SSR face of the one canonical predicate in `../protocol/forbidden-sinks.ts`. A name must be valid HTML attribute-name grammar (blocks quote/space injection, #602), must not be an event handler (`on*`, case-insensitive), and must not be a forbidden sink (`innerhtml`/`srcdoc`). The compiler, protocol validator, and server serializer enforce the same predicate with their own failure strategies; every path delegates to the single implementation, so the boundary cannot diverge.
packages/element/src/internal/core/security.ts:67判断字符串是否符合 HTML 自定义元素的标签名规则。
(tagName: string): boolean英文源码说明
Check if a tag name is a valid custom element name per HTML spec.
packages/element/src/internal/core/tag-utils.ts:38生成的服务端入口对 POST action 请求体施加的字节上限。需要上传更大文件时,可使用配置了明确上限的 API 路由。
number英文源码说明
Request-body bound (bytes) the generated entry applies to action POST routes; larger uploads belong on API routes with explicit limits.
packages/protocol/src/policy.ts:57框架错误,提供稳定错误码、严重程度、发生阶段和可恢复性。
class OpenElementError extends Error英文源码说明
Framework error carrying a stable code, severity, phase and recoverability contract.
packages/protocol/src/errors.ts:100RFC 9457 Problem Details 错误响应使用的媒体类型。
"application/problem+json"英文源码说明
Media type of the RFC 9457 action error channel (#863).
packages/protocol/src/data.ts:117浏览器拒绝装入所属 Part 范围的流式片段所禁用的标签。
readonly ["script", "style", "template", "iframe", "object", "embed", "base", "meta", "link"]英文源码说明
Tags a deferred frame cannot safely install into an owned Part range: the browser installer rejects any frame whose markup carries one of these.
packages/protocol/src/stream-frame-policy.ts:26流式片段的 URL 属性不可使用的协议。
RegExp英文源码说明
Schemes that make a URL attribute unsafe in a streamed frame.
packages/protocol/src/stream-frame-policy.ts:60流式片段中需要检查 URL 协议的属性名。
readonly ["href", "src", "action", "formaction", "xlink:href"]英文源码说明
URL-carrying attributes the frame check screens for script-bearing scheme obfuscation; only these attribute names are value-screened.
packages/protocol/src/stream-frame-policy.ts:42检查 URL 协议前,会移除码点低于或等于此值的控制字符。
32英文源码说明
Control characters at or below this code point are stripped before the URL-scheme test, so tab/newline/control obfuscation cannot smuggle a scheme past admission.
packages/protocol/src/stream-frame-policy.ts:55一个流式路由允许在清单中声明的延迟字段数上限。
32英文源码说明
Deferred fields (declared streamed properties) one stream route's manifest may carry. The build scan, the server executor, and the browser seed contract enforce the same bound.
packages/protocol/src/policy.ts:24一个流式路由清单可以引用的 Part 和 Block 所有者数量上限。
64英文源码说明
Part/Block owners one stream route's manifest may address in total across all deferred fields.
packages/protocol/src/policy.ts:30流式载荷的最大序列化长度,以 UTF-16 码元计。
number英文源码说明
Serialized stream payload bound, as a string length in UTF-16 code units: one seed attribute or one deferred frame's markup may not exceed it. The server checks the JSON text and the rendered range before emitting; the browser checks the attribute before parsing.
packages/protocol/src/policy.ts:45流式 hydration 初始数据可携带的带类型属性数量上限。
64英文源码说明
Typed properties one streamed seed may carry: the browser seed contract rejects the WHOLE seed above this count, so an oversized component would silently fail to hydrate instead of failing loud at the server.
packages/protocol/src/policy.ts:37流式响应等待延迟字段完成的时间上限(毫秒)。
30000英文源码说明
Deferred-field resolution budget (milliseconds) for one streamed response: fields still pending when it expires are failed in place and the stream ends with the shell and whatever resolved.
packages/protocol/src/policy.ts:64为当前服务端进程设置已生成的样式表 URL。
(urls: readonly string[] | null | undefined, islandEntries?: ReadonlyArray<readonly [string, readonly string[] | null]> | null): void英文源码说明
Set the emitted stylesheet URLs for this server process. Called by the router's generated SSR/SSG entry (build time and request-time startup) with the base-joined asset addresses Phase 2 emitted. The optional `islandEntries` half carries the per-tag URLs of generated SHADOW hosts (M09-2e / #1803) through the SAME channel: one setter, one entry import, no second public seam. A `null` URL list is the explicit "declared but carrier unavailable" state the nested renderer fails closed on.
packages/element/src/internal/compiled/server/style-links.ts:34处理页面路由的表单提交。
Action<T, Env, Platform, Route>英文源码说明
Route action: handles form submissions for a page route.
packages/protocol/src/data.ts:64选择表单 action 的响应通道。true 返回序列化结果,enhance 返回与无脚本提交相同的 HTML。
"x-openelement-action"英文源码说明
Request header selecting the action response channel: `true` marks a programmatic caller and selects the serialized ActionResult union; `enhance` marks the built-in morph enhancement and selects the same full-HTML responses the no-JS path receives.
packages/protocol/src/data.ts:125传给路由 action 的上下文,包含 loader 上下文。
ActionContext<Env, Platform, Route>英文源码说明
Context passed to a route action function (extends loader context).
packages/protocol/src/data.ts:47脚本提交表单时返回的联合类型。校验失败返回 failure,成功提交返回 redirect;协议错误使用 ProblemDetails。
ActionResult<Failure>英文源码说明
Wire shape returned to the JavaScript form-enhancement path. The no-JS path never sees this: it gets the equivalent semantics as plain HTTP (303 on success, 422 with the re-rendered form on validation failure, redirect/error as status codes). Success carries no data envelope. The application-loop contract makes a successful non-GET action answer 303 (PRG) — the framework never answers 200 with a rendered page, or with a success document, for a successful mutation — so the fetch channel answers `{ type: 'redirect' }` naming the PRG target and the authored return value is discarded by design. Success data travels the PRG target instead (query state the loader re-runs with, which the props projector then maps; see the router guide's "Form actions" section). The union previously declared a `{ type: 'success' }` member that no code path ever emitted — removed so the type matches the wire. Error outcomes (CSRF 403, unknown action 404, unparseable body 400, unexpected 500) are NOT part of this union: since #863 they answer RFC 9457 Problem Details with the PROBLEM_JSON_MEDIA_TYPE content type — see ProblemDetails.
packages/protocol/src/data.ts:92检查名称是否符合自定义元素的标签名规则。
(tagName: string): void英文源码说明
Assert that a tag name is a valid custom element name.
packages/element/src/internal/core/tag-utils.ts:50收集宿主对象上所有公开的自有属性。
(host: object): Record<string, unknown>英文源码说明
Collect all public (non-internal) own properties from a host object. Keys starting with `__openElement` are framework-internal and excluded. Uses Reflect.get for safe access (respects getters); a getter that throws is skipped with a warning so one bad prop cannot take the tree down.
packages/element/src/internal/core/props-utils.ts:41兼容性扫描为每个标签记录分级、原因、来源和对应的 SSR、DSD 与 hydration 判定依据。
CompatibilityClassification英文源码说明
The per-tag verdict the compatibility scanner records: the tier a discovered tag was classified as, the human-readable `reason`, where the tag was found (`source`), and the SSR/DSD/hydration facts the verdict was derived from.
packages/protocol/src/framework.ts:347标签的构建兼容级别,区分服务端渲染、仅浏览器渲染、实验支持和拒绝构建。
CompatibilityTier英文源码说明
How far a discovered tag may participate in the build: 'ssr-capable' renders and hydrates, 'client-only' ships to the browser without server output, 'experimental-dom' is admitted with a downgraded guarantee, and 'rejected' fails the build.
packages/protocol/src/framework.ts:340组件的交付层级,区分静态 DSD、带交互岛的 DSD、仅客户端交互岛和 Light DOM。
ComponentLayer英文源码说明
The delivery layer a component belongs to: fully static DSD markup ('dsd-static'), DSD markup with a client island ('dsd-interactive'), a client-only island with no SSR output ('pure-island'), or a light-DOM element ('light-dom'). Recorded per component in the build manifest and consumed by the hydration scheduler.
packages/protocol/src/framework.ts:23根据依赖计算一个只读响应式值。
<T>(fn: () => T): ReadonlySignal<T>英文源码说明
Create a derived read-only signal recomputed from its dependencies.
packages/element/src/internal/signal/framework.ts:23将上下文投影为消费端的响应式值。传入宿主时,消费端负责通过 releaseConsumedContext 释放订阅。
<T>(context: Context<T>, host?: HTMLElement): WritableSignal<T>英文源码说明
Consumer-local reactive projection of a protocol context value. When a `host` is given, the returned signal is bridged to the nearest provider through one Community Context Protocol subscription. That bridge is owned by the CALLER: a long-lived consumer must release it when it tears down (typically `disconnectedCallback`) with {@linkcode releaseConsumedContext}, exactly once. Releasing detaches the provider bridge, so the provider no longer retains or updates the local signal; the local signal itself stays usable with its last value. A call after a successful release is a no-op, and a signal created without a `host` has no bridge to release.
packages/element/src/internal/core/signal-context.ts:183上下文令牌,包含协议使用的键和默认值。
Context<T>英文源码说明
A typed context token: protocol identity (`key`) plus its default value.
packages/element/src/internal/core/signal-context.ts:13创建供提供方与消费方共享的带类型上下文令牌。
<T>(key: symbol, defaultValue: T): Context<T>英文源码说明
Create a typed context token shared between provider and consumer elements.
packages/element/src/internal/core/signal-context.ts:58为一次服务端渲染创建文档级样式表收集器。
(): DocumentStyleResources英文源码说明
Create the per-render document stylesheet collection.
packages/element/src/internal/core/html-escape.ts:133创建在每条消息前加上标签的日志记录器。
(tag: string): Logger英文源码说明
Create a {@link Logger} that prefixes every message with `[tag]`.
packages/element/src/internal/core/logger.ts:18从不可信属性复制数据时必须排除的对象原型键。
ReadonlySet<string>英文源码说明
Object prototype keys that must never be injected from untrusted props.
packages/element/src/internal/core/security.ts:25在指定根节点及其嵌套 Shadow Root 中查找匹配 ID 的元素,返回首个匹配项。
(id: string, root?: Document | ShadowRoot): HTMLElement | null英文源码说明
Resolve `id` (a `#hash` or bare id) against `root` and, when the id is not in that root's own tree, recurse into every nested shadow root. Returns the first match or `null`; a malformed percent-encoded id is not an error.
packages/element/src/internal/core/deep-fragment.ts:20使用相同的文档序列化规则生成流式响应的首尾片段,保留正文容器供流写入。
(options?: DocumentWrapOptions): { prefix: string; suffix: string; }英文源码说明
The same document serialization boundary, with only body wrappers left open.
packages/element/src/internal/core/html-escape.ts:205记录一次服务端渲染所发现的文档级样式表,供组件序列化与文档 head 共用。
DocumentStyleResources英文源码说明
The document-level stylesheet resources ONE server render discovered (alpha15 S lane, S-C1.2). A light-root component's DOM lives in the document, so its sheet cannot ride the component's own subtree the way a shadow template's link does: the document owns it. This object is the one carrier between the two halves of that render — the compiled serializer, which discovers a component's external sheets while serializing the component, and the document serializer, which writes the head. It is created per render and never shared, so one page's stylesheets can never reach another page's head.
packages/element/src/internal/core/html-escape.ts:125运行副作用,并在使用的信号发生变化时重新执行和订阅。
(fn: () => void | Unsubscribe): Unsubscribe英文源码说明
Run a side effect that re-subscribes whenever its signal dependencies change.
packages/element/src/internal/signal/framework.ts:27在元素升级前捕获发往待启用交互岛的用户操作,接管 DOM 成功后重放。
(root?: EventTarget, pendingTags?: readonly string[]): void英文源码说明
Install the bounded pre-upgrade interaction capture on an owning root (default: the document). Generated client entries call this with their declared island tags before any compiled element upgrades; after a successful claim the element replays the captured events whose targets live inside its root (compiled claim capture/replay, internal/compiled/runtime.ts). Idempotent per root (repeat calls merge tags, never reinstall listeners) and a no-op where no DOM exists (SSR). Invariant: the capture itself — one fixed listener set per owning root, installed once per page — is page-lifetime by design and is NOT the leak. The M1 leak was retained event-target records; each element releases exactly its own records at its activation decision (success or failure), while records owned by still-pending elements survive for their delayed/lazy upgrade (#1170). Boundedness: the facade capture passes the declared-island filter, so only interactions under a still-pending DECLARED island tag enter the queue — ordinary events and undeclared third-party custom elements are skipped (nested pending declared islands still capture through their own unsettled host). With no tags declared the legacy dash heuristic applies. The shared queue carries a hard capacity cap (fail closed), detached records are swept when a claim root adopts its share (and under queue pressure), and each activation decision deterministically empties that root's own bucket, so post-hydration traffic and removals never grow retention.
packages/element/src/internal/compiled/runtime/pre-upgrade-events.ts:662openElement 错误消息使用的前缀。
"[openElement]"英文源码说明
Error message prefix for all openElement errors.
packages/protocol/src/errors.ts:50接收所有通过错误遥测渠道上报的 OpenElementError。
ErrorTelemetryHook英文源码说明
Callback receiving every reported {@linkcode OpenElementError} for telemetry.
packages/protocol/src/errors.ts:132对 HTML 属性值进行转义。
(value: string): string英文源码说明
Escape an HTML attribute value. Delegates to `escapeHtml` so both share the single `ESCAPE_MAP` and the same single-pass replacement (consolidated in #633). Empty-value conventions remain intentionally distinct by design: - `escapeHtml` returns '' for non-string input. - `escapeAttrValue` (below) coerces via `String()` and is the boundary meant for unknown/variable attribute values.
packages/element/src/internal/core/html-escape.ts:55对文本中的五个 HTML 特殊字符进行转义。
(str: string): string英文源码说明
Escape the five HTML-significant characters in text content.
packages/element/src/internal/core/html-escape.ts:39将未知类型的异常值格式化为可读的字符串。
(e: unknown): string英文源码说明
Format an unknown thrown value as a human-readable string.
packages/element/src/internal/core/errors.ts:52FrameworkOptions英文源码说明
The adapter-facing framework options: where routes and islands live, the default layout and named-layout declarations, the document `<html>`/head injection channels, and the request-time middleware switches. Every field is optional; the adapter applies its documented default. This is the type an application config file's default export is checked against, so the rendered option table and the actual config surface cannot drift.
packages/protocol/src/framework.ts:180运行时支持的 hydration 策略列表,以及 HydrationStrategy 联合类型的来源。
readonly ["load", "idle", "visible", "only", "none"]英文源码说明
Runtime list of supported hydration strategies; the single source of truth for the `HydrationStrategy` union. Consumed by island/registry validation and re-exported from the element root for app and build adapters.
packages/protocol/src/framework.ts:28控制交互岛何时启用,也可跳过浏览器 hydration。
"load" | "idle" | "visible" | "only" | "none"英文源码说明
Island hydration trigger: 'load' | 'idle' | 'visible' | 'only'.
packages/protocol/src/framework.ts:30环境缺少 requestIdleCallback 和 requestAnimationFrame 时,空闲 hydration 的备用延时(毫秒)。
50英文源码说明
Idle-hydration scheduling fallback (milliseconds) when neither `requestIdleCallback` nor `requestAnimationFrame` is available.
packages/protocol/src/policy.ts:70将调用方提供的属性写入目标对象,跳过受保护的键,并容忍只读属性。
(target: Record<string, unknown>, props: Record<string, unknown>, tagName: string, log?: { warn(message: string): void; debug(message: string): void; }): void英文源码说明
Safely assign caller-supplied props onto a target object, skipping keys that could enable prototype pollution and tolerating read-only properties. The canonical guarded assigner for the canonical dangerous-key rule (#903, #1214): the
packages/element/src/internal/core/security.ts:131判断属性键是否为框架在写入属性时必须拒绝的对象原型键。
(key: string): boolean英文源码说明
Shared dangerous-key predicate (#903, #1214). Prototype-internal keys must never be injected from untrusted props on ANY path: host prop collection (collectPublicProps / normalizePublicProps in props-utils.ts), guarded assignment (injectPropsSafe below — the SPA bootstrap page-projection write boundary in
packages/element/src/internal/core/security.ts:53交互岛的交付选项,包括 hydration 策略和是否参与 SSR 或 DSD。
IslandOptions英文源码说明
Per-island delivery options (hydration strategy, SSR/DSD participation).
packages/protocol/src/island.ts:8服务端渲染检查属性名时调用的公共校验入口,规则和协议层一致。
(name: string): boolean英文源码说明
Shared safe-attribute-name predicate (#1033): the SSR face of the one canonical predicate in `../protocol/forbidden-sinks.ts`. A name must be valid HTML attribute-name grammar (blocks quote/space injection, #602), must not be an event handler (`on*`, case-insensitive), and must not be a forbidden sink (`innerhtml`/`srcdoc`). The compiler, protocol validator, and server serializer enforce the same predicate with their own failure strategies; every path delegates to the single implementation, so the boundary cannot diverge.
packages/element/src/internal/core/security.ts:67判断字符串是否符合 HTML 自定义元素的标签名规则。
(tagName: string): boolean英文源码说明
Check if a tag name is a valid custom element name per HTML spec.
packages/element/src/internal/core/tag-utils.ts:38为路由选择内置布局、指定自定义布局及其模块和属性,或关闭布局。
LayoutConfig英文源码说明
Layout declaration: `false` disables the layout entirely, `'default'` uses the built-in layout, and the object form names a tag with the module path that defines it (`import`, resolved like a {@link FrameworkOptions.middleware.use } entry) plus the compiled layout properties the router injects per route.
packages/protocol/src/framework.ts:96为页面路由获取数据的 loader。
Loader<T, Env, Platform, Route>英文源码说明
Route loader: fetches data for a page route.
packages/protocol/src/data.ts:56传给动态路由 loader 的请求上下文。
LoaderContext<Env, Platform, Route>英文源码说明
Context passed to a request-time ('dynamic') route loader.
packages/protocol/src/data.ts:40随语言解析的路径契约。
LocalePath英文源码说明
Locale-aware resolved path contract.
packages/protocol/src/framework.ts:82带标签的控制台日志接口。
Logger英文源码说明
logger.ts - Tagged console logger. Lightweight scoped logger. Returns plain functions so it is tree-shakable and has zero class overhead.
packages/element/src/internal/core/logger.ts:10生成的服务端入口对 POST action 请求体施加的字节上限。需要上传更大文件时,可使用配置了明确上限的 API 路由。
number英文源码说明
Request-body bound (bytes) the generated entry applies to action POST routes; larger uploads belong on API routes with explicit limits.
packages/protocol/src/policy.ts:57renderToString 允许展开的嵌套元素层数,避免循环组合导致无穷递归。
8英文源码说明
Nested element expansion depth bound for `renderToString`: cyclic component composition fails closed instead of recursing without end.
packages/protocol/src/policy.ts:51基于标准 Request 和 Response 的洋葱式中间件。可直接返回响应,也可在 next() 返回后处理响应。
Middleware英文源码说明
Fetch middleware contract (#858): WinterCG shape, dialect-free — no Hono/h3 context object. Composed at the handler boundary in onion order (`use[0]` is outermost: it sees the request first and the response last), so it runs with identical semantics in the dev server, the `start` CLI, the e2e fixture server, and the Nitro production entry. A middleware may short-circuit by returning a Response without calling `next()`, or post-process the Response that `next()` returns. Module contract: a Middleware is the DEFAULT EXPORT of a module referenced from `middleware.use` by path (e.g. './app/middleware/auth.ts'). The generated server entry imports the module, so the middleware may close over module scope and import local helpers and third-party packages — it is a real module in the server module graph, never serialized source.
packages/protocol/src/framework.ts:169生成的自定义元素每次连接时运行回调,包括重新连接。若回调返回清理函数,元素断开时会调用它。
(callback: (env: { readonly host: HTMLElement; readonly signal: AbortSignal; readonly states: CustomStateSet; }) => void | (() => void)): void英文源码说明
Compiler-recognized connect intrinsic: runs the callback on every connection of the generated element (initial mount and each reconnect) and releases the optional returned cleanup at that disconnection. Erased by the compiler; calling it at runtime fails closed. The callback may keep the original zero-argument form or declare ONE `env` parameter. `env.host` is the generated element the connection belongs to (for a depth-1 retained hostless child: its nearest ancestor generated element), and `env.signal` aborts at the START of that disconnection, before any registered cleanup runs; a reconnect gets a fresh, un-aborted signal. The parameter's type is the author-facing contract only — the compiler erases it and passes the value from the connection scope the callback runs in.
packages/element/src/internal/core/compile-lifecycle.ts:58在生成的元素实例最终销毁时运行一次回调,调用顺序在该连接的清理函数之后。
(callback: (env: { readonly host: HTMLElement; readonly signal: AbortSignal; readonly states: CustomStateSet; }) => void): void英文源码说明
Compiler-recognized dispose intrinsic: runs the callback exactly once when the generated element instance is torn down (explicit `dispose()`), after that connection's connect-cleanups. Erased by the compiler; calling it at runtime fails closed. The callback may keep the original zero-argument form or declare ONE `env` parameter whose `signal` is the instance-lifetime teardown signal: it is aborted at the start of teardown, before this and every other disposal callback runs, so `env.signal.aborted` is `true` inside the callback.
packages/element/src/internal/core/compile-lifecycle.ts:80处理当前生成元素在连接、接管服务端标记、更新或处理 DOM 事件时抛出的同步错误。
(callback: (env: { readonly host: HTMLElement; readonly signal: AbortSignal; readonly states: CustomStateSet; readonly error: unknown; }) => void): void英文源码说明
Compiler-recognized error intrinsic (`16b-EB`): the author-facing error boundary of ONE generated element. The callback runs when a value escapes from the element's own work — the connect/claim pass (mount, claim, setup and the `onConnect` replay) and an UPDATE-phase write (a tracked slot refresh or a DOM event handler dispatched inside the compiled body). Erased by the compiler; calling it at runtime fails closed. `env.host` is the generated element the failing work belongs to (the nearest ancestor generated element for a depth-1 retained hostless child), `env.signal` is the per-connection `LifetimeScope` signal for a connect-phase failure and the instance-lifetime teardown signal otherwise, `env.states` is the element's `CustomStateSet`, and `env.error` is the thrown value EXACTLY as it was thrown (never wrapped or replaced). The callback may keep the zero-argument form. A catching handler changes only whether the error escapes: a connect-phase failure still leaves the element in its defined post-failure state (no projection, no listeners, a later reconnect retries from scratch), and an update-phase failure leaves the previously written DOM in place with the subscription still live for the next write. A handler that itself throws REPLACES the original error — that new throw is what surfaces. With no registered handler the pre-existing rethrow/rollback behaviour is unchanged. The callback is CLIENT-owned: it is erased into the compiled module and never runs during `__ssr` (a server render has no element, no connection scope and no handler registry; a producer throw fails the render, exactly as before).
packages/element/src/internal/core/compile-lifecycle.ts:144元素的已声明属性写入新值后运行回调,包括 attribute 和 property 写入。
(callback: (event: { readonly host: HTMLElement; readonly signal: AbortSignal; readonly states: CustomStateSet; readonly name: string; readonly value: unknown; }) => void): void英文源码说明
Compiler-recognized change intrinsic: runs the callback after a DECLARED property of this generated element commits a new value, for an attribute write and for a property write, and never at setup. Erased by the compiler — the callback is registered on the element-lifetime instance owner through the compiler-private host record; calling it at runtime fails closed. `event.host` is the generated element (the nearest ancestor generated element for a depth-1 retained hostless child), `event.signal` is the instance-lifetime teardown signal, and `event.name`/`event.value` are the changed row and its committed value. The callback may keep the zero-argument form.
packages/element/src/internal/core/compile-lifecycle.ts:103自定义元素声明中记录的一个 attribute。
OpenElementAttribute英文源码说明
One documented attribute of a custom element declaration.
packages/protocol/src/manifest.ts:15自定义元素声明中记录的一个 CSS part。
OpenElementCssPart英文源码说明
One documented CSS part of a custom element declaration.
packages/protocol/src/manifest.ts:38包清单中的自定义元素声明,包括标签名、成员和交付信息。
OpenElementDeclaration英文源码说明
One custom element declaration in a package manifest: tag, members and delivery metadata.
packages/protocol/src/manifest.ts:116框架错误,提供稳定错误码、严重程度、发生阶段和可恢复性。
class OpenElementError extends Error英文源码说明
Framework error carrying a stable code, severity, phase and recoverability contract.
packages/protocol/src/errors.ts:100自定义元素声明中记录的一个自定义事件。
OpenElementEvent英文源码说明
One documented custom event of a custom element declaration.
packages/protocol/src/manifest.ts:25包级组件清单,记录其中声明的组件。
OpenElementPackageManifest英文源码说明
Package manifest of component declarations (not a Custom Elements Manifest).
packages/protocol/src/manifest.ts:129应用与构建驱动共享的路由类别。
OpenElementRouteKind英文源码说明
Host-agnostic route and asset contracts shared by app and build drivers.
packages/protocol/src/app-model.ts:2路由树节点,记录匹配路径、路由类型、源码与模块路径、可选的标签和参数,以及子路由。
OpenElementRouteNode英文源码说明
One node of the host-agnostic route tree: the matched URL `path` and route kind, the source and module paths the drivers resolve, the optional registered tag and param names, and the nested `children`.
packages/protocol/src/app-model.ts:9自定义元素声明中记录的一个插槽。
OpenElementSlot英文源码说明
One documented slot of a custom element declaration.
packages/protocol/src/manifest.ts:32RFC 9457 Problem Details 错误响应使用的媒体类型。
"application/problem+json"英文源码说明
Media type of the RFC 9457 action error channel (#863).
packages/protocol/src/data.ts:117表单 action 的协议错误使用的 RFC 9457 文档,按 application/problem+json 返回。detail 提供具体错误说明。
ProblemDetails英文源码说明
RFC 9457 Problem Details document (#863): the action error channel answers `application/problem+json` instead of the bespoke `{ type: 'error', error: { message } }` JSON, so HTTP tooling recognizes failures natively. With `type: 'about:blank'`, `title` is the HTTP reason phrase and `detail` carries the specific explanation. The wire shape is alpha-unfrozen; the 1.0 acceptance freezes it in this problem+json form.
packages/protocol/src/data.ts:105提供普通的协议上下文值。用于提供值的 Signal 仍由 openElement 内部持有。
<T>(host: HTMLElement, context: Context<T>, value: T): Unsubscribe英文源码说明
Provide a plain protocol value; the provider Signal remains OE-private. The returned handle owns exactly one provider record. A repeated call for the same host and {@linkcode Context.key} disposes the previous record (its request listener and mapping) before publishing the replacement, so repeated provides and reconnect cycles never accumulate listeners; the replaced handle becomes a no-op. Releasing removes only the current record and is idempotent.
packages/element/src/internal/core/signal-context.ts:131computed 等派生值使用的只读信号接口。
ReadonlySignal<T>英文源码说明
Read-only signal protocol used by computed values.
packages/protocol/src/signal.ts:26为组件内的一个原生 DOM 节点创建可复用句柄。通过 JSX 的 ref 属性设置,current 随节点连接和断开更新。
<T extends globalThis.Element = Element>(callback?: (element: T | null) => void | (() => void)): { (element: globalThis.Element | null): void; readonly current: T | null; }英文源码说明
Compiler-recognized node-handle factory (`16b-REF`): declares a REF HANDLE for one intrinsic DOM node of this component. The returned value is handed to that node's existing JSX `ref` attribute: ```tsx const field = ref<HTMLInputElement>((element) => { element?.focus(); return () => {/* detach cleanup *\/}; }); // … return <input ref={field} />; ``` The handle is the same object for the whole element lifetime: the compiler erases this call into the retained instance factory, so a reconnect, a claim of server DOM and an update all observe one handle rather than a per-pass copy. It is a REF CHANNEL VALUE, not a reactive source: `current` is written when the node attaches, cleared when it detaches, and it notifies nothing — a tracked slot reading `current` would be a one-shot value, which is why the compiler admits a handle ONLY in a `ref` attribute expression. The optional callback is the attach/detach notification the existing `ref` channel already defines: called with the element on attach, and with `null` on detach AFTER the cleanup it returned has run. Because the handle rides the same `ref` channel, the cleanup ordering, the once-per-detach rule and the scope ownership are the existing ones — this intrinsic adds no second attachment mechanism. Erased by the compiler; calling it at runtime fails closed.
packages/element/src/internal/core/compile-lifecycle.ts:187释放某次带宿主的 consumeContext 创建的提供者订阅。
(signalValue: SignalLike<unknown>): void英文源码说明
Release the provider bridge created by one hosted {@linkcode consumeContext} call. The bridge is deregistered only AFTER its cleanup returns: a throwing unsubscribe must not leave the signal in a state where the bridge is gone from the bookkeeping but still attached to the provider (unretryable). If cleanup throws, the entry stays registered and the error propagates verbatim, so the caller can retry the release — for example from a `disconnectedCallback` that runs again — once the provider's unsubscribe succeeds. A second call after a successful release is a no-op, and a signal without a bridge (including a signal created without a `host`) is always a no-op.
packages/element/src/internal/core/signal-context.ts:208可恢复的渲染错误,携带出错组件的文件路径与标签名。
class RenderError extends OpenElementError英文源码说明
Recoverable render-phase error carrying the failing component path and tag.
packages/element/src/internal/core/errors.ts:95在服务端渲染一个已编译的元素,直接返回序列化后的声明式 Shadow DOM HTML。
(input: string | CustomElementConstructor, options?: RenderToStringOptions): string英文源码说明
Server-render one compiled element through canonical Element composition: returns the serialized DSD `html` string directly.
packages/element/src/public-runtime.ts:945一次 renderToString 调用的选项,包括组件类、属性值、诊断上下文、可渲染的嵌套标签和插槽内容。
RenderToStringOptions英文源码说明
Options for one `renderToString()` call: the compiled component class to serialize, the values projected onto its compiled properties, optional route/source diagnostics metadata, the nested compiled tags the build admitted, and trusted parent-owned light children keyed by slot name.
packages/element/src/public-runtime.ts:170将框架错误交给遥测钩子,无钩子时写入 console.error。
(error: OpenElementError): void英文源码说明
Report an {@linkcode OpenElementError} to the telemetry hook, or console.error when none is installed.
packages/element/src/internal/core/errors.ts:139扫描后入选的路由,记录 URL 路径、源文件、类型、生成入口使用的变量名和可选注册标签。
RouteEntry英文源码说明
One route admitted by the scanner: URL `path`, source `filePath`, the route `type`, the generated variable name (`varName`) the entry binds it to, and the optional registration tag. {@link RouteEntry.definePage} and {@link RouteEntry.hasEnhancedForms} carry the two source-derived admission facts the generated entries branch on.
packages/protocol/src/framework.ts:113请求时渲染和静态站点生成共用的服务端路由上下文。
ServerRouteContext<Env, Platform, Route>英文源码说明
Canonical request-time/SSG server route context.
packages/protocol/src/data.ts:25动态路由 loader 接收的服务端上下文,包括标准请求、路由参数、宿主环境和平台对象。
ServerRouteMetadata英文源码说明
Context passed to a request-time ('dynamic') route loader. This is the server contract: the loader runs on the server with the Web-standard request, matched route params, the host environment and the platform object, and signals validation failure via fail()/redirect().
packages/protocol/src/data.ts:19安装或替换整个进程使用的错误遥测钩子。
(hook: ErrorTelemetryHook): void英文源码说明
Install the process-wide error telemetry hook (replaceable for tests, HMR, multi-app pages).
packages/element/src/internal/core/errors.ts:127创建可读写的响应式状态。
<T>(initialValue: T): WritableSignal<T>英文源码说明
Create a writable signal through the selected signal engine.
packages/element/src/internal/signal/framework.ts:19接受可写信号或只读信号的 API 所用类型。
Signal<T>英文源码说明
Alias for APIs that accept either writable or read-only signals.
packages/protocol/src/signal.ts:31路由扫描器按文件名识别的特殊类型,包括 renderer 和 middleware。
SpecialFileType英文源码说明
Special file kinds the route scanner recognizes by filename: `renderer` and `middleware`.
packages/protocol/src/framework.ts:79构建对自定义元素的 SSR 判定,记录模块路径、发现来源、渲染方式及原因。
SsrAdmissionDecision英文源码说明
The build's admission verdict for one discovered tag: where the declaration lives (`modulePath`), how it was discovered (`source`), which render path it is admitted to, and the reason recorded for the manifest.
packages/protocol/src/render.ts:37浏览器拒绝装入所属 Part 范围的流式片段所禁用的标签。
readonly ["script", "style", "template", "iframe", "object", "embed", "base", "meta", "link"]英文源码说明
Tags a deferred frame cannot safely install into an owned Part range: the browser installer rejects any frame whose markup carries one of these.
packages/protocol/src/stream-frame-policy.ts:26流式片段的 URL 属性不可使用的协议。
RegExp英文源码说明
Schemes that make a URL attribute unsafe in a streamed frame.
packages/protocol/src/stream-frame-policy.ts:60流式片段中需要检查 URL 协议的属性名。
readonly ["href", "src", "action", "formaction", "xlink:href"]英文源码说明
URL-carrying attributes the frame check screens for script-bearing scheme obfuscation; only these attribute names are value-screened.
packages/protocol/src/stream-frame-policy.ts:42检查 URL 协议前,会移除码点低于或等于此值的控制字符。
32英文源码说明
Control characters at or below this code point are stripped before the URL-scheme test, so tab/newline/control obfuscation cannot smuggle a scheme past admission.
packages/protocol/src/stream-frame-policy.ts:55一个流式路由允许在清单中声明的延迟字段数上限。
32英文源码说明
Deferred fields (declared streamed properties) one stream route's manifest may carry. The build scan, the server executor, and the browser seed contract enforce the same bound.
packages/protocol/src/policy.ts:24一个流式路由清单可以引用的 Part 和 Block 所有者数量上限。
64英文源码说明
Part/Block owners one stream route's manifest may address in total across all deferred fields.
packages/protocol/src/policy.ts:30流式载荷的最大序列化长度,以 UTF-16 码元计。
number英文源码说明
Serialized stream payload bound, as a string length in UTF-16 code units: one seed attribute or one deferred frame's markup may not exceed it. The server checks the JSON text and the rendered range before emitting; the browser checks the attribute before parsing.
packages/protocol/src/policy.ts:45流式 hydration 初始数据可携带的带类型属性数量上限。
64英文源码说明
Typed properties one streamed seed may carry: the browser seed contract rejects the WHOLE seed above this count, so an oversized component would silently fail to hydrate instead of failing loud at the server.
packages/protocol/src/policy.ts:37流式响应等待延迟字段完成的时间上限(毫秒)。
30000英文源码说明
Deferred-field resolution budget (milliseconds) for one streamed response: fields still pending when it expires are failed in place and the stream ends with the shell and whatever resolved.
packages/protocol/src/policy.ts:64可跨执行环境使用的样式表构造器,按环境选择原生 CSSStyleSheet 或兼容实现。
new () => StyleSheetLike英文源码说明
Cross-realm StyleSheet constructor: the native CSSStyleSheet or the internal shim.
packages/element/src/internal/core/style-sheet.ts:110原生样式表与兼容实现共用的最小接口,包括 replaceSync 和 cssRules。
StyleSheetLike英文源码说明
Minimal stylesheet contract (replaceSync + cssRules) satisfied by native and shim sheets.
packages/protocol/src/style-sheet.ts:14将 HTML 字符串标记为可信,以便显式传给 innerHTML。序列化时不会保留可信标记。
(html: string): TrustedHtml英文源码说明
Mark an HTML string as trusted for explicit `innerHTML` sinks (the trust does not serialize).
packages/element/src/internal/core/security.ts:88标识应用已明确审查并信任的 HTML。
TrustedHtml英文源码说明
Opaque capability marking HTML the application has explicitly vetted as trusted.
packages/element/src/internal/core/security.ts:83判断 Part Program 中的静态属性是否会使流式片段无法通过安装校验。
(name: string, value: string): boolean英文源码说明
Whether a static attribute (name/value as authored into the Part Program) makes a streamed frame unsafely installable: event-handler, seed-spoofing, and srcdoc names fail outright, and URL-carrying names fail when the entity-decoded, control-stripped value carries a script scheme.
packages/protocol/src/stream-frame-policy.ts:113订阅最近提供者的上下文,返回由实例持有的信号。没有提供者时读到令牌的默认值。
<T>(context: { readonly key: symbol; readonly defaultValue: T; }): { readonly value: T; subscribe(fn: (value: T) => void): () => void; }英文源码说明
Compiler-recognized CONSUMER intrinsic (`16b-CTX`): declares a tracked consumer of `context` for this component and returns the signal its value lives in. ```tsx const theme = useContext(ThemeContext); return <p>{theme.value}</p>; // a tracked slot: refreshes on provider change ``` The returned signal is ONE persistent consumer-local signal: the compiler erases this call into the component's retained setup record, so a reconnect re-reads the nearest provider into the SAME object and a tracked slot keeps exactly one subscription target for the whole element lifetime. Lookup follows the nearest owning component, so an inner provider shadows an outer one and a component with no ancestor provider reads the context's declared default. Reading `.value` in a tracked slot is the supported use — this is the lane's reactive channel, unlike `ref`'s `current`. Reading it inside a handler also works (the signal is live), but only tracked slots refresh. Erased by the compiler; calling it at runtime fails closed.
packages/element/src/internal/core/compile-lifecycle.ts:285获取当前组件所在的自定义元素。用于在组件中访问宿主节点。
(): HTMLElement英文源码说明
Compiler-recognized HOST-ACCESS intrinsic (`16b-REF`, `useHost`). ```tsx const host = useHost(); // … host is this instance's owning element (the custom element). ``` It exposes the SAME fact the lifecycle/change/error callbacks already receive as `env.host` — the owning generated element for a root, the nearest enclosing generated element host for a depth-1 retained hostless child — through the expression position instead of a callback parameter. There is therefore no new runtime channel and no second host lookup: the compiler erases the call into a read of the host-element field the retained setup factory already receives. The read is NOT reactive: the element identity never changes for an instance, so a derived node capturing it can never go stale. That is also why it carries no lifecycle ownership — it allocates nothing and needs no cleanup. Erased by the compiler; calling it at runtime fails closed.
packages/element/src/internal/core/compile-lifecycle.ts:218为渲染后的 HTML 补上文档类型、head 和 body,支持 CSP nonce 与开发脚本。
(html: string, options?: DocumentWrapOptions): string英文源码说明
Wrap rendered HTML in a full HTML document. Adds DOCTYPE, head (title, meta, preload), and body. Supports CSP nonce and dev scripts (e.g. Vite client, route module registration).
packages/element/src/internal/core/html-escape.ts:199按洋葱顺序将 fetch 中间件串联在处理函数外部。首个中间件最早收到请求,最后处理响应。
<Args extends unknown[]>(middleware: Middleware[], handler: (request: Request, ...args: Args) => Promise<Response>): (request: Request, ...args: Args) => Promise<Response>英文源码说明
Compose a fetch middleware chain (#858) around a handler, in onion order: `middleware[0]` is outermost — it sees the request first and the response last. A middleware may short-circuit by returning a Response without calling `next()`. Extra arguments (runtime context such as env/platform) thread transparently past the middleware chain to the terminal handler — the WinterCG-shaped middleware itself only ever sees `(request, next)`. Generated server entries call this once at module scope so the dev server, the `start` CLI, the e2e fixture server, and the Nitro production entry all share the same composed handler.
packages/element/src/internal/core/runtime.ts:47<Env extends Record<string, unknown> = Record<string, unknown>>(options: RuntimeAdapterOptions<Env>): RuntimeAdapter<Env>英文源码说明
Normalize a runtime adapter declaration: pass the name, fetch handler and optional prerender iterator through unchanged so a host integration only implements the {@link RuntimeAdapter} contract it needs.
packages/element/src/internal/core/runtime.ts:23将值序列化为格式化的 JSON,并在末尾添加换行。
(value: unknown): string英文源码说明
Serialize a value to pretty-printed JSON ending with a newline.
packages/element/src/internal/core/write-json.ts:11在 HTML 的 body 结束标签前插入标记,兼容标签大小写与结尾空白。
(html: string, content: string): string英文源码说明
Insert markup before a tolerant HTML body close (`</body >`, case-insensitive).
packages/element/src/internal/core/html-route-utils.ts:2(path: string, sep?: "/" | "-"): string英文源码说明
Normalize path separators and collapse duplicates. - Backslashes and forward slashes are replaced with the chosen separator. - Repeated separators are collapsed to a single separator.
packages/element/src/internal/core/path-utils.ts:17供运行时适配器和生成入口使用的统一请求处理函数,基于标准 Request 和 Response。
OpenElementRequestHandler<Env>英文源码说明
The host-neutral request handler every runtime adapter and generated server entry exposes: a WinterCG `(request, context?) => Response` with no server engine dialect baked in.
packages/protocol/src/runtime.ts:27(filePath: string): string英文源码说明
Convert a file path into a kebab-cased custom element tag name. - Removes a leading `./` or `/`. - Strips known file extensions (`ts`, `tsx`, `js`, `jsx`, `mjs`, `mdx`). - Replaces directory separators with hyphens. - Ensures the result starts with a letter and contains at least one hyphen.
packages/element/src/internal/core/path-utils.ts:32运行时适配器的上下文契约,用来隔离框架和部署环境。
RuntimeContext<Env>英文源码说明
runtime.ts - Runtime adapter protocol. Replacement boundary for Nitro, Workers, Node, Deno, or future fetch-compatible runtimes. Preserves openElement semantics while leaving concrete server engines outside this package.
packages/protocol/src/runtime.ts:9静态站点生成无法加载服务端包或执行失败时抛出的错误,也由 @openelement/element/build-utils 导出。
class SsrRenderError extends OpenElementError英文源码说明
Thrown by the SSG build pipeline when the SSR bundle fails to load or the pipeline throws; re-exported via `@openelement/element/build-utils`. Carries the failing component path plus the original error as `cause`.
packages/element/src/internal/core/errors.ts:74为源码注入交互岛元数据标记。
(source: string, options: IslandTransformOptions): IslandTransformResult英文源码说明
Inject island metadata markers into source code. Only transforms files inside the islands directory. Tag names are derived from the file path and normalized to valid custom element names (lowercase letters, digits, and hyphens). Unsafe characters are silently normalized to hyphens.
packages/element/src/internal/core/island-transform.ts:20为当前服务端进程设置已生成的样式表 URL。
(urls: readonly string[] | null | undefined, islandEntries?: ReadonlyArray<readonly [string, readonly string[] | null]> | null): void英文源码说明
Set the emitted stylesheet URLs for this server process. Called by the router's generated SSR/SSG entry (build time and request-time startup) with the base-joined asset addresses Phase 2 emitted. The optional `islandEntries` half carries the per-tag URLs of generated SHADOW hosts (M09-2e / #1803) through the SAME channel: one setter, one entry import, no second public seam. A `null` URL list is the explicit "declared but carrier unavailable" state the nested renderer fails closed on.
packages/element/src/internal/compiled/server/style-links.ts:34处理页面路由的表单提交。
Action<T, Env, Platform, Route>英文源码说明
Route action: handles form submissions for a page route.
packages/protocol/src/data.ts:64选择表单 action 的响应通道。true 返回序列化结果,enhance 返回与无脚本提交相同的 HTML。
"x-openelement-action"英文源码说明
Request header selecting the action response channel: `true` marks a programmatic caller and selects the serialized ActionResult union; `enhance` marks the built-in morph enhancement and selects the same full-HTML responses the no-JS path receives.
packages/protocol/src/data.ts:125传给路由 action 的上下文,包含 loader 上下文。
ActionContext<Env, Platform, Route>英文源码说明
Context passed to a route action function (extends loader context).
packages/protocol/src/data.ts:47脚本提交表单时返回的联合类型。校验失败返回 failure,成功提交返回 redirect;协议错误使用 ProblemDetails。
ActionResult<Failure>英文源码说明
Wire shape returned to the JavaScript form-enhancement path. The no-JS path never sees this: it gets the equivalent semantics as plain HTTP (303 on success, 422 with the re-rendered form on validation failure, redirect/error as status codes). Success carries no data envelope. The application-loop contract makes a successful non-GET action answer 303 (PRG) — the framework never answers 200 with a rendered page, or with a success document, for a successful mutation — so the fetch channel answers `{ type: 'redirect' }` naming the PRG target and the authored return value is discarded by design. Success data travels the PRG target instead (query state the loader re-runs with, which the props projector then maps; see the router guide's "Form actions" section). The union previously declared a `{ type: 'success' }` member that no code path ever emitted — removed so the type matches the wire. Error outcomes (CSRF 403, unknown action 404, unparseable body 400, unexpected 500) are NOT part of this union: since #863 they answer RFC 9457 Problem Details with the PROBLEM_JSON_MEDIA_TYPE content type — see ProblemDetails.
packages/protocol/src/data.ts:92检查名称是否符合自定义元素的标签名规则。
(tagName: string): void英文源码说明
Assert that a tag name is a valid custom element name.
packages/element/src/internal/core/tag-utils.ts:50收集宿主对象上所有公开的自有属性。
(host: object): Record<string, unknown>英文源码说明
Collect all public (non-internal) own properties from a host object. Keys starting with `__openElement` are framework-internal and excluded. Uses Reflect.get for safe access (respects getters); a getter that throws is skipped with a warning so one bad prop cannot take the tree down.
packages/element/src/internal/core/props-utils.ts:41兼容性扫描为每个标签记录分级、原因、来源和对应的 SSR、DSD 与 hydration 判定依据。
CompatibilityClassification英文源码说明
The per-tag verdict the compatibility scanner records: the tier a discovered tag was classified as, the human-readable `reason`, where the tag was found (`source`), and the SSR/DSD/hydration facts the verdict was derived from.
packages/protocol/src/framework.ts:347标签的构建兼容级别,区分服务端渲染、仅浏览器渲染、实验支持和拒绝构建。
CompatibilityTier英文源码说明
How far a discovered tag may participate in the build: 'ssr-capable' renders and hydrates, 'client-only' ships to the browser without server output, 'experimental-dom' is admitted with a downgraded guarantee, and 'rejected' fails the build.
packages/protocol/src/framework.ts:340组件的交付层级,区分静态 DSD、带交互岛的 DSD、仅客户端交互岛和 Light DOM。
ComponentLayer英文源码说明
The delivery layer a component belongs to: fully static DSD markup ('dsd-static'), DSD markup with a client island ('dsd-interactive'), a client-only island with no SSR output ('pure-island'), or a light-DOM element ('light-dom'). Recorded per component in the build manifest and consumed by the hydration scheduler.
packages/protocol/src/framework.ts:23根据依赖计算一个只读响应式值。
<T>(fn: () => T): ReadonlySignal<T>英文源码说明
Create a derived read-only signal recomputed from its dependencies.
packages/element/src/internal/signal/framework.ts:23将上下文投影为消费端的响应式值。传入宿主时,消费端负责通过 releaseConsumedContext 释放订阅。
<T>(context: Context<T>, host?: HTMLElement): WritableSignal<T>英文源码说明
Consumer-local reactive projection of a protocol context value. When a `host` is given, the returned signal is bridged to the nearest provider through one Community Context Protocol subscription. That bridge is owned by the CALLER: a long-lived consumer must release it when it tears down (typically `disconnectedCallback`) with {@linkcode releaseConsumedContext}, exactly once. Releasing detaches the provider bridge, so the provider no longer retains or updates the local signal; the local signal itself stays usable with its last value. A call after a successful release is a no-op, and a signal created without a `host` has no bridge to release.
packages/element/src/internal/core/signal-context.ts:183上下文令牌,包含协议使用的键和默认值。
Context<T>英文源码说明
A typed context token: protocol identity (`key`) plus its default value.
packages/element/src/internal/core/signal-context.ts:13创建供提供方与消费方共享的带类型上下文令牌。
<T>(key: symbol, defaultValue: T): Context<T>英文源码说明
Create a typed context token shared between provider and consumer elements.
packages/element/src/internal/core/signal-context.ts:58为一次服务端渲染创建文档级样式表收集器。
(): DocumentStyleResources英文源码说明
Create the per-render document stylesheet collection.
packages/element/src/internal/core/html-escape.ts:133创建在每条消息前加上标签的日志记录器。
(tag: string): Logger英文源码说明
Create a {@link Logger} that prefixes every message with `[tag]`.
packages/element/src/internal/core/logger.ts:18从不可信属性复制数据时必须排除的对象原型键。
ReadonlySet<string>英文源码说明
Object prototype keys that must never be injected from untrusted props.
packages/element/src/internal/core/security.ts:25在指定根节点及其嵌套 Shadow Root 中查找匹配 ID 的元素,返回首个匹配项。
(id: string, root?: Document | ShadowRoot): HTMLElement | null英文源码说明
Resolve `id` (a `#hash` or bare id) against `root` and, when the id is not in that root's own tree, recurse into every nested shadow root. Returns the first match or `null`; a malformed percent-encoded id is not an error.
packages/element/src/internal/core/deep-fragment.ts:20使用相同的文档序列化规则生成流式响应的首尾片段,保留正文容器供流写入。
(options?: DocumentWrapOptions): { prefix: string; suffix: string; }英文源码说明
The same document serialization boundary, with only body wrappers left open.
packages/element/src/internal/core/html-escape.ts:205记录一次服务端渲染所发现的文档级样式表,供组件序列化与文档 head 共用。
DocumentStyleResources英文源码说明
The document-level stylesheet resources ONE server render discovered (alpha15 S lane, S-C1.2). A light-root component's DOM lives in the document, so its sheet cannot ride the component's own subtree the way a shadow template's link does: the document owns it. This object is the one carrier between the two halves of that render — the compiled serializer, which discovers a component's external sheets while serializing the component, and the document serializer, which writes the head. It is created per render and never shared, so one page's stylesheets can never reach another page's head.
packages/element/src/internal/core/html-escape.ts:125运行副作用,并在使用的信号发生变化时重新执行和订阅。
(fn: () => void | Unsubscribe): Unsubscribe英文源码说明
Run a side effect that re-subscribes whenever its signal dependencies change.
packages/element/src/internal/signal/framework.ts:27在元素升级前捕获发往待启用交互岛的用户操作,接管 DOM 成功后重放。
(root?: EventTarget, pendingTags?: readonly string[]): void英文源码说明
Install the bounded pre-upgrade interaction capture on an owning root (default: the document). Generated client entries call this with their declared island tags before any compiled element upgrades; after a successful claim the element replays the captured events whose targets live inside its root (compiled claim capture/replay, internal/compiled/runtime.ts). Idempotent per root (repeat calls merge tags, never reinstall listeners) and a no-op where no DOM exists (SSR). Invariant: the capture itself — one fixed listener set per owning root, installed once per page — is page-lifetime by design and is NOT the leak. The M1 leak was retained event-target records; each element releases exactly its own records at its activation decision (success or failure), while records owned by still-pending elements survive for their delayed/lazy upgrade (#1170). Boundedness: the facade capture passes the declared-island filter, so only interactions under a still-pending DECLARED island tag enter the queue — ordinary events and undeclared third-party custom elements are skipped (nested pending declared islands still capture through their own unsettled host). With no tags declared the legacy dash heuristic applies. The shared queue carries a hard capacity cap (fail closed), detached records are swept when a claim root adopts its share (and under queue pressure), and each activation decision deterministically empties that root's own bucket, so post-hydration traffic and removals never grow retention.
packages/element/src/internal/compiled/runtime/pre-upgrade-events.ts:662openElement 错误消息使用的前缀。
"[openElement]"英文源码说明
Error message prefix for all openElement errors.
packages/protocol/src/errors.ts:50接收所有通过错误遥测渠道上报的 OpenElementError。
ErrorTelemetryHook英文源码说明
Callback receiving every reported {@linkcode OpenElementError} for telemetry.
packages/protocol/src/errors.ts:132对 HTML 属性值进行转义。
(value: string): string英文源码说明
Escape an HTML attribute value. Delegates to `escapeHtml` so both share the single `ESCAPE_MAP` and the same single-pass replacement (consolidated in #633). Empty-value conventions remain intentionally distinct by design: - `escapeHtml` returns '' for non-string input. - `escapeAttrValue` (below) coerces via `String()` and is the boundary meant for unknown/variable attribute values.
packages/element/src/internal/core/html-escape.ts:55对文本中的五个 HTML 特殊字符进行转义。
(str: string): string英文源码说明
Escape the five HTML-significant characters in text content.
packages/element/src/internal/core/html-escape.ts:39将未知类型的异常值格式化为可读的字符串。
(e: unknown): string英文源码说明
Format an unknown thrown value as a human-readable string.
packages/element/src/internal/core/errors.ts:52FrameworkOptions英文源码说明
The adapter-facing framework options: where routes and islands live, the default layout and named-layout declarations, the document `<html>`/head injection channels, and the request-time middleware switches. Every field is optional; the adapter applies its documented default. This is the type an application config file's default export is checked against, so the rendered option table and the actual config surface cannot drift.
packages/protocol/src/framework.ts:180运行时支持的 hydration 策略列表,以及 HydrationStrategy 联合类型的来源。
readonly ["load", "idle", "visible", "only", "none"]英文源码说明
Runtime list of supported hydration strategies; the single source of truth for the `HydrationStrategy` union. Consumed by island/registry validation and re-exported from the element root for app and build adapters.
packages/protocol/src/framework.ts:28控制交互岛何时启用,也可跳过浏览器 hydration。
"load" | "idle" | "visible" | "only" | "none"英文源码说明
Island hydration trigger: 'load' | 'idle' | 'visible' | 'only'.
packages/protocol/src/framework.ts:30环境缺少 requestIdleCallback 和 requestAnimationFrame 时,空闲 hydration 的备用延时(毫秒)。
50英文源码说明
Idle-hydration scheduling fallback (milliseconds) when neither `requestIdleCallback` nor `requestAnimationFrame` is available.
packages/protocol/src/policy.ts:70将调用方提供的属性写入目标对象,跳过受保护的键,并容忍只读属性。
(target: Record<string, unknown>, props: Record<string, unknown>, tagName: string, log?: { warn(message: string): void; debug(message: string): void; }): void英文源码说明
Safely assign caller-supplied props onto a target object, skipping keys that could enable prototype pollution and tolerating read-only properties. The canonical guarded assigner for the canonical dangerous-key rule (#903, #1214): the
packages/element/src/internal/core/security.ts:131判断属性键是否为框架在写入属性时必须拒绝的对象原型键。
(key: string): boolean英文源码说明
Shared dangerous-key predicate (#903, #1214). Prototype-internal keys must never be injected from untrusted props on ANY path: host prop collection (collectPublicProps / normalizePublicProps in props-utils.ts), guarded assignment (injectPropsSafe below — the SPA bootstrap page-projection write boundary in
packages/element/src/internal/core/security.ts:53交互岛的交付选项,包括 hydration 策略和是否参与 SSR 或 DSD。
IslandOptions英文源码说明
Per-island delivery options (hydration strategy, SSR/DSD participation).
packages/protocol/src/island.ts:8服务端渲染检查属性名时调用的公共校验入口,规则和协议层一致。
(name: string): boolean英文源码说明
Shared safe-attribute-name predicate (#1033): the SSR face of the one canonical predicate in `../protocol/forbidden-sinks.ts`. A name must be valid HTML attribute-name grammar (blocks quote/space injection, #602), must not be an event handler (`on*`, case-insensitive), and must not be a forbidden sink (`innerhtml`/`srcdoc`). The compiler, protocol validator, and server serializer enforce the same predicate with their own failure strategies; every path delegates to the single implementation, so the boundary cannot diverge.
packages/element/src/internal/core/security.ts:67判断字符串是否符合 HTML 自定义元素的标签名规则。
(tagName: string): boolean英文源码说明
Check if a tag name is a valid custom element name per HTML spec.
packages/element/src/internal/core/tag-utils.ts:38为路由选择内置布局、指定自定义布局及其模块和属性,或关闭布局。
LayoutConfig英文源码说明
Layout declaration: `false` disables the layout entirely, `'default'` uses the built-in layout, and the object form names a tag with the module path that defines it (`import`, resolved like a {@link FrameworkOptions.middleware.use } entry) plus the compiled layout properties the router injects per route.
packages/protocol/src/framework.ts:96为页面路由获取数据的 loader。
Loader<T, Env, Platform, Route>英文源码说明
Route loader: fetches data for a page route.
packages/protocol/src/data.ts:56传给动态路由 loader 的请求上下文。
LoaderContext<Env, Platform, Route>英文源码说明
Context passed to a request-time ('dynamic') route loader.
packages/protocol/src/data.ts:40随语言解析的路径契约。
LocalePath英文源码说明
Locale-aware resolved path contract.
packages/protocol/src/framework.ts:82带标签的控制台日志接口。
Logger英文源码说明
logger.ts - Tagged console logger. Lightweight scoped logger. Returns plain functions so it is tree-shakable and has zero class overhead.
packages/element/src/internal/core/logger.ts:10生成的服务端入口对 POST action 请求体施加的字节上限。需要上传更大文件时,可使用配置了明确上限的 API 路由。
number英文源码说明
Request-body bound (bytes) the generated entry applies to action POST routes; larger uploads belong on API routes with explicit limits.
packages/protocol/src/policy.ts:57renderToString 允许展开的嵌套元素层数,避免循环组合导致无穷递归。
8英文源码说明
Nested element expansion depth bound for `renderToString`: cyclic component composition fails closed instead of recursing without end.
packages/protocol/src/policy.ts:51基于标准 Request 和 Response 的洋葱式中间件。可直接返回响应,也可在 next() 返回后处理响应。
Middleware英文源码说明
Fetch middleware contract (#858): WinterCG shape, dialect-free — no Hono/h3 context object. Composed at the handler boundary in onion order (`use[0]` is outermost: it sees the request first and the response last), so it runs with identical semantics in the dev server, the `start` CLI, the e2e fixture server, and the Nitro production entry. A middleware may short-circuit by returning a Response without calling `next()`, or post-process the Response that `next()` returns. Module contract: a Middleware is the DEFAULT EXPORT of a module referenced from `middleware.use` by path (e.g. './app/middleware/auth.ts'). The generated server entry imports the module, so the middleware may close over module scope and import local helpers and third-party packages — it is a real module in the server module graph, never serialized source.
packages/protocol/src/framework.ts:169生成的自定义元素每次连接时运行回调,包括重新连接。若回调返回清理函数,元素断开时会调用它。
(callback: (env: { readonly host: HTMLElement; readonly signal: AbortSignal; readonly states: CustomStateSet; }) => void | (() => void)): void英文源码说明
Compiler-recognized connect intrinsic: runs the callback on every connection of the generated element (initial mount and each reconnect) and releases the optional returned cleanup at that disconnection. Erased by the compiler; calling it at runtime fails closed. The callback may keep the original zero-argument form or declare ONE `env` parameter. `env.host` is the generated element the connection belongs to (for a depth-1 retained hostless child: its nearest ancestor generated element), and `env.signal` aborts at the START of that disconnection, before any registered cleanup runs; a reconnect gets a fresh, un-aborted signal. The parameter's type is the author-facing contract only — the compiler erases it and passes the value from the connection scope the callback runs in.
packages/element/src/internal/core/compile-lifecycle.ts:58在生成的元素实例最终销毁时运行一次回调,调用顺序在该连接的清理函数之后。
(callback: (env: { readonly host: HTMLElement; readonly signal: AbortSignal; readonly states: CustomStateSet; }) => void): void英文源码说明
Compiler-recognized dispose intrinsic: runs the callback exactly once when the generated element instance is torn down (explicit `dispose()`), after that connection's connect-cleanups. Erased by the compiler; calling it at runtime fails closed. The callback may keep the original zero-argument form or declare ONE `env` parameter whose `signal` is the instance-lifetime teardown signal: it is aborted at the start of teardown, before this and every other disposal callback runs, so `env.signal.aborted` is `true` inside the callback.
packages/element/src/internal/core/compile-lifecycle.ts:80处理当前生成元素在连接、接管服务端标记、更新或处理 DOM 事件时抛出的同步错误。
(callback: (env: { readonly host: HTMLElement; readonly signal: AbortSignal; readonly states: CustomStateSet; readonly error: unknown; }) => void): void英文源码说明
Compiler-recognized error intrinsic (`16b-EB`): the author-facing error boundary of ONE generated element. The callback runs when a value escapes from the element's own work — the connect/claim pass (mount, claim, setup and the `onConnect` replay) and an UPDATE-phase write (a tracked slot refresh or a DOM event handler dispatched inside the compiled body). Erased by the compiler; calling it at runtime fails closed. `env.host` is the generated element the failing work belongs to (the nearest ancestor generated element for a depth-1 retained hostless child), `env.signal` is the per-connection `LifetimeScope` signal for a connect-phase failure and the instance-lifetime teardown signal otherwise, `env.states` is the element's `CustomStateSet`, and `env.error` is the thrown value EXACTLY as it was thrown (never wrapped or replaced). The callback may keep the zero-argument form. A catching handler changes only whether the error escapes: a connect-phase failure still leaves the element in its defined post-failure state (no projection, no listeners, a later reconnect retries from scratch), and an update-phase failure leaves the previously written DOM in place with the subscription still live for the next write. A handler that itself throws REPLACES the original error — that new throw is what surfaces. With no registered handler the pre-existing rethrow/rollback behaviour is unchanged. The callback is CLIENT-owned: it is erased into the compiled module and never runs during `__ssr` (a server render has no element, no connection scope and no handler registry; a producer throw fails the render, exactly as before).
packages/element/src/internal/core/compile-lifecycle.ts:144元素的已声明属性写入新值后运行回调,包括 attribute 和 property 写入。
(callback: (event: { readonly host: HTMLElement; readonly signal: AbortSignal; readonly states: CustomStateSet; readonly name: string; readonly value: unknown; }) => void): void英文源码说明
Compiler-recognized change intrinsic: runs the callback after a DECLARED property of this generated element commits a new value, for an attribute write and for a property write, and never at setup. Erased by the compiler — the callback is registered on the element-lifetime instance owner through the compiler-private host record; calling it at runtime fails closed. `event.host` is the generated element (the nearest ancestor generated element for a depth-1 retained hostless child), `event.signal` is the instance-lifetime teardown signal, and `event.name`/`event.value` are the changed row and its committed value. The callback may keep the zero-argument form.
packages/element/src/internal/core/compile-lifecycle.ts:103自定义元素声明中记录的一个 attribute。
OpenElementAttribute英文源码说明
One documented attribute of a custom element declaration.
packages/protocol/src/manifest.ts:15自定义元素声明中记录的一个 CSS part。
OpenElementCssPart英文源码说明
One documented CSS part of a custom element declaration.
packages/protocol/src/manifest.ts:38包清单中的自定义元素声明,包括标签名、成员和交付信息。
OpenElementDeclaration英文源码说明
One custom element declaration in a package manifest: tag, members and delivery metadata.
packages/protocol/src/manifest.ts:116框架错误,提供稳定错误码、严重程度、发生阶段和可恢复性。
class OpenElementError extends Error英文源码说明
Framework error carrying a stable code, severity, phase and recoverability contract.
packages/protocol/src/errors.ts:100自定义元素声明中记录的一个自定义事件。
OpenElementEvent英文源码说明
One documented custom event of a custom element declaration.
packages/protocol/src/manifest.ts:25包级组件清单,记录其中声明的组件。
OpenElementPackageManifest英文源码说明
Package manifest of component declarations (not a Custom Elements Manifest).
packages/protocol/src/manifest.ts:129应用与构建驱动共享的路由类别。
OpenElementRouteKind英文源码说明
Host-agnostic route and asset contracts shared by app and build drivers.
packages/protocol/src/app-model.ts:2路由树节点,记录匹配路径、路由类型、源码与模块路径、可选的标签和参数,以及子路由。
OpenElementRouteNode英文源码说明
One node of the host-agnostic route tree: the matched URL `path` and route kind, the source and module paths the drivers resolve, the optional registered tag and param names, and the nested `children`.
packages/protocol/src/app-model.ts:9自定义元素声明中记录的一个插槽。
OpenElementSlot英文源码说明
One documented slot of a custom element declaration.
packages/protocol/src/manifest.ts:32RFC 9457 Problem Details 错误响应使用的媒体类型。
"application/problem+json"英文源码说明
Media type of the RFC 9457 action error channel (#863).
packages/protocol/src/data.ts:117表单 action 的协议错误使用的 RFC 9457 文档,按 application/problem+json 返回。detail 提供具体错误说明。
ProblemDetails英文源码说明
RFC 9457 Problem Details document (#863): the action error channel answers `application/problem+json` instead of the bespoke `{ type: 'error', error: { message } }` JSON, so HTTP tooling recognizes failures natively. With `type: 'about:blank'`, `title` is the HTTP reason phrase and `detail` carries the specific explanation. The wire shape is alpha-unfrozen; the 1.0 acceptance freezes it in this problem+json form.
packages/protocol/src/data.ts:105提供普通的协议上下文值。用于提供值的 Signal 仍由 openElement 内部持有。
<T>(host: HTMLElement, context: Context<T>, value: T): Unsubscribe英文源码说明
Provide a plain protocol value; the provider Signal remains OE-private. The returned handle owns exactly one provider record. A repeated call for the same host and {@linkcode Context.key} disposes the previous record (its request listener and mapping) before publishing the replacement, so repeated provides and reconnect cycles never accumulate listeners; the replaced handle becomes a no-op. Releasing removes only the current record and is idempotent.
packages/element/src/internal/core/signal-context.ts:131computed 等派生值使用的只读信号接口。
ReadonlySignal<T>英文源码说明
Read-only signal protocol used by computed values.
packages/protocol/src/signal.ts:26为组件内的一个原生 DOM 节点创建可复用句柄。通过 JSX 的 ref 属性设置,current 随节点连接和断开更新。
<T extends globalThis.Element = Element>(callback?: (element: T | null) => void | (() => void)): { (element: globalThis.Element | null): void; readonly current: T | null; }英文源码说明
Compiler-recognized node-handle factory (`16b-REF`): declares a REF HANDLE for one intrinsic DOM node of this component. The returned value is handed to that node's existing JSX `ref` attribute: ```tsx const field = ref<HTMLInputElement>((element) => { element?.focus(); return () => {/* detach cleanup *\/}; }); // … return <input ref={field} />; ``` The handle is the same object for the whole element lifetime: the compiler erases this call into the retained instance factory, so a reconnect, a claim of server DOM and an update all observe one handle rather than a per-pass copy. It is a REF CHANNEL VALUE, not a reactive source: `current` is written when the node attaches, cleared when it detaches, and it notifies nothing — a tracked slot reading `current` would be a one-shot value, which is why the compiler admits a handle ONLY in a `ref` attribute expression. The optional callback is the attach/detach notification the existing `ref` channel already defines: called with the element on attach, and with `null` on detach AFTER the cleanup it returned has run. Because the handle rides the same `ref` channel, the cleanup ordering, the once-per-detach rule and the scope ownership are the existing ones — this intrinsic adds no second attachment mechanism. Erased by the compiler; calling it at runtime fails closed.
packages/element/src/internal/core/compile-lifecycle.ts:187释放某次带宿主的 consumeContext 创建的提供者订阅。
(signalValue: SignalLike<unknown>): void英文源码说明
Release the provider bridge created by one hosted {@linkcode consumeContext} call. The bridge is deregistered only AFTER its cleanup returns: a throwing unsubscribe must not leave the signal in a state where the bridge is gone from the bookkeeping but still attached to the provider (unretryable). If cleanup throws, the entry stays registered and the error propagates verbatim, so the caller can retry the release — for example from a `disconnectedCallback` that runs again — once the provider's unsubscribe succeeds. A second call after a successful release is a no-op, and a signal without a bridge (including a signal created without a `host`) is always a no-op.
packages/element/src/internal/core/signal-context.ts:208可恢复的渲染错误,携带出错组件的文件路径与标签名。
class RenderError extends OpenElementError英文源码说明
Recoverable render-phase error carrying the failing component path and tag.
packages/element/src/internal/core/errors.ts:95在服务端渲染一个已编译的元素,直接返回序列化后的声明式 Shadow DOM HTML。
(input: string | CustomElementConstructor, options?: RenderToStringOptions): string英文源码说明
Server-render one compiled element through canonical Element composition: returns the serialized DSD `html` string directly.
packages/element/src/public-runtime.ts:945一次 renderToString 调用的选项,包括组件类、属性值、诊断上下文、可渲染的嵌套标签和插槽内容。
RenderToStringOptions英文源码说明
Options for one `renderToString()` call: the compiled component class to serialize, the values projected onto its compiled properties, optional route/source diagnostics metadata, the nested compiled tags the build admitted, and trusted parent-owned light children keyed by slot name.
packages/element/src/public-runtime.ts:170将框架错误交给遥测钩子,无钩子时写入 console.error。
(error: OpenElementError): void英文源码说明
Report an {@linkcode OpenElementError} to the telemetry hook, or console.error when none is installed.
packages/element/src/internal/core/errors.ts:139扫描后入选的路由,记录 URL 路径、源文件、类型、生成入口使用的变量名和可选注册标签。
RouteEntry英文源码说明
One route admitted by the scanner: URL `path`, source `filePath`, the route `type`, the generated variable name (`varName`) the entry binds it to, and the optional registration tag. {@link RouteEntry.definePage} and {@link RouteEntry.hasEnhancedForms} carry the two source-derived admission facts the generated entries branch on.
packages/protocol/src/framework.ts:113请求时渲染和静态站点生成共用的服务端路由上下文。
ServerRouteContext<Env, Platform, Route>英文源码说明
Canonical request-time/SSG server route context.
packages/protocol/src/data.ts:25动态路由 loader 接收的服务端上下文,包括标准请求、路由参数、宿主环境和平台对象。
ServerRouteMetadata英文源码说明
Context passed to a request-time ('dynamic') route loader. This is the server contract: the loader runs on the server with the Web-standard request, matched route params, the host environment and the platform object, and signals validation failure via fail()/redirect().
packages/protocol/src/data.ts:19安装或替换整个进程使用的错误遥测钩子。
(hook: ErrorTelemetryHook): void英文源码说明
Install the process-wide error telemetry hook (replaceable for tests, HMR, multi-app pages).
packages/element/src/internal/core/errors.ts:127创建可读写的响应式状态。
<T>(initialValue: T): WritableSignal<T>英文源码说明
Create a writable signal through the selected signal engine.
packages/element/src/internal/signal/framework.ts:19接受可写信号或只读信号的 API 所用类型。
Signal<T>英文源码说明
Alias for APIs that accept either writable or read-only signals.
packages/protocol/src/signal.ts:31路由扫描器按文件名识别的特殊类型,包括 renderer 和 middleware。
SpecialFileType英文源码说明
Special file kinds the route scanner recognizes by filename: `renderer` and `middleware`.
packages/protocol/src/framework.ts:79构建对自定义元素的 SSR 判定,记录模块路径、发现来源、渲染方式及原因。
SsrAdmissionDecision英文源码说明
The build's admission verdict for one discovered tag: where the declaration lives (`modulePath`), how it was discovered (`source`), which render path it is admitted to, and the reason recorded for the manifest.
packages/protocol/src/render.ts:37浏览器拒绝装入所属 Part 范围的流式片段所禁用的标签。
readonly ["script", "style", "template", "iframe", "object", "embed", "base", "meta", "link"]英文源码说明
Tags a deferred frame cannot safely install into an owned Part range: the browser installer rejects any frame whose markup carries one of these.
packages/protocol/src/stream-frame-policy.ts:26流式片段的 URL 属性不可使用的协议。
RegExp英文源码说明
Schemes that make a URL attribute unsafe in a streamed frame.
packages/protocol/src/stream-frame-policy.ts:60流式片段中需要检查 URL 协议的属性名。
readonly ["href", "src", "action", "formaction", "xlink:href"]英文源码说明
URL-carrying attributes the frame check screens for script-bearing scheme obfuscation; only these attribute names are value-screened.
packages/protocol/src/stream-frame-policy.ts:42检查 URL 协议前,会移除码点低于或等于此值的控制字符。
32英文源码说明
Control characters at or below this code point are stripped before the URL-scheme test, so tab/newline/control obfuscation cannot smuggle a scheme past admission.
packages/protocol/src/stream-frame-policy.ts:55一个流式路由允许在清单中声明的延迟字段数上限。
32英文源码说明
Deferred fields (declared streamed properties) one stream route's manifest may carry. The build scan, the server executor, and the browser seed contract enforce the same bound.
packages/protocol/src/policy.ts:24一个流式路由清单可以引用的 Part 和 Block 所有者数量上限。
64英文源码说明
Part/Block owners one stream route's manifest may address in total across all deferred fields.
packages/protocol/src/policy.ts:30流式载荷的最大序列化长度,以 UTF-16 码元计。
number英文源码说明
Serialized stream payload bound, as a string length in UTF-16 code units: one seed attribute or one deferred frame's markup may not exceed it. The server checks the JSON text and the rendered range before emitting; the browser checks the attribute before parsing.
packages/protocol/src/policy.ts:45流式 hydration 初始数据可携带的带类型属性数量上限。
64英文源码说明
Typed properties one streamed seed may carry: the browser seed contract rejects the WHOLE seed above this count, so an oversized component would silently fail to hydrate instead of failing loud at the server.
packages/protocol/src/policy.ts:37流式响应等待延迟字段完成的时间上限(毫秒)。
30000英文源码说明
Deferred-field resolution budget (milliseconds) for one streamed response: fields still pending when it expires are failed in place and the stream ends with the shell and whatever resolved.
packages/protocol/src/policy.ts:64可跨执行环境使用的样式表构造器,按环境选择原生 CSSStyleSheet 或兼容实现。
new () => StyleSheetLike英文源码说明
Cross-realm StyleSheet constructor: the native CSSStyleSheet or the internal shim.
packages/element/src/internal/core/style-sheet.ts:110原生样式表与兼容实现共用的最小接口,包括 replaceSync 和 cssRules。
StyleSheetLike英文源码说明
Minimal stylesheet contract (replaceSync + cssRules) satisfied by native and shim sheets.
packages/protocol/src/style-sheet.ts:14将 HTML 字符串标记为可信,以便显式传给 innerHTML。序列化时不会保留可信标记。
(html: string): TrustedHtml英文源码说明
Mark an HTML string as trusted for explicit `innerHTML` sinks (the trust does not serialize).
packages/element/src/internal/core/security.ts:88标识应用已明确审查并信任的 HTML。
TrustedHtml英文源码说明
Opaque capability marking HTML the application has explicitly vetted as trusted.
packages/element/src/internal/core/security.ts:83判断 Part Program 中的静态属性是否会使流式片段无法通过安装校验。
(name: string, value: string): boolean英文源码说明
Whether a static attribute (name/value as authored into the Part Program) makes a streamed frame unsafely installable: event-handler, seed-spoofing, and srcdoc names fail outright, and URL-carrying names fail when the entity-decoded, control-stripped value carries a script scheme.
packages/protocol/src/stream-frame-policy.ts:113订阅最近提供者的上下文,返回由实例持有的信号。没有提供者时读到令牌的默认值。
<T>(context: { readonly key: symbol; readonly defaultValue: T; }): { readonly value: T; subscribe(fn: (value: T) => void): () => void; }英文源码说明
Compiler-recognized CONSUMER intrinsic (`16b-CTX`): declares a tracked consumer of `context` for this component and returns the signal its value lives in. ```tsx const theme = useContext(ThemeContext); return <p>{theme.value}</p>; // a tracked slot: refreshes on provider change ``` The returned signal is ONE persistent consumer-local signal: the compiler erases this call into the component's retained setup record, so a reconnect re-reads the nearest provider into the SAME object and a tracked slot keeps exactly one subscription target for the whole element lifetime. Lookup follows the nearest owning component, so an inner provider shadows an outer one and a component with no ancestor provider reads the context's declared default. Reading `.value` in a tracked slot is the supported use — this is the lane's reactive channel, unlike `ref`'s `current`. Reading it inside a handler also works (the signal is live), but only tracked slots refresh. Erased by the compiler; calling it at runtime fails closed.
packages/element/src/internal/core/compile-lifecycle.ts:285获取当前组件所在的自定义元素。用于在组件中访问宿主节点。
(): HTMLElement英文源码说明
Compiler-recognized HOST-ACCESS intrinsic (`16b-REF`, `useHost`). ```tsx const host = useHost(); // … host is this instance's owning element (the custom element). ``` It exposes the SAME fact the lifecycle/change/error callbacks already receive as `env.host` — the owning generated element for a root, the nearest enclosing generated element host for a depth-1 retained hostless child — through the expression position instead of a callback parameter. There is therefore no new runtime channel and no second host lookup: the compiler erases the call into a read of the host-element field the retained setup factory already receives. The read is NOT reactive: the element identity never changes for an instance, so a derived node capturing it can never go stale. That is also why it carries no lifecycle ownership — it allocates nothing and needs no cleanup. Erased by the compiler; calling it at runtime fails closed.
packages/element/src/internal/core/compile-lifecycle.ts:218为渲染后的 HTML 补上文档类型、head 和 body,支持 CSP nonce 与开发脚本。
(html: string, options?: DocumentWrapOptions): string英文源码说明
Wrap rendered HTML in a full HTML document. Adds DOCTYPE, head (title, meta, preload), and body. Supports CSP nonce and dev scripts (e.g. Vite client, route module registration).
packages/element/src/internal/core/html-escape.ts:199在指定根节点及其嵌套 Shadow Root 中查找匹配 ID 的元素,返回首个匹配项。
(id: string, root?: Document | ShadowRoot): HTMLElement | null英文源码说明
Resolve `id` (a `#hash` or bare id) against `root` and, when the id is not in that root's own tree, recurse into every nested shadow root. Returns the first match or `null`; a malformed percent-encoded id is not an error.
packages/element/src/internal/core/deep-fragment.ts:20在元素升级前捕获发往待启用交互岛的用户操作,接管 DOM 成功后重放。
(root?: EventTarget, pendingTags?: readonly string[]): void英文源码说明
Install the bounded pre-upgrade interaction capture on an owning root (default: the document). Generated client entries call this with their declared island tags before any compiled element upgrades; after a successful claim the element replays the captured events whose targets live inside its root (compiled claim capture/replay, internal/compiled/runtime.ts). Idempotent per root (repeat calls merge tags, never reinstall listeners) and a no-op where no DOM exists (SSR). Invariant: the capture itself — one fixed listener set per owning root, installed once per page — is page-lifetime by design and is NOT the leak. The M1 leak was retained event-target records; each element releases exactly its own records at its activation decision (success or failure), while records owned by still-pending elements survive for their delayed/lazy upgrade (#1170). Boundedness: the facade capture passes the declared-island filter, so only interactions under a still-pending DECLARED island tag enter the queue — ordinary events and undeclared third-party custom elements are skipped (nested pending declared islands still capture through their own unsettled host). With no tags declared the legacy dash heuristic applies. The shared queue carries a hard capacity cap (fail closed), detached records are swept when a claim root adopts its share (and under queue pressure), and each activation decision deterministically empties that root's own bucket, so post-hydration traffic and removals never grow retention.
packages/element/src/internal/compiled/runtime/pre-upgrade-events.ts:662为一次服务端渲染创建文档级样式表收集器。
(): DocumentStyleResources英文源码说明
Create the per-render document stylesheet collection.
packages/element/src/internal/core/html-escape.ts:133记录一次服务端渲染所发现的文档级样式表,供组件序列化与文档 head 共用。
DocumentStyleResources英文源码说明
The document-level stylesheet resources ONE server render discovered (alpha15 S lane, S-C1.2). A light-root component's DOM lives in the document, so its sheet cannot ride the component's own subtree the way a shadow template's link does: the document owns it. This object is the one carrier between the two halves of that render — the compiled serializer, which discovers a component's external sheets while serializing the component, and the document serializer, which writes the head. It is created per render and never shared, so one page's stylesheets can never reach another page's head.
packages/element/src/internal/core/html-escape.ts:125对 HTML 属性值进行转义。
(value: string): string英文源码说明
Escape an HTML attribute value. Delegates to `escapeHtml` so both share the single `ESCAPE_MAP` and the same single-pass replacement (consolidated in #633). Empty-value conventions remain intentionally distinct by design: - `escapeHtml` returns '' for non-string input. - `escapeAttrValue` (below) coerces via `String()` and is the boundary meant for unknown/variable attribute values.
packages/element/src/internal/core/html-escape.ts:55转义字符串,以便用于双引号包裹的 HTML 属性值。
(value: unknown): string英文源码说明
Escape a string for use as an attribute value (double-quoted)
packages/element/src/internal/core/html-escape.ts:60对文本中的五个 HTML 特殊字符进行转义。
(str: string): string英文源码说明
Escape the five HTML-significant characters in text content.
packages/element/src/internal/core/html-escape.ts:39(href: string): boolean英文源码说明
True when an href has the shape a framework-emitted component stylesheet address takes: a site-absolute path or an absolute http(s) URL, without whitespace or markup-significant characters. ONE rule for both sinks that serialize such an address — the DSD template's links and the document head's — so a component's stylesheet reaches a browser the same way whichever root kind the component has.
packages/element/src/internal/core/html-escape.ts:158表示已完成 HTML 转义,可作为文本内容使用的字符串类型。
SafeHtml英文源码说明
Branded type: a string that has been HTML-escaped (safe for text content)
packages/protocol/src/framework.ts:9将 HTML 字符串标记为可信,以便显式传给 innerHTML。序列化时不会保留可信标记。
(html: string): TrustedHtml英文源码说明
Mark an HTML string as trusted for explicit `innerHTML` sinks (the trust does not serialize).
packages/element/src/internal/core/security.ts:88标识应用已明确审查并信任的 HTML。
TrustedHtml英文源码说明
Opaque capability marking HTML the application has explicitly vetted as trusted.
packages/element/src/internal/core/security.ts:83标识尚未转义、未被信任的 HTML 字符串。
UnsafeHtml英文源码说明
Branded type: a string that is intentionally raw/untrusted HTML
packages/protocol/src/framework.ts:12为渲染后的 HTML 补上文档类型、head 和 body,支持 CSP nonce 与开发脚本。
(html: string, options?: DocumentWrapOptions): string英文源码说明
Wrap rendered HTML in a full HTML document. Adds DOCTYPE, head (title, meta, preload), and body. Supports CSP nonce and dev scripts (e.g. Vite client, route module registration).
packages/element/src/internal/core/html-escape.ts:199只供类型检查使用的 Fragment 标记,运行时执行会抛出错误。
(_props?: unknown): JSX.Element英文源码说明
Typechecking-only fragment marker; fails closed when executed at runtime.
packages/element/src/jsx-dev-runtime.ts:39供 TypeScript 自动 JSX 转换使用的开发版类型接口。
any英文源码说明
JSX type interface consumed by TypeScript's automatic JSX transform.
packages/element/src/jsx-dev-runtime.ts:44为类型检查提供的 JSX 工厂,运行时调用会报错。
(_type: unknown, _props: unknown, _key: unknown, _isStaticChildren: unknown, _source: unknown, _self: unknown): JSX.Element英文源码说明
Typechecking-only factory; fails closed when executed at runtime.
packages/element/src/jsx-dev-runtime.ts:27只供类型检查使用的 Fragment 标记,运行时执行会抛出错误。
(_props?: unknown): JSX.Element英文源码说明
Typechecking-only fragment marker; fails closed when executed at runtime.
packages/element/src/jsx-runtime.ts:40只用于类型检查的 JSX 工厂,运行时调用会抛出错误。
(_type: unknown, _props: unknown): JSX.Element英文源码说明
Typechecking-only factory; fails closed when executed at runtime.
packages/element/src/jsx-runtime.ts:30供 TypeScript 自动 JSX 转换使用的类型接口。
any英文源码说明
JSX type interface consumed by TypeScript's automatic JSX transform.
packages/element/src/jsx-runtime.ts:45只用于类型检查的 JSX 工厂,运行时调用会抛出错误。
(_type: unknown, _props: unknown): JSX.Element英文源码说明
Typechecking-only factory; fails closed when executed at runtime.
packages/element/src/jsx-runtime.ts:35生成的自定义元素每次连接时运行回调,包括重新连接。若回调返回清理函数,元素断开时会调用它。
(callback: (env: { readonly host: HTMLElement; readonly signal: AbortSignal; readonly states: CustomStateSet; }) => void | (() => void)): void英文源码说明
Compiler-recognized connect intrinsic: runs the callback on every connection of the generated element (initial mount and each reconnect) and releases the optional returned cleanup at that disconnection. Erased by the compiler; calling it at runtime fails closed. The callback may keep the original zero-argument form or declare ONE `env` parameter. `env.host` is the generated element the connection belongs to (for a depth-1 retained hostless child: its nearest ancestor generated element), and `env.signal` aborts at the START of that disconnection, before any registered cleanup runs; a reconnect gets a fresh, un-aborted signal. The parameter's type is the author-facing contract only — the compiler erases it and passes the value from the connection scope the callback runs in.
packages/element/src/internal/core/compile-lifecycle.ts:58在生成的元素实例最终销毁时运行一次回调,调用顺序在该连接的清理函数之后。
(callback: (env: { readonly host: HTMLElement; readonly signal: AbortSignal; readonly states: CustomStateSet; }) => void): void英文源码说明
Compiler-recognized dispose intrinsic: runs the callback exactly once when the generated element instance is torn down (explicit `dispose()`), after that connection's connect-cleanups. Erased by the compiler; calling it at runtime fails closed. The callback may keep the original zero-argument form or declare ONE `env` parameter whose `signal` is the instance-lifetime teardown signal: it is aborted at the start of teardown, before this and every other disposal callback runs, so `env.signal.aborted` is `true` inside the callback.
packages/element/src/internal/core/compile-lifecycle.ts:80元素的已声明属性写入新值后运行回调,包括 attribute 和 property 写入。
(callback: (event: { readonly host: HTMLElement; readonly signal: AbortSignal; readonly states: CustomStateSet; readonly name: string; readonly value: unknown; }) => void): void英文源码说明
Compiler-recognized change intrinsic: runs the callback after a DECLARED property of this generated element commits a new value, for an attribute write and for a property write, and never at setup. Erased by the compiler — the callback is registered on the element-lifetime instance owner through the compiler-private host record; calling it at runtime fails closed. `event.host` is the generated element (the nearest ancestor generated element for a depth-1 retained hostless child), `event.signal` is the instance-lifetime teardown signal, and `event.name`/`event.value` are the changed row and its committed value. The callback may keep the zero-argument form.
packages/element/src/internal/core/compile-lifecycle.ts:103<T>(context: { readonly key: symbol; readonly defaultValue: T; }, read: () => T): void英文源码说明
Compiler-recognized PROVIDER intrinsic (`16b-CTX`): declares that this component provides `context` with the current value of `read` to its subtree. ```tsx const ThemeContext = createContext(Symbol('theme'), 'light'); function App() { provideContext(ThemeContext, () => props.theme); return <Child />; } ``` The second argument is a VALUE THUNK, deliberately: the compiler erases this call into the component's retained setup record and re-reads the thunk on connect and after every declared-row commit, so a provider follows the lane's one change channel (a property write) rather than introducing a second reactivity model. A `computed` would be the class lane's answer; this lane deliberately has no author `computed`. Published over the generated owner tree, hostless owners included: provider discovery is the Community Context Protocol `context-request` composed event, so the nearest ancestor provider wins and two sibling subtrees cannot see each other. A provider registers on connect, unregisters exactly once on disconnect, and registers again on reconnect. Erased by the compiler; calling it at runtime fails closed.
packages/element/src/internal/core/compile-lifecycle.ts:250为组件内的一个原生 DOM 节点创建可复用句柄。通过 JSX 的 ref 属性设置,current 随节点连接和断开更新。
<T extends globalThis.Element = Element>(callback?: (element: T | null) => void | (() => void)): { (element: globalThis.Element | null): void; readonly current: T | null; }英文源码说明
Compiler-recognized node-handle factory (`16b-REF`): declares a REF HANDLE for one intrinsic DOM node of this component. The returned value is handed to that node's existing JSX `ref` attribute: ```tsx const field = ref<HTMLInputElement>((element) => { element?.focus(); return () => {/* detach cleanup *\/}; }); // … return <input ref={field} />; ``` The handle is the same object for the whole element lifetime: the compiler erases this call into the retained instance factory, so a reconnect, a claim of server DOM and an update all observe one handle rather than a per-pass copy. It is a REF CHANNEL VALUE, not a reactive source: `current` is written when the node attaches, cleared when it detaches, and it notifies nothing — a tracked slot reading `current` would be a one-shot value, which is why the compiler admits a handle ONLY in a `ref` attribute expression. The optional callback is the attach/detach notification the existing `ref` channel already defines: called with the element on attach, and with `null` on detach AFTER the cleanup it returned has run. Because the handle rides the same `ref` channel, the cleanup ordering, the once-per-detach rule and the scope ownership are the existing ones — this intrinsic adds no second attachment mechanism. Erased by the compiler; calling it at runtime fails closed.
packages/element/src/internal/core/compile-lifecycle.ts:187订阅最近提供者的上下文,返回由实例持有的信号。没有提供者时读到令牌的默认值。
<T>(context: { readonly key: symbol; readonly defaultValue: T; }): { readonly value: T; subscribe(fn: (value: T) => void): () => void; }英文源码说明
Compiler-recognized CONSUMER intrinsic (`16b-CTX`): declares a tracked consumer of `context` for this component and returns the signal its value lives in. ```tsx const theme = useContext(ThemeContext); return <p>{theme.value}</p>; // a tracked slot: refreshes on provider change ``` The returned signal is ONE persistent consumer-local signal: the compiler erases this call into the component's retained setup record, so a reconnect re-reads the nearest provider into the SAME object and a tracked slot keeps exactly one subscription target for the whole element lifetime. Lookup follows the nearest owning component, so an inner provider shadows an outer one and a component with no ancestor provider reads the context's declared default. Reading `.value` in a tracked slot is the supported use — this is the lane's reactive channel, unlike `ref`'s `current`. Reading it inside a handler also works (the signal is live), but only tracked slots refresh. Erased by the compiler; calling it at runtime fails closed.
packages/element/src/internal/core/compile-lifecycle.ts:285获取当前组件所在的自定义元素。用于在组件中访问宿主节点。
(): HTMLElement英文源码说明
Compiler-recognized HOST-ACCESS intrinsic (`16b-REF`, `useHost`). ```tsx const host = useHost(); // … host is this instance's owning element (the custom element). ``` It exposes the SAME fact the lifecycle/change/error callbacks already receive as `env.host` — the owning generated element for a root, the nearest enclosing generated element host for a depth-1 retained hostless child — through the expression position instead of a callback parameter. There is therefore no new runtime channel and no second host lookup: the compiler erases the call into a read of the host-element field the retained setup factory already receives. The read is NOT reactive: the element identity never changes for an instance, so a derived node capturing it can never go stale. That is also why it carries no lifecycle ownership — it allocates nothing and needs no cleanup. Erased by the compiler; calling it at runtime fails closed.
packages/element/src/internal/core/compile-lifecycle.ts:218创建在每条消息前加上标签的日志记录器。
(tag: string): Logger英文源码说明
Create a {@link Logger} that prefixes every message with `[tag]`.
packages/element/src/internal/core/logger.ts:18为一次渲染创建独立的警告记录范围。
(): WarnScope英文源码说明
Create a fresh, empty warning scope for one render.
packages/element/src/internal/core/logger.ts:41带标签的控制台日志接口。
Logger英文源码说明
logger.ts - Tagged console logger. Lightweight scoped logger. Returns plain functions so it is tree-shakable and has zero class overhead.
packages/element/src/internal/core/logger.ts:10在给定的渲染范围内每个键最多警告一次。未指定范围时使用进程内的全局记录。
(key: string, logger: Logger, msg: string, scope?: WarnScope): void英文源码说明
Warn at most once per `key` for the given render {@link WarnScope}, falling back to a process-wide set when no scope is passed.
packages/element/src/internal/core/logger.ts:52跟踪一次渲染中已发出的警告。
WarnScope英文源码说明
A render-scoped warning tracker. Pass a fresh `WarnScope` (via `createWarnScope()`) into `warnOnce` at a render entry (e.g. once per SSR document in `wrapInDocument`). Suppression is therefore scoped to a single render: the next page/request gets a new scope and the same key can warn again, so one muted key can never silence a diagnostic across all requests/SSG pages (#643).
packages/element/src/internal/core/logger.ts:36为当前服务端进程设置已生成的样式表 URL。
(urls: readonly string[] | null | undefined, islandEntries?: ReadonlyArray<readonly [string, readonly string[] | null]> | null): void英文源码说明
Set the emitted stylesheet URLs for this server process. Called by the router's generated SSR/SSG entry (build time and request-time startup) with the base-joined asset addresses Phase 2 emitted. The optional `islandEntries` half carries the per-tag URLs of generated SHADOW hosts (M09-2e / #1803) through the SAME channel: one setter, one entry import, no second public seam. A `null` URL list is the explicit "declared but carrier unavailable" state the nested renderer fails closed on.
packages/element/src/internal/compiled/server/style-links.ts:34处理页面路由的表单提交。
Action<T, Env, Platform, Route>英文源码说明
Route action: handles form submissions for a page route.
packages/protocol/src/data.ts:64选择表单 action 的响应通道。true 返回序列化结果,enhance 返回与无脚本提交相同的 HTML。
"x-openelement-action"英文源码说明
Request header selecting the action response channel: `true` marks a programmatic caller and selects the serialized ActionResult union; `enhance` marks the built-in morph enhancement and selects the same full-HTML responses the no-JS path receives.
packages/protocol/src/data.ts:125传给路由 action 的上下文,包含 loader 上下文。
ActionContext<Env, Platform, Route>英文源码说明
Context passed to a route action function (extends loader context).
packages/protocol/src/data.ts:47脚本提交表单时返回的联合类型。校验失败返回 failure,成功提交返回 redirect;协议错误使用 ProblemDetails。
ActionResult<Failure>英文源码说明
Wire shape returned to the JavaScript form-enhancement path. The no-JS path never sees this: it gets the equivalent semantics as plain HTTP (303 on success, 422 with the re-rendered form on validation failure, redirect/error as status codes). Success carries no data envelope. The application-loop contract makes a successful non-GET action answer 303 (PRG) — the framework never answers 200 with a rendered page, or with a success document, for a successful mutation — so the fetch channel answers `{ type: 'redirect' }` naming the PRG target and the authored return value is discarded by design. Success data travels the PRG target instead (query state the loader re-runs with, which the props projector then maps; see the router guide's "Form actions" section). The union previously declared a `{ type: 'success' }` member that no code path ever emitted — removed so the type matches the wire. Error outcomes (CSRF 403, unknown action 404, unparseable body 400, unexpected 500) are NOT part of this union: since #863 they answer RFC 9457 Problem Details with the PROBLEM_JSON_MEDIA_TYPE content type — see ProblemDetails.
packages/protocol/src/data.ts:92检查名称是否符合自定义元素的标签名规则。
(tagName: string): void英文源码说明
Assert that a tag name is a valid custom element name.
packages/element/src/internal/core/tag-utils.ts:50收集宿主对象上所有公开的自有属性。
(host: object): Record<string, unknown>英文源码说明
Collect all public (non-internal) own properties from a host object. Keys starting with `__openElement` are framework-internal and excluded. Uses Reflect.get for safe access (respects getters); a getter that throws is skipped with a warning so one bad prop cannot take the tree down.
packages/element/src/internal/core/props-utils.ts:41兼容性扫描为每个标签记录分级、原因、来源和对应的 SSR、DSD 与 hydration 判定依据。
CompatibilityClassification英文源码说明
The per-tag verdict the compatibility scanner records: the tier a discovered tag was classified as, the human-readable `reason`, where the tag was found (`source`), and the SSR/DSD/hydration facts the verdict was derived from.
packages/protocol/src/framework.ts:347标签的构建兼容级别,区分服务端渲染、仅浏览器渲染、实验支持和拒绝构建。
CompatibilityTier英文源码说明
How far a discovered tag may participate in the build: 'ssr-capable' renders and hydrates, 'client-only' ships to the browser without server output, 'experimental-dom' is admitted with a downgraded guarantee, and 'rejected' fails the build.
packages/protocol/src/framework.ts:340组件的交付层级,区分静态 DSD、带交互岛的 DSD、仅客户端交互岛和 Light DOM。
ComponentLayer英文源码说明
The delivery layer a component belongs to: fully static DSD markup ('dsd-static'), DSD markup with a client island ('dsd-interactive'), a client-only island with no SSR output ('pure-island'), or a light-DOM element ('light-dom'). Recorded per component in the build manifest and consumed by the hydration scheduler.
packages/protocol/src/framework.ts:23根据依赖计算一个只读响应式值。
<T>(fn: () => T): ReadonlySignal<T>英文源码说明
Create a derived read-only signal recomputed from its dependencies.
packages/element/src/internal/signal/framework.ts:23将上下文投影为消费端的响应式值。传入宿主时,消费端负责通过 releaseConsumedContext 释放订阅。
<T>(context: Context<T>, host?: HTMLElement): WritableSignal<T>英文源码说明
Consumer-local reactive projection of a protocol context value. When a `host` is given, the returned signal is bridged to the nearest provider through one Community Context Protocol subscription. That bridge is owned by the CALLER: a long-lived consumer must release it when it tears down (typically `disconnectedCallback`) with {@linkcode releaseConsumedContext}, exactly once. Releasing detaches the provider bridge, so the provider no longer retains or updates the local signal; the local signal itself stays usable with its last value. A call after a successful release is a no-op, and a signal created without a `host` has no bridge to release.
packages/element/src/internal/core/signal-context.ts:183上下文令牌,包含协议使用的键和默认值。
Context<T>英文源码说明
A typed context token: protocol identity (`key`) plus its default value.
packages/element/src/internal/core/signal-context.ts:13创建供提供方与消费方共享的带类型上下文令牌。
<T>(key: symbol, defaultValue: T): Context<T>英文源码说明
Create a typed context token shared between provider and consumer elements.
packages/element/src/internal/core/signal-context.ts:58为一次服务端渲染创建文档级样式表收集器。
(): DocumentStyleResources英文源码说明
Create the per-render document stylesheet collection.
packages/element/src/internal/core/html-escape.ts:133创建在每条消息前加上标签的日志记录器。
(tag: string): Logger英文源码说明
Create a {@link Logger} that prefixes every message with `[tag]`.
packages/element/src/internal/core/logger.ts:18从不可信属性复制数据时必须排除的对象原型键。
ReadonlySet<string>英文源码说明
Object prototype keys that must never be injected from untrusted props.
packages/element/src/internal/core/security.ts:25在指定根节点及其嵌套 Shadow Root 中查找匹配 ID 的元素,返回首个匹配项。
(id: string, root?: Document | ShadowRoot): HTMLElement | null英文源码说明
Resolve `id` (a `#hash` or bare id) against `root` and, when the id is not in that root's own tree, recurse into every nested shadow root. Returns the first match or `null`; a malformed percent-encoded id is not an error.
packages/element/src/internal/core/deep-fragment.ts:20使用相同的文档序列化规则生成流式响应的首尾片段,保留正文容器供流写入。
(options?: DocumentWrapOptions): { prefix: string; suffix: string; }英文源码说明
The same document serialization boundary, with only body wrappers left open.
packages/element/src/internal/core/html-escape.ts:205记录一次服务端渲染所发现的文档级样式表,供组件序列化与文档 head 共用。
DocumentStyleResources英文源码说明
The document-level stylesheet resources ONE server render discovered (alpha15 S lane, S-C1.2). A light-root component's DOM lives in the document, so its sheet cannot ride the component's own subtree the way a shadow template's link does: the document owns it. This object is the one carrier between the two halves of that render — the compiled serializer, which discovers a component's external sheets while serializing the component, and the document serializer, which writes the head. It is created per render and never shared, so one page's stylesheets can never reach another page's head.
packages/element/src/internal/core/html-escape.ts:125运行副作用,并在使用的信号发生变化时重新执行和订阅。
(fn: () => void | Unsubscribe): Unsubscribe英文源码说明
Run a side effect that re-subscribes whenever its signal dependencies change.
packages/element/src/internal/signal/framework.ts:27在元素升级前捕获发往待启用交互岛的用户操作,接管 DOM 成功后重放。
(root?: EventTarget, pendingTags?: readonly string[]): void英文源码说明
Install the bounded pre-upgrade interaction capture on an owning root (default: the document). Generated client entries call this with their declared island tags before any compiled element upgrades; after a successful claim the element replays the captured events whose targets live inside its root (compiled claim capture/replay, internal/compiled/runtime.ts). Idempotent per root (repeat calls merge tags, never reinstall listeners) and a no-op where no DOM exists (SSR). Invariant: the capture itself — one fixed listener set per owning root, installed once per page — is page-lifetime by design and is NOT the leak. The M1 leak was retained event-target records; each element releases exactly its own records at its activation decision (success or failure), while records owned by still-pending elements survive for their delayed/lazy upgrade (#1170). Boundedness: the facade capture passes the declared-island filter, so only interactions under a still-pending DECLARED island tag enter the queue — ordinary events and undeclared third-party custom elements are skipped (nested pending declared islands still capture through their own unsettled host). With no tags declared the legacy dash heuristic applies. The shared queue carries a hard capacity cap (fail closed), detached records are swept when a claim root adopts its share (and under queue pressure), and each activation decision deterministically empties that root's own bucket, so post-hydration traffic and removals never grow retention.
packages/element/src/internal/compiled/runtime/pre-upgrade-events.ts:662openElement 错误消息使用的前缀。
"[openElement]"英文源码说明
Error message prefix for all openElement errors.
packages/protocol/src/errors.ts:50接收所有通过错误遥测渠道上报的 OpenElementError。
ErrorTelemetryHook英文源码说明
Callback receiving every reported {@linkcode OpenElementError} for telemetry.
packages/protocol/src/errors.ts:132对 HTML 属性值进行转义。
(value: string): string英文源码说明
Escape an HTML attribute value. Delegates to `escapeHtml` so both share the single `ESCAPE_MAP` and the same single-pass replacement (consolidated in #633). Empty-value conventions remain intentionally distinct by design: - `escapeHtml` returns '' for non-string input. - `escapeAttrValue` (below) coerces via `String()` and is the boundary meant for unknown/variable attribute values.
packages/element/src/internal/core/html-escape.ts:55对文本中的五个 HTML 特殊字符进行转义。
(str: string): string英文源码说明
Escape the five HTML-significant characters in text content.
packages/element/src/internal/core/html-escape.ts:39将未知类型的异常值格式化为可读的字符串。
(e: unknown): string英文源码说明
Format an unknown thrown value as a human-readable string.
packages/element/src/internal/core/errors.ts:52FrameworkOptions英文源码说明
The adapter-facing framework options: where routes and islands live, the default layout and named-layout declarations, the document `<html>`/head injection channels, and the request-time middleware switches. Every field is optional; the adapter applies its documented default. This is the type an application config file's default export is checked against, so the rendered option table and the actual config surface cannot drift.
packages/protocol/src/framework.ts:180运行时支持的 hydration 策略列表,以及 HydrationStrategy 联合类型的来源。
readonly ["load", "idle", "visible", "only", "none"]英文源码说明
Runtime list of supported hydration strategies; the single source of truth for the `HydrationStrategy` union. Consumed by island/registry validation and re-exported from the element root for app and build adapters.
packages/protocol/src/framework.ts:28控制交互岛何时启用,也可跳过浏览器 hydration。
"load" | "idle" | "visible" | "only" | "none"英文源码说明
Island hydration trigger: 'load' | 'idle' | 'visible' | 'only'.
packages/protocol/src/framework.ts:30环境缺少 requestIdleCallback 和 requestAnimationFrame 时,空闲 hydration 的备用延时(毫秒)。
50英文源码说明
Idle-hydration scheduling fallback (milliseconds) when neither `requestIdleCallback` nor `requestAnimationFrame` is available.
packages/protocol/src/policy.ts:70将调用方提供的属性写入目标对象,跳过受保护的键,并容忍只读属性。
(target: Record<string, unknown>, props: Record<string, unknown>, tagName: string, log?: { warn(message: string): void; debug(message: string): void; }): void英文源码说明
Safely assign caller-supplied props onto a target object, skipping keys that could enable prototype pollution and tolerating read-only properties. The canonical guarded assigner for the canonical dangerous-key rule (#903, #1214): the
packages/element/src/internal/core/security.ts:131判断属性键是否为框架在写入属性时必须拒绝的对象原型键。
(key: string): boolean英文源码说明
Shared dangerous-key predicate (#903, #1214). Prototype-internal keys must never be injected from untrusted props on ANY path: host prop collection (collectPublicProps / normalizePublicProps in props-utils.ts), guarded assignment (injectPropsSafe below — the SPA bootstrap page-projection write boundary in
packages/element/src/internal/core/security.ts:53交互岛的交付选项,包括 hydration 策略和是否参与 SSR 或 DSD。
IslandOptions英文源码说明
Per-island delivery options (hydration strategy, SSR/DSD participation).
packages/protocol/src/island.ts:8服务端渲染检查属性名时调用的公共校验入口,规则和协议层一致。
(name: string): boolean英文源码说明
Shared safe-attribute-name predicate (#1033): the SSR face of the one canonical predicate in `../protocol/forbidden-sinks.ts`. A name must be valid HTML attribute-name grammar (blocks quote/space injection, #602), must not be an event handler (`on*`, case-insensitive), and must not be a forbidden sink (`innerhtml`/`srcdoc`). The compiler, protocol validator, and server serializer enforce the same predicate with their own failure strategies; every path delegates to the single implementation, so the boundary cannot diverge.
packages/element/src/internal/core/security.ts:67判断字符串是否符合 HTML 自定义元素的标签名规则。
(tagName: string): boolean英文源码说明
Check if a tag name is a valid custom element name per HTML spec.
packages/element/src/internal/core/tag-utils.ts:38为路由选择内置布局、指定自定义布局及其模块和属性,或关闭布局。
LayoutConfig英文源码说明
Layout declaration: `false` disables the layout entirely, `'default'` uses the built-in layout, and the object form names a tag with the module path that defines it (`import`, resolved like a {@link FrameworkOptions.middleware.use } entry) plus the compiled layout properties the router injects per route.
packages/protocol/src/framework.ts:96为页面路由获取数据的 loader。
Loader<T, Env, Platform, Route>英文源码说明
Route loader: fetches data for a page route.
packages/protocol/src/data.ts:56传给动态路由 loader 的请求上下文。
LoaderContext<Env, Platform, Route>英文源码说明
Context passed to a request-time ('dynamic') route loader.
packages/protocol/src/data.ts:40随语言解析的路径契约。
LocalePath英文源码说明
Locale-aware resolved path contract.
packages/protocol/src/framework.ts:82带标签的控制台日志接口。
Logger英文源码说明
logger.ts - Tagged console logger. Lightweight scoped logger. Returns plain functions so it is tree-shakable and has zero class overhead.
packages/element/src/internal/core/logger.ts:10生成的服务端入口对 POST action 请求体施加的字节上限。需要上传更大文件时,可使用配置了明确上限的 API 路由。
number英文源码说明
Request-body bound (bytes) the generated entry applies to action POST routes; larger uploads belong on API routes with explicit limits.
packages/protocol/src/policy.ts:57renderToString 允许展开的嵌套元素层数,避免循环组合导致无穷递归。
8英文源码说明
Nested element expansion depth bound for `renderToString`: cyclic component composition fails closed instead of recursing without end.
packages/protocol/src/policy.ts:51基于标准 Request 和 Response 的洋葱式中间件。可直接返回响应,也可在 next() 返回后处理响应。
Middleware英文源码说明
Fetch middleware contract (#858): WinterCG shape, dialect-free — no Hono/h3 context object. Composed at the handler boundary in onion order (`use[0]` is outermost: it sees the request first and the response last), so it runs with identical semantics in the dev server, the `start` CLI, the e2e fixture server, and the Nitro production entry. A middleware may short-circuit by returning a Response without calling `next()`, or post-process the Response that `next()` returns. Module contract: a Middleware is the DEFAULT EXPORT of a module referenced from `middleware.use` by path (e.g. './app/middleware/auth.ts'). The generated server entry imports the module, so the middleware may close over module scope and import local helpers and third-party packages — it is a real module in the server module graph, never serialized source.
packages/protocol/src/framework.ts:169生成的自定义元素每次连接时运行回调,包括重新连接。若回调返回清理函数,元素断开时会调用它。
(callback: (env: { readonly host: HTMLElement; readonly signal: AbortSignal; readonly states: CustomStateSet; }) => void | (() => void)): void英文源码说明
Compiler-recognized connect intrinsic: runs the callback on every connection of the generated element (initial mount and each reconnect) and releases the optional returned cleanup at that disconnection. Erased by the compiler; calling it at runtime fails closed. The callback may keep the original zero-argument form or declare ONE `env` parameter. `env.host` is the generated element the connection belongs to (for a depth-1 retained hostless child: its nearest ancestor generated element), and `env.signal` aborts at the START of that disconnection, before any registered cleanup runs; a reconnect gets a fresh, un-aborted signal. The parameter's type is the author-facing contract only — the compiler erases it and passes the value from the connection scope the callback runs in.
packages/element/src/internal/core/compile-lifecycle.ts:58在生成的元素实例最终销毁时运行一次回调,调用顺序在该连接的清理函数之后。
(callback: (env: { readonly host: HTMLElement; readonly signal: AbortSignal; readonly states: CustomStateSet; }) => void): void英文源码说明
Compiler-recognized dispose intrinsic: runs the callback exactly once when the generated element instance is torn down (explicit `dispose()`), after that connection's connect-cleanups. Erased by the compiler; calling it at runtime fails closed. The callback may keep the original zero-argument form or declare ONE `env` parameter whose `signal` is the instance-lifetime teardown signal: it is aborted at the start of teardown, before this and every other disposal callback runs, so `env.signal.aborted` is `true` inside the callback.
packages/element/src/internal/core/compile-lifecycle.ts:80处理当前生成元素在连接、接管服务端标记、更新或处理 DOM 事件时抛出的同步错误。
(callback: (env: { readonly host: HTMLElement; readonly signal: AbortSignal; readonly states: CustomStateSet; readonly error: unknown; }) => void): void英文源码说明
Compiler-recognized error intrinsic (`16b-EB`): the author-facing error boundary of ONE generated element. The callback runs when a value escapes from the element's own work — the connect/claim pass (mount, claim, setup and the `onConnect` replay) and an UPDATE-phase write (a tracked slot refresh or a DOM event handler dispatched inside the compiled body). Erased by the compiler; calling it at runtime fails closed. `env.host` is the generated element the failing work belongs to (the nearest ancestor generated element for a depth-1 retained hostless child), `env.signal` is the per-connection `LifetimeScope` signal for a connect-phase failure and the instance-lifetime teardown signal otherwise, `env.states` is the element's `CustomStateSet`, and `env.error` is the thrown value EXACTLY as it was thrown (never wrapped or replaced). The callback may keep the zero-argument form. A catching handler changes only whether the error escapes: a connect-phase failure still leaves the element in its defined post-failure state (no projection, no listeners, a later reconnect retries from scratch), and an update-phase failure leaves the previously written DOM in place with the subscription still live for the next write. A handler that itself throws REPLACES the original error — that new throw is what surfaces. With no registered handler the pre-existing rethrow/rollback behaviour is unchanged. The callback is CLIENT-owned: it is erased into the compiled module and never runs during `__ssr` (a server render has no element, no connection scope and no handler registry; a producer throw fails the render, exactly as before).
packages/element/src/internal/core/compile-lifecycle.ts:144元素的已声明属性写入新值后运行回调,包括 attribute 和 property 写入。
(callback: (event: { readonly host: HTMLElement; readonly signal: AbortSignal; readonly states: CustomStateSet; readonly name: string; readonly value: unknown; }) => void): void英文源码说明
Compiler-recognized change intrinsic: runs the callback after a DECLARED property of this generated element commits a new value, for an attribute write and for a property write, and never at setup. Erased by the compiler — the callback is registered on the element-lifetime instance owner through the compiler-private host record; calling it at runtime fails closed. `event.host` is the generated element (the nearest ancestor generated element for a depth-1 retained hostless child), `event.signal` is the instance-lifetime teardown signal, and `event.name`/`event.value` are the changed row and its committed value. The callback may keep the zero-argument form.
packages/element/src/internal/core/compile-lifecycle.ts:103自定义元素声明中记录的一个 attribute。
OpenElementAttribute英文源码说明
One documented attribute of a custom element declaration.
packages/protocol/src/manifest.ts:15自定义元素声明中记录的一个 CSS part。
OpenElementCssPart英文源码说明
One documented CSS part of a custom element declaration.
packages/protocol/src/manifest.ts:38包清单中的自定义元素声明,包括标签名、成员和交付信息。
OpenElementDeclaration英文源码说明
One custom element declaration in a package manifest: tag, members and delivery metadata.
packages/protocol/src/manifest.ts:116框架错误,提供稳定错误码、严重程度、发生阶段和可恢复性。
class OpenElementError extends Error英文源码说明
Framework error carrying a stable code, severity, phase and recoverability contract.
packages/protocol/src/errors.ts:100自定义元素声明中记录的一个自定义事件。
OpenElementEvent英文源码说明
One documented custom event of a custom element declaration.
packages/protocol/src/manifest.ts:25包级组件清单,记录其中声明的组件。
OpenElementPackageManifest英文源码说明
Package manifest of component declarations (not a Custom Elements Manifest).
packages/protocol/src/manifest.ts:129应用与构建驱动共享的路由类别。
OpenElementRouteKind英文源码说明
Host-agnostic route and asset contracts shared by app and build drivers.
packages/protocol/src/app-model.ts:2路由树节点,记录匹配路径、路由类型、源码与模块路径、可选的标签和参数,以及子路由。
OpenElementRouteNode英文源码说明
One node of the host-agnostic route tree: the matched URL `path` and route kind, the source and module paths the drivers resolve, the optional registered tag and param names, and the nested `children`.
packages/protocol/src/app-model.ts:9自定义元素声明中记录的一个插槽。
OpenElementSlot英文源码说明
One documented slot of a custom element declaration.
packages/protocol/src/manifest.ts:32RFC 9457 Problem Details 错误响应使用的媒体类型。
"application/problem+json"英文源码说明
Media type of the RFC 9457 action error channel (#863).
packages/protocol/src/data.ts:117表单 action 的协议错误使用的 RFC 9457 文档,按 application/problem+json 返回。detail 提供具体错误说明。
ProblemDetails英文源码说明
RFC 9457 Problem Details document (#863): the action error channel answers `application/problem+json` instead of the bespoke `{ type: 'error', error: { message } }` JSON, so HTTP tooling recognizes failures natively. With `type: 'about:blank'`, `title` is the HTTP reason phrase and `detail` carries the specific explanation. The wire shape is alpha-unfrozen; the 1.0 acceptance freezes it in this problem+json form.
packages/protocol/src/data.ts:105提供普通的协议上下文值。用于提供值的 Signal 仍由 openElement 内部持有。
<T>(host: HTMLElement, context: Context<T>, value: T): Unsubscribe英文源码说明
Provide a plain protocol value; the provider Signal remains OE-private. The returned handle owns exactly one provider record. A repeated call for the same host and {@linkcode Context.key} disposes the previous record (its request listener and mapping) before publishing the replacement, so repeated provides and reconnect cycles never accumulate listeners; the replaced handle becomes a no-op. Releasing removes only the current record and is idempotent.
packages/element/src/internal/core/signal-context.ts:131computed 等派生值使用的只读信号接口。
ReadonlySignal<T>英文源码说明
Read-only signal protocol used by computed values.
packages/protocol/src/signal.ts:26为组件内的一个原生 DOM 节点创建可复用句柄。通过 JSX 的 ref 属性设置,current 随节点连接和断开更新。
<T extends globalThis.Element = Element>(callback?: (element: T | null) => void | (() => void)): { (element: globalThis.Element | null): void; readonly current: T | null; }英文源码说明
Compiler-recognized node-handle factory (`16b-REF`): declares a REF HANDLE for one intrinsic DOM node of this component. The returned value is handed to that node's existing JSX `ref` attribute: ```tsx const field = ref<HTMLInputElement>((element) => { element?.focus(); return () => {/* detach cleanup *\/}; }); // … return <input ref={field} />; ``` The handle is the same object for the whole element lifetime: the compiler erases this call into the retained instance factory, so a reconnect, a claim of server DOM and an update all observe one handle rather than a per-pass copy. It is a REF CHANNEL VALUE, not a reactive source: `current` is written when the node attaches, cleared when it detaches, and it notifies nothing — a tracked slot reading `current` would be a one-shot value, which is why the compiler admits a handle ONLY in a `ref` attribute expression. The optional callback is the attach/detach notification the existing `ref` channel already defines: called with the element on attach, and with `null` on detach AFTER the cleanup it returned has run. Because the handle rides the same `ref` channel, the cleanup ordering, the once-per-detach rule and the scope ownership are the existing ones — this intrinsic adds no second attachment mechanism. Erased by the compiler; calling it at runtime fails closed.
packages/element/src/internal/core/compile-lifecycle.ts:187释放某次带宿主的 consumeContext 创建的提供者订阅。
(signalValue: SignalLike<unknown>): void英文源码说明
Release the provider bridge created by one hosted {@linkcode consumeContext} call. The bridge is deregistered only AFTER its cleanup returns: a throwing unsubscribe must not leave the signal in a state where the bridge is gone from the bookkeeping but still attached to the provider (unretryable). If cleanup throws, the entry stays registered and the error propagates verbatim, so the caller can retry the release — for example from a `disconnectedCallback` that runs again — once the provider's unsubscribe succeeds. A second call after a successful release is a no-op, and a signal without a bridge (including a signal created without a `host`) is always a no-op.
packages/element/src/internal/core/signal-context.ts:208可恢复的渲染错误,携带出错组件的文件路径与标签名。
class RenderError extends OpenElementError英文源码说明
Recoverable render-phase error carrying the failing component path and tag.
packages/element/src/internal/core/errors.ts:95在服务端渲染一个已编译的元素,直接返回序列化后的声明式 Shadow DOM HTML。
(input: string | CustomElementConstructor, options?: RenderToStringOptions): string英文源码说明
Server-render one compiled element through canonical Element composition: returns the serialized DSD `html` string directly.
packages/element/src/public-runtime.ts:945一次 renderToString 调用的选项,包括组件类、属性值、诊断上下文、可渲染的嵌套标签和插槽内容。
RenderToStringOptions英文源码说明
Options for one `renderToString()` call: the compiled component class to serialize, the values projected onto its compiled properties, optional route/source diagnostics metadata, the nested compiled tags the build admitted, and trusted parent-owned light children keyed by slot name.
packages/element/src/public-runtime.ts:170将框架错误交给遥测钩子,无钩子时写入 console.error。
(error: OpenElementError): void英文源码说明
Report an {@linkcode OpenElementError} to the telemetry hook, or console.error when none is installed.
packages/element/src/internal/core/errors.ts:139扫描后入选的路由,记录 URL 路径、源文件、类型、生成入口使用的变量名和可选注册标签。
RouteEntry英文源码说明
One route admitted by the scanner: URL `path`, source `filePath`, the route `type`, the generated variable name (`varName`) the entry binds it to, and the optional registration tag. {@link RouteEntry.definePage} and {@link RouteEntry.hasEnhancedForms} carry the two source-derived admission facts the generated entries branch on.
packages/protocol/src/framework.ts:113请求时渲染和静态站点生成共用的服务端路由上下文。
ServerRouteContext<Env, Platform, Route>英文源码说明
Canonical request-time/SSG server route context.
packages/protocol/src/data.ts:25动态路由 loader 接收的服务端上下文,包括标准请求、路由参数、宿主环境和平台对象。
ServerRouteMetadata英文源码说明
Context passed to a request-time ('dynamic') route loader. This is the server contract: the loader runs on the server with the Web-standard request, matched route params, the host environment and the platform object, and signals validation failure via fail()/redirect().
packages/protocol/src/data.ts:19安装或替换整个进程使用的错误遥测钩子。
(hook: ErrorTelemetryHook): void英文源码说明
Install the process-wide error telemetry hook (replaceable for tests, HMR, multi-app pages).
packages/element/src/internal/core/errors.ts:127创建可读写的响应式状态。
<T>(initialValue: T): WritableSignal<T>英文源码说明
Create a writable signal through the selected signal engine.
packages/element/src/internal/signal/framework.ts:19接受可写信号或只读信号的 API 所用类型。
Signal<T>英文源码说明
Alias for APIs that accept either writable or read-only signals.
packages/protocol/src/signal.ts:31路由扫描器按文件名识别的特殊类型,包括 renderer 和 middleware。
SpecialFileType英文源码说明
Special file kinds the route scanner recognizes by filename: `renderer` and `middleware`.
packages/protocol/src/framework.ts:79构建对自定义元素的 SSR 判定,记录模块路径、发现来源、渲染方式及原因。
SsrAdmissionDecision英文源码说明
The build's admission verdict for one discovered tag: where the declaration lives (`modulePath`), how it was discovered (`source`), which render path it is admitted to, and the reason recorded for the manifest.
packages/protocol/src/render.ts:37浏览器拒绝装入所属 Part 范围的流式片段所禁用的标签。
readonly ["script", "style", "template", "iframe", "object", "embed", "base", "meta", "link"]英文源码说明
Tags a deferred frame cannot safely install into an owned Part range: the browser installer rejects any frame whose markup carries one of these.
packages/protocol/src/stream-frame-policy.ts:26流式片段的 URL 属性不可使用的协议。
RegExp英文源码说明
Schemes that make a URL attribute unsafe in a streamed frame.
packages/protocol/src/stream-frame-policy.ts:60流式片段中需要检查 URL 协议的属性名。
readonly ["href", "src", "action", "formaction", "xlink:href"]英文源码说明
URL-carrying attributes the frame check screens for script-bearing scheme obfuscation; only these attribute names are value-screened.
packages/protocol/src/stream-frame-policy.ts:42检查 URL 协议前,会移除码点低于或等于此值的控制字符。
32英文源码说明
Control characters at or below this code point are stripped before the URL-scheme test, so tab/newline/control obfuscation cannot smuggle a scheme past admission.
packages/protocol/src/stream-frame-policy.ts:55一个流式路由允许在清单中声明的延迟字段数上限。
32英文源码说明
Deferred fields (declared streamed properties) one stream route's manifest may carry. The build scan, the server executor, and the browser seed contract enforce the same bound.
packages/protocol/src/policy.ts:24一个流式路由清单可以引用的 Part 和 Block 所有者数量上限。
64英文源码说明
Part/Block owners one stream route's manifest may address in total across all deferred fields.
packages/protocol/src/policy.ts:30流式载荷的最大序列化长度,以 UTF-16 码元计。
number英文源码说明
Serialized stream payload bound, as a string length in UTF-16 code units: one seed attribute or one deferred frame's markup may not exceed it. The server checks the JSON text and the rendered range before emitting; the browser checks the attribute before parsing.
packages/protocol/src/policy.ts:45流式 hydration 初始数据可携带的带类型属性数量上限。
64英文源码说明
Typed properties one streamed seed may carry: the browser seed contract rejects the WHOLE seed above this count, so an oversized component would silently fail to hydrate instead of failing loud at the server.
packages/protocol/src/policy.ts:37流式响应等待延迟字段完成的时间上限(毫秒)。
30000英文源码说明
Deferred-field resolution budget (milliseconds) for one streamed response: fields still pending when it expires are failed in place and the stream ends with the shell and whatever resolved.
packages/protocol/src/policy.ts:64可跨执行环境使用的样式表构造器,按环境选择原生 CSSStyleSheet 或兼容实现。
new () => StyleSheetLike英文源码说明
Cross-realm StyleSheet constructor: the native CSSStyleSheet or the internal shim.
packages/element/src/internal/core/style-sheet.ts:110原生样式表与兼容实现共用的最小接口,包括 replaceSync 和 cssRules。
StyleSheetLike英文源码说明
Minimal stylesheet contract (replaceSync + cssRules) satisfied by native and shim sheets.
packages/protocol/src/style-sheet.ts:14将 HTML 字符串标记为可信,以便显式传给 innerHTML。序列化时不会保留可信标记。
(html: string): TrustedHtml英文源码说明
Mark an HTML string as trusted for explicit `innerHTML` sinks (the trust does not serialize).
packages/element/src/internal/core/security.ts:88标识应用已明确审查并信任的 HTML。
TrustedHtml英文源码说明
Opaque capability marking HTML the application has explicitly vetted as trusted.
packages/element/src/internal/core/security.ts:83判断 Part Program 中的静态属性是否会使流式片段无法通过安装校验。
(name: string, value: string): boolean英文源码说明
Whether a static attribute (name/value as authored into the Part Program) makes a streamed frame unsafely installable: event-handler, seed-spoofing, and srcdoc names fail outright, and URL-carrying names fail when the entity-decoded, control-stripped value carries a script scheme.
packages/protocol/src/stream-frame-policy.ts:113订阅最近提供者的上下文,返回由实例持有的信号。没有提供者时读到令牌的默认值。
<T>(context: { readonly key: symbol; readonly defaultValue: T; }): { readonly value: T; subscribe(fn: (value: T) => void): () => void; }英文源码说明
Compiler-recognized CONSUMER intrinsic (`16b-CTX`): declares a tracked consumer of `context` for this component and returns the signal its value lives in. ```tsx const theme = useContext(ThemeContext); return <p>{theme.value}</p>; // a tracked slot: refreshes on provider change ``` The returned signal is ONE persistent consumer-local signal: the compiler erases this call into the component's retained setup record, so a reconnect re-reads the nearest provider into the SAME object and a tracked slot keeps exactly one subscription target for the whole element lifetime. Lookup follows the nearest owning component, so an inner provider shadows an outer one and a component with no ancestor provider reads the context's declared default. Reading `.value` in a tracked slot is the supported use — this is the lane's reactive channel, unlike `ref`'s `current`. Reading it inside a handler also works (the signal is live), but only tracked slots refresh. Erased by the compiler; calling it at runtime fails closed.
packages/element/src/internal/core/compile-lifecycle.ts:285获取当前组件所在的自定义元素。用于在组件中访问宿主节点。
(): HTMLElement英文源码说明
Compiler-recognized HOST-ACCESS intrinsic (`16b-REF`, `useHost`). ```tsx const host = useHost(); // … host is this instance's owning element (the custom element). ``` It exposes the SAME fact the lifecycle/change/error callbacks already receive as `env.host` — the owning generated element for a root, the nearest enclosing generated element host for a depth-1 retained hostless child — through the expression position instead of a callback parameter. There is therefore no new runtime channel and no second host lookup: the compiler erases the call into a read of the host-element field the retained setup factory already receives. The read is NOT reactive: the element identity never changes for an instance, so a derived node capturing it can never go stale. That is also why it carries no lifecycle ownership — it allocates nothing and needs no cleanup. Erased by the compiler; calling it at runtime fails closed.
packages/element/src/internal/core/compile-lifecycle.ts:218为渲染后的 HTML 补上文档类型、head 和 body,支持 CSP nonce 与开发脚本。
(html: string, options?: DocumentWrapOptions): string英文源码说明
Wrap rendered HTML in a full HTML document. Adds DOCTYPE, head (title, meta, preload), and body. Supports CSP nonce and dev scripts (e.g. Vite client, route module registration).
packages/element/src/internal/core/html-escape.ts:199(tag: string, attrs?: Record<string, unknown>, children?: readonly unknown[]): string英文源码说明
Construct one element's HTML. `attrs` values are the wire truth: `true` emits a bare attribute, `false`/`null`/`undefined` omit it, arrays and records coerce for `class`/`style` exactly like the serializer, and every other value is attribute-escaped through `escapeAttr`. The reserved `innerHTML` key is the trusted-HTML sink: its value must carry the trustedHtml brand and becomes the element's content (children must be empty — the compiler's shared walk already enforces that shape). `children` are FINAL HTML strings (static text is escaped at compile time, dynamic text arrives through `__t`, nested components through `__ssr` or a direct compiled call).
packages/element/src/server.ts:170为当前服务端进程注入允许渲染的嵌套宿主标签。
(tags: readonly string[] | null | undefined): void英文源码说明
Inject the renderable nested-host tags for this server process.
packages/element/src/server.ts:271序列化一个已获准渲染的组件的服务端标记。
(tag: string, props?: Record<string, unknown>, sourceInfo?: SsrSourceInfo, composition?: SsrComposition): string英文源码说明
Serialize one admitted component's server markup. A generated element's producer is a string builder, so a nested host inside its markup reaches its own producer only through the render's nested-host expander. A class page used to receive that expander from `renderToString`; a SERVER FUNCTION PAGE's compiled `render` calls this function directly, so the expander travels through the module-level set above instead (F16).
packages/element/src/server.ts:284转义一个动态文本值,使其可安全写入服务端函数组件的输出。
(value: unknown): string英文源码说明
Escape one dynamic text value (the ONLY channel untrusted text may take into a server function component's output). Coercion matches the serializer's text-Part pipeline exactly: displayValue, then the ONE `escapeText`. A thenable is refused before coercion: a `Promise<...>`-annotated prop read at a text sink is already a located compile error (M14-2), and this guard is the untyped backstop for every read the compiler cannot see (an `any` prop). `{await props.p}` settles the value first and never reaches this branch.
packages/element/src/server.ts:143↑ ↓ 选择 · Tab 查看 · Esc 返回
@openelement/compiler
46 个导出解析模块源码,提取编译器和 Vite 模块图适配器所需的语义信息。
(source: string, fileName: string, options?: ModuleSemanticsOptions): ModuleSemanticFacts英文源码说明
Parse one module source and report the semantic facts the compiler boundary and the Vite graph adapters branch on. Pure: it never resolves imports from disk and never throws on foreign or invalid syntax — an unparsable module simply yields no recognized facts. The scan's factory vocabulary is host-injected: the default knows only the element package's own registration factories, and page-definition/registration facts for other packages require the caller's {@link ModuleSemanticsOptions.vocabulary} descriptors.
packages/compiler/src/internal/compiler/semantic-core/module-analysis.ts:562保存某次构建或开发服务器发现的样式类名候选项,供该构建的样式输出读取。
ClassCandidateRegistry英文源码说明
One owner's class-candidate facts: the build (or dev server) that created it is the only writer, its stylesheet emitter the only reader.
packages/compiler/src/internal/compiler/tailwind-candidates.ts:55在开始新一轮构建前直接清空已记录的诊断。
(): void英文源码说明
Clear without reading — the hygiene a fresh build invocation starts with.
packages/compiler/src/internal/compiler/semantic-core/diagnostics/index.ts:152从样式注册表清除所有依赖记录,结束本轮构建的记录周期。
(): void英文源码说明
Drop every registered edge (a build's bookkeeping is its own lifetime).
packages/compiler/src/internal/compiler/style-requests.ts:93读取已编译模块记录的样式类名候选项。模块未记录候选项时返回 undefined。
(source: string, fileName: string): readonly string[] | undefined英文源码说明
The admitted class candidates of one compiled artifact module, or undefined when the module does not carry the emitted fact. Generated elements carry a build-only footer, and compiled classes carry their literal static member.
packages/compiler/src/internal/compiler/compiled-artifact-class-candidates.ts:50按源码中的顺序恢复已编译模块的 .css 依赖关系。模块形态不适用时返回 undefined。
(source: string, fileName: string): readonly string[] | undefined英文源码说明
The `.css` style edges of one compiled artifact module, in authored order — or undefined when the module is not a shape this recovery adopts. Never throws and never guesses: a module without the Part Program marker, without a `.css` specifier, without an arrayed `static styles`, or with a sheet import no class arrays is left entirely to the graph's normal channels, exactly as before this recovery existed. Adoption is all-or-nothing per module, so it can never turn a working module into a fail-closed intercept while half its edges stay unregistered. The read tolerates both artifact forms the pack pipeline produces: the compiler's raw emission (TypeScript syntax, e.g. a `type`-annotated styles member) and the packed module (types stripped by the packer). The AST parse is ScriptKind.TSX for exactly that reason — a diagnostics gate on the file extension would refuse the raw form and silently drop its edges.
packages/compiler/src/internal/compiler/compiled-artifact-style-requests.ts:106Vite 插件和编译器测试使用的错误结构。
class CompiledElementError extends CompilerDiagnosticError英文源码说明
Error shape consumed by the Vite plugin and compiler tests.
packages/compiler/src/internal/compiler/semantic-core/compiler-diagnostics.ts:20(options?: CompiledElementPluginOptions): Plugin英文源码说明
The `open:compiled-element` Vite plugin: runs at `enforce: 'pre'` so the compiler sees authored TSX before Vite's own TS/JSX lowering, compiles every module one of the two admission lanes owns, and leaves all other modules untouched. `workspaceRoot` anchors generated source-map ids for linked workspace packages. The generated-element site option is a host capability (M09-1b): hosts that resolve islands before the compiler transform supply the tag fact; hosts that do not (a plain standalone build) omit it and the lane stays inert.
packages/compiler/src/internal/compiler/plugin.ts:199宿主已为模块声明编译条件时,将该模块编译成原生自定义元素。
(code: string, id: string, options: CompileGeneratedElementOptions): CompiledGeneratedElement | null英文源码说明
Compile one module through the generated native element lane when — and only when — the host supplied a site fact for it. Admission order (design §4.2): site fact → class-lane ownership → syntactic default-export/sidecar admission (the root and focus facts and the property table included: the lane reads them from the sidecar, D-root-source / D-delegatesFocus / D-props) → props parameter/type cross-check → leaf generation → bindings requirement. The final emitter step is append-only over the leaf text, so every refusal happens before a half-built module can be returned.
packages/compiler/src/internal/compiler/semantic-ir/generated-element/compile.ts:154将结构化编译诊断转换为协议的 DiagnosticEnvelope。
(diagnostics: ReadonlyArray<ProjectableCompilerDiagnostic>): DiagnosticEnvelope[]英文源码说明
Project the compiler's already-structured diagnostics onto the protocol's {@linkcode DiagnosticEnvelope} shape. An empty list projects to an empty list — the caller keeps its own fallback rather than inventing a record.
packages/compiler/src/internal/compiler/semantic-core/diagnostics/index.ts:111(code: string, id: string, options?: ServerComponentCompileOptions): CompileServerComponentResult | null英文源码说明
The host-build admission bridge: compile `code` through the server function component lane when — and only when — this module belongs to it. - a module carrying a compiled-element decorator (or an unsupported decorator spelling, which the class lane compiles so it fails closed with OEC9027) belongs to the class lane: null; - a module with no admitted server function component and no near-miss exported JSX function has nothing to admit: null; - a near-miss (statements before the return, a block-bodied arrow, or any other exported function/arrow whose body contains JSX but is not the single-return shape) is NOT null: it goes through {@link compileServerComponentModule}, which fails closed with OEC9032. Returning null would hand the authored module to another lane unchanged; - a plain script id never carries the JSX grammar: null; - the cheap `export` + `<` prefilter (the same conservative superset idea the class lane's prefilter uses) keeps plainly inert modules off the parse. A module that does not parse stays null so the host reports the syntax error. Everything else goes through {@link compileServerComponentModule}, whose diagnostics fail the build closed.
packages/compiler/src/internal/compiler/semantic-core/server-component.ts:701将一个 TSX 模块中的服务端函数组件编译为用于生成 HTML 的构造模块。
(source: string, fileName: string, options?: ServerComponentCompileOptions): CompileServerComponentResult | null英文源码说明
Compile one authored TSX module's server function components into the generative constructor module. Returns null for modules with no exported JSX-returning function (nothing to admit). Fails closed with a {@link CompiledElementError} carrying the ordered OEC diagnostics.
packages/compiler/src/internal/compiler/semantic-core/server-component.ts:423服务端函数组件模块的编译结果。
CompileServerComponentResult英文源码说明
The compiled server function component module.
packages/compiler/src/internal/compiler/semantic-core/server-component.ts:93创建供一次构建或一个开发服务器使用的样式类名候选注册表。
(): ClassCandidateRegistry英文源码说明
Create one owner's registry (see the lifetime note above).
packages/compiler/src/internal/compiler/tailwind-candidates.ts:87将编译器诊断转换为构建适配器的错误结构。
(diagnostics: CompilerDiagnostic[], source: string, id: string): PluginDiagnosticError | null英文源码说明
Project compiler diagnostics onto the adapter's error shape. Returns null for an empty diagnostics list: there is nothing to locate or render, and the caller keeps its own fallback rather than inventing a location.
packages/compiler/src/internal/compiler/semantic-core/diagnostics/index.ts:209包含稳定 OEC 错误码、消息和源码范围的编译器诊断。
ElementCompilerDiagnostic英文源码说明
A source-aware compiler diagnostic: stable OEC code, message and source range.
packages/compiler/src/internal/compiler/semantic-core/compiler-diagnostics.ts:17EmittedModuleDiagnostic英文源码说明
One diagnostic the type checker produced for the emitted module. `file` is the virtual module id the check was given; the remaining fields locate the range inside the EMITTED text.
packages/compiler/src/internal/compiler/semantic-core/type-check.ts:37指定输出模块如何解析导入项,以及类型检查时添加的虚拟文件。
EmittedModuleTypeCheckOptions英文源码说明
How the emitted module's imports resolve, and any virtual files to add.
packages/compiler/src/internal/compiler/semantic-core/type-check.ts:46输出模块通过类型检查时返回 true。
(code: string, fileName: string, options?: EmittedModuleTypeCheckOptions): boolean英文源码说明
`true` when the emitted module type-checks. The boolean form exists so a caller that only needs a verdict does not destructure an empty array; the diagnostics form is for callers that must report what failed.
packages/compiler/src/internal/compiler/semantic-core/type-check.ts:178宿主提供的模块信息,据此决定是否用生成式元素编译流程。
GeneratedElementSite英文源码说明
The host-supplied fact that admits one module to the generated-element lane. It is an internal compiler option value, never author syntax: the router derives it from the island path (M09-1b) and the compiler cannot derive it itself because the island transform runs after this compiler plugin. The fact carries the TAG only. The root used to ride here too; D-root-source (2026-11-13) moved it to the compiler lane's own read of the authored sidecar (`site.ts` `readIslandRoot`), so one stale host scan can no longer pin a root that the source no longer declares.
packages/compiler/src/internal/compiler/semantic-ir/generated-element/contract.ts:93按已解析的样式表模块 ID 查找注册记录。
(moduleId: string): RegisteredStyleRequest | undefined英文源码说明
The edge a resolved sheet module id carries, if any.
packages/compiler/src/internal/compiler/style-requests.ts:65判断导入模块是否已注册样式依赖,忽略查询后缀。
(importerId: string): boolean英文源码说明
True when the importing module has registered edges (query suffixes ignored).
packages/compiler/src/internal/compiler/style-requests.ts:70忽略查询后缀,判断模块 ID 是否指向 .jsx 或 .tsx 文件。
(id: string): boolean英文源码说明
Whether an authored module id has a JSX-bearing source extension.
packages/compiler/src/internal/compiler/semantic-core/jsx-module-id.ts:2ModuleSemanticFacts英文源码说明
The bundler-neutral facts one module source yields: its relative imports, the intrinsic bindings it admits ({@link ModuleSemanticFacts.compiledElementDecorator}, {@link ModuleSemanticFacts.exportedTagName}, custom-element tags it defines or references) and the interaction-event names its handlers bind. The Vite graph adapter branches on these without re-parsing the AST.
packages/compiler/src/internal/compiler/semantic-core/module-analysis.ts:14宿主为模块扫描提供的识别规则扩展。
ModuleSemanticsOptions英文源码说明
Host-supplied vocabulary extensions for the module scan.
packages/compiler/src/internal/compiler/semantic-core/module-analysis.ts:147描述模块扫描识别的导出绑定,以及调用该绑定时登记的事实。
ModuleVocabularyDescriptor英文源码说明
One module-scan vocabulary entry the host admits: a binding identity (module specifier + exported name, aliases followed) plus the fact a canonical call of that binding contributes. Plain data — the scan consumes the descriptors without learning the caller's package vocabulary, the same direction as the compiler's {@link StaticSidecarDescriptor} admission (#1473 item 3).
packages/protocol/src/module-descriptors.ts:33Vite 适配层发出的 Rollup 兼容错误结构。
PluginDiagnosticError英文源码说明
Rollup-compatible error shape emitted by the Vite adapter boundary.
packages/compiler/src/internal/compiler/semantic-core/diagnostics/index.ts:167解析用作服务端组件标签的具名导入,并返回供编译器同步查询的函数。
(source: string, fileName: string, resolve: (specifier: string) => string | ResolvedServerComponentSource | undefined | Promise<string | ResolvedServerComponentSource | undefined>): Promise<ServerComponentCompileOptions…英文源码说明
Resolve the compiler's static source candidates through an asynchronous host.
packages/compiler/src/internal/compiler/semantic-core/server-component.ts:357一次读取已编译模块记录的样式依赖和根节点作用域。
(source: string, fileName: string): CompiledArtifactStyleRead | undefined英文源码说明
The same recovery, read once for both facts an artifact states: its edges and its root scope (alpha15 S lane, S-C1.2). The scope comes from the module's own Part Program literal — the emitter writes it verbatim, so the packed form needs no second source of truth and no assumption about which root kind a shipped package used.
packages/compiler/src/internal/compiler/compiled-artifact-style-requests.ts:120记录一次编译失败的结构化诊断,供构建退出时读取。
(diagnostics: ReadonlyArray<ProjectableCompilerDiagnostic>): void英文源码说明
Record one compile failure's envelopes for the build exit (#1612).
packages/compiler/src/internal/compiler/semantic-core/diagnostics/index.ts:138一个已注册样式导入在构建模块图中的定位信息。
RegisteredStyleRequest英文源码说明
One registered style edge: the authored import's build-graph coordinates.
packages/compiler/src/internal/compiler/style-requests.ts:21把一个模块的样式依赖写入注册表。
(id: string, specifiers: readonly string[], scopeTag: string | undefined): void英文源码说明
Register one module's style edges (the registry's one write path, S-C1.4). The importing component's root scope is part of every edge it registers (alpha15 S lane, S-C1.2): a light-root component's sheets leave the build wrapped in `@scope (<tag>)`, so the tag travels to the intercept through the registry key. A shipped artifact states the same fact in its Part Program literal. The Vite transform is the caller for a module the bundler processes; a build host that admits a module for its ADMISSION FACTS alone (a Page or Layout the server renders and no island imports) calls the same step with the same compiled program — no second writer, no second registry.
packages/compiler/src/internal/compiler/plugin.ts:172按模块 ID 注册一个生成的样式依赖。重新编译会覆盖原记录。
(request: RegisteredStyleRequest): void英文源码说明
Register one generated edge (idempotent per module id — recompiles overwrite).
packages/compiler/src/internal/compiler/style-requests.ts:53包含导入的服务端组件源码和解析后的文件名,编译器据文件名选择解析语法。
ResolvedServerComponentSource英文源码说明
Authored source with the resolved filename that determines its syntax.
packages/compiler/src/internal/compiler/semantic-core/server-component.ts:64宿主为编译器语义核心提供的额外准入规则。
SemanticCoreOptions英文源码说明
Host-supplied admission extensions for the semantic core.
packages/compiler/src/internal/compiler/semantic-core/module-analysis.ts:137宿主传给服务端函数组件编译过程的输入。
ServerComponentCompileOptions英文源码说明
Host-supplied inputs for the server function component compile.
packages/compiler/src/internal/compiler/semantic-core/server-component.ts:70(file: string, root: string | undefined, workspaceRoot?: string): string英文源码说明
Compile-time source identity for a module: absolute Vite ids are converted to project-relative POSIX paths so Part Program `metadata.sourceFile` and `sourceMap.file` never embed the build machine's path. Module resolution, diagnostics, and HMR keys keep using the caller's own id. Anchors are explicit, never guessed from path substrings (a checkout living under e.g. `/srv/www/` must not fool the cut): the Vite project root first, then the workspace root when the caller knows it (a module outside the project root is typically a linked workspace package). Callers that hand the compiler a path outside every known root (synthetic ids, projects without a Vite root) get the id back unchanged — there is no correct relative form to invent, and the library boundary must not reject paths it cannot anchor. This module stays runtime-neutral: resolving a workspace root from disk is the caller's job.
packages/compiler/src/internal/compiler/plugin.ts:54告诉元素编译器哪一项与组件放在同一模块的声明属于静态策略。
StaticSidecarDescriptor英文源码说明
One static-sidecar descriptor the host injects into the element compiler: the admission granted is a colocated static policy statement (#1473 item 3, the static-sidecar admission pattern).
packages/protocol/src/module-descriptors.ts:16按样式表路径反查所有关联的导入依赖,供开发时热更新使用。
(file: string): RegisteredStyleRequest[]英文源码说明
Every edge whose sheet file is the given path — the dev HMR reverse lookup.
packages/compiler/src/internal/compiler/style-requests.ts:75将导入模块所在目录与其样式导入路径拼接,得到样式表的绝对路径。
(importerId: string, specifier: string): string英文源码说明
The sheet file's absolute path for one authored edge: the importing module's directory joined with the authored specifier. Relative specifiers only (the compiler refuses bare ones), so the join is total. Parent segments (`../theme.css`) resolve lexically against the directory — the key must be the path the bundler's resolver lands on, never a verbatim `..` id no lookup can match.
packages/compiler/src/internal/compiler/style-requests.ts:148生成样式依赖的注册键,包含已解析的文件路径及可用的 Light DOM 作用域标签。
(importerId: string, specifier: string, scopeTag?: string): string英文源码说明
The registry key for one authored edge: the sheet file's resolved path, plus the importing component's light-root scope tag when it has one. Query suffixes on the importer id (dev-time cache busting) are stripped, so recompiles re-register under one key; the full relative path keeps same-named sheets in sibling subdirectories distinct edges. The scope tag rides the key because the emitted asset is a different resource per scope: a light root's sheet is served wrapped in `@scope (<tag>)`. Registering an edge passes the tag explicitly (the caller is the compile that just proved it); the intercept resolves a `.css` import from `(importer, specifier)` alone, so it reads the same fact back through the importer index. Both paths land on one key for one edge, and a disagreement can only fail closed at the intercept — never emit an unscoped asset.
packages/compiler/src/internal/compiler/style-requests.ts:125返回指定导入模块声明的全部样式依赖。
(importerId: string): RegisteredStyleRequest[]英文源码说明
Every edge one importing module declared. The host build uses it to emit the style resources of modules it admitted for their edges alone (S-C1.4: a Page or Layout the server renders and no island imports).
packages/compiler/src/internal/compiler/style-requests.ts:87读取并清空所有已记录的诊断,确保构建退出时只消费一次。
(): DiagnosticEnvelope[]英文源码说明
Drain the recorded envelopes: the exit reads them exactly once.
packages/compiler/src/internal/compiler/semantic-core/diagnostics/index.ts:145对一个编译后输出的模块执行类型检查。
(code: string, fileName: string, options?: EmittedModuleTypeCheckOptions): EmittedModuleDiagnostic[]英文源码说明
Type-check one emitted compiled module. Returns `[]` when the module type-checks; otherwise every diagnostic the checker reported, in emission order, so a build can print all of them instead of only the first. The `fileName` should be the module's real (virtual) id, not a placeholder: module resolution and `paths` matching both key off it, and the diagnostics quote it back.
packages/compiler/src/internal/compiler/semantic-core/type-check.ts:91校验数据是否符合 Part Program v2,以及指令、所有权记录和路径是否合法。
(raw: unknown): asserts raw is PartProgram英文源码说明
Validate an unknown value as a Part Program v2. The validator is intentionally strict: unknown instruction kinds, missing ownership records and unsafe paths fail before a runtime can guess at their meaning.
packages/protocol/src/part-program.ts:911(options?: CompiledElementPluginOptions): Plugin英文源码说明
The `open:compiled-element` Vite plugin: runs at `enforce: 'pre'` so the compiler sees authored TSX before Vite's own TS/JSX lowering, compiles every module one of the two admission lanes owns, and leaves all other modules untouched. `workspaceRoot` anchors generated source-map ids for linked workspace packages. The generated-element site option is a host capability (M09-1b): hosts that resolve islands before the compiler transform supply the tag fact; hosts that do not (a plain standalone build) omit it and the lane stays inert.
packages/compiler/src/internal/compiler/plugin.ts:199↑ ↓ 选择 · Tab 查看 · Esc 返回
@openelement/router
205 个导出处理页面路由的表单提交。
Action<T, Env, Platform, Route>英文源码说明
Route action: handles form submissions for a page route.
packages/protocol/src/data.ts:64选择表单 action 的响应通道。true 返回序列化结果,enhance 返回与无脚本提交相同的 HTML。
"x-openelement-action"英文源码说明
Request header selecting the action response channel: `true` marks a programmatic caller and selects the serialized ActionResult union; `enhance` marks the built-in morph enhancement and selects the same full-HTML responses the no-JS path receives.
packages/protocol/src/data.ts:125传给路由 action 的上下文,包含 loader 上下文。
ActionContext<Env, Platform, Route>英文源码说明
Context passed to a route action function (extends loader context).
packages/protocol/src/data.ts:47操作的可辨识结果,`success` 携带数据,`failure` 携带 HTTP 状态和数据。
ActionOutcome<Data>英文源码说明
The discriminated result an action returns: `success` carries the action's data; `failure` carries an HTTP status and payload. See ActionResult for the canonical classifier that produces it.
packages/router/src/authoring.ts:213脚本提交表单时返回的联合类型。校验失败返回 failure,成功提交返回 redirect;协议错误使用 ProblemDetails。
ActionResult<Failure>英文源码说明
Wire shape returned to the JavaScript form-enhancement path. The no-JS path never sees this: it gets the equivalent semantics as plain HTTP (303 on success, 422 with the re-rendered form on validation failure, redirect/error as status codes). Success carries no data envelope. The application-loop contract makes a successful non-GET action answer 303 (PRG) — the framework never answers 200 with a rendered page, or with a success document, for a successful mutation — so the fetch channel answers `{ type: 'redirect' }` naming the PRG target and the authored return value is discarded by design. Success data travels the PRG target instead (query state the loader re-runs with, which the props projector then maps; see the router guide's "Form actions" section). The union previously declared a `{ type: 'success' }` member that no code path ever emitted — removed so the type matches the wire. Error outcomes (CSRF 403, unknown action 404, unparseable body 400, unexpected 500) are NOT part of this union: since #863 they answer RFC 9457 Problem Details with the PROBLEM_JSON_MEDIA_TYPE content type — see ProblemDetails.
packages/protocol/src/data.ts:92按应用层的统一规则判断操作返回值是成功还是结构化失败。
<Data>(result: Data): ActionOutcome<Data>英文源码说明
Canonical application-level classification for an action return value. Server and SPA executors project this result differently, but neither may redefine validation failure or admit a raw Response as action data.
packages/router/src/authoring.ts:222当未提供 `dirs` 或各目录没有共同的起始路径段时,用于解析设计令牌、布局和数据的默认目录。
"app"英文源码说明
Default convention base: the directory the tokens/layout/data conventions resolve under when `dirs` is omitted (or has no shared leading segment).
packages/router/src/config.ts:76组件默认目录 `app/components`,也是 `dirs.components` 的默认值。
"app/components"英文源码说明
Default component directory (`app/components`), the `dirs.components` default.
packages/router/src/config.ts:70文档 `<head>` 结构模块的默认约定路径 `app/head.tsx`。
"app/head.tsx"英文源码说明
Convention path for the structural document-head module (`app/head.tsx`).
packages/router/src/config.ts:94文档 `<head>` 结构模块从约定基目录起算的相对路径。
"head.tsx"英文源码说明
Convention-relative suffix of the structural document-head module.
packages/router/src/config.ts:85交互岛默认目录 `app/islands`,也是 `dirs.islands` 的默认值。
"app/islands"英文源码说明
Default island directory (`app/islands`), the `dirs.islands` default.
packages/router/src/config.ts:67自动注册布局的默认约定路径。
"app/layout.tsx"英文源码说明
Convention path for the auto-registered layout.
packages/router/src/config.ts:91自动注册布局从约定基目录起算的相对路径。
"layout.tsx"英文源码说明
Convention-relative suffix of the auto-registered layout.
packages/router/src/config.ts:82自动注册约定布局时使用的元素标签名。
"app-layout"英文源码说明
The tag name the convention layout is registered under.
packages/router/src/config.ts:97约定中用于读取站点标题的文件,标题取自 `package.json` 的 `name` 字段。
"package.json"英文源码说明
The site-title convention source (the package.json `name` field).
packages/router/src/config.ts:100路由默认目录 `app/routes`,也是 `dirs.routes` 的默认值。
"app/routes"英文源码说明
Default route directory (`app/routes`), the `dirs.routes` default.
packages/router/src/config.ts:64设计令牌样式表从约定基目录起算的相对路径。
"styles/tokens.css"英文源码说明
Convention-relative suffix of the design-token stylesheet.
packages/router/src/config.ts:79设计令牌样式表的默认约定路径。
"app/styles/tokens.css"英文源码说明
Convention path for the design-token stylesheet.
packages/router/src/config.ts:88根据已经解析的 `dirs` 计算文档 `<head>` 结构模块的约定路径。
(base: string): string英文源码说明
The structural document-head convention path for a resolved `dirs` block.
packages/router/src/config.ts:699根据已经解析的 `dirs` 计算布局模块的约定路径。
(base: string): string英文源码说明
The layout convention path for a resolved `dirs` block.
packages/router/src/config.ts:694根据已经解析的 `dirs` 计算设计令牌样式表的约定路径。
(base: string): string英文源码说明
The token stylesheet convention path for a resolved `dirs` block.
packages/router/src/config.ts:689从平台请求事件构建统一的 OpenElement 请求上下文。
<Env extends Record<string, unknown> = Record<string, unknown>>(options: CreateRequestContextOptions<Env>): OpenElementRequestContext<Env>英文源码说明
Build the canonical OpenElement request context from a platform request event.
packages/router/src/model.ts:45从平台请求事件构建 `OpenElementRequestContext` 所需的输入。
CreateRequestContextOptions<Env>英文源码说明
Inputs for building an {@linkcode OpenElementRequestContext} from a platform request event.
packages/router/src/model.ts:17原样返回配置对象,同时让 TypeScript 检查其结构。
(config: OpenElementUserConfig): OpenElementUserConfig英文源码说明
`defineConfig()` — identity helper that pins the config file's shape.
packages/router/src/config.ts:290校验并返回组件配置。用它声明自定义元素的标签名、根节点、属性,以及何时在浏览器中启用交互。
(config: IslandConfig): IslandConfig英文源码说明
Validate and register an island delivery descriptor; returns the normalized config.
packages/router/src/authoring.ts:1121为服务端页面函数添加描述符。把函数传给 definePage,并从路由模块默认导出结果。文件名决定 URL。 查看函数重载。
<Data = unknown, Params extends Record<string, string> = Record<string, string>>(componentClass: CustomElementConstructor, descriptor?: PageDescriptorInput<Data, Params>): PageComponentConstructor<Data, Params>英文源码说明
Attach a page descriptor to a compiled page element class. Canonical page authoring: the route module default-exports the compiled class (produced by the open:compiled-element transform) wrapped in definePage(). The descriptor holds head/route/renderIntent metadata plus the optional props/error projectors; it must NOT create classes or hold a render function — the compiled class's Part Program is the render. import { definePage } from '@openelement/router'; import { HomePage } from '../components/page-home.tsx'; export const loader = async (ctx) => ({ ... }); // module named exports export default definePage(HomePage, { head: { title: 'Home' }, props: ({ data }) => ({ heading: data?.heading ?? '' }), }); The server function page form (alpha15 server lane) passes the module's exported TSX component function instead — the compiler has already lowered it to a generative HTML constructor, so the same call admits it as a `kind: 'function-page'` descriptor whose render IS that function: export function Home(props: { heading: string }) { return <main><h1>{props.heading}</h1></main>; } export const loader = async () => ({ heading: 'Home' }); export default definePage(Home, { head: { title: 'Home' } }); Descriptor-shape discriminant (one rule, no text sniffing, no ABI field): a first argument that is an ES class (its `prototype` is a non-writable own property; plain functions and arrows are not classes) takes the class branch; any other function takes the function-page branch. Non-functions fail closed with NOT_COMPILED_CLASS. The class-vs-function PAGE classification is a build-time route fact owned by the Router plugin, not this discriminant (M11-1 / M01 C07); definePage only picks the descriptor shape for the value it is handed.
packages/router/src/authoring.ts:498以 4xx 状态码和带类型的数据返回结构化的操作失败结果。
<Data>(status: number, data: Data): OpenElementActionFailure<Data>英文源码说明
Return a structured action failure with an HTTP status and typed data payload.
packages/router/src/authoring.ts:192`definePage()` 接收函数组件时生成的路由模块默认导出类型。
FunctionPageComponent<Data, Params>英文源码说明
The route-module default export shape a definePage() component call produces.
packages/router/src/authoring.ts:426判断值是否为 `OpenElementActionFailure`,也接受来自其他执行环境且结构匹配的对象。
(error: unknown): error is OpenElementActionFailure英文源码说明
Type guard for {@linkcode OpenElementActionFailure}, including its duck-typed cross-realm shape.
packages/router/src/authoring.ts:197单个交互岛的加载配置,决定是否参与 SSR 或 DSD 以及采用何种水合策略。
IslandConfig英文源码说明
Per-island delivery configuration (SSR/DSD participation and hydration strategy).
packages/router/src/authoring.ts:759由适配器决定的浏览器交付策略,可依据媒体查询决定是否交付。
IslandDeliveryStrategy英文源码说明
Adapter-owned browser delivery strategy, including media-query admission.
packages/protocol/src/ssg.ts:31补充交互岛的属性类型本身无法表达的平台配置。
IslandPropertyConfig英文源码说明
The per-property platform facts an island's typed props cannot express. The primitive **names and types** come from the root component's typed props parameter (an inline object type literal, or a local `type`/`interface` in the same module); this entry carries only what a TS type cannot say: reflection, the attribute channel and a declared initial value. The compiler lane cross-checks the two declarations and fails closed on any mismatch, so one side can never be silently inferred from the other. The table is deliberately the `@property` option vocabulary minus `type` and `converter`: the typed member IS the type (a duplicated `type` field would be a second source with no added power), and a custom converter is not expressible on this lane. Array/object/`trustedHtml` members are retained as PROPERTY-ONLY rows (plan §14): they must spell `attribute: false`, require an explicit literal default, and never become an attribute or a JSON wire.
packages/router/src/authoring.ts:727判断值是否为 `OpenElementNotFound`,也接受来自其他执行环境且结构匹配的对象。
(error: unknown): error is OpenElementNotFound英文源码说明
Type guard for {@linkcode OpenElementNotFound}, including its duck-typed cross-realm shape.
packages/router/src/authoring.ts:156判断值是否为 `OpenElementRedirect`,也接受来自其他执行环境且结构匹配的对象。
(error: unknown): error is OpenElementRedirect英文源码说明
Type guard for {@linkcode OpenElementRedirect}, including its duck-typed cross-realm shape.
packages/router/src/authoring.ts:140结构化数据通道接受的只读 JSON 值,包括基本值、数组和普通对象。
JsonValue英文源码说明
A JSON value: the complete set of shapes the structured-data channel admits (JSON primitives, arrays and plain objects, all readonly). Functions, `undefined`, bigint, symbols, class instances, Date, Map and Set are rejected by the runtime normalizer and by this type, so an author cannot write a document the serializer would refuse.
packages/router/src/authoring.ts:243为页面路由获取数据的 loader。
Loader<T, Env, Platform, Route>英文源码说明
Route loader: fetches data for a page route.
packages/protocol/src/data.ts:56传给动态路由 loader 的请求上下文。
LoaderContext<Env, Platform, Route>英文源码说明
Context passed to a request-time ('dynamic') route loader.
packages/protocol/src/data.ts:40抛出 `OpenElementNotFound`,以渲染当前路由的 404 页面。
(message?: string): never英文源码说明
Throw an {@linkcode OpenElementNotFound} to render the 404 path.
packages/router/src/authoring.ts:135列出配置项 `build` 接受的键。
readonly string[]英文源码说明
Accepted keys inside `build`.
packages/router/src/config.ts:364项目根目录使用的标准配置文件名 `openelement.config.ts`。
"openelement.config.ts"英文源码说明
Canonical config-file name, resolved in the project root.
packages/router/src/config.ts:61顶层配置允许的完整键集合,用于拒绝未知键,并在报错时列出可用键。
readonly string[]英文源码说明
The exact accepted key set, used by the fail-closed unknown-key check and by the error message (the message must name the accepted surface, never just reject). The nested arrays below are this module's single copy of the sub-key surfaces; the host-tooling loader imports them instead of restating them.
packages/router/src/config.ts:301`dirs` 中允许使用的键。
readonly string[]英文源码说明
Accepted keys inside `dirs`.
packages/router/src/config.ts:352`head` 中允许使用的键。
readonly string[]英文源码说明
Accepted keys inside `head`.
packages/router/src/config.ts:324`head.scripts` 中单条记录允许使用的键。
readonly string[]英文源码说明
Keys of one `head.scripts` entry.
packages/router/src/config.ts:335`head` 中以普通字符串为值的键。
readonly string[]英文源码说明
Head keys that carry a plain string value.
packages/router/src/config.ts:343`i18n` 中允许使用的键。
readonly string[]英文源码说明
Accepted keys inside `i18n`.
packages/router/src/config.ts:361`layout` 中允许使用的键。
readonly string[]英文源码说明
Accepted keys inside `layout`.
packages/router/src/config.ts:355`middleware` 中允许使用的键。
readonly string[]英文源码说明
Accepted keys inside `middleware`.
packages/router/src/config.ts:367`styles` 中允许使用的键。
readonly string[]英文源码说明
Accepted keys inside `styles`.
packages/router/src/config.ts:358class OpenElementActionFailure英文源码说明
Expected-failure channel for actions (decision 0120): validation failures RETURN `fail(status, data)` — never throw — so the server can answer 422 with the form re-rendered and the submitted values echoed back. Thrown values keep the exception channel (redirect/notFound/error page).
packages/router/src/authoring.ts:173控制构建产物的选项。
OpenElementBuildConfig英文源码说明
Build-output switches.
packages/router/src/config.ts:156设置扫描器读取的源码根目录,具体目录见 `dirs` 配置说明。
OpenElementDirsConfig英文源码说明
Source roots; see the `dirs` section of the module doc comment.
packages/router/src/config.ts:146OpenElementFunctionPageDescriptor<Data, Params>英文源码说明
The function-page descriptor the pipeline reads (`module.default.openElementPage` with `kind: 'function-page'`): same metadata/projector shape as {@link OpenElementPageDescriptor} plus the compiled component function — no element class exists, so the generated entry registers nothing and renders through the render function.
packages/router/src/authoring.ts:412声明结构化的文档头部数据,URL 和特性均经过校验。字体预加载、图标等额外结构由 `app/head.tsx` 声明。
OpenElementHeadConfig英文源码说明
The document-head channel. Structured only: every entry serializes through the framework's URL/attribute validators, so a raw HTML string has no way in. Structural head content that is not expressible here (font preloads, icons, feed links, inline CSS) belongs in the `app/head.tsx` convention instead.
packages/router/src/config.ts:120`head.scripts` 接受的一条结构化 `<script src>` 描述记录。
OpenElementHeadScript英文源码说明
One structured `<script src>` descriptor accepted by `head.scripts`.
packages/router/src/config.ts:103配置构建的语言及其路由前缀。
OpenElementI18nConfig英文源码说明
Locale configuration for a locale-prefixed build.
packages/router/src/config.ts:138由 loader 抛出的未找到信号,用于渲染当前路由的 404 页面。
class OpenElementNotFound extends OpenElementError英文源码说明
Not-found signal thrown from a loader to render the route's 404 path.
packages/router/src/authoring.ts:114构建与渲染流水线通过 `module.default.openElementPage` 读取的页面描述符。
OpenElementPageDescriptor<Data, Params>英文源码说明
The page descriptor the pipeline reads (`module.default.openElementPage`). Attached to the compiled page class by definePage(); the class owns the render program, so the descriptor carries metadata and projectors only.
packages/router/src/authoring.ts:375由 loader 或 action 抛出,以结束渲染并返回 HTTP 重定向的信号。
class OpenElementRedirect extends OpenElementError英文源码说明
Redirect signal thrown from a loader/action to short-circuit rendering with an HTTP redirect.
packages/router/src/authoring.ts:86应用请求适配器共用的独立于宿主的请求上下文。
OpenElementRequestContext<Env>英文源码说明
Host-agnostic request context shared by App request adapters.
packages/router/src/model.ts:3`openelement.config.ts` 接受的覆盖选项。遇到未知键时拒绝该配置。
OpenElementUserConfig英文源码说明
Overrides accepted by an `openelement.config.ts` file (unknown keys fail closed).
packages/router/src/config.ts:219在静态字段上携带页面描述符的已编译元素类。
PageComponentConstructor<Data, Params>英文源码说明
A compiled element class carrying the page descriptor static.
packages/router/src/authoring.ts:388将捕获的渲染、loader 或 action 异常映射为编译页面错误变体的属性。
PageErrorProjector<Data, Params>英文源码说明
Maps a caught render/loader/action failure onto the error variant of the page's compiled properties. Its presence declares that the page's compiled markup carries an error variant (the generated entry renders the page with these props and status 500 — the POST/GET error-boundary channel of decision 0121 §7); without it the generic status page answers.
packages/router/src/authoring.ts:343路由描述符声明的页面 `<head>` 配置,支持规范链接、备用链接和类型化 JSON-LD。
PageHead英文源码说明
Page <head> meaning declared by a route descriptor (decision 0143; canonical/alternates in #1326; structured data via the typed JSON-LD channel). Either a static object or — via PageHeadResolver — resolved per render from the request-scoped context by resolvePageDocument (@openelement/router/document) before the serializer runs.
packages/router/src/authoring.ts:266根据当前请求的上下文解析页面 `<head>` 配置。
PageHeadResolver<Data, Params>英文源码说明
Resolves a page's head from the request-scoped context (#1326). The resolver receives the same context object the props projector gets and must stay a pure function of it — the Document seam (@openelement/router/ document) never fetches, caches, or schedules loaders on its own.
packages/router/src/authoring.ts:354传入页面 props 映射函数的请求级上下文。
PagePropsContext<Data, Params>英文源码说明
The request-scoped context handed to a page's props projector. Everything a compiled page can render must pass through here: the compiled render() only reads `this.<property>`, so the projector is the single deterministic seam that maps loader data, action data, params and request onto the page's compiled properties (decision 0143).
packages/router/src/authoring.ts:302将请求级上下文映射为编译页面的属性。
PagePropsProjector<Data, Params>英文源码说明
Maps the request-scoped context onto the page's compiled properties. Declared as part of the page descriptor; the generated server entry and the SPA bootstrap call it per render and feed the result to renderToString() props (server) or pre-connect property sets (SPA).
packages/router/src/authoring.ts:331RFC 9457 Problem Details 错误响应使用的媒体类型。
"application/problem+json"英文源码说明
Media type of the RFC 9457 action error channel (#863).
packages/protocol/src/data.ts:117表单 action 的协议错误使用的 RFC 9457 文档,按 application/problem+json 返回。detail 提供具体错误说明。
ProblemDetails英文源码说明
RFC 9457 Problem Details document (#863): the action error channel answers `application/problem+json` instead of the bespoke `{ type: 'error', error: { message } }` JSON, so HTTP tooling recognizes failures natively. With `type: 'about:blank'`, `title` is the HTTP reason phrase and `detail` carries the specific explanation. The wire shape is alpha-unfrozen; the 1.0 acceptance freezes it in this problem+json form.
packages/protocol/src/data.ts:105页面没有自定义映射时,先取路由参数,再合入 loader 数据记录作为默认 props。
(context: { params?: Record<string, string>; data?: unknown; }): Record<string, unknown>英文源码说明
Default request-to-props projection used when a page descriptor declares no props projector: route params first, then loader-data record entries. The compiled serializer consumes only the page's declared compiled properties, so extra entries are ignored. Shared by the generated server entries and the SPA bootstrap (each carries its own copy — generated code cannot import this module's internals). Dangerous keys are filtered through the canonical isDangerousKey predicate (#1214): a hostile loader payload such as JSON.parse('{"__proto__": ...}') can never re-prototype the projection record or the page host it is projected onto. The generated server runtime enforces the same rule by importing this canonical predicate through the kernel-free /authoring leaf (#1470 block e: the old build-time serialization copy of DANGEROUS_KEYS into generated code is retired).
packages/router/src/authoring.ts:684为 `location` 抛出 `OpenElementRedirect`,状态码须为支持的 3xx 重定向码。
(location: string | URL, status?: number): never英文源码说明
Throw an {@linkcode OpenElementRedirect} for `location` (status must be a real 3xx).
packages/router/src/authoring.ts:130为 `dirs` 补齐默认值,解析 `routes`、`islands`、`components` 三个源码目录及约定使用的共同基目录 `base`。
(dirs: OpenElementDirsConfig | undefined): { routes: string; islands: string; components: string; base: string; }英文源码说明
Resolve `dirs` to the three absolute-in-project roots the scanner reads. Omitted entries take the documented defaults.
packages/router/src/config.ts:653ServerPageComponent英文源码说明
A compiled server page component function (alpha15 server lane): the route module's exported TSX component after the server component lane compiled it — props in, final HTML out. While authoring, the TSX function's inferred type is JSX.Element-returning (the compiler owns the body), so this type admits every function shape; the runtime discriminant in definePage() is the authority on which branch a value takes.
packages/router/src/authoring.ts:403请求时渲染和静态站点生成共用的服务端路由上下文。
ServerRouteContext<Env, Platform, Route>英文源码说明
Canonical request-time/SSG server route context.
packages/protocol/src/data.ts:25动态路由 loader 接收的服务端上下文,包括标准请求、路由参数、宿主环境和平台对象。
ServerRouteMetadata英文源码说明
Context passed to a request-time ('dynamic') route loader. This is the server contract: the loader runs on the server with the Web-standard request, matched route params, the host environment and the platform object, and signals validation failure via fail()/redirect().
packages/protocol/src/data.ts:19一份结构化数据文档,即 `BlogPosting` 或 `WebSite` 等 JSON-LD 节点。
StructuredDataEntry英文源码说明
One structured-data document — a JSON-LD node such as a schema.org BlogPosting or WebSite. Its values are JSON data (string, finite number, boolean, null, array, plain object) and nothing else: the serializer emits the document as data, so an HTML string is not a document here.
packages/router/src/authoring.ts:257执行生产构建,并以构建结果决定进程退出状态。
(argv?: string[]): Promise<void>英文源码说明
Run the production build and exit with the build's verdict. Shared by the `openelement build` bin subcommand (cli.ts) and this module's own main block, so both faces behave identically.
packages/router/src/cli/build.ts:28(argv: string[]): Promise<void>英文源码说明
Run the serve CLI with the arguments that follow the command (the bin's `start` subcommand passes them through verbatim, so `--mode=preview` reaches the mode parser unchanged). Shared by the `openelement` bin (cli.ts) and this module's own main block.
packages/router/src/cli/start.ts:496描述解析后的文档需要在 `</body>` 前嵌入的一条框架客户端脚本。`src` 和 `code` 至少须提供一项。
ClientScriptDescriptor英文源码说明
One framework client script a resolved document embeds before `</body>`. Shape-compatible with the serializer's script descriptors, so the document channel routes it through without conversion; entries without src or code are meaningless and rejected at resolution (never silently dropped).
packages/router/src/loading/module/nonce.ts:31一条 `<link rel="alternate">` 记录,通常带有 `hreflang`。
PageHeadAlternate英文源码说明
One <link rel="alternate"> record, typically carrying an hreflang.
packages/router/src/document.ts:41ResolvedDocument英文源码说明
A page's resolved document meaning: every <head> field after the head resolver (when the descriptor declares one) has run, plus the normalized `links` projection the serializer consumes. Call-site precedence is resolved-document value first, route/build docConfig fallback second.
packages/router/src/document.ts:59规范化后的 `<link>` 记录,由序列化器输出到 `<head>`。
ResolvedDocumentLink英文源码说明
A normalized <link> the serializer emits into <head>.
packages/router/src/document.ts:47将静态 `head` 或按请求求值的 `head` 解析为 `ResolvedDocument`。两种形式统一校验,构建提供的 `clientScripts` 也由此纳入文档。
(head: PageHead | PageHeadResolver | undefined, context: PagePropsContext, clientScripts?: readonly ClientScriptDescriptor[]): ResolvedDocument英文源码说明
Resolves the descriptor head into the page's ResolvedDocument. A head may be a static object or a resolver receiving the same request-scoped context the props projector gets; resolver output is validated exactly like a static head so malformed page meaning fails loudly at either build time or request time instead of being silently dropped from the serialized document. `clientScripts` carries the framework's client-script descriptors (the build's client asset manifest — the render wiring hands them in, they are never author head data); they are validated like every other field and become part of the resolved document, so every render channel — the SSG render pass included — serializes the final script tags from one place.
packages/router/src/document.ts:196(handler: WinterCgHandler): Promise<object>英文源码说明
Wraps a WinterCG handler in a Hono app: every method and path delegates to the handler with the host's env binding and — when the host runtime provides one — its execution context. The generated entry's `openElementRuntimeAdapter` and default export plug in unmodified: ```ts import { createHonoAdapter } from '@openelement/router/hono'; import openElement from './dist/server/entry.js'; const app = await createHonoAdapter(openElement); export default app; ```
packages/router/src/hono-adapter.ts:82生成入口导出的 WinterCG 请求处理器。
WinterCgHandler英文源码说明
The WinterCG request handler the generated entries export.
packages/router/src/hono-adapter.ts:30创建挂在宿主中间件和路由之后的 HTTP 路由中间件。未匹配 URL 继续交由宿主处理。
(records: readonly HttpRouteRecord[], options?: RouteTableOptions & { methodNotAllowed?: (request: Request, allow: readonly string[]) => Response | Promise<Response>; }): (request: Request, next: () => Promise<Response>…英文源码说明
Mount after host middleware/routes; unmatched URLs continue to the host.
packages/router/src/http.ts:48HttpHandler英文源码说明
Dialect-free WinterCG route handler: return a Response to short-circuit, or `next()` to pass control down the method's handler chain; the last handler's `next` is the host middleware chain's own next.
packages/router/src/http.ts:16传给每个 `HttpHandler` 的路由级请求上下文。
HttpRouteContext英文源码说明
Route-scoped request context handed to every {@link HttpHandler}.
packages/router/src/http.ts:5HttpRouteRecord英文源码说明
A route record for the WinterCG middleware ({@link createRouteMiddleware}): the matching fields of a {@link RouteRecord} plus a per-method handler (or handler chain) map, so one path can answer each HTTP method differently.
packages/router/src/http.ts:27在 Nitro v3 路由中挂载 OpenElement 请求处理器,接收标准 `Request` 并返回 `Response`。
<Env extends Record<string, unknown> = Record<string, unknown>>(options: OpenElementNitroMountOptions<Env>): (event: NitroRequestEvent<Env>) => Promise<Response>英文源码说明
Mounts an OpenElement request handler on a Nitro v3 route. Near pass-through: the event's standard `req` goes in, the handler's Response comes out — h3 v2 serves a returned Response as-is.
packages/router/src/nitro-mount.ts:56Nitro v3 路由事件的最小结构,`req` 已是标准 `Request`。
NitroRequestEvent<Env>英文源码说明
Minimal Nitro v3 route event shape (#857). Nitro v3 is fetch-native: its h3 v2 event carries `req`, a srvx ServerRequest that already IS a standard Request, so the pre-v3 method/path/headers/body translation layer is gone. The mount only wires the OpenElement runtime context around the standard Request → Response seam.
packages/router/src/nitro-mount.ts:12在 Nitro 或 Node 服务上挂载 OpenElement 请求处理器的选项。
OpenElementNitroMountOptions<Env>英文源码说明
Options for mounting an OpenElement request handler under a Nitro/Node server.
packages/router/src/nitro-mount.ts:20将框架采用的 Hono 风格路由模式转换为 WHATWG `URLPattern` 语法。
(path: string): string英文源码说明
Convert the framework's Hono-style route dialect to WHATWG URLPattern syntax.
packages/router/src/internal/router/route-pattern.ts:2RouteMatch<T>英文源码说明
One URL matched against the table: the matched `route` record, the identity reported for it, the decoded path `params`, the parsed `searchParams`, and the raw URLPattern `patternResult` the match was derived from.
packages/router/src/internal/router/route-table.ts:67RouteRecord英文源码说明
One route as the table stores it: the pathname `path`, an optional stable `id` used in match results, optional non-pathname URL component patterns, and the admitted `methods`.
packages/router/src/internal/router/route-table.ts:54RouteResolution<T>英文源码说明
The table's verdict for one request: a `match` (with the resolved method), `method-not-allowed` (with the `allow` list the caller answers 405 with), or `not-found` when no path in the table matches at all.
packages/router/src/internal/router/route-table.ts:80class RouteTable英文源码说明
Immutable route matcher built once from a route list: it freezes every record, rejects duplicate identities and pathname-owning patterns at construction, and answers {@link RouteTable.resolve} with a {@link RouteResolution}. `Pattern` is injectable so callers can pin the URLPattern implementation.
packages/router/src/internal/router/route-table.ts:168配置所有路由的 URL 前缀,以及匹配时是否区分末尾斜杠。
RouteTableOptions英文源码说明
Construction options: a URL prefix every route is mounted under, and whether a trailing slash is significant.
packages/router/src/internal/router/route-table.ts:86客户端路由表编译后的匹配接口,提供匹配、解析和候选数。
CompiledRouteMatcher英文源码说明
The matcher surface a client route list compiles to: matching, resolution and candidate count.
packages/router/src/internal/router/client-router.ts:82将客户端路由列表编译为 `RouteTable` 匹配器,无需创建路由器实例。
(routes: RouteConfig[]): CompiledRouteMatcher英文源码说明
Compile a client route list into the canonical {@link RouteTable} matcher, with no router instance attached.
packages/router/src/internal/router/client-router.ts:110(options: RouterOptions): RouterInstance英文源码说明
Create the client-side SPA router for `options.mode` over `options.routes`: it matches through the shared RouteTable, owns its navigation listeners and history/hash state, and reports every committed navigation through `onChange`.
packages/router/src/internal/router/client-router.ts:133通过统一的 `RouteTable` 匹配路由。
(pathname: string, search: string, routes: RouteConfig[]): RouteMatch<RouteConfig> | null英文源码说明
Match a route through the canonical RouteTable.
packages/router/src/internal/router/client-router.ts:98RouteConfig英文源码说明
One client route: a {@link RouteRecord} plus the custom element `tagName` SPA mode instantiates for it and an optional `guard` that may veto the navigation by returning `false` or a redirect path.
packages/router/src/internal/router/client-router.ts:29RouterInstance英文源码说明
A live client router: the navigation entry points, the current match (`currentPath`/`currentRoute`/`params`/`searchParams`), and `dispose()` to release its listeners.
packages/router/src/internal/router/client-router.ts:69导航策略,可使用 `history`、`hash`,或由 `auto` 检测文件协议。
RouterMode英文源码说明
Navigation strategy: the History API ('history'), the URL hash ('hash'), or file-protocol auto-detection ('auto').
packages/router/src/internal/router/client-router.ts:22选择表单 action 的响应通道。true 返回序列化结果,enhance 返回与无脚本提交相同的 HTML。
"x-openelement-action"英文源码说明
Request header selecting the action response channel: `true` marks a programmatic caller and selects the serialized ActionResult union; `enhance` marks the built-in morph enhancement and selects the same full-HTML responses the no-JS path receives.
packages/protocol/src/data.ts:125(context: OpenElementRequestScope, routePath: string, error: unknown, production: boolean): Response英文源码说明
The fetch-channel 500 (#863, #558): an unexpected action rejection answers RFC 9457 problem+json with internals scrubbed in production (the detail degrades to the reason phrase; development keeps the message for debugging). The native channel stays on the generated handler's HTML error boundary. `production` is the entry's `import.meta.env.PROD`, injected so this module stays free of build-tool globals.
packages/router/src/vite/internal/server-runtime/action-runtime.ts:379返回给生成处理器的 action 执行结果,可包含直接响应或用于重新渲染表单的结果。
ActionExecution英文源码说明
What one protocol run hands back to the generated handler.
packages/router/src/vite/internal/server-runtime/action-runtime.ts:63为 action 提供生成处理器准备的加载上下文,调用时另附 `formData`。
ActionLoadContext英文源码说明
The load context the generated handler built; actions receive it plus `formData`.
packages/router/src/vite/internal/server-runtime/action-runtime.ts:51ActionProtocolState英文源码说明
The per-request action channel state: mutated by {@linkcode runActionProtocol} before any protocol exit so the generated handler's catch block can branch on the fetch path.
packages/router/src/vite/internal/server-runtime/action-runtime.ts:58构造 POST action 的重定向响应。原生表单直接收到 303,fetch 通道通过 HTTP 200 的 `ActionResult` 携带重定向目标与 303 状态。
(context: OpenElementRequestScope, location: string, isFetch: boolean): Response英文源码说明
The redirect exit for a POST action: every 3xx an author throws out of an action is coerced to 303 — PRG must be method-safe and non-cacheable. The native form channel answers a real 303; the fetch channel answers HTTP 200 with the redirect carried as the ActionResult body (`{ type: 'redirect', status: 303, location }`) — the serialized client executor matches on the body, not the HTTP status. GET handlers keep the author's status (the generated catch emits that branch itself).
packages/router/src/vite/internal/server-runtime/action-runtime.ts:359API 路由模块默认导出的函数式处理器,形式为 `(ctx) => Response`。
ApiRouteFunction英文源码说明
A fn-form API handler: the `(ctx) => Response` form an API route module default-exports.
packages/router/src/vite/internal/server-runtime/wintercg.ts:183用当前请求的 nonce 替换构建时 CSP 模板中的首个 `NONCE_PLACEHOLDER` 标记。
(policyTemplate: string, nonce: string): string英文源码说明
Instantiates a generated CSP policy template for one request: replaces the first `NONCE_PLACEHOLDER` marker with the request nonce. The template is build-time data (route wiring produced it from the author's `middleware.csp` policy); only this substitution is runtime semantics.
packages/router/src/vite/internal/server-runtime/response-channel.ts:145获取生成处理器和内置中间件共用的已绑定请求作用域。
(request: Request): OpenElementRequestScope | undefined英文源码说明
The scope accessor the generated handlers and built-in middleware share.
packages/router/src/vite/internal/server-runtime/wintercg.ts:254生成入口传给 `createCorsMiddleware` 的 CORS 配置选项。
CorsOptions英文源码说明
Options for {@linkcode createCorsMiddleware} — the surface the generated entry emits.
packages/router/src/vite/internal/server-runtime/middleware.ts:93(maxSize: number): (request: Request, route: unknown, next: () => Promise<Response>) => Promise<Response>英文源码说明
The default body-limit handler for action POST routes (#568), bound to the serialized `MAX_ACTION_BODY_BYTES` policy constant (see the module doc): an oversized body answers the fetch channel with problem+json 413 (same fork as the CSRF 403) and the native form channel with plain text. The no-store/Vary negotiation headers ride every 413 like every other action response. Larger uploads belong on API routes with explicit limits. Runs as the first element of the generated POST handler chain (`(request, route, next)` — the {@link HttpHandler } shape of
packages/router/src/vite/internal/server-runtime/action-runtime.ts:290(options?: CorsOptions): WinterCgFetchMiddleware英文源码说明
The CORS middleware: non-preflight requests get the allow-origin (and credentials/expose) headers on the channel and an appended `Vary: Origin` when the origin is not `*`; an `OPTIONS` preflight short-circuits with 204 and the full allow set. The origin resolver may return undefined to deny — the generated default reflects only localhost origins and denies everything else.
packages/router/src/vite/internal/server-runtime/middleware.ts:118为每个请求生成由 32 个十六进制字符组成的 CSP nonce。中间件将其用于 `script-src` 并纳入请求作用域。
(): string英文源码说明
Creates one per-request CSP nonce: a UUID without its dashes (32 hex characters). The CSP middleware embeds this value into the `script-src 'nonce-…'` policy it sets on the response and exposes it to the handlers as the `cspNonce` request-scope variable.
packages/router/src/vite/internal/server-runtime/response-channel.ts:135根据路由描述数据创建生成应用,返回入口用于绑定处理器的接口。
(config: GeneratedAppConfig): GeneratedApp英文源码说明
Assembles the generated app from the entry's route descriptor. Pure factory: descriptor data in, handler contract out — every emitted call site in the entry binds a property of the returned record.
packages/router/src/vite/internal/server-runtime/app.ts:150将布局运行时绑定到入口的渲染器、可信 HTML 边界以及序列化后的布局、导航和语言数据。
(deps: LayoutRuntimeDeps): LayoutRuntime英文源码说明
Binds the layout runtime to the entry's renderer, trust boundary, and serialized layout/nav/locale data. The entry destructures `{ resolveLayout: __resolveLayout, renderLayout: __renderLayout }`.
packages/router/src/vite/internal/server-runtime/document-runtime.ts:113记录请求进入时的方法与路径,并在响应返回后记录 HTTP 状态及耗时。
(options?: LoggerOptions): WinterCgFetchMiddleware英文源码说明
Logs `<-- METHOD /path` before the chain and `--> METHOD /path 200 12ms` after it, with the elapsed time humanized the way the previous built-in logged it. No color support: the color policy read `process.env`, which shipped runtime code must not (P3).
packages/router/src/vite/internal/server-runtime/middleware.ts:70(): (request: Request, allow: string[]) => Response英文源码说明
The 405 responder handed to `createRouteMiddleware` as `methodNotAllowed`: no-store (request-time responses are never cacheable), the action negotiation `Vary`, and the `Allow` header listing the route's methods (#572). Reads the per-request scope bound by the WinterCG composition layer so the WinterCG-side middleware can answer through the scope's text channel with the channel headers merged in.
packages/router/src/vite/internal/server-runtime/route-dispatch.ts:36创建默认的原生页面渲染器,经 Element 组合已注册的编译元素。无效标签、超过渲染深度或未注册的 OpenElement 宿主会被拒绝。
(deps: NativePageRendererDeps): PageSsrRenderer英文源码说明
The native renderer (default): render a registered compiled element class through Element composition. Fails closed for invalid tags, depth-bound violations, and unregistered hosts — an unknown OpenElement host cannot be server-rendered (client-only and foreign tags pass through per the admission plan).
packages/router/src/vite/internal/server-runtime/renderer-runtime.ts:107(paths: readonly string[]): Record<string, Record<string, unknown>>英文源码说明
Creates the per-path page handler table the generated GET/POST wiring populates: one mutable method record per page path, keyed by the route path literal the wiring emits.
packages/router/src/vite/internal/server-runtime/route-dispatch.ts:22将生成入口的危险键清单用于页面属性投影,提供默认、正常和错误三种属性投影函数。
(deps: PagePropsRuntimeDeps): PagePropsRuntime英文源码说明
Binds the page props projection to the generated entry's serialized dangerous-key list. Returns the three projection seams under their generated binding names (`__pageProps`, `__pageErrorProps` — the entry destructures them).
packages/router/src/vite/internal/server-runtime/page-render.ts:209(options?: RequestIdOptions): WinterCgFetchMiddleware英文源码说明
Reads the inbound request id (honoring it only when it is present, ≤ `limitLength`, and free of characters outside `[A-Za-z0-9_-=]`), regenerates otherwise, exposes it as the `requestId` scope variable and the response header — the request-id header rides every response the scope builds.
packages/router/src/vite/internal/server-runtime/middleware.ts:40创建单个请求的作用域。`WinterCgApp.fetch` 为每次分派创建并绑定一个作用域。
(request: Request, env?: Record<string, unknown>, platform?: unknown): OpenElementRequestScope英文源码说明
Creates one per-request scope. Exported for the generated wiring's test harnesses; {@linkcode WinterCgApp.fetch} creates and binds one per dispatch.
packages/router/src/vite/internal/server-runtime/wintercg.ts:106在响应生成后施加安全响应头并移除 `X-Powered-By`。默认禁用 `Cross-Origin-Embedder-Policy`。
(): WinterCgFetchMiddleware英文源码说明
The security response headers, applied after the response exists so a handler cannot skip them, plus `X-Powered-By` removal. Same names and values (and the same disabled `Cross-Origin-Embedder-Policy` default) as the built-in set they replace.
packages/router/src/vite/internal/server-runtime/middleware.ts:178使用入口的 `escapeHtml` 创建状态页渲染器,供 404、渲染失败和 SSG 重定向等场景共用。
(escapeHtml: (value: string) => string): StatusHtmlRenderer英文源码说明
Binds the status-page renderer to the entry's `escapeHtml` import. The generated entry imports the canonical escaper (@openelement/element[/html]), so the one implementation serves every status channel (404 fallbacks, render failures, SSG redirect pages).
packages/router/src/vite/internal/server-runtime/document-runtime.ts:48(config: StreamBodyConfig): StreamBodyFn英文源码说明
Binds the streaming body builder to the entry's injected Element function (and the policy timeout default): the returned builder is the `__streamBody` call site the generated handler invokes once per streamed response.
packages/router/src/vite/internal/server-runtime/stream-runtime.ts:327为流式路由创建请求级响应头通道。提交后延迟修改只记录结构化诊断,保留已提交的响应头。
(route: string): ResponseHeaderChannel英文源码说明
Creates the per-request response-header channel for a streamed route: the author-facing `Headers` proxy plus its commitment switch. The proxy guards the mutating members (`append`, `set`, `delete`) after {@linkcode ResponseHeaderChannel.commit}: a late write from a held `context.responseHeaders` reference is a no-op with a structured diagnostic naming the route, header, and operation (the no-op rule; it never throws and never reinterprets a late `Location`/`Set-Cookie` as a protocol decision). Every other member — reads, `forEach` included — behaves exactly like the wrapped `Headers`, and `forEach` hands the callback the proxy itself so a callback-held reference is gated the same way. `route` only feeds the diagnostic payload.
packages/router/src/vite/internal/server-runtime/response-channel.ts:60(original: Request): StreamRequestScope英文源码说明
The request scope for one streamed route: the loader's `request.signal` aborts when the client disconnects (upstream abort fan-out), the response body's `cancel()` tears the whole scope down, and {@linkcode * StreamRequestScope.abortWork} aborts pending loader work at the timeout without cancelling the still-open response.
packages/router/src/vite/internal/server-runtime/stream-runtime.ts:126创建生成入口组装的内部 WinterCG 应用。首次请求时建立分派器,后续注册会触发重建。
(): WinterCgApp英文源码说明
Creates the internal WinterCG app one generated entry assembles. The dispatch builds lazily on the first fetch (registration happens at module scope) and rebuilds if anything registers afterwards.
packages/router/src/vite/internal/server-runtime/wintercg.ts:270从不可信属性复制数据时必须排除的对象原型键。
ReadonlySet<string>英文源码说明
Object prototype keys that must never be injected from untrusted props.
packages/element/src/internal/core/security.ts:25生成入口从应用工厂的返回对象中解构并再次导出的接口。
GeneratedApp英文源码说明
Everything the generated entry destructures and re-exports.
packages/router/src/vite/internal/server-runtime/app.ts:93生成入口传给应用工厂的路由描述数据。
GeneratedAppConfig英文源码说明
The route-descriptor data the generated entry hands the factory.
packages/router/src/vite/internal/server-runtime/app.ts:67有页面路由时由入口绑定的页面渲染接口,使用所选的渲染适配器。纯 API 入口无需绑定 Element 渲染器。
GeneratedPageRuntime英文源码说明
The page-render seam the entry's Element imports feed (renderer-adapter selected). Present only when the entry has page routes: an API-only entry imports no Element renderer and binds none of it.
packages/router/src/vite/internal/server-runtime/app.ts:55安装 SSR 自定义元素注册表守卫,保留原始 `define`。开发环境可更新入口自身注册的标签,外部已注册的标签保持原样。
(): SsrRegistryGuard英文源码说明
Installs the SSR registry guard and returns its registration seam. Behavior contract (moved verbatim from the generated entry): - The TRUE original `define` is captured ONCE on the registry itself (SSR_REGISTRY_ORIGINAL_DEFINE): the registry outlives vite dev SSR module re-evaluations, so a second installation must never capture the already-wrapped `define` as its "original" (#1339). - On the dev SSR stub registry (SSR_REGISTRY_STUB_MARKER) re-definition WINS — the registry outlives module re-evaluation, so route edits only reach SSR output when define() overwrites the stale class (#952). - `NotSupportedError` from a non-stub registry is swallowed (the shim's duplicate-define rejection is its designed live-reload notice); any other error propagates. - A tag the entry registered itself (ownership map) is re-registered through the TRUE original define — a dev re-evaluation registers a FRESH class for the SAME tag and the new class must win. A registration the entry did NOT make is a genuine conflict and keeps the fail-closed no-op.
packages/router/src/vite/internal/server-runtime/security.ts:84判断当前分派是否为 SSG 预渲染。静态字节不携带请求级 nonce,SSG CSP 注入器仅写入策略元标记。
(env: unknown): boolean英文源码说明
True when the dispatch is an SSG prerender pass. Static build output cannot carry per-request state — the SSG nonce contract (nonce.ts: SSG output carries none, static bytes cannot be per-request) — so the CSP auto-nonce binds nothing on this pass: the handlers' `c.get('cspNonce')` stays undefined and `wrapInDocument` serializes the client script tags nonce-free while the SSG CSP injector writes the policy-only meta.
packages/router/src/vite/internal/server-runtime/response-channel.ts:166绑定到生成入口的布局运行时接口。
LayoutRuntime英文源码说明
The layout runtime bound into the generated entry.
packages/router/src/vite/internal/server-runtime/document-runtime.ts:58`createLayoutRuntime` 绑定布局运行时所需的 Element 依赖和序列化配置。
LayoutRuntimeDeps英文源码说明
What {@linkcode createLayoutRuntime} binds: the entry's Element imports plus its serialized plan data.
packages/router/src/vite/internal/server-runtime/document-runtime.ts:91(locales: readonly string[], path: unknown, fallback: string): string英文源码说明
Path-derived locale resolution: the first non-empty path segment when it is a declared locale, the fallback otherwise. `locales` is the generated entry's `__locales` project declaration, so request-time resolution and the pages the build emits agree (see expandI18nLocales).
packages/router/src/vite/internal/server-runtime/page-render.ts:74(href: string, locale: string, defaultLocale: string): string英文源码说明
Layout href localization: root-relative hrefs gain the active locale prefix unless they already carry it; locale-neutral, external, and protocol-relative hrefs pass through untouched. Nav data is not part of the 1.0 surface, so the generated `__headerNav` is empty today — the contract keeps its guard.
packages/router/src/vite/internal/server-runtime/document-runtime.ts:26`createLoggerMiddleware` 的日志配置。
LoggerOptions英文源码说明
Options for {@linkcode createLoggerMiddleware}.
packages/router/src/vite/internal/server-runtime/middleware.ts:59(pattern: string, pathname: string): boolean英文源码说明
Hono-compatible middleware-scope matching: `'/p/*'` matches `/p` itself and everything beneath it; `'/*'` matches everything; a bare `'/p'` matches only `/p` exactly.
packages/router/src/vite/internal/server-runtime/wintercg.ts:236将 loader 或 action 写入的响应头合入结果,保留多条 `Set-Cookie`。框架已设置的协议响应头在冲突时优先。
(response: Response, channel: Headers): Response英文源码说明
Merges the loader/action response-header channel into a response. Channel entries are appended after the framework-set headers, so multi-value `Set-Cookie` accumulates; a protocol header ({@linkcode PROTOCOL_HEADERS}) the response already carries is skipped — the channel cannot override the protocol. An empty channel returns the original `Response` object untouched, so responses that never touch the channel keep their identity (and their streaming body is not rebuilt).
packages/router/src/vite/internal/server-runtime/response-channel.ts:111原生页面渲染器所需的 Element 序列化接口子集。
NativePageRendererDeps英文源码说明
The subset of the Element serializer the native renderer needs.
packages/router/src/vite/internal/server-runtime/renderer-runtime.ts:79与单次分派的请求绑定的作用域。响应创建前通过 `header()` 写入的字段会带入该作用域构造的响应。
OpenElementRequestScope英文源码说明
The per-request scope: one instance per dispatch, bound to its request by the identity registry. Response headers written before the response exists (`header()`) flow into every response the scope constructs — the merge point the Hono context's prepared headers used to own.
packages/router/src/vite/internal/server-runtime/wintercg.ts:66生成处理器为一次页面渲染建立的请求级上下文。
PageContext英文源码说明
The request-scoped page context the generated handlers build for one render (#1326).
packages/router/src/vite/internal/server-runtime/page-render.ts:86(routeModule: unknown): PageDefinition英文源码说明
Canonical page-definition extractor: a route module's default export carries the authoring descriptor on `openElementPage`; anything else projects to the empty descriptor. Kept a hoisted-friendly plain function — the generated entry calls it at module evaluation (route registration, routeInfo) and inside every request handler.
packages/router/src/vite/internal/server-runtime/page-render.ts:44`definePage` 路由模块通过默认导出提供的页面描述对象。
PageDefinition英文源码说明
The page descriptor a definePage route module carries on its default export.
packages/router/src/vite/internal/server-runtime/page-render.ts:25页面属性投影运行时,以参数和加载数据生成默认属性,并执行 `props`、`error` 自定义投影。每条路径都过滤危险键。
PagePropsRuntime英文源码说明
The page props projection runtime: the default projection from route params/loader data plus the descriptor's `props`/`error` projector seams. Every seam filters the canonical dangerous-key set (#1214) so hostile params, loader data, or author projector output can never pollute the props record that flows into the compiled serializer.
packages/router/src/vite/internal/server-runtime/page-render.ts:102生成应用工厂传给 `createPagePropsRuntime` 的绑定依赖。
PagePropsRuntimeDeps英文源码说明
The binding the generated-app factory hands {@linkcode createPagePropsRuntime}.
packages/router/src/vite/internal/server-runtime/page-render.ts:112PageSsrRenderer英文源码说明
The generated entry's `__ssr` binding: render one registered host tag to HTML. `depth` bounds nested island expansion; `projectedChildren` claims external content (the layout slot). Fails closed per the forks below.
packages/router/src/vite/internal/server-runtime/renderer-runtime.ts:61渲染时传给序列化器的源码信息,包含 `route`。
PageSsrSourceInfo英文源码说明
Source metadata the serializer attributes to a render (the `{ route }` seam).
packages/router/src/vite/internal/server-runtime/renderer-runtime.ts:41按插槽名组织的可信轻 DOM 子节点,由父级提供给宿主插槽认领。
ProjectedChildren英文源码说明
Trusted parent-owned light children keyed by slot name (the shell slot claim).
packages/router/src/vite/internal/server-runtime/renderer-runtime.ts:54交给编译后页面宿主的属性投影记录。
ProjectedProps英文源码说明
The projected props record handed to the compiled page host.
packages/router/src/vite/internal/server-runtime/page-render.ts:93定义 loader 和 action 通道不得覆盖的已有框架协议响应头,按不区分大小写的名称匹配。
ReadonlySet<string>英文源码说明
Headers the loader/action channel may never override once the response already carries them: the framework protocol always wins on conflict. Compared case-insensitively against the channel entry's name; the channel may still introduce one of these when the response does not set it itself.
packages/router/src/vite/internal/server-runtime/response-channel.ts:36同步执行服务端函数页渲染并返回 HTML 字符串。对 thenable 保留直接调用 `String` 的兼容行为。
(page: unknown, props: ProjectedProps): string英文源码说明
Synchronous server function page render. A sync render returns its HTML string on this turn. A thenable is still `String`'d, matching the previous contract; production routes do not use this function for async components.
packages/router/src/vite/internal/server-runtime/page-render.ts:184等待服务端函数页完成渲染再转换为 HTML 字符串。若 thenable 拒绝,原始原因随 Promise 传播。
(page: unknown, props: ProjectedProps): Promise<string>英文源码说明
Full-await server function page render. Published from `@openelement/router/server-runtime` because the generated normal, error, 404, and SSG entries import it from that module. A sync render becomes a fulfilled promise of the same string. A thenable is adopted: fulfillment is coerced with `String` after it settles, and rejection rejects this promise with the original reason. Nothing is built into HTML before that settlement, and a rejection is not caught here.
packages/router/src/vite/internal/server-runtime/page-render.ts:197`createRequestIdMiddleware` 的请求标识配置。
RequestIdOptions英文源码说明
Options for {@linkcode createRequestIdMiddleware}.
packages/router/src/vite/internal/server-runtime/middleware.ts:24生成入口以 `c.req` 提供的请求视图,包含标准 `Request`、URL、路径、参数和请求头读取接口。
RequestScopeRequest英文源码说明
The request view the generated wiring binds as `c.req`.
packages/router/src/vite/internal/server-runtime/wintercg.ts:46ResponseHeaderChannel英文源码说明
The per-request response-header channel: the mutable `Headers` instance the loader and the action receive as `context.responseHeaders`, plus the commitment switch the generated stream handler flips when the response is committed.
packages/router/src/vite/internal/server-runtime/types.ts:18(routeModule: unknown): Record<string, unknown>英文源码说明
Canonical route metadata derived from a route module: only the keys the entry consumers read (route, layout, title, description), each present exactly when the descriptor defines it — spread-conditional, so an absent key stays absent instead of becoming `undefined`.
packages/router/src/vite/internal/server-runtime/page-render.ts:55生成入口通过 `import * as $route` 导入的路由模块命名空间。
RouteModule英文源码说明
A route module namespace as the generated entry imports it (`import * as $route`).
packages/router/src/vite/internal/server-runtime/page-render.ts:28处理一次 POST action 请求,解析目标和表单、校验同源请求并分类执行结果。fetch 得到 JSON,原生表单成功后以 303 跳转,失败可按 action 给出的状态重新渲染。
(context: OpenElementRequestScope, routeModule: unknown, loadContext: ActionLoadContext, renderStatusPage: (title: string, message: string, status: number) => Response, state: ActionProtocolState): Promise<ActionExecuti…英文源码说明
Runs the action POST protocol for one request: resolve the action (named `?/name` map or bare `action` export), enforce the same-origin CSRF floor, parse the form body, classify the outcome, and answer per channel: - fetch callers (`ACTION_FETCH_HEADER: true`) always get JSON — the ActionResult union for outcomes, RFC 9457 problem+json for protocol errors (CSRF 403, unknown action 404, unparseable body 400); - native form callers get PRG 303 on success, the status page on protocol errors, and `{ actionResult }` back for a `fail()` so the handler re-renders the form at the author's status (422).
packages/router/src/vite/internal/server-runtime/action-runtime.ts:114SSG 预渲染每次构建期分派时设为 `true` 的环境键。
"OPEN_ELEMENT_SSG_CONTEXT"英文源码说明
The env key the SSG prerender pass sets to `true` on every build-time dispatch (ssg-render.ts passes `{ [SSG_PRERENDER_ENV_KEY]: true }` as the request env). Since #1560 the prerender driver is our own static generator, so the key is owned here — this module is the single source; the build side imports the constant, and no second copy exists to drift.
packages/router/src/vite/internal/server-runtime/response-channel.ts:156`installSsrRegistryGuard` 返回给生成入口的注册接口。
SsrRegistryGuard英文源码说明
What the generated entry gets from {@linkcode installSsrRegistryGuard}.
packages/router/src/vite/internal/server-runtime/security.ts:37生成入口的 `__statusHtml` 渲染器,用标题和消息生成简洁的状态页。
StatusHtmlRenderer英文源码说明
The generated entry's `__statusHtml` binding: title/message rendered into a minimal status page.
packages/router/src/vite/internal/server-runtime/document-runtime.ts:40string英文源码说明
The browser installer bootstrap — the inline head script of every streamed page: the MutationObserver that scans streaming templates, the typed seed admission against the same policy budgets the server enforced, the anchor range ownership check, the frame markup safety screen, and the pagehide retirement/BFCache contract. The module owns the string so the server pump and the browser installer read the same constants from one place; S4 will re-home it from the per-page inline form to a shared asset.
packages/router/src/vite/internal/server-runtime/stream-runtime.ts:520创建流式响应体构建器时绑定的配置,包括特性转义函数和测试用超时覆盖。
StreamBodyConfig英文源码说明
Binding-time configuration of {@linkcode createStreamBody}.
packages/router/src/vite/internal/server-runtime/stream-runtime.ts:102供生成处理器调用的流式响应体构建函数。
StreamBodyFn英文源码说明
The bound streaming body builder the generated handler calls.
packages/router/src/vite/internal/server-runtime/stream-runtime.ts:117构建一次流式响应体所需的请求级输入。
StreamBodyOptions英文源码说明
Per-request inputs of the streaming body builder.
packages/router/src/vite/internal/server-runtime/stream-runtime.ts:91Element 的 `documentStreamParts` 生成的流式文档前缀和后缀。
StreamDocumentParts英文源码说明
The streamed document halves the element `documentStreamParts` produced.
packages/router/src/vite/internal/server-runtime/stream-runtime.ts:85流式调度循环使用的 Element 流执行接口子集。
StreamExecutorView英文源码说明
The slice of the element stream executor the pump consumes.
packages/router/src/vite/internal/server-runtime/stream-runtime.ts:76记录一个声明为延迟的字段如何完成,供流式调度队列消费。
StreamFieldRecord英文源码说明
One declared deferred field's settlement record (the pump's queue unit).
packages/router/src/vite/internal/server-runtime/stream-runtime.ts:54(data: unknown, manifest: StreamRouteManifest): StreamFieldRecord[]英文源码说明
The deferred-field front gate: validates the loader data against the route's build manifest (one plain object, the `STREAM_MAX_FIELDS` / `STREAM_MAX_OWNERS` budget, every declared field present, no undeclared thenable), attaches both settlement observers per field, and hands back the records the pump queues. Every rejection first sweeps the loader's own thenables for observation (see {@linkcode observeThenables}).
packages/router/src/vite/internal/server-runtime/stream-runtime.ts:199生成处理器为一条流式路由建立的请求作用域。
StreamRequestScope英文源码说明
The request scope the generated handler builds around a streamed route.
packages/router/src/vite/internal/server-runtime/stream-runtime.ts:64标记已由应用明确校验为可信的 HTML 的不透明类型。
TrustedHtmlValue英文源码说明
Opaque capability marking HTML the application has explicitly vetted as trusted.
packages/router/src/vite/internal/server-runtime/renderer-runtime.ts:24生成入口用于组装路由和中间件的内部 WinterCG 应用接口。
WinterCgApp英文源码说明
The internal WinterCG app: the composition surface the generated entry wires.
packages/router/src/vite/internal/server-runtime/wintercg.ts:195应用组合使用的通用 Fetch 中间件接口,基于 `Request`、`Response` 和 `next`。
WinterCgFetchMiddleware英文源码说明
The dialect-free fetch middleware the whole composition speaks.
packages/router/src/vite/internal/server-runtime/wintercg.ts:40单个构建产物的文件大小信息。
ArtifactInfo英文源码说明
File size info for a single artifact
packages/router/src/vite/build-manifest.ts:38按 `vite.config.ts` 中的适配器配置执行生产构建,构建结束后恢复调用进程原有的 `NODE_ENV`。
(config?: InlineConfig): Promise<unknown>英文源码说明
Build an OpenElement application through the supported adapter boundary. Consumers configure the adapter in `vite.config.ts`; this function owns the invocation so CLI callers do not need to know the adapter's internal build phases or Vite plugin ordering. KR-15: this is a PRODUCTION build. Vite derives `import.meta.env.PROD` from ambient `process.env.NODE_ENV`, not from `mode`, so a build launched from a test runner (`NODE_ENV=test`) or a dev shell silently emitted a development-semantics SSR bundle — `PROD=false`, so the production error channel stopped scrubbing and SSG 500 details fell back to stack traces (known-reds KR-15, Release P0 Gate). Pin production for the duration of the Vite call and restore the ambient value afterwards, so programmatic callers (and their tests) cannot leak a production NODE_ENV into the rest of the process. `mode` is made explicit for the same reason: the generated `import.meta.env.MODE` should say production even when a caller's ambient environment disagrees.
packages/router/src/vite/index.ts:73将 `FrameworkOptions.inject` 中的头部片段、样式表和脚本序列化为可注入 `<head>` 的 HTML,同时校验 URL 和脚本入口。
(options: FrameworkOptions): HeadExtrasResult英文源码说明
Build the headExtras string from FrameworkOptions.inject. Serializes headFragments, stylesheets, and scripts into a single HTML string to inject into <head>. Validates all URLs and ensures no raw <script> tags bypass the structured injection APIs.
packages/router/src/vite/head-injection.ts:151完整构建清单的摘要。
BuildManifest英文源码说明
Full build manifest summary
packages/router/src/vite/build-manifest.ts:49底层 Vite 插件管线,提供 SSR 开发服务、SSG 和 islands。内容和国际化集成由 `openElement()` 提供。
(config?: OpenPipelineConfig): Plugin[]英文源码说明
Low-level Vite plugin pipeline: SSR dev server, SSG and islands without the content/i18n conveniences of `openElement()`.
packages/router/src/vite/index.ts:39在 Element 选项上扩展适配器的构建配置,例如语言和样式提供器。
FrameworkOptions英文源码说明
Adapter options extend Element options with build-only delivery declarations. The element package remains unaware of Vite/SSG policy.
packages/router/src/vite/framework.ts:37从 `FrameworkOptions` 构建额外头部内容后的结果。
HeadExtrasResult英文源码说明
Result of building head extras from FrameworkOptions.
packages/router/src/vite/head-injection.ts:139将 `.mdx` 路由文件编译为页面模块的 Vite 插件。
(options?: OpenMdxPluginOptions): Plugin英文源码说明
Vite plugin compiling `.mdx` route files into compiled page modules.
packages/router/src/vite/plugin-mdx.ts:72创建完整的 OpenElement Vite 插件组,涵盖路由管线、SSG 和 islands。
(options?: OpenElementOptions): Plugin[]英文源码说明
Create the full OpenElement Vite plugin set: route pipeline, SSG and islands.
packages/router/src/vite/app-vite.ts:39适配器构建上下文中的博客选项,包含内容目录和 URL 基路径。
OpenElementBlogOptions英文源码说明
Blog options stored in the adapter build context.
packages/router/src/vite/framework.ts:59class OpenElementBuildContext英文源码说明
The build's shared mutable state: the resolved framework options, the phase-1/phase-3 metadata, the sub-plugin data slots, and the production plan and artifact records the release and deployment adapters read. One instance is threaded through every adapter plugin for a build.
packages/router/src/vite/build-context.ts:219适配器子插件可用的最小构建上下文接口。
OpenElementBuildContextLike英文源码说明
Minimal build-context contract available to adapter sub-plugins.
packages/router/src/vite/framework.ts:84经构建上下文传给国际化集成的语言列表与默认语言等选项。
OpenElementI18nContextOptions英文源码说明
Locale options carried through the build context to the i18n integration.
packages/router/src/vite/framework.ts:77声明项目语言。构建会为额外语言展开路由,把语言传给页面的 `head`、`props` 钩子,并本地化布局导航。
OpenElementI18nOptions英文源码说明
Project locale declaration. The build expands every static and dynamic route under each additional locale prefix (`/zh/docs`), passes the resolved locale to page `head`/`props` hooks and localizes layout navigation. Absent means a single-locale site with no locale prefixing — the pre-i18n output, byte for byte.
packages/router/src/vite/framework.ts:26`openElement()` 的 Vite 入口选项。文档头部使用 `head`,源码目录可用 `routesDir`、`islandsDir` 声明。
OpenElementOptions英文源码说明
Options for the openElement() unified Vite entry. The framework-options face here is deliberately narrower than the internal {@linkcode FrameworkOptions} transfer type: - the document-head channel is spelled `head` (never `html`), the same spelling `openelement.config.ts` uses — passing `html` fails closed and names the replacement; - the source roots keep their explicit spellings (`routesDir`, `islandsDir`), while a config file's `dirs` block is the spelling that also moves the file conventions.
packages/router/src/vite/app-vite.ts:31`.mdx` 路由插件 `mdxPlugin` 的配置选项。
OpenMdxPluginOptions英文源码说明
Options for the `.mdx` route plugin ({@linkcode mdxPlugin}).
packages/router/src/vite/plugin-mdx.ts:29底层 Vite 插件管线,提供 SSR 开发服务、SSG 和 islands。内容和国际化集成由 `openElement()` 提供。
(config?: OpenPipelineConfig): Plugin[]英文源码说明
Low-level Vite plugin pipeline: SSR dev server, SSG and islands without the content/i18n conveniences of `openElement()`.
packages/router/src/vite/index.ts:39底层 Vite 插件管线 `openPipeline` 的配置选项。
OpenPipelineConfig英文源码说明
Options for the low-level {@linkcode openPipeline} Vite plugin pipeline.
packages/router/src/vite/index.ts:30解析后的 Tailwind 预设选项,保存按声明次序排列的样式来源。
ResolvedTailwindOptions英文源码说明
The resolved preset options: the declared style sources, in order.
packages/router/src/vite/tailwind.ts:59静态生成后处理使用的 Speculation Rules 配置。
SpeculationRulesOptions英文源码说明
Speculation Rules configuration for SSG post-processing
packages/protocol/src/ssg.ts:448面向应用的静态站点生成构建选项。
SsgBehaviorOptions英文源码说明
User-facing SSG build behavior switches (OpenElementOptions['ssg']).
packages/protocol/src/ssg.ts:63TailwindOptions英文源码说明
Options for the opt-in Tailwind entry (alpha15 S lane; the pre-S "preset" compiled the sources itself — this shape only declares them). `tailwind: true` enables the entry with no declared sources: the document stylesheet is Tailwind's own default compile (`@import 'tailwindcss'`). The shape lives here, on the host-neutral config surface, and the Vite build layer consumes it — the Framework-root declaration graph packed consumers typecheck must never name `vite` (the packed-consumer gate's declaration leak pattern).
packages/router/src/config.ts:176↑ ↓ 选择 · Tab 查看 · Esc 返回
@openelement/create
5 个导出文档不指定版本时用来解析安装包的 npm 发布标签;当前 1.0 系列使用 latest。
"latest"英文源码说明
The dist-tag a versionless documented install resolves: npm's scope alias defaults to `latest`, which the 1.0 line rides since the alpha.11 ruling. The exact version is registry truth; the canonical spelling names no tag.
packages/create/src/install-command.ts:33"@openelement"英文源码说明
The scope `npm create` resolves to {@linkcode CREATE_PACKAGE_SPECIFIER}: npm's initializer alias maps a bare `@scope` (optionally `@scope@<tag>`) to `@scope/create` at the same tag — untagged, at the scope's default dist-tag — so the canonical spelling never repeats the `/create` suffix (owner-verified against npm's init alias rules).
packages/create/src/install-command.ts:26生成器在 npm 上发布时使用的包名。
"@openelement/create"英文源码说明
The npm specifier the generator is published under.
packages/create/src/install-command.ts:17使用说明和文档中代指项目名的占位文本。
"<project-name>"英文源码说明
Placeholder the usage text and the docs use in place of a project name.
packages/create/src/install-command.ts:36(projectName?: string, options?: { tag?: string; }): string英文源码说明
The documented install command shapes, all verified against the published two-bin artifact (bins `openelement-create` and `create-openelement`, both `src/cli.js`; npm 11 / pnpm 12): - canonical: `npm create
packages/create/src/install-command.ts:59↑ ↓ 选择 · Tab 查看 · Esc 返回
@openelement/ui
24 个导出构建时生成的 UI 包清单,包含每个组件的声明。
OpenElementPackageManifest英文源码说明
The build-time generated package manifest (declarations for every UI component).
packages/ui/src/manifest.ts:15可渲染为按钮或链接,支持外观变体、尺寸和表单参与。
(props: { variant: string; size: string; disabled: boolean; href: string; target: string; type: string; }): any英文源码说明
Button or link control with variant/size surfaces and form participation.
packages/ui/src/open-button.tsx:67带复制按钮的代码块。
(props: { copyLabel: string; }): any英文源码说明
Code block with a copy button.
packages/ui/src/open-code-block.tsx:48基于原生 dialog 元素和 Popover API 的对话框组件。
(props: { open: boolean; label: string; closeLabel: string; }): any英文源码说明
Dialog component using native <dialog> element + popover API.
packages/ui/src/open-dialog.tsx:73基于 Popover API 和 CSS 锚点定位的下拉组件。
(props: { anchorName: string; }): any英文源码说明
Popover-API dropdown with CSS Anchor Positioning placement.
packages/ui/src/open-dropdown.tsx:54可与表单关联的文本输入组件,提供标签、错误插槽和原生有效性检查。
(props: { type: string; placeholder: string; label: string; name: string; value: string; disabled: boolean; required: boolean; error: string; }): any英文源码说明
Form-associated text input with a label, an error slot and native validity.
packages/ui/src/open-input.tsx:76(props: { theme: string; }): any英文源码说明
Theme toggle button for dark/light mode: reads and flips the document's `data-theme` (with an initialization priority chain) and persists the choice; icon visibility follows the current theme attribute.
packages/ui/src/open-theme-toggle.tsx:56读取宿主的 `key` 状态槽,首次访问时通过 `init()` 初始化。
<T>(host: object, key: string, init: () => T): T英文源码说明
Read the host's `key` slot, initializing it with `init()` on first use.
packages/ui/src/instance-state.ts:15覆写宿主的 `key` 实例状态槽。
(host: object, key: string, value: unknown): void英文源码说明
Overwrite the host's `key` slot.
packages/ui/src/instance-state.ts:26读取宿主的 `key` 状态槽,首次访问时通过 `init()` 初始化。
<T>(host: object, key: string, init: () => T): T英文源码说明
Read the host's `key` slot, initializing it with `init()` on first use.
packages/ui/src/instance-state.ts:15覆写宿主的 `key` 实例状态槽。
(host: object, key: string, value: unknown): void英文源码说明
Overwrite the host's `key` slot.
packages/ui/src/instance-state.ts:26构建时生成的 UI 包清单,包含每个组件的声明。
OpenElementPackageManifest英文源码说明
The build-time generated package manifest (declarations for every UI component).
packages/ui/src/manifest.ts:15可渲染为按钮或链接,支持外观变体、尺寸和表单参与。
(props: { variant: string; size: string; disabled: boolean; href: string; target: string; type: string; }): any英文源码说明
Button or link control with variant/size surfaces and form participation.
packages/ui/src/open-button.tsx:67{ root: "shadow"; delegatesFocus: true; formAssociated: true; styles: string[]; properties: { variant: { default: string; reflect: true; }; size: { default: string; reflect: true; }; disabled: { default: false; reflect:…英文源码说明
Platform facts for the generated element: shadow root with delegated focus, form association (the class lane's `formAssociated: true`, so `form.elements` membership and the effective-disabled custom state are unchanged), the authored stylesheet, and the six declared property rows — all reflected, the class lane's exact attribute surface.
packages/ui/src/open-button.tsx:51带复制按钮的代码块。
(props: { copyLabel: string; }): any英文源码说明
Code block with a copy button.
packages/ui/src/open-code-block.tsx:48声明生成元素的影子根、组件样式表和只能作为属性传入的 `copyLabel`。
{ root: "shadow"; styles: string[]; properties: { copyLabel: { default: string; attribute: false; }; }; }英文源码说明
Platform facts for the generated element: shadow root, the authored component stylesheet, and the `copyLabel` property (property-only, no attribute form).
packages/ui/src/open-code-block.tsx:38基于原生 dialog 元素和 Popover API 的对话框组件。
(props: { open: boolean; label: string; closeLabel: string; }): any英文源码说明
Dialog component using native <dialog> element + popover API.
packages/ui/src/open-dialog.tsx:73生成对话框元素使用的配置,声明代理焦点的 Shadow Root、样式表和属性。
{ root: "shadow"; delegatesFocus: true; styles: string[]; properties: { open: { default: false; reflect: true; }; label: { default: string; }; closeLabel: { default: string; attribute: string; }; }; }英文源码说明
Platform facts for the generated element: shadow root with delegated focus, the authored package stylesheets, and the declared property rows. Only `open` reflects property updates back to the attribute.
packages/ui/src/open-dialog.tsx:61基于 Popover API 和 CSS 锚点定位的下拉组件。
(props: { anchorName: string; }): any英文源码说明
Popover-API dropdown with CSS Anchor Positioning placement.
packages/ui/src/open-dropdown.tsx:54{ root: "shadow"; styles: string[]; properties: { anchorName: { default: string; attribute: false; }; }; }英文源码说明
Platform facts for the generated element: shadow root, the authored package stylesheets, and the property-only `anchorName` row (the anchor identity is assigned at activation, never spelled as an attribute).
packages/ui/src/open-dropdown.tsx:43可与表单关联的文本输入组件,提供标签、错误插槽和原生有效性检查。
(props: { type: string; placeholder: string; label: string; name: string; value: string; disabled: boolean; required: boolean; error: string; }): any英文源码说明
Form-associated text input with a label, an error slot and native validity.
packages/ui/src/open-input.tsx:76{ root: "shadow"; delegatesFocus: true; formAssociated: true; styles: string[]; properties: { type: { default: string; }; placeholder: { default: string; }; label: { default: string; }; name: { default: string; }; value…英文源码说明
Platform facts for the generated element: shadow root with delegated focus, form association (value publication, required and email validity, reset/restore and the fieldset-effective disabled state are the SHELL's mapping), the authored stylesheet, and the eight declared property rows. Only `value` has no attribute wire — it is the live property the form contract and the compiled sinks read.
packages/ui/src/open-input.tsx:58(props: { theme: string; }): any英文源码说明
Theme toggle button for dark/light mode: reads and flips the document's `data-theme` (with an initialization priority chain) and persists the choice; icon visibility follows the current theme attribute.
packages/ui/src/open-theme-toggle.tsx:56生成主题开关元素使用的配置,声明代理焦点的 Shadow Root、样式表和 theme 属性。
{ root: "shadow"; delegatesFocus: true; styles: string[]; properties: { theme: { default: string; }; }; }英文源码说明
Platform facts for the generated element: shadow root with delegated focus, the authored component stylesheet, and the declared `theme` property.
packages/ui/src/open-theme-toggle.tsx:44↑ ↓ 选择 · Tab 查看 · Esc 返回
应用选项类型,逐成员一行。
stringDocument title; defaults to the package.json `name`.
string`<meta name="description">` + `og:description`.
string`<html lang>`; defaults to `en`.
stringSite-root-relative favicon path, emitted as `<link rel="icon">`.
string`og:image` URL. Absolute (crawlable) or site-root-relative.
string[]External stylesheets linked into `<head>`.
OpenElementHeadScript[]External scripts emitted into `<head>`; inline code is not accepted here.
"fail" | "warn"Policy for dynamic-route render failures during SSG. See {@link SsgRenderOptions.dynamicRouteFailure}.
"native"Page renderer selection. The compiled native renderer is the only one supported; omit this key. A retired `'lit'` value is rejected with an explicit migration error at the config boundary (ADR-0152, 2026-11-08).
stringDirectory the route scanner walks, relative to the Vite root. Defaults to `app/routes`.
stringDirectory island modules are discovered in. Defaults to `app/islands`.
string[] | "auto" | "manual"How the build admits component packages whose modules the application imports. - omitted or `'auto'` (the default): the scan derives the admitted set at scan time — every package-owned element module the app's routes, pages, layouts, islands and components really reach (bundler-resolved) is attributed to its owner package (nearest `package.json`), and a package with a valid openElement manifest i…
LayoutConfigLayout declaration; `false` disables the layout, `'default'` uses the built-in one.
LayoutsConfigNamed layout declarations keyed by layout name.
string@dangerous injected as-is, only use with controlled content
(string | { href: string; integrity?: string; crossorigin?: "anonymous" | "use-credentials"; attrs?: Record<string, string | number | boolean>; })[]Stylesheets linked into the document head; each entry is an href or a link record with integrity/crossorigin/attrs.
(string | { src: string; type?: string; async?: boolean; defer?: boolean; integrity?: string; crossorigin?: "anonymous" | "use-credentials"; attrs?: Record<str…Scripts emitted into the document; each entry is a src or a script record with type/async/defer/integrity/crossorigin/attrs.
string[]@dangerous fragments injected as-is. Trust boundary (same level as `trustedHtml`): never concatenate user-controlled content into these fragments; sanitize untrusted data at your own system boundary first. The framework only enforces no-`<script>` and no-executable-`<style>`.
(string | RegExp)[]"load" | "idle" | "visible" | "only" | "none"stringOutput directory for the build artifacts. Defaults to `dist`.
{ islandKB?: number; totalJsKB?: number; pageKB?: number; }Advisory only: exceeded budgets print build-manifest warnings and never fail the build; enforce them in your own build-output test.
booleanEnable the View Transitions API for client navigations. Defaults to true.
boolean | { prerender?: string[]; prefetch?: string[]; exclude?: string[]; eagerness?: "immediate" | "moderate" | "conservative"; }Speculation Rules emission: `true` uses framework defaults, or pass prerender/prefetch URL lists, exclusions and an eagerness.
booleanBuilt-in CORS middleware. Default-ON; pass `false` to disable.
string | string[]Static CORS allowlist data, serialized into the generated entry as JSON. Mutually exclusive with {@link FrameworkOptions.middleware.corsOriginModule }.
stringPath to a module that default-exports `(origin: string) => string | undefined`. The generated entry imports the module — the callback is never serialized — so it may close over module scope and import dependencies. Resolved with the same idiom as `layout.import` (e.g. './app/cors-origin.ts'). Mutually exclusive with `corsOrigin`.
booleanEmit and honor a per-request id header. Default-ON; pass `false` to disable.
booleanLog each request through the built-in logger. Default-ON; pass `false` to disable.
booleanAttach the built-in security response headers. Default-ON; pass `false` to disable.
{ policy?: string; nonce?: boolean; reportOnly?: boolean; }Content-Security-Policy emission: the policy string, nonce generation, and report-only mode.
string[]Fetch middleware chain (#858), composed around the framework handler in onion order (`use[0]` outermost), outside all built-in middleware above. Each entry is a MODULE PATH (same resolution idiom as `layout.import`, e.g. './app/middleware/auth.ts') whose default export is a {@link Middleware}; the generated entry emits `import * as __mw_N from '<path>'` and composes `__mw_N.default` in configured…
CriticalFontAsset[](string | CriticalStyleAsset)[](string | CriticalStyleAsset)[]Alias for styles accepted by config producers.
(string | CriticalInlineScriptAsset)[]booleanAllow intentional external render-blocking styles/scripts.
booleanAlias retained only within this build-side config shape.
booleanMinify inline CSS. Defaults to true.
stringOrigin used to distinguish same-origin and cross-origin absolute URLs.
CriticalAssetsOptionsOpenElementI18nOptionsboolean | TailwindOptionsOpt-in Tailwind entry (alpha9 C2, #1505; externalized alpha15 S lane). `true` or an options object declares the style sources that compile through the official `@tailwindcss/vite` pipeline into the linked document stylesheet; absent keeps the build byte-identical to a Tailwind-less pipeline.
boolean | UnocssOptionsOpt-in UnoCSS entry (alpha15 stage 2B): the sibling of `tailwind`, same shape and same meaning. Declaring it selects UnoCSS as this application's style engine; declaring both keys is a conflict and fails closed — see `UnocssOptions` (`@openelement/router/vite`).
来自编译器 manifest 的 Custom Element。
Button or link control with variant/size surfaces and form participation.
@openelement/ui/open-buttonCode block with a copy button.
@openelement/ui/open-code-blockDialog component using native <dialog> element + popover API.
@openelement/ui/open-dialogPopover-API dropdown with CSS Anchor Positioning placement.
@openelement/ui/open-dropdownForm-associated text input with a label, an error slot and native validity.
@openelement/ui/open-inputTheme toggle button for dark/light mode: reads and flips the document's `data-theme` (with an initialization priority chain) and persists the choice; icon visibility follows the current theme attribute.
@openelement/ui/open-theme-toggle