@homepages/concrete 14.1.0 → 14.2.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 CHANGED
@@ -1,5 +1,16 @@
1
1
  # @homepages/concrete
2
2
 
3
+ ## 14.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - bc1667e: `concrete check` now synthesizes every display case. For each placed instance whose section declares `variant` cases, it renders a copy of the first fixture once per case that fixture does not already render, with that case switched on as a user would switch it. Marker coverage and the render invariants grade every case, so no fixture has to be on a case just for `check`. Put your fullest property first: `check` does not switch an instance the first fixture hides. A slot that renders only in a case no fixture draws, and loses its marker when empty, is now reported as `render/missing-slot-marker`.
8
+
9
+ ### Patch Changes
10
+
11
+ - ebd29d2: A build's static-assets binding always lists `relative_assets`, and the build's check refuses any stylesheet or script that names an asset by the fixed address `/section-assets/`. No host fills that address in a stylesheet or a script any more, so a build of the earlier form is refused, not served with missing fonts and images.
12
+ - 800518e: The bundled framework-floor module gains a read of a prerelease version, which the development console uses. Nothing a template author runs changed.
13
+
3
14
  ## 14.1.0
4
15
 
5
16
  ### Minor Changes
@@ -41,6 +41,10 @@
41
41
  "14.1.0": {
42
42
  "codemods": [],
43
43
  "manual": []
44
+ },
45
+ "14.2.0": {
46
+ "codemods": [],
47
+ "manual": []
44
48
  }
45
49
  }
46
50
  }
@@ -1,6 +1,7 @@
1
1
  import { uniquePlacements } from "../../../packages/internal/playground/dist/host/resolve.js";
2
2
  import { TEMPLATE_FILE } from "../load-workspace.js";
3
3
  import { findFixturesReachableFromBundle } from "../../../fixtures/bundle-rule.js";
4
+ import { synthesizeCaseFixtures } from "../../../fixtures/synthesize-cases.js";
4
5
  import { synthesizeEmptyFixtures } from "../../../fixtures/synthesize-empties.js";
5
6
  import { loadWorkspaceFixtures } from "../../workspace-fixtures.js";
6
7
  import { join } from "node:path";
@@ -37,7 +38,7 @@ async function fixturesStage(ctx) {
37
38
  fixtureFiles: loaded.files
38
39
  }));
39
40
  const first = resolved[0];
40
- ctx.corpus = [...resolved.map((fixture) => ({ fixture })), ...first === void 0 ? [] : emptiesOf(first, composition)];
41
+ ctx.corpus = [...resolved.map((fixture) => ({ fixture })), ...first === void 0 ? [] : [...emptiesOf(first, composition), ...synthesizeCaseFixtures(first, composition.placements).map((fixture) => ({ fixture }))]];
41
42
  ctx.assets = loaded.assets;
42
43
  if (loaded.list !== null) ctx.fixtureFiles = {
43
44
  list: loaded.list,
@@ -0,0 +1,32 @@
1
+ import { instanceInCase, uniquePlacements } from "../packages/internal/playground/dist/host/resolve.js";
2
+
3
+ //#region src/fixtures/synthesize-cases.ts
4
+ function synthesizeCaseFixtures(resolved, placements) {
5
+ const settled = resolved.settled;
6
+ if (settled === void 0) return [];
7
+ const out = [];
8
+ const base = { ...resolved };
9
+ delete base.settled;
10
+ for (const placement of uniquePlacements(placements)) {
11
+ const instance = settled.find((i) => i.instance_id === placement.instance);
12
+ if (instance === void 0) continue;
13
+ for (const variant of placement.section.display.variant?.cases ?? []) {
14
+ if (variant === instance.variant) continue;
15
+ const switched = instanceInCase({
16
+ ...instance,
17
+ variant
18
+ }, placement.section);
19
+ out.push({
20
+ ...base,
21
+ id: `${resolved.id}/case/${placement.instance}/${variant}`,
22
+ label: `${resolved.label}: ${placement.instance} in case ${variant}`,
23
+ synthesized: true,
24
+ contentDoc: { instances: resolved.contentDoc.instances.map((i) => i.instance_id === placement.instance ? switched : i) }
25
+ });
26
+ }
27
+ }
28
+ return out;
29
+ }
30
+
31
+ //#endregion
32
+ export { synthesizeCaseFixtures };
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "14.1.0";
2
+ var version = "14.2.0";
3
3
 
4
4
  //#endregion
5
5
  export { version };
@@ -1,5 +1,4 @@
1
- import { fillBuildFile } from "../../static-assets-binding/dist/section-asset-url.js";
2
- import { isFilledText } from "./capture-routes.js";
1
+ import "./capture-routes.js";
3
2
  import { createServer } from "node:http";
4
3
  import { pipeline } from "node:stream/promises";
5
4
 
@@ -73,23 +72,6 @@ async function serveRequest(input, documents, req, res) {
73
72
  });
