@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/sdk/flags.ts
DELETED
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Sticky A/B flag persistence via the `deco_segment` cookie — shared by the
|
|
3
|
-
* resolver (SSR variant selection), the worker entry (cache-key cohort
|
|
4
|
-
* splitting), and consumed by analytics (@decocms/apps OneDollarStats reads
|
|
5
|
-
* the same cookie to enrich pageviews/events).
|
|
6
|
-
*
|
|
7
|
-
* ## Why
|
|
8
|
-
*
|
|
9
|
-
* `website/matchers/random.ts` is a stateless `Math.random() < traffic`, so a
|
|
10
|
-
* visitor's variant used to be re-rolled on every request AND frozen per
|
|
11
|
-
* edge-cache entry (the HTML is cached and the cache key never carried the
|
|
12
|
-
* variant). The variant a first visitor happened to roll then got served to
|
|
13
|
-
* everyone in that device/geo bucket, and analytics never saw the flag.
|
|
14
|
-
*
|
|
15
|
-
* ## Cookie format
|
|
16
|
-
*
|
|
17
|
-
* `deco_segment` is the classic deco segment cookie:
|
|
18
|
-
* `btoa(encodeURIComponent(JSON.stringify({ active, inactiveDrawn, pct })))`.
|
|
19
|
-
* - `active` — flag names the visitor was assigned to (`true` branch).
|
|
20
|
-
* - `inactiveDrawn` — flag names drawn but not matched (`false` branch).
|
|
21
|
-
* - `pct` — `{ name: round(traffic*100) }`, a blocks extension (analytics
|
|
22
|
-
* ignores unknown fields) used as the re-roll fingerprint: when the operator
|
|
23
|
-
* changes `traffic` and redeploys, the fingerprint no longer matches and the
|
|
24
|
-
* visitor is re-rolled once, then re-sticks — same self-healing scheme as
|
|
25
|
-
* {@link ./abTesting.ts}.
|
|
26
|
-
* - `exp` — `{ experimentKey: variantId }`, the N-way assignments written by
|
|
27
|
-
* {@link ./experiments.ts}. `active`/`inactiveDrawn` are boolean buckets and
|
|
28
|
-
* physically cannot hold a variant id, so string-valued decisions ride in
|
|
29
|
-
* their own map. It is deliberately the same shape Deco Analytics consumes,
|
|
30
|
-
* so pointing the collector at it later is a read, not a translation.
|
|
31
|
-
* Their re-roll fingerprints share the `pct` map, keyed by experiment key.
|
|
32
|
-
*
|
|
33
|
-
* The cookie MUST be written un-encoded (raw base64) — OneDollarStats reads it
|
|
34
|
-
* with `atob()` directly. Base64's `+ / =` are all valid cookie-value octets
|
|
35
|
-
* (RFC 6265), so pass `encode: (v) => v` to the cookie setter.
|
|
36
|
-
*/
|
|
37
|
-
|
|
38
|
-
/** Cookie carrying the visitor's sticky flag decisions (classic deco segment). */
|
|
39
|
-
export const SEGMENT_COOKIE = "deco_segment";
|
|
40
|
-
|
|
41
|
-
/** A recorded flag decision: which named flag, the branch taken, and the
|
|
42
|
-
* `traffic` fingerprint (0–100) it was decided under. */
|
|
43
|
-
export interface StoredFlag {
|
|
44
|
-
/** Matcher block name, e.g. "TestHero", or an experiment key, e.g.
|
|
45
|
-
* "plp-ranking". Stable identity for the cohort. */
|
|
46
|
-
name: string;
|
|
47
|
-
/**
|
|
48
|
-
* The branch the visitor was assigned to. A boolean for CMS multivariate
|
|
49
|
-
* matchers (the historical case); a variant id for N-way experiments.
|
|
50
|
-
*/
|
|
51
|
-
value: boolean | string;
|
|
52
|
-
/**
|
|
53
|
-
* The fingerprint this decision was made under — `round(traffic * 100)` for
|
|
54
|
-
* a CMS matcher, a weight-vector hash for an experiment. A decision whose
|
|
55
|
-
* stored fingerprint no longer matches the current one is re-rolled once.
|
|
56
|
-
*/
|
|
57
|
-
pct: number;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/** Wire shape of the `deco_segment` cookie payload. */
|
|
61
|
-
interface DecoSegment {
|
|
62
|
-
active?: string[];
|
|
63
|
-
inactiveDrawn?: string[];
|
|
64
|
-
/** blocks extension: per-flag traffic fingerprint. Ignored by analytics. */
|
|
65
|
-
pct?: Record<string, number>;
|
|
66
|
-
/** blocks extension: N-way experiment assignments, `{ key: variantId }`. */
|
|
67
|
-
exp?: Record<string, string>;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/** Convert a 0–1 traffic ratio to the 0–100 integer fingerprint. */
|
|
71
|
-
export function trafficToPct(traffic: number): number {
|
|
72
|
-
if (!Number.isFinite(traffic) || traffic <= 0) return 0;
|
|
73
|
-
if (traffic >= 1) return 100;
|
|
74
|
-
return Math.round(traffic * 100);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Parse the `deco_segment` cookie value into decisions. The value is raw
|
|
79
|
-
* base64 (no URL-decoding needed). Foreign cookies without the `pct` extension
|
|
80
|
-
* parse with `pct: -1`, which the resolver treats as "always matches" so a
|
|
81
|
-
* classic-deco segment stays sticky instead of re-rolling. Malformed cookies
|
|
82
|
-
* yield `[]`.
|
|
83
|
-
*/
|
|
84
|
-
export function parseSegmentCookie(raw: string | undefined | null): StoredFlag[] {
|
|
85
|
-
if (!raw) return [];
|
|
86
|
-
try {
|
|
87
|
-
const seg = JSON.parse(decodeURIComponent(atob(raw))) as DecoSegment;
|
|
88
|
-
const pct = seg.pct ?? {};
|
|
89
|
-
const out: StoredFlag[] = [];
|
|
90
|
-
for (const name of seg.active ?? []) out.push({ name, value: true, pct: pct[name] ?? -1 });
|
|
91
|
-
for (const name of seg.inactiveDrawn ?? []) {
|
|
92
|
-
out.push({ name, value: false, pct: pct[name] ?? -1 });
|
|
93
|
-
}
|
|
94
|
-
for (const [name, variantId] of Object.entries(seg.exp ?? {})) {
|
|
95
|
-
out.push({ name, value: variantId, pct: pct[name] ?? -1 });
|
|
96
|
-
}
|
|
97
|
-
return out;
|
|
98
|
-
} catch {
|
|
99
|
-
return [];
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/** Serialize decisions into a raw-base64 `deco_segment` cookie value. */
|
|
104
|
-
export function serializeSegmentCookie(flags: StoredFlag[]): string {
|
|
105
|
-
const active: string[] = [];
|
|
106
|
-
const inactiveDrawn: string[] = [];
|
|
107
|
-
const pct: Record<string, number> = {};
|
|
108
|
-
const exp: Record<string, string> = {};
|
|
109
|
-
for (const f of [...flags].sort((a, b) => a.name.localeCompare(b.name))) {
|
|
110
|
-
if (typeof f.value === "string") {
|
|
111
|
-
exp[f.name] = f.value;
|
|
112
|
-
} else {
|
|
113
|
-
(f.value ? active : inactiveDrawn).push(f.name);
|
|
114
|
-
}
|
|
115
|
-
pct[f.name] = f.pct;
|
|
116
|
-
}
|
|
117
|
-
const seg: DecoSegment = { active, inactiveDrawn, pct };
|
|
118
|
-
// Omit `exp` entirely when unused so the cookie stays byte-identical to what
|
|
119
|
-
// sites emit today — an added empty map would re-issue every visitor's cookie
|
|
120
|
-
// on deploy and, via segmentCacheToken, cold-start every edge cache entry.
|
|
121
|
-
if (Object.keys(exp).length) seg.exp = exp;
|
|
122
|
-
return btoa(encodeURIComponent(JSON.stringify(seg)));
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Stable token for the cache key — includes the `pct` fingerprint so a
|
|
127
|
-
* `traffic` (or experiment weight) change lands cohorts in fresh buckets.
|
|
128
|
-
* Empty string when there are no flags, so non-A/B pages keep sharing one
|
|
129
|
-
* entry. Experiment assignments fold in on the same footing as boolean flags:
|
|
130
|
-
* without that, two visitors on different variants would share cached HTML.
|
|
131
|
-
*/
|
|
132
|
-
export function segmentCacheToken(flags: StoredFlag[]): string {
|
|
133
|
-
if (!flags.length) return "";
|
|
134
|
-
return [...flags]
|
|
135
|
-
.sort((a, b) => a.name.localeCompare(b.name))
|
|
136
|
-
.map((f) => `${f.name}:${typeof f.value === "string" ? f.value : f.value ? "1" : "0"}:${f.pct}`)
|
|
137
|
-
.join(",");
|
|
138
|
-
}
|
package/src/sdk/http.ts
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* HTTP constants and small typed helpers — replaces the parts of Deno's
|
|
3
|
-
* `@std/http` (other than cookies, which live in `./cookie.ts`) that deco
|
|
4
|
-
* storefronts touch.
|
|
5
|
-
*
|
|
6
|
-
* Currently exposes:
|
|
7
|
-
* - `STATUS_CODE` — full IANA status-code map (parity with @std/http).
|
|
8
|
-
* - `UserAgent` — minimal class with the same shape; does not parse
|
|
9
|
-
* the UA string (sites only used `.toString()` and
|
|
10
|
-
* basic browser/os accessors in dev). Replace with a
|
|
11
|
-
* real parser like `ua-parser-js` if you actually
|
|
12
|
-
* depend on the parsed fields.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
export const STATUS_CODE = {
|
|
16
|
-
Continue: 100,
|
|
17
|
-
SwitchingProtocols: 101,
|
|
18
|
-
Processing: 102,
|
|
19
|
-
EarlyHints: 103,
|
|
20
|
-
OK: 200,
|
|
21
|
-
Created: 201,
|
|
22
|
-
Accepted: 202,
|
|
23
|
-
NonAuthoritativeInfo: 203,
|
|
24
|
-
NoContent: 204,
|
|
25
|
-
ResetContent: 205,
|
|
26
|
-
PartialContent: 206,
|
|
27
|
-
MultiStatus: 207,
|
|
28
|
-
AlreadyReported: 208,
|
|
29
|
-
IMUsed: 226,
|
|
30
|
-
MultipleChoices: 300,
|
|
31
|
-
MovedPermanently: 301,
|
|
32
|
-
Found: 302,
|
|
33
|
-
SeeOther: 303,
|
|
34
|
-
NotModified: 304,
|
|
35
|
-
UseProxy: 305,
|
|
36
|
-
TemporaryRedirect: 307,
|
|
37
|
-
PermanentRedirect: 308,
|
|
38
|
-
BadRequest: 400,
|
|
39
|
-
Unauthorized: 401,
|
|
40
|
-
PaymentRequired: 402,
|
|
41
|
-
Forbidden: 403,
|
|
42
|
-
NotFound: 404,
|
|
43
|
-
MethodNotAllowed: 405,
|
|
44
|
-
NotAcceptable: 406,
|
|
45
|
-
ProxyAuthRequired: 407,
|
|
46
|
-
RequestTimeout: 408,
|
|
47
|
-
Conflict: 409,
|
|
48
|
-
Gone: 410,
|
|
49
|
-
LengthRequired: 411,
|
|
50
|
-
PreconditionFailed: 412,
|
|
51
|
-
ContentTooLarge: 413,
|
|
52
|
-
URITooLong: 414,
|
|
53
|
-
UnsupportedMediaType: 415,
|
|
54
|
-
RangeNotSatisfiable: 416,
|
|
55
|
-
ExpectationFailed: 417,
|
|
56
|
-
Teapot: 418,
|
|
57
|
-
MisdirectedRequest: 421,
|
|
58
|
-
UnprocessableEntity: 422,
|
|
59
|
-
Locked: 423,
|
|
60
|
-
FailedDependency: 424,
|
|
61
|
-
TooEarly: 425,
|
|
62
|
-
UpgradeRequired: 426,
|
|
63
|
-
PreconditionRequired: 428,
|
|
64
|
-
TooManyRequests: 429,
|
|
65
|
-
RequestHeaderFieldsTooLarge: 431,
|
|
66
|
-
UnavailableForLegalReasons: 451,
|
|
67
|
-
InternalServerError: 500,
|
|
68
|
-
NotImplemented: 501,
|
|
69
|
-
BadGateway: 502,
|
|
70
|
-
ServiceUnavailable: 503,
|
|
71
|
-
GatewayTimeout: 504,
|
|
72
|
-
HTTPVersionNotSupported: 505,
|
|
73
|
-
VariantAlsoNegotiates: 506,
|
|
74
|
-
InsufficientStorage: 507,
|
|
75
|
-
LoopDetected: 508,
|
|
76
|
-
NotExtended: 510,
|
|
77
|
-
NetworkAuthenticationRequired: 511,
|
|
78
|
-
} as const;
|
|
79
|
-
|
|
80
|
-
export type StatusCode = typeof STATUS_CODE[keyof typeof STATUS_CODE];
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Minimal stand-in for Deno's `@std/http`'s `UserAgent`. Captures the raw
|
|
84
|
-
* UA string and exposes the same field shape; does NOT parse. Replace with
|
|
85
|
-
* a real parser when you start depending on parsed fields.
|
|
86
|
-
*/
|
|
87
|
-
export class UserAgent {
|
|
88
|
-
ua: string;
|
|
89
|
-
browser: { name?: string; version?: string };
|
|
90
|
-
os: { name?: string; version?: string };
|
|
91
|
-
device: { vendor?: string; model?: string; type?: string };
|
|
92
|
-
cpu: { architecture?: string };
|
|
93
|
-
engine: { name?: string; version?: string };
|
|
94
|
-
|
|
95
|
-
constructor(ua: string | null) {
|
|
96
|
-
this.ua = ua ?? "";
|
|
97
|
-
this.browser = {};
|
|
98
|
-
this.os = {};
|
|
99
|
-
this.device = {};
|
|
100
|
-
this.cpu = {};
|
|
101
|
-
this.engine = {};
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
toString(): string {
|
|
105
|
-
return this.ua;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Lightweight HTTP error class. Drop-in for the `HttpError` shape that
|
|
111
|
-
* `deco-cx/apps` exposes — sites use it as `error instanceof HttpError &&
|
|
112
|
-
* error.status === 304` and similar.
|
|
113
|
-
*/
|
|
114
|
-
export class HttpError extends Error {
|
|
115
|
-
status: number;
|
|
116
|
-
body?: unknown;
|
|
117
|
-
|
|
118
|
-
constructor(status: number, message?: string, body?: unknown) {
|
|
119
|
-
super(message ?? `HTTP ${status}`);
|
|
120
|
-
this.name = "HttpError";
|
|
121
|
-
this.status = status;
|
|
122
|
-
this.body = body;
|
|
123
|
-
}
|
|
124
|
-
}
|
package/src/sdk/index.ts
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
export { ANALYTICS_SCRIPT, type DataEventParams, gtmScript, useSendEvent } from "./analytics";
|
|
2
|
-
export {
|
|
3
|
-
type CacheProfileConfig,
|
|
4
|
-
type CacheProfileName,
|
|
5
|
-
type CacheProfileOverrides,
|
|
6
|
-
type CacheTimingWindow,
|
|
7
|
-
cacheHeaders,
|
|
8
|
-
detectCacheProfile,
|
|
9
|
-
type EdgeCacheConfig,
|
|
10
|
-
edgeCacheConfig,
|
|
11
|
-
getCacheProfile,
|
|
12
|
-
type LoaderCacheOptions,
|
|
13
|
-
loaderCacheOptions,
|
|
14
|
-
registerCachePattern,
|
|
15
|
-
routeCacheDefaults,
|
|
16
|
-
setCacheProfile,
|
|
17
|
-
} from "./cacheHeaders";
|
|
18
|
-
export { clx } from "./clx";
|
|
19
|
-
export { decodeCookie, deleteCookie, getCookie, getServerSideCookie, setCookie } from "./cookie";
|
|
20
|
-
export { buildCSPHeaderValue, type CSPOptions, setCSPHeaders } from "./csp";
|
|
21
|
-
export { deepOmit } from "./deepOmit";
|
|
22
|
-
export { djb2, djb2Hex } from "./djb2";
|
|
23
|
-
export { isDevMode } from "./env";
|
|
24
|
-
export {
|
|
25
|
-
DEFAULT_FETCH_TIMEOUT_MS,
|
|
26
|
-
type FetchFn,
|
|
27
|
-
withFetchTimeout,
|
|
28
|
-
withTimeoutSignal,
|
|
29
|
-
} from "./fetchTimeout";
|
|
30
|
-
export {
|
|
31
|
-
createInstrumentedFetch,
|
|
32
|
-
type FetchInstrumentationOptions,
|
|
33
|
-
type FetchMetrics,
|
|
34
|
-
instrumentFetch,
|
|
35
|
-
} from "./instrumentedFetch";
|
|
36
|
-
export {
|
|
37
|
-
batchInvoke,
|
|
38
|
-
createAppInvoke,
|
|
39
|
-
createInvokeProxy,
|
|
40
|
-
type InvokeProxy,
|
|
41
|
-
invoke,
|
|
42
|
-
invokeQueryOptions,
|
|
43
|
-
type NestedFromFlat,
|
|
44
|
-
} from "./invoke";
|
|
45
|
-
export { createCacheControlCollector, mergeCacheControl } from "./mergeCacheControl";
|
|
46
|
-
export {
|
|
47
|
-
getProductionOrigins,
|
|
48
|
-
normalizeUrlsInObject,
|
|
49
|
-
registerProductionOrigins,
|
|
50
|
-
} from "./normalizeUrls";
|
|
51
|
-
export {
|
|
52
|
-
addRedirects,
|
|
53
|
-
loadRedirects,
|
|
54
|
-
matchRedirect,
|
|
55
|
-
parseRedirectsCsv,
|
|
56
|
-
type Redirect,
|
|
57
|
-
type RedirectMap,
|
|
58
|
-
registerRedirectResolveType,
|
|
59
|
-
} from "./redirects";
|
|
60
|
-
export { createServerTimings, type ServerTimings } from "./serverTimings";
|
|
61
|
-
export { type ReactiveSignal, signal } from "./signal";
|
|
62
|
-
export { redactUrl, type RedactUrlOptions } from "./urlRedaction";
|
|
63
|
-
export {
|
|
64
|
-
canonicalUrl,
|
|
65
|
-
cleanPathForCacheKey,
|
|
66
|
-
hasTrackingParams,
|
|
67
|
-
registerTrackingParam,
|
|
68
|
-
registerTrackingParams,
|
|
69
|
-
stripTrackingParams,
|
|
70
|
-
} from "./urlUtils";
|
|
71
|
-
export {
|
|
72
|
-
checkDesktop,
|
|
73
|
-
checkMobile,
|
|
74
|
-
checkTablet,
|
|
75
|
-
type Device,
|
|
76
|
-
DeviceContext,
|
|
77
|
-
DeviceProvider,
|
|
78
|
-
detectDevice,
|
|
79
|
-
isMobileUA,
|
|
80
|
-
MOBILE_RE,
|
|
81
|
-
TABLET_RE,
|
|
82
|
-
useDevice,
|
|
83
|
-
} from "./useDevice";
|
|
84
|
-
export { useId } from "./useId";
|
|
85
|
-
export {
|
|
86
|
-
inlineScript,
|
|
87
|
-
usePartialSection,
|
|
88
|
-
useScript,
|
|
89
|
-
useScriptAsDataURI,
|
|
90
|
-
useSection,
|
|
91
|
-
} from "./useScript";
|
|
92
|
-
export {
|
|
93
|
-
isWrappedError,
|
|
94
|
-
unwrapError,
|
|
95
|
-
type WrappedError,
|
|
96
|
-
wrapCaughtErrors,
|
|
97
|
-
} from "./wrapCaughtErrors";
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Inflight-Promise timeout guard for module-level dedup caches.
|
|
3
|
-
*
|
|
4
|
-
* Background: across `@decocms/start` (and `@decocms/apps`) we keep
|
|
5
|
-
* `Map<string, Promise<...>>` caches at module scope to dedup concurrent
|
|
6
|
-
* resolutions of the same loader / section / layout block. Entries are
|
|
7
|
-
* evicted via `.finally()` on the stored Promise.
|
|
8
|
-
*
|
|
9
|
-
* The problem: if the wrapped work never settles — e.g. an upstream `fetch()`
|
|
10
|
-
* hangs because a CDN holds the TCP connection open — the `.finally()` never
|
|
11
|
-
* runs and the Map entry leaks forever. With
|
|
12
|
-
* `no_handle_cross_request_promise_resolution: true` on the consumer Worker,
|
|
13
|
-
* the zombie Promise survives across requests. Every subsequent caller for
|
|
14
|
-
* the same key `await`s it, pinning request context into memory until
|
|
15
|
-
* `exceededMemory` terminates the isolate.
|
|
16
|
-
*
|
|
17
|
-
* Production observation on a TanStack Start storefront (24h window): 514
|
|
18
|
-
* hard `exceededMemory` crashes, with CPU time ~0 and wall time in the tens
|
|
19
|
-
* of minutes — workers sleeping on the dead Promise, not computing.
|
|
20
|
-
*
|
|
21
|
-
* Fix: race the stored Promise against a timeout so its terminal state is
|
|
22
|
-
* guaranteed, which means `.finally()` always runs and the Map slot is
|
|
23
|
-
* freed. The underlying hung work is abandoned (the CF runtime will GC it
|
|
24
|
-
* once the request ends).
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
/** Default per-entry timeout for inflight dedup caches. */
|
|
28
|
-
export const DEFAULT_INFLIGHT_TIMEOUT_MS = 10_000;
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Race `work` against a timeout. If `work` doesn't settle within `ms`, the
|
|
32
|
-
* returned Promise rejects with a descriptive error so callers' `.finally()`
|
|
33
|
-
* cleanup always runs.
|
|
34
|
-
*/
|
|
35
|
-
export function withInflightTimeout<T>(
|
|
36
|
-
work: Promise<T>,
|
|
37
|
-
label: string,
|
|
38
|
-
ms: number = DEFAULT_INFLIGHT_TIMEOUT_MS,
|
|
39
|
-
): Promise<T> {
|
|
40
|
-
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
41
|
-
const timeout = new Promise<never>((_, reject) => {
|
|
42
|
-
timer = setTimeout(() => {
|
|
43
|
-
reject(
|
|
44
|
-
new Error(
|
|
45
|
-
`[blocks] inflight cache entry "${label}" timed out after ${ms}ms`,
|
|
46
|
-
),
|
|
47
|
-
);
|
|
48
|
-
}, ms);
|
|
49
|
-
});
|
|
50
|
-
return Promise.race([work, timeout]).finally(() => {
|
|
51
|
-
if (timer !== undefined) clearTimeout(timer);
|
|
52
|
-
});
|
|
53
|
-
}
|