@conloca/astro-cms 0.1.16 → 0.2.1
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 +254 -301
- 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 +11 -131
- package/dist/ts/src/cms-handler.js.map +1 -0
- package/dist/ts/src/collections.d.ts +161 -0
- package/dist/ts/src/collections.d.ts.map +1 -0
- package/dist/ts/src/collections.js +178 -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 +13 -0
- package/dist/ts/src/lib/content-config-guard.d.ts.map +1 -0
- package/dist/ts/src/lib/content-config-guard.js +45 -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 +301 -88
- 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 +16 -0
- package/dist/ts/src/tiptap-html-static.d.ts.map +1 -0
- package/dist/ts/src/tiptap-html-static.js +117 -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 +161 -73
- package/src/asset-ref-base.ts +48 -0
- package/src/checks.ts +11 -0
- package/src/cms-handler.ts +281 -0
- package/src/collections.ts +271 -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 +53 -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 +1496 -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 +134 -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,422 @@
|
|
|
1
|
+
import { SyntaxKind } from 'ts-morph';
|
|
2
|
+
import { inheritsNothing, literalObjectReading, namedMember, propertyKey, SPREADS_NOTHING, setsPrototype, spendWork, writtenValue, } from './literal.js';
|
|
3
|
+
import { resolveCallExpression, resolveLiteralValueReading, resolveObjectLiteral } from './resolve-reference.js';
|
|
4
|
+
/** Field types Puck cannot infer a shape for — they need an `ai.schema` to mean anything to an agent. */
|
|
5
|
+
const OPAQUE_TYPES = new Set(['custom', 'external']);
|
|
6
|
+
const DROPPABLE_KEYS = new Set([
|
|
7
|
+
'label',
|
|
8
|
+
'options',
|
|
9
|
+
'arrayFields',
|
|
10
|
+
'objectFields',
|
|
11
|
+
'min',
|
|
12
|
+
'max',
|
|
13
|
+
'allow',
|
|
14
|
+
'disallow',
|
|
15
|
+
'ai',
|
|
16
|
+
]);
|
|
17
|
+
/** Every key of a field this reader models, `type` included — what a write it cannot name may have replaced. */
|
|
18
|
+
const MODELED_KEYS = ['type', ...DROPPABLE_KEYS];
|
|
19
|
+
/**
|
|
20
|
+
* How deep a field may nest before the reader stops. Each nested field set is
|
|
21
|
+
* one level, and so is each spread followed.
|
|
22
|
+
*
|
|
23
|
+
* Following names made cycles reachable: `const F = { type: 'object',
|
|
24
|
+
* objectFields: { a: F } }`, or `const A = { ...B }` beside `const B = { ...A
|
|
25
|
+
* }`, is source that could never have loaded at runtime, but this reader is
|
|
26
|
+
* handed text rather than a running module, and chasing it exhausts the stack
|
|
27
|
+
* and takes the caller down instead of reporting anything. Set well past what a
|
|
28
|
+
* field written on purpose reaches, so the cap only ever catches a cycle — and
|
|
29
|
+
* reaching it is an admission, never a crash.
|
|
30
|
+
*/
|
|
31
|
+
const MAX_FIELD_DEPTH = 16;
|
|
32
|
+
/** A field written in a config: spreads lead to the names they stand for, and nothing is bound. */
|
|
33
|
+
export const WRITTEN_DOWN = {
|
|
34
|
+
spread: (expression) => resolveObjectLiteral(expression),
|
|
35
|
+
bound: () => undefined,
|
|
36
|
+
object: (expression) => resolveObjectLiteral(expression),
|
|
37
|
+
};
|
|
38
|
+
/** Whether an expression is a function written in place — code, and so unreadable. */
|
|
39
|
+
function isFunctionExpression(node) {
|
|
40
|
+
return node.isKind(SyntaxKind.ArrowFunction) || node.isKind(SyntaxKind.FunctionExpression);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The choices a `radio` or `select` offers, or `undefined` when they are not
|
|
44
|
+
* written down as whole `{ label, value }` pairs. Half a list is worse than
|
|
45
|
+
* none: an agent would write a value Puck rejects and have no way to know why.
|
|
46
|
+
*
|
|
47
|
+
* Puck lets a label or a value be an object, and one with a part left out —
|
|
48
|
+
* `value: { x: 1, y: make() }` — would be handed on as the whole value. The
|
|
49
|
+
* reading only says that something somewhere in the list went unread, so any
|
|
50
|
+
* object label or value in a list with a part missing refuses the list; a
|
|
51
|
+
* string or a number cannot be read in part, and a gap beside one — an
|
|
52
|
+
* option's `icon: make()` — leaves the pair whole.
|
|
53
|
+
*/
|
|
54
|
+
function readOptions(reading) {
|
|
55
|
+
const value = reading?.value;
|
|
56
|
+
if (!Array.isArray(value))
|
|
57
|
+
return undefined;
|
|
58
|
+
const options = [];
|
|
59
|
+
for (const entry of value) {
|
|
60
|
+
if (typeof entry !== 'object' || entry === null || Array.isArray(entry))
|
|
61
|
+
return undefined;
|
|
62
|
+
if (!('label' in entry) || !('value' in entry))
|
|
63
|
+
return undefined;
|
|
64
|
+
if (reading?.dropped && (isObject(entry.label) || isObject(entry.value)))
|
|
65
|
+
return undefined;
|
|
66
|
+
options.push({ label: entry.label, value: entry.value });
|
|
67
|
+
}
|
|
68
|
+
return options;
|
|
69
|
+
}
|
|
70
|
+
/** Whether a JSON value is an object or an array — the kinds that can be read in part. */
|
|
71
|
+
function isObject(value) {
|
|
72
|
+
return typeof value === 'object' && value !== null;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* What one key amounts to: the value the caller binds for it, or the one the
|
|
76
|
+
* source writes down, and whether a part of it was left out.
|
|
77
|
+
*
|
|
78
|
+
* A bound value is read as whole as a written one — `max: o.max` beside `b({
|
|
79
|
+
* max: 7 })` IS 7 — so it admits nothing. A key whose value neither reaches is
|
|
80
|
+
* left unread, and admitted there.
|
|
81
|
+
*
|
|
82
|
+
* A written value with a part left out is kept and says so. A string, a number
|
|
83
|
+
* or a list of strings cannot be read in part, so only the options list has a
|
|
84
|
+
* gap to answer for, and `readOptions` does.
|
|
85
|
+
*/
|
|
86
|
+
function keyValue(node, sources) {
|
|
87
|
+
// The binding goes first: `o.label`, with `o` a parameter, names what the
|
|
88
|
+
// call passed, and nothing the source declares can stand in for it.
|
|
89
|
+
const bound = sources.bound(node);
|
|
90
|
+
return bound === undefined ? resolveLiteralValueReading(node) : { value: bound, dropped: false };
|
|
91
|
+
}
|
|
92
|
+
/** The name a shorthand member stands for. */
|
|
93
|
+
function shorthandName(member) {
|
|
94
|
+
return member.asKind(SyntaxKind.ShorthandPropertyAssignment)?.getNameNode();
|
|
95
|
+
}
|
|
96
|
+
/** Whether a name is one of the keys this reader models, and so one it can carry or drop. */
|
|
97
|
+
function isDroppable(name) {
|
|
98
|
+
return DROPPABLE_KEYS.has(name);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* One key of a spread source, carried over what was read above it — or dropped
|
|
102
|
+
* where the source read nothing for it. Shared by every reader that merges a
|
|
103
|
+
* spread by the runtime's rule, field or component.
|
|
104
|
+
*/
|
|
105
|
+
export function carryKey(target, base, key) {
|
|
106
|
+
const value = base[key];
|
|
107
|
+
if (value === undefined)
|
|
108
|
+
delete target[key];
|
|
109
|
+
else
|
|
110
|
+
target[key] = value;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* A key written in a shape this reader cannot take. The value goes with it,
|
|
114
|
+
* because the last write wins at runtime and a spread's value left standing
|
|
115
|
+
* would be reported as the field's own.
|
|
116
|
+
*/
|
|
117
|
+
function clearKey(walk, name) {
|
|
118
|
+
walk.field.unreadable = true;
|
|
119
|
+
if (name === 'type')
|
|
120
|
+
walk.field.type = 'unknown';
|
|
121
|
+
else if (isDroppable(name))
|
|
122
|
+
delete walk.field[name];
|
|
123
|
+
if (MODELED_KEYS.includes(name))
|
|
124
|
+
walk.unknown.add(name);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* A write this reader cannot name — `[key]: …`, or a spread leading nowhere —
|
|
128
|
+
* which may be any key at all, so every one read before it goes.
|
|
129
|
+
*/
|
|
130
|
+
function clearEveryKey(walk) {
|
|
131
|
+
for (const name of MODELED_KEYS) {
|
|
132
|
+
walk.written.add(name);
|
|
133
|
+
clearKey(walk, name);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
/** Applies one walk over another at the position its spread sits — the runtime's own rule. */
|
|
137
|
+
function applyFieldWalk(walk, base) {
|
|
138
|
+
for (const name of base.written) {
|
|
139
|
+
walk.written.add(name);
|
|
140
|
+
if (name === 'type')
|
|
141
|
+
walk.field.type = base.field.type;
|
|
142
|
+
else if (isDroppable(name))
|
|
143
|
+
carryKey(walk.field, base.field, name);
|
|
144
|
+
if (base.unknown.has(name))
|
|
145
|
+
walk.unknown.add(name);
|
|
146
|
+
else
|
|
147
|
+
walk.unknown.delete(name);
|
|
148
|
+
}
|
|
149
|
+
// A spread copies only what the source writes itself, so a prototype the
|
|
150
|
+
// source sets is not carried across it.
|
|
151
|
+
if (base.field.unreadable)
|
|
152
|
+
walk.field.unreadable = true;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Reads one field declaration. Never throws: an unreadable field is reported,
|
|
156
|
+
* not dropped.
|
|
157
|
+
*
|
|
158
|
+
* What the WHOLE declaration amounts to is settled here rather than inside the
|
|
159
|
+
* walk, because a spread source is a fragment and not a declaration of its own:
|
|
160
|
+
* `{ max: 2 }` mentions no type because it is an override, and admitting it as
|
|
161
|
+
* no field at all would carry that admission into every field it overrides.
|
|
162
|
+
*/
|
|
163
|
+
export function readField(node, depth, sources) {
|
|
164
|
+
const { field, written, unknown, inherits } = walkField(node, depth, sources);
|
|
165
|
+
// Puck has no field without a `type`, so an object that never mentions one —
|
|
166
|
+
// itself or through a spread — is something else wearing a field's place:
|
|
167
|
+
// `icon: ICONS`, where the name stands for a lookup table rather than a
|
|
168
|
+
// declaration. Reported as a plain `unknown` it poses as a field whose shape
|
|
169
|
+
// merely went unwritten; the admission says the entry itself is not a field
|
|
170
|
+
// this reader could read. A field with a prototype may inherit any key it
|
|
171
|
+
// does not write, which is the same admission.
|
|
172
|
+
if (!written.has('type') || inherits)
|
|
173
|
+
field.unreadable = true;
|
|
174
|
+
// Puck takes a slot's nesting rules from the field OR from props on the slot
|
|
175
|
+
// its `render` draws — `<Items disallow={['Hero']} />` — and on the canvas
|
|
176
|
+
// the render's props are the ones that bind. `render` is code, which this
|
|
177
|
+
// reader never follows, so a slot that writes neither rule here has rules
|
|
178
|
+
// that are unknown rather than absent. Read as a slot anything may go into,
|
|
179
|
+
// it would be the confident wrong answer this reader exists to avoid.
|
|
180
|
+
if (field.type === 'slot' && field.allow === undefined && field.disallow === undefined)
|
|
181
|
+
field.unreadable = true;
|
|
182
|
+
// `opaque` asserts that nothing describes the field, so it is claimed only
|
|
183
|
+
// when the `ai` block was read whole — or provably never written.
|
|
184
|
+
const schema = field.ai?.schema;
|
|
185
|
+
const aiUnread = unknown.has('ai') || (inherits && !written.has('ai'));
|
|
186
|
+
if (OPAQUE_TYPES.has(field.type) && schema === undefined && !aiUnread)
|
|
187
|
+
field.opaque = true;
|
|
188
|
+
return field;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* The walk itself: the literal's members in source order, so a spread applies
|
|
192
|
+
* where it is written and the key after it wins, exactly as at runtime.
|
|
193
|
+
*/
|
|
194
|
+
function walkField(node, depth, sources) {
|
|
195
|
+
const walk = { field: { type: 'unknown' }, written: new Set(), unknown: new Set(), inherits: false };
|
|
196
|
+
if (depth > MAX_FIELD_DEPTH) {
|
|
197
|
+
clearEveryKey(walk);
|
|
198
|
+
return walk;
|
|
199
|
+
}
|
|
200
|
+
for (const property of node.getProperties()) {
|
|
201
|
+
spendWork();
|
|
202
|
+
const spread = property.asKind(SyntaxKind.SpreadAssignment);
|
|
203
|
+
if (spread) {
|
|
204
|
+
const source = sources.spread(spread.getExpression());
|
|
205
|
+
// A spread that carries nothing overwrites nothing at runtime either.
|
|
206
|
+
if (source === SPREADS_NOTHING)
|
|
207
|
+
continue;
|
|
208
|
+
// One that cannot be followed may overwrite any key beside it.
|
|
209
|
+
if (source)
|
|
210
|
+
applyFieldWalk(walk, walkField(source, depth + 1, sources));
|
|
211
|
+
else
|
|
212
|
+
clearEveryKey(walk);
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
215
|
+
const member = namedMember(property);
|
|
216
|
+
const name = member && propertyKey(member);
|
|
217
|
+
if (!member || name === undefined) {
|
|
218
|
+
clearEveryKey(walk);
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
221
|
+
if (setsPrototype(member)) {
|
|
222
|
+
walk.inherits = true;
|
|
223
|
+
continue;
|
|
224
|
+
}
|
|
225
|
+
walk.written.add(name);
|
|
226
|
+
// `defaultItemProps() { … }`, `get max() { … }` — each writes its key with
|
|
227
|
+
// something this reader cannot take, and at runtime still overwrites
|
|
228
|
+
// whatever a spread above it put there. A shorthand of a key the manifest
|
|
229
|
+
// ignores names code as often as not, and is admitted the same way.
|
|
230
|
+
const value = member.isKind(SyntaxKind.PropertyAssignment)
|
|
231
|
+
? member.getInitializerOrThrow()
|
|
232
|
+
: MODELED_KEYS.includes(name)
|
|
233
|
+
? shorthandName(member)
|
|
234
|
+
: undefined;
|
|
235
|
+
if (value)
|
|
236
|
+
readFieldMember(walk, name, value, depth, sources);
|
|
237
|
+
else
|
|
238
|
+
clearKey(walk, name);
|
|
239
|
+
}
|
|
240
|
+
return walk;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* One `type` / `label` / `options` / … entry of a field declaration, and what
|
|
244
|
+
* became of it: taken whole, taken in part, not taken at all, or a key the
|
|
245
|
+
* manifest does not model.
|
|
246
|
+
*/
|
|
247
|
+
function readFieldMember(walk, name, initializer, depth, sources) {
|
|
248
|
+
const outcome = readFieldValue(walk.field, name, initializer, depth, sources);
|
|
249
|
+
if (outcome === 'unread')
|
|
250
|
+
clearKey(walk, name);
|
|
251
|
+
else if (outcome === 'partial') {
|
|
252
|
+
// What did read is kept; the field admits the rest.
|
|
253
|
+
walk.field.unreadable = true;
|
|
254
|
+
walk.unknown.add(name);
|
|
255
|
+
}
|
|
256
|
+
else if (outcome === 'read')
|
|
257
|
+
walk.unknown.delete(name);
|
|
258
|
+
}
|
|
259
|
+
function readFieldValue(field, name, initializer, depth, sources) {
|
|
260
|
+
switch (name) {
|
|
261
|
+
case 'type':
|
|
262
|
+
case 'label': {
|
|
263
|
+
const value = keyValue(initializer, sources)?.value;
|
|
264
|
+
if (typeof value !== 'string')
|
|
265
|
+
return 'unread';
|
|
266
|
+
field[name] = value;
|
|
267
|
+
return 'read';
|
|
268
|
+
}
|
|
269
|
+
case 'min':
|
|
270
|
+
case 'max': {
|
|
271
|
+
const value = keyValue(initializer, sources)?.value;
|
|
272
|
+
if (typeof value !== 'number')
|
|
273
|
+
return 'unread';
|
|
274
|
+
field[name] = value;
|
|
275
|
+
return 'read';
|
|
276
|
+
}
|
|
277
|
+
case 'options': {
|
|
278
|
+
const options = readOptions(keyValue(initializer, sources));
|
|
279
|
+
if (!options)
|
|
280
|
+
return 'unread';
|
|
281
|
+
field.options = options;
|
|
282
|
+
return 'read';
|
|
283
|
+
}
|
|
284
|
+
case 'allow':
|
|
285
|
+
case 'disallow': {
|
|
286
|
+
const value = keyValue(initializer, sources)?.value;
|
|
287
|
+
if (!Array.isArray(value) || !value.every((entry) => typeof entry === 'string'))
|
|
288
|
+
return 'unread';
|
|
289
|
+
field[name] = value;
|
|
290
|
+
return 'read';
|
|
291
|
+
}
|
|
292
|
+
case 'arrayFields':
|
|
293
|
+
case 'objectFields': {
|
|
294
|
+
const nested = readFieldSet(initializer, depth + 1, sources);
|
|
295
|
+
if (!nested)
|
|
296
|
+
return 'unread';
|
|
297
|
+
field[name] = nested.fields;
|
|
298
|
+
return nested.unreadable ? 'partial' : 'read';
|
|
299
|
+
}
|
|
300
|
+
case 'ai': {
|
|
301
|
+
// `ai: HERO_AI` names the annotation rather than writing it out, and a
|
|
302
|
+
// reader that stops at the name calls the field opaque with the schema
|
|
303
|
+
// that describes it two lines up. The names inside it — `...BASE_AI`,
|
|
304
|
+
// `schema: SCHEMA` — are followed too, as a component's are.
|
|
305
|
+
const reading = literalObjectReading(sources.object(initializer) ?? initializer);
|
|
306
|
+
// A reading with a gap and nothing else is no reading: `ai: {}` beside
|
|
307
|
+
// the admission would pass for an annotation written empty.
|
|
308
|
+
if (!reading || (reading.dropped && Object.keys(reading.value).length === 0))
|
|
309
|
+
return 'unread';
|
|
310
|
+
field.ai = reading.value;
|
|
311
|
+
// An entry left out may be the schema itself.
|
|
312
|
+
return reading.dropped ? 'partial' : 'read';
|
|
313
|
+
}
|
|
314
|
+
default: {
|
|
315
|
+
// A function-valued key (defaultItemProps, getItemSummary, render) is
|
|
316
|
+
// the readable/unreadable boundary. Say so rather than staying silent.
|
|
317
|
+
if (isFunctionExpression(initializer))
|
|
318
|
+
field.unreadable = true;
|
|
319
|
+
return 'unmodeled';
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Reads a `Record<string, Field>` — a component's `fields`, a nested
|
|
325
|
+
* array/object field set, or the page's `root.fields` — the one field-set
|
|
326
|
+
* reader every owner of one shares.
|
|
327
|
+
*
|
|
328
|
+
* Walked in source order, spreads included, so `{ ...BASE, x }` reads BASE's
|
|
329
|
+
* entries and then `x`, the later write of a name winning as it does at
|
|
330
|
+
* runtime. A spread that cannot be followed, and a key this reader cannot name
|
|
331
|
+
* (`[key]: …`), may each write any entry, so the entries before them go and
|
|
332
|
+
* the set is admitted; the owner turns that into its own admission. A spread
|
|
333
|
+
* shown to carry nothing — an argument the call omits — writes nothing, and
|
|
334
|
+
* `__proto__: base` hands the set entries Puck's `for…in` reaches too, so it
|
|
335
|
+
* is admitted the same way.
|
|
336
|
+
*
|
|
337
|
+
* An entry written as a name (`layout: layoutField`) is followed to the
|
|
338
|
+
* declaration it stands for, and one a helper builds (`buttons:
|
|
339
|
+
* ctaButtonArrayField()`) is read from the helper, so a field set split across
|
|
340
|
+
* files or behind a builder reads the same as one written in place. An entry
|
|
341
|
+
* this reader cannot follow — a getter, a method, a name leading nowhere —
|
|
342
|
+
* keeps its place: the prop is real and an agent may write to it, so the
|
|
343
|
+
* manifest names it and admits the constraints are unknown.
|
|
344
|
+
*
|
|
345
|
+
* The set itself may be named too — `fields: sharedFields`, `objectFields:
|
|
346
|
+
* sub` — and is followed the same way. Undefined is left for the name that
|
|
347
|
+
* cannot be followed at all, which the caller turns into its own admission.
|
|
348
|
+
*/
|
|
349
|
+
export function readFieldSet(node, depth, sources) {
|
|
350
|
+
const literal = node && sources.object(node);
|
|
351
|
+
return literal && walkFieldSet(literal, depth, sources);
|
|
352
|
+
}
|
|
353
|
+
function walkFieldSet(literal, depth, sources) {
|
|
354
|
+
if (depth > MAX_FIELD_DEPTH)
|
|
355
|
+
return { fields: {}, unreadable: true };
|
|
356
|
+
const reading = { fields: {}, unreadable: false };
|
|
357
|
+
for (const property of literal.getProperties()) {
|
|
358
|
+
spendWork();
|
|
359
|
+
const spread = property.asKind(SyntaxKind.SpreadAssignment);
|
|
360
|
+
if (spread) {
|
|
361
|
+
const source = sources.spread(spread.getExpression());
|
|
362
|
+
if (source === SPREADS_NOTHING)
|
|
363
|
+
continue;
|
|
364
|
+
const merged = source && walkFieldSet(source, depth + 1, sources);
|
|
365
|
+
if (!merged || merged.unreadable) {
|
|
366
|
+
reading.fields = {};
|
|
367
|
+
reading.unreadable = true;
|
|
368
|
+
}
|
|
369
|
+
if (merged)
|
|
370
|
+
Object.assign(reading.fields, merged.fields);
|
|
371
|
+
continue;
|
|
372
|
+
}
|
|
373
|
+
const member = namedMember(property);
|
|
374
|
+
const key = member && propertyKey(member);
|
|
375
|
+
if (!member || key === undefined) {
|
|
376
|
+
reading.fields = {};
|
|
377
|
+
reading.unreadable = true;
|
|
378
|
+
continue;
|
|
379
|
+
}
|
|
380
|
+
// Puck walks a field set with `for…in`, which reaches every entry the
|
|
381
|
+
// prototype carries — none of them written here, so the set is admitted.
|
|
382
|
+
// A `null` prototype carries nothing.
|
|
383
|
+
if (setsPrototype(member)) {
|
|
384
|
+
if (!inheritsNothing(member))
|
|
385
|
+
reading.unreadable = true;
|
|
386
|
+
continue;
|
|
387
|
+
}
|
|
388
|
+
// `['__proto__']: …` is an ordinary own entry at runtime, and one no record
|
|
389
|
+
// of ours can hold: assigning it replaces the record's prototype instead of
|
|
390
|
+
// adding a key, so someone else's config could reach through this reader
|
|
391
|
+
// and change what every later object inherits. It is admitted instead.
|
|
392
|
+
if (key === '__proto__') {
|
|
393
|
+
reading.unreadable = true;
|
|
394
|
+
continue;
|
|
395
|
+
}
|
|
396
|
+
const value = writtenValue(member);
|
|
397
|
+
reading.fields[key] = (value && readFieldDeclaration(value, depth, sources)) ?? {
|
|
398
|
+
type: 'unknown',
|
|
399
|
+
unreadable: true,
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
return reading;
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* One entry of a field set: the declaration a name stands for, or the field a
|
|
406
|
+
* helper call builds. Undefined when neither can be followed, which the caller
|
|
407
|
+
* reports as a prop whose shape is unknown.
|
|
408
|
+
*
|
|
409
|
+
* An entry sits at the depth of the set holding it: the set is the level, and
|
|
410
|
+
* counting the entry again would stop a field written on purpose at half the
|
|
411
|
+
* depth the cap promises.
|
|
412
|
+
*/
|
|
413
|
+
function readFieldDeclaration(node, depth, sources) {
|
|
414
|
+
const literal = sources.object(node);
|
|
415
|
+
if (literal)
|
|
416
|
+
return readField(literal, depth, sources);
|
|
417
|
+
const call = resolveCallExpression(node);
|
|
418
|
+
// The refusal's reason is dropped: there is nowhere on a field to record why
|
|
419
|
+
// a builder was refused, and the entry says the shape is unknown either way.
|
|
420
|
+
return call ? sources.builder?.(call, depth).field : undefined;
|
|
421
|
+
}
|
|
422
|
+
//# sourceMappingURL=field-projection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field-projection.js","sourceRoot":"","sources":["../../../../src/puck-manifest/field-projection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgE,UAAU,EAAE,MAAM,UAAU,CAAC;AACpG,OAAO,EACL,eAAe,EACf,oBAAoB,EAEpB,WAAW,EACX,WAAW,EACX,eAAe,EACf,aAAa,EACb,SAAS,EAET,YAAY,GACb,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,qBAA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AC;IACrC,IAAI,OAAO;QAAE,OAAO,SAAS,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IACvD,MAAM,IAAI,GAAG,qBAAqB,CAAC,IAAI,CAAC,CAAC;IACzC,6EAA6E;IAC7E,6EAA6E;IAC7E,OAAO,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AACjE,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { endpointReaderOptions } from './components-endpoint.js';
|
|
2
|
+
export { type ReadPuckConfigOptions, readPuckConfig } from './read-config.js';
|
|
3
|
+
export type { JsonValue, ManifestComponent, ManifestField, PuckManifest } from './types.js';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/puck-manifest/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,KAAK,qBAAqB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC9E,YAAY,EAAE,SAAS,EAAE,iBAAiB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/puck-manifest/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAA8B,cAAc,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { type Node, type ObjectLiteralExpression } from 'ts-morph';
|
|
2
|
+
import type { JsonValue } from './types.js';
|
|
3
|
+
export { limitOutput, MAX_OUTPUT, MAX_OUTPUT_BYTES, MAX_WORK, OutputBudgetExceeded, spendWork, WorkBudgetExceeded, } from './reading-budget.js';
|
|
4
|
+
export { expressionKey, holdsNothing, inheritsNothing, propertyKey, setsPrototype } from './source-reference.js';
|
|
5
|
+
export { asObjectLiteral, type NamedMember, namedMember, unwrapExpression, writtenValue } from './syntax.js';
|
|
6
|
+
/**
|
|
7
|
+
* Reads a TypeScript expression as a JSON value, or `undefined` when it is
|
|
8
|
+
* computed rather than written down — in whole or in part.
|
|
9
|
+
*
|
|
10
|
+
* `undefined` is load-bearing: a config full of function calls must produce an
|
|
11
|
+
* absent value, never an invented one. Callers turn that absence into an
|
|
12
|
+
* explicit marker so the agent is told what is unknown instead of being handed
|
|
13
|
+
* a guess. A value with a part left out — `{ id: makeId(), label: 'x' }` — is
|
|
14
|
+
* no value here either, because handed on without that fact it passes for the
|
|
15
|
+
* whole; a caller that can admit the gap asks `literalValueReading` for the
|
|
16
|
+
* part that did read.
|
|
17
|
+
*/
|
|
18
|
+
export declare function literalValue(node: Node): JsonValue | undefined;
|
|
19
|
+
/** A value read as plain data, and whether any part of it — at any depth — had to be left out. */
|
|
20
|
+
export interface ValueReading {
|
|
21
|
+
value: JsonValue;
|
|
22
|
+
dropped: boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* `literalValue`, keeping the part that read when something had to be left
|
|
26
|
+
* out, and saying so. Every key the value holds is the runtime's own last
|
|
27
|
+
* write of it; `dropped` says the value may hold more than it shows.
|
|
28
|
+
*/
|
|
29
|
+
export declare function literalValueReading(node: Node): ValueReading | undefined;
|
|
30
|
+
/** Why a walk could not read the last write of a key. */
|
|
31
|
+
export type UnreadWrite =
|
|
32
|
+
/** The owner could not take the value written. */
|
|
33
|
+
'value'
|
|
34
|
+
/** A method or a getter writes the key with code this reader does not run. */
|
|
35
|
+
| 'code'
|
|
36
|
+
/** A setter writes it last: undefined on its own, and code beside a getter. */
|
|
37
|
+
| 'setter'
|
|
38
|
+
/**
|
|
39
|
+
* `['__proto__']` — an own key at runtime, but one no record of ours can
|
|
40
|
+
* hold, because assigning it replaces the record's prototype instead of
|
|
41
|
+
* adding a key.
|
|
42
|
+
*/
|
|
43
|
+
| 'reserved';
|
|
44
|
+
/**
|
|
45
|
+
* One object literal walked in source order, by the runtime's own rules. The
|
|
46
|
+
* owner decides what a value is; the walk decides which write of a key is the
|
|
47
|
+
* last one, and what the owner could not see.
|
|
48
|
+
*/
|
|
49
|
+
export interface LiteralWalk<V> {
|
|
50
|
+
/** Every key whose last write the owner could read, with what it read, in the order the runtime keeps them. */
|
|
51
|
+
entries: Map<string, V>;
|
|
52
|
+
/** Keys whose last write could not be read, each with the reason. */
|
|
53
|
+
unread: Map<string, UnreadWrite>;
|
|
54
|
+
/** Keys written before a write the walk cannot name, which may have replaced them, that nothing later settled. */
|
|
55
|
+
cleared: Set<string>;
|
|
56
|
+
/** A write the walk cannot name — a computed key it cannot resolve, a spread it cannot follow — so the object may hold any key. */
|
|
57
|
+
lost: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* The member of this literal behind the last such write — the spread, or the
|
|
60
|
+
* member whose computed name could not be worked out — so a reason can point
|
|
61
|
+
* at it. A spread whose own walk lost something is named here too.
|
|
62
|
+
*/
|
|
63
|
+
lostAt?: Node;
|
|
64
|
+
/** `__proto__` hands the object a prototype, so a key it does not write itself may be inherited. */
|
|
65
|
+
inherits: boolean;
|
|
66
|
+
}
|
|
67
|
+
/** A spread shown to carry nothing — `...null`, or `{ ...overrides }` where the call omitted `overrides`. */
|
|
68
|
+
export declare const SPREADS_NOTHING: unique symbol;
|
|
69
|
+
/** What an owner hands a walk: who it is, how to read one value, and where a spread leads. */
|
|
70
|
+
export interface LiteralWalkHooks<V> {
|
|
71
|
+
/**
|
|
72
|
+
* Names the owner. A walk is remembered per owner and literal for the length
|
|
73
|
+
* of one reading — unless it was cut short, see `walkLiteral` — so two owners
|
|
74
|
+
* that read the same literal differently never share an answer, which holds
|
|
75
|
+
* only while both hooks answer from the node they are handed and nothing else.
|
|
76
|
+
*/
|
|
77
|
+
kind: string;
|
|
78
|
+
/** What one member writes — the value of `key: value`, or the name a shorthand stands for — or undefined where the owner cannot take it. */
|
|
79
|
+
read(value: Node): V | undefined;
|
|
80
|
+
/** The literal a spread reaches, `SPREADS_NOTHING` where it provably carries none, or undefined where it cannot be followed. */
|
|
81
|
+
spread(expression: Node): ObjectLiteralExpression | typeof SPREADS_NOTHING | undefined;
|
|
82
|
+
}
|
|
83
|
+
/** Whether a walk saw every write of its object: nothing unread, lost or inherited. */
|
|
84
|
+
export declare function walkIsWhole<V>(walk: LiteralWalk<V>): boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Source text as a reason quotes it: on one line, cut short on a whole
|
|
87
|
+
* character — an emoji is two 16-bit string units, and cutting between them
|
|
88
|
+
* leaves half of one — and marked where it was cut. Text with nothing in it is
|
|
89
|
+
* named as such rather than quoted as a gap in the sentence.
|
|
90
|
+
*/
|
|
91
|
+
export declare function excerpt(text: string): string;
|
|
92
|
+
/**
|
|
93
|
+
* Runs one reading of a config with its walks remembered and its work counted.
|
|
94
|
+
* A literal spread into ten objects is walked once rather than ten times, and
|
|
95
|
+
* a chain of such spreads costs its length rather than its width to the power
|
|
96
|
+
* of its depth.
|
|
97
|
+
*/
|
|
98
|
+
export declare function withReadingSession<T>(read: () => T): T;
|
|
99
|
+
/**
|
|
100
|
+
* Walks an object literal's members in source order — the one walk every
|
|
101
|
+
* owner of a literal shares, so each rule below is written once and holds
|
|
102
|
+
* wherever a literal is read:
|
|
103
|
+
*
|
|
104
|
+
* - A spread applies where it is written. One the owner can follow merges its
|
|
105
|
+
* own walk there; one of `null` or `undefined` writes nothing; any other may
|
|
106
|
+
* write any key, so every key before it is cleared and the walk is `lost`.
|
|
107
|
+
* - A computed key standing for a `const` is that key. Any other clears every
|
|
108
|
+
* key before it, the same way.
|
|
109
|
+
* - A method, getter or setter writes its key with code, so the key is unread.
|
|
110
|
+
* A setter alone reads back undefined, which is no value either.
|
|
111
|
+
* - `__proto__: x` hands the object a prototype, unless `x` holds nothing.
|
|
112
|
+
* - A shorthand is read as the name it stands for.
|
|
113
|
+
* - The last write of a key wins, and an unreadable one takes the earlier
|
|
114
|
+
* value with it.
|
|
115
|
+
*/
|
|
116
|
+
export declare function walkLiteral<V>(literal: ObjectLiteralExpression, hooks: LiteralWalkHooks<V>): LiteralWalk<V>;
|
|
117
|
+
/**
|
|
118
|
+
* Whether the walked object may hold a key the walk could not read — unread,
|
|
119
|
+
* cleared, or reachable through a write it cannot name or a prototype —
|
|
120
|
+
* as opposed to one it provably does not write at all.
|
|
121
|
+
*/
|
|
122
|
+
export declare function mayHoldUnread<V>(walk: LiteralWalk<V>, key: string): boolean;
|
|
123
|
+
/** An object read as plain data, and whether any of its entries — at any depth — had to be left out. */
|
|
124
|
+
export interface ObjectReading {
|
|
125
|
+
value: Record<string, JsonValue>;
|
|
126
|
+
dropped: boolean;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* An object read as plain data, with the names in it followed: the part that
|
|
130
|
+
* read, and whether anything was left out — a computed value, a method, a key
|
|
131
|
+
* it could not spell, a spread or a name it could not follow, a prototype.
|
|
132
|
+
* Every key the value holds is the runtime's own last write of it, so a caller
|
|
133
|
+
* that owes an admission makes one for the rest rather than presenting a wrong
|
|
134
|
+
* value. Undefined where the node does not lead to an object literal at all.
|
|
135
|
+
*/
|
|
136
|
+
export declare function literalObjectReading(object: Node): ObjectReading | undefined;
|
|
137
|
+
/**
|
|
138
|
+
* The JSON value an expression amounts to, following a name to its `const`
|
|
139
|
+
* declaration when the value is not written in place.
|
|
140
|
+
*
|
|
141
|
+
* `options: sizeOptions` is the shape this exists for: the legal values are two
|
|
142
|
+
* lines up, and reading the name as unreadable loses them. Only `const`
|
|
143
|
+
* declarations count — a `let` can be reassigned after the line being read.
|
|
144
|
+
* `LABELS.hero` is read out of the object `LABELS` stands for, the last write
|
|
145
|
+
* of the key winning as it does at runtime; a key a spread, getter or unknown
|
|
146
|
+
* computed name may have overwritten is no value at all.
|
|
147
|
+
*
|
|
148
|
+
* A value with a part left out is no value here, as for `literalValue`;
|
|
149
|
+
* `resolveLiteralValueReading` keeps the part that read.
|
|
150
|
+
*
|
|
151
|
+
* Known limits, both inherited from the walk: two barrels exporting the same
|
|
152
|
+
* name resolve to whichever one the compiler picked, and a `const` array is
|
|
153
|
+
* followed rather than frozen — `const o = [...]; o.push(x)` elsewhere in the
|
|
154
|
+
* module reads here as the value before the push.
|
|
155
|
+
*/
|
|
156
|
+
export declare function resolveLiteralValue(node: Node): JsonValue | undefined;
|
|
157
|
+
/**
|
|
158
|
+
* `resolveLiteralValue`, keeping the part that read when something had to be
|
|
159
|
+
* left out, and saying so — `items: ITEMS` where each item's `id` is computed
|
|
160
|
+
* — so an owner admits the gap instead of presenting the rest as the whole.
|
|
161
|
+
*/
|
|
162
|
+
export declare function resolveLiteralValueReading(node: Node): ValueReading | undefined;
|
|
163
|
+
//# sourceMappingURL=literal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"literal.d.ts","sourceRoot":"","sources":["../../../../src/puck-manifest/literal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,EAAE,KAAK,uBAAuB,EAAuB,MAAM,UAAU,CAAC;AAWxF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAG5C,OAAO,EACL,WAAW,EACX,UAAU,EACV,gBAAgB,EAChB,QAAQ,EACR,oBAAoB,EACpB,SAAS,EACT,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACjH,OAAO,EAAE,eAAe,EAAE,KAAK,WAAW,EAAE,WAAW,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAO7G;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE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