@openelement/protocol 0.41.0-beta.3 → 1.0.0-alpha.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +42 -0
  3. package/package.json +90 -51
  4. package/src/app-model.d.ts +19 -0
  5. package/src/app-model.js +1 -0
  6. package/src/client-assets.d.ts +44 -0
  7. package/src/client-assets.js +24 -0
  8. package/src/data.d.ts +81 -11
  9. package/src/data.js +11 -7
  10. package/src/errors.d.ts +253 -14
  11. package/src/errors.js +275 -15
  12. package/src/forbidden-sinks.d.ts +60 -0
  13. package/src/forbidden-sinks.js +81 -0
  14. package/src/framework.d.ts +183 -99
  15. package/src/framework.js +13 -5
  16. package/src/index.d.ts +21 -19
  17. package/src/index.js +21 -20
  18. package/src/island-admission.d.ts +5 -0
  19. package/src/island-admission.js +9 -0
  20. package/src/island.d.ts +32 -19
  21. package/src/island.js +1 -4
  22. package/src/manifest.d.ts +15 -27
  23. package/src/manifest.js +1 -4
  24. package/src/module-descriptors.d.ts +40 -0
  25. package/src/module-descriptors.js +1 -0
  26. package/src/module-vocabulary.d.ts +5 -0
  27. package/src/module-vocabulary.js +21 -0
  28. package/src/part-program.d.ts +407 -0
  29. package/src/part-program.js +758 -0
  30. package/src/policy.d.ts +64 -0
  31. package/src/policy.js +65 -0
  32. package/src/registry-markers.d.ts +39 -0
  33. package/src/registry-markers.js +40 -0
  34. package/src/render.d.ts +29 -123
  35. package/src/render.js +1 -7
  36. package/src/runtime.d.ts +13 -4
  37. package/src/runtime.js +1 -8
  38. package/src/signal.d.ts +31 -7
  39. package/src/signal.js +5 -6
  40. package/src/ssg.d.ts +317 -151
  41. package/src/ssg.js +1 -7
  42. package/src/stream-frame-policy.d.ts +49 -0
  43. package/src/stream-frame-policy.js +108 -0
  44. package/src/style-sheet.d.ts +5 -1
  45. package/src/style-sheet.js +1 -8
  46. package/src/void-tags.d.ts +18 -0
  47. package/src/void-tags.js +34 -0
  48. package/src/context.d.ts +0 -25
  49. package/src/context.js +0 -7
  50. package/src/hydration-markers.d.ts +0 -25
  51. package/src/hydration-markers.js +0 -26
  52. package/src/isr.d.ts +0 -30
  53. package/src/isr.js +0 -4
  54. package/src/prop.d.ts +0 -46
  55. package/src/prop.js +0 -6
  56. package/src/vnode.d.ts +0 -19
  57. package/src/vnode.js +0 -9
