@homepages/concrete 12.0.0 → 13.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +184 -0
- package/README.md +8 -10
- package/codemods/fixtures-are-data.mjs +7 -0
- package/codemods/fixtures-list-properties.mjs +6 -0
- package/codemods/manifest.json +11 -0
- package/codemods/steps/fixtures-list-properties.mjs +16 -0
- package/codemods/steps/fixtures-to-data.mjs +41 -0
- package/dist/artifact/playground/client/assets/archivo-latin-ext-wght-normal-C4zznr8T.woff2 +0 -0
- package/dist/artifact/playground/client/assets/archivo-latin-wght-normal-E0tuGl4L.woff2 +0 -0
- package/dist/artifact/playground/client/assets/archivo-vietnamese-wght-normal-XAtsl5Q_.woff2 +0 -0
- package/dist/artifact/playground/client/assets/index-Bmvcss4B.js +1338 -0
- package/dist/artifact/playground/client/assets/index-C01UCAWD.css +1 -0
- package/dist/artifact/playground/client/index.html +2 -2
- package/dist/artifact/playground/client/island-canvas-host.mjs +1 -1
- package/dist/artifact/playground/host.mjs +110 -59
- package/dist/base.css +2 -2
- package/dist/cli/build/icons.js +1 -1
- package/dist/cli/build/index.js +11 -10
- package/dist/cli/build/manifest.js +44 -0
- package/dist/cli/build/record.js +123 -0
- package/dist/cli/build/sections.js +28 -18
- package/dist/cli/build/source.js +1 -1
- package/dist/cli/build/static.js +8 -5
- package/dist/cli/build/template-build.js +614 -0
- package/dist/cli/check/analyze.js +18 -1
- package/dist/cli/check/load-workspace.js +2 -2
- package/dist/cli/check/portable-names.js +1 -1
- package/dist/cli/check/render/corpus.js +119 -0
- package/dist/cli/check/render/invariants.js +1 -0
- package/dist/cli/check/stages/bundles.js +15 -18
- package/dist/cli/check/stages/composition.js +8 -25
- package/dist/cli/check/stages/fixtures.js +14 -10
- package/dist/cli/check/stages/logic.js +7 -23
- package/dist/cli/check/stages/render.js +12 -14
- package/dist/cli/check/stages/sections.js +22 -66
- package/dist/cli/check/stages/stylesheet.js +4 -26
- package/dist/cli/check/stages/workspace.js +27 -22
- package/dist/cli/commands.js +51 -23
- package/dist/cli/currency/preamble.js +1 -1
- package/dist/cli/currency/resolve-latest.js +3 -2
- package/dist/cli/dev/capture-browser.js +26 -0
- package/dist/cli/dev/fixture-schema.js +441 -0
- package/dist/cli/dev/folder-files.js +244 -0
- package/dist/cli/dev/index.js +7 -3
- package/dist/cli/dev/playground-server.js +34 -0
- package/dist/cli/dev/section-ladders.js +76 -0
- package/dist/cli/dev/server.js +120 -304
- package/dist/cli/install/background.js +16 -0
- package/dist/cli/install/index.js +45 -0
- package/dist/cli/install/tools.js +27 -0
- package/dist/cli/media/derive.js +19 -13
- package/dist/cli/media/deriver-plugin.js +14 -3
- package/dist/cli/property/fixture-list.js +46 -0
- package/dist/cli/property/index.js +12 -9
- package/dist/cli/property/library.js +12 -10
- package/dist/cli/publish/artifact.js +90 -0
- package/dist/cli/publish/captures.js +61 -0
- package/dist/cli/publish/fixtures.js +17 -0
- package/dist/cli/publish/index.js +10 -18
- package/dist/cli/{build → publish}/playground.js +3 -3
- package/dist/cli/publish/report.js +15 -33
- package/dist/cli/upgrade/codemod.d.ts +14 -0
- package/dist/cli/upgrade/fixture-conversion.d.ts +11 -0
- package/dist/cli/upgrade/fixture-conversion.js +54 -0
- package/dist/cli/upgrade/fixture-modules.js +125 -0
- package/dist/cli/upgrade/fixtures-to-data.d.ts +40 -0
- package/dist/cli/upgrade/fixtures-to-data.js +498 -0
- package/dist/cli/upgrade/index.js +18 -2
- package/dist/cli/upgrade/legacy-fixtures.d.ts +34 -0
- package/dist/cli/upgrade/legacy-fixtures.js +22 -0
- package/dist/cli/upgrade/stage.js +1 -1
- package/dist/cli/workspace-fixtures.js +80 -0
- package/dist/cli.js +1 -0
- package/dist/css/compile.js +9 -3
- package/dist/fixtures/bundle-rule.js +16 -16
- package/dist/fixtures/media-plugin.js +12 -33
- package/dist/fixtures/synthesize-empties.js +3 -2
- package/dist/index.d.ts +7 -7
- package/dist/{playground-island-runtime.d.ts → island-runtime.d.ts} +1 -2
- package/dist/{playground-island-runtime.js → island-runtime.js} +1 -2
- package/dist/islands/client-module.js +1 -1
- package/dist/{cli/dev → islands}/tsconfig-paths.js +2 -14
- package/dist/islands/wrap.js +40 -0
- package/dist/node_modules/.pnpm/acorn@8.18.0/node_modules/acorn/dist/acorn.js +5119 -0
- package/dist/packages/external/concrete/package.js +1 -1
- package/dist/packages/internal/bundle-evaluation/dist/cache.js +36 -0
- package/dist/packages/internal/bundle-evaluation/dist/evaluate.js +174 -0
- package/dist/packages/internal/bundle-evaluation/dist/index.js +5 -0
- package/dist/packages/internal/bundle-evaluation/dist/section-code.js +10 -0
- package/dist/packages/internal/capture-settle/dist/index.js +2 -2
- package/dist/packages/internal/capture-settle/dist/settle.js +88 -13
- package/dist/packages/internal/code-fingerprint/dist/index.js +57 -0
- package/dist/packages/internal/content-doc-ops/dist/index.js +176 -0
- package/dist/packages/internal/content-doc-ops/dist/made-rows.js +15 -0
- package/dist/packages/internal/deliverable-reads/dist/bootstrap.js +81 -0
- package/dist/packages/internal/deliverable-reads/dist/display.js +21 -0
- package/dist/packages/internal/deliverable-reads/dist/format.js +15 -0
- package/dist/packages/internal/deliverable-reads/dist/index.js +7 -0
- package/dist/packages/internal/deliverable-reads/dist/pages.js +29 -0
- package/dist/packages/internal/deliverable-reads/dist/requirements.js +72 -0
- package/dist/{cli/capture → packages/internal/download-files/dist}/bundle.js +8 -4
- package/dist/packages/internal/download-files/dist/capture-origin.js +126 -0
- package/dist/packages/internal/download-files/dist/capture-routes.js +139 -0
- package/dist/packages/internal/download-files/dist/capture-shell.js +38 -0
- package/dist/packages/internal/download-files/dist/capture.js +74 -0
- package/dist/packages/internal/download-files/dist/egress-watch.js +38 -0
- package/dist/packages/internal/download-files/dist/files.js +7 -0
- package/dist/packages/internal/download-files/dist/finish.js +35 -0
- package/dist/packages/internal/download-files/dist/fleet.js +94 -0
- package/dist/packages/internal/download-files/dist/format.js +40 -0
- package/dist/packages/internal/download-files/dist/make.js +105 -0
- package/dist/packages/internal/download-files/dist/master-tally.js +32 -0
- package/dist/packages/internal/download-files/dist/names.js +24 -0
- package/dist/packages/internal/download-files/dist/pdf-boxes.js +33 -0
- package/dist/packages/internal/download-files/dist/pdf-image-placements.js +194 -0
- package/dist/packages/internal/download-files/dist/pdf-images.js +289 -0
- package/dist/packages/internal/file-store/dist/files.js +8 -0
- package/dist/packages/internal/file-store/dist/lru.js +40 -0
- package/dist/packages/internal/file-store/dist/refusal.js +12 -0
- package/dist/packages/internal/file-store/dist/trees.js +151 -0
- package/dist/packages/internal/fill-bake/dist/bake-property-ref.js +1 -1
- package/dist/packages/internal/fill-bake/dist/compute-reads.js +47 -21
- package/dist/packages/internal/fill-bake/dist/index.js +5 -1
- package/dist/packages/internal/fill-bake/dist/item-merge.js +4 -3
- package/dist/packages/internal/fill-bake/dist/resolve-instance.js +9 -0
- package/dist/packages/internal/fill-bake/dist/resolve.js +3 -0
- package/dist/packages/internal/fill-bake/dist/round-trip.js +2 -0
- package/dist/packages/internal/fill-bake/dist/strip.js +6 -0
- package/dist/packages/internal/fill-vocabulary/dist/holder.js +1 -1
- package/dist/packages/internal/fill-vocabulary/dist/resolved-decision.js +1 -1
- package/dist/packages/internal/fill-vocabulary/dist/verbs.js +1 -1
- package/dist/packages/internal/island-runtime/dist/index.js +1 -10
- package/dist/packages/internal/island-runtime/dist/use-capture-ready.d.ts +5 -0
- package/dist/packages/internal/lead-fields/dist/ingest.js +72 -0
- package/dist/packages/internal/media-resolution/dist/video.js +6 -2
- package/dist/packages/internal/page-render/dist/addresses.js +57 -0
- package/dist/packages/internal/page-render/dist/index.js +6 -0
- package/dist/packages/internal/page-render/dist/kept.js +30 -0
- package/dist/packages/internal/page-render/dist/nav.js +42 -0
- package/dist/packages/internal/page-render/dist/render.js +152 -0
- package/dist/packages/internal/page-shell/dist/assemble.js +161 -0
- package/dist/packages/internal/page-shell/dist/escape.js +10 -0
- package/dist/packages/internal/page-shell/dist/frame.js +23 -0
- package/dist/packages/internal/page-shell/dist/index.js +26 -0
- package/dist/packages/internal/playground/dist/build-fingerprint.js +18 -0
- package/dist/packages/internal/playground/dist/fixture-conversions/list-names-properties.js +76 -0
- package/dist/packages/internal/playground/dist/fixture-formats.d.ts +37 -0
- package/dist/packages/internal/playground/dist/fixture-formats.js +20 -0
- package/dist/packages/internal/playground/dist/host/bootstrap.js +108 -0
- package/dist/packages/internal/playground/dist/host/built.js +202 -0
- package/dist/packages/internal/playground/dist/host/catalog-fixture.js +53 -0
- package/dist/packages/internal/playground/dist/host/download.js +34 -0
- package/dist/packages/internal/playground/dist/host/env.js +11 -0
- package/dist/packages/internal/playground/dist/host/everywhere-saves.js +353 -0
- package/dist/packages/internal/playground/dist/host/fixture-addresses.js +52 -0
- package/dist/packages/internal/playground/dist/host/fixture-documents.js +494 -0
- package/dist/packages/internal/playground/dist/host/fixture-operations.js +364 -0
- package/dist/packages/internal/playground/dist/host/fixture-units.js +93 -0
- package/dist/{fixtures → packages/internal/playground/dist/host}/image-dimensions.js +1 -1
- package/dist/packages/internal/playground/dist/host/leads.js +41 -0
- package/dist/packages/internal/playground/dist/host/media-saves.js +309 -0
- package/dist/{fixtures → packages/internal/playground/dist/host}/media-store.js +79 -26
- package/dist/packages/internal/playground/dist/host/overridable.js +9 -0
- package/dist/packages/internal/playground/dist/host/owned-saves.js +203 -0
- package/dist/{playground → packages/internal/playground/dist}/host/page-state.js +1 -1
- package/dist/packages/internal/playground/dist/host/program.js +54 -0
- package/dist/packages/internal/playground/dist/host/property-derive.js +216 -0
- package/dist/packages/internal/playground/dist/host/property-saves.js +74 -0
- package/dist/{fixtures → packages/internal/playground/dist/host}/property.js +88 -229
- package/dist/packages/internal/playground/dist/host/provenance.js +49 -0
- package/dist/packages/internal/playground/dist/host/resolve.js +553 -0
- package/dist/packages/internal/playground/dist/host/row-images.js +41 -0
- package/dist/{fixtures → packages/internal/playground/dist/host}/rows.js +1 -1
- package/dist/packages/internal/playground/dist/host/save.js +429 -0
- package/dist/packages/internal/playground/dist/host/serve.js +952 -0
- package/dist/packages/internal/playground/dist/host/site.js +79 -0
- package/dist/packages/internal/playground/dist/host/slots.js +202 -0
- package/dist/packages/internal/playground/dist/host/stated-content.js +93 -0
- package/dist/packages/internal/playground/dist/host/stored-fixtures.js +135 -0
- package/dist/packages/internal/playground/dist/host/violations.js +7 -0
- package/dist/packages/internal/playground/dist/jobs/lanes.js +24 -0
- package/dist/packages/internal/playground/dist/jobs/memory-queue.js +112 -0
- package/dist/packages/internal/playground/dist/jobs/probe.js +37 -0
- package/dist/packages/internal/playground/dist/jobs/queue.js +28 -0
- package/dist/packages/internal/playground/dist/jobs/runner.js +207 -0
- package/dist/packages/internal/playground/dist/layout.js +14 -0
- package/dist/packages/internal/playground/dist/platform.js +33 -0
- package/dist/packages/internal/playground/dist/server/changes.js +57 -0
- package/dist/packages/internal/playground/dist/server/crop.js +47 -0
- package/dist/packages/internal/playground/dist/server/derived-files.js +88 -0
- package/dist/packages/internal/playground/dist/server/download.js +158 -0
- package/dist/{cli/dev → packages/internal/playground/dist/server}/http.js +4 -12
- package/dist/packages/internal/playground/dist/server/jobs.js +29 -0
- package/dist/{cli/dev → packages/internal/playground/dist/server}/listen.js +4 -11
- package/dist/packages/internal/playground/dist/server/playground-server.js +424 -0
- package/dist/{cli/dev → packages/internal/playground/dist/server}/request-error.js +1 -1
- package/dist/packages/internal/playground/dist/server/size-ladders.js +170 -0
- package/dist/packages/internal/playground/dist/server/verification.js +75 -0
- package/dist/packages/internal/playground/dist/server/verify-build.js +139 -0
- package/dist/packages/internal/playground/dist/wire.js +78 -0
- package/dist/packages/internal/property-facts/dist/registry-facts.js +1 -1
- package/dist/packages/internal/section-contracts/dist/fill-verb-contract.js +1 -1
- package/dist/packages/internal/section-contracts/dist/reads-acyclic-contract.js +1 -1
- package/dist/packages/internal/section-contracts/dist/row-fill-contract.js +1 -1
- package/dist/packages/internal/site-files/dist/head.js +59 -0
- package/dist/packages/internal/site-files/dist/index.js +4 -0
- package/dist/packages/internal/site-files/dist/site.js +211 -0
- package/dist/packages/internal/static-assets-binding/dist/index.js +32 -0
- package/dist/packages/internal/static-assets-binding/dist/section-asset-url.js +38 -5
- package/dist/packages/internal/template-artifact/dist/asset-mime.js +8 -1
- package/dist/packages/internal/template-artifact/dist/build.js +148 -0
- package/dist/packages/internal/template-artifact/dist/composition.js +62 -0
- package/dist/packages/internal/template-artifact/dist/index.js +2 -2
- package/dist/packages/internal/template-artifact/dist/layout.js +48 -12
- package/dist/packages/internal/template-artifact/dist/manifest.js +3 -10
- package/dist/packages/internal/template-artifact/dist/verify.js +51 -31
- package/dist/packages/internal/template-contracts/dist/address-value.js +6 -1
- package/dist/packages/internal/template-contracts/dist/content-categories.js +10 -1
- package/dist/packages/internal/template-contracts/dist/fact-compute.d.ts +1 -1
- package/dist/packages/internal/template-contracts/dist/fact-keys.d.ts +1 -1
- package/dist/packages/internal/template-contracts/dist/fact-registry.d.ts +3 -3
- package/dist/packages/internal/template-contracts/dist/fact-registry.js +59 -32
- package/dist/packages/internal/template-contracts/dist/fill-spec.js +14 -1
- package/dist/packages/internal/template-contracts/dist/list.d.ts +3 -3
- package/dist/packages/internal/template-contracts/dist/media-candidates.js +67 -2
- package/dist/packages/internal/template-contracts/dist/media-offer.js +180 -0
- package/dist/packages/internal/template-contracts/dist/object.d.ts +2 -2
- package/dist/packages/internal/template-contracts/dist/primitive-descriptors.js +9 -2
- package/dist/packages/internal/template-contracts/dist/read-graph.js +36 -2
- package/dist/packages/internal/template-contracts/dist/ref-locate.js +16 -1
- package/dist/packages/internal/template-contracts/dist/registry-facts.d.ts +9 -10
- package/dist/packages/internal/template-contracts/dist/registry-facts.js +12 -1
- package/dist/packages/internal/template-contracts/dist/registry-graph.js +112 -0
- package/dist/packages/internal/template-contracts/dist/registry-shape.js +15 -2
- package/dist/packages/internal/template-contracts/dist/require-graph.js +300 -0
- package/dist/packages/internal/template-contracts/dist/row-ref.d.ts +3 -3
- package/dist/packages/internal/template-contracts/dist/row.d.ts +3 -3
- package/dist/packages/internal/template-contracts/dist/runtime-values.d.ts +1 -1
- package/dist/{schema → packages/internal/template-contracts/dist}/section-nav.d.ts +1 -1
- package/dist/packages/internal/template-contracts/dist/slot-builders.d.ts +4 -4
- package/dist/packages/internal/template-contracts/dist/slot-catalog.d.ts +3 -1
- package/dist/packages/internal/template-contracts/dist/slot-catalog.js +24 -1
- package/dist/packages/internal/template-contracts/dist/slot-overrides.js +26 -1
- package/dist/packages/internal/template-contracts/dist/slot-ref.d.ts +1 -1
- package/dist/packages/internal/template-contracts/dist/slot-types.js +1 -1
- package/dist/packages/internal/template-contracts/dist/slot-value.d.ts +1 -1
- package/dist/packages/internal/template-contracts/dist/table-members.js +7 -2
- package/dist/packages/internal/template-contracts/dist/video-value.d.ts +1 -1
- package/dist/packages/internal/upload-formats/dist/heic.js +35 -0
- package/dist/packages/internal/upload-formats/dist/index.js +80 -0
- package/dist/packages/internal/upload-formats/dist/magic-bytes.js +293 -0
- package/dist/platform/paths.js +1 -0
- package/dist/platform/process.js +49 -1
- package/dist/rules/registry.js +27 -3
- package/dist/schema/fact.d.ts +2 -2
- package/dist/schema/facts-view.d.ts +1 -1
- package/dist/schema/section-props.d.ts +1 -1
- package/dist/schema/section-schema.d.ts +1 -1
- package/dist/schema/section-schema.js +1 -0
- package/dist/section/declare.d.ts +1 -1
- package/dist/section/discovery.js +6 -2
- package/dist/section/publish-shape.js +38 -0
- package/dist/section/section.d.ts +1 -1
- package/dist/template/define-template.d.ts +14 -4
- package/dist/template/define-template.js +2 -0
- package/dist/template/logic-shim.d.ts +1 -1
- package/dist/template/materialize.js +1 -1
- package/dist/template/running-copy.js +0 -1
- package/dist/template/section-reads.js +1 -1
- package/guide/reference/cli/INDEX.md +6 -5
- package/guide/reference/cli/build.md +10 -8
- package/guide/reference/cli/check.md +4 -2
- package/guide/reference/cli/dev.md +6 -2
- package/guide/reference/cli/install.md +41 -0
- package/guide/reference/cli/property-add.md +5 -4
- package/guide/reference/cli/property-list.md +2 -2
- package/guide/reference/cli/publish.md +5 -5
- package/guide/reference/cli/upgrade.md +1 -1
- package/guide/reference/rules/INDEX.md +8 -4
- package/package.json +14 -30
- package/dist/artifact/playground/client/assets/index-BcLGpWLR.js +0 -1266
- package/dist/artifact/playground/client/assets/index-CxWPYOH2.css +0 -1
- package/dist/cli/build/artifact.js +0 -220
- package/dist/cli/build/captures.js +0 -48
- package/dist/cli/build/fixtures.js +0 -92
- package/dist/cli/capture/capture-browser.js +0 -37
- package/dist/cli/capture/capture.js +0 -115
- package/dist/cli/check/render/inputs.js +0 -60
- package/dist/cli/check/render/nav.js +0 -31
- package/dist/cli/dev/crop.js +0 -20
- package/dist/cli/dev/fixture-ladders.js +0 -96
- package/dist/cli/dev/hmr.js +0 -26
- package/dist/cli/dev/islands.js +0 -234
- package/dist/cli/dev/load-template.js +0 -52
- package/dist/cli/dev/vite.js +0 -114
- package/dist/cli/dev/workspace-reader.js +0 -249
- package/dist/cli/publish/freshness.js +0 -64
- package/dist/fixtures/brand.d.ts +0 -4
- package/dist/fixtures/brand.js +0 -8
- package/dist/fixtures/load.js +0 -159
- package/dist/fixtures/resolve.js +0 -392
- package/dist/fixtures.d.ts +0 -429
- package/dist/fixtures.js +0 -23
- package/dist/packages/internal/canvas-core/dist/island-host.js +0 -62
- package/dist/packages/internal/canvas-core/dist/island-shields.js +0 -30
- package/dist/playground/canvas-island-host.d.ts +0 -11
- package/dist/playground/canvas-island-host.js +0 -29
- package/dist/playground/canvas-markers.js +0 -14
- package/dist/playground/host/paths.js +0 -8
- package/dist/playground/layout.js +0 -17
- package/dist/playground/wire.js +0 -28
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
//#region ../../internal/bundle-evaluation/dist/cache.js
|
|
2
|
+
var BundleCache = class {
|
|
3
|
+
capacity;
|
|
4
|
+
#entries = /* @__PURE__ */ new Map();
|
|
5
|
+
constructor(capacity) {
|
|
6
|
+
this.capacity = capacity;
|
|
7
|
+
if (!Number.isInteger(capacity) || capacity < 1) throw new RangeError(`A bundle cache holds at least one entry, not ${capacity}.`);
|
|
8
|
+
}
|
|
9
|
+
load(key, loader) {
|
|
10
|
+
const held = this.#entries.get(key);
|
|
11
|
+
if (held !== void 0) {
|
|
12
|
+
this.#entries.delete(key);
|
|
13
|
+
this.#entries.set(key, held);
|
|
14
|
+
return held;
|
|
15
|
+
}
|
|
16
|
+
const loading = loader().catch((err) => {
|
|
17
|
+
if (this.#entries.get(key) === loading) this.#entries.delete(key);
|
|
18
|
+
throw err;
|
|
19
|
+
});
|
|
20
|
+
this.#entries.set(key, loading);
|
|
21
|
+
for (const oldest of this.#entries.keys()) {
|
|
22
|
+
if (this.#entries.size <= this.capacity) break;
|
|
23
|
+
this.#entries.delete(oldest);
|
|
24
|
+
}
|
|
25
|
+
return loading;
|
|
26
|
+
}
|
|
27
|
+
get size() {
|
|
28
|
+
return this.#entries.size;
|
|
29
|
+
}
|
|
30
|
+
clear() {
|
|
31
|
+
this.#entries.clear();
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
export { BundleCache };
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { parse } from "../../../../node_modules/.pnpm/acorn@8.18.0/node_modules/acorn/dist/acorn.js";
|
|
2
|
+
|
|
3
|
+
//#region ../../internal/bundle-evaluation/dist/evaluate.js
|
|
4
|
+
const AsyncFunction = Object.getPrototypeOf(async () => {}).constructor;
|
|
5
|
+
const IMPORTS = "__bundle$imports";
|
|
6
|
+
const DEFAULT_LOCAL = "__bundle$default";
|
|
7
|
+
async function evaluateBundle(text, options) {
|
|
8
|
+
const rewrite = rewriteModule(text, options.name);
|
|
9
|
+
const namespaces = [];
|
|
10
|
+
for (const specifier of rewrite.specifiers) {
|
|
11
|
+
if (options.importExternal === void 0) throw new Error(`${options.name} imports "${specifier}", but it is evaluated with no dependencies.`);
|
|
12
|
+
namespaces.push(await options.importExternal(specifier));
|
|
13
|
+
}
|
|
14
|
+
for (const { module, name } of rewrite.required) if (!(name in namespaces[module])) throw new SyntaxError(`The requested module '${rewrite.specifiers[module]}' does not provide an export named '${name}'`);
|
|
15
|
+
const exports = await new AsyncFunction(IMPORTS, rewrite.body)(namespaces);
|
|
16
|
+
for (const module of rewrite.stars) {
|
|
17
|
+
const namespace = namespaces[module];
|
|
18
|
+
for (const name of Object.keys(namespace)) {
|
|
19
|
+
if (name === "default" || name in exports) continue;
|
|
20
|
+
Object.defineProperty(exports, name, {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: () => namespace[name]
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return Object.freeze(exports);
|
|
27
|
+
}
|
|
28
|
+
function rewriteModule(text, name) {
|
|
29
|
+
const program = parse(text, {
|
|
30
|
+
ecmaVersion: "latest",
|
|
31
|
+
sourceType: "module"
|
|
32
|
+
});
|
|
33
|
+
const specifiers = [];
|
|
34
|
+
const required = [];
|
|
35
|
+
const stars = [];
|
|
36
|
+
const bindings = [];
|
|
37
|
+
const exported = /* @__PURE__ */ new Map();
|
|
38
|
+
const edits = [];
|
|
39
|
+
const moduleIndex = (source, attributes) => {
|
|
40
|
+
if (attributes.length > 0) throw new Error(`${name} imports "${String(source.value)}" with attributes, which a bundle cannot carry.`);
|
|
41
|
+
const specifier = String(source.value);
|
|
42
|
+
const known = specifiers.indexOf(specifier);
|
|
43
|
+
if (known !== -1) return known;
|
|
44
|
+
specifiers.push(specifier);
|
|
45
|
+
return specifiers.length - 1;
|
|
46
|
+
};
|
|
47
|
+
const read = (module, member) => `${IMPORTS}[${module}][${JSON.stringify(member)}]`;
|
|
48
|
+
const remove = (node) => {
|
|
49
|
+
edits.push({
|
|
50
|
+
start: node.start,
|
|
51
|
+
end: node.end,
|
|
52
|
+
text: ""
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
for (const node of program.body) if (node.type === "ImportDeclaration") {
|
|
56
|
+
importBindings(node, moduleIndex(node.source, node.attributes), required, bindings, read);
|
|
57
|
+
remove(node);
|
|
58
|
+
} else if (node.type === "ExportNamedDeclaration") namedExports(node, moduleIndex, required, exported, edits, read);
|
|
59
|
+
else if (node.type === "ExportDefaultDeclaration") defaultExport(node, exported, edits);
|
|
60
|
+
else if (node.type === "ExportAllDeclaration") {
|
|
61
|
+
starExport(node, moduleIndex(node.source, node.attributes), stars, exported);
|
|
62
|
+
remove(node);
|
|
63
|
+
}
|
|
64
|
+
let rewritten = "";
|
|
65
|
+
let at = 0;
|
|
66
|
+
for (const edit of edits.sort((a, b) => a.start - b.start)) {
|
|
67
|
+
rewritten += text.slice(at, edit.start) + edit.text;
|
|
68
|
+
at = edit.end;
|
|
69
|
+
}
|
|
70
|
+
rewritten += text.slice(at);
|
|
71
|
+
const getters = [...exported].map(([exportName, expression]) => `get ${JSON.stringify(exportName)}() { return ${expression}; }`);
|
|
72
|
+
return {
|
|
73
|
+
specifiers,
|
|
74
|
+
required,
|
|
75
|
+
body: [
|
|
76
|
+
"\"use strict\";",
|
|
77
|
+
...bindings,
|
|
78
|
+
rewritten,
|
|
79
|
+
`;return { __proto__: null, ${getters.join(", ")} };`,
|
|
80
|
+
`//# sourceURL=${name.replace(/\s/g, "_")}`
|
|
81
|
+
].join("\n"),
|
|
82
|
+
stars
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function importBindings(node, module, required, bindings, read) {
|
|
86
|
+
for (const specifier of node.specifiers) {
|
|
87
|
+
if (specifier.type === "ImportNamespaceSpecifier") {
|
|
88
|
+
bindings.push(`const ${specifier.local.name} = ${IMPORTS}[${module}];`);
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
const member = specifier.type === "ImportDefaultSpecifier" ? "default" : exportName(specifier.imported);
|
|
92
|
+
required.push({
|
|
93
|
+
module,
|
|
94
|
+
name: member
|
|
95
|
+
});
|
|
96
|
+
bindings.push(`const ${specifier.local.name} = ${read(module, member)};`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function namedExports(node, moduleIndex, required, exported, edits, read) {
|
|
100
|
+
if (node.declaration) {
|
|
101
|
+
edits.push({
|
|
102
|
+
start: node.start,
|
|
103
|
+
end: node.declaration.start,
|
|
104
|
+
text: ""
|
|
105
|
+
});
|
|
106
|
+
for (const local of declaredNames(node.declaration)) exported.set(local, local);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
edits.push({
|
|
110
|
+
start: node.start,
|
|
111
|
+
end: node.end,
|
|
112
|
+
text: ""
|
|
113
|
+
});
|
|
114
|
+
if (node.source) {
|
|
115
|
+
const module = moduleIndex(node.source, node.attributes);
|
|
116
|
+
for (const specifier of node.specifiers) {
|
|
117
|
+
const member = exportName(specifier.local);
|
|
118
|
+
required.push({
|
|
119
|
+
module,
|
|
120
|
+
name: member
|
|
121
|
+
});
|
|
122
|
+
exported.set(exportName(specifier.exported), read(module, member));
|
|
123
|
+
}
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
for (const specifier of node.specifiers) exported.set(exportName(specifier.exported), specifier.local.name);
|
|
127
|
+
}
|
|
128
|
+
function defaultExport(node, exported, edits) {
|
|
129
|
+
const declaration = node.declaration;
|
|
130
|
+
if ((declaration.type === "FunctionDeclaration" || declaration.type === "ClassDeclaration") && declaration.id) {
|
|
131
|
+
edits.push({
|
|
132
|
+
start: node.start,
|
|
133
|
+
end: declaration.start,
|
|
134
|
+
text: ""
|
|
135
|
+
});
|
|
136
|
+
exported.set("default", declaration.id.name);
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
edits.push({
|
|
140
|
+
start: node.start,
|
|
141
|
+
end: declaration.start,
|
|
142
|
+
text: `const ${DEFAULT_LOCAL} = (`
|
|
143
|
+
});
|
|
144
|
+
edits.push({
|
|
145
|
+
start: declaration.end,
|
|
146
|
+
end: node.end,
|
|
147
|
+
text: ");"
|
|
148
|
+
});
|
|
149
|
+
exported.set("default", DEFAULT_LOCAL);
|
|
150
|
+
}
|
|
151
|
+
function starExport(node, module, stars, exported) {
|
|
152
|
+
if (node.exported) exported.set(exportName(node.exported), `${IMPORTS}[${module}]`);
|
|
153
|
+
else stars.push(module);
|
|
154
|
+
}
|
|
155
|
+
function exportName(node) {
|
|
156
|
+
return node.type === "Identifier" ? node.name : String(node.value);
|
|
157
|
+
}
|
|
158
|
+
function declaredNames(declaration) {
|
|
159
|
+
if (declaration.type !== "VariableDeclaration") return [declaration.id.name];
|
|
160
|
+
return declaration.declarations.flatMap((declarator) => patternNames(declarator.id));
|
|
161
|
+
}
|
|
162
|
+
function patternNames(pattern) {
|
|
163
|
+
switch (pattern.type) {
|
|
164
|
+
case "Identifier": return [pattern.name];
|
|
165
|
+
case "ObjectPattern": return pattern.properties.flatMap((property) => patternNames(property.type === "RestElement" ? property.argument : property.value));
|
|
166
|
+
case "ArrayPattern": return pattern.elements.flatMap((element) => element === null ? [] : patternNames(element));
|
|
167
|
+
case "AssignmentPattern": return patternNames(pattern.left);
|
|
168
|
+
case "RestElement": return patternNames(pattern.argument);
|
|
169
|
+
case "MemberExpression": return [];
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
//#endregion
|
|
174
|
+
export { evaluateBundle };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BundleCache } from "./cache.js";
|
|
2
|
+
import "./evaluate.js";
|
|
3
|
+
|
|
4
|
+
//#region ../../internal/bundle-evaluation/dist/section-code.js
|
|
5
|
+
const LOGIC_CAPACITY = 128;
|
|
6
|
+
const RENDERER_CAPACITY = 128;
|
|
7
|
+
const logicModules = new BundleCache(LOGIC_CAPACITY);
|
|
8
|
+
const rendererModules = new BundleCache(RENDERER_CAPACITY);
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { CAPTURE_ANIMATIONS_SETTLED_EXPRESSION, CAPTURE_HAS_ISLANDS_EXPRESSION, CAPTURE_ISLANDS_READY_EXPRESSION, CAPTURE_ISLANDS_READY_GLOBAL, CAPTURE_ISLAND_PAINT_GRACE_EXPRESSION, CAPTURE_ISLAND_SETTLE_TIMEOUT_MS, CAPTURE_READY_EXPRESSION, CAPTURE_WAIT_UNTIL, settleCapture } from "./settle.js";
|
|
1
|
+
import { CAPTURE_ANIMATIONS_SETTLED_EXPRESSION, CAPTURE_FRESH_LAYOUT_EXPRESSION, CAPTURE_HAS_ISLANDS_EXPRESSION, CAPTURE_IN_VIEW_SCRIPT, CAPTURE_ISLANDS_READY_EXPRESSION, CAPTURE_ISLANDS_READY_GLOBAL, CAPTURE_ISLAND_PAINT_GRACE_EXPRESSION, CAPTURE_ISLAND_SETTLE_TIMEOUT_MS, CAPTURE_READY_EXPRESSION, CAPTURE_WAIT_UNTIL, settleCapture } from "./settle.js";
|
|
2
2
|
|
|
3
|
-
export { CAPTURE_ISLANDS_READY_GLOBAL, CAPTURE_WAIT_UNTIL, settleCapture };
|
|
3
|
+
export { CAPTURE_IN_VIEW_SCRIPT, CAPTURE_ISLANDS_READY_GLOBAL, CAPTURE_WAIT_UNTIL, settleCapture };
|
|
@@ -5,25 +5,86 @@ const CAPTURE_WAIT_UNTIL = "load";
|
|
|
5
5
|
const CAPTURE_READY_EXPRESSION = `(async () => {
|
|
6
6
|
await document.fonts.ready;
|
|
7
7
|
for (const img of document.images) {
|
|
8
|
-
if (img.loading === "lazy")
|
|
8
|
+
if (img.loading === "lazy") {
|
|
9
|
+
if (/^\\s*auto\\s*(,|$)/i.test(img.sizes) && img.offsetWidth > 0) img.sizes = img.offsetWidth + "px";
|
|
10
|
+
img.loading = "eager";
|
|
11
|
+
}
|
|
12
|
+
img.decoding = "sync";
|
|
9
13
|
}
|
|
10
14
|
await Promise.all(
|
|
11
|
-
Array.from(document.images,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
Array.from(document.images, (img) =>
|
|
16
|
+
new Promise((resolve, reject) => {
|
|
17
|
+
const fail = () =>
|
|
18
|
+
reject(
|
|
19
|
+
new Error(
|
|
20
|
+
"capture blocked: an <img> failed to load — " +
|
|
21
|
+
(img.currentSrc || img.getAttribute("src") || "(no src)"),
|
|
22
|
+
),
|
|
23
|
+
);
|
|
24
|
+
if (!img.complete) {
|
|
25
|
+
img.addEventListener("load", () => resolve(undefined), { once: true });
|
|
26
|
+
img.addEventListener("error", fail, { once: true });
|
|
27
|
+
} else if (img.naturalWidth > 0) {
|
|
28
|
+
resolve(undefined);
|
|
29
|
+
} else {
|
|
30
|
+
img.decode().then(() => resolve(undefined), fail);
|
|
31
|
+
}
|
|
32
|
+
}),
|
|
33
|
+
),
|
|
22
34
|
);
|
|
23
35
|
await new Promise((resolve) => {
|
|
24
36
|
requestAnimationFrame(() => resolve(undefined));
|
|
25
37
|
});
|
|
26
38
|
})()`;
|
|
39
|
+
const CAPTURE_IN_VIEW_SCRIPT = `(function () {
|
|
40
|
+
function CaptureIntersectionObserver(callback, options) {
|
|
41
|
+
var opts = options || {};
|
|
42
|
+
this.root = opts.root || null;
|
|
43
|
+
this.rootMargin = opts.rootMargin || "0px";
|
|
44
|
+
var threshold = opts.threshold;
|
|
45
|
+
this.thresholds = Object.freeze(
|
|
46
|
+
Array.isArray(threshold) ? threshold.slice() : [typeof threshold === "number" ? threshold : 0],
|
|
47
|
+
);
|
|
48
|
+
this._callback = callback;
|
|
49
|
+
this._queued = [];
|
|
50
|
+
this._scheduled = false;
|
|
51
|
+
}
|
|
52
|
+
CaptureIntersectionObserver.prototype._flush = function () {
|
|
53
|
+
this._scheduled = false;
|
|
54
|
+
var entries = this._queued;
|
|
55
|
+
this._queued = [];
|
|
56
|
+
if (entries.length === 0) return;
|
|
57
|
+
this._callback(entries, this);
|
|
58
|
+
};
|
|
59
|
+
CaptureIntersectionObserver.prototype.observe = function (target) {
|
|
60
|
+
var rect = target.getBoundingClientRect();
|
|
61
|
+
this._queued.push({
|
|
62
|
+
target: target,
|
|
63
|
+
isIntersecting: true,
|
|
64
|
+
intersectionRatio: 1,
|
|
65
|
+
boundingClientRect: rect,
|
|
66
|
+
intersectionRect: rect,
|
|
67
|
+
rootBounds: new DOMRectReadOnly(0, 0, window.innerWidth, window.innerHeight),
|
|
68
|
+
time: performance.now(),
|
|
69
|
+
});
|
|
70
|
+
if (this._scheduled) return;
|
|
71
|
+
this._scheduled = true;
|
|
72
|
+
var observer = this;
|
|
73
|
+
Promise.resolve().then(function () {
|
|
74
|
+
observer._flush();
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
CaptureIntersectionObserver.prototype.unobserve = function () {};
|
|
78
|
+
CaptureIntersectionObserver.prototype.disconnect = function () {
|
|
79
|
+
this._queued = [];
|
|
80
|
+
};
|
|
81
|
+
CaptureIntersectionObserver.prototype.takeRecords = function () {
|
|
82
|
+
var entries = this._queued;
|
|
83
|
+
this._queued = [];
|
|
84
|
+
return entries;
|
|
85
|
+
};
|
|
86
|
+
window.IntersectionObserver = CaptureIntersectionObserver;
|
|
87
|
+
})();`;
|
|
27
88
|
const CAPTURE_HAS_ISLANDS_EXPRESSION = `!!document.querySelector("[${ATTR_ISLAND_KEY}]")`;
|
|
28
89
|
const CAPTURE_ISLANDS_READY_GLOBAL = "__trIslandsReady";
|
|
29
90
|
const CAPTURE_ISLANDS_READY_EXPRESSION = `(async () => {
|
|
@@ -78,6 +139,19 @@ const CAPTURE_ANIMATIONS_SETTLED_EXPRESSION = `(async () => {
|
|
|
78
139
|
}
|
|
79
140
|
await frame();
|
|
80
141
|
})()`;
|
|
142
|
+
const CAPTURE_FRESH_LAYOUT_EXPRESSION = `(async () => {
|
|
143
|
+
const root = document.documentElement;
|
|
144
|
+
const display = root.style.getPropertyValue("display");
|
|
145
|
+
const priority = root.style.getPropertyPriority("display");
|
|
146
|
+
root.style.setProperty("display", "none", "important");
|
|
147
|
+
void root.offsetHeight;
|
|
148
|
+
if (display) root.style.setProperty("display", display, priority);
|
|
149
|
+
else root.style.removeProperty("display");
|
|
150
|
+
void root.offsetHeight;
|
|
151
|
+
await new Promise((resolve) => {
|
|
152
|
+
requestAnimationFrame(() => resolve(undefined));
|
|
153
|
+
});
|
|
154
|
+
})()`;
|
|
81
155
|
function legTimeout(leg, ceilingMs) {
|
|
82
156
|
return /* @__PURE__ */ new Error(`capture blocked: ${leg} did not settle within ${ceilingMs}ms`);
|
|
83
157
|
}
|
|
@@ -142,9 +216,10 @@ async function settleCapture(host, ceilingMs = CAPTURE_ISLAND_SETTLE_TIMEOUT_MS)
|
|
|
142
216
|
}
|
|
143
217
|
await host.evaluate(CAPTURE_READY_EXPRESSION);
|
|
144
218
|
await awaitNetworkQuiescence(host, ceilingMs);
|
|
219
|
+
await host.evaluate(CAPTURE_FRESH_LAYOUT_EXPRESSION);
|
|
145
220
|
await host.evaluate(CAPTURE_ANIMATIONS_SETTLED_EXPRESSION);
|
|
146
221
|
await host.evaluate(hasIslands ? CAPTURE_ISLAND_PAINT_GRACE_EXPRESSION : CAPTURE_RAF_FLUSH_EXPRESSION);
|
|
147
222
|
}
|
|
148
223
|
|
|
149
224
|
//#endregion
|
|
150
|
-
export { CAPTURE_ANIMATIONS_SETTLED_EXPRESSION, CAPTURE_HAS_ISLANDS_EXPRESSION, CAPTURE_ISLANDS_DIAGNOSTIC_EXPRESSION, CAPTURE_ISLANDS_READY_EXPRESSION, CAPTURE_ISLANDS_READY_GLOBAL, CAPTURE_ISLAND_PAINT_GRACE_EXPRESSION, CAPTURE_ISLAND_SETTLE_TIMEOUT_MS, CAPTURE_READY_EXPRESSION, CAPTURE_WAIT_UNTIL, settleCapture };
|
|
225
|
+
export { CAPTURE_ANIMATIONS_SETTLED_EXPRESSION, CAPTURE_FRESH_LAYOUT_EXPRESSION, CAPTURE_HAS_ISLANDS_EXPRESSION, CAPTURE_IN_VIEW_SCRIPT, CAPTURE_ISLANDS_DIAGNOSTIC_EXPRESSION, CAPTURE_ISLANDS_READY_EXPRESSION, CAPTURE_ISLANDS_READY_GLOBAL, CAPTURE_ISLAND_PAINT_GRACE_EXPRESSION, CAPTURE_ISLAND_SETTLE_TIMEOUT_MS, CAPTURE_READY_EXPRESSION, CAPTURE_WAIT_UNTIL, settleCapture };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { existsSync, readFileSync, readdirSync, realpathSync, statSync } from "node:fs";
|
|
2
|
+
import { dirname, join, relative, sep } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { createHash } from "node:crypto";
|
|
5
|
+
|
|
6
|
+
//#region ../../internal/code-fingerprint/dist/index.js
|
|
7
|
+
const WORKSPACE_SCOPE = "@homepages/";
|
|
8
|
+
const NOT_CODE = [
|
|
9
|
+
/\.d\.[cm]?ts$/,
|
|
10
|
+
/\.map$/,
|
|
11
|
+
/\.tsbuildinfo$/,
|
|
12
|
+
/\.test\.[cm]?[jt]sx?$/
|
|
13
|
+
];
|
|
14
|
+
const byDirectory = /* @__PURE__ */ new Map();
|
|
15
|
+
function codeFingerprintAt(directory) {
|
|
16
|
+
return fingerprintOf(realpathSync(directory), /* @__PURE__ */ new Set());
|
|
17
|
+
}
|
|
18
|
+
function packageDirectory(packageName, start) {
|
|
19
|
+
for (let dir = start;; dir = dirname(dir)) {
|
|
20
|
+
const candidate = join(dir, "node_modules", packageName);
|
|
21
|
+
if (existsSync(join(candidate, "package.json"))) return realpathSync(candidate);
|
|
22
|
+
if (dirname(dir) === dir) throw new Error(`No package "${packageName}" is reachable from ${start}.`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function fingerprintOf(directory, visiting) {
|
|
26
|
+
const known = byDirectory.get(directory);
|
|
27
|
+
if (known !== void 0) return known;
|
|
28
|
+
if (visiting.has(directory)) return `cycle:${directory}`;
|
|
29
|
+
visiting.add(directory);
|
|
30
|
+
const manifestBytes = readFileSync(join(directory, "package.json"));
|
|
31
|
+
const manifest = JSON.parse(manifestBytes.toString("utf8"));
|
|
32
|
+
const built = join(directory, "dist");
|
|
33
|
+
const codeRoot = existsSync(built) ? built : join(directory, "src");
|
|
34
|
+
const files = existsSync(codeRoot) ? codeFiles(codeRoot).map((file) => [relative(directory, file).split(sep).join("/"), sha256(readFileSync(file))]) : [];
|
|
35
|
+
const dependencies = Object.keys(manifest.dependencies ?? {}).filter((name) => name.startsWith(WORKSPACE_SCOPE)).sort().map((name) => [name, fingerprintOf(packageDirectory(name, directory), visiting)]);
|
|
36
|
+
visiting.delete(directory);
|
|
37
|
+
const fingerprint = sha256(Buffer.from(JSON.stringify([
|
|
38
|
+
sha256(manifestBytes),
|
|
39
|
+
files,
|
|
40
|
+
dependencies
|
|
41
|
+
])));
|
|
42
|
+
byDirectory.set(directory, fingerprint);
|
|
43
|
+
return fingerprint;
|
|
44
|
+
}
|
|
45
|
+
function codeFiles(dir) {
|
|
46
|
+
return readdirSync(dir).sort().flatMap((name) => {
|
|
47
|
+
const full = join(dir, name);
|
|
48
|
+
if (statSync(full).isDirectory()) return name === "node_modules" ? [] : codeFiles(full);
|
|
49
|
+
return NOT_CODE.some((pattern) => pattern.test(name)) ? [] : [full];
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
function sha256(bytes) {
|
|
53
|
+
return createHash("sha256").update(bytes).digest("hex");
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
//#endregion
|
|
57
|
+
export { codeFingerprintAt };
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { withSlotValue } from "../../template-contracts/dist/slot-overrides.js";
|
|
2
|
+
import { withMadeRows } from "./made-rows.js";
|
|
3
|
+
|
|
4
|
+
//#region ../../internal/content-doc-ops/dist/index.js
|
|
5
|
+
var ContentDocOpsRefusal = class extends Error {
|
|
6
|
+
faults;
|
|
7
|
+
constructor(faults) {
|
|
8
|
+
super(faults.map((fault) => fault.message).join("; "));
|
|
9
|
+
this.faults = faults;
|
|
10
|
+
this.name = "ContentDocOpsRefusal";
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
function applyContentDocOps(doc, ops, input) {
|
|
14
|
+
const { composition } = input;
|
|
15
|
+
const declaredVariants = input.declaredVariants ?? /* @__PURE__ */ new Map();
|
|
16
|
+
const listsOfObjects = input.listsOfObjects ?? /* @__PURE__ */ new Map();
|
|
17
|
+
const required = /* @__PURE__ */ new Map();
|
|
18
|
+
for (const page of composition.pages) for (const section of page.sections) if (!required.has(section.instance_id)) required.set(section.instance_id, section.required === true);
|
|
19
|
+
const pageById = new Map(composition.pages.map((p) => [p.id, p]));
|
|
20
|
+
const faults = [];
|
|
21
|
+
ops.forEach((op, index) => {
|
|
22
|
+
if ("section_instance_id" in op && !required.has(op.section_instance_id)) faults.push({
|
|
23
|
+
pointer: `/ops/${index}/section_instance_id`,
|
|
24
|
+
code: "unknown_section_instance",
|
|
25
|
+
message: `No section instance '${op.section_instance_id}' in the deliverable's composition`
|
|
26
|
+
});
|
|
27
|
+
if (op.op === "set_variant" && required.has(op.section_instance_id)) {
|
|
28
|
+
const declared = declaredVariants.get(op.section_instance_id);
|
|
29
|
+
if (!declared) faults.push({
|
|
30
|
+
pointer: `/ops/${index}/variant`,
|
|
31
|
+
code: "section_declares_no_variant",
|
|
32
|
+
message: `Section instance '${op.section_instance_id}' declares no display variant`
|
|
33
|
+
});
|
|
34
|
+
else if (declared.locked) faults.push({
|
|
35
|
+
pointer: `/ops/${index}/variant`,
|
|
36
|
+
code: "variant_locked",
|
|
37
|
+
message: `Section instance '${op.section_instance_id}' declares a locked variant, which the user cannot switch`
|
|
38
|
+
});
|
|
39
|
+
else if (!declared.cases.includes(op.variant)) faults.push({
|
|
40
|
+
pointer: `/ops/${index}/variant`,
|
|
41
|
+
code: "unknown_variant_case",
|
|
42
|
+
message: `'${op.variant}' is not a declared case of section instance '${op.section_instance_id}' (declared: ${declared.cases.join(", ")})`
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
if (op.op === "set_slot" && op.override?.kind === "scalar" && listsOfObjects.get(op.section_instance_id)?.has(op.slot_id) === true) faults.push({
|
|
46
|
+
pointer: `/ops/${index}/override`,
|
|
47
|
+
code: "whole_list_marker_on_list_of_objects",
|
|
48
|
+
message: `Slot '${op.slot_id}' is a list of objects, which marks per item, never whole`
|
|
49
|
+
});
|
|
50
|
+
if (op.op === "toggle_section" && !op.enabled && required.get(op.section_instance_id) === true) faults.push({
|
|
51
|
+
pointer: `/ops/${index}/section_instance_id`,
|
|
52
|
+
code: "section_required",
|
|
53
|
+
message: `Section instance '${op.section_instance_id}' is required and cannot be hidden`
|
|
54
|
+
});
|
|
55
|
+
if (op.op === "toggle_page") {
|
|
56
|
+
const page = pageById.get(op.page_id);
|
|
57
|
+
if (!page) faults.push({
|
|
58
|
+
pointer: `/ops/${index}/page_id`,
|
|
59
|
+
code: "unknown_page",
|
|
60
|
+
message: `No page '${op.page_id}' in the deliverable's composition`
|
|
61
|
+
});
|
|
62
|
+
else if (!page.optional) faults.push({
|
|
63
|
+
pointer: `/ops/${index}/page_id`,
|
|
64
|
+
code: "page_not_optional",
|
|
65
|
+
message: `Page '${op.page_id}' is not optional and cannot be toggled`
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
if (faults.length) throw new ContentDocOpsRefusal(faults);
|
|
70
|
+
const next = {
|
|
71
|
+
...doc,
|
|
72
|
+
instances: doc.instances.map((i) => ({
|
|
73
|
+
...i,
|
|
74
|
+
slots: { ...i.slots },
|
|
75
|
+
...i.slot_overrides ? { slot_overrides: structuredClone(i.slot_overrides) } : {},
|
|
76
|
+
...i.display_overrides ? { display_overrides: { ...i.display_overrides } } : {}
|
|
77
|
+
})),
|
|
78
|
+
...doc.page_state ? { page_state: doc.page_state.map((p) => ({ ...p })) } : {}
|
|
79
|
+
};
|
|
80
|
+
const findInstance = (id) => {
|
|
81
|
+
const found = next.instances.find((i) => i.instance_id === id);
|
|
82
|
+
if (!found) throw new Error(`instance ${id} vanished after validation`);
|
|
83
|
+
return found;
|
|
84
|
+
};
|
|
85
|
+
for (const op of ops) switch (op.op) {
|
|
86
|
+
case "set_slot": {
|
|
87
|
+
const inst = findInstance(op.section_instance_id);
|
|
88
|
+
inst.slots = withSlotValue(inst.slots, op.slot_id, op.value);
|
|
89
|
+
if (op.override) setOverrideLeaf(inst, op.slot_id, op.override);
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
case "relink_slot":
|
|
93
|
+
clearOverrideLeaf(findInstance(op.section_instance_id), op.slot_id, op.target);
|
|
94
|
+
break;
|
|
95
|
+
case "toggle_section": {
|
|
96
|
+
const inst = findInstance(op.section_instance_id);
|
|
97
|
+
inst.enabled = op.enabled;
|
|
98
|
+
markDisplayOwned(inst, "visibility");
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
case "set_variant": {
|
|
102
|
+
const inst = findInstance(op.section_instance_id);
|
|
103
|
+
inst.variant = op.variant;
|
|
104
|
+
markDisplayOwned(inst, "variant");
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
case "toggle_page": {
|
|
108
|
+
const entries = next.page_state ?? [];
|
|
109
|
+
const existing = entries.find((p) => p.page_id === op.page_id);
|
|
110
|
+
if (existing) existing.enabled = op.enabled;
|
|
111
|
+
else entries.push({
|
|
112
|
+
page_id: op.page_id,
|
|
113
|
+
enabled: op.enabled
|
|
114
|
+
});
|
|
115
|
+
next.page_state = entries;
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return next;
|
|
120
|
+
}
|
|
121
|
+
function markDisplayOwned(inst, entry) {
|
|
122
|
+
inst.display_overrides = {
|
|
123
|
+
...inst.display_overrides,
|
|
124
|
+
[entry]: true
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
function setOverrideLeaf(inst, slotId, target) {
|
|
128
|
+
const marks = inst.slot_overrides ??= {};
|
|
129
|
+
if (target.kind === "scalar") (marks.scalar ??= {})[slotId] = true;
|
|
130
|
+
else if (target.kind === "item") {
|
|
131
|
+
const bySlot = marks.items ??= {};
|
|
132
|
+
const byItem = bySlot[slotId] ??= {};
|
|
133
|
+
(byItem[target.item_id] ??= {})[target.field] = true;
|
|
134
|
+
} else if (target.kind === "order") (marks.order ??= {})[slotId] = true;
|
|
135
|
+
else {
|
|
136
|
+
const bySlot = marks.items_removed ??= {};
|
|
137
|
+
(bySlot[slotId] ??= {})[target.item_id] = true;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
function clearOverrideLeaf(inst, slotId, target) {
|
|
141
|
+
const marks = inst.slot_overrides;
|
|
142
|
+
if (!marks) return;
|
|
143
|
+
if (target.kind === "scalar") {
|
|
144
|
+
if (marks.scalar) {
|
|
145
|
+
delete marks.scalar[slotId];
|
|
146
|
+
if (Object.keys(marks.scalar).length === 0) delete marks.scalar;
|
|
147
|
+
}
|
|
148
|
+
} else if (target.kind === "item") {
|
|
149
|
+
const itemMap = marks.items?.[slotId];
|
|
150
|
+
if (itemMap) {
|
|
151
|
+
const fieldMap = itemMap[target.item_id];
|
|
152
|
+
if (fieldMap) {
|
|
153
|
+
delete fieldMap[target.field];
|
|
154
|
+
if (Object.keys(fieldMap).length === 0) delete itemMap[target.item_id];
|
|
155
|
+
}
|
|
156
|
+
if (Object.keys(itemMap).length === 0) delete marks.items[slotId];
|
|
157
|
+
if (marks.items && Object.keys(marks.items).length === 0) delete marks.items;
|
|
158
|
+
}
|
|
159
|
+
} else if (target.kind === "order") {
|
|
160
|
+
if (marks.order) {
|
|
161
|
+
delete marks.order[slotId];
|
|
162
|
+
if (Object.keys(marks.order).length === 0) delete marks.order;
|
|
163
|
+
}
|
|
164
|
+
} else {
|
|
165
|
+
const removedMap = marks.items_removed?.[slotId];
|
|
166
|
+
if (removedMap) {
|
|
167
|
+
delete removedMap[target.item_id];
|
|
168
|
+
if (Object.keys(removedMap).length === 0) delete marks.items_removed[slotId];
|
|
169
|
+
if (marks.items_removed && Object.keys(marks.items_removed).length === 0) delete marks.items_removed;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
if (!marks.scalar && !marks.items && !marks.items_removed && !marks.order) delete inst.slot_overrides;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
//#endregion
|
|
176
|
+
export { ContentDocOpsRefusal, applyContentDocOps, withMadeRows };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region ../../internal/content-doc-ops/dist/made-rows.js
|
|
2
|
+
function withMadeRows(value, rowIds, key) {
|
|
3
|
+
if (rowIds.size === 0) return value;
|
|
4
|
+
if (typeof value === "string") {
|
|
5
|
+
const made = rowIds.get(value);
|
|
6
|
+
if (made !== void 0) return made;
|
|
7
|
+
return key === "path" ? value.split(".").map((segment) => rowIds.get(segment) ?? segment).join(".") : value;
|
|
8
|
+
}
|
|
9
|
+
if (Array.isArray(value)) return value.map((entry) => withMadeRows(entry, rowIds));
|
|
10
|
+
if (value !== null && typeof value === "object") return Object.fromEntries(Object.entries(value).map(([name, entry]) => [name, withMadeRows(entry, rowIds, name)]));
|
|
11
|
+
return value;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
export { withMadeRows };
|