@builder.io/dev-tools 1.11.39 → 1.11.40-dev.202509171209.3df80badd
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.
- package/angular/index.cjs +46 -1
- package/angular/index.mjs +21 -1
- package/cli/index.cjs +112609 -3896
- package/cli/index.cjs.map +4 -4
- package/core/index.cjs +14132 -790
- package/core/index.mjs +14122 -790
- package/figma/index.cjs +47 -1
- package/figma/index.mjs +27 -1
- package/node/index.cjs +25323 -105
- package/node/index.mjs +25327 -105
- package/package.json +2 -3
- package/remix/build.cjs +132 -1
- package/remix/index.mjs +113 -1
- package/server/index.cjs +21342 -1595
- package/server/index.mjs +21339 -1593
- package/types/cli/backup.d.ts +3 -1
- package/types/cli/credentials.d.ts +1 -1
- package/types/cli/launch/InitStateMachine.d.ts +1 -0
- package/types/cli/launch/dev-server-orchestrator.d.ts +2 -2
- package/types/cli/launch/proxy.d.ts +2 -2
- package/types/cli/utils/git.d.ts +11 -0
- package/types/tsconfig.tsbuildinfo +1 -1
- package/types/types/codegen-server.d.ts +14 -0
- package/types/types/connection-tracker.d.ts +31 -0
- package/types/types/proxy-middleware.d.ts +31 -0
- package/types/types/websocket-types.d.ts +17 -0
- package/vite/index.cjs +153 -3
- package/vite/index.mjs +119 -3
- package/webpack/index.cjs +2883 -27
- package/webpack/index.mjs +2871 -27
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type for methods that can be called on the code generation server
|
|
3
|
+
*/
|
|
4
|
+
export type CodeGenMethod = (...args: any[]) => any;
|
|
5
|
+
/**
|
|
6
|
+
* Type for the code generation server object
|
|
7
|
+
*/
|
|
8
|
+
export interface CodeGenServer {
|
|
9
|
+
[key: string]: CodeGenMethod | undefined;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Type guard to check if a value is a valid CodeGenMethod
|
|
13
|
+
*/
|
|
14
|
+
export declare function isCodeGenMethod(value: any): value is CodeGenMethod;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Duplex } from "stream";
|
|
2
|
+
import type { DevToolsSys } from "../types";
|
|
3
|
+
/**
|
|
4
|
+
* Tracks active WebSocket connections to prevent memory leaks
|
|
5
|
+
*/
|
|
6
|
+
export declare class ConnectionTracker {
|
|
7
|
+
private connections;
|
|
8
|
+
private maxConnections;
|
|
9
|
+
private sys;
|
|
10
|
+
constructor(sys: DevToolsSys);
|
|
11
|
+
/**
|
|
12
|
+
* Add a connection to tracking
|
|
13
|
+
*/
|
|
14
|
+
addConnection(socket: Duplex, req?: any): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Remove a connection from tracking
|
|
17
|
+
*/
|
|
18
|
+
removeConnection(socket: Duplex): void;
|
|
19
|
+
/**
|
|
20
|
+
* Get current connection count
|
|
21
|
+
*/
|
|
22
|
+
getConnectionCount(): number;
|
|
23
|
+
/**
|
|
24
|
+
* Clean up all connections
|
|
25
|
+
*/
|
|
26
|
+
cleanup(): void;
|
|
27
|
+
/**
|
|
28
|
+
* Get git information for context
|
|
29
|
+
*/
|
|
30
|
+
private getGitInfo;
|
|
31
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Request, Response, NextFunction } from "express";
|
|
2
|
+
import type { IncomingMessage } from "http";
|
|
3
|
+
import type { Duplex } from "stream";
|
|
4
|
+
/**
|
|
5
|
+
* Express middleware function type
|
|
6
|
+
*/
|
|
7
|
+
export type MiddlewareFunction = (req: Request, res: Response, next: NextFunction) => void;
|
|
8
|
+
/**
|
|
9
|
+
* WebSocket upgrade function type
|
|
10
|
+
*/
|
|
11
|
+
export type WebSocketUpgradeFunction = (req: IncomingMessage, socket: Duplex, head: Buffer) => void;
|
|
12
|
+
/**
|
|
13
|
+
* Extended Express middleware that includes WebSocket upgrade functionality
|
|
14
|
+
*/
|
|
15
|
+
export interface ProxyMiddleware extends MiddlewareFunction {
|
|
16
|
+
/**
|
|
17
|
+
* Handle WebSocket upgrade requests
|
|
18
|
+
* @param req - The incoming request
|
|
19
|
+
* @param socket - The socket connection
|
|
20
|
+
* @param head - The first packet of the upgraded stream
|
|
21
|
+
*/
|
|
22
|
+
upgrade?: WebSocketUpgradeFunction;
|
|
23
|
+
/**
|
|
24
|
+
* Cleanup method for graceful shutdown
|
|
25
|
+
*/
|
|
26
|
+
cleanup?: () => void;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Type guard to check if a middleware has WebSocket upgrade capability
|
|
30
|
+
*/
|
|
31
|
+
export declare function hasUpgrade(middleware: any): middleware is ProxyMiddleware;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { IncomingMessage } from "http";
|
|
2
|
+
import type { Socket } from "net";
|
|
3
|
+
/**
|
|
4
|
+
* WebSocket upgrade request parameters
|
|
5
|
+
*/
|
|
6
|
+
export interface WebSocketUpgradeParams {
|
|
7
|
+
/** The incoming HTTP request */
|
|
8
|
+
req: IncomingMessage;
|
|
9
|
+
/** The socket connection */
|
|
10
|
+
socket: Socket;
|
|
11
|
+
/** The first packet of the upgraded stream */
|
|
12
|
+
head: Buffer;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Type guard to check if an object has WebSocket upgrade parameters
|
|
16
|
+
*/
|
|
17
|
+
export declare function isWebSocketUpgradeParams(obj: any): obj is WebSocketUpgradeParams;
|
package/vite/index.cjs
CHANGED
|
@@ -1,3 +1,153 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// packages/dev-tools/vite/main.ts
|
|
31
|
+
var main_exports = {};
|
|
32
|
+
__export(main_exports, {
|
|
33
|
+
builderDevTools: () => builderDevTools
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(main_exports);
|
|
36
|
+
var import_core = require("../core/index.cjs");
|
|
37
|
+
var import_node = require("../node/index.cjs");
|
|
38
|
+
var import_server = require("../server/index.cjs");
|
|
39
|
+
|
|
40
|
+
// packages/dev-tools/common/dotenv.ts
|
|
41
|
+
async function parseDotEnvFile(sys, envPath) {
|
|
42
|
+
const envContent = await sys.readFile(envPath);
|
|
43
|
+
if (typeof envContent === "string") {
|
|
44
|
+
return parseDotEnvContent(envContent);
|
|
45
|
+
}
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
function parseDotEnvContent(envContent) {
|
|
49
|
+
const envVars = {};
|
|
50
|
+
const lines = envContent.replace(/\r\n?/gm, "\n");
|
|
51
|
+
let match;
|
|
52
|
+
while ((match = DOTENV_LINE.exec(lines)) != null) {
|
|
53
|
+
const key = match[1];
|
|
54
|
+
let value = match[2] || "";
|
|
55
|
+
value = value.trim();
|
|
56
|
+
const maybeQuote = value[0];
|
|
57
|
+
value = value.replace(/^(['"`])([\s\S]*)\1$/gm, "$2");
|
|
58
|
+
if (maybeQuote === '"') {
|
|
59
|
+
value = value.replace(/\\n/g, "\n");
|
|
60
|
+
value = value.replace(/\\r/g, "\r");
|
|
61
|
+
}
|
|
62
|
+
envVars[key] = value;
|
|
63
|
+
}
|
|
64
|
+
return envVars;
|
|
65
|
+
}
|
|
66
|
+
var DOTENV_LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;
|
|
67
|
+
|
|
68
|
+
// packages/dev-tools/vite/main.ts
|
|
69
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
70
|
+
|
|
71
|
+
// packages/dev-tools/common/constants.ts
|
|
72
|
+
var DEV_TOOLS_CLIENT_SCRIPT_PATH = "/~builder-dev-tools.js";
|
|
73
|
+
|
|
74
|
+
// packages/dev-tools/vite/main.ts
|
|
75
|
+
function builderDevTools(opts = {}) {
|
|
76
|
+
const plugin = {
|
|
77
|
+
name: "vite-plugin-builder-dev-tools",
|
|
78
|
+
async configureServer(viteDevServer) {
|
|
79
|
+
if (process.argv.includes("codegen")) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const sys = await (0, import_node.createDevToolsNodeSys)({
|
|
83
|
+
cwd: import_node_path.default.normalize(viteDevServer.config.root)
|
|
84
|
+
});
|
|
85
|
+
const devTools = await (0, import_core.createDevTools)(sys);
|
|
86
|
+
const devToolsServer = await (0, import_server.createDevToolsServer)({
|
|
87
|
+
...devTools,
|
|
88
|
+
getClientId: () => "vite-builder-dev-tools",
|
|
89
|
+
closeAppServer: async () => {
|
|
90
|
+
sys.debug("close server");
|
|
91
|
+
await viteDevServer?.close();
|
|
92
|
+
},
|
|
93
|
+
restartAppServer: async () => {
|
|
94
|
+
sys.debug("restart server");
|
|
95
|
+
await viteDevServer?.restart();
|
|
96
|
+
},
|
|
97
|
+
enableAppWatch: async (enable) => {
|
|
98
|
+
if (enable) {
|
|
99
|
+
sys.debug("enable watch");
|
|
100
|
+
viteDevServer?.watcher.add(viteDevServer.config.root);
|
|
101
|
+
const gitPath = sys.join(viteDevServer.config.root, ".git");
|
|
102
|
+
const nodeModulesPath = sys.join(
|
|
103
|
+
viteDevServer.config.root,
|
|
104
|
+
"node_modules"
|
|
105
|
+
);
|
|
106
|
+
viteDevServer?.watcher.unwatch([gitPath, nodeModulesPath]);
|
|
107
|
+
} else {
|
|
108
|
+
sys.debug("disable watch");
|
|
109
|
+
viteDevServer?.watcher.unwatch(viteDevServer.config.root);
|
|
110
|
+
}
|
|
111
|
+
return enable;
|
|
112
|
+
},
|
|
113
|
+
...sys,
|
|
114
|
+
...opts
|
|
115
|
+
});
|
|
116
|
+
viteDevServer.watcher.on("change", async (filePath) => {
|
|
117
|
+
if (filePath.includes(".env")) {
|
|
118
|
+
const envVars = await parseDotEnvFile(sys, filePath);
|
|
119
|
+
if (envVars) {
|
|
120
|
+
const envKeys = Object.keys(envVars);
|
|
121
|
+
envKeys.forEach((key) => {
|
|
122
|
+
process.env[key] = envVars[key];
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
viteDevServer.middlewares.use(async (_req, res, next) => {
|
|
128
|
+
try {
|
|
129
|
+
const orgResponseEnd = res.end;
|
|
130
|
+
res.end = function(...args) {
|
|
131
|
+
const contentType = (res.getHeader("Content-Type") || "").toString();
|
|
132
|
+
if (contentType.includes("text/html")) {
|
|
133
|
+
const url = new URL(
|
|
134
|
+
DEV_TOOLS_CLIENT_SCRIPT_PATH,
|
|
135
|
+
devToolsServer.getUrl()
|
|
136
|
+
);
|
|
137
|
+
res.write(`<script defer src="${url}"></script>`);
|
|
138
|
+
}
|
|
139
|
+
return orgResponseEnd.apply(this, args);
|
|
140
|
+
};
|
|
141
|
+
next();
|
|
142
|
+
} catch (e) {
|
|
143
|
+
next(e);
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
return plugin;
|
|
149
|
+
}
|
|
150
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
151
|
+
0 && (module.exports = {
|
|
152
|
+
builderDevTools
|
|
153
|
+
});
|
package/vite/index.mjs
CHANGED
|
@@ -1,4 +1,120 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
|
|
3
|
+
// packages/dev-tools/vite/main.ts
|
|
4
|
+
import { createDevTools } from "../core/index.mjs";
|
|
5
|
+
import { createDevToolsNodeSys } from "../node/index.mjs";
|
|
6
|
+
import { createDevToolsServer } from "../server/index.mjs";
|
|
7
|
+
|
|
8
|
+
// packages/dev-tools/common/dotenv.ts
|
|
9
|
+
async function parseDotEnvFile(sys, envPath) {
|
|
10
|
+
const envContent = await sys.readFile(envPath);
|
|
11
|
+
if (typeof envContent === "string") {
|
|
12
|
+
return parseDotEnvContent(envContent);
|
|
13
|
+
}
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
function parseDotEnvContent(envContent) {
|
|
17
|
+
const envVars = {};
|
|
18
|
+
const lines = envContent.replace(/\r\n?/gm, "\n");
|
|
19
|
+
let match;
|
|
20
|
+
while ((match = DOTENV_LINE.exec(lines)) != null) {
|
|
21
|
+
const key = match[1];
|
|
22
|
+
let value = match[2] || "";
|
|
23
|
+
value = value.trim();
|
|
24
|
+
const maybeQuote = value[0];
|
|
25
|
+
value = value.replace(/^(['"`])([\s\S]*)\1$/gm, "$2");
|
|
26
|
+
if (maybeQuote === '"') {
|
|
27
|
+
value = value.replace(/\\n/g, "\n");
|
|
28
|
+
value = value.replace(/\\r/g, "\r");
|
|
29
|
+
}
|
|
30
|
+
envVars[key] = value;
|
|
31
|
+
}
|
|
32
|
+
return envVars;
|
|
33
|
+
}
|
|
34
|
+
var DOTENV_LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;
|
|
35
|
+
|
|
36
|
+
// packages/dev-tools/vite/main.ts
|
|
37
|
+
import path from "path";
|
|
38
|
+
|
|
39
|
+
// packages/dev-tools/common/constants.ts
|
|
40
|
+
var DEV_TOOLS_CLIENT_SCRIPT_PATH = "/~builder-dev-tools.js";
|
|
41
|
+
|
|
42
|
+
// packages/dev-tools/vite/main.ts
|
|
43
|
+
function builderDevTools(opts = {}) {
|
|
44
|
+
const plugin = {
|
|
45
|
+
name: "vite-plugin-builder-dev-tools",
|
|
46
|
+
async configureServer(viteDevServer) {
|
|
47
|
+
if (process.argv.includes("codegen")) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const sys = await createDevToolsNodeSys({
|
|
51
|
+
cwd: path.normalize(viteDevServer.config.root)
|
|
52
|
+
});
|
|
53
|
+
const devTools = await createDevTools(sys);
|
|
54
|
+
const devToolsServer = await createDevToolsServer({
|
|
55
|
+
...devTools,
|
|
56
|
+
getClientId: () => "vite-builder-dev-tools",
|
|
57
|
+
closeAppServer: async () => {
|
|
58
|
+
sys.debug("close server");
|
|
59
|
+
await viteDevServer?.close();
|
|
60
|
+
},
|
|
61
|
+
restartAppServer: async () => {
|
|
62
|
+
sys.debug("restart server");
|
|
63
|
+
await viteDevServer?.restart();
|
|
64
|
+
},
|
|
65
|
+
enableAppWatch: async (enable) => {
|
|
66
|
+
if (enable) {
|
|
67
|
+
sys.debug("enable watch");
|
|
68
|
+
viteDevServer?.watcher.add(viteDevServer.config.root);
|
|
69
|
+
const gitPath = sys.join(viteDevServer.config.root, ".git");
|
|
70
|
+
const nodeModulesPath = sys.join(
|
|
71
|
+
viteDevServer.config.root,
|
|
72
|
+
"node_modules"
|
|
73
|
+
);
|
|
74
|
+
viteDevServer?.watcher.unwatch([gitPath, nodeModulesPath]);
|
|
75
|
+
} else {
|
|
76
|
+
sys.debug("disable watch");
|
|
77
|
+
viteDevServer?.watcher.unwatch(viteDevServer.config.root);
|
|
78
|
+
}
|
|
79
|
+
return enable;
|
|
80
|
+
},
|
|
81
|
+
...sys,
|
|
82
|
+
...opts
|
|
83
|
+
});
|
|
84
|
+
viteDevServer.watcher.on("change", async (filePath) => {
|
|
85
|
+
if (filePath.includes(".env")) {
|
|
86
|
+
const envVars = await parseDotEnvFile(sys, filePath);
|
|
87
|
+
if (envVars) {
|
|
88
|
+
const envKeys = Object.keys(envVars);
|
|
89
|
+
envKeys.forEach((key) => {
|
|
90
|
+
process.env[key] = envVars[key];
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
viteDevServer.middlewares.use(async (_req, res, next) => {
|
|
96
|
+
try {
|
|
97
|
+
const orgResponseEnd = res.end;
|
|
98
|
+
res.end = function(...args) {
|
|
99
|
+
const contentType = (res.getHeader("Content-Type") || "").toString();
|
|
100
|
+
if (contentType.includes("text/html")) {
|
|
101
|
+
const url = new URL(
|
|
102
|
+
DEV_TOOLS_CLIENT_SCRIPT_PATH,
|
|
103
|
+
devToolsServer.getUrl()
|
|
104
|
+
);
|
|
105
|
+
res.write(`<script defer src="${url}"></script>`);
|
|
106
|
+
}
|
|
107
|
+
return orgResponseEnd.apply(this, args);
|
|
108
|
+
};
|
|
109
|
+
next();
|
|
110
|
+
} catch (e) {
|
|
111
|
+
next(e);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
return plugin;
|
|
117
|
+
}
|
|
118
|
+
export {
|
|
119
|
+
builderDevTools
|
|
120
|
+
};
|