@gxp-dev/tools 2.0.63 → 2.0.65

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 (182) hide show
  1. package/README.md +32 -31
  2. package/bin/gx-devtools.js +74 -54
  3. package/bin/lib/cli.js +23 -21
  4. package/bin/lib/commands/add-dependency.js +366 -325
  5. package/bin/lib/commands/assets.js +137 -139
  6. package/bin/lib/commands/build.js +169 -174
  7. package/bin/lib/commands/datastore.js +181 -183
  8. package/bin/lib/commands/dev.js +127 -131
  9. package/bin/lib/commands/extensions.js +147 -149
  10. package/bin/lib/commands/extract-config.js +73 -67
  11. package/bin/lib/commands/index.js +12 -12
  12. package/bin/lib/commands/init.js +342 -240
  13. package/bin/lib/commands/publish.js +69 -75
  14. package/bin/lib/commands/socket.js +69 -69
  15. package/bin/lib/commands/ssl.js +14 -14
  16. package/bin/lib/constants.js +10 -24
  17. package/bin/lib/tui/App.tsx +761 -705
  18. package/bin/lib/tui/components/AIPanel.tsx +191 -171
  19. package/bin/lib/tui/components/CommandInput.tsx +394 -343
  20. package/bin/lib/tui/components/GeminiPanel.tsx +175 -151
  21. package/bin/lib/tui/components/Header.tsx +23 -21
  22. package/bin/lib/tui/components/LogPanel.tsx +244 -220
  23. package/bin/lib/tui/components/TabBar.tsx +50 -48
  24. package/bin/lib/tui/components/WelcomeScreen.tsx +126 -71
  25. package/bin/lib/tui/index.tsx +37 -39
  26. package/bin/lib/tui/services/AIService.ts +518 -462
  27. package/bin/lib/tui/services/ExtensionService.ts +140 -129
  28. package/bin/lib/tui/services/GeminiService.ts +367 -337
  29. package/bin/lib/tui/services/ServiceManager.ts +344 -322
  30. package/bin/lib/tui/services/SocketService.ts +168 -168
  31. package/bin/lib/tui/services/ViteService.ts +88 -88
  32. package/bin/lib/tui/services/index.ts +47 -22
  33. package/bin/lib/utils/ai-scaffold.js +291 -280
  34. package/bin/lib/utils/extract-config.js +157 -140
  35. package/bin/lib/utils/files.js +82 -86
  36. package/bin/lib/utils/index.js +7 -7
  37. package/bin/lib/utils/paths.js +34 -34
  38. package/bin/lib/utils/prompts.js +194 -169
  39. package/bin/lib/utils/ssl.js +79 -81
  40. package/browser-extensions/README.md +0 -1
  41. package/browser-extensions/chrome/background.js +244 -237
  42. package/browser-extensions/chrome/content.js +32 -29
  43. package/browser-extensions/chrome/devtools.html +7 -7
  44. package/browser-extensions/chrome/devtools.js +19 -19
  45. package/browser-extensions/chrome/inspector.js +802 -767
  46. package/browser-extensions/chrome/manifest.json +71 -63
  47. package/browser-extensions/chrome/panel.html +674 -636
  48. package/browser-extensions/chrome/panel.js +722 -712
  49. package/browser-extensions/chrome/popup.html +586 -543
  50. package/browser-extensions/chrome/popup.js +282 -244
  51. package/browser-extensions/chrome/rules.json +1 -1
  52. package/browser-extensions/chrome/test-chrome.html +216 -136
  53. package/browser-extensions/chrome/test-mixed-content.html +284 -189
  54. package/browser-extensions/chrome/test-uri-pattern.html +221 -198
  55. package/browser-extensions/firefox/README.md +9 -6
  56. package/browser-extensions/firefox/background.js +221 -218
  57. package/browser-extensions/firefox/content.js +55 -52
  58. package/browser-extensions/firefox/debug-errors.html +386 -228
  59. package/browser-extensions/firefox/debug-https.html +153 -105
  60. package/browser-extensions/firefox/devtools.html +7 -7
  61. package/browser-extensions/firefox/devtools.js +23 -20
  62. package/browser-extensions/firefox/inspector.js +802 -767
  63. package/browser-extensions/firefox/manifest.json +68 -68
  64. package/browser-extensions/firefox/panel.html +674 -636
  65. package/browser-extensions/firefox/panel.js +722 -712
  66. package/browser-extensions/firefox/popup.html +572 -535
  67. package/browser-extensions/firefox/popup.js +281 -236
  68. package/browser-extensions/firefox/test-gramercy.html +170 -125
  69. package/browser-extensions/firefox/test-imports.html +59 -55
  70. package/browser-extensions/firefox/test-masking.html +231 -140
  71. package/browser-extensions/firefox/test-uri-pattern.html +221 -198
  72. package/dist/tui/App.d.ts +1 -1
  73. package/dist/tui/App.d.ts.map +1 -1
  74. package/dist/tui/App.js +154 -150
  75. package/dist/tui/App.js.map +1 -1
  76. package/dist/tui/components/AIPanel.d.ts.map +1 -1
  77. package/dist/tui/components/AIPanel.js +42 -35
  78. package/dist/tui/components/AIPanel.js.map +1 -1
  79. package/dist/tui/components/CommandInput.d.ts +1 -1
  80. package/dist/tui/components/CommandInput.d.ts.map +1 -1
  81. package/dist/tui/components/CommandInput.js +92 -62
  82. package/dist/tui/components/CommandInput.js.map +1 -1
  83. package/dist/tui/components/GeminiPanel.d.ts.map +1 -1
  84. package/dist/tui/components/GeminiPanel.js +37 -30
  85. package/dist/tui/components/GeminiPanel.js.map +1 -1
  86. package/dist/tui/components/Header.d.ts.map +1 -1
  87. package/dist/tui/components/Header.js +1 -1
  88. package/dist/tui/components/Header.js.map +1 -1
  89. package/dist/tui/components/LogPanel.d.ts +1 -1
  90. package/dist/tui/components/LogPanel.d.ts.map +1 -1
  91. package/dist/tui/components/LogPanel.js +26 -24
  92. package/dist/tui/components/LogPanel.js.map +1 -1
  93. package/dist/tui/components/TabBar.d.ts +2 -2
  94. package/dist/tui/components/TabBar.d.ts.map +1 -1
  95. package/dist/tui/components/TabBar.js +11 -11
  96. package/dist/tui/components/TabBar.js.map +1 -1
  97. package/dist/tui/components/WelcomeScreen.d.ts.map +1 -1
  98. package/dist/tui/components/WelcomeScreen.js +6 -6
  99. package/dist/tui/components/WelcomeScreen.js.map +1 -1
  100. package/dist/tui/index.d.ts.map +1 -1
  101. package/dist/tui/index.js +8 -8
  102. package/dist/tui/index.js.map +1 -1
  103. package/dist/tui/services/AIService.d.ts +2 -2
  104. package/dist/tui/services/AIService.d.ts.map +1 -1
  105. package/dist/tui/services/AIService.js +165 -125
  106. package/dist/tui/services/AIService.js.map +1 -1
  107. package/dist/tui/services/ExtensionService.d.ts +1 -1
  108. package/dist/tui/services/ExtensionService.d.ts.map +1 -1
  109. package/dist/tui/services/ExtensionService.js +33 -26
  110. package/dist/tui/services/ExtensionService.js.map +1 -1
  111. package/dist/tui/services/GeminiService.d.ts +1 -1
  112. package/dist/tui/services/GeminiService.d.ts.map +1 -1
  113. package/dist/tui/services/GeminiService.js +87 -76
  114. package/dist/tui/services/GeminiService.js.map +1 -1
  115. package/dist/tui/services/ServiceManager.d.ts +3 -3
  116. package/dist/tui/services/ServiceManager.d.ts.map +1 -1
  117. package/dist/tui/services/ServiceManager.js +72 -58
  118. package/dist/tui/services/ServiceManager.js.map +1 -1
  119. package/dist/tui/services/SocketService.d.ts.map +1 -1
  120. package/dist/tui/services/SocketService.js +32 -32
  121. package/dist/tui/services/SocketService.js.map +1 -1
  122. package/dist/tui/services/ViteService.d.ts.map +1 -1
  123. package/dist/tui/services/ViteService.js +26 -28
  124. package/dist/tui/services/ViteService.js.map +1 -1
  125. package/dist/tui/services/index.d.ts +6 -6
  126. package/dist/tui/services/index.d.ts.map +1 -1
  127. package/dist/tui/services/index.js +6 -6
  128. package/dist/tui/services/index.js.map +1 -1
  129. package/mcp/gxp-api-server.js +83 -81
  130. package/package.json +109 -93
  131. package/runtime/PortalContainer.vue +258 -234
  132. package/runtime/dev-tools/DevToolsModal.vue +153 -155
  133. package/runtime/dev-tools/LayoutSwitcher.vue +144 -140
  134. package/runtime/dev-tools/MockDataEditor.vue +456 -433
  135. package/runtime/dev-tools/SocketSimulator.vue +379 -371
  136. package/runtime/dev-tools/StoreInspector.vue +517 -455
  137. package/runtime/dev-tools/index.js +5 -5
  138. package/runtime/fallback-layouts/PrivateLayout.vue +2 -2
  139. package/runtime/fallback-layouts/PublicLayout.vue +2 -2
  140. package/runtime/fallback-layouts/SystemLayout.vue +2 -2
  141. package/runtime/gxpStringsPlugin.js +159 -134
  142. package/runtime/index.html +17 -19
  143. package/runtime/main.js +24 -22
  144. package/runtime/mock-api/auth-middleware.js +15 -15
  145. package/runtime/mock-api/image-generator.js +46 -46
  146. package/runtime/mock-api/index.js +55 -55
  147. package/runtime/mock-api/response-generator.js +116 -105
  148. package/runtime/mock-api/route-generator.js +107 -84
  149. package/runtime/mock-api/socket-triggers.js +94 -93
  150. package/runtime/mock-api/spec-loader.js +79 -80
  151. package/runtime/package.json +3 -0
  152. package/runtime/server.js +68 -68
  153. package/runtime/stores/gxpPortalConfigStore.js +204 -186
  154. package/runtime/stores/index.js +2 -2
  155. package/runtime/vite-inspector-plugin.js +858 -707
  156. package/runtime/vite-source-tracker-plugin.js +132 -113
  157. package/runtime/vite.config.js +191 -139
  158. package/scripts/launch-chrome.js +41 -41
  159. package/scripts/pack-chrome.js +38 -39
  160. package/socket-events/AiSessionMessageCreated.json +17 -17
  161. package/socket-events/SocialStreamPostCreated.json +23 -23
  162. package/socket-events/SocialStreamPostVariantCompleted.json +22 -22
  163. package/template/.claude/agents/gxp-developer.md +100 -99
  164. package/template/.claude/settings.json +7 -7
  165. package/template/AGENTS.md +30 -23
  166. package/template/GEMINI.md +20 -20
  167. package/template/README.md +70 -53
  168. package/template/app-manifest.json +2 -4
  169. package/template/configuration.json +10 -10
  170. package/template/default-styling.css +1 -1
  171. package/template/index.html +18 -20
  172. package/template/main.js +24 -22
  173. package/template/src/DemoPage.vue +415 -362
  174. package/template/src/Plugin.vue +76 -85
  175. package/template/src/stores/index.js +3 -3
  176. package/template/src/stores/test-data.json +164 -172
  177. package/template/theme-layouts/AdditionalStyling.css +50 -50
  178. package/template/theme-layouts/PrivateLayout.vue +8 -12
  179. package/template/theme-layouts/PublicLayout.vue +8 -12
  180. package/template/theme-layouts/SystemLayout.vue +8 -12
  181. package/template/vite.extend.js +45 -0
  182. package/template/vite.config.js +0 -409
