@openelement/protocol 1.0.0-alpha.14 → 1.0.0-alpha.15

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.
@@ -3,10 +3,10 @@ import { forbiddenSinkReason, isSafeAttributeName } from "./forbidden-sinks.js";
3
3
  import { VOID_TAGS } from "./void-tags.js";
4
4
  //#region src/part-program.ts
5
5
  /**
6
- * @openelement/element — serializable Part Program v1 protocol.
6
+ * @openelement/element — serializable Part Program v2 protocol.
7
7
  *
8
8
  * The canonical exchange artifact shared by the compiler semantic core, the
9
- * server serializer, fresh DOM creation, and existing-DOM claim. Its only
9
+ * server serializer, fresh DOM creation, and existing-DOM hydration. Its only
10
10
  * imports are the import-free, host-free canonical owners — VOID_TAGS,
11
11
  * forbidden sinks, and the error contract (#1386 item 3); all three are
12
12
  * import-free, so the artifact keeps its freedom from runtime/host edges. The
@@ -15,8 +15,8 @@ import { VOID_TAGS } from "./void-tags.js";
15
15
  * receives a compiler-owned identity. Runtime code does not discover bindings
16
16
  * by walking a VNode or a generic DOM tree.
17
17
  */
18
- /** The Part Program IR version this package defines (currently v1). */
19
- const PART_PROGRAM_VERSION = 1;
18
+ /** The Part Program IR version this package defines (currently v2). */
19
+ const PART_PROGRAM_VERSION = 2;
20
20
  /**
21
21
  * Version of the compiled-module ABI: the statics a generated module carries
22
22
  * (`__partProgram`, `__compiledProperties`, `__elementMetadata`,
@@ -32,7 +32,7 @@ const PART_PROGRAM_VERSION = 1;
32
32
  */
33
33
  const COMPILED_MODULE_ABI_VERSION = 2;
34
34
  /**
35
- * Operator/literal compatibility for when-Region tests (issue #1372). Both
35
+ * Operator/literal compatibility for when-Block tests (issue #1372). Both
36
36
  * wire validators (this module and the server serializer's shared validator)
37
37
  * close the space through this one predicate:
38
38
  * - ordering operators require a finite numeric literal;
@@ -63,7 +63,7 @@ function partAnchorEndMarker(index) {
63
63
  }
64
64
  /**
65
65
  * The one `<style>` element the server serializer emits as the first DSD
66
- * template child when the class carries static styles (renderDsd
66
+ * template child when the class carries static styles (renderToString
67
67
  * parity — pages never upgrade, so their styles must ship in the payload).
68
68
  * The claim path skips exactly this marked node; a marked node on a
69
69
  * style-less class is claim drift and fails closed.
@@ -85,14 +85,14 @@ const DATA_OE_LIGHT = "data-oe-light";
85
85
  * one catchable error type with one stable code.
86
86
  */
87
87
  function fail(reason) {
88
- raiseFrameworkError("validation", ProgramErrorCode.INVALID_PROGRAM, `[compiled-program] invalid Part Program v1: ${reason}`);
88
+ raiseFrameworkError("validation", ProgramErrorCode.INVALID_PROGRAM, `[compiled-program] invalid Part Program v2: ${reason}`);
89
89
  }
90
90
  function isRecord(value) {
91
91
  return typeof value === "object" && value !== null && !Array.isArray(value);
92
92
  }
93
93
  function validateKeys(value, allowed, where) {
94
94
  const keys = new Set(allowed);
95
- for (const key of Object.keys(value)) if (!keys.has(key)) fail(`${where}.${key} is not part of Part Program v1`);
95
+ for (const key of Object.keys(value)) if (!keys.has(key)) fail(`${where}.${key} is not part of Part Program v2`);
96
96
  }
97
97
  function isIntegerArray(value) {
98
98
  return Array.isArray(value) && value.every((entry) => Number.isInteger(entry) && entry >= 0);
@@ -257,18 +257,62 @@ function validateItemValueFields(nodes, field, where) {
257
257
  if (node.k === "el") validateItemValueFields(node.children, field, `${where}[${position}].children`);
258
258
  });
259
259
  }
