@homepages/concrete 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +59 -0
- package/README.md +174 -0
- package/codemods/manifest.json +9 -0
- package/dist/artifact/playground/client/assets/index-BSA1yutg.css +1 -0
- package/dist/artifact/playground/client/assets/index-JloQyj8h.js +1101 -0
- package/dist/artifact/playground/client/index.html +13 -0
- package/dist/artifact/playground/client/island-canvas-host.mjs +1 -0
- package/dist/artifact/playground/host.mjs +127 -0
- package/dist/asset-modules.d.ts +99 -0
- package/dist/base.css +220 -0
- package/dist/browser/site-config.d.ts +18 -0
- package/dist/browser/site-config.js +56 -0
- package/dist/browser/submit-lead.d.ts +98 -0
- package/dist/browser/submit-lead.js +188 -0
- package/dist/browser.d.ts +3 -0
- package/dist/browser.js +4 -0
- package/dist/cli/build/artifact.js +225 -0
- package/dist/cli/build/captures.js +67 -0
- package/dist/cli/build/esbuild.js +127 -0
- package/dist/cli/build/fixtures.js +96 -0
- package/dist/cli/build/icons.js +76 -0
- package/dist/cli/build/index.js +38 -0
- package/dist/cli/build/playground.js +31 -0
- package/dist/cli/build/sections.js +236 -0
- package/dist/cli/build/source.js +62 -0
- package/dist/cli/build/static.js +156 -0
- package/dist/cli/capture/bundle.js +37 -0
- package/dist/cli/capture/capture-browser.js +51 -0
- package/dist/cli/capture/capture.js +121 -0
- package/dist/cli/check/analyze.js +95 -0
- package/dist/cli/check/index.js +19 -0
- package/dist/cli/check/load-workspace.js +119 -0
- package/dist/cli/check/messages.js +16 -0
- package/dist/cli/check/render/class-conflicts.js +39 -0
- package/dist/cli/check/render/html.js +86 -0
- package/dist/cli/check/render/inputs.js +53 -0
- package/dist/cli/check/render/invariants.js +58 -0
- package/dist/cli/check/render/island-frames.js +72 -0
- package/dist/cli/check/render/marker-coverage.js +102 -0
- package/dist/cli/check/render/nav.js +64 -0
- package/dist/cli/check/report.js +73 -0
- package/dist/cli/check/stages/bundles.js +129 -0
- package/dist/cli/check/stages/composition.js +67 -0
- package/dist/cli/check/stages/contracts.js +22 -0
- package/dist/cli/check/stages/dependencies.js +261 -0
- package/dist/cli/check/stages/fixtures.js +74 -0
- package/dist/cli/check/stages/lint.js +41 -0
- package/dist/cli/check/stages/logic.js +63 -0
- package/dist/cli/check/stages/render.js +144 -0
- package/dist/cli/check/stages/sections.js +83 -0
- package/dist/cli/check/stages/stylesheet.js +31 -0
- package/dist/cli/check/stages/typecheck.js +68 -0
- package/dist/cli/check/stages/workspace.js +26 -0
- package/dist/cli/commands.js +342 -0
- package/dist/cli/currency/cache.js +89 -0
- package/dist/cli/currency/decide.js +65 -0
- package/dist/cli/currency/opt-out.js +16 -0
- package/dist/cli/currency/preamble.js +183 -0
- package/dist/cli/currency/prompt.js +28 -0
- package/dist/cli/currency/refresh.js +44 -0
- package/dist/cli/currency/resolve-latest.js +185 -0
- package/dist/cli/currency/version-order.js +38 -0
- package/dist/cli/dev/crop.js +22 -0
- package/dist/cli/dev/hmr.js +26 -0
- package/dist/cli/dev/http.js +129 -0
- package/dist/cli/dev/index.js +70 -0
- package/dist/cli/dev/islands.js +390 -0
- package/dist/cli/dev/load-template.js +46 -0
- package/dist/cli/dev/request-error.js +22 -0
- package/dist/cli/dev/server.js +307 -0
- package/dist/cli/dev/tsconfig-paths.js +95 -0
- package/dist/cli/dev/vite.js +85 -0
- package/dist/cli/dev/workspace-reader.js +274 -0
- package/dist/cli/io.d.ts +14 -0
- package/dist/cli/media/cache.js +125 -0
- package/dist/cli/media/derive.js +252 -0
- package/dist/cli/media/deriver-plugin.js +71 -0
- package/dist/cli/property/index.js +180 -0
- package/dist/cli/property/library.js +137 -0
- package/dist/cli/publish/client.js +119 -0
- package/dist/cli/publish/freshness.js +66 -0
- package/dist/cli/publish/git.js +43 -0
- package/dist/cli/publish/index.js +207 -0
- package/dist/cli/publish/pack.js +78 -0
- package/dist/cli/publish/report.js +98 -0
- package/dist/cli/publish/target.js +87 -0
- package/dist/cli/publish/wire.js +29 -0
- package/dist/cli/tar.js +87 -0
- package/dist/cli/upgrade/codemod.js +56 -0
- package/dist/cli/upgrade/index.js +263 -0
- package/dist/cli/upgrade/manifest.js +72 -0
- package/dist/cli/upgrade/plan.js +68 -0
- package/dist/cli/upgrade/stage.js +71 -0
- package/dist/cli/version.d.ts +12 -0
- package/dist/cli/version.js +15 -0
- package/dist/cli/workspace.js +108 -0
- package/dist/cli.d.ts +6 -0
- package/dist/cli.js +94 -0
- package/dist/css/compile.js +77 -0
- package/dist/css/graph.js +109 -0
- package/dist/css/inline.js +132 -0
- package/dist/css/rules.js +65 -0
- package/dist/design-system/format-variants.js +127 -0
- package/dist/eslint/authoring.js +46 -0
- package/dist/eslint/correctness.js +42 -0
- package/dist/eslint/rules/editor-declaration.js +103 -0
- package/dist/eslint/rules/editor-reason.js +135 -0
- package/dist/eslint/rules/island-imports.js +20 -0
- package/dist/eslint/rules/jsx-visitor.js +20 -0
- package/dist/eslint/rules/no-client-runtime.js +88 -0
- package/dist/eslint/rules/no-editor-globals.js +60 -0
- package/dist/eslint/rules/no-hard-coded-color.js +183 -0
- package/dist/eslint/rules/no-inline-style.js +24 -0
- package/dist/eslint/rules/no-marker-literal.js +37 -0
- package/dist/eslint/rules/no-nondeterminism.js +44 -0
- package/dist/eslint/rules/no-px-breakpoint.js +44 -0
- package/dist/eslint/rules/no-raw-values.js +45 -0
- package/dist/eslint/rules/serializable-props.js +95 -0
- package/dist/eslint.d.ts +6 -0
- package/dist/eslint.js +26 -0
- package/dist/fixtures/brand.d.ts +4 -0
- package/dist/fixtures/brand.js +9 -0
- package/dist/fixtures/bundle-rule.js +67 -0
- package/dist/fixtures/canonical.d.ts +149 -0
- package/dist/fixtures/image-dimensions.js +59 -0
- package/dist/fixtures/load.js +154 -0
- package/dist/fixtures/media-plugin.js +141 -0
- package/dist/fixtures/media.js +165 -0
- package/dist/fixtures/property.js +210 -0
- package/dist/fixtures/resolve.js +202 -0
- package/dist/fixtures/rows.js +108 -0
- package/dist/fixtures/synthesize-empties.js +42 -0
- package/dist/fixtures.d.ts +213 -0
- package/dist/fixtures.js +37 -0
- package/dist/index.d.ts +53 -0
- package/dist/index.js +37 -0
- package/dist/islands/client-module.js +97 -0
- package/dist/islands/marker.d.ts +43 -0
- package/dist/islands/marker.js +44 -0
- package/dist/node_modules/.pnpm/fflate@0.8.3/node_modules/fflate/esm/browser.js +687 -0
- package/dist/packages/external/concrete/package.js +5 -0
- package/dist/packages/internal/fact-interpolation/dist/index.js +22 -0
- package/dist/packages/internal/fill-bake/dist/bake-property-ref.js +111 -0
- package/dist/packages/internal/fill-bake/dist/display.js +9 -0
- package/dist/packages/internal/fill-bake/dist/index.js +6 -0
- package/dist/packages/internal/fill-bake/dist/reconcile-cross-section.js +170 -0
- package/dist/packages/internal/fill-vocabulary/dist/facts.d.ts +32 -0
- package/dist/packages/internal/fill-vocabulary/dist/facts.js +131 -0
- package/dist/packages/internal/fill-vocabulary/dist/row-planners.js +73 -0
- package/dist/packages/internal/format-geometry/dist/capture.js +404 -0
- package/dist/packages/internal/format-geometry/dist/format.d.ts +41 -0
- package/dist/packages/internal/format-geometry/dist/geometry.js +58 -0
- package/dist/packages/internal/format-geometry/dist/index.js +4 -0
- package/dist/packages/internal/image-descriptor/dist/index.d.ts +35 -0
- package/dist/packages/internal/image-ladder/dist/crop.js +82 -0
- package/dist/packages/internal/image-ladder/dist/encode.js +23 -0
- package/dist/packages/internal/image-ladder/dist/index.js +4 -0
- package/dist/packages/internal/image-ladder/dist/policy.js +102 -0
- package/dist/packages/internal/island-runtime/dist/capture-holds.d.ts +13 -0
- package/dist/packages/internal/island-runtime/dist/capture-holds.js +45 -0
- package/dist/packages/internal/island-runtime/dist/contract.d.ts +176 -0
- package/dist/packages/internal/island-runtime/dist/contract.js +94 -0
- package/dist/packages/internal/island-runtime/dist/editor-instance-context.js +15 -0
- package/dist/packages/internal/island-runtime/dist/index.d.ts +103 -0
- package/dist/packages/internal/island-runtime/dist/index.js +163 -0
- package/dist/packages/internal/island-runtime/dist/use-capture-ready.d.ts +19 -0
- package/dist/packages/internal/island-runtime/dist/use-capture-ready.js +39 -0
- package/dist/packages/internal/island-runtime/dist/use-editor.d.ts +22 -0
- package/dist/packages/internal/island-runtime/dist/use-editor.js +54 -0
- package/dist/packages/internal/island-runtime/dist/viewport-schedule.js +105 -0
- package/dist/packages/internal/property-facts/dist/derive-facts-view.js +25 -0
- package/dist/packages/internal/property-facts/dist/index.js +3 -0
- package/dist/packages/internal/property-facts/dist/property-facts-CSdkSuD7.js +181 -0
- package/dist/packages/internal/section-contracts/dist/cap-contract.js +59 -0
- package/dist/packages/internal/section-contracts/dist/catalog.js +102 -0
- package/dist/packages/internal/section-contracts/dist/choose-select-contract.js +24 -0
- package/dist/packages/internal/section-contracts/dist/count-bounds-contract.js +48 -0
- package/dist/packages/internal/section-contracts/dist/display-contract.js +30 -0
- package/dist/packages/internal/section-contracts/dist/display-evidence-contract.js +17 -0
- package/dist/packages/internal/section-contracts/dist/group-contract.js +21 -0
- package/dist/packages/internal/section-contracts/dist/index.js +26 -0
- package/dist/packages/internal/section-contracts/dist/interpolation-contract.js +48 -0
- package/dist/packages/internal/section-contracts/dist/list-fill-contract.js +53 -0
- package/dist/packages/internal/section-contracts/dist/list-scalar-contract.js +70 -0
- package/dist/packages/internal/section-contracts/dist/name-title-contract.js +27 -0
- package/dist/packages/internal/section-contracts/dist/nested-slot-contract.js +12 -0
- package/dist/packages/internal/section-contracts/dist/option-source-contract.js +22 -0
- package/dist/packages/internal/section-contracts/dist/poi-curation-contract.js +18 -0
- package/dist/packages/internal/section-contracts/dist/pooling-field-contract.js +30 -0
- package/dist/packages/internal/section-contracts/dist/record-collection-contract.js +24 -0
- package/dist/packages/internal/section-contracts/dist/row-contract.js +37 -0
- package/dist/packages/internal/section-contracts/dist/row-fill-contract.js +38 -0
- package/dist/packages/internal/section-contracts/dist/runners.js +181 -0
- package/dist/packages/internal/section-contracts/dist/select-contract.js +28 -0
- package/dist/packages/internal/section-contracts/dist/source-contract.js +48 -0
- package/dist/packages/internal/section-contracts/dist/source-filter-contract.js +15 -0
- package/dist/packages/internal/section-contracts/dist/sources-contract.js +28 -0
- package/dist/packages/internal/section-contracts/dist/url-contract.js +20 -0
- package/dist/packages/internal/source-resolution/dist/index.js +222 -0
- package/dist/packages/internal/template-artifact/dist/hash.js +50 -0
- package/dist/packages/internal/template-artifact/dist/index.js +7 -0
- package/dist/packages/internal/template-artifact/dist/layout.js +165 -0
- package/dist/packages/internal/template-artifact/dist/manifest.js +73 -0
- package/dist/packages/internal/template-artifact/dist/sha256.js +138 -0
- package/dist/packages/internal/template-artifact/dist/verify.js +275 -0
- package/dist/packages/internal/template-contracts/dist/collection-editing.js +38 -0
- package/dist/packages/internal/template-contracts/dist/content-categories.d.ts +10 -0
- package/dist/packages/internal/template-contracts/dist/content-categories.js +17 -0
- package/dist/packages/internal/template-contracts/dist/document-value.d.ts +33 -0
- package/dist/packages/internal/template-contracts/dist/facts-view.d.ts +81 -0
- package/dist/packages/internal/template-contracts/dist/facts-view.js +136 -0
- package/dist/packages/internal/template-contracts/dist/layout.js +17 -0
- package/dist/packages/internal/template-contracts/dist/markers.d.ts +40 -0
- package/dist/packages/internal/template-contracts/dist/markers.js +41 -0
- package/dist/packages/internal/template-contracts/dist/poi-row.d.ts +63 -0
- package/dist/packages/internal/template-contracts/dist/select-key.js +13 -0
- package/dist/packages/internal/template-contracts/dist/slot-catalog.d.ts +1112 -0
- package/dist/packages/internal/template-contracts/dist/slot-catalog.js +1109 -0
- package/dist/packages/internal/template-contracts/dist/slot-overrides.js +11 -0
- package/dist/packages/internal/template-contracts/dist/tour-value.d.ts +45 -0
- package/dist/packages/internal/template-contracts/dist/video-value.d.ts +63 -0
- package/dist/playground/host/page-state.js +12 -0
- package/dist/playground/host/paths.js +9 -0
- package/dist/playground/layout.js +24 -0
- package/dist/playground/wire.js +36 -0
- package/dist/playground-island-runtime.d.ts +3 -0
- package/dist/playground-island-runtime.js +4 -0
- package/dist/primitives/FrameShell.d.ts +29 -0
- package/dist/primitives/FrameShell.js +34 -0
- package/dist/primitives/Image.d.ts +119 -0
- package/dist/primitives/Image.js +173 -0
- package/dist/primitives/Section.d.ts +22 -0
- package/dist/primitives/Section.js +26 -0
- package/dist/primitives/Tour.d.ts +43 -0
- package/dist/primitives/Tour.js +72 -0
- package/dist/primitives/Video.d.ts +57 -0
- package/dist/primitives/Video.js +116 -0
- package/dist/primitives/embed-playback.js +50 -0
- package/dist/primitives/index.d.ts +11 -0
- package/dist/primitives/marker-attrs.js +44 -0
- package/dist/primitives/object-fit.js +11 -0
- package/dist/primitives/picture-sources.d.ts +24 -0
- package/dist/primitives/picture-sources.js +52 -0
- package/dist/primitives/probe-context.js +24 -0
- package/dist/primitives/slot-bindings.d.ts +96 -0
- package/dist/primitives/slot-bindings.js +226 -0
- package/dist/primitives/slot-document.d.ts +35 -0
- package/dist/primitives/slot-document.js +37 -0
- package/dist/primitives/slot-group.d.ts +40 -0
- package/dist/primitives/slot-group.js +45 -0
- package/dist/primitives/slot-list.d.ts +21 -0
- package/dist/primitives/slot-list.js +23 -0
- package/dist/primitives/slot-media.d.ts +71 -0
- package/dist/primitives/slot-media.js +98 -0
- package/dist/primitives/slot-scalar.d.ts +53 -0
- package/dist/primitives/slot-scalar.js +98 -0
- package/dist/primitives/slot.d.ts +26 -0
- package/dist/primitives/slot.js +28 -0
- package/dist/rules/registry.js +479 -0
- package/dist/schema/compute.d.ts +22 -0
- package/dist/schema/compute.js +30 -0
- package/dist/schema/define-schema.d.ts +27 -0
- package/dist/schema/define-schema.js +73 -0
- package/dist/schema/extract-fill-spec.js +246 -0
- package/dist/schema/extract-used-facts.js +176 -0
- package/dist/schema/fact.d.ts +65 -0
- package/dist/schema/fact.js +33 -0
- package/dist/schema/fill-builders.d.ts +387 -0
- package/dist/schema/fill-builders.js +263 -0
- package/dist/schema/fill-declaration.d.ts +76 -0
- package/dist/schema/fill-declaration.js +43 -0
- package/dist/schema/fill-spec.d.ts +18 -0
- package/dist/schema/fill-spec.js +170 -0
- package/dist/schema/format-presets.d.ts +27 -0
- package/dist/schema/format-presets.js +76 -0
- package/dist/schema/format.d.ts +22 -0
- package/dist/schema/format.js +40 -0
- package/dist/schema/formats.d.ts +6 -0
- package/dist/schema/formats.js +7 -0
- package/dist/schema/layout.d.ts +32 -0
- package/dist/schema/layout.js +30 -0
- package/dist/schema/manifest.js +300 -0
- package/dist/schema/property-facts.d.ts +83 -0
- package/dist/schema/runtime-values.d.ts +88 -0
- package/dist/schema/section-nav.d.ts +38 -0
- package/dist/schema/section-nav.js +29 -0
- package/dist/schema/section-props.d.ts +98 -0
- package/dist/schema/section-schema.d.ts +53 -0
- package/dist/schema/section-schema.js +54 -0
- package/dist/schema/slot-builders.d.ts +497 -0
- package/dist/schema/slot-builders.js +331 -0
- package/dist/schema/slot-types.d.ts +110 -0
- package/dist/schema/slot-types.js +187 -0
- package/dist/section/declare.d.ts +44 -0
- package/dist/section/declare.js +27 -0
- package/dist/section/discovery.js +76 -0
- package/dist/section/groups.js +74 -0
- package/dist/section/materialize.js +28 -0
- package/dist/section/placements.js +28 -0
- package/dist/section/section.d.ts +69 -0
- package/dist/section/section.js +101 -0
- package/dist/site-analytics.d.ts +1 -0
- package/dist/site-analytics.js +15 -0
- package/dist/site-runtime/analytics.js +97 -0
- package/dist/site-runtime/site-integrations.js +97 -0
- package/dist/styles.css +60 -0
- package/dist/template/define-template.d.ts +139 -0
- package/dist/template/define-template.js +98 -0
- package/dist/template/logic-build.js +191 -0
- package/dist/template/logic-shim.d.ts +43 -0
- package/dist/template/logic-shim.js +52 -0
- package/dist/template/logic-transform.js +92 -0
- package/dist/template/materialize.js +107 -0
- package/dist/template/reconcile.d.ts +67 -0
- package/dist/template/reconcile.js +25 -0
- package/dist/template/running-copy.js +58 -0
- package/guide/reference/cli/INDEX.md +79 -0
- package/guide/reference/cli/build.md +48 -0
- package/guide/reference/cli/check.md +49 -0
- package/guide/reference/cli/dev.md +46 -0
- package/guide/reference/cli/property-add.md +53 -0
- package/guide/reference/cli/property-list.md +46 -0
- package/guide/reference/cli/publish.md +54 -0
- package/guide/reference/cli/upgrade.md +48 -0
- package/guide/reference/rules/INDEX.md +190 -0
- package/package.json +137 -0
- package/tsconfig.base.json +16 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
|
|
3
|
+
//#region ../../internal/image-ladder/dist/policy.js
|
|
4
|
+
const LADDER = [
|
|
5
|
+
320,
|
|
6
|
+
480,
|
|
7
|
+
640,
|
|
8
|
+
768,
|
|
9
|
+
960,
|
|
10
|
+
1200,
|
|
11
|
+
1600,
|
|
12
|
+
2048,
|
|
13
|
+
3400
|
|
14
|
+
];
|
|
15
|
+
const LADDER_CEILING = 3400;
|
|
16
|
+
function rungsFor(intrinsicLongEdge) {
|
|
17
|
+
const effectiveMax = Math.min(intrinsicLongEdge, LADDER_CEILING);
|
|
18
|
+
const below = LADDER.filter((w) => w < effectiveMax);
|
|
19
|
+
return [.../* @__PURE__ */ new Set([...below, effectiveMax])].sort((a, b) => a - b);
|
|
20
|
+
}
|
|
21
|
+
function formatPolicyFor(meta) {
|
|
22
|
+
if (meta.hasAlpha === true || meta.format === "png") return [{
|
|
23
|
+
format: "webp",
|
|
24
|
+
ext: "webp",
|
|
25
|
+
contentType: "image/webp",
|
|
26
|
+
encode: (p) => p.webp({ lossless: true })
|
|
27
|
+
}, {
|
|
28
|
+
format: "png",
|
|
29
|
+
ext: "png",
|
|
30
|
+
contentType: "image/png",
|
|
31
|
+
encode: (p) => p.png()
|
|
32
|
+
}];
|
|
33
|
+
return [
|
|
34
|
+
{
|
|
35
|
+
format: "avif",
|
|
36
|
+
ext: "avif",
|
|
37
|
+
contentType: "image/avif",
|
|
38
|
+
encode: (p) => p.avif({
|
|
39
|
+
quality: 55,
|
|
40
|
+
effort: 4
|
|
41
|
+
})
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
format: "webp",
|
|
45
|
+
ext: "webp",
|
|
46
|
+
contentType: "image/webp",
|
|
47
|
+
encode: (p) => p.webp({ quality: 80 })
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
format: "jpeg",
|
|
51
|
+
ext: "jpg",
|
|
52
|
+
contentType: "image/jpeg",
|
|
53
|
+
encode: (p) => p.jpeg({
|
|
54
|
+
quality: 82,
|
|
55
|
+
mozjpeg: true
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
];
|
|
59
|
+
}
|
|
60
|
+
function ladderVariantKey(sourceKey, edge, format, ext) {
|
|
61
|
+
return `processed/ladder/${createHash("sha256").update(`${sourceKey}|${edge}|${format}`).digest("hex").slice(0, 16)}-w${edge}.${ext}`;
|
|
62
|
+
}
|
|
63
|
+
function encoderSettings(spec) {
|
|
64
|
+
const calls = [];
|
|
65
|
+
const recorder = new Proxy({}, { get: (_target, prop) => (...args) => {
|
|
66
|
+
calls.push(`${String(prop)}(${JSON.stringify(args)})`);
|
|
67
|
+
return recorder;
|
|
68
|
+
} });
|
|
69
|
+
spec.encode(recorder);
|
|
70
|
+
return calls.join(".");
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* A stable digest of every input the derived BYTES depend on: the rung ladder, the
|
|
74
|
+
* ceiling, and each format spec including the encoder settings it actually applies.
|
|
75
|
+
*
|
|
76
|
+
* Independent of how the module was built — no file bytes, no source text — so it
|
|
77
|
+
* is the same number whether this package is imported from its own `dist` or
|
|
78
|
+
* inlined into a published bundle. That is what lets a consumer's derivative cache
|
|
79
|
+
* key on it: change a quality number, a rung or a format list and every entry
|
|
80
|
+
* misses, with nobody having to remember to bump a version constant by hand.
|
|
81
|
+
*
|
|
82
|
+
* Exported separately from the constant below so a test can prove the sensitivity
|
|
83
|
+
* on synthetic specs rather than by editing the real policy.
|
|
84
|
+
*/
|
|
85
|
+
function policyFingerprint(ladder, ceiling, specs) {
|
|
86
|
+
const parts = [
|
|
87
|
+
ladder.join(","),
|
|
88
|
+
String(ceiling),
|
|
89
|
+
...specs.map((s) => [
|
|
90
|
+
s.format,
|
|
91
|
+
s.ext,
|
|
92
|
+
s.contentType,
|
|
93
|
+
encoderSettings(s)
|
|
94
|
+
].join("|"))
|
|
95
|
+
];
|
|
96
|
+
return createHash("sha256").update(parts.join("\n")).digest("hex").slice(0, 16);
|
|
97
|
+
}
|
|
98
|
+
/** The fingerprint of the policy above — every branch of it, both format lists. */
|
|
99
|
+
const LADDER_POLICY_FINGERPRINT = policyFingerprint(LADDER, LADDER_CEILING, [...formatPolicyFor({ format: "jpeg" }), ...formatPolicyFor({ format: "png" })]);
|
|
100
|
+
|
|
101
|
+
//#endregion
|
|
102
|
+
export { LADDER, LADDER_CEILING, LADDER_POLICY_FINGERPRINT, formatPolicyFor, ladderVariantKey, policyFingerprint, rungsFor };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IslandHandle } from "./index.js";
|
|
2
|
+
//#region ../../internal/island-runtime/dist/capture-holds.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Settles when every handle has MOUNTED and every capture hold has been
|
|
5
|
+
* released — the whole readiness a capture host publishes under the capturer's
|
|
6
|
+
* readiness global. Holds registered while the drain is in flight (an island's
|
|
7
|
+
* mount effect runs before its handle's `mounted` settles, but another
|
|
8
|
+
* island's may not have) are drained too. Unbounded by design: the capturer's
|
|
9
|
+
* own per-leg ceiling is the timeout, and it fails naming the leg.
|
|
10
|
+
*/
|
|
11
|
+
declare function islandsCaptureReady(handles: readonly IslandHandle[]): Promise<void>;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { islandsCaptureReady };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ISLAND_CAPTURE_HOLDS_GLOBAL } from "./contract.js";
|
|
2
|
+
|
|
3
|
+
//#region ../../internal/island-runtime/dist/capture-holds.js
|
|
4
|
+
function holdsRegistry() {
|
|
5
|
+
const w = window;
|
|
6
|
+
let holds = w[ISLAND_CAPTURE_HOLDS_GLOBAL];
|
|
7
|
+
if (!holds) {
|
|
8
|
+
holds = /* @__PURE__ */ new Set();
|
|
9
|
+
w[ISLAND_CAPTURE_HOLDS_GLOBAL] = holds;
|
|
10
|
+
}
|
|
11
|
+
return holds;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Take one capture hold. The returned release is idempotent; the hold leaves
|
|
15
|
+
* the registry the moment it is released, so a capturer counting open holds
|
|
16
|
+
* for a diagnostic sees only what is still owed.
|
|
17
|
+
*/
|
|
18
|
+
function takeCaptureHold() {
|
|
19
|
+
const holds = holdsRegistry();
|
|
20
|
+
let release = () => {};
|
|
21
|
+
const hold = new Promise((resolve) => {
|
|
22
|
+
release = resolve;
|
|
23
|
+
});
|
|
24
|
+
holds.add(hold);
|
|
25
|
+
return () => {
|
|
26
|
+
holds.delete(hold);
|
|
27
|
+
release();
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Settles when every handle has MOUNTED and every capture hold has been
|
|
32
|
+
* released — the whole readiness a capture host publishes under the capturer's
|
|
33
|
+
* readiness global. Holds registered while the drain is in flight (an island's
|
|
34
|
+
* mount effect runs before its handle's `mounted` settles, but another
|
|
35
|
+
* island's may not have) are drained too. Unbounded by design: the capturer's
|
|
36
|
+
* own per-leg ceiling is the timeout, and it fails naming the leg.
|
|
37
|
+
*/
|
|
38
|
+
async function islandsCaptureReady(handles) {
|
|
39
|
+
await Promise.all(handles.map((islandHandle) => islandHandle.mounted));
|
|
40
|
+
const holds = holdsRegistry();
|
|
41
|
+
while (holds.size > 0) await Promise.all([...holds]);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
//#endregion
|
|
45
|
+
export { islandsCaptureReady, takeCaptureHold };
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { ComponentType } from "react";
|
|
2
|
+
//#region ../../internal/island-runtime/dist/contract.d.ts
|
|
3
|
+
/** The custom element wrapping an island's server-rendered output. Layout-invisible (`display:contents`). */
|
|
4
|
+
declare const ISLAND_ELEMENT = "tr-island";
|
|
5
|
+
/** Island key on the marker: `<section-key>:<ComponentName>`, e.g. `spw-essential/floorplan:UnitFilter`. */
|
|
6
|
+
declare const ATTR_ISLAND_KEY = "data-tr-island";
|
|
7
|
+
/** Island id on the marker: unique in the document, stable across re-renders of the same island. */
|
|
8
|
+
declare const ATTR_ISLAND_ID = "data-tr-island-id";
|
|
9
|
+
/** On the JSON `<script>` sibling; its value is the island id of the marker the props belong to. */
|
|
10
|
+
declare const ATTR_ISLAND_PROPS = "data-tr-island-props";
|
|
11
|
+
/**
|
|
12
|
+
* Present on a marker holding no server-rendered output — the island mounts fresh
|
|
13
|
+
* instead of hydrating. Value-less: presence is the whole signal.
|
|
14
|
+
*
|
|
15
|
+
* The browser loader decides how to mount a marker before that island's module has
|
|
16
|
+
* loaded, so it cannot ask the module whether it declared `serverFrame = false`. The
|
|
17
|
+
* DOM has to carry the answer, and the marker is the one thing that knows it — an
|
|
18
|
+
* empty marker means there is nothing for React to hydrate against, whatever made it
|
|
19
|
+
* empty.
|
|
20
|
+
*/
|
|
21
|
+
declare const ATTR_ISLAND_FRAMELESS = "data-tr-island-frameless";
|
|
22
|
+
/** Props handed from a server-rendered Renderer to a client component. Strictly JSON-serializable. */
|
|
23
|
+
type IslandProps = Record<string, unknown>;
|
|
24
|
+
/** The window property an editor canvas publishes its {@link EditorBridge} on. Absent on published pages. */
|
|
25
|
+
declare const EDITOR_BRIDGE_PROP = "__trEditorBridge";
|
|
26
|
+
/** The bridge protocol this runtime speaks. See {@link EditorBridge} for the versioning discipline. */
|
|
27
|
+
declare const EDITOR_BRIDGE_PROTOCOL = 1;
|
|
28
|
+
/**
|
|
29
|
+
* The window property holding the page's OPEN capture holds, as a
|
|
30
|
+
* `Set<Promise<void>>`. An island that paints after mount takes a hold (the
|
|
31
|
+
* `useCaptureReady` hook) and the host's readiness promise drains the set —
|
|
32
|
+
* window-level because an island bundle and the page's runtime chunk are
|
|
33
|
+
* separate module graphs, so module state cannot cross between them.
|
|
34
|
+
*/
|
|
35
|
+
declare const ISLAND_CAPTURE_HOLDS_GLOBAL = "__trCaptureHolds";
|
|
36
|
+
/**
|
|
37
|
+
* The current canvas selection as the bridge carries it: document-wide, section
|
|
38
|
+
* instance identity included. A discriminated union rather than flat optionals so
|
|
39
|
+
* a slot selection structurally always carries its slot id.
|
|
40
|
+
*/
|
|
41
|
+
type EditorBridgeSelection = {
|
|
42
|
+
kind: "section";
|
|
43
|
+
instanceId: string;
|
|
44
|
+
} | {
|
|
45
|
+
kind: "slot";
|
|
46
|
+
instanceId: string;
|
|
47
|
+
slotId: string;
|
|
48
|
+
/** For collection slots: the selected item's index. */
|
|
49
|
+
itemIndex?: number;
|
|
50
|
+
/** For a field within that item: the selected field's name. */
|
|
51
|
+
fieldName?: string;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* What `useEditor` hands an island author: the selection scoped to the island's
|
|
55
|
+
* own section instance. Instance identity is resolved by the runtime and never
|
|
56
|
+
* exposed; a selection in any other section instance reads as `null`.
|
|
57
|
+
*/
|
|
58
|
+
type EditorSelection = {
|
|
59
|
+
kind: "section";
|
|
60
|
+
} | {
|
|
61
|
+
kind: "slot";
|
|
62
|
+
slotId: string;
|
|
63
|
+
/** For collection slots: the selected item's index. */
|
|
64
|
+
itemIndex?: number;
|
|
65
|
+
/** For a field within that item: the selected field's name. */
|
|
66
|
+
fieldName?: string;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* The one object an editor canvas publishes for islands, on
|
|
70
|
+
* {@link EDITOR_BRIDGE_PROP}. The host constructs it before hydrating any island;
|
|
71
|
+
* hooks only read it. Publishing a selection change means REPLACING `selection`
|
|
72
|
+
* with a new object (never mutating the current one — subscribers treat the
|
|
73
|
+
* reference as the change signal) and then calling every subscribed listener.
|
|
74
|
+
*
|
|
75
|
+
* An island bundle is immutable once published, so the two sides may only ever
|
|
76
|
+
* diverge additively: bridge fields are added, never changed or removed, and
|
|
77
|
+
* {@link EDITOR_BRIDGE_PROTOCOL} bumps only on an unavoidable break. A hook
|
|
78
|
+
* meeting a bridge with a different protocol degrades to published-page behavior
|
|
79
|
+
* with a console warning — it never throws.
|
|
80
|
+
*/
|
|
81
|
+
interface EditorBridge {
|
|
82
|
+
/** See {@link EDITOR_BRIDGE_PROTOCOL}. */
|
|
83
|
+
protocol: number;
|
|
84
|
+
/** The current selection, or null when nothing is selected. */
|
|
85
|
+
selection: EditorBridgeSelection | null;
|
|
86
|
+
/** Subscribe to selection changes. Returns the unsubscribe. */
|
|
87
|
+
subscribe(listener: () => void): () => void;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* What a `"use client"` island must declare about its editor-canvas behavior.
|
|
91
|
+
* One field, and the switch it names is binary: a live island runs exactly its
|
|
92
|
+
* published behavior in the canvas, a non-live one is its static SSR content.
|
|
93
|
+
* Everything else the canvas needs — shield placement, selection — is derived
|
|
94
|
+
* from the island's own markup or read through `useEditor`, never declared here.
|
|
95
|
+
*
|
|
96
|
+
* An explicit `false` is a decision; a missing field was an accident wearing a
|
|
97
|
+
* decision's clothes.
|
|
98
|
+
*/
|
|
99
|
+
interface IslandEditor {
|
|
100
|
+
/** Hydrate this island in the editor canvas (behind the editor's selection gate). */
|
|
101
|
+
live: boolean;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* The type an island's optional `serverFrame` declaration is checked against, read
|
|
105
|
+
* together with that island's own `editor` declaration.
|
|
106
|
+
*
|
|
107
|
+
* ```tsx
|
|
108
|
+
* import type { IslandEditor, IslandServerFrame } from "@homepages/template-kit";
|
|
109
|
+
*
|
|
110
|
+
* export const editor = { live: true } satisfies IslandEditor;
|
|
111
|
+
* export const serverFrame = false satisfies IslandServerFrame<typeof editor>;
|
|
112
|
+
* ```
|
|
113
|
+
*
|
|
114
|
+
* `serverFrame` answers a different question from `"use client"`: not *does this
|
|
115
|
+
* component's behavior need a browser* — every island's does — but *does it produce
|
|
116
|
+
* meaningful markup when called with no DOM and no effects*. A component that returns
|
|
117
|
+
* its content answers yes and says nothing; one that returns an empty mount element for
|
|
118
|
+
* a library to draw into answers `false`, and the build then omits its implementation
|
|
119
|
+
* from the renderer instead of loading a whole graph to emit an empty box.
|
|
120
|
+
*
|
|
121
|
+
* This type resolves to `true` when `editor.live` is `false`, which makes the one
|
|
122
|
+
* illegal combination a type error: an island with no server frame that also stays
|
|
123
|
+
* static in the canvas is a permanent blank hole — it renders no markup for the editor
|
|
124
|
+
* to show, and nothing hydrates it there to draw any. Validation refuses the same pair
|
|
125
|
+
* at publish, for an island that declared it without this type.
|
|
126
|
+
*/
|
|
127
|
+
type IslandServerFrame<E extends IslandEditor> = E["live"] extends false ? true : boolean;
|
|
128
|
+
/**
|
|
129
|
+
* The RUNTIME's tolerant view of `IslandEditor` — every field optional, `live` included.
|
|
130
|
+
*
|
|
131
|
+
* Deliberately not the same type as the authoring contract. `hydrateIslands` reaches a
|
|
132
|
+
* module through a dynamic `import()` and a cast (runtime.ts): it cannot enforce what
|
|
133
|
+
* the module actually exports, and the published-page path never reads `editor` at all.
|
|
134
|
+
* Requiring `live` here would be an assumption the loader has no way to hold. The
|
|
135
|
+
* authoring requirement is enforced where it can be — the `require-island-editor` lint
|
|
136
|
+
* rule and the registry's ingest validator.
|
|
137
|
+
*/
|
|
138
|
+
type IslandEditorOptions = Partial<IslandEditor>;
|
|
139
|
+
/**
|
|
140
|
+
* A client component's own prop type is the author's business — island props are
|
|
141
|
+
* validated at runtime (serializeIslandProps), not through this alias, and a
|
|
142
|
+
* narrower type here would reject every real component through parameter
|
|
143
|
+
* contravariance.
|
|
144
|
+
*/
|
|
145
|
+
type IslandComponent = ComponentType<any>;
|
|
146
|
+
/** The shape a `"use client"` module must have: a default-exported component, optionally `editor`. */
|
|
147
|
+
interface IslandModule {
|
|
148
|
+
default: IslandComponent;
|
|
149
|
+
editor?: IslandEditorOptions;
|
|
150
|
+
/**
|
|
151
|
+
* See {@link IslandServerFrame}. Optional, and absent is the common answer — an
|
|
152
|
+
* island produces a server-rendered first frame unless it says otherwise. Typed as
|
|
153
|
+
* a bare boolean rather than through `IslandServerFrame` because this is the
|
|
154
|
+
* loader's view of an arbitrary module, which cannot relate two of its exports.
|
|
155
|
+
*/
|
|
156
|
+
serverFrame?: boolean;
|
|
157
|
+
}
|
|
158
|
+
/** A prop that cannot cross the server→browser boundary, or a payload that cannot be read back. */
|
|
159
|
+
declare class IslandPropsError extends Error {
|
|
160
|
+
name: string;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Compose an island id. `scope` is the emitter's per-section-instance identity —
|
|
164
|
+
* without it, two instances of one section on a page collide.
|
|
165
|
+
*/
|
|
166
|
+
declare function islandId(scope: string, islandKey: string, ordinal: number): string;
|
|
167
|
+
/**
|
|
168
|
+
* Validate + encode island props for the `<script type="application/json">` payload.
|
|
169
|
+
* Throws IslandPropsError naming the offending path. Every `<` is emitted as its
|
|
170
|
+
* unicode escape so a string value containing a closing script tag cannot break out.
|
|
171
|
+
*/
|
|
172
|
+
declare function serializeIslandProps(props: IslandProps): string;
|
|
173
|
+
/** Read a props payload back. Throws IslandPropsError on anything that is not a JSON object. */
|
|
174
|
+
declare function deserializeIslandProps(payload: string): IslandProps;
|
|
175
|
+
//#endregion
|
|
176
|
+
export { ATTR_ISLAND_FRAMELESS, ATTR_ISLAND_ID, ATTR_ISLAND_KEY, ATTR_ISLAND_PROPS, EDITOR_BRIDGE_PROP, EDITOR_BRIDGE_PROTOCOL, EditorBridge, EditorBridgeSelection, EditorSelection, ISLAND_CAPTURE_HOLDS_GLOBAL, ISLAND_ELEMENT, IslandComponent, IslandEditor, IslandEditorOptions, IslandModule, IslandProps, IslandPropsError, IslandServerFrame, deserializeIslandProps, islandId, serializeIslandProps };
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
//#region ../../internal/island-runtime/dist/contract.js
|
|
2
|
+
/** The custom element wrapping an island's server-rendered output. Layout-invisible (`display:contents`). */
|
|
3
|
+
const ISLAND_ELEMENT = "tr-island";
|
|
4
|
+
/** Island key on the marker: `<section-key>:<ComponentName>`, e.g. `spw-essential/floorplan:UnitFilter`. */
|
|
5
|
+
const ATTR_ISLAND_KEY = "data-tr-island";
|
|
6
|
+
/** Island id on the marker: unique in the document, stable across re-renders of the same island. */
|
|
7
|
+
const ATTR_ISLAND_ID = "data-tr-island-id";
|
|
8
|
+
/** On the JSON `<script>` sibling; its value is the island id of the marker the props belong to. */
|
|
9
|
+
const ATTR_ISLAND_PROPS = "data-tr-island-props";
|
|
10
|
+
/**
|
|
11
|
+
* Present on a marker holding no server-rendered output — the island mounts fresh
|
|
12
|
+
* instead of hydrating. Value-less: presence is the whole signal.
|
|
13
|
+
*
|
|
14
|
+
* The browser loader decides how to mount a marker before that island's module has
|
|
15
|
+
* loaded, so it cannot ask the module whether it declared `serverFrame = false`. The
|
|
16
|
+
* DOM has to carry the answer, and the marker is the one thing that knows it — an
|
|
17
|
+
* empty marker means there is nothing for React to hydrate against, whatever made it
|
|
18
|
+
* empty.
|
|
19
|
+
*/
|
|
20
|
+
const ATTR_ISLAND_FRAMELESS = "data-tr-island-frameless";
|
|
21
|
+
/** The window property an editor canvas publishes its {@link EditorBridge} on. Absent on published pages. */
|
|
22
|
+
const EDITOR_BRIDGE_PROP = "__trEditorBridge";
|
|
23
|
+
/** The bridge protocol this runtime speaks. See {@link EditorBridge} for the versioning discipline. */
|
|
24
|
+
const EDITOR_BRIDGE_PROTOCOL = 1;
|
|
25
|
+
/**
|
|
26
|
+
* The window property holding the page's OPEN capture holds, as a
|
|
27
|
+
* `Set<Promise<void>>`. An island that paints after mount takes a hold (the
|
|
28
|
+
* `useCaptureReady` hook) and the host's readiness promise drains the set —
|
|
29
|
+
* window-level because an island bundle and the page's runtime chunk are
|
|
30
|
+
* separate module graphs, so module state cannot cross between them.
|
|
31
|
+
*/
|
|
32
|
+
const ISLAND_CAPTURE_HOLDS_GLOBAL = "__trCaptureHolds";
|
|
33
|
+
/** A prop that cannot cross the server→browser boundary, or a payload that cannot be read back. */
|
|
34
|
+
var IslandPropsError = class extends Error {
|
|
35
|
+
name = "IslandPropsError";
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Compose an island id. `scope` is the emitter's per-section-instance identity —
|
|
39
|
+
* without it, two instances of one section on a page collide.
|
|
40
|
+
*/
|
|
41
|
+
function islandId(scope, islandKey, ordinal) {
|
|
42
|
+
return `${scope}~${islandKey}#${ordinal}`;
|
|
43
|
+
}
|
|
44
|
+
const JSON_TYPES = /* @__PURE__ */ new Set([
|
|
45
|
+
"string",
|
|
46
|
+
"number",
|
|
47
|
+
"boolean",
|
|
48
|
+
"undefined"
|
|
49
|
+
]);
|
|
50
|
+
function assertSerializable(value, path) {
|
|
51
|
+
if (value === null) return;
|
|
52
|
+
const type = typeof value;
|
|
53
|
+
if (JSON_TYPES.has(type)) {
|
|
54
|
+
if (type === "number" && !Number.isFinite(value)) throw new IslandPropsError(`${path} is ${String(value)} — island props must be JSON-serializable, and JSON has no NaN or Infinity`);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (type !== "object") throw new IslandPropsError(`${path} is a ${type} — island props must be JSON-serializable (string, number, boolean, null, plain object, array)`);
|
|
58
|
+
if (Array.isArray(value)) {
|
|
59
|
+
value.forEach((entry, i) => {
|
|
60
|
+
assertSerializable(entry, `${path}[${i}]`);
|
|
61
|
+
});
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const proto = Object.getPrototypeOf(value);
|
|
65
|
+
if (proto !== Object.prototype && proto !== null) {
|
|
66
|
+
const ctor = value.constructor?.name ?? "class instance";
|
|
67
|
+
throw new IslandPropsError(`${path} is a ${ctor} — island props must be JSON-serializable (plain objects and arrays only)`);
|
|
68
|
+
}
|
|
69
|
+
for (const [key, entry] of Object.entries(value)) assertSerializable(entry, `${path}.${key}`);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Validate + encode island props for the `<script type="application/json">` payload.
|
|
73
|
+
* Throws IslandPropsError naming the offending path. Every `<` is emitted as its
|
|
74
|
+
* unicode escape so a string value containing a closing script tag cannot break out.
|
|
75
|
+
*/
|
|
76
|
+
function serializeIslandProps(props) {
|
|
77
|
+
if (props === null || typeof props !== "object" || Array.isArray(props)) throw new IslandPropsError("props must be a plain object, not an array or a bare value");
|
|
78
|
+
assertSerializable(props, "props");
|
|
79
|
+
return JSON.stringify(props).replace(/</g, "\\u003c");
|
|
80
|
+
}
|
|
81
|
+
/** Read a props payload back. Throws IslandPropsError on anything that is not a JSON object. */
|
|
82
|
+
function deserializeIslandProps(payload) {
|
|
83
|
+
let parsed;
|
|
84
|
+
try {
|
|
85
|
+
parsed = JSON.parse(payload);
|
|
86
|
+
} catch (cause) {
|
|
87
|
+
throw new IslandPropsError(`island props payload is not valid JSON: ${String(cause)}`);
|
|
88
|
+
}
|
|
89
|
+
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) throw new IslandPropsError("island props payload must be a JSON object");
|
|
90
|
+
return parsed;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
//#endregion
|
|
94
|
+
export { ATTR_ISLAND_FRAMELESS, ATTR_ISLAND_ID, ATTR_ISLAND_KEY, ATTR_ISLAND_PROPS, EDITOR_BRIDGE_PROP, EDITOR_BRIDGE_PROTOCOL, ISLAND_CAPTURE_HOLDS_GLOBAL, ISLAND_ELEMENT, IslandPropsError, deserializeIslandProps, islandId, serializeIslandProps };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region ../../internal/island-runtime/dist/editor-instance-context.js
|
|
2
|
+
const CONTEXT_KEY = Symbol.for("homepages.tr-island-editor-instance");
|
|
3
|
+
/** The one shared editor-instance context, created by whichever copy asks first. */
|
|
4
|
+
function editorInstanceContext(react) {
|
|
5
|
+
const registry = globalThis;
|
|
6
|
+
let context = registry[CONTEXT_KEY];
|
|
7
|
+
if (!context) {
|
|
8
|
+
context = react.createContext(null);
|
|
9
|
+
registry[CONTEXT_KEY] = context;
|
|
10
|
+
}
|
|
11
|
+
return context;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
export { editorInstanceContext };
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { ATTR_ISLAND_FRAMELESS, ATTR_ISLAND_ID, ATTR_ISLAND_KEY, ATTR_ISLAND_PROPS, EDITOR_BRIDGE_PROP, EDITOR_BRIDGE_PROTOCOL, EditorBridge, EditorBridgeSelection, EditorSelection, ISLAND_CAPTURE_HOLDS_GLOBAL, ISLAND_ELEMENT, IslandComponent, IslandEditor, IslandEditorOptions, IslandModule, IslandProps, IslandPropsError, IslandServerFrame, deserializeIslandProps, islandId, serializeIslandProps } from "./contract.js";
|
|
2
|
+
import { islandsCaptureReady } from "./capture-holds.js";
|
|
3
|
+
//#region ../../internal/island-runtime/dist/index.d.ts
|
|
4
|
+
/** What the loader knows about one island once its module has loaded. */
|
|
5
|
+
interface IslandContext {
|
|
6
|
+
id: string;
|
|
7
|
+
key: string;
|
|
8
|
+
element: HTMLElement;
|
|
9
|
+
editor?: IslandEditorOptions;
|
|
10
|
+
/**
|
|
11
|
+
* Settles when this island has MOUNTED — React committed it to the document, and
|
|
12
|
+
* the state its mount effects set has been committed too. Never rejects: an island
|
|
13
|
+
* that failed settles this as well, with the failure already routed to `onError`.
|
|
14
|
+
*
|
|
15
|
+
* Hydrating and mounting are two different moments, and the gap between them is not
|
|
16
|
+
* small. `hydrateRoot()` and `root.render()` SCHEDULE React's work; the commit lands
|
|
17
|
+
* in a later task. A host that took this loader's own promise for a mount would be
|
|
18
|
+
* publishing something it had only asked for — measured tens of milliseconds early
|
|
19
|
+
* on an idle machine, on every run, and wider the busier the machine gets.
|
|
20
|
+
*
|
|
21
|
+
* A host that publishes a readiness promise for a capturer — the page shell's
|
|
22
|
+
* runtime chunk, the CLI dev bootstrap — must await this for every handle it got
|
|
23
|
+
* back. The loader's own promise deliberately does NOT: the editor re-hydrates a
|
|
24
|
+
* section on every re-render and wants its handles as soon as the roots exist, and
|
|
25
|
+
* a promise whose resolution waits on React deadlocks inside `act()`.
|
|
26
|
+
*/
|
|
27
|
+
mounted: Promise<void>;
|
|
28
|
+
}
|
|
29
|
+
/** Alias of {@link IslandContext} — what `hydrateIslands` returns one of per hydrated island. */
|
|
30
|
+
type IslandHandle = IslandContext;
|
|
31
|
+
/** Options for {@link hydrateIslands}. */
|
|
32
|
+
interface HydrateIslandsOptions {
|
|
33
|
+
/** Where to look for markers. Default: the whole document. */
|
|
34
|
+
root?: ParentNode;
|
|
35
|
+
/** Resolve an island key to its module. The host owns this map (the build generates it). */
|
|
36
|
+
load: (islandKey: string) => Promise<IslandModule>;
|
|
37
|
+
/** Decide whether to hydrate, once the module (and so its editor options) is known. */
|
|
38
|
+
shouldHydrate?: (ctx: IslandContext) => boolean;
|
|
39
|
+
/** A failed island is reported here; its neighbors still hydrate. */
|
|
40
|
+
onError?: (error: unknown, ctx: IslandContext) => void;
|
|
41
|
+
/**
|
|
42
|
+
* How main-thread time is spent.
|
|
43
|
+
*
|
|
44
|
+
* `"viewport"` (the default) fetches every island in the background and hydrates
|
|
45
|
+
* by viewport priority — visible islands first, then an island as the visitor
|
|
46
|
+
* approaches it, then the rest in idle slices — so the returned promise covers
|
|
47
|
+
* the visible pass only and `onHydrated` is the signal for the rest.
|
|
48
|
+
*
|
|
49
|
+
* `"eager"` hydrates every island up front, in document order, and the returned
|
|
50
|
+
* promise covers all of them. It is for a host that must hold every handle the
|
|
51
|
+
* moment this call settles — an editor canvas, which derives a click shield from
|
|
52
|
+
* each hydrated island — not for a visitor's page, where hydrating everything up
|
|
53
|
+
* front is main-thread work competing with their first tap.
|
|
54
|
+
*/
|
|
55
|
+
schedule?: "eager" | "viewport";
|
|
56
|
+
/**
|
|
57
|
+
* The URL `load` will import for an island key, used under the viewport schedule
|
|
58
|
+
* to fetch off-screen islands at background priority before they are needed. Must
|
|
59
|
+
* resolve to the same URL `load` imports, or the module is fetched twice. Omit it
|
|
60
|
+
* when the host has no url map (a bundler-resolved `load`); those islands then
|
|
61
|
+
* fetch on approach, as they also do on a `Save-Data` connection.
|
|
62
|
+
*/
|
|
63
|
+
moduleUrl?: (islandKey: string) => string | null | undefined;
|
|
64
|
+
/** One island finished hydrating. Under the viewport schedule this fires long after the returned promise settles. */
|
|
65
|
+
onHydrated?: (island: IslandHandle) => void;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Hydrate every island marker under `options.root` (default: the whole document)
|
|
69
|
+
* into its own React root, loading each one's module through `options.load`.
|
|
70
|
+
*
|
|
71
|
+
* A marker carrying `data-tr-island-frameless` holds no server-rendered output, so its
|
|
72
|
+
* island is mounted fresh rather than hydrated — there is nothing to hydrate against,
|
|
73
|
+
* and asking React to try reports a mismatch on every such island.
|
|
74
|
+
*
|
|
75
|
+
* A marker nested inside another marker is skipped — it belongs to the parent
|
|
76
|
+
* island's own render, so hydrating it separately would create a second root on
|
|
77
|
+
* DOM the parent already owns. A marker whose props payload is missing, or that
|
|
78
|
+
* shares its id with another payload, is refused rather than guessed at. A marker
|
|
79
|
+
* that leaves the document while its module is still loading is silently skipped:
|
|
80
|
+
* that is the host's own re-render racing this call, not a failure. Every other
|
|
81
|
+
* failure — a rejected `load()`, a thrown render — reaches `options.onError`
|
|
82
|
+
* rather than throwing out of this call, so one bad island never blocks its
|
|
83
|
+
* neighbors.
|
|
84
|
+
*
|
|
85
|
+
* Islands hydrate by viewport priority: the returned promise covers what is visible at
|
|
86
|
+
* first paint, and `onHydrated` reports the rest as the visitor approaches them or the
|
|
87
|
+
* main thread goes idle. `schedule: "eager"` hydrates every island before this call
|
|
88
|
+
* settles instead — see {@link HydrateIslandsOptions.schedule}.
|
|
89
|
+
*
|
|
90
|
+
* WHICH islands this promise covers is the schedule's business; WHETHER they have
|
|
91
|
+
* mounted is not. It settles once each covered island has a React root, which React
|
|
92
|
+
* commits a task later — so a caller that needs the islands' DOM to EXIST (a capturer,
|
|
93
|
+
* a measuring pass) must await {@link IslandContext.mounted} on the handles, which is
|
|
94
|
+
* why every handle carries one.
|
|
95
|
+
*/
|
|
96
|
+
declare function hydrateIslands(options: HydrateIslandsOptions): Promise<IslandHandle[]>;
|
|
97
|
+
/**
|
|
98
|
+
* Unmount every island hydrated under `root`. Synchronous, so the editor can call it
|
|
99
|
+
* immediately before replacing a section's innerHTML.
|
|
100
|
+
*/
|
|
101
|
+
declare function unmountIslands(root?: ParentNode): void;
|
|
102
|
+
//#endregion
|
|
103
|
+
export { ATTR_ISLAND_FRAMELESS, ATTR_ISLAND_ID, ATTR_ISLAND_KEY, ATTR_ISLAND_PROPS, EDITOR_BRIDGE_PROP, EDITOR_BRIDGE_PROTOCOL, EditorBridge, EditorBridgeSelection, EditorSelection, HydrateIslandsOptions, ISLAND_CAPTURE_HOLDS_GLOBAL, ISLAND_ELEMENT, IslandComponent, IslandContext, IslandEditor, IslandEditorOptions, IslandHandle, IslandModule, IslandProps, IslandPropsError, IslandServerFrame, deserializeIslandProps, hydrateIslands, islandId, islandsCaptureReady, serializeIslandProps, unmountIslands };
|