@homepages/concrete 10.0.0 → 11.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 +29 -0
- package/codemods/manifest.json +5 -158
- package/dist/artifact/playground/client/assets/index-ByeGGedv.js +1259 -0
- package/dist/artifact/playground/client/assets/index-CxWPYOH2.css +1 -0
- package/dist/artifact/playground/client/index.html +2 -2
- package/dist/artifact/playground/client/island-canvas-host.mjs +1 -1
- package/dist/artifact/playground/host.mjs +26 -26
- package/dist/base.css +1 -8
- package/dist/cli/build/artifact.js +1 -1
- package/dist/cli/build/fixtures.js +3 -2
- package/dist/cli/check/stages/sections.js +1 -1
- package/dist/cli/dev/workspace-reader.js +3 -2
- package/dist/css/compile.js +3 -6
- package/dist/css/rules.js +1 -51
- package/dist/design-system/format-variants.js +1 -1
- package/dist/fixtures/resolve.js +5 -1
- package/dist/fixtures/rows.js +2 -2
- package/dist/index.d.ts +5 -5
- package/dist/packages/external/concrete/package.js +1 -1
- package/dist/packages/internal/fill-vocabulary/dist/holder.js +3 -14
- package/dist/packages/internal/media-resolution/dist/document.js +3 -3
- package/dist/packages/internal/media-resolution/dist/image.js +3 -3
- package/dist/packages/internal/media-resolution/dist/tour.js +6 -6
- package/dist/packages/internal/media-resolution/dist/video.js +9 -9
- package/dist/packages/internal/section-contracts/dist/fill-verb-contract.js +1 -0
- package/dist/packages/internal/section-contracts/dist/runners.js +1 -3
- package/dist/packages/internal/section-contracts/dist/source-contract.js +3 -3
- package/dist/packages/internal/section-contracts/dist/sources-contract.js +0 -2
- package/dist/packages/internal/template-artifact/dist/index.js +2 -2
- package/dist/packages/internal/template-artifact/dist/layout.js +11 -11
- package/dist/packages/internal/template-artifact/dist/manifest.js +1 -1
- package/dist/packages/internal/template-artifact/dist/verify.js +13 -17
- package/dist/packages/internal/template-contracts/dist/document-value.d.ts +3 -5
- package/dist/packages/internal/template-contracts/dist/fill-builders.js +2 -6
- package/dist/packages/internal/template-contracts/dist/fill-spec-schema.js +4 -1
- package/dist/packages/internal/template-contracts/dist/list.js +0 -14
- package/dist/packages/internal/template-contracts/dist/primitive-descriptors.js +1 -1
- package/dist/packages/internal/template-contracts/dist/runtime-values.d.ts +6 -7
- package/dist/packages/internal/template-contracts/dist/slot-builders.js +0 -2
- package/dist/packages/internal/template-contracts/dist/slot-ref.d.ts +6 -1
- package/dist/packages/internal/template-contracts/dist/tour-value.d.ts +2 -4
- package/dist/packages/internal/template-contracts/dist/video-value.d.ts +3 -4
- package/dist/primitives/Image.d.ts +2 -2
- package/dist/primitives/Tour.d.ts +2 -2
- package/dist/primitives/Video.d.ts +2 -2
- package/dist/primitives/slot-bindings.js +6 -13
- package/dist/primitives/slot-document.d.ts +1 -1
- package/dist/primitives/slot-download.d.ts +3 -1
- package/dist/primitives/slot-media.d.ts +5 -2
- package/dist/primitives/slot-media.js +1 -1
- package/dist/rules/registry.js +0 -6
- package/dist/schema/format-presets.d.ts +1 -1
- package/dist/schema/section-schema.d.ts +5 -5
- package/dist/styles.css +4 -4
- package/dist/template/define-template.js +0 -1
- package/guide/reference/cli/INDEX.md +2 -2
- package/guide/reference/cli/build.md +1 -1
- package/guide/reference/cli/check.md +1 -1
- package/guide/reference/cli/dev.md +1 -1
- package/guide/reference/cli/property-add.md +1 -1
- package/guide/reference/cli/property-list.md +1 -1
- package/guide/reference/cli/publish.md +1 -1
- package/guide/reference/cli/upgrade.md +1 -1
- package/guide/reference/rules/INDEX.md +1 -2
- package/package.json +2 -2
- package/codemods/fill-is-a-source.mjs +0 -533
- package/codemods/framework-namespace.mjs +0 -107
- package/codemods/list-grammar.mjs +0 -923
- package/codemods/object-form-only.mjs +0 -39
- package/codemods/platform-namespace.mjs +0 -83
- package/codemods/process-builders.mjs +0 -198
- package/codemods/reads-replace-reconcile.mjs +0 -285
- package/codemods/registry-keys-only.mjs +0 -113
- package/codemods/slot-object.mjs +0 -1097
- package/codemods/steps/content-object-fields.mjs +0 -324
- package/codemods/steps/list-object-form.mjs +0 -686
- package/codemods/steps/registry-key-reads.mjs +0 -276
- package/codemods/steps/select-object-form.mjs +0 -210
- package/codemods/table-rows.mjs +0 -568
- package/codemods/theme-collapse.mjs +0 -396
- package/codemods/unlayer-author-css.mjs +0 -194
- package/codemods/unwrap-object-fields.mjs +0 -310
- package/codemods/viewer-slot-document.mjs +0 -131
- package/codemods/write-property-as-facts-document.mjs +0 -716
- package/codemods/write-the-address-line.mjs +0 -255
- package/codemods/write-the-registry-members.mjs +0 -653
- package/codemods/write-the-select-from.mjs +0 -141
- package/codemods/write-the-sole-from.mjs +0 -369
- package/codemods/write-the-table-from.mjs +0 -267
- package/codemods/write-the-whole-item.mjs +0 -512
- package/codemods/writeback-drop.mjs +0 -168
- package/codemods/written-contact-address.mjs +0 -162
- package/codemods/written-media-category.mjs +0 -227
- package/codemods/written-ref-kinds-name-the-layer.mjs +0 -172
- package/codemods/written-uploads-replace-pool-reads.mjs +0 -454
- package/codemods/written-uploads-sort-into-lists.mjs +0 -405
- package/codemods/written-uploads-stated-in-sorted-lists.mjs +0 -295
- package/codemods/written-video-sources-drop.mjs +0 -144
- package/codemods/written-without-pick-none.mjs +0 -146
- package/codemods/written-without-retired-knowledge.mjs +0 -223
- package/codemods/written-without-the-media-key.mjs +0 -202
- package/codemods/written-without-the-property-type.mjs +0 -249
- package/dist/artifact/playground/client/assets/index-BFNHB7VM.css +0 -1
- package/dist/artifact/playground/client/assets/index-Div1yo6s.js +0 -1259
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
// 10.0.0 — a section reads a property's facts by their registry keys alone.
|
|
2
|
-
//
|
|
3
|
-
// 9.x typed flat spellings beside the registry's: `fact.description`,
|
|
4
|
-
// `fact.contact.<member>` and `fact.unit.<member>` (hinted at by
|
|
5
|
-
// `sections/legacy-fact-key`, with the rewrite shipped as a codemod step), and the
|
|
6
|
-
// address's parts as `fact.property.address_street`, `_unit`, `_city`, `_state`,
|
|
7
|
-
// `_postal`, `fact.property.latitude` and `fact.property.longitude`. This release removes
|
|
8
|
-
// every one, so a section reading one fails to typecheck, and drops the public types
|
|
9
|
-
// nothing reads any more: `FactsAddress`, `ComparableRow`, `Narrative` and
|
|
10
|
-
// `DirectFactRef`.
|
|
11
|
-
//
|
|
12
|
-
// What this codemod does, in one pass over the workspace:
|
|
13
|
-
//
|
|
14
|
-
// - runs the step, `steps/registry-key-reads.mjs`: the description becomes
|
|
15
|
-
// `fact.property.description`, and a contact's or a unit's member is read through a
|
|
16
|
-
// locked row of its table, declared once per section;
|
|
17
|
-
// - then reads each address part off the address, in every `.ts` and `.tsx` that
|
|
18
|
-
// imports `fact` from the package: `fact.property.address_street` becomes
|
|
19
|
-
// `fact.property.address.street`, `fact.property.latitude`
|
|
20
|
-
// `fact.property.address.latitude`, and so on for each part.
|
|
21
|
-
//
|
|
22
|
-
// What it leaves to you is what the step reports, per file, and what no rewrite can
|
|
23
|
-
// make: a part reads `null` where the flat spelling read `""`, so a `compute()` over one
|
|
24
|
-
// may need its body changed, which the typecheck names; and the removed types, named
|
|
25
|
-
// otherwise (an address `AddressValue`, a comparable a `compute()` reads
|
|
26
|
-
// `FactsComparable`).
|
|
27
|
-
|
|
28
|
-
import { readdir, readFile, writeFile } from "node:fs/promises";
|
|
29
|
-
import { join, relative, sep } from "node:path";
|
|
30
|
-
|
|
31
|
-
import ts from "typescript";
|
|
32
|
-
|
|
33
|
-
import registryKeyReads from "./steps/registry-key-reads.mjs";
|
|
34
|
-
|
|
35
|
-
const CONCRETE = "@homepages/concrete";
|
|
36
|
-
|
|
37
|
-
const EXTENSIONS = [".ts", ".tsx"];
|
|
38
|
-
const SKIP_DIRS = new Set(["node_modules", ".concrete", ".git", "dist", "build"]);
|
|
39
|
-
|
|
40
|
-
/** Each flat address spelling and the address part it read. */
|
|
41
|
-
const ADDRESS_PARTS = {
|
|
42
|
-
address_street: "street",
|
|
43
|
-
address_unit: "unit",
|
|
44
|
-
address_city: "city",
|
|
45
|
-
address_state: "state",
|
|
46
|
-
address_postal: "postal",
|
|
47
|
-
latitude: "latitude",
|
|
48
|
-
longitude: "longitude",
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
async function sourceFiles(root) {
|
|
52
|
-
const found = [];
|
|
53
|
-
async function walk(dir) {
|
|
54
|
-
for (const entry of await readdir(dir, { withFileTypes: true })) {
|
|
55
|
-
if (entry.isDirectory()) {
|
|
56
|
-
if (!SKIP_DIRS.has(entry.name)) await walk(join(dir, entry.name));
|
|
57
|
-
} else if (EXTENSIONS.some((ext) => entry.name.endsWith(ext)) && !entry.name.endsWith(".d.ts")) {
|
|
58
|
-
found.push(join(dir, entry.name));
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
await walk(root);
|
|
63
|
-
return found.sort();
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/** `text` with each flat address read respelled as a read of its part, or `null` when it has none. */
|
|
67
|
-
function addressParts(text, file) {
|
|
68
|
-
if (!text.includes(CONCRETE)) return null;
|
|
69
|
-
const sf = ts.createSourceFile(file, text, ts.ScriptTarget.Latest, true, file.endsWith(".tsx") ? ts.ScriptKind.TSX : ts.ScriptKind.TS);
|
|
70
|
-
let factName;
|
|
71
|
-
for (const statement of sf.statements) {
|
|
72
|
-
if (!ts.isImportDeclaration(statement) || !ts.isStringLiteral(statement.moduleSpecifier) || statement.moduleSpecifier.text !== CONCRETE) continue;
|
|
73
|
-
const bindings = statement.importClause?.namedBindings;
|
|
74
|
-
if (bindings === undefined || !ts.isNamedImports(bindings)) continue;
|
|
75
|
-
for (const element of bindings.elements) if ((element.propertyName ?? element.name).text === "fact") factName = element.name.text;
|
|
76
|
-
}
|
|
77
|
-
if (factName === undefined) return null;
|
|
78
|
-
|
|
79
|
-
const edits = [];
|
|
80
|
-
const visit = (node) => {
|
|
81
|
-
if (
|
|
82
|
-
ts.isPropertyAccessExpression(node) &&
|
|
83
|
-
Object.hasOwn(ADDRESS_PARTS, node.name.text) &&
|
|
84
|
-
ts.isPropertyAccessExpression(node.expression) &&
|
|
85
|
-
node.expression.name.text === "property" &&
|
|
86
|
-
ts.isIdentifier(node.expression.expression) &&
|
|
87
|
-
node.expression.expression.text === factName
|
|
88
|
-
) {
|
|
89
|
-
edits.push({ start: node.name.getStart(sf), end: node.name.getEnd(), text: `address.${ADDRESS_PARTS[node.name.text]}` });
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
ts.forEachChild(node, visit);
|
|
93
|
-
};
|
|
94
|
-
visit(sf);
|
|
95
|
-
if (edits.length === 0) return null;
|
|
96
|
-
let out = text;
|
|
97
|
-
for (const edit of edits.sort((a, b) => b.start - a.start)) out = out.slice(0, edit.start) + edit.text + out.slice(edit.end);
|
|
98
|
-
return out;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/** @param {string} root @returns {Promise<{rewritten: string[], notRewritten: {file: string, reason: string}[]}>} */
|
|
102
|
-
export default async function registryKeysOnly(root) {
|
|
103
|
-
const report = await registryKeyReads(root);
|
|
104
|
-
const rewritten = new Set(report.rewritten);
|
|
105
|
-
for (const path of await sourceFiles(root)) {
|
|
106
|
-
const text = await readFile(path, "utf8");
|
|
107
|
-
const out = addressParts(text, path);
|
|
108
|
-
if (out === null) continue;
|
|
109
|
-
await writeFile(path, out, "utf8");
|
|
110
|
-
rewritten.add(relative(root, path).split(sep).join("/"));
|
|
111
|
-
}
|
|
112
|
-
return { rewritten: [...rewritten].sort(), notRewritten: report.notRewritten };
|
|
113
|
-
}
|