@homepages/concrete 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +59 -0
- package/README.md +174 -0
- package/codemods/manifest.json +9 -0
- package/dist/artifact/playground/client/assets/index-BSA1yutg.css +1 -0
- package/dist/artifact/playground/client/assets/index-JloQyj8h.js +1101 -0
- package/dist/artifact/playground/client/index.html +13 -0
- package/dist/artifact/playground/client/island-canvas-host.mjs +1 -0
- package/dist/artifact/playground/host.mjs +127 -0
- package/dist/asset-modules.d.ts +99 -0
- package/dist/base.css +220 -0
- package/dist/browser/site-config.d.ts +18 -0
- package/dist/browser/site-config.js +56 -0
- package/dist/browser/submit-lead.d.ts +98 -0
- package/dist/browser/submit-lead.js +188 -0
- package/dist/browser.d.ts +3 -0
- package/dist/browser.js +4 -0
- package/dist/cli/build/artifact.js +225 -0
- package/dist/cli/build/captures.js +67 -0
- package/dist/cli/build/esbuild.js +127 -0
- package/dist/cli/build/fixtures.js +96 -0
- package/dist/cli/build/icons.js +76 -0
- package/dist/cli/build/index.js +38 -0
- package/dist/cli/build/playground.js +31 -0
- package/dist/cli/build/sections.js +236 -0
- package/dist/cli/build/source.js +62 -0
- package/dist/cli/build/static.js +156 -0
- package/dist/cli/capture/bundle.js +37 -0
- package/dist/cli/capture/capture-browser.js +51 -0
- package/dist/cli/capture/capture.js +121 -0
- package/dist/cli/check/analyze.js +95 -0
- package/dist/cli/check/index.js +19 -0
- package/dist/cli/check/load-workspace.js +119 -0
- package/dist/cli/check/messages.js +16 -0
- package/dist/cli/check/render/class-conflicts.js +39 -0
- package/dist/cli/check/render/html.js +86 -0
- package/dist/cli/check/render/inputs.js +53 -0
- package/dist/cli/check/render/invariants.js +58 -0
- package/dist/cli/check/render/island-frames.js +72 -0
- package/dist/cli/check/render/marker-coverage.js +102 -0
- package/dist/cli/check/render/nav.js +64 -0
- package/dist/cli/check/report.js +73 -0
- package/dist/cli/check/stages/bundles.js +129 -0
- package/dist/cli/check/stages/composition.js +67 -0
- package/dist/cli/check/stages/contracts.js +22 -0
- package/dist/cli/check/stages/dependencies.js +261 -0
- package/dist/cli/check/stages/fixtures.js +74 -0
- package/dist/cli/check/stages/lint.js +41 -0
- package/dist/cli/check/stages/logic.js +63 -0
- package/dist/cli/check/stages/render.js +144 -0
- package/dist/cli/check/stages/sections.js +83 -0
- package/dist/cli/check/stages/stylesheet.js +31 -0
- package/dist/cli/check/stages/typecheck.js +68 -0
- package/dist/cli/check/stages/workspace.js +26 -0
- package/dist/cli/commands.js +342 -0
- package/dist/cli/currency/cache.js +89 -0
- package/dist/cli/currency/decide.js +65 -0
- package/dist/cli/currency/opt-out.js +16 -0
- package/dist/cli/currency/preamble.js +183 -0
- package/dist/cli/currency/prompt.js +28 -0
- package/dist/cli/currency/refresh.js +44 -0
- package/dist/cli/currency/resolve-latest.js +185 -0
- package/dist/cli/currency/version-order.js +38 -0
- package/dist/cli/dev/crop.js +22 -0
- package/dist/cli/dev/hmr.js +26 -0
- package/dist/cli/dev/http.js +129 -0
- package/dist/cli/dev/index.js +70 -0
- package/dist/cli/dev/islands.js +390 -0
- package/dist/cli/dev/load-template.js +46 -0
- package/dist/cli/dev/request-error.js +22 -0
- package/dist/cli/dev/server.js +307 -0
- package/dist/cli/dev/tsconfig-paths.js +95 -0
- package/dist/cli/dev/vite.js +85 -0
- package/dist/cli/dev/workspace-reader.js +274 -0
- package/dist/cli/io.d.ts +14 -0
- package/dist/cli/media/cache.js +125 -0
- package/dist/cli/media/derive.js +252 -0
- package/dist/cli/media/deriver-plugin.js +71 -0
- package/dist/cli/property/index.js +180 -0
- package/dist/cli/property/library.js +137 -0
- package/dist/cli/publish/client.js +119 -0
- package/dist/cli/publish/freshness.js +66 -0
- package/dist/cli/publish/git.js +43 -0
- package/dist/cli/publish/index.js +207 -0
- package/dist/cli/publish/pack.js +78 -0
- package/dist/cli/publish/report.js +98 -0
- package/dist/cli/publish/target.js +87 -0
- package/dist/cli/publish/wire.js +29 -0
- package/dist/cli/tar.js +87 -0
- package/dist/cli/upgrade/codemod.js +56 -0
- package/dist/cli/upgrade/index.js +263 -0
- package/dist/cli/upgrade/manifest.js +72 -0
- package/dist/cli/upgrade/plan.js +68 -0
- package/dist/cli/upgrade/stage.js +71 -0
- package/dist/cli/version.d.ts +12 -0
- package/dist/cli/version.js +15 -0
- package/dist/cli/workspace.js +108 -0
- package/dist/cli.d.ts +6 -0
- package/dist/cli.js +94 -0
- package/dist/css/compile.js +77 -0
- package/dist/css/graph.js +109 -0
- package/dist/css/inline.js +132 -0
- package/dist/css/rules.js +65 -0
- package/dist/design-system/format-variants.js +127 -0
- package/dist/eslint/authoring.js +46 -0
- package/dist/eslint/correctness.js +42 -0
- package/dist/eslint/rules/editor-declaration.js +103 -0
- package/dist/eslint/rules/editor-reason.js +135 -0
- package/dist/eslint/rules/island-imports.js +20 -0
- package/dist/eslint/rules/jsx-visitor.js +20 -0
- package/dist/eslint/rules/no-client-runtime.js +88 -0
- package/dist/eslint/rules/no-editor-globals.js +60 -0
- package/dist/eslint/rules/no-hard-coded-color.js +183 -0
- package/dist/eslint/rules/no-inline-style.js +24 -0
- package/dist/eslint/rules/no-marker-literal.js +37 -0
- package/dist/eslint/rules/no-nondeterminism.js +44 -0
- package/dist/eslint/rules/no-px-breakpoint.js +44 -0
- package/dist/eslint/rules/no-raw-values.js +45 -0
- package/dist/eslint/rules/serializable-props.js +95 -0
- package/dist/eslint.d.ts +6 -0
- package/dist/eslint.js +26 -0
- package/dist/fixtures/brand.d.ts +4 -0
- package/dist/fixtures/brand.js +9 -0
- package/dist/fixtures/bundle-rule.js +67 -0
- package/dist/fixtures/canonical.d.ts +149 -0
- package/dist/fixtures/image-dimensions.js +59 -0
- package/dist/fixtures/load.js +154 -0
- package/dist/fixtures/media-plugin.js +141 -0
- package/dist/fixtures/media.js +165 -0
- package/dist/fixtures/property.js +210 -0
- package/dist/fixtures/resolve.js +202 -0
- package/dist/fixtures/rows.js +108 -0
- package/dist/fixtures/synthesize-empties.js +42 -0
- package/dist/fixtures.d.ts +213 -0
- package/dist/fixtures.js +37 -0
- package/dist/index.d.ts +53 -0
- package/dist/index.js +37 -0
- package/dist/islands/client-module.js +97 -0
- package/dist/islands/marker.d.ts +43 -0
- package/dist/islands/marker.js +44 -0
- package/dist/node_modules/.pnpm/fflate@0.8.3/node_modules/fflate/esm/browser.js +687 -0
- package/dist/packages/external/concrete/package.js +5 -0
- package/dist/packages/internal/fact-interpolation/dist/index.js +22 -0
- package/dist/packages/internal/fill-bake/dist/bake-property-ref.js +111 -0
- package/dist/packages/internal/fill-bake/dist/display.js +9 -0
- package/dist/packages/internal/fill-bake/dist/index.js +6 -0
- package/dist/packages/internal/fill-bake/dist/reconcile-cross-section.js +170 -0
- package/dist/packages/internal/fill-vocabulary/dist/facts.d.ts +32 -0
- package/dist/packages/internal/fill-vocabulary/dist/facts.js +131 -0
- package/dist/packages/internal/fill-vocabulary/dist/row-planners.js +73 -0
- package/dist/packages/internal/format-geometry/dist/capture.js +404 -0
- package/dist/packages/internal/format-geometry/dist/format.d.ts +41 -0
- package/dist/packages/internal/format-geometry/dist/geometry.js +58 -0
- package/dist/packages/internal/format-geometry/dist/index.js +4 -0
- package/dist/packages/internal/image-descriptor/dist/index.d.ts +35 -0
- package/dist/packages/internal/image-ladder/dist/crop.js +82 -0
- package/dist/packages/internal/image-ladder/dist/encode.js +23 -0
- package/dist/packages/internal/image-ladder/dist/index.js +4 -0
- package/dist/packages/internal/image-ladder/dist/policy.js +102 -0
- package/dist/packages/internal/island-runtime/dist/capture-holds.d.ts +13 -0
- package/dist/packages/internal/island-runtime/dist/capture-holds.js +45 -0
- package/dist/packages/internal/island-runtime/dist/contract.d.ts +176 -0
- package/dist/packages/internal/island-runtime/dist/contract.js +94 -0
- package/dist/packages/internal/island-runtime/dist/editor-instance-context.js +15 -0
- package/dist/packages/internal/island-runtime/dist/index.d.ts +103 -0
- package/dist/packages/internal/island-runtime/dist/index.js +163 -0
- package/dist/packages/internal/island-runtime/dist/use-capture-ready.d.ts +19 -0
- package/dist/packages/internal/island-runtime/dist/use-capture-ready.js +39 -0
- package/dist/packages/internal/island-runtime/dist/use-editor.d.ts +22 -0
- package/dist/packages/internal/island-runtime/dist/use-editor.js +54 -0
- package/dist/packages/internal/island-runtime/dist/viewport-schedule.js +105 -0
- package/dist/packages/internal/property-facts/dist/derive-facts-view.js +25 -0
- package/dist/packages/internal/property-facts/dist/index.js +3 -0
- package/dist/packages/internal/property-facts/dist/property-facts-CSdkSuD7.js +181 -0
- package/dist/packages/internal/section-contracts/dist/cap-contract.js +59 -0
- package/dist/packages/internal/section-contracts/dist/catalog.js +102 -0
- package/dist/packages/internal/section-contracts/dist/choose-select-contract.js +24 -0
- package/dist/packages/internal/section-contracts/dist/count-bounds-contract.js +48 -0
- package/dist/packages/internal/section-contracts/dist/display-contract.js +30 -0
- package/dist/packages/internal/section-contracts/dist/display-evidence-contract.js +17 -0
- package/dist/packages/internal/section-contracts/dist/group-contract.js +21 -0
- package/dist/packages/internal/section-contracts/dist/index.js +26 -0
- package/dist/packages/internal/section-contracts/dist/interpolation-contract.js +48 -0
- package/dist/packages/internal/section-contracts/dist/list-fill-contract.js +53 -0
- package/dist/packages/internal/section-contracts/dist/list-scalar-contract.js +70 -0
- package/dist/packages/internal/section-contracts/dist/name-title-contract.js +27 -0
- package/dist/packages/internal/section-contracts/dist/nested-slot-contract.js +12 -0
- package/dist/packages/internal/section-contracts/dist/option-source-contract.js +22 -0
- package/dist/packages/internal/section-contracts/dist/poi-curation-contract.js +18 -0
- package/dist/packages/internal/section-contracts/dist/pooling-field-contract.js +30 -0
- package/dist/packages/internal/section-contracts/dist/record-collection-contract.js +24 -0
- package/dist/packages/internal/section-contracts/dist/row-contract.js +37 -0
- package/dist/packages/internal/section-contracts/dist/row-fill-contract.js +38 -0
- package/dist/packages/internal/section-contracts/dist/runners.js +181 -0
- package/dist/packages/internal/section-contracts/dist/select-contract.js +28 -0
- package/dist/packages/internal/section-contracts/dist/source-contract.js +48 -0
- package/dist/packages/internal/section-contracts/dist/source-filter-contract.js +15 -0
- package/dist/packages/internal/section-contracts/dist/sources-contract.js +28 -0
- package/dist/packages/internal/section-contracts/dist/url-contract.js +20 -0
- package/dist/packages/internal/source-resolution/dist/index.js +222 -0
- package/dist/packages/internal/template-artifact/dist/hash.js +50 -0
- package/dist/packages/internal/template-artifact/dist/index.js +7 -0
- package/dist/packages/internal/template-artifact/dist/layout.js +165 -0
- package/dist/packages/internal/template-artifact/dist/manifest.js +73 -0
- package/dist/packages/internal/template-artifact/dist/sha256.js +138 -0
- package/dist/packages/internal/template-artifact/dist/verify.js +275 -0
- package/dist/packages/internal/template-contracts/dist/collection-editing.js +38 -0
- package/dist/packages/internal/template-contracts/dist/content-categories.d.ts +10 -0
- package/dist/packages/internal/template-contracts/dist/content-categories.js +17 -0
- package/dist/packages/internal/template-contracts/dist/document-value.d.ts +33 -0
- package/dist/packages/internal/template-contracts/dist/facts-view.d.ts +81 -0
- package/dist/packages/internal/template-contracts/dist/facts-view.js +136 -0
- package/dist/packages/internal/template-contracts/dist/layout.js +17 -0
- package/dist/packages/internal/template-contracts/dist/markers.d.ts +40 -0
- package/dist/packages/internal/template-contracts/dist/markers.js +41 -0
- package/dist/packages/internal/template-contracts/dist/poi-row.d.ts +63 -0
- package/dist/packages/internal/template-contracts/dist/select-key.js +13 -0
- package/dist/packages/internal/template-contracts/dist/slot-catalog.d.ts +1112 -0
- package/dist/packages/internal/template-contracts/dist/slot-catalog.js +1109 -0
- package/dist/packages/internal/template-contracts/dist/slot-overrides.js +11 -0
- package/dist/packages/internal/template-contracts/dist/tour-value.d.ts +45 -0
- package/dist/packages/internal/template-contracts/dist/video-value.d.ts +63 -0
- package/dist/playground/host/page-state.js +12 -0
- package/dist/playground/host/paths.js +9 -0
- package/dist/playground/layout.js +24 -0
- package/dist/playground/wire.js +36 -0
- package/dist/playground-island-runtime.d.ts +3 -0
- package/dist/playground-island-runtime.js +4 -0
- package/dist/primitives/FrameShell.d.ts +29 -0
- package/dist/primitives/FrameShell.js +34 -0
- package/dist/primitives/Image.d.ts +119 -0
- package/dist/primitives/Image.js +173 -0
- package/dist/primitives/Section.d.ts +22 -0
- package/dist/primitives/Section.js +26 -0
- package/dist/primitives/Tour.d.ts +43 -0
- package/dist/primitives/Tour.js +72 -0
- package/dist/primitives/Video.d.ts +57 -0
- package/dist/primitives/Video.js +116 -0
- package/dist/primitives/embed-playback.js +50 -0
- package/dist/primitives/index.d.ts +11 -0
- package/dist/primitives/marker-attrs.js +44 -0
- package/dist/primitives/object-fit.js +11 -0
- package/dist/primitives/picture-sources.d.ts +24 -0
- package/dist/primitives/picture-sources.js +52 -0
- package/dist/primitives/probe-context.js +24 -0
- package/dist/primitives/slot-bindings.d.ts +96 -0
- package/dist/primitives/slot-bindings.js +226 -0
- package/dist/primitives/slot-document.d.ts +35 -0
- package/dist/primitives/slot-document.js +37 -0
- package/dist/primitives/slot-group.d.ts +40 -0
- package/dist/primitives/slot-group.js +45 -0
- package/dist/primitives/slot-list.d.ts +21 -0
- package/dist/primitives/slot-list.js +23 -0
- package/dist/primitives/slot-media.d.ts +71 -0
- package/dist/primitives/slot-media.js +98 -0
- package/dist/primitives/slot-scalar.d.ts +53 -0
- package/dist/primitives/slot-scalar.js +98 -0
- package/dist/primitives/slot.d.ts +26 -0
- package/dist/primitives/slot.js +28 -0
- package/dist/rules/registry.js +479 -0
- package/dist/schema/compute.d.ts +22 -0
- package/dist/schema/compute.js +30 -0
- package/dist/schema/define-schema.d.ts +27 -0
- package/dist/schema/define-schema.js +73 -0
- package/dist/schema/extract-fill-spec.js +246 -0
- package/dist/schema/extract-used-facts.js +176 -0
- package/dist/schema/fact.d.ts +65 -0
- package/dist/schema/fact.js +33 -0
- package/dist/schema/fill-builders.d.ts +387 -0
- package/dist/schema/fill-builders.js +263 -0
- package/dist/schema/fill-declaration.d.ts +76 -0
- package/dist/schema/fill-declaration.js +43 -0
- package/dist/schema/fill-spec.d.ts +18 -0
- package/dist/schema/fill-spec.js +170 -0
- package/dist/schema/format-presets.d.ts +27 -0
- package/dist/schema/format-presets.js +76 -0
- package/dist/schema/format.d.ts +22 -0
- package/dist/schema/format.js +40 -0
- package/dist/schema/formats.d.ts +6 -0
- package/dist/schema/formats.js +7 -0
- package/dist/schema/layout.d.ts +32 -0
- package/dist/schema/layout.js +30 -0
- package/dist/schema/manifest.js +300 -0
- package/dist/schema/property-facts.d.ts +83 -0
- package/dist/schema/runtime-values.d.ts +88 -0
- package/dist/schema/section-nav.d.ts +38 -0
- package/dist/schema/section-nav.js +29 -0
- package/dist/schema/section-props.d.ts +98 -0
- package/dist/schema/section-schema.d.ts +53 -0
- package/dist/schema/section-schema.js +54 -0
- package/dist/schema/slot-builders.d.ts +497 -0
- package/dist/schema/slot-builders.js +331 -0
- package/dist/schema/slot-types.d.ts +110 -0
- package/dist/schema/slot-types.js +187 -0
- package/dist/section/declare.d.ts +44 -0
- package/dist/section/declare.js +27 -0
- package/dist/section/discovery.js +76 -0
- package/dist/section/groups.js +74 -0
- package/dist/section/materialize.js +28 -0
- package/dist/section/placements.js +28 -0
- package/dist/section/section.d.ts +69 -0
- package/dist/section/section.js +101 -0
- package/dist/site-analytics.d.ts +1 -0
- package/dist/site-analytics.js +15 -0
- package/dist/site-runtime/analytics.js +97 -0
- package/dist/site-runtime/site-integrations.js +97 -0
- package/dist/styles.css +60 -0
- package/dist/template/define-template.d.ts +139 -0
- package/dist/template/define-template.js +98 -0
- package/dist/template/logic-build.js +191 -0
- package/dist/template/logic-shim.d.ts +43 -0
- package/dist/template/logic-shim.js +52 -0
- package/dist/template/logic-transform.js +92 -0
- package/dist/template/materialize.js +107 -0
- package/dist/template/reconcile.d.ts +67 -0
- package/dist/template/reconcile.js +25 -0
- package/dist/template/running-copy.js +58 -0
- package/guide/reference/cli/INDEX.md +79 -0
- package/guide/reference/cli/build.md +48 -0
- package/guide/reference/cli/check.md +49 -0
- package/guide/reference/cli/dev.md +46 -0
- package/guide/reference/cli/property-add.md +53 -0
- package/guide/reference/cli/property-list.md +46 -0
- package/guide/reference/cli/publish.md +54 -0
- package/guide/reference/cli/upgrade.md +48 -0
- package/guide/reference/rules/INDEX.md +190 -0
- package/package.json +137 -0
- package/tsconfig.base.json +16 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { DocumentFormat, ImageFormat } from "../packages/internal/format-geometry/dist/format.js";
|
|
2
|
+
import { WebsiteFormat } from "../schema/format.js";
|
|
3
|
+
import { ReconcileRule } from "./reconcile.js";
|
|
4
|
+
import { ReactNode } from "react";
|
|
5
|
+
//#region src/template/define-template.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Who a template is offered to. `"global"` is every org; the two org forms name
|
|
8
|
+
* an explicit audience — `{ org }` is the one-org shorthand for `{ orgs: [org] }`.
|
|
9
|
+
*
|
|
10
|
+
* The org set is the audience, never the template's identity: a key is one
|
|
11
|
+
* template however many orgs hold it, so adding or reordering orgs can neither
|
|
12
|
+
* mint a second template nor orphan the existing one.
|
|
13
|
+
*/
|
|
14
|
+
type TemplateScope = "global" | {
|
|
15
|
+
readonly org: string;
|
|
16
|
+
} | {
|
|
17
|
+
readonly orgs: readonly string[];
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* A page: a React component that places sections and receives no props. It is never
|
|
21
|
+
* rendered by the platform — the probe renders it once to read which sections it
|
|
22
|
+
* places, in order, and the platform assembles the page from section renders.
|
|
23
|
+
*/
|
|
24
|
+
type PageComponent = () => ReactNode;
|
|
25
|
+
interface PageBase {
|
|
26
|
+
/** The page's name in the editor's page bar, the sidebar and a nav menu. Required on every page. */
|
|
27
|
+
readonly label: string;
|
|
28
|
+
/** The component that places the page's sections. */
|
|
29
|
+
readonly page: PageComponent;
|
|
30
|
+
/**
|
|
31
|
+
* The user may toggle this whole page off; a disabled page publishes nothing and
|
|
32
|
+
* drops out of `nav.pages`. Never legal on the root page — a site must serve `/`.
|
|
33
|
+
*/
|
|
34
|
+
readonly optional?: boolean;
|
|
35
|
+
}
|
|
36
|
+
/** A website page: addressed by a URL path — `"/"` for the root, else one lowercase-kebab segment. */
|
|
37
|
+
interface WebsitePage extends PageBase {
|
|
38
|
+
readonly path: string;
|
|
39
|
+
}
|
|
40
|
+
/** A rendered class's page — a sheet, a slide, a frame — is not addressed by URL. */
|
|
41
|
+
interface RenderedPage extends PageBase {
|
|
42
|
+
readonly path?: never;
|
|
43
|
+
}
|
|
44
|
+
/** One editing canvas: its canvas-bar label and the page ids it presents, in display order. */
|
|
45
|
+
interface CanvasInput<PageId extends string> {
|
|
46
|
+
readonly label: string;
|
|
47
|
+
readonly pages: readonly [PageId, ...PageId[]];
|
|
48
|
+
}
|
|
49
|
+
/** Keyed canvases: object key is the canvas id, object order is canvas-bar order. */
|
|
50
|
+
type CanvasesInput<PageId extends string> = Readonly<Record<string, CanvasInput<PageId>>>;
|
|
51
|
+
/** The template-picker card: blurb, demo link and the type/intent filter. */
|
|
52
|
+
interface TemplatePreview {
|
|
53
|
+
readonly blurb: string;
|
|
54
|
+
readonly intents: readonly ("for_sale" | "for_rent")[];
|
|
55
|
+
readonly types: readonly ("single_family" | "condo_townhome" | "multi_family" | "investment")[];
|
|
56
|
+
readonly demoUrl?: string | null;
|
|
57
|
+
}
|
|
58
|
+
/** What every artifact class shares: identity, the icon, scope, rules, intake chrome. */
|
|
59
|
+
interface DefineTemplateCommon {
|
|
60
|
+
readonly key: string;
|
|
61
|
+
/** The display name — two words at most; the picker, the editor and the dashboard show it on one line. */
|
|
62
|
+
readonly name: string;
|
|
63
|
+
/** The template's icon, imported: `import icon from "./icon.svg"`. */
|
|
64
|
+
readonly icon: string;
|
|
65
|
+
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
|
+
readonly preview?: TemplatePreview;
|
|
69
|
+
}
|
|
70
|
+
/** One rendered format, or a non-empty list of one class. */
|
|
71
|
+
type FormatList<F> = F | readonly [F, ...F[]];
|
|
72
|
+
/**
|
|
73
|
+
* The input to `defineTemplate`, discriminated on `format`'s class: a website page
|
|
74
|
+
* carries a `path` and a rendered page carries none, so a routed slide, a pathless
|
|
75
|
+
* website page or a cross-class format mix fails to compile rather than to validate.
|
|
76
|
+
* `canvases` names pages by their `pages` key.
|
|
77
|
+
*/
|
|
78
|
+
type DefineTemplateInput<PageId extends string> = DefineTemplateCommon & ({
|
|
79
|
+
readonly format: WebsiteFormat;
|
|
80
|
+
readonly pages: Readonly<Record<PageId, WebsitePage>>;
|
|
81
|
+
readonly canvases?: CanvasesInput<NoInfer<PageId>>;
|
|
82
|
+
} | {
|
|
83
|
+
readonly format: FormatList<ImageFormat>;
|
|
84
|
+
readonly pages: Readonly<Record<PageId, RenderedPage>>;
|
|
85
|
+
readonly canvases?: CanvasesInput<NoInfer<PageId>>;
|
|
86
|
+
} | {
|
|
87
|
+
readonly format: FormatList<DocumentFormat>;
|
|
88
|
+
readonly pages: Readonly<Record<PageId, RenderedPage>>;
|
|
89
|
+
readonly canvases?: CanvasesInput<NoInfer<PageId>>;
|
|
90
|
+
});
|
|
91
|
+
/** The artifact class a template's formats declare. */
|
|
92
|
+
type OutputClass = "website" | "image" | "document";
|
|
93
|
+
/** One page as the template value carries it: the authored entry with its id stamped from the key. */
|
|
94
|
+
interface TemplatePage {
|
|
95
|
+
readonly id: string;
|
|
96
|
+
readonly label: string;
|
|
97
|
+
readonly path?: string;
|
|
98
|
+
readonly optional: boolean;
|
|
99
|
+
readonly page: PageComponent;
|
|
100
|
+
}
|
|
101
|
+
/** One canvas as the template value carries it — declared, or the stamped class default. */
|
|
102
|
+
interface TemplateCanvas {
|
|
103
|
+
readonly id: string;
|
|
104
|
+
readonly label: string;
|
|
105
|
+
readonly pages: readonly string[];
|
|
106
|
+
}
|
|
107
|
+
declare const TEMPLATE: unique symbol;
|
|
108
|
+
/**
|
|
109
|
+
* The value `defineTemplate` returns and `template.ts` default-exports: the authored
|
|
110
|
+
* declaration with the class derived, pages and canvases ordered, and the default
|
|
111
|
+
* canvases stamped. The composition is built from it by `materializeTemplate`.
|
|
112
|
+
*/
|
|
113
|
+
interface TemplateValue {
|
|
114
|
+
readonly key: string;
|
|
115
|
+
readonly name: string;
|
|
116
|
+
readonly output: OutputClass;
|
|
117
|
+
/** The format set as authored — a website's singleton, a rendered class's acceptance set. */
|
|
118
|
+
readonly formats: readonly (WebsiteFormat | ImageFormat | DocumentFormat)[];
|
|
119
|
+
readonly icon: string;
|
|
120
|
+
readonly scope: TemplateScope;
|
|
121
|
+
/** In artifact order. */
|
|
122
|
+
readonly pages: readonly TemplatePage[];
|
|
123
|
+
/** In canvas-bar order; always explicit. */
|
|
124
|
+
readonly canvases: readonly TemplateCanvas[];
|
|
125
|
+
readonly reconcile: readonly ReconcileRule[];
|
|
126
|
+
readonly preview?: TemplatePreview;
|
|
127
|
+
readonly [TEMPLATE]: true;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Declare a template. Validates what needs no render — the scope, the format set's
|
|
131
|
+
* class, the canvases naming real pages — and returns the value the probe reads.
|
|
132
|
+
*
|
|
133
|
+
* @throws when the scope names no org, names one twice, or names one that is not a
|
|
134
|
+
* UUID; when `format` is an empty list or mixes classes; when `pages` is empty; when
|
|
135
|
+
* a declared canvas names a page the site map lacks.
|
|
136
|
+
*/
|
|
137
|
+
declare function defineTemplate<const PageId extends string>(input: DefineTemplateInput<PageId>): TemplateValue;
|
|
138
|
+
//#endregion
|
|
139
|
+
export { CanvasInput, CanvasesInput, DefineTemplateCommon, DefineTemplateInput, FormatList, OutputClass, PageComponent, RenderedPage, TemplateCanvas, TemplatePage, TemplatePreview, TemplateScope, TemplateValue, WebsitePage, defineTemplate };
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
//#region src/template/define-template.ts
|
|
2
|
+
const TEMPLATE = Symbol("@homepages/concrete/template");
|
|
3
|
+
const CLASS_BY_CATEGORY = {
|
|
4
|
+
website: "website",
|
|
5
|
+
"social-post": "image",
|
|
6
|
+
story: "image",
|
|
7
|
+
brochure: "document",
|
|
8
|
+
flyer: "document",
|
|
9
|
+
postcard: "document",
|
|
10
|
+
presentation: "document"
|
|
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
|
+
function defineTemplate(input) {
|
|
21
|
+
assertScope(input.scope);
|
|
22
|
+
const formats = Array.isArray(input.format) ? [...input.format] : [input.format];
|
|
23
|
+
const output = outputClassOf(input.key, formats);
|
|
24
|
+
const authoredPages = input.pages;
|
|
25
|
+
const pages = Object.entries(authoredPages).map(([id, page]) => ({
|
|
26
|
+
id,
|
|
27
|
+
label: page.label,
|
|
28
|
+
...page.path === void 0 ? {} : { path: page.path },
|
|
29
|
+
optional: page.optional ?? false,
|
|
30
|
+
page: page.page
|
|
31
|
+
}));
|
|
32
|
+
if (pages.length === 0) throw new Error(`Template "${input.key}" declares no pages. \`pages\` is the site map — declare at least one.`);
|
|
33
|
+
const authoredCanvases = input.canvases;
|
|
34
|
+
const canvases = authoredCanvases !== void 0 ? Object.entries(authoredCanvases).map(([id, canvas]) => ({
|
|
35
|
+
id,
|
|
36
|
+
label: canvas.label,
|
|
37
|
+
pages: [...canvas.pages]
|
|
38
|
+
})) : output === "website" ? pages.map((page) => ({
|
|
39
|
+
id: page.id,
|
|
40
|
+
label: page.label,
|
|
41
|
+
pages: [page.id]
|
|
42
|
+
})) : [{
|
|
43
|
+
id: "canvas",
|
|
44
|
+
label: input.name,
|
|
45
|
+
pages: pages.map((page) => page.id)
|
|
46
|
+
}];
|
|
47
|
+
const pageIds = new Set(pages.map((page) => page.id));
|
|
48
|
+
for (const canvas of canvases) for (const pageId of canvas.pages) if (!pageIds.has(pageId)) throw new Error(`Template "${input.key}": canvas "${canvas.id}" names page "${pageId}", which \`pages\` does not declare.`);
|
|
49
|
+
const value = {
|
|
50
|
+
key: input.key,
|
|
51
|
+
name: input.name,
|
|
52
|
+
output,
|
|
53
|
+
formats,
|
|
54
|
+
icon: input.icon,
|
|
55
|
+
scope: input.scope,
|
|
56
|
+
pages,
|
|
57
|
+
canvases,
|
|
58
|
+
reconcile: input.reconcile ?? [],
|
|
59
|
+
...input.preview === void 0 ? {} : { preview: input.preview },
|
|
60
|
+
[TEMPLATE]: true
|
|
61
|
+
};
|
|
62
|
+
return Object.freeze(value);
|
|
63
|
+
}
|
|
64
|
+
/** Is this export a template value? What a command asks of `template.ts`'s default export. */
|
|
65
|
+
function isTemplate(value) {
|
|
66
|
+
return typeof value === "object" && value !== null && value[TEMPLATE] === true;
|
|
67
|
+
}
|
|
68
|
+
function outputClassOf(key, formats) {
|
|
69
|
+
const [first] = formats;
|
|
70
|
+
if (first === void 0) throw new Error(`Template "${key}" declares an empty format list. \`format\` is one format or a non-empty list of one class.`);
|
|
71
|
+
const output = CLASS_BY_CATEGORY[first.category];
|
|
72
|
+
for (const format of formats) if (CLASS_BY_CATEGORY[format.category] !== output) throw new Error(`Template "${key}" mixes format classes: "${first.id}" (${output}) and "${format.id}" (${CLASS_BY_CATEGORY[format.category]}). A design spanning classes is two templates sharing sections.`);
|
|
73
|
+
return output;
|
|
74
|
+
}
|
|
75
|
+
const ORG_ID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
76
|
+
function assertScope(scope) {
|
|
77
|
+
if (scope === "global") return;
|
|
78
|
+
const orgs = orgsForScope(scope);
|
|
79
|
+
if (orgs.length === 0) throw new Error("Template scope { orgs: [] } names no org. A template granted to nobody publishes into the catalog and is then offered to no picker at all — declare the orgs that hold it, or scope: \"global\" to offer it to every org.");
|
|
80
|
+
const seen = /* @__PURE__ */ new Set();
|
|
81
|
+
for (const org of orgs) {
|
|
82
|
+
if (!ORG_ID_RE.test(org)) throw new Error(`Template scope org "${org}" is not a UUID. An org-scoped template names the orgs it belongs to; each one becomes a grant.`);
|
|
83
|
+
if (seen.has(org)) throw new Error(`Template scope org "${org}" is listed twice. The grant set is a set — name each org once.`);
|
|
84
|
+
seen.add(org);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
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
|
+
function orgsForScope(scope) {
|
|
93
|
+
if (scope === "global") return [];
|
|
94
|
+
return "orgs" in scope ? scope.orgs : [scope.org];
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
//#endregion
|
|
98
|
+
export { defineTemplate, isTemplate, orgsForScope };
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { stripRendersForLogic } from "./logic-transform.js";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { dirname, extname } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { readFile } from "node:fs/promises";
|
|
6
|
+
import { build } from "esbuild";
|
|
7
|
+
|
|
8
|
+
//#region src/template/logic-build.ts
|
|
9
|
+
const SHIM_NAMESPACE = "concrete-logic-shim";
|
|
10
|
+
const REACT_NAMESPACE = "concrete-logic-react";
|
|
11
|
+
const EMPTY_NAMESPACE = "concrete-logic-empty";
|
|
12
|
+
const WORKSPACE_RESOLVE = Symbol("concrete-logic-workspace-resolve");
|
|
13
|
+
const STYLESHEET_RE = /\.(?:css|scss|sass|less)$/;
|
|
14
|
+
const ASSET_RE = /\.(?:png|jpe?g|webp|avif|svg|gif|ico|woff2?|ttf|otf|eot|mp4|webm|mov|mp3|wav|pdf|zip)$/;
|
|
15
|
+
const MODULE_RE = /\.(?:[cm]?[jt]s|[jt]sx)$/;
|
|
16
|
+
const LOADER_BY_EXT = {
|
|
17
|
+
".ts": "ts",
|
|
18
|
+
".mts": "ts",
|
|
19
|
+
".cts": "ts",
|
|
20
|
+
".tsx": "tsx",
|
|
21
|
+
".js": "js",
|
|
22
|
+
".mjs": "js",
|
|
23
|
+
".cjs": "js",
|
|
24
|
+
".jsx": "jsx"
|
|
25
|
+
};
|
|
26
|
+
function shimPath() {
|
|
27
|
+
const resolved = fileURLToPath(import.meta.resolve("./logic-shim.js"));
|
|
28
|
+
if (existsSync(resolved)) return resolved;
|
|
29
|
+
const source = resolved.replace(/\.js$/, ".ts");
|
|
30
|
+
if (existsSync(source)) return source;
|
|
31
|
+
throw new Error(`@homepages/concrete: the logic shim is missing beside ${import.meta.url}`);
|
|
32
|
+
}
|
|
33
|
+
const REACT_STUB = [`const marker = "@homepages/concrete logic build: a render-time primitive reached the bundle";`, `module.exports = new Proxy({}, { get(_, name) { return name === "__esModule" ? false : () => { throw new Error(marker + " (react." + String(name) + ")"); }; } });`].join("\n");
|
|
34
|
+
function logicPlugin() {
|
|
35
|
+
return {
|
|
36
|
+
name: "concrete-logic",
|
|
37
|
+
setup(api) {
|
|
38
|
+
api.onResolve({ filter: /^@homepages\/concrete$/ }, () => ({
|
|
39
|
+
path: shimPath(),
|
|
40
|
+
namespace: SHIM_NAMESPACE
|
|
41
|
+
}));
|
|
42
|
+
api.onLoad({
|
|
43
|
+
filter: /.*/,
|
|
44
|
+
namespace: SHIM_NAMESPACE
|
|
45
|
+
}, async (args) => ({
|
|
46
|
+
contents: await readFile(args.path, "utf8"),
|
|
47
|
+
loader: "ts",
|
|
48
|
+
resolveDir: dirname(args.path)
|
|
49
|
+
}));
|
|
50
|
+
api.onResolve({ filter: /^react(?:-dom)?(?:\/.*)?$/ }, (args) => ({
|
|
51
|
+
path: args.path,
|
|
52
|
+
namespace: REACT_NAMESPACE,
|
|
53
|
+
sideEffects: false
|
|
54
|
+
}));
|
|
55
|
+
api.onLoad({
|
|
56
|
+
filter: /.*/,
|
|
57
|
+
namespace: REACT_NAMESPACE
|
|
58
|
+
}, () => ({
|
|
59
|
+
contents: REACT_STUB,
|
|
60
|
+
loader: "js"
|
|
61
|
+
}));
|
|
62
|
+
api.onResolve({ filter: STYLESHEET_RE }, (args) => ({
|
|
63
|
+
path: args.path,
|
|
64
|
+
namespace: EMPTY_NAMESPACE,
|
|
65
|
+
sideEffects: false
|
|
66
|
+
}));
|
|
67
|
+
api.onResolve({ filter: ASSET_RE }, (args) => ({
|
|
68
|
+
path: args.path,
|
|
69
|
+
namespace: EMPTY_NAMESPACE,
|
|
70
|
+
sideEffects: false
|
|
71
|
+
}));
|
|
72
|
+
api.onLoad({
|
|
73
|
+
filter: /.*/,
|
|
74
|
+
namespace: EMPTY_NAMESPACE
|
|
75
|
+
}, () => ({
|
|
76
|
+
contents: `export default "";`,
|
|
77
|
+
loader: "js"
|
|
78
|
+
}));
|
|
79
|
+
api.onResolve({ filter: /.*/ }, async (args) => {
|
|
80
|
+
if (args.pluginData === WORKSPACE_RESOLVE) return void 0;
|
|
81
|
+
const resolved = await api.resolve(args.path, {
|
|
82
|
+
kind: args.kind,
|
|
83
|
+
importer: args.importer,
|
|
84
|
+
namespace: args.namespace,
|
|
85
|
+
resolveDir: args.resolveDir,
|
|
86
|
+
with: args.with,
|
|
87
|
+
pluginData: WORKSPACE_RESOLVE
|
|
88
|
+
});
|
|
89
|
+
if (resolved.errors.length > 0 || resolved.external || resolved.namespace !== "file") return void 0;
|
|
90
|
+
if (resolved.path.includes("/node_modules/") || !MODULE_RE.test(resolved.path)) return void 0;
|
|
91
|
+
return {
|
|
92
|
+
path: resolved.path,
|
|
93
|
+
sideEffects: false
|
|
94
|
+
};
|
|
95
|
+
});
|
|
96
|
+
api.onLoad({ filter: MODULE_RE }, async (args) => {
|
|
97
|
+
if (args.path.includes("/node_modules/")) return void 0;
|
|
98
|
+
const loader = LOADER_BY_EXT[extname(args.path)];
|
|
99
|
+
if (loader === void 0) return void 0;
|
|
100
|
+
return {
|
|
101
|
+
contents: stripRendersForLogic(await readFile(args.path, "utf8"), args.path),
|
|
102
|
+
loader,
|
|
103
|
+
resolveDir: dirname(args.path)
|
|
104
|
+
};
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
function reachedThrough(metafile) {
|
|
110
|
+
const output = Object.values(metafile.outputs)[0];
|
|
111
|
+
if (output === void 0) return [];
|
|
112
|
+
const survivors = new Set(Object.keys(output.inputs).filter((input) => input.startsWith(`${REACT_NAMESPACE}:`)));
|
|
113
|
+
if (survivors.size === 0) return [];
|
|
114
|
+
const importers = [];
|
|
115
|
+
for (const [input, entry] of Object.entries(metafile.inputs)) {
|
|
116
|
+
if (input.startsWith(`${REACT_NAMESPACE}:`) || !(input in output.inputs)) continue;
|
|
117
|
+
for (const imported of entry.imports) if (survivors.has(imported.path)) importers.push(`${input} (${imported.path.slice(21)})`);
|
|
118
|
+
}
|
|
119
|
+
return importers;
|
|
120
|
+
}
|
|
121
|
+
async function bundleLogic(what, contents, resolveDir) {
|
|
122
|
+
const result = await build({
|
|
123
|
+
stdin: {
|
|
124
|
+
contents,
|
|
125
|
+
resolveDir,
|
|
126
|
+
loader: "ts"
|
|
127
|
+
},
|
|
128
|
+
bundle: true,
|
|
129
|
+
format: "esm",
|
|
130
|
+
target: "es2022",
|
|
131
|
+
platform: "neutral",
|
|
132
|
+
mainFields: ["module", "main"],
|
|
133
|
+
minify: true,
|
|
134
|
+
write: false,
|
|
135
|
+
metafile: true,
|
|
136
|
+
external: [],
|
|
137
|
+
jsx: "automatic",
|
|
138
|
+
plugins: [logicPlugin()],
|
|
139
|
+
logOverride: {
|
|
140
|
+
"import-is-undefined": "silent",
|
|
141
|
+
"ignored-bare-import": "silent"
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
const importers = reachedThrough(result.metafile);
|
|
145
|
+
if (importers.length > 0) throw new Error(`${what}: React reached the logic bundle through ${importers.join(", ")}. A logic bundle carries only declarations and compute closures; move whatever these modules keep alive outside the closure, or hand-list the logic entry.`);
|
|
146
|
+
const js = result.outputFiles?.[0];
|
|
147
|
+
if (js === void 0) throw new Error(`${what}: esbuild produced no logic-bundle output`);
|
|
148
|
+
return js.text;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* A section's logic bundle: `export const computed` — the handle → pure-fn map read off
|
|
152
|
+
* the section's schema (`display.<entry>` for a computed display origin, the slot id for
|
|
153
|
+
* a computed source), or `{}` for a section that authored none.
|
|
154
|
+
*/
|
|
155
|
+
async function buildSectionLogic(input) {
|
|
156
|
+
const contents = [
|
|
157
|
+
`import * as authored from ${JSON.stringify(input.module)};`,
|
|
158
|
+
`import { getComputed } from "@homepages/concrete";`,
|
|
159
|
+
`export const computed = getComputed(authored[${JSON.stringify(input.exportName)}].schema);`
|
|
160
|
+
].join("\n");
|
|
161
|
+
return bundleLogic(`section ${input.exportName} (${input.module})`, contents, dirname(input.module));
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* A template's logic bundle: `export const reconcile` — the template's named
|
|
165
|
+
* `reconcile` export with every read and every edit addressed to the instance the
|
|
166
|
+
* composition placed for its section — and `export const instances`, the section key →
|
|
167
|
+
* instance id list the interpreter builds the site view from, emitted as data.
|
|
168
|
+
*/
|
|
169
|
+
async function buildTemplateLogic(input) {
|
|
170
|
+
const instanceBySection = {};
|
|
171
|
+
for (const instance of input.instances) if (!(instance.key in instanceBySection)) instanceBySection[instance.key] = instance.instanceId;
|
|
172
|
+
const contents = [
|
|
173
|
+
`import * as template from ${JSON.stringify(input.templateFile)};`,
|
|
174
|
+
`const instanceBySection = ${JSON.stringify(instanceBySection)};`,
|
|
175
|
+
`const instanceOf = (section) => {`,
|
|
176
|
+
` const instanceId = instanceBySection[section];`,
|
|
177
|
+
` if (instanceId === undefined) throw new Error('reconcile: no placed instance for section "' + section + '"');`,
|
|
178
|
+
` return instanceId;`,
|
|
179
|
+
`};`,
|
|
180
|
+
`export const instances = ${JSON.stringify(input.instances)};`,
|
|
181
|
+
`export const reconcile = (template.reconcile ?? []).map((rule) => ({`,
|
|
182
|
+
` description: rule.description,`,
|
|
183
|
+
` reads: rule.reads.map((ref) => ({ instanceId: instanceOf(ref.section), slot: ref.slot })),`,
|
|
184
|
+
` fn: (ctx) => rule.fn(ctx).map((edit) => ({ op: "set", instanceId: instanceOf(edit.section), slot: edit.slot, value: edit.value })),`,
|
|
185
|
+
`}));`
|
|
186
|
+
].join("\n");
|
|
187
|
+
return bundleLogic(`template (${input.templateFile})`, contents, dirname(input.templateFile));
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
//#endregion
|
|
191
|
+
export { buildSectionLogic, buildTemplateLogic };
|
|
@@ -0,0 +1,43 @@
|
|
|
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 { fact } from "../schema/fact.js";
|
|
3
|
+
import { compute, getComputed } from "../schema/compute.js";
|
|
4
|
+
import { chooseFrom, contactAssign, documentAssign, imageAssign, listFill, nameRows, textBlock, tourAssign, videoAssign } from "../schema/fill-builders.js";
|
|
5
|
+
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
|
+
import { DisplayInput } from "../schema/define-schema.js";
|
|
8
|
+
import { SectionDeclaration, SectionOptions } from "../section/declare.js";
|
|
9
|
+
import { rule, set } from "./reconcile.js";
|
|
10
|
+
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
|
+
import { presets } from "../schema/format-presets.js";
|
|
12
|
+
import { a4Landscape, a4Portrait, deck16x9, facebookPost, halfLetterFlyer, instagramPortrait, instagramSquare, instagramStory, letterLandscape, letterPortrait, linkedinPost, postcard6x4, postcard7x5, website, xPost } from "../schema/formats.js";
|
|
13
|
+
//#region src/template/logic-shim.d.ts
|
|
14
|
+
declare const CONCRETE_VERSION = "";
|
|
15
|
+
/** The declaration half of `section()`: the value minus its component. */
|
|
16
|
+
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: the template's default export is dropped by the bundle, which reads the named `reconcile`. */
|
|
18
|
+
declare function defineTemplate<T>(input: T): T;
|
|
19
|
+
/** The text a surviving stub throws with — what the build greps the output for. */
|
|
20
|
+
declare const LOGIC_STUB_MARKER = "@homepages/concrete logic build: a render-time primitive reached the bundle";
|
|
21
|
+
declare const Section: () => never;
|
|
22
|
+
declare const SlotGroup: () => never;
|
|
23
|
+
declare const Image: () => never;
|
|
24
|
+
declare const Video: () => never;
|
|
25
|
+
declare const Tour: () => never;
|
|
26
|
+
declare const FrameShell: () => never;
|
|
27
|
+
declare const IslandMarker: () => never;
|
|
28
|
+
declare const bindItems: () => never;
|
|
29
|
+
declare const useEditor: () => never;
|
|
30
|
+
declare const useCaptureReady: () => never;
|
|
31
|
+
declare const Slot: {
|
|
32
|
+
Text: () => never;
|
|
33
|
+
Number: () => never;
|
|
34
|
+
Select: () => never;
|
|
35
|
+
Url: () => never;
|
|
36
|
+
Image: () => never;
|
|
37
|
+
Video: () => never;
|
|
38
|
+
Tour: () => never;
|
|
39
|
+
Document: () => never;
|
|
40
|
+
List: () => never;
|
|
41
|
+
};
|
|
42
|
+
//#endregion
|
|
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, chooseFrom, compute, contactAssign, deck16x9, defineTemplate, deserializeIslandProps, document, documentAssign, facebookPost, fact, getComputed, halfLetterFlyer, image, imageAssign, instagramPortrait, instagramSquare, instagramStory, islandId, letterLandscape, letterPortrait, linkedinPost, list, listFill, nameRows, number, poi, postcard6x4, postcard7x5, presets, rule, section, select, serializeIslandProps, set, text, textBlock, tour, tourAssign, url, useCaptureReady, useEditor, video, videoAssign, website, xPost };
|
|
@@ -0,0 +1,52 @@
|
|
|
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
|
+
import { compute, getComputed } from "../schema/compute.js";
|
|
3
|
+
import { declareSection } from "../section/declare.js";
|
|
4
|
+
import { rule, set } from "./reconcile.js";
|
|
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
|
+
import { document, image, list, number, poi, select, text, tour, url, video } from "../schema/slot-builders.js";
|
|
7
|
+
import { fact } from "../schema/fact.js";
|
|
8
|
+
import { chooseFrom, contactAssign, documentAssign, imageAssign, listFill, nameRows, textBlock, tourAssign, videoAssign } from "../schema/fill-builders.js";
|
|
9
|
+
import { presets } from "../schema/format-presets.js";
|
|
10
|
+
import { a4Landscape, a4Portrait, deck16x9, facebookPost, halfLetterFlyer, instagramPortrait, instagramSquare, instagramStory, letterLandscape, letterPortrait, linkedinPost, postcard6x4, postcard7x5, website, xPost } from "../schema/formats.js";
|
|
11
|
+
|
|
12
|
+
//#region src/template/logic-shim.ts
|
|
13
|
+
const CONCRETE_VERSION = "";
|
|
14
|
+
/** The declaration half of `section()`: the value minus its component. */
|
|
15
|
+
function section(options) {
|
|
16
|
+
return declareSection(options);
|
|
17
|
+
}
|
|
18
|
+
/** Inert: the template's default export is dropped by the bundle, which reads the named `reconcile`. */
|
|
19
|
+
function defineTemplate(input) {
|
|
20
|
+
return input;
|
|
21
|
+
}
|
|
22
|
+
/** The text a surviving stub throws with — what the build greps the output for. */
|
|
23
|
+
const LOGIC_STUB_MARKER = "@homepages/concrete logic build: a render-time primitive reached the bundle";
|
|
24
|
+
const stub = (name) => {
|
|
25
|
+
return () => {
|
|
26
|
+
throw new Error(`${LOGIC_STUB_MARKER} (${name})`);
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
const Section = /* @__PURE__ */ stub("Section");
|
|
30
|
+
const SlotGroup = /* @__PURE__ */ stub("SlotGroup");
|
|
31
|
+
const Image = /* @__PURE__ */ stub("Image");
|
|
32
|
+
const Video = /* @__PURE__ */ stub("Video");
|
|
33
|
+
const Tour = /* @__PURE__ */ stub("Tour");
|
|
34
|
+
const FrameShell = /* @__PURE__ */ stub("FrameShell");
|
|
35
|
+
const IslandMarker = /* @__PURE__ */ stub("IslandMarker");
|
|
36
|
+
const bindItems = /* @__PURE__ */ stub("bindItems");
|
|
37
|
+
const useEditor = /* @__PURE__ */ stub("useEditor");
|
|
38
|
+
const useCaptureReady = /* @__PURE__ */ stub("useCaptureReady");
|
|
39
|
+
const Slot = {
|
|
40
|
+
Text: /* @__PURE__ */ stub("Slot.Text"),
|
|
41
|
+
Number: /* @__PURE__ */ stub("Slot.Number"),
|
|
42
|
+
Select: /* @__PURE__ */ stub("Slot.Select"),
|
|
43
|
+
Url: /* @__PURE__ */ stub("Slot.Url"),
|
|
44
|
+
Image: /* @__PURE__ */ stub("Slot.Image"),
|
|
45
|
+
Video: /* @__PURE__ */ stub("Slot.Video"),
|
|
46
|
+
Tour: /* @__PURE__ */ stub("Slot.Tour"),
|
|
47
|
+
Document: /* @__PURE__ */ stub("Slot.Document"),
|
|
48
|
+
List: /* @__PURE__ */ stub("Slot.List")
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
//#endregion
|
|
52
|
+
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, chooseFrom, compute, contactAssign, deck16x9, defineTemplate, deserializeIslandProps, document, documentAssign, facebookPost, fact, getComputed, halfLetterFlyer, image, imageAssign, instagramPortrait, instagramSquare, instagramStory, islandId, letterLandscape, letterPortrait, linkedinPost, list, listFill, nameRows, number, poi, postcard6x4, postcard7x5, presets, rule, section, select, serializeIslandProps, set, text, textBlock, tour, tourAssign, url, useCaptureReady, useEditor, video, videoAssign, website, xPost };
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
//#region src/template/logic-transform.ts
|
|
4
|
+
/** The package the two authoring calls are imported from. */
|
|
5
|
+
const CONCRETE_SPECIFIER = "@homepages/concrete";
|
|
6
|
+
const PURE = "/* @__PURE__ */ ";
|
|
7
|
+
function calleeNames(sourceFile) {
|
|
8
|
+
const names = {
|
|
9
|
+
section: /* @__PURE__ */ new Set(),
|
|
10
|
+
defineTemplate: /* @__PURE__ */ new Set(),
|
|
11
|
+
namespaces: /* @__PURE__ */ new Set()
|
|
12
|
+
};
|
|
13
|
+
for (const statement of sourceFile.statements) {
|
|
14
|
+
if (!ts.isImportDeclaration(statement)) continue;
|
|
15
|
+
if (!ts.isStringLiteral(statement.moduleSpecifier) || statement.moduleSpecifier.text !== "@homepages/concrete") continue;
|
|
16
|
+
const clause = statement.importClause;
|
|
17
|
+
if (clause === void 0 || clause.isTypeOnly || clause.namedBindings === void 0) continue;
|
|
18
|
+
if (ts.isNamespaceImport(clause.namedBindings)) {
|
|
19
|
+
names.namespaces.add(clause.namedBindings.name.text);
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
for (const element of clause.namedBindings.elements) {
|
|
23
|
+
if (element.isTypeOnly) continue;
|
|
24
|
+
const imported = (element.propertyName ?? element.name).text;
|
|
25
|
+
if (imported === "section") names.section.add(element.name.text);
|
|
26
|
+
if (imported === "defineTemplate") names.defineTemplate.add(element.name.text);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return names;
|
|
30
|
+
}
|
|
31
|
+
function calleeKind(expression, names) {
|
|
32
|
+
if (ts.isIdentifier(expression)) {
|
|
33
|
+
if (names.section.has(expression.text)) return "section";
|
|
34
|
+
if (names.defineTemplate.has(expression.text)) return "defineTemplate";
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
if (ts.isPropertyAccessExpression(expression) && ts.isIdentifier(expression.expression) && names.namespaces.has(expression.expression.text)) {
|
|
38
|
+
if (expression.name.text === "section") return "section";
|
|
39
|
+
if (expression.name.text === "defineTemplate") return "defineTemplate";
|
|
40
|
+
}
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
function alreadyPure(sourceFile, call) {
|
|
44
|
+
const leading = sourceFile.text.slice(call.getFullStart(), call.getStart(sourceFile));
|
|
45
|
+
return /@__PURE__/.test(leading);
|
|
46
|
+
}
|
|
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
|
+
function stripRendersForLogic(source, fileName) {
|
|
53
|
+
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
|
+
const sourceFile = ts.createSourceFile(fileName, source, ts.ScriptTarget.ES2022, true, kind);
|
|
55
|
+
const names = calleeNames(sourceFile);
|
|
56
|
+
if (names.section.size === 0 && names.defineTemplate.size === 0 && names.namespaces.size === 0) return source;
|
|
57
|
+
const splices = [];
|
|
58
|
+
const visit = (node) => {
|
|
59
|
+
if (ts.isCallExpression(node)) {
|
|
60
|
+
const callee = calleeKind(node.expression, names);
|
|
61
|
+
if (callee !== null) {
|
|
62
|
+
if (!alreadyPure(sourceFile, node)) {
|
|
63
|
+
const start = node.getStart(sourceFile);
|
|
64
|
+
splices.push({
|
|
65
|
+
start,
|
|
66
|
+
end: start,
|
|
67
|
+
text: PURE
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
if (callee === "section" && node.arguments.length >= 2) {
|
|
71
|
+
const first = node.arguments[0];
|
|
72
|
+
const last = node.arguments[node.arguments.length - 1];
|
|
73
|
+
splices.push({
|
|
74
|
+
start: first.getEnd(),
|
|
75
|
+
end: last.getEnd(),
|
|
76
|
+
text: ""
|
|
77
|
+
});
|
|
78
|
+
ts.forEachChild(first, visit);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
ts.forEachChild(node, visit);
|
|
84
|
+
};
|
|
85
|
+
visit(sourceFile);
|
|
86
|
+
let out = source;
|
|
87
|
+
for (const splice of [...splices].sort((a, b) => b.start - a.start)) out = out.slice(0, splice.start) + splice.text + out.slice(splice.end);
|
|
88
|
+
return out;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
//#endregion
|
|
92
|
+
export { CONCRETE_SPECIFIER, stripRendersForLogic };
|