@homepages/concrete 6.0.0 → 6.1.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 +46 -0
- package/codemods/manifest.json +8 -0
- package/dist/artifact/playground/client/assets/index-Cqz-jjVw.js +1101 -0
- package/dist/artifact/playground/client/index.html +1 -1
- package/dist/css/inline.js +3 -6
- package/dist/packages/external/concrete/package.js +1 -1
- package/dist/platform/paths.js +5 -1
- package/dist/schema/define-schema.js +31 -5
- package/dist/schema/extract-fill-spec.js +8 -4
- package/dist/schema/fill-builders.d.ts +6 -4
- package/dist/schema/fill-declaration.js +5 -1
- package/dist/schema/slot-ref.d.ts +1 -1
- package/package.json +1 -1
- package/dist/artifact/playground/client/assets/index-u3T7DiSN.js +0 -1101
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="utf-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
6
|
<title>Playground</title>
|
|
7
|
-
<script type="module" crossorigin src="./assets/index-
|
|
7
|
+
<script type="module" crossorigin src="./assets/index-Cqz-jjVw.js"></script>
|
|
8
8
|
<link rel="stylesheet" crossorigin href="./assets/index-CckS2ONm.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|
package/dist/css/inline.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { externalSpecifier } from "../platform/paths.js";
|
|
2
|
-
import { basename, extname,
|
|
1
|
+
import { externalSpecifier, isFileSpecifier } from "../platform/paths.js";
|
|
2
|
+
import { basename, extname, join } from "node:path";
|
|
3
3
|
import { build } from "esbuild";
|
|
4
4
|
|
|
5
5
|
//#region src/css/inline.ts
|
|
@@ -27,16 +27,13 @@ const ASSET_MIME = {
|
|
|
27
27
|
".pdf": "application/pdf",
|
|
28
28
|
".zip": "application/zip"
|
|
29
29
|
};
|
|
30
|
-
const REMOTE_RE = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
|
|
31
30
|
function importRulePlugin() {
|
|
32
31
|
return {
|
|
33
32
|
name: "concrete-css-inline",
|
|
34
33
|
setup(api) {
|
|
35
34
|
api.onResolve({ filter: /.*/ }, (args) => {
|
|
36
35
|
if (args.kind !== "import-rule") return void 0;
|
|
37
|
-
|
|
38
|
-
if (args.path.startsWith(".") || isAbsolute(args.path)) return void 0;
|
|
39
|
-
return externalSpecifier(args.path);
|
|
36
|
+
return isFileSpecifier(args.path) ? void 0 : externalSpecifier(args.path);
|
|
40
37
|
});
|
|
41
38
|
}
|
|
42
39
|
};
|
package/dist/platform/paths.js
CHANGED
|
@@ -29,6 +29,10 @@ function withoutRoot(text, root, paths = nodePath) {
|
|
|
29
29
|
function normalizePosix(path) {
|
|
30
30
|
return nodePath.posix.normalize(path);
|
|
31
31
|
}
|
|
32
|
+
function isFileSpecifier(specifier, paths = nodePath) {
|
|
33
|
+
if (specifier.startsWith("//")) return false;
|
|
34
|
+
return specifier.startsWith(".") || paths.isAbsolute(specifier);
|
|
35
|
+
}
|
|
32
36
|
function externalFile(file) {
|
|
33
37
|
return {
|
|
34
38
|
path: pathToFileURL(file).href,
|
|
@@ -59,4 +63,4 @@ function packageFile(source, built) {
|
|
|
59
63
|
}
|
|
60
64
|
|
|
61
65
|
//#endregion
|
|
62
|
-
export { RUNNING_FROM_SOURCE, externalFile, externalSpecifier, isInsideRoot, isWorkspaceFile, normalizePosix, packageFile, packageRoot, replaceRoot, resolveRoot, toPosix, underNodeModules, withoutRoot, workspacePath };
|
|
66
|
+
export { RUNNING_FROM_SOURCE, externalFile, externalSpecifier, isFileSpecifier, isInsideRoot, isWorkspaceFile, normalizePosix, packageFile, packageRoot, replaceRoot, resolveRoot, toPosix, underNodeModules, withoutRoot, workspacePath };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { COMPUTED, isComputeBinding } from "./compute.js";
|
|
2
2
|
import { isFillBinding } from "./fill-builders.js";
|
|
3
|
-
import { fillMark } from "./fill-declaration.js";
|
|
3
|
+
import { FILL, FILL_SECTION, fillMark, getFill } from "./fill-declaration.js";
|
|
4
4
|
import { groupsFromLayout } from "./layout.js";
|
|
5
|
-
import { isSiblingSlot, serializeRef } from "./slot-ref.js";
|
|
5
|
+
import { isSiblingSlot, isSlotRef, serializeRef } from "./slot-ref.js";
|
|
6
6
|
|
|
7
7
|
//#region src/schema/define-schema.ts
|
|
8
8
|
function derivedSource(transform, reads) {
|
|
@@ -29,6 +29,24 @@ function siblingResolver(sectionKey, slots) {
|
|
|
29
29
|
};
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
|
+
function resolveFillReads(at, slot, resolveReads) {
|
|
33
|
+
const binding = getFill(slot);
|
|
34
|
+
const reads = binding?.reads;
|
|
35
|
+
if (binding === void 0 || reads === void 0 || !reads.some(isSiblingSlot)) return slot;
|
|
36
|
+
const resolved = resolveReads(at, reads) ?? [];
|
|
37
|
+
const upstream = resolved[reads.findIndex((read) => isSiblingSlot(read) && read.source !== void 0)];
|
|
38
|
+
if (upstream !== void 0 && isSlotRef(upstream)) throw new Error(`\`${at}\` is filled and reads its sibling slot "${upstream.slot}", which is sourced — a fact, a \`compute()\` or another slot settles it, not a fill. A sourced value settles at finalize, AFTER every fill has run, so the fill would read nothing. Read the refs that slot reads instead, or read a slot a fill writes.`);
|
|
39
|
+
const sibling = resolved[reads.findIndex(isSiblingSlot)];
|
|
40
|
+
const section = sibling !== void 0 && isSlotRef(sibling) ? sibling.section : void 0;
|
|
41
|
+
return {
|
|
42
|
+
...slot,
|
|
43
|
+
[FILL]: {
|
|
44
|
+
...binding,
|
|
45
|
+
reads: resolved,
|
|
46
|
+
[FILL_SECTION]: section
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
32
50
|
function emitDisplay(display, computed) {
|
|
33
51
|
const out = {};
|
|
34
52
|
for (const key of ["visibility", "variant"]) {
|
|
@@ -36,9 +54,9 @@ function emitDisplay(display, computed) {
|
|
|
36
54
|
if (entry === void 0) continue;
|
|
37
55
|
const emitted = { cases: [...entry.cases] };
|
|
38
56
|
if (entry.locked === true) emitted.locked = true;
|
|
57
|
+
const sibling = entry.source?.reads?.find(isSiblingSlot);
|
|
58
|
+
if (sibling !== void 0) throw new Error(`\`display.${key}\` reads the section's own slot "${sibling.label}". A display entry settles which of the section's slots exist, so it may read facts and other sections only.`);
|
|
39
59
|
if (isComputeBinding(entry.source)) {
|
|
40
|
-
const sibling = entry.source.reads?.find(isSiblingSlot);
|
|
41
|
-
if (sibling !== void 0) throw new Error(`\`display.${key}\` reads the section's own slot "${sibling.label}". A display entry settles which of the section's slots exist, so it may read facts and other sections only.`);
|
|
42
60
|
computed[`display.${key}`] = entry.source.fn;
|
|
43
61
|
emitted.source = derivedSource(`display.${key}`, entry.source.reads);
|
|
44
62
|
} else if (isFillBinding(entry.source)) emitted.fill = {
|
|
@@ -61,7 +79,15 @@ function defineSchema(input) {
|
|
|
61
79
|
const slots = {};
|
|
62
80
|
const resolveReads = siblingResolver(input.key, input.slots);
|
|
63
81
|
for (const [key, slot] of Object.entries(input.slots)) {
|
|
64
|
-
let emitted = slot;
|
|
82
|
+
let emitted = resolveFillReads(key, slot, resolveReads);
|
|
83
|
+
const fields = emitted.fields;
|
|
84
|
+
if (emitted.type === "list" && fields !== void 0) {
|
|
85
|
+
const resolvedFields = Object.fromEntries(Object.entries(fields).map(([field, def]) => [field, resolveFillReads(`${key}.${field}`, def, resolveReads)]));
|
|
86
|
+
if (Object.keys(fields).some((field) => resolvedFields[field] !== fields[field])) emitted = {
|
|
87
|
+
...emitted,
|
|
88
|
+
fields: resolvedFields
|
|
89
|
+
};
|
|
90
|
+
}
|
|
65
91
|
if (isComputeBinding(slot.source)) {
|
|
66
92
|
computed[key] = slot.source.fn;
|
|
67
93
|
emitted = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DISPLAY_ENTRIES } from "../packages/internal/template-contracts/dist/slot-catalog.js";
|
|
2
|
-
import { getFill } from "./fill-declaration.js";
|
|
3
|
-
import { serializeRef } from "./slot-ref.js";
|
|
2
|
+
import { getFill, getFillSection } from "./fill-declaration.js";
|
|
3
|
+
import { isSiblingSlot, serializeRef } from "./slot-ref.js";
|
|
4
4
|
import { byCodeUnit } from "../platform/order.js";
|
|
5
5
|
import { plannerForField } from "../packages/internal/fill-vocabulary/dist/row-planners.js";
|
|
6
6
|
import { isListSlot, originationFor } from "../packages/internal/fill-vocabulary/dist/origination.js";
|
|
@@ -23,11 +23,15 @@ function optionsOf(binding) {
|
|
|
23
23
|
return out;
|
|
24
24
|
}
|
|
25
25
|
function serializedReads(reads) {
|
|
26
|
-
return (reads ?? []).map(
|
|
26
|
+
return (reads ?? []).map((read) => {
|
|
27
|
+
if (isSiblingSlot(read)) throw new Error(`fillSpecFromSchema: a fill reads the slot "${read.label}" by its const, which only a section declared with \`section()\` resolves — read another section's slot through its ref (\`Section.slots.<key>\`).`);
|
|
28
|
+
return serializeRef(read);
|
|
29
|
+
});
|
|
27
30
|
}
|
|
28
31
|
function collectReads(into, binding) {
|
|
32
|
+
const ownSection = getFillSection(binding);
|
|
29
33
|
for (const read of serializedReads(binding?.reads)) if (read.kind === "fact") into.facts.add(read.key);
|
|
30
|
-
else into.slots.set(`${read.section} ${read.slot}`, read);
|
|
34
|
+
else if (read.section !== ownSection) into.slots.set(`${read.section} ${read.slot}`, read);
|
|
31
35
|
}
|
|
32
36
|
function editorPickedOrigin(slot) {
|
|
33
37
|
return slot.type === "poi";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ComputeRead } from "./slot-ref.js";
|
|
2
2
|
//#region src/schema/fill-builders.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* How many items a list fill produces.
|
|
@@ -50,10 +50,12 @@ type FillInput<Legal extends FillOptionName = FillOptionName> = {
|
|
|
50
50
|
readonly brief: string;
|
|
51
51
|
/**
|
|
52
52
|
* Exactly what the model sees beside the brief: fact refs (`fact.property.address`,
|
|
53
|
-
* `fact.description`)
|
|
54
|
-
*
|
|
53
|
+
* `fact.description`), slot refs of other sections (`Hero.slots.headline`), and a
|
|
54
|
+
* sibling slot of the same section by its own const — read the way a `compute()`
|
|
55
|
+
* reads one, and filled first. A pick's candidates come from the slot's own pool
|
|
56
|
+
* and need no read.
|
|
55
57
|
*/
|
|
56
|
-
readonly reads?: readonly
|
|
58
|
+
readonly reads?: readonly ComputeRead[];
|
|
57
59
|
} & { readonly [K in Legal]?: FillOptionTypes[K]; } & { readonly [K in Exclude<FillOptionName, Legal>]?: never; };
|
|
58
60
|
/**
|
|
59
61
|
* A fill as a slot's `source:` holds it — what `fill()` returns. `O` is the input
|
|
@@ -5,10 +5,14 @@ const FILL = Symbol.for("@homepages/concrete:fill:declaration");
|
|
|
5
5
|
function fillMark(source) {
|
|
6
6
|
return isFillBinding(source) ? { [FILL]: source } : {};
|
|
7
7
|
}
|
|
8
|
+
const FILL_SECTION = Symbol.for("@homepages/concrete:fill:section");
|
|
9
|
+
function getFillSection(binding) {
|
|
10
|
+
return binding?.[FILL_SECTION];
|
|
11
|
+
}
|
|
8
12
|
function getFill(slot) {
|
|
9
13
|
if (typeof slot !== "object" || slot === null) return void 0;
|
|
10
14
|
return slot[FILL];
|
|
11
15
|
}
|
|
12
16
|
|
|
13
17
|
//#endregion
|
|
14
|
-
export { FILL, fillMark, getFill };
|
|
18
|
+
export { FILL, FILL_SECTION, fillMark, getFill, getFillSection };
|
|
@@ -40,7 +40,7 @@ interface FactRef<Key extends string = string, Value = unknown> {
|
|
|
40
40
|
type Ref = FactRef | SlotRef;
|
|
41
41
|
/** A slot of the declaring section, named by its own const — see the module header. */
|
|
42
42
|
type SiblingSlot = Slot;
|
|
43
|
-
/** What a `compute`'s `reads` (and a mirror's `source:`) may name: any ref, or a sibling slot. */
|
|
43
|
+
/** What a `compute`'s or a fill's `reads` (and a mirror's `source:`) may name: any ref, or a sibling slot. */
|
|
44
44
|
type ComputeRead = Ref | SiblingSlot;
|
|
45
45
|
/** The value a ref refers to, read off the phantom member. */
|
|
46
46
|
type RefValue<R> = R extends {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@homepages/concrete",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.1.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",
|