@homepages/concrete 8.0.0 → 9.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 +988 -0
- package/README.md +20 -9
- package/codemods/list-grammar.mjs +923 -0
- package/codemods/manifest.json +60 -0
- package/codemods/process-builders.mjs +198 -0
- package/codemods/slot-object.mjs +1097 -0
- package/codemods/steps/content-object-fields.mjs +324 -0
- package/codemods/steps/list-object-form.mjs +6 -7
- package/codemods/table-rows.mjs +568 -0
- package/codemods/unwrap-object-fields.mjs +310 -0
- package/codemods/viewer-slot-document.mjs +131 -0
- package/codemods/write-property-as-facts-document.mjs +716 -0
- package/codemods/write-the-address-line.mjs +255 -0
- package/codemods/write-the-registry-members.mjs +653 -0
- package/codemods/write-the-select-from.mjs +141 -0
- package/codemods/write-the-sole-from.mjs +369 -0
- package/codemods/write-the-table-from.mjs +267 -0
- package/codemods/write-the-whole-item.mjs +512 -0
- package/codemods/writeback-drop.mjs +168 -0
- package/codemods/written-contact-address.mjs +162 -0
- package/codemods/written-media-category.mjs +227 -0
- package/codemods/written-ref-kinds-name-the-layer.mjs +172 -0
- package/codemods/written-uploads-replace-pool-reads.mjs +454 -0
- package/codemods/written-uploads-sort-into-lists.mjs +405 -0
- package/codemods/written-uploads-stated-in-sorted-lists.mjs +295 -0
- package/codemods/written-video-sources-drop.mjs +144 -0
- package/codemods/written-without-pick-none.mjs +146 -0
- package/codemods/written-without-retired-knowledge.mjs +223 -0
- package/codemods/written-without-the-media-key.mjs +202 -0
- package/codemods/written-without-the-property-type.mjs +249 -0
- package/dist/artifact/playground/client/assets/index-BUmdDDX5.js +1259 -0
- package/dist/artifact/playground/client/assets/index-DDOcM0zA.css +1 -0
- package/dist/artifact/playground/client/index.html +2 -2
- package/dist/artifact/playground/client/island-canvas-host.mjs +1 -1
- package/dist/artifact/playground/host.mjs +61 -27
- package/dist/base.css +58 -1
- package/dist/cli/build/artifact.js +6 -9
- package/dist/cli/build/captures.js +2 -12
- package/dist/cli/build/esbuild.js +1 -25
- package/dist/cli/build/fixtures.js +2 -1
- package/dist/cli/build/icons.js +1 -1
- package/dist/cli/build/static.js +2 -2
- package/dist/cli/capture/capture.js +8 -9
- package/dist/cli/check/analyze.js +8 -1
- package/dist/cli/check/load-outdir.js +47 -0
- package/dist/cli/check/load-workspace.js +4 -4
- package/dist/cli/check/render/html.js +1 -2
- package/dist/cli/check/render/inputs.js +10 -3
- package/dist/cli/check/render/island-frames.js +2 -1
- package/dist/cli/check/render/marker-coverage.js +23 -15
- package/dist/cli/check/report.js +5 -0
- package/dist/cli/check/stages/bundles.js +1 -1
- package/dist/cli/check/stages/relations.js +1 -1
- package/dist/cli/check/stages/render.js +48 -33
- package/dist/cli/check/stages/sections.js +83 -31
- package/dist/cli/commands.js +1 -1
- package/dist/cli/dev/crop.js +1 -1
- package/dist/cli/dev/fixture-ladders.js +96 -0
- package/dist/cli/dev/islands.js +12 -123
- package/dist/cli/dev/listen.js +20 -1
- package/dist/cli/dev/load-template.js +1 -1
- package/dist/cli/dev/server.js +35 -10
- package/dist/cli/dev/vite.js +9 -7
- package/dist/cli/dev/workspace-reader.js +16 -16
- package/dist/cli/media/derive.js +43 -57
- package/dist/cli/media/frame-rung-floor.js +0 -1
- package/dist/cli/property/index.js +1 -6
- package/dist/css/inline.js +1 -22
- package/dist/eslint/rules/no-marker-literal.js +1 -1
- package/dist/fixtures/load.js +16 -7
- package/dist/fixtures/media-plugin.js +17 -12
- package/dist/fixtures/media-store.js +115 -0
- package/dist/fixtures/property.js +345 -126
- package/dist/fixtures/resolve.js +263 -251
- package/dist/fixtures/rows.js +4 -11
- package/dist/fixtures.d.ts +234 -109
- package/dist/index.d.ts +25 -16
- package/dist/index.js +10 -6
- package/dist/islands/marker.js +2 -1
- package/dist/packages/external/concrete/package.js +1 -1
- package/dist/packages/internal/canvas-core/dist/island-host.js +62 -0
- package/dist/packages/internal/canvas-core/dist/island-shields.js +30 -0
- package/dist/packages/internal/capture-settle/dist/index.js +3 -0
- package/dist/packages/internal/capture-settle/dist/island-markers.d.ts +13 -0
- package/dist/packages/internal/capture-settle/dist/island-markers.js +6 -0
- package/dist/packages/internal/capture-settle/dist/settle.js +150 -0
- package/dist/packages/internal/{image-ladder/dist/crop.js → crop-region/dist/index.js} +21 -20
- package/dist/packages/internal/fill-bake/dist/bake-property-ref.js +251 -33
- package/dist/packages/internal/fill-bake/dist/compute-reads.js +365 -4
- package/dist/packages/internal/fill-bake/dist/derive-source.js +35 -21
- package/dist/packages/internal/fill-bake/dist/index.js +8 -3
- package/dist/packages/internal/fill-bake/dist/item-merge.js +119 -0
- package/dist/packages/internal/fill-bake/dist/item-overrides.js +28 -0
- package/dist/packages/internal/fill-bake/dist/linked-merge.js +40 -0
- package/dist/packages/internal/fill-bake/dist/list-grammar.js +175 -0
- package/dist/packages/internal/fill-vocabulary/dist/holder.js +51 -0
- package/dist/packages/internal/fill-vocabulary/dist/resolved-decision.js +390 -0
- package/dist/packages/internal/fill-vocabulary/dist/row-planners.js +1 -23
- package/dist/packages/internal/fill-vocabulary/dist/row-reads.js +1 -1
- package/dist/packages/internal/fill-vocabulary/dist/verbs.js +75 -0
- package/dist/packages/internal/format-geometry/dist/capture.js +11 -147
- package/dist/packages/internal/format-geometry/dist/format.d.ts +8 -2
- package/dist/packages/internal/format-geometry/dist/geometry.js +13 -2
- package/dist/packages/internal/image-ladder/dist/encode.js +27 -14
- package/dist/packages/internal/image-ladder/dist/index.js +3 -3
- package/dist/packages/internal/image-ladder/dist/policy.js +28 -53
- package/dist/packages/internal/island-runtime/dist/capture-holds.js +1 -1
- package/dist/packages/internal/island-runtime/dist/contract.d.ts +3 -12
- package/dist/packages/internal/island-runtime/dist/contract.js +2 -2
- package/dist/packages/internal/island-runtime/dist/index.d.ts +3 -7
- package/dist/packages/internal/island-runtime/dist/index.js +2 -1
- package/dist/packages/internal/island-runtime/dist/viewport-schedule.js +1 -1
- package/dist/packages/internal/media-resolution/dist/crop-key.js +7 -0
- package/dist/packages/internal/media-resolution/dist/document.js +63 -0
- package/dist/packages/internal/media-resolution/dist/image.js +228 -0
- package/dist/packages/internal/media-resolution/dist/index.js +11 -0
- package/dist/packages/internal/media-resolution/dist/list.js +112 -0
- package/dist/packages/internal/media-resolution/dist/media.js +59 -0
- package/dist/packages/internal/media-resolution/dist/records.js +7 -0
- package/dist/packages/internal/media-resolution/dist/slot.js +34 -0
- package/dist/packages/internal/media-resolution/dist/store.js +19 -0
- package/dist/packages/internal/media-resolution/dist/tour.js +59 -0
- package/dist/packages/internal/media-resolution/dist/video.js +93 -0
- package/dist/packages/internal/property-facts/dist/registry-facts.js +244 -0
- package/dist/packages/internal/section-contracts/dist/cap-contract.js +8 -17
- package/dist/packages/internal/section-contracts/dist/catalog.js +34 -10
- package/dist/packages/internal/section-contracts/dist/count-bounds-contract.js +11 -2
- package/dist/packages/internal/section-contracts/dist/directly-linked-list-contract.js +27 -0
- package/dist/packages/internal/section-contracts/dist/fill-options.js +12 -0
- package/dist/packages/internal/section-contracts/dist/fill-verb-contract.js +95 -0
- package/dist/packages/internal/section-contracts/dist/grammar-scope.js +154 -0
- package/dist/packages/internal/section-contracts/dist/index.js +7 -1
- package/dist/packages/internal/section-contracts/dist/list-fill-contract.js +15 -20
- package/dist/packages/internal/section-contracts/dist/list-scalar-contract.js +12 -7
- package/dist/packages/internal/section-contracts/dist/list-source-contract.js +46 -0
- package/dist/packages/internal/section-contracts/dist/nested-slot-contract.js +11 -2
- package/dist/packages/internal/section-contracts/dist/object-contract.js +92 -0
- package/dist/packages/internal/section-contracts/dist/poi-curation-contract.js +5 -5
- package/dist/packages/internal/section-contracts/dist/reads-acyclic-contract.js +63 -0
- package/dist/packages/internal/section-contracts/dist/row-fill-contract.js +7 -4
- package/dist/packages/internal/section-contracts/dist/row-rule-contract.js +83 -0
- package/dist/packages/internal/section-contracts/dist/row-source-contract.js +67 -0
- package/dist/packages/internal/section-contracts/dist/runners.js +74 -10
- package/dist/packages/internal/section-contracts/dist/select-contract.js +0 -8
- package/dist/packages/internal/section-contracts/dist/source-contract.js +103 -46
- package/dist/packages/internal/section-contracts/dist/sources-contract.js +47 -17
- package/dist/packages/internal/section-contracts/dist/table-member.js +16 -0
- package/dist/packages/internal/section-contracts/dist/writer-reads-fact-contract.js +42 -21
- package/dist/packages/internal/source-resolution/dist/index.js +113 -72
- package/dist/packages/internal/static-assets-binding/dist/section-asset-url.js +16 -0
- package/dist/packages/internal/street-address/dist/index.js +72 -0
- package/dist/packages/internal/template-artifact/dist/asset-mime.js +30 -0
- package/dist/packages/internal/template-artifact/dist/layout.js +1 -2
- package/dist/packages/internal/template-artifact/dist/manifest.js +1 -1
- package/dist/packages/internal/template-artifact/dist/verify.js +12 -29
- package/dist/packages/internal/template-contracts/dist/address-value.d.ts +52 -0
- package/dist/packages/internal/template-contracts/dist/address-value.js +90 -0
- package/dist/packages/internal/template-contracts/dist/comparable-address.js +19 -0
- package/dist/{schema → packages/internal/template-contracts/dist}/compute.d.ts +29 -6
- package/dist/{schema → packages/internal/template-contracts/dist}/compute.js +11 -13
- package/dist/packages/internal/template-contracts/dist/content-pick.js +51 -0
- package/dist/packages/internal/template-contracts/dist/decision-fills.js +85 -0
- package/dist/packages/internal/template-contracts/dist/display-overrides.js +7 -0
- package/dist/packages/internal/template-contracts/dist/document-value.d.ts +16 -5
- package/dist/packages/internal/template-contracts/dist/fact-compute.d.ts +24 -0
- package/dist/packages/internal/template-contracts/dist/fact-compute.js +30 -0
- package/dist/packages/internal/template-contracts/dist/fact-keys.d.ts +44 -0
- package/dist/packages/internal/template-contracts/dist/fact-keys.js +88 -0
- package/dist/packages/internal/template-contracts/dist/fact-registry.d.ts +290 -0
- package/dist/packages/internal/template-contracts/dist/fact-registry.js +598 -0
- package/dist/packages/internal/template-contracts/dist/facts-view.d.ts +10 -24
- package/dist/packages/internal/template-contracts/dist/fill-builders.d.ts +157 -0
- package/dist/packages/internal/template-contracts/dist/fill-builders.js +79 -0
- package/dist/packages/internal/template-contracts/dist/fill-declaration.d.ts +14 -0
- package/dist/{schema → packages/internal/template-contracts/dist}/fill-declaration.js +6 -5
- package/dist/packages/internal/template-contracts/dist/fill-spec-schema.js +158 -0
- package/dist/packages/internal/template-contracts/dist/fill-spec.js +291 -0
- package/dist/packages/internal/template-contracts/dist/findable.js +8 -0
- package/dist/packages/internal/template-contracts/dist/floor-presets.js +13 -0
- package/dist/packages/internal/template-contracts/dist/icon-names.d.ts +5 -0
- package/dist/packages/internal/template-contracts/dist/icon-names.js +70 -0
- package/dist/packages/internal/template-contracts/dist/legacy-facts.js +167 -0
- package/dist/packages/internal/template-contracts/dist/list-editing.js +94 -0
- package/dist/packages/internal/template-contracts/dist/list.d.ts +215 -0
- package/dist/packages/internal/template-contracts/dist/list.js +258 -0
- package/dist/packages/internal/template-contracts/dist/markers.d.ts +2 -2
- package/dist/packages/internal/template-contracts/dist/media-candidates.js +38 -0
- package/dist/packages/internal/template-contracts/dist/mirror-kind.js +48 -0
- package/dist/packages/internal/template-contracts/dist/number-display.js +10 -0
- package/dist/packages/internal/template-contracts/dist/object.d.ts +89 -0
- package/dist/packages/internal/template-contracts/dist/object.js +131 -0
- package/dist/packages/internal/template-contracts/dist/poi-row.d.ts +1 -1
- package/dist/packages/internal/template-contracts/dist/primitive-descriptors.d.ts +1 -0
- package/dist/packages/internal/template-contracts/dist/primitive-descriptors.js +162 -0
- package/dist/packages/internal/template-contracts/dist/process-builders.d.ts +77 -0
- package/dist/packages/internal/template-contracts/dist/process-builders.js +73 -0
- package/dist/packages/internal/template-contracts/dist/read-graph.js +250 -0
- package/dist/packages/internal/template-contracts/dist/ref-locate.js +192 -0
- package/dist/packages/internal/template-contracts/dist/registry-aliases.js +77 -0
- package/dist/packages/internal/template-contracts/dist/registry-facts.d.ts +268 -0
- package/dist/packages/internal/template-contracts/dist/registry-facts.js +202 -0
- package/dist/packages/internal/template-contracts/dist/registry-shape.d.ts +41 -0
- package/dist/packages/internal/template-contracts/dist/registry-shape.js +135 -0
- package/dist/packages/internal/template-contracts/dist/resolve-scope.js +103 -0
- package/dist/packages/internal/{image-descriptor/dist/index.d.ts → template-contracts/dist/responsive-image.d.ts} +1 -1
- package/dist/packages/internal/template-contracts/dist/row-planners.js +29 -0
- package/dist/packages/internal/template-contracts/dist/row-ref.d.ts +133 -0
- package/dist/packages/internal/template-contracts/dist/row-ref.js +101 -0
- package/dist/packages/internal/template-contracts/dist/row-sources.js +49 -3
- package/dist/packages/internal/template-contracts/dist/row.d.ts +155 -0
- package/dist/packages/internal/template-contracts/dist/row.js +84 -0
- package/dist/packages/internal/template-contracts/dist/runtime-values.d.ts +97 -0
- package/dist/packages/internal/template-contracts/dist/slot-builders.d.ts +782 -0
- package/dist/packages/internal/template-contracts/dist/slot-builders.js +233 -0
- package/dist/packages/internal/template-contracts/dist/slot-catalog.d.ts +243 -384
- package/dist/packages/internal/template-contracts/dist/slot-catalog.js +335 -227
- package/dist/packages/internal/template-contracts/dist/slot-overrides.js +21 -0
- package/dist/packages/internal/template-contracts/dist/slot-ref.d.ts +155 -0
- package/dist/packages/internal/template-contracts/dist/slot-ref.js +76 -0
- package/dist/packages/internal/template-contracts/dist/slot-types.d.ts +163 -0
- package/dist/packages/internal/template-contracts/dist/slot-types.js +140 -0
- package/dist/packages/internal/template-contracts/dist/slot-value.d.ts +97 -0
- package/dist/packages/internal/template-contracts/dist/table-members.d.ts +25 -0
- package/dist/packages/internal/template-contracts/dist/table-members.js +90 -0
- package/dist/packages/internal/template-contracts/dist/tour-value.d.ts +5 -5
- package/dist/packages/internal/template-contracts/dist/value-contracts.js +15 -0
- package/dist/packages/internal/template-contracts/dist/video-value.d.ts +2 -2
- package/dist/platform/fs.js +5 -2
- package/dist/playground/canvas-island-host.d.ts +11 -0
- package/dist/playground/canvas-island-host.js +29 -0
- package/dist/playground/canvas-markers.js +14 -0
- package/dist/playground-island-runtime.d.ts +3 -2
- package/dist/playground-island-runtime.js +3 -2
- package/dist/primitives/FrameShell.js +0 -1
- package/dist/primitives/Image.d.ts +5 -4
- package/dist/primitives/Tour.d.ts +1 -1
- package/dist/primitives/Video.d.ts +2 -2
- package/dist/primitives/index.d.ts +2 -3
- package/dist/primitives/picture-sources.js +2 -2
- package/dist/primitives/probe-context.js +2 -12
- package/dist/primitives/slot-address.d.ts +44 -0
- package/dist/primitives/slot-address.js +19 -0
- package/dist/primitives/slot-bindings.d.ts +65 -26
- package/dist/primitives/slot-bindings.js +104 -46
- package/dist/primitives/slot-document.d.ts +23 -18
- package/dist/primitives/slot-document.js +39 -14
- package/dist/primitives/slot-download.d.ts +39 -0
- package/dist/primitives/slot-download.js +39 -0
- package/dist/primitives/slot-list.d.ts +3 -3
- package/dist/primitives/slot-list.js +0 -2
- package/dist/primitives/slot-media.d.ts +24 -5
- package/dist/primitives/slot-media.js +6 -9
- package/dist/primitives/slot-object.d.ts +49 -0
- package/dist/primitives/slot-object.js +20 -0
- package/dist/primitives/slot-scalar.d.ts +27 -2
- package/dist/primitives/slot-scalar.js +50 -7
- package/dist/primitives/slot.d.ts +13 -6
- package/dist/primitives/slot.js +10 -3
- package/dist/rules/registry.js +19 -30
- package/dist/schema/define-schema.d.ts +4 -8
- package/dist/schema/define-schema.js +178 -79
- package/dist/schema/extract-fill-spec.js +2 -153
- package/dist/schema/fact.d.ts +57 -15
- package/dist/schema/fact.js +42 -7
- package/dist/schema/facts-view.d.ts +14 -0
- package/dist/schema/format.d.ts +1 -0
- package/dist/schema/format.js +2 -1
- package/dist/schema/manifest.js +24 -0
- package/dist/schema/property-facts.d.ts +8 -12
- package/dist/schema/section-props.d.ts +2 -66
- package/dist/schema/section-schema.d.ts +8 -11
- package/dist/schema/section-schema.js +27 -10
- package/dist/section/declare.d.ts +18 -7
- package/dist/section/declare.js +18 -5
- package/dist/section/materialize.js +3 -8
- package/dist/section/section.d.ts +12 -8
- package/dist/section/section.js +1 -1
- package/dist/template/logic-shim.d.ts +14 -7
- package/dist/template/logic-shim.js +14 -7
- package/dist/template/materialize.js +17 -18
- package/dist/template/mirror-types.js +30 -31
- package/dist/template/section-reads.js +85 -9
- package/guide/reference/cli/INDEX.md +2 -2
- package/guide/reference/cli/build.md +1 -1
- package/guide/reference/cli/check.md +1 -1
- package/guide/reference/cli/dev.md +1 -1
- package/guide/reference/cli/property-add.md +1 -1
- package/guide/reference/cli/property-list.md +2 -2
- package/guide/reference/cli/publish.md +1 -1
- package/guide/reference/cli/upgrade.md +1 -1
- package/guide/reference/rules/INDEX.md +28 -24
- package/package.json +9 -8
- package/dist/artifact/playground/client/assets/index-CckS2ONm.css +0 -1
- package/dist/artifact/playground/client/assets/index-Dn_xT16-.js +0 -1101
- package/dist/fixtures/canonical.d.ts +0 -166
- package/dist/fixtures/media.js +0 -163
- package/dist/packages/internal/fill-vocabulary/dist/origination.js +0 -51
- package/dist/packages/internal/format-geometry/dist/index.js +0 -4
- package/dist/packages/internal/property-facts/dist/derive-facts-view.js +0 -10
- package/dist/packages/internal/property-facts/dist/index.js +0 -3
- package/dist/packages/internal/property-facts/dist/property-facts-Cy7-O4p0.js +0 -189
- package/dist/packages/internal/section-contracts/dist/record-collection-contract.js +0 -24
- package/dist/packages/internal/template-contracts/dist/collection-editing.js +0 -22
- package/dist/packages/internal/template-contracts/dist/facts-view.js +0 -104
- package/dist/packages/internal/template-contracts/dist/select-key.js +0 -7
- package/dist/primitives/slot-group.d.ts +0 -40
- package/dist/primitives/slot-group.js +0 -36
- package/dist/schema/extract-used-facts.js +0 -34
- package/dist/schema/fill-builders.d.ts +0 -115
- package/dist/schema/fill-builders.js +0 -25
- package/dist/schema/fill-declaration.d.ts +0 -14
- package/dist/schema/fill-spec.js +0 -98
- package/dist/schema/layout.d.ts +0 -30
- package/dist/schema/layout.js +0 -14
- package/dist/schema/row-fields.js +0 -88
- package/dist/schema/row-ref.d.ts +0 -59
- package/dist/schema/row-ref.js +0 -28
- package/dist/schema/runtime-values.d.ts +0 -71
- package/dist/schema/section-nav.js +0 -14
- package/dist/schema/slot-builders.d.ts +0 -633
- package/dist/schema/slot-builders.js +0 -177
- package/dist/schema/slot-ref.d.ts +0 -79
- package/dist/schema/slot-ref.js +0 -41
- package/dist/schema/slot-types.d.ts +0 -111
- package/dist/schema/slot-types.js +0 -214
- package/dist/section/groups.js +0 -68
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isListSlotType } from "../../../packages/internal/template-contracts/dist/slot-catalog.js";
|
|
2
2
|
import { describeError } from "../messages.js";
|
|
3
3
|
import { renderInputs } from "../render/inputs.js";
|
|
4
|
-
import {
|
|
4
|
+
import { listEditing } from "../../../packages/internal/template-contracts/dist/list-editing.js";
|
|
5
5
|
import { checkClassConflicts } from "../render/class-conflicts.js";
|
|
6
6
|
import { parseHtml } from "../render/html.js";
|
|
7
7
|
import { checkRenderInvariants } from "../render/invariants.js";
|
|
@@ -11,14 +11,30 @@ import { renderToStaticMarkup } from "react-dom/server";
|
|
|
11
11
|
|
|
12
12
|
//#region src/cli/check/stages/render.ts
|
|
13
13
|
function editingViewOf(spec) {
|
|
14
|
+
const fields = itemFieldsOf(spec);
|
|
14
15
|
return {
|
|
15
16
|
type: spec.type ?? "",
|
|
16
17
|
...spec.element !== void 0 ? { element: spec.element } : {},
|
|
17
|
-
...
|
|
18
|
+
...fields !== void 0 ? { fields } : {}
|
|
18
19
|
};
|
|
19
20
|
}
|
|
20
|
-
function
|
|
21
|
-
|
|
21
|
+
function itemFieldsOf(spec) {
|
|
22
|
+
const element = spec.element;
|
|
23
|
+
return element?.type === "object" && typeof element.fields === "object" && element.fields !== null ? element.fields : void 0;
|
|
24
|
+
}
|
|
25
|
+
function objectFieldsOf(spec) {
|
|
26
|
+
return spec.type === "object" && typeof spec.fields === "object" && spec.fields !== null ? spec.fields : void 0;
|
|
27
|
+
}
|
|
28
|
+
function fieldIsUnmarked(field) {
|
|
29
|
+
if (typeof field !== "object" || field === null) return false;
|
|
30
|
+
const { locked, type } = field;
|
|
31
|
+
return locked === true || type === "row";
|
|
32
|
+
}
|
|
33
|
+
function placementIsOwn(slots, placement) {
|
|
34
|
+
const owner = placement.owner === void 0 ? void 0 : slots[placement.owner];
|
|
35
|
+
if (owner === void 0) return false;
|
|
36
|
+
const fields = placement.inItem ? itemFieldsOf(owner) : objectFieldsOf(owner);
|
|
37
|
+
return fields !== void 0 && Object.hasOwn(fields, placement.field);
|
|
22
38
|
}
|
|
23
39
|
const INVARIANT_RULE = {
|
|
24
40
|
"sentinel-text": "render/sentinel-text",
|
|
@@ -34,9 +50,9 @@ var SectionEvidence = class {
|
|
|
34
50
|
entry;
|
|
35
51
|
marked = /* @__PURE__ */ new Set();
|
|
36
52
|
selectable = /* @__PURE__ */ new Set();
|
|
37
|
-
unitWithItems = /* @__PURE__ */ new Set();
|
|
38
53
|
rowFields = /* @__PURE__ */ new Map();
|
|
39
|
-
|
|
54
|
+
objectFields = /* @__PURE__ */ new Map();
|
|
55
|
+
escapedFields = /* @__PURE__ */ new Map();
|
|
40
56
|
findings = /* @__PURE__ */ new Map();
|
|
41
57
|
constructor(entry) {
|
|
42
58
|
this.entry = entry;
|
|
@@ -50,10 +66,10 @@ var SectionEvidence = class {
|
|
|
50
66
|
});
|
|
51
67
|
}
|
|
52
68
|
};
|
|
53
|
-
function renderStage(ctx) {
|
|
69
|
+
async function renderStage(ctx) {
|
|
54
70
|
const { composition, sections, corpus } = ctx;
|
|
55
|
-
if (composition === void 0 || sections === void 0) return
|
|
56
|
-
if (corpus === void 0 || corpus.length === 0) return
|
|
71
|
+
if (composition === void 0 || sections === void 0) return { skipped: "the sections stage could not materialize the placed sections" };
|
|
72
|
+
if (corpus === void 0 || corpus.length === 0) return { skipped: "no fixture resolved, so the render corpus is empty" };
|
|
57
73
|
const assets = ctx.assets ?? /* @__PURE__ */ new Map();
|
|
58
74
|
const imported = ctx.workspace?.assets ?? /* @__PURE__ */ new Map();
|
|
59
75
|
const carriesMedia = (url) => {
|
|
@@ -61,7 +77,7 @@ function renderStage(ctx) {
|
|
|
61
77
|
return assets.has(path) || imported.has(path);
|
|
62
78
|
};
|
|
63
79
|
const evidence = new Map(sections.map((entry) => [entry.key, new SectionEvidence(entry)]));
|
|
64
|
-
for (const { corpus: { emptied }, instanceId, entry, props, where } of renderInputs(composition, sections, corpus)) {
|
|
80
|
+
for await (const { corpus: { emptied }, instanceId, entry, props, where } of renderInputs(composition, sections, corpus, ctx.assets)) {
|
|
65
81
|
const proof = evidence.get(entry.key);
|
|
66
82
|
if (proof === void 0) continue;
|
|
67
83
|
const { section, schema } = proof.entry;
|
|
@@ -78,17 +94,12 @@ function renderStage(ctx) {
|
|
|
78
94
|
const coverage = collectMarkerCoverage(parseHtml(first));
|
|
79
95
|
for (const id of coverage.slotIds) proof.marked.add(id);
|
|
80
96
|
for (const id of coverage.selectableSlotIds) proof.selectable.add(id);
|
|
81
|
-
for (const [
|
|
82
|
-
const seen =
|
|
97
|
+
for (const [found, into] of [[coverage.rowFieldsBySlot, proof.rowFields], [coverage.objectFieldsBySlot, proof.objectFields]]) for (const [slotId, fields] of found) {
|
|
98
|
+
const seen = into.get(slotId) ?? /* @__PURE__ */ new Set();
|
|
83
99
|
for (const field of fields) seen.add(field);
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
const groupOf = /* @__PURE__ */ new Map();
|
|
87
|
-
for (const group of schema.groups ?? []) for (const member of group.members) groupOf.set(member, group.id);
|
|
88
|
-
for (const [slotId, instances] of coverage.enclosingGroupsBySlot) {
|
|
89
|
-
const group = groupOf.get(slotId);
|
|
90
|
-
if (group !== void 0 && instances.some((groups) => !groups.has(group))) proof.escapedGroup.add(slotId);
|
|
100
|
+
into.set(slotId, seen);
|
|
91
101
|
}
|
|
102
|
+
for (const placement of coverage.fieldPlacements) if (!placementIsOwn(schema.slots, placement)) proof.escapedFields.set(placement.field, placement);
|
|
92
103
|
for (const conflict of checkClassConflicts(first)) proof.report("render/section-root-margin", `The section root carries margin utility "${conflict.token}". Zero margin on the root is what lets consecutive sections butt edge-to-edge; space content with padding instead.`);
|
|
93
104
|
const slots = schema.slots;
|
|
94
105
|
if (emptied !== void 0 && emptied.instance === instanceId && slots[emptied.slot]?.locked !== true && slots[emptied.slot] !== void 0) {
|
|
@@ -96,14 +107,11 @@ function renderStage(ctx) {
|
|
|
96
107
|
else if (!coverage.selectableSlotIds.has(emptied.slot)) proof.report("render/missing-slot-marker", `Slot "${emptied.slot}" is selectable when it has a value, but every copy is flagged non-selectable when it is empty (${where}). Keep one rendering of the empty state selectable.`);
|
|
97
108
|
}
|
|
98
109
|
for (const [slotId, spec] of Object.entries(slots)) {
|
|
99
|
-
if (!
|
|
100
|
-
|
|
101
|
-
const granularity = collectionEditing(editingViewOf(spec));
|
|
102
|
-
if (granularity === "unit" && scopes.some((scope) => scope.indices.length > 0)) proof.unitWithItems.add(slotId);
|
|
103
|
-
if (granularity !== "item" || spec.locked === true) continue;
|
|
110
|
+
if (!isListSlotType(spec.type ?? "")) continue;
|
|
111
|
+
if (listEditing(editingViewOf(spec)) !== "item" || spec.locked === true) continue;
|
|
104
112
|
const rows = props.slots[slotId];
|
|
105
113
|
if (!Array.isArray(rows)) continue;
|
|
106
|
-
for (const problem of checkItemIndices(rows.length,
|
|
114
|
+
for (const problem of checkItemIndices(rows.length, coverage.itemScopesBySlot.get(slotId) ?? [])) proof.report("render/missing-slot-marker", `Slot "${slotId}" (${spec.type ?? "list"}): ${problem}. Render each item as a Slot.Object over bindItems(...), which emits the item index from the array position.`);
|
|
107
115
|
}
|
|
108
116
|
if (first !== second) {
|
|
109
117
|
proof.report("render/determinism-drift", `${where} rendered differently twice from the same input. A section must be a pure function of its props: no clock, no random, no unstable iteration order.`);
|
|
@@ -120,23 +128,30 @@ function renderStage(ctx) {
|
|
|
120
128
|
file: proof.entry.file,
|
|
121
129
|
message
|
|
122
130
|
});
|
|
123
|
-
for (const slotId of proof.unitWithItems) at("render/unit-collection-item-marker", `Slot "${slotId}" declares a single-slot item, so it is edited as one card, but its rendering emits data-slot-item row markers the editor never uses. Declare the item as a record if its rows should be individually editable, or render the rows as plain elements.`);
|
|
124
131
|
for (const [slotId, spec] of Object.entries(slots)) {
|
|
125
|
-
if (spec.
|
|
126
|
-
const
|
|
127
|
-
const
|
|
132
|
+
if (spec.locked === true) continue;
|
|
133
|
+
const itemFields = isListSlotType(spec.type ?? "") ? itemFieldsOf(spec) : void 0;
|
|
134
|
+
const fields = itemFields ?? objectFieldsOf(spec);
|
|
135
|
+
if (fields === void 0) continue;
|
|
136
|
+
const declared = Object.entries(fields).filter(([, field]) => !fieldIsUnmarked(field)).map(([field]) => field);
|
|
137
|
+
const seen = (itemFields !== void 0 ? proof.rowFields : proof.objectFields).get(slotId) ?? /* @__PURE__ */ new Set();
|
|
128
138
|
const missing = declared.filter((field) => !seen.has(field));
|
|
129
139
|
if (missing.length === 0) continue;
|
|
130
|
-
|
|
140
|
+
const names = missing.map((f) => `"${f}"`).join(", ");
|
|
141
|
+
const them = missing.length === 1 ? "it" : "them";
|
|
142
|
+
at("render/missing-slot-marker", itemFields !== void 0 ? `Item field${missing.length === 1 ? "" : "s"} ${names} of "${slotId}" never render as data-slot-field in any fixture, so the editor cannot select ${them} on any item. Render each item field through its binding, or declare it locked: true.` : `Field${missing.length === 1 ? "" : "s"} ${names} of object "${slotId}" never render as data-slot-field inside its Slot.Object in any fixture, so the editor cannot select ${them}. Render each field through its binding (slot.${slotId}.<field>) inside <Slot.Object slot={slot.${slotId}}>, or declare it locked: true.`);
|
|
143
|
+
}
|
|
144
|
+
for (const placement of proof.escapedFields.values()) {
|
|
145
|
+
const where = placement.owner === void 0 ? "outside every Slot.Object" : `inside "${placement.owner}"${placement.inItem ? "'s items" : ""}, which declares no such field`;
|
|
146
|
+
at("render/group-ancestry", `Field "${placement.field}" is marked ${where}, so the editor resolves it to the wrong card or to none. Render an object's fields inside its own Slot.Object — the top-level object's, or the item's — or render the outside copy with selectable={false}.`);
|
|
131
147
|
}
|
|
132
|
-
for (const slotId of proof.escapedGroup) at("render/group-ancestry", `Slot "${slotId}" belongs to a group but is marked on an element outside that group's element, so the editor resolves it to no group. Move the marked element inside the SlotGroup, or render the outside copy with selectable={false}.`);
|
|
133
148
|
for (const [slotId, spec] of Object.entries(slots)) {
|
|
134
149
|
if (spec.locked === true) continue;
|
|
135
150
|
if (!proof.marked.has(slotId)) at("render/missing-slot-marker", `Slot "${slotId}" is editable but never renders as data-slot-id in any fixture, so the editor cannot select it. Render it through its own Slot primitive, which owns the marker.`);
|
|
136
151
|
else if (!proof.selectable.has(slotId)) at("render/missing-slot-marker", `Slot "${slotId}" reaches the DOM only on elements flagged non-selectable, so the editor can never select it. Render at least one copy without selectable={false}.`);
|
|
137
152
|
}
|
|
138
153
|
}
|
|
139
|
-
return
|
|
154
|
+
return { violations };
|
|
140
155
|
}
|
|
141
156
|
|
|
142
157
|
//#endregion
|
|
@@ -1,35 +1,84 @@
|
|
|
1
|
+
import { REGISTRY_TABLE_KEYS, tableKeyOf } from "../../../packages/internal/template-contracts/dist/slot-catalog.js";
|
|
2
|
+
import { tableColumnOfKey } from "../../../packages/internal/template-contracts/dist/registry-shape.js";
|
|
1
3
|
import { declaringModule } from "../../../section/section.js";
|
|
4
|
+
import "../../../packages/internal/template-contracts/dist/table-members.js";
|
|
2
5
|
import { isInsideRoot, workspacePath } from "../../../platform/paths.js";
|
|
3
|
-
import { fillSpecFromSchema } from "../../../schema/extract-fill-spec.js";
|
|
4
6
|
import { exportSite } from "../../../section/discovery.js";
|
|
5
7
|
import { describeError } from "../messages.js";
|
|
6
|
-
import {
|
|
8
|
+
import { fillSpecFromSchema } from "../../../schema/extract-fill-spec.js";
|
|
7
9
|
import { TEMPLATE_FILE } from "../load-workspace.js";
|
|
8
|
-
import { FillSpec } from "../../../
|
|
10
|
+
import { FillSpec } from "../../../packages/internal/template-contracts/dist/fill-spec-schema.js";
|
|
9
11
|
import { SectionSchema } from "../../../schema/section-schema.js";
|
|
10
|
-
import { GroupDerivationError } from "../../../section/groups.js";
|
|
11
12
|
import { materializeSection } from "../../../section/materialize.js";
|
|
12
13
|
import { isAbsolute } from "node:path";
|
|
13
14
|
|
|
14
15
|
//#region src/cli/check/stages/sections.ts
|
|
15
|
-
const GROUP_RULE = {
|
|
16
|
-
"slot-in-two-groups": "groups/slot-in-two-groups",
|
|
17
|
-
"label-conflict": "groups/label-conflict",
|
|
18
|
-
empty: "groups/empty"
|
|
19
|
-
};
|
|
20
16
|
function flatten(parsed, key) {
|
|
21
17
|
const { meta, ...rest } = parsed;
|
|
22
18
|
return {
|
|
23
19
|
...rest,
|
|
24
20
|
anchor: meta.anchor ?? key,
|
|
25
|
-
...meta.display ? { display: meta.display } : {}
|
|
26
|
-
|
|
21
|
+
...meta.display ? { display: meta.display } : {}
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function stampItemOrder(object) {
|
|
25
|
+
object.item_order = Object.keys(object.fields);
|
|
26
|
+
for (const field of Object.values(object.fields)) {
|
|
27
|
+
const element = field.element;
|
|
28
|
+
if (field.type === "list" && element?.type === "object") stampItemOrder(element);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function heldTables(slot) {
|
|
32
|
+
const rowTables = (row) => row?.type === "row" ? [row.from].flat().flatMap((key) => tableKeyOf(key)?.table ?? []) : [];
|
|
33
|
+
if (slot.type === "row") return new Set(rowTables(slot));
|
|
34
|
+
if (slot.type !== "list") return /* @__PURE__ */ new Set();
|
|
35
|
+
return /* @__PURE__ */ new Set([...rowTables(slot.element), ...Object.values(slot.element?.fields ?? {}).flatMap(rowTables)]);
|
|
36
|
+
}
|
|
37
|
+
function wholeTableReads(schema) {
|
|
38
|
+
const found = [];
|
|
39
|
+
const visit = (path, slot) => {
|
|
40
|
+
if (slot === void 0) return;
|
|
41
|
+
if (slot.source?.kind === "derived") {
|
|
42
|
+
const held = heldTables(slot);
|
|
43
|
+
for (const read of slot.source.reads ?? []) {
|
|
44
|
+
const table = read.kind === "home" ? tableKeyOf(read.key) : null;
|
|
45
|
+
if (table !== null && !held.has(table.table)) found.push([
|
|
46
|
+
path,
|
|
47
|
+
String(read.key),
|
|
48
|
+
REGISTRY_TABLE_KEYS[table.table]
|
|
49
|
+
]);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
for (const [field, def] of Object.entries(slot.fields ?? {})) visit(`${path}.${field}`, def);
|
|
53
|
+
visit(path, slot.element);
|
|
54
|
+
};
|
|
55
|
+
for (const [key, slot] of Object.entries(schema.slots)) visit(key, slot);
|
|
56
|
+
for (const [entry, def] of Object.entries(schema.display ?? {})) visit(`display.${entry}`, def);
|
|
57
|
+
return found;
|
|
58
|
+
}
|
|
59
|
+
function rowProjectionLists(schema) {
|
|
60
|
+
const found = [];
|
|
61
|
+
const visit = (path, slot, locked) => {
|
|
62
|
+
if (slot === void 0) return;
|
|
63
|
+
const isLocked = locked || slot.locked === true;
|
|
64
|
+
if (slot.type === "list" && !isLocked && slot.element?.type !== "select" && slot.source?.kind === "derived") {
|
|
65
|
+
const required = new Set((slot.source.requires ?? []).map((read) => read.key));
|
|
66
|
+
const projected = /* @__PURE__ */ new Set();
|
|
67
|
+
for (const read of slot.source.reads ?? []) {
|
|
68
|
+
const column = read.kind === "home" && !required.has(read.key) ? tableColumnOfKey(read.key) : null;
|
|
69
|
+
if (column !== null) projected.add(column.tableKey);
|
|
70
|
+
}
|
|
71
|
+
for (const registryKey of projected) found.push([path, registryKey]);
|
|
72
|
+
}
|
|
73
|
+
for (const [field, def] of Object.entries(slot.fields ?? {})) visit(`${path}.${field}`, def, isLocked);
|
|
74
|
+
visit(path, slot.element, isLocked);
|
|
27
75
|
};
|
|
76
|
+
for (const [key, slot] of Object.entries(schema.slots)) visit(key, slot, false);
|
|
77
|
+
return found;
|
|
28
78
|
}
|
|
29
79
|
function sectionsStage(ctx) {
|
|
30
80
|
const { workspace, discovered, composition } = ctx;
|
|
31
81
|
if (workspace === void 0 || discovered === void 0 || composition === void 0) return Promise.resolve({ skipped: "the composition stage could not derive the placed sections" });
|
|
32
|
-
const corpus = ctx.corpus ?? [];
|
|
33
82
|
const fileOf = (section) => {
|
|
34
83
|
const exported = exportSite(discovered, section);
|
|
35
84
|
if (exported !== void 0) return exported.module;
|
|
@@ -37,37 +86,37 @@ function sectionsStage(ctx) {
|
|
|
37
86
|
return at !== void 0 && isAbsolute(at) && isInsideRoot(workspace.root, at) ? workspacePath(workspace.root, at) : TEMPLATE_FILE;
|
|
38
87
|
};
|
|
39
88
|
const violations = [];
|
|
89
|
+
const hints = [];
|
|
40
90
|
const sections = [];
|
|
41
91
|
for (const [key, section] of composition.sections) {
|
|
42
92
|
const file = fileOf(section);
|
|
43
|
-
const
|
|
44
|
-
let materialized;
|
|
45
|
-
try {
|
|
46
|
-
materialized = materializeSection(section, states);
|
|
47
|
-
} catch (cause) {
|
|
48
|
-
violations.push(cause instanceof GroupDerivationError ? {
|
|
49
|
-
rule: GROUP_RULE[cause.fault],
|
|
50
|
-
file,
|
|
51
|
-
message: cause.message
|
|
52
|
-
} : {
|
|
53
|
-
rule: "groups/probe-failed",
|
|
54
|
-
file,
|
|
55
|
-
message: `Section "${key}" throws under the groups probe: ${describeError(cause)}`
|
|
56
|
-
});
|
|
57
|
-
continue;
|
|
58
|
-
}
|
|
93
|
+
const materialized = materializeSection(section);
|
|
59
94
|
try {
|
|
60
95
|
const parsed = SectionSchema.parse(materialized);
|
|
61
96
|
parsed.slot_order = Object.keys(parsed.slots);
|
|
62
|
-
for (const slot of Object.values(parsed.slots))
|
|
97
|
+
for (const slot of Object.values(parsed.slots)) {
|
|
98
|
+
if (slot.type === "object") stampItemOrder(slot);
|
|
99
|
+
if (slot.type === "list" && slot.element?.type === "object") stampItemOrder(slot.element);
|
|
100
|
+
}
|
|
63
101
|
const fillSpec = FillSpec.parse(fillSpecFromSchema(materialized));
|
|
102
|
+
const schema = flatten(parsed, key);
|
|
64
103
|
sections.push({
|
|
65
104
|
key,
|
|
66
105
|
section,
|
|
67
106
|
file,
|
|
68
|
-
schema
|
|
107
|
+
schema,
|
|
69
108
|
fillSpec
|
|
70
109
|
});
|
|
110
|
+
for (const [path, table, registryKey] of wholeTableReads(schema)) hints.push({
|
|
111
|
+
rule: "sections/whole-table-read",
|
|
112
|
+
file,
|
|
113
|
+
message: `Section "${key}": \`${path}\` computes from the whole table "${table}", so every member of it counts as used. If the value needs only some members, read those columns instead (\`fact.${registryKey}.<member>\`).`
|
|
114
|
+
});
|
|
115
|
+
for (const [path, registryKey] of rowProjectionLists(schema)) violations.push({
|
|
116
|
+
rule: "sections/row-projection-list",
|
|
117
|
+
file,
|
|
118
|
+
message: `Section "${key}": \`${path}\` computes its items from the columns of "${registryKey}", so an item loses its row: the user cannot tell which row it stands for, choose another, or edit the member where it lives. Hold the rows instead: an item holding a row \`from: fact.${registryKey}\`, its other fields reading members off that row, and a \`compute({ reads: [fact.${registryKey}] }, (rows) => …)\` returning the rows the list starts with as its source. Or, where the list is vocabulary nobody arranges, declare it \`locked: true\`.`
|
|
119
|
+
});
|
|
71
120
|
} catch (cause) {
|
|
72
121
|
violations.push({
|
|
73
122
|
rule: "sections/schema-invalid",
|
|
@@ -77,7 +126,10 @@ function sectionsStage(ctx) {
|
|
|
77
126
|
}
|
|
78
127
|
}
|
|
79
128
|
ctx.sections = sections;
|
|
80
|
-
return Promise.resolve({
|
|
129
|
+
return Promise.resolve({
|
|
130
|
+
violations,
|
|
131
|
+
...hints.length === 0 ? {} : { hints }
|
|
132
|
+
});
|
|
81
133
|
}
|
|
82
134
|
|
|
83
135
|
//#endregion
|
package/dist/cli/commands.js
CHANGED
|
@@ -121,7 +121,7 @@ const DECLARED_COMMANDS = [
|
|
|
121
121
|
when: "the library cannot be read from the registry and no earlier copy of it is cached"
|
|
122
122
|
}],
|
|
123
123
|
constraints: [
|
|
124
|
-
"Prints one line per property on stdout: its slug, its description, then its
|
|
124
|
+
"Prints one line per property on stdout: its slug, its description, then its listing intent and non-zero counts.",
|
|
125
125
|
"Reads the latest @homepages/sample-properties from the registry the workspace installs from, and caches each version per user under `XDG_CACHE_HOME`, else `~/.cache`.",
|
|
126
126
|
"When the registry cannot be read, lists the newest cached version and says so on stderr."
|
|
127
127
|
]
|
package/dist/cli/dev/crop.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CROP_PARAM, croppedUrl, cutRegion as cutRegion$1, parseCropParam } from "../../packages/internal/
|
|
1
|
+
import { CROP_PARAM, croppedUrl, cutRegion as cutRegion$1, parseCropParam } from "../../packages/internal/crop-region/dist/index.js";
|
|
2
2
|
|
|
3
3
|
//#region src/cli/dev/crop.ts
|
|
4
4
|
function croppedMediaUrl(url, rect) {
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { cachedAuthorImage, deriveAuthorImage, masterHash } from "../media/derive.js";
|
|
2
|
+
import { FIXTURE_MEDIA_PATH } from "../../fixtures/media-plugin.js";
|
|
3
|
+
import { basename } from "node:path";
|
|
4
|
+
|
|
5
|
+
//#region src/cli/dev/fixture-ladders.ts
|
|
6
|
+
function servedLadder(derivation) {
|
|
7
|
+
const { responsive } = derivation.image;
|
|
8
|
+
if (responsive === null) return null;
|
|
9
|
+
const rehome = (srcset) => srcset.split(",").map((candidate) => {
|
|
10
|
+
const [url = "", ...descriptors] = candidate.trim().split(/\s+/);
|
|
11
|
+
return [`${FIXTURE_MEDIA_PATH}/${basename(url)}`, ...descriptors].join(" ");
|
|
12
|
+
}).join(", ");
|
|
13
|
+
return {
|
|
14
|
+
...responsive,
|
|
15
|
+
sources: responsive.sources.map((source) => ({
|
|
16
|
+
...source,
|
|
17
|
+
srcset: rehome(source.srcset)
|
|
18
|
+
}))
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
const errorText = (err) => err instanceof Error ? err.message : String(err);
|
|
22
|
+
function createFixtureLadders(options) {
|
|
23
|
+
const { cacheDir, log } = options;
|
|
24
|
+
const ready = /* @__PURE__ */ new Map();
|
|
25
|
+
const lookups = /* @__PURE__ */ new Map();
|
|
26
|
+
const rungs = /* @__PURE__ */ new Map();
|
|
27
|
+
let queue = Promise.resolve();
|
|
28
|
+
let reportedNoSharp = false;
|
|
29
|
+
let closed = false;
|
|
30
|
+
const adopt = (key, derivation) => {
|
|
31
|
+
const ladder = servedLadder(derivation);
|
|
32
|
+
if (ladder === null) return false;
|
|
33
|
+
for (const rung of derivation.derivatives) rungs.set(`${FIXTURE_MEDIA_PATH}/${rung.filename}`, rung);
|
|
34
|
+
ready.set(key, ladder);
|
|
35
|
+
return true;
|
|
36
|
+
};
|
|
37
|
+
const derive = async (key, path, bytes) => {
|
|
38
|
+
if (closed) return;
|
|
39
|
+
try {
|
|
40
|
+
const derivation = await deriveAuthorImage(path, bytes, {
|
|
41
|
+
cacheDir,
|
|
42
|
+
...options.loadSharp === void 0 ? {} : { loadSharp: options.loadSharp }
|
|
43
|
+
});
|
|
44
|
+
if (closed) return;
|
|
45
|
+
if (derivation.passthrough) {
|
|
46
|
+
if (!reportedNoSharp) log.write("concrete dev: sharp is not installed, so images serve as their masters, without a responsive ladder.\n");
|
|
47
|
+
reportedNoSharp = true;
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (adopt(key, derivation)) options.onReady();
|
|
51
|
+
} catch (err) {
|
|
52
|
+
log.write(`concrete dev: no responsive ladder for ${path}: ${errorText(err)}\n`);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
const lookup = async (key, path, bytes) => {
|
|
56
|
+
let hit;
|
|
57
|
+
try {
|
|
58
|
+
hit = await cachedAuthorImage(path, bytes, { cacheDir });
|
|
59
|
+
} catch (err) {
|
|
60
|
+
log.write(`concrete dev: no responsive ladder for ${path}: ${errorText(err)}\n`);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (hit !== null) {
|
|
64
|
+
adopt(key, hit);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
queue = queue.then(() => derive(key, path, bytes));
|
|
68
|
+
};
|
|
69
|
+
const idle = async () => {
|
|
70
|
+
for (let seen = queue;; seen = queue) {
|
|
71
|
+
await seen;
|
|
72
|
+
if (seen === queue) return;
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
return {
|
|
76
|
+
async responsiveFor(path, bytes) {
|
|
77
|
+
const key = `${path}|${masterHash(bytes)}`;
|
|
78
|
+
let pending = lookups.get(key);
|
|
79
|
+
if (pending === void 0) {
|
|
80
|
+
pending = lookup(key, path, bytes);
|
|
81
|
+
lookups.set(key, pending);
|
|
82
|
+
}
|
|
83
|
+
await pending;
|
|
84
|
+
return ready.get(key) ?? null;
|
|
85
|
+
},
|
|
86
|
+
rung: (url) => rungs.get(url),
|
|
87
|
+
idle,
|
|
88
|
+
close() {
|
|
89
|
+
closed = true;
|
|
90
|
+
return idle();
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
//#endregion
|
|
96
|
+
export { createFixtureLadders };
|
package/dist/cli/dev/islands.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { CAPTURE_ISLANDS_READY_GLOBAL } from "../../packages/internal/format-geometry/dist/capture.js";
|
|
2
|
-
import "../../packages/internal/format-geometry/dist/index.js";
|
|
3
1
|
import { hasClientDirective } from "../../islands/client-module.js";
|
|
4
2
|
import { isWorkspaceFile, packageFile, toPosix } from "../../platform/paths.js";
|
|
5
3
|
import { listDirSync } from "../../platform/fs.js";
|
|
4
|
+
import { CAPTURE_ISLANDS_READY_GLOBAL } from "../../packages/internal/capture-settle/dist/settle.js";
|
|
5
|
+
import "../../packages/internal/capture-settle/dist/index.js";
|
|
6
6
|
import { readFileSync } from "node:fs";
|
|
7
7
|
import nodePath, { dirname, extname, join, relative } from "node:path";
|
|
8
8
|
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
@@ -193,118 +193,9 @@ window.${CAPTURE_ISLANDS_READY_GLOBAL} = ready;
|
|
|
193
193
|
ready.catch(() => {});
|
|
194
194
|
`;
|
|
195
195
|
}
|
|
196
|
-
function canvasHostCore(runtimeSpecifier, modules) {
|
|
197
|
-
return `${modules.head}
|
|
198
|
-
import { hydrateIslands, unmountIslands } from ${JSON.stringify(runtimeSpecifier)};
|
|
199
|
-
import { createElement, useLayoutEffect } from "react";
|
|
200
|
-
|
|
201
|
-
// The shared canvas kernel's shield names: this script must speak the same spellings or
|
|
202
|
-
// its shields never lift.
|
|
203
|
-
const SHIELD_CLASS = "we-enh-shield";
|
|
204
|
-
const SHIELD_ITEM_CLASS = "we-enh-shield--item";
|
|
205
|
-
const LIVE_ATTR = "data-we-live";
|
|
206
|
-
const ITEM_ATTR = "data-slot-item";
|
|
207
|
-
|
|
208
|
-
const map = window.__TR_ISLAND_MAP || {};
|
|
209
|
-
${modules.importer}
|
|
210
|
-
|
|
211
|
-
// Per-island hydration-commit signal, keyed by the \`editor\` object each load() clones —
|
|
212
|
-
// never by island key, or N copies of one island would share one commit.
|
|
213
|
-
const commitOf = new WeakMap();
|
|
214
|
-
|
|
215
|
-
function withCommitSignal(component, signalCommit) {
|
|
216
|
-
return function IslandCommitSignal(props) {
|
|
217
|
-
useLayoutEffect(signalCommit, []);
|
|
218
|
-
return createElement(component, props);
|
|
219
|
-
};
|
|
220
|
-
}
|
|
221
|
-
${REAL_COMPONENT}
|
|
222
|
-
async function load(key) {
|
|
223
|
-
const mod = await importIsland(key);
|
|
224
|
-
let signalCommit;
|
|
225
|
-
const committed = new Promise((resolve) => { signalCommit = resolve; });
|
|
226
|
-
const editor = mod.editor ? { ...mod.editor } : undefined;
|
|
227
|
-
if (editor) commitOf.set(editor, { committed, signalCommit });
|
|
228
|
-
return { ...mod, editor, default: withCommitSignal(realComponent(mod), signalCommit) };
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
function makeShield(doc, itemShield) {
|
|
232
|
-
const shield = doc.createElement("div");
|
|
233
|
-
shield.className = itemShield ? SHIELD_CLASS + " " + SHIELD_ITEM_CLASS : SHIELD_CLASS;
|
|
234
|
-
shield.setAttribute("aria-hidden", "true");
|
|
235
|
-
return shield;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
function installShield(surface, itemShield) {
|
|
239
|
-
const doc = surface.ownerDocument;
|
|
240
|
-
const win = doc.defaultView;
|
|
241
|
-
const pos = win ? win.getComputedStyle(surface).position : "";
|
|
242
|
-
if (!pos || pos === "static") surface.style.position = "relative";
|
|
243
|
-
if (Array.from(surface.children).some((c) => c.classList.contains(SHIELD_CLASS))) return;
|
|
244
|
-
surface.appendChild(makeShield(doc, itemShield));
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
// Shields derive from the island's own markup: an item shield per collection-item copy,
|
|
248
|
-
// then a base shield per root box (the marker is display:contents).
|
|
249
|
-
function shieldHandle(handle) {
|
|
250
|
-
const editor = handle.editor;
|
|
251
|
-
if (!editor || editor.live !== true) return;
|
|
252
|
-
const root = handle.element;
|
|
253
|
-
for (const itemEl of Array.from(root.querySelectorAll("[" + ITEM_ATTR + "]"))) installShield(itemEl, true);
|
|
254
|
-
const doc = root.ownerDocument;
|
|
255
|
-
const win = doc.defaultView;
|
|
256
|
-
const display = win ? win.getComputedStyle(root).display : "";
|
|
257
|
-
const baseEls = display === "contents" ? Array.from(root.children) : [root];
|
|
258
|
-
for (const baseEl of baseEls) installShield(baseEl, false);
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
let styleInstalled = false;
|
|
262
|
-
function ensureShieldStyle() {
|
|
263
|
-
if (styleInstalled || document.getElementById("concrete-canvas-shield-style")) return;
|
|
264
|
-
styleInstalled = true;
|
|
265
|
-
const style = document.createElement("style");
|
|
266
|
-
style.id = "concrete-canvas-shield-style";
|
|
267
|
-
style.textContent =
|
|
268
|
-
"." + SHIELD_CLASS + "{position:absolute;inset:0;z-index:1;cursor:pointer;background:transparent;}" +
|
|
269
|
-
"." + SHIELD_ITEM_CLASS + "{z-index:2;}" +
|
|
270
|
-
"[" + LIVE_ATTR + "] ." + SHIELD_CLASS + "{display:none;}";
|
|
271
|
-
document.head.appendChild(style);
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
async function hydrateRoot(root) {
|
|
275
|
-
ensureShieldStyle();
|
|
276
|
-
const handles = await hydrateIslands({
|
|
277
|
-
root,
|
|
278
|
-
load,
|
|
279
|
-
// The shield pass needs every handle the moment this settles.
|
|
280
|
-
schedule: "eager",
|
|
281
|
-
shouldHydrate: (ctx) => (ctx.editor ? ctx.editor.live === true : false),
|
|
282
|
-
onError: (error, ctx) => {
|
|
283
|
-
console.error(${JSON.stringify(`${modules.label}: canvas island failed to hydrate:`)}, ctx.key, error);
|
|
284
|
-
if (ctx.editor) { const c = commitOf.get(ctx.editor); if (c) c.signalCommit(); }
|
|
285
|
-
},
|
|
286
|
-
});
|
|
287
|
-
// React commits on a scheduler task; mutating its DOM before the commit makes it discard
|
|
288
|
-
// the server tree, shields and all.
|
|
289
|
-
await Promise.all(
|
|
290
|
-
handles.map((h) => (h.editor ? commitOf.get(h.editor) : undefined)).filter((c) => c !== undefined).map((c) => c.committed),
|
|
291
|
-
);
|
|
292
|
-
for (const handle of handles) shieldHandle(handle);
|
|
293
|
-
return handles;
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
function unmountRoot(root) {
|
|
297
|
-
unmountIslands(root);
|
|
298
|
-
root.querySelectorAll("." + SHIELD_CLASS).forEach((s) => s.remove());
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
window.__trCanvasIslands = { hydrateRoot, unmountRoot };
|
|
302
|
-
void hydrateRoot(document.body);
|
|
303
|
-
`;
|
|
304
|
-
}
|
|
305
196
|
function canvasHostSource(runtimeUrl, root, files) {
|
|
306
|
-
return
|
|
307
|
-
|
|
197
|
+
return `import RefreshRuntime from "/@react-refresh";
|
|
198
|
+
import { installCanvasIslandHost } from ${JSON.stringify(runtimeUrl)};
|
|
308
199
|
|
|
309
200
|
// The React Refresh preamble. The React plugin compiles every client component to assert
|
|
310
201
|
// it ran, and the canvas frame is not built by Vite's own html transform, so the one
|
|
@@ -315,15 +206,13 @@ if (!window.__vite_plugin_react_preamble_installed__) {
|
|
|
315
206
|
window.$RefreshSig$ = () => (type) => type;
|
|
316
207
|
window.__vite_plugin_react_preamble_installed__ = true;
|
|
317
208
|
}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
const
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
label: "concrete dev"
|
|
326
|
-
});
|
|
209
|
+
|
|
210
|
+
${importers(root, files)}
|
|
211
|
+
installCanvasIslandHost((url) => {
|
|
212
|
+
const importer = modules[url];
|
|
213
|
+
return importer ? importer() : Promise.reject(new Error("concrete dev: no island module at " + url));
|
|
214
|
+
}, "concrete dev");
|
|
215
|
+
`;
|
|
327
216
|
}
|
|
328
217
|
async function writeIslandHostScripts(root, files) {
|
|
329
218
|
const dir = join(root, ".concrete", "dev");
|
|
@@ -333,7 +222,7 @@ async function writeIslandHostScripts(root, files) {
|
|
|
333
222
|
const file = join(dir, name);
|
|
334
223
|
await writeFile(file, source, "utf8");
|
|
335
224
|
const version = createHash("sha256").update(source).digest("hex").slice(0, 12);
|
|
336
|
-
return `${fsUrl(file)}?
|
|
225
|
+
return `${fsUrl(file)}?h=${version}`;
|
|
337
226
|
};
|
|
338
227
|
return {
|
|
339
228
|
canvas: await write("island-canvas-host.js", canvasHostSource(runtimeUrl, root, files)),
|
package/dist/cli/dev/listen.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { createServer } from "node:net";
|
|
2
|
+
|
|
1
3
|
//#region src/cli/dev/listen.ts
|
|
2
4
|
const HMR_PORT_OFFSET = 100;
|
|
3
5
|
const MAX_PORT = 65535;
|
|
@@ -6,6 +8,23 @@ function hmrPortFor(port) {
|
|
|
6
8
|
if (port > 65435) throw new Error(`port ${String(port)} leaves no room for the editor's module-reload socket at port + ${String(100)} — pick one no higher than ${String(MAX_DEV_PORT)} with --port <n>`);
|
|
7
9
|
return port + 100;
|
|
8
10
|
}
|
|
11
|
+
function probe(port) {
|
|
12
|
+
return new Promise((resolveProbe) => {
|
|
13
|
+
const server = createServer();
|
|
14
|
+
server.once("error", () => resolveProbe(null));
|
|
15
|
+
server.listen(port, () => {
|
|
16
|
+
const address = server.address();
|
|
17
|
+
server.close(() => resolveProbe(typeof address === "object" && address !== null ? address.port : null));
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
async function freeDevPort() {
|
|
22
|
+
for (let attempt = 0; attempt < 20; attempt += 1) {
|
|
23
|
+
const port = await probe(0);
|
|
24
|
+
if (port !== null && port <= 65435 && await probe(hmrPortFor(port)) !== null) return port;
|
|
25
|
+
}
|
|
26
|
+
throw new Error("no free port pair for the dev server: every probed port's module-reload socket was taken");
|
|
27
|
+
}
|
|
9
28
|
function listenRefusal(err, what) {
|
|
10
29
|
if (err.code === "EADDRINUSE") return /* @__PURE__ */ new Error(`${what} is already in use — pick another with --port <n>`);
|
|
11
30
|
if (err.code === "EACCES") return /* @__PURE__ */ new Error(`${what} is reserved or not permitted on this machine — pick another with --port <n>`);
|
|
@@ -23,4 +42,4 @@ function listenOn(server, port, what) {
|
|
|
23
42
|
}
|
|
24
43
|
|
|
25
44
|
//#endregion
|
|
26
|
-
export { MAX_DEV_PORT, hmrPortFor, listenOn, listenRefusal };
|
|
45
|
+
export { MAX_DEV_PORT, freeDevPort, hmrPortFor, listenOn, listenRefusal };
|
|
@@ -9,7 +9,7 @@ import { build } from "esbuild";
|
|
|
9
9
|
let serial = 0;
|
|
10
10
|
async function loadTemplateModule(options) {
|
|
11
11
|
const { root } = options;
|
|
12
|
-
const media = createFixtureMediaPlugin(root);
|
|
12
|
+
const media = createFixtureMediaPlugin(root, options.ladders);
|
|
13
13
|
const stylesheets = await createPackageStylesheetsPlugin(root);
|
|
14
14
|
const outfile = join(root, ".concrete", "cache", "dev", "template.mjs");
|
|
15
15
|
try {
|