@homepages/concrete 4.0.0 → 6.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 +359 -0
- package/README.md +28 -17
- package/codemods/fill-is-a-source.mjs +533 -0
- package/codemods/manifest.json +18 -0
- package/codemods/reads-replace-reconcile.mjs +285 -0
- package/dist/artifact/playground/client/assets/{index-D1fwOGVK.js → index-u3T7DiSN.js} +96 -96
- package/dist/artifact/playground/client/index.html +1 -1
- package/dist/artifact/playground/host.mjs +23 -23
- package/dist/base.css +3 -8
- package/dist/browser/site-config.js +1 -16
- package/dist/browser/submit-lead.js +0 -31
- package/dist/cli/build/artifact.js +16 -23
- package/dist/cli/build/captures.js +0 -6
- package/dist/cli/build/esbuild.js +0 -17
- package/dist/cli/build/fixtures.js +15 -30
- package/dist/cli/build/icons.js +0 -3
- package/dist/cli/build/index.js +1 -1
- package/dist/cli/build/playground.js +4 -8
- package/dist/cli/build/sections.js +9 -30
- package/dist/cli/build/source.js +52 -27
- package/dist/cli/build/static.js +4 -25
- package/dist/cli/capture/bundle.js +0 -9
- package/dist/cli/capture/capture-browser.js +0 -14
- package/dist/cli/capture/capture.js +1 -8
- package/dist/cli/check/analyze.js +2 -5
- package/dist/cli/check/index.js +1 -1
- package/dist/cli/check/line-endings.js +52 -0
- package/dist/cli/check/load-workspace.js +3 -8
- package/dist/cli/check/portable-names.js +48 -0
- package/dist/cli/check/render/class-conflicts.js +0 -5
- package/dist/cli/check/render/html.js +0 -1
- package/dist/cli/check/render/invariants.js +0 -5
- package/dist/cli/check/render/island-frames.js +0 -25
- package/dist/cli/check/render/marker-coverage.js +0 -20
- package/dist/cli/check/render/nav.js +0 -33
- package/dist/cli/check/report.js +0 -3
- package/dist/cli/check/stages/bundles.js +1 -9
- package/dist/cli/check/stages/composition.js +3 -2
- package/dist/cli/check/stages/dependencies.js +7 -38
- package/dist/cli/check/stages/fixtures.js +3 -31
- package/dist/cli/check/stages/lint.js +2 -2
- package/dist/cli/check/stages/logic.js +3 -34
- package/dist/cli/check/stages/relations.js +46 -0
- package/dist/cli/check/stages/render.js +0 -1
- package/dist/cli/check/stages/sections.js +3 -3
- package/dist/cli/check/stages/stylesheet.js +1 -1
- package/dist/cli/check/stages/typecheck.js +5 -11
- package/dist/cli/check/stages/workspace.js +36 -14
- package/dist/cli/commands.js +9 -56
- package/dist/cli/currency/cache.js +4 -17
- package/dist/cli/currency/decide.js +0 -14
- package/dist/cli/currency/opt-out.js +0 -7
- package/dist/cli/currency/preamble.js +3 -24
- package/dist/cli/currency/prompt.js +0 -1
- package/dist/cli/currency/refresh.js +5 -12
- package/dist/cli/currency/resolve-latest.js +3 -64
- package/dist/cli/currency/version-order.js +0 -12
- package/dist/cli/dev/crop.js +0 -2
- package/dist/cli/dev/http.js +0 -13
- package/dist/cli/dev/index.js +3 -4
- package/dist/cli/dev/islands.js +25 -70
- package/dist/cli/dev/listen.js +26 -0
- package/dist/cli/dev/load-template.js +0 -1
- package/dist/cli/dev/request-error.js +0 -4
- package/dist/cli/dev/server.js +46 -52
- package/dist/cli/dev/tsconfig-paths.js +0 -13
- package/dist/cli/dev/vite.js +9 -38
- package/dist/cli/dev/workspace-reader.js +4 -34
- package/dist/cli/media/cache.js +4 -51
- package/dist/cli/media/derive.js +2 -94
- package/dist/cli/media/deriver-plugin.js +0 -2
- package/dist/cli/media/frame-rung-floor.js +0 -6
- package/dist/cli/property/index.js +0 -4
- package/dist/cli/property/library.js +6 -24
- package/dist/cli/publish/client.js +0 -1
- package/dist/cli/publish/freshness.js +0 -2
- package/dist/cli/publish/git.js +2 -8
- package/dist/cli/publish/index.js +8 -15
- package/dist/cli/publish/pack.js +5 -6
- package/dist/cli/publish/report.js +0 -6
- package/dist/cli/publish/target.js +16 -13
- package/dist/cli/publish/wire.js +0 -6
- package/dist/cli/tar.js +2 -9
- package/dist/cli/upgrade/codemod.js +0 -8
- package/dist/cli/upgrade/index.js +0 -24
- package/dist/cli/upgrade/manifest.js +0 -12
- package/dist/cli/upgrade/plan.js +0 -17
- package/dist/cli/upgrade/stage.js +12 -15
- package/dist/cli/version.js +0 -8
- package/dist/cli/workspace.js +2 -34
- package/dist/cli.js +4 -21
- package/dist/css/compile.js +25 -28
- package/dist/css/graph.js +3 -10
- package/dist/css/inline.js +3 -13
- package/dist/css/rules.js +6 -43
- package/dist/design-system/format-variants.js +0 -22
- package/dist/eslint/authoring.js +0 -2
- package/dist/eslint/correctness.js +0 -7
- package/dist/eslint/rules/editor-reason.js +0 -11
- package/dist/eslint/rules/island-ids.js +0 -1
- package/dist/eslint/rules/jsx-visitor.js +0 -13
- package/dist/eslint/rules/no-editor-globals.js +0 -2
- package/dist/eslint/rules/no-raw-values.js +0 -1
- package/dist/fixtures/brand.js +0 -1
- package/dist/fixtures/bundle-rule.js +4 -9
- package/dist/fixtures/canonical.d.ts +20 -0
- package/dist/fixtures/image-dimensions.js +0 -1
- package/dist/fixtures/load.js +8 -17
- package/dist/fixtures/media-plugin.js +4 -31
- package/dist/fixtures/media.js +0 -21
- package/dist/fixtures/package-stylesheets.js +0 -6
- package/dist/fixtures/property.js +16 -15
- package/dist/fixtures/resolve.js +102 -29
- package/dist/fixtures/rows.js +12 -11
- package/dist/fixtures/synthesize-empties.js +0 -4
- package/dist/fixtures.d.ts +19 -4
- package/dist/fixtures.js +0 -18
- package/dist/index.d.ts +8 -9
- package/dist/index.js +2 -11
- package/dist/islands/client-module.js +0 -11
- package/dist/islands/marker.js +0 -33
- package/dist/node_modules/.pnpm/fflate@0.8.3/node_modules/fflate/esm/browser.js +0 -20
- package/dist/packages/external/concrete/package.js +1 -1
- package/dist/packages/internal/fill-bake/dist/bake-property-ref.js +22 -36
- package/dist/packages/internal/fill-bake/dist/compute-reads.js +4 -0
- package/dist/packages/internal/fill-bake/dist/derive-source.js +40 -0
- package/dist/packages/internal/fill-bake/dist/display.js +0 -1
- package/dist/packages/internal/fill-bake/dist/index.js +4 -4
- package/dist/packages/internal/fill-vocabulary/dist/origination.js +106 -0
- package/dist/packages/internal/fill-vocabulary/dist/row-planners.js +1 -49
- package/dist/packages/internal/format-geometry/dist/capture.js +10 -240
- package/dist/packages/internal/format-geometry/dist/geometry.js +0 -6
- package/dist/packages/internal/image-ladder/dist/crop.js +0 -12
- package/dist/packages/internal/image-ladder/dist/policy.js +0 -14
- package/dist/packages/internal/island-runtime/dist/capture-holds.js +0 -13
- package/dist/packages/internal/island-runtime/dist/contract.js +0 -34
- package/dist/packages/internal/island-runtime/dist/editor-instance-context.js +0 -1
- package/dist/packages/internal/island-runtime/dist/index.js +0 -34
- package/dist/packages/internal/island-runtime/dist/island-id-context.js +0 -1
- package/dist/packages/internal/island-runtime/dist/use-capture-ready.js +0 -15
- package/dist/packages/internal/island-runtime/dist/use-editor.js +0 -10
- package/dist/packages/internal/island-runtime/dist/use-island-id.js +0 -32
- package/dist/packages/internal/property-facts/dist/derive-facts-view.js +2 -17
- package/dist/packages/internal/property-facts/dist/index.js +1 -1
- package/dist/packages/internal/property-facts/dist/{property-facts-CSdkSuD7.js → property-facts-5pxZnlkh.js} +13 -2
- package/dist/packages/internal/section-contracts/dist/cap-contract.js +1 -18
- package/dist/packages/internal/section-contracts/dist/catalog.js +16 -8
- package/dist/packages/internal/section-contracts/dist/choose-select-contract.js +12 -16
- package/dist/packages/internal/section-contracts/dist/count-bounds-contract.js +5 -11
- package/dist/packages/internal/section-contracts/dist/display-contract.js +2 -0
- package/dist/packages/internal/section-contracts/dist/display-evidence-contract.js +2 -8
- package/dist/packages/internal/section-contracts/dist/fill-spec-view.js +13 -0
- package/dist/packages/internal/section-contracts/dist/index.js +2 -1
- package/dist/packages/internal/section-contracts/dist/interpolation-contract.js +16 -42
- package/dist/packages/internal/section-contracts/dist/list-fill-contract.js +24 -43
- package/dist/packages/internal/section-contracts/dist/name-title-contract.js +11 -18
- package/dist/packages/internal/section-contracts/dist/poi-curation-contract.js +10 -12
- package/dist/packages/internal/section-contracts/dist/pooling-field-contract.js +3 -13
- package/dist/packages/internal/section-contracts/dist/row-fill-contract.js +6 -18
- package/dist/packages/internal/section-contracts/dist/runners.js +21 -13
- package/dist/packages/internal/section-contracts/dist/source-contract.js +13 -2
- package/dist/packages/internal/section-contracts/dist/writer-reads-fact-contract.js +31 -0
- package/dist/packages/internal/source-resolution/dist/index.js +5 -30
- package/dist/packages/internal/template-artifact/dist/hash.js +0 -8
- package/dist/packages/internal/template-artifact/dist/index.js +1 -1
- package/dist/packages/internal/template-artifact/dist/layout.js +0 -39
- package/dist/packages/internal/template-artifact/dist/manifest.js +1 -9
- package/dist/packages/internal/template-artifact/dist/sha256.js +0 -1
- package/dist/packages/internal/template-artifact/dist/verify.js +2 -4
- package/dist/packages/internal/template-contracts/dist/collection-editing.js +0 -16
- package/dist/packages/internal/template-contracts/dist/content-categories.js +0 -4
- package/dist/packages/internal/template-contracts/dist/facts-view.d.ts +16 -10
- package/dist/packages/internal/template-contracts/dist/facts-view.js +15 -28
- package/dist/packages/internal/template-contracts/dist/layout.js +0 -7
- package/dist/packages/internal/template-contracts/dist/markers.js +0 -29
- package/dist/packages/internal/template-contracts/dist/select-key.js +0 -6
- package/dist/packages/internal/template-contracts/dist/slot-catalog.d.ts +56 -34
- package/dist/packages/internal/template-contracts/dist/slot-catalog.js +22 -389
- package/dist/platform/file-url.js +8 -0
- package/dist/platform/fs.js +73 -0
- package/dist/platform/names.js +63 -0
- package/dist/platform/order.js +7 -0
- package/dist/platform/paths.js +62 -0
- package/dist/platform/process.js +97 -0
- package/dist/playground/host/page-state.js +0 -2
- package/dist/playground/host/paths.js +0 -1
- package/dist/playground/layout.js +0 -7
- package/dist/playground/wire.js +0 -8
- package/dist/primitives/FrameShell.js +0 -18
- package/dist/primitives/Image.d.ts +5 -1
- package/dist/primitives/Image.js +2 -68
- package/dist/primitives/Section.js +0 -13
- package/dist/primitives/Tour.js +0 -26
- package/dist/primitives/Video.js +0 -32
- package/dist/primitives/embed-playback.js +0 -1
- package/dist/primitives/marker-attrs.js +0 -17
- package/dist/primitives/picture-sources.js +6 -1
- package/dist/primitives/probe-context.js +0 -7
- package/dist/primitives/slot-bindings.d.ts +3 -2
- package/dist/primitives/slot-bindings.js +0 -46
- package/dist/primitives/slot-document.js +0 -11
- package/dist/primitives/slot-group.js +0 -9
- package/dist/primitives/slot-media.js +0 -27
- package/dist/primitives/slot-scalar.js +0 -4
- package/dist/primitives/slot.js +0 -6
- package/dist/rules/registry.js +42 -24
- package/dist/schema/compute.d.ts +46 -8
- package/dist/schema/compute.js +21 -15
- package/dist/schema/define-schema.d.ts +1 -1
- package/dist/schema/define-schema.js +37 -17
- package/dist/schema/extract-fill-spec.js +93 -180
- package/dist/schema/extract-used-facts.js +16 -158
- package/dist/schema/fact.d.ts +33 -18
- package/dist/schema/fact.js +7 -11
- package/dist/schema/fill-builders.d.ts +91 -366
- package/dist/schema/fill-builders.js +21 -259
- package/dist/schema/fill-declaration.d.ts +7 -69
- package/dist/schema/fill-declaration.js +5 -34
- package/dist/schema/fill-spec.js +59 -148
- package/dist/schema/format-presets.js +0 -12
- package/dist/schema/format.js +0 -7
- package/dist/schema/layout.js +0 -10
- package/dist/schema/manifest.js +0 -39
- package/dist/schema/property-facts.d.ts +20 -0
- package/dist/schema/runtime-values.d.ts +6 -18
- package/dist/schema/section-nav.js +0 -15
- package/dist/schema/section-props.d.ts +7 -9
- package/dist/schema/section-schema.d.ts +0 -1
- package/dist/schema/section-schema.js +4 -20
- package/dist/schema/slot-builders.d.ts +128 -117
- package/dist/schema/slot-builders.js +18 -201
- package/dist/schema/slot-ref.d.ts +63 -0
- package/dist/schema/slot-ref.js +33 -0
- package/dist/schema/slot-types.d.ts +3 -2
- package/dist/schema/slot-types.js +11 -20
- package/dist/section/declare.d.ts +14 -10
- package/dist/section/declare.js +13 -2
- package/dist/section/discovery.js +6 -21
- package/dist/section/groups.js +0 -6
- package/dist/section/materialize.js +0 -5
- package/dist/section/placements.js +0 -4
- package/dist/section/section.d.ts +8 -5
- package/dist/section/section.js +7 -29
- package/dist/styles.css +5 -0
- package/dist/template/define-template.d.ts +0 -4
- package/dist/template/define-template.js +1 -15
- package/dist/template/logic-build.js +8 -35
- package/dist/template/logic-shim.d.ts +4 -5
- package/dist/template/logic-shim.js +2 -6
- package/dist/template/logic-transform.js +0 -6
- package/dist/template/materialize.js +52 -43
- package/dist/template/mirror-types.js +43 -0
- package/dist/template/running-copy.js +5 -20
- package/dist/template/section-reads.js +83 -0
- package/guide/reference/cli/INDEX.md +12 -6
- package/guide/reference/cli/build.md +1 -1
- package/guide/reference/cli/check.md +1 -1
- package/guide/reference/cli/dev.md +3 -3
- package/guide/reference/cli/property-add.md +1 -1
- package/guide/reference/cli/property-list.md +1 -1
- package/guide/reference/cli/publish.md +4 -2
- package/guide/reference/cli/upgrade.md +1 -1
- package/guide/reference/rules/INDEX.md +26 -13
- package/package.json +4 -2
- package/dist/packages/internal/fact-interpolation/dist/index.js +0 -22
- package/dist/packages/internal/fill-bake/dist/reconcile-cross-section.js +0 -170
- package/dist/packages/internal/fill-vocabulary/dist/facts.d.ts +0 -32
- package/dist/packages/internal/fill-vocabulary/dist/facts.js +0 -131
- package/dist/packages/internal/template-contracts/dist/slot-overrides.js +0 -11
- package/dist/schema/fill-spec.d.ts +0 -18
- package/dist/template/reconcile.d.ts +0 -67
- package/dist/template/reconcile.js +0 -25
|
@@ -2,11 +2,6 @@ import { COMPUTED, getComputed } from "../schema/compute.js";
|
|
|
2
2
|
import { deriveGroups } from "./groups.js";
|
|
3
3
|
|
|
4
4
|
//#region src/section/materialize.ts
|
|
5
|
-
/**
|
|
6
|
-
* Materialize a section: derive its groups over `states` (the blank state is always
|
|
7
|
-
* included) and freeze its slot order. The result parses with `SectionSchema` and
|
|
8
|
-
* feeds `fillSpecFromSchema` exactly as a `defineSchema` result does today.
|
|
9
|
-
*/
|
|
10
5
|
function materializeSection(section, states = []) {
|
|
11
6
|
const groups = deriveGroups(section, states);
|
|
12
7
|
const result = {
|
|
@@ -3,10 +3,6 @@ import { createElement } from "react";
|
|
|
3
3
|
import { renderToStaticMarkup } from "react-dom/server";
|
|
4
4
|
|
|
5
5
|
//#region src/section/placements.ts
|
|
6
|
-
/**
|
|
7
|
-
* Render `node` once under the placement probe. Returns the placements in order and
|
|
8
|
-
* whatever markup the node emitted besides them.
|
|
9
|
-
*/
|
|
10
6
|
function recordPlacements(node) {
|
|
11
7
|
const placements = [];
|
|
12
8
|
return {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { SectionNav } from "../schema/section-nav.js";
|
|
2
1
|
import { Slot } from "../schema/slot-types.js";
|
|
2
|
+
import { SlotRef } from "../schema/slot-ref.js";
|
|
3
|
+
import { SectionNav } from "../schema/section-nav.js";
|
|
3
4
|
import "../schema/section-schema.js";
|
|
4
5
|
import { SectionProps } from "../schema/section-props.js";
|
|
5
6
|
import { SlotBindingMap } from "../primitives/slot-bindings.js";
|
|
6
7
|
import { DisplayInput } from "../schema/define-schema.js";
|
|
7
|
-
import { SectionOptions, SectionSchemaOf,
|
|
8
|
+
import { DisplayRefsOf, SectionOptions, SectionSchemaOf, SlotRefsOf } from "./declare.js";
|
|
8
9
|
import { ReactNode } from "react";
|
|
9
10
|
//#region src/section/section.d.ts
|
|
10
11
|
/** The contract props the platform renders a section with: `{ slots, nav, variant }`. */
|
|
@@ -32,8 +33,9 @@ declare const SECTION: unique symbol;
|
|
|
32
33
|
/**
|
|
33
34
|
* The value {@link section} returns: a React component taking the contract props (or,
|
|
34
35
|
* placed on a page, an optional `instance`), carrying its `key`, `label`, `required`,
|
|
35
|
-
* its materializable `schema`,
|
|
36
|
-
*
|
|
36
|
+
* its materializable `schema`, one {@link SlotRef} per slot (`Hero.slots.hero_image`)
|
|
37
|
+
* and one per declared display entry (`Hero.display.visibility`) — what another
|
|
38
|
+
* section's declaration `reads`.
|
|
37
39
|
*/
|
|
38
40
|
interface SectionValue<Key extends string, Slots extends Record<string, Slot>, Display extends DisplayInput> {
|
|
39
41
|
(props: SectionContractProps<Slots, Display> | SectionPlacementProps): ReactNode;
|
|
@@ -42,6 +44,7 @@ interface SectionValue<Key extends string, Slots extends Record<string, Slot>, D
|
|
|
42
44
|
readonly required: boolean;
|
|
43
45
|
readonly schema: SectionSchemaOf<Slots, Display>;
|
|
44
46
|
readonly slots: SlotRefsOf<Key, Slots>;
|
|
47
|
+
readonly display: DisplayRefsOf<Key, Display>;
|
|
45
48
|
readonly [SECTION]: true;
|
|
46
49
|
}
|
|
47
50
|
/**
|
|
@@ -52,7 +55,7 @@ interface SectionValue<Key extends string, Slots extends Record<string, Slot>, D
|
|
|
52
55
|
* key: "hero",
|
|
53
56
|
* label: "Hero",
|
|
54
57
|
* slots: {
|
|
55
|
-
* headline: text.medium({ cap: 60, label: "Headline",
|
|
58
|
+
* headline: text.medium({ cap: 60, label: "Headline", source: fill({ brief: "A confident one-line headline." }) }),
|
|
56
59
|
* street: text.short({ source: fact.property.address_street, label: "Street" }),
|
|
57
60
|
* },
|
|
58
61
|
* }, ({ slot, nav }) => (
|
package/dist/section/section.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { filePathOfUrl } from "../platform/file-url.js";
|
|
1
2
|
import { ProbeContext } from "../primitives/probe-context.js";
|
|
2
3
|
import { bindSlots } from "../primitives/slot-bindings.js";
|
|
3
4
|
import { declareSection } from "./declare.js";
|
|
@@ -14,36 +15,11 @@ function callerModule() {
|
|
|
14
15
|
if (match === null) continue;
|
|
15
16
|
const file = match[1] ?? "";
|
|
16
17
|
if (/\/section\/section\.(?:tsx?|m?js)$/.test(file)) continue;
|
|
17
|
-
return file.startsWith("file://") ?
|
|
18
|
+
return file.startsWith("file://") ? filePathOfUrl(file) : file;
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
|
-
/**
|
|
21
|
-
* Declare a section: its schema and its markup in one exported value.
|
|
22
|
-
*
|
|
23
|
-
* ```tsx
|
|
24
|
-
* export const Hero = section({
|
|
25
|
-
* key: "hero",
|
|
26
|
-
* label: "Hero",
|
|
27
|
-
* slots: {
|
|
28
|
-
* headline: text.medium({ cap: 60, label: "Headline", fill: textBlock({ … }) }),
|
|
29
|
-
* street: text.short({ source: fact.property.address_street, label: "Street" }),
|
|
30
|
-
* },
|
|
31
|
-
* }, ({ slot, nav }) => (
|
|
32
|
-
* <Section id={nav.selfAnchor}>
|
|
33
|
-
* <Slot.Text slot={slot.headline} as="h1" />
|
|
34
|
-
* <SlotGroup id="address" label="Property address">
|
|
35
|
-
* <Slot.Text slot={slot.street} as="span" />
|
|
36
|
-
* </SlotGroup>
|
|
37
|
-
* </Section>
|
|
38
|
-
* ));
|
|
39
|
-
* ```
|
|
40
|
-
*
|
|
41
|
-
* The returned component is what a page places (`<Hero />`) and what the platform
|
|
42
|
-
* renders with `{ slots, nav, variant }`. `render` receives bindings: `slot.<id>` is
|
|
43
|
-
* typed by that slot's own declaration, and `variant` by the declared cases.
|
|
44
|
-
*/
|
|
45
21
|
function section(options, render) {
|
|
46
|
-
const { key, label, required, schema, slots } = declareSection(options);
|
|
22
|
+
const { key, label, required, schema, slots, display } = declareSection(options);
|
|
47
23
|
const component = (props) => {
|
|
48
24
|
const probe = useContext(ProbeContext);
|
|
49
25
|
if (probe?.kind === "placement") {
|
|
@@ -83,16 +59,18 @@ function section(options, render) {
|
|
|
83
59
|
value: slots,
|
|
84
60
|
enumerable: true
|
|
85
61
|
},
|
|
62
|
+
display: {
|
|
63
|
+
value: display,
|
|
64
|
+
enumerable: true
|
|
65
|
+
},
|
|
86
66
|
[SECTION]: { value: true }
|
|
87
67
|
});
|
|
88
68
|
declared.set(value, { module: callerModule() });
|
|
89
69
|
return value;
|
|
90
70
|
}
|
|
91
|
-
/** Is this export a section value? What discovery asks of every export of every module. */
|
|
92
71
|
function isSection(value) {
|
|
93
72
|
return typeof value === "function" && value[SECTION] === true;
|
|
94
73
|
}
|
|
95
|
-
/** The module that declared a section, when the runtime's stack frames named it. */
|
|
96
74
|
function declaringModule(section) {
|
|
97
75
|
return declared.get(section)?.module;
|
|
98
76
|
}
|
package/dist/styles.css
CHANGED
|
@@ -34,6 +34,11 @@
|
|
|
34
34
|
* utilities and 19 stray @property registrations, ~2.5 KB. If a primitive ever moves out
|
|
35
35
|
* of primitives/, widen this — an unstyled <Image> in every template is the failure mode,
|
|
36
36
|
* and scripts/verify-consumer.mjs is what catches it.
|
|
37
|
+
*
|
|
38
|
+
* The primitives' own prose is kept out the same way: the build strips JSDoc from the
|
|
39
|
+
* shipped JS (tsdown.config.ts; the .d.ts keeps it), so an example class in a doc comment
|
|
40
|
+
* — `Section`'s `px-gutter` — never compiles into a template that declares its token.
|
|
41
|
+
* compile.test.ts's framework-prose workspace is the gate.
|
|
37
42
|
*/
|
|
38
43
|
@source "./primitives/**/*.js";
|
|
39
44
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { DocumentFormat, ImageFormat } from "../packages/internal/format-geometry/dist/format.js";
|
|
2
2
|
import { WebsiteFormat } from "../schema/format.js";
|
|
3
|
-
import { ReconcileRule } from "./reconcile.js";
|
|
4
3
|
import { ReactNode } from "react";
|
|
5
4
|
//#region src/template/define-template.d.ts
|
|
6
5
|
/**
|
|
@@ -63,8 +62,6 @@ interface DefineTemplateCommon {
|
|
|
63
62
|
/** The template's icon, imported: `import icon from "./icon.svg"`. */
|
|
64
63
|
readonly icon: string;
|
|
65
64
|
readonly scope: TemplateScope;
|
|
66
|
-
/** The cross-section rules — the template's named `reconcile` export, passed here as that same array. */
|
|
67
|
-
readonly reconcile?: readonly ReconcileRule[];
|
|
68
65
|
readonly preview?: TemplatePreview;
|
|
69
66
|
}
|
|
70
67
|
/** One rendered format, or a non-empty list of one class. */
|
|
@@ -122,7 +119,6 @@ interface TemplateValue {
|
|
|
122
119
|
readonly pages: readonly TemplatePage[];
|
|
123
120
|
/** In canvas-bar order; always explicit. */
|
|
124
121
|
readonly canvases: readonly TemplateCanvas[];
|
|
125
|
-
readonly reconcile: readonly ReconcileRule[];
|
|
126
122
|
readonly preview?: TemplatePreview;
|
|
127
123
|
readonly [TEMPLATE]: true;
|
|
128
124
|
}
|
|
@@ -9,15 +9,8 @@ const CLASS_BY_CATEGORY = {
|
|
|
9
9
|
postcard: "document",
|
|
10
10
|
presentation: "document"
|
|
11
11
|
};
|
|
12
|
-
/**
|
|
13
|
-
* Declare a template. Validates what needs no render — the scope, the format set's
|
|
14
|
-
* class, the canvases naming real pages — and returns the value the probe reads.
|
|
15
|
-
*
|
|
16
|
-
* @throws when the scope names no org, names one twice, or names one that is not a
|
|
17
|
-
* UUID; when `format` is an empty list or mixes classes; when `pages` is empty; when
|
|
18
|
-
* a declared canvas names a page the site map lacks.
|
|
19
|
-
*/
|
|
20
12
|
function defineTemplate(input) {
|
|
13
|
+
if ("reconcile" in input) throw new Error(`Template "${input.key}" passes \`reconcile\`, which defineTemplate no longer takes. A slot that depends on another section reads it on its own \`source:\` — a slot ref (\`source: Hero.slots.title\`) or \`compute({ reads }, fn)\`. \`concrete upgrade\` removes an empty \`reconcile: []\` and lists every rule left to move by hand.`);
|
|
21
14
|
assertScope(input.scope);
|
|
22
15
|
const formats = Array.isArray(input.format) ? [...input.format] : [input.format];
|
|
23
16
|
const output = outputClassOf(input.key, formats);
|
|
@@ -55,13 +48,11 @@ function defineTemplate(input) {
|
|
|
55
48
|
scope: input.scope,
|
|
56
49
|
pages,
|
|
57
50
|
canvases,
|
|
58
|
-
reconcile: input.reconcile ?? [],
|
|
59
51
|
...input.preview === void 0 ? {} : { preview: input.preview },
|
|
60
52
|
[TEMPLATE]: true
|
|
61
53
|
};
|
|
62
54
|
return Object.freeze(value);
|
|
63
55
|
}
|
|
64
|
-
/** Is this export a template value? What a command asks of `template.ts`'s default export. */
|
|
65
56
|
function isTemplate(value) {
|
|
66
57
|
return typeof value === "object" && value !== null && value[TEMPLATE] === true;
|
|
67
58
|
}
|
|
@@ -84,11 +75,6 @@ function assertScope(scope) {
|
|
|
84
75
|
seen.add(org);
|
|
85
76
|
}
|
|
86
77
|
}
|
|
87
|
-
/**
|
|
88
|
-
* The orgs this scope grants the template to, in authored order. Empty for
|
|
89
|
-
* `"global"` — a global template is offered by its visibility class and holds
|
|
90
|
-
* no grants at all.
|
|
91
|
-
*/
|
|
92
78
|
function orgsForScope(scope) {
|
|
93
79
|
if (scope === "global") return [];
|
|
94
80
|
return "orgs" in scope ? scope.orgs : [scope.org];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { underNodeModules } from "../platform/paths.js";
|
|
1
2
|
import { stripRendersForLogic } from "./logic-transform.js";
|
|
2
3
|
import { existsSync } from "node:fs";
|
|
3
|
-
import { dirname, extname } from "node:path";
|
|
4
|
+
import nodePath, { dirname, extname } from "node:path";
|
|
4
5
|
import ts from "typescript";
|
|
5
6
|
import { fileURLToPath } from "node:url";
|
|
6
7
|
import { readFile } from "node:fs/promises";
|
|
@@ -24,6 +25,9 @@ const LOADER_BY_EXT = {
|
|
|
24
25
|
".cjs": "js",
|
|
25
26
|
".jsx": "jsx"
|
|
26
27
|
};
|
|
28
|
+
function isLogicWorkspaceModule(file, paths = nodePath) {
|
|
29
|
+
return MODULE_RE.test(file) && !underNodeModules(file, paths);
|
|
30
|
+
}
|
|
27
31
|
function shimPath() {
|
|
28
32
|
const resolved = fileURLToPath(import.meta.resolve("./logic-shim.js"));
|
|
29
33
|
if (existsSync(resolved)) return resolved;
|
|
@@ -128,14 +132,14 @@ function logicPlugin() {
|
|
|
128
132
|
pluginData: WORKSPACE_RESOLVE
|
|
129
133
|
});
|
|
130
134
|
if (resolved.errors.length > 0 || resolved.external || resolved.namespace !== "file") return void 0;
|
|
131
|
-
if (
|
|
135
|
+
if (!isLogicWorkspaceModule(resolved.path)) return void 0;
|
|
132
136
|
return {
|
|
133
137
|
path: resolved.path,
|
|
134
138
|
sideEffects: false
|
|
135
139
|
};
|
|
136
140
|
});
|
|
137
141
|
api.onLoad({ filter: MODULE_RE }, async (args) => {
|
|
138
|
-
if (args.path
|
|
142
|
+
if (!isLogicWorkspaceModule(args.path)) return void 0;
|
|
139
143
|
const loader = LOADER_BY_EXT[extname(args.path)];
|
|
140
144
|
if (loader === void 0) return void 0;
|
|
141
145
|
return {
|
|
@@ -192,11 +196,6 @@ async function bundleLogic(what, contents, resolveDir) {
|
|
|
192
196
|
if (js === void 0) throw new Error(`${what}: esbuild produced no logic-bundle output`);
|
|
193
197
|
return js.text;
|
|
194
198
|
}
|
|
195
|
-
/**
|
|
196
|
-
* A section's logic bundle: `export const computed` — the handle → pure-fn map read off
|
|
197
|
-
* the section's schema (`display.<entry>` for a computed display origin, the slot id for
|
|
198
|
-
* a computed source), or `{}` for a section that authored none.
|
|
199
|
-
*/
|
|
200
199
|
async function buildSectionLogic(input) {
|
|
201
200
|
const contents = [
|
|
202
201
|
`import * as authored from ${JSON.stringify(input.module)};`,
|
|
@@ -205,32 +204,6 @@ async function buildSectionLogic(input) {
|
|
|
205
204
|
].join("\n");
|
|
206
205
|
return bundleLogic(`section ${input.exportName} (${input.module})`, contents, dirname(input.module));
|
|
207
206
|
}
|
|
208
|
-
/**
|
|
209
|
-
* A template's logic bundle: `export const reconcile` — the template's named
|
|
210
|
-
* `reconcile` export with every read and every edit addressed to the instance the
|
|
211
|
-
* composition placed for its section — and `export const instances`, the section key →
|
|
212
|
-
* instance id list the interpreter builds the site view from, emitted as data.
|
|
213
|
-
*/
|
|
214
|
-
async function buildTemplateLogic(input) {
|
|
215
|
-
const instanceBySection = {};
|
|
216
|
-
for (const instance of input.instances) if (!(instance.key in instanceBySection)) instanceBySection[instance.key] = instance.instanceId;
|
|
217
|
-
const contents = [
|
|
218
|
-
`import * as template from ${JSON.stringify(input.templateFile)};`,
|
|
219
|
-
`const instanceBySection = ${JSON.stringify(instanceBySection)};`,
|
|
220
|
-
`const instanceOf = (section) => {`,
|
|
221
|
-
` const instanceId = instanceBySection[section];`,
|
|
222
|
-
` if (instanceId === undefined) throw new Error('reconcile: no placed instance for section "' + section + '"');`,
|
|
223
|
-
` return instanceId;`,
|
|
224
|
-
`};`,
|
|
225
|
-
`export const instances = ${JSON.stringify(input.instances)};`,
|
|
226
|
-
`export const reconcile = (template.reconcile ?? []).map((rule) => ({`,
|
|
227
|
-
` description: rule.description,`,
|
|
228
|
-
` reads: rule.reads.map((ref) => ({ instanceId: instanceOf(ref.section), slot: ref.slot })),`,
|
|
229
|
-
` fn: (ctx) => rule.fn(ctx).map((edit) => ({ op: "set", instanceId: instanceOf(edit.section), slot: edit.slot, value: edit.value })),`,
|
|
230
|
-
`}));`
|
|
231
|
-
].join("\n");
|
|
232
|
-
return bundleLogic(`template (${input.templateFile})`, contents, dirname(input.templateFile));
|
|
233
|
-
}
|
|
234
207
|
|
|
235
208
|
//#endregion
|
|
236
|
-
export { buildSectionLogic,
|
|
209
|
+
export { buildSectionLogic, isLogicWorkspaceModule };
|
|
@@ -1,12 +1,11 @@
|
|
|
1
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 "../packages/internal/island-runtime/dist/contract.js";
|
|
2
|
+
import { fill } from "../schema/fill-builders.js";
|
|
3
|
+
import { Slot as Slot$1 } from "../schema/slot-types.js";
|
|
2
4
|
import { fact } from "../schema/fact.js";
|
|
3
5
|
import { compute, getComputed } from "../schema/compute.js";
|
|
4
|
-
import { chooseFrom, contactAssign, documentAssign, imageAssign, listFill, nameRows, textBlock, tourAssign, videoAssign } from "../schema/fill-builders.js";
|
|
5
6
|
import { document, image, list, number, poi, select, text, tour, url, video } from "../schema/slot-builders.js";
|
|
6
|
-
import { Slot as Slot$1 } from "../schema/slot-types.js";
|
|
7
7
|
import { DisplayInput } from "../schema/define-schema.js";
|
|
8
8
|
import { SectionDeclaration, SectionOptions } from "../section/declare.js";
|
|
9
|
-
import { rule, set } from "./reconcile.js";
|
|
10
9
|
import { ATTR_SECTION_INSTANCE_ID, ATTR_SLOT_FIELD, ATTR_SLOT_GROUP, ATTR_SLOT_ID, ATTR_SLOT_ITEM, ATTR_SLOT_TEXT_LEAF, ATTR_SLOT_UNSELECTABLE, ATTR_TR_ENHANCE } from "../packages/internal/template-contracts/dist/markers.js";
|
|
11
10
|
import { presets } from "../schema/format-presets.js";
|
|
12
11
|
import { a4Landscape, a4Portrait, deck16x9, facebookPost, halfLetterFlyer, instagramPortrait, instagramSquare, instagramStory, letterLandscape, letterPortrait, linkedinPost, postcard6x4, postcard7x5, website, xPost } from "../schema/formats.js";
|
|
@@ -14,7 +13,7 @@ import { a4Landscape, a4Portrait, deck16x9, facebookPost, halfLetterFlyer, insta
|
|
|
14
13
|
declare const CONCRETE_VERSION = "";
|
|
15
14
|
/** The declaration half of `section()`: the value minus its component. */
|
|
16
15
|
declare function section<const Key extends string, const Slots extends Record<string, Slot$1>, const Display extends DisplayInput = Record<string, never>>(options: SectionOptions<Key, Slots, Display>): SectionDeclaration<Key, Slots, Display>;
|
|
17
|
-
/** Inert:
|
|
16
|
+
/** Inert: a section bundle that reaches a template module drops its default export unreferenced. */
|
|
18
17
|
declare function defineTemplate<T>(input: T): T;
|
|
19
18
|
/** The text a surviving stub throws with — what the build greps the output for. */
|
|
20
19
|
declare const LOGIC_STUB_MARKER = "@homepages/concrete logic build: a render-time primitive reached the bundle";
|
|
@@ -41,4 +40,4 @@ declare const Slot: {
|
|
|
41
40
|
List: () => never;
|
|
42
41
|
};
|
|
43
42
|
//#endregion
|
|
44
|
-
export { ATTR_ISLAND_FRAMELESS, ATTR_ISLAND_ID, ATTR_ISLAND_KEY, ATTR_ISLAND_PROPS, ATTR_SECTION_INSTANCE_ID, ATTR_SLOT_FIELD, ATTR_SLOT_GROUP, ATTR_SLOT_ID, ATTR_SLOT_ITEM, ATTR_SLOT_TEXT_LEAF, ATTR_SLOT_UNSELECTABLE, ATTR_TR_ENHANCE, CONCRETE_VERSION, EDITOR_BRIDGE_PROP, EDITOR_BRIDGE_PROTOCOL, EditorBridge, EditorBridgeSelection, EditorSelection, FrameShell, ISLAND_CAPTURE_HOLDS_GLOBAL, ISLAND_ELEMENT, Image, IslandComponent, IslandEditor, IslandEditorOptions, IslandMarker, IslandModule, IslandProps, IslandPropsError, IslandServerFrame, LOGIC_STUB_MARKER, Section, Slot, SlotGroup, Tour, Video, a4Landscape, a4Portrait, bindItems,
|
|
43
|
+
export { ATTR_ISLAND_FRAMELESS, ATTR_ISLAND_ID, ATTR_ISLAND_KEY, ATTR_ISLAND_PROPS, ATTR_SECTION_INSTANCE_ID, ATTR_SLOT_FIELD, ATTR_SLOT_GROUP, ATTR_SLOT_ID, ATTR_SLOT_ITEM, ATTR_SLOT_TEXT_LEAF, ATTR_SLOT_UNSELECTABLE, ATTR_TR_ENHANCE, CONCRETE_VERSION, EDITOR_BRIDGE_PROP, EDITOR_BRIDGE_PROTOCOL, EditorBridge, EditorBridgeSelection, EditorSelection, FrameShell, ISLAND_CAPTURE_HOLDS_GLOBAL, ISLAND_ELEMENT, Image, IslandComponent, IslandEditor, IslandEditorOptions, IslandMarker, IslandModule, IslandProps, IslandPropsError, IslandServerFrame, LOGIC_STUB_MARKER, Section, Slot, SlotGroup, Tour, Video, a4Landscape, a4Portrait, bindItems, compute, deck16x9, defineTemplate, deserializeIslandProps, document, facebookPost, fact, fill, getComputed, halfLetterFlyer, image, instagramPortrait, instagramSquare, instagramStory, islandId, letterLandscape, letterPortrait, linkedinPost, list, number, poi, postcard6x4, postcard7x5, presets, section, select, serializeIslandProps, text, tour, url, useCaptureReady, useEditor, useIslandId, video, website, xPost };
|
|
@@ -1,25 +1,21 @@
|
|
|
1
1
|
import { 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 } from "../packages/internal/island-runtime/dist/contract.js";
|
|
2
2
|
import { compute, getComputed } from "../schema/compute.js";
|
|
3
|
+
import { fill } from "../schema/fill-builders.js";
|
|
3
4
|
import { declareSection } from "../section/declare.js";
|
|
4
|
-
import { rule, set } from "./reconcile.js";
|
|
5
5
|
import { ATTR_SECTION_INSTANCE_ID, ATTR_SLOT_FIELD, ATTR_SLOT_GROUP, ATTR_SLOT_ID, ATTR_SLOT_ITEM, ATTR_SLOT_TEXT_LEAF, ATTR_SLOT_UNSELECTABLE, ATTR_TR_ENHANCE } from "../packages/internal/template-contracts/dist/markers.js";
|
|
6
6
|
import { document, image, list, number, poi, select, text, tour, url, video } from "../schema/slot-builders.js";
|
|
7
7
|
import { fact } from "../schema/fact.js";
|
|
8
|
-
import { chooseFrom, contactAssign, documentAssign, imageAssign, listFill, nameRows, textBlock, tourAssign, videoAssign } from "../schema/fill-builders.js";
|
|
9
8
|
import { presets } from "../schema/format-presets.js";
|
|
10
9
|
import { a4Landscape, a4Portrait, deck16x9, facebookPost, halfLetterFlyer, instagramPortrait, instagramSquare, instagramStory, letterLandscape, letterPortrait, linkedinPost, postcard6x4, postcard7x5, website, xPost } from "../schema/formats.js";
|
|
11
10
|
|
|
12
11
|
//#region src/template/logic-shim.ts
|
|
13
12
|
const CONCRETE_VERSION = "";
|
|
14
|
-
/** The declaration half of `section()`: the value minus its component. */
|
|
15
13
|
function section(options) {
|
|
16
14
|
return declareSection(options);
|
|
17
15
|
}
|
|
18
|
-
/** Inert: the template's default export is dropped by the bundle, which reads the named `reconcile`. */
|
|
19
16
|
function defineTemplate(input) {
|
|
20
17
|
return input;
|
|
21
18
|
}
|
|
22
|
-
/** The text a surviving stub throws with — what the build greps the output for. */
|
|
23
19
|
const LOGIC_STUB_MARKER = "@homepages/concrete logic build: a render-time primitive reached the bundle";
|
|
24
20
|
const stub = (name) => {
|
|
25
21
|
return () => {
|
|
@@ -50,4 +46,4 @@ const Slot = {
|
|
|
50
46
|
};
|
|
51
47
|
|
|
52
48
|
//#endregion
|
|
53
|
-
export { ATTR_ISLAND_FRAMELESS, ATTR_ISLAND_ID, ATTR_ISLAND_KEY, ATTR_ISLAND_PROPS, ATTR_SECTION_INSTANCE_ID, ATTR_SLOT_FIELD, ATTR_SLOT_GROUP, ATTR_SLOT_ID, ATTR_SLOT_ITEM, ATTR_SLOT_TEXT_LEAF, ATTR_SLOT_UNSELECTABLE, ATTR_TR_ENHANCE, CONCRETE_VERSION, EDITOR_BRIDGE_PROP, EDITOR_BRIDGE_PROTOCOL, FrameShell, ISLAND_CAPTURE_HOLDS_GLOBAL, ISLAND_ELEMENT, Image, IslandMarker, IslandPropsError, LOGIC_STUB_MARKER, Section, Slot, SlotGroup, Tour, Video, a4Landscape, a4Portrait, bindItems,
|
|
49
|
+
export { ATTR_ISLAND_FRAMELESS, ATTR_ISLAND_ID, ATTR_ISLAND_KEY, ATTR_ISLAND_PROPS, ATTR_SECTION_INSTANCE_ID, ATTR_SLOT_FIELD, ATTR_SLOT_GROUP, ATTR_SLOT_ID, ATTR_SLOT_ITEM, ATTR_SLOT_TEXT_LEAF, ATTR_SLOT_UNSELECTABLE, ATTR_TR_ENHANCE, CONCRETE_VERSION, EDITOR_BRIDGE_PROP, EDITOR_BRIDGE_PROTOCOL, FrameShell, ISLAND_CAPTURE_HOLDS_GLOBAL, ISLAND_ELEMENT, Image, IslandMarker, IslandPropsError, LOGIC_STUB_MARKER, Section, Slot, SlotGroup, Tour, Video, a4Landscape, a4Portrait, bindItems, compute, deck16x9, defineTemplate, deserializeIslandProps, document, facebookPost, fact, fill, getComputed, halfLetterFlyer, image, instagramPortrait, instagramSquare, instagramStory, islandId, letterLandscape, letterPortrait, linkedinPost, list, number, poi, postcard6x4, postcard7x5, presets, section, select, serializeIslandProps, text, tour, url, useCaptureReady, useEditor, useIslandId, video, website, xPost };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import ts from "typescript";
|
|
2
2
|
|
|
3
3
|
//#region src/template/logic-transform.ts
|
|
4
|
-
/** The package the two authoring calls are imported from. */
|
|
5
4
|
const CONCRETE_SPECIFIER = "@homepages/concrete";
|
|
6
5
|
const PURE = "/* @__PURE__ */ ";
|
|
7
6
|
function calleeNames(sourceFile) {
|
|
@@ -44,11 +43,6 @@ function alreadyPure(sourceFile, call) {
|
|
|
44
43
|
const leading = sourceFile.text.slice(call.getFullStart(), call.getStart(sourceFile));
|
|
45
44
|
return /@__PURE__/.test(leading);
|
|
46
45
|
}
|
|
47
|
-
/**
|
|
48
|
-
* Strip every `section(options, render)` in `source` to `section(options)` and mark it
|
|
49
|
-
* and every `defineTemplate(...)` pure. Returns the source unchanged when the module
|
|
50
|
-
* imports neither name from the package.
|
|
51
|
-
*/
|
|
52
46
|
function stripRendersForLogic(source, fileName) {
|
|
53
47
|
const kind = /\.tsx$/.test(fileName) ? ts.ScriptKind.TSX : /\.jsx$/.test(fileName) ? ts.ScriptKind.JSX : /\.[cm]?js$/.test(fileName) ? ts.ScriptKind.JS : ts.ScriptKind.TS;
|
|
54
48
|
const sourceFile = ts.createSourceFile(fileName, source, ts.ScriptTarget.ES2022, true, kind);
|
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
import { recordPlacements } from "../section/placements.js";
|
|
2
2
|
import { TemplateManifest } from "../schema/manifest.js";
|
|
3
|
+
import { buildReadGraph, isSourcedTarget } from "./section-reads.js";
|
|
3
4
|
import { createElement } from "react";
|
|
4
5
|
|
|
5
6
|
//#region src/template/materialize.ts
|
|
6
|
-
/**
|
|
7
|
-
* Render each page under the placement probe and build the composition.
|
|
8
|
-
*
|
|
9
|
-
* @throws when a page emits markup that is not a section; when one instance id names
|
|
10
|
-
* two different sections; when a rule reads a section no page places; and on every
|
|
11
|
-
* `TemplateManifest` rule (duplicate page id, duplicate instance on one page, the
|
|
12
|
-
* website page rules, the canvas partition, the name cap, the format rules).
|
|
13
|
-
*/
|
|
14
7
|
function materializeTemplate(template, options = {}) {
|
|
15
8
|
const sections = /* @__PURE__ */ new Map();
|
|
16
9
|
const sectionOfInstance = /* @__PURE__ */ new Map();
|
|
@@ -49,18 +42,23 @@ function materializeTemplate(template, options = {}) {
|
|
|
49
42
|
}))
|
|
50
43
|
};
|
|
51
44
|
});
|
|
45
|
+
const manifest = TemplateManifest.parse({
|
|
46
|
+
key: template.key,
|
|
47
|
+
name: template.name,
|
|
48
|
+
output: template.output,
|
|
49
|
+
formats: template.formats,
|
|
50
|
+
pages,
|
|
51
|
+
canvases: template.canvases,
|
|
52
|
+
...template.preview === void 0 ? {} : { preview: template.preview }
|
|
53
|
+
});
|
|
54
|
+
const readGraph = buildReadGraph(sections);
|
|
55
|
+
const { reads, readDiagnostics } = resolveReads(readGraph, sections, instanceBySection);
|
|
52
56
|
return {
|
|
53
|
-
manifest
|
|
54
|
-
key: template.key,
|
|
55
|
-
name: template.name,
|
|
56
|
-
output: template.output,
|
|
57
|
-
formats: template.formats,
|
|
58
|
-
pages,
|
|
59
|
-
canvases: template.canvases,
|
|
60
|
-
...template.preview === void 0 ? {} : { preview: template.preview }
|
|
61
|
-
}),
|
|
57
|
+
manifest,
|
|
62
58
|
instances,
|
|
63
|
-
reads
|
|
59
|
+
reads,
|
|
60
|
+
readGraph,
|
|
61
|
+
readDiagnostics,
|
|
64
62
|
instanceBySection,
|
|
65
63
|
placements,
|
|
66
64
|
sections
|
|
@@ -70,38 +68,49 @@ function excerpt(markup) {
|
|
|
70
68
|
const oneLine = markup.replace(/\s+/g, " ").trim();
|
|
71
69
|
return oneLine.length > 80 ? `${oneLine.slice(0, 77)}…` : oneLine;
|
|
72
70
|
}
|
|
73
|
-
function resolveReads(
|
|
71
|
+
function resolveReads(graph, sections, instanceBySection) {
|
|
74
72
|
const seen = /* @__PURE__ */ new Set();
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
if (seen.has(key)) continue;
|
|
73
|
+
const reads = [];
|
|
74
|
+
const readDiagnostics = [];
|
|
75
|
+
const index = (instanceId, slot) => {
|
|
76
|
+
const key = `${instanceId} ${slot}`;
|
|
77
|
+
if (seen.has(key)) return;
|
|
81
78
|
seen.add(key);
|
|
82
|
-
|
|
79
|
+
reads.push({
|
|
83
80
|
instanceId,
|
|
84
|
-
slot
|
|
81
|
+
slot
|
|
85
82
|
});
|
|
83
|
+
};
|
|
84
|
+
for (const edge of graph.edges) {
|
|
85
|
+
const upstream = sections.get(edge.to.section);
|
|
86
|
+
const instanceId = instanceBySection[edge.to.section];
|
|
87
|
+
if (upstream === void 0 || instanceId === void 0) {
|
|
88
|
+
readDiagnostics.push({
|
|
89
|
+
kind: "unplaced",
|
|
90
|
+
from: edge.from,
|
|
91
|
+
at: edge.at,
|
|
92
|
+
section: edge.to.section,
|
|
93
|
+
slot: edge.to.slot
|
|
94
|
+
});
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
if (edge.kind === "fill") {
|
|
98
|
+
if (isSourcedTarget(upstream.schema, edge.to.slot)) readDiagnostics.push({
|
|
99
|
+
kind: "fill-reads-computed",
|
|
100
|
+
from: edge.from,
|
|
101
|
+
at: edge.at,
|
|
102
|
+
section: edge.to.section,
|
|
103
|
+
slot: edge.to.slot
|
|
104
|
+
});
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
index(instanceId, edge.to.slot);
|
|
86
108
|
}
|
|
87
|
-
return out;
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Address a rule's edits to instances: the shape the template logic bundle exports and
|
|
91
|
-
* the interpreter joins to a content document by id. Also compiled INTO that bundle,
|
|
92
|
-
* so keep it dependency-free.
|
|
93
|
-
*/
|
|
94
|
-
function resolveEdit(edit, instanceBySection) {
|
|
95
|
-
const setEdit = edit;
|
|
96
|
-
const instanceId = instanceBySection[setEdit.section];
|
|
97
|
-
if (instanceId === void 0) throw new Error(`reconcile set(): no placed instance for section "${setEdit.section}"`);
|
|
98
109
|
return {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
slot: setEdit.slot,
|
|
102
|
-
value: setEdit.value
|
|
110
|
+
reads,
|
|
111
|
+
readDiagnostics
|
|
103
112
|
};
|
|
104
113
|
}
|
|
105
114
|
|
|
106
115
|
//#endregion
|
|
107
|
-
export { materializeTemplate
|
|
116
|
+
export { materializeTemplate };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { getComputed, isMirrorFn } from "../schema/compute.js";
|
|
2
|
+
import { DISPLAY_REF_PREFIX, serializedSlotRefs } from "../schema/slot-ref.js";
|
|
3
|
+
|
|
4
|
+
//#region src/template/mirror-types.ts
|
|
5
|
+
function valueKindOf(def) {
|
|
6
|
+
const type = def.type ?? "unknown";
|
|
7
|
+
if (type === "text" || type === "select" || type === "url") return "string";
|
|
8
|
+
if (type !== "list") return type;
|
|
9
|
+
if (def.element !== void 0) return `list<${valueKindOf(def.element)}>`;
|
|
10
|
+
return `list<{ ${Object.entries(def.fields ?? {}).map(([key, field]) => `${key}: ${valueKindOf(field)}`).sort().join("; ")} }>`;
|
|
11
|
+
}
|
|
12
|
+
function upstreamKindOf(schema, slot) {
|
|
13
|
+
if (slot.startsWith("display.")) return schema.meta.display?.[slot.slice("display.".length)] === void 0 ? void 0 : "string";
|
|
14
|
+
const def = schema.slots[slot];
|
|
15
|
+
return def === void 0 ? void 0 : valueKindOf(def);
|
|
16
|
+
}
|
|
17
|
+
function mirrorMismatches(sections) {
|
|
18
|
+
const out = [];
|
|
19
|
+
for (const [key, section] of sections) {
|
|
20
|
+
const handles = getComputed(section.schema);
|
|
21
|
+
for (const [slot, def] of Object.entries(section.schema.slots)) {
|
|
22
|
+
const source = def.source;
|
|
23
|
+
if (source?.kind !== "derived" || source.transform === void 0 || !isMirrorFn(handles[source.transform])) continue;
|
|
24
|
+
const [upstream] = serializedSlotRefs(source.reads ?? []);
|
|
25
|
+
if (upstream === void 0) continue;
|
|
26
|
+
const from = sections.get(upstream.section);
|
|
27
|
+
const upstreamKind = from === void 0 ? void 0 : upstreamKindOf(from.schema, upstream.slot);
|
|
28
|
+
if (upstreamKind === void 0) continue;
|
|
29
|
+
const mirrorKind = valueKindOf(def);
|
|
30
|
+
if (mirrorKind !== upstreamKind) out.push({
|
|
31
|
+
section: key,
|
|
32
|
+
slot,
|
|
33
|
+
upstream,
|
|
34
|
+
mirrorKind,
|
|
35
|
+
upstreamKind
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return out;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
//#endregion
|
|
43
|
+
export { mirrorMismatches, valueKindOf };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { RUNNING_FROM_SOURCE, externalFile, packageRoot } from "../platform/paths.js";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
4
|
|
|
5
5
|
//#region src/template/running-copy.ts
|
|
6
6
|
const PACKAGE = "@homepages/concrete";
|
|
@@ -10,23 +10,12 @@ const SOURCE_ENTRIES = {
|
|
|
10
10
|
"./browser": "src/browser/index.ts",
|
|
11
11
|
"./eslint": "src/eslint/index.ts"
|
|
12
12
|
};
|
|
13
|
-
function packageRoot() {
|
|
14
|
-
let dir = dirname(fileURLToPath(import.meta.url));
|
|
15
|
-
for (;;) {
|
|
16
|
-
const manifest = join(dir, "package.json");
|
|
17
|
-
if (existsSync(manifest) && JSON.parse(readFileSync(manifest, "utf8")).name === PACKAGE) return dir;
|
|
18
|
-
const parent = dirname(dir);
|
|
19
|
-
if (parent === dir) throw new Error(`${PACKAGE}: could not find this package's own package.json above ${fileURLToPath(import.meta.url)}.`);
|
|
20
|
-
dir = parent;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
13
|
let cached;
|
|
24
|
-
/** Specifier (`@homepages/concrete`, `@homepages/concrete/fixtures`, …) → the running copy's absolute entry file. */
|
|
25
14
|
function runningCopyEntries() {
|
|
26
15
|
if (cached !== void 0) return cached;
|
|
27
16
|
const root = packageRoot();
|
|
28
17
|
const entries = /* @__PURE__ */ new Map();
|
|
29
|
-
if (
|
|
18
|
+
if (RUNNING_FROM_SOURCE) for (const [subpath, file] of Object.entries(SOURCE_ENTRIES)) entries.set(PACKAGE + subpath.slice(1), join(root, file));
|
|
30
19
|
else {
|
|
31
20
|
const { exports } = JSON.parse(readFileSync(join(root, "package.json"), "utf8"));
|
|
32
21
|
for (const [subpath, target] of Object.entries(exports)) {
|
|
@@ -37,7 +26,6 @@ function runningCopyEntries() {
|
|
|
37
26
|
cached = entries;
|
|
38
27
|
return entries;
|
|
39
28
|
}
|
|
40
|
-
/** An esbuild plugin resolving the package's JavaScript subpaths to the running copy, kept external. */
|
|
41
29
|
function runningCopyPlugin() {
|
|
42
30
|
const entries = runningCopyEntries();
|
|
43
31
|
return {
|
|
@@ -45,10 +33,7 @@ function runningCopyPlugin() {
|
|
|
45
33
|
setup(build) {
|
|
46
34
|
build.onResolve({ filter: /^@homepages\/concrete(?:\/[a-z-]+)?$/ }, (args) => {
|
|
47
35
|
const path = entries.get(args.path);
|
|
48
|
-
return path === void 0 ? null :
|
|
49
|
-
path,
|
|
50
|
-
external: true
|
|
51
|
-
};
|
|
36
|
+
return path === void 0 ? null : externalFile(path);
|
|
52
37
|
});
|
|
53
38
|
}
|
|
54
39
|
};
|