polen 0.10.0 → 0.11.0-next.10
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/build/api/api.d.ts +1 -0
- package/build/api/api.d.ts.map +1 -1
- package/build/api/api.js +1 -0
- package/build/api/api.js.map +1 -1
- package/build/api/config/configurator.d.ts +55 -26
- package/build/api/config/configurator.d.ts.map +1 -1
- package/build/api/config/configurator.js +27 -9
- package/build/api/config/configurator.js.map +1 -1
- package/build/api/config/merge.d.ts.map +1 -1
- package/build/api/config/merge.js +0 -11
- package/build/api/config/merge.js.map +1 -1
- package/build/api/content/metadata.d.ts +8 -2
- package/build/api/content/metadata.d.ts.map +1 -1
- package/build/api/content/metadata.js +1 -1
- package/build/api/content/metadata.js.map +1 -1
- package/build/api/schema/data-sources/data-sources.d.ts +1 -0
- package/build/api/schema/data-sources/data-sources.d.ts.map +1 -1
- package/build/api/schema/data-sources/data-sources.js +1 -0
- package/build/api/schema/data-sources/data-sources.js.map +1 -1
- package/build/api/schema/data-sources/introspection/introspection.d.ts +83 -0
- package/build/api/schema/data-sources/introspection/introspection.d.ts.map +1 -0
- package/build/api/schema/data-sources/introspection/introspection.js +110 -0
- package/build/api/schema/data-sources/introspection/introspection.js.map +1 -0
- package/build/api/schema/data-sources/memory/memory.d.ts +2 -2
- package/build/api/schema/data-sources/memory/memory.d.ts.map +1 -1
- package/build/api/schema/data-sources/memory/memory.js +1 -3
- package/build/api/schema/data-sources/memory/memory.js.map +1 -1
- package/build/api/schema/data-sources/schema-directory/file-name-expression/file-name-expression.d.ts +7 -3
- package/build/api/schema/data-sources/schema-directory/file-name-expression/file-name-expression.d.ts.map +1 -1
- package/build/api/schema/data-sources/schema-directory/file-name-expression/file-name-expression.js +15 -11
- package/build/api/schema/data-sources/schema-directory/file-name-expression/file-name-expression.js.map +1 -1
- package/build/api/schema/data-sources/schema-directory/schema-directory.d.ts +16 -7
- package/build/api/schema/data-sources/schema-directory/schema-directory.d.ts.map +1 -1
- package/build/api/schema/data-sources/schema-directory/schema-directory.js +26 -7
- package/build/api/schema/data-sources/schema-directory/schema-directory.js.map +1 -1
- package/build/api/schema/data-sources/schema-file/schema-file.d.ts +7 -2
- package/build/api/schema/data-sources/schema-file/schema-file.d.ts.map +1 -1
- package/build/api/schema/data-sources/schema-file/schema-file.js +13 -5
- package/build/api/schema/data-sources/schema-file/schema-file.js.map +1 -1
- package/build/api/schema/metadata.d.ts +16 -0
- package/build/api/schema/metadata.d.ts.map +1 -0
- package/build/api/schema/metadata.js +19 -0
- package/build/api/schema/metadata.js.map +1 -0
- package/build/api/schema/read.d.ts +85 -11
- package/build/api/schema/read.d.ts.map +1 -1
- package/build/api/schema/read.js +15 -6
- package/build/api/schema/read.js.map +1 -1
- package/build/api/schema/schema.d.ts +33 -2
- package/build/api/schema/schema.d.ts.map +1 -1
- package/build/api/schema/schema.js +42 -0
- package/build/api/schema/schema.js.map +1 -1
- package/build/api/schema-source/index.d.ts +2 -0
- package/build/api/schema-source/index.d.ts.map +1 -0
- package/build/api/schema-source/index.js +2 -0
- package/build/api/schema-source/index.js.map +1 -0
- package/build/api/schema-source/schema-source.d.ts +33 -0
- package/build/api/schema-source/schema-source.d.ts.map +1 -0
- package/build/api/schema-source/schema-source.js +137 -0
- package/build/api/schema-source/schema-source.js.map +1 -0
- package/build/api/static/manifest.d.ts +1 -2
- package/build/api/static/manifest.d.ts.map +1 -1
- package/build/api/static/manifest.js +1 -1
- package/build/api/static/manifest.js.map +1 -1
- package/build/api/vite/plugins/build.d.ts.map +1 -1
- package/build/api/vite/plugins/build.js +3 -0
- package/build/api/vite/plugins/build.js.map +1 -1
- package/build/api/vite/plugins/core.d.ts +1 -0
- package/build/api/vite/plugins/core.d.ts.map +1 -1
- package/build/api/vite/plugins/core.js +25 -22
- package/build/api/vite/plugins/core.js.map +1 -1
- package/build/api/vite/plugins/main.d.ts.map +1 -1
- package/build/api/vite/plugins/main.js +1 -8
- package/build/api/vite/plugins/main.js.map +1 -1
- package/build/api/vite/plugins/schema-assets.d.ts +22 -0
- package/build/api/vite/plugins/schema-assets.d.ts.map +1 -0
- package/build/api/vite/plugins/schema-assets.js +310 -0
- package/build/api/vite/plugins/schema-assets.js.map +1 -0
- package/build/api/vite/plugins/serve.d.ts.map +1 -1
- package/build/api/vite/plugins/serve.js +11 -0
- package/build/api/vite/plugins/serve.js.map +1 -1
- package/build/cli/commands/open.js +1 -1
- package/build/cli/commands/open.js.map +1 -1
- package/build/lib/grafaid/schema/schema.d.ts +1 -1
- package/build/lib/grafaid/schema/schema.d.ts.map +1 -1
- package/build/lib/grafaid/schema/schema.js +1 -1
- package/build/lib/grafaid/schema/schema.js.map +1 -1
- package/build/lib/graphql-change/change-groups.d.ts +2 -0
- package/build/lib/graphql-change/change-groups.d.ts.map +1 -1
- package/build/lib/graphql-change/change-groups.js +54 -0
- package/build/lib/graphql-change/change-groups.js.map +1 -1
- package/build/lib/kit-temp.d.ts +9 -0
- package/build/lib/kit-temp.d.ts.map +1 -1
- package/build/lib/kit-temp.js +14 -2
- package/build/lib/kit-temp.js.map +1 -1
- package/build/lib/path-map/path-map.d.ts.map +1 -1
- package/build/lib/path-map/path-map.js +3 -1
- package/build/lib/path-map/path-map.js.map +1 -1
- package/build/lib/react-router-aid/react-router-aid.d.ts +5 -3
- package/build/lib/react-router-aid/react-router-aid.d.ts.map +1 -1
- package/build/lib/react-router-aid/react-router-aid.js +7 -4
- package/build/lib/react-router-aid/react-router-aid.js.map +1 -1
- package/build/project-data.d.ts +3 -11
- package/build/project-data.d.ts.map +1 -1
- package/build/template/components/Changelog.d.ts +3 -3
- package/build/template/components/Changelog.d.ts.map +1 -1
- package/build/template/components/Changelog.js +8 -84
- package/build/template/components/Changelog.js.map +1 -1
- package/build/template/components/CodeBlock.d.ts +2 -0
- package/build/template/components/CodeBlock.d.ts.map +1 -1
- package/build/template/components/CodeBlock.js +1 -4
- package/build/template/components/CodeBlock.js.map +1 -1
- package/build/template/components/ComponentDispatch.d.ts +34 -0
- package/build/template/components/ComponentDispatch.d.ts.map +1 -0
- package/build/template/components/ComponentDispatch.js +33 -0
- package/build/template/components/ComponentDispatch.js.map +1 -0
- package/build/template/components/ReferenceLink.d.ts +19 -0
- package/build/template/components/ReferenceLink.d.ts.map +1 -0
- package/build/template/components/ReferenceLink.js +19 -0
- package/build/template/components/ReferenceLink.js.map +1 -0
- package/build/template/components/TypeAnnotation.d.ts.map +1 -1
- package/build/template/components/TypeAnnotation.js +3 -3
- package/build/template/components/TypeAnnotation.js.map +1 -1
- package/build/template/components/TypeFieldsLinkList.d.ts.map +1 -1
- package/build/template/components/TypeFieldsLinkList.js +4 -4
- package/build/template/components/TypeFieldsLinkList.js.map +1 -1
- package/build/template/components/TypeIndex.js +2 -2
- package/build/template/components/TypeIndex.js.map +1 -1
- package/build/template/components/VersionSelector.d.ts +7 -0
- package/build/template/components/VersionSelector.d.ts.map +1 -0
- package/build/template/components/VersionSelector.js +30 -0
- package/build/template/components/VersionSelector.js.map +1 -0
- package/build/template/components/graphql/type-link.d.ts.map +1 -1
- package/build/template/components/graphql/type-link.js +2 -2
- package/build/template/components/graphql/type-link.js.map +1 -1
- package/build/template/hooks/useVersionPath.d.ts +6 -0
- package/build/template/hooks/useVersionPath.d.ts.map +1 -0
- package/build/template/hooks/useVersionPath.js +10 -0
- package/build/template/hooks/useVersionPath.js.map +1 -0
- package/build/template/layouts/ChangelogLayout.d.ts.map +1 -0
- package/build/template/{components → layouts}/ChangelogLayout.js +1 -1
- package/build/template/layouts/ChangelogLayout.js.map +1 -0
- package/build/template/layouts/index.d.ts +1 -0
- package/build/template/layouts/index.d.ts.map +1 -1
- package/build/template/layouts/index.js +1 -0
- package/build/template/layouts/index.js.map +1 -1
- package/build/template/lib/fetch-text.d.ts +8 -0
- package/build/template/lib/fetch-text.d.ts.map +1 -0
- package/build/template/lib/fetch-text.js +14 -0
- package/build/template/lib/fetch-text.js.map +1 -0
- package/build/template/lib/polen-url.d.ts +14 -0
- package/build/template/lib/polen-url.d.ts.map +1 -1
- package/build/template/lib/polen-url.js +16 -0
- package/build/template/lib/polen-url.js.map +1 -1
- package/build/template/lib/schema-utils/constants.d.ts +5 -0
- package/build/template/lib/schema-utils/constants.d.ts.map +1 -0
- package/build/template/lib/schema-utils/constants.js +5 -0
- package/build/template/lib/schema-utils/constants.js.map +1 -0
- package/build/template/lib/schema-utils/schema-utils.d.ts +15 -0
- package/build/template/lib/schema-utils/schema-utils.d.ts.map +1 -0
- package/build/template/lib/schema-utils/schema-utils.js +37 -0
- package/build/template/lib/schema-utils/schema-utils.js.map +1 -0
- package/build/template/routes/changelog.d.ts +4 -3
- package/build/template/routes/changelog.d.ts.map +1 -1
- package/build/template/routes/changelog.js +15 -9
- package/build/template/routes/changelog.js.map +1 -1
- package/build/template/routes/index.js +2 -2
- package/build/template/routes/index.js.map +1 -1
- package/build/template/routes/pages.d.ts +10 -0
- package/build/template/routes/pages.d.ts.map +1 -0
- package/build/template/routes/pages.js +76 -0
- package/build/template/routes/pages.js.map +1 -0
- package/build/template/routes/reference.d.ts +35 -6
- package/build/template/routes/reference.d.ts.map +1 -1
- package/build/template/routes/reference.js +97 -14
- package/build/template/routes/reference.js.map +1 -1
- package/build/template/routes/root.d.ts.map +1 -1
- package/build/template/routes/root.js +11 -75
- package/build/template/routes/root.js.map +1 -1
- package/build/template/server/app.d.ts +22 -1
- package/build/template/server/app.d.ts.map +1 -1
- package/build/template/server/app.js +19 -9
- package/build/template/server/app.js.map +1 -1
- package/build/template/server/main.js +9 -1
- package/build/template/server/main.js.map +1 -1
- package/build/template/server/ssg/generate.js +2 -2
- package/build/template/server/ssg/generate.js.map +1 -1
- package/build/template/server/ssg/get-route-paths.d.ts +1 -1
- package/build/template/server/ssg/get-route-paths.d.ts.map +1 -1
- package/build/template/server/ssg/get-route-paths.js +90 -27
- package/build/template/server/ssg/get-route-paths.js.map +1 -1
- package/build/template/sources/schema-source.d.ts +15 -0
- package/build/template/sources/schema-source.d.ts.map +1 -0
- package/build/template/sources/schema-source.js +64 -0
- package/build/template/sources/schema-source.js.map +1 -0
- package/package.json +16 -17
- package/src/api/api.ts +1 -0
- package/src/api/config/configurator.ts +86 -36
- package/src/api/config/merge.ts +0 -16
- package/src/api/content/metadata.ts +1 -1
- package/src/api/schema/data-sources/data-sources.ts +1 -0
- package/src/api/schema/data-sources/introspection/introspection.ts +213 -0
- package/src/api/schema/data-sources/memory/memory.ts +3 -5
- package/src/api/schema/data-sources/schema-directory/file-name-expression/file-name-expression.ts +29 -13
- package/src/api/schema/data-sources/schema-directory/schema-directory.ts +56 -16
- package/src/api/schema/data-sources/schema-file/schema-file.ts +16 -7
- package/src/api/schema/metadata.ts +23 -0
- package/src/api/schema/read.ts +109 -18
- package/src/api/schema/schema.ts +62 -2
- package/src/api/schema-source/index.ts +1 -0
- package/src/api/schema-source/schema-source.ts +189 -0
- package/src/api/static/manifest.ts +1 -1
- package/src/api/vite/plugins/build.ts +3 -0
- package/src/api/vite/plugins/core.ts +27 -22
- package/src/api/vite/plugins/main.ts +1 -9
- package/src/api/vite/plugins/schema-assets.ts +364 -0
- package/src/api/vite/plugins/serve.ts +15 -8
- package/src/cli/commands/open.ts +1 -1
- package/src/lib/grafaid/schema/schema.ts +1 -0
- package/src/lib/graphql-change/change-groups.ts +57 -0
- package/src/lib/kit-temp.ts +15 -2
- package/src/lib/mask/$.test.ts +3 -3
- package/src/lib/path-map/$.test.ts +22 -19
- package/src/lib/path-map/path-map.ts +3 -1
- package/src/lib/react-router-aid/react-router-aid.ts +12 -6
- package/src/project-data.ts +3 -11
- package/src/template/components/Changelog.tsx +16 -67
- package/src/template/components/CodeBlock.tsx +3 -5
- package/src/template/components/ComponentDispatch.tsx +42 -0
- package/src/template/components/ReferenceLink.tsx +34 -0
- package/src/template/components/TypeAnnotation.tsx +5 -7
- package/src/template/components/TypeFieldsLinkList.tsx +20 -23
- package/src/template/components/TypeIndex.tsx +10 -12
- package/src/template/components/VersionSelector.tsx +50 -0
- package/src/template/components/graphql/type-link.tsx +4 -3
- package/src/template/hooks/useVersionPath.ts +10 -0
- package/src/template/{components → layouts}/ChangelogLayout.tsx +1 -1
- package/src/template/layouts/index.ts +1 -0
- package/src/template/lib/fetch-text.ts +13 -0
- package/src/template/lib/polen-url.ts +20 -0
- package/src/template/lib/schema-utils/constants.ts +4 -0
- package/src/template/lib/schema-utils/schema-utils.ts +42 -0
- package/src/template/routes/changelog.tsx +19 -10
- package/src/template/routes/index.tsx +2 -2
- package/src/template/routes/pages.tsx +109 -0
- package/src/template/routes/reference.tsx +112 -12
- package/src/template/routes/root.tsx +11 -112
- package/src/template/server/app.ts +47 -14
- package/src/template/server/main.ts +9 -1
- package/src/template/server/ssg/generate.ts +2 -2
- package/src/template/server/ssg/get-route-paths.test.ts +132 -0
- package/src/template/server/ssg/get-route-paths.ts +91 -27
- package/src/template/sources/schema-source.ts +69 -0
- package/build/lib/graphql-document/$$.d.ts +0 -5
- package/build/lib/graphql-document/$$.d.ts.map +0 -1
- package/build/lib/graphql-document/$$.js +0 -5
- package/build/lib/graphql-document/$$.js.map +0 -1
- package/build/lib/graphql-document/$.d.ts +0 -2
- package/build/lib/graphql-document/$.d.ts.map +0 -1
- package/build/lib/graphql-document/$.js +0 -2
- package/build/lib/graphql-document/$.js.map +0 -1
- package/build/lib/graphql-document/analysis.d.ts +0 -44
- package/build/lib/graphql-document/analysis.d.ts.map +0 -1
- package/build/lib/graphql-document/analysis.js +0 -361
- package/build/lib/graphql-document/analysis.js.map +0 -1
- package/build/lib/graphql-document/components/GraphQLDocument.d.ts +0 -38
- package/build/lib/graphql-document/components/GraphQLDocument.d.ts.map +0 -1
- package/build/lib/graphql-document/components/GraphQLDocument.js +0 -151
- package/build/lib/graphql-document/components/GraphQLDocument.js.map +0 -1
- package/build/lib/graphql-document/components/GraphQLDocumentWithSchema.d.ts +0 -7
- package/build/lib/graphql-document/components/GraphQLDocumentWithSchema.d.ts.map +0 -1
- package/build/lib/graphql-document/components/GraphQLDocumentWithSchema.js +0 -27
- package/build/lib/graphql-document/components/GraphQLDocumentWithSchema.js.map +0 -1
- package/build/lib/graphql-document/components/GraphQLIdentifierPopover.d.ts +0 -33
- package/build/lib/graphql-document/components/GraphQLIdentifierPopover.d.ts.map +0 -1
- package/build/lib/graphql-document/components/GraphQLIdentifierPopover.js +0 -50
- package/build/lib/graphql-document/components/GraphQLIdentifierPopover.js.map +0 -1
- package/build/lib/graphql-document/components/IdentifierLink.d.ts +0 -39
- package/build/lib/graphql-document/components/IdentifierLink.d.ts.map +0 -1
- package/build/lib/graphql-document/components/IdentifierLink.js +0 -75
- package/build/lib/graphql-document/components/IdentifierLink.js.map +0 -1
- package/build/lib/graphql-document/components/graphql-document-styles.d.ts +0 -5
- package/build/lib/graphql-document/components/graphql-document-styles.d.ts.map +0 -1
- package/build/lib/graphql-document/components/graphql-document-styles.js +0 -144
- package/build/lib/graphql-document/components/graphql-document-styles.js.map +0 -1
- package/build/lib/graphql-document/components/index.d.ts +0 -5
- package/build/lib/graphql-document/components/index.d.ts.map +0 -1
- package/build/lib/graphql-document/components/index.js +0 -5
- package/build/lib/graphql-document/components/index.js.map +0 -1
- package/build/lib/graphql-document/example.d.ts +0 -25
- package/build/lib/graphql-document/example.d.ts.map +0 -1
- package/build/lib/graphql-document/example.js +0 -140
- package/build/lib/graphql-document/example.js.map +0 -1
- package/build/lib/graphql-document/graphql-document.d.ts +0 -35
- package/build/lib/graphql-document/graphql-document.d.ts.map +0 -1
- package/build/lib/graphql-document/graphql-document.js +0 -36
- package/build/lib/graphql-document/graphql-document.js.map +0 -1
- package/build/lib/graphql-document/hooks/use-tooltip-state.d.ts +0 -43
- package/build/lib/graphql-document/hooks/use-tooltip-state.d.ts.map +0 -1
- package/build/lib/graphql-document/hooks/use-tooltip-state.js +0 -132
- package/build/lib/graphql-document/hooks/use-tooltip-state.js.map +0 -1
- package/build/lib/graphql-document/positioning-simple.d.ts +0 -63
- package/build/lib/graphql-document/positioning-simple.d.ts.map +0 -1
- package/build/lib/graphql-document/positioning-simple.js +0 -185
- package/build/lib/graphql-document/positioning-simple.js.map +0 -1
- package/build/lib/graphql-document/schema-context.d.ts +0 -8
- package/build/lib/graphql-document/schema-context.d.ts.map +0 -1
- package/build/lib/graphql-document/schema-context.js +0 -11
- package/build/lib/graphql-document/schema-context.js.map +0 -1
- package/build/lib/graphql-document/schema-integration.d.ts +0 -135
- package/build/lib/graphql-document/schema-integration.d.ts.map +0 -1
- package/build/lib/graphql-document/schema-integration.js +0 -328
- package/build/lib/graphql-document/schema-integration.js.map +0 -1
- package/build/lib/graphql-document/types.d.ts +0 -117
- package/build/lib/graphql-document/types.d.ts.map +0 -1
- package/build/lib/graphql-document/types.js +0 -2
- package/build/lib/graphql-document/types.js.map +0 -1
- package/build/template/components/ChangelogLayout.d.ts.map +0 -1
- package/build/template/components/ChangelogLayout.js.map +0 -1
- package/build/template/components/CodeHikePre.d.ts +0 -16
- package/build/template/components/CodeHikePre.d.ts.map +0 -1
- package/build/template/components/CodeHikePre.js +0 -37
- package/build/template/components/CodeHikePre.js.map +0 -1
- package/build/template/routes/reference.$type.$field.d.ts +0 -5
- package/build/template/routes/reference.$type.$field.d.ts.map +0 -1
- package/build/template/routes/reference.$type.$field.js +0 -31
- package/build/template/routes/reference.$type.$field.js.map +0 -1
- package/build/template/routes/reference.$type.d.ts +0 -5
- package/build/template/routes/reference.$type.d.ts.map +0 -1
- package/build/template/routes/reference.$type.js +0 -23
- package/build/template/routes/reference.$type.js.map +0 -1
- package/src/lib/graphql-document/$$.ts +0 -4
- package/src/lib/graphql-document/$.test.ts +0 -132
- package/src/lib/graphql-document/$.ts +0 -1
- package/src/lib/graphql-document/README.md +0 -102
- package/src/lib/graphql-document/analysis.ts +0 -415
- package/src/lib/graphql-document/components/GraphQLDocument.tsx +0 -265
- package/src/lib/graphql-document/components/GraphQLDocument.unit.test.ts +0 -188
- package/src/lib/graphql-document/components/GraphQLDocumentWithSchema.tsx +0 -46
- package/src/lib/graphql-document/components/GraphQLIdentifierPopover.tsx +0 -199
- package/src/lib/graphql-document/components/IdentifierLink.tsx +0 -160
- package/src/lib/graphql-document/components/graphql-document-styles.ts +0 -144
- package/src/lib/graphql-document/components/index.ts +0 -4
- package/src/lib/graphql-document/demo.md +0 -155
- package/src/lib/graphql-document/example.ts +0 -163
- package/src/lib/graphql-document/graphql-document.ts +0 -37
- package/src/lib/graphql-document/hooks/use-tooltip-state.test.ts +0 -76
- package/src/lib/graphql-document/hooks/use-tooltip-state.ts +0 -191
- package/src/lib/graphql-document/positioning-simple.test.ts +0 -248
- package/src/lib/graphql-document/positioning-simple.ts +0 -260
- package/src/lib/graphql-document/schema-context.tsx +0 -20
- package/src/lib/graphql-document/schema-integration.test.ts +0 -365
- package/src/lib/graphql-document/schema-integration.ts +0 -488
- package/src/lib/graphql-document/types.ts +0 -129
- package/src/template/components/CodeHikePre.tsx +0 -51
- package/src/template/routes/reference.$type.$field.tsx +0 -34
- package/src/template/routes/reference.$type.tsx +0 -27
- /package/build/template/{components → layouts}/ChangelogLayout.d.ts +0 -0
package/src/api/schema/read.ts
CHANGED
@@ -1,38 +1,104 @@
|
|
1
|
-
import { Arr } from '@wollybeard/kit'
|
1
|
+
import { Arr, Fs, Path } from '@wollybeard/kit'
|
2
2
|
import * as DataSources from './data-sources/data-sources.js'
|
3
|
-
import type {
|
3
|
+
import type { NonEmptyChangeSets } from './schema.js'
|
4
4
|
|
5
|
-
export type DataSourceType =
|
5
|
+
export type DataSourceType =
|
6
|
+
| `file`
|
7
|
+
| `directory`
|
8
|
+
| `memory`
|
9
|
+
| `data`
|
10
|
+
| `introspection`
|
11
|
+
| `introspectionFile`
|
12
|
+
| `introspectionAuto`
|
13
|
+
|
14
|
+
/**
|
15
|
+
* Result of schema reading with provenance tracking for file watching and debugging.
|
16
|
+
*/
|
17
|
+
export interface SchemaReadResult {
|
18
|
+
data: NonEmptyChangeSets | null
|
19
|
+
source: {
|
20
|
+
type: DataSourceType
|
21
|
+
/**
|
22
|
+
* Recreate the schema data and file after it has been deleted.
|
23
|
+
*
|
24
|
+
* This function re-fetches data from the original source and recreates
|
25
|
+
* the schema file on disk. Only called by file watchers after deletion.
|
26
|
+
*
|
27
|
+
* @returns Promise resolving to the recreated schema data, or null if recreation fails
|
28
|
+
*/
|
29
|
+
reCreate?: () => Promise<NonEmptyChangeSets | null>
|
30
|
+
}
|
31
|
+
}
|
6
32
|
|
7
33
|
/**
|
8
34
|
* Schema configuration for Polen.
|
35
|
+
*
|
36
|
+
* Polen supports multiple ways to load your GraphQL schema, from simple files
|
37
|
+
* to dynamic introspection. Configure which sources to use and in what order.
|
38
|
+
*
|
39
|
+
* @example
|
40
|
+
* ```ts
|
41
|
+
* // Load from a file (default)
|
42
|
+
* schema: {} // Looks for schema.graphql
|
43
|
+
*
|
44
|
+
* // Load via introspection
|
45
|
+
* schema: {
|
46
|
+
* dataSources: {
|
47
|
+
* introspection: {
|
48
|
+
* url: 'https://api.example.com/graphql',
|
49
|
+
* headers: { 'Authorization': 'Bearer token' }
|
50
|
+
* }
|
51
|
+
* }
|
52
|
+
* }
|
53
|
+
*
|
54
|
+
* // Try multiple sources in order
|
55
|
+
* schema: {
|
56
|
+
* useDataSources: ['introspection', 'file'],
|
57
|
+
* dataSources: {
|
58
|
+
* introspection: { url: 'https://api.example.com/graphql' },
|
59
|
+
* file: { path: './fallback-schema.graphql' }
|
60
|
+
* }
|
61
|
+
* }
|
62
|
+
* ```
|
9
63
|
*/
|
10
64
|
export interface Config {
|
11
65
|
/**
|
12
66
|
* Whether to enable schema loading.
|
13
67
|
*
|
14
|
-
* Set to `false` to disable schema features entirely.
|
68
|
+
* Set to `false` to disable schema features entirely. This removes
|
69
|
+
* the Reference and Changelog pages from your portal.
|
15
70
|
*
|
16
|
-
* @default
|
71
|
+
* @default true
|
72
|
+
*
|
73
|
+
* @example
|
74
|
+
* ```ts
|
75
|
+
* // Disable schema features
|
76
|
+
* schema: { enabled: false }
|
77
|
+
* ```
|
17
78
|
*/
|
18
79
|
enabled?: boolean
|
19
80
|
/**
|
20
81
|
* Which data sources to use for loading schemas.
|
21
82
|
*
|
22
|
-
* - `file` - Load from a single SDL file
|
23
|
-
* - `directory` - Load multiple SDL files from a directory
|
83
|
+
* - `file` - Load from a single SDL file (default: `./schema.graphql`)
|
84
|
+
* - `directory` - Load multiple SDL files from a directory (default: `./schema/`)
|
24
85
|
* - `memory` - Use schemas defined in configuration
|
25
86
|
* - `data` - Use a pre-built schema object
|
87
|
+
* - `introspection` - Load schema via GraphQL introspection
|
26
88
|
*
|
27
|
-
* If not specified, Polen
|
89
|
+
* If not specified, Polen tries all sources in this order:
|
90
|
+
* 1. `data` 2. `directory` 3. `file` 4. `memory` 5. `introspection`
|
28
91
|
*
|
29
92
|
* @example
|
30
93
|
* ```ts
|
31
94
|
* // Use only file source
|
32
95
|
* useDataSources: 'file'
|
33
96
|
*
|
34
|
-
* // Try multiple sources
|
35
|
-
* useDataSources: ['
|
97
|
+
* // Try multiple sources in custom order
|
98
|
+
* useDataSources: ['introspection', 'file']
|
99
|
+
*
|
100
|
+
* // Default behavior (try all sources)
|
101
|
+
* // useDataSources: undefined
|
36
102
|
* ```
|
37
103
|
*/
|
38
104
|
useDataSources?: Arr.Maybe<DataSourceType>
|
@@ -55,23 +121,39 @@ export interface Config {
|
|
55
121
|
/**
|
56
122
|
* Pre-built schema object to use directly.
|
57
123
|
*/
|
58
|
-
data?:
|
124
|
+
data?: NonEmptyChangeSets
|
125
|
+
/**
|
126
|
+
* Configuration for loading schema via GraphQL introspection.
|
127
|
+
*
|
128
|
+
* Introspection fetches your schema directly from a running GraphQL endpoint.
|
129
|
+
* The schema is saved to `schema.introspection.json` in your project root.
|
130
|
+
* Delete this file to force a fresh introspection on the next build.
|
131
|
+
*
|
132
|
+
* @example
|
133
|
+
* ```ts
|
134
|
+
* introspection: {
|
135
|
+
* url: 'https://api.example.com/graphql',
|
136
|
+
* headers: { 'Authorization': 'Bearer token' }
|
137
|
+
* }
|
138
|
+
* ```
|
139
|
+
*/
|
140
|
+
introspection?: DataSources.Introspection.ConfigInput
|
59
141
|
}
|
60
142
|
projectRoot: string
|
61
143
|
}
|
62
144
|
|
63
145
|
export const readOrThrow = async (
|
64
146
|
config: Config,
|
65
|
-
): Promise<
|
147
|
+
): Promise<SchemaReadResult> => {
|
66
148
|
if (config.enabled === false) {
|
67
|
-
return null
|
149
|
+
return { data: null, source: { type: 'data' } }
|
68
150
|
}
|
69
151
|
|
70
152
|
const useDataSources = config.useDataSources ? Arr.sure(config.useDataSources) : null
|
71
153
|
const usingDataSource = (dataSource: DataSourceType) => useDataSources === null || useDataSources.includes(dataSource)
|
72
154
|
|
73
155
|
if (usingDataSource(`data`) && config.dataSources?.data) {
|
74
|
-
return config.dataSources.data
|
156
|
+
return { data: config.dataSources.data, source: { type: 'data' } }
|
75
157
|
}
|
76
158
|
|
77
159
|
if (usingDataSource(`directory`)) {
|
@@ -80,7 +162,7 @@ export const readOrThrow = async (
|
|
80
162
|
...config.dataSources?.directory,
|
81
163
|
}
|
82
164
|
const result = await DataSources.SchemaDirectory.readOrThrow(directoryConfig)
|
83
|
-
if (result) return result
|
165
|
+
if (result) return { data: result, source: { type: 'directory' } }
|
84
166
|
}
|
85
167
|
|
86
168
|
if (usingDataSource(`file`)) {
|
@@ -89,7 +171,7 @@ export const readOrThrow = async (
|
|
89
171
|
...config.dataSources?.file,
|
90
172
|
}
|
91
173
|
const result = await DataSources.SchemaFile.readOrThrow(fileConfig)
|
92
|
-
if (result) return result
|
174
|
+
if (result) return { data: result, source: { type: 'file' } }
|
93
175
|
}
|
94
176
|
|
95
177
|
if (usingDataSource(`memory`) && config.dataSources?.memory) {
|
@@ -98,8 +180,17 @@ export const readOrThrow = async (
|
|
98
180
|
...config.dataSources.memory,
|
99
181
|
}
|
100
182
|
const result = await DataSources.Memory.read(memoryConfig)
|
101
|
-
if (result) return result
|
183
|
+
if (result) return { data: result, source: { type: 'memory' } }
|
184
|
+
}
|
185
|
+
|
186
|
+
if (usingDataSource(`introspection`) && config.dataSources?.introspection) {
|
187
|
+
const introspectionConfig = {
|
188
|
+
projectRoot: config.projectRoot,
|
189
|
+
...config.dataSources.introspection,
|
190
|
+
}
|
191
|
+
const result = await DataSources.Introspection.readOrThrow(introspectionConfig)
|
192
|
+
if (result.data) return result
|
102
193
|
}
|
103
194
|
|
104
|
-
return null
|
195
|
+
return { data: null, source: { type: 'data' } }
|
105
196
|
}
|
package/src/api/schema/schema.ts
CHANGED
@@ -4,6 +4,66 @@ export * as DataSources from './data-sources/data-sources.js'
|
|
4
4
|
|
5
5
|
export * from './read.js'
|
6
6
|
|
7
|
-
export
|
8
|
-
|
7
|
+
export * from './metadata.js'
|
8
|
+
|
9
|
+
export type ChangeSets = GraphqlChangeset.ChangeSet[]
|
10
|
+
|
11
|
+
export type NonEmptyChangeSets = [GraphqlChangeset.ChangeSet, ...GraphqlChangeset.ChangeSet[]]
|
12
|
+
|
13
|
+
/**
|
14
|
+
* Changelog data structure for JSON serialization
|
15
|
+
*/
|
16
|
+
export interface ChangelogData {
|
17
|
+
changes: GraphqlChangeset.ChangeSet['changes']
|
18
|
+
date: string
|
19
|
+
}
|
20
|
+
|
21
|
+
/**
|
22
|
+
* Constants for schema versioning
|
23
|
+
*/
|
24
|
+
|
25
|
+
/**
|
26
|
+
* The version identifier for the latest schema
|
27
|
+
*/
|
28
|
+
export const VERSION_LATEST = `latest`
|
29
|
+
|
30
|
+
/**
|
31
|
+
* Fallback version name when date parsing fails
|
32
|
+
*/
|
33
|
+
export const VERSION_UNKNOWN_FALLBACK = `unknown`
|
34
|
+
|
35
|
+
/**
|
36
|
+
* Convert a date to a version string in YYYY-MM-DD format
|
37
|
+
*/
|
38
|
+
export const dateToVersionString = (date: Date): string => {
|
39
|
+
return date.toLocaleDateString('en-CA')
|
40
|
+
}
|
41
|
+
|
42
|
+
/**
|
43
|
+
* Determine if a version at the given index should have a changelog file.
|
44
|
+
* Only non-oldest versions get changelog files.
|
45
|
+
*/
|
46
|
+
export const shouldVersionHaveChangelog = (versionIndex: number, totalVersions: number): boolean => {
|
47
|
+
return versionIndex < totalVersions - 1
|
48
|
+
}
|
49
|
+
|
50
|
+
/**
|
51
|
+
* Convert a version string back to a Date
|
52
|
+
*/
|
53
|
+
export const versionStringToDate = (version: string): Date => {
|
54
|
+
if (version === VERSION_LATEST) {
|
55
|
+
return new Date()
|
56
|
+
}
|
57
|
+
|
58
|
+
// Use modern date parsing - the version string should be in YYYY-MM-DD format
|
59
|
+
// which is ISO 8601 compatible
|
60
|
+
const parsedDate = new Date(version + 'T00:00:00Z')
|
61
|
+
|
62
|
+
// Check if the date is valid
|
63
|
+
if (!isNaN(parsedDate.getTime())) {
|
64
|
+
return parsedDate
|
65
|
+
}
|
66
|
+
|
67
|
+
// Throw error for invalid dates instead of silently defaulting
|
68
|
+
throw new Error(`Invalid version string: ${version}`)
|
9
69
|
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './schema-source.js'
|
@@ -0,0 +1,189 @@
|
|
1
|
+
import { Schema } from '#api/schema/index'
|
2
|
+
import { Grafaid } from '#lib/grafaid/index'
|
3
|
+
import type { GraphqlChangeset } from '#lib/graphql-changeset/index'
|
4
|
+
import { astToSchema } from '#template/lib/schema-utils/schema-utils'
|
5
|
+
import { Cache } from '@wollybeard/kit'
|
6
|
+
import type { GraphQLSchema } from 'graphql'
|
7
|
+
|
8
|
+
type WriteFile = (path: string, content: string) => Promise<void>
|
9
|
+
|
10
|
+
type ReadFile = (locator: string) => Promise<string>
|
11
|
+
|
12
|
+
type ClearDirectory = (path: string) => Promise<void>
|
13
|
+
|
14
|
+
type RemoveFile = (path: string) => Promise<void>
|
15
|
+
|
16
|
+
const NoImplementationWriteFile: WriteFile = async (path: string, content: string) => {
|
17
|
+
throw new Error('Write operations not supported in this environment')
|
18
|
+
}
|
19
|
+
|
20
|
+
const NoImplementationClearDirectory: ClearDirectory = async (path: string) => {
|
21
|
+
throw new Error('Directory operations not supported in this environment')
|
22
|
+
}
|
23
|
+
|
24
|
+
const NoImplementationRemoveFile: RemoveFile = async (path: string) => {
|
25
|
+
throw new Error('File removal operations not supported in this environment')
|
26
|
+
}
|
27
|
+
|
28
|
+
interface SchemaSourceConfig {
|
29
|
+
io: {
|
30
|
+
read: ReadFile
|
31
|
+
write?: WriteFile
|
32
|
+
clearDirectory?: ClearDirectory
|
33
|
+
removeFile?: RemoveFile
|
34
|
+
}
|
35
|
+
versions: string[]
|
36
|
+
assetsPath: string
|
37
|
+
}
|
38
|
+
|
39
|
+
export const createSchemaSource = (config: SchemaSourceConfig) => {
|
40
|
+
const getSchemaPath = (version: string) => `${config.assetsPath}/schemas/${version}.json`
|
41
|
+
|
42
|
+
const getChangelogPath = (version: string) => `${config.assetsPath}/schemas/${version}.changelog.json`
|
43
|
+
|
44
|
+
const getSchemasDirectory = () => `${config.assetsPath}/schemas`
|
45
|
+
|
46
|
+
const getMetadataPath = () => `${config.assetsPath}/schemas/metadata.json`
|
47
|
+
|
48
|
+
const ioWrite = config.io.write || NoImplementationWriteFile
|
49
|
+
const ioClearDirectory = config.io.clearDirectory || NoImplementationClearDirectory
|
50
|
+
const ioRemoveFile = config.io.removeFile || NoImplementationRemoveFile
|
51
|
+
|
52
|
+
// Memoize only the base IO read operation
|
53
|
+
const ioReadMemoized = Cache.memoize(config.io.read)
|
54
|
+
|
55
|
+
const get = async (version: string): Promise<GraphQLSchema> => {
|
56
|
+
const content = await ioReadMemoized(getSchemaPath(version))
|
57
|
+
const schemaAst = JSON.parse(content)
|
58
|
+
const schema = astToSchema(schemaAst)
|
59
|
+
return schema
|
60
|
+
}
|
61
|
+
|
62
|
+
const getChangelog = async (version: string): Promise<Schema.ChangelogData> => {
|
63
|
+
const content = await ioReadMemoized(getChangelogPath(version))
|
64
|
+
return JSON.parse(content)
|
65
|
+
}
|
66
|
+
|
67
|
+
const getAllChangesets = async (): Promise<GraphqlChangeset.ChangeSet[]> => {
|
68
|
+
const changesets: GraphqlChangeset.ChangeSet[] = []
|
69
|
+
|
70
|
+
for (let i = 0; i < config.versions.length; i++) {
|
71
|
+
const version = config.versions[i]
|
72
|
+
if (!version) continue
|
73
|
+
|
74
|
+
const schema = await get(version)
|
75
|
+
if (!schema) continue
|
76
|
+
|
77
|
+
// Only try to read changelog for non-oldest versions (matching writeDevAssets logic)
|
78
|
+
let changelogData = null
|
79
|
+
if (i < config.versions.length - 1) {
|
80
|
+
changelogData = await getChangelog(version)
|
81
|
+
}
|
82
|
+
|
83
|
+
if (changelogData) {
|
84
|
+
const prevVersion = config.versions[i + 1]
|
85
|
+
const prevSchema = prevVersion ? await get(prevVersion) : null
|
86
|
+
|
87
|
+
if (prevSchema) {
|
88
|
+
changesets.push({
|
89
|
+
after: schema,
|
90
|
+
before: prevSchema,
|
91
|
+
changes: changelogData.changes,
|
92
|
+
date: new Date(changelogData.date),
|
93
|
+
})
|
94
|
+
}
|
95
|
+
} else {
|
96
|
+
// Oldest version - no changelog, use existing utility
|
97
|
+
changesets.push({
|
98
|
+
after: schema,
|
99
|
+
before: Grafaid.Schema.empty,
|
100
|
+
changes: [],
|
101
|
+
date: Schema.versionStringToDate(version),
|
102
|
+
})
|
103
|
+
}
|
104
|
+
}
|
105
|
+
|
106
|
+
return changesets
|
107
|
+
}
|
108
|
+
|
109
|
+
return {
|
110
|
+
//
|
111
|
+
// Properties
|
112
|
+
//
|
113
|
+
versions: config.versions,
|
114
|
+
isEmpty: config.versions.length === 0,
|
115
|
+
|
116
|
+
//
|
117
|
+
// Methods
|
118
|
+
//
|
119
|
+
get,
|
120
|
+
getChangelog,
|
121
|
+
getAllChangesets,
|
122
|
+
|
123
|
+
// Expose the memoized reader's clear method
|
124
|
+
clearCache: ioReadMemoized.clear,
|
125
|
+
|
126
|
+
// Write operations (use the writer, which throws if not provided)
|
127
|
+
writeSchema: async (version: string, schema: GraphQLSchema) => {
|
128
|
+
const ast = Grafaid.Schema.AST.parse(Grafaid.Schema.print(schema))
|
129
|
+
await ioWrite(getSchemaPath(version), JSON.stringify(ast))
|
130
|
+
},
|
131
|
+
|
132
|
+
writeChangelog: async (version: string, changelog: Schema.ChangelogData) => {
|
133
|
+
await ioWrite(getChangelogPath(version), JSON.stringify(changelog))
|
134
|
+
},
|
135
|
+
|
136
|
+
// Directory operations
|
137
|
+
clearAllAssets: async () => {
|
138
|
+
await ioClearDirectory(getSchemasDirectory())
|
139
|
+
},
|
140
|
+
|
141
|
+
removeAsset: async (version: string) => {
|
142
|
+
try {
|
143
|
+
await ioRemoveFile(getSchemaPath(version))
|
144
|
+
} catch (error) {
|
145
|
+
// Swallow errors for file removal as requested
|
146
|
+
}
|
147
|
+
|
148
|
+
try {
|
149
|
+
await ioRemoveFile(getChangelogPath(version))
|
150
|
+
} catch (error) {
|
151
|
+
// Swallow errors for file removal as requested
|
152
|
+
}
|
153
|
+
},
|
154
|
+
|
155
|
+
writeMetadata: async (metadata: Schema.SchemaMetadata) => {
|
156
|
+
await ioWrite(getMetadataPath(), JSON.stringify(metadata, null, 2))
|
157
|
+
},
|
158
|
+
|
159
|
+
writeAllAssets: async (
|
160
|
+
schemaData: Awaited<ReturnType<typeof Schema.readOrThrow>>['data'],
|
161
|
+
metadata: Schema.SchemaMetadata,
|
162
|
+
) => {
|
163
|
+
if (!schemaData) return
|
164
|
+
|
165
|
+
// Write schema and changelog files
|
166
|
+
for (const [index, version] of schemaData!.entries()) {
|
167
|
+
const versionName = index === 0 ? Schema.VERSION_LATEST : Schema.dateToVersionString(version.date)
|
168
|
+
|
169
|
+
// Write schema file
|
170
|
+
await ioWrite(
|
171
|
+
getSchemaPath(versionName),
|
172
|
+
JSON.stringify(Grafaid.Schema.AST.parse(Grafaid.Schema.print(version.after))),
|
173
|
+
)
|
174
|
+
|
175
|
+
// Write changelog file (except for the oldest/last version)
|
176
|
+
if (Schema.shouldVersionHaveChangelog(index, schemaData!.length)) {
|
177
|
+
const changelogData = {
|
178
|
+
changes: version.changes,
|
179
|
+
date: version.date.toISOString(),
|
180
|
+
}
|
181
|
+
await ioWrite(getChangelogPath(versionName), JSON.stringify(changelogData))
|
182
|
+
}
|
183
|
+
}
|
184
|
+
|
185
|
+
// Write metadata file
|
186
|
+
await ioWrite(getMetadataPath(), JSON.stringify(metadata, null, 2))
|
187
|
+
},
|
188
|
+
}
|
189
|
+
}
|
@@ -75,6 +75,9 @@ export const Build = (config: Config.Config): Vite.Plugin[] => {
|
|
75
75
|
// @see https://github.com/vitejs/vite/issues/20098
|
76
76
|
ssr: {
|
77
77
|
noExternal: true,
|
78
|
+
// Exclude lightningcss from bundling due to native bindings
|
79
|
+
// @see https://github.com/parcel-bundler/lightningcss/issues/701
|
80
|
+
external: ['lightningcss'],
|
78
81
|
},
|
79
82
|
environments: {
|
80
83
|
ssr: {
|
@@ -2,23 +2,29 @@ import type { Config } from '#api/config/index'
|
|
2
2
|
import { Content } from '#api/content/$'
|
3
3
|
import { createNavbar } from '#api/content/navbar'
|
4
4
|
import { VitePluginSelfContainedMode } from '#cli/_/self-contained-mode'
|
5
|
+
import { Hono } from '#dep/hono/index'
|
5
6
|
import type { ReactRouter } from '#dep/react-router/index'
|
6
7
|
import type { Vite } from '#dep/vite/index'
|
7
8
|
import { VitePluginJson } from '#lib/vite-plugin-json/index'
|
8
9
|
import { ViteVirtual } from '#lib/vite-virtual/index'
|
9
10
|
import { debugPolen } from '#singletons/debug'
|
10
11
|
import { superjson } from '#singletons/superjson'
|
12
|
+
import * as HonoNodeServer from '@hono/node-server'
|
13
|
+
import { serveStatic } from '@hono/node-server/serve-static'
|
11
14
|
import { Json, Str } from '@wollybeard/kit'
|
15
|
+
import * as NodePath from 'node:path'
|
12
16
|
import type { ProjectData } from '../../../project-data.js'
|
13
17
|
import { SchemaAugmentation } from '../../schema-augmentation/index.js'
|
14
18
|
import { Schema } from '../../schema/index.js'
|
15
19
|
import { createLogger } from '../logger.js'
|
16
20
|
import { polenVirtual } from '../vi.js'
|
17
21
|
import { Pages } from './pages.js'
|
22
|
+
import { SchemaAssets } from './schema-assets.js'
|
18
23
|
|
19
24
|
const viTemplateVariables = polenVirtual([`template`, `variables`])
|
20
25
|
const viTemplateSchemaAugmentations = polenVirtual([`template`, `schema-augmentations`])
|
21
26
|
export const viProjectData = polenVirtual([`project`, `data.jsonsuper`], { allowPluginProcessing: true })
|
27
|
+
export const viProjectSchema = polenVirtual([`project`, `schema.jsonsuper`], { allowPluginProcessing: true })
|
22
28
|
|
23
29
|
export interface ProjectRoutesModule {
|
24
30
|
routes: ReactRouter.RouteObject[]
|
@@ -29,15 +35,15 @@ export const Core = (config: Config.Config): Vite.PluginOption[] => {
|
|
29
35
|
|
30
36
|
const readSchema = async () => {
|
31
37
|
if (schemaCache === null) {
|
32
|
-
const
|
38
|
+
const schemaResult = await Schema.readOrThrow({
|
33
39
|
...config.schema,
|
34
40
|
projectRoot: config.paths.project.rootDir,
|
35
41
|
})
|
36
42
|
// todo: augmentations scoped to a version
|
37
|
-
|
43
|
+
schemaResult.data?.forEach(version => {
|
38
44
|
SchemaAugmentation.apply(version.after, config.schemaAugmentations)
|
39
45
|
})
|
40
|
-
schemaCache =
|
46
|
+
schemaCache = schemaResult
|
41
47
|
}
|
42
48
|
return schemaCache
|
43
49
|
}
|
@@ -68,6 +74,7 @@ export const Core = (config: Config.Config): Vite.PluginOption[] => {
|
|
68
74
|
|
69
75
|
return [
|
70
76
|
...plugins,
|
77
|
+
SchemaAssets(config),
|
71
78
|
/**
|
72
79
|
* If a `polen*` import is encountered from the user's project, resolve it to the currently
|
73
80
|
* running source code of Polen rather than the user's node_modules.
|
@@ -133,11 +140,11 @@ export const Core = (config: Config.Config): Vite.PluginOption[] => {
|
|
133
140
|
__BUILD_ARCHITECTURE_SSG__: Json.encode(config.build.architecture === `ssg`),
|
134
141
|
'process.env.NODE_ENV': Json.encode(config.advanced.debug ? 'development' : 'production'),
|
135
142
|
},
|
136
|
-
customLogger: createLogger(config),
|
143
|
+
// customLogger: createLogger(config),
|
137
144
|
esbuild: false,
|
138
145
|
build: {
|
139
146
|
target: `esnext`,
|
140
|
-
assetsDir: config.paths.project.relative.build.relative.assets,
|
147
|
+
assetsDir: config.paths.project.relative.build.relative.assets.root,
|
141
148
|
rollupOptions: {
|
142
149
|
treeshake: {
|
143
150
|
// Aggressive tree-shaking for smallest bundles
|
@@ -153,6 +160,16 @@ export const Core = (config: Config.Config): Vite.PluginOption[] => {
|
|
153
160
|
}
|
154
161
|
},
|
155
162
|
...ViteVirtual.IdentifiedLoader.toHooks(
|
163
|
+
{
|
164
|
+
identifier: viProjectSchema,
|
165
|
+
async loader() {
|
166
|
+
const debug = debugPolen.sub(`module-project-schema`)
|
167
|
+
debug(`load`, { id: viProjectSchema.id })
|
168
|
+
|
169
|
+
const schemaResult = await readSchema()
|
170
|
+
return superjson.stringify(schemaResult.data)
|
171
|
+
},
|
172
|
+
},
|
156
173
|
{
|
157
174
|
identifier: viTemplateVariables,
|
158
175
|
loader() {
|
@@ -174,18 +191,18 @@ export const Core = (config: Config.Config): Vite.PluginOption[] => {
|
|
174
191
|
|
175
192
|
debug(`load`, { id: viProjectData.id })
|
176
193
|
|
177
|
-
const
|
194
|
+
const schemaResult = await readSchema()
|
178
195
|
|
179
196
|
const navbar = []
|
180
197
|
|
181
198
|
// ━ Schema presence causes adding some navbar items
|
182
|
-
if (
|
199
|
+
if (schemaResult.data) {
|
183
200
|
// IMPORTANT: Always ensure paths start with '/' for React Router compatibility.
|
184
201
|
// Without the leading slash, React Router treats paths as relative, which causes
|
185
202
|
// hydration mismatches between SSR (where base path is prepended) and client
|
186
203
|
// (where basename is configured). This ensures consistent behavior.
|
187
204
|
navbar.push({ pathExp: `/reference`, title: `Reference` })
|
188
|
-
if (
|
205
|
+
if (schemaResult.data.length > 1) {
|
189
206
|
navbar.push({ pathExp: `/changelog`, title: `Changelog` })
|
190
207
|
}
|
191
208
|
}
|
@@ -204,22 +221,10 @@ export const Core = (config: Config.Config): Vite.PluginOption[] => {
|
|
204
221
|
//
|
205
222
|
|
206
223
|
const projectData: ProjectData = {
|
207
|
-
schema,
|
208
224
|
basePath: config.build.base,
|
209
|
-
paths: config.paths
|
225
|
+
paths: config.paths,
|
210
226
|
navbar, // Complete navbar with schema and pages
|
211
|
-
server:
|
212
|
-
port: config.server.port,
|
213
|
-
static: {
|
214
|
-
// todo
|
215
|
-
// relative from CWD of process that boots n1ode server
|
216
|
-
// can easily break! Use path relative in server??
|
217
|
-
directory: `./` + config.paths.project.relative.build.root,
|
218
|
-
// Uses Hono route syntax - includes base path
|
219
|
-
route: config.build.base.slice(0, -1) + `/` + config.paths.project.relative.build.relative.assets
|
220
|
-
+ `/*`,
|
221
|
-
},
|
222
|
-
},
|
227
|
+
server: config.server,
|
223
228
|
warnings: config.warnings,
|
224
229
|
}
|
225
230
|
|
@@ -2,9 +2,8 @@ import type { Config } from '#api/config/index'
|
|
2
2
|
import type { Vite } from '#dep/vite/index'
|
3
3
|
import { vitePluginSsrCss } from '@hiogawa/vite-plugin-ssr-css'
|
4
4
|
import ViteReact from '@vitejs/plugin-react-oxc'
|
5
|
-
import {
|
5
|
+
import { Path } from '@wollybeard/kit'
|
6
6
|
import Inspect from 'vite-plugin-inspect'
|
7
|
-
import Restart from 'vite-plugin-restart'
|
8
7
|
import { Branding } from './branding.js'
|
9
8
|
import { Build } from './build.js'
|
10
9
|
import { Core } from './core.js'
|
@@ -26,13 +25,6 @@ export const Main = (
|
|
26
25
|
plugins.push(plugin)
|
27
26
|
}
|
28
27
|
|
29
|
-
if (Arr.isntEmpty(config.watch.also)) {
|
30
|
-
const plugin = Restart({
|
31
|
-
restart: config.watch.also,
|
32
|
-
})
|
33
|
-
plugins.push(plugin)
|
34
|
-
}
|
35
|
-
|
36
28
|
plugins.push(
|
37
29
|
ViteReact(),
|
38
30
|
vitePluginSsrCss({
|