@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,163 @@
|
|
|
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 "./contract.js";
|
|
2
|
+
import { editorInstanceContext } from "./editor-instance-context.js";
|
|
3
|
+
import { islandsCaptureReady, takeCaptureHold } from "./capture-holds.js";
|
|
4
|
+
import { scheduleViewport } from "./viewport-schedule.js";
|
|
5
|
+
|
|
6
|
+
//#region ../../internal/island-runtime/dist/index.js
|
|
7
|
+
/** The host-stamped section-root attribute the loader scopes each island's editor instance by. */
|
|
8
|
+
const ATTR_SECTION_INSTANCE_ID = "data-section-instance-id";
|
|
9
|
+
const roots = /* @__PURE__ */ new WeakMap();
|
|
10
|
+
/**
|
|
11
|
+
* Hydrate every island marker under `options.root` (default: the whole document)
|
|
12
|
+
* into its own React root, loading each one's module through `options.load`.
|
|
13
|
+
*
|
|
14
|
+
* A marker carrying `data-tr-island-frameless` holds no server-rendered output, so its
|
|
15
|
+
* island is mounted fresh rather than hydrated — there is nothing to hydrate against,
|
|
16
|
+
* and asking React to try reports a mismatch on every such island.
|
|
17
|
+
*
|
|
18
|
+
* A marker nested inside another marker is skipped — it belongs to the parent
|
|
19
|
+
* island's own render, so hydrating it separately would create a second root on
|
|
20
|
+
* DOM the parent already owns. A marker whose props payload is missing, or that
|
|
21
|
+
* shares its id with another payload, is refused rather than guessed at. A marker
|
|
22
|
+
* that leaves the document while its module is still loading is silently skipped:
|
|
23
|
+
* that is the host's own re-render racing this call, not a failure. Every other
|
|
24
|
+
* failure — a rejected `load()`, a thrown render — reaches `options.onError`
|
|
25
|
+
* rather than throwing out of this call, so one bad island never blocks its
|
|
26
|
+
* neighbors.
|
|
27
|
+
*
|
|
28
|
+
* Islands hydrate by viewport priority: the returned promise covers what is visible at
|
|
29
|
+
* first paint, and `onHydrated` reports the rest as the visitor approaches them or the
|
|
30
|
+
* main thread goes idle. `schedule: "eager"` hydrates every island before this call
|
|
31
|
+
* settles instead — see {@link HydrateIslandsOptions.schedule}.
|
|
32
|
+
*
|
|
33
|
+
* WHICH islands this promise covers is the schedule's business; WHETHER they have
|
|
34
|
+
* mounted is not. It settles once each covered island has a React root, which React
|
|
35
|
+
* commits a task later — so a caller that needs the islands' DOM to EXIST (a capturer,
|
|
36
|
+
* a measuring pass) must await {@link IslandContext.mounted} on the handles, which is
|
|
37
|
+
* why every handle carries one.
|
|
38
|
+
*/
|
|
39
|
+
async function hydrateIslands(options) {
|
|
40
|
+
const root = options.root ?? document;
|
|
41
|
+
const markers = Array.from(root.querySelectorAll(`[${ATTR_ISLAND_KEY}]`)).filter((element) => !roots.has(element) && element.parentElement?.closest(`[${"data-tr-island"}]`) == null);
|
|
42
|
+
if (markers.length === 0) return [];
|
|
43
|
+
const payloads = /* @__PURE__ */ new Map();
|
|
44
|
+
const duplicateIds = /* @__PURE__ */ new Set();
|
|
45
|
+
for (const script of root.querySelectorAll(`script[${ATTR_ISLAND_PROPS}]`)) {
|
|
46
|
+
const id = script.getAttribute(ATTR_ISLAND_PROPS);
|
|
47
|
+
if (id === null) continue;
|
|
48
|
+
if (payloads.has(id)) duplicateIds.add(id);
|
|
49
|
+
payloads.set(id, script.textContent ?? "");
|
|
50
|
+
}
|
|
51
|
+
const [react, { createRoot, hydrateRoot }] = await Promise.all([import("react"), import("react-dom/client")]);
|
|
52
|
+
const { createElement } = react;
|
|
53
|
+
const InstanceContext = editorInstanceContext(react);
|
|
54
|
+
const MountSignal = ({ onMounted, children }) => {
|
|
55
|
+
const [pass, setPass] = react.useState(0);
|
|
56
|
+
react.useEffect(() => {
|
|
57
|
+
if (pass === 0) setPass(1);
|
|
58
|
+
else onMounted();
|
|
59
|
+
}, [pass, onMounted]);
|
|
60
|
+
return children;
|
|
61
|
+
};
|
|
62
|
+
const loading = /* @__PURE__ */ new Map();
|
|
63
|
+
const loadOnce = (key) => {
|
|
64
|
+
let pending = loading.get(key);
|
|
65
|
+
if (!pending) {
|
|
66
|
+
pending = options.load(key);
|
|
67
|
+
loading.set(key, pending);
|
|
68
|
+
}
|
|
69
|
+
return pending;
|
|
70
|
+
};
|
|
71
|
+
const viewport = options.schedule !== "eager";
|
|
72
|
+
const load = viewport ? loadOnce : options.load;
|
|
73
|
+
const hydrateMarker = async (element) => {
|
|
74
|
+
const key = element.getAttribute("data-tr-island") ?? "";
|
|
75
|
+
const id = element.getAttribute("data-tr-island-id") ?? "";
|
|
76
|
+
let signalMounted = () => {};
|
|
77
|
+
const ctx = {
|
|
78
|
+
id,
|
|
79
|
+
key,
|
|
80
|
+
element,
|
|
81
|
+
mounted: new Promise((resolve) => {
|
|
82
|
+
signalMounted = resolve;
|
|
83
|
+
})
|
|
84
|
+
};
|
|
85
|
+
try {
|
|
86
|
+
if (duplicateIds.has(id)) throw new Error(`island "${id}" (${key}) shares its id with another ${ATTR_ISLAND_PROPS} payload — refusing to hydrate either instance rather than guess whose props belong to which marker`);
|
|
87
|
+
const payload = payloads.get(id);
|
|
88
|
+
if (payload === void 0) throw new Error(`island "${id}" (${key}) has no ${ATTR_ISLAND_PROPS} payload`);
|
|
89
|
+
const props = deserializeIslandProps(payload);
|
|
90
|
+
const module = await load(key);
|
|
91
|
+
ctx.editor = module.editor;
|
|
92
|
+
if (options.shouldHydrate && !options.shouldHydrate(ctx)) {
|
|
93
|
+
signalMounted();
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
if (roots.has(element)) {
|
|
97
|
+
signalMounted();
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
if (!element.isConnected) {
|
|
101
|
+
signalMounted();
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
const instanceId = element.closest(`[${"data-section-instance-id"}]`)?.getAttribute("data-section-instance-id") ?? null;
|
|
105
|
+
const tree = createElement(InstanceContext, { value: instanceId }, createElement(MountSignal, {
|
|
106
|
+
onMounted: signalMounted,
|
|
107
|
+
children: createElement(module.default, props)
|
|
108
|
+
}));
|
|
109
|
+
const rootOptions = {
|
|
110
|
+
onUncaughtError: (renderError) => {
|
|
111
|
+
options.onError?.(renderError, ctx);
|
|
112
|
+
signalMounted();
|
|
113
|
+
},
|
|
114
|
+
onCaughtError: (renderError) => {
|
|
115
|
+
options.onError?.(renderError, ctx);
|
|
116
|
+
signalMounted();
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
let reactRoot;
|
|
120
|
+
if (element.hasAttribute("data-tr-island-frameless")) {
|
|
121
|
+
reactRoot = createRoot(element, rootOptions);
|
|
122
|
+
reactRoot.render(tree);
|
|
123
|
+
} else reactRoot = hydrateRoot(element, tree, rootOptions);
|
|
124
|
+
roots.set(element, reactRoot);
|
|
125
|
+
options.onHydrated?.(ctx);
|
|
126
|
+
return ctx;
|
|
127
|
+
} catch (error) {
|
|
128
|
+
options.onError?.(error, ctx);
|
|
129
|
+
signalMounted();
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
if (viewport) return scheduleViewport({
|
|
134
|
+
markers,
|
|
135
|
+
hydrate: hydrateMarker,
|
|
136
|
+
warm: (key) => {
|
|
137
|
+
loadOnce(key).catch(() => void 0);
|
|
138
|
+
},
|
|
139
|
+
moduleUrl: options.moduleUrl
|
|
140
|
+
});
|
|
141
|
+
const handles = [];
|
|
142
|
+
for (const element of markers) {
|
|
143
|
+
const hydrated = await hydrateMarker(element);
|
|
144
|
+
if (hydrated) handles.push(hydrated);
|
|
145
|
+
}
|
|
146
|
+
return handles;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Unmount every island hydrated under `root`. Synchronous, so the editor can call it
|
|
150
|
+
* immediately before replacing a section's innerHTML.
|
|
151
|
+
*/
|
|
152
|
+
function unmountIslands(root = document) {
|
|
153
|
+
const self = root instanceof Element && root.matches(`[${"data-tr-island"}]`) ? [root] : [];
|
|
154
|
+
for (const element of [...self, ...root.querySelectorAll(`[${ATTR_ISLAND_KEY}]`)]) {
|
|
155
|
+
const reactRoot = roots.get(element);
|
|
156
|
+
if (!reactRoot) continue;
|
|
157
|
+
roots.delete(element);
|
|
158
|
+
reactRoot.unmount();
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
//#endregion
|
|
163
|
+
export { ATTR_ISLAND_FRAMELESS, ATTR_ISLAND_ID, ATTR_ISLAND_KEY, ATTR_ISLAND_PROPS, ATTR_SECTION_INSTANCE_ID, EDITOR_BRIDGE_PROP, EDITOR_BRIDGE_PROTOCOL, ISLAND_CAPTURE_HOLDS_GLOBAL, ISLAND_ELEMENT, IslandPropsError, deserializeIslandProps, hydrateIslands, islandId, islandsCaptureReady, serializeIslandProps, unmountIslands };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region ../../internal/island-runtime/dist/use-capture-ready.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Hold the capture shutter until this island's pixels are real.
|
|
4
|
+
*
|
|
5
|
+
* An island that keeps painting after mount — a map engine loading tiles, an
|
|
6
|
+
* async decode — calls this hook and invokes the returned `ready` when its
|
|
7
|
+
* last pixel is painted (`map.once("idle", ready)` is the map-engine shape).
|
|
8
|
+
* Calling the hook takes a hold for this island instance at mount; `ready` is
|
|
9
|
+
* identity-stable and idempotent, an unmounted island releases automatically,
|
|
10
|
+
* and a branch with nothing to draw calls `ready()` immediately. An island
|
|
11
|
+
* that paints everything during mount needs none of this — never calling the
|
|
12
|
+
* hook is the default contract.
|
|
13
|
+
*
|
|
14
|
+
* Where nothing captures (an editor canvas, a published website) the hold is
|
|
15
|
+
* never read, so the hook costs nothing there.
|
|
16
|
+
*/
|
|
17
|
+
declare function useCaptureReady(): () => void;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { useCaptureReady };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { takeCaptureHold } from "./capture-holds.js";
|
|
2
|
+
import { useCallback, useEffect, useRef } from "react";
|
|
3
|
+
|
|
4
|
+
//#region ../../internal/island-runtime/dist/use-capture-ready.js
|
|
5
|
+
/**
|
|
6
|
+
* Hold the capture shutter until this island's pixels are real.
|
|
7
|
+
*
|
|
8
|
+
* An island that keeps painting after mount — a map engine loading tiles, an
|
|
9
|
+
* async decode — calls this hook and invokes the returned `ready` when its
|
|
10
|
+
* last pixel is painted (`map.once("idle", ready)` is the map-engine shape).
|
|
11
|
+
* Calling the hook takes a hold for this island instance at mount; `ready` is
|
|
12
|
+
* identity-stable and idempotent, an unmounted island releases automatically,
|
|
13
|
+
* and a branch with nothing to draw calls `ready()` immediately. An island
|
|
14
|
+
* that paints everything during mount needs none of this — never calling the
|
|
15
|
+
* hook is the default contract.
|
|
16
|
+
*
|
|
17
|
+
* Where nothing captures (an editor canvas, a published website) the hold is
|
|
18
|
+
* never read, so the hook costs nothing there.
|
|
19
|
+
*/
|
|
20
|
+
function useCaptureReady() {
|
|
21
|
+
const releaseRef = useRef(null);
|
|
22
|
+
const readyRef = useRef(false);
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
const release = takeCaptureHold();
|
|
25
|
+
releaseRef.current = release;
|
|
26
|
+
if (readyRef.current) release();
|
|
27
|
+
return () => {
|
|
28
|
+
release();
|
|
29
|
+
releaseRef.current = null;
|
|
30
|
+
};
|
|
31
|
+
}, []);
|
|
32
|
+
return useCallback(() => {
|
|
33
|
+
readyRef.current = true;
|
|
34
|
+
releaseRef.current?.();
|
|
35
|
+
}, []);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
//#endregion
|
|
39
|
+
export { useCaptureReady };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { EditorSelection } from "./contract.js";
|
|
2
|
+
//#region ../../internal/island-runtime/dist/use-editor.d.ts
|
|
3
|
+
/** What {@link useEditor} returns. */
|
|
4
|
+
interface UseEditorResult {
|
|
5
|
+
/** True only in an editor canvas whose bridge speaks a compatible protocol. */
|
|
6
|
+
inCanvas: boolean;
|
|
7
|
+
/** The selection inside this island's own section instance, else null. */
|
|
8
|
+
selection: EditorSelection | null;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Whether this island is live in an editor canvas, and what is selected inside
|
|
12
|
+
* its own section instance.
|
|
13
|
+
*
|
|
14
|
+
* During server rendering, on published pages, and under an incompatible bridge
|
|
15
|
+
* protocol it returns `{ inCanvas: false, selection: null }` — hydration-safe by
|
|
16
|
+
* construction. `selection` is already scoped to the island's own section
|
|
17
|
+
* instance and keeps its identity between publishes, so it is safe to use as an
|
|
18
|
+
* effect dependency.
|
|
19
|
+
*/
|
|
20
|
+
declare function useEditor(): UseEditorResult;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { UseEditorResult, useEditor };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { EDITOR_BRIDGE_PROP, EDITOR_BRIDGE_PROTOCOL } from "./contract.js";
|
|
2
|
+
import { editorInstanceContext } from "./editor-instance-context.js";
|
|
3
|
+
import { createContext, useCallback, useContext, useMemo, useSyncExternalStore } from "react";
|
|
4
|
+
|
|
5
|
+
//#region ../../internal/island-runtime/dist/use-editor.js
|
|
6
|
+
const InstanceContext = editorInstanceContext({ createContext });
|
|
7
|
+
const warnedBridges = /* @__PURE__ */ new WeakSet();
|
|
8
|
+
function compatibleBridge() {
|
|
9
|
+
if (typeof window === "undefined") return null;
|
|
10
|
+
const bridge = window[EDITOR_BRIDGE_PROP];
|
|
11
|
+
if (!bridge) return null;
|
|
12
|
+
if (bridge.protocol !== 1) {
|
|
13
|
+
if (!warnedBridges.has(bridge)) {
|
|
14
|
+
warnedBridges.add(bridge);
|
|
15
|
+
console.warn(`editor bridge protocol ${String(bridge.protocol)} does not match this island's supported protocol ${String(1)}; islands fall back to published-page behavior`);
|
|
16
|
+
}
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
return bridge;
|
|
20
|
+
}
|
|
21
|
+
function scopeSelection(raw, instanceId) {
|
|
22
|
+
if (!raw || instanceId === null || raw.instanceId !== instanceId) return null;
|
|
23
|
+
if (raw.kind === "section") return { kind: "section" };
|
|
24
|
+
return {
|
|
25
|
+
kind: "slot",
|
|
26
|
+
slotId: raw.slotId,
|
|
27
|
+
...raw.itemIndex !== void 0 ? { itemIndex: raw.itemIndex } : {},
|
|
28
|
+
...raw.fieldName !== void 0 ? { fieldName: raw.fieldName } : {}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Whether this island is live in an editor canvas, and what is selected inside
|
|
33
|
+
* its own section instance.
|
|
34
|
+
*
|
|
35
|
+
* During server rendering, on published pages, and under an incompatible bridge
|
|
36
|
+
* protocol it returns `{ inCanvas: false, selection: null }` — hydration-safe by
|
|
37
|
+
* construction. `selection` is already scoped to the island's own section
|
|
38
|
+
* instance and keeps its identity between publishes, so it is safe to use as an
|
|
39
|
+
* effect dependency.
|
|
40
|
+
*/
|
|
41
|
+
function useEditor() {
|
|
42
|
+
const instanceId = useContext(InstanceContext);
|
|
43
|
+
const bridge = compatibleBridge();
|
|
44
|
+
const subscribe = useCallback((listener) => bridge ? bridge.subscribe(listener) : () => {}, [bridge]);
|
|
45
|
+
const inCanvas = useSyncExternalStore(subscribe, () => bridge !== null, () => false);
|
|
46
|
+
const raw = useSyncExternalStore(subscribe, () => bridge ? bridge.selection : null, () => null);
|
|
47
|
+
return {
|
|
48
|
+
inCanvas,
|
|
49
|
+
selection: useMemo(() => scopeSelection(raw, instanceId), [raw, instanceId])
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
//#endregion
|
|
54
|
+
export { useEditor };
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { ATTR_ISLAND_KEY } from "./contract.js";
|
|
2
|
+
|
|
3
|
+
//#region ../../internal/island-runtime/dist/viewport-schedule.js
|
|
4
|
+
const APPROACH_MARGIN = "100%";
|
|
5
|
+
function hasBox(target) {
|
|
6
|
+
const box = target.getBoundingClientRect();
|
|
7
|
+
return box.width > 0 || box.height > 0;
|
|
8
|
+
}
|
|
9
|
+
function anchorTarget(element) {
|
|
10
|
+
if (hasBox(element)) return element;
|
|
11
|
+
const child = element.firstElementChild;
|
|
12
|
+
if (child && hasBox(child)) return child;
|
|
13
|
+
for (let prev = element.previousElementSibling; prev; prev = prev.previousElementSibling) if (hasBox(prev)) return prev;
|
|
14
|
+
for (let parent = element.parentElement; parent; parent = parent.parentElement) if (hasBox(parent)) return parent;
|
|
15
|
+
return child ?? element;
|
|
16
|
+
}
|
|
17
|
+
function inViewport(target) {
|
|
18
|
+
const box = target.getBoundingClientRect();
|
|
19
|
+
return box.bottom > 0 && box.right > 0 && box.top < window.innerHeight && box.left < window.innerWidth;
|
|
20
|
+
}
|
|
21
|
+
function saveData() {
|
|
22
|
+
return navigator.connection?.saveData === true;
|
|
23
|
+
}
|
|
24
|
+
function idle(run) {
|
|
25
|
+
if (typeof requestIdleCallback === "function") requestIdleCallback(run);
|
|
26
|
+
else setTimeout(run, 1);
|
|
27
|
+
}
|
|
28
|
+
async function scheduleViewport(options) {
|
|
29
|
+
const { markers, hydrate, warm, moduleUrl } = options;
|
|
30
|
+
const keyOf = (element) => element.getAttribute("data-tr-island") ?? "";
|
|
31
|
+
const started = /* @__PURE__ */ new Set();
|
|
32
|
+
const start = (element) => {
|
|
33
|
+
if (started.has(element)) return Promise.resolve(null);
|
|
34
|
+
started.add(element);
|
|
35
|
+
return hydrate(element);
|
|
36
|
+
};
|
|
37
|
+
const anchors = /* @__PURE__ */ new Map();
|
|
38
|
+
for (const element of markers) anchors.set(element, anchorTarget(element));
|
|
39
|
+
const anchorOf = (element) => anchors.get(element) ?? element;
|
|
40
|
+
const visible = [];
|
|
41
|
+
const rest = [];
|
|
42
|
+
for (const element of markers) (inViewport(anchorOf(element)) ? visible : rest).push(element);
|
|
43
|
+
if (moduleUrl && !saveData()) {
|
|
44
|
+
const preloaded = /* @__PURE__ */ new Set();
|
|
45
|
+
for (const element of rest) {
|
|
46
|
+
const url = moduleUrl(keyOf(element));
|
|
47
|
+
if (url == null || url === "" || preloaded.has(url)) continue;
|
|
48
|
+
preloaded.add(url);
|
|
49
|
+
const link = document.createElement("link");
|
|
50
|
+
link.rel = "modulepreload";
|
|
51
|
+
link.href = url;
|
|
52
|
+
link.setAttribute("fetchpriority", "low");
|
|
53
|
+
document.head.appendChild(link);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
for (const element of visible) warm(keyOf(element));
|
|
57
|
+
const handles = [];
|
|
58
|
+
for (const element of visible) {
|
|
59
|
+
const hydrated = await start(element);
|
|
60
|
+
if (hydrated) handles.push(hydrated);
|
|
61
|
+
}
|
|
62
|
+
let observer = null;
|
|
63
|
+
const byTarget = /* @__PURE__ */ new Map();
|
|
64
|
+
const take = (element) => {
|
|
65
|
+
const hydrating = start(element);
|
|
66
|
+
const target = anchorOf(element);
|
|
67
|
+
const sharing = byTarget.get(target);
|
|
68
|
+
if (!sharing || sharing.every((one) => started.has(one))) observer?.unobserve(target);
|
|
69
|
+
return hydrating;
|
|
70
|
+
};
|
|
71
|
+
if (typeof IntersectionObserver !== "undefined") {
|
|
72
|
+
observer = new IntersectionObserver((entries) => {
|
|
73
|
+
for (const entry of entries) {
|
|
74
|
+
if (!entry.isIntersecting) continue;
|
|
75
|
+
for (const element of byTarget.get(entry.target) ?? []) take(element);
|
|
76
|
+
}
|
|
77
|
+
}, { rootMargin: APPROACH_MARGIN });
|
|
78
|
+
for (const element of rest) {
|
|
79
|
+
const target = anchorOf(element);
|
|
80
|
+
const sharing = byTarget.get(target);
|
|
81
|
+
if (sharing) sharing.push(element);
|
|
82
|
+
else {
|
|
83
|
+
byTarget.set(target, [element]);
|
|
84
|
+
observer.observe(target);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const queue = rest.slice();
|
|
89
|
+
const pump = () => {
|
|
90
|
+
idle(() => {
|
|
91
|
+
let element = queue.shift();
|
|
92
|
+
while (element && started.has(element)) element = queue.shift();
|
|
93
|
+
if (!element) {
|
|
94
|
+
observer?.disconnect();
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
take(element).then(pump, pump);
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
pump();
|
|
101
|
+
return handles;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
//#endregion
|
|
105
|
+
export { scheduleViewport };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { projectFactsView } from "../../template-contracts/dist/facts-view.js";
|
|
2
|
+
import "../../source-resolution/dist/index.js";
|
|
3
|
+
|
|
4
|
+
//#region ../../internal/property-facts/dist/derive-facts-view.js
|
|
5
|
+
function currentYear() {
|
|
6
|
+
const fixed = process.env.TR_FIXED_YEAR;
|
|
7
|
+
if (fixed) {
|
|
8
|
+
const n = Number(fixed);
|
|
9
|
+
if (!Number.isInteger(n)) throw new Error(`TR_FIXED_YEAR not an integer: ${fixed}`);
|
|
10
|
+
return n;
|
|
11
|
+
}
|
|
12
|
+
return (/* @__PURE__ */ new Date()).getUTCFullYear();
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Projects the loaded PropertyFacts into the derive-time `Facts` view an
|
|
16
|
+
* authored `compute()` handle receives. The projector takes the canonical
|
|
17
|
+
* bundle as a loose record and normalizes member-by-member against the fact
|
|
18
|
+
* graph registry, so the Zod-inferred type passes straight in.
|
|
19
|
+
*/
|
|
20
|
+
function buildDeriveFactsView(facts) {
|
|
21
|
+
return projectFactsView(facts, { year: currentYear() });
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
export { buildDeriveFactsView, currentYear };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { C as VideoSchema, S as UnitSchema, _ as PropertyFactsSchema, a as ComparableSchema, b as TourLinkSchema, c as DocumentSchema, f as ListingIntentSchema, h as PlannerUnitSchema, i as ComparablePricePeriodSchema, l as FloorPlanSchema, m as PhotoSchema, n as COMPARABLE_PRICE_PERIODS, o as ComparableStatusSchema, p as NarrativeSchema, r as COMPARABLE_STATUSES, s as ContactCardSchema, t as AddressSchema, u as FloorPlanUnitAssignmentSchema, v as PropertyTypeSchema, x as UnitFloorPlanRefSchema } from "./property-facts-CSdkSuD7.js";
|
|
2
|
+
|
|
3
|
+
export { PropertyFactsSchema };
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
//#region ../../internal/property-facts/dist/property-facts-CSdkSuD7.js
|
|
4
|
+
const AddressSchema = z.object({
|
|
5
|
+
display: z.string(),
|
|
6
|
+
street: z.string(),
|
|
7
|
+
street_no_type: z.string(),
|
|
8
|
+
city: z.string(),
|
|
9
|
+
state: z.string(),
|
|
10
|
+
postal: z.string(),
|
|
11
|
+
unit: z.string().optional()
|
|
12
|
+
});
|
|
13
|
+
const PropertyTypeSchema = z.enum([
|
|
14
|
+
"single_family",
|
|
15
|
+
"condo_townhome",
|
|
16
|
+
"multi_family",
|
|
17
|
+
"investment"
|
|
18
|
+
]);
|
|
19
|
+
const ListingIntentSchema = z.enum(["for_sale", "for_rent"]);
|
|
20
|
+
const NarrativeSchema = z.object({ description: z.string() });
|
|
21
|
+
const TourLinkSchema = z.object({
|
|
22
|
+
id: z.string(),
|
|
23
|
+
url: z.string(),
|
|
24
|
+
provider: z.string()
|
|
25
|
+
});
|
|
26
|
+
const UnitFloorPlanRefSchema = z.object({
|
|
27
|
+
id: z.string(),
|
|
28
|
+
upload_id: z.string().optional(),
|
|
29
|
+
floor_label: z.string().nullable(),
|
|
30
|
+
position: z.number().int()
|
|
31
|
+
});
|
|
32
|
+
const UnitSchema = z.object({
|
|
33
|
+
unit_id: z.string(),
|
|
34
|
+
unit_label: z.string().nullable(),
|
|
35
|
+
beds: z.number().int(),
|
|
36
|
+
baths: z.number(),
|
|
37
|
+
sqft: z.number().int().nullable(),
|
|
38
|
+
price: z.string().max(40).nullable().default(null),
|
|
39
|
+
position: z.number().int(),
|
|
40
|
+
floor_plans: z.array(UnitFloorPlanRefSchema)
|
|
41
|
+
});
|
|
42
|
+
const PhotoSchema = z.object({
|
|
43
|
+
id: z.string(),
|
|
44
|
+
tags: z.array(z.string()),
|
|
45
|
+
caption: z.string().nullable()
|
|
46
|
+
});
|
|
47
|
+
const VideoSchema = z.object({
|
|
48
|
+
id: z.string(),
|
|
49
|
+
source: z.enum(["upload", "link"]),
|
|
50
|
+
tags: z.array(z.string()),
|
|
51
|
+
caption: z.string().nullable(),
|
|
52
|
+
description: z.string().nullable(),
|
|
53
|
+
duration_ms: z.number().int().nullable(),
|
|
54
|
+
url: z.string().nullable(),
|
|
55
|
+
provider: z.string().nullable()
|
|
56
|
+
});
|
|
57
|
+
const DocumentSchema = z.object({
|
|
58
|
+
id: z.string(),
|
|
59
|
+
filename: z.string(),
|
|
60
|
+
mime: z.string(),
|
|
61
|
+
notes: z.string()
|
|
62
|
+
});
|
|
63
|
+
const LinkMetadataCoreSchema = z.object({
|
|
64
|
+
via: z.enum([
|
|
65
|
+
"oembed",
|
|
66
|
+
"api",
|
|
67
|
+
"opengraph",
|
|
68
|
+
"none"
|
|
69
|
+
]).nullable(),
|
|
70
|
+
title: z.string().nullable(),
|
|
71
|
+
description: z.string().nullable(),
|
|
72
|
+
author_name: z.string().nullable(),
|
|
73
|
+
captured_at: z.string().nullable(),
|
|
74
|
+
duration_ms: z.number().int().nullable(),
|
|
75
|
+
thumbnail_source_url: z.string().nullable()
|
|
76
|
+
});
|
|
77
|
+
const FloorPlanUnitAssignmentSchema = z.object({
|
|
78
|
+
unit_label: z.string().nullable(),
|
|
79
|
+
floor_label: z.string().nullable(),
|
|
80
|
+
position: z.number().int()
|
|
81
|
+
});
|
|
82
|
+
const FloorPlanSchema = z.object({
|
|
83
|
+
id: z.string(),
|
|
84
|
+
upload_id: z.string().optional(),
|
|
85
|
+
page_index: z.number().int().optional(),
|
|
86
|
+
unit_assignments: z.array(FloorPlanUnitAssignmentSchema),
|
|
87
|
+
processed_s3_key: z.string().nullable()
|
|
88
|
+
});
|
|
89
|
+
const ContactCardSchema = z.object({
|
|
90
|
+
id: z.string(),
|
|
91
|
+
primary: z.boolean(),
|
|
92
|
+
name: z.string().nullable(),
|
|
93
|
+
title: z.string().nullable(),
|
|
94
|
+
org_name: z.string().nullable(),
|
|
95
|
+
bio: z.string().nullable(),
|
|
96
|
+
email: z.string().nullable(),
|
|
97
|
+
phone: z.string().nullable(),
|
|
98
|
+
address: z.string().nullable(),
|
|
99
|
+
website_url: z.string().nullable(),
|
|
100
|
+
avatar_upload_id: z.string().nullable(),
|
|
101
|
+
logo_dark_upload_id: z.string().nullable(),
|
|
102
|
+
logo_light_upload_id: z.string().nullable(),
|
|
103
|
+
instagram_url: z.string().nullable(),
|
|
104
|
+
linkedin_url: z.string().nullable(),
|
|
105
|
+
x_url: z.string().nullable(),
|
|
106
|
+
facebook_url: z.string().nullable()
|
|
107
|
+
});
|
|
108
|
+
const COMPARABLE_STATUSES = ["sold", "active"];
|
|
109
|
+
const ComparableStatusSchema = z.enum(COMPARABLE_STATUSES);
|
|
110
|
+
const COMPARABLE_PRICE_PERIODS = ["total", "monthly"];
|
|
111
|
+
const ComparablePricePeriodSchema = z.enum(COMPARABLE_PRICE_PERIODS);
|
|
112
|
+
const ComparableSchema = z.object({
|
|
113
|
+
id: z.string(),
|
|
114
|
+
address_street: z.string().nullable(),
|
|
115
|
+
address_city: z.string().nullable(),
|
|
116
|
+
address_state: z.string().nullable(),
|
|
117
|
+
address_postal: z.string().nullable(),
|
|
118
|
+
address: z.string(),
|
|
119
|
+
lat: z.number().nullable(),
|
|
120
|
+
lng: z.number().nullable(),
|
|
121
|
+
distance_m: z.number().nullable(),
|
|
122
|
+
status: ComparableStatusSchema.nullable(),
|
|
123
|
+
price: z.number().int().nullable(),
|
|
124
|
+
price_period: ComparablePricePeriodSchema,
|
|
125
|
+
sale_date: z.string().nullable(),
|
|
126
|
+
beds: z.number().int().nullable(),
|
|
127
|
+
baths: z.number().nullable(),
|
|
128
|
+
sqft: z.number().int().nullable(),
|
|
129
|
+
photo_url: z.string().nullable(),
|
|
130
|
+
source_url: z.string().nullable(),
|
|
131
|
+
source_name: z.string().nullable()
|
|
132
|
+
});
|
|
133
|
+
const PropertyFactsSchema = z.object({
|
|
134
|
+
address: AddressSchema,
|
|
135
|
+
lat: z.number().nullable(),
|
|
136
|
+
lon: z.number().nullable(),
|
|
137
|
+
property_type: PropertyTypeSchema,
|
|
138
|
+
listing_intent: ListingIntentSchema,
|
|
139
|
+
units: z.array(UnitSchema),
|
|
140
|
+
narrative: NarrativeSchema,
|
|
141
|
+
photos: z.array(PhotoSchema),
|
|
142
|
+
videos: z.array(VideoSchema),
|
|
143
|
+
floor_plans: z.array(FloorPlanSchema),
|
|
144
|
+
tours: z.array(TourLinkSchema),
|
|
145
|
+
document_notes: z.array(z.object({
|
|
146
|
+
upload_id: z.string(),
|
|
147
|
+
notes: z.string()
|
|
148
|
+
})),
|
|
149
|
+
documents: z.array(DocumentSchema),
|
|
150
|
+
contacts: z.array(ContactCardSchema),
|
|
151
|
+
comparables: z.array(ComparableSchema)
|
|
152
|
+
});
|
|
153
|
+
const PlannerUnitSchema = z.object({
|
|
154
|
+
label: z.string().nullable(),
|
|
155
|
+
beds: z.number().int(),
|
|
156
|
+
baths: z.number(),
|
|
157
|
+
sqft: z.number().int().nullable(),
|
|
158
|
+
price: z.string().nullable().default(null)
|
|
159
|
+
});
|
|
160
|
+
const PlannerViewSchema = z.object({
|
|
161
|
+
address: AddressSchema,
|
|
162
|
+
lat: z.number().nullable(),
|
|
163
|
+
lon: z.number().nullable(),
|
|
164
|
+
property_type: PropertyTypeSchema,
|
|
165
|
+
listing_intent: ListingIntentSchema,
|
|
166
|
+
units: z.array(PlannerUnitSchema),
|
|
167
|
+
narrative: NarrativeSchema,
|
|
168
|
+
document_notes: z.array(z.object({
|
|
169
|
+
upload_id: z.string(),
|
|
170
|
+
notes: z.string()
|
|
171
|
+
})),
|
|
172
|
+
photo_count: z.number().int(),
|
|
173
|
+
floor_plan_count: z.number().int(),
|
|
174
|
+
units_with_floor_plans_count: z.number().int(),
|
|
175
|
+
has_tour_3d: z.boolean(),
|
|
176
|
+
has_video: z.boolean(),
|
|
177
|
+
comparable_count: z.number().int()
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
//#endregion
|
|
181
|
+
export { VideoSchema as C, UnitSchema as S, PropertyFactsSchema as _, ComparableSchema as a, TourLinkSchema as b, DocumentSchema as c, ListingIntentSchema as f, PlannerUnitSchema as h, ComparablePricePeriodSchema as i, FloorPlanSchema as l, PhotoSchema as m, COMPARABLE_PRICE_PERIODS as n, ComparableStatusSchema as o, NarrativeSchema as p, COMPARABLE_STATUSES as r, ContactCardSchema as s, AddressSchema as t, FloorPlanUnitAssignmentSchema as u, PropertyTypeSchema as v, UnitFloorPlanRefSchema as x };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { plannerForField } from "../../fill-vocabulary/dist/row-planners.js";
|
|
2
|
+
|
|
3
|
+
//#region ../../internal/section-contracts/dist/cap-contract.js
|
|
4
|
+
function generatesText(node) {
|
|
5
|
+
if (node.type === "list-fill") return node.mode === "extract" || node.mode === void 0;
|
|
6
|
+
return node.type === "text-block";
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Where the character budget for the value filling this slot is declared, and
|
|
10
|
+
* what to call it in a message. A `text` slot declares its own; a scalar `list`
|
|
11
|
+
* writes ITEMS, so the element that holds an item declares it. Everything else —
|
|
12
|
+
* a select vocabulary, a record list, media, a POI — fills a value with no
|
|
13
|
+
* character budget at all, which is what makes this rule a no-op for it.
|
|
14
|
+
*/
|
|
15
|
+
function capHolder(slot) {
|
|
16
|
+
if (slot.fields !== void 0) return null;
|
|
17
|
+
const planner = plannerForField(slot);
|
|
18
|
+
if (planner === "text") return {
|
|
19
|
+
holder: slot,
|
|
20
|
+
suffix: ""
|
|
21
|
+
};
|
|
22
|
+
if (planner === "list") return {
|
|
23
|
+
holder: slot.element ?? {},
|
|
24
|
+
suffix: "'s element"
|
|
25
|
+
};
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
function checkAgainstSlot(node, slot, where, decisionId, sectionKey) {
|
|
29
|
+
if (slot === void 0 || !generatesText(node)) return;
|
|
30
|
+
const resolved = capHolder(slot);
|
|
31
|
+
if (resolved === null) return;
|
|
32
|
+
const label = `${where}${resolved.suffix}`;
|
|
33
|
+
const slotCap = resolved.holder.cap;
|
|
34
|
+
if (slotCap === void 0) throw new Error(`Section "${sectionKey}": decision "${decisionId}" fills ${label}, which declares no \`cap\` — a filled text slot must state its own character budget, and the decision inherits it.`);
|
|
35
|
+
if (node.cap === void 0) return;
|
|
36
|
+
if (node.cap > slotCap) throw new Error(`Section "${sectionKey}": decision "${decisionId}" asks for up to ${node.cap} chars but ${label} holds ${slotCap} — the overrun is trimmed away at fill time. Drop the decision's \`cap\`, or raise the slot's.`);
|
|
37
|
+
if (node.cap === slotCap) throw new Error(`Section "${sectionKey}": decision "${decisionId}" restates ${label}'s cap of ${slotCap}. Drop the decision's \`cap\` — it inherits the slot's; state one only to ask for something strictly shorter.`);
|
|
38
|
+
}
|
|
39
|
+
function checkNode(node, slot, slotId, field, decisionId, sectionKey) {
|
|
40
|
+
checkAgainstSlot(node, slot, field === void 0 ? `slot "${slotId}"` : `inner slot "${field}" of "${slotId}"`, decisionId, sectionKey);
|
|
41
|
+
for (const [planned, plan] of Object.entries(node.fields ?? {})) {
|
|
42
|
+
const rowField = slot?.fields?.[planned];
|
|
43
|
+
if (!rowField) continue;
|
|
44
|
+
checkNode(plan, rowField, slotId, planned, decisionId, sectionKey);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Rejects a fill-side character cap that is not strictly lower than the slot's,
|
|
49
|
+
* and a filled text slot or list element that declares no cap at all. Throws on
|
|
50
|
+
* the first violation; mirrors assertCountBoundsContract in signature and
|
|
51
|
+
* error-message style.
|
|
52
|
+
*/
|
|
53
|
+
function assertCapContract(schema, decision, sectionKey) {
|
|
54
|
+
const node = decision;
|
|
55
|
+
for (const slotId of decision.produces) checkNode(node, schema.slots[slotId], slotId, void 0, decision.id, sectionKey);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
//#endregion
|
|
59
|
+
export { assertCapContract };
|