pythonlib 1.0.2 → 2.0.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 +3 -1
- package/dist/base64-C_am75Sv.d.ts +165 -0
- package/dist/base64.d.ts +1 -0
- package/dist/base64.js +37 -0
- package/dist/chunk-2YTO24B5.js +78 -0
- package/dist/chunk-3CLXPGAB.js +237 -0
- package/dist/{chunk-7BZB2TQF.js → chunk-3M3PB4RO.js} +4 -6
- package/dist/chunk-5OKGPZBQ.js +1106 -0
- package/dist/chunk-5VAHUJNC.js +348 -0
- package/dist/chunk-B5AUEOAH.js +193 -0
- package/dist/chunk-B5LQJODJ.js +37 -0
- package/dist/{chunk-CUP6EPDB.js → chunk-BCMGGBWG.js} +2 -5
- package/dist/chunk-BCVIH2BN.js +175 -0
- package/dist/{chunk-QURVRHY2.js → chunk-D35YI363.js} +15 -12
- package/dist/{chunk-RSBRI27Z.js → chunk-ETBW6XNR.js} +3 -4
- package/dist/chunk-FCJ7E4OE.js +250 -0
- package/dist/chunk-HSTC277I.js +255 -0
- package/dist/chunk-IANXD4D4.js +250 -0
- package/dist/{chunk-G6PUQTVZ.js → chunk-JAUU3HMH.js} +1 -2
- package/dist/chunk-JJKTRIVO.js +262 -0
- package/dist/chunk-KKHKTQNN.js +361 -0
- package/dist/chunk-KKJHGY4C.js +551 -0
- package/dist/chunk-LHPQS75Z.js +192 -0
- package/dist/{chunk-OSX7QZAW.js → chunk-LK2L2TFG.js} +5 -6
- package/dist/chunk-LLZFLQS6.js +280 -0
- package/dist/chunk-LTXTS7RP.js +154 -0
- package/dist/{chunk-CEZSBJJV.js → chunk-LWYBTWBZ.js} +2 -3
- package/dist/{chunk-TAYRRHJ3.js → chunk-MFKIEN7N.js} +1 -2
- package/dist/{chunk-PZ5AY32C.js → chunk-MLKGABMK.js} +0 -1
- package/dist/chunk-OZRS5PC4.js +312 -0
- package/dist/chunk-PWA3YQZU.js +346 -0
- package/dist/{chunk-56DGFWIJ.js → chunk-QKJBQKPY.js} +1 -2
- package/dist/chunk-RB6BYCIQ.js +141 -0
- package/dist/chunk-U4X5DEIP.js +188 -0
- package/dist/chunk-UGZ5OY5Z.js +165 -0
- package/dist/chunk-WTZSAITC.js +82 -0
- package/dist/collections.js +2 -3
- package/dist/copy-6ZaZ__ge.d.ts +59 -0
- package/dist/copy.d.ts +1 -0
- package/dist/copy.js +9 -0
- package/dist/datetime.js +2 -3
- package/dist/functools.js +2 -3
- package/dist/glob.browser-B6d_YdV5.d.ts +50 -0
- package/dist/glob.browser.d.ts +1 -0
- package/dist/glob.browser.js +15 -0
- package/dist/glob.node-wn5ehtyM.d.ts +80 -0
- package/dist/glob.node.d.ts +1 -0
- package/dist/glob.node.js +15 -0
- package/dist/hashlib-vKP511NY.d.ts +205 -0
- package/dist/hashlib.d.ts +1 -0
- package/dist/hashlib.js +39 -0
- package/dist/index.browser.d.ts +172 -0
- package/dist/index.browser.js +304 -0
- package/dist/index.d.ts +36 -602
- package/dist/index.js +138 -1073
- package/dist/itertools.js +2 -3
- package/dist/json.js +2 -3
- package/dist/logging.browser-Dux4L5kz.d.ts +185 -0
- package/dist/logging.browser.d.ts +1 -0
- package/dist/logging.browser.js +63 -0
- package/dist/logging.node-CH75bVdE.d.ts +185 -0
- package/dist/logging.node.d.ts +1 -0
- package/dist/logging.node.js +61 -0
- package/dist/math.js +2 -3
- package/dist/{os-CqGKe872.d.ts → os.browser-krjSx5kF.d.ts} +32 -55
- package/dist/os.browser.d.ts +2 -0
- package/dist/{os.js → os.browser.js} +41 -16
- package/dist/os.node-CQjch8Ht.d.ts +124 -0
- package/dist/os.node.d.ts +2 -0
- package/dist/os.node.js +83 -0
- package/dist/os.shared-C3x70nhO.d.ts +59 -0
- package/dist/pathlib.browser-NC7kKQYe.d.ts +91 -0
- package/dist/pathlib.browser.d.ts +1 -0
- package/dist/pathlib.browser.js +17 -0
- package/dist/pathlib.node-CY3yUFdT.d.ts +331 -0
- package/dist/pathlib.node.d.ts +2 -0
- package/dist/pathlib.node.js +17 -0
- package/dist/random.js +2 -3
- package/dist/re.js +2 -3
- package/dist/set-JQbLAq8B.d.ts +592 -0
- package/dist/shutil.browser-Ck5oWhnP.d.ts +113 -0
- package/dist/shutil.browser.d.ts +1 -0
- package/dist/shutil.browser.js +33 -0
- package/dist/shutil.node-C9kwvhAf.d.ts +160 -0
- package/dist/shutil.node.d.ts +2 -0
- package/dist/shutil.node.js +33 -0
- package/dist/string.js +2 -3
- package/dist/subprocess-CZVYzQ3V.d.ts +214 -0
- package/dist/subprocess.d.ts +1 -0
- package/dist/subprocess.js +29 -0
- package/dist/sys-IL8LgI_W.d.ts +212 -0
- package/dist/sys.d.ts +1 -0
- package/dist/sys.js +51 -0
- package/dist/tempfile.browser-DciOKfNm.d.ts +78 -0
- package/dist/tempfile.browser.d.ts +1 -0
- package/dist/tempfile.browser.js +19 -0
- package/dist/tempfile.node-bVMY60Cu.d.ts +195 -0
- package/dist/tempfile.node.d.ts +2 -0
- package/dist/tempfile.node.js +23 -0
- package/dist/time-CcYhdiSu.d.ts +245 -0
- package/dist/time.d.ts +1 -0
- package/dist/time.js +49 -0
- package/dist/urllib-DJtkj-0f.d.ts +198 -0
- package/dist/urllib.d.ts +1 -0
- package/dist/urllib.js +37 -0
- package/dist/uuid-C0ypmn56.d.ts +160 -0
- package/dist/uuid.d.ts +1 -0
- package/dist/uuid.js +23 -0
- package/package.json +127 -5
- package/dist/chunk-56DGFWIJ.js.map +0 -1
- package/dist/chunk-5AOJFFYN.js +0 -313
- package/dist/chunk-5AOJFFYN.js.map +0 -1
- package/dist/chunk-7BZB2TQF.js.map +0 -1
- package/dist/chunk-CEZSBJJV.js.map +0 -1
- package/dist/chunk-CUP6EPDB.js.map +0 -1
- package/dist/chunk-G6PUQTVZ.js.map +0 -1
- package/dist/chunk-OSX7QZAW.js.map +0 -1
- package/dist/chunk-PZ5AY32C.js.map +0 -1
- package/dist/chunk-QURVRHY2.js.map +0 -1
- package/dist/chunk-RSBRI27Z.js.map +0 -1
- package/dist/chunk-TAYRRHJ3.js.map +0 -1
- package/dist/collections.js.map +0 -1
- package/dist/datetime.js.map +0 -1
- package/dist/functools.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/itertools.js.map +0 -1
- package/dist/json.js.map +0 -1
- package/dist/math.js.map +0 -1
- package/dist/os.d.ts +0 -1
- package/dist/os.js.map +0 -1
- package/dist/random.js.map +0 -1
- package/dist/re.js.map +0 -1
- package/dist/string.js.map +0 -1
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
// src/os.shared.ts
|
|
2
|
+
var environ = typeof process !== "undefined" ? process.env : {};
|
|
3
|
+
function getenv(key, defaultValue) {
|
|
4
|
+
return environ[key] ?? defaultValue;
|
|
5
|
+
}
|
|
6
|
+
var sep = typeof process !== "undefined" && process.platform === "win32" ? "\\" : "/";
|
|
7
|
+
var altSep = typeof process !== "undefined" && process.platform === "win32" ? "/" : null;
|
|
8
|
+
var pathSep = typeof process !== "undefined" && process.platform === "win32" ? ";" : ":";
|
|
9
|
+
var lineSep = typeof process !== "undefined" && process.platform === "win32" ? "\r\n" : "\n";
|
|
10
|
+
var curDir = ".";
|
|
11
|
+
var parDir = "..";
|
|
12
|
+
var extSep = ".";
|
|
13
|
+
var name = typeof process !== "undefined" && process.platform === "win32" ? "nt" : "posix";
|
|
14
|
+
function pathJoin(...paths) {
|
|
15
|
+
if (paths.length === 0) return "";
|
|
16
|
+
if (paths.length === 1) return paths[0] ?? "";
|
|
17
|
+
let result = paths[0] ?? "";
|
|
18
|
+
for (let i = 1; i < paths.length; i++) {
|
|
19
|
+
const p = paths[i] ?? "";
|
|
20
|
+
if (p.startsWith("/") || p.length > 1 && p[1] === ":") {
|
|
21
|
+
result = p;
|
|
22
|
+
} else if (result === "" || result.endsWith("/") || result.endsWith("\\")) {
|
|
23
|
+
result += p;
|
|
24
|
+
} else {
|
|
25
|
+
result += sep + p;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
function pathBasename(p, suffix) {
|
|
31
|
+
let s = p.replace(/[/\\]+$/, "");
|
|
32
|
+
const idx = Math.max(s.lastIndexOf("/"), s.lastIndexOf("\\"));
|
|
33
|
+
s = idx >= 0 ? s.slice(idx + 1) : s;
|
|
34
|
+
if (suffix && s.endsWith(suffix)) {
|
|
35
|
+
s = s.slice(0, -suffix.length);
|
|
36
|
+
}
|
|
37
|
+
return s;
|
|
38
|
+
}
|
|
39
|
+
function pathDirname(p) {
|
|
40
|
+
const s = p.replace(/[/\\]+$/, "");
|
|
41
|
+
const idx = Math.max(s.lastIndexOf("/"), s.lastIndexOf("\\"));
|
|
42
|
+
if (idx < 0) return "";
|
|
43
|
+
if (idx === 0) return s[0] ?? "";
|
|
44
|
+
return s.slice(0, idx);
|
|
45
|
+
}
|
|
46
|
+
function pathSplitFn(p) {
|
|
47
|
+
return [pathDirname(p), pathBasename(p)];
|
|
48
|
+
}
|
|
49
|
+
function pathSplitExt(p) {
|
|
50
|
+
const base = pathBasename(p);
|
|
51
|
+
const dotIdx = base.lastIndexOf(".");
|
|
52
|
+
if (dotIdx <= 0) {
|
|
53
|
+
return [p, ""];
|
|
54
|
+
}
|
|
55
|
+
const dir = pathDirname(p);
|
|
56
|
+
const root = base.slice(0, dotIdx);
|
|
57
|
+
const ext = base.slice(dotIdx);
|
|
58
|
+
return [dir ? pathJoin(dir, root) : root, ext];
|
|
59
|
+
}
|
|
60
|
+
function pathExtName(p) {
|
|
61
|
+
return pathSplitExt(p)[1];
|
|
62
|
+
}
|
|
63
|
+
function pathIsAbs(p) {
|
|
64
|
+
if (p.startsWith("/")) return true;
|
|
65
|
+
if (p.length >= 3 && p[1] === ":" && (p[2] === "/" || p[2] === "\\")) return true;
|
|
66
|
+
if (p.startsWith("\\\\")) return true;
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
function pathNormPath(p) {
|
|
70
|
+
if (!p) return ".";
|
|
71
|
+
let prefix = "";
|
|
72
|
+
if (p.length >= 2 && p[1] === ":") {
|
|
73
|
+
prefix = p.slice(0, 2);
|
|
74
|
+
p = p.slice(2);
|
|
75
|
+
}
|
|
76
|
+
const isWin = p.includes("\\");
|
|
77
|
+
p = p.replace(/\\/g, "/");
|
|
78
|
+
const isAbsolute = p.startsWith("/");
|
|
79
|
+
const parts = p.split("/").filter((part) => part && part !== ".");
|
|
80
|
+
const result = [];
|
|
81
|
+
for (const part of parts) {
|
|
82
|
+
if (part === "..") {
|
|
83
|
+
if (result.length > 0 && result[result.length - 1] !== "..") {
|
|
84
|
+
result.pop();
|
|
85
|
+
} else if (!isAbsolute) {
|
|
86
|
+
result.push("..");
|
|
87
|
+
}
|
|
88
|
+
} else {
|
|
89
|
+
result.push(part);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
let normalized = result.join(isWin ? "\\" : "/");
|
|
93
|
+
if (isAbsolute) {
|
|
94
|
+
normalized = (isWin ? "\\" : "/") + normalized;
|
|
95
|
+
}
|
|
96
|
+
normalized = prefix + normalized;
|
|
97
|
+
return normalized || ".";
|
|
98
|
+
}
|
|
99
|
+
function pathRelPath(p, start = ".") {
|
|
100
|
+
const pParts = pathNormPath(p).split(/[/\\]/).filter(Boolean);
|
|
101
|
+
const startParts = pathNormPath(start).split(/[/\\]/).filter(Boolean);
|
|
102
|
+
let commonLen = 0;
|
|
103
|
+
const minLen = Math.min(pParts.length, startParts.length);
|
|
104
|
+
for (let i = 0; i < minLen; i++) {
|
|
105
|
+
if (pParts[i] === startParts[i]) {
|
|
106
|
+
commonLen++;
|
|
107
|
+
} else {
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
const upCount = startParts.length - commonLen;
|
|
112
|
+
const result = [...Array(upCount).fill(".."), ...pParts.slice(commonLen)];
|
|
113
|
+
return result.join(sep) || ".";
|
|
114
|
+
}
|
|
115
|
+
function pathCommonPath(paths) {
|
|
116
|
+
if (paths.length === 0) {
|
|
117
|
+
throw new Error("commonPath() arg is an empty sequence");
|
|
118
|
+
}
|
|
119
|
+
const splitPaths = paths.map((p) => pathNormPath(p).split(/[/\\]/));
|
|
120
|
+
const first = splitPaths[0];
|
|
121
|
+
if (!first) {
|
|
122
|
+
throw new Error("commonPath() arg is an empty sequence");
|
|
123
|
+
}
|
|
124
|
+
let commonLen = first.length;
|
|
125
|
+
for (const parts of splitPaths.slice(1)) {
|
|
126
|
+
commonLen = Math.min(commonLen, parts.length);
|
|
127
|
+
for (let j = 0; j < commonLen; j++) {
|
|
128
|
+
if (parts[j] !== first[j]) {
|
|
129
|
+
commonLen = j;
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return first.slice(0, commonLen).join(sep) || sep;
|
|
135
|
+
}
|
|
136
|
+
function pathExpandUser(p) {
|
|
137
|
+
if (!p.startsWith("~")) return p;
|
|
138
|
+
const home = typeof process !== "undefined" ? process.env.HOME ?? process.env.USERPROFILE : void 0;
|
|
139
|
+
if (!home) return p;
|
|
140
|
+
if (p === "~" || p.startsWith("~/") || p.startsWith("~\\")) {
|
|
141
|
+
return home + p.slice(1);
|
|
142
|
+
}
|
|
143
|
+
return p;
|
|
144
|
+
}
|
|
145
|
+
function pathExpandVars(p) {
|
|
146
|
+
return p.replace(/\$(\w+)|\$\{(\w+)\}/g, (_, v1, v2) => {
|
|
147
|
+
const key = v1 || v2;
|
|
148
|
+
return environ[key] ?? "";
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
function getCwd() {
|
|
152
|
+
if (typeof process !== "undefined") {
|
|
153
|
+
return process.cwd();
|
|
154
|
+
}
|
|
155
|
+
return "/";
|
|
156
|
+
}
|
|
157
|
+
function getCwdb() {
|
|
158
|
+
return getCwd();
|
|
159
|
+
}
|
|
160
|
+
function chdir(p) {
|
|
161
|
+
if (typeof process !== "undefined") {
|
|
162
|
+
process.chdir(p);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export {
|
|
167
|
+
environ,
|
|
168
|
+
getenv,
|
|
169
|
+
sep,
|
|
170
|
+
altSep,
|
|
171
|
+
pathSep,
|
|
172
|
+
lineSep,
|
|
173
|
+
curDir,
|
|
174
|
+
parDir,
|
|
175
|
+
extSep,
|
|
176
|
+
name,
|
|
177
|
+
pathJoin,
|
|
178
|
+
pathBasename,
|
|
179
|
+
pathDirname,
|
|
180
|
+
pathSplitFn,
|
|
181
|
+
pathSplitExt,
|
|
182
|
+
pathExtName,
|
|
183
|
+
pathIsAbs,
|
|
184
|
+
pathNormPath,
|
|
185
|
+
pathRelPath,
|
|
186
|
+
pathCommonPath,
|
|
187
|
+
pathExpandUser,
|
|
188
|
+
pathExpandVars,
|
|
189
|
+
getCwd,
|
|
190
|
+
getCwdb,
|
|
191
|
+
chdir
|
|
192
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
__export
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-MLKGABMK.js";
|
|
4
4
|
|
|
5
5
|
// src/datetime.ts
|
|
6
6
|
var datetime_exports = {};
|
|
@@ -120,7 +120,7 @@ var date = class _date {
|
|
|
120
120
|
}
|
|
121
121
|
static fromIsoFormat(dateString) {
|
|
122
122
|
const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(dateString);
|
|
123
|
-
if (!match
|
|
123
|
+
if (!match?.[1] || !match[2] || !match[3]) {
|
|
124
124
|
throw new Error(`Invalid isoFormat string: '${dateString}'`);
|
|
125
125
|
}
|
|
126
126
|
return new _date(parseInt(match[1]), parseInt(match[2]), parseInt(match[3]));
|
|
@@ -231,7 +231,7 @@ var time = class _time {
|
|
|
231
231
|
}
|
|
232
232
|
static fromIsoFormat(timeString) {
|
|
233
233
|
const match = /^(\d{2}):(\d{2}):(\d{2})(?:\.(\d+))?$/.exec(timeString);
|
|
234
|
-
if (!match
|
|
234
|
+
if (!match?.[1] || !match[2] || !match[3]) {
|
|
235
235
|
throw new Error(`Invalid isoFormat string: '${timeString}'`);
|
|
236
236
|
}
|
|
237
237
|
const microsecond = match[4] ? parseInt(match[4].padEnd(6, "0").slice(0, 6)) : 0;
|
|
@@ -352,9 +352,9 @@ var datetime = class _datetime extends date {
|
|
|
352
352
|
}
|
|
353
353
|
static fromIsoFormat(s) {
|
|
354
354
|
const match = /^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2}):(\d{2})(?:\.(\d+))?$/.exec(s);
|
|
355
|
-
if (!match
|
|
355
|
+
if (!match?.[1] || !match[2] || !match[3] || !match[4] || !match[5] || !match[6]) {
|
|
356
356
|
const dateMatch = /^(\d{4})-(\d{2})-(\d{2})$/.exec(s);
|
|
357
|
-
if (dateMatch
|
|
357
|
+
if (dateMatch?.[1] && dateMatch[2] && dateMatch[3]) {
|
|
358
358
|
return new _datetime(parseInt(dateMatch[1]), parseInt(dateMatch[2]), parseInt(dateMatch[3]));
|
|
359
359
|
}
|
|
360
360
|
throw new Error(`Invalid isoFormat string: '${s}'`);
|
|
@@ -678,4 +678,3 @@ export {
|
|
|
678
678
|
MAXYEAR,
|
|
679
679
|
datetime_exports
|
|
680
680
|
};
|
|
681
|
-
//# sourceMappingURL=chunk-OSX7QZAW.js.map
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__export
|
|
3
|
+
} from "./chunk-MLKGABMK.js";
|
|
4
|
+
|
|
5
|
+
// src/subprocess.ts
|
|
6
|
+
var subprocess_exports = {};
|
|
7
|
+
__export(subprocess_exports, {
|
|
8
|
+
CalledProcessError: () => CalledProcessError,
|
|
9
|
+
DEVNULL: () => DEVNULL,
|
|
10
|
+
PIPE: () => PIPE,
|
|
11
|
+
Popen: () => Popen,
|
|
12
|
+
STDOUT: () => STDOUT,
|
|
13
|
+
TimeoutExpired: () => TimeoutExpired,
|
|
14
|
+
call: () => call,
|
|
15
|
+
checkCall: () => checkCall,
|
|
16
|
+
checkOutput: () => checkOutput,
|
|
17
|
+
getoutput: () => getoutput,
|
|
18
|
+
getstatusoutput: () => getstatusoutput,
|
|
19
|
+
run: () => run
|
|
20
|
+
});
|
|
21
|
+
import * as childProcess from "child_process";
|
|
22
|
+
var PIPE = "pipe";
|
|
23
|
+
var STDOUT = "stdout";
|
|
24
|
+
var DEVNULL = "devnull";
|
|
25
|
+
var CalledProcessError = class extends Error {
|
|
26
|
+
returncode;
|
|
27
|
+
cmd;
|
|
28
|
+
stdout;
|
|
29
|
+
stderr;
|
|
30
|
+
constructor(returncode, cmd, stdout = null, stderr = null) {
|
|
31
|
+
super(`Command '${cmd.join(" ")}' returned non-zero exit status ${String(returncode)}`);
|
|
32
|
+
this.name = "CalledProcessError";
|
|
33
|
+
this.returncode = returncode;
|
|
34
|
+
this.cmd = cmd;
|
|
35
|
+
this.stdout = stdout;
|
|
36
|
+
this.stderr = stderr;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
var TimeoutExpired = class extends Error {
|
|
40
|
+
cmd;
|
|
41
|
+
timeout;
|
|
42
|
+
stdout;
|
|
43
|
+
stderr;
|
|
44
|
+
constructor(cmd, timeout, stdout = null, stderr = null) {
|
|
45
|
+
super(`Command '${cmd.join(" ")}' timed out after ${String(timeout)} milliseconds`);
|
|
46
|
+
this.name = "TimeoutExpired";
|
|
47
|
+
this.cmd = cmd;
|
|
48
|
+
this.timeout = timeout;
|
|
49
|
+
this.stdout = stdout;
|
|
50
|
+
this.stderr = stderr;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
function run(args, options) {
|
|
54
|
+
const encoding = options?.encoding ?? "utf-8";
|
|
55
|
+
const text = options?.text ?? true;
|
|
56
|
+
let command;
|
|
57
|
+
let cmdArgs;
|
|
58
|
+
if (typeof args === "string") {
|
|
59
|
+
command = args;
|
|
60
|
+
cmdArgs = [args];
|
|
61
|
+
} else {
|
|
62
|
+
command = args[0] ?? "";
|
|
63
|
+
cmdArgs = args.slice(1);
|
|
64
|
+
}
|
|
65
|
+
const spawnOptions = {
|
|
66
|
+
cwd: options?.cwd,
|
|
67
|
+
env: options?.env ? { ...process.env, ...options.env } : void 0,
|
|
68
|
+
input: options?.input,
|
|
69
|
+
timeout: options?.timeout,
|
|
70
|
+
shell: options?.shell,
|
|
71
|
+
encoding: text ? encoding : "buffer",
|
|
72
|
+
stdio: [
|
|
73
|
+
options?.input !== void 0 ? "pipe" : "inherit",
|
|
74
|
+
options?.stdout === PIPE ? "pipe" : options?.stdout === DEVNULL ? "ignore" : "inherit",
|
|
75
|
+
options?.stderr === PIPE ? "pipe" : options?.stderr === STDOUT ? "pipe" : options?.stderr === DEVNULL ? "ignore" : "inherit"
|
|
76
|
+
]
|
|
77
|
+
};
|
|
78
|
+
let result;
|
|
79
|
+
if (typeof args === "string" || options?.shell) {
|
|
80
|
+
result = childProcess.spawnSync(typeof args === "string" ? args : args.join(" "), [], {
|
|
81
|
+
...spawnOptions,
|
|
82
|
+
shell: true
|
|
83
|
+
});
|
|
84
|
+
} else {
|
|
85
|
+
result = childProcess.spawnSync(command, cmdArgs, spawnOptions);
|
|
86
|
+
}
|
|
87
|
+
if (result.error && result.error.code === "ETIMEDOUT") {
|
|
88
|
+
throw new TimeoutExpired(
|
|
89
|
+
typeof args === "string" ? [args] : args,
|
|
90
|
+
options?.timeout ?? 0,
|
|
91
|
+
result.stdout ? result.stdout.toString() : null,
|
|
92
|
+
result.stderr ? result.stderr.toString() : null
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
const stdout = result.stdout ? text ? result.stdout.toString() : result.stdout.toString() : null;
|
|
96
|
+
const stderr = result.stderr ? text ? result.stderr.toString() : result.stderr.toString() : null;
|
|
97
|
+
const returncode = result.status ?? -1;
|
|
98
|
+
if (options?.check && returncode !== 0) {
|
|
99
|
+
throw new CalledProcessError(
|
|
100
|
+
returncode,
|
|
101
|
+
typeof args === "string" ? [args] : args,
|
|
102
|
+
stdout,
|
|
103
|
+
stderr
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
return {
|
|
107
|
+
args: typeof args === "string" ? [args] : args,
|
|
108
|
+
returncode,
|
|
109
|
+
stdout,
|
|
110
|
+
stderr
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
function call(args, options) {
|
|
114
|
+
const result = run(args, options);
|
|
115
|
+
return result.returncode;
|
|
116
|
+
}
|
|
117
|
+
function checkCall(args, options) {
|
|
118
|
+
const result = run(args, { ...options, check: true });
|
|
119
|
+
return result.returncode;
|
|
120
|
+
}
|
|
121
|
+
function checkOutput(args, options) {
|
|
122
|
+
const result = run(args, { ...options, stdout: PIPE, check: true });
|
|
123
|
+
return result.stdout ?? "";
|
|
124
|
+
}
|
|
125
|
+
function getoutput(cmd) {
|
|
126
|
+
try {
|
|
127
|
+
const result = run(cmd, { shell: true, stdout: PIPE, stderr: DEVNULL });
|
|
128
|
+
return result.stdout?.trim() ?? "";
|
|
129
|
+
} catch {
|
|
130
|
+
return "";
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
function getstatusoutput(cmd) {
|
|
134
|
+
const result = run(cmd, { shell: true, stdout: PIPE, stderr: STDOUT });
|
|
135
|
+
return [result.returncode, result.stdout?.trim() ?? ""];
|
|
136
|
+
}
|
|
137
|
+
var Popen = class {
|
|
138
|
+
args;
|
|
139
|
+
process;
|
|
140
|
+
_returncode = null;
|
|
141
|
+
_stdout = null;
|
|
142
|
+
_stderr = null;
|
|
143
|
+
constructor(args, options) {
|
|
144
|
+
this.args = typeof args === "string" ? [args] : args;
|
|
145
|
+
const command = typeof args === "string" ? args : args[0] ?? "";
|
|
146
|
+
const cmdArgs = typeof args === "string" ? [] : args.slice(1);
|
|
147
|
+
const spawnOptions = {
|
|
148
|
+
cwd: options?.cwd,
|
|
149
|
+
env: options?.env ? { ...process.env, ...options.env } : void 0,
|
|
150
|
+
shell: options?.shell,
|
|
151
|
+
stdio: [
|
|
152
|
+
options?.input !== void 0 ? "pipe" : "inherit",
|
|
153
|
+
options?.stdout === PIPE ? "pipe" : options?.stdout === DEVNULL ? "ignore" : "inherit",
|
|
154
|
+
options?.stderr === PIPE ? "pipe" : options?.stderr === STDOUT ? "pipe" : options?.stderr === DEVNULL ? "ignore" : "inherit"
|
|
155
|
+
]
|
|
156
|
+
};
|
|
157
|
+
if (typeof args === "string" || options?.shell) {
|
|
158
|
+
this.process = childProcess.spawn(typeof args === "string" ? args : args.join(" "), [], {
|
|
159
|
+
...spawnOptions,
|
|
160
|
+
shell: true
|
|
161
|
+
});
|
|
162
|
+
} else {
|
|
163
|
+
this.process = childProcess.spawn(command, cmdArgs, spawnOptions);
|
|
164
|
+
}
|
|
165
|
+
if (options?.input !== void 0 && this.process.stdin) {
|
|
166
|
+
this.process.stdin.write(options.input);
|
|
167
|
+
this.process.stdin.end();
|
|
168
|
+
}
|
|
169
|
+
if (this.process.stdout) {
|
|
170
|
+
let data = "";
|
|
171
|
+
this.process.stdout.on("data", (chunk) => {
|
|
172
|
+
data += chunk.toString();
|
|
173
|
+
});
|
|
174
|
+
this.process.stdout.on("end", () => {
|
|
175
|
+
this._stdout = data;
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
if (this.process.stderr) {
|
|
179
|
+
let data = "";
|
|
180
|
+
this.process.stderr.on("data", (chunk) => {
|
|
181
|
+
data += chunk.toString();
|
|
182
|
+
});
|
|
183
|
+
this.process.stderr.on("end", () => {
|
|
184
|
+
this._stderr = data;
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
this.process.on("exit", (code) => {
|
|
188
|
+
this._returncode = code ?? -1;
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Wait for the process to complete.
|
|
193
|
+
*/
|
|
194
|
+
wait() {
|
|
195
|
+
return new Promise((resolve) => {
|
|
196
|
+
if (this._returncode !== null) {
|
|
197
|
+
resolve(this._returncode);
|
|
198
|
+
} else {
|
|
199
|
+
this.process.on("exit", (code) => {
|
|
200
|
+
resolve(code ?? -1);
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Get the exit code (or null if still running).
|
|
207
|
+
*/
|
|
208
|
+
poll() {
|
|
209
|
+
return this._returncode;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Communicate with the process and return stdout/stderr.
|
|
213
|
+
*/
|
|
214
|
+
async communicate(input) {
|
|
215
|
+
if (input !== void 0 && this.process.stdin) {
|
|
216
|
+
this.process.stdin.write(input);
|
|
217
|
+
this.process.stdin.end();
|
|
218
|
+
}
|
|
219
|
+
await this.wait();
|
|
220
|
+
return [this._stdout, this._stderr];
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Send a signal to the process.
|
|
224
|
+
*/
|
|
225
|
+
send_signal(signal) {
|
|
226
|
+
return this.process.kill(signal);
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Terminate the process.
|
|
230
|
+
*/
|
|
231
|
+
terminate() {
|
|
232
|
+
return this.process.kill("SIGTERM");
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Kill the process.
|
|
236
|
+
*/
|
|
237
|
+
kill() {
|
|
238
|
+
return this.process.kill("SIGKILL");
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* The process ID.
|
|
242
|
+
*/
|
|
243
|
+
get pid() {
|
|
244
|
+
return this.process.pid;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* The exit code (or null if still running).
|
|
248
|
+
*/
|
|
249
|
+
get returncode() {
|
|
250
|
+
return this._returncode;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* The captured stdout.
|
|
254
|
+
*/
|
|
255
|
+
get stdout() {
|
|
256
|
+
return this._stdout;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* The captured stderr.
|
|
260
|
+
*/
|
|
261
|
+
get stderr() {
|
|
262
|
+
return this._stderr;
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
export {
|
|
267
|
+
PIPE,
|
|
268
|
+
STDOUT,
|
|
269
|
+
DEVNULL,
|
|
270
|
+
CalledProcessError,
|
|
271
|
+
TimeoutExpired,
|
|
272
|
+
run,
|
|
273
|
+
call,
|
|
274
|
+
checkCall,
|
|
275
|
+
checkOutput,
|
|
276
|
+
getoutput,
|
|
277
|
+
getstatusoutput,
|
|
278
|
+
Popen,
|
|
279
|
+
subprocess_exports
|
|
280
|
+
};
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__export
|
|
3
|
+
} from "./chunk-MLKGABMK.js";
|
|
4
|
+
|
|
5
|
+
// src/copy.ts
|
|
6
|
+
var copy_exports = {};
|
|
7
|
+
__export(copy_exports, {
|
|
8
|
+
copy: () => copy,
|
|
9
|
+
deepcopy: () => deepcopy
|
|
10
|
+
});
|
|
11
|
+
function copy(x) {
|
|
12
|
+
if (x === null || x === void 0) {
|
|
13
|
+
return x;
|
|
14
|
+
}
|
|
15
|
+
const type = typeof x;
|
|
16
|
+
if (type === "number" || type === "string" || type === "boolean" || type === "bigint" || type === "symbol") {
|
|
17
|
+
return x;
|
|
18
|
+
}
|
|
19
|
+
if (x instanceof Date) {
|
|
20
|
+
return new Date(x.getTime());
|
|
21
|
+
}
|
|
22
|
+
if (x instanceof RegExp) {
|
|
23
|
+
return new RegExp(x.source, x.flags);
|
|
24
|
+
}
|
|
25
|
+
if (Array.isArray(x)) {
|
|
26
|
+
return [...x];
|
|
27
|
+
}
|
|
28
|
+
if (x instanceof Map) {
|
|
29
|
+
return new Map(x);
|
|
30
|
+
}
|
|
31
|
+
if (x instanceof Set) {
|
|
32
|
+
return new Set(x);
|
|
33
|
+
}
|
|
34
|
+
if (ArrayBuffer.isView(x) && !(x instanceof DataView)) {
|
|
35
|
+
const TypedArrayConstructor = x.constructor;
|
|
36
|
+
const typedArray = x;
|
|
37
|
+
return new TypedArrayConstructor(typedArray.buffer.slice(0));
|
|
38
|
+
}
|
|
39
|
+
if (x instanceof DataView) {
|
|
40
|
+
return new DataView(x.buffer.slice(0), x.byteOffset, x.byteLength);
|
|
41
|
+
}
|
|
42
|
+
if (x instanceof ArrayBuffer) {
|
|
43
|
+
return x.slice(0);
|
|
44
|
+
}
|
|
45
|
+
if (type === "object") {
|
|
46
|
+
const proto = Object.getPrototypeOf(x);
|
|
47
|
+
if (proto === Object.prototype || proto === null) {
|
|
48
|
+
return { ...x };
|
|
49
|
+
}
|
|
50
|
+
const result = Object.create(proto);
|
|
51
|
+
Object.assign(result, x);
|
|
52
|
+
return result;
|
|
53
|
+
}
|
|
54
|
+
return x;
|
|
55
|
+
}
|
|
56
|
+
function deepcopy(x, memo) {
|
|
57
|
+
if (typeof structuredClone === "function") {
|
|
58
|
+
try {
|
|
59
|
+
return structuredClone(x);
|
|
60
|
+
} catch {
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (x === null || x === void 0) {
|
|
64
|
+
return x;
|
|
65
|
+
}
|
|
66
|
+
const type = typeof x;
|
|
67
|
+
if (type === "number" || type === "string" || type === "boolean" || type === "bigint" || type === "symbol") {
|
|
68
|
+
return x;
|
|
69
|
+
}
|
|
70
|
+
memo ??= /* @__PURE__ */ new Map();
|
|
71
|
+
if (memo.has(x)) {
|
|
72
|
+
return memo.get(x);
|
|
73
|
+
}
|
|
74
|
+
if (x instanceof Date) {
|
|
75
|
+
const result = new Date(x.getTime());
|
|
76
|
+
memo.set(x, result);
|
|
77
|
+
return result;
|
|
78
|
+
}
|
|
79
|
+
if (x instanceof RegExp) {
|
|
80
|
+
const result = new RegExp(x.source, x.flags);
|
|
81
|
+
memo.set(x, result);
|
|
82
|
+
return result;
|
|
83
|
+
}
|
|
84
|
+
if (Array.isArray(x)) {
|
|
85
|
+
const result = [];
|
|
86
|
+
memo.set(x, result);
|
|
87
|
+
for (const item of x) {
|
|
88
|
+
result.push(deepcopy(item, memo));
|
|
89
|
+
}
|
|
90
|
+
return result;
|
|
91
|
+
}
|
|
92
|
+
if (x instanceof Map) {
|
|
93
|
+
const result = /* @__PURE__ */ new Map();
|
|
94
|
+
memo.set(x, result);
|
|
95
|
+
for (const [key, value] of x) {
|
|
96
|
+
result.set(deepcopy(key, memo), deepcopy(value, memo));
|
|
97
|
+
}
|
|
98
|
+
return result;
|
|
99
|
+
}
|
|
100
|
+
if (x instanceof Set) {
|
|
101
|
+
const result = /* @__PURE__ */ new Set();
|
|
102
|
+
memo.set(x, result);
|
|
103
|
+
for (const item of x) {
|
|
104
|
+
result.add(deepcopy(item, memo));
|
|
105
|
+
}
|
|
106
|
+
return result;
|
|
107
|
+
}
|
|
108
|
+
if (ArrayBuffer.isView(x) && !(x instanceof DataView)) {
|
|
109
|
+
const TypedArrayConstructor = x.constructor;
|
|
110
|
+
const typedArray = x;
|
|
111
|
+
const result = new TypedArrayConstructor(typedArray.buffer.slice(0));
|
|
112
|
+
memo.set(x, result);
|
|
113
|
+
return result;
|
|
114
|
+
}
|
|
115
|
+
if (x instanceof DataView) {
|
|
116
|
+
const result = new DataView(x.buffer.slice(0), x.byteOffset, x.byteLength);
|
|
117
|
+
memo.set(x, result);
|
|
118
|
+
return result;
|
|
119
|
+
}
|
|
120
|
+
if (x instanceof ArrayBuffer) {
|
|
121
|
+
const result = x.slice(0);
|
|
122
|
+
memo.set(x, result);
|
|
123
|
+
return result;
|
|
124
|
+
}
|
|
125
|
+
if (type === "function") {
|
|
126
|
+
return x;
|
|
127
|
+
}
|
|
128
|
+
if (type === "object") {
|
|
129
|
+
const proto = Object.getPrototypeOf(x);
|
|
130
|
+
const result = Object.create(proto);
|
|
131
|
+
memo.set(x, result);
|
|
132
|
+
for (const key of Object.keys(x)) {
|
|
133
|
+
result[key] = deepcopy(x[key], memo);
|
|
134
|
+
}
|
|
135
|
+
for (const sym of Object.getOwnPropertySymbols(x)) {
|
|
136
|
+
const descriptor = Object.getOwnPropertyDescriptor(x, sym);
|
|
137
|
+
if (descriptor?.enumerable) {
|
|
138
|
+
;
|
|
139
|
+
result[sym] = deepcopy(
|
|
140
|
+
x[sym],
|
|
141
|
+
memo
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return result;
|
|
146
|
+
}
|
|
147
|
+
return x;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export {
|
|
151
|
+
copy,
|
|
152
|
+
deepcopy,
|
|
153
|
+
copy_exports
|
|
154
|
+
};
|
|
@@ -52,7 +52,7 @@ var Template = class {
|
|
|
52
52
|
const regex = /\$(\w+)|\$\{(\w+)\}/g;
|
|
53
53
|
let match;
|
|
54
54
|
while ((match = regex.exec(this.template)) !== null) {
|
|
55
|
-
const name = match[1]
|
|
55
|
+
const name = match[1] ?? match[2];
|
|
56
56
|
if (name && !identifiers.includes(name)) {
|
|
57
57
|
identifiers.push(name);
|
|
58
58
|
}
|
|
@@ -267,7 +267,7 @@ var string = {
|
|
|
267
267
|
*/
|
|
268
268
|
zFill(s, width) {
|
|
269
269
|
if (s.length >= width) return s;
|
|
270
|
-
const sign = s
|
|
270
|
+
const sign = s.startsWith("-") || s.startsWith("+") ? s.charAt(0) : "";
|
|
271
271
|
const digits2 = sign ? s.slice(1) : s;
|
|
272
272
|
return sign + digits2.padStart(width - sign.length, "0");
|
|
273
273
|
},
|
|
@@ -373,4 +373,3 @@ export {
|
|
|
373
373
|
capWords,
|
|
374
374
|
string
|
|
375
375
|
};
|
|
376
|
-
//# sourceMappingURL=chunk-CEZSBJJV.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
__export
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-MLKGABMK.js";
|
|
4
4
|
|
|
5
5
|
// src/collections.ts
|
|
6
6
|
var collections_exports = {};
|
|
@@ -214,4 +214,3 @@ export {
|
|
|
214
214
|
collections_exports
|
|
215
215
|
};
|
|
216
216
|
/* v8 ignore next -- getter properties on Map fail with proxy receiver @preserve */
|
|
217
|
-
//# sourceMappingURL=chunk-TAYRRHJ3.js.map
|