260
- function validatePartPath(template, path, where, elementIds) {
261
- if (!isIntegerArray(path) || path.length === 0) fail(`${where}.path must target an element`);
262
- let nodes = template;
260
+ /** Non-throwing walk of one node list: the node a fixed-Part path lands on. */
261
+ function probePath(nodes, path) {
262
+ let list = nodes;
263
263
  let node;
264
264
  for (const index of path) {
265
- node = nodes[index];
266
- if (!node) fail(`${where}.path [${path.join(",")}] is unresolved`);
267
- nodes = node.k === "el" ? node.children : [];
265
+ node = list[index];
266
+ if (!node) return void 0;
267
+ list = node.k === "el" ? node.children : [];
268
268
  }
269
- if (!node || node.k !== "el") fail(`${where}.path must target an element`);
270
- if (!elementIds.has(node.id)) fail(`${where}.path targets an unknown element`);
271
- return node.id;
269
+ return node;
270
+ }
271
+ /**
272
+ * True when `path` resolves within some when-Block branch tree to the element
273
+ * `nodeId` names — the branch-sink attribution test. Element ids are globally
274
+ * unique across the template and every branch tree, so the id match is exact:
275
+ * the same branch-relative suffix can exist in both branches, but only the
276
+ * owning branch's element carries the sink's location node id.
277
+ */
278
+ function branchTreeOwnsPath(parts, path, nodeId) {
279
+ for (const part of parts) {
280
+ if (part.k !== "when") continue;
281
+ for (const tree of [part.on, part.off]) {
282
+ const node = probePath(tree, path);
283
+ if (node && node.k === "el" && node.id === nodeId) return node;
284
+ }
285
+ }
286
+ }
287
+ /**
288
+ * Where one fixed Part's path lives: on the main template (anchor-precedence
289
+ * rules apply) or inside a when-Block branch (branch-relative; the branch
290
+ * tree holds no anchors by construction, so precedence is structural).
291
+ * Fail-closed on every shape that resolves to neither. `nodeId` is validated
292
+ * present for sink locations by {@linkcode validateLocation} before this runs;
293
+ * the guard keeps the optional wire shape honest.
294
+ */
295
+ function validateFixedPartTarget(template, parts, path, where, nodeId, allowBranch) {
296
+ if (nodeId === void 0) fail(`${where} location node is invalid`);
297
+ if (!isIntegerArray(path) || path.length === 0) fail(`${where}.path must target an element`);
298
+ const templateNode = probePath(template, path);
299
+ if (templateNode && templateNode.k === "el" && templateNode.id === nodeId) {
300
+ validateFixedPartPath(template, path, where);
301
+ return {
302
+ site: "template",
303
+ node: templateNode
304
+ };
305
+ }
306
+ if (allowBranch) {
307
+ const branchNode = branchTreeOwnsPath(parts, path, nodeId);
308
+ if (branchNode) return {
309
+ site: "branch",
310
+ node: branchNode
311
+ };
312
+ } else if (branchTreeOwnsPath(parts, path, nodeId)) fail(`${where} targets a Block-branch element; events and refs stay outside blocks`);
313
+ if (!templateNode) fail(`${where}.path [${path.join(",")}] is unresolved`);
314
+ if (templateNode.k !== "el") fail(`${where}.path must target an element`);
315
+ fail(`${where} location node does not match path`);
272
316
  }
273
317
  function validateAnchorPath(template, path, partIndex, where) {
274
318
  if (!isIntegerArray(path) || path.length === 0) fail(`${where}.path must target a template anchor`);
@@ -295,7 +339,7 @@ function validateFixedPartPath(template, path, where) {
295
339
  function hasSignal(part) {
296
340
  return part.k === "text" || part.k === "prop" || part.k === "attr" || part.k === "bool" || part.k === "class" || part.k === "style" || part.k === "html" || part.k === "when" || part.k === "each";
297
341
  }
298
- function isRegion(part) {
342
+ function isBlock(part) {
299
343
  return part.k === "when" || part.k === "each";
300
344
  }
301
345
  function validateEventAction(value, where) {
@@ -331,7 +375,7 @@ function validateEventAction(value, where) {
331
375
  fail(`${where} has unknown action kind ${value.kind}`);
332
376
  }
333
377
  /**
334
- * Validate an unknown value as a Part Program v1. The validator is intentionally
378
+ * Validate an unknown value as a Part Program v2. The validator is intentionally
335
379
  * strict: unknown instruction kinds, missing ownership records and unsafe paths
336
380
  * fail before a runtime can guess at their meaning.
337
381
  */
@@ -343,13 +387,13 @@ function validatePartProgram(raw) {
343
387
  "root",
344
388
  "template",
345
389
  "parts",
346
- "regions",
390
+ "blocks",
347
391
  "dependencies",
348
392
  "locations",
349
393
  "sourceMap",
350
394
  "metadata"
351
395
  ], "program");
352
- if (raw.version !== 1) fail("version must be 1");
396
+ if (raw.version !== 2) fail(`version must be 2 (got ${JSON.stringify(raw.version)}): regenerate the program with the current compiler; v1 artifacts are refused, never coerced`);
353
397
  if (typeof raw.tag !== "string" || !/^[a-z][a-z0-9]*(-[a-z0-9]+)+$/.test(raw.tag)) fail("tag must be a custom-element tag name");
354
398
  if (!isRecord(raw.root) || raw.root.id !== "root") fail("root must be a root record");
355
399
  validateKeys(raw.root, [
@@ -368,6 +412,7 @@ function validatePartProgram(raw) {
368
412
  if (!Array.isArray(raw.parts)) fail("parts must be an array");
369
413
  const parts = raw.parts;
370
414
  const anchorPartCounts = /* @__PURE__ */ new Map();
415
+ const branchOwnedParts = /* @__PURE__ */ new Set();
371
416
  parts.forEach((part, position) => {
372
417
  if (!isRecord(part)) fail(`parts[${position}] must be an object`);
373
418
  if (part.index !== position) fail(`parts[${position}].index must equal its position`);
@@ -405,7 +450,7 @@ function validatePartProgram(raw) {
405
450
  }
406
451
  if ((part.k === "attr" || part.k === "bool") && !isAttributeName(part.name)) fail(`parts[${position}] ${part.k} name is unsafe`);
407
452
  if (part.location.kind !== "sink") fail(`parts[${position}] ${part.k} must own a sink`);
408
- if (validatePartPath(raw.template, part.path, `parts[${position}]`, elementIds) !== part.location.node) fail(`parts[${position}] location node does not match path`);
453
+ if (validateFixedPartTarget(raw.template, parts, part.path, `parts[${position}]`, part.location.node, true).site === "branch") branchOwnedParts.add(part.index);
409
454
  if (!samePath(part.location.path, part.path)) fail(`parts[${position}] location path does not match path`);
410
455
  break;
411
456
  case "class":
@@ -418,7 +463,7 @@ function validatePartProgram(raw) {
418
463
  "location"
419
464
  ], `parts[${position}]`);
420
465
  if (!isIdentifier(part.signal) || part.location.kind !== "sink") fail(`parts[${position}] ${part.k} is invalid`);
421
- if (validatePartPath(raw.template, part.path, `parts[${position}]`, elementIds) !== part.location.node) fail(`parts[${position}] location node does not match path`);
466
+ if (validateFixedPartTarget(raw.template, parts, part.path, `parts[${position}]`, part.location.node, true).site === "branch") branchOwnedParts.add(part.index);
422
467
  if (!samePath(part.location.path, part.path)) fail(`parts[${position}] location path does not match path`);
423
468
  break;
424
469
  case "html": {
@@ -430,15 +475,9 @@ function validatePartProgram(raw) {
430
475
  "location"
431
476
  ], `parts[${position}]`);
432
477
  if (!isIdentifier(part.signal) || part.location.kind !== "sink") fail(`parts[${position}] html is invalid`);
433
- if (validatePartPath(raw.template, part.path, `parts[${position}]`, elementIds) !== part.location.node) fail(`parts[${position}] location node does not match path`);
434
- if (!samePath(part.location.path, part.path)) fail(`parts[${position}] location path does not match path`);
435
- let htmlTarget;
436
- let htmlNodes = raw.template;
437
- for (const pathIndex of part.path) {
438
- htmlTarget = htmlNodes[pathIndex];
439
- htmlNodes = htmlTarget?.k === "el" ? htmlTarget.children : [];
440
- }
441
- if (htmlTarget?.k !== "el" || htmlTarget.children.length > 0) fail(`parts[${position}] html sink target must be a childless element`);
478
+ const htmlTarget = validateFixedPartTarget(raw.template, parts, part.path, `parts[${position}]`, part.location.node, true);
479
+ if (htmlTarget.site === "branch") branchOwnedParts.add(part.index);
480
+ if (htmlTarget.node.children.length > 0) fail(`parts[${position}] html sink target must be a childless element`);
442
481
  break;
443
482
  }
444
483
  case "ref":
@@ -450,7 +489,7 @@ function validatePartProgram(raw) {
450
489
  "location"
451
490
  ], `parts[${position}]`);
452
491
  if (!isIdentifier(part.ref) || part.location.kind !== "sink") fail(`parts[${position}] ref is invalid`);
453
- if (validatePartPath(raw.template, part.path, `parts[${position}]`, elementIds) !== part.location.node) fail(`parts[${position}] location node does not match path`);
492
+ validateFixedPartTarget(raw.template, parts, part.path, `parts[${position}]`, part.location.node, false);
454
493
  if (!samePath(part.location.path, part.path)) fail(`parts[${position}] location path does not match path`);
455
494
  break;
456
495
  case "event":
@@ -467,7 +506,7 @@ function validatePartProgram(raw) {
467
506
  if (!/^[a-z][a-z0-9:-]*$/.test(part.event)) fail(`parts[${position}] event name is unsafe`);
468
507
  validateEventAction(part.action, `parts[${position}].action`);
469
508
  if (part.location.kind !== "sink") fail(`parts[${position}] event must own a sink`);
470
- if (validatePartPath(raw.template, part.path, `parts[${position}]`, elementIds) !== part.location.node) fail(`parts[${position}] event location node does not match path`);
509
+ validateFixedPartTarget(raw.template, parts, part.path, `parts[${position}]`, part.location.node, false);
471
510
  if (!samePath(part.location.path, part.path)) fail(`parts[${position}] location path does not match path`);
472
511
  break;
473
512
  case "when":
@@ -484,8 +523,8 @@ function validatePartProgram(raw) {
484
523
  if (part.location.kind !== "anchor") fail(`parts[${position}] when must own an anchor`);
485
524
  validateCondition(part.test, `parts[${position}].test`);
486
525
  if (part.test.signal !== part.signal) fail(`parts[${position}] test signal mismatch`);
487
- validateTreeNodes(part.on, `parts[${position}].on`, false, false, elementIds, /* @__PURE__ */ new Map(), elementLocations, [], []);
488
- validateTreeNodes(part.off, `parts[${position}].off`, false, false, elementIds, /* @__PURE__ */ new Map(), elementLocations, [], []);
526
+ validateTreeNodes(part.on, `parts[${position}].on`, false, false, elementIds, /* @__PURE__ */ new Map(), elementLocations, [], [0]);
527
+ validateTreeNodes(part.off, `parts[${position}].off`, false, false, elementIds, /* @__PURE__ */ new Map(), elementLocations, [], [0]);
489
528
  validateAnchorPath(raw.template, part.location.path, position, `parts[${position}]`);
490
529
  anchorPartCounts.set(position, (anchorPartCounts.get(position) ?? 0) + 1);
491
530
  break;
@@ -528,36 +567,37 @@ function validatePartProgram(raw) {
528
567
  });
529
568
  for (const part of parts) {
530
569
  if (part.k === "text" || part.k === "when" || part.k === "each") continue;
570
+ if (branchOwnedParts.has(part.index)) continue;
531
571
  validateFixedPartPath(raw.template, part.path, `parts[${part.index}]`);
532
572
  }
533
573
  for (const [index, id] of anchorIds) {
534
574
  const part = parts[index];
535
- if (!part || !isRegion(part) && part.k !== "text") fail(`anchor ${id} must reference a text or Region part`);
575
+ if (!part || !isBlock(part) && part.k !== "text") fail(`anchor ${id} must reference a text or Block part`);
536
576
  if ((anchorPartCounts.get(index) ?? 0) !== 1) fail(`part ${index} must have exactly one anchor`);
537
577
  }
538
- for (const part of parts) if (isRegion(part) || part.k === "text") {
578
+ for (const part of parts) if (isBlock(part) || part.k === "text") {
539
579
  if (!anchorIds.has(part.index)) fail(`part ${part.index} is missing its template anchor`);
540
580
  } else if (anchorIds.has(part.index)) fail(`fixed part ${part.index} may not have a template anchor`);
541
- if (!Array.isArray(raw.regions)) fail("regions must be an array");
542
- const regions = raw.regions;
543
- const regionParts = parts.filter(isRegion);
544
- if (regions.length !== regionParts.length) fail("regions must describe every Region part exactly once");
545
- regions.forEach((region, position) => {
546
- if (isRecord(region)) validateKeys(region, [
581
+ if (!Array.isArray(raw.blocks)) fail("blocks must be an array");
582
+ const blocks = raw.blocks;
583
+ const blockParts = parts.filter(isBlock);
584
+ if (blocks.length !== blockParts.length) fail("blocks must describe every Block part exactly once");
585
+ blocks.forEach((block, position) => {
586
+ if (isRecord(block)) validateKeys(block, [
547
587
  "id",
548
588
  "index",
549
589
  "kind",
550
590
  "anchor",
551
591
  "end",
552
592
  "source"
553
- ], `regions[${position}]`);
554
- if (!isRecord(region) || region.id !== `r${region.index}` || region.index !== regionParts[position].index || region.kind !== "when" && region.kind !== "each" || region.anchor !== `p${region.index}` || region.end !== `p${region.index}:end` || region.source !== `p${region.index}`) fail(`regions[${position}] has an invalid Region record`);
555
- if (region.kind !== regionParts[position].k) fail(`regions[${position}] kind mismatches its part`);
593
+ ], `blocks[${position}]`);
594
+ if (!isRecord(block) || block.id !== `r${block.index}` || block.index !== blockParts[position].index || block.kind !== "when" && block.kind !== "each" || block.anchor !== `p${block.index}` || block.end !== `p${block.index}:end` || block.source !== `p${block.index}`) fail(`blocks[${position}] has an invalid Block record`);
595
+ if (block.kind !== blockParts[position].k) fail(`blocks[${position}] kind mismatches its part`);
556
596
  });
557
597
  if (!Array.isArray(raw.dependencies)) fail("dependencies must be an array");
558
598
  const dependencies = raw.dependencies;
559
599
  const dependencyOwners = /* @__PURE__ */ new Set();
560
- const expectedDependencyOwners = new Set(parts.filter(hasSignal).map((part) => `${isRegion(part) ? "region" : "part"}:${part.index}`));
600
+ const expectedDependencyOwners = new Set(parts.filter(hasSignal).map((part) => `${isBlock(part) ? "region" : "part"}:${part.index}`));
561
601
  for (const [position, dependency] of dependencies.entries()) {
562
602
  if (!isRecord(dependency) || !isIdentifier(dependency.signal) || !isRecord(dependency.owner)) fail(`dependencies[${position}] is invalid`);
563
603
  validateKeys(dependency, [
@@ -569,7 +609,7 @@ function validatePartProgram(raw) {
569
609
  if (dependency.owner.kind !== "part" && dependency.owner.kind !== "region") fail(`dependencies[${position}].owner.kind is invalid`);
570
610
  if (!Number.isInteger(dependency.owner.index) || dependency.owner.index < 0) fail(`dependencies[${position}].owner.index is invalid`);
571
611
  const owner = parts[dependency.owner.index];
572
- if (!owner || !hasSignal(owner) || (isRegion(owner) ? "region" : "part") !== dependency.owner.kind) fail(`dependencies[${position}] points at a non-signal owner`);
612
+ if (!owner || !hasSignal(owner) || (isBlock(owner) ? "region" : "part") !== dependency.owner.kind) fail(`dependencies[${position}] points at a non-signal owner`);
573
613
  if (owner.signal !== dependency.signal || dependency.location !== owner.location.id) fail(`dependencies[${position}] does not match its owning instruction`);
574
614
  const ownerKey = `${dependency.owner.kind}:${dependency.owner.index}`;
575
615
  if (dependencyOwners.has(ownerKey)) fail(`dependencies duplicate ${ownerKey}`);
@@ -612,10 +652,10 @@ function validatePartProgram(raw) {
612
652
  if (!element || location.tag !== element.tag || !samePath(location.path, element.path)) fail(`locations[${position}] element is invalid`);
613
653
  } else if (location.kind === "anchor") {
614
654
  const part = Number.isInteger(location.part) ? parts[location.part] : void 0;
615
- if (!part || !isRegion(part) && part.k !== "text" || location.id !== `p${location.part}` || !samePath(location.path, part.location.path)) fail(`locations[${position}] anchor is invalid`);
655
+ if (!part || !isBlock(part) && part.k !== "text" || location.id !== `p${location.part}` || !samePath(location.path, part.location.path)) fail(`locations[${position}] anchor is invalid`);
616
656
  } else if (location.kind === "sink") {
617
657
  const part = Number.isInteger(location.part) ? parts[location.part] : void 0;
618
- if (!part || isRegion(part) || part.k === "text" || location.id !== `p${location.part}` || !elementIds.has(location.node) || !samePath(location.path, part.location.path) || part.location.node !== location.node) fail(`locations[${position}] sink is invalid`);
658
+ if (!part || isBlock(part) || part.k === "text" || location.id !== `p${location.part}` || !elementIds.has(location.node) || !samePath(location.path, part.location.path) || part.location.node !== location.node) fail(`locations[${position}] sink is invalid`);
619
659
  } else fail(`locations[${position}] has an unknown kind`);
620
660
  }
621
661
  for (const elementId of elementIds) if (!locationIds.has(elementId)) fail(`missing location for ${elementId}`);
@@ -754,7 +794,7 @@ function validatePartProgram(raw) {
754
794
  "root",
755
795
  ...metadataProperties.map((property) => `property:${property.name}`),
756
796
  ...locations.map((location) => location.id),
757
- ...regions.map((region) => region.id)
797
+ ...blocks.map((block) => block.id)
758
798
  ]);
759
799
  for (const sourceId of expectedSourceIds) if (!sourceIds.has(sourceId)) fail(`sourceMap is missing record ${sourceId}`);
760
800
  }
package/src/policy.d.ts CHANGED
@@ -23,7 +23,7 @@
23
23
  */
24
24
  export declare const STREAM_MAX_FIELDS = 32;
25
25
  /**
26
- * Part/Region owners one stream route's manifest may address in total across
26
+ * Part/Block owners one stream route's manifest may address in total across
27
27
  * all deferred fields.
28
28
  */
29
29
  export declare const STREAM_MAX_OWNERS = 64;
@@ -41,7 +41,7 @@ export declare const STREAM_MAX_SEED_PROPERTIES = 64;
41
41
  */
42
42
  export declare const STREAM_MAX_PAYLOAD_LENGTH: number;
43
43
  /**
44
- * Nested element expansion depth bound for `renderDsd`: cyclic component
44
+ * Nested element expansion depth bound for `renderToString`: cyclic component
45
45
  * composition fails closed instead of recursing without end.
46
46
  */
47
47
  export declare const MAX_COMPOSITION_DEPTH = 8;
package/src/policy.js CHANGED
@@ -23,7 +23,7 @@
23
23
  */
24
24
  const STREAM_MAX_FIELDS = 32;
25
25
  /**
26
- * Part/Region owners one stream route's manifest may address in total across
26
+ * Part/Block owners one stream route's manifest may address in total across
27
27
  * all deferred fields.
28
28
  */
29
29
  const STREAM_MAX_OWNERS = 64;
@@ -41,7 +41,7 @@ const STREAM_MAX_SEED_PROPERTIES = 64;
41
41
  */
42
42
  const STREAM_MAX_PAYLOAD_LENGTH = 262144;
43
43
  /**
44
- * Nested element expansion depth bound for `renderDsd`: cyclic component
44
+ * Nested element expansion depth bound for `renderToString`: cyclic component
45
45
  * composition fails closed instead of recursing without end.
46
46
  */
47
47
  const MAX_COMPOSITION_DEPTH = 8;
package/src/render.d.ts CHANGED
@@ -1,10 +1,11 @@
1
1
  import { ComponentLayer, HydrationStrategy } from "./framework.js";
2
+ import { ErrorPhase } from "./errors.js";
2
3
  //#region src/render.d.ts
3
4
  /** One render failure record the SSR pipeline reports. */
4
5
  export interface RenderError {
5
6
  code: string;
6
7
  severity: 'error' | 'warning';
7
- phase: string;
8
+ phase: ErrorPhase;
8
9
  tagName: string;
9
10
  message: string;
10
11
  recoverable: boolean;
@@ -15,27 +16,6 @@ export interface HydrationHint {
15
16
  layer: ComponentLayer;
16
17
  hydrate?: HydrationStrategy;
17
18
  }
18
- /**
19
- * The public result of one `renderDsd()` call: the serialized DSD `html`, the
20
- * render errors collected while composing it (empty on success), the render
21
- * metrics for the root component, and the hydration hints the client
22
- * scheduler reads to upgrade islands.
23
- */
24
- export interface RenderOutput {
25
- html: string;
26
- errors: RenderError[];
27
- metrics: DsdRenderMetrics;
28
- hydrationHints: HydrationHint[];
29
- }
30
- /** Per-render declarative-shadow-dom metrics the server records. */
31
- export interface DsdRenderMetrics {
32
- tagName: string;
33
- renderTimeMs: number;
34
- templateSize: number;
35
- layer: ComponentLayer;
36
- hasError: boolean;
37
- nestingDepth: number;
38
- }
39
19
  /**
40
20
  * The build's admission verdict for one discovered tag: where the declaration
41
21
  * lives (`modulePath`), how it was discovered (`source`), which render path it
package/src/ssg.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { CompatibilityClassification, FrameworkOptions, HydrationStrategy } from "./framework.js";
2
2
  import { RenderError, SsrAdmissionDecision } from "./render.js";
3
- import { PartProgramV1 } from "./part-program.js";
3
+ import { PartProgramV2 } from "./part-program.js";
4
4
  //#region src/ssg.d.ts
5
5
  /** Build-only route projection bound to a specific compiled page program. */
6
6
  export interface StreamRouteManifest {
@@ -16,7 +16,7 @@ export interface StreamRouteManifest {
16
16
  kind: 'part' | 'region';
17
17
  index: number;
18
18
  location: string;
19
- source: PartProgramV1['sourceMap']['records'][number]['source'];
19
+ source: PartProgramV2['sourceMap']['records'][number]['source'];
20
20
  }>;
21
21
  }>;
22
22
  }
@@ -39,7 +39,7 @@ export interface SsgRenderOptions {
39
39
  nonce?: boolean;
40
40
  };
41
41
  };
42
- upgradeStrategy?: string;
42
+ upgradeStrategy?: HydrationStrategy;
43
43
  viewTransition?: boolean;
44
44
  speculation?: boolean | Record<string, unknown>;
45
45
  islandTagNames?: string[];
@@ -81,11 +81,22 @@ export interface SsgRenderSummary {
81
81
  */
82
82
  warnings: string[];
83
83
  }
84
- /** Client island entry shape passed to entry generator. */
85
- export interface ClientIslandEntry {
84
+ /**
85
+ * Shared island module identity (CL-3 convergence: one base, three shapes). Every island record names the same module the same way — the tag
86
+ * it registers as, the module path that owns it, and whether that module is
87
+ * a package (CEM-derived named export) rather than a local file (default
88
+ * export) — so a rename of the identity touches one declaration, not three.
89
+ * The delivery-strategy fields intentionally stay per-shape (`strategy` on
90
+ * the client entry vs `hydrate` on the build decls): they are different
91
+ * stages' vocabularies, not one field spelled two ways.
92
+ */
93
+ export interface IslandModuleIdentity {
86
94
  tagName: string;
87
95
  modulePath: string;
88
96
  isPackage?: boolean;
97
+ }
98
+ /** Client island entry shape passed to entry generator. */
99
+ export interface ClientIslandEntry extends IslandModuleIdentity {
89
100
  /**
90
101
  * Optional named export to register as the custom element constructor.
91
102
  * When set (package islands whose chunk dropped `export default` per #638),
@@ -155,12 +166,18 @@ export interface PageRouteDecl {
155
166
  isDynamic?: boolean;
156
167
  paramNames?: string[];
157
168
  streamManifest?: StreamRouteManifest;
169
+ /**
170
+ * The server function page fact (alpha15 server lane): the exported server
171
+ * function component the route's `export default definePage(Component)`
172
+ * named — compiled into the module by the server component lane. No element
173
+ * class exists to register; both render channels render through the
174
+ * descriptor's render function (the compiled constructor) and feed the same
175
+ * renderer/layout/document wraps.
176
+ */
177
+ functionPage?: string;
158
178
  }
159
179
  /** One island the build admits: tag, module path, and delivery facts. */
160
- export interface IslandDecl {
161
- tagName: string;
162
- modulePath: string;
163
- isPackage?: boolean;
180
+ export interface IslandDecl extends IslandModuleIdentity {
164
181
  /**
165
182
  * Optional named export to register as the custom element constructor.
166
183
  * Set for package islands from the manifest declaration's `className`
@@ -224,25 +241,25 @@ export interface DocumentConfig {
224
241
  headExtras: string;
225
242
  allowHeadExtrasScripts: boolean;
226
243
  }
227
- /** The app shell module a build resolves: tag, import path, and serialized props. */
228
- export interface AppShellDecl {
244
+ /** The layout module a build resolves: tag, import path, and serialized props. */
245
+ export interface LayoutDecl {
229
246
  tagName: string;
230
247
  importPath: string;
231
248
  props: Record<string, unknown>;
232
249
  }
233
- /** The resolved shell for one plan slot: disabled (false) or a full declaration. */
234
- export type ResolvedAppShell = false | AppShellDecl;
235
- /** The resolved app shells a build ships: the default shell plus named layouts. */
236
- export interface AppShellPlan {
237
- default: ResolvedAppShell;
238
- layouts: Record<string, ResolvedAppShell>;
250
+ /** The resolved layout for one plan slot: disabled (false) or a full declaration. */
251
+ export type ResolvedLayout = false | LayoutDecl;
252
+ /** The resolved layouts a build ships: the default layout plus named layouts. */
253
+ export interface LayoutPlan {
254
+ default: ResolvedLayout;
255
+ layouts: Record<string, ResolvedLayout>;
239
256
  }
240
- /** The full build-time description of one generated entry: routes, islands, renderers, middleware, document, and app-shell plans. */
257
+ /** The full build-time description of one generated entry: routes, islands, renderers, middleware, document, and layout plans. */
241
258
  export interface EntryDescriptor {
242
259
  isSSG: boolean;
243
260
  /**
244
261
  * Page renderer selection (#1339). Absent/'native' keeps the
245
- * compiled renderDsd page path byte-identical; 'lit' forks page tag
262
+ * compiled renderToString page path byte-identical; 'lit' forks page tag
246
263
  * resolution, page SSR and the client entry onto @lit-labs/ssr.
247
264
  * Loader/action/protocol codegen never forks.
248
265
  */
@@ -273,7 +290,7 @@ export interface EntryDescriptor {
273
290
  renderers: RendererDecl[];
274
291
  middlewareScopes: MiddlewareScopeDecl[];
275
292
  document: DocumentConfig;
276
- appShell: AppShellPlan;
293
+ layout: LayoutPlan;
277
294
  upgradeStrategy?: HydrationStrategy;
278
295
  /**
279
296
  * Declared project locales. Absent for a single-locale site: the generated
@@ -329,7 +346,7 @@ export interface RouteInfoEntry {
329
346
  isDynamic: boolean;
330
347
  paramNames: string[];
331
348
  /** Rendering mode declared via renderIntent.mode ("static" when unset; the "auto" alias is rejected, #609). */
332
- rendering?: string;
349
+ rendering?: 'static' | 'dynamic';
333
350
  /** True when the route module exports an action (request-time form POST). */
334
351
  hasAction?: boolean;
335
352
  streamManifest?: StreamRouteManifest;
@@ -408,10 +425,7 @@ export interface BuildRouteInput {
408
425
  staticParams?: Array<Record<string, string>>;
409
426
  }
410
427
  /** A single island input to the build pipeline. */
411
- export interface BuildIslandInput {
412
- tagName: string;
413
- modulePath: string;
414
- isPackage?: boolean;
428
+ export interface BuildIslandInput extends IslandModuleIdentity {
415
429
  hydrate?: IslandDeliveryStrategy;
416
430
  ssr?: boolean;
417
431
  dsd?: boolean;
@@ -1,7 +1,7 @@
1
1
  //#region src/stream-frame-policy.d.ts
2
2
  /**
3
3
  * Streamed-frame admission policy — the canonical deny lists a deferred
4
- * text/Region Part frame must satisfy for the browser installer to accept it.
4
+ * text/Block Part frame must satisfy for the browser installer to accept it.
5
5
  *
6
6
  * This module is import-free and host-free by design (same base-of-graph
7
7
  * contract as forbidden-sinks.ts) and is the single policy source for every
@@ -1,7 +1,7 @@
1
1
  //#region src/stream-frame-policy.ts
2
2
  /**
3
3
  * Streamed-frame admission policy — the canonical deny lists a deferred
4
- * text/Region Part frame must satisfy for the browser installer to accept it.
4
+ * text/Block Part frame must satisfy for the browser installer to accept it.
5
5
  *
6
6
  * This module is import-free and host-free by design (same base-of-graph
7
7
  * contract as forbidden-sinks.ts) and is the single policy source for every
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * In browsers this delegates to the native CSSStyleSheet API. In SSR runtimes
6
6
  * it falls back to a minimal in-memory implementation that exposes the subset
7
- * used by OpenElement and renderDsd().
7
+ * used by OpenElement and renderToString().
8
8
  */
9
9
  export interface StyleSheetRule {
10
10
  cssText: string;
@@ -14,4 +14,48 @@ export interface StyleSheetLike {
14
14
  replaceSync(text: string): void;
15
15
  readonly cssRules: StyleSheetRule[];
16
16
  }
17
+ /**
18
+ * The one key under which a sheet carries its readiness promise: the generated
19
+ * client style adapter records it on the sheet it exports, and the element
20
+ * runtime reads the same key to hand styles to roots that are already
21
+ * connected. Build-time and runtime cannot drift because the adapter generator
22
+ * interpolates this exact name.
23
+ *
24
+ * The promise settles once. Fulfillment means the rules were installed through
25
+ * `replace()`; rejection carries the load or replacement failure and keeps its
26
+ * rejected state — an observer may attach its own catch, it must never convert
27
+ * the promise into a fulfilled one.
28
+ */
29
+ export declare const STYLE_SHEET_READY = "__openElementStyleReady";
30
+ /**
31
+ * The one key under which a sheet carries the URL of the external CSS resource
32
+ * that delivers its rules: the generated client style adapter records the
33
+ * emitted asset URL on the sheet it exports, and the element runtime compares
34
+ * it against the declarative `<link rel="stylesheet" data-oe-static-styles>`
35
+ * nodes an SSR/DSD template already carries (alpha15 S lane). A root whose
36
+ * serialized markup already references the sheet's URL keeps that link as the
37
+ * delivery and does NOT adopt a second constructable copy — one stylesheet
38
+ * resource, one delivery, no duplicate application. Build-time and runtime
39
+ * cannot drift because the adapter generator interpolates this exact name.
40
+ */
41
+ export declare const STYLE_SHEET_URL = "__openElementStyleSheetUrl";
42
+ /**
43
+ * The one key marking a sheet whose bytes are a LIVE resource rather than an
44
+ * immutable one (alpha15 S lane, S-C1.3).
45
+ *
46
+ * The dev server serves an authored sheet from a mutable endpoint that
47
+ * hot-updates: the sheet object is the copy the live resource re-fills through
48
+ * `replace()`, so every root that adopted it re-renders on an edit. A root
49
+ * whose serialized markup declares the same URL therefore still ADOPTS this
50
+ * sheet — the declarative `<link>` stays the first-paint / no-JavaScript
51
+ * delivery, and the adopted object is the one an edit reaches. Without that,
52
+ * a CSS-only edit could only be delivered by re-fetching the link, which is a
53
+ * DOM write this protocol does not perform.
54
+ *
55
+ * Production sheets never carry this key: their URL is content-addressed, so
56
+ * the link and the sheet can never disagree and one delivery is the whole
57
+ * story. Build-time and runtime cannot drift because the dev adapter generator
58
+ * interpolates this exact name.
59
+ */
60
+ export declare const STYLE_SHEET_LIVE = "__openElementStyleSheetLive";
17
61
  //#endregion