@jasonshimmy/vite-plugin-cer-app 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (299) hide show
  1. package/.github/copilot-instructions.md +130 -0
  2. package/.github/workflows/publish.yml +206 -0
  3. package/.nvmrc +1 -0
  4. package/CHANGELOG.md +10 -0
  5. package/IMPLEMENTATION_PLAN.md +391 -0
  6. package/README.md +231 -0
  7. package/VITE_PLUGIN_FRAMEWORK_PLAN.md +594 -0
  8. package/commits.txt +3 -0
  9. package/dist/__tests__/plugin/path-utils.test.d.ts +2 -0
  10. package/dist/__tests__/plugin/path-utils.test.d.ts.map +1 -0
  11. package/dist/__tests__/plugin/path-utils.test.js +305 -0
  12. package/dist/__tests__/plugin/path-utils.test.js.map +1 -0
  13. package/dist/__tests__/plugin/scanner.test.d.ts +2 -0
  14. package/dist/__tests__/plugin/scanner.test.d.ts.map +1 -0
  15. package/dist/__tests__/plugin/scanner.test.js +143 -0
  16. package/dist/__tests__/plugin/scanner.test.js.map +1 -0
  17. package/dist/__tests__/plugin/transforms/auto-import.test.d.ts +2 -0
  18. package/dist/__tests__/plugin/transforms/auto-import.test.d.ts.map +1 -0
  19. package/dist/__tests__/plugin/transforms/auto-import.test.js +151 -0
  20. package/dist/__tests__/plugin/transforms/auto-import.test.js.map +1 -0
  21. package/dist/__tests__/plugin/transforms/head-inject.test.d.ts +2 -0
  22. package/dist/__tests__/plugin/transforms/head-inject.test.d.ts.map +1 -0
  23. package/dist/__tests__/plugin/transforms/head-inject.test.js +151 -0
  24. package/dist/__tests__/plugin/transforms/head-inject.test.js.map +1 -0
  25. package/dist/__tests__/plugin/virtual/components.test.d.ts +2 -0
  26. package/dist/__tests__/plugin/virtual/components.test.d.ts.map +1 -0
  27. package/dist/__tests__/plugin/virtual/components.test.js +47 -0
  28. package/dist/__tests__/plugin/virtual/components.test.js.map +1 -0
  29. package/dist/__tests__/plugin/virtual/composables.test.d.ts +2 -0
  30. package/dist/__tests__/plugin/virtual/composables.test.d.ts.map +1 -0
  31. package/dist/__tests__/plugin/virtual/composables.test.js +48 -0
  32. package/dist/__tests__/plugin/virtual/composables.test.js.map +1 -0
  33. package/dist/__tests__/plugin/virtual/layouts.test.d.ts +2 -0
  34. package/dist/__tests__/plugin/virtual/layouts.test.d.ts.map +1 -0
  35. package/dist/__tests__/plugin/virtual/layouts.test.js +59 -0
  36. package/dist/__tests__/plugin/virtual/layouts.test.js.map +1 -0
  37. package/dist/__tests__/plugin/virtual/middleware.test.d.ts +2 -0
  38. package/dist/__tests__/plugin/virtual/middleware.test.d.ts.map +1 -0
  39. package/dist/__tests__/plugin/virtual/middleware.test.js +58 -0
  40. package/dist/__tests__/plugin/virtual/middleware.test.js.map +1 -0
  41. package/dist/__tests__/plugin/virtual/plugins.test.d.ts +2 -0
  42. package/dist/__tests__/plugin/virtual/plugins.test.d.ts.map +1 -0
  43. package/dist/__tests__/plugin/virtual/plugins.test.js +73 -0
  44. package/dist/__tests__/plugin/virtual/plugins.test.js.map +1 -0
  45. package/dist/__tests__/plugin/virtual/routes.test.d.ts +2 -0
  46. package/dist/__tests__/plugin/virtual/routes.test.d.ts.map +1 -0
  47. package/dist/__tests__/plugin/virtual/routes.test.js +167 -0
  48. package/dist/__tests__/plugin/virtual/routes.test.js.map +1 -0
  49. package/dist/__tests__/plugin/virtual/server-api.test.d.ts +2 -0
  50. package/dist/__tests__/plugin/virtual/server-api.test.d.ts.map +1 -0
  51. package/dist/__tests__/plugin/virtual/server-api.test.js +72 -0
  52. package/dist/__tests__/plugin/virtual/server-api.test.js.map +1 -0
  53. package/dist/__tests__/runtime/use-head.test.d.ts +2 -0
  54. package/dist/__tests__/runtime/use-head.test.d.ts.map +1 -0
  55. package/dist/__tests__/runtime/use-head.test.js +202 -0
  56. package/dist/__tests__/runtime/use-head.test.js.map +1 -0
  57. package/dist/__tests__/runtime/use-page-data.test.d.ts +2 -0
  58. package/dist/__tests__/runtime/use-page-data.test.d.ts.map +1 -0
  59. package/dist/__tests__/runtime/use-page-data.test.js +41 -0
  60. package/dist/__tests__/runtime/use-page-data.test.js.map +1 -0
  61. package/dist/cli/commands/build.d.ts +3 -0
  62. package/dist/cli/commands/build.d.ts.map +1 -0
  63. package/dist/cli/commands/build.js +103 -0
  64. package/dist/cli/commands/build.js.map +1 -0
  65. package/dist/cli/commands/dev.d.ts +3 -0
  66. package/dist/cli/commands/dev.d.ts.map +1 -0
  67. package/dist/cli/commands/dev.js +92 -0
  68. package/dist/cli/commands/dev.js.map +1 -0
  69. package/dist/cli/commands/generate.d.ts +7 -0
  70. package/dist/cli/commands/generate.d.ts.map +1 -0
  71. package/dist/cli/commands/generate.js +72 -0
  72. package/dist/cli/commands/generate.js.map +1 -0
  73. package/dist/cli/commands/preview.d.ts +3 -0
  74. package/dist/cli/commands/preview.d.ts.map +1 -0
  75. package/dist/cli/commands/preview.js +191 -0
  76. package/dist/cli/commands/preview.js.map +1 -0
  77. package/dist/cli/create/index.d.ts +3 -0
  78. package/dist/cli/create/index.d.ts.map +1 -0
  79. package/dist/cli/create/index.js +184 -0
  80. package/dist/cli/create/index.js.map +1 -0
  81. package/dist/cli/index.d.ts +3 -0
  82. package/dist/cli/index.d.ts.map +1 -0
  83. package/dist/cli/index.js +17 -0
  84. package/dist/cli/index.js.map +1 -0
  85. package/dist/index.d.ts +9 -0
  86. package/dist/index.d.ts.map +1 -0
  87. package/dist/index.js +4 -0
  88. package/dist/index.js.map +1 -0
  89. package/dist/plugin/build-ssg.d.ts +12 -0
  90. package/dist/plugin/build-ssg.d.ts.map +1 -0
  91. package/dist/plugin/build-ssg.js +212 -0
  92. package/dist/plugin/build-ssg.js.map +1 -0
  93. package/dist/plugin/build-ssr.d.ts +10 -0
  94. package/dist/plugin/build-ssr.d.ts.map +1 -0
  95. package/dist/plugin/build-ssr.js +139 -0
  96. package/dist/plugin/build-ssr.js.map +1 -0
  97. package/dist/plugin/dev-server.d.ts +46 -0
  98. package/dist/plugin/dev-server.d.ts.map +1 -0
  99. package/dist/plugin/dev-server.js +194 -0
  100. package/dist/plugin/dev-server.js.map +1 -0
  101. package/dist/plugin/dts-generator.d.ts +27 -0
  102. package/dist/plugin/dts-generator.d.ts.map +1 -0
  103. package/dist/plugin/dts-generator.js +180 -0
  104. package/dist/plugin/dts-generator.js.map +1 -0
  105. package/dist/plugin/index.d.ts +13 -0
  106. package/dist/plugin/index.d.ts.map +1 -0
  107. package/dist/plugin/index.js +298 -0
  108. package/dist/plugin/index.js.map +1 -0
  109. package/dist/plugin/path-utils.d.ts +57 -0
  110. package/dist/plugin/path-utils.d.ts.map +1 -0
  111. package/dist/plugin/path-utils.js +160 -0
  112. package/dist/plugin/path-utils.js.map +1 -0
  113. package/dist/plugin/scanner.d.ts +17 -0
  114. package/dist/plugin/scanner.d.ts.map +1 -0
  115. package/dist/plugin/scanner.js +54 -0
  116. package/dist/plugin/scanner.js.map +1 -0
  117. package/dist/plugin/transforms/auto-import.d.ts +14 -0
  118. package/dist/plugin/transforms/auto-import.d.ts.map +1 -0
  119. package/dist/plugin/transforms/auto-import.js +154 -0
  120. package/dist/plugin/transforms/auto-import.js.map +1 -0
  121. package/dist/plugin/transforms/head-inject.d.ts +29 -0
  122. package/dist/plugin/transforms/head-inject.d.ts.map +1 -0
  123. package/dist/plugin/transforms/head-inject.js +127 -0
  124. package/dist/plugin/transforms/head-inject.js.map +1 -0
  125. package/dist/plugin/virtual/components.d.ts +6 -0
  126. package/dist/plugin/virtual/components.d.ts.map +1 -0
  127. package/dist/plugin/virtual/components.js +22 -0
  128. package/dist/plugin/virtual/components.js.map +1 -0
  129. package/dist/plugin/virtual/composables.d.ts +6 -0
  130. package/dist/plugin/virtual/composables.d.ts.map +1 -0
  131. package/dist/plugin/virtual/composables.js +22 -0
  132. package/dist/plugin/virtual/composables.js.map +1 -0
  133. package/dist/plugin/virtual/error.d.ts +13 -0
  134. package/dist/plugin/virtual/error.d.ts.map +1 -0
  135. package/dist/plugin/virtual/error.js +32 -0
  136. package/dist/plugin/virtual/error.js.map +1 -0
  137. package/dist/plugin/virtual/layouts.d.ts +6 -0
  138. package/dist/plugin/virtual/layouts.d.ts.map +1 -0
  139. package/dist/plugin/virtual/layouts.js +33 -0
  140. package/dist/plugin/virtual/layouts.js.map +1 -0
  141. package/dist/plugin/virtual/loading.d.ts +11 -0
  142. package/dist/plugin/virtual/loading.d.ts.map +1 -0
  143. package/dist/plugin/virtual/loading.js +30 -0
  144. package/dist/plugin/virtual/loading.js.map +1 -0
  145. package/dist/plugin/virtual/middleware.d.ts +6 -0
  146. package/dist/plugin/virtual/middleware.d.ts.map +1 -0
  147. package/dist/plugin/virtual/middleware.js +36 -0
  148. package/dist/plugin/virtual/middleware.js.map +1 -0
  149. package/dist/plugin/virtual/plugins.d.ts +6 -0
  150. package/dist/plugin/virtual/plugins.d.ts.map +1 -0
  151. package/dist/plugin/virtual/plugins.js +30 -0
  152. package/dist/plugin/virtual/plugins.js.map +1 -0
  153. package/dist/plugin/virtual/routes.d.ts +16 -0
  154. package/dist/plugin/virtual/routes.d.ts.map +1 -0
  155. package/dist/plugin/virtual/routes.js +131 -0
  156. package/dist/plugin/virtual/routes.js.map +1 -0
  157. package/dist/plugin/virtual/server-api.d.ts +6 -0
  158. package/dist/plugin/virtual/server-api.d.ts.map +1 -0
  159. package/dist/plugin/virtual/server-api.js +41 -0
  160. package/dist/plugin/virtual/server-api.js.map +1 -0
  161. package/dist/plugin/virtual/server-middleware.d.ts +6 -0
  162. package/dist/plugin/virtual/server-middleware.d.ts.map +1 -0
  163. package/dist/plugin/virtual/server-middleware.js +36 -0
  164. package/dist/plugin/virtual/server-middleware.js.map +1 -0
  165. package/dist/runtime/app-template.d.ts +10 -0
  166. package/dist/runtime/app-template.d.ts.map +1 -0
  167. package/dist/runtime/app-template.js +143 -0
  168. package/dist/runtime/app-template.js.map +1 -0
  169. package/dist/runtime/composables/index.d.ts +4 -0
  170. package/dist/runtime/composables/index.d.ts.map +1 -0
  171. package/dist/runtime/composables/index.js +3 -0
  172. package/dist/runtime/composables/index.js.map +1 -0
  173. package/dist/runtime/composables/use-head.d.ts +30 -0
  174. package/dist/runtime/composables/use-head.d.ts.map +1 -0
  175. package/dist/runtime/composables/use-head.js +182 -0
  176. package/dist/runtime/composables/use-head.js.map +1 -0
  177. package/dist/runtime/composables/use-page-data.d.ts +32 -0
  178. package/dist/runtime/composables/use-page-data.d.ts.map +1 -0
  179. package/dist/runtime/composables/use-page-data.js +41 -0
  180. package/dist/runtime/composables/use-page-data.js.map +1 -0
  181. package/dist/runtime/entry-client-template.d.ts +8 -0
  182. package/dist/runtime/entry-client-template.d.ts.map +1 -0
  183. package/dist/runtime/entry-client-template.js +18 -0
  184. package/dist/runtime/entry-client-template.js.map +1 -0
  185. package/dist/runtime/entry-server-template.d.ts +9 -0
  186. package/dist/runtime/entry-server-template.d.ts.map +1 -0
  187. package/dist/runtime/entry-server-template.js +72 -0
  188. package/dist/runtime/entry-server-template.js.map +1 -0
  189. package/dist/types/api.d.ts +16 -0
  190. package/dist/types/api.d.ts.map +1 -0
  191. package/dist/types/api.js +2 -0
  192. package/dist/types/api.js.map +1 -0
  193. package/dist/types/config.d.ts +32 -0
  194. package/dist/types/config.d.ts.map +1 -0
  195. package/dist/types/config.js +4 -0
  196. package/dist/types/config.js.map +1 -0
  197. package/dist/types/index.d.ts +7 -0
  198. package/dist/types/index.d.ts.map +1 -0
  199. package/dist/types/index.js +2 -0
  200. package/dist/types/index.js.map +1 -0
  201. package/dist/types/middleware.d.ts +6 -0
  202. package/dist/types/middleware.d.ts.map +1 -0
  203. package/dist/types/middleware.js +2 -0
  204. package/dist/types/middleware.js.map +1 -0
  205. package/dist/types/page.d.ts +21 -0
  206. package/dist/types/page.d.ts.map +1 -0
  207. package/dist/types/page.js +2 -0
  208. package/dist/types/page.js.map +1 -0
  209. package/dist/types/plugin.d.ts +12 -0
  210. package/dist/types/plugin.d.ts.map +1 -0
  211. package/dist/types/plugin.js +2 -0
  212. package/dist/types/plugin.js.map +1 -0
  213. package/docs/cli.md +233 -0
  214. package/docs/components.md +114 -0
  215. package/docs/composables.md +99 -0
  216. package/docs/configuration.md +270 -0
  217. package/docs/data-loading.md +165 -0
  218. package/docs/getting-started.md +235 -0
  219. package/docs/head-management.md +206 -0
  220. package/docs/layouts.md +112 -0
  221. package/docs/middleware.md +140 -0
  222. package/docs/plugins.md +138 -0
  223. package/docs/rendering-modes.md +251 -0
  224. package/docs/routing.md +180 -0
  225. package/docs/server-api.md +172 -0
  226. package/docs/testing.md +462 -0
  227. package/package.json +75 -0
  228. package/src/__tests__/plugin/path-utils.test.ts +399 -0
  229. package/src/__tests__/plugin/scanner.test.ts +172 -0
  230. package/src/__tests__/plugin/transforms/auto-import.test.ts +229 -0
  231. package/src/__tests__/plugin/transforms/head-inject.test.ts +178 -0
  232. package/src/__tests__/plugin/virtual/components.test.ts +56 -0
  233. package/src/__tests__/plugin/virtual/composables.test.ts +57 -0
  234. package/src/__tests__/plugin/virtual/layouts.test.ts +70 -0
  235. package/src/__tests__/plugin/virtual/middleware.test.ts +68 -0
  236. package/src/__tests__/plugin/virtual/plugins.test.ts +84 -0
  237. package/src/__tests__/plugin/virtual/routes.test.ts +202 -0
  238. package/src/__tests__/plugin/virtual/server-api.test.ts +85 -0
  239. package/src/__tests__/runtime/use-head.test.ts +243 -0
  240. package/src/__tests__/runtime/use-page-data.test.ts +45 -0
  241. package/src/cli/commands/build.ts +114 -0
  242. package/src/cli/commands/dev.ts +101 -0
  243. package/src/cli/commands/generate.ts +81 -0
  244. package/src/cli/commands/preview.ts +218 -0
  245. package/src/cli/create/index.ts +250 -0
  246. package/src/cli/create/templates/spa/app/app.ts.tpl +74 -0
  247. package/src/cli/create/templates/spa/app/layouts/default.ts.tpl +15 -0
  248. package/src/cli/create/templates/spa/app/pages/index.ts.tpl +8 -0
  249. package/src/cli/create/templates/spa/cer.config.ts.tpl +6 -0
  250. package/src/cli/create/templates/spa/index.html.tpl +12 -0
  251. package/src/cli/create/templates/spa/package.json.tpl +18 -0
  252. package/src/cli/create/templates/ssg/app/app.ts.tpl +74 -0
  253. package/src/cli/create/templates/ssg/app/layouts/default.ts.tpl +15 -0
  254. package/src/cli/create/templates/ssg/app/pages/index.ts.tpl +17 -0
  255. package/src/cli/create/templates/ssg/cer.config.ts.tpl +13 -0
  256. package/src/cli/create/templates/ssg/index.html.tpl +12 -0
  257. package/src/cli/create/templates/ssg/package.json.tpl +19 -0
  258. package/src/cli/create/templates/ssr/app/app.ts.tpl +74 -0
  259. package/src/cli/create/templates/ssr/app/layouts/default.ts.tpl +15 -0
  260. package/src/cli/create/templates/ssr/app/pages/index.ts.tpl +8 -0
  261. package/src/cli/create/templates/ssr/cer.config.ts.tpl +10 -0
  262. package/src/cli/create/templates/ssr/index.html.tpl +12 -0
  263. package/src/cli/create/templates/ssr/package.json.tpl +18 -0
  264. package/src/cli/index.ts +20 -0
  265. package/src/index.ts +13 -0
  266. package/src/plugin/build-ssg.ts +259 -0
  267. package/src/plugin/build-ssr.ts +147 -0
  268. package/src/plugin/dev-server.ts +266 -0
  269. package/src/plugin/dts-generator.ts +214 -0
  270. package/src/plugin/index.ts +330 -0
  271. package/src/plugin/path-utils.ts +186 -0
  272. package/src/plugin/scanner.ts +65 -0
  273. package/src/plugin/transforms/auto-import.ts +190 -0
  274. package/src/plugin/transforms/head-inject.ts +161 -0
  275. package/src/plugin/virtual/components.ts +28 -0
  276. package/src/plugin/virtual/composables.ts +28 -0
  277. package/src/plugin/virtual/error.ts +34 -0
  278. package/src/plugin/virtual/layouts.ts +41 -0
  279. package/src/plugin/virtual/loading.ts +33 -0
  280. package/src/plugin/virtual/middleware.ts +45 -0
  281. package/src/plugin/virtual/plugins.ts +36 -0
  282. package/src/plugin/virtual/routes.ts +147 -0
  283. package/src/plugin/virtual/server-api.ts +52 -0
  284. package/src/plugin/virtual/server-middleware.ts +44 -0
  285. package/src/runtime/app-template.ts +142 -0
  286. package/src/runtime/composables/index.ts +3 -0
  287. package/src/runtime/composables/use-head.ts +204 -0
  288. package/src/runtime/composables/use-page-data.ts +39 -0
  289. package/src/runtime/entry-client-template.ts +17 -0
  290. package/src/runtime/entry-server-template.ts +71 -0
  291. package/src/types/api.ts +19 -0
  292. package/src/types/config.ts +39 -0
  293. package/src/types/index.ts +6 -0
  294. package/src/types/middleware.ts +16 -0
  295. package/src/types/page.ts +29 -0
  296. package/src/types/plugin.ts +13 -0
  297. package/tsconfig.build.json +10 -0
  298. package/tsconfig.json +19 -0
  299. package/vitest.config.ts +29 -0
