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