@decocms/blocks 8.1.0-next.0 → 8.1.0-next.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (490) hide show
  1. package/bin/deco.js +5 -12
  2. package/dist/index.d.ts +2 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +4 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/protocol/assets.d.ts +46 -0
  7. package/dist/protocol/assets.d.ts.map +1 -0
  8. package/dist/protocol/assets.js +105 -0
  9. package/dist/protocol/assets.js.map +1 -0
  10. package/dist/protocol/canonical.d.ts +8 -0
  11. package/dist/protocol/canonical.d.ts.map +1 -0
  12. package/dist/protocol/canonical.js +8 -0
  13. package/dist/protocol/canonical.js.map +1 -0
  14. package/dist/protocol/ciphertext.d.ts +7 -0
  15. package/dist/protocol/ciphertext.d.ts.map +1 -0
  16. package/dist/protocol/ciphertext.js +7 -0
  17. package/dist/protocol/ciphertext.js.map +1 -0
  18. package/dist/protocol/client.d.ts +54 -0
  19. package/dist/protocol/client.d.ts.map +1 -0
  20. package/dist/protocol/client.js +104 -0
  21. package/dist/protocol/client.js.map +1 -0
  22. package/dist/protocol/conformance/cases/assets.d.ts +3 -0
  23. package/dist/protocol/conformance/cases/assets.d.ts.map +1 -0
  24. package/dist/protocol/conformance/cases/assets.js +71 -0
  25. package/dist/protocol/conformance/cases/assets.js.map +1 -0
  26. package/dist/protocol/conformance/cases/guards.d.ts +3 -0
  27. package/dist/protocol/conformance/cases/guards.d.ts.map +1 -0
  28. package/dist/protocol/conformance/cases/guards.js +265 -0
  29. package/dist/protocol/conformance/cases/guards.js.map +1 -0
  30. package/dist/protocol/conformance/cases/reads.d.ts +3 -0
  31. package/dist/protocol/conformance/cases/reads.d.ts.map +1 -0
  32. package/dist/protocol/conformance/cases/reads.js +140 -0
  33. package/dist/protocol/conformance/cases/reads.js.map +1 -0
  34. package/dist/protocol/conformance/cases/types.d.ts +9 -0
  35. package/dist/protocol/conformance/cases/types.d.ts.map +1 -0
  36. package/dist/protocol/conformance/cases/types.js +2 -0
  37. package/dist/protocol/conformance/cases/types.js.map +1 -0
  38. package/dist/protocol/conformance/cases/wire.d.ts +3 -0
  39. package/dist/protocol/conformance/cases/wire.d.ts.map +1 -0
  40. package/dist/protocol/conformance/cases/wire.js +130 -0
  41. package/dist/protocol/conformance/cases/wire.js.map +1 -0
  42. package/dist/protocol/conformance/cases/writes.d.ts +3 -0
  43. package/dist/protocol/conformance/cases/writes.d.ts.map +1 -0
  44. package/dist/protocol/conformance/cases/writes.js +278 -0
  45. package/dist/protocol/conformance/cases/writes.js.map +1 -0
  46. package/dist/protocol/conformance/contentHashFixtures.d.ts +22 -0
  47. package/dist/protocol/conformance/contentHashFixtures.d.ts.map +1 -0
  48. package/dist/protocol/conformance/contentHashFixtures.js +64 -0
  49. package/dist/protocol/conformance/contentHashFixtures.js.map +1 -0
  50. package/dist/protocol/conformance/context.d.ts +100 -0
  51. package/dist/protocol/conformance/context.d.ts.map +1 -0
  52. package/dist/protocol/conformance/context.js +155 -0
  53. package/dist/protocol/conformance/context.js.map +1 -0
  54. package/dist/protocol/conformance/index.d.ts +32 -0
  55. package/dist/protocol/conformance/index.d.ts.map +1 -0
  56. package/dist/protocol/conformance/index.js +90 -0
  57. package/dist/protocol/conformance/index.js.map +1 -0
  58. package/dist/protocol/errors.d.ts +85 -0
  59. package/dist/protocol/errors.d.ts.map +1 -0
  60. package/dist/protocol/errors.js +62 -0
  61. package/dist/protocol/errors.js.map +1 -0
  62. package/dist/protocol/index.d.ts +25 -0
  63. package/dist/protocol/index.d.ts.map +1 -0
  64. package/dist/protocol/index.js +25 -0
  65. package/dist/protocol/index.js.map +1 -0
  66. package/dist/protocol/keys.d.ts +101 -0
  67. package/dist/protocol/keys.d.ts.map +1 -0
  68. package/dist/protocol/keys.js +223 -0
  69. package/dist/protocol/keys.js.map +1 -0
  70. package/dist/protocol/params.d.ts +10 -0
  71. package/dist/protocol/params.d.ts.map +1 -0
  72. package/dist/protocol/params.js +54 -0
  73. package/dist/protocol/params.js.map +1 -0
  74. package/dist/protocol/secrets.d.ts +22 -0
  75. package/dist/protocol/secrets.d.ts.map +1 -0
  76. package/dist/protocol/secrets.js +200 -0
  77. package/dist/protocol/secrets.js.map +1 -0
  78. package/dist/protocol/server/assets.d.ts +20 -0
  79. package/dist/protocol/server/assets.d.ts.map +1 -0
  80. package/dist/protocol/server/assets.js +77 -0
  81. package/dist/protocol/server/assets.js.map +1 -0
  82. package/dist/protocol/server/auth.d.ts +31 -0
  83. package/dist/protocol/server/auth.d.ts.map +1 -0
  84. package/dist/protocol/server/auth.js +32 -0
  85. package/dist/protocol/server/auth.js.map +1 -0
  86. package/dist/protocol/server/bodyCache.d.ts +28 -0
  87. package/dist/protocol/server/bodyCache.d.ts.map +1 -0
  88. package/dist/protocol/server/bodyCache.js +75 -0
  89. package/dist/protocol/server/bodyCache.js.map +1 -0
  90. package/dist/protocol/server/content.d.ts +44 -0
  91. package/dist/protocol/server/content.d.ts.map +1 -0
  92. package/dist/protocol/server/content.js +132 -0
  93. package/dist/protocol/server/content.js.map +1 -0
  94. package/dist/protocol/server/core.d.ts +63 -0
  95. package/dist/protocol/server/core.d.ts.map +1 -0
  96. package/dist/protocol/server/core.js +77 -0
  97. package/dist/protocol/server/core.js.map +1 -0
  98. package/dist/protocol/server/handler.d.ts +5 -0
  99. package/dist/protocol/server/handler.d.ts.map +1 -0
  100. package/dist/protocol/server/handler.js +70 -0
  101. package/dist/protocol/server/handler.js.map +1 -0
  102. package/dist/protocol/server/http.d.ts +24 -0
  103. package/dist/protocol/server/http.d.ts.map +1 -0
  104. package/dist/protocol/server/http.js +133 -0
  105. package/dist/protocol/server/http.js.map +1 -0
  106. package/dist/protocol/server/index.d.ts +11 -0
  107. package/dist/protocol/server/index.d.ts.map +1 -0
  108. package/dist/protocol/server/index.js +9 -0
  109. package/dist/protocol/server/index.js.map +1 -0
  110. package/dist/protocol/server/methods/apply.d.ts +4 -0
  111. package/dist/protocol/server/methods/apply.d.ts.map +1 -0
  112. package/dist/protocol/server/methods/apply.js +275 -0
  113. package/dist/protocol/server/methods/apply.js.map +1 -0
  114. package/dist/protocol/server/methods/read.d.ts +14 -0
  115. package/dist/protocol/server/methods/read.d.ts.map +1 -0
  116. package/dist/protocol/server/methods/read.js +132 -0
  117. package/dist/protocol/server/methods/read.js.map +1 -0
  118. package/dist/protocol/server/rpc.d.ts +7 -0
  119. package/dist/protocol/server/rpc.d.ts.map +1 -0
  120. package/dist/protocol/server/rpc.js +115 -0
  121. package/dist/protocol/server/rpc.js.map +1 -0
  122. package/dist/protocol/storage/fs/hash.d.ts +8 -0
  123. package/dist/protocol/storage/fs/hash.d.ts.map +1 -0
  124. package/dist/protocol/storage/fs/hash.js +20 -0
  125. package/dist/protocol/storage/fs/hash.js.map +1 -0
  126. package/dist/protocol/storage/fs/index.d.ts +30 -0
  127. package/dist/protocol/storage/fs/index.d.ts.map +1 -0
  128. package/dist/protocol/storage/fs/index.js +301 -0
  129. package/dist/protocol/storage/fs/index.js.map +1 -0
  130. package/dist/protocol/storage/fs/lock.d.ts +8 -0
  131. package/dist/protocol/storage/fs/lock.d.ts.map +1 -0
  132. package/dist/protocol/storage/fs/lock.js +61 -0
  133. package/dist/protocol/storage/fs/lock.js.map +1 -0
  134. package/dist/protocol/storage/fs/transaction.d.ts +19 -0
  135. package/dist/protocol/storage/fs/transaction.d.ts.map +1 -0
  136. package/dist/protocol/storage/fs/transaction.js +174 -0
  137. package/dist/protocol/storage/fs/transaction.js.map +1 -0
  138. package/dist/protocol/storage/fs/unsupported.d.ts +10 -0
  139. package/dist/protocol/storage/fs/unsupported.d.ts.map +1 -0
  140. package/dist/protocol/storage/fs/unsupported.js +4 -0
  141. package/dist/protocol/storage/fs/unsupported.js.map +1 -0
  142. package/dist/protocol/storage/memory.d.ts +40 -0
  143. package/dist/protocol/storage/memory.d.ts.map +1 -0
  144. package/dist/protocol/storage/memory.js +179 -0
  145. package/dist/protocol/storage/memory.js.map +1 -0
  146. package/dist/protocol/storage.d.ts +178 -0
  147. package/dist/protocol/storage.d.ts.map +1 -0
  148. package/dist/protocol/storage.js +29 -0
  149. package/dist/protocol/storage.js.map +1 -0
  150. package/dist/protocol/types.d.ts +194 -0
  151. package/dist/protocol/types.d.ts.map +1 -0
  152. package/dist/protocol/types.js +31 -0
  153. package/dist/protocol/types.js.map +1 -0
  154. package/dist/v8/analytics.d.ts +31 -0
  155. package/dist/v8/analytics.d.ts.map +1 -0
  156. package/dist/v8/analytics.js +46 -0
  157. package/dist/v8/analytics.js.map +1 -0
  158. package/dist/v8/background.d.ts +26 -0
  159. package/dist/v8/background.d.ts.map +1 -0
  160. package/dist/v8/background.js +95 -0
  161. package/dist/v8/background.js.map +1 -0
  162. package/dist/v8/builtins/data.d.ts +15 -0
  163. package/dist/v8/builtins/data.d.ts.map +1 -0
  164. package/dist/v8/builtins/data.js +18 -0
  165. package/dist/v8/builtins/data.js.map +1 -0
  166. package/dist/v8/builtins/index.d.ts +9 -0
  167. package/dist/v8/builtins/index.d.ts.map +1 -0
  168. package/dist/v8/builtins/index.js +24 -0
  169. package/dist/v8/builtins/index.js.map +1 -0
  170. package/dist/v8/builtins/lazy.d.ts +17 -0
  171. package/dist/v8/builtins/lazy.d.ts.map +1 -0
  172. package/dist/v8/builtins/lazy.js +13 -0
  173. package/dist/v8/builtins/lazy.js.map +1 -0
  174. package/dist/v8/builtins/legacy.d.ts +41 -0
  175. package/dist/v8/builtins/legacy.d.ts.map +1 -0
  176. package/dist/v8/builtins/legacy.js +62 -0
  177. package/dist/v8/builtins/legacy.js.map +1 -0
  178. package/dist/v8/builtins/matchers.d.ts +19 -0
  179. package/dist/v8/builtins/matchers.d.ts.map +1 -0
  180. package/dist/v8/builtins/matchers.js +24 -0
  181. package/dist/v8/builtins/matchers.js.map +1 -0
  182. package/dist/v8/builtins/multivariate.d.ts +15 -0
  183. package/dist/v8/builtins/multivariate.d.ts.map +1 -0
  184. package/dist/v8/builtins/multivariate.js +18 -0
  185. package/dist/v8/builtins/multivariate.js.map +1 -0
  186. package/dist/v8/builtins/secret.d.ts +7 -0
  187. package/dist/v8/builtins/secret.d.ts.map +1 -0
  188. package/dist/v8/builtins/secret.js +68 -0
  189. package/dist/v8/builtins/secret.js.map +1 -0
  190. package/dist/v8/canonical.d.ts +42 -0
  191. package/dist/v8/canonical.d.ts.map +1 -0
  192. package/dist/v8/canonical.js +111 -0
  193. package/dist/v8/canonical.js.map +1 -0
  194. package/dist/v8/ciphertext.d.ts +58 -0
  195. package/dist/v8/ciphertext.d.ts.map +1 -0
  196. package/dist/v8/ciphertext.js +134 -0
  197. package/dist/v8/ciphertext.js.map +1 -0
  198. package/dist/v8/cli/builtins.d.ts +11 -0
  199. package/dist/v8/cli/builtins.d.ts.map +1 -0
  200. package/dist/v8/cli/builtins.js +18 -0
  201. package/dist/v8/cli/builtins.js.map +1 -0
  202. package/dist/v8/cli/check/index.d.ts +41 -0
  203. package/dist/v8/cli/check/index.d.ts.map +1 -0
  204. package/dist/v8/cli/check/index.js +713 -0
  205. package/dist/v8/cli/check/index.js.map +1 -0
  206. package/dist/v8/cli/check/messages.d.ts +24 -0
  207. package/dist/v8/cli/check/messages.d.ts.map +1 -0
  208. package/dist/v8/cli/check/messages.js +150 -0
  209. package/dist/v8/cli/check/messages.js.map +1 -0
  210. package/dist/v8/cli/content.d.ts +60 -0
  211. package/dist/v8/cli/content.d.ts.map +1 -0
  212. package/dist/v8/cli/content.js +231 -0
  213. package/dist/v8/cli/content.js.map +1 -0
  214. package/dist/v8/cli/index.d.ts +18 -0
  215. package/dist/v8/cli/index.d.ts.map +1 -0
  216. package/dist/v8/cli/index.js +18 -0
  217. package/dist/v8/cli/index.js.map +1 -0
  218. package/dist/v8/cli/log.d.ts +9 -0
  219. package/dist/v8/cli/log.d.ts.map +1 -0
  220. package/dist/v8/cli/log.js +11 -0
  221. package/dist/v8/cli/log.js.map +1 -0
  222. package/dist/v8/cli/main.d.ts +2 -0
  223. package/dist/v8/cli/main.d.ts.map +1 -0
  224. package/dist/v8/cli/main.js +9 -0
  225. package/dist/v8/cli/main.js.map +1 -0
  226. package/dist/v8/cli/root.d.ts +28 -0
  227. package/dist/v8/cli/root.d.ts.map +1 -0
  228. package/dist/v8/cli/root.js +64 -0
  229. package/dist/v8/cli/root.js.map +1 -0
  230. package/dist/v8/cli/run.d.ts +13 -0
  231. package/dist/v8/cli/run.d.ts.map +1 -0
  232. package/dist/v8/cli/run.js +210 -0
  233. package/dist/v8/cli/run.js.map +1 -0
  234. package/dist/v8/cli/schema/builtinSchemas.d.ts +22 -0
  235. package/dist/v8/cli/schema/builtinSchemas.d.ts.map +1 -0
  236. package/dist/v8/cli/schema/builtinSchemas.js +213 -0
  237. package/dist/v8/cli/schema/builtinSchemas.js.map +1 -0
  238. package/dist/v8/cli/schema/generate.d.ts +50 -0
  239. package/dist/v8/cli/schema/generate.d.ts.map +1 -0
  240. package/dist/v8/cli/schema/generate.js +415 -0
  241. package/dist/v8/cli/schema/generate.js.map +1 -0
  242. package/dist/v8/cli/schema/index.d.ts +21 -0
  243. package/dist/v8/cli/schema/index.d.ts.map +1 -0
  244. package/dist/v8/cli/schema/index.js +51 -0
  245. package/dist/v8/cli/schema/index.js.map +1 -0
  246. package/dist/v8/cli/schema/tsProgram.d.ts +120 -0
  247. package/dist/v8/cli/schema/tsProgram.d.ts.map +1 -0
  248. package/dist/v8/cli/schema/tsProgram.js +418 -0
  249. package/dist/v8/cli/schema/tsProgram.js.map +1 -0
  250. package/dist/v8/cli/schema/typeToSchema.d.ts +81 -0
  251. package/dist/v8/cli/schema/typeToSchema.d.ts.map +1 -0
  252. package/dist/v8/cli/schema/typeToSchema.js +683 -0
  253. package/dist/v8/cli/schema/typeToSchema.js.map +1 -0
  254. package/dist/v8/cli/serve/server.d.ts +31 -0
  255. package/dist/v8/cli/serve/server.d.ts.map +1 -0
  256. package/dist/v8/cli/serve/server.js +247 -0
  257. package/dist/v8/cli/serve/server.js.map +1 -0
  258. package/dist/v8/cli/watch.d.ts +20 -0
  259. package/dist/v8/cli/watch.d.ts.map +1 -0
  260. package/dist/v8/cli/watch.js +79 -0
  261. package/dist/v8/cli/watch.js.map +1 -0
  262. package/dist/v8/client.d.ts +20 -0
  263. package/dist/v8/client.d.ts.map +1 -0
  264. package/dist/v8/client.js +115 -0
  265. package/dist/v8/client.js.map +1 -0
  266. package/dist/v8/cms.d.ts +9 -0
  267. package/dist/v8/cms.d.ts.map +1 -0
  268. package/dist/v8/cms.js +206 -0
  269. package/dist/v8/cms.js.map +1 -0
  270. package/dist/v8/content.d.ts +35 -0
  271. package/dist/v8/content.d.ts.map +1 -0
  272. package/dist/v8/content.js +183 -0
  273. package/dist/v8/content.js.map +1 -0
  274. package/dist/v8/draft.d.ts +44 -0
  275. package/dist/v8/draft.d.ts.map +1 -0
  276. package/dist/v8/draft.js +133 -0
  277. package/dist/v8/draft.js.map +1 -0
  278. package/dist/v8/errors.d.ts +21 -0
  279. package/dist/v8/errors.d.ts.map +1 -0
  280. package/dist/v8/errors.js +39 -0
  281. package/dist/v8/errors.js.map +1 -0
  282. package/dist/v8/fetch.d.ts +26 -0
  283. package/dist/v8/fetch.d.ts.map +1 -0
  284. package/dist/v8/fetch.js +98 -0
  285. package/dist/v8/fetch.js.map +1 -0
  286. package/dist/v8/identity.d.ts +19 -0
  287. package/dist/v8/identity.d.ts.map +1 -0
  288. package/dist/v8/identity.js +54 -0
  289. package/dist/v8/identity.js.map +1 -0
  290. package/dist/v8/index.d.ts +11 -0
  291. package/dist/v8/index.d.ts.map +1 -0
  292. package/dist/v8/index.js +10 -0
  293. package/dist/v8/index.js.map +1 -0
  294. package/dist/v8/json.d.ts +19 -0
  295. package/dist/v8/json.d.ts.map +1 -0
  296. package/dist/v8/json.js +65 -0
  297. package/dist/v8/json.js.map +1 -0
  298. package/dist/v8/matchRoute.d.ts +30 -0
  299. package/dist/v8/matchRoute.d.ts.map +1 -0
  300. package/dist/v8/matchRoute.js +175 -0
  301. package/dist/v8/matchRoute.js.map +1 -0
  302. package/dist/v8/remoteLoader.d.ts +16 -0
  303. package/dist/v8/remoteLoader.d.ts.map +1 -0
  304. package/dist/v8/remoteLoader.js +243 -0
  305. package/dist/v8/remoteLoader.js.map +1 -0
  306. package/dist/v8/resolver.d.ts +34 -0
  307. package/dist/v8/resolver.d.ts.map +1 -0
  308. package/dist/v8/resolver.js +219 -0
  309. package/dist/v8/resolver.js.map +1 -0
  310. package/dist/v8/secrets.d.ts +9 -0
  311. package/dist/v8/secrets.d.ts.map +1 -0
  312. package/dist/v8/secrets.js +14 -0
  313. package/dist/v8/secrets.js.map +1 -0
  314. package/dist/v8/telemetry.d.ts +61 -0
  315. package/dist/v8/telemetry.d.ts.map +1 -0
  316. package/dist/v8/telemetry.js +460 -0
  317. package/dist/v8/telemetry.js.map +1 -0
  318. package/dist/v8/types.d.ts +214 -0
  319. package/dist/v8/types.d.ts.map +1 -0
  320. package/dist/v8/types.js +2 -0
  321. package/dist/v8/types.js.map +1 -0
  322. package/package.json +65 -105
  323. package/src/index.ts +3 -13
  324. package/src/protocol/canonical.ts +1 -1
  325. package/src/protocol/ciphertext.ts +1 -1
  326. package/src/protocol/client.ts +2 -2
  327. package/src/protocol/conformance/cases/assets.ts +3 -3
  328. package/src/protocol/conformance/cases/guards.ts +4 -4
  329. package/src/protocol/conformance/cases/reads.ts +4 -4
  330. package/src/protocol/conformance/cases/types.ts +1 -1
  331. package/src/protocol/conformance/cases/wire.ts +4 -4
  332. package/src/protocol/conformance/cases/writes.ts +4 -4
  333. package/src/protocol/conformance/context.ts +4 -4
  334. package/src/protocol/conformance/index.ts +10 -10
  335. package/src/protocol/index.ts +6 -6
  336. package/src/protocol/params.ts +2 -2
  337. package/src/protocol/secrets.ts +3 -3
  338. package/src/protocol/server/assets.ts +6 -6
  339. package/src/protocol/server/auth.ts +1 -1
  340. package/src/protocol/server/content.ts +5 -5
  341. package/src/protocol/server/core.ts +12 -6
  342. package/src/protocol/server/handler.ts +6 -6
  343. package/src/protocol/server/http.ts +1 -1
  344. package/src/protocol/server/index.ts +3 -3
  345. package/src/protocol/server/methods/apply.ts +9 -9
  346. package/src/protocol/server/methods/read.ts +5 -5
  347. package/src/protocol/server/rpc.ts +6 -6
  348. package/src/protocol/storage/fs/index.ts +7 -7
  349. package/src/protocol/storage/fs/lock.ts +1 -1
  350. package/src/protocol/storage/fs/unsupported.ts +2 -2
  351. package/src/protocol/storage/memory.ts +5 -5
  352. package/src/protocol/storage.ts +1 -1
  353. package/src/v8/analytics.ts +2 -2
  354. package/src/v8/background.ts +3 -3
  355. package/src/v8/builtins/data.ts +1 -1
  356. package/src/v8/builtins/index.ts +6 -6
  357. package/src/v8/builtins/lazy.ts +1 -1
  358. package/src/v8/builtins/legacy.ts +2 -2
  359. package/src/v8/builtins/multivariate.ts +1 -1
  360. package/src/v8/builtins/secret.ts +2 -2
  361. package/src/v8/cli/builtins.ts +2 -2
  362. package/src/v8/cli/check/index.ts +11 -11
  363. package/src/v8/cli/content.ts +6 -6
  364. package/src/v8/cli/index.ts +8 -8
  365. package/src/v8/cli/main.ts +1 -1
  366. package/src/v8/cli/run.ts +7 -7
  367. package/src/v8/cli/schema/builtinSchemas.ts +1 -1
  368. package/src/v8/cli/schema/generate.ts +6 -6
  369. package/src/v8/cli/schema/index.ts +4 -4
  370. package/src/v8/cli/schema/tsProgram.ts +1 -1
  371. package/src/v8/cli/schema/typeToSchema.ts +24 -2
  372. package/src/v8/cli/serve/server.ts +9 -9
  373. package/src/v8/client.ts +5 -5
  374. package/src/v8/cms.ts +9 -9
  375. package/src/v8/content.ts +4 -4
  376. package/src/v8/draft.ts +1 -1
  377. package/src/v8/errors.ts +1 -1
  378. package/src/v8/fetch.ts +9 -28
  379. package/src/v8/identity.ts +1 -1
  380. package/src/v8/index.ts +5 -5
  381. package/src/v8/matchRoute.ts +1 -1
  382. package/src/v8/remoteLoader.ts +7 -7
  383. package/src/v8/resolver.ts +6 -6
  384. package/src/v8/secrets.ts +1 -1
  385. package/src/v8/telemetry.ts +6 -6
  386. package/src/cms/applySectionConventions.ts +0 -148
  387. package/src/cms/blockSource.ts +0 -228
  388. package/src/cms/client.ts +0 -85
  389. package/src/cms/deferredTrigger.ts +0 -58
  390. package/src/cms/draftSource.ts +0 -476
  391. package/src/cms/index.ts +0 -180
  392. package/src/cms/loadDecofileDirectory.ts +0 -89
  393. package/src/cms/loader.ts +0 -563
  394. package/src/cms/registry.ts +0 -264
  395. package/src/cms/renderJson.ts +0 -179
  396. package/src/cms/resolve.ts +0 -2583
  397. package/src/cms/schema.ts +0 -1219
  398. package/src/cms/sectionLoaderContext.ts +0 -113
  399. package/src/cms/sectionLoaders.ts +0 -686
  400. package/src/cms/sectionMixins.ts +0 -153
  401. package/src/flags/audience.ts +0 -56
  402. package/src/flags/everyone.ts +0 -29
  403. package/src/flags/flag.ts +0 -15
  404. package/src/flags/multivariate/image.ts +0 -11
  405. package/src/flags/multivariate/message.ts +0 -11
  406. package/src/flags/multivariate/page.ts +0 -16
  407. package/src/flags/multivariate/section.ts +0 -16
  408. package/src/flags/multivariate.ts +0 -1
  409. package/src/flags/types.ts +0 -59
  410. package/src/flags/utils/multivariate.ts +0 -20
  411. package/src/hooks/Image.tsx +0 -314
  412. package/src/hooks/JsonLd.tsx +0 -353
  413. package/src/hooks/LazySection.tsx +0 -121
  414. package/src/hooks/LiveControls.tsx +0 -144
  415. package/src/hooks/Picture.tsx +0 -127
  416. package/src/hooks/RenderSection.tsx +0 -91
  417. package/src/hooks/SectionErrorFallback.tsx +0 -97
  418. package/src/hooks/Stats.tsx +0 -134
  419. package/src/hooks/index.ts +0 -35
  420. package/src/hooks/useLoadMore.ts +0 -100
  421. package/src/matchers/builtins.ts +0 -459
  422. package/src/matchers/countryNames.ts +0 -104
  423. package/src/matchers/override.ts +0 -136
  424. package/src/matchers/posthog.ts +0 -154
  425. package/src/middleware/decoState.ts +0 -55
  426. package/src/middleware/healthMetrics.ts +0 -133
  427. package/src/middleware/hydrationContext.ts +0 -79
  428. package/src/middleware/index.ts +0 -88
  429. package/src/middleware/liveness.ts +0 -21
  430. package/src/middleware/observability.ts +0 -800
  431. package/src/middleware/validateSection.ts +0 -100
  432. package/src/preview/DraftPreviewBadge.tsx +0 -306
  433. package/src/preview/decoMark.ts +0 -11
  434. package/src/preview/index.ts +0 -8
  435. package/src/sdk/abTesting.ts +0 -556
  436. package/src/sdk/analytics.ts +0 -147
  437. package/src/sdk/cacheHeaders.ts +0 -633
  438. package/src/sdk/cacheStorage.ts +0 -287
  439. package/src/sdk/cachedLoader.ts +0 -556
  440. package/src/sdk/clx.ts +0 -5
  441. package/src/sdk/cn.ts +0 -28
  442. package/src/sdk/composite.ts +0 -114
  443. package/src/sdk/cookie.ts +0 -129
  444. package/src/sdk/crypto.ts +0 -199
  445. package/src/sdk/csp.ts +0 -59
  446. package/src/sdk/deepOmit.ts +0 -52
  447. package/src/sdk/detectDevice.ts +0 -45
  448. package/src/sdk/djb2.ts +0 -20
  449. package/src/sdk/encoding.ts +0 -44
  450. package/src/sdk/env.ts +0 -54
  451. package/src/sdk/experiments.ts +0 -314
  452. package/src/sdk/fetchCache.ts +0 -269
  453. package/src/sdk/fetchTimeout.ts +0 -58
  454. package/src/sdk/flags.ts +0 -138
  455. package/src/sdk/http.ts +0 -124
  456. package/src/sdk/index.ts +0 -97
  457. package/src/sdk/inflightTimeout.ts +0 -53
  458. package/src/sdk/instrumentedFetch.ts +0 -362
  459. package/src/sdk/invoke.ts +0 -298
  460. package/src/sdk/logger.ts +0 -304
  461. package/src/sdk/mergeCacheControl.ts +0 -150
  462. package/src/sdk/nonce.ts +0 -46
  463. package/src/sdk/normalizeUrls.ts +0 -91
  464. package/src/sdk/observability.ts +0 -116
  465. package/src/sdk/otel.ts +0 -1118
  466. package/src/sdk/otelAdapters/clickhouseCollector.ts +0 -65
  467. package/src/sdk/otelAdapters.ts +0 -144
  468. package/src/sdk/otelHttpLog.ts +0 -419
  469. package/src/sdk/otelHttpMeter.ts +0 -532
  470. package/src/sdk/otelHttpTracer.ts +0 -543
  471. package/src/sdk/redirects.ts +0 -336
  472. package/src/sdk/requestContext.ts +0 -281
  473. package/src/sdk/requestContextStorage.browser.ts +0 -43
  474. package/src/sdk/requestContextStorage.ts +0 -35
  475. package/src/sdk/responseCache.ts +0 -82
  476. package/src/sdk/retry.ts +0 -45
  477. package/src/sdk/serverTimings.ts +0 -68
  478. package/src/sdk/signal.ts +0 -42
  479. package/src/sdk/sitemap.ts +0 -160
  480. package/src/sdk/urlRedaction.ts +0 -82
  481. package/src/sdk/urlUtils.ts +0 -183
  482. package/src/sdk/useDevice.ts +0 -89
  483. package/src/sdk/useDeviceContext.tsx +0 -108
  484. package/src/sdk/useId.ts +0 -7
  485. package/src/sdk/useScript.ts +0 -210
  486. package/src/sdk/useSuggestions.ts +0 -188
  487. package/src/sdk/wrapCaughtErrors.ts +0 -107
  488. package/src/setup.ts +0 -120
  489. package/src/types/index.ts +0 -53
  490. package/src/types/widgets.ts +0 -14
