@decocms/blocks 8.9.1 → 8.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (409) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +1 -1
  4. package/dist/index.js.map +1 -1
  5. package/dist/protocol/channel.d.ts +98 -0
  6. package/dist/protocol/channel.d.ts.map +1 -0
  7. package/dist/protocol/channel.js +58 -0
  8. package/dist/protocol/channel.js.map +1 -0
  9. package/dist/protocol/client.js +2 -2
  10. package/dist/protocol/client.js.map +1 -1
  11. package/dist/protocol/conformance/blockMetaVectors.json +214 -0
  12. package/dist/protocol/conformance/contentHashFixtures.d.ts +22 -0
  13. package/dist/protocol/conformance/contentHashFixtures.d.ts.map +1 -1
  14. package/dist/protocol/conformance/contentHashFixtures.js +55 -0
  15. package/dist/protocol/conformance/contentHashFixtures.js.map +1 -1
  16. package/dist/protocol/conformance/index.d.ts +2 -1
  17. package/dist/protocol/conformance/index.d.ts.map +1 -1
  18. package/dist/protocol/conformance/index.js +2 -1
  19. package/dist/protocol/conformance/index.js.map +1 -1
  20. package/dist/protocol/conformance/vectors.d.ts +33 -0
  21. package/dist/protocol/conformance/vectors.d.ts.map +1 -0
  22. package/dist/protocol/conformance/vectors.js +3 -0
  23. package/dist/protocol/conformance/vectors.js.map +1 -0
  24. package/dist/protocol/index.d.ts +11 -1
  25. package/dist/protocol/index.d.ts.map +1 -1
  26. package/dist/protocol/index.js +11 -1
  27. package/dist/protocol/index.js.map +1 -1
  28. package/dist/protocol/keys.d.ts +1 -1
  29. package/dist/protocol/keys.js +1 -1
  30. package/dist/v8/background.d.ts +13 -0
  31. package/dist/v8/background.d.ts.map +1 -1
  32. package/dist/v8/background.js +41 -0
  33. package/dist/v8/background.js.map +1 -1
  34. package/dist/v8/blockMeta.d.ts +27 -0
  35. package/dist/v8/blockMeta.d.ts.map +1 -0
  36. package/dist/v8/blockMeta.js +75 -0
  37. package/dist/v8/blockMeta.js.map +1 -0
  38. package/dist/v8/blockStore.d.ts +43 -0
  39. package/dist/v8/blockStore.d.ts.map +1 -0
  40. package/dist/v8/blockStore.js +95 -0
  41. package/dist/v8/blockStore.js.map +1 -0
  42. package/dist/v8/boundedJson.d.ts +5 -0
  43. package/dist/v8/boundedJson.d.ts.map +1 -1
  44. package/dist/v8/boundedJson.js +10 -2
  45. package/dist/v8/boundedJson.js.map +1 -1
  46. package/dist/v8/boundedMap.d.ts +19 -0
  47. package/dist/v8/boundedMap.d.ts.map +1 -0
  48. package/dist/v8/boundedMap.js +52 -0
  49. package/dist/v8/boundedMap.js.map +1 -0
  50. package/dist/v8/builtins/data.d.ts +18 -2
  51. package/dist/v8/builtins/data.d.ts.map +1 -1
  52. package/dist/v8/builtins/data.js +17 -1
  53. package/dist/v8/builtins/data.js.map +1 -1
  54. package/dist/v8/builtins/index.d.ts.map +1 -1
  55. package/dist/v8/builtins/index.js +2 -1
  56. package/dist/v8/builtins/index.js.map +1 -1
  57. package/dist/v8/builtins/legacy.d.ts +6 -3
  58. package/dist/v8/builtins/legacy.d.ts.map +1 -1
  59. package/dist/v8/builtins/legacy.js +6 -3
  60. package/dist/v8/builtins/legacy.js.map +1 -1
  61. package/dist/v8/canonical.d.ts +8 -0
  62. package/dist/v8/canonical.d.ts.map +1 -1
  63. package/dist/v8/canonical.js +15 -0
  64. package/dist/v8/canonical.js.map +1 -1
  65. package/dist/v8/cli/builtins.d.ts.map +1 -1
  66. package/dist/v8/cli/builtins.js +1 -0
  67. package/dist/v8/cli/builtins.js.map +1 -1
  68. package/dist/v8/cli/check/index.d.ts +10 -0
  69. package/dist/v8/cli/check/index.d.ts.map +1 -1
  70. package/dist/v8/cli/check/index.js +91 -7
  71. package/dist/v8/cli/check/index.js.map +1 -1
  72. package/dist/v8/cli/content.d.ts +12 -25
  73. package/dist/v8/cli/content.d.ts.map +1 -1
  74. package/dist/v8/cli/content.js +46 -75
  75. package/dist/v8/cli/content.js.map +1 -1
  76. package/dist/v8/cli/index.d.ts +2 -2
  77. package/dist/v8/cli/index.d.ts.map +1 -1
  78. package/dist/v8/cli/index.js +2 -2
  79. package/dist/v8/cli/index.js.map +1 -1
  80. package/dist/v8/cli/remote/commands.d.ts +71 -0
  81. package/dist/v8/cli/remote/commands.d.ts.map +1 -0
  82. package/dist/v8/cli/remote/commands.js +644 -0
  83. package/dist/v8/cli/remote/commands.js.map +1 -0
  84. package/dist/v8/cli/remote/diff.d.ts +15 -0
  85. package/dist/v8/cli/remote/diff.d.ts.map +1 -0
  86. package/dist/v8/cli/remote/diff.js +102 -0
  87. package/dist/v8/cli/remote/diff.js.map +1 -0
  88. package/dist/v8/cli/remote/env.d.ts +35 -0
  89. package/dist/v8/cli/remote/env.d.ts.map +1 -0
  90. package/dist/v8/cli/remote/env.js +84 -0
  91. package/dist/v8/cli/remote/env.js.map +1 -0
  92. package/dist/v8/cli/remote/http.d.ts +149 -0
  93. package/dist/v8/cli/remote/http.d.ts.map +1 -0
  94. package/dist/v8/cli/remote/http.js +381 -0
  95. package/dist/v8/cli/remote/http.js.map +1 -0
  96. package/dist/v8/cli/remote/local.d.ts +90 -0
  97. package/dist/v8/cli/remote/local.d.ts.map +1 -0
  98. package/dist/v8/cli/remote/local.js +309 -0
  99. package/dist/v8/cli/remote/local.js.map +1 -0
  100. package/dist/v8/cli/root.d.ts +29 -0
  101. package/dist/v8/cli/root.d.ts.map +1 -1
  102. package/dist/v8/cli/root.js +28 -0
  103. package/dist/v8/cli/root.js.map +1 -1
  104. package/dist/v8/cli/run.d.ts +13 -1
  105. package/dist/v8/cli/run.d.ts.map +1 -1
  106. package/dist/v8/cli/run.js +310 -124
  107. package/dist/v8/cli/run.js.map +1 -1
  108. package/dist/v8/cli/schema/builtinSchemas.d.ts.map +1 -1
  109. package/dist/v8/cli/schema/builtinSchemas.js +28 -10
  110. package/dist/v8/cli/schema/builtinSchemas.js.map +1 -1
  111. package/dist/v8/cli/schema/generate.js +1 -1
  112. package/dist/v8/cli/schema/generate.js.map +1 -1
  113. package/dist/v8/cli/skills.d.ts +25 -0
  114. package/dist/v8/cli/skills.d.ts.map +1 -0
  115. package/dist/v8/cli/skills.js +70 -0
  116. package/dist/v8/cli/skills.js.map +1 -0
  117. package/dist/v8/client.d.ts +9 -9
  118. package/dist/v8/client.d.ts.map +1 -1
  119. package/dist/v8/client.js +138 -50
  120. package/dist/v8/client.js.map +1 -1
  121. package/dist/v8/cms.d.ts +2 -1
  122. package/dist/v8/cms.d.ts.map +1 -1
  123. package/dist/v8/cms.js +55 -46
  124. package/dist/v8/cms.js.map +1 -1
  125. package/dist/v8/content.d.ts +39 -78
  126. package/dist/v8/content.d.ts.map +1 -1
  127. package/dist/v8/content.js +155 -195
  128. package/dist/v8/content.js.map +1 -1
  129. package/dist/v8/contentIndex.d.ts +71 -0
  130. package/dist/v8/contentIndex.d.ts.map +1 -0
  131. package/dist/v8/contentIndex.js +137 -0
  132. package/dist/v8/contentIndex.js.map +1 -0
  133. package/dist/v8/draft.d.ts +7 -7
  134. package/dist/v8/draft.d.ts.map +1 -1
  135. package/dist/v8/draft.js +10 -9
  136. package/dist/v8/draft.js.map +1 -1
  137. package/dist/v8/draftChanges.d.ts +59 -32
  138. package/dist/v8/draftChanges.d.ts.map +1 -1
  139. package/dist/v8/draftChanges.js +139 -75
  140. package/dist/v8/draftChanges.js.map +1 -1
  141. package/dist/v8/errors.d.ts +21 -0
  142. package/dist/v8/errors.d.ts.map +1 -1
  143. package/dist/v8/errors.js +22 -0
  144. package/dist/v8/errors.js.map +1 -1
  145. package/dist/v8/hostedSource.d.ts +57 -0
  146. package/dist/v8/hostedSource.d.ts.map +1 -0
  147. package/dist/v8/hostedSource.js +18 -0
  148. package/dist/v8/hostedSource.js.map +1 -0
  149. package/dist/v8/identity.d.ts +1 -1
  150. package/dist/v8/identity.js +1 -1
  151. package/dist/v8/index.d.ts +1 -0
  152. package/dist/v8/index.d.ts.map +1 -1
  153. package/dist/v8/index.js +1 -0
  154. package/dist/v8/index.js.map +1 -1
  155. package/dist/v8/matchRoute.js +7 -4
  156. package/dist/v8/matchRoute.js.map +1 -1
  157. package/dist/v8/pin.d.ts +34 -0
  158. package/dist/v8/pin.d.ts.map +1 -0
  159. package/dist/v8/pin.js +156 -0
  160. package/dist/v8/pin.js.map +1 -0
  161. package/dist/v8/preview/StudioBridge.d.ts +8 -8
  162. package/dist/v8/preview/StudioBridge.d.ts.map +1 -1
  163. package/dist/v8/preview/StudioBridge.js +8 -10
  164. package/dist/v8/preview/StudioBridge.js.map +1 -1
  165. package/dist/v8/preview/StudioChannel.d.ts +51 -0
  166. package/dist/v8/preview/StudioChannel.d.ts.map +1 -0
  167. package/dist/v8/preview/StudioChannel.js +104 -0
  168. package/dist/v8/preview/StudioChannel.js.map +1 -0
  169. package/dist/v8/preview/index.d.ts +3 -0
  170. package/dist/v8/preview/index.d.ts.map +1 -1
  171. package/dist/v8/preview/index.js +3 -0
  172. package/dist/v8/preview/index.js.map +1 -1
  173. package/dist/v8/remoteLoader.d.ts +42 -5
  174. package/dist/v8/remoteLoader.d.ts.map +1 -1
  175. package/dist/v8/remoteLoader.js +317 -259
  176. package/dist/v8/remoteLoader.js.map +1 -1
  177. package/dist/v8/resolver.d.ts +22 -8
  178. package/dist/v8/resolver.d.ts.map +1 -1
  179. package/dist/v8/resolver.js +37 -32
  180. package/dist/v8/resolver.js.map +1 -1
  181. package/dist/v8/revisionId.d.ts +11 -0
  182. package/dist/v8/revisionId.d.ts.map +1 -0
  183. package/dist/v8/revisionId.js +13 -0
  184. package/dist/v8/revisionId.js.map +1 -0
  185. package/dist/v8/settings.d.ts +6 -6
  186. package/dist/v8/settings.d.ts.map +1 -1
  187. package/dist/v8/settings.js +8 -7
  188. package/dist/v8/settings.js.map +1 -1
  189. package/dist/v8/telemetry.d.ts +4 -2
  190. package/dist/v8/telemetry.d.ts.map +1 -1
  191. package/dist/v8/telemetry.js +2 -2
  192. package/dist/v8/telemetry.js.map +1 -1
  193. package/dist/v8/types.d.ts +52 -40
  194. package/dist/v8/types.d.ts.map +1 -1
  195. package/dist/v8/variants.d.ts +7 -2
  196. package/dist/v8/variants.d.ts.map +1 -1
  197. package/dist/v8/variants.js +21 -24
  198. package/dist/v8/variants.js.map +1 -1
  199. package/dist/v8/vite/index.d.ts +2 -2
  200. package/dist/v8/vite/index.js +1 -1
  201. package/dist/v8/vite/index.js.map +1 -1
  202. package/package.json +3 -2
  203. package/skills/deco-apps/SKILL.md +82 -0
  204. package/skills/deco-apps/references/algolia.md +51 -0
  205. package/skills/deco-apps/references/commerce-types.md +132 -0
  206. package/skills/deco-apps/references/instrumented-fetch.md +144 -0
  207. package/skills/deco-apps/references/magento.md +55 -0
  208. package/skills/deco-apps/references/messaging.md +76 -0
  209. package/skills/deco-apps/references/shopify.md +69 -0
  210. package/skills/deco-apps/references/vendored-loaders.md +135 -0
  211. package/skills/deco-apps/references/vtex-cookies-auth.md +146 -0
  212. package/skills/deco-apps/references/vtex.md +150 -0
  213. package/skills/deco-apps/references/wake.md +75 -0
  214. package/skills/deco-cms-schema/SKILL.md +80 -0
  215. package/skills/deco-cms-schema/references/annotations.md +147 -0
  216. package/skills/deco-cms-schema/references/content-hygiene.md +91 -0
  217. package/skills/deco-cms-schema/references/formats-and-widgets.md +112 -0
  218. package/skills/deco-cms-schema/references/shapes-that-break-the-form.md +165 -0
  219. package/skills/deco-cms-schema/references/types-to-fields.md +112 -0
  220. package/skills/deco-go-live/SKILL.md +127 -0
  221. package/skills/deco-go-live/references/content-releases.md +90 -0
  222. package/skills/deco-go-live/references/process.md +106 -0
  223. package/skills/deco-go-live/references/proxy-headers-checkout.md +139 -0
  224. package/skills/deco-go-live/references/qa-checklist-template.md +150 -0
  225. package/skills/deco-go-live/references/qa-inventory.md +120 -0
  226. package/skills/deco-go-live/references/react-spa.md +183 -0
  227. package/skills/deco-go-live/references/seo-analytics.md +114 -0
  228. package/skills/deco-go-live/references/traffic-ramp.md +87 -0
  229. package/skills/deco-go-live/references/worker-runtime.md +93 -0
  230. package/skills/deco-go-live/scripts/preflight.sh +221 -0
  231. package/skills/deco-images-media/SKILL.md +64 -0
  232. package/skills/deco-images-media/references/asset-upload.md +191 -0
  233. package/skills/deco-images-media/references/components-per-binding.md +167 -0
  234. package/skills/deco-images-media/references/providers-and-cdn.md +145 -0
  235. package/skills/deco-images-media/references/quality-and-lcp.md +93 -0
  236. package/skills/deco-images-media/references/troubleshooting.md +147 -0
  237. package/skills/deco-images-media/references/video.md +122 -0
  238. package/skills/deco-make-editable/SKILL.md +94 -0
  239. package/skills/deco-make-editable/references/a11y-and-e2e.md +104 -0
  240. package/skills/deco-make-editable/references/content-shapes.md +198 -0
  241. package/skills/deco-make-editable/references/from-figma.md +110 -0
  242. package/skills/deco-make-editable/references/i18n-fields.md +112 -0
  243. package/skills/deco-make-editable/references/inventory.md +79 -0
  244. package/skills/deco-make-editable/references/pixel-parity.md +175 -0
  245. package/skills/deco-make-editable/references/seeding-content.md +119 -0
  246. package/skills/deco-nextjs-site/SKILL.md +74 -0
  247. package/skills/deco-nextjs-site/references/caching.md +116 -0
  248. package/skills/deco-nextjs-site/references/metadata-seo.md +100 -0
  249. package/skills/deco-nextjs-site/references/proxy-and-drafts.md +177 -0
  250. package/skills/deco-nextjs-site/references/rendering.md +171 -0
  251. package/skills/deco-nextjs-site/references/setup.md +190 -0
  252. package/skills/deco-nextjs-site/references/studio-bridge.md +130 -0
  253. package/skills/deco-site-authoring/SKILL.md +75 -0
  254. package/skills/deco-site-authoring/references/lazy-blocks.md +155 -0
  255. package/skills/deco-site-authoring/references/loaders.md +192 -0
  256. package/skills/deco-site-authoring/references/pages.md +156 -0
  257. package/skills/deco-site-authoring/references/review-before-publish.md +95 -0
  258. package/skills/deco-site-authoring/references/sections.md +158 -0
  259. package/skills/deco-site-authoring/references/seo.md +116 -0
  260. package/skills/deco-site-workflow/SKILL.md +92 -0
  261. package/skills/deco-site-workflow/references/check.md +116 -0
  262. package/skills/deco-site-workflow/references/cli-reference.md +104 -0
  263. package/skills/deco-site-workflow/references/content-layout.md +93 -0
  264. package/skills/deco-site-workflow/references/content-sync.md +146 -0
  265. package/skills/deco-site-workflow/references/delivery.md +51 -0
  266. package/skills/deco-site-workflow/references/deploy.md +87 -0
  267. package/skills/deco-site-workflow/references/schema.md +173 -0
  268. package/skills/deco-site-workflow/references/serve-and-studio.md +138 -0
  269. package/skills/deco-storefront-caching/SKILL.md +67 -0
  270. package/skills/deco-storefront-caching/references/cache-keys.md +129 -0
  271. package/skills/deco-storefront-caching/references/case-study.md +82 -0
  272. package/skills/deco-storefront-caching/references/egress-traps.md +153 -0
  273. package/skills/deco-storefront-caching/references/nextjs.md +60 -0
  274. package/skills/deco-storefront-caching/references/perf-guardrails-e2e.md +123 -0
  275. package/skills/deco-storefront-caching/references/verification.md +136 -0
  276. package/skills/deco-storefront-caching/references/worker-page-cache.md +160 -0
  277. package/skills/deco-storefront-caching/scripts/html-anatomy.mjs +97 -0
  278. package/skills/deco-storefront-performance/SKILL.md +81 -0
  279. package/skills/deco-storefront-performance/references/cls-third-party.md +90 -0
  280. package/skills/deco-storefront-performance/references/hydration.md +116 -0
  281. package/skills/deco-storefront-performance/references/loaders-n-plus-1.md +107 -0
  282. package/skills/deco-storefront-performance/references/navigation-ux.md +130 -0
  283. package/skills/deco-storefront-performance/references/payload-trim.md +163 -0
  284. package/skills/deco-storefront-performance/references/render-location.md +152 -0
  285. package/skills/deco-storefront-performance/references/request-dedupe.md +147 -0
  286. package/skills/deco-storefront-performance/references/trace-reading.md +79 -0
  287. package/skills/deco-storefront-performance/references/worker-memory.md +176 -0
  288. package/skills/deco-tanstack-site/SKILL.md +68 -0
  289. package/skills/deco-tanstack-site/references/document-and-security.md +155 -0
  290. package/skills/deco-tanstack-site/references/router-and-navigation.md +137 -0
  291. package/skills/deco-tanstack-site/references/routes-and-pages.md +183 -0
  292. package/skills/deco-tanstack-site/references/server-functions.md +123 -0
  293. package/skills/deco-tanstack-site/references/setup.md +153 -0
  294. package/skills/deco-tanstack-site/references/worker-entry.md +152 -0
  295. package/skills/deco-v7-to-v8-migration/SKILL.md +122 -0
  296. package/skills/deco-v7-to-v8-migration/references/caching-and-privacy.md +10 -0
  297. package/skills/deco-v7-to-v8-migration/references/content.md +25 -0
  298. package/skills/deco-v7-to-v8-migration/references/editor-forms.md +27 -0
  299. package/skills/deco-v7-to-v8-migration/references/faststore.md +40 -0
  300. package/skills/deco-v7-to-v8-migration/references/framework-code.md +53 -0
  301. package/skills/deco-v7-to-v8-migration/references/hosted-releases.md +16 -0
  302. package/skills/deco-v7-to-v8-migration/references/import-map.md +81 -0
  303. package/skills/deco-v7-to-v8-migration/references/legacy-names.md +33 -0
  304. package/skills/deco-v7-to-v8-migration/references/manual-steps.md +10 -0
  305. package/skills/deco-v7-to-v8-migration/references/native-apps.md +43 -0
  306. package/skills/deco-v7-to-v8-migration/references/nextjs.md +19 -0
  307. package/skills/deco-v7-to-v8-migration/references/parity.md +66 -0
  308. package/skills/deco-v7-to-v8-migration/references/rendering.md +13 -0
  309. package/skills/deco-v7-to-v8-migration/references/running-the-script.md +29 -0
  310. package/skills/deco-v7-to-v8-migration/references/script-steps.md +13 -0
  311. package/skills/deco-v7-to-v8-migration/references/server-functions.md +15 -0
  312. package/skills/deco-v7-to-v8-migration/references/sibling-port.md +11 -0
  313. package/skills/deco-v7-to-v8-migration/references/site-code.md +15 -0
  314. package/skills/deco-v7-to-v8-migration/references/telemetry.md +10 -0
  315. package/skills/deco-v7-to-v8-migration/references/verify.md +20 -0
  316. package/skills/deco-v7-to-v8-migration/scripts/apps.ts +297 -0
  317. package/skills/deco-v7-to-v8-migration/scripts/asyncRendering.ts +73 -0
  318. package/skills/deco-v7-to-v8-migration/scripts/blockMap.ts +584 -0
  319. package/skills/deco-v7-to-v8-migration/scripts/ciSchemaCheck.ts +145 -0
  320. package/skills/deco-v7-to-v8-migration/scripts/compat.ts +357 -0
  321. package/skills/deco-v7-to-v8-migration/scripts/content.ts +121 -0
  322. package/skills/deco-v7-to-v8-migration/scripts/experiments.ts +81 -0
  323. package/skills/deco-v7-to-v8-migration/scripts/framework.ts +61 -0
  324. package/skills/deco-v7-to-v8-migration/scripts/imageCopy.ts +276 -0
  325. package/skills/deco-v7-to-v8-migration/scripts/imageModule.ts +285 -0
  326. package/skills/deco-v7-to-v8-migration/scripts/imports.ts +942 -0
  327. package/skills/deco-v7-to-v8-migration/scripts/invoke.ts +624 -0
  328. package/skills/deco-v7-to-v8-migration/scripts/legacyNames.ts +45 -0
  329. package/skills/deco-v7-to-v8-migration/scripts/main.ts +59 -0
  330. package/skills/deco-v7-to-v8-migration/scripts/matchers.ts +41 -0
  331. package/skills/deco-v7-to-v8-migration/scripts/migrate.ts +176 -0
  332. package/skills/deco-v7-to-v8-migration/scripts/redirects.ts +455 -0
  333. package/skills/deco-v7-to-v8-migration/scripts/report.ts +50 -0
  334. package/skills/deco-v7-to-v8-migration/scripts/scaffold.ts +1119 -0
  335. package/skills/deco-v7-to-v8-migration/scripts/secrets.ts +35 -0
  336. package/skills/deco-v7-to-v8-migration/scripts/sectionLoaders.ts +216 -0
  337. package/skills/deco-v7-to-v8-migration/scripts/siteSettings.ts +261 -0
  338. package/skills/deco-v7-to-v8-migration/scripts/stubs.ts +388 -0
  339. package/skills/deco-v7-to-v8-migration/scripts/tsconfig.json +7 -0
  340. package/skills/deco-v7-to-v8-migration/scripts/vendor.ts +249 -0
  341. package/skills/deco-v7-to-v8-migration/scripts/vtexInvoke.ts +240 -0
  342. package/skills/deco-v7-to-v8-migration/scripts/walk.ts +30 -0
  343. package/skills/deco-variants/SKILL.md +57 -0
  344. package/skills/deco-variants/references/caching-variants.md +63 -0
  345. package/skills/deco-variants/references/custom-matchers.md +83 -0
  346. package/skills/deco-variants/references/draft-preview.md +59 -0
  347. package/skills/deco-variants/references/experiments-and-campaigns.md +104 -0
  348. package/skills/deco-variants/references/multivariate.md +85 -0
  349. package/skills/deco-variants/references/v7-matchers.md +71 -0
  350. package/src/index.ts +2 -0
  351. package/src/protocol/channel.ts +127 -0
  352. package/src/protocol/client.ts +2 -2
  353. package/src/protocol/conformance/blockMetaVectors.json +214 -0
  354. package/src/protocol/conformance/contentHashFixtures.ts +74 -0
  355. package/src/protocol/conformance/index.ts +9 -1
  356. package/src/protocol/conformance/vectors.ts +36 -0
  357. package/src/protocol/index.ts +32 -0
  358. package/src/protocol/keys.ts +1 -1
  359. package/src/v8/background.ts +42 -0
  360. package/src/v8/blockMeta.ts +100 -0
  361. package/src/v8/blockStore.ts +124 -0
  362. package/src/v8/boundedJson.ts +20 -2
  363. package/src/v8/boundedMap.ts +53 -0
  364. package/src/v8/builtins/data.ts +26 -2
  365. package/src/v8/builtins/index.ts +2 -1
  366. package/src/v8/builtins/legacy.ts +6 -3
  367. package/src/v8/canonical.ts +15 -0
  368. package/src/v8/cli/builtins.ts +1 -0
  369. package/src/v8/cli/check/index.ts +97 -7
  370. package/src/v8/cli/content.ts +49 -91
  371. package/src/v8/cli/index.ts +2 -2
  372. package/src/v8/cli/remote/commands.ts +834 -0
  373. package/src/v8/cli/remote/diff.ts +100 -0
  374. package/src/v8/cli/remote/env.ts +107 -0
  375. package/src/v8/cli/remote/http.ts +484 -0
  376. package/src/v8/cli/remote/local.ts +343 -0
  377. package/src/v8/cli/root.ts +40 -0
  378. package/src/v8/cli/run.ts +366 -135
  379. package/src/v8/cli/schema/builtinSchemas.ts +29 -10
  380. package/src/v8/cli/schema/generate.ts +1 -1
  381. package/src/v8/cli/skills.ts +91 -0
  382. package/src/v8/client.ts +162 -60
  383. package/src/v8/cms.ts +62 -53
  384. package/src/v8/content.ts +179 -229
  385. package/src/v8/contentIndex.ts +183 -0
  386. package/src/v8/draft.ts +15 -14
  387. package/src/v8/draftChanges.ts +151 -85
  388. package/src/v8/errors.ts +37 -0
  389. package/src/v8/hostedSource.ts +67 -0
  390. package/src/v8/identity.ts +1 -1
  391. package/src/v8/index.ts +1 -0
  392. package/src/v8/matchRoute.ts +7 -4
  393. package/src/v8/pin.ts +176 -0
  394. package/src/v8/preview/StudioBridge.ts +8 -10
  395. package/src/v8/preview/StudioChannel.ts +116 -0
  396. package/src/v8/preview/index.ts +3 -0
  397. package/src/v8/remoteLoader.ts +350 -286
  398. package/src/v8/resolver.ts +56 -33
  399. package/src/v8/revisionId.ts +14 -0
  400. package/src/v8/settings.ts +10 -9
  401. package/src/v8/telemetry.ts +3 -3
  402. package/src/v8/types.ts +52 -40
  403. package/src/v8/variants.ts +30 -26
  404. package/src/v8/vite/index.ts +3 -3
  405. package/dist/v8/cli/serve/server.d.ts +0 -29
  406. package/dist/v8/cli/serve/server.d.ts.map +0 -1
  407. package/dist/v8/cli/serve/server.js +0 -296
  408. package/dist/v8/cli/serve/server.js.map +0 -1
  409. package/src/v8/cli/serve/server.ts +0 -348
