@homepages/concrete 1.0.2 → 1.0.3
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 +15 -0
- package/codemods/manifest.json +4 -0
- package/dist/artifact/playground/client/assets/index-CckS2ONm.css +1 -0
- package/dist/artifact/playground/client/assets/{index-JloQyj8h.js → index-Da8V3M7E.js} +105 -105
- package/dist/artifact/playground/client/index.html +2 -2
- package/dist/artifact/playground/host.mjs +20 -20
- package/dist/cli/build/artifact.js +5 -2
- package/dist/cli/build/captures.js +15 -18
- package/dist/cli/build/fixtures.js +11 -3
- package/dist/cli/build/sections.js +13 -4
- package/dist/cli/check/load-workspace.js +6 -1
- package/dist/cli/check/stages/bundles.js +3 -1
- package/dist/cli/commands.js +1 -1
- package/dist/cli/dev/load-template.js +32 -25
- package/dist/cli/dev/server.js +5 -1
- package/dist/cli/dev/vite.js +37 -1
- package/dist/cli/dev/workspace-reader.js +2 -6
- package/dist/cli/media/derive.js +30 -3
- package/dist/cli/media/deriver-plugin.js +6 -2
- package/dist/cli/media/frame-rung-floor.js +18 -0
- package/dist/css/graph.js +2 -1
- package/dist/fixtures/load.js +6 -1
- package/dist/fixtures/media.js +37 -6
- package/dist/fixtures/package-stylesheets.js +59 -0
- package/dist/fixtures/property.js +28 -7
- package/dist/fixtures.d.ts +27 -4
- package/dist/packages/external/concrete/package.js +1 -1
- package/dist/primitives/slot-bindings.d.ts +19 -13
- package/dist/primitives/slot-bindings.js +7 -3
- package/dist/section/section.d.ts +6 -1
- package/guide/reference/cli/build.md +1 -1
- package/package.json +1 -1
- package/dist/artifact/playground/client/assets/index-BSA1yutg.css +0 -1
|
@@ -5,7 +5,6 @@ import { renderInstanceSlots } from "../../fixtures/media.js";
|
|
|
5
5
|
import { materializeTemplate, resolveEdit } from "../../template/materialize.js";
|
|
6
6
|
import { loadFixtures } from "../../fixtures/load.js";
|
|
7
7
|
import { resolveFixture } from "../../fixtures/resolve.js";
|
|
8
|
-
import { synthesizeEmptyFixtures } from "../../fixtures/synthesize-empties.js";
|
|
9
8
|
import { materializeSection } from "../../section/materialize.js";
|
|
10
9
|
import { loadTemplateModule } from "./load-template.js";
|
|
11
10
|
import { createElement } from "react";
|
|
@@ -74,8 +73,7 @@ function hostFixture(fixture, sizeOf) {
|
|
|
74
73
|
facts: fixture.facts,
|
|
75
74
|
media,
|
|
76
75
|
instances: fixture.contentDoc.instances,
|
|
77
|
-
provenance: fixture.provenance
|
|
78
|
-
...fixture.synthesized ? { synthesized: true } : {}
|
|
76
|
+
provenance: fixture.provenance
|
|
79
77
|
};
|
|
80
78
|
}
|
|
81
79
|
var DevWorkspace = class {
|
|
@@ -144,13 +142,11 @@ var DevWorkspace = class {
|
|
|
144
142
|
if (result.resolved !== null) resolved.set(fixture.id, result.resolved);
|
|
145
143
|
}
|
|
146
144
|
const authored = loaded.fixtures.flatMap((f) => resolved.get(f.id) ?? []);
|
|
147
|
-
const first = authored[0];
|
|
148
|
-
const empties = first === void 0 ? [] : synthesizeEmptyFixtures(first, materialized.placements);
|
|
149
145
|
const sizeOf = (url) => loaded.assets.get(url)?.bytes;
|
|
150
146
|
return {
|
|
151
147
|
loaded,
|
|
152
148
|
resolved,
|
|
153
|
-
hosted:
|
|
149
|
+
hosted: authored.map((fixture) => hostFixture(fixture, sizeOf)),
|
|
154
150
|
violations
|
|
155
151
|
};
|
|
156
152
|
})();
|
package/dist/cli/media/derive.js
CHANGED
|
@@ -15,6 +15,31 @@ const DERIVABLE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
|
15
15
|
".webp",
|
|
16
16
|
".avif"
|
|
17
17
|
]);
|
|
18
|
+
/**
|
|
19
|
+
* The rungs of `rungs` a rendered frame can ever select, for a master `width` wide whose
|
|
20
|
+
* long edge is `longEdge`: every rung at least `floor` px wide, plus the top rung.
|
|
21
|
+
*
|
|
22
|
+
* A rendered template's page is a frame document whose window is exactly the format's
|
|
23
|
+
* box — the canvas scales the iframe, it never narrows it — so an unsized `<Image>`
|
|
24
|
+
* (`sizes` defaults to `100vw`) asks for the frame width times the device pixel ratio,
|
|
25
|
+
* and a candidate narrower than the frame is never the one a DPR >= 1 screen picks. The
|
|
26
|
+
* top rung stays whatever its width: it is what a frame wider than the master picks.
|
|
27
|
+
*
|
|
28
|
+
* Dropping a candidate can never degrade a render, whatever `sizes` an author wrote or
|
|
29
|
+
* whatever DPR a browser has: every rung kept is wider than every rung dropped, so a
|
|
30
|
+
* browser choosing from the kept set lands on the rung it chose before or a wider one.
|
|
31
|
+
* Measured on a `deck16x9` canvas at DPR 1, 2 and 3: every image fetched exactly one
|
|
32
|
+
* candidate, and never one narrower than the frame unless it was the master's top rung.
|
|
33
|
+
*
|
|
34
|
+
* `width` is estimated per rung the way `encodeRung` resizes (`fit: inside` on the long
|
|
35
|
+
* edge), before encoding, so a dropped rung costs no encode. An off-by-one at the floor
|
|
36
|
+
* only decides whether one more candidate ships, never what a frame shows.
|
|
37
|
+
*/
|
|
38
|
+
function frameReachableRungs(rungs, width, longEdge, floor) {
|
|
39
|
+
if (floor === void 0 || floor <= 0 || longEdge <= 0 || rungs.length === 0) return [...rungs];
|
|
40
|
+
const top = rungs[rungs.length - 1];
|
|
41
|
+
return rungs.filter((edge) => edge === top || Math.round(width * Math.min(edge, longEdge) / longEdge) >= floor);
|
|
42
|
+
}
|
|
18
43
|
/** 8 hex chars of sha256 over the master's bytes — the shared stem of every derivative. */
|
|
19
44
|
function masterHash(bytes) {
|
|
20
45
|
return createHash("sha256").update(bytes).digest("hex").slice(0, 8);
|
|
@@ -152,7 +177,8 @@ async function deriveAuthorImage(absPath, bytes, opts = {}) {
|
|
|
152
177
|
const hash = masterHash(bytes);
|
|
153
178
|
const stem = basename(absPath, extname(absPath));
|
|
154
179
|
if (!SAFE_STEM.test(stem)) throw new UnsafeStemError(absPath, stem);
|
|
155
|
-
const
|
|
180
|
+
const floor = opts.minRungWidth !== void 0 && opts.minRungWidth > 0 ? opts.minRungWidth : void 0;
|
|
181
|
+
const masterKey = floor === void 0 ? `${stem}|${hash}` : `${stem}|${hash}|frame${String(floor)}`;
|
|
156
182
|
const memoKey = `${opts.cacheDir ?? ""}|${masterKey}`;
|
|
157
183
|
const master = masterAsset(absPath, hash, bytes);
|
|
158
184
|
const memoHit = derivationCache.get(memoKey);
|
|
@@ -190,7 +216,8 @@ async function deriveAuthorImage(absPath, bytes, opts = {}) {
|
|
|
190
216
|
const { encodeRung, formatPolicyFor, rungsFor } = await loadImageLadder();
|
|
191
217
|
const buffer = Buffer.from(bytes);
|
|
192
218
|
const meta = await sharp(buffer).metadata();
|
|
193
|
-
const
|
|
219
|
+
const longEdge = Math.max(meta.width ?? 0, meta.height ?? 0);
|
|
220
|
+
const rungs = frameReachableRungs(rungsFor(longEdge), meta.width ?? 0, longEdge, floor);
|
|
194
221
|
const specs = formatPolicyFor({
|
|
195
222
|
format: meta.format,
|
|
196
223
|
hasAlpha: meta.hasAlpha
|
|
@@ -249,4 +276,4 @@ async function deriveAuthorImage(absPath, bytes, opts = {}) {
|
|
|
249
276
|
}
|
|
250
277
|
|
|
251
278
|
//#endregion
|
|
252
|
-
export { DERIVABLE_EXTENSIONS, UnsafeStemError, deriveAuthorImage, mapConcurrent, masterHash };
|
|
279
|
+
export { DERIVABLE_EXTENSIONS, UnsafeStemError, deriveAuthorImage, frameReachableRungs, mapConcurrent, masterHash };
|
|
@@ -6,7 +6,8 @@ import { readFile } from "node:fs/promises";
|
|
|
6
6
|
const NAMESPACE = "media-deriver";
|
|
7
7
|
const RESOLVING = Symbol("media-deriver:resolving");
|
|
8
8
|
const RASTER_FILTER = /\.(?:[jJ][pP][eE]?[gG]|[pP][nN][gG]|[wW][eE][bB][pP]|[aA][vV][iI][fF])$/;
|
|
9
|
-
/** A fresh deriver per esbuild pass; `cacheDir` opts it into the on-disk ladder cache
|
|
9
|
+
/** A fresh deriver per esbuild pass; `cacheDir` opts it into the on-disk ladder cache, and
|
|
10
|
+
* `minRungWidth` (a rendered template's frame width) drops the rungs no frame selects. */
|
|
10
11
|
function createMediaDeriver(opts = {}) {
|
|
11
12
|
const derived = /* @__PURE__ */ new Map();
|
|
12
13
|
const masters = /* @__PURE__ */ new Map();
|
|
@@ -38,7 +39,10 @@ function createMediaDeriver(opts = {}) {
|
|
|
38
39
|
namespace: NAMESPACE
|
|
39
40
|
}, async (args) => {
|
|
40
41
|
const bytes = await readFile(args.path);
|
|
41
|
-
const derivation = await deriveAuthorImage(args.path, bytes, {
|
|
42
|
+
const derivation = await deriveAuthorImage(args.path, bytes, {
|
|
43
|
+
cacheDir: opts.cacheDir,
|
|
44
|
+
minRungWidth: opts.minRungWidth
|
|
45
|
+
});
|
|
42
46
|
for (const asset of derivation.derivatives) derived.set(asset.filename, asset);
|
|
43
47
|
const { key, filename, bytes: masterBytes, contentType } = derivation.master;
|
|
44
48
|
derived.set(filename, {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { captureViewport } from "../../packages/internal/format-geometry/dist/capture.js";
|
|
2
|
+
import "../../packages/internal/format-geometry/dist/index.js";
|
|
3
|
+
|
|
4
|
+
//#region src/cli/media/frame-rung-floor.ts
|
|
5
|
+
/**
|
|
6
|
+
* The frame width, in CSS px at DPR 1, of the template's narrowest declared format —
|
|
7
|
+
* undefined for a website, whose pages are served at any viewport and keep the full
|
|
8
|
+
* ladder. The narrowest, so a multi-format template keeps every rung any of its frames
|
|
9
|
+
* can select.
|
|
10
|
+
*/
|
|
11
|
+
function frameRungFloor(template) {
|
|
12
|
+
if (template.output === "website") return void 0;
|
|
13
|
+
const widths = template.formats.filter((format) => format.width !== void 0).map((format) => captureViewport(format).width);
|
|
14
|
+
return widths.length === 0 ? void 0 : Math.min(...widths);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
export { frameRungFloor };
|
package/dist/css/graph.js
CHANGED
|
@@ -26,6 +26,7 @@ const EMPTY_LOADERS = Object.fromEntries([
|
|
|
26
26
|
".pdf",
|
|
27
27
|
".zip"
|
|
28
28
|
].map((ext) => [ext, "empty"]));
|
|
29
|
+
const INTERCEPTED_FILTER = /^[^./]|\.css$/;
|
|
29
30
|
function isOwnResolve(pluginData) {
|
|
30
31
|
return typeof pluginData === "object" && pluginData !== null && pluginData.concreteCssGraph === true;
|
|
31
32
|
}
|
|
@@ -33,7 +34,7 @@ function graphPlugin() {
|
|
|
33
34
|
return {
|
|
34
35
|
name: "concrete-css-graph",
|
|
35
36
|
setup(api) {
|
|
36
|
-
api.onResolve({ filter:
|
|
37
|
+
api.onResolve({ filter: INTERCEPTED_FILTER }, async (args) => {
|
|
37
38
|
if (args.kind === "entry-point" || isOwnResolve(args.pluginData)) return void 0;
|
|
38
39
|
if (UNFOLLOWED_RE.test(args.path)) return {
|
|
39
40
|
path: args.path,
|
package/dist/fixtures/load.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isFixture } from "./brand.js";
|
|
2
2
|
import { MEDIA_LOADERS, createFixtureMediaPlugin, externalOutsideWorkspace } from "./media-plugin.js";
|
|
3
3
|
import { runningCopyPlugin } from "../template/running-copy.js";
|
|
4
|
+
import { createPackageStylesheetsPlugin } from "./package-stylesheets.js";
|
|
4
5
|
import { readdirSync } from "node:fs";
|
|
5
6
|
import { join, relative, sep } from "node:path";
|
|
6
7
|
import { pathToFileURL } from "node:url";
|
|
@@ -41,6 +42,7 @@ let importSerial = 0;
|
|
|
41
42
|
/** The default loader: one esbuild pass over every fixture module, then a dynamic import of each output. */
|
|
42
43
|
async function bundleAndImportFixtureModules(root, files) {
|
|
43
44
|
const media = createFixtureMediaPlugin(root);
|
|
45
|
+
const stylesheets = await createPackageStylesheetsPlugin(root);
|
|
44
46
|
const outdir = join(root, ".concrete", "cache", "fixtures");
|
|
45
47
|
let result;
|
|
46
48
|
try {
|
|
@@ -63,7 +65,8 @@ async function bundleAndImportFixtureModules(root, files) {
|
|
|
63
65
|
plugins: [
|
|
64
66
|
runningCopyPlugin(),
|
|
65
67
|
externalOutsideWorkspace(root),
|
|
66
|
-
media.plugin
|
|
68
|
+
media.plugin,
|
|
69
|
+
stylesheets.plugin
|
|
67
70
|
],
|
|
68
71
|
metafile: true,
|
|
69
72
|
write: true,
|
|
@@ -81,6 +84,8 @@ async function bundleAndImportFixtureModules(root, files) {
|
|
|
81
84
|
message: m.location === null || m.location === void 0 ? m.text : `${m.text} (${m.location.file}:${m.location.line})`
|
|
82
85
|
}))
|
|
83
86
|
};
|
|
87
|
+
} finally {
|
|
88
|
+
await stylesheets.dispose();
|
|
84
89
|
}
|
|
85
90
|
const outputByInput = /* @__PURE__ */ new Map();
|
|
86
91
|
for (const [out, meta] of Object.entries(result.metafile.outputs)) if (meta.entryPoint !== void 0) outputByInput.set(join(root, meta.entryPoint), join(root, out));
|
package/dist/fixtures/media.js
CHANGED
|
@@ -68,11 +68,22 @@ function imageValue(entry, ref, resolver) {
|
|
|
68
68
|
};
|
|
69
69
|
return value;
|
|
70
70
|
}
|
|
71
|
+
function posterOf(entry, resolver) {
|
|
72
|
+
if (entry.posterFile !== void 0) {
|
|
73
|
+
const served = resolver.file(entry.posterFile);
|
|
74
|
+
return served.responsive === null ? { poster: served.url } : {
|
|
75
|
+
poster: served.url,
|
|
76
|
+
poster_responsive: served.responsive
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
return { poster: entry.posterUrl ?? "" };
|
|
80
|
+
}
|
|
71
81
|
function videoValue(entry, resolver) {
|
|
82
|
+
const poster = posterOf(entry, resolver);
|
|
72
83
|
if (entry.file === null) return {
|
|
73
84
|
video_id: entry.id,
|
|
74
85
|
url: entry.url ?? "",
|
|
75
|
-
poster
|
|
86
|
+
...poster,
|
|
76
87
|
alt: entry.alt,
|
|
77
88
|
source: "link",
|
|
78
89
|
...entry.provider === null ? {} : { provider: entry.provider }
|
|
@@ -80,16 +91,16 @@ function videoValue(entry, resolver) {
|
|
|
80
91
|
return {
|
|
81
92
|
video_id: entry.id,
|
|
82
93
|
url: resolver.file(entry.file).url,
|
|
83
|
-
poster
|
|
94
|
+
...poster,
|
|
84
95
|
alt: entry.alt,
|
|
85
96
|
source: "upload"
|
|
86
97
|
};
|
|
87
98
|
}
|
|
88
|
-
function tourValue(entry) {
|
|
99
|
+
function tourValue(entry, resolver) {
|
|
89
100
|
return {
|
|
90
101
|
tour_id: entry.id,
|
|
91
102
|
url: entry.url ?? "",
|
|
92
|
-
|
|
103
|
+
...posterOf(entry, resolver),
|
|
93
104
|
alt: entry.alt,
|
|
94
105
|
...entry.provider === null ? {} : { provider: entry.provider }
|
|
95
106
|
};
|
|
@@ -116,7 +127,7 @@ function renderMediaRef(kind, value, media, resolver) {
|
|
|
116
127
|
switch (kind) {
|
|
117
128
|
case "image": return imageValue(entry, value, resolver);
|
|
118
129
|
case "video": return videoValue(entry, resolver);
|
|
119
|
-
case "tour": return tourValue(entry);
|
|
130
|
+
case "tour": return tourValue(entry, resolver);
|
|
120
131
|
case "document": return documentValue(entry, resolver);
|
|
121
132
|
default: return null;
|
|
122
133
|
}
|
|
@@ -127,6 +138,26 @@ const MEDIA_KINDS = /* @__PURE__ */ new Set([
|
|
|
127
138
|
"tour",
|
|
128
139
|
"document"
|
|
129
140
|
]);
|
|
141
|
+
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
142
|
+
function floorPlanValue(ref, media, resolver) {
|
|
143
|
+
const id = typeof ref.id === "string" ? ref.id : "";
|
|
144
|
+
const floorLabel = typeof ref.floor_label === "string" ? ref.floor_label : null;
|
|
145
|
+
const entry = id === "" ? void 0 : media.get(id);
|
|
146
|
+
const served = entry?.kind === "image" && entry.file !== null ? resolver.file(entry.file) : null;
|
|
147
|
+
return {
|
|
148
|
+
id,
|
|
149
|
+
...typeof ref.upload_id === "string" ? { upload_id: ref.upload_id } : {},
|
|
150
|
+
url: served?.url ?? "",
|
|
151
|
+
alt: floorLabel ?? "Floor plan",
|
|
152
|
+
floor_label: floorLabel,
|
|
153
|
+
position: typeof ref.position === "number" ? ref.position : 0,
|
|
154
|
+
...served?.responsive ? { responsive: served.responsive } : {}
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
function renderRowField(def, value, media, resolver) {
|
|
158
|
+
if (def.type === "image" && Array.isArray(value)) return value.filter(isRecord).map((ref) => floorPlanValue(ref, media, resolver));
|
|
159
|
+
return renderValue(def, value, media, resolver);
|
|
160
|
+
}
|
|
130
161
|
function renderValue(def, value, media, resolver) {
|
|
131
162
|
if (value === null || value === void 0) return value;
|
|
132
163
|
if (MEDIA_KINDS.has(def.type)) return renderMediaRef(def.type, value, media, resolver);
|
|
@@ -137,7 +168,7 @@ function renderValue(def, value, media, resolver) {
|
|
|
137
168
|
return items.map((row) => {
|
|
138
169
|
if (typeof row !== "object" || row === null) return row;
|
|
139
170
|
const out = { ...row };
|
|
140
|
-
for (const [field, fieldDef] of Object.entries(fields)) out[field] =
|
|
171
|
+
for (const [field, fieldDef] of Object.entries(fields)) out[field] = renderRowField(fieldDef, out[field], media, resolver);
|
|
141
172
|
return out;
|
|
142
173
|
});
|
|
143
174
|
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { context } from "esbuild";
|
|
2
|
+
|
|
3
|
+
//#region src/fixtures/package-stylesheets.ts
|
|
4
|
+
const NAMESPACE = "concrete-package-stylesheet";
|
|
5
|
+
/**
|
|
6
|
+
* Whether a bare specifier names a stylesheet is only known once it resolves, and a
|
|
7
|
+
* pass's own `build.resolve` honours `packages: "external"` and never does. So the plugin
|
|
8
|
+
* asks a resolver context of its own, without that option, and claims only what
|
|
9
|
+
* resolves to `.css`; everything else falls through to the pass unchanged.
|
|
10
|
+
*/
|
|
11
|
+
async function createPackageStylesheetsPlugin(root) {
|
|
12
|
+
let resolve;
|
|
13
|
+
const resolver = await context({
|
|
14
|
+
absWorkingDir: root,
|
|
15
|
+
platform: "node",
|
|
16
|
+
logLevel: "silent",
|
|
17
|
+
plugins: [{
|
|
18
|
+
name: `${NAMESPACE}-resolver`,
|
|
19
|
+
setup: (api) => void (resolve = (path, options) => api.resolve(path, options))
|
|
20
|
+
}]
|
|
21
|
+
});
|
|
22
|
+
const stylesheets = /* @__PURE__ */ new Map();
|
|
23
|
+
return {
|
|
24
|
+
plugin: {
|
|
25
|
+
name: NAMESPACE,
|
|
26
|
+
setup(api) {
|
|
27
|
+
api.onResolve({ filter: /^[^./]/ }, async (args) => {
|
|
28
|
+
if (args.kind === "entry-point" || args.path.startsWith("node:") || resolve === void 0) return null;
|
|
29
|
+
const key = `${args.kind}\0${args.resolveDir}\0${args.path}`;
|
|
30
|
+
let stylesheet = stylesheets.get(key);
|
|
31
|
+
if (stylesheet === void 0) {
|
|
32
|
+
stylesheet = resolve(args.path, {
|
|
33
|
+
kind: args.kind,
|
|
34
|
+
importer: args.importer,
|
|
35
|
+
resolveDir: args.resolveDir
|
|
36
|
+
}).then((resolved) => resolved.errors.length === 0 && !resolved.external && resolved.path.endsWith(".css") ? resolved.path : null);
|
|
37
|
+
stylesheets.set(key, stylesheet);
|
|
38
|
+
}
|
|
39
|
+
const path = await stylesheet;
|
|
40
|
+
return path === null ? null : {
|
|
41
|
+
path,
|
|
42
|
+
namespace: NAMESPACE
|
|
43
|
+
};
|
|
44
|
+
});
|
|
45
|
+
api.onLoad({
|
|
46
|
+
filter: /.*/,
|
|
47
|
+
namespace: NAMESPACE
|
|
48
|
+
}, () => ({
|
|
49
|
+
contents: "",
|
|
50
|
+
loader: "empty"
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
dispose: () => resolver.dispose()
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
//#endregion
|
|
59
|
+
export { createPackageStylesheetsPlugin };
|
|
@@ -88,34 +88,55 @@ function canonicalizeProperty(property, file) {
|
|
|
88
88
|
});
|
|
89
89
|
media.set(plan.id, entry(plan.id, "image", planFile, ""));
|
|
90
90
|
}
|
|
91
|
+
const admitThumbnail = (value, path) => {
|
|
92
|
+
if (value === void 0) return {};
|
|
93
|
+
if (typeof value === "string" && value !== "") return { posterUrl: value };
|
|
94
|
+
invalid(`${path}.thumbnail_source_url: expected a non-empty URL`);
|
|
95
|
+
return null;
|
|
96
|
+
};
|
|
91
97
|
const videos = [];
|
|
92
98
|
for (const [i, video] of (property.videos ?? []).entries()) {
|
|
93
99
|
const path = `videos[${i}]`;
|
|
94
100
|
if (!admit("videos", video.id, path)) continue;
|
|
95
101
|
if (video.source === "upload") {
|
|
96
102
|
if (!admitFile(video.file, `${path}.file`)) continue;
|
|
97
|
-
const { file: videoFile, ...row } = video;
|
|
103
|
+
const { file: videoFile, poster, ...row } = video;
|
|
104
|
+
if (poster !== void 0 && !admitFile(poster, `${path}.poster`)) continue;
|
|
98
105
|
videos.push({
|
|
99
106
|
...row,
|
|
100
107
|
url: null,
|
|
101
108
|
provider: null
|
|
102
109
|
});
|
|
103
|
-
media.set(video.id,
|
|
110
|
+
media.set(video.id, {
|
|
111
|
+
...entry(video.id, "video", videoFile, video.caption ?? ""),
|
|
112
|
+
...poster === void 0 ? {} : { posterFile: poster }
|
|
113
|
+
});
|
|
104
114
|
} else {
|
|
105
|
-
|
|
115
|
+
const { thumbnail_source_url: thumbnail, ...row } = video;
|
|
116
|
+
const poster = admitThumbnail(thumbnail, path);
|
|
117
|
+
if (poster === null) continue;
|
|
118
|
+
videos.push(row);
|
|
106
119
|
media.set(video.id, {
|
|
107
120
|
...entry(video.id, "video", null, video.caption ?? ""),
|
|
108
121
|
url: video.url,
|
|
109
|
-
provider: video.provider
|
|
122
|
+
provider: video.provider,
|
|
123
|
+
...poster
|
|
110
124
|
});
|
|
111
125
|
}
|
|
112
126
|
}
|
|
127
|
+
const tours = [];
|
|
113
128
|
for (const [i, tour] of (property.tours ?? []).entries()) {
|
|
114
|
-
|
|
129
|
+
const path = `tours[${i}]`;
|
|
130
|
+
if (!admit("tours", tour.id, path)) continue;
|
|
131
|
+
const { thumbnail_source_url: thumbnail, ...row } = tour;
|
|
132
|
+
const poster = admitThumbnail(thumbnail, path);
|
|
133
|
+
if (poster === null) continue;
|
|
134
|
+
tours.push(row);
|
|
115
135
|
media.set(tour.id, {
|
|
116
136
|
...entry(tour.id, "tour", null, ""),
|
|
117
137
|
url: tour.url,
|
|
118
|
-
provider: tour.provider
|
|
138
|
+
provider: tour.provider,
|
|
139
|
+
...poster
|
|
119
140
|
});
|
|
120
141
|
}
|
|
121
142
|
const documents = [];
|
|
@@ -168,7 +189,7 @@ function canonicalizeProperty(property, file) {
|
|
|
168
189
|
listing_intent: property.listing_intent,
|
|
169
190
|
units: property.units,
|
|
170
191
|
narrative: property.narrative,
|
|
171
|
-
tours
|
|
192
|
+
tours,
|
|
172
193
|
comparables: property.comparables,
|
|
173
194
|
photos,
|
|
174
195
|
floor_plans: floorPlans,
|
package/dist/fixtures.d.ts
CHANGED
|
@@ -33,15 +33,31 @@ type FloorPlanEntry = Omit<CanonicalFloorPlan, "upload_id" | "page_index" | "pro
|
|
|
33
33
|
type UploadVideoEntry = Omit<CanonicalVideo, "source" | "url" | "provider"> & {
|
|
34
34
|
readonly source: "upload";
|
|
35
35
|
readonly file: MediaFile;
|
|
36
|
+
/**
|
|
37
|
+
* The poster frame the platform cuts from the upload, imported like any image and
|
|
38
|
+
* served with its ladder. Absent means the video resolves with no poster.
|
|
39
|
+
*/
|
|
40
|
+
readonly poster?: MediaFile;
|
|
36
41
|
};
|
|
37
42
|
/** A pasted provider link. Stays a URL, exactly as the platform stores it. */
|
|
38
43
|
type LinkVideoEntry = Omit<CanonicalVideo, "source"> & {
|
|
39
44
|
readonly source: "link";
|
|
45
|
+
/**
|
|
46
|
+
* The provider thumbnail the platform's link enrichment records, served as the
|
|
47
|
+
* video's poster. It stays a link: the fixture never hosts it. Absent means no poster.
|
|
48
|
+
*/
|
|
49
|
+
readonly thumbnail_source_url?: string;
|
|
40
50
|
};
|
|
41
51
|
/** One video candidate — a hosted upload or a pasted provider link. */
|
|
42
52
|
type VideoEntry = UploadVideoEntry | LinkVideoEntry;
|
|
43
53
|
/** One 3D tour link. Stays a URL, exactly as the platform stores it. */
|
|
44
|
-
type TourEntry = Canonical["tours"][number]
|
|
54
|
+
type TourEntry = Canonical["tours"][number] & {
|
|
55
|
+
/**
|
|
56
|
+
* The provider thumbnail the platform's link enrichment records, served as the
|
|
57
|
+
* tour's poster. It stays a link. Absent means no poster, as for a private tour.
|
|
58
|
+
*/
|
|
59
|
+
readonly thumbnail_source_url?: string;
|
|
60
|
+
};
|
|
45
61
|
/**
|
|
46
62
|
* An attachable document: its file imported, plus the notes distilled from it. The
|
|
47
63
|
* property's `document_notes` are derived from these entries and never stated.
|
|
@@ -64,10 +80,11 @@ type ContactEntry = Omit<CanonicalContact, "avatar_upload_id" | "logo_dark_uploa
|
|
|
64
80
|
* Facts only. Unit copy, points of interest, amenities and any other fill output are
|
|
65
81
|
* not on a property; a fixture states them in its content entries.
|
|
66
82
|
*/
|
|
67
|
-
type Property = Omit<Canonical, "photos" | "floor_plans" | "videos" | "documents" | "contacts" | "document_notes"> & {
|
|
83
|
+
type Property = Omit<Canonical, "photos" | "floor_plans" | "videos" | "tours" | "documents" | "contacts" | "document_notes"> & {
|
|
68
84
|
readonly photos: PhotoEntry[];
|
|
69
85
|
readonly floor_plans: FloorPlanEntry[];
|
|
70
86
|
readonly videos: VideoEntry[];
|
|
87
|
+
readonly tours: TourEntry[];
|
|
71
88
|
readonly documents: DocumentEntry[];
|
|
72
89
|
readonly contacts: ContactEntry[];
|
|
73
90
|
};
|
|
@@ -139,6 +156,12 @@ type SlotsOf<S> = S extends {
|
|
|
139
156
|
type ContentRow<I> = {
|
|
140
157
|
readonly id?: string;
|
|
141
158
|
} & { readonly [K in keyof I]?: ContentSlotValue<I[K]> | null; };
|
|
159
|
+
/**
|
|
160
|
+
* An entry a content doc may state on an `image` slot: every property entry the resolver
|
|
161
|
+
* registers as image media — a photo or a floor plan. A contact's avatar and logos are
|
|
162
|
+
* image media too, but under minted ids with no entry of their own, so none is stateable.
|
|
163
|
+
*/
|
|
164
|
+
type ImageEntry = PhotoEntry | FloorPlanEntry;
|
|
142
165
|
/**
|
|
143
166
|
* The value one slot takes in a content entry: a media slot takes an entry of the
|
|
144
167
|
* fixture's property, a list of them an array, a record list its rows, a points-of-
|
|
@@ -147,7 +170,7 @@ type ContentRow<I> = {
|
|
|
147
170
|
*/
|
|
148
171
|
type ContentSlotValue<S> = S extends {
|
|
149
172
|
type: "image";
|
|
150
|
-
} ?
|
|
173
|
+
} ? ImageEntry : S extends {
|
|
151
174
|
type: "video";
|
|
152
175
|
} ? VideoEntry : S extends {
|
|
153
176
|
type: "tour";
|
|
@@ -210,4 +233,4 @@ declare function content<S extends SectionRef, M extends object>(section: S, val
|
|
|
210
233
|
readonly instance?: string;
|
|
211
234
|
}): ContentEntry<S>;
|
|
212
235
|
//#endregion
|
|
213
|
-
export { ContactEntry, ContentDisplay, ContentEntry, ContentRow, ContentSlotValue, ContentSlots, ContentValues, ContentValuesOf, DocumentEntry, ExactContent, Fixture, FixtureSpec, FloorPlanEntry, LinkVideoEntry, MediaFile, PhotoEntry, Property, SectionRef, TourEntry, UploadVideoEntry, VideoEntry, content, defineFixture };
|
|
236
|
+
export { ContactEntry, ContentDisplay, ContentEntry, ContentRow, ContentSlotValue, ContentSlots, ContentValues, ContentValuesOf, DocumentEntry, ExactContent, Fixture, FixtureSpec, FloorPlanEntry, ImageEntry, LinkVideoEntry, MediaFile, PhotoEntry, Property, SectionRef, TourEntry, UploadVideoEntry, VideoEntry, content, defineFixture };
|
|
@@ -5,18 +5,17 @@ import { RowValue, SlotValue } from "../schema/section-props.js";
|
|
|
5
5
|
//#region src/primitives/slot-bindings.d.ts
|
|
6
6
|
/**
|
|
7
7
|
* The value shape a binding holds after bind-time normalization: `SlotValue`
|
|
8
|
-
* for every kind except a RECORD list, whose bound rows
|
|
9
|
-
*
|
|
10
|
-
* editor-stamped `id` plus each DECLARED field and drops everything else, so a
|
|
11
|
-
* whole-row-baked slot's projection-only fields (which `SlotValue` types on
|
|
12
|
-
* the raw slot value) never survive into a binding.
|
|
8
|
+
* for every kind except a RECORD list, whose bound rows carry the
|
|
9
|
+
* editor-stamped `id` plus each DECLARED field, normalized by its definition.
|
|
13
10
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
11
|
+
* A stored record list's row (`RowValue`) is closed: anything else on it is
|
|
12
|
+
* dropped. A record list bound whole-row to a collection
|
|
13
|
+
* (`source: fact.property.comparables`) is the other case, because a section's
|
|
14
|
+
* render receives bindings and nothing else: its bound row
|
|
15
|
+
* ({@link BoundBakedRow}) also keeps every member the platform bakes onto the
|
|
16
|
+
* row, so markup reads a comparable's `status` or `lat` off
|
|
17
|
+
* `slot.comps.value[n]` (or `bindItems(slot.comps)[n].value`) without
|
|
18
|
+
* declaring it as a row field.
|
|
20
19
|
*/
|
|
21
20
|
type BoundSlotValue<D> = D extends {
|
|
22
21
|
type: "list";
|
|
@@ -32,8 +31,15 @@ type BoundSlotValue<D> = D extends {
|
|
|
32
31
|
type ProjectedImageListKeys<F extends CollectionField, I> = { [K in keyof I & keyof CollectionRowValues[F]]: I[K] extends {
|
|
33
32
|
type: "image";
|
|
34
33
|
} ? CollectionRowValues[F][K] extends readonly unknown[] ? K : never : never; }[keyof I & keyof CollectionRowValues[F]];
|
|
35
|
-
/**
|
|
36
|
-
|
|
34
|
+
/**
|
|
35
|
+
* One bound row of a whole-row-baked record list: every member of the collection's
|
|
36
|
+
* projected row, with each DECLARED field at its normalized kind — except a declared
|
|
37
|
+
* `image` field the projection carries as a list (a unit's `floor_plans`, its ordered
|
|
38
|
+
* floor-plan assignments), which keeps the projection's list. That field's own
|
|
39
|
+
* `FieldBinding` still holds the `image` kind's value, so the primitives read it
|
|
40
|
+
* exactly as before.
|
|
41
|
+
*/
|
|
42
|
+
type BoundBakedRow<F extends CollectionField, I> = Omit<CollectionRowValues[F], keyof I | "id"> & Omit<RowValue<I>, ProjectedImageListKeys<F, I>> & { [K in ProjectedImageListKeys<F, I>]: CollectionRowValues[F][K]; };
|
|
37
43
|
/**
|
|
38
44
|
* One slot: its id, the definition the section declared for it, and its runtime value.
|
|
39
45
|
*
|
|
@@ -70,9 +70,12 @@ function normalizeTour(value) {
|
|
|
70
70
|
alt: stringField(value.alt)
|
|
71
71
|
};
|
|
72
72
|
}
|
|
73
|
-
function normalizeRow(fields, row) {
|
|
73
|
+
function normalizeRow(fields, row, baked) {
|
|
74
74
|
const source = isRecord(row) ? row : {};
|
|
75
|
-
const normalized = {
|
|
75
|
+
const normalized = {
|
|
76
|
+
...baked ? source : {},
|
|
77
|
+
id: stringField(source.id)
|
|
78
|
+
};
|
|
76
79
|
for (const [field, def] of Object.entries(fields)) {
|
|
77
80
|
const value = source[field];
|
|
78
81
|
normalized[field] = def.type === "image" && Array.isArray(value) ? value.filter(isRecord) : normalizeValue(def, value);
|
|
@@ -95,7 +98,8 @@ function normalizeValue(def, value) {
|
|
|
95
98
|
if (!Array.isArray(value)) return [];
|
|
96
99
|
if (isRecord(slot.fields)) {
|
|
97
100
|
const fields = slot.fields;
|
|
98
|
-
|
|
101
|
+
const baked = isRecord(slot.source) && slot.source.kind === "direct";
|
|
102
|
+
return value.map((row) => normalizeRow(fields, row, baked));
|
|
99
103
|
}
|
|
100
104
|
if (slot.element == null) return value;
|
|
101
105
|
const element = slot.element;
|
|
@@ -16,7 +16,12 @@ interface SectionPlacementProps {
|
|
|
16
16
|
}
|
|
17
17
|
/** What the render function receives: bindings, not raw values. */
|
|
18
18
|
interface SectionRenderBindings<Slots extends Record<string, Slot>, Display extends DisplayInput> {
|
|
19
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* One binding per declared slot, keyed by slot id — what `bindSlots` returned to a Renderer.
|
|
21
|
+
* There is no raw `slots` beside it: a record list bound whole-row to a collection keeps
|
|
22
|
+
* every member the platform bakes onto its rows on the bound row itself
|
|
23
|
+
* (`slot.comps.value[n].status`), declared as a row field or not.
|
|
24
|
+
*/
|
|
20
25
|
readonly slot: SlotBindingMap<SectionSchemaOf<Slots, Display>>;
|
|
21
26
|
/** The build-injected navigation input: this section's anchor, the anchor map, the pages. */
|
|
22
27
|
readonly nav: SectionNav;
|
|
@@ -34,7 +34,7 @@ concrete build [--out <dir>] [--no-auto-update]
|
|
|
34
34
|
|
|
35
35
|
- The only producer of an artifact. Nothing else — no bare bundler — writes one.
|
|
36
36
|
- Deterministic: the same tree builds to the same artifact hash.
|
|
37
|
-
- An image or document template also carries `captures/`: every authored fixture at every declared format, taken exactly as `dev`'s *Download
|
|
37
|
+
- An image or document template also carries `captures/`: every authored fixture at every declared format, taken exactly as `dev`'s *Download* takes it — the enabled pages and their zip, or the PDF. Captures sit outside the artifact hash, and need Playwright: without it, build refuses with the install line.
|
|
38
38
|
- The default output directory, `.concrete/build/`, is gitignored by the scaffold.
|
|
39
39
|
|
|
40
40
|
## Before it runs
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@homepages/concrete",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Concrete, the HomePages template framework: the authoring API, the contract primitives, the styles, the lint preset and the `concrete` command in one package that owns its whole toolchain.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|