@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,76 @@
|
|
|
1
|
+
import { isSection } from "./section.js";
|
|
2
|
+
import { readdirSync } from "node:fs";
|
|
3
|
+
import { join, relative, sep } from "node:path";
|
|
4
|
+
import { pathToFileURL } from "node:url";
|
|
5
|
+
|
|
6
|
+
//#region src/section/discovery.ts
|
|
7
|
+
const MODULE_FILE = /\.(?:[cm]?[jt]s|[jt]sx)$/;
|
|
8
|
+
const SKIPPED_FILE = /\.test\.[^/]+$|\.d\.[cm]?ts$/;
|
|
9
|
+
const SKIPPED_DIRS = /* @__PURE__ */ new Set([
|
|
10
|
+
"node_modules",
|
|
11
|
+
"dist",
|
|
12
|
+
".concrete"
|
|
13
|
+
]);
|
|
14
|
+
/** Two distinct section values under one key: the key is the platform identity. */
|
|
15
|
+
var DuplicateSectionKeyError = class extends Error {
|
|
16
|
+
key;
|
|
17
|
+
first;
|
|
18
|
+
second;
|
|
19
|
+
constructor(key, first, second) {
|
|
20
|
+
super(`Two sections declare key "${key}": ${first.module} (${first.exportName}) and ${second.module} (${second.exportName}).`);
|
|
21
|
+
this.key = key;
|
|
22
|
+
this.first = first;
|
|
23
|
+
this.second = second;
|
|
24
|
+
this.name = "DuplicateSectionKeyError";
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
/** The workspace's modules in discovery order, absolute paths: what discovery imports and `check` loads. */
|
|
28
|
+
function listModules(root) {
|
|
29
|
+
const out = [];
|
|
30
|
+
const walk = (dir, depth) => {
|
|
31
|
+
const entries = readdirSync(dir, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name));
|
|
32
|
+
for (const entry of entries) {
|
|
33
|
+
if (entry.name.startsWith(".")) continue;
|
|
34
|
+
const path = join(dir, entry.name);
|
|
35
|
+
if (entry.isDirectory()) {
|
|
36
|
+
if (SKIPPED_DIRS.has(entry.name) || depth === 0 && entry.name === "fixtures") continue;
|
|
37
|
+
walk(path, depth + 1);
|
|
38
|
+
} else if (entry.isFile() && MODULE_FILE.test(entry.name) && !SKIPPED_FILE.test(entry.name)) out.push(path);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
walk(root, 0);
|
|
42
|
+
return out;
|
|
43
|
+
}
|
|
44
|
+
async function defaultImport(file) {
|
|
45
|
+
return await import(pathToFileURL(file).href);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Enumerate the workspace's modules and collect every exported section value. Two
|
|
49
|
+
* DISTINCT sections declaring one key is an error — the key is the platform identity,
|
|
50
|
+
* and two values cannot share it.
|
|
51
|
+
*/
|
|
52
|
+
async function discoverSections(options) {
|
|
53
|
+
const importModule = options.importModule ?? defaultImport;
|
|
54
|
+
const found = [];
|
|
55
|
+
const byKey = /* @__PURE__ */ new Map();
|
|
56
|
+
for (const file of listModules(options.root)) {
|
|
57
|
+
const module = relative(options.root, file).split(sep).join("/");
|
|
58
|
+
const exports = await importModule(file);
|
|
59
|
+
for (const [exportName, value] of Object.entries(exports)) {
|
|
60
|
+
if (!isSection(value)) continue;
|
|
61
|
+
const entry = {
|
|
62
|
+
section: value,
|
|
63
|
+
module,
|
|
64
|
+
exportName
|
|
65
|
+
};
|
|
66
|
+
found.push(entry);
|
|
67
|
+
const prior = byKey.get(value.key);
|
|
68
|
+
if (prior === void 0) byKey.set(value.key, entry);
|
|
69
|
+
else if (prior.section !== value) throw new DuplicateSectionKeyError(value.key, prior, entry);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return found;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
//#endregion
|
|
76
|
+
export { DuplicateSectionKeyError, discoverSections, listModules };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { ProbeContext } from "../primitives/probe-context.js";
|
|
2
|
+
import { defaultForSlotType } from "../schema/slot-types.js";
|
|
3
|
+
import { previewAnchors, previewPages } from "../schema/section-nav.js";
|
|
4
|
+
import { createElement } from "react";
|
|
5
|
+
import { renderToStaticMarkup } from "react-dom/server";
|
|
6
|
+
|
|
7
|
+
//#region src/section/groups.ts
|
|
8
|
+
/** A group derivation check error, carrying which fault it is so `check` can name its rule. */
|
|
9
|
+
var GroupDerivationError = class extends Error {
|
|
10
|
+
fault;
|
|
11
|
+
constructor(fault, message) {
|
|
12
|
+
super(message);
|
|
13
|
+
this.fault = fault;
|
|
14
|
+
this.name = "GroupDerivationError";
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Derive a section's `groups` by rendering it under the groups probe over the blank
|
|
19
|
+
* state plus every `states` entry, for every declared variant case. Throws the check
|
|
20
|
+
* errors named above; returns `[]` for a section that declares no card.
|
|
21
|
+
*/
|
|
22
|
+
function deriveGroups(section, states = []) {
|
|
23
|
+
const { key, schema } = section;
|
|
24
|
+
const slotIds = Object.keys(schema.slots);
|
|
25
|
+
const blank = {};
|
|
26
|
+
for (const [id, def] of Object.entries(schema.slots)) blank[id] = defaultForSlotType(def.type);
|
|
27
|
+
const cases = schema.meta.display?.variant?.cases ?? [""];
|
|
28
|
+
const labels = /* @__PURE__ */ new Map();
|
|
29
|
+
const cardsOf = /* @__PURE__ */ new Map();
|
|
30
|
+
const probe = {
|
|
31
|
+
kind: "groups",
|
|
32
|
+
group(id, label) {
|
|
33
|
+
const prior = labels.get(id);
|
|
34
|
+
if (prior !== void 0 && prior !== label) throw new GroupDerivationError("label-conflict", `Section "${key}": group "${id}" is labeled both "${prior}" and "${label}".`);
|
|
35
|
+
labels.set(id, label);
|
|
36
|
+
},
|
|
37
|
+
member(slotId, groupId) {
|
|
38
|
+
let cards = cardsOf.get(slotId);
|
|
39
|
+
if (cards === void 0) cardsOf.set(slotId, cards = /* @__PURE__ */ new Set());
|
|
40
|
+
cards.add(groupId);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
const nav = {
|
|
44
|
+
selfAnchor: key,
|
|
45
|
+
anchors: previewAnchors(),
|
|
46
|
+
pages: previewPages()
|
|
47
|
+
};
|
|
48
|
+
const Component = section;
|
|
49
|
+
for (const state of [blank, ...states]) for (const variant of cases) renderToStaticMarkup(createElement(ProbeContext.Provider, { value: probe }, createElement(Component, {
|
|
50
|
+
slots: state,
|
|
51
|
+
nav,
|
|
52
|
+
variant
|
|
53
|
+
})));
|
|
54
|
+
for (const [slotId, cards] of cardsOf) if (cards.size > 1) {
|
|
55
|
+
const [a, b] = [...cards].sort();
|
|
56
|
+
throw new GroupDerivationError("slot-in-two-groups", `Section "${key}": slot "${slotId}" is rendered in two groups, "${a}" and "${b}".`);
|
|
57
|
+
}
|
|
58
|
+
const groups = [];
|
|
59
|
+
for (const [id, label] of labels) {
|
|
60
|
+
const members = slotIds.filter((slotId) => cardsOf.get(slotId)?.has(id) === true);
|
|
61
|
+
if (members.length === 0) throw new GroupDerivationError("empty", `Section "${key}": group "${id}" holds no slot in any state — a card with nothing in it.`);
|
|
62
|
+
groups.push({
|
|
63
|
+
id,
|
|
64
|
+
label,
|
|
65
|
+
members
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
const position = (group) => slotIds.indexOf(group.members[0]);
|
|
69
|
+
groups.sort((a, b) => position(a) - position(b));
|
|
70
|
+
return groups;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
//#endregion
|
|
74
|
+
export { GroupDerivationError, deriveGroups };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { COMPUTED, getComputed } from "../schema/compute.js";
|
|
2
|
+
import { deriveGroups } from "./groups.js";
|
|
3
|
+
|
|
4
|
+
//#region src/section/materialize.ts
|
|
5
|
+
/**
|
|
6
|
+
* Materialize a section: derive its groups over `states` (the blank state is always
|
|
7
|
+
* included) and freeze its slot order. The result parses with `SectionSchema` and
|
|
8
|
+
* feeds `fillSpecFromSchema` exactly as a `defineSchema` result does today.
|
|
9
|
+
*/
|
|
10
|
+
function materializeSection(section, states = []) {
|
|
11
|
+
const groups = deriveGroups(section, states);
|
|
12
|
+
const result = {
|
|
13
|
+
meta: {
|
|
14
|
+
...section.schema.meta,
|
|
15
|
+
...groups.length > 0 ? { groups } : {}
|
|
16
|
+
},
|
|
17
|
+
slots: section.schema.slots,
|
|
18
|
+
slot_order: Object.keys(section.schema.slots)
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(result, COMPUTED, {
|
|
21
|
+
value: getComputed(section.schema),
|
|
22
|
+
enumerable: false
|
|
23
|
+
});
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
export { materializeSection };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ProbeContext } from "../primitives/probe-context.js";
|
|
2
|
+
import { createElement } from "react";
|
|
3
|
+
import { renderToStaticMarkup } from "react-dom/server";
|
|
4
|
+
|
|
5
|
+
//#region src/section/placements.ts
|
|
6
|
+
/**
|
|
7
|
+
* Render `node` once under the placement probe. Returns the placements in order and
|
|
8
|
+
* whatever markup the node emitted besides them.
|
|
9
|
+
*/
|
|
10
|
+
function recordPlacements(node) {
|
|
11
|
+
const placements = [];
|
|
12
|
+
return {
|
|
13
|
+
placements,
|
|
14
|
+
markup: renderToStaticMarkup(createElement(ProbeContext.Provider, { value: {
|
|
15
|
+
kind: "placement",
|
|
16
|
+
place(key, instance, section) {
|
|
17
|
+
placements.push({
|
|
18
|
+
key,
|
|
19
|
+
instance,
|
|
20
|
+
section
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
} }, node))
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
export { recordPlacements };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { SectionNav } from "../schema/section-nav.js";
|
|
2
|
+
import { Slot } from "../schema/slot-types.js";
|
|
3
|
+
import "../schema/section-schema.js";
|
|
4
|
+
import { SectionProps } from "../schema/section-props.js";
|
|
5
|
+
import { SlotBindingMap } from "../primitives/slot-bindings.js";
|
|
6
|
+
import { DisplayInput } from "../schema/define-schema.js";
|
|
7
|
+
import { SectionOptions, SectionSchemaOf, SlotRef, SlotRefsOf } from "./declare.js";
|
|
8
|
+
import { ReactNode } from "react";
|
|
9
|
+
//#region src/section/section.d.ts
|
|
10
|
+
/** The contract props the platform renders a section with: `{ slots, nav, variant }`. */
|
|
11
|
+
type SectionContractProps<Slots extends Record<string, Slot>, Display extends DisplayInput> = SectionProps<SectionSchemaOf<Slots, Display>>;
|
|
12
|
+
/** The props a section takes when PLACED on a page. */
|
|
13
|
+
interface SectionPlacementProps {
|
|
14
|
+
/** The instance id, when a template places this section more than once. Defaults to `<key>-1`. */
|
|
15
|
+
readonly instance?: string;
|
|
16
|
+
}
|
|
17
|
+
/** What the render function receives: bindings, not raw values. */
|
|
18
|
+
interface SectionRenderBindings<Slots extends Record<string, Slot>, Display extends DisplayInput> {
|
|
19
|
+
/** One binding per declared slot, keyed by slot id — what `bindSlots` returned to a Renderer. */
|
|
20
|
+
readonly slot: SlotBindingMap<SectionSchemaOf<Slots, Display>>;
|
|
21
|
+
/** The build-injected navigation input: this section's anchor, the anchor map, the pages. */
|
|
22
|
+
readonly nav: SectionNav;
|
|
23
|
+
/** The stored variant case — the union of the declared cases, or `string` when none. */
|
|
24
|
+
readonly variant: SectionContractProps<Slots, Display>["variant"];
|
|
25
|
+
}
|
|
26
|
+
declare const SECTION: unique symbol;
|
|
27
|
+
/**
|
|
28
|
+
* The value {@link section} returns: a React component taking the contract props (or,
|
|
29
|
+
* placed on a page, an optional `instance`), carrying its `key`, `label`, `required`,
|
|
30
|
+
* its materializable `schema`, and one {@link SlotRef} per slot (`Hero.slots.hero_image`)
|
|
31
|
+
* for reconcile rules.
|
|
32
|
+
*/
|
|
33
|
+
interface SectionValue<Key extends string, Slots extends Record<string, Slot>, Display extends DisplayInput> {
|
|
34
|
+
(props: SectionContractProps<Slots, Display> | SectionPlacementProps): ReactNode;
|
|
35
|
+
readonly key: Key;
|
|
36
|
+
readonly label: string;
|
|
37
|
+
readonly required: boolean;
|
|
38
|
+
readonly schema: SectionSchemaOf<Slots, Display>;
|
|
39
|
+
readonly slots: SlotRefsOf<Key, Slots>;
|
|
40
|
+
readonly [SECTION]: true;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Declare a section: its schema and its markup in one exported value.
|
|
44
|
+
*
|
|
45
|
+
* ```tsx
|
|
46
|
+
* export const Hero = section({
|
|
47
|
+
* key: "hero",
|
|
48
|
+
* label: "Hero",
|
|
49
|
+
* slots: {
|
|
50
|
+
* headline: text.medium({ cap: 60, label: "Headline", fill: textBlock({ … }) }),
|
|
51
|
+
* street: text.short({ source: fact.property.address_street, label: "Street" }),
|
|
52
|
+
* },
|
|
53
|
+
* }, ({ slot, nav }) => (
|
|
54
|
+
* <Section id={nav.selfAnchor}>
|
|
55
|
+
* <Slot.Text slot={slot.headline} as="h1" />
|
|
56
|
+
* <SlotGroup id="address" label="Property address">
|
|
57
|
+
* <Slot.Text slot={slot.street} as="span" />
|
|
58
|
+
* </SlotGroup>
|
|
59
|
+
* </Section>
|
|
60
|
+
* ));
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* The returned component is what a page places (`<Hero />`) and what the platform
|
|
64
|
+
* renders with `{ slots, nav, variant }`. `render` receives bindings: `slot.<id>` is
|
|
65
|
+
* typed by that slot's own declaration, and `variant` by the declared cases.
|
|
66
|
+
*/
|
|
67
|
+
declare function section<const Key extends string, const Slots extends Record<string, Slot>, const Display extends DisplayInput = Record<string, never>>(options: SectionOptions<Key, Slots, Display>, render: (bindings: SectionRenderBindings<Slots, Display>) => ReactNode): SectionValue<Key, Slots, Display>;
|
|
68
|
+
//#endregion
|
|
69
|
+
export { SectionContractProps, type SectionOptions, SectionPlacementProps, SectionRenderBindings, SectionValue, type SlotRef, section };
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { ProbeContext } from "../primitives/probe-context.js";
|
|
2
|
+
import { bindSlots } from "../primitives/slot-bindings.js";
|
|
3
|
+
import { declareSection } from "./declare.js";
|
|
4
|
+
import { useContext } from "react";
|
|
5
|
+
|
|
6
|
+
//#region src/section/section.tsx
|
|
7
|
+
const SECTION = Symbol("@homepages/concrete/section");
|
|
8
|
+
const declared = /* @__PURE__ */ new Map();
|
|
9
|
+
function callerModule() {
|
|
10
|
+
const stack = (/* @__PURE__ */ new Error()).stack;
|
|
11
|
+
if (typeof stack !== "string") return void 0;
|
|
12
|
+
for (const line of stack.split("\n").slice(1)) {
|
|
13
|
+
const match = /((?:file:\/\/)?\/[^\s()]+?):\d+:\d+\)?\s*$/.exec(line);
|
|
14
|
+
if (match === null) continue;
|
|
15
|
+
const file = match[1] ?? "";
|
|
16
|
+
if (/\/section\/section\.(?:tsx?|m?js)$/.test(file)) continue;
|
|
17
|
+
return file.startsWith("file://") ? decodeURIComponent(file.slice(7)) : file;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Declare a section: its schema and its markup in one exported value.
|
|
22
|
+
*
|
|
23
|
+
* ```tsx
|
|
24
|
+
* export const Hero = section({
|
|
25
|
+
* key: "hero",
|
|
26
|
+
* label: "Hero",
|
|
27
|
+
* slots: {
|
|
28
|
+
* headline: text.medium({ cap: 60, label: "Headline", fill: textBlock({ … }) }),
|
|
29
|
+
* street: text.short({ source: fact.property.address_street, label: "Street" }),
|
|
30
|
+
* },
|
|
31
|
+
* }, ({ slot, nav }) => (
|
|
32
|
+
* <Section id={nav.selfAnchor}>
|
|
33
|
+
* <Slot.Text slot={slot.headline} as="h1" />
|
|
34
|
+
* <SlotGroup id="address" label="Property address">
|
|
35
|
+
* <Slot.Text slot={slot.street} as="span" />
|
|
36
|
+
* </SlotGroup>
|
|
37
|
+
* </Section>
|
|
38
|
+
* ));
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* The returned component is what a page places (`<Hero />`) and what the platform
|
|
42
|
+
* renders with `{ slots, nav, variant }`. `render` receives bindings: `slot.<id>` is
|
|
43
|
+
* typed by that slot's own declaration, and `variant` by the declared cases.
|
|
44
|
+
*/
|
|
45
|
+
function section(options, render) {
|
|
46
|
+
const { key, label, required, schema, slots } = declareSection(options);
|
|
47
|
+
const component = (props) => {
|
|
48
|
+
const probe = useContext(ProbeContext);
|
|
49
|
+
if (probe?.kind === "placement") {
|
|
50
|
+
const instance = "instance" in props && props.instance !== void 0 ? props.instance : `${key}-1`;
|
|
51
|
+
probe.place(key, instance, value);
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
if (!("slots" in props)) throw new Error(`Section "${key}" was rendered with no slot values. A section renders through the platform, a fixture, or a probe — never bare; on a page, place it (\`<${label.replace(/\s+/g, "")} />\`) and let the page probe read it.`);
|
|
55
|
+
return render({
|
|
56
|
+
slot: bindSlots(schema, props.slots),
|
|
57
|
+
nav: props.nav,
|
|
58
|
+
variant: props.variant
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
const value = Object.defineProperties(component, {
|
|
62
|
+
displayName: {
|
|
63
|
+
value: `section(${key})`,
|
|
64
|
+
configurable: true
|
|
65
|
+
},
|
|
66
|
+
key: {
|
|
67
|
+
value: key,
|
|
68
|
+
enumerable: true
|
|
69
|
+
},
|
|
70
|
+
label: {
|
|
71
|
+
value: label,
|
|
72
|
+
enumerable: true
|
|
73
|
+
},
|
|
74
|
+
required: {
|
|
75
|
+
value: required,
|
|
76
|
+
enumerable: true
|
|
77
|
+
},
|
|
78
|
+
schema: {
|
|
79
|
+
value: schema,
|
|
80
|
+
enumerable: true
|
|
81
|
+
},
|
|
82
|
+
slots: {
|
|
83
|
+
value: slots,
|
|
84
|
+
enumerable: true
|
|
85
|
+
},
|
|
86
|
+
[SECTION]: { value: true }
|
|
87
|
+
});
|
|
88
|
+
declared.set(value, { module: callerModule() });
|
|
89
|
+
return value;
|
|
90
|
+
}
|
|
91
|
+
/** Is this export a section value? What discovery asks of every export of every module. */
|
|
92
|
+
function isSection(value) {
|
|
93
|
+
return typeof value === "function" && value[SECTION] === true;
|
|
94
|
+
}
|
|
95
|
+
/** The module that declared a section, when the runtime's stack frames named it. */
|
|
96
|
+
function declaringModule(section) {
|
|
97
|
+
return declared.get(section)?.module;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
//#endregion
|
|
101
|
+
export { declaringModule, isSection, section };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { initAnalytics } from "./site-runtime/analytics.js";
|
|
2
|
+
import { initSiteIntegrations } from "./site-runtime/site-integrations.js";
|
|
3
|
+
|
|
4
|
+
//#region src/site-runtime/analytics-entry.ts
|
|
5
|
+
if (typeof window !== "undefined") {
|
|
6
|
+
const run = () => {
|
|
7
|
+
for (const init of [initAnalytics, initSiteIntegrations]) try {
|
|
8
|
+
init();
|
|
9
|
+
} catch {}
|
|
10
|
+
};
|
|
11
|
+
if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", run, { once: true });
|
|
12
|
+
else run();
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { readSiteConfig, signedIngestHeaders } from "../browser/site-config.js";
|
|
2
|
+
|
|
3
|
+
//#region src/site-runtime/analytics.ts
|
|
4
|
+
const __analyticsTestHooks = {};
|
|
5
|
+
function sendEvents(cfg, events) {
|
|
6
|
+
const body = JSON.stringify({ events });
|
|
7
|
+
__analyticsTestHooks.lastSend = (async () => {
|
|
8
|
+
const headers = await signedIngestHeaders(cfg, body);
|
|
9
|
+
await fetch(`${cfg.ingestBase}/analytics/ingest`, {
|
|
10
|
+
method: "POST",
|
|
11
|
+
headers,
|
|
12
|
+
body,
|
|
13
|
+
keepalive: true
|
|
14
|
+
});
|
|
15
|
+
})().catch(() => {});
|
|
16
|
+
}
|
|
17
|
+
function initAnalytics() {
|
|
18
|
+
const cfg = readSiteConfig();
|
|
19
|
+
if (!cfg) return;
|
|
20
|
+
const config = cfg;
|
|
21
|
+
sendEvents(config, [{
|
|
22
|
+
kind: "page_view",
|
|
23
|
+
path: location.pathname,
|
|
24
|
+
query: location.search,
|
|
25
|
+
referrer: document.referrer || null,
|
|
26
|
+
host: location.host
|
|
27
|
+
}]);
|
|
28
|
+
const startMs = Date.now();
|
|
29
|
+
let maxScrollPct = 0;
|
|
30
|
+
let engagementSent = false;
|
|
31
|
+
let iframeTracked = false;
|
|
32
|
+
let formTracked = false;
|
|
33
|
+
function recordScroll() {
|
|
34
|
+
const total = document.documentElement.scrollHeight;
|
|
35
|
+
if (total <= 0) return;
|
|
36
|
+
const seen = Math.min((window.scrollY + window.innerHeight) / total, 1) * 100;
|
|
37
|
+
if (seen > maxScrollPct) maxScrollPct = seen;
|
|
38
|
+
}
|
|
39
|
+
document.addEventListener("scroll", recordScroll, { passive: true });
|
|
40
|
+
recordScroll();
|
|
41
|
+
function flushEngagement() {
|
|
42
|
+
if (engagementSent) return;
|
|
43
|
+
engagementSent = true;
|
|
44
|
+
sendEvents(config, [{
|
|
45
|
+
kind: "engagement",
|
|
46
|
+
path: location.pathname,
|
|
47
|
+
dwell_ms: Date.now() - startMs,
|
|
48
|
+
scroll_pct: Math.round(maxScrollPct)
|
|
49
|
+
}]);
|
|
50
|
+
}
|
|
51
|
+
document.addEventListener("visibilitychange", () => {
|
|
52
|
+
if (document.visibilityState === "hidden") flushEngagement();
|
|
53
|
+
});
|
|
54
|
+
window.addEventListener("pagehide", flushEngagement);
|
|
55
|
+
document.addEventListener("click", (clickEvent) => {
|
|
56
|
+
const anchor = clickEvent.target?.closest?.("a[href]");
|
|
57
|
+
if (!anchor) return;
|
|
58
|
+
const href = anchor.getAttribute("href") ?? "";
|
|
59
|
+
if (href.startsWith("tel:")) sendEvents(config, [{
|
|
60
|
+
kind: "click",
|
|
61
|
+
path: location.pathname,
|
|
62
|
+
target: "phone"
|
|
63
|
+
}]);
|
|
64
|
+
else if (href.startsWith("mailto:")) sendEvents(config, [{
|
|
65
|
+
kind: "click",
|
|
66
|
+
path: location.pathname,
|
|
67
|
+
target: "email"
|
|
68
|
+
}]);
|
|
69
|
+
});
|
|
70
|
+
document.addEventListener("focusin", (focusEvent) => {
|
|
71
|
+
if (formTracked) return;
|
|
72
|
+
if (focusEvent.target?.closest?.("[data-tr-lead-form]")) {
|
|
73
|
+
formTracked = true;
|
|
74
|
+
sendEvents(config, [{
|
|
75
|
+
kind: "click",
|
|
76
|
+
path: location.pathname,
|
|
77
|
+
target: "contact_form_open"
|
|
78
|
+
}]);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
window.addEventListener("blur", () => {
|
|
82
|
+
if (iframeTracked) return;
|
|
83
|
+
const active = document.activeElement;
|
|
84
|
+
if (!active || active.tagName !== "IFRAME") return;
|
|
85
|
+
const target = active.closest?.("[data-slot-id=\"tour_url\"]") ? "tour_3d" : active.closest?.("[data-slot-id=\"video_url\"]") ? "video" : null;
|
|
86
|
+
if (!target) return;
|
|
87
|
+
iframeTracked = true;
|
|
88
|
+
sendEvents(config, [{
|
|
89
|
+
kind: "click",
|
|
90
|
+
path: location.pathname,
|
|
91
|
+
target
|
|
92
|
+
}]);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
//#endregion
|
|
97
|
+
export { __analyticsTestHooks, initAnalytics };
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { readSiteConfig } from "../browser/site-config.js";
|
|
2
|
+
import { LEAD_EVENT } from "../browser/submit-lead.js";
|
|
3
|
+
|
|
4
|
+
//#region src/site-runtime/site-integrations.ts
|
|
5
|
+
const QUEUE_NAME = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
|
|
6
|
+
const PLACEHOLDER = /^\{lead\.([A-Za-z_]+)\}$/;
|
|
7
|
+
const __siteIntegrationsTestHooks = {};
|
|
8
|
+
function isRecord(value) {
|
|
9
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
10
|
+
}
|
|
11
|
+
function parseManifest(raw) {
|
|
12
|
+
const manifest = {
|
|
13
|
+
scripts: [],
|
|
14
|
+
lead: []
|
|
15
|
+
};
|
|
16
|
+
if (!isRecord(raw)) return manifest;
|
|
17
|
+
if (Array.isArray(raw.scripts)) {
|
|
18
|
+
for (const script of raw.scripts) if (isRecord(script) && typeof script.src === "string" && typeof script.async === "boolean") manifest.scripts.push({
|
|
19
|
+
src: script.src,
|
|
20
|
+
async: script.async
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
const lead = isRecord(raw.on) ? raw.on.lead : void 0;
|
|
24
|
+
if (Array.isArray(lead)) {
|
|
25
|
+
for (const binding of lead) if (isRecord(binding) && typeof binding.queue === "string" && QUEUE_NAME.test(binding.queue) && Array.isArray(binding.push)) manifest.lead.push({
|
|
26
|
+
queue: binding.queue,
|
|
27
|
+
push: binding.push
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
return manifest;
|
|
31
|
+
}
|
|
32
|
+
function appendScript(script) {
|
|
33
|
+
let url;
|
|
34
|
+
try {
|
|
35
|
+
url = new URL(script.src);
|
|
36
|
+
} catch {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (url.protocol !== "https:") return;
|
|
40
|
+
const element = document.createElement("script");
|
|
41
|
+
element.src = url.href;
|
|
42
|
+
element.async = script.async;
|
|
43
|
+
document.head.appendChild(element);
|
|
44
|
+
}
|
|
45
|
+
function fill(value, detail) {
|
|
46
|
+
if (typeof value === "string") {
|
|
47
|
+
const key = PLACEHOLDER.exec(value)?.[1];
|
|
48
|
+
if (key === void 0) return value;
|
|
49
|
+
const filled = detail[key];
|
|
50
|
+
return typeof filled === "string" ? filled : null;
|
|
51
|
+
}
|
|
52
|
+
if (Array.isArray(value)) return value.map((entry) => fill(entry, detail));
|
|
53
|
+
if (isRecord(value)) return Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, fill(entry, detail)]));
|
|
54
|
+
return value;
|
|
55
|
+
}
|
|
56
|
+
function queueNamed(name) {
|
|
57
|
+
const globals = window;
|
|
58
|
+
if (globals[name] === void 0) globals[name] = [];
|
|
59
|
+
const queue = globals[name];
|
|
60
|
+
return typeof queue?.push === "function" ? queue : null;
|
|
61
|
+
}
|
|
62
|
+
function fire(bindings, detail) {
|
|
63
|
+
for (const binding of bindings) try {
|
|
64
|
+
const queue = queueNamed(binding.queue);
|
|
65
|
+
if (!queue) continue;
|
|
66
|
+
for (const entry of binding.push) queue.push(fill(entry, detail));
|
|
67
|
+
} catch {}
|
|
68
|
+
}
|
|
69
|
+
function initSiteIntegrations() {
|
|
70
|
+
const cfg = readSiteConfig();
|
|
71
|
+
if (!cfg) return;
|
|
72
|
+
let bindings = null;
|
|
73
|
+
const pending = [];
|
|
74
|
+
window.addEventListener(LEAD_EVENT, (event) => {
|
|
75
|
+
const detail = event.detail;
|
|
76
|
+
if (!isRecord(detail) || typeof detail.email !== "string") return;
|
|
77
|
+
if (bindings) fire(bindings, detail);
|
|
78
|
+
else pending.push(detail);
|
|
79
|
+
});
|
|
80
|
+
const url = `${cfg.ingestBase}/public/site-integrations/${encodeURIComponent(cfg.siteId)}`;
|
|
81
|
+
__siteIntegrationsTestHooks.applied = (async () => {
|
|
82
|
+
let manifest = {
|
|
83
|
+
scripts: [],
|
|
84
|
+
lead: []
|
|
85
|
+
};
|
|
86
|
+
try {
|
|
87
|
+
const response = await fetch(url, { credentials: "omit" });
|
|
88
|
+
if (response.ok) manifest = parseManifest(await response.json());
|
|
89
|
+
for (const script of manifest.scripts) appendScript(script);
|
|
90
|
+
} catch {}
|
|
91
|
+
bindings = manifest.lead;
|
|
92
|
+
for (const detail of pending.splice(0)) fire(bindings, detail);
|
|
93
|
+
})();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
//#endregion
|
|
97
|
+
export { __siteIntegrationsTestHooks, initSiteIntegrations };
|
package/dist/styles.css
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @homepages/concrete — the global Tailwind preamble.
|
|
3
|
+
*
|
|
4
|
+
* Import this AFTER `@import "tailwindcss";` in the first stylesheet template.ts imports
|
|
5
|
+
* (by convention globals.css), and declare your own tokens after it:
|
|
6
|
+
*
|
|
7
|
+
* @import "tailwindcss";
|
|
8
|
+
* @import "@homepages/concrete/styles.css";
|
|
9
|
+
* @theme { --color-ink: #1b1b1b; }
|
|
10
|
+
*
|
|
11
|
+
* This file must NOT import Tailwind itself. Exactly one `@import "tailwindcss"` may
|
|
12
|
+
* exist per build graph — your entry owns it. Two double-emit Tailwind's preflight
|
|
13
|
+
* reset (box-sizing declared twice, ~4 KB of duplicate base layer).
|
|
14
|
+
*
|
|
15
|
+
* WHAT IS HERE: only what is true of EVERY template — the spacing base unit and the
|
|
16
|
+
* motion defaults.
|
|
17
|
+
*
|
|
18
|
+
* WHAT IS NOT: your design tokens. Colors, fonts, type, radii and shadows are yours.
|
|
19
|
+
* Declare them with `@theme` in your own CSS under names you choose, and Tailwind turns
|
|
20
|
+
* each one into a utility (`--color-ink` yields `text-ink`). Nothing about
|
|
21
|
+
* your visual system is shared, and there is no global file for you to edit to make a
|
|
22
|
+
* token of yours usable.
|
|
23
|
+
*
|
|
24
|
+
* The @source below resolves relative to THIS FILE'S SHIPPED LOCATION (dist/styles.css),
|
|
25
|
+
* registering the kit's compiled JS for class scanning — that is how the utility classes
|
|
26
|
+
* baked into the kit's primitives reach your compiled CSS. It also overrides Tailwind's
|
|
27
|
+
* default exclusion of node_modules.
|
|
28
|
+
*
|
|
29
|
+
* It is scoped to `primitives/` because those are the ONLY shipped modules that emit
|
|
30
|
+
* markup. Tailwind's scanner is a plain candidate-extractor — it cannot tell code from a
|
|
31
|
+
* comment — and the kit ships unminified (deliberately: it keeps these class-name string
|
|
32
|
+
* literals scannable). Pointed at all of dist/, it therefore compiled prose out of the
|
|
33
|
+
* CLI's and the ESLint preset's doc comments into every consumer's stylesheet: 8 dead
|
|
34
|
+
* utilities and 19 stray @property registrations, ~2.5 KB. If a primitive ever moves out
|
|
35
|
+
* of primitives/, widen this — an unstyled <Image> in every template is the failure mode,
|
|
36
|
+
* and scripts/verify-consumer.mjs is what catches it.
|
|
37
|
+
*/
|
|
38
|
+
@source "./primitives/**/*.js";
|
|
39
|
+
|
|
40
|
+
/* `@theme inline` so a value is substituted straight into the utilities Tailwind
|
|
41
|
+
* generates (`.gap-2 { gap: .5rem }`), rather than emitted as a `:root` custom property
|
|
42
|
+
* the utilities then read through `var()`. These are fixed global constants, not
|
|
43
|
+
* per-page-overridable tokens, so inlining is both correct and what keeps the compiled
|
|
44
|
+
* output stable. Nothing here may reference a token a template's own CSS defines.
|
|
45
|
+
*
|
|
46
|
+
* NO BREAKPOINTS. The kit declares none and resets none, so Tailwind's own
|
|
47
|
+
* `sm`/`md`/`lg`/`xl`/`2xl` reach a template untouched. Where a design swaps is the
|
|
48
|
+
* template's call, not the platform's: declare your own `--breakpoint-*` tokens in
|
|
49
|
+
* `@theme` (each becomes a variant prefix), or write an arbitrary variant inline. The
|
|
50
|
+
* platform enforces objective defects, never geometry — see the framework principles.
|
|
51
|
+
* `styles.test.ts` fails the build if a breakpoint is ever declared here again. */
|
|
52
|
+
@theme inline {
|
|
53
|
+
/* ---------- Spacing ---------- */
|
|
54
|
+
--spacing: 0.25rem; /* v4 base unit; Tailwind multiplies (e.g. p-4 = 1rem) */
|
|
55
|
+
|
|
56
|
+
/* ---------- Motion ----------
|
|
57
|
+
* The --tr-* values these read are defined in base.css, which every page loads. */
|
|
58
|
+
--default-transition-duration: var(--tr-duration-fast);
|
|
59
|
+
--default-transition-timing-function: var(--tr-ease);
|
|
60
|
+
}
|