@@ -14,18 +14,50 @@
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
  */
29
+
22
30
  export {
31
+ type BlockIndex,
32
+ type BlockMeta,
33
+ blockMeta,
34
+ type IndexEntry,
35
+ indexEntry,
36
+ } from "../v8/blockMeta.ts";
37
+ export { isRevisionId, REVISION_ID_RE } from "../v8/revisionId.ts";
38
+ export {
39
+ blockVersion,
23
40
  CanonicalJsonError,
24
41
  CONTENT_HASH_FORMAT,
25
42
  canonicalJson,
26
43
  computeContentRevision,
27
44
  sha256Hex,
28
45
  } from "./canonical.ts";
46
+ export {
47
+ CHANNEL_MESSAGE,
48
+ type ChannelLoadErrorMessage,
49
+ type ChannelLoadedMessage,
50
+ type ChannelLoadMessage,
51
+ type ChannelReadyMessage,
52
+ DEFAULT_STUDIO_ORIGIN,
53
+ DEFAULT_STUDIO_ORIGINS,
54
+ defineStudioModule,
55
+ type ModuleMessage,
56
+ type PageChannelMessage,
57
+ type StudioChannelContext,
58
+ type StudioChannelMessage,
59
+ type StudioChannelModule,
60
+ } from "./channel.ts";
29
61
  export {
30
62
  assertSupportedEndpoint,
31
63
  type BatchCall,
@@ -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, `deco serve` and `deco content` all import this module, so
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
@@ -95,6 +95,48 @@ export function runInBackground(task: Task): void {
95
95
  });
