wexts 4.1.6 → 4.1.7

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.
@@ -0,0 +1,273 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2;
2
+
3
+ var _chunkWCKSKU3Cjs = require('./chunk-WCKSKU3C.js');
4
+
5
+
6
+
7
+ var _chunkXE4OXN2Wjs = require('./chunk-XE4OXN2W.js');
8
+
9
+ // src/dev-server/index.ts
10
+ var dev_server_exports = {};
11
+ _chunkXE4OXN2Wjs.__export.call(void 0, dev_server_exports, {
12
+ FusionDevServer: () => FusionDevServer,
13
+ ProcessRunner: () => ProcessRunner,
14
+ ProxyServer: () => ProxyServer
15
+ });
16
+
17
+ // src/dev-server/process-runner.ts
18
+ var _child_process = require('child_process');
19
+ var _picocolors = require('picocolors'); var pc = _interopRequireWildcard(_picocolors); var pc2 = _interopRequireWildcard(_picocolors);
20
+ var ProcessRunner = (_class = class {constructor() { _class.prototype.__init.call(this);_class.prototype.__init2.call(this); }
21
+ static {
22
+ _chunkXE4OXN2Wjs.__name.call(void 0, this, "ProcessRunner");
23
+ }
24
+ __init() {this.processes = /* @__PURE__ */ new Map()}
25
+ __init2() {this.colors = {
26
+ cyan: pc.cyan,
27
+ green: pc.green,
28
+ yellow: pc.yellow,
29
+ magenta: pc.magenta,
30
+ blue: pc.blue
31
+ }}
32
+ async run(configs) {
33
+ _chunkWCKSKU3Cjs.logger.info("\u{1F680} Starting development servers...\n");
34
+ for (const config of configs) {
35
+ this.startProcess(config);
36
+ }
37
+ process.on("SIGINT", () => this.stopAll());
38
+ process.on("SIGTERM", () => this.stopAll());
39
+ }
40
+ startProcess(config) {
41
+ const { name, command, args, cwd, color, env } = config;
42
+ const colorFn = this.colors[color];
43
+ const prefix = colorFn(`[${name}]`);
44
+ _chunkWCKSKU3Cjs.logger.info(`${prefix} Starting...`);
45
+ const proc = _child_process.spawn.call(void 0, command, args, {
46
+ cwd,
47
+ stdio: "pipe",
48
+ shell: true,
49
+ env: {
50
+ ...process.env,
51
+ ...env
52
+ }
53
+ });
54
+ this.processes.set(name, proc);
55
+ _optionalChain([proc, 'access', _ => _.stdout, 'optionalAccess', _2 => _2.on, 'call', _3 => _3("data", (data) => {
56
+ const lines = data.toString().split("\n").filter((l) => l.trim());
57
+ lines.forEach((line) => {
58
+ console.log(`${prefix} ${line}`);
59
+ });
60
+ })]);
61
+ _optionalChain([proc, 'access', _4 => _4.stderr, 'optionalAccess', _5 => _5.on, 'call', _6 => _6("data", (data) => {
62
+ const lines = data.toString().split("\n").filter((l) => l.trim());
63
+ lines.forEach((line) => {
64
+ console.error(`${prefix} ${pc.red(line)}`);
65
+ });
66
+ })]);
67
+ proc.on("exit", (code) => {
68
+ if (code !== 0 && code !== null) {
69
+ _chunkWCKSKU3Cjs.logger.error(`${prefix} Exited with code ${code}`);
70
+ }
71
+ this.processes.delete(name);
72
+ });
73
+ proc.on("error", (error) => {
74
+ _chunkWCKSKU3Cjs.logger.error(`${prefix} Error:`, error.message);
75
+ });
76
+ }
77
+ stopAll() {
78
+ _chunkWCKSKU3Cjs.logger.info("\n\u{1F6D1} Stopping all processes...");
79
+ for (const [name, proc] of this.processes.entries()) {
80
+ _chunkWCKSKU3Cjs.logger.info(`Stopping ${name}...`);
81
+ proc.kill("SIGTERM");
82
+ }
83
+ setTimeout(() => {
84
+ process.exit(0);
85
+ }, 1e3);
86
+ }
87
+ isRunning(name) {
88
+ return this.processes.has(name);
89
+ }
90
+ }, _class);
91
+
92
+ // src/dev-server/dev-server.ts
93
+ var _path = require('path'); var path = _interopRequireWildcard(_path);
94
+ var _fs = require('fs'); var fs = _interopRequireWildcard(_fs);
95
+ var DEFAULT_RUNTIME_CONFIG = "./wexts.runtime.js";
96
+ var FusionDevServer = class {
97
+ static {
98
+ _chunkXE4OXN2Wjs.__name.call(void 0, this, "FusionDevServer");
99
+ }
100
+
101
+ constructor() {
102
+ this.processRunner = new ProcessRunner();
103
+ }
104
+ async start(config) {
105
+ const { apiPath, webPath, webPort = 3e3, apiPort = 5050, useProxy = false, rootDir = process.cwd(), runtimeConfigPath = DEFAULT_RUNTIME_CONFIG } = config;
106
+ if (useProxy) {
107
+ throw new Error("The legacy dev proxy is disabled because it conflicts with the Next.js port. Use the production runtime for single-port serving.");
108
+ }
109
+ if (!fs.existsSync(apiPath)) {
110
+ throw new Error(`API path not found: ${apiPath}`);
111
+ }
112
+ if (!fs.existsSync(webPath)) {
113
+ throw new Error(`Web path not found: ${webPath}`);
114
+ }
115
+ const absoluteRuntimeConfigPath = path.isAbsolute(runtimeConfigPath) ? runtimeConfigPath : path.join(path.resolve(rootDir), runtimeConfigPath);
116
+ if (!fs.existsSync(absoluteRuntimeConfigPath)) {
117
+ throw new Error(`Runtime config not found: ${absoluteRuntimeConfigPath}. Create wexts.runtime.js or pass --config.`);
118
+ }
119
+ const processes = this.createProcessConfigs({
120
+ apiPath,
121
+ webPath,
122
+ webPort,
123
+ apiPort,
124
+ rootDir,
125
+ runtimeConfigPath
126
+ });
127
+ await this.processRunner.run(processes);
128
+ _chunkWCKSKU3Cjs.logger.info("\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557");
129
+ _chunkWCKSKU3Cjs.logger.info("\u2551 Fusion Development Server Ready \u2551");
130
+ _chunkWCKSKU3Cjs.logger.info("\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D\n");
131
+ _chunkWCKSKU3Cjs.logger.info(`\u{1F310} Web + RPC: http://localhost:${webPort}`);
132
+ _chunkWCKSKU3Cjs.logger.info(`\u{1F50C} API compiler: ${path.resolve(apiPath)}`);
133
+ _chunkWCKSKU3Cjs.logger.info("\n");
134
+ }
135
+ createProcessConfigs(config) {
136
+ const apiPath = path.resolve(config.apiPath);
137
+ const webPath = path.resolve(config.webPath);
138
+ const rootDir = path.resolve(config.rootDir);
139
+ const runtimeConfigPath = path.isAbsolute(config.runtimeConfigPath) ? config.runtimeConfigPath : path.join(rootDir, config.runtimeConfigPath);
140
+ return [
141
+ this.createApiCompilerProcess(apiPath, config.apiPort, rootDir),
142
+ {
143
+ name: "Web",
144
+ command: "pnpm",
145
+ args: [
146
+ "exec",
147
+ "wexts",
148
+ "start",
149
+ "-c",
150
+ runtimeConfigPath,
151
+ "-p",
152
+ config.webPort.toString(),
153
+ "--dev"
154
+ ],
155
+ cwd: rootDir,
156
+ color: "green",
157
+ env: {
158
+ NEXT_PUBLIC_API_URL: `http://localhost:${config.apiPort}`,
159
+ WEXTS_WEB_DIR: webPath
160
+ }
161
+ }
162
+ ];
163
+ }
164
+ createApiCompilerProcess(apiPath, apiPort, rootDir) {
165
+ if (fs.existsSync(path.join(apiPath, "package.json"))) {
166
+ return {
167
+ name: "API",
168
+ command: "pnpm",
169
+ args: [
170
+ "run",
171
+ "start:dev"
172
+ ],
173
+ cwd: apiPath,
174
+ color: "cyan",
175
+ env: {
176
+ PORT: apiPort.toString()
177
+ }
178
+ };
179
+ }
180
+ return {
181
+ name: "API",
182
+ command: "pnpm",
183
+ args: [
184
+ "exec",
185
+ "tsc",
186
+ "-w",
187
+ "-p",
188
+ path.join(apiPath, "tsconfig.json")
189
+ ],
190
+ cwd: rootDir,
191
+ color: "cyan",
192
+ env: {
193
+ PORT: apiPort.toString()
194
+ }
195
+ };
196
+ }
197
+ stop() {
198
+ this.processRunner.stopAll();
199
+ }
200
+ };
201
+
202
+ // src/dev-server/proxy.ts
203
+ var _http = require('http'); var _http2 = _interopRequireDefault(_http);
204
+ var _httpproxy = require('http-proxy'); var _httpproxy2 = _interopRequireDefault(_httpproxy);
205
+
206
+ var ProxyServer = (_class2 = class {constructor() { _class2.prototype.__init3.call(this);_class2.prototype.__init4.call(this); }
207
+ static {
208
+ _chunkXE4OXN2Wjs.__name.call(void 0, this, "ProxyServer");
209
+ }
210
+ __init3() {this.server = null}
211
+ __init4() {this.proxy = null}
212
+ async start(config) {
213
+ const { port, apiTarget, apiPrefix } = config;
214
+ this.proxy = _httpproxy2.default.createProxyServer({
215
+ target: apiTarget,
216
+ changeOrigin: true,
217
+ ws: true
218
+ });
219
+ this.proxy.on("error", (err, req, res) => {
220
+ _chunkWCKSKU3Cjs.logger.error("Proxy error:", err.message);
221
+ if (res && "headersSent" in res && !res.headersSent) {
222
+ res.writeHead(502, {
223
+ "Content-Type": "text/plain"
224
+ });
225
+ res.end("Bad Gateway - API server unavailable");
226
+ }
227
+ });
228
+ this.server = _http2.default.createServer((req, res) => {
229
+ if (_optionalChain([req, 'access', _7 => _7.url, 'optionalAccess', _8 => _8.startsWith, 'call', _9 => _9(apiPrefix)])) {
230
+ const newUrl = req.url.substring(apiPrefix.length) || "/";
231
+ req.url = newUrl;
232
+ _chunkWCKSKU3Cjs.logger.info(pc2.gray(`\u2192 ${req.method} ${apiPrefix}${newUrl}`));
233
+ this.proxy.web(req, res);
234
+ } else {
235
+ res.writeHead(404);
236
+ res.end("Not Found");
237
+ }
238
+ });
239
+ this.server.on("upgrade", (req, socket, head) => {
240
+ if (_optionalChain([req, 'access', _10 => _10.url, 'optionalAccess', _11 => _11.startsWith, 'call', _12 => _12(apiPrefix)])) {
241
+ const newUrl = req.url.substring(apiPrefix.length) || "/";
242
+ req.url = newUrl;
243
+ this.proxy.ws(req, socket, head);
244
+ }
245
+ });
246
+ return new Promise((resolve2) => {
247
+ this.server.listen(port, () => {
248
+ _chunkWCKSKU3Cjs.logger.success(`\u2705 Proxy server running on port ${port}`);
249
+ _chunkWCKSKU3Cjs.logger.info(` Forwarding ${pc2.cyan(apiPrefix + "/*")} \u2192 ${pc2.cyan(apiTarget)}
250
+ `);
251
+ resolve2();
252
+ });
253
+ });
254
+ }
255
+ stop() {
256
+ if (this.server) {
257
+ this.server.close();
258
+ this.server = null;
259
+ }
260
+ if (this.proxy) {
261
+ this.proxy.close();
262
+ this.proxy = null;
263
+ }
264
+ }
265
+ }, _class2);
266
+
267
+
268
+
269
+
270
+
271
+
272
+ exports.ProcessRunner = ProcessRunner; exports.FusionDevServer = FusionDevServer; exports.ProxyServer = ProxyServer; exports.dev_server_exports = dev_server_exports;
273
+ //# sourceMappingURL=chunk-IRRJJ7KL.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Volumes/Projects/wexts/packages/dist/chunk-IRRJJ7KL.js","../src/dev-server/index.ts","../src/dev-server/process-runner.ts","../src/dev-server/dev-server.ts","../src/dev-server/proxy.ts"],"names":["ProcessRunner","processes","Map","colors","cyan","green","yellow","magenta","blue","run","configs","logger","info","config","startProcess","process","on","stopAll","name","command","args","cwd","color","env","colorFn","prefix","spawn","lines","forEach","log","error","code","exit","path","fs","DEFAULT_RUNTIME_CONFIG","FusionDevServer","processRunner","apiPath","useProxy","Error","existsSync","absoluteRuntimeConfigPath","webPath","webPort","apiPort","rootDir","runtimeConfigPath","createProcessConfigs","createApiCompilerProcess","NEXT_PUBLIC_API_URL","WEXTS_WEB_DIR","join","httpProxy","pc","ProxyServer","port","apiTarget","changeOrigin","writeHead","server","url","newUrl","proxy","Promise","success","resolve","close"],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACA;AACF,sDAA4B;AAC5B;AACA;ACRA,IAAA,mBAAA,EAAA,CAAA,CAAA;ADUA,uCAAQ,kBAAmB,EAAE;AAC7B,EAAE,eAAe,EAAE,CAAC,EAAE,GAAG,eAAe;AACxC,EAAE,aAAa,EAAE,CAAC,EAAE,GAAG,aAAa;AACpC,EAAE,WAAW,EAAE,CAAC,EAAE,GAAG;AACrB,CAAC,CAAC;AACF;AACA;AEhBA,8CAAoC;AAEpC,uIAAoB;AAcb,IAAMA,cAAAA,YAAN,MAAMA;AFIb,EEpBA,OAgBaA;AFKb,IAAI,qCAAM,IAAK,EAAE,eAAe,CAAC;AACjC,EAAE;AACF,iBENYC,UAAAA,kBAAuC,IAAIC,GAAAA,CAAAA,EAAAA;AFOvD,kBENYC,OAAAA,EAAS;AFOrB,IENQC,IAAAA,EAASA,EAAAA,CAAAA,IAAAA;AFOjB,IENQC,KAAAA,EAAUA,EAAAA,CAAAA,KAAAA;AFOlB,IENQC,MAAAA,EAAWA,EAAAA,CAAAA,MAAAA;AFOnB,IENQC,OAAAA,EAAYA,EAAAA,CAAAA,OAAAA;AFOpB,IENQC,IAAAA,EAASA,EAAAA,CAAAA;AFOjB,EENI,EAAA;AFOJ,EELI,MAAMC,GAAAA,CAAIC,OAAAA,EAAyC;AAC/CC,IAAAA,uBAAAA,CAAOC,IAAAA,CAAK,6CAAA,CAAA;AAEZ,IAAA,IAAA,CAAA,MAAWC,OAAAA,GAAUH,OAAAA,EAAS;AAC1B,MAAA,IAAA,CAAKI,YAAAA,CAAaD,MAAAA,CAAAA;AFK9B,IEJQ;AAGAE,IAAAA,OAAAA,CAAQC,EAAAA,CAAG,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ACJ,EAAA;AAEa,EAAA;AACJR,IAAAA;AACT,EAAA;AACJ;AHqEiB;AACA;AIzMA;AACVgB;AAEKC;AAWCC;AAAAA,EAAAA;AJiMI,IAAA;AACA,EAAA;AIjMwB,kBAAA;AACH,kBAAA;AAEtB1C,EAAAA;AACA2C,IAAAA;AAEKH,IAAAA;AACDI,MAAAA;AACRC,MAAAA;AACI,MAAA;AACR,IAAA;AAGW1C,IAAAA;AACAc,MAAAA;AACI,MAAA;AACsB6B,QAAAA;AAAiB,UAAA;AAA6B,QAAA;AAC1C,QAAA;AACrC,MAAA;AACJ,IAAA;AAEKC,IAAAA;AAEOC,MAAAA;AAEEC,QAAAA;AACFD,QAAAA;AAEGjD,QAAAA;AACFmD,QAAAA;AACF,MAAA;AAECJ,QAAAA;AACI,QAAA;AACZ,MAAA;AACJ,IAAA;AAGY3C,IAAAA;AACA6C,MAAAA;AACEC,QAAAA;AACFD,QAAAA;AACCE,QAAAA;AACT,MAAA;AACJ,IAAA;AAEWC,IAAAA;AACFJ,MAAAA;AACMK,QAAAA;AACArD,QAAAA;AAA2E;AAClFsD,QAAAA;AACJ,MAAA;AACJ,IAAA;AACJ,EAAA;AAEa,EAAA;AACAN,IAAAA;AACAA,MAAAA;AACAA,MAAAA;AACT,IAAA;AACSG,IAAAA;AACMI,MAAAA;AACNJ,MAAAA;AACT,IAAA;AACJ,EAAA;AACJ;AJyLiB;AACA;AACA;AACA;AACA;AACA;AACA","file":"/Volumes/Projects/wexts/packages/dist/chunk-IRRJJ7KL.js","sourcesContent":[null,"export * from './dev-server';\nexport * from './process-runner';\nexport * from './proxy';\n","import { spawn, ChildProcess } from 'child_process';\nimport { logger } from '../core/logger';\nimport * as pc from 'picocolors';\n\nexport interface ProcessConfig {\n name: string;\n command: string;\n args: string[];\n cwd: string;\n color: 'cyan' | 'green' | 'yellow' | 'magenta' | 'blue';\n env?: Record<string, string>;\n}\n\n/**\n * Run multiple processes concurrently with colored output\n */\nexport class ProcessRunner {\n private processes: Map<string, ChildProcess> = new Map();\n private colors = {\n cyan: pc.cyan,\n green: pc.green,\n yellow: pc.yellow,\n magenta: pc.magenta,\n blue: pc.blue,\n };\n\n async run(configs: ProcessConfig[]): Promise<void> {\n logger.info('šŸš€ Starting development servers...\\n');\n\n for (const config of configs) {\n this.startProcess(config);\n }\n\n // Handle graceful shutdown\n process.on('SIGINT', () => this.stopAll());\n process.on('SIGTERM', () => this.stopAll());\n }\n\n private startProcess(config: ProcessConfig): void {\n const { name, command, args, cwd, color, env } = config;\n\n const colorFn = this.colors[color];\n const prefix = colorFn(`[${name}]`);\n\n logger.info(`${prefix} Starting...`);\n\n const proc = spawn(command, args, {\n cwd,\n stdio: 'pipe',\n shell: true,\n env: { ...process.env, ...env },\n });\n\n this.processes.set(name, proc);\n\n // Handle stdout\n proc.stdout?.on('data', (data) => {\n const lines = data.toString().split('\\n').filter((l: string) => l.trim());\n lines.forEach((line: string) => {\n console.log(`${prefix} ${line}`);\n });\n });\n\n // Handle stderr\n proc.stderr?.on('data', (data) => {\n const lines = data.toString().split('\\n').filter((l: string) => l.trim());\n lines.forEach((line: string) => {\n console.error(`${prefix} ${pc.red(line)}`);\n });\n });\n\n // Handle exit\n proc.on('exit', (code) => {\n if (code !== 0 && code !== null) {\n logger.error(`${prefix} Exited with code ${code}`);\n }\n this.processes.delete(name);\n });\n\n // Handle errors\n proc.on('error', (error) => {\n logger.error(`${prefix} Error:`, error.message);\n });\n }\n\n stopAll(): void {\n logger.info('\\nšŸ›‘ Stopping all processes...');\n\n for (const [name, proc] of this.processes.entries()) {\n logger.info(`Stopping ${name}...`);\n proc.kill('SIGTERM');\n }\n\n setTimeout(() => {\n process.exit(0);\n }, 1000);\n }\n\n isRunning(name: string): boolean {\n return this.processes.has(name);\n }\n}\n","import { ProcessRunner, ProcessConfig } from './process-runner';\nimport { logger } from '../core/logger';\nimport * as path from 'path';\nimport * as fs from 'fs';\n\nexport interface DevServerConfig {\n apiPath: string;\n webPath: string;\n webPort?: number;\n apiPort?: number;\n useProxy?: boolean;\n rootDir?: string;\n runtimeConfigPath?: string;\n}\n\nconst DEFAULT_RUNTIME_CONFIG = './wexts.runtime.js';\n\n/**\n * Unified development server for Fusion projects\n */\nexport class FusionDevServer {\n private processRunner: ProcessRunner;\n\n constructor() {\n this.processRunner = new ProcessRunner();\n }\n\n async start(config: DevServerConfig): Promise<void> {\n const {\n apiPath,\n webPath,\n webPort = 3000,\n apiPort = 5050,\n useProxy = false,\n rootDir = process.cwd(),\n runtimeConfigPath = DEFAULT_RUNTIME_CONFIG,\n } = config;\n\n if (useProxy) {\n throw new Error('The legacy dev proxy is disabled because it conflicts with the Next.js port. Use the production runtime for single-port serving.');\n }\n\n // Validate paths\n if (!fs.existsSync(apiPath)) {\n throw new Error(`API path not found: ${apiPath}`);\n }\n if (!fs.existsSync(webPath)) {\n throw new Error(`Web path not found: ${webPath}`);\n }\n\n const absoluteRuntimeConfigPath = path.isAbsolute(runtimeConfigPath)\n ? runtimeConfigPath\n : path.join(path.resolve(rootDir), runtimeConfigPath);\n if (!fs.existsSync(absoluteRuntimeConfigPath)) {\n throw new Error(`Runtime config not found: ${absoluteRuntimeConfigPath}. Create wexts.runtime.js or pass --config.`);\n }\n\n const processes = this.createProcessConfigs({\n apiPath,\n webPath,\n webPort,\n apiPort,\n rootDir,\n runtimeConfigPath,\n });\n\n // Start processes\n await this.processRunner.run(processes);\n\n // Log info\n logger.info('╔═══════════════════════════════════════╗');\n logger.info('ā•‘ Fusion Development Server Ready ā•‘');\n logger.info('ā•šā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•\\n');\n logger.info(`🌐 Web + RPC: http://localhost:${webPort}`);\n logger.info(`šŸ”Œ API compiler: ${path.resolve(apiPath)}`);\n logger.info('\\n');\n }\n\n createProcessConfigs(config: Required<Pick<DevServerConfig, 'apiPath' | 'webPath' | 'webPort' | 'apiPort' | 'rootDir' | 'runtimeConfigPath'>>): ProcessConfig[] {\n const apiPath = path.resolve(config.apiPath);\n const webPath = path.resolve(config.webPath);\n const rootDir = path.resolve(config.rootDir);\n const runtimeConfigPath = path.isAbsolute(config.runtimeConfigPath)\n ? config.runtimeConfigPath\n : path.join(rootDir, config.runtimeConfigPath);\n\n return [\n this.createApiCompilerProcess(apiPath, config.apiPort, rootDir),\n {\n name: 'Web',\n command: 'pnpm',\n args: ['exec', 'wexts', 'start', '-c', runtimeConfigPath, '-p', config.webPort.toString(), '--dev'],\n cwd: rootDir,\n color: 'green',\n env: {\n NEXT_PUBLIC_API_URL: `http://localhost:${config.apiPort}`,\n WEXTS_WEB_DIR: webPath,\n },\n },\n ];\n }\n\n private createApiCompilerProcess(apiPath: string, apiPort: number, rootDir: string): ProcessConfig {\n if (fs.existsSync(path.join(apiPath, 'package.json'))) {\n return {\n name: 'API',\n command: 'pnpm',\n args: ['run', 'start:dev'],\n cwd: apiPath,\n color: 'cyan',\n env: {\n PORT: apiPort.toString(),\n },\n };\n }\n\n return {\n name: 'API',\n command: 'pnpm',\n args: ['exec', 'tsc', '-w', '-p', path.join(apiPath, 'tsconfig.json')],\n cwd: rootDir,\n color: 'cyan',\n env: {\n PORT: apiPort.toString(),\n },\n };\n }\n\n stop(): void {\n this.processRunner.stopAll();\n }\n}\n","import http from 'http';\nimport httpProxy from 'http-proxy';\nimport { logger } from '../core/logger';\nimport * as pc from 'picocolors';\n\nexport interface ProxyConfig {\n port: number;\n apiTarget: string;\n apiPrefix: string;\n}\n\n/**\n * Proxy server to forward API requests from Next.js to NestJS\n */\nexport class ProxyServer {\n private server: http.Server | null = null;\n private proxy: httpProxy | null = null;\n\n async start(config: ProxyConfig): Promise<void> {\n const { port, apiTarget, apiPrefix } = config;\n\n this.proxy = httpProxy.createProxyServer({\n target: apiTarget,\n changeOrigin: true,\n ws: true, // WebSocket support\n });\n\n // Handle proxy errors\n this.proxy.on('error', (err, req, res) => {\n logger.error('Proxy error:', err.message);\n if (res && 'headersSent' in res && !(res as any).headersSent) {\n (res as http.ServerResponse).writeHead(502, { 'Content-Type': 'text/plain' });\n (res as http.ServerResponse).end('Bad Gateway - API server unavailable');\n }\n });\n\n this.server = http.createServer((req, res) => {\n // Check if request is for API\n if (req.url?.startsWith(apiPrefix)) {\n // Remove prefix before forwarding\n const newUrl = req.url.substring(apiPrefix.length) || '/';\n req.url = newUrl;\n\n logger.info(pc.gray(`→ ${req.method} ${apiPrefix}${newUrl}`));\n this.proxy!.web(req, res);\n } else {\n // Not an API request - should not happen\n res.writeHead(404);\n res.end('Not Found');\n }\n });\n\n // Handle WebSocket upgrade\n this.server.on('upgrade', (req, socket, head) => {\n if (req.url?.startsWith(apiPrefix)) {\n const newUrl = req.url.substring(apiPrefix.length) || '/';\n req.url = newUrl;\n this.proxy!.ws(req, socket, head);\n }\n });\n\n return new Promise((resolve) => {\n this.server!.listen(port, () => {\n logger.success(`āœ… Proxy server running on port ${port}`);\n logger.info(` Forwarding ${pc.cyan(apiPrefix + '/*')} → ${pc.cyan(apiTarget)}\\n`);\n resolve();\n });\n });\n }\n\n stop(): void {\n if (this.server) {\n this.server.close();\n this.server = null;\n }\n if (this.proxy) {\n this.proxy.close();\n this.proxy = null;\n }\n }\n}\n"]}
@@ -0,0 +1,273 @@
1
+ import {
2
+ logger
3
+ } from "./chunk-C2AG7Q3C.mjs";
4
+ import {
5
+ __export,
6
+ __name
7
+ } from "./chunk-L77ANWWT.mjs";
8
+
9
+ // src/dev-server/index.ts
10
+ var dev_server_exports = {};
11
+ __export(dev_server_exports, {
12
+ FusionDevServer: () => FusionDevServer,
13
+ ProcessRunner: () => ProcessRunner,
14
+ ProxyServer: () => ProxyServer
15
+ });
16
+
17
+ // src/dev-server/process-runner.ts
18
+ import { spawn } from "child_process";
19
+ import * as pc from "picocolors";
20
+ var ProcessRunner = class {
21
+ static {
22
+ __name(this, "ProcessRunner");
23
+ }
24
+ processes = /* @__PURE__ */ new Map();
25
+ colors = {
26
+ cyan: pc.cyan,
27
+ green: pc.green,
28
+ yellow: pc.yellow,
29
+ magenta: pc.magenta,
30
+ blue: pc.blue
31
+ };
32
+ async run(configs) {
33
+ logger.info("\u{1F680} Starting development servers...\n");
34
+ for (const config of configs) {
35
+ this.startProcess(config);
36
+ }
37
+ process.on("SIGINT", () => this.stopAll());
38
+ process.on("SIGTERM", () => this.stopAll());
39
+ }
40
+ startProcess(config) {
41
+ const { name, command, args, cwd, color, env } = config;
42
+ const colorFn = this.colors[color];
43
+ const prefix = colorFn(`[${name}]`);
44
+ logger.info(`${prefix} Starting...`);
45
+ const proc = spawn(command, args, {
46
+ cwd,
47
+ stdio: "pipe",
48
+ shell: true,
49
+ env: {
50
+ ...process.env,
51
+ ...env
52
+ }
53
+ });
54
+ this.processes.set(name, proc);
55
+ proc.stdout?.on("data", (data) => {
56
+ const lines = data.toString().split("\n").filter((l) => l.trim());
57
+ lines.forEach((line) => {
58
+ console.log(`${prefix} ${line}`);
59
+ });
60
+ });
61
+ proc.stderr?.on("data", (data) => {
62
+ const lines = data.toString().split("\n").filter((l) => l.trim());
63
+ lines.forEach((line) => {
64
+ console.error(`${prefix} ${pc.red(line)}`);
65
+ });
66
+ });
67
+ proc.on("exit", (code) => {
68
+ if (code !== 0 && code !== null) {
69
+ logger.error(`${prefix} Exited with code ${code}`);
70
+ }
71
+ this.processes.delete(name);
72
+ });
73
+ proc.on("error", (error) => {
74
+ logger.error(`${prefix} Error:`, error.message);
75
+ });
76
+ }
77
+ stopAll() {
78
+ logger.info("\n\u{1F6D1} Stopping all processes...");
79
+ for (const [name, proc] of this.processes.entries()) {
80
+ logger.info(`Stopping ${name}...`);
81
+ proc.kill("SIGTERM");
82
+ }
83
+ setTimeout(() => {
84
+ process.exit(0);
85
+ }, 1e3);
86
+ }
87
+ isRunning(name) {
88
+ return this.processes.has(name);
89
+ }
90
+ };
91
+
92
+ // src/dev-server/dev-server.ts
93
+ import * as path from "path";
94
+ import * as fs from "fs";
95
+ var DEFAULT_RUNTIME_CONFIG = "./wexts.runtime.js";
96
+ var FusionDevServer = class {
97
+ static {
98
+ __name(this, "FusionDevServer");
99
+ }
100
+ processRunner;
101
+ constructor() {
102
+ this.processRunner = new ProcessRunner();
103
+ }
104
+ async start(config) {
105
+ const { apiPath, webPath, webPort = 3e3, apiPort = 5050, useProxy = false, rootDir = process.cwd(), runtimeConfigPath = DEFAULT_RUNTIME_CONFIG } = config;
106
+ if (useProxy) {
107
+ throw new Error("The legacy dev proxy is disabled because it conflicts with the Next.js port. Use the production runtime for single-port serving.");
108
+ }
109
+ if (!fs.existsSync(apiPath)) {
110
+ throw new Error(`API path not found: ${apiPath}`);
111
+ }
112
+ if (!fs.existsSync(webPath)) {
113
+ throw new Error(`Web path not found: ${webPath}`);
114
+ }
115
+ const absoluteRuntimeConfigPath = path.isAbsolute(runtimeConfigPath) ? runtimeConfigPath : path.join(path.resolve(rootDir), runtimeConfigPath);
116
+ if (!fs.existsSync(absoluteRuntimeConfigPath)) {
117
+ throw new Error(`Runtime config not found: ${absoluteRuntimeConfigPath}. Create wexts.runtime.js or pass --config.`);
118
+ }
119
+ const processes = this.createProcessConfigs({
120
+ apiPath,
121
+ webPath,
122
+ webPort,
123
+ apiPort,
124
+ rootDir,
125
+ runtimeConfigPath
126
+ });
127
+ await this.processRunner.run(processes);
128
+ logger.info("\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557");
129
+ logger.info("\u2551 Fusion Development Server Ready \u2551");
130
+ logger.info("\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D\n");
131
+ logger.info(`\u{1F310} Web + RPC: http://localhost:${webPort}`);
132
+ logger.info(`\u{1F50C} API compiler: ${path.resolve(apiPath)}`);
133
+ logger.info("\n");
134
+ }
135
+ createProcessConfigs(config) {
136
+ const apiPath = path.resolve(config.apiPath);
137
+ const webPath = path.resolve(config.webPath);
138
+ const rootDir = path.resolve(config.rootDir);
139
+ const runtimeConfigPath = path.isAbsolute(config.runtimeConfigPath) ? config.runtimeConfigPath : path.join(rootDir, config.runtimeConfigPath);
140
+ return [
141
+ this.createApiCompilerProcess(apiPath, config.apiPort, rootDir),
142
+ {
143
+ name: "Web",
144
+ command: "pnpm",
145
+ args: [
146
+ "exec",
147
+ "wexts",
148
+ "start",
149
+ "-c",
150
+ runtimeConfigPath,
151
+ "-p",
152
+ config.webPort.toString(),
153
+ "--dev"
154
+ ],
155
+ cwd: rootDir,
156
+ color: "green",
157
+ env: {
158
+ NEXT_PUBLIC_API_URL: `http://localhost:${config.apiPort}`,
159
+ WEXTS_WEB_DIR: webPath
160
+ }
161
+ }
162
+ ];
163
+ }
164
+ createApiCompilerProcess(apiPath, apiPort, rootDir) {
165
+ if (fs.existsSync(path.join(apiPath, "package.json"))) {
166
+ return {
167
+ name: "API",
168
+ command: "pnpm",
169
+ args: [
170
+ "run",
171
+ "start:dev"
172
+ ],
173
+ cwd: apiPath,
174
+ color: "cyan",
175
+ env: {
176
+ PORT: apiPort.toString()
177
+ }
178
+ };
179
+ }
180
+ return {
181
+ name: "API",
182
+ command: "pnpm",
183
+ args: [
184
+ "exec",
185
+ "tsc",
186
+ "-w",
187
+ "-p",
188
+ path.join(apiPath, "tsconfig.json")
189
+ ],
190
+ cwd: rootDir,
191
+ color: "cyan",
192
+ env: {
193
+ PORT: apiPort.toString()
194
+ }
195
+ };
196
+ }
197
+ stop() {
198
+ this.processRunner.stopAll();
199
+ }
200
+ };
201
+
202
+ // src/dev-server/proxy.ts
203
+ import http from "http";
204
+ import httpProxy from "http-proxy";
205
+ import * as pc2 from "picocolors";
206
+ var ProxyServer = class {
207
+ static {
208
+ __name(this, "ProxyServer");
209
+ }
210
+ server = null;
211
+ proxy = null;
212
+ async start(config) {
213
+ const { port, apiTarget, apiPrefix } = config;
214
+ this.proxy = httpProxy.createProxyServer({
215
+ target: apiTarget,
216
+ changeOrigin: true,
217
+ ws: true
218
+ });
219
+ this.proxy.on("error", (err, req, res) => {
220
+ logger.error("Proxy error:", err.message);
221
+ if (res && "headersSent" in res && !res.headersSent) {
222
+ res.writeHead(502, {
223
+ "Content-Type": "text/plain"
224
+ });
225
+ res.end("Bad Gateway - API server unavailable");
226
+ }
227
+ });
228
+ this.server = http.createServer((req, res) => {
229
+ if (req.url?.startsWith(apiPrefix)) {
230
+ const newUrl = req.url.substring(apiPrefix.length) || "/";
231
+ req.url = newUrl;
232
+ logger.info(pc2.gray(`\u2192 ${req.method} ${apiPrefix}${newUrl}`));
233
+ this.proxy.web(req, res);
234
+ } else {
235
+ res.writeHead(404);
236
+ res.end("Not Found");
237
+ }
238
+ });
239
+ this.server.on("upgrade", (req, socket, head) => {
240
+ if (req.url?.startsWith(apiPrefix)) {
241
+ const newUrl = req.url.substring(apiPrefix.length) || "/";
242
+ req.url = newUrl;
243
+ this.proxy.ws(req, socket, head);
244
+ }
245
+ });
246
+ return new Promise((resolve2) => {
247
+ this.server.listen(port, () => {
248
+ logger.success(`\u2705 Proxy server running on port ${port}`);
249
+ logger.info(` Forwarding ${pc2.cyan(apiPrefix + "/*")} \u2192 ${pc2.cyan(apiTarget)}
250
+ `);
251
+ resolve2();
252
+ });
253
+ });
254
+ }
255
+ stop() {
256
+ if (this.server) {
257
+ this.server.close();
258
+ this.server = null;
259
+ }
260
+ if (this.proxy) {
261
+ this.proxy.close();
262
+ this.proxy = null;
263
+ }
264
+ }
265
+ };
266
+
267
+ export {
268
+ ProcessRunner,
269
+ FusionDevServer,
270
+ ProxyServer,
271
+ dev_server_exports
272
+ };
273
+ //# sourceMappingURL=chunk-VJY6PHYF.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/dev-server/index.ts","../src/dev-server/process-runner.ts","../src/dev-server/dev-server.ts","../src/dev-server/proxy.ts"],"sourcesContent":["export * from './dev-server';\nexport * from './process-runner';\nexport * from './proxy';\n","import { spawn, ChildProcess } from 'child_process';\nimport { logger } from '../core/logger';\nimport * as pc from 'picocolors';\n\nexport interface ProcessConfig {\n name: string;\n command: string;\n args: string[];\n cwd: string;\n color: 'cyan' | 'green' | 'yellow' | 'magenta' | 'blue';\n env?: Record<string, string>;\n}\n\n/**\n * Run multiple processes concurrently with colored output\n */\nexport class ProcessRunner {\n private processes: Map<string, ChildProcess> = new Map();\n private colors = {\n cyan: pc.cyan,\n green: pc.green,\n yellow: pc.yellow,\n magenta: pc.magenta,\n blue: pc.blue,\n };\n\n async run(configs: ProcessConfig[]): Promise<void> {\n logger.info('šŸš€ Starting development servers...\\n');\n\n for (const config of configs) {\n this.startProcess(config);\n }\n\n // Handle graceful shutdown\n process.on('SIGINT', () => this.stopAll());\n process.on('SIGTERM', () => this.stopAll());\n }\n\n private startProcess(config: ProcessConfig): void {\n const { name, command, args, cwd, color, env } = config;\n\n const colorFn = this.colors[color];\n const prefix = colorFn(`[${name}]`);\n\n logger.info(`${prefix} Starting...`);\n\n const proc = spawn(command, args, {\n cwd,\n stdio: 'pipe',\n shell: true,\n env: { ...process.env, ...env },\n });\n\n this.processes.set(name, proc);\n\n // Handle stdout\n proc.stdout?.on('data', (data) => {\n const lines = data.toString().split('\\n').filter((l: string) => l.trim());\n lines.forEach((line: string) => {\n console.log(`${prefix} ${line}`);\n });\n });\n\n // Handle stderr\n proc.stderr?.on('data', (data) => {\n const lines = data.toString().split('\\n').filter((l: string) => l.trim());\n lines.forEach((line: string) => {\n console.error(`${prefix} ${pc.red(line)}`);\n });\n });\n\n // Handle exit\n proc.on('exit', (code) => {\n if (code !== 0 && code !== null) {\n logger.error(`${prefix} Exited with code ${code}`);\n }\n this.processes.delete(name);\n });\n\n // Handle errors\n proc.on('error', (error) => {\n logger.error(`${prefix} Error:`, error.message);\n });\n }\n\n stopAll(): void {\n logger.info('\\nšŸ›‘ Stopping all processes...');\n\n for (const [name, proc] of this.processes.entries()) {\n logger.info(`Stopping ${name}...`);\n proc.kill('SIGTERM');\n }\n\n setTimeout(() => {\n process.exit(0);\n }, 1000);\n }\n\n isRunning(name: string): boolean {\n return this.processes.has(name);\n }\n}\n","import { ProcessRunner, ProcessConfig } from './process-runner';\nimport { logger } from '../core/logger';\nimport * as path from 'path';\nimport * as fs from 'fs';\n\nexport interface DevServerConfig {\n apiPath: string;\n webPath: string;\n webPort?: number;\n apiPort?: number;\n useProxy?: boolean;\n rootDir?: string;\n runtimeConfigPath?: string;\n}\n\nconst DEFAULT_RUNTIME_CONFIG = './wexts.runtime.js';\n\n/**\n * Unified development server for Fusion projects\n */\nexport class FusionDevServer {\n private processRunner: ProcessRunner;\n\n constructor() {\n this.processRunner = new ProcessRunner();\n }\n\n async start(config: DevServerConfig): Promise<void> {\n const {\n apiPath,\n webPath,\n webPort = 3000,\n apiPort = 5050,\n useProxy = false,\n rootDir = process.cwd(),\n runtimeConfigPath = DEFAULT_RUNTIME_CONFIG,\n } = config;\n\n if (useProxy) {\n throw new Error('The legacy dev proxy is disabled because it conflicts with the Next.js port. Use the production runtime for single-port serving.');\n }\n\n // Validate paths\n if (!fs.existsSync(apiPath)) {\n throw new Error(`API path not found: ${apiPath}`);\n }\n if (!fs.existsSync(webPath)) {\n throw new Error(`Web path not found: ${webPath}`);\n }\n\n const absoluteRuntimeConfigPath = path.isAbsolute(runtimeConfigPath)\n ? runtimeConfigPath\n : path.join(path.resolve(rootDir), runtimeConfigPath);\n if (!fs.existsSync(absoluteRuntimeConfigPath)) {\n throw new Error(`Runtime config not found: ${absoluteRuntimeConfigPath}. Create wexts.runtime.js or pass --config.`);\n }\n\n const processes = this.createProcessConfigs({\n apiPath,\n webPath,\n webPort,\n apiPort,\n rootDir,\n runtimeConfigPath,\n });\n\n // Start processes\n await this.processRunner.run(processes);\n\n // Log info\n logger.info('╔═══════════════════════════════════════╗');\n logger.info('ā•‘ Fusion Development Server Ready ā•‘');\n logger.info('ā•šā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•\\n');\n logger.info(`🌐 Web + RPC: http://localhost:${webPort}`);\n logger.info(`šŸ”Œ API compiler: ${path.resolve(apiPath)}`);\n logger.info('\\n');\n }\n\n createProcessConfigs(config: Required<Pick<DevServerConfig, 'apiPath' | 'webPath' | 'webPort' | 'apiPort' | 'rootDir' | 'runtimeConfigPath'>>): ProcessConfig[] {\n const apiPath = path.resolve(config.apiPath);\n const webPath = path.resolve(config.webPath);\n const rootDir = path.resolve(config.rootDir);\n const runtimeConfigPath = path.isAbsolute(config.runtimeConfigPath)\n ? config.runtimeConfigPath\n : path.join(rootDir, config.runtimeConfigPath);\n\n return [\n this.createApiCompilerProcess(apiPath, config.apiPort, rootDir),\n {\n name: 'Web',\n command: 'pnpm',\n args: ['exec', 'wexts', 'start', '-c', runtimeConfigPath, '-p', config.webPort.toString(), '--dev'],\n cwd: rootDir,\n color: 'green',\n env: {\n NEXT_PUBLIC_API_URL: `http://localhost:${config.apiPort}`,\n WEXTS_WEB_DIR: webPath,\n },\n },\n ];\n }\n\n private createApiCompilerProcess(apiPath: string, apiPort: number, rootDir: string): ProcessConfig {\n if (fs.existsSync(path.join(apiPath, 'package.json'))) {\n return {\n name: 'API',\n command: 'pnpm',\n args: ['run', 'start:dev'],\n cwd: apiPath,\n color: 'cyan',\n env: {\n PORT: apiPort.toString(),\n },\n };\n }\n\n return {\n name: 'API',\n command: 'pnpm',\n args: ['exec', 'tsc', '-w', '-p', path.join(apiPath, 'tsconfig.json')],\n cwd: rootDir,\n color: 'cyan',\n env: {\n PORT: apiPort.toString(),\n },\n };\n }\n\n stop(): void {\n this.processRunner.stopAll();\n }\n}\n","import http from 'http';\nimport httpProxy from 'http-proxy';\nimport { logger } from '../core/logger';\nimport * as pc from 'picocolors';\n\nexport interface ProxyConfig {\n port: number;\n apiTarget: string;\n apiPrefix: string;\n}\n\n/**\n * Proxy server to forward API requests from Next.js to NestJS\n */\nexport class ProxyServer {\n private server: http.Server | null = null;\n private proxy: httpProxy | null = null;\n\n async start(config: ProxyConfig): Promise<void> {\n const { port, apiTarget, apiPrefix } = config;\n\n this.proxy = httpProxy.createProxyServer({\n target: apiTarget,\n changeOrigin: true,\n ws: true, // WebSocket support\n });\n\n // Handle proxy errors\n this.proxy.on('error', (err, req, res) => {\n logger.error('Proxy error:', err.message);\n if (res && 'headersSent' in res && !(res as any).headersSent) {\n (res as http.ServerResponse).writeHead(502, { 'Content-Type': 'text/plain' });\n (res as http.ServerResponse).end('Bad Gateway - API server unavailable');\n }\n });\n\n this.server = http.createServer((req, res) => {\n // Check if request is for API\n if (req.url?.startsWith(apiPrefix)) {\n // Remove prefix before forwarding\n const newUrl = req.url.substring(apiPrefix.length) || '/';\n req.url = newUrl;\n\n logger.info(pc.gray(`→ ${req.method} ${apiPrefix}${newUrl}`));\n this.proxy!.web(req, res);\n } else {\n // Not an API request - should not happen\n res.writeHead(404);\n res.end('Not Found');\n }\n });\n\n // Handle WebSocket upgrade\n this.server.on('upgrade', (req, socket, head) => {\n if (req.url?.startsWith(apiPrefix)) {\n const newUrl = req.url.substring(apiPrefix.length) || '/';\n req.url = newUrl;\n this.proxy!.ws(req, socket, head);\n }\n });\n\n return new Promise((resolve) => {\n this.server!.listen(port, () => {\n logger.success(`āœ… Proxy server running on port ${port}`);\n logger.info(` Forwarding ${pc.cyan(apiPrefix + '/*')} → ${pc.cyan(apiTarget)}\\n`);\n resolve();\n });\n });\n }\n\n stop(): void {\n if (this.server) {\n this.server.close();\n this.server = null;\n }\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AAWnB,SAAAA,GAAY;AAEhC,cAAMoB,SAASZ,IAAIU,IAAIG,UAAUrB,UAAUsB,MAAM,KAAK;AACtDd,YAAIU,MAAME;AAEVV,eAAOa,KAAQC,SAAK,UAAKhB,IAAIiB,MAAM,IAAIzB,SAAAA,GAAYoB,MAAAA,EAAQ,CAAA;AAC3D,aAAKzB,MAAO+B,IAAIlB,KAAKC,GAAAA;MACzB,OAAO;AAEHA,YAAIK,UAAU,GAAA;AACdL,YAAIM,IAAI,WAAA;MACZ;IACJ,CAAA;AAGA,SAAKrB,OAAOY,GAAG,WAAW,CAACE,KAAKmB,QAAQC,SAAAA;AACpC,UAAIpB,IAAIU,KAAKC,WAAWnB,SAAAA,GAAY;AAChC,cAAMoB,SAASZ,IAAIU,IAAIG,UAAUrB,UAAUsB,MAAM,KAAK;AACtDd,YAAIU,MAAME;AACV,aAAKzB,MAAOU,GAAGG,KAAKmB,QAAQC,IAAAA;MAChC;IACJ,CAAA;AAEA,WAAO,IAAIC,QAAQ,CAACC,aAAAA;AAChB,WAAKpC,OAAQqC,OAAOjC,MAAM,MAAA;AACtBY,eAAOsB,QAAQ,uCAAkClC,IAAAA,EAAM;AACvDY,eAAOa,KAAK,iBAAoBU,SAAKjC,YAAY,IAAA,CAAA,WAAciC,SAAKlC,SAAAA,CAAAA;CAAc;AAClF+B,QAAAA,SAAAA;MACJ,CAAA;IACJ,CAAA;EACJ;EAEAI,OAAa;AACT,QAAI,KAAKxC,QAAQ;AACb,WAAKA,OAAOyC,MAAK;AACjB,WAAKzC,SAAS;IAClB;AACA,QAAI,KAAKC,OAAO;AACZ,WAAKA,MAAMwC,MAAK;AAChB,WAAKxC,QAAQ;IACjB;EACJ;AACJ;","names":["spawn","pc","ProcessRunner","processes","Map","colors","cyan","green","yellow","magenta","blue","run","configs","logger","info","config","startProcess","process","on","stopAll","name","command","args","cwd","color","env","colorFn","prefix","proc","spawn","stdio","shell","set","stdout","data","lines","toString","split","filter","l","trim","forEach","line","console","log","stderr","error","red","code","delete","message","entries","kill","setTimeout","exit","isRunning","has","path","fs","DEFAULT_RUNTIME_CONFIG","FusionDevServer","processRunner","ProcessRunner","start","config","apiPath","webPath","webPort","apiPort","useProxy","rootDir","process","cwd","runtimeConfigPath","Error","existsSync","absoluteRuntimeConfigPath","isAbsolute","join","resolve","processes","createProcessConfigs","run","logger","info","createApiCompilerProcess","name","command","args","toString","color","env","NEXT_PUBLIC_API_URL","WEXTS_WEB_DIR","PORT","stop","stopAll","http","httpProxy","pc","ProxyServer","server","proxy","start","config","port","apiTarget","apiPrefix","httpProxy","createProxyServer","target","changeOrigin","ws","on","err","req","res","logger","error","message","headersSent","writeHead","end","http","createServer","url","startsWith","newUrl","substring","length","info","gray","method","web","socket","head","Promise","resolve","listen","success","cyan","stop","close"]}