@conloca/astro-cms 0.1.16 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (422) hide show
  1. package/README.md +250 -298
  2. package/dist/internal/acorn-default.mjs +11 -3
  3. package/dist/internal/page-handler.astro +137 -358
  4. package/dist/ts/node/content.d.ts +4 -0
  5. package/dist/ts/node/content.d.ts.map +1 -0
  6. package/dist/ts/node/content.js +3 -0
  7. package/dist/ts/node/content.js.map +1 -0
  8. package/dist/ts/node/index.d.ts +9 -0
  9. package/dist/ts/node/index.d.ts.map +1 -0
  10. package/dist/ts/node/index.js +14 -0
  11. package/dist/ts/node/index.js.map +1 -0
  12. package/dist/ts/src/asset-ref-base.d.ts +3 -0
  13. package/dist/ts/src/asset-ref-base.d.ts.map +1 -0
  14. package/dist/ts/src/asset-ref-base.js +48 -0
  15. package/dist/ts/src/asset-ref-base.js.map +1 -0
  16. package/dist/ts/src/checks.d.ts +7 -0
  17. package/dist/ts/src/checks.d.ts.map +1 -0
  18. package/dist/ts/src/checks.js +7 -0
  19. package/dist/ts/src/checks.js.map +1 -0
  20. package/dist/{src → ts/src}/cms-handler.d.ts +0 -1
  21. package/dist/ts/src/cms-handler.d.ts.map +1 -0
  22. package/dist/{src → ts/src}/cms-handler.js +9 -130
  23. package/dist/ts/src/cms-handler.js.map +1 -0
  24. package/dist/ts/src/collections.d.ts +160 -0
  25. package/dist/ts/src/collections.d.ts.map +1 -0
  26. package/dist/ts/src/collections.js +170 -0
  27. package/dist/ts/src/collections.js.map +1 -0
  28. package/dist/{src → ts/src}/components/HydrationWrapper.d.ts +1 -1
  29. package/dist/ts/src/components/HydrationWrapper.d.ts.map +1 -0
  30. package/dist/{src → ts/src}/components/HydrationWrapper.js +1 -0
  31. package/dist/ts/src/components/HydrationWrapper.js.map +1 -0
  32. package/dist/{src/components/RenderWithBlocks.d.ts → ts/src/components/RenderWithFragments.d.ts} +8 -4
  33. package/dist/ts/src/components/RenderWithFragments.d.ts.map +1 -0
  34. package/dist/ts/src/components/RenderWithFragments.js +133 -0
  35. package/dist/ts/src/components/RenderWithFragments.js.map +1 -0
  36. package/dist/{src → ts/src}/components/RenderWithHydration.d.ts +6 -2
  37. package/dist/ts/src/components/RenderWithHydration.d.ts.map +1 -0
  38. package/dist/{src → ts/src}/components/RenderWithHydration.js +6 -3
  39. package/dist/ts/src/components/RenderWithHydration.js.map +1 -0
  40. package/dist/ts/src/components.d.ts +4 -0
  41. package/dist/ts/src/components.d.ts.map +1 -0
  42. package/dist/ts/src/components.js +4 -0
  43. package/dist/ts/src/components.js.map +1 -0
  44. package/dist/ts/src/discovery/astro-frontmatter.d.ts.map +1 -0
  45. package/dist/{src → ts/src}/discovery/astro-frontmatter.js +1 -0
  46. package/dist/ts/src/discovery/astro-frontmatter.js.map +1 -0
  47. package/dist/ts/src/discovery/discover.d.ts +43 -0
  48. package/dist/ts/src/discovery/discover.d.ts.map +1 -0
  49. package/dist/ts/src/discovery/discover.js +87 -0
  50. package/dist/ts/src/discovery/discover.js.map +1 -0
  51. package/dist/ts/src/discovery/extract-props-ts.d.ts.map +1 -0
  52. package/dist/{src → ts/src}/discovery/extract-props-ts.js +1 -0
  53. package/dist/ts/src/discovery/extract-props-ts.js.map +1 -0
  54. package/dist/{src → ts/src}/discovery/merge-registry.d.ts +3 -3
  55. package/dist/ts/src/discovery/merge-registry.d.ts.map +1 -0
  56. package/dist/{src → ts/src}/discovery/merge-registry.js +1 -0
  57. package/dist/ts/src/discovery/merge-registry.js.map +1 -0
  58. package/dist/ts/src/discovery/registry-endpoint.d.ts +27 -0
  59. package/dist/ts/src/discovery/registry-endpoint.d.ts.map +1 -0
  60. package/dist/ts/src/discovery/registry-endpoint.js +76 -0
  61. package/dist/ts/src/discovery/registry-endpoint.js.map +1 -0
  62. package/dist/{src → ts/src}/discovery/scan-components.d.ts +3 -7
  63. package/dist/ts/src/discovery/scan-components.d.ts.map +1 -0
  64. package/dist/{src → ts/src}/discovery/scan-components.js +4 -6
  65. package/dist/ts/src/discovery/scan-components.js.map +1 -0
  66. package/dist/ts/src/discovery/scan-mdx.d.ts.map +1 -0
  67. package/dist/{src → ts/src}/discovery/scan-mdx.js +1 -0
  68. package/dist/ts/src/discovery/scan-mdx.js.map +1 -0
  69. package/dist/ts/src/discovery/scan-overrides.d.ts.map +1 -0
  70. package/dist/{src → ts/src}/discovery/scan-overrides.js +1 -0
  71. package/dist/ts/src/discovery/scan-overrides.js.map +1 -0
  72. package/dist/ts/src/editor-descriptors.d.ts +31 -0
  73. package/dist/ts/src/editor-descriptors.d.ts.map +1 -0
  74. package/dist/ts/src/editor-descriptors.js +84 -0
  75. package/dist/ts/src/editor-descriptors.js.map +1 -0
  76. package/dist/ts/src/handlers/collection-content-api.d.ts +32 -0
  77. package/dist/ts/src/handlers/collection-content-api.d.ts.map +1 -0
  78. package/dist/ts/src/handlers/collection-content-api.js +166 -0
  79. package/dist/ts/src/handlers/collection-content-api.js.map +1 -0
  80. package/dist/ts/src/handlers/page-render-core.d.ts +137 -0
  81. package/dist/ts/src/handlers/page-render-core.d.ts.map +1 -0
  82. package/dist/ts/src/handlers/page-render-core.js +315 -0
  83. package/dist/ts/src/handlers/page-render-core.js.map +1 -0
  84. package/dist/ts/src/hydration.d.ts.map +1 -0
  85. package/dist/{src → ts/src}/hydration.js +1 -0
  86. package/dist/ts/src/hydration.js.map +1 -0
  87. package/dist/ts/src/index.d.ts +21 -0
  88. package/dist/ts/src/index.d.ts.map +1 -0
  89. package/dist/ts/src/index.js +45 -0
  90. package/dist/ts/src/index.js.map +1 -0
  91. package/dist/ts/src/internal/declared-collections.d.ts +30 -0
  92. package/dist/ts/src/internal/declared-collections.d.ts.map +1 -0
  93. package/dist/ts/src/internal/declared-collections.js +84 -0
  94. package/dist/ts/src/internal/declared-collections.js.map +1 -0
  95. package/dist/ts/src/internal/page-collection-schema.d.ts +44 -0
  96. package/dist/ts/src/internal/page-collection-schema.d.ts.map +1 -0
  97. package/dist/ts/src/internal/page-collection-schema.js +152 -0
  98. package/dist/ts/src/internal/page-collection-schema.js.map +1 -0
  99. package/dist/ts/src/lib/content-config-guard.d.ts +11 -0
  100. package/dist/ts/src/lib/content-config-guard.d.ts.map +1 -0
  101. package/dist/ts/src/lib/content-config-guard.js +41 -0
  102. package/dist/ts/src/lib/content-config-guard.js.map +1 -0
  103. package/dist/ts/src/lib/hydration-scanner.d.ts.map +1 -0
  104. package/dist/{src → ts/src}/lib/hydration-scanner.js +1 -0
  105. package/dist/ts/src/lib/hydration-scanner.js.map +1 -0
  106. package/dist/ts/src/lib/hydration-script.d.ts.map +1 -0
  107. package/dist/{src → ts/src}/lib/hydration-script.js +1 -0
  108. package/dist/ts/src/lib/hydration-script.js.map +1 -0
  109. package/dist/ts/src/lib/hydration-utils.d.ts.map +1 -0
  110. package/dist/{src → ts/src}/lib/hydration-utils.js +1 -0
  111. package/dist/ts/src/lib/hydration-utils.js.map +1 -0
  112. package/dist/ts/src/lib/resolve-locale.d.ts +15 -0
  113. package/dist/ts/src/lib/resolve-locale.d.ts.map +1 -0
  114. package/dist/ts/src/lib/resolve-locale.js +16 -0
  115. package/dist/ts/src/lib/resolve-locale.js.map +1 -0
  116. package/dist/ts/src/lib/resolve-site-name.d.ts +8 -0
  117. package/dist/ts/src/lib/resolve-site-name.d.ts.map +1 -0
  118. package/dist/ts/src/lib/resolve-site-name.js +12 -0
  119. package/dist/ts/src/lib/resolve-site-name.js.map +1 -0
  120. package/dist/{src → ts/src}/lib/route-utils.d.ts +26 -6
  121. package/dist/ts/src/lib/route-utils.d.ts.map +1 -0
  122. package/dist/{src → ts/src}/lib/route-utils.js +33 -15
  123. package/dist/ts/src/lib/route-utils.js.map +1 -0
  124. package/dist/{src → ts/src}/lib/routing-config.d.ts +7 -1
  125. package/dist/ts/src/lib/routing-config.d.ts.map +1 -0
  126. package/dist/{src → ts/src}/lib/routing-config.js +13 -0
  127. package/dist/ts/src/lib/routing-config.js.map +1 -0
  128. package/dist/ts/src/lib/serialize-props.d.ts.map +1 -0
  129. package/dist/{src → ts/src}/lib/serialize-props.js +1 -0
  130. package/dist/ts/src/lib/serialize-props.js.map +1 -0
  131. package/dist/ts/src/lib/unknown-components.d.ts +21 -0
  132. package/dist/ts/src/lib/unknown-components.d.ts.map +1 -0
  133. package/dist/ts/src/lib/unknown-components.js +49 -0
  134. package/dist/ts/src/lib/unknown-components.js.map +1 -0
  135. package/dist/{src → ts/src}/lib/virtual-module-generators.d.ts +0 -24
  136. package/dist/ts/src/lib/virtual-module-generators.d.ts.map +1 -0
  137. package/dist/ts/src/lib/virtual-module-generators.js +51 -0
  138. package/dist/ts/src/lib/virtual-module-generators.js.map +1 -0
  139. package/dist/ts/src/lib/withHydration.d.ts.map +1 -0
  140. package/dist/{src → ts/src}/lib/withHydration.js +1 -0
  141. package/dist/ts/src/lib/withHydration.js.map +1 -0
  142. package/dist/ts/src/loader.d.ts +27 -0
  143. package/dist/ts/src/loader.d.ts.map +1 -0
  144. package/dist/{src → ts/src}/loader.js +33 -4
  145. package/dist/ts/src/loader.js.map +1 -0
  146. package/dist/ts/src/locales-helpers.d.ts.map +1 -0
  147. package/dist/{src → ts/src}/locales-helpers.js +1 -0
  148. package/dist/ts/src/locales-helpers.js.map +1 -0
  149. package/dist/ts/src/mime-types.d.ts.map +1 -0
  150. package/dist/{src → ts/src}/mime-types.js +1 -0
  151. package/dist/ts/src/mime-types.js.map +1 -0
  152. package/dist/ts/src/page-feed.d.ts +13 -0
  153. package/dist/ts/src/page-feed.d.ts.map +1 -0
  154. package/dist/ts/src/page-feed.js +20 -0
  155. package/dist/ts/src/page-feed.js.map +1 -0
  156. package/dist/ts/src/page-schemas.d.ts +6 -0
  157. package/dist/ts/src/page-schemas.d.ts.map +1 -0
  158. package/dist/ts/src/page-schemas.js +6 -0
  159. package/dist/ts/src/page-schemas.js.map +1 -0
  160. package/dist/ts/src/path-validation.d.ts.map +1 -0
  161. package/dist/{src → ts/src}/path-validation.js +1 -0
  162. package/dist/ts/src/path-validation.js.map +1 -0
  163. package/dist/{src → ts/src}/plugin-spa.d.ts +28 -10
  164. package/dist/ts/src/plugin-spa.d.ts.map +1 -0
  165. package/dist/{src → ts/src}/plugin-spa.js +280 -87
  166. package/dist/ts/src/plugin-spa.js.map +1 -0
  167. package/dist/ts/src/puck-manifest/components-endpoint.d.ts +30 -0
  168. package/dist/ts/src/puck-manifest/components-endpoint.d.ts.map +1 -0
  169. package/dist/ts/src/puck-manifest/components-endpoint.js +54 -0
  170. package/dist/ts/src/puck-manifest/components-endpoint.js.map +1 -0
  171. package/dist/ts/src/puck-manifest/field-projection.d.ts +91 -0
  172. package/dist/ts/src/puck-manifest/field-projection.d.ts.map +1 -0
  173. package/dist/ts/src/puck-manifest/field-projection.js +422 -0
  174. package/dist/ts/src/puck-manifest/field-projection.js.map +1 -0
  175. package/dist/ts/src/puck-manifest/index.d.ts +4 -0
  176. package/dist/ts/src/puck-manifest/index.d.ts.map +1 -0
  177. package/dist/ts/src/puck-manifest/index.js +3 -0
  178. package/dist/ts/src/puck-manifest/index.js.map +1 -0
  179. package/dist/ts/src/puck-manifest/literal.d.ts +163 -0
  180. package/dist/ts/src/puck-manifest/literal.d.ts.map +1 -0
  181. package/dist/ts/src/puck-manifest/literal.js +354 -0
  182. package/dist/ts/src/puck-manifest/literal.js.map +1 -0
  183. package/dist/ts/src/puck-manifest/read-config.d.ts +42 -0
  184. package/dist/ts/src/puck-manifest/read-config.d.ts.map +1 -0
  185. package/dist/ts/src/puck-manifest/read-config.js +517 -0
  186. package/dist/ts/src/puck-manifest/read-config.js.map +1 -0
  187. package/dist/ts/src/puck-manifest/read-field.d.ts +7 -0
  188. package/dist/ts/src/puck-manifest/read-field.d.ts.map +1 -0
  189. package/dist/ts/src/puck-manifest/read-field.js +11 -0
  190. package/dist/ts/src/puck-manifest/read-field.js.map +1 -0
  191. package/dist/ts/src/puck-manifest/read-wrapper.d.ts +147 -0
  192. package/dist/ts/src/puck-manifest/read-wrapper.d.ts.map +1 -0
  193. package/dist/ts/src/puck-manifest/read-wrapper.js +889 -0
  194. package/dist/ts/src/puck-manifest/read-wrapper.js.map +1 -0
  195. package/dist/ts/src/puck-manifest/reading-budget.d.ts +50 -0
  196. package/dist/ts/src/puck-manifest/reading-budget.d.ts.map +1 -0
  197. package/dist/ts/src/puck-manifest/reading-budget.js +113 -0
  198. package/dist/ts/src/puck-manifest/reading-budget.js.map +1 -0
  199. package/dist/ts/src/puck-manifest/resolve-reference.d.ts +4 -0
  200. package/dist/ts/src/puck-manifest/resolve-reference.d.ts.map +1 -0
  201. package/dist/ts/src/puck-manifest/resolve-reference.js +4 -0
  202. package/dist/ts/src/puck-manifest/resolve-reference.js.map +1 -0
  203. package/dist/ts/src/puck-manifest/source-reference.d.ts +96 -0
  204. package/dist/ts/src/puck-manifest/source-reference.d.ts.map +1 -0
  205. package/dist/ts/src/puck-manifest/source-reference.js +424 -0
  206. package/dist/ts/src/puck-manifest/source-reference.js.map +1 -0
  207. package/dist/ts/src/puck-manifest/syntax.d.ts +29 -0
  208. package/dist/ts/src/puck-manifest/syntax.d.ts.map +1 -0
  209. package/dist/ts/src/puck-manifest/syntax.js +79 -0
  210. package/dist/ts/src/puck-manifest/syntax.js.map +1 -0
  211. package/dist/ts/src/puck-manifest/types.d.ts +145 -0
  212. package/dist/ts/src/puck-manifest/types.d.ts.map +1 -0
  213. package/dist/ts/src/puck-manifest/types.js +2 -0
  214. package/dist/ts/src/puck-manifest/types.js.map +1 -0
  215. package/dist/ts/src/safe-json-stringify.d.ts.map +1 -0
  216. package/dist/{src → ts/src}/safe-json-stringify.js +1 -0
  217. package/dist/ts/src/safe-json-stringify.js.map +1 -0
  218. package/dist/ts/src/sandbox-frame-handler.d.ts +19 -0
  219. package/dist/ts/src/sandbox-frame-handler.d.ts.map +1 -0
  220. package/dist/ts/src/sandbox-frame-handler.js +27 -0
  221. package/dist/ts/src/sandbox-frame-handler.js.map +1 -0
  222. package/dist/{src → ts/src}/site-styles/content-wrapper-endpoint.d.ts +2 -5
  223. package/dist/ts/src/site-styles/content-wrapper-endpoint.d.ts.map +1 -0
  224. package/dist/{src → ts/src}/site-styles/content-wrapper-endpoint.js +5 -8
  225. package/dist/ts/src/site-styles/content-wrapper-endpoint.js.map +1 -0
  226. package/dist/{src → ts/src}/site-styles/render-endpoint.d.ts +4 -9
  227. package/dist/ts/src/site-styles/render-endpoint.d.ts.map +1 -0
  228. package/dist/{src → ts/src}/site-styles/render-endpoint.js +1 -0
  229. package/dist/ts/src/site-styles/render-endpoint.js.map +1 -0
  230. package/dist/{src → ts/src}/site-styles/styles-endpoint.d.ts +2 -4
  231. package/dist/ts/src/site-styles/styles-endpoint.d.ts.map +1 -0
  232. package/dist/{src → ts/src}/site-styles/styles-endpoint.js +3 -5
  233. package/dist/ts/src/site-styles/styles-endpoint.js.map +1 -0
  234. package/dist/ts/src/sitemap-options.d.ts +21 -0
  235. package/dist/ts/src/sitemap-options.d.ts.map +1 -0
  236. package/dist/ts/src/sitemap-options.js +92 -0
  237. package/dist/ts/src/sitemap-options.js.map +1 -0
  238. package/dist/ts/src/tiptap-html-static.d.ts +15 -0
  239. package/dist/ts/src/tiptap-html-static.d.ts.map +1 -0
  240. package/dist/ts/src/tiptap-html-static.js +67 -0
  241. package/dist/ts/src/tiptap-html-static.js.map +1 -0
  242. package/dist/{src → ts/src}/types.d.ts +26 -110
  243. package/dist/ts/src/types.d.ts.map +1 -0
  244. package/dist/ts/src/types.js +2 -0
  245. package/dist/ts/src/types.js.map +1 -0
  246. package/dist/virtual-modules.d.ts +12 -93
  247. package/node/content.ts +14 -0
  248. package/node/index.ts +22 -0
  249. package/package.json +159 -73
  250. package/src/asset-ref-base.ts +48 -0
  251. package/src/checks.ts +10 -0
  252. package/src/cms-handler.ts +280 -0
  253. package/src/collections.ts +262 -0
  254. package/src/components/HydrationWrapper.tsx +41 -0
  255. package/src/components/RenderWithFragments.tsx +204 -0
  256. package/src/components/RenderWithHydration.tsx +55 -0
  257. package/src/components.ts +3 -0
  258. package/src/discovery/astro-frontmatter.ts +24 -0
  259. package/src/discovery/discover.ts +108 -0
  260. package/src/discovery/extract-props-ts.ts +255 -0
  261. package/src/discovery/merge-registry.ts +411 -0
  262. package/src/discovery/registry-endpoint.ts +80 -0
  263. package/src/discovery/scan-components.ts +458 -0
  264. package/src/discovery/scan-mdx.ts +190 -0
  265. package/src/discovery/scan-overrides.ts +92 -0
  266. package/src/editor-descriptors.ts +96 -0
  267. package/src/env.d.ts +31 -0
  268. package/src/handlers/collection-content-api.ts +196 -0
  269. package/src/handlers/page-handler.astro +320 -0
  270. package/src/handlers/page-render-core.ts +456 -0
  271. package/src/hydration.ts +7 -0
  272. package/src/index.ts +111 -0
  273. package/src/internal/acorn-default.mjs +37 -0
  274. package/src/internal/declared-collections.ts +98 -0
  275. package/src/internal/page-collection-schema.ts +210 -0
  276. package/src/lib/content-config-guard.ts +48 -0
  277. package/src/lib/hydration-scanner.ts +176 -0
  278. package/src/lib/hydration-script.ts +126 -0
  279. package/src/lib/hydration-utils.ts +120 -0
  280. package/src/lib/resolve-locale.ts +22 -0
  281. package/src/lib/resolve-site-name.ts +10 -0
  282. package/src/lib/route-utils.ts +106 -0
  283. package/src/lib/routing-config.ts +126 -0
  284. package/src/lib/serialize-props.ts +7 -0
  285. package/src/lib/unknown-components.ts +64 -0
  286. package/src/lib/virtual-module-generators.ts +58 -0
  287. package/{dist/withHydration-DkKpkmzJ.d.mts → src/lib/withHydration.ts} +25 -8
  288. package/src/loader.ts +145 -0
  289. package/{dist/locales-helpers-BvYYqnJ5.d.mts → src/locales-helpers.ts} +21 -17
  290. package/src/mime-types.ts +19 -0
  291. package/src/page-feed.ts +26 -0
  292. package/src/page-schemas.ts +19 -0
  293. package/src/path-validation.ts +13 -0
  294. package/src/plugin-spa.ts +1480 -0
  295. package/src/puck-manifest/components-endpoint.ts +55 -0
  296. package/src/puck-manifest/field-projection.ts +510 -0
  297. package/src/puck-manifest/index.ts +3 -0
  298. package/src/puck-manifest/literal.ts +459 -0
  299. package/src/puck-manifest/read-config.ts +577 -0
  300. package/src/puck-manifest/read-field.ts +19 -0
  301. package/src/puck-manifest/read-wrapper.ts +1056 -0
  302. package/src/puck-manifest/reading-budget.ts +127 -0
  303. package/src/puck-manifest/resolve-reference.ts +9 -0
  304. package/src/puck-manifest/source-reference.ts +484 -0
  305. package/src/puck-manifest/syntax.ts +104 -0
  306. package/src/puck-manifest/types.ts +139 -0
  307. package/src/safe-json-stringify.ts +17 -0
  308. package/src/sandbox-frame-handler.ts +31 -0
  309. package/src/site-styles/content-wrapper-endpoint.ts +327 -0
  310. package/src/site-styles/render-endpoint.ts +331 -0
  311. package/src/site-styles/styles-endpoint.ts +184 -0
  312. package/src/sitemap-options.ts +115 -0
  313. package/src/tiptap-html-static.ts +84 -0
  314. package/{dist/types-CS9neadI.d.mts → src/types.ts} +87 -124
  315. package/src/virtual-modules.d.ts +74 -0
  316. package/dist/collections-Bd7EME4b.mjs +0 -129
  317. package/dist/collections-Bd7EME4b.mjs.map +0 -1
  318. package/dist/collections.d.mts +0 -35
  319. package/dist/collections.d.mts.map +0 -1
  320. package/dist/collections.mjs +0 -2
  321. package/dist/components.d.mts +0 -41
  322. package/dist/components.d.mts.map +0 -1
  323. package/dist/components.mjs +0 -223
  324. package/dist/components.mjs.map +0 -1
  325. package/dist/hydration.d.mts +0 -4
  326. package/dist/hydration.mjs +0 -2
  327. package/dist/index.d.mts +0 -108
  328. package/dist/index.d.mts.map +0 -1
  329. package/dist/index.mjs +0 -67
  330. package/dist/index.mjs.map +0 -1
  331. package/dist/internal/cms-handler.d.mts +0 -25
  332. package/dist/internal/cms-handler.d.mts.map +0 -1
  333. package/dist/internal/cms-handler.mjs +0 -314
  334. package/dist/internal/cms-handler.mjs.map +0 -1
  335. package/dist/lib/hydration-script.d.mts +0 -30
  336. package/dist/lib/hydration-script.d.mts.map +0 -1
  337. package/dist/lib/hydration-script.mjs +0 -84
  338. package/dist/lib/hydration-script.mjs.map +0 -1
  339. package/dist/locales-helpers-BvYYqnJ5.d.mts.map +0 -1
  340. package/dist/locales-helpers-qiwh7nxS.mjs +0 -54
  341. package/dist/locales-helpers-qiwh7nxS.mjs.map +0 -1
  342. package/dist/node/content.d.mts +0 -18
  343. package/dist/node/content.d.mts.map +0 -1
  344. package/dist/node/content.d.ts +0 -3
  345. package/dist/node/content.d.ts.map +0 -1
  346. package/dist/node/content.js +0 -2
  347. package/dist/node/content.mjs +0 -2
  348. package/dist/node/index.d.mts +0 -200
  349. package/dist/node/index.d.mts.map +0 -1
  350. package/dist/node/index.d.ts +0 -4
  351. package/dist/node/index.d.ts.map +0 -1
  352. package/dist/node/index.js +0 -3
  353. package/dist/node/index.mjs +0 -2513
  354. package/dist/node/index.mjs.map +0 -1
  355. package/dist/serialize-props-BHoNpzH6.mjs +0 -72
  356. package/dist/serialize-props-BHoNpzH6.mjs.map +0 -1
  357. package/dist/src/cms-handler.d.ts.map +0 -1
  358. package/dist/src/collections.d.ts +0 -32
  359. package/dist/src/collections.d.ts.map +0 -1
  360. package/dist/src/collections.js +0 -50
  361. package/dist/src/components/HydrationWrapper.d.ts.map +0 -1
  362. package/dist/src/components/RenderWithBlocks.d.ts.map +0 -1
  363. package/dist/src/components/RenderWithBlocks.js +0 -129
  364. package/dist/src/components/RenderWithHydration.d.ts.map +0 -1
  365. package/dist/src/components.d.ts +0 -4
  366. package/dist/src/components.d.ts.map +0 -1
  367. package/dist/src/components.js +0 -3
  368. package/dist/src/discovery/astro-frontmatter.d.ts.map +0 -1
  369. package/dist/src/discovery/extract-props-ts.d.ts.map +0 -1
  370. package/dist/src/discovery/merge-registry.d.ts.map +0 -1
  371. package/dist/src/discovery/registry-endpoint.d.ts +0 -42
  372. package/dist/src/discovery/registry-endpoint.d.ts.map +0 -1
  373. package/dist/src/discovery/registry-endpoint.js +0 -81
  374. package/dist/src/discovery/scan-components.d.ts.map +0 -1
  375. package/dist/src/discovery/scan-mdx.d.ts.map +0 -1
  376. package/dist/src/discovery/scan-overrides.d.ts.map +0 -1
  377. package/dist/src/hydration.d.ts.map +0 -1
  378. package/dist/src/index.d.ts +0 -11
  379. package/dist/src/index.d.ts.map +0 -1
  380. package/dist/src/index.js +0 -25
  381. package/dist/src/lib/hydration-scanner.d.ts.map +0 -1
  382. package/dist/src/lib/hydration-script.d.ts.map +0 -1
  383. package/dist/src/lib/hydration-utils.d.ts.map +0 -1
  384. package/dist/src/lib/page-api.d.ts +0 -77
  385. package/dist/src/lib/page-api.d.ts.map +0 -1
  386. package/dist/src/lib/page-api.js +0 -121
  387. package/dist/src/lib/route-utils.d.ts.map +0 -1
  388. package/dist/src/lib/routing-config.d.ts.map +0 -1
  389. package/dist/src/lib/serialize-props.d.ts.map +0 -1
  390. package/dist/src/lib/virtual-module-generators.d.ts.map +0 -1
  391. package/dist/src/lib/virtual-module-generators.js +0 -263
  392. package/dist/src/lib/withHydration.d.ts.map +0 -1
  393. package/dist/src/loader.d.ts +0 -14
  394. package/dist/src/loader.d.ts.map +0 -1
  395. package/dist/src/locales-helpers.d.ts.map +0 -1
  396. package/dist/src/mime-types.d.ts.map +0 -1
  397. package/dist/src/path-validation.d.ts.map +0 -1
  398. package/dist/src/plugin-spa.d.ts.map +0 -1
  399. package/dist/src/safe-json-stringify.d.ts.map +0 -1
  400. package/dist/src/site-styles/content-wrapper-endpoint.d.ts.map +0 -1
  401. package/dist/src/site-styles/render-endpoint.d.ts.map +0 -1
  402. package/dist/src/site-styles/styles-endpoint.d.ts.map +0 -1
  403. package/dist/src/types.d.ts.map +0 -1
  404. package/dist/src/types.js +0 -1
  405. package/dist/types-CS9neadI.d.mts.map +0 -1
  406. package/dist/withHydration-C256ox_6.mjs +0 -49
  407. package/dist/withHydration-C256ox_6.mjs.map +0 -1
  408. package/dist/withHydration-DkKpkmzJ.d.mts.map +0 -1
  409. /package/dist/{src → ts/src}/discovery/astro-frontmatter.d.ts +0 -0
  410. /package/dist/{src → ts/src}/discovery/extract-props-ts.d.ts +0 -0
  411. /package/dist/{src → ts/src}/discovery/scan-mdx.d.ts +0 -0
  412. /package/dist/{src → ts/src}/discovery/scan-overrides.d.ts +0 -0
  413. /package/dist/{src → ts/src}/hydration.d.ts +0 -0
  414. /package/dist/{src → ts/src}/lib/hydration-scanner.d.ts +0 -0
  415. /package/dist/{src → ts/src}/lib/hydration-script.d.ts +0 -0
  416. /package/dist/{src → ts/src}/lib/hydration-utils.d.ts +0 -0
  417. /package/dist/{src → ts/src}/lib/serialize-props.d.ts +0 -0
  418. /package/dist/{src → ts/src}/lib/withHydration.d.ts +0 -0
  419. /package/dist/{src → ts/src}/locales-helpers.d.ts +0 -0
  420. /package/dist/{src → ts/src}/mime-types.d.ts +0 -0
  421. /package/dist/{src → ts/src}/path-validation.d.ts +0 -0
  422. /package/dist/{src → ts/src}/safe-json-stringify.d.ts +0 -0
