@homepages/concrete 5.0.0 → 6.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 +336 -0
- package/README.md +28 -17
- package/codemods/fill-is-a-source.mjs +533 -0
- package/codemods/manifest.json +12 -0
- package/codemods/reads-replace-reconcile.mjs +285 -0
- package/dist/artifact/playground/client/assets/{index-D1fwOGVK.js → index-u3T7DiSN.js} +96 -96
- package/dist/artifact/playground/client/index.html +1 -1
- package/dist/artifact/playground/host.mjs +23 -23
- package/dist/base.css +3 -8
- package/dist/browser/site-config.js +1 -16
- package/dist/browser/submit-lead.js +0 -31
- package/dist/cli/build/artifact.js +16 -23
- package/dist/cli/build/captures.js +0 -6
- package/dist/cli/build/esbuild.js +0 -17
- package/dist/cli/build/fixtures.js +15 -30
- package/dist/cli/build/icons.js +0 -3
- package/dist/cli/build/index.js +1 -1
- package/dist/cli/build/playground.js +4 -8
- package/dist/cli/build/sections.js +9 -30
- package/dist/cli/build/source.js +52 -27
- package/dist/cli/build/static.js +4 -25
- package/dist/cli/capture/bundle.js +0 -9
- package/dist/cli/capture/capture-browser.js +0 -14
- package/dist/cli/capture/capture.js +1 -8
- package/dist/cli/check/analyze.js +2 -5
- package/dist/cli/check/index.js +1 -1
- package/dist/cli/check/line-endings.js +52 -0
- package/dist/cli/check/load-workspace.js +3 -8
- package/dist/cli/check/portable-names.js +48 -0
- package/dist/cli/check/render/class-conflicts.js +0 -5
- package/dist/cli/check/render/html.js +0 -1
- package/dist/cli/check/render/invariants.js +0 -5
- package/dist/cli/check/render/island-frames.js +0 -25
- package/dist/cli/check/render/marker-coverage.js +0 -20
- package/dist/cli/check/render/nav.js +0 -33
- package/dist/cli/check/report.js +0 -3
- package/dist/cli/check/stages/bundles.js +1 -9
- package/dist/cli/check/stages/composition.js +3 -2
- package/dist/cli/check/stages/dependencies.js +7 -38
- package/dist/cli/check/stages/fixtures.js +3 -31
- package/dist/cli/check/stages/lint.js +2 -2
- package/dist/cli/check/stages/logic.js +3 -34
- package/dist/cli/check/stages/relations.js +46 -0
- package/dist/cli/check/stages/render.js +0 -1
- package/dist/cli/check/stages/sections.js +3 -3
- package/dist/cli/check/stages/stylesheet.js +1 -1
- package/dist/cli/check/stages/typecheck.js +5 -11
- package/dist/cli/check/stages/workspace.js +36 -14
- package/dist/cli/commands.js +9 -56
- package/dist/cli/currency/cache.js +4 -17
- package/dist/cli/currency/decide.js +0 -14
- package/dist/cli/currency/opt-out.js +0 -7
- package/dist/cli/currency/preamble.js +3 -24
- package/dist/cli/currency/prompt.js +0 -1
- package/dist/cli/currency/refresh.js +5 -12
- package/dist/cli/currency/resolve-latest.js +3 -64
- package/dist/cli/currency/version-order.js +0 -12
- package/dist/cli/dev/crop.js +0 -2
- package/dist/cli/dev/http.js +0 -13
- package/dist/cli/dev/index.js +3 -4
- package/dist/cli/dev/islands.js +25 -70
- package/dist/cli/dev/listen.js +26 -0
- package/dist/cli/dev/load-template.js +0 -1
- package/dist/cli/dev/request-error.js +0 -4
- package/dist/cli/dev/server.js +46 -52
- package/dist/cli/dev/tsconfig-paths.js +0 -13
- package/dist/cli/dev/vite.js +9 -38
- package/dist/cli/dev/workspace-reader.js +4 -34
- package/dist/cli/media/cache.js +4 -51
- package/dist/cli/media/derive.js +2 -94
- package/dist/cli/media/deriver-plugin.js +0 -2
- package/dist/cli/media/frame-rung-floor.js +0 -6
- package/dist/cli/property/index.js +0 -4
- package/dist/cli/property/library.js +6 -24
- package/dist/cli/publish/client.js +0 -1
- package/dist/cli/publish/freshness.js +0 -2
- package/dist/cli/publish/git.js +2 -8
- package/dist/cli/publish/index.js +8 -15
- package/dist/cli/publish/pack.js +5 -6
- package/dist/cli/publish/report.js +0 -6
- package/dist/cli/publish/target.js +16 -13
- package/dist/cli/publish/wire.js +0 -6
- package/dist/cli/tar.js +2 -9
- package/dist/cli/upgrade/codemod.js +0 -8
- package/dist/cli/upgrade/index.js +0 -24
- package/dist/cli/upgrade/manifest.js +0 -12
- package/dist/cli/upgrade/plan.js +0 -17
- package/dist/cli/upgrade/stage.js +12 -15
- package/dist/cli/version.js +0 -8
- package/dist/cli/workspace.js +2 -34
- package/dist/cli.js +4 -21
- package/dist/css/compile.js +25 -28
- package/dist/css/graph.js +3 -10
- package/dist/css/inline.js +3 -13
- package/dist/css/rules.js +6 -43
- package/dist/design-system/format-variants.js +0 -22
- package/dist/eslint/authoring.js +0 -2
- package/dist/eslint/correctness.js +0 -7
- package/dist/eslint/rules/editor-reason.js +0 -11
- package/dist/eslint/rules/island-ids.js +0 -1
- package/dist/eslint/rules/jsx-visitor.js +0 -13
- package/dist/eslint/rules/no-editor-globals.js +0 -2
- package/dist/eslint/rules/no-raw-values.js +0 -1
- package/dist/fixtures/brand.js +0 -1
- package/dist/fixtures/bundle-rule.js +4 -9
- package/dist/fixtures/canonical.d.ts +20 -0
- package/dist/fixtures/image-dimensions.js +0 -1
- package/dist/fixtures/load.js +8 -17
- package/dist/fixtures/media-plugin.js +4 -31
- package/dist/fixtures/media.js +0 -21
- package/dist/fixtures/package-stylesheets.js +0 -6
- package/dist/fixtures/property.js +16 -15
- package/dist/fixtures/resolve.js +102 -29
- package/dist/fixtures/rows.js +12 -11
- package/dist/fixtures/synthesize-empties.js +0 -4
- package/dist/fixtures.d.ts +19 -4
- package/dist/fixtures.js +0 -18
- package/dist/index.d.ts +8 -9
- package/dist/index.js +2 -11
- package/dist/islands/client-module.js +0 -11
- package/dist/islands/marker.js +0 -33
- package/dist/node_modules/.pnpm/fflate@0.8.3/node_modules/fflate/esm/browser.js +0 -20
- package/dist/packages/external/concrete/package.js +1 -1
- package/dist/packages/internal/fill-bake/dist/bake-property-ref.js +21 -35
- package/dist/packages/internal/fill-bake/dist/compute-reads.js +4 -0
- package/dist/packages/internal/fill-bake/dist/derive-source.js +40 -0
- package/dist/packages/internal/fill-bake/dist/display.js +0 -1
- package/dist/packages/internal/fill-bake/dist/index.js +4 -4
- package/dist/packages/internal/fill-vocabulary/dist/origination.js +106 -0
- package/dist/packages/internal/fill-vocabulary/dist/row-planners.js +1 -49
- package/dist/packages/internal/format-geometry/dist/capture.js +10 -240
- package/dist/packages/internal/format-geometry/dist/geometry.js +0 -6
- package/dist/packages/internal/image-ladder/dist/crop.js +0 -12
- package/dist/packages/internal/image-ladder/dist/policy.js +0 -14
- package/dist/packages/internal/island-runtime/dist/capture-holds.js +0 -13
- package/dist/packages/internal/island-runtime/dist/contract.js +0 -34
- package/dist/packages/internal/island-runtime/dist/editor-instance-context.js +0 -1
- package/dist/packages/internal/island-runtime/dist/index.js +0 -34
- package/dist/packages/internal/island-runtime/dist/island-id-context.js +0 -1
- package/dist/packages/internal/island-runtime/dist/use-capture-ready.js +0 -15
- package/dist/packages/internal/island-runtime/dist/use-editor.js +0 -10
- package/dist/packages/internal/island-runtime/dist/use-island-id.js +0 -32
- package/dist/packages/internal/property-facts/dist/derive-facts-view.js +2 -17
- package/dist/packages/internal/property-facts/dist/index.js +1 -1
- package/dist/packages/internal/property-facts/dist/{property-facts-CSdkSuD7.js → property-facts-5pxZnlkh.js} +13 -2
- package/dist/packages/internal/section-contracts/dist/cap-contract.js +1 -18
- package/dist/packages/internal/section-contracts/dist/catalog.js +16 -8
- package/dist/packages/internal/section-contracts/dist/choose-select-contract.js +12 -16
- package/dist/packages/internal/section-contracts/dist/count-bounds-contract.js +5 -11
- package/dist/packages/internal/section-contracts/dist/display-contract.js +2 -0
- package/dist/packages/internal/section-contracts/dist/display-evidence-contract.js +2 -8
- package/dist/packages/internal/section-contracts/dist/fill-spec-view.js +13 -0
- package/dist/packages/internal/section-contracts/dist/index.js +2 -1
- package/dist/packages/internal/section-contracts/dist/interpolation-contract.js +16 -42
- package/dist/packages/internal/section-contracts/dist/list-fill-contract.js +24 -43
- package/dist/packages/internal/section-contracts/dist/name-title-contract.js +11 -18
- package/dist/packages/internal/section-contracts/dist/poi-curation-contract.js +10 -12
- package/dist/packages/internal/section-contracts/dist/pooling-field-contract.js +3 -13
- package/dist/packages/internal/section-contracts/dist/row-fill-contract.js +6 -18
- package/dist/packages/internal/section-contracts/dist/runners.js +21 -13
- package/dist/packages/internal/section-contracts/dist/source-contract.js +13 -2
- package/dist/packages/internal/section-contracts/dist/writer-reads-fact-contract.js +31 -0
- package/dist/packages/internal/source-resolution/dist/index.js +1 -9
- package/dist/packages/internal/template-artifact/dist/hash.js +0 -8
- package/dist/packages/internal/template-artifact/dist/index.js +1 -1
- package/dist/packages/internal/template-artifact/dist/layout.js +0 -39
- package/dist/packages/internal/template-artifact/dist/manifest.js +1 -9
- package/dist/packages/internal/template-artifact/dist/sha256.js +0 -1
- package/dist/packages/internal/template-artifact/dist/verify.js +2 -4
- package/dist/packages/internal/template-contracts/dist/collection-editing.js +0 -16
- package/dist/packages/internal/template-contracts/dist/content-categories.js +0 -4
- package/dist/packages/internal/template-contracts/dist/facts-view.d.ts +16 -10
- package/dist/packages/internal/template-contracts/dist/facts-view.js +15 -28
- package/dist/packages/internal/template-contracts/dist/layout.js +0 -7
- package/dist/packages/internal/template-contracts/dist/markers.js +0 -29
- package/dist/packages/internal/template-contracts/dist/select-key.js +0 -6
- package/dist/packages/internal/template-contracts/dist/slot-catalog.d.ts +56 -34
- package/dist/packages/internal/template-contracts/dist/slot-catalog.js +22 -389
- package/dist/platform/file-url.js +8 -0
- package/dist/platform/fs.js +73 -0
- package/dist/platform/names.js +63 -0
- package/dist/platform/order.js +7 -0
- package/dist/platform/paths.js +62 -0
- package/dist/platform/process.js +97 -0
- package/dist/playground/host/page-state.js +0 -2
- package/dist/playground/host/paths.js +0 -1
- package/dist/playground/layout.js +0 -7
- package/dist/playground/wire.js +0 -8
- package/dist/primitives/FrameShell.js +0 -18
- package/dist/primitives/Image.d.ts +5 -1
- package/dist/primitives/Image.js +2 -68
- package/dist/primitives/Section.js +0 -13
- package/dist/primitives/Tour.js +0 -26
- package/dist/primitives/Video.js +0 -32
- package/dist/primitives/embed-playback.js +0 -1
- package/dist/primitives/marker-attrs.js +0 -17
- package/dist/primitives/picture-sources.js +6 -1
- package/dist/primitives/probe-context.js +0 -7
- package/dist/primitives/slot-bindings.js +0 -46
- package/dist/primitives/slot-document.js +0 -11
- package/dist/primitives/slot-group.js +0 -9
- package/dist/primitives/slot-media.js +0 -27
- package/dist/primitives/slot-scalar.js +0 -4
- package/dist/primitives/slot.js +0 -6
- package/dist/rules/registry.js +42 -24
- package/dist/schema/compute.d.ts +46 -8
- package/dist/schema/compute.js +21 -15
- package/dist/schema/define-schema.d.ts +1 -1
- package/dist/schema/define-schema.js +37 -17
- package/dist/schema/extract-fill-spec.js +93 -180
- package/dist/schema/extract-used-facts.js +16 -158
- package/dist/schema/fact.d.ts +25 -12
- package/dist/schema/fact.js +7 -11
- package/dist/schema/fill-builders.d.ts +91 -366
- package/dist/schema/fill-builders.js +21 -259
- package/dist/schema/fill-declaration.d.ts +7 -69
- package/dist/schema/fill-declaration.js +5 -34
- package/dist/schema/fill-spec.js +59 -148
- package/dist/schema/format-presets.js +0 -12
- package/dist/schema/format.js +0 -7
- package/dist/schema/layout.js +0 -10
- package/dist/schema/manifest.js +0 -39
- package/dist/schema/property-facts.d.ts +20 -0
- package/dist/schema/section-nav.js +0 -15
- package/dist/schema/section-schema.d.ts +0 -1
- package/dist/schema/section-schema.js +4 -20
- package/dist/schema/slot-builders.d.ts +128 -117
- package/dist/schema/slot-builders.js +18 -201
- package/dist/schema/slot-ref.d.ts +63 -0
- package/dist/schema/slot-ref.js +33 -0
- package/dist/schema/slot-types.d.ts +3 -2
- package/dist/schema/slot-types.js +11 -20
- package/dist/section/declare.d.ts +14 -10
- package/dist/section/declare.js +13 -2
- package/dist/section/discovery.js +6 -21
- package/dist/section/groups.js +0 -6
- package/dist/section/materialize.js +0 -5
- package/dist/section/placements.js +0 -4
- package/dist/section/section.d.ts +8 -5
- package/dist/section/section.js +7 -29
- package/dist/styles.css +5 -0
- package/dist/template/define-template.d.ts +0 -4
- package/dist/template/define-template.js +1 -15
- package/dist/template/logic-build.js +8 -35
- package/dist/template/logic-shim.d.ts +4 -5
- package/dist/template/logic-shim.js +2 -6
- package/dist/template/logic-transform.js +0 -6
- package/dist/template/materialize.js +52 -43
- package/dist/template/mirror-types.js +43 -0
- package/dist/template/running-copy.js +5 -20
- package/dist/template/section-reads.js +83 -0
- package/guide/reference/cli/INDEX.md +12 -6
- package/guide/reference/cli/build.md +1 -1
- package/guide/reference/cli/check.md +1 -1
- package/guide/reference/cli/dev.md +3 -3
- package/guide/reference/cli/property-add.md +1 -1
- package/guide/reference/cli/property-list.md +1 -1
- package/guide/reference/cli/publish.md +4 -2
- package/guide/reference/cli/upgrade.md +1 -1
- package/guide/reference/rules/INDEX.md +26 -13
- package/package.json +4 -2
- package/dist/packages/internal/fact-interpolation/dist/index.js +0 -22
- package/dist/packages/internal/fill-bake/dist/reconcile-cross-section.js +0 -170
- package/dist/packages/internal/fill-vocabulary/dist/facts.d.ts +0 -32
- package/dist/packages/internal/fill-vocabulary/dist/facts.js +0 -131
- package/dist/packages/internal/template-contracts/dist/slot-overrides.js +0 -11
- package/dist/schema/fill-spec.d.ts +0 -18
- package/dist/template/reconcile.d.ts +0 -67
- package/dist/template/reconcile.js +0 -25
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { FIXTURES_DIR, publishedSectionKey, sectionDir } from "../../packages/internal/template-artifact/dist/layout.js";
|
|
2
|
+
import "../../packages/internal/template-artifact/dist/index.js";
|
|
3
|
+
import { caseCollisions, unportableName, unportablePaths } from "../../platform/names.js";
|
|
4
|
+
|
|
5
|
+
//#region src/cli/check/portable-names.ts
|
|
6
|
+
const RULE = "workspace/unportable-name";
|
|
7
|
+
function quoted(paths) {
|
|
8
|
+
return paths.map((path) => `"${path}"`).join(" and ");
|
|
9
|
+
}
|
|
10
|
+
function gradeKeys(kind, sites, dirOf) {
|
|
11
|
+
const violations = [];
|
|
12
|
+
const firstSite = /* @__PURE__ */ new Map();
|
|
13
|
+
for (const site of sites) if (!firstSite.has(site.name)) firstSite.set(site.name, site);
|
|
14
|
+
for (const site of firstSite.values()) {
|
|
15
|
+
const reason = unportableName(site.name);
|
|
16
|
+
if (reason === null) continue;
|
|
17
|
+
violations.push({
|
|
18
|
+
rule: RULE,
|
|
19
|
+
file: site.module,
|
|
20
|
+
message: `The ${kind} "${site.name}" ${reason}. It names the artifact directory ${dirOf(site.name)}; rename it.`
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
for (const group of caseCollisions(firstSite.keys())) {
|
|
24
|
+
const named = group.map((name) => firstSite.get(name));
|
|
25
|
+
violations.push({
|
|
26
|
+
rule: RULE,
|
|
27
|
+
file: named[named.length - 1].module,
|
|
28
|
+
message: `The ${kind}s ${named.map((site) => `"${site.name}" (${site.module})`).join(" and ")} differ only by case or Unicode form: Windows and macOS write ${quoted(group.map(dirOf))} as one directory. Rename one.`
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
return violations;
|
|
32
|
+
}
|
|
33
|
+
function unportableNameViolations(names) {
|
|
34
|
+
const violations = unportablePaths(names.sourcePaths, { hostSpelled: true }).map((found) => ({
|
|
35
|
+
rule: RULE,
|
|
36
|
+
file: found.paths[found.paths.length - 1],
|
|
37
|
+
message: found.paths.length === 1 ? `The source path "${found.paths[0]}" ${found.reason}. Rename it.` : `The source paths ${quoted(found.paths)} ${found.reason}. Rename one.`
|
|
38
|
+
}));
|
|
39
|
+
const templateKey = names.template;
|
|
40
|
+
if (templateKey !== void 0) violations.push(...gradeKeys("template key", [templateKey], (name) => sectionDir(name)));
|
|
41
|
+
const tplKey = templateKey?.name ?? "<template>";
|
|
42
|
+
violations.push(...gradeKeys("section key", names.sections, (name) => sectionDir(publishedSectionKey(tplKey, name))));
|
|
43
|
+
violations.push(...gradeKeys("fixture id", names.fixtures, (name) => `${FIXTURES_DIR}/${name}`));
|
|
44
|
+
return violations;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
//#endregion
|
|
48
|
+
export { unportableNameViolations };
|
|
@@ -13,11 +13,6 @@ function utilityOf(token) {
|
|
|
13
13
|
}
|
|
14
14
|
return token.slice(cut + 1);
|
|
15
15
|
}
|
|
16
|
-
/**
|
|
17
|
-
* Every framework-owned-box class conflict in one rendered fixture, one entry per
|
|
18
|
-
* distinct offending token per rule — a token repeated across a responsive tree is one
|
|
19
|
-
* defect for the author to fix.
|
|
20
|
-
*/
|
|
21
16
|
function checkClassConflicts(html) {
|
|
22
17
|
const marginTokens = /* @__PURE__ */ new Set();
|
|
23
18
|
for (const [tag] of html.matchAll(/<[a-zA-Z][^>]*>/g)) {
|
|
@@ -29,7 +29,6 @@ function parseAttrs(raw) {
|
|
|
29
29
|
function decode(s) {
|
|
30
30
|
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, "\"").replace(/'/g, "'");
|
|
31
31
|
}
|
|
32
|
-
/** Parse server-rendered HTML into a tree under a synthetic `#root` node. */
|
|
33
32
|
function parseHtml(html) {
|
|
34
33
|
html = html.replace(/<!--[\s\S]*?-->/g, "");
|
|
35
34
|
const root = {
|
|
@@ -18,11 +18,6 @@ function fixtureMediaPathOf(url) {
|
|
|
18
18
|
const path = url.replace(/[?#].*$/, "");
|
|
19
19
|
return path.startsWith(`${"/fixture-media"}/`) ? path : null;
|
|
20
20
|
}
|
|
21
|
-
/**
|
|
22
|
-
* The render invariants over one fixture's rendered HTML. `carriesMedia` answers
|
|
23
|
-
* whether a fixture media URL (its path, decoded, query and fragment dropped) names
|
|
24
|
-
* bytes the fixture load served; no other URL is ever passed to it.
|
|
25
|
-
*/
|
|
26
21
|
function checkRenderInvariants(html, carriesMedia) {
|
|
27
22
|
const violations = [];
|
|
28
23
|
const graded = /* @__PURE__ */ new Set();
|
|
@@ -1,15 +1,6 @@
|
|
|
1
1
|
import { ATTR_ISLAND_KEY, ISLAND_ELEMENT } from "../../../packages/internal/island-runtime/dist/contract.js";
|
|
2
2
|
|
|
3
3
|
//#region src/cli/check/render/island-frames.ts
|
|
4
|
-
/**
|
|
5
|
-
* Elements that ARE content even when empty, so their presence in a server render is
|
|
6
|
-
* something a `serverFrame = false` declaration would delete.
|
|
7
|
-
*
|
|
8
|
-
* `canvas` is deliberately absent, and it is the distinction this check turns on: a
|
|
9
|
-
* canvas is an empty box until code draws into it, which is exactly the island the
|
|
10
|
-
* declaration exists for. A nested island marker counts: whatever it wrapped is markup
|
|
11
|
-
* the parent's render carried.
|
|
12
|
-
*/
|
|
13
4
|
const CONTENT_ELEMENTS = /* @__PURE__ */ new Set([
|
|
14
5
|
"img",
|
|
15
6
|
"svg",
|
|
@@ -26,15 +17,6 @@ const CONTENT_ELEMENTS = /* @__PURE__ */ new Set([
|
|
|
26
17
|
ISLAND_ELEMENT
|
|
27
18
|
]);
|
|
28
19
|
const TAG = /<([a-zA-Z][a-zA-Z0-9-]*)/g;
|
|
29
|
-
/**
|
|
30
|
-
* Whether a server-rendered subtree carries anything a visitor or a crawler gets with no
|
|
31
|
-
* JavaScript: text, or one of {@link CONTENT_ELEMENTS}.
|
|
32
|
-
*
|
|
33
|
-
* Empty containers do not count, and that is the point: `<div class="map"></div>` is a
|
|
34
|
-
* box an island fills at runtime, not content. `<script>` and `<style>` bodies do not
|
|
35
|
-
* count either; a nested island's props payload is a `<script>` that would otherwise
|
|
36
|
-
* read as content for the island that wrapped it.
|
|
37
|
-
*/
|
|
38
20
|
function carriesContent(html) {
|
|
39
21
|
const stripped = html.replace(/<!--[\s\S]*?-->/g, "").replace(/<script\b[^<>]*>[\s\S]*?<\/script\s*>/gi, "").replace(/<style\b[^<>]*>[\s\S]*?<\/style\s*>/gi, "");
|
|
40
22
|
for (const match of stripped.matchAll(TAG)) if (CONTENT_ELEMENTS.has(match[1].toLowerCase())) return true;
|
|
@@ -45,13 +27,6 @@ const KEY_ATTR = new RegExp(`${ATTR_ISLAND_KEY}="([^"]*)"`);
|
|
|
45
27
|
function unescapeAttribute(value) {
|
|
46
28
|
return value.replace(/"/g, "\"").replace(/'/g, "'").replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&");
|
|
47
29
|
}
|
|
48
|
-
/**
|
|
49
|
-
* Every island marker in rendered HTML, innermost first within a nest.
|
|
50
|
-
*
|
|
51
|
-
* A token scan rather than a parse: React escapes `<` in every attribute value and the
|
|
52
|
-
* props payload escapes it too, so the only `<tr-island` in the output is a real marker.
|
|
53
|
-
* Markers nest (an island rendering another), so open tags stack.
|
|
54
|
-
*/
|
|
55
30
|
function islandMarkers(html) {
|
|
56
31
|
const out = [];
|
|
57
32
|
const open = [];
|
|
@@ -4,7 +4,6 @@ function push(map, key, value) {
|
|
|
4
4
|
if (existing) existing.push(value);
|
|
5
5
|
else map.set(key, [value]);
|
|
6
6
|
}
|
|
7
|
-
/** Walk one parsed render and record every marker it offers the editor. */
|
|
8
7
|
function collectMarkerCoverage(root) {
|
|
9
8
|
const coverage = {
|
|
10
9
|
slotIds: /* @__PURE__ */ new Set(),
|
|
@@ -57,25 +56,6 @@ function collectMarkerCoverage(root) {
|
|
|
57
56
|
walk(root, void 0, void 0, /* @__PURE__ */ new Set());
|
|
58
57
|
return coverage;
|
|
59
58
|
}
|
|
60
|
-
/**
|
|
61
|
-
* Item coverage for ONE per-item collection slot in ONE fixture.
|
|
62
|
-
*
|
|
63
|
-
* Three requirements, mirroring how the editor resolves items:
|
|
64
|
-
*
|
|
65
|
-
* - Somewhere on the page, every index `0..rowCount-1` must appear on a selectable
|
|
66
|
-
* item element — a row no selectable element carries can never be selected.
|
|
67
|
-
* - Each full rendering of the collection (a container scope that is neither a
|
|
68
|
-
* containerless row nor flagged non-selectable) must itself mark every row: the
|
|
69
|
-
* editor targets every live copy, so a copy missing a row shows selection on some
|
|
70
|
-
* copies and not others.
|
|
71
|
-
* - No index may fall outside `0..rowCount-1`, on ANY element — flagged copies
|
|
72
|
-
* included, because patching reaches them too and a wrong index patches the
|
|
73
|
-
* wrong row.
|
|
74
|
-
*
|
|
75
|
-
* A repeat index is never reported: within a scope it is the same row rendered
|
|
76
|
-
* twice (a live copy), across scopes the same collection rendered twice, and the
|
|
77
|
-
* editor targets every copy of either kind.
|
|
78
|
-
*/
|
|
79
59
|
function checkItemIndices(rowCount, scopes) {
|
|
80
60
|
const problems = [];
|
|
81
61
|
const selectable = /* @__PURE__ */ new Set();
|
|
@@ -1,41 +1,8 @@
|
|
|
1
1
|
//#region src/cli/check/render/nav.ts
|
|
2
|
-
/**
|
|
3
|
-
* A page's canonical URL: the directory form, always trailing-slash, under
|
|
4
|
-
* `basePath`. `("/", "/")` → `/`; `("/", "/gallery")` → `/gallery/`;
|
|
5
|
-
* `("/template/spw", "/gallery")` → `/template/spw/gallery/`.
|
|
6
|
-
*/
|
|
7
2
|
function pageHref(basePath, path) {
|
|
8
3
|
const base = basePath.replace(/\/+$/, "");
|
|
9
4
|
return path === "/" ? `${base}/` : `${base}${path}/`;
|
|
10
5
|
}
|
|
11
|
-
/**
|
|
12
|
-
* The section key → href map for a render of `currentPageId`, plus that
|
|
13
|
-
* render's `nav.pages`.
|
|
14
|
-
*
|
|
15
|
-
* A target on the current page resolves to a bare `#anchor`; a target on
|
|
16
|
-
* another page to that page's `pageHref` plus the fragment. A target listed on
|
|
17
|
-
* several pages prefers the current page, then the first ENABLED page in page
|
|
18
|
-
* order.
|
|
19
|
-
*
|
|
20
|
-
* `anchors` obeys page visibility exactly as `pages` does: a target reachable
|
|
21
|
-
* only through disabled pages is ABSENT from the map rather than resolving to a
|
|
22
|
-
* page that publishes nothing. Absence is the renderer's signal to omit the
|
|
23
|
-
* control entirely — a resolved href would 404, and an `undefined` one React
|
|
24
|
-
* drops leaves a dead, href-less `<a>`. The current page always counts as
|
|
25
|
-
* reachable for its own render: a disabled page is never published, and an
|
|
26
|
-
* editor canvas renders it only for itself, where same-page `#anchor` links
|
|
27
|
-
* must keep working.
|
|
28
|
-
*
|
|
29
|
-
* Section visibility omits by the same rule, one level down: a disabled section
|
|
30
|
-
* ref is not a target on the page that lists it, so a section disabled on every
|
|
31
|
-
* page it appears on is absent from the map, and one disabled on some pages
|
|
32
|
-
* resolves to a page where it still renders. There is no current-page exception
|
|
33
|
-
* here — the page exception exists because a disabled page is still rendered for
|
|
34
|
-
* its own canvas, whereas a disabled section renders nothing anywhere, the page
|
|
35
|
-
* being rendered included, so a bare `#anchor` to it would be dead too.
|
|
36
|
-
*
|
|
37
|
-
* @throws when `currentPageId` names no page in `pages`.
|
|
38
|
-
*/
|
|
39
6
|
function resolveNav(input) {
|
|
40
7
|
const { pages, currentPageId, basePath = "/" } = input;
|
|
41
8
|
const current = pages.find((p) => p.id === currentPageId);
|
package/dist/cli/check/report.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { CHECK_STAGES, qualify } from "../../rules/registry.js";
|
|
2
2
|
|
|
3
3
|
//#region src/cli/check/report.ts
|
|
4
|
-
/** A violation as the report carries it. */
|
|
5
4
|
function reportViolation(violation) {
|
|
6
5
|
return {
|
|
7
6
|
rule: qualify(violation.rule),
|
|
@@ -14,7 +13,6 @@ function toJson(report) {
|
|
|
14
13
|
return `${JSON.stringify(report, null, 2)}\n`;
|
|
15
14
|
}
|
|
16
15
|
const SUMMARY = new Map(CHECK_STAGES.map((stage) => [stage.id, stage.summary]));
|
|
17
|
-
/** Terminal text: one line per stage, each violation under it as `file:line rule message`. */
|
|
18
16
|
function formatHuman(report) {
|
|
19
17
|
const lines = [];
|
|
20
18
|
for (const stage of report.stages) {
|
|
@@ -50,7 +48,6 @@ function formatHuman(report) {
|
|
|
50
48
|
function kb(bytes) {
|
|
51
49
|
return `${(bytes / 1024).toFixed(1)} KB`;
|
|
52
50
|
}
|
|
53
|
-
/** One line per section under the bundles stage: the weights print on every run, not only past a ceiling. */
|
|
54
51
|
function formatWeights(weights) {
|
|
55
52
|
const width = Math.max(0, ...weights.map((w) => w.section.length));
|
|
56
53
|
return weights.map((w) => {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { workspacePath } from "../../../platform/paths.js";
|
|
1
2
|
import { publishedSectionKey } from "../../../packages/internal/template-artifact/dist/layout.js";
|
|
2
3
|
import "../../../packages/internal/template-artifact/dist/index.js";
|
|
3
4
|
import { frameRungFloor } from "../../media/frame-rung-floor.js";
|
|
4
5
|
import { exportSite } from "../../../section/discovery.js";
|
|
5
6
|
import { buildFramedRenderer, buildSection, framedRendererPath } from "../../build/sections.js";
|
|
6
|
-
import { workspacePath } from "../load-workspace.js";
|
|
7
7
|
import { describeError } from "../messages.js";
|
|
8
8
|
import { renderInputs } from "../render/inputs.js";
|
|
9
9
|
import { carriesContent, islandMarkers } from "../render/island-frames.js";
|
|
@@ -15,11 +15,8 @@ import { gzipSync } from "node:zlib";
|
|
|
15
15
|
import { renderToStaticMarkup } from "react-dom/server";
|
|
16
16
|
|
|
17
17
|
//#region src/cli/check/stages/bundles.ts
|
|
18
|
-
/** Gzipped bytes of a section's renderer bundle above which check fails. */
|
|
19
18
|
const RENDERER_GZIP_CEILING = 300 * 1024;
|
|
20
|
-
/** Gzipped bytes of one island chunk above which check fails. */
|
|
21
19
|
const ISLAND_GZIP_CEILING = 1024 * 1024;
|
|
22
|
-
/** `412.3 KB`: the unit a size message speaks in. */
|
|
23
20
|
function formatBytes(bytes) {
|
|
24
21
|
if (bytes < 1024) return `${String(bytes)} B`;
|
|
25
22
|
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
|
|
@@ -95,11 +92,6 @@ async function bundlesStage(ctx) {
|
|
|
95
92
|
ctx.weights = weights;
|
|
96
93
|
return { violations };
|
|
97
94
|
}
|
|
98
|
-
/**
|
|
99
|
-
* Render the section's framed renderer (every island wrapped for real) over the corpus,
|
|
100
|
-
* and fail each `serverFrame = false` island whose server render carries content.
|
|
101
|
-
* A render that throws is the render stage's finding, never this rule's.
|
|
102
|
-
*/
|
|
103
95
|
async function gradeServerFrames(ctx, input, entry, section, composition, sections, corpus) {
|
|
104
96
|
const frameless = new Map(section.islands.filter((island) => island.frameless).map((island) => [island.islandKey, island]));
|
|
105
97
|
const bytes = await buildFramedRenderer(input);
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { declaringModule } from "../../../section/section.js";
|
|
2
|
-
import {
|
|
2
|
+
import { isInsideRoot, workspacePath } from "../../../platform/paths.js";
|
|
3
3
|
import { describeError } from "../messages.js";
|
|
4
4
|
import { recordPlacements } from "../../../section/placements.js";
|
|
5
5
|
import { materializeTemplate } from "../../../template/materialize.js";
|
|
6
|
+
import { TEMPLATE_FILE } from "../load-workspace.js";
|
|
6
7
|
import { createElement } from "react";
|
|
7
8
|
import { isAbsolute } from "node:path";
|
|
8
9
|
|
|
@@ -53,7 +54,7 @@ function compositionStage(ctx) {
|
|
|
53
54
|
if (exported.has(placement.section) || reported.has(placement.section)) continue;
|
|
54
55
|
reported.add(placement.section);
|
|
55
56
|
const at = declaringModule(placement.section);
|
|
56
|
-
const file = at !== void 0 && isAbsolute(at) &&
|
|
57
|
+
const file = at !== void 0 && isAbsolute(at) && isInsideRoot(root, at) ? workspacePath(root, at) : TEMPLATE_FILE;
|
|
57
58
|
violations.push({
|
|
58
59
|
rule: "pages/section-not-exported",
|
|
59
60
|
file,
|
|
@@ -1,21 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { workspacePath } from "../../../platform/paths.js";
|
|
2
|
+
import { execNpm } from "../../../platform/process.js";
|
|
3
|
+
import { join } from "node:path";
|
|
2
4
|
import { readFile, readdir, realpath, stat } from "node:fs/promises";
|
|
3
5
|
import { z } from "zod";
|
|
4
|
-
import { execFile } from "node:child_process";
|
|
5
|
-
import { promisify } from "node:util";
|
|
6
6
|
|
|
7
7
|
//#region src/cli/check/stages/dependencies.ts
|
|
8
|
-
const
|
|
9
|
-
/** Real `execFile`-backed runner. Never throws on a non-zero exit: `npm audit` and
|
|
10
|
-
* `npm ls` both use exit codes to report findings, not tool failure, so the caller
|
|
11
|
-
* must always get the payload to parse. */
|
|
12
|
-
const defaultRunCommand = async (cmd, args, cwd) => {
|
|
8
|
+
const defaultRunCommand = async (_cmd, args, cwd) => {
|
|
13
9
|
try {
|
|
14
|
-
const
|
|
15
|
-
const { stdout } = await execFileAsync(cmd, [...args], {
|
|
10
|
+
const { stdout } = await execNpm(args, {
|
|
16
11
|
cwd,
|
|
17
|
-
maxBuffer: 64 * 1024 * 1024
|
|
18
|
-
shell
|
|
12
|
+
maxBuffer: 64 * 1024 * 1024
|
|
19
13
|
});
|
|
20
14
|
return {
|
|
21
15
|
stdout,
|
|
@@ -29,7 +23,6 @@ const defaultRunCommand = async (cmd, args, cwd) => {
|
|
|
29
23
|
};
|
|
30
24
|
}
|
|
31
25
|
};
|
|
32
|
-
/** A vulnerability at or above this severity fails the check. */
|
|
33
26
|
const AUDIT_FAIL_ON = ["high", "critical"];
|
|
34
27
|
const LOCKFILE = "package-lock.json";
|
|
35
28
|
async function isFile(p) {
|
|
@@ -46,8 +39,6 @@ async function isDir(p) {
|
|
|
46
39
|
return false;
|
|
47
40
|
}
|
|
48
41
|
}
|
|
49
|
-
/** `fs.realpath`, or `undefined` if the path is missing or unresolvable
|
|
50
|
-
* (e.g. a broken symlink or a genuine symlink loop, which trips `ELOOP`). */
|
|
51
42
|
async function realPathOrUndefined(p) {
|
|
52
43
|
try {
|
|
53
44
|
return await realpath(p);
|
|
@@ -134,30 +125,11 @@ async function readVersion(pkgDir) {
|
|
|
134
125
|
return "unknown version";
|
|
135
126
|
}
|
|
136
127
|
}
|
|
137
|
-
/** True when `entry` is worth descending into: a real directory, or a symlink whose
|
|
138
|
-
* target is one. `Dirent.isDirectory()` reports the dirent's OWN type, not what it
|
|
139
|
-
* resolves to: a symlink to a directory (exactly how `npm link` and npm workspaces
|
|
140
|
-
* lay out linked packages) reports `false`, so trusting it blindly makes the walk
|
|
141
|
-
* blind to every linked package's own `node_modules`. `isDir` re-`stat`s, which
|
|
142
|
-
* follows the link. */
|
|
143
128
|
async function isTraversableDir(dir, entry) {
|
|
144
129
|
if (entry.isDirectory()) return true;
|
|
145
130
|
if (!entry.isSymbolicLink()) return false;
|
|
146
131
|
return isDir(join(dir, entry.name));
|
|
147
132
|
}
|
|
148
|
-
/**
|
|
149
|
-
* Walks `node_modules` for a nested `react` or `react-dom`: one whose own
|
|
150
|
-
* `node_modules` (not the workspace's top-level one) holds a copy. `owner` is the
|
|
151
|
-
* name of the package whose private `node_modules` directory holds the offending
|
|
152
|
-
* copy, so the message can point straight at what to dedupe.
|
|
153
|
-
*
|
|
154
|
-
* `topLevelReal` maps "react"/"react-dom" to the REAL (symlink-resolved) path of the
|
|
155
|
-
* workspace's own top-level copy, if any; see `visitReactCandidate` for why identity
|
|
156
|
-
* is checked against it rather than against walk depth. `visited` is the set of real
|
|
157
|
-
* directory paths already walked: a defense against a symlink cycle (a linked
|
|
158
|
-
* package whose own `node_modules` loops back to an ancestor already on the path)
|
|
159
|
-
* turning this into infinite recursion.
|
|
160
|
-
*/
|
|
161
133
|
async function walkForNestedReact(dir, atTopLevel, owner, out, topLevelReal, visited) {
|
|
162
134
|
const real = await realPathOrUndefined(dir);
|
|
163
135
|
if (real === void 0 || visited.has(real)) return;
|
|
@@ -210,7 +182,7 @@ async function singleReactGate(root) {
|
|
|
210
182
|
await walkForNestedReact(nodeModules, true, "", offenders, topLevelReal, /* @__PURE__ */ new Set());
|
|
211
183
|
return offenders.map((offender) => ({
|
|
212
184
|
rule: "dependencies/single-react",
|
|
213
|
-
file:
|
|
185
|
+
file: workspacePath(root, offender.dir),
|
|
214
186
|
message: `A nested copy of ${offender.name}@${offender.version} is bundled inside ${offender.owner}'s own node_modules. ${SINGLE_REACT_FIX}`
|
|
215
187
|
}));
|
|
216
188
|
}
|
|
@@ -232,9 +204,6 @@ async function auditSeverityGate(run, root) {
|
|
|
232
204
|
message: `npm audit found ${counts} severity advisories. Run npm audit fix, or upgrade the package the advisory names.`
|
|
233
205
|
}] };
|
|
234
206
|
}
|
|
235
|
-
/** Grades the workspace at `root` against every `dependencies/*` rule. Spawns npm
|
|
236
|
-
* through `run` (twice, unless there is no lockfile, in which case never) and never
|
|
237
|
-
* throws on what npm reports. */
|
|
238
207
|
async function dependencyGates(root, run = defaultRunCommand) {
|
|
239
208
|
if (!await isFile(join(root, LOCKFILE))) return {
|
|
240
209
|
violations: [],
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { TEMPLATE_FILE } from "../load-workspace.js";
|
|
2
|
-
import { resolveEdit } from "../../../template/materialize.js";
|
|
3
2
|
import { loadFixtures } from "../../../fixtures/load.js";
|
|
4
3
|
import { findFixturesReachableFromBundle } from "../../../fixtures/bundle-rule.js";
|
|
5
4
|
import { resolveFixture, uniquePlacements } from "../../../fixtures/resolve.js";
|
|
@@ -7,29 +6,6 @@ import { synthesizeEmptyFixtures } from "../../../fixtures/synthesize-empties.js
|
|
|
7
6
|
import { join } from "node:path";
|
|
8
7
|
|
|
9
8
|
//#region src/cli/check/stages/fixtures.ts
|
|
10
|
-
/**
|
|
11
|
-
* The template's rules as the platform's reconcile runner takes them: reads and edits
|
|
12
|
-
* addressed to the instance each section key resolves to, exactly as the template
|
|
13
|
-
* logic bundle addresses them.
|
|
14
|
-
*/
|
|
15
|
-
function bakeReconcileRules(template, composition) {
|
|
16
|
-
const { instanceBySection } = composition;
|
|
17
|
-
return template.reconcile.map((rule) => ({
|
|
18
|
-
description: rule.description,
|
|
19
|
-
reads: rule.reads.flatMap((ref) => {
|
|
20
|
-
const instanceId = instanceBySection[ref.section];
|
|
21
|
-
return instanceId === void 0 ? [] : [{
|
|
22
|
-
instanceId,
|
|
23
|
-
slot: ref.slot
|
|
24
|
-
}];
|
|
25
|
-
}),
|
|
26
|
-
fn: ({ site, facts }) => rule.fn({
|
|
27
|
-
site,
|
|
28
|
-
facts
|
|
29
|
-
}).map((edit) => resolveEdit(edit, instanceBySection))
|
|
30
|
-
}));
|
|
31
|
-
}
|
|
32
|
-
/** The synthesized empties, each tagged with the (instance, slot) it emptied. */
|
|
33
9
|
function emptiesOf(first, composition) {
|
|
34
10
|
const instances = uniquePlacements(composition.placements).map((p) => p.instance);
|
|
35
11
|
const prefix = `${first.id}/empty/`;
|
|
@@ -48,15 +24,11 @@ function emptiesOf(first, composition) {
|
|
|
48
24
|
async function fixturesStage(ctx) {
|
|
49
25
|
const { workspace, composition } = ctx;
|
|
50
26
|
if (workspace?.template === null || workspace === void 0 || composition === void 0) return { skipped: "the composition stage could not derive the placed instances fixtures resolve over" };
|
|
51
|
-
const loaded = await loadFixtures({ root: ctx.root });
|
|
27
|
+
const loaded = ctx.fixtures ?? await loadFixtures({ root: ctx.root });
|
|
52
28
|
const violations = [...loaded.violations];
|
|
53
|
-
const reconcile = bakeReconcileRules(workspace.template, composition);
|
|
54
29
|
const resolved = [];
|
|
55
30
|
for (const fixture of loaded.fixtures) {
|
|
56
|
-
const result = resolveFixture(fixture, {
|
|
57
|
-
placements: composition.placements,
|
|
58
|
-
reconcile
|
|
59
|
-
});
|
|
31
|
+
const result = resolveFixture(fixture, { placements: composition.placements });
|
|
60
32
|
violations.push(...result.violations);
|
|
61
33
|
if (result.resolved !== null) resolved.push(result.resolved);
|
|
62
34
|
}
|
|
@@ -71,4 +43,4 @@ async function fixturesStage(ctx) {
|
|
|
71
43
|
}
|
|
72
44
|
|
|
73
45
|
//#endregion
|
|
74
|
-
export {
|
|
46
|
+
export { fixturesStage };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { eslintRuleByEngineId, isConcreteRuleId } from "../../../rules/registry.js";
|
|
2
2
|
import { concreteConfig } from "../../../eslint.js";
|
|
3
|
-
import { workspacePath } from "
|
|
3
|
+
import { replaceRoot, workspacePath } from "../../../platform/paths.js";
|
|
4
4
|
import { ESLint } from "eslint";
|
|
5
5
|
|
|
6
6
|
//#region src/cli/check/stages/lint.ts
|
|
@@ -31,7 +31,7 @@ async function lintStage(ctx) {
|
|
|
31
31
|
rule: message.ruleId === null ? "lint/parse-error" : registeredRule(message.ruleId),
|
|
32
32
|
file,
|
|
33
33
|
line: message.line,
|
|
34
|
-
message: message.message
|
|
34
|
+
message: replaceRoot(message.message, root, ".")
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
37
|
return { violations };
|
|
@@ -1,19 +1,12 @@
|
|
|
1
1
|
import { exportSite } from "../../../section/discovery.js";
|
|
2
|
-
import { TEMPLATE_FILE } from "../load-workspace.js";
|
|
3
2
|
import { describeError } from "../messages.js";
|
|
4
|
-
import { buildSectionLogic
|
|
3
|
+
import { buildSectionLogic } from "../../../template/logic-build.js";
|
|
5
4
|
import { join } from "node:path";
|
|
6
5
|
|
|
7
6
|
//#region src/cli/check/stages/logic.ts
|
|
8
|
-
/** How many rules a built template logic bundle carries, read by importing it. */
|
|
9
|
-
async function bundledRuleCount(bundle) {
|
|
10
|
-
const { reconcile } = await import(`data:text/javascript;base64,${Buffer.from(bundle).toString("base64")}`);
|
|
11
|
-
return Array.isArray(reconcile) ? reconcile.length : 0;
|
|
12
|
-
}
|
|
13
7
|
async function logicStage(ctx) {
|
|
14
8
|
const { workspace, discovered, composition } = ctx;
|
|
15
|
-
|
|
16
|
-
if (template === null || discovered === void 0 || composition === void 0) return { skipped: "the composition stage could not derive the placed sections" };
|
|
9
|
+
if ((workspace?.template ?? null) === null || discovered === void 0 || composition === void 0) return { skipped: "the composition stage could not derive the placed sections" };
|
|
17
10
|
const violations = [];
|
|
18
11
|
const sections = /* @__PURE__ */ new Map();
|
|
19
12
|
for (const [key, section] of composition.sections) {
|
|
@@ -32,31 +25,7 @@ async function logicStage(ctx) {
|
|
|
32
25
|
});
|
|
33
26
|
}
|
|
34
27
|
}
|
|
35
|
-
|
|
36
|
-
try {
|
|
37
|
-
templateLogic = await buildTemplateLogic({
|
|
38
|
-
templateFile: join(ctx.root, TEMPLATE_FILE),
|
|
39
|
-
instances: composition.instances
|
|
40
|
-
});
|
|
41
|
-
const bundled = await bundledRuleCount(templateLogic);
|
|
42
|
-
const authored = template.reconcile.length;
|
|
43
|
-
if (bundled !== authored) violations.push({
|
|
44
|
-
rule: "logic/reconcile-not-exported",
|
|
45
|
-
file: TEMPLATE_FILE,
|
|
46
|
-
message: `defineTemplate() was handed ${String(authored)} reconcile rule(s), but the template logic bundle carries ${String(bundled)}. The bundle reads the named export, so declare the rules as \`export const reconcile = [...]\` in ${TEMPLATE_FILE} and pass that same array to defineTemplate({ reconcile }).`
|
|
47
|
-
});
|
|
48
|
-
} catch (cause) {
|
|
49
|
-
violations.push({
|
|
50
|
-
rule: "logic/template-build-failed",
|
|
51
|
-
file: TEMPLATE_FILE,
|
|
52
|
-
message: `The template logic bundle does not build or evaluate: ${describeError(cause)}`
|
|
53
|
-
});
|
|
54
|
-
return { violations };
|
|
55
|
-
}
|
|
56
|
-
if (violations.length === 0) ctx.logic = {
|
|
57
|
-
sections,
|
|
58
|
-
template: templateLogic
|
|
59
|
-
};
|
|
28
|
+
if (violations.length === 0) ctx.logic = { sections };
|
|
60
29
|
return { violations };
|
|
61
30
|
}
|
|
62
31
|
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { TEMPLATE_FILE } from "../load-workspace.js";
|
|
2
|
+
import { mirrorMismatches } from "../../../template/mirror-types.js";
|
|
3
|
+
|
|
4
|
+
//#region src/cli/check/stages/relations.ts
|
|
5
|
+
function where(from, at) {
|
|
6
|
+
if (at === "fill") return `Section "${from}"'s fill`;
|
|
7
|
+
return `Section "${from}"'s \`${at}\``;
|
|
8
|
+
}
|
|
9
|
+
function relationsStage(ctx) {
|
|
10
|
+
const { composition } = ctx;
|
|
11
|
+
if (composition === void 0) return Promise.resolve({ skipped: "the composition stage could not derive the placed sections" });
|
|
12
|
+
const violations = [];
|
|
13
|
+
const { cycle } = composition.readGraph;
|
|
14
|
+
if (cycle.length > 0) {
|
|
15
|
+
const closing = composition.readGraph.edges.filter((edge) => edge.from !== edge.to.section && cycle.includes(edge.from) && cycle.includes(edge.to.section));
|
|
16
|
+
violations.push({
|
|
17
|
+
rule: "relations/section-cycle",
|
|
18
|
+
file: TEMPLATE_FILE,
|
|
19
|
+
message: `The sections ${cycle.map((key) => `"${key}"`).join(" → ")} read each other in a loop. A template's sections form a DAG: a ref taken at module scope inside an import cycle is \`undefined\`, so the loop cannot settle. Closing it: ${closing.map((edge) => `${where(edge.from, edge.at)} reads "${edge.to.section}".${edge.to.slot}`).join("; ")}.`
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
for (const diagnostic of composition.readDiagnostics) {
|
|
23
|
+
if (diagnostic.kind === "unplaced") {
|
|
24
|
+
violations.push({
|
|
25
|
+
rule: "relations/unplaced-read",
|
|
26
|
+
file: TEMPLATE_FILE,
|
|
27
|
+
message: `${where(diagnostic.from, diagnostic.at)} reads "${diagnostic.section}".${diagnostic.slot}, but no page places section "${diagnostic.section}". A declaration reads only sections the site map composes — place it, or drop the read.`
|
|
28
|
+
});
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
violations.push({
|
|
32
|
+
rule: "relations/fill-reads-computed",
|
|
33
|
+
file: TEMPLATE_FILE,
|
|
34
|
+
message: `${where(diagnostic.from, diagnostic.at)} reads "${diagnostic.section}".${diagnostic.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 a fill would read nothing. Read the refs that slot reads instead, or read a slot a fill writes.`
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
for (const mismatch of mirrorMismatches(composition.sections)) violations.push({
|
|
38
|
+
rule: "relations/mirror-type",
|
|
39
|
+
file: TEMPLATE_FILE,
|
|
40
|
+
message: `Section "${mismatch.section}"'s \`${mismatch.slot}\` mirrors "${mismatch.upstream.section}".${mismatch.upstream.slot}, but holds ${mismatch.mirrorKind} where its upstream holds ${mismatch.upstreamKind}. A mirror IS its upstream's value — declare the mirror at the upstream's kind, or derive the value with a \`compute()\`.`
|
|
41
|
+
});
|
|
42
|
+
return Promise.resolve({ violations });
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
//#endregion
|
|
46
|
+
export { relationsStage };
|
|
@@ -30,7 +30,6 @@ const INVARIANT_FIX = {
|
|
|
30
30
|
"broken-image": "Render a placeholder, or nothing, when an image slot is empty; never an <img> with no src.",
|
|
31
31
|
"unresolved-media": "State media by value, as an entry of the fixture's property, so the load mints its URL; never a hand-written media path."
|
|
32
32
|
};
|
|
33
|
-
/** What the corpus proved about one section, unioned over every render of it. */
|
|
34
33
|
var SectionEvidence = class {
|
|
35
34
|
entry;
|
|
36
35
|
marked = /* @__PURE__ */ new Set();
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { declaringModule } from "../../../section/section.js";
|
|
2
|
+
import { isInsideRoot, workspacePath } from "../../../platform/paths.js";
|
|
2
3
|
import { fillSpecFromSchema } from "../../../schema/extract-fill-spec.js";
|
|
3
4
|
import { exportSite } from "../../../section/discovery.js";
|
|
4
|
-
import { TEMPLATE_FILE, workspacePath } from "../load-workspace.js";
|
|
5
5
|
import { describeError } from "../messages.js";
|
|
6
6
|
import { renderInstanceSlots } from "../../../fixtures/media.js";
|
|
7
|
+
import { TEMPLATE_FILE } from "../load-workspace.js";
|
|
7
8
|
import { FillSpec } from "../../../schema/fill-spec.js";
|
|
8
9
|
import { SectionSchema } from "../../../schema/section-schema.js";
|
|
9
10
|
import { GroupDerivationError } from "../../../section/groups.js";
|
|
@@ -16,7 +17,6 @@ const GROUP_RULE = {
|
|
|
16
17
|
"label-conflict": "groups/label-conflict",
|
|
17
18
|
empty: "groups/empty"
|
|
18
19
|
};
|
|
19
|
-
/** The flat serialized shape every contract and consumer reads: `meta`'s anchor, groups and display lifted to the root. */
|
|
20
20
|
function flatten(parsed, key) {
|
|
21
21
|
const { meta, ...rest } = parsed;
|
|
22
22
|
return {
|
|
@@ -34,7 +34,7 @@ function sectionsStage(ctx) {
|
|
|
34
34
|
const exported = exportSite(discovered, section);
|
|
35
35
|
if (exported !== void 0) return exported.module;
|
|
36
36
|
const at = declaringModule(section);
|
|
37
|
-
return at !== void 0 && isAbsolute(at) &&
|
|
37
|
+
return at !== void 0 && isAbsolute(at) && isInsideRoot(workspace.root, at) ? workspacePath(workspace.root, at) : TEMPLATE_FILE;
|
|
38
38
|
};
|
|
39
39
|
const violations = [];
|
|
40
40
|
const sections = [];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { compileTemplateCss } from "../../../css/compile.js";
|
|
2
|
-
import { TEMPLATE_FILE } from "../load-workspace.js";
|
|
3
2
|
import { describeError } from "../messages.js";
|
|
3
|
+
import { TEMPLATE_FILE } from "../load-workspace.js";
|
|
4
4
|
import { join } from "node:path";
|
|
5
5
|
|
|
6
6
|
//#region src/cli/check/stages/stylesheet.ts
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import { workspacePath } from "
|
|
1
|
+
import { isWorkspaceFile, withoutRoot, workspacePath } from "../../../platform/paths.js";
|
|
2
2
|
import { existsSync } from "node:fs";
|
|
3
|
-
import { join
|
|
3
|
+
import { join } from "node:path";
|
|
4
4
|
import ts from "typescript";
|
|
5
5
|
|
|
6
6
|
//#region src/cli/check/stages/typecheck.ts
|
|
7
7
|
const TSCONFIG = "tsconfig.json";
|
|
8
|
-
function relativize(text, root) {
|
|
9
|
-
const prefix = root.endsWith(sep) ? root : root + sep;
|
|
10
|
-
return text.split(prefix).join("");
|
|
11
|
-
}
|
|
12
8
|
function typecheckStage(ctx) {
|
|
13
9
|
const { root } = ctx;
|
|
14
10
|
const configPath = join(root, TSCONFIG);
|
|
@@ -18,7 +14,7 @@ function typecheckStage(ctx) {
|
|
|
18
14
|
message: `The workspace has no ${TSCONFIG}. Extend the framework's compiler options: { "extends": "@homepages/concrete/tsconfig" }.`
|
|
19
15
|
}] });
|
|
20
16
|
const violations = [];
|
|
21
|
-
const text = (diagnostic) =>
|
|
17
|
+
const text = (diagnostic) => withoutRoot(ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n"), root);
|
|
22
18
|
const configFile = ts.readConfigFile(configPath, (file) => ts.sys.readFile(file));
|
|
23
19
|
if (configFile.error !== void 0) return Promise.resolve({ violations: [{
|
|
24
20
|
rule: "typecheck/error",
|
|
@@ -39,7 +35,6 @@ function typecheckStage(ctx) {
|
|
|
39
35
|
},
|
|
40
36
|
configFileParsingDiagnostics: parsed.errors
|
|
41
37
|
});
|
|
42
|
-
const inside = root.endsWith(sep) ? root : root + sep;
|
|
43
38
|
for (const diagnostic of ts.getPreEmitDiagnostics(program)) {
|
|
44
39
|
if (parsed.errors.includes(diagnostic)) continue;
|
|
45
40
|
if (diagnostic.category !== ts.DiagnosticCategory.Error) continue;
|
|
@@ -52,11 +47,10 @@ function typecheckStage(ctx) {
|
|
|
52
47
|
});
|
|
53
48
|
continue;
|
|
54
49
|
}
|
|
55
|
-
|
|
56
|
-
if (!path.startsWith(inside) || path.includes(`${sep}node_modules${sep}`)) continue;
|
|
50
|
+
if (!isWorkspaceFile(root, file.fileName)) continue;
|
|
57
51
|
violations.push({
|
|
58
52
|
rule: "typecheck/error",
|
|
59
|
-
file: workspacePath(root,
|
|
53
|
+
file: workspacePath(root, file.fileName),
|
|
60
54
|
...diagnostic.start === void 0 ? {} : { line: file.getLineAndCharacterOfPosition(diagnostic.start).line + 1 },
|
|
61
55
|
message: `TS${String(diagnostic.code)}: ${text(diagnostic)}`
|
|
62
56
|
});
|