@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,424 @@
1
+ import { Node, SyntaxKind, VariableDeclarationKind, } from 'ts-morph';
2
+ import { MAX_OUTPUT_BYTES, OutputBudgetExceeded, spendWork } from './reading-budget.js';
3
+ import { asObjectLiteral, literalPrimitive, namedMember, unwrapExpression, writtenValue, } from './syntax.js';
4
+ /**
5
+ * A backstop on the walk below, shared by all three things a name is followed
6
+ * to here: a component's object literal, a value, and a wrapper call.
7
+ *
8
+ * Barrels are nearly free: the compiler collapses a whole re-export chain into
9
+ * a single alias hop, so even a nine-deep stack of index files arrives in
10
+ * three. Renames are not — `const Hero = HeroBase` costs a hop of its own, and
11
+ * an imported one costs two — which leaves room for roughly a single
12
+ * cross-file rename beyond the barrel before the walk gives up and the caller
13
+ * reports the name unresolved. Reading a key out of an object — `LABELS.hero`,
14
+ * or a spread on the way to it — costs a hop like a rename does.
15
+ *
16
+ * There is a limit at all because the graph being walked comes from someone
17
+ * else's source, and a reader of arbitrary configs should not depend on the
18
+ * compiler to stop it.
19
+ */
20
+ const MAX_HOPS = 5;
21
+ /**
22
+ * Follows an identifier to the object literal it names, across files and
23
+ * through barrel re-exports.
24
+ *
25
+ * Every real Puck config writes `components: { Hero, Badge }`, so the
26
+ * definitions live in per-component modules behind an index that re-exports
27
+ * them. Resolving that chain is the difference between reading a config and
28
+ * reading a list of names.
29
+ *
30
+ * A member access — `NESTED.fields` — is read by finding the object the left
31
+ * side stands for and looking the key up in it, never by asking the compiler
32
+ * what the key's declaration is: that answer comes from the TYPE, and a name
33
+ * typed `typeof Base` would be handed Base's value.
34
+ *
35
+ * Returns undefined when the chain cannot be followed — an npm package with no
36
+ * types, a parameter, or a component a wrapper builds (`withLayout(Inner)`,
37
+ * which both of our own sites use) — so the caller can record the component as
38
+ * unresolved instead of reporting it as having no fields.
39
+ *
40
+ * Known limit: when two barrels `export *` the same name, the compiler picks
41
+ * one and this walk relays that pick without noticing the collision.
42
+ */
43
+ export function resolveObjectLiteral(node) {
44
+ // A caller holding `Flex: { ...Flex }` hands over the spread source, which is
45
+ // sometimes the literal itself rather than a name for one.
46
+ return fromExpression(node, MAX_HOPS, asObjectLiteral);
47
+ }
48
+ /**
49
+ * A call expression an identifier names — `withLayout(GridInternal)` behind
50
+ * `export const Grid = withLayout(GridInternal)`. The wrapper reader's entry.
51
+ *
52
+ * Same limits as the walk above: a name exported by two barrels resolves to
53
+ * the compiler's pick, and only a `const` is followed.
54
+ */
55
+ export function resolveCallExpression(node) {
56
+ const unwrapped = unwrapExpression(node);
57
+ return (unwrapped.asKind(SyntaxKind.CallExpression) ?? resolveValueExpression(unwrapped)?.asKind(SyntaxKind.CallExpression));
58
+ }
59
+ /**
60
+ * The expression a name was declared as, once every rename and member access
61
+ * between here and the declaration has been followed. Undefined when the name
62
+ * is not a `const`, or when the walk runs out of hops.
63
+ */
64
+ export function resolveValueExpression(node) {
65
+ return fromExpression(node, MAX_HOPS, terminalExpression);
66
+ }
67
+ /**
68
+ * The end of a chain of names: any expression that is not itself another name
69
+ * or a key read out of one. Returning undefined for those is what tells the
70
+ * walk to keep going.
71
+ */
72
+ function terminalExpression(expression) {
73
+ const unwrapped = unwrapExpression(expression);
74
+ return Node.isIdentifier(unwrapped) || isMemberAccess(unwrapped) ? undefined : unwrapped;
75
+ }
76
+ /** `x.y` or `x['y']` — a key read out of whatever `x` stands for. */
77
+ function isMemberAccess(node) {
78
+ return Node.isPropertyAccessExpression(node) || Node.isElementAccessExpression(node);
79
+ }
80
+ /** What an expression amounts to, whether written in place, named, or read out of a named object. */
81
+ function fromExpression(expression, hops, reading) {
82
+ // `satisfies`, `as const` and parentheses keep the value one level down.
83
+ const read = reading(expression);
84
+ if (read)
85
+ return read;
86
+ const unwrapped = unwrapExpression(expression);
87
+ if (Node.isIdentifier(unwrapped))
88
+ return fromSymbol(unwrapped.getSymbol(), hops, reading);
89
+ if (isMemberAccess(unwrapped))
90
+ return fromMember(unwrapped, hops, reading);
91
+ return undefined;
92
+ }
93
+ /**
94
+ * Each declaration of a name is a candidate; when none of them reads, the name
95
+ * is an alias for another one — an import, a re-export — and the hunt
96
+ * continues at what it points at.
97
+ *
98
+ * The last candidate wins, because that is the declaration whose value the name
99
+ * carries by the time anything reads it.
100
+ */
101
+ function fromSymbol(symbol, hops, reading) {
102
+ if (!symbol || hops <= 0)
103
+ return undefined;
104
+ let found;
105
+ for (const declaration of symbol.getDeclarations()) {
106
+ // `components: { Hero }` writes a property and a value at once, and the
107
+ // checker reports the property — whose only declaration is this shorthand.
108
+ // The value it stands for is a separate symbol, and the only way onward: a
109
+ // property symbol is an alias for nothing, so there is nothing to fall back
110
+ // to when its value cannot be followed. Only the shorthand's own name
111
+ // reaches here: a member access never asks the checker for its symbol.
112
+ if (Node.isShorthandPropertyAssignment(declaration)) {
113
+ return fromSymbol(declaration.getValueSymbol(), hops - 1, reading);
114
+ }
115
+ const read = fromDeclaration(declaration, hops, reading);
116
+ if (read)
117
+ found = read;
118
+ }
119
+ if (found)
120
+ return found;
121
+ return fromSymbol(symbol.getAliasedSymbol(), hops - 1, reading);
122
+ }
123
+ /**
124
+ * What a single declaration of a name settles on.
125
+ *
126
+ * Only `const` is trusted: a `let` or `var` holds whatever was assigned to it
127
+ * last, which is code this reader never sees, so its initializer describes the
128
+ * name at one moment rather than at the moment Puck reads it.
129
+ */
130
+ function fromDeclaration(declaration, hops, reading) {
131
+ if (Node.isVariableDeclaration(declaration)) {
132
+ if (declaration.getVariableStatement()?.getDeclarationKind() !== VariableDeclarationKind.Const)
133
+ return undefined;
134
+ const initializer = declaration.getInitializer();
135
+ if (!initializer)
136
+ return undefined;
137
+ return fromExpression(initializer, hops - 1, reading);
138
+ }
139
+ // `export default { … }`, paired with `import Hero from './Hero'`: the import
140
+ // aliases the module's default, and this is what that default is written as.
141
+ if (Node.isExportAssignment(declaration)) {
142
+ return fromExpression(declaration.getExpression(), hops - 1, reading);
143
+ }
144
+ return undefined;
145
+ }
146
+ /**
147
+ * What `x.y` amounts to: the key `y` looked up in the object `x` stands for.
148
+ *
149
+ * A namespace import is the one left side the compiler's own answer is right
150
+ * for — `sections.Hero` names an export, and an export is a declaration, not a
151
+ * type's memory of one.
152
+ */
153
+ function fromMember(access, hops, reading) {
154
+ if (hops <= 0)
155
+ return undefined;
156
+ if (Node.isPropertyAccessExpression(access) && namesModule(access.getExpression())) {
157
+ return fromSymbol(access.getNameNode().getSymbol(), hops, reading);
158
+ }
159
+ const key = Node.isPropertyAccessExpression(access)
160
+ ? access.getName()
161
+ : expressionKey(access.getArgumentExpressionOrThrow());
162
+ if (key === undefined)
163
+ return undefined;
164
+ const object = fromExpression(access.getExpression(), hops, asObjectLiteral);
165
+ const value = object && keyValue(object, key, hops - 1);
166
+ return value ? fromExpression(value, hops - 1, reading) : undefined;
167
+ }
168
+ /** Whether an expression is the name of a module — `import * as sections`, or a `namespace` block. */
169
+ function namesModule(expression) {
170
+ const identifier = unwrapExpression(expression).asKind(SyntaxKind.Identifier);
171
+ const symbol = identifier?.getSymbol();
172
+ const target = symbol?.isAlias() ? symbol.getAliasedSymbol() : symbol;
173
+ return (target
174
+ ?.getDeclarations()
175
+ .some((declaration) => Node.isSourceFile(declaration) || Node.isModuleDeclaration(declaration)) ?? false);
176
+ }
177
+ /**
178
+ * The node an object literal assigns to one key, seen through the spreads it
179
+ * applies — undefined when the literal does not provably assign one.
180
+ */
181
+ function keyValue(literal, key, hops) {
182
+ const found = walkKey(literal, key, hops, (expression) => fromExpression(expression, hops - 1, asObjectLiteral));
183
+ return found === 'absent' || found === 'unknown' ? undefined : found;
184
+ }
185
+ /**
186
+ * What an object literal assigns to one key, by the runtime's own rule, walked
187
+ * in source order: the last write of the key wins. A spread that cannot be
188
+ * followed, a computed name that cannot be resolved, and a getter or method
189
+ * are all writes this walk cannot read — any of them may be the key, so the
190
+ * answer becomes unknown until a later plain write settles it. `__proto__`
191
+ * hands the object a prototype, so a key it never writes itself may still be
192
+ * inherited.
193
+ *
194
+ * Spreads lead wherever `spreadSource` takes them — by default to the names
195
+ * they stand for; a caller with a function's parameters in scope hands in its
196
+ * own, so `{ ...config }` reaches the argument the call passed.
197
+ */
198
+ export function lookUpKey(literal, key, spreadSource = (expression) => fromExpression(expression, MAX_HOPS, asObjectLiteral)) {
199
+ return walkKey(literal, key, MAX_HOPS, spreadSource);
200
+ }
201
+ /** `lookUpKey`, spending one hop per spread followed so a spread cycle ends as unknown. */
202
+ function walkKey(literal, key, hops, spreadSource) {
203
+ let found = 'absent';
204
+ let inherits = false;
205
+ for (const property of literal.getProperties()) {
206
+ spendWork();
207
+ const spread = property.asKind(SyntaxKind.SpreadAssignment);
208
+ if (spread) {
209
+ const source = hops > 0 ? spreadSource(spread.getExpression()) : undefined;
210
+ const inherited = source ? walkKey(source, key, hops - 1, spreadSource) : 'unknown';
211
+ if (inherited !== 'absent')
212
+ found = inherited;
213
+ continue;
214
+ }
215
+ const member = namedMember(property);
216
+ if (!member) {
217
+ found = 'unknown';
218
+ continue;
219
+ }
220
+ const name = propertyKey(member);
221
+ if (name === undefined) {
222
+ found = 'unknown';
223
+ continue;
224
+ }
225
+ if (setsPrototype(member)) {
226
+ inherits = true;
227
+ continue;
228
+ }
229
+ if (name !== key)
230
+ continue;
231
+ if (Node.isPropertyAssignment(member))
232
+ found = member.getInitializerOrThrow();
233
+ else if (Node.isShorthandPropertyAssignment(member))
234
+ found = member.getNameNode();
235
+ else
236
+ found = 'unknown';
237
+ }
238
+ return found === 'absent' && inherits ? 'unknown' : found;
239
+ }
240
+ /**
241
+ * Computed names currently being worked out. A name that leads back to the
242
+ * object it sits in — `const x = { [x.k]: 1 }` — asks for itself again before
243
+ * it has an answer, and is no key rather than a loop.
244
+ */
245
+ const resolvingKeys = new Set();
246
+ /**
247
+ * The written-down name of a member, or `undefined` when the source does not
248
+ * spell one out. A computed key is that key only when its expression stands
249
+ * for a `const` string or number — `[K]` beside `const K = 'max'`, or a sum of
250
+ * such parts like `['resolve' + 'Data']`. Any other `[k]` is skipped rather than
251
+ * read from its text: `"[k]"` would be an invented field name, the worst guess
252
+ * this module can make, because it looks exactly like a real one.
253
+ *
254
+ * Every shape a name can be written in is accepted — `resolveData: fn`,
255
+ * `{ resolveData }`, `resolveData() { … }`, `get fields() { … }` — because a
256
+ * caller that reads only assignments loses the rest, and a key it never sees is
257
+ * a key it cannot report as unread.
258
+ */
259
+ export function propertyKey(member) {
260
+ const name = member.getNameNode();
261
+ // getLiteralValue, not the text: it resolves escapes, so `'it\'s'` is a key
262
+ // named `it's` rather than one carrying a stray backslash.
263
+ const quoted = name.asKind(SyntaxKind.StringLiteral);
264
+ if (quoted)
265
+ return quoted.getLiteralValue();
266
+ // The runtime spells a number written as a key the way `String` does: `{
267
+ // 1e21: … }` holds the key `1e+21`, `{ 0x10: … }` the key `16`.
268
+ const numeric = name.asKind(SyntaxKind.NumericLiteral);
269
+ if (numeric)
270
+ return String(Number(numeric.compilerNode.text));
271
+ const identifier = name.asKind(SyntaxKind.Identifier);
272
+ if (identifier)
273
+ return identifier.getText();
274
+ const computed = name.asKind(SyntaxKind.ComputedPropertyName);
275
+ if (computed)
276
+ return expressionKey(computed.getExpression());
277
+ return undefined;
278
+ }
279
+ /**
280
+ * The property key an expression spells — the `K` of `[K]` or of `obj[K]` —
281
+ * when it stands for a `const` string or number. Undefined for anything the
282
+ * reader would have to run to know.
283
+ */
284
+ export function expressionKey(expression) {
285
+ if (resolvingKeys.has(expression.compilerNode))
286
+ return undefined;
287
+ resolvingKeys.add(expression.compilerNode);
288
+ try {
289
+ const key = constantKey(expression);
290
+ return key === undefined ? undefined : String(key);
291
+ }
292
+ finally {
293
+ resolvingKeys.delete(expression.compilerNode);
294
+ }
295
+ }
296
+ /**
297
+ * A `const` string or number, or a `+` of them folded the way the runtime folds
298
+ * it — written in place, or behind a `const` whose initializer is itself one:
299
+ * `const M = 'He' + 'ro'` makes `[M]` the key `Hero`, as `['He' + 'ro']` is.
300
+ *
301
+ * Folded with a stack of its own rather than by recursion: a sum twenty
302
+ * thousand parts long is one line of source, and recursing into it exhausts
303
+ * the call stack long before the parts run out. Each part, and each `+`, is
304
+ * work the reading pays for, so a key built by naming one sum from another,
305
+ * over and over, costs what folding it costs. A name folded past the length a
306
+ * whole manifest may run to is refused there, before it grows any longer.
307
+ */
308
+ function constantKey(expression, hops = MAX_CONST_HOPS) {
309
+ // A `+` is met twice: first to queue its two sides, then to fold what they came to.
310
+ const pending = [{ node: expression, folding: false }];
311
+ const folded = [];
312
+ for (let next = pending.pop(); next; next = pending.pop()) {
313
+ spendWork();
314
+ const unwrapped = unwrapExpression(next.node);
315
+ const sum = unwrapped.asKind(SyntaxKind.BinaryExpression);
316
+ if (!sum) {
317
+ const part = constantPart(unwrapped, hops);
318
+ if (part === undefined)
319
+ return undefined;
320
+ folded.push(part);
321
+ }
322
+ else if (sum.getOperatorToken().getKind() !== SyntaxKind.PlusToken) {
323
+ return undefined;
324
+ }
325
+ else if (next.folding) {
326
+ const right = folded.pop();
327
+ const left = folded.pop();
328
+ const joined = typeof left === 'number' && typeof right === 'number' ? left + right : `${left}${right}`;
329
+ // A character is never less than a byte of UTF-8, so a name this long is
330
+ // more than the manifest may carry however it is spelled.
331
+ if (typeof joined === 'string' && joined.length > MAX_OUTPUT_BYTES) {
332
+ throw new OutputBudgetExceeded(`a computed name would run to more than ${MAX_OUTPUT_BYTES.toLocaleString('en-US')} characters, more ` +
333
+ 'than a whole manifest may, so it was not produced — usually a string summed with itself through names ' +
334
+ 'that each sum the one before; summing it fewer times keeps it readable');
335
+ }
336
+ folded.push(joined);
337
+ }
338
+ else {
339
+ pending.push({ node: sum, folding: true }, { node: sum.getRight(), folding: false }, { node: sum.getLeft(), folding: false });
340
+ }
341
+ }
342
+ return folded[0];
343
+ }
344
+ /** One part of a sum: a value written in place or named, or a `const` whose initializer is a key of its own. */
345
+ function constantPart(expression, hops) {
346
+ // A key only needs a primitive. Resolving its source must not invoke the JSON
347
+ // reader, which itself depends on these key and reference rules.
348
+ const target = resolveValueExpression(expression);
349
+ const value = target && literalPrimitive(target);
350
+ if (typeof value === 'string' || typeof value === 'number')
351
+ return value;
352
+ const initializer = hops > 0 ? primitiveInitializer(expression) : undefined;
353
+ return initializer ? constantKey(initializer, hops - 1) : undefined;
354
+ }
355
+ /**
356
+ * How many names a primitive is followed through here — a string key, or an
357
+ * `undefined` — before the reader gives up and treats it as unknown. Neither
358
+ * can be written to after its `const` is declared, which is why these two
359
+ * follow names on their own terms rather than through `resolve-reference`.
360
+ */
361
+ const MAX_CONST_HOPS = 5;
362
+ /**
363
+ * The initializer of the `const` a name stands for, across an import or a
364
+ * re-export. Undefined for anything else — a `let`, a parameter, a global —
365
+ * because only a `const` holds what its declaration says.
366
+ */
367
+ function primitiveInitializer(expression) {
368
+ const identifier = expression.asKind(SyntaxKind.Identifier);
369
+ if (!identifier)
370
+ return undefined;
371
+ // A shorthand's name is a property to the checker; the value it stands for
372
+ // is a symbol of its own.
373
+ const shorthand = identifier.getParentIfKind(SyntaxKind.ShorthandPropertyAssignment);
374
+ let symbol = shorthand?.getNameNode() === identifier ? shorthand.getValueSymbol() : identifier.getSymbol();
375
+ for (let hop = 0; symbol && hop < MAX_CONST_HOPS; hop++) {
376
+ const declarations = symbol.getDeclarations();
377
+ if (declarations.length === 0 || !symbol.isAlias()) {
378
+ const declaration = declarations.length === 1 ? declarations[0]?.asKind(SyntaxKind.VariableDeclaration) : undefined;
379
+ if (declaration?.getVariableStatement()?.getDeclarationKind() !== VariableDeclarationKind.Const)
380
+ return undefined;
381
+ return declaration.getInitializer();
382
+ }
383
+ symbol = symbol.getAliasedSymbol();
384
+ }
385
+ return undefined;
386
+ }
387
+ /**
388
+ * Whether an expression provably holds no value at all: `null`, `undefined`,
389
+ * `void 0`, or a `const` bound to one of them. Spread, such a value writes no
390
+ * key; written to a behaviour key, it leaves Puck nothing to run.
391
+ *
392
+ * `undefined` counts only as the global: a parameter or a local may be named
393
+ * `undefined` too, and holds whatever was bound to it.
394
+ */
395
+ export function holdsNothing(node, hops = MAX_CONST_HOPS) {
396
+ const expression = unwrapExpression(node);
397
+ if (expression.isKind(SyntaxKind.NullKeyword) || expression.isKind(SyntaxKind.VoidExpression))
398
+ return true;
399
+ const identifier = expression.asKind(SyntaxKind.Identifier);
400
+ if (!identifier)
401
+ return false;
402
+ if (identifier.getText() === 'undefined' && identifier.getSymbol()?.getDeclarations().length === 0)
403
+ return true;
404
+ const initializer = hops > 0 ? primitiveInitializer(identifier) : undefined;
405
+ return initializer !== undefined && holdsNothing(initializer, hops - 1);
406
+ }
407
+ /**
408
+ * Whether a member hands its object a prototype rather than a key: `__proto__:
409
+ * base`, written as a plain name or a string. The object then inherits every
410
+ * key it does not write itself, which no reading of its text can see. Written
411
+ * computed — `['__proto__']: …` — or as a shorthand, it is an ordinary key.
412
+ */
413
+ export function setsPrototype(member) {
414
+ if (!member.isKind(SyntaxKind.PropertyAssignment))
415
+ return false;
416
+ const name = member.getNameNode();
417
+ return !name.isKind(SyntaxKind.ComputedPropertyName) && propertyKey(member) === '__proto__';
418
+ }
419
+ /** `__proto__: null` — a prototype set to nothing, which leaves the object nothing to inherit. */
420
+ export function inheritsNothing(member) {
421
+ const value = writtenValue(member);
422
+ return value !== undefined && holdsNothing(value);
423
+ }
424
+ //# sourceMappingURL=source-reference.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source-reference.js","sourceRoot":"","sources":["../../../../src/puck-manifest/source-reference.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,IAAI,EAGJ,UAAU,EAGV,uBAAuB,GACxB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACxF,OAAO,EACL,eAAe,EACf,gBAAgB,EAEhB,WAAW,EACX,gBAAgB,EAChB,YAAY,GACb,MAAM,aAAa,CAAC;AAErB;;;;;;;;;;;;;;;GAeG;AACH,MAAM,QAAQ,GAAG,CAAC,CAAC;AAgBnB;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAAU;IAC7C,8EAA8E;IAC9E,2DAA2D;IAC3D,OAAO,cAAc,CAAC,IAAI,EAAE,QAAQ,EAAE,eAAe,CAAC,CAAC;AACzD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAAU;IAC9C,MAAM,SAAS,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACzC,OAAO,CACL,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC,cAAc,CAAC,IAAI,sBAAsB,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,cAAc,CAAC,CACpH,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CAAC,IAAU;IAC/C,OAAO,cAAc,CAAC,IAAI,EAAE,QAAQ,EAAE,kBAAkB,CAAC,CAAC;AAC5D,CAAC;AAED;;;;GAIG;AACH,SAAS,kBAAkB,CAAC,UAAgB;IAC1C,MAAM,SAAS,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC;IAC/C,OAAO,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,cAAc,CAAC,SAAS,CAAC,CAAC,CA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UAAU,CAAC,UAAU,CAAC,CAAC;IAC5D,IAAI,CAAC,UAAU;QAAE,OAAO,KAAK,CAAC;IAC9B,IAAI,UAAU,CAAC,OAAO,EAAE,KAAK,WAAW,IAAI,UAAU,CAAC,SAAS,EAAE,EAAE,eAAe,EAAE,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAChH,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC5E,OAAO,WAAW,KAAK,SAAS,IAAI,YAAY,CAAC,WAAW,EAAE,IAAI,GAAG,CAAC,CAAC,CAAC;AAC1E,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,MAAmB;IAC/C,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,kBAAkB,CAAC;QAAE,OAAO,KAAK,CAAC;IAChE,MAAM,IAAI,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;IAClC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,oBAAoB,CAAC,IAAI,WAAW,CAAC,MAAM,CAAC,KAAK,WAAW,CAAC;AAC9F,CAAC;AAED,kGAAkG;AAClG,MAAM,UAAU,eAAe,CAAC,MAAmB;IACjD,MAAM,KAAK,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;IACnC,OAAO,KAAK,KAAK,SAAS,IAAI,YAAY,CAAC,KAAK,CAAC,CAAC;AACpD,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { type GetAccessorDeclaration, type MethodDeclaration, type Node, type ObjectLiteralExpression, type PropertyAssignment, type SetAccessorDeclaration, type ShorthandPropertyAssignment } from 'ts-morph';
2
+ /**
3
+ * Strips the type-only wrappers around an expression until the value itself is
4
+ * reached. Configs are habitually written `… satisfies Config` or `… as const`,
5
+ * and a reader blind to the wrapper reads them as absent rather than as the
6
+ * object they plainly are.
7
+ */
8
+ export declare function unwrapExpression(node: Node): Node;
9
+ /** The object literal an expression amounts to, seen through its type wrappers. */
10
+ export declare function asObjectLiteral(node: Node): ObjectLiteralExpression | undefined;
11
+ /** A written JSON primitive, without following names or traversing containers. */
12
+ export declare function literalPrimitive(node: Node): string | number | boolean | null | undefined;
13
+ /** Every shape a named member of an object literal can be written in. */
14
+ export type NamedMember = PropertyAssignment | ShorthandPropertyAssignment | MethodDeclaration | GetAccessorDeclaration | SetAccessorDeclaration;
15
+ /**
16
+ * An object literal's member as one node a reader can ask for a key, or
17
+ * undefined for a spread. Every reader walking a literal asks this rather than
18
+ * listing the kinds itself, because a reader that forgets one — a setter, say —
19
+ * walks past a write that still replaces the key at runtime.
20
+ */
21
+ export declare function namedMember(property: Node): NamedMember | undefined;
22
+ /**
23
+ * The node a member hands over as its value: what `key: value` assigns, or the
24
+ * name a shorthand stands for — `{ options }` means `options: options`, and is
25
+ * followed the same way. Undefined for a method or an accessor, which carry
26
+ * code rather than a value.
27
+ */
28
+ export declare function writtenValue(member: NamedMember): Node | undefined;
29
+ //# sourceMappingURL=syntax.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"syntax.d.ts","sourceRoot":"","sources":["../../../../src/puck-manifest/syntax.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,EACtB,KAAK,IAAI,EACT,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAC3B,KAAK,2BAA2B,EAEjC,MAAM,UAAU,CAAC;AAElB;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAQjD;AAED,mFAAmF;AACnF,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,GAAG,uBAAuB,GAAG,SAAS,CAE/E;AAED,kFAAkF;AAClF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAyBzF;AAUD,yEAAyE;AACzE,MAAM,MAAM,WAAW,GACnB,kBAAkB,GAClB,2BAA2B,GAC3B,iBAAiB,GACjB,sBAAsB,GACtB,sBAAsB,CAAC;AAE3B;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,IAAI,GAAG,WAAW,GAAG,SAAS,CAQnE;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,CAKlE"}
@@ -0,0 +1,79 @@
1
+ import { SyntaxKind, } from 'ts-morph';
2
+ /**
3
+ * Strips the type-only wrappers around an expression until the value itself is
4
+ * reached. Configs are habitually written `… satisfies Config` or `… as const`,
5
+ * and a reader blind to the wrapper reads them as absent rather than as the
6
+ * object they plainly are.
7
+ */
8
+ export function unwrapExpression(node) {
9
+ const wrapper = node.asKind(SyntaxKind.AsExpression) ??
10
+ node.asKind(SyntaxKind.SatisfiesExpression) ??
11
+ node.asKind(SyntaxKind.ParenthesizedExpression) ??
12
+ node.asKind(SyntaxKind.TypeAssertionExpression) ??
13
+ node.asKind(SyntaxKind.NonNullExpression);
14
+ return wrapper ? unwrapExpression(wrapper.getExpression()) : node;
15
+ }
16
+ /** The object literal an expression amounts to, seen through its type wrappers. */
17
+ export function asObjectLiteral(node) {
18
+ return unwrapExpression(node).asKind(SyntaxKind.ObjectLiteralExpression);
19
+ }
20
+ /** A written JSON primitive, without following names or traversing containers. */
21
+ export function literalPrimitive(node) {
22
+ const expression = unwrapExpression(node);
23
+ const stringLiteral = expression.asKind(SyntaxKind.StringLiteral) ?? expression.asKind(SyntaxKind.NoSubstitutionTemplateLiteral);
24
+ if (stringLiteral)
25
+ return stringLiteral.getLiteralValue();
26
+ // The compiler hands a number's text over normalized — `1e21` as `1e+21`,
27
+ // `0.0000001` as `1e-7`, `0x10` as `16` — and `getLiteralValue` parses text
28
+ // without a dot as an integer, reading the first two as 1. `Number` reads
29
+ // the whole of it.
30
+ const numeric = expression.asKind(SyntaxKind.NumericLiteral);
31
+ if (numeric)
32
+ return finite(Number(numeric.compilerNode.text));
33
+ // Negative numbers parse as a prefix-unary expression, not a numeric literal.
34
+ const unary = expression.asKind(SyntaxKind.PrefixUnaryExpression);
35
+ if (unary && unary.getOperatorToken() === SyntaxKind.MinusToken) {
36
+ const operand = unary.getOperand().asKind(SyntaxKind.NumericLiteral);
37
+ if (operand)
38
+ return finite(-Number(operand.compilerNode.text));
39
+ return undefined;
40
+ }
41
+ if (expression.isKind(SyntaxKind.TrueKeyword))
42
+ return true;
43
+ if (expression.isKind(SyntaxKind.FalseKeyword))
44
+ return false;
45
+ if (expression.isKind(SyntaxKind.NullKeyword))
46
+ return null;
47
+ return undefined;
48
+ }
49
+ /**
50
+ * A number JSON can carry, or no value. `1e999` is Infinity at runtime, and a
51
+ * manifest would carry it as `null` — a wrong answer rather than a missing one.
52
+ */
53
+ function finite(value) {
54
+ return Number.isFinite(value) ? value : undefined;
55
+ }
56
+ /**
57
+ * An object literal's member as one node a reader can ask for a key, or
58
+ * undefined for a spread. Every reader walking a literal asks this rather than
59
+ * listing the kinds itself, because a reader that forgets one — a setter, say —
60
+ * walks past a write that still replaces the key at runtime.
61
+ */
62
+ export function namedMember(property) {
63
+ return (property.asKind(SyntaxKind.PropertyAssignment) ??
64
+ property.asKind(SyntaxKind.ShorthandPropertyAssignment) ??
65
+ property.asKind(SyntaxKind.MethodDeclaration) ??
66
+ property.asKind(SyntaxKind.GetAccessor) ??
67
+ property.asKind(SyntaxKind.SetAccessor));
68
+ }
69
+ /**
70
+ * The node a member hands over as its value: what `key: value` assigns, or the
71
+ * name a shorthand stands for — `{ options }` means `options: options`, and is
72
+ * followed the same way. Undefined for a method or an accessor, which carry
73
+ * code rather than a value.
74
+ */
75
+ export function writtenValue(member) {
76
+ return (member.asKind(SyntaxKind.PropertyAssignment)?.getInitializerOrThrow() ??
77
+ member.asKind(SyntaxKind.ShorthandPropertyAssignment)?.getNameNode());
78
+ }
79
+ //# sourceMappingURL=syntax.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"syntax.js","sourceRoot":"","sources":["../../../../src/puck-manifest/syntax.ts"],"names":[],"mappings":"AAAA,OAAO,EAQL,UAAU,GACX,MAAM,UAAU,CAAC;AAElB;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAU;IACzC,MAAM,OAAO,GACX,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,YAAY,CAAC;QACpC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,mBAAmB,CAAC;QAC3C,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,uBAAuB,CAAC;QAC/C,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,uBAAuB,CAAC;QAC/C,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC;IAC5C,OAAO,OAAO,CAAC,CAAC,CAAC,gBAAgB,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACpE,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,eAAe,CAAC,IAAU;IACxC,OAAO,gBAAgB,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,uBAAuB,CAAC,CAAC;AAC3E,CAAC;AAED,kFAAkF;AAClF,MAAM,UAAU,gBAAgB,CAAC,IAAU;IACzC,MAAM,UAAU,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAC1C,MAAM,aAAa,GACjB,UAAU,CAAC,MAAM,CAAC,UAAU,CAAC,aAAa,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,UAAU,CAAC,6BAA6B,CAAC,CAAC;IAC7G,IAAI,aAAa;QAAE,OAAO,aAAa,CAAC,eAAe,EAAE,CAAC;IAE1D,0EAA0E;IAC1E,4EAA4E;IAC5E,0EAA0E;IAC1E,mBAAmB;IACnB,MAAM,OAAO,GAAG,UAAU,CAAC,M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