@origen-ui/admin-cli 1.0.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 (430) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +17 -0
  3. package/bin/og-admin.mjs +131 -0
  4. package/package.json +28 -0
  5. package/templates/current/clean/.codebuddy/AGENTS.md +18 -0
  6. package/templates/current/clean/.codebuddy/rules/01-feature-architecture.md +12 -0
  7. package/templates/current/clean/.codebuddy/rules/02-vue-typescript.md +12 -0
  8. package/templates/current/clean/.codebuddy/rules/03-component-policy.md +30 -0
  9. package/templates/current/clean/.codebuddy/rules/04-api-auth-router.md +12 -0
  10. package/templates/current/clean/.codebuddy/rules/05-style.md +12 -0
  11. package/templates/current/clean/.codebuddy/rules/06-quality.md +12 -0
  12. package/templates/current/clean/.codebuddy/skills/build-admin-feature/SKILL.md +17 -0
  13. package/templates/current/clean/.codebuddy/skills/style-og-origen-ui/SKILL.md +14 -0
  14. package/templates/current/clean/.codebuddy/skills/use-og-dialog/SKILL.md +15 -0
  15. package/templates/current/clean/.codebuddy/skills/use-og-editor/SKILL.md +28 -0
  16. package/templates/current/clean/.codebuddy/skills/use-og-form/SKILL.md +15 -0
  17. package/templates/current/clean/.codebuddy/skills/use-og-form-table/SKILL.md +28 -0
  18. package/templates/current/clean/.codebuddy/skills/use-og-http/SKILL.md +16 -0
  19. package/templates/current/clean/.codebuddy/skills/use-og-router-tabs/SKILL.md +14 -0
  20. package/templates/current/clean/.codebuddy/skills/use-og-search/SKILL.md +17 -0
  21. package/templates/current/clean/.codebuddy/skills/use-og-table/SKILL.md +19 -0
  22. package/templates/current/clean/.codebuddy/skills/use-og-upload/SKILL.md +28 -0
  23. package/templates/current/clean/.codex/AGENTS.md +15 -0
  24. package/templates/current/clean/.codex/rules/01-feature-architecture.md +6 -0
  25. package/templates/current/clean/.codex/rules/02-vue-typescript.md +6 -0
  26. package/templates/current/clean/.codex/rules/03-component-policy.md +24 -0
  27. package/templates/current/clean/.codex/rules/04-api-auth-router.md +6 -0
  28. package/templates/current/clean/.codex/rules/05-style.md +6 -0
  29. package/templates/current/clean/.codex/rules/06-quality.md +6 -0
  30. package/templates/current/clean/.codex/skills/build-admin-feature/SKILL.md +14 -0
  31. package/templates/current/clean/.codex/skills/build-admin-feature/references/component-selection.md +25 -0
  32. package/templates/current/clean/.codex/skills/style-og-origen-ui/SKILL.md +11 -0
  33. package/templates/current/clean/.codex/skills/style-og-origen-ui/agents/openai.yaml +4 -0
  34. package/templates/current/clean/.codex/skills/use-og-dialog/SKILL.md +12 -0
  35. package/templates/current/clean/.codex/skills/use-og-dialog/agents/openai.yaml +4 -0
  36. package/templates/current/clean/.codex/skills/use-og-editor/SKILL.md +25 -0
  37. package/templates/current/clean/.codex/skills/use-og-form/SKILL.md +12 -0
  38. package/templates/current/clean/.codex/skills/use-og-form-table/SKILL.md +25 -0
  39. package/templates/current/clean/.codex/skills/use-og-http/SKILL.md +13 -0
  40. package/templates/current/clean/.codex/skills/use-og-http/agents/openai.yaml +4 -0
  41. package/templates/current/clean/.codex/skills/use-og-router-tabs/SKILL.md +11 -0
  42. package/templates/current/clean/.codex/skills/use-og-search/SKILL.md +14 -0
  43. package/templates/current/clean/.codex/skills/use-og-table/SKILL.md +16 -0
  44. package/templates/current/clean/.codex/skills/use-og-upload/SKILL.md +25 -0
  45. package/templates/current/clean/.cursor/AGENTS.md +18 -0
  46. package/templates/current/clean/.cursor/rules/01-feature-architecture.mdc +12 -0
  47. package/templates/current/clean/.cursor/rules/02-vue-typescript.mdc +12 -0
  48. package/templates/current/clean/.cursor/rules/03-component-policy.mdc +30 -0
  49. package/templates/current/clean/.cursor/rules/04-api-auth-router.mdc +12 -0
  50. package/templates/current/clean/.cursor/rules/05-style.mdc +12 -0
  51. package/templates/current/clean/.cursor/rules/06-quality.mdc +12 -0
  52. package/templates/current/clean/.cursor/skills/build-admin-feature/SKILL.md +14 -0
  53. package/templates/current/clean/.cursor/skills/style-og-origen-ui/SKILL.md +11 -0
  54. package/templates/current/clean/.cursor/skills/use-og-dialog/SKILL.md +12 -0
  55. package/templates/current/clean/.cursor/skills/use-og-editor/SKILL.md +25 -0
  56. package/templates/current/clean/.cursor/skills/use-og-form/SKILL.md +12 -0
  57. package/templates/current/clean/.cursor/skills/use-og-form-table/SKILL.md +25 -0
  58. package/templates/current/clean/.cursor/skills/use-og-http/SKILL.md +13 -0
  59. package/templates/current/clean/.cursor/skills/use-og-router-tabs/SKILL.md +11 -0
  60. package/templates/current/clean/.cursor/skills/use-og-search/SKILL.md +14 -0
  61. package/templates/current/clean/.cursor/skills/use-og-table/SKILL.md +16 -0
  62. package/templates/current/clean/.cursor/skills/use-og-upload/SKILL.md +25 -0
  63. package/templates/current/clean/.env.example +7 -0
  64. package/templates/current/clean/.env.production.example +31 -0
  65. package/templates/current/clean/.qoder/AGENTS.md +15 -0
  66. package/templates/current/clean/.qoder/rules/01-feature-architecture.md +12 -0
  67. package/templates/current/clean/.qoder/rules/02-vue-typescript.md +12 -0
  68. package/templates/current/clean/.qoder/rules/03-component-policy.md +30 -0
  69. package/templates/current/clean/.qoder/rules/04-api-auth-router.md +12 -0
  70. package/templates/current/clean/.qoder/rules/05-style.md +12 -0
  71. package/templates/current/clean/.qoder/rules/06-quality.md +12 -0
  72. package/templates/current/clean/.qoder/skills/build-admin-feature/SKILL.md +14 -0
  73. package/templates/current/clean/.qoder/skills/style-og-origen-ui/SKILL.md +11 -0
  74. package/templates/current/clean/.qoder/skills/use-og-dialog/SKILL.md +12 -0
  75. package/templates/current/clean/.qoder/skills/use-og-editor/SKILL.md +25 -0
  76. package/templates/current/clean/.qoder/skills/use-og-form/SKILL.md +12 -0
  77. package/templates/current/clean/.qoder/skills/use-og-form-table/SKILL.md +25 -0
  78. package/templates/current/clean/.qoder/skills/use-og-http/SKILL.md +13 -0
  79. package/templates/current/clean/.qoder/skills/use-og-router-tabs/SKILL.md +11 -0
  80. package/templates/current/clean/.qoder/skills/use-og-search/SKILL.md +14 -0
  81. package/templates/current/clean/.qoder/skills/use-og-table/SKILL.md +16 -0
  82. package/templates/current/clean/.qoder/skills/use-og-upload/SKILL.md +25 -0
  83. package/templates/current/clean/AGENTS.md +16 -0
  84. package/templates/current/clean/README.md +116 -0
  85. package/templates/current/clean/component-catalog.json +765 -0
  86. package/templates/current/clean/e2e/admin-shell.spec.ts +150 -0
  87. package/templates/current/clean/e2e/demo-shell.spec.ts +328 -0
  88. package/templates/current/clean/evals/component-selection.json +29 -0
  89. package/templates/current/clean/gitignore +3 -0
  90. package/templates/current/clean/index.html +13 -0
  91. package/templates/current/clean/openapi.json +1623 -0
  92. package/templates/current/clean/package.json +65 -0
  93. package/templates/current/clean/playwright.config.ts +31 -0
  94. package/templates/current/clean/playwright.demo.config.ts +25 -0
  95. package/templates/current/clean/recipes/README.md +7 -0
  96. package/templates/current/clean/recipes/remote-crud-dialog-form.json +15 -0
  97. package/templates/current/clean/recipes/remote-crud-dialog-form.vue +66 -0
  98. package/templates/current/clean/scaffold.lock.json +12 -0
  99. package/templates/current/clean/scripts/check-admin-bundle.mjs +214 -0
  100. package/templates/current/clean/scripts/check-admin-scaffold.mjs +168 -0
  101. package/templates/current/clean/scripts/clean-overlay/src/features/errors/pages/Forbidden.vue +26 -0
  102. package/templates/current/clean/scripts/clean-overlay/src/features/errors/pages/NotFound.vue +26 -0
  103. package/templates/current/clean/scripts/clean-overlay/src/features/errors/pages/ServerError.vue +26 -0
  104. package/templates/current/clean/scripts/clean-overlay/src/features/errors/pages/error-pages.spec.ts +32 -0
  105. package/templates/current/clean/scripts/clean-overlay/src/main.ts +91 -0
  106. package/templates/current/clean/scripts/clean-overlay/src/router/componentRegistry.ts +25 -0
  107. package/templates/current/clean/scripts/clean-overlay/src/router/dynamicRoutes.spec.ts +47 -0
  108. package/templates/current/clean/scripts/clean-overlay/src/router/staticRoutes.ts +63 -0
  109. package/templates/current/clean/scripts/demo-api.ts +797 -0
  110. package/templates/current/clean/scripts/generate-api.ts +27 -0
  111. package/templates/current/clean/scripts/performance/baselines/bundle-gzip-v2-pre-entry-unification.json +38 -0
  112. package/templates/current/clean/scripts/remove-examples.mjs +54 -0
  113. package/templates/current/clean/src/App.vue +67 -0
  114. package/templates/current/clean/src/api/client.spec.ts +66 -0
  115. package/templates/current/clean/src/api/client.ts +72 -0
  116. package/templates/current/clean/src/api/generated/data-contracts.ts +268 -0
  117. package/templates/current/clean/src/api/generated/http-client.ts +266 -0
  118. package/templates/current/clean/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/345/206/205/345/256/271/346/226/207/347/253/240.ts +147 -0
  119. package/templates/current/clean/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/345/256/241/350/256/241.ts +53 -0
  120. package/templates/current/clean/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/346/226/207/344/273/266/344/270/212/344/274/240.ts +66 -0
  121. package/templates/current/clean/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/347/224/250/346/210/267.ts +171 -0
  122. package/templates/current/clean/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/350/217/234/345/215/225.ts +181 -0
  123. package/templates/current/clean/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/350/247/222/350/211/262.ts +169 -0
  124. package/templates/current/clean/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/350/256/242/345/215/225/350/215/211/347/250/277.ts +170 -0
  125. package/templates/current/clean/src/api/generated//350/256/244/350/257/201.ts +98 -0
  126. package/templates/current/clean/src/api/http-adapter.spec.ts +33 -0
  127. package/templates/current/clean/src/api/http-adapter.ts +83 -0
  128. package/templates/current/clean/src/api/index.ts +41 -0
  129. package/templates/current/clean/src/app/createAdminUi.spec.ts +110 -0
  130. package/templates/current/clean/src/app/createAdminUi.ts +78 -0
  131. package/templates/current/clean/src/app/menu.spec.ts +255 -0
  132. package/templates/current/clean/src/app/menu.ts +268 -0
  133. package/templates/current/clean/src/app/menuTypes.ts +17 -0
  134. package/templates/current/clean/src/app/origenUiLocale.spec.ts +14 -0
  135. package/templates/current/clean/src/app/origenUiLocale.ts +65 -0
  136. package/templates/current/clean/src/app/permission.ts +9 -0
  137. package/templates/current/clean/src/app/runtimeConfig.ts +77 -0
  138. package/templates/current/clean/src/demo-api.spec.ts +167 -0
  139. package/templates/current/clean/src/env.d.ts +14 -0
  140. package/templates/current/clean/src/features/appearance/components/ThemePanel.vue +200 -0
  141. package/templates/current/clean/src/features/appearance/composables/useTheme.ts +17 -0
  142. package/templates/current/clean/src/features/appearance/store/theme.ts +140 -0
  143. package/templates/current/clean/src/features/auth/pages/Login.vue +159 -0
  144. package/templates/current/clean/src/features/auth/store/auth.spec.ts +131 -0
  145. package/templates/current/clean/src/features/auth/store/auth.ts +210 -0
  146. package/templates/current/clean/src/features/errors/pages/Forbidden.vue +26 -0
  147. package/templates/current/clean/src/features/errors/pages/NotFound.vue +26 -0
  148. package/templates/current/clean/src/features/errors/pages/ServerError.vue +26 -0
  149. package/templates/current/clean/src/features/errors/pages/error-pages.spec.ts +32 -0
  150. package/templates/current/clean/src/features/security/components/DevtoolsProtectionOverlay.vue +56 -0
  151. package/templates/current/clean/src/features/security/devtoolsProtection.spec.ts +211 -0
  152. package/templates/current/clean/src/features/security/devtoolsProtection.ts +242 -0
  153. package/templates/current/clean/src/features/shell/components/AdminWatermark.spec.ts +90 -0
  154. package/templates/current/clean/src/features/shell/components/AdminWatermark.vue +47 -0
  155. package/templates/current/clean/src/features/shell/components/RouteProgress.vue +68 -0
  156. package/templates/current/clean/src/features/shell/composables/useRouteProgress.spec.ts +95 -0
  157. package/templates/current/clean/src/features/shell/composables/useRouteProgress.ts +52 -0
  158. package/templates/current/clean/src/features/shell/store/sidebar.ts +55 -0
  159. package/templates/current/clean/src/features/system/access/api/admin-repository.ts +279 -0
  160. package/templates/current/clean/src/features/system/access/api/rbac.spec.ts +72 -0
  161. package/templates/current/clean/src/features/system/access/api/rbac.ts +272 -0
  162. package/templates/current/clean/src/features/system/access/composables/useAuthorizationRefresh.ts +15 -0
  163. package/templates/current/clean/src/features/workspace/pages/Empty.vue +18 -0
  164. package/templates/current/clean/src/features/workspace/pages/Profile.vue +183 -0
  165. package/templates/current/clean/src/layouts/AdminLayout.vue +61 -0
  166. package/templates/current/clean/src/layouts/BreadcrumbBar.vue +27 -0
  167. package/templates/current/clean/src/layouts/SideMenu.vue +119 -0
  168. package/templates/current/clean/src/layouts/TopBar.vue +301 -0
  169. package/templates/current/clean/src/layouts/WorkspaceTabs.vue +44 -0
  170. package/templates/current/clean/src/layouts/topBarMenuSearch.spec.ts +31 -0
  171. package/templates/current/clean/src/layouts/topBarMenuSearch.ts +21 -0
  172. package/templates/current/clean/src/locales/en-US.ts +55 -0
  173. package/templates/current/clean/src/locales/index.ts +119 -0
  174. package/templates/current/clean/src/locales/messages.spec.ts +23 -0
  175. package/templates/current/clean/src/locales/zh-CN.ts +55 -0
  176. package/templates/current/clean/src/locales/zh-TW.ts +44 -0
  177. package/templates/current/clean/src/main.ts +91 -0
  178. package/templates/current/clean/src/router/bootstrap.ts +76 -0
  179. package/templates/current/clean/src/router/componentRegistry.ts +25 -0
  180. package/templates/current/clean/src/router/dynamicRoutes.spec.ts +47 -0
  181. package/templates/current/clean/src/router/dynamicRoutes.ts +162 -0
  182. package/templates/current/clean/src/router/guards.ts +5 -0
  183. package/templates/current/clean/src/router/queryEncryption.spec.ts +82 -0
  184. package/templates/current/clean/src/router/queryEncryption.ts +133 -0
  185. package/templates/current/clean/src/router/routeQuery.spec.ts +11 -0
  186. package/templates/current/clean/src/router/routeQuery.ts +3 -0
  187. package/templates/current/clean/src/router/runtimeErrorRecovery.spec.ts +161 -0
  188. package/templates/current/clean/src/router/runtimeErrorRecovery.ts +108 -0
  189. package/templates/current/clean/src/router/staticRoutes.ts +63 -0
  190. package/templates/current/clean/src/router/useRouteQueryDefaults.spec.ts +90 -0
  191. package/templates/current/clean/src/router/useRouteQueryDefaults.ts +51 -0
  192. package/templates/current/clean/src/router/useRouteQueryDefaults.types.ts +19 -0
  193. package/templates/current/clean/src/store/index.ts +3 -0
  194. package/templates/current/clean/src/styles/element/index.scss +33 -0
  195. package/templates/current/clean/src/styles/index.css +39 -0
  196. package/templates/current/clean/src/styles/layout.css +115 -0
  197. package/templates/current/clean/src/styles/shell.css +196 -0
  198. package/templates/current/clean/src/styles/source-package-style-compat.css +1 -0
  199. package/templates/current/clean/src/templates/og-form.ts +48 -0
  200. package/templates/current/clean/src/templates/og-table.ts +212 -0
  201. package/templates/current/clean/src/templates/router.ts +51 -0
  202. package/templates/current/clean/src/templates/templates.spec.ts +90 -0
  203. package/templates/current/clean/src/theme/index.ts +7 -0
  204. package/templates/current/clean/src/utils/__tests__/color-mix.spec.ts +39 -0
  205. package/templates/current/clean/src/utils/color-mix.ts +76 -0
  206. package/templates/current/clean/src/utils/permissions.ts +6 -0
  207. package/templates/current/clean/tsconfig.json +40 -0
  208. package/templates/current/clean/tsconfig.node.json +9 -0
  209. package/templates/current/clean/vite.build-policy.ts +405 -0
  210. package/templates/current/clean/vite.config.ts +37 -0
  211. package/templates/current/examples/.codebuddy/AGENTS.md +18 -0
  212. package/templates/current/examples/.codebuddy/rules/01-feature-architecture.md +12 -0
  213. package/templates/current/examples/.codebuddy/rules/02-vue-typescript.md +12 -0
  214. package/templates/current/examples/.codebuddy/rules/03-component-policy.md +30 -0
  215. package/templates/current/examples/.codebuddy/rules/04-api-auth-router.md +12 -0
  216. package/templates/current/examples/.codebuddy/rules/05-style.md +12 -0
  217. package/templates/current/examples/.codebuddy/rules/06-quality.md +12 -0
  218. package/templates/current/examples/.codebuddy/skills/build-admin-feature/SKILL.md +17 -0
  219. package/templates/current/examples/.codebuddy/skills/style-og-origen-ui/SKILL.md +14 -0
  220. package/templates/current/examples/.codebuddy/skills/use-og-dialog/SKILL.md +15 -0
  221. package/templates/current/examples/.codebuddy/skills/use-og-editor/SKILL.md +28 -0
  222. package/templates/current/examples/.codebuddy/skills/use-og-form/SKILL.md +15 -0
  223. package/templates/current/examples/.codebuddy/skills/use-og-form-table/SKILL.md +28 -0
  224. package/templates/current/examples/.codebuddy/skills/use-og-http/SKILL.md +16 -0
  225. package/templates/current/examples/.codebuddy/skills/use-og-router-tabs/SKILL.md +14 -0
  226. package/templates/current/examples/.codebuddy/skills/use-og-search/SKILL.md +17 -0
  227. package/templates/current/examples/.codebuddy/skills/use-og-table/SKILL.md +19 -0
  228. package/templates/current/examples/.codebuddy/skills/use-og-upload/SKILL.md +28 -0
  229. package/templates/current/examples/.codex/AGENTS.md +15 -0
  230. package/templates/current/examples/.codex/rules/01-feature-architecture.md +6 -0
  231. package/templates/current/examples/.codex/rules/02-vue-typescript.md +6 -0
  232. package/templates/current/examples/.codex/rules/03-component-policy.md +24 -0
  233. package/templates/current/examples/.codex/rules/04-api-auth-router.md +6 -0
  234. package/templates/current/examples/.codex/rules/05-style.md +6 -0
  235. package/templates/current/examples/.codex/rules/06-quality.md +6 -0
  236. package/templates/current/examples/.codex/skills/build-admin-feature/SKILL.md +14 -0
  237. package/templates/current/examples/.codex/skills/build-admin-feature/references/component-selection.md +25 -0
  238. package/templates/current/examples/.codex/skills/style-og-origen-ui/SKILL.md +11 -0
  239. package/templates/current/examples/.codex/skills/style-og-origen-ui/agents/openai.yaml +4 -0
  240. package/templates/current/examples/.codex/skills/use-og-dialog/SKILL.md +12 -0
  241. package/templates/current/examples/.codex/skills/use-og-dialog/agents/openai.yaml +4 -0
  242. package/templates/current/examples/.codex/skills/use-og-editor/SKILL.md +25 -0
  243. package/templates/current/examples/.codex/skills/use-og-form/SKILL.md +12 -0
  244. package/templates/current/examples/.codex/skills/use-og-form-table/SKILL.md +25 -0
  245. package/templates/current/examples/.codex/skills/use-og-http/SKILL.md +13 -0
  246. package/templates/current/examples/.codex/skills/use-og-http/agents/openai.yaml +4 -0
  247. package/templates/current/examples/.codex/skills/use-og-router-tabs/SKILL.md +11 -0
  248. package/templates/current/examples/.codex/skills/use-og-search/SKILL.md +14 -0
  249. package/templates/current/examples/.codex/skills/use-og-table/SKILL.md +16 -0
  250. package/templates/current/examples/.codex/skills/use-og-upload/SKILL.md +25 -0
  251. package/templates/current/examples/.cursor/AGENTS.md +18 -0
  252. package/templates/current/examples/.cursor/rules/01-feature-architecture.mdc +12 -0
  253. package/templates/current/examples/.cursor/rules/02-vue-typescript.mdc +12 -0
  254. package/templates/current/examples/.cursor/rules/03-component-policy.mdc +30 -0
  255. package/templates/current/examples/.cursor/rules/04-api-auth-router.mdc +12 -0
  256. package/templates/current/examples/.cursor/rules/05-style.mdc +12 -0
  257. package/templates/current/examples/.cursor/rules/06-quality.mdc +12 -0
  258. package/templates/current/examples/.cursor/skills/build-admin-feature/SKILL.md +14 -0
  259. package/templates/current/examples/.cursor/skills/style-og-origen-ui/SKILL.md +11 -0
  260. package/templates/current/examples/.cursor/skills/use-og-dialog/SKILL.md +12 -0
  261. package/templates/current/examples/.cursor/skills/use-og-editor/SKILL.md +25 -0
  262. package/templates/current/examples/.cursor/skills/use-og-form/SKILL.md +12 -0
  263. package/templates/current/examples/.cursor/skills/use-og-form-table/SKILL.md +25 -0
  264. package/templates/current/examples/.cursor/skills/use-og-http/SKILL.md +13 -0
  265. package/templates/current/examples/.cursor/skills/use-og-router-tabs/SKILL.md +11 -0
  266. package/templates/current/examples/.cursor/skills/use-og-search/SKILL.md +14 -0
  267. package/templates/current/examples/.cursor/skills/use-og-table/SKILL.md +16 -0
  268. package/templates/current/examples/.cursor/skills/use-og-upload/SKILL.md +25 -0
  269. package/templates/current/examples/.env.example +7 -0
  270. package/templates/current/examples/.env.production.example +31 -0
  271. package/templates/current/examples/.qoder/AGENTS.md +15 -0
  272. package/templates/current/examples/.qoder/rules/01-feature-architecture.md +12 -0
  273. package/templates/current/examples/.qoder/rules/02-vue-typescript.md +12 -0
  274. package/templates/current/examples/.qoder/rules/03-component-policy.md +30 -0
  275. package/templates/current/examples/.qoder/rules/04-api-auth-router.md +12 -0
  276. package/templates/current/examples/.qoder/rules/05-style.md +12 -0
  277. package/templates/current/examples/.qoder/rules/06-quality.md +12 -0
  278. package/templates/current/examples/.qoder/skills/build-admin-feature/SKILL.md +14 -0
  279. package/templates/current/examples/.qoder/skills/style-og-origen-ui/SKILL.md +11 -0
  280. package/templates/current/examples/.qoder/skills/use-og-dialog/SKILL.md +12 -0
  281. package/templates/current/examples/.qoder/skills/use-og-editor/SKILL.md +25 -0
  282. package/templates/current/examples/.qoder/skills/use-og-form/SKILL.md +12 -0
  283. package/templates/current/examples/.qoder/skills/use-og-form-table/SKILL.md +25 -0
  284. package/templates/current/examples/.qoder/skills/use-og-http/SKILL.md +13 -0
  285. package/templates/current/examples/.qoder/skills/use-og-router-tabs/SKILL.md +11 -0
  286. package/templates/current/examples/.qoder/skills/use-og-search/SKILL.md +14 -0
  287. package/templates/current/examples/.qoder/skills/use-og-table/SKILL.md +16 -0
  288. package/templates/current/examples/.qoder/skills/use-og-upload/SKILL.md +25 -0
  289. package/templates/current/examples/AGENTS.md +16 -0
  290. package/templates/current/examples/README.md +116 -0
  291. package/templates/current/examples/component-catalog.json +765 -0
  292. package/templates/current/examples/e2e/admin-shell.spec.ts +150 -0
  293. package/templates/current/examples/e2e/demo-shell.spec.ts +328 -0
  294. package/templates/current/examples/evals/component-selection.json +29 -0
  295. package/templates/current/examples/gitignore +3 -0
  296. package/templates/current/examples/index.html +13 -0
  297. package/templates/current/examples/openapi.json +1623 -0
  298. package/templates/current/examples/package.json +65 -0
  299. package/templates/current/examples/playwright.config.ts +31 -0
  300. package/templates/current/examples/playwright.demo.config.ts +25 -0
  301. package/templates/current/examples/recipes/README.md +7 -0
  302. package/templates/current/examples/recipes/remote-crud-dialog-form.json +15 -0
  303. package/templates/current/examples/recipes/remote-crud-dialog-form.vue +66 -0
  304. package/templates/current/examples/scaffold.lock.json +12 -0
  305. package/templates/current/examples/scripts/check-admin-bundle.mjs +214 -0
  306. package/templates/current/examples/scripts/check-admin-scaffold.mjs +168 -0
  307. package/templates/current/examples/scripts/clean-overlay/src/features/errors/pages/Forbidden.vue +26 -0
  308. package/templates/current/examples/scripts/clean-overlay/src/features/errors/pages/NotFound.vue +26 -0
  309. package/templates/current/examples/scripts/clean-overlay/src/features/errors/pages/ServerError.vue +26 -0
  310. package/templates/current/examples/scripts/clean-overlay/src/features/errors/pages/error-pages.spec.ts +32 -0
  311. package/templates/current/examples/scripts/clean-overlay/src/main.ts +91 -0
  312. package/templates/current/examples/scripts/clean-overlay/src/router/componentRegistry.ts +25 -0
  313. package/templates/current/examples/scripts/clean-overlay/src/router/dynamicRoutes.spec.ts +47 -0
  314. package/templates/current/examples/scripts/clean-overlay/src/router/staticRoutes.ts +63 -0
  315. package/templates/current/examples/scripts/demo-api.ts +797 -0
  316. package/templates/current/examples/scripts/generate-api.ts +27 -0
  317. package/templates/current/examples/scripts/performance/baselines/bundle-gzip-v2-pre-entry-unification.json +38 -0
  318. package/templates/current/examples/scripts/remove-examples.mjs +54 -0
  319. package/templates/current/examples/src/App.vue +67 -0
  320. package/templates/current/examples/src/api/client.spec.ts +66 -0
  321. package/templates/current/examples/src/api/client.ts +72 -0
  322. package/templates/current/examples/src/api/generated/data-contracts.ts +268 -0
  323. package/templates/current/examples/src/api/generated/http-client.ts +266 -0
  324. package/templates/current/examples/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/345/206/205/345/256/271/346/226/207/347/253/240.ts +147 -0
  325. package/templates/current/examples/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/345/256/241/350/256/241.ts +53 -0
  326. package/templates/current/examples/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/346/226/207/344/273/266/344/270/212/344/274/240.ts +66 -0
  327. package/templates/current/examples/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/347/224/250/346/210/267.ts +171 -0
  328. package/templates/current/examples/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/350/217/234/345/215/225.ts +181 -0
  329. package/templates/current/examples/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/350/247/222/350/211/262.ts +169 -0
  330. package/templates/current/examples/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/350/256/242/345/215/225/350/215/211/347/250/277.ts +170 -0
  331. package/templates/current/examples/src/api/generated//350/256/244/350/257/201.ts +98 -0
  332. package/templates/current/examples/src/api/http-adapter.spec.ts +33 -0
  333. package/templates/current/examples/src/api/http-adapter.ts +83 -0
  334. package/templates/current/examples/src/api/index.ts +41 -0
  335. package/templates/current/examples/src/app/createAdminUi.spec.ts +110 -0
  336. package/templates/current/examples/src/app/createAdminUi.ts +78 -0
  337. package/templates/current/examples/src/app/menu.spec.ts +255 -0
  338. package/templates/current/examples/src/app/menu.ts +268 -0
  339. package/templates/current/examples/src/app/menuTypes.ts +17 -0
  340. package/templates/current/examples/src/app/origenUiLocale.spec.ts +14 -0
  341. package/templates/current/examples/src/app/origenUiLocale.ts +65 -0
  342. package/templates/current/examples/src/app/permission.ts +9 -0
  343. package/templates/current/examples/src/app/runtimeConfig.ts +77 -0
  344. package/templates/current/examples/src/demo-api.spec.ts +167 -0
  345. package/templates/current/examples/src/env.d.ts +14 -0
  346. package/templates/current/examples/src/features/appearance/components/ThemePanel.vue +200 -0
  347. package/templates/current/examples/src/features/appearance/composables/useTheme.ts +17 -0
  348. package/templates/current/examples/src/features/appearance/store/theme.ts +140 -0
  349. package/templates/current/examples/src/features/auth/pages/Login.vue +159 -0
  350. package/templates/current/examples/src/features/auth/store/auth.spec.ts +131 -0
  351. package/templates/current/examples/src/features/auth/store/auth.ts +210 -0
  352. package/templates/current/examples/src/features/errors/pages/Forbidden.vue +26 -0
  353. package/templates/current/examples/src/features/errors/pages/NotFound.vue +26 -0
  354. package/templates/current/examples/src/features/errors/pages/ServerError.vue +26 -0
  355. package/templates/current/examples/src/features/errors/pages/error-pages.spec.ts +32 -0
  356. package/templates/current/examples/src/features/feature-composables.spec.ts +208 -0
  357. package/templates/current/examples/src/features/security/components/DevtoolsProtectionOverlay.vue +56 -0
  358. package/templates/current/examples/src/features/security/devtoolsProtection.spec.ts +211 -0
  359. package/templates/current/examples/src/features/security/devtoolsProtection.ts +242 -0
  360. package/templates/current/examples/src/features/shell/components/AdminWatermark.spec.ts +90 -0
  361. package/templates/current/examples/src/features/shell/components/AdminWatermark.vue +47 -0
  362. package/templates/current/examples/src/features/shell/components/RouteProgress.vue +68 -0
  363. package/templates/current/examples/src/features/shell/composables/useRouteProgress.spec.ts +95 -0
  364. package/templates/current/examples/src/features/shell/composables/useRouteProgress.ts +52 -0
  365. package/templates/current/examples/src/features/shell/store/sidebar.ts +55 -0
  366. package/templates/current/examples/src/features/system/access/api/admin-repository.ts +279 -0
  367. package/templates/current/examples/src/features/system/access/api/rbac.spec.ts +72 -0
  368. package/templates/current/examples/src/features/system/access/api/rbac.ts +272 -0
  369. package/templates/current/examples/src/features/system/access/composables/useAuthorizationRefresh.ts +15 -0
  370. package/templates/current/examples/src/features/system/audit/composables/useAuditManagement.ts +117 -0
  371. package/templates/current/examples/src/features/system/audit/pages/AuditList.vue +20 -0
  372. package/templates/current/examples/src/features/system/menus/components/MenuEditorForm.vue +189 -0
  373. package/templates/current/examples/src/features/system/menus/composables/useMenuManagement.ts +327 -0
  374. package/templates/current/examples/src/features/system/menus/pages/MenuList.vue +49 -0
  375. package/templates/current/examples/src/features/system/roles/components/RoleEditorForm.vue +112 -0
  376. package/templates/current/examples/src/features/system/roles/composables/useRoleManagement.ts +198 -0
  377. package/templates/current/examples/src/features/system/roles/pages/RoleList.vue +45 -0
  378. package/templates/current/examples/src/features/system/users/components/UserEditorForm.vue +101 -0
  379. package/templates/current/examples/src/features/system/users/composables/useUserManagement.ts +233 -0
  380. package/templates/current/examples/src/features/system/users/pages/UserList.vue +49 -0
  381. package/templates/current/examples/src/features/workspace/pages/Dashboard.spec.ts +32 -0
  382. package/templates/current/examples/src/features/workspace/pages/Dashboard.vue +297 -0
  383. package/templates/current/examples/src/features/workspace/pages/Empty.vue +18 -0
  384. package/templates/current/examples/src/features/workspace/pages/Profile.vue +183 -0
  385. package/templates/current/examples/src/layouts/AdminLayout.vue +61 -0
  386. package/templates/current/examples/src/layouts/BreadcrumbBar.vue +27 -0
  387. package/templates/current/examples/src/layouts/SideMenu.vue +119 -0
  388. package/templates/current/examples/src/layouts/TopBar.vue +301 -0
  389. package/templates/current/examples/src/layouts/WorkspaceTabs.vue +44 -0
  390. package/templates/current/examples/src/layouts/topBarMenuSearch.spec.ts +31 -0
  391. package/templates/current/examples/src/layouts/topBarMenuSearch.ts +21 -0
  392. package/templates/current/examples/src/locales/en-US.ts +55 -0
  393. package/templates/current/examples/src/locales/index.ts +119 -0
  394. package/templates/current/examples/src/locales/messages.spec.ts +23 -0
  395. package/templates/current/examples/src/locales/zh-CN.ts +55 -0
  396. package/templates/current/examples/src/locales/zh-TW.ts +44 -0
  397. package/templates/current/examples/src/main.ts +91 -0
  398. package/templates/current/examples/src/router/bootstrap.ts +76 -0
  399. package/templates/current/examples/src/router/componentRegistry.ts +83 -0
  400. package/templates/current/examples/src/router/dynamicRoutes.spec.ts +109 -0
  401. package/templates/current/examples/src/router/dynamicRoutes.ts +162 -0
  402. package/templates/current/examples/src/router/guards.ts +5 -0
  403. package/templates/current/examples/src/router/queryEncryption.spec.ts +82 -0
  404. package/templates/current/examples/src/router/queryEncryption.ts +133 -0
  405. package/templates/current/examples/src/router/routeQuery.spec.ts +11 -0
  406. package/templates/current/examples/src/router/routeQuery.ts +3 -0
  407. package/templates/current/examples/src/router/runtimeErrorRecovery.spec.ts +161 -0
  408. package/templates/current/examples/src/router/runtimeErrorRecovery.ts +108 -0
  409. package/templates/current/examples/src/router/staticRoutes.ts +63 -0
  410. package/templates/current/examples/src/router/useRouteQueryDefaults.spec.ts +90 -0
  411. package/templates/current/examples/src/router/useRouteQueryDefaults.ts +51 -0
  412. package/templates/current/examples/src/router/useRouteQueryDefaults.types.ts +19 -0
  413. package/templates/current/examples/src/store/index.ts +3 -0
  414. package/templates/current/examples/src/styles/element/index.scss +33 -0
  415. package/templates/current/examples/src/styles/index.css +39 -0
  416. package/templates/current/examples/src/styles/layout.css +115 -0
  417. package/templates/current/examples/src/styles/shell.css +196 -0
  418. package/templates/current/examples/src/styles/source-package-style-compat.css +1 -0
  419. package/templates/current/examples/src/templates/og-form.ts +48 -0
  420. package/templates/current/examples/src/templates/og-table.ts +212 -0
  421. package/templates/current/examples/src/templates/router.ts +51 -0
  422. package/templates/current/examples/src/templates/templates.spec.ts +90 -0
  423. package/templates/current/examples/src/theme/index.ts +7 -0
  424. package/templates/current/examples/src/utils/__tests__/color-mix.spec.ts +39 -0
  425. package/templates/current/examples/src/utils/color-mix.ts +76 -0
  426. package/templates/current/examples/src/utils/permissions.ts +6 -0
  427. package/templates/current/examples/tsconfig.json +40 -0
  428. package/templates/current/examples/tsconfig.node.json +9 -0
  429. package/templates/current/examples/vite.build-policy.ts +405 -0
  430. package/templates/current/examples/vite.config.ts +37 -0