74
73
  const contentType = route.contentType ?? stored.contentType ?? DEFAULT_CONTENT_TYPE;
75
74
  const disposition = route.from === "media" && route.contentDisposition !== void 0 ? { "content-disposition": route.contentDisposition } : {};
76
- if (isFilledText(route) && route.from === "build") {
77
- let raw;
78
- try {
79
- raw = await readBytes(stored.body);
80
- } catch (err) {
81
- input.onError?.(`capture origin could not read ${route.path}`, err);
82
- res.writeHead(404).end();
83
- return;
84
- }
85
- const body = fillBuildFile(route.filename, raw, input.bases.build).bytes;
86
- res.writeHead(200, {
87
- "content-type": contentType,
88
- "content-length": body.byteLength
89
- });
90
- res.end(req.method === "HEAD" ? void 0 : body);
91
- return;
92
- }
93
75
  res.writeHead(200, {
94
76
  "content-type": contentType,
95
77
  ...stored.contentLength === void 0 ? {} : { "content-length": stored.contentLength },
@@ -107,11 +89,6 @@ async function serveRequest(input, documents, req, res) {
107
89
  res.destroy();
108
90
  }
109
91
  }
110
- async function readBytes(body) {
111
- const chunks = [];
112
- for await (const chunk of body) chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
113
- return Buffer.concat(chunks);
114
- }
115
92
  function closeServer(server) {
116
93
  return new Promise((resolve, reject) => {
117
94
  server.closeAllConnections();
@@ -1,6 +1,5 @@
1
1
  import { assetContentType } from "../../template-artifact/dist/asset-mime.js";
2
2
  import { assetPath, browserFiles } from "../../template-artifact/dist/layout.js";
3
- import { carriesFixedAddresses } from "../../static-assets-binding/dist/section-asset-url.js";
4
3
  import { imageDocumentHtml, printDocumentHtml } from "./capture-shell.js";
5
4
 
6
5
  //#region ../../internal/download-files/dist/capture-routes.js
@@ -131,9 +130,6 @@ function captureRoutes(input) {
131
130
  return buildFile(pathname.slice(build.length));
132
131
  } };
133
132
  }
134
- function isFilledText(route) {
135
- return route.from === "build" && carriesFixedAddresses(route.filename);
136
- }
137
133
 
138
134
  //#endregion
139
- export { captureDocuments, captureRoutes, isFilledText, pageDocumentPath, printDocumentPath };
135
+ export { captureDocuments, captureRoutes, pageDocumentPath, printDocumentPath };
@@ -51,7 +51,6 @@ async function shoot(input, format, shotAs, pages) {
51
51
  media: input.media,
52
52
  bases: input.bases
53
53
  }),
54
- bases: input.bases,
55
54
  reads: input.reads,
56
55
  onError: (message, err) => log.error({ err }, message),
57
56
  onAbsentBuildFile: (path) => masters.recordAbsent(path),
@@ -16,6 +16,22 @@ import { isEmptyValue, slotProvenance } from "./provenance.js";
16
16
  import { blankForField } from "./rows.js";
17
17
 
18
18
  //#region ../../internal/playground/dist/host/resolve.js
19
+ function instanceInCase(instance, section) {
20
+ const slots = {};
21
+ for (const [id, def] of Object.entries(section.slots)) {
22
+ const cases = def.variant?.cases;
23
+ if (cases !== void 0 && (instance.variant === void 0 || !cases.includes(instance.variant))) continue;
24
+ slots[id] = instance.slots[id];
25
+ }
26
+ return {
27
+ instance_id: instance.instance_id,
28
+ section_key: section.key,
29
+ enabled: instance.enabled,
30
+ ...instance.variant === void 0 ? {} : { variant: instance.variant },
31
+ slots,
32
+ ...instance.slot_overrides === void 0 ? {} : { slot_overrides: instance.slot_overrides }
33
+ };
34
+ }
19
35
  function assertAuthored(fixture) {
20
36
  if (fixture.settled === void 0) throw new Error(`Fixture "${fixture.id}" is synthesized: it carries no settled doc, and no playground serves it.`);
21
37
  }
@@ -137,23 +153,9 @@ function resolveStated(input) {
137
153
  const provenance = {};
138
154
  settled.forEach((instance, index) => {
139
155
  const { placement, values } = filled[index];
140
- const schemaSlots = placement.section.slots;
141
- const slots = {};
142
156
  const provenanceOf = {};
143
- for (const [id, def] of Object.entries(schemaSlots)) {
144
- provenanceOf[id] = slotProvenance(def, id, values[id], instance.slots[id], facts, instance.slot_overrides);
145
- const cases = def.variant?.cases;
146
- if (cases !== void 0 && (instance.variant === void 0 || !cases.includes(instance.variant))) continue;
147
- slots[id] = instance.slots[id];
148
- }
149
- instances.push({
150
- instance_id: instance.instance_id,
151
- section_key: placement.section.key,
152
- enabled: instance.enabled,
153
- ...instance.variant === void 0 ? {} : { variant: instance.variant },
154
- slots,
155
- ...instance.slot_overrides === void 0 ? {} : { slot_overrides: instance.slot_overrides }
156
- });
157
+ for (const [id, def] of Object.entries(placement.section.slots)) provenanceOf[id] = slotProvenance(def, id, values[id], instance.slots[id], facts, instance.slot_overrides);
158
+ instances.push(instanceInCase(instance, placement.section));
157
159
  provenance[instance.instance_id] = provenanceOf;
158
160
  });
159
161
  return {
@@ -550,4 +552,4 @@ function catalogRef(def, id, what, ctx) {
550
552
  }
551
553
 
552
554
  //#endregion
553
- export { assertAuthored, catalogRef, croppedPick, emptyValueFor, fixtureSectionOf, isEmptyValue, resolveStated, settleOverPlacements, uniquePlacements };
555
+ export { assertAuthored, catalogRef, croppedPick, emptyValueFor, fixtureSectionOf, instanceInCase, isEmptyValue, resolveStated, settleOverPlacements, uniquePlacements };
@@ -1,5 +1,4 @@
1
1
  import { TEMPLATE_FILES, browserFiles, builtTreePath, templatePath } from "../../../template-artifact/dist/layout.js";
2
- import { fillBuildFile } from "../../../static-assets-binding/dist/section-asset-url.js";
3
2
  import { playgroundClientDir } from "../layout.js";
4
3
  import { parseDownloadPath } from "../host/download.js";
5
4
  import { OUTPUT_FOLDERS, ROUTES, parseOutputPath } from "../wire.js";
@@ -264,10 +263,10 @@ async function handle(req, res, ctx) {
264
263
  if (await sendClientAsset(ctx, path, res)) return;
265
264
  sendText(res, 404, "not found");
266
265
  }
267
- async function sendTemplateFile(ctx, req, url, res, buildBase = `${ctx.base}${BUILD_MOUNT}`) {
266
+ async function sendTemplateFile(ctx, req, url, res) {
268
267
  const path = `/${url.pathname.slice(ctx.base.length)}`;
269
268
  if (url.pathname.startsWith(ctx.base) && path.startsWith(`/${BUILD_MOUNT}`)) {
270
- await sendBuiltFile(ctx, decodeURIComponent(path.slice(BUILD_MOUNT.length + 1)), res, buildBase);
269
+ await sendBuiltFile(ctx, decodeURIComponent(path.slice(BUILD_MOUNT.length + 1)), res);
271
270
  return true;
272
271
  }
273
272
  if (url.pathname.startsWith(`${ctx.fixtureMediaPath}/`)) {
@@ -279,8 +278,7 @@ async function sendTemplateFile(ctx, req, url, res, buildBase = `${ctx.base}${BU
279
278
  async function sendContentFile(ctx, req, url, res) {
280
279
  if (req.method !== "GET" && req.method !== "HEAD") throw new RequestError(405, `${url.pathname} only reads.`);
281
280
  const file = await ctx.host.contentFile(url.pathname);
282
- const buildBase = `${ctx.base}${url.pathname.slice(ctx.base.length).split("/").slice(0, 6).join("/")}/`;
283
- if (file === null || !await sendTemplateFile(ctx, req, new URL(file.url, url), res, buildBase)) sendText(res, 404, "not found");
281
+ if (file === null || !await sendTemplateFile(ctx, req, new URL(file.url, url), res)) sendText(res, 404, "not found");
284
282
  }
285
283
  async function sendVerdict(ctx, req, res) {
286
284
  if (req.method !== "POST") throw new RequestError(405, "POST to ask for the build's verdict.");
@@ -311,7 +309,7 @@ async function sendClientAsset(ctx, path, res) {
311
309
  sendBytes(res, contentTypeFor(file), await readFile(file));
312
310
  return true;
313
311
  }
314
- async function sendBuiltFile(ctx, filename, res, buildBase = `${ctx.base}${BUILD_MOUNT}`) {
312
+ async function sendBuiltFile(ctx, filename, res) {
315
313
  const view = await ctx.files.current();
316
314
  const at = await browserFilePath(ctx, view, filename).catch(() => null);
317
315
  const read = at === null ? null : await view.readBytes(builtTreePath(at)).catch(() => null);
@@ -320,7 +318,7 @@ async function sendBuiltFile(ctx, filename, res, buildBase = `${ctx.base}${BUILD
320
318
  return;
321
319
  }
322
320
  res.setHeader("cache-control", "no-cache");
323
- sendBytes(res, contentTypeFor(at), fillBuildFile(filename, read.bytes, buildBase).bytes);
321
+ sendBytes(res, contentTypeFor(at), read.bytes);
324
322
  }
325
323
  async function sendFixtureMedia(ctx, req, url, res) {
326
324
  if (req.method !== "GET" && req.method !== "HEAD") {
@@ -1,6 +1,5 @@
1
1
  import { assetContentType } from "../../template-artifact/dist/asset-mime.js";
2
2
  import { assetPath, boundFiles } from "../../template-artifact/dist/layout.js";
3
- import { fillBuildFile } from "../../static-assets-binding/dist/section-asset-url.js";
4
3
  import { pageTitle, siteHead } from "./head.js";
5
4
  import { renderPage } from "../../page-shell/dist/index.js";
6
5
 
@@ -28,7 +27,7 @@ async function siteFiles(input) {
28
27
  if (!input.siteUrl.endsWith("/")) throw new Error(`A site's address ends with "/", not "${input.siteUrl}".`);
29
28
  const buildDir = buildBase.slice(contentBase.length);
30
29
  const head = siteHead(input.head);
31
- const copy = await buildCopy(input, buildBase, buildDir);
30
+ const copy = await buildCopy(input, buildDir);
32
31
  const share = input.cover === null ? null : await shareImage(input, input.cover);
33
32
  const icoBytes = copy.byFilename.get(input.binding.icons.ico.filename);
34
33
  if (icoBytes === void 0) throw new Error(`the build's root icon ${input.binding.icons.ico.filename} was not copied`);
@@ -89,19 +88,18 @@ function siteBoundEntries(binding, analytics) {
89
88
  icon(apple_touch)
90
89
  ];
91
90
  }
92
- async function buildCopy(input, buildBase, buildDir) {
91
+ async function buildCopy(input, buildDir) {
93
92
  const { binding } = input;
94
93
  if (binding.analytics === null) throw new Error("The binding is an image or a document template's (it names no visit beacon): a site is made from a website's build.");
95
94
  if (Object.keys(binding.islands).length > 0 && (binding.island_runtime === null || binding.react_vendor === null || binding.react_vendor_core === null)) throw new Error("The binding has islands but names no island runtime, React vendor or vendor core.");
96
95
  const pathOf = new Map(boundFiles(binding).map((file) => [file.filename, file.path]));
97
- const named = /* @__PURE__ */ new Set([...input.pages.flatMap((page) => page.buildFiles), ...binding.relative_assets ?? []]);
96
+ const named = /* @__PURE__ */ new Set([...input.pages.flatMap((page) => page.buildFiles), ...binding.relative_assets]);
98
97
  const bound = await Promise.all(siteBoundEntries(binding, input.analytics).map(async ({ ref, contentType }) => {
99
- const raw = await input.readBuildFile(pathOf.get(ref.filename));
100
98
  return {
101
99
  path: `${buildDir}${ref.filename}`,
102
100
  contentType,
103
101
  immutable: true,
104
- bytes: fillBuildBytes(ref.filename, raw, buildBase, named)
102
+ bytes: await input.readBuildFile(pathOf.get(ref.filename))
105
103
  };
106
104
  }));
107
105
  const copied = new Set(bound.map((file) => file.path.slice(buildDir.length)));
@@ -117,11 +115,6 @@ async function buildCopy(input, buildBase, buildDir) {
117
115
  byFilename: new Map(files.map((file) => [file.path.slice(buildDir.length), file.bytes]))
118
116
  };
119
117
  }
120
- function fillBuildBytes(filename, raw, buildBase, named) {
121
- const filled = fillBuildFile(filename, raw, buildBase);
122
- for (const file of filled.files) named.add(file);
123
- return filled.bytes;
124
- }
125
118
  async function shareImage(input, cover) {
126
119
  const bytes = await input.cutShareImage(await cover.read(), {
127
120
  width: SHARE_IMAGE.width,
@@ -26,7 +26,7 @@ const StaticAssetsBindingSchema = z.object({
26
26
  png: z.record(z.string(), StaticAssetRefSchema),
27
27
  apple_touch: StaticAssetRefSchema
28
28
  }),
29
- relative_assets: z.array(z.string().min(1)).optional()
29
+ relative_assets: z.array(z.string().min(1))
30
30
  }).strict();
31
31
 
32
32
  //#endregion
@@ -11,7 +11,6 @@ function sectionAssetPrefix(profile) {
11
11
  switch (profile.kind) {
12
12
  case "canonical": return SECTION_ASSET_PREFIX;
13
13
  case "underBuildBase": return checkBuildBase(profile.buildBase);
14
- case "stylesheet": return "";
15
14
  }
16
15
  }
17
16
  function fillSectionAssetRefs(text, profile) {
@@ -25,37 +24,6 @@ function fillSectionAssetRefs(text, profile) {
25
24
  files: [...files]
26
25
  };
27
26
  }
28
- const STYLESHEET_RE = /\.css$/i;
29
- const SCRIPT_RE = /\.(mjs|js)$/i;
30
- function carriesFixedAddresses(filename) {
31
- return STYLESHEET_RE.test(filename) || SCRIPT_RE.test(filename);
32
- }
33
- function fillBuildFileText(filename, text, buildBase) {
34
- if (STYLESHEET_RE.test(filename)) return fillSectionAssetRefs(text, { kind: "stylesheet" });
35
- if (SCRIPT_RE.test(filename)) return fillSectionAssetRefs(text, {
36
- kind: "underBuildBase",
37
- buildBase
38
- });
39
- return {
40
- text,
41
- files: []
42
- };
43
- }
44
- function fillBuildFile(filename, bytes, buildBase) {
45
- if (!carriesFixedAddresses(filename)) return {
46
- bytes,
47
- files: []
48
- };
49
- const filled = fillBuildFileText(filename, new TextDecoder().decode(bytes), buildBase);
50
- if (filled.files.length === 0) return {
51
- bytes,
52
- files: []
53
- };
54
- return {
55
- bytes: new TextEncoder().encode(filled.text),
56
- files: filled.files
57
- };
58
- }
59
27
 
60
28
  //#endregion
61
- export { SECTION_ASSET_PREFIX, carriesFixedAddresses, fillBuildFile, fillSectionAssetRefs, sectionAssetPrefix };
29
+ export { SECTION_ASSET_PREFIX, fillSectionAssetRefs, sectionAssetPrefix };
@@ -93,7 +93,7 @@ function boundFiles(binding) {
93
93
  path: assetPath(filename),
94
94
  filename
95
95
  });
96
- for (const filename of binding.relative_assets ?? []) out.push({
96
+ for (const filename of binding.relative_assets) out.push({
97
97
  path: assetPath(filename),
98
98
  filename
99
99
  });
@@ -209,11 +209,11 @@ function verifyBuild(files, stored = /* @__PURE__ */ new Map()) {
209
209
  path: clash.paths[1],
210
210
  message: `is a browser file named ${clash.filename}, as ${clash.paths.filter((p) => p !== clash.paths[1]).join(" and ")} is: a build's browser files have one name each`
211
211
  });
212
- if (binding.value.relative_assets !== void 0) for (const file of bound) {
212
+ for (const file of bound) {
213
213
  const bytes = files.get(file.path);
214
214
  if (bytes !== void 0 && BUILD_TEXT.test(file.path) && new TextDecoder().decode(bytes).includes("/section-assets/")) problems.push({
215
215
  path: file.path,
216
- message: `names an asset by the fixed address ${ASSET_URL_PREFIX}, which a build whose binding lists relative_assets never writes`
216
+ message: `names an asset by the fixed address ${ASSET_URL_PREFIX}, which no stylesheet or script of a build may`
217
217
  });
218
218
  }
219
219
  for (const path of files.keys()) {
@@ -44,7 +44,7 @@ const CHECK_STAGES = [
44
44
  },
45
45
  {
46
46
  id: "render",
47
- summary: "Every placed instance renders over every fixture and synthesized empty: deterministic, free of defects, and fully marked for the editor."
47
+ summary: "Every placed instance renders over every fixture, synthesized empty and synthesized display case: deterministic, free of defects, and fully marked for the editor."
48
48
  },
49
49
  {
50
50
  id: "bundles",
@@ -171,7 +171,7 @@ Every placed section's schema and fill spec satisfy the contract assertions publ
171
171
 
172
172
  ## render
173
173
 
174
- Every placed instance renders over every fixture and synthesized empty: deterministic, free of defects, and fully marked for the editor.
174
+ Every placed instance renders over every fixture, synthesized empty and synthesized display case: deterministic, free of defects, and fully marked for the editor.
175
175
 
176
176
  | Rule | Venue | What it requires |
177
177
  |---|---|---|
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homepages/concrete",
3
- "version": "14.1.0",
3
+ "version": "14.2.0",
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",