grammy 1.18.0 → 1.18.1
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/out/web.mjs +463 -455
- package/package.json +1 -1
package/out/web.mjs
CHANGED
|
@@ -373,6 +373,9 @@ const checker = {
|
|
|
373
373
|
}
|
|
374
374
|
};
|
|
375
375
|
class Context {
|
|
376
|
+
update;
|
|
377
|
+
api;
|
|
378
|
+
me;
|
|
376
379
|
match;
|
|
377
380
|
constructor(update, api, me){
|
|
378
381
|
this.update = update;
|
|
@@ -763,9 +766,6 @@ class Context {
|
|
|
763
766
|
replyWithGame(game_short_name, other, signal) {
|
|
764
767
|
return this.api.sendGame(orThrow(this.chat, "sendGame").id, game_short_name, other, signal);
|
|
765
768
|
}
|
|
766
|
-
update;
|
|
767
|
-
api;
|
|
768
|
-
me;
|
|
769
769
|
}
|
|
770
770
|
function orThrow(value, method) {
|
|
771
771
|
if (value === undefined) {
|
|
@@ -792,6 +792,8 @@ function toArray(e) {
|
|
|
792
792
|
];
|
|
793
793
|
}
|
|
794
794
|
class BotError extends Error {
|
|
795
|
+
error;
|
|
796
|
+
ctx;
|
|
795
797
|
constructor(error, ctx){
|
|
796
798
|
super(generateBotErrorMessage(error));
|
|
797
799
|
this.error = error;
|
|
@@ -799,8 +801,6 @@ class BotError extends Error {
|
|
|
799
801
|
this.name = "BotError";
|
|
800
802
|
if (error instanceof Error) this.stack = error.stack;
|
|
801
803
|
}
|
|
802
|
-
error;
|
|
803
|
-
ctx;
|
|
804
804
|
}
|
|
805
805
|
function generateBotErrorMessage(error) {
|
|
806
806
|
let msg;
|
|
@@ -1574,15 +1574,15 @@ browser$1.log;
|
|
|
1574
1574
|
browser$1.save;
|
|
1575
1575
|
browser$1.storage;
|
|
1576
1576
|
browser$1.useColors;
|
|
1577
|
-
class
|
|
1577
|
+
class AssertionError extends Error {
|
|
1578
|
+
name = "AssertionError";
|
|
1578
1579
|
constructor(message){
|
|
1579
1580
|
super(message);
|
|
1580
|
-
this.name = "DenoStdInternalError";
|
|
1581
1581
|
}
|
|
1582
1582
|
}
|
|
1583
1583
|
function assert(expr, msg = "") {
|
|
1584
1584
|
if (!expr) {
|
|
1585
|
-
throw new
|
|
1585
|
+
throw new AssertionError(msg);
|
|
1586
1586
|
}
|
|
1587
1587
|
}
|
|
1588
1588
|
function copy(src, dst, off = 0) {
|
|
@@ -1670,27 +1670,27 @@ class Buffer1 {
|
|
|
1670
1670
|
assert(len <= this.#buf.buffer.byteLength);
|
|
1671
1671
|
this.#buf = new Uint8Array(this.#buf.buffer, 0, len);
|
|
1672
1672
|
}
|
|
1673
|
-
#grow(
|
|
1673
|
+
#grow(n) {
|
|
1674
1674
|
const m = this.length;
|
|
1675
1675
|
if (m === 0 && this.#off !== 0) {
|
|
1676
1676
|
this.reset();
|
|
1677
1677
|
}
|
|
1678
|
-
const i = this.#tryGrowByReslice(
|
|
1678
|
+
const i = this.#tryGrowByReslice(n);
|
|
1679
1679
|
if (i >= 0) {
|
|
1680
1680
|
return i;
|
|
1681
1681
|
}
|
|
1682
1682
|
const c = this.capacity;
|
|
1683
|
-
if (
|
|
1683
|
+
if (n <= Math.floor(c / 2) - m) {
|
|
1684
1684
|
copy(this.#buf.subarray(this.#off), this.#buf);
|
|
1685
|
-
} else if (c +
|
|
1685
|
+
} else if (c + n > MAX_SIZE) {
|
|
1686
1686
|
throw new Error("The buffer cannot be grown beyond the maximum size.");
|
|
1687
1687
|
} else {
|
|
1688
|
-
const buf = new Uint8Array(Math.min(2 * c +
|
|
1688
|
+
const buf = new Uint8Array(Math.min(2 * c + n, MAX_SIZE));
|
|
1689
1689
|
copy(this.#buf.subarray(this.#off), buf);
|
|
1690
1690
|
this.#buf = buf;
|
|
1691
1691
|
}
|
|
1692
1692
|
this.#off = 0;
|
|
1693
|
-
this.#reslice(Math.min(m +
|
|
1693
|
+
this.#reslice(Math.min(m + n, MAX_SIZE));
|
|
1694
1694
|
return m;
|
|
1695
1695
|
}
|
|
1696
1696
|
grow(n) {
|
|
@@ -1911,6 +1911,8 @@ function readableStreamFromIterable(iterable) {
|
|
|
1911
1911
|
const baseFetchConfig = (_apiRoot)=>({});
|
|
1912
1912
|
const defaultAdapter = "cloudflare";
|
|
1913
1913
|
class GrammyError extends Error {
|
|
1914
|
+
method;
|
|
1915
|
+
payload;
|
|
1914
1916
|
ok;
|
|
1915
1917
|
error_code;
|
|
1916
1918
|
description;
|
|
@@ -1925,19 +1927,17 @@ class GrammyError extends Error {
|
|
|
1925
1927
|
this.description = err.description;
|
|
1926
1928
|
this.parameters = err.parameters ?? {};
|
|
1927
1929
|
}
|
|
1928
|
-
method;
|
|
1929
|
-
payload;
|
|
1930
1930
|
}
|
|
1931
1931
|
function toGrammyError(err, method, payload) {
|
|
1932
1932
|
return new GrammyError(`Call to '${method}' failed!`, err, method, payload);
|
|
1933
1933
|
}
|
|
1934
1934
|
class HttpError extends Error {
|
|
1935
|
+
error;
|
|
1935
1936
|
constructor(message, error){
|
|
1936
1937
|
super(message);
|
|
1937
1938
|
this.error = error;
|
|
1938
1939
|
this.name = "HttpError";
|
|
1939
1940
|
}
|
|
1940
|
-
error;
|
|
1941
1941
|
}
|
|
1942
1942
|
function isTelegramError(err) {
|
|
1943
1943
|
return typeof err === "object" && err !== null && "status" in err && "statusText" in err;
|
|
@@ -2030,43 +2030,6 @@ function normalizeString(path, allowAboveRoot, separator, isPathSeparator) {
|
|
|
2030
2030
|
}
|
|
2031
2031
|
return res;
|
|
2032
2032
|
}
|
|
2033
|
-
function _format(sep, pathObject) {
|
|
2034
|
-
const dir = pathObject.dir || pathObject.root;
|
|
2035
|
-
const base = pathObject.base || (pathObject.name || "") + (pathObject.ext || "");
|
|
2036
|
-
if (!dir) return base;
|
|
2037
|
-
if (base === sep) return dir;
|
|
2038
|
-
if (dir === pathObject.root) return dir + base;
|
|
2039
|
-
return dir + sep + base;
|
|
2040
|
-
}
|
|
2041
|
-
const WHITESPACE_ENCODINGS = {
|
|
2042
|
-
"\u0009": "%09",
|
|
2043
|
-
"\u000A": "%0A",
|
|
2044
|
-
"\u000B": "%0B",
|
|
2045
|
-
"\u000C": "%0C",
|
|
2046
|
-
"\u000D": "%0D",
|
|
2047
|
-
"\u0020": "%20"
|
|
2048
|
-
};
|
|
2049
|
-
function encodeWhitespace(string) {
|
|
2050
|
-
return string.replaceAll(/[\s]/g, (c)=>{
|
|
2051
|
-
return WHITESPACE_ENCODINGS[c] ?? c;
|
|
2052
|
-
});
|
|
2053
|
-
}
|
|
2054
|
-
function lastPathSegment(path, isSep, start = 0) {
|
|
2055
|
-
let matchedNonSeparator = false;
|
|
2056
|
-
let end = path.length;
|
|
2057
|
-
for(let i = path.length - 1; i >= start; --i){
|
|
2058
|
-
if (isSep(path.charCodeAt(i))) {
|
|
2059
|
-
if (matchedNonSeparator) {
|
|
2060
|
-
start = i + 1;
|
|
2061
|
-
break;
|
|
2062
|
-
}
|
|
2063
|
-
} else if (!matchedNonSeparator) {
|
|
2064
|
-
matchedNonSeparator = true;
|
|
2065
|
-
end = i + 1;
|
|
2066
|
-
}
|
|
2067
|
-
}
|
|
2068
|
-
return path.slice(start, end);
|
|
2069
|
-
}
|
|
2070
2033
|
function stripTrailingSeparators(segment, isSep) {
|
|
2071
2034
|
if (segment.length <= 1) {
|
|
2072
2035
|
return segment;
|
|
@@ -2081,21 +2044,34 @@ function stripTrailingSeparators(segment, isSep) {
|
|
|
2081
2044
|
}
|
|
2082
2045
|
return segment.slice(0, end);
|
|
2083
2046
|
}
|
|
2084
|
-
function
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2047
|
+
function posixResolve(...pathSegments) {
|
|
2048
|
+
let resolvedPath = "";
|
|
2049
|
+
let resolvedAbsolute = false;
|
|
2050
|
+
for(let i = pathSegments.length - 1; i >= -1 && !resolvedAbsolute; i--){
|
|
2051
|
+
let path;
|
|
2052
|
+
if (i >= 0) path = pathSegments[i];
|
|
2053
|
+
else {
|
|
2054
|
+
const { Deno } = globalThis;
|
|
2055
|
+
if (typeof Deno?.cwd !== "function") {
|
|
2056
|
+
throw new TypeError("Resolved a relative path without a CWD.");
|
|
2057
|
+
}
|
|
2058
|
+
path = Deno.cwd();
|
|
2059
|
+
}
|
|
2060
|
+
assertPath(path);
|
|
2061
|
+
if (path.length === 0) {
|
|
2062
|
+
continue;
|
|
2092
2063
|
}
|
|
2064
|
+
resolvedPath = `${path}/${resolvedPath}`;
|
|
2065
|
+
resolvedAbsolute = isPosixPathSeparator(path.charCodeAt(0));
|
|
2093
2066
|
}
|
|
2094
|
-
|
|
2067
|
+
resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute, "/", isPosixPathSeparator);
|
|
2068
|
+
if (resolvedAbsolute) {
|
|
2069
|
+
if (resolvedPath.length > 0) return `/${resolvedPath}`;
|
|
2070
|
+
else return "/";
|
|
2071
|
+
} else if (resolvedPath.length > 0) return resolvedPath;
|
|
2072
|
+
else return ".";
|
|
2095
2073
|
}
|
|
2096
|
-
|
|
2097
|
-
const delimiter = ";";
|
|
2098
|
-
function resolve(...pathSegments) {
|
|
2074
|
+
function windowsResolve(...pathSegments) {
|
|
2099
2075
|
let resolvedDevice = "";
|
|
2100
2076
|
let resolvedTail = "";
|
|
2101
2077
|
let resolvedAbsolute = false;
|
|
@@ -2188,10 +2164,23 @@ function resolve(...pathSegments) {
|
|
|
2188
2164
|
resolvedTail = normalizeString(resolvedTail, !resolvedAbsolute, "\\", isPathSeparator);
|
|
2189
2165
|
return resolvedDevice + (resolvedAbsolute ? "\\" : "") + resolvedTail || ".";
|
|
2190
2166
|
}
|
|
2191
|
-
function
|
|
2167
|
+
function assertArg(path) {
|
|
2192
2168
|
assertPath(path);
|
|
2169
|
+
if (path.length === 0) return ".";
|
|
2170
|
+
}
|
|
2171
|
+
function posixNormalize(path) {
|
|
2172
|
+
assertArg(path);
|
|
2173
|
+
const isAbsolute = isPosixPathSeparator(path.charCodeAt(0));
|
|
2174
|
+
const trailingSeparator = isPosixPathSeparator(path.charCodeAt(path.length - 1));
|
|
2175
|
+
path = normalizeString(path, !isAbsolute, "/", isPosixPathSeparator);
|
|
2176
|
+
if (path.length === 0 && !isAbsolute) path = ".";
|
|
2177
|
+
if (path.length > 0 && trailingSeparator) path += "/";
|
|
2178
|
+
if (isAbsolute) return `/${path}`;
|
|
2179
|
+
return path;
|
|
2180
|
+
}
|
|
2181
|
+
function windowsNormalize(path) {
|
|
2182
|
+
assertArg(path);
|
|
2193
2183
|
const len = path.length;
|
|
2194
|
-
if (len === 0) return ".";
|
|
2195
2184
|
let rootEnd = 0;
|
|
2196
2185
|
let device;
|
|
2197
2186
|
let isAbsolute = false;
|
|
@@ -2270,7 +2259,7 @@ function normalize(path) {
|
|
|
2270
2259
|
return device;
|
|
2271
2260
|
}
|
|
2272
2261
|
}
|
|
2273
|
-
function
|
|
2262
|
+
function windowsIsAbsolute(path) {
|
|
2274
2263
|
assertPath(path);
|
|
2275
2264
|
const len = path.length;
|
|
2276
2265
|
if (len === 0) return false;
|
|
@@ -2284,12 +2273,29 @@ function isAbsolute(path) {
|
|
|
2284
2273
|
}
|
|
2285
2274
|
return false;
|
|
2286
2275
|
}
|
|
2287
|
-
function
|
|
2288
|
-
|
|
2289
|
-
|
|
2276
|
+
function posixIsAbsolute(path) {
|
|
2277
|
+
assertPath(path);
|
|
2278
|
+
return path.length > 0 && isPosixPathSeparator(path.charCodeAt(0));
|
|
2279
|
+
}
|
|
2280
|
+
function posixJoin(...paths) {
|
|
2281
|
+
if (paths.length === 0) return ".";
|
|
2282
|
+
let joined;
|
|
2283
|
+
for(let i = 0, len = paths.length; i < len; ++i){
|
|
2284
|
+
const path = paths[i];
|
|
2285
|
+
assertPath(path);
|
|
2286
|
+
if (path.length > 0) {
|
|
2287
|
+
if (!joined) joined = path;
|
|
2288
|
+
else joined += `/${path}`;
|
|
2289
|
+
}
|
|
2290
|
+
}
|
|
2291
|
+
if (!joined) return ".";
|
|
2292
|
+
return posixNormalize(joined);
|
|
2293
|
+
}
|
|
2294
|
+
function windowsJoin(...paths) {
|
|
2295
|
+
if (paths.length === 0) return ".";
|
|
2290
2296
|
let joined;
|
|
2291
2297
|
let firstPart = null;
|
|
2292
|
-
for(let i = 0; i <
|
|
2298
|
+
for(let i = 0; i < paths.length; ++i){
|
|
2293
2299
|
const path = paths[i];
|
|
2294
2300
|
assertPath(path);
|
|
2295
2301
|
if (path.length > 0) {
|
|
@@ -2322,14 +2328,73 @@ function join(...paths) {
|
|
|
2322
2328
|
}
|
|
2323
2329
|
if (slashCount >= 2) joined = `\\${joined.slice(slashCount)}`;
|
|
2324
2330
|
}
|
|
2325
|
-
return
|
|
2331
|
+
return windowsNormalize(joined);
|
|
2326
2332
|
}
|
|
2327
|
-
function
|
|
2333
|
+
function assertArgs(from, to) {
|
|
2328
2334
|
assertPath(from);
|
|
2329
2335
|
assertPath(to);
|
|
2330
2336
|
if (from === to) return "";
|
|
2331
|
-
|
|
2332
|
-
|
|
2337
|
+
}
|
|
2338
|
+
function posixRelative(from, to) {
|
|
2339
|
+
assertArgs(from, to);
|
|
2340
|
+
from = posixResolve(from);
|
|
2341
|
+
to = posixResolve(to);
|
|
2342
|
+
if (from === to) return "";
|
|
2343
|
+
let fromStart = 1;
|
|
2344
|
+
const fromEnd = from.length;
|
|
2345
|
+
for(; fromStart < fromEnd; ++fromStart){
|
|
2346
|
+
if (!isPosixPathSeparator(from.charCodeAt(fromStart))) break;
|
|
2347
|
+
}
|
|
2348
|
+
const fromLen = fromEnd - fromStart;
|
|
2349
|
+
let toStart = 1;
|
|
2350
|
+
const toEnd = to.length;
|
|
2351
|
+
for(; toStart < toEnd; ++toStart){
|
|
2352
|
+
if (!isPosixPathSeparator(to.charCodeAt(toStart))) break;
|
|
2353
|
+
}
|
|
2354
|
+
const toLen = toEnd - toStart;
|
|
2355
|
+
const length = fromLen < toLen ? fromLen : toLen;
|
|
2356
|
+
let lastCommonSep = -1;
|
|
2357
|
+
let i = 0;
|
|
2358
|
+
for(; i <= length; ++i){
|
|
2359
|
+
if (i === length) {
|
|
2360
|
+
if (toLen > length) {
|
|
2361
|
+
if (isPosixPathSeparator(to.charCodeAt(toStart + i))) {
|
|
2362
|
+
return to.slice(toStart + i + 1);
|
|
2363
|
+
} else if (i === 0) {
|
|
2364
|
+
return to.slice(toStart + i);
|
|
2365
|
+
}
|
|
2366
|
+
} else if (fromLen > length) {
|
|
2367
|
+
if (isPosixPathSeparator(from.charCodeAt(fromStart + i))) {
|
|
2368
|
+
lastCommonSep = i;
|
|
2369
|
+
} else if (i === 0) {
|
|
2370
|
+
lastCommonSep = 0;
|
|
2371
|
+
}
|
|
2372
|
+
}
|
|
2373
|
+
break;
|
|
2374
|
+
}
|
|
2375
|
+
const fromCode = from.charCodeAt(fromStart + i);
|
|
2376
|
+
const toCode = to.charCodeAt(toStart + i);
|
|
2377
|
+
if (fromCode !== toCode) break;
|
|
2378
|
+
else if (isPosixPathSeparator(fromCode)) lastCommonSep = i;
|
|
2379
|
+
}
|
|
2380
|
+
let out = "";
|
|
2381
|
+
for(i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i){
|
|
2382
|
+
if (i === fromEnd || isPosixPathSeparator(from.charCodeAt(i))) {
|
|
2383
|
+
if (out.length === 0) out += "..";
|
|
2384
|
+
else out += "/..";
|
|
2385
|
+
}
|
|
2386
|
+
}
|
|
2387
|
+
if (out.length > 0) return out + to.slice(toStart + lastCommonSep);
|
|
2388
|
+
else {
|
|
2389
|
+
toStart += lastCommonSep;
|
|
2390
|
+
if (isPosixPathSeparator(to.charCodeAt(toStart))) ++toStart;
|
|
2391
|
+
return to.slice(toStart);
|
|
2392
|
+
}
|
|
2393
|
+
}
|
|
2394
|
+
function windowsRelative(from, to) {
|
|
2395
|
+
assertArgs(from, to);
|
|
2396
|
+
const fromOrig = windowsResolve(from);
|
|
2397
|
+
const toOrig = windowsResolve(to);
|
|
2333
2398
|
if (fromOrig === toOrig) return "";
|
|
2334
2399
|
from = fromOrig.toLowerCase();
|
|
2335
2400
|
to = toOrig.toLowerCase();
|
|
@@ -2397,10 +2462,13 @@ function relative(from, to) {
|
|
|
2397
2462
|
return toOrig.slice(toStart, toEnd);
|
|
2398
2463
|
}
|
|
2399
2464
|
}
|
|
2400
|
-
function
|
|
2465
|
+
function posixToNamespacedPath(path) {
|
|
2466
|
+
return path;
|
|
2467
|
+
}
|
|
2468
|
+
function windowsToNamespacedPath(path) {
|
|
2401
2469
|
if (typeof path !== "string") return path;
|
|
2402
2470
|
if (path.length === 0) return "";
|
|
2403
|
-
const resolvedPath =
|
|
2471
|
+
const resolvedPath = windowsResolve(path);
|
|
2404
2472
|
if (resolvedPath.length >= 3) {
|
|
2405
2473
|
if (resolvedPath.charCodeAt(0) === 92) {
|
|
2406
2474
|
if (resolvedPath.charCodeAt(1) === 92) {
|
|
@@ -2417,10 +2485,32 @@ function toNamespacedPath(path) {
|
|
|
2417
2485
|
}
|
|
2418
2486
|
return path;
|
|
2419
2487
|
}
|
|
2420
|
-
function
|
|
2488
|
+
function assertArg1(path) {
|
|
2421
2489
|
assertPath(path);
|
|
2490
|
+
if (path.length === 0) return ".";
|
|
2491
|
+
}
|
|
2492
|
+
function posixDirname(path) {
|
|
2493
|
+
assertArg1(path);
|
|
2494
|
+
let end = -1;
|
|
2495
|
+
let matchedNonSeparator = false;
|
|
2496
|
+
for(let i = path.length - 1; i >= 1; --i){
|
|
2497
|
+
if (isPosixPathSeparator(path.charCodeAt(i))) {
|
|
2498
|
+
if (matchedNonSeparator) {
|
|
2499
|
+
end = i;
|
|
2500
|
+
break;
|
|
2501
|
+
}
|
|
2502
|
+
} else {
|
|
2503
|
+
matchedNonSeparator = true;
|
|
2504
|
+
}
|
|
2505
|
+
}
|
|
2506
|
+
if (end === -1) {
|
|
2507
|
+
return isPosixPathSeparator(path.charCodeAt(0)) ? "/" : ".";
|
|
2508
|
+
}
|
|
2509
|
+
return stripTrailingSeparators(path.slice(0, end), isPosixPathSeparator);
|
|
2510
|
+
}
|
|
2511
|
+
function windowsDirname(path) {
|
|
2512
|
+
assertArg1(path);
|
|
2422
2513
|
const len = path.length;
|
|
2423
|
-
if (len === 0) return ".";
|
|
2424
2514
|
let rootEnd = -1;
|
|
2425
2515
|
let end = -1;
|
|
2426
2516
|
let matchedSlash = true;
|
|
@@ -2479,364 +2569,63 @@ function dirname(path) {
|
|
|
2479
2569
|
if (rootEnd === -1) return ".";
|
|
2480
2570
|
else end = rootEnd;
|
|
2481
2571
|
}
|
|
2482
|
-
return stripTrailingSeparators(path.slice(0, end), isPosixPathSeparator);
|
|
2483
|
-
}
|
|
2484
|
-
function basename(path, suffix = "") {
|
|
2485
|
-
assertPath(path);
|
|
2486
|
-
if (path.length === 0) return path;
|
|
2487
|
-
if (typeof suffix !== "string") {
|
|
2488
|
-
throw new TypeError(`Suffix must be a string. Received ${JSON.stringify(suffix)}`);
|
|
2489
|
-
}
|
|
2490
|
-
let start = 0;
|
|
2491
|
-
if (path.length >= 2) {
|
|
2492
|
-
const drive = path.charCodeAt(0);
|
|
2493
|
-
if (isWindowsDeviceRoot(drive)) {
|
|
2494
|
-
if (path.charCodeAt(1) === 58) start = 2;
|
|
2495
|
-
}
|
|
2496
|
-
}
|
|
2497
|
-
const lastSegment = lastPathSegment(path, isPathSeparator, start);
|
|
2498
|
-
const strippedSegment = stripTrailingSeparators(lastSegment, isPathSeparator);
|
|
2499
|
-
return suffix ? stripSuffix(strippedSegment, suffix) : strippedSegment;
|
|
2500
|
-
}
|
|
2501
|
-
function extname(path) {
|
|
2502
|
-
assertPath(path);
|
|
2503
|
-
let start = 0;
|
|
2504
|
-
let startDot = -1;
|
|
2505
|
-
let startPart = 0;
|
|
2506
|
-
let end = -1;
|
|
2507
|
-
let matchedSlash = true;
|
|
2508
|
-
let preDotState = 0;
|
|
2509
|
-
if (path.length >= 2 && path.charCodeAt(1) === 58 && isWindowsDeviceRoot(path.charCodeAt(0))) {
|
|
2510
|
-
start = startPart = 2;
|
|
2511
|
-
}
|
|
2512
|
-
for(let i = path.length - 1; i >= start; --i){
|
|
2513
|
-
const code = path.charCodeAt(i);
|
|
2514
|
-
if (isPathSeparator(code)) {
|
|
2515
|
-
if (!matchedSlash) {
|
|
2516
|
-
startPart = i + 1;
|
|
2517
|
-
break;
|
|
2518
|
-
}
|
|
2519
|
-
continue;
|
|
2520
|
-
}
|
|
2521
|
-
if (end === -1) {
|
|
2522
|
-
matchedSlash = false;
|
|
2523
|
-
end = i + 1;
|
|
2524
|
-
}
|
|
2525
|
-
if (code === 46) {
|
|
2526
|
-
if (startDot === -1) startDot = i;
|
|
2527
|
-
else if (preDotState !== 1) preDotState = 1;
|
|
2528
|
-
} else if (startDot !== -1) {
|
|
2529
|
-
preDotState = -1;
|
|
2530
|
-
}
|
|
2531
|
-
}
|
|
2532
|
-
if (startDot === -1 || end === -1 || preDotState === 0 || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
|
|
2533
|
-
return "";
|
|
2534
|
-
}
|
|
2535
|
-
return path.slice(startDot, end);
|
|
2536
|
-
}
|
|
2537
|
-
function format(pathObject) {
|
|
2538
|
-
if (pathObject === null || typeof pathObject !== "object") {
|
|
2539
|
-
throw new TypeError(`The "pathObject" argument must be of type Object. Received type ${typeof pathObject}`);
|
|
2540
|
-
}
|
|
2541
|
-
return _format("\\", pathObject);
|
|
2542
|
-
}
|
|
2543
|
-
function parse2(path) {
|
|
2544
|
-
assertPath(path);
|
|
2545
|
-
const ret = {
|
|
2546
|
-
root: "",
|
|
2547
|
-
dir: "",
|
|
2548
|
-
base: "",
|
|
2549
|
-
ext: "",
|
|
2550
|
-
name: ""
|
|
2551
|
-
};
|
|
2552
|
-
const len = path.length;
|
|
2553
|
-
if (len === 0) return ret;
|
|
2554
|
-
let rootEnd = 0;
|
|
2555
|
-
let code = path.charCodeAt(0);
|
|
2556
|
-
if (len > 1) {
|
|
2557
|
-
if (isPathSeparator(code)) {
|
|
2558
|
-
rootEnd = 1;
|
|
2559
|
-
if (isPathSeparator(path.charCodeAt(1))) {
|
|
2560
|
-
let j = 2;
|
|
2561
|
-
let last = j;
|
|
2562
|
-
for(; j < len; ++j){
|
|
2563
|
-
if (isPathSeparator(path.charCodeAt(j))) break;
|
|
2564
|
-
}
|
|
2565
|
-
if (j < len && j !== last) {
|
|
2566
|
-
last = j;
|
|
2567
|
-
for(; j < len; ++j){
|
|
2568
|
-
if (!isPathSeparator(path.charCodeAt(j))) break;
|
|
2569
|
-
}
|
|
2570
|
-
if (j < len && j !== last) {
|
|
2571
|
-
last = j;
|
|
2572
|
-
for(; j < len; ++j){
|
|
2573
|
-
if (isPathSeparator(path.charCodeAt(j))) break;
|
|
2574
|
-
}
|
|
2575
|
-
if (j === len) {
|
|
2576
|
-
rootEnd = j;
|
|
2577
|
-
} else if (j !== last) {
|
|
2578
|
-
rootEnd = j + 1;
|
|
2579
|
-
}
|
|
2580
|
-
}
|
|
2581
|
-
}
|
|
2582
|
-
}
|
|
2583
|
-
} else if (isWindowsDeviceRoot(code)) {
|
|
2584
|
-
if (path.charCodeAt(1) === 58) {
|
|
2585
|
-
rootEnd = 2;
|
|
2586
|
-
if (len > 2) {
|
|
2587
|
-
if (isPathSeparator(path.charCodeAt(2))) {
|
|
2588
|
-
if (len === 3) {
|
|
2589
|
-
ret.root = ret.dir = path;
|
|
2590
|
-
ret.base = "\\";
|
|
2591
|
-
return ret;
|
|
2592
|
-
}
|
|
2593
|
-
rootEnd = 3;
|
|
2594
|
-
}
|
|
2595
|
-
} else {
|
|
2596
|
-
ret.root = ret.dir = path;
|
|
2597
|
-
return ret;
|
|
2598
|
-
}
|
|
2599
|
-
}
|
|
2600
|
-
}
|
|
2601
|
-
} else if (isPathSeparator(code)) {
|
|
2602
|
-
ret.root = ret.dir = path;
|
|
2603
|
-
ret.base = "\\";
|
|
2604
|
-
return ret;
|
|
2605
|
-
}
|
|
2606
|
-
if (rootEnd > 0) ret.root = path.slice(0, rootEnd);
|
|
2607
|
-
let startDot = -1;
|
|
2608
|
-
let startPart = rootEnd;
|
|
2609
|
-
let end = -1;
|
|
2610
|
-
let matchedSlash = true;
|
|
2611
|
-
let i = path.length - 1;
|
|
2612
|
-
let preDotState = 0;
|
|
2613
|
-
for(; i >= rootEnd; --i){
|
|
2614
|
-
code = path.charCodeAt(i);
|
|
2615
|
-
if (isPathSeparator(code)) {
|
|
2616
|
-
if (!matchedSlash) {
|
|
2617
|
-
startPart = i + 1;
|
|
2618
|
-
break;
|
|
2619
|
-
}
|
|
2620
|
-
continue;
|
|
2621
|
-
}
|
|
2622
|
-
if (end === -1) {
|
|
2623
|
-
matchedSlash = false;
|
|
2624
|
-
end = i + 1;
|
|
2625
|
-
}
|
|
2626
|
-
if (code === 46) {
|
|
2627
|
-
if (startDot === -1) startDot = i;
|
|
2628
|
-
else if (preDotState !== 1) preDotState = 1;
|
|
2629
|
-
} else if (startDot !== -1) {
|
|
2630
|
-
preDotState = -1;
|
|
2631
|
-
}
|
|
2632
|
-
}
|
|
2633
|
-
if (startDot === -1 || end === -1 || preDotState === 0 || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
|
|
2634
|
-
if (end !== -1) {
|
|
2635
|
-
ret.base = ret.name = path.slice(startPart, end);
|
|
2636
|
-
}
|
|
2637
|
-
} else {
|
|
2638
|
-
ret.name = path.slice(startPart, startDot);
|
|
2639
|
-
ret.base = path.slice(startPart, end);
|
|
2640
|
-
ret.ext = path.slice(startDot, end);
|
|
2641
|
-
}
|
|
2642
|
-
ret.base = ret.base || "\\";
|
|
2643
|
-
if (startPart > 0 && startPart !== rootEnd) {
|
|
2644
|
-
ret.dir = path.slice(0, startPart - 1);
|
|
2645
|
-
} else ret.dir = ret.root;
|
|
2646
|
-
return ret;
|
|
2647
|
-
}
|
|
2648
|
-
function fromFileUrl(url) {
|
|
2649
|
-
url = url instanceof URL ? url : new URL(url);
|
|
2650
|
-
if (url.protocol != "file:") {
|
|
2651
|
-
throw new TypeError("Must be a file URL.");
|
|
2652
|
-
}
|
|
2653
|
-
let path = decodeURIComponent(url.pathname.replace(/\//g, "\\").replace(/%(?![0-9A-Fa-f]{2})/g, "%25")).replace(/^\\*([A-Za-z]:)(\\|$)/, "$1\\");
|
|
2654
|
-
if (url.hostname != "") {
|
|
2655
|
-
path = `\\\\${url.hostname}${path}`;
|
|
2656
|
-
}
|
|
2657
|
-
return path;
|
|
2658
|
-
}
|
|
2659
|
-
function toFileUrl(path) {
|
|
2660
|
-
if (!isAbsolute(path)) {
|
|
2661
|
-
throw new TypeError("Must be an absolute path.");
|
|
2662
|
-
}
|
|
2663
|
-
const [, hostname, pathname] = path.match(/^(?:[/\\]{2}([^/\\]+)(?=[/\\](?:[^/\\]|$)))?(.*)/);
|
|
2664
|
-
const url = new URL("file:///");
|
|
2665
|
-
url.pathname = encodeWhitespace(pathname.replace(/%/g, "%25"));
|
|
2666
|
-
if (hostname != null && hostname != "localhost") {
|
|
2667
|
-
url.hostname = hostname;
|
|
2668
|
-
if (!url.hostname) {
|
|
2669
|
-
throw new TypeError("Invalid hostname.");
|
|
2670
|
-
}
|
|
2671
|
-
}
|
|
2672
|
-
return url;
|
|
2673
|
-
}
|
|
2674
|
-
const mod = {
|
|
2675
|
-
sep: sep,
|
|
2676
|
-
delimiter: delimiter,
|
|
2677
|
-
resolve: resolve,
|
|
2678
|
-
normalize: normalize,
|
|
2679
|
-
isAbsolute: isAbsolute,
|
|
2680
|
-
join: join,
|
|
2681
|
-
relative: relative,
|
|
2682
|
-
toNamespacedPath: toNamespacedPath,
|
|
2683
|
-
dirname: dirname,
|
|
2684
|
-
basename: basename,
|
|
2685
|
-
extname: extname,
|
|
2686
|
-
format: format,
|
|
2687
|
-
parse: parse2,
|
|
2688
|
-
fromFileUrl: fromFileUrl,
|
|
2689
|
-
toFileUrl: toFileUrl
|
|
2690
|
-
};
|
|
2691
|
-
const sep1 = "/";
|
|
2692
|
-
const delimiter1 = ":";
|
|
2693
|
-
function resolve1(...pathSegments) {
|
|
2694
|
-
let resolvedPath = "";
|
|
2695
|
-
let resolvedAbsolute = false;
|
|
2696
|
-
for(let i = pathSegments.length - 1; i >= -1 && !resolvedAbsolute; i--){
|
|
2697
|
-
let path;
|
|
2698
|
-
if (i >= 0) path = pathSegments[i];
|
|
2699
|
-
else {
|
|
2700
|
-
const { Deno } = globalThis;
|
|
2701
|
-
if (typeof Deno?.cwd !== "function") {
|
|
2702
|
-
throw new TypeError("Resolved a relative path without a CWD.");
|
|
2703
|
-
}
|
|
2704
|
-
path = Deno.cwd();
|
|
2705
|
-
}
|
|
2706
|
-
assertPath(path);
|
|
2707
|
-
if (path.length === 0) {
|
|
2708
|
-
continue;
|
|
2709
|
-
}
|
|
2710
|
-
resolvedPath = `${path}/${resolvedPath}`;
|
|
2711
|
-
resolvedAbsolute = isPosixPathSeparator(path.charCodeAt(0));
|
|
2712
|
-
}
|
|
2713
|
-
resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute, "/", isPosixPathSeparator);
|
|
2714
|
-
if (resolvedAbsolute) {
|
|
2715
|
-
if (resolvedPath.length > 0) return `/${resolvedPath}`;
|
|
2716
|
-
else return "/";
|
|
2717
|
-
} else if (resolvedPath.length > 0) return resolvedPath;
|
|
2718
|
-
else return ".";
|
|
2719
|
-
}
|
|
2720
|
-
function normalize1(path) {
|
|
2721
|
-
assertPath(path);
|
|
2722
|
-
if (path.length === 0) return ".";
|
|
2723
|
-
const isAbsolute = isPosixPathSeparator(path.charCodeAt(0));
|
|
2724
|
-
const trailingSeparator = isPosixPathSeparator(path.charCodeAt(path.length - 1));
|
|
2725
|
-
path = normalizeString(path, !isAbsolute, "/", isPosixPathSeparator);
|
|
2726
|
-
if (path.length === 0 && !isAbsolute) path = ".";
|
|
2727
|
-
if (path.length > 0 && trailingSeparator) path += "/";
|
|
2728
|
-
if (isAbsolute) return `/${path}`;
|
|
2729
|
-
return path;
|
|
2730
|
-
}
|
|
2731
|
-
function isAbsolute1(path) {
|
|
2732
|
-
assertPath(path);
|
|
2733
|
-
return path.length > 0 && isPosixPathSeparator(path.charCodeAt(0));
|
|
2734
|
-
}
|
|
2735
|
-
function join1(...paths) {
|
|
2736
|
-
if (paths.length === 0) return ".";
|
|
2737
|
-
let joined;
|
|
2738
|
-
for(let i = 0, len = paths.length; i < len; ++i){
|
|
2739
|
-
const path = paths[i];
|
|
2740
|
-
assertPath(path);
|
|
2741
|
-
if (path.length > 0) {
|
|
2742
|
-
if (!joined) joined = path;
|
|
2743
|
-
else joined += `/${path}`;
|
|
2744
|
-
}
|
|
2745
|
-
}
|
|
2746
|
-
if (!joined) return ".";
|
|
2747
|
-
return normalize1(joined);
|
|
2748
|
-
}
|
|
2749
|
-
function relative1(from, to) {
|
|
2750
|
-
assertPath(from);
|
|
2751
|
-
assertPath(to);
|
|
2752
|
-
if (from === to) return "";
|
|
2753
|
-
from = resolve1(from);
|
|
2754
|
-
to = resolve1(to);
|
|
2755
|
-
if (from === to) return "";
|
|
2756
|
-
let fromStart = 1;
|
|
2757
|
-
const fromEnd = from.length;
|
|
2758
|
-
for(; fromStart < fromEnd; ++fromStart){
|
|
2759
|
-
if (!isPosixPathSeparator(from.charCodeAt(fromStart))) break;
|
|
2760
|
-
}
|
|
2761
|
-
const fromLen = fromEnd - fromStart;
|
|
2762
|
-
let toStart = 1;
|
|
2763
|
-
const toEnd = to.length;
|
|
2764
|
-
for(; toStart < toEnd; ++toStart){
|
|
2765
|
-
if (!isPosixPathSeparator(to.charCodeAt(toStart))) break;
|
|
2766
|
-
}
|
|
2767
|
-
const toLen = toEnd - toStart;
|
|
2768
|
-
const length = fromLen < toLen ? fromLen : toLen;
|
|
2769
|
-
let lastCommonSep = -1;
|
|
2770
|
-
let i = 0;
|
|
2771
|
-
for(; i <= length; ++i){
|
|
2772
|
-
if (i === length) {
|
|
2773
|
-
if (toLen > length) {
|
|
2774
|
-
if (isPosixPathSeparator(to.charCodeAt(toStart + i))) {
|
|
2775
|
-
return to.slice(toStart + i + 1);
|
|
2776
|
-
} else if (i === 0) {
|
|
2777
|
-
return to.slice(toStart + i);
|
|
2778
|
-
}
|
|
2779
|
-
} else if (fromLen > length) {
|
|
2780
|
-
if (isPosixPathSeparator(from.charCodeAt(fromStart + i))) {
|
|
2781
|
-
lastCommonSep = i;
|
|
2782
|
-
} else if (i === 0) {
|
|
2783
|
-
lastCommonSep = 0;
|
|
2784
|
-
}
|
|
2785
|
-
}
|
|
2786
|
-
break;
|
|
2787
|
-
}
|
|
2788
|
-
const fromCode = from.charCodeAt(fromStart + i);
|
|
2789
|
-
const toCode = to.charCodeAt(toStart + i);
|
|
2790
|
-
if (fromCode !== toCode) break;
|
|
2791
|
-
else if (isPosixPathSeparator(fromCode)) lastCommonSep = i;
|
|
2792
|
-
}
|
|
2793
|
-
let out = "";
|
|
2794
|
-
for(i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i){
|
|
2795
|
-
if (i === fromEnd || isPosixPathSeparator(from.charCodeAt(i))) {
|
|
2796
|
-
if (out.length === 0) out += "..";
|
|
2797
|
-
else out += "/..";
|
|
2798
|
-
}
|
|
2799
|
-
}
|
|
2800
|
-
if (out.length > 0) return out + to.slice(toStart + lastCommonSep);
|
|
2801
|
-
else {
|
|
2802
|
-
toStart += lastCommonSep;
|
|
2803
|
-
if (isPosixPathSeparator(to.charCodeAt(toStart))) ++toStart;
|
|
2804
|
-
return to.slice(toStart);
|
|
2805
|
-
}
|
|
2572
|
+
return stripTrailingSeparators(path.slice(0, end), isPosixPathSeparator);
|
|
2806
2573
|
}
|
|
2807
|
-
function
|
|
2808
|
-
|
|
2574
|
+
function stripSuffix(name, suffix) {
|
|
2575
|
+
if (suffix.length >= name.length) {
|
|
2576
|
+
return name;
|
|
2577
|
+
}
|
|
2578
|
+
const lenDiff = name.length - suffix.length;
|
|
2579
|
+
for(let i = suffix.length - 1; i >= 0; --i){
|
|
2580
|
+
if (name.charCodeAt(lenDiff + i) !== suffix.charCodeAt(i)) {
|
|
2581
|
+
return name;
|
|
2582
|
+
}
|
|
2583
|
+
}
|
|
2584
|
+
return name.slice(0, -suffix.length);
|
|
2809
2585
|
}
|
|
2810
|
-
function
|
|
2811
|
-
if (path.length === 0) return ".";
|
|
2812
|
-
let end = -1;
|
|
2586
|
+
function lastPathSegment(path, isSep, start = 0) {
|
|
2813
2587
|
let matchedNonSeparator = false;
|
|
2814
|
-
|
|
2815
|
-
|
|
2588
|
+
let end = path.length;
|
|
2589
|
+
for(let i = path.length - 1; i >= start; --i){
|
|
2590
|
+
if (isSep(path.charCodeAt(i))) {
|
|
2816
2591
|
if (matchedNonSeparator) {
|
|
2817
|
-
|
|
2592
|
+
start = i + 1;
|
|
2818
2593
|
break;
|
|
2819
2594
|
}
|
|
2820
|
-
} else {
|
|
2595
|
+
} else if (!matchedNonSeparator) {
|
|
2821
2596
|
matchedNonSeparator = true;
|
|
2597
|
+
end = i + 1;
|
|
2822
2598
|
}
|
|
2823
2599
|
}
|
|
2824
|
-
|
|
2825
|
-
return isPosixPathSeparator(path.charCodeAt(0)) ? "/" : ".";
|
|
2826
|
-
}
|
|
2827
|
-
return stripTrailingSeparators(path.slice(0, end), isPosixPathSeparator);
|
|
2600
|
+
return path.slice(start, end);
|
|
2828
2601
|
}
|
|
2829
|
-
function
|
|
2602
|
+
function assertArgs1(path, suffix) {
|
|
2830
2603
|
assertPath(path);
|
|
2831
2604
|
if (path.length === 0) return path;
|
|
2832
2605
|
if (typeof suffix !== "string") {
|
|
2833
2606
|
throw new TypeError(`Suffix must be a string. Received ${JSON.stringify(suffix)}`);
|
|
2834
2607
|
}
|
|
2608
|
+
}
|
|
2609
|
+
function posixBasename(path, suffix = "") {
|
|
2610
|
+
assertArgs1(path, suffix);
|
|
2835
2611
|
const lastSegment = lastPathSegment(path, isPosixPathSeparator);
|
|
2836
2612
|
const strippedSegment = stripTrailingSeparators(lastSegment, isPosixPathSeparator);
|
|
2837
2613
|
return suffix ? stripSuffix(strippedSegment, suffix) : strippedSegment;
|
|
2838
2614
|
}
|
|
2839
|
-
function
|
|
2615
|
+
function windowsBasename(path, suffix = "") {
|
|
2616
|
+
assertArgs1(path, suffix);
|
|
2617
|
+
let start = 0;
|
|
2618
|
+
if (path.length >= 2) {
|
|
2619
|
+
const drive = path.charCodeAt(0);
|
|
2620
|
+
if (isWindowsDeviceRoot(drive)) {
|
|
2621
|
+
if (path.charCodeAt(1) === 58) start = 2;
|
|
2622
|
+
}
|
|
2623
|
+
}
|
|
2624
|
+
const lastSegment = lastPathSegment(path, isPathSeparator, start);
|
|
2625
|
+
const strippedSegment = stripTrailingSeparators(lastSegment, isPathSeparator);
|
|
2626
|
+
return suffix ? stripSuffix(strippedSegment, suffix) : strippedSegment;
|
|
2627
|
+
}
|
|
2628
|
+
function posixExtname(path) {
|
|
2840
2629
|
assertPath(path);
|
|
2841
2630
|
let startDot = -1;
|
|
2842
2631
|
let startPart = 0;
|
|
@@ -2868,13 +2657,64 @@ function extname1(path) {
|
|
|
2868
2657
|
}
|
|
2869
2658
|
return path.slice(startDot, end);
|
|
2870
2659
|
}
|
|
2871
|
-
function
|
|
2660
|
+
function windowsExtname(path) {
|
|
2661
|
+
assertPath(path);
|
|
2662
|
+
let start = 0;
|
|
2663
|
+
let startDot = -1;
|
|
2664
|
+
let startPart = 0;
|
|
2665
|
+
let end = -1;
|
|
2666
|
+
let matchedSlash = true;
|
|
2667
|
+
let preDotState = 0;
|
|
2668
|
+
if (path.length >= 2 && path.charCodeAt(1) === 58 && isWindowsDeviceRoot(path.charCodeAt(0))) {
|
|
2669
|
+
start = startPart = 2;
|
|
2670
|
+
}
|
|
2671
|
+
for(let i = path.length - 1; i >= start; --i){
|
|
2672
|
+
const code = path.charCodeAt(i);
|
|
2673
|
+
if (isPathSeparator(code)) {
|
|
2674
|
+
if (!matchedSlash) {
|
|
2675
|
+
startPart = i + 1;
|
|
2676
|
+
break;
|
|
2677
|
+
}
|
|
2678
|
+
continue;
|
|
2679
|
+
}
|
|
2680
|
+
if (end === -1) {
|
|
2681
|
+
matchedSlash = false;
|
|
2682
|
+
end = i + 1;
|
|
2683
|
+
}
|
|
2684
|
+
if (code === 46) {
|
|
2685
|
+
if (startDot === -1) startDot = i;
|
|
2686
|
+
else if (preDotState !== 1) preDotState = 1;
|
|
2687
|
+
} else if (startDot !== -1) {
|
|
2688
|
+
preDotState = -1;
|
|
2689
|
+
}
|
|
2690
|
+
}
|
|
2691
|
+
if (startDot === -1 || end === -1 || preDotState === 0 || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
|
|
2692
|
+
return "";
|
|
2693
|
+
}
|
|
2694
|
+
return path.slice(startDot, end);
|
|
2695
|
+
}
|
|
2696
|
+
function _format(sep, pathObject) {
|
|
2697
|
+
const dir = pathObject.dir || pathObject.root;
|
|
2698
|
+
const base = pathObject.base || (pathObject.name || "") + (pathObject.ext || "");
|
|
2699
|
+
if (!dir) return base;
|
|
2700
|
+
if (base === sep) return dir;
|
|
2701
|
+
if (dir === pathObject.root) return dir + base;
|
|
2702
|
+
return dir + sep + base;
|
|
2703
|
+
}
|
|
2704
|
+
function assertArg2(pathObject) {
|
|
2872
2705
|
if (pathObject === null || typeof pathObject !== "object") {
|
|
2873
2706
|
throw new TypeError(`The "pathObject" argument must be of type Object. Received type ${typeof pathObject}`);
|
|
2874
2707
|
}
|
|
2708
|
+
}
|
|
2709
|
+
function posixFormat(pathObject) {
|
|
2710
|
+
assertArg2(pathObject);
|
|
2875
2711
|
return _format("/", pathObject);
|
|
2876
2712
|
}
|
|
2877
|
-
function
|
|
2713
|
+
function windowsFormat(pathObject) {
|
|
2714
|
+
assertArg2(pathObject);
|
|
2715
|
+
return _format("\\", pathObject);
|
|
2716
|
+
}
|
|
2717
|
+
function posixParse(path) {
|
|
2878
2718
|
assertPath(path);
|
|
2879
2719
|
const ret = {
|
|
2880
2720
|
root: "",
|
|
@@ -2942,42 +2782,210 @@ function parse3(path) {
|
|
|
2942
2782
|
} else if (isAbsolute) ret.dir = "/";
|
|
2943
2783
|
return ret;
|
|
2944
2784
|
}
|
|
2945
|
-
function
|
|
2785
|
+
function windowsParse(path) {
|
|
2786
|
+
assertPath(path);
|
|
2787
|
+
const ret = {
|
|
2788
|
+
root: "",
|
|
2789
|
+
dir: "",
|
|
2790
|
+
base: "",
|
|
2791
|
+
ext: "",
|
|
2792
|
+
name: ""
|
|
2793
|
+
};
|
|
2794
|
+
const len = path.length;
|
|
2795
|
+
if (len === 0) return ret;
|
|
2796
|
+
let rootEnd = 0;
|
|
2797
|
+
let code = path.charCodeAt(0);
|
|
2798
|
+
if (len > 1) {
|
|
2799
|
+
if (isPathSeparator(code)) {
|
|
2800
|
+
rootEnd = 1;
|
|
2801
|
+
if (isPathSeparator(path.charCodeAt(1))) {
|
|
2802
|
+
let j = 2;
|
|
2803
|
+
let last = j;
|
|
2804
|
+
for(; j < len; ++j){
|
|
2805
|
+
if (isPathSeparator(path.charCodeAt(j))) break;
|
|
2806
|
+
}
|
|
2807
|
+
if (j < len && j !== last) {
|
|
2808
|
+
last = j;
|
|
2809
|
+
for(; j < len; ++j){
|
|
2810
|
+
if (!isPathSeparator(path.charCodeAt(j))) break;
|
|
2811
|
+
}
|
|
2812
|
+
if (j < len && j !== last) {
|
|
2813
|
+
last = j;
|
|
2814
|
+
for(; j < len; ++j){
|
|
2815
|
+
if (isPathSeparator(path.charCodeAt(j))) break;
|
|
2816
|
+
}
|
|
2817
|
+
if (j === len) {
|
|
2818
|
+
rootEnd = j;
|
|
2819
|
+
} else if (j !== last) {
|
|
2820
|
+
rootEnd = j + 1;
|
|
2821
|
+
}
|
|
2822
|
+
}
|
|
2823
|
+
}
|
|
2824
|
+
}
|
|
2825
|
+
} else if (isWindowsDeviceRoot(code)) {
|
|
2826
|
+
if (path.charCodeAt(1) === 58) {
|
|
2827
|
+
rootEnd = 2;
|
|
2828
|
+
if (len > 2) {
|
|
2829
|
+
if (isPathSeparator(path.charCodeAt(2))) {
|
|
2830
|
+
if (len === 3) {
|
|
2831
|
+
ret.root = ret.dir = path;
|
|
2832
|
+
ret.base = "\\";
|
|
2833
|
+
return ret;
|
|
2834
|
+
}
|
|
2835
|
+
rootEnd = 3;
|
|
2836
|
+
}
|
|
2837
|
+
} else {
|
|
2838
|
+
ret.root = ret.dir = path;
|
|
2839
|
+
return ret;
|
|
2840
|
+
}
|
|
2841
|
+
}
|
|
2842
|
+
}
|
|
2843
|
+
} else if (isPathSeparator(code)) {
|
|
2844
|
+
ret.root = ret.dir = path;
|
|
2845
|
+
ret.base = "\\";
|
|
2846
|
+
return ret;
|
|
2847
|
+
}
|
|
2848
|
+
if (rootEnd > 0) ret.root = path.slice(0, rootEnd);
|
|
2849
|
+
let startDot = -1;
|
|
2850
|
+
let startPart = rootEnd;
|
|
2851
|
+
let end = -1;
|
|
2852
|
+
let matchedSlash = true;
|
|
2853
|
+
let i = path.length - 1;
|
|
2854
|
+
let preDotState = 0;
|
|
2855
|
+
for(; i >= rootEnd; --i){
|
|
2856
|
+
code = path.charCodeAt(i);
|
|
2857
|
+
if (isPathSeparator(code)) {
|
|
2858
|
+
if (!matchedSlash) {
|
|
2859
|
+
startPart = i + 1;
|
|
2860
|
+
break;
|
|
2861
|
+
}
|
|
2862
|
+
continue;
|
|
2863
|
+
}
|
|
2864
|
+
if (end === -1) {
|
|
2865
|
+
matchedSlash = false;
|
|
2866
|
+
end = i + 1;
|
|
2867
|
+
}
|
|
2868
|
+
if (code === 46) {
|
|
2869
|
+
if (startDot === -1) startDot = i;
|
|
2870
|
+
else if (preDotState !== 1) preDotState = 1;
|
|
2871
|
+
} else if (startDot !== -1) {
|
|
2872
|
+
preDotState = -1;
|
|
2873
|
+
}
|
|
2874
|
+
}
|
|
2875
|
+
if (startDot === -1 || end === -1 || preDotState === 0 || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
|
|
2876
|
+
if (end !== -1) {
|
|
2877
|
+
ret.base = ret.name = path.slice(startPart, end);
|
|
2878
|
+
}
|
|
2879
|
+
} else {
|
|
2880
|
+
ret.name = path.slice(startPart, startDot);
|
|
2881
|
+
ret.base = path.slice(startPart, end);
|
|
2882
|
+
ret.ext = path.slice(startDot, end);
|
|
2883
|
+
}
|
|
2884
|
+
ret.base = ret.base || "\\";
|
|
2885
|
+
if (startPart > 0 && startPart !== rootEnd) {
|
|
2886
|
+
ret.dir = path.slice(0, startPart - 1);
|
|
2887
|
+
} else ret.dir = ret.root;
|
|
2888
|
+
return ret;
|
|
2889
|
+
}
|
|
2890
|
+
function assertArg3(url) {
|
|
2946
2891
|
url = url instanceof URL ? url : new URL(url);
|
|
2947
2892
|
if (url.protocol != "file:") {
|
|
2948
2893
|
throw new TypeError("Must be a file URL.");
|
|
2949
2894
|
}
|
|
2895
|
+
return url;
|
|
2896
|
+
}
|
|
2897
|
+
function posixFromFileUrl(url) {
|
|
2898
|
+
url = assertArg3(url);
|
|
2950
2899
|
return decodeURIComponent(url.pathname.replace(/%(?![0-9A-Fa-f]{2})/g, "%25"));
|
|
2951
2900
|
}
|
|
2952
|
-
function
|
|
2953
|
-
|
|
2901
|
+
function windowsFromFileUrl(url) {
|
|
2902
|
+
url = assertArg3(url);
|
|
2903
|
+
let path = decodeURIComponent(url.pathname.replace(/\//g, "\\").replace(/%(?![0-9A-Fa-f]{2})/g, "%25")).replace(/^\\*([A-Za-z]:)(\\|$)/, "$1\\");
|
|
2904
|
+
if (url.hostname != "") {
|
|
2905
|
+
path = `\\\\${url.hostname}${path}`;
|
|
2906
|
+
}
|
|
2907
|
+
return path;
|
|
2908
|
+
}
|
|
2909
|
+
const WHITESPACE_ENCODINGS = {
|
|
2910
|
+
"\u0009": "%09",
|
|
2911
|
+
"\u000A": "%0A",
|
|
2912
|
+
"\u000B": "%0B",
|
|
2913
|
+
"\u000C": "%0C",
|
|
2914
|
+
"\u000D": "%0D",
|
|
2915
|
+
"\u0020": "%20"
|
|
2916
|
+
};
|
|
2917
|
+
function encodeWhitespace(string) {
|
|
2918
|
+
return string.replaceAll(/[\s]/g, (c)=>{
|
|
2919
|
+
return WHITESPACE_ENCODINGS[c] ?? c;
|
|
2920
|
+
});
|
|
2921
|
+
}
|
|
2922
|
+
function posixToFileUrl(path) {
|
|
2923
|
+
if (!posixIsAbsolute(path)) {
|
|
2954
2924
|
throw new TypeError("Must be an absolute path.");
|
|
2955
2925
|
}
|
|
2956
2926
|
const url = new URL("file:///");
|
|
2957
2927
|
url.pathname = encodeWhitespace(path.replace(/%/g, "%25").replace(/\\/g, "%5C"));
|
|
2958
2928
|
return url;
|
|
2959
2929
|
}
|
|
2930
|
+
function windowsToFileUrl(path) {
|
|
2931
|
+
if (!windowsIsAbsolute(path)) {
|
|
2932
|
+
throw new TypeError("Must be an absolute path.");
|
|
2933
|
+
}
|
|
2934
|
+
const [, hostname, pathname] = path.match(/^(?:[/\\]{2}([^/\\]+)(?=[/\\](?:[^/\\]|$)))?(.*)/);
|
|
2935
|
+
const url = new URL("file:///");
|
|
2936
|
+
url.pathname = encodeWhitespace(pathname.replace(/%/g, "%25"));
|
|
2937
|
+
if (hostname != null && hostname != "localhost") {
|
|
2938
|
+
url.hostname = hostname;
|
|
2939
|
+
if (!url.hostname) {
|
|
2940
|
+
throw new TypeError("Invalid hostname.");
|
|
2941
|
+
}
|
|
2942
|
+
}
|
|
2943
|
+
return url;
|
|
2944
|
+
}
|
|
2945
|
+
const sep = "\\";
|
|
2946
|
+
const delimiter = ";";
|
|
2947
|
+
const mod = {
|
|
2948
|
+
resolve: windowsResolve,
|
|
2949
|
+
normalize: windowsNormalize,
|
|
2950
|
+
isAbsolute: windowsIsAbsolute,
|
|
2951
|
+
join: windowsJoin,
|
|
2952
|
+
relative: windowsRelative,
|
|
2953
|
+
toNamespacedPath: windowsToNamespacedPath,
|
|
2954
|
+
dirname: windowsDirname,
|
|
2955
|
+
basename: windowsBasename,
|
|
2956
|
+
extname: windowsExtname,
|
|
2957
|
+
format: windowsFormat,
|
|
2958
|
+
parse: windowsParse,
|
|
2959
|
+
fromFileUrl: windowsFromFileUrl,
|
|
2960
|
+
toFileUrl: windowsToFileUrl,
|
|
2961
|
+
sep: sep,
|
|
2962
|
+
delimiter: delimiter
|
|
2963
|
+
};
|
|
2964
|
+
const sep1 = "/";
|
|
2965
|
+
const delimiter1 = ":";
|
|
2960
2966
|
const mod1 = {
|
|
2967
|
+
resolve: posixResolve,
|
|
2968
|
+
normalize: posixNormalize,
|
|
2969
|
+
isAbsolute: posixIsAbsolute,
|
|
2970
|
+
join: posixJoin,
|
|
2971
|
+
relative: posixRelative,
|
|
2972
|
+
toNamespacedPath: posixToNamespacedPath,
|
|
2973
|
+
dirname: posixDirname,
|
|
2974
|
+
basename: posixBasename,
|
|
2975
|
+
extname: posixExtname,
|
|
2976
|
+
format: posixFormat,
|
|
2977
|
+
parse: posixParse,
|
|
2978
|
+
fromFileUrl: posixFromFileUrl,
|
|
2979
|
+
toFileUrl: posixToFileUrl,
|
|
2961
2980
|
sep: sep1,
|
|
2962
|
-
delimiter: delimiter1
|
|
2963
|
-
resolve: resolve1,
|
|
2964
|
-
normalize: normalize1,
|
|
2965
|
-
isAbsolute: isAbsolute1,
|
|
2966
|
-
join: join1,
|
|
2967
|
-
relative: relative1,
|
|
2968
|
-
toNamespacedPath: toNamespacedPath1,
|
|
2969
|
-
dirname: dirname1,
|
|
2970
|
-
basename: basename1,
|
|
2971
|
-
extname: extname1,
|
|
2972
|
-
format: format1,
|
|
2973
|
-
parse: parse3,
|
|
2974
|
-
fromFileUrl: fromFileUrl1,
|
|
2975
|
-
toFileUrl: toFileUrl1
|
|
2981
|
+
delimiter: delimiter1
|
|
2976
2982
|
};
|
|
2983
|
+
function basename(path, suffix = "") {
|
|
2984
|
+
return isWindows ? windowsBasename(path, suffix) : posixBasename(path, suffix);
|
|
2985
|
+
}
|
|
2977
2986
|
const path = isWindows ? mod : mod1;
|
|
2978
|
-
const { join
|
|
2979
|
-
|
|
2980
|
-
const { basename: basename2 , delimiter: delimiter2 , dirname: dirname2 , extname: extname2 , format: format2 , fromFileUrl: fromFileUrl2 , isAbsolute: isAbsolute2 , join: join3 , normalize: normalize3 , parse: parse4 , relative: relative2 , resolve: resolve2 , toFileUrl: toFileUrl2 , toNamespacedPath: toNamespacedPath2 } = path1;
|
|
2987
|
+
const { join , normalize } = path;
|
|
2988
|
+
isWindows ? mod.delimiter : mod1.delimiter;
|
|
2981
2989
|
class InputFile {
|
|
2982
2990
|
consumed = false;
|
|
2983
2991
|
fileData;
|
|
@@ -2988,11 +2996,11 @@ class InputFile {
|
|
|
2988
2996
|
this.filename = filename;
|
|
2989
2997
|
}
|
|
2990
2998
|
guessFilename(file) {
|
|
2991
|
-
if (typeof file === "string") return
|
|
2999
|
+
if (typeof file === "string") return basename(file);
|
|
2992
3000
|
if (typeof file !== "object") return undefined;
|
|
2993
|
-
if ("url" in file) return
|
|
3001
|
+
if ("url" in file) return basename(file.url);
|
|
2994
3002
|
if (!(file instanceof URL)) return undefined;
|
|
2995
|
-
return
|
|
3003
|
+
return basename(file.pathname) || basename(file.hostname);
|
|
2996
3004
|
}
|
|
2997
3005
|
toRaw() {
|
|
2998
3006
|
if (this.consumed) {
|
|
@@ -3136,6 +3144,8 @@ function concatTransformer(prev, trans) {
|
|
|
3136
3144
|
return (method, payload, signal)=>trans(prev, method, payload, signal);
|
|
3137
3145
|
}
|
|
3138
3146
|
class ApiClient {
|
|
3147
|
+
token;
|
|
3148
|
+
webhookReplyEnvelope;
|
|
3139
3149
|
options;
|
|
3140
3150
|
hasUsedWebhookReply;
|
|
3141
3151
|
installedTransformers;
|
|
@@ -3212,8 +3222,6 @@ class ApiClient {
|
|
|
3212
3222
|
if (data.ok) return data.result;
|
|
3213
3223
|
else throw toGrammyError(data, method, payload);
|
|
3214
3224
|
}
|
|
3215
|
-
token;
|
|
3216
|
-
webhookReplyEnvelope;
|
|
3217
3225
|
}
|
|
3218
3226
|
function createRawApi(token, options, webhookReplyEnvelope) {
|
|
3219
3227
|
const client = new ApiClient(token, options, webhookReplyEnvelope);
|
|
@@ -4097,6 +4105,7 @@ const DEFAULT_UPDATE_TYPES = [
|
|
|
4097
4105
|
"chat_join_request"
|
|
4098
4106
|
];
|
|
4099
4107
|
class Bot extends Composer {
|
|
4108
|
+
token;
|
|
4100
4109
|
pollingRunning;
|
|
4101
4110
|
pollingAbortController;
|
|
4102
4111
|
lastTriedUpdateId;
|
|
@@ -4288,7 +4297,6 @@ a known bot info object.");
|
|
|
4288
4297
|
debugErr(`Call to getUpdates failed, retrying in ${sleepSeconds} seconds ...`);
|
|
4289
4298
|
await sleep(sleepSeconds);
|
|
4290
4299
|
}
|
|
4291
|
-
token;
|
|
4292
4300
|
}
|
|
4293
4301
|
async function withRetries(task, signal) {
|
|
4294
4302
|
const INITIAL_DELAY = 50;
|
|
@@ -4725,6 +4733,7 @@ const InputMediaBuilder = {
|
|
|
4725
4733
|
};
|
|
4726
4734
|
export { InputMediaBuilder as InputMediaBuilder };
|
|
4727
4735
|
class Keyboard {
|
|
4736
|
+
keyboard;
|
|
4728
4737
|
is_persistent;
|
|
4729
4738
|
selective;
|
|
4730
4739
|
one_time_keyboard;
|
|
@@ -4875,9 +4884,9 @@ class Keyboard {
|
|
|
4875
4884
|
}
|
|
4876
4885
|
return new Keyboard(source.map((row)=>row.map(toButton)));
|
|
4877
4886
|
}
|
|
4878
|
-
keyboard;
|
|
4879
4887
|
}
|
|
4880
4888
|
class InlineKeyboard {
|
|
4889
|
+
inline_keyboard;
|
|
4881
4890
|
constructor(inline_keyboard = [
|
|
4882
4891
|
[]
|
|
4883
4892
|
]){
|
|
@@ -5000,7 +5009,6 @@ class InlineKeyboard {
|
|
|
5000
5009
|
if (source instanceof InlineKeyboard) return source.clone();
|
|
5001
5010
|
return new InlineKeyboard(source.map((row)=>row.slice()));
|
|
5002
5011
|
}
|
|
5003
|
-
inline_keyboard;
|
|
5004
5012
|
}
|
|
5005
5013
|
function transpose(grid) {
|
|
5006
5014
|
const transposed = [];
|
|
@@ -5093,6 +5101,10 @@ function lazySession(options = {}) {
|
|
|
5093
5101
|
};
|
|
5094
5102
|
}
|
|
5095
5103
|
class PropertySession {
|
|
5104
|
+
storage;
|
|
5105
|
+
obj;
|
|
5106
|
+
prop;
|
|
5107
|
+
initial;
|
|
5096
5108
|
key;
|
|
5097
5109
|
value;
|
|
5098
5110
|
promise;
|
|
@@ -5177,10 +5189,6 @@ class PropertySession {
|
|
|
5177
5189
|
}
|
|
5178
5190
|
}
|
|
5179
5191
|
}
|
|
5180
|
-
storage;
|
|
5181
|
-
obj;
|
|
5182
|
-
prop;
|
|
5183
|
-
initial;
|
|
5184
5192
|
}
|
|
5185
5193
|
function fillDefaults(opts = {}) {
|
|
5186
5194
|
let { getSessionKey =defaultGetSessionKey , initial , storage } = opts;
|
|
@@ -5297,6 +5305,7 @@ function wrapStorage(storage) {
|
|
|
5297
5305
|
};
|
|
5298
5306
|
}
|
|
5299
5307
|
class MemorySessionStorage {
|
|
5308
|
+
timeToLive;
|
|
5300
5309
|
storage;
|
|
5301
5310
|
constructor(timeToLive){
|
|
5302
5311
|
this.timeToLive = timeToLive;
|
|
@@ -5335,7 +5344,6 @@ class MemorySessionStorage {
|
|
|
5335
5344
|
delete(key) {
|
|
5336
5345
|
this.storage.delete(key);
|
|
5337
5346
|
}
|
|
5338
|
-
timeToLive;
|
|
5339
5347
|
}
|
|
5340
5348
|
function addExpiryDate(value, ttl) {
|
|
5341
5349
|
if (ttl !== undefined && ttl < Infinity) {
|