package/src/ssg.d.ts CHANGED
@@ -1,33 +1,29 @@
1
- /**
2
- * @openelement/protocol - SSG engine contracts.
3
- *
4
- * Runtime-free data contracts consumed by the SSG engine and build adapters.
5
- * These types keep the SSG engine adapter-agnostic.
6
- */ import type { CompatibilityClassification, HydrationStrategy } from "./framework.js";
7
- import type { HydrationHint, RenderError, SsrAdmissionDecision } from "./render.js";
8
- import type { OpenElementPackageManifest } from "./manifest.js";
9
- /** A single page to be rendered during SSG. */ export interface SsgPageInput {
10
- /** Route path (e.g. '/about', '/blog/hello') */ path: string;
11
- /** Route params (e.g. { slug: 'hello' }) */ params?: Record<string, string>;
12
- }
13
- /** Result of rendering a single page through the concurrency helper. */ export interface ParallelRenderPageOutput {
14
- path: string;
15
- html: string;
16
- durationMs: number;
17
- error?: string;
18
- }
19
- /** Options for parallel SSG rendering. */ export interface ParallelRenderOptions {
20
- /** Pages to render. */ pages: SsgPageInput[];
21
- /** Render function called for each page. */ renderPage: (page: SsgPageInput) => Promise<string>;
22
- /** Number of concurrent workers. Defaults to hardware concurrency or 4. */ concurrency?: number;
23
- }
24
- /** Summary of a parallel render run. */ export interface ParallelRenderResult {
25
- pages: ParallelRenderPageOutput[];
26
- totalDurationMs: number;
27
- successCount: number;
28
- errorCount: number;
1
+ import { CompatibilityClassification, FrameworkOptions, HydrationStrategy } from "./framework.js";
2
+ import { RenderError, SsrAdmissionDecision } from "./render.js";
3
+ import { PartProgramV1 } from "./part-program.js";
4
+ //#region src/ssg.d.ts
5
+ /** Build-only route projection bound to a specific compiled page program. */
6
+ export interface StreamRouteManifest {
7
+ program: {
8
+ version: number;
9
+ tag: string;
10
+ sha256: string;
11
+ };
12
+ fields: Array<{
13
+ field: string;
14
+ signal: string;
15
+ owners: Array<{
16
+ kind: 'part' | 'region';
17
+ index: number;
18
+ location: string;
19
+ source: PartProgramV1['sourceMap']['records'][number]['source'];
20
+ }>;
21
+ }>;
29
22
  }
30
- /** Options passed to the shared SSG render pipeline. */ export interface SsgRenderOptions {
23
+ /** Adapter-owned browser delivery strategy, including media-query admission. */
24
+ export type IslandDeliveryStrategy = HydrationStrategy | 'media';
25
+ /** Options passed to the shared SSG render pipeline. */
26
+ export interface SsgRenderOptions {
31
27
  root: string;
32
28
  outDir: string;
33
29
  base?: string;
@@ -48,45 +44,98 @@ import type { OpenElementPackageManifest } from "./manifest.js";
48
44
  speculation?: boolean | Record<string, unknown>;
49
45
  islandTagNames?: string[];
50
46
  routesDir?: string;
47
+ /**
48
+ * Policy for dynamic-route render failures (HTTP status >= 500, non-empty
49
+ * render errors, or a renderRoute throw) during SSG.
50
+ * - 'fail' (default): abort the build - a failed page must never ship as a
51
+ * normal 200 page.
52
+ * - 'warn': log the failure and skip the page (the page is not written and
53
+ * is not registered in the ISR manifest).
54
+ * @default 'fail'
55
+ */
56
+ dynamicRouteFailure?: 'fail' | 'warn';
57
+ }
58
+ /** User-facing SSG build behavior switches (OpenElementOptions['ssg']). */
59
+ export interface SsgBehaviorOptions {
60
+ /**
61
+ * Policy for dynamic-route render failures during SSG.
62
+ * See {@link SsgRenderOptions.dynamicRouteFailure}.
63
+ */
64
+ dynamicRouteFailure?: 'fail' | 'warn';
51
65
  }
52
- /** Manifest produced by Deno dependency pre-resolution. */ export interface ExternalManifest {
53
- /** Complete list of bare specifiers to mark as external. */ specifiers: string[];
54
- /** Redirect map (bare specifier to npm: URL) for importmap generation. */ importMap: Record<string, string>;
55
- /** ISO timestamp of generation. */ generatedAt: string;
56
- /** SHA-256 hash prefix of deno.lock at time of generation. */ lockHash: string;
57
- }
58
- /** Client island entry shape passed to entry generator. */ export interface ClientIslandEntry {
66
+ /** Summary of an SSG render run, returned by ssgRender(). */
67
+ export interface SsgRenderSummary {
68
+ /**
69
+ * Static routes whose handler returned a non-200 status. hono/ssg drops
70
+ * these responses (defaultPlugin), so they are not written to disk; they
71
+ * are listed here and in the build log instead of disappearing silently.
72
+ */
73
+ staticNon200: Array<{
74
+ path: string;
75
+ status: number;
76
+ }>;
77
+ /**
78
+ * Non-fatal warnings collected during the SSG run (sitemap generation
79
+ * failures, etc.). Surfaced here so the build summary / release evidence
80
+ * carries them instead of letting them disappear silently.
81
+ */
82
+ warnings: string[];
83
+ }
84
+ /** Client island entry shape passed to entry generator. */
85
+ export interface ClientIslandEntry {
59
86
  tagName: string;
60
87
  modulePath: string;
61
88
  isPackage?: boolean;
62
- strategy: HydrationStrategy;
89
+ /**
90
+ * Optional named export to register as the custom element constructor.
91
+ * When set (package islands whose chunk dropped `export default` per #638),
92
+ * the client island factory reads `mod[exportName]` instead of `mod.default`.
93
+ * When absent, the factory falls back to `mod.default` (local/route islands).
94
+ */
95
+ exportName?: string;
96
+ strategy: IslandDeliveryStrategy;
63
97
  strategySource?: 'default' | 'manifest' | 'component' | 'route';
64
98
  ssr?: boolean;
65
99
  dsd?: boolean;
66
100
  reason?: string;
67
101
  }
102
+ /** One module import the generated entry emits. */
68
103
  export interface ImportDecl {
69
104
  from: string;
70
105
  names: string[];
71
106
  alias?: string;
72
107
  }
73
- export type CorsOriginConfig = string | string[] | {
74
- type: 'function';
75
- body: string;
76
- };
108
+ /** The CORS origin policy an API route declares. */
109
+ export type CorsOriginConfig = string | string[];
110
+ /** The content-security-policy directives a route or document declares. */
77
111
  export interface CspConfig {
78
112
  policy?: string;
79
113
  nonce?: boolean;
80
114
  reportOnly?: boolean;
81
115
  }
116
+ /** One middleware module the generated entry composes. */
82
117
  export interface MiddlewareDecl {
83
118
  kind: 'requestId' | 'logger' | 'cors' | 'securityHeaders' | 'csp';
84
119
  comment?: string;
85
120
  config?: {
86
121
  corsOrigin?: CorsOriginConfig;
122
+ /**
123
+ * Normalized import path of a module default-exporting
124
+ * `(origin: string) => string | undefined`. The generated entry imports
125
+ * the module and passes its default export to `cors({ origin })` — the
126
+ * callback is referenced, never serialized.
127
+ */
128
+ corsOriginModule?: string;
129
+ /**
130
+ * #1411: emit the default-CORS production advisory. Absent means "warn"
131
+ * (production builds); the dev server sets false so the first run is
132
+ * warning-free.
133
+ */
134
+ warnOnDefaultCors?: boolean;
87
135
  csp?: CspConfig;
88
136
  };
89
137
  }
138
+ /** One API route declaration in the generated entry descriptor. */
90
139
  export interface ApiRouteDecl {
91
140
  kind: 'api';
92
141
  path: string;
@@ -94,6 +143,7 @@ export interface ApiRouteDecl {
94
143
  filePath: string;
95
144
  importPath: string;
96
145
  }
146
+ /** One page route declaration in the generated entry descriptor. */
97
147
  export interface PageRouteDecl {
98
148
  kind: 'page';
99
149
  path: string;
@@ -104,18 +154,40 @@ export interface PageRouteDecl {
104
154
  importPath: string;
105
155
  isDynamic?: boolean;
106
156
  paramNames?: string[];
157
+ streamManifest?: StreamRouteManifest;
107
158
  }
159
+ /** One island the build admits: tag, module path, and delivery facts. */
108
160
  export interface IslandDecl {
109
161
  tagName: string;
110
162
  modulePath: string;
111
163
  isPackage?: boolean;
112
- hydrate?: HydrationStrategy;
164
+ /**
165
+ * Optional named export to register as the custom element constructor.
166
+ * Set for package islands from the manifest declaration's `className`
167
+ * (the CEM-derived export class name), so the client island factory can
168
+ * read `mod[exportName]` after #638 removed `export default` from UI
169
+ * component chunks. Absent for local/route islands (which use default).
170
+ */
171
+ exportName?: string;
172
+ hydrate?: IslandDeliveryStrategy;
113
173
  ssr?: boolean;
114
174
  dsd?: boolean;
115
175
  authoring?: 'basic-element' | 'third-party-wc';
116
176
  source?: 'local' | 'package' | 'nested';
117
177
  reason?: string;
118
178
  }
179
+ /**
180
+ * Build-host-only compiled component reached through a route's local import
181
+ * graph. These components participate in recursive SSR/SSG expansion but are
182
+ * not client islands and therefore add no hydration or browser entry.
183
+ */
184
+ export interface StaticComponentDecl {
185
+ tagName: string;
186
+ modulePath: string;
187
+ /** Compiler-owned interaction events; empty means no inferred browser entry. */
188
+ compilerInteractionEvents: string[];
189
+ }
190
+ /** The build-time SSR admission decisions per component tag. */
119
191
  export interface SsrAdmissionPlan {
120
192
  renderableTags: string[];
121
193
  clientOnlyTags: string[];
@@ -123,213 +195,307 @@ export interface SsrAdmissionPlan {
123
195
  reasons: Record<string, string>;
124
196
  decisions: SsrAdmissionDecision[];
125
197
  cemClassifications?: CompatibilityClassification[];
126
- }
198
+ /**
199
+ * #979: foreign custom-element tags discovered in page /
200
+ * island JSX that are neither local islands, package-manifest islands, nor
201
+ * openElement-authored elements. Visibility only — each tag also carries a
202
+ * source:'foreign' decision (renderPath 'client-only') and the SSR/behavior
203
+ * is unchanged (opaque passthrough).
204
+ */
205
+ foreignTags?: string[];
206
+ }
207
+ /** One page renderer module registration. */
127
208
  export interface RendererDecl {
128
209
  varName: string;
129
210
  scope: string;
130
211
  importPath: string;
131
212
  depth: number;
132
213
  }
214
+ /** The scope one middleware applies to (all routes or a named route set). */
133
215
  export interface MiddlewareScopeDecl {
134
216
  varName: string;
135
217
  scope: string;
136
218
  importPath: string;
137
219
  }
220
+ /** The document-level facts a build bakes into the generated entry. */
138
221
  export interface DocumentConfig {
139
222
  lang: string;
140
223
  title: string;
141
224
  headExtras: string;
142
225
  allowHeadExtrasScripts: boolean;
143
226
  }
227
+ /** The app shell module a build resolves: tag, import path, and serialized props. */
144
228
  export interface AppShellDecl {
145
229
  tagName: string;
146
230
  importPath: string;
147
231
  props: Record<string, unknown>;
148
232
  }
233
+ /** The resolved shell for one plan slot: disabled (false) or a full declaration. */
149
234
  export type ResolvedAppShell = false | AppShellDecl;
235
+ /** The resolved app shells a build ships: the default shell plus named layouts. */
150
236
  export interface AppShellPlan {
151
237
  default: ResolvedAppShell;
152
238
  layouts: Record<string, ResolvedAppShell>;
153
239
  }
240
+ /** The full build-time description of one generated entry: routes, islands, renderers, middleware, document, and app-shell plans. */
154
241
  export interface EntryDescriptor {
155
242
  isSSG: boolean;
243
+ /**
244
+ * Page renderer selection (#1339). Absent/'native' keeps the
245
+ * compiled renderDsd page path byte-identical; 'lit' forks page tag
246
+ * resolution, page SSR and the client entry onto @lit-labs/ssr.
247
+ * Loader/action/protocol codegen never forks.
248
+ */
249
+ renderer?: 'native' | 'lit';
156
250
  imports: ImportDecl[];
157
251
  middleware: MiddlewareDecl[];
252
+ /**
253
+ * `middleware.use` fetch middleware module paths (#858),
254
+ * in user-configured order. The entry renderer emits one
255
+ * `import * as __mw_N from '<path>'` per entry and composes each module's
256
+ * default export around the exported handler in onion order. Absent/empty
257
+ * when the app configures no fetch middleware, keeping the generated entry
258
+ * byte-identical to pre-#858 output.
259
+ */
260
+ fetchMiddleware?: string[];
158
261
  apiRoutes: ApiRouteDecl[];
159
262
  pageRoutes: PageRouteDecl[];
263
+ staticComponents: StaticComponentDecl[];
160
264
  islands: IslandDecl[];
265
+ /**
266
+ * True when any page route carries data-open-enhance forms (#569). Drives
267
+ * the dev island client script injection (#951): an island-free app with
268
+ * enhanced forms still needs the client entry in dev HTML.
269
+ */
270
+ hasEnhancedForms?: boolean;
161
271
  ssrAdmissionPlan: SsrAdmissionPlan;
162
272
  cemClassifications?: CompatibilityClassification[];
163
- clientOnlyTags?: string[];
164
273
  renderers: RendererDecl[];
165
274
  middlewareScopes: MiddlewareScopeDecl[];
166
275
  document: DocumentConfig;
167
276
  appShell: AppShellPlan;
168
277
  upgradeStrategy?: HydrationStrategy;
169
- debugRoutes?: Array<{
170
- path: string;
171
- type: string;
172
- }>;
278
+ /**
279
+ * Declared project locales. Absent for a single-locale site: the generated
280
+ * entry then emits no locale prefixes and the default-locale fallback, which
281
+ * is byte-identical to pre-i18n output.
282
+ */
283
+ i18n?: {
284
+ locales: string[];
285
+ defaultLocale: string;
286
+ };
173
287
  }
174
- /** Per-page render diagnostics returned by renderRoute() */ export interface SsgPageOutput {
175
- /** Rendered HTML string */ html: string;
176
- /** Render errors collected during rendering */ errors: RenderError[];
177
- /** Hydration hints collected during rendering */ hydrationHints: HydrationHint[];
178
- /** Number of DSD components rendered on this page */ componentCount: number;
179
- /** Total render time for all components on this page (ms) */ renderTimeMs: number;
288
+ /** Per-page render diagnostics returned by renderRoute() */
289
+ export interface SsgPageOutput {
290
+ /** Rendered HTML string */
291
+ html: string;
292
+ /**
293
+ * HTTP status for the rendered page. Undefined on the success path;
294
+ * set for redirect (3xx), not-found (404) and render-failure (500) results.
295
+ */
296
+ status?: number;
297
+ /**
298
+ * Redirect outcome (3xx). When set, `html` holds an interim status page and
299
+ * the result must not be persisted as a normal 200 page.
300
+ */
301
+ redirect?: {
302
+ location: string;
303
+ status: number;
304
+ };
305
+ /** True when the route signalled not-found (404). */
306
+ notFound?: boolean;
307
+ /** Render errors collected during rendering */
308
+ errors: RenderError[];
309
+ /** Number of DSD components rendered on this page */
310
+ componentCount: number;
311
+ /** Total render time for all components on this page (ms) */
312
+ renderTimeMs: number;
180
313
  }
314
+ /**
315
+ * A single route metadata entry emitted as `routeInfo` by the generated SSG
316
+ * entry module (see entry-render-ssg.ts).
317
+ */
318
+ export interface RouteInfoEntry {
319
+ path: string;
320
+ /**
321
+ * Route module file path. Read by the render pipeline: ssg-render.ts copies
322
+ * it into server-manifest.json for request-time (renderIntent 'dynamic')
323
+ * routes.
324
+ */
325
+ filePath?: string;
326
+ tagName: string;
327
+ /** The route module namespace object (typed per-module at codegen time). */
328
+ module?: unknown;
329
+ isDynamic: boolean;
330
+ paramNames: string[];
331
+ /** Rendering mode declared via renderIntent.mode ("static" when unset; the "auto" alias is rejected, #609). */
332
+ rendering?: string;
333
+ /** True when the route module exports an action (request-time form POST). */
334
+ hasAction?: boolean;
335
+ streamManifest?: StreamRouteManifest;
336
+ params?: Record<string, string>;
337
+ }
338
+ /** The server bundle facts the SSG engine consumes for stream rendering. */
181
339
  export interface SsrBundle {
182
340
  default: unknown;
183
- routeInfo?: Array<{
184
- path: string;
185
- tagName: string;
186
- isDynamic: boolean;
187
- paramNames: string[];
188
- revalidate?: number;
189
- params?: Record<string, string>;
190
- }>;
341
+ routeInfo?: RouteInfoEntry[];
191
342
  renderRoute?: (path: string, opts?: Record<string, unknown>) => Promise<SsgPageOutput>;
192
343
  getStaticPaths?: (path: string) => Promise<Array<Record<string, string>>>;
193
- posts?: unknown[];
194
344
  [key: string]: unknown;
195
345
  }
346
+ /** The per-build render evidence record the SSG engine emits for audit. */
196
347
  export interface SsgRenderEvidence {
197
348
  i18nOptions?: {
198
349
  locales: string[];
199
350
  defaultLocale?: string;
200
351
  [key: string]: unknown;
201
352
  } | null;
202
- localIslandMeta?: Record<string, {
203
- hydrate?: string;
204
- }>;
205
- packageIslandDecls?: IslandDecl[];
206
- packageManifests?: OpenElementPackageManifest[];
353
+ /** SSR admission decisions from the plan that rendered the pages. */
207
354
  admissionDecisions?: SsrAdmissionDecision[];
208
- cemClassifications?: CompatibilityClassification[];
355
+ /** Build-manifest budget thresholds (KB) from the plugin options. */
356
+ manifestBudget?: {
357
+ islandKB?: number;
358
+ totalJsKB?: number;
359
+ pageKB?: number;
360
+ };
209
361
  onPrintBuildManifest?: (input: {
210
362
  root: string;
211
363
  outDir: string;
212
364
  phase: 3;
213
365
  headExtras?: string;
366
+ budget?: {
367
+ islandKB?: number;
368
+ totalJsKB?: number;
369
+ pageKB?: number;
370
+ };
214
371
  }) => void | Promise<void>;
215
- onGenerateSitemap?: (outputDir: string) => void | Promise<void>;
216
372
  }
217
- /** Speculation Rules configuration for SSG post-processing */ export interface SpeculationRulesOptions {
373
+ /** Speculation Rules configuration for SSG post-processing */
374
+ export interface SpeculationRulesOptions {
218
375
  /**
219
376
  * URL patterns to prerender (fully render in background before navigation).
220
- */ prerender?: string[];
377
+ */
378
+ prerender?: string[];
221
379
  /**
222
380
  * URL patterns to prefetch (fetch HTML + resources without rendering).
223
- */ prefetch?: string[];
381
+ */
382
+ prefetch?: string[];
224
383
  /**
225
384
  * URL patterns to exclude from both prefetch and prerender.
226
- */ exclude?: string[];
385
+ */
386
+ exclude?: string[];
227
387
  /**
228
388
  * Eagerness level for prerender rules.
229
389
  * @default 'moderate'
230
- */ eagerness?: 'immediate' | 'moderate' | 'conservative';
231
- }
232
- /** A single route input to the build pipeline. */ export interface BuildRouteInput {
233
- /** Route kind: page or API. */ kind: 'page' | 'api';
234
- /** Route path (e.g. '/about', '/blog/:slug'). */ path: string;
235
- /** Absolute or relative file path of the route module. */ filePath: string;
236
- /** Import specifier used by generated entry code. */ importPath: string;
237
- /** Resolved tag name for page routes. */ tagName?: string;
238
- /** Dynamic segment names. */ paramNames?: string[];
239
- /** Static generation params produced by getStaticPaths(). */ staticParams?: Array<Record<string, string>>;
240
- }
241
- /** A single island input to the build pipeline. */ export interface BuildIslandInput {
390
+ */
391
+ eagerness?: 'immediate' | 'moderate' | 'conservative';
392
+ }
393
+ /** A single route input to the build pipeline. */
394
+ export interface BuildRouteInput {
395
+ /** Route kind: page or API. */
396
+ kind: 'page' | 'api';
397
+ /** Route path (e.g. '/about', '/blog/:slug'). */
398
+ path: string;
399
+ /** Absolute or relative file path of the route module. */
400
+ filePath: string;
401
+ /** Import specifier used by generated entry code. */
402
+ importPath: string;
403
+ /** Resolved tag name for page routes. */
404
+ tagName?: string;
405
+ /** Dynamic segment names. */
406
+ paramNames?: string[];
407
+ /** Static generation params produced by getStaticPaths(). */
408
+ staticParams?: Array<Record<string, string>>;
409
+ }
410
+ /** A single island input to the build pipeline. */
411
+ export interface BuildIslandInput {
242
412
  tagName: string;
243
413
  modulePath: string;
244
414
  isPackage?: boolean;
245
- hydrate?: HydrationStrategy;
415
+ hydrate?: IslandDeliveryStrategy;
246
416
  ssr?: boolean;
247
417
  dsd?: boolean;
248
418
  source?: 'local' | 'package' | 'nested';
249
419
  reason?: string;
250
420
  }
251
- /** Output configuration for the build pipeline. */ export interface BuildOutputOptions {
252
- /** Project root directory. */ root?: string;
253
- /** Output directory relative to root. */ outDir?: string;
254
- /** Base URL path. */ base?: string;
255
- /** If true, emit a client-only SPA bundle instead of SSG. */ spa?: boolean;
421
+ /** Output configuration for the build pipeline. */
422
+ export interface BuildOutputOptions {
423
+ /** Project root directory. */
424
+ root?: string;
425
+ /** Output directory relative to root. */
426
+ outDir?: string;
427
+ /** Base URL path. */
428
+ base?: string;
256
429
  }
257
- /** i18n configuration for the build pipeline. */ export interface BuildI18nOptions {
430
+ /** i18n configuration for the build pipeline. */
431
+ export interface BuildI18nOptions {
258
432
  locales: string[];
259
433
  defaultLocale?: string;
260
434
  }
261
- /** Content/blog configuration for the build pipeline. */ export interface BuildContentOptions {
262
- contentDir?: string;
263
- basePath?: string;
264
- }
265
- /** Package island configuration for the build pipeline. */ export interface BuildPackageIslandOptions {
266
- /** Package names that may expose island declarations. */ packages?: string[];
267
- }
268
- /** Framework-agnostic plan consumed by the OpenElement build pipeline. */ export interface BuildPlan {
269
- /** User-facing framework options. */ options: import('./framework.js').FrameworkOptions;
270
- /** Discovered page and API routes. */ routes: BuildRouteInput[];
271
- /** Discovered local and package islands. */ islands: BuildIslandInput[];
272
- /** Output configuration. */ output: BuildOutputOptions;
273
- /** i18n expansion options. */ i18n?: BuildI18nOptions;
274
- /** Content expansion options. */ content?: BuildContentOptions;
275
- /** Package island discovery options. */ packageIslands?: BuildPackageIslandOptions;
276
- /** Extra evidence passed to the render pipeline. */ evidence?: SsgRenderEvidence;
277
- }
278
- /** A single generated HTML page artifact. */ export interface BuildPageArtifact {
435
+ /** Package island configuration for the build pipeline. */
436
+ export interface BuildPackageIslandOptions {
437
+ /** Package names that may expose island declarations. */
438
+ packages?: string[];
439
+ }
440
+ /** Framework-agnostic plan consumed by the OpenElement build pipeline. */
441
+ export interface BuildPlan {
442
+ /** User-facing framework options. */
443
+ options: FrameworkOptions;
444
+ /** Discovered page and API routes. */
445
+ routes: BuildRouteInput[];
446
+ /** Discovered local and package islands. */
447
+ islands: BuildIslandInput[];
448
+ /** Output configuration. */
449
+ output: BuildOutputOptions;
450
+ /** i18n expansion options. */
451
+ i18n?: BuildI18nOptions;
452
+ /** Package island discovery options. */
453
+ packageIslands?: BuildPackageIslandOptions;
454
+ }
455
+ /** A single generated HTML page artifact. */
456
+ export interface BuildPageArtifact {
279
457
  path: string;
280
458
  html: string;
281
- /** Errors collected while rendering this page. */ errors: Array<{
459
+ /** Errors collected while rendering this page. */
460
+ errors: Array<{
282
461
  message: string;
283
462
  route?: string;
284
463
  }>;
285
464
  }
286
- /** Manifest produced by the build pipeline. */ export interface BuildManifestArtifact {
465
+ /** Manifest produced by the build pipeline. */
466
+ export interface BuildManifestArtifact {
287
467
  routes: Array<{
468
+ kind: 'page' | 'api';
288
469
  path: string;
289
470
  tagName?: string;
290
471
  isDynamic: boolean;
291
472
  }>;
292
473
  islands: BuildIslandInput[];
474
+ /**
475
+ * Paths served at request time (renderIntent mode 'dynamic').
476
+ * Absent for pure-static builds.
477
+ */
478
+ requestTimeRoutes?: string[];
293
479
  }
294
- /** A single client asset emitted by the build pipeline. */ export interface BuildClientAsset {
480
+ /** A single client asset emitted by the build pipeline. */
481
+ export interface BuildClientAsset {
295
482
  fileName: string;
296
483
  source: string | Uint8Array;
297
484
  sizeBytes: number;
298
485
  }
299
- /** Result returned by the OpenElement build pipeline. */ export interface BuildArtifacts {
300
- /** Generated HTML pages. */ pages: BuildPageArtifact[];
301
- /** Build manifest. */ manifest: BuildManifestArtifact;
302
- /** Client-side assets (island bundles, CSS, etc). */ clientAssets: BuildClientAsset[];
303
- /** Non-fatal warnings. */ warnings: string[];
304
- /** Fatal errors. */ errors: string[];
305
- /** Whether the build succeeded. */ success: boolean;
306
- }
307
- /** Build function contract implemented by adapter-agnostic SSG engines. */ export type OpenElementBuild = (plan: BuildPlan) => Promise<BuildArtifacts>;
308
- /** A resolved specifier target. */ export interface ResolvedSpecifier {
309
- /** Final specifier to use in generated code or import map. */ specifier: string;
310
- /** True if the specifier points to a remote (https://) source. */ isRemote: boolean;
311
- /** Optional local file system path when resolved to disk. */ filePath?: string;
312
- }
313
- /** Input to the OpenElement package resolver. */ export interface PackageResolverInput {
314
- /** The import specifier to resolve, e.g. '@openelement/core/logger'. */ id: string;
315
- /** The module requesting the resolution, if any. */ importer?: string;
316
- /** Workspace root directory, when running inside a Deno workspace. */ workspaceRoot?: string | null;
317
- /** Local monorepo root for source fallback. */ localPackageRoot?: string | null;
318
- /** Package version to use for remote registry resolution. */ version?: string;
319
- /** Registry mode. 'npm' uses node_modules; 'jsr' fetches remote source. */ registry?: 'npm' | 'jsr';
320
- /** User-provided aliases that should take precedence. */ userAliases?: Record<string, string> | Array<{
321
- find: string;
322
- replacement: string;
323
- }> | null;
324
- }
325
- /** Result of resolving an OpenElement package specifier. */ export interface PackageResolverResult {
326
- /** Resolved target, or null if the resolver declined. */ resolution: ResolvedSpecifier | null;
327
- /** Errors if the specifier is known to be invalid. */ errors: string[];
328
- /** Warnings, e.g. deprecated subpaths. */ warnings: string[];
329
- }
330
- /** Contract for an OpenElement package/subpath resolver. */ export type OpenElementPackageResolver = (input: PackageResolverInput) => PackageResolverResult | Promise<PackageResolverResult>;
331
- /** Known OpenElement package name and its exported subpaths. */ export interface OpenElementPackageExports {
332
- packageName: string;
333
- exports: Record<string, string>;
334
- }
335
- /** Registry from package name to exported subpaths. */ export type OpenElementExportMap = Record<string, OpenElementPackageExports>;
486
+ /** Result returned by the OpenElement build pipeline. */
487
+ export interface BuildArtifacts {
488
+ /** Generated HTML pages. */
489
+ pages: BuildPageArtifact[];
490
+ /** Build manifest. */
491
+ manifest: BuildManifestArtifact;
492
+ /** Client-side assets (island bundles, CSS, etc). */
493
+ clientAssets: BuildClientAsset[];
494
+ /** Non-fatal warnings. */
495
+ warnings: string[];
496
+ /** Fatal errors. */
497
+ errors: string[];
498
+ /** Whether the build succeeded. */
499
+ success: boolean;
500
+ }
501
+ //#endregion