@conloca/astro-cms 0.1.15 → 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.
- package/README.md +259 -247
- package/dist/internal/acorn-default.mjs +11 -3
- package/dist/internal/page-handler.astro +137 -358
- package/dist/ts/node/content.d.ts +4 -0
- package/dist/ts/node/content.d.ts.map +1 -0
- package/dist/ts/node/content.js +3 -0
- package/dist/ts/node/content.js.map +1 -0
- package/dist/ts/node/index.d.ts +9 -0
- package/dist/ts/node/index.d.ts.map +1 -0
- package/dist/ts/node/index.js +14 -0
- package/dist/ts/node/index.js.map +1 -0
- package/dist/ts/src/asset-ref-base.d.ts +3 -0
- package/dist/ts/src/asset-ref-base.d.ts.map +1 -0
- package/dist/ts/src/asset-ref-base.js +48 -0
- package/dist/ts/src/asset-ref-base.js.map +1 -0
- package/dist/ts/src/checks.d.ts +7 -0
- package/dist/ts/src/checks.d.ts.map +1 -0
- package/dist/ts/src/checks.js +7 -0
- package/dist/ts/src/checks.js.map +1 -0
- package/dist/ts/src/cms-handler.d.ts +18 -0
- package/dist/ts/src/cms-handler.d.ts.map +1 -0
- package/dist/ts/src/cms-handler.js +245 -0
- package/dist/ts/src/cms-handler.js.map +1 -0
- package/dist/ts/src/collections.d.ts +160 -0
- package/dist/ts/src/collections.d.ts.map +1 -0
- package/dist/ts/src/collections.js +170 -0
- package/dist/ts/src/collections.js.map +1 -0
- package/dist/ts/src/components/HydrationWrapper.d.ts +18 -0
- package/dist/ts/src/components/HydrationWrapper.d.ts.map +1 -0
- package/dist/ts/src/components/HydrationWrapper.js +22 -0
- package/dist/ts/src/components/HydrationWrapper.js.map +1 -0
- package/dist/ts/src/components/RenderWithFragments.d.ts +27 -0
- package/dist/ts/src/components/RenderWithFragments.d.ts.map +1 -0
- package/dist/ts/src/components/RenderWithFragments.js +133 -0
- package/dist/ts/src/components/RenderWithFragments.js.map +1 -0
- package/dist/ts/src/components/RenderWithHydration.d.ts +21 -0
- package/dist/ts/src/components/RenderWithHydration.d.ts.map +1 -0
- package/dist/ts/src/components/RenderWithHydration.js +39 -0
- package/dist/ts/src/components/RenderWithHydration.js.map +1 -0
- package/dist/ts/src/components.d.ts +4 -0
- package/dist/ts/src/components.d.ts.map +1 -0
- package/dist/ts/src/components.js +4 -0
- package/dist/ts/src/components.js.map +1 -0
- package/dist/ts/src/discovery/astro-frontmatter.d.ts +18 -0
- package/dist/ts/src/discovery/astro-frontmatter.d.ts.map +1 -0
- package/dist/ts/src/discovery/astro-frontmatter.js +25 -0
- package/dist/ts/src/discovery/astro-frontmatter.js.map +1 -0
- package/dist/ts/src/discovery/discover.d.ts +43 -0
- package/dist/ts/src/discovery/discover.d.ts.map +1 -0
- package/dist/ts/src/discovery/discover.js +87 -0
- package/dist/ts/src/discovery/discover.js.map +1 -0
- package/dist/ts/src/discovery/extract-props-ts.d.ts +41 -0
- package/dist/ts/src/discovery/extract-props-ts.d.ts.map +1 -0
- package/dist/ts/src/discovery/extract-props-ts.js +232 -0
- package/dist/ts/src/discovery/extract-props-ts.js.map +1 -0
- package/dist/ts/src/discovery/merge-registry.d.ts +58 -0
- package/dist/ts/src/discovery/merge-registry.d.ts.map +1 -0
- package/dist/ts/src/discovery/merge-registry.js +333 -0
- package/dist/ts/src/discovery/merge-registry.js.map +1 -0
- package/dist/ts/src/discovery/registry-endpoint.d.ts +27 -0
- package/dist/ts/src/discovery/registry-endpoint.d.ts.map +1 -0
- package/dist/ts/src/discovery/registry-endpoint.js +76 -0
- package/dist/ts/src/discovery/registry-endpoint.js.map +1 -0
- package/dist/ts/src/discovery/scan-components.d.ts +94 -0
- package/dist/ts/src/discovery/scan-components.d.ts.map +1 -0
- package/dist/ts/src/discovery/scan-components.js +397 -0
- package/dist/ts/src/discovery/scan-components.js.map +1 -0
- package/dist/ts/src/discovery/scan-mdx.d.ts +63 -0
- package/dist/ts/src/discovery/scan-mdx.d.ts.map +1 -0
- package/dist/ts/src/discovery/scan-mdx.js +113 -0
- package/dist/ts/src/discovery/scan-mdx.js.map +1 -0
- package/dist/ts/src/discovery/scan-overrides.d.ts +71 -0
- package/dist/ts/src/discovery/scan-overrides.d.ts.map +1 -0
- package/dist/ts/src/discovery/scan-overrides.js +34 -0
- package/dist/ts/src/discovery/scan-overrides.js.map +1 -0
- package/dist/ts/src/editor-descriptors.d.ts +31 -0
- package/dist/ts/src/editor-descriptors.d.ts.map +1 -0
- package/dist/ts/src/editor-descriptors.js +84 -0
- package/dist/ts/src/editor-descriptors.js.map +1 -0
- package/dist/ts/src/handlers/collection-content-api.d.ts +32 -0
- package/dist/ts/src/handlers/collection-content-api.d.ts.map +1 -0
- package/dist/ts/src/handlers/collection-content-api.js +166 -0
- package/dist/ts/src/handlers/collection-content-api.js.map +1 -0
- package/dist/ts/src/handlers/page-render-core.d.ts +137 -0
- package/dist/ts/src/handlers/page-render-core.d.ts.map +1 -0
- package/dist/ts/src/handlers/page-render-core.js +315 -0
- package/dist/ts/src/handlers/page-render-core.js.map +1 -0
- package/dist/ts/src/hydration.d.ts +4 -0
- package/dist/ts/src/hydration.d.ts.map +1 -0
- package/dist/ts/src/hydration.js +5 -0
- package/dist/ts/src/hydration.js.map +1 -0
- package/dist/ts/src/index.d.ts +21 -0
- package/dist/ts/src/index.d.ts.map +1 -0
- package/dist/ts/src/index.js +45 -0
- package/dist/ts/src/index.js.map +1 -0
- package/dist/ts/src/internal/declared-collections.d.ts +30 -0
- package/dist/ts/src/internal/declared-collections.d.ts.map +1 -0
- package/dist/ts/src/internal/declared-collections.js +84 -0
- package/dist/ts/src/internal/declared-collections.js.map +1 -0
- package/dist/ts/src/internal/page-collection-schema.d.ts +44 -0
- package/dist/ts/src/internal/page-collection-schema.d.ts.map +1 -0
- package/dist/ts/src/internal/page-collection-schema.js +152 -0
- package/dist/ts/src/internal/page-collection-schema.js.map +1 -0
- package/dist/ts/src/lib/content-config-guard.d.ts +11 -0
- package/dist/ts/src/lib/content-config-guard.d.ts.map +1 -0
- package/dist/ts/src/lib/content-config-guard.js +41 -0
- package/dist/ts/src/lib/content-config-guard.js.map +1 -0
- package/dist/ts/src/lib/hydration-scanner.d.ts +47 -0
- package/dist/ts/src/lib/hydration-scanner.d.ts.map +1 -0
- package/dist/ts/src/lib/hydration-scanner.js +136 -0
- package/dist/ts/src/lib/hydration-scanner.js.map +1 -0
- package/dist/{lib/hydration-script.d.mts → ts/src/lib/hydration-script.d.ts} +7 -10
- package/dist/ts/src/lib/hydration-script.d.ts.map +1 -0
- package/dist/ts/src/lib/hydration-script.js +89 -0
- package/dist/ts/src/lib/hydration-script.js.map +1 -0
- package/dist/ts/src/lib/hydration-utils.d.ts +51 -0
- package/dist/ts/src/lib/hydration-utils.d.ts.map +1 -0
- package/dist/ts/src/lib/hydration-utils.js +84 -0
- package/dist/ts/src/lib/hydration-utils.js.map +1 -0
- package/dist/ts/src/lib/resolve-locale.d.ts +15 -0
- package/dist/ts/src/lib/resolve-locale.d.ts.map +1 -0
- package/dist/ts/src/lib/resolve-locale.js +16 -0
- package/dist/ts/src/lib/resolve-locale.js.map +1 -0
- package/dist/ts/src/lib/resolve-site-name.d.ts +8 -0
- package/dist/ts/src/lib/resolve-site-name.d.ts.map +1 -0
- package/dist/ts/src/lib/resolve-site-name.js +12 -0
- package/dist/ts/src/lib/resolve-site-name.js.map +1 -0
- package/dist/ts/src/lib/route-utils.d.ts +61 -0
- package/dist/ts/src/lib/route-utils.d.ts.map +1 -0
- package/dist/ts/src/lib/route-utils.js +96 -0
- package/dist/ts/src/lib/route-utils.js.map +1 -0
- package/dist/ts/src/lib/routing-config.d.ts +38 -0
- package/dist/ts/src/lib/routing-config.d.ts.map +1 -0
- package/dist/ts/src/lib/routing-config.js +106 -0
- package/dist/ts/src/lib/routing-config.js.map +1 -0
- package/dist/ts/src/lib/serialize-props.d.ts +6 -0
- package/dist/ts/src/lib/serialize-props.d.ts.map +1 -0
- package/dist/ts/src/lib/serialize-props.js +8 -0
- package/dist/ts/src/lib/serialize-props.js.map +1 -0
- package/dist/ts/src/lib/unknown-components.d.ts +21 -0
- package/dist/ts/src/lib/unknown-components.d.ts.map +1 -0
- package/dist/ts/src/lib/unknown-components.js +49 -0
- package/dist/ts/src/lib/unknown-components.js.map +1 -0
- package/dist/ts/src/lib/virtual-module-generators.d.ts +33 -0
- package/dist/ts/src/lib/virtual-module-generators.d.ts.map +1 -0
- package/dist/ts/src/lib/virtual-module-generators.js +51 -0
- package/dist/ts/src/lib/virtual-module-generators.js.map +1 -0
- package/dist/{withHydration-HIvO9ysY.d.mts → ts/src/lib/withHydration.d.ts} +7 -11
- package/dist/ts/src/lib/withHydration.d.ts.map +1 -0
- package/dist/ts/src/lib/withHydration.js +50 -0
- package/dist/ts/src/lib/withHydration.js.map +1 -0
- package/dist/ts/src/loader.d.ts +27 -0
- package/dist/ts/src/loader.d.ts.map +1 -0
- package/dist/ts/src/loader.js +118 -0
- package/dist/ts/src/loader.js.map +1 -0
- package/dist/ts/src/locales-helpers.d.ts +61 -0
- package/dist/ts/src/locales-helpers.d.ts.map +1 -0
- package/dist/ts/src/locales-helpers.js +50 -0
- package/dist/ts/src/locales-helpers.js.map +1 -0
- package/dist/ts/src/mime-types.d.ts +3 -0
- package/dist/ts/src/mime-types.d.ts.map +1 -0
- package/dist/ts/src/mime-types.js +20 -0
- package/dist/ts/src/mime-types.js.map +1 -0
- package/dist/ts/src/page-feed.d.ts +13 -0
- package/dist/ts/src/page-feed.d.ts.map +1 -0
- package/dist/ts/src/page-feed.js +20 -0
- package/dist/ts/src/page-feed.js.map +1 -0
- package/dist/ts/src/page-schemas.d.ts +6 -0
- package/dist/ts/src/page-schemas.d.ts.map +1 -0
- package/dist/ts/src/page-schemas.js +6 -0
- package/dist/ts/src/page-schemas.js.map +1 -0
- package/dist/ts/src/path-validation.d.ts +8 -0
- package/dist/ts/src/path-validation.d.ts.map +1 -0
- package/dist/ts/src/path-validation.js +13 -0
- package/dist/ts/src/path-validation.js.map +1 -0
- package/dist/ts/src/plugin-spa.d.ts +182 -0
- package/dist/ts/src/plugin-spa.d.ts.map +1 -0
- package/dist/ts/src/plugin-spa.js +1165 -0
- package/dist/ts/src/plugin-spa.js.map +1 -0
- package/dist/ts/src/puck-manifest/components-endpoint.d.ts +30 -0
- package/dist/ts/src/puck-manifest/components-endpoint.d.ts.map +1 -0
- package/dist/ts/src/puck-manifest/components-endpoint.js +54 -0
- package/dist/ts/src/puck-manifest/components-endpoint.js.map +1 -0
- package/dist/ts/src/puck-manifest/field-projection.d.ts +91 -0
- package/dist/ts/src/puck-manifest/field-projection.d.ts.map +1 -0
- package/dist/ts/src/puck-manifest/field-projection.js +422 -0
- package/dist/ts/src/puck-manifest/field-projection.js.map +1 -0
- package/dist/ts/src/puck-manifest/index.d.ts +4 -0
- package/dist/ts/src/puck-manifest/index.d.ts.map +1 -0
- package/dist/ts/src/puck-manifest/index.js +3 -0
- package/dist/ts/src/puck-manifest/index.js.map +1 -0
- package/dist/ts/src/puck-manifest/literal.d.ts +163 -0
- package/dist/ts/src/puck-manifest/literal.d.ts.map +1 -0
- package/dist/ts/src/puck-manifest/literal.js +354 -0
- package/dist/ts/src/puck-manifest/literal.js.map +1 -0
- package/dist/ts/src/puck-manifest/read-config.d.ts +42 -0
- package/dist/ts/src/puck-manifest/read-config.d.ts.map +1 -0
- package/dist/ts/src/puck-manifest/read-config.js +517 -0
- package/dist/ts/src/puck-manifest/read-config.js.map +1 -0
- package/dist/ts/src/puck-manifest/read-field.d.ts +7 -0
- package/dist/ts/src/puck-manifest/read-field.d.ts.map +1 -0
- package/dist/ts/src/puck-manifest/read-field.js +11 -0
- package/dist/ts/src/puck-manifest/read-field.js.map +1 -0
- package/dist/ts/src/puck-manifest/read-wrapper.d.ts +147 -0
- package/dist/ts/src/puck-manifest/read-wrapper.d.ts.map +1 -0
- package/dist/ts/src/puck-manifest/read-wrapper.js +889 -0
- package/dist/ts/src/puck-manifest/read-wrapper.js.map +1 -0
- package/dist/ts/src/puck-manifest/reading-budget.d.ts +50 -0
- package/dist/ts/src/puck-manifest/reading-budget.d.ts.map +1 -0
- package/dist/ts/src/puck-manifest/reading-budget.js +113 -0
- package/dist/ts/src/puck-manifest/reading-budget.js.map +1 -0
- package/dist/ts/src/puck-manifest/resolve-reference.d.ts +4 -0
- package/dist/ts/src/puck-manifest/resolve-reference.d.ts.map +1 -0
- package/dist/ts/src/puck-manifest/resolve-reference.js +4 -0
- package/dist/ts/src/puck-manifest/resolve-reference.js.map +1 -0
- package/dist/ts/src/puck-manifest/source-reference.d.ts +96 -0
- package/dist/ts/src/puck-manifest/source-reference.d.ts.map +1 -0
- package/dist/ts/src/puck-manifest/source-reference.js +424 -0
- package/dist/ts/src/puck-manifest/source-reference.js.map +1 -0
- package/dist/ts/src/puck-manifest/syntax.d.ts +29 -0
- package/dist/ts/src/puck-manifest/syntax.d.ts.map +1 -0
- package/dist/ts/src/puck-manifest/syntax.js +79 -0
- package/dist/ts/src/puck-manifest/syntax.js.map +1 -0
- package/dist/ts/src/puck-manifest/types.d.ts +145 -0
- package/dist/ts/src/puck-manifest/types.d.ts.map +1 -0
- package/dist/ts/src/puck-manifest/types.js +2 -0
- package/dist/ts/src/puck-manifest/types.js.map +1 -0
- package/dist/ts/src/safe-json-stringify.d.ts +13 -0
- package/dist/ts/src/safe-json-stringify.d.ts.map +1 -0
- package/dist/ts/src/safe-json-stringify.js +7 -0
- package/dist/ts/src/safe-json-stringify.js.map +1 -0
- package/dist/ts/src/sandbox-frame-handler.d.ts +19 -0
- package/dist/ts/src/sandbox-frame-handler.d.ts.map +1 -0
- package/dist/ts/src/sandbox-frame-handler.js +27 -0
- package/dist/ts/src/sandbox-frame-handler.js.map +1 -0
- package/dist/ts/src/site-styles/content-wrapper-endpoint.d.ts +73 -0
- package/dist/ts/src/site-styles/content-wrapper-endpoint.d.ts.map +1 -0
- package/dist/ts/src/site-styles/content-wrapper-endpoint.js +224 -0
- package/dist/ts/src/site-styles/content-wrapper-endpoint.js.map +1 -0
- package/dist/ts/src/site-styles/render-endpoint.d.ts +50 -0
- package/dist/ts/src/site-styles/render-endpoint.d.ts.map +1 -0
- package/dist/ts/src/site-styles/render-endpoint.js +264 -0
- package/dist/ts/src/site-styles/render-endpoint.js.map +1 -0
- package/dist/ts/src/site-styles/styles-endpoint.d.ts +59 -0
- package/dist/ts/src/site-styles/styles-endpoint.d.ts.map +1 -0
- package/dist/ts/src/site-styles/styles-endpoint.js +156 -0
- package/dist/ts/src/site-styles/styles-endpoint.js.map +1 -0
- package/dist/ts/src/sitemap-options.d.ts +21 -0
- package/dist/ts/src/sitemap-options.d.ts.map +1 -0
- package/dist/ts/src/sitemap-options.js +92 -0
- package/dist/ts/src/sitemap-options.js.map +1 -0
- package/dist/ts/src/tiptap-html-static.d.ts +15 -0
- package/dist/ts/src/tiptap-html-static.d.ts.map +1 -0
- package/dist/ts/src/tiptap-html-static.js +67 -0
- package/dist/ts/src/tiptap-html-static.js.map +1 -0
- package/dist/ts/src/types.d.ts +543 -0
- package/dist/ts/src/types.d.ts.map +1 -0
- package/dist/ts/src/types.js +2 -0
- package/dist/ts/src/types.js.map +1 -0
- package/dist/virtual-modules.d.ts +74 -0
- package/node/content.ts +14 -0
- package/node/index.ts +22 -0
- package/package.json +198 -56
- package/src/asset-ref-base.ts +48 -0
- package/src/checks.ts +10 -0
- package/src/cms-handler.ts +280 -0
- package/src/collections.ts +262 -0
- package/src/components/HydrationWrapper.tsx +41 -0
- package/src/components/RenderWithFragments.tsx +204 -0
- package/src/components/RenderWithHydration.tsx +55 -0
- package/src/components.ts +3 -0
- package/src/discovery/astro-frontmatter.ts +24 -0
- package/src/discovery/discover.ts +108 -0
- package/src/discovery/extract-props-ts.ts +255 -0
- package/src/discovery/merge-registry.ts +411 -0
- package/src/discovery/registry-endpoint.ts +80 -0
- package/src/discovery/scan-components.ts +458 -0
- package/src/discovery/scan-mdx.ts +190 -0
- package/src/discovery/scan-overrides.ts +92 -0
- package/src/editor-descriptors.ts +96 -0
- package/src/env.d.ts +31 -0
- package/src/handlers/collection-content-api.ts +196 -0
- package/src/handlers/page-handler.astro +320 -0
- package/src/handlers/page-render-core.ts +456 -0
- package/src/hydration.ts +7 -0
- package/src/index.ts +111 -0
- package/src/internal/acorn-default.mjs +37 -0
- package/src/internal/declared-collections.ts +98 -0
- package/src/internal/page-collection-schema.ts +210 -0
- package/src/lib/content-config-guard.ts +48 -0
- package/src/lib/hydration-scanner.ts +176 -0
- package/src/lib/hydration-script.ts +126 -0
- package/src/lib/hydration-utils.ts +120 -0
- package/src/lib/resolve-locale.ts +22 -0
- package/src/lib/resolve-site-name.ts +10 -0
- package/src/lib/route-utils.ts +106 -0
- package/src/lib/routing-config.ts +126 -0
- package/src/lib/serialize-props.ts +7 -0
- package/src/lib/unknown-components.ts +64 -0
- package/src/lib/virtual-module-generators.ts +58 -0
- package/src/lib/withHydration.ts +71 -0
- package/src/loader.ts +145 -0
- package/src/locales-helpers.ts +68 -0
- package/src/mime-types.ts +19 -0
- package/src/page-feed.ts +26 -0
- package/src/page-schemas.ts +19 -0
- package/src/path-validation.ts +13 -0
- package/src/plugin-spa.ts +1480 -0
- package/src/puck-manifest/components-endpoint.ts +55 -0
- package/src/puck-manifest/field-projection.ts +510 -0
- package/src/puck-manifest/index.ts +3 -0
- package/src/puck-manifest/literal.ts +459 -0
- package/src/puck-manifest/read-config.ts +577 -0
- package/src/puck-manifest/read-field.ts +19 -0
- package/src/puck-manifest/read-wrapper.ts +1056 -0
- package/src/puck-manifest/reading-budget.ts +127 -0
- package/src/puck-manifest/resolve-reference.ts +9 -0
- package/src/puck-manifest/source-reference.ts +484 -0
- package/src/puck-manifest/syntax.ts +104 -0
- package/src/puck-manifest/types.ts +139 -0
- package/src/safe-json-stringify.ts +17 -0
- package/src/sandbox-frame-handler.ts +31 -0
- package/src/site-styles/content-wrapper-endpoint.ts +327 -0
- package/src/site-styles/render-endpoint.ts +331 -0
- package/src/site-styles/styles-endpoint.ts +184 -0
- package/src/sitemap-options.ts +115 -0
- package/src/tiptap-html-static.ts +84 -0
- package/{dist/types-CVQNmPxF.d.mts → src/types.ts} +232 -79
- package/src/virtual-modules.d.ts +74 -0
- package/dist/collections.d.mts +0 -36
- package/dist/collections.d.mts.map +0 -1
- package/dist/collections.mjs +0 -65
- package/dist/collections.mjs.map +0 -1
- package/dist/components.d.mts +0 -46
- package/dist/components.d.mts.map +0 -1
- package/dist/components.mjs +0 -226
- package/dist/components.mjs.map +0 -1
- package/dist/hydration-scanner-B0NjYkZ_.mjs +0 -109
- package/dist/hydration-scanner-B0NjYkZ_.mjs.map +0 -1
- package/dist/hydration.d.mts +0 -4
- package/dist/hydration.mjs +0 -3
- package/dist/index.d.mts +0 -139
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs +0 -66
- package/dist/index.mjs.map +0 -1
- package/dist/internal/cms-handler.d.mts +0 -26
- package/dist/internal/cms-handler.d.mts.map +0 -1
- package/dist/internal/cms-handler.mjs +0 -267
- package/dist/internal/cms-handler.mjs.map +0 -1
- package/dist/lib/hydration-script.d.mts.map +0 -1
- package/dist/lib/hydration-script.mjs +0 -85
- package/dist/lib/hydration-script.mjs.map +0 -1
- package/dist/loader-By-AQWHc.mjs +0 -68
- package/dist/loader-By-AQWHc.mjs.map +0 -1
- package/dist/node/content.d.mts +0 -19
- package/dist/node/content.d.mts.map +0 -1
- package/dist/node/content.mjs +0 -4
- package/dist/node/index.d.mts +0 -52
- package/dist/node/index.d.mts.map +0 -1
- package/dist/node/index.mjs +0 -753
- package/dist/node/index.mjs.map +0 -1
- package/dist/serialize-props-Dhv_MnkY.mjs +0 -73
- package/dist/serialize-props-Dhv_MnkY.mjs.map +0 -1
- package/dist/types-CVQNmPxF.d.mts.map +0 -1
- package/dist/withHydration-EzyzBQ-Y.mjs +0 -49
- package/dist/withHydration-EzyzBQ-Y.mjs.map +0 -1
- package/dist/withHydration-HIvO9ysY.d.mts.map +0 -1
|
@@ -0,0 +1,517 @@
|
|
|
1
|
+
import { existsSync, statSync } from 'node:fs';
|
|
2
|
+
import { dirname, join, relative } from 'node:path';
|
|
3
|
+
import { Node, SyntaxKind, ts, VariableDeclarationKind } from 'ts-morph';
|
|
4
|
+
import { createScanProject } from '../discovery/extract-props-ts.js';
|
|
5
|
+
import { excerpt, holdsNothing, limitOutput, mayHoldUnread, namedMember, OutputBudgetExceeded, unwrapExpression, WorkBudgetExceeded, walkIsWhole, walkLiteral, withReadingSession, } from './literal.js';
|
|
6
|
+
import { readFieldSet } from './read-field.js';
|
|
7
|
+
import { callsDeclaredFunction, readComponentWithSpreads, readWrapperCall, readWrapperCallReading, } from './read-wrapper.js';
|
|
8
|
+
import { lookUpKey, resolveCallExpression, resolveLiteralValue, resolveObjectLiteral } from './resolve-reference.js';
|
|
9
|
+
/**
|
|
10
|
+
* Reads a site's Puck config into a manifest, from source and without
|
|
11
|
+
* executing it.
|
|
12
|
+
*
|
|
13
|
+
* Everything unreadable is named rather than dropped: a component whose
|
|
14
|
+
* definition cannot be followed lands in `unresolved`, so an agent is told what
|
|
15
|
+
* it does not know instead of being handed a component that appears to accept
|
|
16
|
+
* nothing.
|
|
17
|
+
*
|
|
18
|
+
* A config that cannot be read at all — no file to open, a file it loads that
|
|
19
|
+
* does not parse, no default export, a default export that is not an object this reader
|
|
20
|
+
* can follow — is refused as a whole with the reason, and so is one that would
|
|
21
|
+
* cost more to read, or produce a bigger manifest, than the reader allows:
|
|
22
|
+
* refused, never read or sent in part.
|
|
23
|
+
*
|
|
24
|
+
* Never throws. A reading that fails in a way nothing above anticipates is
|
|
25
|
+
* refused too, with the error it stopped on as the reason: the caller serves
|
|
26
|
+
* this manifest, and a config it cannot read is an answer, not a crash.
|
|
27
|
+
*/
|
|
28
|
+
export function readPuckConfig(options) {
|
|
29
|
+
return withReadingSession(() => {
|
|
30
|
+
try {
|
|
31
|
+
const manifest = readConfigFile(options);
|
|
32
|
+
limitOutput(manifest);
|
|
33
|
+
return manifest;
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
return refusal(stoppedReason(error));
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Why a reading that threw is refused. A budget says what it measured; any
|
|
42
|
+
* other error is quoted as it is, because the reader cannot tell a fault of
|
|
43
|
+
* its own from a limit of the runtime it runs on — except the call stack,
|
|
44
|
+
* which source nested thousands of levels deep runs out of, and says so.
|
|
45
|
+
*/
|
|
46
|
+
function stoppedReason(error) {
|
|
47
|
+
if (error instanceof WorkBudgetExceeded || error instanceof OutputBudgetExceeded)
|
|
48
|
+
return error.message;
|
|
49
|
+
const quoted = excerpt(error instanceof Error ? `${error.name}: ${error.message}` : String(error));
|
|
50
|
+
const stack = error instanceof RangeError && /call stack/i.test(error.message);
|
|
51
|
+
return stack
|
|
52
|
+
? `reading the config ran out of call stack (${quoted}) — usually source nested thousands of levels deep — so its components are unknown`
|
|
53
|
+
: `reading the config stopped on an error (${quoted}), so its components are unknown`;
|
|
54
|
+
}
|
|
55
|
+
/** A config refused as a whole: no component names to report, so the manifest carries the gap and its reason. */
|
|
56
|
+
function refusal(reason) {
|
|
57
|
+
return { components: {}, unresolved: [], unreadable: true, unreadableReason: reason };
|
|
58
|
+
}
|
|
59
|
+
function readConfigFile(options) {
|
|
60
|
+
const manifest = { components: {}, unresolved: [] };
|
|
61
|
+
const project = createScanProject(options.tsConfigFilePath ?? nearestTsConfig(dirname(options.configPath)));
|
|
62
|
+
// A project whose options say nothing about `jsx` resolves an import of a
|
|
63
|
+
// `.tsx` file to nothing at all and reports no error — every component would
|
|
64
|
+
// read as unresolved with nothing to explain why. Reachable from three
|
|
65
|
+
// directions: no tsconfig, one that cannot be parsed, and one that simply
|
|
66
|
+
// never mentions jsx. Set before the first file is added, because changing
|
|
67
|
+
// compiler options reparses everything already in the project.
|
|
68
|
+
if (project.compilerOptions.get().jsx === undefined) {
|
|
69
|
+
project.compilerOptions.set({ jsx: ts.JsxEmit.Preserve });
|
|
70
|
+
}
|
|
71
|
+
let file;
|
|
72
|
+
try {
|
|
73
|
+
file = project.addSourceFileAtPath(options.configPath);
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
// An unreadable path is a missing config, not a crash in the caller. A
|
|
77
|
+
// file that IS there and still would not open — nested deeper than the
|
|
78
|
+
// parser's call stack goes — is not missing, and is refused for what
|
|
79
|
+
// stopped it.
|
|
80
|
+
if (isFile(options.configPath))
|
|
81
|
+
throw error;
|
|
82
|
+
return refusal('the config file could not be opened: it is missing, or its path is not a file this reader can read');
|
|
83
|
+
}
|
|
84
|
+
const directory = dirname(options.configPath);
|
|
85
|
+
// A file that does not parse fails to load, however much of it the parser
|
|
86
|
+
// recovers into something this reader could otherwise read.
|
|
87
|
+
const broken = syntaxError(project.getProgram().compilerObject, file.compilerNode, directory);
|
|
88
|
+
if (broken)
|
|
89
|
+
return refusal(`the config file, ${broken}, so it fails to load and its components are unknown`);
|
|
90
|
+
const exported = defaultExport(file);
|
|
91
|
+
if (typeof exported === 'string')
|
|
92
|
+
return refusal(exported);
|
|
93
|
+
// The file is there and its config is not: `export default defineConfig(…)`.
|
|
94
|
+
const configObject = resolveObjectLiteral(exported);
|
|
95
|
+
if (!configObject) {
|
|
96
|
+
return refusal(`the config's default export, ${excerpt(exported.getText())}, ${whyNotFollowed(exported)}, so its components are unknown`);
|
|
97
|
+
}
|
|
98
|
+
// The config is walked by the same rules as every literal in it: `{
|
|
99
|
+
// ...base, components: … }` reads base's categories and root, and the last
|
|
100
|
+
// write of a key is the one Puck gets.
|
|
101
|
+
const config = walkLiteral(configObject, CONFIG_KEYS);
|
|
102
|
+
const components = configKey(config, 'components');
|
|
103
|
+
if (components === 'unknown') {
|
|
104
|
+
manifest.unreadable = true;
|
|
105
|
+
manifest.unreadableReason = `${unknownComponentsReason(config)}, so its components are unknown`;
|
|
106
|
+
}
|
|
107
|
+
else if (components !== 'absent')
|
|
108
|
+
readComponents(components, manifest);
|
|
109
|
+
const categories = configKey(config, 'categories');
|
|
110
|
+
if (categories === 'unknown')
|
|
111
|
+
manifest.categoriesUnreadable = true;
|
|
112
|
+
else if (categories !== 'absent')
|
|
113
|
+
readCategories(categories, manifest);
|
|
114
|
+
const root = configKey(config, 'root');
|
|
115
|
+
if (root === 'unknown')
|
|
116
|
+
manifest.root = { fields: {}, fieldsUnreadable: true };
|
|
117
|
+
else if (root !== 'absent') {
|
|
118
|
+
const read = readRoot(root);
|
|
119
|
+
if (read)
|
|
120
|
+
manifest.root = read;
|
|
121
|
+
}
|
|
122
|
+
// A module the reading went through that does not parse fails to load, and
|
|
123
|
+
// takes the config down with it — whatever the parser recovered of it.
|
|
124
|
+
const brokenImport = brokenModule(project, directory);
|
|
125
|
+
if (brokenImport) {
|
|
126
|
+
return refusal(`a module the config loads, ${brokenImport}, so the config fails to load and its components are unknown`);
|
|
127
|
+
}
|
|
128
|
+
return manifest;
|
|
129
|
+
}
|
|
130
|
+
/** The config's own keys, each handed over as the node its last write assigns — spreads followed to the literal they name. */
|
|
131
|
+
const CONFIG_KEYS = {
|
|
132
|
+
kind: 'config',
|
|
133
|
+
read: (value) => value,
|
|
134
|
+
spread: (expression) => resolveObjectLiteral(expression),
|
|
135
|
+
};
|
|
136
|
+
/**
|
|
137
|
+
* What the config provably says about one of its keys: the node its last
|
|
138
|
+
* write assigns; `absent` where nothing writes it — or the write holds nothing,
|
|
139
|
+
* as `root: undefined` does; or `unknown` where a write this reader cannot read
|
|
140
|
+
* may be it — a getter, a spread or a computed name it cannot follow, a
|
|
141
|
+
* prototype.
|
|
142
|
+
*/
|
|
143
|
+
function configKey(config, key) {
|
|
144
|
+
const value = config.entries.get(key);
|
|
145
|
+
if (value)
|
|
146
|
+
return holdsNothing(value) ? 'absent' : value;
|
|
147
|
+
return mayHoldUnread(config, key) ? 'unknown' : 'absent';
|
|
148
|
+
}
|
|
149
|
+
/** Whether a path names a file that is there — as opposed to nothing, or a directory. */
|
|
150
|
+
function isFile(path) {
|
|
151
|
+
return statSync(path, { throwIfNoEntry: false })?.isFile() ?? false;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Where a file fails to parse, as a reason names it — `Hero.ts, has a syntax
|
|
155
|
+
* error at line 3 (',' expected)` — or undefined when it parses. The path is
|
|
156
|
+
* taken from the config's directory. Only the parser is asked, which costs
|
|
157
|
+
* nothing the reading would not pay anyway.
|
|
158
|
+
*/
|
|
159
|
+
function syntaxError(program, file, directory) {
|
|
160
|
+
const [first] = program.getSyntacticDiagnostics(file);
|
|
161
|
+
if (!first)
|
|
162
|
+
return undefined;
|
|
163
|
+
const message = ts.flattenDiagnosticMessageText(first.messageText, ' ');
|
|
164
|
+
const line = file.getLineAndCharacterOfPosition(first.start).line + 1;
|
|
165
|
+
return `${relative(directory, file.fileName)}, has a syntax error at line ${line} (${excerpt(message)})`;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* The first file the reading loaded that does not parse, named as
|
|
169
|
+
* `syntaxError` names it. Only syntax counts — a type error still loads — and
|
|
170
|
+
* declaration files and packages are left out: neither is the site's source.
|
|
171
|
+
*/
|
|
172
|
+
function brokenModule(project, directory) {
|
|
173
|
+
const program = project.getProgram().compilerObject;
|
|
174
|
+
for (const file of program.getSourceFiles()) {
|
|
175
|
+
const external = program.isSourceFileFromExternalLibrary(file) || file.fileName.includes('/node_modules/');
|
|
176
|
+
if (file.isDeclarationFile || external)
|
|
177
|
+
continue;
|
|
178
|
+
const broken = syntaxError(program, file, directory);
|
|
179
|
+
if (broken)
|
|
180
|
+
return broken;
|
|
181
|
+
}
|
|
182
|
+
return undefined;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* The node the config's default export is written as — the expression of
|
|
186
|
+
* `export default …`, or the name `export { config as default }` and `export
|
|
187
|
+
* { default } from './real'` hand over — or the reason there is none this
|
|
188
|
+
* reader can read.
|
|
189
|
+
*
|
|
190
|
+
* The default exports are counted from the statements rather than asked of
|
|
191
|
+
* the compiler, which keeps the first of two and says nothing of the second:
|
|
192
|
+
* a module with two does not load at all.
|
|
193
|
+
*/
|
|
194
|
+
function defaultExport(file) {
|
|
195
|
+
const written = file.getStatements().flatMap(defaultExportsOf);
|
|
196
|
+
if (written.length > 1) {
|
|
197
|
+
const lines = written.map((declaration) => declaration.getStartLineNumber()).join(' and ');
|
|
198
|
+
return `the config file has ${written.length} default exports, on lines ${lines}, and a module with more than one fails to load, so its components are unknown`;
|
|
199
|
+
}
|
|
200
|
+
const [declaration] = written;
|
|
201
|
+
if (!declaration) {
|
|
202
|
+
return file.getExportAssignment((node) => node.isExportEquals())
|
|
203
|
+
? 'the config file exports with `export =`, which this reader does not read as a default export, so its components are unknown'
|
|
204
|
+
: 'the config file has no default export, so there is no config to read';
|
|
205
|
+
}
|
|
206
|
+
if (Node.isExportAssignment(declaration))
|
|
207
|
+
return declaration.getExpression();
|
|
208
|
+
if (Node.isExportSpecifier(declaration))
|
|
209
|
+
return declaration.getNameNode();
|
|
210
|
+
if (Node.isExportDeclaration(declaration)) {
|
|
211
|
+
return "the config's default export is a module namespace, which this reader does not read, so its components are unknown";
|
|
212
|
+
}
|
|
213
|
+
const kind = Node.isClassDeclaration(declaration) ? 'a class' : 'a function';
|
|
214
|
+
return `the config's default export is ${kind}, not an object written out in the source, so its components are unknown`;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* The default exports one statement makes that exist at runtime. An overload
|
|
218
|
+
* signature and a type-only export make none — a function's overloads are one
|
|
219
|
+
* function, its body — and `export =` is no default export. `export * as
|
|
220
|
+
* default from './real'` makes one: the module's namespace.
|
|
221
|
+
*/
|
|
222
|
+
function defaultExportsOf(statement) {
|
|
223
|
+
if (Node.isExportAssignment(statement))
|
|
224
|
+
return statement.isExportEquals() ? [] : [statement];
|
|
225
|
+
if (Node.isFunctionDeclaration(statement) || Node.isClassDeclaration(statement)) {
|
|
226
|
+
const signatureOnly = Node.isFunctionDeclaration(statement) && !statement.hasBody();
|
|
227
|
+
return statement.isDefaultExport() && !signatureOnly && !statement.hasDeclareKeyword() ? [statement] : [];
|
|
228
|
+
}
|
|
229
|
+
if (!Node.isExportDeclaration(statement) || statement.isTypeOnly())
|
|
230
|
+
return [];
|
|
231
|
+
const namespace = statement.getNamespaceExport();
|
|
232
|
+
if (namespace && exportName(namespace.getNameNode()) === 'default')
|
|
233
|
+
return [statement];
|
|
234
|
+
return statement.getNamedExports().filter((specifier) => {
|
|
235
|
+
const exported = specifier.getAliasNode() ?? specifier.getNameNode();
|
|
236
|
+
return exportName(exported) === 'default' && !specifier.isTypeOnly();
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
/** The name an export is made under, written as a name or — `export { x as 'default' }` — a string. */
|
|
240
|
+
function exportName(name) {
|
|
241
|
+
return Node.isStringLiteral(name) ? name.getLiteralValue() : name.getText();
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Why a node that was to lead to an object does not, as the clause a reason
|
|
245
|
+
* puts after quoting it. What this reader can tell apart is named — a call, a
|
|
246
|
+
* name it cannot find, a `let` — and anything else is admitted plainly, never
|
|
247
|
+
* guessed at.
|
|
248
|
+
*/
|
|
249
|
+
function whyNotFollowed(node) {
|
|
250
|
+
const expression = unwrapExpression(node);
|
|
251
|
+
if (Node.isCallExpression(expression))
|
|
252
|
+
return "is a call's result, which this reader would have to run to know";
|
|
253
|
+
const identifier = expression.asKind(SyntaxKind.Identifier);
|
|
254
|
+
if (identifier) {
|
|
255
|
+
const declarations = declarationsOf(identifier);
|
|
256
|
+
if (declarations.length === 0) {
|
|
257
|
+
return 'names nothing this reader can find — an import it cannot resolve, or a global';
|
|
258
|
+
}
|
|
259
|
+
const letOrVar = declarations.some((declaration) => Node.isVariableDeclaration(declaration) &&
|
|
260
|
+
declaration.getVariableStatement()?.getDeclarationKind() !== VariableDeclarationKind.Const);
|
|
261
|
+
if (letOrVar)
|
|
262
|
+
return 'is declared with let or var, and what it holds when Puck reads it may not be what is written there';
|
|
263
|
+
}
|
|
264
|
+
return 'is not an object written out in the source or a name this reader can follow to one';
|
|
265
|
+
}
|
|
266
|
+
/** How many imports and re-exports `declarationsOf` follows before it gives up. */
|
|
267
|
+
const MAX_ALIAS_HOPS = 5;
|
|
268
|
+
/** The declarations a name stands for, across imports and re-exports; none when it stands for nothing this reader can find. */
|
|
269
|
+
function declarationsOf(identifier) {
|
|
270
|
+
// A shorthand's name is a property to the checker; the value it stands for
|
|
271
|
+
// is a symbol of its own.
|
|
272
|
+
const shorthand = identifier.getParentIfKind(SyntaxKind.ShorthandPropertyAssignment);
|
|
273
|
+
let symbol = shorthand?.getNameNode() === identifier ? shorthand.getValueSymbol() : identifier.getSymbol();
|
|
274
|
+
for (let hop = 0; symbol?.isAlias() && hop < MAX_ALIAS_HOPS; hop++)
|
|
275
|
+
symbol = symbol.getAliasedSymbol();
|
|
276
|
+
return symbol?.getDeclarations() ?? [];
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Why the config's `components` key is unknown: what writes it may be code, or
|
|
280
|
+
* a write this reader cannot name, or a prototype.
|
|
281
|
+
*/
|
|
282
|
+
function unknownComponentsReason(config) {
|
|
283
|
+
const unread = config.unread.get('components');
|
|
284
|
+
if (unread === 'code')
|
|
285
|
+
return 'the config declares components with a getter or a method, whose code this reader does not run';
|
|
286
|
+
if (unread === 'setter')
|
|
287
|
+
return 'the config writes components last with a setter, which reads back as undefined — or, beside a getter, runs code this reader does not run';
|
|
288
|
+
if (config.lost)
|
|
289
|
+
return `${unnamedWrite(config, 'the config')}, and it may set the components map`;
|
|
290
|
+
return 'the config sets its prototype with __proto__, and the components map may be inherited through it';
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* The write a walk could not name, as a reason puts it: the spread it could
|
|
294
|
+
* not follow — or that led to one it could not — or the computed name it could
|
|
295
|
+
* not work out.
|
|
296
|
+
*/
|
|
297
|
+
function unnamedWrite(walk, owner) {
|
|
298
|
+
const spread = walk.lostAt?.asKind(SyntaxKind.SpreadAssignment);
|
|
299
|
+
if (spread)
|
|
300
|
+
return `${owner} spreads ${excerpt(spread.getExpression().getText())}, which this reader cannot follow to the keys it writes`;
|
|
301
|
+
const name = walk.lostAt && namedMember(walk.lostAt)?.getNameNode();
|
|
302
|
+
if (name)
|
|
303
|
+
return `${owner} writes a key under a computed name, ${excerpt(name.getText())}, that this reader cannot work out`;
|
|
304
|
+
return `${owner} writes a key this reader cannot name`;
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* The nearest `tsconfig.json` at or above a directory. Absent one, the caller
|
|
308
|
+
* falls back to permissive defaults, which is the best that can be done for a
|
|
309
|
+
* project that has no TypeScript config of its own.
|
|
310
|
+
*/
|
|
311
|
+
function nearestTsConfig(fromDirectory) {
|
|
312
|
+
let directory = fromDirectory;
|
|
313
|
+
for (;;) {
|
|
314
|
+
const candidate = join(directory, 'tsconfig.json');
|
|
315
|
+
if (existsSync(candidate))
|
|
316
|
+
return candidate;
|
|
317
|
+
const parent = dirname(directory);
|
|
318
|
+
if (parent === directory)
|
|
319
|
+
return undefined;
|
|
320
|
+
directory = parent;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
/** Why a name is admitted when a later write the components map cannot name may have replaced it. */
|
|
324
|
+
const MAY_BE_REPLACED = 'a later entry of the components map — a spread or a computed name this reader cannot follow — may replace this component';
|
|
325
|
+
/**
|
|
326
|
+
* Why a name is admitted when the components map declares it in a shape that
|
|
327
|
+
* carries no value to read. `['__proto__']` has no reason: none can be recorded
|
|
328
|
+
* under that name, and `value` never arises — every definition reads as a
|
|
329
|
+
* component or a reason of its own.
|
|
330
|
+
*/
|
|
331
|
+
function unreadReason(why) {
|
|
332
|
+
switch (why) {
|
|
333
|
+
case 'code':
|
|
334
|
+
return 'the components map declares it with a getter or a method, whose code this reader does not run';
|
|
335
|
+
case 'setter':
|
|
336
|
+
return 'the components map writes it last with a setter, which reads back as undefined — or, beside a getter, runs code this reader does not run';
|
|
337
|
+
default:
|
|
338
|
+
return undefined;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Reads the `components` map, whether it is written in the config, named
|
|
343
|
+
* (`components: siteComponents`) or handed over as a shorthand.
|
|
344
|
+
*
|
|
345
|
+
* A map that cannot be followed at all leaves no names behind to report, so the
|
|
346
|
+
* manifest itself is marked unreadable — the difference between a site with no
|
|
347
|
+
* components and a site whose components this reader could not see.
|
|
348
|
+
*
|
|
349
|
+
* The map is walked by the runtime's own rules, spreads merged where they sit
|
|
350
|
+
* and the last entry for a name winning. A later write the walk cannot name —
|
|
351
|
+
* `[name]: …`, `...buildComponents()` — may replace any component written
|
|
352
|
+
* before it, so those move to `unresolved` with that reason, and may add
|
|
353
|
+
* components no name here reveals, so the manifest is marked unreadable too; so
|
|
354
|
+
* does a prototype, through which Puck looks a component up as well.
|
|
355
|
+
*/
|
|
356
|
+
function readComponents(node, manifest) {
|
|
357
|
+
const literal = resolveObjectLiteral(node);
|
|
358
|
+
if (!literal) {
|
|
359
|
+
manifest.unreadable = true;
|
|
360
|
+
manifest.unreadableReason = `the config's components map, ${excerpt(node.getText())}, ${whyNotFollowed(node)}, so its components are unknown`;
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
const walk = walkLiteral(literal, COMPONENT_ENTRIES);
|
|
364
|
+
for (const [name, { component, reason }] of walk.entries) {
|
|
365
|
+
if (component)
|
|
366
|
+
manifest.components[name] = component;
|
|
367
|
+
else
|
|
368
|
+
admitComponent(manifest, name, reason);
|
|
369
|
+
}
|
|
370
|
+
for (const [name, why] of walk.unread)
|
|
371
|
+
admitComponent(manifest, name, unreadReason(why));
|
|
372
|
+
for (const name of walk.cleared)
|
|
373
|
+
admitComponent(manifest, name, MAY_BE_REPLACED);
|
|
374
|
+
if (walk.lost || walk.inherits) {
|
|
375
|
+
manifest.unreadable = true;
|
|
376
|
+
manifest.unreadableReason = walk.lost
|
|
377
|
+
? `${unnamedWrite(walk, 'the components map')}, so it may declare components not listed here`
|
|
378
|
+
: 'the components map sets its prototype with __proto__, and Puck finds components through it too, so it may declare components not listed here';
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
/** The components map's entries, each read as a definition — `components: { ...shared, Badge: … }` inlines a second map. */
|
|
382
|
+
const COMPONENT_ENTRIES = {
|
|
383
|
+
kind: 'components map',
|
|
384
|
+
read: (value) => resolveComponentDefinition(value),
|
|
385
|
+
spread: (expression) => resolveObjectLiteral(expression),
|
|
386
|
+
};
|
|
387
|
+
/** Names a component in `unresolved`, with the reason where one is known. */
|
|
388
|
+
function admitComponent(manifest, name, reason) {
|
|
389
|
+
manifest.unresolved.push(name);
|
|
390
|
+
// `__proto__` would replace the record's prototype rather than add a reason.
|
|
391
|
+
if (!reason || name === '__proto__')
|
|
392
|
+
return;
|
|
393
|
+
manifest.unresolvedReasons ??= {};
|
|
394
|
+
manifest.unresolvedReasons[name] = reason;
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* A component definition reached through a name or written in place: the
|
|
398
|
+
* resolved literal read with its spreads applied, or — when the name stands for
|
|
399
|
+
* a wrapper call — the wrapper's symbolic reading. The reason, when set, names
|
|
400
|
+
* the refusing rule for the manifest.
|
|
401
|
+
*
|
|
402
|
+
* One walker reads both, in source order and by the runtime's own rules, so a
|
|
403
|
+
* component written `{ ...Grid, label: … }` in the config means here exactly
|
|
404
|
+
* what it means inside a wrapper body.
|
|
405
|
+
*/
|
|
406
|
+
function resolveComponentDefinition(node) {
|
|
407
|
+
const literal = resolveObjectLiteral(node);
|
|
408
|
+
if (literal)
|
|
409
|
+
return readComponentWithSpreads(literal, wrapperBuiltSpread);
|
|
410
|
+
const call = resolveCallExpression(node);
|
|
411
|
+
return call ? readWrapperCall(call) : {};
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* The one spread source the walker cannot reach as text: a name standing for a
|
|
415
|
+
* wrapper CALL. Both of our own configs rename wrapper-built components this
|
|
416
|
+
* way — `Grid: { ...Grid, label: … }` — and the override literal on its own is
|
|
417
|
+
* a label and no fields, so reported as the component it would claim the
|
|
418
|
+
* component accepts nothing.
|
|
419
|
+
*
|
|
420
|
+
* Only a call to a function declared in the source is a wrapper. `...mk()`
|
|
421
|
+
* with `mk` nowhere to be found is a spread that cannot be followed, and the
|
|
422
|
+
* walker's own reason says so; the wrapper reader's would blame a wrapper the
|
|
423
|
+
* config never wrote.
|
|
424
|
+
*/
|
|
425
|
+
function wrapperBuiltSpread(expression) {
|
|
426
|
+
const call = resolveCallExpression(expression);
|
|
427
|
+
return call && callsDeclaredFunction(call) ? readWrapperCallReading(call) : {};
|
|
428
|
+
}
|
|
429
|
+
/** A category's own keys: values followed to the `const` they name, spreads to the literal they name. */
|
|
430
|
+
const CATEGORY_KEYS = {
|
|
431
|
+
kind: 'category',
|
|
432
|
+
read: (value) => resolveLiteralValue(value),
|
|
433
|
+
spread: (expression) => resolveObjectLiteral(expression),
|
|
434
|
+
};
|
|
435
|
+
/**
|
|
436
|
+
* Sidebar grouping, walked by the runtime's own rules. A category that cannot
|
|
437
|
+
* be read — or whose name cannot be — is left out and admitted with
|
|
438
|
+
* `categoriesUnreadable`, as is any other part of the value the walk could not
|
|
439
|
+
* see, so a missing category is never mistaken for one the config lacks.
|
|
440
|
+
*/
|
|
441
|
+
function readCategories(node, manifest) {
|
|
442
|
+
const literal = resolveObjectLiteral(node);
|
|
443
|
+
if (!literal) {
|
|
444
|
+
manifest.categoriesUnreadable = true;
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
const walk = walkLiteral(literal, CATEGORY_ENTRIES);
|
|
448
|
+
const categories = [];
|
|
449
|
+
let admitted = !walkIsWhole(walk);
|
|
450
|
+
for (const [name, reading] of walk.entries) {
|
|
451
|
+
if (reading.admitted)
|
|
452
|
+
admitted = true;
|
|
453
|
+
if (reading.category)
|
|
454
|
+
categories.push([name, reading.category]);
|
|
455
|
+
}
|
|
456
|
+
manifest.categories = Object.fromEntries(categories);
|
|
457
|
+
if (admitted)
|
|
458
|
+
manifest.categoriesUnreadable = true;
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* One category. One whose component list is provably never written says
|
|
462
|
+
* nothing and is left out; one whose list or title may be written but could
|
|
463
|
+
* not be read is admitted — the list by leaving the category out, the title by
|
|
464
|
+
* listing the category without it.
|
|
465
|
+
*/
|
|
466
|
+
/** The categories map's entries, each read as a category; a spread inlines a second map. */
|
|
467
|
+
const CATEGORY_ENTRIES = {
|
|
468
|
+
kind: 'categories',
|
|
469
|
+
read: (value) => readCategory(value),
|
|
470
|
+
spread: (expression) => resolveObjectLiteral(expression),
|
|
471
|
+
};
|
|
472
|
+
function readCategory(node) {
|
|
473
|
+
const literal = resolveObjectLiteral(node);
|
|
474
|
+
if (!literal)
|
|
475
|
+
return { admitted: true };
|
|
476
|
+
const walk = walkLiteral(literal, CATEGORY_KEYS);
|
|
477
|
+
const components = walk.entries.get('components');
|
|
478
|
+
if (!isStringList(components)) {
|
|
479
|
+
return { admitted: components !== undefined || mayHoldUnread(walk, 'components') };
|
|
480
|
+
}
|
|
481
|
+
const title = walk.entries.get('title');
|
|
482
|
+
if (typeof title === 'string')
|
|
483
|
+
return { category: { title, components }, admitted: false };
|
|
484
|
+
return { category: { components }, admitted: title !== undefined || mayHoldUnread(walk, 'title') };
|
|
485
|
+
}
|
|
486
|
+
function isStringList(value) {
|
|
487
|
+
return Array.isArray(value) && value.every((entry) => typeof entry === 'string');
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
490
|
+
* Page-level fields, which Puck declares as a component in all but name. The
|
|
491
|
+
* `fields` key is looked up by the runtime's rule — the last write wins,
|
|
492
|
+
* spreads included — and a write that may be it but cannot be read admits the
|
|
493
|
+
* set rather than reporting a page with no fields. A root that cannot be read
|
|
494
|
+
* at all — `root: buildRoot()` — is admitted the same way, because it may
|
|
495
|
+
* declare page fields too.
|
|
496
|
+
*/
|
|
497
|
+
function readRoot(node) {
|
|
498
|
+
const literal = resolveObjectLiteral(node);
|
|
499
|
+
if (!literal)
|
|
500
|
+
return { fields: {}, fieldsUnreadable: true };
|
|
501
|
+
const written = lookUpKey(literal, 'fields');
|
|
502
|
+
if (written === 'absent')
|
|
503
|
+
return undefined;
|
|
504
|
+
const set = written === 'unknown' ? undefined : readFieldSet(written);
|
|
505
|
+
if (!set)
|
|
506
|
+
return { fields: {}, fieldsUnreadable: true };
|
|
507
|
+
return set.unreadable ? { fields: set.fields, fieldsUnreadable: true } : { fields: set.fields };
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* The dev endpoint's response body. Kept beside the reader so the dev route
|
|
511
|
+
* and a build that publishes the manifest serialize identically — one JSON
|
|
512
|
+
* shape, one place.
|
|
513
|
+
*/
|
|
514
|
+
export function componentsEndpointBody(options) {
|
|
515
|
+
return JSON.stringify(readPuckConfig(options));
|
|
516
|
+
}
|
|
517
|
+
//# sourceMappingURL=read-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-config.js","sourceRoot":"","sources":["../../../../src/puck-manifest/read-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,IAAI,EAAiC,UAAU,EAAE,EAAE,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AACxG,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EACL,OAAO,EACP,YAAY,EAGZ,WAAW,EACX,aAAa,EACb,WAAW,EACX,oBAAoB,EAEpB,gBAAgB,EAChB,kBAAkB,EAClB,WAAW,EACX,WAAW,EACX,kBAAkB,GACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAEL,qBAAqB,EACrB,wBAAwB,EACxB,eAAe,EACf,sBAAsB,GAEvB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,SAAS,EAAE,qBA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GAAG,oBAAoB,CAAC,IAAI,CAAC,CAAC;IAC3C,IAAI,CAAC,OAAO;QAAE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAAC;IAE5D,MAAM,OAAO,GAAG,SAAS,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC7C,IAAI,OAAO,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IAC3C,MAAM,GAAG,GAAG,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IACtE,IAAI,CAAC,GAAG;QAAE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAAC;IACxD,OAAO,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC;AAClG,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAA8B;IACnE,OAAO,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Node, ObjectLiteralExpression } from 'ts-morph';
|
|
2
|
+
import { type FieldSources } from './field-projection.js';
|
|
3
|
+
export { carryKey, type FieldSetReading, type FieldSources } from './field-projection.js';
|
|
4
|
+
/** Public reader entry points retain builder support without a projection/wrapper import cycle. */
|
|
5
|
+
export declare function readField(node: ObjectLiteralExpression, depth?: number, sources?: FieldSources): import("./types.js").ManifestField;
|
|
6
|
+
export declare function readFieldSet(node: Node | undefined, depth?: number, sources?: FieldSources): import("./field-projection.js").FieldSetReading | undefined;
|
|
7
|
+
//# sourceMappingURL=read-field.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-field.d.ts","sourceRoot":"","sources":["../../../../src/puck-manifest/read-field.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAC9D,OAAO,EACL,KAAK,YAAY,EAIlB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAE,QAAQ,EAAE,KAAK,eAAe,EAAE,KAAK,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1F,mGAAmG;AACnG,wBAAgB,SAAS,CAAC,IAAI,EAAE,uBAAuB,EAAE,KAAK,SAAI,EAAE,OAAO,GAAE,YAA2B,sCAEvG;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,IAAI,GAAG,SAAS,EAAE,KAAK,SAAI,EAAE,OAAO,GAAE,YAA2B,+DAEnG"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { readField as projectField, readFieldSet as projectFieldSet, WRITTEN_DOWN, } from './field-projection.js';
|
|
2
|
+
import { readFieldBuilderCall } from './read-wrapper.js';
|
|
3
|
+
export { carryKey } from './field-projection.js';
|
|
4
|
+
/** Public reader entry points retain builder support without a projection/wrapper import cycle. */
|
|
5
|
+
export function readField(node, depth = 0, sources = WRITTEN_DOWN) {
|
|
6
|
+
return projectField(node, depth, { ...sources, builder: sources.builder ?? readFieldBuilderCall });
|
|
7
|
+
}
|
|
8
|
+
export function readFieldSet(node, depth = 0, sources = WRITTEN_DOWN) {
|
|
9
|
+
return projectFieldSet(node, depth, { ...sources, builder: sources.builder ?? readFieldBuilderCall });
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=read-field.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-field.js","sourceRoot":"","sources":["../../../../src/puck-manifest/read-field.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,SAAS,IAAI,YAAY,EACzB,YAAY,IAAI,eAAe,EAC/B,YAAY,GACb,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAEzD,OAAO,EAAE,QAAQ,EAA2C,MAAM,uBAAuB,CAAC;AAE1F,mGAAmG;AACnG,MAAM,UAAU,SAAS,CAAC,IAA6B,EAAE,KAAK,GAAG,CAAC,EAAE,OAAO,GAAiB,YAAY;IACtG,OAAO,YAAY,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,oBAAoB,EAAE,CAAC,CAAC;AACrG,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,IAAsB,EAAE,KAAK,GAAG,CAAC,EAAE,OAAO,GAAiB,YAAY;IAClG,OAAO,eAAe,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,oBAAoB,EAAE,CAAC,CAAC;AACxG,CAAC"}
|