@@ -1,409 +0,0 @@
1
- import { defineConfig, loadEnv } from "vite";
2
- import vue from "@vitejs/plugin-vue";
3
- import path from "path";
4
- import fs from "fs";
5
- import externalGlobals from "rollup-plugin-external-globals";
6
-
7
- // Environment URL configuration for API proxy
8
- const ENVIRONMENT_URLS = {
9
- production: "https://api.gramercy.cloud",
10
- staging: "https://api.efz-staging.env.eventfinity.app",
11
- testing: "https://api.zenith-develop-testing.env.eventfinity.app",
12
- develop: "https://api.zenith-develop.env.eventfinity.app",
13
- local: "https://dashboard.eventfinity.test",
14
- };
15
-
16
- /**
17
- * Get the API proxy target URL based on environment
18
- */
19
- function getApiProxyTarget(env) {
20
- const apiEnv = env.API_ENV || "mock";
21
-
22
- // Custom URL takes precedence
23
- if (env.API_BASE_URL) {
24
- return env.API_BASE_URL;
25
- }
26
-
27
- // Mock uses local mock-api server (no proxy needed, handled separately)
28
- if (apiEnv === "mock") {
29
- return null;
30
- }
31
-
32
- // Look up environment URL
33
- return ENVIRONMENT_URLS[apiEnv] || ENVIRONMENT_URLS.production;
34
- }
35
-
36
- /**
37
- * Get the library name from package.json
38
- */
39
- function getLibName() {
40
- try {
41
- const packageJsonPath = path.resolve(process.cwd(), "package.json");
42
- if (fs.existsSync(packageJsonPath)) {
43
- const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
44
- // Convert package name to a valid JS identifier
45
- // e.g., "@company/my-plugin" -> "MyPlugin"
46
- const name = packageJson.name || "Plugin";
47
- return name
48
- .replace(/[@\/\-]/g, " ")
49
- .replace(/\b\w/g, (l) => l.toUpperCase())
50
- .replace(/\s/g, "");
51
- }
52
- } catch (error) {
53
- console.warn("Could not read package.json, using default lib name");
54
- }
55
- return "Plugin";
56
- }
57
-
58
- /**
59
- * Setup HTTPS configuration if certificates are available
60
- */
61
- function getHttpsConfig(env) {
62
- const useHttps = env.USE_HTTPS === "true";
63
- const certPath = env.CERT_PATH;
64
- const keyPath = env.KEY_PATH;
65
-
66
- if (!useHttps || !certPath || !keyPath) {
67
- return false;
68
- }
69
-
70
- // Resolve paths relative to project root
71
- const resolvedCertPath = path.resolve(process.cwd(), certPath);
72
- const resolvedKeyPath = path.resolve(process.cwd(), keyPath);
73
-
74
- // Check if certificate files exist
75
- if (!fs.existsSync(resolvedCertPath) || !fs.existsSync(resolvedKeyPath)) {
76
- console.warn("⚠ SSL certificate files not found, falling back to HTTP");
77
- return false;
78
- }
79
-
80
- try {
81
- return {
82
- key: fs.readFileSync(resolvedKeyPath),
83
- cert: fs.readFileSync(resolvedCertPath),
84
- };
85
- } catch (error) {
86
- console.warn("⚠ Failed to read SSL certificates, falling back to HTTP");
87
- return false;
88
- }
89
- }
90
-
91
- /**
92
- * Find the gx-devtools package directory (works for both local and global installs)
93
- */
94
- function findToolkitPath() {
95
- const packageName = "@gxp-dev/tools";
96
-
97
- // Try local node_modules first
98
- const localPath = path.resolve(process.cwd(), "node_modules", packageName);
99
- if (fs.existsSync(localPath)) {
100
- return localPath;
101
- }
102
-
103
- // Try to find via require.resolve
104
- try {
105
- const pkgPath = require.resolve(`${packageName}/package.json`);
106
- return path.dirname(pkgPath);
107
- } catch (e) {
108
- // Fallback: assume we're in the toolkit itself during development
109
- return process.cwd();
110
- }
111
- }
112
-
113
- // Dynamically import the inspector plugin from the toolkit
114
- let gxpInspectorPlugin;
115
- let gxpSourceTrackerPlugin;
116
- try {
117
- const toolkitPathForPlugin = findToolkitPath();
118
- const pluginPath = path.join(
119
- toolkitPathForPlugin,
120
- "runtime/vite-inspector-plugin.js"
121
- );
122
- if (fs.existsSync(pluginPath)) {
123
- const pluginModule = await import(pluginPath);
124
- gxpInspectorPlugin = pluginModule.gxpInspectorPlugin;
125
- }
126
- // Load source tracker plugin for injecting data-gxp-source attributes
127
- const trackerPath = path.join(
128
- toolkitPathForPlugin,
129
- "runtime/vite-source-tracker-plugin.js"
130
- );
131
- if (fs.existsSync(trackerPath)) {
132
- const trackerModule = await import(trackerPath);
133
- gxpSourceTrackerPlugin = trackerModule.gxpSourceTrackerPlugin;
134
- }
135
- } catch (e) {
136
- console.warn("Could not load GxP Inspector plugin:", e.message);
137
- }
138
-
139
- export default defineConfig(({ mode }) => {
140
- // Load environment variables
141
- const env = loadEnv(mode, process.cwd(), "");
142
-
143
- // Get lib name from package.json
144
- const libName = getLibName();
145
-
146
- // Find the toolkit path for runtime imports
147
- const toolkitPath = findToolkitPath();
148
-
149
- // Resolve @layouts: use project's theme-layouts/ if it exists,
150
- // otherwise fall back to toolkit's runtime/fallback-layouts/
151
- const projectLayoutsDir = path.resolve(process.cwd(), "theme-layouts");
152
- const fallbackLayoutsDir = path.resolve(toolkitPath, "runtime", "fallback-layouts");
153
- const layoutsDir = fs.existsSync(projectLayoutsDir) ? projectLayoutsDir : fallbackLayoutsDir;
154
-
155
- if (layoutsDir === fallbackLayoutsDir) {
156
- console.log("📐 Layouts: using toolkit fallbacks (no theme-layouts/ directory)");
157
- } else {
158
- console.log("📐 Layouts: using project theme-layouts/");
159
- }
160
-
161
- // Determine if HTTPS is enabled
162
- const useHttps = getHttpsConfig(env) !== false;
163
-
164
- // Get API proxy target for non-mock environments
165
- const apiProxyTarget = getApiProxyTarget(env);
166
- if (apiProxyTarget) {
167
- console.log(`🔀 API Proxy: /api-proxy -> ${apiProxyTarget}`);
168
- }
169
-
170
- return {
171
- // Expose environment variables to the browser
172
- define: {
173
- "import.meta.env.VITE_API_ENV": JSON.stringify(env.API_ENV || "mock"),
174
- "import.meta.env.VITE_API_BASE_URL": JSON.stringify(
175
- env.API_BASE_URL || ""
176
- ),
177
- "import.meta.env.VITE_API_KEY": JSON.stringify(env.API_KEY || ""),
178
- "import.meta.env.VITE_API_PROJECT_ID": JSON.stringify(
179
- env.API_PROJECT_ID || ""
180
- ),
181
- "import.meta.env.VITE_USE_HTTPS": JSON.stringify(
182
- useHttps ? "true" : "false"
183
- ),
184
- "import.meta.env.VITE_NODE_PORT": JSON.stringify(env.NODE_PORT || "3060"),
185
- "import.meta.env.VITE_SOCKET_IO_PORT": JSON.stringify(
186
- env.SOCKET_IO_PORT || "3069"
187
- ),
188
- },
189
- plugins: [
190
- // Source tracker must come before vue() to transform templates before compilation
191
- ...(gxpSourceTrackerPlugin ? [gxpSourceTrackerPlugin()] : []),
192
- vue(),
193
- // GxP Inspector plugin for browser extension integration (if available)
194
- ...(gxpInspectorPlugin ? [gxpInspectorPlugin()] : []),
195
- externalGlobals(
196
- {
197
- vue: "Vue",
198
- pinia: "Pinia",
199
- "@/stores/gxpPortalConfigStore":
200
- "(window.useGxpStore || (() => { console.warn('useGxpStore not found on window, using fallback'); return {}; }))",
201
- },
202
- {
203
- include: ["src/**"],
204
- }
205
- ),
206
- // Add this new plugin to the plugins array
207
- {
208
- name: "spa-fallback",
209
- configureServer(server) {
210
- return () => {
211
- server.middlewares.use((req, res, next) => {
212
- // Only handle GET requests for non-file routes
213
- if (req.method !== "GET") {
214
- next();
215
- return;
216
- }
217
-
218
- // Skip API routes, health checks, known file extensions, and vite internals
219
- if (
220
- req.url.startsWith("/@") ||
221
- req.url.startsWith("/api") ||
222
- req.url === "/__health" ||
223
- /\.[a-z0-9]+$/i.test(req.url) // Has file extension
224
- ) {
225
- next();
226
- return;
227
- }
228
-
229
- // Check if local index.html exists, otherwise use toolkit version
230
- const localIndexPath = path.join(process.cwd(), "index.html");
231
- const toolkitIndexPath = path.join(runtimeDir, "index.html");
232
- const indexPath = fs.existsSync(localIndexPath) ? localIndexPath : toolkitIndexPath;
233
-
234
- if (fs.existsSync(indexPath)) {
235
- server
236
- .transformIndexHtml(req.url, fs.readFileSync(indexPath, "utf-8"))
237
- .then((html) => {
238
- res.setHeader("Content-Type", "text/html");
239
- res.end(html);
240
- })
241
- .catch((err) => {
242
- console.error("Error serving SPA fallback:", err);
243
- next(err);
244
- });
245
- } else {
246
- next();
247
- }
248
- });
249
- };
250
- },
251
- },
252
- // Custom request logging and CORS plugin
253
- {
254
- name: "request-logger-cors",
255
- configureServer(server) {
256
- server.middlewares.use((req, res, next) => {
257
- // Health check route
258
- if (req.url === "/__health") {
259
- res.statusCode = 200;
260
- res.setHeader("Content-Type", "application/json");
261
- res.end(JSON.stringify({ status: "ok" }));
262
- return;
263
- }
264
-
265
- const start = Date.now();
266
- const originalEnd = res.end;
267
-
268
- // Add CORS headers to all responses
269
- res.setHeader("Access-Control-Allow-Origin", "*");
270
- res.setHeader(
271
- "Access-Control-Allow-Methods",
272
- "GET, POST, PUT, DELETE, OPTIONS"
273
- );
274
- res.setHeader("Access-Control-Allow-Headers", "*");
275
- res.setHeader("Access-Control-Allow-Credentials", "false");
276
-
277
- // Handle preflight requests
278
- if (req.method === "OPTIONS") {
279
- res.statusCode = 200;
280
- res.end();
281
- return;
282
- }
283
-
284
- res.end = function (...args) {
285
- const duration = Date.now() - start;
286
- const status = res.statusCode;
287
- const method = req.method;
288
- const url = req.url;
289
- const referer = req.headers.referer || "direct";
290
- const origin = req.headers.origin || "unknown";
291
-
292
- console.log(
293
- `[${new Date().toISOString()}] ${method} ${url} ${status} (${duration}ms) - Origin: ${origin} - Referer: ${referer}`
294
- );
295
- originalEnd.apply(this, args);
296
- };
297
-
298
- next();
299
- });
300
- },
301
- },
302
- ],
303
- logLevel: env.NODE_LOG_LEVEL || "error",
304
- clearScreen: false,
305
- server: {
306
- port: parseInt(env.NODE_PORT) || 3060,
307
- strictPort: true,
308
- https: getHttpsConfig(env),
309
- allowedHosts: env.ALLOWED_HOSTS
310
- ? env.ALLOWED_HOSTS.split(",").map((h) => h.trim()).filter(Boolean)
311
- : "all",
312
- cors: {
313
- origin: "*",
314
- methods: ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
315
- allowedHeaders: ["*"],
316
- credentials: false,
317
- },
318
- hmr: env.HMR_HOST
319
- ? {
320
- protocol: env.HMR_PROTOCOL || "wss",
321
- host: env.HMR_HOST,
322
- port: parseInt(env.HMR_PORT) || 443,
323
- clientPort: parseInt(env.HMR_PORT) || 443,
324
- }
325
- : {
326
- clientPort:
327
- parseInt(env.CLIENT_PORT) || parseInt(env.NODE_PORT) || 3060,
328
- },
329
- host: true, // Allow access from network
330
- // API proxy for non-mock environments
331
- proxy: apiProxyTarget
332
- ? {
333
- "/api-proxy": {
334
- target: apiProxyTarget,
335
- changeOrigin: true,
336
- rewrite: (path) => path.replace(/^\/api-proxy/, ""),
337
- secure: false,
338
- configure: (proxy, options) => {
339
- proxy.on("proxyReq", (proxyReq, req) => {
340
- // Forward the API key as Authorization header if set
341
- const apiKey = env.API_KEY;
342
- if (apiKey) {
343
- proxyReq.setHeader("Authorization", `Bearer ${apiKey}`);
344
- }
345
- console.log(
346
- `[API Proxy] ${req.method} ${
347
- req.url
348
- } -> ${apiProxyTarget}${req.url.replace(
349
- /^\/api-proxy/,
350
- ""
351
- )}`
352
- );
353
- });
354
- proxy.on("proxyRes", (proxyRes, req) => {
355
- console.log(
356
- `[API Proxy] ${req.method} ${req.url} <- ${proxyRes.statusCode}`
357
- );
358
- });
359
- proxy.on("error", (err, req) => {
360
- console.error(`[API Proxy] Error: ${err.message}`);
361
- });
362
- },
363
- },
364
- }
365
- : {},
366
- },
367
- build: {
368
- lib: {
369
- entry: [path.resolve(process.cwd(), env.COMPONENT_PATH || "./src/Plugin.vue")],
370
- name: libName,
371
- fileName: (format) => `plugin.${format}.js`,
372
- formats: ["es"],
373
- },
374
- rollupOptions: {
375
- // Make sure Vue and Pinia are treated as external dependencies
376
- external: ["vue", "pinia"],
377
- output: {
378
- globals: {
379
- vue: "Vue",
380
- pinia: "Pinia",
381
- },
382
- },
383
- },
384
- },
385
- resolve: {
386
- alias: {
387
- // Client project's source directory
388
- "@": path.resolve(process.cwd(), "src"),
389
- // Theme layouts in client project
390
- "@layouts": layoutsDir,
391
- // GxP Toolkit runtime (PortalContainer, etc.) - from node_modules
392
- "@gx-runtime": path.resolve(toolkitPath, "runtime"),
393
- // Ensure single Vue and Pinia instances
394
- vue: path.resolve(process.cwd(), "node_modules/vue"),
395
- pinia: path.resolve(process.cwd(), "node_modules/pinia"),
396
- },
397
- // Dedupe Vue and Pinia to ensure only one instance is used
398
- dedupe: ["vue", "pinia"],
399
- },
400
- // Force Vite to pre-bundle these dependencies to ensure single instances
401
- optimizeDeps: {
402
- include: ["vue", "pinia"],
403
- },
404
- // SSR configuration to handle externals properly
405
- ssr: {
406
- external: ["vue", "pinia"],
407
- },
408
- };
409
- });