@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
@@ -1,121 +0,0 @@
1
- "use client";
2
-
3
- /**
4
- * LazySection -- Intersection Observer-based deferred rendering.
5
- *
6
- * Wraps section content and defers rendering until the element scrolls
7
- * into view. Uses IntersectionObserver for zero-JS-cost detection and
8
- * renders a lightweight placeholder until the content is needed.
9
- *
10
- * For SSR: the placeholder is rendered server-side. On hydration,
11
- * the observer is set up and content loads when visible.
12
- *
13
- * @example
14
- * ```tsx
15
- * <LazySection fallback={<div style={{ height: 400 }} />}>
16
- * <HeavyProductCarousel products={products} />
17
- * </LazySection>
18
- * ```
19
- *
20
- * `"use client"` added by Phase 2 Task 9 (@decocms/nextjs's next-smoke
21
- * fixture): this file uses `useEffect`/`useRef`/`useState`, which Next's App
22
- * Router statically rejects in any file reachable from a Server Component's
23
- * module graph unless the file itself declares the client boundary. Neither
24
- * `@decocms/tanstack` (Vite, no RSC directive enforcement) nor this
25
- * package's Vitest/jsdom unit tests caught this — `@decocms/nextjs` is the
26
- * first consumer to go through Next's real RSC-aware webpack build.
27
- */
28
-
29
- import { type ReactNode, useEffect, useRef, useState } from "react";
30
-
31
- export interface LazySectionProps {
32
- children: ReactNode;
33
- /**
34
- * Content shown before the section scrolls into view.
35
- * Should have a fixed height to prevent layout shifts.
36
- */
37
- fallback?: ReactNode;
38
- /**
39
- * IntersectionObserver rootMargin.
40
- * Positive values trigger loading before the element is visible.
41
- * @default "200px"
42
- */
43
- rootMargin?: string;
44
- /**
45
- * Minimum height for the wrapper div (prevents CLS).
46
- * Applied as CSS min-height.
47
- */
48
- minHeight?: string | number;
49
- /**
50
- * CSS class for the wrapper div.
51
- */
52
- className?: string;
53
- /**
54
- * If true, render the content immediately (bypass lazy loading).
55
- * Useful for sections above the fold.
56
- * @default false
57
- */
58
- eager?: boolean;
59
- }
60
-
61
- export function LazySection({
62
- children,
63
- fallback,
64
- rootMargin = "200px",
65
- minHeight,
66
- className,
67
- eager = false,
68
- }: LazySectionProps) {
69
- const [isVisible, setVisible] = useState(eager);
70
- const ref = useRef<HTMLDivElement>(null);
71
-
72
- useEffect(() => {
73
- if (eager || isVisible) return;
74
-
75
- const element = ref.current;
76
- if (!element) return;
77
-
78
- if (typeof IntersectionObserver === "undefined") {
79
- setVisible(true);
80
- return;
81
- }
82
-
83
- const observer = new IntersectionObserver(
84
- ([entry]) => {
85
- if (entry?.isIntersecting) {
86
- setVisible(true);
87
- observer.disconnect();
88
- }
89
- },
90
- { rootMargin },
91
- );
92
-
93
- observer.observe(element);
94
- return () => observer.disconnect();
95
- }, [eager, isVisible, rootMargin]);
96
-
97
- const style: React.CSSProperties | undefined = minHeight
98
- ? { minHeight: typeof minHeight === "number" ? `${minHeight}px` : minHeight }
99
- : undefined;
100
-
101
- return (
102
- <div ref={ref} className={className} style={style}>
103
- {isVisible ? children : (fallback ?? null)}
104
- </div>
105
- );
106
- }
107
-
108
- /**
109
- * Determine if a section index is "below the fold" and should be lazy-loaded.
110
- *
111
- * Used by DecoPageRenderer to auto-wrap distant sections.
112
- *
113
- * @param index - Zero-based section index on the page
114
- * @param foldThreshold - Sections at or above this index are below the fold.
115
- * Defaults to `Infinity` (nothing below the fold), matching the framework
116
- * default where the admin ⚡ toggle — not position — drives deferral.
117
- * @default foldThreshold = Infinity
118
- */
119
- export function isBelowFold(index: number, foldThreshold = Infinity): boolean {
120
- return index >= foldThreshold;
121
- }
@@ -1,144 +0,0 @@
1
- "use client";
2
-
3
- import React, { useEffect } from "react";
4
- import { getRequestNonce } from "../sdk/nonce";
5
-
6
- interface LiveControlsProps {
7
- site?: string;
8
- page?: { id?: string; pathTemplate?: string };
9
- flags?: any[];
10
- }
11
-
12
- /**
13
- * LiveControls bridges the deco admin (parent window) with the storefront (iframe).
14
- *
15
- * Mirrors production behavior (apps/website/components/_Controls.tsx):
16
- * 1. Injects __DECO_STATE for the admin to read
17
- * 2. Listens for postMessage events from the admin (inject scripts, scroll, rerender)
18
- * 3. "." opens admin in same tab, Ctrl/Cmd+"." opens in new tab, Ctrl+Shift+E also works
19
- */
20
- export function LiveControls({ site, page, flags }: LiveControlsProps) {
21
- // Keep `window.LIVE.page` in sync with the CURRENT page across SPA
22
- // navigations. The bootstrap script below reads __DECO_STATE only once (on
23
- // initial load), so without this effect a client-side navigation would leave
24
- // window.LIVE.page pointing at the first page rendered — and the "." shortcut
25
- // would send that page's pathTemplate/id (or the "/*" fallback) instead of the
26
- // route the user is actually looking at.
27
- useEffect(() => {
28
- if (typeof window === "undefined") return;
29
- const w = window as unknown as { LIVE?: Record<string, unknown> };
30
- w.LIVE = w.LIVE || {};
31
- w.LIVE.page = page || {};
32
- w.LIVE.site = { name: site || "storefront" };
33
- // eslint-disable-next-line react-hooks/exhaustive-deps
34
- }, [site, page?.id, page?.pathTemplate]);
35
-
36
- return (
37
- <>
38
- <script
39
- id="__DECO_STATE"
40
- type="application/json"
41
- dangerouslySetInnerHTML={{
42
- __html: JSON.stringify({
43
- page: page || {},
44
- site: { name: site || "storefront" },
45
- flags: flags || [],
46
- }),
47
- }}
48
- />
49
- <LiveControlsScript />
50
- </>
51
- );
52
- }
53
-
54
- function LiveControlsScript() {
55
- const script = `
56
- (function() {
57
- if (window.__DECO_LIVE_CONTROLS__) return;
58
- window.__DECO_LIVE_CONTROLS__ = true;
59
-
60
- var TRUSTED_ORIGINS = ["https://deco.cx", "https://admin.deco.cx", "https://play.deco.cx", "https://decocms.com", "https://studio.decocms.com"];
61
- function isTrustedOrigin(origin) {
62
- return TRUSTED_ORIGINS.indexOf(origin) !== -1 ||
63
- (origin.startsWith("https://") && origin.endsWith(".deco.cx")) ||
64
- (origin.startsWith("https://") && origin.endsWith(".decocms.com")) ||
65
- origin === window.location.origin;
66
- }
67
-
68
- var LIVE = JSON.parse(document.getElementById("__DECO_STATE")?.textContent || "{}");
69
- window.LIVE = { ...window.LIVE, ...LIVE };
70
-
71
- window.addEventListener("message", function(event) {
72
- if (!isTrustedOrigin(event.origin)) return;
73
-
74
- var data = event.data;
75
- if (!data || typeof data !== "object") return;
76
-
77
- switch (data.type) {
78
- case "editor::inject":
79
- if (data.args && data.args.script) {
80
- try { eval(data.args.script); } catch(e) { console.error("[deco] inject error:", e); }
81
- }
82
- break;
83
-
84
- case "scrollToComponent":
85
- var el = document.querySelector('[data-manifest-key="' + CSS.escape(data.args?.id || "") + '"]');
86
- if (!el) el = document.getElementById(data.args?.id);
87
- if (el) el.scrollIntoView({ behavior: "smooth", block: "center" });
88
- break;
89
-
90
- case "DOMInspector":
91
- break;
92
-
93
- case "editor::rerender":
94
- if (data.args?.url) {
95
- try {
96
- var targetUrl = new URL(data.args.url, window.location.origin);
97
- if (targetUrl.origin === window.location.origin) {
98
- window.location.href = targetUrl.href;
99
- }
100
- } catch(e) {}
101
- }
102
- break;
103
- }
104
- });
105
-
106
- if (window.self === window.top) {
107
- document.addEventListener("keydown", function(e) {
108
- var t = e.target;
109
- if (t && (t.tagName === "INPUT" || t.tagName === "TEXTAREA" || t.tagName === "SELECT" || t.isContentEditable)) return;
110
- if (e.defaultPrevented) return;
111
-
112
- if (
113
- (e.ctrlKey && e.shiftKey && e.key === "E") ||
114
- e.key === "."
115
- ) {
116
- e.preventDefault();
117
- e.stopPropagation();
118
-
119
- var siteName = (window.LIVE.site && window.LIVE.site.name) || window.LIVE.site || "storefront";
120
- var pageId = (window.LIVE.page && window.LIVE.page.id) || "";
121
- var pathTemplate = (window.LIVE.page && window.LIVE.page.pathTemplate) || "/*";
122
-
123
- var href = new URL("/choose-editor", "https://studio.decocms.com");
124
- href.searchParams.set("site", siteName);
125
- href.searchParams.set("domain", window.location.origin);
126
- if (pageId) href.searchParams.set("pageId", pageId);
127
- href.searchParams.set("path", window.location.pathname + window.location.search);
128
- href.searchParams.set("pathTemplate", pathTemplate);
129
-
130
- if ((e.ctrlKey || e.metaKey) && e.key === ".") {
131
- window.open(href.toString(), "_blank");
132
- return;
133
- }
134
- window.location.href = href.toString();
135
- }
136
- });
137
- }
138
- })();
139
- `;
140
-
141
- return (
142
- <script type="module" nonce={getRequestNonce()} dangerouslySetInnerHTML={{ __html: script }} />
143
- );
144
- }
@@ -1,127 +0,0 @@
1
- "use client";
2
-
3
- // `"use client"` added by @decocms/nextjs's next-smoke fixture build
4
- // (Picture is reachable from `DecoRootLayout`/`SectionRenderer` via the
5
- // `hooks/index.ts` barrel, so it is part of the react-server module graph
6
- // on any Next.js Server Component page even when a given page never
7
- // renders it): `createContext`/`useContext` are unavailable under React's
8
- // react-server condition, and Next statically flags any reachable module
9
- // that imports them without this directive ("You're importing a component
10
- // that needs createContext...") — same class of fix, same precedent, as
11
- // `SectionErrorFallback.tsx`'s `"use client"` (class component /
12
- // componentDidCatch, also client-only).
13
- import {
14
- type ComponentPropsWithoutRef,
15
- type Context,
16
- createContext,
17
- forwardRef,
18
- type ReactNode,
19
- useContext,
20
- useMemo,
21
- } from "react";
22
- import { type FitOptions, getOptimizedMediaUrl, getSrcSet } from "./Image";
23
-
24
- // -------------------------------------------------------------------------
25
- // Preload context — flows from <Picture preload> to child <Source> elements
26
- // so each source can inject its own <link rel="preload"> with the correct
27
- // media query for responsive art direction.
28
- //
29
- // Still created LAZILY (first render, not module scope) even under
30
- // `"use client"`: this keeps a single memoized context object regardless of
31
- // how many client bundle chunks end up importing this module, rather than
32
- // relying on module-instance identity across chunks.
33
- // -------------------------------------------------------------------------
34
-
35
- interface PreloadContextValue {
36
- preload: boolean;
37
- }
38
-
39
- let _preloadContext: Context<PreloadContextValue> | null = null;
40
- function getPreloadContext(): Context<PreloadContextValue> {
41
- _preloadContext ??= createContext<PreloadContextValue>({ preload: false });
42
- return _preloadContext;
43
- }
44
-
45
- // -------------------------------------------------------------------------
46
- // Source — composable <source> with automatic srcSet optimization and
47
- // preload link injection when inside a <Picture preload>.
48
- // -------------------------------------------------------------------------
49
-
50
- export type SourceProps = Omit<ComponentPropsWithoutRef<"source">, "width" | "height"> & {
51
- src: string;
52
- /** @description Improves Web Vitals (CLS|LCP) */
53
- width: number;
54
- /** @description Improves Web Vitals (CLS|LCP) */
55
- height?: number;
56
- /** @description Improves Web Vitals (LCP). Use high for LCP image. */
57
- fetchPriority?: "high" | "low" | "auto";
58
- /** @description Object-fit */
59
- fit?: FitOptions;
60
- };
61
-
62
- export const Source = forwardRef<HTMLSourceElement, SourceProps>(function Source(
63
- { src, width, height, fetchPriority, fit = "cover", ...rest },
64
- ref,
65
- ) {
66
- const { preload } = useContext(getPreloadContext());
67
-
68
- const optimizedSrc = getOptimizedMediaUrl({
69
- originalSrc: src,
70
- width,
71
- height,
72
- fit,
73
- });
74
- const srcSet = rest.srcSet ?? getSrcSet(src, width, height, fit);
75
-
76
- return (
77
- <>
78
- {preload && (
79
- <link
80
- as="image"
81
- rel="preload"
82
- href={optimizedSrc}
83
- imageSrcSet={srcSet}
84
- fetchPriority={fetchPriority ?? "high"}
85
- media={rest.media}
86
- />
87
- )}
88
- <source {...rest} srcSet={srcSet ?? optimizedSrc} width={width} height={height} ref={ref} />
89
- </>
90
- );
91
- });
92
-
93
- // -------------------------------------------------------------------------
94
- // Picture — composable wrapper that provides preload context to children.
95
- //
96
- // Usage:
97
- // <Picture preload={isLcp}>
98
- // <Source media="(max-width: 767px)" src={mobile} width={320} height={280} />
99
- // <Source media="(min-width: 768px)" src={desktop} width={1280} height={280} />
100
- // <Image src={desktop} width={1280} height={280} />
101
- // </Picture>
102
- // -------------------------------------------------------------------------
103
-
104
- export type PictureProps = ComponentPropsWithoutRef<"picture"> & {
105
- children: ReactNode;
106
- /**
107
- * @description When true, child <Source> and <Image> elements inject
108
- * `<link rel="preload">` tags for their respective media queries.
109
- */
110
- preload?: boolean;
111
- };
112
-
113
- export const Picture = forwardRef<HTMLPictureElement, PictureProps>(function Picture(
114
- { children, preload = false, ...props },
115
- ref,
116
- ) {
117
- const value = useMemo(() => ({ preload }), [preload]);
118
- const PreloadContext = getPreloadContext();
119
-
120
- return (
121
- <PreloadContext.Provider value={value}>
122
- <picture {...props} ref={ref}>
123
- {children}
124
- </picture>
125
- </PreloadContext.Provider>
126
- );
127
- });
@@ -1,91 +0,0 @@
1
- import { type ComponentType, lazy, Suspense } from "react";
2
- import { getSection, getSyncComponent } from "../cms/registry";
3
-
4
- const componentCache = new Map<string, ComponentType<any>>();
5
-
6
- function getOrCreateLazy(resolveType: string): ComponentType<any> | null {
7
- if (componentCache.has(resolveType)) {
8
- return componentCache.get(resolveType)!;
9
- }
10
-
11
- const loader = getSection(resolveType);
12
- if (!loader) return null;
13
-
14
- const LazyComponent = lazy(async () => {
15
- const mod = await loader();
16
- return { default: mod.default };
17
- });
18
-
19
- componentCache.set(resolveType, LazyComponent);
20
- return LazyComponent;
21
- }
22
-
23
- interface SectionLike {
24
- __resolveType?: string;
25
- Component?: ComponentType<any>;
26
- props?: Record<string, unknown>;
27
- [key: string]: unknown;
28
- }
29
-
30
- /**
31
- * Renders a Section-type prop from the CMS.
32
- *
33
- * Handles both the old Deco format ({ Component, props }) and
34
- * the new @decocms/start format ({ __resolveType, ...props }).
35
- *
36
- * Sync-first: sections registered as sync (`export const sync = true`,
37
- * bundled in the main chunk) render DIRECTLY — no React.lazy / Suspense.
38
- * This mirrors DecoPageRenderer's sync-first path and matters twice:
39
- *
40
- * - SSR streaming: React 19 omits the `<!--$-->` markers when a Suspense
41
- * boundary resolves synchronously, which triggers a hydration mismatch
42
- * (minified #418) — same reason DecoPageRenderer bifurcates.
43
- * - SPA commit: the lazy path suspends with `fallback ?? null` while the
44
- * section chunk loads, so a route commit that renders content through
45
- * RenderSection (e.g. a gate section like NotFoundChallenge) paints the
46
- * page with a BLANK middle until the chunk resolves.
47
- *
48
- * Sites without registered sync components are unaffected:
49
- * `getSyncComponent()` returns undefined and the lazy path runs as before.
50
- */
51
- export default function RenderSection({
52
- section,
53
- fallback,
54
- }: {
55
- section: SectionLike | null | undefined;
56
- fallback?: React.ReactNode;
57
- }) {
58
- if (!section) return null;
59
-
60
- if (section.Component) {
61
- const { Component, props = {}, ...overrides } = section;
62
- const mergedProps = { ...(props as Record<string, unknown>), ...overrides };
63
- if (typeof Component === "string") {
64
- const Sync = getSyncComponent(Component);
65
- if (Sync) return <Sync {...mergedProps} />;
66
- const Comp = getOrCreateLazy(Component);
67
- if (!Comp) return <>{fallback ?? null}</>;
68
- return (
69
- <Suspense fallback={fallback ?? null}>
70
- <Comp {...mergedProps} />
71
- </Suspense>
72
- );
73
- }
74
- return <Component {...mergedProps} />;
75
- }
76
-
77
- if (section.__resolveType) {
78
- const { __resolveType: _, ...props } = section;
79
- const Sync = getSyncComponent(section.__resolveType);
80
- if (Sync) return <Sync {...props} />;
81
- const Comp = getOrCreateLazy(section.__resolveType);
82
- if (!Comp) return <>{fallback ?? null}</>;
83
- return (
84
- <Suspense fallback={fallback ?? null}>
85
- <Comp {...props} />
86
- </Suspense>
87
- );
88
- }
89
-
90
- return null;
91
- }
@@ -1,97 +0,0 @@
1
- "use client";
2
-
3
- // `"use client"` added by Phase 2 Task 9 (@decocms/nextjs's next-smoke
4
- // fixture): `SectionErrorBoundary` is a class component with
5
- // `componentDidCatch`/`getDerivedStateFromError` — error boundaries require
6
- // a Client Component in Next's App Router. `SectionRenderer.tsx` wraps
7
- // every rendered section in this boundary, so without the directive, any
8
- // Server Component that ends up importing `@decocms/blocks/hooks`
9
- // transitively fails Next's build. Server Component children passed via
10
- // `props.children` still render fine — passing already-rendered Server
11
- // Component output into a Client Component's `children` is a supported RSC
12
- // composition pattern.
13
- import { Component, type ErrorInfo, type ReactNode } from "react";
14
-
15
- interface ErrorBoundaryProps {
16
- sectionKey: string;
17
- fallback?: ReactNode;
18
- children: ReactNode;
19
- }
20
-
21
- interface ErrorBoundaryState {
22
- error: Error | null;
23
- }
24
-
25
- /**
26
- * Per-section error boundary that prevents a single broken section
27
- * from crashing the entire page.
28
- *
29
- * In development, shows the error message + stack trace.
30
- * In production, renders a silent empty placeholder.
31
- */
32
- export class SectionErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
33
- constructor(props: ErrorBoundaryProps) {
34
- super(props);
35
- this.state = { error: null };
36
- }
37
-
38
- static getDerivedStateFromError(error: Error): ErrorBoundaryState {
39
- return { error };
40
- }
41
-
42
- componentDidCatch(error: Error, info: ErrorInfo) {
43
- console.error(`[CMS] Section "${this.props.sectionKey}" crashed:`, error, info.componentStack);
44
- }
45
-
46
- render() {
47
- if (this.state.error) {
48
- if (this.props.fallback) return this.props.fallback;
49
- return (
50
- <DefaultSectionErrorFallback error={this.state.error} sectionKey={this.props.sectionKey} />
51
- );
52
- }
53
- return this.props.children;
54
- }
55
- }
56
-
57
- function DefaultSectionErrorFallback({ error, sectionKey }: { error: Error; sectionKey: string }) {
58
- const isDev = typeof process !== "undefined" && process.env.NODE_ENV === "development";
59
-
60
- if (!isDev) {
61
- return <div data-section-error={sectionKey} className="hidden" />;
62
- }
63
-
64
- return (
65
- <div
66
- data-section-error={sectionKey}
67
- style={{
68
- padding: "16px",
69
- margin: "8px 0",
70
- border: "2px solid #ef4444",
71
- borderRadius: "8px",
72
- background: "#fef2f2",
73
- fontFamily: "monospace",
74
- fontSize: "13px",
75
- }}
76
- >
77
- <div style={{ fontWeight: "bold", color: "#dc2626", marginBottom: "8px" }}>
78
- Section Error: {sectionKey}
79
- </div>
80
- <div style={{ color: "#991b1b" }}>{error.message}</div>
81
- {error.stack && (
82
- <pre
83
- style={{
84
- marginTop: "8px",
85
- fontSize: "11px",
86
- color: "#6b7280",
87
- whiteSpace: "pre-wrap",
88
- overflow: "auto",
89
- maxHeight: "200px",
90
- }}
91
- >
92
- {error.stack}
93
- </pre>
94
- )}
95
- </div>
96
- );
97
- }