@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,314 +0,0 @@
1
- import type { ImgHTMLAttributes } from "react";
2
- import { forwardRef } from "react";
3
-
4
- // -------------------------------------------------------------------------
5
- // Known asset prefixes that get stripped to produce a relative src path
6
- // -------------------------------------------------------------------------
7
-
8
- // Anchored: only a leading host is stripped.
9
- const DECO_ASSET_PREFIX_RE =
10
- /^https:\/\/(?:assets\.decocache\.com|deco-sites-assets\.s3\.sa-east-1\.amazonaws\.com)\//;
11
- // decoims.com — the legacy default image CDN (pre-#495). Decofiles are full of
12
- // these URLs; passing one as `src=` to a Cloudflare Deco CDN makes it fetch
13
- // itself → 508 Loop Detected. Azion CDNs (edgedeco/decoazn) fetch it fine but
14
- // may 404 on the relative path, so only strip it for the Cloudflare ones.
15
- const DECOIMS_PREFIX_RE = /^https:\/\/decoims\.com\//;
16
- const CLOUDFLARE_CDNS = new Set(["assets.decocms.com", "decoims.com"]);
17
-
18
- // -------------------------------------------------------------------------
19
- // Configurable CDN domain
20
- // -------------------------------------------------------------------------
21
-
22
- let imageCdnDomain = "assets.decocms.com";
23
-
24
- /**
25
- * Register the image CDN domain used by `getOptimizedMediaUrl`.
26
- * Call once in your site's setup.ts before any page loads.
27
- *
28
- * Available domains:
29
- * - `assets.decocms.com` (Cloudflare, default — best compression, same edge as Workers)
30
- * - `deco-assets.edgedeco.com` (Azion IMS)
31
- * - `deco-assets.decoazn.com` (Azion IMS, legacy)
32
- */
33
- export function registerImageCdnDomain(domain: string) {
34
- imageCdnDomain = domain.replace(/^https?:\/\//, "").replace(/\/+$/, "");
35
- }
36
-
37
- export function getImageCdnDomain(): string {
38
- return imageCdnDomain;
39
- }
40
-
41
- // -------------------------------------------------------------------------
42
- // Configurable image quality
43
- // -------------------------------------------------------------------------
44
-
45
- /**
46
- * Quality levels the Deco image CDN accepts as a site-wide default.
47
- *
48
- * The CDN maps these to 60% / 70% / 80%. It also accepts `original` (100%),
49
- * deliberately excluded here: a global 100% default hurts performance on
50
- * every page, which is the same call `DefaultQualityOptions` makes in the
51
- * Fresh implementation this file was ported from (deco-cx/apps,
52
- * website/components/Image.tsx).
53
- *
54
- * A union rather than `string` because the CDN **fails silently** on
55
- * anything else: it answers 200 and serves its 60% default. So the obvious
56
- * `registerImageQuality("80")` — quality means 1-100 in Cloudflare Images,
57
- * next/image and imgix — would quietly serve the LOWEST quality while
58
- * changing the cache key on every image. Measured against production
59
- * decoims.com on one asset: no param 2911 B, `low` 2911, `medium` 3235,
60
- * `high` 5189, and `"80"` / `"HIGH"` / garbage all 2911.
61
- */
62
- export type ImageQuality = "low" | "medium" | "high";
63
-
64
- let imageQuality: ImageQuality | undefined;
65
-
66
- /**
67
- * Register the quality level `getOptimizedMediaUrl` asks the image CDN for.
68
- *
69
- * Call once at module scope in your site's setup, NOT from a loader, action or
70
- * anything else on the request path. This is module-level state shared by every
71
- * request in a Worker isolate: setting it per-request would leak across
72
- * concurrent requests, and setting it on only one of the SSR/hydration paths
73
- * would produce mismatched `src`/`srcSet` and re-download every image.
74
- *
75
- * Unset by default, which emits no `quality` param and leaves the CDN on its
76
- * 60% default — so existing sites are byte-for-byte unaffected and no CDN
77
- * cache is invalidated. Set it when a site's art direction needs fidelity over
78
- * bytes: on fashion/editorial catalogues the default compression visibly
79
- * softens fabric texture and print detail.
80
- *
81
- * Applies to every URL built by `getOptimizedMediaUrl` — `Image`, `getSrcSet`
82
- * and also `Video` when it is given `forceOptimizedSrc`. It does NOT apply to
83
- * VTEX- or Shopify-hosted sources: those are resized through their own native
84
- * URL syntax (`optimizeVTEX` / `optimizeShopify`), which returns before the
85
- * query-param block. On a VTEX storefront that means product imagery is
86
- * untouched and only CMS/banner assets are affected.
87
- */
88
- export function registerImageQuality(quality: ImageQuality | undefined) {
89
- imageQuality = quality || undefined;
90
- }
91
-
92
- export function getImageQuality(): ImageQuality | undefined {
93
- return imageQuality;
94
- }
95
-
96
- // -------------------------------------------------------------------------
97
- // Fit options & optimization types
98
- // -------------------------------------------------------------------------
99
-
100
- export type FitOptions = "contain" | "cover" | "fill";
101
-
102
- export const FACTORS = [1, 2];
103
-
104
- interface OptimizationOptions {
105
- originalSrc: string;
106
- width: number;
107
- height?: number;
108
- fit: FitOptions;
109
- }
110
-
111
- // -------------------------------------------------------------------------
112
- // Platform-specific URL optimizers (fallbacks when the CDN can handle
113
- // the native platform's resize syntax directly)
114
- // -------------------------------------------------------------------------
115
-
116
- function optimizeVTEX(originalSrc: string, width: number, height?: number): string {
117
- const src = new URL(originalSrc);
118
- const [slash, arquivos, ids, rawId, ...rest] = src.pathname.split("/");
119
- const [trueId] = rawId.split("-");
120
-
121
- src.pathname = [slash, arquivos, ids, `${trueId}-${width}-${height ?? width}`, ...rest].join("/");
122
-
123
- return src.href;
124
- }
125
-
126
- function optimizeShopify(originalSrc: string, width: number, height?: number): string {
127
- const url = new URL(originalSrc);
128
- url.searchParams.set("width", `${width}`);
129
- if (height) url.searchParams.set("height", `${height}`);
130
- url.searchParams.set("crop", "center");
131
- return url.href;
132
- }
133
-
134
- // -------------------------------------------------------------------------
135
- // Core optimization function
136
- // Ported from deco-cx/apps website/components/Image.tsx
137
- // -------------------------------------------------------------------------
138
-
139
- /**
140
- * Builds an optimized image URL.
141
- *
142
- * For Deco-hosted images (decocache / S3 / decoims), strips the known prefix and
143
- * routes through the Deco image CDN for edge resize + format conversion.
144
- *
145
- * For platform-specific images (VTEX, Shopify), rewrites the URL using
146
- * the platform's native resize params — no CDN proxy needed.
147
- *
148
- * Data URIs are returned as-is.
149
- */
150
- export function getOptimizedMediaUrl(opts: OptimizationOptions): string {
151
- const { originalSrc, width, height, fit } = opts;
152
-
153
- // Defensive: an upstream CMS payload occasionally has missing/null image
154
- // fields. Crashing the entire React tree on `undefined.startsWith` would
155
- // take down the whole page. Return an empty string so the resulting
156
- // `<img>` is rendered with no src — the browser shows the broken-image
157
- // placeholder and SSR completes cleanly.
158
- if (typeof originalSrc !== "string" || originalSrc.length === 0) {
159
- if (typeof process !== "undefined" && process.env?.NODE_ENV !== "production") {
160
- console.warn(
161
- `[Image] getOptimizedMediaUrl called with empty/undefined src — rendering empty src instead of crashing.`,
162
- );
163
- }
164
- return "";
165
- }
166
-
167
- if (originalSrc.startsWith("data:")) {
168
- return originalSrc;
169
- }
170
-
171
- if (/(vteximg\.com\.br|vtexassets\.com|myvtex\.com)\/arquivos\/ids\/\d+/.test(originalSrc)) {
172
- return optimizeVTEX(originalSrc, width, height);
173
- }
174
-
175
- if (originalSrc.startsWith("https://cdn.shopify.com")) {
176
- return optimizeShopify(originalSrc, width, height);
177
- }
178
-
179
- let imageSource = originalSrc.replace(DECO_ASSET_PREFIX_RE, "").split("?")[0];
180
- if (CLOUDFLARE_CDNS.has(imageCdnDomain)) imageSource = imageSource.replace(DECOIMS_PREFIX_RE, "");
181
-
182
- // Already on the image CDN — strip the host so we don't proxy through ourselves.
183
- const cdnPrefix = `https://${imageCdnDomain}/`;
184
- if (imageSource.startsWith(cdnPrefix)) {
185
- imageSource = imageSource.slice(cdnPrefix.length);
186
- }
187
-
188
- const params = new URLSearchParams();
189
- params.set("fit", fit);
190
- params.set("width", `${width}`);
191
- if (height) params.set("height", `${height}`);
192
- if (imageQuality) params.set("quality", imageQuality);
193
-
194
- return `https://${imageCdnDomain}/image?${params}&src=${imageSource}`;
195
- }
196
-
197
- /**
198
- * Generates a srcset string with responsive multipliers.
199
- */
200
- export function getSrcSet(
201
- originalSrc: string,
202
- width: number,
203
- height?: number,
204
- fit?: FitOptions,
205
- factors: number[] = FACTORS,
206
- ): string | undefined {
207
- if (typeof originalSrc !== "string" || originalSrc.length === 0) {
208
- return undefined;
209
- }
210
-
211
- const entries: string[] = [];
212
-
213
- for (const factor of factors) {
214
- const w = Math.trunc(factor * width);
215
- const h = height ? Math.trunc(factor * height) : undefined;
216
-
217
- const src = getOptimizedMediaUrl({
218
- originalSrc,
219
- width: w,
220
- height: h,
221
- fit: fit ?? "cover",
222
- });
223
-
224
- if (src) {
225
- entries.push(`${src} ${w}w`);
226
- }
227
- }
228
-
229
- return entries.length > 0 ? entries.join(", ") : undefined;
230
- }
231
-
232
- // -------------------------------------------------------------------------
233
- // Image component
234
- // -------------------------------------------------------------------------
235
-
236
- export interface ImageProps
237
- extends Omit<ImgHTMLAttributes<HTMLImageElement>, "src" | "width" | "height"> {
238
- src: string;
239
- /** @description Improves Web Vitals (CLS/LCP) */
240
- width: number;
241
- /** @description Improves Web Vitals (CLS/LCP) */
242
- height?: number;
243
- /** @description Object-fit */
244
- fit?: FitOptions;
245
- /**
246
- * @description Web Vitals (LCP). Injects a `<link rel="preload">` tag
247
- * alongside the `<img>`, sets `fetchPriority="high"` and `loading="eager"`.
248
- * Use once per page for the LCP image.
249
- */
250
- preload?: boolean;
251
- /** @description Media query for responsive preloading (e.g. "(min-width: 768px)") */
252
- media?: string;
253
- }
254
-
255
- export const Image = forwardRef<HTMLImageElement, ImageProps>(function Image(
256
- {
257
- src,
258
- width,
259
- height,
260
- fit = "cover",
261
- preload,
262
- media,
263
- loading,
264
- decoding,
265
- srcSet: srcSetProp,
266
- sizes,
267
- fetchPriority,
268
- ...rest
269
- },
270
- ref,
271
- ) {
272
- if (!height && typeof process !== "undefined") {
273
- console.warn(`Missing height. This image will NOT be optimized: ${src}`);
274
- }
275
-
276
- const optimizedSrc = getOptimizedMediaUrl({
277
- originalSrc: src,
278
- width,
279
- height,
280
- fit,
281
- });
282
- const srcSet = srcSetProp ?? getSrcSet(src, width, height, fit);
283
- const resolvedSizes = srcSet ? (sizes ?? "(max-width: 768px) 100vw, 50vw") : undefined;
284
-
285
- return (
286
- <>
287
- {preload && (
288
- <link
289
- as="image"
290
- rel="preload"
291
- href={optimizedSrc}
292
- imageSrcSet={srcSet}
293
- imageSizes={resolvedSizes}
294
- fetchPriority={fetchPriority ?? "high"}
295
- media={media}
296
- />
297
- )}
298
- <img
299
- {...rest}
300
- src={optimizedSrc}
301
- srcSet={srcSet}
302
- sizes={resolvedSizes}
303
- width={width}
304
- height={height}
305
- loading={loading ?? (preload ? "eager" : "lazy")}
306
- decoding={decoding ?? "async"}
307
- fetchPriority={preload ? "high" : fetchPriority}
308
- ref={ref}
309
- />
310
- </>
311
- );
312
- });
313
-
314
- export default Image;
@@ -1,353 +0,0 @@
1
- /**
2
- * SEO JSON-LD structured data components.
3
- *
4
- * Generates JSON-LD script tags for Product (PDP), ProductList (PLP),
5
- * and BreadcrumbList schemas. Compatible with Google's Rich Results
6
- * requirements.
7
- *
8
- * @example
9
- * ```tsx
10
- * import { ProductJsonLd, PLPJsonLd, BreadcrumbJsonLd } from "@decocms/blocks/hooks";
11
- *
12
- * // In a PDP route
13
- * <ProductJsonLd product={product} />
14
- *
15
- * // In a PLP route
16
- * <PLPJsonLd page={productListingPage} />
17
- *
18
- * // Anywhere with breadcrumbs
19
- * <BreadcrumbJsonLd breadcrumb={breadcrumbList} />
20
- * ```
21
- *
22
- * Type note: originally these components imported `Product`,
23
- * `ProductListingPage`, `BreadcrumbList`, etc. from apps-start's
24
- * commerce types module (now `@decocms/apps-commerce/types`).
25
- * `@decocms/blocks` must not depend on any `apps-*` package (one-way
26
- * dependency rule: `apps-*` depends on `blocks`, never the reverse), so
27
- * that import can't carry over as-is. Each function here only reads a
28
- * small, flat subset of the full schema.org Product/Offer/ListItem
29
- * graph (the original code already didn't fully trust the nominal
30
- * `Product.offers` type either — see the `as Offer[] | AggregateOffer`
31
- * casts it used). The types below are local, minimal, structural
32
- * equivalents of just that subset: any commerce `Product` /
33
- * `ProductListingPage` / `BreadcrumbList` value is a structural
34
- * superset and can be passed in directly without a cast.
35
- */
36
-
37
- // -------------------------------------------------------------------------
38
- // Minimal structural types (see file header for why these aren't imported
39
- // from @decocms/apps-commerce/types)
40
- // -------------------------------------------------------------------------
41
-
42
- interface JsonLdOffer {
43
- price?: number;
44
- priceCurrency?: string;
45
- availability?: string;
46
- seller?: string;
47
- priceValidUntil?: string;
48
- }
49
-
50
- interface JsonLdAggregateOffer {
51
- "@type"?: string;
52
- lowPrice?: number;
53
- priceCurrency?: string;
54
- }
55
-
56
- interface JsonLdPriceSpecification {
57
- priceType?: string;
58
- price?: number;
59
- }
60
-
61
- interface JsonLdAggregateRating {
62
- ratingValue?: number;
63
- reviewCount?: number;
64
- ratingCount?: number;
65
- bestRating?: number;
66
- worstRating?: number;
67
- }
68
-
69
- interface JsonLdImage {
70
- url?: string;
71
- }
72
-
73
- interface JsonLdBrand {
74
- name?: string;
75
- }
76
-
77
- export interface JsonLdProduct {
78
- name?: string;
79
- description?: string;
80
- url?: string;
81
- sku?: string;
82
- productID?: string;
83
- gtin?: string;
84
- brand?: JsonLdBrand | null;
85
- image?: JsonLdImage[] | null;
86
- offers?: JsonLdOffer[] | JsonLdAggregateOffer;
87
- aggregateRating?: JsonLdAggregateRating;
88
- }
89
-
90
- interface JsonLdSeo {
91
- canonical?: string;
92
- title?: string;
93
- description?: string;
94
- }
95
-
96
- export interface JsonLdProductListingPage {
97
- products?: JsonLdProduct[];
98
- seo?: JsonLdSeo | null;
99
- }
100
-
101
- interface JsonLdListItem {
102
- position?: number;
103
- name?: string;
104
- item?: string;
105
- url?: string;
106
- }
107
-
108
- export interface JsonLdBreadcrumbList {
109
- itemListElement?: JsonLdListItem[];
110
- }
111
-
112
- // -------------------------------------------------------------------------
113
- // JSON-LD script renderer
114
- // -------------------------------------------------------------------------
115
-
116
- function JsonLdScript({ data }: { data: unknown }) {
117
- return (
118
- <script type="application/ld+json" dangerouslySetInnerHTML={{ __html: JSON.stringify(data) }} />
119
- );
120
- }
121
-
122
- // -------------------------------------------------------------------------
123
- // Product (PDP)
124
- // -------------------------------------------------------------------------
125
-
126
- export interface ProductJsonLdProps {
127
- product: JsonLdProduct;
128
- /** Override the canonical URL. Defaults to product.url. */
129
- url?: string;
130
- }
131
-
132
- function getBestOffer(offers: JsonLdOffer[] | JsonLdAggregateOffer | undefined): {
133
- price?: number;
134
- priceCurrency?: string;
135
- availability?: string;
136
- seller?: string;
137
- priceValidUntil?: string;
138
- } {
139
- if (!offers) return {};
140
-
141
- if ("@type" in offers && offers["@type"] === "AggregateOffer") {
142
- const agg = offers as JsonLdAggregateOffer;
143
- return {
144
- price: agg.lowPrice,
145
- priceCurrency: agg.priceCurrency,
146
- };
147
- }
148
-
149
- if (Array.isArray(offers) && offers.length > 0) {
150
- const best = offers.reduce((a, b) => {
151
- const ap = a.price ?? Infinity;
152
- const bp = b.price ?? Infinity;
153
- return ap <= bp ? a : b;
154
- });
155
- return {
156
- price: best.price,
157
- priceCurrency: best.priceCurrency,
158
- availability: best.availability,
159
- seller: best.seller,
160
- priceValidUntil: best.priceValidUntil,
161
- };
162
- }
163
-
164
- return {};
165
- }
166
-
167
- function _getListPrice(priceSpec: JsonLdPriceSpecification[] | undefined): number | undefined {
168
- if (!priceSpec) return undefined;
169
- const list = priceSpec.find(
170
- (p) =>
171
- p.priceType === "https://schema.org/ListPrice" || p.priceType === "https://schema.org/SRP",
172
- );
173
- return list?.price;
174
- }
175
-
176
- export function ProductJsonLd({ product, url }: ProductJsonLdProps) {
177
- const offer = getBestOffer(product.offers);
178
- const images = product.image?.map((img) => img.url).filter(Boolean) ?? [];
179
- const rating = product.aggregateRating;
180
-
181
- const data: Record<string, unknown> = {
182
- "@context": "https://schema.org",
183
- "@type": "Product",
184
- name: product.name,
185
- description: product.description,
186
- image: images.length === 1 ? images[0] : images,
187
- url: url ?? product.url,
188
- sku: product.sku,
189
- productID: product.productID,
190
- brand: product.brand ? { "@type": "Brand", name: product.brand.name } : undefined,
191
- gtin: product.gtin,
192
- };
193
-
194
- if (offer.price != null) {
195
- data.offers = {
196
- "@type": "Offer",
197
- price: offer.price,
198
- priceCurrency: offer.priceCurrency ?? "BRL",
199
- availability: offer.availability ?? "https://schema.org/InStock",
200
- seller: offer.seller ? { "@type": "Organization", name: offer.seller } : undefined,
201
- priceValidUntil: offer.priceValidUntil,
202
- url: url ?? product.url,
203
- };
204
- }
205
-
206
- if (rating?.ratingValue) {
207
- data.aggregateRating = {
208
- "@type": "AggregateRating",
209
- ratingValue: rating.ratingValue,
210
- reviewCount: rating.reviewCount ?? rating.ratingCount ?? 0,
211
- bestRating: rating.bestRating ?? 5,
212
- worstRating: rating.worstRating ?? 1,
213
- };
214
- }
215
-
216
- return <JsonLdScript data={data} />;
217
- }
218
-
219
- // -------------------------------------------------------------------------
220
- // Product Listing Page (PLP)
221
- // -------------------------------------------------------------------------
222
-
223
- export interface PLPJsonLdProps {
224
- page: JsonLdProductListingPage;
225
- /** Override the canonical URL. */
226
- url?: string;
227
- }
228
-
229
- export function PLPJsonLd({ page, url }: PLPJsonLdProps) {
230
- const items = (page.products ?? []).map((product, index) => {
231
- const offer = getBestOffer(product.offers);
232
- return {
233
- "@type": "ListItem" as const,
234
- position: index + 1,
235
- item: {
236
- "@type": "Product" as const,
237
- name: product.name,
238
- url: product.url,
239
- image: product.image?.[0]?.url,
240
- offers:
241
- offer.price != null
242
- ? {
243
- "@type": "Offer" as const,
244
- price: offer.price,
245
- priceCurrency: offer.priceCurrency ?? "BRL",
246
- availability: offer.availability ?? "https://schema.org/InStock",
247
- }
248
- : undefined,
249
- },
250
- };
251
- });
252
-
253
- const data = {
254
- "@context": "https://schema.org",
255
- "@type": "ItemList",
256
- url: url ?? page.seo?.canonical,
257
- name: page.seo?.title,
258
- description: page.seo?.description,
259
- numberOfItems: page.products?.length ?? 0,
260
- itemListElement: items,
261
- };
262
-
263
- return <JsonLdScript data={data} />;
264
- }
265
-
266
- // -------------------------------------------------------------------------
267
- // Breadcrumb
268
- // -------------------------------------------------------------------------
269
-
270
- export interface BreadcrumbJsonLdProps {
271
- breadcrumb: JsonLdBreadcrumbList;
272
- }
273
-
274
- export function BreadcrumbJsonLd({ breadcrumb }: BreadcrumbJsonLdProps) {
275
- const items = (breadcrumb.itemListElement ?? []).map((item, index) => {
276
- return {
277
- "@type": "ListItem" as const,
278
- position: item.position ?? index + 1,
279
- name: item.name,
280
- item: item.item ?? item.url,
281
- };
282
- });
283
-
284
- const data = {
285
- "@context": "https://schema.org",
286
- "@type": "BreadcrumbList",
287
- itemListElement: items,
288
- numberOfItems: items.length,
289
- };
290
-
291
- return <JsonLdScript data={data} />;
292
- }
293
-
294
- // -------------------------------------------------------------------------
295
- // Generic SEO Meta
296
- // -------------------------------------------------------------------------
297
-
298
- export interface SeoMetaProps {
299
- title?: string;
300
- description?: string;
301
- canonical?: string;
302
- image?: string;
303
- noIndex?: boolean;
304
- type?: "website" | "article" | "product";
305
- siteName?: string;
306
- }
307
-
308
- /**
309
- * Generates Open Graph and Twitter Card meta tags.
310
- *
311
- * Use this in combination with TanStack Router's `meta()` route option,
312
- * or render directly in the component tree (tags will be hoisted to <head>
313
- * by React's built-in behavior with TanStack Start).
314
- */
315
- export function seoMetaTags(props: SeoMetaProps): Array<Record<string, string>> {
316
- const tags: Array<Record<string, string>> = [];
317
-
318
- if (props.title) {
319
- tags.push({ title: props.title });
320
- tags.push({ property: "og:title", content: props.title });
321
- tags.push({ name: "twitter:title", content: props.title });
322
- }
323
-
324
- if (props.description) {
325
- tags.push({ name: "description", content: props.description });
326
- tags.push({ property: "og:description", content: props.description });
327
- tags.push({ name: "twitter:description", content: props.description });
328
- }
329
-
330
- if (props.canonical) {
331
- tags.push({ property: "og:url", content: props.canonical });
332
- }
333
-
334
- if (props.image) {
335
- tags.push({ property: "og:image", content: props.image });
336
- tags.push({ name: "twitter:image", content: props.image });
337
- tags.push({ name: "twitter:card", content: "summary_large_image" });
338
- }
339
-
340
- if (props.type) {
341
- tags.push({ property: "og:type", content: props.type });
342
- }
343
-
344
- if (props.siteName) {
345
- tags.push({ property: "og:site_name", content: props.siteName });
346
- }
347
-
348
- if (props.noIndex) {
349
- tags.push({ name: "robots", content: "noindex, nofollow" });
350
- }
351
-
352
- return tags;
353
- }