@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
package/dist/v8/pin.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type IndexedContent } from "./contentIndex.ts";
|
|
2
|
+
import type { ForcedVariant } from "./types.ts";
|
|
3
|
+
/** What a client is handed to read: the current index, the previous one, a draft's forced variants. */
|
|
4
|
+
export interface Selection {
|
|
5
|
+
current: IndexedContent;
|
|
6
|
+
previous?: IndexedContent;
|
|
7
|
+
variants?: readonly ForcedVariant[];
|
|
8
|
+
}
|
|
9
|
+
export declare class Pin {
|
|
10
|
+
#private;
|
|
11
|
+
readonly content: IndexedContent;
|
|
12
|
+
constructor(content: IndexedContent, variants?: readonly ForcedVariant[]);
|
|
13
|
+
get aliases(): Readonly<Record<string, string>> | undefined;
|
|
14
|
+
has(name: string): boolean;
|
|
15
|
+
/** The body of a name the pinned index has. Rejects with `LOADER_FAILED` when it can't be fetched. */
|
|
16
|
+
body(name: string, path?: (string | number)[]): Promise<unknown>;
|
|
17
|
+
/**
|
|
18
|
+
* One parallel wave of every body `names` need that isn't pinned yet: an
|
|
19
|
+
* LRU hit is pinned at once, the rest are fetched. Never rejects; a failure
|
|
20
|
+
* is remembered for the body's later use.
|
|
21
|
+
*/
|
|
22
|
+
wave(names: readonly string[]): Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
/** The walk a request starts from: its page (when known) plus the redirects block. */
|
|
25
|
+
export declare function rootsOf(content: IndexedContent, name: string | undefined): string[];
|
|
26
|
+
/**
|
|
27
|
+
* The index a request pins (contract §3.4 rule 1): the current one when its
|
|
28
|
+
* walk is cached, when there is no previous index, or for a draft; the
|
|
29
|
+
* previous one when its walk is cached and the current one's isn't (and the
|
|
30
|
+
* page has the same path in both), warming the current one's missing blocks in
|
|
31
|
+
* the background.
|
|
32
|
+
*/
|
|
33
|
+
export declare function choosePin(selection: Selection, name: string | undefined): Pin;
|
|
34
|
+
//# sourceMappingURL=pin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pin.d.ts","sourceRoot":"","sources":["../../src/v8/pin.ts"],"names":[],"mappings":"AAaA,OAAO,EAIL,KAAK,cAAc,EAGpB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGhD,uGAAuG;AACvG,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,cAAc,CAAC;IACxB,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,QAAQ,CAAC,EAAE,SAAS,aAAa,EAAE,CAAC;CACrC;AAED,qBAAa,GAAG;;IACd,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;IASjC,YAAY,OAAO,EAAE,cAAc,EAAE,QAAQ,CAAC,EAAE,SAAS,aAAa,EAAE,EAGvE;IAED,IAAI,OAAO,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,SAAS,CAE1D;IAED,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEzB;IAED,sGAAsG;IACtG,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAWnE;IAED;;;;OAIG;IACG,IAAI,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAgBlD;CAiCF;AAED,sFAAsF;AACtF,wBAAgB,OAAO,CAAC,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,EAAE,CAKnF;AAYD;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,GAAG,CAyB7E"}
|
package/dist/v8/pin.js
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What one request reads (see /next/hosted-releases-internals): the index it
|
|
3
|
+
* pinned and every body it fetched, for its whole life. Lazy and streamed
|
|
4
|
+
* sections and names read at run time use the same data, and LRU eviction
|
|
5
|
+
* can't pull a body out mid-request. Whether a name exists comes only from the
|
|
6
|
+
* pinned index; a body that isn't pinned is an awaited fetch by its hash.
|
|
7
|
+
*
|
|
8
|
+
* `choosePin` is the previous-index rule: after a publish, a request whose
|
|
9
|
+
* subtree under the new index has blocks missing, while its subtree under the
|
|
10
|
+
* previous index is all cached, is served on the previous index, and the
|
|
11
|
+
* missing hashes are fetched in the background. A draft never is.
|
|
12
|
+
*/
|
|
13
|
+
import { runInBackground } from "./background.js";
|
|
14
|
+
import { bodyInMemory, entryOf, hasEntry, redirectsBlockOf, walk, } from "./contentIndex.js";
|
|
15
|
+
import { errors } from "./errors.js";
|
|
16
|
+
import { forceBody } from "./variants.js";
|
|
17
|
+
export class Pin {
|
|
18
|
+
content;
|
|
19
|
+
#variants;
|
|
20
|
+
/** Bodies this request fetched or found cached, by hash. */
|
|
21
|
+
#bodies = new Map();
|
|
22
|
+
/** Fetches that failed in this request, by hash: every later use fails fast. */
|
|
23
|
+
#failed = new Map();
|
|
24
|
+
/** Bodies in flight or read, by name (forced variants applied once). */
|
|
25
|
+
#byName = new Map();
|
|
26
|
+
constructor(content, variants) {
|
|
27
|
+
this.content = content;
|
|
28
|
+
this.#variants = variants !== undefined && variants.length > 0 ? variants : undefined;
|
|
29
|
+
}
|
|
30
|
+
get aliases() {
|
|
31
|
+
return this.content.aliases;
|
|
32
|
+
}
|
|
33
|
+
has(name) {
|
|
34
|
+
return hasEntry(this.content, name);
|
|
35
|
+
}
|
|
36
|
+
/** The body of a name the pinned index has. Rejects with `LOADER_FAILED` when it can't be fetched. */
|
|
37
|
+
body(name, path = []) {
|
|
38
|
+
let pending = this.#byName.get(name);
|
|
39
|
+
if (pending === undefined) {
|
|
40
|
+
pending = this.#read(name).then((body) => this.#variants === undefined ? body : forceBody(name, body, this.#variants, this.aliases));
|
|
41
|
+
this.#byName.set(name, pending);
|
|
42
|
+
}
|
|
43
|
+
return pending.catch((error) => {
|
|
44
|
+
throw errors.blockUnavailable(name, path, error);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* One parallel wave of every body `names` need that isn't pinned yet: an
|
|
49
|
+
* LRU hit is pinned at once, the rest are fetched. Never rejects; a failure
|
|
50
|
+
* is remembered for the body's later use.
|
|
51
|
+
*/
|
|
52
|
+
async wave(names) {
|
|
53
|
+
const source = this.content.source;
|
|
54
|
+
if (source === undefined)
|
|
55
|
+
return;
|
|
56
|
+
const fetches = [];
|
|
57
|
+
for (const name of names) {
|
|
58
|
+
if (bodyInMemory(this.content, name))
|
|
59
|
+
continue;
|
|
60
|
+
const hash = entryOf(this.content, name)?.version;
|
|
61
|
+
if (hash === undefined || this.#bodies.has(hash) || this.#failed.has(hash))
|
|
62
|
+
continue;
|
|
63
|
+
const cached = source.peek(hash);
|
|
64
|
+
if (cached !== undefined) {
|
|
65
|
+
this.#bodies.set(hash, cached);
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
fetches.push(this.#fetch(hash, name).catch(() => { }));
|
|
69
|
+
}
|
|
70
|
+
await Promise.all(fetches);
|
|
71
|
+
}
|
|
72
|
+
async #read(name) {
|
|
73
|
+
const content = this.content;
|
|
74
|
+
if (content.held?.has(name))
|
|
75
|
+
return content.held.get(name);
|
|
76
|
+
const entry = entryOf(content, name);
|
|
77
|
+
if (entry === undefined)
|
|
78
|
+
return undefined;
|
|
79
|
+
if (entry.data !== undefined)
|
|
80
|
+
return entry.data;
|
|
81
|
+
const hash = entry.version;
|
|
82
|
+
if (this.#bodies.has(hash))
|
|
83
|
+
return this.#bodies.get(hash);
|
|
84
|
+
if (this.#failed.has(hash))
|
|
85
|
+
throw this.#failed.get(hash);
|
|
86
|
+
const source = content.source;
|
|
87
|
+
if (source === undefined)
|
|
88
|
+
return undefined;
|
|
89
|
+
const cached = source.peek(hash);
|
|
90
|
+
if (cached !== undefined) {
|
|
91
|
+
this.#bodies.set(hash, cached);
|
|
92
|
+
return cached;
|
|
93
|
+
}
|
|
94
|
+
return this.#fetch(hash, name);
|
|
95
|
+
}
|
|
96
|
+
#fetch(hash, name) {
|
|
97
|
+
return this.content.source.get(hash, name).then((body) => {
|
|
98
|
+
this.#bodies.set(hash, body);
|
|
99
|
+
return body;
|
|
100
|
+
}, (error) => {
|
|
101
|
+
this.#failed.set(hash, error);
|
|
102
|
+
throw error;
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/** The walk a request starts from: its page (when known) plus the redirects block. */
|
|
107
|
+
export function rootsOf(content, name) {
|
|
108
|
+
const roots = name !== undefined ? [name] : [];
|
|
109
|
+
const redirects = redirectsBlockOf(content);
|
|
110
|
+
if (redirects !== null && redirects !== name)
|
|
111
|
+
roots.push(redirects);
|
|
112
|
+
return roots;
|
|
113
|
+
}
|
|
114
|
+
/** Every body of `names` is in memory or in the LRU. */
|
|
115
|
+
function allCached(content, names) {
|
|
116
|
+
const source = content.source;
|
|
117
|
+
return names.every((name) => {
|
|
118
|
+
if (bodyInMemory(content, name))
|
|
119
|
+
return true;
|
|
120
|
+
const hash = entryOf(content, name)?.version;
|
|
121
|
+
return hash !== undefined && source?.peek(hash) !== undefined;
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* The index a request pins (contract §3.4 rule 1): the current one when its
|
|
126
|
+
* walk is cached, when there is no previous index, or for a draft; the
|
|
127
|
+
* previous one when its walk is cached and the current one's isn't (and the
|
|
128
|
+
* page has the same path in both), warming the current one's missing blocks in
|
|
129
|
+
* the background.
|
|
130
|
+
*/
|
|
131
|
+
export function choosePin(selection, name) {
|
|
132
|
+
const { current, previous, variants } = selection;
|
|
133
|
+
const onCurrent = () => new Pin(current, variants);
|
|
134
|
+
if (current.draft || previous === undefined || current.source === undefined)
|
|
135
|
+
return onCurrent();
|
|
136
|
+
const fresh = walk(current, rootsOf(current, name));
|
|
137
|
+
if (allCached(current, fresh))
|
|
138
|
+
return onCurrent();
|
|
139
|
+
if (name !== undefined) {
|
|
140
|
+
const now = entryOf(current, name);
|
|
141
|
+
const before = entryOf(previous, name);
|
|
142
|
+
if (now === undefined || before === undefined || now.meta?.path !== before.meta?.path) {
|
|
143
|
+
return onCurrent();
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
if (!allCached(previous, walk(previous, rootsOf(previous, name))))
|
|
147
|
+
return onCurrent();
|
|
148
|
+
const source = current.source;
|
|
149
|
+
const missing = fresh.filter((n) => !bodyInMemory(current, n));
|
|
150
|
+
runInBackground(() => Promise.all(missing.map((n) => {
|
|
151
|
+
const hash = current.blocks[n]?.version;
|
|
152
|
+
return source.peek(hash) !== undefined ? undefined : source.get(hash, n).catch(() => { });
|
|
153
|
+
})));
|
|
154
|
+
return new Pin(previous, variants);
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=pin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pin.js","sourceRoot":"","sources":["../../src/v8/pin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EACL,YAAY,EACZ,OAAO,EACP,QAAQ,EAER,gBAAgB,EAChB,IAAI,GACL,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAS1C,MAAM,OAAO,GAAG;IACL,OAAO,CAAiB;IACxB,SAAS,CAAuC;IACzD,4DAA4D;IACnD,OAAO,GAAG,IAAI,GAAG,EAAmB,CAAC;IAC9C,gFAAgF;IACvE,OAAO,GAAG,IAAI,GAAG,EAAmB,CAAC;IAC9C,wEAAwE;IAC/D,OAAO,GAAG,IAAI,GAAG,EAA4B,CAAC;IAEvD,YAAY,OAAuB,EAAE,QAAmC;QACtE,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,QAAQ,KAAK,SAAS,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;IACxF,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;IAC9B,CAAC;IAED,GAAG,CAAC,IAAY;QACd,OAAO,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACtC,CAAC;IAED,sGAAsG;IACtG,IAAI,CAAC,IAAY,EAAE,IAAI,GAAwB,EAAE;QAC/C,IAAI,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACr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,OAAO,SAAS,EAAE,CAAC;IACtF,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAC9B,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;IAC/D,eAAe,CAAC,GAAG,EAAE,CACnB,OAAO,CAAC,GAAG,CACT,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QAChB,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,OAAiB,CAAC;QAClD,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IAC3F,CAAC,CAAC,CACH,CACF,CAAC;IACF,OAAO,IAAI,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;AACrC,CAAC"}
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
* The Studio bridge: what lets Deco Studio's site editor drive a page it
|
|
3
3
|
* shows in an iframe (v7's `LiveControls`).
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* overlay
|
|
8
|
-
*
|
|
9
|
-
*
|
|
5
|
+
* The bridge answers v7's `scrollToComponent` and `editor::rerender`
|
|
6
|
+
* (same-origin navigation only). It runs no code Studio sends: Studio's own
|
|
7
|
+
* editor code (the section overlay, the HTML swap after a save) reaches the
|
|
8
|
+
* page through the Studio channel (`StudioChannel`: `deco:ready` /
|
|
9
|
+
* `deco:load`), which imports versioned modules from Studio's exact origins.
|
|
10
10
|
*
|
|
11
11
|
* In a frame it answers only messages from the parent window whose origin is
|
|
12
12
|
* one of `trustedOrigins`. On a page that isn't framed it answers no message;
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
* origin: under a test runner that proxies the site, the runner's own messages
|
|
20
20
|
* would navigate the page.
|
|
21
21
|
*
|
|
22
|
-
* An inline script, not an effect: Studio
|
|
23
|
-
* which can come before React hydrates, so the listener must exist as soon as
|
|
22
|
+
* An inline script, not an effect: Studio may post as soon as the frame
|
|
23
|
+
* loads, which can come before React hydrates, so the listener must exist as soon as
|
|
24
24
|
* the HTML is parsed. No hooks, so it renders from a Next.js Server Component
|
|
25
25
|
* as well as from a client tree. Its settings travel in `data-*` attributes;
|
|
26
26
|
* the script itself is static.
|
|
@@ -61,7 +61,7 @@ export interface StudioPageInfo {
|
|
|
61
61
|
id?: string;
|
|
62
62
|
}
|
|
63
63
|
/** The browser side. Static: everything it needs comes from the script element's attributes. */
|
|
64
|
-
export declare const STUDIO_BRIDGE_SCRIPT = "(function(){\nvar s=document.currentScript;\nif(!s||window.__decoStudioBridge)return;\nwindow.__decoStudioBridge=true;\nvar origins=[];\ntry{origins=JSON.parse(s.getAttribute(\"data-origins\")||\"[]\")}catch(e){}\nvar site=s.getAttribute(\"data-site\")||\"\";\nfunction page(){\n var all=document.querySelectorAll(\"[data-deco-page]\"),el=all.length?all[all.length-1]:null;\n if(!el||!el.getAttribute(\"data-path-template\")){el=document.querySelector(\"script[data-deco-studio-bridge]\")||s}\n return{t:el.getAttribute(\"data-path-template\")||\"\",id:el.getAttribute(\"data-page-id\")||\"\"};\n}\nfunction trusted(o){\n if(typeof o!==\"string\"||!o)return false;\n var u;\n try{u=new URL(o)}catch(e){return false}\n if(u.origin!==o)return false;\n for(var i=0;i<origins.length;i++){\n var p=origins[i];\n if(p===o)return true;\n var m=/^([a-z][a-z0-9+.-]*:)\\/\\/\\*\\.([^\\/:]+)(?::([0-9]+))?$/.exec(p);\n if(m&&u.protocol===m[1]&&u.port===(m[3]||\"\")&&u.hostname.slice(-m[2].length-1)===\".\"+m[2])return true;\n }\n return false;\n}\nif(window.self!==window.top){\n window.addEventListener(\"message\",function(e){\n if(e.source!==window.parent||!trusted(e.origin))return;\n var d=e.data;\n if(!d||typeof d!==\"object\")return;\n var a=d.args||{};\n if(d.type===\"
|
|
64
|
+
export declare const STUDIO_BRIDGE_SCRIPT = "(function(){\nvar s=document.currentScript;\nif(!s||window.__decoStudioBridge)return;\nwindow.__decoStudioBridge=true;\nvar origins=[];\ntry{origins=JSON.parse(s.getAttribute(\"data-origins\")||\"[]\")}catch(e){}\nvar site=s.getAttribute(\"data-site\")||\"\";\nfunction page(){\n var all=document.querySelectorAll(\"[data-deco-page]\"),el=all.length?all[all.length-1]:null;\n if(!el||!el.getAttribute(\"data-path-template\")){el=document.querySelector(\"script[data-deco-studio-bridge]\")||s}\n return{t:el.getAttribute(\"data-path-template\")||\"\",id:el.getAttribute(\"data-page-id\")||\"\"};\n}\nfunction trusted(o){\n if(typeof o!==\"string\"||!o)return false;\n var u;\n try{u=new URL(o)}catch(e){return false}\n if(u.origin!==o)return false;\n for(var i=0;i<origins.length;i++){\n var p=origins[i];\n if(p===o)return true;\n var m=/^([a-z][a-z0-9+.-]*:)\\/\\/\\*\\.([^\\/:]+)(?::([0-9]+))?$/.exec(p);\n if(m&&u.protocol===m[1]&&u.port===(m[3]||\"\")&&u.hostname.slice(-m[2].length-1)===\".\"+m[2])return true;\n }\n return false;\n}\nif(window.self!==window.top){\n window.addEventListener(\"message\",function(e){\n if(e.source!==window.parent||!trusted(e.origin))return;\n var d=e.data;\n if(!d||typeof d!==\"object\")return;\n var a=d.args||{};\n if(d.type===\"scrollToComponent\"){\n var id=typeof a.id===\"string\"?a.id:\"\";\n if(!id)return;\n var el=null,all=document.querySelectorAll(\"[data-manifest-key]\");\n for(var i=0;i<all.length&&!el;i++)if(all[i].getAttribute(\"data-manifest-key\")===id)el=all[i];\n el=el||document.getElementById(id);\n if(el)el.scrollIntoView({behavior:\"smooth\",block:\"center\"});\n }else if(d.type===\"editor::rerender\"){\n if(typeof a.url!==\"string\")return;\n try{var t=new URL(a.url,location.origin);if(t.origin===location.origin)location.href=t.href}catch(err){}\n }\n });\n}else if(s.hasAttribute(\"data-shortcut\")){\n document.addEventListener(\"keydown\",function(e){\n var t=e.target;\n if(e.defaultPrevented||(t&&(t.tagName===\"INPUT\"||t.tagName===\"TEXTAREA\"||t.tagName===\"SELECT\"||t.isContentEditable)))return;\n if(e.key!==\".\"&&!(e.ctrlKey&&e.shiftKey&&e.key===\"E\"))return;\n e.preventDefault();\n e.stopPropagation();\n var p=page(),h=new URL(\"https://studio.decocms.com/choose-editor\");\n h.searchParams.set(\"site\",site);\n h.searchParams.set(\"domain\",location.origin);\n if(p.id)h.searchParams.set(\"pageId\",p.id);\n h.searchParams.set(\"path\",location.pathname+location.search);\n h.searchParams.set(\"pathTemplate\",p.t||\"/*\");\n if((e.ctrlKey||e.metaKey)&&e.key===\".\"){window.open(h.toString(),\"_blank\");return}\n location.href=h.toString();\n });\n}\n})();";
|
|
65
65
|
/**
|
|
66
66
|
* Lets Studio's site editor select and edit sections on the page. Render it
|
|
67
67
|
* once, in the root layout's `<body>`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StudioBridge.d.ts","sourceRoot":"","sources":["../../../src/v8/preview/StudioBridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,EAAiB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEtD,MAAM,WAAW,iBAAiB;IAChC,qEAAqE;IACrE,IAAI,EAAE,MAAM,CAAC;IACb;;;;;OAKG;IACH,cAAc,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,oEAAoE;IACpE,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,iDAAiD;AACjD,MAAM,WAAW,cAAc;IAC7B,uFAAuF;IACvF,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,mDAAmD;IACnD,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAUD,gGAAgG;AAChG,eAAO,MAAM,oBAAoB,
|
|
1
|
+
{"version":3,"file":"StudioBridge.d.ts","sourceRoot":"","sources":["../../../src/v8/preview/StudioBridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,EAAiB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEtD,MAAM,WAAW,iBAAiB;IAChC,qEAAqE;IACrE,IAAI,EAAE,MAAM,CAAC;IACb;;;;;OAKG;IACH,cAAc,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,oEAAoE;IACpE,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,iDAAiD;AACjD,MAAM,WAAW,cAAc;IAC7B,uFAAuF;IACvF,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,mDAAmD;IACnD,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAUD,gGAAgG;AAChG,eAAO,MAAM,oBAAoB,0tFA4D3B,CAAC;AAEP;;;GAGG;AACH,wBAAgB,YAAY,CAAC,EAC3B,IAAI,EACJ,cAAc,EACd,YAAmB,EACnB,IAAI,EACJ,KAAK,GACN,EAAE,iBAAiB,GAAG,SAAS,CAgB/B;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,EAAE,YAAY,EAAE,EAAE,EAAE,EAAE,cAAc,GAAG,SAAS,CAS1E"}
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
* The Studio bridge: what lets Deco Studio's site editor drive a page it
|
|
3
3
|
* shows in an iframe (v7's `LiveControls`).
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* overlay
|
|
8
|
-
*
|
|
9
|
-
*
|
|
5
|
+
* The bridge answers v7's `scrollToComponent` and `editor::rerender`
|
|
6
|
+
* (same-origin navigation only). It runs no code Studio sends: Studio's own
|
|
7
|
+
* editor code (the section overlay, the HTML swap after a save) reaches the
|
|
8
|
+
* page through the Studio channel (`StudioChannel`: `deco:ready` /
|
|
9
|
+
* `deco:load`), which imports versioned modules from Studio's exact origins.
|
|
10
10
|
*
|
|
11
11
|
* In a frame it answers only messages from the parent window whose origin is
|
|
12
12
|
* one of `trustedOrigins`. On a page that isn't framed it answers no message;
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
* origin: under a test runner that proxies the site, the runner's own messages
|
|
20
20
|
* would navigate the page.
|
|
21
21
|
*
|
|
22
|
-
* An inline script, not an effect: Studio
|
|
23
|
-
* which can come before React hydrates, so the listener must exist as soon as
|
|
22
|
+
* An inline script, not an effect: Studio may post as soon as the frame
|
|
23
|
+
* loads, which can come before React hydrates, so the listener must exist as soon as
|
|
24
24
|
* the HTML is parsed. No hooks, so it renders from a Next.js Server Component
|
|
25
25
|
* as well as from a client tree. Its settings travel in `data-*` attributes;
|
|
26
26
|
* the script itself is static.
|
|
@@ -63,9 +63,7 @@ if(window.self!==window.top){
|
|
|
63
63
|
var d=e.data;
|
|
64
64
|
if(!d||typeof d!=="object")return;
|
|
65
65
|
var a=d.args||{};
|
|
66
|
-
if(d.type==="
|
|
67
|
-
if(typeof a.script==="string"){try{(0,eval)(a.script)}catch(err){console.error("[deco] Studio script failed:",err)}}
|
|
68
|
-
}else if(d.type==="scrollToComponent"){
|
|
66
|
+
if(d.type==="scrollToComponent"){
|
|
69
67
|
var id=typeof a.id==="string"?a.id:"";
|
|
70
68
|
if(!id)return;
|
|
71
69
|
var el=null,all=document.querySelectorAll("[data-manifest-key]");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StudioBridge.js","sourceRoot":"","sources":["../../../src/v8/preview/StudioBridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;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oB,EAAE,IAAI,EAAE,YAAY,IAAI,SAAS;QACrD,cAAc,EAAE,IAAI,EAAE,EAAE,IAAI,SAAS;QACrC,KAAK;QACL,sEAAsE;QACtE,kCAAkC;QAClC,wBAAwB,EAAE,IAAI;QAC9B,uBAAuB,EAAE,EAAE,MAAM,EAAE,oBAAoB,EAAE;KAC1D,CAAC,CAAC;AACL,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,EAAE,YAAY,EAAE,EAAE,EAAkB;IAC7D,IAAI,CAAC,YAAY;QAAE,OAAO,IAAI,CAAC;IAC/B,OAAO,aAAa,CAAC,MAAM,EAAE;QAC3B,IAAI,EAAE,WAAW;QACjB,OAAO,EAAE,YAAY;QACrB,CAAC,WAAW,CAAC,EAAE,EAAE;QACjB,oBAAoB,EAAE,YAAY;QAClC,cAAc,EAAE,EAAE,IAAI,SAAS;KAChC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Studio channel's bootstrap (protocol: `src/protocol/channel.ts`,
|
|
3
|
+
* exported for Studio from `@decocms/blocks/protocol`): a tiny inline script every page
|
|
4
|
+
* carries, production included, so code that belongs to Studio's site editor
|
|
5
|
+
* (the section wireframe, the HTML swap after a save) ships with Studio and
|
|
6
|
+
* runs inside the page only when Studio frames it. It is the only way Studio
|
|
7
|
+
* runs code in the page: the bridge evaluates no script Studio sends.
|
|
8
|
+
*
|
|
9
|
+
* The page trusts a list of Studio origins (`studioOrigins`), each one exact:
|
|
10
|
+
* no wildcard, no prefix. Framed (`window.parent !== window`), it posts
|
|
11
|
+
* `{ type: "deco:ready" }` with each trusted origin as the `targetOrigin`, so
|
|
12
|
+
* the browser delivers it only to a parent at one of them, and to no other
|
|
13
|
+
* (where the browser names the parent's origin, `location.ancestorOrigins`,
|
|
14
|
+
* the page posts only to that one, when it's trusted). It imports each module
|
|
15
|
+
* Studio names in `{ type: "deco:load", url }` once, when the message comes
|
|
16
|
+
* from the parent at exactly one of the trusted origins and the URL is on
|
|
17
|
+
* exactly the origin of that message; the module talks to that origin alone.
|
|
18
|
+
* Not framed, or with no valid origin, it does nothing (and a parent of
|
|
19
|
+
* another origin never gets the `deco:ready`, nor a message it sends an answer).
|
|
20
|
+
*
|
|
21
|
+
* An inline script, like `StudioBridge`: it listens before React hydrates, and
|
|
22
|
+
* renders from a Next.js Server Component. Studio's origins travel in a
|
|
23
|
+
* `data-*` attribute; the script itself is static. The binding owns the list
|
|
24
|
+
* (its option, its environment override, Studio's production and staging
|
|
25
|
+
* origins by default) and adds the same origins to the page's CSP
|
|
26
|
+
* `script-src` (the modules) and `frame-ancestors`; `@decocms/blocks` reads no
|
|
27
|
+
* environment. The inline script itself needs the site's CSP `nonce`.
|
|
28
|
+
*/
|
|
29
|
+
import { type ReactNode } from "react";
|
|
30
|
+
export interface StudioChannelProps {
|
|
31
|
+
/**
|
|
32
|
+
* Studio's origins (`https://studio.decocms.com`): the only origins whose
|
|
33
|
+
* messages the page accepts and whose modules it imports, each compared
|
|
34
|
+
* exactly. The binding passes them; a value that isn't an http(s) origin is
|
|
35
|
+
* dropped, and with none left the channel is off.
|
|
36
|
+
*/
|
|
37
|
+
studioOrigins: readonly string[];
|
|
38
|
+
/** The CSP nonce for the inline script, when the site sends one. */
|
|
39
|
+
nonce?: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The browser side. Static. `import(h)` is the one dynamic import (a classic
|
|
43
|
+
* script may `import()`); the module's default export gets the context.
|
|
44
|
+
*/
|
|
45
|
+
export declare const STUDIO_CHANNEL_SCRIPT = "(function(){\nvar s=document.currentScript,w=window,p=w.parent,t;\nif(!s||p===w||w.__decoStudioChannel)return;\ntry{t=JSON.parse(s.getAttribute(\"data-studio-origins\")||\"[]\")}catch(e){}\nif(!Array.isArray(t)||!t.length)return;\nw.__decoStudioChannel=true;\nvar seen={},fns=[];\nfunction send(o,m){p.postMessage(m,o)}\nw.addEventListener(\"message\",function(e){\nvar d=e.data,o=e.origin;\nif(t.indexOf(o)<0||e.source!==p||!d||typeof d.type!==\"string\")return;\nif(d.type!==\"deco:load\"){\nif(d.type.indexOf(\"deco:\")===0)return;\nfns.slice().forEach(function(l){if(l.o===o)try{l.f(d)}catch(err){console.error(\"[deco] Studio module failed:\",err)}});\nreturn}\nvar h;\nif(typeof d.url!==\"string\")return;\ntry{h=new URL(d.url)}catch(err){return}\nif(h.origin!==o)return;\nh=h.href;\nif(seen[h])return;\nseen[h]=1;\nimport(h).then(function(m){\nif(typeof m.default!==\"function\")throw new TypeError(\"no default export\");\nreturn m.default({studioOrigin:o,url:h,send:function(x){send(o,x)},on:function(f){var l={o:o,f:f};fns.push(l);return function(){var i=fns.indexOf(l);if(i>=0)fns.splice(i,1)}}})\n}).then(function(){send(o,{type:\"deco:loaded\",url:h})},function(err){\ndelete seen[h];\nsend(o,{type:\"deco:load-error\",url:h,message:String(err&&err.message||err)})})\n});\nvar a=w.location.ancestorOrigins;\n(a&&a.length?t.indexOf(a[0])<0?[]:[a[0]]:t).forEach(function(o){send(o,{type:\"deco:ready\"})});\n})();";
|
|
46
|
+
/**
|
|
47
|
+
* The Studio channel's bootstrap. Render it once, in the root layout's
|
|
48
|
+
* `<body>` (the bindings' documents do).
|
|
49
|
+
*/
|
|
50
|
+
export declare function StudioChannel({ studioOrigins, nonce }: StudioChannelProps): ReactNode;
|
|
51
|
+
//# sourceMappingURL=StudioChannel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StudioChannel.d.ts","sourceRoot":"","sources":["../../../src/v8/preview/StudioChannel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,EAAiB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEtD,MAAM,WAAW,kBAAkB;IACjC;;;;;OAKG;IACH,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,oEAAoE;IACpE,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAID;;;GAGG;AACH,eAAO,MAAM,qBAAqB,q5CA+B5B,CAAC;AAsBP;;;GAGG;AACH,wBAAgB,aAAa,CAAC,EAAE,aAAa,EAAE,KAAK,EAAE,EAAE,kBAAkB,GAAG,SAAS,CAUrF"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Studio channel's bootstrap (protocol: `src/protocol/channel.ts`,
|
|
3
|
+
* exported for Studio from `@decocms/blocks/protocol`): a tiny inline script every page
|
|
4
|
+
* carries, production included, so code that belongs to Studio's site editor
|
|
5
|
+
* (the section wireframe, the HTML swap after a save) ships with Studio and
|
|
6
|
+
* runs inside the page only when Studio frames it. It is the only way Studio
|
|
7
|
+
* runs code in the page: the bridge evaluates no script Studio sends.
|
|
8
|
+
*
|
|
9
|
+
* The page trusts a list of Studio origins (`studioOrigins`), each one exact:
|
|
10
|
+
* no wildcard, no prefix. Framed (`window.parent !== window`), it posts
|
|
11
|
+
* `{ type: "deco:ready" }` with each trusted origin as the `targetOrigin`, so
|
|
12
|
+
* the browser delivers it only to a parent at one of them, and to no other
|
|
13
|
+
* (where the browser names the parent's origin, `location.ancestorOrigins`,
|
|
14
|
+
* the page posts only to that one, when it's trusted). It imports each module
|
|
15
|
+
* Studio names in `{ type: "deco:load", url }` once, when the message comes
|
|
16
|
+
* from the parent at exactly one of the trusted origins and the URL is on
|
|
17
|
+
* exactly the origin of that message; the module talks to that origin alone.
|
|
18
|
+
* Not framed, or with no valid origin, it does nothing (and a parent of
|
|
19
|
+
* another origin never gets the `deco:ready`, nor a message it sends an answer).
|
|
20
|
+
*
|
|
21
|
+
* An inline script, like `StudioBridge`: it listens before React hydrates, and
|
|
22
|
+
* renders from a Next.js Server Component. Studio's origins travel in a
|
|
23
|
+
* `data-*` attribute; the script itself is static. The binding owns the list
|
|
24
|
+
* (its option, its environment override, Studio's production and staging
|
|
25
|
+
* origins by default) and adds the same origins to the page's CSP
|
|
26
|
+
* `script-src` (the modules) and `frame-ancestors`; `@decocms/blocks` reads no
|
|
27
|
+
* environment. The inline script itself needs the site's CSP `nonce`.
|
|
28
|
+
*/
|
|
29
|
+
import { createElement } from "react";
|
|
30
|
+
const GLOBAL = "__decoStudioChannel";
|
|
31
|
+
/**
|
|
32
|
+
* The browser side. Static. `import(h)` is the one dynamic import (a classic
|
|
33
|
+
* script may `import()`); the module's default export gets the context.
|
|
34
|
+
*/
|
|
35
|
+
export const STUDIO_CHANNEL_SCRIPT = `(function(){
|
|
36
|
+
var s=document.currentScript,w=window,p=w.parent,t;
|
|
37
|
+
if(!s||p===w||w.${GLOBAL})return;
|
|
38
|
+
try{t=JSON.parse(s.getAttribute("data-studio-origins")||"[]")}catch(e){}
|
|
39
|
+
if(!Array.isArray(t)||!t.length)return;
|
|
40
|
+
w.${GLOBAL}=true;
|
|
41
|
+
var seen={},fns=[];
|
|
42
|
+
function send(o,m){p.postMessage(m,o)}
|
|
43
|
+
w.addEventListener("message",function(e){
|
|
44
|
+
var d=e.data,o=e.origin;
|
|
45
|
+
if(t.indexOf(o)<0||e.source!==p||!d||typeof d.type!=="string")return;
|
|
46
|
+
if(d.type!=="deco:load"){
|
|
47
|
+
if(d.type.indexOf("deco:")===0)return;
|
|
48
|
+
fns.slice().forEach(function(l){if(l.o===o)try{l.f(d)}catch(err){console.error("[deco] Studio module failed:",err)}});
|
|
49
|
+
return}
|
|
50
|
+
var h;
|
|
51
|
+
if(typeof d.url!=="string")return;
|
|
52
|
+
try{h=new URL(d.url)}catch(err){return}
|
|
53
|
+
if(h.origin!==o)return;
|
|
54
|
+
h=h.href;
|
|
55
|
+
if(seen[h])return;
|
|
56
|
+
seen[h]=1;
|
|
57
|
+
import(h).then(function(m){
|
|
58
|
+
if(typeof m.default!=="function")throw new TypeError("no default export");
|
|
59
|
+
return m.default({studioOrigin:o,url:h,send:function(x){send(o,x)},on:function(f){var l={o:o,f:f};fns.push(l);return function(){var i=fns.indexOf(l);if(i>=0)fns.splice(i,1)}}})
|
|
60
|
+
}).then(function(){send(o,{type:"deco:loaded",url:h})},function(err){
|
|
61
|
+
delete seen[h];
|
|
62
|
+
send(o,{type:"deco:load-error",url:h,message:String(err&&err.message||err)})})
|
|
63
|
+
});
|
|
64
|
+
var a=w.location.ancestorOrigins;
|
|
65
|
+
(a&&a.length?t.indexOf(a[0])<0?[]:[a[0]]:t).forEach(function(o){send(o,{type:"deco:ready"})});
|
|
66
|
+
})();`;
|
|
67
|
+
/** `value` as an exact http(s) origin (`https://host[:port]`; no wildcard), or `""`. */
|
|
68
|
+
function asOrigin(value) {
|
|
69
|
+
if (typeof value !== "string")
|
|
70
|
+
return "";
|
|
71
|
+
try {
|
|
72
|
+
const url = new URL(value);
|
|
73
|
+
if (url.protocol !== "https:" && url.protocol !== "http:")
|
|
74
|
+
return "";
|
|
75
|
+
// A host name or an IP address: a URL parser accepts `*` in a host, which a
|
|
76
|
+
// CSP source would read as a wildcard.
|
|
77
|
+
if (!/^(\[[0-9a-f:.]+\]|[a-z0-9_.-]+)$/.test(url.hostname))
|
|
78
|
+
return "";
|
|
79
|
+
return value === url.origin || value === `${url.origin}/` ? url.origin : "";
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
return "";
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/** The valid origins of `list`, normalized, each once. */
|
|
86
|
+
function origins(list) {
|
|
87
|
+
return [...new Set((Array.isArray(list) ? list : []).map(asOrigin).filter(Boolean))];
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* The Studio channel's bootstrap. Render it once, in the root layout's
|
|
91
|
+
* `<body>` (the bindings' documents do).
|
|
92
|
+
*/
|
|
93
|
+
export function StudioChannel({ studioOrigins, nonce }) {
|
|
94
|
+
return createElement("script", {
|
|
95
|
+
"data-deco-studio-channel": "",
|
|
96
|
+
// Always rendered, even when off (`[]`), so the server's and the client's
|
|
97
|
+
// trees match when only one side sees the binding's environment override.
|
|
98
|
+
"data-studio-origins": JSON.stringify(origins(studioOrigins)),
|
|
99
|
+
nonce,
|
|
100
|
+
suppressHydrationWarning: true,
|
|
101
|
+
dangerouslySetInnerHTML: { __html: STUDIO_CHANNEL_SCRIPT },
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=StudioChannel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StudioChannel.js","sourceRoot":"","sources":["../../../src/v8/preview/StudioChannel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,EAAE,aAAa,EAAkB,MAAM,OAAO,CAAC;AActD,MAAM,MAAM,GAAG,qBAAqB,CAAC;AAErC;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG;;kBAEnB,MAAM;;;IAGpB,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;MA0BJ,CAAC;AAEP,wFAAwF;AACxF,SAAS,QAAQ,CAAC,KAAc;IAC9B,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,EAAE,CAAC;IACzC,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;QAC3B,IAAI,GAAG,CAAC,QAAQ,KAAK,QAAQ,IAAI,GAAG,CAAC,QAAQ,KAAK,OAAO;YAAE,OAAO,EAAE,CAAC;QACrE,4EAA4E;QAC5E,uCAAuC;QACvC,IAAI,CAAC,kCAAkC,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC;YAAE,OAAO,EAAE,CAAC;QACtE,OAAO,KAAK,KAAK,GAAG,CAAC,MAAM,IAAI,KAAK,KAAK,GAAG,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IAC9E,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC;AAED,0DAA0D;AAC1D,SAAS,OAAO,CAAC,IAAmC;IAClD,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AACvF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,EAAE,aAAa,EAAE,KAAK,EAAsB;IACxE,OAAO,aAAa,CAAC,QAAQ,EAAE;QAC7B,0BAA0B,EAAE,EAAE;QAC9B,0EAA0E;QAC1E,0EAA0E;QAC1E,qBAAqB,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;QAC7D,KAAK;QACL,wBAAwB,EAAE,IAAI;QAC9B,uBAAuB,EAAE,EAAE,MAAM,EAAE,qBAAqB,EAAE;KAC3D,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -8,7 +8,10 @@
|
|
|
8
8
|
* - `StudioBridge`: lets Studio's site editor drive the page when Studio
|
|
9
9
|
* frames it, and opens the page in Studio on "." when it isn't framed.
|
|
10
10
|
* - `StudioPage`: what a page renders to tell the bridge which page it is.
|
|
11
|
+
* - `StudioChannel`: the bootstrap through which Studio loads its own modules
|
|
12
|
+
* into the page when it frames it (protocol: `@decocms/blocks/protocol`).
|
|
11
13
|
*/
|
|
12
14
|
export { DraftBadge, type DraftBadgeProps } from "./DraftBadge.tsx";
|
|
13
15
|
export { StudioBridge, type StudioBridgeProps, StudioPage, type StudioPageInfo, } from "./StudioBridge.ts";
|
|
16
|
+
export { StudioChannel, type StudioChannelProps } from "./StudioChannel.ts";
|
|
14
17
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/v8/preview/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/v8/preview/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EACL,YAAY,EACZ,KAAK,iBAAiB,EACtB,UAAU,EACV,KAAK,cAAc,GACpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,aAAa,EAAE,KAAK,kBAAkB,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/v8/preview/index.js
CHANGED
|
@@ -8,7 +8,10 @@
|
|
|
8
8
|
* - `StudioBridge`: lets Studio's site editor drive the page when Studio
|
|
9
9
|
* frames it, and opens the page in Studio on "." when it isn't framed.
|
|
10
10
|
* - `StudioPage`: what a page renders to tell the bridge which page it is.
|
|
11
|
+
* - `StudioChannel`: the bootstrap through which Studio loads its own modules
|
|
12
|
+
* into the page when it frames it (protocol: `@decocms/blocks/protocol`).
|
|
11
13
|
*/
|
|
12
14
|
export { DraftBadge } from "./DraftBadge.js";
|
|
13
15
|
export { StudioBridge, StudioPage, } from "./StudioBridge.js";
|
|
16
|
+
export { StudioChannel } from "./StudioChannel.js";
|
|
14
17
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/v8/preview/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/v8/preview/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,UAAU,EAAwB,MAAM,iBAAkB,CAAC;AACpE,OAAO,EACL,YAAY,EAEZ,UAAU,GAEX,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,aAAa,EAA2B,MAAM,oBAAoB,CAAC"}
|
|
@@ -1,16 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `remoteLoader`: hosted releases from `delivery.decocms.com`, read at
|
|
3
|
+
* runtime only (see /next/hosted-releases-internals). Content is never
|
|
4
|
+
* bundled: with `site`, the release comes from the CDN or not at all. Sites
|
|
5
|
+
* talk only to the CDN, with plain HTTP (ETag, `If-None-Match`, 304).
|
|
6
|
+
*
|
|
7
|
+
* - **The index.** `sites/<site>/latest.json` is the current revision's
|
|
8
|
+
* index (`{ revision, sequence, previewHosts, blocks: { <name>: { version,
|
|
9
|
+
* meta?, data? } } }`). The first use loads it (calls made meanwhile share
|
|
10
|
+
* the load; a failed load isn't kept and rejects with a
|
|
11
|
+
* `ContentUnavailableError`, a 404 included: never an empty site). A poll
|
|
12
|
+
* (the CMS starts one in the background every interval, and a draft
|
|
13
|
+
* request's release check is one) sends `If-None-Match` on the held ETag, so
|
|
14
|
+
* an unchanged index is a 304: nothing is downloaded or parsed. A read is
|
|
15
|
+
* adopted only when its `sequence` is higher than the held one, so a
|
|
16
|
+
* slightly stale CDN answer never moves the isolate backwards; the index
|
|
17
|
+
* that was current is kept as the previous one (one only). A failed poll
|
|
18
|
+
* keeps the held index.
|
|
19
|
+
* - **Blocks.** `sites/<site>/blocks/<hash>.json`, immutable, fetched with
|
|
20
|
+
* plain `fetch()` (it reads through the CDN cache) when a request needs one,
|
|
21
|
+
* into an LRU per isolate keyed by hash and bounded by bytes (32 MiB of
|
|
22
|
+
* JSON text). Concurrent requests share one fetch per hash; a failed fetch
|
|
23
|
+
* (a 404 included) isn't kept.
|
|
24
|
+
* - **Revisions by id** (`cms.client({ version: <id> })`): the
|
|
25
|
+
* `revisions/<id>/index.json` of that revision, read on first use and kept,
|
|
26
|
+
* three at a time, since a revision never changes. Bodies by hash as usual.
|
|
27
|
+
* - Each fetch has 10 s (headers and body), sends no credential, and refuses
|
|
28
|
+
* a body over 16 MiB while it downloads. Unknown keys are ignored.
|
|
29
|
+
* - `previewHosts`: as before, from the last `latest.json` read whose index
|
|
30
|
+
* was adopted (a 304, or a stale answer with a lower or equal `sequence`,
|
|
31
|
+
* keeps the list it had). A site with no `latest.json` yet (a 404), or one without
|
|
32
|
+
* `previewHosts`, previews on every host; until a read succeeds, previews
|
|
33
|
+
* stay closed, and a later failure keeps the last answer.
|
|
34
|
+
* - Without `site` it's a plain loader over the content it's given.
|
|
35
|
+
*
|
|
36
|
+
* Instances are process-wide singletons, like `createCMS`'s.
|
|
37
|
+
*/
|
|
1
38
|
import type { Loader, Snapshot } from "./types.ts";
|
|
2
39
|
interface RemoteLoaderOptions {
|
|
3
40
|
site?: string;
|
|
4
41
|
/** ms between release checks, used when `createCMS` has no `interval` of its own. */
|
|
5
42
|
interval?: number;
|
|
6
|
-
/** Local development: never swap in a release, so local files win. */
|
|
7
|
-
dev?: boolean;
|
|
8
43
|
}
|
|
9
44
|
/**
|
|
10
|
-
* Hosted releases
|
|
11
|
-
*
|
|
45
|
+
* Hosted releases: `createCMS` builds it for you when `site` is set. With
|
|
46
|
+
* `site`, content comes only from the CDN, so `content` must be `undefined`
|
|
47
|
+
* (nothing is bundled). Without `site`, it's a loader over
|
|
48
|
+
* `content` alone.
|
|
12
49
|
*/
|
|
13
|
-
export declare function remoteLoader(
|
|
50
|
+
export declare function remoteLoader(content: Snapshot | Loader | undefined, options: RemoteLoaderOptions): Loader;
|
|
14
51
|
export declare function resetRemoteLoaders(): void;
|
|
15
52
|
export {};
|
|
16
53
|
//# sourceMappingURL=remoteLoader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remoteLoader.d.ts","sourceRoot":"","sources":["../../src/v8/remoteLoader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"remoteLoader.d.ts","sourceRoot":"","sources":["../../src/v8/remoteLoader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAmBH,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AA2BnD,UAAU,mBAAmB;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qFAAqF;IACrF,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAoRD;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,QAAQ,GAAG,MAAM,GAAG,SAAS,EACtC,OAAO,EAAE,mBAAmB,GAC3B,MAAM,CAuCR;AAED,wBAAgB,kBAAkB,IAAI,IAAI,CAEzC"}
|