@object-ui/console 3.0.0 → 3.0.2

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 (112) hide show
  1. package/dist/assets/{AuditLogPage-BQW_Xbnm.js → AuditLogPage-CyY7VZJW.js} +1 -1
  2. package/dist/assets/AuditLogPage-CyY7VZJW.js.br +0 -0
  3. package/dist/assets/AuditLogPage-CyY7VZJW.js.gz +0 -0
  4. package/dist/assets/{DashboardView-Dt-4VhH6.js → DashboardView-CikFb_lD.js} +1 -1
  5. package/dist/assets/DashboardView-CikFb_lD.js.br +0 -0
  6. package/dist/assets/DashboardView-CikFb_lD.js.gz +0 -0
  7. package/dist/assets/{ForgotPasswordPage-zr9S5vrE.js → ForgotPasswordPage-DUfjj-wh.js} +1 -1
  8. package/dist/assets/{KanbanEnhanced-BlGp--J7.js → KanbanEnhanced-CwlMhI0l.js} +1 -1
  9. package/dist/assets/KanbanEnhanced-CwlMhI0l.js.br +0 -0
  10. package/dist/assets/KanbanEnhanced-CwlMhI0l.js.gz +0 -0
  11. package/dist/assets/{KanbanImpl-B5wWMXrJ.js → KanbanImpl-BsMtStI7.js} +1 -1
  12. package/dist/assets/KanbanImpl-BsMtStI7.js.br +0 -0
  13. package/dist/assets/KanbanImpl-BsMtStI7.js.gz +0 -0
  14. package/dist/assets/{LoginPage-H688gsah.js → LoginPage-2CoFvwsL.js} +1 -1
  15. package/dist/assets/{OrgManagementPage-x3qIkxHL.js → OrgManagementPage-BJt5Iiun.js} +1 -1
  16. package/dist/assets/OrgManagementPage-BJt5Iiun.js.br +0 -0
  17. package/dist/assets/OrgManagementPage-BJt5Iiun.js.gz +0 -0
  18. package/dist/assets/{PageView-BRN1h8QD.js → PageView-CQP2T84v.js} +1 -1
  19. package/dist/assets/PageView-CQP2T84v.js.br +0 -0
  20. package/dist/assets/PageView-CQP2T84v.js.gz +0 -0
  21. package/dist/assets/{ProfilePage-DjAiGvFb.js → ProfilePage-MVUfKMrp.js} +1 -1
  22. package/dist/assets/ProfilePage-MVUfKMrp.js.br +0 -0
  23. package/dist/assets/ProfilePage-MVUfKMrp.js.gz +0 -0
  24. package/dist/assets/{RecordDetailView-Bfu7541n.js → RecordDetailView-IO2ShB0a.js} +1 -1
  25. package/dist/assets/RecordDetailView-IO2ShB0a.js.br +0 -0
  26. package/dist/assets/RecordDetailView-IO2ShB0a.js.gz +0 -0
  27. package/dist/assets/{RegisterPage-CR91Lc7x.js → RegisterPage-B9itUVYp.js} +1 -1
  28. package/dist/assets/{ReportView-CwWsv2yl.js → ReportView-BfR7RjL9.js} +1 -1
  29. package/dist/assets/ReportView-BfR7RjL9.js.br +0 -0
  30. package/dist/assets/ReportView-BfR7RjL9.js.gz +0 -0
  31. package/dist/assets/{RoleManagementPage-DnWuzxKJ.js → RoleManagementPage-BRqaeF_L.js} +1 -1
  32. package/dist/assets/RoleManagementPage-BRqaeF_L.js.br +0 -0
  33. package/dist/assets/RoleManagementPage-BRqaeF_L.js.gz +0 -0
  34. package/dist/assets/{SearchResultsPage-DBpjAlh2.js → SearchResultsPage-DaxRxhBY.js} +1 -1
  35. package/dist/assets/SearchResultsPage-DaxRxhBY.js.br +0 -0
  36. package/dist/assets/SearchResultsPage-DaxRxhBY.js.gz +0 -0
  37. package/dist/assets/{UserManagementPage-o0_K0dzR.js → UserManagementPage-DOH6ql6-.js} +1 -1
  38. package/dist/assets/UserManagementPage-DOH6ql6-.js.br +0 -0
  39. package/dist/assets/UserManagementPage-DOH6ql6-.js.gz +0 -0
  40. package/dist/assets/{data-adapter-Cn800k4a.js → data-adapter-CIsDmDZ2.js} +1 -1
  41. package/dist/assets/data-adapter-CIsDmDZ2.js.br +0 -0
  42. package/dist/assets/data-adapter-CIsDmDZ2.js.gz +0 -0
  43. package/dist/assets/{index-BjEGJcpx.js → index-5NGcxsNI.js} +7 -7
  44. package/dist/assets/index-5NGcxsNI.js.br +0 -0
  45. package/dist/assets/index-5NGcxsNI.js.gz +0 -0
  46. package/dist/assets/{infrastructure-aS2LF8OZ.js → infrastructure-Di0WqY4l.js} +1 -1
  47. package/dist/assets/infrastructure-Di0WqY4l.js.br +0 -0
  48. package/dist/assets/infrastructure-Di0WqY4l.js.gz +0 -0
  49. package/dist/assets/{plugins-core-CcBSZCjG.js → plugins-core-HuzSJDPK.js} +1 -1
  50. package/dist/assets/plugins-core-HuzSJDPK.js.br +0 -0
  51. package/dist/assets/plugins-core-HuzSJDPK.js.gz +0 -0
  52. package/dist/assets/{plugins-views-DQwkCaaO.js → plugins-views-JvEQp7xT.js} +1 -1
  53. package/dist/assets/plugins-views-JvEQp7xT.js.br +0 -0
  54. package/dist/assets/plugins-views-JvEQp7xT.js.gz +0 -0
  55. package/dist/assets/{ui-components-DVonQS7H.js → ui-components-CseD2Dpn.js} +1 -1
  56. package/dist/assets/ui-components-CseD2Dpn.js.br +0 -0
  57. package/dist/assets/ui-components-CseD2Dpn.js.gz +0 -0
  58. package/dist/assets/{ui-layout-BENIRxAF.js → ui-layout-CF_1bNSv.js} +1 -1
  59. package/dist/assets/ui-layout-CF_1bNSv.js.br +0 -0
  60. package/dist/assets/ui-layout-CF_1bNSv.js.gz +0 -0
  61. package/dist/assets/vendor-objectstack-BbgElG6O.js +37 -0
  62. package/dist/assets/vendor-objectstack-BbgElG6O.js.br +0 -0
  63. package/dist/assets/vendor-objectstack-BbgElG6O.js.gz +0 -0
  64. package/dist/index.html +24 -24
  65. package/dist/index.html.br +0 -0
  66. package/dist/index.html.gz +0 -0
  67. package/dist/stats.html +1 -1
  68. package/package.json +55 -52
  69. package/plugin.d.ts +44 -0
  70. package/plugin.js +62 -0
  71. package/plugin.ts +9 -118
  72. package/dist/assets/AuditLogPage-BQW_Xbnm.js.br +0 -0
  73. package/dist/assets/AuditLogPage-BQW_Xbnm.js.gz +0 -0
  74. package/dist/assets/DashboardView-Dt-4VhH6.js.br +0 -0
  75. package/dist/assets/DashboardView-Dt-4VhH6.js.gz +0 -0
  76. package/dist/assets/KanbanEnhanced-BlGp--J7.js.br +0 -0
  77. package/dist/assets/KanbanEnhanced-BlGp--J7.js.gz +0 -0
  78. package/dist/assets/KanbanImpl-B5wWMXrJ.js.br +0 -0
  79. package/dist/assets/KanbanImpl-B5wWMXrJ.js.gz +0 -0
  80. package/dist/assets/OrgManagementPage-x3qIkxHL.js.br +0 -0
  81. package/dist/assets/OrgManagementPage-x3qIkxHL.js.gz +0 -0
  82. package/dist/assets/PageView-BRN1h8QD.js.br +0 -0
  83. package/dist/assets/PageView-BRN1h8QD.js.gz +0 -0
  84. package/dist/assets/ProfilePage-DjAiGvFb.js.br +0 -0
  85. package/dist/assets/ProfilePage-DjAiGvFb.js.gz +0 -0
  86. package/dist/assets/RecordDetailView-Bfu7541n.js.br +0 -0
  87. package/dist/assets/RecordDetailView-Bfu7541n.js.gz +0 -0
  88. package/dist/assets/ReportView-CwWsv2yl.js.br +0 -0
  89. package/dist/assets/ReportView-CwWsv2yl.js.gz +0 -0
  90. package/dist/assets/RoleManagementPage-DnWuzxKJ.js.br +0 -0
  91. package/dist/assets/RoleManagementPage-DnWuzxKJ.js.gz +0 -0
  92. package/dist/assets/SearchResultsPage-DBpjAlh2.js.br +0 -0
  93. package/dist/assets/SearchResultsPage-DBpjAlh2.js.gz +0 -0
  94. package/dist/assets/UserManagementPage-o0_K0dzR.js.br +0 -0
  95. package/dist/assets/UserManagementPage-o0_K0dzR.js.gz +0 -0
  96. package/dist/assets/data-adapter-Cn800k4a.js.br +0 -0
  97. package/dist/assets/data-adapter-Cn800k4a.js.gz +0 -0
  98. package/dist/assets/index-BjEGJcpx.js.br +0 -0
  99. package/dist/assets/index-BjEGJcpx.js.gz +0 -0
  100. package/dist/assets/infrastructure-aS2LF8OZ.js.br +0 -0
  101. package/dist/assets/infrastructure-aS2LF8OZ.js.gz +0 -0
  102. package/dist/assets/plugins-core-CcBSZCjG.js.br +0 -0
  103. package/dist/assets/plugins-core-CcBSZCjG.js.gz +0 -0
  104. package/dist/assets/plugins-views-DQwkCaaO.js.br +0 -0
  105. package/dist/assets/plugins-views-DQwkCaaO.js.gz +0 -0
  106. package/dist/assets/ui-components-DVonQS7H.js.br +0 -0
  107. package/dist/assets/ui-components-DVonQS7H.js.gz +0 -0
  108. package/dist/assets/ui-layout-BENIRxAF.js.br +0 -0
  109. package/dist/assets/ui-layout-BENIRxAF.js.gz +0 -0
  110. package/dist/assets/vendor-objectstack-DqojdwYW.js +0 -37
  111. package/dist/assets/vendor-objectstack-DqojdwYW.js.br +0 -0
  112. package/dist/assets/vendor-objectstack-DqojdwYW.js.gz +0 -0