96
96
  }
97
97
 
98
+ /**
99
+ * Keeps the request that started `promise` alive until it settles, where the
100
+ * runtime ends a request's work with its response: a host's hook, or on
101
+ * Cloudflare Workers the platform's `waitUntil`. Unlike
102
+ * {@link runInBackground}, the work has already started: nothing is
103
+ * deferred. Elsewhere a pending promise needs nothing to settle, so this does
104
+ * nothing. Never throws.
105
+ *
106
+ * Shared work goes through here: a fetch a later request may await (a block
107
+ * body by hash, `latest.json`, a revision's index) must not die with the
108
+ * request that happened to start it.
109
+ */
110
+ export function keepAlive(promise: Promise<unknown>): void {
111
+ const settled = promise.then(
112
+ () => {},
113
+ () => {},
114
+ );
115
+ const g = globalThis as BackgroundGlobals;
116
+ const hook = g[BACKGROUND_HOOK];
117
+ try {
118
+ if (typeof hook === "function") {
119
+ hook(() => settled);
120
+ return;
121
+ }
122
+ if (onWorkers()) {
123
+ void workersWaitUntil().then((waitUntil) => {
124
+ if (waitUntil === undefined) return;
125
+ if (typeof g[BACKGROUND_HOOK] !== "function") {
126
+ g[BACKGROUND_HOOK] = (next) => waitUntil(next());
127
+ }
128
+ try {
129
+ g[BACKGROUND_HOOK]?.(() => settled);
130
+ } catch {
131
+ // As below.
132
+ }
133
+ });
134
+ }
135
+ } catch {
136
+ // Outside a request there is no request to keep: the work just runs.
137
+ }
138
+ }
139
+
98
140
  /** `setTimeout` that never keeps a Node process alive. */
