@flemist/simple-utils 1.0.3 → 1.0.6
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/build/browser/index.cjs +1 -1
- package/build/browser/index.mjs +32 -30
- package/build/common/index.cjs +1 -1
- package/build/common/index.mjs +32 -30
- package/build/common/object/index.d.ts +1 -0
- package/build/common/object/setFuncName.d.ts +2 -0
- package/build/common/string/format/formatAny.d.ts +4 -2
- package/build/common/string/format/index.d.ts +1 -0
- package/build/common/string/format/truncateString.d.ts +5 -0
- package/build/node/index.cjs +2 -2
- package/build/node/index.mjs +66 -64
- package/build/urlGet-DQwg0Ia9.js +11 -0
- package/build/{urlGet-CW30yZvt.mjs → urlGet-O09ZzKiX.mjs} +228 -216
- package/package.json +36 -33
- package/build/urlGet-Dr4stTPz.js +0 -11
package/build/browser/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../urlGet-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../urlGet-DQwg0Ia9.js");exports.ConsoleMessageLevel=e.ConsoleMessageLevel;exports.Lazy=e.Lazy;exports.LazyWithId=e.LazyWithId;exports.Random=e.Random;exports.UNIQUE_PSEUDO_RANDOM_MAX_COUNT=e.UNIQUE_PSEUDO_RANDOM_MAX_COUNT;exports.alertReplace=e.alertReplace;exports.consoleReplace=e.consoleReplace;exports.convertTimeZone=e.convertTimeZone;exports.createUniquePseudoRandom=e.createUniquePseudoRandom;exports.dateNowUnique=e.dateNowUnique;exports.deepCloneJsonLike=e.deepCloneJsonLike;exports.deepEqualJsonLike=e.deepEqualJsonLike;exports.deepEqualJsonLikeMap=e.deepEqualJsonLikeMap;exports.equalArray=e.equalArray;exports.escapeHtml=e.escapeHtml;exports.escapeRegExp=e.escapeRegExp;exports.fixStackTrace=e.fixStackTrace;exports.formatAny=e.formatAny;exports.formatDate=e.formatDate;exports.formatDateFileName=e.formatDateFileName;exports.getDateInet=e.getDateInet;exports.getNormalizedObject=e.getNormalizedObject;exports.getRandomFunc=e.getRandomFunc;exports.getRandomSeed=e.getRandomSeed;exports.getStackTrace=e.getStackTrace;exports.max=e.max;exports.min=e.min;exports.minMax=e.minMax;exports.numberMod=e.numberMod;exports.randomBoolean=e.randomBoolean;exports.randomEnum=e.randomEnum;exports.randomFloat=e.randomFloat;exports.randomIndexWeighted=e.randomIndexWeighted;exports.randomInt=e.randomInt;exports.randomItem=e.randomItem;exports.randomItems=e.randomItems;exports.setFuncName=e.setFuncName;exports.sha256=e.sha256;exports.sha256Buffer=e.sha256Buffer;exports.timeoutAbortController=e.timeoutAbortController;exports.toHex=e.toHex;exports.truncateString=e.truncateString;exports.urlGetBoolean=e.urlGetBoolean;exports.urlGetFloat=e.urlGetFloat;exports.urlGetInt=e.urlGetInt;exports.urlGetParams=e.urlGetParams;exports.urlGetString=e.urlGetString;exports.urlParamToBoolean=e.urlParamToBoolean;exports.urlParamToFloat=e.urlParamToFloat;exports.urlParamToInt=e.urlParamToInt;exports.withConsoleReplace=e.withConsoleReplace;exports.withTimeout=e.withTimeout;
|
package/build/browser/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { H as s, O as o, P as t, R as n, U as r, G as m, I as l, q as d, l as u, o as i, A as c, B as p, C as g, D as I, y as R, z as T, K as f, u as x, v as N, w as h, p as E, E as F, d as L, g as M, L as P, b as S, m as U, c as k, n as q, f as A, k as C, r as D, h as G, e as y, i as B, j as O, F as b, a as w, s as z, M as J, t as _, x as v, X as H, Z as W, Y as j, Q, W as X, S as Z, V as K, T as V, J as Y, N as $ } from "../urlGet-O09ZzKiX.mjs";
|
|
2
2
|
export {
|
|
3
3
|
s as ConsoleMessageLevel,
|
|
4
4
|
o as Lazy,
|
|
@@ -18,36 +18,38 @@ export {
|
|
|
18
18
|
T as escapeRegExp,
|
|
19
19
|
f as fixStackTrace,
|
|
20
20
|
x as formatAny,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
21
|
+
N as formatDate,
|
|
22
|
+
h as formatDateFileName,
|
|
23
|
+
E as getDateInet,
|
|
24
|
+
F as getNormalizedObject,
|
|
25
|
+
L as getRandomFunc,
|
|
26
|
+
M as getRandomSeed,
|
|
27
|
+
P as getStackTrace,
|
|
28
|
+
S as max,
|
|
29
|
+
U as min,
|
|
30
|
+
k as minMax,
|
|
31
|
+
q as numberMod,
|
|
32
|
+
A as randomBoolean,
|
|
33
|
+
C as randomEnum,
|
|
34
|
+
D as randomFloat,
|
|
35
|
+
G as randomIndexWeighted,
|
|
36
36
|
y as randomInt,
|
|
37
37
|
B as randomItem,
|
|
38
38
|
O as randomItems,
|
|
39
|
-
b as
|
|
40
|
-
w as
|
|
41
|
-
z as
|
|
42
|
-
J as
|
|
43
|
-
_ as
|
|
44
|
-
v as
|
|
45
|
-
H as
|
|
46
|
-
W as
|
|
47
|
-
j as
|
|
48
|
-
Q as
|
|
49
|
-
X as
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
39
|
+
b as setFuncName,
|
|
40
|
+
w as sha256,
|
|
41
|
+
z as sha256Buffer,
|
|
42
|
+
J as timeoutAbortController,
|
|
43
|
+
_ as toHex,
|
|
44
|
+
v as truncateString,
|
|
45
|
+
H as urlGetBoolean,
|
|
46
|
+
W as urlGetFloat,
|
|
47
|
+
j as urlGetInt,
|
|
48
|
+
Q as urlGetParams,
|
|
49
|
+
X as urlGetString,
|
|
50
|
+
Z as urlParamToBoolean,
|
|
51
|
+
K as urlParamToFloat,
|
|
52
|
+
V as urlParamToInt,
|
|
53
|
+
Y as withConsoleReplace,
|
|
54
|
+
$ as withTimeout
|
|
53
55
|
};
|
package/build/common/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../urlGet-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../urlGet-DQwg0Ia9.js");exports.ConsoleMessageLevel=e.ConsoleMessageLevel;exports.Lazy=e.Lazy;exports.LazyWithId=e.LazyWithId;exports.Random=e.Random;exports.UNIQUE_PSEUDO_RANDOM_MAX_COUNT=e.UNIQUE_PSEUDO_RANDOM_MAX_COUNT;exports.alertReplace=e.alertReplace;exports.consoleReplace=e.consoleReplace;exports.convertTimeZone=e.convertTimeZone;exports.createUniquePseudoRandom=e.createUniquePseudoRandom;exports.dateNowUnique=e.dateNowUnique;exports.deepCloneJsonLike=e.deepCloneJsonLike;exports.deepEqualJsonLike=e.deepEqualJsonLike;exports.deepEqualJsonLikeMap=e.deepEqualJsonLikeMap;exports.equalArray=e.equalArray;exports.escapeHtml=e.escapeHtml;exports.escapeRegExp=e.escapeRegExp;exports.fixStackTrace=e.fixStackTrace;exports.formatAny=e.formatAny;exports.formatDate=e.formatDate;exports.formatDateFileName=e.formatDateFileName;exports.getDateInet=e.getDateInet;exports.getNormalizedObject=e.getNormalizedObject;exports.getRandomFunc=e.getRandomFunc;exports.getRandomSeed=e.getRandomSeed;exports.getStackTrace=e.getStackTrace;exports.max=e.max;exports.min=e.min;exports.minMax=e.minMax;exports.numberMod=e.numberMod;exports.randomBoolean=e.randomBoolean;exports.randomEnum=e.randomEnum;exports.randomFloat=e.randomFloat;exports.randomIndexWeighted=e.randomIndexWeighted;exports.randomInt=e.randomInt;exports.randomItem=e.randomItem;exports.randomItems=e.randomItems;exports.setFuncName=e.setFuncName;exports.sha256=e.sha256;exports.sha256Buffer=e.sha256Buffer;exports.timeoutAbortController=e.timeoutAbortController;exports.toHex=e.toHex;exports.truncateString=e.truncateString;exports.urlGetBoolean=e.urlGetBoolean;exports.urlGetFloat=e.urlGetFloat;exports.urlGetInt=e.urlGetInt;exports.urlGetParams=e.urlGetParams;exports.urlGetString=e.urlGetString;exports.urlParamToBoolean=e.urlParamToBoolean;exports.urlParamToFloat=e.urlParamToFloat;exports.urlParamToInt=e.urlParamToInt;exports.withConsoleReplace=e.withConsoleReplace;exports.withTimeout=e.withTimeout;
|
package/build/common/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { H as s, O as o, P as t, R as n, U as r, G as m, I as l, q as d, l as u, o as i, A as c, B as p, C as g, D as I, y as R, z as T, K as f, u as x, v as N, w as h, p as E, E as F, d as L, g as M, L as P, b as S, m as U, c as k, n as q, f as A, k as C, r as D, h as G, e as y, i as B, j as O, F as b, a as w, s as z, M as J, t as _, x as v, X as H, Z as W, Y as j, Q, W as X, S as Z, V as K, T as V, J as Y, N as $ } from "../urlGet-O09ZzKiX.mjs";
|
|
2
2
|
export {
|
|
3
3
|
s as ConsoleMessageLevel,
|
|
4
4
|
o as Lazy,
|
|
@@ -18,36 +18,38 @@ export {
|
|
|
18
18
|
T as escapeRegExp,
|
|
19
19
|
f as fixStackTrace,
|
|
20
20
|
x as formatAny,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
21
|
+
N as formatDate,
|
|
22
|
+
h as formatDateFileName,
|
|
23
|
+
E as getDateInet,
|
|
24
|
+
F as getNormalizedObject,
|
|
25
|
+
L as getRandomFunc,
|
|
26
|
+
M as getRandomSeed,
|
|
27
|
+
P as getStackTrace,
|
|
28
|
+
S as max,
|
|
29
|
+
U as min,
|
|
30
|
+
k as minMax,
|
|
31
|
+
q as numberMod,
|
|
32
|
+
A as randomBoolean,
|
|
33
|
+
C as randomEnum,
|
|
34
|
+
D as randomFloat,
|
|
35
|
+
G as randomIndexWeighted,
|
|
36
36
|
y as randomInt,
|
|
37
37
|
B as randomItem,
|
|
38
38
|
O as randomItems,
|
|
39
|
-
b as
|
|
40
|
-
w as
|
|
41
|
-
z as
|
|
42
|
-
J as
|
|
43
|
-
_ as
|
|
44
|
-
v as
|
|
45
|
-
H as
|
|
46
|
-
W as
|
|
47
|
-
j as
|
|
48
|
-
Q as
|
|
49
|
-
X as
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
39
|
+
b as setFuncName,
|
|
40
|
+
w as sha256,
|
|
41
|
+
z as sha256Buffer,
|
|
42
|
+
J as timeoutAbortController,
|
|
43
|
+
_ as toHex,
|
|
44
|
+
v as truncateString,
|
|
45
|
+
H as urlGetBoolean,
|
|
46
|
+
W as urlGetFloat,
|
|
47
|
+
j as urlGetInt,
|
|
48
|
+
Q as urlGetParams,
|
|
49
|
+
X as urlGetString,
|
|
50
|
+
Z as urlParamToBoolean,
|
|
51
|
+
K as urlParamToFloat,
|
|
52
|
+
V as urlParamToInt,
|
|
53
|
+
Y as withConsoleReplace,
|
|
54
|
+
$ as withTimeout
|
|
53
55
|
};
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type FormatAnyOptions = {
|
|
2
2
|
pretty?: boolean;
|
|
3
3
|
filter?: null | ((path: string[], value: any) => boolean);
|
|
4
4
|
maxDepth?: number;
|
|
5
5
|
maxItems?: number;
|
|
6
|
+
maxStringLength?: number;
|
|
6
7
|
showObjectId?: boolean;
|
|
7
8
|
showArrayIndex?: boolean;
|
|
8
9
|
customToString?: null | ((obj: any, toString: (obj: any) => any) => string | null | undefined | void);
|
|
9
|
-
}
|
|
10
|
+
};
|
|
11
|
+
export declare function formatAny(obj: any, options?: null | FormatAnyOptions, path?: null | string[], visited?: null | Set<any>): string;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type TruncateStringOptions = {
|
|
2
|
+
fromStart?: boolean;
|
|
3
|
+
};
|
|
4
|
+
export declare function truncateString(str: string, maxLength: number | null | undefined, options?: null | TruncateStringOptions): string;
|
|
5
|
+
export declare function truncateString(str: string | null | undefined, maxLength: number | null | undefined, options?: null | TruncateStringOptions): string | null;
|
package/build/node/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../urlGet-
|
|
2
|
-
`),i=[];return a.forEach(r=>{r=r.trim(),!(!r||r.startsWith("#"))&&i.push(r)}),i}async function
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../urlGet-DQwg0Ia9.js"),C=require("@flemist/async-utils"),S=require("@flemist/time-limits"),b=require("node:os"),V=require("path"),W=require("@flemist/priority-queue"),ee=require("fs"),te=require("picomatch");function j(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const a in e)if(a!=="default"){const i=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(n,a,i.get?i:{enumerable:!0,get:()=>e[a]})}}return n.default=e,Object.freeze(n)}const w=j(V),g=j(ee),z=new S.Pool(b.cpus().length);function x(e){return e.replace(/\\/g,"/")}let I=null;function ne(e){I==null&&(I=new Map);const n=x(e);let a=I.get(n);return a==null&&(a=new C.Locker,I.set(n,a)),a}function re(e){const{filePath:n,func:a}=e;return ne(n).lock(()=>S.poolRunWait({pool:z,count:1,func:a}))}function B(e){return e.match(/^[/\\]?[^/\\]+/)[0]}function H(e,n){return B(e)+"|"+n.ino}function $(e){return e.endsWith(":")&&(e+="/"),w.resolve(e)}function _(e,n){e.totalSize+=n.totalSize,e.maxFileDateModified=Math.max(e.maxFileDateModified,n.maxFileDateModified),e.countFiles+=n.countFiles,e.countDirs+=n.countDirs,e.countLinks+=n.countLinks}const J=function(n){return n.code==="ENOENT"};function Q(e){const n=e.paths;if(!n||n.length===0)return Promise.resolve({totalSize:0,maxFileDateModified:0,countFiles:0,countDirs:0,countLinks:0});const a=e.level??0,i=e.walkedIds??new Set,r=e.abortSignal,l=e.pool??z,p=e.handleError,d=e.priority??W.priorityCreate(0),c=e.walkLinks??!1,m=e.log,D=e.handlePath,N=e.matchPath;async function R(L){if(!(p&&await p(L))&&!J(L))throw L}function Y(L){return!(!m||m.minTotalContentSize!=null&&L<m.minTotalContentSize||m.maxNestedLevel!=null&&a>m.maxNestedLevel)}return C.useAbortController(async L=>{const E=C.combineAbortSignals(r,L),T={totalSize:0,maxFileDateModified:0,countFiles:0,countDirs:0,countLinks:0};function q(f,y){if(Y(y.totalSize)){const o=`${y.totalSize.toLocaleString("en-US").replace(/,/g," ").padStart(19)}: ${f}`;m?.handleLog?m.handleLog(o):console.log(o)}}async function G(f,y,k,o){return D?await S.poolRunWait({pool:l,func:async()=>{try{return await D({level:a,path:f,stat:y,itemStat:k,totalStat:T,abortSignal:E})}catch(u){return await R(u),!1}},count:1,priority:o,abortSignal:E}):!0}async function O(f,y,k,o){o||(o=f);const u=await S.poolRunWait({pool:l,func:()=>g.promises.lstat(f).catch(R),count:1,priority:W.priorityCreate(y,W.priorityCreate(1,d)),abortSignal:E});if(!u||!k&&u.isFile())return null;const U=H(f,u);if(i.has(U))return null;i.add(U);let s={totalSize:u.size,maxFileDateModified:u.isDirectory()?0:u.mtimeMs,countFiles:0,countDirs:0,countLinks:0};const M=W.priorityCreate(y,W.priorityCreate(u.isDirectory()?2:3,d));if(u.isSymbolicLink()){if(c){const h=await S.poolRunWait({pool:l,func:()=>g.promises.readlink(f).catch(R).then(F=>F??null),count:1,priority:M,abortSignal:E});if(h){const F=w.isAbsolute(h)?h:w.resolve(w.dirname(o),h),v=await O(F,y,k,o);v&&(s=v)}}return(k||s.countFiles+s.countDirs+s.countLinks>=1)&&(s.countLinks+=1,await G(o,u,s,M)&&(_(T,s),q(o,s))),s}else if(u.isDirectory()){const h=await S.poolRunWait({pool:l,func:()=>g.promises.readdir(f).catch(R),count:1,priority:d,abortSignal:E});if(h){for(let F=0,v=h.length;F<v;F++)h[F]=w.join(o,h[F]);s=await Q({...e,paths:h,abortSignal:E,priority:M,level:a+1,walkedIds:i})}}return(k||s.countFiles+s.countDirs+s.countLinks>=1)&&(u.isDirectory()?s.countDirs+=1:u.isFile()&&(s.countFiles+=1),await G(o,u,s,M)&&(_(T,s),q(o,s))),s}const A=[];for(let f=0,y=n.length;f<y;f++){const k=$(n[f]),o=N?N(k):!0;o!==!1&&A.push(O(k,f,o))}return await Promise.all(A),T})}function ae(e){return Q(e)}function ie({globs:e,rootDir:n,noCase:a}){const i=[];return e.forEach(r=>{r=x(r).trim();const l=r.startsWith("^");l&&(r=r.substring(1).trim());const p=r.startsWith("!");if(p&&(r=r.substring(1).trim()),r.startsWith("!")||r.startsWith("^"))throw new Error(`Invalid glob pattern: "${r}". The syntax '${r.substring(0,2)}' is not supported. Valid glob patterns use: * (match any characters), ** (match any directories), ? (match single character), [abc] (character class), ! (negate pattern), ^ (exclude if included). Examples of valid patterns: "*.js", "src/**/*.ts", "!node_modules", "^dist". Avoid starting with '!' after '^' or multiple special prefixes.`);r.startsWith("/")&&(r="."+r);const d=x(n?w.resolve(n,r):r);if(!d)return;let c;try{c=te(d,{nocase:a??!1,dot:!0,strictBrackets:!0})}catch(m){throw new Error(`Invalid glob pattern: "${r}". ${m instanceof Error?m.message:"Unknown error"}. Valid glob patterns use: * (match any characters), ** (match any directories), ? (match single character), [abc] (character class with balanced brackets), ! (negate pattern), ^ (exclude if included). Examples: "*.js", "src/**/*.ts", "!node_modules", "[abc]def.txt". Ensure all brackets [ ] are properly closed and balanced.`)}i.push({exclude:l,negative:p,debugInfo:d,match:c})}),function(l){l=x(l);let p=null,d=!1;for(let c=0,m=i.length;c<m;c++){const D=i[c];D.match(l)&&(D.exclude?d=!D.negative:(p=!D.negative,d=!1))}return d?!1:p}}function X(e){const n=e.startsWith("!");return n&&(e=e.substring(1)),e.startsWith("/")?e=e.substring(1):!e.startsWith("**")&&!e.startsWith("../")&&(e=`**/${e}`),n&&(e="!"+e),e}function Z(e,n){if(!n||n===".")return e;const a=e.startsWith("^");a&&(e=e.substring(1));const i=e.startsWith("!");return i&&(e=e.substring(1)),e.startsWith("/")?(n.endsWith("/")&&(n=n.substring(0,n.length-1)),e=n+e):(n.endsWith("/")||(n+="/"),e.startsWith("./")?e=n+e.substring(2):e.startsWith("../")?e=n+e:(n.startsWith("..")&&(n=""),e.startsWith("**")?e=n+e:e=n+"**/"+e)),e=x(w.normalize(e)),i&&(e="!"+e),a&&(e="^"+e),e}function P(e){return"^"+e}async function K(e){const a=(await g.promises.readFile(e,"utf-8")).split(`
|
|
2
|
+
`),i=[];return a.forEach(r=>{r=r.trim(),!(!r||r.startsWith("#"))&&i.push(r)}),i}async function se(e){const n=e.rootDir??".",a=[];if(!e.globs?.length)return a;const i=[];return e.globs.forEach(r=>{r.value&&(r.valueType==="file-contains-patterns"?i.push(r):r.valueType==="pattern"&&a.push(r.exclude?P(r.value):r.value))}),i.length&&await Promise.all(i.map(async r=>{await S.poolRunWait({pool:z,count:1,func:async()=>{const l=w.resolve(n,r.value),p=await K(l),d=w.relative(n,w.dirname(l));p.forEach(c=>{c=X(c),c=Z(c,d),a.push(r.exclude?P(c):c)})}})})),a}exports.ConsoleMessageLevel=t.ConsoleMessageLevel;exports.Lazy=t.Lazy;exports.LazyWithId=t.LazyWithId;exports.Random=t.Random;exports.UNIQUE_PSEUDO_RANDOM_MAX_COUNT=t.UNIQUE_PSEUDO_RANDOM_MAX_COUNT;exports.alertReplace=t.alertReplace;exports.consoleReplace=t.consoleReplace;exports.convertTimeZone=t.convertTimeZone;exports.createUniquePseudoRandom=t.createUniquePseudoRandom;exports.dateNowUnique=t.dateNowUnique;exports.deepCloneJsonLike=t.deepCloneJsonLike;exports.deepEqualJsonLike=t.deepEqualJsonLike;exports.deepEqualJsonLikeMap=t.deepEqualJsonLikeMap;exports.equalArray=t.equalArray;exports.escapeHtml=t.escapeHtml;exports.escapeRegExp=t.escapeRegExp;exports.fixStackTrace=t.fixStackTrace;exports.formatAny=t.formatAny;exports.formatDate=t.formatDate;exports.formatDateFileName=t.formatDateFileName;exports.getDateInet=t.getDateInet;exports.getNormalizedObject=t.getNormalizedObject;exports.getRandomFunc=t.getRandomFunc;exports.getRandomSeed=t.getRandomSeed;exports.getStackTrace=t.getStackTrace;exports.max=t.max;exports.min=t.min;exports.minMax=t.minMax;exports.numberMod=t.numberMod;exports.randomBoolean=t.randomBoolean;exports.randomEnum=t.randomEnum;exports.randomFloat=t.randomFloat;exports.randomIndexWeighted=t.randomIndexWeighted;exports.randomInt=t.randomInt;exports.randomItem=t.randomItem;exports.randomItems=t.randomItems;exports.setFuncName=t.setFuncName;exports.sha256=t.sha256;exports.sha256Buffer=t.sha256Buffer;exports.timeoutAbortController=t.timeoutAbortController;exports.toHex=t.toHex;exports.truncateString=t.truncateString;exports.urlGetBoolean=t.urlGetBoolean;exports.urlGetFloat=t.urlGetFloat;exports.urlGetInt=t.urlGetInt;exports.urlGetParams=t.urlGetParams;exports.urlGetString=t.urlGetString;exports.urlParamToBoolean=t.urlParamToBoolean;exports.urlParamToFloat=t.urlParamToFloat;exports.urlParamToInt=t.urlParamToInt;exports.withConsoleReplace=t.withConsoleReplace;exports.withTimeout=t.withTimeout;exports.createMatchPath=ie;exports.fileLock=re;exports.getDrive=B;exports.getFileId=H;exports.globGitIgnoreToPicomatch=X;exports.globToRelative=Z;exports.loadGlobs=se;exports.loadGlobsFromFile=K;exports.pathNormalize=x;exports.pathResolve=$;exports.poolFs=z;exports.walkPathHandleErrorDefault=J;exports.walkPaths=ae;
|
package/build/node/index.mjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { H as mt, O as ht, P as pt, R as kt, U as wt, G as yt, I as xt, q as Ft, l as Lt, o as Dt, A as St, B as Et, C as Wt, D as zt, y as vt, z as Mt, K as Tt, u as It, v as Nt, w as Rt, p as Ct, E as At, d as Gt, g as Ut, L as Ot, b as $t, m as qt, c as Bt, n as _t, f as jt, k as Ht, r as Jt, h as gt, e as Pt, i as Qt, j as Xt, F as Zt, a as Kt, s as Yt, M as Vt, t as bt, x as te, X as ee, Z as ne, Y as se, Q as ae, W as re, S as ie, V as oe, T as ce, J as ue, N as le } from "../urlGet-O09ZzKiX.mjs";
|
|
2
2
|
import { Locker as j, useAbortController as H, combineAbortSignals as J } from "@flemist/async-utils";
|
|
3
|
-
import { Pool as
|
|
4
|
-
import
|
|
3
|
+
import { Pool as g, poolRunWait as D } from "@flemist/time-limits";
|
|
4
|
+
import P from "node:os";
|
|
5
5
|
import * as w from "path";
|
|
6
6
|
import { priorityCreate as E } from "@flemist/priority-queue";
|
|
7
7
|
import * as I from "fs";
|
|
8
|
-
import
|
|
9
|
-
const
|
|
8
|
+
import Q from "picomatch";
|
|
9
|
+
const R = new g(P.cpus().length);
|
|
10
10
|
function S(t) {
|
|
11
11
|
return t.replace(/\\/g, "/");
|
|
12
12
|
}
|
|
13
13
|
let T = null;
|
|
14
|
-
function
|
|
14
|
+
function X(t) {
|
|
15
15
|
T == null && (T = /* @__PURE__ */ new Map());
|
|
16
16
|
const e = S(t);
|
|
17
17
|
let s = T.get(e);
|
|
@@ -19,19 +19,19 @@ function g(t) {
|
|
|
19
19
|
}
|
|
20
20
|
function ot(t) {
|
|
21
21
|
const { filePath: e, func: s } = t;
|
|
22
|
-
return
|
|
23
|
-
() =>
|
|
24
|
-
pool:
|
|
22
|
+
return X(e).lock(
|
|
23
|
+
() => D({
|
|
24
|
+
pool: R,
|
|
25
25
|
count: 1,
|
|
26
26
|
func: s
|
|
27
27
|
})
|
|
28
28
|
);
|
|
29
29
|
}
|
|
30
|
-
function
|
|
30
|
+
function Z(t) {
|
|
31
31
|
return t.match(/^[/\\]?[^/\\]+/)[0];
|
|
32
32
|
}
|
|
33
|
-
function
|
|
34
|
-
return
|
|
33
|
+
function K(t, e) {
|
|
34
|
+
return Z(t) + "|" + e.ino;
|
|
35
35
|
}
|
|
36
36
|
function Y(t) {
|
|
37
37
|
return t.endsWith(":") && (t += "/"), w.resolve(t);
|
|
@@ -55,30 +55,30 @@ function B(t) {
|
|
|
55
55
|
countDirs: 0,
|
|
56
56
|
countLinks: 0
|
|
57
57
|
});
|
|
58
|
-
const s = t.level ?? 0, r = t.walkedIds ?? /* @__PURE__ */ new Set(), n = t.abortSignal, u = t.pool ??
|
|
59
|
-
async function W(
|
|
60
|
-
if (!(h && await h(
|
|
61
|
-
throw
|
|
58
|
+
const s = t.level ?? 0, r = t.walkedIds ?? /* @__PURE__ */ new Set(), n = t.abortSignal, u = t.pool ?? R, h = t.handleError, f = t.priority ?? E(0), o = t.walkLinks ?? !1, d = t.log, x = t.handlePath, N = t.matchPath;
|
|
59
|
+
async function W(F) {
|
|
60
|
+
if (!(h && await h(F)) && !V(F))
|
|
61
|
+
throw F;
|
|
62
62
|
}
|
|
63
|
-
function _(
|
|
64
|
-
return !(!d || d.minTotalContentSize != null &&
|
|
63
|
+
function _(F) {
|
|
64
|
+
return !(!d || d.minTotalContentSize != null && F < d.minTotalContentSize || d.maxNestedLevel != null && s > d.maxNestedLevel);
|
|
65
65
|
}
|
|
66
|
-
return H(async (
|
|
67
|
-
const
|
|
66
|
+
return H(async (F) => {
|
|
67
|
+
const L = J(n, F), z = {
|
|
68
68
|
totalSize: 0,
|
|
69
69
|
maxFileDateModified: 0,
|
|
70
70
|
countFiles: 0,
|
|
71
71
|
countDirs: 0,
|
|
72
72
|
countLinks: 0
|
|
73
73
|
};
|
|
74
|
-
function
|
|
74
|
+
function C(l, p) {
|
|
75
75
|
if (_(p.totalSize)) {
|
|
76
76
|
const i = `${p.totalSize.toLocaleString("en-US").replace(/,/g, " ").padStart(19)}: ${l}`;
|
|
77
77
|
d?.handleLog ? d.handleLog(i) : console.log(i);
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
async function A(l, p, k, i) {
|
|
81
|
-
return x ? await
|
|
81
|
+
return x ? await D({
|
|
82
82
|
pool: u,
|
|
83
83
|
func: async () => {
|
|
84
84
|
try {
|
|
@@ -88,7 +88,7 @@ function B(t) {
|
|
|
88
88
|
stat: p,
|
|
89
89
|
itemStat: k,
|
|
90
90
|
totalStat: z,
|
|
91
|
-
abortSignal:
|
|
91
|
+
abortSignal: L
|
|
92
92
|
});
|
|
93
93
|
} catch (c) {
|
|
94
94
|
return await W(c), !1;
|
|
@@ -96,21 +96,21 @@ function B(t) {
|
|
|
96
96
|
},
|
|
97
97
|
count: 1,
|
|
98
98
|
priority: i,
|
|
99
|
-
abortSignal:
|
|
99
|
+
abortSignal: L
|
|
100
100
|
}) : !0;
|
|
101
101
|
}
|
|
102
102
|
async function G(l, p, k, i) {
|
|
103
103
|
i || (i = l);
|
|
104
|
-
const c = await
|
|
104
|
+
const c = await D({
|
|
105
105
|
pool: u,
|
|
106
106
|
func: () => I.promises.lstat(l).catch(W),
|
|
107
107
|
count: 1,
|
|
108
108
|
priority: E(p, E(1, f)),
|
|
109
|
-
abortSignal:
|
|
109
|
+
abortSignal: L
|
|
110
110
|
});
|
|
111
111
|
if (!c || !k && c.isFile())
|
|
112
112
|
return null;
|
|
113
|
-
const O =
|
|
113
|
+
const O = K(l, c);
|
|
114
114
|
if (r.has(O))
|
|
115
115
|
return null;
|
|
116
116
|
r.add(O);
|
|
@@ -127,12 +127,12 @@ function B(t) {
|
|
|
127
127
|
);
|
|
128
128
|
if (c.isSymbolicLink()) {
|
|
129
129
|
if (o) {
|
|
130
|
-
const m = await
|
|
130
|
+
const m = await D({
|
|
131
131
|
pool: u,
|
|
132
132
|
func: () => I.promises.readlink(l).catch(W).then((y) => y ?? null),
|
|
133
133
|
count: 1,
|
|
134
134
|
priority: v,
|
|
135
|
-
abortSignal:
|
|
135
|
+
abortSignal: L
|
|
136
136
|
});
|
|
137
137
|
if (m) {
|
|
138
138
|
const y = w.isAbsolute(m) ? m : w.resolve(w.dirname(i), m), M = await G(
|
|
@@ -149,14 +149,14 @@ function B(t) {
|
|
|
149
149
|
c,
|
|
150
150
|
a,
|
|
151
151
|
v
|
|
152
|
-
) && ($(z, a),
|
|
152
|
+
) && ($(z, a), C(i, a))), a;
|
|
153
153
|
} else if (c.isDirectory()) {
|
|
154
|
-
const m = await
|
|
154
|
+
const m = await D({
|
|
155
155
|
pool: u,
|
|
156
156
|
func: () => I.promises.readdir(l).catch(W),
|
|
157
157
|
count: 1,
|
|
158
158
|
priority: f,
|
|
159
|
-
abortSignal:
|
|
159
|
+
abortSignal: L
|
|
160
160
|
});
|
|
161
161
|
if (m) {
|
|
162
162
|
for (let y = 0, M = m.length; y < M; y++)
|
|
@@ -164,7 +164,7 @@ function B(t) {
|
|
|
164
164
|
a = await B({
|
|
165
165
|
...t,
|
|
166
166
|
paths: m,
|
|
167
|
-
abortSignal:
|
|
167
|
+
abortSignal: L,
|
|
168
168
|
priority: v,
|
|
169
169
|
level: s + 1,
|
|
170
170
|
walkedIds: r
|
|
@@ -176,11 +176,11 @@ function B(t) {
|
|
|
176
176
|
c,
|
|
177
177
|
a,
|
|
178
178
|
v
|
|
179
|
-
) && ($(z, a),
|
|
179
|
+
) && ($(z, a), C(i, a))), a;
|
|
180
180
|
}
|
|
181
181
|
const U = [];
|
|
182
182
|
for (let l = 0, p = e.length; l < p; l++) {
|
|
183
|
-
const k = Y(e[l]), i =
|
|
183
|
+
const k = Y(e[l]), i = N ? N(k) : !0;
|
|
184
184
|
i !== !1 && U.push(G(k, l, i));
|
|
185
185
|
}
|
|
186
186
|
return await Promise.all(U), z;
|
|
@@ -210,7 +210,7 @@ function ut({
|
|
|
210
210
|
return;
|
|
211
211
|
let o;
|
|
212
212
|
try {
|
|
213
|
-
o =
|
|
213
|
+
o = Q(f, {
|
|
214
214
|
nocase: s ?? !1,
|
|
215
215
|
dot: !0,
|
|
216
216
|
strictBrackets: !0
|
|
@@ -268,8 +268,8 @@ async function lt(t) {
|
|
|
268
268
|
n.value && (n.valueType === "file-contains-patterns" ? r.push(n) : n.valueType === "pattern" && s.push(n.exclude ? q(n.value) : n.value));
|
|
269
269
|
}), r.length && await Promise.all(
|
|
270
270
|
r.map(async (n) => {
|
|
271
|
-
await
|
|
272
|
-
pool:
|
|
271
|
+
await D({
|
|
272
|
+
pool: R,
|
|
273
273
|
count: 1,
|
|
274
274
|
func: async () => {
|
|
275
275
|
const u = w.resolve(e, n.value), h = await et(u), f = w.relative(e, w.dirname(u));
|
|
@@ -289,10 +289,10 @@ export {
|
|
|
289
289
|
wt as UNIQUE_PSEUDO_RANDOM_MAX_COUNT,
|
|
290
290
|
yt as alertReplace,
|
|
291
291
|
xt as consoleReplace,
|
|
292
|
-
|
|
292
|
+
Ft as convertTimeZone,
|
|
293
293
|
ut as createMatchPath,
|
|
294
|
-
|
|
295
|
-
|
|
294
|
+
Lt as createUniquePseudoRandom,
|
|
295
|
+
Dt as dateNowUnique,
|
|
296
296
|
St as deepCloneJsonLike,
|
|
297
297
|
Et as deepEqualJsonLike,
|
|
298
298
|
Wt as deepEqualJsonLikeMap,
|
|
@@ -302,11 +302,11 @@ export {
|
|
|
302
302
|
ot as fileLock,
|
|
303
303
|
Tt as fixStackTrace,
|
|
304
304
|
It as formatAny,
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
305
|
+
Nt as formatDate,
|
|
306
|
+
Rt as formatDateFileName,
|
|
307
|
+
Ct as getDateInet,
|
|
308
|
+
Z as getDrive,
|
|
309
|
+
K as getFileId,
|
|
310
310
|
At as getNormalizedObject,
|
|
311
311
|
Gt as getRandomFunc,
|
|
312
312
|
Ut as getRandomSeed,
|
|
@@ -321,28 +321,30 @@ export {
|
|
|
321
321
|
_t as numberMod,
|
|
322
322
|
S as pathNormalize,
|
|
323
323
|
Y as pathResolve,
|
|
324
|
-
|
|
324
|
+
R as poolFs,
|
|
325
325
|
jt as randomBoolean,
|
|
326
326
|
Ht as randomEnum,
|
|
327
327
|
Jt as randomFloat,
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
328
|
+
gt as randomIndexWeighted,
|
|
329
|
+
Pt as randomInt,
|
|
330
|
+
Qt as randomItem,
|
|
331
|
+
Xt as randomItems,
|
|
332
|
+
Zt as setFuncName,
|
|
332
333
|
Kt as sha256,
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
334
|
+
Yt as sha256Buffer,
|
|
335
|
+
Vt as timeoutAbortController,
|
|
336
|
+
bt as toHex,
|
|
337
|
+
te as truncateString,
|
|
338
|
+
ee as urlGetBoolean,
|
|
339
|
+
ne as urlGetFloat,
|
|
340
|
+
se as urlGetInt,
|
|
341
|
+
ae as urlGetParams,
|
|
342
|
+
re as urlGetString,
|
|
343
|
+
ie as urlParamToBoolean,
|
|
344
|
+
oe as urlParamToFloat,
|
|
345
|
+
ce as urlParamToInt,
|
|
344
346
|
V as walkPathHandleErrorDefault,
|
|
345
347
|
ct as walkPaths,
|
|
346
|
-
|
|
347
|
-
|
|
348
|
+
ue as withConsoleReplace,
|
|
349
|
+
le as withTimeout
|
|
348
350
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";const z=require("@flemist/abort-controller-fast"),K=require("@flemist/async-utils"),At=require("@flemist/time-controller");let q=null;function Tt(){if(!q){q=new Array(256);for(let t=0;t<256;t++)q[t]=t.toString(16).padStart(2,"0")}return q}function st(t){const e=Tt(),r=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);let n="";for(let o=0,i=r.length;o<i;o++)n+=e[r[o]];return n}let Y=null,ut=null,B=null,lt=null;function Et(){Y||(Y=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),ut=new Uint32Array(64),lt=new TextEncoder,B=new Uint8Array(65536))}function at(t){if(t==null)return null;Et();const e=Y,r=ut,n=lt;let o=B,i;if(typeof t=="string"){const f=t.length*3;o.length<f+128&&(o=B=new Uint8Array(f+128));const c=n.encodeInto(t,o);i=o.subarray(0,c.written)}else if(t instanceof Uint8Array)i=t;else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);else throw new Error(`[sha256Buffer] Unsupported content type: ${typeof t}`);const m=i.length,a=m+72>>>6<<6;o.length<a&&(o=B=new Uint8Array(a)),i!==o&&o.set(i),o[m]=128;for(let f=m+1;f<a;f++)o[f]=0;const A=m*8,O=A/4294967296|0,C=A|0;o[a-8]=O>>>24,o[a-7]=O>>>16,o[a-6]=O>>>8,o[a-5]=O,o[a-4]=C>>>24,o[a-3]=C>>>16,o[a-2]=C>>>8,o[a-1]=C;let T=1779033703,U=-1150833019,u=1013904242,s=-1521486534,l=1359893119,g=-1694144372,d=528734635,y=1541459225;for(let f=0;f<a;f+=64){for(let h=0;h<16;h++){const p=f+(h<<2);r[h]=o[p]<<24|o[p+1]<<16|o[p+2]<<8|o[p+3]}for(let h=16;h<64;h++){const p=r[h-15],$=r[h-2],b=(p>>>7|p<<25)^(p>>>18|p<<14)^p>>>3,F=($>>>17|$<<15)^($>>>19|$<<13)^$>>>10;r[h]=r[h-16]+b+r[h-7]+F|0}let c=T,S=U,D=u,W=s,_=l,L=g,N=d,J=y;for(let h=0;h<64;h+=4)for(let p=0;p<4;p++){const $=h+p,b=(_>>>6|_<<26)^(_>>>11|_<<21)^(_>>>25|_<<7),F=J+b+(N^_&(L^N))+e[$]+r[$]|0,$t=((c>>>2|c<<30)^(c>>>13|c<<19)^(c>>>22|c<<10))+(c&S^D&(c^S))|0;J=N,N=L,L=_,_=W+F|0,W=D,D=S,S=c,c=F+$t|0}T=T+c|0,U=U+S|0,u=u+D|0,s=s+W|0,l=l+_|0,g=g+L|0,d=d+N|0,y=y+J|0}const w=new Uint8Array(32),R=[T,U,u,s,l,g,d,y];for(let f=0;f<8;f++){const c=R[f],S=f<<2;w[S]=c>>>24,w[S+1]=c>>>16&255,w[S+2]=c>>>8&255,w[S+3]=c&255}return w}function Ct(t){const e=at(t);return e?st(e):null}function ct(t,e){return t==null?e:e==null?t:Math.min(t,e)}function ft(t,e){return t==null?e:e==null?t:Math.max(t,e)}function Rt(t,e,r){return ft(ct(t,e),r)}function It(t,e){return(t%e+e)%e}function kt(t){return function(){let r=t+=1831565813;return r=Math.imul(r^r>>>15,r|1),r^=r+Math.imul(r^r>>>7,r|61),(r^r>>>14)/4294967296+.5}}function Nt(){return Math.random()}function Pt(){return Math.random()*2**32>>>0}function ht(t){return t!=null?kt(t):Nt}class G{_seed;_rnd;constructor(e){this._seed=e,this._rnd=ht(e)}get seed(){return this._seed}nextSeed(){return this.next()*2**32>>>0}nextRandom(){return new G(this.nextSeed())}next(){return this._rnd()}clone(){return new G(this._seed)}}function v(t,e,r){if(r==null&&(r=e,e=0),r<=e)throw new Error(`[random][randomFloat] toExclusive (${r}) must be greater than from (${e})`);return t.next()*(r-e)+e}function mt(t,e,r){return Math.floor(v(t,e,r))}function Mt(t,e){return t.next()<(e??.5)}function xt(t,e,r){if(Array.isArray(e)){const i=e;e=i.length,r=m=>i[m]}if(!r)throw new Error("[random][randomIndexWeighted] getWeight is required");let n=0;for(let i=0;i<e;i++)n+=r(i);if(n===0)return-1;let o=v(t,n);for(let i=0;i<e;i++)if(o-=r(i),o<0)return i;return e-1}function j(t,e){if(e.length===0)throw new Error("[random][randomItem] items is empty");const r=mt(t,e.length);return e[r]}function Dt(t,e,r){if(e.length===0)throw new Error("[random][randomItems] items is empty");const n=[];for(let o=0;o<r;o++)n.push(j(t,e));return n}function Lt(t,e,r){let n=Object.values(e);return r&&(n=n.filter(r)),j(t,n)}const dt=1073741789,V=(dt>>2)-1;function Ft(t=V,e){if(t<=0)throw new Error(`[random][PseudoRandom] count(${t}) must be > 0`);if(t>V)throw new Error(`[random][PseudoRandom] count(${t}) must be <= ${V}`);if(e==null&&(e=Math.floor(Math.random()*t)),e>=t)throw new Error(`[random][PseudoRandom] startFrom(${e}) must be < count(${t})`);let r=e;return function(){return r=(r+dt)%t,r}}let P=null;function qt(){const t=Date.now();return P==null||t>P?(P=t,t):(P++,P)}async function Bt({url:t,timeout:e}={}){t||(t=typeof window<"u"?"/":"https://google.com");let r;try{const n=new z.AbortControllerFast;r=e?setTimeout(()=>{n.abort()},e):null;const o=await fetch(t,{method:"HEAD",signal:z.toAbortSignal(n.signal)}),i=o.headers.get("date");if(!i)throw new Error(`[Now][getDateInet] No date header in response: ${o.status} ${t}`);return new Date(i).getTime()}finally{r&&clearTimeout(r)}}function tt(t,e,r){const n=e==null?t:new Date(t.toLocaleString("en-US",{timeZone:e})),o=r==null?t:new Date(t.toLocaleString("en-US",{timeZone:r}));return new Date(t.getTime()+o.getTime()-n.getTime())}function pt(t,e){t=tt(t,"UTC",e);const r=t.getUTCFullYear().toString().padStart(4,"0"),n=(t.getUTCMonth()+1).toString().padStart(2,"0"),o=t.getUTCDate().toString().padStart(2,"0"),i=t.getUTCHours().toString().padStart(2,"0"),m=t.getUTCMinutes().toString().padStart(2,"0"),a=t.getUTCSeconds().toString().padStart(2,"0");return`${r}-${n}-${o} ${i}:${m}:${a}`}let Vt=0;const X=new WeakMap;function I(t){if(X.has(t))return X.get(t);const e=Vt++;return X.set(t,e),e}function M(t,e,r){return t==null?t??null:e==null?t:t.length>e?e<=0?"…":r?.fromStart?"…"+t.slice(t.length-e+1):t.slice(0,e-1)+"…":t}function rt(t,e){try{return t[e]}catch(r){return"Error: "+(r instanceof Error?r.message:String(r))}}function k(t,e,r,n){const{pretty:o,filter:i,maxDepth:m,maxItems:a,maxStringLength:A,showObjectId:O,showArrayIndex:C,customToString:T}=e??{};if(r==null&&(r=[]),n==null&&(n=new Set),T){const u=T(t,s=>k(s,e,r,n));if(u!=null)return M(u,A)}const U=r.length;if(typeof t=="string")return t=M(t,A),n.size>0&&(t=JSON.stringify(t)),t;if(t==null||typeof t!="object")return String(t);if(t instanceof ArrayBuffer||ArrayBuffer.isView(t))return`${t.constructor?.name??""}#${I(t)}[${t.byteLength}]`;if(t instanceof RegExp)return M(String(t),A);if(t instanceof Date)return pt(t);if(t instanceof Object){if(n.has(t)||m!=null&&U>=m)return`${t.constructor===Object?"":t.constructor?.name??""}#${I(t)}`;n.add(t)}if(t instanceof Error)return M(t.stack||t.message||String(t),A);if(Array.isArray(t)){const u=o?" ".repeat(U):"";let s="";O&&(s+=`#${I(t)} `),s+="[";let l=0,g=!1;for(let d=0;d<t.length;d++){if(a!=null&&l>=a){g=!0;break}const y=[...r,String(d)],w=rt(t,d);if(i!=null&&!i(y,w))continue;const R=k(w,e,y,n);l>0&&(s+=","),o&&(s+=`
|
|
2
|
+
`),o&&(s+=`${u} `),C&&(s+=`${d}: `),s+=`${R}`,l++}return g?(l>0&&(s+=","),o?(s+=`
|
|
3
|
+
`,s+=`${u} ...
|
|
4
|
+
`):s+="...",s+=u,s+="]"):(l>0&&o&&(s+=`
|
|
5
|
+
${u}`),s+="]"),s}if(t instanceof Map){let u="";return O&&(u+=`#${I(t)} `),u+="Map",u+=k(Array.from(t.entries()),e,r,n),u}if(t instanceof Set){let u="";return O&&(u+=`#${I(t)} `),u+="Set",u+=k(Array.from(t.values()),e,r,n),u}{const u=t.constructor===Object?"":t.constructor?.name??"",s=o?" ".repeat(U):"";let l=u?`${u} `:"";O&&(l+=`#${I(t)} `),l+="{";let g=0,d=!1;for(const y in t){if(a!=null&&g>=a){d=!0;break}const w=[...r,y],R=rt(t,y);if(i!=null&&!i(w,R))continue;const f=k(R,e,w,n);g>0&&(l+=","),o&&(l+=`
|
|
6
|
+
`),o&&(l+=`${s} `),l+=`${y}: ${f}`,g++}return d&&(g>0&&(l+=","),o?(l+=`
|
|
7
|
+
`,l+=`${s} ...
|
|
8
|
+
`):l+="...",l+=s),g>0&&o&&!d&&(l+=`
|
|
9
|
+
${s}`),l+="}",l}}function zt(t,e){t=tt(t,"UTC",e);const r=t.getUTCFullYear().toString().padStart(4,"0"),n=(t.getUTCMonth()+1).toString().padStart(2,"0"),o=t.getUTCDate().toString().padStart(2,"0"),i=t.getUTCHours().toString().padStart(2,"0"),m=t.getUTCMinutes().toString().padStart(2,"0"),a=t.getUTCSeconds().toString().padStart(2,"0");return`${r}-${n}-${o}_${i}-${m}-${a}`}function Gt(t){return t==null?null:t.replace(/[&<>"']/g,e=>{switch(e){case"&":return"&";case"<":return"<";case">":return"&rt;";case'"':return""";default:return"'"}})}function Ht(t){return t==null?null:t?.replace(/[/\\^$*+?.()|[\]{}]/g,"\\$&")}function Q(t){if(t==null)return null;if(Array.isArray(t)){const e=t.length,r=[];for(let n=0;n<e;n++)r.push(Q(t[n]));return r}if(typeof t=="object"){if(t.constructor&&t.constructor!==Object)return t;const e={};for(const r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=Q(t[r]));return e}return t}function x(t,e){if(t===e)return!0;if(t==null)return e==null;if(e==null)return!1;if(Array.isArray(t)){if(!Array.isArray(e))return!1;const r=t.length;if(r!==e.length)return!1;for(let n=0;n<r;n++)if(!x(t[n],e[n]))return!1;return!0}if(typeof t=="object"){if(typeof e!="object"||t.constructor&&t.constructor!==Object||e.constructor&&e.constructor!==Object)return!1;for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&!x(t[r],Object.prototype.hasOwnProperty.call(e,r)?e[r]:null))return!1;for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&!Object.prototype.hasOwnProperty.call(t,r)&&!x(e[r],null))return!1;return!0}return!1}function Wt(t,e){if(t==null||e==null)return t==null==(e==null);if(t.size!==e.size)return!1;for(const[r,n]of t)if(!x(n,e.get(r)))return!1;return!0}function Jt(t,e){const r=t.length;if(r!==e.length)return!1;for(let n=0;n<r;n++)if(t[n]!==e[n])return!1;return!0}function Z(t){return!t||typeof t!="object"?t:Array.isArray(t)?t.map(Z):t&&Object.keys(t).sort().reduce((e,r)=>{const n=Z(t[r]);return n!=null&&(e[r]=n),e},{})}function bt(t,e){return Object.defineProperty(t,"name",{value:e,configurable:!0}),t}function Xt(t){const e=alert;return window.alert=r=>t(e,r),()=>{window.alert=e}}var et=(t=>(t.log="log",t.warn="warn",t.error="error",t.info="info",t.debug="debug",t.trace="trace",t.assert="assert",t))(et||{});const nt=Object.values(et);function E(t){return function(){t.apply(console,arguments)}}const ot={log:E(console.log),warn:E(console.warn),error:E(console.error),info:E(console.info),debug:E(console.debug),trace:E(console.trace),assert:E(console.assert)};function gt(t){return nt.forEach(e=>{console[e]=(...r)=>{t(ot,e,r)}}),()=>{nt.forEach(e=>{console[e]=ot[e]})}}function Yt(t){return function(r){const n=gt(t);try{const o=r();return K.isPromiseLike(o)?o.then(i=>(n(),i),i=>{throw n(),i}):o}finally{n()}}}function yt(){let t=new Error().stack;if(t!=null){const e=t.indexOf(`
|
|
10
|
+
`);e!=null&&e>=0&&(t=t.substring(e+1))}return t??""}function Qt(t){return function(...e){const r=yt();try{return t.apply(this,e)}catch(n){throw n instanceof Error||(n=new Error(String(n))),n.stack=n.stack?n.stack+`
|
|
11
|
+
`+r:r,n}}}function wt(t){if(!t||t.timeout==null)return null;const e=new z.AbortControllerFast,r=t.timeController??At.timeControllerDefault;if(t.timeout){const n=r.setTimeout(()=>{e.abort(new z.AbortError(`[timeoutAbortController] Timeout error: ${t.timeout}ms`))},t.timeout);e.signal.subscribe(()=>{clearTimeout(n)})}return t.abortSignal?.subscribe(n=>{e.abort(n)}),e}async function Zt(t,e){const r=wt(e);try{return await t(r?.signal??e?.abortSignal??null)}finally{r?.abort()}}class Kt{_options;_hasValue=!1;_promiseOrValue=null;constructor(e){this._options=e}run(){if(!this._hasValue){let e=this._options.func();const r=o=>(this._options.persist?this._promiseOrValue=o:(this._promiseOrValue=null,this._hasValue=!1),o),n=o=>{throw this._options.persist||(this._promiseOrValue=null,this._hasValue=!1),o};if(K.isPromiseLike(e))e=e.then(r,n);else if(!this._options.persist)return e;this._promiseOrValue=e,this._hasValue=!0}return this._promiseOrValue}set(e){if(!this._options.persist)throw new Error("[Lazy][set] Cannot set value when persist is false");this._hasValue=!0,this._promiseOrValue=e}}class vt{_options;_promiseOrValues=new Map;constructor(e){this._options=e}run(e){if(this._promiseOrValues.has(e))return this._promiseOrValues.get(e);let r=this._options.func(e);const n=i=>(this._options.persist?this._promiseOrValues.set(e,i):this._promiseOrValues.delete(e),i),o=i=>{throw this._options.persist||this._promiseOrValues.delete(e),i};if(K.isPromiseLike(r))r=r.then(n,o);else if(!this._options.persist)return r;return this._promiseOrValues.set(e,r),r}set(e,r){if(!this._options.persist)throw new Error("[LazyWithId][set] Cannot set value when persist is false");this._promiseOrValues.set(e,r)}}function it(t){return t.replace(/\W/g,"").toLowerCase()}function St(t){return t instanceof URL?t.searchParams:t instanceof URLSearchParams?t:typeof t=="string"?new URL(t).searchParams:typeof window<"u"?new URL(window.location.href).searchParams:new URLSearchParams}function _t(t){return t==null?null:(t=t.toLowerCase().trim(),t==="true"||t==="1"||t==="yes"?!0:t==="false"||t==="0"||t==="no"?!1:null)}function Ot(t){if(t==null)return null;t=t.trim();const e=parseInt(t,10);return isNaN(e)?null:e}function Ut(t){if(t==null)return null;t=t.trim();const e=parseFloat(t);return isNaN(e)?null:e}function H(t,e){const r=St(e),n=it(t);for(const[o,i]of r.entries())if(it(o)===n)return i;return null}function jt(t,e){return _t(H(t,e))}function te(t,e){return Ot(H(t,e))}function ee(t,e){return Ut(H(t,e))}exports.ConsoleMessageLevel=et;exports.Lazy=Kt;exports.LazyWithId=vt;exports.Random=G;exports.UNIQUE_PSEUDO_RANDOM_MAX_COUNT=V;exports.alertReplace=Xt;exports.consoleReplace=gt;exports.convertTimeZone=tt;exports.createUniquePseudoRandom=Ft;exports.dateNowUnique=qt;exports.deepCloneJsonLike=Q;exports.deepEqualJsonLike=x;exports.deepEqualJsonLikeMap=Wt;exports.equalArray=Jt;exports.escapeHtml=Gt;exports.escapeRegExp=Ht;exports.fixStackTrace=Qt;exports.formatAny=k;exports.formatDate=pt;exports.formatDateFileName=zt;exports.getDateInet=Bt;exports.getNormalizedObject=Z;exports.getRandomFunc=ht;exports.getRandomSeed=Pt;exports.getStackTrace=yt;exports.max=ft;exports.min=ct;exports.minMax=Rt;exports.numberMod=It;exports.randomBoolean=Mt;exports.randomEnum=Lt;exports.randomFloat=v;exports.randomIndexWeighted=xt;exports.randomInt=mt;exports.randomItem=j;exports.randomItems=Dt;exports.setFuncName=bt;exports.sha256=Ct;exports.sha256Buffer=at;exports.timeoutAbortController=wt;exports.toHex=st;exports.truncateString=M;exports.urlGetBoolean=jt;exports.urlGetFloat=ee;exports.urlGetInt=te;exports.urlGetParams=St;exports.urlGetString=H;exports.urlParamToBoolean=_t;exports.urlParamToFloat=Ut;exports.urlParamToInt=Ot;exports.withConsoleReplace=Yt;exports.withTimeout=Zt;
|