@idlebox/common 1.3.23 → 1.3.26
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/lib/cjs/__create_index.generated.cjs +73 -57
- package/lib/cjs/__create_index.generated.cjs.map +1 -1
- package/lib/cjs/__create_index.generated.d.cts +62 -5
- package/lib/cjs/debugging/tryInspect.cjs +4 -1
- package/lib/cjs/debugging/tryInspect.cjs.map +1 -1
- package/lib/cjs/error/pretty.cjs +235 -0
- package/lib/cjs/error/pretty.cjs.map +10 -0
- package/lib/cjs/lifecycle/dispose/disposedError.cjs +15 -2
- package/lib/cjs/lifecycle/dispose/disposedError.cjs.map +1 -1
- package/lib/cjs/lifecycle/dispose/lifecycle.async.cjs +9 -4
- package/lib/cjs/lifecycle/dispose/lifecycle.async.cjs.map +1 -1
- package/lib/cjs/lifecycle/dispose/lifecycle.sync.cjs +10 -2
- package/lib/cjs/lifecycle/dispose/lifecycle.sync.cjs.map +1 -1
- package/lib/cjs/path/normalizePath.cjs +116 -4
- package/lib/cjs/path/normalizePath.cjs.map +1 -1
- package/lib/cjs/promise/{promisePool.cjs → promiseCollection.cjs} +4 -4
- package/lib/cjs/promise/promiseCollection.cjs.map +10 -0
- package/lib/cjs/promise/{timeoutPromisePool.cjs → timeoutPromiseCollection.cjs} +5 -5
- package/lib/cjs/promise/timeoutPromiseCollection.cjs.map +10 -0
- package/lib/cjs/state/StateMachine.cjs +34 -0
- package/lib/cjs/state/StateMachine.cjs.map +10 -0
- package/lib/esm/__create_index.generated.d.mts +62 -5
- package/lib/esm/__create_index.generated.mjs +41 -32
- package/lib/esm/__create_index.generated.mjs.map +1 -1
- package/lib/esm/debugging/tryInspect.mjs +4 -1
- package/lib/esm/debugging/tryInspect.mjs.map +1 -1
- package/lib/esm/error/pretty.mjs +229 -0
- package/lib/esm/error/pretty.mjs.map +10 -0
- package/lib/esm/lifecycle/dispose/disposedError.mjs +15 -2
- package/lib/esm/lifecycle/dispose/disposedError.mjs.map +1 -1
- package/lib/esm/lifecycle/dispose/lifecycle.async.mjs +9 -4
- package/lib/esm/lifecycle/dispose/lifecycle.async.mjs.map +1 -1
- package/lib/esm/lifecycle/dispose/lifecycle.sync.mjs +10 -2
- package/lib/esm/lifecycle/dispose/lifecycle.sync.mjs.map +1 -1
- package/lib/esm/path/normalizePath.mjs +113 -3
- package/lib/esm/path/normalizePath.mjs.map +1 -1
- package/lib/esm/promise/{promisePool.mjs → promiseCollection.mjs} +2 -2
- package/lib/esm/promise/promiseCollection.mjs.map +10 -0
- package/lib/esm/promise/{timeoutPromisePool.mjs → timeoutPromiseCollection.mjs} +3 -3
- package/lib/esm/promise/timeoutPromiseCollection.mjs.map +10 -0
- package/lib/esm/state/StateMachine.mjs +30 -0
- package/lib/esm/state/StateMachine.mjs.map +10 -0
- package/package.json +4 -4
- package/src/debugging/tryInspect.ts +3 -1
- package/src/error/pretty.ts +249 -0
- package/src/lifecycle/dispose/disposedError.ts +20 -3
- package/src/lifecycle/dispose/lifecycle.async.ts +14 -3
- package/src/lifecycle/dispose/lifecycle.sync.ts +18 -4
- package/src/lifecycle/dispose/lifecycle.ts +1 -1
- package/src/path/normalizePath.ts +126 -3
- package/src/promise/{promisePool.ts → promiseCollection.ts} +1 -1
- package/src/promise/{timeoutPromisePool.ts → timeoutPromiseCollection.ts} +2 -2
- package/src/state/StateMachine.ts +52 -0
- package/lib/cjs/promise/promisePool.cjs.map +0 -10
- package/lib/cjs/promise/timeoutPromisePool.cjs.map +0 -10
- package/lib/esm/promise/promisePool.mjs.map +0 -10
- package/lib/esm/promise/timeoutPromisePool.mjs.map +0 -10
|
@@ -2,6 +2,8 @@ export declare function addDisposableEventListener<T extends Function>(target: I
|
|
|
2
2
|
|
|
3
3
|
export declare function addDisposableEventListener<T extends Function>(target: IEventHostObject<T> | IEventEmitterObject<T>, type: string, handler: T): IDisposable;
|
|
4
4
|
|
|
5
|
+
export declare function analyzePath(p: string): IPathInfo;
|
|
6
|
+
|
|
5
7
|
/**
|
|
6
8
|
* Compare two array, returns the difference from `before` to `after`
|
|
7
9
|
* @public
|
|
@@ -66,7 +68,7 @@ export declare class AsyncCallbackList<Argument extends unknown[]> {
|
|
|
66
68
|
* Async version of Disposable
|
|
67
69
|
* @public
|
|
68
70
|
*/
|
|
69
|
-
export declare class AsyncDisposable implements IAsyncDisposable,
|
|
71
|
+
export declare class AsyncDisposable implements IAsyncDisposable, IDisposableEvents {
|
|
70
72
|
private readonly _disposables;
|
|
71
73
|
protected readonly _onDisposeError: Emitter<Error>;
|
|
72
74
|
readonly onDisposeError: EventRegister<Error>;
|
|
@@ -82,6 +84,8 @@ export declare class AsyncDisposable implements IAsyncDisposable, IDisposableBas
|
|
|
82
84
|
* register a disposable object
|
|
83
85
|
*/
|
|
84
86
|
_register<T extends IAsyncDisposable>(d: T): T;
|
|
87
|
+
_register<T extends IAsyncDisposable & IDisposableEvents>(d: T, autoDereference?: boolean): T;
|
|
88
|
+
_unregister(d: IAsyncDisposable): boolean;
|
|
85
89
|
dispose(): Promise<void>;
|
|
86
90
|
}
|
|
87
91
|
|
|
@@ -343,7 +347,7 @@ export declare function deleteSymbol(category: string, name: string): void;
|
|
|
343
347
|
/**
|
|
344
348
|
* Standalone disposable class, can use as instance or base class.
|
|
345
349
|
*/
|
|
346
|
-
export declare class Disposable implements IDisposable,
|
|
350
|
+
export declare class Disposable implements IDisposable, IDisposableEvents {
|
|
347
351
|
private readonly _disposables;
|
|
348
352
|
protected readonly _onDisposeError: Emitter<Error>;
|
|
349
353
|
readonly onDisposeError: EventRegister<Error>;
|
|
@@ -355,7 +359,12 @@ export declare class Disposable implements IDisposable, IDisposableBaseInternal
|
|
|
355
359
|
* @throws if already disposed
|
|
356
360
|
*/
|
|
357
361
|
assertNotDisposed(): void;
|
|
362
|
+
/**
|
|
363
|
+
* register a disposable object
|
|
364
|
+
*/
|
|
358
365
|
_register<T extends IDisposable>(d: T): T;
|
|
366
|
+
_register<T extends IDisposable & IDisposableEvents>(d: T, autoDereference?: boolean): T;
|
|
367
|
+
_unregister(d: IDisposable): boolean;
|
|
359
368
|
dispose(): void;
|
|
360
369
|
}
|
|
361
370
|
|
|
@@ -370,7 +379,10 @@ export declare abstract class DisposableOnce implements IDisposable {
|
|
|
370
379
|
* Error when call dispose() twice
|
|
371
380
|
*/
|
|
372
381
|
export declare class DisposedError extends Error {
|
|
382
|
+
readonly previous: Error;
|
|
383
|
+
readonly inspectString: string;
|
|
373
384
|
constructor(object: any, previous: Error);
|
|
385
|
+
tryCreateConsoleWarning(): Promise<void>;
|
|
374
386
|
}
|
|
375
387
|
|
|
376
388
|
/**
|
|
@@ -618,7 +630,7 @@ export declare interface IDisposable {
|
|
|
618
630
|
/**
|
|
619
631
|
* @private
|
|
620
632
|
*/
|
|
621
|
-
export declare interface
|
|
633
|
+
export declare interface IDisposableEvents {
|
|
622
634
|
onDisposeError: EventRegister<Error>;
|
|
623
635
|
onBeforeDispose: EventRegister<void>;
|
|
624
636
|
readonly hasDisposed: boolean;
|
|
@@ -640,6 +652,8 @@ export declare interface IEventListenerOptions {
|
|
|
640
652
|
passive?: boolean;
|
|
641
653
|
}
|
|
642
654
|
|
|
655
|
+
export declare type IFsmRuleMap<StateType, EventType> = MapLike_2<StateType, MapLike_2<EventType, StateType>>;
|
|
656
|
+
|
|
643
657
|
declare interface IHooks<T, TC> {
|
|
644
658
|
afterConstruct?: ((obj: T) => void)[];
|
|
645
659
|
beforeConstruct?: ((obj: TC) => T | void)[];
|
|
@@ -723,6 +737,13 @@ export declare interface IPackageJson {
|
|
|
723
737
|
[field: string]: any;
|
|
724
738
|
}
|
|
725
739
|
|
|
740
|
+
export declare interface IPathInfo {
|
|
741
|
+
kind: PathKind;
|
|
742
|
+
prefix?: string;
|
|
743
|
+
path: string;
|
|
744
|
+
url?: URL;
|
|
745
|
+
}
|
|
746
|
+
|
|
726
747
|
export declare interface IProgressHolder<T, PT> {
|
|
727
748
|
progress(fn: ProgressCallback<PT>): Promise<T> & IProgressHolder<T, PT>;
|
|
728
749
|
}
|
|
@@ -787,6 +808,12 @@ export declare function isScalar(value: any): value is ScalarTypes;
|
|
|
787
808
|
|
|
788
809
|
export declare function isSerializable(value: any): SerializableKind;
|
|
789
810
|
|
|
811
|
+
export declare interface IStateChangeEvent<StateType, EventType> {
|
|
812
|
+
from: StateType;
|
|
813
|
+
to: StateType;
|
|
814
|
+
reason: EventType;
|
|
815
|
+
}
|
|
816
|
+
|
|
790
817
|
/** @public */
|
|
791
818
|
export declare function isTimeoutError(error: Error): error is TimeoutError;
|
|
792
819
|
|
|
@@ -814,6 +841,8 @@ export declare interface MapLike<V> {
|
|
|
814
841
|
[id: string]: V;
|
|
815
842
|
}
|
|
816
843
|
|
|
844
|
+
declare type MapLike_2<K, V> = Pick<Map<K, V>, 'get' | 'has' | 'keys'>;
|
|
845
|
+
|
|
817
846
|
declare type MaybeArray<T> = T | T[];
|
|
818
847
|
|
|
819
848
|
export declare interface MaybeNamedFunction extends Function {
|
|
@@ -961,12 +990,25 @@ export declare class PathArrayWindows extends PathArrayAbstract {
|
|
|
961
990
|
values(): IterableIterator<string>;
|
|
962
991
|
}
|
|
963
992
|
|
|
993
|
+
export declare enum PathKind {
|
|
994
|
+
url = 0,
|
|
995
|
+
unc = 1,
|
|
996
|
+
win = 2,
|
|
997
|
+
cifs = 3,
|
|
998
|
+
unix = 4,
|
|
999
|
+
relative = 5
|
|
1000
|
+
}
|
|
1001
|
+
|
|
964
1002
|
declare type Person = StructString<{
|
|
965
1003
|
name: string;
|
|
966
1004
|
email: string;
|
|
967
1005
|
url: string;
|
|
968
1006
|
}>;
|
|
969
1007
|
|
|
1008
|
+
export declare function prettyFormatError(e: Error, withMessage?: boolean): string;
|
|
1009
|
+
|
|
1010
|
+
export declare function prettyPrintError(type: string, e: Error): void;
|
|
1011
|
+
|
|
970
1012
|
export declare type Primitive = undefined | null | boolean | string | number | Function | bigint;
|
|
971
1013
|
|
|
972
1014
|
export declare type ProgressCallback<T = any> = (value: T) => void;
|
|
@@ -977,7 +1019,7 @@ export declare type ProgressCallback<T = any> = (value: T) => void;
|
|
|
977
1019
|
*/
|
|
978
1020
|
export declare function promiseBool(p: Promise<any>): Promise<boolean>;
|
|
979
1021
|
|
|
980
|
-
export declare class
|
|
1022
|
+
export declare class PromiseCollection {
|
|
981
1023
|
protected readonly promiseList: Record<string, DeferredPromise<any>>;
|
|
982
1024
|
size(): number;
|
|
983
1025
|
create(id: string): Promise<any> & IProgressHolder<any, any>;
|
|
@@ -1003,6 +1045,8 @@ export declare function RegexpFinder(this: RegExp[], item: RegExp): number;
|
|
|
1003
1045
|
*/
|
|
1004
1046
|
export declare function registerGlobalLifecycle(object: IDisposable): void;
|
|
1005
1047
|
|
|
1048
|
+
export declare function relativePath(from: string, to: string): string;
|
|
1049
|
+
|
|
1006
1050
|
declare type ScalarTypes = bigint | number | Number | boolean | Boolean | string | String | symbol | undefined | null | Date | RegExp | Function;
|
|
1007
1051
|
|
|
1008
1052
|
export declare const sepList: string;
|
|
@@ -1014,6 +1058,19 @@ export declare enum SerializableKind {
|
|
|
1014
1058
|
Other = 3
|
|
1015
1059
|
}
|
|
1016
1060
|
|
|
1061
|
+
export declare function setErrorLogRoot(_root: string): void;
|
|
1062
|
+
|
|
1063
|
+
export declare class SimpleStateMachine<StateType, EventType> {
|
|
1064
|
+
protected currentState: StateType;
|
|
1065
|
+
protected readonly rules: IFsmRuleMap<StateType, EventType>;
|
|
1066
|
+
private readonly _onStateChange;
|
|
1067
|
+
readonly onStateChange: EventRegister<IStateChangeEvent<StateType, EventType>>;
|
|
1068
|
+
constructor(rules: IFsmRuleMap<StateType, EventType>, init_state: StateType);
|
|
1069
|
+
protected moveTo(state: StateType): void;
|
|
1070
|
+
getName(): StateType;
|
|
1071
|
+
change(event: EventType): void;
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1017
1074
|
export declare function singleton(type?: SingletonType): ClassDecorator;
|
|
1018
1075
|
|
|
1019
1076
|
export declare const singletonSymbol: unique symbol;
|
|
@@ -1068,7 +1125,7 @@ export declare function timeoutPromise<T, PT = any>(ms: number, p: DeferredPromi
|
|
|
1068
1125
|
|
|
1069
1126
|
export declare function timeoutPromise<T, PT = any>(ms: number, message: string, p: DeferredPromise<T, PT>): DeferredPromise<T, PT>;
|
|
1070
1127
|
|
|
1071
|
-
export declare class
|
|
1128
|
+
export declare class TimeoutPromiseCollection extends PromiseCollection {
|
|
1072
1129
|
private readonly defaultTimeoutMs;
|
|
1073
1130
|
constructor(defaultTimeoutMs?: number);
|
|
1074
1131
|
create(id: string, timeoutMs?: number, timeoutMsg?: string): Promise<any> & IProgressHolder<any, any>;
|
|
@@ -61,6 +61,42 @@ export { getErrorFrame } from "./error/getFrame.mjs";
|
|
|
61
61
|
/* error/convertUnknown.ts */
|
|
62
62
|
// Identifiers
|
|
63
63
|
export { convertCatchedError } from "./error/convertUnknown.mjs";
|
|
64
|
+
/* path/isAbsolute.ts */
|
|
65
|
+
// Identifiers
|
|
66
|
+
export { isAbsolute } from "./path/isAbsolute.mjs";
|
|
67
|
+
/* path/normalizePath.ts */
|
|
68
|
+
// Identifiers
|
|
69
|
+
export { PathKind } from "./path/normalizePath.mjs";
|
|
70
|
+
export { analyzePath } from "./path/normalizePath.mjs";
|
|
71
|
+
export { normalizePath } from "./path/normalizePath.mjs";
|
|
72
|
+
export { relativePath } from "./path/normalizePath.mjs";
|
|
73
|
+
/* platform/globalObject.ts */
|
|
74
|
+
// Identifiers
|
|
75
|
+
export { globalObject } from "./platform/globalObject.mjs";
|
|
76
|
+
export { ensureGlobalObject } from "./platform/globalObject.mjs";
|
|
77
|
+
export { x } from "./platform/globalObject.mjs";
|
|
78
|
+
/* platform/os.ts */
|
|
79
|
+
// Identifiers
|
|
80
|
+
export { hasProcess } from "./platform/os.mjs";
|
|
81
|
+
export { hasWindow } from "./platform/os.mjs";
|
|
82
|
+
export { hasGlobal } from "./platform/os.mjs";
|
|
83
|
+
export { isElectron } from "./platform/os.mjs";
|
|
84
|
+
export { isElectronSandbox } from "./platform/os.mjs";
|
|
85
|
+
export { isElectronRenderer } from "./platform/os.mjs";
|
|
86
|
+
export { isElectronMain } from "./platform/os.mjs";
|
|
87
|
+
export { isWindows } from "./platform/os.mjs";
|
|
88
|
+
export { isMacintosh } from "./platform/os.mjs";
|
|
89
|
+
export { isLinux } from "./platform/os.mjs";
|
|
90
|
+
export { isNative } from "./platform/os.mjs";
|
|
91
|
+
export { isWeb } from "./platform/os.mjs";
|
|
92
|
+
export { is64Bit } from "./platform/os.mjs";
|
|
93
|
+
export { sepList } from "./platform/os.mjs";
|
|
94
|
+
export { is32Bit } from "./platform/os.mjs";
|
|
95
|
+
/* error/pretty.ts */
|
|
96
|
+
// Identifiers
|
|
97
|
+
export { setErrorLogRoot } from "./error/pretty.mjs";
|
|
98
|
+
export { prettyPrintError } from "./error/pretty.mjs";
|
|
99
|
+
export { prettyFormatError } from "./error/pretty.mjs";
|
|
64
100
|
export { functionName } from "./function/functionName.mjs";
|
|
65
101
|
export { nameFunction } from "./function/functionName.mjs";
|
|
66
102
|
export { assertFunctionHasName } from "./function/functionName.mjs";
|
|
@@ -77,11 +113,6 @@ export { isDisposedError } from "./lifecycle/dispose/disposedError.mjs";
|
|
|
77
113
|
/* lifecycle/dispose/lifecycle.async.ts */
|
|
78
114
|
// Identifiers
|
|
79
115
|
export { AsyncDisposable } from "./lifecycle/dispose/lifecycle.async.mjs";
|
|
80
|
-
/* platform/globalObject.ts */
|
|
81
|
-
// Identifiers
|
|
82
|
-
export { globalObject } from "./platform/globalObject.mjs";
|
|
83
|
-
export { ensureGlobalObject } from "./platform/globalObject.mjs";
|
|
84
|
-
export { x } from "./platform/globalObject.mjs";
|
|
85
116
|
/* platform/globalSingleton.ts */
|
|
86
117
|
// Identifiers
|
|
87
118
|
export { globalSingletonStrong } from "./platform/globalSingleton.mjs";
|
|
@@ -124,23 +155,6 @@ export { isTimeoutError } from "./lifecycle/timeout/timeoutError.mjs";
|
|
|
124
155
|
export { timeout } from "./lifecycle/timeout/timeout.mjs";
|
|
125
156
|
export { sleep } from "./lifecycle/timeout/timeout.mjs";
|
|
126
157
|
export { timeoutPromise } from "./lifecycle/timeout/timeout.mjs";
|
|
127
|
-
/* platform/os.ts */
|
|
128
|
-
// Identifiers
|
|
129
|
-
export { hasProcess } from "./platform/os.mjs";
|
|
130
|
-
export { hasWindow } from "./platform/os.mjs";
|
|
131
|
-
export { hasGlobal } from "./platform/os.mjs";
|
|
132
|
-
export { isElectron } from "./platform/os.mjs";
|
|
133
|
-
export { isElectronSandbox } from "./platform/os.mjs";
|
|
134
|
-
export { isElectronRenderer } from "./platform/os.mjs";
|
|
135
|
-
export { isElectronMain } from "./platform/os.mjs";
|
|
136
|
-
export { isWindows } from "./platform/os.mjs";
|
|
137
|
-
export { isMacintosh } from "./platform/os.mjs";
|
|
138
|
-
export { isLinux } from "./platform/os.mjs";
|
|
139
|
-
export { isNative } from "./platform/os.mjs";
|
|
140
|
-
export { isWeb } from "./platform/os.mjs";
|
|
141
|
-
export { is64Bit } from "./platform/os.mjs";
|
|
142
|
-
export { sepList } from "./platform/os.mjs";
|
|
143
|
-
export { is32Bit } from "./platform/os.mjs";
|
|
144
158
|
/* log/logger.ts */
|
|
145
159
|
// Identifiers
|
|
146
160
|
export { ColorKind } from "./log/logger.mjs";
|
|
@@ -163,12 +177,6 @@ export { objectPath } from "./object/objectPath.mjs";
|
|
|
163
177
|
// Identifiers
|
|
164
178
|
export { isObjectSame } from "./object/objectSame.mjs";
|
|
165
179
|
export { isObjectSameRecursive } from "./object/objectSame.mjs";
|
|
166
|
-
/* path/isAbsolute.ts */
|
|
167
|
-
// Identifiers
|
|
168
|
-
export { isAbsolute } from "./path/isAbsolute.mjs";
|
|
169
|
-
/* path/normalizePath.ts */
|
|
170
|
-
// Identifiers
|
|
171
|
-
export { normalizePath } from "./path/normalizePath.mjs";
|
|
172
180
|
/* string/castCase.ts */
|
|
173
181
|
// Identifiers
|
|
174
182
|
export { camelCase } from "./string/castCase.mjs";
|
|
@@ -188,12 +196,12 @@ export { finishAllPromise } from "./promise/finishAllPromise.mjs";
|
|
|
188
196
|
/* promise/promiseBool.ts */
|
|
189
197
|
// Identifiers
|
|
190
198
|
export { promiseBool } from "./promise/promiseBool.mjs";
|
|
191
|
-
/* promise/
|
|
199
|
+
/* promise/promiseCollection.ts */
|
|
192
200
|
// Identifiers
|
|
193
|
-
export {
|
|
194
|
-
/* promise/
|
|
201
|
+
export { PromiseCollection } from "./promise/promiseCollection.mjs";
|
|
202
|
+
/* promise/timeoutPromiseCollection.ts */
|
|
195
203
|
// Identifiers
|
|
196
|
-
export {
|
|
204
|
+
export { TimeoutPromiseCollection } from "./promise/timeoutPromiseCollection.mjs";
|
|
197
205
|
/* reflection/classes/hookClass.ts */
|
|
198
206
|
// Identifiers
|
|
199
207
|
export { hookClassSymbol } from "./reflection/classes/hookClass.mjs";
|
|
@@ -213,6 +221,7 @@ export { init } from "./reflection/methods/initOnRead.mjs";
|
|
|
213
221
|
// Identifiers
|
|
214
222
|
export { memorizeValueSymbol } from "./reflection/methods/memorize.mjs";
|
|
215
223
|
export { memo } from "./reflection/methods/memorize.mjs";
|
|
224
|
+
export { SimpleStateMachine } from "./state/StateMachine.mjs";
|
|
216
225
|
/* string/concatType.generated.ts */
|
|
217
226
|
// Identifiers
|
|
218
227
|
export { concatStringType } from "./string/concatType.generated.mjs";
|
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
"../../src/__create_index.generated.ts"
|
|
7
7
|
],
|
|
8
8
|
"names": [],
|
|
9
|
-
"mappings": "AAAA,wBAAwB;AACxB,aAAa;AACb,oBAAoB;AAKnB,OAAO,EAAC,SAAS,EAAC,8BAA6B;AAChD,wBAAwB;AACvB,cAAc;AACd,OAAO,EAAC,WAAW,EAAC,8BAA6B;AAClD,0BAA0B;AACzB,cAAc;AACd,OAAO,EAAC,WAAW,EAAC,gCAA+B;AACnD,OAAO,EAAC,oBAAoB,EAAC,gCAA+B;AAE5D,OAAO,EAAC,YAA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SAAS,EAAC,2CAA0C;AAC7D,gCAAgC;AAC/B,cAAc;AACd,OAAO,EAAC,QAAQ,EAAC,sCAAqC;AACvD,sCAAsC;AACrC,cAAc;AACd,OAAO,EAAC,IAAI,EAAC,4CAA2C;AACzD,oCAAoC;AACnC,cAAc;AACd,OAAO,EAAC,mBAAmB,EAAC,0CAAyC;AACrE,OAAO,EAAC,IAAI,EAAC,0CAAyC;AAKtD,OAAO,EAAC,kBAAkB,EAAC,iCAAgC;AAC5D,oCAAoC;AACnC,cAAc;AACd,OAAO,EAAC,gBAAgB,EAAC,0CAAyC;AACnE,4BAA4B;AAC3B,cAAc;AACd,OAAO,EAAC,YAAY,EAAC,kCAAiC;AACvD,0BAA0B;AACzB,cAAc;AACd,OAAO,EAAC,WAAW,EAAC,gCAA+B;AACnD,OAAO,EAAC,SAAS,EAAC,gCAA+B;AACjD,OAAO,EAAC,UAAU,EAAC,gCAA+B"
|
|
10
10
|
}
|
|
@@ -32,8 +32,11 @@ export function tryInspect(object) {
|
|
|
32
32
|
else if (object.toJSON) {
|
|
33
33
|
return object.toJSON();
|
|
34
34
|
}
|
|
35
|
+
else if (object.constructor?.name) {
|
|
36
|
+
return `unknown: ${object.constructor.name}`;
|
|
37
|
+
}
|
|
35
38
|
else {
|
|
36
|
-
return '' + object;
|
|
39
|
+
return 'unknown: ' + object;
|
|
37
40
|
}
|
|
38
41
|
}
|
|
39
42
|
//# sourceMappingURL=tryInspect.mjs.map
|
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
"../../../src/debugging/tryInspect.ts"
|
|
7
7
|
],
|
|
8
8
|
"names": [],
|
|
9
|
-
"mappings": "AAAA,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC,CAAC,oBAAoB;AAC9E,MAAM,UAAU,GAAG,YAAY,EAAE,CAAC;AAIlC,SAAS,YAAY;IACpB,IAAI;QACH,MAAM,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC;QACzB,OAA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O,MAAM,KAAK,QAAQ,EAAE;QAC1C,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;KAC9B;IAED,IAAI,MAAM,CAAC,OAAO,CAAC,EAAE;QACpB,OAAO,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;KACzB;SAAM,IAAI,UAAU,IAAI,MAAM,CAAC,UAAU,CAAC,EAAE;QAC5C,OAAO,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC;KAC5B;SAAM,IAAI,MAAM,CAAC,SAAS,CAAC,EAAE;QAC7B,OAAO,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC;KAC3B;SAAM,IAAI,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE;QACtC,OAAO,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC;KACpC;SAAM,IAAI,MAAM,CAAC,MAAM,EAAE;QACzB,OAAO,MAAM,CAAC,MAAM,EAAE,CAAC;KACvB;SAAM,IAAI,MAAM,CAAC,WAAW,EAAE,IAAI,EAAE;QACpC,OAAO,YAAY,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;KAC7C;SAAM;QACN,OAAO,WAAW,GAAG,MAAM,CAAC;KAC5B;AACF,CAAC"
|
|
10
10
|
}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import { isAbsolute } from "../path/isAbsolute.mjs";
|
|
2
|
+
import { relativePath } from "../path/normalizePath.mjs";
|
|
3
|
+
import { globalObject } from "../platform/globalObject.mjs";
|
|
4
|
+
import { isNative } from "../platform/os.mjs";
|
|
5
|
+
const regNormal = /^\s+at ([^\/\s]+)(?: \[as ([^\]]+)])? \(((?:node|file):\/*)?([^:]+)(:\d+)?(:\d+)\)$/;
|
|
6
|
+
const process = globalObject.process;
|
|
7
|
+
const window = globalObject.window;
|
|
8
|
+
var regNormalMatch;
|
|
9
|
+
(function (regNormalMatch) {
|
|
10
|
+
regNormalMatch[regNormalMatch["fn"] = 1] = "fn";
|
|
11
|
+
regNormalMatch[regNormalMatch["fnAlias"] = 2] = "fnAlias";
|
|
12
|
+
regNormalMatch[regNormalMatch["fileSchema"] = 3] = "fileSchema";
|
|
13
|
+
regNormalMatch[regNormalMatch["file"] = 4] = "file";
|
|
14
|
+
regNormalMatch[regNormalMatch["row"] = 5] = "row";
|
|
15
|
+
regNormalMatch[regNormalMatch["column"] = 6] = "column";
|
|
16
|
+
})(regNormalMatch || (regNormalMatch = {}));
|
|
17
|
+
const regFunctionOnly = /^\s+at ([^\/\\\s]+(?: \[as ([^\]]+)])?)$/;
|
|
18
|
+
var regFunctionMatch;
|
|
19
|
+
(function (regFunctionMatch) {
|
|
20
|
+
regFunctionMatch[regFunctionMatch["fn"] = 1] = "fn";
|
|
21
|
+
regFunctionMatch[regFunctionMatch["fnAlias"] = 2] = "fnAlias";
|
|
22
|
+
})(regFunctionMatch || (regFunctionMatch = {}));
|
|
23
|
+
const regFileOnly = /^\s+at ([^:]+)(:\d+)?(:\d+)$/;
|
|
24
|
+
var regFileOnlyMatch;
|
|
25
|
+
(function (regFileOnlyMatch) {
|
|
26
|
+
regFileOnlyMatch[regFileOnlyMatch["file"] = 1] = "file";
|
|
27
|
+
regFileOnlyMatch[regFileOnlyMatch["row"] = 2] = "row";
|
|
28
|
+
regFileOnlyMatch[regFileOnlyMatch["column"] = 3] = "column";
|
|
29
|
+
})(regFileOnlyMatch || (regFileOnlyMatch = {}));
|
|
30
|
+
const regSimpleFrame = /^\s+at ([^(]+) \(<anonymous>\)$/;
|
|
31
|
+
var regSimpleFrameMatch;
|
|
32
|
+
(function (regSimpleFrameMatch) {
|
|
33
|
+
regSimpleFrameMatch[regSimpleFrameMatch["fn"] = 1] = "fn";
|
|
34
|
+
})(regSimpleFrameMatch || (regSimpleFrameMatch = {}));
|
|
35
|
+
let root = process?.cwd() ?? window?.location?.domain ?? '/';
|
|
36
|
+
export function setErrorLogRoot(_root) {
|
|
37
|
+
root = _root;
|
|
38
|
+
}
|
|
39
|
+
let notify_printed = false;
|
|
40
|
+
export function prettyPrintError(type, e) {
|
|
41
|
+
if (globalObject.process?.env?.DISABLE_PRETTY_ERROR) {
|
|
42
|
+
console.error('[${type}] %s', e.stack || e.message);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
console.error(`------------------------------------------
|
|
46
|
+
[${type}] ${prettyFormatError(e)}`);
|
|
47
|
+
if (!notify_printed) {
|
|
48
|
+
notify_printed = true;
|
|
49
|
+
console.error('\x1B[2muse env.DISABLE_PRETTY_ERROR=yes to see original error stack\x1B[0m');
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function red(s) {
|
|
53
|
+
return isNative ? `\x1B[38;5;9m${s}\x1B[0m` : '';
|
|
54
|
+
}
|
|
55
|
+
export function prettyFormatError(e, withMessage = true) {
|
|
56
|
+
if (!e || typeof e.message !== 'string') {
|
|
57
|
+
console.error(e);
|
|
58
|
+
return red('Unknown Error') + '\n' + new Error().stack?.split('\n').slice(3).join('\n');
|
|
59
|
+
}
|
|
60
|
+
if (!e.stack) {
|
|
61
|
+
return red(e.message + '\nNo stack trace');
|
|
62
|
+
}
|
|
63
|
+
const stackStr = e.stack.replace(/file:\/\//, '').split(/\n/g);
|
|
64
|
+
let first = stackStr.shift();
|
|
65
|
+
const stack = stackStr.map((line) => {
|
|
66
|
+
if (regNormal.test(line)) {
|
|
67
|
+
const m = regNormal.exec(line);
|
|
68
|
+
return {
|
|
69
|
+
fn: m[1 /* regNormalMatch.fn */],
|
|
70
|
+
as: m[2 /* regNormalMatch.fnAlias */],
|
|
71
|
+
fileSchema: m[3 /* regNormalMatch.fileSchema */],
|
|
72
|
+
file: m[4 /* regNormalMatch.file */],
|
|
73
|
+
line: parseInt(m[5 /* regNormalMatch.row */].slice(1)),
|
|
74
|
+
col: parseInt(m[6 /* regNormalMatch.column */].slice(1)),
|
|
75
|
+
abs: isAbsolute(m[4 /* regNormalMatch.file */]),
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
else if (regFunctionOnly.test(line)) {
|
|
79
|
+
const m = regFunctionOnly.exec(line);
|
|
80
|
+
return {
|
|
81
|
+
fn: m[1 /* regFunctionMatch.fn */],
|
|
82
|
+
as: m[2 /* regFunctionMatch.fnAlias */],
|
|
83
|
+
file: undefined,
|
|
84
|
+
line: undefined,
|
|
85
|
+
col: undefined,
|
|
86
|
+
abs: false,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
else if (regFileOnly.test(line)) {
|
|
90
|
+
const m = regFileOnly.exec(line);
|
|
91
|
+
return {
|
|
92
|
+
fn: undefined,
|
|
93
|
+
as: undefined,
|
|
94
|
+
file: m[1 /* regFileOnlyMatch.file */],
|
|
95
|
+
line: parseInt(m[2 /* regFileOnlyMatch.row */].slice(1)),
|
|
96
|
+
col: parseInt(m[3 /* regFileOnlyMatch.column */].slice(1)),
|
|
97
|
+
abs: isAbsolute(m[1 /* regFileOnlyMatch.file */]),
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
else if (regSimpleFrame.test(line)) {
|
|
101
|
+
const m = regSimpleFrame.exec(line);
|
|
102
|
+
return {
|
|
103
|
+
fn: m[1 /* regSimpleFrameMatch.fn */],
|
|
104
|
+
as: undefined,
|
|
105
|
+
file: '<anonymous>',
|
|
106
|
+
line: undefined,
|
|
107
|
+
col: undefined,
|
|
108
|
+
abs: false,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
return { raw: line.replace(/^ /, '') };
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
const stackOutput = stack
|
|
116
|
+
.filter(ignoreSomeFiles)
|
|
117
|
+
.map(translateFunction)
|
|
118
|
+
.map(({ raw, fn, file, as, abs, line, col, fileSchema }) => {
|
|
119
|
+
let ret;
|
|
120
|
+
if (raw) {
|
|
121
|
+
return raw;
|
|
122
|
+
}
|
|
123
|
+
if (abs) {
|
|
124
|
+
const isNodeModule = file?.includes('/node_modules/');
|
|
125
|
+
const color = fn ? (isNodeModule ? '4' : '14') : '8';
|
|
126
|
+
ret = ` at \x1b[38;5;${color}m`;
|
|
127
|
+
if (as && fn && fn.startsWith('Object.')) {
|
|
128
|
+
ret += as + ' [export]';
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
ret += formatFunctionName(fn, as);
|
|
132
|
+
}
|
|
133
|
+
ret += '\x1b[0m';
|
|
134
|
+
if (file) {
|
|
135
|
+
ret += ' (';
|
|
136
|
+
if (!isNodeModule) {
|
|
137
|
+
ret += '\x1b[38;5;2m';
|
|
138
|
+
}
|
|
139
|
+
ret += formatFileLine(fileSchema, file, line, col);
|
|
140
|
+
ret += '\x1B[0m)';
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
ret = '\x1B[2m at ';
|
|
145
|
+
if (fn) {
|
|
146
|
+
ret += fn;
|
|
147
|
+
}
|
|
148
|
+
if (file) {
|
|
149
|
+
if (fn) {
|
|
150
|
+
ret += ' (';
|
|
151
|
+
}
|
|
152
|
+
ret += formatFileLine(fileSchema, file, line, col);
|
|
153
|
+
if (fn) {
|
|
154
|
+
ret += ')';
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
ret += '\x1B[0m';
|
|
158
|
+
}
|
|
159
|
+
return ret;
|
|
160
|
+
});
|
|
161
|
+
if (withMessage) {
|
|
162
|
+
if (e.code) {
|
|
163
|
+
first = first.replace(/^(\S+):/, (_, name) => {
|
|
164
|
+
return `${name}(code ${e.code}):`;
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
return first + '\n' + stackOutput.join('\n');
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
return stackOutput.join('\n');
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
function formatFileLine(schema, file, row, col) {
|
|
174
|
+
let rel = file;
|
|
175
|
+
if (schema !== 'node:') {
|
|
176
|
+
rel = relativePath(root, file);
|
|
177
|
+
if (rel.startsWith('..')) {
|
|
178
|
+
rel = file;
|
|
179
|
+
}
|
|
180
|
+
else if (!rel.startsWith('.')) {
|
|
181
|
+
rel = './' + rel;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return `${schema || ''}${rel}${row ? `:${row}` : ''}${col ? `:${col}` : ''}`;
|
|
185
|
+
}
|
|
186
|
+
function formatFunctionName(fn, as) {
|
|
187
|
+
if (fn) {
|
|
188
|
+
if (as) {
|
|
189
|
+
return `${fn} [as ${as}]`;
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
return fn;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
return '[anonymous]';
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
function translateFunction(data) {
|
|
200
|
+
if (!data.fn) {
|
|
201
|
+
return data;
|
|
202
|
+
}
|
|
203
|
+
if (data.fn === 'Timeout._onTimeout') {
|
|
204
|
+
data.fn = 'setTimeout';
|
|
205
|
+
}
|
|
206
|
+
if (data.fn.startsWith('Timeout.') && data.as === '_onTimeout') {
|
|
207
|
+
data.fn = 'setTimeout->' + data.fn.slice(8);
|
|
208
|
+
delete data.as;
|
|
209
|
+
}
|
|
210
|
+
return data;
|
|
211
|
+
}
|
|
212
|
+
function ignoreSomeFiles({ file }) {
|
|
213
|
+
if (!file) {
|
|
214
|
+
return true;
|
|
215
|
+
}
|
|
216
|
+
if (file === 'internal/timers.js') {
|
|
217
|
+
return false;
|
|
218
|
+
}
|
|
219
|
+
if (file.startsWith('internal/modules/cjs/loader')) {
|
|
220
|
+
return false;
|
|
221
|
+
}
|
|
222
|
+
if (!file.includes('/')) {
|
|
223
|
+
if (file.startsWith('_stream_')) {
|
|
224
|
+
return false;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return true;
|
|
228
|
+
}
|
|
229
|
+
//# sourceMappingURL=pretty.mjs.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"file": "pretty.mj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C,EAAE,GAAG,cAAc,GAAG,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC5C,OAAO,IAAI,CAAC,EAAE,CAAC;KACf;IACD,OAAO,IAAI,CAAC;AACb,CAAC;AAED,SAAS,eAAe,CAAC,EAAE,IAAI,EAAiB;IAC/C,IAAI,CAAC,IAAI,EAAE;QACV,OAAO,IAAI,CAAC;KACZ;IACD,IAAI,IAAI,KAAK,oBAAoB,EAAE;QAClC,OAAO,KAAK,CAAC;KACb;IACD,IAAI,IAAI,CAAC,UAAU,CAAC,6BAA6B,CAAC,EAAE;QACnD,OAAO,KAAK,CAAC;KACb;IACD,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;QACxB,IAAI,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE;YAChC,OAAO,KAAK,CAAC;SACb;KACD;IACD,OAAO,IAAI,CAAC;AACb,CAAC"
|
|
10
|
+
}
|
|
@@ -1,12 +1,25 @@
|
|
|
1
|
-
import { getErrorFrame } from "../../error/getFrame.mjs";
|
|
2
1
|
import { tryInspect } from "../../debugging/tryInspect.mjs";
|
|
2
|
+
import { getErrorFrame } from "../../error/getFrame.mjs";
|
|
3
|
+
import { prettyFormatError } from "../../error/pretty.mjs";
|
|
3
4
|
/**
|
|
4
5
|
* Error when call dispose() twice
|
|
5
6
|
*/
|
|
6
7
|
export class DisposedError extends Error {
|
|
8
|
+
previous;
|
|
9
|
+
inspectString;
|
|
7
10
|
constructor(object, previous) {
|
|
8
|
-
|
|
11
|
+
const insp = tryInspect(object);
|
|
12
|
+
super(`Object [${insp}] has already disposed ${getErrorFrame(previous, 2)}.`);
|
|
13
|
+
this.previous = previous;
|
|
14
|
+
this.inspectString = insp;
|
|
9
15
|
this.name = 'Warning';
|
|
16
|
+
this.tryCreateConsoleWarning().catch(() => { });
|
|
17
|
+
}
|
|
18
|
+
async tryCreateConsoleWarning() {
|
|
19
|
+
console.error('DisposedWarning: duplicate dispose.');
|
|
20
|
+
console.error(' * first dispose:\n%s', prettyFormatError(this.previous, false));
|
|
21
|
+
console.error(' * current dispose:\n%s', prettyFormatError(this, false));
|
|
22
|
+
console.error(' * Object: %s', this.inspectString);
|
|
10
23
|
}
|
|
11
24
|
}
|
|
12
25
|
export function isDisposedError(error) {
|
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
"../../../../src/lifecycle/dispose/disposedError.ts"
|
|
7
7
|
],
|
|
8
8
|
"names": [],
|
|
9
|
-
"mappings": "AAAA,OAAO,EAAE,aAAa,EAAE,iCAA6B;AACrD,OAAO,EAAE,
|
|
9
|
+
"mappings": "AAAA,OAAO,EAAE,UAAU,EAAE,uCAAmC;AACxD,OAAO,EAAE,aAAa,EAAE,iCAA6B;AACrD,OAAO,EAAE,iBAAiB,EAAE,+BAA2B;AAEvD;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,KAAK;IAItB;IAHD,aAAa,CAAS;IACtC,YACC,MAAW,EACK,QAAe;QAE/B,MAAM,IAAI,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;QAChC,KAAK,CAAC,WAAW,IAAI,0BAA0B,aAAa,CAAC,QAAQ,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;QAH9D,aAAQ,GAAR,QAAQ,CAAO;QAK/B,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC;QAEtB,IAAI,CAAC,uBAAuB,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IAChD,CAAC;IAEM,KAAK,CAAC,uBAAuB;QACnC,OAAO,CAAC,KAAK,CAAC,qCAAqC,CAAC,CAAC;QACrD,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAE,iBAAiB,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC;QAClF,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAE,iBAAiB,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