@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
package/src/cms/registry.ts
DELETED
|
@@ -1,264 +0,0 @@
|
|
|
1
|
-
import type { ComponentType } from "react";
|
|
2
|
-
import type { RenderJson } from "./renderJson";
|
|
3
|
-
|
|
4
|
-
export type OnBeforeResolveProps = (props: Record<string, unknown>) => Record<string, unknown>;
|
|
5
|
-
|
|
6
|
-
export type SectionModule = {
|
|
7
|
-
default: ComponentType<any>;
|
|
8
|
-
loader?: (props: any) => Promise<any> | any;
|
|
9
|
-
onBeforeResolveProps?: OnBeforeResolveProps;
|
|
10
|
-
LoadingFallback?: ComponentType<any>;
|
|
11
|
-
ErrorFallback?: ComponentType<{ error: Error }>;
|
|
12
|
-
/** How this section renders to JSON for the mobile app (?renderJson). */
|
|
13
|
-
renderJson?: RenderJson;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
type RegistryEntry = () => Promise<SectionModule>;
|
|
17
|
-
|
|
18
|
-
export interface SectionOptions {
|
|
19
|
-
/** Custom loading fallback component for this section. */
|
|
20
|
-
loadingFallback?: ComponentType<any>;
|
|
21
|
-
/** Custom error fallback component for this section. */
|
|
22
|
-
errorFallback?: ComponentType<{ error: Error }>;
|
|
23
|
-
/**
|
|
24
|
-
* The section's `renderJson` export (?renderJson mobile path): `false` drops
|
|
25
|
-
* the section from the JSON, a function projects its props. Populated by the
|
|
26
|
-
* generated section conventions and, as a fallback, on module preload.
|
|
27
|
-
*/
|
|
28
|
-
renderJson?: RenderJson;
|
|
29
|
-
/**
|
|
30
|
-
* When true, the section is wrapped in `<ClientOnly>` from TanStack Router.
|
|
31
|
-
* It renders only on the client — no SSR, no hydration mismatch.
|
|
32
|
-
* Use for analytics scripts, GTM, third-party widgets, and other
|
|
33
|
-
* browser-dependent components.
|
|
34
|
-
*/
|
|
35
|
-
clientOnly?: boolean;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// globalThis-backed: server function split modules need access to the registry
|
|
39
|
-
const G = globalThis as any;
|
|
40
|
-
if (!G.__deco) G.__deco = {};
|
|
41
|
-
if (!G.__deco.sectionRegistry) G.__deco.sectionRegistry = {};
|
|
42
|
-
if (!G.__deco.sectionOptions) G.__deco.sectionOptions = {};
|
|
43
|
-
if (!G.__deco.resolvedComponents) G.__deco.resolvedComponents = {};
|
|
44
|
-
if (!G.__deco.syncComponents) G.__deco.syncComponents = {};
|
|
45
|
-
if (!G.__deco.onBeforeResolvePropsRegistry) G.__deco.onBeforeResolvePropsRegistry = {};
|
|
46
|
-
|
|
47
|
-
const registry: Record<string, RegistryEntry> = G.__deco.sectionRegistry;
|
|
48
|
-
const sectionOptions: Record<string, SectionOptions> = G.__deco.sectionOptions;
|
|
49
|
-
|
|
50
|
-
// Cache of already-resolved component references.
|
|
51
|
-
// When a module is loaded (server-side or after first client import),
|
|
52
|
-
// the default export is stored here so subsequent renders can use
|
|
53
|
-
// the component directly WITHOUT React.lazy/Suspense — preventing
|
|
54
|
-
// hydration flash on SSR'd content.
|
|
55
|
-
const resolvedComponents: Record<string, ComponentType<any>> = G.__deco.resolvedComponents;
|
|
56
|
-
|
|
57
|
-
// Static sync registry — components that were statically imported and
|
|
58
|
-
// are guaranteed available on BOTH server and client without any async import.
|
|
59
|
-
// These never need React.lazy/Suspense and render identically on SSR and hydration.
|
|
60
|
-
const syncComponents: Record<string, ComponentType<any>> = G.__deco.syncComponents;
|
|
61
|
-
|
|
62
|
-
// onBeforeResolveProps registry — functions that transform raw CMS props
|
|
63
|
-
// BEFORE resolvables are resolved. Allows sections to extract data from
|
|
64
|
-
// raw resolvable structures (e.g., collection IDs from loader refs) that
|
|
65
|
-
// would be lost after resolution.
|
|
66
|
-
const onBeforeResolvePropsRegistry: Record<string, OnBeforeResolveProps> =
|
|
67
|
-
G.__deco.onBeforeResolvePropsRegistry;
|
|
68
|
-
|
|
69
|
-
export function registerSection(key: string, loader: RegistryEntry, options?: SectionOptions) {
|
|
70
|
-
registry[key] = loader;
|
|
71
|
-
if (options) sectionOptions[key] = options;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export function registerSections(
|
|
75
|
-
sections: Record<string, RegistryEntry>,
|
|
76
|
-
defaultOptions?: SectionOptions,
|
|
77
|
-
) {
|
|
78
|
-
for (const [key, loader] of Object.entries(sections)) {
|
|
79
|
-
registry[key] = loader;
|
|
80
|
-
if (defaultOptions) sectionOptions[key] = { ...defaultOptions };
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Set a section's `renderJson` option (?renderJson mobile path) without touching
|
|
86
|
-
* its loader/component registration. Called from the generated section
|
|
87
|
-
* conventions for `export const renderJson = false | (props) => ...`.
|
|
88
|
-
*/
|
|
89
|
-
export function setSectionRenderJson(key: string, renderJson: RenderJson): void {
|
|
90
|
-
sectionOptions[key] = { ...sectionOptions[key], renderJson };
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export function getSection(resolveType: string): RegistryEntry | undefined {
|
|
94
|
-
return registry[resolveType];
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export function getSectionOptions(resolveType: string): SectionOptions | undefined {
|
|
98
|
-
return sectionOptions[resolveType];
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Load a section module eagerly to extract LoadingFallback/ErrorFallback.
|
|
103
|
-
* Used by DeferredSectionWrapper to show custom skeletons before the section
|
|
104
|
-
* scrolls into view and its full props are fetched.
|
|
105
|
-
*/
|
|
106
|
-
export async function preloadSectionModule(
|
|
107
|
-
resolveType: string,
|
|
108
|
-
): Promise<SectionOptions | undefined> {
|
|
109
|
-
const existing = sectionOptions[resolveType];
|
|
110
|
-
if (existing?.loadingFallback) return existing;
|
|
111
|
-
|
|
112
|
-
const loader = registry[resolveType];
|
|
113
|
-
if (!loader) return undefined;
|
|
114
|
-
|
|
115
|
-
try {
|
|
116
|
-
const mod = await loader();
|
|
117
|
-
const opts: SectionOptions = { ...existing };
|
|
118
|
-
if (mod.LoadingFallback) opts.loadingFallback = mod.LoadingFallback;
|
|
119
|
-
if (mod.ErrorFallback) opts.errorFallback = mod.ErrorFallback;
|
|
120
|
-
if (mod.renderJson !== undefined) opts.renderJson = mod.renderJson;
|
|
121
|
-
sectionOptions[resolveType] = opts;
|
|
122
|
-
return opts;
|
|
123
|
-
} catch (e) {
|
|
124
|
-
console.warn(`[Registry] Failed to preload section module "${resolveType}":`, e);
|
|
125
|
-
return existing;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Get a previously resolved component. Returns undefined if the module
|
|
131
|
-
* hasn't been imported yet. Use this to render WITHOUT React.lazy/Suspense
|
|
132
|
-
* for sections whose JS is already loaded — avoids hydration flash.
|
|
133
|
-
*/
|
|
134
|
-
export function getResolvedComponent(key: string): ComponentType<any> | undefined {
|
|
135
|
-
return resolvedComponents[key];
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Store a resolved component reference. Called after a successful import()
|
|
140
|
-
* so future renders can skip React.lazy entirely.
|
|
141
|
-
*/
|
|
142
|
-
export function setResolvedComponent(key: string, component: ComponentType<any>): void {
|
|
143
|
-
resolvedComponents[key] = component;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* Pre-import section modules and cache their default exports.
|
|
148
|
-
* Called server-side after resolving eager sections so that
|
|
149
|
-
* the SSR render tree uses direct component refs instead of React.lazy.
|
|
150
|
-
*/
|
|
151
|
-
export async function preloadSectionComponents(keys: string[]): Promise<void> {
|
|
152
|
-
await Promise.all(
|
|
153
|
-
keys.map(async (key) => {
|
|
154
|
-
if (resolvedComponents[key]) return;
|
|
155
|
-
const loader = registry[key];
|
|
156
|
-
if (!loader) return;
|
|
157
|
-
try {
|
|
158
|
-
const mod = await loader();
|
|
159
|
-
if (mod?.default) {
|
|
160
|
-
resolvedComponents[key] = mod.default;
|
|
161
|
-
}
|
|
162
|
-
if (mod?.onBeforeResolveProps && !onBeforeResolvePropsRegistry[key]) {
|
|
163
|
-
onBeforeResolvePropsRegistry[key] = mod.onBeforeResolveProps;
|
|
164
|
-
}
|
|
165
|
-
const opts: SectionOptions = { ...sectionOptions[key] };
|
|
166
|
-
if (mod.LoadingFallback) opts.loadingFallback = mod.LoadingFallback;
|
|
167
|
-
if (mod.ErrorFallback) opts.errorFallback = mod.ErrorFallback;
|
|
168
|
-
if (mod.renderJson !== undefined) opts.renderJson = mod.renderJson;
|
|
169
|
-
sectionOptions[key] = opts;
|
|
170
|
-
} catch (e) {
|
|
171
|
-
console.warn(`[Registry] Failed to preload component "${key}":`, e);
|
|
172
|
-
}
|
|
173
|
-
}),
|
|
174
|
-
);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* A sync section entry: either a plain component reference or a full module
|
|
179
|
-
* object with optional LoadingFallback and ErrorFallback.
|
|
180
|
-
* Providing the full module allows DeferredSectionWrapper to show the correct
|
|
181
|
-
* skeleton immediately (optionsReady=true on first render) without waiting for
|
|
182
|
-
* the async preloadSectionModule() call.
|
|
183
|
-
*/
|
|
184
|
-
export type SyncSectionEntry =
|
|
185
|
-
| ComponentType<any>
|
|
186
|
-
| {
|
|
187
|
-
default: ComponentType<any>;
|
|
188
|
-
LoadingFallback?: ComponentType<any>;
|
|
189
|
-
ErrorFallback?: ComponentType<{ error: Error }>;
|
|
190
|
-
renderJson?: RenderJson;
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* Register sections with their already-imported component references.
|
|
195
|
-
* These are available synchronously on both server and client — no dynamic
|
|
196
|
-
* import, no React.lazy, no Suspense. Use for critical above-the-fold
|
|
197
|
-
* sections that must never flash during hydration.
|
|
198
|
-
*
|
|
199
|
-
* Accepts either a plain component or a full module object (with optional
|
|
200
|
-
* LoadingFallback / ErrorFallback). Providing the module object populates
|
|
201
|
-
* sectionOptions immediately, so DeferredSectionWrapper can show the correct
|
|
202
|
-
* skeleton without an extra async preloadSectionModule() round-trip.
|
|
203
|
-
*/
|
|
204
|
-
export function registerSectionsSync(sections: Record<string, SyncSectionEntry>): void {
|
|
205
|
-
for (const [key, entry] of Object.entries(sections)) {
|
|
206
|
-
const raw = typeof entry === "function" ? entry : (entry as any).default;
|
|
207
|
-
// Accept functions and React wrapper objects (React.memo, forwardRef, lazy)
|
|
208
|
-
const REACT_WRAPPERS = [
|
|
209
|
-
Symbol.for("react.memo"),
|
|
210
|
-
Symbol.for("react.forward_ref"),
|
|
211
|
-
Symbol.for("react.lazy"),
|
|
212
|
-
];
|
|
213
|
-
const component =
|
|
214
|
-
typeof raw === "function" ||
|
|
215
|
-
(raw != null && typeof raw === "object" && REACT_WRAPPERS.includes((raw as any).$$typeof))
|
|
216
|
-
? raw
|
|
217
|
-
: undefined;
|
|
218
|
-
if (!component) {
|
|
219
|
-
console.warn(`[registerSectionsSync] "${key}" has no callable default export — skipping`);
|
|
220
|
-
continue;
|
|
221
|
-
}
|
|
222
|
-
syncComponents[key] = component;
|
|
223
|
-
resolvedComponents[key] = component;
|
|
224
|
-
|
|
225
|
-
if (typeof entry !== "function") {
|
|
226
|
-
const opts: SectionOptions = { ...sectionOptions[key] };
|
|
227
|
-
if (entry.LoadingFallback) opts.loadingFallback = entry.LoadingFallback;
|
|
228
|
-
if (entry.ErrorFallback) opts.errorFallback = entry.ErrorFallback;
|
|
229
|
-
if (entry.renderJson !== undefined) opts.renderJson = entry.renderJson;
|
|
230
|
-
sectionOptions[key] = opts;
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
/**
|
|
236
|
-
* Get a synchronously-registered component. Returns undefined if the
|
|
237
|
-
* section was only registered with a lazy loader (registerSections).
|
|
238
|
-
*/
|
|
239
|
-
export function getSyncComponent(key: string): ComponentType<any> | undefined {
|
|
240
|
-
return syncComponents[key];
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
/**
|
|
244
|
-
* Register an onBeforeResolveProps function for a section.
|
|
245
|
-
* Called with raw CMS props (containing unresolved `__resolveType` references)
|
|
246
|
-
* BEFORE the resolution engine resolves them. Use to extract metadata from
|
|
247
|
-
* resolvable structures that would be lost after resolution.
|
|
248
|
-
*/
|
|
249
|
-
export function registerOnBeforeResolveProps(sectionKey: string, fn: OnBeforeResolveProps): void {
|
|
250
|
-
onBeforeResolvePropsRegistry[sectionKey] = fn;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
/** Get the registered onBeforeResolveProps for a section, if any. */
|
|
254
|
-
export function getOnBeforeResolveProps(sectionKey: string): OnBeforeResolveProps | undefined {
|
|
255
|
-
return onBeforeResolvePropsRegistry[sectionKey];
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
export function listRegisteredSections(): string[] {
|
|
259
|
-
return Object.keys(registry);
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
export function getSectionRegistry(): Record<string, RegistryEntry> {
|
|
263
|
-
return registry;
|
|
264
|
-
}
|
package/src/cms/renderJson.ts
DELETED
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* renderJson — structured JSON projection of a resolved page for the mobile app.
|
|
3
|
-
*
|
|
4
|
-
* A section controls how it renders to JSON through a recognized named export
|
|
5
|
-
* `renderJson` (same convention family as `loader`/`action`/`LoadingFallback`):
|
|
6
|
-
*
|
|
7
|
-
* - `export const renderJson = false` — drop the section from the JSON entirely
|
|
8
|
-
* (web-only: theme/analytics/SEO/scripts). It also short-circuits the loader
|
|
9
|
-
* in {@link runSectionLoaders} (no data fetch for a dropped section).
|
|
10
|
-
* - `export const renderJson = (props) => projected` — a pure projection applied
|
|
11
|
-
* to the resolved props before serialization (typically {@link deepOmit} of
|
|
12
|
-
* internal/SEO/store-config fields).
|
|
13
|
-
* - no export — the section serializes with its full resolved props.
|
|
14
|
-
*
|
|
15
|
-
* The whole-page envelope (`?renderJson`) is `{ name, path, sections }`, where
|
|
16
|
-
* each section is `{ component, props }`. This is the lean shape — no admin
|
|
17
|
-
* `resolveChain`/metadata (unlike the legacy `?asJson`).
|
|
18
|
-
*
|
|
19
|
-
* Ported from the deco-runtime fork's `serialize-section.ts`, adapted for the
|
|
20
|
-
* TanStack pipeline: sections are resolved EAGERLY before serialization, so this
|
|
21
|
-
* serializer has no lazy-placeholder (`{ component, lazyUrl }`) branch — the
|
|
22
|
-
* mobile app receives the whole page in one request.
|
|
23
|
-
*
|
|
24
|
-
* ponytail: no nested section-in-section recursion (composite/layout sections).
|
|
25
|
-
* deepOmit handles trimming within a single section's data; add a recursive walk
|
|
26
|
-
* here if a composite section must project its child sections.
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
// deno-lint-ignore-style any: a projection accepts the section's own resolved props.
|
|
30
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
31
|
-
export type RenderJson = ((props: any) => Record<string, unknown>) | false;
|
|
32
|
-
|
|
33
|
-
export interface RenderJsonModule {
|
|
34
|
-
renderJson?: RenderJson;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/** A resolved section after its loader ran: component id + enriched props. */
|
|
38
|
-
export interface SerializableSection {
|
|
39
|
-
component: string;
|
|
40
|
-
props?: Record<string, unknown>;
|
|
41
|
-
/** Position in the page's flat section list (used to interleave with lazy ones). */
|
|
42
|
-
index?: number;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/** A deferred section that isn't resolved eagerly — emitted as a lazy placeholder. */
|
|
46
|
-
export interface DeferredRef {
|
|
47
|
-
component: string;
|
|
48
|
-
index: number;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/** An eager section carries `props`; a lazy one carries a `lazyUrl` to fetch it. */
|
|
52
|
-
export type SerializedSection =
|
|
53
|
-
| { component: string; props: Record<string, unknown> }
|
|
54
|
-
| { component: string; lazyUrl: string };
|
|
55
|
-
|
|
56
|
-
export interface SerializeOptions {
|
|
57
|
-
/**
|
|
58
|
-
* Resolves a section module by resolveType so the serializer can honor its
|
|
59
|
-
* `renderJson` export. When omitted, every section keeps its full props.
|
|
60
|
-
*/
|
|
61
|
-
getSectionModule?: (component: string) => RenderJsonModule | undefined;
|
|
62
|
-
/**
|
|
63
|
-
* App-owned sections excluded from the response, matched by resolveType
|
|
64
|
-
* suffix (e.g. "SeoV2.tsx"). Blank entries are ignored — a "" suffix would
|
|
65
|
-
* endsWith-match every section.
|
|
66
|
-
*/
|
|
67
|
-
sectionsToIgnore?: string[];
|
|
68
|
-
/**
|
|
69
|
-
* Deferred sections to emit as `{ component, lazyUrl }` placeholders,
|
|
70
|
-
* interleaved with the eager ones by `index`. Dropped sections
|
|
71
|
-
* (`renderJson === false` / `sectionsToIgnore`) are omitted here too. When
|
|
72
|
-
* set, the output is ordered by `index`.
|
|
73
|
-
*/
|
|
74
|
-
deferred?: DeferredRef[];
|
|
75
|
-
/** Builds the lazy-fetch URL for a deferred section. Required when `deferred` is set. */
|
|
76
|
-
lazyUrlFor?: (ref: DeferredRef) => string;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Projects a page's sections into the lean renderJson shape. Eager sections
|
|
81
|
-
* become `{ component, props }` (a `renderJson` function projects the props;
|
|
82
|
-
* otherwise props pass through). Deferred sections become
|
|
83
|
-
* `{ component, lazyUrl }`, interleaved by `index`. A section is dropped when
|
|
84
|
-
* its resolveType matches a `sectionsToIgnore` suffix OR its module exports
|
|
85
|
-
* `renderJson === false` (for a deferred section, dropping avoids emitting a
|
|
86
|
-
* lazyUrl the app would fetch for nothing).
|
|
87
|
-
*/
|
|
88
|
-
/**
|
|
89
|
-
* Keys the section loader / mixins inject into props at request time — page
|
|
90
|
-
* context (`__pageUrl`/`__pagePath`, `runSectionLoaders`) and device
|
|
91
|
-
* (`device`/`isMobile`/`currentSearchParam`, the withDevice/withMobile/
|
|
92
|
-
* withSearchParam mixins). They are request-derived framework internals, NOT
|
|
93
|
-
* content, so they are stripped from the JSON: they would bust the ETag per
|
|
94
|
-
* request/device and leak internals the mobile app shouldn't cache. Any
|
|
95
|
-
* `__`-prefixed key is treated as internal by convention (mirrors `__section`).
|
|
96
|
-
*/
|
|
97
|
-
const FRAMEWORK_INJECTED_KEYS = new Set(["device", "isMobile", "currentSearchParam"]);
|
|
98
|
-
|
|
99
|
-
function stripFrameworkKeys(props: Record<string, unknown>): Record<string, unknown> {
|
|
100
|
-
let out: Record<string, unknown> | null = null;
|
|
101
|
-
for (const k of Object.keys(props)) {
|
|
102
|
-
if (k.startsWith("__") || FRAMEWORK_INJECTED_KEYS.has(k)) {
|
|
103
|
-
out ??= { ...props };
|
|
104
|
-
delete out[k];
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
return out ?? props;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export function serializeRenderJson(
|
|
111
|
-
sections: SerializableSection[],
|
|
112
|
-
opts: SerializeOptions = {},
|
|
113
|
-
): SerializedSection[] {
|
|
114
|
-
const ignore = (opts.sectionsToIgnore ?? [])
|
|
115
|
-
.map((s) => s.trim())
|
|
116
|
-
.filter((s) => s.length > 0);
|
|
117
|
-
|
|
118
|
-
const renderJsonOf = (component: string): RenderJson | undefined =>
|
|
119
|
-
opts.getSectionModule?.(component)?.renderJson;
|
|
120
|
-
|
|
121
|
-
const isDropped = (component: string): boolean =>
|
|
122
|
-
ignore.some((suffix) => component.endsWith(suffix)) ||
|
|
123
|
-
renderJsonOf(component) === false;
|
|
124
|
-
|
|
125
|
-
const eager = sections
|
|
126
|
-
.filter((s) => !isDropped(s.component))
|
|
127
|
-
.map((section) => {
|
|
128
|
-
const rj = renderJsonOf(section.component);
|
|
129
|
-
const projected = typeof rj === "function" ? rj(section.props ?? {}) : section.props ?? {};
|
|
130
|
-
const props = stripFrameworkKeys(projected);
|
|
131
|
-
return { index: section.index, out: { component: section.component, props } as SerializedSection };
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
// No deferred sections → preserve input order (backward compatible).
|
|
135
|
-
if (!opts.deferred || opts.deferred.length === 0) {
|
|
136
|
-
return eager.map((e) => e.out);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
const lazyUrlFor = opts.lazyUrlFor;
|
|
140
|
-
const lazy = opts.deferred
|
|
141
|
-
.filter((ref) => !isDropped(ref.component) && !!lazyUrlFor)
|
|
142
|
-
.map((ref) => ({
|
|
143
|
-
index: ref.index,
|
|
144
|
-
out: { component: ref.component, lazyUrl: lazyUrlFor!(ref) } as SerializedSection,
|
|
145
|
-
}));
|
|
146
|
-
|
|
147
|
-
// Interleave eager + lazy by their position in the page's flat section list.
|
|
148
|
-
return [...eager, ...lazy].sort((a, b) => (a.index ?? 0) - (b.index ?? 0)).map((e) => e.out);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* A resolved Deco `Secret` is `{ get: () => string | null }` (apps-website
|
|
153
|
-
* `loaders/secret.ts`) — the plaintext lives behind a function, so JSON.stringify
|
|
154
|
-
* already drops it to `{}`. An unresolved secret block is `{ __resolveType:
|
|
155
|
-
* ".../secret.ts", encrypted, ... }`. Neither has any place in a page-as-JSON
|
|
156
|
-
* payload, so we remove the whole field. Matches by shape, so no content field
|
|
157
|
-
* is caught by accident.
|
|
158
|
-
*
|
|
159
|
-
* Limitation: a *plaintext* secret a loader extracted into a string prop (the
|
|
160
|
-
* deprecated `SecretString` or a manual `secret.get()`) is indistinguishable from
|
|
161
|
-
* content — keep secrets as `Secret`, never resolve them into a serialized prop.
|
|
162
|
-
*/
|
|
163
|
-
export function isSecretValue(value: unknown): boolean {
|
|
164
|
-
if (!value || typeof value !== "object") return false;
|
|
165
|
-
const o = value as Record<string, unknown>;
|
|
166
|
-
// Resolved Secret: an object whose only own key is a `get` function.
|
|
167
|
-
if (typeof o.get === "function" && Object.keys(o).length === 1) return true;
|
|
168
|
-
// Unresolved secret block (defensive — resolved props usually drop __resolveType).
|
|
169
|
-
const rt = o.__resolveType;
|
|
170
|
-
return typeof rt === "string" && /secret/i.test(rt);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* `JSON.stringify` that drops any Secret-shaped value ({@link isSecretValue})
|
|
175
|
-
* anywhere in the tree. Used for both `?renderJson` and `?asJson` bodies.
|
|
176
|
-
*/
|
|
177
|
-
export function stringifyWithoutSecrets(value: unknown): string {
|
|
178
|
-
return JSON.stringify(value, (_key, v) => (isSecretValue(v) ? undefined : v));
|
|
179
|
-
}
|