@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,300 @@
|
|
|
1
|
+
import { presetGeometryMatches, presets } from "./format-presets.js";
|
|
2
|
+
import { formatVariantNameError } from "../design-system/format-variants.js";
|
|
3
|
+
import { DocumentFormatSchema, ImageFormatSchema, WebsiteFormatSchema } from "./format.js";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
|
|
6
|
+
//#region src/schema/manifest.ts
|
|
7
|
+
const SectionInstance = z.object({
|
|
8
|
+
section: z.string().min(1),
|
|
9
|
+
instance_id: z.string().min(1),
|
|
10
|
+
required: z.boolean().default(false)
|
|
11
|
+
}).strict();
|
|
12
|
+
const PAGE_PATH_RE = /^\/[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
13
|
+
/** The root page's path. Exactly one page in a website template declares it. */
|
|
14
|
+
const ROOT_PAGE_PATH = "/";
|
|
15
|
+
/**
|
|
16
|
+
* The word cap on a template's display name. The name is what the picker card,
|
|
17
|
+
* the editor chrome and the dashboard each show on ONE line that truncates with
|
|
18
|
+
* an ellipsis, so a long name is not merely verbose — it is unreadable at the
|
|
19
|
+
* only place a user reads it.
|
|
20
|
+
*/
|
|
21
|
+
const TEMPLATE_NAME_WORD_CAP = 2;
|
|
22
|
+
/** The words of a display name: whitespace-separated runs, empties dropped. */
|
|
23
|
+
const nameWords = (name) => name.trim().split(/\s+/).filter(Boolean);
|
|
24
|
+
const TemplateName = z.string().min(1).superRefine((name, ctx) => {
|
|
25
|
+
const words = nameWords(name);
|
|
26
|
+
if (words.length <= 2) return;
|
|
27
|
+
ctx.addIssue({
|
|
28
|
+
code: z.ZodIssueCode.custom,
|
|
29
|
+
message: `Template name "${name}" is ${words.length} words; a display name is at most ${2}. The picker card, the editor chrome and the dashboard each show it on one truncating line — say what the template IS ("Classic Carousel") and leave the rest to the \`preview\` blurb.`
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
const TemplatePage = z.object({
|
|
33
|
+
id: z.string().min(1),
|
|
34
|
+
label: z.string().min(1),
|
|
35
|
+
path: z.string().min(1),
|
|
36
|
+
optional: z.boolean().default(false),
|
|
37
|
+
sections: z.array(SectionInstance).min(1)
|
|
38
|
+
}).strict();
|
|
39
|
+
const RenderedPage = z.object({
|
|
40
|
+
id: z.string().min(1),
|
|
41
|
+
label: z.string().min(1),
|
|
42
|
+
optional: z.boolean().default(false),
|
|
43
|
+
sections: z.array(SectionInstance).min(1)
|
|
44
|
+
}).strict();
|
|
45
|
+
const TemplateCanvas = z.object({
|
|
46
|
+
id: z.string().min(1),
|
|
47
|
+
label: z.string().min(1),
|
|
48
|
+
pages: z.array(z.string().min(1)).min(1, "A canvas must hold at least one page.")
|
|
49
|
+
}).strict();
|
|
50
|
+
const TemplatePreview = z.object({
|
|
51
|
+
blurb: z.string().min(1),
|
|
52
|
+
intents: z.array(z.enum(["for_sale", "for_rent"])),
|
|
53
|
+
types: z.array(z.enum([
|
|
54
|
+
"single_family",
|
|
55
|
+
"condo_townhome",
|
|
56
|
+
"multi_family",
|
|
57
|
+
"investment"
|
|
58
|
+
])),
|
|
59
|
+
demoUrl: z.string().nullable().optional()
|
|
60
|
+
}).strict();
|
|
61
|
+
const WebsiteManifest = z.object({
|
|
62
|
+
key: z.string().min(1),
|
|
63
|
+
name: TemplateName,
|
|
64
|
+
output: z.literal("website"),
|
|
65
|
+
formats: z.tuple([WebsiteFormatSchema]),
|
|
66
|
+
pages: z.array(TemplatePage).min(1),
|
|
67
|
+
canvases: z.array(TemplateCanvas).min(1),
|
|
68
|
+
preview: TemplatePreview.optional()
|
|
69
|
+
}).strict();
|
|
70
|
+
const ImageManifest = z.object({
|
|
71
|
+
key: z.string().min(1),
|
|
72
|
+
name: TemplateName,
|
|
73
|
+
output: z.literal("image"),
|
|
74
|
+
formats: z.array(ImageFormatSchema).min(1, "A rendered template must declare at least one format."),
|
|
75
|
+
pages: z.array(RenderedPage).min(1),
|
|
76
|
+
canvases: z.array(TemplateCanvas).min(1),
|
|
77
|
+
preview: TemplatePreview.optional()
|
|
78
|
+
}).strict();
|
|
79
|
+
const DocumentManifest = z.object({
|
|
80
|
+
key: z.string().min(1),
|
|
81
|
+
name: TemplateName,
|
|
82
|
+
output: z.literal("document"),
|
|
83
|
+
formats: z.array(DocumentFormatSchema).min(1, "A rendered template must declare at least one format."),
|
|
84
|
+
pages: z.array(RenderedPage).min(1),
|
|
85
|
+
canvases: z.array(TemplateCanvas).min(1),
|
|
86
|
+
preview: TemplatePreview.optional()
|
|
87
|
+
}).strict();
|
|
88
|
+
function refinePageRules(manifest, ctx) {
|
|
89
|
+
const seenIds = /* @__PURE__ */ new Set();
|
|
90
|
+
manifest.pages.forEach((page, pageIdx) => {
|
|
91
|
+
if (seenIds.has(page.id)) ctx.addIssue({
|
|
92
|
+
code: z.ZodIssueCode.custom,
|
|
93
|
+
path: [
|
|
94
|
+
"pages",
|
|
95
|
+
pageIdx,
|
|
96
|
+
"id"
|
|
97
|
+
],
|
|
98
|
+
message: `Duplicate page id "${page.id}".`
|
|
99
|
+
});
|
|
100
|
+
seenIds.add(page.id);
|
|
101
|
+
const seenInstances = /* @__PURE__ */ new Set();
|
|
102
|
+
page.sections.forEach((inst, idx) => {
|
|
103
|
+
if (seenInstances.has(inst.instance_id)) ctx.addIssue({
|
|
104
|
+
code: z.ZodIssueCode.custom,
|
|
105
|
+
path: [
|
|
106
|
+
"pages",
|
|
107
|
+
pageIdx,
|
|
108
|
+
"sections",
|
|
109
|
+
idx,
|
|
110
|
+
"instance_id"
|
|
111
|
+
],
|
|
112
|
+
message: `Duplicate instance_id "${inst.instance_id}" on page "${page.id}".`
|
|
113
|
+
});
|
|
114
|
+
seenInstances.add(inst.instance_id);
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
function refineCanvasRules(manifest, ctx) {
|
|
119
|
+
const pageIds = new Set(manifest.pages.map((page) => page.id));
|
|
120
|
+
const seenCanvasIds = /* @__PURE__ */ new Set();
|
|
121
|
+
const claimed = /* @__PURE__ */ new Map();
|
|
122
|
+
manifest.canvases.forEach((cv, canvasIdx) => {
|
|
123
|
+
if (seenCanvasIds.has(cv.id)) ctx.addIssue({
|
|
124
|
+
code: z.ZodIssueCode.custom,
|
|
125
|
+
path: [
|
|
126
|
+
"canvases",
|
|
127
|
+
canvasIdx,
|
|
128
|
+
"id"
|
|
129
|
+
],
|
|
130
|
+
message: `Duplicate canvas id "${cv.id}".`
|
|
131
|
+
});
|
|
132
|
+
seenCanvasIds.add(cv.id);
|
|
133
|
+
cv.pages.forEach((pageId, idx) => {
|
|
134
|
+
if (!pageIds.has(pageId)) {
|
|
135
|
+
ctx.addIssue({
|
|
136
|
+
code: z.ZodIssueCode.custom,
|
|
137
|
+
path: [
|
|
138
|
+
"canvases",
|
|
139
|
+
canvasIdx,
|
|
140
|
+
"pages",
|
|
141
|
+
idx
|
|
142
|
+
],
|
|
143
|
+
message: `Canvas "${cv.id}" names unknown page "${pageId}".`
|
|
144
|
+
});
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
const holder = claimed.get(pageId);
|
|
148
|
+
if (holder !== void 0) {
|
|
149
|
+
ctx.addIssue({
|
|
150
|
+
code: z.ZodIssueCode.custom,
|
|
151
|
+
path: [
|
|
152
|
+
"canvases",
|
|
153
|
+
canvasIdx,
|
|
154
|
+
"pages",
|
|
155
|
+
idx
|
|
156
|
+
],
|
|
157
|
+
message: `Page "${pageId}" must be on exactly one canvas; it is on "${holder}" and "${cv.id}".`
|
|
158
|
+
});
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
claimed.set(pageId, cv.id);
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
for (const page of manifest.pages) if (!claimed.has(page.id)) ctx.addIssue({
|
|
165
|
+
code: z.ZodIssueCode.custom,
|
|
166
|
+
path: ["canvases"],
|
|
167
|
+
message: `Page "${page.id}" is on no canvas — canvases must partition the pages.`
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
function refineWebsiteRules(manifest, ctx) {
|
|
171
|
+
const seenPaths = /* @__PURE__ */ new Set();
|
|
172
|
+
let rootPages = 0;
|
|
173
|
+
manifest.pages.forEach((page, pageIdx) => {
|
|
174
|
+
if (seenPaths.has(page.path)) ctx.addIssue({
|
|
175
|
+
code: z.ZodIssueCode.custom,
|
|
176
|
+
path: [
|
|
177
|
+
"pages",
|
|
178
|
+
pageIdx,
|
|
179
|
+
"path"
|
|
180
|
+
],
|
|
181
|
+
message: `Duplicate page path "${page.path}".`
|
|
182
|
+
});
|
|
183
|
+
seenPaths.add(page.path);
|
|
184
|
+
if (page.path === "/") {
|
|
185
|
+
rootPages += 1;
|
|
186
|
+
if (page.optional) ctx.addIssue({
|
|
187
|
+
code: z.ZodIssueCode.custom,
|
|
188
|
+
path: [
|
|
189
|
+
"pages",
|
|
190
|
+
pageIdx,
|
|
191
|
+
"optional"
|
|
192
|
+
],
|
|
193
|
+
message: `The "${"/"}" page cannot be optional — a site must serve its root.`
|
|
194
|
+
});
|
|
195
|
+
} else if (!PAGE_PATH_RE.test(page.path)) ctx.addIssue({
|
|
196
|
+
code: z.ZodIssueCode.custom,
|
|
197
|
+
path: [
|
|
198
|
+
"pages",
|
|
199
|
+
pageIdx,
|
|
200
|
+
"path"
|
|
201
|
+
],
|
|
202
|
+
message: `Page path "${page.path}" must be a single lowercase-kebab segment ("/gallery"), or "${"/"}" for the root page.`
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
if (rootPages !== 1) ctx.addIssue({
|
|
206
|
+
code: z.ZodIssueCode.custom,
|
|
207
|
+
path: ["pages"],
|
|
208
|
+
message: `Exactly one page must declare path "${"/"}"; found ${String(rootPages)}.`
|
|
209
|
+
});
|
|
210
|
+
const [format] = manifest.formats;
|
|
211
|
+
const website = presets.website;
|
|
212
|
+
if (format.id !== website.id || format.label !== website.label || format.category !== website.category) ctx.addIssue({
|
|
213
|
+
code: z.ZodIssueCode.custom,
|
|
214
|
+
path: ["formats", 0],
|
|
215
|
+
message: `A website template's format set is exactly [presets.website] ({ id: "${website.id}", label: "${website.label}", category: "${website.category}" }); found { id: "${format.id}", label: "${format.label}", category: "${format.category}" }.`
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
function refineRenderedRules(manifest, ctx) {
|
|
219
|
+
if (!manifest.pages.some((page) => !page.optional)) ctx.addIssue({
|
|
220
|
+
code: z.ZodIssueCode.custom,
|
|
221
|
+
path: ["pages"],
|
|
222
|
+
message: `A rendered template needs at least one non-optional page; every page of "${manifest.key}" is optional.`
|
|
223
|
+
});
|
|
224
|
+
const seenFormatIds = /* @__PURE__ */ new Set();
|
|
225
|
+
manifest.formats.forEach((format, formatIdx) => {
|
|
226
|
+
const variantError = formatVariantNameError(format.id);
|
|
227
|
+
if (variantError !== null) ctx.addIssue({
|
|
228
|
+
code: z.ZodIssueCode.custom,
|
|
229
|
+
path: [
|
|
230
|
+
"formats",
|
|
231
|
+
formatIdx,
|
|
232
|
+
"id"
|
|
233
|
+
],
|
|
234
|
+
message: variantError
|
|
235
|
+
});
|
|
236
|
+
if (seenFormatIds.has(format.id)) ctx.addIssue({
|
|
237
|
+
code: z.ZodIssueCode.custom,
|
|
238
|
+
path: [
|
|
239
|
+
"formats",
|
|
240
|
+
formatIdx,
|
|
241
|
+
"id"
|
|
242
|
+
],
|
|
243
|
+
message: `Duplicate format id "${format.id}".`
|
|
244
|
+
});
|
|
245
|
+
seenFormatIds.add(format.id);
|
|
246
|
+
if (!presetGeometryMatches(format)) ctx.addIssue({
|
|
247
|
+
code: z.ZodIssueCode.custom,
|
|
248
|
+
path: [
|
|
249
|
+
"formats",
|
|
250
|
+
formatIdx,
|
|
251
|
+
"preset"
|
|
252
|
+
],
|
|
253
|
+
message: `Format "${format.id}" is tagged preset "${format.preset ?? ""}" but its geometry does not match that library entry — match the preset or clear \`preset\` and re-identify (id, label) as a custom format.`
|
|
254
|
+
});
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Zod schema for the object a template's `template.ts` builds via
|
|
259
|
+
* `defineTemplate`: a discriminated union on `output`, the artifact class.
|
|
260
|
+
* Validates a BUILT object, not parsed JSON, and owns a template's static
|
|
261
|
+
* composition only: identity (`key`, a `name` of at most two words, `output`), its `formats`
|
|
262
|
+
* acceptance set (websites hold exactly the geometry-less website singleton;
|
|
263
|
+
* image and document templates one or more of their own class's formats), its
|
|
264
|
+
* ordered `pages` (each page's label, optionality, ordered section instances,
|
|
265
|
+
* and — websites only — path), its `canvases` (the editing-surface grouping,
|
|
266
|
+
* always explicit on the wire), and optional intake `preview` chrome.
|
|
267
|
+
* Cross-section reconcile rules are not part of this schema — they compile
|
|
268
|
+
* into the template logic bundle instead.
|
|
269
|
+
*
|
|
270
|
+
* Pages are the composition unit in every class: a single-page template is a
|
|
271
|
+
* one-page template, declared exactly as a five-page one is. There is no flat
|
|
272
|
+
* `sections` shape.
|
|
273
|
+
*
|
|
274
|
+
* @throws on parse when a composition rule is violated, each with an error
|
|
275
|
+
* naming the rule — a `name` of more than two words, duplicate page id, duplicate format id, one `instance_id`
|
|
276
|
+
* listed twice on the same page (listing an instance on SEVERAL pages is legal
|
|
277
|
+
* and means one shared instance rendered on each), a rendered template with no
|
|
278
|
+
* format or with every page optional, a `preset`-tagged format whose geometry
|
|
279
|
+
* does not match the library entry for that tag, a website format set that is
|
|
280
|
+
* not exactly `[presets.website]`, a canvas rule — no canvases, a duplicate
|
|
281
|
+
* canvas id, an empty canvas, a canvas naming an unknown page, a page on no
|
|
282
|
+
* canvas or on two (canvases must partition the pages) — or a website page
|
|
283
|
+
* rule — duplicate path, no root page or more than one, an optional root
|
|
284
|
+
* page, a non-root path that is not a single lowercase-kebab segment. Format geometry bounds (positive
|
|
285
|
+
* dimensions, the 72–600 dpi window, bleed ≥ 0, no mixed physical/pixel
|
|
286
|
+
* dimensions) are enforced by the format schemas themselves.
|
|
287
|
+
*/
|
|
288
|
+
const TemplateManifest = z.discriminatedUnion("output", [
|
|
289
|
+
WebsiteManifest,
|
|
290
|
+
ImageManifest,
|
|
291
|
+
DocumentManifest
|
|
292
|
+
]).superRefine((manifest, ctx) => {
|
|
293
|
+
refinePageRules(manifest, ctx);
|
|
294
|
+
refineCanvasRules(manifest, ctx);
|
|
295
|
+
if (manifest.output === "website") refineWebsiteRules(manifest, ctx);
|
|
296
|
+
else refineRenderedRules(manifest, ctx);
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
//#endregion
|
|
300
|
+
export { TemplateManifest };
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { ResponsiveImage } from "../packages/internal/image-descriptor/dist/index.js";
|
|
2
|
+
//#region src/schema/property-facts.d.ts
|
|
3
|
+
/** A geocoded point: latitude and longitude. */
|
|
4
|
+
type Coordinates = {
|
|
5
|
+
lat: number;
|
|
6
|
+
lng: number;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* The property's always-on prose description — the substrate every text
|
|
10
|
+
* decision is grounded in, and a fact a `compute()` reads directly. A true
|
|
11
|
+
* canonical mirror, like `address`: `""` is a real state (nothing written
|
|
12
|
+
* yet), never a placeholder.
|
|
13
|
+
*/
|
|
14
|
+
type Narrative = {
|
|
15
|
+
description: string;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* One floor plan attached to a unit, in the fixture/render-time view.
|
|
19
|
+
* `url`/`alt`/`responsive` are ATTACHED at render time by a resolution step —
|
|
20
|
+
* absent here means "not yet resolved", never "no plan".
|
|
21
|
+
*/
|
|
22
|
+
type FloorplanAssignment = {
|
|
23
|
+
id: string;
|
|
24
|
+
upload_id?: string;
|
|
25
|
+
url?: string;
|
|
26
|
+
alt?: string;
|
|
27
|
+
floor_label: string | null;
|
|
28
|
+
position: number;
|
|
29
|
+
responsive?: ResponsiveImage | null;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* One property unit in the fixture/render-time view: its scalar facts plus
|
|
33
|
+
* its AI-generated `description`/`features` — baked into content by the
|
|
34
|
+
* floorplan section's per-unit fill decision, not aggregated from any
|
|
35
|
+
* canonical field — and its attached `floor_plans`.
|
|
36
|
+
*/
|
|
37
|
+
type UnitRow = {
|
|
38
|
+
unit_id: string;
|
|
39
|
+
unit_label: string | null;
|
|
40
|
+
beds: number | null;
|
|
41
|
+
baths: number | null;
|
|
42
|
+
sqft: number | null;
|
|
43
|
+
price: string | null;
|
|
44
|
+
description: string | null;
|
|
45
|
+
features: string[];
|
|
46
|
+
position: number;
|
|
47
|
+
floor_plans: FloorplanAssignment[];
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* One comparable property — a recently sold or currently listed home similar
|
|
51
|
+
* to the subject — as the canonical fact bundle carries it. A true canonical
|
|
52
|
+
* mirror, like `address` and `contacts`: a `compute()` reads these rows to
|
|
53
|
+
* derive every market number a slide shows, so a fixture states them in the
|
|
54
|
+
* same shape. `address`, `distance_m` and `price_period` are the three members
|
|
55
|
+
* the live projection derives (the display line, meters from the subject, and
|
|
56
|
+
* what the price is denominated in); a fixture states them directly.
|
|
57
|
+
*/
|
|
58
|
+
type ComparableRow = {
|
|
59
|
+
id: string;
|
|
60
|
+
address_street: string | null;
|
|
61
|
+
address_city: string | null;
|
|
62
|
+
address_state: string | null;
|
|
63
|
+
address_postal: string | null;
|
|
64
|
+
address: string;
|
|
65
|
+
lat: number | null;
|
|
66
|
+
lng: number | null;
|
|
67
|
+
distance_m: number | null;
|
|
68
|
+
status: "sold" | "active" | null;
|
|
69
|
+
/** One integer in dollars — the sale price when sold, the list price otherwise. Read it with `price_period`, which says whether the figure is a total or a rent per month. */
|
|
70
|
+
price: number | null;
|
|
71
|
+
/** What `price` is denominated in: `"monthly"` for comps on a for-rent property, `"total"` otherwise. Never null — a price printed without it renders a $2,400 rent as a sale. */
|
|
72
|
+
price_period: "total" | "monthly";
|
|
73
|
+
/** ISO `YYYY-MM-DD`; null unless sold. */
|
|
74
|
+
sale_date: string | null;
|
|
75
|
+
beds: number | null;
|
|
76
|
+
baths: number | null;
|
|
77
|
+
sqft: number | null;
|
|
78
|
+
photo_url: string | null;
|
|
79
|
+
source_url: string | null;
|
|
80
|
+
source_name: string | null;
|
|
81
|
+
};
|
|
82
|
+
//#endregion
|
|
83
|
+
export { ComparableRow, Coordinates, FloorplanAssignment, Narrative, UnitRow };
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { ResponsiveImage } from "../packages/internal/image-descriptor/dist/index.js";
|
|
2
|
+
import { VideoCollectionValue, VideoValue } from "../packages/internal/template-contracts/dist/video-value.js";
|
|
3
|
+
import { TourCollectionValue, TourValue } from "../packages/internal/template-contracts/dist/tour-value.js";
|
|
4
|
+
import { DocumentCollectionValue, DocumentValue } from "../packages/internal/template-contracts/dist/document-value.js";
|
|
5
|
+
import { PoiPhoto, PoiRow } from "../packages/internal/template-contracts/dist/poi-row.js";
|
|
6
|
+
import { ComparableRow, Coordinates, FloorplanAssignment, Narrative, UnitRow } from "./property-facts.js";
|
|
7
|
+
//#region src/schema/runtime-values.d.ts
|
|
8
|
+
/**
|
|
9
|
+
* An image slot's runtime value after resolution: `url`/`alt` plus optional
|
|
10
|
+
* re-edit state (`rect`, `ar`, `crop_key`) carried for the cropper, never
|
|
11
|
+
* rendered directly. The crop is baked into `url` itself — the kit reconstructs
|
|
12
|
+
* none of it at render time; a renderer reads only `url`, `alt`, `mobile`, and
|
|
13
|
+
* `responsive`.
|
|
14
|
+
*/
|
|
15
|
+
type ImageValue = {
|
|
16
|
+
photo_id: string;
|
|
17
|
+
url: string;
|
|
18
|
+
alt: string;
|
|
19
|
+
rect?: {
|
|
20
|
+
nx: number;
|
|
21
|
+
ny: number;
|
|
22
|
+
nw: number;
|
|
23
|
+
nh: number;
|
|
24
|
+
} | null;
|
|
25
|
+
ar?: number | null;
|
|
26
|
+
crop_key?: string;
|
|
27
|
+
mobile?: {
|
|
28
|
+
url: string;
|
|
29
|
+
responsive?: ResponsiveImage | null;
|
|
30
|
+
} | null;
|
|
31
|
+
responsive?: ResponsiveImage | null;
|
|
32
|
+
};
|
|
33
|
+
/** An image list slot's runtime value: an ordered array of `ImageValue`, possibly empty. */
|
|
34
|
+
type ImageCollectionValue = ImageValue[];
|
|
35
|
+
/**
|
|
36
|
+
* One row of a `contacts`-bound record list, as a renderer receives it: the
|
|
37
|
+
* collection's projection of one contact card. `id` is the contact's stable
|
|
38
|
+
* row identity. Scalar fields resolve to `""` when the card has no value;
|
|
39
|
+
* `bio` is baked verbatim and is `null` when the card carries none. `headshot`
|
|
40
|
+
* and `logo` resolve to a served `ImageValue`, or `null` when the card has no
|
|
41
|
+
* such image.
|
|
42
|
+
*/
|
|
43
|
+
type ContactRow = {
|
|
44
|
+
id: string;
|
|
45
|
+
name: string;
|
|
46
|
+
title: string;
|
|
47
|
+
bio: string | null;
|
|
48
|
+
email: string;
|
|
49
|
+
phone: string;
|
|
50
|
+
instagram: string;
|
|
51
|
+
linkedin: string;
|
|
52
|
+
x: string;
|
|
53
|
+
facebook: string;
|
|
54
|
+
website: string;
|
|
55
|
+
headshot: ImageValue | null;
|
|
56
|
+
logo: ImageValue | null;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* A raster image the template itself ships — a build-time `import` of a file
|
|
60
|
+
* under the template's own assets — resolved to its optimized responsive
|
|
61
|
+
* ladder. Distinct from `ImageValue`: it has no database identity of any
|
|
62
|
+
* kind, no `alt` (the template must supply one directly), and no `mobile`
|
|
63
|
+
* crop variant, since it is part of the template's design rather than a
|
|
64
|
+
* per-property editorial decision.
|
|
65
|
+
*/
|
|
66
|
+
type AuthorImage = {
|
|
67
|
+
url: string;
|
|
68
|
+
responsive: ResponsiveImage | null;
|
|
69
|
+
width: number;
|
|
70
|
+
height: number;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Author-declared playback behavior for a video slot, referenced from the
|
|
74
|
+
* slot's `playback` field and passed to `<Video playback>`. `autoplay`
|
|
75
|
+
* requires `muted` — every browser blocks unmuted autoplay — enforced by a
|
|
76
|
+
* Zod refinement on the slot definition at check time, not by this type.
|
|
77
|
+
*/
|
|
78
|
+
type PlaybackConfig = {
|
|
79
|
+
autoplay?: boolean;
|
|
80
|
+
loop?: boolean;
|
|
81
|
+
muted?: boolean;
|
|
82
|
+
controls?: boolean;
|
|
83
|
+
playsinline?: boolean;
|
|
84
|
+
/** Bandwidth lever: "none" for a below-fold video most visitors never reach. */
|
|
85
|
+
preload?: "none" | "metadata" | "auto";
|
|
86
|
+
};
|
|
87
|
+
//#endregion
|
|
88
|
+
export { AuthorImage, type ComparableRow, ContactRow, type Coordinates, type DocumentCollectionValue, type DocumentValue, type FloorplanAssignment, ImageCollectionValue, ImageValue, type Narrative, PlaybackConfig, type PoiPhoto, type PoiRow, type TourCollectionValue, type TourValue, type UnitRow, type VideoCollectionValue, type VideoValue };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
//#region src/schema/section-nav.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* The build-injected navigation input a section Renderer receives alongside
|
|
4
|
+
* `slots` and `options`. Resolution happens at build/render time, never
|
|
5
|
+
* inside a pure renderer — the composition-aware caller builds the map from
|
|
6
|
+
* the composed sections' resolved `anchor` values and passes it in.
|
|
7
|
+
*/
|
|
8
|
+
type SectionNav = {
|
|
9
|
+
/** This section's own in-page id (its `meta.anchor`, default = section name). Used as `<Section id={nav.selfAnchor}>`. */
|
|
10
|
+
selfAnchor: string;
|
|
11
|
+
/**
|
|
12
|
+
* Target section key → resolved href. A cross-section link reads
|
|
13
|
+
* `nav.anchors[targetKey]`; a downstream validation step wraps this map so
|
|
14
|
+
* looking up an unknown key throws at render time, failing the build, rather
|
|
15
|
+
* than silently emitting an `undefined` href.
|
|
16
|
+
*
|
|
17
|
+
* A target on the CURRENT page resolves to a bare `#anchor`; a target on
|
|
18
|
+
* another page to that page's URL plus the fragment (`/gallery/#anchor`), so
|
|
19
|
+
* the same renderer code links within and across pages with no branch.
|
|
20
|
+
*/
|
|
21
|
+
anchors: Record<string, string>;
|
|
22
|
+
/**
|
|
23
|
+
* The site's pages in composition order, for a renderer that builds a menu.
|
|
24
|
+
* Disabled pages are excluded, so a renderer never has to know about
|
|
25
|
+
* optionality; `current` marks the page this render is for.
|
|
26
|
+
*/
|
|
27
|
+
pages: NavPage[];
|
|
28
|
+
};
|
|
29
|
+
/** One entry of `nav.pages` — what a menu-building renderer needs and nothing more. */
|
|
30
|
+
type NavPage = {
|
|
31
|
+
id: string;
|
|
32
|
+
label: string;
|
|
33
|
+
/** Absolute, already carrying the render's base path, in canonical directory form (`/gallery/`). */
|
|
34
|
+
href: string;
|
|
35
|
+
current: boolean;
|
|
36
|
+
};
|
|
37
|
+
//#endregion
|
|
38
|
+
export { NavPage, SectionNav };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//#region src/schema/section-nav.ts
|
|
2
|
+
/**
|
|
3
|
+
* The anchor map a STANDALONE render receives: every target key resolves to
|
|
4
|
+
* `#<target>`. A lone section has no composed page to link into, so nothing is
|
|
5
|
+
* authored — the map is synthesized. It answers ANY key rather than a fixed
|
|
6
|
+
* record because a renderer's target keys are its own, and the links are dead
|
|
7
|
+
* ends in a standalone preview regardless; a composed page builds the real map
|
|
8
|
+
* from its composition instead.
|
|
9
|
+
*/
|
|
10
|
+
function previewAnchors() {
|
|
11
|
+
const target = {};
|
|
12
|
+
return new Proxy(target, { get: (_target, prop) => {
|
|
13
|
+
if (typeof prop !== "string" || prop in target || prop === "then" || prop === "toJSON") return target[prop];
|
|
14
|
+
return `#${prop}`;
|
|
15
|
+
} });
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The page list a STANDALONE render receives: empty. Unlike `previewAnchors`,
|
|
19
|
+
* which can synthesize an answer for whatever key it is ASKED for, a page list
|
|
20
|
+
* must be ENUMERATED — and a lone section has no site map, so any entry here
|
|
21
|
+
* would be an invented page a menu then renders as real. A menu-building
|
|
22
|
+
* renderer emits no items in a standalone preview, which is the honest render.
|
|
23
|
+
*/
|
|
24
|
+
function previewPages() {
|
|
25
|
+
return [];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
export { previewAnchors, previewPages };
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { CollectionField } from "../packages/internal/template-contracts/dist/slot-catalog.js";
|
|
2
|
+
import { VideoValue } from "../packages/internal/template-contracts/dist/video-value.js";
|
|
3
|
+
import { TourValue } from "../packages/internal/template-contracts/dist/tour-value.js";
|
|
4
|
+
import { DocumentValue } from "../packages/internal/template-contracts/dist/document-value.js";
|
|
5
|
+
import { PoiRow } from "../packages/internal/template-contracts/dist/poi-row.js";
|
|
6
|
+
import { ImageValue } from "./runtime-values.js";
|
|
7
|
+
import { CollectionRowValues } from "./fact.js";
|
|
8
|
+
import { SectionNav } from "./section-nav.js";
|
|
9
|
+
import { SectionSchemaShape } from "./section-schema.js";
|
|
10
|
+
//#region src/schema/section-props.d.ts
|
|
11
|
+
/**
|
|
12
|
+
* Maps one slot definition (as authored under a section schema's `slots`) to
|
|
13
|
+
* the runtime value shape a renderer receives at `props.slots[<key>]`, as
|
|
14
|
+
* normalized by the binding layer. String-valued kinds (`text`, `select`,
|
|
15
|
+
* `url`) are plain `string` — the canonical blank is `""`, never `null`; a
|
|
16
|
+
* `number`, `image`, `poi` or `document` slot's blank is `null`. A `list` slot is always an
|
|
17
|
+
* array, never `null` — an empty list is the absent state. A record list bound
|
|
18
|
+
* whole-row to a bakeable fact array types its rows from that collection's
|
|
19
|
+
* projected row type (see `BakedRowValue`), not from a synthesis of its
|
|
20
|
+
* declared fields.
|
|
21
|
+
*/
|
|
22
|
+
type SlotValue<S> = S extends {
|
|
23
|
+
type: "text";
|
|
24
|
+
} ? string : S extends {
|
|
25
|
+
type: "number";
|
|
26
|
+
} ? number | null : S extends {
|
|
27
|
+
type: "select";
|
|
28
|
+
} ? string : S extends {
|
|
29
|
+
type: "image";
|
|
30
|
+
} ? ImageValue | null : S extends {
|
|
31
|
+
type: "video";
|
|
32
|
+
} ? VideoValue | null : S extends {
|
|
33
|
+
type: "tour";
|
|
34
|
+
} ? TourValue | null : S extends {
|
|
35
|
+
type: "list";
|
|
36
|
+
source: {
|
|
37
|
+
kind: "direct";
|
|
38
|
+
field: infer F extends CollectionField;
|
|
39
|
+
};
|
|
40
|
+
fields: infer I;
|
|
41
|
+
} ? BakedRowValue<F, I>[] : S extends {
|
|
42
|
+
type: "list";
|
|
43
|
+
fields: infer I;
|
|
44
|
+
} ? RowValue<I>[] : S extends {
|
|
45
|
+
type: "list";
|
|
46
|
+
element: infer E;
|
|
47
|
+
} ? NonNullable<SlotValue<E>>[] : S extends {
|
|
48
|
+
type: "list";
|
|
49
|
+
} ? unknown[] : S extends {
|
|
50
|
+
type: "poi";
|
|
51
|
+
} ? PoiRow | null : S extends {
|
|
52
|
+
type: "url";
|
|
53
|
+
} ? string : S extends {
|
|
54
|
+
type: "document";
|
|
55
|
+
} ? DocumentValue | null : never;
|
|
56
|
+
/**
|
|
57
|
+
* One row of a record `list` slot, derived from the declared `fields` record:
|
|
58
|
+
* the editor-stamped `id` — which every persisted row carries though `fields`
|
|
59
|
+
* never declares it — plus each declared field typed by its own definition.
|
|
60
|
+
* The shape is closed (no index signature), so an undeclared field is a
|
|
61
|
+
* compile error.
|
|
62
|
+
*/
|
|
63
|
+
type RowValue<I> = {
|
|
64
|
+
id: string;
|
|
65
|
+
} & { [K in keyof I]: SlotValue<I[K]>; };
|
|
66
|
+
type AuthoredRowFieldKeys<I> = { [K in keyof I]: I[K] extends {
|
|
67
|
+
source: unknown;
|
|
68
|
+
} ? never : K; }[keyof I];
|
|
69
|
+
/**
|
|
70
|
+
* One row of a record `list` bound whole-row to a bakeable fact array
|
|
71
|
+
* (`source: fact.property.units` / `fact.property.contacts`): the collection's
|
|
72
|
+
* projected row type (`CollectionRowValues[F]`), plus any authored
|
|
73
|
+
* (source-less) fields the projection does not already carry, typed from their
|
|
74
|
+
* builders. A field the projection does carry keeps the projection's type —
|
|
75
|
+
* the bake delivers that shape whether or not the field is also declared.
|
|
76
|
+
*/
|
|
77
|
+
type BakedRowValue<F extends CollectionField, I> = CollectionRowValues[F] & { [K in Exclude<AuthoredRowFieldKeys<I>, keyof CollectionRowValues[F]>]: SlotValue<I[K]>; };
|
|
78
|
+
type VariantOf<S extends SectionSchemaShape> = S["meta"] extends {
|
|
79
|
+
display: {
|
|
80
|
+
variant: {
|
|
81
|
+
cases: readonly (infer C extends string)[];
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
} ? C : string;
|
|
85
|
+
/**
|
|
86
|
+
* The full renderer prop type derived from a section's schema: `slots`, the
|
|
87
|
+
* build-injected `nav`, and the stored `variant` case (the union of the
|
|
88
|
+
* declared `display.variant` cases, or plain `string` when the section
|
|
89
|
+
* declares none). Sections declare `export type Props =
|
|
90
|
+
* SectionProps<typeof schema>;` rather than hand-writing this shape.
|
|
91
|
+
*/
|
|
92
|
+
type SectionProps<S extends SectionSchemaShape> = {
|
|
93
|
+
slots: { [K in keyof S["slots"]]: SlotValue<S["slots"][K]>; };
|
|
94
|
+
nav: SectionNav;
|
|
95
|
+
variant: VariantOf<S>;
|
|
96
|
+
};
|
|
97
|
+
//#endregion
|
|
98
|
+
export { BakedRowValue, RowValue, SectionProps, SlotValue };
|