@homepages/concrete 12.0.0 → 13.0.1
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 +192 -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 +15 -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,54 @@
|
|
|
1
|
+
import { builtEnv } from "./built.js";
|
|
2
|
+
import { folderReads } from "./fixture-operations.js";
|
|
3
|
+
import { serveHost } from "./serve.js";
|
|
4
|
+
import { fixtureListPath, fixtureReads, storedFixtures } from "./stored-fixtures.js";
|
|
5
|
+
|
|
6
|
+
//#region ../../internal/playground/dist/host/program.js
|
|
7
|
+
function createPlayground(env) {
|
|
8
|
+
const built = builtEnv(env);
|
|
9
|
+
const fixturesAt = env.fixtures ? storedFixtures({
|
|
10
|
+
env,
|
|
11
|
+
built,
|
|
12
|
+
reader: built.reader
|
|
13
|
+
}) : null;
|
|
14
|
+
const saves = fixturesAt === null ? void 0 : {
|
|
15
|
+
async current() {
|
|
16
|
+
const view = await env.files.current();
|
|
17
|
+
const [{ template, fixtureList }, fixtures] = await Promise.all([built.readAt(view), fixturesAt(view)]);
|
|
18
|
+
return {
|
|
19
|
+
version: view.version,
|
|
20
|
+
template,
|
|
21
|
+
fixtures,
|
|
22
|
+
list: fixtureListPath(fixtureList),
|
|
23
|
+
reads: {
|
|
24
|
+
...fixtureReads(env, view),
|
|
25
|
+
...folderReads(view)
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
},
|
|
29
|
+
change: (base, writes) => env.files.change(base, writes),
|
|
30
|
+
async served(path) {
|
|
31
|
+
return (await env.media(await env.files.current(), path))?.file ?? null;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
return serveHost({
|
|
35
|
+
reader: built.reader,
|
|
36
|
+
renderer: built.renderer,
|
|
37
|
+
assetUrl: env.url,
|
|
38
|
+
stylesheets: built.stylesheets,
|
|
39
|
+
saves,
|
|
40
|
+
fixtures: async () => fixturesAt === null ? {
|
|
41
|
+
properties: [],
|
|
42
|
+
fixtures: [],
|
|
43
|
+
violations: []
|
|
44
|
+
} : fixturesAt(await env.files.current()),
|
|
45
|
+
version: async () => (await env.files.current()).version,
|
|
46
|
+
jobs: env.jobs,
|
|
47
|
+
site: built.site,
|
|
48
|
+
downloads: env.downloads,
|
|
49
|
+
fixtureMediaPath: env.fixtureMediaPath
|
|
50
|
+
}, env.base);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
//#endregion
|
|
54
|
+
export { createPlayground };
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { derivedMembers } from "../../../template-contracts/dist/fact-compute.js";
|
|
2
|
+
import { propertyFacts } from "../../../template-contracts/dist/fact-registry.js";
|
|
3
|
+
import { SIZED_IMAGE_EXTENSIONS } from "../../../template-artifact/dist/asset-mime.js";
|
|
4
|
+
import { imageDimensions } from "./image-dimensions.js";
|
|
5
|
+
|
|
6
|
+
//#region ../../internal/playground/dist/host/property-derive.js
|
|
7
|
+
function contactImageId(contactId, field) {
|
|
8
|
+
return `contact:${contactId}:${field}`;
|
|
9
|
+
}
|
|
10
|
+
function comparableImageId(comparableId) {
|
|
11
|
+
return `comparable:${comparableId}:photo`;
|
|
12
|
+
}
|
|
13
|
+
const FIXTURE_EPOCH = Date.UTC(2026, 0, 1);
|
|
14
|
+
function addedAt(index) {
|
|
15
|
+
return new Date(FIXTURE_EPOCH + index * 1e3).toISOString();
|
|
16
|
+
}
|
|
17
|
+
const MIME_BY_EXTENSION = {
|
|
18
|
+
".pdf": "application/pdf",
|
|
19
|
+
".mp4": "video/mp4",
|
|
20
|
+
".webm": "video/webm",
|
|
21
|
+
".mov": "video/quicktime",
|
|
22
|
+
".mp3": "audio/mpeg",
|
|
23
|
+
".wav": "audio/wav",
|
|
24
|
+
".png": "image/png",
|
|
25
|
+
".jpg": "image/jpeg",
|
|
26
|
+
".jpeg": "image/jpeg",
|
|
27
|
+
".webp": "image/webp",
|
|
28
|
+
".avif": "image/avif",
|
|
29
|
+
".gif": "image/gif",
|
|
30
|
+
".svg": "image/svg+xml",
|
|
31
|
+
".zip": "application/zip"
|
|
32
|
+
};
|
|
33
|
+
const DERIVED_EXTENSIONS = SIZED_IMAGE_EXTENSIONS;
|
|
34
|
+
function baseOf(url) {
|
|
35
|
+
return url.slice(url.lastIndexOf("/") + 1);
|
|
36
|
+
}
|
|
37
|
+
function extensionOfUrl(url) {
|
|
38
|
+
const base = baseOf(url);
|
|
39
|
+
const dot = base.lastIndexOf(".");
|
|
40
|
+
return dot <= 0 ? "" : base.slice(dot).toLowerCase();
|
|
41
|
+
}
|
|
42
|
+
function fileUrlOf(file) {
|
|
43
|
+
return typeof file === "string" ? file : file.url;
|
|
44
|
+
}
|
|
45
|
+
function fixtureMediaUrl(mount, path, fingerprint) {
|
|
46
|
+
const name = path.slice(path.lastIndexOf("/") + 1);
|
|
47
|
+
const dot = name.lastIndexOf(".");
|
|
48
|
+
const [stem, ext] = dot <= 0 ? [name, ""] : [name.slice(0, dot), name.slice(dot).toLowerCase()];
|
|
49
|
+
return `${mount}/${stem}-${fingerprint.slice(0, 8)}${ext}`;
|
|
50
|
+
}
|
|
51
|
+
function fixtureMediaAddressKey(key, mount) {
|
|
52
|
+
return mount !== void 0 && key.startsWith(`${mount}/`) ? key.slice(mount.length) : key;
|
|
53
|
+
}
|
|
54
|
+
function displayName(url) {
|
|
55
|
+
const base = baseOf(url);
|
|
56
|
+
const dot = base.lastIndexOf(".");
|
|
57
|
+
const ext = dot <= 0 ? "" : base.slice(dot);
|
|
58
|
+
return base.slice(0, base.length - ext.length).replace(/-[0-9a-f]{8}$/, "") + ext;
|
|
59
|
+
}
|
|
60
|
+
function mimeOf(url) {
|
|
61
|
+
return MIME_BY_EXTENSION[extensionOfUrl(url)] ?? "application/octet-stream";
|
|
62
|
+
}
|
|
63
|
+
function importedFileValue(url, bytes, responsive) {
|
|
64
|
+
if (!DERIVED_EXTENSIONS.has(extensionOfUrl(url))) return url;
|
|
65
|
+
return {
|
|
66
|
+
url,
|
|
67
|
+
responsive,
|
|
68
|
+
...imageDimensions(bytes) ?? {
|
|
69
|
+
width: 0,
|
|
70
|
+
height: 0
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function renditionOf(file, mime = null) {
|
|
75
|
+
const sized = typeof file === "string" ? null : file;
|
|
76
|
+
return {
|
|
77
|
+
key: fileUrlOf(file),
|
|
78
|
+
mime,
|
|
79
|
+
width: sized?.width ?? null,
|
|
80
|
+
height: sized?.height ?? null,
|
|
81
|
+
bytes: null
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
function fileCatalogEntry(id, kind, file) {
|
|
85
|
+
const url = fileUrlOf(file);
|
|
86
|
+
return {
|
|
87
|
+
id,
|
|
88
|
+
kind,
|
|
89
|
+
file,
|
|
90
|
+
url: null,
|
|
91
|
+
provider: null,
|
|
92
|
+
filename: url === "" ? "" : displayName(url),
|
|
93
|
+
mime: url === "" ? "" : mimeOf(url)
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
function fileMedia(id, kind, file, index, stated, extra) {
|
|
97
|
+
const url = fileUrlOf(file);
|
|
98
|
+
const held = kind === "video" ? {
|
|
99
|
+
encode: renditionOf(file, mimeOf(url)),
|
|
100
|
+
...extra === void 0 ? {} : { poster: renditionOf(extra) }
|
|
101
|
+
} : extra === void 0 ? {} : { poster: renditionOf(extra) };
|
|
102
|
+
return {
|
|
103
|
+
record: fixtureRecord(id, kind, displayName(url), addedAt(index), {
|
|
104
|
+
mime: mimeOf(url),
|
|
105
|
+
...stated,
|
|
106
|
+
key: url,
|
|
107
|
+
renditions: renditionsOf(held)
|
|
108
|
+
}),
|
|
109
|
+
catalog: {
|
|
110
|
+
...fileCatalogEntry(id, kind, file),
|
|
111
|
+
...extra === void 0 ? {} : { posterFile: extra }
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
function ownedImageMedia(id, file) {
|
|
116
|
+
const url = fileUrlOf(file);
|
|
117
|
+
return {
|
|
118
|
+
record: fixtureRecord(id, "image", displayName(url), addedAt(0), {
|
|
119
|
+
mime: mimeOf(url),
|
|
120
|
+
key: url
|
|
121
|
+
}),
|
|
122
|
+
catalog: fileCatalogEntry(id, "image", file)
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
const NOTHING_STATED = {
|
|
126
|
+
crop: null,
|
|
127
|
+
key: null,
|
|
128
|
+
mime: null,
|
|
129
|
+
bytes: null,
|
|
130
|
+
url: null,
|
|
131
|
+
provider: null,
|
|
132
|
+
account: null,
|
|
133
|
+
page_count: null,
|
|
134
|
+
duration_ms: null,
|
|
135
|
+
width: null,
|
|
136
|
+
height: null,
|
|
137
|
+
captured_at: null,
|
|
138
|
+
scan_count: null,
|
|
139
|
+
poster_at_ms: null,
|
|
140
|
+
renditions: {
|
|
141
|
+
master: null,
|
|
142
|
+
crop: null,
|
|
143
|
+
cutout: null,
|
|
144
|
+
mask_white: null,
|
|
145
|
+
mask_black: null,
|
|
146
|
+
poster: null,
|
|
147
|
+
encode: null
|
|
148
|
+
},
|
|
149
|
+
state: "ready"
|
|
150
|
+
};
|
|
151
|
+
function fixtureRecord(id, kind, name, added, stated) {
|
|
152
|
+
return {
|
|
153
|
+
...NOTHING_STATED,
|
|
154
|
+
id,
|
|
155
|
+
file: id,
|
|
156
|
+
kind,
|
|
157
|
+
name,
|
|
158
|
+
added_at: added,
|
|
159
|
+
...stated
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
function linkName(url) {
|
|
163
|
+
return typeof url === "string" ? url.replace(/^[a-z][a-z0-9+.-]*:\/\//i, "") : "";
|
|
164
|
+
}
|
|
165
|
+
function renditionsOf(held) {
|
|
166
|
+
return {
|
|
167
|
+
master: null,
|
|
168
|
+
crop: null,
|
|
169
|
+
cutout: null,
|
|
170
|
+
mask_white: null,
|
|
171
|
+
mask_black: null,
|
|
172
|
+
poster: null,
|
|
173
|
+
encode: null,
|
|
174
|
+
...held
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
function thumbnailRendition(url) {
|
|
178
|
+
return {
|
|
179
|
+
key: url,
|
|
180
|
+
mime: null,
|
|
181
|
+
width: null,
|
|
182
|
+
height: null,
|
|
183
|
+
bytes: null
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
function linkMedia(id, kind, stated, index, posterUrl) {
|
|
187
|
+
const held = posterUrl === void 0 ? {} : { poster: thumbnailRendition(posterUrl) };
|
|
188
|
+
const url = stated["url"];
|
|
189
|
+
const provider = stated["provider"];
|
|
190
|
+
return {
|
|
191
|
+
record: fixtureRecord(id, kind, linkName(url), addedAt(index), {
|
|
192
|
+
...stated,
|
|
193
|
+
renditions: renditionsOf(held)
|
|
194
|
+
}),
|
|
195
|
+
catalog: {
|
|
196
|
+
id,
|
|
197
|
+
kind,
|
|
198
|
+
file: null,
|
|
199
|
+
url: typeof url === "string" ? url : null,
|
|
200
|
+
provider: typeof provider === "string" ? provider : null,
|
|
201
|
+
filename: "",
|
|
202
|
+
mime: "",
|
|
203
|
+
...posterUrl === void 0 ? {} : { posterUrl }
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
const COMPARABLE_FIELDS = propertyFacts.pages.comparables.declaration.element.fields;
|
|
208
|
+
function comparableDerived(comparable, subject) {
|
|
209
|
+
return {
|
|
210
|
+
...comparable,
|
|
211
|
+
...derivedMembers(COMPARABLE_FIELDS, comparable, subject)
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
//#endregion
|
|
216
|
+
export { addedAt, comparableDerived, comparableImageId, contactImageId, displayName, extensionOfUrl, fileCatalogEntry, fileMedia, fileUrlOf, fixtureMediaAddressKey, fixtureMediaUrl, fixtureRecord, importedFileValue, linkMedia, mimeOf, ownedImageMedia, renditionOf, renditionsOf };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { normalizeAddressValue } from "../../../template-contracts/dist/address-value.js";
|
|
2
|
+
import { memberValueType, tableNames } from "../../../template-contracts/dist/registry-shape.js";
|
|
3
|
+
import { isRegistryFactKey, registryFactValueType } from "../../../template-contracts/dist/fact-keys.js";
|
|
4
|
+
import { isStorable, tableField } from "../../../template-contracts/dist/table-members.js";
|
|
5
|
+
import { HostRefusal } from "./env.js";
|
|
6
|
+
|
|
7
|
+
//#region ../../internal/playground/dist/host/property-saves.js
|
|
8
|
+
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9
|
+
function factValueOf(valueType, value) {
|
|
10
|
+
if (valueType === "address") return normalizeAddressValue(value);
|
|
11
|
+
if (valueType === "text_list" || valueType === "number_list") return (Array.isArray(value) ? value : []).filter((entry) => entry !== null && entry !== void 0 && entry !== "").map((entry) => scalarAs(valueType === "text_list" ? "text" : "number", entry));
|
|
12
|
+
return scalarAs(valueType, value);
|
|
13
|
+
}
|
|
14
|
+
function scalarAs(valueType, value) {
|
|
15
|
+
if (valueType === "number") {
|
|
16
|
+
if (value === "" || value === void 0 || value === null) return null;
|
|
17
|
+
if (typeof value === "string" && Number.isFinite(Number(value))) return Number(value);
|
|
18
|
+
}
|
|
19
|
+
if (valueType === "text" && typeof value === "number") return String(value);
|
|
20
|
+
return value ?? null;
|
|
21
|
+
}
|
|
22
|
+
const isTable = (name) => tableNames().includes(name);
|
|
23
|
+
function factTargetAt(path) {
|
|
24
|
+
const parts = path.split(".");
|
|
25
|
+
if (parts.length === 3) {
|
|
26
|
+
const [table, row, member] = parts;
|
|
27
|
+
if (!isTable(table)) throw new HostRefusal(400, `"${path}" names no row of a table the property holds.`);
|
|
28
|
+
if (!isStorable(table, member)) throw new HostRefusal(400, `"${path}" is ${table}' ${member}, which no one writes back.`);
|
|
29
|
+
const declaration = tableField(table, member);
|
|
30
|
+
return {
|
|
31
|
+
table,
|
|
32
|
+
row,
|
|
33
|
+
member,
|
|
34
|
+
valueType: declaration === void 0 ? null : memberValueType(declaration)
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
const key = `property.${path}`;
|
|
38
|
+
if (parts.length !== 1 || !isRegistryFactKey(key) || !isStorable(key)) throw new HostRefusal(400, `"${path}" names no fact the playground can write.`);
|
|
39
|
+
if (isTable(path)) throw new HostRefusal(400, `"${path}" is a list of rows: write its rows.`);
|
|
40
|
+
return {
|
|
41
|
+
table: null,
|
|
42
|
+
member: path,
|
|
43
|
+
valueType: registryFactValueType(key)
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function written(before, value) {
|
|
47
|
+
if (!isRecord(value)) return value;
|
|
48
|
+
const held = isRecord(before) ? before : {};
|
|
49
|
+
const out = { ...held };
|
|
50
|
+
for (const [part, next] of Object.entries(value)) if (next !== null || part in held) out[part] = next;
|
|
51
|
+
return out;
|
|
52
|
+
}
|
|
53
|
+
function factWrite(into, property, path, value) {
|
|
54
|
+
const target = factTargetAt(path);
|
|
55
|
+
if (Array.isArray(value) && target.valueType !== "text_list" && target.valueType !== "number_list") throw new HostRefusal(400, `"${path}" holds no list; set its value.`);
|
|
56
|
+
const fact = factValueOf(target.valueType, value);
|
|
57
|
+
if (target.table === null) return {
|
|
58
|
+
...property,
|
|
59
|
+
[target.member]: written(property[target.member], fact)
|
|
60
|
+
};
|
|
61
|
+
const { table, row } = target;
|
|
62
|
+
const rows = property[table];
|
|
63
|
+
if (!Array.isArray(rows) || !rows.some((r) => isRecord(r) && r["id"] === row)) throw new HostRefusal(404, `The property document "${into.property}" holds no ${table} row "${row}".`);
|
|
64
|
+
return {
|
|
65
|
+
...property,
|
|
66
|
+
[table]: rows.map((r) => isRecord(r) && r["id"] === row ? {
|
|
67
|
+
...r,
|
|
68
|
+
[target.member]: written(r[target.member], fact)
|
|
69
|
+
} : r)
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
//#endregion
|
|
74
|
+
export { factWrite };
|