@@ -0,0 +1,90 @@
1
+ import type { OgTableDataSource } from '@origen-ui/table'
2
+ import { describe, expect, it, vi } from 'vitest'
3
+ import { createOgFormTemplate } from './og-form'
4
+ import {
5
+ createEditableApprovalTableTemplate,
6
+ createPermissionCrudTableTemplate,
7
+ createQueryScopeBatchTableTemplate,
8
+ createRemoteListTableTemplate,
9
+ createVirtualLargeTableTemplate,
10
+ } from './og-table'
11
+ import {
12
+ createDynamicPermissionRouteTemplate,
13
+ createStaticRouteTemplate,
14
+ createWorkspacePersistenceRouteTemplate,
15
+ } from './router'
16
+
17
+ interface Row {
18
+ id: string
19
+ name: string
20
+ }
21
+ interface Query {
22
+ status?: string
23
+ }
24
+
25
+ const dataSource: OgTableDataSource<Row, Query> = {
26
+ list: async (request) => ({ list: [], total: 0, page: request.page, pageSize: request.pageSize }),
27
+ }
28
+
29
+ const base = {
30
+ tableId: 'template-table',
31
+ rowKey: 'id' as const,
32
+ columns: [{ prop: 'name', label: 'Name' }] as [{ prop: 'name', label: string }],
33
+ dataSource,
34
+ permissions: () => true,
35
+ }
36
+
37
+ describe('admin local templates', () => {
38
+ it('keeps remote data and permission adapters explicit across table scenarios', () => {
39
+ expect(createRemoteListTableTemplate(base).dataSource).toBe(dataSource)
40
+ expect(
41
+ createPermissionCrudTableTemplate({
42
+ ...base,
43
+ adapter: { create: vi.fn(), edit: vi.fn(), remove: vi.fn() },
44
+ }).config.permissions?.has,
45
+ ).toBe(base.permissions)
46
+ expect(createEditableApprovalTableTemplate(base).config.editing?.mode).toBe('row')
47
+ expect(createVirtualLargeTableTemplate(base).config.virtual?.enabled).toBe(true)
48
+ expect(
49
+ createQueryScopeBatchTableTemplate({ ...base, eligibilityKey: 'all', adapter: {} }).config.selection?.queryScope?.enabled,
50
+ ).toBe(true)
51
+ })
52
+
53
+ it('keeps OgForm transformation and validation in the caller adapter', async () => {
54
+ const template = createOgFormTemplate({
55
+ schema: {
56
+ sections: [{ fields: [{ prop: 'name', label: 'Name', required: true }] }],
57
+ },
58
+ permissions: () => true,
59
+ transformSubmit: (model) => ({ name: String(model.name).trim() }),
60
+ validateSubmit: (model) => {
61
+ if (!model.name) throw new Error('Name is required')
62
+ },
63
+ })
64
+ await expect(template.submit({ name: ' Ada ' })).resolves.toEqual({ name: 'Ada' })
65
+ await expect(template.submit({ name: ' ' })).rejects.toThrow('Name is required')
66
+ })
67
+
68
+ it('filters dynamic routes and preserves workspace persistence metadata', () => {
69
+ const routes = createDynamicPermissionRouteTemplate(
70
+ [
71
+ { name: 'allowed', path: '/allowed', meta: { permissions: ['read'] } },
72
+ { name: 'denied', path: '/denied', meta: { permissions: ['write'] } },
73
+ ],
74
+ (permission) => permission === 'read',
75
+ )
76
+ expect(routes.map((route) => route.name)).toEqual(['allowed'])
77
+ expect(createStaticRouteTemplate([{ path: '/login', redirect: '/dashboard' }])).toHaveLength(1)
78
+ expect(
79
+ createWorkspacePersistenceRouteTemplate({
80
+ storage: { read: () => undefined, write: () => {}, remove: () => {} },
81
+ key: 'workspace',
82
+ version: 1,
83
+ scope: 'admin',
84
+ }),
85
+ ).toMatchObject({
86
+ enabled: true,
87
+ persistence: { key: 'workspace', version: 1, scope: 'admin' },
88
+ })
89
+ })
90
+ })
@@ -0,0 +1,7 @@
1
+ export function installTheme(): void {
2
+ if (typeof document === 'undefined') return
3
+
4
+ const root = document.documentElement
5
+ // 只覆盖 base;派生色由 SCSS 在 build 期算,不再运行时覆盖
6
+ root.style.setProperty('--el-color-primary', '#5E6AD2')
7
+ }
@@ -0,0 +1,39 @@
1
+ import { describe, expect, it } from 'vitest'
2
+ import { derivePrimaryPalette } from '../color-mix'
3
+
4
+ describe('derivePrimaryPalette', () => {
5
+ it('matches the Element Plus light color ladder', () => {
6
+ expect(derivePrimaryPalette('#5E6AD2', 'light')).toEqual({
7
+ base: '#5E6AD2',
8
+ rgb: '94, 106, 210',
9
+ light3: '#8e97e0',
10
+ light5: '#afb5e9',
11
+ light7: '#cfd2f2',
12
+ light8: '#dfe1f6',
13
+ light9: '#eff0fb',
14
+ dark2: '#4b55a8',
15
+ })
16
+ })
17
+
18
+ it('uses the admin surface for the dark color ladder', () => {
19
+ expect(derivePrimaryPalette('#5E6AD2', 'dark')).toEqual({
20
+ base: '#5E6AD2',
21
+ rgb: '94, 106, 210',
22
+ light3: '#475099',
23
+ light5: '#383e73',
24
+ light7: '#292c4d',
25
+ light8: '#21243a',
26
+ light9: '#1a1b27',
27
+ dark2: '#7e88db',
28
+ })
29
+ })
30
+
31
+ it('derives both schemes from a custom primary color', () => {
32
+ expect(derivePrimaryPalette('#0EA5E9', 'light').light9).toBe('#e7f6fd')
33
+ expect(derivePrimaryPalette('#0EA5E9', 'dark')).toMatchObject({
34
+ rgb: '14, 165, 233',
35
+ light9: '#122129',
36
+ dark2: '#3eb7ed',
37
+ })
38
+ })
39
+ })
@@ -0,0 +1,76 @@
1
+ // 浅色模式遵循 Element Plus 的白色色阶;深色模式改与基础表面混合。
2
+ // dark-2 在浅色下压暗、深色下提亮,保证主色文字有足够对比度。
3
+ export interface RgbColor {
4
+ r: number
5
+ g: number
6
+ b: number
7
+ }
8
+
9
+ export type ThemeColorScheme = 'light' | 'dark'
10
+
11
+ export function hexToRgb(hex: string): RgbColor {
12
+ const normalized = hex.replace('#', '').trim()
13
+ const value =
14
+ normalized.length === 3
15
+ ? normalized
16
+ .split('')
17
+ .map((c) => c + c)
18
+ .join('')
19
+ : normalized.padEnd(6, '0')
20
+ return {
21
+ r: Number.parseInt(value.slice(0, 2), 16),
22
+ g: Number.parseInt(value.slice(2, 4), 16),
23
+ b: Number.parseInt(value.slice(4, 6), 16),
24
+ }
25
+ }
26
+
27
+ export function rgbToHex({ r, g, b }: RgbColor): string {
28
+ return `#${[r, g, b].map((n) => n.toString(16).padStart(2, '0')).join('')}`
29
+ }
30
+
31
+ function clamp(value: number): number {
32
+ return Math.max(0, Math.min(255, Math.round(value)))
33
+ }
34
+
35
+ export function mixWith(target: RgbColor, base: RgbColor, targetWeight: number): RgbColor {
36
+ return {
37
+ r: clamp(target.r * targetWeight + base.r * (1 - targetWeight)),
38
+ g: clamp(target.g * targetWeight + base.g * (1 - targetWeight)),
39
+ b: clamp(target.b * targetWeight + base.b * (1 - targetWeight)),
40
+ }
41
+ }
42
+
43
+ export interface PrimaryPalette {
44
+ base: string
45
+ rgb: string
46
+ light3: string
47
+ light5: string
48
+ light7: string
49
+ light8: string
50
+ light9: string
51
+ dark2: string
52
+ }
53
+
54
+ const WHITE: RgbColor = { r: 255, g: 255, b: 255 }
55
+ const BLACK: RgbColor = { r: 0, g: 0, b: 0 }
56
+ const DARK_SURFACE: RgbColor = { r: 18, g: 18, b: 20 }
57
+
58
+ export function derivePrimaryPalette(
59
+ base: string,
60
+ scheme: ThemeColorScheme = 'light',
61
+ ): PrimaryPalette {
62
+ const baseRgb = hexToRgb(base)
63
+ const lightTarget = scheme === 'dark' ? DARK_SURFACE : WHITE
64
+ const darkTarget = scheme === 'dark' ? WHITE : BLACK
65
+
66
+ return {
67
+ base,
68
+ rgb: `${baseRgb.r}, ${baseRgb.g}, ${baseRgb.b}`,
69
+ light3: rgbToHex(mixWith(lightTarget, baseRgb, 0.3)),
70
+ light5: rgbToHex(mixWith(lightTarget, baseRgb, 0.5)),
71
+ light7: rgbToHex(mixWith(lightTarget, baseRgb, 0.7)),
72
+ light8: rgbToHex(mixWith(lightTarget, baseRgb, 0.8)),
73
+ light9: rgbToHex(mixWith(lightTarget, baseRgb, 0.9)),
74
+ dark2: rgbToHex(mixWith(darkTarget, baseRgb, 0.2)),
75
+ }
76
+ }
@@ -0,0 +1,6 @@
1
+ import type { AdminSession } from '../features/auth/store/auth'
2
+ import { hasCodePermission } from '@origen-ui/permission/codes'
3
+
4
+ export function hasPermission(session: AdminSession | null, codes: readonly string[]): boolean {
5
+ return hasCodePermission(session?.permissions, codes)
6
+ }
@@ -0,0 +1,40 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "compilerOptions": {
4
+ "target": "ESNext",
5
+ "jsx": "preserve",
6
+ "jsxImportSource": "vue",
7
+ "lib": [
8
+ "ESNext",
9
+ "DOM",
10
+ "DOM.Iterable"
11
+ ],
12
+ "baseUrl": ".",
13
+ "module": "ESNext",
14
+ "moduleResolution": "Bundler",
15
+ "paths": {
16
+ "@/*": [
17
+ "./src/*"
18
+ ]
19
+ },
20
+ "resolveJsonModule": true,
21
+ "types": [
22
+ "vite/client"
23
+ ],
24
+ "strict": true,
25
+ "noFallthroughCasesInSwitch": true,
26
+ "noImplicitAny": true,
27
+ "noUnusedLocals": true,
28
+ "noUnusedParameters": true,
29
+ "esModuleInterop": true,
30
+ "forceConsistentCasingInFileNames": true,
31
+ "isolatedModules": true,
32
+ "skipLibCheck": true
33
+ },
34
+ "include": [
35
+ "src/**/*.ts",
36
+ "src/**/*.vue",
37
+ "src/**/*.d.ts",
38
+ "vite.config.ts"
39
+ ]
40
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "extends": "./tsconfig.json",
4
+ "compilerOptions": {
5
+ "composite": true,
6
+ "types": ["node"]
7
+ },
8
+ "include": ["vite.config.ts"]
9
+ }
@@ -0,0 +1,405 @@
1
+ import type { Plugin, Rollup, UserConfig } from 'vite'
2
+ import { writeFile } from 'node:fs/promises'
3
+ import { resolve } from 'node:path'
4
+ import process from 'node:process'
5
+
6
+ const packageBuildDirectories = new Set(['dist', 'es', 'esm', 'lib', 'src'])
7
+ const splitModuleDirectories = new Set(['components', 'languages', 'locale'])
8
+ const ASYNC_COMPONENT_CHUNK_BUCKETS = 4
9
+ const INITIAL_CHUNK_BUCKETS = 3
10
+
11
+ function chunkName(value: string): string {
12
+ return value
13
+ .replace(/^@/, '')
14
+ .replaceAll(/[^\w-]+/g, '-')
15
+ .replaceAll(/^-+|-+$/g, '')
16
+ .toLowerCase()
17
+ }
18
+
19
+ function dependencyPath(normalized: string): { name: string, path: string[] } | undefined {
20
+ const marker = '/node_modules/'
21
+ const nodeModulesIndex = normalized.lastIndexOf(marker)
22
+ if (nodeModulesIndex < 0) return undefined
23
+
24
+ const segments = normalized.slice(nodeModulesIndex + marker.length).split('/')
25
+ const scoped = segments[0]?.startsWith('@')
26
+ const packageSegments = scoped ? segments.slice(0, 2) : segments.slice(0, 1)
27
+ if (packageSegments.some((segment) => !segment)) return undefined
28
+ return {
29
+ name: packageSegments.join('/'),
30
+ path: segments.slice(packageSegments.length),
31
+ }
32
+ }
33
+
34
+ function workspacePackagePath(normalized: string): { name: string, path: string[] } | undefined {
35
+ const match = normalized.match(/\/packages\/([^/]+)\/(?:dist|src)\/(.+)$/)
36
+ if (!match) return undefined
37
+ return { name: `og-${match[1]}`, path: match[2].split('/') }
38
+ }
39
+
40
+ function moduleLocation(id: string) {
41
+ const normalized = id.split('?')[0].replaceAll('\\', '/')
42
+ const dependency = dependencyPath(normalized) ?? workspacePackagePath(normalized)
43
+ if (!dependency) return undefined
44
+
45
+ const path = [...dependency.path]
46
+ const buildDirectory = packageBuildDirectories.has(path[0]) ? path.shift() : undefined
47
+ return { ...dependency, path, buildDirectory }
48
+ }
49
+
50
+ function isStyleModule(id: string): boolean {
51
+ return /\.(?:css|less|sass|scss|styl)(?:$|\?)/.test(id)
52
+ }
53
+
54
+ function moduleUnitKey(id: string): string | undefined {
55
+ const location = moduleLocation(id)
56
+ if (!location) return undefined
57
+ const [directory, moduleName] = location.path
58
+ if (!directory || !splitModuleDirectories.has(directory)) return location.name
59
+ if (directory === 'components' && moduleName)
60
+ return `${location.name}\0${directory}\0${moduleName}`
61
+ return `${location.name}\0${directory}`
62
+ }
63
+
64
+ function stableHash(value: string): string {
65
+ let hash = 2_166_136_261
66
+ for (let index = 0; index < value.length; index += 1) {
67
+ hash ^= value.charCodeAt(index)
68
+ hash = Math.imul(hash, 16_777_619)
69
+ }
70
+ return (hash >>> 0).toString(36)
71
+ }
72
+
73
+ function dynamicRootLabels(ids: readonly string[]): ReadonlyMap<string, string> {
74
+ const used = new Map<string, number>()
75
+ const labels = new Map<string, string>()
76
+ for (const id of [...ids].sort()) {
77
+ const normalized = id.split('?')[0].replaceAll('\\', '/')
78
+ const filename = normalized.slice(normalized.lastIndexOf('/') + 1).replace(/\.[^.]+$/, '')
79
+ const base = chunkName(filename || 'async') || 'async'
80
+ const count = (used.get(base) ?? 0) + 1
81
+ used.set(base, count)
82
+ labels.set(id, count === 1 ? base : `${base}-${count}`)
83
+ }
84
+ return labels
85
+ }
86
+
87
+ function moduleOwners(
88
+ meta: Parameters<Rollup.GetManualChunk>[1],
89
+ ): ReadonlyMap<string, readonly string[]> {
90
+ const ids = [...meta.getModuleIds()].sort()
91
+ const ownerSets = new Map<string, Set<string>>()
92
+ const entryRoots = ids.filter((id) => meta.getModuleInfo(id)?.isEntry)
93
+ const dynamicRoots = [
94
+ ...new Set(ids.flatMap((id) => meta.getModuleInfo(id)?.dynamicallyImportedIds ?? [])),
95
+ ]
96
+ const labels = dynamicRootLabels(dynamicRoots)
97
+
98
+ function markStaticClosure(root: string, owner: string): void {
99
+ const stack = [root]
100
+ while (stack.length > 0) {
101
+ const id = stack.pop()!
102
+ const info = meta.getModuleInfo(id)
103
+ if (!info || info.isExternal) continue
104
+ const owners = ownerSets.get(id) ?? new Set<string>()
105
+ if (owners.has(owner)) continue
106
+ owners.add(owner)
107
+ ownerSets.set(id, owners)
108
+ stack.push(...info.importedIds)
109
+ }
110
+ }
111
+
112
+ for (const root of entryRoots) markStaticClosure(root, 'entry')
113
+ for (const root of dynamicRoots) markStaticClosure(root, labels.get(root) ?? 'async')
114
+
115
+ return new Map([...ownerSets].map(([id, owners]) => [id, [...owners].sort()]))
116
+ }
117
+
118
+ function asyncOwnerLabel(owners: readonly string[]): string {
119
+ const asyncOwners = owners.filter((owner) => owner !== 'entry')
120
+ if (asyncOwners.length === 0) return 'orphan'
121
+ if (asyncOwners.length === 1) return asyncOwners[0]
122
+ return `shared-${stableHash(asyncOwners.join('|'))}`
123
+ }
124
+
125
+ function isInitialOnly(owners: readonly string[]): boolean {
126
+ return owners.length === 1 && owners[0] === 'entry'
127
+ }
128
+
129
+ function stronglyConnectedComponents(units: Map<string, { edges: Set<string> }>): string[][] {
130
+ const indices = new Map<string, number>()
131
+ const lowLinks = new Map<string, number>()
132
+ const stack: string[] = []
133
+ const stacked = new Set<string>()
134
+ const components: string[][] = []
135
+ let index = 0
136
+
137
+ function visit(key: string) {
138
+ indices.set(key, index)
139
+ lowLinks.set(key, index++)
140
+ stack.push(key)
141
+ stacked.add(key)
142
+
143
+ for (const edge of [...(units.get(key)?.edges ?? [])].sort()) {
144
+ if (!units.has(edge)) continue
145
+ if (!indices.has(edge)) {
146
+ visit(edge)
147
+ lowLinks.set(key, Math.min(lowLinks.get(key)!, lowLinks.get(edge)!))
148
+ } else if (stacked.has(edge)) {
149
+ lowLinks.set(key, Math.min(lowLinks.get(key)!, indices.get(edge)!))
150
+ }
151
+ }
152
+
153
+ if (lowLinks.get(key) !== indices.get(key)) return
154
+ const component: string[] = []
155
+ let member: string
156
+ do {
157
+ member = stack.pop()!
158
+ stacked.delete(member)
159
+ component.push(member)
160
+ } while (member !== key)
161
+ components.push(component.sort())
162
+ }
163
+
164
+ for (const key of [...units.keys()].sort()) {
165
+ if (!indices.has(key)) visit(key)
166
+ }
167
+ return components
168
+ }
169
+
170
+ function topologicallyOrderedComponents(units: Map<string, { edges: Set<string> }>): string[][] {
171
+ const components = stronglyConnectedComponents(units)
172
+ const componentByUnit = new Map<string, number>()
173
+ components.forEach((component, index) => {
174
+ for (const key of component) componentByUnit.set(key, index)
175
+ })
176
+
177
+ const edges = components.map(() => new Set<number>())
178
+ const indegrees = components.map(() => 0)
179
+ for (const [unit, value] of units) {
180
+ const from = componentByUnit.get(unit)!
181
+ for (const dependency of value.edges) {
182
+ const to = componentByUnit.get(dependency)
183
+ if (to === undefined || to === from || edges[from].has(to)) continue
184
+ edges[from].add(to)
185
+ indegrees[to] += 1
186
+ }
187
+ }
188
+
189
+ const available = components
190
+ .map((_, index) => index)
191
+ .filter((index) => indegrees[index] === 0)
192
+ .sort((left, right) => components[left].join('\0').localeCompare(components[right].join('\0')))
193
+ const ordered: string[][] = []
194
+ while (available.length > 0) {
195
+ const index = available.shift()!
196
+ ordered.push(components[index])
197
+ for (const dependency of edges[index]) {
198
+ indegrees[dependency] -= 1
199
+ if (indegrees[dependency] === 0) {
200
+ available.push(dependency)
201
+ available.sort((left, right) =>
202
+ components[left].join('\0').localeCompare(components[right].join('\0')),
203
+ )
204
+ }
205
+ }
206
+ }
207
+ return ordered
208
+ }
209
+
210
+ function assignBuckets(
211
+ units: Map<string, { edges: Set<string>, size: number }>,
212
+ bucketCount: number,
213
+ ): ReadonlyMap<string, string> {
214
+ const components = topologicallyOrderedComponents(units)
215
+ const totalSize = components.reduce(
216
+ (total, component) => total + component.reduce((size, key) => size + units.get(key)!.size, 0),
217
+ 0,
218
+ )
219
+ const assignments = new Map<string, string>()
220
+ let consumedSize = 0
221
+ for (const component of components) {
222
+ const componentSize = component.reduce((size, key) => size + units.get(key)!.size, 0)
223
+ const midpoint = consumedSize + componentSize / 2
224
+ const bucket = Math.min(
225
+ Math.floor((midpoint * bucketCount) / Math.max(totalSize, 1)),
226
+ bucketCount - 1,
227
+ )
228
+ for (const key of component) assignments.set(key, String(bucket))
229
+ consumedSize += componentSize
230
+ }
231
+ return assignments
232
+ }
233
+
234
+ function initialChunkAssignments(
235
+ meta: Parameters<Rollup.GetManualChunk>[1],
236
+ owners: ReadonlyMap<string, readonly string[]>,
237
+ ): ReadonlyMap<string, string> {
238
+ const units = new Map<string, { edges: Set<string>, size: number }>()
239
+ const unitByModule = new Map<string, string>()
240
+
241
+ for (const id of [...meta.getModuleIds()].sort()) {
242
+ if (!isInitialOnly(owners.get(id) ?? [])) continue
243
+ const key = moduleUnitKey(id)
244
+ if (!key) continue
245
+ const unit = units.get(key) ?? { edges: new Set(), size: 0 }
246
+ unit.size += meta.getModuleInfo(id)?.code?.length ?? 1
247
+ units.set(key, unit)
248
+ unitByModule.set(id, key)
249
+ }
250
+
251
+ for (const [id, key] of unitByModule) {
252
+ for (const importedId of meta.getModuleInfo(id)?.importedIds ?? []) {
253
+ const importedKey = unitByModule.get(importedId)
254
+ if (importedKey && importedKey !== key) units.get(key)!.edges.add(importedKey)
255
+ }
256
+ }
257
+
258
+ const unitAssignments = assignBuckets(units, INITIAL_CHUNK_BUCKETS)
259
+ return new Map([...unitByModule].map(([id, key]) => [id, unitAssignments.get(key) ?? '0']))
260
+ }
261
+
262
+ function asyncComponentAssignments(
263
+ meta: Parameters<Rollup.GetManualChunk>[1],
264
+ owners: ReadonlyMap<string, readonly string[]>,
265
+ ): ReadonlyMap<string, string> {
266
+ const modulesByGroup = new Map<string, Map<string, string>>()
267
+ const unitsByGroup = new Map<string, Map<string, { edges: Set<string>, size: number }>>()
268
+
269
+ for (const id of [...meta.getModuleIds()].sort()) {
270
+ const location = moduleLocation(id)
271
+ const moduleOwners = owners.get(id) ?? []
272
+ if (isInitialOnly(moduleOwners) || location?.path[0] !== 'components' || !location.path[1])
273
+ continue
274
+ const group = `${asyncOwnerLabel(moduleOwners)}\0${location.name}`
275
+ const key = `${group}\0${location.path[1]}`
276
+ const units = unitsByGroup.get(group) ?? new Map()
277
+ const unit = units.get(key) ?? { edges: new Set<string>(), size: 0 }
278
+ unit.size += meta.getModuleInfo(id)?.code?.length ?? 1
279
+ units.set(key, unit)
280
+ unitsByGroup.set(group, units)
281
+ const modules = modulesByGroup.get(group) ?? new Map()
282
+ modules.set(id, key)
283
+ modulesByGroup.set(group, modules)
284
+ }
285
+
286
+ const assignments = new Map<string, string>()
287
+ for (const [group, modules] of modulesByGroup) {
288
+ const units = unitsByGroup.get(group)!
289
+ for (const [id, key] of modules) {
290
+ for (const importedId of meta.getModuleInfo(id)?.importedIds ?? []) {
291
+ const importedKey = modules.get(importedId)
292
+ if (importedKey && importedKey !== key) units.get(key)!.edges.add(importedKey)
293
+ }
294
+ }
295
+ const buckets = assignBuckets(units, ASYNC_COMPONENT_CHUNK_BUCKETS)
296
+ for (const [id, key] of modules) assignments.set(id, buckets.get(key) ?? '0')
297
+ }
298
+ return assignments
299
+ }
300
+
301
+ export function createAdminManualChunks(): Rollup.GetManualChunk {
302
+ let owners: ReadonlyMap<string, readonly string[]> | undefined
303
+ let initialChunks: ReadonlyMap<string, string> | undefined
304
+ let componentChunks: ReadonlyMap<string, string> | undefined
305
+ return (id, meta) => {
306
+ if (id.startsWith('\0') || isStyleModule(id)) return undefined
307
+ const location = moduleLocation(id)
308
+ if (!location) return undefined
309
+
310
+ owners ??= moduleOwners(meta)
311
+ initialChunks ??= initialChunkAssignments(meta, owners)
312
+ componentChunks ??= asyncComponentAssignments(meta, owners)
313
+ const currentOwners = owners.get(id) ?? []
314
+ // These runtime families are shared by the same feature surfaces; keeping
315
+ // them together avoids repeated module wrappers across async chunks.
316
+ if (location.name === 'vue' || location.name.startsWith('@vue/')) return 'vendor-vue-runtime'
317
+ if (location.name === 'vue-i18n' || location.name.startsWith('@intlify/'))
318
+ return 'vendor-vue-i18n'
319
+ if (location.name.startsWith('@vueuse/')) return 'vendor-vueuse'
320
+ if (location.name.startsWith('@floating-ui/') || location.name === '@sxzz/popperjs-es')
321
+ return 'vendor-positioning'
322
+ if (
323
+ location.name === 'og-table' ||
324
+ location.name === 'og-table-search' ||
325
+ location.name === 'og-search'
326
+ ) {
327
+ return 'vendor-table-suite'
328
+ }
329
+ if (isInitialOnly(currentOwners)) return `vendor-initial-${initialChunks.get(id) ?? '0'}`
330
+ if (currentOwners.includes('entry')) return undefined
331
+ if (location.name === 'element-plus') return undefined
332
+
333
+ const owner = asyncOwnerLabel(currentOwners)
334
+ const packageName = chunkName(location.name)
335
+ const [directory, moduleName] = location.path
336
+ if (splitModuleDirectories.has(directory)) {
337
+ if (directory === 'components' && moduleName)
338
+ return `vendor-${owner}-${packageName}-components-${componentChunks.get(id) ?? '0'}`
339
+ return `vendor-${owner}-${packageName}-${chunkName(directory)}`
340
+ }
341
+ return `vendor-${owner}-${packageName}`
342
+ }
343
+ }
344
+
345
+ function normalizeEmptyChunks(): Plugin {
346
+ return {
347
+ name: 'admin-normalize-empty-chunks',
348
+ renderChunk(code) {
349
+ const payload = code.replaceAll(/\/\*[\s\S]*?\*\//g, '').trim()
350
+ if (!payload || /^export\s*\{\s*\}\s*;?$/.test(payload)) return 'void 0;\n'
351
+ return null
352
+ },
353
+ generateBundle(_options, bundle) {
354
+ for (const output of Object.values(bundle)) {
355
+ const payload =
356
+ output.type === 'chunk'
357
+ ? output.code.replaceAll(/\/\*[\s\S]*?\*\//g, '').trim()
358
+ : undefined
359
+ if (output.type === 'chunk' && (!payload || /^export\s*\{\s*\}\s*;?$/.test(payload))) {
360
+ output.code = 'void 0;\n'
361
+ }
362
+ }
363
+ },
364
+ async writeBundle(_options, bundle) {
365
+ await Promise.all(
366
+ Object.values(bundle).map(async (output) => {
367
+ if (output.type !== 'chunk') return
368
+ const payload = output.code.replaceAll(/\/\*[\s\S]*?\*\//g, '').trim()
369
+ if (!payload || /^export\s*\{\s*\}\s*;?$/.test(payload))
370
+ await writeFile(resolve(process.cwd(), 'dist', output.fileName), 'void 0;\n')
371
+ }),
372
+ )
373
+ },
374
+ }
375
+ }
376
+
377
+ export function createAdminBuildPlugins(): Plugin[] {
378
+ return [normalizeEmptyChunks()]
379
+ }
380
+
381
+ export function createAdminBuildOptions(isDebugBuild: boolean): UserConfig['build'] {
382
+ return {
383
+ outDir: 'dist',
384
+ sourcemap: isDebugBuild,
385
+ minify: isDebugBuild ? false : 'esbuild',
386
+ target: 'es2020',
387
+ modulePreload: false,
388
+ rollupOptions: {
389
+ onwarn(warning, warn) {
390
+ if (warning.code === 'EMPTY_BUNDLE') return
391
+ if (
392
+ warning.code === 'INVALID_ANNOTATION' &&
393
+ warning.id?.includes('@vueuse/core/dist/index.js')
394
+ ) {
395
+ return
396
+ }
397
+ warn(warning)
398
+ },
399
+ output: {
400
+ manualChunks: createAdminManualChunks(),
401
+ onlyExplicitManualChunks: true,
402
+ },
403
+ },
404
+ }
405
+ }