@react-grab/cursor 0.0.78 → 0.0.80
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/dist/cli.cjs +498 -4
- package/dist/cli.js +498 -4
- package/dist/client.cjs +38 -16
- package/dist/client.d.cts +2 -1
- package/dist/client.d.ts +2 -1
- package/dist/client.global.js +3 -3
- package/dist/client.js +38 -16
- package/dist/server.cjs +656 -70
- package/dist/server.js +656 -69
- package/package.json +6 -2
package/dist/server.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { spawn } from 'child_process';
|
|
2
|
-
import net from 'net';
|
|
3
1
|
import { pathToFileURL } from 'url';
|
|
4
2
|
import { createServer as createServer$1 } from 'http';
|
|
5
3
|
import { Http2ServerRequest } from 'http2';
|
|
@@ -12,7 +10,13 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
12
10
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
11
|
var __getProtoOf = Object.getPrototypeOf;
|
|
14
12
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
15
|
-
var
|
|
13
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
14
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
15
|
+
}) : x)(function(x) {
|
|
16
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
17
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
18
|
+
});
|
|
19
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
16
20
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
17
21
|
};
|
|
18
22
|
var __copyProps = (to, from, except, desc) => {
|
|
@@ -32,6 +36,572 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
32
36
|
mod
|
|
33
37
|
));
|
|
34
38
|
|
|
39
|
+
// ../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.js
|
|
40
|
+
var require_windows = __commonJS({
|
|
41
|
+
"../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.js"(exports, module) {
|
|
42
|
+
module.exports = isexe;
|
|
43
|
+
isexe.sync = sync;
|
|
44
|
+
var fs = __require("fs");
|
|
45
|
+
function checkPathExt(path, options) {
|
|
46
|
+
var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
|
|
47
|
+
if (!pathext) {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
pathext = pathext.split(";");
|
|
51
|
+
if (pathext.indexOf("") !== -1) {
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
for (var i = 0; i < pathext.length; i++) {
|
|
55
|
+
var p = pathext[i].toLowerCase();
|
|
56
|
+
if (p && path.substr(-p.length).toLowerCase() === p) {
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
function checkStat(stat, path, options) {
|
|
63
|
+
if (!stat.isSymbolicLink() && !stat.isFile()) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
return checkPathExt(path, options);
|
|
67
|
+
}
|
|
68
|
+
function isexe(path, options, cb) {
|
|
69
|
+
fs.stat(path, function(er, stat) {
|
|
70
|
+
cb(er, er ? false : checkStat(stat, path, options));
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
function sync(path, options) {
|
|
74
|
+
return checkStat(fs.statSync(path), path, options);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
// ../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/mode.js
|
|
80
|
+
var require_mode = __commonJS({
|
|
81
|
+
"../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/mode.js"(exports, module) {
|
|
82
|
+
module.exports = isexe;
|
|
83
|
+
isexe.sync = sync;
|
|
84
|
+
var fs = __require("fs");
|
|
85
|
+
function isexe(path, options, cb) {
|
|
86
|
+
fs.stat(path, function(er, stat) {
|
|
87
|
+
cb(er, er ? false : checkStat(stat, options));
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
function sync(path, options) {
|
|
91
|
+
return checkStat(fs.statSync(path), options);
|
|
92
|
+
}
|
|
93
|
+
function checkStat(stat, options) {
|
|
94
|
+
return stat.isFile() && checkMode(stat, options);
|
|
95
|
+
}
|
|
96
|
+
function checkMode(stat, options) {
|
|
97
|
+
var mod = stat.mode;
|
|
98
|
+
var uid = stat.uid;
|
|
99
|
+
var gid = stat.gid;
|
|
100
|
+
var myUid = options.uid !== void 0 ? options.uid : process.getuid && process.getuid();
|
|
101
|
+
var myGid = options.gid !== void 0 ? options.gid : process.getgid && process.getgid();
|
|
102
|
+
var u = parseInt("100", 8);
|
|
103
|
+
var g = parseInt("010", 8);
|
|
104
|
+
var o = parseInt("001", 8);
|
|
105
|
+
var ug = u | g;
|
|
106
|
+
var ret = mod & o || mod & g && gid === myGid || mod & u && uid === myUid || mod & ug && myUid === 0;
|
|
107
|
+
return ret;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
// ../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js
|
|
113
|
+
var require_isexe = __commonJS({
|
|
114
|
+
"../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js"(exports, module) {
|
|
115
|
+
__require("fs");
|
|
116
|
+
var core;
|
|
117
|
+
if (process.platform === "win32" || global.TESTING_WINDOWS) {
|
|
118
|
+
core = require_windows();
|
|
119
|
+
} else {
|
|
120
|
+
core = require_mode();
|
|
121
|
+
}
|
|
122
|
+
module.exports = isexe;
|
|
123
|
+
isexe.sync = sync;
|
|
124
|
+
function isexe(path, options, cb) {
|
|
125
|
+
if (typeof options === "function") {
|
|
126
|
+
cb = options;
|
|
127
|
+
options = {};
|
|
128
|
+
}
|
|
129
|
+
if (!cb) {
|
|
130
|
+
if (typeof Promise !== "function") {
|
|
131
|
+
throw new TypeError("callback not provided");
|
|
132
|
+
}
|
|
133
|
+
return new Promise(function(resolve, reject) {
|
|
134
|
+
isexe(path, options || {}, function(er, is) {
|
|
135
|
+
if (er) {
|
|
136
|
+
reject(er);
|
|
137
|
+
} else {
|
|
138
|
+
resolve(is);
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
core(path, options || {}, function(er, is) {
|
|
144
|
+
if (er) {
|
|
145
|
+
if (er.code === "EACCES" || options && options.ignoreErrors) {
|
|
146
|
+
er = null;
|
|
147
|
+
is = false;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
cb(er, is);
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
function sync(path, options) {
|
|
154
|
+
try {
|
|
155
|
+
return core.sync(path, options || {});
|
|
156
|
+
} catch (er) {
|
|
157
|
+
if (options && options.ignoreErrors || er.code === "EACCES") {
|
|
158
|
+
return false;
|
|
159
|
+
} else {
|
|
160
|
+
throw er;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
// ../../node_modules/.pnpm/which@2.0.2/node_modules/which/which.js
|
|
168
|
+
var require_which = __commonJS({
|
|
169
|
+
"../../node_modules/.pnpm/which@2.0.2/node_modules/which/which.js"(exports, module) {
|
|
170
|
+
var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
|
|
171
|
+
var path = __require("path");
|
|
172
|
+
var COLON = isWindows ? ";" : ":";
|
|
173
|
+
var isexe = require_isexe();
|
|
174
|
+
var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
|
|
175
|
+
var getPathInfo = (cmd, opt) => {
|
|
176
|
+
const colon = opt.colon || COLON;
|
|
177
|
+
const pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? [""] : [
|
|
178
|
+
// windows always checks the cwd first
|
|
179
|
+
...isWindows ? [process.cwd()] : [],
|
|
180
|
+
...(opt.path || process.env.PATH || /* istanbul ignore next: very unusual */
|
|
181
|
+
"").split(colon)
|
|
182
|
+
];
|
|
183
|
+
const pathExtExe = isWindows ? opt.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM" : "";
|
|
184
|
+
const pathExt = isWindows ? pathExtExe.split(colon) : [""];
|
|
185
|
+
if (isWindows) {
|
|
186
|
+
if (cmd.indexOf(".") !== -1 && pathExt[0] !== "")
|
|
187
|
+
pathExt.unshift("");
|
|
188
|
+
}
|
|
189
|
+
return {
|
|
190
|
+
pathEnv,
|
|
191
|
+
pathExt,
|
|
192
|
+
pathExtExe
|
|
193
|
+
};
|
|
194
|
+
};
|
|
195
|
+
var which = (cmd, opt, cb) => {
|
|
196
|
+
if (typeof opt === "function") {
|
|
197
|
+
cb = opt;
|
|
198
|
+
opt = {};
|
|
199
|
+
}
|
|
200
|
+
if (!opt)
|
|
201
|
+
opt = {};
|
|
202
|
+
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
203
|
+
const found = [];
|
|
204
|
+
const step = (i) => new Promise((resolve, reject) => {
|
|
205
|
+
if (i === pathEnv.length)
|
|
206
|
+
return opt.all && found.length ? resolve(found) : reject(getNotFoundError(cmd));
|
|
207
|
+
const ppRaw = pathEnv[i];
|
|
208
|
+
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
209
|
+
const pCmd = path.join(pathPart, cmd);
|
|
210
|
+
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
211
|
+
resolve(subStep(p, i, 0));
|
|
212
|
+
});
|
|
213
|
+
const subStep = (p, i, ii) => new Promise((resolve, reject) => {
|
|
214
|
+
if (ii === pathExt.length)
|
|
215
|
+
return resolve(step(i + 1));
|
|
216
|
+
const ext = pathExt[ii];
|
|
217
|
+
isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
|
|
218
|
+
if (!er && is) {
|
|
219
|
+
if (opt.all)
|
|
220
|
+
found.push(p + ext);
|
|
221
|
+
else
|
|
222
|
+
return resolve(p + ext);
|
|
223
|
+
}
|
|
224
|
+
return resolve(subStep(p, i, ii + 1));
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
|
|
228
|
+
};
|
|
229
|
+
var whichSync = (cmd, opt) => {
|
|
230
|
+
opt = opt || {};
|
|
231
|
+
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
232
|
+
const found = [];
|
|
233
|
+
for (let i = 0; i < pathEnv.length; i++) {
|
|
234
|
+
const ppRaw = pathEnv[i];
|
|
235
|
+
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
236
|
+
const pCmd = path.join(pathPart, cmd);
|
|
237
|
+
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
238
|
+
for (let j = 0; j < pathExt.length; j++) {
|
|
239
|
+
const cur = p + pathExt[j];
|
|
240
|
+
try {
|
|
241
|
+
const is = isexe.sync(cur, { pathExt: pathExtExe });
|
|
242
|
+
if (is) {
|
|
243
|
+
if (opt.all)
|
|
244
|
+
found.push(cur);
|
|
245
|
+
else
|
|
246
|
+
return cur;
|
|
247
|
+
}
|
|
248
|
+
} catch (ex) {
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
if (opt.all && found.length)
|
|
253
|
+
return found;
|
|
254
|
+
if (opt.nothrow)
|
|
255
|
+
return null;
|
|
256
|
+
throw getNotFoundError(cmd);
|
|
257
|
+
};
|
|
258
|
+
module.exports = which;
|
|
259
|
+
which.sync = whichSync;
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
// ../../node_modules/.pnpm/path-key@3.1.1/node_modules/path-key/index.js
|
|
264
|
+
var require_path_key = __commonJS({
|
|
265
|
+
"../../node_modules/.pnpm/path-key@3.1.1/node_modules/path-key/index.js"(exports, module) {
|
|
266
|
+
var pathKey = (options = {}) => {
|
|
267
|
+
const environment = options.env || process.env;
|
|
268
|
+
const platform = options.platform || process.platform;
|
|
269
|
+
if (platform !== "win32") {
|
|
270
|
+
return "PATH";
|
|
271
|
+
}
|
|
272
|
+
return Object.keys(environment).reverse().find((key) => key.toUpperCase() === "PATH") || "Path";
|
|
273
|
+
};
|
|
274
|
+
module.exports = pathKey;
|
|
275
|
+
module.exports.default = pathKey;
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
// ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js
|
|
280
|
+
var require_resolveCommand = __commonJS({
|
|
281
|
+
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js"(exports, module) {
|
|
282
|
+
var path = __require("path");
|
|
283
|
+
var which = require_which();
|
|
284
|
+
var getPathKey = require_path_key();
|
|
285
|
+
function resolveCommandAttempt(parsed, withoutPathExt) {
|
|
286
|
+
const env = parsed.options.env || process.env;
|
|
287
|
+
const cwd = process.cwd();
|
|
288
|
+
const hasCustomCwd = parsed.options.cwd != null;
|
|
289
|
+
const shouldSwitchCwd = hasCustomCwd && process.chdir !== void 0 && !process.chdir.disabled;
|
|
290
|
+
if (shouldSwitchCwd) {
|
|
291
|
+
try {
|
|
292
|
+
process.chdir(parsed.options.cwd);
|
|
293
|
+
} catch (err) {
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
let resolved;
|
|
297
|
+
try {
|
|
298
|
+
resolved = which.sync(parsed.command, {
|
|
299
|
+
path: env[getPathKey({ env })],
|
|
300
|
+
pathExt: withoutPathExt ? path.delimiter : void 0
|
|
301
|
+
});
|
|
302
|
+
} catch (e) {
|
|
303
|
+
} finally {
|
|
304
|
+
if (shouldSwitchCwd) {
|
|
305
|
+
process.chdir(cwd);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
if (resolved) {
|
|
309
|
+
resolved = path.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
|
|
310
|
+
}
|
|
311
|
+
return resolved;
|
|
312
|
+
}
|
|
313
|
+
function resolveCommand(parsed) {
|
|
314
|
+
return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true);
|
|
315
|
+
}
|
|
316
|
+
module.exports = resolveCommand;
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
// ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/escape.js
|
|
321
|
+
var require_escape = __commonJS({
|
|
322
|
+
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/escape.js"(exports, module) {
|
|
323
|
+
var metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
|
|
324
|
+
function escapeCommand(arg) {
|
|
325
|
+
arg = arg.replace(metaCharsRegExp, "^$1");
|
|
326
|
+
return arg;
|
|
327
|
+
}
|
|
328
|
+
function escapeArgument(arg, doubleEscapeMetaChars) {
|
|
329
|
+
arg = `${arg}`;
|
|
330
|
+
arg = arg.replace(/(?=(\\+?)?)\1"/g, '$1$1\\"');
|
|
331
|
+
arg = arg.replace(/(?=(\\+?)?)\1$/, "$1$1");
|
|
332
|
+
arg = `"${arg}"`;
|
|
333
|
+
arg = arg.replace(metaCharsRegExp, "^$1");
|
|
334
|
+
if (doubleEscapeMetaChars) {
|
|
335
|
+
arg = arg.replace(metaCharsRegExp, "^$1");
|
|
336
|
+
}
|
|
337
|
+
return arg;
|
|
338
|
+
}
|
|
339
|
+
module.exports.command = escapeCommand;
|
|
340
|
+
module.exports.argument = escapeArgument;
|
|
341
|
+
}
|
|
342
|
+
});
|
|
343
|
+
|
|
344
|
+
// ../../node_modules/.pnpm/shebang-regex@3.0.0/node_modules/shebang-regex/index.js
|
|
345
|
+
var require_shebang_regex = __commonJS({
|
|
346
|
+
"../../node_modules/.pnpm/shebang-regex@3.0.0/node_modules/shebang-regex/index.js"(exports, module) {
|
|
347
|
+
module.exports = /^#!(.*)/;
|
|
348
|
+
}
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
// ../../node_modules/.pnpm/shebang-command@2.0.0/node_modules/shebang-command/index.js
|
|
352
|
+
var require_shebang_command = __commonJS({
|
|
353
|
+
"../../node_modules/.pnpm/shebang-command@2.0.0/node_modules/shebang-command/index.js"(exports, module) {
|
|
354
|
+
var shebangRegex = require_shebang_regex();
|
|
355
|
+
module.exports = (string = "") => {
|
|
356
|
+
const match2 = string.match(shebangRegex);
|
|
357
|
+
if (!match2) {
|
|
358
|
+
return null;
|
|
359
|
+
}
|
|
360
|
+
const [path, argument] = match2[0].replace(/#! ?/, "").split(" ");
|
|
361
|
+
const binary = path.split("/").pop();
|
|
362
|
+
if (binary === "env") {
|
|
363
|
+
return argument;
|
|
364
|
+
}
|
|
365
|
+
return argument ? `${binary} ${argument}` : binary;
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
// ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.js
|
|
371
|
+
var require_readShebang = __commonJS({
|
|
372
|
+
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.js"(exports, module) {
|
|
373
|
+
var fs = __require("fs");
|
|
374
|
+
var shebangCommand = require_shebang_command();
|
|
375
|
+
function readShebang(command) {
|
|
376
|
+
const size = 150;
|
|
377
|
+
const buffer = Buffer.alloc(size);
|
|
378
|
+
let fd;
|
|
379
|
+
try {
|
|
380
|
+
fd = fs.openSync(command, "r");
|
|
381
|
+
fs.readSync(fd, buffer, 0, size, 0);
|
|
382
|
+
fs.closeSync(fd);
|
|
383
|
+
} catch (e) {
|
|
384
|
+
}
|
|
385
|
+
return shebangCommand(buffer.toString());
|
|
386
|
+
}
|
|
387
|
+
module.exports = readShebang;
|
|
388
|
+
}
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
// ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js
|
|
392
|
+
var require_parse = __commonJS({
|
|
393
|
+
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js"(exports, module) {
|
|
394
|
+
var path = __require("path");
|
|
395
|
+
var resolveCommand = require_resolveCommand();
|
|
396
|
+
var escape = require_escape();
|
|
397
|
+
var readShebang = require_readShebang();
|
|
398
|
+
var isWin = process.platform === "win32";
|
|
399
|
+
var isExecutableRegExp = /\.(?:com|exe)$/i;
|
|
400
|
+
var isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
|
|
401
|
+
function detectShebang(parsed) {
|
|
402
|
+
parsed.file = resolveCommand(parsed);
|
|
403
|
+
const shebang = parsed.file && readShebang(parsed.file);
|
|
404
|
+
if (shebang) {
|
|
405
|
+
parsed.args.unshift(parsed.file);
|
|
406
|
+
parsed.command = shebang;
|
|
407
|
+
return resolveCommand(parsed);
|
|
408
|
+
}
|
|
409
|
+
return parsed.file;
|
|
410
|
+
}
|
|
411
|
+
function parseNonShell(parsed) {
|
|
412
|
+
if (!isWin) {
|
|
413
|
+
return parsed;
|
|
414
|
+
}
|
|
415
|
+
const commandFile = detectShebang(parsed);
|
|
416
|
+
const needsShell = !isExecutableRegExp.test(commandFile);
|
|
417
|
+
if (parsed.options.forceShell || needsShell) {
|
|
418
|
+
const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
|
|
419
|
+
parsed.command = path.normalize(parsed.command);
|
|
420
|
+
parsed.command = escape.command(parsed.command);
|
|
421
|
+
parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars));
|
|
422
|
+
const shellCommand = [parsed.command].concat(parsed.args).join(" ");
|
|
423
|
+
parsed.args = ["/d", "/s", "/c", `"${shellCommand}"`];
|
|
424
|
+
parsed.command = process.env.comspec || "cmd.exe";
|
|
425
|
+
parsed.options.windowsVerbatimArguments = true;
|
|
426
|
+
}
|
|
427
|
+
return parsed;
|
|
428
|
+
}
|
|
429
|
+
function parse(command, args, options) {
|
|
430
|
+
if (args && !Array.isArray(args)) {
|
|
431
|
+
options = args;
|
|
432
|
+
args = null;
|
|
433
|
+
}
|
|
434
|
+
args = args ? args.slice(0) : [];
|
|
435
|
+
options = Object.assign({}, options);
|
|
436
|
+
const parsed = {
|
|
437
|
+
command,
|
|
438
|
+
args,
|
|
439
|
+
options,
|
|
440
|
+
file: void 0,
|
|
441
|
+
original: {
|
|
442
|
+
command,
|
|
443
|
+
args
|
|
444
|
+
}
|
|
445
|
+
};
|
|
446
|
+
return options.shell ? parsed : parseNonShell(parsed);
|
|
447
|
+
}
|
|
448
|
+
module.exports = parse;
|
|
449
|
+
}
|
|
450
|
+
});
|
|
451
|
+
|
|
452
|
+
// ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/enoent.js
|
|
453
|
+
var require_enoent = __commonJS({
|
|
454
|
+
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/enoent.js"(exports, module) {
|
|
455
|
+
var isWin = process.platform === "win32";
|
|
456
|
+
function notFoundError(original, syscall) {
|
|
457
|
+
return Object.assign(new Error(`${syscall} ${original.command} ENOENT`), {
|
|
458
|
+
code: "ENOENT",
|
|
459
|
+
errno: "ENOENT",
|
|
460
|
+
syscall: `${syscall} ${original.command}`,
|
|
461
|
+
path: original.command,
|
|
462
|
+
spawnargs: original.args
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
function hookChildProcess(cp, parsed) {
|
|
466
|
+
if (!isWin) {
|
|
467
|
+
return;
|
|
468
|
+
}
|
|
469
|
+
const originalEmit = cp.emit;
|
|
470
|
+
cp.emit = function(name, arg1) {
|
|
471
|
+
if (name === "exit") {
|
|
472
|
+
const err = verifyENOENT(arg1, parsed);
|
|
473
|
+
if (err) {
|
|
474
|
+
return originalEmit.call(cp, "error", err);
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
return originalEmit.apply(cp, arguments);
|
|
478
|
+
};
|
|
479
|
+
}
|
|
480
|
+
function verifyENOENT(status, parsed) {
|
|
481
|
+
if (isWin && status === 1 && !parsed.file) {
|
|
482
|
+
return notFoundError(parsed.original, "spawn");
|
|
483
|
+
}
|
|
484
|
+
return null;
|
|
485
|
+
}
|
|
486
|
+
function verifyENOENTSync(status, parsed) {
|
|
487
|
+
if (isWin && status === 1 && !parsed.file) {
|
|
488
|
+
return notFoundError(parsed.original, "spawnSync");
|
|
489
|
+
}
|
|
490
|
+
return null;
|
|
491
|
+
}
|
|
492
|
+
module.exports = {
|
|
493
|
+
hookChildProcess,
|
|
494
|
+
verifyENOENT,
|
|
495
|
+
verifyENOENTSync,
|
|
496
|
+
notFoundError
|
|
497
|
+
};
|
|
498
|
+
}
|
|
499
|
+
});
|
|
500
|
+
|
|
501
|
+
// ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/index.js
|
|
502
|
+
var require_cross_spawn = __commonJS({
|
|
503
|
+
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/index.js"(exports, module) {
|
|
504
|
+
var cp = __require("child_process");
|
|
505
|
+
var parse = require_parse();
|
|
506
|
+
var enoent = require_enoent();
|
|
507
|
+
function spawn2(command, args, options) {
|
|
508
|
+
const parsed = parse(command, args, options);
|
|
509
|
+
const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
|
|
510
|
+
enoent.hookChildProcess(spawned, parsed);
|
|
511
|
+
return spawned;
|
|
512
|
+
}
|
|
513
|
+
function spawnSync(command, args, options) {
|
|
514
|
+
const parsed = parse(command, args, options);
|
|
515
|
+
const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
|
|
516
|
+
result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
|
|
517
|
+
return result;
|
|
518
|
+
}
|
|
519
|
+
module.exports = spawn2;
|
|
520
|
+
module.exports.spawn = spawn2;
|
|
521
|
+
module.exports.sync = spawnSync;
|
|
522
|
+
module.exports._parse = parse;
|
|
523
|
+
module.exports._enoent = enoent;
|
|
524
|
+
}
|
|
525
|
+
});
|
|
526
|
+
|
|
527
|
+
// ../../node_modules/.pnpm/shell-exec@1.0.2/node_modules/shell-exec/index.js
|
|
528
|
+
var require_shell_exec = __commonJS({
|
|
529
|
+
"../../node_modules/.pnpm/shell-exec@1.0.2/node_modules/shell-exec/index.js"(exports, module) {
|
|
530
|
+
var childProcess = __require("child_process");
|
|
531
|
+
function shellExec(cmd = "", opts = {}) {
|
|
532
|
+
if (Array.isArray(cmd)) {
|
|
533
|
+
cmd = cmd.join(";");
|
|
534
|
+
}
|
|
535
|
+
opts = Object.assign({ stdio: "pipe", cwd: process.cwd() }, opts);
|
|
536
|
+
let child;
|
|
537
|
+
const shell = process.platform === "win32" ? { cmd: "cmd", arg: "/C" } : { cmd: "sh", arg: "-c" };
|
|
538
|
+
try {
|
|
539
|
+
child = childProcess.spawn(shell.cmd, [shell.arg, cmd], opts);
|
|
540
|
+
} catch (error) {
|
|
541
|
+
return Promise.reject(error);
|
|
542
|
+
}
|
|
543
|
+
return new Promise((resolve) => {
|
|
544
|
+
let stdout = "";
|
|
545
|
+
let stderr = "";
|
|
546
|
+
if (child.stdout) {
|
|
547
|
+
child.stdout.on("data", (data) => {
|
|
548
|
+
stdout += data;
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
if (child.stderr) {
|
|
552
|
+
child.stderr.on("data", (data) => {
|
|
553
|
+
stderr += data;
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
child.on("error", (error) => {
|
|
557
|
+
resolve({ error, stdout, stderr, cmd });
|
|
558
|
+
});
|
|
559
|
+
child.on("close", (code) => {
|
|
560
|
+
resolve({ stdout, stderr, cmd, code });
|
|
561
|
+
});
|
|
562
|
+
});
|
|
563
|
+
}
|
|
564
|
+
module.exports = shellExec;
|
|
565
|
+
}
|
|
566
|
+
});
|
|
567
|
+
|
|
568
|
+
// ../../node_modules/.pnpm/kill-port@2.0.1/node_modules/kill-port/index.js
|
|
569
|
+
var require_kill_port = __commonJS({
|
|
570
|
+
"../../node_modules/.pnpm/kill-port@2.0.1/node_modules/kill-port/index.js"(exports, module) {
|
|
571
|
+
var sh = require_shell_exec();
|
|
572
|
+
module.exports = function(port, method = "tcp") {
|
|
573
|
+
port = Number.parseInt(port);
|
|
574
|
+
if (!port) {
|
|
575
|
+
return Promise.reject(new Error("Invalid port number provided"));
|
|
576
|
+
}
|
|
577
|
+
if (process.platform === "win32") {
|
|
578
|
+
return sh("netstat -nao").then((res) => {
|
|
579
|
+
const { stdout } = res;
|
|
580
|
+
if (!stdout) return res;
|
|
581
|
+
const lines = stdout.split("\n");
|
|
582
|
+
const lineWithLocalPortRegEx = new RegExp(`^ *${method.toUpperCase()} *[^ ]*:${port}`, "gm");
|
|
583
|
+
const linesWithLocalPort = lines.filter((line) => line.match(lineWithLocalPortRegEx));
|
|
584
|
+
const pids = linesWithLocalPort.reduce((acc, line) => {
|
|
585
|
+
const match2 = line.match(/(\d*)\w*(\n|$)/gm);
|
|
586
|
+
return match2 && match2[0] && !acc.includes(match2[0]) ? acc.concat(match2[0]) : acc;
|
|
587
|
+
}, []);
|
|
588
|
+
return sh(`TaskKill /F /PID ${pids.join(" /PID ")}`);
|
|
589
|
+
});
|
|
590
|
+
}
|
|
591
|
+
return sh("lsof -i -P").then((res) => {
|
|
592
|
+
const { stdout } = res;
|
|
593
|
+
if (!stdout) return res;
|
|
594
|
+
const lines = stdout.split("\n");
|
|
595
|
+
const existProccess = lines.filter((line) => line.match(new RegExp(`:*${port}`))).length > 0;
|
|
596
|
+
if (!existProccess) return Promise.reject(new Error("No process running on port"));
|
|
597
|
+
return sh(
|
|
598
|
+
`lsof -i ${method === "udp" ? "udp" : "tcp"}:${port} | grep ${method === "udp" ? "UDP" : "LISTEN"} | awk '{print $2}' | xargs kill -9`
|
|
599
|
+
);
|
|
600
|
+
});
|
|
601
|
+
};
|
|
602
|
+
}
|
|
603
|
+
});
|
|
604
|
+
|
|
35
605
|
// ../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js
|
|
36
606
|
var require_picocolors = __commonJS({
|
|
37
607
|
"../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js"(exports, module) {
|
|
@@ -104,6 +674,9 @@ var require_picocolors = __commonJS({
|
|
|
104
674
|
}
|
|
105
675
|
});
|
|
106
676
|
|
|
677
|
+
// src/server.ts
|
|
678
|
+
var import_cross_spawn = __toESM(require_cross_spawn());
|
|
679
|
+
|
|
107
680
|
// ../../node_modules/.pnpm/hono@4.10.7/node_modules/hono/dist/compose.js
|
|
108
681
|
var compose = (middleware, onError, onNotFound) => {
|
|
109
682
|
return (context, next) => {
|
|
@@ -2352,13 +2925,16 @@ var serve = (options, listeningListener) => {
|
|
|
2352
2925
|
};
|
|
2353
2926
|
|
|
2354
2927
|
// src/server.ts
|
|
2928
|
+
var import_kill_port = __toESM(require_kill_port());
|
|
2355
2929
|
var import_picocolors = __toESM(require_picocolors());
|
|
2356
2930
|
|
|
2357
2931
|
// src/constants.ts
|
|
2358
2932
|
var DEFAULT_PORT = 5567;
|
|
2359
2933
|
|
|
2360
2934
|
// src/server.ts
|
|
2361
|
-
var VERSION = "0.0.
|
|
2935
|
+
var VERSION = "0.0.80";
|
|
2936
|
+
var cursorSessionMap = /* @__PURE__ */ new Map();
|
|
2937
|
+
var activeProcesses = /* @__PURE__ */ new Map();
|
|
2362
2938
|
var parseStreamLine = (line) => {
|
|
2363
2939
|
const trimmed = line.trim();
|
|
2364
2940
|
if (!trimmed) return null;
|
|
@@ -2374,14 +2950,15 @@ var extractTextFromMessage = (message) => {
|
|
|
2374
2950
|
};
|
|
2375
2951
|
var createServer = () => {
|
|
2376
2952
|
const app = new Hono2();
|
|
2377
|
-
app.use("
|
|
2953
|
+
app.use("*", cors());
|
|
2378
2954
|
app.post("/agent", async (context) => {
|
|
2379
2955
|
const body = await context.req.json();
|
|
2380
|
-
const { content, prompt, options } = body;
|
|
2381
|
-
const
|
|
2956
|
+
const { content, prompt, options, sessionId } = body;
|
|
2957
|
+
const cursorChatId = sessionId ? cursorSessionMap.get(sessionId) : void 0;
|
|
2958
|
+
const isFollowUp = Boolean(cursorChatId);
|
|
2959
|
+
const userPrompt = isFollowUp ? prompt : `${prompt}
|
|
2382
2960
|
|
|
2383
2961
|
${content}`;
|
|
2384
|
-
const requestSignal = context.req.raw.signal;
|
|
2385
2962
|
return streamSSE(context, async (stream2) => {
|
|
2386
2963
|
const cursorAgentArgs = [
|
|
2387
2964
|
"--print",
|
|
@@ -2397,39 +2974,34 @@ ${content}`;
|
|
|
2397
2974
|
} else {
|
|
2398
2975
|
cursorAgentArgs.push("--workspace", process.cwd());
|
|
2399
2976
|
}
|
|
2977
|
+
if (isFollowUp && cursorChatId) {
|
|
2978
|
+
cursorAgentArgs.push("--resume", cursorChatId);
|
|
2979
|
+
}
|
|
2980
|
+
let cursorProcess;
|
|
2981
|
+
let stderrBuffer = "";
|
|
2400
2982
|
try {
|
|
2401
2983
|
await stream2.writeSSE({ data: "Thinking...", event: "status" });
|
|
2402
|
-
|
|
2984
|
+
cursorProcess = (0, import_cross_spawn.default)("cursor-agent", cursorAgentArgs, {
|
|
2403
2985
|
stdio: ["pipe", "pipe", "pipe"],
|
|
2404
2986
|
env: { ...process.env }
|
|
2405
2987
|
});
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2988
|
+
if (sessionId) {
|
|
2989
|
+
activeProcesses.set(sessionId, cursorProcess);
|
|
2990
|
+
}
|
|
2991
|
+
if (cursorProcess.stderr) {
|
|
2992
|
+
cursorProcess.stderr.on("data", (chunk) => {
|
|
2993
|
+
stderrBuffer += chunk.toString();
|
|
2994
|
+
});
|
|
2995
|
+
}
|
|
2412
2996
|
let buffer = "";
|
|
2997
|
+
let capturedCursorChatId;
|
|
2413
2998
|
const processLine = async (line) => {
|
|
2414
2999
|
const event = parseStreamLine(line);
|
|
2415
3000
|
if (!event) return;
|
|
3001
|
+
if (!capturedCursorChatId && event.session_id) {
|
|
3002
|
+
capturedCursorChatId = event.session_id;
|
|
3003
|
+
}
|
|
2416
3004
|
switch (event.type) {
|
|
2417
|
-
case "system":
|
|
2418
|
-
if (event.subtype === "init") {
|
|
2419
|
-
await stream2.writeSSE({
|
|
2420
|
-
data: "Thinking...",
|
|
2421
|
-
event: "status"
|
|
2422
|
-
});
|
|
2423
|
-
}
|
|
2424
|
-
break;
|
|
2425
|
-
case "thinking":
|
|
2426
|
-
if (event.subtype === "completed") {
|
|
2427
|
-
await stream2.writeSSE({
|
|
2428
|
-
data: "Thinking\u2026",
|
|
2429
|
-
event: "status"
|
|
2430
|
-
});
|
|
2431
|
-
}
|
|
2432
|
-
break;
|
|
2433
3005
|
case "assistant": {
|
|
2434
3006
|
const textContent = extractTextFromMessage(event.message);
|
|
2435
3007
|
if (textContent) {
|
|
@@ -2457,65 +3029,80 @@ ${content}`;
|
|
|
2457
3029
|
break;
|
|
2458
3030
|
}
|
|
2459
3031
|
};
|
|
2460
|
-
cursorProcess.stdout
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
});
|
|
2469
|
-
cursorProcess.stderr.on("data", (chunk) => {
|
|
2470
|
-
console.error("[cursor-agent stderr]:", chunk.toString());
|
|
2471
|
-
});
|
|
2472
|
-
cursorProcess.stdin.write(fullPrompt);
|
|
2473
|
-
cursorProcess.stdin.end();
|
|
2474
|
-
await new Promise((resolve, reject) => {
|
|
2475
|
-
cursorProcess.on("close", (code) => {
|
|
2476
|
-
requestSignal.removeEventListener("abort", killProcess);
|
|
2477
|
-
if (code === 0 || cursorProcess.killed) {
|
|
2478
|
-
resolve();
|
|
2479
|
-
} else {
|
|
2480
|
-
reject(new Error(`cursor-agent exited with code ${code}`));
|
|
3032
|
+
if (cursorProcess.stdout) {
|
|
3033
|
+
cursorProcess.stdout.on("data", async (chunk) => {
|
|
3034
|
+
buffer += chunk.toString();
|
|
3035
|
+
let newlineIndex;
|
|
3036
|
+
while ((newlineIndex = buffer.indexOf("\n")) !== -1) {
|
|
3037
|
+
const line = buffer.slice(0, newlineIndex);
|
|
3038
|
+
buffer = buffer.slice(newlineIndex + 1);
|
|
3039
|
+
await processLine(line);
|
|
2481
3040
|
}
|
|
2482
3041
|
});
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
3042
|
+
}
|
|
3043
|
+
if (cursorProcess.stdin) {
|
|
3044
|
+
cursorProcess.stdin.write(userPrompt);
|
|
3045
|
+
cursorProcess.stdin.end();
|
|
3046
|
+
}
|
|
3047
|
+
if (cursorProcess) {
|
|
3048
|
+
const childProcess = cursorProcess;
|
|
3049
|
+
await new Promise((resolve, reject) => {
|
|
3050
|
+
childProcess.on("close", (code) => {
|
|
3051
|
+
if (sessionId) {
|
|
3052
|
+
activeProcesses.delete(sessionId);
|
|
3053
|
+
}
|
|
3054
|
+
if (code === 0 || childProcess.killed) {
|
|
3055
|
+
resolve();
|
|
3056
|
+
} else {
|
|
3057
|
+
reject(new Error(`cursor-agent exited with code ${code}`));
|
|
3058
|
+
}
|
|
3059
|
+
});
|
|
3060
|
+
childProcess.on("error", (error) => {
|
|
3061
|
+
if (sessionId) {
|
|
3062
|
+
activeProcesses.delete(sessionId);
|
|
3063
|
+
}
|
|
3064
|
+
reject(error);
|
|
3065
|
+
});
|
|
2486
3066
|
});
|
|
2487
|
-
}
|
|
3067
|
+
}
|
|
2488
3068
|
if (buffer.trim()) {
|
|
2489
3069
|
await processLine(buffer);
|
|
2490
3070
|
}
|
|
3071
|
+
if (sessionId && capturedCursorChatId) {
|
|
3072
|
+
cursorSessionMap.set(sessionId, capturedCursorChatId);
|
|
3073
|
+
}
|
|
2491
3074
|
await stream2.writeSSE({ data: "", event: "done" });
|
|
2492
3075
|
} catch (error) {
|
|
2493
3076
|
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
|
3077
|
+
const stderrContent = stderrBuffer.trim();
|
|
3078
|
+
const fullError = stderrContent ? `${errorMessage}
|
|
3079
|
+
|
|
3080
|
+
stderr:
|
|
3081
|
+
${stderrContent}` : errorMessage;
|
|
2494
3082
|
await stream2.writeSSE({
|
|
2495
|
-
data: `Error: ${
|
|
3083
|
+
data: `Error: ${fullError}`,
|
|
2496
3084
|
event: "error"
|
|
2497
3085
|
});
|
|
2498
3086
|
}
|
|
2499
3087
|
});
|
|
2500
3088
|
});
|
|
3089
|
+
app.post("/abort/:sessionId", (context) => {
|
|
3090
|
+
const { sessionId } = context.req.param();
|
|
3091
|
+
const activeProcess = activeProcesses.get(sessionId);
|
|
3092
|
+
if (activeProcess && !activeProcess.killed) {
|
|
3093
|
+
activeProcess.kill("SIGTERM");
|
|
3094
|
+
activeProcesses.delete(sessionId);
|
|
3095
|
+
}
|
|
3096
|
+
return context.json({ status: "ok" });
|
|
3097
|
+
});
|
|
2501
3098
|
app.get("/health", (context) => {
|
|
2502
3099
|
return context.json({ status: "ok", provider: "cursor" });
|
|
2503
3100
|
});
|
|
2504
3101
|
return app;
|
|
2505
3102
|
};
|
|
2506
|
-
var isPortInUse = (port) => new Promise((resolve) => {
|
|
2507
|
-
const server = net.createServer();
|
|
2508
|
-
server.once("error", () => resolve(true));
|
|
2509
|
-
server.once("listening", () => {
|
|
2510
|
-
server.close();
|
|
2511
|
-
resolve(false);
|
|
2512
|
-
});
|
|
2513
|
-
server.listen(port);
|
|
2514
|
-
});
|
|
2515
3103
|
var startServer = async (port = DEFAULT_PORT) => {
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
}
|
|
3104
|
+
await (0, import_kill_port.default)(port).catch(() => {
|
|
3105
|
+
});
|
|
2519
3106
|
const app = createServer();
|
|
2520
3107
|
serve({ fetch: app.fetch, port });
|
|
2521
3108
|
console.log(`${import_picocolors.default.magenta("\u269B")} ${import_picocolors.default.bold("React Grab")} ${import_picocolors.default.gray(VERSION)} ${import_picocolors.default.dim("(Cursor)")}`);
|