polen 0.10.0-next.13 → 0.10.0-next.14

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.
Files changed (104) hide show
  1. package/build/api/vite/plugins/build.d.ts.map +1 -1
  2. package/build/api/vite/plugins/build.js +11 -3
  3. package/build/api/vite/plugins/build.js.map +1 -1
  4. package/build/api/vite/plugins/core.d.ts.map +1 -1
  5. package/build/api/vite/plugins/core.js +12 -10
  6. package/build/api/vite/plugins/core.js.map +1 -1
  7. package/build/api/vite/plugins/pages.d.ts.map +1 -1
  8. package/build/api/vite/plugins/pages.js +6 -7
  9. package/build/api/vite/plugins/pages.js.map +1 -1
  10. package/build/api/vite/plugins/serve.d.ts.map +1 -1
  11. package/build/api/vite/plugins/serve.js +47 -7
  12. package/build/api/vite/plugins/serve.js.map +1 -1
  13. package/build/lib/file-router/diagnostic-reporter.js +2 -2
  14. package/build/lib/file-router/diagnostic-reporter.js.map +1 -1
  15. package/build/lib/graphql-document/components/GraphQLDocument.d.ts.map +1 -1
  16. package/build/lib/graphql-document/components/GraphQLDocument.js +23 -11
  17. package/build/lib/graphql-document/components/GraphQLDocument.js.map +1 -1
  18. package/build/lib/graphql-document/positioning-simple.d.ts +0 -5
  19. package/build/lib/graphql-document/positioning-simple.d.ts.map +1 -1
  20. package/build/lib/graphql-document/positioning-simple.js +78 -90
  21. package/build/lib/graphql-document/positioning-simple.js.map +1 -1
  22. package/build/lib/kit-temp.d.ts +103 -0
  23. package/build/lib/kit-temp.d.ts.map +1 -1
  24. package/build/lib/kit-temp.js +236 -2
  25. package/build/lib/kit-temp.js.map +1 -1
  26. package/build/lib/vite-plugin-reactive-data/vite-plugin-reactive-data.d.ts +1 -8
  27. package/build/lib/vite-plugin-reactive-data/vite-plugin-reactive-data.d.ts.map +1 -1
  28. package/build/lib/vite-plugin-reactive-data/vite-plugin-reactive-data.js +48 -53
  29. package/build/lib/vite-plugin-reactive-data/vite-plugin-reactive-data.js.map +1 -1
  30. package/build/package-paths.js +3 -3
  31. package/build/package-paths.js.map +1 -1
  32. package/build/template/components/Link.d.ts +1 -1
  33. package/build/template/components/Link.d.ts.map +1 -1
  34. package/build/template/components/Link.js +14 -5
  35. package/build/template/components/Link.js.map +1 -1
  36. package/build/template/components/content/GraphQLDocumentWithSchema.d.ts.map +1 -1
  37. package/build/template/components/content/GraphQLDocumentWithSchema.js +0 -3
  38. package/build/template/components/content/GraphQLDocumentWithSchema.js.map +1 -1
  39. package/build/template/components/content/GraphQLDocumentWrapper.d.ts.map +1 -1
  40. package/build/template/components/content/GraphQLDocumentWrapper.js +8 -7
  41. package/build/template/components/content/GraphQLDocumentWrapper.js.map +1 -1
  42. package/build/template/components/sidebar/SidebarItem.js +2 -2
  43. package/build/template/entry.client.d.ts.map +1 -1
  44. package/build/template/entry.client.js +0 -3
  45. package/build/template/entry.client.js.map +1 -1
  46. package/build/template/hooks/useClientOnly.d.ts +9 -0
  47. package/build/template/hooks/useClientOnly.d.ts.map +1 -0
  48. package/build/template/hooks/useClientOnly.js +16 -0
  49. package/build/template/hooks/useClientOnly.js.map +1 -0
  50. package/build/template/routes/root.d.ts.map +1 -1
  51. package/build/template/routes/root.js +2 -150
  52. package/build/template/routes/root.js.map +1 -1
  53. package/build/template/server/app.d.ts +8 -1
  54. package/build/template/server/app.d.ts.map +1 -1
  55. package/build/template/server/app.js +21 -21
  56. package/build/template/server/app.js.map +1 -1
  57. package/build/template/server/create-page-html-response.d.ts +7 -0
  58. package/build/template/server/create-page-html-response.d.ts.map +1 -0
  59. package/build/template/server/{render-page.js → create-page-html-response.js} +11 -16
  60. package/build/template/server/create-page-html-response.js.map +1 -0
  61. package/build/template/server/main.js +2 -1
  62. package/build/template/server/main.js.map +1 -1
  63. package/build/template/server/middleware/page.d.ts +4 -0
  64. package/build/template/server/middleware/page.d.ts.map +1 -0
  65. package/build/template/server/middleware/page.js +15 -0
  66. package/build/template/server/middleware/page.js.map +1 -0
  67. package/build/template/server/middleware/unsupported-assets.d.ts +10 -0
  68. package/build/template/server/middleware/unsupported-assets.d.ts.map +1 -0
  69. package/build/template/server/middleware/unsupported-assets.js +21 -0
  70. package/build/template/server/middleware/unsupported-assets.js.map +1 -0
  71. package/build/template/server/ssg/generate.d.ts.map +1 -1
  72. package/build/template/server/ssg/generate.js +33 -34
  73. package/build/template/server/ssg/generate.js.map +1 -1
  74. package/build/template/styles/code-block.css +218 -0
  75. package/package.json +3 -2
  76. package/src/api/singletons/markdown/markdown.test.ts +1 -1
  77. package/src/api/vite/plugins/build.ts +97 -89
  78. package/src/api/vite/plugins/core.ts +15 -10
  79. package/src/api/vite/plugins/pages.ts +9 -7
  80. package/src/api/vite/plugins/serve.ts +62 -9
  81. package/src/lib/file-router/diagnostic-reporter.ts +2 -2
  82. package/src/lib/graphql-document/components/GraphQLDocument.tsx +23 -11
  83. package/src/lib/graphql-document/positioning-simple.test.ts +18 -22
  84. package/src/lib/graphql-document/positioning-simple.ts +97 -108
  85. package/src/lib/kit-temp.test.ts +15 -3
  86. package/src/lib/kit-temp.ts +304 -4
  87. package/src/lib/vite-plugin-reactive-data/vite-plugin-reactive-data.ts +52 -58
  88. package/src/package-paths.ts +3 -3
  89. package/src/template/components/Link.tsx +20 -12
  90. package/src/template/components/content/GraphQLDocumentWithSchema.tsx +0 -5
  91. package/src/template/components/content/GraphQLDocumentWrapper.tsx +14 -7
  92. package/src/template/components/sidebar/SidebarItem.tsx +2 -2
  93. package/src/template/entry.client.tsx +0 -3
  94. package/src/template/hooks/useClientOnly.ts +21 -0
  95. package/src/template/routes/root.tsx +0 -159
  96. package/src/template/server/app.ts +33 -23
  97. package/src/template/server/{render-page.tsx → create-page-html-response.ts} +19 -16
  98. package/src/template/server/main.ts +2 -1
  99. package/src/template/server/middleware/page.ts +19 -0
  100. package/src/template/server/middleware/unsupported-assets.ts +25 -0
  101. package/src/template/server/ssg/generate.ts +68 -72
  102. package/build/template/server/render-page.d.ts +0 -3
  103. package/build/template/server/render-page.d.ts.map +0 -1
  104. package/build/template/server/render-page.js.map +0 -1