99
141
  export function later(ms: number, callback: () => void): void {
100
142
  const timer = setTimeout(callback, ms) as unknown as { unref?: () => void };
@@ -0,0 +1,100 @@
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.ts";
23
+
24
+ /** What an index says about a block, besides its hash. */
25
+ export interface BlockMeta {
26
+ /** The body's raw `__resolveType`. */
27
+ type?: string;
28
+ /** The body's top-level `path`. */
29
+ path?: string;
30
+ /** The block names the body references, deduped, in code-unit order. */
31
+ refs?: string[];
32
+ }
33
+
34
+ /** One entry of a revision index. */
35
+ export interface IndexEntry {
36
+ /** `blockVersion(body)`: the hash the body is stored under (`blocks/<version>.json`). */
37
+ version: string;
38
+ /** Omitted when empty. */
39
+ meta?: BlockMeta;
40
+ /** The body itself, only on the CMS settings entry (`CMS`). */
41
+ data?: unknown;
42
+ }
43
+
44
+ /** A revision index's blocks: block name → entry. */
45
+ export type BlockIndex = Record<string, IndexEntry>;
46
+
47
+ /** The well-known name whose body every index inlines as `data`. */
48
+ export const INLINE_BLOCK = "CMS";
49
+
50
+ /** The metadata of one block body; `names` are the block names of the index being built. */
51
+ export function blockMeta(
52
+ body: unknown,
53
+ names: ReadonlySet<string> | readonly string[],
54
+ ): BlockMeta {
55
+ const meta: BlockMeta = {};
56
+ if (!isRecord(body)) return meta;
57
+ if (typeof body.__resolveType === "string") meta.type = body.__resolveType;
58
+ if (typeof body.path === "string") meta.path = body.path;
59
+ const known: ReadonlySet<string> = isSet(names) ? names : new Set(names);
60
+ const found = new Set<string>();
61
+ collectRefs(body, known, found);
62
+ if (found.size > 0) meta.refs = [...found].sort();
63
+ return meta;
64
+ }
65
+
66
+ /** The index entry for a block: its hash, its metadata when any, and its body when it is `CMS`. */
67
+ export async function indexEntry(
68
+ name: string,
69
+ body: unknown,
70
+ names: ReadonlySet<string> | readonly string[],
71
+ ): Promise<IndexEntry> {
72
+ const entry: IndexEntry = { version: await blockVersion(body) };
73
+ const meta = blockMeta(body, names);
74
+ if (Object.keys(meta).length > 0) entry.meta = meta;
75
+ if (name === INLINE_BLOCK) entry.data = body;
76
+ return entry;
77
+ }
78
+
79
+ function collectRefs(node: unknown, names: ReadonlySet<string>, found: Set<string>): void {
80
+ if (Array.isArray(node)) {
81
+ for (const item of node) collectRefs(item, names, found);
82
+ return;
83
+ }
84
+ if (!isRecord(node)) return;
85
+ for (const [key, value] of Object.entries(node)) {
86
+ if (key === "__resolveType") {
87
+ if (typeof value === "string" && names.has(value)) found.add(value);
88
+ } else {
89
+ collectRefs(value, names, found);
90
+ }
91
+ }
92
+ }
93
+
94
+ function isRecord(value: unknown): value is Record<string, unknown> {
95
+ return typeof value === "object" && value !== null && !Array.isArray(value);
96
+ }
97
+
98
+ function isSet(value: ReadonlySet<string> | readonly string[]): value is ReadonlySet<string> {
99
+ return !Array.isArray(value);
100
+ }
@@ -0,0 +1,124 @@
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
+
24
+ import { keepAlive } from "./background.ts";
25
+ import { BoundedMap } from "./boundedMap.ts";
26
+ import type { BodySource } from "./contentIndex.ts";
27
+ import { ContentUnavailableError } from "./errors.ts";
28
+
29
+ /** The default byte bound of the LRU: the sum of the bodies' JSON text lengths. */
30
+ export const DEFAULT_BLOCK_CACHE_BYTES = 32 * 1024 * 1024;
31
+
32
+ /**
33
+ * How long a shared fetch may stay in flight: the 10 s each fetch has
34
+ * (headers and body), plus a second's margin. A fetch still in flight past
35
+ * it is one whose request went away.
36
+ */
37
+ export const IN_FLIGHT_DEADLINE_MS = 11_000;
38
+
39
+ /** A fetched body and the length of its JSON text. */
40
+ export interface FetchedBody {
41
+ body: unknown;
42
+ bytes: number;
43
+ }
44
+
45
+ interface InFlight {
46
+ body: Promise<unknown>;
47
+ /** When it started, in ms since the epoch. */
48
+ at: number;
49
+ }
50
+
51
+ export class BlockStore implements BodySource {
52
+ readonly #fetch: (hash: string, name: string) => Promise<FetchedBody>;
53
+ readonly #lru: BoundedMap<string, FetchedBody>;
54
+ readonly #deadlineMs: number;
55
+ readonly #inFlight = new Map<string, InFlight>();
56
+
57
+ constructor(
58
+ fetchBody: (hash: string, name: string) => Promise<FetchedBody>,
59
+ limitBytes = DEFAULT_BLOCK_CACHE_BYTES,
60
+ deadlineMs = IN_FLIGHT_DEADLINE_MS,
61
+ ) {
62
+ this.#fetch = fetchBody;
63
+ this.#lru = new BoundedMap(limitBytes, (entry) => entry.bytes);
64
+ this.#deadlineMs = deadlineMs;
65
+ }
66
+
67
+ peek(hash: string): unknown | undefined {
68
+ return this.#lru.get(hash)?.body;
69
+ }
70
+
71
+ get(hash: string, name: string): Promise<unknown> {
72
+ const held = this.#lru.get(hash);
73
+ if (held !== undefined) return Promise.resolve(held.body);
74
+ const shared = this.#inFlight.get(hash);
75
+ if (shared !== undefined) {
76
+ const left = shared.at + this.#deadlineMs - Date.now();
77
+ if (left > 0) return this.#join(hash, name, shared, left);
78
+ // Past its deadline: its request went away without settling it.
79
+ this.#inFlight.delete(hash);
80
+ }
81
+ return this.#start(hash, name);
82
+ }
83
+
84
+ #start(hash: string, name: string): Promise<unknown> {
85
+ const body = this.#fetch(hash, name).then((fetched) => {
86
+ this.#lru.set(hash, fetched);
87
+ return fetched.body;
88
+ });
89
+ const entry: InFlight = { body, at: Date.now() };
90
+ this.#inFlight.set(hash, entry);
91
+ const settle = () => {
92
+ if (this.#inFlight.get(hash) === entry) this.#inFlight.delete(hash);
93
+ };
94
+ body.then(settle, settle);
95
+ keepAlive(body);
96
+ return body;
97
+ }
98
+
99
+ /** Another request's fetch, awaited for at most `ms`. */
100
+ #join(hash: string, name: string, entry: InFlight, ms: number): Promise<unknown> {
101
+ return new Promise((resolve, reject) => {
102
+ const timer = setTimeout(() => {
103
+ if (this.#inFlight.get(hash) === entry) this.#inFlight.delete(hash);
104
+ reject(
105
+ new ContentUnavailableError(
106
+ "timeout",
107
+ `block "${name}" (${hash}): no answer within ${this.#deadlineMs} ms`,
108
+ ),
109
+ );
110
+ }, ms) as unknown as { unref?: () => void };
111
+ timer?.unref?.();
112
+ entry.body.then(
113
+ (body) => {
114
+ clearTimeout(timer as unknown as number);
115
+ resolve(body);
116
+ },
117
+ (error: unknown) => {
118
+ clearTimeout(timer as unknown as number);
119
+ reject(error);
120
+ },
121
+ );
122
+ });
123
+ }
124
+ }
@@ -18,6 +18,24 @@ export async function readBoundedJson(
18
18
  label: string,
19
19
  maxBytes: number,
20
20
  ): Promise<unknown> {
21
+ return (await readBoundedJsonSized(response, label, maxBytes)).value;
22
+ }
23
+
24
+ /** `readBoundedJson`, plus the length of the JSON text (what a byte-bounded cache counts). */
25
+ export async function readBoundedJsonSized(
26
+ response: Response,
27
+ label: string,
28
+ maxBytes: number,
29
+ ): Promise<{ value: unknown; bytes: number }> {
30
+ const text = await readBoundedText(response, label, maxBytes);
31
+ return { value: JSON.parse(text), bytes: text.length };
32
+ }
33
+
34
+ async function readBoundedText(
35
+ response: Response,
36
+ label: string,
37
+ maxBytes: number,
38
+ ): Promise<string> {
21
39
  const tooLarge = () => new Error(`${label}: larger than ${maxBytes} bytes`);
22
40
  if (Number(response.headers.get("content-length")) > maxBytes) {
23
41
  await response.body?.cancel();
@@ -26,7 +44,7 @@ export async function readBoundedJson(
26
44
  if (response.body === null) {
27
45
  const text = await response.text();
28
46
  if (text.length > maxBytes) throw tooLarge();
29
- return JSON.parse(text);
47
+ return text;
30
48
  }
31
49
  const reader = response.body.getReader();
32
50
  const decoder = new TextDecoder();
@@ -43,5 +61,5 @@ export async function readBoundedJson(
43
61
  parts.push(decoder.decode(value, { stream: true }));
44
62
  }
45
63
  parts.push(decoder.decode());
46
- return JSON.parse(parts.join(""));
64
+ return parts.join("");
47
65
  }
@@ -0,0 +1,53 @@
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<K, V> {
7
+ readonly #map = new Map<K, V>();
8
+ #total = 0;
9
+ constructor(
10
+ readonly limit: number,
11
+ readonly size: (value: V) => number = () => 1,
12
+ ) {}
13
+
14
+ get(key: K): V | undefined {
15
+ const value = this.#map.get(key);
16
+ if (value !== undefined) {
17
+ this.#map.delete(key);
18
+ this.#map.set(key, value);
19
+ }
20
+ return value;
21
+ }
22
+
23
+ has(key: K): boolean {
24
+ return this.#map.has(key);
25
+ }
26
+
27
+ set(key: K, value: V): void {
28
+ this.delete(key);
29
+ this.#map.set(key, value);
30
+ this.#total += this.size(value);
31
+ for (const [oldest, old] of this.#map) {
32
+ if (this.#total <= this.limit || oldest === key) break;
33
+ this.#map.delete(oldest);
34
+ this.#total -= this.size(old);
35
+ }
36
+ }
37
+
38
+ delete(key: K): void {
39
+ if (!this.#map.has(key)) return;
40
+ this.#total -= this.size(this.#map.get(key) as V);
41
+ this.#map.delete(key);
42
+ }
43
+
44
+ clear(): void {
45
+ this.#map.clear();
46
+ this.#total = 0;
47
+ }
48
+
49
+ /** The total size held. */
50
+ get total(): number {
51
+ return this.#total;
52
+ }
53
+ }
@@ -1,4 +1,4 @@
1
- import type { Analytics, CMSSettings, Redirect, Telemetry } from "../types.ts";
1
+ import type { Analytics, CMSSettings, LegacyRedirect, Redirect, Telemetry } from "../types.ts";
2
2
 
3
3
  /** The hosted Deco CMS collector: where page views go when `collector` is left out. */
4
4
  export const HOSTED_ANALYTICS_COLLECTOR = "https://d.lilstts.com/events";
@@ -15,9 +15,33 @@ export const DECO_ANALYTICS_SCRIPT = "/_dq/a.js";
15
15
  */
16
16
  export const page = <P>(props: P): P => props;
17
17
 
18
- /** `redirect`: returns its arguments as saved. */
18
+ /**
19
+ * `redirect`: returns its arguments as saved. Still a built-in, so a v7 rule
20
+ * block resolves, but no longer routed: `client.redirects()` reads only the
21
+ * redirects block (`deco check` warns on every `redirect` block).
22
+ */
19
23
  export const redirect = (props: Redirect): Redirect => props;
20
24
 
25
+ /** The type of the site's one redirects block (canonically saved as `Redirects`). */
26
+ export const REDIRECTS_TYPE = "redirects";
27
+
28
+ /**
29
+ * `redirects`: the site's whole list of rules, one block (routing needs every
30
+ * rule, so it is one cached fetch). Each rule has either shape `matchRoute`
31
+ * reads: the flat `{ from, to, permanent?, status?, discardQueryParameters? }`
32
+ * or v7's nested `{ redirect: { from, to, type? } }`; anything that isn't an
33
+ * object is left out.
34
+ */
35
+ export const redirects = (props: {
36
+ redirects?: Array<Redirect | LegacyRedirect>;
37
+ }): Array<Redirect | LegacyRedirect> =>
38
+ Array.isArray(props?.redirects)
39
+ ? props.redirects.filter(
40
+ (rule): rule is Redirect | LegacyRedirect =>
41
+ typeof rule === "object" && rule !== null && !Array.isArray(rule),
42
+ )
43
+ : [];
44
+
21
45
  /** The `telemetry` section's defaults (sample rates before code's caps). */
22
46
  export const TELEMETRY_DEFAULTS: Readonly<Required<Telemetry>> = Object.freeze({
23
47
  enabled: true,
@@ -1,6 +1,6 @@
1
1
  import type { BlockFunction } from "../types.ts";
2
2
  import { CALENDAR_TYPE, calendar, campaign } from "./campaigns.ts";
3
- import { cmsSettings, page, redirect, SETTINGS_TYPE } from "./data.ts";
3
+ import { cmsSettings, page, REDIRECTS_TYPE, redirect, redirects, SETTINGS_TYPE } from "./data.ts";
4
4
  import { experiment, SPLIT_TRAFFIC_TYPE, splitTraffic } from "./experiments.ts";
5
5
  import { lazy } from "./lazy.ts";
6
6
  import { always, never } from "./matchers.ts";
@@ -16,6 +16,7 @@ export const builtIns: Readonly<Record<string, BlockFunction>> = Object.freeze({
16
16
  campaign,
17
17
  page,
18
18
  redirect,
19
+ [REDIRECTS_TYPE]: redirects,
19
20
  [SETTINGS_TYPE]: cmsSettings,
20
21
  [SPLIT_TRAFFIC_TYPE]: splitTraffic,
21
22
  [CALENDAR_TYPE]: calendar,
@@ -4,11 +4,14 @@
4
4
  * without a block-map entry (see /next/studio-compatibility#well-known-types-and-the-alias-table
5
5
  * and /next/renames-and-migrations#rename-a-type-with-an-alias).
6
6
  *
7
- * A snapshot's own `aliases` (the table `deco content` writes) win over these, and a key in the block map wins over
7
+ * A snapshot's own `aliases` (the table the content module carries) win over these, and a key in the block map wins over
8
8
  * both, so a site can still register a legacy name itself.
9
9
  *
10
10
  * - Redirects keep v7's nested shape: `redirect` returns its arguments as
11
- * saved, and `matchRoute` accepts both shapes.
11
+ * saved, and `matchRoute` accepts both shapes. v7's `website/loaders/redirects.ts`
12
+ * has no alias: v8 routes only a block typed `redirects`, so the v7-to-v8
13
+ * migration folds every v7 redirect block into `Redirects` and `deco check`
14
+ * warns about one left over.
12
15
  * - `website/loaders/secret.ts` has no alias: secrets live in the deploy
13
16
  * platform, read by the site's code and passed as params (see
14
17
  * /next/renames-and-migrations#secrets), so a leftover v7 secret block
@@ -20,7 +23,7 @@ import { isPlainObject, type JsonObject } from "../json.ts";
20
23
 
21
24
  /**
22
25
  * Legacy type name → built-in. The one table: the runtime falls back to it,
23
- * and `deco schema` / `deco content` write it into the schema and the content
26
+ * and `deco schema` and the content module write it into the schema and the content
24
27
  * module. Exactly the names the site editor's special screens look for
25
28
  * (/next/studio-compatibility#well-known-types-and-the-alias-table); other
26
29
  * legacy names (`$live/…`, the per-kind multivariate files, the date
@@ -104,3 +104,18 @@ export const CONTENT_HASH_FORMAT = 1;
104
104
  export async function computeContentRevision(blocks: Record<string, unknown>): Promise<string> {
105
105
  return sha256Hex(canonicalJson(blocks));
106
106
  }
107
+
108
+ /**
109
+ * A saved block's version: the first 16 bytes of SHA-256 over its canonical
110
+ * JSON, written as 22 characters of base64url without padding. The one
111
+ * definition `ifMatch`, conflicts, `blocks.list` versions and the CLI's
112
+ * `.deco/pull.json` share; `blockVersionFixtures` (in
113
+ * `@decocms/blocks/protocol/conformance`) pins its output.
114
+ */
115
+ export async function blockVersion(block: unknown): Promise<string> {
116
+ const bytes = new TextEncoder().encode(canonicalJson(block));
117
+ const digest = new Uint8Array(await crypto.subtle.digest("SHA-256", bytes as BufferSource));
118
+ let binary = "";
119
+ for (const byte of digest.subarray(0, 16)) binary += String.fromCharCode(byte);
120
+ return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
121
+ }
@@ -27,6 +27,7 @@ export const BUILT_IN_USES: Readonly<Record<string, string>> = Object.freeze({
27
27
  "Studio's campaign rules rely on it, each naming a campaign of the saved block campaigns",
28
28
  page: "Studio's page list and page editor rely on it",
29
29
  redirect: "Studio's redirect list relies on it",
30
+ redirects: "the site's routing reads its rules from the saved block Redirects, through it",
30
31
  "cms-settings": "the saved block CMS relies on it, and Studio's settings edit that block",
31
32
  "split-traffic":
32
33
  "the saved block experiments relies on it, and Studio's Experiments view edits its percentages",