@@ -0,0 +1,21 @@
1
+ import type { CMSError, CMSErrorCode } from "./types.ts";
2
+ /**
3
+ * The concrete {@link CMSError}. It extends `Error` so a lazy block can reject
4
+ * with it (and a stack trace survives), while still satisfying the plain
5
+ * `{ code, message, path, cause }` shape the API documents.
6
+ */
7
+ export declare class ResolutionError extends Error implements CMSError {
8
+ readonly code: CMSErrorCode;
9
+ readonly path: (string | number)[];
10
+ readonly cause?: unknown;
11
+ constructor(code: CMSErrorCode, message: string, path: (string | number)[], cause?: unknown);
12
+ }
13
+ export declare function isResolutionError(value: unknown): value is ResolutionError;
14
+ export declare const errors: {
15
+ notFound: (name: string) => ResolutionError;
16
+ unknownBlock: (type: string, path: (string | number)[]) => ResolutionError;
17
+ cycle: (chain: string[]) => ResolutionError;
18
+ blockFailed: (type: string, path: (string | number)[], cause: unknown) => ResolutionError;
19
+ loaderFailed: (message: string, cause?: unknown) => ResolutionError;
20
+ };
21
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/v8/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAEzD;;;;GAIG;AACH,qBAAa,eAAgB,SAAQ,KAAM,YAAW,QAAQ;IAC5D,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;IACnC,SAAkB,KAAK,CAAC,EAAE,OAAO,CAAC;IAElC,YAAY,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,EAAE,OAAO,EAM1F;CACF;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,eAAe,CAE1E;AAWD,eAAO,MAAM,MAAM;IACjB,QAAQ,SAAS,MAAM;IAGvB,YAAY,SAAS,MAAM,QAAQ,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE;IAOtD,KAAK,UAAU,MAAM,EAAE;IAGvB,WAAW,SAAS,MAAM,QAAQ,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,SAAS,OAAO;IAGrE,YAAY,YAAY,MAAM,UAAU,OAAO;CAOhD,CAAC"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * The concrete {@link CMSError}. It extends `Error` so a lazy block can reject
3
+ * with it (and a stack trace survives), while still satisfying the plain
4
+ * `{ code, message, path, cause }` shape the API documents.
5
+ */
6
+ export class ResolutionError extends Error {
7
+ code;
8
+ path;
9
+ cause;
10
+ constructor(code, message, path, cause) {
11
+ super(message);
12
+ this.name = "CMSError";
13
+ this.code = code;
14
+ this.path = path;
15
+ if (cause !== undefined)
16
+ this.cause = cause;
17
+ }
18
+ }
19
+ export function isResolutionError(value) {
20
+ return value instanceof ResolutionError;
21
+ }
22
+ function describe(cause) {
23
+ if (cause instanceof Error)
24
+ return cause.message;
25
+ try {
26
+ return String(cause);
27
+ }
28
+ catch {
29
+ return "unknown error";
30
+ }
31
+ }
32
+ export const errors = {
33
+ notFound: (name) => new ResolutionError("NOT_FOUND", `no saved block named "${name}"`, []),
34
+ unknownBlock: (type, path) => new ResolutionError("UNKNOWN_BLOCK", `"${type}" is neither a type in the block map nor a saved block`, path),
35
+ cycle: (chain) => new ResolutionError("CYCLE", `saved blocks refer to each other: ${chain.join(" → ")}`, chain),
36
+ blockFailed: (type, path, cause) => new ResolutionError("BLOCK_FAILED", `block "${type}" failed: ${describe(cause)}`, path, cause),
37
+ loaderFailed: (message, cause) => new ResolutionError("LOADER_FAILED", cause === undefined ? message : `${message}: ${describe(cause)}`, [], cause),
38
+ };
39
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/v8/errors.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,OAAO,eAAgB,SAAQ,KAAK;IAC/B,IAAI,CAAe;IACnB,IAAI,CAAsB;IACjB,KAAK,CAAW;IAElC,YAAY,IAAkB,EAAE,OAAe,EAAE,IAAyB,EAAE,KAAe;QACzF,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,KAAK,KAAK,SAAS;YAAE,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IAC9C,CAAC;CACF;AAED,MAAM,UAAU,iBAAiB,CAAC,KAAc;IAC9C,OAAO,KAAK,YAAY,eAAe,CAAC;AAC1C,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,IAAI,KAAK,YAAY,KAAK;QAAE,OAAO,KAAK,CAAC,OAAO,CAAC;IACjD,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,eAAe,CAAC;IACzB,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,QAAQ,EAAE,CAAC,IAAY,EAAE,EAAE,CACzB,IAAI,eAAe,CAAC,WAAW,EAAE,yBAAyB,IAAI,GAAG,EAAE,EAAE,CAAC;IAExE,YAAY,EAAE,CAAC,IAAY,EAAE,IAAyB,EAAE,EAAE,CACxD,IAAI,eAAe,CACjB,eAAe,EACf,IAAI,IAAI,wDAAwD,EAChE,IAAI,CACL;IAEH,KAAK,EAAE,CAAC,KAAe,EAAE,EAAE,CACzB,IAAI,eAAe,CAAC,OAAO,EAAE,qCAAqC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,KAAK,CAAC;IAE/F,WAAW,EAAE,CAAC,IAAY,EAAE,IAAyB,EAAE,KAAc,EAAE,EAAE,CACvE,IAAI,eAAe,CAAC,cAAc,EAAE,UAAU,IAAI,aAAa,QAAQ,CAAC,KAAK,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC;IAEhG,YAAY,EAAE,CAAC,OAAe,EAAE,KAAe,EAAE,EAAE,CACjD,IAAI,eAAe,CACjB,eAAe,EACf,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,KAAK,QAAQ,CAAC,KAAK,CAAC,EAAE,EAChE,EAAE,EACF,KAAK,CACN;CACJ,CAAC"}
@@ -0,0 +1,26 @@
1
+ interface InstrumentedFetchOptions {
2
+ /** The provider label, e.g. "vtex", "acme-search". */
3
+ provider: string;
4
+ /**
5
+ * The fetch underneath; defaults to `globalThis.fetch`. An upstream cache
6
+ * goes here (see /next/caching#upstream-data); a response it serves from
7
+ * the cache carries `x-cache: HIT` and is measured with `cached=true`.
8
+ */
9
+ fetch?: typeof fetch;
10
+ /** Off unless set. `attempts` is how many times a failed request is retried; a retried request is measured once. */
11
+ retry?: {
12
+ attempts: number;
13
+ backoffMs?: number;
14
+ };
15
+ /** Off unless set: after `failures` consecutive failures, fail fast for `cooldownMs`. */
16
+ circuitBreaker?: {
17
+ failures: number;
18
+ cooldownMs: number;
19
+ };
20
+ }
21
+ type InstrumentedFetch = (input: string | URL | Request, init?: RequestInit & {
22
+ operation?: string;
23
+ }) => Promise<Response>;
24
+ export declare function createInstrumentedFetch(options: InstrumentedFetchOptions): InstrumentedFetch;
25
+ export {};
26
+ //# sourceMappingURL=fetch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/v8/fetch.ts"],"names":[],"mappings":"AAaA,UAAU,wBAAwB;IAChC,sDAAsD;IACtD,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IACrB,oHAAoH;IACpH,KAAK,CAAC,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACjD,yFAAyF;IACzF,cAAc,CAAC,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC;CAC3D;AAED,KAAK,iBAAiB,GAAG,CACvB,KAAK,EAAE,MAAM,GAAG,GAAG,GAAG,OAAO,EAC7B,IAAI,CAAC,EAAE,WAAW,GAAG;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,KACxC,OAAO,CAAC,QAAQ,CAAC,CAAC;AAOvB,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,wBAAwB,GAAG,iBAAiB,CAyF5F"}
@@ -0,0 +1,98 @@
1
+ /**
2
+ * `@decocms/blocks/fetch`: the instrumented fetch every upstream client uses.
3
+ * See /next/upstream-clients and /next/api-reference#createinstrumentedfetch-options.
4
+ *
5
+ * Each request is timed until its response headers arrive and measured once
6
+ * (`http.client.request.duration`), with `provider`, `operation`,
7
+ * `status_class`, `cached` and `retries` labels, however many retries it
8
+ * took. Measurements go to the CMS in the same process, and nowhere when it
9
+ * has no telemetry destination. Nothing about a request's body, headers or
10
+ * query string is recorded.
11
+ */
12
+ import { currentTelemetry, describe, newTraceId } from "./telemetry.js";
13
+ /** Statuses worth retrying: rate limits and gateway errors. */
14
+ const RETRY_STATUSES = new Set([429, 502, 503, 504]);
15
+ /** Only requests that are safe to repeat are retried. */
16
+ const IDEMPOTENT = new Set(["GET", "HEAD", "OPTIONS", "PUT", "DELETE"]);
17
+ export function createInstrumentedFetch(options) {
18
+ const { provider, retry, circuitBreaker } = options;
19
+ let failures = 0;
20
+ let openUntil = 0;
21
+ return async (input, init = {}) => {
22
+ const { operation = "unknown", ...requestInit } = init;
23
+ const method = (requestInit.method ?? (input instanceof Request ? input.method : "GET")).toUpperCase();
24
+ const doFetch = options.fetch ?? globalThis.fetch;
25
+ const maxRetries = retry && IDEMPOTENT.has(method) ? Math.max(0, Math.floor(retry.attempts)) : 0;
26
+ const startedAt = Date.now();
27
+ const started = performance.now();
28
+ let retries = 0;
29
+ let response;
30
+ let failure;
31
+ if (circuitBreaker && failures >= circuitBreaker.failures && Date.now() < openUntil) {
32
+ failure = new Error(`${provider} ${operation}: circuit open after ${failures} failures`);
33
+ }
34
+ else {
35
+ for (;;) {
36
+ try {
37
+ response = await doFetch(maxRetries > 0 && input instanceof Request ? input.clone() : input, requestInit);
38
+ failure = undefined;
39
+ }
40
+ catch (error) {
41
+ response = undefined;
42
+ failure = error;
43
+ }
44
+ const retryable = response !== undefined ? RETRY_STATUSES.has(response.status) : !isAbort(failure);
45
+ if (!retryable || retries >= maxRetries)
46
+ break;
47
+ void response?.body?.cancel().catch(() => { });
48
+ await new Promise((resolve) => setTimeout(resolve, (retry?.backoffMs ?? 100) * 2 ** retries));
49
+ retries++;
50
+ }
51
+ if (circuitBreaker) {
52
+ const failed = response === undefined || response.status >= 500;
53
+ failures = failed ? failures + 1 : 0;
54
+ if (failed && failures >= circuitBreaker.failures) {
55
+ openUntil = Date.now() + circuitBreaker.cooldownMs;
56
+ }
57
+ }
58
+ }
59
+ const telemetry = currentTelemetry();
60
+ if (telemetry !== undefined) {
61
+ const labels = {
62
+ provider,
63
+ operation,
64
+ status_class: response ? `${Math.floor(response.status / 100)}xx` : "error",
65
+ // An upstream cache is the site's own `fetch` option; it marks a hit `x-cache: HIT`.
66
+ cached: response?.headers.get("x-cache") === "HIT",
67
+ retries,
68
+ };
69
+ telemetry.histogram("http.client.request.duration", labels, (performance.now() - started) / 1000);
70
+ if (response === undefined) {
71
+ telemetry.error(`${provider} ${operation} failed: ${describe(failure)}`, {
72
+ "error.code": "FETCH_FAILED",
73
+ provider,
74
+ operation,
75
+ });
76
+ }
77
+ if (telemetry.sampleTrace()) {
78
+ telemetry.span({
79
+ name: `${provider} ${operation}`,
80
+ kind: "client",
81
+ traceId: newTraceId(),
82
+ start: startedAt,
83
+ end: Date.now(),
84
+ attributes: { ...labels, "http.response.status_code": response?.status },
85
+ error: response === undefined || response.status >= 500,
86
+ });
87
+ }
88
+ }
89
+ if (response === undefined)
90
+ throw failure;
91
+ return response;
92
+ };
93
+ }
94
+ function isAbort(error) {
95
+ const name = error?.name;
96
+ return name === "AbortError" || name === "TimeoutError";
97
+ }
98
+ //# sourceMappingURL=fetch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../src/v8/fetch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAsBxE,+DAA+D;AAC/D,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AACrD,yDAAyD;AACzD,MAAM,UAAU,GAAG,IAAI,G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AAQ,KAAK,SAAS,IAAI,QAAQ,CAAC,MAAM,IAAI,GAAG;iBACxD,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAED,IAAI,QAAQ,KAAK,SAAS;YAAE,MAAM,OAAO,CAAC;QAC1C,OAAO,QAAQ,CAAC;IAClB,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,OAAO,CAAC,KAAc;IAC7B,MAAM,IAAI,GAAI,KAAmC,EAAE,IAAI,CAAC;IACxD,OAAO,IAAI,KAAK,YAAY,IAAI,IAAI,KAAK,cAAc,CAAC;AAC1D,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Identity helpers for process-wide singletons (`createCMS`, `remoteLoader`):
3
+ * keys go into the global symbol registry, so they're derived from the
4
+ * configuration and never carry a secret.
5
+ */
6
+ import type { Loader, Snapshot } from "./types.ts";
7
+ /**
8
+ * `module:<root>` for a content module, which names the `.deco` folder it was
9
+ * generated from in a `root` field `deco content` writes (not part of the
10
+ * documented `Snapshot`); `loader#<id>`/`module#<id>` otherwise.
11
+ */
12
+ export declare function contentIdentity(content: Snapshot | Loader): string;
13
+ /** FNV-1a, 32-bit: a non-cryptographic fingerprint that keeps secrets out of keys and logs. */
14
+ export declare function fnv1a(input: string): string;
15
+ /** Reads an environment variable where there is one (Node, Bun, Workers with nodejs_compat). */
16
+ export declare function readEnv(name: string): string | undefined;
17
+ /** Clears every global instance whose registry key starts with `prefix`. */
18
+ export declare function clearGlobals(prefix: string): void;
19
+ //# sourceMappingURL=identity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../src/v8/identity.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAInD;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,QAAQ,GAAG,MAAM,GAAG,MAAM,CAMlE;AAkBD,+FAA+F;AAC/F,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAO3C;AAED,gGAAgG;AAChG,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAOxD;AAED,4EAA4E;AAC5E,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAKjD"}
@@ -0,0 +1,54 @@
1
+ const OBJECT_IDS = Symbol.for("decocms.blocks.cms-loader-ids");
2
+ /**
3
+ * `module:<root>` for a content module, which names the `.deco` folder it was
4
+ * generated from in a `root` field `deco content` writes (not part of the
5
+ * documented `Snapshot`); `loader#<id>`/`module#<id>` otherwise.
6
+ */
7
+ export function contentIdentity(content) {
8
+ if (typeof content.load === "function")
9
+ return `loader#${objectId(content)}`;
10
+ const root = content.root;
11
+ return typeof root === "string" && root.length > 0
12
+ ? `module:${root}`
13
+ : `module#${objectId(content)}`;
14
+ }
15
+ /** A process-wide id per object (a loader, a root-less module), shared by every copy of this module. */
16
+ function objectId(object) {
17
+ const store = globalThis;
18
+ store[OBJECT_IDS] ??= { ids: new WeakMap(), next: 1 };
19
+ const registry = store[OBJECT_IDS];
20
+ let id = registry.ids.get(object);
21
+ if (id === undefined) {
22
+ id = registry.next++;
23
+ registry.ids.set(object, id);
24
+ }
25
+ return id;
26
+ }
27
+ /** FNV-1a, 32-bit: a non-cryptographic fingerprint that keeps secrets out of keys and logs. */
28
+ export function fnv1a(input) {
29
+ let hash = 0x811c9dc5;
30
+ for (let i = 0; i < input.length; i++) {
31
+ hash ^= input.charCodeAt(i);
32
+ hash = Math.imul(hash, 0x01000193);
33
+ }
34
+ return (hash >>> 0).toString(16).padStart(8, "0");
35
+ }
36
+ /** Reads an environment variable where there is one (Node, Bun, Workers with nodejs_compat). */
37
+ export function readEnv(name) {
38
+ try {
39
+ return globalThis.process
40
+ ?.env?.[name];
41
+ }
42
+ catch {
43
+ return undefined;
44
+ }
45
+ }
46
+ /** Clears every global instance whose registry key starts with `prefix`. */
47
+ export function clearGlobals(prefix) {
48
+ const store = globalThis;
49
+ for (const symbol of Object.getOwnPropertySymbols(globalThis)) {
50
+ if (Symbol.keyFor(symbol)?.startsWith(prefix))
51
+ delete store[symbol];
52
+ }
53
+ }
54
+ //# sourceMappingURL=identity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity.js","sourceRoot":"","sources":["../../src/v8/identity.ts"],"names":[],"mappings":"AAOA,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;AAE/D;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,OAA0B;IACxD,IAAI,OAAQ,OAAkB,CAAC,IAAI,KAAK,UAAU;QAAE,OAAO,UAAU,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;IACzF,MAAM,IAAI,GAAa,OAA8B,CAAC,IAAI,CAAC;IAC3D,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC;QAChD,CAAC,CAAC,UAAU,IAAI,EAAE;QAClB,CAAC,CAAC,UAAU,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;AACpC,CAAC;AAED,wGAAwG;AACxG,SAAS,QAAQ,CAAC,MAAc;IAC9B,MAAM,KAAK,GAAG,UAGb,CAAC;IACF,KAAK,CAAC,UAAU,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,OAAO,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;IACtD,MAAM,QAAQ,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC;IACnC,IAAI,EAAE,GAAG,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAClC,IAAI,EAAE,KAAK,SAAS,EAAE,CAAC;QACrB,EAAE,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC;QACrB,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAC/B,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,+FAA+F;AAC/F,MAAM,UAAU,KAAK,CAAC,KAAa;IACjC,IAAI,IAAI,GAAG,UAAU,CAAC;IACtB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,IAAI,IAAI,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QAC5B,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IACrC,CAAC;IACD,OAAO,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AACpD,CAAC;AAED,gGAAgG;AAChG,MAAM,UAAU,OAAO,CAAC,IAAY;IAClC,IAAI,CAAC;QACH,OAAQ,UAAyE,CAAC,OAAO;YACvF,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;IAClB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED,4EAA4E;AAC5E,MAAM,UAAU,YAAY,CAAC,MAAc;IACzC,MAAM,KAAK,GAAG,UAAgD,CAAC;IAC/D,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,qBAAqB,CAAC,UAAU,CAAC,EAAE,CAAC;QAC9D,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC,MAAM,CAAC;YAAE,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC;IACtE,CAAC;AACH,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * The next-major (v8) core SDK: `createCMS`, the clients, the built-in blocks,
3
+ * `matchRoute` and the draft helpers. Re-exported from the package root, where
4
+ * these names are the documented ones; see /next/api-reference.
5
+ */
6
+ export { createCMS, resetForTests } from "./cms.ts";
7
+ export { DRAFT_COOKIE, draftCookie, draftPointer, formatDraftPointer, parseDraftPointer, } from "./draft.ts";
8
+ export { matchRoute } from "./matchRoute.ts";
9
+ export { remoteLoader } from "./remoteLoader.ts";
10
+ export type { Analytics, Block, BlockFunction, Blocks, Client, CMS, CMSError, DraftPointer, Lazy, ListOptions, Loader, Match, Page, Redirect, Result, Route, Secret, Seo, Snapshot, Telemetry, TelemetryConfig, Variant, } from "./types.ts";
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/v8/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,EACL,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,YAAY,EACV,SAAS,EACT,KAAK,EACL,aAAa,EACb,MAAM,EACN,MAAM,EACN,GAAG,EACH,QAAQ,EACR,YAAY,EACZ,IAAI,EACJ,WAAW,EACX,MAAM,EACN,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,KAAK,EACL,MAAM,EACN,GAAG,EACH,QAAQ,EACR,SAAS,EACT,eAAe,EACf,OAAO,GACR,MAAM,YAAY,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * The next-major (v8) core SDK: `createCMS`, the clients, the built-in blocks,
3
+ * `matchRoute` and the draft helpers. Re-exported from the package root, where
4
+ * these names are the documented ones; see /next/api-reference.
5
+ */
6
+ export { createCMS, resetForTests } from "./cms.js";
7
+ export { DRAFT_COOKIE, draftCookie, draftPointer, formatDraftPointer, parseDraftPointer, } from "./draft.js";
8
+ export { matchRoute } from "./matchRoute.js";
9
+ export { remoteLoader } from "./remoteLoader.js";
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/v8/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,EACL,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,19 @@
1
+ /** Small JSON-shape helpers shared by the resolver and the CMS. */
2
+ export type JsonObject = Record<string, unknown>;
3
+ /** A plain `{}` object (JSON-like), not an array, a class instance, a Date… */
4
+ export declare function isPlainObject(value: unknown): value is JsonObject;
5
+ /** A stored block: a plain object whose `__resolveType` is a string. */
6
+ export declare function isBlock(value: unknown): value is JsonObject & {
7
+ __resolveType: string;
8
+ };
9
+ /** Own-property lookup that ignores the prototype chain (`"constructor"`, `"__proto__"`…). */
10
+ export declare function own<T>(record: Record<string, T> | undefined, key: string): T | undefined;
11
+ /**
12
+ * A canonical string for a JSON-like value: object keys sorted, so two equal
13
+ * blocks written in a different key order share a key. Returns `null` for
14
+ * anything that isn't JSON-like (functions, Dates, class instances…), which
15
+ * callers treat as "don't memoize". Object results are cached per object, so a
16
+ * subtree's key is computed once even when its parents are keyed too.
17
+ */
18
+ export declare function canonicalKey(value: unknown, cache: WeakMap<object, string | null>): string | null;
19
+ //# sourceMappingURL=json.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../src/v8/json.ts"],"names":[],"mappings":"AAAA,mEAAmE;AAEnE,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEjD,+EAA+E;AAC/E,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,UAAU,CAIjE;AAED,wEAAwE;AACxE,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,UAAU,GAAG;IAAE,aAAa,EAAE,MAAM,CAAA;CAAE,CAEvF;AAED,8FAA8F;AAC9F,wBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,SAAS,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAExF;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,GAAG,MAAM,GAAG,IAAI,CAwCjG"}
@@ -0,0 +1,65 @@
1
+ /** Small JSON-shape helpers shared by the resolver and the CMS. */
2
+ /** A plain `{}` object (JSON-like), not an array, a class instance, a Date… */
3
+ export function isPlainObject(value) {
4
+ if (value === null || typeof value !== "object" || Array.isArray(value))
5
+ return false;
6
+ const proto = Object.getPrototypeOf(value);
7
+ return proto === Object.prototype || proto === null;
8
+ }
9
+ /** A stored block: a plain object whose `__resolveType` is a string. */
10
+ export function isBlock(value) {
11
+ return isPlainObject(value) && typeof value.__resolveType === "string";
12
+ }
13
+ /** Own-property lookup that ignores the prototype chain (`"constructor"`, `"__proto__"`…). */
14
+ export function own(record, key) {
15
+ return record !== undefined && Object.hasOwn(record, key) ? record[key] : undefined;
16
+ }
17
+ /**
18
+ * A canonical string for a JSON-like value: object keys sorted, so two equal
19
+ * blocks written in a different key order share a key. Returns `null` for
20
+ * anything that isn't JSON-like (functions, Dates, class instances…), which
21
+ * callers treat as "don't memoize". Object results are cached per object, so a
22
+ * subtree's key is computed once even when its parents are keyed too.
23
+ */
24
+ export function canonicalKey(value, cache) {
25
+ switch (typeof value) {
26
+ case "string":
27
+ case "boolean":
28
+ return JSON.stringify(value);
29
+ case "number":
30
+ return Number.isFinite(value) ? String(value) : "null";
31
+ case "undefined":
32
+ return "~";
33
+ case "object":
34
+ break;
35
+ default:
36
+ return null;
37
+ }
38
+ if (value === null)
39
+ return "null";
40
+ const cached = cache.get(value);
41
+ if (cached !== undefined)
42
+ return cached;
43
+ let key;
44
+ if (Array.isArray(value)) {
45
+ key = joinKeys(value.map((item) => canonicalKey(item, cache)), "[", "]");
46
+ }
47
+ else if (isPlainObject(value)) {
48
+ const names = Object.keys(value).sort();
49
+ key = joinKeys(names.map((name) => {
50
+ const child = canonicalKey(value[name], cache);
51
+ return child === null ? null : `${JSON.stringify(name)}:${child}`;
52
+ }), "{", "}");
53
+ }
54
+ else {
55
+ key = null;
56
+ }
57
+ cache.set(value, key);
58
+ return key;
59
+ }
60
+ function joinKeys(parts, open, close) {
61
+ if (parts.some((part) => part === null))
62
+ return null;
63
+ return `${open}${parts.join(",")}${close}`;
64
+ }
65
+ //# sourceMappingURL=json.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json.js","sourceRoot":"","sources":["../../src/v8/json.ts"],"names":[],"mappings":"AAAA,mEAAmE;AAInE,+EAA+E;AAC/E,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACtF,MAAM,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IAC3C,OAAO,KAAK,KAAK,MAAM,CAAC,SAAS,IAAI,KAAK,KAAK,IAAI,CAAC;AACtD,CAAC;AAED,wEAAwE;AACxE,MAAM,UAAU,OAAO,CAAC,KAAc;IACpC,OAAO,aAAa,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC,aAAa,KAAK,QAAQ,CAAC;AACzE,CAAC;AAED,8FAA8F;AAC9F,MAAM,UAAU,GAAG,CAAI,MA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KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;YACjB,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,CAAC;YAC/C,OAAO,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,KAAK,EAAE,CAAC;QACpE,CAAC,CAAC,EACF,GAAG,EACH,GAAG,CACJ,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,GAAG,GAAG,IAAI,CAAC;IACb,CAAC;IACD,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACtB,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,QAAQ,CAAC,KAAwB,EAAE,IAAY,EAAE,KAAa;IACrE,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IACrD,OAAO,GAAG,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,EAAE,CAAC;AAC7C,CAAC"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * `matchRoute(url, items)`: finds the entry for a URL (see /next/routing and
3
+ * /next/router-internals).
4
+ *
5
+ * Paths compile into a segment trie, cached per array object: a lookup costs
6
+ * the URL's depth, not the number of routes. At every node the walk tries the
7
+ * literal child, then the parameter child, then a trailing `*` (a splat: one
8
+ * or more remaining segments), so exact paths win over parameters and
9
+ * parameters over a splat, per segment. Redirects are a second trie, checked
10
+ * first. Two entries that
11
+ * reach the same leaf are a conflict `deco check` reports; here the earlier
12
+ * one keeps it, so a lookup never throws. No regex, no sorting.
13
+ */
14
+ import type { Match, Redirect, Route } from "./types.ts";
15
+ export declare function matchRoute<T extends Route>(url: string | URL | Request, items: {
16
+ routes: T[];
17
+ redirects?: Redirect[];
18
+ }): Match<T>;
19
+ /**
20
+ * The entries that reach a leaf an earlier entry already holds: two equal
21
+ * paths, or two templates of one shape (`/:slug/p` and `/:id/p`). `matchRoute`
22
+ * serves the earlier one; `deco check` reports each pair.
23
+ */
24
+ export declare function findRouteConflicts<T extends {
25
+ path: string;
26
+ }>(entries: readonly T[]): {
27
+ entry: T;
28
+ other: T;
29
+ }[];
30
+ //# sourceMappingURL=matchRoute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matchRoute.d.ts","sourceRoot":"","sources":["../../src/v8/matchRoute.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAkB,KAAK,EAAE,QAAQ,EAAkB,KAAK,EAAE,MAAM,YAAY,CAAC;AAiBzF,wBAAgB,UAAU,CAAC,CAAC,SAAS,KAAK,EACxC,GAAG,EAAE,MAAM,GAAG,GAAG,GAAG,OAAO,EAC3B,KAAK,EAAE;IAAE,MAAM,EAAE,CAAC,EAAE,CAAC;IAAC,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAA;CAAE,GAC7C,KAAK,CAAC,CAAC,CAAC,CAwBV;AAsED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,OAAO,EAAE,SAAS,CAAC,EAAE;WAExD,CAAC;WAAS,CAAC;IAMtC"}
@@ -0,0 +1,175 @@
1
+ const routeTries = new WeakMap();
2
+ const redirectTries = new WeakMap();
3
+ const STATUSES = new Set([301, 302, 307, 308]);
4
+ export function matchRoute(url, items) {
5
+ const target = parseTarget(url);
6
+ if (target === null)
7
+ return { kind: "not-found" };
8
+ const redirects = Array.isArray(items?.redirects) ? items.redirects : [];
9
+ const redirectTrie = cached(redirectTries, redirects, () => redirects.flatMap((input) => {
10
+ const r = normalizeRedirect(input);
11
+ return r ? [[r.from, r]] : [];
12
+ }));
13
+ const redirect = lookup(redirectTrie, target.segments);
14
+ if (redirect !== null) {
15
+ const location = buildLocation(redirect, target.search);
16
+ return { kind: "redirect", location, status: redirect.value.status };
17
+ }
18
+ const routes = Array.isArray(items?.routes) ? items.routes : [];
19
+ const trie = cached(routeTries, routes, () => routes.filter((r) => typeof r?.path === "string").map((r) => [r.path, r]));
20
+ const found = lookup(trie, target.segments);
21
+ if (found === null)
22
+ return { kind: "not-found" };
23
+ return { kind: "match", entry: found.value, params: found.params };
24
+ }
25
+ /** The URL's path segments (percent-decoded) and its query string, with its `?`, or `""`. */
26
+ function parseTarget(url) {
27
+ try {
28
+ const raw = typeof url === "string" ? url : url instanceof URL ? url.href : url.url;
29
+ // A bare path stays a path: `//summer` is not a host named "summer".
30
+ const parsed = raw.startsWith("/") ? new URL(raw, "http://path.invalid") : new URL(raw);
31
+ const pathname = raw.startsWith("/") ? raw : parsed.pathname;
32
+ return { segments: splitPath(pathname).map(safeDecode), search: parsed.search };
33
+ }
34
+ catch {
35
+ return null;
36
+ }
37
+ }
38
+ /** `/a/b/`, `/a//b` and `/a/b?x` all name `["a", "b"]`; `/` names `[]`. */
39
+ function splitPath(path) {
40
+ const query = path.indexOf("?");
41
+ const hash = path.indexOf("#");
42
+ const end = Math.min(query === -1 ? path.length : query, hash === -1 ? path.length : hash);
43
+ return path
44
+ .slice(0, end)
45
+ .split("/")
46
+ .filter((segment) => segment.length > 0);
47
+ }
48
+ function safeDecode(segment) {
49
+ try {
50
+ return decodeURIComponent(segment);
51
+ }
52
+ catch {
53
+ return segment;
54
+ }
55
+ }
56
+ /** The trie for an array, built once per array object. */
57
+ function cached(cache, key, entries) {
58
+ const hit = cache.get(key);
59
+ if (hit)
60
+ return hit;
61
+ const root = { literals: new Map() };
62
+ for (const [path, value] of entries())
63
+ insert(root, path, value);
64
+ cache.set(key, root);
65
+ return root;
66
+ }
67
+ /** Adds `path`; returns the value already holding its leaf (a conflict: the earlier keeps it). */
68
+ function insert(root, path, value) {
69
+ const names = [];
70
+ const segments = splitPath(path);
71
+ let node = root;
72
+ for (const [i, segment] of segments.entries()) {
73
+ if (segment === "*" && i === segments.length - 1) {
74
+ if (node.splat)
75
+ return node.splat.value;
76
+ node.splat = { value, names };
77
+ return undefined;
78
+ }
79
+ if (segment.startsWith(":") && segment.length > 1) {
80
+ names.push(segment.slice(1));
81
+ node = node.param ??= { literals: new Map() };
82
+ continue;
83
+ }
84
+ const literal = safeDecode(segment);
85
+ const child = node.literals.get(literal) ?? { literals: new Map() };
86
+ node.literals.set(literal, child);
87
+ node = child;
88
+ }
89
+ if (node.leaf)
90
+ return node.leaf.value;
91
+ node.leaf = { value, names };
92
+ return undefined;
93
+ }
94
+ /**
95
+ * The entries that reach a leaf an earlier entry already holds: two equal
96
+ * paths, or two templates of one shape (`/:slug/p` and `/:id/p`). `matchRoute`
97
+ * serves the earlier one; `deco check` reports each pair.
98
+ */
99
+ export function findRouteConflicts(entries) {
100
+ const root = { literals: new Map() };
101
+ const conflicts = [];
102
+ for (const entry of entries) {
103
+ const other = insert(root, entry.path, entry);
104
+ if (other !== undefined)
105
+ conflicts.push({ entry, other });
106
+ }
107
+ return conflicts;
108
+ }
109
+ /** Walks the URL's segments: the literal child first, then the parameter child, then the splat. */
110
+ function lookup(node, segs, i = 0, vals = []) {
111
+ if (i === segs.length)
112
+ return node.leaf ? hit(node.leaf, vals, []) : null;
113
+ const literal = node.literals.get(segs[i]);
114
+ let found = literal ? lookup(literal, segs, i + 1, vals) : null;
115
+ // A parameter is one segment and never contains a slash, even an encoded one.
116
+ if (!found && node.param && !segs[i].includes("/")) {
117
+ found = lookup(node.param, segs, i + 1, [...vals, segs[i]]);
118
+ }
119
+ // A splat takes the rest (at least one segment, as there is one here).
120
+ return found ?? (node.splat ? hit(node.splat, vals, segs.slice(i)) : null);
121
+ }
122
+ function hit({ value, names }, values, rest) {
123
+ const params = Object.fromEntries(names.map((n, i) => [n, values[i]]));
124
+ if (rest.length > 0)
125
+ params["*"] = rest.join("/");
126
+ return { value, params, rest };
127
+ }
128
+ /**
129
+ * Both redirect shapes: the flat built-in `{ from, to, permanent, status?,
130
+ * discardQueryParameters? }` and the site editor's legacy nested
131
+ * `{ redirect: { from, to, type } }` (see /next/studio-compatibility), where
132
+ * `permanent` is a 301 and anything else a 307.
133
+ */
134
+ function normalizeRedirect(input) {
135
+ if (typeof input !== "object" || input === null)
136
+ return null;
137
+ const nested = input.redirect;
138
+ const flat = (nested ?? input);
139
+ if (typeof flat.from !== "string" || typeof flat.to !== "string")
140
+ return null;
141
+ let status = flat.permanent === true ? 301 : 302;
142
+ if (nested)
143
+ status = flat.type === "permanent" ? 301 : 307;
144
+ else if (STATUSES.has(flat.status))
145
+ status = flat.status;
146
+ const { from, to, discardQueryParameters } = flat;
147
+ return { from, to, permanent: status === 301 || status === 308, status, discardQueryParameters };
148
+ }
149
+ /**
150
+ * Fills the redirect's `:name` segments with the parameters `from` captured,
151
+ * and a `*` segment with the splat's segments, then carries the request's
152
+ * query string over unless the redirect discards it. Each captured segment is
153
+ * re-encoded on its own and none is empty, so a `to` on this site can't turn
154
+ * into `//other.host` (or `/\other.host`).
155
+ */
156
+ function buildLocation({ value: redirect, params, rest }, search) {
157
+ const { to } = redirect;
158
+ const hashAt = to.indexOf("#") === -1 ? to.length : to.indexOf("#");
159
+ const queryAt = to.indexOf("?") === -1 || to.indexOf("?") > hashAt ? hashAt : to.indexOf("?");
160
+ const filled = to
161
+ .slice(0, queryAt)
162
+ .split("/")
163
+ .map((s) => {
164
+ if (s === "*" && rest.length > 0)
165
+ return rest.map(encodeURIComponent).join("/");
166
+ return Object.hasOwn(params, s.slice(1)) && s[0] === ":"
167
+ ? encodeURIComponent(params[s.slice(1)])
168
+ : s;
169
+ })
170
+ .join("/");
171
+ const carried = redirect.discardQueryParameters ? "" : search.slice(1);
172
+ const query = [to.slice(queryAt + 1, hashAt), carried].filter(Boolean).join("&");
173
+ return `${filled}${query ? `?${query}` : ""}${to.slice(hashAt)}`;
174
+ }
175
+ //# sourceMappingURL=matchRoute.js.map