package/package.json CHANGED
@@ -1,64 +1,31 @@
1
1
  {
2
2
  "name": "@object-ui/console",
3
- "version": "3.0.0",
3
+ "version": "3.0.2",
4
4
  "description": "ObjectStack Console - The standard runtime UI for ObjectStack applications",
5
5
  "type": "module",
6
- "main": "./plugin.ts",
6
+ "main": "./plugin.js",
7
+ "types": "./plugin.d.ts",
7
8
  "exports": {
8
9
  ".": {
9
- "import": "./plugin.ts",
10
- "default": "./plugin.ts"
10
+ "types": "./plugin.d.ts",
11
+ "import": "./plugin.js",
12
+ "default": "./plugin.js"
11
13
  }
12
14
  },
13
15
  "files": [
14
16
  "dist",
15
- "plugin.ts"
17
+ "plugin.ts",
18
+ "plugin.js",
19
+ "plugin.d.ts"
16
20
  ],
17
- "dependencies": {
18
- "@objectstack/client": "^3.0.2",
19
- "@objectstack/driver-memory": "^3.0.2",
20
- "@objectstack/objectql": "^3.0.2",
21
- "@objectstack/plugin-msw": "^3.0.2",
22
- "@objectstack/runtime": "^3.0.2",
23
- "@objectstack/spec": "^3.0.2",
24
- "lucide-react": "^0.563.0",
25
- "react": "19.2.4",
26
- "react-dom": "19.2.4",
27
- "react-router-dom": "^7.13.0",
28
- "sonner": "^2.0.7",
29
- "@object-ui/auth": "3.0.0",
30
- "@object-ui/collaboration": "3.0.0",
31
- "@object-ui/components": "3.0.0",
32
- "@object-ui/core": "3.0.0",
33
- "@object-ui/data-objectstack": "3.0.0",
34
- "@object-ui/example-crm": "1.0.0",
35
- "@object-ui/example-kitchen-sink": "1.0.0",
36
- "@object-ui/example-todo": "1.0.0",
37
- "@object-ui/fields": "3.0.0",
38
- "@object-ui/i18n": "3.0.0",
39
- "@object-ui/layout": "3.0.0",
40
- "@object-ui/mobile": "3.0.0",
41
- "@object-ui/permissions": "3.0.0",
42
- "@object-ui/plugin-calendar": "3.0.0",
43
- "@object-ui/plugin-charts": "3.0.0",
44
- "@object-ui/plugin-dashboard": "3.0.0",
45
- "@object-ui/plugin-designer": "3.0.0",
46
- "@object-ui/plugin-detail": "3.0.0",
47
- "@object-ui/plugin-form": "3.0.0",
48
- "@object-ui/plugin-gantt": "3.0.0",
49
- "@object-ui/plugin-grid": "3.0.0",
50
- "@object-ui/plugin-kanban": "3.0.0",
51
- "@object-ui/plugin-list": "3.0.0",
52
- "@object-ui/plugin-map": "3.0.0",
53
- "@object-ui/plugin-markdown": "3.0.0",
54
- "@object-ui/plugin-report": "3.0.0",
55
- "@object-ui/plugin-timeline": "3.0.0",
56
- "@object-ui/plugin-view": "3.0.0",
57
- "@object-ui/react": "3.0.0",
58
- "@object-ui/types": "3.0.0"
59
- },
60
21
  "devDependencies": {
61
- "@objectstack/cli": "^3.0.2",
22
+ "@objectstack/cli": "^3.0.4",
23
+ "@objectstack/client": "^3.0.4",
24
+ "@objectstack/driver-memory": "^3.0.4",
25
+ "@objectstack/objectql": "^3.0.4",
26
+ "@objectstack/plugin-msw": "^3.0.4",
27
+ "@objectstack/runtime": "^3.0.4",
28
+ "@objectstack/spec": "^3.0.4",
62
29
  "@tailwindcss/postcss": "^4.1.18",
63
30
  "@testing-library/jest-dom": "^6.9.1",
64
31
  "@testing-library/react": "^16.3.2",
@@ -70,12 +37,47 @@
70
37
  "@vitest/ui": "^4.0.18",
71
38
  "autoprefixer": "^10.4.24",
72
39
  "happy-dom": "^20.6.1",
40
+ "lucide-react": "^0.563.0",
73
41
  "msw": "^2.12.10",
74
42
  "postcss": "^8.5.6",
43
+ "react": "19.2.4",
44
+ "react-dom": "19.2.4",
45
+ "react-router-dom": "^7.13.0",
46
+ "sonner": "^2.0.7",
75
47
  "tailwindcss": "^4.1.18",
76
48
  "typescript": "^5.9.3",
77
49
  "vite": "^6.4.1",
78
- "vitest": "^4.0.18"
50
+ "vitest": "^4.0.18",
51
+ "@object-ui/auth": "3.0.2",
52
+ "@object-ui/collaboration": "3.0.2",
53
+ "@object-ui/components": "3.0.2",
54
+ "@object-ui/core": "3.0.2",
55
+ "@object-ui/data-objectstack": "3.0.2",
56
+ "@object-ui/example-crm": "1.0.0",
57
+ "@object-ui/example-kitchen-sink": "1.0.0",
58
+ "@object-ui/example-todo": "1.0.0",
59
+ "@object-ui/fields": "3.0.2",
60
+ "@object-ui/i18n": "3.0.2",
61
+ "@object-ui/layout": "3.0.2",
62
+ "@object-ui/mobile": "3.0.2",
63
+ "@object-ui/permissions": "3.0.2",
64
+ "@object-ui/plugin-calendar": "3.0.2",
65
+ "@object-ui/plugin-charts": "3.0.2",
66
+ "@object-ui/plugin-dashboard": "3.0.2",
67
+ "@object-ui/plugin-designer": "3.0.2",
68
+ "@object-ui/plugin-detail": "3.0.2",
69
+ "@object-ui/plugin-form": "3.0.2",
70
+ "@object-ui/plugin-gantt": "3.0.2",
71
+ "@object-ui/plugin-grid": "3.0.2",
72
+ "@object-ui/plugin-kanban": "3.0.2",
73
+ "@object-ui/plugin-list": "3.0.2",
74
+ "@object-ui/plugin-map": "3.0.2",
75
+ "@object-ui/plugin-markdown": "3.0.2",
76
+ "@object-ui/plugin-report": "3.0.2",
77
+ "@object-ui/plugin-timeline": "3.0.2",
78
+ "@object-ui/plugin-view": "3.0.2",
79
+ "@object-ui/react": "3.0.2",
80
+ "@object-ui/types": "3.0.2"
79
81
  },
80
82
  "msw": {
81
83
  "workerDirectory": [
@@ -87,8 +89,9 @@
87
89
  "dev": "pnpm msw:init && vite",
88
90
  "start": "tsx ../../node_modules/@objectstack/cli/bin/objectstack.js serve objectstack.config.ts",
89
91
  "start:mock": "pnpm msw:init && vite preview",
90
- "build": "pnpm msw:init && tsc && VITE_USE_MOCK_SERVER=false vite build",
91
- "build:vercel": "pnpm msw:init && tsc && VITE_USE_MOCK_SERVER=true vite build",
92
+ "build:plugin": "tsc -p tsconfig.plugin.json",
93
+ "build": "pnpm msw:init && tsc && VITE_USE_MOCK_SERVER=false vite build && pnpm build:plugin",
94
+ "build:vercel": "pnpm msw:init && tsc && VITE_USE_MOCK_SERVER=true vite build && pnpm build:plugin",
92
95
  "build:analyze": "pnpm build && echo 'Bundle analysis available at dist/stats.html'",
93
96
  "preview": "vite preview",
94
97
  "test": "vitest run",
package/plugin.d.ts ADDED
@@ -0,0 +1,44 @@
1
+ /**
2
+ * ObjectStack Console Plugin
3
+ *
4
+ * Serves the pre-built Console SPA as a static UI plugin.
5
+ * HonoServerPlugin auto-discovers this plugin via `type: 'ui-plugin'`
6
+ * and mounts it at `/<slug>` (i.e. `/console`).
7
+ *
8
+ * The SPA must be built with the matching base path:
9
+ * VITE_BASE_PATH=/console/ pnpm build
10
+ *
11
+ * Usage in any ObjectStack application:
12
+ *
13
+ * import { ConsolePlugin } from '@object-ui/console';
14
+ *
15
+ * export default {
16
+ * plugins: [
17
+ * new HonoServerPlugin({ port: 3000 }),
18
+ * new ConsolePlugin(),
19
+ * ],
20
+ * };
21
+ *
22
+ * @see https://github.com/objectstack-ai/objectui
23
+ */
24
+ /** Absolute path to the built SPA assets (dist/) */
25
+ export declare const staticPath: string;
26
+ export declare class ConsolePlugin {
27
+ readonly name = "@object-ui/console";
28
+ readonly version = "1.0.0";
29
+ readonly type: "ui-plugin";
30
+ readonly slug = "console";
31
+ readonly staticPath: string;
32
+ readonly default = true;
33
+ readonly description = "ObjectStack Console - The standard runtime UI for ObjectStack applications";
34
+ readonly metadata: {
35
+ author: string;
36
+ license: string;
37
+ homepage: string;
38
+ repository: string;
39
+ capabilities: string[];
40
+ };
41
+ init(): void;
42
+ start(_ctx: any): Promise<void>;
43
+ }
44
+ export default ConsolePlugin;
package/plugin.js ADDED
@@ -0,0 +1,62 @@
1
+ /**
2
+ * ObjectStack Console Plugin
3
+ *
4
+ * Serves the pre-built Console SPA as a static UI plugin.
5
+ * HonoServerPlugin auto-discovers this plugin via `type: 'ui-plugin'`
6
+ * and mounts it at `/<slug>` (i.e. `/console`).
7
+ *
8
+ * The SPA must be built with the matching base path:
9
+ * VITE_BASE_PATH=/console/ pnpm build
10
+ *
11
+ * Usage in any ObjectStack application:
12
+ *
13
+ * import { ConsolePlugin } from '@object-ui/console';
14
+ *
15
+ * export default {
16
+ * plugins: [
17
+ * new HonoServerPlugin({ port: 3000 }),
18
+ * new ConsolePlugin(),
19
+ * ],
20
+ * };
21
+ *
22
+ * @see https://github.com/objectstack-ai/objectui
23
+ */
24
+ import { fileURLToPath } from 'url';
25
+ import { dirname, resolve } from 'path';
26
+ const __filename = fileURLToPath(import.meta.url);
27
+ const __dirname = dirname(__filename);
28
+ /** Absolute path to the built SPA assets (dist/) */
29
+ export const staticPath = resolve(__dirname, 'dist');
30
+ export class ConsolePlugin {
31
+ constructor() {
32
+ this.name = '@object-ui/console';
33
+ this.version = '1.0.0';
34
+ this.type = 'ui-plugin';
35
+ this.slug = 'console';
36
+ this.staticPath = staticPath;
37
+ this.default = true;
38
+ this.description = 'ObjectStack Console - The standard runtime UI for ObjectStack applications';
39
+ this.metadata = {
40
+ author: 'ObjectUI Team',
41
+ license: 'MIT',
42
+ homepage: 'https://www.objectui.org',
43
+ repository: 'https://github.com/objectstack-ai/objectui',
44
+ capabilities: [
45
+ 'ui-rendering',
46
+ 'crud-operations',
47
+ 'multi-app-support',
48
+ 'dynamic-navigation',
49
+ 'theme-support',
50
+ ],
51
+ };
52
+ }
53
+ init() {
54
+ // No initialization needed — HonoServerPlugin handles static serving & SPA fallback
55
+ }
56
+ async start(_ctx) {
57
+ // Static file serving and SPA fallback are handled automatically by
58
+ // HonoServerPlugin's auto-discovery (type: 'ui-plugin', slug: 'console').
59
+ // No custom route registration needed.
60
+ }
61
+ }
62
+ export default ConsolePlugin;
package/plugin.ts CHANGED
@@ -2,12 +2,11 @@
2
2
  * ObjectStack Console Plugin
3
3
  *
4
4
  * Serves the pre-built Console SPA as a static UI plugin.
5
- * The mount path is auto-detected from the built assets (VITE_BASE_PATH
6
- * at build time determines asset prefixes and React Router basename).
5
+ * HonoServerPlugin auto-discovers this plugin via `type: 'ui-plugin'`
6
+ * and mounts it at `/<slug>` (i.e. `/console`).
7
7
  *
8
- * Build commands:
9
- * pnpm build → base '/' → mount at /
10
- * VITE_BASE_PATH=/console/ pnpm build → base '/console' → mount at /console
8
+ * The SPA must be built with the matching base path:
9
+ * VITE_BASE_PATH=/console/ pnpm build
11
10
  *
12
11
  * Usage in any ObjectStack application:
13
12
  *
@@ -25,7 +24,6 @@
25
24
 
26
25
  import { fileURLToPath } from 'url';
27
26
  import { dirname, resolve } from 'path';
28
- import { existsSync, readFileSync } from 'fs';
29
27
 
30
28
  const __filename = fileURLToPath(import.meta.url);
31
29
  const __dirname = dirname(__filename);
@@ -33,23 +31,6 @@ const __dirname = dirname(__filename);
33
31
  /** Absolute path to the built SPA assets (dist/) */
34
32
  export const staticPath = resolve(__dirname, 'dist');
35
33
 
36
- /**
37
- * Detect the base path baked into dist/index.html at build time.
38
- *
39
- * Vite prefixes all asset URLs with the `base` config value.
40
- * We parse `<script … src="/console/assets/…">` to recover it.
41
- * Falls back to '/' when dist is missing or no prefix is found.
42
- */
43
- function detectBasePath(distDir: string): string {
44
- const indexPath = resolve(distDir, 'index.html');
45
- if (!existsSync(indexPath)) return '/';
46
- const html = readFileSync(indexPath, 'utf-8');
47
- // Match src="/console/assets/..." or href="/console/assets/..."
48
- const match = html.match(/(?:src|href)="(\/[^"]*?)\/assets\//);
49
- if (match?.[1]) return match[1]; // e.g. '/console'
50
- return '/';
51
- }
52
-
53
34
  export class ConsolePlugin {
54
35
  readonly name = '@object-ui/console';
55
36
  readonly version = '1.0.0';
@@ -74,103 +55,13 @@ export class ConsolePlugin {
74
55
  };
75
56
 
76
57
  init() {
77
- // No initialization needed
58
+ // No initialization needed — HonoServerPlugin handles static serving & SPA fallback
78
59
  }
79
60
 
80
- async start(ctx: any) {
81
- const httpService = ctx.getService?.('http-server') || ctx.getService?.('http.server');
82
- if (!httpService || typeof httpService.getRawApp !== 'function') {
83
- const logger = ctx.logger || console;
84
- logger.warn('[Console] HTTP server not available. SPA routes not registered.');
85
- return;
86
- }
87
-
88
- const app = httpService.getRawApp();
89
- const logger = ctx.logger || console;
90
- const distDir = staticPath;
91
-
92
- if (!existsSync(distDir)) {
93
- logger.warn(`[Console] dist/ not found at ${distDir}. Run "pnpm build" first.`);
94
- return;
95
- }
96
-
97
- // Auto-detect mount path from the build output
98
- const basePath = detectBasePath(distDir);
99
- const isRoot = basePath === '/';
100
-
101
- // Try to use @hono/node-server/serve-static for efficient file serving
102
- let serveStaticFn: any;
103
- try {
104
- const mod = await import('@hono/node-server/serve-static');
105
- serveStaticFn = mod.serveStatic;
106
- } catch {
107
- // Fallback: manual file serving if @hono/node-server not available
108
- serveStaticFn = null;
109
- }
110
-
111
- const routePattern = isRoot ? '/*' : `${basePath}/*`;
112
- const stripPrefix = isRoot
113
- ? (p: string) => p
114
- : (p: string) => p.replace(new RegExp(`^${basePath}`), '');
115
-
116
- if (serveStaticFn) {
117
- // Serve static assets
118
- app.use(routePattern, serveStaticFn({
119
- root: distDir,
120
- rewriteRequestPath: stripPrefix,
121
- }));
122
-
123
- // SPA fallback: any non-file route → dist/index.html
124
- app.get(routePattern, serveStaticFn({
125
- root: distDir,
126
- rewriteRequestPath: () => '/index.html',
127
- }));
128
- } else {
129
- // Manual fallback when serveStatic is unavailable
130
- const indexPath = resolve(distDir, 'index.html');
131
-
132
- app.get(routePattern, async (c: any) => {
133
- // Skip API routes
134
- if (c.req.path.startsWith('/api')) return c.text('Not Found', 404);
135
-
136
- const reqPath = stripPrefix(c.req.path);
137
- const filePath = resolve(distDir, reqPath.replace(/^\//, ''));
138
-
139
- // Try to serve the exact file first
140
- if (existsSync(filePath) && !filePath.endsWith('/')) {
141
- const ext = filePath.split('.').pop() || '';
142
- const mimeTypes: Record<string, string> = {
143
- js: 'application/javascript',
144
- css: 'text/css',
145
- json: 'application/json',
146
- html: 'text/html',
147
- svg: 'image/svg+xml',
148
- png: 'image/png',
149
- ico: 'image/x-icon',
150
- woff2: 'font/woff2',
151
- woff: 'font/woff',
152
- gz: 'application/gzip',
153
- br: 'application/x-brotli',
154
- };
155
- const contentType = mimeTypes[ext] || 'application/octet-stream';
156
- const content = readFileSync(filePath);
157
- return c.body(content, 200, { 'Content-Type': contentType });
158
- }
159
-
160
- // SPA fallback: return index.html
161
- if (existsSync(indexPath)) {
162
- return c.html(readFileSync(indexPath, 'utf-8'));
163
- }
164
- return c.text('Console not built. Run: pnpm --filter @object-ui/console build', 404);
165
- });
166
- }
167
-
168
- // Only redirect / → basePath when NOT mounted at root
169
- if (!isRoot) {
170
- app.get('/', (c: any) => c.redirect(basePath));
171
- }
172
-
173
- logger.info(`[Console] SPA mounted at ${isRoot ? '/' : basePath}`);
61
+ async start(_ctx: any) {
62
+ // Static file serving and SPA fallback are handled automatically by
63
+ // HonoServerPlugin's auto-discovery (type: 'ui-plugin', slug: 'console').
64
+ // No custom route registration needed.
174
65
  }
175
66
  }
176
67
 
Binary file
Binary file
Binary file
Binary file