@linguacode/cli 1.3.0 → 1.5.0
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/README.md +6 -3
- package/bin/lingua.cjs +265 -128
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,9 +25,12 @@ lingua --version
|
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
Release pages also carry standalone Windows and Linux x64 archives. Those
|
|
28
|
-
archives embed the matching Node.js runtime
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
archives embed the matching Node.js runtime for the CLI itself, so utilities
|
|
29
|
+
and Capsule validation do not require a separate Node installation. Running or
|
|
30
|
+
replaying JavaScript and TypeScript still requires Node.js 24 on `PATH`; other
|
|
31
|
+
languages need their own command-line toolchains. Extract the archive, place
|
|
32
|
+
`lingua` or `lingua.exe` on `PATH`, and verify it against the release
|
|
33
|
+
`SHA256SUMS.txt` before use.
|
|
31
34
|
|
|
32
35
|
## Examples
|
|
33
36
|
|
package/bin/lingua.cjs
CHANGED
|
@@ -44,11 +44,23 @@ var CLI_EXIT_CODES = {
|
|
|
44
44
|
internal: 4
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
-
// src/shared/
|
|
48
|
-
var
|
|
47
|
+
// src/shared/utf8.ts
|
|
48
|
+
var encoder = new TextEncoder();
|
|
49
|
+
var decoder = new TextDecoder("utf-8", { fatal: false, ignoreBOM: true });
|
|
49
50
|
function utf8ByteLength(value) {
|
|
50
|
-
return
|
|
51
|
+
return encoder.encode(value).byteLength;
|
|
52
|
+
}
|
|
53
|
+
function truncateUtf8(value, maxBytes) {
|
|
54
|
+
if (maxBytes <= 0) return "";
|
|
55
|
+
const bytes = encoder.encode(value);
|
|
56
|
+
if (bytes.byteLength <= maxBytes) return value;
|
|
57
|
+
let end = maxBytes;
|
|
58
|
+
while (end > 0 && (bytes[end] & 192) === 128) end -= 1;
|
|
59
|
+
return decoder.decode(bytes.subarray(0, end));
|
|
51
60
|
}
|
|
61
|
+
|
|
62
|
+
// src/shared/runCapsule.ts
|
|
63
|
+
var MAX_CAPSULE_BYTES = 4194304;
|
|
52
64
|
function isRecord(value) {
|
|
53
65
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
54
66
|
}
|
|
@@ -337,6 +349,7 @@ var TOOLCHAIN_KEYS = [
|
|
|
337
349
|
"NODE_PATH",
|
|
338
350
|
"NPM_CONFIG_CACHE",
|
|
339
351
|
"NPM_CONFIG_PREFIX",
|
|
352
|
+
"PYTHON",
|
|
340
353
|
"VIRTUAL_ENV",
|
|
341
354
|
"PYTHONPATH",
|
|
342
355
|
"PYENV_VERSION",
|
|
@@ -459,8 +472,9 @@ function buildMissingRuntimeRecovery(command, runtime, platform = process.platfo
|
|
|
459
472
|
verifyExecutable: executable,
|
|
460
473
|
installGuide: CLI_RUNTIME_HELP_URL
|
|
461
474
|
};
|
|
475
|
+
const verifyExecutable = key === "python" ? executable : descriptor.verifyExecutable;
|
|
462
476
|
const installCommand = platform === "darwin" && descriptor.homebrewFormula ? `brew install ${descriptor.homebrewFormula}` : void 0;
|
|
463
|
-
const verifyCommand = `${
|
|
477
|
+
const verifyCommand = `${verifyExecutable} --version`;
|
|
464
478
|
const recovery = {
|
|
465
479
|
runtime: descriptor.name,
|
|
466
480
|
executable,
|
|
@@ -493,7 +507,9 @@ function executableName(command) {
|
|
|
493
507
|
}
|
|
494
508
|
function runtimeKey(executable, runtime) {
|
|
495
509
|
const normalizedRuntime = runtime.toLowerCase();
|
|
496
|
-
if (executable.startsWith("python") || normalizedRuntime.startsWith("python"))
|
|
510
|
+
if (executable === "py" || executable.startsWith("python") || normalizedRuntime.startsWith("python")) {
|
|
511
|
+
return "python";
|
|
512
|
+
}
|
|
497
513
|
if (executable === "go" || normalizedRuntime.startsWith("go")) return "go";
|
|
498
514
|
if (["rustc", "cargo"].includes(executable) || normalizedRuntime.startsWith("rust")) return "rust";
|
|
499
515
|
if (executable === "ruby" || normalizedRuntime.startsWith("ruby")) return "ruby";
|
|
@@ -681,7 +697,7 @@ var CappedOutput = class {
|
|
|
681
697
|
return chunk;
|
|
682
698
|
}
|
|
683
699
|
const remainingBytes = Math.max(0, payloadCap - currentBytes);
|
|
684
|
-
const prefix =
|
|
700
|
+
const prefix = truncateUtf8(chunk, remainingBytes);
|
|
685
701
|
const accepted = `${prefix}${OUTPUT_TRUNCATION_MARKER}`;
|
|
686
702
|
this.value += accepted;
|
|
687
703
|
this.truncated = true;
|
|
@@ -692,14 +708,6 @@ function forwardOutput(output, chunk, listener) {
|
|
|
692
708
|
const accepted = output.append(chunk);
|
|
693
709
|
if (accepted) listener?.(accepted);
|
|
694
710
|
}
|
|
695
|
-
function utf8Prefix(value, maxBytes) {
|
|
696
|
-
if (maxBytes <= 0) return "";
|
|
697
|
-
const bytes = Buffer.from(value, "utf8");
|
|
698
|
-
if (bytes.length <= maxBytes) return value;
|
|
699
|
-
let end = maxBytes;
|
|
700
|
-
while (end > 0 && (bytes[end] & 192) === 128) end -= 1;
|
|
701
|
-
return bytes.subarray(0, end).toString("utf8");
|
|
702
|
-
}
|
|
703
711
|
function asErrno(error) {
|
|
704
712
|
return error instanceof Error ? error : new Error(String(error));
|
|
705
713
|
}
|
|
@@ -734,9 +742,11 @@ function killProcessTree(child, signal) {
|
|
|
734
742
|
}
|
|
735
743
|
|
|
736
744
|
// src/cli/runtime/targets.ts
|
|
745
|
+
var import_node_fs = require("node:fs");
|
|
737
746
|
var import_promises2 = require("node:fs/promises");
|
|
738
747
|
var import_node_os = __toESM(require("node:os"));
|
|
739
|
-
var
|
|
748
|
+
var import_node_path3 = __toESM(require("node:path"));
|
|
749
|
+
var import_node_sea = require("node:sea");
|
|
740
750
|
|
|
741
751
|
// node_modules/acorn/dist/acorn.mjs
|
|
742
752
|
var astralIdentifierCodes = [509, 0, 227, 0, 150, 4, 294, 9, 1368, 2, 2, 1, 6, 3, 41, 2, 5, 0, 166, 1, 574, 3, 9, 9, 7, 9, 32, 4, 318, 1, 78, 5, 71, 10, 50, 3, 123, 2, 54, 14, 32, 10, 3, 1, 11, 3, 46, 10, 8, 0, 46, 9, 7, 2, 37, 13, 2, 9, 6, 1, 45, 0, 13, 2, 49, 13, 9, 3, 2, 11, 83, 11, 7, 0, 3, 0, 158, 11, 6, 9, 7, 3, 56, 1, 2, 6, 3, 1, 3, 2, 10, 0, 11, 1, 3, 6, 4, 4, 68, 8, 2, 0, 3, 0, 2, 3, 2, 4, 2, 0, 15, 1, 83, 17, 10, 9, 5, 0, 82, 19, 13, 9, 214, 6, 3, 8, 28, 1, 83, 16, 16, 9, 82, 12, 9, 9, 7, 19, 58, 14, 5, 9, 243, 14, 166, 9, 71, 5, 2, 1, 3, 3, 2, 0, 2, 1, 13, 9, 120, 6, 3, 6, 4, 0, 29, 9, 41, 6, 2, 3, 9, 0, 10, 10, 47, 15, 199, 7, 137, 9, 54, 7, 2, 7, 17, 9, 57, 21, 2, 13, 123, 5, 4, 0, 2, 1, 2, 6, 2, 0, 9, 9, 49, 4, 2, 1, 2, 4, 9, 9, 55, 9, 266, 3, 10, 1, 2, 0, 49, 6, 4, 4, 14, 10, 5350, 0, 7, 14, 11465, 27, 2343, 9, 87, 9, 39, 4, 60, 6, 26, 9, 535, 9, 470, 0, 2, 54, 8, 3, 82, 0, 12, 1, 19628, 1, 4178, 9, 519, 45, 3, 22, 543, 4, 4, 5, 9, 7, 3, 6, 31, 3, 149, 2, 1418, 49, 513, 54, 5, 49, 9, 0, 15, 0, 23, 4, 2, 14, 1361, 6, 2, 16, 3, 6, 2, 1, 2, 4, 101, 0, 161, 6, 10, 9, 357, 0, 62, 13, 499, 13, 245, 1, 2, 9, 233, 0, 3, 0, 8, 1, 6, 0, 475, 6, 110, 6, 6, 9, 4759, 9, 787719, 239];
|
|
@@ -1013,6 +1023,9 @@ var defaultOptions = {
|
|
|
1013
1023
|
// Can be either `"script"`, `"module"` or `"commonjs"`. This influences global
|
|
1014
1024
|
// strict mode and parsing of `import` and `export` declarations.
|
|
1015
1025
|
sourceType: "script",
|
|
1026
|
+
// When set to true, enable strict parsing mode even if `sourceType`
|
|
1027
|
+
// is `"script"`.
|
|
1028
|
+
strict: false,
|
|
1016
1029
|
// `onInsertedSemicolon` can be a callback that will be called when
|
|
1017
1030
|
// a semicolon is automatically inserted. It will be passed the
|
|
1018
1031
|
// position of the inserted semicolon as an offset, and if
|
|
@@ -1054,6 +1067,11 @@ var defaultOptions = {
|
|
|
1054
1067
|
// line being 1-based and column 0-based) will be attached to the
|
|
1055
1068
|
// nodes.
|
|
1056
1069
|
locations: false,
|
|
1070
|
+
// Pass an optional `{line, column}` object to use for the start of
|
|
1071
|
+
// the parse. This is mostly useful when using `parseExpressionAt`
|
|
1072
|
+
// with `locations: true`, to prevent the parser from having to
|
|
1073
|
+
// determine the line position at the start position.
|
|
1074
|
+
startLocation: null,
|
|
1057
1075
|
// A function can be passed as `onToken` option, which will
|
|
1058
1076
|
// cause Acorn to call that function with object in the same
|
|
1059
1077
|
// format as tokens returned from `tokenizer().getToken()`. Note
|
|
@@ -1190,13 +1208,18 @@ var Parser = function Parser2(options, input, startPos) {
|
|
|
1190
1208
|
this.reservedWordsStrictBind = wordsRegexp(reservedStrict + " " + reservedWords.strictBind);
|
|
1191
1209
|
this.input = String(input);
|
|
1192
1210
|
this.containsEsc = false;
|
|
1193
|
-
|
|
1194
|
-
|
|
1211
|
+
this.pos = startPos || 0;
|
|
1212
|
+
this.curLine = 1;
|
|
1213
|
+
if (options.startLocation) {
|
|
1214
|
+
this.lineStart = this.pos - options.startLocation.column;
|
|
1215
|
+
this.curLine = options.startLocation.line;
|
|
1216
|
+
} else if (startPos) {
|
|
1195
1217
|
this.lineStart = this.input.lastIndexOf("\n", startPos - 1) + 1;
|
|
1196
|
-
|
|
1218
|
+
if (this.options.locations) {
|
|
1219
|
+
this.curLine = this.input.slice(0, this.lineStart).split(lineBreak).length;
|
|
1220
|
+
}
|
|
1197
1221
|
} else {
|
|
1198
|
-
this.
|
|
1199
|
-
this.curLine = 1;
|
|
1222
|
+
this.lineStart = 0;
|
|
1200
1223
|
}
|
|
1201
1224
|
this.type = types$1.eof;
|
|
1202
1225
|
this.value = null;
|
|
@@ -1207,7 +1230,7 @@ var Parser = function Parser2(options, input, startPos) {
|
|
|
1207
1230
|
this.context = this.initialContext();
|
|
1208
1231
|
this.exprAllowed = true;
|
|
1209
1232
|
this.inModule = options.sourceType === "module";
|
|
1210
|
-
this.strict = this.inModule || this.strictDirective(this.pos);
|
|
1233
|
+
this.strict = this.inModule || options.strict === true || this.strictDirective(this.pos);
|
|
1211
1234
|
this.potentialArrowAt = -1;
|
|
1212
1235
|
this.potentialArrowInForAwait = false;
|
|
1213
1236
|
this.yieldPos = this.awaitPos = this.awaitIdentPos = 0;
|
|
@@ -1225,9 +1248,12 @@ var Parser = function Parser2(options, input, startPos) {
|
|
|
1225
1248
|
};
|
|
1226
1249
|
var prototypeAccessors = { inFunction: { configurable: true }, inGenerator: { configurable: true }, inAsync: { configurable: true }, canAwait: { configurable: true }, allowReturn: { configurable: true }, allowSuper: { configurable: true }, allowDirectSuper: { configurable: true }, treatFunctionsAsVar: { configurable: true }, allowNewDotTarget: { configurable: true }, allowUsing: { configurable: true }, inClassStaticBlock: { configurable: true } };
|
|
1227
1250
|
Parser.prototype.parse = function parse() {
|
|
1251
|
+
var this$1$1 = this;
|
|
1228
1252
|
var node = this.options.program || this.startNode();
|
|
1229
1253
|
this.nextToken();
|
|
1230
|
-
return this.
|
|
1254
|
+
return this.catchStackOverflow(function() {
|
|
1255
|
+
return this$1$1.parseTopLevel(node);
|
|
1256
|
+
});
|
|
1231
1257
|
};
|
|
1232
1258
|
prototypeAccessors.inFunction.get = function() {
|
|
1233
1259
|
return (this.currentVarScope().flags & SCOPE_FUNCTION) > 0;
|
|
@@ -1361,6 +1387,17 @@ pp$9.eatContextual = function(name) {
|
|
|
1361
1387
|
this.next();
|
|
1362
1388
|
return true;
|
|
1363
1389
|
};
|
|
1390
|
+
pp$9.catchStackOverflow = function(f) {
|
|
1391
|
+
try {
|
|
1392
|
+
return f();
|
|
1393
|
+
} catch (e) {
|
|
1394
|
+
if (e instanceof Error && (/\bstack\b.*\b(exceeded|overflow)\b/i.test(e.message) || /\btoo much recursion\b/i.test(e.message))) {
|
|
1395
|
+
this.raise(this.start, "Not enough stack space to parse input");
|
|
1396
|
+
} else {
|
|
1397
|
+
throw e;
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1400
|
+
};
|
|
1364
1401
|
pp$9.expectContextual = function(name) {
|
|
1365
1402
|
if (!this.eatContextual(name)) {
|
|
1366
1403
|
this.unexpected();
|
|
@@ -1446,12 +1483,12 @@ pp$9.isSimpleAssignTarget = function(expr) {
|
|
|
1446
1483
|
};
|
|
1447
1484
|
var pp$8 = Parser.prototype;
|
|
1448
1485
|
pp$8.parseTopLevel = function(node) {
|
|
1449
|
-
var
|
|
1486
|
+
var exports$1 = /* @__PURE__ */ Object.create(null);
|
|
1450
1487
|
if (!node.body) {
|
|
1451
1488
|
node.body = [];
|
|
1452
1489
|
}
|
|
1453
1490
|
while (this.type !== types$1.eof) {
|
|
1454
|
-
var stmt = this.parseStatement(null, true,
|
|
1491
|
+
var stmt = this.parseStatement(null, true, exports$1);
|
|
1455
1492
|
node.body.push(stmt);
|
|
1456
1493
|
}
|
|
1457
1494
|
if (this.inModule) {
|
|
@@ -1541,9 +1578,18 @@ pp$8.isUsingKeyword = function(isAwaitUsing, isFor) {
|
|
|
1541
1578
|
return true;
|
|
1542
1579
|
}
|
|
1543
1580
|
var id = this.input.slice(idStart, next);
|
|
1544
|
-
if (keywordRelationalOperator.test(id)
|
|
1581
|
+
if (keywordRelationalOperator.test(id)) {
|
|
1545
1582
|
return false;
|
|
1546
1583
|
}
|
|
1584
|
+
if (isFor && !isAwaitUsing && id === "of") {
|
|
1585
|
+
skipWhiteSpace.lastIndex = next;
|
|
1586
|
+
var skipAfterOf = skipWhiteSpace.exec(this.input);
|
|
1587
|
+
next = next + skipAfterOf[0].length;
|
|
1588
|
+
if (this.input.charCodeAt(next) !== 61 || // Check for ==, === and => operators
|
|
1589
|
+
(ch = this.input.charCodeAt(next + 1)) === 61 || ch === 62) {
|
|
1590
|
+
return false;
|
|
1591
|
+
}
|
|
1592
|
+
}
|
|
1547
1593
|
return true;
|
|
1548
1594
|
};
|
|
1549
1595
|
pp$8.isAwaitUsing = function(isFor) {
|
|
@@ -1552,7 +1598,7 @@ pp$8.isAwaitUsing = function(isFor) {
|
|
|
1552
1598
|
pp$8.isUsing = function(isFor) {
|
|
1553
1599
|
return this.isUsingKeyword(false, isFor);
|
|
1554
1600
|
};
|
|
1555
|
-
pp$8.parseStatement = function(context, topLevel,
|
|
1601
|
+
pp$8.parseStatement = function(context, topLevel, exports$1) {
|
|
1556
1602
|
var starttype = this.type, node = this.startNode(), kind;
|
|
1557
1603
|
if (this.isLet(context)) {
|
|
1558
1604
|
starttype = types$1._var;
|
|
@@ -1621,7 +1667,7 @@ pp$8.parseStatement = function(context, topLevel, exports2) {
|
|
|
1621
1667
|
this.raise(this.start, "'import' and 'export' may appear only with 'sourceType: module'");
|
|
1622
1668
|
}
|
|
1623
1669
|
}
|
|
1624
|
-
return starttype === types$1._import ? this.parseImport(node) : this.parseExport(node,
|
|
1670
|
+
return starttype === types$1._import ? this.parseImport(node) : this.parseExport(node, exports$1);
|
|
1625
1671
|
// If the statement does not start with a statement keyword or a
|
|
1626
1672
|
// brace, it's an ExpressionStatement or LabeledStatement. We
|
|
1627
1673
|
// simply start parsing an expression, and afterwards, if the
|
|
@@ -1640,6 +1686,9 @@ pp$8.parseStatement = function(context, topLevel, exports2) {
|
|
|
1640
1686
|
if (!this.allowUsing) {
|
|
1641
1687
|
this.raise(this.start, "Using declaration cannot appear in the top level when source type is `script` or in the bare case statement");
|
|
1642
1688
|
}
|
|
1689
|
+
if (context) {
|
|
1690
|
+
this.raise(this.start, "Using declaration is not allowed in single-statement positions");
|
|
1691
|
+
}
|
|
1643
1692
|
if (usingKind === "await using") {
|
|
1644
1693
|
if (!this.canAwait) {
|
|
1645
1694
|
this.raise(this.start, "Await using cannot appear outside of async function");
|
|
@@ -1774,14 +1823,15 @@ pp$8.parseForStatement = function(node) {
|
|
|
1774
1823
|
};
|
|
1775
1824
|
pp$8.parseForAfterInit = function(node, init, awaitAt) {
|
|
1776
1825
|
if ((this.type === types$1._in || this.options.ecmaVersion >= 6 && this.isContextual("of")) && init.declarations.length === 1) {
|
|
1777
|
-
if (this.
|
|
1778
|
-
if (
|
|
1779
|
-
|
|
1780
|
-
this.unexpected(awaitAt);
|
|
1781
|
-
}
|
|
1782
|
-
} else {
|
|
1783
|
-
node.await = awaitAt > -1;
|
|
1826
|
+
if (this.type === types$1._in) {
|
|
1827
|
+
if ((init.kind === "using" || init.kind === "await using") && !init.declarations[0].init) {
|
|
1828
|
+
this.raise(this.start, "Using declaration is not allowed in for-in loops");
|
|
1784
1829
|
}
|
|
1830
|
+
if (this.options.ecmaVersion >= 9 && awaitAt > -1) {
|
|
1831
|
+
this.unexpected(awaitAt);
|
|
1832
|
+
}
|
|
1833
|
+
} else if (this.options.ecmaVersion >= 9) {
|
|
1834
|
+
node.await = awaitAt > -1;
|
|
1785
1835
|
}
|
|
1786
1836
|
return this.parseForIn(node, init);
|
|
1787
1837
|
}
|
|
@@ -2299,11 +2349,11 @@ function checkKeyName(node, name) {
|
|
|
2299
2349
|
var key = node.key;
|
|
2300
2350
|
return !computed && (key.type === "Identifier" && key.name === name || key.type === "Literal" && key.value === name);
|
|
2301
2351
|
}
|
|
2302
|
-
pp$8.parseExportAllDeclaration = function(node,
|
|
2352
|
+
pp$8.parseExportAllDeclaration = function(node, exports$1) {
|
|
2303
2353
|
if (this.options.ecmaVersion >= 11) {
|
|
2304
2354
|
if (this.eatContextual("as")) {
|
|
2305
2355
|
node.exported = this.parseModuleExportName();
|
|
2306
|
-
this.checkExport(
|
|
2356
|
+
this.checkExport(exports$1, node.exported, this.lastTokStart);
|
|
2307
2357
|
} else {
|
|
2308
2358
|
node.exported = null;
|
|
2309
2359
|
}
|
|
@@ -2319,22 +2369,22 @@ pp$8.parseExportAllDeclaration = function(node, exports2) {
|
|
|
2319
2369
|
this.semicolon();
|
|
2320
2370
|
return this.finishNode(node, "ExportAllDeclaration");
|
|
2321
2371
|
};
|
|
2322
|
-
pp$8.parseExport = function(node,
|
|
2372
|
+
pp$8.parseExport = function(node, exports$1) {
|
|
2323
2373
|
this.next();
|
|
2324
2374
|
if (this.eat(types$1.star)) {
|
|
2325
|
-
return this.parseExportAllDeclaration(node,
|
|
2375
|
+
return this.parseExportAllDeclaration(node, exports$1);
|
|
2326
2376
|
}
|
|
2327
2377
|
if (this.eat(types$1._default)) {
|
|
2328
|
-
this.checkExport(
|
|
2378
|
+
this.checkExport(exports$1, "default", this.lastTokStart);
|
|
2329
2379
|
node.declaration = this.parseExportDefaultDeclaration();
|
|
2330
2380
|
return this.finishNode(node, "ExportDefaultDeclaration");
|
|
2331
2381
|
}
|
|
2332
2382
|
if (this.shouldParseExportStatement()) {
|
|
2333
2383
|
node.declaration = this.parseExportDeclaration(node);
|
|
2334
2384
|
if (node.declaration.type === "VariableDeclaration") {
|
|
2335
|
-
this.checkVariableExport(
|
|
2385
|
+
this.checkVariableExport(exports$1, node.declaration.declarations);
|
|
2336
2386
|
} else {
|
|
2337
|
-
this.checkExport(
|
|
2387
|
+
this.checkExport(exports$1, node.declaration.id, node.declaration.id.start);
|
|
2338
2388
|
}
|
|
2339
2389
|
node.specifiers = [];
|
|
2340
2390
|
node.source = null;
|
|
@@ -2343,7 +2393,7 @@ pp$8.parseExport = function(node, exports2) {
|
|
|
2343
2393
|
}
|
|
2344
2394
|
} else {
|
|
2345
2395
|
node.declaration = null;
|
|
2346
|
-
node.specifiers = this.parseExportSpecifiers(
|
|
2396
|
+
node.specifiers = this.parseExportSpecifiers(exports$1);
|
|
2347
2397
|
if (this.eatContextual("from")) {
|
|
2348
2398
|
if (this.type !== types$1.string) {
|
|
2349
2399
|
this.unexpected();
|
|
@@ -2391,66 +2441,66 @@ pp$8.parseExportDefaultDeclaration = function() {
|
|
|
2391
2441
|
return declaration;
|
|
2392
2442
|
}
|
|
2393
2443
|
};
|
|
2394
|
-
pp$8.checkExport = function(
|
|
2395
|
-
if (!
|
|
2444
|
+
pp$8.checkExport = function(exports$1, name, pos) {
|
|
2445
|
+
if (!exports$1) {
|
|
2396
2446
|
return;
|
|
2397
2447
|
}
|
|
2398
2448
|
if (typeof name !== "string") {
|
|
2399
2449
|
name = name.type === "Identifier" ? name.name : name.value;
|
|
2400
2450
|
}
|
|
2401
|
-
if (hasOwn(
|
|
2451
|
+
if (hasOwn(exports$1, name)) {
|
|
2402
2452
|
this.raiseRecoverable(pos, "Duplicate export '" + name + "'");
|
|
2403
2453
|
}
|
|
2404
|
-
|
|
2454
|
+
exports$1[name] = true;
|
|
2405
2455
|
};
|
|
2406
|
-
pp$8.checkPatternExport = function(
|
|
2456
|
+
pp$8.checkPatternExport = function(exports$1, pat) {
|
|
2407
2457
|
var type = pat.type;
|
|
2408
2458
|
if (type === "Identifier") {
|
|
2409
|
-
this.checkExport(
|
|
2459
|
+
this.checkExport(exports$1, pat, pat.start);
|
|
2410
2460
|
} else if (type === "ObjectPattern") {
|
|
2411
2461
|
for (var i2 = 0, list2 = pat.properties; i2 < list2.length; i2 += 1) {
|
|
2412
2462
|
var prop = list2[i2];
|
|
2413
|
-
this.checkPatternExport(
|
|
2463
|
+
this.checkPatternExport(exports$1, prop);
|
|
2414
2464
|
}
|
|
2415
2465
|
} else if (type === "ArrayPattern") {
|
|
2416
2466
|
for (var i$1 = 0, list$1 = pat.elements; i$1 < list$1.length; i$1 += 1) {
|
|
2417
2467
|
var elt = list$1[i$1];
|
|
2418
2468
|
if (elt) {
|
|
2419
|
-
this.checkPatternExport(
|
|
2469
|
+
this.checkPatternExport(exports$1, elt);
|
|
2420
2470
|
}
|
|
2421
2471
|
}
|
|
2422
2472
|
} else if (type === "Property") {
|
|
2423
|
-
this.checkPatternExport(
|
|
2473
|
+
this.checkPatternExport(exports$1, pat.value);
|
|
2424
2474
|
} else if (type === "AssignmentPattern") {
|
|
2425
|
-
this.checkPatternExport(
|
|
2475
|
+
this.checkPatternExport(exports$1, pat.left);
|
|
2426
2476
|
} else if (type === "RestElement") {
|
|
2427
|
-
this.checkPatternExport(
|
|
2477
|
+
this.checkPatternExport(exports$1, pat.argument);
|
|
2428
2478
|
}
|
|
2429
2479
|
};
|
|
2430
|
-
pp$8.checkVariableExport = function(
|
|
2431
|
-
if (!
|
|
2480
|
+
pp$8.checkVariableExport = function(exports$1, decls) {
|
|
2481
|
+
if (!exports$1) {
|
|
2432
2482
|
return;
|
|
2433
2483
|
}
|
|
2434
2484
|
for (var i2 = 0, list2 = decls; i2 < list2.length; i2 += 1) {
|
|
2435
2485
|
var decl = list2[i2];
|
|
2436
|
-
this.checkPatternExport(
|
|
2486
|
+
this.checkPatternExport(exports$1, decl.id);
|
|
2437
2487
|
}
|
|
2438
2488
|
};
|
|
2439
2489
|
pp$8.shouldParseExportStatement = function() {
|
|
2440
2490
|
return this.type.keyword === "var" || this.type.keyword === "const" || this.type.keyword === "class" || this.type.keyword === "function" || this.isLet() || this.isAsyncFunction();
|
|
2441
2491
|
};
|
|
2442
|
-
pp$8.parseExportSpecifier = function(
|
|
2492
|
+
pp$8.parseExportSpecifier = function(exports$1) {
|
|
2443
2493
|
var node = this.startNode();
|
|
2444
2494
|
node.local = this.parseModuleExportName();
|
|
2445
2495
|
node.exported = this.eatContextual("as") ? this.parseModuleExportName() : node.local;
|
|
2446
2496
|
this.checkExport(
|
|
2447
|
-
|
|
2497
|
+
exports$1,
|
|
2448
2498
|
node.exported,
|
|
2449
2499
|
node.exported.start
|
|
2450
2500
|
);
|
|
2451
2501
|
return this.finishNode(node, "ExportSpecifier");
|
|
2452
2502
|
};
|
|
2453
|
-
pp$8.parseExportSpecifiers = function(
|
|
2503
|
+
pp$8.parseExportSpecifiers = function(exports$1) {
|
|
2454
2504
|
var nodes = [], first = true;
|
|
2455
2505
|
this.expect(types$1.braceL);
|
|
2456
2506
|
while (!this.eat(types$1.braceR)) {
|
|
@@ -2462,7 +2512,7 @@ pp$8.parseExportSpecifiers = function(exports2) {
|
|
|
2462
2512
|
} else {
|
|
2463
2513
|
first = false;
|
|
2464
2514
|
}
|
|
2465
|
-
nodes.push(this.parseExportSpecifier(
|
|
2515
|
+
nodes.push(this.parseExportSpecifier(exports$1));
|
|
2466
2516
|
}
|
|
2467
2517
|
return nodes;
|
|
2468
2518
|
};
|
|
@@ -3030,17 +3080,20 @@ pp$5.checkPropClash = function(prop, propHash, refDestructuringErrors) {
|
|
|
3030
3080
|
other[kind] = true;
|
|
3031
3081
|
};
|
|
3032
3082
|
pp$5.parseExpression = function(forInit, refDestructuringErrors) {
|
|
3033
|
-
var
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
var
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
node.expressions
|
|
3083
|
+
var this$1$1 = this;
|
|
3084
|
+
return this.catchStackOverflow(function() {
|
|
3085
|
+
var startPos = this$1$1.start, startLoc = this$1$1.startLoc;
|
|
3086
|
+
var expr = this$1$1.parseMaybeAssign(forInit, refDestructuringErrors);
|
|
3087
|
+
if (this$1$1.type === types$1.comma) {
|
|
3088
|
+
var node = this$1$1.startNodeAt(startPos, startLoc);
|
|
3089
|
+
node.expressions = [expr];
|
|
3090
|
+
while (this$1$1.eat(types$1.comma)) {
|
|
3091
|
+
node.expressions.push(this$1$1.parseMaybeAssign(forInit, refDestructuringErrors));
|
|
3092
|
+
}
|
|
3093
|
+
return this$1$1.finishNode(node, "SequenceExpression");
|
|
3040
3094
|
}
|
|
3041
|
-
return
|
|
3042
|
-
}
|
|
3043
|
-
return expr;
|
|
3095
|
+
return expr;
|
|
3096
|
+
});
|
|
3044
3097
|
};
|
|
3045
3098
|
pp$5.parseMaybeAssign = function(forInit, refDestructuringErrors, afterLeftParse) {
|
|
3046
3099
|
if (this.isContextual("yield")) {
|
|
@@ -3112,7 +3165,7 @@ pp$5.parseMaybeConditional = function(forInit, refDestructuringErrors) {
|
|
|
3112
3165
|
if (this.checkExpressionErrors(refDestructuringErrors)) {
|
|
3113
3166
|
return expr;
|
|
3114
3167
|
}
|
|
3115
|
-
if (this.eat(types$1.question)) {
|
|
3168
|
+
if (!(expr.type === "ArrowFunctionExpression" && expr.start === startPos) && this.eat(types$1.question)) {
|
|
3116
3169
|
var node = this.startNodeAt(startPos, startLoc);
|
|
3117
3170
|
node.test = expr;
|
|
3118
3171
|
node.consequent = this.parseMaybeAssign();
|
|
@@ -3207,7 +3260,7 @@ pp$5.parseMaybeUnary = function(refDestructuringErrors, sawUnary, incDec, forIni
|
|
|
3207
3260
|
expr = this.finishNode(node$1, "UpdateExpression");
|
|
3208
3261
|
}
|
|
3209
3262
|
}
|
|
3210
|
-
if (!incDec && this.eat(types$1.starstar)) {
|
|
3263
|
+
if (!incDec && !(expr.type === "ArrowFunctionExpression" && expr.start === startPos) && this.eat(types$1.starstar)) {
|
|
3211
3264
|
if (sawUnary) {
|
|
3212
3265
|
this.unexpected(this.lastTokStart);
|
|
3213
3266
|
} else {
|
|
@@ -3611,6 +3664,9 @@ pp$5.parseNew = function() {
|
|
|
3611
3664
|
}
|
|
3612
3665
|
var startPos = this.start, startLoc = this.startLoc;
|
|
3613
3666
|
node.callee = this.parseSubscripts(this.parseExprAtom(null, false, true), startPos, startLoc, true, false);
|
|
3667
|
+
if (node.callee.type === "Super") {
|
|
3668
|
+
this.raiseRecoverable(startPos, "Invalid use of 'super'");
|
|
3669
|
+
}
|
|
3614
3670
|
if (this.eat(types$1.parenL)) {
|
|
3615
3671
|
node.arguments = this.parseExprList(types$1.parenR, this.options.ecmaVersion >= 8, false);
|
|
3616
3672
|
} else {
|
|
@@ -6363,7 +6419,7 @@ pp.readWord = function() {
|
|
|
6363
6419
|
}
|
|
6364
6420
|
return this.finishToken(type, word);
|
|
6365
6421
|
};
|
|
6366
|
-
var version = "8.
|
|
6422
|
+
var version = "8.18.0";
|
|
6367
6423
|
Parser.acorn = {
|
|
6368
6424
|
Parser,
|
|
6369
6425
|
version,
|
|
@@ -6433,6 +6489,48 @@ function sourceRequiresModuleInput(source) {
|
|
|
6433
6489
|
}
|
|
6434
6490
|
}
|
|
6435
6491
|
|
|
6492
|
+
// src/shared/python/interpreter.ts
|
|
6493
|
+
var import_node_path2 = __toESM(require("node:path"));
|
|
6494
|
+
function pythonCommandCandidates(platform) {
|
|
6495
|
+
return platform === "win32" ? ["python", "py", "python3"] : ["python3", "python"];
|
|
6496
|
+
}
|
|
6497
|
+
function pythonVenvRelativePaths(platform) {
|
|
6498
|
+
const pathApi = platform === "win32" ? import_node_path2.default.win32 : import_node_path2.default.posix;
|
|
6499
|
+
return platform === "win32" ? [
|
|
6500
|
+
pathApi.join(".venv", "Scripts", "python.exe"),
|
|
6501
|
+
pathApi.join("venv", "Scripts", "python.exe")
|
|
6502
|
+
] : [pathApi.join(".venv", "bin", "python"), pathApi.join("venv", "bin", "python")];
|
|
6503
|
+
}
|
|
6504
|
+
function pythonInterpreterCandidates(options) {
|
|
6505
|
+
const { startDirectory, platform, env, walkUp = false, respectPythonEnv = false } = options;
|
|
6506
|
+
const pathApi = platform === "win32" ? import_node_path2.default.win32 : import_node_path2.default.posix;
|
|
6507
|
+
const relatives = pythonVenvRelativePaths(platform);
|
|
6508
|
+
const candidates = [];
|
|
6509
|
+
let current2 = startDirectory;
|
|
6510
|
+
for (; ; ) {
|
|
6511
|
+
for (const relative of relatives) {
|
|
6512
|
+
candidates.push({ command: pathApi.join(current2, relative), source: "venv" });
|
|
6513
|
+
}
|
|
6514
|
+
if (!walkUp) break;
|
|
6515
|
+
const parent = pathApi.dirname(current2);
|
|
6516
|
+
if (parent === current2) break;
|
|
6517
|
+
current2 = parent;
|
|
6518
|
+
}
|
|
6519
|
+
const pythonEnv = respectPythonEnv ? env?.PYTHON : void 0;
|
|
6520
|
+
if (pythonEnv) candidates.push({ command: pythonEnv, source: "python-env" });
|
|
6521
|
+
for (const name of pythonCommandCandidates(platform)) {
|
|
6522
|
+
candidates.push({ command: name, source: "path" });
|
|
6523
|
+
}
|
|
6524
|
+
return candidates;
|
|
6525
|
+
}
|
|
6526
|
+
async function resolvePythonInterpreter(options, probe) {
|
|
6527
|
+
for (const candidate of pythonInterpreterCandidates(options)) {
|
|
6528
|
+
const resolved = await probe(candidate);
|
|
6529
|
+
if (resolved !== null) return resolved;
|
|
6530
|
+
}
|
|
6531
|
+
return null;
|
|
6532
|
+
}
|
|
6533
|
+
|
|
6436
6534
|
// src/cli/runtime/targets.ts
|
|
6437
6535
|
var ExecutionTargetError = class extends Error {
|
|
6438
6536
|
constructor(reason, message) {
|
|
@@ -6442,8 +6540,8 @@ var ExecutionTargetError = class extends Error {
|
|
|
6442
6540
|
}
|
|
6443
6541
|
reason;
|
|
6444
6542
|
};
|
|
6445
|
-
async function resolveExecutionTarget(target, programArgs) {
|
|
6446
|
-
const absolute =
|
|
6543
|
+
async function resolveExecutionTarget(target, programArgs, env = process.env) {
|
|
6544
|
+
const absolute = import_node_path3.default.resolve(target);
|
|
6447
6545
|
let targetStat;
|
|
6448
6546
|
try {
|
|
6449
6547
|
targetStat = await (0, import_promises2.stat)(absolute);
|
|
@@ -6455,17 +6553,17 @@ async function resolveExecutionTarget(target, programArgs) {
|
|
|
6455
6553
|
);
|
|
6456
6554
|
}
|
|
6457
6555
|
if (targetStat.isFile()) {
|
|
6458
|
-
return planFile(absolute, target, programArgs);
|
|
6556
|
+
return planFile(absolute, target, programArgs, env);
|
|
6459
6557
|
}
|
|
6460
6558
|
if (targetStat.isDirectory()) {
|
|
6461
|
-
return planProject(absolute, target, programArgs);
|
|
6559
|
+
return planProject(absolute, target, programArgs, env);
|
|
6462
6560
|
}
|
|
6463
6561
|
throw new ExecutionTargetError(
|
|
6464
6562
|
"unsupported-file-type",
|
|
6465
6563
|
`Target must be a regular file or directory: ${target}`
|
|
6466
6564
|
);
|
|
6467
6565
|
}
|
|
6468
|
-
async function resolveCapsuleSource(input, programArgs) {
|
|
6566
|
+
async function resolveCapsuleSource(input, programArgs, env = process.env) {
|
|
6469
6567
|
if (input.runtimeMode === "browser-preview") {
|
|
6470
6568
|
throw new ExecutionTargetError(
|
|
6471
6569
|
"unsupported-runtime-mode",
|
|
@@ -6482,7 +6580,7 @@ async function resolveCapsuleSource(input, programArgs) {
|
|
|
6482
6580
|
return planJavaScriptCapsule(displayTarget, cwd, input, programArgs, true);
|
|
6483
6581
|
}
|
|
6484
6582
|
case "python":
|
|
6485
|
-
return singleStep(displayTarget, "python", cwd, await findPython(cwd), [
|
|
6583
|
+
return singleStep(displayTarget, "python", cwd, await findPython(cwd, env), [
|
|
6486
6584
|
"-c",
|
|
6487
6585
|
input.source,
|
|
6488
6586
|
...programArgs
|
|
@@ -6510,8 +6608,8 @@ async function resolveCapsuleSource(input, programArgs) {
|
|
|
6510
6608
|
);
|
|
6511
6609
|
}
|
|
6512
6610
|
}
|
|
6513
|
-
async function planProject(root, displayTarget, programArgs) {
|
|
6514
|
-
const packageJson =
|
|
6611
|
+
async function planProject(root, displayTarget, programArgs, env) {
|
|
6612
|
+
const packageJson = import_node_path3.default.join(root, "package.json");
|
|
6515
6613
|
if (await exists(packageJson)) {
|
|
6516
6614
|
let manifest;
|
|
6517
6615
|
try {
|
|
@@ -6533,18 +6631,18 @@ async function planProject(root, displayTarget, programArgs) {
|
|
|
6533
6631
|
]);
|
|
6534
6632
|
}
|
|
6535
6633
|
if (isRecord2(manifest) && typeof manifest.main === "string") {
|
|
6536
|
-
const mainPath =
|
|
6537
|
-
if (await isFile(mainPath)) return planFile(mainPath, displayTarget, programArgs);
|
|
6634
|
+
const mainPath = import_node_path3.default.resolve(root, manifest.main);
|
|
6635
|
+
if (await isFile(mainPath)) return planFile(mainPath, displayTarget, programArgs, env);
|
|
6538
6636
|
}
|
|
6539
6637
|
}
|
|
6540
|
-
if (await exists(
|
|
6638
|
+
if (await exists(import_node_path3.default.join(root, "go.mod"))) {
|
|
6541
6639
|
return singleStep(displayTarget, "go-project", root, commandName("go"), [
|
|
6542
6640
|
"run",
|
|
6543
6641
|
".",
|
|
6544
6642
|
...programArgs
|
|
6545
6643
|
]);
|
|
6546
6644
|
}
|
|
6547
|
-
if (await exists(
|
|
6645
|
+
if (await exists(import_node_path3.default.join(root, "Cargo.toml"))) {
|
|
6548
6646
|
return singleStep(displayTarget, "cargo", root, commandName("cargo"), [
|
|
6549
6647
|
"run",
|
|
6550
6648
|
"--quiet",
|
|
@@ -6553,8 +6651,8 @@ async function planProject(root, displayTarget, programArgs) {
|
|
|
6553
6651
|
]);
|
|
6554
6652
|
}
|
|
6555
6653
|
for (const candidate of PROJECT_ENTRY_CANDIDATES) {
|
|
6556
|
-
const entry =
|
|
6557
|
-
if (await isFile(entry)) return planFile(entry, displayTarget, programArgs);
|
|
6654
|
+
const entry = import_node_path3.default.join(root, candidate);
|
|
6655
|
+
if (await isFile(entry)) return planFile(entry, displayTarget, programArgs, env);
|
|
6558
6656
|
}
|
|
6559
6657
|
throw new ExecutionTargetError(
|
|
6560
6658
|
"no-project-entry",
|
|
@@ -6579,24 +6677,27 @@ var PROJECT_ENTRY_CANDIDATES = [
|
|
|
6579
6677
|
"index.ts",
|
|
6580
6678
|
"src/index.ts"
|
|
6581
6679
|
];
|
|
6582
|
-
async function planFile(absolute, displayTarget, programArgs) {
|
|
6583
|
-
const cwd =
|
|
6584
|
-
const extension =
|
|
6680
|
+
async function planFile(absolute, displayTarget, programArgs, env) {
|
|
6681
|
+
const cwd = import_node_path3.default.dirname(absolute);
|
|
6682
|
+
const extension = import_node_path3.default.extname(absolute).toLowerCase();
|
|
6585
6683
|
switch (extension) {
|
|
6586
6684
|
case ".js":
|
|
6587
6685
|
case ".mjs":
|
|
6588
6686
|
case ".cjs":
|
|
6589
|
-
return singleStep(displayTarget, "node", cwd,
|
|
6687
|
+
return singleStep(displayTarget, "node", cwd, nodeRuntimeExecutable(), [
|
|
6688
|
+
absolute,
|
|
6689
|
+
...programArgs
|
|
6690
|
+
]);
|
|
6590
6691
|
case ".ts":
|
|
6591
6692
|
case ".mts":
|
|
6592
6693
|
case ".cts":
|
|
6593
|
-
return singleStep(displayTarget, "node-typescript", cwd,
|
|
6694
|
+
return singleStep(displayTarget, "node-typescript", cwd, nodeRuntimeExecutable(), [
|
|
6594
6695
|
"--experimental-strip-types",
|
|
6595
6696
|
absolute,
|
|
6596
6697
|
...programArgs
|
|
6597
6698
|
]);
|
|
6598
6699
|
case ".py":
|
|
6599
|
-
return singleStep(displayTarget, "python", cwd, await findPython(cwd), [
|
|
6700
|
+
return singleStep(displayTarget, "python", cwd, await findPython(cwd, env), [
|
|
6600
6701
|
absolute,
|
|
6601
6702
|
...programArgs
|
|
6602
6703
|
]);
|
|
@@ -6614,8 +6715,8 @@ async function planFile(absolute, displayTarget, programArgs) {
|
|
|
6614
6715
|
case ".lua":
|
|
6615
6716
|
return singleStep(displayTarget, "lua", cwd, commandName("lua"), [absolute, ...programArgs]);
|
|
6616
6717
|
case ".rs": {
|
|
6617
|
-
const temporaryRoot = await (0, import_promises2.mkdtemp)(
|
|
6618
|
-
const binary =
|
|
6718
|
+
const temporaryRoot = await (0, import_promises2.mkdtemp)(import_node_path3.default.join(import_node_os.default.tmpdir(), "lingua-cli-rust-"));
|
|
6719
|
+
const binary = import_node_path3.default.join(
|
|
6619
6720
|
temporaryRoot,
|
|
6620
6721
|
process.platform === "win32" ? "program.exe" : "program"
|
|
6621
6722
|
);
|
|
@@ -6642,8 +6743,8 @@ async function planFile(absolute, displayTarget, programArgs) {
|
|
|
6642
6743
|
}
|
|
6643
6744
|
}
|
|
6644
6745
|
async function stageCompiledSource(displayTarget, language, filename, source, programArgs) {
|
|
6645
|
-
const temporaryRoot = await (0, import_promises2.mkdtemp)(
|
|
6646
|
-
const sourcePath =
|
|
6746
|
+
const temporaryRoot = await (0, import_promises2.mkdtemp)(import_node_path3.default.join(import_node_os.default.tmpdir(), `lingua-cli-${language}-`));
|
|
6747
|
+
const sourcePath = import_node_path3.default.join(temporaryRoot, filename);
|
|
6647
6748
|
await (0, import_promises2.writeFile)(sourcePath, source, "utf8");
|
|
6648
6749
|
if (language === "go") {
|
|
6649
6750
|
return {
|
|
@@ -6660,7 +6761,7 @@ async function stageCompiledSource(displayTarget, language, filename, source, pr
|
|
|
6660
6761
|
]
|
|
6661
6762
|
};
|
|
6662
6763
|
}
|
|
6663
|
-
const binary =
|
|
6764
|
+
const binary = import_node_path3.default.join(temporaryRoot, process.platform === "win32" ? "program.exe" : "program");
|
|
6664
6765
|
return {
|
|
6665
6766
|
displayTarget,
|
|
6666
6767
|
runtime: "rust",
|
|
@@ -6694,7 +6795,7 @@ function planJavaScriptCapsule(displayTarget, cwd, input, programArgs, typescrip
|
|
|
6694
6795
|
displayTarget,
|
|
6695
6796
|
typescript ? "node-typescript-worker" : "node-worker",
|
|
6696
6797
|
cwd,
|
|
6697
|
-
|
|
6798
|
+
nodeRuntimeExecutable(),
|
|
6698
6799
|
[
|
|
6699
6800
|
...typescript ? ["--experimental-strip-types"] : [],
|
|
6700
6801
|
"--input-type=commonjs",
|
|
@@ -6709,7 +6810,7 @@ function planJavaScriptCapsule(displayTarget, cwd, input, programArgs, typescrip
|
|
|
6709
6810
|
displayTarget,
|
|
6710
6811
|
typescript ? "node-typescript" : "node",
|
|
6711
6812
|
cwd,
|
|
6712
|
-
|
|
6813
|
+
nodeRuntimeExecutable(),
|
|
6713
6814
|
[
|
|
6714
6815
|
...typescript ? ["--experimental-strip-types"] : [],
|
|
6715
6816
|
`--input-type=${sourceRequiresModuleInput(input.source) ? "module" : "commonjs"}`,
|
|
@@ -6724,16 +6825,41 @@ function planJavaScriptCapsule(displayTarget, cwd, input, programArgs, typescrip
|
|
|
6724
6825
|
`Capsule runtime mode ${JSON.stringify(input.runtimeMode)} is not replayable by the CLI for ${typescript ? "TypeScript" : "JavaScript"}; supported modes are worker and node.`
|
|
6725
6826
|
);
|
|
6726
6827
|
}
|
|
6727
|
-
|
|
6728
|
-
|
|
6729
|
-
|
|
6730
|
-
|
|
6731
|
-
|
|
6732
|
-
|
|
6733
|
-
|
|
6734
|
-
|
|
6828
|
+
function nodeRuntimeExecutable(options) {
|
|
6829
|
+
const sea = options?.sea ?? (0, import_node_sea.isSea)();
|
|
6830
|
+
return sea ? commandName("node") : options?.execPath ?? process.execPath;
|
|
6831
|
+
}
|
|
6832
|
+
async function findPython(startDirectory, env = process.env, platform = process.platform) {
|
|
6833
|
+
const resolved = await resolvePythonInterpreter(
|
|
6834
|
+
{ startDirectory, platform, env, walkUp: true, respectPythonEnv: true },
|
|
6835
|
+
async (candidate) => {
|
|
6836
|
+
if (candidate.source === "path") {
|
|
6837
|
+
return await executableIsOnPath(candidate.command, platform, env) ? commandName(candidate.command) : null;
|
|
6838
|
+
}
|
|
6839
|
+
if (candidate.source === "python-env") return candidate.command;
|
|
6840
|
+
return await isFile(candidate.command) ? candidate.command : null;
|
|
6841
|
+
}
|
|
6842
|
+
);
|
|
6843
|
+
return resolved ?? commandName(pythonCommandCandidates(platform)[0]);
|
|
6844
|
+
}
|
|
6845
|
+
async function executableIsOnPath(executable, platform = process.platform, env = process.env) {
|
|
6846
|
+
const pathValue = env.PATH ?? env.Path ?? env.path;
|
|
6847
|
+
if (!pathValue) return false;
|
|
6848
|
+
const windows = platform === "win32";
|
|
6849
|
+
const pathApi = windows ? import_node_path3.default.win32 : import_node_path3.default.posix;
|
|
6850
|
+
const delimiter = windows ? ";" : ":";
|
|
6851
|
+
const extensions = windows ? (env.PATHEXT ?? ".COM;.EXE;.BAT;.CMD").split(";").filter(Boolean).map((extension) => extension.toLowerCase()) : [""];
|
|
6852
|
+
const hasExtension = pathApi.extname(executable).length > 0;
|
|
6853
|
+
for (const rawEntry of pathValue.split(delimiter)) {
|
|
6854
|
+
const entry = rawEntry.trim().replace(/^"|"$/gu, "");
|
|
6855
|
+
if (!entry) continue;
|
|
6856
|
+
const base = pathApi.join(entry, executable);
|
|
6857
|
+
const candidates = windows && !hasExtension ? extensions.map((extension) => base + extension) : [base];
|
|
6858
|
+
for (const candidate of candidates) {
|
|
6859
|
+
if (await isExecutableFile(candidate, platform)) return true;
|
|
6860
|
+
}
|
|
6735
6861
|
}
|
|
6736
|
-
return
|
|
6862
|
+
return false;
|
|
6737
6863
|
}
|
|
6738
6864
|
function commandName(name) {
|
|
6739
6865
|
return process.platform === "win32" && ["npm", "npx"].includes(name) ? `${name}.cmd` : name;
|
|
@@ -6753,6 +6879,16 @@ async function isFile(filePath) {
|
|
|
6753
6879
|
return false;
|
|
6754
6880
|
}
|
|
6755
6881
|
}
|
|
6882
|
+
async function isExecutableFile(filePath, platform = process.platform) {
|
|
6883
|
+
if (!await isFile(filePath)) return false;
|
|
6884
|
+
if (platform === "win32") return true;
|
|
6885
|
+
try {
|
|
6886
|
+
await (0, import_promises2.access)(filePath, import_node_fs.constants.X_OK);
|
|
6887
|
+
return true;
|
|
6888
|
+
} catch {
|
|
6889
|
+
return false;
|
|
6890
|
+
}
|
|
6891
|
+
}
|
|
6756
6892
|
function isRecord2(value) {
|
|
6757
6893
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6758
6894
|
}
|
|
@@ -6800,7 +6936,7 @@ async function runTargetCommand(args, io) {
|
|
|
6800
6936
|
}
|
|
6801
6937
|
let plan;
|
|
6802
6938
|
try {
|
|
6803
|
-
plan = await resolveExecutionTarget(args.target, args.programArgs);
|
|
6939
|
+
plan = await resolveExecutionTarget(args.target, args.programArgs, env);
|
|
6804
6940
|
} catch (error) {
|
|
6805
6941
|
if (error instanceof ExecutionTargetError) {
|
|
6806
6942
|
const unsupported = [
|
|
@@ -6937,7 +7073,8 @@ async function runReplayCapsuleCommand(args, io) {
|
|
|
6937
7073
|
source: capsule.source.content,
|
|
6938
7074
|
capsuleId: capsule.capsuleId
|
|
6939
7075
|
},
|
|
6940
|
-
capsule.input.args ?? []
|
|
7076
|
+
capsule.input.args ?? [],
|
|
7077
|
+
env
|
|
6941
7078
|
);
|
|
6942
7079
|
} catch (error) {
|
|
6943
7080
|
if (error instanceof ExecutionTargetError) {
|
|
@@ -7036,10 +7173,10 @@ function errorMessage3(error) {
|
|
|
7036
7173
|
}
|
|
7037
7174
|
|
|
7038
7175
|
// src/cli/commands/completionInstall.ts
|
|
7039
|
-
var
|
|
7176
|
+
var import_node_fs2 = require("node:fs");
|
|
7040
7177
|
var import_promises3 = require("node:fs/promises");
|
|
7041
7178
|
var import_node_os2 = __toESM(require("node:os"));
|
|
7042
|
-
var
|
|
7179
|
+
var import_node_path4 = __toESM(require("node:path"));
|
|
7043
7180
|
|
|
7044
7181
|
// src/cli/commandModel.ts
|
|
7045
7182
|
var CLI_COLOR_MODES = ["auto", "always", "never"];
|
|
@@ -7428,7 +7565,7 @@ var defaultDependencies = {
|
|
|
7428
7565
|
homedir: import_node_os2.default.homedir,
|
|
7429
7566
|
async isExecutable(filePath) {
|
|
7430
7567
|
try {
|
|
7431
|
-
await (0, import_promises3.access)(filePath,
|
|
7568
|
+
await (0, import_promises3.access)(filePath, import_node_fs2.constants.X_OK);
|
|
7432
7569
|
return true;
|
|
7433
7570
|
} catch {
|
|
7434
7571
|
return false;
|
|
@@ -7454,29 +7591,29 @@ var defaultDependencies = {
|
|
|
7454
7591
|
};
|
|
7455
7592
|
function shellFromExecutable(executablePath) {
|
|
7456
7593
|
if (!executablePath) return void 0;
|
|
7457
|
-
const name =
|
|
7594
|
+
const name = import_node_path4.default.basename(executablePath);
|
|
7458
7595
|
return CLI_COMPLETION_SHELLS.includes(name) ? name : void 0;
|
|
7459
7596
|
}
|
|
7460
7597
|
function completionPathForShell(shell, io, dependencies) {
|
|
7461
7598
|
const home = io.getEnvironmentValue("HOME") || dependencies.homedir();
|
|
7462
7599
|
switch (shell) {
|
|
7463
7600
|
case "bash": {
|
|
7464
|
-
const dataHome = io.getEnvironmentValue("XDG_DATA_HOME") ||
|
|
7601
|
+
const dataHome = io.getEnvironmentValue("XDG_DATA_HOME") || import_node_path4.default.join(home, ".local/share");
|
|
7465
7602
|
return {
|
|
7466
|
-
completionPath:
|
|
7603
|
+
completionPath: import_node_path4.default.join(dataHome, "bash-completion/completions/lingua")
|
|
7467
7604
|
};
|
|
7468
7605
|
}
|
|
7469
7606
|
case "zsh": {
|
|
7470
7607
|
const zshHome = io.getEnvironmentValue("ZDOTDIR") || home;
|
|
7471
7608
|
return {
|
|
7472
|
-
completionPath:
|
|
7473
|
-
activationPath:
|
|
7609
|
+
completionPath: import_node_path4.default.join(zshHome, ".zfunc/_lingua"),
|
|
7610
|
+
activationPath: import_node_path4.default.join(zshHome, ".zshrc")
|
|
7474
7611
|
};
|
|
7475
7612
|
}
|
|
7476
7613
|
case "fish": {
|
|
7477
|
-
const configHome = io.getEnvironmentValue("XDG_CONFIG_HOME") ||
|
|
7614
|
+
const configHome = io.getEnvironmentValue("XDG_CONFIG_HOME") || import_node_path4.default.join(home, ".config");
|
|
7478
7615
|
return {
|
|
7479
|
-
completionPath:
|
|
7616
|
+
completionPath: import_node_path4.default.join(configHome, "fish/completions/lingua.fish")
|
|
7480
7617
|
};
|
|
7481
7618
|
}
|
|
7482
7619
|
}
|
|
@@ -7486,9 +7623,9 @@ async function resolveExecutable(shell, io, dependencies) {
|
|
|
7486
7623
|
if (shellFromExecutable(currentShellPath) === shell && currentShellPath !== void 0 && await dependencies.isExecutable(currentShellPath)) {
|
|
7487
7624
|
return currentShellPath;
|
|
7488
7625
|
}
|
|
7489
|
-
const pathEntries = (io.getEnvironmentValue("PATH") || "").split(
|
|
7626
|
+
const pathEntries = (io.getEnvironmentValue("PATH") || "").split(import_node_path4.default.delimiter).filter(Boolean);
|
|
7490
7627
|
for (const directory of pathEntries) {
|
|
7491
|
-
const candidate =
|
|
7628
|
+
const candidate = import_node_path4.default.join(directory, shell);
|
|
7492
7629
|
if (await dependencies.isExecutable(candidate)) return candidate;
|
|
7493
7630
|
}
|
|
7494
7631
|
return void 0;
|
|
@@ -7571,7 +7708,7 @@ async function runCompletionInstallCommand(options, io, dependencies = defaultDe
|
|
|
7571
7708
|
}
|
|
7572
7709
|
}
|
|
7573
7710
|
for (const target of targets) {
|
|
7574
|
-
await dependencies.mkdir(
|
|
7711
|
+
await dependencies.mkdir(import_node_path4.default.dirname(target.completionPath));
|
|
7575
7712
|
await dependencies.writeFile(target.completionPath, renderCompletion(target.shell));
|
|
7576
7713
|
if (target.shell === "zsh" && target.activationPath) {
|
|
7577
7714
|
await ensureZshActivation(target.activationPath, dependencies);
|
|
@@ -10398,8 +10535,8 @@ function createDefaultIo() {
|
|
|
10398
10535
|
writeStderr(text) {
|
|
10399
10536
|
process.stderr.write(text);
|
|
10400
10537
|
},
|
|
10401
|
-
async readFile(
|
|
10402
|
-
return (0, import_promises4.readFile)(
|
|
10538
|
+
async readFile(path5) {
|
|
10539
|
+
return (0, import_promises4.readFile)(path5, "utf8");
|
|
10403
10540
|
},
|
|
10404
10541
|
async readStdin() {
|
|
10405
10542
|
if (process.stdin.isTTY) {
|
|
@@ -10870,8 +11007,8 @@ function assertSingleTarget(command, positionals, help, label) {
|
|
|
10870
11007
|
|
|
10871
11008
|
// src/cli/lingua.ts
|
|
10872
11009
|
function resolveCliVersion() {
|
|
10873
|
-
if ("1.
|
|
10874
|
-
return "1.
|
|
11010
|
+
if ("1.5.0".length > 0) {
|
|
11011
|
+
return "1.5.0";
|
|
10875
11012
|
}
|
|
10876
11013
|
return "0.0.0-dev";
|
|
10877
11014
|
}
|
package/package.json
CHANGED