@homepages/concrete 12.0.0 → 13.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 +184 -0
- package/README.md +8 -10
- package/codemods/fixtures-are-data.mjs +7 -0
- package/codemods/fixtures-list-properties.mjs +6 -0
- package/codemods/manifest.json +11 -0
- package/codemods/steps/fixtures-list-properties.mjs +16 -0
- package/codemods/steps/fixtures-to-data.mjs +41 -0
- package/dist/artifact/playground/client/assets/archivo-latin-ext-wght-normal-C4zznr8T.woff2 +0 -0
- package/dist/artifact/playground/client/assets/archivo-latin-wght-normal-E0tuGl4L.woff2 +0 -0
- package/dist/artifact/playground/client/assets/archivo-vietnamese-wght-normal-XAtsl5Q_.woff2 +0 -0
- package/dist/artifact/playground/client/assets/index-Bmvcss4B.js +1338 -0
- package/dist/artifact/playground/client/assets/index-C01UCAWD.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 +110 -59
- package/dist/base.css +2 -2
- package/dist/cli/build/icons.js +1 -1
- package/dist/cli/build/index.js +11 -10
- package/dist/cli/build/manifest.js +44 -0
- package/dist/cli/build/record.js +123 -0
- package/dist/cli/build/sections.js +28 -18
- package/dist/cli/build/source.js +1 -1
- package/dist/cli/build/static.js +8 -5
- package/dist/cli/build/template-build.js +614 -0
- package/dist/cli/check/analyze.js +18 -1
- package/dist/cli/check/load-workspace.js +2 -2
- package/dist/cli/check/portable-names.js +1 -1
- package/dist/cli/check/render/corpus.js +119 -0
- package/dist/cli/check/render/invariants.js +1 -0
- package/dist/cli/check/stages/bundles.js +15 -18
- package/dist/cli/check/stages/composition.js +8 -25
- package/dist/cli/check/stages/fixtures.js +14 -10
- package/dist/cli/check/stages/logic.js +7 -23
- package/dist/cli/check/stages/render.js +12 -14
- package/dist/cli/check/stages/sections.js +22 -66
- package/dist/cli/check/stages/stylesheet.js +4 -26
- package/dist/cli/check/stages/workspace.js +27 -22
- package/dist/cli/commands.js +51 -23
- package/dist/cli/currency/preamble.js +1 -1
- package/dist/cli/currency/resolve-latest.js +3 -2
- package/dist/cli/dev/capture-browser.js +26 -0
- package/dist/cli/dev/fixture-schema.js +441 -0
- package/dist/cli/dev/folder-files.js +244 -0
- package/dist/cli/dev/index.js +7 -3
- package/dist/cli/dev/playground-server.js +34 -0
- package/dist/cli/dev/section-ladders.js +76 -0
- package/dist/cli/dev/server.js +120 -304
- package/dist/cli/install/background.js +16 -0
- package/dist/cli/install/index.js +45 -0
- package/dist/cli/install/tools.js +27 -0
- package/dist/cli/media/derive.js +19 -13
- package/dist/cli/media/deriver-plugin.js +14 -3
- package/dist/cli/property/fixture-list.js +46 -0
- package/dist/cli/property/index.js +12 -9
- package/dist/cli/property/library.js +12 -10
- package/dist/cli/publish/artifact.js +90 -0
- package/dist/cli/publish/captures.js +61 -0
- package/dist/cli/publish/fixtures.js +17 -0
- package/dist/cli/publish/index.js +10 -18
- package/dist/cli/{build → publish}/playground.js +3 -3
- package/dist/cli/publish/report.js +15 -33
- package/dist/cli/upgrade/codemod.d.ts +14 -0
- package/dist/cli/upgrade/fixture-conversion.d.ts +11 -0
- package/dist/cli/upgrade/fixture-conversion.js +54 -0
- package/dist/cli/upgrade/fixture-modules.js +125 -0
- package/dist/cli/upgrade/fixtures-to-data.d.ts +40 -0
- package/dist/cli/upgrade/fixtures-to-data.js +498 -0
- package/dist/cli/upgrade/index.js +18 -2
- package/dist/cli/upgrade/legacy-fixtures.d.ts +34 -0
- package/dist/cli/upgrade/legacy-fixtures.js +22 -0
- package/dist/cli/upgrade/stage.js +1 -1
- package/dist/cli/workspace-fixtures.js +80 -0
- package/dist/cli.js +1 -0
- package/dist/css/compile.js +9 -3
- package/dist/fixtures/bundle-rule.js +16 -16
- package/dist/fixtures/media-plugin.js +12 -33
- package/dist/fixtures/synthesize-empties.js +3 -2
- package/dist/index.d.ts +7 -7
- package/dist/{playground-island-runtime.d.ts → island-runtime.d.ts} +1 -2
- package/dist/{playground-island-runtime.js → island-runtime.js} +1 -2
- package/dist/islands/client-module.js +1 -1
- package/dist/{cli/dev → islands}/tsconfig-paths.js +2 -14
- package/dist/islands/wrap.js +40 -0
- package/dist/node_modules/.pnpm/acorn@8.18.0/node_modules/acorn/dist/acorn.js +5119 -0
- package/dist/packages/external/concrete/package.js +1 -1
- package/dist/packages/internal/bundle-evaluation/dist/cache.js +36 -0
- package/dist/packages/internal/bundle-evaluation/dist/evaluate.js +174 -0
- package/dist/packages/internal/bundle-evaluation/dist/index.js +5 -0
- package/dist/packages/internal/bundle-evaluation/dist/section-code.js +10 -0
- package/dist/packages/internal/capture-settle/dist/index.js +2 -2
- package/dist/packages/internal/capture-settle/dist/settle.js +88 -13
- package/dist/packages/internal/code-fingerprint/dist/index.js +57 -0
- package/dist/packages/internal/content-doc-ops/dist/index.js +176 -0
- package/dist/packages/internal/content-doc-ops/dist/made-rows.js +15 -0
- package/dist/packages/internal/deliverable-reads/dist/bootstrap.js +81 -0
- package/dist/packages/internal/deliverable-reads/dist/display.js +21 -0
- package/dist/packages/internal/deliverable-reads/dist/format.js +15 -0
- package/dist/packages/internal/deliverable-reads/dist/index.js +7 -0
- package/dist/packages/internal/deliverable-reads/dist/pages.js +29 -0
- package/dist/packages/internal/deliverable-reads/dist/requirements.js +72 -0
- package/dist/{cli/capture → packages/internal/download-files/dist}/bundle.js +8 -4
- package/dist/packages/internal/download-files/dist/capture-origin.js +126 -0
- package/dist/packages/internal/download-files/dist/capture-routes.js +139 -0
- package/dist/packages/internal/download-files/dist/capture-shell.js +38 -0
- package/dist/packages/internal/download-files/dist/capture.js +74 -0
- package/dist/packages/internal/download-files/dist/egress-watch.js +38 -0
- package/dist/packages/internal/download-files/dist/files.js +7 -0
- package/dist/packages/internal/download-files/dist/finish.js +35 -0
- package/dist/packages/internal/download-files/dist/fleet.js +94 -0
- package/dist/packages/internal/download-files/dist/format.js +40 -0
- package/dist/packages/internal/download-files/dist/make.js +105 -0
- package/dist/packages/internal/download-files/dist/master-tally.js +32 -0
- package/dist/packages/internal/download-files/dist/names.js +24 -0
- package/dist/packages/internal/download-files/dist/pdf-boxes.js +33 -0
- package/dist/packages/internal/download-files/dist/pdf-image-placements.js +194 -0
- package/dist/packages/internal/download-files/dist/pdf-images.js +289 -0
- package/dist/packages/internal/file-store/dist/files.js +8 -0
- package/dist/packages/internal/file-store/dist/lru.js +40 -0
- package/dist/packages/internal/file-store/dist/refusal.js +12 -0
- package/dist/packages/internal/file-store/dist/trees.js +151 -0
- package/dist/packages/internal/fill-bake/dist/bake-property-ref.js +1 -1
- package/dist/packages/internal/fill-bake/dist/compute-reads.js +47 -21
- package/dist/packages/internal/fill-bake/dist/index.js +5 -1
- package/dist/packages/internal/fill-bake/dist/item-merge.js +4 -3
- package/dist/packages/internal/fill-bake/dist/resolve-instance.js +9 -0
- package/dist/packages/internal/fill-bake/dist/resolve.js +3 -0
- package/dist/packages/internal/fill-bake/dist/round-trip.js +2 -0
- package/dist/packages/internal/fill-bake/dist/strip.js +6 -0
- package/dist/packages/internal/fill-vocabulary/dist/holder.js +1 -1
- package/dist/packages/internal/fill-vocabulary/dist/resolved-decision.js +1 -1
- package/dist/packages/internal/fill-vocabulary/dist/verbs.js +1 -1
- package/dist/packages/internal/island-runtime/dist/index.js +1 -10
- package/dist/packages/internal/island-runtime/dist/use-capture-ready.d.ts +5 -0
- package/dist/packages/internal/lead-fields/dist/ingest.js +72 -0
- package/dist/packages/internal/media-resolution/dist/video.js +6 -2
- package/dist/packages/internal/page-render/dist/addresses.js +57 -0
- package/dist/packages/internal/page-render/dist/index.js +6 -0
- package/dist/packages/internal/page-render/dist/kept.js +30 -0
- package/dist/packages/internal/page-render/dist/nav.js +42 -0
- package/dist/packages/internal/page-render/dist/render.js +152 -0
- package/dist/packages/internal/page-shell/dist/assemble.js +161 -0
- package/dist/packages/internal/page-shell/dist/escape.js +10 -0
- package/dist/packages/internal/page-shell/dist/frame.js +23 -0
- package/dist/packages/internal/page-shell/dist/index.js +26 -0
- package/dist/packages/internal/playground/dist/build-fingerprint.js +18 -0
- package/dist/packages/internal/playground/dist/fixture-conversions/list-names-properties.js +76 -0
- package/dist/packages/internal/playground/dist/fixture-formats.d.ts +37 -0
- package/dist/packages/internal/playground/dist/fixture-formats.js +20 -0
- package/dist/packages/internal/playground/dist/host/bootstrap.js +108 -0
- package/dist/packages/internal/playground/dist/host/built.js +202 -0
- package/dist/packages/internal/playground/dist/host/catalog-fixture.js +53 -0
- package/dist/packages/internal/playground/dist/host/download.js +34 -0
- package/dist/packages/internal/playground/dist/host/env.js +11 -0
- package/dist/packages/internal/playground/dist/host/everywhere-saves.js +353 -0
- package/dist/packages/internal/playground/dist/host/fixture-addresses.js +52 -0
- package/dist/packages/internal/playground/dist/host/fixture-documents.js +494 -0
- package/dist/packages/internal/playground/dist/host/fixture-operations.js +364 -0
- package/dist/packages/internal/playground/dist/host/fixture-units.js +93 -0
- package/dist/{fixtures → packages/internal/playground/dist/host}/image-dimensions.js +1 -1
- package/dist/packages/internal/playground/dist/host/leads.js +41 -0
- package/dist/packages/internal/playground/dist/host/media-saves.js +309 -0
- package/dist/{fixtures → packages/internal/playground/dist/host}/media-store.js +79 -26
- package/dist/packages/internal/playground/dist/host/overridable.js +9 -0
- package/dist/packages/internal/playground/dist/host/owned-saves.js +203 -0
- package/dist/{playground → packages/internal/playground/dist}/host/page-state.js +1 -1
- package/dist/packages/internal/playground/dist/host/program.js +54 -0
- package/dist/packages/internal/playground/dist/host/property-derive.js +216 -0
- package/dist/packages/internal/playground/dist/host/property-saves.js +74 -0
- package/dist/{fixtures → packages/internal/playground/dist/host}/property.js +88 -229
- package/dist/packages/internal/playground/dist/host/provenance.js +49 -0
- package/dist/packages/internal/playground/dist/host/resolve.js +553 -0
- package/dist/packages/internal/playground/dist/host/row-images.js +41 -0
- package/dist/{fixtures → packages/internal/playground/dist/host}/rows.js +1 -1
- package/dist/packages/internal/playground/dist/host/save.js +429 -0
- package/dist/packages/internal/playground/dist/host/serve.js +952 -0
- package/dist/packages/internal/playground/dist/host/site.js +79 -0
- package/dist/packages/internal/playground/dist/host/slots.js +202 -0
- package/dist/packages/internal/playground/dist/host/stated-content.js +93 -0
- package/dist/packages/internal/playground/dist/host/stored-fixtures.js +135 -0
- package/dist/packages/internal/playground/dist/host/violations.js +7 -0
- package/dist/packages/internal/playground/dist/jobs/lanes.js +24 -0
- package/dist/packages/internal/playground/dist/jobs/memory-queue.js +112 -0
- package/dist/packages/internal/playground/dist/jobs/probe.js +37 -0
- package/dist/packages/internal/playground/dist/jobs/queue.js +28 -0
- package/dist/packages/internal/playground/dist/jobs/runner.js +207 -0
- package/dist/packages/internal/playground/dist/layout.js +14 -0
- package/dist/packages/internal/playground/dist/platform.js +33 -0
- package/dist/packages/internal/playground/dist/server/changes.js +57 -0
- package/dist/packages/internal/playground/dist/server/crop.js +47 -0
- package/dist/packages/internal/playground/dist/server/derived-files.js +88 -0
- package/dist/packages/internal/playground/dist/server/download.js +158 -0
- package/dist/{cli/dev → packages/internal/playground/dist/server}/http.js +4 -12
- package/dist/packages/internal/playground/dist/server/jobs.js +29 -0
- package/dist/{cli/dev → packages/internal/playground/dist/server}/listen.js +4 -11
- package/dist/packages/internal/playground/dist/server/playground-server.js +424 -0
- package/dist/{cli/dev → packages/internal/playground/dist/server}/request-error.js +1 -1
- package/dist/packages/internal/playground/dist/server/size-ladders.js +170 -0
- package/dist/packages/internal/playground/dist/server/verification.js +75 -0
- package/dist/packages/internal/playground/dist/server/verify-build.js +139 -0
- package/dist/packages/internal/playground/dist/wire.js +78 -0
- package/dist/packages/internal/property-facts/dist/registry-facts.js +1 -1
- package/dist/packages/internal/section-contracts/dist/fill-verb-contract.js +1 -1
- package/dist/packages/internal/section-contracts/dist/reads-acyclic-contract.js +1 -1
- package/dist/packages/internal/section-contracts/dist/row-fill-contract.js +1 -1
- package/dist/packages/internal/site-files/dist/head.js +59 -0
- package/dist/packages/internal/site-files/dist/index.js +4 -0
- package/dist/packages/internal/site-files/dist/site.js +211 -0
- package/dist/packages/internal/static-assets-binding/dist/index.js +32 -0
- package/dist/packages/internal/static-assets-binding/dist/section-asset-url.js +38 -5
- package/dist/packages/internal/template-artifact/dist/asset-mime.js +8 -1
- package/dist/packages/internal/template-artifact/dist/build.js +148 -0
- package/dist/packages/internal/template-artifact/dist/composition.js +62 -0
- package/dist/packages/internal/template-artifact/dist/index.js +2 -2
- package/dist/packages/internal/template-artifact/dist/layout.js +48 -12
- package/dist/packages/internal/template-artifact/dist/manifest.js +3 -10
- package/dist/packages/internal/template-artifact/dist/verify.js +51 -31
- package/dist/packages/internal/template-contracts/dist/address-value.js +6 -1
- package/dist/packages/internal/template-contracts/dist/content-categories.js +10 -1
- package/dist/packages/internal/template-contracts/dist/fact-compute.d.ts +1 -1
- package/dist/packages/internal/template-contracts/dist/fact-keys.d.ts +1 -1
- package/dist/packages/internal/template-contracts/dist/fact-registry.d.ts +3 -3
- package/dist/packages/internal/template-contracts/dist/fact-registry.js +59 -32
- package/dist/packages/internal/template-contracts/dist/fill-spec.js +14 -1
- package/dist/packages/internal/template-contracts/dist/list.d.ts +3 -3
- package/dist/packages/internal/template-contracts/dist/media-candidates.js +67 -2
- package/dist/packages/internal/template-contracts/dist/media-offer.js +180 -0
- package/dist/packages/internal/template-contracts/dist/object.d.ts +2 -2
- package/dist/packages/internal/template-contracts/dist/primitive-descriptors.js +9 -2
- package/dist/packages/internal/template-contracts/dist/read-graph.js +36 -2
- package/dist/packages/internal/template-contracts/dist/ref-locate.js +16 -1
- package/dist/packages/internal/template-contracts/dist/registry-facts.d.ts +9 -10
- package/dist/packages/internal/template-contracts/dist/registry-facts.js +12 -1
- package/dist/packages/internal/template-contracts/dist/registry-graph.js +112 -0
- package/dist/packages/internal/template-contracts/dist/registry-shape.js +15 -2
- package/dist/packages/internal/template-contracts/dist/require-graph.js +300 -0
- package/dist/packages/internal/template-contracts/dist/row-ref.d.ts +3 -3
- package/dist/packages/internal/template-contracts/dist/row.d.ts +3 -3
- package/dist/packages/internal/template-contracts/dist/runtime-values.d.ts +1 -1
- package/dist/{schema → packages/internal/template-contracts/dist}/section-nav.d.ts +1 -1
- package/dist/packages/internal/template-contracts/dist/slot-builders.d.ts +4 -4
- package/dist/packages/internal/template-contracts/dist/slot-catalog.d.ts +3 -1
- package/dist/packages/internal/template-contracts/dist/slot-catalog.js +24 -1
- package/dist/packages/internal/template-contracts/dist/slot-overrides.js +26 -1
- package/dist/packages/internal/template-contracts/dist/slot-ref.d.ts +1 -1
- package/dist/packages/internal/template-contracts/dist/slot-types.js +1 -1
- package/dist/packages/internal/template-contracts/dist/slot-value.d.ts +1 -1
- package/dist/packages/internal/template-contracts/dist/table-members.js +7 -2
- package/dist/packages/internal/template-contracts/dist/video-value.d.ts +1 -1
- package/dist/packages/internal/upload-formats/dist/heic.js +35 -0
- package/dist/packages/internal/upload-formats/dist/index.js +80 -0
- package/dist/packages/internal/upload-formats/dist/magic-bytes.js +293 -0
- package/dist/platform/paths.js +1 -0
- package/dist/platform/process.js +49 -1
- package/dist/rules/registry.js +27 -3
- package/dist/schema/fact.d.ts +2 -2
- package/dist/schema/facts-view.d.ts +1 -1
- package/dist/schema/section-props.d.ts +1 -1
- package/dist/schema/section-schema.d.ts +1 -1
- package/dist/schema/section-schema.js +1 -0
- package/dist/section/declare.d.ts +1 -1
- package/dist/section/discovery.js +6 -2
- package/dist/section/publish-shape.js +38 -0
- package/dist/section/section.d.ts +1 -1
- package/dist/template/define-template.d.ts +14 -4
- package/dist/template/define-template.js +2 -0
- package/dist/template/logic-shim.d.ts +1 -1
- package/dist/template/materialize.js +1 -1
- package/dist/template/running-copy.js +0 -1
- package/dist/template/section-reads.js +1 -1
- package/guide/reference/cli/INDEX.md +6 -5
- package/guide/reference/cli/build.md +10 -8
- package/guide/reference/cli/check.md +4 -2
- package/guide/reference/cli/dev.md +6 -2
- package/guide/reference/cli/install.md +41 -0
- package/guide/reference/cli/property-add.md +5 -4
- package/guide/reference/cli/property-list.md +2 -2
- package/guide/reference/cli/publish.md +5 -5
- package/guide/reference/cli/upgrade.md +1 -1
- package/guide/reference/rules/INDEX.md +8 -4
- package/package.json +14 -30
- package/dist/artifact/playground/client/assets/index-BcLGpWLR.js +0 -1266
- package/dist/artifact/playground/client/assets/index-CxWPYOH2.css +0 -1
- package/dist/cli/build/artifact.js +0 -220
- package/dist/cli/build/captures.js +0 -48
- package/dist/cli/build/fixtures.js +0 -92
- package/dist/cli/capture/capture-browser.js +0 -37
- package/dist/cli/capture/capture.js +0 -115
- package/dist/cli/check/render/inputs.js +0 -60
- package/dist/cli/check/render/nav.js +0 -31
- package/dist/cli/dev/crop.js +0 -20
- package/dist/cli/dev/fixture-ladders.js +0 -96
- package/dist/cli/dev/hmr.js +0 -26
- package/dist/cli/dev/islands.js +0 -234
- package/dist/cli/dev/load-template.js +0 -52
- package/dist/cli/dev/vite.js +0 -114
- package/dist/cli/dev/workspace-reader.js +0 -249
- package/dist/cli/publish/freshness.js +0 -64
- package/dist/fixtures/brand.d.ts +0 -4
- package/dist/fixtures/brand.js +0 -8
- package/dist/fixtures/load.js +0 -159
- package/dist/fixtures/resolve.js +0 -392
- package/dist/fixtures.d.ts +0 -429
- package/dist/fixtures.js +0 -23
- package/dist/packages/internal/canvas-core/dist/island-host.js +0 -62
- package/dist/packages/internal/canvas-core/dist/island-shields.js +0 -30
- package/dist/playground/canvas-island-host.d.ts +0 -11
- package/dist/playground/canvas-island-host.js +0 -29
- package/dist/playground/canvas-markers.js +0 -14
- package/dist/playground/host/paths.js +0 -8
- package/dist/playground/layout.js +0 -17
- package/dist/playground/wire.js +0 -28
|
@@ -0,0 +1,614 @@
|
|
|
1
|
+
import { stampTableBounds } from "../../packages/internal/template-contracts/dist/registry-shape.js";
|
|
2
|
+
import { declaringModule } from "../../section/section.js";
|
|
3
|
+
import "../../packages/internal/template-contracts/dist/table-members.js";
|
|
4
|
+
import { isInsideRoot, workspacePath } from "../../platform/paths.js";
|
|
5
|
+
import { CONCRETE_CLI_VERSION } from "../version.js";
|
|
6
|
+
import { removeTree, writeFileReplacing } from "../../platform/fs.js";
|
|
7
|
+
import { MANIFEST_FILE, SECTION_FILES, TEMPLATE_DIR, TEMPLATE_FILES, assetPath, browserFileClashes, isSectionKey, isTemplateKey, islandPath, publishedSectionKey, sectionDir, sectionPath, staticPath, templatePath } from "../../packages/internal/template-artifact/dist/layout.js";
|
|
8
|
+
import { listingDigest } from "../../packages/internal/template-artifact/dist/hash.js";
|
|
9
|
+
import "../../packages/internal/template-artifact/dist/index.js";
|
|
10
|
+
import { sectionGraphOf } from "../../packages/internal/template-contracts/dist/read-graph.js";
|
|
11
|
+
import { collectTemplateCss, compileTemplateCss } from "../../css/compile.js";
|
|
12
|
+
import { unportablePaths } from "../../platform/names.js";
|
|
13
|
+
import { DuplicateSectionKeyError, discoverSections, exportSite } from "../../section/discovery.js";
|
|
14
|
+
import { publishShape } from "../../section/publish-shape.js";
|
|
15
|
+
import { buildSectionLogic } from "../../template/logic-build.js";
|
|
16
|
+
import { materializeTemplate } from "../../template/materialize.js";
|
|
17
|
+
import { TEMPLATE_FILE, loadWorkspace } from "../check/load-workspace.js";
|
|
18
|
+
import { describeError } from "../check/messages.js";
|
|
19
|
+
import { frameRungFloor } from "../media/frame-rung-floor.js";
|
|
20
|
+
import { deriveSiteIcons } from "./icons.js";
|
|
21
|
+
import { LEGACY_BUILD_RECORD_FILE, buildRecordPath, frameworkFingerprint, inputsUnchanged, outputsPresent, readBuildRecord, sectionIdentity, sha256Hex, stampInputs } from "./record.js";
|
|
22
|
+
import { buildManifest } from "./manifest.js";
|
|
23
|
+
import { buildSection } from "./sections.js";
|
|
24
|
+
import { analyticsBundle, baseCssBundle, islandRuntimeBundle, reactVendorBundles } from "./static.js";
|
|
25
|
+
import { existsSync } from "node:fs";
|
|
26
|
+
import { dirname, isAbsolute, join, relative } from "node:path";
|
|
27
|
+
import { mkdir, readFile, readdir } from "node:fs/promises";
|
|
28
|
+
import { availableParallelism } from "node:os";
|
|
29
|
+
|
|
30
|
+
//#region src/cli/build/template-build.ts
|
|
31
|
+
const encoder = new TextEncoder();
|
|
32
|
+
const json = (value) => encoder.encode(`${JSON.stringify(value, null, 2)}\n`);
|
|
33
|
+
function byKey(entries) {
|
|
34
|
+
return [...entries].sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
|
|
35
|
+
}
|
|
36
|
+
async function mapPool(items, limit, map) {
|
|
37
|
+
const results = new Array(items.length);
|
|
38
|
+
let next = 0;
|
|
39
|
+
const worker = async () => {
|
|
40
|
+
while (next < items.length) {
|
|
41
|
+
const index = next++;
|
|
42
|
+
results[index] = await map(items[index]);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
await Promise.all(Array.from({ length: Math.min(limit, items.length) }, worker));
|
|
46
|
+
return results;
|
|
47
|
+
}
|
|
48
|
+
function sectionNotExported(root, placementKey, section) {
|
|
49
|
+
const at = declaringModule(section);
|
|
50
|
+
const file = at !== void 0 && isAbsolute(at) && isInsideRoot(root, at) ? workspacePath(root, at) : TEMPLATE_FILE;
|
|
51
|
+
return {
|
|
52
|
+
rule: "pages/section-not-exported",
|
|
53
|
+
file,
|
|
54
|
+
message: `Section "${placementKey}" is placed but exported by no module. Export it from ${file} so the build can bundle it alone.`
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function pageLocator(workspace) {
|
|
58
|
+
const moduleOf = /* @__PURE__ */ new Map();
|
|
59
|
+
for (const [file, exports] of workspace.modules) for (const value of Object.values(exports)) if (!moduleOf.has(value)) moduleOf.set(value, workspacePath(workspace.root, file));
|
|
60
|
+
return (page) => moduleOf.get(page);
|
|
61
|
+
}
|
|
62
|
+
async function assertReplaceable(root, out) {
|
|
63
|
+
if (relative(out, root) === "" || isInsideRoot(out, root)) throw new Error(`The output directory ${out} contains the workspace; build writes into a directory of its own.`);
|
|
64
|
+
if (!existsSync(out)) return;
|
|
65
|
+
const entries = await readdir(out);
|
|
66
|
+
if (entries.length > 0 && !entries.includes("manifest.json") && !entries.includes("build.json") && !existsSync(buildRecordPath(out))) throw new Error(`The output directory ${out} is not empty and holds no build; build replaces only a previous build. Name an empty or new directory.`);
|
|
67
|
+
}
|
|
68
|
+
var Output = class {
|
|
69
|
+
writes = /* @__PURE__ */ new Map();
|
|
70
|
+
hashes = /* @__PURE__ */ new Map();
|
|
71
|
+
put(path, bytes) {
|
|
72
|
+
const sha = sha256Hex(bytes);
|
|
73
|
+
const prior = this.hashes.get(path);
|
|
74
|
+
if (prior !== void 0 && prior !== sha) throw new Error(`Two different files would be written as ${path}. Content-addressed names cannot collide; rename one of the sources.`);
|
|
75
|
+
this.hashes.set(path, sha);
|
|
76
|
+
this.writes.set(path, bytes);
|
|
77
|
+
}
|
|
78
|
+
keep(path, sha) {
|
|
79
|
+
const prior = this.hashes.get(path);
|
|
80
|
+
if (prior !== void 0 && prior !== sha) throw new Error(`Two different files would be written as ${path}. Content-addressed names cannot collide; rename one of the sources.`);
|
|
81
|
+
if (prior === void 0) this.hashes.set(path, sha);
|
|
82
|
+
}
|
|
83
|
+
asset(asset) {
|
|
84
|
+
this.put(assetPath(asset.filename), asset.bytes);
|
|
85
|
+
}
|
|
86
|
+
digestUnder(dir, extra = []) {
|
|
87
|
+
const prefix = `${dir}/`;
|
|
88
|
+
const entries = [...this.hashes].filter(([path]) => path.startsWith(prefix)).map(([path, sha256]) => ({
|
|
89
|
+
name: path.slice(prefix.length),
|
|
90
|
+
sha256
|
|
91
|
+
}));
|
|
92
|
+
if (entries.length === 0) throw new Error(`build: nothing was built under ${dir}/.`);
|
|
93
|
+
return listingDigest([...entries, ...extra]);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
async function produceSection(root, out, task, site, context) {
|
|
97
|
+
const module = join(root, site.module);
|
|
98
|
+
const identity = sectionIdentity({
|
|
99
|
+
framework: context.framework,
|
|
100
|
+
key: task.key,
|
|
101
|
+
module,
|
|
102
|
+
exportName: site.exportName,
|
|
103
|
+
minRungWidth: context.minRungWidth
|
|
104
|
+
});
|
|
105
|
+
const prior = context.prior.get(task.key);
|
|
106
|
+
if (prior !== void 0 && prior.identity === identity && prior.pending.length === 0 && await inputsUnchanged(prior.inputs) && await outputsPresent(out, [
|
|
107
|
+
...prior.files,
|
|
108
|
+
sectionPath(task.key, SECTION_FILES.logic),
|
|
109
|
+
sectionPath(task.key, SECTION_FILES.renderer)
|
|
110
|
+
])) {
|
|
111
|
+
const read = (path) => readFile(join(out, ...path.split("/"))).then((bytes) => new Uint8Array(bytes));
|
|
112
|
+
const [logic, renderer, islandBytes] = await Promise.all([
|
|
113
|
+
readFile(join(out, ...sectionPath(task.key, SECTION_FILES.logic).split("/")), "utf8"),
|
|
114
|
+
read(sectionPath(task.key, SECTION_FILES.renderer)),
|
|
115
|
+
Promise.all(prior.islands.map((island) => read(islandPath(task.key, island.filename))))
|
|
116
|
+
]);
|
|
117
|
+
const islands = prior.islands.map((island, index) => ({
|
|
118
|
+
islandKey: island.island_key,
|
|
119
|
+
filename: island.filename,
|
|
120
|
+
contentHash: island.content_hash,
|
|
121
|
+
bytes: islandBytes[index],
|
|
122
|
+
file: island.file,
|
|
123
|
+
frameless: island.frameless
|
|
124
|
+
}));
|
|
125
|
+
return {
|
|
126
|
+
logic: {
|
|
127
|
+
ok: true,
|
|
128
|
+
value: logic
|
|
129
|
+
},
|
|
130
|
+
bundles: {
|
|
131
|
+
ok: true,
|
|
132
|
+
value: {
|
|
133
|
+
renderer,
|
|
134
|
+
islands,
|
|
135
|
+
sources: prior.sources,
|
|
136
|
+
masters: new Map(Object.entries(prior.masters)),
|
|
137
|
+
passthrough: new Set(prior.passthrough),
|
|
138
|
+
pending: /* @__PURE__ */ new Set()
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
rebuilt: false,
|
|
142
|
+
record: {
|
|
143
|
+
...prior,
|
|
144
|
+
rebuilt: false
|
|
145
|
+
},
|
|
146
|
+
assets: null
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
const [logic, bundles] = await Promise.all([buildSectionLogic({
|
|
150
|
+
module,
|
|
151
|
+
exportName: site.exportName
|
|
152
|
+
}).then((value) => ({
|
|
153
|
+
ok: true,
|
|
154
|
+
value
|
|
155
|
+
}), (cause) => ({
|
|
156
|
+
ok: false,
|
|
157
|
+
violation: {
|
|
158
|
+
rule: "logic/section-build-failed",
|
|
159
|
+
file: site.module,
|
|
160
|
+
message: `Section "${task.local}"'s logic bundle does not build: ${describeError(cause)}`
|
|
161
|
+
}
|
|
162
|
+
})), buildSection({
|
|
163
|
+
root,
|
|
164
|
+
key: task.key,
|
|
165
|
+
module,
|
|
166
|
+
exportName: site.exportName,
|
|
167
|
+
...context.minRungWidth === void 0 ? {} : { minRungWidth: context.minRungWidth },
|
|
168
|
+
...context.pending === void 0 ? {} : { pending: context.pending }
|
|
169
|
+
}).then((value) => ({
|
|
170
|
+
ok: true,
|
|
171
|
+
value
|
|
172
|
+
}), (cause) => ({
|
|
173
|
+
ok: false,
|
|
174
|
+
violation: {
|
|
175
|
+
rule: "bundles/build-failed",
|
|
176
|
+
file: task.file,
|
|
177
|
+
message: `Section "${task.local}" does not bundle the way \`concrete build\` bundles it, so it could not be weighed and would not build: ${describeError(cause)}`
|
|
178
|
+
}
|
|
179
|
+
}))]);
|
|
180
|
+
if (!bundles.ok) return {
|
|
181
|
+
logic,
|
|
182
|
+
bundles,
|
|
183
|
+
rebuilt: true,
|
|
184
|
+
assets: null
|
|
185
|
+
};
|
|
186
|
+
const built = bundles.value;
|
|
187
|
+
const record = {
|
|
188
|
+
key: task.key,
|
|
189
|
+
rebuilt: true,
|
|
190
|
+
identity,
|
|
191
|
+
inputs: await stampInputs(built.inputs),
|
|
192
|
+
islands: built.islands.map((island) => ({
|
|
193
|
+
island_key: island.islandKey,
|
|
194
|
+
filename: island.filename,
|
|
195
|
+
content_hash: island.contentHash,
|
|
196
|
+
file: island.file,
|
|
197
|
+
frameless: island.frameless
|
|
198
|
+
})),
|
|
199
|
+
sources: [...built.sources],
|
|
200
|
+
masters: Object.fromEntries(byKey(built.masters)),
|
|
201
|
+
passthrough: [...built.passthrough].sort(),
|
|
202
|
+
pending: [...built.pending].sort()
|
|
203
|
+
};
|
|
204
|
+
return {
|
|
205
|
+
logic,
|
|
206
|
+
bundles: {
|
|
207
|
+
ok: true,
|
|
208
|
+
value: {
|
|
209
|
+
renderer: built.renderer,
|
|
210
|
+
islands: built.islands,
|
|
211
|
+
sources: built.sources,
|
|
212
|
+
masters: built.masters,
|
|
213
|
+
passthrough: built.passthrough,
|
|
214
|
+
pending: built.pending
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
rebuilt: true,
|
|
218
|
+
record,
|
|
219
|
+
assets: built.assets
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
const compileFailed = (cause) => ({
|
|
223
|
+
ok: false,
|
|
224
|
+
violation: {
|
|
225
|
+
rule: "css/compile-failed",
|
|
226
|
+
file: TEMPLATE_FILE,
|
|
227
|
+
message: `The stylesheet reachable from ${TEMPLATE_FILE} could not be resolved or compiled: ${describeError(cause)}`
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
var LayoutRefusal = class extends Error {
|
|
231
|
+
violation;
|
|
232
|
+
constructor(violation) {
|
|
233
|
+
super(violation.message);
|
|
234
|
+
this.violation = violation;
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
async function buildTemplate(options) {
|
|
238
|
+
const { root, out } = options;
|
|
239
|
+
await assertReplaceable(root, out);
|
|
240
|
+
const failures = [];
|
|
241
|
+
const templateFile = join(root, TEMPLATE_FILE);
|
|
242
|
+
const collected = existsSync(templateFile) ? collectTemplateCss({
|
|
243
|
+
root,
|
|
244
|
+
templateFile
|
|
245
|
+
}).then((value) => ({
|
|
246
|
+
ok: true,
|
|
247
|
+
value
|
|
248
|
+
}), (cause) => compileFailed(cause)) : null;
|
|
249
|
+
const workspace = await loadWorkspace(root);
|
|
250
|
+
failures.push(...workspace.violations);
|
|
251
|
+
const template = workspace.template;
|
|
252
|
+
if (template === null) return {
|
|
253
|
+
root,
|
|
254
|
+
workspace,
|
|
255
|
+
sections: [],
|
|
256
|
+
failures,
|
|
257
|
+
output: null
|
|
258
|
+
};
|
|
259
|
+
let discovered;
|
|
260
|
+
let duplicateKey;
|
|
261
|
+
try {
|
|
262
|
+
discovered = await discoverSections({
|
|
263
|
+
root,
|
|
264
|
+
importModule: (file) => Promise.resolve(workspace.modules.get(file) ?? {})
|
|
265
|
+
});
|
|
266
|
+
} catch (cause) {
|
|
267
|
+
if (!(cause instanceof DuplicateSectionKeyError)) throw cause;
|
|
268
|
+
duplicateKey = {
|
|
269
|
+
rule: "workspace/duplicate-section-key",
|
|
270
|
+
file: cause.second.module,
|
|
271
|
+
message: cause.message
|
|
272
|
+
};
|
|
273
|
+
failures.push(duplicateKey);
|
|
274
|
+
}
|
|
275
|
+
const stylesheetRun = (async () => {
|
|
276
|
+
const graph = await collected;
|
|
277
|
+
if (graph === null) throw new Error(`build: ${TEMPLATE_FILE} loaded but is not on disk.`);
|
|
278
|
+
if (!graph.ok) return graph;
|
|
279
|
+
try {
|
|
280
|
+
return {
|
|
281
|
+
ok: true,
|
|
282
|
+
value: await compileTemplateCss({
|
|
283
|
+
root,
|
|
284
|
+
templateFile,
|
|
285
|
+
template: {
|
|
286
|
+
key: template.key,
|
|
287
|
+
output: template.output,
|
|
288
|
+
formats: template.formats
|
|
289
|
+
},
|
|
290
|
+
exclude: [out]
|
|
291
|
+
}, graph.value)
|
|
292
|
+
};
|
|
293
|
+
} catch (cause) {
|
|
294
|
+
return compileFailed(cause);
|
|
295
|
+
}
|
|
296
|
+
})();
|
|
297
|
+
const iconFile = workspace.assets.get(template.icon)?.path;
|
|
298
|
+
const sharedRun = (async () => {
|
|
299
|
+
const [icons, baseCss, islandRuntime, vendor, analytics] = await Promise.all([
|
|
300
|
+
iconFile === void 0 ? null : deriveSiteIcons(iconFile),
|
|
301
|
+
baseCssBundle(),
|
|
302
|
+
islandRuntimeBundle(),
|
|
303
|
+
reactVendorBundles(root),
|
|
304
|
+
template.output === "website" ? analyticsBundle() : null
|
|
305
|
+
]);
|
|
306
|
+
return {
|
|
307
|
+
icons,
|
|
308
|
+
baseCss,
|
|
309
|
+
islandRuntime,
|
|
310
|
+
vendor,
|
|
311
|
+
analytics
|
|
312
|
+
};
|
|
313
|
+
})();
|
|
314
|
+
sharedRun.catch(() => void 0);
|
|
315
|
+
let composition;
|
|
316
|
+
if (discovered !== void 0) try {
|
|
317
|
+
composition = {
|
|
318
|
+
ok: true,
|
|
319
|
+
value: materializeTemplate(template, { locate: pageLocator(workspace) })
|
|
320
|
+
};
|
|
321
|
+
} catch (cause) {
|
|
322
|
+
composition = {
|
|
323
|
+
ok: false,
|
|
324
|
+
violation: {
|
|
325
|
+
rule: "pages/composition-invalid",
|
|
326
|
+
file: TEMPLATE_FILE,
|
|
327
|
+
message: describeError(cause)
|
|
328
|
+
}
|
|
329
|
+
};
|
|
330
|
+
failures.push(composition.violation);
|
|
331
|
+
}
|
|
332
|
+
const sectionResults = [];
|
|
333
|
+
if (discovered !== void 0 && composition?.ok === true) {
|
|
334
|
+
const found = discovered;
|
|
335
|
+
const fileOf = (section) => {
|
|
336
|
+
const site = exportSite(found, section);
|
|
337
|
+
if (site !== void 0) return site.module;
|
|
338
|
+
const at = declaringModule(section);
|
|
339
|
+
return at !== void 0 && isAbsolute(at) && isInsideRoot(root, at) ? workspacePath(root, at) : TEMPLATE_FILE;
|
|
340
|
+
};
|
|
341
|
+
const tasks = [...composition.value.sections].map(([local, section]) => ({
|
|
342
|
+
local,
|
|
343
|
+
key: publishedSectionKey(template.key, local),
|
|
344
|
+
section,
|
|
345
|
+
file: fileOf(section),
|
|
346
|
+
site: exportSite(found, section)
|
|
347
|
+
}));
|
|
348
|
+
const prior = await readBuildRecord(out);
|
|
349
|
+
const context = {
|
|
350
|
+
framework: await frameworkFingerprint(),
|
|
351
|
+
minRungWidth: frameRungFloor(template),
|
|
352
|
+
prior: new Map((prior?.key === template.key ? prior.sections : []).map((section) => [section.key, section])),
|
|
353
|
+
pending: options.pending
|
|
354
|
+
};
|
|
355
|
+
sectionResults.push(...await mapPool(tasks, Math.max(2, availableParallelism()), async (task) => {
|
|
356
|
+
let shape;
|
|
357
|
+
try {
|
|
358
|
+
shape = {
|
|
359
|
+
ok: true,
|
|
360
|
+
value: publishShape(task.local, task.section)
|
|
361
|
+
};
|
|
362
|
+
} catch (cause) {
|
|
363
|
+
shape = {
|
|
364
|
+
ok: false,
|
|
365
|
+
violation: {
|
|
366
|
+
rule: "sections/schema-invalid",
|
|
367
|
+
file: task.file,
|
|
368
|
+
message: `Section "${task.local}": ${describeError(cause)}`
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
if (task.site === void 0) return {
|
|
373
|
+
build: {
|
|
374
|
+
...task,
|
|
375
|
+
shape,
|
|
376
|
+
rebuilt: false
|
|
377
|
+
},
|
|
378
|
+
assets: null
|
|
379
|
+
};
|
|
380
|
+
const produced = await produceSection(root, out, task, task.site, context);
|
|
381
|
+
return {
|
|
382
|
+
build: {
|
|
383
|
+
...task,
|
|
384
|
+
shape,
|
|
385
|
+
logic: produced.logic,
|
|
386
|
+
bundles: produced.bundles,
|
|
387
|
+
rebuilt: produced.rebuilt
|
|
388
|
+
},
|
|
389
|
+
...produced.record === void 0 ? {} : { record: produced.record },
|
|
390
|
+
assets: produced.assets
|
|
391
|
+
};
|
|
392
|
+
}));
|
|
393
|
+
for (const { build } of sectionResults) {
|
|
394
|
+
if (build.site === void 0) failures.push(sectionNotExported(root, build.local, build.section));
|
|
395
|
+
if (!build.shape.ok) failures.push(build.shape.violation);
|
|
396
|
+
if (build.logic?.ok === false) failures.push(build.logic.violation);
|
|
397
|
+
if (build.bundles?.ok === false) failures.push(build.bundles.violation);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
const stylesheet = await stylesheetRun;
|
|
401
|
+
if (!stylesheet.ok) failures.push(stylesheet.violation);
|
|
402
|
+
else if (stylesheet.value.bundle === null) failures.push(...stylesheet.value.violations);
|
|
403
|
+
const sections = sectionResults.map((result) => result.build);
|
|
404
|
+
const partial = {
|
|
405
|
+
root,
|
|
406
|
+
workspace,
|
|
407
|
+
...discovered === void 0 ? {} : { discovered },
|
|
408
|
+
...duplicateKey === void 0 ? {} : { duplicateKey },
|
|
409
|
+
...composition === void 0 ? {} : { composition },
|
|
410
|
+
stylesheet,
|
|
411
|
+
sections,
|
|
412
|
+
failures
|
|
413
|
+
};
|
|
414
|
+
if (failures.length > 0 || composition?.ok !== true || !stylesheet.ok || stylesheet.value.bundle === null) return {
|
|
415
|
+
...partial,
|
|
416
|
+
output: null
|
|
417
|
+
};
|
|
418
|
+
let record;
|
|
419
|
+
try {
|
|
420
|
+
record = await assemble(root, out, workspace, composition.value, stylesheet.value.bundle, sectionResults, await sharedRun);
|
|
421
|
+
} catch (cause) {
|
|
422
|
+
if (!(cause instanceof LayoutRefusal)) throw cause;
|
|
423
|
+
return {
|
|
424
|
+
...partial,
|
|
425
|
+
failures: [...failures, cause.violation],
|
|
426
|
+
assembly: cause.violation,
|
|
427
|
+
output: null
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
return {
|
|
431
|
+
...partial,
|
|
432
|
+
output: {
|
|
433
|
+
out,
|
|
434
|
+
record
|
|
435
|
+
}
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
async function assemble(root, out, workspace, composition, css, results, shared) {
|
|
439
|
+
const template = workspace.template;
|
|
440
|
+
if (!isTemplateKey(template.key)) throw new LayoutRefusal({
|
|
441
|
+
rule: "workspace/key-not-name",
|
|
442
|
+
file: TEMPLATE_FILE,
|
|
443
|
+
message: `Template key "${template.key}" cannot name an artifact: a key is one path segment of letters, digits, ".", "_" and "-".`
|
|
444
|
+
});
|
|
445
|
+
const prior = await readBuildRecord(out);
|
|
446
|
+
const output = new Output();
|
|
447
|
+
const sectionRecords = [];
|
|
448
|
+
const islands = {};
|
|
449
|
+
const masters = [];
|
|
450
|
+
for (const result of [...results].sort((a, b) => a.build.key < b.build.key ? -1 : a.build.key > b.build.key ? 1 : 0)) {
|
|
451
|
+
const { build, record } = result;
|
|
452
|
+
if (!isSectionKey(build.key)) throw new LayoutRefusal({
|
|
453
|
+
rule: "sections/schema-invalid",
|
|
454
|
+
file: build.file,
|
|
455
|
+
message: `Section key "${build.local}" cannot name an artifact directory: a key is one path segment of letters, digits, ".", "_" and "-".`
|
|
456
|
+
});
|
|
457
|
+
if (!build.shape.ok || build.logic?.ok !== true || build.bundles?.ok !== true || record === void 0) throw new Error(`build: section "${build.local}" has no failure and no bundles.`);
|
|
458
|
+
const bundles = build.bundles.value;
|
|
459
|
+
const schema = JSON.parse(JSON.stringify(build.shape.value.schema));
|
|
460
|
+
stampTableBounds(schema.slots);
|
|
461
|
+
const readGraph = sectionGraphOf(schema, build.shape.value.fillSpec);
|
|
462
|
+
output.put(sectionPath(build.key, SECTION_FILES.schema), json(schema));
|
|
463
|
+
output.put(sectionPath(build.key, SECTION_FILES.fillSpec), json(build.shape.value.fillSpec));
|
|
464
|
+
output.put(sectionPath(build.key, SECTION_FILES.readGraph), json(readGraph));
|
|
465
|
+
output.put(sectionPath(build.key, SECTION_FILES.logic), encoder.encode(build.logic.value));
|
|
466
|
+
output.put(sectionPath(build.key, SECTION_FILES.renderer), bundles.renderer);
|
|
467
|
+
for (const island of bundles.islands) output.put(islandPath(build.key, island.filename), island.bytes);
|
|
468
|
+
let files;
|
|
469
|
+
if (result.assets !== null) {
|
|
470
|
+
for (const asset of result.assets) output.asset(asset);
|
|
471
|
+
files = [...bundles.islands.map((island) => islandPath(build.key, island.filename)), ...result.assets.map((asset) => assetPath(asset.filename))];
|
|
472
|
+
} else {
|
|
473
|
+
const kept = prior?.sections.find((section) => section.key === build.key);
|
|
474
|
+
if (kept === void 0) throw new Error(`build: section "${build.local}" was kept from a build that does not record it.`);
|
|
475
|
+
files = kept.files;
|
|
476
|
+
for (const path of files) {
|
|
477
|
+
const sha = prior?.files[path];
|
|
478
|
+
if (sha === void 0) throw new Error(`build: the recorded build lists ${path} without its hash.`);
|
|
479
|
+
output.keep(path, sha);
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
for (const island of bundles.islands) islands[island.islandKey] = {
|
|
483
|
+
filename: island.filename,
|
|
484
|
+
content_hash: island.contentHash
|
|
485
|
+
};
|
|
486
|
+
masters.push(...bundles.masters);
|
|
487
|
+
const contentHash = output.digestUnder(sectionDir(build.key));
|
|
488
|
+
sectionRecords.push({
|
|
489
|
+
...record,
|
|
490
|
+
content_hash: contentHash,
|
|
491
|
+
files: [...new Set(files)].sort()
|
|
492
|
+
});
|
|
493
|
+
}
|
|
494
|
+
const { manifest } = composition;
|
|
495
|
+
const publishedKey = (local) => publishedSectionKey(template.key, local);
|
|
496
|
+
const compositionColumn = {
|
|
497
|
+
output: manifest.output,
|
|
498
|
+
formats: manifest.formats,
|
|
499
|
+
pages: manifest.pages.map((page) => ({
|
|
500
|
+
...page,
|
|
501
|
+
sections: page.sections.map((instance) => ({
|
|
502
|
+
...instance,
|
|
503
|
+
section: publishedKey(instance.section)
|
|
504
|
+
}))
|
|
505
|
+
})),
|
|
506
|
+
canvases: manifest.canvases,
|
|
507
|
+
read_index: composition.reads.map((read) => ({
|
|
508
|
+
instance_id: read.instanceId,
|
|
509
|
+
slot: read.slot
|
|
510
|
+
}))
|
|
511
|
+
};
|
|
512
|
+
output.put(templatePath(TEMPLATE_FILES.composition), json(compositionColumn));
|
|
513
|
+
output.put(templatePath(TEMPLATE_FILES.preview), json(manifest.preview ?? null));
|
|
514
|
+
output.put(templatePath(TEMPLATE_FILES.stylesheet), css.bytes);
|
|
515
|
+
for (const asset of css.assets) output.asset(asset);
|
|
516
|
+
const { icons } = shared;
|
|
517
|
+
if (icons === null) throw new LayoutRefusal({
|
|
518
|
+
rule: "workspace/template-invalid",
|
|
519
|
+
file: TEMPLATE_FILE,
|
|
520
|
+
message: `The template's icon (${template.icon}) is not a file in the workspace. Import it: \`import icon from "./icon.svg"\`.`
|
|
521
|
+
});
|
|
522
|
+
for (const asset of icons.assets) output.asset(asset);
|
|
523
|
+
const putStatic = (bundle) => {
|
|
524
|
+
output.put(staticPath(bundle.filename), bundle.bytes);
|
|
525
|
+
return {
|
|
526
|
+
filename: bundle.filename,
|
|
527
|
+
content_hash: bundle.contentHash
|
|
528
|
+
};
|
|
529
|
+
};
|
|
530
|
+
const hasIslands = Object.keys(islands).length > 0;
|
|
531
|
+
const vendor = hasIslands ? shared.vendor : null;
|
|
532
|
+
const binding = {
|
|
533
|
+
base_css: putStatic(shared.baseCss),
|
|
534
|
+
template_css: {
|
|
535
|
+
filename: css.filename,
|
|
536
|
+
content_hash: css.contentHash
|
|
537
|
+
},
|
|
538
|
+
islands: Object.fromEntries(byKey(Object.entries(islands))),
|
|
539
|
+
island_runtime: hasIslands ? putStatic(shared.islandRuntime) : null,
|
|
540
|
+
react_vendor: vendor === null ? null : Object.fromEntries(byKey(vendor.facades).map(([specifier, facade]) => [specifier, putStatic(facade)])),
|
|
541
|
+
react_vendor_core: vendor === null ? null : putStatic(vendor.core),
|
|
542
|
+
analytics: shared.analytics === null ? null : putStatic(shared.analytics),
|
|
543
|
+
masters: Object.fromEntries(byKey(masters)),
|
|
544
|
+
icons: icons.icons
|
|
545
|
+
};
|
|
546
|
+
output.put(templatePath(TEMPLATE_FILES.staticAssets), json(binding));
|
|
547
|
+
const clashes = browserFileClashes(binding, output.hashes.keys());
|
|
548
|
+
if (clashes.length > 0) throw new LayoutRefusal({
|
|
549
|
+
rule: "workspace/duplicate-browser-file",
|
|
550
|
+
file: TEMPLATE_FILE,
|
|
551
|
+
message: `Two of the build's browser files would have one filename:\n` + clashes.map((clash) => ` ${clash.filename}: ${clash.paths.join(" and ")}`).join("\n") + "\nRename the source file one of them comes from."
|
|
552
|
+
});
|
|
553
|
+
const templateHash = output.digestUnder(TEMPLATE_DIR, sectionRecords.map((section) => ({
|
|
554
|
+
name: sectionDir(section.key),
|
|
555
|
+
sha256: section.content_hash
|
|
556
|
+
})));
|
|
557
|
+
const labels = new Map(results.map((result) => [result.build.key, result.build.section.label]));
|
|
558
|
+
const builtManifest = await buildManifest({
|
|
559
|
+
root,
|
|
560
|
+
out,
|
|
561
|
+
template,
|
|
562
|
+
templateHash,
|
|
563
|
+
sections: sectionRecords.map((section) => ({
|
|
564
|
+
key: section.key,
|
|
565
|
+
label: labels.get(section.key) ?? section.key,
|
|
566
|
+
contentHash: section.content_hash
|
|
567
|
+
}))
|
|
568
|
+
});
|
|
569
|
+
output.put(MANIFEST_FILE, json(builtManifest));
|
|
570
|
+
const unportable = unportablePaths([...output.hashes.keys()]);
|
|
571
|
+
if (unportable.length > 0) throw new LayoutRefusal({
|
|
572
|
+
rule: "workspace/unportable-name",
|
|
573
|
+
file: TEMPLATE_FILE,
|
|
574
|
+
message: `The build would not write the same files on Windows and macOS:\n` + unportable.map((found) => ` ${found.paths.join(" and ")}: ${found.reason}`).join("\n") + "\nRename the source files these names come from."
|
|
575
|
+
});
|
|
576
|
+
const record = {
|
|
577
|
+
build_schema: 2,
|
|
578
|
+
framework_version: CONCRETE_CLI_VERSION,
|
|
579
|
+
key: template.key,
|
|
580
|
+
template: { content_hash: templateHash },
|
|
581
|
+
sections: sectionRecords,
|
|
582
|
+
files: Object.fromEntries(byKey(output.hashes))
|
|
583
|
+
};
|
|
584
|
+
await writeOutput(out, prior, output, record);
|
|
585
|
+
return record;
|
|
586
|
+
}
|
|
587
|
+
async function writeOutput(out, prior, output, record) {
|
|
588
|
+
if (prior === null) await removeTree(out);
|
|
589
|
+
const tag = `${String(process.pid)}-${Math.random().toString(36).slice(2)}`;
|
|
590
|
+
const target = (path) => join(out, ...path.split("/"));
|
|
591
|
+
const writes = [...output.writes].filter(([path, bytes]) => prior?.files[path] !== sha256Hex(bytes) || !existsSync(target(path)));
|
|
592
|
+
const dirs = new Set(writes.map(([path]) => dirname(target(path))));
|
|
593
|
+
await Promise.all([...dirs].map((dir) => mkdir(dir, { recursive: true })));
|
|
594
|
+
await Promise.all(writes.map(([path, bytes]) => writeFileReplacing(`${target(path)}.${tag}.tmp`, target(path), bytes)));
|
|
595
|
+
if (prior !== null) {
|
|
596
|
+
const stale = Object.keys(prior.files).filter((path) => !output.hashes.has(path));
|
|
597
|
+
await Promise.all(stale.map((path) => removeTree(target(path))));
|
|
598
|
+
}
|
|
599
|
+
await mkdir(out, { recursive: true });
|
|
600
|
+
const recordFile = buildRecordPath(out);
|
|
601
|
+
await writeFileReplacing(`${recordFile}.${tag}.tmp`, recordFile, `${JSON.stringify(record, null, 2)}\n`);
|
|
602
|
+
}
|
|
603
|
+
async function readBuiltFiles(output) {
|
|
604
|
+
const files = /* @__PURE__ */ new Map();
|
|
605
|
+
await Promise.all(Object.entries(output.record.files).map(async ([path, sha]) => {
|
|
606
|
+
const bytes = new Uint8Array(await readFile(join(output.out, ...path.split("/"))));
|
|
607
|
+
if (sha256Hex(bytes) !== sha) throw new Error(`${path} in ${output.out} is not the file the build wrote; run the build again.`);
|
|
608
|
+
files.set(path, bytes);
|
|
609
|
+
}));
|
|
610
|
+
return new Map(byKey(files));
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
//#endregion
|
|
614
|
+
export { buildTemplate, pageLocator, readBuiltFiles, sectionNotExported };
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { CHECK_STAGES, ruleById } from "../../rules/registry.js";
|
|
2
|
+
import { DEFAULT_BUILD_DIR } from "../commands.js";
|
|
2
3
|
import { CONCRETE_CLI_VERSION } from "../version.js";
|
|
4
|
+
import { buildTemplate } from "../build/template-build.js";
|
|
3
5
|
import { reportViolation } from "./report.js";
|
|
4
6
|
import { bundlesStage } from "./stages/bundles.js";
|
|
5
7
|
import { compositionStage } from "./stages/composition.js";
|
|
@@ -14,6 +16,7 @@ import { sectionsStage } from "./stages/sections.js";
|
|
|
14
16
|
import { stylesheetStage } from "./stages/stylesheet.js";
|
|
15
17
|
import { typecheckStage } from "./stages/typecheck.js";
|
|
16
18
|
import { workspaceStage } from "./stages/workspace.js";
|
|
19
|
+
import { join } from "node:path";
|
|
17
20
|
|
|
18
21
|
//#region src/cli/check/analyze.ts
|
|
19
22
|
const RUNNERS = {
|
|
@@ -35,9 +38,14 @@ async function analyzeCheck(options) {
|
|
|
35
38
|
return (await analyzeWorkspace(options)).report;
|
|
36
39
|
}
|
|
37
40
|
async function analyzeWorkspace(options) {
|
|
41
|
+
const build = await buildTemplate({
|
|
42
|
+
root: options.root,
|
|
43
|
+
out: options.out ?? join(options.root, ".concrete/build")
|
|
44
|
+
});
|
|
38
45
|
const ctx = {
|
|
39
46
|
root: options.root,
|
|
40
|
-
runCommand: options.runCommand
|
|
47
|
+
runCommand: options.runCommand,
|
|
48
|
+
build
|
|
41
49
|
};
|
|
42
50
|
const stages = [];
|
|
43
51
|
for (const { id } of CHECK_STAGES) {
|
|
@@ -84,6 +92,15 @@ async function analyzeWorkspace(options) {
|
|
|
84
92
|
...hints.length === 0 ? {} : { hints }
|
|
85
93
|
});
|
|
86
94
|
}
|
|
95
|
+
if (build.assembly !== void 0) {
|
|
96
|
+
const at = stages.findIndex((stage) => stage.id === ruleById(build.assembly.rule).stage);
|
|
97
|
+
const stage = stages[at];
|
|
98
|
+
if (stage !== void 0) stages[at] = {
|
|
99
|
+
...stage,
|
|
100
|
+
status: "failed",
|
|
101
|
+
violations: [...stage.violations, reportViolation(build.assembly)]
|
|
102
|
+
};
|
|
103
|
+
}
|
|
87
104
|
return {
|
|
88
105
|
report: {
|
|
89
106
|
ok: stages.every((stage) => stage.status === "passed"),
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { isTemplate } from "../../template/define-template.js";
|
|
2
2
|
import { workspacePath } from "../../platform/paths.js";
|
|
3
|
-
import { listModules } from "../../section/discovery.js";
|
|
4
3
|
import { MEDIA_LOADERS, createFixtureMediaPlugin, externalOutsideWorkspace } from "../../fixtures/media-plugin.js";
|
|
5
|
-
import { runningCopyPlugin } from "../../template/running-copy.js";
|
|
6
4
|
import { createPackageStylesheetsPlugin } from "../../fixtures/package-stylesheets.js";
|
|
5
|
+
import { runningCopyPlugin } from "../../template/running-copy.js";
|
|
6
|
+
import { listModules } from "../../section/discovery.js";
|
|
7
7
|
import { claimLoadOutdir } from "./load-outdir.js";
|
|
8
8
|
import { existsSync } from "node:fs";
|
|
9
9
|
import { join } from "node:path";
|
|
@@ -40,7 +40,7 @@ function unportableNameViolations(names) {
|
|
|
40
40
|
if (templateKey !== void 0) violations.push(...gradeKeys("template key", [templateKey], (name) => sectionDir(name)));
|
|
41
41
|
const tplKey = templateKey?.name ?? "<template>";
|
|
42
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}`));
|
|
43
|
+
violations.push(...gradeKeys("fixture id", names.fixtures ?? [], (name) => `${FIXTURES_DIR}/${name}`));
|
|
44
44
|
return violations;
|
|
45
45
|
}
|
|
46
46
|
|