@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.
- package/README.md +250 -298
- 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/{src → ts/src}/cms-handler.d.ts +0 -1
- package/dist/ts/src/cms-handler.d.ts.map +1 -0
- package/dist/{src → ts/src}/cms-handler.js +9 -130
- 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/{src → ts/src}/components/HydrationWrapper.d.ts +1 -1
- package/dist/ts/src/components/HydrationWrapper.d.ts.map +1 -0
- package/dist/{src → ts/src}/components/HydrationWrapper.js +1 -0
- package/dist/ts/src/components/HydrationWrapper.js.map +1 -0
- package/dist/{src/components/RenderWithBlocks.d.ts → ts/src/components/RenderWithFragments.d.ts} +8 -4
- 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/{src → ts/src}/components/RenderWithHydration.d.ts +6 -2
- package/dist/ts/src/components/RenderWithHydration.d.ts.map +1 -0
- package/dist/{src → ts/src}/components/RenderWithHydration.js +6 -3
- 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.map +1 -0
- package/dist/{src → ts/src}/discovery/astro-frontmatter.js +1 -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.map +1 -0
- package/dist/{src → ts/src}/discovery/extract-props-ts.js +1 -0
- package/dist/ts/src/discovery/extract-props-ts.js.map +1 -0
- package/dist/{src → ts/src}/discovery/merge-registry.d.ts +3 -3
- package/dist/ts/src/discovery/merge-registry.d.ts.map +1 -0
- package/dist/{src → ts/src}/discovery/merge-registry.js +1 -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/{src → ts/src}/discovery/scan-components.d.ts +3 -7
- package/dist/ts/src/discovery/scan-components.d.ts.map +1 -0
- package/dist/{src → ts/src}/discovery/scan-components.js +4 -6
- package/dist/ts/src/discovery/scan-components.js.map +1 -0
- package/dist/ts/src/discovery/scan-mdx.d.ts.map +1 -0
- package/dist/{src → ts/src}/discovery/scan-mdx.js +1 -0
- package/dist/ts/src/discovery/scan-mdx.js.map +1 -0
- package/dist/ts/src/discovery/scan-overrides.d.ts.map +1 -0
- package/dist/{src → ts/src}/discovery/scan-overrides.js +1 -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.map +1 -0
- package/dist/{src → ts/src}/hydration.js +1 -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.map +1 -0
- package/dist/{src → ts/src}/lib/hydration-scanner.js +1 -0
- package/dist/ts/src/lib/hydration-scanner.js.map +1 -0
- package/dist/ts/src/lib/hydration-script.d.ts.map +1 -0
- package/dist/{src → ts/src}/lib/hydration-script.js +1 -0
- package/dist/ts/src/lib/hydration-script.js.map +1 -0
- package/dist/ts/src/lib/hydration-utils.d.ts.map +1 -0
- package/dist/{src → ts/src}/lib/hydration-utils.js +1 -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/{src → ts/src}/lib/route-utils.d.ts +26 -6
- package/dist/ts/src/lib/route-utils.d.ts.map +1 -0
- package/dist/{src → ts/src}/lib/route-utils.js +33 -15
- package/dist/ts/src/lib/route-utils.js.map +1 -0
- package/dist/{src → ts/src}/lib/routing-config.d.ts +7 -1
- package/dist/ts/src/lib/routing-config.d.ts.map +1 -0
- package/dist/{src → ts/src}/lib/routing-config.js +13 -0
- package/dist/ts/src/lib/routing-config.js.map +1 -0
- package/dist/ts/src/lib/serialize-props.d.ts.map +1 -0
- package/dist/{src → ts/src}/lib/serialize-props.js +1 -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/{src → ts/src}/lib/virtual-module-generators.d.ts +0 -24
- 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/ts/src/lib/withHydration.d.ts.map +1 -0
- package/dist/{src → ts/src}/lib/withHydration.js +1 -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/{src → ts/src}/loader.js +33 -4
- package/dist/ts/src/loader.js.map +1 -0
- package/dist/ts/src/locales-helpers.d.ts.map +1 -0
- package/dist/{src → ts/src}/locales-helpers.js +1 -0
- package/dist/ts/src/locales-helpers.js.map +1 -0
- package/dist/ts/src/mime-types.d.ts.map +1 -0
- package/dist/{src → ts/src}/mime-types.js +1 -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.map +1 -0
- package/dist/{src → ts/src}/path-validation.js +1 -0
- package/dist/ts/src/path-validation.js.map +1 -0
- package/dist/{src → ts/src}/plugin-spa.d.ts +28 -10
- package/dist/ts/src/plugin-spa.d.ts.map +1 -0
- package/dist/{src → ts/src}/plugin-spa.js +280 -87
- 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.map +1 -0
- package/dist/{src → ts/src}/safe-json-stringify.js +1 -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/{src → ts/src}/site-styles/content-wrapper-endpoint.d.ts +2 -5
- package/dist/ts/src/site-styles/content-wrapper-endpoint.d.ts.map +1 -0
- package/dist/{src → ts/src}/site-styles/content-wrapper-endpoint.js +5 -8
- package/dist/ts/src/site-styles/content-wrapper-endpoint.js.map +1 -0
- package/dist/{src → ts/src}/site-styles/render-endpoint.d.ts +4 -9
- package/dist/ts/src/site-styles/render-endpoint.d.ts.map +1 -0
- package/dist/{src → ts/src}/site-styles/render-endpoint.js +1 -0
- package/dist/ts/src/site-styles/render-endpoint.js.map +1 -0
- package/dist/{src → ts/src}/site-styles/styles-endpoint.d.ts +2 -4
- package/dist/ts/src/site-styles/styles-endpoint.d.ts.map +1 -0
- package/dist/{src → ts/src}/site-styles/styles-endpoint.js +3 -5
- 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/{src → ts/src}/types.d.ts +26 -110
- 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 +12 -93
- package/node/content.ts +14 -0
- package/node/index.ts +22 -0
- package/package.json +159 -73
- 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/{dist/withHydration-DkKpkmzJ.d.mts → src/lib/withHydration.ts} +25 -8
- package/src/loader.ts +145 -0
- package/{dist/locales-helpers-BvYYqnJ5.d.mts → src/locales-helpers.ts} +21 -17
- 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-CS9neadI.d.mts → src/types.ts} +87 -124
- package/src/virtual-modules.d.ts +74 -0
- package/dist/collections-Bd7EME4b.mjs +0 -129
- package/dist/collections-Bd7EME4b.mjs.map +0 -1
- package/dist/collections.d.mts +0 -35
- package/dist/collections.d.mts.map +0 -1
- package/dist/collections.mjs +0 -2
- package/dist/components.d.mts +0 -41
- package/dist/components.d.mts.map +0 -1
- package/dist/components.mjs +0 -223
- package/dist/components.mjs.map +0 -1
- package/dist/hydration.d.mts +0 -4
- package/dist/hydration.mjs +0 -2
- package/dist/index.d.mts +0 -108
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs +0 -67
- package/dist/index.mjs.map +0 -1
- package/dist/internal/cms-handler.d.mts +0 -25
- package/dist/internal/cms-handler.d.mts.map +0 -1
- package/dist/internal/cms-handler.mjs +0 -314
- package/dist/internal/cms-handler.mjs.map +0 -1
- package/dist/lib/hydration-script.d.mts +0 -30
- package/dist/lib/hydration-script.d.mts.map +0 -1
- package/dist/lib/hydration-script.mjs +0 -84
- package/dist/lib/hydration-script.mjs.map +0 -1
- package/dist/locales-helpers-BvYYqnJ5.d.mts.map +0 -1
- package/dist/locales-helpers-qiwh7nxS.mjs +0 -54
- package/dist/locales-helpers-qiwh7nxS.mjs.map +0 -1
- package/dist/node/content.d.mts +0 -18
- package/dist/node/content.d.mts.map +0 -1
- package/dist/node/content.d.ts +0 -3
- package/dist/node/content.d.ts.map +0 -1
- package/dist/node/content.js +0 -2
- package/dist/node/content.mjs +0 -2
- package/dist/node/index.d.mts +0 -200
- package/dist/node/index.d.mts.map +0 -1
- package/dist/node/index.d.ts +0 -4
- package/dist/node/index.d.ts.map +0 -1
- package/dist/node/index.js +0 -3
- package/dist/node/index.mjs +0 -2513
- package/dist/node/index.mjs.map +0 -1
- package/dist/serialize-props-BHoNpzH6.mjs +0 -72
- package/dist/serialize-props-BHoNpzH6.mjs.map +0 -1
- package/dist/src/cms-handler.d.ts.map +0 -1
- package/dist/src/collections.d.ts +0 -32
- package/dist/src/collections.d.ts.map +0 -1
- package/dist/src/collections.js +0 -50
- package/dist/src/components/HydrationWrapper.d.ts.map +0 -1
- package/dist/src/components/RenderWithBlocks.d.ts.map +0 -1
- package/dist/src/components/RenderWithBlocks.js +0 -129
- package/dist/src/components/RenderWithHydration.d.ts.map +0 -1
- package/dist/src/components.d.ts +0 -4
- package/dist/src/components.d.ts.map +0 -1
- package/dist/src/components.js +0 -3
- package/dist/src/discovery/astro-frontmatter.d.ts.map +0 -1
- package/dist/src/discovery/extract-props-ts.d.ts.map +0 -1
- package/dist/src/discovery/merge-registry.d.ts.map +0 -1
- package/dist/src/discovery/registry-endpoint.d.ts +0 -42
- package/dist/src/discovery/registry-endpoint.d.ts.map +0 -1
- package/dist/src/discovery/registry-endpoint.js +0 -81
- package/dist/src/discovery/scan-components.d.ts.map +0 -1
- package/dist/src/discovery/scan-mdx.d.ts.map +0 -1
- package/dist/src/discovery/scan-overrides.d.ts.map +0 -1
- package/dist/src/hydration.d.ts.map +0 -1
- package/dist/src/index.d.ts +0 -11
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/index.js +0 -25
- package/dist/src/lib/hydration-scanner.d.ts.map +0 -1
- package/dist/src/lib/hydration-script.d.ts.map +0 -1
- package/dist/src/lib/hydration-utils.d.ts.map +0 -1
- package/dist/src/lib/page-api.d.ts +0 -77
- package/dist/src/lib/page-api.d.ts.map +0 -1
- package/dist/src/lib/page-api.js +0 -121
- package/dist/src/lib/route-utils.d.ts.map +0 -1
- package/dist/src/lib/routing-config.d.ts.map +0 -1
- package/dist/src/lib/serialize-props.d.ts.map +0 -1
- package/dist/src/lib/virtual-module-generators.d.ts.map +0 -1
- package/dist/src/lib/virtual-module-generators.js +0 -263
- package/dist/src/lib/withHydration.d.ts.map +0 -1
- package/dist/src/loader.d.ts +0 -14
- package/dist/src/loader.d.ts.map +0 -1
- package/dist/src/locales-helpers.d.ts.map +0 -1
- package/dist/src/mime-types.d.ts.map +0 -1
- package/dist/src/path-validation.d.ts.map +0 -1
- package/dist/src/plugin-spa.d.ts.map +0 -1
- package/dist/src/safe-json-stringify.d.ts.map +0 -1
- package/dist/src/site-styles/content-wrapper-endpoint.d.ts.map +0 -1
- package/dist/src/site-styles/render-endpoint.d.ts.map +0 -1
- package/dist/src/site-styles/styles-endpoint.d.ts.map +0 -1
- package/dist/src/types.d.ts.map +0 -1
- package/dist/src/types.js +0 -1
- package/dist/types-CS9neadI.d.mts.map +0 -1
- package/dist/withHydration-C256ox_6.mjs +0 -49
- package/dist/withHydration-C256ox_6.mjs.map +0 -1
- package/dist/withHydration-DkKpkmzJ.d.mts.map +0 -1
- /package/dist/{src → ts/src}/discovery/astro-frontmatter.d.ts +0 -0
- /package/dist/{src → ts/src}/discovery/extract-props-ts.d.ts +0 -0
- /package/dist/{src → ts/src}/discovery/scan-mdx.d.ts +0 -0
- /package/dist/{src → ts/src}/discovery/scan-overrides.d.ts +0 -0
- /package/dist/{src → ts/src}/hydration.d.ts +0 -0
- /package/dist/{src → ts/src}/lib/hydration-scanner.d.ts +0 -0
- /package/dist/{src → ts/src}/lib/hydration-script.d.ts +0 -0
- /package/dist/{src → ts/src}/lib/hydration-utils.d.ts +0 -0
- /package/dist/{src → ts/src}/lib/serialize-props.d.ts +0 -0
- /package/dist/{src → ts/src}/lib/withHydration.d.ts +0 -0
- /package/dist/{src → ts/src}/locales-helpers.d.ts +0 -0
- /package/dist/{src → ts/src}/mime-types.d.ts +0 -0
- /package/dist/{src → ts/src}/path-validation.d.ts +0 -0
- /package/dist/{src → ts/src}/safe-json-stringify.d.ts +0 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { isAbsolute, relative, resolve, sep } from 'node:path';
|
|
2
|
+
import { type DiscoveredComponent, mergeRegistry } from './merge-registry.js';
|
|
3
|
+
import { scanExternalComponents, scanLocalComponents } from './scan-components.js';
|
|
4
|
+
import { scanMdxFiles } from './scan-mdx.js';
|
|
5
|
+
import { loadCmsOverrides } from './scan-overrides.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Inputs for the MDX component registry scan. Resolved ONCE by the
|
|
9
|
+
* integration so the dev endpoint and a build-time integration cannot drift.
|
|
10
|
+
*/
|
|
11
|
+
export interface MdxRegistryScanOptions {
|
|
12
|
+
/** Absolute or project-relative path to the MDX content directory. */
|
|
13
|
+
contentRoot: string;
|
|
14
|
+
/** Project-relative paths to scan for local components. */
|
|
15
|
+
componentFolders: string[];
|
|
16
|
+
/** Project-relative folder of `*.cms.json` sidecar override files,
|
|
17
|
+
* keyed by component basename (`Card.cms.json` → overrides `Card`).
|
|
18
|
+
* Defaults to `src/cms-overrides` — hosts can omit it when they
|
|
19
|
+
* don't need any overrides yet. */
|
|
20
|
+
overridesFolder?: string;
|
|
21
|
+
/** Base for resolving the paths above. Defaults to `process.cwd()`. */
|
|
22
|
+
projectRoot?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The three-stage auto-discovery pipeline behind the editor's MDX
|
|
27
|
+
* component registry (scan-mdx + scan-components + merge-registry).
|
|
28
|
+
*
|
|
29
|
+
* Free of any dev-server dependency on purpose: dev serves the result
|
|
30
|
+
* from `/__cms/api/registry`, and a build-time caller, where no dev server
|
|
31
|
+
* runs, calls this same function. One scan implementation is the only way
|
|
32
|
+
* both can agree.
|
|
33
|
+
*/
|
|
34
|
+
export async function discoverMdxComponents(options: MdxRegistryScanOptions): Promise<DiscoveredComponent[]> {
|
|
35
|
+
const projectRoot = options.projectRoot ?? process.cwd();
|
|
36
|
+
const contentRoot = resolve(projectRoot, options.contentRoot);
|
|
37
|
+
// MDX scan first — its results feed BOTH the merge step AND the
|
|
38
|
+
// external-package scan (which uses the imports to know what
|
|
39
|
+
// packages to walk into).
|
|
40
|
+
const mdxScans = await scanMdxFiles(contentRoot);
|
|
41
|
+
const overridesFolder = options.overridesFolder ?? 'src/cms-overrides';
|
|
42
|
+
const [localComponents, externalComponents, overrides] = await Promise.all([
|
|
43
|
+
scanLocalComponents(options.componentFolders, projectRoot),
|
|
44
|
+
scanExternalComponents(mdxScans, projectRoot),
|
|
45
|
+
loadCmsOverrides(overridesFolder, projectRoot),
|
|
46
|
+
]);
|
|
47
|
+
// External (npm) and local components live in disjoint key
|
|
48
|
+
// spaces — external source strings are npm specifiers, local
|
|
49
|
+
// source strings are absolute paths — so they never collide on
|
|
50
|
+
// the `${source}::${name}` dedup key. The interesting collision
|
|
51
|
+
// case is two sources sharing a `name`; that pass is resolved
|
|
52
|
+
// inside `mergeRegistry` by usage count (see rule 6 in its top
|
|
53
|
+
// doc). Host sidecar overrides apply last as the highest-priority
|
|
54
|
+
// layer (see `applyOverride` in merge-registry).
|
|
55
|
+
return mergeRegistry(mdxScans, [...externalComponents, ...localComponents], overrides);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Rewrites absolute local-component import specifiers to project-relative
|
|
60
|
+
* ones (`/src/components/mdx/Aside.tsx`), and `aliases` keys — absolute MDX
|
|
61
|
+
* file paths of the scanning machine — the same way.
|
|
62
|
+
*
|
|
63
|
+
* The scanner records a local component's `import.from` as its absolute file
|
|
64
|
+
* path, which is what the dev render endpoint hands to `ssrLoadModule`. That
|
|
65
|
+
* path is machine-specific: descriptors that outlive the scan (saved with the
|
|
66
|
+
* site's MDX files, say) would carry the scanning machine's prefix into the
|
|
67
|
+
* repository and break the next build elsewhere. Callers whose descriptors
|
|
68
|
+
* outlive the scan apply it; the dev endpoint keeps the paths its loader
|
|
69
|
+
* expects. npm specifiers and paths outside the project are left untouched.
|
|
70
|
+
*/
|
|
71
|
+
export function toPortableImports(components: DiscoveredComponent[], projectRoot: string): DiscoveredComponent[] {
|
|
72
|
+
return components.map((component) => {
|
|
73
|
+
let next = component;
|
|
74
|
+
const imported = component.import;
|
|
75
|
+
const portableFrom = imported === undefined ? undefined : toProjectRelative(imported.from, projectRoot);
|
|
76
|
+
if (imported && portableFrom !== undefined) {
|
|
77
|
+
next = { ...next, import: { ...imported, from: portableFrom } };
|
|
78
|
+
}
|
|
79
|
+
if (component.aliases) {
|
|
80
|
+
next = {
|
|
81
|
+
...next,
|
|
82
|
+
aliases: Object.fromEntries(
|
|
83
|
+
Object.entries(component.aliases).map(([file, alias]) => [
|
|
84
|
+
toProjectRelative(file, projectRoot) ?? file,
|
|
85
|
+
alias,
|
|
86
|
+
]),
|
|
87
|
+
),
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
return next;
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* One absolute path → project-relative `/src/...` specifier, or `undefined`
|
|
96
|
+
* when the path is not absolute or falls outside the project. The
|
|
97
|
+
* outside-project guard matches `..` segments only (a directory literally
|
|
98
|
+
* named `..foo` is INSIDE the project and must rewrite); `isAbsolute` catches
|
|
99
|
+
* the Windows different-drive case, where `relative()` returns an absolute
|
|
100
|
+
* path instead of `..` hops.
|
|
101
|
+
*/
|
|
102
|
+
function toProjectRelative(path: string, projectRoot: string): string | undefined {
|
|
103
|
+
if (!isAbsolute(path)) return undefined;
|
|
104
|
+
const relativePath = relative(projectRoot, path);
|
|
105
|
+
if (relativePath === '' || relativePath === '..' || relativePath.startsWith(`..${sep}`) || isAbsolute(relativePath))
|
|
106
|
+
return undefined;
|
|
107
|
+
return `/${relativePath.replace(/\\/g, '/')}`;
|
|
108
|
+
}
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript-aware extraction of a component's `Props` interface,
|
|
3
|
+
* replacing the regex-based path in `scan-components.ts`. Uses
|
|
4
|
+
* `ts-morph` (a thin wrapper over the TypeScript compiler API) so
|
|
5
|
+
* derived types — `(typeof asideVariants)[number]`, mapped types,
|
|
6
|
+
* imported aliases, conditional types — resolve to their concrete
|
|
7
|
+
* literal-union values. The regex scanner couldn't follow any
|
|
8
|
+
* indirection and silently dropped options for those props (Aside's
|
|
9
|
+
* `type` being the canonical example).
|
|
10
|
+
*
|
|
11
|
+
* The output shape is identical to the regex path (`ParsedProp[]`)
|
|
12
|
+
* so the rest of the discovery pipeline doesn't change.
|
|
13
|
+
*
|
|
14
|
+
* Astro files are handled by extracting the frontmatter block and
|
|
15
|
+
* feeding it to the Project as a virtual `.ts` source — see
|
|
16
|
+
* `extractAstroFrontmatter` in `astro-frontmatter.ts`.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import {
|
|
20
|
+
type InterfaceDeclaration,
|
|
21
|
+
ModuleKind,
|
|
22
|
+
ModuleResolutionKind,
|
|
23
|
+
Project,
|
|
24
|
+
type PropertySignature,
|
|
25
|
+
ScriptTarget,
|
|
26
|
+
type SourceFile,
|
|
27
|
+
type Type,
|
|
28
|
+
type TypeAliasDeclaration,
|
|
29
|
+
type TypeLiteralNode,
|
|
30
|
+
} from 'ts-morph';
|
|
31
|
+
import type { ParsedProp } from './scan-components.js';
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* One Project per scan run, reused across `extractPropsViaTs` calls
|
|
35
|
+
* within the same scan. Building the Project loads `lib.dom.d.ts`
|
|
36
|
+
* etc. which dominates cold-start cost (~500ms-2s); sharing across
|
|
37
|
+
* files in a scan amortises that. A fresh Project is built per scan
|
|
38
|
+
* run so file changes are picked up — ts-morph's `addSourceFile`
|
|
39
|
+
* caches by path and wouldn't see external edits otherwise.
|
|
40
|
+
*/
|
|
41
|
+
export function createScanProject(tsConfigFilePath?: string): Project {
|
|
42
|
+
// When the host has a tsconfig, use it — that's how cross-file
|
|
43
|
+
// `typeof` refs and path mappings (`@/foo`) resolve. Without one,
|
|
44
|
+
// fall back to permissive defaults that still handle the common
|
|
45
|
+
// shapes (literal unions inside a single file, simple imports).
|
|
46
|
+
if (tsConfigFilePath) {
|
|
47
|
+
try {
|
|
48
|
+
return new Project({
|
|
49
|
+
tsConfigFilePath,
|
|
50
|
+
// Add files explicitly per scan; don't auto-load every file
|
|
51
|
+
// referenced by tsconfig.include — that would slow scans on
|
|
52
|
+
// big projects.
|
|
53
|
+
skipAddingFilesFromTsConfig: true,
|
|
54
|
+
});
|
|
55
|
+
} catch {
|
|
56
|
+
// tsconfig parse failure — fall through to defaults
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return new Project({
|
|
60
|
+
compilerOptions: {
|
|
61
|
+
target: ScriptTarget.ES2022,
|
|
62
|
+
module: ModuleKind.ESNext,
|
|
63
|
+
moduleResolution: ModuleResolutionKind.Bundler,
|
|
64
|
+
allowJs: true,
|
|
65
|
+
esModuleInterop: true,
|
|
66
|
+
skipLibCheck: true,
|
|
67
|
+
strict: false,
|
|
68
|
+
},
|
|
69
|
+
skipAddingFilesFromTsConfig: true,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Extract the Props interface from a source string and return the
|
|
75
|
+
* parsed prop list. `filepath` is used as the virtual file's path
|
|
76
|
+
* inside the Project so error messages and source-map debugging
|
|
77
|
+
* point back at the right file; the actual content comes from
|
|
78
|
+
* `sourceText`. `.astro` callers pass the extracted frontmatter as
|
|
79
|
+
* `sourceText` and `${filepath}.virtual.ts` as `filepath`.
|
|
80
|
+
*
|
|
81
|
+
* Returns `[]` when no Props interface is found — same contract as
|
|
82
|
+
* the regex path so callers don't need a special-case branch.
|
|
83
|
+
*/
|
|
84
|
+
export function extractPropsViaTs(
|
|
85
|
+
project: Project,
|
|
86
|
+
filepath: string,
|
|
87
|
+
sourceText: string,
|
|
88
|
+
componentName?: string,
|
|
89
|
+
): ParsedProp[] {
|
|
90
|
+
let sf: SourceFile;
|
|
91
|
+
try {
|
|
92
|
+
sf = project.createSourceFile(filepath, sourceText, { overwrite: true });
|
|
93
|
+
} catch (err) {
|
|
94
|
+
// Source parse failure — eg the .astro frontmatter contained
|
|
95
|
+
// syntax the TS compiler rejected (rare; most front-matter is
|
|
96
|
+
// valid TS). Return empty so the merge layer can still surface
|
|
97
|
+
// the component, just without prop schema.
|
|
98
|
+
console.warn(`[conloca:ts-morph] parse failed for ${filepath}:`, err instanceof Error ? err.message : err);
|
|
99
|
+
return [];
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Try `${ComponentName}Props` first (matches the convention
|
|
103
|
+
// `interface CardProps {...}` used by some libraries), then the
|
|
104
|
+
// bare `Props` name (Astro components and most React components).
|
|
105
|
+
// Try interface declarations first, then type aliases — same
|
|
106
|
+
// priority the regex scanner used.
|
|
107
|
+
const candidates: string[] = [];
|
|
108
|
+
if (componentName) candidates.push(`${componentName}Props`);
|
|
109
|
+
candidates.push('Props');
|
|
110
|
+
|
|
111
|
+
let propertySignatures: PropertySignature[] = [];
|
|
112
|
+
for (const name of candidates) {
|
|
113
|
+
const iface = sf.getInterface(name);
|
|
114
|
+
if (iface) {
|
|
115
|
+
propertySignatures = collectLocalProperties(iface);
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
const alias = sf.getTypeAlias(name);
|
|
119
|
+
if (alias) {
|
|
120
|
+
propertySignatures = collectAliasProperties(alias);
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
if (propertySignatures.length === 0) {
|
|
125
|
+
project.removeSourceFile(sf);
|
|
126
|
+
return [];
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const props: ParsedProp[] = [];
|
|
130
|
+
for (const prop of propertySignatures) {
|
|
131
|
+
const name = prop.getName();
|
|
132
|
+
// `getType()` on the PropertySignature node resolves at the
|
|
133
|
+
// declaration site — this is where `(typeof X)[number]` collapses
|
|
134
|
+
// to its literal union, generics expand, conditional types branch.
|
|
135
|
+
const type = prop.getType();
|
|
136
|
+
const required = !prop.hasQuestionToken();
|
|
137
|
+
props.push(parseType(name, type, required));
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Clean up the virtual source file so successive calls in the
|
|
141
|
+
// same scan don't accumulate sources and bloat memory.
|
|
142
|
+
project.removeSourceFile(sf);
|
|
143
|
+
|
|
144
|
+
return props;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Get ONLY the locally-declared properties on an interface, NOT
|
|
149
|
+
* properties inherited from `extends` clauses. This is the key choice
|
|
150
|
+
* that keeps the side panel sane for components like Starlight's
|
|
151
|
+
* `LinkCard` which declares `extends Omit<HTMLAttributes<'a'>, 'title'>`:
|
|
152
|
+
* the type-level `Type.getProperties()` would include every HTML
|
|
153
|
+
* attribute (~200 entries — `accesskey`, `aria-*`, `on*`, etc), making
|
|
154
|
+
* the panel useless. The declaration-level `iface.getProperties()`
|
|
155
|
+
* returns just the props the author explicitly wrote inside the
|
|
156
|
+
* braces, which is the editor's intent.
|
|
157
|
+
*
|
|
158
|
+
* Trade-off: a property the author "overrides" via re-declaration
|
|
159
|
+
* (eg LinkCard's local `title: string` overriding the inherited
|
|
160
|
+
* `title?: string`) appears — good. A property the author NEVER
|
|
161
|
+
* declared locally but the inherited interface defines (eg `href`
|
|
162
|
+
* inherited from HTMLAttributes) does NOT appear — also good, the
|
|
163
|
+
* panel stays focused on what the author wanted to expose. Hosts
|
|
164
|
+
* who want a specific inherited prop surfaced can re-declare it
|
|
165
|
+
* locally or use the sidecar `cmsConfig.props` override.
|
|
166
|
+
*/
|
|
167
|
+
function collectLocalProperties(iface: InterfaceDeclaration): PropertySignature[] {
|
|
168
|
+
// PropertySignature[] — only what's between this interface's own
|
|
169
|
+
// braces. Inherited properties from `extends` aren't included.
|
|
170
|
+
return iface.getProperties();
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Type-alias variant. For `type Props = { ... }`, the declaration
|
|
175
|
+
* node is a TypeLiteralNode and we read its own member list. For
|
|
176
|
+
* intersections (`type Props = A & { ... }`) or imported aliases,
|
|
177
|
+
* we get an empty list rather than walking into the constituent
|
|
178
|
+
* types — same author-intent rationale as the interface case.
|
|
179
|
+
*/
|
|
180
|
+
function collectAliasProperties(alias: TypeAliasDeclaration): PropertySignature[] {
|
|
181
|
+
const node = alias.getTypeNode();
|
|
182
|
+
// ts-morph's `asKind(SyntaxKind.TypeLiteral)` would narrow this
|
|
183
|
+
// cleanly, but we only need the duck-typed check that the node
|
|
184
|
+
// exposes `getMembers()`. A type literal does; an intersection or
|
|
185
|
+
// imported reference doesn't — those return an empty list and the
|
|
186
|
+
// alias is skipped by the caller.
|
|
187
|
+
const members = (node as TypeLiteralNode | undefined)?.getMembers?.();
|
|
188
|
+
if (!members) return [];
|
|
189
|
+
return members.filter((m): m is PropertySignature => m.getKindName() === 'PropertySignature');
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Map a resolved `Type` to a `ParsedProp`. Mirrors the kind of
|
|
194
|
+
* branching the old regex did, but on real type information.
|
|
195
|
+
*/
|
|
196
|
+
function parseType(name: string, type: Type, required: boolean): ParsedProp {
|
|
197
|
+
if (type.isString()) return { name, type: 'string', required };
|
|
198
|
+
if (type.isNumber()) return { name, type: 'number', required };
|
|
199
|
+
if (type.isBoolean()) return { name, type: 'boolean', required };
|
|
200
|
+
|
|
201
|
+
if (type.isUnion()) {
|
|
202
|
+
const members = type.getUnionTypes();
|
|
203
|
+
// Filter out `undefined` (added by the compiler for `?` props
|
|
204
|
+
// under strictNullChecks). The remaining members tell us what
|
|
205
|
+
// the prop actually accepts.
|
|
206
|
+
const nonUndefined = members.filter((m) => !m.isUndefined());
|
|
207
|
+
|
|
208
|
+
// All-boolean-literal union (`true | false`, or even `true` alone,
|
|
209
|
+
// or `false` alone) → boolean. Under strict mode, `boolean` is
|
|
210
|
+
// canonicalised by the checker into the union `true | false`, so
|
|
211
|
+
// `isBoolean()` on the original type returns false — we have to
|
|
212
|
+
// detect the expanded form. This is the path that catches eg
|
|
213
|
+
// CardGrid's `stagger?: boolean` (resolved as `true | false |
|
|
214
|
+
// undefined`).
|
|
215
|
+
if (nonUndefined.length > 0 && nonUndefined.every((m) => m.isBooleanLiteral() || m.isBoolean())) {
|
|
216
|
+
return { name, type: 'boolean', required };
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// String-literal union → string prop with `options`. Even when
|
|
220
|
+
// the union also includes a non-literal `string`, surface the
|
|
221
|
+
// literals as picker suggestions.
|
|
222
|
+
const stringLiterals = nonUndefined
|
|
223
|
+
.filter((m) => m.isStringLiteral())
|
|
224
|
+
.map((m) => m.getLiteralValue())
|
|
225
|
+
.filter((v): v is string => typeof v === 'string');
|
|
226
|
+
if (stringLiterals.length > 0) {
|
|
227
|
+
return { name, type: 'string', required, options: stringLiterals };
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// Single non-undefined primitive after stripping the optional
|
|
231
|
+
// undefined — eg `string | undefined` collapses to `string`.
|
|
232
|
+
if (nonUndefined.length === 1) {
|
|
233
|
+
const only = nonUndefined[0];
|
|
234
|
+
if (only.isString()) return { name, type: 'string', required };
|
|
235
|
+
if (only.isNumber()) return { name, type: 'number', required };
|
|
236
|
+
if (only.isBoolean()) return { name, type: 'boolean', required };
|
|
237
|
+
if (only.isStringLiteral()) {
|
|
238
|
+
const v = only.getLiteralValue();
|
|
239
|
+
return { name, type: 'string', required, options: typeof v === 'string' ? [v] : undefined };
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
if (type.isStringLiteral()) {
|
|
245
|
+
const v = type.getLiteralValue();
|
|
246
|
+
return { name, type: 'string', required, options: typeof v === 'string' ? [v] : undefined };
|
|
247
|
+
}
|
|
248
|
+
if (type.isBooleanLiteral()) {
|
|
249
|
+
return { name, type: 'boolean', required };
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// Anything else — function types, object types, branded types,
|
|
253
|
+
// arrays, Records — render as a free-form expression input.
|
|
254
|
+
return { name, type: 'expression', required };
|
|
255
|
+
}
|