@decocms/blocks 8.1.0-next.0 → 8.1.0-next.2
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/bin/deco.js +5 -12
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/protocol/assets.d.ts +46 -0
- package/dist/protocol/assets.d.ts.map +1 -0
- package/dist/protocol/assets.js +105 -0
- package/dist/protocol/assets.js.map +1 -0
- package/dist/protocol/canonical.d.ts +8 -0
- package/dist/protocol/canonical.d.ts.map +1 -0
- package/dist/protocol/canonical.js +8 -0
- package/dist/protocol/canonical.js.map +1 -0
- package/dist/protocol/ciphertext.d.ts +7 -0
- package/dist/protocol/ciphertext.d.ts.map +1 -0
- package/dist/protocol/ciphertext.js +7 -0
- package/dist/protocol/ciphertext.js.map +1 -0
- package/dist/protocol/client.d.ts +54 -0
- package/dist/protocol/client.d.ts.map +1 -0
- package/dist/protocol/client.js +104 -0
- package/dist/protocol/client.js.map +1 -0
- package/dist/protocol/conformance/cases/assets.d.ts +3 -0
- package/dist/protocol/conformance/cases/assets.d.ts.map +1 -0
- package/dist/protocol/conformance/cases/assets.js +71 -0
- package/dist/protocol/conformance/cases/assets.js.map +1 -0
- package/dist/protocol/conformance/cases/guards.d.ts +3 -0
- package/dist/protocol/conformance/cases/guards.d.ts.map +1 -0
- package/dist/protocol/conformance/cases/guards.js +265 -0
- package/dist/protocol/conformance/cases/guards.js.map +1 -0
- package/dist/protocol/conformance/cases/reads.d.ts +3 -0
- package/dist/protocol/conformance/cases/reads.d.ts.map +1 -0
- package/dist/protocol/conformance/cases/reads.js +140 -0
- package/dist/protocol/conformance/cases/reads.js.map +1 -0
- package/dist/protocol/conformance/cases/types.d.ts +9 -0
- package/dist/protocol/conformance/cases/types.d.ts.map +1 -0
- package/dist/protocol/conformance/cases/types.js +2 -0
- package/dist/protocol/conformance/cases/types.js.map +1 -0
- package/dist/protocol/conformance/cases/wire.d.ts +3 -0
- package/dist/protocol/conformance/cases/wire.d.ts.map +1 -0
- package/dist/protocol/conformance/cases/wire.js +130 -0
- package/dist/protocol/conformance/cases/wire.js.map +1 -0
- package/dist/protocol/conformance/cases/writes.d.ts +3 -0
- package/dist/protocol/conformance/cases/writes.d.ts.map +1 -0
- package/dist/protocol/conformance/cases/writes.js +278 -0
- package/dist/protocol/conformance/cases/writes.js.map +1 -0
- package/dist/protocol/conformance/contentHashFixtures.d.ts +22 -0
- package/dist/protocol/conformance/contentHashFixtures.d.ts.map +1 -0
- package/dist/protocol/conformance/contentHashFixtures.js +64 -0
- package/dist/protocol/conformance/contentHashFixtures.js.map +1 -0
- package/dist/protocol/conformance/context.d.ts +100 -0
- package/dist/protocol/conformance/context.d.ts.map +1 -0
- package/dist/protocol/conformance/context.js +155 -0
- package/dist/protocol/conformance/context.js.map +1 -0
- package/dist/protocol/conformance/index.d.ts +32 -0
- package/dist/protocol/conformance/index.d.ts.map +1 -0
- package/dist/protocol/conformance/index.js +90 -0
- package/dist/protocol/conformance/index.js.map +1 -0
- package/dist/protocol/errors.d.ts +85 -0
- package/dist/protocol/errors.d.ts.map +1 -0
- package/dist/protocol/errors.js +62 -0
- package/dist/protocol/errors.js.map +1 -0
- package/dist/protocol/index.d.ts +25 -0
- package/dist/protocol/index.d.ts.map +1 -0
- package/dist/protocol/index.js +25 -0
- package/dist/protocol/index.js.map +1 -0
- package/dist/protocol/keys.d.ts +101 -0
- package/dist/protocol/keys.d.ts.map +1 -0
- package/dist/protocol/keys.js +223 -0
- package/dist/protocol/keys.js.map +1 -0
- package/dist/protocol/params.d.ts +10 -0
- package/dist/protocol/params.d.ts.map +1 -0
- package/dist/protocol/params.js +54 -0
- package/dist/protocol/params.js.map +1 -0
- package/dist/protocol/secrets.d.ts +22 -0
- package/dist/protocol/secrets.d.ts.map +1 -0
- package/dist/protocol/secrets.js +200 -0
- package/dist/protocol/secrets.js.map +1 -0
- package/dist/protocol/server/assets.d.ts +20 -0
- package/dist/protocol/server/assets.d.ts.map +1 -0
- package/dist/protocol/server/assets.js +77 -0
- package/dist/protocol/server/assets.js.map +1 -0
- package/dist/protocol/server/auth.d.ts +31 -0
- package/dist/protocol/server/auth.d.ts.map +1 -0
- package/dist/protocol/server/auth.js +32 -0
- package/dist/protocol/server/auth.js.map +1 -0
- package/dist/protocol/server/bodyCache.d.ts +28 -0
- package/dist/protocol/server/bodyCache.d.ts.map +1 -0
- package/dist/protocol/server/bodyCache.js +75 -0
- package/dist/protocol/server/bodyCache.js.map +1 -0
- package/dist/protocol/server/content.d.ts +44 -0
- package/dist/protocol/server/content.d.ts.map +1 -0
- package/dist/protocol/server/content.js +132 -0
- package/dist/protocol/server/content.js.map +1 -0
- package/dist/protocol/server/core.d.ts +63 -0
- package/dist/protocol/server/core.d.ts.map +1 -0
- package/dist/protocol/server/core.js +77 -0
- package/dist/protocol/server/core.js.map +1 -0
- package/dist/protocol/server/handler.d.ts +5 -0
- package/dist/protocol/server/handler.d.ts.map +1 -0
- package/dist/protocol/server/handler.js +70 -0
- package/dist/protocol/server/handler.js.map +1 -0
- package/dist/protocol/server/http.d.ts +24 -0
- package/dist/protocol/server/http.d.ts.map +1 -0
- package/dist/protocol/server/http.js +133 -0
- package/dist/protocol/server/http.js.map +1 -0
- package/dist/protocol/server/index.d.ts +11 -0
- package/dist/protocol/server/index.d.ts.map +1 -0
- package/dist/protocol/server/index.js +9 -0
- package/dist/protocol/server/index.js.map +1 -0
- package/dist/protocol/server/methods/apply.d.ts +4 -0
- package/dist/protocol/server/methods/apply.d.ts.map +1 -0
- package/dist/protocol/server/methods/apply.js +275 -0
- package/dist/protocol/server/methods/apply.js.map +1 -0
- package/dist/protocol/server/methods/read.d.ts +14 -0
- package/dist/protocol/server/methods/read.d.ts.map +1 -0
- package/dist/protocol/server/methods/read.js +132 -0
- package/dist/protocol/server/methods/read.js.map +1 -0
- package/dist/protocol/server/rpc.d.ts +7 -0
- package/dist/protocol/server/rpc.d.ts.map +1 -0
- package/dist/protocol/server/rpc.js +115 -0
- package/dist/protocol/server/rpc.js.map +1 -0
- package/dist/protocol/storage/fs/hash.d.ts +8 -0
- package/dist/protocol/storage/fs/hash.d.ts.map +1 -0
- package/dist/protocol/storage/fs/hash.js +20 -0
- package/dist/protocol/storage/fs/hash.js.map +1 -0
- package/dist/protocol/storage/fs/index.d.ts +30 -0
- package/dist/protocol/storage/fs/index.d.ts.map +1 -0
- package/dist/protocol/storage/fs/index.js +301 -0
- package/dist/protocol/storage/fs/index.js.map +1 -0
- package/dist/protocol/storage/fs/lock.d.ts +8 -0
- package/dist/protocol/storage/fs/lock.d.ts.map +1 -0
- package/dist/protocol/storage/fs/lock.js +61 -0
- package/dist/protocol/storage/fs/lock.js.map +1 -0
- package/dist/protocol/storage/fs/transaction.d.ts +19 -0
- package/dist/protocol/storage/fs/transaction.d.ts.map +1 -0
- package/dist/protocol/storage/fs/transaction.js +174 -0
- package/dist/protocol/storage/fs/transaction.js.map +1 -0
- package/dist/protocol/storage/fs/unsupported.d.ts +10 -0
- package/dist/protocol/storage/fs/unsupported.d.ts.map +1 -0
- package/dist/protocol/storage/fs/unsupported.js +4 -0
- package/dist/protocol/storage/fs/unsupported.js.map +1 -0
- package/dist/protocol/storage/memory.d.ts +40 -0
- package/dist/protocol/storage/memory.d.ts.map +1 -0
- package/dist/protocol/storage/memory.js +179 -0
- package/dist/protocol/storage/memory.js.map +1 -0
- package/dist/protocol/storage.d.ts +178 -0
- package/dist/protocol/storage.d.ts.map +1 -0
- package/dist/protocol/storage.js +29 -0
- package/dist/protocol/storage.js.map +1 -0
- package/dist/protocol/types.d.ts +194 -0
- package/dist/protocol/types.d.ts.map +1 -0
- package/dist/protocol/types.js +31 -0
- package/dist/protocol/types.js.map +1 -0
- package/dist/v8/analytics.d.ts +31 -0
- package/dist/v8/analytics.d.ts.map +1 -0
- package/dist/v8/analytics.js +46 -0
- package/dist/v8/analytics.js.map +1 -0
- package/dist/v8/background.d.ts +26 -0
- package/dist/v8/background.d.ts.map +1 -0
- package/dist/v8/background.js +95 -0
- package/dist/v8/background.js.map +1 -0
- package/dist/v8/builtins/data.d.ts +15 -0
- package/dist/v8/builtins/data.d.ts.map +1 -0
- package/dist/v8/builtins/data.js +18 -0
- package/dist/v8/builtins/data.js.map +1 -0
- package/dist/v8/builtins/index.d.ts +9 -0
- package/dist/v8/builtins/index.d.ts.map +1 -0
- package/dist/v8/builtins/index.js +24 -0
- package/dist/v8/builtins/index.js.map +1 -0
- package/dist/v8/builtins/lazy.d.ts +17 -0
- package/dist/v8/builtins/lazy.d.ts.map +1 -0
- package/dist/v8/builtins/lazy.js +13 -0
- package/dist/v8/builtins/lazy.js.map +1 -0
- package/dist/v8/builtins/legacy.d.ts +41 -0
- package/dist/v8/builtins/legacy.d.ts.map +1 -0
- package/dist/v8/builtins/legacy.js +62 -0
- package/dist/v8/builtins/legacy.js.map +1 -0
- package/dist/v8/builtins/matchers.d.ts +19 -0
- package/dist/v8/builtins/matchers.d.ts.map +1 -0
- package/dist/v8/builtins/matchers.js +24 -0
- package/dist/v8/builtins/matchers.js.map +1 -0
- package/dist/v8/builtins/multivariate.d.ts +15 -0
- package/dist/v8/builtins/multivariate.d.ts.map +1 -0
- package/dist/v8/builtins/multivariate.js +18 -0
- package/dist/v8/builtins/multivariate.js.map +1 -0
- package/dist/v8/builtins/secret.d.ts +7 -0
- package/dist/v8/builtins/secret.d.ts.map +1 -0
- package/dist/v8/builtins/secret.js +68 -0
- package/dist/v8/builtins/secret.js.map +1 -0
- package/dist/v8/canonical.d.ts +42 -0
- package/dist/v8/canonical.d.ts.map +1 -0
- package/dist/v8/canonical.js +111 -0
- package/dist/v8/canonical.js.map +1 -0
- package/dist/v8/ciphertext.d.ts +58 -0
- package/dist/v8/ciphertext.d.ts.map +1 -0
- package/dist/v8/ciphertext.js +134 -0
- package/dist/v8/ciphertext.js.map +1 -0
- package/dist/v8/cli/builtins.d.ts +11 -0
- package/dist/v8/cli/builtins.d.ts.map +1 -0
- package/dist/v8/cli/builtins.js +18 -0
- package/dist/v8/cli/builtins.js.map +1 -0
- package/dist/v8/cli/check/index.d.ts +41 -0
- package/dist/v8/cli/check/index.d.ts.map +1 -0
- package/dist/v8/cli/check/index.js +713 -0
- package/dist/v8/cli/check/index.js.map +1 -0
- package/dist/v8/cli/check/messages.d.ts +24 -0
- package/dist/v8/cli/check/messages.d.ts.map +1 -0
- package/dist/v8/cli/check/messages.js +150 -0
- package/dist/v8/cli/check/messages.js.map +1 -0
- package/dist/v8/cli/content.d.ts +60 -0
- package/dist/v8/cli/content.d.ts.map +1 -0
- package/dist/v8/cli/content.js +231 -0
- package/dist/v8/cli/content.js.map +1 -0
- package/dist/v8/cli/index.d.ts +18 -0
- package/dist/v8/cli/index.d.ts.map +1 -0
- package/dist/v8/cli/index.js +18 -0
- package/dist/v8/cli/index.js.map +1 -0
- package/dist/v8/cli/log.d.ts +9 -0
- package/dist/v8/cli/log.d.ts.map +1 -0
- package/dist/v8/cli/log.js +11 -0
- package/dist/v8/cli/log.js.map +1 -0
- package/dist/v8/cli/main.d.ts +2 -0
- package/dist/v8/cli/main.d.ts.map +1 -0
- package/dist/v8/cli/main.js +9 -0
- package/dist/v8/cli/main.js.map +1 -0
- package/dist/v8/cli/root.d.ts +28 -0
- package/dist/v8/cli/root.d.ts.map +1 -0
- package/dist/v8/cli/root.js +64 -0
- package/dist/v8/cli/root.js.map +1 -0
- package/dist/v8/cli/run.d.ts +13 -0
- package/dist/v8/cli/run.d.ts.map +1 -0
- package/dist/v8/cli/run.js +210 -0
- package/dist/v8/cli/run.js.map +1 -0
- package/dist/v8/cli/schema/builtinSchemas.d.ts +22 -0
- package/dist/v8/cli/schema/builtinSchemas.d.ts.map +1 -0
- package/dist/v8/cli/schema/builtinSchemas.js +213 -0
- package/dist/v8/cli/schema/builtinSchemas.js.map +1 -0
- package/dist/v8/cli/schema/generate.d.ts +50 -0
- package/dist/v8/cli/schema/generate.d.ts.map +1 -0
- package/dist/v8/cli/schema/generate.js +415 -0
- package/dist/v8/cli/schema/generate.js.map +1 -0
- package/dist/v8/cli/schema/index.d.ts +21 -0
- package/dist/v8/cli/schema/index.d.ts.map +1 -0
- package/dist/v8/cli/schema/index.js +51 -0
- package/dist/v8/cli/schema/index.js.map +1 -0
- package/dist/v8/cli/schema/tsProgram.d.ts +120 -0
- package/dist/v8/cli/schema/tsProgram.d.ts.map +1 -0
- package/dist/v8/cli/schema/tsProgram.js +418 -0
- package/dist/v8/cli/schema/tsProgram.js.map +1 -0
- package/dist/v8/cli/schema/typeToSchema.d.ts +81 -0
- package/dist/v8/cli/schema/typeToSchema.d.ts.map +1 -0
- package/dist/v8/cli/schema/typeToSchema.js +683 -0
- package/dist/v8/cli/schema/typeToSchema.js.map +1 -0
- package/dist/v8/cli/serve/server.d.ts +31 -0
- package/dist/v8/cli/serve/server.d.ts.map +1 -0
- package/dist/v8/cli/serve/server.js +247 -0
- package/dist/v8/cli/serve/server.js.map +1 -0
- package/dist/v8/cli/watch.d.ts +20 -0
- package/dist/v8/cli/watch.d.ts.map +1 -0
- package/dist/v8/cli/watch.js +79 -0
- package/dist/v8/cli/watch.js.map +1 -0
- package/dist/v8/client.d.ts +20 -0
- package/dist/v8/client.d.ts.map +1 -0
- package/dist/v8/client.js +115 -0
- package/dist/v8/client.js.map +1 -0
- package/dist/v8/cms.d.ts +9 -0
- package/dist/v8/cms.d.ts.map +1 -0
- package/dist/v8/cms.js +206 -0
- package/dist/v8/cms.js.map +1 -0
- package/dist/v8/content.d.ts +35 -0
- package/dist/v8/content.d.ts.map +1 -0
- package/dist/v8/content.js +183 -0
- package/dist/v8/content.js.map +1 -0
- package/dist/v8/draft.d.ts +44 -0
- package/dist/v8/draft.d.ts.map +1 -0
- package/dist/v8/draft.js +133 -0
- package/dist/v8/draft.js.map +1 -0
- package/dist/v8/errors.d.ts +21 -0
- package/dist/v8/errors.d.ts.map +1 -0
- package/dist/v8/errors.js +39 -0
- package/dist/v8/errors.js.map +1 -0
- package/dist/v8/fetch.d.ts +26 -0
- package/dist/v8/fetch.d.ts.map +1 -0
- package/dist/v8/fetch.js +98 -0
- package/dist/v8/fetch.js.map +1 -0
- package/dist/v8/identity.d.ts +19 -0
- package/dist/v8/identity.d.ts.map +1 -0
- package/dist/v8/identity.js +54 -0
- package/dist/v8/identity.js.map +1 -0
- package/dist/v8/index.d.ts +11 -0
- package/dist/v8/index.d.ts.map +1 -0
- package/dist/v8/index.js +10 -0
- package/dist/v8/index.js.map +1 -0
- package/dist/v8/json.d.ts +19 -0
- package/dist/v8/json.d.ts.map +1 -0
- package/dist/v8/json.js +65 -0
- package/dist/v8/json.js.map +1 -0
- package/dist/v8/matchRoute.d.ts +30 -0
- package/dist/v8/matchRoute.d.ts.map +1 -0
- package/dist/v8/matchRoute.js +175 -0
- package/dist/v8/matchRoute.js.map +1 -0
- package/dist/v8/remoteLoader.d.ts +16 -0
- package/dist/v8/remoteLoader.d.ts.map +1 -0
- package/dist/v8/remoteLoader.js +243 -0
- package/dist/v8/remoteLoader.js.map +1 -0
- package/dist/v8/resolver.d.ts +34 -0
- package/dist/v8/resolver.d.ts.map +1 -0
- package/dist/v8/resolver.js +219 -0
- package/dist/v8/resolver.js.map +1 -0
- package/dist/v8/secrets.d.ts +9 -0
- package/dist/v8/secrets.d.ts.map +1 -0
- package/dist/v8/secrets.js +14 -0
- package/dist/v8/secrets.js.map +1 -0
- package/dist/v8/telemetry.d.ts +61 -0
- package/dist/v8/telemetry.d.ts.map +1 -0
- package/dist/v8/telemetry.js +460 -0
- package/dist/v8/telemetry.js.map +1 -0
- package/dist/v8/types.d.ts +214 -0
- package/dist/v8/types.d.ts.map +1 -0
- package/dist/v8/types.js +2 -0
- package/dist/v8/types.js.map +1 -0
- package/package.json +65 -105
- package/src/index.ts +3 -13
- package/src/protocol/canonical.ts +1 -1
- package/src/protocol/ciphertext.ts +1 -1
- package/src/protocol/client.ts +2 -2
- package/src/protocol/conformance/cases/assets.ts +3 -3
- package/src/protocol/conformance/cases/guards.ts +4 -4
- package/src/protocol/conformance/cases/reads.ts +4 -4
- package/src/protocol/conformance/cases/types.ts +1 -1
- package/src/protocol/conformance/cases/wire.ts +4 -4
- package/src/protocol/conformance/cases/writes.ts +4 -4
- package/src/protocol/conformance/context.ts +4 -4
- package/src/protocol/conformance/index.ts +10 -10
- package/src/protocol/index.ts +6 -6
- package/src/protocol/params.ts +2 -2
- package/src/protocol/secrets.ts +3 -3
- package/src/protocol/server/assets.ts +6 -6
- package/src/protocol/server/auth.ts +1 -1
- package/src/protocol/server/content.ts +5 -5
- package/src/protocol/server/core.ts +12 -6
- package/src/protocol/server/handler.ts +6 -6
- package/src/protocol/server/http.ts +1 -1
- package/src/protocol/server/index.ts +3 -3
- package/src/protocol/server/methods/apply.ts +9 -9
- package/src/protocol/server/methods/read.ts +5 -5
- package/src/protocol/server/rpc.ts +6 -6
- package/src/protocol/storage/fs/index.ts +7 -7
- package/src/protocol/storage/fs/lock.ts +1 -1
- package/src/protocol/storage/fs/unsupported.ts +2 -2
- package/src/protocol/storage/memory.ts +5 -5
- package/src/protocol/storage.ts +1 -1
- package/src/v8/analytics.ts +2 -2
- package/src/v8/background.ts +3 -3
- package/src/v8/builtins/data.ts +1 -1
- package/src/v8/builtins/index.ts +6 -6
- package/src/v8/builtins/lazy.ts +1 -1
- package/src/v8/builtins/legacy.ts +2 -2
- package/src/v8/builtins/multivariate.ts +1 -1
- package/src/v8/builtins/secret.ts +2 -2
- package/src/v8/cli/builtins.ts +2 -2
- package/src/v8/cli/check/index.ts +11 -11
- package/src/v8/cli/content.ts +6 -6
- package/src/v8/cli/index.ts +8 -8
- package/src/v8/cli/main.ts +1 -1
- package/src/v8/cli/run.ts +7 -7
- package/src/v8/cli/schema/builtinSchemas.ts +1 -1
- package/src/v8/cli/schema/generate.ts +6 -6
- package/src/v8/cli/schema/index.ts +4 -4
- package/src/v8/cli/schema/tsProgram.ts +1 -1
- package/src/v8/cli/schema/typeToSchema.ts +24 -2
- package/src/v8/cli/serve/server.ts +9 -9
- package/src/v8/client.ts +5 -5
- package/src/v8/cms.ts +9 -9
- package/src/v8/content.ts +4 -4
- package/src/v8/draft.ts +1 -1
- package/src/v8/errors.ts +1 -1
- package/src/v8/fetch.ts +9 -28
- package/src/v8/identity.ts +1 -1
- package/src/v8/index.ts +5 -5
- package/src/v8/matchRoute.ts +1 -1
- package/src/v8/remoteLoader.ts +7 -7
- package/src/v8/resolver.ts +6 -6
- package/src/v8/secrets.ts +1 -1
- package/src/v8/telemetry.ts +6 -6
- package/src/cms/applySectionConventions.ts +0 -148
- package/src/cms/blockSource.ts +0 -228
- package/src/cms/client.ts +0 -85
- package/src/cms/deferredTrigger.ts +0 -58
- package/src/cms/draftSource.ts +0 -476
- package/src/cms/index.ts +0 -180
- package/src/cms/loadDecofileDirectory.ts +0 -89
- package/src/cms/loader.ts +0 -563
- package/src/cms/registry.ts +0 -264
- package/src/cms/renderJson.ts +0 -179
- package/src/cms/resolve.ts +0 -2583
- package/src/cms/schema.ts +0 -1219
- package/src/cms/sectionLoaderContext.ts +0 -113
- package/src/cms/sectionLoaders.ts +0 -686
- package/src/cms/sectionMixins.ts +0 -153
- package/src/flags/audience.ts +0 -56
- package/src/flags/everyone.ts +0 -29
- package/src/flags/flag.ts +0 -15
- package/src/flags/multivariate/image.ts +0 -11
- package/src/flags/multivariate/message.ts +0 -11
- package/src/flags/multivariate/page.ts +0 -16
- package/src/flags/multivariate/section.ts +0 -16
- package/src/flags/multivariate.ts +0 -1
- package/src/flags/types.ts +0 -59
- package/src/flags/utils/multivariate.ts +0 -20
- package/src/hooks/Image.tsx +0 -314
- package/src/hooks/JsonLd.tsx +0 -353
- package/src/hooks/LazySection.tsx +0 -121
- package/src/hooks/LiveControls.tsx +0 -144
- package/src/hooks/Picture.tsx +0 -127
- package/src/hooks/RenderSection.tsx +0 -91
- package/src/hooks/SectionErrorFallback.tsx +0 -97
- package/src/hooks/Stats.tsx +0 -134
- package/src/hooks/index.ts +0 -35
- package/src/hooks/useLoadMore.ts +0 -100
- package/src/matchers/builtins.ts +0 -459
- package/src/matchers/countryNames.ts +0 -104
- package/src/matchers/override.ts +0 -136
- package/src/matchers/posthog.ts +0 -154
- package/src/middleware/decoState.ts +0 -55
- package/src/middleware/healthMetrics.ts +0 -133
- package/src/middleware/hydrationContext.ts +0 -79
- package/src/middleware/index.ts +0 -88
- package/src/middleware/liveness.ts +0 -21
- package/src/middleware/observability.ts +0 -800
- package/src/middleware/validateSection.ts +0 -100
- package/src/preview/DraftPreviewBadge.tsx +0 -306
- package/src/preview/decoMark.ts +0 -11
- package/src/preview/index.ts +0 -8
- package/src/sdk/abTesting.ts +0 -556
- package/src/sdk/analytics.ts +0 -147
- package/src/sdk/cacheHeaders.ts +0 -633
- package/src/sdk/cacheStorage.ts +0 -287
- package/src/sdk/cachedLoader.ts +0 -556
- package/src/sdk/clx.ts +0 -5
- package/src/sdk/cn.ts +0 -28
- package/src/sdk/composite.ts +0 -114
- package/src/sdk/cookie.ts +0 -129
- package/src/sdk/crypto.ts +0 -199
- package/src/sdk/csp.ts +0 -59
- package/src/sdk/deepOmit.ts +0 -52
- package/src/sdk/detectDevice.ts +0 -45
- package/src/sdk/djb2.ts +0 -20
- package/src/sdk/encoding.ts +0 -44
- package/src/sdk/env.ts +0 -54
- package/src/sdk/experiments.ts +0 -314
- package/src/sdk/fetchCache.ts +0 -269
- package/src/sdk/fetchTimeout.ts +0 -58
- package/src/sdk/flags.ts +0 -138
- package/src/sdk/http.ts +0 -124
- package/src/sdk/index.ts +0 -97
- package/src/sdk/inflightTimeout.ts +0 -53
- package/src/sdk/instrumentedFetch.ts +0 -362
- package/src/sdk/invoke.ts +0 -298
- package/src/sdk/logger.ts +0 -304
- package/src/sdk/mergeCacheControl.ts +0 -150
- package/src/sdk/nonce.ts +0 -46
- package/src/sdk/normalizeUrls.ts +0 -91
- package/src/sdk/observability.ts +0 -116
- package/src/sdk/otel.ts +0 -1118
- package/src/sdk/otelAdapters/clickhouseCollector.ts +0 -65
- package/src/sdk/otelAdapters.ts +0 -144
- package/src/sdk/otelHttpLog.ts +0 -419
- package/src/sdk/otelHttpMeter.ts +0 -532
- package/src/sdk/otelHttpTracer.ts +0 -543
- package/src/sdk/redirects.ts +0 -336
- package/src/sdk/requestContext.ts +0 -281
- package/src/sdk/requestContextStorage.browser.ts +0 -43
- package/src/sdk/requestContextStorage.ts +0 -35
- package/src/sdk/responseCache.ts +0 -82
- package/src/sdk/retry.ts +0 -45
- package/src/sdk/serverTimings.ts +0 -68
- package/src/sdk/signal.ts +0 -42
- package/src/sdk/sitemap.ts +0 -160
- package/src/sdk/urlRedaction.ts +0 -82
- package/src/sdk/urlUtils.ts +0 -183
- package/src/sdk/useDevice.ts +0 -89
- package/src/sdk/useDeviceContext.tsx +0 -108
- package/src/sdk/useId.ts +0 -7
- package/src/sdk/useScript.ts +0 -210
- package/src/sdk/useSuggestions.ts +0 -188
- package/src/sdk/wrapCaughtErrors.ts +0 -107
- package/src/setup.ts +0 -120
- package/src/types/index.ts +0 -53
- package/src/types/widgets.ts +0 -14
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* LazySection -- Intersection Observer-based deferred rendering.
|
|
5
|
-
*
|
|
6
|
-
* Wraps section content and defers rendering until the element scrolls
|
|
7
|
-
* into view. Uses IntersectionObserver for zero-JS-cost detection and
|
|
8
|
-
* renders a lightweight placeholder until the content is needed.
|
|
9
|
-
*
|
|
10
|
-
* For SSR: the placeholder is rendered server-side. On hydration,
|
|
11
|
-
* the observer is set up and content loads when visible.
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```tsx
|
|
15
|
-
* <LazySection fallback={<div style={{ height: 400 }} />}>
|
|
16
|
-
* <HeavyProductCarousel products={products} />
|
|
17
|
-
* </LazySection>
|
|
18
|
-
* ```
|
|
19
|
-
*
|
|
20
|
-
* `"use client"` added by Phase 2 Task 9 (@decocms/nextjs's next-smoke
|
|
21
|
-
* fixture): this file uses `useEffect`/`useRef`/`useState`, which Next's App
|
|
22
|
-
* Router statically rejects in any file reachable from a Server Component's
|
|
23
|
-
* module graph unless the file itself declares the client boundary. Neither
|
|
24
|
-
* `@decocms/tanstack` (Vite, no RSC directive enforcement) nor this
|
|
25
|
-
* package's Vitest/jsdom unit tests caught this — `@decocms/nextjs` is the
|
|
26
|
-
* first consumer to go through Next's real RSC-aware webpack build.
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
import { type ReactNode, useEffect, useRef, useState } from "react";
|
|
30
|
-
|
|
31
|
-
export interface LazySectionProps {
|
|
32
|
-
children: ReactNode;
|
|
33
|
-
/**
|
|
34
|
-
* Content shown before the section scrolls into view.
|
|
35
|
-
* Should have a fixed height to prevent layout shifts.
|
|
36
|
-
*/
|
|
37
|
-
fallback?: ReactNode;
|
|
38
|
-
/**
|
|
39
|
-
* IntersectionObserver rootMargin.
|
|
40
|
-
* Positive values trigger loading before the element is visible.
|
|
41
|
-
* @default "200px"
|
|
42
|
-
*/
|
|
43
|
-
rootMargin?: string;
|
|
44
|
-
/**
|
|
45
|
-
* Minimum height for the wrapper div (prevents CLS).
|
|
46
|
-
* Applied as CSS min-height.
|
|
47
|
-
*/
|
|
48
|
-
minHeight?: string | number;
|
|
49
|
-
/**
|
|
50
|
-
* CSS class for the wrapper div.
|
|
51
|
-
*/
|
|
52
|
-
className?: string;
|
|
53
|
-
/**
|
|
54
|
-
* If true, render the content immediately (bypass lazy loading).
|
|
55
|
-
* Useful for sections above the fold.
|
|
56
|
-
* @default false
|
|
57
|
-
*/
|
|
58
|
-
eager?: boolean;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export function LazySection({
|
|
62
|
-
children,
|
|
63
|
-
fallback,
|
|
64
|
-
rootMargin = "200px",
|
|
65
|
-
minHeight,
|
|
66
|
-
className,
|
|
67
|
-
eager = false,
|
|
68
|
-
}: LazySectionProps) {
|
|
69
|
-
const [isVisible, setVisible] = useState(eager);
|
|
70
|
-
const ref = useRef<HTMLDivElement>(null);
|
|
71
|
-
|
|
72
|
-
useEffect(() => {
|
|
73
|
-
if (eager || isVisible) return;
|
|
74
|
-
|
|
75
|
-
const element = ref.current;
|
|
76
|
-
if (!element) return;
|
|
77
|
-
|
|
78
|
-
if (typeof IntersectionObserver === "undefined") {
|
|
79
|
-
setVisible(true);
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const observer = new IntersectionObserver(
|
|
84
|
-
([entry]) => {
|
|
85
|
-
if (entry?.isIntersecting) {
|
|
86
|
-
setVisible(true);
|
|
87
|
-
observer.disconnect();
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
|
-
{ rootMargin },
|
|
91
|
-
);
|
|
92
|
-
|
|
93
|
-
observer.observe(element);
|
|
94
|
-
return () => observer.disconnect();
|
|
95
|
-
}, [eager, isVisible, rootMargin]);
|
|
96
|
-
|
|
97
|
-
const style: React.CSSProperties | undefined = minHeight
|
|
98
|
-
? { minHeight: typeof minHeight === "number" ? `${minHeight}px` : minHeight }
|
|
99
|
-
: undefined;
|
|
100
|
-
|
|
101
|
-
return (
|
|
102
|
-
<div ref={ref} className={className} style={style}>
|
|
103
|
-
{isVisible ? children : (fallback ?? null)}
|
|
104
|
-
</div>
|
|
105
|
-
);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Determine if a section index is "below the fold" and should be lazy-loaded.
|
|
110
|
-
*
|
|
111
|
-
* Used by DecoPageRenderer to auto-wrap distant sections.
|
|
112
|
-
*
|
|
113
|
-
* @param index - Zero-based section index on the page
|
|
114
|
-
* @param foldThreshold - Sections at or above this index are below the fold.
|
|
115
|
-
* Defaults to `Infinity` (nothing below the fold), matching the framework
|
|
116
|
-
* default where the admin ⚡ toggle — not position — drives deferral.
|
|
117
|
-
* @default foldThreshold = Infinity
|
|
118
|
-
*/
|
|
119
|
-
export function isBelowFold(index: number, foldThreshold = Infinity): boolean {
|
|
120
|
-
return index >= foldThreshold;
|
|
121
|
-
}
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import React, { useEffect } from "react";
|
|
4
|
-
import { getRequestNonce } from "../sdk/nonce";
|
|
5
|
-
|
|
6
|
-
interface LiveControlsProps {
|
|
7
|
-
site?: string;
|
|
8
|
-
page?: { id?: string; pathTemplate?: string };
|
|
9
|
-
flags?: any[];
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* LiveControls bridges the deco admin (parent window) with the storefront (iframe).
|
|
14
|
-
*
|
|
15
|
-
* Mirrors production behavior (apps/website/components/_Controls.tsx):
|
|
16
|
-
* 1. Injects __DECO_STATE for the admin to read
|
|
17
|
-
* 2. Listens for postMessage events from the admin (inject scripts, scroll, rerender)
|
|
18
|
-
* 3. "." opens admin in same tab, Ctrl/Cmd+"." opens in new tab, Ctrl+Shift+E also works
|
|
19
|
-
*/
|
|
20
|
-
export function LiveControls({ site, page, flags }: LiveControlsProps) {
|
|
21
|
-
// Keep `window.LIVE.page` in sync with the CURRENT page across SPA
|
|
22
|
-
// navigations. The bootstrap script below reads __DECO_STATE only once (on
|
|
23
|
-
// initial load), so without this effect a client-side navigation would leave
|
|
24
|
-
// window.LIVE.page pointing at the first page rendered — and the "." shortcut
|
|
25
|
-
// would send that page's pathTemplate/id (or the "/*" fallback) instead of the
|
|
26
|
-
// route the user is actually looking at.
|
|
27
|
-
useEffect(() => {
|
|
28
|
-
if (typeof window === "undefined") return;
|
|
29
|
-
const w = window as unknown as { LIVE?: Record<string, unknown> };
|
|
30
|
-
w.LIVE = w.LIVE || {};
|
|
31
|
-
w.LIVE.page = page || {};
|
|
32
|
-
w.LIVE.site = { name: site || "storefront" };
|
|
33
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
34
|
-
}, [site, page?.id, page?.pathTemplate]);
|
|
35
|
-
|
|
36
|
-
return (
|
|
37
|
-
<>
|
|
38
|
-
<script
|
|
39
|
-
id="__DECO_STATE"
|
|
40
|
-
type="application/json"
|
|
41
|
-
dangerouslySetInnerHTML={{
|
|
42
|
-
__html: JSON.stringify({
|
|
43
|
-
page: page || {},
|
|
44
|
-
site: { name: site || "storefront" },
|
|
45
|
-
flags: flags || [],
|
|
46
|
-
}),
|
|
47
|
-
}}
|
|
48
|
-
/>
|
|
49
|
-
<LiveControlsScript />
|
|
50
|
-
</>
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function LiveControlsScript() {
|
|
55
|
-
const script = `
|
|
56
|
-
(function() {
|
|
57
|
-
if (window.__DECO_LIVE_CONTROLS__) return;
|
|
58
|
-
window.__DECO_LIVE_CONTROLS__ = true;
|
|
59
|
-
|
|
60
|
-
var TRUSTED_ORIGINS = ["https://deco.cx", "https://admin.deco.cx", "https://play.deco.cx", "https://decocms.com", "https://studio.decocms.com"];
|
|
61
|
-
function isTrustedOrigin(origin) {
|
|
62
|
-
return TRUSTED_ORIGINS.indexOf(origin) !== -1 ||
|
|
63
|
-
(origin.startsWith("https://") && origin.endsWith(".deco.cx")) ||
|
|
64
|
-
(origin.startsWith("https://") && origin.endsWith(".decocms.com")) ||
|
|
65
|
-
origin === window.location.origin;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
var LIVE = JSON.parse(document.getElementById("__DECO_STATE")?.textContent || "{}");
|
|
69
|
-
window.LIVE = { ...window.LIVE, ...LIVE };
|
|
70
|
-
|
|
71
|
-
window.addEventListener("message", function(event) {
|
|
72
|
-
if (!isTrustedOrigin(event.origin)) return;
|
|
73
|
-
|
|
74
|
-
var data = event.data;
|
|
75
|
-
if (!data || typeof data !== "object") return;
|
|
76
|
-
|
|
77
|
-
switch (data.type) {
|
|
78
|
-
case "editor::inject":
|
|
79
|
-
if (data.args && data.args.script) {
|
|
80
|
-
try { eval(data.args.script); } catch(e) { console.error("[deco] inject error:", e); }
|
|
81
|
-
}
|
|
82
|
-
break;
|
|
83
|
-
|
|
84
|
-
case "scrollToComponent":
|
|
85
|
-
var el = document.querySelector('[data-manifest-key="' + CSS.escape(data.args?.id || "") + '"]');
|
|
86
|
-
if (!el) el = document.getElementById(data.args?.id);
|
|
87
|
-
if (el) el.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
88
|
-
break;
|
|
89
|
-
|
|
90
|
-
case "DOMInspector":
|
|
91
|
-
break;
|
|
92
|
-
|
|
93
|
-
case "editor::rerender":
|
|
94
|
-
if (data.args?.url) {
|
|
95
|
-
try {
|
|
96
|
-
var targetUrl = new URL(data.args.url, window.location.origin);
|
|
97
|
-
if (targetUrl.origin === window.location.origin) {
|
|
98
|
-
window.location.href = targetUrl.href;
|
|
99
|
-
}
|
|
100
|
-
} catch(e) {}
|
|
101
|
-
}
|
|
102
|
-
break;
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
if (window.self === window.top) {
|
|
107
|
-
document.addEventListener("keydown", function(e) {
|
|
108
|
-
var t = e.target;
|
|
109
|
-
if (t && (t.tagName === "INPUT" || t.tagName === "TEXTAREA" || t.tagName === "SELECT" || t.isContentEditable)) return;
|
|
110
|
-
if (e.defaultPrevented) return;
|
|
111
|
-
|
|
112
|
-
if (
|
|
113
|
-
(e.ctrlKey && e.shiftKey && e.key === "E") ||
|
|
114
|
-
e.key === "."
|
|
115
|
-
) {
|
|
116
|
-
e.preventDefault();
|
|
117
|
-
e.stopPropagation();
|
|
118
|
-
|
|
119
|
-
var siteName = (window.LIVE.site && window.LIVE.site.name) || window.LIVE.site || "storefront";
|
|
120
|
-
var pageId = (window.LIVE.page && window.LIVE.page.id) || "";
|
|
121
|
-
var pathTemplate = (window.LIVE.page && window.LIVE.page.pathTemplate) || "/*";
|
|
122
|
-
|
|
123
|
-
var href = new URL("/choose-editor", "https://studio.decocms.com");
|
|
124
|
-
href.searchParams.set("site", siteName);
|
|
125
|
-
href.searchParams.set("domain", window.location.origin);
|
|
126
|
-
if (pageId) href.searchParams.set("pageId", pageId);
|
|
127
|
-
href.searchParams.set("path", window.location.pathname + window.location.search);
|
|
128
|
-
href.searchParams.set("pathTemplate", pathTemplate);
|
|
129
|
-
|
|
130
|
-
if ((e.ctrlKey || e.metaKey) && e.key === ".") {
|
|
131
|
-
window.open(href.toString(), "_blank");
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
window.location.href = href.toString();
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
})();
|
|
139
|
-
`;
|
|
140
|
-
|
|
141
|
-
return (
|
|
142
|
-
<script type="module" nonce={getRequestNonce()} dangerouslySetInnerHTML={{ __html: script }} />
|
|
143
|
-
);
|
|
144
|
-
}
|
package/src/hooks/Picture.tsx
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
// `"use client"` added by @decocms/nextjs's next-smoke fixture build
|
|
4
|
-
// (Picture is reachable from `DecoRootLayout`/`SectionRenderer` via the
|
|
5
|
-
// `hooks/index.ts` barrel, so it is part of the react-server module graph
|
|
6
|
-
// on any Next.js Server Component page even when a given page never
|
|
7
|
-
// renders it): `createContext`/`useContext` are unavailable under React's
|
|
8
|
-
// react-server condition, and Next statically flags any reachable module
|
|
9
|
-
// that imports them without this directive ("You're importing a component
|
|
10
|
-
// that needs createContext...") — same class of fix, same precedent, as
|
|
11
|
-
// `SectionErrorFallback.tsx`'s `"use client"` (class component /
|
|
12
|
-
// componentDidCatch, also client-only).
|
|
13
|
-
import {
|
|
14
|
-
type ComponentPropsWithoutRef,
|
|
15
|
-
type Context,
|
|
16
|
-
createContext,
|
|
17
|
-
forwardRef,
|
|
18
|
-
type ReactNode,
|
|
19
|
-
useContext,
|
|
20
|
-
useMemo,
|
|
21
|
-
} from "react";
|
|
22
|
-
import { type FitOptions, getOptimizedMediaUrl, getSrcSet } from "./Image";
|
|
23
|
-
|
|
24
|
-
// -------------------------------------------------------------------------
|
|
25
|
-
// Preload context — flows from <Picture preload> to child <Source> elements
|
|
26
|
-
// so each source can inject its own <link rel="preload"> with the correct
|
|
27
|
-
// media query for responsive art direction.
|
|
28
|
-
//
|
|
29
|
-
// Still created LAZILY (first render, not module scope) even under
|
|
30
|
-
// `"use client"`: this keeps a single memoized context object regardless of
|
|
31
|
-
// how many client bundle chunks end up importing this module, rather than
|
|
32
|
-
// relying on module-instance identity across chunks.
|
|
33
|
-
// -------------------------------------------------------------------------
|
|
34
|
-
|
|
35
|
-
interface PreloadContextValue {
|
|
36
|
-
preload: boolean;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
let _preloadContext: Context<PreloadContextValue> | null = null;
|
|
40
|
-
function getPreloadContext(): Context<PreloadContextValue> {
|
|
41
|
-
_preloadContext ??= createContext<PreloadContextValue>({ preload: false });
|
|
42
|
-
return _preloadContext;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// -------------------------------------------------------------------------
|
|
46
|
-
// Source — composable <source> with automatic srcSet optimization and
|
|
47
|
-
// preload link injection when inside a <Picture preload>.
|
|
48
|
-
// -------------------------------------------------------------------------
|
|
49
|
-
|
|
50
|
-
export type SourceProps = Omit<ComponentPropsWithoutRef<"source">, "width" | "height"> & {
|
|
51
|
-
src: string;
|
|
52
|
-
/** @description Improves Web Vitals (CLS|LCP) */
|
|
53
|
-
width: number;
|
|
54
|
-
/** @description Improves Web Vitals (CLS|LCP) */
|
|
55
|
-
height?: number;
|
|
56
|
-
/** @description Improves Web Vitals (LCP). Use high for LCP image. */
|
|
57
|
-
fetchPriority?: "high" | "low" | "auto";
|
|
58
|
-
/** @description Object-fit */
|
|
59
|
-
fit?: FitOptions;
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
export const Source = forwardRef<HTMLSourceElement, SourceProps>(function Source(
|
|
63
|
-
{ src, width, height, fetchPriority, fit = "cover", ...rest },
|
|
64
|
-
ref,
|
|
65
|
-
) {
|
|
66
|
-
const { preload } = useContext(getPreloadContext());
|
|
67
|
-
|
|
68
|
-
const optimizedSrc = getOptimizedMediaUrl({
|
|
69
|
-
originalSrc: src,
|
|
70
|
-
width,
|
|
71
|
-
height,
|
|
72
|
-
fit,
|
|
73
|
-
});
|
|
74
|
-
const srcSet = rest.srcSet ?? getSrcSet(src, width, height, fit);
|
|
75
|
-
|
|
76
|
-
return (
|
|
77
|
-
<>
|
|
78
|
-
{preload && (
|
|
79
|
-
<link
|
|
80
|
-
as="image"
|
|
81
|
-
rel="preload"
|
|
82
|
-
href={optimizedSrc}
|
|
83
|
-
imageSrcSet={srcSet}
|
|
84
|
-
fetchPriority={fetchPriority ?? "high"}
|
|
85
|
-
media={rest.media}
|
|
86
|
-
/>
|
|
87
|
-
)}
|
|
88
|
-
<source {...rest} srcSet={srcSet ?? optimizedSrc} width={width} height={height} ref={ref} />
|
|
89
|
-
</>
|
|
90
|
-
);
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
// -------------------------------------------------------------------------
|
|
94
|
-
// Picture — composable wrapper that provides preload context to children.
|
|
95
|
-
//
|
|
96
|
-
// Usage:
|
|
97
|
-
// <Picture preload={isLcp}>
|
|
98
|
-
// <Source media="(max-width: 767px)" src={mobile} width={320} height={280} />
|
|
99
|
-
// <Source media="(min-width: 768px)" src={desktop} width={1280} height={280} />
|
|
100
|
-
// <Image src={desktop} width={1280} height={280} />
|
|
101
|
-
// </Picture>
|
|
102
|
-
// -------------------------------------------------------------------------
|
|
103
|
-
|
|
104
|
-
export type PictureProps = ComponentPropsWithoutRef<"picture"> & {
|
|
105
|
-
children: ReactNode;
|
|
106
|
-
/**
|
|
107
|
-
* @description When true, child <Source> and <Image> elements inject
|
|
108
|
-
* `<link rel="preload">` tags for their respective media queries.
|
|
109
|
-
*/
|
|
110
|
-
preload?: boolean;
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
export const Picture = forwardRef<HTMLPictureElement, PictureProps>(function Picture(
|
|
114
|
-
{ children, preload = false, ...props },
|
|
115
|
-
ref,
|
|
116
|
-
) {
|
|
117
|
-
const value = useMemo(() => ({ preload }), [preload]);
|
|
118
|
-
const PreloadContext = getPreloadContext();
|
|
119
|
-
|
|
120
|
-
return (
|
|
121
|
-
<PreloadContext.Provider value={value}>
|
|
122
|
-
<picture {...props} ref={ref}>
|
|
123
|
-
{children}
|
|
124
|
-
</picture>
|
|
125
|
-
</PreloadContext.Provider>
|
|
126
|
-
);
|
|
127
|
-
});
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { type ComponentType, lazy, Suspense } from "react";
|
|
2
|
-
import { getSection, getSyncComponent } from "../cms/registry";
|
|
3
|
-
|
|
4
|
-
const componentCache = new Map<string, ComponentType<any>>();
|
|
5
|
-
|
|
6
|
-
function getOrCreateLazy(resolveType: string): ComponentType<any> | null {
|
|
7
|
-
if (componentCache.has(resolveType)) {
|
|
8
|
-
return componentCache.get(resolveType)!;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const loader = getSection(resolveType);
|
|
12
|
-
if (!loader) return null;
|
|
13
|
-
|
|
14
|
-
const LazyComponent = lazy(async () => {
|
|
15
|
-
const mod = await loader();
|
|
16
|
-
return { default: mod.default };
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
componentCache.set(resolveType, LazyComponent);
|
|
20
|
-
return LazyComponent;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
interface SectionLike {
|
|
24
|
-
__resolveType?: string;
|
|
25
|
-
Component?: ComponentType<any>;
|
|
26
|
-
props?: Record<string, unknown>;
|
|
27
|
-
[key: string]: unknown;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Renders a Section-type prop from the CMS.
|
|
32
|
-
*
|
|
33
|
-
* Handles both the old Deco format ({ Component, props }) and
|
|
34
|
-
* the new @decocms/start format ({ __resolveType, ...props }).
|
|
35
|
-
*
|
|
36
|
-
* Sync-first: sections registered as sync (`export const sync = true`,
|
|
37
|
-
* bundled in the main chunk) render DIRECTLY — no React.lazy / Suspense.
|
|
38
|
-
* This mirrors DecoPageRenderer's sync-first path and matters twice:
|
|
39
|
-
*
|
|
40
|
-
* - SSR streaming: React 19 omits the `<!--$-->` markers when a Suspense
|
|
41
|
-
* boundary resolves synchronously, which triggers a hydration mismatch
|
|
42
|
-
* (minified #418) — same reason DecoPageRenderer bifurcates.
|
|
43
|
-
* - SPA commit: the lazy path suspends with `fallback ?? null` while the
|
|
44
|
-
* section chunk loads, so a route commit that renders content through
|
|
45
|
-
* RenderSection (e.g. a gate section like NotFoundChallenge) paints the
|
|
46
|
-
* page with a BLANK middle until the chunk resolves.
|
|
47
|
-
*
|
|
48
|
-
* Sites without registered sync components are unaffected:
|
|
49
|
-
* `getSyncComponent()` returns undefined and the lazy path runs as before.
|
|
50
|
-
*/
|
|
51
|
-
export default function RenderSection({
|
|
52
|
-
section,
|
|
53
|
-
fallback,
|
|
54
|
-
}: {
|
|
55
|
-
section: SectionLike | null | undefined;
|
|
56
|
-
fallback?: React.ReactNode;
|
|
57
|
-
}) {
|
|
58
|
-
if (!section) return null;
|
|
59
|
-
|
|
60
|
-
if (section.Component) {
|
|
61
|
-
const { Component, props = {}, ...overrides } = section;
|
|
62
|
-
const mergedProps = { ...(props as Record<string, unknown>), ...overrides };
|
|
63
|
-
if (typeof Component === "string") {
|
|
64
|
-
const Sync = getSyncComponent(Component);
|
|
65
|
-
if (Sync) return <Sync {...mergedProps} />;
|
|
66
|
-
const Comp = getOrCreateLazy(Component);
|
|
67
|
-
if (!Comp) return <>{fallback ?? null}</>;
|
|
68
|
-
return (
|
|
69
|
-
<Suspense fallback={fallback ?? null}>
|
|
70
|
-
<Comp {...mergedProps} />
|
|
71
|
-
</Suspense>
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
return <Component {...mergedProps} />;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if (section.__resolveType) {
|
|
78
|
-
const { __resolveType: _, ...props } = section;
|
|
79
|
-
const Sync = getSyncComponent(section.__resolveType);
|
|
80
|
-
if (Sync) return <Sync {...props} />;
|
|
81
|
-
const Comp = getOrCreateLazy(section.__resolveType);
|
|
82
|
-
if (!Comp) return <>{fallback ?? null}</>;
|
|
83
|
-
return (
|
|
84
|
-
<Suspense fallback={fallback ?? null}>
|
|
85
|
-
<Comp {...props} />
|
|
86
|
-
</Suspense>
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
return null;
|
|
91
|
-
}
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
// `"use client"` added by Phase 2 Task 9 (@decocms/nextjs's next-smoke
|
|
4
|
-
// fixture): `SectionErrorBoundary` is a class component with
|
|
5
|
-
// `componentDidCatch`/`getDerivedStateFromError` — error boundaries require
|
|
6
|
-
// a Client Component in Next's App Router. `SectionRenderer.tsx` wraps
|
|
7
|
-
// every rendered section in this boundary, so without the directive, any
|
|
8
|
-
// Server Component that ends up importing `@decocms/blocks/hooks`
|
|
9
|
-
// transitively fails Next's build. Server Component children passed via
|
|
10
|
-
// `props.children` still render fine — passing already-rendered Server
|
|
11
|
-
// Component output into a Client Component's `children` is a supported RSC
|
|
12
|
-
// composition pattern.
|
|
13
|
-
import { Component, type ErrorInfo, type ReactNode } from "react";
|
|
14
|
-
|
|
15
|
-
interface ErrorBoundaryProps {
|
|
16
|
-
sectionKey: string;
|
|
17
|
-
fallback?: ReactNode;
|
|
18
|
-
children: ReactNode;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
interface ErrorBoundaryState {
|
|
22
|
-
error: Error | null;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Per-section error boundary that prevents a single broken section
|
|
27
|
-
* from crashing the entire page.
|
|
28
|
-
*
|
|
29
|
-
* In development, shows the error message + stack trace.
|
|
30
|
-
* In production, renders a silent empty placeholder.
|
|
31
|
-
*/
|
|
32
|
-
export class SectionErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
|
|
33
|
-
constructor(props: ErrorBoundaryProps) {
|
|
34
|
-
super(props);
|
|
35
|
-
this.state = { error: null };
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
static getDerivedStateFromError(error: Error): ErrorBoundaryState {
|
|
39
|
-
return { error };
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
componentDidCatch(error: Error, info: ErrorInfo) {
|
|
43
|
-
console.error(`[CMS] Section "${this.props.sectionKey}" crashed:`, error, info.componentStack);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
render() {
|
|
47
|
-
if (this.state.error) {
|
|
48
|
-
if (this.props.fallback) return this.props.fallback;
|
|
49
|
-
return (
|
|
50
|
-
<DefaultSectionErrorFallback error={this.state.error} sectionKey={this.props.sectionKey} />
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
return this.props.children;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function DefaultSectionErrorFallback({ error, sectionKey }: { error: Error; sectionKey: string }) {
|
|
58
|
-
const isDev = typeof process !== "undefined" && process.env.NODE_ENV === "development";
|
|
59
|
-
|
|
60
|
-
if (!isDev) {
|
|
61
|
-
return <div data-section-error={sectionKey} className="hidden" />;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return (
|
|
65
|
-
<div
|
|
66
|
-
data-section-error={sectionKey}
|
|
67
|
-
style={{
|
|
68
|
-
padding: "16px",
|
|
69
|
-
margin: "8px 0",
|
|
70
|
-
border: "2px solid #ef4444",
|
|
71
|
-
borderRadius: "8px",
|
|
72
|
-
background: "#fef2f2",
|
|
73
|
-
fontFamily: "monospace",
|
|
74
|
-
fontSize: "13px",
|
|
75
|
-
}}
|
|
76
|
-
>
|
|
77
|
-
<div style={{ fontWeight: "bold", color: "#dc2626", marginBottom: "8px" }}>
|
|
78
|
-
Section Error: {sectionKey}
|
|
79
|
-
</div>
|
|
80
|
-
<div style={{ color: "#991b1b" }}>{error.message}</div>
|
|
81
|
-
{error.stack && (
|
|
82
|
-
<pre
|
|
83
|
-
style={{
|
|
84
|
-
marginTop: "8px",
|
|
85
|
-
fontSize: "11px",
|
|
86
|
-
color: "#6b7280",
|
|
87
|
-
whiteSpace: "pre-wrap",
|
|
88
|
-
overflow: "auto",
|
|
89
|
-
maxHeight: "200px",
|
|
90
|
-
}}
|
|
91
|
-
>
|
|
92
|
-
{error.stack}
|
|
93
|
-
</pre>
|
|
94
|
-
)}
|
|
95
|
-
</div>
|
|
96
|
-
);
|
|
97
|
-
}
|