@decocms/blocks 8.9.1 → 8.11.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/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/protocol/channel.d.ts +98 -0
- package/dist/protocol/channel.d.ts.map +1 -0
- package/dist/protocol/channel.js +58 -0
- package/dist/protocol/channel.js.map +1 -0
- package/dist/protocol/client.js +2 -2
- package/dist/protocol/client.js.map +1 -1
- package/dist/protocol/conformance/blockMetaVectors.json +214 -0
- package/dist/protocol/conformance/contentHashFixtures.d.ts +22 -0
- package/dist/protocol/conformance/contentHashFixtures.d.ts.map +1 -1
- package/dist/protocol/conformance/contentHashFixtures.js +55 -0
- package/dist/protocol/conformance/contentHashFixtures.js.map +1 -1
- package/dist/protocol/conformance/index.d.ts +2 -1
- package/dist/protocol/conformance/index.d.ts.map +1 -1
- package/dist/protocol/conformance/index.js +2 -1
- package/dist/protocol/conformance/index.js.map +1 -1
- package/dist/protocol/conformance/vectors.d.ts +33 -0
- package/dist/protocol/conformance/vectors.d.ts.map +1 -0
- package/dist/protocol/conformance/vectors.js +3 -0
- package/dist/protocol/conformance/vectors.js.map +1 -0
- package/dist/protocol/index.d.ts +11 -1
- package/dist/protocol/index.d.ts.map +1 -1
- package/dist/protocol/index.js +11 -1
- package/dist/protocol/index.js.map +1 -1
- package/dist/protocol/keys.d.ts +1 -1
- package/dist/protocol/keys.js +1 -1
- package/dist/v8/background.d.ts +13 -0
- package/dist/v8/background.d.ts.map +1 -1
- package/dist/v8/background.js +41 -0
- package/dist/v8/background.js.map +1 -1
- package/dist/v8/blockMeta.d.ts +27 -0
- package/dist/v8/blockMeta.d.ts.map +1 -0
- package/dist/v8/blockMeta.js +75 -0
- package/dist/v8/blockMeta.js.map +1 -0
- package/dist/v8/blockStore.d.ts +43 -0
- package/dist/v8/blockStore.d.ts.map +1 -0
- package/dist/v8/blockStore.js +95 -0
- package/dist/v8/blockStore.js.map +1 -0
- package/dist/v8/boundedJson.d.ts +5 -0
- package/dist/v8/boundedJson.d.ts.map +1 -1
- package/dist/v8/boundedJson.js +10 -2
- package/dist/v8/boundedJson.js.map +1 -1
- package/dist/v8/boundedMap.d.ts +19 -0
- package/dist/v8/boundedMap.d.ts.map +1 -0
- package/dist/v8/boundedMap.js +52 -0
- package/dist/v8/boundedMap.js.map +1 -0
- package/dist/v8/builtins/data.d.ts +18 -2
- package/dist/v8/builtins/data.d.ts.map +1 -1
- package/dist/v8/builtins/data.js +17 -1
- package/dist/v8/builtins/data.js.map +1 -1
- package/dist/v8/builtins/index.d.ts.map +1 -1
- package/dist/v8/builtins/index.js +2 -1
- package/dist/v8/builtins/index.js.map +1 -1
- package/dist/v8/builtins/legacy.d.ts +6 -3
- package/dist/v8/builtins/legacy.d.ts.map +1 -1
- package/dist/v8/builtins/legacy.js +6 -3
- package/dist/v8/builtins/legacy.js.map +1 -1
- package/dist/v8/canonical.d.ts +8 -0
- package/dist/v8/canonical.d.ts.map +1 -1
- package/dist/v8/canonical.js +15 -0
- package/dist/v8/canonical.js.map +1 -1
- package/dist/v8/cli/builtins.d.ts.map +1 -1
- package/dist/v8/cli/builtins.js +1 -0
- package/dist/v8/cli/builtins.js.map +1 -1
- package/dist/v8/cli/check/index.d.ts +10 -0
- package/dist/v8/cli/check/index.d.ts.map +1 -1
- package/dist/v8/cli/check/index.js +91 -7
- package/dist/v8/cli/check/index.js.map +1 -1
- package/dist/v8/cli/content.d.ts +12 -25
- package/dist/v8/cli/content.d.ts.map +1 -1
- package/dist/v8/cli/content.js +46 -75
- package/dist/v8/cli/content.js.map +1 -1
- package/dist/v8/cli/index.d.ts +2 -2
- package/dist/v8/cli/index.d.ts.map +1 -1
- package/dist/v8/cli/index.js +2 -2
- package/dist/v8/cli/index.js.map +1 -1
- package/dist/v8/cli/remote/commands.d.ts +71 -0
- package/dist/v8/cli/remote/commands.d.ts.map +1 -0
- package/dist/v8/cli/remote/commands.js +644 -0
- package/dist/v8/cli/remote/commands.js.map +1 -0
- package/dist/v8/cli/remote/diff.d.ts +15 -0
- package/dist/v8/cli/remote/diff.d.ts.map +1 -0
- package/dist/v8/cli/remote/diff.js +102 -0
- package/dist/v8/cli/remote/diff.js.map +1 -0
- package/dist/v8/cli/remote/env.d.ts +35 -0
- package/dist/v8/cli/remote/env.d.ts.map +1 -0
- package/dist/v8/cli/remote/env.js +84 -0
- package/dist/v8/cli/remote/env.js.map +1 -0
- package/dist/v8/cli/remote/http.d.ts +149 -0
- package/dist/v8/cli/remote/http.d.ts.map +1 -0
- package/dist/v8/cli/remote/http.js +381 -0
- package/dist/v8/cli/remote/http.js.map +1 -0
- package/dist/v8/cli/remote/local.d.ts +90 -0
- package/dist/v8/cli/remote/local.d.ts.map +1 -0
- package/dist/v8/cli/remote/local.js +309 -0
- package/dist/v8/cli/remote/local.js.map +1 -0
- package/dist/v8/cli/root.d.ts +29 -0
- package/dist/v8/cli/root.d.ts.map +1 -1
- package/dist/v8/cli/root.js +28 -0
- package/dist/v8/cli/root.js.map +1 -1
- package/dist/v8/cli/run.d.ts +13 -1
- package/dist/v8/cli/run.d.ts.map +1 -1
- package/dist/v8/cli/run.js +310 -124
- package/dist/v8/cli/run.js.map +1 -1
- package/dist/v8/cli/schema/builtinSchemas.d.ts.map +1 -1
- package/dist/v8/cli/schema/builtinSchemas.js +28 -10
- package/dist/v8/cli/schema/builtinSchemas.js.map +1 -1
- package/dist/v8/cli/schema/generate.js +1 -1
- package/dist/v8/cli/schema/generate.js.map +1 -1
- package/dist/v8/cli/skills.d.ts +25 -0
- package/dist/v8/cli/skills.d.ts.map +1 -0
- package/dist/v8/cli/skills.js +70 -0
- package/dist/v8/cli/skills.js.map +1 -0
- package/dist/v8/client.d.ts +9 -9
- package/dist/v8/client.d.ts.map +1 -1
- package/dist/v8/client.js +138 -50
- package/dist/v8/client.js.map +1 -1
- package/dist/v8/cms.d.ts +2 -1
- package/dist/v8/cms.d.ts.map +1 -1
- package/dist/v8/cms.js +55 -46
- package/dist/v8/cms.js.map +1 -1
- package/dist/v8/content.d.ts +39 -78
- package/dist/v8/content.d.ts.map +1 -1
- package/dist/v8/content.js +155 -195
- package/dist/v8/content.js.map +1 -1
- package/dist/v8/contentIndex.d.ts +71 -0
- package/dist/v8/contentIndex.d.ts.map +1 -0
- package/dist/v8/contentIndex.js +137 -0
- package/dist/v8/contentIndex.js.map +1 -0
- package/dist/v8/draft.d.ts +7 -7
- package/dist/v8/draft.d.ts.map +1 -1
- package/dist/v8/draft.js +10 -9
- package/dist/v8/draft.js.map +1 -1
- package/dist/v8/draftChanges.d.ts +59 -32
- package/dist/v8/draftChanges.d.ts.map +1 -1
- package/dist/v8/draftChanges.js +139 -75
- package/dist/v8/draftChanges.js.map +1 -1
- package/dist/v8/errors.d.ts +21 -0
- package/dist/v8/errors.d.ts.map +1 -1
- package/dist/v8/errors.js +22 -0
- package/dist/v8/errors.js.map +1 -1
- package/dist/v8/hostedSource.d.ts +57 -0
- package/dist/v8/hostedSource.d.ts.map +1 -0
- package/dist/v8/hostedSource.js +18 -0
- package/dist/v8/hostedSource.js.map +1 -0
- package/dist/v8/identity.d.ts +1 -1
- package/dist/v8/identity.js +1 -1
- package/dist/v8/index.d.ts +1 -0
- package/dist/v8/index.d.ts.map +1 -1
- package/dist/v8/index.js +1 -0
- package/dist/v8/index.js.map +1 -1
- package/dist/v8/matchRoute.js +7 -4
- package/dist/v8/matchRoute.js.map +1 -1
- package/dist/v8/pin.d.ts +34 -0
- package/dist/v8/pin.d.ts.map +1 -0
- package/dist/v8/pin.js +156 -0
- package/dist/v8/pin.js.map +1 -0
- package/dist/v8/preview/StudioBridge.d.ts +8 -8
- package/dist/v8/preview/StudioBridge.d.ts.map +1 -1
- package/dist/v8/preview/StudioBridge.js +8 -10
- package/dist/v8/preview/StudioBridge.js.map +1 -1
- package/dist/v8/preview/StudioChannel.d.ts +51 -0
- package/dist/v8/preview/StudioChannel.d.ts.map +1 -0
- package/dist/v8/preview/StudioChannel.js +104 -0
- package/dist/v8/preview/StudioChannel.js.map +1 -0
- package/dist/v8/preview/index.d.ts +3 -0
- package/dist/v8/preview/index.d.ts.map +1 -1
- package/dist/v8/preview/index.js +3 -0
- package/dist/v8/preview/index.js.map +1 -1
- package/dist/v8/remoteLoader.d.ts +42 -5
- package/dist/v8/remoteLoader.d.ts.map +1 -1
- package/dist/v8/remoteLoader.js +317 -259
- package/dist/v8/remoteLoader.js.map +1 -1
- package/dist/v8/resolver.d.ts +22 -8
- package/dist/v8/resolver.d.ts.map +1 -1
- package/dist/v8/resolver.js +37 -32
- package/dist/v8/resolver.js.map +1 -1
- package/dist/v8/revisionId.d.ts +11 -0
- package/dist/v8/revisionId.d.ts.map +1 -0
- package/dist/v8/revisionId.js +13 -0
- package/dist/v8/revisionId.js.map +1 -0
- package/dist/v8/settings.d.ts +6 -6
- package/dist/v8/settings.d.ts.map +1 -1
- package/dist/v8/settings.js +8 -7
- package/dist/v8/settings.js.map +1 -1
- package/dist/v8/telemetry.d.ts +4 -2
- package/dist/v8/telemetry.d.ts.map +1 -1
- package/dist/v8/telemetry.js +2 -2
- package/dist/v8/telemetry.js.map +1 -1
- package/dist/v8/types.d.ts +52 -40
- package/dist/v8/types.d.ts.map +1 -1
- package/dist/v8/variants.d.ts +7 -2
- package/dist/v8/variants.d.ts.map +1 -1
- package/dist/v8/variants.js +21 -24
- package/dist/v8/variants.js.map +1 -1
- package/dist/v8/vite/index.d.ts +2 -2
- package/dist/v8/vite/index.js +1 -1
- package/dist/v8/vite/index.js.map +1 -1
- package/package.json +3 -2
- package/skills/deco-apps/SKILL.md +82 -0
- package/skills/deco-apps/references/algolia.md +51 -0
- package/skills/deco-apps/references/commerce-types.md +132 -0
- package/skills/deco-apps/references/instrumented-fetch.md +144 -0
- package/skills/deco-apps/references/magento.md +55 -0
- package/skills/deco-apps/references/messaging.md +76 -0
- package/skills/deco-apps/references/shopify.md +69 -0
- package/skills/deco-apps/references/vendored-loaders.md +135 -0
- package/skills/deco-apps/references/vtex-cookies-auth.md +146 -0
- package/skills/deco-apps/references/vtex.md +150 -0
- package/skills/deco-apps/references/wake.md +75 -0
- package/skills/deco-cms-schema/SKILL.md +80 -0
- package/skills/deco-cms-schema/references/annotations.md +147 -0
- package/skills/deco-cms-schema/references/content-hygiene.md +91 -0
- package/skills/deco-cms-schema/references/formats-and-widgets.md +112 -0
- package/skills/deco-cms-schema/references/shapes-that-break-the-form.md +165 -0
- package/skills/deco-cms-schema/references/types-to-fields.md +112 -0
- package/skills/deco-go-live/SKILL.md +127 -0
- package/skills/deco-go-live/references/content-releases.md +90 -0
- package/skills/deco-go-live/references/process.md +106 -0
- package/skills/deco-go-live/references/proxy-headers-checkout.md +139 -0
- package/skills/deco-go-live/references/qa-checklist-template.md +150 -0
- package/skills/deco-go-live/references/qa-inventory.md +120 -0
- package/skills/deco-go-live/references/react-spa.md +183 -0
- package/skills/deco-go-live/references/seo-analytics.md +114 -0
- package/skills/deco-go-live/references/traffic-ramp.md +87 -0
- package/skills/deco-go-live/references/worker-runtime.md +93 -0
- package/skills/deco-go-live/scripts/preflight.sh +221 -0
- package/skills/deco-images-media/SKILL.md +64 -0
- package/skills/deco-images-media/references/asset-upload.md +191 -0
- package/skills/deco-images-media/references/components-per-binding.md +167 -0
- package/skills/deco-images-media/references/providers-and-cdn.md +145 -0
- package/skills/deco-images-media/references/quality-and-lcp.md +93 -0
- package/skills/deco-images-media/references/troubleshooting.md +147 -0
- package/skills/deco-images-media/references/video.md +122 -0
- package/skills/deco-make-editable/SKILL.md +94 -0
- package/skills/deco-make-editable/references/a11y-and-e2e.md +104 -0
- package/skills/deco-make-editable/references/content-shapes.md +198 -0
- package/skills/deco-make-editable/references/from-figma.md +110 -0
- package/skills/deco-make-editable/references/i18n-fields.md +112 -0
- package/skills/deco-make-editable/references/inventory.md +79 -0
- package/skills/deco-make-editable/references/pixel-parity.md +175 -0
- package/skills/deco-make-editable/references/seeding-content.md +119 -0
- package/skills/deco-nextjs-site/SKILL.md +74 -0
- package/skills/deco-nextjs-site/references/caching.md +116 -0
- package/skills/deco-nextjs-site/references/metadata-seo.md +100 -0
- package/skills/deco-nextjs-site/references/proxy-and-drafts.md +177 -0
- package/skills/deco-nextjs-site/references/rendering.md +171 -0
- package/skills/deco-nextjs-site/references/setup.md +190 -0
- package/skills/deco-nextjs-site/references/studio-bridge.md +130 -0
- package/skills/deco-site-authoring/SKILL.md +75 -0
- package/skills/deco-site-authoring/references/lazy-blocks.md +155 -0
- package/skills/deco-site-authoring/references/loaders.md +192 -0
- package/skills/deco-site-authoring/references/pages.md +156 -0
- package/skills/deco-site-authoring/references/review-before-publish.md +95 -0
- package/skills/deco-site-authoring/references/sections.md +158 -0
- package/skills/deco-site-authoring/references/seo.md +116 -0
- package/skills/deco-site-workflow/SKILL.md +92 -0
- package/skills/deco-site-workflow/references/check.md +116 -0
- package/skills/deco-site-workflow/references/cli-reference.md +104 -0
- package/skills/deco-site-workflow/references/content-layout.md +93 -0
- package/skills/deco-site-workflow/references/content-sync.md +146 -0
- package/skills/deco-site-workflow/references/delivery.md +51 -0
- package/skills/deco-site-workflow/references/deploy.md +87 -0
- package/skills/deco-site-workflow/references/schema.md +173 -0
- package/skills/deco-site-workflow/references/serve-and-studio.md +138 -0
- package/skills/deco-storefront-caching/SKILL.md +67 -0
- package/skills/deco-storefront-caching/references/cache-keys.md +129 -0
- package/skills/deco-storefront-caching/references/case-study.md +82 -0
- package/skills/deco-storefront-caching/references/egress-traps.md +153 -0
- package/skills/deco-storefront-caching/references/nextjs.md +60 -0
- package/skills/deco-storefront-caching/references/perf-guardrails-e2e.md +123 -0
- package/skills/deco-storefront-caching/references/verification.md +136 -0
- package/skills/deco-storefront-caching/references/worker-page-cache.md +160 -0
- package/skills/deco-storefront-caching/scripts/html-anatomy.mjs +97 -0
- package/skills/deco-storefront-performance/SKILL.md +81 -0
- package/skills/deco-storefront-performance/references/cls-third-party.md +90 -0
- package/skills/deco-storefront-performance/references/hydration.md +116 -0
- package/skills/deco-storefront-performance/references/loaders-n-plus-1.md +107 -0
- package/skills/deco-storefront-performance/references/navigation-ux.md +130 -0
- package/skills/deco-storefront-performance/references/payload-trim.md +163 -0
- package/skills/deco-storefront-performance/references/render-location.md +152 -0
- package/skills/deco-storefront-performance/references/request-dedupe.md +147 -0
- package/skills/deco-storefront-performance/references/trace-reading.md +79 -0
- package/skills/deco-storefront-performance/references/worker-memory.md +176 -0
- package/skills/deco-tanstack-site/SKILL.md +68 -0
- package/skills/deco-tanstack-site/references/document-and-security.md +155 -0
- package/skills/deco-tanstack-site/references/router-and-navigation.md +137 -0
- package/skills/deco-tanstack-site/references/routes-and-pages.md +183 -0
- package/skills/deco-tanstack-site/references/server-functions.md +123 -0
- package/skills/deco-tanstack-site/references/setup.md +153 -0
- package/skills/deco-tanstack-site/references/worker-entry.md +152 -0
- package/skills/deco-v7-to-v8-migration/SKILL.md +122 -0
- package/skills/deco-v7-to-v8-migration/references/caching-and-privacy.md +10 -0
- package/skills/deco-v7-to-v8-migration/references/content.md +25 -0
- package/skills/deco-v7-to-v8-migration/references/editor-forms.md +27 -0
- package/skills/deco-v7-to-v8-migration/references/faststore.md +40 -0
- package/skills/deco-v7-to-v8-migration/references/framework-code.md +53 -0
- package/skills/deco-v7-to-v8-migration/references/hosted-releases.md +16 -0
- package/skills/deco-v7-to-v8-migration/references/import-map.md +81 -0
- package/skills/deco-v7-to-v8-migration/references/legacy-names.md +33 -0
- package/skills/deco-v7-to-v8-migration/references/manual-steps.md +10 -0
- package/skills/deco-v7-to-v8-migration/references/native-apps.md +43 -0
- package/skills/deco-v7-to-v8-migration/references/nextjs.md +19 -0
- package/skills/deco-v7-to-v8-migration/references/parity.md +66 -0
- package/skills/deco-v7-to-v8-migration/references/rendering.md +13 -0
- package/skills/deco-v7-to-v8-migration/references/running-the-script.md +29 -0
- package/skills/deco-v7-to-v8-migration/references/script-steps.md +13 -0
- package/skills/deco-v7-to-v8-migration/references/server-functions.md +15 -0
- package/skills/deco-v7-to-v8-migration/references/sibling-port.md +11 -0
- package/skills/deco-v7-to-v8-migration/references/site-code.md +15 -0
- package/skills/deco-v7-to-v8-migration/references/telemetry.md +10 -0
- package/skills/deco-v7-to-v8-migration/references/verify.md +20 -0
- package/skills/deco-v7-to-v8-migration/scripts/apps.ts +297 -0
- package/skills/deco-v7-to-v8-migration/scripts/asyncRendering.ts +73 -0
- package/skills/deco-v7-to-v8-migration/scripts/blockMap.ts +584 -0
- package/skills/deco-v7-to-v8-migration/scripts/ciSchemaCheck.ts +145 -0
- package/skills/deco-v7-to-v8-migration/scripts/compat.ts +357 -0
- package/skills/deco-v7-to-v8-migration/scripts/content.ts +121 -0
- package/skills/deco-v7-to-v8-migration/scripts/experiments.ts +81 -0
- package/skills/deco-v7-to-v8-migration/scripts/framework.ts +61 -0
- package/skills/deco-v7-to-v8-migration/scripts/imageCopy.ts +276 -0
- package/skills/deco-v7-to-v8-migration/scripts/imageModule.ts +285 -0
- package/skills/deco-v7-to-v8-migration/scripts/imports.ts +942 -0
- package/skills/deco-v7-to-v8-migration/scripts/invoke.ts +624 -0
- package/skills/deco-v7-to-v8-migration/scripts/legacyNames.ts +45 -0
- package/skills/deco-v7-to-v8-migration/scripts/main.ts +59 -0
- package/skills/deco-v7-to-v8-migration/scripts/matchers.ts +41 -0
- package/skills/deco-v7-to-v8-migration/scripts/migrate.ts +176 -0
- package/skills/deco-v7-to-v8-migration/scripts/redirects.ts +455 -0
- package/skills/deco-v7-to-v8-migration/scripts/report.ts +50 -0
- package/skills/deco-v7-to-v8-migration/scripts/scaffold.ts +1119 -0
- package/skills/deco-v7-to-v8-migration/scripts/secrets.ts +35 -0
- package/skills/deco-v7-to-v8-migration/scripts/sectionLoaders.ts +216 -0
- package/skills/deco-v7-to-v8-migration/scripts/siteSettings.ts +261 -0
- package/skills/deco-v7-to-v8-migration/scripts/stubs.ts +388 -0
- package/skills/deco-v7-to-v8-migration/scripts/tsconfig.json +7 -0
- package/skills/deco-v7-to-v8-migration/scripts/vendor.ts +249 -0
- package/skills/deco-v7-to-v8-migration/scripts/vtexInvoke.ts +240 -0
- package/skills/deco-v7-to-v8-migration/scripts/walk.ts +30 -0
- package/skills/deco-variants/SKILL.md +57 -0
- package/skills/deco-variants/references/caching-variants.md +63 -0
- package/skills/deco-variants/references/custom-matchers.md +83 -0
- package/skills/deco-variants/references/draft-preview.md +59 -0
- package/skills/deco-variants/references/experiments-and-campaigns.md +104 -0
- package/skills/deco-variants/references/multivariate.md +85 -0
- package/skills/deco-variants/references/v7-matchers.md +71 -0
- package/src/index.ts +2 -0
- package/src/protocol/channel.ts +127 -0
- package/src/protocol/client.ts +2 -2
- package/src/protocol/conformance/blockMetaVectors.json +214 -0
- package/src/protocol/conformance/contentHashFixtures.ts +74 -0
- package/src/protocol/conformance/index.ts +9 -1
- package/src/protocol/conformance/vectors.ts +36 -0
- package/src/protocol/index.ts +32 -0
- package/src/protocol/keys.ts +1 -1
- package/src/v8/background.ts +42 -0
- package/src/v8/blockMeta.ts +100 -0
- package/src/v8/blockStore.ts +124 -0
- package/src/v8/boundedJson.ts +20 -2
- package/src/v8/boundedMap.ts +53 -0
- package/src/v8/builtins/data.ts +26 -2
- package/src/v8/builtins/index.ts +2 -1
- package/src/v8/builtins/legacy.ts +6 -3
- package/src/v8/canonical.ts +15 -0
- package/src/v8/cli/builtins.ts +1 -0
- package/src/v8/cli/check/index.ts +97 -7
- package/src/v8/cli/content.ts +49 -91
- package/src/v8/cli/index.ts +2 -2
- package/src/v8/cli/remote/commands.ts +834 -0
- package/src/v8/cli/remote/diff.ts +100 -0
- package/src/v8/cli/remote/env.ts +107 -0
- package/src/v8/cli/remote/http.ts +484 -0
- package/src/v8/cli/remote/local.ts +343 -0
- package/src/v8/cli/root.ts +40 -0
- package/src/v8/cli/run.ts +366 -135
- package/src/v8/cli/schema/builtinSchemas.ts +29 -10
- package/src/v8/cli/schema/generate.ts +1 -1
- package/src/v8/cli/skills.ts +91 -0
- package/src/v8/client.ts +162 -60
- package/src/v8/cms.ts +62 -53
- package/src/v8/content.ts +179 -229
- package/src/v8/contentIndex.ts +183 -0
- package/src/v8/draft.ts +15 -14
- package/src/v8/draftChanges.ts +151 -85
- package/src/v8/errors.ts +37 -0
- package/src/v8/hostedSource.ts +67 -0
- package/src/v8/identity.ts +1 -1
- package/src/v8/index.ts +1 -0
- package/src/v8/matchRoute.ts +7 -4
- package/src/v8/pin.ts +176 -0
- package/src/v8/preview/StudioBridge.ts +8 -10
- package/src/v8/preview/StudioChannel.ts +116 -0
- package/src/v8/preview/index.ts +3 -0
- package/src/v8/remoteLoader.ts +350 -286
- package/src/v8/resolver.ts +56 -33
- package/src/v8/revisionId.ts +14 -0
- package/src/v8/settings.ts +10 -9
- package/src/v8/telemetry.ts +3 -3
- package/src/v8/types.ts +52 -40
- package/src/v8/variants.ts +30 -26
- package/src/v8/vite/index.ts +3 -3
- package/dist/v8/cli/serve/server.d.ts +0 -29
- package/dist/v8/cli/serve/server.d.ts.map +0 -1
- package/dist/v8/cli/serve/server.js +0 -296
- package/dist/v8/cli/serve/server.js.map +0 -1
- package/src/v8/cli/serve/server.ts +0 -348
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A/B tests and dates. v7 ran tests on its random matcher and date windows on
|
|
3
|
+
* its date matcher; the next major keeps both in content: tests in the saved
|
|
4
|
+
* block `experiments` (type `split-traffic`) read by the `experiment` rule,
|
|
5
|
+
* date windows in the saved block `campaigns` (type `calendar`) read by the
|
|
6
|
+
* `campaign` rule, which names one. The script moves neither: it
|
|
7
|
+
* reports each kind once, for whoever moves them by hand, and says who hands
|
|
8
|
+
* the visitor to the client when the site has tests.
|
|
9
|
+
*/
|
|
10
|
+
import { siteFramework } from "./framework";
|
|
11
|
+
import type { Report } from "./report";
|
|
12
|
+
import { forEachBlock, readContent } from "./walk";
|
|
13
|
+
|
|
14
|
+
/** v7's random matcher, under each name v7 saved it with. */
|
|
15
|
+
const RANDOM_MATCHERS = new Set([
|
|
16
|
+
"website/matchers/random.ts",
|
|
17
|
+
"website/matchers/random",
|
|
18
|
+
"$live/matchers/MatchRandom.ts",
|
|
19
|
+
]);
|
|
20
|
+
|
|
21
|
+
/** A date rule: v7's names (renamed to `date` by the content step) and v8's prerelease one. */
|
|
22
|
+
const DATE_RULES = new Set(["date", "website/matchers/date.ts", "$live/matchers/MatchDate.ts"]);
|
|
23
|
+
|
|
24
|
+
export const RUN_AN_AB_TEST = "/next/matchers-and-variants#run-an-a-b-test";
|
|
25
|
+
export const SCHEDULE_A_CAMPAIGN = "/next/matchers-and-variants#schedule-a-campaign";
|
|
26
|
+
|
|
27
|
+
const quoted = (names: Iterable<string>) =>
|
|
28
|
+
[...names]
|
|
29
|
+
.sort()
|
|
30
|
+
.map((n) => `"${n}"`)
|
|
31
|
+
.join(", ");
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Reports v7's random matchers and every date rule (v7's, or the prerelease
|
|
35
|
+
* `date`, which no longer exists): one "Left to do" line each, pointing at
|
|
36
|
+
* the docs. Changes no file.
|
|
37
|
+
*/
|
|
38
|
+
export function reportTestsAndDates(root: string, report: Report): void {
|
|
39
|
+
const { blocks, files } = readContent(root);
|
|
40
|
+
const tests = new Set<string>();
|
|
41
|
+
const dates = new Set<string>();
|
|
42
|
+
for (const [entry, block] of Object.entries(blocks)) {
|
|
43
|
+
if (RANDOM_MATCHERS.has(block.__resolveType as string)) {
|
|
44
|
+
tests.add(entry);
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
forEachBlock(block, (node) => {
|
|
48
|
+
if (RANDOM_MATCHERS.has(node.__resolveType)) tests.add(entry);
|
|
49
|
+
else if (DATE_RULES.has(node.__resolveType)) dates.add(entry);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
if (tests.size > 0) {
|
|
53
|
+
report.manual.push({
|
|
54
|
+
step: "content",
|
|
55
|
+
subject: "A/B tests",
|
|
56
|
+
message: `v7's random matchers (in ${quoted([...tests].map((n) => files[n] ?? n))}) weren't moved: put each test in the saved block experiments (type split-traffic) under its saved-block name, so visitors keep their groups and results carry over, and point its rules at { "__resolveType": "experiment", "name": … } (Run an A/B test, ${RUN_AN_AB_TEST})`,
|
|
57
|
+
});
|
|
58
|
+
reportAssignment(root, report);
|
|
59
|
+
}
|
|
60
|
+
if (dates.size > 0) {
|
|
61
|
+
report.manual.push({
|
|
62
|
+
step: "content",
|
|
63
|
+
subject: "date rules",
|
|
64
|
+
message: `date rules (in ${quoted([...dates].map((n) => files[n] ?? n))}) weren't moved, and deco check rejects them until they are: put each window in the saved block campaigns (type calendar), each start and end a date and time with the store's offset (like 2026-11-27T00:00-03:00: v7 read a date-time without one in the server's time zone, and deco check rejects it), and write each rule as { "__resolveType": "campaign", "name": … } naming its campaign (a prerelease { "__resolveType": "date", "campaign": … } becomes that rule with the same name) (Schedule a campaign, ${SCHEDULE_A_CAMPAIGN})`,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Who hands the visitor to the client, by binding: without one every test is off. */
|
|
70
|
+
function reportAssignment(root: string, report: Report): void {
|
|
71
|
+
const framework = siteFramework(root);
|
|
72
|
+
if (framework === "tanstack") return; // createDecoWorker reads the visitor on every page request.
|
|
73
|
+
report.manual.push({
|
|
74
|
+
step: "content",
|
|
75
|
+
subject: "experiments",
|
|
76
|
+
message:
|
|
77
|
+
framework === "nextjs"
|
|
78
|
+
? "decide the tests in proxy.ts: draftProxy from @decocms/nextjs/proxy does it, or decideVisitor, decideAssignments, visitorRequestHeaders, assignmentsRequestHeaders and applyVisitor next to the draft calls; the catch-all page's bindDraft and contentClient(cms) then build cms.client({ version, experiments, campaigns }) from what the proxy decided"
|
|
79
|
+
: "hand the visitor to the client per request: const { visitor, cookie } = readVisitor(request) from @decocms/blocks/experiments, cms.client({ visitor, ...(await cms.readVersion(request)) }), and the cookie on the response when it isn't null and the request isn't a preview (/next/built-in-blocks#split-traffic); until then every test is off",
|
|
80
|
+
});
|
|
81
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/** Which v7 framework binding the site ran on, from its `package.json`. */
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { isPlainObject } from "./walk";
|
|
5
|
+
|
|
6
|
+
export type Framework = "tanstack" | "nextjs";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* `"tanstack"` when the site depends on `@decocms/tanstack`, `"nextjs"` on
|
|
10
|
+
* `@decocms/nextjs`, else `undefined` (a native app, a FastStore store that
|
|
11
|
+
* isn't ejected). Each moves to the binding of the same name in v8.
|
|
12
|
+
*/
|
|
13
|
+
export function siteFramework(root: string): Framework | undefined {
|
|
14
|
+
try {
|
|
15
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(root, "package.json"), "utf8"));
|
|
16
|
+
const has = (name: string) =>
|
|
17
|
+
["dependencies", "devDependencies"].some(
|
|
18
|
+
(field) => isPlainObject(pkg[field]) && Object.hasOwn(pkg[field], name),
|
|
19
|
+
);
|
|
20
|
+
if (has("@decocms/tanstack")) return "tanstack";
|
|
21
|
+
if (has("@decocms/nextjs")) return "nextjs";
|
|
22
|
+
} catch {
|
|
23
|
+
// No readable package.json: no binding.
|
|
24
|
+
}
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The `@decocms/blocks` 7.x version the site ran: the installed copy's, else
|
|
30
|
+
* the lowest version its `package.json` range names; `undefined` when neither
|
|
31
|
+
* is a 7.x version. v7's image URLs changed across 7.x releases.
|
|
32
|
+
*/
|
|
33
|
+
export function siteBlocksVersion(root: string): string | undefined {
|
|
34
|
+
const v7 = (v: unknown) =>
|
|
35
|
+
typeof v === "string" ? /(?:^|[^\d.])(7\.\d+\.\d+)/.exec(v)?.[1] : undefined;
|
|
36
|
+
try {
|
|
37
|
+
const installed = JSON.parse(
|
|
38
|
+
fs.readFileSync(
|
|
39
|
+
path.join(root, "node_modules", "@decocms", "blocks", "package.json"),
|
|
40
|
+
"utf8",
|
|
41
|
+
),
|
|
42
|
+
);
|
|
43
|
+
const version = v7(installed.version);
|
|
44
|
+
if (version) return version;
|
|
45
|
+
} catch {
|
|
46
|
+
// Not installed: the range in package.json.
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(root, "package.json"), "utf8"));
|
|
50
|
+
for (const field of ["dependencies", "devDependencies"]) {
|
|
51
|
+
const version = isPlainObject(pkg[field]) ? v7(pkg[field]["@decocms/blocks"]) : undefined;
|
|
52
|
+
if (version) return version;
|
|
53
|
+
}
|
|
54
|
+
} catch {
|
|
55
|
+
// No readable package.json.
|
|
56
|
+
}
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** The v8 version every package of the release shares: blocks and both bindings. */
|
|
61
|
+
export const V8_RANGE = "^8.4.0";
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A site's own copy of v7's image helper (`hooks/Image.tsx` from
|
|
3
|
+
* `@decocms/blocks` 7.x, vendored into `src/` and sometimes edited): its URLs
|
|
4
|
+
* are what the site serves, so the `decoCdn` options that reproduce them are
|
|
5
|
+
* read from the copy, not from the release the site's `package.json` names.
|
|
6
|
+
* The rules read are the ones that changed across 7.x releases (or that a
|
|
7
|
+
* site edited): the CDN domain and quality it starts with, whether the Deco
|
|
8
|
+
* asset hosts are stripped anywhere or only at the start, how decoims.com
|
|
9
|
+
* sources are treated, and Nuvemshop's fixed sizes.
|
|
10
|
+
*/
|
|
11
|
+
import fs from "node:fs";
|
|
12
|
+
import path from "node:path";
|
|
13
|
+
import ts from "typescript";
|
|
14
|
+
|
|
15
|
+
const SOURCE = /\.(tsx?|mts|cts)$/;
|
|
16
|
+
const CLOUDFLARE_CDNS = new Set(["assets.decocms.com", "decoims.com"]);
|
|
17
|
+
export const DEFAULT_DOMAIN = "assets.decocms.com";
|
|
18
|
+
|
|
19
|
+
export interface ImageCopyRules {
|
|
20
|
+
/** `imageCdnDomain`'s initial value. */
|
|
21
|
+
domain: string;
|
|
22
|
+
/** `imageQuality`'s initial value, if any. */
|
|
23
|
+
quality?: string;
|
|
24
|
+
/** `"anywhere"`: `.replace(DECO_CACHE_URL, "")`; `"leading"`: an anchored regex. */
|
|
25
|
+
stripAssetHosts: "anywhere" | "leading";
|
|
26
|
+
/**
|
|
27
|
+
* decoims.com sources: `"none"` (kept whole), `"cloudflare"` (stripped on
|
|
28
|
+
* the Cloudflare CDNs, v7 from 7.71.5), `"always"` (in the anchored asset
|
|
29
|
+
* regex, v7 7.71.4).
|
|
30
|
+
*/
|
|
31
|
+
decoims: "none" | "cloudflare" | "always";
|
|
32
|
+
/** v7's VTEX catalog rule (`vtexCatalog()`), Shopify's (`shopifyCdn()`), Nuvemshop's fixed sizes. */
|
|
33
|
+
vtex: boolean;
|
|
34
|
+
shopify: boolean;
|
|
35
|
+
nuvemshop: boolean;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface ImageCopy {
|
|
39
|
+
/** Path from the site root. */
|
|
40
|
+
file: string;
|
|
41
|
+
/** The rules read from the copy, or null when it doesn't have v7's shape. */
|
|
42
|
+
rules: ImageCopyRules | null;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const stripScheme = (d: string) => d.replace(/^https?:\/\//, "").replace(/\/+$/, "");
|
|
46
|
+
|
|
47
|
+
/** Whether `text` defines v7's image helper (not just imports it). */
|
|
48
|
+
export function isImageCopy(text: string): boolean {
|
|
49
|
+
return (
|
|
50
|
+
/(?:function\s+getOptimizedMediaUrl\b|\bgetOptimizedMediaUrl\s*=\s*(?:\(|function))/.test(
|
|
51
|
+
text,
|
|
52
|
+
) && /assets\\?\.decocache\\?\.com/.test(text)
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** The URL rules of a copy of v7's image helper, or null when they can't be read. */
|
|
57
|
+
export function readImageCopy(text: string): ImageCopyRules | null {
|
|
58
|
+
const domain = /\blet\s+imageCdnDomain(?:\s*:\s*[^=]+)?\s*=\s*["'`]([^"'`]+)["'`]/.exec(
|
|
59
|
+
text,
|
|
60
|
+
)?.[1];
|
|
61
|
+
if (!domain) return null;
|
|
62
|
+
// The CDN's own URLs are always shown relative; a copy without that check is not v7's.
|
|
63
|
+
if (!/startsWith\(\s*(?:cdnPrefix|`https:\/\/\$\{imageCdnDomain\}\/`)\s*\)/.test(text))
|
|
64
|
+
return null;
|
|
65
|
+
const anchored = /\^https:\\\/\\\/\(\?:assets\\\.decocache\\\.com[^/\n]*/.exec(text)?.[0];
|
|
66
|
+
const anywhere =
|
|
67
|
+
/\.replace\(\s*(?:DECO_CACHE_URL|["'`]https:\/\/assets\.decocache\.com\/["'`])\s*,/.test(text);
|
|
68
|
+
if (!anchored && !anywhere) return null;
|
|
69
|
+
const quality = /\blet\s+imageQuality(?:\s*:\s*[^=]+)?\s*=\s*["'`](\w+)["'`]/.exec(text)?.[1];
|
|
70
|
+
const decoims =
|
|
71
|
+
anchored?.includes("decoims\\.com") === true
|
|
72
|
+
? "always"
|
|
73
|
+
: /CLOUDFLARE_CDNS\.has\(\s*imageCdnDomain\s*\)/.test(text) && /decoims\\\.com/.test(text)
|
|
74
|
+
? "cloudflare"
|
|
75
|
+
: /decoims\\\.com/.test(text)
|
|
76
|
+
? null
|
|
77
|
+
: "none";
|
|
78
|
+
if (decoims === null) return null;
|
|
79
|
+
return {
|
|
80
|
+
domain: stripScheme(domain),
|
|
81
|
+
...(quality ? { quality } : {}),
|
|
82
|
+
stripAssetHosts: anchored ? "leading" : "anywhere",
|
|
83
|
+
decoims,
|
|
84
|
+
vtex: /vteximg|vtexassets/.test(text),
|
|
85
|
+
shopify: text.includes("cdn.shopify.com"),
|
|
86
|
+
nuvemshop: text.includes("mitiendanube"),
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* The `decoCdn` options (besides the providers' order) that reproduce a
|
|
92
|
+
* copy's URLs. `registered` is what the site passes the copy's
|
|
93
|
+
* `registerImageCdnDomain`/`registerImageQuality` (a string literal), which
|
|
94
|
+
* overrides the copy's initial values; `null` when it passes something else,
|
|
95
|
+
* left as `domain`/`quality` for a person to fill in.
|
|
96
|
+
*/
|
|
97
|
+
export function copyDecoCdnOptions(
|
|
98
|
+
rules: ImageCopyRules,
|
|
99
|
+
registered: { domain?: string | null; quality?: string | null } = {},
|
|
100
|
+
): string {
|
|
101
|
+
const parts: string[] = [];
|
|
102
|
+
const domain = registered.domain === undefined ? rules.domain : registered.domain;
|
|
103
|
+
if (domain === null) parts.push("domain");
|
|
104
|
+
else if (stripScheme(domain) !== DEFAULT_DOMAIN) parts.push(`domain: "${stripScheme(domain)}"`);
|
|
105
|
+
const quality = registered.quality === undefined ? rules.quality : registered.quality;
|
|
106
|
+
if (quality === null) parts.push("quality");
|
|
107
|
+
else if (quality) parts.push(`quality: "${quality}"`);
|
|
108
|
+
parts.push('sources: "all"');
|
|
109
|
+
// stripAssetHosts is left at decoCdn's default, "leading", for every copy: a
|
|
110
|
+
// copy that stripped the asset hosts anywhere moves to "leading" too
|
|
111
|
+
// (approved, PO 2026-10-15), and `leadingStripChanges` counts the URLs that changes.
|
|
112
|
+
// decoCdn's default: decoims.com on the Cloudflare CDNs (but not the CDN's own host).
|
|
113
|
+
if (domain !== null) {
|
|
114
|
+
const host = stripScheme(domain);
|
|
115
|
+
const fallback = CLOUDFLARE_CDNS.has(host) && host !== "decoims.com" ? ["decoims.com"] : [];
|
|
116
|
+
const copy =
|
|
117
|
+
rules.decoims === "none"
|
|
118
|
+
? []
|
|
119
|
+
: rules.decoims === "always"
|
|
120
|
+
? host === "decoims.com"
|
|
121
|
+
? []
|
|
122
|
+
: ["decoims.com"]
|
|
123
|
+
: fallback;
|
|
124
|
+
if (copy.join() !== fallback.join()) parts.push(`legacyHosts: ${JSON.stringify(copy)}`);
|
|
125
|
+
} else if (rules.decoims !== "cloudflare") {
|
|
126
|
+
parts.push(rules.decoims === "none" ? "legacyHosts: []" : 'legacyHosts: ["decoims.com"]');
|
|
127
|
+
}
|
|
128
|
+
return parts.join(", ");
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function listSources(dir: string): string[] {
|
|
132
|
+
if (!fs.existsSync(dir)) return [];
|
|
133
|
+
return fs
|
|
134
|
+
.readdirSync(dir, { recursive: true, withFileTypes: true })
|
|
135
|
+
.filter((d) => d.isFile() && SOURCE.test(d.name) && !d.name.endsWith(".d.ts"))
|
|
136
|
+
.map((d) => path.join(d.parentPath, d.name))
|
|
137
|
+
.filter((f) => !f.split(path.sep).includes("node_modules") && !/\.test\.tsx?$/.test(f))
|
|
138
|
+
.sort();
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* What the site's code passes to `name(…)`: the string literal, null for
|
|
143
|
+
* anything else (or different values), undefined when it is never called.
|
|
144
|
+
*/
|
|
145
|
+
function registeredValue(files: ts.SourceFile[], name: string): string | null | undefined {
|
|
146
|
+
const values = new Set<string | null>();
|
|
147
|
+
const visit = (node: ts.Node): void => {
|
|
148
|
+
if (ts.isCallExpression(node)) {
|
|
149
|
+
const callee = node.expression;
|
|
150
|
+
const called = ts.isIdentifier(callee)
|
|
151
|
+
? callee.text
|
|
152
|
+
: ts.isPropertyAccessExpression(callee)
|
|
153
|
+
? callee.name.text
|
|
154
|
+
: undefined;
|
|
155
|
+
if (called === name) {
|
|
156
|
+
const [arg] = node.arguments;
|
|
157
|
+
values.add(arg && ts.isStringLiteralLike(arg) ? arg.text : null);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
ts.forEachChild(node, visit);
|
|
161
|
+
};
|
|
162
|
+
for (const file of files) visit(file);
|
|
163
|
+
if (values.size === 0) return undefined;
|
|
164
|
+
return values.size === 1 ? [...values][0] : null;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** The site's copies of v7's image helper under `src/`, in path order. */
|
|
168
|
+
export function findImageCopies(root: string): {
|
|
169
|
+
copies: ImageCopy[];
|
|
170
|
+
registered: { domain?: string | null; quality?: string | null };
|
|
171
|
+
} {
|
|
172
|
+
const parsed: ts.SourceFile[] = [];
|
|
173
|
+
const copies: ImageCopy[] = [];
|
|
174
|
+
for (const file of listSources(path.join(root, "src"))) {
|
|
175
|
+
const text = fs.readFileSync(file, "utf8");
|
|
176
|
+
if (/registerImage(?:CdnDomain|Quality)\(/.test(text)) {
|
|
177
|
+
parsed.push(
|
|
178
|
+
ts.createSourceFile(
|
|
179
|
+
file,
|
|
180
|
+
text,
|
|
181
|
+
ts.ScriptTarget.Latest,
|
|
182
|
+
false,
|
|
183
|
+
file.endsWith("x") ? ts.ScriptKind.TSX : ts.ScriptKind.TS,
|
|
184
|
+
),
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
if (isImageCopy(text)) {
|
|
188
|
+
copies.push({
|
|
189
|
+
file: path.relative(root, file).split(path.sep).join("/"),
|
|
190
|
+
rules: readImageCopy(text),
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
return {
|
|
195
|
+
copies,
|
|
196
|
+
registered: {
|
|
197
|
+
domain: registeredValue(parsed, "registerImageCdnDomain"),
|
|
198
|
+
quality: registeredValue(parsed, "registerImageQuality"),
|
|
199
|
+
},
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const DECO_CACHE_URL = "https://assets.decocache.com/";
|
|
204
|
+
const DECO_S3_URL = "https://deco-sites-assets.s3.sa-east-1.amazonaws.com/";
|
|
205
|
+
const LEADING_ASSET_HOST =
|
|
206
|
+
/^https:\/\/(?:assets\.decocache\.com|deco-sites-assets\.s3\.sa-east-1\.amazonaws\.com)\//;
|
|
207
|
+
const URL_IN_TEXT = /https?:\/\/[^\s"'`<>()\\]+/g;
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Whether decoCdn's `stripAssetHosts: "leading"` (its default) gives `src` a
|
|
211
|
+
* different source than v7's strip-anywhere did (`.replace(DECO_CACHE_URL, "")`,
|
|
212
|
+
* then the S3 bucket): true for a URL that merely contains an asset URL,
|
|
213
|
+
* such as `https://other.host/https://assets.decocache.com/…`.
|
|
214
|
+
*/
|
|
215
|
+
export function changedByLeadingStrip(src: string): boolean {
|
|
216
|
+
// Both drop the query afterwards, as decoCdn does.
|
|
217
|
+
const anywhere = src.replace(DECO_CACHE_URL, "").replace(DECO_S3_URL, "").split("?")[0];
|
|
218
|
+
return anywhere !== src.replace(LEADING_ASSET_HOST, "").split("?")[0];
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
export interface LeadingStripChange {
|
|
222
|
+
/** Path from the site root. */
|
|
223
|
+
file: string;
|
|
224
|
+
url: string;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function stringsOf(value: unknown, out: string[]): string[] {
|
|
228
|
+
if (typeof value === "string") out.push(value);
|
|
229
|
+
else if (Array.isArray(value)) for (const v of value) stringsOf(v, out);
|
|
230
|
+
else if (value && typeof value === "object")
|
|
231
|
+
for (const v of Object.values(value)) stringsOf(v, out);
|
|
232
|
+
return out;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* The URLs in the saved content (`.deco/blocks`) and in `src/` whose image
|
|
237
|
+
* source changes when the asset hosts are stripped only at the start, for a
|
|
238
|
+
* site whose v7 image code stripped them anywhere. One entry per URL and file.
|
|
239
|
+
*/
|
|
240
|
+
export function leadingStripChanges(root: string): LeadingStripChange[] {
|
|
241
|
+
const found: LeadingStripChange[] = [];
|
|
242
|
+
const seen = new Set<string>();
|
|
243
|
+
const add = (file: string, texts: string[]) => {
|
|
244
|
+
const rel = path.relative(root, file).split(path.sep).join("/");
|
|
245
|
+
for (const text of texts) {
|
|
246
|
+
if (!text.includes(DECO_CACHE_URL) && !text.includes(DECO_S3_URL)) continue;
|
|
247
|
+
for (const [url] of text.matchAll(URL_IN_TEXT)) {
|
|
248
|
+
const key = `${rel}\0${url}`;
|
|
249
|
+
if (seen.has(key) || !changedByLeadingStrip(url)) continue;
|
|
250
|
+
seen.add(key);
|
|
251
|
+
found.push({ file: rel, url });
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
const blocks = path.join(root, ".deco", "blocks");
|
|
256
|
+
if (fs.existsSync(blocks)) {
|
|
257
|
+
const files = fs
|
|
258
|
+
.readdirSync(blocks, { recursive: true, withFileTypes: true })
|
|
259
|
+
.filter((d) => d.isFile() && d.name.endsWith(".json"))
|
|
260
|
+
.map((d) => path.join(d.parentPath, d.name))
|
|
261
|
+
.sort();
|
|
262
|
+
for (const file of files) {
|
|
263
|
+
const text = fs.readFileSync(file, "utf8");
|
|
264
|
+
let parsed: unknown;
|
|
265
|
+
try {
|
|
266
|
+
parsed = JSON.parse(text);
|
|
267
|
+
} catch {
|
|
268
|
+
parsed = text;
|
|
269
|
+
}
|
|
270
|
+
add(file, stringsOf(parsed, []));
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
for (const file of listSources(path.join(root, "src")))
|
|
274
|
+
add(file, [fs.readFileSync(file, "utf8")]);
|
|
275
|
+
return found;
|
|
276
|
+
}
|