polen 0.11.0-next.25 → 0.11.0-next.26
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/config/input.d.ts +183 -0
- package/build/api/config/input.d.ts.map +1 -1
- package/build/api/config/input.js +2 -0
- package/build/api/config/input.js.map +1 -1
- package/build/api/config/normalized.d.ts +297 -0
- package/build/api/config/normalized.d.ts.map +1 -1
- package/build/api/config/normalized.js +47 -0
- package/build/api/config/normalized.js.map +1 -1
- package/build/api/config-template/template.d.ts +81 -0
- package/build/api/config-template/template.d.ts.map +1 -1
- package/build/api/config-template/template.js +18 -1
- package/build/api/config-template/template.js.map +1 -1
- package/build/api/examples/scanner.d.ts.map +1 -1
- package/build/api/examples/scanner.js +11 -0
- package/build/api/examples/scanner.js.map +1 -1
- package/build/api/examples/schemas/catalog.d.ts +36 -0
- package/build/api/examples/schemas/catalog.d.ts.map +1 -1
- package/build/api/examples/schemas/example/example.d.ts +37 -0
- package/build/api/examples/schemas/example/example.d.ts.map +1 -1
- package/build/api/examples/schemas/example/example.js +5 -0
- package/build/api/examples/schemas/example/example.js.map +1 -1
- package/build/api/reference/$.d.ts +4 -0
- package/build/api/reference/$.d.ts.map +1 -0
- package/build/api/reference/$.js +4 -0
- package/build/api/reference/$.js.map +1 -0
- package/build/api/reference/catalog.d.ts +69 -0
- package/build/api/reference/catalog.d.ts.map +1 -0
- package/build/api/reference/catalog.js +44 -0
- package/build/api/reference/catalog.js.map +1 -0
- package/build/api/reference/config.d.ts +616 -0
- package/build/api/reference/config.d.ts.map +1 -0
- package/build/api/reference/config.js +162 -0
- package/build/api/reference/config.js.map +1 -0
- package/build/api/reference/scanner.d.ts +26 -0
- package/build/api/reference/scanner.d.ts.map +1 -0
- package/build/api/reference/scanner.js +27 -0
- package/build/api/reference/scanner.js.map +1 -0
- package/build/lib/grafaid/schema/format-default-value.d.ts +11 -0
- package/build/lib/grafaid/schema/format-default-value.d.ts.map +1 -0
- package/build/lib/grafaid/schema/format-default-value.js +20 -0
- package/build/lib/grafaid/schema/format-default-value.js.map +1 -0
- package/build/lib/grafaid/schema/schema.d.ts +1 -0
- package/build/lib/grafaid/schema/schema.d.ts.map +1 -1
- package/build/lib/grafaid/schema/schema.js +1 -0
- package/build/lib/grafaid/schema/schema.js.map +1 -1
- package/build/template/components/ArgumentAnnotation.d.ts +2 -1
- package/build/template/components/ArgumentAnnotation.d.ts.map +1 -1
- package/build/template/components/ArgumentAnnotation.js +14 -4
- package/build/template/components/ArgumentAnnotation.js.map +1 -1
- package/build/template/components/ArgumentListAnnotation.d.ts +1 -0
- package/build/template/components/ArgumentListAnnotation.d.ts.map +1 -1
- package/build/template/components/ArgumentListAnnotation.js +21 -8
- package/build/template/components/ArgumentListAnnotation.js.map +1 -1
- package/build/template/components/Changelog/groups/FieldArgument.d.ts.map +1 -1
- package/build/template/components/Changelog/groups/FieldArgument.js +0 -1
- package/build/template/components/Changelog/groups/FieldArgument.js.map +1 -1
- package/build/template/components/CodeBlock.d.ts.map +1 -1
- package/build/template/components/CodeBlock.js +1 -1
- package/build/template/components/CodeBlock.js.map +1 -1
- package/build/template/components/Description.js +1 -1
- package/build/template/components/Description.js.map +1 -1
- package/build/template/components/ExampleLink.d.ts.map +1 -1
- package/build/template/components/ExampleLink.js +2 -1
- package/build/template/components/ExampleLink.js.map +1 -1
- package/build/template/components/Field.d.ts +2 -0
- package/build/template/components/Field.d.ts.map +1 -1
- package/build/template/components/Field.js +42 -4
- package/build/template/components/Field.js.map +1 -1
- package/build/template/components/FieldList.d.ts +2 -1
- package/build/template/components/FieldList.d.ts.map +1 -1
- package/build/template/components/FieldList.js +14 -3
- package/build/template/components/FieldList.js.map +1 -1
- package/build/template/components/FieldListSection.d.ts.map +1 -1
- package/build/template/components/FieldListSection.js +6 -1
- package/build/template/components/FieldListSection.js.map +1 -1
- package/build/template/components/GraphQLDocument.d.ts.map +1 -1
- package/build/template/components/GraphQLDocument.js +2 -1
- package/build/template/components/GraphQLDocument.js.map +1 -1
- package/build/template/components/GraphQLInteractive/GraphQLInteractive.d.ts +2 -0
- package/build/template/components/GraphQLInteractive/GraphQLInteractive.d.ts.map +1 -1
- package/build/template/components/GraphQLInteractive/GraphQLInteractive.js +4 -3
- package/build/template/components/GraphQLInteractive/GraphQLInteractive.js.map +1 -1
- package/build/template/components/GraphQLInteractive/lib/parser.d.ts +2 -2
- package/build/template/components/GraphQLInteractive/lib/parser.d.ts.map +1 -1
- package/build/template/components/GraphQLInteractive/lib/parser.js +17 -12
- package/build/template/components/GraphQLInteractive/lib/parser.js.map +1 -1
- package/build/template/components/IAPIndicator.d.ts +12 -0
- package/build/template/components/IAPIndicator.d.ts.map +1 -0
- package/build/template/components/IAPIndicator.js +21 -0
- package/build/template/components/IAPIndicator.js.map +1 -0
- package/build/template/components/Link.d.ts +1 -2
- package/build/template/components/Link.d.ts.map +1 -1
- package/build/template/components/Link.js +5 -2
- package/build/template/components/Link.js.map +1 -1
- package/build/template/components/NamedType.d.ts.map +1 -1
- package/build/template/components/NamedType.js +9 -5
- package/build/template/components/NamedType.js.map +1 -1
- package/build/template/components/ReferenceLink.d.ts +2 -2
- package/build/template/components/ReferenceLink.d.ts.map +1 -1
- package/build/template/components/ReferenceLink.js +5 -3
- package/build/template/components/ReferenceLink.js.map +1 -1
- package/build/template/components/TypeAnnotation.d.ts +2 -0
- package/build/template/components/TypeAnnotation.d.ts.map +1 -1
- package/build/template/components/TypeAnnotation.js +4 -4
- package/build/template/components/TypeAnnotation.js.map +1 -1
- package/build/template/components/ViewModeToggle.d.ts +3 -0
- package/build/template/components/ViewModeToggle.d.ts.map +1 -0
- package/build/template/components/ViewModeToggle.js +9 -0
- package/build/template/components/ViewModeToggle.js.map +1 -0
- package/build/template/components/graphql/type-link.d.ts +2 -0
- package/build/template/components/graphql/type-link.d.ts.map +1 -1
- package/build/template/components/graphql/type-link.js +15 -3
- package/build/template/components/graphql/type-link.js.map +1 -1
- package/build/template/components/home/PlaygroundPreview.d.ts.map +1 -1
- package/build/template/components/home/PlaygroundPreview.js +3 -2
- package/build/template/components/home/PlaygroundPreview.js.map +1 -1
- package/build/template/components/sidebar/SidebarItem.d.ts.map +1 -1
- package/build/template/components/sidebar/SidebarItem.js +18 -5
- package/build/template/components/sidebar/SidebarItem.js.map +1 -1
- package/build/template/contexts/ReferenceConfigContext.d.ts +16 -0
- package/build/template/contexts/ReferenceConfigContext.d.ts.map +1 -0
- package/build/template/contexts/ReferenceConfigContext.js +14 -0
- package/build/template/contexts/ReferenceConfigContext.js.map +1 -0
- package/build/template/contexts/ViewModeContext.d.ts +14 -0
- package/build/template/contexts/ViewModeContext.d.ts.map +1 -0
- package/build/template/contexts/ViewModeContext.js +40 -0
- package/build/template/contexts/ViewModeContext.js.map +1 -0
- package/build/template/hooks/use-examples.d.ts +3 -0
- package/build/template/hooks/use-examples.d.ts.map +1 -1
- package/build/template/hooks/useAlignedColumns.d.ts +10 -0
- package/build/template/hooks/useAlignedColumns.d.ts.map +1 -0
- package/build/template/hooks/useAlignedColumns.js +17 -0
- package/build/template/hooks/useAlignedColumns.js.map +1 -0
- package/build/template/routes/examples/_.d.ts +9 -0
- package/build/template/routes/examples/_.d.ts.map +1 -1
- package/build/template/routes/examples/_index.d.ts +6 -0
- package/build/template/routes/examples/_index.d.ts.map +1 -1
- package/build/template/routes/examples/name.d.ts +9 -0
- package/build/template/routes/examples/name.d.ts.map +1 -1
- package/build/template/routes/examples/name.js +6 -2
- package/build/template/routes/examples/name.js.map +1 -1
- package/build/template/routes/reference.d.ts.map +1 -1
- package/build/template/routes/reference.js +37 -10
- package/build/template/routes/reference.js.map +1 -1
- package/build/vite/plugins/core.d.ts.map +1 -1
- package/build/vite/plugins/core.js +6 -0
- package/build/vite/plugins/core.js.map +1 -1
- package/build/vite/plugins/examples.d.ts.map +1 -1
- package/build/vite/plugins/examples.js +10 -1
- package/build/vite/plugins/examples.js.map +1 -1
- package/build/vite/plugins/index.d.ts +1 -0
- package/build/vite/plugins/index.d.ts.map +1 -1
- package/build/vite/plugins/index.js +1 -0
- package/build/vite/plugins/index.js.map +1 -1
- package/build/vite/plugins/navbar.d.ts.map +1 -1
- package/build/vite/plugins/navbar.js +3 -1
- package/build/vite/plugins/navbar.js.map +1 -1
- package/build/vite/plugins/reference.d.ts +19 -0
- package/build/vite/plugins/reference.d.ts.map +1 -0
- package/build/vite/plugins/reference.js +96 -0
- package/build/vite/plugins/reference.js.map +1 -0
- package/package.json +1 -1
- package/src/api/config/input.ts +2 -0
- package/src/api/config/normalized.ts +54 -0
- package/src/api/config-template/template.ts +18 -1
- package/src/api/examples/scanner.ts +14 -0
- package/src/api/examples/schemas/example/example.ts +6 -0
- package/src/api/reference/$.ts +3 -0
- package/src/api/reference/catalog.ts +55 -0
- package/src/api/reference/config.ts +193 -0
- package/src/api/reference/scanner.ts +53 -0
- package/src/lib/grafaid/schema/format-default-value.ts +22 -0
- package/src/lib/grafaid/schema/schema.ts +2 -0
- package/src/template/components/ArgumentAnnotation.tsx +58 -9
- package/src/template/components/ArgumentListAnnotation.tsx +50 -17
- package/src/template/components/Changelog/groups/FieldArgument.tsx +0 -1
- package/src/template/components/CodeBlock.tsx +1 -0
- package/src/template/components/Description.tsx +1 -1
- package/src/template/components/ExampleLink.tsx +2 -1
- package/src/template/components/Field.tsx +148 -20
- package/src/template/components/FieldList.tsx +28 -13
- package/src/template/components/FieldListSection.tsx +12 -2
- package/src/template/components/GraphQLDocument.tsx +2 -0
- package/src/template/components/GraphQLInteractive/GraphQLInteractive.tsx +6 -1
- package/src/template/components/GraphQLInteractive/lib/parser.ts +16 -3
- package/src/template/components/IAPIndicator.tsx +73 -0
- package/src/template/components/Link.tsx +9 -3
- package/src/template/components/NamedType.tsx +54 -28
- package/src/template/components/ReferenceLink.tsx +16 -10
- package/src/template/components/TypeAnnotation.tsx +17 -5
- package/src/template/components/ViewModeToggle.tsx +27 -0
- package/src/template/components/graphql/type-link.tsx +34 -3
- package/src/template/components/home/PlaygroundPreview.tsx +3 -0
- package/src/template/components/sidebar/SidebarItem.tsx +21 -5
- package/src/template/contexts/ReferenceConfigContext.tsx +37 -0
- package/src/template/contexts/ViewModeContext.tsx +64 -0
- package/src/template/hooks/useAlignedColumns.ts +19 -0
- package/src/template/routes/examples/name.tsx +13 -1
- package/src/template/routes/reference.tsx +67 -23
- package/src/types/virtual-modules.d.ts +5 -0
- package/src/vite/plugins/core.ts +6 -0
- package/src/vite/plugins/examples.ts +12 -0
- package/src/vite/plugins/index.ts +1 -0
- package/src/vite/plugins/navbar.ts +4 -1
- package/src/vite/plugins/reference.ts +130 -0
- package/build/template/components/ArgumentList.d.ts +0 -6
- package/build/template/components/ArgumentList.d.ts.map +0 -1
- package/build/template/components/ArgumentList.js +0 -9
- package/build/template/components/ArgumentList.js.map +0 -1
- package/src/template/components/ArgumentList.tsx +0 -22
@@ -7,20 +7,28 @@ import { Lifecycles } from '#lib/lifecycles/$'
|
|
7
7
|
import { route, useLoaderData } from '#lib/react-router-effect/react-router-effect'
|
8
8
|
import { Schema } from '#lib/schema/$'
|
9
9
|
import { Version } from '#lib/version/$'
|
10
|
+
import { SegmentedControl, Text } from '@radix-ui/themes'
|
10
11
|
import { Flex } from '@radix-ui/themes'
|
12
|
+
import { Str } from '@wollybeard/kit'
|
11
13
|
import { neverCase } from '@wollybeard/kit/language'
|
12
14
|
import { HashMap, Option } from 'effect'
|
13
15
|
import { Effect, Match } from 'effect'
|
14
16
|
import React from 'react'
|
15
|
-
import { useParams } from 'react-router'
|
17
|
+
import { redirect, useParams } from 'react-router'
|
18
|
+
import { templateConfig } from 'virtual:polen/project/config'
|
19
|
+
import { IndexComponent } from 'virtual:polen/project/reference'
|
16
20
|
import { schemasCatalog } from 'virtual:polen/project/schemas'
|
17
21
|
import { Field } from '../components/Field.js'
|
18
22
|
import { TypeKindIcon } from '../components/graphql/graphql.js'
|
19
23
|
import { MissingSchema } from '../components/MissingSchema.js'
|
20
24
|
import { NamedType } from '../components/NamedType.js'
|
21
25
|
import { ReferenceVersionPicker } from '../components/ReferenceVersionPicker.js'
|
26
|
+
import { ViewModeToggle } from '../components/ViewModeToggle.js'
|
22
27
|
import { GraphqlLifecycleProvider } from '../contexts/GraphqlLifecycleContext.js'
|
28
|
+
import { ReferenceConfigProvider } from '../contexts/ReferenceConfigContext.js'
|
29
|
+
import { ViewModeProvider } from '../contexts/ViewModeContext.js'
|
23
30
|
import { SidebarLayout } from '../layouts/index.js'
|
31
|
+
import { MdxProvider } from '../providers/mdx.js'
|
24
32
|
|
25
33
|
const routeSchema = S.Struct({
|
26
34
|
catalog: Catalog.Catalog,
|
@@ -28,6 +36,17 @@ const routeSchema = S.Struct({
|
|
28
36
|
})
|
29
37
|
|
30
38
|
const referenceLoader = ({ params }: any) => {
|
39
|
+
// Check if reference is enabled
|
40
|
+
if (!templateConfig.reference.enabled) {
|
41
|
+
throw new Response('Reference documentation is disabled', { status: 404 })
|
42
|
+
}
|
43
|
+
|
44
|
+
// Check if no type is selected (index route) and no custom index exists
|
45
|
+
if (!params.type && !params.version && !IndexComponent) {
|
46
|
+
// Redirect to Query type which is guaranteed to exist
|
47
|
+
throw redirect('/reference/Query')
|
48
|
+
}
|
49
|
+
|
31
50
|
// This should never be called when schemasCatalog is null
|
32
51
|
// because the route won't be added to the router
|
33
52
|
// But we return an Effect.fail for safety
|
@@ -97,7 +116,7 @@ const ReferenceView = () => {
|
|
97
116
|
for (const [title, types] of kindEntries) {
|
98
117
|
sidebarItems.push({
|
99
118
|
type: `ItemSection` as const,
|
100
|
-
title,
|
119
|
+
title: Str.Case.title(Str.Case.snake(title)),
|
101
120
|
pathExp: `reference-${title.toLowerCase()}`,
|
102
121
|
isLinkToo: false,
|
103
122
|
links: types.map(type => {
|
@@ -130,7 +149,16 @@ const ReferenceView = () => {
|
|
130
149
|
|
131
150
|
const content: React.ReactNode = (() => {
|
132
151
|
if (viewType === 'index') {
|
133
|
-
|
152
|
+
// Render custom index component if available
|
153
|
+
if (IndexComponent) {
|
154
|
+
return (
|
155
|
+
<MdxProvider schema={schema.definition}>
|
156
|
+
<IndexComponent />
|
157
|
+
</MdxProvider>
|
158
|
+
)
|
159
|
+
}
|
160
|
+
// Fallback message (shouldn't reach here due to redirect)
|
161
|
+
return <Text>Select a type from the sidebar to view its documentation.</Text>
|
134
162
|
} else if (viewType === 'type-missing' || viewType === 'field-missing') {
|
135
163
|
return <MissingSchema />
|
136
164
|
} else if (viewType === 'type') {
|
@@ -151,26 +179,42 @@ const ReferenceView = () => {
|
|
151
179
|
}
|
152
180
|
})()
|
153
181
|
|
182
|
+
const referenceConfig = {
|
183
|
+
descriptionsView: templateConfig.reference.descriptionsView,
|
184
|
+
nullabilityRendering: templateConfig.reference.nullabilityRendering,
|
185
|
+
}
|
186
|
+
|
154
187
|
return (
|
155
|
-
<
|
156
|
-
<
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
188
|
+
<ReferenceConfigProvider config={referenceConfig}>
|
189
|
+
<ViewModeProvider defaultMode={referenceConfig.descriptionsView.defaultMode}>
|
190
|
+
<GraphqlLifecycleProvider lifecycle={lifecycle} schema={schema}>
|
191
|
+
<SidebarLayout
|
192
|
+
sidebar={sidebarItems}
|
193
|
+
basePath={basePath}
|
194
|
+
topContent={(() => {
|
195
|
+
const version = Schema.getVersion(schema)
|
196
|
+
const versionPicker = catalog._tag === 'CatalogVersioned' && version
|
197
|
+
? (
|
198
|
+
<ReferenceVersionPicker
|
199
|
+
data={Catalog.Versioned.getVersions(catalog)}
|
200
|
+
current={version}
|
201
|
+
/>
|
202
|
+
)
|
203
|
+
: null
|
204
|
+
|
205
|
+
return (
|
206
|
+
<Flex gap='3' align='center'>
|
207
|
+
{versionPicker}
|
208
|
+
{referenceConfig.descriptionsView.showControl && <ViewModeToggle />}
|
209
|
+
</Flex>
|
210
|
+
)
|
211
|
+
})()}
|
212
|
+
>
|
213
|
+
{content}
|
214
|
+
</SidebarLayout>
|
215
|
+
</GraphqlLifecycleProvider>
|
216
|
+
</ViewModeProvider>
|
217
|
+
</ReferenceConfigProvider>
|
174
218
|
)
|
175
219
|
}
|
176
220
|
|
@@ -207,7 +251,7 @@ const typeAndFieldRoutes = [
|
|
207
251
|
* - Single ReferenceView component handles all variations
|
208
252
|
*/
|
209
253
|
|
210
|
-
export const reference = !schemasCatalog
|
254
|
+
export const reference = !schemasCatalog || !templateConfig.reference.enabled
|
211
255
|
? null
|
212
256
|
: route({
|
213
257
|
path: `reference`,
|
@@ -35,6 +35,11 @@ declare module 'virtual:polen/project/examples' {
|
|
35
35
|
export const IndexComponent: React.ComponentType | null
|
36
36
|
}
|
37
37
|
|
38
|
+
declare module 'virtual:polen/project/reference' {
|
39
|
+
export const referenceCatalog: import('#api/reference/catalog').Catalog
|
40
|
+
export const IndexComponent: React.ComponentType | null
|
41
|
+
}
|
42
|
+
|
38
43
|
declare module 'virtual:polen/project/config' {
|
39
44
|
export const templateConfig: import('#api/config-template/template').TemplateConfig
|
40
45
|
}
|
package/src/vite/plugins/core.ts
CHANGED
@@ -10,6 +10,7 @@ import { Examples } from './examples.js'
|
|
10
10
|
import { Hooks, viProjectHooks } from './hooks.js'
|
11
11
|
import { Navbar, viProjectNavbar } from './navbar.js'
|
12
12
|
import { Pages, viProjectRoutes } from './pages.js'
|
13
|
+
import { Reference, viProjectReference } from './reference.js'
|
13
14
|
import { Schemas, viProjectSchema } from './schemas.js'
|
14
15
|
|
15
16
|
export interface ProjectRoutesModule {
|
@@ -44,6 +45,10 @@ export const Core = (config: Api.Config.Config): Vite.PluginOption[] => {
|
|
44
45
|
schemaReader: schemasArea.reader,
|
45
46
|
dependentVirtualModules: [viProjectConfig, viProjectNavbar],
|
46
47
|
})
|
48
|
+
const referenceArea = Reference({
|
49
|
+
config,
|
50
|
+
dependentVirtualModules: [viProjectConfig, viProjectNavbar],
|
51
|
+
})
|
47
52
|
const configPlugin = ConfigPlugin({
|
48
53
|
config,
|
49
54
|
schemaReader: schemasArea.reader,
|
@@ -62,6 +67,7 @@ export const Core = (config: Api.Config.Config): Vite.PluginOption[] => {
|
|
62
67
|
...conditionalPlugins,
|
63
68
|
...examplesArea.plugins,
|
64
69
|
...schemasArea.plugins,
|
70
|
+
...referenceArea.plugins,
|
65
71
|
...pagesArea.plugins,
|
66
72
|
configPlugin,
|
67
73
|
navbarPlugin,
|
@@ -121,6 +121,8 @@ export const Examples = ({
|
|
121
121
|
|| file.endsWith('.gql')
|
122
122
|
|| file.endsWith('index.md')
|
123
123
|
|| file.endsWith('index.mdx')
|
124
|
+
|| (file.endsWith('.md') && !file.endsWith('index.md'))
|
125
|
+
|| (file.endsWith('.mdx') && !file.endsWith('index.mdx'))
|
124
126
|
)
|
125
127
|
},
|
126
128
|
},
|
@@ -179,6 +181,16 @@ export const Examples = ({
|
|
179
181
|
s`export const IndexComponent = null`
|
180
182
|
}
|
181
183
|
|
184
|
+
// Export description components for each example
|
185
|
+
for (const example of scanExamplesResult.catalog.examples) {
|
186
|
+
if (example.description?.path) {
|
187
|
+
s``
|
188
|
+
s`export { default as DescriptionComponent_${
|
189
|
+
example.name.replace(/-/g, '_')
|
190
|
+
} } from '${example.description.path}'`
|
191
|
+
}
|
192
|
+
}
|
193
|
+
|
182
194
|
// Encode the catalog to ensure HashMap and other Effect types are properly serialized
|
183
195
|
const encodedCatalog = Catalog.encodeSync(catalogWithIndex)
|
184
196
|
|
@@ -46,7 +46,10 @@ export const Navbar = ({
|
|
46
46
|
>,
|
47
47
|
)
|
48
48
|
|
49
|
-
if (
|
49
|
+
// Check if reference is enabled (explicitly or auto-detected via schema presence)
|
50
|
+
const referenceEnabled = config.reference.enabled ?? Boolean(loadedSchemaCatalog?.data)
|
51
|
+
|
52
|
+
if (referenceEnabled && loadedSchemaCatalog?.data) {
|
50
53
|
// IMPORTANT: Always ensure paths start with '/' for React Router compatibility.
|
51
54
|
// Without the leading slash, React Router treats paths as relative, which causes
|
52
55
|
// hydration mismatches between SSR (where base path is prepended) and client
|
@@ -0,0 +1,130 @@
|
|
1
|
+
import type { Api } from '#api/$'
|
2
|
+
import * as ReferenceModule from '#api/reference/$'
|
3
|
+
import * as Catalog from '#api/reference/catalog'
|
4
|
+
import { Diagnostic } from '#lib/diagnostic/$'
|
5
|
+
import { ViteReactive } from '#lib/vite-reactive/$'
|
6
|
+
import { type AssetReader, createAssetReader } from '#lib/vite-reactive/reactive-asset-plugin'
|
7
|
+
import { ViteVirtual } from '#lib/vite-virtual'
|
8
|
+
import { debugPolen } from '#singletons/debug'
|
9
|
+
import { FileSystem } from '@effect/platform'
|
10
|
+
import * as NodeFileSystem from '@effect/platform-node/NodeFileSystem'
|
11
|
+
import { Str } from '@wollybeard/kit'
|
12
|
+
import { Effect } from 'effect'
|
13
|
+
import type * as Vite from 'vite'
|
14
|
+
import { polenVirtual } from '../vi.js'
|
15
|
+
|
16
|
+
// Virtual modules provided by this plugin
|
17
|
+
export const viProjectReference = polenVirtual([`project`, `reference`])
|
18
|
+
|
19
|
+
export interface Options {
|
20
|
+
config: Api.Config.Config
|
21
|
+
dependentVirtualModules?: ViteVirtual.Identifier.Identifier[]
|
22
|
+
}
|
23
|
+
|
24
|
+
/**
|
25
|
+
* Reference plugin for handling reference documentation
|
26
|
+
*/
|
27
|
+
export const Reference = ({
|
28
|
+
config,
|
29
|
+
dependentVirtualModules = [],
|
30
|
+
}: Options): {
|
31
|
+
plugins: Vite.Plugin[]
|
32
|
+
reader: AssetReader<ReferenceModule.ScanResult, Error, FileSystem.FileSystem>
|
33
|
+
} => {
|
34
|
+
const debug = debugPolen.sub(`vite-reference`)
|
35
|
+
|
36
|
+
const reader = createAssetReader<ReferenceModule.ScanResult, Error, FileSystem.FileSystem>(() => {
|
37
|
+
return ReferenceModule.scan({
|
38
|
+
dir: config.paths.project.rootDir,
|
39
|
+
})
|
40
|
+
})
|
41
|
+
|
42
|
+
const scanReference = async () => {
|
43
|
+
return await Effect.runPromise(
|
44
|
+
reader.read().pipe(Effect.provide(NodeFileSystem.layer)),
|
45
|
+
)
|
46
|
+
}
|
47
|
+
|
48
|
+
// Map diagnostic to its control configuration
|
49
|
+
const getControlForDiagnostic = (diagnostic: any) => {
|
50
|
+
return config.reference.diagnostics?.validation
|
51
|
+
}
|
52
|
+
|
53
|
+
// Report diagnostics
|
54
|
+
const reportDiagnostics = (
|
55
|
+
diagnostics: any[],
|
56
|
+
phase: 'dev' | 'build' = 'dev',
|
57
|
+
) => {
|
58
|
+
Diagnostic.filterAndReport(diagnostics, getControlForDiagnostic, phase)
|
59
|
+
}
|
60
|
+
|
61
|
+
// Check if a file is the reference index file
|
62
|
+
const isReferenceIndexFile = (file: string): boolean => {
|
63
|
+
return file.endsWith('/reference/index.md') || file.endsWith('/reference/index.mdx')
|
64
|
+
}
|
65
|
+
|
66
|
+
const plugins: Vite.Plugin[] = [
|
67
|
+
ViteReactive.ReactiveAssetPlugin<ReferenceModule.ScanResult, Error, FileSystem.FileSystem>({
|
68
|
+
name: 'polen:reference-reactive',
|
69
|
+
reader,
|
70
|
+
filePatterns: {
|
71
|
+
watch: ['reference'],
|
72
|
+
isRelevant: (file: string) => {
|
73
|
+
return isReferenceIndexFile(file)
|
74
|
+
},
|
75
|
+
},
|
76
|
+
dependentVirtualModules: [viProjectReference, ...dependentVirtualModules],
|
77
|
+
hooks: {
|
78
|
+
async shouldFullReload() {
|
79
|
+
// Trigger full reload for reference changes
|
80
|
+
return true
|
81
|
+
},
|
82
|
+
async onDiagnostics(data: any) {
|
83
|
+
// Report diagnostics with DiagnosticControl filtering
|
84
|
+
reportDiagnostics(data.diagnostics, 'dev')
|
85
|
+
},
|
86
|
+
},
|
87
|
+
}),
|
88
|
+
{
|
89
|
+
name: 'polen:reference-virtual',
|
90
|
+
...ViteVirtual.IdentifiedLoader.toHooks(
|
91
|
+
{
|
92
|
+
identifier: viProjectReference,
|
93
|
+
async loader() {
|
94
|
+
debug(`Loading viProjectReference virtual module`)
|
95
|
+
|
96
|
+
const scanReferenceResult = await scanReference()
|
97
|
+
|
98
|
+
reportDiagnostics(scanReferenceResult.diagnostics, 'dev')
|
99
|
+
|
100
|
+
// Generate the module code with both catalog and component exports
|
101
|
+
const s = Str.Builder()
|
102
|
+
s`import { Effect } from 'effect'`
|
103
|
+
s`import * as Catalog from '#api/reference/catalog'`
|
104
|
+
|
105
|
+
const indexFilePath = scanReferenceResult.catalog.index?.path
|
106
|
+
if (indexFilePath) {
|
107
|
+
s``
|
108
|
+
s`export { default as IndexComponent } from '${indexFilePath}'`
|
109
|
+
} else {
|
110
|
+
s``
|
111
|
+
s`export const IndexComponent = null`
|
112
|
+
}
|
113
|
+
|
114
|
+
// Encode the catalog to ensure proper serialization
|
115
|
+
const encodedCatalog = Catalog.encodeSync(scanReferenceResult.catalog)
|
116
|
+
|
117
|
+
s``
|
118
|
+
s`const catalogData = ${JSON.stringify(encodedCatalog)}`
|
119
|
+
s``
|
120
|
+
s`export const referenceCatalog = Catalog.decodeSync(catalogData)`
|
121
|
+
|
122
|
+
return s.render()
|
123
|
+
},
|
124
|
+
},
|
125
|
+
),
|
126
|
+
},
|
127
|
+
]
|
128
|
+
|
129
|
+
return { plugins, reader }
|
130
|
+
}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"ArgumentList.d.ts","sourceRoot":"","sources":["../../../src/template/components/ArgumentList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAE7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAG9C,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,IAAI,EAAE,SAAS,eAAe,EAAE,CAAA;CAAE,CAgBxE,CAAA"}
|
@@ -1,9 +0,0 @@
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
|
-
import { Box, Flex, Heading, Text } from '@radix-ui/themes';
|
3
|
-
import { TypeAnnotation } from './TypeAnnotation.js';
|
4
|
-
export const ArgumentsList = ({ args }) => {
|
5
|
-
if (args.length === 0)
|
6
|
-
return null;
|
7
|
-
return (_jsxs(Flex, { direction: 'column', children: [_jsx(Heading, { size: '1', weight: 'bold', children: "Arguments" }), args.map(arg => (_jsxs(Box, { children: [_jsx(Text, { children: arg.name }), _jsx(Text, { children: ":" }), _jsx(TypeAnnotation, { type: arg.type }), arg.description && _jsx(Text, { as: 'p', size: '2', color: 'gray', children: arg.description })] }, arg.name)))] }));
|
8
|
-
};
|
9
|
-
//# sourceMappingURL=ArgumentList.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"ArgumentList.js","sourceRoot":"","sources":["../../../src/template/components/ArgumentList.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAE3D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAEpD,MAAM,CAAC,MAAM,aAAa,GAAmD,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE;IACxF,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAA;IAElC,OAAO,CACL,MAAC,IAAI,IAAC,SAAS,EAAC,QAAQ,aACtB,KAAC,OAAO,IAAC,IAAI,EAAC,GAAG,EAAC,MAAM,EAAC,MAAM,0BAAoB,EAClD,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CACf,MAAC,GAAG,eACF,KAAC,IAAI,cAAE,GAAG,CAAC,IAAI,GAAQ,EACvB,KAAC,IAAI,oBAAS,EACd,KAAC,cAAc,IAAC,IAAI,EAAE,GAAG,CAAC,IAAI,GAAI,EACjC,GAAG,CAAC,WAAW,IAAI,KAAC,IAAI,IAAC,EAAE,EAAC,GAAG,EAAC,IAAI,EAAC,GAAG,EAAC,KAAK,EAAC,MAAM,YAAE,GAAG,CAAC,WAAW,GAAQ,KAJvE,GAAG,CAAC,IAAI,CAKZ,CACP,CAAC,IACG,CACR,CAAA;AACH,CAAC,CAAA"}
|
@@ -1,22 +0,0 @@
|
|
1
|
-
import type { React } from '#dep/react/index'
|
2
|
-
import { Box, Flex, Heading, Text } from '@radix-ui/themes'
|
3
|
-
import type { GraphQLArgument } from 'graphql'
|
4
|
-
import { TypeAnnotation } from './TypeAnnotation.js'
|
5
|
-
|
6
|
-
export const ArgumentsList: React.FC<{ args: readonly GraphQLArgument[] }> = ({ args }) => {
|
7
|
-
if (args.length === 0) return null
|
8
|
-
|
9
|
-
return (
|
10
|
-
<Flex direction='column'>
|
11
|
-
<Heading size='1' weight='bold'>Arguments</Heading>
|
12
|
-
{args.map(arg => (
|
13
|
-
<Box key={arg.name}>
|
14
|
-
<Text>{arg.name}</Text>
|
15
|
-
<Text>:</Text>
|
16
|
-
<TypeAnnotation type={arg.type} />
|
17
|
-
{arg.description && <Text as='p' size='2' color='gray'>{arg.description}</Text>}
|
18
|
-
</Box>
|
19
|
-
))}
|
20
|
-
</Flex>
|
21
|
-
)
|
22
|
-
}
|