@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
package/dist/cli/dev/server.js
CHANGED
|
@@ -1,334 +1,150 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { qualify } from "../../rules/registry.js";
|
|
2
|
+
import { toPosix } from "../../platform/paths.js";
|
|
3
3
|
import { mediaCacheDir } from "../media/cache.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { CROP_PARAM, parseCropParam } from "../../packages/internal/crop-region/dist/index.js";
|
|
12
|
-
import { croppedMediaUrl, cutRegion } from "./crop.js";
|
|
13
|
-
import { createFixtureLadders } from "./fixture-ladders.js";
|
|
14
|
-
import { createHmrBus } from "./hmr.js";
|
|
15
|
-
import { RequestError, contentTypeFor, readBody, sendBytes, sendFile, sendHtml, sendText } from "./http.js";
|
|
16
|
-
import { respondToHandlerError } from "./request-error.js";
|
|
17
|
-
import { createDevVite, settleBrowserDependencies } from "./vite.js";
|
|
18
|
-
import { DevWorkspace } from "./workspace-reader.js";
|
|
19
|
-
import { existsSync, statSync } from "node:fs";
|
|
20
|
-
import { extname, join, relative, resolve } from "node:path";
|
|
21
|
-
import { pathToFileURL } from "node:url";
|
|
22
|
-
import { readFile } from "node:fs/promises";
|
|
23
|
-
import { createServer } from "node:http";
|
|
4
|
+
import { buildTemplate } from "../build/template-build.js";
|
|
5
|
+
import { writeFixtureSchemas } from "./fixture-schema.js";
|
|
6
|
+
import { createSectionLadders } from "./section-ladders.js";
|
|
7
|
+
import { folderFiles } from "./folder-files.js";
|
|
8
|
+
import { startPlaygroundServer } from "./playground-server.js";
|
|
9
|
+
import { watch } from "node:fs";
|
|
10
|
+
import { join, relative } from "node:path";
|
|
24
11
|
|
|
25
12
|
//#region src/cli/dev/server.ts
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
13
|
+
const DEV_BUILD_DIR = ".concrete/dev";
|
|
14
|
+
const TOOLING_FILES = /* @__PURE__ */ new Set(["package.json", "tsconfig.json"]);
|
|
15
|
+
const FIXTURES_MOVED = {
|
|
16
|
+
source: false,
|
|
17
|
+
stylesheet: false,
|
|
18
|
+
fixtures: true
|
|
19
|
+
};
|
|
20
|
+
const SOURCE_MOVED = {
|
|
21
|
+
source: true,
|
|
22
|
+
stylesheet: false,
|
|
23
|
+
fixtures: false
|
|
24
|
+
};
|
|
25
|
+
const SETTLE_MS = 30;
|
|
26
|
+
function failureText(failures) {
|
|
27
|
+
return failures.map((failure) => `${failure.file}${failure.line === void 0 ? "" : `:${String(failure.line)}`} ${qualify(failure.rule)}\n ${failure.message.replace(/\n/g, "\n ")}`).join("\n");
|
|
35
28
|
}
|
|
36
|
-
function
|
|
37
|
-
|
|
38
|
-
const [head, fixture, view, ...rest] = path.split("/").filter(Boolean);
|
|
39
|
-
return head === "fixtures" && fixture !== void 0 && view === "canvas" && rest.length <= 1;
|
|
40
|
-
}
|
|
41
|
-
async function loadHostModule(packageRoot) {
|
|
42
|
-
const file = playgroundHostFile(packageRoot);
|
|
43
|
-
if (!existsSync(file)) throw new Error(`the playground host module is not built (${file}) — run the package's build.`);
|
|
44
|
-
const mod = await import(pathToFileURL(file).href);
|
|
45
|
-
if (typeof mod.createHost !== "function") throw new Error(`${file} does not export createHost.`);
|
|
46
|
-
return mod.createHost;
|
|
29
|
+
function isWorkspaceChange(path) {
|
|
30
|
+
return path.split("/").every((segment) => segment !== "node_modules" && !segment.startsWith("."));
|
|
47
31
|
}
|
|
48
32
|
async function startDevServer(options) {
|
|
49
|
-
const { root,
|
|
50
|
-
const
|
|
51
|
-
const packageRoot$1 = packageRoot();
|
|
52
|
-
const clientDir = playgroundClientOutDir(packageRoot$1);
|
|
53
|
-
if (!existsSync(join(clientDir, "index.html"))) log.write(`concrete dev: the playground client is not built (${clientDir}) — run the package's build.\n`);
|
|
54
|
-
const createHost = await loadHostModule(packageRoot$1);
|
|
55
|
-
const sourceMarker = join(packageRoot$1, "src", "islands", "marker.tsx");
|
|
56
|
-
const browserMarker = RUNNING_FROM_SOURCE ? fsUrl(sourceMarker) : "@homepages/concrete";
|
|
57
|
-
const serverMarker = RUNNING_FROM_SOURCE ? sourceMarker : "@homepages/concrete";
|
|
58
|
-
const islandEntries = findWorkspaceIslands(root).map((file) => toPosix(relative(root, file)));
|
|
59
|
-
const browserAssets = /* @__PURE__ */ new Map();
|
|
33
|
+
const { root, log } = options;
|
|
34
|
+
const out = join(root, ...DEV_BUILD_DIR.split("/"));
|
|
60
35
|
let onLadderReady = () => {};
|
|
61
|
-
const ladders =
|
|
36
|
+
const ladders = createSectionLadders({
|
|
62
37
|
cacheDir: mediaCacheDir(root),
|
|
63
38
|
log,
|
|
64
39
|
onReady: () => onLadderReady()
|
|
65
40
|
});
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
});
|
|
69
|
-
await listenOn(hmrServer, hmrPort, `port ${String(hmrPort)} (the editor's module-reload socket, --port + ${String(100)})`);
|
|
70
|
-
const closeHmrServer = () => new Promise((done) => hmrServer.close(() => done()));
|
|
71
|
-
let vite;
|
|
72
|
-
try {
|
|
73
|
-
vite = await createDevVite({
|
|
74
|
-
root,
|
|
75
|
-
packageRoot: packageRoot$1,
|
|
76
|
-
markerSpecifier: browserMarker,
|
|
77
|
-
hmrServer,
|
|
78
|
-
hmrPort,
|
|
79
|
-
islandEntries,
|
|
80
|
-
assets: browserAssets,
|
|
81
|
-
ladders
|
|
82
|
-
});
|
|
83
|
-
} catch (err) {
|
|
84
|
-
await closeHmrServer();
|
|
85
|
-
throw err;
|
|
86
|
-
}
|
|
87
|
-
let islands = {
|
|
88
|
-
map: {},
|
|
89
|
-
canvasHost: null,
|
|
90
|
-
previewHost: null
|
|
91
|
-
};
|
|
92
|
-
let islandKey = "";
|
|
93
|
-
const refreshIslands = async () => {
|
|
94
|
-
const files = findWorkspaceIslands(root);
|
|
95
|
-
const key = files.join("\n");
|
|
96
|
-
if (key === islandKey && islands.canvasHost !== null) return false;
|
|
97
|
-
islandKey = key;
|
|
98
|
-
const scripts = await writeIslandHostScripts(root, files);
|
|
99
|
-
islands = files.length === 0 ? {
|
|
100
|
-
map: {},
|
|
101
|
-
canvasHost: null,
|
|
102
|
-
previewHost: null
|
|
103
|
-
} : {
|
|
104
|
-
map: islandMapOf(root, files),
|
|
105
|
-
canvasHost: scripts.canvas,
|
|
106
|
-
previewHost: scripts.preview
|
|
107
|
-
};
|
|
108
|
-
return true;
|
|
109
|
-
};
|
|
110
|
-
await refreshIslands();
|
|
111
|
-
const capturer = options.capturer ?? createCapturer({
|
|
41
|
+
let server = null;
|
|
42
|
+
const files = folderFiles({
|
|
112
43
|
root,
|
|
113
|
-
|
|
44
|
+
build: { failure: "The template is still building." },
|
|
45
|
+
onWritten: () => server?.changes.moved(FIXTURES_MOVED)
|
|
114
46
|
});
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
const capture = async (request) => {
|
|
118
|
-
browserGraphSettled ??= settleBrowserDependencies(vite, [...islands.previewHost === null ? [] : [islands.previewHost], ...Object.values(islands.map)]);
|
|
119
|
-
await browserGraphSettled;
|
|
47
|
+
const buildOnce = async () => {
|
|
48
|
+
const started = performance.now();
|
|
120
49
|
try {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
50
|
+
const build = await buildTemplate({
|
|
51
|
+
root,
|
|
52
|
+
out,
|
|
53
|
+
pending: ladders
|
|
54
|
+
});
|
|
55
|
+
if (build.output === null) {
|
|
56
|
+
const text = failureText(build.failures);
|
|
57
|
+
log.write(`concrete dev: the template did not build:\n${text}\n`);
|
|
58
|
+
return { failure: `The template did not build:\n${text}` };
|
|
59
|
+
}
|
|
60
|
+
if (build.composition?.ok === true) await writeFixtureSchemas(root, build.composition.value).catch(() => void 0);
|
|
61
|
+
const { sections } = build.output.record;
|
|
62
|
+
const rebuilt = sections.filter((section) => section.rebuilt).length;
|
|
63
|
+
log.write(`concrete dev: built in ${String(Math.round(performance.now() - started))} ms — ${String(rebuilt)} of ${String(sections.length)} sections.\n`);
|
|
64
|
+
return { output: build.output };
|
|
65
|
+
} catch (cause) {
|
|
66
|
+
const message = cause instanceof Error ? cause.message : String(cause);
|
|
67
|
+
log.write(`concrete dev: the template did not build: ${message}\n`);
|
|
68
|
+
return { failure: `The template did not build: ${message}` };
|
|
125
69
|
}
|
|
126
70
|
};
|
|
127
|
-
|
|
71
|
+
let running = null;
|
|
72
|
+
let again = false;
|
|
73
|
+
const rebuild = () => {
|
|
74
|
+
if (running !== null) {
|
|
75
|
+
again = true;
|
|
76
|
+
return running;
|
|
77
|
+
}
|
|
78
|
+
running = (async () => {
|
|
79
|
+
do {
|
|
80
|
+
again = false;
|
|
81
|
+
files.serve(await buildOnce());
|
|
82
|
+
server?.changes.moved(SOURCE_MOVED);
|
|
83
|
+
} while (again);
|
|
84
|
+
})().finally(() => {
|
|
85
|
+
running = null;
|
|
86
|
+
});
|
|
87
|
+
return running;
|
|
88
|
+
};
|
|
89
|
+
server = await startPlaygroundServer({
|
|
128
90
|
root,
|
|
129
|
-
|
|
130
|
-
islands: () => islands,
|
|
131
|
-
capture,
|
|
132
|
-
ladders
|
|
133
|
-
});
|
|
134
|
-
const assetUrl = (path, transform) => transform === void 0 ? path : croppedMediaUrl(path, transform.crop);
|
|
135
|
-
const host = createHost({
|
|
136
|
-
reader: workspace,
|
|
137
|
-
assetUrl,
|
|
138
|
-
renderer: workspace.renderer(),
|
|
139
|
-
base: "/"
|
|
140
|
-
});
|
|
141
|
-
const hmr = createHmrBus();
|
|
142
|
-
const ctx = {
|
|
143
|
-
port,
|
|
144
|
-
vite,
|
|
145
|
-
workspace,
|
|
146
|
-
host,
|
|
147
|
-
hmr,
|
|
148
|
-
clientDir,
|
|
149
|
-
baseCss: packageFile("css/base.css", "base.css"),
|
|
91
|
+
port: options.port,
|
|
150
92
|
log,
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
93
|
+
files,
|
|
94
|
+
cutsLadders: true,
|
|
95
|
+
...options.browser === void 0 ? {} : { browser: options.browser },
|
|
96
|
+
...options.toolsReady === void 0 ? {} : { toolsReady: options.toolsReady }
|
|
97
|
+
});
|
|
98
|
+
const playground = server;
|
|
99
|
+
onLadderReady = () => void rebuild();
|
|
100
|
+
let pending = null;
|
|
101
|
+
let fixturesChanged = false;
|
|
102
|
+
let sourceChanged = false;
|
|
103
|
+
const flush = () => {
|
|
104
|
+
pending = null;
|
|
105
|
+
if (fixturesChanged) {
|
|
106
|
+
fixturesChanged = false;
|
|
107
|
+
files.changed();
|
|
108
|
+
playground.changes.moved(FIXTURES_MOVED);
|
|
163
109
|
}
|
|
164
|
-
if (
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
return;
|
|
110
|
+
if (sourceChanged) {
|
|
111
|
+
sourceChanged = false;
|
|
112
|
+
rebuild();
|
|
168
113
|
}
|
|
169
|
-
workspace.invalidateSource();
|
|
170
|
-
refreshIslands().finally(() => {
|
|
171
|
-
hmr.broadcast(HMR_EVENTS.source);
|
|
172
|
-
hmr.broadcast(HMR_EVENTS.stylesheet);
|
|
173
|
-
});
|
|
174
|
-
};
|
|
175
|
-
onLadderReady = () => {
|
|
176
|
-
vite.moduleGraph.invalidateAll();
|
|
177
|
-
browserGraphSettled = null;
|
|
178
|
-
workspace.invalidateMedia();
|
|
179
|
-
hmr.broadcast(HMR_EVENTS.source);
|
|
180
114
|
};
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
respondToHandlerError(err, req, res, (error) => vite.ssrFixStacktrace(error));
|
|
191
|
-
});
|
|
115
|
+
const watcher = watch(root, { recursive: true }, (_event, filename) => {
|
|
116
|
+
if (filename === null) return;
|
|
117
|
+
const path = toPosix(relative(root, join(root, filename)));
|
|
118
|
+
if (path === "" || path.startsWith("../") || !isWorkspaceChange(path)) return;
|
|
119
|
+
if (files.reaches(path) || path.endsWith(".json") && !TOOLING_FILES.has(path)) fixturesChanged = true;
|
|
120
|
+
else sourceChanged = true;
|
|
121
|
+
pending ??= setTimeout(flush, SETTLE_MS);
|
|
192
122
|
});
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
123
|
+
watcher.on("error", (err) => log.write(`concrete dev: the workspace watcher stopped: ${err.message}\n`));
|
|
124
|
+
await rebuild();
|
|
125
|
+
const built = async () => {
|
|
126
|
+
while (pending !== null || running !== null) {
|
|
127
|
+
if (pending !== null) {
|
|
128
|
+
clearTimeout(pending);
|
|
129
|
+
flush();
|
|
130
|
+
}
|
|
131
|
+
await running;
|
|
132
|
+
}
|
|
133
|
+
};
|
|
200
134
|
return {
|
|
201
|
-
url:
|
|
202
|
-
port,
|
|
203
|
-
|
|
204
|
-
|
|
135
|
+
url: playground.url,
|
|
136
|
+
port: playground.port,
|
|
137
|
+
sectionLadders: ladders,
|
|
138
|
+
built,
|
|
205
139
|
close: async () => {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
await
|
|
140
|
+
watcher.close();
|
|
141
|
+
if (pending !== null) clearTimeout(pending);
|
|
142
|
+
await running;
|
|
143
|
+
await playground.close();
|
|
209
144
|
await ladders.close();
|
|
210
|
-
await vite.close();
|
|
211
|
-
await closeHmrServer();
|
|
212
145
|
}
|
|
213
146
|
};
|
|
214
147
|
}
|
|
215
|
-
async function toFetchRequest(req, url) {
|
|
216
|
-
const method = req.method ?? "GET";
|
|
217
|
-
const headers = new Headers();
|
|
218
|
-
for (const [name, value] of Object.entries(req.headers)) if (typeof value === "string") headers.set(name, value);
|
|
219
|
-
else if (Array.isArray(value)) for (const item of value) headers.append(name, item);
|
|
220
|
-
const body = method === "GET" || method === "HEAD" ? void 0 : await readBody(req, MAX_BODY_BYTES);
|
|
221
|
-
return new Request(url, {
|
|
222
|
-
method,
|
|
223
|
-
headers,
|
|
224
|
-
...body === void 0 ? {} : { body: new Uint8Array(body) }
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
async function sendFetchResponse(res, response) {
|
|
228
|
-
res.statusCode = response.status;
|
|
229
|
-
response.headers.forEach((value, name) => res.setHeader(name, value));
|
|
230
|
-
res.end(Buffer.from(await response.arrayBuffer()));
|
|
231
|
-
}
|
|
232
|
-
async function handle(req, res, ctx) {
|
|
233
|
-
const url = new URL(req.url ?? "/", `http://localhost:${ctx.port}`);
|
|
234
|
-
const path = url.pathname;
|
|
235
|
-
if (isCanvasPath(path)) return sendClientShell(ctx, res);
|
|
236
|
-
if (path === `/${ROUTES.hmr}`) return ctx.hmr.attach(res);
|
|
237
|
-
if (path === `/${STYLESHEET_PATHS.base}`) return sendBytes(res, "text/css; charset=utf-8", await readFile(ctx.baseCss));
|
|
238
|
-
if (path === `/${STYLESHEET_PATHS.template}`) return sendTemplateCss(ctx, res);
|
|
239
|
-
const assetPrefix = SECTION_ASSET_PREFIXES.find((prefix) => path.startsWith(prefix));
|
|
240
|
-
if (assetPrefix !== void 0) return sendSectionAsset(ctx, path.slice(assetPrefix.length), res);
|
|
241
|
-
if (path.startsWith(`${"/fixture-media"}/`)) return sendFixtureMedia(ctx, req, url, res);
|
|
242
|
-
const answered = await ctx.host.handle(await toFetchRequest(req, url));
|
|
243
|
-
if (answered !== null) return sendFetchResponse(res, answered);
|
|
244
|
-
if (await sendClientAsset(ctx, path, res)) return;
|
|
245
|
-
ctx.vite.middlewares(req, res, () => sendText(res, 404, "not found"));
|
|
246
|
-
}
|
|
247
|
-
async function sendClientShell(ctx, res) {
|
|
248
|
-
let html;
|
|
249
|
-
try {
|
|
250
|
-
html = await readFile(join(ctx.clientDir, "index.html"), "utf8");
|
|
251
|
-
} catch {
|
|
252
|
-
sendText(res, 500, "the playground client is not built — run the package's build");
|
|
253
|
-
return;
|
|
254
|
-
}
|
|
255
|
-
sendHtml(res, stampBase(html, "/"));
|
|
256
|
-
}
|
|
257
|
-
async function sendClientAsset(ctx, path, res) {
|
|
258
|
-
const file = resolve(ctx.clientDir, `.${decodeURIComponent(path)}`);
|
|
259
|
-
if (!isInsideRoot(ctx.clientDir, file)) return false;
|
|
260
|
-
try {
|
|
261
|
-
if (!statSync(file).isFile()) return false;
|
|
262
|
-
} catch {
|
|
263
|
-
return false;
|
|
264
|
-
}
|
|
265
|
-
sendBytes(res, contentTypeFor(file), await readFile(file));
|
|
266
|
-
return true;
|
|
267
|
-
}
|
|
268
|
-
async function sendTemplateCss(ctx, res) {
|
|
269
|
-
const { css, violations } = await ctx.workspace.templateCss();
|
|
270
|
-
for (const violation of violations) ctx.log.write(`concrete dev: ${violation.file}: ${violation.message} (${violation.rule})\n`);
|
|
271
|
-
res.setHeader("cache-control", "no-cache");
|
|
272
|
-
sendBytes(res, "text/css; charset=utf-8", new TextEncoder().encode(css));
|
|
273
|
-
}
|
|
274
|
-
function sendSectionAsset(ctx, rawFilename, res) {
|
|
275
|
-
const filename = decodeURIComponent(rawFilename);
|
|
276
|
-
if (filename.includes("/") || filename.includes("\\") || filename.includes("..")) {
|
|
277
|
-
sendText(res, 403, "forbidden");
|
|
278
|
-
return;
|
|
279
|
-
}
|
|
280
|
-
const asset = ctx.workspace.sectionAsset(filename);
|
|
281
|
-
if (asset === void 0) {
|
|
282
|
-
sendText(res, 404, "not found");
|
|
283
|
-
return;
|
|
284
|
-
}
|
|
285
|
-
sendBytes(res, asset.contentType, asset.bytes);
|
|
286
|
-
}
|
|
287
|
-
async function sendFixtureMedia(ctx, req, url, res) {
|
|
288
|
-
if (req.method !== "GET" && req.method !== "HEAD") {
|
|
289
|
-
sendText(res, 405, "fixture media only reads; the playground accepts no uploads.");
|
|
290
|
-
return;
|
|
291
|
-
}
|
|
292
|
-
const path = decodeURIComponent(url.pathname);
|
|
293
|
-
const asset = await ctx.workspace.fixtureAsset(path) ?? ctx.browserAssets.get(path);
|
|
294
|
-
const cropValue = url.searchParams.get(CROP_PARAM);
|
|
295
|
-
if (asset === void 0) {
|
|
296
|
-
const rung = ctx.ladders.rung(path);
|
|
297
|
-
if (rung === void 0) sendText(res, 404, "not found");
|
|
298
|
-
else if (cropValue !== null) sendText(res, 400, `${url.pathname} is one rung of an image's ladder; crop the image itself.`);
|
|
299
|
-
else sendBytes(res, rung.contentType, rung.bytes);
|
|
300
|
-
return;
|
|
301
|
-
}
|
|
302
|
-
if (cropValue === null) {
|
|
303
|
-
await sendFile(req, res, asset.path);
|
|
304
|
-
return;
|
|
305
|
-
}
|
|
306
|
-
const rect = parseCropParam(cropValue);
|
|
307
|
-
if (rect === null) {
|
|
308
|
-
sendText(res, 400, `"${cropValue}" is not a crop of the image.`);
|
|
309
|
-
return;
|
|
310
|
-
}
|
|
311
|
-
if (!asset.derived) {
|
|
312
|
-
sendText(res, 400, `${url.pathname} is not a raster image and cannot be cropped.`);
|
|
313
|
-
return;
|
|
314
|
-
}
|
|
315
|
-
const key = `${url.pathname}?${CROP_PARAM}=${cropValue}`;
|
|
316
|
-
let cut = ctx.crops.get(key);
|
|
317
|
-
if (cut === void 0) {
|
|
318
|
-
cut = readFile(asset.path).then((bytes) => cutRegion(bytes, rect));
|
|
319
|
-
cut.catch(() => ctx.crops.delete(key));
|
|
320
|
-
ctx.crops.set(key, cut);
|
|
321
|
-
if (ctx.crops.size > MAX_CACHED_CROPS) ctx.crops.delete(ctx.crops.keys().next().value);
|
|
322
|
-
}
|
|
323
|
-
const image = await cut;
|
|
324
|
-
if (image === null) {
|
|
325
|
-
ctx.log.write(`concrete dev: sharp is not installed, so a crop of ${url.pathname} serves the whole image.\n`);
|
|
326
|
-
await sendFile(req, res, asset.path);
|
|
327
|
-
return;
|
|
328
|
-
}
|
|
329
|
-
res.setHeader("cache-control", "no-cache");
|
|
330
|
-
sendBytes(res, image.contentType, image.bytes);
|
|
331
|
-
}
|
|
332
148
|
|
|
333
149
|
//#endregion
|
|
334
|
-
export {
|
|
150
|
+
export { DEV_BUILD_DIR, failureText, startDevServer };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { PLAYGROUND_TOOLS, TOOLS_INSTALL_COMMAND } from "./tools.js";
|
|
2
|
+
|
|
3
|
+
//#region src/cli/install/background.ts
|
|
4
|
+
async function installMissingTools(log, tools = PLAYGROUND_TOOLS) {
|
|
5
|
+
const missing = [];
|
|
6
|
+
for (const tool of tools) if (!await tool.present().catch(() => true)) missing.push(tool);
|
|
7
|
+
if (missing.length === 0) return { ready: Promise.resolve() };
|
|
8
|
+
const names = missing.map((tool) => tool.name).join(" and ");
|
|
9
|
+
log.write(`concrete dev: installing ${names} in the background — captures wait for it.\n`);
|
|
10
|
+
return { ready: Promise.all(missing.map((tool) => tool.install().catch((cause) => {
|
|
11
|
+
log.write(`concrete dev: installing ${tool.name} failed (${cause instanceof Error ? cause.message : String(cause)}). Install it with \`${TOOLS_INSTALL_COMMAND}\`.\n`);
|
|
12
|
+
}))).then(() => void 0) };
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
export { installMissingTools };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { parseSpec } from "../commands.js";
|
|
2
|
+
import { PLAYGROUND_TOOLS, TOOLS_INSTALL_COMMAND } from "./tools.js";
|
|
3
|
+
import { parseArgs } from "node:util";
|
|
4
|
+
|
|
5
|
+
//#region src/cli/install/index.ts
|
|
6
|
+
const PREFIX = "concrete install";
|
|
7
|
+
function messageOf(cause) {
|
|
8
|
+
return cause instanceof Error ? cause.message : String(cause);
|
|
9
|
+
}
|
|
10
|
+
function installWith(tools) {
|
|
11
|
+
return async (argv, io) => {
|
|
12
|
+
try {
|
|
13
|
+
parseArgs({
|
|
14
|
+
args: [...argv],
|
|
15
|
+
...parseSpec("install"),
|
|
16
|
+
allowPositionals: false,
|
|
17
|
+
strict: true
|
|
18
|
+
});
|
|
19
|
+
} catch (cause) {
|
|
20
|
+
io.stderr.write(`${PREFIX}: ${messageOf(cause)}\n`);
|
|
21
|
+
return 1;
|
|
22
|
+
}
|
|
23
|
+
let failed = false;
|
|
24
|
+
for (const tool of tools) {
|
|
25
|
+
if (await tool.present()) {
|
|
26
|
+
io.stdout.write(`${PREFIX}: ${tool.name} is already installed.\n`);
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
io.stdout.write(`${PREFIX}: installing ${tool.name}…\n`);
|
|
30
|
+
try {
|
|
31
|
+
await tool.install({ sink: io.stderr });
|
|
32
|
+
io.stdout.write(`${PREFIX}: ${tool.name} installed.\n`);
|
|
33
|
+
} catch (cause) {
|
|
34
|
+
io.stderr.write(`${PREFIX}: installing ${tool.name} failed: ${messageOf(cause)}\n`);
|
|
35
|
+
failed = true;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (failed) io.stderr.write(`${PREFIX}: run \`${TOOLS_INSTALL_COMMAND}\` again once the download can complete.\n`);
|
|
39
|
+
return failed ? 1 : 0;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
const runInstall = installWith(PLAYGROUND_TOOLS);
|
|
43
|
+
|
|
44
|
+
//#endregion
|
|
45
|
+
export { installWith, runInstall };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { runNodeScript } from "../../platform/process.js";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
import { createRequire } from "node:module";
|
|
5
|
+
|
|
6
|
+
//#region src/cli/install/tools.ts
|
|
7
|
+
const require = createRequire(import.meta.url);
|
|
8
|
+
const chromium = {
|
|
9
|
+
name: "Chromium",
|
|
10
|
+
async present() {
|
|
11
|
+
const { chromium: browser } = await import("playwright-core");
|
|
12
|
+
return existsSync(browser.executablePath());
|
|
13
|
+
},
|
|
14
|
+
async install({ sink } = {}) {
|
|
15
|
+
const failure = await runNodeScript([
|
|
16
|
+
join(dirname(require.resolve("playwright-core/package.json")), "cli.js"),
|
|
17
|
+
"install",
|
|
18
|
+
"chromium"
|
|
19
|
+
], sink === void 0 ? {} : { sink });
|
|
20
|
+
if (failure !== null) throw new Error(`Playwright's installer ${failure}`);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const PLAYGROUND_TOOLS = [chromium];
|
|
24
|
+
const TOOLS_INSTALL_COMMAND = "npx concrete install";
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
export { PLAYGROUND_TOOLS, TOOLS_INSTALL_COMMAND, chromium };
|
package/dist/cli/media/derive.js
CHANGED
|
@@ -92,16 +92,8 @@ async function lookupCached(keys, masterByteLength, cacheDir) {
|
|
|
92
92
|
derivationCache.set(keys.memoKey, memo);
|
|
93
93
|
return toDerivation(memo, keys.master, masterByteLength, false);
|
|
94
94
|
}
|
|
95
|
-
|
|
96
|
-
return
|
|
97
|
-
}
|
|
98
|
-
async function deriveAuthorImage(absPath, bytes, opts = {}) {
|
|
99
|
-
const keys = derivationKeys(absPath, bytes, opts);
|
|
100
|
-
const { stem, hash, floor, memoKey, diskKey, master } = keys;
|
|
101
|
-
const hit = await lookupCached(keys, bytes.byteLength, opts.cacheDir);
|
|
102
|
-
if (hit) return hit;
|
|
103
|
-
const sharp = await (opts.loadSharp ?? defaultLoadSharp)();
|
|
104
|
-
if (!sharp) return {
|
|
95
|
+
function masterOnly(master, masterByteLength) {
|
|
96
|
+
return {
|
|
105
97
|
image: {
|
|
106
98
|
url: `${ASSET_PUBLIC_PATH}/${master.filename}`,
|
|
107
99
|
responsive: null,
|
|
@@ -114,10 +106,24 @@ async function deriveAuthorImage(absPath, bytes, opts = {}) {
|
|
|
114
106
|
contentType: master.contentType
|
|
115
107
|
}],
|
|
116
108
|
master,
|
|
117
|
-
masterBytes:
|
|
118
|
-
derivedBytes:
|
|
109
|
+
masterBytes: masterByteLength,
|
|
110
|
+
derivedBytes: masterByteLength,
|
|
119
111
|
passthrough: true
|
|
120
112
|
};
|
|
113
|
+
}
|
|
114
|
+
function masterOnlyDerivation(absPath, bytes) {
|
|
115
|
+
return masterOnly(derivationKeys(absPath, bytes, {}).master, bytes.byteLength);
|
|
116
|
+
}
|
|
117
|
+
async function cachedAuthorImage(absPath, bytes, opts = {}) {
|
|
118
|
+
return lookupCached(derivationKeys(absPath, bytes, opts), bytes.byteLength, opts.cacheDir);
|
|
119
|
+
}
|
|
120
|
+
async function deriveAuthorImage(absPath, bytes, opts = {}) {
|
|
121
|
+
const keys = derivationKeys(absPath, bytes, opts);
|
|
122
|
+
const { stem, hash, floor, memoKey, diskKey, master } = keys;
|
|
123
|
+
const hit = await lookupCached(keys, bytes.byteLength, opts.cacheDir);
|
|
124
|
+
if (hit) return hit;
|
|
125
|
+
const sharp = await (opts.loadSharp ?? defaultLoadSharp)();
|
|
126
|
+
if (!sharp) return masterOnly(master, bytes.byteLength);
|
|
121
127
|
const { encodeRungs, LADDER_SPEC, rungsFor } = await loadImageLadder();
|
|
122
128
|
const buffer = Buffer.from(bytes);
|
|
123
129
|
const meta = await sharp(buffer).metadata();
|
|
@@ -170,4 +176,4 @@ async function deriveAuthorImage(absPath, bytes, opts = {}) {
|
|
|
170
176
|
}
|
|
171
177
|
|
|
172
178
|
//#endregion
|
|
173
|
-
export { DERIVABLE_EXTENSIONS, UnsafeStemError, cachedAuthorImage, deriveAuthorImage, frameReachableRungs, masterHash };
|
|
179
|
+
export { DERIVABLE_EXTENSIONS, UnsafeStemError, cachedAuthorImage, deriveAuthorImage, frameReachableRungs, masterHash, masterOnlyDerivation };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DERIVABLE_EXTENSIONS, deriveAuthorImage } from "./derive.js";
|
|
1
|
+
import { DERIVABLE_EXTENSIONS, cachedAuthorImage, deriveAuthorImage, masterOnlyDerivation } from "./derive.js";
|
|
2
2
|
import { extname } from "node:path";
|
|
3
3
|
import { readFile } from "node:fs/promises";
|
|
4
4
|
|
|
@@ -10,6 +10,7 @@ function createMediaDeriver(opts = {}) {
|
|
|
10
10
|
const derived = /* @__PURE__ */ new Map();
|
|
11
11
|
const masters = /* @__PURE__ */ new Map();
|
|
12
12
|
const passthrough = /* @__PURE__ */ new Set();
|
|
13
|
+
const pending = /* @__PURE__ */ new Set();
|
|
13
14
|
const sources = /* @__PURE__ */ new Map();
|
|
14
15
|
return {
|
|
15
16
|
plugin: {
|
|
@@ -37,10 +38,19 @@ function createMediaDeriver(opts = {}) {
|
|
|
37
38
|
namespace: NAMESPACE
|
|
38
39
|
}, async (args) => {
|
|
39
40
|
const bytes = await readFile(args.path);
|
|
40
|
-
const
|
|
41
|
+
const options = {
|
|
41
42
|
cacheDir: opts.cacheDir,
|
|
42
43
|
minRungWidth: opts.minRungWidth
|
|
43
|
-
}
|
|
44
|
+
};
|
|
45
|
+
let derivation = opts.pending === void 0 ? await deriveAuthorImage(args.path, bytes, options) : await cachedAuthorImage(args.path, bytes, options);
|
|
46
|
+
if (derivation === null) {
|
|
47
|
+
derivation = {
|
|
48
|
+
...masterOnlyDerivation(args.path, bytes),
|
|
49
|
+
passthrough: false
|
|
50
|
+
};
|
|
51
|
+
pending.add(args.path);
|
|
52
|
+
opts.pending?.derive(args.path, bytes, opts.minRungWidth);
|
|
53
|
+
}
|
|
44
54
|
for (const asset of derivation.derivatives) derived.set(asset.filename, asset);
|
|
45
55
|
const { key, filename, bytes: masterBytes, contentType } = derivation.master;
|
|
46
56
|
derived.set(filename, {
|
|
@@ -65,6 +75,7 @@ function createMediaDeriver(opts = {}) {
|
|
|
65
75
|
derived,
|
|
66
76
|
masters,
|
|
67
77
|
passthrough,
|
|
78
|
+
pending,
|
|
68
79
|
sources
|
|
69
80
|
};
|
|
70
81
|
}
|