@homepages/concrete 11.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 +203 -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 +17 -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 -60
- package/dist/base.css +19 -59
- 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 +48 -22
- package/dist/packages/internal/fill-bake/dist/held-rows.js +2 -0
- package/dist/packages/internal/fill-bake/dist/index.js +6 -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/format-geometry/dist/capture.js +3 -11
- package/dist/packages/internal/format-geometry/dist/format.d.ts +2 -8
- package/dist/packages/internal/format-geometry/dist/geometry.js +2 -13
- 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/primitives/FrameShell.d.ts +5 -2
- package/dist/primitives/FrameShell.js +2 -1
- package/dist/rules/registry.js +28 -4
- package/dist/schema/fact.d.ts +2 -2
- package/dist/schema/facts-view.d.ts +1 -1
- package/dist/schema/format.d.ts +0 -1
- package/dist/schema/format.js +1 -2
- package/dist/schema/manifest.js +18 -24
- 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/site-analytics.js +6 -1
- package/dist/site-runtime/window-height.js +19 -0
- package/dist/template/define-template.d.ts +25 -4
- package/dist/template/define-template.js +3 -0
- package/dist/template/logic-shim.d.ts +1 -1
- package/dist/template/materialize.js +3 -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 +9 -5
- package/package.json +14 -30
- package/dist/artifact/playground/client/assets/index-ByeGGedv.js +0 -1259
- 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 -113
- 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 -248
- 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
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { captureViewport, printPageSize, printViewport } from "../../packages/internal/format-geometry/dist/capture.js";
|
|
2
|
-
import { CAPTURE_WAIT_UNTIL, settleCapture } from "../../packages/internal/capture-settle/dist/settle.js";
|
|
3
|
-
import "../../packages/internal/capture-settle/dist/index.js";
|
|
4
|
-
import { bundlePages } from "./bundle.js";
|
|
5
|
-
import { closeCapturePage, createCaptureBrowserPool } from "./capture-browser.js";
|
|
6
|
-
import { join } from "node:path";
|
|
7
|
-
import { pathToFileURL } from "node:url";
|
|
8
|
-
import { createRequire } from "node:module";
|
|
9
|
-
|
|
10
|
-
//#region src/cli/capture/capture.ts
|
|
11
|
-
var CaptureUnavailableError = class extends Error {};
|
|
12
|
-
const INSTALL_LINE = "captures need Playwright. Install it in this workspace with these two commands, in order:\n npm install --save-dev @playwright/test\n npx playwright install chromium";
|
|
13
|
-
async function importPlaywright(root, packageRoot) {
|
|
14
|
-
for (const base of [root, packageRoot]) {
|
|
15
|
-
let resolved;
|
|
16
|
-
try {
|
|
17
|
-
resolved = createRequire(pathToFileURL(join(base, "package.json"))).resolve("@playwright/test");
|
|
18
|
-
} catch {
|
|
19
|
-
continue;
|
|
20
|
-
}
|
|
21
|
-
const mod = await import(pathToFileURL(resolved).href);
|
|
22
|
-
const chromium = mod.chromium ?? mod.default?.chromium;
|
|
23
|
-
if (chromium !== void 0) return { chromium };
|
|
24
|
-
}
|
|
25
|
-
throw new CaptureUnavailableError(INSTALL_LINE);
|
|
26
|
-
}
|
|
27
|
-
function settleHost(page) {
|
|
28
|
-
return {
|
|
29
|
-
evaluate: (expression) => page.evaluate(expression),
|
|
30
|
-
onNetworkActivity: (listener) => {
|
|
31
|
-
page.on("request", listener);
|
|
32
|
-
page.on("requestfinished", listener);
|
|
33
|
-
page.on("requestfailed", listener);
|
|
34
|
-
return () => {
|
|
35
|
-
page.off("request", listener);
|
|
36
|
-
page.off("requestfinished", listener);
|
|
37
|
-
page.off("requestfailed", listener);
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
function createCapturer(options) {
|
|
43
|
-
const pool = createCaptureBrowserPool(options.launch ?? (async () => {
|
|
44
|
-
const { chromium } = await importPlaywright(options.root, options.packageRoot);
|
|
45
|
-
try {
|
|
46
|
-
return await chromium.launch();
|
|
47
|
-
} catch (err) {
|
|
48
|
-
throw new CaptureUnavailableError(`chromium is not available — run: npx playwright install chromium\n(${err instanceof Error ? err.message : String(err)})`);
|
|
49
|
-
}
|
|
50
|
-
}));
|
|
51
|
-
const withPage = async (viewport, run) => {
|
|
52
|
-
const page = await (await pool.acquire()).newPage({
|
|
53
|
-
viewport: {
|
|
54
|
-
width: viewport.width,
|
|
55
|
-
height: viewport.height
|
|
56
|
-
},
|
|
57
|
-
deviceScaleFactor: viewport.deviceScaleFactor
|
|
58
|
-
});
|
|
59
|
-
try {
|
|
60
|
-
return await run(page);
|
|
61
|
-
} finally {
|
|
62
|
-
await closeCapturePage(page);
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
const shoot = async (page, url) => {
|
|
66
|
-
await page.goto(url, { waitUntil: CAPTURE_WAIT_UNTIL });
|
|
67
|
-
await settleCapture(settleHost(page));
|
|
68
|
-
return new Uint8Array(await page.screenshot({ fullPage: false }));
|
|
69
|
-
};
|
|
70
|
-
return {
|
|
71
|
-
screenshot: (url, format) => withPage(captureViewport(format), (page) => shoot(page, url)),
|
|
72
|
-
bundle: (entries, format) => withPage(captureViewport(format), async (page) => {
|
|
73
|
-
const members = [];
|
|
74
|
-
for (const entry of entries) members.push({
|
|
75
|
-
name: entry.name,
|
|
76
|
-
bytes: await shoot(page, entry.url)
|
|
77
|
-
});
|
|
78
|
-
return new Uint8Array(bundlePages(members));
|
|
79
|
-
}),
|
|
80
|
-
print: (url, format) => withPage(printViewport(format), async (page) => {
|
|
81
|
-
await page.emulateMedia({ media: "screen" });
|
|
82
|
-
await page.goto(url, { waitUntil: CAPTURE_WAIT_UNTIL });
|
|
83
|
-
await settleCapture(settleHost(page));
|
|
84
|
-
const paper = printPageSize(format);
|
|
85
|
-
return new Uint8Array(await page.pdf({
|
|
86
|
-
width: paper.width,
|
|
87
|
-
height: paper.height,
|
|
88
|
-
margin: {
|
|
89
|
-
top: "0",
|
|
90
|
-
right: "0",
|
|
91
|
-
bottom: "0",
|
|
92
|
-
left: "0"
|
|
93
|
-
},
|
|
94
|
-
printBackground: true
|
|
95
|
-
}));
|
|
96
|
-
}),
|
|
97
|
-
close: () => pool.close()
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
async function captureFixture(capturer, origin, request) {
|
|
101
|
-
const entries = request.documents.map((document) => ({
|
|
102
|
-
url: new URL(document.path, origin).href,
|
|
103
|
-
name: document.name
|
|
104
|
-
}));
|
|
105
|
-
const [first] = entries;
|
|
106
|
-
if (first === void 0) throw new Error(`A ${request.kind} capture of "${request.fixture}" names no document.`);
|
|
107
|
-
if (request.kind === "screenshot") return capturer.screenshot(first.url, request.format);
|
|
108
|
-
if (request.kind === "bundle") return capturer.bundle(entries, request.format);
|
|
109
|
-
return capturer.print(first.url, request.format);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
//#endregion
|
|
113
|
-
export { CaptureUnavailableError, captureFixture, createCapturer };
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { fixtureMediaRecords, fixtureMediaStore, resolveFixtureSlots } from "../../../fixtures/media-store.js";
|
|
2
|
-
import { resolveNav } from "./nav.js";
|
|
3
|
-
|
|
4
|
-
//#region src/cli/check/render/inputs.ts
|
|
5
|
-
async function* renderInputs(composition, sections, corpus, assets) {
|
|
6
|
-
const byKey = new Map(sections.map((entry) => [entry.key, entry]));
|
|
7
|
-
const { manifest } = composition;
|
|
8
|
-
for (const entry of corpus) {
|
|
9
|
-
const { fixture } = entry;
|
|
10
|
-
const store = fixtureMediaStore(fixture.media);
|
|
11
|
-
const records = fixtureMediaRecords(fixture.facts, fixture.media, (path) => assets?.get(path)?.bytes);
|
|
12
|
-
const enabled = (instanceId) => fixture.contentDoc.instances.find((i) => i.instance_id === instanceId)?.enabled === true;
|
|
13
|
-
const navPages = manifest.pages.map((page) => ({
|
|
14
|
-
id: page.id,
|
|
15
|
-
label: page.label,
|
|
16
|
-
path: page.path ?? `/${page.id}`,
|
|
17
|
-
sections: page.sections.map((s) => ({
|
|
18
|
-
key: s.section,
|
|
19
|
-
anchor: s.section,
|
|
20
|
-
enabled: enabled(s.instance_id)
|
|
21
|
-
}))
|
|
22
|
-
}));
|
|
23
|
-
for (const page of manifest.pages) {
|
|
24
|
-
const { anchors, pages } = resolveNav({
|
|
25
|
-
pages: navPages,
|
|
26
|
-
currentPageId: page.id
|
|
27
|
-
});
|
|
28
|
-
for (const placed of page.sections) {
|
|
29
|
-
const section = byKey.get(placed.section);
|
|
30
|
-
const instance = fixture.contentDoc.instances.find((i) => i.instance_id === placed.instance_id);
|
|
31
|
-
if (section === void 0 || instance === void 0 || !instance.enabled) continue;
|
|
32
|
-
const firstCase = (section.schema.display?.variant?.cases ?? [])[0];
|
|
33
|
-
yield {
|
|
34
|
-
corpus: entry,
|
|
35
|
-
pageId: page.id,
|
|
36
|
-
instanceId: placed.instance_id,
|
|
37
|
-
entry: section,
|
|
38
|
-
props: {
|
|
39
|
-
slots: await resolveFixtureSlots({
|
|
40
|
-
slots: instance.slots,
|
|
41
|
-
declared: section.section.schema.slots,
|
|
42
|
-
records,
|
|
43
|
-
store
|
|
44
|
-
}),
|
|
45
|
-
nav: {
|
|
46
|
-
selfAnchor: section.schema.anchor,
|
|
47
|
-
anchors,
|
|
48
|
-
pages
|
|
49
|
-
},
|
|
50
|
-
variant: instance.variant ?? firstCase ?? ""
|
|
51
|
-
},
|
|
52
|
-
where: `fixture "${fixture.id}", page "${page.id}", instance "${placed.instance_id}"`
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
//#endregion
|
|
60
|
-
export { renderInputs };
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
//#region src/cli/check/render/nav.ts
|
|
2
|
-
function pageHref(basePath, path) {
|
|
3
|
-
const base = basePath.replace(/\/+$/, "");
|
|
4
|
-
return path === "/" ? `${base}/` : `${base}${path}/`;
|
|
5
|
-
}
|
|
6
|
-
function resolveNav(input) {
|
|
7
|
-
const { pages, currentPageId, basePath = "/" } = input;
|
|
8
|
-
const current = pages.find((p) => p.id === currentPageId);
|
|
9
|
-
if (!current) throw new Error(`resolveNav: current page "${currentPageId}" is not one of the declared pages (${pages.map((p) => p.id).join(", ")}).`);
|
|
10
|
-
const anchors = {};
|
|
11
|
-
for (const target of targetOrder(pages, current)) for (const section of target.sections) {
|
|
12
|
-
if (section.enabled === false) continue;
|
|
13
|
-
if (section.key in anchors) continue;
|
|
14
|
-
anchors[section.key] = target.id === current.id ? `#${section.anchor}` : `${pageHref(basePath, target.path)}#${section.anchor}`;
|
|
15
|
-
}
|
|
16
|
-
return {
|
|
17
|
-
anchors,
|
|
18
|
-
pages: pages.filter((p) => p.enabled !== false).map((p) => ({
|
|
19
|
-
id: p.id,
|
|
20
|
-
label: p.label,
|
|
21
|
-
href: pageHref(basePath, p.path),
|
|
22
|
-
current: p.id === current.id
|
|
23
|
-
}))
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
function targetOrder(pages, current) {
|
|
27
|
-
return [current, ...pages.filter((p) => p.id !== current.id).filter((p) => p.enabled !== false)];
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
//#endregion
|
|
31
|
-
export { pageHref, resolveNav };
|
package/dist/cli/dev/crop.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { CROP_PARAM, croppedUrl, cutRegion as cutRegion$1, parseCropParam } from "../../packages/internal/crop-region/dist/index.js";
|
|
2
|
-
|
|
3
|
-
//#region src/cli/dev/crop.ts
|
|
4
|
-
function croppedMediaUrl(url, rect) {
|
|
5
|
-
return croppedUrl(url, rect);
|
|
6
|
-
}
|
|
7
|
-
async function defaultLoadSharp() {
|
|
8
|
-
try {
|
|
9
|
-
return (await import("sharp")).default;
|
|
10
|
-
} catch {
|
|
11
|
-
return null;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
async function cutRegion(master, rect, loadSharp = defaultLoadSharp) {
|
|
15
|
-
const sharp = await loadSharp();
|
|
16
|
-
return sharp === null ? null : cutRegion$1(sharp, master, rect);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
//#endregion
|
|
20
|
-
export { CROP_PARAM, croppedMediaUrl, cutRegion, parseCropParam };
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { cachedAuthorImage, deriveAuthorImage, masterHash } from "../media/derive.js";
|
|
2
|
-
import { FIXTURE_MEDIA_PATH } from "../../fixtures/media-plugin.js";
|
|
3
|
-
import { basename } from "node:path";
|
|
4
|
-
|
|
5
|
-
//#region src/cli/dev/fixture-ladders.ts
|
|
6
|
-
function servedLadder(derivation) {
|
|
7
|
-
const { responsive } = derivation.image;
|
|
8
|
-
if (responsive === null) return null;
|
|
9
|
-
const rehome = (srcset) => srcset.split(",").map((candidate) => {
|
|
10
|
-
const [url = "", ...descriptors] = candidate.trim().split(/\s+/);
|
|
11
|
-
return [`${FIXTURE_MEDIA_PATH}/${basename(url)}`, ...descriptors].join(" ");
|
|
12
|
-
}).join(", ");
|
|
13
|
-
return {
|
|
14
|
-
...responsive,
|
|
15
|
-
sources: responsive.sources.map((source) => ({
|
|
16
|
-
...source,
|
|
17
|
-
srcset: rehome(source.srcset)
|
|
18
|
-
}))
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
const errorText = (err) => err instanceof Error ? err.message : String(err);
|
|
22
|
-
function createFixtureLadders(options) {
|
|
23
|
-
const { cacheDir, log } = options;
|
|
24
|
-
const ready = /* @__PURE__ */ new Map();
|
|
25
|
-
const lookups = /* @__PURE__ */ new Map();
|
|
26
|
-
const rungs = /* @__PURE__ */ new Map();
|
|
27
|
-
let queue = Promise.resolve();
|
|
28
|
-
let reportedNoSharp = false;
|
|
29
|
-
let closed = false;
|
|
30
|
-
const adopt = (key, derivation) => {
|
|
31
|
-
const ladder = servedLadder(derivation);
|
|
32
|
-
if (ladder === null) return false;
|
|
33
|
-
for (const rung of derivation.derivatives) rungs.set(`${FIXTURE_MEDIA_PATH}/${rung.filename}`, rung);
|
|
34
|
-
ready.set(key, ladder);
|
|
35
|
-
return true;
|
|
36
|
-
};
|
|
37
|
-
const derive = async (key, path, bytes) => {
|
|
38
|
-
if (closed) return;
|
|
39
|
-
try {
|
|
40
|
-
const derivation = await deriveAuthorImage(path, bytes, {
|
|
41
|
-
cacheDir,
|
|
42
|
-
...options.loadSharp === void 0 ? {} : { loadSharp: options.loadSharp }
|
|
43
|
-
});
|
|
44
|
-
if (closed) return;
|
|
45
|
-
if (derivation.passthrough) {
|
|
46
|
-
if (!reportedNoSharp) log.write("concrete dev: sharp is not installed, so images serve as their masters, without a responsive ladder.\n");
|
|
47
|
-
reportedNoSharp = true;
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
if (adopt(key, derivation)) options.onReady();
|
|
51
|
-
} catch (err) {
|
|
52
|
-
log.write(`concrete dev: no responsive ladder for ${path}: ${errorText(err)}\n`);
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
const lookup = async (key, path, bytes) => {
|
|
56
|
-
let hit;
|
|
57
|
-
try {
|
|
58
|
-
hit = await cachedAuthorImage(path, bytes, { cacheDir });
|
|
59
|
-
} catch (err) {
|
|
60
|
-
log.write(`concrete dev: no responsive ladder for ${path}: ${errorText(err)}\n`);
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
if (hit !== null) {
|
|
64
|
-
adopt(key, hit);
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
queue = queue.then(() => derive(key, path, bytes));
|
|
68
|
-
};
|
|
69
|
-
const idle = async () => {
|
|
70
|
-
for (let seen = queue;; seen = queue) {
|
|
71
|
-
await seen;
|
|
72
|
-
if (seen === queue) return;
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
return {
|
|
76
|
-
async responsiveFor(path, bytes) {
|
|
77
|
-
const key = `${path}|${masterHash(bytes)}`;
|
|
78
|
-
let pending = lookups.get(key);
|
|
79
|
-
if (pending === void 0) {
|
|
80
|
-
pending = lookup(key, path, bytes);
|
|
81
|
-
lookups.set(key, pending);
|
|
82
|
-
}
|
|
83
|
-
await pending;
|
|
84
|
-
return ready.get(key) ?? null;
|
|
85
|
-
},
|
|
86
|
-
rung: (url) => rungs.get(url),
|
|
87
|
-
idle,
|
|
88
|
-
close() {
|
|
89
|
-
closed = true;
|
|
90
|
-
return idle();
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
//#endregion
|
|
96
|
-
export { createFixtureLadders };
|
package/dist/cli/dev/hmr.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
//#region src/cli/dev/hmr.ts
|
|
2
|
-
function createHmrBus() {
|
|
3
|
-
const clients = /* @__PURE__ */ new Set();
|
|
4
|
-
return {
|
|
5
|
-
attach(res) {
|
|
6
|
-
res.writeHead(200, {
|
|
7
|
-
"content-type": "text/event-stream",
|
|
8
|
-
"cache-control": "no-cache",
|
|
9
|
-
connection: "keep-alive"
|
|
10
|
-
});
|
|
11
|
-
res.write(": hello\n\n");
|
|
12
|
-
clients.add(res);
|
|
13
|
-
res.on("close", () => clients.delete(res));
|
|
14
|
-
},
|
|
15
|
-
broadcast(event) {
|
|
16
|
-
for (const res of clients) res.write(`event: ${event}\ndata: {}\n\n`);
|
|
17
|
-
},
|
|
18
|
-
closeAll() {
|
|
19
|
-
for (const res of clients) res.end();
|
|
20
|
-
clients.clear();
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
//#endregion
|
|
26
|
-
export { createHmrBus };
|
package/dist/cli/dev/islands.js
DELETED
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
import { hasClientDirective } from "../../islands/client-module.js";
|
|
2
|
-
import { isWorkspaceFile, packageFile, toPosix } from "../../platform/paths.js";
|
|
3
|
-
import { listDirSync } from "../../platform/fs.js";
|
|
4
|
-
import { CAPTURE_ISLANDS_READY_GLOBAL } from "../../packages/internal/capture-settle/dist/settle.js";
|
|
5
|
-
import "../../packages/internal/capture-settle/dist/index.js";
|
|
6
|
-
import { readFileSync } from "node:fs";
|
|
7
|
-
import nodePath, { dirname, extname, join, relative } from "node:path";
|
|
8
|
-
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
9
|
-
import { createHash } from "node:crypto";
|
|
10
|
-
|
|
11
|
-
//#region src/cli/dev/islands.ts
|
|
12
|
-
const COMPONENT_EXTS = /* @__PURE__ */ new Set([".tsx", ".jsx"]);
|
|
13
|
-
const SKIPPED_DIRS = /* @__PURE__ */ new Set([
|
|
14
|
-
"node_modules",
|
|
15
|
-
"dist",
|
|
16
|
-
".concrete"
|
|
17
|
-
]);
|
|
18
|
-
const SERVER_FRAME = /^[ \t]*export[ \t]+const[ \t]+serverFrame[ \t]*(?::[^=]*)?=[ \t]*(.*)$/m;
|
|
19
|
-
function declaresNoServerFrame(text) {
|
|
20
|
-
const declaration = SERVER_FRAME.exec(text);
|
|
21
|
-
if (!declaration) return false;
|
|
22
|
-
const source = (declaration[1] ?? "").replace(/;.*$/, "").trim();
|
|
23
|
-
const literal = /^(true|false)\b/.exec(source);
|
|
24
|
-
if (!literal) return false;
|
|
25
|
-
const rest = source.slice(literal[0].length).trim();
|
|
26
|
-
if (rest !== "" && !/^(?:satisfies|as)\b/.test(rest)) return false;
|
|
27
|
-
return literal[1] === "false";
|
|
28
|
-
}
|
|
29
|
-
function islandKeyFor(root, file, paths = nodePath) {
|
|
30
|
-
const rel = toPosix(paths.relative(root, file), paths);
|
|
31
|
-
const slash = rel.lastIndexOf("/");
|
|
32
|
-
const name = rel.slice(slash + 1);
|
|
33
|
-
const dot = name.lastIndexOf(".");
|
|
34
|
-
return `${rel.slice(0, Math.max(slash, 0))}:${dot > 0 ? name.slice(0, dot) : name}`;
|
|
35
|
-
}
|
|
36
|
-
function workspaceComponentFile(root, id, paths = nodePath) {
|
|
37
|
-
const file = id.split("?")[0] ?? id;
|
|
38
|
-
return COMPONENT_EXTS.has(paths.extname(file)) && isWorkspaceFile(root, file, paths) ? file : null;
|
|
39
|
-
}
|
|
40
|
-
function findWorkspaceIslands(root) {
|
|
41
|
-
const out = [];
|
|
42
|
-
const walk = (dir, depth) => {
|
|
43
|
-
let entries;
|
|
44
|
-
try {
|
|
45
|
-
entries = listDirSync(dir);
|
|
46
|
-
} catch {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
for (const entry of entries) {
|
|
50
|
-
if (entry.name.startsWith(".")) continue;
|
|
51
|
-
const path = entry.path;
|
|
52
|
-
if (entry.isDirectory()) {
|
|
53
|
-
if (SKIPPED_DIRS.has(entry.name) || depth === 0 && entry.name === "fixtures") continue;
|
|
54
|
-
walk(path, depth + 1);
|
|
55
|
-
} else if (entry.isFile() && COMPONENT_EXTS.has(extname(entry.name)) && !/\.test\.[^/]+$/.test(entry.name)) {
|
|
56
|
-
let text;
|
|
57
|
-
try {
|
|
58
|
-
text = readFileSync(path, "utf8");
|
|
59
|
-
} catch {
|
|
60
|
-
continue;
|
|
61
|
-
}
|
|
62
|
-
if (hasClientDirective(text)) out.push(path);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
walk(root, 0);
|
|
67
|
-
return out;
|
|
68
|
-
}
|
|
69
|
-
function islandMapOf(root, files) {
|
|
70
|
-
const map = {};
|
|
71
|
-
for (const file of files) map[islandKeyFor(root, file)] = `/${toPosix(relative(root, file))}`;
|
|
72
|
-
return map;
|
|
73
|
-
}
|
|
74
|
-
function markerModule(islandKey, markerSpecifier, children) {
|
|
75
|
-
return `
|
|
76
|
-
;
|
|
77
|
-
import { createElement as __trCreateElement, useId as __trUseId } from "react";
|
|
78
|
-
import { IslandMarker as __TrIslandMarker } from ${JSON.stringify(markerSpecifier)};
|
|
79
|
-
export default function __trIslandWrapper(__trProps) {
|
|
80
|
-
const __trIslandId = __trUseId();
|
|
81
|
-
return __trCreateElement(
|
|
82
|
-
__TrIslandMarker,
|
|
83
|
-
{ islandKey: ${JSON.stringify(islandKey)}, islandId: __trIslandId, props: __trProps },${children}
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
`;
|
|
87
|
-
}
|
|
88
|
-
const DEFAULT_EXPORT = /export\s+default\s+/;
|
|
89
|
-
function wrapClientModule(code, islandKey, markerSpecifier) {
|
|
90
|
-
if (!hasClientDirective(code) || !DEFAULT_EXPORT.test(code)) return null;
|
|
91
|
-
return code.replace(DEFAULT_EXPORT, "const __trIslandReal = ") + markerModule(islandKey, markerSpecifier, "\n __trCreateElement(__trIslandReal, __trProps),") + "export { __trIslandReal };\n";
|
|
92
|
-
}
|
|
93
|
-
function stubClientModule(code, islandKey, markerSpecifier) {
|
|
94
|
-
if (!hasClientDirective(code) || !DEFAULT_EXPORT.test(code) || !declaresNoServerFrame(code)) return null;
|
|
95
|
-
return markerModule(islandKey, markerSpecifier, "");
|
|
96
|
-
}
|
|
97
|
-
function islandTransformPlugin(options) {
|
|
98
|
-
return {
|
|
99
|
-
name: "concrete-dev:islands",
|
|
100
|
-
enforce: "pre",
|
|
101
|
-
transform(code, id, transformOptions) {
|
|
102
|
-
const file = workspaceComponentFile(options.root, id);
|
|
103
|
-
if (file === null) return null;
|
|
104
|
-
const key = islandKeyFor(options.root, file);
|
|
105
|
-
if (transformOptions?.ssr === true) {
|
|
106
|
-
const stub = stubClientModule(code, key, options.markerSpecifier);
|
|
107
|
-
if (stub !== null) return {
|
|
108
|
-
code: stub,
|
|
109
|
-
map: null
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
const wrapped = wrapClientModule(code, key, options.markerSpecifier);
|
|
113
|
-
return wrapped === null ? null : {
|
|
114
|
-
code: wrapped,
|
|
115
|
-
map: null
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
function islandEsbuildPlugin(options) {
|
|
121
|
-
return {
|
|
122
|
-
name: "concrete-dev:islands",
|
|
123
|
-
setup(build) {
|
|
124
|
-
build.onLoad({ filter: /\.[jt]sx$/ }, async (args) => {
|
|
125
|
-
if (workspaceComponentFile(options.root, args.path) === null) return void 0;
|
|
126
|
-
const code = await readFile(args.path, "utf8");
|
|
127
|
-
const key = islandKeyFor(options.root, args.path);
|
|
128
|
-
const contents = stubClientModule(code, key, options.markerSpecifier) ?? wrapClientModule(code, key, options.markerSpecifier);
|
|
129
|
-
if (contents === null) return void 0;
|
|
130
|
-
return {
|
|
131
|
-
contents,
|
|
132
|
-
loader: extname(args.path) === ".jsx" ? "jsx" : "tsx",
|
|
133
|
-
resolveDir: dirname(args.path)
|
|
134
|
-
};
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
function islandRuntimeFile() {
|
|
140
|
-
return packageFile("cli/dev/island-runtime.ts", "playground-island-runtime.js");
|
|
141
|
-
}
|
|
142
|
-
function fsUrl(file) {
|
|
143
|
-
return `/@fs/${toPosix(file).replace(/^\/+/, "")}`;
|
|
144
|
-
}
|
|
145
|
-
function importers(root, files) {
|
|
146
|
-
return `const modules = {\n${files.map((file) => {
|
|
147
|
-
const url = `/${toPosix(relative(root, file))}`;
|
|
148
|
-
return ` ${JSON.stringify(url)}: () => import(${JSON.stringify(url)}),`;
|
|
149
|
-
}).join("\n")}\n};`;
|
|
150
|
-
}
|
|
151
|
-
const REAL_COMPONENT = `
|
|
152
|
-
// The island transform rewrites the browser graph too, so a client module's \`default\`
|
|
153
|
-
// renders the marker. A TOP-LEVEL marker hydrates the raw component instead.
|
|
154
|
-
function realComponent(mod) {
|
|
155
|
-
return mod.__trIslandReal || mod.default;
|
|
156
|
-
}
|
|
157
|
-
`;
|
|
158
|
-
function previewHostSource(runtimeUrl, root, files) {
|
|
159
|
-
return `import { hydrateIslands, islandsCaptureReady } from ${JSON.stringify(runtimeUrl)};
|
|
160
|
-
|
|
161
|
-
${importers(root, files)}
|
|
162
|
-
const map = window.__TR_ISLAND_MAP || {};
|
|
163
|
-
${REAL_COMPONENT}
|
|
164
|
-
// The first island that fails to hydrate: logged as it happens, and re-thrown out of the
|
|
165
|
-
// readiness promise, because a capture of a page whose island threw is a hole in an artifact.
|
|
166
|
-
let hydrationFailure = null;
|
|
167
|
-
|
|
168
|
-
const hydrated = hydrateIslands({
|
|
169
|
-
load: async (key) => {
|
|
170
|
-
const url = map[key];
|
|
171
|
-
const importer = url ? modules[url] : undefined;
|
|
172
|
-
if (!importer) return Promise.reject(new Error("concrete dev: no island module for " + key));
|
|
173
|
-
const mod = await importer();
|
|
174
|
-
return { ...mod, default: realComponent(mod) };
|
|
175
|
-
},
|
|
176
|
-
// Absent on a browsed page, so the loader's viewport default runs — what deployment does.
|
|
177
|
-
// A captured document sets "eager".
|
|
178
|
-
schedule: window.__TR_ISLAND_SCHEDULE,
|
|
179
|
-
onError: (error, ctx) => {
|
|
180
|
-
console.error("concrete dev: island failed to hydrate:", ctx.key, error);
|
|
181
|
-
if (!hydrationFailure) {
|
|
182
|
-
hydrationFailure = new Error("island " + ctx.key + " failed to hydrate: " + ((error && error.message) || error));
|
|
183
|
-
}
|
|
184
|
-
},
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
// The capture settle's hydration leg: every handle mounted, then every capture hold drained.
|
|
188
|
-
const ready = hydrated.then(async (handles) => {
|
|
189
|
-
await islandsCaptureReady(handles);
|
|
190
|
-
if (hydrationFailure) throw hydrationFailure;
|
|
191
|
-
});
|
|
192
|
-
window.${CAPTURE_ISLANDS_READY_GLOBAL} = ready;
|
|
193
|
-
ready.catch(() => {});
|
|
194
|
-
`;
|
|
195
|
-
}
|
|
196
|
-
function canvasHostSource(runtimeUrl, root, files) {
|
|
197
|
-
return `import RefreshRuntime from "/@react-refresh";
|
|
198
|
-
import { installCanvasIslandHost } from ${JSON.stringify(runtimeUrl)};
|
|
199
|
-
|
|
200
|
-
// The React Refresh preamble. The React plugin compiles every client component to assert
|
|
201
|
-
// it ran, and the canvas frame is not built by Vite's own html transform, so the one
|
|
202
|
-
// module every canvas frame loads supplies it.
|
|
203
|
-
if (!window.__vite_plugin_react_preamble_installed__) {
|
|
204
|
-
RefreshRuntime.injectIntoGlobalHook(window);
|
|
205
|
-
window.$RefreshReg$ = () => {};
|
|
206
|
-
window.$RefreshSig$ = () => (type) => type;
|
|
207
|
-
window.__vite_plugin_react_preamble_installed__ = true;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
${importers(root, files)}
|
|
211
|
-
installCanvasIslandHost((url) => {
|
|
212
|
-
const importer = modules[url];
|
|
213
|
-
return importer ? importer() : Promise.reject(new Error("concrete dev: no island module at " + url));
|
|
214
|
-
}, "concrete dev");
|
|
215
|
-
`;
|
|
216
|
-
}
|
|
217
|
-
async function writeIslandHostScripts(root, files) {
|
|
218
|
-
const dir = join(root, ".concrete", "dev");
|
|
219
|
-
await mkdir(dir, { recursive: true });
|
|
220
|
-
const runtimeUrl = fsUrl(islandRuntimeFile());
|
|
221
|
-
const write = async (name, source) => {
|
|
222
|
-
const file = join(dir, name);
|
|
223
|
-
await writeFile(file, source, "utf8");
|
|
224
|
-
const version = createHash("sha256").update(source).digest("hex").slice(0, 12);
|
|
225
|
-
return `${fsUrl(file)}?h=${version}`;
|
|
226
|
-
};
|
|
227
|
-
return {
|
|
228
|
-
canvas: await write("island-canvas-host.js", canvasHostSource(runtimeUrl, root, files)),
|
|
229
|
-
preview: await write("island-preview-host.js", previewHostSource(runtimeUrl, root, files))
|
|
230
|
-
};
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
//#endregion
|
|
234
|
-
export { declaresNoServerFrame, findWorkspaceIslands, fsUrl, hasClientDirective, islandEsbuildPlugin, islandKeyFor, islandMapOf, islandRuntimeFile, islandTransformPlugin, stubClientModule, workspaceComponentFile, wrapClientModule, writeIslandHostScripts };
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { islandEsbuildPlugin } from "./islands.js";
|
|
2
|
-
import { MEDIA_LOADERS, createFixtureMediaPlugin, externalOutsideWorkspace } from "../../fixtures/media-plugin.js";
|
|
3
|
-
import { createPackageStylesheetsPlugin } from "../../fixtures/package-stylesheets.js";
|
|
4
|
-
import { join } from "node:path";
|
|
5
|
-
import { pathToFileURL } from "node:url";
|
|
6
|
-
import { build } from "esbuild";
|
|
7
|
-
|
|
8
|
-
//#region src/cli/dev/load-template.ts
|
|
9
|
-
let serial = 0;
|
|
10
|
-
async function loadTemplateModule(options) {
|
|
11
|
-
const { root } = options;
|
|
12
|
-
const media = createFixtureMediaPlugin(root, options.ladders);
|
|
13
|
-
const stylesheets = await createPackageStylesheetsPlugin(root);
|
|
14
|
-
const outfile = join(root, ".concrete", "cache", "dev", "template.mjs");
|
|
15
|
-
try {
|
|
16
|
-
await build({
|
|
17
|
-
entryPoints: [options.templateFile],
|
|
18
|
-
bundle: true,
|
|
19
|
-
format: "esm",
|
|
20
|
-
platform: "node",
|
|
21
|
-
target: "node22",
|
|
22
|
-
outfile,
|
|
23
|
-
absWorkingDir: root,
|
|
24
|
-
packages: "external",
|
|
25
|
-
jsx: "automatic",
|
|
26
|
-
loader: {
|
|
27
|
-
".css": "empty",
|
|
28
|
-
...MEDIA_LOADERS
|
|
29
|
-
},
|
|
30
|
-
plugins: [
|
|
31
|
-
externalOutsideWorkspace(root),
|
|
32
|
-
islandEsbuildPlugin({
|
|
33
|
-
root,
|
|
34
|
-
markerSpecifier: options.markerSpecifier
|
|
35
|
-
}),
|
|
36
|
-
media.plugin,
|
|
37
|
-
stylesheets.plugin
|
|
38
|
-
],
|
|
39
|
-
write: true,
|
|
40
|
-
logLevel: "silent"
|
|
41
|
-
});
|
|
42
|
-
} finally {
|
|
43
|
-
await stylesheets.dispose();
|
|
44
|
-
}
|
|
45
|
-
return {
|
|
46
|
-
template: (await import(`${pathToFileURL(outfile).href}?load=${Date.now()}-${serial++}`)).default,
|
|
47
|
-
assets: media.assets
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
//#endregion
|
|
52
|
-
export { loadTemplateModule };
|