@@ -0,0 +1,218 @@
1
+ /* Code Block Styles */
2
+
3
+ /* Base code block container */
4
+ .code-block {
5
+ position: relative;
6
+ margin: 1rem 0;
7
+ border-radius: 8px;
8
+ overflow: hidden;
9
+ font-size: 14px;
10
+ line-height: 1.6;
11
+ }
12
+
13
+ .code-block pre {
14
+ margin: 0;
15
+ padding: 1rem;
16
+ overflow-x: auto;
17
+ background: inherit;
18
+ }
19
+
20
+ .code-block code {
21
+ font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, 'Liberation Mono', Menlo, monospace;
22
+ font-variant-ligatures: contextual;
23
+ }
24
+
25
+ /* Shiki theme switching with CSS variables */
26
+ /* Default to light theme */
27
+ :root {
28
+ color-scheme: light;
29
+ }
30
+
31
+ /* When dark mode is active */
32
+ .dark {
33
+ color-scheme: dark;
34
+ }
35
+
36
+ /* Shiki token colors for light theme (github-light) */
37
+ :root {
38
+ --shiki-color-text: #24292e;
39
+ --shiki-color-background: #f6f8fa;
40
+ --shiki-token-constant: #005cc5;
41
+ --shiki-token-string: #032f62;
42
+ --shiki-token-comment: #6a737d;
43
+ --shiki-token-keyword: #d73a49;
44
+ --shiki-token-parameter: #e36209;
45
+ --shiki-token-function: #6f42c1;
46
+ --shiki-token-string-expression: #032f62;
47
+ --shiki-token-punctuation: #24292e;
48
+ --shiki-token-link: #032f62;
49
+ }
50
+
51
+ /* Shiki token colors for dark theme (tokyo-night) */
52
+ .dark {
53
+ --shiki-color-text: #c0caf5;
54
+ --shiki-color-background: #1a1b26;
55
+ --shiki-token-constant: #ff9e64;
56
+ --shiki-token-string: #9ece6a;
57
+ --shiki-token-comment: #565f89;
58
+ --shiki-token-keyword: #bb9af7;
59
+ --shiki-token-parameter: #e0af68;
60
+ --shiki-token-function: #7aa2f7;
61
+ --shiki-token-string-expression: #9ece6a;
62
+ --shiki-token-punctuation: #c0caf5;
63
+ --shiki-token-link: #9ece6a;
64
+ }
65
+
66
+ /* Shiki code blocks */
67
+ pre.shiki {
68
+ margin: 1rem 0;
69
+ padding: 1rem;
70
+ border-radius: 8px;
71
+ overflow-x: auto;
72
+ font-size: 14px;
73
+ line-height: 1.6;
74
+ background-color: var(--shiki-color-background);
75
+ color: var(--shiki-color-text);
76
+ }
77
+
78
+ pre.shiki code {
79
+ font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, 'Liberation Mono', Menlo, monospace;
80
+ font-variant-ligatures: contextual;
81
+ }
82
+
83
+ /* Line numbers */
84
+ .code-block[data-line-numbers="true"] pre {
85
+ padding-left: 3.5rem;
86
+ position: relative;
87
+ }
88
+
89
+ .code-block[data-line-numbers="true"] .line {
90
+ position: relative;
91
+ }
92
+
93
+ .code-block[data-line-numbers="true"] .line::before {
94
+ content: attr(data-line);
95
+ position: absolute;
96
+ left: -3rem;
97
+ width: 2.5rem;
98
+ text-align: right;
99
+ color: var(--gray-a6);
100
+ user-select: none;
101
+ }
102
+
103
+ /* Line highlighting */
104
+ .code-block .line[data-highlighted="true"] {
105
+ background-color: var(--amber-a3);
106
+ display: block;
107
+ margin: 0 -1rem;
108
+ padding: 0 1rem;
109
+ }
110
+
111
+ /* Diff lines */
112
+ .code-block .line[data-diff="+"] {
113
+ background-color: var(--green-a3);
114
+ display: block;
115
+ margin: 0 -1rem;
116
+ padding: 0 1rem;
117
+ }
118
+
119
+ .code-block .line[data-diff="-"] {
120
+ background-color: var(--red-a3);
121
+ display: block;
122
+ margin: 0 -1rem;
123
+ padding: 0 1rem;
124
+ }
125
+
126
+ .code-block .line[data-diff="+"]::before {
127
+ content: "+ ";
128
+ color: var(--green-11);
129
+ font-weight: bold;
130
+ }
131
+
132
+ .code-block .line[data-diff="-"]::before {
133
+ content: "- ";
134
+ color: var(--red-11);
135
+ font-weight: bold;
136
+ }
137
+
138
+ /* Focus lines */
139
+ .code-block .line:not([data-focus="true"]) {
140
+ opacity: 0.5;
141
+ filter: grayscale(100%);
142
+ transition: opacity 0.2s, filter 0.2s;
143
+ }
144
+
145
+ .code-block:hover .line:not([data-focus="true"]) {
146
+ opacity: 0.8;
147
+ filter: grayscale(0%);
148
+ }
149
+
150
+ /* Copy button */
151
+ .code-block-copy {
152
+ position: absolute;
153
+ top: 0.5rem;
154
+ right: 0.5rem;
155
+ padding: 0.25rem 0.5rem;
156
+ border-radius: 4px;
157
+ background: var(--gray-a3);
158
+ color: var(--gray-12);
159
+ border: 1px solid var(--gray-a5);
160
+ cursor: pointer;
161
+ font-size: 12px;
162
+ transition: all 0.2s;
163
+ }
164
+
165
+ .code-block-copy:hover {
166
+ background: var(--gray-a4);
167
+ border-color: var(--gray-a6);
168
+ }
169
+
170
+ .code-block-copy.copied {
171
+ background: var(--green-a3);
172
+ border-color: var(--green-a5);
173
+ color: var(--green-11);
174
+ }
175
+
176
+ /* Language badge */
177
+ .code-block-lang {
178
+ position: absolute;
179
+ top: 0;
180
+ right: 0;
181
+ padding: 0.25rem 0.75rem;
182
+ background: var(--gray-a3);
183
+ color: var(--gray-11);
184
+ font-size: 12px;
185
+ font-weight: 500;
186
+ border-bottom-left-radius: 4px;
187
+ user-select: none;
188
+ }
189
+
190
+ /* Scrollbar styling */
191
+ .code-block pre::-webkit-scrollbar {
192
+ height: 8px;
193
+ width: 8px;
194
+ }
195
+
196
+ .code-block pre::-webkit-scrollbar-track {
197
+ background: var(--gray-a3);
198
+ border-radius: 4px;
199
+ }
200
+
201
+ .code-block pre::-webkit-scrollbar-thumb {
202
+ background: var(--gray-a6);
203
+ border-radius: 4px;
204
+ }
205
+
206
+ .code-block pre::-webkit-scrollbar-thumb:hover {
207
+ background: var(--gray-a7);
208
+ }
209
+
210
+ /* Inline code */
211
+ code:not(.code-block code) {
212
+ padding: 0.2em 0.4em;
213
+ margin: 0;
214
+ font-size: 0.85em;
215
+ background-color: var(--gray-a3);
216
+ border-radius: 4px;
217
+ font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, 'Liberation Mono', Menlo, monospace;
218
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "polen",
3
- "version": "0.10.0-next.13",
3
+ "version": "0.10.0-next.14",
4
4
  "type": "module",
5
5
  "description": "A framework for delightful GraphQL developer portals",
6
6
  "author": {
@@ -268,7 +268,8 @@
268
268
  "prepublishOnly": "pnpm build",
269
269
  "prepack": "pnpm build",
270
270
  "build:cli:chmodx": "chmod +x ./build/cli/index.js",
271
- "postbuild": "pnpm run build:cli:chmodx",
271
+ "postbuild": "pnpm run build:cli:chmodx && pnpm run build:copy-assets",
272
+ "build:copy-assets": "cp -r src/template/styles build/template/",
272
273
  "test": "vitest",
273
274
  "check": "pnpm run '/^check:(?!pedantic:).+/'",
274
275
  "checkAll": "pnpm run '/^check:.+/'",
@@ -2,7 +2,7 @@ import { describe, expect, test } from 'vitest'
2
2
  import { parse } from './markdown.ts'
3
3
 
4
4
  describe(`markdown parser with syntax highlighting`, () => {
5
- test(`parse highlights code blocks`, async () => {
5
+ test(`parse highlights code blocks`, { timeout: 10000 }, async () => {
6
6
  const markdown = `
7
7
  # Hello
8
8
 
@@ -2,118 +2,126 @@ import type { Config } from '#api/config/index'
2
2
  import type { PolenBuildManifest } from '#api/static/manifest'
3
3
  import { Vite } from '#dep/vite/index'
4
4
  import { ViteVirtual } from '#lib/vite-virtual/index'
5
+ import { debugPolen } from '#singletons/debug'
5
6
  import { Fs, Path } from '@wollybeard/kit'
6
7
  import packageJson from '../../../../package.json' with { type: 'json' }
7
8
  import { isKitUnusedExternalImport, isRadixModuleLevelDirective } from '../log-filters.ts'
8
9
  import { polenVirtual } from '../vi.ts'
9
10
 
10
11
  export const Build = (config: Config.Config): Vite.Plugin[] => {
12
+ const debug = debugPolen.sub(`vite-build`)
13
+ debug('construct')
11
14
  // let viteConfigResolved: Vite.ResolvedConfig
12
15
 
13
16
  // const outDir = Path.join(config.paths.project.rootDir, `dist`)
14
17
 
15
- return [Manifest(config), BuildManifest(config), {
16
- name: `polen:build-client`,
17
- apply: `build`,
18
- applyToEnvironment: Vite.isEnvironmentClient,
19
- // HACK: For some reason the ?url import doesn't lead to a rewrite in the build.
20
- // Furthermore we need to rely on the manifest to get its final name because it is
21
- // generated by the client build before the server build.
22
- // However, we still need the asset in development.
23
- // But we cannot exclude the import in build.
24
- // So this does that for us but it is really hacky.
25
- // FIXME
26
- // 1. Raise issue about having ?url lead to expected build path rewrite?
27
- // 2. And: Move asset generation to server build?
28
- // 3. And/or: Use Vite Environments API?
29
- generateBundle(_, bundle, isWrite) {
30
- if (isWrite) {
31
- for (const chunkOrAsset of Object.values(bundle)) {
32
- if (chunkOrAsset.type === `asset` && chunkOrAsset.names.includes(`entry.client.jsx`)) {
33
- // eslint-disable-next-line
34
- delete bundle[chunkOrAsset.fileName]
18
+ return [
19
+ Manifest(config),
20
+ BuildManifest(config),
21
+ {
22
+ name: `polen:build-client`,
23
+ apply: `build`,
24
+ applyToEnvironment: Vite.isEnvironmentClient,
25
+ // HACK: For some reason the ?url import doesn't lead to a rewrite in the build.
26
+ // Furthermore we need to rely on the manifest to get its final name because it is
27
+ // generated by the client build before the server build.
28
+ // However, we still need the asset in development.
29
+ // But we cannot exclude the import in build.
30
+ // So this does that for us but it is really hacky.
31
+ // FIXME
32
+ // 1. Raise issue about having ?url lead to expected build path rewrite?
33
+ // 2. And: Move asset generation to server build?
34
+ // 3. And/or: Use Vite Environments API?
35
+ generateBundle(_, bundle, isWrite) {
36
+ if (isWrite) {
37
+ for (const chunkOrAsset of Object.values(bundle)) {
38
+ if (chunkOrAsset.type === `asset` && chunkOrAsset.names.includes(`entry.client.jsx`)) {
39
+ // eslint-disable-next-line
40
+ delete bundle[chunkOrAsset.fileName]
41
+ }
35
42
  }
36
43
  }
37
- }
38
- },
39
- onLog(_, message) {
40
- if (isRadixModuleLevelDirective(message)) return
41
- if (isKitUnusedExternalImport(message)) return
42
- },
43
- config() {
44
- return {
45
- environments: {
46
- client: {
47
- build: {
48
- manifest: true,
49
- rollupOptions: {
50
- input: [config.paths.framework.template.client.entrypoint],
51
- external: id => id.startsWith(`node:`),
52
- onwarn(message) {
53
- if (isKitUnusedExternalImport(message)) return
44
+ },
45
+ onLog(_, message) {
46
+ if (isRadixModuleLevelDirective(message)) return
47
+ if (isKitUnusedExternalImport(message)) return
48
+ },
49
+ config() {
50
+ return {
51
+ environments: {
52
+ client: {
53
+ build: {
54
+ manifest: true,
55
+ rollupOptions: {
56
+ input: [config.paths.framework.template.client.entrypoint],
57
+ external: id => id.startsWith(`node:`),
58
+ onwarn(message) {
59
+ if (isKitUnusedExternalImport(message)) return
60
+ },
54
61
  },
55
62
  },
56
63
  },
57
64
  },
58
- },
59
- }
65
+ }
66
+ },
60
67
  },
61
- }, {
62
- name: `polen-ssr-build`,
63
- apply: `build`,
64
- applyToEnvironment: Vite.isEnvironmentSsr,
65
- config() {
66
- return {
67
- // Have to configure this here??
68
- // @see https://github.com/vitejs/vite/issues/20098
69
- ssr: {
70
- noExternal: true,
71
- },
72
- environments: {
68
+
69
+ {
70
+ name: `polen-ssr-build`,
71
+ apply: `build`,
72
+ applyToEnvironment: Vite.isEnvironmentSsr,
73
+ config() {
74
+ return {
75
+ // Have to configure this here??
76
+ // @see https://github.com/vitejs/vite/issues/20098
73
77
  ssr: {
74
- build: {
75
- // NO EFFECT (see above)
76
- // Bundle all dependencies instead of externalizing them
77
- // noExternal: true,
78
- // The SSR build will follow the client build, and emptying the dir would lose the output of the client build.
79
- emptyOutDir: false,
80
- rollupOptions: {
81
- input: [config.paths.framework.template.server.entrypoint],
82
- output: {
83
- entryFileNames: config.paths.project.relative.build.relative.serverEntrypoint,
78
+ noExternal: true,
79
+ },
80
+ environments: {
81
+ ssr: {
82
+ build: {
83
+ // NO EFFECT (see above)
84
+ // Bundle all dependencies instead of externalizing them
85
+ // noExternal: true,
86
+ // The SSR build will follow the client build, and emptying the dir would lose the output of the client build.
87
+ emptyOutDir: false,
88
+ rollupOptions: {
89
+ input: [config.paths.framework.template.server.entrypoint],
90
+ output: {
91
+ entryFileNames: config.paths.project.relative.build.relative.serverEntrypoint,
92
+ },
84
93
  },
85
94
  },
86
95
  },
87
96
  },
88
- },
89
- }
90
- },
91
-
92
- onLog(_, message) {
93
- if (isKitUnusedExternalImport(message)) return
94
- },
95
- // generateBundle(_, bundle, isWrite) {
96
- // if (isWrite) {
97
- // for (const chunkOrAsset of Object.values(bundle)) {
98
- // console.log(chunkOrAsset)
99
- // if (chunkOrAsset.type === `chunk`) {
100
- // if (chunkOrAsset.facadeModuleId === viClientManifest.resolved) {
101
- // // eslint-disable-next-line
102
- // delete bundle[chunkOrAsset.fileName]
103
- // }
104
- // }
105
- // }
106
- // }
107
- // },
108
- async closeBundle() {
109
- /**
110
- * clean up the manifest. Was generated by client. For server build. Not needed after (unless debugging).
111
- */
112
- if (!config.advanced.debug) {
113
- await Fs.remove(Path.join(config.paths.project.absolute.build.root, `.vite`))
114
- }
97
+ }
98
+ },
99
+ onLog(_, message) {
100
+ if (isKitUnusedExternalImport(message)) return
101
+ },
102
+ // generateBundle(_, bundle, isWrite) {
103
+ // if (isWrite) {
104
+ // for (const chunkOrAsset of Object.values(bundle)) {
105
+ // console.log(chunkOrAsset)
106
+ // if (chunkOrAsset.type === `chunk`) {
107
+ // if (chunkOrAsset.facadeModuleId === viClientManifest.resolved) {
108
+ // // eslint-disable-next-line
109
+ // delete bundle[chunkOrAsset.fileName]
110
+ // }
111
+ // }
112
+ // }
113
+ // }
114
+ // },
115
+ async closeBundle() {
116
+ /**
117
+ * clean up the manifest. Was generated by client. For server build. Not needed after (unless debugging).
118
+ */
119
+ if (!config.advanced.debug) {
120
+ await Fs.remove(Path.join(config.paths.project.absolute.build.root, `.vite`))
121
+ }
122
+ },
115
123
  },
116
- }]
124
+ ]
117
125
  }
118
126
 
119
127
  const viClientManifest = polenVirtual([`vite`, `client`, `manifest`])
@@ -57,7 +57,7 @@ export const Core = (config: Config.Config): Vite.PluginOption[] => {
57
57
  }))
58
58
  }
59
59
 
60
- const json = VitePluginJson.create({
60
+ const jsonsuper = VitePluginJson.create({
61
61
  codec: {
62
62
  validate: superjson,
63
63
  importPath: import.meta.resolve('#singletons/superjson'),
@@ -85,7 +85,7 @@ export const Core = (config: Config.Config): Vite.PluginOption[] => {
85
85
  name: `polen:internal-import-alias`,
86
86
  enforce: 'pre' as const,
87
87
  resolveId(id, importer) {
88
- const d = debugPolen.sub(`vite-plugin:internal-import-alias`)
88
+ // const debug = debugPolen.sub(`vite-plugin:internal-import-alias`)
89
89
 
90
90
  const isPolenImporter = Boolean(
91
91
  importer
@@ -107,25 +107,24 @@ export const Core = (config: Config.Config): Vite.PluginOption[] => {
107
107
  )
108
108
 
109
109
  if (!isPolenImporter) return null
110
- d(`check candidate`, { id, importer, isPolenImporter })
110
+ // debug(`check candidate`, { id, importer, isPolenImporter })
111
111
 
112
112
  const find = Str.pattern<{ groups: [`path`] }>(/^#(?<path>.+)/)
113
113
  const match = Str.match(id, find)
114
114
  if (!match) return null
115
115
 
116
116
  const to = `${config.paths.framework.sourceDir}/${match.groups.path}${config.paths.framework.sourceExtension}`
117
- d(`did resolve`, { from: id, to })
117
+ // debug(`did resolve`, { from: id, to })
118
118
 
119
119
  return to
120
120
  },
121
121
  },
122
- json,
122
+ jsonsuper,
123
123
  VitePluginReactiveData.create({
124
- moduleId: `virtual:polen/project/data/navbar`,
125
- data: navbarData.value,
124
+ moduleId: `virtual:polen/project/data/navbar.jsonsuper`,
126
125
  codec: superjson,
126
+ data: navbarData.value,
127
127
  name: `polen-navbar`,
128
- moduleType: 'jsonsuper',
129
128
  }),
130
129
  ...Pages({
131
130
  config,
@@ -181,12 +180,18 @@ export const Core = (config: Config.Config): Vite.PluginOption[] => {
181
180
  {
182
181
  identifier: viProjectData,
183
182
  async loader() {
183
+ const debug = debugPolen.sub(`module-project-data`)
184
+
185
+ debug('load', { id: viProjectData.id })
186
+
184
187
  const schema = await readSchema()
185
188
 
186
189
  // ━ Schema presence causes adding some navbar items
187
- const schemaNavbar = navbarData.get('schema')
188
- schemaNavbar.length = 0 // Clear existing
189
190
  if (schema) {
191
+ const schemaNavbar = navbarData.get('schema')
192
+ schemaNavbar.length = 0 // Clear existing
193
+ debug('update navbar', { message: 'for schema' })
194
+
190
195
  // IMPORTANT: Always ensure paths start with '/' for React Router compatibility.
191
196
  // Without the leading slash, React Router treats paths as relative, which causes
192
197
  // hydration mismatches between SSR (where base path is prepended) and client
@@ -14,7 +14,7 @@ import { Arr, Cache, Path, Str } from '@wollybeard/kit'
14
14
  import remarkFrontmatter from 'remark-frontmatter'
15
15
  import remarkGfm from 'remark-gfm'
16
16
 
17
- const debug = debugPolen.sub(`vite-plugin-pages`)
17
+ const debug = debugPolen.sub(`vite-pages`)
18
18
 
19
19
  export const viProjectRoutes = polenVirtual([`project`, `routes.jsx`], { allowPluginProcessing: true })
20
20
  export const viProjectPagesCatalog = polenVirtual([`project`, `data`, 'pages-catalog.jsonsuper'], {
@@ -207,25 +207,27 @@ export const Pages = ({
207
207
  // },
208
208
  async handler(id) {
209
209
  if (id !== viProjectPagesCatalog.resolved) return
210
- debug(`viProjectPagesCatalog`)
210
+ debug(`hook load`)
211
211
 
212
212
  const scanResult = await scanPages()
213
213
 
214
- // Report any diagnostics
215
214
  reportDiagnostics(scanResult.diagnostics)
216
- debug(`Found ${String(scanResult.list.length)} visible pages`)
215
+ debug(`found visible`, { count: scanResult.list.length })
217
216
 
218
217
  //
219
218
  // ━━ Build Navbar
220
219
  //
221
220
 
222
- // Update navbar if provided
223
221
  if (navbarData) {
224
222
  const navbarPages = navbarData.get('pages')
223
+
225
224
  navbarPages.length = 0 // Clear existing
226
225
 
227
- const navbarItems = createNavbar(scanResult.list)
228
- navbarPages.push(...navbarItems)
226
+ const data = createNavbar(scanResult.list)
227
+
228
+ debug('update navbar', data)
229
+
230
+ navbarPages.push(...data)
229
231
  }
230
232
 
231
233
  //