@decocms/blocks 8.9.0 → 8.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/protocol/channel.d.ts +98 -0
- package/dist/protocol/channel.d.ts.map +1 -0
- package/dist/protocol/channel.js +58 -0
- package/dist/protocol/channel.js.map +1 -0
- package/dist/protocol/client.js +2 -2
- package/dist/protocol/client.js.map +1 -1
- package/dist/protocol/conformance/blockMetaVectors.json +214 -0
- package/dist/protocol/conformance/contentHashFixtures.d.ts +22 -0
- package/dist/protocol/conformance/contentHashFixtures.d.ts.map +1 -1
- package/dist/protocol/conformance/contentHashFixtures.js +55 -0
- package/dist/protocol/conformance/contentHashFixtures.js.map +1 -1
- package/dist/protocol/conformance/index.d.ts +2 -1
- package/dist/protocol/conformance/index.d.ts.map +1 -1
- package/dist/protocol/conformance/index.js +2 -1
- package/dist/protocol/conformance/index.js.map +1 -1
- package/dist/protocol/conformance/vectors.d.ts +33 -0
- package/dist/protocol/conformance/vectors.d.ts.map +1 -0
- package/dist/protocol/conformance/vectors.js +3 -0
- package/dist/protocol/conformance/vectors.js.map +1 -0
- package/dist/protocol/index.d.ts +11 -1
- package/dist/protocol/index.d.ts.map +1 -1
- package/dist/protocol/index.js +11 -1
- package/dist/protocol/index.js.map +1 -1
- package/dist/protocol/keys.d.ts +1 -1
- package/dist/protocol/keys.js +1 -1
- package/dist/v8/background.d.ts +13 -0
- package/dist/v8/background.d.ts.map +1 -1
- package/dist/v8/background.js +41 -0
- package/dist/v8/background.js.map +1 -1
- package/dist/v8/blockMeta.d.ts +27 -0
- package/dist/v8/blockMeta.d.ts.map +1 -0
- package/dist/v8/blockMeta.js +75 -0
- package/dist/v8/blockMeta.js.map +1 -0
- package/dist/v8/blockStore.d.ts +43 -0
- package/dist/v8/blockStore.d.ts.map +1 -0
- package/dist/v8/blockStore.js +95 -0
- package/dist/v8/blockStore.js.map +1 -0
- package/dist/v8/boundedJson.d.ts +5 -0
- package/dist/v8/boundedJson.d.ts.map +1 -1
- package/dist/v8/boundedJson.js +10 -2
- package/dist/v8/boundedJson.js.map +1 -1
- package/dist/v8/boundedMap.d.ts +19 -0
- package/dist/v8/boundedMap.d.ts.map +1 -0
- package/dist/v8/boundedMap.js +52 -0
- package/dist/v8/boundedMap.js.map +1 -0
- package/dist/v8/builtins/data.d.ts +18 -2
- package/dist/v8/builtins/data.d.ts.map +1 -1
- package/dist/v8/builtins/data.js +17 -1
- package/dist/v8/builtins/data.js.map +1 -1
- package/dist/v8/builtins/index.d.ts.map +1 -1
- package/dist/v8/builtins/index.js +2 -1
- package/dist/v8/builtins/index.js.map +1 -1
- package/dist/v8/builtins/legacy.d.ts +6 -3
- package/dist/v8/builtins/legacy.d.ts.map +1 -1
- package/dist/v8/builtins/legacy.js +6 -3
- package/dist/v8/builtins/legacy.js.map +1 -1
- package/dist/v8/canonical.d.ts +8 -0
- package/dist/v8/canonical.d.ts.map +1 -1
- package/dist/v8/canonical.js +15 -0
- package/dist/v8/canonical.js.map +1 -1
- package/dist/v8/cli/builtins.d.ts.map +1 -1
- package/dist/v8/cli/builtins.js +1 -0
- package/dist/v8/cli/builtins.js.map +1 -1
- package/dist/v8/cli/check/index.d.ts +10 -0
- package/dist/v8/cli/check/index.d.ts.map +1 -1
- package/dist/v8/cli/check/index.js +91 -7
- package/dist/v8/cli/check/index.js.map +1 -1
- package/dist/v8/cli/content.d.ts +12 -25
- package/dist/v8/cli/content.d.ts.map +1 -1
- package/dist/v8/cli/content.js +46 -75
- package/dist/v8/cli/content.js.map +1 -1
- package/dist/v8/cli/index.d.ts +1 -2
- package/dist/v8/cli/index.d.ts.map +1 -1
- package/dist/v8/cli/index.js +1 -2
- package/dist/v8/cli/index.js.map +1 -1
- package/dist/v8/cli/remote/commands.d.ts +71 -0
- package/dist/v8/cli/remote/commands.d.ts.map +1 -0
- package/dist/v8/cli/remote/commands.js +644 -0
- package/dist/v8/cli/remote/commands.js.map +1 -0
- package/dist/v8/cli/remote/diff.d.ts +15 -0
- package/dist/v8/cli/remote/diff.d.ts.map +1 -0
- package/dist/v8/cli/remote/diff.js +102 -0
- package/dist/v8/cli/remote/diff.js.map +1 -0
- package/dist/v8/cli/remote/env.d.ts +35 -0
- package/dist/v8/cli/remote/env.d.ts.map +1 -0
- package/dist/v8/cli/remote/env.js +84 -0
- package/dist/v8/cli/remote/env.js.map +1 -0
- package/dist/v8/cli/remote/http.d.ts +149 -0
- package/dist/v8/cli/remote/http.d.ts.map +1 -0
- package/dist/v8/cli/remote/http.js +381 -0
- package/dist/v8/cli/remote/http.js.map +1 -0
- package/dist/v8/cli/remote/local.d.ts +90 -0
- package/dist/v8/cli/remote/local.d.ts.map +1 -0
- package/dist/v8/cli/remote/local.js +309 -0
- package/dist/v8/cli/remote/local.js.map +1 -0
- package/dist/v8/cli/root.d.ts +29 -0
- package/dist/v8/cli/root.d.ts.map +1 -1
- package/dist/v8/cli/root.js +28 -0
- package/dist/v8/cli/root.js.map +1 -1
- package/dist/v8/cli/run.d.ts +11 -1
- package/dist/v8/cli/run.d.ts.map +1 -1
- package/dist/v8/cli/run.js +281 -124
- package/dist/v8/cli/run.js.map +1 -1
- package/dist/v8/cli/schema/builtinSchemas.d.ts.map +1 -1
- package/dist/v8/cli/schema/builtinSchemas.js +28 -10
- package/dist/v8/cli/schema/builtinSchemas.js.map +1 -1
- package/dist/v8/cli/schema/generate.js +1 -1
- package/dist/v8/cli/schema/generate.js.map +1 -1
- package/dist/v8/client.d.ts +9 -9
- package/dist/v8/client.d.ts.map +1 -1
- package/dist/v8/client.js +138 -50
- package/dist/v8/client.js.map +1 -1
- package/dist/v8/cms.d.ts +2 -1
- package/dist/v8/cms.d.ts.map +1 -1
- package/dist/v8/cms.js +55 -46
- package/dist/v8/cms.js.map +1 -1
- package/dist/v8/content.d.ts +39 -78
- package/dist/v8/content.d.ts.map +1 -1
- package/dist/v8/content.js +155 -195
- package/dist/v8/content.js.map +1 -1
- package/dist/v8/contentIndex.d.ts +71 -0
- package/dist/v8/contentIndex.d.ts.map +1 -0
- package/dist/v8/contentIndex.js +137 -0
- package/dist/v8/contentIndex.js.map +1 -0
- package/dist/v8/draft.d.ts +7 -7
- package/dist/v8/draft.d.ts.map +1 -1
- package/dist/v8/draft.js +10 -9
- package/dist/v8/draft.js.map +1 -1
- package/dist/v8/draftChanges.d.ts +59 -32
- package/dist/v8/draftChanges.d.ts.map +1 -1
- package/dist/v8/draftChanges.js +139 -75
- package/dist/v8/draftChanges.js.map +1 -1
- package/dist/v8/errors.d.ts +21 -0
- package/dist/v8/errors.d.ts.map +1 -1
- package/dist/v8/errors.js +22 -0
- package/dist/v8/errors.js.map +1 -1
- package/dist/v8/hostedSource.d.ts +57 -0
- package/dist/v8/hostedSource.d.ts.map +1 -0
- package/dist/v8/hostedSource.js +18 -0
- package/dist/v8/hostedSource.js.map +1 -0
- package/dist/v8/identity.d.ts +1 -1
- package/dist/v8/identity.js +1 -1
- package/dist/v8/index.d.ts +1 -0
- package/dist/v8/index.d.ts.map +1 -1
- package/dist/v8/index.js +1 -0
- package/dist/v8/index.js.map +1 -1
- package/dist/v8/matchRoute.js +7 -4
- package/dist/v8/matchRoute.js.map +1 -1
- package/dist/v8/pin.d.ts +34 -0
- package/dist/v8/pin.d.ts.map +1 -0
- package/dist/v8/pin.js +156 -0
- package/dist/v8/pin.js.map +1 -0
- package/dist/v8/preview/StudioBridge.d.ts +8 -8
- package/dist/v8/preview/StudioBridge.d.ts.map +1 -1
- package/dist/v8/preview/StudioBridge.js +8 -10
- package/dist/v8/preview/StudioBridge.js.map +1 -1
- package/dist/v8/preview/StudioChannel.d.ts +51 -0
- package/dist/v8/preview/StudioChannel.d.ts.map +1 -0
- package/dist/v8/preview/StudioChannel.js +104 -0
- package/dist/v8/preview/StudioChannel.js.map +1 -0
- package/dist/v8/preview/index.d.ts +3 -0
- package/dist/v8/preview/index.d.ts.map +1 -1
- package/dist/v8/preview/index.js +3 -0
- package/dist/v8/preview/index.js.map +1 -1
- package/dist/v8/remoteLoader.d.ts +42 -5
- package/dist/v8/remoteLoader.d.ts.map +1 -1
- package/dist/v8/remoteLoader.js +317 -259
- package/dist/v8/remoteLoader.js.map +1 -1
- package/dist/v8/resolver.d.ts +22 -8
- package/dist/v8/resolver.d.ts.map +1 -1
- package/dist/v8/resolver.js +37 -32
- package/dist/v8/resolver.js.map +1 -1
- package/dist/v8/revisionId.d.ts +11 -0
- package/dist/v8/revisionId.d.ts.map +1 -0
- package/dist/v8/revisionId.js +13 -0
- package/dist/v8/revisionId.js.map +1 -0
- package/dist/v8/settings.d.ts +6 -6
- package/dist/v8/settings.d.ts.map +1 -1
- package/dist/v8/settings.js +8 -7
- package/dist/v8/settings.js.map +1 -1
- package/dist/v8/telemetry.d.ts +4 -2
- package/dist/v8/telemetry.d.ts.map +1 -1
- package/dist/v8/telemetry.js +2 -2
- package/dist/v8/telemetry.js.map +1 -1
- package/dist/v8/types.d.ts +52 -40
- package/dist/v8/types.d.ts.map +1 -1
- package/dist/v8/variants.d.ts +7 -2
- package/dist/v8/variants.d.ts.map +1 -1
- package/dist/v8/variants.js +21 -24
- package/dist/v8/variants.js.map +1 -1
- package/dist/v8/vite/index.d.ts +2 -2
- package/dist/v8/vite/index.js +1 -1
- package/dist/v8/vite/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +2 -0
- package/src/protocol/channel.ts +127 -0
- package/src/protocol/client.ts +2 -2
- package/src/protocol/conformance/blockMetaVectors.json +214 -0
- package/src/protocol/conformance/contentHashFixtures.ts +74 -0
- package/src/protocol/conformance/index.ts +9 -1
- package/src/protocol/conformance/vectors.ts +36 -0
- package/src/protocol/index.ts +32 -0
- package/src/protocol/keys.ts +1 -1
- package/src/v8/background.ts +42 -0
- package/src/v8/blockMeta.ts +100 -0
- package/src/v8/blockStore.ts +124 -0
- package/src/v8/boundedJson.ts +20 -2
- package/src/v8/boundedMap.ts +53 -0
- package/src/v8/builtins/data.ts +26 -2
- package/src/v8/builtins/index.ts +2 -1
- package/src/v8/builtins/legacy.ts +6 -3
- package/src/v8/canonical.ts +15 -0
- package/src/v8/cli/builtins.ts +1 -0
- package/src/v8/cli/check/index.ts +97 -7
- package/src/v8/cli/content.ts +49 -91
- package/src/v8/cli/index.ts +1 -2
- package/src/v8/cli/remote/commands.ts +834 -0
- package/src/v8/cli/remote/diff.ts +100 -0
- package/src/v8/cli/remote/env.ts +107 -0
- package/src/v8/cli/remote/http.ts +484 -0
- package/src/v8/cli/remote/local.ts +343 -0
- package/src/v8/cli/root.ts +40 -0
- package/src/v8/cli/run.ts +333 -136
- package/src/v8/cli/schema/builtinSchemas.ts +29 -10
- package/src/v8/cli/schema/generate.ts +1 -1
- package/src/v8/client.ts +162 -60
- package/src/v8/cms.ts +62 -53
- package/src/v8/content.ts +179 -229
- package/src/v8/contentIndex.ts +183 -0
- package/src/v8/draft.ts +15 -14
- package/src/v8/draftChanges.ts +151 -85
- package/src/v8/errors.ts +37 -0
- package/src/v8/hostedSource.ts +67 -0
- package/src/v8/identity.ts +1 -1
- package/src/v8/index.ts +1 -0
- package/src/v8/matchRoute.ts +7 -4
- package/src/v8/pin.ts +176 -0
- package/src/v8/preview/StudioBridge.ts +8 -10
- package/src/v8/preview/StudioChannel.ts +116 -0
- package/src/v8/preview/index.ts +3 -0
- package/src/v8/remoteLoader.ts +350 -286
- package/src/v8/resolver.ts +56 -33
- package/src/v8/revisionId.ts +14 -0
- package/src/v8/settings.ts +10 -9
- package/src/v8/telemetry.ts +3 -3
- package/src/v8/types.ts +52 -40
- package/src/v8/variants.ts +30 -26
- package/src/v8/vite/index.ts +3 -3
- package/dist/v8/cli/serve/server.d.ts +0 -29
- package/dist/v8/cli/serve/server.d.ts.map +0 -1
- package/dist/v8/cli/serve/server.js +0 -296
- package/dist/v8/cli/serve/server.js.map +0 -1
- package/src/v8/cli/serve/server.ts +0 -348
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vectors.d.ts","sourceRoot":"","sources":["../../../src/protocol/conformance/vectors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAGnE,MAAM,WAAW,eAAe;IAC9B,qCAAqC;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,OAAO,CAAC;IACd,4BAA4B;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,gCAAgC;IAChC,IAAI,EAAE,SAAS,CAAC;IAChB,uCAAuC;IACvC,KAAK,EAAE,UAAU,CAAC;CACnB;AAED,MAAM,WAAW,gBAAgB;IAC/B,+DAA+D;IAC/D,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,KAAK,EAAE,SAAS,eAAe,EAAE,CAAC;CACnC;AAED,eAAO,MAAM,gBAAgB,EAAE,gBAA8C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vectors.js","sourceRoot":"","sources":["../../../src/protocol/conformance/vectors.ts"],"names":[],"mappings":"AAeA,OAAO,OAAO,MAAM,yBAAyB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAoBpE,MAAM,CAAC,MAAM,gBAAgB,GAAqB,OAA2B,CAAC"}
|
package/dist/protocol/index.d.ts
CHANGED
|
@@ -14,12 +14,22 @@
|
|
|
14
14
|
* - `@decocms/blocks/protocol/storage/fs` — the filesystem storage (Node only)
|
|
15
15
|
* - `@decocms/blocks/protocol/conformance` — a black-box test suite over HTTP
|
|
16
16
|
*
|
|
17
|
+
* The Studio channel's messages (`deco:ready`, `deco:load`, ...) and the
|
|
18
|
+
* context a Studio module gets are here too (`./channel.ts`):
|
|
19
|
+
* the page's bootstrap is `StudioChannel` in `@decocms/blocks/preview`.
|
|
20
|
+
*
|
|
21
|
+
* `blockMeta`/`indexEntry` compute a hosted revision index's entries (the
|
|
22
|
+
* SDK's own browser-safe module, shared with Studio and the CLI).
|
|
23
|
+
*
|
|
17
24
|
* The SDK's runtime never imports the protocol, so it never reaches an app
|
|
18
25
|
* bundle. The canonical hash it re-exports is the SDK's own dependency-free
|
|
19
26
|
* leaf module (see ./canonical.ts). Draft previews and the draft lifecycle
|
|
20
27
|
* are outside the protocol (see /next/content-delivery#draft-previews).
|
|
21
28
|
*/
|
|
22
|
-
export {
|
|
29
|
+
export { type BlockIndex, type BlockMeta, blockMeta, type IndexEntry, indexEntry, } from "../v8/blockMeta.ts";
|
|
30
|
+
export { isRevisionId, REVISION_ID_RE } from "../v8/revisionId.ts";
|
|
31
|
+
export { blockVersion, CanonicalJsonError, CONTENT_HASH_FORMAT, canonicalJson, computeContentRevision, sha256Hex, } from "./canonical.ts";
|
|
32
|
+
export { CHANNEL_MESSAGE, type ChannelLoadErrorMessage, type ChannelLoadedMessage, type ChannelLoadMessage, type ChannelReadyMessage, DEFAULT_STUDIO_ORIGIN, DEFAULT_STUDIO_ORIGINS, defineStudioModule, type ModuleMessage, type PageChannelMessage, type StudioChannelContext, type StudioChannelMessage, type StudioChannelModule, } from "./channel.ts";
|
|
23
33
|
export { assertSupportedEndpoint, type BatchCall, type BatchOutcome, type ContentClient, type ContentClientOptions, createContentClient, } from "./client.ts";
|
|
24
34
|
export * from "./errors.ts";
|
|
25
35
|
export * from "./keys.ts";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/protocol/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/protocol/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EACL,KAAK,UAAU,EACf,KAAK,SAAS,EACd,SAAS,EACT,KAAK,UAAU,EACf,UAAU,GACX,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,mBAAmB,EACnB,aAAa,EACb,sBAAsB,EACtB,SAAS,GACV,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,eAAe,EACf,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,qBAAqB,EACrB,sBAAsB,EACtB,kBAAkB,EAClB,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,GACzB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,uBAAuB,EACvB,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,mBAAmB,GACpB,MAAM,aAAa,CAAC;AACrB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}
|
package/dist/protocol/index.js
CHANGED
|
@@ -14,12 +14,22 @@
|
|
|
14
14
|
* - `@decocms/blocks/protocol/storage/fs` — the filesystem storage (Node only)
|
|
15
15
|
* - `@decocms/blocks/protocol/conformance` — a black-box test suite over HTTP
|
|
16
16
|
*
|
|
17
|
+
* The Studio channel's messages (`deco:ready`, `deco:load`, ...) and the
|
|
18
|
+
* context a Studio module gets are here too (`./channel.ts`):
|
|
19
|
+
* the page's bootstrap is `StudioChannel` in `@decocms/blocks/preview`.
|
|
20
|
+
*
|
|
21
|
+
* `blockMeta`/`indexEntry` compute a hosted revision index's entries (the
|
|
22
|
+
* SDK's own browser-safe module, shared with Studio and the CLI).
|
|
23
|
+
*
|
|
17
24
|
* The SDK's runtime never imports the protocol, so it never reaches an app
|
|
18
25
|
* bundle. The canonical hash it re-exports is the SDK's own dependency-free
|
|
19
26
|
* leaf module (see ./canonical.ts). Draft previews and the draft lifecycle
|
|
20
27
|
* are outside the protocol (see /next/content-delivery#draft-previews).
|
|
21
28
|
*/
|
|
22
|
-
export {
|
|
29
|
+
export { blockMeta, indexEntry, } from "../v8/blockMeta.js";
|
|
30
|
+
export { isRevisionId, REVISION_ID_RE } from "../v8/revisionId.js";
|
|
31
|
+
export { blockVersion, CanonicalJsonError, CONTENT_HASH_FORMAT, canonicalJson, computeContentRevision, sha256Hex, } from "./canonical.js";
|
|
32
|
+
export { CHANNEL_MESSAGE, DEFAULT_STUDIO_ORIGIN, DEFAULT_STUDIO_ORIGINS, defineStudioModule, } from "./channel.js";
|
|
23
33
|
export { assertSupportedEndpoint, createContentClient, } from "./client.js";
|
|
24
34
|
export * from "./errors.js";
|
|
25
35
|
export * from "./keys.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/protocol/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/protocol/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAGL,SAAS,EAET,UAAU,GACX,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,mBAAmB,EACnB,aAAa,EACb,sBAAsB,EACtB,SAAS,GACV,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,eAAe,EAKf,qBAAqB,EACrB,sBAAsB,EACtB,kBAAkB,GAMnB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,uBAAuB,EAKvB,mBAAmB,GACpB,MAAM,aAAa,CAAC;AACrB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}
|
package/dist/protocol/keys.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The one file-name rule for saved blocks (`@decocms/blocks/protocol/keys`).
|
|
3
3
|
*
|
|
4
|
-
* The site editor,
|
|
4
|
+
* The site editor, the deco CLI and the content module all import this module, so
|
|
5
5
|
* an entry the site editor edits is the entry the app renders:
|
|
6
6
|
*
|
|
7
7
|
* - **Name to file:** `encodeURIComponent(name) + ".json"`, directly in
|
package/dist/protocol/keys.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The one file-name rule for saved blocks (`@decocms/blocks/protocol/keys`).
|
|
3
3
|
*
|
|
4
|
-
* The site editor,
|
|
4
|
+
* The site editor, the deco CLI and the content module all import this module, so
|
|
5
5
|
* an entry the site editor edits is the entry the app renders:
|
|
6
6
|
*
|
|
7
7
|
* - **Name to file:** `encodeURIComponent(name) + ".json"`, directly in
|
package/dist/v8/background.d.ts
CHANGED
|
@@ -18,6 +18,19 @@
|
|
|
18
18
|
*/
|
|
19
19
|
type Task = () => unknown;
|
|
20
20
|
export declare function runInBackground(task: Task): void;
|
|
21
|
+
/**
|
|
22
|
+
* Keeps the request that started `promise` alive until it settles, where the
|
|
23
|
+
* runtime ends a request's work with its response: a host's hook, or on
|
|
24
|
+
* Cloudflare Workers the platform's `waitUntil`. Unlike
|
|
25
|
+
* {@link runInBackground}, the work has already started: nothing is
|
|
26
|
+
* deferred. Elsewhere a pending promise needs nothing to settle, so this does
|
|
27
|
+
* nothing. Never throws.
|
|
28
|
+
*
|
|
29
|
+
* Shared work goes through here: a fetch a later request may await (a block
|
|
30
|
+
* body by hash, `latest.json`, a revision's index) must not die with the
|
|
31
|
+
* request that happened to start it.
|
|
32
|
+
*/
|
|
33
|
+
export declare function keepAlive(promise: Promise<unknown>): void;
|
|
21
34
|
/** `setTimeout` that never keeps a Node process alive. */
|
|
22
35
|
export declare function later(ms: number, callback: () => void): void;
|
|
23
36
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"background.d.ts","sourceRoot":"","sources":["../../src/v8/background.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAKH,KAAK,IAAI,GAAG,MAAM,OAAO,CAAC;AAoC1B,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAqChD;AAED,0DAA0D;AAC1D,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI,CAG5D;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAE3C"}
|
|
1
|
+
{"version":3,"file":"background.d.ts","sourceRoot":"","sources":["../../src/v8/background.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAKH,KAAK,IAAI,GAAG,MAAM,OAAO,CAAC;AAoC1B,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAqChD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,IAAI,CA4BzD;AAED,0DAA0D;AAC1D,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI,CAG5D;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAE3C"}
|
package/dist/v8/background.js
CHANGED
|
@@ -83,6 +83,47 @@ export function runInBackground(task) {
|
|
|
83
83
|
void run();
|
|
84
84
|
});
|
|
85
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* Keeps the request that started `promise` alive until it settles, where the
|
|
88
|
+
* runtime ends a request's work with its response: a host's hook, or on
|
|
89
|
+
* Cloudflare Workers the platform's `waitUntil`. Unlike
|
|
90
|
+
* {@link runInBackground}, the work has already started: nothing is
|
|
91
|
+
* deferred. Elsewhere a pending promise needs nothing to settle, so this does
|
|
92
|
+
* nothing. Never throws.
|
|
93
|
+
*
|
|
94
|
+
* Shared work goes through here: a fetch a later request may await (a block
|
|
95
|
+
* body by hash, `latest.json`, a revision's index) must not die with the
|
|
96
|
+
* request that happened to start it.
|
|
97
|
+
*/
|
|
98
|
+
export function keepAlive(promise) {
|
|
99
|
+
const settled = promise.then(() => { }, () => { });
|
|
100
|
+
const g = globalThis;
|
|
101
|
+
const hook = g[BACKGROUND_HOOK];
|
|
102
|
+
try {
|
|
103
|
+
if (typeof hook === "function") {
|
|
104
|
+
hook(() => settled);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
if (onWorkers()) {
|
|
108
|
+
void workersWaitUntil().then((waitUntil) => {
|
|
109
|
+
if (waitUntil === undefined)
|
|
110
|
+
return;
|
|
111
|
+
if (typeof g[BACKGROUND_HOOK] !== "function") {
|
|
112
|
+
g[BACKGROUND_HOOK] = (next) => waitUntil(next());
|
|
113
|
+
}
|
|
114
|
+
try {
|
|
115
|
+
g[BACKGROUND_HOOK]?.(() => settled);
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
// As below.
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
catch {
|
|
124
|
+
// Outside a request there is no request to keep: the work just runs.
|
|
125
|
+
}
|
|
126
|
+
}
|
|
86
127
|
/** `setTimeout` that never keeps a Node process alive. */
|
|
87
128
|
export function later(ms, callback) {
|
|
88
129
|
const timer = setTimeout(callback, ms);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"background.js","sourceRoot":"","sources":["../../src/v8/background.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;;;;;;;;;AAEH,iFAAiF;AACjF,MAAM,eAAe,GAAG,MAAM,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;AAMhE,4DAA4D;AAC5D,SAAS,SAAS;IAChB,OAAO,CACJ,UAAqD,CAAC,SAAS,EAAE,SAAS;QAC3E,oBAA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;QACH,IAAI,OAAO,IAAI,KAAK,UAAU,EAAE,CAAC;YAC/B,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC;YACpB,OAAO;QACT,CAAC;QACD,IAAI,SAAS,EAAE,EAAE,CAAC;YAChB,KAAK,gBAAgB,EAAE,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE;gBACzC,IAAI,SAAS,KAAK,SAAS;oBAAE,OAAO;gBACpC,IAAI,OAAO,CAAC,CAAC,eAAe,CAAC,KAAK,UAAU,EAAE,CAAC;oBAC7C,CAAC,CAAC,eAAe,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC;gBACnD,CAAC;gBACD,IAAI,CAAC;oBACH,CAAC,CAAC,eAAe,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC;gBACtC,CAAC;gBAAC,MAAM,CAAC;oBACP,YAAY;gBACd,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,qEAAqE;IACvE,CAAC;AACH,CAAC;AAED,0DAA0D;AAC1D,MAAM,UAAU,KAAK,CAAC,EAAU,EAAE,QAAoB;IACpD,MAAM,KAAK,GAAG,UAAU,CAAC,QAAQ,EAAE,EAAE,CAAsC,CAAC;IAC5E,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC;AACnB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB;IAC/B,OAAO,OAAQ,UAAgC,CAAC,eAAe,CAAC,KAAK,UAAU,IAAI,SAAS,EAAE,CAAC;AACjG,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** What an index says about a block, besides its hash. */
|
|
2
|
+
export interface BlockMeta {
|
|
3
|
+
/** The body's raw `__resolveType`. */
|
|
4
|
+
type?: string;
|
|
5
|
+
/** The body's top-level `path`. */
|
|
6
|
+
path?: string;
|
|
7
|
+
/** The block names the body references, deduped, in code-unit order. */
|
|
8
|
+
refs?: string[];
|
|
9
|
+
}
|
|
10
|
+
/** One entry of a revision index. */
|
|
11
|
+
export interface IndexEntry {
|
|
12
|
+
/** `blockVersion(body)`: the hash the body is stored under (`blocks/<version>.json`). */
|
|
13
|
+
version: string;
|
|
14
|
+
/** Omitted when empty. */
|
|
15
|
+
meta?: BlockMeta;
|
|
16
|
+
/** The body itself, only on the CMS settings entry (`CMS`). */
|
|
17
|
+
data?: unknown;
|
|
18
|
+
}
|
|
19
|
+
/** A revision index's blocks: block name → entry. */
|
|
20
|
+
export type BlockIndex = Record<string, IndexEntry>;
|
|
21
|
+
/** The well-known name whose body every index inlines as `data`. */
|
|
22
|
+
export declare const INLINE_BLOCK = "CMS";
|
|
23
|
+
/** The metadata of one block body; `names` are the block names of the index being built. */
|
|
24
|
+
export declare function blockMeta(body: unknown, names: ReadonlySet<string> | readonly string[]): BlockMeta;
|
|
25
|
+
/** The index entry for a block: its hash, its metadata when any, and its body when it is `CMS`. */
|
|
26
|
+
export declare function indexEntry(name: string, body: unknown, names: ReadonlySet<string> | readonly string[]): Promise<IndexEntry>;
|
|
27
|
+
//# sourceMappingURL=blockMeta.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blockMeta.d.ts","sourceRoot":"","sources":["../../src/v8/blockMeta.ts"],"names":[],"mappings":"AAuBA,0DAA0D;AAC1D,MAAM,WAAW,SAAS;IACxB,sCAAsC;IACtC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,mCAAmC;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,wEAAwE;IACxE,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,qCAAqC;AACrC,MAAM,WAAW,UAAU;IACzB,yFAAyF;IACzF,OAAO,EAAE,MAAM,CAAC;IAChB,0BAA0B;IAC1B,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,+DAA+D;IAC/D,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,qDAAqD;AACrD,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AAEpD,oEAAoE;AACpE,eAAO,MAAM,YAAY,QAAQ,CAAC;AAElC,4FAA4F;AAC5F,wBAAgB,SAAS,CACvB,IAAI,EAAE,OAAO,EACb,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,SAAS,MAAM,EAAE,GAC7C,SAAS,CAUX;AAED,mGAAmG;AACnG,wBAAsB,UAAU,CAC9B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,OAAO,EACb,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,SAAS,MAAM,EAAE,GAC7C,OAAO,CAAC,UAAU,CAAC,CAMrB"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Index entries of a hosted release (see /next/hosted-releases-internals):
|
|
3
|
+
* `revisions/<id>/index.json` and `latest.json` map each block name to its
|
|
4
|
+
* hash (`version`) plus the little metadata routing and the reference walk
|
|
5
|
+
* need, so neither needs a block body.
|
|
6
|
+
*
|
|
7
|
+
* `blockMeta(body, names)` is the one helper Studio, the SDK and the CLI use
|
|
8
|
+
* to compute that metadata, so all three write and read the same entries.
|
|
9
|
+
* Pure, synchronous, browser-safe; its only import is the dependency-free
|
|
10
|
+
* canonical hash (for `indexEntry`).
|
|
11
|
+
*
|
|
12
|
+
* - `type`: the body's raw top-level `__resolveType`, copied without alias
|
|
13
|
+
* mapping (readers map it with their alias rules).
|
|
14
|
+
* - `path`: the body's top-level `path`, when it is a string (any type).
|
|
15
|
+
* - `refs`: every `__resolveType` string anywhere in the body (the top-level
|
|
16
|
+
* one included, every variant, `never` and `lazy` values included) that is
|
|
17
|
+
* one of `names`, deduped and sorted in code-unit order.
|
|
18
|
+
*
|
|
19
|
+
* A key is present only when it has a value (`refs: []` is left out), so a
|
|
20
|
+
* body with nothing to say gives `{}` and its entry carries no `meta`.
|
|
21
|
+
*/
|
|
22
|
+
import { blockVersion } from "./canonical.js";
|
|
23
|
+
/** The well-known name whose body every index inlines as `data`. */
|
|
24
|
+
export const INLINE_BLOCK = "CMS";
|
|
25
|
+
/** The metadata of one block body; `names` are the block names of the index being built. */
|
|
26
|
+
export function blockMeta(body, names) {
|
|
27
|
+
const meta = {};
|
|
28
|
+
if (!isRecord(body))
|
|
29
|
+
return meta;
|
|
30
|
+
if (typeof body.__resolveType === "string")
|
|
31
|
+
meta.type = body.__resolveType;
|
|
32
|
+
if (typeof body.path === "string")
|
|
33
|
+
meta.path = body.path;
|
|
34
|
+
const known = isSet(names) ? names : new Set(names);
|
|
35
|
+
const found = new Set();
|
|
36
|
+
collectRefs(body, known, found);
|
|
37
|
+
if (found.size > 0)
|
|
38
|
+
meta.refs = [...found].sort();
|
|
39
|
+
return meta;
|
|
40
|
+
}
|
|
41
|
+
/** The index entry for a block: its hash, its metadata when any, and its body when it is `CMS`. */
|
|
42
|
+
export async function indexEntry(name, body, names) {
|
|
43
|
+
const entry = { version: await blockVersion(body) };
|
|
44
|
+
const meta = blockMeta(body, names);
|
|
45
|
+
if (Object.keys(meta).length > 0)
|
|
46
|
+
entry.meta = meta;
|
|
47
|
+
if (name === INLINE_BLOCK)
|
|
48
|
+
entry.data = body;
|
|
49
|
+
return entry;
|
|
50
|
+
}
|
|
51
|
+
function collectRefs(node, names, found) {
|
|
52
|
+
if (Array.isArray(node)) {
|
|
53
|
+
for (const item of node)
|
|
54
|
+
collectRefs(item, names, found);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (!isRecord(node))
|
|
58
|
+
return;
|
|
59
|
+
for (const [key, value] of Object.entries(node)) {
|
|
60
|
+
if (key === "__resolveType") {
|
|
61
|
+
if (typeof value === "string" && names.has(value))
|
|
62
|
+
found.add(value);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
collectRefs(value, names, found);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function isRecord(value) {
|
|
70
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
71
|
+
}
|
|
72
|
+
function isSet(value) {
|
|
73
|
+
return !Array.isArray(value);
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=blockMeta.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blockMeta.js","sourceRoot":"","sources":["../../src/v8/blockMeta.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAyB9C,oEAAoE;AACpE,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,CAAC;AAElC,4FAA4F;AAC5F,MAAM,UAAU,SAAS,CACvB,IAAa,EACb,KAA8C;IAE9C,MAAM,IAAI,GAAc,EAAE,CAAC;IAC3B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IACjC,IAAI,OAAO,IAAI,CAAC,aAAa,KAAK,QAAQ;QAAE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,aAAa,CAAC;IAC3E,IAAI,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ;QAAE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;IACzD,MAAM,KAAK,GAAwB,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;IACzE,MAAM,KAAK,GAAG,IAAI,GAAG,EAAU,CAAC;IAChC,WAAW,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IAChC,IAAI,KAAK,CAAC,IAAI,GAAG,CAAC;QAAE,IAAI,CAAC,IAAI,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC;IAClD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,mGAAmG;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,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,KAAK,CAAC,KAA8C;IAC3D,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hosted block bodies by hash (see /next/hosted-releases-internals): an LRU
|
|
3
|
+
* per isolate, bounded by bytes, in front of plain `fetch()` of
|
|
4
|
+
* `sites/<site>/blocks/<hash>.json` through the delivery CDN.
|
|
5
|
+
*
|
|
6
|
+
* A hash always means the same body, so nothing here is ever invalidated.
|
|
7
|
+
* Concurrent requests for one hash share one fetch; a fetch that fails isn't
|
|
8
|
+
* kept, so the next request that needs it tries again.
|
|
9
|
+
*
|
|
10
|
+
* A shared fetch belongs to the request that started it, and some runtimes
|
|
11
|
+
* (Cloudflare Workers) stop a request's I/O with its response: a fetch the
|
|
12
|
+
* request only prefetched would then never settle, and every later request
|
|
13
|
+
* that needs the body would wait on it forever. So:
|
|
14
|
+
* - every fetch is kept alive until it settles (`keepAlive`: the platform's
|
|
15
|
+
* `waitUntil`), whoever started it;
|
|
16
|
+
* - a request that joins another's fetch waits for it no longer than that
|
|
17
|
+
* fetch's own deadline (the 10 s every fetch has, plus a margin): past it
|
|
18
|
+
* the fetch is dropped from the map, that request's read fails with a
|
|
19
|
+
* `"timeout"` `ContentUnavailableError`, and the next request fetches
|
|
20
|
+
* again; a fetch already past its deadline when a request asks is dropped
|
|
21
|
+
* and fetched again at once.
|
|
22
|
+
*/
|
|
23
|
+
import type { BodySource } from "./contentIndex.ts";
|
|
24
|
+
/** The default byte bound of the LRU: the sum of the bodies' JSON text lengths. */
|
|
25
|
+
export declare const DEFAULT_BLOCK_CACHE_BYTES: number;
|
|
26
|
+
/**
|
|
27
|
+
* How long a shared fetch may stay in flight: the 10 s each fetch has
|
|
28
|
+
* (headers and body), plus a second's margin. A fetch still in flight past
|
|
29
|
+
* it is one whose request went away.
|
|
30
|
+
*/
|
|
31
|
+
export declare const IN_FLIGHT_DEADLINE_MS = 11000;
|
|
32
|
+
/** A fetched body and the length of its JSON text. */
|
|
33
|
+
export interface FetchedBody {
|
|
34
|
+
body: unknown;
|
|
35
|
+
bytes: number;
|
|
36
|
+
}
|
|
37
|
+
export declare class BlockStore implements BodySource {
|
|
38
|
+
#private;
|
|
39
|
+
constructor(fetchBody: (hash: string, name: string) => Promise<FetchedBody>, limitBytes?: number, deadlineMs?: number);
|
|
40
|
+
peek(hash: string): unknown | undefined;
|
|
41
|
+
get(hash: string, name: string): Promise<unknown>;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=blockStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blockStore.d.ts","sourceRoot":"","sources":["../../src/v8/blockStore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAGpD,mFAAmF;AACnF,eAAO,MAAM,yBAAyB,QAAmB,CAAC;AAE1D;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,QAAS,CAAC;AAE5C,sDAAsD;AACtD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAQD,qBAAa,UAAW,YAAW,UAAU;;IAM3C,YACE,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,WAAW,CAAC,EAC/D,UAAU,SAA4B,EACtC,UAAU,SAAwB,EAKnC;IAED,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAEtC;IAED,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAWhD;CA0CF"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hosted block bodies by hash (see /next/hosted-releases-internals): an LRU
|
|
3
|
+
* per isolate, bounded by bytes, in front of plain `fetch()` of
|
|
4
|
+
* `sites/<site>/blocks/<hash>.json` through the delivery CDN.
|
|
5
|
+
*
|
|
6
|
+
* A hash always means the same body, so nothing here is ever invalidated.
|
|
7
|
+
* Concurrent requests for one hash share one fetch; a fetch that fails isn't
|
|
8
|
+
* kept, so the next request that needs it tries again.
|
|
9
|
+
*
|
|
10
|
+
* A shared fetch belongs to the request that started it, and some runtimes
|
|
11
|
+
* (Cloudflare Workers) stop a request's I/O with its response: a fetch the
|
|
12
|
+
* request only prefetched would then never settle, and every later request
|
|
13
|
+
* that needs the body would wait on it forever. So:
|
|
14
|
+
* - every fetch is kept alive until it settles (`keepAlive`: the platform's
|
|
15
|
+
* `waitUntil`), whoever started it;
|
|
16
|
+
* - a request that joins another's fetch waits for it no longer than that
|
|
17
|
+
* fetch's own deadline (the 10 s every fetch has, plus a margin): past it
|
|
18
|
+
* the fetch is dropped from the map, that request's read fails with a
|
|
19
|
+
* `"timeout"` `ContentUnavailableError`, and the next request fetches
|
|
20
|
+
* again; a fetch already past its deadline when a request asks is dropped
|
|
21
|
+
* and fetched again at once.
|
|
22
|
+
*/
|
|
23
|
+
import { keepAlive } from "./background.js";
|
|
24
|
+
import { BoundedMap } from "./boundedMap.js";
|
|
25
|
+
import { ContentUnavailableError } from "./errors.js";
|
|
26
|
+
/** The default byte bound of the LRU: the sum of the bodies' JSON text lengths. */
|
|
27
|
+
export const DEFAULT_BLOCK_CACHE_BYTES = 32 * 1024 * 1024;
|
|
28
|
+
/**
|
|
29
|
+
* How long a shared fetch may stay in flight: the 10 s each fetch has
|
|
30
|
+
* (headers and body), plus a second's margin. A fetch still in flight past
|
|
31
|
+
* it is one whose request went away.
|
|
32
|
+
*/
|
|
33
|
+
export const IN_FLIGHT_DEADLINE_MS = 11_000;
|
|
34
|
+
export class BlockStore {
|
|
35
|
+
#fetch;
|
|
36
|
+
#lru;
|
|
37
|
+
#deadlineMs;
|
|
38
|
+
#inFlight = new Map();
|
|
39
|
+
constructor(fetchBody, limitBytes = DEFAULT_BLOCK_CACHE_BYTES, deadlineMs = IN_FLIGHT_DEADLINE_MS) {
|
|
40
|
+
this.#fetch = fetchBody;
|
|
41
|
+
this.#lru = new BoundedMap(limitBytes, (entry) => entry.bytes);
|
|
42
|
+
this.#deadlineMs = deadlineMs;
|
|
43
|
+
}
|
|
44
|
+
peek(hash) {
|
|
45
|
+
return this.#lru.get(hash)?.body;
|
|
46
|
+
}
|
|
47
|
+
get(hash, name) {
|
|
48
|
+
const held = this.#lru.get(hash);
|
|
49
|
+
if (held !== undefined)
|
|
50
|
+
return Promise.resolve(held.body);
|
|
51
|
+
const shared = this.#inFlight.get(hash);
|
|
52
|
+
if (shared !== undefined) {
|
|
53
|
+
const left = shared.at + this.#deadlineMs - Date.now();
|
|
54
|
+
if (left > 0)
|
|
55
|
+
return this.#join(hash, name, shared, left);
|
|
56
|
+
// Past its deadline: its request went away without settling it.
|
|
57
|
+
this.#inFlight.delete(hash);
|
|
58
|
+
}
|
|
59
|
+
return this.#start(hash, name);
|
|
60
|
+
}
|
|
61
|
+
#start(hash, name) {
|
|
62
|
+
const body = this.#fetch(hash, name).then((fetched) => {
|
|
63
|
+
this.#lru.set(hash, fetched);
|
|
64
|
+
return fetched.body;
|
|
65
|
+
});
|
|
66
|
+
const entry = { body, at: Date.now() };
|
|
67
|
+
this.#inFlight.set(hash, entry);
|
|
68
|
+
const settle = () => {
|
|
69
|
+
if (this.#inFlight.get(hash) === entry)
|
|
70
|
+
this.#inFlight.delete(hash);
|
|
71
|
+
};
|
|
72
|
+
body.then(settle, settle);
|
|
73
|
+
keepAlive(body);
|
|
74
|
+
return body;
|
|
75
|
+
}
|
|
76
|
+
/** Another request's fetch, awaited for at most `ms`. */
|
|
77
|
+
#join(hash, name, entry, ms) {
|
|
78
|
+
return new Promise((resolve, reject) => {
|
|
79
|
+
const timer = setTimeout(() => {
|
|
80
|
+
if (this.#inFlight.get(hash) === entry)
|
|
81
|
+
this.#inFlight.delete(hash);
|
|
82
|
+
reject(new ContentUnavailableError("timeout", `block "${name}" (${hash}): no answer within ${this.#deadlineMs} ms`));
|
|
83
|
+
}, ms);
|
|
84
|
+
timer?.unref?.();
|
|
85
|
+
entry.body.then((body) => {
|
|
86
|
+
clearTimeout(timer);
|
|
87
|
+
resolve(body);
|
|
88
|
+
}, (error) => {
|
|
89
|
+
clearTimeout(timer);
|
|
90
|
+
reject(error);
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=blockStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blockStore.js","sourceRoot":"","sources":["../../src/v8/blockStore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAEtD,mFAAmF;AACnF,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAE1D;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC;AAc5C,MAAM,OAAO,UAAU;IACZ,MAAM,CAAuD;IAC7D,IAAI,CAAkC;IACtC,WAAW,CAAS;IACpB,SAAS,GAAG,IAAI,GAAG,EAAoB,CAAC;IAEjD,YACE,SAA+D,EAC/D,UAAU,GAAG,yBAAyB,EACtC,UAAU,GAAG,qBAAqB;QAElC,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,IAAI,UAAU,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAA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;YAChB,CAAC,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
|
package/dist/v8/boundedJson.d.ts
CHANGED
|
@@ -8,4 +8,9 @@
|
|
|
8
8
|
export declare function timeoutSignal(ms: number): AbortSignal | undefined;
|
|
9
9
|
/** Parses a JSON body, refusing it once it passes `maxBytes`. */
|
|
10
10
|
export declare function readBoundedJson(response: Response, label: string, maxBytes: number): Promise<unknown>;
|
|
11
|
+
/** `readBoundedJson`, plus the length of the JSON text (what a byte-bounded cache counts). */
|
|
12
|
+
export declare function readBoundedJsonSized(response: Response, label: string, maxBytes: number): Promise<{
|
|
13
|
+
value: unknown;
|
|
14
|
+
bytes: number;
|
|
15
|
+
}>;
|
|
11
16
|
//# sourceMappingURL=boundedJson.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boundedJson.d.ts","sourceRoot":"","sources":["../../src/v8/boundedJson.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,0FAA0F;AAC1F,wBAAgB,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAIjE;AAED,iEAAiE;AACjE,wBAAsB,eAAe,CACnC,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"boundedJson.d.ts","sourceRoot":"","sources":["../../src/v8/boundedJson.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,0FAA0F;AAC1F,wBAAgB,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAIjE;AAED,iEAAiE;AACjE,wBAAsB,eAAe,CACnC,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,OAAO,CAAC,CAElB;AAED,8FAA8F;AAC9F,wBAAsB,oBAAoB,CACxC,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAG5C"}
|
package/dist/v8/boundedJson.js
CHANGED
|
@@ -12,6 +12,14 @@ export function timeoutSignal(ms) {
|
|
|
12
12
|
}
|
|
13
13
|
/** Parses a JSON body, refusing it once it passes `maxBytes`. */
|
|
14
14
|
export async function readBoundedJson(response, label, maxBytes) {
|
|
15
|
+
return (await readBoundedJsonSized(response, label, maxBytes)).value;
|
|
16
|
+
}
|
|
17
|
+
/** `readBoundedJson`, plus the length of the JSON text (what a byte-bounded cache counts). */
|
|
18
|
+
export async function readBoundedJsonSized(response, label, maxBytes) {
|
|
19
|
+
const text = await readBoundedText(response, label, maxBytes);
|
|
20
|
+
return { value: JSON.parse(text), bytes: text.length };
|
|
21
|
+
}
|
|
22
|
+
async function readBoundedText(response, label, maxBytes) {
|
|
15
23
|
const tooLarge = () => new Error(`${label}: larger than ${maxBytes} bytes`);
|
|
16
24
|
if (Number(response.headers.get("content-length")) > maxBytes) {
|
|
17
25
|
await response.body?.cancel();
|
|
@@ -21,7 +29,7 @@ export async function readBoundedJson(response, label, maxBytes) {
|
|
|
21
29
|
const text = await response.text();
|
|
22
30
|
if (text.length > maxBytes)
|
|
23
31
|
throw tooLarge();
|
|
24
|
-
return
|
|
32
|
+
return text;
|
|
25
33
|
}
|
|
26
34
|
const reader = response.body.getReader();
|
|
27
35
|
const decoder = new TextDecoder();
|
|
@@ -39,6 +47,6 @@ export async function readBoundedJson(response, label, maxBytes) {
|
|
|
39
47
|
parts.push(decoder.decode(value, { stream: true }));
|
|
40
48
|
}
|
|
41
49
|
parts.push(decoder.decode());
|
|
42
|
-
return
|
|
50
|
+
return parts.join("");
|
|
43
51
|
}
|
|
44
52
|
//# sourceMappingURL=boundedJson.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boundedJson.js","sourceRoot":"","sources":["../../src/v8/boundedJson.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,0FAA0F;AAC1F,MAAM,UAAU,aAAa,CAAC,EAAU;IACtC,OAAO,OAAO,WAAW,KAAK,WAAW,IAAI,OAAO,WAAW,CAAC,OAAO,KAAK,UAAU;QACpF,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC;QACzB,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC;AAED,iEAAiE;AACjE,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,QAAkB,EAClB,KAAa,EACb,QAAgB;IAEhB,MAAM,QAAQ,GAAG,GAAG,EAAE,CAAC,IAAI,KAAK,CAAC,GAAG,KAAK,iBAAiB,QAAQ,QAAQ,CAAC,CAAC;IAC5E,IAAI,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC,GAAG,QAAQ,EAAE,CAAC;QAC9D,MAAM,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC;QAC9B,MAAM,QAAQ,EAAE,CAAC;IACnB,CAAC;IACD,IAAI,QAAQ,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;QAC3B,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QACnC,IAAI,IAAI,CAAC,MAAM,GAAG,QAAQ;YAAE,MAAM,QAAQ,EAAE,CAAC;QAC7C,OAAO,IAAI,CAAC
|
|
1
|
+
{"version":3,"file":"boundedJson.js","sourceRoot":"","sources":["../../src/v8/boundedJson.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,0FAA0F;AAC1F,MAAM,UAAU,aAAa,CAAC,EAAU;IACtC,OAAO,OAAO,WAAW,KAAK,WAAW,IAAI,OAAO,WAAW,CAAC,OAAO,KAAK,UAAU;QACpF,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC;QACzB,CAAC,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G,IAAI,WAAW,EAAE,CAAC;IAClC,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,SAAS,CAAC;QACR,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;QAC5C,IAAI,IAAI;YAAE,MAAM;QAChB,IAAI,IAAI,KAAK,CAAC,UAAU,CAAC;QACzB,IAAI,IAAI,GAAG,QAAQ,EAAE,CAAC;YACpB,MAAM,MAAM,CAAC,MAAM,EAAE,CAAC;YACtB,MAAM,QAAQ,EAAE,CAAC;QACnB,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IACtD,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAC7B,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACxB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A Map that forgets its least recently used entries past `limit`, counted by
|
|
3
|
+
* `size` (one per entry unless given). An entry larger than the limit on its
|
|
4
|
+
* own is kept until the next `set`.
|
|
5
|
+
*/
|
|
6
|
+
export declare class BoundedMap<K, V> {
|
|
7
|
+
#private;
|
|
8
|
+
readonly limit: number;
|
|
9
|
+
readonly size: (value: V) => number;
|
|
10
|
+
constructor(limit: number, size?: (value: V) => number);
|
|
11
|
+
get(key: K): V | undefined;
|
|
12
|
+
has(key: K): boolean;
|
|
13
|
+
set(key: K, value: V): void;
|
|
14
|
+
delete(key: K): void;
|
|
15
|
+
clear(): void;
|
|
16
|
+
/** The total size held. */
|
|
17
|
+
get total(): number;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=boundedMap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boundedMap.d.ts","sourceRoot":"","sources":["../../src/v8/boundedMap.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,qBAAa,UAAU,CAAC,CAAC,EAAE,CAAC;;IAIxB,QAAQ,CAAC,KAAK,EAAE,MAAM;IACtB,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM;IAFrC,YACW,KAAK,EAAE,MAAM,EACb,IAAI,GAAE,CAAC,KAAK,EAAE,CAAC,KAAK,MAAgB,EAC3C;IAEJ,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS,CAOzB;IAED,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,OAAO,CAEnB;IAED,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAS1B;IAED,MAAM,CAAC,GAAG,EAAE,CAAC,GAAG,IAAI,CAInB;IAED,KAAK,IAAI,IAAI,CAGZ;IAED,2BAA2B;IAC3B,IAAI,KAAK,IAAI,MAAM,CAElB;CACF"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A Map that forgets its least recently used entries past `limit`, counted by
|
|
3
|
+
* `size` (one per entry unless given). An entry larger than the limit on its
|
|
4
|
+
* own is kept until the next `set`.
|
|
5
|
+
*/
|
|
6
|
+
export class BoundedMap {
|
|
7
|
+
limit;
|
|
8
|
+
size;
|
|
9
|
+
#map = new Map();
|
|
10
|
+
#total = 0;
|
|
11
|
+
constructor(limit, size = () => 1) {
|
|
12
|
+
this.limit = limit;
|
|
13
|
+
this.size = size;
|
|
14
|
+
}
|
|
15
|
+
get(key) {
|
|
16
|
+
const value = this.#map.get(key);
|
|
17
|
+
if (value !== undefined) {
|
|
18
|
+
this.#map.delete(key);
|
|
19
|
+
this.#map.set(key, value);
|
|
20
|
+
}
|
|
21
|
+
return value;
|
|
22
|
+
}
|
|
23
|
+
has(key) {
|
|
24
|
+
return this.#map.has(key);
|
|
25
|
+
}
|
|
26
|
+
set(key, value) {
|
|
27
|
+
this.delete(key);
|
|
28
|
+
this.#map.set(key, value);
|
|
29
|
+
this.#total += this.size(value);
|
|
30
|
+
for (const [oldest, old] of this.#map) {
|
|
31
|
+
if (this.#total <= this.limit || oldest === key)
|
|
32
|
+
break;
|
|
33
|
+
this.#map.delete(oldest);
|
|
34
|
+
this.#total -= this.size(old);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
delete(key) {
|
|
38
|
+
if (!this.#map.has(key))
|
|
39
|
+
return;
|
|
40
|
+
this.#total -= this.size(this.#map.get(key));
|
|
41
|
+
this.#map.delete(key);
|
|
42
|
+
}
|
|
43
|
+
clear() {
|
|
44
|
+
this.#map.clear();
|
|
45
|
+
this.#total = 0;
|
|
46
|
+
}
|
|
47
|
+
/** The total size held. */
|
|
48
|
+
get total() {
|
|
49
|
+
return this.#total;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=boundedMap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boundedMap.js","sourceRoot":"","sources":["../../src/v8/boundedMap.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,OAAO,UAAU;IAIV,KAAK;IACL,IAAI;IAJN,IAAI,GAAG,IAAI,GAAG,EAAQ,CAAC;IAChC,MAAM,GAAG,CAAC,CAAC;IACX,YACW,KAAa,EACb,IAAI,GAAyB,GAAG,EAAE,CAAC,CAAC;qBADpC,KAAK;oBACL,IAAI;IACZ,CAAC;IAEJ,GAAG,CAAC,GAAM;QACR,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACjC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACtB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,K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@
|
|
|
1
|
-
import type { Analytics, CMSSettings, Redirect, Telemetry } from "../types.ts";
|
|
1
|
+
import type { Analytics, CMSSettings, LegacyRedirect, Redirect, Telemetry } from "../types.ts";
|
|
2
2
|
/** The hosted Deco CMS collector: where page views go when `collector` is left out. */
|
|
3
3
|
export declare const HOSTED_ANALYTICS_COLLECTOR = "https://d.lilstts.com/events";
|
|
4
4
|
/** Where the Deco Analytics tag loads from unless the site opts into first-party. */
|
|
@@ -10,8 +10,24 @@ export declare const DECO_ANALYTICS_SCRIPT = "/_dq/a.js";
|
|
|
10
10
|
* `sections`), so the page is its input.
|
|
11
11
|
*/
|
|
12
12
|
export declare const page: <P>(props: P) => P;
|
|
13
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* `redirect`: returns its arguments as saved. Still a built-in, so a v7 rule
|
|
15
|
+
* block resolves, but no longer routed: `client.redirects()` reads only the
|
|
16
|
+
* redirects block (`deco check` warns on every `redirect` block).
|
|
17
|
+
*/
|
|
14
18
|
export declare const redirect: (props: Redirect) => Redirect;
|
|
19
|
+
/** The type of the site's one redirects block (canonically saved as `Redirects`). */
|
|
20
|
+
export declare const REDIRECTS_TYPE = "redirects";
|
|
21
|
+
/**
|
|
22
|
+
* `redirects`: the site's whole list of rules, one block (routing needs every
|
|
23
|
+
* rule, so it is one cached fetch). Each rule has either shape `matchRoute`
|
|
24
|
+
* reads: the flat `{ from, to, permanent?, status?, discardQueryParameters? }`
|
|
25
|
+
* or v7's nested `{ redirect: { from, to, type? } }`; anything that isn't an
|
|
26
|
+
* object is left out.
|
|
27
|
+
*/
|
|
28
|
+
export declare const redirects: (props: {
|
|
29
|
+
redirects?: Array<Redirect | LegacyRedirect>;
|
|
30
|
+
}) => Array<Redirect | LegacyRedirect>;
|
|
15
31
|
/** The `telemetry` section's defaults (sample rates before code's caps). */
|
|
16
32
|
export declare const TELEMETRY_DEFAULTS: Readonly<Required<Telemetry>>;
|
|
17
33
|
/** The well-known saved block that holds the CMS settings, and its built-in type. */
|