@homepages/concrete 1.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 +59 -0
- package/README.md +174 -0
- package/codemods/manifest.json +9 -0
- package/dist/artifact/playground/client/assets/index-BSA1yutg.css +1 -0
- package/dist/artifact/playground/client/assets/index-JloQyj8h.js +1101 -0
- package/dist/artifact/playground/client/index.html +13 -0
- package/dist/artifact/playground/client/island-canvas-host.mjs +1 -0
- package/dist/artifact/playground/host.mjs +127 -0
- package/dist/asset-modules.d.ts +99 -0
- package/dist/base.css +220 -0
- package/dist/browser/site-config.d.ts +18 -0
- package/dist/browser/site-config.js +56 -0
- package/dist/browser/submit-lead.d.ts +98 -0
- package/dist/browser/submit-lead.js +188 -0
- package/dist/browser.d.ts +3 -0
- package/dist/browser.js +4 -0
- package/dist/cli/build/artifact.js +225 -0
- package/dist/cli/build/captures.js +67 -0
- package/dist/cli/build/esbuild.js +127 -0
- package/dist/cli/build/fixtures.js +96 -0
- package/dist/cli/build/icons.js +76 -0
- package/dist/cli/build/index.js +38 -0
- package/dist/cli/build/playground.js +31 -0
- package/dist/cli/build/sections.js +236 -0
- package/dist/cli/build/source.js +62 -0
- package/dist/cli/build/static.js +156 -0
- package/dist/cli/capture/bundle.js +37 -0
- package/dist/cli/capture/capture-browser.js +51 -0
- package/dist/cli/capture/capture.js +121 -0
- package/dist/cli/check/analyze.js +95 -0
- package/dist/cli/check/index.js +19 -0
- package/dist/cli/check/load-workspace.js +119 -0
- package/dist/cli/check/messages.js +16 -0
- package/dist/cli/check/render/class-conflicts.js +39 -0
- package/dist/cli/check/render/html.js +86 -0
- package/dist/cli/check/render/inputs.js +53 -0
- package/dist/cli/check/render/invariants.js +58 -0
- package/dist/cli/check/render/island-frames.js +72 -0
- package/dist/cli/check/render/marker-coverage.js +102 -0
- package/dist/cli/check/render/nav.js +64 -0
- package/dist/cli/check/report.js +73 -0
- package/dist/cli/check/stages/bundles.js +129 -0
- package/dist/cli/check/stages/composition.js +67 -0
- package/dist/cli/check/stages/contracts.js +22 -0
- package/dist/cli/check/stages/dependencies.js +261 -0
- package/dist/cli/check/stages/fixtures.js +74 -0
- package/dist/cli/check/stages/lint.js +41 -0
- package/dist/cli/check/stages/logic.js +63 -0
- package/dist/cli/check/stages/render.js +144 -0
- package/dist/cli/check/stages/sections.js +83 -0
- package/dist/cli/check/stages/stylesheet.js +31 -0
- package/dist/cli/check/stages/typecheck.js +68 -0
- package/dist/cli/check/stages/workspace.js +26 -0
- package/dist/cli/commands.js +342 -0
- package/dist/cli/currency/cache.js +89 -0
- package/dist/cli/currency/decide.js +65 -0
- package/dist/cli/currency/opt-out.js +16 -0
- package/dist/cli/currency/preamble.js +183 -0
- package/dist/cli/currency/prompt.js +28 -0
- package/dist/cli/currency/refresh.js +44 -0
- package/dist/cli/currency/resolve-latest.js +185 -0
- package/dist/cli/currency/version-order.js +38 -0
- package/dist/cli/dev/crop.js +22 -0
- package/dist/cli/dev/hmr.js +26 -0
- package/dist/cli/dev/http.js +129 -0
- package/dist/cli/dev/index.js +70 -0
- package/dist/cli/dev/islands.js +390 -0
- package/dist/cli/dev/load-template.js +46 -0
- package/dist/cli/dev/request-error.js +22 -0
- package/dist/cli/dev/server.js +307 -0
- package/dist/cli/dev/tsconfig-paths.js +95 -0
- package/dist/cli/dev/vite.js +85 -0
- package/dist/cli/dev/workspace-reader.js +274 -0
- package/dist/cli/io.d.ts +14 -0
- package/dist/cli/media/cache.js +125 -0
- package/dist/cli/media/derive.js +252 -0
- package/dist/cli/media/deriver-plugin.js +71 -0
- package/dist/cli/property/index.js +180 -0
- package/dist/cli/property/library.js +137 -0
- package/dist/cli/publish/client.js +119 -0
- package/dist/cli/publish/freshness.js +66 -0
- package/dist/cli/publish/git.js +43 -0
- package/dist/cli/publish/index.js +207 -0
- package/dist/cli/publish/pack.js +78 -0
- package/dist/cli/publish/report.js +98 -0
- package/dist/cli/publish/target.js +87 -0
- package/dist/cli/publish/wire.js +29 -0
- package/dist/cli/tar.js +87 -0
- package/dist/cli/upgrade/codemod.js +56 -0
- package/dist/cli/upgrade/index.js +263 -0
- package/dist/cli/upgrade/manifest.js +72 -0
- package/dist/cli/upgrade/plan.js +68 -0
- package/dist/cli/upgrade/stage.js +71 -0
- package/dist/cli/version.d.ts +12 -0
- package/dist/cli/version.js +15 -0
- package/dist/cli/workspace.js +108 -0
- package/dist/cli.d.ts +6 -0
- package/dist/cli.js +94 -0
- package/dist/css/compile.js +77 -0
- package/dist/css/graph.js +109 -0
- package/dist/css/inline.js +132 -0
- package/dist/css/rules.js +65 -0
- package/dist/design-system/format-variants.js +127 -0
- package/dist/eslint/authoring.js +46 -0
- package/dist/eslint/correctness.js +42 -0
- package/dist/eslint/rules/editor-declaration.js +103 -0
- package/dist/eslint/rules/editor-reason.js +135 -0
- package/dist/eslint/rules/island-imports.js +20 -0
- package/dist/eslint/rules/jsx-visitor.js +20 -0
- package/dist/eslint/rules/no-client-runtime.js +88 -0
- package/dist/eslint/rules/no-editor-globals.js +60 -0
- package/dist/eslint/rules/no-hard-coded-color.js +183 -0
- package/dist/eslint/rules/no-inline-style.js +24 -0
- package/dist/eslint/rules/no-marker-literal.js +37 -0
- package/dist/eslint/rules/no-nondeterminism.js +44 -0
- package/dist/eslint/rules/no-px-breakpoint.js +44 -0
- package/dist/eslint/rules/no-raw-values.js +45 -0
- package/dist/eslint/rules/serializable-props.js +95 -0
- package/dist/eslint.d.ts +6 -0
- package/dist/eslint.js +26 -0
- package/dist/fixtures/brand.d.ts +4 -0
- package/dist/fixtures/brand.js +9 -0
- package/dist/fixtures/bundle-rule.js +67 -0
- package/dist/fixtures/canonical.d.ts +149 -0
- package/dist/fixtures/image-dimensions.js +59 -0
- package/dist/fixtures/load.js +154 -0
- package/dist/fixtures/media-plugin.js +141 -0
- package/dist/fixtures/media.js +165 -0
- package/dist/fixtures/property.js +210 -0
- package/dist/fixtures/resolve.js +202 -0
- package/dist/fixtures/rows.js +108 -0
- package/dist/fixtures/synthesize-empties.js +42 -0
- package/dist/fixtures.d.ts +213 -0
- package/dist/fixtures.js +37 -0
- package/dist/index.d.ts +53 -0
- package/dist/index.js +37 -0
- package/dist/islands/client-module.js +97 -0
- package/dist/islands/marker.d.ts +43 -0
- package/dist/islands/marker.js +44 -0
- package/dist/node_modules/.pnpm/fflate@0.8.3/node_modules/fflate/esm/browser.js +687 -0
- package/dist/packages/external/concrete/package.js +5 -0
- package/dist/packages/internal/fact-interpolation/dist/index.js +22 -0
- package/dist/packages/internal/fill-bake/dist/bake-property-ref.js +111 -0
- package/dist/packages/internal/fill-bake/dist/display.js +9 -0
- package/dist/packages/internal/fill-bake/dist/index.js +6 -0
- package/dist/packages/internal/fill-bake/dist/reconcile-cross-section.js +170 -0
- package/dist/packages/internal/fill-vocabulary/dist/facts.d.ts +32 -0
- package/dist/packages/internal/fill-vocabulary/dist/facts.js +131 -0
- package/dist/packages/internal/fill-vocabulary/dist/row-planners.js +73 -0
- package/dist/packages/internal/format-geometry/dist/capture.js +404 -0
- package/dist/packages/internal/format-geometry/dist/format.d.ts +41 -0
- package/dist/packages/internal/format-geometry/dist/geometry.js +58 -0
- package/dist/packages/internal/format-geometry/dist/index.js +4 -0
- package/dist/packages/internal/image-descriptor/dist/index.d.ts +35 -0
- package/dist/packages/internal/image-ladder/dist/crop.js +82 -0
- package/dist/packages/internal/image-ladder/dist/encode.js +23 -0
- package/dist/packages/internal/image-ladder/dist/index.js +4 -0
- package/dist/packages/internal/image-ladder/dist/policy.js +102 -0
- package/dist/packages/internal/island-runtime/dist/capture-holds.d.ts +13 -0
- package/dist/packages/internal/island-runtime/dist/capture-holds.js +45 -0
- package/dist/packages/internal/island-runtime/dist/contract.d.ts +176 -0
- package/dist/packages/internal/island-runtime/dist/contract.js +94 -0
- package/dist/packages/internal/island-runtime/dist/editor-instance-context.js +15 -0
- package/dist/packages/internal/island-runtime/dist/index.d.ts +103 -0
- package/dist/packages/internal/island-runtime/dist/index.js +163 -0
- package/dist/packages/internal/island-runtime/dist/use-capture-ready.d.ts +19 -0
- package/dist/packages/internal/island-runtime/dist/use-capture-ready.js +39 -0
- package/dist/packages/internal/island-runtime/dist/use-editor.d.ts +22 -0
- package/dist/packages/internal/island-runtime/dist/use-editor.js +54 -0
- package/dist/packages/internal/island-runtime/dist/viewport-schedule.js +105 -0
- package/dist/packages/internal/property-facts/dist/derive-facts-view.js +25 -0
- package/dist/packages/internal/property-facts/dist/index.js +3 -0
- package/dist/packages/internal/property-facts/dist/property-facts-CSdkSuD7.js +181 -0
- package/dist/packages/internal/section-contracts/dist/cap-contract.js +59 -0
- package/dist/packages/internal/section-contracts/dist/catalog.js +102 -0
- package/dist/packages/internal/section-contracts/dist/choose-select-contract.js +24 -0
- package/dist/packages/internal/section-contracts/dist/count-bounds-contract.js +48 -0
- package/dist/packages/internal/section-contracts/dist/display-contract.js +30 -0
- package/dist/packages/internal/section-contracts/dist/display-evidence-contract.js +17 -0
- package/dist/packages/internal/section-contracts/dist/group-contract.js +21 -0
- package/dist/packages/internal/section-contracts/dist/index.js +26 -0
- package/dist/packages/internal/section-contracts/dist/interpolation-contract.js +48 -0
- package/dist/packages/internal/section-contracts/dist/list-fill-contract.js +53 -0
- package/dist/packages/internal/section-contracts/dist/list-scalar-contract.js +70 -0
- package/dist/packages/internal/section-contracts/dist/name-title-contract.js +27 -0
- package/dist/packages/internal/section-contracts/dist/nested-slot-contract.js +12 -0
- package/dist/packages/internal/section-contracts/dist/option-source-contract.js +22 -0
- package/dist/packages/internal/section-contracts/dist/poi-curation-contract.js +18 -0
- package/dist/packages/internal/section-contracts/dist/pooling-field-contract.js +30 -0
- package/dist/packages/internal/section-contracts/dist/record-collection-contract.js +24 -0
- package/dist/packages/internal/section-contracts/dist/row-contract.js +37 -0
- package/dist/packages/internal/section-contracts/dist/row-fill-contract.js +38 -0
- package/dist/packages/internal/section-contracts/dist/runners.js +181 -0
- package/dist/packages/internal/section-contracts/dist/select-contract.js +28 -0
- package/dist/packages/internal/section-contracts/dist/source-contract.js +48 -0
- package/dist/packages/internal/section-contracts/dist/source-filter-contract.js +15 -0
- package/dist/packages/internal/section-contracts/dist/sources-contract.js +28 -0
- package/dist/packages/internal/section-contracts/dist/url-contract.js +20 -0
- package/dist/packages/internal/source-resolution/dist/index.js +222 -0
- package/dist/packages/internal/template-artifact/dist/hash.js +50 -0
- package/dist/packages/internal/template-artifact/dist/index.js +7 -0
- package/dist/packages/internal/template-artifact/dist/layout.js +165 -0
- package/dist/packages/internal/template-artifact/dist/manifest.js +73 -0
- package/dist/packages/internal/template-artifact/dist/sha256.js +138 -0
- package/dist/packages/internal/template-artifact/dist/verify.js +275 -0
- package/dist/packages/internal/template-contracts/dist/collection-editing.js +38 -0
- package/dist/packages/internal/template-contracts/dist/content-categories.d.ts +10 -0
- package/dist/packages/internal/template-contracts/dist/content-categories.js +17 -0
- package/dist/packages/internal/template-contracts/dist/document-value.d.ts +33 -0
- package/dist/packages/internal/template-contracts/dist/facts-view.d.ts +81 -0
- package/dist/packages/internal/template-contracts/dist/facts-view.js +136 -0
- package/dist/packages/internal/template-contracts/dist/layout.js +17 -0
- package/dist/packages/internal/template-contracts/dist/markers.d.ts +40 -0
- package/dist/packages/internal/template-contracts/dist/markers.js +41 -0
- package/dist/packages/internal/template-contracts/dist/poi-row.d.ts +63 -0
- package/dist/packages/internal/template-contracts/dist/select-key.js +13 -0
- package/dist/packages/internal/template-contracts/dist/slot-catalog.d.ts +1112 -0
- package/dist/packages/internal/template-contracts/dist/slot-catalog.js +1109 -0
- package/dist/packages/internal/template-contracts/dist/slot-overrides.js +11 -0
- package/dist/packages/internal/template-contracts/dist/tour-value.d.ts +45 -0
- package/dist/packages/internal/template-contracts/dist/video-value.d.ts +63 -0
- package/dist/playground/host/page-state.js +12 -0
- package/dist/playground/host/paths.js +9 -0
- package/dist/playground/layout.js +24 -0
- package/dist/playground/wire.js +36 -0
- package/dist/playground-island-runtime.d.ts +3 -0
- package/dist/playground-island-runtime.js +4 -0
- package/dist/primitives/FrameShell.d.ts +29 -0
- package/dist/primitives/FrameShell.js +34 -0
- package/dist/primitives/Image.d.ts +119 -0
- package/dist/primitives/Image.js +173 -0
- package/dist/primitives/Section.d.ts +22 -0
- package/dist/primitives/Section.js +26 -0
- package/dist/primitives/Tour.d.ts +43 -0
- package/dist/primitives/Tour.js +72 -0
- package/dist/primitives/Video.d.ts +57 -0
- package/dist/primitives/Video.js +116 -0
- package/dist/primitives/embed-playback.js +50 -0
- package/dist/primitives/index.d.ts +11 -0
- package/dist/primitives/marker-attrs.js +44 -0
- package/dist/primitives/object-fit.js +11 -0
- package/dist/primitives/picture-sources.d.ts +24 -0
- package/dist/primitives/picture-sources.js +52 -0
- package/dist/primitives/probe-context.js +24 -0
- package/dist/primitives/slot-bindings.d.ts +96 -0
- package/dist/primitives/slot-bindings.js +226 -0
- package/dist/primitives/slot-document.d.ts +35 -0
- package/dist/primitives/slot-document.js +37 -0
- package/dist/primitives/slot-group.d.ts +40 -0
- package/dist/primitives/slot-group.js +45 -0
- package/dist/primitives/slot-list.d.ts +21 -0
- package/dist/primitives/slot-list.js +23 -0
- package/dist/primitives/slot-media.d.ts +71 -0
- package/dist/primitives/slot-media.js +98 -0
- package/dist/primitives/slot-scalar.d.ts +53 -0
- package/dist/primitives/slot-scalar.js +98 -0
- package/dist/primitives/slot.d.ts +26 -0
- package/dist/primitives/slot.js +28 -0
- package/dist/rules/registry.js +479 -0
- package/dist/schema/compute.d.ts +22 -0
- package/dist/schema/compute.js +30 -0
- package/dist/schema/define-schema.d.ts +27 -0
- package/dist/schema/define-schema.js +73 -0
- package/dist/schema/extract-fill-spec.js +246 -0
- package/dist/schema/extract-used-facts.js +176 -0
- package/dist/schema/fact.d.ts +65 -0
- package/dist/schema/fact.js +33 -0
- package/dist/schema/fill-builders.d.ts +387 -0
- package/dist/schema/fill-builders.js +263 -0
- package/dist/schema/fill-declaration.d.ts +76 -0
- package/dist/schema/fill-declaration.js +43 -0
- package/dist/schema/fill-spec.d.ts +18 -0
- package/dist/schema/fill-spec.js +170 -0
- package/dist/schema/format-presets.d.ts +27 -0
- package/dist/schema/format-presets.js +76 -0
- package/dist/schema/format.d.ts +22 -0
- package/dist/schema/format.js +40 -0
- package/dist/schema/formats.d.ts +6 -0
- package/dist/schema/formats.js +7 -0
- package/dist/schema/layout.d.ts +32 -0
- package/dist/schema/layout.js +30 -0
- package/dist/schema/manifest.js +300 -0
- package/dist/schema/property-facts.d.ts +83 -0
- package/dist/schema/runtime-values.d.ts +88 -0
- package/dist/schema/section-nav.d.ts +38 -0
- package/dist/schema/section-nav.js +29 -0
- package/dist/schema/section-props.d.ts +98 -0
- package/dist/schema/section-schema.d.ts +53 -0
- package/dist/schema/section-schema.js +54 -0
- package/dist/schema/slot-builders.d.ts +497 -0
- package/dist/schema/slot-builders.js +331 -0
- package/dist/schema/slot-types.d.ts +110 -0
- package/dist/schema/slot-types.js +187 -0
- package/dist/section/declare.d.ts +44 -0
- package/dist/section/declare.js +27 -0
- package/dist/section/discovery.js +76 -0
- package/dist/section/groups.js +74 -0
- package/dist/section/materialize.js +28 -0
- package/dist/section/placements.js +28 -0
- package/dist/section/section.d.ts +69 -0
- package/dist/section/section.js +101 -0
- package/dist/site-analytics.d.ts +1 -0
- package/dist/site-analytics.js +15 -0
- package/dist/site-runtime/analytics.js +97 -0
- package/dist/site-runtime/site-integrations.js +97 -0
- package/dist/styles.css +60 -0
- package/dist/template/define-template.d.ts +139 -0
- package/dist/template/define-template.js +98 -0
- package/dist/template/logic-build.js +191 -0
- package/dist/template/logic-shim.d.ts +43 -0
- package/dist/template/logic-shim.js +52 -0
- package/dist/template/logic-transform.js +92 -0
- package/dist/template/materialize.js +107 -0
- package/dist/template/reconcile.d.ts +67 -0
- package/dist/template/reconcile.js +25 -0
- package/dist/template/running-copy.js +58 -0
- package/guide/reference/cli/INDEX.md +79 -0
- package/guide/reference/cli/build.md +48 -0
- package/guide/reference/cli/check.md +49 -0
- package/guide/reference/cli/dev.md +46 -0
- package/guide/reference/cli/property-add.md +53 -0
- package/guide/reference/cli/property-list.md +46 -0
- package/guide/reference/cli/publish.md +54 -0
- package/guide/reference/cli/upgrade.md +48 -0
- package/guide/reference/rules/INDEX.md +190 -0
- package/package.json +137 -0
- package/tsconfig.base.json +16 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
//#region ../../internal/template-artifact/dist/layout.js
|
|
2
|
+
const MANIFEST_FILE = "manifest.json";
|
|
3
|
+
const SECTIONS_DIR = "sections";
|
|
4
|
+
const TEMPLATE_DIR = "template";
|
|
5
|
+
const STATIC_DIR = "static";
|
|
6
|
+
const ASSETS_DIR = "assets";
|
|
7
|
+
const SECTION_ISLANDS_DIR = "islands";
|
|
8
|
+
const PLAYGROUND_DIR = "playground";
|
|
9
|
+
const PLAYGROUND_CLIENT_DIR = "client";
|
|
10
|
+
const FIXTURES_DIR = "fixtures";
|
|
11
|
+
const CAPTURES_DIR = "captures";
|
|
12
|
+
/** The top-level directories outside every content hash. */
|
|
13
|
+
const UNHASHED_DIRS = [
|
|
14
|
+
FIXTURES_DIR,
|
|
15
|
+
PLAYGROUND_DIR,
|
|
16
|
+
CAPTURES_DIR
|
|
17
|
+
];
|
|
18
|
+
/** Every file a fixture directory carries. */
|
|
19
|
+
const FIXTURE_FILES = {
|
|
20
|
+
contentDoc: "content-doc.json",
|
|
21
|
+
property: "property.json",
|
|
22
|
+
meta: "meta.json"
|
|
23
|
+
};
|
|
24
|
+
/** The capture files that are not a page's PNG. */
|
|
25
|
+
const CAPTURE_FILES = {
|
|
26
|
+
bundle: "bundle.zip",
|
|
27
|
+
document: "document.pdf"
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* The URL prefix an artifact's author assets are named under wherever bytes or data name
|
|
31
|
+
* them — a renderer bundle's image, a fixture's media file — each `<prefix>/<filename>`
|
|
32
|
+
* naming `assets/<filename>`. The platform serves it from the same store.
|
|
33
|
+
*/
|
|
34
|
+
const ASSET_URL_PREFIX = "/section-assets/";
|
|
35
|
+
/**
|
|
36
|
+
* The playground's loader contract: the module a reader imports, the one export it
|
|
37
|
+
* calls, and the client shell it serves with its `<base href>` stamped. A change to any
|
|
38
|
+
* of these is a new `artifact_schema`.
|
|
39
|
+
*/
|
|
40
|
+
const PLAYGROUND_FILES = {
|
|
41
|
+
host: "host.mjs",
|
|
42
|
+
clientShell: `${PLAYGROUND_CLIENT_DIR}/index.html`
|
|
43
|
+
};
|
|
44
|
+
/** A file inside the playground directory, by its path below it. */
|
|
45
|
+
function playgroundPath(file) {
|
|
46
|
+
return `${PLAYGROUND_DIR}/${file}`;
|
|
47
|
+
}
|
|
48
|
+
/** Every file a section directory carries besides its island chunks. */
|
|
49
|
+
const SECTION_FILES = {
|
|
50
|
+
schema: "schema.json",
|
|
51
|
+
fillSpec: "fill-spec.json",
|
|
52
|
+
usedFacts: "used-facts.json",
|
|
53
|
+
logic: "logic.mjs",
|
|
54
|
+
renderer: "renderer.mjs"
|
|
55
|
+
};
|
|
56
|
+
/** Every file the template directory carries. */
|
|
57
|
+
const TEMPLATE_FILES = {
|
|
58
|
+
composition: "composition.json",
|
|
59
|
+
logic: "logic.mjs",
|
|
60
|
+
usedFacts: "used-facts.json",
|
|
61
|
+
stylesheet: "template.css",
|
|
62
|
+
preview: "preview.json",
|
|
63
|
+
staticAssets: "static-assets.json"
|
|
64
|
+
};
|
|
65
|
+
const SEGMENT = /^(?!\.{1,2}$)[A-Za-z0-9._-]+$/;
|
|
66
|
+
/** Whether `key` is a template key the layout can place: one safe path segment. */
|
|
67
|
+
function isTemplateKey(key) {
|
|
68
|
+
return SEGMENT.test(key);
|
|
69
|
+
}
|
|
70
|
+
/** Whether `key` is a published section key: `<template>/<section>`, two safe segments. */
|
|
71
|
+
function isSectionKey(key) {
|
|
72
|
+
const parts = key.split("/");
|
|
73
|
+
return parts.length === 2 && parts.every((part) => SEGMENT.test(part));
|
|
74
|
+
}
|
|
75
|
+
/** The published key of a section a template declares under `local`. */
|
|
76
|
+
function publishedSectionKey(templateKey, local) {
|
|
77
|
+
return `${templateKey}/${local}`;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* One capture file of one fixture at one format: `captures/<fixture>/<format>/<file>`,
|
|
81
|
+
* the file a {@link CAPTURE_FILES} name or `<page>.png`. Throws unless every part is one
|
|
82
|
+
* safe path segment, so no fixture or format id can place a file elsewhere.
|
|
83
|
+
*/
|
|
84
|
+
function capturePath(fixture, format, file) {
|
|
85
|
+
for (const segment of [
|
|
86
|
+
fixture,
|
|
87
|
+
format,
|
|
88
|
+
file
|
|
89
|
+
]) if (!SEGMENT.test(segment)) throw new Error(`"${segment}" cannot name a capture path: one path segment of letters, digits, ".", "_" and "-".`);
|
|
90
|
+
return `${CAPTURES_DIR}/${fixture}/${format}/${file}`;
|
|
91
|
+
}
|
|
92
|
+
/** Whether `id` is a fixture id the layout can place: one safe path segment. */
|
|
93
|
+
function isFixtureId(id) {
|
|
94
|
+
return SEGMENT.test(id);
|
|
95
|
+
}
|
|
96
|
+
/** A file inside a fixture's directory. */
|
|
97
|
+
function fixturePath(id, file) {
|
|
98
|
+
return `${FIXTURES_DIR}/${id}/${file}`;
|
|
99
|
+
}
|
|
100
|
+
/** `sections/<key>`. */
|
|
101
|
+
function sectionDir(key) {
|
|
102
|
+
return `${SECTIONS_DIR}/${key}`;
|
|
103
|
+
}
|
|
104
|
+
/** A file inside a section directory. */
|
|
105
|
+
function sectionPath(key, file) {
|
|
106
|
+
return `${sectionDir(key)}/${file}`;
|
|
107
|
+
}
|
|
108
|
+
/** A file inside the template directory. */
|
|
109
|
+
function templatePath(file) {
|
|
110
|
+
return `${TEMPLATE_DIR}/${file}`;
|
|
111
|
+
}
|
|
112
|
+
/** An island chunk of a section, by the filename the binding names it by. */
|
|
113
|
+
function islandPath(sectionKey, filename) {
|
|
114
|
+
return sectionPath(sectionKey, `${SECTION_ISLANDS_DIR}/${filename}`);
|
|
115
|
+
}
|
|
116
|
+
/** The section an island key belongs to: everything before its last `:`. */
|
|
117
|
+
function sectionOfIslandKey(islandKey) {
|
|
118
|
+
const at = islandKey.lastIndexOf(":");
|
|
119
|
+
return at < 0 ? islandKey : islandKey.slice(0, at);
|
|
120
|
+
}
|
|
121
|
+
/** A shared static bundle. */
|
|
122
|
+
function staticPath(filename) {
|
|
123
|
+
return `${STATIC_DIR}/${filename}`;
|
|
124
|
+
}
|
|
125
|
+
/** A content-addressed asset. */
|
|
126
|
+
function assetPath(filename) {
|
|
127
|
+
return `${ASSETS_DIR}/${filename}`;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Where every file a static-assets binding names lives in the artifact. A reader
|
|
131
|
+
* uploads each one under its binding filename; the verifier checks each is present
|
|
132
|
+
* and, where the binding states a hash, that the bytes match it.
|
|
133
|
+
*/
|
|
134
|
+
function boundFiles(binding) {
|
|
135
|
+
const out = [];
|
|
136
|
+
const ref = (path, r) => {
|
|
137
|
+
out.push({
|
|
138
|
+
path,
|
|
139
|
+
filename: r.filename,
|
|
140
|
+
contentHash: r.content_hash
|
|
141
|
+
});
|
|
142
|
+
};
|
|
143
|
+
ref(staticPath(binding.base_css.filename), binding.base_css);
|
|
144
|
+
ref(templatePath(TEMPLATE_FILES.stylesheet), binding.template_css);
|
|
145
|
+
for (const [key, island] of Object.entries(binding.islands)) ref(islandPath(sectionOfIslandKey(key), island.filename), island);
|
|
146
|
+
if (binding.island_runtime !== null) ref(staticPath(binding.island_runtime.filename), binding.island_runtime);
|
|
147
|
+
for (const facade of Object.values(binding.react_vendor ?? {})) ref(staticPath(facade.filename), facade);
|
|
148
|
+
if (binding.react_vendor_core !== null) ref(staticPath(binding.react_vendor_core.filename), binding.react_vendor_core);
|
|
149
|
+
if (binding.analytics !== null) ref(staticPath(binding.analytics.filename), binding.analytics);
|
|
150
|
+
for (const filename of Object.values(binding.masters ?? {})) out.push({
|
|
151
|
+
path: assetPath(filename),
|
|
152
|
+
filename
|
|
153
|
+
});
|
|
154
|
+
if (binding.icons !== void 0) {
|
|
155
|
+
const { ico, svg, png, apple_touch } = binding.icons;
|
|
156
|
+
ref(assetPath(ico.filename), ico);
|
|
157
|
+
if (svg !== null) ref(assetPath(svg.filename), svg);
|
|
158
|
+
for (const size of Object.values(png)) ref(assetPath(size.filename), size);
|
|
159
|
+
ref(assetPath(apple_touch.filename), apple_touch);
|
|
160
|
+
}
|
|
161
|
+
return out;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
//#endregion
|
|
165
|
+
export { ASSETS_DIR, ASSET_URL_PREFIX, CAPTURES_DIR, CAPTURE_FILES, FIXTURES_DIR, FIXTURE_FILES, MANIFEST_FILE, PLAYGROUND_CLIENT_DIR, PLAYGROUND_DIR, PLAYGROUND_FILES, SECTIONS_DIR, SECTION_FILES, SECTION_ISLANDS_DIR, STATIC_DIR, TEMPLATE_DIR, TEMPLATE_FILES, UNHASHED_DIRS, assetPath, boundFiles, capturePath, fixturePath, isFixtureId, isSectionKey, isTemplateKey, islandPath, playgroundPath, publishedSectionKey, sectionDir, sectionOfIslandKey, sectionPath, staticPath, templatePath };
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { isFixtureId, isSectionKey, isTemplateKey } from "./layout.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
|
|
4
|
+
//#region ../../internal/template-artifact/dist/manifest.js
|
|
5
|
+
const Sha256 = z.string().regex(/^[0-9a-f]{64}$/, "a lowercase hex SHA-256");
|
|
6
|
+
const OrgId = z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/, "an org UUID");
|
|
7
|
+
/** Who the template is offered to, as authored: every org, or the named set. */
|
|
8
|
+
const ArtifactScope = z.union([z.literal("global"), z.object({ orgs: z.array(OrgId).min(1) }).strict()]);
|
|
9
|
+
const ArtifactSection = z.object({
|
|
10
|
+
key: z.string().refine(isSectionKey, "a section key `<template>/<section>`"),
|
|
11
|
+
display_name: z.string().min(1),
|
|
12
|
+
content_hash: Sha256
|
|
13
|
+
}).strict();
|
|
14
|
+
const ArtifactManifest = z.object({
|
|
15
|
+
artifact_schema: z.literal(1),
|
|
16
|
+
framework_version: z.string().min(1),
|
|
17
|
+
key: z.string().refine(isTemplateKey, "a template key: one path segment"),
|
|
18
|
+
display_name: z.string().min(1),
|
|
19
|
+
deliverable_type: z.enum([
|
|
20
|
+
"website",
|
|
21
|
+
"image",
|
|
22
|
+
"document"
|
|
23
|
+
]),
|
|
24
|
+
scope: ArtifactScope,
|
|
25
|
+
source_digest: Sha256,
|
|
26
|
+
template: z.object({ content_hash: Sha256 }).strict(),
|
|
27
|
+
/** Sorted by key. */
|
|
28
|
+
sections: z.array(ArtifactSection),
|
|
29
|
+
/** The authored fixtures under `fixtures/`, in discovery order: the first is the one a playground opens. */
|
|
30
|
+
fixtures: z.array(z.string().refine(isFixtureId, "a fixture id: one path segment"))
|
|
31
|
+
}).strict().superRefine((manifest, ctx) => {
|
|
32
|
+
manifest.fixtures.forEach((id, index) => {
|
|
33
|
+
if (manifest.fixtures.indexOf(id) !== index) ctx.addIssue({
|
|
34
|
+
code: "custom",
|
|
35
|
+
path: ["fixtures", index],
|
|
36
|
+
message: `fixture "${id}" is listed twice`
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
manifest.sections.forEach((section, index) => {
|
|
40
|
+
if (!section.key.startsWith(`${manifest.key}/`)) ctx.addIssue({
|
|
41
|
+
code: "custom",
|
|
42
|
+
path: [
|
|
43
|
+
"sections",
|
|
44
|
+
index,
|
|
45
|
+
"key"
|
|
46
|
+
],
|
|
47
|
+
message: `section "${section.key}" is not namespaced under "${manifest.key}/"`
|
|
48
|
+
});
|
|
49
|
+
const previous = manifest.sections[index - 1];
|
|
50
|
+
if (previous !== void 0 && previous.key >= section.key) ctx.addIssue({
|
|
51
|
+
code: "custom",
|
|
52
|
+
path: [
|
|
53
|
+
"sections",
|
|
54
|
+
index,
|
|
55
|
+
"key"
|
|
56
|
+
],
|
|
57
|
+
message: `sections must be sorted by key with no repeat; "${section.key}" follows "${previous.key}"`
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
/**
|
|
62
|
+
* The schema number a manifest claims, read before anything else is parsed, so a
|
|
63
|
+
* reader can refuse an artifact from a newer shape by name rather than by a wall of
|
|
64
|
+
* field errors. `null` when the value carries no integer `artifact_schema`.
|
|
65
|
+
*/
|
|
66
|
+
function readArtifactSchema(value) {
|
|
67
|
+
if (typeof value !== "object" || value === null) return null;
|
|
68
|
+
const schema = value.artifact_schema;
|
|
69
|
+
return typeof schema === "number" && Number.isInteger(schema) ? schema : null;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
//#endregion
|
|
73
|
+
export { ArtifactManifest, ArtifactScope, ArtifactSection, readArtifactSchema };
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
//#region ../../internal/template-artifact/dist/sha256.js
|
|
2
|
+
const K = new Uint32Array([
|
|
3
|
+
1116352408,
|
|
4
|
+
1899447441,
|
|
5
|
+
3049323471,
|
|
6
|
+
3921009573,
|
|
7
|
+
961987163,
|
|
8
|
+
1508970993,
|
|
9
|
+
2453635748,
|
|
10
|
+
2870763221,
|
|
11
|
+
3624381080,
|
|
12
|
+
310598401,
|
|
13
|
+
607225278,
|
|
14
|
+
1426881987,
|
|
15
|
+
1925078388,
|
|
16
|
+
2162078206,
|
|
17
|
+
2614888103,
|
|
18
|
+
3248222580,
|
|
19
|
+
3835390401,
|
|
20
|
+
4022224774,
|
|
21
|
+
264347078,
|
|
22
|
+
604807628,
|
|
23
|
+
770255983,
|
|
24
|
+
1249150122,
|
|
25
|
+
1555081692,
|
|
26
|
+
1996064986,
|
|
27
|
+
2554220882,
|
|
28
|
+
2821834349,
|
|
29
|
+
2952996808,
|
|
30
|
+
3210313671,
|
|
31
|
+
3336571891,
|
|
32
|
+
3584528711,
|
|
33
|
+
113926993,
|
|
34
|
+
338241895,
|
|
35
|
+
666307205,
|
|
36
|
+
773529912,
|
|
37
|
+
1294757372,
|
|
38
|
+
1396182291,
|
|
39
|
+
1695183700,
|
|
40
|
+
1986661051,
|
|
41
|
+
2177026350,
|
|
42
|
+
2456956037,
|
|
43
|
+
2730485921,
|
|
44
|
+
2820302411,
|
|
45
|
+
3259730800,
|
|
46
|
+
3345764771,
|
|
47
|
+
3516065817,
|
|
48
|
+
3600352804,
|
|
49
|
+
4094571909,
|
|
50
|
+
275423344,
|
|
51
|
+
430227734,
|
|
52
|
+
506948616,
|
|
53
|
+
659060556,
|
|
54
|
+
883997877,
|
|
55
|
+
958139571,
|
|
56
|
+
1322822218,
|
|
57
|
+
1537002063,
|
|
58
|
+
1747873779,
|
|
59
|
+
1955562222,
|
|
60
|
+
2024104815,
|
|
61
|
+
2227730452,
|
|
62
|
+
2361852424,
|
|
63
|
+
2428436474,
|
|
64
|
+
2756734187,
|
|
65
|
+
3204031479,
|
|
66
|
+
3329325298
|
|
67
|
+
]);
|
|
68
|
+
const HEX = Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
|
|
69
|
+
/** The lowercase hex SHA-256 of `bytes`. */
|
|
70
|
+
function sha256Hex(bytes) {
|
|
71
|
+
const h = new Uint32Array([
|
|
72
|
+
1779033703,
|
|
73
|
+
3144134277,
|
|
74
|
+
1013904242,
|
|
75
|
+
2773480762,
|
|
76
|
+
1359893119,
|
|
77
|
+
2600822924,
|
|
78
|
+
528734635,
|
|
79
|
+
1541459225
|
|
80
|
+
]);
|
|
81
|
+
const length = bytes.length;
|
|
82
|
+
const padded = new Uint8Array(length + 9 + 63 >>> 6 << 6);
|
|
83
|
+
padded.set(bytes);
|
|
84
|
+
padded[length] = 128;
|
|
85
|
+
const view = new DataView(padded.buffer);
|
|
86
|
+
const bits = length * 8;
|
|
87
|
+
view.setUint32(padded.length - 8, Math.floor(bits / 4294967296));
|
|
88
|
+
view.setUint32(padded.length - 4, bits >>> 0);
|
|
89
|
+
const w = /* @__PURE__ */ new Uint32Array(64);
|
|
90
|
+
for (let offset = 0; offset < padded.length; offset += 64) {
|
|
91
|
+
for (let t = 0; t < 16; t++) w[t] = view.getUint32(offset + t * 4);
|
|
92
|
+
for (let t = 16; t < 64; t++) {
|
|
93
|
+
const w15 = w[t - 15];
|
|
94
|
+
const w2 = w[t - 2];
|
|
95
|
+
const s0 = (w15 >>> 7 | w15 << 25) ^ (w15 >>> 18 | w15 << 14) ^ w15 >>> 3;
|
|
96
|
+
w[t] = ((w2 >>> 17 | w2 << 15) ^ (w2 >>> 19 | w2 << 13) ^ w2 >>> 10) + w[t - 7] + s0 + w[t - 16] | 0;
|
|
97
|
+
}
|
|
98
|
+
let a = h[0];
|
|
99
|
+
let b = h[1];
|
|
100
|
+
let c = h[2];
|
|
101
|
+
let d = h[3];
|
|
102
|
+
let e = h[4];
|
|
103
|
+
let f = h[5];
|
|
104
|
+
let g = h[6];
|
|
105
|
+
let hh = h[7];
|
|
106
|
+
for (let t = 0; t < 64; t++) {
|
|
107
|
+
const s1 = (e >>> 6 | e << 26) ^ (e >>> 11 | e << 21) ^ (e >>> 25 | e << 7);
|
|
108
|
+
const ch = e & f ^ ~e & g;
|
|
109
|
+
const t1 = hh + s1 + ch + K[t] + w[t] | 0;
|
|
110
|
+
const t2 = ((a >>> 2 | a << 30) ^ (a >>> 13 | a << 19) ^ (a >>> 22 | a << 10)) + (a & b ^ a & c ^ b & c) | 0;
|
|
111
|
+
hh = g;
|
|
112
|
+
g = f;
|
|
113
|
+
f = e;
|
|
114
|
+
e = d + t1 | 0;
|
|
115
|
+
d = c;
|
|
116
|
+
c = b;
|
|
117
|
+
b = a;
|
|
118
|
+
a = t1 + t2 | 0;
|
|
119
|
+
}
|
|
120
|
+
h[0] = h[0] + a | 0;
|
|
121
|
+
h[1] = h[1] + b | 0;
|
|
122
|
+
h[2] = h[2] + c | 0;
|
|
123
|
+
h[3] = h[3] + d | 0;
|
|
124
|
+
h[4] = h[4] + e | 0;
|
|
125
|
+
h[5] = h[5] + f | 0;
|
|
126
|
+
h[6] = h[6] + g | 0;
|
|
127
|
+
h[7] = h[7] + hh | 0;
|
|
128
|
+
}
|
|
129
|
+
let out = "";
|
|
130
|
+
for (let i = 0; i < 8; i++) {
|
|
131
|
+
const word = h[i];
|
|
132
|
+
out += HEX[word >>> 24] + HEX[word >>> 16 & 255] + HEX[word >>> 8 & 255] + HEX[word & 255];
|
|
133
|
+
}
|
|
134
|
+
return out;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
//#endregion
|
|
138
|
+
export { sha256Hex };
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
import { ASSETS_DIR, ASSET_URL_PREFIX, FIXTURES_DIR, FIXTURE_FILES, MANIFEST_FILE, PLAYGROUND_CLIENT_DIR, PLAYGROUND_DIR, PLAYGROUND_FILES, SECTIONS_DIR, SECTION_FILES, SECTION_ISLANDS_DIR, STATIC_DIR, TEMPLATE_DIR, TEMPLATE_FILES, UNHASHED_DIRS, boundFiles, fixturePath, playgroundPath, sectionPath, templatePath } from "./layout.js";
|
|
2
|
+
import { sha256Hex } from "./sha256.js";
|
|
3
|
+
import { sectionContentHash, templateContentHash } from "./hash.js";
|
|
4
|
+
import { ArtifactManifest, readArtifactSchema } from "./manifest.js";
|
|
5
|
+
|
|
6
|
+
//#region ../../internal/template-artifact/dist/verify.js
|
|
7
|
+
const decoder = new TextDecoder("utf-8", { fatal: true });
|
|
8
|
+
const SECTION_FILE_NAMES = new Set(Object.values(SECTION_FILES));
|
|
9
|
+
const TEMPLATE_FILE_NAMES = new Set(Object.values(TEMPLATE_FILES));
|
|
10
|
+
const ISLAND_CHUNK = new RegExp(`^${SECTION_ISLANDS_DIR}/[A-Za-z0-9._-]+\\.mjs$`);
|
|
11
|
+
const FLAT_FILE = /^[A-Za-z0-9._-]+$/;
|
|
12
|
+
const CLIENT_SEGMENT = /^(?!\.{1,2}$)[A-Za-z0-9._-]+$/;
|
|
13
|
+
const FIXTURE_FILE_NAMES = new Set(Object.values(FIXTURE_FILES));
|
|
14
|
+
const ASSET_URL = new RegExp(`${ASSET_URL_PREFIX.replace(/[.*+?^${}()|[\]\\/]/g, "\\$&")}([A-Za-z0-9._-]+)`, "g");
|
|
15
|
+
function readJson(files, path, problems) {
|
|
16
|
+
const bytes = files.get(path);
|
|
17
|
+
if (bytes === void 0) {
|
|
18
|
+
problems.push({
|
|
19
|
+
path,
|
|
20
|
+
message: "missing"
|
|
21
|
+
});
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
try {
|
|
25
|
+
return { value: JSON.parse(decoder.decode(bytes)) };
|
|
26
|
+
} catch (cause) {
|
|
27
|
+
problems.push({
|
|
28
|
+
path,
|
|
29
|
+
message: `not valid UTF-8 JSON: ${cause instanceof Error ? cause.message : String(cause)}`
|
|
30
|
+
});
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function checkUsedFacts(value, path, problems) {
|
|
35
|
+
if (!Array.isArray(value) || !value.every((entry) => typeof entry === "string")) {
|
|
36
|
+
problems.push({
|
|
37
|
+
path,
|
|
38
|
+
message: "used facts must be an array of fact keys, never null"
|
|
39
|
+
});
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
for (let i = 1; i < value.length; i++) if (value[i - 1] >= value[i]) {
|
|
43
|
+
problems.push({
|
|
44
|
+
path,
|
|
45
|
+
message: `used facts must be sorted with no repeat; "${value[i]}" follows "${value[i - 1]}"`
|
|
46
|
+
});
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/** The section keys a composition's pages place, read structurally. */
|
|
51
|
+
function composedSections(composition) {
|
|
52
|
+
const pages = composition?.pages;
|
|
53
|
+
if (!Array.isArray(pages)) return null;
|
|
54
|
+
const keys = /* @__PURE__ */ new Set();
|
|
55
|
+
for (const page of pages) {
|
|
56
|
+
const sections = page?.sections;
|
|
57
|
+
if (!Array.isArray(sections)) return null;
|
|
58
|
+
for (const instance of sections) {
|
|
59
|
+
const key = instance?.section;
|
|
60
|
+
if (typeof key !== "string") return null;
|
|
61
|
+
keys.add(key);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return keys;
|
|
65
|
+
}
|
|
66
|
+
/** Verify `files` against the artifact shape. Never throws for a malformed artifact. */
|
|
67
|
+
function verifyArtifact(files) {
|
|
68
|
+
const problems = [];
|
|
69
|
+
const raw = readJson(files, MANIFEST_FILE, problems);
|
|
70
|
+
if (raw === null) return {
|
|
71
|
+
manifest: null,
|
|
72
|
+
problems
|
|
73
|
+
};
|
|
74
|
+
const schema = readArtifactSchema(raw.value);
|
|
75
|
+
if (schema !== 1) {
|
|
76
|
+
problems.push({
|
|
77
|
+
path: MANIFEST_FILE,
|
|
78
|
+
message: schema === null ? `carries no integer artifact_schema; this reader knows ${String(1)}` : `artifact_schema ${String(schema)} is not one this reader knows (it knows ${String(1)})`
|
|
79
|
+
});
|
|
80
|
+
return {
|
|
81
|
+
manifest: null,
|
|
82
|
+
problems
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
const parsed = ArtifactManifest.safeParse(raw.value);
|
|
86
|
+
if (!parsed.success) {
|
|
87
|
+
for (const issue of parsed.error.issues) problems.push({
|
|
88
|
+
path: MANIFEST_FILE,
|
|
89
|
+
message: `${issue.path.join(".") || "(root)"}: ${issue.message}`
|
|
90
|
+
});
|
|
91
|
+
return {
|
|
92
|
+
manifest: null,
|
|
93
|
+
problems
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
const manifest = parsed.data;
|
|
97
|
+
const listed = new Set(manifest.sections.map((section) => section.key));
|
|
98
|
+
for (const path of files.keys()) {
|
|
99
|
+
if (path === "manifest.json") continue;
|
|
100
|
+
const slash = path.indexOf("/");
|
|
101
|
+
const top = slash < 0 ? path : path.slice(0, slash);
|
|
102
|
+
const rest = slash < 0 ? "" : path.slice(slash + 1);
|
|
103
|
+
if (top === "playground") {
|
|
104
|
+
const [head, ...inner] = rest.split("/");
|
|
105
|
+
if (!(rest === PLAYGROUND_FILES.host || head === "client" && inner.length > 0 && inner.every((part) => CLIENT_SEGMENT.test(part)))) problems.push({
|
|
106
|
+
path,
|
|
107
|
+
message: `is not the host module or a file under ${PLAYGROUND_DIR}/${PLAYGROUND_CLIENT_DIR}/`
|
|
108
|
+
});
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
if (top === "fixtures") {
|
|
112
|
+
const [id, file, ...inner] = rest.split("/");
|
|
113
|
+
if (id === void 0 || !manifest.fixtures.includes(id)) problems.push({
|
|
114
|
+
path,
|
|
115
|
+
message: "belongs to no fixture the manifest lists"
|
|
116
|
+
});
|
|
117
|
+
else if (inner.length > 0 || file === void 0 || !FIXTURE_FILE_NAMES.has(file)) problems.push({
|
|
118
|
+
path,
|
|
119
|
+
message: "is not a file a fixture directory carries"
|
|
120
|
+
});
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
if (UNHASHED_DIRS.includes(top)) continue;
|
|
124
|
+
if (top === "sections") {
|
|
125
|
+
const [template, section, ...inner] = rest.split("/");
|
|
126
|
+
const key = `${template ?? ""}/${section ?? ""}`;
|
|
127
|
+
const file = inner.join("/");
|
|
128
|
+
if (!listed.has(key)) problems.push({
|
|
129
|
+
path,
|
|
130
|
+
message: `belongs to no section the manifest lists`
|
|
131
|
+
});
|
|
132
|
+
else if (!SECTION_FILE_NAMES.has(file) && !ISLAND_CHUNK.test(file)) problems.push({
|
|
133
|
+
path,
|
|
134
|
+
message: "is not a file a section directory carries"
|
|
135
|
+
});
|
|
136
|
+
} else if (top === "template") {
|
|
137
|
+
if (!TEMPLATE_FILE_NAMES.has(rest)) problems.push({
|
|
138
|
+
path,
|
|
139
|
+
message: "is not a file the template directory carries"
|
|
140
|
+
});
|
|
141
|
+
} else if (top === "static" || top === "assets") {
|
|
142
|
+
if (!FLAT_FILE.test(rest)) problems.push({
|
|
143
|
+
path,
|
|
144
|
+
message: `${top}/ holds flat, content-addressed filenames only`
|
|
145
|
+
});
|
|
146
|
+
} else problems.push({
|
|
147
|
+
path,
|
|
148
|
+
message: "is outside the artifact layout"
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
for (const file of Object.values(PLAYGROUND_FILES)) if (!files.has(playgroundPath(file))) problems.push({
|
|
152
|
+
path: playgroundPath(file),
|
|
153
|
+
message: "missing"
|
|
154
|
+
});
|
|
155
|
+
for (const id of manifest.fixtures) for (const file of Object.values(FIXTURE_FILES)) {
|
|
156
|
+
const path = fixturePath(id, file);
|
|
157
|
+
if (readJson(files, path, problems) === null) continue;
|
|
158
|
+
for (const match of decoder.decode(files.get(path)).matchAll(ASSET_URL)) if (!files.has(`${"assets"}/${match[1]}`)) problems.push({
|
|
159
|
+
path,
|
|
160
|
+
message: `names ${match[0]}, which ${ASSETS_DIR}/ does not carry`
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
const sectionHashes = /* @__PURE__ */ new Map();
|
|
164
|
+
for (const section of manifest.sections) {
|
|
165
|
+
for (const file of Object.values(SECTION_FILES)) {
|
|
166
|
+
const path = sectionPath(section.key, file);
|
|
167
|
+
if (!files.has(path)) problems.push({
|
|
168
|
+
path,
|
|
169
|
+
message: "missing"
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
for (const file of [SECTION_FILES.schema, SECTION_FILES.fillSpec]) {
|
|
173
|
+
const path = sectionPath(section.key, file);
|
|
174
|
+
if (files.has(path)) readJson(files, path, problems);
|
|
175
|
+
}
|
|
176
|
+
const usedPath = sectionPath(section.key, SECTION_FILES.usedFacts);
|
|
177
|
+
if (files.has(usedPath)) {
|
|
178
|
+
const used = readJson(files, usedPath, problems);
|
|
179
|
+
if (used !== null) checkUsedFacts(used.value, usedPath, problems);
|
|
180
|
+
}
|
|
181
|
+
let actual;
|
|
182
|
+
try {
|
|
183
|
+
actual = sectionContentHash(files, section.key);
|
|
184
|
+
} catch {
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
sectionHashes.set(section.key, actual);
|
|
188
|
+
if (actual !== section.content_hash) problems.push({
|
|
189
|
+
path: MANIFEST_FILE,
|
|
190
|
+
message: `section "${section.key}" states content hash ${section.content_hash}, its files hash to ${actual}`
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
for (const file of Object.values(TEMPLATE_FILES)) if (!files.has(templatePath(file))) problems.push({
|
|
194
|
+
path: templatePath(file),
|
|
195
|
+
message: "missing"
|
|
196
|
+
});
|
|
197
|
+
const compositionPath = templatePath(TEMPLATE_FILES.composition);
|
|
198
|
+
if (files.has(compositionPath)) {
|
|
199
|
+
const composition = readJson(files, compositionPath, problems);
|
|
200
|
+
if (composition !== null) {
|
|
201
|
+
const placed = composedSections(composition.value);
|
|
202
|
+
if (placed === null) problems.push({
|
|
203
|
+
path: compositionPath,
|
|
204
|
+
message: "has no pages[].sections[].section to read the placed sections from"
|
|
205
|
+
});
|
|
206
|
+
else {
|
|
207
|
+
for (const key of placed) if (!listed.has(key)) problems.push({
|
|
208
|
+
path: compositionPath,
|
|
209
|
+
message: `places section "${key}", which the manifest does not list`
|
|
210
|
+
});
|
|
211
|
+
for (const key of listed) if (!placed.has(key)) problems.push({
|
|
212
|
+
path: MANIFEST_FILE,
|
|
213
|
+
message: `lists section "${key}", which the composition places nowhere`
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
const templateUsed = templatePath(TEMPLATE_FILES.usedFacts);
|
|
219
|
+
if (files.has(templateUsed)) {
|
|
220
|
+
const used = readJson(files, templateUsed, problems);
|
|
221
|
+
if (used !== null) checkUsedFacts(used.value, templateUsed, problems);
|
|
222
|
+
}
|
|
223
|
+
if (files.has(templatePath(TEMPLATE_FILES.preview))) readJson(files, templatePath(TEMPLATE_FILES.preview), problems);
|
|
224
|
+
const bindingPath = templatePath(TEMPLATE_FILES.staticAssets);
|
|
225
|
+
if (files.has(bindingPath)) {
|
|
226
|
+
const binding = readJson(files, bindingPath, problems);
|
|
227
|
+
if (binding !== null) {
|
|
228
|
+
let bound;
|
|
229
|
+
try {
|
|
230
|
+
bound = boundFiles(binding.value);
|
|
231
|
+
} catch (cause) {
|
|
232
|
+
problems.push({
|
|
233
|
+
path: bindingPath,
|
|
234
|
+
message: `does not read as a static-assets binding: ${cause instanceof Error ? cause.message : String(cause)}`
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
const boundPaths = /* @__PURE__ */ new Set();
|
|
238
|
+
for (const file of bound ?? []) {
|
|
239
|
+
boundPaths.add(file.path);
|
|
240
|
+
const bytes = files.get(file.path);
|
|
241
|
+
if (bytes === void 0) problems.push({
|
|
242
|
+
path: file.path,
|
|
243
|
+
message: `named by the binding as ${file.filename}, and missing`
|
|
244
|
+
});
|
|
245
|
+
else if (file.contentHash !== void 0 && sha256Hex(bytes) !== file.contentHash) problems.push({
|
|
246
|
+
path: file.path,
|
|
247
|
+
message: `the binding states content hash ${file.contentHash} for ${file.filename}; the bytes hash to ${sha256Hex(bytes)}`
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
if (bound !== void 0) for (const path of files.keys()) {
|
|
251
|
+
const parts = path.split("/");
|
|
252
|
+
const isChunk = parts.length === 5 && parts[0] === "sections" && parts[3] === "islands";
|
|
253
|
+
if ((path.startsWith(`${"static"}/`) || isChunk) && !boundPaths.has(path)) problems.push({
|
|
254
|
+
path,
|
|
255
|
+
message: "is a static bundle the binding does not name"
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
let templateHash = null;
|
|
261
|
+
try {
|
|
262
|
+
templateHash = templateContentHash(files, sectionHashes);
|
|
263
|
+
} catch {}
|
|
264
|
+
if (templateHash !== null && templateHash !== manifest.template.content_hash) problems.push({
|
|
265
|
+
path: MANIFEST_FILE,
|
|
266
|
+
message: `the template states content hash ${manifest.template.content_hash}, its files hash to ${templateHash}`
|
|
267
|
+
});
|
|
268
|
+
return {
|
|
269
|
+
manifest,
|
|
270
|
+
problems
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
//#endregion
|
|
275
|
+
export { verifyArtifact };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
//#region ../../internal/template-contracts/dist/collection-editing.js
|
|
2
|
+
function editorOf(def) {
|
|
3
|
+
if (def.fields != null) return "row-editor";
|
|
4
|
+
const element = def.element?.type;
|
|
5
|
+
if (element === "image" || element === "video" || element === "tour") return "gallery";
|
|
6
|
+
if (element === "poi") return "poi-curation";
|
|
7
|
+
if (element === "document") return "document-list";
|
|
8
|
+
return "scalar-list";
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The editor state one collection slot derives from its item content — the
|
|
12
|
+
* D6 table. Item content is the only input: an unrecognized or absent item
|
|
13
|
+
* declaration reads as the scalar card rather than widening the contract.
|
|
14
|
+
*
|
|
15
|
+
* Only a record item selects per-item; every other editor addresses the
|
|
16
|
+
* collection as one card, which is what every audited scalar and media
|
|
17
|
+
* collection already did.
|
|
18
|
+
*/
|
|
19
|
+
function collectionEditorState(def) {
|
|
20
|
+
const editor = editorOf(def);
|
|
21
|
+
return {
|
|
22
|
+
editor,
|
|
23
|
+
granularity: editor === "row-editor" ? "item" : "unit"
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* How the editor treats one collection slot's items: `"item"` selects/crops each
|
|
28
|
+
* item individually; `"unit"` edits the whole collection as one card.
|
|
29
|
+
*
|
|
30
|
+
* The granularity half of `collectionEditorState`, kept as the narrow view
|
|
31
|
+
* existing consumers read.
|
|
32
|
+
*/
|
|
33
|
+
function collectionEditing(def) {
|
|
34
|
+
return collectionEditorState(def).granularity;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
//#endregion
|
|
38
|
+
export { collectionEditing, collectionEditorState };
|