@@ -0,0 +1,459 @@
1
+ import { type Node, type ObjectLiteralExpression, SyntaxKind, type ts } from 'ts-morph';
2
+ import { spendWork, withWorkBudget } from './reading-budget.js';
3
+ import {
4
+ holdsNothing,
5
+ inheritsNothing,
6
+ propertyKey,
7
+ resolveObjectLiteral,
8
+ resolveValueExpression,
9
+ setsPrototype,
10
+ } from './source-reference.js';
11
+ import { asObjectLiteral, literalPrimitive, namedMember, unwrapExpression, writtenValue } from './syntax.js';
12
+ import type { JsonValue } from './types.js';
13
+
14
+ // Keep the existing reader entry points; implementations import their owning layers directly.
15
+ export {
16
+ limitOutput,
17
+ MAX_OUTPUT,
18
+ MAX_OUTPUT_BYTES,
19
+ MAX_WORK,
20
+ OutputBudgetExceeded,
21
+ spendWork,
22
+ WorkBudgetExceeded,
23
+ } from './reading-budget.js';
24
+ export { expressionKey, holdsNothing, inheritsNothing, propertyKey, setsPrototype } from './source-reference.js';
25
+ export { asObjectLiteral, type NamedMember, namedMember, unwrapExpression, writtenValue } from './syntax.js';
26
+
27
+ /** Whether a reading left anything out. Set on the way down, never cleared. */
28
+ interface Drops {
29
+ dropped: boolean;
30
+ }
31
+
32
+ /**
33
+ * Reads a TypeScript expression as a JSON value, or `undefined` when it is
34
+ * computed rather than written down — in whole or in part.
35
+ *
36
+ * `undefined` is load-bearing: a config full of function calls must produce an
37
+ * absent value, never an invented one. Callers turn that absence into an
38
+ * explicit marker so the agent is told what is unknown instead of being handed
39
+ * a guess. A value with a part left out — `{ id: makeId(), label: 'x' }` — is
40
+ * no value here either, because handed on without that fact it passes for the
41
+ * whole; a caller that can admit the gap asks `literalValueReading` for the
42
+ * part that did read.
43
+ */
44
+ export function literalValue(node: Node): JsonValue | undefined {
45
+ const reading = literalValueReading(node);
46
+ return reading && !reading.dropped ? reading.value : undefined;
47
+ }
48
+
49
+ /** A value read as plain data, and whether any part of it — at any depth — had to be left out. */
50
+ export interface ValueReading {
51
+ value: JsonValue;
52
+ dropped: boolean;
53
+ }
54
+
55
+ /**
56
+ * `literalValue`, keeping the part that read when something had to be left
57
+ * out, and saying so. Every key the value holds is the runtime's own last
58
+ * write of it; `dropped` says the value may hold more than it shows.
59
+ */
60
+ export function literalValueReading(node: Node): ValueReading | undefined {
61
+ const drops = { dropped: false };
62
+ const value = readValue(node, drops);
63
+ return value === undefined ? undefined : { value, dropped: drops.dropped };
64
+ }
65
+
66
+ function readValue(node: Node, drops: Drops): JsonValue | undefined {
67
+ // `options: [...] as const` is how Puck's own docs write a field's legal
68
+ // values — reading through the wrapper is the difference between those
69
+ // values and silence.
70
+ const expression = unwrapExpression(node);
71
+
72
+ const primitive = literalPrimitive(expression);
73
+ if (primitive !== undefined) return primitive;
74
+
75
+ const array = expression.asKind(SyntaxKind.ArrayLiteralExpression);
76
+ if (array) {
77
+ const values: JsonValue[] = [];
78
+ for (const element of array.getElements()) {
79
+ // Each place an array is named reads it anew, so every item costs work.
80
+ spendWork();
81
+ const value = readValue(element, drops);
82
+ // A computed element would silently shift every later index, so the
83
+ // whole array is unknown rather than partially wrong.
84
+ if (value === undefined) return undefined;
85
+ values.push(value);
86
+ }
87
+ return values;
88
+ }
89
+
90
+ const object = expression.asKind(SyntaxKind.ObjectLiteralExpression);
91
+ if (object) return readObject(object, drops);
92
+
93
+ return undefined;
94
+ }
95
+
96
+ /** Why a walk could not read the last write of a key. */
97
+ export type UnreadWrite =
98
+ /** The owner could not take the value written. */
99
+ | 'value'
100
+ /** A method or a getter writes the key with code this reader does not run. */
101
+ | 'code'
102
+ /** A setter writes it last: undefined on its own, and code beside a getter. */
103
+ | 'setter'
104
+ /**
105
+ * `['__proto__']` — an own key at runtime, but one no record of ours can
106
+ * hold, because assigning it replaces the record's prototype instead of
107
+ * adding a key.
108
+ */
109
+ | 'reserved';
110
+
111
+ /**
112
+ * One object literal walked in source order, by the runtime's own rules. The
113
+ * owner decides what a value is; the walk decides which write of a key is the
114
+ * last one, and what the owner could not see.
115
+ */
116
+ export interface LiteralWalk<V> {
117
+ /** Every key whose last write the owner could read, with what it read, in the order the runtime keeps them. */
118
+ entries: Map<string, V>;
119
+ /** Keys whose last write could not be read, each with the reason. */
120
+ unread: Map<string, UnreadWrite>;
121
+ /** Keys written before a write the walk cannot name, which may have replaced them, that nothing later settled. */
122
+ cleared: Set<string>;
123
+ /** A write the walk cannot name — a computed key it cannot resolve, a spread it cannot follow — so the object may hold any key. */
124
+ lost: boolean;
125
+ /**
126
+ * The member of this literal behind the last such write — the spread, or the
127
+ * member whose computed name could not be worked out — so a reason can point
128
+ * at it. A spread whose own walk lost something is named here too.
129
+ */
130
+ lostAt?: Node;
131
+ /** `__proto__` hands the object a prototype, so a key it does not write itself may be inherited. */
132
+ inherits: boolean;
133
+ }
134
+
135
+ /** A spread shown to carry nothing — `...null`, or `{ ...overrides }` where the call omitted `overrides`. */
136
+ export const SPREADS_NOTHING: unique symbol = Symbol('spreads nothing');
137
+
138
+ /** What an owner hands a walk: who it is, how to read one value, and where a spread leads. */
139
+ export interface LiteralWalkHooks<V> {
140
+ /**
141
+ * Names the owner. A walk is remembered per owner and literal for the length
142
+ * of one reading — unless it was cut short, see `walkLiteral` — so two owners
143
+ * that read the same literal differently never share an answer, which holds
144
+ * only while both hooks answer from the node they are handed and nothing else.
145
+ */
146
+ kind: string;
147
+ /** What one member writes — the value of `key: value`, or the name a shorthand stands for — or undefined where the owner cannot take it. */
148
+ read(value: Node): V | undefined;
149
+ /** The literal a spread reaches, `SPREADS_NOTHING` where it provably carries none, or undefined where it cannot be followed. */
150
+ spread(expression: Node): ObjectLiteralExpression | typeof SPREADS_NOTHING | undefined;
151
+ }
152
+
153
+ /** Whether a walk saw every write of its object: nothing unread, lost or inherited. */
154
+ export function walkIsWhole<V>(walk: LiteralWalk<V>): boolean {
155
+ return walk.unread.size === 0 && !walk.lost && !walk.inherits;
156
+ }
157
+
158
+ /** How many characters of source a reason quotes before it cuts the quote short. */
159
+ const EXCERPT_LENGTH = 60;
160
+
161
+ /**
162
+ * Source text as a reason quotes it: on one line, cut short on a whole
163
+ * character — an emoji is two 16-bit string units, and cutting between them
164
+ * leaves half of one — and marked where it was cut. Text with nothing in it is
165
+ * named as such rather than quoted as a gap in the sentence.
166
+ */
167
+ export function excerpt(text: string): string {
168
+ const oneLine = text.replace(/\s+/g, ' ').trim();
169
+ if (oneLine === '') return 'an empty expression';
170
+ let kept = '';
171
+ let count = 0;
172
+ for (const character of oneLine) {
173
+ if (count++ === EXCERPT_LENGTH) return `${kept}…`;
174
+ kept += character;
175
+ }
176
+ return kept;
177
+ }
178
+
179
+ /**
180
+ * One `readPuckConfig` call from start to finish: the walks already made, and
181
+ * the work spent so far. Walks are remembered only here, because a project
182
+ * read again later may have changed underneath the answer.
183
+ */
184
+ interface ReadingSession {
185
+ walks: Map<string, Map<ts.Node, LiteralWalk<unknown>>>;
186
+ }
187
+
188
+ let session: ReadingSession | undefined;
189
+
190
+ /**
191
+ * Runs one reading of a config with its walks remembered and its work counted.
192
+ * A literal spread into ten objects is walked once rather than ten times, and
193
+ * a chain of such spreads costs its length rather than its width to the power
194
+ * of its depth.
195
+ */
196
+ export function withReadingSession<T>(read: () => T): T {
197
+ if (session) return read();
198
+ session = { walks: new Map() };
199
+ try {
200
+ return withWorkBudget(read);
201
+ } finally {
202
+ session = undefined;
203
+ }
204
+ }
205
+
206
+ /**
207
+ * Literals whose walk is under way, each with its owner. A spread or a value
208
+ * that leads back to one of them is source that could never have loaded —
209
+ * `const A = { ...B }` beside `const B = { ...A }` — and is a write the walk
210
+ * cannot name rather than a loop.
211
+ */
212
+ const walking: { kind: string; node: ts.Node }[] = [];
213
+
214
+ /**
215
+ * How many walks may nest before the next is given up as a write the walk
216
+ * cannot name. Cycles end on their own above; this only keeps a chain written
217
+ * thousands deep from exhausting the stack.
218
+ */
219
+ const MAX_WALK_NESTING = 256;
220
+
221
+ /**
222
+ * How many walks have been cut short so far — by the nesting limit, or by
223
+ * leading back into a walk under way. A walk that sees the count move while it
224
+ * runs holds a cut somewhere inside it, and a cut depends on how deep the
225
+ * reading already was when it got there, so that walk is never remembered:
226
+ * remembered, it would hand the cut to a later reading that starts shallow
227
+ * enough to read the whole chain.
228
+ */
229
+ let cutWalks = 0;
230
+
231
+ /**
232
+ * Walks an object literal's members in source order — the one walk every
233
+ * owner of a literal shares, so each rule below is written once and holds
234
+ * wherever a literal is read:
235
+ *
236
+ * - A spread applies where it is written. One the owner can follow merges its
237
+ * own walk there; one of `null` or `undefined` writes nothing; any other may
238
+ * write any key, so every key before it is cleared and the walk is `lost`.
239
+ * - A computed key standing for a `const` is that key. Any other clears every
240
+ * key before it, the same way.
241
+ * - A method, getter or setter writes its key with code, so the key is unread.
242
+ * A setter alone reads back undefined, which is no value either.
243
+ * - `__proto__: x` hands the object a prototype, unless `x` holds nothing.
244
+ * - A shorthand is read as the name it stands for.
245
+ * - The last write of a key wins, and an unreadable one takes the earlier
246
+ * value with it.
247
+ */
248
+ export function walkLiteral<V>(literal: ObjectLiteralExpression, hooks: LiteralWalkHooks<V>): LiteralWalk<V> {
249
+ const node = literal.compilerNode;
250
+ const remembered = session?.walks.get(hooks.kind)?.get(node);
251
+ if (remembered) return remembered as LiteralWalk<V>;
252
+ if (walking.length >= MAX_WALK_NESTING || walking.some((open) => open.kind === hooks.kind && open.node === node)) {
253
+ cutWalks++;
254
+ const cut = emptyWalk<V>();
255
+ cut.lost = true;
256
+ return cut;
257
+ }
258
+
259
+ const cutsBefore = cutWalks;
260
+ walking.push({ kind: hooks.kind, node });
261
+ let walk: LiteralWalk<V>;
262
+ try {
263
+ walk = walkMembers(literal, hooks);
264
+ } finally {
265
+ walking.pop();
266
+ }
267
+ if (session && cutWalks === cutsBefore) {
268
+ const walks = session.walks.get(hooks.kind) ?? new Map<ts.Node, LiteralWalk<unknown>>();
269
+ session.walks.set(hooks.kind, walks);
270
+ walks.set(node, walk);
271
+ }
272
+ return walk;
273
+ }
274
+
275
+ function emptyWalk<V>(): LiteralWalk<V> {
276
+ return { entries: new Map(), unread: new Map(), cleared: new Set(), lost: false, inherits: false };
277
+ }
278
+
279
+ function walkMembers<V>(literal: ObjectLiteralExpression, hooks: LiteralWalkHooks<V>): LiteralWalk<V> {
280
+ const walk = emptyWalk<V>();
281
+ for (const property of literal.getProperties()) {
282
+ spendWork();
283
+ const spread = property.asKind(SyntaxKind.SpreadAssignment);
284
+ if (spread) {
285
+ const expression = spread.getExpression();
286
+ const source = holdsNothing(expression) ? SPREADS_NOTHING : hooks.spread(expression);
287
+ if (source === SPREADS_NOTHING) continue;
288
+ if (source) applySpread(walk, walkLiteral(source, hooks), property);
289
+ else writeUnnamed(walk, property);
290
+ continue;
291
+ }
292
+
293
+ const member = namedMember(property);
294
+ const key = member && propertyKey(member);
295
+ if (!member || key === undefined) {
296
+ writeUnnamed(walk, property);
297
+ continue;
298
+ }
299
+ if (setsPrototype(member)) {
300
+ if (!inheritsNothing(member)) walk.inherits = true;
301
+ continue;
302
+ }
303
+ if (key === '__proto__') {
304
+ writeKey(walk, key, undefined, 'reserved');
305
+ continue;
306
+ }
307
+ const value = writtenValue(member);
308
+ if (value) writeKey(walk, key, hooks.read(value), 'value');
309
+ else writeKey(walk, key, undefined, member.isKind(SyntaxKind.SetAccessor) ? 'setter' : 'code');
310
+ }
311
+ return walk;
312
+ }
313
+
314
+ /**
315
+ * Whether the walked object may hold a key the walk could not read — unread,
316
+ * cleared, or reachable through a write it cannot name or a prototype —
317
+ * as opposed to one it provably does not write at all.
318
+ */
319
+ export function mayHoldUnread<V>(walk: LiteralWalk<V>, key: string): boolean {
320
+ return !walk.entries.has(key) && (walk.unread.has(key) || walk.lost || walk.inherits);
321
+ }
322
+
323
+ /** One write of a key: the last write wins, and one the owner could not read takes the earlier value with it. */
324
+ function writeKey<V>(walk: LiteralWalk<V>, key: string, value: V | undefined, why: UnreadWrite): void {
325
+ walk.cleared.delete(key);
326
+ if (value === undefined) {
327
+ walk.entries.delete(key);
328
+ walk.unread.set(key, why);
329
+ } else {
330
+ walk.unread.delete(key);
331
+ walk.entries.set(key, value);
332
+ }
333
+ }
334
+
335
+ /** A write the walk cannot name, made by the member `at`, which may be any key — so every key written before it is cleared. */
336
+ function writeUnnamed<V>(walk: LiteralWalk<V>, at: Node): void {
337
+ for (const key of [...walk.entries.keys(), ...walk.unread.keys()]) walk.cleared.add(key);
338
+ walk.entries.clear();
339
+ walk.unread.clear();
340
+ walk.lost = true;
341
+ walk.lostAt = at;
342
+ }
343
+
344
+ /**
345
+ * A spread source's walk, applied where the spread sits. A spread copies the
346
+ * source's own keys only, so its prototype is not carried over; a key the
347
+ * source could not name may be any key here too.
348
+ */
349
+ function applySpread<V>(walk: LiteralWalk<V>, source: LiteralWalk<V>, spread: Node): void {
350
+ if (source.lost) {
351
+ writeUnnamed(walk, spread);
352
+ for (const key of source.cleared) walk.cleared.add(key);
353
+ }
354
+ for (const [key, why] of source.unread) writeKey(walk, key, undefined, why);
355
+ for (const [key, value] of source.entries) writeKey(walk, key, value, 'value');
356
+ }
357
+
358
+ /** An object read as plain data, and whether any of its entries — at any depth — had to be left out. */
359
+ export interface ObjectReading {
360
+ value: Record<string, JsonValue>;
361
+ dropped: boolean;
362
+ }
363
+
364
+ /**
365
+ * Plain data written in place: values read as written and names not followed,
366
+ * so a spread merges only an object written where it sits; a spread of
367
+ * anything else may write any key, and clears what came before it.
368
+ */
369
+ const WRITTEN_DATA: LiteralWalkHooks<ValueReading> = {
370
+ kind: 'plain data',
371
+ read: literalValueReading,
372
+ spread: asObjectLiteral,
373
+ };
374
+
375
+ /**
376
+ * Plain data with every name in it followed to the `const` it stands for — an
377
+ * annotation written `ai: { ...BASE_AI, schema: SCHEMA }` reads the same as
378
+ * one written out in place.
379
+ */
380
+ const NAMED_DATA: LiteralWalkHooks<ValueReading> = {
381
+ kind: 'plain data, names followed',
382
+ read: (value) => {
383
+ const literal = resolveObjectLiteral(value);
384
+ return literal ? objectReading(literal, NAMED_DATA) : resolveLiteralValueReading(value);
385
+ },
386
+ spread: resolveObjectLiteral,
387
+ };
388
+
389
+ /**
390
+ * An object read as plain data, with the names in it followed: the part that
391
+ * read, and whether anything was left out — a computed value, a method, a key
392
+ * it could not spell, a spread or a name it could not follow, a prototype.
393
+ * Every key the value holds is the runtime's own last write of it, so a caller
394
+ * that owes an admission makes one for the rest rather than presenting a wrong
395
+ * value. Undefined where the node does not lead to an object literal at all.
396
+ */
397
+ export function literalObjectReading(object: Node): ObjectReading | undefined {
398
+ const literal = resolveObjectLiteral(object);
399
+ return literal && objectReading(literal, NAMED_DATA);
400
+ }
401
+
402
+ /** Plain data written in place, walked; the drop is carried to the reading holding it. */
403
+ function readObject(literal: ObjectLiteralExpression, drops: Drops): Record<string, JsonValue> {
404
+ const reading = objectReading(literal, WRITTEN_DATA);
405
+ if (reading.dropped) drops.dropped = true;
406
+ return reading.value;
407
+ }
408
+
409
+ function objectReading(literal: ObjectLiteralExpression, hooks: LiteralWalkHooks<ValueReading>): ObjectReading {
410
+ const walk = walkLiteral(literal, hooks);
411
+ let dropped = !walkIsWhole(walk);
412
+ const entries: [string, JsonValue][] = [];
413
+ for (const [key, reading] of walk.entries) {
414
+ // The walk is remembered, but each place the object is named gets its own
415
+ // copy, so every entry copied costs work.
416
+ spendWork();
417
+ if (reading.dropped) dropped = true;
418
+ entries.push([key, reading.value]);
419
+ }
420
+ // `fromEntries` defines each key rather than assigning it, and the walk never
421
+ // hands over `__proto__`, so the record keeps its own prototype.
422
+ return { value: Object.fromEntries(entries), dropped };
423
+ }
424
+
425
+ /**
426
+ * The JSON value an expression amounts to, following a name to its `const`
427
+ * declaration when the value is not written in place.
428
+ *
429
+ * `options: sizeOptions` is the shape this exists for: the legal values are two
430
+ * lines up, and reading the name as unreadable loses them. Only `const`
431
+ * declarations count — a `let` can be reassigned after the line being read.
432
+ * `LABELS.hero` is read out of the object `LABELS` stands for, the last write
433
+ * of the key winning as it does at runtime; a key a spread, getter or unknown
434
+ * computed name may have overwritten is no value at all.
435
+ *
436
+ * A value with a part left out is no value here, as for `literalValue`;
437
+ * `resolveLiteralValueReading` keeps the part that read.
438
+ *
439
+ * Known limits, both inherited from the walk: two barrels exporting the same
440
+ * name resolve to whichever one the compiler picked, and a `const` array is
441
+ * followed rather than frozen — `const o = [...]; o.push(x)` elsewhere in the
442
+ * module reads here as the value before the push.
443
+ */
444
+ export function resolveLiteralValue(node: Node): JsonValue | undefined {
445
+ const reading = resolveLiteralValueReading(node);
446
+ return reading && !reading.dropped ? reading.value : undefined;
447
+ }
448
+
449
+ /**
450
+ * `resolveLiteralValue`, keeping the part that read when something had to be
451
+ * left out, and saying so — `items: ITEMS` where each item's `id` is computed
452
+ * — so an owner admits the gap instead of presenting the rest as the whole.
453
+ */
454
+ export function resolveLiteralValueReading(node: Node): ValueReading | undefined {
455
+ const direct = literalValueReading(node);
456
+ if (direct) return direct;
457
+ const initializer = resolveValueExpression(node);
458
+ return initializer ? literalValueReading(initializer) : undefined;
459
+ }