跳到主要内容
EnglishEnglish查看本页的英文版本。
浏览文档

API 参考

查阅 v1.0.0-alpha.16 的导入路径、签名和配置选项。

01 / 接口规则

从路由和组件开始

用 definePage 为页面函数设置路由选项。在组件函数旁用 defineIslandConfig 声明自定义元素的标签名和启用交互的时机。编写页面和自定义元素路由与数据

02 / 受支持的产品面

6 个受支持的包

查看各个包的用途及受支持的导入路径。

@openelement/protocol

@openelement/protocol
核心
root./app-model./client-assets./data+20 more

编译模板、渲染、路由和错误共用的类型。

应用通常从 router 或 element 包导入这些类型。

@openelement/element

@openelement/element
核心
root./authoring./base./build-utils+14 more

将组件函数编译为浏览器原生自定义元素后,用这个运行时渲染和运行它们。

用组件函数编写自定义元素,并导出其配置。从包根导入 `signal` 管理响应式状态,用 `StyleSheet` 编写组件样式。

@openelement/compiler

@openelement/compiler
构建
root./vite

在构建时编译 TSX 组件函数。

不使用 router 构建组件时,将它安装为开发依赖。通常通过 `@openelement/router` 构建驱动;独立插件在 `@openelement/compiler/vite`。

@openelement/router

@openelement/router
核心
root./cli/build./cli/start./document+7 more

应用与构建面:页面、路由、island、请求/渲染语义、Vite 集成、静态生成与 Nitro 输出。

用 `definePage` 与 `defineIslandConfig` 进行应用创作。构建使用 `@openelement/router/vite` 的 `openPipeline()`/`openElement()` 或生成的构建任务。插件顺序、manifest 与内容扫描属于 router 的实现细节。

@openelement/create

@openelement/create
构建
root./install-command

生成起步应用并安装依赖。

生成的项目暴露 `dev`、`check`、`test`、`build`、`start` 与 `preview`。

@openelement/ui

@openelement/ui
可选
root./instance-state./manifest./open-button+6 more

可选的现成自定义元素,包括按钮、输入框和对话框。

※ 内部子路径(router 请求管线、element hydration 模块)仍可被工具导入,但不携带兼容性承诺。公开类型面是显式的——v1.0.0-alpha.16 线上没有 export-star 缝隙。

由 pnpm --dir tools/repo run interface:snapshot 从仓库真值生成,并对照每个包的 exports map 做机器校验。

03 / 导出参考

导出的符号

签名和路径取自上方标明的源码版本。常用条目提供中文说明,展开即可查阅英文源码摘要和参数选项。 在更新日志中查看已发布版本

用 Page Up 或 Page Down 翻页,用 ↑ 或 ↓ 选择导出项。按 Tab 进入长签名、说明或链接,用 ← 或 → 横向阅读签名,按 Esc 返回列表。打开“随页面滚动此列表”可用页面的滚动条浏览。

@openelement/protocol

433 个导出
Action类型 · 公开
@openelement/protocol · root

处理页面路由的表单提交。

Action<T, Env, Platform, Route>
英文源码说明

Route action: handles form submissions for a page route.

packages/protocol/src/data.ts:64
ACTION_FETCH_HEADER常量 · 公开
@openelement/protocol · root

选择表单 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
ActionContext接口 · 公开
@openelement/protocol · root

传给路由 action 的上下文,包含 loader 上下文。

ActionContext<Env, Platform, Route>
英文源码说明

Context passed to a route action function (extends loader context).

formData: FormData (必填); request: Request (必填); params: Record<string, string> (必填); env: Env (必填); platform: Platform (必填); responseHeaders: Headers (必填) — Mutable response-only channel merged into the framework response.; route: Route (必填)

packages/protocol/src/data.ts:47
ActionResult类型 · 公开
@openelement/protocol · root

脚本提交表单时返回的联合类型。校验失败返回 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
ApiRouteDecl接口 · 公开
@openelement/protocol · root

生成入口描述符中的一条 API 路由声明。

ApiRouteDecl
英文源码说明

One API route declaration in the generated entry descriptor.

kind: "api" (必填); path: string (必填); varName: string (必填); filePath: string (必填); importPath: string (必填)

packages/protocol/src/ssg.ts:163
AuthoringErrorCode常量 · 公开
@openelement/protocol · root

编写组件的属性或声明时可能遇到的校验错误码。

{ 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
BuildArtifacts接口 · 公开
@openelement/protocol · root

openElement 构建流程返回的产物。

BuildArtifacts
英文源码说明

Result returned by the OpenElement build pipeline.

pages: BuildPageArtifact[] (必填) — Generated HTML pages.; manifest: BuildManifestArtifact (必填) — Build manifest.; clientAssets: BuildClientAsset[] (必填) — Client-side assets (island bundles, CSS, etc).; warnings: string[] (必填) — Non-fatal warnings.; errors: string[] (必填) — Fatal errors.; success: boolean (必填) — Whether the build succeeded.

packages/protocol/src/ssg.ts:565
BuildClientAsset接口 · 公开
@openelement/protocol · root

构建流水线输出的一项客户端资源。

BuildClientAsset
英文源码说明

A single client asset emitted by the build pipeline.

fileName: string (必填); source: string | Uint8Array<ArrayBufferLike> (必填); sizeBytes.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; sizeBytes.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; sizeBytes.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; sizeBytes.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; sizeBytes.valueOf: () => number (必填) — Returns the primitive value of the specified object.; sizeBytes.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.

packages/protocol/src/ssg.ts:558
BuildI18nOptions接口 · 公开
@openelement/protocol · root

构建流水线的国际化配置。

BuildI18nOptions
英文源码说明

i18n configuration for the build pipeline.

locales: string[] (必填); defaultLocale?: string (可选)

packages/protocol/src/ssg.ts:511
BuildIslandInput接口 · 公开
@openelement/protocol · root

构建流水线接收的一项交互岛输入。

BuildIslandInput
英文源码说明

A single island input to the build pipeline.

hydrate?: IslandDeliveryStrategy (可选); ssr?: boolean (可选); dsd?: boolean (可选); source?: "local" | "package" | "nested" (可选); reason?: string (可选); tagName: string (必填); modulePath: string (必填); isPackage?: boolean (可选)

packages/protocol/src/ssg.ts:492
BuildManifestArtifact接口 · 公开
@openelement/protocol · root

构建流水线输出的清单产物。

BuildManifestArtifact
英文源码说明

Manifest produced by the build pipeline.

routes: { kind: "page" | "api"; path: string; tagName?: string; isDynamic: boolean; }[] (必填); islands: BuildIslandInput[] (必填); requestTimeRoutes?: string[] (可选) — Paths served at request time (renderIntent mode 'dynamic'). Absent for pure-static builds.

packages/protocol/src/ssg.ts:547
BuildOutputOptions接口 · 公开
@openelement/protocol · root

构建流水线的输出配置。

BuildOutputOptions
英文源码说明

Output configuration for the build pipeline.

root?: string (可选) — Project root directory.; outDir?: string (可选) — Output directory relative to root.; base?: string (可选) — Base URL path.

packages/protocol/src/ssg.ts:501
BuildPackageIslandOptions接口 · 公开
@openelement/protocol · root

构建流水线中由包提供的交互岛的配置。

BuildPackageIslandOptions
英文源码说明

Package island configuration for the build pipeline.

packages?: string[] (可选) — Package names that may expose island declarations.

packages/protocol/src/ssg.ts:517
BuildPageArtifact接口 · 公开
@openelement/protocol · root

一份生成的 HTML 页面产物。

BuildPageArtifact
英文源码说明

A single generated HTML page artifact.

path: string (必填); html: string (必填); errors: { message: string; route?: string; }[] (必填) — Errors collected while rendering this page.

packages/protocol/src/ssg.ts:539
BuildPlan接口 · 公开
@openelement/protocol · root

openElement 构建流水线接收的框架无关构建计划。

BuildPlan
英文源码说明

Framework-agnostic plan consumed by the OpenElement build pipeline.

options.renderer?: "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).; options.routesDir?: string (可选) — Directory the route scanner walks, relative to the Vite root. Defaults to `app/routes`.; options.islandsDir?: string (可选) — Directory island modules are discovered in. Defaults to `app/islands`.; options.packageIslands?: 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…; options.layout?: LayoutConfig (可选) — Layout declaration; `false` disables the layout, `'default'` uses the built-in one.; options.layouts?: LayoutsConfig (可选) — Named layout declarations keyed by layout name.; options.headExtras?: string (可选) — @dangerous injected as-is, only use with controlled content; options.html?: { lang?: string; title?: string; } (可选) — Document `<html>` attributes: the `lang` the document declares and the default `<title>`.; options.inject?: { stylesheets?: Array<string | { href: string; integrity?: string; crossorigin?: "anonymous" | "use-credentials"; attrs?: Record<string, string | number | bool… (可选) — Document head/body injection channels: external stylesheets, scripts, and trusted raw head fragments.; options.ssr?: { noExternal?: (string | RegExp)[]; } (可选) — SSR bundling switches; `noExternal` forces the named packages through the SSR bundle instead of an external import.; options.island?: { upgradeStrategy?: HydrationStrategy; } (可选) — Island defaults applied to every island the build discovers.; options.build?: { outDir?: string; manifestBudget?: { islandKB?: number; totalJsKB?: number; pageKB?: number; }; } (可选) — Build output switches: the output directory and the advisory manifest budgets.; options.viewTransition?: boolean (可选) — Enable the View Transitions API for client navigations. Defaults to true.; options.speculation?: 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.; options.middleware?: { cors?: boolean; corsOrigin?: string | string[]; corsOriginModule?: string; requestId?: boolean; logger?: boolean; securityHeaders?: boolean; csp?: { policy?:… (可选) — Request-time middleware switches, composed outside the framework handler.; routes: BuildRouteInput[] (必填) — Discovered page and API routes.; islands: BuildIslandInput[] (必填) — Discovered local and package islands.; output.root?: string (可选) — Project root directory.; output.outDir?: string (可选) — Output directory relative to root.; output.base?: string (可选) — Base URL path.; i18n?: BuildI18nOptions (可选) — i18n expansion options.; packageIslands.packages?: string[] (可选) — Package names that may expose island declarations.

packages/protocol/src/ssg.ts:523
BuildRouteInput接口 · 公开
@openelement/protocol · root

构建流水线接收的一条路由输入。

BuildRouteInput
英文源码说明

A single route input to the build pipeline.

kind: "page" | "api" (必填) — Route kind: page or API.; path: string (必填) — Route path (e.g. '/about', '/blog/:slug').; filePath: string (必填) — Absolute or relative file path of the route module.; importPath: string (必填) — Import specifier used by generated entry code.; tagName?: string (可选) — Resolved tag name for page routes.; paramNames?: string[] (可选) — Dynamic segment names.; staticParams?: Record<string, string>[] (可选) — Static generation params produced by getStaticPaths().

packages/protocol/src/ssg.ts:474
camelToKebab函数 · 公开
@openelement/protocol · root
(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接口 · 公开
@openelement/protocol · root

针对一份自定义元素清单的兼容性分类报告。

CemCompatibilityReport
英文源码说明

The compatibility classification report for one custom element manifest.

totalClassified.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; totalClassified.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; totalClassified.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; totalClassified.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; totalClassified.valueOf: () => number (必填) — Returns the primitive value of the specified object.; totalClassified.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.; ssrCapableCount: number (必填); clientOnlyCount: number (必填); rejectedCount: number (必填); experimentalDomCount: number (必填); classifications: CompatibilityClassification[] (必填); summary: string (必填)

packages/protocol/src/manifest.ts:146
CemPropertyMetadata接口 · 公开
@openelement/protocol · root

编译生成的自定义元素清单中的单个属性记录。

CemPropertyMetadata
英文源码说明

One property entry of the compiled custom-elements-manifest metadata.

name: string (必填); fieldName: string (必填); type: PropertyValueType (必填); attribute: string | null (必填); reflect: boolean (必填)

packages/protocol/src/part-program.ts:381
ClaimErrorCode常量 · 公开
@openelement/protocol · root

现有 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接口 · 公开
@openelement/protocol · root

客户端构建的交付清单,以交互岛标识为索引。

ClientAssetManifest
英文源码说明

The Phase 2 client build's delivery manifest, keyed by island identity.

entry: string (必填) — The island client entry URL ('' when no client bundle shipped).; islands: Record<string, ClientIslandAsset> (必填) — Compile-time island identity (delivery tag) -> emitted asset.; shared: string[] (必填) — Shared chunk URLs emitted by the client build (JS, neither entry nor island-dedicated).; styles: string[] (必填) — Preloadable island style asset URLs, sorted, base-prefixed. Shadow-component CSS cannot be applied as a document-level stylesheet — it cannot reach shadow trees — so the document channel's only role for these URLs is preload; the sheets themselves are adopted through the sheet adapters.

packages/protocol/src/client-assets.ts:36
ClientIslandAsset接口 · 公开
@openelement/protocol · root

一个编译期交互岛标识对应的客户端资源。

ClientIslandAsset
英文源码说明

The client asset one compile-time island identity resolves to.

file: string (必填) — Emitted asset URL (site-root relative, base-prefixed) of the chunk that carries the island module — its dedicated chunk, a shared chunk, or the client entry when the island has no chunk of its own.; strategy: IslandDeliveryStrategy (必填) — Delivery strategy resolved from the island declaration at build time.; preload?: boolean (可选) — True when the island's delivery strategy hydrates at load time, so the asset is a modulepreload candidate.

packages/protocol/src/client-assets.ts:19
ClientIslandEntry接口 · 公开
@openelement/protocol · root

传给入口生成器的客户端交互岛条目结构。

ClientIslandEntry
英文源码说明

Client island entry shape passed to entry generator.

exportName?: string (可选) — Optional named export to register as the custom element constructor. When set (package islands whose chunk dropped `export default` per #638), the client island factory reads `mod[exportName]` instead of `mod.default`. When absent, the factory falls back to `mod.default` (local/route islands).; strategy: IslandDeliveryStrategy (必填); strategySource?: "default" | "manifest" | "component" | "route" (可选); ssr?: boolean (可选); dsd?: boolean (可选); reason?: string (可选); tagName: string (必填); modulePath: string (必填); isPackage?: boolean (可选)

packages/protocol/src/ssg.ts:105
CompatibilityClassification接口 · 公开
@openelement/protocol · root

兼容性扫描为每个标签记录分级、原因、来源和对应的 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.

tagName: string (必填); tier: CompatibilityTier (必填); reason: string (必填); source: "local" | "package" | "nested" (必填); modulePath?: string (可选); ssr?: boolean (可选); dsd?: boolean (可选); hydrate?: string (可选)

packages/protocol/src/framework.ts:347
CompatibilityTier类型 · 公开
@openelement/protocol · root

标签的构建兼容级别,区分服务端渲染、仅浏览器渲染、实验支持和拒绝构建。

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接口 · 公开
@openelement/protocol · root

一个组件编译生成的自定义元素清单元数据。

CompiledCemMetadata
英文源码说明

The compiled custom-elements-manifest metadata block of one component.

tagName: string (必填); className: string (必填); declaration: { name: string; module: string; } (必填); attributes: { name: string; fieldName: string; type: PropertyValueType; reflect: boolean; }[] (必填); members: CemPropertyMetadata[] (必填)

packages/protocol/src/part-program.ts:390
CompiledElementMetadata接口 · 公开
@openelement/protocol · root

程序提供给工具读取的编译元素元数据。

CompiledElementMetadata
英文源码说明

The compiled element metadata the program carries for tooling consumers.

tag: string (必填); className: string (必填); sourceFile: string (必填); properties: CompiledPropertyMetadata[] (必填); observedAttributes: string[] (必填); cem: CompiledCemMetadata (必填)

packages/protocol/src/part-program.ts:399
CompiledPropertyMetadata接口 · 公开
@openelement/protocol · root

编译后的单个 @property 声明,记录名称、类型和反射设置。

CompiledPropertyMetadata
英文源码说明

One compiled

name: string (必填); attribute: string | null (必填); type: PropertyValueType (必填); converter: PropertyValueType (必填); reflect: boolean (必填); default: SerializableValue (必填); computed?: boolean (可选) — True for computed fields (`= computed(() => ...)` in the source): their signal is derived from other property signals by the generated `__computedFields` factory, never seeded from attributes/props. Always paired with `attribute: null` and `reflect: false`.; deps?: string[] (可选) — Source signal names a computed field reads (declaration order).

packages/protocol/src/part-program.ts:362
CompilerErrorCode常量 · 公开
@openelement/protocol · root

编译期间使用的错误码。

{ 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
ComponentLayer类型 · 公开
@openelement/protocol · root

组件的交付层级,区分静态 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
conditionLiteralAllowed函数 · 公开
@openelement/protocol · root

判断比较运算符与 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类型 · 公开
@openelement/protocol · root

编译程序的条件表达式所支持的比较运算符。

ConditionOperator
英文源码说明

The comparison operators a program condition supports.

packages/protocol/src/part-program.ts:236
ContextErrorCode常量 · 公开
@openelement/protocol · root

Context Community Protocol 服务的生命周期错误码,发生在 csr 阶段。

{ readonly SERVICE_DISPOSED: "OE_CONTEXT_SERVICE_DISPOSED"; }
英文源码说明

Community-context service lifecycle failures (phase `csr`).

packages/protocol/src/errors.ts:233
CorsOriginConfig类型 · 公开
@openelement/protocol · root

API 路由声明的 CORS 来源策略。

CorsOriginConfig
英文源码说明

The CORS origin policy an API route declares.

packages/protocol/src/ssg.ts:130
CspConfig接口 · 公开
@openelement/protocol · root

路由或文档声明的内容安全策略(CSP)指令。

CspConfig
英文源码说明

The content-security-policy directives a route or document declares.

policy?: string (可选); nonce?: boolean (可选); reportOnly?: boolean (可选)

packages/protocol/src/ssg.ts:133
DATA_OE_LIGHT常量 · 公开
@openelement/protocol · root

标识由服务端渲染的 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
DEFAULT_RENDER_ERROR_CODE常量 · 公开
@openelement/protocol · root

RenderError 使用的默认错误码。

"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
DIAGNOSTIC_REPORT_FORMAT常量 · 公开
@openelement/protocol · root

用于识别诊断报告格式的 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:84
DiagnosticEnvelope接口 · 公开
@openelement/protocol · root
DiagnosticEnvelope
英文源码说明

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.

code: string (必填) — The producer's own stable code (`OEC9020`, `OE_PRESET_*`, `OE_SSG_*`).; severity: DiagnosticSeverity (必填); phase: DiagnosticPhase (必填); message: string (必填) — What happened, in the producer's own words.; file?: string (可选) — The source file (or module specifier) the diagnostic points at.; line.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; line.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; line.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; line.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; line.valueOf: () => number (必填) — Returns the primitive value of the specified object.; line.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.; column?: number (可选) — 1-based authored column, when the producer has a source location.; hint?: string (可选) — The fix, when the producer can name one.

packages/protocol/src/diagnostics.ts:60
DiagnosticPhase类型 · 公开
@openelement/protocol · root
DiagnosticPhase
英文源码说明

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
diagnosticReport函数 · 公开
@openelement/protocol · root

组装构建退出报告。只要一个诊断的严重级别为 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:105
DiagnosticReport接口 · 公开
@openelement/protocol · root
DiagnosticReport
英文源码说明

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.

format: "openelement.diagnostics/1" (必填); ok: boolean (必填); diagnostics: DiagnosticEnvelope[] (必填)

packages/protocol/src/diagnostics.ts:95
DiagnosticReportFormat类型 · 公开
@openelement/protocol · root

诊断报告 format 字段使用的格式标识类型。

"openelement.diagnostics/1"
英文源码说明

One format tag value (kept as a type for the report's `format` field).

packages/protocol/src/diagnostics.ts:87
DiagnosticReportParseError类 · 公开
@openelement/protocol · root

parseDiagnosticReport 发现文本不是可读取的诊断报告时抛出的错误。

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
DiagnosticSeverity类型 · 公开
@openelement/protocol · root

区分导致构建失败的 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接口 · 公开
@openelement/protocol · root

构建时写入生成入口的文档级配置。

DocumentConfig
英文源码说明

The document-level facts a build bakes into the generated entry.

lang: string (必填); title: string (必填); headExtras: string (必填); allowHeadExtrasScripts: boolean (必填)

packages/protocol/src/ssg.ts:286
EachKeyErrorCode常量 · 公开
@openelement/protocol · root

带键列表无法确定条目身份时使用的错误码。

{ 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
EMPTY_CLIENT_ASSET_MANIFEST常量 · 公开
@openelement/protocol · root

没有客户端包的项目使用的资源清单。

ClientAssetManifest
英文源码说明

The manifest a project without a client bundle carries.

packages/protocol/src/client-assets.ts:54
ENTRY_REGISTRATION_OWNERS常量 · 公开
@openelement/protocol · root
"__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接口 · 公开
@openelement/protocol · root

一个生成入口的完整构建描述,包含路由、交互岛、渲染器、中间件、文档和布局计划。

EntryDescriptor
英文源码说明

The full build-time description of one generated entry: routes, islands, renderers, middleware, document, and layout plans.

isSSG: boolean (必填); renderer?: "native" (可选) — Page renderer selection. Only the compiled native renderer exists; absent or 'native' keeps the renderToString page path byte-identical. Loader, action and protocol codegen never fork on a renderer.; imports: ImportDecl[] (必填); middleware: MiddlewareDecl[] (必填); fetchMiddleware?: string[] (可选) — `middleware.use` fetch middleware module paths (#858), in user-configured order. The entry renderer emits one `import * as __mw_N from '<path>'` per entry and composes each module's default export around the exported handler in onion order. Absent/empty when the app configures no fetch middleware, keeping the generated entry byte-identical to pre-#858 output.; apiRoutes: ApiRouteDecl[] (必填); pageRoutes: PageRouteDecl[] (必填); staticComponents: StaticComponentDecl[] (必填); islands: IslandDecl[] (必填); hasEnhancedForms?: boolean (可选) — True when any page route carries data-open-enhance forms (#569). Drives the dev island client script injection (#951): an island-free app with enhanced forms still needs the client entry in dev HTML.; ssrAdmissionPlan: SsrAdmissionPlan (必填); cemClassifications?: CompatibilityClassification[] (可选); renderers: RendererDecl[] (必填); middlewareScopes: MiddlewareScopeDecl[] (必填); document: DocumentConfig (必填); layout: LayoutPlan (必填); upgradeStrategy?: "load" | "idle" | "visible" | "only" | "none" (可选); i18n?: { locales: string[]; defaultLocale: string; } (可选) — Declared project locales. Absent for a single-locale site: the generated entry then emits no locale prefixes and the default-locale fallback, which is byte-identical to pre-i18n output.

packages/protocol/src/ssg.ts:321
ERROR_PREFIX常量 · 公开
@openelement/protocol · root

openElement 错误消息使用的前缀。

"[openElement]"
英文源码说明

Error message prefix for all openElement errors.

packages/protocol/src/errors.ts:50
ErrorCode常量 · 公开
@openelement/protocol · root

常用错误码常量。调用方也可以传入字符串错误码。

{ 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类型 · 公开
@openelement/protocol · root

发生错误时所在的执行阶段。

ErrorPhase
英文源码说明

The pipeline phase an error was raised in.

packages/protocol/src/errors.ts:80
ErrorSeverity类型 · 公开
@openelement/protocol · root

框架错误的严重程度。

ErrorSeverity
英文源码说明

How severe a framework error is.

packages/protocol/src/errors.ts:78
ErrorTelemetryHook类型 · 公开
@openelement/protocol · root

接收所有通过错误遥测渠道上报的 OpenElementError。

ErrorTelemetryHook
英文源码说明

Callback receiving every reported {@linkcode OpenElementError} for telemetry.

packages/protocol/src/errors.ts:132
errorToEnvelope函数 · 公开
@openelement/protocol · root

将 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`.

code: string (必填); severity: ErrorSeverity (必填); phase: ErrorPhase (必填); recoverable: boolean (必填); statusCode.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; statusCode.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; statusCode.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; statusCode.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; statusCode.valueOf: () => number (必填) — Returns the primitive value of the specified object.; statusCode.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.; toJSON: () => Record<string, unknown> (必填); name: string (必填); message: string (必填); stack?: string (可选); cause?: unknown (可选)

packages/protocol/src/diagnostics.ts:256
FacadeErrorCode常量 · 公开
@openelement/protocol · root

公开入口在 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
FORBIDDEN_ATTRIBUTE_NAMES常量 · 公开
@openelement/protocol · root
ReadonlySet<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
FORBIDDEN_PROPERTY_NAMES常量 · 公开
@openelement/protocol · root

编译器不允许用作 @property 声明的属性名集合。

ReadonlySet<string>
英文源码说明

Property names the compiler refuses as

packages/protocol/src/forbidden-sinks.ts:31
ForbiddenSinkKind类型 · 公开
@openelement/protocol · root

统一禁用规则检查的写入目标类别。

ForbiddenSinkKind
英文源码说明

Sink categories the canonical deny list classifies.

packages/protocol/src/forbidden-sinks.ts:41
forbiddenSinkReason函数 · 公开
@openelement/protocol · root

返回指定类别下某名称不允许写入的原因,名称可用时返回 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
frameworkError函数 · 公开
@openelement/protocol · root

创建 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
FrameworkOptions接口 · 公开
@openelement/protocol · root
FrameworkOptions
英文源码说明

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.

renderer?: "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).; routesDir?: string (可选) — Directory the route scanner walks, relative to the Vite root. Defaults to `app/routes`.; islandsDir?: string (可选) — Directory island modules are discovered in. Defaults to `app/islands`.; packageIslands?: 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…; layout?: LayoutConfig (可选) — Layout declaration; `false` disables the layout, `'default'` uses the built-in one.; layouts?: LayoutsConfig (可选) — Named layout declarations keyed by layout name.; headExtras?: string (可选) — @dangerous injected as-is, only use with controlled content; html.lang?: string (可选); html.title?: string (可选); inject.stylesheets?: (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.; inject.scripts?: (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.; inject.headFragments?: 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>`.; ssr.noExternal?: (string | RegExp)[] (可选); island.upgradeStrategy?: "load" | "idle" | "visible" | "only" | "none" (可选); build.outDir?: string (可选) — Output directory for the build artifacts. Defaults to `dist`.; build.manifestBudget?: { 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.; viewTransition?: boolean (可选) — Enable the View Transitions API for client navigations. Defaults to true.; speculation?: 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.; middleware.cors?: boolean (可选) — Built-in CORS middleware. Default-ON; pass `false` to disable.; middleware.corsOrigin?: string | string[] (可选) — Static CORS allowlist data, serialized into the generated entry as JSON. Mutually exclusive with {@link FrameworkOptions.middleware.corsOriginModule }.; middleware.corsOriginModule?: string (可选) — Path 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`.; middleware.requestId?: boolean (可选) — Emit and honor a per-request id header. Default-ON; pass `false` to disable.; middleware.logger?: boolean (可选) — Log each request through the built-in logger. Default-ON; pass `false` to disable.; middleware.securityHeaders?: boolean (可选) — Attach the built-in security response headers. Default-ON; pass `false` to disable.; middleware.csp?: { policy?: string; nonce?: boolean; reportOnly?: boolean; } (可选) — Content-Security-Policy emission: the policy string, nonce generation, and report-only mode.; middleware.use?: 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…

packages/protocol/src/framework.ts:180
HYDRATION_STRATEGIES常量 · 公开
@openelement/protocol · root

运行时支持的 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接口 · 公开
@openelement/protocol · root

组件或路由携带的水合加载提示。

HydrationHint
英文源码说明

The hydration delivery hint a component or route carries.

tagName: string (必填); layer: ComponentLayer (必填); hydrate?: "load" | "idle" | "visible" | "only" | "none" (可选)

packages/protocol/src/render.ts:26
HydrationStrategy类型 · 公开
@openelement/protocol · root

控制交互岛何时启用,也可跳过浏览器 hydration。

"load" | "idle" | "visible" | "only" | "none"
英文源码说明

Island hydration trigger: 'load' | 'idle' | 'visible' | 'only'.

packages/protocol/src/framework.ts:30
IDLE_FALLBACK_TIMEOUT_MS常量 · 公开
@openelement/protocol · root

环境缺少 requestIdleCallback 和 requestAnimationFrame 时,空闲 hydration 的备用延时(毫秒)。

50
英文源码说明

Idle-hydration scheduling fallback (milliseconds) when neither `requestIdleCallback` nor `requestAnimationFrame` is available.

packages/protocol/src/policy.ts:70
ImportDecl接口 · 公开
@openelement/protocol · root

生成入口输出的一条模块导入声明。

ImportDecl
英文源码说明

One module import the generated entry emits.

from: string (必填); names: string[] (必填); alias?: string (可选)

packages/protocol/src/ssg.ts:123
isAttributeName函数 · 公开
@openelement/protocol · root

线格式校验器用来检查属性名的入口,采用统一校验规则。

(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
ISLAND_ADMISSION常量 · 公开
@openelement/protocol · root

路由器交给元素编译器的静态配置识别描述符。

StaticSidecarDescriptor
英文源码说明

The static-sidecar descriptor router injects into the element compiler.

packages/protocol/src/island-admission.ts:18
IslandDecl接口 · 公开
@openelement/protocol · root

构建纳入的一个交互岛的声明,包括标签名、模块路径和加载方式。

IslandDecl
英文源码说明

One island the build admits: tag, module path, and delivery facts.

exportName?: string (可选) — Optional named export to register as the custom element constructor. Set for package islands from the manifest declaration's `className` (the CEM-derived export class name), so the client island factory can read `mod[exportName]` after #638 removed `export default` from UI component chunks. Absent for local/route islands (which use default).; hydrate?: IslandDeliveryStrategy (可选); ssr?: boolean (可选); dsd?: boolean (可选); authoring?: "basic-element" | "third-party-wc" (可选); source?: "local" | "package" | "nested" (可选); reason?: string (可选); tagName: string (必填); modulePath: string (必填); isPackage?: boolean (可选)

packages/protocol/src/ssg.ts:195
IslandDeliveryStrategy类型 · 公开
@openelement/protocol · root

由适配器决定的浏览器交付策略,可依据媒体查询决定是否交付。

IslandDeliveryStrategy
英文源码说明

Adapter-owned browser delivery strategy, including media-query admission.

packages/protocol/src/ssg.ts:31
IslandModuleIdentity接口 · 公开
@openelement/protocol · root

交互岛记录共用的模块标识,包含注册标签、模块路径及包来源信息。

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.

tagName: string (必填); modulePath: string (必填); isPackage?: boolean (可选)

packages/protocol/src/ssg.ts:98
IslandOptions接口 · 公开
@openelement/protocol · root

交互岛的交付选项,包括 hydration 策略和是否参与 SSR 或 DSD。

IslandOptions
英文源码说明

Per-island delivery options (hydration strategy, SSR/DSD participation).

hydrate?: "load" | "idle" | "visible" | "only" | "none" (可选) — Hydration strategy: - 'load': load immediately when module is imported - 'idle': defer to requestIdleCallback (default) - 'visible': use IntersectionObserver to defer until element is visible - 'only': client-only render, no DSD/SSR output Named `hydrate` to match `defineIslandConfig()` in the Router package — one option name across both packages.; dsd?: boolean (可选) — Whether to use DSD for SSR rendering of this island. Honored by the build-side island scan (via `defineIslandConfig`), not by `defineIsland()` itself: passing it in `IslandOptions` has no runtime effect.; ssr?: boolean (可选) — Whether this island may be admitted into server rendering. Like `dsd`, decided by the build-side island scan; inert when passed to `defineIsland()`.

packages/protocol/src/island.ts:8
IslandTransformOptions接口 · 公开
@openelement/protocol · root

构建时转换交互岛源码所用的选项。

IslandTransformOptions
英文源码说明

Options for the build-time island source transform.

islandsDir: string (必填) — Directory containing island files (e.g. "app/islands"); filePath: string (必填) — Absolute or relative file path of the source being processed; layout?: { path: string; tagName: string; } (可选) — Layout-convention admission (alpha15 R batch 3): the resolved layout module the router convention owns (`app/layout.tsx`, tag `app-layout`, or a project-relative custom `layout: { import }` override). The gate admits this one path with its resolved tag even though it lives outside `islandsDir`. Absent when the project configures no layout module (`layout: false`, or the deletable convention file …

packages/protocol/src/island.ts:42
IslandTransformResult接口 · 公开
@openelement/protocol · root

交互岛转换的结果,包括改写的源码和提取的信息。

IslandTransformResult
英文源码说明

The island transform output: rewritten source plus extracted facts.

code: string (必填) — Transformed source code with markers; islands: { tagName: string; filePath: string; }[] (必填) — Detected island entries; map?: string (可选) — Optional source map

packages/protocol/src/island.ts:64
isSafeAttributeName函数 · 公开
@openelement/protocol · root

统一检查属性名称是否符合安全规则。

(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
ItemEventBinding接口 · 公开
@openelement/protocol · root

每个 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.

event: string (必填) — DOM event name ('click', 'input', …).; handler: string (必填) — Handler method name on the compiled class.; action: ProgramEventAction (必填) — The action to dispatch, same union as fixed event parts.; selector?: string (可选) — Optional child selector within the item template (e.g. '.probe-button'). When omitted, the listener attaches to the item root.

packages/protocol/src/part-program.ts:295
KernelErrorCode常量 · 公开
@openelement/protocol · root

自定义元素在客户端运行期间违反内核生命周期契约时使用的错误码。

{ 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类型 · 公开
@openelement/protocol · root

为路由选择内置布局、指定自定义布局及其模块和属性,或关闭布局。

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接口 · 公开
@openelement/protocol · root

构建解析出的布局模块声明,包含标签名、导入路径和序列化属性。

LayoutDecl
英文源码说明

The layout module a build resolves: tag, import path, and serialized props.

tagName: string (必填); importPath: string (必填); props: Record<string, unknown> (必填); generatedHostExport?: string (可选) — The compiler-emitted SSR host producer export (`<Name>__ssrHost`) when the layout module is a GENERATED element, or absent when it is a class. A generated layout cannot be registered class-only: a generated element carries no Part Program, so `renderToString` fails with PROGRAM_MISSING on every render. The entry therefore registers the generated host PAIR — the same channel an island uses. The na…

packages/protocol/src/ssg.ts:294
LayoutPlan接口 · 公开
@openelement/protocol · root

构建最终交付的布局计划,包含默认布局和具名布局。

LayoutPlan
英文源码说明

The resolved layouts a build ships: the default layout plus named layouts.

default: ResolvedLayout (必填); layouts: Record<string, ResolvedLayout> (必填)

packages/protocol/src/ssg.ts:315
Loader类型 · 公开
@openelement/protocol · root

为页面路由获取数据的 loader。

Loader<T, Env, Platform, Route>
英文源码说明

Route loader: fetches data for a page route.

packages/protocol/src/data.ts:56
LoaderContext接口 · 公开
@openelement/protocol · root

传给动态路由 loader 的请求上下文。

LoaderContext<Env, Platform, Route>
英文源码说明

Context passed to a request-time ('dynamic') route loader.

request: Request (必填); params: Record<string, string> (必填); env: Env (必填); platform: Platform (必填); responseHeaders: Headers (必填) — Mutable response-only channel merged into the framework response.; route: Route (必填)

packages/protocol/src/data.ts:40
LocalePath接口 · 公开
@openelement/protocol · root

随语言解析的路径契约。

LocalePath
英文源码说明

Locale-aware resolved path contract.

locale: string (必填); path: string (必填); localizedPath: string (必填); isDefaultLocalePath: boolean (必填)

packages/protocol/src/framework.ts:82
MAX_ACTION_BODY_BYTES常量 · 公开
@openelement/protocol · root

生成的服务端入口对 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
MAX_COMPOSITION_DEPTH常量 · 公开
@openelement/protocol · root

renderToString 允许展开的嵌套元素层数,避免循环组合导致无穷递归。

8
英文源码说明

Nested element expansion depth bound for `renderToString`: cyclic component composition fails closed instead of recursing without end.

packages/protocol/src/policy.ts:51
Middleware类型 · 公开
@openelement/protocol · root

基于标准 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接口 · 公开
@openelement/protocol · root

由生成入口纳入执行链的一个中间件模块声明。

MiddlewareDecl
英文源码说明

One middleware module the generated entry composes.

kind: "requestId" | "logger" | "cors" | "securityHeaders" | "csp" (必填); comment?: string (可选); config.corsOrigin?: CorsOriginConfig (可选); config.corsOriginModule?: string (可选) — Normalized import path of a module default-exporting `(origin: string) => string | undefined`. The generated entry imports the module and passes its default export to `cors({ origin })` — the callback is referenced, never serialized.; config.warnOnDefaultCors?: boolean (可选) — #1411: emit the default-CORS production advisory. Absent means "warn" (production builds); the dev server sets false so the first run is warning-free.; config.csp?: CspConfig (可选)

packages/protocol/src/ssg.ts:140
MiddlewareScopeDecl接口 · 公开
@openelement/protocol · root

一个中间件的适用范围,可覆盖全部路由或一组具名路由。

MiddlewareScopeDecl
英文源码说明

The scope one middleware applies to (all routes or a named route set).

varName: string (必填); scope: string (必填); importPath: string (必填)

packages/protocol/src/ssg.ts:279
ModuleVocabularyDescriptor接口 · 公开
@openelement/protocol · root

描述模块扫描识别的导出绑定,以及调用该绑定时登记的事实。

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).

moduleSpecifier: string (必填) — Canonical module specifier the factory must be imported from.; exportName: string (必填) — Exported name of the factory binding.; kind: "page-definition" | "element-registration" (必填) — What a canonical call of the binding contributes to the scan.

packages/protocol/src/module-descriptors.ts:33
NESTED_HOST_EXPANDER常量 · 公开
@openelement/protocol · root

编译器内部字段,用于在渲染的宿主记录中存放展开嵌套宿主的函数。

"__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
OpenElementAttribute接口 · 公开
@openelement/protocol · root

自定义元素声明中记录的一个 attribute。

OpenElementAttribute
英文源码说明

One documented attribute of a custom element declaration.

name: string (必填); type?: string (可选); default?: string (可选); description?: string (可选); reflects?: boolean (可选); fieldName?: string (可选)

packages/protocol/src/manifest.ts:15
OpenElementBlogOptions接口 · 公开
@openelement/protocol · root

构建上下文中可选的博客内容目录和 URL 基础路径。

OpenElementBlogOptions
英文源码说明

Blog options stored in the build context by

contentDir?: string (可选); basePath?: string (可选)

packages/protocol/src/framework.ts:37
OpenElementBuildContextLike接口 · 公开
@openelement/protocol · root

供子插件使用的最小构建上下文接口。

OpenElementBuildContextLike
英文源码说明

Minimal build context interface that sub-plugins can use.

plugins: { [key: string]: unknown; blogOptions: OpenElementBlogOptions | null; navSections: OpenElementNavSection[]; headerNav: OpenElementHeaderNavLink[]; sitemapOptio… (必填); registerPlugin: (name: string, instance: unknown) => void (必填) — Register plugin data by name. Protocol level uses loose typing; concrete implementations should tighten the generic constraint.

packages/protocol/src/framework.ts:62
OpenElementCssPart接口 · 公开
@openelement/protocol · root

自定义元素声明中记录的一个 CSS part。

OpenElementCssPart
英文源码说明

One documented CSS part of a custom element declaration.

name: string (必填); description?: string (可选)

packages/protocol/src/manifest.ts:38
OpenElementDeclaration接口 · 公开
@openelement/protocol · root

包清单中的自定义元素声明,包括标签名、成员和交付信息。

OpenElementDeclaration
英文源码说明

One custom element declaration in a package manifest: tag, members and delivery metadata.

tagName: string (必填); className?: string (可选); superclassName?: string (可选); attributes?: OpenElementAttribute[] (可选); events?: OpenElementEvent[] (可选); slots?: OpenElementSlot[] (可选); cssParts?: OpenElementCssPart[] (可选); openElement.ssr?: boolean (可选); openElement.dsd?: boolean (可选); openElement.layer?: ComponentLayer (可选); openElement.hydrate?: "load" | "idle" | "visible" | "only" | "none" (可选); openElement.status?: "stable" | "experimental" (可选) — Stability marker from the owning package's manifest policy.; openElement.module?: string (可选); openElement.export?: string (可选); openElement.tailwind?: OpenElementTailwindDeclaration (可选); openElement.root?: "light" | "shadow" | "closed" (可选) — The host root a generated-element declaration was compiled with. Absent for a class declaration (its descriptor owns the root) and for a generated declaration whose sidecar declares none (the descriptor default is light).; openElement.styles?: readonly string[] (可选) — The authored package-relative `.css` specifiers a generated SHADOW host declares, published so a consuming build can emit the sheet and hand its URL to the DSD style-link carrier. Absent when the component declares none; class declarations deliver their sheets through `static styles` instead.; openElement.ssrHostExport?: string (可选) — The compiler-emitted SSR host producer's export name (`<Component>__ssrHost`) for a generated declaration whose root is `shadow`. A consuming build cannot otherwise learn it: the name is the compiler's return-only `ssrHostExport` metadata, and re-deriving it from a naming convention inside the router would be exactly the drift ADR-0182 forbids ("read the compiler's return value, never re-derive i…; description?: string (可选)

packages/protocol/src/manifest.ts:116
OpenElementError类 · 公开
@openelement/protocol · root

框架错误,提供稳定错误码、严重程度、发生阶段和可恢复性。

class OpenElementError extends Error
英文源码说明

Framework error carrying a stable code, severity, phase and recoverability contract.

packages/protocol/src/errors.ts:100
OpenElementErrorOptions接口 · 公开
@openelement/protocol · root

OpenElementError 的构造选项,每个字段都有默认值。

OpenElementErrorOptions
英文源码说明

Constructor options for {@linkcode OpenElementError}; every field is defaulted.

cause?: Error (可选); code?: string (可选); statusCode.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; statusCode.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; statusCode.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; statusCode.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; statusCode.valueOf: () => number (必填) — Returns the primitive value of the specified object.; statusCode.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.; severity?: ErrorSeverity (可选); phase?: ErrorPhase (可选); recoverable?: boolean (可选)

packages/protocol/src/errors.ts:90
OpenElementEvent接口 · 公开
@openelement/protocol · root

自定义元素声明中记录的一个自定义事件。

OpenElementEvent
英文源码说明

One documented custom event of a custom element declaration.

name: string (必填); type?: string (可选); description?: string (可选)

packages/protocol/src/manifest.ts:25
OpenElementExtensions接口 · 公开
@openelement/protocol · root

包清单声明中的 openElement 扩展字段。

OpenElementExtensions
英文源码说明

The openElement-specific extension block of a package manifest declaration.

ssr?: boolean (可选); dsd?: boolean (可选); layer?: ComponentLayer (可选); hydrate?: "load" | "idle" | "visible" | "only" | "none" (可选); status?: "stable" | "experimental" (可选) — Stability marker from the owning package's manifest policy.; module?: string (可选); export?: string (可选); tailwind.required?: boolean (可选); tailwind.sources?: string[] (可选); tailwind.dialect?: "tailwind4" (可选); root?: "light" | "shadow" | "closed" (可选) — The host root a generated-element declaration was compiled with. Absent for a class declaration (its descriptor owns the root) and for a generated declaration whose sidecar declares none (the descriptor default is light).; styles?: readonly string[] (可选) — The authored package-relative `.css` specifiers a generated SHADOW host declares, published so a consuming build can emit the sheet and hand its URL to the DSD style-link carrier. Absent when the component declares none; class declarations deliver their sheets through `static styles` instead.; ssrHostExport?: string (可选) — The compiler-emitted SSR host producer's export name (`<Component>__ssrHost`) for a generated declaration whose root is `shadow`. A consuming build cannot otherwise learn it: the name is the compiler's return-only `ssrHostExport` metadata, and re-deriving it from a naming convention inside the router would be exactly the drift ADR-0182 forbids ("read the compiler's return value, never re-derive i…

packages/protocol/src/manifest.ts:72
OpenElementI18nContextOptions接口 · 公开
@openelement/protocol · root

由 @openelement/i18n 保存到构建上下文的国际化配置。

OpenElementI18nContextOptions
英文源码说明

i18n options stored in the build context by

packages/protocol/src/framework.ts:55
OpenElementNavSection接口 · 公开
@openelement/protocol · root

导航分组,每项包含路径、标签和可选的排序值。

OpenElementNavSection
英文源码说明

Navigation section from

section: string (必填); items: { path: string; label: string; order?: number; }[] (必填)

packages/protocol/src/framework.ts:43
OpenElementPackageManifest接口 · 公开
@openelement/protocol · root

包级组件清单,记录其中声明的组件。

OpenElementPackageManifest
英文源码说明

Package manifest of component declarations (not a Custom Elements Manifest).

schemaVersion: string (必填); packageName: string (必填); version: string (必填); description?: string (可选); author?: string (可选); license?: string (可选); homepage?: string (可选); repository?: string (可选); declarations: OpenElementDeclaration[] (必填)

packages/protocol/src/manifest.ts:129
OpenElementRequestHandler类型 · 公开
@openelement/protocol · root

供运行时适配器和生成入口使用的统一请求处理函数,基于标准 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类型 · 公开
@openelement/protocol · root

应用与构建驱动共享的路由类别。

OpenElementRouteKind
英文源码说明

Host-agnostic route and asset contracts shared by app and build drivers.

packages/protocol/src/app-model.ts:2
OpenElementRouteNode接口 · 公开
@openelement/protocol · root

路由树节点,记录匹配路径、路由类型、源码与模块路径、可选的标签和参数,以及子路由。

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`.

kind: OpenElementRouteKind (必填); path: string (必填); filePath?: string (可选); importPath?: string (可选); tagName?: string (可选); paramNames?: string[] (可选); children?: OpenElementRouteNode[] (可选); meta?: Record<string, unknown> (可选)

packages/protocol/src/app-model.ts:9
OpenElementSlot接口 · 公开
@openelement/protocol · root

自定义元素声明中记录的一个插槽。

OpenElementSlot
英文源码说明

One documented slot of a custom element declaration.

name: string (必填); description?: string (可选)

packages/protocol/src/manifest.ts:32
OpenElementTailwindDeclaration接口 · 公开
@openelement/protocol · root
OpenElementTailwindDeclaration
英文源码说明

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.

required?: boolean (可选); sources?: string[] (可选); dialect?: "tailwind4" (可选)

packages/protocol/src/manifest.ts:65
PageRouteDecl接口 · 公开
@openelement/protocol · root

生成入口描述符中的一条页面路由声明。

PageRouteDecl
英文源码说明

One page route declaration in the generated entry descriptor.

kind: "page" (必填); path: string (必填); varName: string (必填); filePath: string (必填); defaultTagName: string (必填); tagName: string (必填); importPath: string (必填); isDynamic?: boolean (可选); paramNames?: string[] (可选); streamManifest?: StreamRouteManifest (可选); functionPage?: string (可选) — The server function page fact (alpha15 server lane): the exported server function component the route's `export default definePage(Component)` named — compiled into the module by the server component lane. No element class exists to register; both render channels render through the descriptor's render function (the compiled constructor) and feed the same renderer/layout/document wraps.

packages/protocol/src/ssg.ts:172
parseDiagnosticReport函数 · 公开
@openelement/protocol · root

解析线格式中的一份诊断报告。

(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_VERSION常量 · 公开
@openelement/protocol · root

当前包定义的 Part Program 中间表示版本。

2
英文源码说明

The Part Program IR version this package defines (currently v2).

packages/protocol/src/part-program.ts:23
partAnchorEndMarker函数 · 公开
@openelement/protocol · root

序列化程序标记中结束 Part 锚点的注释文本。

(index: number): string
英文源码说明

The comment marker closing a part anchor in serialized program markup.

toString: (radix?: number) => string (必填) — Returns a string representation of an object.; toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; valueOf: () => number (必填) — Returns the primitive value of the specified object.; toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.

packages/protocol/src/part-program.ts:437
partAnchorMarker函数 · 公开
@openelement/protocol · root

初始数据运行时共用的锚点标记内容。

(index: number): string
英文源码说明

Anchor marker payloads shared by seed runtime consumers.

toString: (radix?: number) => string (必填) — Returns a string representation of an object.; toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; valueOf: () => number (必填) — Returns the primitive value of the specified object.; toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.

packages/protocol/src/part-program.ts:432
PartProgram类型 · 公开
@openelement/protocol · root

可序列化的 Part Program v2,用数据表示一个编译后的组件。

PartProgramV2
英文源码说明

The serializable Part Program v2: one compiled component as data.

version: 2 (必填); tag: string (必填); root: ProgramRoot (必填); template: ProgramTreeNode[] (必填); parts: ProgramPart[] (必填); blocks: ProgramBlockRecord[] (必填); dependencies: ProgramDependencyRecord[] (必填); locations: ProgramLocationRecord[] (必填); sourceMap: ProgramSourceMap (必填) — Compile-time provenance. The canonical in-memory artifact always carries it; the serialized module payload omits it (no runtime consumer reads it), so the validator accepts programs with or without it but still verifies it strictly when present.; metadata: CompiledElementMetadata (必填)

packages/protocol/src/part-program.ts:429
PartProgramV2接口 · 公开
@openelement/protocol · root

所有执行模式共享的确定性程序格式。

PartProgramV2
英文源码说明

The one deterministic program consumed by all execution modes.

version: 2 (必填); tag: string (必填); root: ProgramRoot (必填); template: ProgramTreeNode[] (必填); parts: ProgramPart[] (必填); blocks: ProgramBlockRecord[] (必填); dependencies: ProgramDependencyRecord[] (必填); locations: ProgramLocationRecord[] (必填); sourceMap: ProgramSourceMap (必填) — Compile-time provenance. The canonical in-memory artifact always carries it; the serialized module payload omits it (no runtime consumer reads it), so the validator accepts programs with or without it but still verifies it strictly when present.; metadata: CompiledElementMetadata (必填)

packages/protocol/src/part-program.ts:409
PROBLEM_JSON_MEDIA_TYPE常量 · 公开
@openelement/protocol · root

RFC 9457 Problem Details 错误响应使用的媒体类型。

"application/problem+json"
英文源码说明

Media type of the RFC 9457 action error channel (#863).

packages/protocol/src/data.ts:117
ProblemDetails接口 · 公开
@openelement/protocol · root

表单 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.

type: string (必填) — URI reference identifying the problem type; 'about:blank' when none applies.; title: string (必填) — Short human-readable summary (the HTTP reason phrase for 'about:blank').; status.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; status.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; status.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; status.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; status.valueOf: () => number (必填) — Returns the primitive value of the specified object.; status.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.; detail?: string (可选) — Human-readable explanation specific to this occurrence.

packages/protocol/src/data.ts:105
ProgramAttrPart接口 · 公开
@openelement/protocol · root

将信号值写入字符串型 DOM 特性的绑定。

ProgramAttrPart
英文源码说明

String attribute sink bound to a Signal.

k: "attr" (必填); index.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; index.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; index.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; index.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; index.valueOf: () => number (必填) — Returns the primitive value of the specified object.; index.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.; signal: string (必填); name: string (必填); path: number[] (必填); location: ProgramLocation (必填)

packages/protocol/src/part-program.ts:154
ProgramBlockRecord接口 · 公开
@openelement/protocol · root

记录编译程序所追踪的一个动态子树块及其边界。

ProgramBlockRecord
英文源码说明

One block the program tracks: the boundaries of a dynamic subtree.

id: string (必填); index.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; index.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; index.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; index.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; index.valueOf: () => number (必填) — Returns the primitive value of the specified object.; index.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.; kind: "when" | "each" (必填); anchor: string (必填); end: string (必填); source: string (必填)

packages/protocol/src/part-program.ts:342
ProgramBoolPart接口 · 公开
@openelement/protocol · root

将信号值写入布尔型 DOM 特性的绑定。

ProgramBoolPart
英文源码说明

Boolean attribute sink bound to a Signal.

k: "bool" (必填); index.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; index.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; index.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; index.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; index.valueOf: () => number (必填) — Returns the primitive value of the specified object.; index.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.; signal: string (必填); name: string (必填); path: number[] (必填); location: ProgramLocation (必填)

packages/protocol/src/part-program.ts:164
ProgramClassPart接口 · 公开
@openelement/protocol · root

将类名绑定到专用写入目标,明确该绑定对类名的归属。

ProgramClassPart
英文源码说明

Specialized fixed sinks make ownership explicit for class and style text.

k: "class" (必填); index.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; index.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; index.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; index.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; index.valueOf: () => number (必填) — Returns the primitive value of the specified object.; index.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.; signal: string (必填); path: number[] (必填); location: ProgramLocation (必填)

packages/protocol/src/part-program.ts:174
ProgramCondition接口 · 公开
@openelement/protocol · root

`when` 条件绑定中的一个条件子句。

ProgramCondition
英文源码说明

One condition clause of a when part.

signal: string (必填); op: ConditionOperator (必填); value: string | number | boolean (必填)

packages/protocol/src/part-program.ts:246
ProgramDependencyRecord接口 · 公开
@openelement/protocol · root

编译后的模块图记录的一项依赖。

ProgramDependencyRecord
英文源码说明

One module dependency the compiled module graph records.

signal: string (必填); owner: { kind: "part" | "region"; index: number; } (必填); location: string (必填)

packages/protocol/src/part-program.ts:352
ProgramEachPart接口 · 公开
@openelement/protocol · root

读取绑定信号的列表,按列表项重复渲染模板。

ProgramEachPart
英文源码说明

A list part: repeats its template node per item of a bound signal.

k: "each" (必填); index.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; index.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; index.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; index.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; index.valueOf: () => number (必填) — Returns the primitive value of the specified object.; index.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.; signal: string (必填); key: string (必填); field?: string (可选) — Restatement of the item field for single-field templates; omitted when the item template binds multiple fields (each `ival`/`iattrs` slot then carries its own field).; item: ProgramTreeNode[] (必填); itemEvents?: ItemEventBinding[] (可选) — Per-item event bindings (#1556 IR v2): listeners attached to each item.; location: ProgramLocation (必填)

packages/protocol/src/part-program.ts:310
ProgramElementNode接口 · 公开
@openelement/protocol · root

编译程序树中的静态元素节点。

ProgramElementNode
英文源码说明

A static element node of the program tree.

k: "el" (必填); id: string (必填); tag: string (必填); attrs: [string, string][] (必填); iattrs?: [string, string][] (可选) — Per-item attribute slots ([name, itemField]) — valid only inside an `each` item template. At mount/claim time the value resolves from the current item: `true` emits a bare attribute, `false`/`null`/`undefined` omit it, anything else serializes with String().; children: ProgramTreeNode[] (必填)

packages/protocol/src/part-program.ts:90
ProgramErrorCode常量 · 公开
@openelement/protocol · root

Part 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类型 · 公开
@openelement/protocol · root

一次事件绑定所分派的操作。

ProgramEventAction
英文源码说明

The action one event part dispatches.

packages/protocol/src/part-program.ts:217
ProgramEventPart接口 · 公开
@openelement/protocol · root

将 DOM 事件的监听器连接到对应操作的绑定。

ProgramEventPart
英文源码说明

An event binding part: listener wiring between DOM event and action.

k: "event" (必填); index.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; index.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; index.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; index.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; index.valueOf: () => number (必填) — Returns the primitive value of the specified object.; index.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.; event: string (必填); handler: string (必填); action: ProgramEventAction (必填); path: number[] (必填); location: ProgramLocation (必填)

packages/protocol/src/part-program.ts:225
ProgramHtmlPart接口 · 公开
@openelement/protocol · root

接收 `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.

k: "html" (必填); index.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; index.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; index.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; index.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; index.valueOf: () => number (必填) — Returns the primitive value of the specified object.; index.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.; signal: string (必填); path: number[] (必填); location: ProgramLocation (必填)

packages/protocol/src/part-program.ts:199
ProgramItemValueNode接口 · 公开
@openelement/protocol · root
ProgramItemValueNode
英文源码说明

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.

k: "ival" (必填); field: string (必填)

packages/protocol/src/part-program.ts:123
ProgramLocation接口 · 公开
@openelement/protocol · root

由编译器标定的一个动态写入目标或范围锚点的准确位置。

ProgramLocation
英文源码说明

Exact compiler-owned location for one dynamic sink or range anchor.

id: string (必填); kind: "anchor" | "sink" (必填); path: number[] (必填); node?: string (可选)

packages/protocol/src/part-program.ts:76
ProgramLocationRecord类型 · 公开
@openelement/protocol · root

无需读取绑定本身即可核查其标识与位置的记录。

ProgramLocationRecord
英文源码说明

A location record also makes the identity auditable without inspecting parts.

packages/protocol/src/part-program.ts:84
ProgramPart类型 · 公开
@openelement/protocol · root

可由编译程序实例化的各类动态绑定的可辨识联合类型。

ProgramPart
英文源码说明

The discriminated union of dynamic parts a program instantiates.

packages/protocol/src/part-program.ts:328
ProgramPartAnchorNode接口 · 公开
@openelement/protocol · root

标记编译程序树中动态绑定位置的锚点节点。

ProgramPartAnchorNode
英文源码说明

The anchor node marking where a part binds in the tree.

k: "part" (必填); id: string (必填); index.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; index.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; index.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; index.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; index.valueOf: () => number (必填) — Returns the primitive value of the specified object.; index.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.

packages/protocol/src/part-program.ts:112
ProgramPosition接口 · 公开
@openelement/protocol · root

记录绑定相对于锚点的位置,包括偏移、行和列。

ProgramPosition
英文源码说明

Where a part sits relative to its anchor.

offset.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; offset.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; offset.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; offset.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; offset.valueOf: () => number (必填) — Returns the primitive value of the specified object.; offset.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.; line: number (必填); column: number (必填)

packages/protocol/src/part-program.ts:45
ProgramPropPart接口 · 公开
@openelement/protocol · root

将信号值写入 DOM 属性,并保留 `path` 供读取初始数据的代码使用。

ProgramPropPart
英文源码说明

DOM property sink bound to a Signal; `path` is retained for seed consumers.

k: "prop" (必填); index.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; index.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; index.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; index.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; index.valueOf: () => number (必填) — Returns the primitive value of the specified object.; index.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.; signal: string (必填); name: string (必填); path: number[] (必填); location: ProgramLocation (必填)

packages/protocol/src/part-program.ts:144
ProgramRefPart接口 · 公开
@openelement/protocol · root

可序列化的具名引用位置,其引用值由生成的类提供。

ProgramRefPart
英文源码说明

A named ref slot is serializable; the generated class supplies the ref value.

k: "ref" (必填); index.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; index.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; index.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; index.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; index.valueOf: () => number (必填) — Returns the primitive value of the specified object.; index.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.; ref: string (必填); path: number[] (必填); location: ProgramLocation (必填)

packages/protocol/src/part-program.ts:208
ProgramRoot接口 · 公开
@openelement/protocol · root

描述一个编译程序树的根,树可包含元素、绑定锚点或文本。

ProgramRoot
英文源码说明

The root of one program tree: element, part anchor, or text.

id: "root" (必填); kind: RootMode (必填); nodes: string[] (必填)

packages/protocol/src/part-program.ts:29
ProgramSourceKind类型 · 公开
@openelement/protocol · root

标明程序源映射记录所对应的源代码实体类型。

ProgramSourceKind
英文源码说明

The kind of source record a program source map entry carries.

packages/protocol/src/part-program.ts:59
ProgramSourceMap接口 · 公开
@openelement/protocol · root

将源码片段的位置映射到编译器输出的记录。

ProgramSourceMap
英文源码说明

The program source map: authored spans projected onto emitted records.

version: 1 (必填); file: string (必填); records: ProgramSourceRecord[] (必填)

packages/protocol/src/part-program.ts:69
ProgramSourceRange接口 · 公开
@openelement/protocol · root

源码中的半开区间 `[start, end)`,包含起点且排除终点。

ProgramSourceRange
英文源码说明

A half-open [start, end) range into the authored source text.

file: string (必填); start: ProgramPosition (必填); end: ProgramPosition (必填)

packages/protocol/src/part-program.ts:52
ProgramSourceRecord接口 · 公开
@openelement/protocol · root

记录一个生成节点或绑定在源码中的出处。

ProgramSourceRecord
英文源码说明

One source-map record: the authored origin of one emitted node or part.

id: string (必填); kind: ProgramSourceKind (必填); source: ProgramSourceRange (必填)

packages/protocol/src/part-program.ts:62
ProgramStylePart接口 · 公开
@openelement/protocol · root

用于样式的编译绑定。

ProgramStylePart
英文源码说明

A style binding part.

k: "style" (必填); index.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; index.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; index.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; index.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; index.valueOf: () => number (必填) — Returns the primitive value of the specified object.; index.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.; signal: string (必填); path: number[] (必填); location: ProgramLocation (必填)

packages/protocol/src/part-program.ts:183
ProgramTextNode接口 · 公开
@openelement/protocol · root

编译程序树中的静态文本节点。

ProgramTextNode
英文源码说明

A static text node of the program tree.

k: "text" (必填); value: string (必填)

packages/protocol/src/part-program.ts:106
ProgramTextPart接口 · 公开
@openelement/protocol · root

绑定到单个信号的文本插值。

ProgramTextPart
英文源码说明

A text interpolation part bound to one signal.

k: "text" (必填); index.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; index.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; index.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; index.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; index.valueOf: () => number (必填) — Returns the primitive value of the specified object.; index.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.; signal: string (必填); location: ProgramLocation (必填)

packages/protocol/src/part-program.ts:136
ProgramTreeNode类型 · 公开
@openelement/protocol · root

静态程序树节点的可辨识联合类型。

ProgramTreeNode
英文源码说明

The discriminated union of static tree nodes.

packages/protocol/src/part-program.ts:129
ProgramWhenPart接口 · 公开
@openelement/protocol · root

按条件切换模板分支的动态绑定。

ProgramWhenPart
英文源码说明

A conditional part: swaps template branches on a condition.

k: "when" (必填); index.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; index.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; index.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; index.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; index.valueOf: () => number (必填) — Returns the primitive value of the specified object.; index.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.; signal: string (必填); test: ProgramCondition (必填); on: ProgramTreeNode[] (必填); off: ProgramTreeNode[] (必填); location: ProgramLocation (必填)

packages/protocol/src/part-program.ts:279
PropertyValueType类型 · 公开
@openelement/protocol · root

编译属性默认值序列化后所带的值类型标记。

PropertyValueType
英文源码说明

The serialized value-type tag of a compiled property default.

packages/protocol/src/part-program.ts:359
raiseFrameworkError函数 · 公开
@openelement/protocol · root

构造并抛出框架错误,是 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
RAW_TEXT_TAGS常量 · 公开
@openelement/protocol · root

文本内容不可插入为标记的 HTML 元素标签集合。

ReadonlySet<string>
英文源码说明

Elements whose text content must never be interpolated as markup.

packages/protocol/src/forbidden-sinks.ts:38
ReadonlySignal接口 · 公开
@openelement/protocol · root

computed 等派生值使用的只读信号接口。

ReadonlySignal<T>
英文源码说明

Read-only signal protocol used by computed values.

value: T (必填); subscribe: (fn: (value: T) => void) => Unsubscribe (必填); __@[email protected]: () => boolean (必填) — Returns the primitive value of the specified object.

packages/protocol/src/signal.ts:26
RendererDecl接口 · 公开
@openelement/protocol · root

一条页面渲染器模块注册记录。

RendererDecl
英文源码说明

One page renderer module registration.

varName: string (必填); scope: string (必填); importPath: string (必填); depth.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; depth.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; depth.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; depth.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; depth.valueOf: () => number (必填) — Returns the primitive value of the specified object.; depth.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.

packages/protocol/src/ssg.ts:271
RenderError接口 · 公开
@openelement/protocol · root

SSR 流水线报告的一条渲染错误记录。

RenderError
英文源码说明

One render failure record the SSR pipeline reports.

code: string (必填); severity: "error" | "warning" (必填); phase: ErrorPhase (必填); tagName: string (必填); message: string (必填); recoverable: boolean (必填)

packages/protocol/src/render.ts:16
ResolvedLayout类型 · 公开
@openelement/protocol · root

布局计划中一个位置的解析结果,可为 `false`(禁用)或完整声明。

ResolvedLayout
英文源码说明

The resolved layout for one plan slot: disabled (false) or a full declaration.

packages/protocol/src/ssg.ts:312
RootMode类型 · 公开
@openelement/protocol · root

指定编译组件将内容挂载到 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
RouteEntry接口 · 公开
@openelement/protocol · root

扫描后入选的路由,记录 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.

path: string (必填); filePath: string (必填); type: "page" | "api" | "island" | "special" (必填); varName: string (必填); tagName?: string (可选); definePage?: boolean (可选) — True when the route module's default export is a definePage() definition (#960 — registration decoupling). The generated entry registers the page class under the path-derived fallback tag and IGNORES the tagName export for registration: on a definePage route the export only names a content element. Plain element routes keep tagName as their registration tag.; functionPage?: string (可选) — The server function page fact (alpha15 server lane): the exported server function component the route's `export default definePage(Component)` was called over. Present only when the argument is a plain identifier resolving to a component THIS module declares — an inline arrow or an unexported local never records it (the R1 admission rule mirrored, so a shape whose JSX would escape to runtime is n…; source?: string (可选) — Source text captured during scanning when includeSource is enabled.; hasEnhancedForms?: boolean (可选) — True when the page route source carries data-open-enhance (#569): the client entry must ship the form-enhancement layer even when the app has zero islands.; special?: SpecialFileType (可选); params?: string[] (可选)

packages/protocol/src/framework.ts:113
RouteInfoEntry接口 · 公开
@openelement/protocol · root

生成的 SSG 入口模块通过 `routeInfo` 输出的一条路由元数据。

RouteInfoEntry
英文源码说明

A single route metadata entry emitted as `routeInfo` by the generated SSG entry module (see entry-render-ssg.ts).

path: string (必填); filePath?: string (可选) — Route module file path. Read by the render pipeline: ssg-render.ts copies it into server-manifest.json for request-time (renderIntent 'dynamic') routes.; tagName: string (必填); module?: unknown (可选) — The route module namespace object (typed per-module at codegen time).; isDynamic: boolean (必填); paramNames: string[] (必填); rendering?: "static" | "dynamic" (可选) — Rendering mode declared via renderIntent.mode ("static" when unset; the "auto" alias is rejected, #609).; hasAction?: boolean (可选) — True when the route module exports an action (request-time form POST).; streamManifest?: StreamRouteManifest (可选); params?: Record<string, string> (可选)

packages/protocol/src/ssg.ts:395
ROUTER_MODULE_VOCABULARY常量 · 公开
@openelement/protocol · root

路由器传给 analyzeModuleSemantics 的模块扫描识别规则。

readonly ModuleVocabularyDescriptor[]
英文源码说明

The module vocabulary router injects into `analyzeModuleSemantics`.

packages/protocol/src/module-vocabulary.ts:17
RUNTIME_MESSAGES_ENABLED常量 · 公开
@openelement/protocol · root

控制是否保留原始错误消息,生产客户端构建会关闭,其他场景保留。

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
RuntimeAdapter接口 · 公开
@openelement/protocol · root

宿主运行时适配器,向服务器引擎提供接收请求的 `fetch` 处理器。

RuntimeAdapter<Env>
英文源码说明

A host runtime adapter: exposes the fetch handler a server engine dispatches to.

name: string (必填); fetch: OpenElementRequestHandler<Env> (必填); prerender?: (() => AsyncIterable<RuntimePrerenderResult> | Iterable<RuntimePrerenderResult>) (可选)

packages/protocol/src/runtime.ts:32
RuntimeAdapterOptions接口 · 公开
@openelement/protocol · root

构造运行时适配器时传入的选项。

RuntimeAdapterOptions<Env>
英文源码说明

Options one runtime adapter is constructed with.

name: string (必填); fetch: OpenElementRequestHandler<Env> (必填); prerender?: (() => AsyncIterable<RuntimePrerenderResult> | Iterable<RuntimePrerenderResult>) (可选)

packages/protocol/src/runtime.ts:39
RuntimeContext接口 · 公开
@openelement/protocol · root

运行时适配器的上下文契约,用来隔离框架和部署环境。

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.

env?: Env (可选); platform?: unknown (可选); params?: Record<string, string> (可选)

packages/protocol/src/runtime.ts:9
RuntimeErrorCode常量 · 公开
@openelement/protocol · root

编译程序序列化、创建 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
SafeHtml类型 · 公开
@openelement/protocol · root

表示已完成 HTML 转义,可作为文本内容使用的字符串类型。

SafeHtml
英文源码说明

Branded type: a string that has been HTML-escaped (safe for text content)

packages/protocol/src/framework.ts:9
SerializableValue类型 · 公开
@openelement/protocol · root

编译属性的默认值可采用的 JSON 可序列化类型。

SerializableValue
英文源码说明

The JSON-serializable value shape a compiled property default admits.

packages/protocol/src/part-program.ts:36
serializeClientAssetsModule函数 · 公开
@openelement/protocol · root
(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.

entry: string (必填) — The island client entry URL ('' when no client bundle shipped).; islands: Record<string, ClientIslandAsset> (必填) — Compile-time island identity (delivery tag) -> emitted asset.; shared: string[] (必填) — Shared chunk URLs emitted by the client build (JS, neither entry nor island-dedicated).; styles: string[] (必填) — Preloadable island style asset URLs, sorted, base-prefixed. Shadow-component CSS cannot be applied as a document-level stylesheet — it cannot reach shadow trees — so the document channel's only role for these URLs is preload; the sheets themselves are adopted through the sheet adapters.

packages/protocol/src/client-assets.ts:68
serializeDiagnosticReport函数 · 公开
@openelement/protocol · root

将报告序列化为供流或文件读取的一行文本,末尾不含换行。

(report: DiagnosticReport): string
英文源码说明

Serialize a report for the stream/file channel: one line, no trailing newline.

format: "openelement.diagnostics/1" (必填); ok: boolean (必填); diagnostics: DiagnosticEnvelope[] (必填)

packages/protocol/src/diagnostics.ts:114
ServerErrorCode常量 · 公开
@openelement/protocol · root

编译后服务端渲染和 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接口 · 公开
@openelement/protocol · root

请求时渲染和静态站点生成共用的服务端路由上下文。

ServerRouteContext<Env, Platform, Route>
英文源码说明

Canonical request-time/SSG server route context.

request: Request (必填); params: Record<string, string> (必填); env: Env (必填); platform: Platform (必填); responseHeaders: Headers (必填) — Mutable response-only channel merged into the framework response.; route: Route (必填)

packages/protocol/src/data.ts:25
ServerRouteMetadata接口 · 公开
@openelement/protocol · root

动态路由 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().

path: string (必填); filePath: string (必填)

packages/protocol/src/data.ts:19
Signal类型 · 公开
@openelement/protocol · root

接受可写信号或只读信号的 API 所用类型。

Signal<T>
英文源码说明

Alias for APIs that accept either writable or read-only signals.

packages/protocol/src/signal.ts:31
SIGNAL_BRAND常量 · 公开
@openelement/protocol · root

标识当前配置的响应式引擎所创建的信号,供运行时和类型系统识别。

typeof SIGNAL_BRAND
英文源码说明

Runtime/type brand for signals created by the configured reactive engine.

packages/protocol/src/signal.ts:11
SignalEngine接口 · 公开
@openelement/protocol · root

框架内置适配器使用的信号引擎协议。

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).

signal: <T>(initialValue: T) => WritableSignal<T> (必填); computed: <T>(fn: () => T) => ReadonlySignal<T> (必填); effect: (fn: () => void | Unsubscribe) => Unsubscribe (必填)

packages/protocol/src/signal.ts:46
SignalLike接口 · 公开
@openelement/protocol · root

渲染器和绑定接受的最简信号对象接口。

SignalLike<T>
英文源码说明

Minimal signal-like object accepted by renderers and bindings.

value: T (必填); subscribe: (fn: (value: T) => void) => Unsubscribe (必填); __@[email protected]: () => boolean (必填) — Returns the primitive value of the specified object.

packages/protocol/src/signal.ts:14
SpecialFileType类型 · 公开
@openelement/protocol · root

路由扫描器按文件名识别的特殊类型,包括 renderer 和 middleware。

SpecialFileType
英文源码说明

Special file kinds the route scanner recognizes by filename: `renderer` and `middleware`.

packages/protocol/src/framework.ts:79
SpeculationRulesOptions接口 · 公开
@openelement/protocol · root

静态生成后处理使用的 Speculation Rules 配置。

SpeculationRulesOptions
英文源码说明

Speculation Rules configuration for SSG post-processing

prerender?: string[] (可选) — URL patterns to prerender (fully render in background before navigation).; prefetch?: string[] (可选) — URL patterns to prefetch (fetch HTML + resources without rendering).; exclude?: string[] (可选) — URL patterns to exclude from both prefetch and prerender.; eagerness?: "immediate" | "moderate" | "conservative" (可选) — Eagerness level for prerender rules.

packages/protocol/src/ssg.ts:448
SsgBehaviorOptions接口 · 公开
@openelement/protocol · root

面向应用的静态站点生成构建选项。

SsgBehaviorOptions
英文源码说明

User-facing SSG build behavior switches (OpenElementOptions['ssg']).

dynamicRouteFailure?: "fail" | "warn" (可选) — Policy for dynamic-route render failures during SSG. See {@link SsgRenderOptions.dynamicRouteFailure}.

packages/protocol/src/ssg.ts:63
SsgPageOutput接口 · 公开
@openelement/protocol · root

`renderRoute()` 返回的单页渲染诊断结果。

SsgPageOutput
英文源码说明

Per-page render diagnostics returned by renderRoute()

html: string (必填) — Rendered HTML string; status.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; status.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; status.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; status.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; status.valueOf: () => number (必填) — Returns the primitive value of the specified object.; status.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.; redirect?: { location: string; status: number; } (可选) — Redirect outcome (3xx). When set, `html` holds an interim status page and the result must not be persisted as a normal 200 page.; notFound?: boolean (可选) — True when the route signalled not-found (404).; errors: RenderError[] (必填) — Render errors collected during rendering; componentCount: number (必填) — Number of DSD components rendered on this page; renderTimeMs: number (必填) — Total render time for all components on this page (ms)

packages/protocol/src/ssg.ts:368
SsgRenderEvidence接口 · 公开
@openelement/protocol · root

SSG 引擎为每次构建输出的渲染审计记录。

SsgRenderEvidence
英文源码说明

The per-build render evidence record the SSG engine emits for audit.

i18nOptions?: { [key: string]: unknown; locales: string[]; defaultLocale?: string; } | null (可选); admissionDecisions?: SsrAdmissionDecision[] (可选) — SSR admission decisions from the plan that rendered the pages.; manifestBudget.islandKB?: number (可选); manifestBudget.totalJsKB?: number (可选); manifestBudget.pageKB?: number (可选); onPrintBuildManifest?: ((input: { root: string; outDir: string; phase: 3; headExtras?: string; budget?: { islandKB?: number; totalJsKB?: number; pageKB?: number; }; }) => void | Prom… (可选)

packages/protocol/src/ssg.ts:426
SsgRenderOptions接口 · 公开
@openelement/protocol · root

传给共用 SSG 渲染流水线的选项。

SsgRenderOptions
英文源码说明

Options passed to the shared SSG render pipeline.

root: string (必填); outDir: string (必填); base?: string (可选); headExtras?: string (可选); html.lang?: string (可选); html.title?: string (可选); middleware.csp?: { policy?: string; reportOnly?: boolean; nonce?: boolean; } (可选); upgradeStrategy?: "load" | "idle" | "visible" | "only" | "none" (可选); viewTransition?: boolean (可选); speculation?: boolean | Record<string, unknown> (可选); islandTagNames?: string[] (可选); routesDir?: string (可选); dynamicRouteFailure?: "fail" | "warn" (可选) — Policy for dynamic-route render failures (HTTP status >= 500, non-empty render errors, or a renderRoute throw) during SSG. - 'fail' (default): abort the build - a failed page must never ship as a normal 200 page. - 'warn': log the failure and skip the page (the page is not written and is not registered in the ISR manifest).

packages/protocol/src/ssg.ts:36
SsgRenderSummary接口 · 公开
@openelement/protocol · root

`ssgRender()` 返回的一次 SSG 渲染汇总。

SsgRenderSummary
英文源码说明

Summary of an SSG render run, returned by ssgRender().

staticNon200: { path: string; status: number; }[] (必填) — Static routes whose handler returned a non-200 status. hono/ssg drops these responses (defaultPlugin), so they are not written to disk; they are listed here and in the build log instead of disappearing silently.; warnings: string[] (必填) — Non-fatal warnings collected during the SSG run (sitemap generation failures, etc.). Surfaced here so the build summary / release evidence carries them instead of letting them disappear silently.

packages/protocol/src/ssg.ts:72
SSR_REGISTRY_GENERATED_HOSTS常量 · 公开
@openelement/protocol · root
"__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_REGISTRY_ORIGINAL_DEFINE常量 · 公开
@openelement/protocol · root

标识 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_REGISTRY_STUB_MARKER常量 · 公开
@openelement/protocol · root

在 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
SsrAdmissionDecision接口 · 公开
@openelement/protocol · root

构建对自定义元素的 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.

tagName: string (必填); modulePath: string (必填) — Module path of the island declaration. Empty for 'foreign' decisions: a foreign tag is consumed in JSX but declares no module the build owns.; source: "local" | "package" | "nested" | "foreign" (必填) — 'foreign' (#979): a third-party WC tag discovered by the foreign-tag scanner in page/island JSX — recorded for visibility only; SSR still treats it as an opaque passthrough (renderPath 'client-only').; renderPath: "client-only" | "rejected" | "ssr+client" (必填); reason: string (必填)

packages/protocol/src/render.ts:37
SsrAdmissionPlan接口 · 公开
@openelement/protocol · root

构建时按组件标签记录的 SSR 准入决策。

SsrAdmissionPlan
英文源码说明

The build-time SSR admission decisions per component tag.

renderableTags: string[] (必填); clientOnlyTags: string[] (必填); rejectedTags: string[] (必填); reasons: Record<string, string> (必填); decisions: SsrAdmissionDecision[] (必填); cemClassifications?: CompatibilityClassification[] (可选); foreignTags?: string[] (可选) — #979: foreign custom-element tags discovered in page / island JSX that are neither local islands, package-manifest islands, nor openElement-authored elements. Visibility only — each tag also carries a source:'foreign' decision (renderPath 'client-only') and the SSR/behavior is unchanged (opaque passthrough).

packages/protocol/src/ssg.ts:253
SsrBundle接口 · 公开
@openelement/protocol · root

SSG 引擎执行流式渲染时读取的服务端包信息。

SsrBundle
英文源码说明

The server bundle facts the SSG engine consumes for stream rendering.

packages/protocol/src/ssg.ts:417
STATIC_STYLES_MARKER常量 · 公开
@openelement/protocol · root
"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
StaticComponentDecl接口 · 公开
@openelement/protocol · root

从路由的本地导入图发现的静态编译组件声明,供构建纳入递归 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.

tagName: string (必填); modulePath: string (必填); compilerInteractionEvents: string[] (必填) — Compiler-owned interaction events; empty means no inferred browser entry.; generatedHostExport?: string (可选) — The compiler-emitted SSR host producer export (`<Name>__ssrHost`) when this static component belongs to the GENERATED lane, or absent for a class. Same fact, same rule as {@linkcode LayoutDecl.generatedHostExport}: a generated component carries no Part Program, so a class-only registration fails every render with PROGRAM_MISSING. The entry therefore registers the generated host PAIR. The name is …; root?: "light" | "shadow" | "closed" (可选) — The descriptor root a page-local GENERATED component declares (P-2, 2026-11-21). A shadow root's class candidates need the shared COMPONENT stylesheet linked inside the DSD template; a light root's belong to the document sheet. Absent for a class component (its `static styles` scope carries the same fact).; pageComponent?: boolean (可选) — True when this record is a PAGE COMPONENT (the module a route passes to `definePage`), not a nested component. A page root is rendered by the route handler, so the entry must register its host pair even though no JSX reference to the tag exists anywhere.; pageComponentDependency?: boolean (可选) — A generated host reached through a page component’s side-effect imports.

packages/protocol/src/ssg.ts:217
StaticSidecarDescriptor接口 · 公开
@openelement/protocol · root

告诉元素编译器哪一项与组件放在同一模块的声明属于静态策略。

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).

moduleSpecifier: string (必填) — Canonical module specifier the sidecar export must be imported from.; exportName: string (必填) — Exported name of the sidecar factory binding.; kind: "static-sidecar" (必填) — The admission granted: a colocated static policy statement.

packages/protocol/src/module-descriptors.ts:16
StrategySource类型 · 公开
@openelement/protocol · root

交互岛最终采用的 hydration 策略的来源。

StrategySource
英文源码说明

Where an island's resolved hydration strategy came from.

packages/protocol/src/framework.ts:32
STREAM_FRAME_FORBIDDEN_TAGS常量 · 公开
@openelement/protocol · root

浏览器拒绝装入所属 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
STREAM_FRAME_UNSAFE_URL常量 · 公开
@openelement/protocol · root

流式片段的 URL 属性不可使用的协议。

RegExp
英文源码说明

Schemes that make a URL attribute unsafe in a streamed frame.

packages/protocol/src/stream-frame-policy.ts:60
STREAM_FRAME_URL_ATTRIBUTES常量 · 公开
@openelement/protocol · root

流式片段中需要检查 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
STREAM_FRAME_URL_CONTROL_MAX常量 · 公开
@openelement/protocol · root

检查 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
STREAM_MAX_FIELDS常量 · 公开
@openelement/protocol · root

一个流式路由允许在清单中声明的延迟字段数上限。

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
STREAM_MAX_OWNERS常量 · 公开
@openelement/protocol · root

一个流式路由清单可以引用的 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
STREAM_MAX_PAYLOAD_LENGTH常量 · 公开
@openelement/protocol · root

流式载荷的最大序列化长度,以 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
STREAM_MAX_SEED_PROPERTIES常量 · 公开
@openelement/protocol · root

流式 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
STREAM_TIMEOUT_MS常量 · 公开
@openelement/protocol · root

流式响应等待延迟字段完成的时间上限(毫秒)。

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接口 · 公开
@openelement/protocol · root

构建时绑定到某个编译页面程序的路由信息。

StreamRouteManifest
英文源码说明

Build-only route projection bound to a specific compiled page program.

program: { version: number; tag: string; sha256: string; } (必填); fields: { field: string; signal: string; owners: Array<{ kind: "part" | "region"; index: number; location: string; source: PartProgramV2["sourceMap"]["records"][number… (必填)

packages/protocol/src/ssg.ts:13
STYLE_SHEET_LIVE常量 · 公开
@openelement/protocol · root

用来标记可在开发期间热更新的样式表资源的键。

"__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
STYLE_SHEET_READY常量 · 公开
@openelement/protocol · root
"__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
STYLE_SHEET_URL常量 · 公开
@openelement/protocol · root
"__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
StyleErrorCode常量 · 公开
@openelement/protocol · root

客户端应用编译样式失败时使用的错误码。

{ 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
StyleSheetLike接口 · 公开
@openelement/protocol · root

原生样式表与兼容实现共用的最小接口,包括 replaceSync 和 cssRules。

StyleSheetLike
英文源码说明

Minimal stylesheet contract (replaceSync + cssRules) satisfied by native and shim sheets.

replaceSync: (text: string) => void (必填); cssRules: StyleSheetRule[] (必填)

packages/protocol/src/style-sheet.ts:14
StyleSheetRule接口 · 公开
@openelement/protocol · root

浏览器与 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().

cssText: string (必填)

packages/protocol/src/style-sheet.ts:9
UnsafeHtml类型 · 公开
@openelement/protocol · root

标识尚未转义、未被信任的 HTML 字符串。

UnsafeHtml
英文源码说明

Branded type: a string that is intentionally raw/untrusted HTML

packages/protocol/src/framework.ts:12
unsafeStreamFrameAttribute函数 · 公开
@openelement/protocol · root

判断 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类型 · 公开
@openelement/protocol · root

订阅和响应式副作用返回的取消订阅函数。

Unsubscribe
英文源码说明

Unsubscribe function returned by subscriptions and effects.

packages/protocol/src/signal.ts:8
validatePartProgram函数 · 公开
@openelement/protocol · root

校验数据是否符合 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
VOID_TAGS常量 · 公开
@openelement/protocol · root

由编译器、序列化器与校验器共用的 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
WritableSignal接口 · 公开
@openelement/protocol · root

openElement 集成使用的可写信号协议。

WritableSignal<T>
英文源码说明

Writable signal protocol used by openElement integrations.

value: T (必填); subscribe: (fn: (value: T) => void) => Unsubscribe (必填); __@[email protected]: () => boolean (必填) — Returns the primitive value of the specified object.

packages/protocol/src/signal.ts:21
OpenElementRouteKind类型 · 公开
@openelement/protocol · ./app-model

应用与构建驱动共享的路由类别。

OpenElementRouteKind
英文源码说明

Host-agnostic route and asset contracts shared by app and build drivers.

packages/protocol/src/app-model.ts:2
OpenElementRouteNode接口 · 公开
@openelement/protocol · ./app-model

路由树节点,记录匹配路径、路由类型、源码与模块路径、可选的标签和参数,以及子路由。

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`.

kind: OpenElementRouteKind (必填); path: string (必填); filePath?: string (可选); importPath?: string (可选); tagName?: string (可选); paramNames?: string[] (可选); children?: OpenElementRouteNode[] (可选); meta?: Record<string, unknown> (可选)

packages/protocol/src/app-model.ts:9
ClientAssetManifest接口 · 公开
@openelement/protocol · ./client-assets

客户端构建的交付清单,以交互岛标识为索引。

ClientAssetManifest
英文源码说明

The Phase 2 client build's delivery manifest, keyed by island identity.

entry: string (必填) — The island client entry URL ('' when no client bundle shipped).; islands: Record<string, ClientIslandAsset> (必填) — Compile-time island identity (delivery tag) -> emitted asset.; shared: string[] (必填) — Shared chunk URLs emitted by the client build (JS, neither entry nor island-dedicated).; styles: string[] (必填) — Preloadable island style asset URLs, sorted, base-prefixed. Shadow-component CSS cannot be applied as a document-level stylesheet — it cannot reach shadow trees — so the document channel's only role for these URLs is preload; the sheets themselves are adopted through the sheet adapters.

packages/protocol/src/client-assets.ts:36
ClientIslandAsset接口 · 公开
@openelement/protocol · ./client-assets

一个编译期交互岛标识对应的客户端资源。

ClientIslandAsset
英文源码说明

The client asset one compile-time island identity resolves to.

file: string (必填) — Emitted asset URL (site-root relative, base-prefixed) of the chunk that carries the island module — its dedicated chunk, a shared chunk, or the client entry when the island has no chunk of its own.; strategy: IslandDeliveryStrategy (必填) — Delivery strategy resolved from the island declaration at build time.; preload?: boolean (可选) — True when the island's delivery strategy hydrates at load time, so the asset is a modulepreload candidate.

packages/protocol/src/client-assets.ts:19
EMPTY_CLIENT_ASSET_MANIFEST常量 · 公开
@openelement/protocol · ./client-assets

没有客户端包的项目使用的资源清单。

ClientAssetManifest
英文源码说明

The manifest a project without a client bundle carries.

packages/protocol/src/client-assets.ts:54
serializeClientAssetsModule函数 · 公开
@openelement/protocol · ./client-assets
(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.

entry: string (必填) — The island client entry URL ('' when no client bundle shipped).; islands: Record<string, ClientIslandAsset> (必填) — Compile-time island identity (delivery tag) -> emitted asset.; shared: string[] (必填) — Shared chunk URLs emitted by the client build (JS, neither entry nor island-dedicated).; styles: string[] (必填) — Preloadable island style asset URLs, sorted, base-prefixed. Shadow-component CSS cannot be applied as a document-level stylesheet — it cannot reach shadow trees — so the document channel's only role for these URLs is preload; the sheets themselves are adopted through the sheet adapters.

packages/protocol/src/client-assets.ts:68
Action类型 · 公开
@openelement/protocol · ./data

处理页面路由的表单提交。

Action<T, Env, Platform, Route>
英文源码说明

Route action: handles form submissions for a page route.

packages/protocol/src/data.ts:64
ACTION_FETCH_HEADER常量 · 公开
@openelement/protocol · ./data

选择表单 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
ActionContext接口 · 公开
@openelement/protocol · ./data

传给路由 action 的上下文,包含 loader 上下文。

ActionContext<Env, Platform, Route>
英文源码说明

Context passed to a route action function (extends loader context).

formData: FormData (必填); request: Request (必填); params: Record<string, string> (必填); env: Env (必填); platform: Platform (必填); responseHeaders: Headers (必填) — Mutable response-only channel merged into the framework response.; route: Route (必填)

packages/protocol/src/data.ts:47
ActionResult类型 · 公开
@openelement/protocol · ./data

脚本提交表单时返回的联合类型。校验失败返回 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类型 · 公开
@openelement/protocol · ./data

为页面路由获取数据的 loader。

Loader<T, Env, Platform, Route>
英文源码说明

Route loader: fetches data for a page route.

packages/protocol/src/data.ts:56
LoaderContext接口 · 公开
@openelement/protocol · ./data

传给动态路由 loader 的请求上下文。

LoaderContext<Env, Platform, Route>
英文源码说明

Context passed to a request-time ('dynamic') route loader.

request: Request (必填); params: Record<string, string> (必填); env: Env (必填); platform: Platform (必填); responseHeaders: Headers (必填) — Mutable response-only channel merged into the framework response.; route: Route (必填)

packages/protocol/src/data.ts:40
PROBLEM_JSON_MEDIA_TYPE常量 · 公开
@openelement/protocol · ./data

RFC 9457 Problem Details 错误响应使用的媒体类型。

"application/problem+json"
英文源码说明

Media type of the RFC 9457 action error channel (#863).

packages/protocol/src/data.ts:117
ProblemDetails接口 · 公开
@openelement/protocol · ./data

表单 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.

type: string (必填) — URI reference identifying the problem type; 'about:blank' when none applies.; title: string (必填) — Short human-readable summary (the HTTP reason phrase for 'about:blank').; status.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; status.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; status.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; status.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; status.valueOf: () => number (必填) — Returns the primitive value of the specified object.; status.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.; detail?: string (可选) — Human-readable explanation specific to this occurrence.

packages/protocol/src/data.ts:105
ServerRouteContext接口 · 公开
@openelement/protocol · ./data

请求时渲染和静态站点生成共用的服务端路由上下文。

ServerRouteContext<Env, Platform, Route>
英文源码说明

Canonical request-time/SSG server route context.

request: Request (必填); params: Record<string, string> (必填); env: Env (必填); platform: Platform (必填); responseHeaders: Headers (必填) — Mutable response-only channel merged into the framework response.; route: Route (必填)

packages/protocol/src/data.ts:25
ServerRouteMetadata接口 · 公开
@openelement/protocol · ./data

动态路由 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().

path: string (必填); filePath: string (必填)

packages/protocol/src/data.ts:19
DIAGNOSTIC_REPORT_FORMAT常量 · 公开
@openelement/protocol · ./diagnostics

用于识别诊断报告格式的 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:84
DiagnosticEnvelope接口 · 公开
@openelement/protocol · ./diagnostics
DiagnosticEnvelope
英文源码说明

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.

code: string (必填) — The producer's own stable code (`OEC9020`, `OE_PRESET_*`, `OE_SSG_*`).; severity: DiagnosticSeverity (必填); phase: DiagnosticPhase (必填); message: string (必填) — What happened, in the producer's own words.; file?: string (可选) — The source file (or module specifier) the diagnostic points at.; line.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; line.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; line.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; line.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; line.valueOf: () => number (必填) — Returns the primitive value of the specified object.; line.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.; column?: number (可选) — 1-based authored column, when the producer has a source location.; hint?: string (可选) — The fix, when the producer can name one.

packages/protocol/src/diagnostics.ts:60
DiagnosticPhase类型 · 公开
@openelement/protocol · ./diagnostics
DiagnosticPhase
英文源码说明

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
diagnosticReport函数 · 公开
@openelement/protocol · ./diagnostics

组装构建退出报告。只要一个诊断的严重级别为 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:105
DiagnosticReport接口 · 公开
@openelement/protocol · ./diagnostics
DiagnosticReport
英文源码说明

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.

format: "openelement.diagnostics/1" (必填); ok: boolean (必填); diagnostics: DiagnosticEnvelope[] (必填)

packages/protocol/src/diagnostics.ts:95
DiagnosticReportFormat类型 · 公开
@openelement/protocol · ./diagnostics

诊断报告 format 字段使用的格式标识类型。

"openelement.diagnostics/1"
英文源码说明

One format tag value (kept as a type for the report's `format` field).

packages/protocol/src/diagnostics.ts:87
DiagnosticReportParseError类 · 公开
@openelement/protocol · ./diagnostics

parseDiagnosticReport 发现文本不是可读取的诊断报告时抛出的错误。

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
DiagnosticSeverity类型 · 公开
@openelement/protocol · ./diagnostics

区分导致构建失败的 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
errorToEnvelope函数 · 公开
@openelement/protocol · ./diagnostics

将 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`.

code: string (必填); severity: ErrorSeverity (必填); phase: ErrorPhase (必填); recoverable: boolean (必填); statusCode.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; statusCode.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; statusCode.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; statusCode.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; statusCode.valueOf: () => number (必填) — Returns the primitive value of the specified object.; statusCode.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.; toJSON: () => Record<string, unknown> (必填); name: string (必填); message: string (必填); stack?: string (可选); cause?: unknown (可选)

packages/protocol/src/diagnostics.ts:256
parseDiagnosticReport函数 · 公开
@openelement/protocol · ./diagnostics

解析线格式中的一份诊断报告。

(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
serializeDiagnosticReport函数 · 公开
@openelement/protocol · ./diagnostics

将报告序列化为供流或文件读取的一行文本,末尾不含换行。

(report: DiagnosticReport): string
英文源码说明

Serialize a report for the stream/file channel: one line, no trailing newline.

format: "openelement.diagnostics/1" (必填); ok: boolean (必填); diagnostics: DiagnosticEnvelope[] (必填)

packages/protocol/src/diagnostics.ts:114
AuthoringErrorCode常量 · 公开
@openelement/protocol · ./errors

编写组件的属性或声明时可能遇到的校验错误码。

{ 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
ClaimErrorCode常量 · 公开
@openelement/protocol · ./errors

现有 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
CompilerErrorCode常量 · 公开
@openelement/protocol · ./errors

编译期间使用的错误码。

{ 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
ContextErrorCode常量 · 公开
@openelement/protocol · ./errors

Context Community Protocol 服务的生命周期错误码,发生在 csr 阶段。

{ readonly SERVICE_DISPOSED: "OE_CONTEXT_SERVICE_DISPOSED"; }
英文源码说明

Community-context service lifecycle failures (phase `csr`).

packages/protocol/src/errors.ts:233
DEFAULT_RENDER_ERROR_CODE常量 · 公开
@openelement/protocol · ./errors

RenderError 使用的默认错误码。

"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
EachKeyErrorCode常量 · 公开
@openelement/protocol · ./errors

带键列表无法确定条目身份时使用的错误码。

{ 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
ERROR_PREFIX常量 · 公开
@openelement/protocol · ./errors

openElement 错误消息使用的前缀。

"[openElement]"
英文源码说明

Error message prefix for all openElement errors.

packages/protocol/src/errors.ts:50
ErrorCode常量 · 公开
@openelement/protocol · ./errors

常用错误码常量。调用方也可以传入字符串错误码。

{ 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类型 · 公开
@openelement/protocol · ./errors

发生错误时所在的执行阶段。

ErrorPhase
英文源码说明

The pipeline phase an error was raised in.

packages/protocol/src/errors.ts:80
ErrorSeverity类型 · 公开
@openelement/protocol · ./errors

框架错误的严重程度。

ErrorSeverity
英文源码说明

How severe a framework error is.

packages/protocol/src/errors.ts:78
ErrorTelemetryHook类型 · 公开
@openelement/protocol · ./errors

接收所有通过错误遥测渠道上报的 OpenElementError。

ErrorTelemetryHook
英文源码说明

Callback receiving every reported {@linkcode OpenElementError} for telemetry.

packages/protocol/src/errors.ts:132
FacadeErrorCode常量 · 公开
@openelement/protocol · ./errors

公开入口在 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
frameworkError函数 · 公开
@openelement/protocol · ./errors

创建 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
KernelErrorCode常量 · 公开
@openelement/protocol · ./errors

自定义元素在客户端运行期间违反内核生命周期契约时使用的错误码。

{ 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
OpenElementError类 · 公开
@openelement/protocol · ./errors

框架错误,提供稳定错误码、严重程度、发生阶段和可恢复性。

class OpenElementError extends Error
英文源码说明

Framework error carrying a stable code, severity, phase and recoverability contract.

packages/protocol/src/errors.ts:100
OpenElementErrorOptions接口 · 公开
@openelement/protocol · ./errors

OpenElementError 的构造选项,每个字段都有默认值。

OpenElementErrorOptions
英文源码说明

Constructor options for {@linkcode OpenElementError}; every field is defaulted.

cause?: Error (可选); code?: string (可选); statusCode.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; statusCode.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; statusCode.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; statusCode.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; statusCode.valueOf: () => number (必填) — Returns the primitive value of the specified object.; statusCode.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.; severity?: ErrorSeverity (可选); phase?: ErrorPhase (可选); recoverable?: boolean (可选)

packages/protocol/src/errors.ts:90
ProgramErrorCode常量 · 公开
@openelement/protocol · ./errors

Part 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
raiseFrameworkError函数 · 公开
@openelement/protocol · ./errors

构造并抛出框架错误,是 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
RUNTIME_MESSAGES_ENABLED常量 · 公开
@openelement/protocol · ./errors

控制是否保留原始错误消息,生产客户端构建会关闭,其他场景保留。

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
RuntimeErrorCode常量 · 公开
@openelement/protocol · ./errors

编译程序序列化、创建 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
ServerErrorCode常量 · 公开
@openelement/protocol · ./errors

编译后服务端渲染和 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
StyleErrorCode常量 · 公开
@openelement/protocol · ./errors

客户端应用编译样式失败时使用的错误码。

{ 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
camelToKebab函数 · 公开
@openelement/protocol · ./forbidden-sinks
(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
FORBIDDEN_ATTRIBUTE_NAMES常量 · 公开
@openelement/protocol · ./forbidden-sinks
ReadonlySet<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
FORBIDDEN_PROPERTY_NAMES常量 · 公开
@openelement/protocol · ./forbidden-sinks

编译器不允许用作 @property 声明的属性名集合。

ReadonlySet<string>
英文源码说明

Property names the compiler refuses as

packages/protocol/src/forbidden-sinks.ts:31
ForbiddenSinkKind类型 · 公开
@openelement/protocol · ./forbidden-sinks

统一禁用规则检查的写入目标类别。

ForbiddenSinkKind
英文源码说明

Sink categories the canonical deny list classifies.

packages/protocol/src/forbidden-sinks.ts:41
forbiddenSinkReason函数 · 公开
@openelement/protocol · ./forbidden-sinks

返回指定类别下某名称不允许写入的原因,名称可用时返回 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
isSafeAttributeName函数 · 公开
@openelement/protocol · ./forbidden-sinks

统一检查属性名称是否符合安全规则。

(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
RAW_TEXT_TAGS常量 · 公开
@openelement/protocol · ./forbidden-sinks

文本内容不可插入为标记的 HTML 元素标签集合。

ReadonlySet<string>
英文源码说明

Elements whose text content must never be interpolated as markup.

packages/protocol/src/forbidden-sinks.ts:38
CompatibilityClassification接口 · 公开
@openelement/protocol · ./framework

兼容性扫描为每个标签记录分级、原因、来源和对应的 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.

tagName: string (必填); tier: CompatibilityTier (必填); reason: string (必填); source: "local" | "package" | "nested" (必填); modulePath?: string (可选); ssr?: boolean (可选); dsd?: boolean (可选); hydrate?: string (可选)

packages/protocol/src/framework.ts:347
CompatibilityTier类型 · 公开
@openelement/protocol · ./framework

标签的构建兼容级别,区分服务端渲染、仅浏览器渲染、实验支持和拒绝构建。

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
ComponentLayer类型 · 公开
@openelement/protocol · ./framework

组件的交付层级,区分静态 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
FrameworkOptions接口 · 公开
@openelement/protocol · ./framework
FrameworkOptions
英文源码说明

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.

renderer?: "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).; routesDir?: string (可选) — Directory the route scanner walks, relative to the Vite root. Defaults to `app/routes`.; islandsDir?: string (可选) — Directory island modules are discovered in. Defaults to `app/islands`.; packageIslands?: 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…; layout?: LayoutConfig (可选) — Layout declaration; `false` disables the layout, `'default'` uses the built-in one.; layouts?: LayoutsConfig (可选) — Named layout declarations keyed by layout name.; headExtras?: string (可选) — @dangerous injected as-is, only use with controlled content; html.lang?: string (可选); html.title?: string (可选); inject.stylesheets?: (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.; inject.scripts?: (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.; inject.headFragments?: 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>`.; ssr.noExternal?: (string | RegExp)[] (可选); island.upgradeStrategy?: "load" | "idle" | "visible" | "only" | "none" (可选); build.outDir?: string (可选) — Output directory for the build artifacts. Defaults to `dist`.; build.manifestBudget?: { 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.; viewTransition?: boolean (可选) — Enable the View Transitions API for client navigations. Defaults to true.; speculation?: 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.; middleware.cors?: boolean (可选) — Built-in CORS middleware. Default-ON; pass `false` to disable.; middleware.corsOrigin?: string | string[] (可选) — Static CORS allowlist data, serialized into the generated entry as JSON. Mutually exclusive with {@link FrameworkOptions.middleware.corsOriginModule }.; middleware.corsOriginModule?: string (可选) — Path 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`.; middleware.requestId?: boolean (可选) — Emit and honor a per-request id header. Default-ON; pass `false` to disable.; middleware.logger?: boolean (可选) — Log each request through the built-in logger. Default-ON; pass `false` to disable.; middleware.securityHeaders?: boolean (可选) — Attach the built-in security response headers. Default-ON; pass `false` to disable.; middleware.csp?: { policy?: string; nonce?: boolean; reportOnly?: boolean; } (可选) — Content-Security-Policy emission: the policy string, nonce generation, and report-only mode.; middleware.use?: 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…

packages/protocol/src/framework.ts:180
HYDRATION_STRATEGIES常量 · 公开
@openelement/protocol · ./framework

运行时支持的 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
HydrationStrategy类型 · 公开
@openelement/protocol · ./framework

控制交互岛何时启用,也可跳过浏览器 hydration。

"load" | "idle" | "visible" | "only" | "none"
英文源码说明

Island hydration trigger: 'load' | 'idle' | 'visible' | 'only'.

packages/protocol/src/framework.ts:30
LayoutConfig类型 · 公开
@openelement/protocol · ./framework

为路由选择内置布局、指定自定义布局及其模块和属性,或关闭布局。

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接口 · 公开
@openelement/protocol · ./framework

随语言解析的路径契约。

LocalePath
英文源码说明

Locale-aware resolved path contract.

locale: string (必填); path: string (必填); localizedPath: string (必填); isDefaultLocalePath: boolean (必填)

packages/protocol/src/framework.ts:82
Middleware类型 · 公开
@openelement/protocol · ./framework

基于标准 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
OpenElementBlogOptions接口 · 公开
@openelement/protocol · ./framework

构建上下文中可选的博客内容目录和 URL 基础路径。

OpenElementBlogOptions
英文源码说明

Blog options stored in the build context by

contentDir?: string (可选); basePath?: string (可选)

packages/protocol/src/framework.ts:37
OpenElementBuildContextLike接口 · 公开
@openelement/protocol · ./framework

供子插件使用的最小构建上下文接口。

OpenElementBuildContextLike
英文源码说明

Minimal build context interface that sub-plugins can use.

plugins: { [key: string]: unknown; blogOptions: OpenElementBlogOptions | null; navSections: OpenElementNavSection[]; headerNav: OpenElementHeaderNavLink[]; sitemapOptio… (必填); registerPlugin: (name: string, instance: unknown) => void (必填) — Register plugin data by name. Protocol level uses loose typing; concrete implementations should tighten the generic constraint.

packages/protocol/src/framework.ts:62
OpenElementI18nContextOptions接口 · 公开
@openelement/protocol · ./framework

由 @openelement/i18n 保存到构建上下文的国际化配置。

OpenElementI18nContextOptions
英文源码说明

i18n options stored in the build context by

packages/protocol/src/framework.ts:55
OpenElementNavSection接口 · 公开
@openelement/protocol · ./framework

导航分组,每项包含路径、标签和可选的排序值。

OpenElementNavSection
英文源码说明

Navigation section from

section: string (必填); items: { path: string; label: string; order?: number; }[] (必填)

packages/protocol/src/framework.ts:43
RouteEntry接口 · 公开
@openelement/protocol · ./framework

扫描后入选的路由,记录 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.

path: string (必填); filePath: string (必填); type: "page" | "api" | "island" | "special" (必填); varName: string (必填); tagName?: string (可选); definePage?: boolean (可选) — True when the route module's default export is a definePage() definition (#960 — registration decoupling). The generated entry registers the page class under the path-derived fallback tag and IGNORES the tagName export for registration: on a definePage route the export only names a content element. Plain element routes keep tagName as their registration tag.; functionPage?: string (可选) — The server function page fact (alpha15 server lane): the exported server function component the route's `export default definePage(Component)` was called over. Present only when the argument is a plain identifier resolving to a component THIS module declares — an inline arrow or an unexported local never records it (the R1 admission rule mirrored, so a shape whose JSX would escape to runtime is n…; source?: string (可选) — Source text captured during scanning when includeSource is enabled.; hasEnhancedForms?: boolean (可选) — True when the page route source carries data-open-enhance (#569): the client entry must ship the form-enhancement layer even when the app has zero islands.; special?: SpecialFileType (可选); params?: string[] (可选)

packages/protocol/src/framework.ts:113
SafeHtml类型 · 公开
@openelement/protocol · ./framework

表示已完成 HTML 转义,可作为文本内容使用的字符串类型。

SafeHtml
英文源码说明

Branded type: a string that has been HTML-escaped (safe for text content)

packages/protocol/src/framework.ts:9
SpecialFileType类型 · 公开
@openelement/protocol · ./framework

路由扫描器按文件名识别的特殊类型,包括 renderer 和 middleware。

SpecialFileType
英文源码说明

Special file kinds the route scanner recognizes by filename: `renderer` and `middleware`.

packages/protocol/src/framework.ts:79
StrategySource类型 · 公开
@openelement/protocol · ./framework

交互岛最终采用的 hydration 策略的来源。

StrategySource
英文源码说明

Where an island's resolved hydration strategy came from.

packages/protocol/src/framework.ts:32
UnsafeHtml类型 · 公开
@openelement/protocol · ./framework

标识尚未转义、未被信任的 HTML 字符串。

UnsafeHtml
英文源码说明

Branded type: a string that is intentionally raw/untrusted HTML

packages/protocol/src/framework.ts:12
IslandOptions接口 · 公开
@openelement/protocol · ./island

交互岛的交付选项,包括 hydration 策略和是否参与 SSR 或 DSD。

IslandOptions
英文源码说明

Per-island delivery options (hydration strategy, SSR/DSD participation).

hydrate?: "load" | "idle" | "visible" | "only" | "none" (可选) — Hydration strategy: - 'load': load immediately when module is imported - 'idle': defer to requestIdleCallback (default) - 'visible': use IntersectionObserver to defer until element is visible - 'only': client-only render, no DSD/SSR output Named `hydrate` to match `defineIslandConfig()` in the Router package — one option name across both packages.; dsd?: boolean (可选) — Whether to use DSD for SSR rendering of this island. Honored by the build-side island scan (via `defineIslandConfig`), not by `defineIsland()` itself: passing it in `IslandOptions` has no runtime effect.; ssr?: boolean (可选) — Whether this island may be admitted into server rendering. Like `dsd`, decided by the build-side island scan; inert when passed to `defineIsland()`.

packages/protocol/src/island.ts:8
IslandTransformOptions接口 · 公开
@openelement/protocol · ./island

构建时转换交互岛源码所用的选项。

IslandTransformOptions
英文源码说明

Options for the build-time island source transform.

islandsDir: string (必填) — Directory containing island files (e.g. "app/islands"); filePath: string (必填) — Absolute or relative file path of the source being processed; layout?: { path: string; tagName: string; } (可选) — Layout-convention admission (alpha15 R batch 3): the resolved layout module the router convention owns (`app/layout.tsx`, tag `app-layout`, or a project-relative custom `layout: { import }` override). The gate admits this one path with its resolved tag even though it lives outside `islandsDir`. Absent when the project configures no layout module (`layout: false`, or the deletable convention file …

packages/protocol/src/island.ts:42
IslandTransformResult接口 · 公开
@openelement/protocol · ./island

交互岛转换的结果,包括改写的源码和提取的信息。

IslandTransformResult
英文源码说明

The island transform output: rewritten source plus extracted facts.

code: string (必填) — Transformed source code with markers; islands: { tagName: string; filePath: string; }[] (必填) — Detected island entries; map?: string (可选) — Optional source map

packages/protocol/src/island.ts:64
ISLAND_ADMISSION常量 · 公开
@openelement/protocol · ./island-admission

路由器交给元素编译器的静态配置识别描述符。

StaticSidecarDescriptor
英文源码说明

The static-sidecar descriptor router injects into the element compiler.

packages/protocol/src/island-admission.ts:18
CemCompatibilityReport接口 · 公开
@openelement/protocol · ./manifest

针对一份自定义元素清单的兼容性分类报告。

CemCompatibilityReport
英文源码说明

The compatibility classification report for one custom element manifest.

totalClassified.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; totalClassified.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; totalClassified.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; totalClassified.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; totalClassified.valueOf: () => number (必填) — Returns the primitive value of the specified object.; totalClassified.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.; ssrCapableCount: number (必填); clientOnlyCount: number (必填); rejectedCount: number (必填); experimentalDomCount: number (必填); classifications: CompatibilityClassification[] (必填); summary: string (必填)

packages/protocol/src/manifest.ts:146
CompatibilityClassification接口 · 公开
@openelement/protocol · ./manifest

兼容性扫描为每个标签记录分级、原因、来源和对应的 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.

tagName: string (必填); tier: CompatibilityTier (必填); reason: string (必填); source: "local" | "package" | "nested" (必填); modulePath?: string (可选); ssr?: boolean (可选); dsd?: boolean (可选); hydrate?: string (可选)

packages/protocol/src/framework.ts:347
CompatibilityTier类型 · 公开
@openelement/protocol · ./manifest

标签的构建兼容级别,区分服务端渲染、仅浏览器渲染、实验支持和拒绝构建。

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
OpenElementAttribute接口 · 公开
@openelement/protocol · ./manifest

自定义元素声明中记录的一个 attribute。

OpenElementAttribute
英文源码说明

One documented attribute of a custom element declaration.

name: string (必填); type?: string (可选); default?: string (可选); description?: string (可选); reflects?: boolean (可选); fieldName?: string (可选)

packages/protocol/src/manifest.ts:15
OpenElementCssPart接口 · 公开
@openelement/protocol · ./manifest

自定义元素声明中记录的一个 CSS part。

OpenElementCssPart
英文源码说明

One documented CSS part of a custom element declaration.

name: string (必填); description?: string (可选)

packages/protocol/src/manifest.ts:38
OpenElementDeclaration接口 · 公开
@openelement/protocol · ./manifest

包清单中的自定义元素声明,包括标签名、成员和交付信息。

OpenElementDeclaration
英文源码说明

One custom element declaration in a package manifest: tag, members and delivery metadata.

tagName: string (必填); className?: string (可选); superclassName?: string (可选); attributes?: OpenElementAttribute[] (可选); events?: OpenElementEvent[] (可选); slots?: OpenElementSlot[] (可选); cssParts?: OpenElementCssPart[] (可选); openElement.ssr?: boolean (可选); openElement.dsd?: boolean (可选); openElement.layer?: ComponentLayer (可选); openElement.hydrate?: "load" | "idle" | "visible" | "only" | "none" (可选); openElement.status?: "stable" | "experimental" (可选) — Stability marker from the owning package's manifest policy.; openElement.module?: string (可选); openElement.export?: string (可选); openElement.tailwind?: OpenElementTailwindDeclaration (可选); openElement.root?: "light" | "shadow" | "closed" (可选) — The host root a generated-element declaration was compiled with. Absent for a class declaration (its descriptor owns the root) and for a generated declaration whose sidecar declares none (the descriptor default is light).; openElement.styles?: readonly string[] (可选) — The authored package-relative `.css` specifiers a generated SHADOW host declares, published so a consuming build can emit the sheet and hand its URL to the DSD style-link carrier. Absent when the component declares none; class declarations deliver their sheets through `static styles` instead.; openElement.ssrHostExport?: string (可选) — The compiler-emitted SSR host producer's export name (`<Component>__ssrHost`) for a generated declaration whose root is `shadow`. A consuming build cannot otherwise learn it: the name is the compiler's return-only `ssrHostExport` metadata, and re-deriving it from a naming convention inside the router would be exactly the drift ADR-0182 forbids ("read the compiler's return value, never re-derive i…; description?: string (可选)

packages/protocol/src/manifest.ts:116
OpenElementEvent接口 · 公开
@openelement/protocol · ./manifest

自定义元素声明中记录的一个自定义事件。

OpenElementEvent
英文源码说明

One documented custom event of a custom element declaration.

name: string (必填); type?: string (可选); description?: string (可选)

packages/protocol/src/manifest.ts:25
OpenElementExtensions接口 · 公开
@openelement/protocol · ./manifest

包清单声明中的 openElement 扩展字段。

OpenElementExtensions
英文源码说明

The openElement-specific extension block of a package manifest declaration.

ssr?: boolean (可选); dsd?: boolean (可选); layer?: ComponentLayer (可选); hydrate?: "load" | "idle" | "visible" | "only" | "none" (可选); status?: "stable" | "experimental" (可选) — Stability marker from the owning package's manifest policy.; module?: string (可选); export?: string (可选); tailwind.required?: boolean (可选); tailwind.sources?: string[] (可选); tailwind.dialect?: "tailwind4" (可选); root?: "light" | "shadow" | "closed" (可选) — The host root a generated-element declaration was compiled with. Absent for a class declaration (its descriptor owns the root) and for a generated declaration whose sidecar declares none (the descriptor default is light).; styles?: readonly string[] (可选) — The authored package-relative `.css` specifiers a generated SHADOW host declares, published so a consuming build can emit the sheet and hand its URL to the DSD style-link carrier. Absent when the component declares none; class declarations deliver their sheets through `static styles` instead.; ssrHostExport?: string (可选) — The compiler-emitted SSR host producer's export name (`<Component>__ssrHost`) for a generated declaration whose root is `shadow`. A consuming build cannot otherwise learn it: the name is the compiler's return-only `ssrHostExport` metadata, and re-deriving it from a naming convention inside the router would be exactly the drift ADR-0182 forbids ("read the compiler's return value, never re-derive i…

packages/protocol/src/manifest.ts:72
OpenElementPackageManifest接口 · 公开
@openelement/protocol · ./manifest

包级组件清单,记录其中声明的组件。

OpenElementPackageManifest
英文源码说明

Package manifest of component declarations (not a Custom Elements Manifest).

schemaVersion: string (必填); packageName: string (必填); version: string (必填); description?: string (可选); author?: string (可选); license?: string (可选); homepage?: string (可选); repository?: string (可选); declarations: OpenElementDeclaration[] (必填)

packages/protocol/src/manifest.ts:129
OpenElementSlot接口 · 公开
@openelement/protocol · ./manifest

自定义元素声明中记录的一个插槽。

OpenElementSlot
英文源码说明

One documented slot of a custom element declaration.

name: string (必填); description?: string (可选)

packages/protocol/src/manifest.ts:32
OpenElementTailwindDeclaration接口 · 公开
@openelement/protocol · ./manifest
OpenElementTailwindDeclaration
英文源码说明

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.

required?: boolean (可选); sources?: string[] (可选); dialect?: "tailwind4" (可选)

packages/protocol/src/manifest.ts:65
ModuleVocabularyDescriptor接口 · 公开
@openelement/protocol · ./module-descriptors

描述模块扫描识别的导出绑定,以及调用该绑定时登记的事实。

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).

moduleSpecifier: string (必填) — Canonical module specifier the factory must be imported from.; exportName: string (必填) — Exported name of the factory binding.; kind: "page-definition" | "element-registration" (必填) — What a canonical call of the binding contributes to the scan.

packages/protocol/src/module-descriptors.ts:33
StaticSidecarDescriptor接口 · 公开
@openelement/protocol · ./module-descriptors

告诉元素编译器哪一项与组件放在同一模块的声明属于静态策略。

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).

moduleSpecifier: string (必填) — Canonical module specifier the sidecar export must be imported from.; exportName: string (必填) — Exported name of the sidecar factory binding.; kind: "static-sidecar" (必填) — The admission granted: a colocated static policy statement.

packages/protocol/src/module-descriptors.ts:16
ROUTER_MODULE_VOCABULARY常量 · 公开
@openelement/protocol · ./module-vocabulary

路由器传给 analyzeModuleSemantics 的模块扫描识别规则。

readonly ModuleVocabularyDescriptor[]
英文源码说明

The module vocabulary router injects into `analyzeModuleSemantics`.

packages/protocol/src/module-vocabulary.ts:17
CemPropertyMetadata接口 · 公开
@openelement/protocol · ./part-program

编译生成的自定义元素清单中的单个属性记录。

CemPropertyMetadata
英文源码说明

One property entry of the compiled custom-elements-manifest metadata.

name: string (必填); fieldName: string (必填); type: PropertyValueType (必填); attribute: string | null (必填); reflect: boolean (必填)

packages/protocol/src/part-program.ts:381
CompiledCemMetadata接口 · 公开
@openelement/protocol · ./part-program

一个组件编译生成的自定义元素清单元数据。

CompiledCemMetadata
英文源码说明

The compiled custom-elements-manifest metadata block of one component.

tagName: string (必填); className: string (必填); declaration: { name: string; module: string; } (必填); attributes: { name: string; fieldName: string; type: PropertyValueType; reflect: boolean; }[] (必填); members: CemPropertyMetadata[] (必填)

packages/protocol/src/part-program.ts:390
CompiledElementMetadata接口 · 公开
@openelement/protocol · ./part-program

程序提供给工具读取的编译元素元数据。

CompiledElementMetadata
英文源码说明

The compiled element metadata the program carries for tooling consumers.

tag: string (必填); className: string (必填); sourceFile: string (必填); properties: CompiledPropertyMetadata[] (必填); observedAttributes: string[] (必填); cem: CompiledCemMetadata (必填)

packages/protocol/src/part-program.ts:399
CompiledPropertyMetadata接口 · 公开
@openelement/protocol · ./part-program

编译后的单个 @property 声明,记录名称、类型和反射设置。

CompiledPropertyMetadata
英文源码说明

One compiled

name: string (必填); attribute: string | null (必填); type: PropertyValueType (必填); converter: PropertyValueType (必填); reflect: boolean (必填); default: SerializableValue (必填); computed?: boolean (可选) — True for computed fields (`= computed(() => ...)` in the source): their signal is derived from other property signals by the generated `__computedFields` factory, never seeded from attributes/props. Always paired with `attribute: null` and `reflect: false`.; deps?: string[] (可选) — Source signal names a computed field reads (declaration order).

packages/protocol/src/part-program.ts:362
conditionLiteralAllowed函数 · 公开
@openelement/protocol · ./part-program

判断比较运算符与 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类型 · 公开
@openelement/protocol · ./part-program

编译程序的条件表达式所支持的比较运算符。

ConditionOperator
英文源码说明

The comparison operators a program condition supports.

packages/protocol/src/part-program.ts:236
DATA_OE_LIGHT常量 · 公开
@openelement/protocol · ./part-program

标识由服务端渲染的 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
isAttributeName函数 · 公开
@openelement/protocol · ./part-program

线格式校验器用来检查属性名的入口,采用统一校验规则。

(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
ItemEventBinding接口 · 公开
@openelement/protocol · ./part-program

每个 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.

event: string (必填) — DOM event name ('click', 'input', …).; handler: string (必填) — Handler method name on the compiled class.; action: ProgramEventAction (必填) — The action to dispatch, same union as fixed event parts.; selector?: string (可选) — Optional child selector within the item template (e.g. '.probe-button'). When omitted, the listener attaches to the item root.

packages/protocol/src/part-program.ts:295
PART_PROGRAM_VERSION常量 · 公开
@openelement/protocol · ./part-program

当前包定义的 Part Program 中间表示版本。

2
英文源码说明

The Part Program IR version this package defines (currently v2).

packages/protocol/src/part-program.ts:23
partAnchorEndMarker函数 · 公开
@openelement/protocol · ./part-program

序列化程序标记中结束 Part 锚点的注释文本。

(index: number): string
英文源码说明

The comment marker closing a part anchor in serialized program markup.

toString: (radix?: number) => string (必填) — Returns a string representation of an object.; toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; valueOf: () => number (必填) — Returns the primitive value of the specified object.; toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.

packages/protocol/src/part-program.ts:437
partAnchorMarker函数 · 公开
@openelement/protocol · ./part-program

初始数据运行时共用的锚点标记内容。

(index: number): string
英文源码说明

Anchor marker payloads shared by seed runtime consumers.

toString: (radix?: number) => string (必填) — Returns a string representation of an object.; toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; valueOf: () => number (必填) — Returns the primitive value of the specified object.; toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.

packages/protocol/src/part-program.ts:432
PartProgram类型 · 公开
@openelement/protocol · ./part-program

可序列化的 Part Program v2,用数据表示一个编译后的组件。

PartProgramV2
英文源码说明

The serializable Part Program v2: one compiled component as data.

version: 2 (必填); tag: string (必填); root: ProgramRoot (必填); template: ProgramTreeNode[] (必填); parts: ProgramPart[] (必填); blocks: ProgramBlockRecord[] (必填); dependencies: ProgramDependencyRecord[] (必填); locations: ProgramLocationRecord[] (必填); sourceMap: ProgramSourceMap (必填) — Compile-time provenance. The canonical in-memory artifact always carries it; the serialized module payload omits it (no runtime consumer reads it), so the validator accepts programs with or without it but still verifies it strictly when present.; metadata: CompiledElementMetadata (必填)

packages/protocol/src/part-program.ts:429
PartProgramV2接口 · 公开
@openelement/protocol · ./part-program

所有执行模式共享的确定性程序格式。

PartProgramV2
英文源码说明

The one deterministic program consumed by all execution modes.

version: 2 (必填); tag: string (必填); root: ProgramRoot (必填); template: ProgramTreeNode[] (必填); parts: ProgramPart[] (必填); blocks: ProgramBlockRecord[] (必填); dependencies: ProgramDependencyRecord[] (必填); locations: ProgramLocationRecord[] (必填); sourceMap: ProgramSourceMap (必填) — Compile-time provenance. The canonical in-memory artifact always carries it; the serialized module payload omits it (no runtime consumer reads it), so the validator accepts programs with or without it but still verifies it strictly when present.; metadata: CompiledElementMetadata (必填)

packages/protocol/src/part-program.ts:409
ProgramAttrPart接口 · 公开
@openelement/protocol · ./part-program

将信号值写入字符串型 DOM 特性的绑定。

ProgramAttrPart
英文源码说明

String attribute sink bound to a Signal.

k: "attr" (必填); index.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; index.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; index.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; index.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; index.valueOf: () => number (必填) — Returns the primitive value of the specified object.; index.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.; signal: string (必填); name: string (必填); path: number[] (必填); location: ProgramLocation (必填)

packages/protocol/src/part-program.ts:154
ProgramBlockRecord接口 · 公开
@openelement/protocol · ./part-program

记录编译程序所追踪的一个动态子树块及其边界。

ProgramBlockRecord
英文源码说明

One block the program tracks: the boundaries of a dynamic subtree.

id: string (必填); index.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; index.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; index.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; index.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; index.valueOf: () => number (必填) — Returns the primitive value of the specified object.; index.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.; kind: "when" | "each" (必填); anchor: string (必填); end: string (必填); source: string (必填)

packages/protocol/src/part-program.ts:342
ProgramBoolPart接口 · 公开
@openelement/protocol · ./part-program

将信号值写入布尔型 DOM 特性的绑定。

ProgramBoolPart
英文源码说明

Boolean attribute sink bound to a Signal.

k: "bool" (必填); index.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; index.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; index.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; index.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; index.valueOf: () => number (必填) — Returns the primitive value of the specified object.; index.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.; signal: string (必填); name: string (必填); path: number[] (必填); location: ProgramLocation (必填)

packages/protocol/src/part-program.ts:164
ProgramClassPart接口 · 公开
@openelement/protocol · ./part-program

将类名绑定到专用写入目标,明确该绑定对类名的归属。

ProgramClassPart
英文源码说明

Specialized fixed sinks make ownership explicit for class and style text.

k: "class" (必填); index.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; index.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; index.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; index.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; index.valueOf: () => number (必填) — Returns the primitive value of the specified object.; index.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.; signal: string (必填); path: number[] (必填); location: ProgramLocation (必填)

packages/protocol/src/part-program.ts:174
ProgramCondition接口 · 公开
@openelement/protocol · ./part-program

`when` 条件绑定中的一个条件子句。

ProgramCondition
英文源码说明

One condition clause of a when part.

signal: string (必填); op: ConditionOperator (必填); value: string | number | boolean (必填)

packages/protocol/src/part-program.ts:246
ProgramDependencyRecord接口 · 公开
@openelement/protocol · ./part-program

编译后的模块图记录的一项依赖。

ProgramDependencyRecord
英文源码说明

One module dependency the compiled module graph records.

signal: string (必填); owner: { kind: "part" | "region"; index: number; } (必填); location: string (必填)

packages/protocol/src/part-program.ts:352
ProgramEachPart接口 · 公开
@openelement/protocol · ./part-program

读取绑定信号的列表,按列表项重复渲染模板。

ProgramEachPart
英文源码说明

A list part: repeats its template node per item of a bound signal.

k: "each" (必填); index.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; index.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; index.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; index.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; index.valueOf: () => number (必填) — Returns the primitive value of the specified object.; index.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.; signal: string (必填); key: string (必填); field?: string (可选) — Restatement of the item field for single-field templates; omitted when the item template binds multiple fields (each `ival`/`iattrs` slot then carries its own field).; item: ProgramTreeNode[] (必填); itemEvents?: ItemEventBinding[] (可选) — Per-item event bindings (#1556 IR v2): listeners attached to each item.; location: ProgramLocation (必填)

packages/protocol/src/part-program.ts:310
ProgramElementNode接口 · 公开
@openelement/protocol · ./part-program

编译程序树中的静态元素节点。

ProgramElementNode
英文源码说明

A static element node of the program tree.

k: "el" (必填); id: string (必填); tag: string (必填); attrs: [string, string][] (必填); iattrs?: [string, string][] (可选) — Per-item attribute slots ([name, itemField]) — valid only inside an `each` item template. At mount/claim time the value resolves from the current item: `true` emits a bare attribute, `false`/`null`/`undefined` omit it, anything else serializes with String().; children: ProgramTreeNode[] (必填)

packages/protocol/src/part-program.ts:90
ProgramEventAction类型 · 公开
@openelement/protocol · ./part-program

一次事件绑定所分派的操作。

ProgramEventAction
英文源码说明

The action one event part dispatches.

packages/protocol/src/part-program.ts:217
ProgramEventPart接口 · 公开
@openelement/protocol · ./part-program

将 DOM 事件的监听器连接到对应操作的绑定。

ProgramEventPart
英文源码说明

An event binding part: listener wiring between DOM event and action.

k: "event" (必填); index.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; index.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; index.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; index.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; index.valueOf: () => number (必填) — Returns the primitive value of the specified object.; index.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.; event: string (必填); handler: string (必填); action: ProgramEventAction (必填); path: number[] (必填); location: ProgramLocation (必填)

packages/protocol/src/part-program.ts:225
ProgramHtmlPart接口 · 公开
@openelement/protocol · ./part-program

接收 `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.

k: "html" (必填); index.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; index.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; index.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; index.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; index.valueOf: () => number (必填) — Returns the primitive value of the specified object.; index.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.; signal: string (必填); path: number[] (必填); location: ProgramLocation (必填)

packages/protocol/src/part-program.ts:199
ProgramItemValueNode接口 · 公开
@openelement/protocol · ./part-program
ProgramItemValueNode
英文源码说明

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.

k: "ival" (必填); field: string (必填)

packages/protocol/src/part-program.ts:123
ProgramLocation接口 · 公开
@openelement/protocol · ./part-program

由编译器标定的一个动态写入目标或范围锚点的准确位置。

ProgramLocation
英文源码说明

Exact compiler-owned location for one dynamic sink or range anchor.

id: string (必填); kind: "anchor" | "sink" (必填); path: number[] (必填); node?: string (可选)

packages/protocol/src/part-program.ts:76
ProgramLocationRecord类型 · 公开
@openelement/protocol · ./part-program

无需读取绑定本身即可核查其标识与位置的记录。

ProgramLocationRecord
英文源码说明

A location record also makes the identity auditable without inspecting parts.

packages/protocol/src/part-program.ts:84
ProgramPart类型 · 公开
@openelement/protocol · ./part-program

可由编译程序实例化的各类动态绑定的可辨识联合类型。

ProgramPart
英文源码说明

The discriminated union of dynamic parts a program instantiates.

packages/protocol/src/part-program.ts:328
ProgramPartAnchorNode接口 · 公开
@openelement/protocol · ./part-program

标记编译程序树中动态绑定位置的锚点节点。

ProgramPartAnchorNode
英文源码说明

The anchor node marking where a part binds in the tree.

k: "part" (必填); id: string (必填); index.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; index.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; index.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; index.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; index.valueOf: () => number (必填) — Returns the primitive value of the specified object.; index.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.

packages/protocol/src/part-program.ts:112
ProgramPosition接口 · 公开
@openelement/protocol · ./part-program

记录绑定相对于锚点的位置,包括偏移、行和列。

ProgramPosition
英文源码说明

Where a part sits relative to its anchor.

offset.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; offset.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; offset.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; offset.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; offset.valueOf: () => number (必填) — Returns the primitive value of the specified object.; offset.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.; line: number (必填); column: number (必填)

packages/protocol/src/part-program.ts:45
ProgramPropPart接口 · 公开
@openelement/protocol · ./part-program

将信号值写入 DOM 属性,并保留 `path` 供读取初始数据的代码使用。

ProgramPropPart
英文源码说明

DOM property sink bound to a Signal; `path` is retained for seed consumers.

k: "prop" (必填); index.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; index.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; index.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; index.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; index.valueOf: () => number (必填) — Returns the primitive value of the specified object.; index.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.; signal: string (必填); name: string (必填); path: number[] (必填); location: ProgramLocation (必填)

packages/protocol/src/part-program.ts:144
ProgramRefPart接口 · 公开
@openelement/protocol · ./part-program

可序列化的具名引用位置,其引用值由生成的类提供。

ProgramRefPart
英文源码说明

A named ref slot is serializable; the generated class supplies the ref value.

k: "ref" (必填); index.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; index.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; index.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; index.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; index.valueOf: () => number (必填) — Returns the primitive value of the specified object.; index.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.; ref: string (必填); path: number[] (必填); location: ProgramLocation (必填)

packages/protocol/src/part-program.ts:208
ProgramRoot接口 · 公开
@openelement/protocol · ./part-program

描述一个编译程序树的根,树可包含元素、绑定锚点或文本。

ProgramRoot
英文源码说明

The root of one program tree: element, part anchor, or text.

id: "root" (必填); kind: RootMode (必填); nodes: string[] (必填)

packages/protocol/src/part-program.ts:29
ProgramSourceKind类型 · 公开
@openelement/protocol · ./part-program

标明程序源映射记录所对应的源代码实体类型。

ProgramSourceKind
英文源码说明

The kind of source record a program source map entry carries.

packages/protocol/src/part-program.ts:59
ProgramSourceMap接口 · 公开
@openelement/protocol · ./part-program

将源码片段的位置映射到编译器输出的记录。

ProgramSourceMap
英文源码说明

The program source map: authored spans projected onto emitted records.

version: 1 (必填); file: string (必填); records: ProgramSourceRecord[] (必填)

packages/protocol/src/part-program.ts:69
ProgramSourceRange接口 · 公开
@openelement/protocol · ./part-program

源码中的半开区间 `[start, end)`,包含起点且排除终点。

ProgramSourceRange
英文源码说明

A half-open [start, end) range into the authored source text.

file: string (必填); start: ProgramPosition (必填); end: ProgramPosition (必填)

packages/protocol/src/part-program.ts:52
ProgramSourceRecord接口 · 公开
@openelement/protocol · ./part-program

记录一个生成节点或绑定在源码中的出处。

ProgramSourceRecord
英文源码说明

One source-map record: the authored origin of one emitted node or part.

id: string (必填); kind: ProgramSourceKind (必填); source: ProgramSourceRange (必填)

packages/protocol/src/part-program.ts:62
ProgramStylePart接口 · 公开
@openelement/protocol · ./part-program

用于样式的编译绑定。

ProgramStylePart
英文源码说明

A style binding part.

k: "style" (必填); index.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; index.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; index.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; index.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; index.valueOf: () => number (必填) — Returns the primitive value of the specified object.; index.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.; signal: string (必填); path: number[] (必填); location: ProgramLocation (必填)

packages/protocol/src/part-program.ts:183
ProgramTextNode接口 · 公开
@openelement/protocol · ./part-program

编译程序树中的静态文本节点。

ProgramTextNode
英文源码说明

A static text node of the program tree.

k: "text" (必填); value: string (必填)

packages/protocol/src/part-program.ts:106
ProgramTextPart接口 · 公开
@openelement/protocol · ./part-program

绑定到单个信号的文本插值。

ProgramTextPart
英文源码说明

A text interpolation part bound to one signal.

k: "text" (必填); index.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; index.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; index.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; index.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; index.valueOf: () => number (必填) — Returns the primitive value of the specified object.; index.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.; signal: string (必填); location: ProgramLocation (必填)

packages/protocol/src/part-program.ts:136
ProgramTreeNode类型 · 公开
@openelement/protocol · ./part-program

静态程序树节点的可辨识联合类型。

ProgramTreeNode
英文源码说明

The discriminated union of static tree nodes.

packages/protocol/src/part-program.ts:129
ProgramWhenPart接口 · 公开
@openelement/protocol · ./part-program

按条件切换模板分支的动态绑定。

ProgramWhenPart
英文源码说明

A conditional part: swaps template branches on a condition.

k: "when" (必填); index.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; index.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; index.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; index.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; index.valueOf: () => number (必填) — Returns the primitive value of the specified object.; index.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.; signal: string (必填); test: ProgramCondition (必填); on: ProgramTreeNode[] (必填); off: ProgramTreeNode[] (必填); location: ProgramLocation (必填)

packages/protocol/src/part-program.ts:279
PropertyValueType类型 · 公开
@openelement/protocol · ./part-program

编译属性默认值序列化后所带的值类型标记。

PropertyValueType
英文源码说明

The serialized value-type tag of a compiled property default.

packages/protocol/src/part-program.ts:359
RootMode类型 · 公开
@openelement/protocol · ./part-program

指定编译组件将内容挂载到 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
SerializableValue类型 · 公开
@openelement/protocol · ./part-program

编译属性的默认值可采用的 JSON 可序列化类型。

SerializableValue
英文源码说明

The JSON-serializable value shape a compiled property default admits.

packages/protocol/src/part-program.ts:36
STATIC_STYLES_MARKER常量 · 公开
@openelement/protocol · ./part-program
"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
validatePartProgram函数 · 公开
@openelement/protocol · ./part-program

校验数据是否符合 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
VOID_TAGS常量 · 公开
@openelement/protocol · ./part-program

由编译器、序列化器与校验器共用的 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
IDLE_FALLBACK_TIMEOUT_MS常量 · 公开
@openelement/protocol · ./policy

环境缺少 requestIdleCallback 和 requestAnimationFrame 时,空闲 hydration 的备用延时(毫秒)。

50
英文源码说明

Idle-hydration scheduling fallback (milliseconds) when neither `requestIdleCallback` nor `requestAnimationFrame` is available.

packages/protocol/src/policy.ts:70
MAX_ACTION_BODY_BYTES常量 · 公开
@openelement/protocol · ./policy

生成的服务端入口对 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
MAX_COMPOSITION_DEPTH常量 · 公开
@openelement/protocol · ./policy

renderToString 允许展开的嵌套元素层数,避免循环组合导致无穷递归。

8
英文源码说明

Nested element expansion depth bound for `renderToString`: cyclic component composition fails closed instead of recursing without end.

packages/protocol/src/policy.ts:51
STREAM_MAX_FIELDS常量 · 公开
@openelement/protocol · ./policy

一个流式路由允许在清单中声明的延迟字段数上限。

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
STREAM_MAX_OWNERS常量 · 公开
@openelement/protocol · ./policy

一个流式路由清单可以引用的 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
STREAM_MAX_PAYLOAD_LENGTH常量 · 公开
@openelement/protocol · ./policy

流式载荷的最大序列化长度,以 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
STREAM_MAX_SEED_PROPERTIES常量 · 公开
@openelement/protocol · ./policy

流式 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
STREAM_TIMEOUT_MS常量 · 公开
@openelement/protocol · ./policy

流式响应等待延迟字段完成的时间上限(毫秒)。

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
ENTRY_REGISTRATION_OWNERS常量 · 公开
@openelement/protocol · ./registry-markers
"__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
SSR_REGISTRY_GENERATED_HOSTS常量 · 公开
@openelement/protocol · ./registry-markers
"__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_REGISTRY_ORIGINAL_DEFINE常量 · 公开
@openelement/protocol · ./registry-markers

标识 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_REGISTRY_STUB_MARKER常量 · 公开
@openelement/protocol · ./registry-markers

在 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接口 · 公开
@openelement/protocol · ./render

组件或路由携带的水合加载提示。

HydrationHint
英文源码说明

The hydration delivery hint a component or route carries.

tagName: string (必填); layer: ComponentLayer (必填); hydrate?: "load" | "idle" | "visible" | "only" | "none" (可选)

packages/protocol/src/render.ts:26
RenderError接口 · 公开
@openelement/protocol · ./render

SSR 流水线报告的一条渲染错误记录。

RenderError
英文源码说明

One render failure record the SSR pipeline reports.

code: string (必填); severity: "error" | "warning" (必填); phase: ErrorPhase (必填); tagName: string (必填); message: string (必填); recoverable: boolean (必填)

packages/protocol/src/render.ts:16
SsrAdmissionDecision接口 · 公开
@openelement/protocol · ./render

构建对自定义元素的 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.

tagName: string (必填); modulePath: string (必填) — Module path of the island declaration. Empty for 'foreign' decisions: a foreign tag is consumed in JSX but declares no module the build owns.; source: "local" | "package" | "nested" | "foreign" (必填) — 'foreign' (#979): a third-party WC tag discovered by the foreign-tag scanner in page/island JSX — recorded for visibility only; SSR still treats it as an opaque passthrough (renderPath 'client-only').; renderPath: "ssr+client" | "client-only" | "rejected" (必填); reason: string (必填)

packages/protocol/src/render.ts:37
OpenElementRequestHandler类型 · 公开
@openelement/protocol · ./runtime

供运行时适配器和生成入口使用的统一请求处理函数,基于标准 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
RuntimeAdapter接口 · 公开
@openelement/protocol · ./runtime

宿主运行时适配器,向服务器引擎提供接收请求的 `fetch` 处理器。

RuntimeAdapter<Env>
英文源码说明

A host runtime adapter: exposes the fetch handler a server engine dispatches to.

name: string (必填); fetch: OpenElementRequestHandler<Env> (必填); prerender?: (() => AsyncIterable<RuntimePrerenderResult> | Iterable<RuntimePrerenderResult>) (可选)

packages/protocol/src/runtime.ts:32
RuntimeAdapterOptions接口 · 公开
@openelement/protocol · ./runtime

构造运行时适配器时传入的选项。

RuntimeAdapterOptions<Env>
英文源码说明

Options one runtime adapter is constructed with.

name: string (必填); fetch: OpenElementRequestHandler<Env> (必填); prerender?: (() => AsyncIterable<RuntimePrerenderResult> | Iterable<RuntimePrerenderResult>) (可选)

packages/protocol/src/runtime.ts:39
RuntimeContext接口 · 公开
@openelement/protocol · ./runtime

运行时适配器的上下文契约,用来隔离框架和部署环境。

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.

env?: Env (可选); platform?: unknown (可选); params?: Record<string, string> (可选)

packages/protocol/src/runtime.ts:9
ReadonlySignal接口 · 公开
@openelement/protocol · ./signal

computed 等派生值使用的只读信号接口。

ReadonlySignal<T>
英文源码说明

Read-only signal protocol used by computed values.

value: T (必填); subscribe: (fn: (value: T) => void) => Unsubscribe (必填); __@[email protected]: () => boolean (必填) — Returns the primitive value of the specified object.

packages/protocol/src/signal.ts:26
Signal类型 · 公开
@openelement/protocol · ./signal

接受可写信号或只读信号的 API 所用类型。

Signal<T>
英文源码说明

Alias for APIs that accept either writable or read-only signals.

packages/protocol/src/signal.ts:31
SIGNAL_BRAND常量 · 公开
@openelement/protocol · ./signal

标识当前配置的响应式引擎所创建的信号,供运行时和类型系统识别。

typeof SIGNAL_BRAND
英文源码说明

Runtime/type brand for signals created by the configured reactive engine.

packages/protocol/src/signal.ts:11
SignalEngine接口 · 公开
@openelement/protocol · ./signal

框架内置适配器使用的信号引擎协议。

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).

signal: <T>(initialValue: T) => WritableSignal<T> (必填); computed: <T>(fn: () => T) => ReadonlySignal<T> (必填); effect: (fn: () => void | Unsubscribe) => Unsubscribe (必填)

packages/protocol/src/signal.ts:46
SignalLike接口 · 公开
@openelement/protocol · ./signal

渲染器和绑定接受的最简信号对象接口。

SignalLike<T>
英文源码说明

Minimal signal-like object accepted by renderers and bindings.

value: T (必填); subscribe: (fn: (value: T) => void) => Unsubscribe (必填); __@[email protected]: () => boolean (必填) — Returns the primitive value of the specified object.

packages/protocol/src/signal.ts:14
Unsubscribe类型 · 公开
@openelement/protocol · ./signal

订阅和响应式副作用返回的取消订阅函数。

Unsubscribe
英文源码说明

Unsubscribe function returned by subscriptions and effects.

packages/protocol/src/signal.ts:8
WritableSignal接口 · 公开
@openelement/protocol · ./signal

openElement 集成使用的可写信号协议。

WritableSignal<T>
英文源码说明

Writable signal protocol used by openElement integrations.

value: T (必填); subscribe: (fn: (value: T) => void) => Unsubscribe (必填); __@[email protected]: () => boolean (必填) — Returns the primitive value of the specified object.

packages/protocol/src/signal.ts:21
ApiRouteDecl接口 · 公开
@openelement/protocol · ./ssg

生成入口描述符中的一条 API 路由声明。

ApiRouteDecl
英文源码说明

One API route declaration in the generated entry descriptor.

kind: "api" (必填); path: string (必填); varName: string (必填); filePath: string (必填); importPath: string (必填)

packages/protocol/src/ssg.ts:163
BuildArtifacts接口 · 公开
@openelement/protocol · ./ssg

openElement 构建流程返回的产物。

BuildArtifacts
英文源码说明

Result returned by the OpenElement build pipeline.

pages: BuildPageArtifact[] (必填) — Generated HTML pages.; manifest: BuildManifestArtifact (必填) — Build manifest.; clientAssets: BuildClientAsset[] (必填) — Client-side assets (island bundles, CSS, etc).; warnings: string[] (必填) — Non-fatal warnings.; errors: string[] (必填) — Fatal errors.; success: boolean (必填) — Whether the build succeeded.

packages/protocol/src/ssg.ts:565
BuildClientAsset接口 · 公开
@openelement/protocol · ./ssg

构建流水线输出的一项客户端资源。

BuildClientAsset
英文源码说明

A single client asset emitted by the build pipeline.

fileName: string (必填); source: string | Uint8Array<ArrayBufferLike> (必填); sizeBytes.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; sizeBytes.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; sizeBytes.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; sizeBytes.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; sizeBytes.valueOf: () => number (必填) — Returns the primitive value of the specified object.; sizeBytes.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.

packages/protocol/src/ssg.ts:558
BuildI18nOptions接口 · 公开
@openelement/protocol · ./ssg

构建流水线的国际化配置。

BuildI18nOptions
英文源码说明

i18n configuration for the build pipeline.

locales: string[] (必填); defaultLocale?: string (可选)

packages/protocol/src/ssg.ts:511
BuildIslandInput接口 · 公开
@openelement/protocol · ./ssg

构建流水线接收的一项交互岛输入。

BuildIslandInput
英文源码说明

A single island input to the build pipeline.

hydrate?: IslandDeliveryStrategy (可选); ssr?: boolean (可选); dsd?: boolean (可选); source?: "local" | "package" | "nested" (可选); reason?: string (可选); tagName: string (必填); modulePath: string (必填); isPackage?: boolean (可选)

packages/protocol/src/ssg.ts:492
BuildManifestArtifact接口 · 公开
@openelement/protocol · ./ssg

构建流水线输出的清单产物。

BuildManifestArtifact
英文源码说明

Manifest produced by the build pipeline.

routes: { kind: "page" | "api"; path: string; tagName?: string; isDynamic: boolean; }[] (必填); islands: BuildIslandInput[] (必填); requestTimeRoutes?: string[] (可选) — Paths served at request time (renderIntent mode 'dynamic'). Absent for pure-static builds.

packages/protocol/src/ssg.ts:547
BuildOutputOptions接口 · 公开
@openelement/protocol · ./ssg

构建流水线的输出配置。

BuildOutputOptions
英文源码说明

Output configuration for the build pipeline.

root?: string (可选) — Project root directory.; outDir?: string (可选) — Output directory relative to root.; base?: string (可选) — Base URL path.

packages/protocol/src/ssg.ts:501
BuildPackageIslandOptions接口 · 公开
@openelement/protocol · ./ssg

构建流水线中由包提供的交互岛的配置。

BuildPackageIslandOptions
英文源码说明

Package island configuration for the build pipeline.

packages?: string[] (可选) — Package names that may expose island declarations.

packages/protocol/src/ssg.ts:517
BuildPageArtifact接口 · 公开
@openelement/protocol · ./ssg

一份生成的 HTML 页面产物。

BuildPageArtifact
英文源码说明

A single generated HTML page artifact.

path: string (必填); html: string (必填); errors: { message: string; route?: string; }[] (必填) — Errors collected while rendering this page.

packages/protocol/src/ssg.ts:539
BuildPlan接口 · 公开
@openelement/protocol · ./ssg

openElement 构建流水线接收的框架无关构建计划。

BuildPlan
英文源码说明

Framework-agnostic plan consumed by the OpenElement build pipeline.

options.renderer?: "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).; options.routesDir?: string (可选) — Directory the route scanner walks, relative to the Vite root. Defaults to `app/routes`.; options.islandsDir?: string (可选) — Directory island modules are discovered in. Defaults to `app/islands`.; options.packageIslands?: 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…; options.layout?: LayoutConfig (可选) — Layout declaration; `false` disables the layout, `'default'` uses the built-in one.; options.layouts?: LayoutsConfig (可选) — Named layout declarations keyed by layout name.; options.headExtras?: string (可选) — @dangerous injected as-is, only use with controlled content; options.html?: { lang?: string; title?: string; } (可选) — Document `<html>` attributes: the `lang` the document declares and the default `<title>`.; options.inject?: { stylesheets?: Array<string | { href: string; integrity?: string; crossorigin?: "anonymous" | "use-credentials"; attrs?: Record<string, string | number | bool… (可选) — Document head/body injection channels: external stylesheets, scripts, and trusted raw head fragments.; options.ssr?: { noExternal?: (string | RegExp)[]; } (可选) — SSR bundling switches; `noExternal` forces the named packages through the SSR bundle instead of an external import.; options.island?: { upgradeStrategy?: HydrationStrategy; } (可选) — Island defaults applied to every island the build discovers.; options.build?: { outDir?: string; manifestBudget?: { islandKB?: number; totalJsKB?: number; pageKB?: number; }; } (可选) — Build output switches: the output directory and the advisory manifest budgets.; options.viewTransition?: boolean (可选) — Enable the View Transitions API for client navigations. Defaults to true.; options.speculation?: 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.; options.middleware?: { cors?: boolean; corsOrigin?: string | string[]; corsOriginModule?: string; requestId?: boolean; logger?: boolean; securityHeaders?: boolean; csp?: { policy?:… (可选) — Request-time middleware switches, composed outside the framework handler.; routes: BuildRouteInput[] (必填) — Discovered page and API routes.; islands: BuildIslandInput[] (必填) — Discovered local and package islands.; output.root?: string (可选) — Project root directory.; output.outDir?: string (可选) — Output directory relative to root.; output.base?: string (可选) — Base URL path.; i18n?: BuildI18nOptions (可选) — i18n expansion options.; packageIslands.packages?: string[] (可选) — Package names that may expose island declarations.

packages/protocol/src/ssg.ts:523
BuildRouteInput接口 · 公开
@openelement/protocol · ./ssg

构建流水线接收的一条路由输入。

BuildRouteInput
英文源码说明

A single route input to the build pipeline.

kind: "api" | "page" (必填) — Route kind: page or API.; path: string (必填) — Route path (e.g. '/about', '/blog/:slug').; filePath: string (必填) — Absolute or relative file path of the route module.; importPath: string (必填) — Import specifier used by generated entry code.; tagName?: string (可选) — Resolved tag name for page routes.; paramNames?: string[] (可选) — Dynamic segment names.; staticParams?: Record<string, string>[] (可选) — Static generation params produced by getStaticPaths().

packages/protocol/src/ssg.ts:474
ClientIslandEntry接口 · 公开
@openelement/protocol · ./ssg

传给入口生成器的客户端交互岛条目结构。

ClientIslandEntry
英文源码说明

Client island entry shape passed to entry generator.

exportName?: string (可选) — Optional named export to register as the custom element constructor. When set (package islands whose chunk dropped `export default` per #638), the client island factory reads `mod[exportName]` instead of `mod.default`. When absent, the factory falls back to `mod.default` (local/route islands).; strategy: IslandDeliveryStrategy (必填); strategySource?: "default" | "manifest" | "component" | "route" (可选); ssr?: boolean (可选); dsd?: boolean (可选); reason?: string (可选); tagName: string (必填); modulePath: string (必填); isPackage?: boolean (可选)

packages/protocol/src/ssg.ts:105
CorsOriginConfig类型 · 公开
@openelement/protocol · ./ssg

API 路由声明的 CORS 来源策略。

CorsOriginConfig
英文源码说明

The CORS origin policy an API route declares.

packages/protocol/src/ssg.ts:130
CspConfig接口 · 公开
@openelement/protocol · ./ssg

路由或文档声明的内容安全策略(CSP)指令。

CspConfig
英文源码说明

The content-security-policy directives a route or document declares.

policy?: string (可选); nonce?: boolean (可选); reportOnly?: boolean (可选)

packages/protocol/src/ssg.ts:133
DocumentConfig接口 · 公开
@openelement/protocol · ./ssg

构建时写入生成入口的文档级配置。

DocumentConfig
英文源码说明

The document-level facts a build bakes into the generated entry.

lang: string (必填); title: string (必填); headExtras: string (必填); allowHeadExtrasScripts: boolean (必填)

packages/protocol/src/ssg.ts:286
EntryDescriptor接口 · 公开
@openelement/protocol · ./ssg

一个生成入口的完整构建描述,包含路由、交互岛、渲染器、中间件、文档和布局计划。

EntryDescriptor
英文源码说明

The full build-time description of one generated entry: routes, islands, renderers, middleware, document, and layout plans.

isSSG: boolean (必填); renderer?: "native" (可选) — Page renderer selection. Only the compiled native renderer exists; absent or 'native' keeps the renderToString page path byte-identical. Loader, action and protocol codegen never fork on a renderer.; imports: ImportDecl[] (必填); middleware: MiddlewareDecl[] (必填); fetchMiddleware?: string[] (可选) — `middleware.use` fetch middleware module paths (#858), in user-configured order. The entry renderer emits one `import * as __mw_N from '<path>'` per entry and composes each module's default export around the exported handler in onion order. Absent/empty when the app configures no fetch middleware, keeping the generated entry byte-identical to pre-#858 output.; apiRoutes: ApiRouteDecl[] (必填); pageRoutes: PageRouteDecl[] (必填); staticComponents: StaticComponentDecl[] (必填); islands: IslandDecl[] (必填); hasEnhancedForms?: boolean (可选) — True when any page route carries data-open-enhance forms (#569). Drives the dev island client script injection (#951): an island-free app with enhanced forms still needs the client entry in dev HTML.; ssrAdmissionPlan: SsrAdmissionPlan (必填); cemClassifications?: CompatibilityClassification[] (可选); renderers: RendererDecl[] (必填); middlewareScopes: MiddlewareScopeDecl[] (必填); document: DocumentConfig (必填); layout: LayoutPlan (必填); upgradeStrategy?: "load" | "idle" | "visible" | "only" | "none" (可选); i18n?: { locales: string[]; defaultLocale: string; } (可选) — Declared project locales. Absent for a single-locale site: the generated entry then emits no locale prefixes and the default-locale fallback, which is byte-identical to pre-i18n output.

packages/protocol/src/ssg.ts:321
ImportDecl接口 · 公开
@openelement/protocol · ./ssg

生成入口输出的一条模块导入声明。

ImportDecl
英文源码说明

One module import the generated entry emits.

from: string (必填); names: string[] (必填); alias?: string (可选)

packages/protocol/src/ssg.ts:123
IslandDecl接口 · 公开
@openelement/protocol · ./ssg

构建纳入的一个交互岛的声明,包括标签名、模块路径和加载方式。

IslandDecl
英文源码说明

One island the build admits: tag, module path, and delivery facts.

exportName?: string (可选) — Optional named export to register as the custom element constructor. Set for package islands from the manifest declaration's `className` (the CEM-derived export class name), so the client island factory can read `mod[exportName]` after #638 removed `export default` from UI component chunks. Absent for local/route islands (which use default).; hydrate?: IslandDeliveryStrategy (可选); ssr?: boolean (可选); dsd?: boolean (可选); authoring?: "basic-element" | "third-party-wc" (可选); source?: "local" | "package" | "nested" (可选); reason?: string (可选); tagName: string (必填); modulePath: string (必填); isPackage?: boolean (可选)

packages/protocol/src/ssg.ts:195
IslandDeliveryStrategy类型 · 公开
@openelement/protocol · ./ssg

由适配器决定的浏览器交付策略,可依据媒体查询决定是否交付。

IslandDeliveryStrategy
英文源码说明

Adapter-owned browser delivery strategy, including media-query admission.

packages/protocol/src/ssg.ts:31
IslandModuleIdentity接口 · 公开
@openelement/protocol · ./ssg

交互岛记录共用的模块标识,包含注册标签、模块路径及包来源信息。

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.

tagName: string (必填); modulePath: string (必填); isPackage?: boolean (可选)

packages/protocol/src/ssg.ts:98
LayoutDecl接口 · 公开
@openelement/protocol · ./ssg

构建解析出的布局模块声明,包含标签名、导入路径和序列化属性。

LayoutDecl
英文源码说明

The layout module a build resolves: tag, import path, and serialized props.

tagName: string (必填); importPath: string (必填); props: Record<string, unknown> (必填); generatedHostExport?: string (可选) — The compiler-emitted SSR host producer export (`<Name>__ssrHost`) when the layout module is a GENERATED element, or absent when it is a class. A generated layout cannot be registered class-only: a generated element carries no Part Program, so `renderToString` fails with PROGRAM_MISSING on every render. The entry therefore registers the generated host PAIR — the same channel an island uses. The na…

packages/protocol/src/ssg.ts:294
LayoutPlan接口 · 公开
@openelement/protocol · ./ssg

构建最终交付的布局计划,包含默认布局和具名布局。

LayoutPlan
英文源码说明

The resolved layouts a build ships: the default layout plus named layouts.

default: ResolvedLayout (必填); layouts: Record<string, ResolvedLayout> (必填)

packages/protocol/src/ssg.ts:315
MiddlewareDecl接口 · 公开
@openelement/protocol · ./ssg

由生成入口纳入执行链的一个中间件模块声明。

MiddlewareDecl
英文源码说明

One middleware module the generated entry composes.

kind: "requestId" | "logger" | "cors" | "securityHeaders" | "csp" (必填); comment?: string (可选); config.corsOrigin?: CorsOriginConfig (可选); config.corsOriginModule?: string (可选) — Normalized import path of a module default-exporting `(origin: string) => string | undefined`. The generated entry imports the module and passes its default export to `cors({ origin })` — the callback is referenced, never serialized.; config.warnOnDefaultCors?: boolean (可选) — #1411: emit the default-CORS production advisory. Absent means "warn" (production builds); the dev server sets false so the first run is warning-free.; config.csp?: CspConfig (可选)

packages/protocol/src/ssg.ts:140
MiddlewareScopeDecl接口 · 公开
@openelement/protocol · ./ssg

一个中间件的适用范围,可覆盖全部路由或一组具名路由。

MiddlewareScopeDecl
英文源码说明

The scope one middleware applies to (all routes or a named route set).

varName: string (必填); scope: string (必填); importPath: string (必填)

packages/protocol/src/ssg.ts:279
PageRouteDecl接口 · 公开
@openelement/protocol · ./ssg

生成入口描述符中的一条页面路由声明。

PageRouteDecl
英文源码说明

One page route declaration in the generated entry descriptor.

kind: "page" (必填); path: string (必填); varName: string (必填); filePath: string (必填); defaultTagName: string (必填); tagName: string (必填); importPath: string (必填); isDynamic?: boolean (可选); paramNames?: string[] (可选); streamManifest?: StreamRouteManifest (可选); functionPage?: string (可选) — The server function page fact (alpha15 server lane): the exported server function component the route's `export default definePage(Component)` named — compiled into the module by the server component lane. No element class exists to register; both render channels render through the descriptor's render function (the compiled constructor) and feed the same renderer/layout/document wraps.

packages/protocol/src/ssg.ts:172
RendererDecl接口 · 公开
@openelement/protocol · ./ssg

一条页面渲染器模块注册记录。

RendererDecl
英文源码说明

One page renderer module registration.

varName: string (必填); scope: string (必填); importPath: string (必填); depth.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; depth.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; depth.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; depth.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; depth.valueOf: () => number (必填) — Returns the primitive value of the specified object.; depth.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.

packages/protocol/src/ssg.ts:271
ResolvedLayout类型 · 公开
@openelement/protocol · ./ssg

布局计划中一个位置的解析结果,可为 `false`(禁用)或完整声明。

ResolvedLayout
英文源码说明

The resolved layout for one plan slot: disabled (false) or a full declaration.

packages/protocol/src/ssg.ts:312
RouteInfoEntry接口 · 公开
@openelement/protocol · ./ssg

生成的 SSG 入口模块通过 `routeInfo` 输出的一条路由元数据。

RouteInfoEntry
英文源码说明

A single route metadata entry emitted as `routeInfo` by the generated SSG entry module (see entry-render-ssg.ts).

path: string (必填); filePath?: string (可选) — Route module file path. Read by the render pipeline: ssg-render.ts copies it into server-manifest.json for request-time (renderIntent 'dynamic') routes.; tagName: string (必填); module?: unknown (可选) — The route module namespace object (typed per-module at codegen time).; isDynamic: boolean (必填); paramNames: string[] (必填); rendering?: "static" | "dynamic" (可选) — Rendering mode declared via renderIntent.mode ("static" when unset; the "auto" alias is rejected, #609).; hasAction?: boolean (可选) — True when the route module exports an action (request-time form POST).; streamManifest?: StreamRouteManifest (可选); params?: Record<string, string> (可选)

packages/protocol/src/ssg.ts:395
SpeculationRulesOptions接口 · 公开
@openelement/protocol · ./ssg

静态生成后处理使用的 Speculation Rules 配置。

SpeculationRulesOptions
英文源码说明

Speculation Rules configuration for SSG post-processing

prerender?: string[] (可选) — URL patterns to prerender (fully render in background before navigation).; prefetch?: string[] (可选) — URL patterns to prefetch (fetch HTML + resources without rendering).; exclude?: string[] (可选) — URL patterns to exclude from both prefetch and prerender.; eagerness?: "immediate" | "moderate" | "conservative" (可选) — Eagerness level for prerender rules.

packages/protocol/src/ssg.ts:448
SsgBehaviorOptions接口 · 公开
@openelement/protocol · ./ssg

面向应用的静态站点生成构建选项。

SsgBehaviorOptions
英文源码说明

User-facing SSG build behavior switches (OpenElementOptions['ssg']).

dynamicRouteFailure?: "fail" | "warn" (可选) — Policy for dynamic-route render failures during SSG. See {@link SsgRenderOptions.dynamicRouteFailure}.

packages/protocol/src/ssg.ts:63
SsgPageOutput接口 · 公开
@openelement/protocol · ./ssg

`renderRoute()` 返回的单页渲染诊断结果。

SsgPageOutput
英文源码说明

Per-page render diagnostics returned by renderRoute()

html: string (必填) — Rendered HTML string; status.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; status.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; status.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; status.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; status.valueOf: () => number (必填) — Returns the primitive value of the specified object.; status.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.; redirect?: { location: string; status: number; } (可选) — Redirect outcome (3xx). When set, `html` holds an interim status page and the result must not be persisted as a normal 200 page.; notFound?: boolean (可选) — True when the route signalled not-found (404).; errors: RenderError[] (必填) — Render errors collected during rendering; componentCount: number (必填) — Number of DSD components rendered on this page; renderTimeMs: number (必填) — Total render time for all components on this page (ms)

packages/protocol/src/ssg.ts:368
SsgRenderEvidence接口 · 公开
@openelement/protocol · ./ssg

SSG 引擎为每次构建输出的渲染审计记录。

SsgRenderEvidence
英文源码说明

The per-build render evidence record the SSG engine emits for audit.

i18nOptions?: { [key: string]: unknown; locales: string[]; defaultLocale?: string; } | null (可选); admissionDecisions?: SsrAdmissionDecision[] (可选) — SSR admission decisions from the plan that rendered the pages.; manifestBudget.islandKB?: number (可选); manifestBudget.totalJsKB?: number (可选); manifestBudget.pageKB?: number (可选); onPrintBuildManifest?: ((input: { root: string; outDir: string; phase: 3; headExtras?: string; budget?: { islandKB?: number; totalJsKB?: number; pageKB?: number; }; }) => void | Prom… (可选)

packages/protocol/src/ssg.ts:426
SsgRenderOptions接口 · 公开
@openelement/protocol · ./ssg

传给共用 SSG 渲染流水线的选项。

SsgRenderOptions
英文源码说明

Options passed to the shared SSG render pipeline.

root: string (必填); outDir: string (必填); base?: string (可选); headExtras?: string (可选); html.lang?: string (可选); html.title?: string (可选); middleware.csp?: { policy?: string; reportOnly?: boolean; nonce?: boolean; } (可选); upgradeStrategy?: "load" | "idle" | "visible" | "only" | "none" (可选); viewTransition?: boolean (可选); speculation?: boolean | Record<string, unknown> (可选); islandTagNames?: string[] (可选); routesDir?: string (可选); dynamicRouteFailure?: "fail" | "warn" (可选) — Policy for dynamic-route render failures (HTTP status >= 500, non-empty render errors, or a renderRoute throw) during SSG. - 'fail' (default): abort the build - a failed page must never ship as a normal 200 page. - 'warn': log the failure and skip the page (the page is not written and is not registered in the ISR manifest).

packages/protocol/src/ssg.ts:36
SsgRenderSummary接口 · 公开
@openelement/protocol · ./ssg

`ssgRender()` 返回的一次 SSG 渲染汇总。

SsgRenderSummary
英文源码说明

Summary of an SSG render run, returned by ssgRender().

staticNon200: { path: string; status: number; }[] (必填) — Static routes whose handler returned a non-200 status. hono/ssg drops these responses (defaultPlugin), so they are not written to disk; they are listed here and in the build log instead of disappearing silently.; warnings: string[] (必填) — Non-fatal warnings collected during the SSG run (sitemap generation failures, etc.). Surfaced here so the build summary / release evidence carries them instead of letting them disappear silently.

packages/protocol/src/ssg.ts:72
SsrAdmissionPlan接口 · 公开
@openelement/protocol · ./ssg

构建时按组件标签记录的 SSR 准入决策。

SsrAdmissionPlan
英文源码说明

The build-time SSR admission decisions per component tag.

renderableTags: string[] (必填); clientOnlyTags: string[] (必填); rejectedTags: string[] (必填); reasons: Record<string, string> (必填); decisions: SsrAdmissionDecision[] (必填); cemClassifications?: CompatibilityClassification[] (可选); foreignTags?: string[] (可选) — #979: foreign custom-element tags discovered in page / island JSX that are neither local islands, package-manifest islands, nor openElement-authored elements. Visibility only — each tag also carries a source:'foreign' decision (renderPath 'client-only') and the SSR/behavior is unchanged (opaque passthrough).

packages/protocol/src/ssg.ts:253
SsrBundle接口 · 公开
@openelement/protocol · ./ssg

SSG 引擎执行流式渲染时读取的服务端包信息。

SsrBundle
英文源码说明

The server bundle facts the SSG engine consumes for stream rendering.

packages/protocol/src/ssg.ts:417
StaticComponentDecl接口 · 公开
@openelement/protocol · ./ssg

从路由的本地导入图发现的静态编译组件声明,供构建纳入递归 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.

tagName: string (必填); modulePath: string (必填); compilerInteractionEvents: string[] (必填) — Compiler-owned interaction events; empty means no inferred browser entry.; generatedHostExport?: string (可选) — The compiler-emitted SSR host producer export (`<Name>__ssrHost`) when this static component belongs to the GENERATED lane, or absent for a class. Same fact, same rule as {@linkcode LayoutDecl.generatedHostExport}: a generated component carries no Part Program, so a class-only registration fails every render with PROGRAM_MISSING. The entry therefore registers the generated host PAIR. The name is …; root?: "light" | "shadow" | "closed" (可选) — The descriptor root a page-local GENERATED component declares (P-2, 2026-11-21). A shadow root's class candidates need the shared COMPONENT stylesheet linked inside the DSD template; a light root's belong to the document sheet. Absent for a class component (its `static styles` scope carries the same fact).; pageComponent?: boolean (可选) — True when this record is a PAGE COMPONENT (the module a route passes to `definePage`), not a nested component. A page root is rendered by the route handler, so the entry must register its host pair even though no JSX reference to the tag exists anywhere.; pageComponentDependency?: boolean (可选) — A generated host reached through a page component’s side-effect imports.

packages/protocol/src/ssg.ts:217
StreamRouteManifest接口 · 公开
@openelement/protocol · ./ssg

构建时绑定到某个编译页面程序的路由信息。

StreamRouteManifest
英文源码说明

Build-only route projection bound to a specific compiled page program.

program: { version: number; tag: string; sha256: string; } (必填); fields: { field: string; signal: string; owners: Array<{ kind: "part" | "region"; index: number; location: string; source: PartProgramV2["sourceMap"]["records"][number… (必填)

packages/protocol/src/ssg.ts:13
STREAM_FRAME_FORBIDDEN_TAGS常量 · 公开
@openelement/protocol · ./stream-frame-policy

浏览器拒绝装入所属 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
STREAM_FRAME_UNSAFE_URL常量 · 公开
@openelement/protocol · ./stream-frame-policy

流式片段的 URL 属性不可使用的协议。

RegExp
英文源码说明

Schemes that make a URL attribute unsafe in a streamed frame.

packages/protocol/src/stream-frame-policy.ts:60
STREAM_FRAME_URL_ATTRIBUTES常量 · 公开
@openelement/protocol · ./stream-frame-policy

流式片段中需要检查 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
STREAM_FRAME_URL_CONTROL_MAX常量 · 公开
@openelement/protocol · ./stream-frame-policy

检查 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
unsafeStreamFrameAttribute函数 · 公开
@openelement/protocol · ./stream-frame-policy

判断 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
NESTED_HOST_EXPANDER常量 · 公开
@openelement/protocol · ./style-sheet

编译器内部字段,用于在渲染的宿主记录中存放展开嵌套宿主的函数。

"__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
STYLE_SHEET_LIVE常量 · 公开
@openelement/protocol · ./style-sheet

用来标记可在开发期间热更新的样式表资源的键。

"__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
STYLE_SHEET_READY常量 · 公开
@openelement/protocol · ./style-sheet
"__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
STYLE_SHEET_URL常量 · 公开
@openelement/protocol · ./style-sheet
"__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
StyleSheetLike接口 · 公开
@openelement/protocol · ./style-sheet

原生样式表与兼容实现共用的最小接口,包括 replaceSync 和 cssRules。

StyleSheetLike
英文源码说明

Minimal stylesheet contract (replaceSync + cssRules) satisfied by native and shim sheets.

replaceSync: (text: string) => void (必填); cssRules: StyleSheetRule[] (必填)

packages/protocol/src/style-sheet.ts:14
StyleSheetRule接口 · 公开
@openelement/protocol · ./style-sheet

浏览器与 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().

cssText: string (必填)

packages/protocol/src/style-sheet.ts:9
VOID_TAGS常量 · 公开
@openelement/protocol · ./void-tags

由编译器、序列化器与校验器共用的 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

@openelement/element

441 个导出
__setRequestTimeStyleSheetUrls函数 · 公开
@openelement/element · root

为当前服务端进程设置已生成的样式表 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类型 · 公开
@openelement/element · root

处理页面路由的表单提交。

Action<T, Env, Platform, Route>
英文源码说明

Route action: handles form submissions for a page route.

packages/protocol/src/data.ts:64
ACTION_FETCH_HEADER常量 · 公开
@openelement/element · root

选择表单 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
ActionContext接口 · 公开
@openelement/element · root

传给路由 action 的上下文,包含 loader 上下文。

ActionContext<Env, Platform, Route>
英文源码说明

Context passed to a route action function (extends loader context).

formData: FormData (必填); request: Request (必填); params: Record<string, string> (必填); env: Env (必填); platform: Platform (必填); responseHeaders: Headers (必填) — Mutable response-only channel merged into the framework response.; route: Route (必填)

packages/protocol/src/data.ts:47
ActionResult类型 · 公开
@openelement/element · root

脚本提交表单时返回的联合类型。校验失败返回 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
assertValidTagName函数 · 公开
@openelement/element · root

检查名称是否符合自定义元素的标签名规则。

(tagName: string): void
英文源码说明

Assert that a tag name is a valid custom element name.

packages/element/src/internal/core/tag-utils.ts:50
collectPublicProps函数 · 公开
@openelement/element · root

收集宿主对象上所有公开的自有属性。

(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
CompatibilityClassification接口 · 公开
@openelement/element · root

兼容性扫描为每个标签记录分级、原因、来源和对应的 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.

tagName: string (必填); tier: CompatibilityTier (必填); reason: string (必填); source: "local" | "package" | "nested" (必填); modulePath?: string (可选); ssr?: boolean (可选); dsd?: boolean (可选); hydrate?: string (可选)

packages/protocol/src/framework.ts:347
CompatibilityTier类型 · 公开
@openelement/element · root

标签的构建兼容级别,区分服务端渲染、仅浏览器渲染、实验支持和拒绝构建。

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
ComponentLayer类型 · 公开
@openelement/element · root

组件的交付层级,区分静态 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
computed函数 · 公开
@openelement/element · root

根据依赖计算一个只读响应式值。

<T>(fn: () => T): ReadonlySignal<T>
英文源码说明

Create a derived read-only signal recomputed from its dependencies.

packages/element/src/internal/signal/framework.ts:23
consumeContext函数 · 公开
@openelement/element · root

将上下文投影为消费端的响应式值。传入宿主时,消费端负责通过 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.

key.toString: () => string (必填) — Returns a string representation of an object.; key.valueOf: () => symbol (必填) — Returns the primitive value of the specified object.; key.description: string (必填) — Expose the [[Description]] internal slot of a symbol directly.; key.__@toPrimitive@4101: (hint: string) => symbol (必填) — Converts a Symbol object to a symbol.; key.__@toStringTag@3987: string (必填); defaultValue: T (必填)

packages/element/src/internal/core/signal-context.ts:183
Context接口 · 公开
@openelement/element · root

上下文令牌,包含协议使用的键和默认值。

Context<T>
英文源码说明

A typed context token: protocol identity (`key`) plus its default value.

key.toString: () => string (必填) — Returns a string representation of an object.; key.valueOf: () => symbol (必填) — Returns the primitive value of the specified object.; key.description: string (必填) — Expose the [[Description]] internal slot of a symbol directly.; key.__@toPrimitive@4101: (hint: string) => symbol (必填) — Converts a Symbol object to a symbol.; key.__@toStringTag@3987: string (必填); defaultValue: T (必填)

packages/element/src/internal/core/signal-context.ts:13
createContext函数 · 公开
@openelement/element · root

创建供提供方与消费方共享的带类型上下文令牌。

<T>(key: symbol, defaultValue: T): Context<T>
英文源码说明

Create a typed context token shared between provider and consumer elements.

toString: () => string (必填) — Returns a string representation of an object.; valueOf: () => symbol (必填) — Returns the primitive value of the specified object.; description: string (必填) — Expose the [[Description]] internal slot of a symbol directly.; __@toPrimitive@4101: (hint: string) => symbol (必填) — Converts a Symbol object to a symbol.; __@toStringTag@3987: string (必填)

packages/element/src/internal/core/signal-context.ts:58
createDocumentStyleResources函数 · 公开
@openelement/element · root

为一次服务端渲染创建文档级样式表收集器。

(): DocumentStyleResources
英文源码说明

Create the per-render document stylesheet collection.

packages/element/src/internal/core/html-escape.ts:133
createLogger函数 · 公开
@openelement/element · root

创建在每条消息前加上标签的日志记录器。

(tag: string): Logger
英文源码说明

Create a {@link Logger} that prefixes every message with `[tag]`.

packages/element/src/internal/core/logger.ts:18
DANGEROUS_KEYS常量 · 公开
@openelement/element · root

从不可信属性复制数据时必须排除的对象原型键。

ReadonlySet<string>
英文源码说明

Object prototype keys that must never be injected from untrusted props.

packages/element/src/internal/core/security.ts:25
deepGetElementById函数 · 公开
@openelement/element · root

在指定根节点及其嵌套 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
documentStreamParts函数 · 公开
@openelement/element · root

使用相同的文档序列化规则生成流式响应的首尾片段,保留正文容器供流写入。

(options?: DocumentWrapOptions): { prefix: string; suffix: string; }
英文源码说明

The same document serialization boundary, with only body wrappers left open.

title?: string (可选); lang?: string (可选); clientScript?: string (可选); scripts?: DocumentScriptDescriptor[] (可选); meta.description?: string (可选); meta.tags?: Record<string, string | number | boolean>[] (可选); devScripts?: string (可选); headExtras?: string (可选); dangerouslyHeadFragments?: string[] (可选); allowHeadExtrasScripts?: boolean (可选); links?: { rel: string; href: string; hreflang?: string; }[] (可选); structuredData?: readonly Record<string, unknown>[] (可选); cspNonce?: string (可选); streamBootstrap?: string (可选) — Trusted framework bootstrap emitted synchronously in the document head.; styleLinks?: readonly string[] (可选) — The document's light-root component stylesheets: external resource URLs (alpha15 S lane, S-C1.2) serialized as marked `<link rel="stylesheet">` nodes after `headExtras`, so a light component is styled by the document that contains it — without JavaScript and without a runtime style node.

packages/element/src/internal/core/html-escape.ts:205
DocumentStyleResources接口 · 公开
@openelement/element · root

记录一次服务端渲染所发现的文档级样式表,供组件序列化与文档 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.

links: readonly string[] (必填) — Discovered resource URLs, deduplicated, in discovery (cascade) order.; add: (urls: readonly string[]) => void (必填) — Record the external stylesheet URLs one rendered component contributes.

packages/element/src/internal/core/html-escape.ts:125
effect函数 · 公开
@openelement/element · root

运行副作用,并在使用的信号发生变化时重新执行和订阅。

(fn: () => void | Unsubscribe): Unsubscribe
英文源码说明

Run a side effect that re-subscribes whenever its signal dependencies change.

packages/element/src/internal/signal/framework.ts:27
ensureDeepFragmentNavigation函数 · 公开
@openelement/element · root

为文档安装深层锚点导航,使同页链接能定位到嵌套 Shadow Root 内的目标。

(options?: DeepFragmentOptions): void
英文源码说明

Install (once per document) framework-level fragment navigation: a same-document anchor click whose target lives inside a nested shadow root scrolls to it and pushes the hash instead of being dropped by the browser. `{ enabled: false }` opts an application out.

enabled?: boolean (可选) — Set false before installation to opt out for an application.

packages/element/src/internal/core/deep-fragment.ts:67
ensurePreHydrationClickCapture函数 · 公开
@openelement/element · root

在元素升级前捕获发往待启用交互岛的用户操作,接管 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.

addEventListener: (type: string, callback: EventListenerOrEventListenerObject | null, options?: AddEventListenerOptions | boolean) => void (必填) — The **`addEventListener()`** method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target. [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener); dispatchEvent: (event: Event) => boolean (必填) — The **`dispatchEvent()`** method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order. The normal event processing rules (including the capturing and optional bubbling phase) also apply to events dispatched manually with dispatchEvent(). [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent); removeEventListener: (type: string, callback: EventListenerOrEventListenerObject | null, options?: EventListenerOptions | boolean) => void (必填) — The **`removeEventListener()`** method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target. The event listener to be removed is identified using a combination of the event type, the event listener function itself, and various optional options that may affect the matching process; see Matching event listeners for removal.…

packages/element/src/internal/compiled/runtime/pre-upgrade-events.ts:662
ERROR_PREFIX常量 · 公开
@openelement/element · root

openElement 错误消息使用的前缀。

"[openElement]"
英文源码说明

Error message prefix for all openElement errors.

packages/protocol/src/errors.ts:50
ErrorTelemetryHook类型 · 公开
@openelement/element · root

接收所有通过错误遥测渠道上报的 OpenElementError。

ErrorTelemetryHook
英文源码说明

Callback receiving every reported {@linkcode OpenElementError} for telemetry.

packages/protocol/src/errors.ts:132
escapeAttr函数 · 公开
@openelement/element · root

对 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
escapeHtml函数 · 公开
@openelement/element · root

对文本中的五个 HTML 特殊字符进行转义。

(str: string): string
英文源码说明

Escape the five HTML-significant characters in text content.

packages/element/src/internal/core/html-escape.ts:39
formatError函数 · 公开
@openelement/element · root

将未知类型的异常值格式化为可读的字符串。

(e: unknown): string
英文源码说明

Format an unknown thrown value as a human-readable string.

packages/element/src/internal/core/errors.ts:52
FrameworkOptions接口 · 公开
@openelement/element · root
FrameworkOptions
英文源码说明

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.

renderer?: "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).; routesDir?: string (可选) — Directory the route scanner walks, relative to the Vite root. Defaults to `app/routes`.; islandsDir?: string (可选) — Directory island modules are discovered in. Defaults to `app/islands`.; packageIslands?: 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…; layout?: LayoutConfig (可选) — Layout declaration; `false` disables the layout, `'default'` uses the built-in one.; layouts?: LayoutsConfig (可选) — Named layout declarations keyed by layout name.; headExtras?: string (可选) — @dangerous injected as-is, only use with controlled content; html.lang?: string (可选); html.title?: string (可选); inject.stylesheets?: (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.; inject.scripts?: (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.; inject.headFragments?: 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>`.; ssr.noExternal?: (string | RegExp)[] (可选); island.upgradeStrategy?: "load" | "idle" | "visible" | "only" | "none" (可选); build.outDir?: string (可选) — Output directory for the build artifacts. Defaults to `dist`.; build.manifestBudget?: { 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.; viewTransition?: boolean (可选) — Enable the View Transitions API for client navigations. Defaults to true.; speculation?: 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.; middleware.cors?: boolean (可选) — Built-in CORS middleware. Default-ON; pass `false` to disable.; middleware.corsOrigin?: string | string[] (可选) — Static CORS allowlist data, serialized into the generated entry as JSON. Mutually exclusive with {@link FrameworkOptions.middleware.corsOriginModule }.; middleware.corsOriginModule?: string (可选) — Path 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`.; middleware.requestId?: boolean (可选) — Emit and honor a per-request id header. Default-ON; pass `false` to disable.; middleware.logger?: boolean (可选) — Log each request through the built-in logger. Default-ON; pass `false` to disable.; middleware.securityHeaders?: boolean (可选) — Attach the built-in security response headers. Default-ON; pass `false` to disable.; middleware.csp?: { policy?: string; nonce?: boolean; reportOnly?: boolean; } (可选) — Content-Security-Policy emission: the policy string, nonce generation, and report-only mode.; middleware.use?: 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…

packages/protocol/src/framework.ts:180
HYDRATION_STRATEGIES常量 · 公开
@openelement/element · root

运行时支持的 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
HydrationStrategy类型 · 公开
@openelement/element · root

控制交互岛何时启用,也可跳过浏览器 hydration。

"load" | "idle" | "visible" | "only" | "none"
英文源码说明

Island hydration trigger: 'load' | 'idle' | 'visible' | 'only'.

packages/protocol/src/framework.ts:30
IDLE_FALLBACK_TIMEOUT_MS常量 · 公开
@openelement/element · root

环境缺少 requestIdleCallback 和 requestAnimationFrame 时,空闲 hydration 的备用延时(毫秒)。

50
英文源码说明

Idle-hydration scheduling fallback (milliseconds) when neither `requestIdleCallback` nor `requestAnimationFrame` is available.

packages/protocol/src/policy.ts:70
injectPropsSafe函数 · 公开
@openelement/element · root

将调用方提供的属性写入目标对象,跳过受保护的键,并容忍只读属性。

(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
isDangerousKey函数 · 公开
@openelement/element · root

判断属性键是否为框架在写入属性时必须拒绝的对象原型键。

(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
IslandOptions接口 · 公开
@openelement/element · root

交互岛的交付选项,包括 hydration 策略和是否参与 SSR 或 DSD。

IslandOptions
英文源码说明

Per-island delivery options (hydration strategy, SSR/DSD participation).

hydrate?: "load" | "idle" | "visible" | "only" | "none" (可选) — Hydration strategy: - 'load': load immediately when module is imported - 'idle': defer to requestIdleCallback (default) - 'visible': use IntersectionObserver to defer until element is visible - 'only': client-only render, no DSD/SSR output Named `hydrate` to match `defineIslandConfig()` in the Router package — one option name across both packages.; dsd?: boolean (可选) — Whether to use DSD for SSR rendering of this island. Honored by the build-side island scan (via `defineIslandConfig`), not by `defineIsland()` itself: passing it in `IslandOptions` has no runtime effect.; ssr?: boolean (可选) — Whether this island may be admitted into server rendering. Like `dsd`, decided by the build-side island scan; inert when passed to `defineIsland()`.

packages/protocol/src/island.ts:8
isSafeAttributeName函数 · 公开
@openelement/element · root

服务端渲染检查属性名时调用的公共校验入口,规则和协议层一致。

(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
isValidTagName函数 · 公开
@openelement/element · root

判断字符串是否符合 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类型 · 公开
@openelement/element · root

为路由选择内置布局、指定自定义布局及其模块和属性,或关闭布局。

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类型 · 公开
@openelement/element · root

为页面路由获取数据的 loader。

Loader<T, Env, Platform, Route>
英文源码说明

Route loader: fetches data for a page route.

packages/protocol/src/data.ts:56
LoaderContext接口 · 公开
@openelement/element · root

传给动态路由 loader 的请求上下文。

LoaderContext<Env, Platform, Route>
英文源码说明

Context passed to a request-time ('dynamic') route loader.

request: Request (必填); params: Record<string, string> (必填); env: Env (必填); platform: Platform (必填); responseHeaders: Headers (必填) — Mutable response-only channel merged into the framework response.; route: Route (必填)

packages/protocol/src/data.ts:40
LocalePath接口 · 公开
@openelement/element · root

随语言解析的路径契约。

LocalePath
英文源码说明

Locale-aware resolved path contract.

locale: string (必填); path: string (必填); localizedPath: string (必填); isDefaultLocalePath: boolean (必填)

packages/protocol/src/framework.ts:82
Logger接口 · 公开
@openelement/element · root

带标签的控制台日志接口。

Logger
英文源码说明

logger.ts - Tagged console logger. Lightweight scoped logger. Returns plain functions so it is tree-shakable and has zero class overhead.

debug: (msg: string, ...args: unknown[]) => void (必填); info: (msg: string, ...args: unknown[]) => void (必填); warn: (msg: string, ...args: unknown[]) => void (必填); error: (msg: string, ...args: unknown[]) => void (必填)

packages/element/src/internal/core/logger.ts:10
MAX_ACTION_BODY_BYTES常量 · 公开
@openelement/element · root

生成的服务端入口对 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
MAX_COMPOSITION_DEPTH常量 · 公开
@openelement/element · root

renderToString 允许展开的嵌套元素层数,避免循环组合导致无穷递归。

8
英文源码说明

Nested element expansion depth bound for `renderToString`: cyclic component composition fails closed instead of recursing without end.

packages/protocol/src/policy.ts:51
Middleware类型 · 公开
@openelement/element · root

基于标准 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
onConnect函数 · 公开
@openelement/element · root

生成的自定义元素每次连接时运行回调,包括重新连接。若回调返回清理函数,元素断开时会调用它。

(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
onDispose函数 · 公开
@openelement/element · root

在生成的元素实例最终销毁时运行一次回调,调用顺序在该连接的清理函数之后。

(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
onError函数 · 公开
@openelement/element · root

处理当前生成元素在连接、接管服务端标记、更新或处理 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
onPropertyChange函数 · 公开
@openelement/element · root

元素的已声明属性写入新值后运行回调,包括 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
OpenElementAttribute接口 · 公开
@openelement/element · root

自定义元素声明中记录的一个 attribute。

OpenElementAttribute
英文源码说明

One documented attribute of a custom element declaration.

name: string (必填); type?: string (可选); default?: string (可选); description?: string (可选); reflects?: boolean (可选); fieldName?: string (可选)

packages/protocol/src/manifest.ts:15
OpenElementCssPart接口 · 公开
@openelement/element · root

自定义元素声明中记录的一个 CSS part。

OpenElementCssPart
英文源码说明

One documented CSS part of a custom element declaration.

name: string (必填); description?: string (可选)

packages/protocol/src/manifest.ts:38
OpenElementDeclaration接口 · 公开
@openelement/element · root

包清单中的自定义元素声明,包括标签名、成员和交付信息。

OpenElementDeclaration
英文源码说明

One custom element declaration in a package manifest: tag, members and delivery metadata.

tagName: string (必填); className?: string (可选); superclassName?: string (可选); attributes?: OpenElementAttribute[] (可选); events?: OpenElementEvent[] (可选); slots?: OpenElementSlot[] (可选); cssParts?: OpenElementCssPart[] (可选); openElement.ssr?: boolean (可选); openElement.dsd?: boolean (可选); openElement.layer?: ComponentLayer (可选); openElement.hydrate?: "load" | "idle" | "visible" | "only" | "none" (可选); openElement.status?: "stable" | "experimental" (可选) — Stability marker from the owning package's manifest policy.; openElement.module?: string (可选); openElement.export?: string (可选); openElement.tailwind?: OpenElementTailwindDeclaration (可选); openElement.root?: "light" | "shadow" | "closed" (可选) — The host root a generated-element declaration was compiled with. Absent for a class declaration (its descriptor owns the root) and for a generated declaration whose sidecar declares none (the descriptor default is light).; openElement.styles?: readonly string[] (可选) — The authored package-relative `.css` specifiers a generated SHADOW host declares, published so a consuming build can emit the sheet and hand its URL to the DSD style-link carrier. Absent when the component declares none; class declarations deliver their sheets through `static styles` instead.; openElement.ssrHostExport?: string (可选) — The compiler-emitted SSR host producer's export name (`<Component>__ssrHost`) for a generated declaration whose root is `shadow`. A consuming build cannot otherwise learn it: the name is the compiler's return-only `ssrHostExport` metadata, and re-deriving it from a naming convention inside the router would be exactly the drift ADR-0182 forbids ("read the compiler's return value, never re-derive i…; description?: string (可选)

packages/protocol/src/manifest.ts:116
OpenElementError类 · 公开
@openelement/element · root

框架错误,提供稳定错误码、严重程度、发生阶段和可恢复性。

class OpenElementError extends Error
英文源码说明

Framework error carrying a stable code, severity, phase and recoverability contract.

packages/protocol/src/errors.ts:100
OpenElementEvent接口 · 公开
@openelement/element · root

自定义元素声明中记录的一个自定义事件。

OpenElementEvent
英文源码说明

One documented custom event of a custom element declaration.

name: string (必填); type?: string (可选); description?: string (可选)

packages/protocol/src/manifest.ts:25
OpenElementPackageManifest接口 · 公开
@openelement/element · root

包级组件清单,记录其中声明的组件。

OpenElementPackageManifest
英文源码说明

Package manifest of component declarations (not a Custom Elements Manifest).

schemaVersion: string (必填); packageName: string (必填); version: string (必填); description?: string (可选); author?: string (可选); license?: string (可选); homepage?: string (可选); repository?: string (可选); declarations: OpenElementDeclaration[] (必填)

packages/protocol/src/manifest.ts:129
OpenElementRouteKind类型 · 公开
@openelement/element · root

应用与构建驱动共享的路由类别。

OpenElementRouteKind
英文源码说明

Host-agnostic route and asset contracts shared by app and build drivers.

packages/protocol/src/app-model.ts:2
OpenElementRouteNode接口 · 公开
@openelement/element · root

路由树节点,记录匹配路径、路由类型、源码与模块路径、可选的标签和参数,以及子路由。

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`.

kind: OpenElementRouteKind (必填); path: string (必填); filePath?: string (可选); importPath?: string (可选); tagName?: string (可选); paramNames?: string[] (可选); children?: OpenElementRouteNode[] (可选); meta?: Record<string, unknown> (可选)

packages/protocol/src/app-model.ts:9
OpenElementSlot接口 · 公开
@openelement/element · root

自定义元素声明中记录的一个插槽。

OpenElementSlot
英文源码说明

One documented slot of a custom element declaration.

name: string (必填); description?: string (可选)

packages/protocol/src/manifest.ts:32
PROBLEM_JSON_MEDIA_TYPE常量 · 公开
@openelement/element · root

RFC 9457 Problem Details 错误响应使用的媒体类型。

"application/problem+json"
英文源码说明

Media type of the RFC 9457 action error channel (#863).

packages/protocol/src/data.ts:117
ProblemDetails接口 · 公开
@openelement/element · root

表单 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.

type: string (必填) — URI reference identifying the problem type; 'about:blank' when none applies.; title: string (必填) — Short human-readable summary (the HTTP reason phrase for 'about:blank').; status.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; status.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; status.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; status.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; status.valueOf: () => number (必填) — Returns the primitive value of the specified object.; status.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.; detail?: string (可选) — Human-readable explanation specific to this occurrence.

packages/protocol/src/data.ts:105
provideContext函数 · 公开
@openelement/element · root

提供普通的协议上下文值。用于提供值的 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:131
ReadonlySignal接口 · 公开
@openelement/element · root

computed 等派生值使用的只读信号接口。

ReadonlySignal<T>
英文源码说明

Read-only signal protocol used by computed values.

value: T (必填); subscribe: (fn: (value: T) => void) => Unsubscribe (必填); __@[email protected]: () => boolean (必填) — Returns the primitive value of the specified object.

packages/protocol/src/signal.ts:26
ref函数 · 公开
@openelement/element · root

为组件内的一个原生 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
releaseConsumedContext函数 · 公开
@openelement/element · root

释放某次带宿主的 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.

value: unknown (必填); subscribe: (fn: (value: unknown) => void) => Unsubscribe (必填); __@[email protected]: () => boolean (必填) — Returns the primitive value of the specified object.

packages/element/src/internal/core/signal-context.ts:208
RenderError类 · 公开
@openelement/element · root

可恢复的渲染错误,携带出错组件的文件路径与标签名。

class RenderError extends OpenElementError
英文源码说明

Recoverable render-phase error carrying the failing component path and tag.

packages/element/src/internal/core/errors.ts:95
renderToString函数 · 公开
@openelement/element · root

在服务端渲染一个已编译的元素,直接返回序列化后的声明式 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
RenderToStringOptions接口 · 公开
@openelement/element · root

一次 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.

componentClass?: CustomElementConstructor (可选); props?: Record<string, unknown> (可选); sourceInfo.route?: string (可选); sourceInfo.source?: string (可选); ssrRenderableTags?: readonly string[] (可选) — Build-admitted nested compiled tags. Omitted means shell-only rendering.; projectedChildren?: ReadonlyMap<string, TrustedHtml> (可选) — Trusted parent-owned light children keyed by slot name.; hostChildren?: TrustedHtml (可选) — Trusted parent-owned light children emitted AFTER the host's DSD template (a shadow-root host's slotted content). This is the shadow-side sibling of `projectedChildren`: a light root substitutes projections into its own `<slot>` elements, a shadow root distributes appended light DOM natively. Both are the compiled children channel — compiler-produced final HTML carrying the trustedHtml brand, nev…; onNestedFailure?: ((error: unknown) => void) (可选) — `16b-EB` (execution plan §19.2): the report channel for a descendant producer that threw while the enclosing error boundary owns it. The boundary supplies this; the renderer routes the caught failure here instead of failing the whole render, and renders the boundary's fallback bytes in the failing descendant's place. OMITTED is the no-boundary render: the failure re-raises, which is the unchanged…; nestedStyleSink?: Set<string> (可选) — Sheet URLs a nested LIGHT child lifted into the enclosing template (F16).; documentStyles?: DocumentStyleSink (可选) — The render's document stylesheet collection (alpha15 S lane, S-C1.2). Every light-root component serialized in this render reports its external sheet URLs here, and the document wrapper declares them in the head. The caller owns the collection's lifetime — one per document render — so styles discovered for one page can never reach another page's head.

packages/element/src/public-runtime.ts:170
reportError函数 · 公开
@openelement/element · root

将框架错误交给遥测钩子,无钩子时写入 console.error。

(error: OpenElementError): void
英文源码说明

Report an {@linkcode OpenElementError} to the telemetry hook, or console.error when none is installed.

code: string (必填); severity: ErrorSeverity (必填); phase: ErrorPhase (必填); recoverable: boolean (必填); statusCode.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; statusCode.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; statusCode.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; statusCode.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; statusCode.valueOf: () => number (必填) — Returns the primitive value of the specified object.; statusCode.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.; toJSON: () => Record<string, unknown> (必填); name: string (必填); message: string (必填); stack?: string (可选); cause?: unknown (可选)

packages/element/src/internal/core/errors.ts:139
RouteEntry接口 · 公开
@openelement/element · root

扫描后入选的路由,记录 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.

path: string (必填); filePath: string (必填); type: "page" | "api" | "island" | "special" (必填); varName: string (必填); tagName?: string (可选); definePage?: boolean (可选) — True when the route module's default export is a definePage() definition (#960 — registration decoupling). The generated entry registers the page class under the path-derived fallback tag and IGNORES the tagName export for registration: on a definePage route the export only names a content element. Plain element routes keep tagName as their registration tag.; functionPage?: string (可选) — The server function page fact (alpha15 server lane): the exported server function component the route's `export default definePage(Component)` was called over. Present only when the argument is a plain identifier resolving to a component THIS module declares — an inline arrow or an unexported local never records it (the R1 admission rule mirrored, so a shape whose JSX would escape to runtime is n…; source?: string (可选) — Source text captured during scanning when includeSource is enabled.; hasEnhancedForms?: boolean (可选) — True when the page route source carries data-open-enhance (#569): the client entry must ship the form-enhancement layer even when the app has zero islands.; special?: SpecialFileType (可选); params?: string[] (可选)

packages/protocol/src/framework.ts:113
ServerRouteContext接口 · 公开
@openelement/element · root

请求时渲染和静态站点生成共用的服务端路由上下文。

ServerRouteContext<Env, Platform, Route>
英文源码说明

Canonical request-time/SSG server route context.

request: Request (必填); params: Record<string, string> (必填); env: Env (必填); platform: Platform (必填); responseHeaders: Headers (必填) — Mutable response-only channel merged into the framework response.; route: Route (必填)

packages/protocol/src/data.ts:25
ServerRouteMetadata接口 · 公开
@openelement/element · root

动态路由 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().

path: string (必填); filePath: string (必填)

packages/protocol/src/data.ts:19
setErrorTelemetryHook函数 · 公开
@openelement/element · root

安装或替换整个进程使用的错误遥测钩子。

(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
signal函数 · 公开
@openelement/element · root

创建可读写的响应式状态。

<T>(initialValue: T): WritableSignal<T>
英文源码说明

Create a writable signal through the selected signal engine.

packages/element/src/internal/signal/framework.ts:19
Signal类型 · 公开
@openelement/element · root

接受可写信号或只读信号的 API 所用类型。

Signal<T>
英文源码说明

Alias for APIs that accept either writable or read-only signals.

packages/protocol/src/signal.ts:31
SpecialFileType类型 · 公开
@openelement/element · root

路由扫描器按文件名识别的特殊类型,包括 renderer 和 middleware。

SpecialFileType
英文源码说明

Special file kinds the route scanner recognizes by filename: `renderer` and `middleware`.

packages/protocol/src/framework.ts:79
SsrAdmissionDecision接口 · 公开
@openelement/element · root

构建对自定义元素的 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.

tagName: string (必填); modulePath: string (必填) — Module path of the island declaration. Empty for 'foreign' decisions: a foreign tag is consumed in JSX but declares no module the build owns.; source: "local" | "package" | "nested" | "foreign" (必填) — 'foreign' (#979): a third-party WC tag discovered by the foreign-tag scanner in page/island JSX — recorded for visibility only; SSR still treats it as an opaque passthrough (renderPath 'client-only').; renderPath: "ssr+client" | "client-only" | "rejected" (必填); reason: string (必填)

packages/protocol/src/render.ts:37
STREAM_FRAME_FORBIDDEN_TAGS常量 · 公开
@openelement/element · root

浏览器拒绝装入所属 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
STREAM_FRAME_UNSAFE_URL常量 · 公开
@openelement/element · root

流式片段的 URL 属性不可使用的协议。

RegExp
英文源码说明

Schemes that make a URL attribute unsafe in a streamed frame.

packages/protocol/src/stream-frame-policy.ts:60
STREAM_FRAME_URL_ATTRIBUTES常量 · 公开
@openelement/element · root

流式片段中需要检查 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
STREAM_FRAME_URL_CONTROL_MAX常量 · 公开
@openelement/element · root

检查 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
STREAM_MAX_FIELDS常量 · 公开
@openelement/element · root

一个流式路由允许在清单中声明的延迟字段数上限。

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
STREAM_MAX_OWNERS常量 · 公开
@openelement/element · root

一个流式路由清单可以引用的 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
STREAM_MAX_PAYLOAD_LENGTH常量 · 公开
@openelement/element · root

流式载荷的最大序列化长度,以 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
STREAM_MAX_SEED_PROPERTIES常量 · 公开
@openelement/element · root

流式 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
STREAM_TIMEOUT_MS常量 · 公开
@openelement/element · root

流式响应等待延迟字段完成的时间上限(毫秒)。

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
StyleSheet常量 · 公开
@openelement/element · root

可跨执行环境使用的样式表构造器,按环境选择原生 CSSStyleSheet 或兼容实现。

new () => StyleSheetLike
英文源码说明

Cross-realm StyleSheet constructor: the native CSSStyleSheet or the internal shim.

packages/element/src/internal/core/style-sheet.ts:110
StyleSheetLike接口 · 公开
@openelement/element · root

原生样式表与兼容实现共用的最小接口,包括 replaceSync 和 cssRules。

StyleSheetLike
英文源码说明

Minimal stylesheet contract (replaceSync + cssRules) satisfied by native and shim sheets.

replaceSync: (text: string) => void (必填); cssRules: StyleSheetRule[] (必填)

packages/protocol/src/style-sheet.ts:14
trustedHtml函数 · 公开
@openelement/element · root

将 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
TrustedHtml接口 · 公开
@openelement/element · root

标识应用已明确审查并信任的 HTML。

TrustedHtml
英文源码说明

Opaque capability marking HTML the application has explicitly vetted as trusted.

html: string (必填)

packages/element/src/internal/core/security.ts:83
unsafeStreamFrameAttribute函数 · 公开
@openelement/element · root

判断 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
useContext函数 · 公开
@openelement/element · root

订阅最近提供者的上下文,返回由实例持有的信号。没有提供者时读到令牌的默认值。

<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.

key.toString: () => string (必填) — Returns a string representation of an object.; key.valueOf: () => symbol (必填) — Returns the primitive value of the specified object.; key.description: string (必填) — Expose the [[Description]] internal slot of a symbol directly.; key.__@toPrimitive@4101: (hint: string) => symbol (必填) — Converts a Symbol object to a symbol.; key.__@toStringTag@3987: string (必填); defaultValue: T (必填)

packages/element/src/internal/core/compile-lifecycle.ts:285
useHost函数 · 公开
@openelement/element · root

获取当前组件所在的自定义元素。用于在组件中访问宿主节点。

(): 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
wrapInDocument函数 · 公开
@openelement/element · root

为渲染后的 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_FETCH_HEADER常量 · 公开
@openelement/element · ./authoring

选择表单 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
assertValidTagName函数 · 公开
@openelement/element · ./authoring

检查名称是否符合自定义元素的标签名规则。

(tagName: string): void
英文源码说明

Assert that a tag name is a valid custom element name.

packages/element/src/internal/core/tag-utils.ts:50
DANGEROUS_KEYS常量 · 公开
@openelement/element · ./authoring

从不可信属性复制数据时必须排除的对象原型键。

ReadonlySet<string>
英文源码说明

Object prototype keys that must never be injected from untrusted props.

packages/element/src/internal/core/security.ts:25
ERROR_PREFIX常量 · 公开
@openelement/element · ./authoring

openElement 错误消息使用的前缀。

"[openElement]"
英文源码说明

Error message prefix for all openElement errors.

packages/protocol/src/errors.ts:50
HYDRATION_STRATEGIES常量 · 公开
@openelement/element · ./authoring

运行时支持的 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
HydrationStrategy类型 · 公开
@openelement/element · ./authoring

控制交互岛何时启用,也可跳过浏览器 hydration。

"load" | "idle" | "visible" | "only" | "none"
英文源码说明

Island hydration trigger: 'load' | 'idle' | 'visible' | 'only'.

packages/protocol/src/framework.ts:30
injectPropsSafe函数 · 公开
@openelement/element · ./authoring

将调用方提供的属性写入目标对象,跳过受保护的键,并容忍只读属性。

(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
isDangerousKey函数 · 公开
@openelement/element · ./authoring

判断属性键是否为框架在写入属性时必须拒绝的对象原型键。

(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
isSafeAttributeName函数 · 公开
@openelement/element · ./authoring

服务端渲染检查属性名时调用的公共校验入口,规则和协议层一致。

(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
isValidTagName函数 · 公开
@openelement/element · ./authoring

判断字符串是否符合 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
MAX_ACTION_BODY_BYTES常量 · 公开
@openelement/element · ./authoring

生成的服务端入口对 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
OpenElementError类 · 公开
@openelement/element · ./authoring

框架错误,提供稳定错误码、严重程度、发生阶段和可恢复性。

class OpenElementError extends Error
英文源码说明

Framework error carrying a stable code, severity, phase and recoverability contract.

packages/protocol/src/errors.ts:100
PROBLEM_JSON_MEDIA_TYPE常量 · 公开
@openelement/element · ./authoring

RFC 9457 Problem Details 错误响应使用的媒体类型。

"application/problem+json"
英文源码说明

Media type of the RFC 9457 action error channel (#863).

packages/protocol/src/data.ts:117
STREAM_FRAME_FORBIDDEN_TAGS常量 · 公开
@openelement/element · ./authoring

浏览器拒绝装入所属 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
STREAM_FRAME_UNSAFE_URL常量 · 公开
@openelement/element · ./authoring

流式片段的 URL 属性不可使用的协议。

RegExp
英文源码说明

Schemes that make a URL attribute unsafe in a streamed frame.

packages/protocol/src/stream-frame-policy.ts:60
STREAM_FRAME_URL_ATTRIBUTES常量 · 公开
@openelement/element · ./authoring

流式片段中需要检查 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
STREAM_FRAME_URL_CONTROL_MAX常量 · 公开
@openelement/element · ./authoring

检查 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
STREAM_MAX_FIELDS常量 · 公开
@openelement/element · ./authoring

一个流式路由允许在清单中声明的延迟字段数上限。

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
STREAM_MAX_OWNERS常量 · 公开
@openelement/element · ./authoring

一个流式路由清单可以引用的 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
STREAM_MAX_PAYLOAD_LENGTH常量 · 公开
@openelement/element · ./authoring

流式载荷的最大序列化长度,以 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
STREAM_MAX_SEED_PROPERTIES常量 · 公开
@openelement/element · ./authoring

流式 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
STREAM_TIMEOUT_MS常量 · 公开
@openelement/element · ./authoring

流式响应等待延迟字段完成的时间上限(毫秒)。

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
__setRequestTimeStyleSheetUrls函数 · 公开
@openelement/element · ./base

为当前服务端进程设置已生成的样式表 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类型 · 公开
@openelement/element · ./base

处理页面路由的表单提交。

Action<T, Env, Platform, Route>
英文源码说明

Route action: handles form submissions for a page route.

packages/protocol/src/data.ts:64
ACTION_FETCH_HEADER常量 · 公开
@openelement/element · ./base

选择表单 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
ActionContext接口 · 公开
@openelement/element · ./base

传给路由 action 的上下文,包含 loader 上下文。

ActionContext<Env, Platform, Route>
英文源码说明

Context passed to a route action function (extends loader context).

formData: FormData (必填); request: Request (必填); params: Record<string, string> (必填); env: Env (必填); platform: Platform (必填); responseHeaders: Headers (必填) — Mutable response-only channel merged into the framework response.; route: Route (必填)

packages/protocol/src/data.ts:47
ActionResult类型 · 公开
@openelement/element · ./base

脚本提交表单时返回的联合类型。校验失败返回 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
assertValidTagName函数 · 公开
@openelement/element · ./base

检查名称是否符合自定义元素的标签名规则。

(tagName: string): void
英文源码说明

Assert that a tag name is a valid custom element name.

packages/element/src/internal/core/tag-utils.ts:50
collectPublicProps函数 · 公开
@openelement/element · ./base

收集宿主对象上所有公开的自有属性。

(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
CompatibilityClassification接口 · 公开
@openelement/element · ./base

兼容性扫描为每个标签记录分级、原因、来源和对应的 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.

tagName: string (必填); tier: CompatibilityTier (必填); reason: string (必填); source: "local" | "package" | "nested" (必填); modulePath?: string (可选); ssr?: boolean (可选); dsd?: boolean (可选); hydrate?: string (可选)

packages/protocol/src/framework.ts:347
CompatibilityTier类型 · 公开
@openelement/element · ./base

标签的构建兼容级别,区分服务端渲染、仅浏览器渲染、实验支持和拒绝构建。

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
ComponentLayer类型 · 公开
@openelement/element · ./base

组件的交付层级,区分静态 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
computed函数 · 公开
@openelement/element · ./base

根据依赖计算一个只读响应式值。

<T>(fn: () => T): ReadonlySignal<T>
英文源码说明

Create a derived read-only signal recomputed from its dependencies.

packages/element/src/internal/signal/framework.ts:23
consumeContext函数 · 公开
@openelement/element · ./base

将上下文投影为消费端的响应式值。传入宿主时,消费端负责通过 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.

key.toString: () => string (必填) — Returns a string representation of an object.; key.valueOf: () => symbol (必填) — Returns the primitive value of the specified object.; key.description: string (必填) — Expose the [[Description]] internal slot of a symbol directly.; key.__@toPrimitive@5327: (hint: string) => symbol (必填) — Converts a Symbol object to a symbol.; key.__@toStringTag@5213: string (必填); defaultValue: T (必填)

packages/element/src/internal/core/signal-context.ts:183
Context接口 · 公开
@openelement/element · ./base

上下文令牌,包含协议使用的键和默认值。

Context<T>
英文源码说明

A typed context token: protocol identity (`key`) plus its default value.

key.toString: () => string (必填) — Returns a string representation of an object.; key.valueOf: () => symbol (必填) — Returns the primitive value of the specified object.; key.description: string (必填) — Expose the [[Description]] internal slot of a symbol directly.; key.__@toPrimitive@5327: (hint: string) => symbol (必填) — Converts a Symbol object to a symbol.; key.__@toStringTag@5213: string (必填); defaultValue: T (必填)

packages/element/src/internal/core/signal-context.ts:13
createContext函数 · 公开
@openelement/element · ./base

创建供提供方与消费方共享的带类型上下文令牌。

<T>(key: symbol, defaultValue: T): Context<T>
英文源码说明

Create a typed context token shared between provider and consumer elements.

toString: () => string (必填) — Returns a string representation of an object.; valueOf: () => symbol (必填) — Returns the primitive value of the specified object.; description: string (必填) — Expose the [[Description]] internal slot of a symbol directly.; __@toPrimitive@5327: (hint: string) => symbol (必填) — Converts a Symbol object to a symbol.; __@toStringTag@5213: string (必填)

packages/element/src/internal/core/signal-context.ts:58
createDocumentStyleResources函数 · 公开
@openelement/element · ./base

为一次服务端渲染创建文档级样式表收集器。

(): DocumentStyleResources
英文源码说明

Create the per-render document stylesheet collection.

packages/element/src/internal/core/html-escape.ts:133
createLogger函数 · 公开
@openelement/element · ./base

创建在每条消息前加上标签的日志记录器。

(tag: string): Logger
英文源码说明

Create a {@link Logger} that prefixes every message with `[tag]`.

packages/element/src/internal/core/logger.ts:18
DANGEROUS_KEYS常量 · 公开
@openelement/element · ./base

从不可信属性复制数据时必须排除的对象原型键。

ReadonlySet<string>
英文源码说明

Object prototype keys that must never be injected from untrusted props.

packages/element/src/internal/core/security.ts:25
deepGetElementById函数 · 公开
@openelement/element · ./base

在指定根节点及其嵌套 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
documentStreamParts函数 · 公开
@openelement/element · ./base

使用相同的文档序列化规则生成流式响应的首尾片段,保留正文容器供流写入。

(options?: DocumentWrapOptions): { prefix: string; suffix: string; }
英文源码说明

The same document serialization boundary, with only body wrappers left open.

title?: string (可选); lang?: string (可选); clientScript?: string (可选); scripts?: DocumentScriptDescriptor[] (可选); meta.description?: string (可选); meta.tags?: Record<string, string | number | boolean>[] (可选); devScripts?: string (可选); headExtras?: string (可选); dangerouslyHeadFragments?: string[] (可选); allowHeadExtrasScripts?: boolean (可选); links?: { rel: string; href: string; hreflang?: string; }[] (可选); structuredData?: readonly Record<string, unknown>[] (可选); cspNonce?: string (可选); streamBootstrap?: string (可选) — Trusted framework bootstrap emitted synchronously in the document head.; styleLinks?: readonly string[] (可选) — The document's light-root component stylesheets: external resource URLs (alpha15 S lane, S-C1.2) serialized as marked `<link rel="stylesheet">` nodes after `headExtras`, so a light component is styled by the document that contains it — without JavaScript and without a runtime style node.

packages/element/src/internal/core/html-escape.ts:205
DocumentStyleResources接口 · 公开
@openelement/element · ./base

记录一次服务端渲染所发现的文档级样式表,供组件序列化与文档 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.

links: readonly string[] (必填) — Discovered resource URLs, deduplicated, in discovery (cascade) order.; add: (urls: readonly string[]) => void (必填) — Record the external stylesheet URLs one rendered component contributes.

packages/element/src/internal/core/html-escape.ts:125
effect函数 · 公开
@openelement/element · ./base

运行副作用,并在使用的信号发生变化时重新执行和订阅。

(fn: () => void | Unsubscribe): Unsubscribe
英文源码说明

Run a side effect that re-subscribes whenever its signal dependencies change.

packages/element/src/internal/signal/framework.ts:27
ensureDeepFragmentNavigation函数 · 公开
@openelement/element · ./base

为文档安装深层锚点导航,使同页链接能定位到嵌套 Shadow Root 内的目标。

(options?: DeepFragmentOptions): void
英文源码说明

Install (once per document) framework-level fragment navigation: a same-document anchor click whose target lives inside a nested shadow root scrolls to it and pushes the hash instead of being dropped by the browser. `{ enabled: false }` opts an application out.

enabled?: boolean (可选) — Set false before installation to opt out for an application.

packages/element/src/internal/core/deep-fragment.ts:67
ensurePreHydrationClickCapture函数 · 公开
@openelement/element · ./base

在元素升级前捕获发往待启用交互岛的用户操作,接管 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.

addEventListener: (type: string, callback: EventListenerOrEventListenerObject | null, options?: AddEventListenerOptions | boolean) => void (必填) — The **`addEventListener()`** method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target. [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener); dispatchEvent: (event: Event) => boolean (必填) — The **`dispatchEvent()`** method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order. The normal event processing rules (including the capturing and optional bubbling phase) also apply to events dispatched manually with dispatchEvent(). [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent); removeEventListener: (type: string, callback: EventListenerOrEventListenerObject | null, options?: EventListenerOptions | boolean) => void (必填) — The **`removeEventListener()`** method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target. The event listener to be removed is identified using a combination of the event type, the event listener function itself, and various optional options that may affect the matching process; see Matching event listeners for removal.…

packages/element/src/internal/compiled/runtime/pre-upgrade-events.ts:662
ERROR_PREFIX常量 · 公开
@openelement/element · ./base

openElement 错误消息使用的前缀。

"[openElement]"
英文源码说明

Error message prefix for all openElement errors.

packages/protocol/src/errors.ts:50
ErrorTelemetryHook类型 · 公开
@openelement/element · ./base

接收所有通过错误遥测渠道上报的 OpenElementError。

ErrorTelemetryHook
英文源码说明

Callback receiving every reported {@linkcode OpenElementError} for telemetry.

packages/protocol/src/errors.ts:132
escapeAttr函数 · 公开
@openelement/element · ./base

对 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
escapeHtml函数 · 公开
@openelement/element · ./base

对文本中的五个 HTML 特殊字符进行转义。

(str: string): string
英文源码说明

Escape the five HTML-significant characters in text content.

packages/element/src/internal/core/html-escape.ts:39
formatError函数 · 公开
@openelement/element · ./base

将未知类型的异常值格式化为可读的字符串。

(e: unknown): string
英文源码说明

Format an unknown thrown value as a human-readable string.

packages/element/src/internal/core/errors.ts:52
FrameworkOptions接口 · 公开
@openelement/element · ./base
FrameworkOptions
英文源码说明

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.

renderer?: "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).; routesDir?: string (可选) — Directory the route scanner walks, relative to the Vite root. Defaults to `app/routes`.; islandsDir?: string (可选) — Directory island modules are discovered in. Defaults to `app/islands`.; packageIslands?: 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…; layout?: LayoutConfig (可选) — Layout declaration; `false` disables the layout, `'default'` uses the built-in one.; layouts?: LayoutsConfig (可选) — Named layout declarations keyed by layout name.; headExtras?: string (可选) — @dangerous injected as-is, only use with controlled content; html.lang?: string (可选); html.title?: string (可选); inject.stylesheets?: (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.; inject.scripts?: (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.; inject.headFragments?: 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>`.; ssr.noExternal?: (string | RegExp)[] (可选); island.upgradeStrategy?: "load" | "idle" | "visible" | "only" | "none" (可选); build.outDir?: string (可选) — Output directory for the build artifacts. Defaults to `dist`.; build.manifestBudget?: { 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.; viewTransition?: boolean (可选) — Enable the View Transitions API for client navigations. Defaults to true.; speculation?: 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.; middleware.cors?: boolean (可选) — Built-in CORS middleware. Default-ON; pass `false` to disable.; middleware.corsOrigin?: string | string[] (可选) — Static CORS allowlist data, serialized into the generated entry as JSON. Mutually exclusive with {@link FrameworkOptions.middleware.corsOriginModule }.; middleware.corsOriginModule?: string (可选) — Path 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`.; middleware.requestId?: boolean (可选) — Emit and honor a per-request id header. Default-ON; pass `false` to disable.; middleware.logger?: boolean (可选) — Log each request through the built-in logger. Default-ON; pass `false` to disable.; middleware.securityHeaders?: boolean (可选) — Attach the built-in security response headers. Default-ON; pass `false` to disable.; middleware.csp?: { policy?: string; nonce?: boolean; reportOnly?: boolean; } (可选) — Content-Security-Policy emission: the policy string, nonce generation, and report-only mode.; middleware.use?: 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…

packages/protocol/src/framework.ts:180
HYDRATION_STRATEGIES常量 · 公开
@openelement/element · ./base

运行时支持的 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
HydrationStrategy类型 · 公开
@openelement/element · ./base

控制交互岛何时启用,也可跳过浏览器 hydration。

"load" | "idle" | "visible" | "only" | "none"
英文源码说明

Island hydration trigger: 'load' | 'idle' | 'visible' | 'only'.

packages/protocol/src/framework.ts:30
IDLE_FALLBACK_TIMEOUT_MS常量 · 公开
@openelement/element · ./base

环境缺少 requestIdleCallback 和 requestAnimationFrame 时,空闲 hydration 的备用延时(毫秒)。

50
英文源码说明

Idle-hydration scheduling fallback (milliseconds) when neither `requestIdleCallback` nor `requestAnimationFrame` is available.

packages/protocol/src/policy.ts:70
injectPropsSafe函数 · 公开
@openelement/element · ./base

将调用方提供的属性写入目标对象,跳过受保护的键,并容忍只读属性。

(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
isDangerousKey函数 · 公开
@openelement/element · ./base

判断属性键是否为框架在写入属性时必须拒绝的对象原型键。

(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
IslandOptions接口 · 公开
@openelement/element · ./base

交互岛的交付选项,包括 hydration 策略和是否参与 SSR 或 DSD。

IslandOptions
英文源码说明

Per-island delivery options (hydration strategy, SSR/DSD participation).

hydrate?: "load" | "idle" | "visible" | "only" | "none" (可选) — Hydration strategy: - 'load': load immediately when module is imported - 'idle': defer to requestIdleCallback (default) - 'visible': use IntersectionObserver to defer until element is visible - 'only': client-only render, no DSD/SSR output Named `hydrate` to match `defineIslandConfig()` in the Router package — one option name across both packages.; dsd?: boolean (可选) — Whether to use DSD for SSR rendering of this island. Honored by the build-side island scan (via `defineIslandConfig`), not by `defineIsland()` itself: passing it in `IslandOptions` has no runtime effect.; ssr?: boolean (可选) — Whether this island may be admitted into server rendering. Like `dsd`, decided by the build-side island scan; inert when passed to `defineIsland()`.

packages/protocol/src/island.ts:8
isSafeAttributeName函数 · 公开
@openelement/element · ./base

服务端渲染检查属性名时调用的公共校验入口,规则和协议层一致。

(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
isValidTagName函数 · 公开
@openelement/element · ./base

判断字符串是否符合 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类型 · 公开
@openelement/element · ./base

为路由选择内置布局、指定自定义布局及其模块和属性,或关闭布局。

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类型 · 公开
@openelement/element · ./base

为页面路由获取数据的 loader。

Loader<T, Env, Platform, Route>
英文源码说明

Route loader: fetches data for a page route.

packages/protocol/src/data.ts:56
LoaderContext接口 · 公开
@openelement/element · ./base

传给动态路由 loader 的请求上下文。

LoaderContext<Env, Platform, Route>
英文源码说明

Context passed to a request-time ('dynamic') route loader.

request: Request (必填); params: Record<string, string> (必填); env: Env (必填); platform: Platform (必填); responseHeaders: Headers (必填) — Mutable response-only channel merged into the framework response.; route: Route (必填)

packages/protocol/src/data.ts:40
LocalePath接口 · 公开
@openelement/element · ./base

随语言解析的路径契约。

LocalePath
英文源码说明

Locale-aware resolved path contract.

locale: string (必填); path: string (必填); localizedPath: string (必填); isDefaultLocalePath: boolean (必填)

packages/protocol/src/framework.ts:82
Logger接口 · 公开
@openelement/element · ./base

带标签的控制台日志接口。

Logger
英文源码说明

logger.ts - Tagged console logger. Lightweight scoped logger. Returns plain functions so it is tree-shakable and has zero class overhead.

debug: (msg: string, ...args: unknown[]) => void (必填); info: (msg: string, ...args: unknown[]) => void (必填); warn: (msg: string, ...args: unknown[]) => void (必填); error: (msg: string, ...args: unknown[]) => void (必填)

packages/element/src/internal/core/logger.ts:10
MAX_ACTION_BODY_BYTES常量 · 公开
@openelement/element · ./base

生成的服务端入口对 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
MAX_COMPOSITION_DEPTH常量 · 公开
@openelement/element · ./base

renderToString 允许展开的嵌套元素层数,避免循环组合导致无穷递归。

8
英文源码说明

Nested element expansion depth bound for `renderToString`: cyclic component composition fails closed instead of recursing without end.

packages/protocol/src/policy.ts:51
Middleware类型 · 公开
@openelement/element · ./base

基于标准 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
onConnect函数 · 公开
@openelement/element · ./base

生成的自定义元素每次连接时运行回调,包括重新连接。若回调返回清理函数,元素断开时会调用它。

(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
onDispose函数 · 公开
@openelement/element · ./base

在生成的元素实例最终销毁时运行一次回调,调用顺序在该连接的清理函数之后。

(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
onError函数 · 公开
@openelement/element · ./base

处理当前生成元素在连接、接管服务端标记、更新或处理 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
onPropertyChange函数 · 公开
@openelement/element · ./base

元素的已声明属性写入新值后运行回调,包括 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
OpenElementAttribute接口 · 公开
@openelement/element · ./base

自定义元素声明中记录的一个 attribute。

OpenElementAttribute
英文源码说明

One documented attribute of a custom element declaration.

name: string (必填); type?: string (可选); default?: string (可选); description?: string (可选); reflects?: boolean (可选); fieldName?: string (可选)

packages/protocol/src/manifest.ts:15
OpenElementCssPart接口 · 公开
@openelement/element · ./base

自定义元素声明中记录的一个 CSS part。

OpenElementCssPart
英文源码说明

One documented CSS part of a custom element declaration.

name: string (必填); description?: string (可选)

packages/protocol/src/manifest.ts:38
OpenElementDeclaration接口 · 公开
@openelement/element · ./base

包清单中的自定义元素声明,包括标签名、成员和交付信息。

OpenElementDeclaration
英文源码说明

One custom element declaration in a package manifest: tag, members and delivery metadata.

tagName: string (必填); className?: string (可选); superclassName?: string (可选); attributes?: OpenElementAttribute[] (可选); events?: OpenElementEvent[] (可选); slots?: OpenElementSlot[] (可选); cssParts?: OpenElementCssPart[] (可选); openElement.ssr?: boolean (可选); openElement.dsd?: boolean (可选); openElement.layer?: ComponentLayer (可选); openElement.hydrate?: "load" | "idle" | "visible" | "only" | "none" (可选); openElement.status?: "stable" | "experimental" (可选) — Stability marker from the owning package's manifest policy.; openElement.module?: string (可选); openElement.export?: string (可选); openElement.tailwind?: OpenElementTailwindDeclaration (可选); openElement.root?: "light" | "shadow" | "closed" (可选) — The host root a generated-element declaration was compiled with. Absent for a class declaration (its descriptor owns the root) and for a generated declaration whose sidecar declares none (the descriptor default is light).; openElement.styles?: readonly string[] (可选) — The authored package-relative `.css` specifiers a generated SHADOW host declares, published so a consuming build can emit the sheet and hand its URL to the DSD style-link carrier. Absent when the component declares none; class declarations deliver their sheets through `static styles` instead.; openElement.ssrHostExport?: string (可选) — The compiler-emitted SSR host producer's export name (`<Component>__ssrHost`) for a generated declaration whose root is `shadow`. A consuming build cannot otherwise learn it: the name is the compiler's return-only `ssrHostExport` metadata, and re-deriving it from a naming convention inside the router would be exactly the drift ADR-0182 forbids ("read the compiler's return value, never re-derive i…; description?: string (可选)

packages/protocol/src/manifest.ts:116
OpenElementError类 · 公开
@openelement/element · ./base

框架错误,提供稳定错误码、严重程度、发生阶段和可恢复性。

class OpenElementError extends Error
英文源码说明

Framework error carrying a stable code, severity, phase and recoverability contract.

packages/protocol/src/errors.ts:100
OpenElementEvent接口 · 公开
@openelement/element · ./base

自定义元素声明中记录的一个自定义事件。

OpenElementEvent
英文源码说明

One documented custom event of a custom element declaration.

name: string (必填); type?: string (可选); description?: string (可选)

packages/protocol/src/manifest.ts:25
OpenElementPackageManifest接口 · 公开
@openelement/element · ./base

包级组件清单,记录其中声明的组件。

OpenElementPackageManifest
英文源码说明

Package manifest of component declarations (not a Custom Elements Manifest).

schemaVersion: string (必填); packageName: string (必填); version: string (必填); description?: string (可选); author?: string (可选); license?: string (可选); homepage?: string (可选); repository?: string (可选); declarations: OpenElementDeclaration[] (必填)

packages/protocol/src/manifest.ts:129
OpenElementRouteKind类型 · 公开
@openelement/element · ./base

应用与构建驱动共享的路由类别。

OpenElementRouteKind
英文源码说明

Host-agnostic route and asset contracts shared by app and build drivers.

packages/protocol/src/app-model.ts:2
OpenElementRouteNode接口 · 公开
@openelement/element · ./base

路由树节点,记录匹配路径、路由类型、源码与模块路径、可选的标签和参数,以及子路由。

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`.

kind: OpenElementRouteKind (必填); path: string (必填); filePath?: string (可选); importPath?: string (可选); tagName?: string (可选); paramNames?: string[] (可选); children?: OpenElementRouteNode[] (可选); meta?: Record<string, unknown> (可选)

packages/protocol/src/app-model.ts:9
OpenElementSlot接口 · 公开
@openelement/element · ./base

自定义元素声明中记录的一个插槽。

OpenElementSlot
英文源码说明

One documented slot of a custom element declaration.

name: string (必填); description?: string (可选)

packages/protocol/src/manifest.ts:32
PROBLEM_JSON_MEDIA_TYPE常量 · 公开
@openelement/element · ./base

RFC 9457 Problem Details 错误响应使用的媒体类型。

"application/problem+json"
英文源码说明

Media type of the RFC 9457 action error channel (#863).

packages/protocol/src/data.ts:117
ProblemDetails接口 · 公开
@openelement/element · ./base

表单 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.

type: string (必填) — URI reference identifying the problem type; 'about:blank' when none applies.; title: string (必填) — Short human-readable summary (the HTTP reason phrase for 'about:blank').; status.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; status.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; status.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; status.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; status.valueOf: () => number (必填) — Returns the primitive value of the specified object.; status.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.; detail?: string (可选) — Human-readable explanation specific to this occurrence.

packages/protocol/src/data.ts:105
provideContext函数 · 公开
@openelement/element · ./base

提供普通的协议上下文值。用于提供值的 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:131
ReadonlySignal接口 · 公开
@openelement/element · ./base

computed 等派生值使用的只读信号接口。

ReadonlySignal<T>
英文源码说明

Read-only signal protocol used by computed values.

value: T (必填); subscribe: (fn: (value: T) => void) => Unsubscribe (必填); __@[email protected]: () => boolean (必填) — Returns the primitive value of the specified object.

packages/protocol/src/signal.ts:26
ref函数 · 公开
@openelement/element · ./base

为组件内的一个原生 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
releaseConsumedContext函数 · 公开
@openelement/element · ./base

释放某次带宿主的 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.

value: unknown (必填); subscribe: (fn: (value: unknown) => void) => Unsubscribe (必填); __@[email protected]: () => boolean (必填) — Returns the primitive value of the specified object.

packages/element/src/internal/core/signal-context.ts:208
RenderError类 · 公开
@openelement/element · ./base

可恢复的渲染错误,携带出错组件的文件路径与标签名。

class RenderError extends OpenElementError
英文源码说明

Recoverable render-phase error carrying the failing component path and tag.

packages/element/src/internal/core/errors.ts:95
renderToString函数 · 公开
@openelement/element · ./base

在服务端渲染一个已编译的元素,直接返回序列化后的声明式 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
RenderToStringOptions接口 · 公开
@openelement/element · ./base

一次 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.

componentClass?: CustomElementConstructor (可选); props?: Record<string, unknown> (可选); sourceInfo.route?: string (可选); sourceInfo.source?: string (可选); ssrRenderableTags?: readonly string[] (可选) — Build-admitted nested compiled tags. Omitted means shell-only rendering.; projectedChildren?: ReadonlyMap<string, TrustedHtml> (可选) — Trusted parent-owned light children keyed by slot name.; hostChildren?: TrustedHtml (可选) — Trusted parent-owned light children emitted AFTER the host's DSD template (a shadow-root host's slotted content). This is the shadow-side sibling of `projectedChildren`: a light root substitutes projections into its own `<slot>` elements, a shadow root distributes appended light DOM natively. Both are the compiled children channel — compiler-produced final HTML carrying the trustedHtml brand, nev…; onNestedFailure?: ((error: unknown) => void) (可选) — `16b-EB` (execution plan §19.2): the report channel for a descendant producer that threw while the enclosing error boundary owns it. The boundary supplies this; the renderer routes the caught failure here instead of failing the whole render, and renders the boundary's fallback bytes in the failing descendant's place. OMITTED is the no-boundary render: the failure re-raises, which is the unchanged…; nestedStyleSink?: Set<string> (可选) — Sheet URLs a nested LIGHT child lifted into the enclosing template (F16).; documentStyles?: DocumentStyleSink (可选) — The render's document stylesheet collection (alpha15 S lane, S-C1.2). Every light-root component serialized in this render reports its external sheet URLs here, and the document wrapper declares them in the head. The caller owns the collection's lifetime — one per document render — so styles discovered for one page can never reach another page's head.

packages/element/src/public-runtime.ts:170
reportError函数 · 公开
@openelement/element · ./base

将框架错误交给遥测钩子,无钩子时写入 console.error。

(error: OpenElementError): void
英文源码说明

Report an {@linkcode OpenElementError} to the telemetry hook, or console.error when none is installed.

code: string (必填); severity: ErrorSeverity (必填); phase: ErrorPhase (必填); recoverable: boolean (必填); statusCode.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; statusCode.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; statusCode.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; statusCode.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; statusCode.valueOf: () => number (必填) — Returns the primitive value of the specified object.; statusCode.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.; toJSON: () => Record<string, unknown> (必填); name: string (必填); message: string (必填); stack?: string (可选); cause?: unknown (可选)

packages/element/src/internal/core/errors.ts:139
RouteEntry接口 · 公开
@openelement/element · ./base

扫描后入选的路由,记录 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.

path: string (必填); filePath: string (必填); type: "page" | "api" | "island" | "special" (必填); varName: string (必填); tagName?: string (可选); definePage?: boolean (可选) — True when the route module's default export is a definePage() definition (#960 — registration decoupling). The generated entry registers the page class under the path-derived fallback tag and IGNORES the tagName export for registration: on a definePage route the export only names a content element. Plain element routes keep tagName as their registration tag.; functionPage?: string (可选) — The server function page fact (alpha15 server lane): the exported server function component the route's `export default definePage(Component)` was called over. Present only when the argument is a plain identifier resolving to a component THIS module declares — an inline arrow or an unexported local never records it (the R1 admission rule mirrored, so a shape whose JSX would escape to runtime is n…; source?: string (可选) — Source text captured during scanning when includeSource is enabled.; hasEnhancedForms?: boolean (可选) — True when the page route source carries data-open-enhance (#569): the client entry must ship the form-enhancement layer even when the app has zero islands.; special?: SpecialFileType (可选); params?: string[] (可选)

packages/protocol/src/framework.ts:113
ServerRouteContext接口 · 公开
@openelement/element · ./base

请求时渲染和静态站点生成共用的服务端路由上下文。

ServerRouteContext<Env, Platform, Route>
英文源码说明

Canonical request-time/SSG server route context.

request: Request (必填); params: Record<string, string> (必填); env: Env (必填); platform: Platform (必填); responseHeaders: Headers (必填) — Mutable response-only channel merged into the framework response.; route: Route (必填)

packages/protocol/src/data.ts:25
ServerRouteMetadata接口 · 公开
@openelement/element · ./base

动态路由 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().

path: string (必填); filePath: string (必填)

packages/protocol/src/data.ts:19
setErrorTelemetryHook函数 · 公开
@openelement/element · ./base

安装或替换整个进程使用的错误遥测钩子。

(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
signal函数 · 公开
@openelement/element · ./base

创建可读写的响应式状态。

<T>(initialValue: T): WritableSignal<T>
英文源码说明

Create a writable signal through the selected signal engine.

packages/element/src/internal/signal/framework.ts:19
Signal类型 · 公开
@openelement/element · ./base

接受可写信号或只读信号的 API 所用类型。

Signal<T>
英文源码说明

Alias for APIs that accept either writable or read-only signals.

packages/protocol/src/signal.ts:31
SpecialFileType类型 · 公开
@openelement/element · ./base

路由扫描器按文件名识别的特殊类型,包括 renderer 和 middleware。

SpecialFileType
英文源码说明

Special file kinds the route scanner recognizes by filename: `renderer` and `middleware`.

packages/protocol/src/framework.ts:79
SsrAdmissionDecision接口 · 公开
@openelement/element · ./base

构建对自定义元素的 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.

tagName: string (必填); modulePath: string (必填) — Module path of the island declaration. Empty for 'foreign' decisions: a foreign tag is consumed in JSX but declares no module the build owns.; source: "local" | "package" | "nested" | "foreign" (必填) — 'foreign' (#979): a third-party WC tag discovered by the foreign-tag scanner in page/island JSX — recorded for visibility only; SSR still treats it as an opaque passthrough (renderPath 'client-only').; renderPath: "ssr+client" | "client-only" | "rejected" (必填); reason: string (必填)

packages/protocol/src/render.ts:37
STREAM_FRAME_FORBIDDEN_TAGS常量 · 公开
@openelement/element · ./base

浏览器拒绝装入所属 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
STREAM_FRAME_UNSAFE_URL常量 · 公开
@openelement/element · ./base

流式片段的 URL 属性不可使用的协议。

RegExp
英文源码说明

Schemes that make a URL attribute unsafe in a streamed frame.

packages/protocol/src/stream-frame-policy.ts:60
STREAM_FRAME_URL_ATTRIBUTES常量 · 公开
@openelement/element · ./base

流式片段中需要检查 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
STREAM_FRAME_URL_CONTROL_MAX常量 · 公开
@openelement/element · ./base

检查 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
STREAM_MAX_FIELDS常量 · 公开
@openelement/element · ./base

一个流式路由允许在清单中声明的延迟字段数上限。

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
STREAM_MAX_OWNERS常量 · 公开
@openelement/element · ./base

一个流式路由清单可以引用的 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
STREAM_MAX_PAYLOAD_LENGTH常量 · 公开
@openelement/element · ./base

流式载荷的最大序列化长度,以 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
STREAM_MAX_SEED_PROPERTIES常量 · 公开
@openelement/element · ./base

流式 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
STREAM_TIMEOUT_MS常量 · 公开
@openelement/element · ./base

流式响应等待延迟字段完成的时间上限(毫秒)。

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
StyleSheet常量 · 公开
@openelement/element · ./base

可跨执行环境使用的样式表构造器,按环境选择原生 CSSStyleSheet 或兼容实现。

new () => StyleSheetLike
英文源码说明

Cross-realm StyleSheet constructor: the native CSSStyleSheet or the internal shim.

packages/element/src/internal/core/style-sheet.ts:110
StyleSheetLike接口 · 公开
@openelement/element · ./base

原生样式表与兼容实现共用的最小接口,包括 replaceSync 和 cssRules。

StyleSheetLike
英文源码说明

Minimal stylesheet contract (replaceSync + cssRules) satisfied by native and shim sheets.

replaceSync: (text: string) => void (必填); cssRules: StyleSheetRule[] (必填)

packages/protocol/src/style-sheet.ts:14
trustedHtml函数 · 公开
@openelement/element · ./base

将 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
TrustedHtml接口 · 公开
@openelement/element · ./base

标识应用已明确审查并信任的 HTML。

TrustedHtml
英文源码说明

Opaque capability marking HTML the application has explicitly vetted as trusted.

html: string (必填)

packages/element/src/internal/core/security.ts:83
unsafeStreamFrameAttribute函数 · 公开
@openelement/element · ./base

判断 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
useContext函数 · 公开
@openelement/element · ./base

订阅最近提供者的上下文,返回由实例持有的信号。没有提供者时读到令牌的默认值。

<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.

key.toString: () => string (必填) — Returns a string representation of an object.; key.valueOf: () => symbol (必填) — Returns the primitive value of the specified object.; key.description: string (必填) — Expose the [[Description]] internal slot of a symbol directly.; key.__@toPrimitive@5327: (hint: string) => symbol (必填) — Converts a Symbol object to a symbol.; key.__@toStringTag@5213: string (必填); defaultValue: T (必填)

packages/element/src/internal/core/compile-lifecycle.ts:285
useHost函数 · 公开
@openelement/element · ./base

获取当前组件所在的自定义元素。用于在组件中访问宿主节点。

(): 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
wrapInDocument函数 · 公开
@openelement/element · ./base

为渲染后的 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
composeFetchMiddleware函数 · 公开
@openelement/element · ./build-utils

按洋葱顺序将 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
createRuntimeAdapter函数 · 公开
@openelement/element · ./build-utils
<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.

name: string (必填); fetch: OpenElementRequestHandler<Env> (必填); prerender?: (() => AsyncIterable<RuntimePrerenderResult> | Iterable<RuntimePrerenderResult>) (可选)

packages/element/src/internal/core/runtime.ts:23
formatJson函数 · 公开
@openelement/element · ./build-utils

将值序列化为格式化的 JSON,并在末尾添加换行。

(value: unknown): string
英文源码说明

Serialize a value to pretty-printed JSON ending with a newline.

packages/element/src/internal/core/write-json.ts:11
insertBeforeBodyClose函数 · 公开
@openelement/element · ./build-utils

在 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
normalizeSeparators函数 · 公开
@openelement/element · ./build-utils
(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
OpenElementRequestHandler类型 · 公开
@openelement/element · ./build-utils

供运行时适配器和生成入口使用的统一请求处理函数,基于标准 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
pathToTagName函数 · 公开
@openelement/element · ./build-utils
(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接口 · 公开
@openelement/element · ./build-utils

运行时适配器的上下文契约,用来隔离框架和部署环境。

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.

env?: Env (可选); platform?: unknown (可选); params?: Record<string, string> (可选)

packages/protocol/src/runtime.ts:9
SsrRenderError类 · 公开
@openelement/element · ./build-utils

静态站点生成无法加载服务端包或执行失败时抛出的错误,也由 @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
transformIslandSource函数 · 公开
@openelement/element · ./build-utils

为源码注入交互岛元数据标记。

(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
__setRequestTimeStyleSheetUrls函数 · 公开
@openelement/element · ./client-only

为当前服务端进程设置已生成的样式表 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类型 · 公开
@openelement/element · ./client-only

处理页面路由的表单提交。

Action<T, Env, Platform, Route>
英文源码说明

Route action: handles form submissions for a page route.

packages/protocol/src/data.ts:64
ACTION_FETCH_HEADER常量 · 公开
@openelement/element · ./client-only

选择表单 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
ActionContext接口 · 公开
@openelement/element · ./client-only

传给路由 action 的上下文,包含 loader 上下文。

ActionContext<Env, Platform, Route>
英文源码说明

Context passed to a route action function (extends loader context).

formData: FormData (必填); request: Request (必填); params: Record<string, string> (必填); env: Env (必填); platform: Platform (必填); responseHeaders: Headers (必填) — Mutable response-only channel merged into the framework response.; route: Route (必填)

packages/protocol/src/data.ts:47
ActionResult类型 · 公开
@openelement/element · ./client-only

脚本提交表单时返回的联合类型。校验失败返回 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
assertValidTagName函数 · 公开
@openelement/element · ./client-only

检查名称是否符合自定义元素的标签名规则。

(tagName: string): void
英文源码说明

Assert that a tag name is a valid custom element name.

packages/element/src/internal/core/tag-utils.ts:50
collectPublicProps函数 · 公开
@openelement/element · ./client-only

收集宿主对象上所有公开的自有属性。

(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
CompatibilityClassification接口 · 公开
@openelement/element · ./client-only

兼容性扫描为每个标签记录分级、原因、来源和对应的 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.

tagName: string (必填); tier: CompatibilityTier (必填); reason: string (必填); source: "local" | "package" | "nested" (必填); modulePath?: string (可选); ssr?: boolean (可选); dsd?: boolean (可选); hydrate?: string (可选)

packages/protocol/src/framework.ts:347
CompatibilityTier类型 · 公开
@openelement/element · ./client-only

标签的构建兼容级别,区分服务端渲染、仅浏览器渲染、实验支持和拒绝构建。

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
ComponentLayer类型 · 公开
@openelement/element · ./client-only

组件的交付层级,区分静态 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
computed函数 · 公开
@openelement/element · ./client-only

根据依赖计算一个只读响应式值。

<T>(fn: () => T): ReadonlySignal<T>
英文源码说明

Create a derived read-only signal recomputed from its dependencies.

packages/element/src/internal/signal/framework.ts:23
consumeContext函数 · 公开
@openelement/element · ./client-only

将上下文投影为消费端的响应式值。传入宿主时,消费端负责通过 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.

key.toString: () => string (必填) — Returns a string representation of an object.; key.valueOf: () => symbol (必填) — Returns the primitive value of the specified object.; key.description: string (必填) — Expose the [[Description]] internal slot of a symbol directly.; key.__@toPrimitive@6538: (hint: string) => symbol (必填) — Converts a Symbol object to a symbol.; key.__@toStringTag@6424: string (必填); defaultValue: T (必填)

packages/element/src/internal/core/signal-context.ts:183
Context接口 · 公开
@openelement/element · ./client-only

上下文令牌,包含协议使用的键和默认值。

Context<T>
英文源码说明

A typed context token: protocol identity (`key`) plus its default value.

key.toString: () => string (必填) — Returns a string representation of an object.; key.valueOf: () => symbol (必填) — Returns the primitive value of the specified object.; key.description: string (必填) — Expose the [[Description]] internal slot of a symbol directly.; key.__@toPrimitive@6538: (hint: string) => symbol (必填) — Converts a Symbol object to a symbol.; key.__@toStringTag@6424: string (必填); defaultValue: T (必填)

packages/element/src/internal/core/signal-context.ts:13
createContext函数 · 公开
@openelement/element · ./client-only

创建供提供方与消费方共享的带类型上下文令牌。

<T>(key: symbol, defaultValue: T): Context<T>
英文源码说明

Create a typed context token shared between provider and consumer elements.

toString: () => string (必填) — Returns a string representation of an object.; valueOf: () => symbol (必填) — Returns the primitive value of the specified object.; description: string (必填) — Expose the [[Description]] internal slot of a symbol directly.; __@toPrimitive@6538: (hint: string) => symbol (必填) — Converts a Symbol object to a symbol.; __@toStringTag@6424: string (必填)

packages/element/src/internal/core/signal-context.ts:58
createDocumentStyleResources函数 · 公开
@openelement/element · ./client-only

为一次服务端渲染创建文档级样式表收集器。

(): DocumentStyleResources
英文源码说明

Create the per-render document stylesheet collection.

packages/element/src/internal/core/html-escape.ts:133
createLogger函数 · 公开
@openelement/element · ./client-only

创建在每条消息前加上标签的日志记录器。

(tag: string): Logger
英文源码说明

Create a {@link Logger} that prefixes every message with `[tag]`.

packages/element/src/internal/core/logger.ts:18
DANGEROUS_KEYS常量 · 公开
@openelement/element · ./client-only

从不可信属性复制数据时必须排除的对象原型键。

ReadonlySet<string>
英文源码说明

Object prototype keys that must never be injected from untrusted props.

packages/element/src/internal/core/security.ts:25
deepGetElementById函数 · 公开
@openelement/element · ./client-only

在指定根节点及其嵌套 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
documentStreamParts函数 · 公开
@openelement/element · ./client-only

使用相同的文档序列化规则生成流式响应的首尾片段,保留正文容器供流写入。

(options?: DocumentWrapOptions): { prefix: string; suffix: string; }
英文源码说明

The same document serialization boundary, with only body wrappers left open.

title?: string (可选); lang?: string (可选); clientScript?: string (可选); scripts?: DocumentScriptDescriptor[] (可选); meta.description?: string (可选); meta.tags?: Record<string, string | number | boolean>[] (可选); devScripts?: string (可选); headExtras?: string (可选); dangerouslyHeadFragments?: string[] (可选); allowHeadExtrasScripts?: boolean (可选); links?: { rel: string; href: string; hreflang?: string; }[] (可选); structuredData?: readonly Record<string, unknown>[] (可选); cspNonce?: string (可选); streamBootstrap?: string (可选) — Trusted framework bootstrap emitted synchronously in the document head.; styleLinks?: readonly string[] (可选) — The document's light-root component stylesheets: external resource URLs (alpha15 S lane, S-C1.2) serialized as marked `<link rel="stylesheet">` nodes after `headExtras`, so a light component is styled by the document that contains it — without JavaScript and without a runtime style node.

packages/element/src/internal/core/html-escape.ts:205
DocumentStyleResources接口 · 公开
@openelement/element · ./client-only

记录一次服务端渲染所发现的文档级样式表,供组件序列化与文档 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.

links: readonly string[] (必填) — Discovered resource URLs, deduplicated, in discovery (cascade) order.; add: (urls: readonly string[]) => void (必填) — Record the external stylesheet URLs one rendered component contributes.

packages/element/src/internal/core/html-escape.ts:125
effect函数 · 公开
@openelement/element · ./client-only

运行副作用,并在使用的信号发生变化时重新执行和订阅。

(fn: () => void | Unsubscribe): Unsubscribe
英文源码说明

Run a side effect that re-subscribes whenever its signal dependencies change.

packages/element/src/internal/signal/framework.ts:27
ensureDeepFragmentNavigation函数 · 公开
@openelement/element · ./client-only

为文档安装深层锚点导航,使同页链接能定位到嵌套 Shadow Root 内的目标。

(options?: DeepFragmentOptions): void
英文源码说明

Install (once per document) framework-level fragment navigation: a same-document anchor click whose target lives inside a nested shadow root scrolls to it and pushes the hash instead of being dropped by the browser. `{ enabled: false }` opts an application out.

enabled?: boolean (可选) — Set false before installation to opt out for an application.

packages/element/src/internal/core/deep-fragment.ts:67
ensurePreHydrationClickCapture函数 · 公开
@openelement/element · ./client-only

在元素升级前捕获发往待启用交互岛的用户操作,接管 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.

addEventListener: (type: string, callback: EventListenerOrEventListenerObject | null, options?: AddEventListenerOptions | boolean) => void (必填) — The **`addEventListener()`** method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target. [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener); dispatchEvent: (event: Event) => boolean (必填) — The **`dispatchEvent()`** method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order. The normal event processing rules (including the capturing and optional bubbling phase) also apply to events dispatched manually with dispatchEvent(). [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent); removeEventListener: (type: string, callback: EventListenerOrEventListenerObject | null, options?: EventListenerOptions | boolean) => void (必填) — The **`removeEventListener()`** method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target. The event listener to be removed is identified using a combination of the event type, the event listener function itself, and various optional options that may affect the matching process; see Matching event listeners for removal.…

packages/element/src/internal/compiled/runtime/pre-upgrade-events.ts:662
ERROR_PREFIX常量 · 公开
@openelement/element · ./client-only

openElement 错误消息使用的前缀。

"[openElement]"
英文源码说明

Error message prefix for all openElement errors.

packages/protocol/src/errors.ts:50
ErrorTelemetryHook类型 · 公开
@openelement/element · ./client-only

接收所有通过错误遥测渠道上报的 OpenElementError。

ErrorTelemetryHook
英文源码说明

Callback receiving every reported {@linkcode OpenElementError} for telemetry.

packages/protocol/src/errors.ts:132
escapeAttr函数 · 公开
@openelement/element · ./client-only

对 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
escapeHtml函数 · 公开
@openelement/element · ./client-only

对文本中的五个 HTML 特殊字符进行转义。

(str: string): string
英文源码说明

Escape the five HTML-significant characters in text content.

packages/element/src/internal/core/html-escape.ts:39
formatError函数 · 公开
@openelement/element · ./client-only

将未知类型的异常值格式化为可读的字符串。

(e: unknown): string
英文源码说明

Format an unknown thrown value as a human-readable string.

packages/element/src/internal/core/errors.ts:52
FrameworkOptions接口 · 公开
@openelement/element · ./client-only
FrameworkOptions
英文源码说明

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.

renderer?: "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).; routesDir?: string (可选) — Directory the route scanner walks, relative to the Vite root. Defaults to `app/routes`.; islandsDir?: string (可选) — Directory island modules are discovered in. Defaults to `app/islands`.; packageIslands?: 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…; layout?: LayoutConfig (可选) — Layout declaration; `false` disables the layout, `'default'` uses the built-in one.; layouts?: LayoutsConfig (可选) — Named layout declarations keyed by layout name.; headExtras?: string (可选) — @dangerous injected as-is, only use with controlled content; html.lang?: string (可选); html.title?: string (可选); inject.stylesheets?: (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.; inject.scripts?: (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.; inject.headFragments?: 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>`.; ssr.noExternal?: (string | RegExp)[] (可选); island.upgradeStrategy?: "load" | "idle" | "visible" | "only" | "none" (可选); build.outDir?: string (可选) — Output directory for the build artifacts. Defaults to `dist`.; build.manifestBudget?: { 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.; viewTransition?: boolean (可选) — Enable the View Transitions API for client navigations. Defaults to true.; speculation?: 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.; middleware.cors?: boolean (可选) — Built-in CORS middleware. Default-ON; pass `false` to disable.; middleware.corsOrigin?: string | string[] (可选) — Static CORS allowlist data, serialized into the generated entry as JSON. Mutually exclusive with {@link FrameworkOptions.middleware.corsOriginModule }.; middleware.corsOriginModule?: string (可选) — Path 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`.; middleware.requestId?: boolean (可选) — Emit and honor a per-request id header. Default-ON; pass `false` to disable.; middleware.logger?: boolean (可选) — Log each request through the built-in logger. Default-ON; pass `false` to disable.; middleware.securityHeaders?: boolean (可选) — Attach the built-in security response headers. Default-ON; pass `false` to disable.; middleware.csp?: { policy?: string; nonce?: boolean; reportOnly?: boolean; } (可选) — Content-Security-Policy emission: the policy string, nonce generation, and report-only mode.; middleware.use?: 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…

packages/protocol/src/framework.ts:180
HYDRATION_STRATEGIES常量 · 公开
@openelement/element · ./client-only

运行时支持的 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
HydrationStrategy类型 · 公开
@openelement/element · ./client-only

控制交互岛何时启用,也可跳过浏览器 hydration。

"load" | "idle" | "visible" | "only" | "none"
英文源码说明

Island hydration trigger: 'load' | 'idle' | 'visible' | 'only'.

packages/protocol/src/framework.ts:30
IDLE_FALLBACK_TIMEOUT_MS常量 · 公开
@openelement/element · ./client-only

环境缺少 requestIdleCallback 和 requestAnimationFrame 时,空闲 hydration 的备用延时(毫秒)。

50
英文源码说明

Idle-hydration scheduling fallback (milliseconds) when neither `requestIdleCallback` nor `requestAnimationFrame` is available.

packages/protocol/src/policy.ts:70
injectPropsSafe函数 · 公开
@openelement/element · ./client-only

将调用方提供的属性写入目标对象,跳过受保护的键,并容忍只读属性。

(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
isDangerousKey函数 · 公开
@openelement/element · ./client-only

判断属性键是否为框架在写入属性时必须拒绝的对象原型键。

(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
IslandOptions接口 · 公开
@openelement/element · ./client-only

交互岛的交付选项,包括 hydration 策略和是否参与 SSR 或 DSD。

IslandOptions
英文源码说明

Per-island delivery options (hydration strategy, SSR/DSD participation).

hydrate?: "load" | "idle" | "visible" | "only" | "none" (可选) — Hydration strategy: - 'load': load immediately when module is imported - 'idle': defer to requestIdleCallback (default) - 'visible': use IntersectionObserver to defer until element is visible - 'only': client-only render, no DSD/SSR output Named `hydrate` to match `defineIslandConfig()` in the Router package — one option name across both packages.; dsd?: boolean (可选) — Whether to use DSD for SSR rendering of this island. Honored by the build-side island scan (via `defineIslandConfig`), not by `defineIsland()` itself: passing it in `IslandOptions` has no runtime effect.; ssr?: boolean (可选) — Whether this island may be admitted into server rendering. Like `dsd`, decided by the build-side island scan; inert when passed to `defineIsland()`.

packages/protocol/src/island.ts:8
isSafeAttributeName函数 · 公开
@openelement/element · ./client-only

服务端渲染检查属性名时调用的公共校验入口,规则和协议层一致。

(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
isValidTagName函数 · 公开
@openelement/element · ./client-only

判断字符串是否符合 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类型 · 公开
@openelement/element · ./client-only

为路由选择内置布局、指定自定义布局及其模块和属性,或关闭布局。

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类型 · 公开
@openelement/element · ./client-only

为页面路由获取数据的 loader。

Loader<T, Env, Platform, Route>
英文源码说明

Route loader: fetches data for a page route.

packages/protocol/src/data.ts:56
LoaderContext接口 · 公开
@openelement/element · ./client-only

传给动态路由 loader 的请求上下文。

LoaderContext<Env, Platform, Route>
英文源码说明

Context passed to a request-time ('dynamic') route loader.

request: Request (必填); params: Record<string, string> (必填); env: Env (必填); platform: Platform (必填); responseHeaders: Headers (必填) — Mutable response-only channel merged into the framework response.; route: Route (必填)

packages/protocol/src/data.ts:40
LocalePath接口 · 公开
@openelement/element · ./client-only

随语言解析的路径契约。

LocalePath
英文源码说明

Locale-aware resolved path contract.

locale: string (必填); path: string (必填); localizedPath: string (必填); isDefaultLocalePath: boolean (必填)

packages/protocol/src/framework.ts:82
Logger接口 · 公开
@openelement/element · ./client-only

带标签的控制台日志接口。

Logger
英文源码说明

logger.ts - Tagged console logger. Lightweight scoped logger. Returns plain functions so it is tree-shakable and has zero class overhead.

debug: (msg: string, ...args: unknown[]) => void (必填); info: (msg: string, ...args: unknown[]) => void (必填); warn: (msg: string, ...args: unknown[]) => void (必填); error: (msg: string, ...args: unknown[]) => void (必填)

packages/element/src/internal/core/logger.ts:10
MAX_ACTION_BODY_BYTES常量 · 公开
@openelement/element · ./client-only

生成的服务端入口对 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
MAX_COMPOSITION_DEPTH常量 · 公开
@openelement/element · ./client-only

renderToString 允许展开的嵌套元素层数,避免循环组合导致无穷递归。

8
英文源码说明

Nested element expansion depth bound for `renderToString`: cyclic component composition fails closed instead of recursing without end.

packages/protocol/src/policy.ts:51
Middleware类型 · 公开
@openelement/element · ./client-only

基于标准 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
onConnect函数 · 公开
@openelement/element · ./client-only

生成的自定义元素每次连接时运行回调,包括重新连接。若回调返回清理函数,元素断开时会调用它。

(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
onDispose函数 · 公开
@openelement/element · ./client-only

在生成的元素实例最终销毁时运行一次回调,调用顺序在该连接的清理函数之后。

(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
onError函数 · 公开
@openelement/element · ./client-only

处理当前生成元素在连接、接管服务端标记、更新或处理 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
onPropertyChange函数 · 公开
@openelement/element · ./client-only

元素的已声明属性写入新值后运行回调,包括 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
OpenElementAttribute接口 · 公开
@openelement/element · ./client-only

自定义元素声明中记录的一个 attribute。

OpenElementAttribute
英文源码说明

One documented attribute of a custom element declaration.

name: string (必填); type?: string (可选); default?: string (可选); description?: string (可选); reflects?: boolean (可选); fieldName?: string (可选)

packages/protocol/src/manifest.ts:15
OpenElementCssPart接口 · 公开
@openelement/element · ./client-only

自定义元素声明中记录的一个 CSS part。

OpenElementCssPart
英文源码说明

One documented CSS part of a custom element declaration.

name: string (必填); description?: string (可选)

packages/protocol/src/manifest.ts:38
OpenElementDeclaration接口 · 公开
@openelement/element · ./client-only

包清单中的自定义元素声明,包括标签名、成员和交付信息。

OpenElementDeclaration
英文源码说明

One custom element declaration in a package manifest: tag, members and delivery metadata.

tagName: string (必填); className?: string (可选); superclassName?: string (可选); attributes?: OpenElementAttribute[] (可选); events?: OpenElementEvent[] (可选); slots?: OpenElementSlot[] (可选); cssParts?: OpenElementCssPart[] (可选); openElement.ssr?: boolean (可选); openElement.dsd?: boolean (可选); openElement.layer?: ComponentLayer (可选); openElement.hydrate?: "load" | "idle" | "visible" | "only" | "none" (可选); openElement.status?: "stable" | "experimental" (可选) — Stability marker from the owning package's manifest policy.; openElement.module?: string (可选); openElement.export?: string (可选); openElement.tailwind?: OpenElementTailwindDeclaration (可选); openElement.root?: "light" | "shadow" | "closed" (可选) — The host root a generated-element declaration was compiled with. Absent for a class declaration (its descriptor owns the root) and for a generated declaration whose sidecar declares none (the descriptor default is light).; openElement.styles?: readonly string[] (可选) — The authored package-relative `.css` specifiers a generated SHADOW host declares, published so a consuming build can emit the sheet and hand its URL to the DSD style-link carrier. Absent when the component declares none; class declarations deliver their sheets through `static styles` instead.; openElement.ssrHostExport?: string (可选) — The compiler-emitted SSR host producer's export name (`<Component>__ssrHost`) for a generated declaration whose root is `shadow`. A consuming build cannot otherwise learn it: the name is the compiler's return-only `ssrHostExport` metadata, and re-deriving it from a naming convention inside the router would be exactly the drift ADR-0182 forbids ("read the compiler's return value, never re-derive i…; description?: string (可选)

packages/protocol/src/manifest.ts:116
OpenElementError类 · 公开
@openelement/element · ./client-only

框架错误,提供稳定错误码、严重程度、发生阶段和可恢复性。

class OpenElementError extends Error
英文源码说明

Framework error carrying a stable code, severity, phase and recoverability contract.

packages/protocol/src/errors.ts:100
OpenElementEvent接口 · 公开
@openelement/element · ./client-only

自定义元素声明中记录的一个自定义事件。

OpenElementEvent
英文源码说明

One documented custom event of a custom element declaration.

name: string (必填); type?: string (可选); description?: string (可选)

packages/protocol/src/manifest.ts:25
OpenElementPackageManifest接口 · 公开
@openelement/element · ./client-only

包级组件清单,记录其中声明的组件。

OpenElementPackageManifest
英文源码说明

Package manifest of component declarations (not a Custom Elements Manifest).

schemaVersion: string (必填); packageName: string (必填); version: string (必填); description?: string (可选); author?: string (可选); license?: string (可选); homepage?: string (可选); repository?: string (可选); declarations: OpenElementDeclaration[] (必填)

packages/protocol/src/manifest.ts:129
OpenElementRouteKind类型 · 公开
@openelement/element · ./client-only

应用与构建驱动共享的路由类别。

OpenElementRouteKind
英文源码说明

Host-agnostic route and asset contracts shared by app and build drivers.

packages/protocol/src/app-model.ts:2
OpenElementRouteNode接口 · 公开
@openelement/element · ./client-only

路由树节点,记录匹配路径、路由类型、源码与模块路径、可选的标签和参数,以及子路由。

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`.

kind: OpenElementRouteKind (必填); path: string (必填); filePath?: string (可选); importPath?: string (可选); tagName?: string (可选); paramNames?: string[] (可选); children?: OpenElementRouteNode[] (可选); meta?: Record<string, unknown> (可选)

packages/protocol/src/app-model.ts:9
OpenElementSlot接口 · 公开
@openelement/element · ./client-only

自定义元素声明中记录的一个插槽。

OpenElementSlot
英文源码说明

One documented slot of a custom element declaration.

name: string (必填); description?: string (可选)

packages/protocol/src/manifest.ts:32
PROBLEM_JSON_MEDIA_TYPE常量 · 公开
@openelement/element · ./client-only

RFC 9457 Problem Details 错误响应使用的媒体类型。

"application/problem+json"
英文源码说明

Media type of the RFC 9457 action error channel (#863).

packages/protocol/src/data.ts:117
ProblemDetails接口 · 公开
@openelement/element · ./client-only

表单 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.

type: string (必填) — URI reference identifying the problem type; 'about:blank' when none applies.; title: string (必填) — Short human-readable summary (the HTTP reason phrase for 'about:blank').; status.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; status.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; status.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; status.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; status.valueOf: () => number (必填) — Returns the primitive value of the specified object.; status.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.; detail?: string (可选) — Human-readable explanation specific to this occurrence.

packages/protocol/src/data.ts:105
provideContext函数 · 公开
@openelement/element · ./client-only

提供普通的协议上下文值。用于提供值的 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:131
ReadonlySignal接口 · 公开
@openelement/element · ./client-only

computed 等派生值使用的只读信号接口。

ReadonlySignal<T>
英文源码说明

Read-only signal protocol used by computed values.

value: T (必填); subscribe: (fn: (value: T) => void) => Unsubscribe (必填); __@[email protected]: () => boolean (必填) — Returns the primitive value of the specified object.

packages/protocol/src/signal.ts:26
ref函数 · 公开
@openelement/element · ./client-only

为组件内的一个原生 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
releaseConsumedContext函数 · 公开
@openelement/element · ./client-only

释放某次带宿主的 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.

value: unknown (必填); subscribe: (fn: (value: unknown) => void) => Unsubscribe (必填); __@[email protected]: () => boolean (必填) — Returns the primitive value of the specified object.

packages/element/src/internal/core/signal-context.ts:208
RenderError类 · 公开
@openelement/element · ./client-only

可恢复的渲染错误,携带出错组件的文件路径与标签名。

class RenderError extends OpenElementError
英文源码说明

Recoverable render-phase error carrying the failing component path and tag.

packages/element/src/internal/core/errors.ts:95
renderToString函数 · 公开
@openelement/element · ./client-only

在服务端渲染一个已编译的元素,直接返回序列化后的声明式 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
RenderToStringOptions接口 · 公开
@openelement/element · ./client-only

一次 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.

componentClass?: CustomElementConstructor (可选); props?: Record<string, unknown> (可选); sourceInfo.route?: string (可选); sourceInfo.source?: string (可选); ssrRenderableTags?: readonly string[] (可选) — Build-admitted nested compiled tags. Omitted means shell-only rendering.; projectedChildren?: ReadonlyMap<string, TrustedHtml> (可选) — Trusted parent-owned light children keyed by slot name.; hostChildren?: TrustedHtml (可选) — Trusted parent-owned light children emitted AFTER the host's DSD template (a shadow-root host's slotted content). This is the shadow-side sibling of `projectedChildren`: a light root substitutes projections into its own `<slot>` elements, a shadow root distributes appended light DOM natively. Both are the compiled children channel — compiler-produced final HTML carrying the trustedHtml brand, nev…; onNestedFailure?: ((error: unknown) => void) (可选) — `16b-EB` (execution plan §19.2): the report channel for a descendant producer that threw while the enclosing error boundary owns it. The boundary supplies this; the renderer routes the caught failure here instead of failing the whole render, and renders the boundary's fallback bytes in the failing descendant's place. OMITTED is the no-boundary render: the failure re-raises, which is the unchanged…; nestedStyleSink?: Set<string> (可选) — Sheet URLs a nested LIGHT child lifted into the enclosing template (F16).; documentStyles?: DocumentStyleSink (可选) — The render's document stylesheet collection (alpha15 S lane, S-C1.2). Every light-root component serialized in this render reports its external sheet URLs here, and the document wrapper declares them in the head. The caller owns the collection's lifetime — one per document render — so styles discovered for one page can never reach another page's head.

packages/element/src/public-runtime.ts:170
reportError函数 · 公开
@openelement/element · ./client-only

将框架错误交给遥测钩子,无钩子时写入 console.error。

(error: OpenElementError): void
英文源码说明

Report an {@linkcode OpenElementError} to the telemetry hook, or console.error when none is installed.

code: string (必填); severity: ErrorSeverity (必填); phase: ErrorPhase (必填); recoverable: boolean (必填); statusCode.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; statusCode.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; statusCode.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; statusCode.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; statusCode.valueOf: () => number (必填) — Returns the primitive value of the specified object.; statusCode.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.; toJSON: () => Record<string, unknown> (必填); name: string (必填); message: string (必填); stack?: string (可选); cause?: unknown (可选)

packages/element/src/internal/core/errors.ts:139
RouteEntry接口 · 公开
@openelement/element · ./client-only

扫描后入选的路由,记录 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.

path: string (必填); filePath: string (必填); type: "page" | "api" | "island" | "special" (必填); varName: string (必填); tagName?: string (可选); definePage?: boolean (可选) — True when the route module's default export is a definePage() definition (#960 — registration decoupling). The generated entry registers the page class under the path-derived fallback tag and IGNORES the tagName export for registration: on a definePage route the export only names a content element. Plain element routes keep tagName as their registration tag.; functionPage?: string (可选) — The server function page fact (alpha15 server lane): the exported server function component the route's `export default definePage(Component)` was called over. Present only when the argument is a plain identifier resolving to a component THIS module declares — an inline arrow or an unexported local never records it (the R1 admission rule mirrored, so a shape whose JSX would escape to runtime is n…; source?: string (可选) — Source text captured during scanning when includeSource is enabled.; hasEnhancedForms?: boolean (可选) — True when the page route source carries data-open-enhance (#569): the client entry must ship the form-enhancement layer even when the app has zero islands.; special?: SpecialFileType (可选); params?: string[] (可选)

packages/protocol/src/framework.ts:113
ServerRouteContext接口 · 公开
@openelement/element · ./client-only

请求时渲染和静态站点生成共用的服务端路由上下文。

ServerRouteContext<Env, Platform, Route>
英文源码说明

Canonical request-time/SSG server route context.

request: Request (必填); params: Record<string, string> (必填); env: Env (必填); platform: Platform (必填); responseHeaders: Headers (必填) — Mutable response-only channel merged into the framework response.; route: Route (必填)

packages/protocol/src/data.ts:25
ServerRouteMetadata接口 · 公开
@openelement/element · ./client-only

动态路由 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().

path: string (必填); filePath: string (必填)

packages/protocol/src/data.ts:19
setErrorTelemetryHook函数 · 公开
@openelement/element · ./client-only

安装或替换整个进程使用的错误遥测钩子。

(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
signal函数 · 公开
@openelement/element · ./client-only

创建可读写的响应式状态。

<T>(initialValue: T): WritableSignal<T>
英文源码说明

Create a writable signal through the selected signal engine.

packages/element/src/internal/signal/framework.ts:19
Signal类型 · 公开
@openelement/element · ./client-only

接受可写信号或只读信号的 API 所用类型。

Signal<T>
英文源码说明

Alias for APIs that accept either writable or read-only signals.

packages/protocol/src/signal.ts:31
SpecialFileType类型 · 公开
@openelement/element · ./client-only

路由扫描器按文件名识别的特殊类型,包括 renderer 和 middleware。

SpecialFileType
英文源码说明

Special file kinds the route scanner recognizes by filename: `renderer` and `middleware`.

packages/protocol/src/framework.ts:79
SsrAdmissionDecision接口 · 公开
@openelement/element · ./client-only

构建对自定义元素的 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.

tagName: string (必填); modulePath: string (必填) — Module path of the island declaration. Empty for 'foreign' decisions: a foreign tag is consumed in JSX but declares no module the build owns.; source: "local" | "package" | "nested" | "foreign" (必填) — 'foreign' (#979): a third-party WC tag discovered by the foreign-tag scanner in page/island JSX — recorded for visibility only; SSR still treats it as an opaque passthrough (renderPath 'client-only').; renderPath: "ssr+client" | "client-only" | "rejected" (必填); reason: string (必填)

packages/protocol/src/render.ts:37
STREAM_FRAME_FORBIDDEN_TAGS常量 · 公开
@openelement/element · ./client-only

浏览器拒绝装入所属 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
STREAM_FRAME_UNSAFE_URL常量 · 公开
@openelement/element · ./client-only

流式片段的 URL 属性不可使用的协议。

RegExp
英文源码说明

Schemes that make a URL attribute unsafe in a streamed frame.

packages/protocol/src/stream-frame-policy.ts:60
STREAM_FRAME_URL_ATTRIBUTES常量 · 公开
@openelement/element · ./client-only

流式片段中需要检查 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
STREAM_FRAME_URL_CONTROL_MAX常量 · 公开
@openelement/element · ./client-only

检查 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
STREAM_MAX_FIELDS常量 · 公开
@openelement/element · ./client-only

一个流式路由允许在清单中声明的延迟字段数上限。

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
STREAM_MAX_OWNERS常量 · 公开
@openelement/element · ./client-only

一个流式路由清单可以引用的 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
STREAM_MAX_PAYLOAD_LENGTH常量 · 公开
@openelement/element · ./client-only

流式载荷的最大序列化长度,以 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
STREAM_MAX_SEED_PROPERTIES常量 · 公开
@openelement/element · ./client-only

流式 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
STREAM_TIMEOUT_MS常量 · 公开
@openelement/element · ./client-only

流式响应等待延迟字段完成的时间上限(毫秒)。

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
StyleSheet常量 · 公开
@openelement/element · ./client-only

可跨执行环境使用的样式表构造器,按环境选择原生 CSSStyleSheet 或兼容实现。

new () => StyleSheetLike
英文源码说明

Cross-realm StyleSheet constructor: the native CSSStyleSheet or the internal shim.

packages/element/src/internal/core/style-sheet.ts:110
StyleSheetLike接口 · 公开
@openelement/element · ./client-only

原生样式表与兼容实现共用的最小接口,包括 replaceSync 和 cssRules。

StyleSheetLike
英文源码说明

Minimal stylesheet contract (replaceSync + cssRules) satisfied by native and shim sheets.

replaceSync: (text: string) => void (必填); cssRules: StyleSheetRule[] (必填)

packages/protocol/src/style-sheet.ts:14
trustedHtml函数 · 公开
@openelement/element · ./client-only

将 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
TrustedHtml接口 · 公开
@openelement/element · ./client-only

标识应用已明确审查并信任的 HTML。

TrustedHtml
英文源码说明

Opaque capability marking HTML the application has explicitly vetted as trusted.

html: string (必填)

packages/element/src/internal/core/security.ts:83
unsafeStreamFrameAttribute函数 · 公开
@openelement/element · ./client-only

判断 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
useContext函数 · 公开
@openelement/element · ./client-only

订阅最近提供者的上下文,返回由实例持有的信号。没有提供者时读到令牌的默认值。

<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.

key.toString: () => string (必填) — Returns a string representation of an object.; key.valueOf: () => symbol (必填) — Returns the primitive value of the specified object.; key.description: string (必填) — Expose the [[Description]] internal slot of a symbol directly.; key.__@toPrimitive@6538: (hint: string) => symbol (必填) — Converts a Symbol object to a symbol.; key.__@toStringTag@6424: string (必填); defaultValue: T (必填)

packages/element/src/internal/core/compile-lifecycle.ts:285
useHost函数 · 公开
@openelement/element · ./client-only

获取当前组件所在的自定义元素。用于在组件中访问宿主节点。

(): 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
wrapInDocument函数 · 公开
@openelement/element · ./client-only

为渲染后的 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
deepGetElementById函数 · 公开
@openelement/element · ./document-services

在指定根节点及其嵌套 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
ensureDeepFragmentNavigation函数 · 公开
@openelement/element · ./document-services

为文档安装深层锚点导航,使同页链接能定位到嵌套 Shadow Root 内的目标。

(options?: DeepFragmentOptions): void
英文源码说明

Install (once per document) framework-level fragment navigation: a same-document anchor click whose target lives inside a nested shadow root scrolls to it and pushes the hash instead of being dropped by the browser. `{ enabled: false }` opts an application out.

enabled?: boolean (可选) — Set false before installation to opt out for an application.

packages/element/src/internal/core/deep-fragment.ts:67
ensurePreHydrationClickCapture函数 · 公开
@openelement/element · ./document-services

在元素升级前捕获发往待启用交互岛的用户操作,接管 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.

addEventListener: (type: string, callback: EventListenerOrEventListenerObject | null, options?: AddEventListenerOptions | boolean) => void (必填) — The **`addEventListener()`** method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target. [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener); dispatchEvent: (event: Event) => boolean (必填) — The **`dispatchEvent()`** method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order. The normal event processing rules (including the capturing and optional bubbling phase) also apply to events dispatched manually with dispatchEvent(). [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent); removeEventListener: (type: string, callback: EventListenerOrEventListenerObject | null, options?: EventListenerOptions | boolean) => void (必填) — The **`removeEventListener()`** method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target. The event listener to be removed is identified using a combination of the event type, the event listener function itself, and various optional options that may affect the matching process; see Matching event listeners for removal.…

packages/element/src/internal/compiled/runtime/pre-upgrade-events.ts:662
createDocumentStyleResources函数 · 公开
@openelement/element · ./html

为一次服务端渲染创建文档级样式表收集器。

(): DocumentStyleResources
英文源码说明

Create the per-render document stylesheet collection.

packages/element/src/internal/core/html-escape.ts:133
DocumentStyleResources接口 · 公开
@openelement/element · ./html

记录一次服务端渲染所发现的文档级样式表,供组件序列化与文档 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.

links: readonly string[] (必填) — Discovered resource URLs, deduplicated, in discovery (cascade) order.; add: (urls: readonly string[]) => void (必填) — Record the external stylesheet URLs one rendered component contributes.

packages/element/src/internal/core/html-escape.ts:125
escapeAttr函数 · 公开
@openelement/element · ./html

对 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
escapeAttrValue函数 · 公开
@openelement/element · ./html

转义字符串,以便用于双引号包裹的 HTML 属性值。

(value: unknown): string
英文源码说明

Escape a string for use as an attribute value (double-quoted)

packages/element/src/internal/core/html-escape.ts:60
escapeHtml函数 · 公开
@openelement/element · ./html

对文本中的五个 HTML 特殊字符进行转义。

(str: string): string
英文源码说明

Escape the five HTML-significant characters in text content.

packages/element/src/internal/core/html-escape.ts:39
isComponentStyleHref函数 · 公开
@openelement/element · ./html
(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
SafeHtml类型 · 公开
@openelement/element · ./html

表示已完成 HTML 转义,可作为文本内容使用的字符串类型。

SafeHtml
英文源码说明

Branded type: a string that has been HTML-escaped (safe for text content)

packages/protocol/src/framework.ts:9
trustedHtml函数 · 公开
@openelement/element · ./html

将 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
TrustedHtml接口 · 公开
@openelement/element · ./html

标识应用已明确审查并信任的 HTML。

TrustedHtml
英文源码说明

Opaque capability marking HTML the application has explicitly vetted as trusted.

html: string (必填)

packages/element/src/internal/core/security.ts:83
UnsafeHtml类型 · 公开
@openelement/element · ./html

标识尚未转义、未被信任的 HTML 字符串。

UnsafeHtml
英文源码说明

Branded type: a string that is intentionally raw/untrusted HTML

packages/protocol/src/framework.ts:12
wrapInDocument函数 · 公开
@openelement/element · ./html

为渲染后的 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函数 · 公开
@openelement/element · ./jsx-dev-runtime

只供类型检查使用的 Fragment 标记,运行时执行会抛出错误。

(_props?: unknown): JSX.Element
英文源码说明

Typechecking-only fragment marker; fails closed when executed at runtime.

packages/element/src/jsx-dev-runtime.ts:39
JSX命名空间 · 公开
@openelement/element · ./jsx-dev-runtime

供 TypeScript 自动 JSX 转换使用的开发版类型接口。

any
英文源码说明

JSX type interface consumed by TypeScript's automatic JSX transform.

packages/element/src/jsx-dev-runtime.ts:44
jsxDEV函数 · 公开
@openelement/element · ./jsx-dev-runtime

为类型检查提供的 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函数 · 公开
@openelement/element · ./jsx-runtime

只供类型检查使用的 Fragment 标记,运行时执行会抛出错误。

(_props?: unknown): JSX.Element
英文源码说明

Typechecking-only fragment marker; fails closed when executed at runtime.

packages/element/src/jsx-runtime.ts:40
jsx函数 · 公开
@openelement/element · ./jsx-runtime

只用于类型检查的 JSX 工厂,运行时调用会抛出错误。

(_type: unknown, _props: unknown): JSX.Element
英文源码说明

Typechecking-only factory; fails closed when executed at runtime.

packages/element/src/jsx-runtime.ts:30
JSX命名空间 · 公开
@openelement/element · ./jsx-runtime

供 TypeScript 自动 JSX 转换使用的类型接口。

any
英文源码说明

JSX type interface consumed by TypeScript's automatic JSX transform.

packages/element/src/jsx-runtime.ts:45
jsxs函数 · 公开
@openelement/element · ./jsx-runtime

只用于类型检查的 JSX 工厂,运行时调用会抛出错误。

(_type: unknown, _props: unknown): JSX.Element
英文源码说明

Typechecking-only factory; fails closed when executed at runtime.

packages/element/src/jsx-runtime.ts:35
onConnect函数 · 公开
@openelement/element · ./lifecycle

生成的自定义元素每次连接时运行回调,包括重新连接。若回调返回清理函数,元素断开时会调用它。

(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
onDispose函数 · 公开
@openelement/element · ./lifecycle

在生成的元素实例最终销毁时运行一次回调,调用顺序在该连接的清理函数之后。

(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
onPropertyChange函数 · 公开
@openelement/element · ./lifecycle

元素的已声明属性写入新值后运行回调,包括 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
provideContext函数 · 公开
@openelement/element · ./lifecycle
<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.

key.toString: () => string (必填) — Returns a string representation of an object.; key.valueOf: () => symbol (必填) — Returns the primitive value of the specified object.; key.description: string (必填) — Expose the [[Description]] internal slot of a symbol directly.; key.__@toPrimitive@7556: (hint: string) => symbol (必填) — Converts a Symbol object to a symbol.; key.__@toStringTag@7558: string (必填); defaultValue: T (必填)

packages/element/src/internal/core/compile-lifecycle.ts:250
ref函数 · 公开
@openelement/element · ./lifecycle

为组件内的一个原生 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
useContext函数 · 公开
@openelement/element · ./lifecycle

订阅最近提供者的上下文,返回由实例持有的信号。没有提供者时读到令牌的默认值。

<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.

key.toString: () => string (必填) — Returns a string representation of an object.; key.valueOf: () => symbol (必填) — Returns the primitive value of the specified object.; key.description: string (必填) — Expose the [[Description]] internal slot of a symbol directly.; key.__@toPrimitive@7556: (hint: string) => symbol (必填) — Converts a Symbol object to a symbol.; key.__@toStringTag@7558: string (必填); defaultValue: T (必填)

packages/element/src/internal/core/compile-lifecycle.ts:285
useHost函数 · 公开
@openelement/element · ./lifecycle

获取当前组件所在的自定义元素。用于在组件中访问宿主节点。

(): 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
createLogger函数 · 公开
@openelement/element · ./logger

创建在每条消息前加上标签的日志记录器。

(tag: string): Logger
英文源码说明

Create a {@link Logger} that prefixes every message with `[tag]`.

packages/element/src/internal/core/logger.ts:18
createWarnScope函数 · 公开
@openelement/element · ./logger

为一次渲染创建独立的警告记录范围。

(): WarnScope
英文源码说明

Create a fresh, empty warning scope for one render.

packages/element/src/internal/core/logger.ts:41
Logger接口 · 公开
@openelement/element · ./logger

带标签的控制台日志接口。

Logger
英文源码说明

logger.ts - Tagged console logger. Lightweight scoped logger. Returns plain functions so it is tree-shakable and has zero class overhead.

debug: (msg: string, ...args: unknown[]) => void (必填); info: (msg: string, ...args: unknown[]) => void (必填); warn: (msg: string, ...args: unknown[]) => void (必填); error: (msg: string, ...args: unknown[]) => void (必填)

packages/element/src/internal/core/logger.ts:10
warnOnce函数 · 公开
@openelement/element · ./logger

在给定的渲染范围内每个键最多警告一次。未指定范围时使用进程内的全局记录。

(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接口 · 公开
@openelement/element · ./logger

跟踪一次渲染中已发出的警告。

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).

warned: Set<string> (必填)

packages/element/src/internal/core/logger.ts:36
__setRequestTimeStyleSheetUrls函数 · 公开
@openelement/element · ./no-blocks

为当前服务端进程设置已生成的样式表 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类型 · 公开
@openelement/element · ./no-blocks

处理页面路由的表单提交。

Action<T, Env, Platform, Route>
英文源码说明

Route action: handles form submissions for a page route.

packages/protocol/src/data.ts:64
ACTION_FETCH_HEADER常量 · 公开
@openelement/element · ./no-blocks

选择表单 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
ActionContext接口 · 公开
@openelement/element · ./no-blocks

传给路由 action 的上下文,包含 loader 上下文。

ActionContext<Env, Platform, Route>
英文源码说明

Context passed to a route action function (extends loader context).

formData: FormData (必填); request: Request (必填); params: Record<string, string> (必填); env: Env (必填); platform: Platform (必填); responseHeaders: Headers (必填) — Mutable response-only channel merged into the framework response.; route: Route (必填)

packages/protocol/src/data.ts:47
ActionResult类型 · 公开
@openelement/element · ./no-blocks

脚本提交表单时返回的联合类型。校验失败返回 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
assertValidTagName函数 · 公开
@openelement/element · ./no-blocks

检查名称是否符合自定义元素的标签名规则。

(tagName: string): void
英文源码说明

Assert that a tag name is a valid custom element name.

packages/element/src/internal/core/tag-utils.ts:50
collectPublicProps函数 · 公开
@openelement/element · ./no-blocks

收集宿主对象上所有公开的自有属性。

(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
CompatibilityClassification接口 · 公开
@openelement/element · ./no-blocks

兼容性扫描为每个标签记录分级、原因、来源和对应的 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.

tagName: string (必填); tier: CompatibilityTier (必填); reason: string (必填); source: "local" | "package" | "nested" (必填); modulePath?: string (可选); ssr?: boolean (可选); dsd?: boolean (可选); hydrate?: string (可选)

packages/protocol/src/framework.ts:347
CompatibilityTier类型 · 公开
@openelement/element · ./no-blocks

标签的构建兼容级别,区分服务端渲染、仅浏览器渲染、实验支持和拒绝构建。

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
ComponentLayer类型 · 公开
@openelement/element · ./no-blocks

组件的交付层级,区分静态 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
computed函数 · 公开
@openelement/element · ./no-blocks

根据依赖计算一个只读响应式值。

<T>(fn: () => T): ReadonlySignal<T>
英文源码说明

Create a derived read-only signal recomputed from its dependencies.

packages/element/src/internal/signal/framework.ts:23
consumeContext函数 · 公开
@openelement/element · ./no-blocks

将上下文投影为消费端的响应式值。传入宿主时,消费端负责通过 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.

key.toString: () => string (必填) — Returns a string representation of an object.; key.valueOf: () => symbol (必填) — Returns the primitive value of the specified object.; key.description: string (必填) — Expose the [[Description]] internal slot of a symbol directly.; key.__@toPrimitive@8012: (hint: string) => symbol (必填) — Converts a Symbol object to a symbol.; key.__@toStringTag@7898: string (必填); defaultValue: T (必填)

packages/element/src/internal/core/signal-context.ts:183
Context接口 · 公开
@openelement/element · ./no-blocks

上下文令牌,包含协议使用的键和默认值。

Context<T>
英文源码说明

A typed context token: protocol identity (`key`) plus its default value.

key.toString: () => string (必填) — Returns a string representation of an object.; key.valueOf: () => symbol (必填) — Returns the primitive value of the specified object.; key.description: string (必填) — Expose the [[Description]] internal slot of a symbol directly.; key.__@toPrimitive@8012: (hint: string) => symbol (必填) — Converts a Symbol object to a symbol.; key.__@toStringTag@7898: string (必填); defaultValue: T (必填)

packages/element/src/internal/core/signal-context.ts:13
createContext函数 · 公开
@openelement/element · ./no-blocks

创建供提供方与消费方共享的带类型上下文令牌。

<T>(key: symbol, defaultValue: T): Context<T>
英文源码说明

Create a typed context token shared between provider and consumer elements.

toString: () => string (必填) — Returns a string representation of an object.; valueOf: () => symbol (必填) — Returns the primitive value of the specified object.; description: string (必填) — Expose the [[Description]] internal slot of a symbol directly.; __@toPrimitive@8012: (hint: string) => symbol (必填) — Converts a Symbol object to a symbol.; __@toStringTag@7898: string (必填)

packages/element/src/internal/core/signal-context.ts:58
createDocumentStyleResources函数 · 公开
@openelement/element · ./no-blocks

为一次服务端渲染创建文档级样式表收集器。

(): DocumentStyleResources
英文源码说明

Create the per-render document stylesheet collection.

packages/element/src/internal/core/html-escape.ts:133
createLogger函数 · 公开
@openelement/element · ./no-blocks

创建在每条消息前加上标签的日志记录器。

(tag: string): Logger
英文源码说明

Create a {@link Logger} that prefixes every message with `[tag]`.

packages/element/src/internal/core/logger.ts:18
DANGEROUS_KEYS常量 · 公开
@openelement/element · ./no-blocks

从不可信属性复制数据时必须排除的对象原型键。

ReadonlySet<string>
英文源码说明

Object prototype keys that must never be injected from untrusted props.

packages/element/src/internal/core/security.ts:25
deepGetElementById函数 · 公开
@openelement/element · ./no-blocks

在指定根节点及其嵌套 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
documentStreamParts函数 · 公开
@openelement/element · ./no-blocks

使用相同的文档序列化规则生成流式响应的首尾片段,保留正文容器供流写入。

(options?: DocumentWrapOptions): { prefix: string; suffix: string; }
英文源码说明

The same document serialization boundary, with only body wrappers left open.

title?: string (可选); lang?: string (可选); clientScript?: string (可选); scripts?: DocumentScriptDescriptor[] (可选); meta.description?: string (可选); meta.tags?: Record<string, string | number | boolean>[] (可选); devScripts?: string (可选); headExtras?: string (可选); dangerouslyHeadFragments?: string[] (可选); allowHeadExtrasScripts?: boolean (可选); links?: { rel: string; href: string; hreflang?: string; }[] (可选); structuredData?: readonly Record<string, unknown>[] (可选); cspNonce?: string (可选); streamBootstrap?: string (可选) — Trusted framework bootstrap emitted synchronously in the document head.; styleLinks?: readonly string[] (可选) — The document's light-root component stylesheets: external resource URLs (alpha15 S lane, S-C1.2) serialized as marked `<link rel="stylesheet">` nodes after `headExtras`, so a light component is styled by the document that contains it — without JavaScript and without a runtime style node.

packages/element/src/internal/core/html-escape.ts:205
DocumentStyleResources接口 · 公开
@openelement/element · ./no-blocks

记录一次服务端渲染所发现的文档级样式表,供组件序列化与文档 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.

links: readonly string[] (必填) — Discovered resource URLs, deduplicated, in discovery (cascade) order.; add: (urls: readonly string[]) => void (必填) — Record the external stylesheet URLs one rendered component contributes.

packages/element/src/internal/core/html-escape.ts:125
effect函数 · 公开
@openelement/element · ./no-blocks

运行副作用,并在使用的信号发生变化时重新执行和订阅。

(fn: () => void | Unsubscribe): Unsubscribe
英文源码说明

Run a side effect that re-subscribes whenever its signal dependencies change.

packages/element/src/internal/signal/framework.ts:27
ensureDeepFragmentNavigation函数 · 公开
@openelement/element · ./no-blocks

为文档安装深层锚点导航,使同页链接能定位到嵌套 Shadow Root 内的目标。

(options?: DeepFragmentOptions): void
英文源码说明

Install (once per document) framework-level fragment navigation: a same-document anchor click whose target lives inside a nested shadow root scrolls to it and pushes the hash instead of being dropped by the browser. `{ enabled: false }` opts an application out.

enabled?: boolean (可选) — Set false before installation to opt out for an application.

packages/element/src/internal/core/deep-fragment.ts:67
ensurePreHydrationClickCapture函数 · 公开
@openelement/element · ./no-blocks

在元素升级前捕获发往待启用交互岛的用户操作,接管 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.

addEventListener: (type: string, callback: EventListenerOrEventListenerObject | null, options?: AddEventListenerOptions | boolean) => void (必填) — The **`addEventListener()`** method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target. [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener); dispatchEvent: (event: Event) => boolean (必填) — The **`dispatchEvent()`** method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order. The normal event processing rules (including the capturing and optional bubbling phase) also apply to events dispatched manually with dispatchEvent(). [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent); removeEventListener: (type: string, callback: EventListenerOrEventListenerObject | null, options?: EventListenerOptions | boolean) => void (必填) — The **`removeEventListener()`** method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target. The event listener to be removed is identified using a combination of the event type, the event listener function itself, and various optional options that may affect the matching process; see Matching event listeners for removal.…

packages/element/src/internal/compiled/runtime/pre-upgrade-events.ts:662
ERROR_PREFIX常量 · 公开
@openelement/element · ./no-blocks

openElement 错误消息使用的前缀。

"[openElement]"
英文源码说明

Error message prefix for all openElement errors.

packages/protocol/src/errors.ts:50
ErrorTelemetryHook类型 · 公开
@openelement/element · ./no-blocks

接收所有通过错误遥测渠道上报的 OpenElementError。

ErrorTelemetryHook
英文源码说明

Callback receiving every reported {@linkcode OpenElementError} for telemetry.

packages/protocol/src/errors.ts:132
escapeAttr函数 · 公开
@openelement/element · ./no-blocks

对 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
escapeHtml函数 · 公开
@openelement/element · ./no-blocks

对文本中的五个 HTML 特殊字符进行转义。

(str: string): string
英文源码说明

Escape the five HTML-significant characters in text content.

packages/element/src/internal/core/html-escape.ts:39
formatError函数 · 公开
@openelement/element · ./no-blocks

将未知类型的异常值格式化为可读的字符串。

(e: unknown): string
英文源码说明

Format an unknown thrown value as a human-readable string.

packages/element/src/internal/core/errors.ts:52
FrameworkOptions接口 · 公开
@openelement/element · ./no-blocks
FrameworkOptions
英文源码说明

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.

renderer?: "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).; routesDir?: string (可选) — Directory the route scanner walks, relative to the Vite root. Defaults to `app/routes`.; islandsDir?: string (可选) — Directory island modules are discovered in. Defaults to `app/islands`.; packageIslands?: 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…; layout?: LayoutConfig (可选) — Layout declaration; `false` disables the layout, `'default'` uses the built-in one.; layouts?: LayoutsConfig (可选) — Named layout declarations keyed by layout name.; headExtras?: string (可选) — @dangerous injected as-is, only use with controlled content; html.lang?: string (可选); html.title?: string (可选); inject.stylesheets?: (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.; inject.scripts?: (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.; inject.headFragments?: 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>`.; ssr.noExternal?: (string | RegExp)[] (可选); island.upgradeStrategy?: "load" | "idle" | "visible" | "only" | "none" (可选); build.outDir?: string (可选) — Output directory for the build artifacts. Defaults to `dist`.; build.manifestBudget?: { 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.; viewTransition?: boolean (可选) — Enable the View Transitions API for client navigations. Defaults to true.; speculation?: 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.; middleware.cors?: boolean (可选) — Built-in CORS middleware. Default-ON; pass `false` to disable.; middleware.corsOrigin?: string | string[] (可选) — Static CORS allowlist data, serialized into the generated entry as JSON. Mutually exclusive with {@link FrameworkOptions.middleware.corsOriginModule }.; middleware.corsOriginModule?: string (可选) — Path 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`.; middleware.requestId?: boolean (可选) — Emit and honor a per-request id header. Default-ON; pass `false` to disable.; middleware.logger?: boolean (可选) — Log each request through the built-in logger. Default-ON; pass `false` to disable.; middleware.securityHeaders?: boolean (可选) — Attach the built-in security response headers. Default-ON; pass `false` to disable.; middleware.csp?: { policy?: string; nonce?: boolean; reportOnly?: boolean; } (可选) — Content-Security-Policy emission: the policy string, nonce generation, and report-only mode.; middleware.use?: 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…

packages/protocol/src/framework.ts:180
HYDRATION_STRATEGIES常量 · 公开
@openelement/element · ./no-blocks

运行时支持的 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
HydrationStrategy类型 · 公开
@openelement/element · ./no-blocks

控制交互岛何时启用,也可跳过浏览器 hydration。

"load" | "idle" | "visible" | "only" | "none"
英文源码说明

Island hydration trigger: 'load' | 'idle' | 'visible' | 'only'.

packages/protocol/src/framework.ts:30
IDLE_FALLBACK_TIMEOUT_MS常量 · 公开
@openelement/element · ./no-blocks

环境缺少 requestIdleCallback 和 requestAnimationFrame 时,空闲 hydration 的备用延时(毫秒)。

50
英文源码说明

Idle-hydration scheduling fallback (milliseconds) when neither `requestIdleCallback` nor `requestAnimationFrame` is available.

packages/protocol/src/policy.ts:70
injectPropsSafe函数 · 公开
@openelement/element · ./no-blocks

将调用方提供的属性写入目标对象,跳过受保护的键,并容忍只读属性。

(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
isDangerousKey函数 · 公开
@openelement/element · ./no-blocks

判断属性键是否为框架在写入属性时必须拒绝的对象原型键。

(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
IslandOptions接口 · 公开
@openelement/element · ./no-blocks

交互岛的交付选项,包括 hydration 策略和是否参与 SSR 或 DSD。

IslandOptions
英文源码说明

Per-island delivery options (hydration strategy, SSR/DSD participation).

hydrate?: "load" | "idle" | "visible" | "only" | "none" (可选) — Hydration strategy: - 'load': load immediately when module is imported - 'idle': defer to requestIdleCallback (default) - 'visible': use IntersectionObserver to defer until element is visible - 'only': client-only render, no DSD/SSR output Named `hydrate` to match `defineIslandConfig()` in the Router package — one option name across both packages.; dsd?: boolean (可选) — Whether to use DSD for SSR rendering of this island. Honored by the build-side island scan (via `defineIslandConfig`), not by `defineIsland()` itself: passing it in `IslandOptions` has no runtime effect.; ssr?: boolean (可选) — Whether this island may be admitted into server rendering. Like `dsd`, decided by the build-side island scan; inert when passed to `defineIsland()`.

packages/protocol/src/island.ts:8
isSafeAttributeName函数 · 公开
@openelement/element · ./no-blocks

服务端渲染检查属性名时调用的公共校验入口,规则和协议层一致。

(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
isValidTagName函数 · 公开
@openelement/element · ./no-blocks

判断字符串是否符合 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类型 · 公开
@openelement/element · ./no-blocks

为路由选择内置布局、指定自定义布局及其模块和属性,或关闭布局。

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类型 · 公开
@openelement/element · ./no-blocks

为页面路由获取数据的 loader。

Loader<T, Env, Platform, Route>
英文源码说明

Route loader: fetches data for a page route.

packages/protocol/src/data.ts:56
LoaderContext接口 · 公开
@openelement/element · ./no-blocks

传给动态路由 loader 的请求上下文。

LoaderContext<Env, Platform, Route>
英文源码说明

Context passed to a request-time ('dynamic') route loader.

request: Request (必填); params: Record<string, string> (必填); env: Env (必填); platform: Platform (必填); responseHeaders: Headers (必填) — Mutable response-only channel merged into the framework response.; route: Route (必填)

packages/protocol/src/data.ts:40
LocalePath接口 · 公开
@openelement/element · ./no-blocks

随语言解析的路径契约。

LocalePath
英文源码说明

Locale-aware resolved path contract.

locale: string (必填); path: string (必填); localizedPath: string (必填); isDefaultLocalePath: boolean (必填)

packages/protocol/src/framework.ts:82
Logger接口 · 公开
@openelement/element · ./no-blocks

带标签的控制台日志接口。

Logger
英文源码说明

logger.ts - Tagged console logger. Lightweight scoped logger. Returns plain functions so it is tree-shakable and has zero class overhead.

debug: (msg: string, ...args: unknown[]) => void (必填); info: (msg: string, ...args: unknown[]) => void (必填); warn: (msg: string, ...args: unknown[]) => void (必填); error: (msg: string, ...args: unknown[]) => void (必填)

packages/element/src/internal/core/logger.ts:10
MAX_ACTION_BODY_BYTES常量 · 公开
@openelement/element · ./no-blocks

生成的服务端入口对 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
MAX_COMPOSITION_DEPTH常量 · 公开
@openelement/element · ./no-blocks

renderToString 允许展开的嵌套元素层数,避免循环组合导致无穷递归。

8
英文源码说明

Nested element expansion depth bound for `renderToString`: cyclic component composition fails closed instead of recursing without end.

packages/protocol/src/policy.ts:51
Middleware类型 · 公开
@openelement/element · ./no-blocks

基于标准 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
onConnect函数 · 公开
@openelement/element · ./no-blocks

生成的自定义元素每次连接时运行回调,包括重新连接。若回调返回清理函数,元素断开时会调用它。

(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
onDispose函数 · 公开
@openelement/element · ./no-blocks

在生成的元素实例最终销毁时运行一次回调,调用顺序在该连接的清理函数之后。

(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
onError函数 · 公开
@openelement/element · ./no-blocks

处理当前生成元素在连接、接管服务端标记、更新或处理 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
onPropertyChange函数 · 公开
@openelement/element · ./no-blocks

元素的已声明属性写入新值后运行回调,包括 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
OpenElementAttribute接口 · 公开
@openelement/element · ./no-blocks

自定义元素声明中记录的一个 attribute。

OpenElementAttribute
英文源码说明

One documented attribute of a custom element declaration.

name: string (必填); type?: string (可选); default?: string (可选); description?: string (可选); reflects?: boolean (可选); fieldName?: string (可选)

packages/protocol/src/manifest.ts:15
OpenElementCssPart接口 · 公开
@openelement/element · ./no-blocks

自定义元素声明中记录的一个 CSS part。

OpenElementCssPart
英文源码说明

One documented CSS part of a custom element declaration.

name: string (必填); description?: string (可选)

packages/protocol/src/manifest.ts:38
OpenElementDeclaration接口 · 公开
@openelement/element · ./no-blocks

包清单中的自定义元素声明,包括标签名、成员和交付信息。

OpenElementDeclaration
英文源码说明

One custom element declaration in a package manifest: tag, members and delivery metadata.

tagName: string (必填); className?: string (可选); superclassName?: string (可选); attributes?: OpenElementAttribute[] (可选); events?: OpenElementEvent[] (可选); slots?: OpenElementSlot[] (可选); cssParts?: OpenElementCssPart[] (可选); openElement.ssr?: boolean (可选); openElement.dsd?: boolean (可选); openElement.layer?: ComponentLayer (可选); openElement.hydrate?: "load" | "idle" | "visible" | "only" | "none" (可选); openElement.status?: "stable" | "experimental" (可选) — Stability marker from the owning package's manifest policy.; openElement.module?: string (可选); openElement.export?: string (可选); openElement.tailwind?: OpenElementTailwindDeclaration (可选); openElement.root?: "light" | "shadow" | "closed" (可选) — The host root a generated-element declaration was compiled with. Absent for a class declaration (its descriptor owns the root) and for a generated declaration whose sidecar declares none (the descriptor default is light).; openElement.styles?: readonly string[] (可选) — The authored package-relative `.css` specifiers a generated SHADOW host declares, published so a consuming build can emit the sheet and hand its URL to the DSD style-link carrier. Absent when the component declares none; class declarations deliver their sheets through `static styles` instead.; openElement.ssrHostExport?: string (可选) — The compiler-emitted SSR host producer's export name (`<Component>__ssrHost`) for a generated declaration whose root is `shadow`. A consuming build cannot otherwise learn it: the name is the compiler's return-only `ssrHostExport` metadata, and re-deriving it from a naming convention inside the router would be exactly the drift ADR-0182 forbids ("read the compiler's return value, never re-derive i…; description?: string (可选)

packages/protocol/src/manifest.ts:116
OpenElementError类 · 公开
@openelement/element · ./no-blocks

框架错误,提供稳定错误码、严重程度、发生阶段和可恢复性。

class OpenElementError extends Error
英文源码说明

Framework error carrying a stable code, severity, phase and recoverability contract.

packages/protocol/src/errors.ts:100
OpenElementEvent接口 · 公开
@openelement/element · ./no-blocks

自定义元素声明中记录的一个自定义事件。

OpenElementEvent
英文源码说明

One documented custom event of a custom element declaration.

name: string (必填); type?: string (可选); description?: string (可选)

packages/protocol/src/manifest.ts:25
OpenElementPackageManifest接口 · 公开
@openelement/element · ./no-blocks

包级组件清单,记录其中声明的组件。

OpenElementPackageManifest
英文源码说明

Package manifest of component declarations (not a Custom Elements Manifest).

schemaVersion: string (必填); packageName: string (必填); version: string (必填); description?: string (可选); author?: string (可选); license?: string (可选); homepage?: string (可选); repository?: string (可选); declarations: OpenElementDeclaration[] (必填)

packages/protocol/src/manifest.ts:129
OpenElementRouteKind类型 · 公开
@openelement/element · ./no-blocks

应用与构建驱动共享的路由类别。

OpenElementRouteKind
英文源码说明

Host-agnostic route and asset contracts shared by app and build drivers.

packages/protocol/src/app-model.ts:2
OpenElementRouteNode接口 · 公开
@openelement/element · ./no-blocks

路由树节点,记录匹配路径、路由类型、源码与模块路径、可选的标签和参数,以及子路由。

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`.

kind: OpenElementRouteKind (必填); path: string (必填); filePath?: string (可选); importPath?: string (可选); tagName?: string (可选); paramNames?: string[] (可选); children?: OpenElementRouteNode[] (可选); meta?: Record<string, unknown> (可选)

packages/protocol/src/app-model.ts:9
OpenElementSlot接口 · 公开
@openelement/element · ./no-blocks

自定义元素声明中记录的一个插槽。

OpenElementSlot
英文源码说明

One documented slot of a custom element declaration.

name: string (必填); description?: string (可选)

packages/protocol/src/manifest.ts:32
PROBLEM_JSON_MEDIA_TYPE常量 · 公开
@openelement/element · ./no-blocks

RFC 9457 Problem Details 错误响应使用的媒体类型。

"application/problem+json"
英文源码说明

Media type of the RFC 9457 action error channel (#863).

packages/protocol/src/data.ts:117
ProblemDetails接口 · 公开
@openelement/element · ./no-blocks

表单 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.

type: string (必填) — URI reference identifying the problem type; 'about:blank' when none applies.; title: string (必填) — Short human-readable summary (the HTTP reason phrase for 'about:blank').; status.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; status.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; status.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; status.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; status.valueOf: () => number (必填) — Returns the primitive value of the specified object.; status.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.; detail?: string (可选) — Human-readable explanation specific to this occurrence.

packages/protocol/src/data.ts:105
provideContext函数 · 公开
@openelement/element · ./no-blocks

提供普通的协议上下文值。用于提供值的 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:131
ReadonlySignal接口 · 公开
@openelement/element · ./no-blocks

computed 等派生值使用的只读信号接口。

ReadonlySignal<T>
英文源码说明

Read-only signal protocol used by computed values.

value: T (必填); subscribe: (fn: (value: T) => void) => Unsubscribe (必填); __@[email protected]: () => boolean (必填) — Returns the primitive value of the specified object.

packages/protocol/src/signal.ts:26
ref函数 · 公开
@openelement/element · ./no-blocks

为组件内的一个原生 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
releaseConsumedContext函数 · 公开
@openelement/element · ./no-blocks

释放某次带宿主的 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.

value: unknown (必填); subscribe: (fn: (value: unknown) => void) => Unsubscribe (必填); __@[email protected]: () => boolean (必填) — Returns the primitive value of the specified object.

packages/element/src/internal/core/signal-context.ts:208
RenderError类 · 公开
@openelement/element · ./no-blocks

可恢复的渲染错误,携带出错组件的文件路径与标签名。

class RenderError extends OpenElementError
英文源码说明

Recoverable render-phase error carrying the failing component path and tag.

packages/element/src/internal/core/errors.ts:95
renderToString函数 · 公开
@openelement/element · ./no-blocks

在服务端渲染一个已编译的元素,直接返回序列化后的声明式 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
RenderToStringOptions接口 · 公开
@openelement/element · ./no-blocks

一次 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.

componentClass?: CustomElementConstructor (可选); props?: Record<string, unknown> (可选); sourceInfo.route?: string (可选); sourceInfo.source?: string (可选); ssrRenderableTags?: readonly string[] (可选) — Build-admitted nested compiled tags. Omitted means shell-only rendering.; projectedChildren?: ReadonlyMap<string, TrustedHtml> (可选) — Trusted parent-owned light children keyed by slot name.; hostChildren?: TrustedHtml (可选) — Trusted parent-owned light children emitted AFTER the host's DSD template (a shadow-root host's slotted content). This is the shadow-side sibling of `projectedChildren`: a light root substitutes projections into its own `<slot>` elements, a shadow root distributes appended light DOM natively. Both are the compiled children channel — compiler-produced final HTML carrying the trustedHtml brand, nev…; onNestedFailure?: ((error: unknown) => void) (可选) — `16b-EB` (execution plan §19.2): the report channel for a descendant producer that threw while the enclosing error boundary owns it. The boundary supplies this; the renderer routes the caught failure here instead of failing the whole render, and renders the boundary's fallback bytes in the failing descendant's place. OMITTED is the no-boundary render: the failure re-raises, which is the unchanged…; nestedStyleSink?: Set<string> (可选) — Sheet URLs a nested LIGHT child lifted into the enclosing template (F16).; documentStyles?: DocumentStyleSink (可选) — The render's document stylesheet collection (alpha15 S lane, S-C1.2). Every light-root component serialized in this render reports its external sheet URLs here, and the document wrapper declares them in the head. The caller owns the collection's lifetime — one per document render — so styles discovered for one page can never reach another page's head.

packages/element/src/public-runtime.ts:170
reportError函数 · 公开
@openelement/element · ./no-blocks

将框架错误交给遥测钩子,无钩子时写入 console.error。

(error: OpenElementError): void
英文源码说明

Report an {@linkcode OpenElementError} to the telemetry hook, or console.error when none is installed.

code: string (必填); severity: ErrorSeverity (必填); phase: ErrorPhase (必填); recoverable: boolean (必填); statusCode.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; statusCode.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; statusCode.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; statusCode.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; statusCode.valueOf: () => number (必填) — Returns the primitive value of the specified object.; statusCode.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.; toJSON: () => Record<string, unknown> (必填); name: string (必填); message: string (必填); stack?: string (可选); cause?: unknown (可选)

packages/element/src/internal/core/errors.ts:139
RouteEntry接口 · 公开
@openelement/element · ./no-blocks

扫描后入选的路由,记录 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.

path: string (必填); filePath: string (必填); type: "page" | "api" | "island" | "special" (必填); varName: string (必填); tagName?: string (可选); definePage?: boolean (可选) — True when the route module's default export is a definePage() definition (#960 — registration decoupling). The generated entry registers the page class under the path-derived fallback tag and IGNORES the tagName export for registration: on a definePage route the export only names a content element. Plain element routes keep tagName as their registration tag.; functionPage?: string (可选) — The server function page fact (alpha15 server lane): the exported server function component the route's `export default definePage(Component)` was called over. Present only when the argument is a plain identifier resolving to a component THIS module declares — an inline arrow or an unexported local never records it (the R1 admission rule mirrored, so a shape whose JSX would escape to runtime is n…; source?: string (可选) — Source text captured during scanning when includeSource is enabled.; hasEnhancedForms?: boolean (可选) — True when the page route source carries data-open-enhance (#569): the client entry must ship the form-enhancement layer even when the app has zero islands.; special?: SpecialFileType (可选); params?: string[] (可选)

packages/protocol/src/framework.ts:113
ServerRouteContext接口 · 公开
@openelement/element · ./no-blocks

请求时渲染和静态站点生成共用的服务端路由上下文。

ServerRouteContext<Env, Platform, Route>
英文源码说明

Canonical request-time/SSG server route context.

request: Request (必填); params: Record<string, string> (必填); env: Env (必填); platform: Platform (必填); responseHeaders: Headers (必填) — Mutable response-only channel merged into the framework response.; route: Route (必填)

packages/protocol/src/data.ts:25
ServerRouteMetadata接口 · 公开
@openelement/element · ./no-blocks

动态路由 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().

path: string (必填); filePath: string (必填)

packages/protocol/src/data.ts:19
setErrorTelemetryHook函数 · 公开
@openelement/element · ./no-blocks

安装或替换整个进程使用的错误遥测钩子。

(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
signal函数 · 公开
@openelement/element · ./no-blocks

创建可读写的响应式状态。

<T>(initialValue: T): WritableSignal<T>
英文源码说明

Create a writable signal through the selected signal engine.

packages/element/src/internal/signal/framework.ts:19
Signal类型 · 公开
@openelement/element · ./no-blocks

接受可写信号或只读信号的 API 所用类型。

Signal<T>
英文源码说明

Alias for APIs that accept either writable or read-only signals.

packages/protocol/src/signal.ts:31
SpecialFileType类型 · 公开
@openelement/element · ./no-blocks

路由扫描器按文件名识别的特殊类型,包括 renderer 和 middleware。

SpecialFileType
英文源码说明

Special file kinds the route scanner recognizes by filename: `renderer` and `middleware`.

packages/protocol/src/framework.ts:79
SsrAdmissionDecision接口 · 公开
@openelement/element · ./no-blocks

构建对自定义元素的 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.

tagName: string (必填); modulePath: string (必填) — Module path of the island declaration. Empty for 'foreign' decisions: a foreign tag is consumed in JSX but declares no module the build owns.; source: "local" | "package" | "nested" | "foreign" (必填) — 'foreign' (#979): a third-party WC tag discovered by the foreign-tag scanner in page/island JSX — recorded for visibility only; SSR still treats it as an opaque passthrough (renderPath 'client-only').; renderPath: "ssr+client" | "client-only" | "rejected" (必填); reason: string (必填)

packages/protocol/src/render.ts:37
STREAM_FRAME_FORBIDDEN_TAGS常量 · 公开
@openelement/element · ./no-blocks

浏览器拒绝装入所属 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
STREAM_FRAME_UNSAFE_URL常量 · 公开
@openelement/element · ./no-blocks

流式片段的 URL 属性不可使用的协议。

RegExp
英文源码说明

Schemes that make a URL attribute unsafe in a streamed frame.

packages/protocol/src/stream-frame-policy.ts:60
STREAM_FRAME_URL_ATTRIBUTES常量 · 公开
@openelement/element · ./no-blocks

流式片段中需要检查 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
STREAM_FRAME_URL_CONTROL_MAX常量 · 公开
@openelement/element · ./no-blocks

检查 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
STREAM_MAX_FIELDS常量 · 公开
@openelement/element · ./no-blocks

一个流式路由允许在清单中声明的延迟字段数上限。

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
STREAM_MAX_OWNERS常量 · 公开
@openelement/element · ./no-blocks

一个流式路由清单可以引用的 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
STREAM_MAX_PAYLOAD_LENGTH常量 · 公开
@openelement/element · ./no-blocks

流式载荷的最大序列化长度,以 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
STREAM_MAX_SEED_PROPERTIES常量 · 公开
@openelement/element · ./no-blocks

流式 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
STREAM_TIMEOUT_MS常量 · 公开
@openelement/element · ./no-blocks

流式响应等待延迟字段完成的时间上限(毫秒)。

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
StyleSheet常量 · 公开
@openelement/element · ./no-blocks

可跨执行环境使用的样式表构造器,按环境选择原生 CSSStyleSheet 或兼容实现。

new () => StyleSheetLike
英文源码说明

Cross-realm StyleSheet constructor: the native CSSStyleSheet or the internal shim.

packages/element/src/internal/core/style-sheet.ts:110
StyleSheetLike接口 · 公开
@openelement/element · ./no-blocks

原生样式表与兼容实现共用的最小接口,包括 replaceSync 和 cssRules。

StyleSheetLike
英文源码说明

Minimal stylesheet contract (replaceSync + cssRules) satisfied by native and shim sheets.

replaceSync: (text: string) => void (必填); cssRules: StyleSheetRule[] (必填)

packages/protocol/src/style-sheet.ts:14
trustedHtml函数 · 公开
@openelement/element · ./no-blocks

将 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
TrustedHtml接口 · 公开
@openelement/element · ./no-blocks

标识应用已明确审查并信任的 HTML。

TrustedHtml
英文源码说明

Opaque capability marking HTML the application has explicitly vetted as trusted.

html: string (必填)

packages/element/src/internal/core/security.ts:83
unsafeStreamFrameAttribute函数 · 公开
@openelement/element · ./no-blocks

判断 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
useContext函数 · 公开
@openelement/element · ./no-blocks

订阅最近提供者的上下文,返回由实例持有的信号。没有提供者时读到令牌的默认值。

<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.

key.toString: () => string (必填) — Returns a string representation of an object.; key.valueOf: () => symbol (必填) — Returns the primitive value of the specified object.; key.description: string (必填) — Expose the [[Description]] internal slot of a symbol directly.; key.__@toPrimitive@8012: (hint: string) => symbol (必填) — Converts a Symbol object to a symbol.; key.__@toStringTag@7898: string (必填); defaultValue: T (必填)

packages/element/src/internal/core/compile-lifecycle.ts:285
useHost函数 · 公开
@openelement/element · ./no-blocks

获取当前组件所在的自定义元素。用于在组件中访问宿主节点。

(): 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
wrapInDocument函数 · 公开
@openelement/element · ./no-blocks

为渲染后的 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
__h函数 · 公开
@openelement/element · ./server
(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
__setSsrRenderableTags函数 · 公开
@openelement/element · ./server

为当前服务端进程注入允许渲染的嵌套宿主标签。

(tags: readonly string[] | null | undefined): void
英文源码说明

Inject the renderable nested-host tags for this server process.

packages/element/src/server.ts:271
__ssr函数 · 公开
@openelement/element · ./server

序列化一个已获准渲染的组件的服务端标记。

(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
__t函数 · 公开
@openelement/element · ./server

转义一个动态文本值,使其可安全写入服务端函数组件的输出。

(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

@openelement/compiler

46 个导出
analyzeModuleSemantics函数 · 公开
@openelement/compiler · root

解析模块源码,提取编译器和 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接口 · 公开
@openelement/compiler · root

保存某次构建或开发服务器发现的样式类名候选项,供该构建的样式输出读取。

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.

register: (moduleId: string, candidates: readonly string[], options: { shadow: boolean; }) => void (必填) — Register ONE module's statically admitted class candidates. The call is authoritative for that module: an empty list means the module now carries no statically admitted class token, so its previous facts are dropped rather than left to inflate the next stylesheet.; remove: (moduleId: string) => void (必填) — Forget one module (a deleted file, a module that left the graph).; forModule: (moduleId: string) => readonly string[] (必填) — The candidates one module contributed, or an empty list.; all: () => readonly string[] (必填) — Every candidate registered so far, first-seen ordered and deduplicated.; allShadow: () => readonly string[] (必填) — The SHADOW-root candidates only. The COMPONENT sheet no longer compiles from this view (a light-root class can render inside a shadow tree, so the sheet takes {@linkcode ClassCandidateRegistry.all}); it stays as the shadow-only view of the facts, for a consumer that wants exactly that.; allLight: () => readonly string[] (必填) — The LIGHT-root candidates only — the document sheet's input for an engine that generates its own document CSS (a shadow component's classes are delivered by the component stylesheet and never inflate the document one).; has: () => boolean (必填) — True when any module contributed candidates.

packages/compiler/src/internal/compiler/tailwind-candidates.ts:55
clearCompilerDiagnostics函数 · 公开
@openelement/compiler · root

在开始新一轮构建前直接清空已记录的诊断。

(): void
英文源码说明

Clear without reading — the hygiene a fresh build invocation starts with.

packages/compiler/src/internal/compiler/semantic-core/diagnostics/index.ts:152
clearStyleRequests函数 · 公开
@openelement/compiler · root

从样式注册表清除所有依赖记录,结束本轮构建的记录周期。

(): void
英文源码说明

Drop every registered edge (a build's bookkeeping is its own lifetime).

packages/compiler/src/internal/compiler/style-requests.ts:93
compiledArtifactClassCandidates函数 · 公开
@openelement/compiler · root

读取已编译模块记录的样式类名候选项。模块未记录候选项时返回 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
compiledArtifactStyleRequests函数 · 公开
@openelement/compiler · root

按源码中的顺序恢复已编译模块的 .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:106
CompiledElementError类 · 公开
@openelement/compiler · root

Vite 插件和编译器测试使用的错误结构。

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
compiledElementPlugin函数 · 公开
@openelement/compiler · root
(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.

workspaceRoot?: string (可选) — Workspace root used as the second identity anchor: Vite ids outside the project root are typically linked workspace packages, and anchoring them on the workspace keeps machine paths out of emitted source maps. Callers that do not know a workspace root omit it and get ids passed through.; typeCheckEmitted?: boolean (可选) — Type-check every module the compiler emits and fail the build when one does not compile (#1386 item 2). Off by default: it runs a TypeScript program per emitted module, which a dev-server transform must not pay. A build or verification pass turns it on, so the emitted program is checked against the declarations the consumer compiles against.; resolutionPaths?: Record<string, string[]> (可选) — Specifier → candidate files map used when `typeCheckEmitted` is on.; candidates?: ClassCandidateRegistry (可选) — The class-candidate registry this plugin instance writes its compiled modules' statically admitted class tokens into (alpha15 S lane). The registry is OWNED by the host that created it — one per build, one per dev server — so two live builds in one process never inherit each other's facts (defect C). Omitted: this instance collects no candidates, which is the right shape for a build that consumes…; resolveServerComponentModule?: ((specifier: string, importer: string, resolve: (specifier: string) => Promise<{ id: string; external?: boolean | "absolute" | "relative"; } | null>) => string… (可选) — Host-supplied resolver for the server function component lane's nested imports (`resolveModule` of {@link compileServerComponentModule }): given a specifier and the importing module id, return that module's source so a nested server function component composes by direct call. Omitting it (or answering undefined) keeps nested composition a coded rejection. The compiler itself never reads the files…; compiledTags?: readonly string[] (可选) — The custom-element host tags the host build admitted as; generatedElementSite?: ((moduleId: string) => GeneratedElementSite | null) (可选) — Host-supplied site fact for the generated Native Custom Element lane (M09-1b): return `{ tag }` for a module the host resolved as an island whose registration tag is already decided, and null for every other module. Returning null (or omitting the option) keeps the lane inert and the module with the class/server/passthrough lanes. This is a host capability, never author syntax: the compiler trans…

packages/compiler/src/internal/compiler/plugin.ts:199
compileGeneratedElementIfAdmitted函数 · 公开
@openelement/compiler · root

宿主已为模块声明编译条件时,将该模块编译成原生自定义元素。

(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
compilerDiagnosticsToEnvelopes函数 · 公开
@openelement/compiler · root

将结构化编译诊断转换为协议的 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
compileServerComponentIfAdmitted函数 · 公开
@openelement/compiler · root
(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
compileServerComponentModule函数 · 公开
@openelement/compiler · root

将一个 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接口 · 公开
@openelement/compiler · root

服务端函数组件模块的编译结果。

CompileServerComponentResult
英文源码说明

The compiled server function component module.

code: string (必填) — The generated TS module: verbatim authored content + constructor functions.; map: CompiledElementSourceMap (必填) — Real Source Map v3 for the generated component functions.; components: string[] (必填) — The compiled component names, sorted.; classCandidates?: string[] (可选) — The statically admitted class tokens (alpha15 S lane), unioned over the compiled components — the host build forwards them to the official Tailwind compiler as explicit candidates.

packages/compiler/src/internal/compiler/semantic-core/server-component.ts:93
createClassCandidateRegistry函数 · 公开
@openelement/compiler · root

创建供一次构建或一个开发服务器使用的样式类名候选注册表。

(): ClassCandidateRegistry
英文源码说明

Create one owner's registry (see the lifetime note above).

packages/compiler/src/internal/compiler/tailwind-candidates.ts:87
diagnosticPluginError函数 · 公开
@openelement/compiler · root

将编译器诊断转换为构建适配器的错误结构。

(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
ElementCompilerDiagnostic接口 · 公开
@openelement/compiler · root

包含稳定 OEC 错误码、消息和源码范围的编译器诊断。

ElementCompilerDiagnostic
英文源码说明

A source-aware compiler diagnostic: stable OEC code, message and source range.

code: string (必填); message: string (必填); file: string (必填); line.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; line.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; line.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; line.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; line.valueOf: () => number (必填) — Returns the primitive value of the specified object.; line.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.; character: number (必填); start: number (必填); end: number (必填)

packages/compiler/src/internal/compiler/semantic-core/compiler-diagnostics.ts:17
EmittedModuleDiagnostic接口 · 公开
@openelement/compiler · root
EmittedModuleDiagnostic
英文源码说明

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.

code.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; code.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; code.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; code.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; code.valueOf: () => number (必填) — Returns the primitive value of the specified object.; code.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.; message: string (必填); file: string (必填); line: number (必填); character: number (必填)

packages/compiler/src/internal/compiler/semantic-core/type-check.ts:37
EmittedModuleTypeCheckOptions接口 · 公开
@openelement/compiler · root

指定输出模块如何解析导入项,以及类型检查时添加的虚拟文件。

EmittedModuleTypeCheckOptions
英文源码说明

How the emitted module's imports resolve, and any virtual files to add.

paths?: Record<string, string[]> (可选) — Module resolution map for the specifiers the emitted module imports, in TypeScript `paths` form (specifier → candidate files). A caller that resolves `@openelement/element` through the workspace passes that map; omitting it means imported specifiers resolve through `node_modules`, which is what a packed consumer has instead.; compilerOptions?: ts.CompilerOptions (可选) — Extra compiler options, merged over the defaults below.; extraFiles?: Readonly<Record<string, string>> (可选) — Support files the emitted module imports, supplied as text for ids that do not exist on disk (a bundler's other virtual modules). The emitted module itself is added under `fileName`.

packages/compiler/src/internal/compiler/semantic-core/type-check.ts:46
emittedModuleTypeChecks函数 · 公开
@openelement/compiler · root

输出模块通过类型检查时返回 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接口 · 公开
@openelement/compiler · root

宿主提供的模块信息,据此决定是否用生成式元素编译流程。

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.

tag: string (必填) — The custom-element tag the host's island pipeline will register.; root?: "light" | "shadow" | "closed" (可选) — The descriptor root the host will create, when the host already knows it (P-1, 2026-11-21). The router resolves this from the island's OWN declaration — the same fact the DSD link list and the shell's `root` come from — so a shadow generated island's statically admitted class tokens can be registered as SHADOW candidates (the component stylesheet) rather than light ones (the document sheet, which…

packages/compiler/src/internal/compiler/semantic-ir/generated-element/contract.ts:93
getStyleRequest函数 · 公开
@openelement/compiler · root

按已解析的样式表模块 ID 查找注册记录。

(moduleId: string): RegisteredStyleRequest | undefined
英文源码说明

The edge a resolved sheet module id carries, if any.

packages/compiler/src/internal/compiler/style-requests.ts:65
hasStyleImporter函数 · 公开
@openelement/compiler · root

判断导入模块是否已注册样式依赖,忽略查询后缀。

(importerId: string): boolean
英文源码说明

True when the importing module has registered edges (query suffixes ignored).

packages/compiler/src/internal/compiler/style-requests.ts:70
isJsxModuleId函数 · 公开
@openelement/compiler · root

忽略查询后缀,判断模块 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:2
ModuleSemanticFacts接口 · 公开
@openelement/compiler · root
ModuleSemanticFacts
英文源码说明

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.

relativeImports: string[] (必填); moduleSpecifiers?: string[] (可选) — Every runtime-capable static import/export specifier, relative or not — present only when the caller asks for it (`collectSpecifiers`), because a host that walks a module graph through its own resolver (S-C1.4's server-rendered style-edge pass) needs the aliased and package specifiers too, while every other consumer's facts stay exactly as they were.; compiledElementDecorator: boolean (必填); unsupportedElementDecorator?: string (可选) — Set when a class decorator spells the `element` intrinsic through unsupported or ambiguous provenance (type-only import, namespace access, default import, conflicting duplicate bindings, or a relative-module re-export). Never set for clearly foreign bindings (third-party packages, local declarations, bare/global spellings) — those modules are simply not OpenElement modules. No lane compiles such …; exportedTagName?: string (可选); definePage: boolean (必填) — True when the module default-exports a page-definition factory call from the host's injected vocabulary, or is an .mdx route. The default scan (no injected vocabulary) never recognizes another package's factories.; pageComponentName?: string (可选) — The server function page fact (alpha15 server lane): the first argument of a default-exported `definePage(…)` call when that argument is an identifier resolving to a server function component THIS module declares. A function component never carries a Part Program, so the route cannot be a compiled class page; the host build renders it through the component function. Spread-conditional: absent for…; serverFunctionComponents: string[] (必填) — The exported functions whose body is a single return of JSX — the server-only TSX function components this module declares (alpha15 server lane). Discovery is structural and deterministic: `export function` declarations (named, not default) with exactly one return statement of a JSX element, or `export const` arrows with a JSX expression body. The fact is the cheap graph-walker face; admission an…; usesExportedTagName: boolean (必填); enhancedForm: boolean (必填); defaultCompiledTag?: string (可选); definedCustomElementTags: string[] (必填); referencedCustomElementTags: string[] (必填); compilerInteractionEvents: string[] (必填); hasGeneratedElementSidecar: boolean (必填) — The module declares a GENERATED element: it carries the island policy sidecar statement (`export const openElement = defineIslandConfig({...})` / `defineComponentConfig({...})`) that the generated-element lane reads. This is the generated lane's counterpart to `definedCustomElementTags`: a generated component never applies the `@element` decorator (its element class is emitted by the compiler), s…

packages/compiler/src/internal/compiler/semantic-core/module-analysis.ts:14
ModuleSemanticsOptions接口 · 公开
@openelement/compiler · root

宿主为模块扫描提供的识别规则扩展。

ModuleSemanticsOptions
英文源码说明

Host-supplied vocabulary extensions for the module scan.

vocabulary?: readonly ModuleVocabularyDescriptor[] (可选) — Vocabulary descriptors the host admits beyond the core's own element bindings. The default scan knows no other package: a route module's page-definition export or registration factory is recognized only when the host injects its descriptor.; collectSpecifiers?: boolean (可选) — Collect {@link ModuleSemanticFacts.moduleSpecifiers} (opt-in).

packages/compiler/src/internal/compiler/semantic-core/module-analysis.ts:147
ModuleVocabularyDescriptor接口 · 公开
@openelement/compiler · root

描述模块扫描识别的导出绑定,以及调用该绑定时登记的事实。

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).

moduleSpecifier: string (必填) — Canonical module specifier the factory must be imported from.; exportName: string (必填) — Exported name of the factory binding.; kind: "page-definition" | "element-registration" (必填) — What a canonical call of the binding contributes to the scan.

packages/protocol/src/module-descriptors.ts:33
PluginDiagnosticError接口 · 公开
@openelement/compiler · root

Vite 适配层发出的 Rollup 兼容错误结构。

PluginDiagnosticError
英文源码说明

Rollup-compatible error shape emitted by the Vite adapter boundary.

id: string (必填); loc: { file: string; line: number; column: number; } (必填); frame: string (必填); message: string (必填); diagnostics: CompilerDiagnostic[] (必填)

packages/compiler/src/internal/compiler/semantic-core/diagnostics/index.ts:167
prepareServerComponentImports函数 · 公开
@openelement/compiler · root

解析用作服务端组件标签的具名导入,并返回供编译器同步查询的函数。

(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
readCompiledArtifactStyles函数 · 公开
@openelement/compiler · root

一次读取已编译模块记录的样式依赖和根节点作用域。

(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
recordCompilerDiagnostics函数 · 公开
@openelement/compiler · root

记录一次编译失败的结构化诊断,供构建退出时读取。

(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接口 · 公开
@openelement/compiler · root

一个已注册样式导入在构建模块图中的定位信息。

RegisteredStyleRequest
英文源码说明

One registered style edge: the authored import's build-graph coordinates.

moduleId: string (必填) — Resolved edge module id — the registry key, and what resolveId answers.; importer: string (必填) — The importing module's id as the build graph tracks it.; specifier: string (必填) — The authored `.css` specifier the generated module imports verbatim.; file: string (必填) — The sheet file's absolute path — where the intercepting build reads the bytes.; scopeTag?: string (可选) — The light-root component tag this edge's emitted asset is scoped to (alpha15 S lane, S-C1.2). A light root has no shadow boundary, so its sheets leave the build wrapped in native `@scope (<tag>)`; the tag is therefore part of the edge's identity, not a detail of its bytes — two components sharing one sheet file are two resources with two scopes. Absent for a shadow-root edge, whose bytes ship exa…

packages/compiler/src/internal/compiler/style-requests.ts:21
registerStyleEdges函数 · 公开
@openelement/compiler · root

把一个模块的样式依赖写入注册表。

(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
registerStyleRequest函数 · 公开
@openelement/compiler · root

按模块 ID 注册一个生成的样式依赖。重新编译会覆盖原记录。

(request: RegisteredStyleRequest): void
英文源码说明

Register one generated edge (idempotent per module id — recompiles overwrite).

moduleId: string (必填) — Resolved edge module id — the registry key, and what resolveId answers.; importer: string (必填) — The importing module's id as the build graph tracks it.; specifier: string (必填) — The authored `.css` specifier the generated module imports verbatim.; file: string (必填) — The sheet file's absolute path — where the intercepting build reads the bytes.; scopeTag?: string (可选) — The light-root component tag this edge's emitted asset is scoped to (alpha15 S lane, S-C1.2). A light root has no shadow boundary, so its sheets leave the build wrapped in native `@scope (<tag>)`; the tag is therefore part of the edge's identity, not a detail of its bytes — two components sharing one sheet file are two resources with two scopes. Absent for a shadow-root edge, whose bytes ship exa…

packages/compiler/src/internal/compiler/style-requests.ts:53
ResolvedServerComponentSource接口 · 公开
@openelement/compiler · root

包含导入的服务端组件源码和解析后的文件名,编译器据文件名选择解析语法。

ResolvedServerComponentSource
英文源码说明

Authored source with the resolved filename that determines its syntax.

fileName: string (必填); source: string (必填)

packages/compiler/src/internal/compiler/semantic-core/server-component.ts:64
SemanticCoreOptions接口 · 公开
@openelement/compiler · root

宿主为编译器语义核心提供的额外准入规则。

SemanticCoreOptions
英文源码说明

Host-supplied admission extensions for the semantic core.

staticSidecars?: readonly StaticSidecarDescriptor[] (可选) — Static-sidecar descriptors the host admits. The default core knows none: a module carrying a sidecar policy statement fails closed until the host injects its descriptor.

packages/compiler/src/internal/compiler/semantic-core/module-analysis.ts:137
ServerComponentCompileOptions接口 · 公开
@openelement/compiler · root

宿主传给服务端函数组件编译过程的输入。

ServerComponentCompileOptions
英文源码说明

Host-supplied inputs for the server function component compile.

resolveModule?: ((specifier: string) => string | ResolvedServerComponentSource | undefined) (可选) — Resolve one authored import specifier to that module's SOURCE, so a nested server function component composes by direct call to the imported binding (compile-time resolved, deterministic). Absent or returning undefined: importing components from that specifier is a coded rejection. Resolution of specifiers to files stays the host's job — the compiler never reads the filesystem. Supply the resolve…; compiledTags?: readonly string[] (可选) — The custom-element host tags the host build admitted as

packages/compiler/src/internal/compiler/semantic-core/server-component.ts:70
stableModuleId函数 · 公开
@openelement/compiler · root
(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接口 · 公开
@openelement/compiler · root

告诉元素编译器哪一项与组件放在同一模块的声明属于静态策略。

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).

moduleSpecifier: string (必填) — Canonical module specifier the sidecar export must be imported from.; exportName: string (必填) — Exported name of the sidecar factory binding.; kind: "static-sidecar" (必填) — The admission granted: a colocated static policy statement.

packages/protocol/src/module-descriptors.ts:16
styleEdgesForFile函数 · 公开
@openelement/compiler · root

按样式表路径反查所有关联的导入依赖,供开发时热更新使用。

(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
styleRequestFile函数 · 公开
@openelement/compiler · root

将导入模块所在目录与其样式导入路径拼接,得到样式表的绝对路径。

(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
styleRequestModuleId函数 · 公开
@openelement/compiler · root

生成样式依赖的注册键,包含已解析的文件路径及可用的 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
styleRequestsForImporter函数 · 公开
@openelement/compiler · root

返回指定导入模块声明的全部样式依赖。

(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
takeCompilerDiagnostics函数 · 公开
@openelement/compiler · root

读取并清空所有已记录的诊断,确保构建退出时只消费一次。

(): DiagnosticEnvelope[]
英文源码说明

Drain the recorded envelopes: the exit reads them exactly once.

packages/compiler/src/internal/compiler/semantic-core/diagnostics/index.ts:145
typeCheckEmittedModule函数 · 公开
@openelement/compiler · root

对一个编译后输出的模块执行类型检查。

(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
validatePartProgram函数 · 公开
@openelement/compiler · root

校验数据是否符合 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
element函数 · 公开
@openelement/compiler · ./vite
(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.

workspaceRoot?: string (可选) — Workspace root used as the second identity anchor: Vite ids outside the project root are typically linked workspace packages, and anchoring them on the workspace keeps machine paths out of emitted source maps. Callers that do not know a workspace root omit it and get ids passed through.; typeCheckEmitted?: boolean (可选) — Type-check every module the compiler emits and fail the build when one does not compile (#1386 item 2). Off by default: it runs a TypeScript program per emitted module, which a dev-server transform must not pay. A build or verification pass turns it on, so the emitted program is checked against the declarations the consumer compiles against.; resolutionPaths?: Record<string, string[]> (可选) — Specifier → candidate files map used when `typeCheckEmitted` is on.; candidates?: ClassCandidateRegistry (可选) — The class-candidate registry this plugin instance writes its compiled modules' statically admitted class tokens into (alpha15 S lane). The registry is OWNED by the host that created it — one per build, one per dev server — so two live builds in one process never inherit each other's facts (defect C). Omitted: this instance collects no candidates, which is the right shape for a build that consumes…; resolveServerComponentModule?: ((specifier: string, importer: string, resolve: (specifier: string) => Promise<{ id: string; external?: boolean | "absolute" | "relative"; } | null>) => string… (可选) — Host-supplied resolver for the server function component lane's nested imports (`resolveModule` of {@link compileServerComponentModule }): given a specifier and the importing module id, return that module's source so a nested server function component composes by direct call. Omitting it (or answering undefined) keeps nested composition a coded rejection. The compiler itself never reads the files…; compiledTags?: readonly string[] (可选) — The custom-element host tags the host build admitted as; generatedElementSite?: ((moduleId: string) => GeneratedElementSite | null) (可选) — Host-supplied site fact for the generated Native Custom Element lane (M09-1b): return `{ tag }` for a module the host resolved as an island whose registration tag is already decided, and null for every other module. Returning null (or omitting the option) keeps the lane inert and the module with the class/server/passthrough lanes. This is a host capability, never author syntax: the compiler trans…

packages/compiler/src/internal/compiler/plugin.ts:199

@openelement/router

205 个导出
Action类型 · 公开
@openelement/router · root

处理页面路由的表单提交。

Action<T, Env, Platform, Route>
英文源码说明

Route action: handles form submissions for a page route.

packages/protocol/src/data.ts:64
ACTION_FETCH_HEADER常量 · 公开
@openelement/router · root

选择表单 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
ActionContext接口 · 公开
@openelement/router · root

传给路由 action 的上下文,包含 loader 上下文。

ActionContext<Env, Platform, Route>
英文源码说明

Context passed to a route action function (extends loader context).

formData: FormData (必填); request: Request (必填); params: Record<string, string> (必填); env: Env (必填); platform: Platform (必填); responseHeaders: Headers (必填) — Mutable response-only channel merged into the framework response.; route: Route (必填)

packages/protocol/src/data.ts:47
ActionOutcome类型 · 公开
@openelement/router · root

操作的可辨识结果,`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
ActionResult类型 · 公开
@openelement/router · root

脚本提交表单时返回的联合类型。校验失败返回 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
classifyActionResult函数 · 公开
@openelement/router · root

按应用层的统一规则判断操作返回值是成功还是结构化失败。

<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
CONVENTION_BASE_DIR常量 · 公开
@openelement/router · root

当未提供 `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
CONVENTION_COMPONENTS_DIR常量 · 公开
@openelement/router · root

组件默认目录 `app/components`,也是 `dirs.components` 的默认值。

"app/components"
英文源码说明

Default component directory (`app/components`), the `dirs.components` default.

packages/router/src/config.ts:70
CONVENTION_HEAD_PATH常量 · 公开
@openelement/router · root

文档 `<head>` 结构模块的默认约定路径 `app/head.tsx`。

"app/head.tsx"
英文源码说明

Convention path for the structural document-head module (`app/head.tsx`).

packages/router/src/config.ts:94
CONVENTION_HEAD_SUFFIX常量 · 公开
@openelement/router · root

文档 `<head>` 结构模块从约定基目录起算的相对路径。

"head.tsx"
英文源码说明

Convention-relative suffix of the structural document-head module.

packages/router/src/config.ts:85
CONVENTION_ISLANDS_DIR常量 · 公开
@openelement/router · root

交互岛默认目录 `app/islands`,也是 `dirs.islands` 的默认值。

"app/islands"
英文源码说明

Default island directory (`app/islands`), the `dirs.islands` default.

packages/router/src/config.ts:67
CONVENTION_LAYOUT_PATH常量 · 公开
@openelement/router · root

自动注册布局的默认约定路径。

"app/layout.tsx"
英文源码说明

Convention path for the auto-registered layout.

packages/router/src/config.ts:91
CONVENTION_LAYOUT_SUFFIX常量 · 公开
@openelement/router · root

自动注册布局从约定基目录起算的相对路径。

"layout.tsx"
英文源码说明

Convention-relative suffix of the auto-registered layout.

packages/router/src/config.ts:82
CONVENTION_LAYOUT_TAG常量 · 公开
@openelement/router · root

自动注册约定布局时使用的元素标签名。

"app-layout"
英文源码说明

The tag name the convention layout is registered under.

packages/router/src/config.ts:97
CONVENTION_PACKAGE_JSON常量 · 公开
@openelement/router · root

约定中用于读取站点标题的文件,标题取自 `package.json` 的 `name` 字段。

"package.json"
英文源码说明

The site-title convention source (the package.json `name` field).

packages/router/src/config.ts:100
CONVENTION_ROUTES_DIR常量 · 公开
@openelement/router · root

路由默认目录 `app/routes`,也是 `dirs.routes` 的默认值。

"app/routes"
英文源码说明

Default route directory (`app/routes`), the `dirs.routes` default.

packages/router/src/config.ts:64
CONVENTION_STYLES_SUFFIX常量 · 公开
@openelement/router · root

设计令牌样式表从约定基目录起算的相对路径。

"styles/tokens.css"
英文源码说明

Convention-relative suffix of the design-token stylesheet.

packages/router/src/config.ts:79
CONVENTION_TOKENS_PATH常量 · 公开
@openelement/router · root

设计令牌样式表的默认约定路径。

"app/styles/tokens.css"
英文源码说明

Convention path for the design-token stylesheet.

packages/router/src/config.ts:88
conventionHeadPath函数 · 公开
@openelement/router · root

根据已经解析的 `dirs` 计算文档 `<head>` 结构模块的约定路径。

(base: string): string
英文源码说明

The structural document-head convention path for a resolved `dirs` block.

packages/router/src/config.ts:699
conventionLayoutPath函数 · 公开
@openelement/router · root

根据已经解析的 `dirs` 计算布局模块的约定路径。

(base: string): string
英文源码说明

The layout convention path for a resolved `dirs` block.

packages/router/src/config.ts:694
conventionTokensPath函数 · 公开
@openelement/router · root

根据已经解析的 `dirs` 计算设计令牌样式表的约定路径。

(base: string): string
英文源码说明

The token stylesheet convention path for a resolved `dirs` block.

packages/router/src/config.ts:689
createRequestContext函数 · 公开
@openelement/router · root

从平台请求事件构建统一的 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.

request: Request (必填); params?: Record<string, string> (可选); env?: Env (可选); platform?: unknown (可选)

packages/router/src/model.ts:45
CreateRequestContextOptions接口 · 公开
@openelement/router · root

从平台请求事件构建 `OpenElementRequestContext` 所需的输入。

CreateRequestContextOptions<Env>
英文源码说明

Inputs for building an {@linkcode OpenElementRequestContext} from a platform request event.

request: Request (必填); params?: Record<string, string> (可选); env?: Env (可选); platform?: unknown (可选)

packages/router/src/model.ts:17
defineConfig函数 · 公开
@openelement/router · root

原样返回配置对象,同时让 TypeScript 检查其结构。

(config: OpenElementUserConfig): OpenElementUserConfig
英文源码说明

`defineConfig()` — identity helper that pins the config file's shape.

renderer?: "native" | "lit" (可选) — Page renderer. Omit to keep the compiled native renderer.; dirs.routes?: string (可选) — Route directory. Defaults to `app/routes`.; dirs.islands?: string (可选) — Island directory. Defaults to `app/islands`.; dirs.components?: string (可选) — Component directory. Defaults to `app/components`.; layout?: false | { import: string; props?: Record<string, unknown>; } (可选) — Layout. `false` opts out of the `layout.tsx` convention; an object registers the named module. `tagName` is derived from the import's basename, so it is not part of the surface.; packageIslands?: string[] | "auto" | "manual" (可选) — How component packages are admitted. Omitted or `'auto'` (the default): the scan derives the set from the package element modules the app really imports, and an array adds explicit entries (explicit outranks a derived claim on a shared tag). `'manual'`: the escape hatch — derivation off, only listed packages are admitted, an imported-but-unlisted package is reported with the explicit fix.; head.title?: string (可选) — Document title; defaults to the package.json `name`.; head.description?: string (可选) — `<meta name="description">` + `og:description`.; head.lang?: string (可选) — `<html lang>`; defaults to `en`.; head.favicon?: string (可选) — Site-root-relative favicon path, emitted as `<link rel="icon">`.; head.ogImage?: string (可选) — `og:image` URL. Absolute (crawlable) or site-root-relative.; head.stylesheets?: string[] (可选) — External stylesheets linked into `<head>`.; head.scripts?: OpenElementHeadScript[] (可选) — External scripts emitted into `<head>`; inline code is not accepted here.; styles.tokens?: string (可选) — Token stylesheet path; defaults to the `styles/tokens.css` convention.; i18n?: OpenElementI18nConfig (可选) — Locale-prefixed build configuration.; viewTransition?: boolean (可选) — Client-navigation View Transitions. Boolean for now; an object form (per-transition types) is a possible future widening of this key.; tailwind?: boolean | TailwindOptions (可选) — The Tailwind entry (alpha15 S lane, opt-in): the config-file home for the same option the inline `openElement(...)` face takes. `true` enables the entry with no declared sources; an object names the style sources that compile into the document stylesheet — see `TailwindOptions` (@openelement/router/vite).; unocss?: boolean | UnocssOptions (可选) — The UnoCSS entry (alpha15 stage 2B, opt-in): the sibling of `tailwind`. Declaring it selects UnoCSS as this application's style engine; declaring both keys is a conflict and fails closed — see `UnocssOptions` (@openelement/router/vite).; speculation?: boolean (可选) — Speculation Rules emission. Boolean for now: `true` uses the framework route-derived defaults, `false` emits none. An object form (explicit prerender/prefetch lists, exclusions, eagerness) is a possible future widening of this key.; build.manifestBudget?: Record<string, number> (可选) — Advisory per-entry manifest budgets in KB, e.g. `{ islandKB: 100, totalJsKB: 300 }`.; middleware.corsOrigin?: string | string[] (可选) — CORS allowlist; omitted means localhost-only reflection (production warning).

packages/router/src/config.ts:290
defineIslandConfig函数 · 公开
@openelement/router · root

校验并返回组件配置。用它声明自定义元素的标签名、根节点、属性,以及何时在浏览器中启用交互。

(config: IslandConfig): IslandConfig
英文源码说明

Validate and register an island delivery descriptor; returns the normalized config.

ssr?: boolean (可选); dsd?: boolean (可选); hydrate?: IslandDeliveryStrategy (可选) — Delivery strategy for this island: one of the four element hydration triggers ('load' | 'idle' | 'visible' | 'only' — the element package's `HydrationStrategy`), or the router-level 'media' delivery strategy, which fetches the chunk only while the required `media` query matches.; media?: string (可选) — Media query required by the `media` delivery strategy.; styles?: readonly string[] (可选) — Authored stylesheets for a GENERATED-element (function) island: relative `.css` specifiers resolved against the island module and fed into the existing router style plan — the same style-edge registry, Vite CSS pipeline, content-addressed emitted asset and client asset manifest (`styles`) the class lane's `static styles` imports ride. One style channel, no second pipeline. A class island does not…; root?: "light" | "shadow" | "closed" (可选) — The root family this island is delivered in: `'shadow'` (the compiled default, DSD markup in a shadow root) or `'light'` (the component's children live in the document tree, which is what lets a light island use utility classes without a shadow-boundary workaround). Declarative only: `@element(tag, { root: 'light' })` on the component class is the single source of truth, and the build fails close…; delegatesFocus?: boolean (可选) — Delegate focus to this island's shadow root (`shadowrootdelegatesfocus` in the DSD template, `attachShadow({ delegatesFocus: true })` for a client-created root): focusing the host forwards focus to its first focusable descendant. Only valid with `root: 'shadow'` — a light root has no shadow boundary to delegate through, so `delegatesFocus: true` without `root: 'shadow'` is refused instead of sile…; formAssociated?: boolean (可选) — Associate the generated element host with its surrounding native form (`static formAssociated = true` + `ElementInternals`). The form value is the declared string property named `value`; optional boolean `required` and `disabled` properties enable the required/valueMissing mirror and the fieldset disabled state. There is deliberately no separate `formValue` field: one declared property is the sou…; properties?: Readonly<Record<string, IslandPropertyConfig>> (可选) — The island element's declared **primitive** properties, keyed by the root component's typed props member names. Every typed member must have an entry and every entry must name a typed member (the compiler lane refuses a mismatch); the entry supplies the platform facts a type cannot express. Only `string`, `number` and `boolean` members are admitted. Array, object and `trustedHtml` conversion, cus…; tags?: readonly string[] (可选) — Custom-element tags delivered by this one capability module.; tagNames?: readonly string[] (可选) — Alias accepted by generated artifact producers.; exportNames?: Readonly<Record<string, string>> (可选) — Named constructor exports keyed by delivered custom-element tag.; tag?: string (可选) — The generated element's custom-element tag, declared EXPLICITLY. An island's tag is its file path's (`pathToTagName`) and a package component's is its manifest declaration. A page-local component under a directory neither convention owns (e.g. `app/site-ui/`) has no tag source at all, so the build's generated-element site resolver declines it and the module never compiles. Declaring the tag here …

packages/router/src/authoring.ts:1121
definePage函数 · 公开
@openelement/router · root

为服务端页面函数添加描述符。把函数传给 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
fail函数 · 公开
@openelement/router · root

以 4xx 状态码和带类型的数据返回结构化的操作失败结果。

<Data>(status: number, data: Data): OpenElementActionFailure<Data>
英文源码说明

Return a structured action failure with an HTTP status and typed data payload.

toString: (radix?: number) => string (必填) — Returns a string representation of an object.; toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; valueOf: () => number (必填) — Returns the primitive value of the specified object.; toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.

packages/router/src/authoring.ts:192
FunctionPageComponent类型 · 公开
@openelement/router · root

`definePage()` 接收函数组件时生成的路由模块默认导出类型。

FunctionPageComponent<Data, Params>
英文源码说明

The route-module default export shape a definePage() component call produces.

packages/router/src/authoring.ts:426
isActionFailure函数 · 公开
@openelement/router · root

判断值是否为 `OpenElementActionFailure`,也接受来自其他执行环境且结构匹配的对象。

(error: unknown): error is OpenElementActionFailure
英文源码说明

Type guard for {@linkcode OpenElementActionFailure}, including its duck-typed cross-realm shape.

packages/router/src/authoring.ts:197
IslandConfig接口 · 公开
@openelement/router · root

单个交互岛的加载配置,决定是否参与 SSR 或 DSD 以及采用何种水合策略。

IslandConfig
英文源码说明

Per-island delivery configuration (SSR/DSD participation and hydration strategy).

ssr?: boolean (可选); dsd?: boolean (可选); hydrate?: IslandDeliveryStrategy (可选) — Delivery strategy for this island: one of the four element hydration triggers ('load' | 'idle' | 'visible' | 'only' — the element package's `HydrationStrategy`), or the router-level 'media' delivery strategy, which fetches the chunk only while the required `media` query matches.; media?: string (可选) — Media query required by the `media` delivery strategy.; styles?: readonly string[] (可选) — Authored stylesheets for a GENERATED-element (function) island: relative `.css` specifiers resolved against the island module and fed into the existing router style plan — the same style-edge registry, Vite CSS pipeline, content-addressed emitted asset and client asset manifest (`styles`) the class lane's `static styles` imports ride. One style channel, no second pipeline. A class island does not…; root?: "light" | "shadow" | "closed" (可选) — The root family this island is delivered in: `'shadow'` (the compiled default, DSD markup in a shadow root) or `'light'` (the component's children live in the document tree, which is what lets a light island use utility classes without a shadow-boundary workaround). Declarative only: `@element(tag, { root: 'light' })` on the component class is the single source of truth, and the build fails close…; delegatesFocus?: boolean (可选) — Delegate focus to this island's shadow root (`shadowrootdelegatesfocus` in the DSD template, `attachShadow({ delegatesFocus: true })` for a client-created root): focusing the host forwards focus to its first focusable descendant. Only valid with `root: 'shadow'` — a light root has no shadow boundary to delegate through, so `delegatesFocus: true` without `root: 'shadow'` is refused instead of sile…; formAssociated?: boolean (可选) — Associate the generated element host with its surrounding native form (`static formAssociated = true` + `ElementInternals`). The form value is the declared string property named `value`; optional boolean `required` and `disabled` properties enable the required/valueMissing mirror and the fieldset disabled state. There is deliberately no separate `formValue` field: one declared property is the sou…; properties?: Readonly<Record<string, IslandPropertyConfig>> (可选) — The island element's declared **primitive** properties, keyed by the root component's typed props member names. Every typed member must have an entry and every entry must name a typed member (the compiler lane refuses a mismatch); the entry supplies the platform facts a type cannot express. Only `string`, `number` and `boolean` members are admitted. Array, object and `trustedHtml` conversion, cus…; tags?: readonly string[] (可选) — Custom-element tags delivered by this one capability module.; tagNames?: readonly string[] (可选) — Alias accepted by generated artifact producers.; exportNames?: Readonly<Record<string, string>> (可选) — Named constructor exports keyed by delivered custom-element tag.; tag?: string (可选) — The generated element's custom-element tag, declared EXPLICITLY. An island's tag is its file path's (`pathToTagName`) and a package component's is its manifest declaration. A page-local component under a directory neither convention owns (e.g. `app/site-ui/`) has no tag source at all, so the build's generated-element site resolver declines it and the module never compiles. Declaring the tag here …

packages/router/src/authoring.ts:759
IslandDeliveryStrategy类型 · 公开
@openelement/router · root

由适配器决定的浏览器交付策略,可依据媒体查询决定是否交付。

IslandDeliveryStrategy
英文源码说明

Adapter-owned browser delivery strategy, including media-query admission.

packages/protocol/src/ssg.ts:31
IslandPropertyConfig接口 · 公开
@openelement/router · root

补充交互岛的属性类型本身无法表达的平台配置。

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.

reflect?: boolean (可选) — Reflect property writes back to the attribute. Requires an attribute channel: `reflect: true` with `attribute: false` is refused.; attribute?: string | false (可选) — Attribute name. Omitted derives `camelToKebab(propertyName)`; `false` declares a property with no attribute channel (property-only). A string is lowercased and must be a safe HTML attribute name — the shell applies the same normalization.; default?: string | number | boolean | readonly unknown[] | Readonly<Record<string, unknown>> | { readonly html: string; } (可选) — Declared initial value, used before any property write. A `string`/`number`/`boolean` literal matching a primitive typed member may be omitted (the shell applies the type zero value). A property-only array/object member requires an explicit recursively literal graph (`[]`, `{…}`, nested values); `trustedHtml` requires the canonical `trustedHtml('…')` value. The build validates the shape and prove…

packages/router/src/authoring.ts:727
isOpenElementNotFound函数 · 公开
@openelement/router · root

判断值是否为 `OpenElementNotFound`,也接受来自其他执行环境且结构匹配的对象。

(error: unknown): error is OpenElementNotFound
英文源码说明

Type guard for {@linkcode OpenElementNotFound}, including its duck-typed cross-realm shape.

packages/router/src/authoring.ts:156
isOpenElementRedirect函数 · 公开
@openelement/router · root

判断值是否为 `OpenElementRedirect`,也接受来自其他执行环境且结构匹配的对象。

(error: unknown): error is OpenElementRedirect
英文源码说明

Type guard for {@linkcode OpenElementRedirect}, including its duck-typed cross-realm shape.

packages/router/src/authoring.ts:140
JsonValue类型 · 公开
@openelement/router · root

结构化数据通道接受的只读 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类型 · 公开
@openelement/router · root

为页面路由获取数据的 loader。

Loader<T, Env, Platform, Route>
英文源码说明

Route loader: fetches data for a page route.

packages/protocol/src/data.ts:56
LoaderContext接口 · 公开
@openelement/router · root

传给动态路由 loader 的请求上下文。

LoaderContext<Env, Platform, Route>
英文源码说明

Context passed to a request-time ('dynamic') route loader.

request: Request (必填); params: Record<string, string> (必填); env: Env (必填); platform: Platform (必填); responseHeaders: Headers (必填) — Mutable response-only channel merged into the framework response.; route: Route (必填)

packages/protocol/src/data.ts:40
notFound函数 · 公开
@openelement/router · root

抛出 `OpenElementNotFound`,以渲染当前路由的 404 页面。

(message?: string): never
英文源码说明

Throw an {@linkcode OpenElementNotFound} to render the 404 path.

packages/router/src/authoring.ts:135
OPEN_ELEMENT_BUILD_KEYS常量 · 公开
@openelement/router · root

列出配置项 `build` 接受的键。

readonly string[]
英文源码说明

Accepted keys inside `build`.

packages/router/src/config.ts:364
OPEN_ELEMENT_CONFIG_FILE常量 · 公开
@openelement/router · root

项目根目录使用的标准配置文件名 `openelement.config.ts`。

"openelement.config.ts"
英文源码说明

Canonical config-file name, resolved in the project root.

packages/router/src/config.ts:61
OPEN_ELEMENT_CONFIG_KEYS常量 · 公开
@openelement/router · root

顶层配置允许的完整键集合,用于拒绝未知键,并在报错时列出可用键。

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
OPEN_ELEMENT_DIRS_KEYS常量 · 公开
@openelement/router · root

`dirs` 中允许使用的键。

readonly string[]
英文源码说明

Accepted keys inside `dirs`.

packages/router/src/config.ts:352
OPEN_ELEMENT_HEAD_KEYS常量 · 公开
@openelement/router · root

`head` 中允许使用的键。

readonly string[]
英文源码说明

Accepted keys inside `head`.

packages/router/src/config.ts:324
OPEN_ELEMENT_HEAD_SCRIPT_KEYS常量 · 公开
@openelement/router · root

`head.scripts` 中单条记录允许使用的键。

readonly string[]
英文源码说明

Keys of one `head.scripts` entry.

packages/router/src/config.ts:335
OPEN_ELEMENT_HEAD_STRING_KEYS常量 · 公开
@openelement/router · root

`head` 中以普通字符串为值的键。

readonly string[]
英文源码说明

Head keys that carry a plain string value.

packages/router/src/config.ts:343
OPEN_ELEMENT_I18N_KEYS常量 · 公开
@openelement/router · root

`i18n` 中允许使用的键。

readonly string[]
英文源码说明

Accepted keys inside `i18n`.

packages/router/src/config.ts:361
OPEN_ELEMENT_LAYOUT_KEYS常量 · 公开
@openelement/router · root

`layout` 中允许使用的键。

readonly string[]
英文源码说明

Accepted keys inside `layout`.

packages/router/src/config.ts:355
OPEN_ELEMENT_MIDDLEWARE_KEYS常量 · 公开
@openelement/router · root

`middleware` 中允许使用的键。

readonly string[]
英文源码说明

Accepted keys inside `middleware`.

packages/router/src/config.ts:367
OPEN_ELEMENT_STYLES_KEYS常量 · 公开
@openelement/router · root

`styles` 中允许使用的键。

readonly string[]
英文源码说明

Accepted keys inside `styles`.

packages/router/src/config.ts:358
OpenElementActionFailure类 · 公开
@openelement/router · root
class 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接口 · 公开
@openelement/router · root

控制构建产物的选项。

OpenElementBuildConfig
英文源码说明

Build-output switches.

manifestBudget?: Record<string, number> (可选) — Advisory per-entry manifest budgets in KB, e.g. `{ islandKB: 100, totalJsKB: 300 }`.

packages/router/src/config.ts:156
OpenElementDirsConfig接口 · 公开
@openelement/router · root

设置扫描器读取的源码根目录,具体目录见 `dirs` 配置说明。

OpenElementDirsConfig
英文源码说明

Source roots; see the `dirs` section of the module doc comment.

routes?: string (可选) — Route directory. Defaults to `app/routes`.; islands?: string (可选) — Island directory. Defaults to `app/islands`.; components?: string (可选) — Component directory. Defaults to `app/components`.

packages/router/src/config.ts:146
OpenElementFunctionPageDescriptor接口 · 公开
@openelement/router · root
OpenElementFunctionPageDescriptor<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.

kind: "function-page" (必填); route.id?: string (可选); route.params?: readonly string[] (可选); route.layout?: string | false (可选) — Named layout selection (decision 0123): a string picks one of the `openElement({ layouts })` entries by name (unknown names fall back to the default layout); `false` renders the page without any layout. Unset means the default shell.; head?: PageHead | PageHeadResolver<Data, Params> (可选); renderIntent: NormalizedPageRenderIntent (必填); props?: PagePropsProjector<Data, Params> (可选); error?: PageErrorProjector<Data, Params> (可选); render: ServerPageComponent (必填)

packages/router/src/authoring.ts:412
OpenElementHeadConfig接口 · 公开
@openelement/router · root

声明结构化的文档头部数据,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.

title?: string (可选) — Document title; defaults to the package.json `name`.; description?: string (可选) — `<meta name="description">` + `og:description`.; lang?: string (可选) — `<html lang>`; defaults to `en`.; favicon?: string (可选) — Site-root-relative favicon path, emitted as `<link rel="icon">`.; ogImage?: string (可选) — `og:image` URL. Absolute (crawlable) or site-root-relative.; stylesheets?: string[] (可选) — External stylesheets linked into `<head>`.; scripts?: OpenElementHeadScript[] (可选) — External scripts emitted into `<head>`; inline code is not accepted here.

packages/router/src/config.ts:120
OpenElementHeadScript接口 · 公开
@openelement/router · root

`head.scripts` 接受的一条结构化 `<script src>` 描述记录。

OpenElementHeadScript
英文源码说明

One structured `<script src>` descriptor accepted by `head.scripts`.

src: string (必填) — Script URL: absolute, or site-root relative (`/theme-init.js`).; defer?: boolean (可选) — Emit `defer`; leave unset for a parser-blocking external script.; crossOrigin?: string (可选) — `crossorigin` attribute value, e.g. `anonymous`.; integrity?: string (可选) — Subresource-integrity digest for the script.

packages/router/src/config.ts:103
OpenElementI18nConfig接口 · 公开
@openelement/router · root

配置构建的语言及其路由前缀。

OpenElementI18nConfig
英文源码说明

Locale configuration for a locale-prefixed build.

locales: string[] (必填) — Every locale the build emits, default locale included.; defaultLocale: string (必填) — The locale served at the unprefixed root.

packages/router/src/config.ts:138
OpenElementNotFound类 · 公开
@openelement/router · root

由 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
OpenElementPageDescriptor接口 · 公开
@openelement/router · root

构建与渲染流水线通过 `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.

kind: "page" (必填); route.id?: string (可选); route.params?: readonly string[] (可选); route.layout?: string | false (可选) — Named layout selection (decision 0123): a string picks one of the `openElement({ layouts })` entries by name (unknown names fall back to the default layout); `false` renders the page without any layout. Unset means the default shell.; head?: PageHead | PageHeadResolver<Data, Params> (可选); renderIntent: NormalizedPageRenderIntent (必填); props?: PagePropsProjector<Data, Params> (可选); error?: PageErrorProjector<Data, Params> (可选)

packages/router/src/authoring.ts:375
OpenElementRedirect类 · 公开
@openelement/router · root

由 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接口 · 公开
@openelement/router · root

应用请求适配器共用的独立于宿主的请求上下文。

OpenElementRequestContext<Env>
英文源码说明

Host-agnostic request context shared by App request adapters.

request: Request (必填); url: URL (必填); path: string (必填); method: string (必填); params: Record<string, string> (必填); searchParams: URLSearchParams (必填); env?: Env (可选); platform?: unknown (可选)

packages/router/src/model.ts:3
OpenElementUserConfig接口 · 公开
@openelement/router · root

`openelement.config.ts` 接受的覆盖选项。遇到未知键时拒绝该配置。

OpenElementUserConfig
英文源码说明

Overrides accepted by an `openelement.config.ts` file (unknown keys fail closed).

renderer?: "native" | "lit" (可选) — Page renderer. Omit to keep the compiled native renderer.; dirs.routes?: string (可选) — Route directory. Defaults to `app/routes`.; dirs.islands?: string (可选) — Island directory. Defaults to `app/islands`.; dirs.components?: string (可选) — Component directory. Defaults to `app/components`.; layout?: false | { import: string; props?: Record<string, unknown>; } (可选) — Layout. `false` opts out of the `layout.tsx` convention; an object registers the named module. `tagName` is derived from the import's basename, so it is not part of the surface.; packageIslands?: string[] | "auto" | "manual" (可选) — How component packages are admitted. Omitted or `'auto'` (the default): the scan derives the set from the package element modules the app really imports, and an array adds explicit entries (explicit outranks a derived claim on a shared tag). `'manual'`: the escape hatch — derivation off, only listed packages are admitted, an imported-but-unlisted package is reported with the explicit fix.; head.title?: string (可选) — Document title; defaults to the package.json `name`.; head.description?: string (可选) — `<meta name="description">` + `og:description`.; head.lang?: string (可选) — `<html lang>`; defaults to `en`.; head.favicon?: string (可选) — Site-root-relative favicon path, emitted as `<link rel="icon">`.; head.ogImage?: string (可选) — `og:image` URL. Absolute (crawlable) or site-root-relative.; head.stylesheets?: string[] (可选) — External stylesheets linked into `<head>`.; head.scripts?: OpenElementHeadScript[] (可选) — External scripts emitted into `<head>`; inline code is not accepted here.; styles.tokens?: string (可选) — Token stylesheet path; defaults to the `styles/tokens.css` convention.; i18n?: OpenElementI18nConfig (可选) — Locale-prefixed build configuration.; viewTransition?: boolean (可选) — Client-navigation View Transitions. Boolean for now; an object form (per-transition types) is a possible future widening of this key.; tailwind?: boolean | TailwindOptions (可选) — The Tailwind entry (alpha15 S lane, opt-in): the config-file home for the same option the inline `openElement(...)` face takes. `true` enables the entry with no declared sources; an object names the style sources that compile into the document stylesheet — see `TailwindOptions` (@openelement/router/vite).; unocss?: boolean | UnocssOptions (可选) — The UnoCSS entry (alpha15 stage 2B, opt-in): the sibling of `tailwind`. Declaring it selects UnoCSS as this application's style engine; declaring both keys is a conflict and fails closed — see `UnocssOptions` (@openelement/router/vite).; speculation?: boolean (可选) — Speculation Rules emission. Boolean for now: `true` uses the framework route-derived defaults, `false` emits none. An object form (explicit prerender/prefetch lists, exclusions, eagerness) is a possible future widening of this key.; build.manifestBudget?: Record<string, number> (可选) — Advisory per-entry manifest budgets in KB, e.g. `{ islandKB: 100, totalJsKB: 300 }`.; middleware.corsOrigin?: string | string[] (可选) — CORS allowlist; omitted means localhost-only reflection (production warning).

packages/router/src/config.ts:219
PageComponentConstructor类型 · 公开
@openelement/router · root

在静态字段上携带页面描述符的已编译元素类。

PageComponentConstructor<Data, Params>
英文源码说明

A compiled element class carrying the page descriptor static.

packages/router/src/authoring.ts:388
PageErrorProjector类型 · 公开
@openelement/router · root

将捕获的渲染、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
PageHead接口 · 公开
@openelement/router · root

路由描述符声明的页面 `<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.

title?: string (可选); description?: string (可选); meta?: Record<string, string | number | boolean>[] (可选); canonical?: string (可选) — Canonical URL of this page (#1326), resolved into <link rel="canonical"> by the shared Document seam.; alternates?: { href: string; hreflang?: string; }[] (可选) — Locale alternates of this page (#1326), resolved into <link rel="alternate" hreflang="..."> entries in author order.; structuredData?: StructuredDataEntry[] (可选) — Structured data (JSON-LD) for this page, resolved into one `<script type="application/ld+json">` element per document in <head>. This is a DATA channel, not a markup channel: entries must be JSON data, and resolvePageDocument fails closed on anything JSON cannot represent (functions, undefined, non-finite numbers, non-plain objects, cycles). It is deliberately NOT reachable through `dangerouslyHe…; dangerouslyHeadFragments?: string[] (可选)

packages/router/src/authoring.ts:266
PageHeadResolver类型 · 公开
@openelement/router · root

根据当前请求的上下文解析页面 `<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
PagePropsContext接口 · 公开
@openelement/router · root

传入页面 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).

data: Data (必填); actionData: unknown (必填) — The 422 re-render payload of a RETURNED action failure (`fail(status, data)`): the classified `failure.data`, verbatim. It is `undefined` on every other render — a successful action answers 303 (PRG), and the projector runs again only on the redirected GET, where success data arrives through the loader's re-run (read the PRG target's query state there). There is no success envelope on this channe…; params: Params (必填); request?: Request (可选); locale?: string (可选) — Resolved application locale for this render, when i18n is configured.; route.path?: string (可选); route.filePath?: string (可选); meta: PageMeta (必填)

packages/router/src/authoring.ts:302
PagePropsProjector类型 · 公开
@openelement/router · root

将请求级上下文映射为编译页面的属性。

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:331
PROBLEM_JSON_MEDIA_TYPE常量 · 公开
@openelement/router · root

RFC 9457 Problem Details 错误响应使用的媒体类型。

"application/problem+json"
英文源码说明

Media type of the RFC 9457 action error channel (#863).

packages/protocol/src/data.ts:117
ProblemDetails接口 · 公开
@openelement/router · root

表单 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.

type: string (必填) — URI reference identifying the problem type; 'about:blank' when none applies.; title: string (必填) — Short human-readable summary (the HTTP reason phrase for 'about:blank').; status.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; status.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; status.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; status.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; status.valueOf: () => number (必填) — Returns the primitive value of the specified object.; status.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.; detail?: string (可选) — Human-readable explanation specific to this occurrence.

packages/protocol/src/data.ts:105
projectPageProps函数 · 公开
@openelement/router · root

页面没有自定义映射时,先取路由参数,再合入 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).

params?: Record<string, string> (可选); data?: unknown (可选)

packages/router/src/authoring.ts:684
redirect函数 · 公开
@openelement/router · root

为 `location` 抛出 `OpenElementRedirect`,状态码须为支持的 3xx 重定向码。

(location: string | URL, status?: number): never
英文源码说明

Throw an {@linkcode OpenElementRedirect} for `location` (status must be a real 3xx).

hash: string (必填) — The **`hash`** property of the URL interface is a string containing a "#" followed by the fragment identifier of the URL. If the URL does not have a fragment identifier, this property contains an empty string, "". [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hash); host: string (必填) — The **`host`** property of the URL interface is a string containing the host, which is the hostname, and then, if the port of the URL is nonempty, a ":", followed by the port of the URL. If the URL does not have a hostname, this property contains an empty string, "". [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/host); hostname: string (必填) — The **`hostname`** property of the URL interface is a string containing either the domain name or IP address of the URL. If the URL does not have a hostname, this property contains an empty string, "". IPv4 and IPv6 addresses are normalized, such as stripping leading zeros, and domain names are converted to IDN. [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hostname); href: string (必填) — The **`href`** property of the URL interface is a string containing the whole URL. [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/href); toString: () => string (必填); origin: string (必填) — The **`origin`** read-only property of the URL interface returns a string containing the Unicode serialization of the origin of the represented URL. [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/origin); password: string (必填) — The **`password`** property of the URL interface is a string containing the password component of the URL. If the URL does not have a password, this property contains an empty string, "". [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/password); pathname: string (必填) — The **`pathname`** property of the URL interface represents a location in a hierarchical structure. It is a string constructed from a list of path segments, each of which is prefixed by a / character. [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/pathname); port: string (必填) — The **`port`** property of the URL interface is a string containing the port number of the URL. If the port is the default for the protocol (80 for ws: and http:, 443 for wss: and https:, and 21 for ftp:), this property contains an empty string, "". [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/port); protocol: string (必填) — The **`protocol`** property of the URL interface is a string containing the protocol or scheme of the URL, including the final ":". [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/protocol); search: string (必填) — The **`search`** property of the URL interface is a search string, also called a query string, that is a string containing a "?" followed by the parameters of the URL. If the URL does not have a search query, this property contains an empty string, "". [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/search); searchParams: URLSearchParams (必填) — The **`searchParams`** read-only property of the URL interface returns a URLSearchParams object allowing access to the GET decoded query arguments contained in the URL. [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/searchParams); username: string (必填) — The **`username`** property of the URL interface is a string containing the username component of the URL. If the URL does not have a username, this property contains an empty string, "". [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/username); toJSON: () => string (必填) — The **`toJSON()`** method of the URL interface returns a string containing a serialized version of the URL, although in practice it seems to have the same effect as URL.toString(). [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/toJSON)

packages/router/src/authoring.ts:130
resolveDirs函数 · 公开
@openelement/router · root

为 `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.

routes?: string (可选) — Route directory. Defaults to `app/routes`.; islands?: string (可选) — Island directory. Defaults to `app/islands`.; components?: string (可选) — Component directory. Defaults to `app/components`.

packages/router/src/config.ts:653
ServerPageComponent类型 · 公开
@openelement/router · root
ServerPageComponent
英文源码说明

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接口 · 公开
@openelement/router · root

请求时渲染和静态站点生成共用的服务端路由上下文。

ServerRouteContext<Env, Platform, Route>
英文源码说明

Canonical request-time/SSG server route context.

request: Request (必填); params: Record<string, string> (必填); env: Env (必填); platform: Platform (必填); responseHeaders: Headers (必填) — Mutable response-only channel merged into the framework response.; route: Route (必填)

packages/protocol/src/data.ts:25
ServerRouteMetadata接口 · 公开
@openelement/router · root

动态路由 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().

path: string (必填); filePath: string (必填)

packages/protocol/src/data.ts:19
StructuredDataEntry类型 · 公开
@openelement/router · root

一份结构化数据文档,即 `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
runBuildCli函数 · 公开
@openelement/router · ./cli/build

执行生产构建,并以构建结果决定进程退出状态。

(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
runServeCli函数 · 公开
@openelement/router · ./cli/start
(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
ClientScriptDescriptor接口 · 公开
@openelement/router · ./document

描述解析后的文档需要在 `</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).

src?: string (可选) — External script URL (attribute-escaped at serialization).; code?: string (可选) — Inline script body. Trusted framework input, never user content.; type?: string (可选) — Script type attribute, e.g. 'module'; omitted means a classic script.

packages/router/src/loading/module/nonce.ts:31
PageHeadAlternate接口 · 公开
@openelement/router · ./document

一条 `<link rel="alternate">` 记录,通常带有 `hreflang`。

PageHeadAlternate
英文源码说明

One <link rel="alternate"> record, typically carrying an hreflang.

href: string (必填); hreflang?: string (可选)

packages/router/src/document.ts:41
ResolvedDocument接口 · 公开
@openelement/router · ./document
ResolvedDocument
英文源码说明

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.

title?: string (可选); description?: string (可选); meta?: Record<string, string | number | boolean>[] (可选); structuredData?: StructuredDataEntry[] (可选) — Structured data (JSON-LD), one serialized `<script type= "application/ld+json">` element per entry. Normalized here to plain JSON data so the serializer only has to escape, never interpret.; dangerouslyHeadFragments?: string[] (可选); clientScripts?: ClientScriptDescriptor[] (可选) — The framework client scripts this document embeds before `</body>` — structured descriptors rendered by the serializer at document time (#1471), never by post-build HTML surgery. The serializer attaches the per-request CSP nonce; SSG output carries none.; lang?: string (可选) — Document language: the resolved application locale for this render, and ONLY that. It stays undefined on a single-locale site — the seam never defaults it to `'en'` — so the configured document `head.lang` remains the fallback the serializer applies. A project that declared i18n always resolves a locale, and that locale overrides the configured value (the document-language decision record).; canonical?: string (可选); alternates?: PageHeadAlternate[] (可选); links: ResolvedDocumentLink[] (必填) — Canonical first, then alternates in author order — deterministic.

packages/router/src/document.ts:59
resolvePageDocument函数 · 公开
@openelement/router · ./document

将静态 `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.

title?: string (可选); description?: string (可选); meta?: Record<string, string | number | boolean>[] (可选); canonical?: string (可选) — Canonical URL of this page (#1326), resolved into <link rel="canonical"> by the shared Document seam.; alternates?: { href: string; hreflang?: string; }[] (可选) — Locale alternates of this page (#1326), resolved into <link rel="alternate" hreflang="..."> entries in author order.; structuredData?: StructuredDataEntry[] (可选) — Structured data (JSON-LD) for this page, resolved into one `<script type="application/ld+json">` element per document in <head>. This is a DATA channel, not a markup channel: entries must be JSON data, and resolvePageDocument fails closed on anything JSON cannot represent (functions, undefined, non-finite numbers, non-plain objects, cycles). It is deliberately NOT reachable through `dangerouslyHe…; dangerouslyHeadFragments?: string[] (可选)

packages/router/src/document.ts:196
createHonoAdapter函数 · 公开
@openelement/router · ./hono
(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
WinterCgHandler类型 · 公开
@openelement/router · ./hono

生成入口导出的 WinterCG 请求处理器。

WinterCgHandler
英文源码说明

The WinterCG request handler the generated entries export.

packages/router/src/hono-adapter.ts:30
createRouteMiddleware函数 · 公开
@openelement/router · ./http

创建挂在宿主中间件和路由之后的 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:48
HttpHandler类型 · 公开
@openelement/router · ./http
HttpHandler
英文源码说明

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
HttpRouteContext接口 · 公开
@openelement/router · ./http

传给每个 `HttpHandler` 的路由级请求上下文。

HttpRouteContext
英文源码说明

Route-scoped request context handed to every {@link HttpHandler}.

params: Record<string, string> (必填); searchParams: URLSearchParams (必填); url: URL (必填)

packages/router/src/http.ts:5
HttpRouteRecord接口 · 公开
@openelement/router · ./http
HttpRouteRecord
英文源码说明

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.

handlers: Readonly<Record<string, HttpHandler | readonly HttpHandler[]>> (必填); path: string (必填); id?: string (可选); pattern.protocol?: string (可选); pattern.username?: string (可选); pattern.password?: string (可选); pattern.hostname?: string (可选); pattern.port?: string (可选); pattern.search?: string (可选); pattern.hash?: string (可选); pattern.baseURL?: string (可选)

packages/router/src/http.ts:27
createOpenElementNitroHandler函数 · 公开
@openelement/router · ./nitro-mount

在 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.

handler: OpenElementRequestHandler<Env> (必填); env?: Env (可选); platform?: unknown (可选); onBeforeRequestContext?: ((context: OpenElementRequestContext<Env>) => void | Promise<void>) (可选) — Observes the normalized OpenElement request context before the application handler runs. Route params are empty here unless the host supplies them on `event.context.params` before dispatch.

packages/router/src/nitro-mount.ts:56
NitroRequestEvent接口 · 公开
@openelement/router · ./nitro-mount

Nitro 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.

req: Request (必填); context.params?: Record<string, string> (可选); env?: Env (可选); platform?: unknown (可选)

packages/router/src/nitro-mount.ts:12
OpenElementNitroMountOptions接口 · 公开
@openelement/router · ./nitro-mount

在 Nitro 或 Node 服务上挂载 OpenElement 请求处理器的选项。

OpenElementNitroMountOptions<Env>
英文源码说明

Options for mounting an OpenElement request handler under a Nitro/Node server.

handler: OpenElementRequestHandler<Env> (必填); env?: Env (可选); platform?: unknown (可选); onBeforeRequestContext?: ((context: OpenElementRequestContext<Env>) => void | Promise<void>) (可选) — Observes the normalized OpenElement request context before the application handler runs. Route params are empty here unless the host supplies them on `event.context.params` before dispatch.

packages/router/src/nitro-mount.ts:20
normalizeRoutePatternForURLPattern函数 · 公开
@openelement/router · ./router

将框架采用的 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:2
RouteMatch接口 · 公开
@openelement/router · ./router
RouteMatch<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.

route: T (必填); id: string (必填); params: Record<string, string> (必填); searchParams: URLSearchParams (必填); patternResult: RoutePatternResult (必填)

packages/router/src/internal/router/route-table.ts:67
RouteRecord接口 · 公开
@openelement/router · ./router
RouteRecord
英文源码说明

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`.

path: string (必填); id?: string (可选); pattern.protocol?: string (可选); pattern.username?: string (可选); pattern.password?: string (可选); pattern.hostname?: string (可选); pattern.port?: string (可选); pattern.search?: string (可选); pattern.hash?: string (可选); pattern.baseURL?: string (可选); methods?: readonly string[] (可选)

packages/router/src/internal/router/route-table.ts:54
RouteResolution类型 · 公开
@openelement/router · ./router
RouteResolution<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:80
RouteTable类 · 公开
@openelement/router · ./router
class 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
RouteTableOptions接口 · 公开
@openelement/router · ./router

配置所有路由的 URL 前缀,以及匹配时是否区分末尾斜杠。

RouteTableOptions
英文源码说明

Construction options: a URL prefix every route is mounted under, and whether a trailing slash is significant.

basePath?: string (可选); trailingSlash?: "strict" | "ignore" (可选)

packages/router/src/internal/router/route-table.ts:86
CompiledRouteMatcher类型 · 公开
@openelement/router · ./router/client

客户端路由表编译后的匹配接口,提供匹配、解析和候选数。

CompiledRouteMatcher
英文源码说明

The matcher surface a client route list compiles to: matching, resolution and candidate count.

match: (input: string | URL, search?: string) => RouteMatch<RouteConfig> | null (必填); resolve: (input: string | URL, search?: string, method?: string) => RouteResolution<RouteConfig> (必填); candidateCount: (input: string | URL) => number (必填)

packages/router/src/internal/router/client-router.ts:82
compileRouteMatcher函数 · 公开
@openelement/router · ./router/client

将客户端路由列表编译为 `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
createRouter函数 · 公开
@openelement/router · ./router/client
(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`.

mode: RouterMode (必填); routes: RouteConfig[] (必填); onChange?: (() => void | Promise<void>) (可选) — Called after navigation or browser history/hash changes update the current match.; onPending?: (() => void) (可选) — Invalidate pending execution as soon as a newer navigation owns intent.; viewTransitions?: boolean (可选) — Opt in to wrapping the render step of every navigation in document.startViewTransition when the platform offers it (the animation itself is user CSS via ::view-transition-* — the framework ships zero animation code). Default off, NAMED DEVIATION from #1561's wrap-by-default ruling — verified cross-engine platform behavior (2026-10-08, Chromium 147 / Firefox Nightly / WebKit 26.4, deterministic th…

packages/router/src/internal/router/client-router.ts:133
matchRoute函数 · 公开
@openelement/router · ./router/client

通过统一的 `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:98
RouteConfig接口 · 公开
@openelement/router · ./router/client
RouteConfig
英文源码说明

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.

tagName: string (必填) — Custom element tag to instantiate directly in SPA mode.; guard?: (() => Promise<boolean | string>) (可选); path: string (必填); id?: string (可选); pattern.protocol?: string (可选); pattern.username?: string (可选); pattern.password?: string (可选); pattern.hostname?: string (可选); pattern.port?: string (可选); pattern.search?: string (可选); pattern.hash?: string (可选); pattern.baseURL?: string (可选); methods?: readonly string[] (可选)

packages/router/src/internal/router/client-router.ts:29
RouterInstance接口 · 公开
@openelement/router · ./router/client
RouterInstance
英文源码说明

A live client router: the navigation entry points, the current match (`currentPath`/`currentRoute`/`params`/`searchParams`), and `dispose()` to release its listeners.

navigate: (path: string) => Promise<void> (必填); replace: (path: string) => Promise<void> (必填); dispose: () => void (必填); currentPath: string (必填); currentRoute: RouteConfig | null (必填); params: Record<string, string> (必填); searchParams: URLSearchParams (必填)

packages/router/src/internal/router/client-router.ts:69
RouterMode类型 · 公开
@openelement/router · ./router/client

导航策略,可使用 `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_FETCH_HEADER常量 · 公开
@openelement/router · ./server-runtime

选择表单 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
actionErrorResponse函数 · 公开
@openelement/router · ./server-runtime
(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.

req: RequestScopeRequest (必填); headers: Headers (必填) — The response-header channel. Headers the handler or the built-in middleware write before a response exists (`Cache-Control`, `Vary`, `X-Request-Id`, the security set) land here and merge into every response the scope builds. Stream routes hand the handler a separate committed stream channel; the scope keeps supplying the framework set.; env: Record<string, unknown> (必填) — The runtime env binding (`fetch(request, env)`).; executionCtx: unknown (必填) — The host execution context; throws when the host passed none (call sites guard).; header: (name: string, value: string, options?: { append?: boolean; }) => void (必填) — Writes one response header on the channel (set by default, append opt-in).; get: (key: string) => unknown (必填) — Reads one typed variable (e.g. `cspNonce`).; set: (key: string, value: unknown) => void (必填) — Writes one typed variable.; json: (object: unknown, status?: number, headers?: Record<string, string>) => Response (必填) — `application/json` response starting from the channel headers.; text: (text: string, status?: number, headers?: Record<string, string>) => Response (必填) — `text/plain; charset=UTF-8` response starting from the channel headers.; html: (html: string, status?: number, headers?: Record<string, string>) => Response (必填) — `text/html; charset=UTF-8` response starting from the channel headers.; redirect: (location: string, status?: number) => Response (必填) — Redirect response (`Location` + status, default 302).; body: (data: BodyInit | null, status?: number, headers?: Record<string, string>) => Response (必填) — Raw-body response starting from the channel headers.

packages/router/src/vite/internal/server-runtime/action-runtime.ts:379
ActionExecution接口 · 公开
@openelement/router · ./server-runtime

返回给生成处理器的 action 执行结果,可包含直接响应或用于重新渲染表单的结果。

ActionExecution
英文源码说明

What one protocol run hands back to the generated handler.

response?: Response (可选) — When set, the handler returns this response and renders nothing.; actionResult?: ActionOutcome (可选) — The classified action outcome for the 422 re-render (native failure path).

packages/router/src/vite/internal/server-runtime/action-runtime.ts:63
ActionLoadContext类型 · 公开
@openelement/router · ./server-runtime

为 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:51
ActionProtocolState接口 · 公开
@openelement/router · ./server-runtime
ActionProtocolState
英文源码说明

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.

isFetch: boolean (必填)

packages/router/src/vite/internal/server-runtime/action-runtime.ts:58
actionRedirectResponse函数 · 公开
@openelement/router · ./server-runtime

构造 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).

req: RequestScopeRequest (必填); headers: Headers (必填) — The response-header channel. Headers the handler or the built-in middleware write before a response exists (`Cache-Control`, `Vary`, `X-Request-Id`, the security set) land here and merge into every response the scope builds. Stream routes hand the handler a separate committed stream channel; the scope keeps supplying the framework set.; env: Record<string, unknown> (必填) — The runtime env binding (`fetch(request, env)`).; executionCtx: unknown (必填) — The host execution context; throws when the host passed none (call sites guard).; header: (name: string, value: string, options?: { append?: boolean; }) => void (必填) — Writes one response header on the channel (set by default, append opt-in).; get: (key: string) => unknown (必填) — Reads one typed variable (e.g. `cspNonce`).; set: (key: string, value: unknown) => void (必填) — Writes one typed variable.; json: (object: unknown, status?: number, headers?: Record<string, string>) => Response (必填) — `application/json` response starting from the channel headers.; text: (text: string, status?: number, headers?: Record<string, string>) => Response (必填) — `text/plain; charset=UTF-8` response starting from the channel headers.; html: (html: string, status?: number, headers?: Record<string, string>) => Response (必填) — `text/html; charset=UTF-8` response starting from the channel headers.; redirect: (location: string, status?: number) => Response (必填) — Redirect response (`Location` + status, default 302).; body: (data: BodyInit | null, status?: number, headers?: Record<string, string>) => Response (必填) — Raw-body response starting from the channel headers.

packages/router/src/vite/internal/server-runtime/action-runtime.ts:359
ApiRouteFunction类型 · 公开
@openelement/router · ./server-runtime

API 路由模块默认导出的函数式处理器,形式为 `(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
applyCspNonce函数 · 公开
@openelement/router · ./server-runtime

用当前请求的 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
boundRequestScope函数 · 公开
@openelement/router · ./server-runtime

获取生成处理器和内置中间件共用的已绑定请求作用域。

(request: Request): OpenElementRequestScope | undefined
英文源码说明

The scope accessor the generated handlers and built-in middleware share.

cache: RequestCache (必填) — The **`cache`** read-only property of the Request interface contains the cache mode of the request. It controls how the request will interact with the browser's HTTP cache. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/cache); credentials: RequestCredentials (必填) — The **`credentials`** read-only property of the Request interface reflects the value given to the Request() constructor in the credentials option. It determines whether or not the browser sends credentials with the request, as well as whether any Set-Cookie response headers are respected. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/credentials); destination: RequestDestination (必填) — The **`destination`** read-only property of the Request interface returns a string describing the type of content being requested. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/destination); headers: Headers (必填) — The **`headers`** read-only property of the Request interface contains the Headers object associated with the request. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/headers); integrity: string (必填) — The **`integrity`** read-only property of the Request interface contains the subresource integrity value of the request. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/integrity); keepalive: boolean (必填) — The **`keepalive`** read-only property of the Request interface contains the request's keepalive setting (true or false), which indicates whether the browser will keep the associated request alive if the page that initiated it is unloaded before the request is complete. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/keepalive); method: string (必填) — The **`method`** read-only property of the Request interface contains the request's method (GET, POST, etc.) [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/method); mode: RequestMode (必填) — The **`mode`** read-only property of the Request interface contains the mode of the request (e.g., cors, no-cors, same-origin, or navigate.) This is used to determine if cross-origin requests lead to valid responses, and which properties of the response are readable. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/mode); redirect: RequestRedirect (必填) — The **`redirect`** read-only property of the Request interface contains the mode for how redirects are handled. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/redirect); referrer: string (必填) — The **`referrer`** read-only property of the Request interface is set by the user agent to be the referrer of the Request. (e.g., client, no-referrer, or a URL.) [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/referrer); referrerPolicy: ReferrerPolicy (必填) — The **`referrerPolicy`** read-only property of the Request interface returns the referrer policy, which governs what referrer information, sent in the Referer header, should be included with the request. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/referrerPolicy); signal: AbortSignal (必填) — The read-only **`signal`** property of the Request interface returns the AbortSignal associated with the request. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/signal); url: string (必填) — The **`url`** read-only property of the Request interface contains the URL of the request. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/url); clone: () => Request (必填) — The **`clone()`** method of the Request interface creates a copy of the current Request object. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/clone); body: ReadableStream<Uint8Array<ArrayBuffer>> | null (必填) — [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/body); bodyUsed: boolean (必填) — [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bodyUsed); arrayBuffer: () => Promise<ArrayBuffer> (必填) — [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/arrayBuffer); blob: () => Promise<Blob> (必填) — [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/blob); bytes: () => Promise<Uint8Array<ArrayBuffer>> (必填) — [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bytes); formData: () => Promise<FormData> (必填) — [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/formData); json: () => Promise<any> (必填) — [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/json); text: () => Promise<string> (必填) — [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/text)

packages/router/src/vite/internal/server-runtime/wintercg.ts:254
CorsOptions接口 · 公开
@openelement/router · ./server-runtime

生成入口传给 `createCorsMiddleware` 的 CORS 配置选项。

CorsOptions
英文源码说明

Options for {@linkcode createCorsMiddleware} — the surface the generated entry emits.

origin?: string | string[] | ((origin: string) => string | undefined | null) (可选) — The `Access-Control-Allow-Origin` value: one origin, a list, or a resolver returning an origin or undefined.; allowMethods?: string[] (可选) — The `Access-Control-Allow-Methods` list.; allowHeaders?: string[] (可选) — The `Access-Control-Allow-Headers` list.; exposeHeaders?: string[] (可选) — The `Access-Control-Expose-Headers` list.; credentials?: boolean (可选) — Emits `Access-Control-Allow-Credentials: true`.; maxAge.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; maxAge.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; maxAge.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; maxAge.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; maxAge.valueOf: () => number (必填) — Returns the primitive value of the specified object.; maxAge.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.

packages/router/src/vite/internal/server-runtime/middleware.ts:93
createActionBodyLimit函数 · 公开
@openelement/router · ./server-runtime
(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

toString: (radix?: number) => string (必填) — Returns a string representation of an object.; toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; valueOf: () => number (必填) — Returns the primitive value of the specified object.; toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.

packages/router/src/vite/internal/server-runtime/action-runtime.ts:290
createCorsMiddleware函数 · 公开
@openelement/router · ./server-runtime
(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.

origin?: string | string[] | ((origin: string) => string | undefined | null) (可选) — The `Access-Control-Allow-Origin` value: one origin, a list, or a resolver returning an origin or undefined.; allowMethods?: string[] (可选) — The `Access-Control-Allow-Methods` list.; allowHeaders?: string[] (可选) — The `Access-Control-Allow-Headers` list.; exposeHeaders?: string[] (可选) — The `Access-Control-Expose-Headers` list.; credentials?: boolean (可选) — Emits `Access-Control-Allow-Credentials: true`.; maxAge.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; maxAge.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; maxAge.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; maxAge.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; maxAge.valueOf: () => number (必填) — Returns the primitive value of the specified object.; maxAge.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.

packages/router/src/vite/internal/server-runtime/middleware.ts:118
createCspNonce函数 · 公开
@openelement/router · ./server-runtime

为每个请求生成由 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
createGeneratedApp函数 · 公开
@openelement/router · ./server-runtime

根据路由描述数据创建生成应用,返回入口用于绑定处理器的接口。

(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.

islands: Record<string, string> (必填) — Build-time island map: tag -> client module path (#951 upgrade URLs).; layoutPlan: LayoutPlan (必填) — The build's layout plan (serialized generated data).; locales: readonly string[] (必填) — Declared project locales (serialized generated data).; navSections: readonly unknown[] (必填) — Nav sections (serialized generated data; empty on the 1.0 surface).; headerNav: readonly Record<string, unknown>[] (必填) — Header nav links (serialized generated data; empty on the 1.0 surface).; defaultLocale: string (必填) — The project's default locale (generated data).; devClientScriptSrc: string | null (必填) — The dev island-client URL the entry computed from its compile-time `import.meta.env` constants; null when the app ships no client entry.; pageHandlerPaths: readonly string[] (必填) — Page route paths, in route order — the handler table's keys.; fetchMiddleware?: readonly FetchMiddleware[] (可选) — `middleware.use` module defaults, user-configured order (use[0] outermost).; pageRuntime?: GeneratedPageRuntime (可选)

packages/router/src/vite/internal/server-runtime/app.ts:150
createLayoutRuntime函数 · 公开
@openelement/router · ./server-runtime

将布局运行时绑定到入口的渲染器、可信 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 }`.

ssr: PageSsrRenderer (必填) — The entry's bound page renderer (`__ssr`) — the layout renders through the same seam.; trustedHtml: (html: string) => TrustedHtmlValue (必填) — The entry's `trustedHtml` import — the slot projection is an explicit trust boundary.; layoutPlan: LayoutPlan (必填) — The build's layout plan (serialized generated data).; locales: readonly string[] (必填) — Declared project locales (serialized generated data).; navSections: readonly unknown[] (必填) — Nav sections (serialized generated data; empty on the 1.0 surface).; headerNav: readonly Record<string, unknown>[] (必填) — Header nav links (serialized generated data; empty on the 1.0 surface).; defaultLocale: string (必填) — The project's default locale (generated data).

packages/router/src/vite/internal/server-runtime/document-runtime.ts:113
createLoggerMiddleware函数 · 公开
@openelement/router · ./server-runtime

记录请求进入时的方法与路径,并在响应返回后记录 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).

print?: ((line: string) => void) (可选) — The print function. Default `console.log`.

packages/router/src/vite/internal/server-runtime/middleware.ts:70
createMethodNotAllowedResponder函数 · 公开
@openelement/router · ./server-runtime
(): (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
createNativePageRenderer函数 · 公开
@openelement/router · ./server-runtime

创建默认的原生页面渲染器,经 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).

renderToString: (tag: string, options: { componentClass?: unknown; props?: Record<string, unknown>; sourceInfo?: PageSsrSourceInfo; ssrRenderableTags?: readonly string[]; proj… (必填) — Element's sync compiled serializer (`renderToString`, returning HTML directly).; customElements: { get(tag: string): unknown; } (必填) — The SSR registry (the runtime's `customElements` global).; ssrRenderableTags: readonly string[] (必填) — Build-admitted nested compiled tags (serialized generated data).

packages/router/src/vite/internal/server-runtime/renderer-runtime.ts:107
createPageHandlerTable函数 · 公开
@openelement/router · ./server-runtime
(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
createPagePropsRuntime函数 · 公开
@openelement/router · ./server-runtime

将生成入口的危险键清单用于页面属性投影,提供默认、正常和错误三种属性投影函数。

(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).

dangerousKeys: ReadonlySet<string> (必填) — The canonical dangerous-key set (the factory imports it from the kernel-free /authoring leaf): one rule, no second copy.

packages/router/src/vite/internal/server-runtime/page-render.ts:209
createRequestIdMiddleware函数 · 公开
@openelement/router · ./server-runtime
(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.

limitLength.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; limitLength.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; limitLength.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; limitLength.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; limitLength.valueOf: () => number (必填) — Returns the primitive value of the specified object.; limitLength.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.; headerName?: string (可选) — The response header carrying the id. Default `X-Request-Id`.; generator?: ((request: Request) => string) (可选) — The id generator. Default `crypto.randomUUID()`.

packages/router/src/vite/internal/server-runtime/middleware.ts:40
createRequestScope函数 · 公开
@openelement/router · ./server-runtime

创建单个请求的作用域。`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.

cache: RequestCache (必填) — The **`cache`** read-only property of the Request interface contains the cache mode of the request. It controls how the request will interact with the browser's HTTP cache. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/cache); credentials: RequestCredentials (必填) — The **`credentials`** read-only property of the Request interface reflects the value given to the Request() constructor in the credentials option. It determines whether or not the browser sends credentials with the request, as well as whether any Set-Cookie response headers are respected. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/credentials); destination: RequestDestination (必填) — The **`destination`** read-only property of the Request interface returns a string describing the type of content being requested. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/destination); headers: Headers (必填) — The **`headers`** read-only property of the Request interface contains the Headers object associated with the request. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/headers); integrity: string (必填) — The **`integrity`** read-only property of the Request interface contains the subresource integrity value of the request. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/integrity); keepalive: boolean (必填) — The **`keepalive`** read-only property of the Request interface contains the request's keepalive setting (true or false), which indicates whether the browser will keep the associated request alive if the page that initiated it is unloaded before the request is complete. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/keepalive); method: string (必填) — The **`method`** read-only property of the Request interface contains the request's method (GET, POST, etc.) [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/method); mode: RequestMode (必填) — The **`mode`** read-only property of the Request interface contains the mode of the request (e.g., cors, no-cors, same-origin, or navigate.) This is used to determine if cross-origin requests lead to valid responses, and which properties of the response are readable. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/mode); redirect: RequestRedirect (必填) — The **`redirect`** read-only property of the Request interface contains the mode for how redirects are handled. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/redirect); referrer: string (必填) — The **`referrer`** read-only property of the Request interface is set by the user agent to be the referrer of the Request. (e.g., client, no-referrer, or a URL.) [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/referrer); referrerPolicy: ReferrerPolicy (必填) — The **`referrerPolicy`** read-only property of the Request interface returns the referrer policy, which governs what referrer information, sent in the Referer header, should be included with the request. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/referrerPolicy); signal: AbortSignal (必填) — The read-only **`signal`** property of the Request interface returns the AbortSignal associated with the request. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/signal); url: string (必填) — The **`url`** read-only property of the Request interface contains the URL of the request. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/url); clone: () => Request (必填) — The **`clone()`** method of the Request interface creates a copy of the current Request object. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/clone); body: ReadableStream<Uint8Array<ArrayBuffer>> | null (必填) — [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/body); bodyUsed: boolean (必填) — [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bodyUsed); arrayBuffer: () => Promise<ArrayBuffer> (必填) — [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/arrayBuffer); blob: () => Promise<Blob> (必填) — [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/blob); bytes: () => Promise<Uint8Array<ArrayBuffer>> (必填) — [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bytes); formData: () => Promise<FormData> (必填) — [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/formData); json: () => Promise<any> (必填) — [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/json); text: () => Promise<string> (必填) — [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/text)

packages/router/src/vite/internal/server-runtime/wintercg.ts:106
createSecureHeadersMiddleware函数 · 公开
@openelement/router · ./server-runtime

在响应生成后施加安全响应头并移除 `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
createStatusHtml函数 · 公开
@openelement/router · ./server-runtime

使用入口的 `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
createStreamBody函数 · 公开
@openelement/router · ./server-runtime
(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.

escapeAttr: (value: string) => string (必填) — The entry's `escapeAttr` import — an Element function, injected so this module stays free of an Element runtime edge.; timeoutMs.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; timeoutMs.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; timeoutMs.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; timeoutMs.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; timeoutMs.valueOf: () => number (必填) — Returns the primitive value of the specified object.; timeoutMs.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.

packages/router/src/vite/internal/server-runtime/stream-runtime.ts:327
createStreamHeaderChannel函数 · 公开
@openelement/router · ./server-runtime

为流式路由创建请求级响应头通道。提交后延迟修改只记录结构化诊断,保留已提交的响应头。

(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
createStreamRequestScope函数 · 公开
@openelement/router · ./server-runtime
(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.

cache: RequestCache (必填) — The **`cache`** read-only property of the Request interface contains the cache mode of the request. It controls how the request will interact with the browser's HTTP cache. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/cache); credentials: RequestCredentials (必填) — The **`credentials`** read-only property of the Request interface reflects the value given to the Request() constructor in the credentials option. It determines whether or not the browser sends credentials with the request, as well as whether any Set-Cookie response headers are respected. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/credentials); destination: RequestDestination (必填) — The **`destination`** read-only property of the Request interface returns a string describing the type of content being requested. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/destination); headers: Headers (必填) — The **`headers`** read-only property of the Request interface contains the Headers object associated with the request. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/headers); integrity: string (必填) — The **`integrity`** read-only property of the Request interface contains the subresource integrity value of the request. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/integrity); keepalive: boolean (必填) — The **`keepalive`** read-only property of the Request interface contains the request's keepalive setting (true or false), which indicates whether the browser will keep the associated request alive if the page that initiated it is unloaded before the request is complete. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/keepalive); method: string (必填) — The **`method`** read-only property of the Request interface contains the request's method (GET, POST, etc.) [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/method); mode: RequestMode (必填) — The **`mode`** read-only property of the Request interface contains the mode of the request (e.g., cors, no-cors, same-origin, or navigate.) This is used to determine if cross-origin requests lead to valid responses, and which properties of the response are readable. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/mode); redirect: RequestRedirect (必填) — The **`redirect`** read-only property of the Request interface contains the mode for how redirects are handled. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/redirect); referrer: string (必填) — The **`referrer`** read-only property of the Request interface is set by the user agent to be the referrer of the Request. (e.g., client, no-referrer, or a URL.) [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/referrer); referrerPolicy: ReferrerPolicy (必填) — The **`referrerPolicy`** read-only property of the Request interface returns the referrer policy, which governs what referrer information, sent in the Referer header, should be included with the request. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/referrerPolicy); signal: AbortSignal (必填) — The read-only **`signal`** property of the Request interface returns the AbortSignal associated with the request. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/signal); url: string (必填) — The **`url`** read-only property of the Request interface contains the URL of the request. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/url); clone: () => Request (必填) — The **`clone()`** method of the Request interface creates a copy of the current Request object. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/clone); body: ReadableStream<Uint8Array<ArrayBuffer>> | null (必填) — [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/body); bodyUsed: boolean (必填) — [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bodyUsed); arrayBuffer: () => Promise<ArrayBuffer> (必填) — [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/arrayBuffer); blob: () => Promise<Blob> (必填) — [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/blob); bytes: () => Promise<Uint8Array<ArrayBuffer>> (必填) — [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bytes); formData: () => Promise<FormData> (必填) — [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/formData); json: () => Promise<any> (必填) — [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/json); text: () => Promise<string> (必填) — [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/text)

packages/router/src/vite/internal/server-runtime/stream-runtime.ts:126
createWinterCgApp函数 · 公开
@openelement/router · ./server-runtime

创建生成入口组装的内部 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
DANGEROUS_KEYS常量 · 公开
@openelement/router · ./server-runtime

从不可信属性复制数据时必须排除的对象原型键。

ReadonlySet<string>
英文源码说明

Object prototype keys that must never be injected from untrusted props.

packages/element/src/internal/core/security.ts:25
GeneratedApp接口 · 公开
@openelement/router · ./server-runtime

生成入口从应用工厂的返回对象中解构并再次导出的接口。

GeneratedApp
英文源码说明

Everything the generated entry destructures and re-exports.

app: WinterCgApp (必填) — The internal WinterCG app — the entry's default export.; requestScope: (request: Request) => OpenElementRequestScope (必填) — The per-request scope accessor the generated handlers bind (`__requestScope`): one scope per dispatch, keyed by request identity.; handler: (request: Request, context?: { env?: unknown; platform?: unknown; }) => Promise<Response> (必填) — The WinterCG request handler: the app's composed dispatch with the fetch-middleware onion composed around it when `middleware.use` is configured (#858).; devFetch?: { fetch: (request: Request, env: unknown, executionContext: unknown) => Promise<Response>; } (可选) — Dev-server boundary export, present only with `middleware.use` (#858).; runtimeAdapter: Record<string, unknown> (必填) — Deployment adapter record (`openElementRuntimeAdapter`).; pageHandlers: Record<string, Record<string, unknown>> (必填) — Per-path page handler table the generated GET/POST wiring populates.; apiRouteRecords: { id: string; path: string; handlers: unknown; }[] (必填) — API route records the generated API wiring pushes into.; methodNotAllowed: (request: Request, allow: string[]) => Response (必填) — The 405 responder for `createRouteMiddleware({ methodNotAllowed })` (#572).; actionBodyLimit: (request: Request, route: unknown, next: () => Promise<Response>) => Promise<Response> (必填) — The default action body-limit middleware (#568), bound to the policy constant.; registerSsrComponent: (tag: string, ctor: unknown) => void (必填) — SSR registration seam (security.ts).; registerSsrIsland: (tag: string, ctor: unknown, hostRenderer: unknown) => void (必填) — Generated-island registration seam (M11): pairs the generated element class with its compiler-emitted host renderer atomically, through the same guard owner. The generated entry calls it only for ssr-admitted islands whose compiler fact names a host producer.; setRequestTimeClientScript: (src: string | null | undefined) => void (必填) — Request-time client-script src setter (`dist/server/index.js` startup).; clientScriptDescriptors: () => Array<{ type: "module"; src: string; }> (必填) — wrapInDocument `scripts` descriptors for the current runtime mode (#951).; locales: readonly string[] (必填); getDefaultLocale: () => string (必填); ssr?: PageSsrRenderer (可选) — Page-render bindings — present only when the config carried `pageRuntime`.; pageProps?: ((routeModule: unknown, context: PageContext) => ProjectedProps) (可选); pageErrorProps?: ((routeModule: unknown, error: unknown, context: PageContext) => ProjectedProps) (可选); statusHtml?: StatusHtmlRenderer (可选); resolveLayout?: ((routeMeta?: Record<string, unknown>) => ResolvedLayout) (可选); renderLayout?: ((pageHtml: unknown, routePath: string, options?: { locale?: string; routeMeta?: Record<string, unknown>; documentStyles?: DocumentStyleSink; }) => string) | u… (可选)

packages/router/src/vite/internal/server-runtime/app.ts:93
GeneratedAppConfig接口 · 公开
@openelement/router · ./server-runtime

生成入口传给应用工厂的路由描述数据。

GeneratedAppConfig
英文源码说明

The route-descriptor data the generated entry hands the factory.

islands: Record<string, string> (必填) — Build-time island map: tag -> client module path (#951 upgrade URLs).; layoutPlan: LayoutPlan (必填) — The build's layout plan (serialized generated data).; locales: readonly string[] (必填) — Declared project locales (serialized generated data).; navSections: readonly unknown[] (必填) — Nav sections (serialized generated data; empty on the 1.0 surface).; headerNav: readonly Record<string, unknown>[] (必填) — Header nav links (serialized generated data; empty on the 1.0 surface).; defaultLocale: string (必填) — The project's default locale (generated data).; devClientScriptSrc: string | null (必填) — The dev island-client URL the entry computed from its compile-time `import.meta.env` constants; null when the app ships no client entry.; pageHandlerPaths: readonly string[] (必填) — Page route paths, in route order — the handler table's keys.; fetchMiddleware?: readonly FetchMiddleware[] (可选) — `middleware.use` module defaults, user-configured order (use[0] outermost).; pageRuntime?: GeneratedPageRuntime (可选)

packages/router/src/vite/internal/server-runtime/app.ts:67
GeneratedPageRuntime接口 · 公开
@openelement/router · ./server-runtime

有页面路由时由入口绑定的页面渲染接口,使用所选的渲染适配器。纯 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.

mode: "native" (必填); ssrRenderableTags: readonly string[] (必填) — Build-admitted SSR-renderable tags (serialized generated data).; trustedHtml: (html: string) => TrustedHtmlValue (必填); escapeHtml: (value: string) => string (必填); renderToString?: ((tag: string, options: { componentClass?: unknown; props?: Record<string, unknown>; sourceInfo?: PageSsrSourceInfo; ssrRenderableTags?: readonly string[]; pro… (可选) — The compiled serializer and the SSR registry.; customElements?: { get(tag: string): unknown; } (可选)

packages/router/src/vite/internal/server-runtime/app.ts:55
installSsrRegistryGuard函数 · 公开
@openelement/router · ./server-runtime

安装 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
isSsgPrerenderDispatch函数 · 公开
@openelement/router · ./server-runtime

判断当前分派是否为 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接口 · 公开
@openelement/router · ./server-runtime

绑定到生成入口的布局运行时接口。

LayoutRuntime
英文源码说明

The layout runtime bound into the generated entry.

resolveLayout: (routeMeta?: Record<string, unknown>) => ResolvedLayout (必填) — Resolve the layout for one route's metadata: `layout: false` disables the layout, a named layout looks up `layoutPlan.layouts`, anything else (and an unset layout) takes the plan default.; renderLayout: (pageHtml: unknown, routePath: string, options?: { locale?: string; routeMeta?: Record<string, unknown>; documentStyles?: DocumentStyleSink; }) => string (必填) — Render route content inside the resolved layout: the page HTML is projected into the layout's default slot through the page renderer, so nested admitted islands expand deterministically and route content stays inside the declared layout-main boundary. An unresolved layout returns the content unchanged.

packages/router/src/vite/internal/server-runtime/document-runtime.ts:58
LayoutRuntimeDeps接口 · 公开
@openelement/router · ./server-runtime

`createLayoutRuntime` 绑定布局运行时所需的 Element 依赖和序列化配置。

LayoutRuntimeDeps
英文源码说明

What {@linkcode createLayoutRuntime} binds: the entry's Element imports plus its serialized plan data.

ssr: PageSsrRenderer (必填) — The entry's bound page renderer (`__ssr`) — the layout renders through the same seam.; trustedHtml: (html: string) => TrustedHtmlValue (必填) — The entry's `trustedHtml` import — the slot projection is an explicit trust boundary.; layoutPlan: LayoutPlan (必填) — The build's layout plan (serialized generated data).; locales: readonly string[] (必填) — Declared project locales (serialized generated data).; navSections: readonly unknown[] (必填) — Nav sections (serialized generated data; empty on the 1.0 surface).; headerNav: readonly Record<string, unknown>[] (必填) — Header nav links (serialized generated data; empty on the 1.0 surface).; defaultLocale: string (必填) — The project's default locale (generated data).

packages/router/src/vite/internal/server-runtime/document-runtime.ts:91
localeFromPath函数 · 公开
@openelement/router · ./server-runtime
(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
localizeLayoutHref函数 · 公开
@openelement/router · ./server-runtime
(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
LoggerOptions接口 · 公开
@openelement/router · ./server-runtime

`createLoggerMiddleware` 的日志配置。

LoggerOptions
英文源码说明

Options for {@linkcode createLoggerMiddleware}.

print?: ((line: string) => void) (可选) — The print function. Default `console.log`.

packages/router/src/vite/internal/server-runtime/middleware.ts:59
matchesMiddlewareScope函数 · 公开
@openelement/router · ./server-runtime
(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
mergeChannelHeaders函数 · 公开
@openelement/router · ./server-runtime

将 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).

headers: Headers (必填) — The **`headers`** read-only property of the Response interface contains the Headers object associated with the response. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/headers); ok: boolean (必填) — The **`ok`** read-only property of the Response interface contains a Boolean stating whether the response was successful (status in the range 200-299) or not. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/ok); redirected: boolean (必填) — The **`redirected`** read-only property of the Response interface indicates whether or not the response is the result of a request you made which was redirected. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/redirected); status.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; status.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; status.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; status.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; status.valueOf: () => number (必填) — Returns the primitive value of the specified object.; status.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.; statusText: string (必填) — The **`statusText`** read-only property of the Response interface contains the status message corresponding to the HTTP status code in Response.status. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/statusText); type: ResponseType (必填) — The **`type`** read-only property of the Response interface contains the type of the response. The type determines whether scripts are able to access the response body and headers. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/type); url: string (必填) — The **`url`** read-only property of the Response interface contains the URL of the response. The value of the url property will be the final URL obtained after any redirects. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/url); clone: () => Response (必填) — The **`clone()`** method of the Response interface creates a clone of a response object, identical in every way, but stored in a different variable. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/clone); body: ReadableStream<Uint8Array<ArrayBuffer>> | null (必填) — [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/body); bodyUsed: boolean (必填) — [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bodyUsed); arrayBuffer: () => Promise<ArrayBuffer> (必填) — [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/arrayBuffer); blob: () => Promise<Blob> (必填) — [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/blob); bytes: () => Promise<Uint8Array<ArrayBuffer>> (必填) — [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bytes); formData: () => Promise<FormData> (必填) — [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/formData); json: () => Promise<any> (必填) — [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/json); text: () => Promise<string> (必填) — [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/text)

packages/router/src/vite/internal/server-runtime/response-channel.ts:111
NativePageRendererDeps接口 · 公开
@openelement/router · ./server-runtime

原生页面渲染器所需的 Element 序列化接口子集。

NativePageRendererDeps
英文源码说明

The subset of the Element serializer the native renderer needs.

renderToString: (tag: string, options: { componentClass?: unknown; props?: Record<string, unknown>; sourceInfo?: PageSsrSourceInfo; ssrRenderableTags?: readonly string[]; proj… (必填) — Element's sync compiled serializer (`renderToString`, returning HTML directly).; customElements: { get(tag: string): unknown; } (必填) — The SSR registry (the runtime's `customElements` global).; ssrRenderableTags: readonly string[] (必填) — Build-admitted nested compiled tags (serialized generated data).

packages/router/src/vite/internal/server-runtime/renderer-runtime.ts:79
OpenElementRequestScope接口 · 公开
@openelement/router · ./server-runtime

与单次分派的请求绑定的作用域。响应创建前通过 `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.

req: RequestScopeRequest (必填); headers: Headers (必填) — The response-header channel. Headers the handler or the built-in middleware write before a response exists (`Cache-Control`, `Vary`, `X-Request-Id`, the security set) land here and merge into every response the scope builds. Stream routes hand the handler a separate committed stream channel; the scope keeps supplying the framework set.; env: Record<string, unknown> (必填) — The runtime env binding (`fetch(request, env)`).; executionCtx: unknown (必填) — The host execution context; throws when the host passed none (call sites guard).; header: (name: string, value: string, options?: { append?: boolean; }) => void (必填) — Writes one response header on the channel (set by default, append opt-in).; get: (key: string) => unknown (必填) — Reads one typed variable (e.g. `cspNonce`).; set: (key: string, value: unknown) => void (必填) — Writes one typed variable.; json: (object: unknown, status?: number, headers?: Record<string, string>) => Response (必填) — `application/json` response starting from the channel headers.; text: (text: string, status?: number, headers?: Record<string, string>) => Response (必填) — `text/plain; charset=UTF-8` response starting from the channel headers.; html: (html: string, status?: number, headers?: Record<string, string>) => Response (必填) — `text/html; charset=UTF-8` response starting from the channel headers.; redirect: (location: string, status?: number) => Response (必填) — Redirect response (`Location` + status, default 302).; body: (data: BodyInit | null, status?: number, headers?: Record<string, string>) => Response (必填) — Raw-body response starting from the channel headers.

packages/router/src/vite/internal/server-runtime/wintercg.ts:66
PageContext接口 · 公开
@openelement/router · ./server-runtime

生成处理器为一次页面渲染建立的请求级上下文。

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
pageDefinition函数 · 公开
@openelement/router · ./server-runtime
(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
PageDefinition类型 · 公开
@openelement/router · ./server-runtime

`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
PagePropsRuntime接口 · 公开
@openelement/router · ./server-runtime

页面属性投影运行时,以参数和加载数据生成默认属性,并执行 `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.

defaultPageProps: (context: PageContext) => ProjectedProps (必填) — The descriptor-less fallback: params + plain-object loader data.; pageProps: (routeModule: unknown, context: PageContext) => ProjectedProps (必填) — The descriptor `props` projector, falling back to the default projection.; pageErrorProps: (routeModule: unknown, error: unknown, context: PageContext) => ProjectedProps (必填) — The descriptor `error` projector for the error-boundary re-render.

packages/router/src/vite/internal/server-runtime/page-render.ts:102
PagePropsRuntimeDeps接口 · 公开
@openelement/router · ./server-runtime

生成应用工厂传给 `createPagePropsRuntime` 的绑定依赖。

PagePropsRuntimeDeps
英文源码说明

The binding the generated-app factory hands {@linkcode createPagePropsRuntime}.

dangerousKeys: ReadonlySet<string> (必填) — The canonical dangerous-key set (the factory imports it from the kernel-free /authoring leaf): one rule, no second copy.

packages/router/src/vite/internal/server-runtime/page-render.ts:112
PageSsrRenderer类型 · 公开
@openelement/router · ./server-runtime
PageSsrRenderer
英文源码说明

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
PageSsrSourceInfo接口 · 公开
@openelement/router · ./server-runtime

渲染时传给序列化器的源码信息,包含 `route`。

PageSsrSourceInfo
英文源码说明

Source metadata the serializer attributes to a render (the `{ route }` seam).

route?: string (可选); source?: string (可选); generatedPageRoot?: boolean (可选); documentStyles?: DocumentStyleSink (可选) — The render's document stylesheet collection. It rides this per-render object because every emitted `__ssr` call site already builds one, and the collection's lifetime IS the render's.

packages/router/src/vite/internal/server-runtime/renderer-runtime.ts:41
ProjectedChildren类型 · 公开
@openelement/router · ./server-runtime

按插槽名组织的可信轻 DOM 子节点,由父级提供给宿主插槽认领。

ProjectedChildren
英文源码说明

Trusted parent-owned light children keyed by slot name (the shell slot claim).

forEach: (callbackfn: (value: TrustedHtmlValue, key: string, map: ReadonlyMap<string, TrustedHtmlValue>) => void, thisArg?: any) => void (必填); get: (key: string) => TrustedHtmlValue (必填); has: (key: string) => boolean (必填); size.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; size.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; size.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; size.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; size.valueOf: () => number (必填) — Returns the primitive value of the specified object.; size.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.; entries: () => MapIterator<[string, TrustedHtmlValue]> (必填) — Returns an iterable of key, value pairs for every entry in the map.; keys: () => MapIterator<string> (必填) — Returns an iterable of keys in the map; values: () => MapIterator<TrustedHtmlValue> (必填) — Returns an iterable of values in the map; __@iterator@11158: () => MapIterator<[string, TrustedHtmlValue]> (必填) — Returns an iterable of entries in the map.

packages/router/src/vite/internal/server-runtime/renderer-runtime.ts:54
ProjectedProps类型 · 公开
@openelement/router · ./server-runtime

交给编译后页面宿主的属性投影记录。

ProjectedProps
英文源码说明

The projected props record handed to the compiled page host.

packages/router/src/vite/internal/server-runtime/page-render.ts:93
PROTOCOL_HEADERS常量 · 公开
@openelement/router · ./server-runtime

定义 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
renderFunctionPage函数 · 公开
@openelement/router · ./server-runtime

同步执行服务端函数页渲染并返回 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
renderFunctionPageAwaited函数 · 公开
@openelement/router · ./server-runtime

等待服务端函数页完成渲染再转换为 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
RequestIdOptions接口 · 公开
@openelement/router · ./server-runtime

`createRequestIdMiddleware` 的请求标识配置。

RequestIdOptions
英文源码说明

Options for {@linkcode createRequestIdMiddleware}.

limitLength.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; limitLength.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; limitLength.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; limitLength.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; limitLength.valueOf: () => number (必填) — Returns the primitive value of the specified object.; limitLength.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.; headerName?: string (可选) — The response header carrying the id. Default `X-Request-Id`.; generator?: ((request: Request) => string) (可选) — The id generator. Default `crypto.randomUUID()`.

packages/router/src/vite/internal/server-runtime/middleware.ts:24
RequestScopeRequest接口 · 公开
@openelement/router · ./server-runtime

生成入口以 `c.req` 提供的请求视图,包含标准 `Request`、URL、路径、参数和请求头读取接口。

RequestScopeRequest
英文源码说明

The request view the generated wiring binds as `c.req`.

raw: Request (必填) — The underlying WinterCG request (replaceable — the body limit swaps in a buffered twin).; url: string (必填) — The full request URL string.; path: string (必填) — The request pathname.; param: () => Record<string, string> (必填) — The route-match path params (empty outside a match).; header: (name: string) => string (必填) — One request header.

packages/router/src/vite/internal/server-runtime/wintercg.ts:46
ResponseHeaderChannel接口 · 公开
@openelement/router · ./server-runtime
ResponseHeaderChannel
英文源码说明

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.

channel: Headers (必填) — Author-facing view of the channel. Before commitment every `Headers` mutator passes through unchanged; after {@linkcode ResponseHeaderChannel.commit} the mutating methods are gated — a late `append`/`set`/`delete` becomes a warn-and-ignore diagnostic naming the route, header, and operation. It never throws and never mutates the committed response.; commit: () => void (必填) — The header-commitment point: the generated handler calls this once, immediately before it exposes the response body. Later mutator calls are ignored with a diagnostic. Idempotent.

packages/router/src/vite/internal/server-runtime/types.ts:18
routeMeta函数 · 公开
@openelement/router · ./server-runtime
(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
RouteModule接口 · 公开
@openelement/router · ./server-runtime

生成入口通过 `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
runActionProtocol函数 · 公开
@openelement/router · ./server-runtime

处理一次 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).

req: RequestScopeRequest (必填); headers: Headers (必填) — The response-header channel. Headers the handler or the built-in middleware write before a response exists (`Cache-Control`, `Vary`, `X-Request-Id`, the security set) land here and merge into every response the scope builds. Stream routes hand the handler a separate committed stream channel; the scope keeps supplying the framework set.; env: Record<string, unknown> (必填) — The runtime env binding (`fetch(request, env)`).; executionCtx: unknown (必填) — The host execution context; throws when the host passed none (call sites guard).; header: (name: string, value: string, options?: { append?: boolean; }) => void (必填) — Writes one response header on the channel (set by default, append opt-in).; get: (key: string) => unknown (必填) — Reads one typed variable (e.g. `cspNonce`).; set: (key: string, value: unknown) => void (必填) — Writes one typed variable.; json: (object: unknown, status?: number, headers?: Record<string, string>) => Response (必填) — `application/json` response starting from the channel headers.; text: (text: string, status?: number, headers?: Record<string, string>) => Response (必填) — `text/plain; charset=UTF-8` response starting from the channel headers.; html: (html: string, status?: number, headers?: Record<string, string>) => Response (必填) — `text/html; charset=UTF-8` response starting from the channel headers.; redirect: (location: string, status?: number) => Response (必填) — Redirect response (`Location` + status, default 302).; body: (data: BodyInit | null, status?: number, headers?: Record<string, string>) => Response (必填) — Raw-body response starting from the channel headers.

packages/router/src/vite/internal/server-runtime/action-runtime.ts:114
SSG_PRERENDER_ENV_KEY常量 · 公开
@openelement/router · ./server-runtime

SSG 预渲染每次构建期分派时设为 `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
SsrRegistryGuard接口 · 公开
@openelement/router · ./server-runtime

`installSsrRegistryGuard` 返回给生成入口的注册接口。

SsrRegistryGuard
英文源码说明

What the generated entry gets from {@linkcode installSsrRegistryGuard}.

register: (tag: string, ctor: unknown) => void (必填) — Registers one component class under `tag` with the same ownership/conflict rules the generated entry has always applied (#952, #1339).; registerIsland: (tag: string, ctor: unknown, hostRenderer: unknown) => void (必填) — Registers one generated element class AND its compiler-emitted host renderer as ONE atomic pair (M11 complete vertical). The pair is written under {@linkcode SSR_REGISTRY_GENERATED_HOSTS} only when this call actually owns the class registration after running the EXISTING define/ownership decision: a foreign (entry-unowned) conflict pairs neither half, and a dev re-evaluation replaces both halves …

packages/router/src/vite/internal/server-runtime/security.ts:37
StatusHtmlRenderer类型 · 公开
@openelement/router · ./server-runtime

生成入口的 `__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:40
STREAM_BROWSER_BOOTSTRAP常量 · 公开
@openelement/router · ./server-runtime
string
英文源码说明

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接口 · 公开
@openelement/router · ./server-runtime

创建流式响应体构建器时绑定的配置,包括特性转义函数和测试用超时覆盖。

StreamBodyConfig
英文源码说明

Binding-time configuration of {@linkcode createStreamBody}.

escapeAttr: (value: string) => string (必填) — The entry's `escapeAttr` import — an Element function, injected so this module stays free of an Element runtime edge.; timeoutMs.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; timeoutMs.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; timeoutMs.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; timeoutMs.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; timeoutMs.valueOf: () => number (必填) — Returns the primitive value of the specified object.; timeoutMs.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.

packages/router/src/vite/internal/server-runtime/stream-runtime.ts:102
StreamBodyFn类型 · 公开
@openelement/router · ./server-runtime

供生成处理器调用的流式响应体构建函数。

StreamBodyFn
英文源码说明

The bound streaming body builder the generated handler calls.

packages/router/src/vite/internal/server-runtime/stream-runtime.ts:117
StreamBodyOptions接口 · 公开
@openelement/router · ./server-runtime

构建一次流式响应体所需的请求级输入。

StreamBodyOptions
英文源码说明

Per-request inputs of the streaming body builder.

scope: StreamRequestScope (必填); route: string (必填); manifest: StreamRouteManifest (必填); executor: StreamExecutorView (必填); records: readonly StreamFieldRecord[] (必填); document: StreamDocumentParts (必填); token: string (必填)

packages/router/src/vite/internal/server-runtime/stream-runtime.ts:91
StreamDocumentParts接口 · 公开
@openelement/router · ./server-runtime

Element 的 `documentStreamParts` 生成的流式文档前缀和后缀。

StreamDocumentParts
英文源码说明

The streamed document halves the element `documentStreamParts` produced.

prefix: string (必填); suffix: string (必填)

packages/router/src/vite/internal/server-runtime/stream-runtime.ts:85
StreamExecutorView接口 · 公开
@openelement/router · ./server-runtime

流式调度循环使用的 Element 流执行接口子集。

StreamExecutorView
英文源码说明

The slice of the element stream executor the pump consumes.

shell: string (必填); owner: { readonly instanceId: string; } (必填); seed: Record<string, { type: string; }> (必填); resolvedValue: (field: string, value: unknown) => unknown (必填); serializeResolved: (field: string, value: unknown) => string[] (必填)

packages/router/src/vite/internal/server-runtime/stream-runtime.ts:76
StreamFieldRecord接口 · 公开
@openelement/router · ./server-runtime

记录一个声明为延迟的字段如何完成,供流式调度队列消费。

StreamFieldRecord
英文源码说明

One declared deferred field's settlement record (the pump's queue unit).

entry: { field: string; signal: string; owners: Array<{ kind: "part" | "region"; index: number; location: string; source: PartProgramV2["sourceMap"]["records"][number… (必填); settled: boolean (必填); failed: boolean (必填); error: unknown (必填); value: unknown (必填); notify?: (() => void) (可选)

packages/router/src/vite/internal/server-runtime/stream-runtime.ts:54
streamFields函数 · 公开
@openelement/router · ./server-runtime
(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接口 · 公开
@openelement/router · ./server-runtime

生成处理器为一条流式路由建立的请求作用域。

StreamRequestScope
英文源码说明

The request scope the generated handler builds around a streamed route.

request: Request (必填) — The request the loader sees, carrying the scope's abort signal.; upstreamSignal: AbortSignal (必填) — The original WinterCG request's signal (the response-cancel source).; abortWork: () => void (必填) — Aborts the loader's work without tearing down the scope bridge.; cancel: () => void (必填) — Detaches the upstream bridge and aborts the scope (handler-level exit).

packages/router/src/vite/internal/server-runtime/stream-runtime.ts:64
TrustedHtmlValue接口 · 公开
@openelement/router · ./server-runtime

标记已由应用明确校验为可信的 HTML 的不透明类型。

TrustedHtmlValue
英文源码说明

Opaque capability marking HTML the application has explicitly vetted as trusted.

html: string (必填)

packages/router/src/vite/internal/server-runtime/renderer-runtime.ts:24
WinterCgApp接口 · 公开
@openelement/router · ./server-runtime

生成入口用于组装路由和中间件的内部 WinterCG 应用接口。

WinterCgApp
英文源码说明

The internal WinterCG app: the composition surface the generated entry wires.

use: (pattern: string, middleware: WinterCgFetchMiddleware) => void (必填) — Registers middleware, optionally path-scoped (`'*'`, `'/p/*'`, or a bare `'/p'`).; route: (middleware: WinterCgFetchMiddleware) => void (必填) — Registers the route-table layer: theWinterCG middleware that resolves method-keyed records (createRouteMiddleware). It composes after the fn-form mounts — the route layer, not an outer middleware — so a mount and a record at the same path resolve with route specificity, the way the replaced composition ordered them.; all: (path: string, handler: ApiRouteFunction) => void (必填) — Mounts a fn-form API handler at a path — every method reaches it, params resolve from the match.; notFound: (handler: (request: Request, scope: OpenElementRequestScope) => Response | Promise<Response>) => void (必填) — The 404 terminal: invoked when no middleware or mount produced a response.; fetch: (request: Request, env?: Record<string, unknown>, platform?: unknown) => Promise<Response> (必填) — The dispatch: the composed chain over one request. Never rejects.; request: (input: string | URL | Request, init?: RequestInit, env?: Record<string, unknown>) => Promise<Response> (必填) — `Request`-convenience dispatch (the SSG prerender and test harnesses).; requestScope: (request: Request) => OpenElementRequestScope (必填) — The per-request scope accessor the generated handlers bind (`__requestScope`).; routes: readonly { method: "ALL"; path: string; }[] (必填) — The fn-form mounts (the SSG prerender's page-discovery exclusion set).

packages/router/src/vite/internal/server-runtime/wintercg.ts:195
WinterCgFetchMiddleware类型 · 公开
@openelement/router · ./server-runtime

应用组合使用的通用 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接口 · 公开
@openelement/router · ./vite

单个构建产物的文件大小信息。

ArtifactInfo
英文源码说明

File size info for a single artifact

name: string (必填); path: string (必填); sizeBytes.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; sizeBytes.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; sizeBytes.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; sizeBytes.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; sizeBytes.valueOf: () => number (必填) — Returns the primitive value of the specified object.; sizeBytes.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.; sizeKB: string (必填); gzipBytes?: number (可选) — gzip -9 bytes; only computed for JS chunks, not HTML pages.; gzipKB?: string (可选)

packages/router/src/vite/build-manifest.ts:38
buildApp函数 · 公开
@openelement/router · ./vite

按 `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
buildHeadExtras函数 · 公开
@openelement/router · ./vite

将 `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接口 · 公开
@openelement/router · ./vite

完整构建清单的摘要。

BuildManifest
英文源码说明

Full build manifest summary

phase: 1 | 2 | 3 (必填); timestamp: string (必填); islands: ArtifactInfo[] (必填); clientEntry: ArtifactInfo | null (必填); sharedChunks: ArtifactInfo[] (必填) — JS chunks that are neither an island chunk nor the client entry: the shared runtime chunks every island page eagerly imports, and dynamically fetched chunks like the search combobox.; htmlPages: ArtifactInfo[] (必填); totalJsBytes.toString: (radix?: number) => string (必填) — Returns a string representation of an object.; totalJsBytes.toFixed: (fractionDigits?: number) => string (必填) — Returns a string representing a number in fixed-point notation.; totalJsBytes.toExponential: (fractionDigits?: number) => string (必填) — Returns a string containing a number represented in exponential notation.; totalJsBytes.toPrecision: (precision?: number) => string (必填) — Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.; totalJsBytes.valueOf: () => number (必填) — Returns the primitive value of the specified object.; totalJsBytes.toLocaleString: { (locales?: string | string[], options?: Intl.NumberFormatOptions): string; (locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string; } (必填) — Converts a number to a string by using the current or specified locale.; totalJsGzipBytes: number (必填) — Sum of per-file gzip sizes over every scanned JS chunk.; totalHtmlBytes: number (必填); headExtrasSize: number (必填); warnings: string[] (必填) — Budget warnings (files > threshold)

packages/router/src/vite/build-manifest.ts:49
default函数 · 公开
@openelement/router · ./vite

底层 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()`.

routes.dir?: string (可选); output.outDir?: string (可选); island.dir?: string (可选); island.upgradeStrategy?: string (可选); viewTransition?: boolean (可选); headExtras?: string (可选)

packages/router/src/vite/index.ts:39
FrameworkOptions类型 · 公开
@openelement/router · ./vite

在 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
HeadExtrasResult接口 · 公开
@openelement/router · ./vite

从 `FrameworkOptions` 构建额外头部内容后的结果。

HeadExtrasResult
英文源码说明

Result of building head extras from FrameworkOptions.

headExtras: string (必填); allowHeadExtrasScripts: boolean (必填)

packages/router/src/vite/head-injection.ts:139
mdxPlugin函数 · 公开
@openelement/router · ./vite

将 `.mdx` 路由文件编译为页面模块的 Vite 插件。

(options?: OpenMdxPluginOptions): Plugin
英文源码说明

Vite plugin compiling `.mdx` route files into compiled page modules.

routesDir?: string (可选) — Routes directory (as configured in openElement()). The compiled page tag derives from the route-file-relative path so the generated entry's path-derived registration tag matches the program tag.

packages/router/src/vite/plugin-mdx.ts:72
openElement函数 · 公开
@openelement/router · ./vite

创建完整的 OpenElement Vite 插件组,涵盖路由管线、SSG 和 islands。

(options?: OpenElementOptions): Plugin[]
英文源码说明

Create the full OpenElement Vite plugin set: route pipeline, SSG and islands.

head.title?: string (可选) — Document title; defaults to the package.json `name`.; head.description?: string (可选) — `<meta name="description">` + `og:description`.; head.lang?: string (可选) — `<html lang>`; defaults to `en`.; head.favicon?: string (可选) — Site-root-relative favicon path, emitted as `<link rel="icon">`.; head.ogImage?: string (可选) — `og:image` URL. Absolute (crawlable) or site-root-relative.; head.stylesheets?: string[] (可选) — External stylesheets linked into `<head>`.; head.scripts?: OpenElementHeadScript[] (可选) — External scripts emitted into `<head>`; inline code is not accepted here.; ssg.dynamicRouteFailure?: "fail" | "warn" (可选) — Policy for dynamic-route render failures during SSG. See {@link SsgRenderOptions.dynamicRouteFailure}.; build.outDir?: string (可选) — Output directory for the build artifacts. Defaults to `dist`.; build.manifestBudget?: { 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.; renderer?: "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).; routesDir?: string (可选) — Directory the route scanner walks, relative to the Vite root. Defaults to `app/routes`.; islandsDir?: string (可选) — Directory island modules are discovered in. Defaults to `app/islands`.; packageIslands?: 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…; layout?: LayoutConfig (可选) — Layout declaration; `false` disables the layout, `'default'` uses the built-in one.; layouts?: LayoutsConfig (可选) — Named layout declarations keyed by layout name.; headExtras?: string (可选) — @dangerous injected as-is, only use with controlled content; inject.stylesheets?: (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.; inject.scripts?: (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.; inject.headFragments?: 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>`.; ssr.noExternal?: (string | RegExp)[] (可选); island.upgradeStrategy?: "load" | "idle" | "visible" | "only" | "none" (可选); viewTransition?: boolean (可选) — Enable the View Transitions API for client navigations. Defaults to true.; speculation?: 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.; middleware.cors?: boolean (可选) — Built-in CORS middleware. Default-ON; pass `false` to disable.; middleware.corsOrigin?: string | string[] (可选) — Static CORS allowlist data, serialized into the generated entry as JSON. Mutually exclusive with {@link FrameworkOptions.middleware.corsOriginModule }.; middleware.corsOriginModule?: string (可选) — Path 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`.; middleware.requestId?: boolean (可选) — Emit and honor a per-request id header. Default-ON; pass `false` to disable.; middleware.logger?: boolean (可选) — Log each request through the built-in logger. Default-ON; pass `false` to disable.; middleware.securityHeaders?: boolean (可选) — Attach the built-in security response headers. Default-ON; pass `false` to disable.; middleware.csp?: { policy?: string; nonce?: boolean; reportOnly?: boolean; } (可选) — Content-Security-Policy emission: the policy string, nonce generation, and report-only mode.; middleware.use?: 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…; criticalAssets.fonts?: CriticalFontAsset[] (可选); criticalAssets.styles?: (string | CriticalStyleAsset)[] (可选); criticalAssets.stylesheets?: (string | CriticalStyleAsset)[] (可选) — Alias for styles accepted by config producers.; criticalAssets.inlineScripts?: (string | CriticalInlineScriptAsset)[] (可选); criticalAssets.allowExternalRenderBlocking?: boolean (可选) — Allow intentional external render-blocking styles/scripts.; criticalAssets.allowRenderBlockingExternal?: boolean (可选) — Alias retained only within this build-side config shape.; criticalAssets.minifyInlineStyles?: boolean (可选) — Minify inline CSS. Defaults to true.; criticalAssets.origin?: string (可选) — Origin used to distinguish same-origin and cross-origin absolute URLs.; critical?: CriticalAssetsOptions (可选); i18n?: OpenElementI18nOptions (可选); tailwind?: boolean | TailwindOptions (可选) — Opt-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.; unocss?: boolean | UnocssOptions (可选) — Opt-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`).

packages/router/src/vite/app-vite.ts:39
OpenElementBlogOptions接口 · 公开
@openelement/router · ./vite

适配器构建上下文中的博客选项,包含内容目录和 URL 基路径。

OpenElementBlogOptions
英文源码说明

Blog options stored in the adapter build context.

contentDir?: string (可选); basePath?: string (可选)

packages/router/src/vite/framework.ts:59
OpenElementBuildContext类 · 公开
@openelement/router · ./vite
class 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接口 · 公开
@openelement/router · ./vite

适配器子插件可用的最小构建上下文接口。

OpenElementBuildContextLike
英文源码说明

Minimal build-context contract available to adapter sub-plugins.

plugins: { [key: string]: unknown; blogOptions: OpenElementBlogOptions | null; navSections: OpenElementNavSection[]; headerNav: OpenElementHeaderNavLink[]; sitemapOptio… (必填); registerPlugin: (name: string, instance: unknown) => void (必填)

packages/router/src/vite/framework.ts:84
OpenElementI18nContextOptions接口 · 公开
@openelement/router · ./vite

经构建上下文传给国际化集成的语言列表与默认语言等选项。

OpenElementI18nContextOptions
英文源码说明

Locale options carried through the build context to the i18n integration.

packages/router/src/vite/framework.ts:77
OpenElementI18nOptions接口 · 公开
@openelement/router · ./vite

声明项目语言。构建会为额外语言展开路由,把语言传给页面的 `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.

locales: string[] (必填) — Locale prefixes the build expands, e.g. `['en', 'zh']`.; defaultLocale?: string (可选) — Locale served without a prefix. Defaults to the first entry.

packages/router/src/vite/framework.ts:26
OpenElementNavSection接口 · 公开
@openelement/router · ./vite

适配器内容管线生成的导航分区及其条目。

OpenElementNavSection
英文源码说明

Navigation section produced by the adapter content pipeline.

section: string (必填); items: { path: string; label: string; order?: number; }[] (必填)

packages/router/src/vite/framework.ts:65
OpenElementOptions接口 · 公开
@openelement/router · ./vite

`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.

head.title?: string (可选) — Document title; defaults to the package.json `name`.; head.description?: string (可选) — `<meta name="description">` + `og:description`.; head.lang?: string (可选) — `<html lang>`; defaults to `en`.; head.favicon?: string (可选) — Site-root-relative favicon path, emitted as `<link rel="icon">`.; head.ogImage?: string (可选) — `og:image` URL. Absolute (crawlable) or site-root-relative.; head.stylesheets?: string[] (可选) — External stylesheets linked into `<head>`.; head.scripts?: OpenElementHeadScript[] (可选) — External scripts emitted into `<head>`; inline code is not accepted here.; ssg.dynamicRouteFailure?: "fail" | "warn" (可选) — Policy for dynamic-route render failures during SSG. See {@link SsgRenderOptions.dynamicRouteFailure}.; build.outDir?: string (可选) — Output directory for the build artifacts. Defaults to `dist`.; build.manifestBudget?: { 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.; renderer?: "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).; routesDir?: string (可选) — Directory the route scanner walks, relative to the Vite root. Defaults to `app/routes`.; islandsDir?: string (可选) — Directory island modules are discovered in. Defaults to `app/islands`.; packageIslands?: 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…; layout?: LayoutConfig (可选) — Layout declaration; `false` disables the layout, `'default'` uses the built-in one.; layouts?: LayoutsConfig (可选) — Named layout declarations keyed by layout name.; headExtras?: string (可选) — @dangerous injected as-is, only use with controlled content; inject.stylesheets?: (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.; inject.scripts?: (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.; inject.headFragments?: 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>`.; ssr.noExternal?: (string | RegExp)[] (可选); island.upgradeStrategy?: "load" | "idle" | "visible" | "only" | "none" (可选); viewTransition?: boolean (可选) — Enable the View Transitions API for client navigations. Defaults to true.; speculation?: 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.; middleware.cors?: boolean (可选) — Built-in CORS middleware. Default-ON; pass `false` to disable.; middleware.corsOrigin?: string | string[] (可选) — Static CORS allowlist data, serialized into the generated entry as JSON. Mutually exclusive with {@link FrameworkOptions.middleware.corsOriginModule }.; middleware.corsOriginModule?: string (可选) — Path 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`.; middleware.requestId?: boolean (可选) — Emit and honor a per-request id header. Default-ON; pass `false` to disable.; middleware.logger?: boolean (可选) — Log each request through the built-in logger. Default-ON; pass `false` to disable.; middleware.securityHeaders?: boolean (可选) — Attach the built-in security response headers. Default-ON; pass `false` to disable.; middleware.csp?: { policy?: string; nonce?: boolean; reportOnly?: boolean; } (可选) — Content-Security-Policy emission: the policy string, nonce generation, and report-only mode.; middleware.use?: 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…; criticalAssets.fonts?: CriticalFontAsset[] (可选); criticalAssets.styles?: (string | CriticalStyleAsset)[] (可选); criticalAssets.stylesheets?: (string | CriticalStyleAsset)[] (可选) — Alias for styles accepted by config producers.; criticalAssets.inlineScripts?: (string | CriticalInlineScriptAsset)[] (可选); criticalAssets.allowExternalRenderBlocking?: boolean (可选) — Allow intentional external render-blocking styles/scripts.; criticalAssets.allowRenderBlockingExternal?: boolean (可选) — Alias retained only within this build-side config shape.; criticalAssets.minifyInlineStyles?: boolean (可选) — Minify inline CSS. Defaults to true.; criticalAssets.origin?: string (可选) — Origin used to distinguish same-origin and cross-origin absolute URLs.; critical?: CriticalAssetsOptions (可选); i18n?: OpenElementI18nOptions (可选); tailwind?: boolean | TailwindOptions (可选) — Opt-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.; unocss?: boolean | UnocssOptions (可选) — Opt-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`).

packages/router/src/vite/app-vite.ts:31
OpenMdxPluginOptions接口 · 公开
@openelement/router · ./vite

`.mdx` 路由插件 `mdxPlugin` 的配置选项。

OpenMdxPluginOptions
英文源码说明

Options for the `.mdx` route plugin ({@linkcode mdxPlugin}).

routesDir?: string (可选) — Routes directory (as configured in openElement()). The compiled page tag derives from the route-file-relative path so the generated entry's path-derived registration tag matches the program tag.

packages/router/src/vite/plugin-mdx.ts:29
openPipeline函数 · 公开
@openelement/router · ./vite

底层 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()`.

routes.dir?: string (可选); output.outDir?: string (可选); island.dir?: string (可选); island.upgradeStrategy?: string (可选); viewTransition?: boolean (可选); headExtras?: string (可选)

packages/router/src/vite/index.ts:39
OpenPipelineConfig接口 · 公开
@openelement/router · ./vite

底层 Vite 插件管线 `openPipeline` 的配置选项。

OpenPipelineConfig
英文源码说明

Options for the low-level {@linkcode openPipeline} Vite plugin pipeline.

routes.dir?: string (可选); output.outDir?: string (可选); island.dir?: string (可选); island.upgradeStrategy?: string (可选); viewTransition?: boolean (可选); headExtras?: string (可选)

packages/router/src/vite/index.ts:30
ResolvedTailwindOptions接口 · 公开
@openelement/router · ./vite

解析后的 Tailwind 预设选项,保存按声明次序排列的样式来源。

ResolvedTailwindOptions
英文源码说明

The resolved preset options: the declared style sources, in order.

theme: readonly string[] (必填) — The sources the entry `@import`s after Tailwind itself: package CSS specifiers (`@openelement/ui/theme.css`) or app-relative paths. Their `@theme` blocks, `@import`s and `url()` references compile through the official plugin like any other Tailwind CSS source.; documentReset: boolean (必填) — WHOSE document the entry is: `true` when the application declared it (`tailwind: true | { theme }`), `false` when an admitted package declaration enabled it (automatic mode, `tailwind: undefined`). The single thing it decides is the DOCUMENT RESET. `@import 'tailwindcss'` carries preflight, and an application that turned the entry on is resetting its own document — that is the pre-S-lane behavior…

packages/router/src/vite/tailwind.ts:59
SpeculationRulesOptions接口 · 公开
@openelement/router · ./vite

静态生成后处理使用的 Speculation Rules 配置。

SpeculationRulesOptions
英文源码说明

Speculation Rules configuration for SSG post-processing

prerender?: string[] (可选) — URL patterns to prerender (fully render in background before navigation).; prefetch?: string[] (可选) — URL patterns to prefetch (fetch HTML + resources without rendering).; exclude?: string[] (可选) — URL patterns to exclude from both prefetch and prerender.; eagerness?: "immediate" | "moderate" | "conservative" (可选) — Eagerness level for prerender rules.

packages/protocol/src/ssg.ts:448
SsgBehaviorOptions接口 · 公开
@openelement/router · ./vite

面向应用的静态站点生成构建选项。

SsgBehaviorOptions
英文源码说明

User-facing SSG build behavior switches (OpenElementOptions['ssg']).

dynamicRouteFailure?: "fail" | "warn" (可选) — Policy for dynamic-route render failures during SSG. See {@link SsgRenderOptions.dynamicRouteFailure}.

packages/protocol/src/ssg.ts:63
TailwindOptions接口 · 公开
@openelement/router · ./vite
TailwindOptions
英文源码说明

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).

theme?: string[] (可选) — The style sources the entry `@import`s after Tailwind itself: package CSS specifiers (`@openelement/ui/theme.css`, `tailwindcss/theme.css`) or app-relative paths. Their `@theme` blocks, `@import`s and `url()` assets compile through the official `@tailwindcss/vite` pipeline into the document stylesheet — the router neither scans for classes nor transforms the compiled CSS.

packages/router/src/config.ts:176

@openelement/create

5 个导出
CREATE_INSTALL_TAG常量 · 公开
@openelement/create · ./install-command

文档不指定版本时用来解析安装包的 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
CREATE_NPM_CREATE_SCOPE常量 · 公开
@openelement/create · ./install-command
"@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
CREATE_PACKAGE_SPECIFIER常量 · 公开
@openelement/create · ./install-command

生成器在 npm 上发布时使用的包名。

"@openelement/create"
英文源码说明

The npm specifier the generator is published under.

packages/create/src/install-command.ts:17
CREATE_PROJECT_PLACEHOLDER常量 · 公开
@openelement/create · ./install-command

使用说明和文档中代指项目名的占位文本。

"<project-name>"
英文源码说明

Placeholder the usage text and the docs use in place of a project name.

packages/create/src/install-command.ts:36
createInstallCommand函数 · 公开
@openelement/create · ./install-command
(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

@openelement/ui

24 个导出
manifest常量 · 公开
@openelement/ui · root

构建时生成的 UI 包清单,包含每个组件的声明。

OpenElementPackageManifest
英文源码说明

The build-time generated package manifest (declarations for every UI component).

packages/ui/src/manifest.ts:15
OpenButton函数 · 公开
@openelement/ui · root

可渲染为按钮或链接,支持外观变体、尺寸和表单参与。

(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.

variant: string (必填); size: string (必填); disabled: boolean (必填); href: string (必填); target: string (必填); type: string (必填)

packages/ui/src/open-button.tsx:67
OpenCodeBlock函数 · 公开
@openelement/ui · root

带复制按钮的代码块。

(props: { copyLabel: string; }): any
英文源码说明

Code block with a copy button.

copyLabel: string (必填)

packages/ui/src/open-code-block.tsx:48
OpenDialog函数 · 公开
@openelement/ui · root

基于原生 dialog 元素和 Popover API 的对话框组件。

(props: { open: boolean; label: string; closeLabel: string; }): any
英文源码说明

Dialog component using native <dialog> element + popover API.

open: boolean (必填); label: string (必填); closeLabel: string (必填)

packages/ui/src/open-dialog.tsx:73
OpenDropdown函数 · 公开
@openelement/ui · root

基于 Popover API 和 CSS 锚点定位的下拉组件。

(props: { anchorName: string; }): any
英文源码说明

Popover-API dropdown with CSS Anchor Positioning placement.

anchorName: string (必填)

packages/ui/src/open-dropdown.tsx:54
OpenInput函数 · 公开
@openelement/ui · root

可与表单关联的文本输入组件,提供标签、错误插槽和原生有效性检查。

(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.

type: string (必填); placeholder: string (必填); label: string (必填); name: string (必填); value: string (必填); disabled: boolean (必填); required: boolean (必填); error: string (必填)

packages/ui/src/open-input.tsx:76
OpenThemeToggle函数 · 公开
@openelement/ui · root
(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.

theme: string (必填)

packages/ui/src/open-theme-toggle.tsx:56
readInstanceState函数 · 公开
@openelement/ui · root

读取宿主的 `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
writeInstanceState函数 · 公开
@openelement/ui · root

覆写宿主的 `key` 实例状态槽。

(host: object, key: string, value: unknown): void
英文源码说明

Overwrite the host's `key` slot.

packages/ui/src/instance-state.ts:26
readInstanceState函数 · 公开
@openelement/ui · ./instance-state

读取宿主的 `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
writeInstanceState函数 · 公开
@openelement/ui · ./instance-state

覆写宿主的 `key` 实例状态槽。

(host: object, key: string, value: unknown): void
英文源码说明

Overwrite the host's `key` slot.

packages/ui/src/instance-state.ts:26
manifest常量 · 公开
@openelement/ui · ./manifest

构建时生成的 UI 包清单,包含每个组件的声明。

OpenElementPackageManifest
英文源码说明

The build-time generated package manifest (declarations for every UI component).

packages/ui/src/manifest.ts:15
default函数 · 公开
@openelement/ui · ./open-button

可渲染为按钮或链接,支持外观变体、尺寸和表单参与。

(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.

variant: string (必填); size: string (必填); disabled: boolean (必填); href: string (必填); target: string (必填); type: string (必填)

packages/ui/src/open-button.tsx:67
openElement常量 · 公开
@openelement/ui · ./open-button
{ 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
default函数 · 公开
@openelement/ui · ./open-code-block

带复制按钮的代码块。

(props: { copyLabel: string; }): any
英文源码说明

Code block with a copy button.

copyLabel: string (必填)

packages/ui/src/open-code-block.tsx:48
openElement常量 · 公开
@openelement/ui · ./open-code-block

声明生成元素的影子根、组件样式表和只能作为属性传入的 `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
default函数 · 公开
@openelement/ui · ./open-dialog

基于原生 dialog 元素和 Popover API 的对话框组件。

(props: { open: boolean; label: string; closeLabel: string; }): any
英文源码说明

Dialog component using native <dialog> element + popover API.

open: boolean (必填); label: string (必填); closeLabel: string (必填)

packages/ui/src/open-dialog.tsx:73
openElement常量 · 公开
@openelement/ui · ./open-dialog

生成对话框元素使用的配置,声明代理焦点的 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
default函数 · 公开
@openelement/ui · ./open-dropdown

基于 Popover API 和 CSS 锚点定位的下拉组件。

(props: { anchorName: string; }): any
英文源码说明

Popover-API dropdown with CSS Anchor Positioning placement.

anchorName: string (必填)

packages/ui/src/open-dropdown.tsx:54
openElement常量 · 公开
@openelement/ui · ./open-dropdown
{ 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
default函数 · 公开
@openelement/ui · ./open-input

可与表单关联的文本输入组件,提供标签、错误插槽和原生有效性检查。

(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.

type: string (必填); placeholder: string (必填); label: string (必填); name: string (必填); value: string (必填); disabled: boolean (必填); required: boolean (必填); error: string (必填)

packages/ui/src/open-input.tsx:76
openElement常量 · 公开
@openelement/ui · ./open-input
{ 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
default函数 · 公开
@openelement/ui · ./open-theme-toggle
(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.

theme: string (必填)

packages/ui/src/open-theme-toggle.tsx:56
openElement常量 · 公开
@openelement/ui · ./open-theme-toggle

生成主题开关元素使用的配置,声明代理焦点的 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

05 / 配置选项

应用选项类型,逐成员一行。

由配置入口所校验的应用选项类型渲染而成,因此这张表与真实配置面不可能漂移。嵌套选项组以点号路径呈现;类型列是声明的类型文本。

head.title
string

Document title; defaults to the package.json `name`.

可选
head.description
string

`<meta name="description">` + `og:description`.

可选
head.lang
string

`<html lang>`; defaults to `en`.

可选
head.favicon
string

Site-root-relative favicon path, emitted as `<link rel="icon">`.

可选
head.ogImage
string

`og:image` URL. Absolute (crawlable) or site-root-relative.

可选
head.stylesheets
string[]

External stylesheets linked into `<head>`.

可选
head.scripts
OpenElementHeadScript[]

External scripts emitted into `<head>`; inline code is not accepted here.

可选
ssg.dynamicRouteFailure
"fail" | "warn"

Policy for dynamic-route render failures during SSG. See {@link SsgRenderOptions.dynamicRouteFailure}.

可选
renderer
"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).

可选
routesDir
string

Directory the route scanner walks, relative to the Vite root. Defaults to `app/routes`.

可选
islandsDir
string

Directory island modules are discovered in. Defaults to `app/islands`.

可选
packageIslands
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…

可选
layout
LayoutConfig

Layout declaration; `false` disables the layout, `'default'` uses the built-in one.

可选
layouts
LayoutsConfig

Named layout declarations keyed by layout name.

可选
headExtras
string

@dangerous injected as-is, only use with controlled content

可选
inject.stylesheets
(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.

可选
inject.scripts
(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.

可选
inject.headFragments
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>`.

可选
ssr.noExternal
(string | RegExp)[]

可选
island.upgradeStrategy
"load" | "idle" | "visible" | "only" | "none"

可选
build.outDir
string

Output directory for the build artifacts. Defaults to `dist`.

可选
build.manifestBudget
{ 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.

可选
viewTransition
boolean

Enable the View Transitions API for client navigations. Defaults to true.

可选
speculation
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.

可选
middleware.cors
boolean

Built-in CORS middleware. Default-ON; pass `false` to disable.

可选
middleware.corsOrigin
string | string[]

Static CORS allowlist data, serialized into the generated entry as JSON. Mutually exclusive with {@link FrameworkOptions.middleware.corsOriginModule }.

可选
middleware.corsOriginModule
string

Path 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`.

可选
middleware.requestId
boolean

Emit and honor a per-request id header. Default-ON; pass `false` to disable.

可选
middleware.logger
boolean

Log each request through the built-in logger. Default-ON; pass `false` to disable.

可选
middleware.securityHeaders
boolean

Attach the built-in security response headers. Default-ON; pass `false` to disable.

可选
middleware.csp
{ policy?: string; nonce?: boolean; reportOnly?: boolean; }

Content-Security-Policy emission: the policy string, nonce generation, and report-only mode.

可选
middleware.use
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…

可选
criticalAssets.fonts
CriticalFontAsset[]

可选
criticalAssets.styles
(string | CriticalStyleAsset)[]

可选
criticalAssets.stylesheets
(string | CriticalStyleAsset)[]

Alias for styles accepted by config producers.

可选
criticalAssets.inlineScripts
(string | CriticalInlineScriptAsset)[]

可选
criticalAssets.allowExternalRenderBlocking
boolean

Allow intentional external render-blocking styles/scripts.

可选
criticalAssets.allowRenderBlockingExternal
boolean

Alias retained only within this build-side config shape.

可选
criticalAssets.minifyInlineStyles
boolean

Minify inline CSS. Defaults to true.

可选
criticalAssets.origin
string

Origin used to distinguish same-origin and cross-origin absolute URLs.

可选
critical
CriticalAssetsOptions

可选
i18n
OpenElementI18nOptions

可选
tailwind
boolean | TailwindOptions

Opt-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.

可选
unocss
boolean | UnocssOptions

Opt-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`).

可选

04 / 元素参考

来自编译器 manifest 的 Custom Element。

标签、层级、hydration 策略、属性、事件、插槽与 CSS parts 均来自 @openelement/ui 编译器 manifest——SSR/claim 管线校验所依据的同一份真值。

<open-button>OpenButtonElementdsd-interactiveload

Button or link control with variant/size surfaces and form participation.

@openelement/ui/open-button
属性variant: string = default; size: string = md; disabled: boolean = false; href: string = ; target: string = ; type: string = button事件open-click: CustomEvent — Fired on open-click插槽(default)CSS partscontrol
<open-code-block>OpenCodeBlockElementdsd-staticidle

Code block with a copy button.

@openelement/ui/open-code-block
属性事件插槽(default)CSS partscopy
<open-dialog>OpenDialogElementdsd-interactiveidle实验性

Dialog component using native <dialog> element + popover API.

@openelement/ui/open-dialog
属性open: boolean = false; label: string = ; close-label: string = Close事件open-dialog-close: CustomEvent — Fired on open-dialog-close插槽(default); trigger; footerCSS partsoverlay; header; close; body; footer
<open-dropdown>OpenDropdownElementdsd-interactiveload实验性

Popover-API dropdown with CSS Anchor Positioning placement.

@openelement/ui/open-dropdown
属性事件插槽(default); triggerCSS partstrigger; content
<open-input>OpenInputElementdsd-interactiveload实验性

Form-associated text input with a label, an error slot and native validity.

@openelement/ui/open-input
属性type: string = text; placeholder: string = ; label: string = ; name: string = ; value: string = ; disabled: boolean = false; required: boolean = false; error: string = 事件open-input: CustomEvent<{ value: unknown }> — Fired on open-input; open-change: CustomEvent<{ value: unknown }> — Fired on open-change; open-focus: CustomEvent — Fired on open-focus; open-blur: CustomEvent — Fired on open-blur插槽CSS partswrapper; label; control; error
<open-theme-toggle>OpenThemeToggleElementdsd-interactiveload

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.

@openelement/ui/open-theme-toggle
属性theme: string = dark事件open:theme-change: CustomEvent<{ theme: unknown }> — Fired on open:theme-change插槽CSS partstoggle; icon-sun; icon-moon