@@ -0,0 +1,154 @@
1
+ import MagicString from 'magic-string';
2
+ import { normalize } from 'pathe';
3
+ const RUNTIME_IMPORTS = `import { component, html, css, ref, computed, watch, watchEffect, useProps, useEmit, useOnConnected, useOnDisconnected, useOnAttributeChanged, useOnError, useStyle, useDesignTokens, useGlobalStyle, useExpose, useSlots, provide, inject, createComposable, nextTick, defineModel, getCurrentComponentContext, isReactiveState, unsafeHTML, decodeEntities, useTeleport } from '@jasonshimmy/custom-elements-runtime';`;
4
+ const DIRECTIVE_IMPORTS = `import { when, each, match, anchorBlock } from '@jasonshimmy/custom-elements-runtime/directives';`;
5
+ const FRAMEWORK_IMPORTS = `import { useHead, usePageData } from 'vite-plugin-cer-app/composables';`;
6
+ const FRAMEWORK_IDENTIFIERS = ['useHead', 'usePageData'];
7
+ const RUNTIME_IDENTIFIERS = [
8
+ 'component',
9
+ 'html',
10
+ 'css',
11
+ 'ref',
12
+ 'computed',
13
+ 'watch',
14
+ 'watchEffect',
15
+ 'useProps',
16
+ 'useEmit',
17
+ 'useOnConnected',
18
+ 'useOnDisconnected',
19
+ 'useOnAttributeChanged',
20
+ 'useOnError',
21
+ 'useStyle',
22
+ 'useDesignTokens',
23
+ 'useGlobalStyle',
24
+ 'useExpose',
25
+ 'useSlots',
26
+ 'provide',
27
+ 'inject',
28
+ 'createComposable',
29
+ 'nextTick',
30
+ 'defineModel',
31
+ 'getCurrentComponentContext',
32
+ 'isReactiveState',
33
+ 'unsafeHTML',
34
+ 'decodeEntities',
35
+ 'useTeleport',
36
+ ];
37
+ const DIRECTIVE_IDENTIFIERS = ['when', 'each', 'match', 'anchorBlock'];
38
+ /**
39
+ * Auto-import transform: injects runtime and directive imports at the top of
40
+ * files inside app/pages/, app/layouts/, or app/components/ if those
41
+ * identifiers are not already imported.
42
+ *
43
+ * Returns the transformed code string, or null if no injection was needed.
44
+ */
45
+ export function autoImportTransform(code, id, opts) {
46
+ const normalizedId = normalize(id);
47
+ const srcDir = normalize(opts.srcDir);
48
+ // Transform files inside app/pages/, app/layouts/, app/components/,
49
+ // AND special convention files directly in app/ (loading.ts, error.ts, etc.)
50
+ const isSubDir = normalizedId.startsWith(srcDir + '/pages/') ||
51
+ normalizedId.startsWith(srcDir + '/layouts/') ||
52
+ normalizedId.startsWith(srcDir + '/components/');
53
+ // Files directly in srcDir root (e.g. app/loading.ts, app/error.ts)
54
+ const isRootConventionFile = normalizedId.startsWith(srcDir + '/') &&
55
+ !normalizedId.slice(srcDir.length + 1).includes('/');
56
+ const isTargetDir = isSubDir || isRootConventionFile;
57
+ if (!isTargetDir)
58
+ return null;
59
+ // Skip virtual modules and non-ts files
60
+ if (id.startsWith('\0') || (!id.endsWith('.ts') && !id.endsWith('.js')))
61
+ return null;
62
+ const needsRuntime = isRuntimeImportNeeded(code);
63
+ const needsDirectives = isDirectiveImportNeeded(code);
64
+ const needsFramework = isFrameworkImportNeeded(code);
65
+ const composableImport = buildComposableImport(code, opts.composableExports);
66
+ if (!needsRuntime && !needsDirectives && !needsFramework && !composableImport)
67
+ return null;
68
+ const ms = new MagicString(code);
69
+ const injectLines = [];
70
+ if (needsRuntime) {
71
+ injectLines.push(RUNTIME_IMPORTS);
72
+ }
73
+ if (needsDirectives) {
74
+ injectLines.push(DIRECTIVE_IMPORTS);
75
+ }
76
+ if (needsFramework) {
77
+ injectLines.push(FRAMEWORK_IMPORTS);
78
+ }
79
+ if (composableImport) {
80
+ injectLines.push(composableImport);
81
+ }
82
+ ms.prepend(injectLines.join('\n') + '\n');
83
+ return ms.toString();
84
+ }
85
+ /**
86
+ * Checks if the file already imports runtime identifiers.
87
+ * Returns true if injection is needed (not already imported).
88
+ */
89
+ function isRuntimeImportNeeded(code) {
90
+ // If already importing from @jasonshimmy/custom-elements-runtime (not a sub-path), skip
91
+ if (code.includes("from '@jasonshimmy/custom-elements-runtime'") ||
92
+ code.includes('from "@jasonshimmy/custom-elements-runtime"')) {
93
+ return false;
94
+ }
95
+ // Check if any runtime identifiers are used in the file
96
+ return RUNTIME_IDENTIFIERS.some((id) => {
97
+ const pattern = new RegExp(`\\b${id}\\b`);
98
+ return pattern.test(code);
99
+ });
100
+ }
101
+ /**
102
+ * Builds an import statement for any composable names used in the file
103
+ * that are not already imported.
104
+ * Returns null if no injection is needed.
105
+ */
106
+ function buildComposableImport(code, composableExports) {
107
+ if (!composableExports || composableExports.size === 0)
108
+ return null;
109
+ // Skip if already importing from virtual:cer-composables
110
+ if (code.includes("from 'virtual:cer-composables'") || code.includes('from "virtual:cer-composables"')) {
111
+ return null;
112
+ }
113
+ const needed = [];
114
+ for (const name of composableExports.keys()) {
115
+ const pattern = new RegExp(`\\b${name}\\b`);
116
+ if (pattern.test(code)) {
117
+ needed.push(name);
118
+ }
119
+ }
120
+ if (needed.length === 0)
121
+ return null;
122
+ return `import { ${needed.join(', ')} } from 'virtual:cer-composables';`;
123
+ }
124
+ /**
125
+ * Checks if the file already imports framework composables (useHead, etc.).
126
+ * Returns true if injection is needed (not already imported).
127
+ */
128
+ function isFrameworkImportNeeded(code) {
129
+ if (code.includes("from 'vite-plugin-cer-app/composables'") ||
130
+ code.includes('from "vite-plugin-cer-app/composables"')) {
131
+ return false;
132
+ }
133
+ return FRAMEWORK_IDENTIFIERS.some((id) => {
134
+ const pattern = new RegExp(`\\b${id}\\b`);
135
+ return pattern.test(code);
136
+ });
137
+ }
138
+ /**
139
+ * Checks if the file already imports directive identifiers.
140
+ * Returns true if injection is needed (not already imported).
141
+ */
142
+ function isDirectiveImportNeeded(code) {
143
+ // If already importing from directives sub-path, skip
144
+ if (code.includes("from '@jasonshimmy/custom-elements-runtime/directives'") ||
145
+ code.includes('from "@jasonshimmy/custom-elements-runtime/directives"')) {
146
+ return false;
147
+ }
148
+ // Check if any directive identifiers are used in the file
149
+ return DIRECTIVE_IDENTIFIERS.some((id) => {
150
+ const pattern = new RegExp(`\\b${id}\\b`);
151
+ return pattern.test(code);
152
+ });
153
+ }
154
+ //# sourceMappingURL=auto-import.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auto-import.js","sourceRoot":"","sources":["../../../src/plugin/transforms/auto-import.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAQjC,MAAM,eAAe,GAAG,0ZAA0Z,CAAA;AAElb,MAAM,iBAAiB,GAAG,mGAAmG,CAAA;AAE7H,MAAM,iBAAiB,GAAG,yEAAyE,CAAA;AAEnG,MAAM,qBAAqB,GAAG,CAAC,SAAS,EAAE,aAAa,CAAC,CAAA;AAExD,MAAM,mBAAmB,GAAG;IAC1B,WAAW;IACX,MAAM;IACN,KAAK;IACL,KAAK;IACL,UAAU;IACV,OAAO;IACP,aAAa;IACb,UAAU;IACV,SAAS;IACT,gBAAgB;IAChB,mBAAmB;IACnB,uBAAuB;IACvB,YAAY;IACZ,UAAU;IACV,iBAAiB;IACjB,gBAAgB;IAChB,WAAW;IACX,UAAU;IACV,SAAS;IACT,QAAQ;IACR,kBAAkB;IAClB,UAAU;IACV,aAAa;IACb,4BAA4B;IAC5B,iBAAiB;IACjB,YAAY;IACZ,gBAAgB;IAChB,aAAa;CACd,CAAA;AAED,MAAM,qBAAqB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,CAAC,CAAA;AAEtE;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CACjC,IAAY,EACZ,EAAU,EACV,IAAuB;IAEvB,MAAM,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E,EAAE,EAAE;QACvC,MAAM,OAAO,GAAG,IAAI,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;QACzC,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC3B,CAAC,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,29 @@
1
+ export interface HeadTag {
2
+ tag: string;
3
+ attrs?: Record<string, string>;
4
+ innerHTML?: string;
5
+ }
6
+ export interface HeadInput {
7
+ title?: string;
8
+ meta?: Array<Record<string, string>>;
9
+ link?: Array<Record<string, string>>;
10
+ script?: Array<Record<string, string>>;
11
+ style?: Array<Record<string, string>>;
12
+ }
13
+ /**
14
+ * Inserts stringified head tags before the closing </head> tag.
15
+ * If no </head> is found, prepends to the document.
16
+ */
17
+ export declare function injectHead(html: string, headTags: HeadTag[]): string;
18
+ /**
19
+ * HeadCollector gathers HeadInput objects during SSR and serializes them
20
+ * to an HTML string for injection into the document head.
21
+ */
22
+ export declare class HeadCollector {
23
+ private readonly _collected;
24
+ collect(tags: HeadInput): void;
25
+ serialize(): string;
26
+ reset(): void;
27
+ getCollected(): HeadInput[];
28
+ }
29
+ //# sourceMappingURL=head-inject.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"head-inject.d.ts","sourceRoot":"","sources":["../../../src/plugin/transforms/head-inject.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO;IACtB,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,SAAS;IACxB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;IACpC,IAAI,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;IACpC,MAAM,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;IACtC,KAAK,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;CACtC;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,MAAM,CAYpE;AA+BD;;;GAGG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAkB;IAE7C,OAAO,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI;IAI9B,SAAS,IAAI,MAAM;IAKnB,KAAK,IAAI,IAAI;IAIb,YAAY,IAAI,SAAS,EAAE;CAG5B"}
@@ -0,0 +1,127 @@
1
+ /**
2
+ * Inserts stringified head tags before the closing </head> tag.
3
+ * If no </head> is found, prepends to the document.
4
+ */
5
+ export function injectHead(html, headTags) {
6
+ if (headTags.length === 0)
7
+ return html;
8
+ const serialized = headTags.map(serializeTag).join('\n');
9
+ const closeHeadIdx = html.indexOf('</head>');
10
+ if (closeHeadIdx !== -1) {
11
+ return html.slice(0, closeHeadIdx) + serialized + '\n' + html.slice(closeHeadIdx);
12
+ }
13
+ // No </head> found: prepend
14
+ return serialized + '\n' + html;
15
+ }
16
+ /**
17
+ * Serializes a single HeadTag to an HTML string.
18
+ */
19
+ function serializeTag(tag) {
20
+ const attrs = tag.attrs
21
+ ? Object.entries(tag.attrs)
22
+ .map(([k, v]) => (v === '' ? k : `${k}="${escapeAttr(v)}"`))
23
+ .join(' ')
24
+ : '';
25
+ const openTag = attrs ? `<${tag.tag} ${attrs}>` : `<${tag.tag}>`;
26
+ if (tag.innerHTML !== undefined) {
27
+ return `${openTag}${tag.innerHTML}</${tag.tag}>`;
28
+ }
29
+ // Self-closing for void elements
30
+ const voidTags = new Set(['meta', 'link', 'base', 'br', 'hr', 'img', 'input']);
31
+ if (voidTags.has(tag.tag)) {
32
+ return attrs ? `<${tag.tag} ${attrs}>` : `<${tag.tag}>`;
33
+ }
34
+ return `${openTag}</${tag.tag}>`;
35
+ }
36
+ function escapeAttr(value) {
37
+ return value.replace(/&/g, '&amp;').replace(/"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
38
+ }
39
+ /**
40
+ * HeadCollector gathers HeadInput objects during SSR and serializes them
41
+ * to an HTML string for injection into the document head.
42
+ */
43
+ export class HeadCollector {
44
+ _collected = [];
45
+ collect(tags) {
46
+ this._collected.push(tags);
47
+ }
48
+ serialize() {
49
+ const tags = headInputToTags(this._collected);
50
+ return tags.map(serializeTag).join('\n');
51
+ }
52
+ reset() {
53
+ this._collected.length = 0;
54
+ }
55
+ getCollected() {
56
+ return [...this._collected];
57
+ }
58
+ }
59
+ /**
60
+ * Converts an array of HeadInput objects to a flat array of HeadTags.
61
+ * Later entries override earlier ones for title; meta/link/script/style are merged.
62
+ */
63
+ function headInputToTags(inputs) {
64
+ const tags = [];
65
+ // Collect title — last one wins
66
+ let title;
67
+ for (const input of inputs) {
68
+ if (input.title !== undefined) {
69
+ title = input.title;
70
+ }
71
+ }
72
+ if (title !== undefined) {
73
+ tags.push({ tag: 'title', innerHTML: escapeHtml(title) });
74
+ }
75
+ // Collect meta tags (deduplicate by name/property)
76
+ const metaMap = new Map();
77
+ for (const input of inputs) {
78
+ if (input.meta) {
79
+ for (const meta of input.meta) {
80
+ const key = meta.name ?? meta.property ?? meta.charset ?? JSON.stringify(meta);
81
+ metaMap.set(key, meta);
82
+ }
83
+ }
84
+ }
85
+ for (const attrs of metaMap.values()) {
86
+ tags.push({ tag: 'meta', attrs });
87
+ }
88
+ // Collect link tags (deduplicate by rel+href)
89
+ const linkMap = new Map();
90
+ for (const input of inputs) {
91
+ if (input.link) {
92
+ for (const link of input.link) {
93
+ const key = `${link.rel ?? ''}:${link.href ?? ''}`;
94
+ linkMap.set(key, link);
95
+ }
96
+ }
97
+ }
98
+ for (const attrs of linkMap.values()) {
99
+ tags.push({ tag: 'link', attrs });
100
+ }
101
+ // Collect script tags
102
+ for (const input of inputs) {
103
+ if (input.script) {
104
+ for (const script of input.script) {
105
+ const { innerHTML, ...attrs } = script;
106
+ tags.push({ tag: 'script', attrs, innerHTML });
107
+ }
108
+ }
109
+ }
110
+ // Collect style tags
111
+ for (const input of inputs) {
112
+ if (input.style) {
113
+ for (const style of input.style) {
114
+ const { innerHTML, ...attrs } = style;
115
+ tags.push({ tag: 'style', attrs, innerHTML });
116
+ }
117
+ }
118
+ }
119
+ return tags;
120
+ }
121
+ function escapeHtml(str) {
122
+ return str
123
+ .replace(/&/g, '&amp;')
124
+ .replace(/</g, '&lt;')
125
+ .replace(/>/g, '&gt;');
126
+ }
127
+ //# sourceMappingURL=head-inject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"head-inject.js","sourceRoot":"","sources":["../../../src/plugin/transforms/head-inject.ts"],"names":[],"mappings":"AAcA;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,IAAY,EAAE,QAAmB;IAC1D,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAA;IAEtC,MAAM,UAAU,GAAG,QAAQ,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAExD,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;IAC5C,IAAI,YAAY,KAAK,CAAC,CAAC,EAAE,CAAC;QACxB,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,YAAY,CAAC,GAAG,UAAU,GAAG,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAA;IACnF,CAAC;IAED,4BAA4B;IAC5B,OAAO,UAAU,GAAG,IAAI,GAAG,IAAI,CAAA;AACjC,CAAC;AAED;;GAEG;AACH,SAAS,YAAY,CAAC,GAAY;IAChC,MAAM,KAAK,GAAG,GAAG,CAA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AAA;gBAChE,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAA;YAChD,CAAC;QACH,CAAC;IACH,CAAC;IAED,qBAAqB;IACrB,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;YAChB,KAAK,MAAM,KAAK,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;gBAChC,MAAM,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,GAAG,KAA+B,CAAA;gBAC/D,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAA;YAC/C,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC;AAED,SAAS,UAAU,CAAC,GAAW;IAC7B,OAAO,GAAG;SACP,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;SACtB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;AAC1B,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Generates the virtual:cer-components module code.
3
+ * Scans app/components/ and produces side-effect imports for registration.
4
+ */
5
+ export declare function generateComponentsCode(componentsDir: string): Promise<string>;
6
+ //# sourceMappingURL=components.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../../src/plugin/virtual/components.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,wBAAsB,sBAAsB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAoBnF"}
@@ -0,0 +1,22 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { scanDirectory } from '../scanner.js';
3
+ /**
4
+ * Generates the virtual:cer-components module code.
5
+ * Scans app/components/ and produces side-effect imports for registration.
6
+ */
7
+ export async function generateComponentsCode(componentsDir) {
8
+ if (!existsSync(componentsDir)) {
9
+ return `// AUTO-GENERATED by vite-plugin-cer-app\n// No components directory found\n`;
10
+ }
11
+ const files = await scanDirectory('**/*.ts', componentsDir);
12
+ if (files.length === 0) {
13
+ return `// AUTO-GENERATED by vite-plugin-cer-app\n// No components found\n`;
14
+ }
15
+ const lines = ['// AUTO-GENERATED by vite-plugin-cer-app', ''];
16
+ for (const file of files) {
17
+ lines.push(`import ${JSON.stringify(file)}`);
18
+ }
19
+ lines.push('');
20
+ return lines.join('\n');
21
+ }
22
+ //# sourceMappingURL=components.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"components.js","sourceRoot":"","sources":["../../../src/plugin/virtual/components.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAE7C;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,aAAqB;IAChE,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,CAAC;QAC/B,OAAO,8EAA8E,CAAA;IACvF,CAAC;IAED,MAAM,KAAK,GAAG,MAAM,aAAa,CAAC,SAAS,EAAE,aAAa,CAAC,CAAA;IAE3D,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,oEAAoE,CAAA;IAC7E,CAAC;IAED,MAAM,KAAK,GAAa,CAAC,0CAA0C,EAAE,EAAE,CAAC,CAAA;IAExE,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,KAAK,CAAC,IAAI,CAAC,UAAU,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAC9C,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAEd,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACzB,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Generates the virtual:cer-composables module code.
3
+ * Scans app/composables/ and re-exports all composable functions.
4
+ */
5
+ export declare function generateComposablesCode(composablesDir: string): Promise<string>;
6
+ //# sourceMappingURL=composables.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"composables.d.ts","sourceRoot":"","sources":["../../../src/plugin/virtual/composables.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,wBAAsB,uBAAuB,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAoBrF"}
@@ -0,0 +1,22 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { scanDirectory } from '../scanner.js';
3
+ /**
4
+ * Generates the virtual:cer-composables module code.
5
+ * Scans app/composables/ and re-exports all composable functions.
6
+ */
7
+ export async function generateComposablesCode(composablesDir) {
8
+ if (!existsSync(composablesDir)) {
9
+ return `// AUTO-GENERATED by vite-plugin-cer-app\n// No composables directory found\n`;
10
+ }
11
+ const files = await scanDirectory('**/*.ts', composablesDir);
12
+ if (files.length === 0) {
13
+ return `// AUTO-GENERATED by vite-plugin-cer-app\n// No composables found\n`;
14
+ }
15
+ const lines = ['// AUTO-GENERATED by vite-plugin-cer-app', ''];
16
+ for (const file of files) {
17
+ lines.push(`export * from ${JSON.stringify(file)}`);
18
+ }
19
+ lines.push('');
20
+ return lines.join('\n');
21
+ }
22
+ //# sourceMappingURL=composables.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"composables.js","sourceRoot":"","sources":["../../../src/plugin/virtual/composables.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAE7C;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,cAAsB;IAClE,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,EAAE,CAAC;QAChC,OAAO,+EAA+E,CAAA;IACxF,CAAC;IAED,MAAM,KAAK,GAAG,MAAM,aAAa,CAAC,SAAS,EAAE,cAAc,CAAC,CAAA;IAE5D,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,qEAAqE,CAAA;IAC9E,CAAC;IAED,MAAM,KAAK,GAAa,CAAC,0CAA0C,EAAE,EAAE,CAAC,CAAA;IAExE,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,KAAK,CAAC,IAAI,CAAC,iBAAiB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACrD,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAEd,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACzB,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Generates the virtual:cer-error module code.
3
+ *
4
+ * If app/error.ts exists the module exports:
5
+ * hasError = true
6
+ * errorTag = 'page-error'
7
+ *
8
+ * The page-error component receives an `error` attribute (stringified message)
9
+ * and a `reset` attribute (set to "true" to signal the reset handler).
10
+ * The bootstrap wires `resetError()` as a global so the component can call it.
11
+ */
12
+ export declare function generateErrorCode(srcDir: string): Promise<string>;
13
+ //# sourceMappingURL=error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../../src/plugin/virtual/error.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;GAUG;AACH,wBAAsB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAmBvE"}
@@ -0,0 +1,32 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { join } from 'pathe';
3
+ /**
4
+ * Generates the virtual:cer-error module code.
5
+ *
6
+ * If app/error.ts exists the module exports:
7
+ * hasError = true
8
+ * errorTag = 'page-error'
9
+ *
10
+ * The page-error component receives an `error` attribute (stringified message)
11
+ * and a `reset` attribute (set to "true" to signal the reset handler).
12
+ * The bootstrap wires `resetError()` as a global so the component can call it.
13
+ */
14
+ export async function generateErrorCode(srcDir) {
15
+ const errorFile = join(srcDir, 'error.ts');
16
+ if (!existsSync(errorFile)) {
17
+ return [
18
+ '// AUTO-GENERATED by vite-plugin-cer-app',
19
+ 'export const hasError = false',
20
+ 'export const errorTag = null',
21
+ '',
22
+ ].join('\n');
23
+ }
24
+ return [
25
+ '// AUTO-GENERATED by vite-plugin-cer-app',
26
+ `import ${JSON.stringify(errorFile)}`,
27
+ 'export const hasError = true',
28
+ "export const errorTag = 'page-error'",
29
+ '',
30
+ ].join('\n');
31
+ }
32
+ //# sourceMappingURL=error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.js","sourceRoot":"","sources":["../../../src/plugin/virtual/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AAE5B;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,MAAc;IACpD,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;IAE1C,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QAC3B,OAAO;YACL,0CAA0C;YAC1C,+BAA+B;YAC/B,8BAA8B;YAC9B,EAAE;SACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACd,CAAC;IAED,OAAO;QACL,0CAA0C;QAC1C,UAAU,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE;QACrC,8BAA8B;QAC9B,sCAAsC;QACtC,EAAE;KACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACd,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Generates the virtual:cer-layouts module code.
3
+ * Scans app/layouts/ and produces a layouts map.
4
+ */
5
+ export declare function generateLayoutsCode(layoutsDir: string): Promise<string>;
6
+ //# sourceMappingURL=layouts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layouts.d.ts","sourceRoot":"","sources":["../../../src/plugin/virtual/layouts.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,wBAAsB,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAgC7E"}
@@ -0,0 +1,33 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { scanDirectory } from '../scanner.js';
3
+ import { fileToLayoutName, fileToLayoutTagName } from '../path-utils.js';
4
+ /**
5
+ * Generates the virtual:cer-layouts module code.
6
+ * Scans app/layouts/ and produces a layouts map.
7
+ */
8
+ export async function generateLayoutsCode(layoutsDir) {
9
+ if (!existsSync(layoutsDir)) {
10
+ return `// AUTO-GENERATED by vite-plugin-cer-app\nexport const layouts = {}\nexport default layouts\n`;
11
+ }
12
+ const files = await scanDirectory('**/*.ts', layoutsDir);
13
+ if (files.length === 0) {
14
+ return `// AUTO-GENERATED by vite-plugin-cer-app\nexport const layouts = {}\nexport default layouts\n`;
15
+ }
16
+ const lines = ['// AUTO-GENERATED by vite-plugin-cer-app', ''];
17
+ // Side-effect imports to register the layout custom elements
18
+ for (const file of files) {
19
+ lines.push(`import ${JSON.stringify(file)}`);
20
+ }
21
+ lines.push('');
22
+ lines.push('export const layouts = {');
23
+ for (const file of files) {
24
+ const name = fileToLayoutName(file, layoutsDir);
25
+ const tagName = fileToLayoutTagName(file, layoutsDir);
26
+ lines.push(` ${JSON.stringify(name)}: ${JSON.stringify(tagName)},`);
27
+ }
28
+ lines.push('}');
29
+ lines.push('export default layouts');
30
+ lines.push('');
31
+ return lines.join('\n');
32
+ }
33
+ //# sourceMappingURL=layouts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layouts.js","sourceRoot":"","sources":["../../../src/plugin/virtual/layouts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EA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,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACzB,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Generates the virtual:cer-loading module code.
3
+ *
4
+ * If app/loading.ts exists the module exports:
5
+ * hasLoading = true
6
+ * loadingTag = 'page-loading'
7
+ *
8
+ * Otherwise both are falsy so the bootstrap skips the loading indicator.
9
+ */
10
+ export declare function generateLoadingCode(srcDir: string): Promise<string>;
11
+ //# sourceMappingURL=loading.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loading.d.ts","sourceRoot":"","sources":["../../../src/plugin/virtual/loading.ts"],"names":[],"mappings":"AAIA;;;;;;;;GAQG;AACH,wBAAsB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAmBzE"}
@@ -0,0 +1,30 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { join } from 'pathe';
3
+ /**
4
+ * Generates the virtual:cer-loading module code.
5
+ *
6
+ * If app/loading.ts exists the module exports:
7
+ * hasLoading = true
8
+ * loadingTag = 'page-loading'
9
+ *
10
+ * Otherwise both are falsy so the bootstrap skips the loading indicator.
11
+ */
12
+ export async function generateLoadingCode(srcDir) {
13
+ const loadingFile = join(srcDir, 'loading.ts');
14
+ if (!existsSync(loadingFile)) {
15
+ return [
16
+ '// AUTO-GENERATED by vite-plugin-cer-app',
17
+ 'export const hasLoading = false',
18
+ 'export const loadingTag = null',
19
+ '',
20
+ ].join('\n');
21
+ }
22
+ return [
23
+ '// AUTO-GENERATED by vite-plugin-cer-app',
24
+ `import ${JSON.stringify(loadingFile)}`,
25
+ 'export const hasLoading = true',
26
+ "export const loadingTag = 'page-loading'",
27
+ '',
28
+ ].join('\n');
29
+ }
30
+ //# sourceMappingURL=loading.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loading.js","sourceRoot":"","sources":["../../../src/plugin/virtual/loading.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AAG5B;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,MAAc;IACtD,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,EAAE,YAAY,CAAC,CAAA;IAE9C,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;QAC7B,OAAO;YACL,0CAA0C;YAC1C,iCAAiC;YACjC,gCAAgC;YAChC,EAAE;SACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACd,CAAC;IAED,OAAO;QACL,0CAA0C;QAC1C,UAAU,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE;QACvC,gCAAgC;QAChC,0CAA0C;QAC1C,EAAE;KACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACd,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Generates the virtual:cer-middleware module code.
3
+ * Scans app/middleware/ and produces a named map of middleware functions.
4
+ */
5
+ export declare function generateMiddlewareCode(middlewareDir: string): Promise<string>;
6
+ //# sourceMappingURL=middleware.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../../src/plugin/virtual/middleware.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,wBAAsB,sBAAsB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAoCnF"}
@@ -0,0 +1,36 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { basename } from 'pathe';
3
+ import { scanDirectory } from '../scanner.js';
4
+ /**
5
+ * Generates the virtual:cer-middleware module code.
6
+ * Scans app/middleware/ and produces a named map of middleware functions.
7
+ */
8
+ export async function generateMiddlewareCode(middlewareDir) {
9
+ if (!existsSync(middlewareDir)) {
10
+ return `// AUTO-GENERATED by vite-plugin-cer-app\nexport const middleware = {}\nexport default middleware\n`;
11
+ }
12
+ const files = await scanDirectory('**/*.ts', middlewareDir);
13
+ if (files.length === 0) {
14
+ return `// AUTO-GENERATED by vite-plugin-cer-app\nexport const middleware = {}\nexport default middleware\n`;
15
+ }
16
+ const lines = ['// AUTO-GENERATED by vite-plugin-cer-app', ''];
17
+ const entries = [];
18
+ for (const file of files) {
19
+ // Key is the filename without extension
20
+ const name = basename(file).replace(/\.[jt]s$/, '');
21
+ // Create a safe JS identifier
22
+ const alias = `_m_${name.replace(/[^a-zA-Z0-9_]/g, '_').replace(/^(\d)/, '_$1')}`;
23
+ entries.push({ alias, name });
24
+ lines.push(`import ${alias} from ${JSON.stringify(file)}`);
25
+ }
26
+ lines.push('');
27
+ lines.push('export const middleware = {');
28
+ for (const { alias, name } of entries) {
29
+ lines.push(` ${JSON.stringify(name)}: ${alias},`);
30
+ }
31
+ lines.push('}');
32
+ lines.push('export default middleware');
33
+ lines.push('');
34
+ return lines.join('\n');
35
+ }
36
+ //# sourceMappingURL=middleware.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../../src/plugin/virtual/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAE7C;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,aAAqB;IAChE,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,CAAC;QAC/B,OAAO,qGAAqG,CAAA;IAC9G,CAAC;IAED,MAAM,KAAK,GAAG,MAAM,aAAa,CAAC,SAAS,EAAE,aAAa,CAAC,CAAA;IAE3D,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,qGAAqG,CAAA;IAC9G,CAAC;IAED,MAAM,KAAK,GAAa,CAAC,0CAA0C,EAAE,EAAE,CAAC,CAAA;IAExE,MAAM,OAAO,GAA2C,EAAE,CAAA;IAE1D,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,wCAAwC;QACxC,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAA;QACnD,8BAA8B;QAC9B,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,CAAA;QACjF,OAAO,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;QAC7B,KAAK,CAAC,IAAI,CAAC,UAAU,KAAK,SAAS,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAC5D,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACd,KAAK,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAA;IAEzC,KAAK,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,OAAO,EAAE,CAAC;QACtC,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,KAAK,GAAG,CAAC,CAAA;IACpD,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACf,KAAK,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAA;IACvC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAEd,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACzB,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Generates the virtual:cer-plugins module code.
3
+ * Scans app/plugins/ and produces an ordered array of plugin imports.
4
+ */
5
+ export declare function generatePluginsCode(pluginsDir: string): Promise<string>;
6
+ //# sourceMappingURL=plugins.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugins.d.ts","sourceRoot":"","sources":["../../../src/plugin/virtual/plugins.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,wBAAsB,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CA2B7E"}