@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,244 @@
|
|
|
1
|
+
import { isInsideRoot } from "../../platform/paths.js";
|
|
2
|
+
import { fixtureMediaModule } from "../../fixtures/media-plugin.js";
|
|
3
|
+
import { byCodeUnit } from "../../platform/order.js";
|
|
4
|
+
import { listDir, removeTree, renameSettled } from "../../platform/fs.js";
|
|
5
|
+
import { builtPathOf, builtTreePath, isBuiltTreePath } from "../../packages/internal/template-artifact/dist/layout.js";
|
|
6
|
+
import { FIXTURE_FILE_EXTENSIONS } from "../../packages/internal/playground/dist/host/media-saves.js";
|
|
7
|
+
import { dirname, extname, join } from "node:path";
|
|
8
|
+
import { pathToFileURL } from "node:url";
|
|
9
|
+
import { access, mkdir, readFile, readdir, stat, writeFile } from "node:fs/promises";
|
|
10
|
+
import { createHash } from "node:crypto";
|
|
11
|
+
|
|
12
|
+
//#region src/cli/dev/folder-files.ts
|
|
13
|
+
const FIXTURE_DOCUMENT_EXTENSIONS = /* @__PURE__ */ new Set([".json", ".md"]);
|
|
14
|
+
const sha256 = (bytes) => createHash("sha256").update(bytes).digest("hex");
|
|
15
|
+
function isMissing(cause) {
|
|
16
|
+
const code = cause.code;
|
|
17
|
+
return code === "ENOENT" || code === "ENOTDIR" || code === "EISDIR";
|
|
18
|
+
}
|
|
19
|
+
function isWorkspaceFile(path) {
|
|
20
|
+
return path.split("/").every((segment) => segment !== "node_modules" && !segment.startsWith("."));
|
|
21
|
+
}
|
|
22
|
+
function folderFiles(options) {
|
|
23
|
+
const { root } = options;
|
|
24
|
+
let build = options.build;
|
|
25
|
+
let version = 0;
|
|
26
|
+
const reached = /* @__PURE__ */ new Set();
|
|
27
|
+
const fingerprints = /* @__PURE__ */ new Map();
|
|
28
|
+
const fileOf = (path) => {
|
|
29
|
+
const file = join(root, ...path.split("/"));
|
|
30
|
+
return isInsideRoot(root, file) ? file : null;
|
|
31
|
+
};
|
|
32
|
+
const built = () => {
|
|
33
|
+
if ("failure" in build) throw new Error(build.failure);
|
|
34
|
+
return build;
|
|
35
|
+
};
|
|
36
|
+
const builtBytes = async (path) => {
|
|
37
|
+
const { output } = built();
|
|
38
|
+
const fingerprint = output.record.files[path];
|
|
39
|
+
if (fingerprint === void 0) return null;
|
|
40
|
+
return {
|
|
41
|
+
bytes: new Uint8Array(await readFile(join(output.out, ...path.split("/")))),
|
|
42
|
+
fingerprint
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
const workspaceBytes = async (path) => {
|
|
46
|
+
const file = isWorkspaceFile(path) ? fileOf(path) : null;
|
|
47
|
+
if (file === null) return null;
|
|
48
|
+
try {
|
|
49
|
+
const [bytes, stats] = await Promise.all([readFile(file), stat(file)]);
|
|
50
|
+
reached.add(path);
|
|
51
|
+
const fingerprint = sha256(bytes);
|
|
52
|
+
fingerprints.set(file, {
|
|
53
|
+
stamp: `${String(stats.mtimeMs)}:${String(stats.ctimeMs)}:${String(stats.size)}:${String(stats.ino)}`,
|
|
54
|
+
fingerprint
|
|
55
|
+
});
|
|
56
|
+
return {
|
|
57
|
+
bytes: new Uint8Array(bytes),
|
|
58
|
+
fingerprint
|
|
59
|
+
};
|
|
60
|
+
} catch (cause) {
|
|
61
|
+
if (isMissing(cause)) return null;
|
|
62
|
+
throw cause;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
const readBytes = (path) => {
|
|
66
|
+
const at = builtPathOf(path);
|
|
67
|
+
return at !== null ? builtBytes(at) : isBuiltTreePath(path) ? Promise.resolve(null) : workspaceBytes(path);
|
|
68
|
+
};
|
|
69
|
+
const workspaceEntry = async (path) => {
|
|
70
|
+
const file = fileOf(path);
|
|
71
|
+
if (file === null) return null;
|
|
72
|
+
const stats = await stat(file).catch((cause) => {
|
|
73
|
+
if (isMissing(cause)) return null;
|
|
74
|
+
throw cause;
|
|
75
|
+
});
|
|
76
|
+
if (stats === null || !stats.isFile()) return null;
|
|
77
|
+
const stamp = `${String(stats.mtimeMs)}:${String(stats.ctimeMs)}:${String(stats.size)}:${String(stats.ino)}`;
|
|
78
|
+
const known = fingerprints.get(file);
|
|
79
|
+
const fingerprint = known?.stamp === stamp ? known.fingerprint : (await workspaceBytes(path))?.fingerprint;
|
|
80
|
+
return fingerprint === void 0 ? null : {
|
|
81
|
+
path,
|
|
82
|
+
fingerprint,
|
|
83
|
+
size: stats.size
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
const workspaceEntries = async (path) => {
|
|
87
|
+
if (path !== "" && !isWorkspaceFile(path)) return [];
|
|
88
|
+
const single = path === "" ? null : await workspaceEntry(path);
|
|
89
|
+
if (single !== null) return [single];
|
|
90
|
+
const dir = path === "" ? root : fileOf(path);
|
|
91
|
+
if (dir === null) return [];
|
|
92
|
+
const names = await readdir(dir, { withFileTypes: true }).catch((cause) => {
|
|
93
|
+
if (isMissing(cause)) return [];
|
|
94
|
+
throw cause;
|
|
95
|
+
});
|
|
96
|
+
return (await Promise.all(names.filter((entry) => isWorkspaceFile(entry.name)).map((entry) => workspaceEntries(path === "" ? entry.name : `${path}/${entry.name}`)))).flat();
|
|
97
|
+
};
|
|
98
|
+
const builtEntries = async (path) => {
|
|
99
|
+
if ("failure" in build) return [];
|
|
100
|
+
const { output } = build;
|
|
101
|
+
const entries = Object.entries(output.record.files).map(([at, fingerprint]) => ({
|
|
102
|
+
at,
|
|
103
|
+
path: builtTreePath(at),
|
|
104
|
+
fingerprint
|
|
105
|
+
})).filter((entry) => path === "" || entry.path === path || entry.path.startsWith(`${path}/`)).map(async ({ at, path: treePath, fingerprint }) => ({
|
|
106
|
+
path: treePath,
|
|
107
|
+
fingerprint,
|
|
108
|
+
size: (await stat(join(output.out, ...at.split("/")))).size
|
|
109
|
+
}));
|
|
110
|
+
return Promise.all(entries);
|
|
111
|
+
};
|
|
112
|
+
const list = async (path) => {
|
|
113
|
+
const [builds, workspace] = await Promise.all([builtEntries(path), isBuiltTreePath(path) ? [] : workspaceEntries(path)]);
|
|
114
|
+
return [...builds, ...workspace].sort((a, b) => byCodeUnit(a.path, b.path));
|
|
115
|
+
};
|
|
116
|
+
const view = (at) => ({
|
|
117
|
+
version: at,
|
|
118
|
+
async readText(path) {
|
|
119
|
+
const read = await readBytes(path);
|
|
120
|
+
return read === null ? null : {
|
|
121
|
+
text: new TextDecoder().decode(read.bytes),
|
|
122
|
+
fingerprint: read.fingerprint
|
|
123
|
+
};
|
|
124
|
+
},
|
|
125
|
+
readBytes,
|
|
126
|
+
list
|
|
127
|
+
});
|
|
128
|
+
const assets = /* @__PURE__ */ new Map();
|
|
129
|
+
const served = /* @__PURE__ */ new Map();
|
|
130
|
+
return {
|
|
131
|
+
current: () => Promise.resolve(view(String(version))),
|
|
132
|
+
async change(_base, changes) {
|
|
133
|
+
await land(root, changes, reached);
|
|
134
|
+
for (const c of changes) fingerprints.delete(join(root, ...c.path.split("/")));
|
|
135
|
+
version += 1;
|
|
136
|
+
options.onWritten?.();
|
|
137
|
+
return { version: String(version) };
|
|
138
|
+
},
|
|
139
|
+
serve(next) {
|
|
140
|
+
build = next;
|
|
141
|
+
version += 1;
|
|
142
|
+
},
|
|
143
|
+
changed() {
|
|
144
|
+
version += 1;
|
|
145
|
+
},
|
|
146
|
+
reaches: (path) => reached.has(path),
|
|
147
|
+
media: {
|
|
148
|
+
async file(at, path) {
|
|
149
|
+
const known = served.get(path);
|
|
150
|
+
if (known !== void 0) {
|
|
151
|
+
const [entry] = await at.list(path);
|
|
152
|
+
if (entry?.path === path && entry.fingerprint === known.fingerprint) return {
|
|
153
|
+
file: known.file,
|
|
154
|
+
size: known.size
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
const file = isBuiltTreePath(path) || !isWorkspaceFile(path) ? null : fileOf(path);
|
|
158
|
+
const read = file === null ? null : await at.readBytes(path);
|
|
159
|
+
if (file === null || read === null) return null;
|
|
160
|
+
const { asset, value } = await fixtureMediaModule(file, read.bytes);
|
|
161
|
+
assets.set(asset.url, {
|
|
162
|
+
path,
|
|
163
|
+
derived: asset.derived
|
|
164
|
+
});
|
|
165
|
+
const answer = {
|
|
166
|
+
file: value,
|
|
167
|
+
size: read.bytes.byteLength
|
|
168
|
+
};
|
|
169
|
+
served.set(path, {
|
|
170
|
+
fingerprint: read.fingerprint,
|
|
171
|
+
...answer
|
|
172
|
+
});
|
|
173
|
+
return answer;
|
|
174
|
+
},
|
|
175
|
+
asset: (url) => assets.get(url)
|
|
176
|
+
},
|
|
177
|
+
async loadModule(path) {
|
|
178
|
+
const { output } = built();
|
|
179
|
+
const fingerprint = output.record.files[path];
|
|
180
|
+
if (fingerprint === void 0) throw new Error(`The build has no ${path}.`);
|
|
181
|
+
return await import(`${pathToFileURL(join(output.out, ...path.split("/"))).href}?v=${fingerprint}`);
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
async function land(root, changes, reached) {
|
|
186
|
+
const fileOf = (path, kind) => {
|
|
187
|
+
const file = join(root, ...path.split("/"));
|
|
188
|
+
const named = kind === "document" ? path.endsWith(".json") : FIXTURE_FILE_EXTENSIONS.has(extname(path).toLowerCase()) || FIXTURE_DOCUMENT_EXTENSIONS.has(extname(path).toLowerCase());
|
|
189
|
+
if (isBuiltTreePath(path) || !isWorkspaceFile(path) || !isInsideRoot(root, file) || !named) throw Object.assign(/* @__PURE__ */ new Error(`A save writes no file at "${path}".`), { status: 400 });
|
|
190
|
+
return file;
|
|
191
|
+
};
|
|
192
|
+
const staged = [];
|
|
193
|
+
const moved = [];
|
|
194
|
+
const removed = [];
|
|
195
|
+
for (const c of changes) if ("remove" in c) {
|
|
196
|
+
removed.push(fileOf(c.path, "file"));
|
|
197
|
+
reached.add(c.path);
|
|
198
|
+
} else if ("from" in c) {
|
|
199
|
+
moved.push({
|
|
200
|
+
source: c.from,
|
|
201
|
+
from: fileOf(c.from, "file"),
|
|
202
|
+
file: fileOf(c.path, "file")
|
|
203
|
+
});
|
|
204
|
+
reached.add(c.path).add(c.from);
|
|
205
|
+
} else {
|
|
206
|
+
const file = "text" in c ? fileOf(c.path, "document") : fileOf(c.path, "file");
|
|
207
|
+
const temporary = `${file}.${String(process.pid)}.saving.json`;
|
|
208
|
+
staged.push({
|
|
209
|
+
file,
|
|
210
|
+
temporary,
|
|
211
|
+
content: "text" in c ? c.text : c.bytes
|
|
212
|
+
});
|
|
213
|
+
reached.add(c.path).add(`${c.path}.${String(process.pid)}.saving.json`);
|
|
214
|
+
}
|
|
215
|
+
for (const m of moved) await access(m.from).catch(() => {
|
|
216
|
+
throw Object.assign(/* @__PURE__ */ new Error(`A save moves "${m.source}", which is gone; reload the playground.`), { status: 409 });
|
|
217
|
+
});
|
|
218
|
+
try {
|
|
219
|
+
for (const s of staged) {
|
|
220
|
+
await mkdir(dirname(s.file), { recursive: true });
|
|
221
|
+
await writeFile(s.temporary, s.content);
|
|
222
|
+
}
|
|
223
|
+
} catch (cause) {
|
|
224
|
+
await Promise.all(staged.map((s) => removeTree(s.temporary).catch(() => void 0)));
|
|
225
|
+
throw cause;
|
|
226
|
+
}
|
|
227
|
+
for (const s of staged) await renameSettled(s.temporary, s.file);
|
|
228
|
+
for (const m of moved) {
|
|
229
|
+
await mkdir(dirname(m.file), { recursive: true });
|
|
230
|
+
await renameSettled(m.from, m.file);
|
|
231
|
+
}
|
|
232
|
+
for (const file of removed) await removeTree(file);
|
|
233
|
+
for (const file of [...moved.map((m) => m.from), ...removed]) await removeEmptyFolders(root, dirname(file));
|
|
234
|
+
}
|
|
235
|
+
async function removeEmptyFolders(root, folder) {
|
|
236
|
+
for (let at = folder; at !== root && isInsideRoot(root, at); at = dirname(at)) {
|
|
237
|
+
const held = await listDir(at).catch(() => null);
|
|
238
|
+
if (held === null || held.length > 0) return;
|
|
239
|
+
await removeTree(at);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
//#endregion
|
|
244
|
+
export { folderFiles };
|
package/dist/cli/dev/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { onShutdown } from "../../platform/process.js";
|
|
2
2
|
import { findCommand, flagDefault, parseSpec, stringFlag } from "../commands.js";
|
|
3
3
|
import { findWorkspaceRoot } from "../workspace.js";
|
|
4
|
-
import { TEMPLATE_FILE } from "
|
|
4
|
+
import { TEMPLATE_FILE } from "../check/load-workspace.js";
|
|
5
|
+
import { installMissingTools } from "../install/background.js";
|
|
5
6
|
import { startDevServer } from "./server.js";
|
|
6
7
|
import { existsSync } from "node:fs";
|
|
7
8
|
import { join } from "node:path";
|
|
@@ -43,12 +44,14 @@ function createDevRunner(deps) {
|
|
|
43
44
|
io.stderr.write(`concrete dev: there is no ${TEMPLATE_FILE} at ${root} — a workspace declares its template there.\n`);
|
|
44
45
|
return 1;
|
|
45
46
|
}
|
|
47
|
+
const tools = await deps.installTools(io.stderr);
|
|
46
48
|
let server;
|
|
47
49
|
try {
|
|
48
50
|
server = await deps.start({
|
|
49
51
|
root,
|
|
50
52
|
port,
|
|
51
|
-
log: io.stderr
|
|
53
|
+
log: io.stderr,
|
|
54
|
+
toolsReady: tools.ready
|
|
52
55
|
});
|
|
53
56
|
} catch (err) {
|
|
54
57
|
io.stderr.write(`concrete dev: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
@@ -62,7 +65,8 @@ function createDevRunner(deps) {
|
|
|
62
65
|
}
|
|
63
66
|
const runDev = createDevRunner({
|
|
64
67
|
start: startDevServer,
|
|
65
|
-
untilStopped: processSignals
|
|
68
|
+
untilStopped: processSignals,
|
|
69
|
+
installTools: installMissingTools
|
|
66
70
|
});
|
|
67
71
|
|
|
68
72
|
//#endregion
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { packageRoot } from "../../platform/paths.js";
|
|
2
|
+
import { CONCRETE_CLI_VERSION } from "../version.js";
|
|
3
|
+
import { FIXTURE_MEDIA_PATH } from "../../fixtures/media-plugin.js";
|
|
4
|
+
import { codeFingerprintAt } from "../../packages/internal/code-fingerprint/dist/index.js";
|
|
5
|
+
import { playgroundDistDir } from "../../packages/internal/playground/dist/layout.js";
|
|
6
|
+
import { derivedFolder } from "../../packages/internal/playground/dist/server/derived-files.js";
|
|
7
|
+
import { startPlaygroundServer as startPlaygroundServer$1 } from "../../packages/internal/playground/dist/server/playground-server.js";
|
|
8
|
+
import { frameworkBrowser } from "./capture-browser.js";
|
|
9
|
+
import { join } from "node:path";
|
|
10
|
+
|
|
11
|
+
//#region src/cli/dev/playground-server.ts
|
|
12
|
+
function derivedCacheDir(workspaceRoot) {
|
|
13
|
+
return join(workspaceRoot, ".concrete", "cache", "derived");
|
|
14
|
+
}
|
|
15
|
+
async function startPlaygroundServer(options) {
|
|
16
|
+
const { browser, files, toolsReady, ...served } = options;
|
|
17
|
+
const packageRoot$1 = packageRoot();
|
|
18
|
+
return startPlaygroundServer$1({
|
|
19
|
+
...served,
|
|
20
|
+
files,
|
|
21
|
+
media: files.media,
|
|
22
|
+
loadModule: files.loadModule,
|
|
23
|
+
name: "concrete dev",
|
|
24
|
+
playgroundDir: playgroundDistDir(packageRoot$1),
|
|
25
|
+
fixtureMediaPath: FIXTURE_MEDIA_PATH,
|
|
26
|
+
derived: derivedFolder(derivedCacheDir(options.root)),
|
|
27
|
+
downloadCode: codeFingerprintAt(packageRoot$1),
|
|
28
|
+
browser: browser ?? frameworkBrowser(toolsReady),
|
|
29
|
+
platform: `@homepages/concrete ${CONCRETE_CLI_VERSION}`
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
//#endregion
|
|
34
|
+
export { derivedCacheDir, startPlaygroundServer };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { deriveAuthorImage, masterHash } from "../media/derive.js";
|
|
2
|
+
|
|
3
|
+
//#region src/cli/dev/section-ladders.ts
|
|
4
|
+
const NOTICE_WINDOW_MS = 1e4;
|
|
5
|
+
const errorText = (err) => err instanceof Error ? err.message : String(err);
|
|
6
|
+
function createSectionLadders(options) {
|
|
7
|
+
const { cacheDir, log } = options;
|
|
8
|
+
let queue = Promise.resolve();
|
|
9
|
+
let queued = 0;
|
|
10
|
+
let unannounced = false;
|
|
11
|
+
let noticeTimer = null;
|
|
12
|
+
let reportedNoSharp = false;
|
|
13
|
+
let closed = false;
|
|
14
|
+
const asked = /* @__PURE__ */ new Set();
|
|
15
|
+
const announce = () => {
|
|
16
|
+
if (noticeTimer !== null) clearTimeout(noticeTimer);
|
|
17
|
+
noticeTimer = null;
|
|
18
|
+
if (!unannounced || closed) return;
|
|
19
|
+
unannounced = false;
|
|
20
|
+
try {
|
|
21
|
+
options.onReady();
|
|
22
|
+
} catch (err) {
|
|
23
|
+
log.write(`concrete dev: landed ladders could not be announced: ${errorText(err)}\n`);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const landed = () => {
|
|
27
|
+
unannounced = true;
|
|
28
|
+
noticeTimer ??= setTimeout(announce, options.noticeWindowMs ?? 1e4);
|
|
29
|
+
};
|
|
30
|
+
const derive = async (path, bytes, minRungWidth) => {
|
|
31
|
+
try {
|
|
32
|
+
if (closed) return;
|
|
33
|
+
const derivation = await deriveAuthorImage(path, bytes, {
|
|
34
|
+
cacheDir,
|
|
35
|
+
...minRungWidth === void 0 ? {} : { minRungWidth },
|
|
36
|
+
...options.loadSharp === void 0 ? {} : { loadSharp: options.loadSharp }
|
|
37
|
+
});
|
|
38
|
+
if (closed) return;
|
|
39
|
+
if (derivation.passthrough) {
|
|
40
|
+
if (!reportedNoSharp) log.write("concrete dev: sharp did not load, so images serve as their masters, without a responsive ladder.\n");
|
|
41
|
+
reportedNoSharp = true;
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
landed();
|
|
45
|
+
} catch (err) {
|
|
46
|
+
log.write(`concrete dev: no responsive ladder for ${path}: ${errorText(err)}\n`);
|
|
47
|
+
} finally {
|
|
48
|
+
queued -= 1;
|
|
49
|
+
if (queued === 0) announce();
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
const idle = async () => {
|
|
53
|
+
for (let seen = queue;; seen = queue) {
|
|
54
|
+
await seen;
|
|
55
|
+
if (seen === queue) return;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
return {
|
|
59
|
+
derive(path, bytes, minRungWidth) {
|
|
60
|
+
const key = `${path}|${masterHash(bytes)}|${String(minRungWidth ?? "")}`;
|
|
61
|
+
if (closed || asked.has(key)) return;
|
|
62
|
+
asked.add(key);
|
|
63
|
+
queued += 1;
|
|
64
|
+
queue = queue.then(() => derive(path, bytes, minRungWidth));
|
|
65
|
+
},
|
|
66
|
+
idle,
|
|
67
|
+
close() {
|
|
68
|
+
closed = true;
|
|
69
|
+
announce();
|
|
70
|
+
return idle();
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
//#endregion
|
|
76
|
+
export { NOTICE_WINDOW_MS, createSectionLadders };
|