@journeyapps/reactor-lib-utils 2.0.15 → 2.0.16
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/package.json +7 -7
- package/dist/@types/Disposable.d.ts +0 -3
- package/dist/@types/EventEmitter.d.ts +0 -16
- package/dist/@types/Mutex.d.ts +0 -78
- package/dist/@types/ReactorPath.d.ts +0 -15
- package/dist/@types/Validators.d.ts +0 -3
- package/dist/@types/async-throttle.d.ts +0 -12
- package/dist/@types/clipboard.d.ts +0 -1
- package/dist/@types/color.d.ts +0 -23
- package/dist/@types/dates.d.ts +0 -41
- package/dist/@types/file-input.d.ts +0 -14
- package/dist/@types/index.d.ts +0 -12
- package/dist/@types/logging.d.ts +0 -2
- package/dist/@types/retries.d.ts +0 -1
- package/dist/@types/string-manipulation.d.ts +0 -10
- package/dist/Disposable.js +0 -3
- package/dist/Disposable.js.map +0 -1
- package/dist/EventEmitter.js +0 -46
- package/dist/EventEmitter.js.map +0 -1
- package/dist/Mutex.js +0 -276
- package/dist/Mutex.js.map +0 -1
- package/dist/ReactorPath.js +0 -61
- package/dist/ReactorPath.js.map +0 -1
- package/dist/Validators.js +0 -27
- package/dist/Validators.js.map +0 -1
- package/dist/async-throttle.js +0 -50
- package/dist/async-throttle.js.map +0 -1
- package/dist/clipboard.js +0 -16
- package/dist/clipboard.js.map +0 -1
- package/dist/color.js +0 -102
- package/dist/color.js.map +0 -1
- package/dist/dates.js +0 -95
- package/dist/dates.js.map +0 -1
- package/dist/file-input.js +0 -87
- package/dist/file-input.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/logging.js +0 -8
- package/dist/logging.js.map +0 -1
- package/dist/retries.js +0 -34
- package/dist/retries.js.map +0 -1
- package/dist/string-manipulation.js +0 -25
- package/dist/string-manipulation.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@journeyapps/reactor-lib-utils",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.16",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"registry": "https://registry.npmjs.org/",
|
|
6
6
|
"access": "public"
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"main": "./dist/index.js",
|
|
15
15
|
"typings": "./dist/@types/index",
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@journeyapps
|
|
17
|
+
"@journeyapps/common-logger": "1.1.2",
|
|
18
18
|
"async": "^3.2.6",
|
|
19
19
|
"color": "^5.0.3",
|
|
20
20
|
"hex-opacity": "^1.0.16",
|
|
@@ -23,16 +23,16 @@
|
|
|
23
23
|
"lodash": "^4.18.1",
|
|
24
24
|
"luxon": "^3.7.2",
|
|
25
25
|
"minimatch": "^10.2.6",
|
|
26
|
-
"mobx": "^7.0.
|
|
26
|
+
"mobx": "^7.0.3",
|
|
27
27
|
"tslib": "^2.8.1",
|
|
28
|
-
"uuid": "^14.0.
|
|
28
|
+
"uuid": "^14.0.2"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/jsonwebtoken": "^9.0.10",
|
|
32
32
|
"@types/lodash": "^4.17.25",
|
|
33
|
-
"@types/luxon": "^3.7.
|
|
34
|
-
"@types/node": "^26.
|
|
35
|
-
"vitest": "^
|
|
33
|
+
"@types/luxon": "^3.7.5",
|
|
34
|
+
"@types/node": "^26.5.0",
|
|
35
|
+
"vitest": "^5.0.0"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
38
|
"build": "../node_modules/.bin/tsc --build",
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Disposable } from './Disposable';
|
|
2
|
-
export type SubscriberCallback<E> = (event: E) => void;
|
|
3
|
-
export type Subscriber<E> = {
|
|
4
|
-
id: string;
|
|
5
|
-
handler: SubscriberCallback<E>;
|
|
6
|
-
};
|
|
7
|
-
/**
|
|
8
|
-
* Not to be confused with node's EventEmitter. This is a typed emitter
|
|
9
|
-
*/
|
|
10
|
-
export declare class EventEmitter<E> implements Disposable {
|
|
11
|
-
subscribers: Subscriber<E>[];
|
|
12
|
-
private unsubscribe;
|
|
13
|
-
subscribe(handler: SubscriberCallback<E>): Disposable;
|
|
14
|
-
emit(event: E): void;
|
|
15
|
-
dispose(): void;
|
|
16
|
-
}
|
package/dist/@types/Mutex.d.ts
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
export type PromiseFunction<T> = (context: MutexContext) => Promise<T>;
|
|
2
|
-
export type SharedPromiseFunction<T> = (context: SharedMutexContext) => Promise<T>;
|
|
3
|
-
export interface SharedMutexContext {
|
|
4
|
-
sharedLock<T>(promiseFn: SharedPromiseFunction<T>): Promise<T>;
|
|
5
|
-
}
|
|
6
|
-
export interface MutexContext extends SharedMutexContext {
|
|
7
|
-
exclusiveLock<T>(promiseFn: PromiseFunction<T>): Promise<T>;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Mutex maintains a queue of Promise-returning functions that
|
|
11
|
-
* are executed sequentially (whereas normally they would execute their async code concurrently).
|
|
12
|
-
*/
|
|
13
|
-
export declare class Mutex implements MutexContext {
|
|
14
|
-
private queue;
|
|
15
|
-
private sharedCount;
|
|
16
|
-
private exclusiveLocked;
|
|
17
|
-
private emptyQueuePromise;
|
|
18
|
-
private emptyQueueResolve?;
|
|
19
|
-
constructor();
|
|
20
|
-
/**
|
|
21
|
-
* Returns true if no locks are held: the queue is empty, and no tasks are being executed.
|
|
22
|
-
*/
|
|
23
|
-
isFree(): boolean;
|
|
24
|
-
/**
|
|
25
|
-
* Resolves when no lock is being held: the queue is empty, and no tasks are being executed.
|
|
26
|
-
*/
|
|
27
|
-
waitUntilFree(): Promise<void>;
|
|
28
|
-
/**
|
|
29
|
-
* Place a function on the queue.
|
|
30
|
-
* The function may either return a Promise or a value.
|
|
31
|
-
* Return a Promise that is resolved with the result of the function.
|
|
32
|
-
*/
|
|
33
|
-
exclusiveLock<T>(promiseFn: PromiseFunction<T>): Promise<T>;
|
|
34
|
-
/**
|
|
35
|
-
* Place a function on the queue.
|
|
36
|
-
* This function may execute in parallel with other "multi" functions, but not with other functions on the exclusive
|
|
37
|
-
* queue.
|
|
38
|
-
*/
|
|
39
|
-
sharedLock<T>(promiseFn: SharedPromiseFunction<T>): Promise<T>;
|
|
40
|
-
private lock;
|
|
41
|
-
/**
|
|
42
|
-
* Convert a normal Promise-returning function into one that is automatically enqueued.
|
|
43
|
-
* The signature of the function stays the same - only the execution is potentially delayed.
|
|
44
|
-
* The only exception is that if the function would have returned a scalar value, it now
|
|
45
|
-
* returns a Promise.
|
|
46
|
-
*/
|
|
47
|
-
qu<T extends (...args: any[]) => Promise<any>>(fn: T): T;
|
|
48
|
-
/**
|
|
49
|
-
* Like qu, but ensures there is never more than one function on
|
|
50
|
-
* the queue. Note that there may be one running as well as one
|
|
51
|
-
* on the queue.
|
|
52
|
-
*
|
|
53
|
-
* If a call to this function would result in a second item on
|
|
54
|
-
* the queue, the last promise this returned. In that case, any
|
|
55
|
-
* arguments passed to the function are ignored.
|
|
56
|
-
*/
|
|
57
|
-
quOnce<T extends (...args: any[]) => Promise<any>>(fn: T): T;
|
|
58
|
-
/**
|
|
59
|
-
* Transform a function into a queued batch processor.
|
|
60
|
-
*
|
|
61
|
-
* @param process The processing function. It takes a batch of items, and must return the same number of results.
|
|
62
|
-
* @param options.limit An optional limit to the number of items passed to a single batch.
|
|
63
|
-
* @param options.debounce Specify to add a delay between queuing a batch and processing the batch.
|
|
64
|
-
*/
|
|
65
|
-
batched<T, R>(process: (items: T[]) => Promise<R[]>, options?: {
|
|
66
|
-
limit?: number;
|
|
67
|
-
debounce?: number;
|
|
68
|
-
}): (items: T[]) => Promise<R[]>;
|
|
69
|
-
/**
|
|
70
|
-
* Wait until we are ready to execute the next task on the queue.
|
|
71
|
-
*
|
|
72
|
-
* This places a "Task" marker on the queue, and waits until we get to it.
|
|
73
|
-
*
|
|
74
|
-
* @param exclusive
|
|
75
|
-
*/
|
|
76
|
-
private _lockNext;
|
|
77
|
-
private _tryNext;
|
|
78
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import * as _ from 'lodash';
|
|
2
|
-
export declare class ReactorPath {
|
|
3
|
-
static IMAGE_EXTENSIONS: string[];
|
|
4
|
-
static isImage: ((filename: string) => boolean) & _.MemoizedFunction;
|
|
5
|
-
static isBinary: ((filename: string) => boolean) & _.MemoizedFunction;
|
|
6
|
-
static normalize: ((directory: string) => string) & _.MemoizedFunction;
|
|
7
|
-
static join(...parts: string[]): string;
|
|
8
|
-
static startsWith: ((base: string, check: string) => boolean) & _.MemoizedFunction;
|
|
9
|
-
/**
|
|
10
|
-
*
|
|
11
|
-
*/
|
|
12
|
-
static split: ((directory: string) => string[]) & _.MemoizedFunction;
|
|
13
|
-
static equals(...paths: string[]): boolean;
|
|
14
|
-
static matches(path: string, glob: string): boolean;
|
|
15
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export type ThrottleOptions = {
|
|
2
|
-
wait_ms?: number;
|
|
3
|
-
leading?: boolean;
|
|
4
|
-
};
|
|
5
|
-
export type IFunc<I extends any[], O> = (...args: I) => Promise<O>;
|
|
6
|
-
/**
|
|
7
|
-
* Given an execution function, return a throttled execution function which executes a maximum of
|
|
8
|
-
* once every `wait_ms`.
|
|
9
|
-
*
|
|
10
|
-
* This is conceptually the same as _.throttle except this handles promises correctly
|
|
11
|
-
*/
|
|
12
|
-
export declare const throttle: <I extends any[], O>(func: IFunc<I, O>, options?: ThrottleOptions) => IFunc<I, O>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const copyTextToClipboard: (str: string) => boolean;
|
package/dist/@types/color.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import * as _ from 'lodash';
|
|
2
|
-
export declare const asColor: ((color: any) => import("color").ColorInstance) & _.MemoizedFunction;
|
|
3
|
-
export declare const isColor: ((color: any) => boolean) & _.MemoizedFunction;
|
|
4
|
-
export declare const normalizeColorToHex: ((color: string) => string) & _.MemoizedFunction;
|
|
5
|
-
export declare const getTransparentColor: ((color: any, transparency: any) => any) & _.MemoizedFunction;
|
|
6
|
-
export declare const getDarkenedColor: ((color: any, ratio: number) => any) & _.MemoizedFunction;
|
|
7
|
-
export declare const getColorWithAlphaOptions: (options: {
|
|
8
|
-
color: string;
|
|
9
|
-
alphaValueIfNotPresent: number;
|
|
10
|
-
}) => any;
|
|
11
|
-
/**
|
|
12
|
-
* #11223344 => rgba(17, 34, 51, 0.27)
|
|
13
|
-
*/
|
|
14
|
-
export declare const aHexToRgba: ((hex: string) => string) & _.MemoizedFunction;
|
|
15
|
-
/**
|
|
16
|
-
* rgba(17, 34, 51, 0.27) => #11223344
|
|
17
|
-
*/
|
|
18
|
-
export declare const rgbaToAHex: ((str: any) => string) & _.MemoizedFunction;
|
|
19
|
-
export declare const colorToHex: ((str: string) => string) & _.MemoizedFunction;
|
|
20
|
-
/**
|
|
21
|
-
* same as rgbaToAHex, but can also work with colour names like 'mediumpurple'
|
|
22
|
-
*/
|
|
23
|
-
export declare const colorToAHex: ((str: string) => string) & _.MemoizedFunction;
|
package/dist/@types/dates.d.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { DateTime } from 'luxon';
|
|
2
|
-
export type ReactorDateType = Date | DateTime | string;
|
|
3
|
-
export declare const parseDateTypesToLuxon: (date: ReactorDateType) => DateTime<boolean>;
|
|
4
|
-
/**
|
|
5
|
-
* Takes any date as accepted by new Date(x) where x is the date
|
|
6
|
-
* and returns the date as a string in the format yyyy-mm-dd hh:mm:ss
|
|
7
|
-
*
|
|
8
|
-
* @deprecated use displayDateTime instead
|
|
9
|
-
*/
|
|
10
|
-
export declare const simpleDateTime: (date: ReactorDateType, _debugLocale?: boolean) => string;
|
|
11
|
-
export declare enum ReactorDateFormats {
|
|
12
|
-
/**
|
|
13
|
-
* @example 2025-06-12 13:02:46
|
|
14
|
-
*/
|
|
15
|
-
SIMPLE = "simple",
|
|
16
|
-
/**
|
|
17
|
-
* @example 2025-06-12T19:02:46.925Z
|
|
18
|
-
*/
|
|
19
|
-
ISO = "iso",
|
|
20
|
-
/**
|
|
21
|
-
* 6/12/2025, 7:02 PM
|
|
22
|
-
*/
|
|
23
|
-
LOCAL = "local"
|
|
24
|
-
}
|
|
25
|
-
export interface ComputeDateTimePartsOptions {
|
|
26
|
-
date: ReactorDateType;
|
|
27
|
-
local: boolean;
|
|
28
|
-
format: ReactorDateFormats;
|
|
29
|
-
_debugLocale?: boolean;
|
|
30
|
-
}
|
|
31
|
-
export declare const computeDateTimeParts: (options: ComputeDateTimePartsOptions) => {
|
|
32
|
-
display: string;
|
|
33
|
-
display_time: string;
|
|
34
|
-
display_date: string;
|
|
35
|
-
zone: string;
|
|
36
|
-
datetime: DateTime<boolean>;
|
|
37
|
-
};
|
|
38
|
-
export declare const displayDateTime: (options: ComputeDateTimePartsOptions & {
|
|
39
|
-
zone?: boolean;
|
|
40
|
-
}) => string;
|
|
41
|
-
export declare const toRelative: (date: ReactorDateType, now?: ReactorDateType) => string;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export declare enum MimeTypes {
|
|
2
|
-
A_JSON = "application/json",
|
|
3
|
-
T_JSON = "text/json",
|
|
4
|
-
VSIX = "application/vsix"
|
|
5
|
-
}
|
|
6
|
-
export interface FileSelectionParams {
|
|
7
|
-
mimeTypes?: string[];
|
|
8
|
-
single?: boolean;
|
|
9
|
-
}
|
|
10
|
-
export declare const selectFiles: (options?: FileSelectionParams) => Promise<File[]>;
|
|
11
|
-
export declare const selectFile: (options?: FileSelectionParams) => Promise<File | null>;
|
|
12
|
-
export declare const saveFile: (content: BlobPart, fileName: string) => void;
|
|
13
|
-
export declare const readFileAsText: (file: File) => Promise<string | null>;
|
|
14
|
-
export declare const readFileAsArrayBuffer: (file: File) => Promise<ArrayBuffer | null>;
|
package/dist/@types/index.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export * from './clipboard';
|
|
2
|
-
export * from './color';
|
|
3
|
-
export * from './file-input';
|
|
4
|
-
export * from './string-manipulation';
|
|
5
|
-
export * from './ReactorPath';
|
|
6
|
-
export * from './Mutex';
|
|
7
|
-
export * from './EventEmitter';
|
|
8
|
-
export * from './Disposable';
|
|
9
|
-
export * from './Validators';
|
|
10
|
-
export * from './retries';
|
|
11
|
-
export * from './async-throttle';
|
|
12
|
-
export * from './dates';
|
package/dist/@types/logging.d.ts
DELETED
package/dist/@types/retries.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const retryWithBackoff: <T>(handler: () => Promise<T>, attempts?: number, hint?: string) => Promise<T>;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import * as _ from 'lodash';
|
|
2
|
-
/**
|
|
3
|
-
* If the provided string is longer than the
|
|
4
|
-
* maximum length, the string is returned with an ellipse
|
|
5
|
-
* @param str
|
|
6
|
-
* @param maxLength
|
|
7
|
-
*/
|
|
8
|
-
export declare const trimString: (str: string, maxLength: number) => string;
|
|
9
|
-
export declare const getIntlNumberFormatter: ((maximumFractionDigits?: number) => Intl.NumberFormat) & _.MemoizedFunction;
|
|
10
|
-
export declare const formatNumber: (number: number, maximumFractionDigits?: number) => string;
|
package/dist/Disposable.js
DELETED
package/dist/Disposable.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Disposable.js","sourceRoot":"","sources":["../src/Disposable.ts"],"names":[],"mappings":""}
|
package/dist/EventEmitter.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EventEmitter = void 0;
|
|
4
|
-
const uuid = require("uuid");
|
|
5
|
-
const logging_1 = require("./logging");
|
|
6
|
-
const logger = (0, logging_1.getUtilsLogger)('Events');
|
|
7
|
-
/**
|
|
8
|
-
* Not to be confused with node's EventEmitter. This is a typed emitter
|
|
9
|
-
*/
|
|
10
|
-
class EventEmitter {
|
|
11
|
-
constructor() {
|
|
12
|
-
this.subscribers = [];
|
|
13
|
-
}
|
|
14
|
-
unsubscribe(id) {
|
|
15
|
-
this.subscribers = this.subscribers.filter((subscriber) => {
|
|
16
|
-
return subscriber.id !== id;
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
subscribe(handler) {
|
|
20
|
-
const id = uuid.v4();
|
|
21
|
-
this.subscribers.push({
|
|
22
|
-
id: id,
|
|
23
|
-
handler: handler
|
|
24
|
-
});
|
|
25
|
-
return {
|
|
26
|
-
dispose: () => {
|
|
27
|
-
this.unsubscribe(id);
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
emit(event) {
|
|
32
|
-
this.subscribers.forEach((subscriber) => {
|
|
33
|
-
try {
|
|
34
|
-
subscriber.handler(event);
|
|
35
|
-
}
|
|
36
|
-
catch (err) {
|
|
37
|
-
logger.error('Event subscriber failed', subscriber.id, err);
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
dispose() {
|
|
42
|
-
this.subscribers = [];
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
exports.EventEmitter = EventEmitter;
|
|
46
|
-
//# sourceMappingURL=EventEmitter.js.map
|
package/dist/EventEmitter.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EventEmitter.js","sourceRoot":"","sources":["../src/EventEmitter.ts"],"names":[],"mappings":";;;AACA,6BAA6B;AAC7B,uCAA2C;AAE3C,MAAM,MAAM,GAAG,IAAA,wBAAc,EAAC,QAAQ,CAAC,CAAC;AAQxC;;GAEG;AACH,MAAa,YAAY;IAAzB;QACE,gBAAW,GAAoB,EAAE,CAAC;IAmCpC,CAAC;IAjCS,WAAW,CAAC,EAAU;QAC5B,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,EAAE;YACxD,OAAO,UAAU,CAAC,EAAE,KAAK,EAAE,CAAC;QAC9B,CAAC,CAAC,CAAC;IACL,CAAC;IAED,SAAS,CAAC,OAA8B;QACtC,MAAM,EAAE,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;QACrB,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;YACpB,EAAE,EAAE,EAAE;YACN,OAAO,EAAE,OAAO;SACjB,CAAC,CAAC;QAEH,OAAO;YACL,OAAO,EAAE,GAAG,EAAE;gBACZ,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;YACvB,CAAC;SACF,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,KAAQ;QACX,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE;YACtC,IAAI,CAAC;gBACH,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YAC5B,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,MAAM,CAAC,KAAK,CAAC,yBAAyB,EAAE,UAAU,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;YAC9D,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED,OAAO;QACL,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;IACxB,CAAC;CACF;AApCD,oCAoCC"}
|
package/dist/Mutex.js
DELETED
|
@@ -1,276 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Mutex = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const logging_1 = require("./logging");
|
|
6
|
-
const logger = (0, logging_1.getUtilsLogger)('Mutex');
|
|
7
|
-
const DEBUG_MUTEX = false;
|
|
8
|
-
class ExclusiveContext {
|
|
9
|
-
constructor(mutex) {
|
|
10
|
-
this.mutex = mutex;
|
|
11
|
-
}
|
|
12
|
-
exclusiveLock(promiseFn) {
|
|
13
|
-
return promiseFn(this);
|
|
14
|
-
}
|
|
15
|
-
sharedLock(promiseFn) {
|
|
16
|
-
return promiseFn(this);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
class SharedContext {
|
|
20
|
-
constructor(mutex) {
|
|
21
|
-
this.mutex = mutex;
|
|
22
|
-
}
|
|
23
|
-
exclusiveLock(promiseFn) {
|
|
24
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
throw new Error('Cannot upgrade a shared lock to an exclusive lock.');
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
sharedLock(promiseFn) {
|
|
29
|
-
return promiseFn(this);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Mutex maintains a queue of Promise-returning functions that
|
|
34
|
-
* are executed sequentially (whereas normally they would execute their async code concurrently).
|
|
35
|
-
*/
|
|
36
|
-
class Mutex {
|
|
37
|
-
constructor() {
|
|
38
|
-
this.queue = [];
|
|
39
|
-
this.sharedCount = 0;
|
|
40
|
-
this.exclusiveLocked = false;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Returns true if no locks are held: the queue is empty, and no tasks are being executed.
|
|
44
|
-
*/
|
|
45
|
-
isFree() {
|
|
46
|
-
if (this.queue.length > 0) {
|
|
47
|
-
return false;
|
|
48
|
-
}
|
|
49
|
-
if (this.exclusiveLocked) {
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
if (this.sharedCount > 0) {
|
|
53
|
-
return false;
|
|
54
|
-
}
|
|
55
|
-
return true;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Resolves when no lock is being held: the queue is empty, and no tasks are being executed.
|
|
59
|
-
*/
|
|
60
|
-
waitUntilFree() {
|
|
61
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
62
|
-
if (this.isFree()) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
if (this.emptyQueueResolve == null) {
|
|
66
|
-
this.emptyQueuePromise = new Promise((resolve) => {
|
|
67
|
-
this.emptyQueueResolve = resolve;
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
yield this.emptyQueuePromise.finally(() => {
|
|
71
|
-
this.emptyQueuePromise = null;
|
|
72
|
-
this.emptyQueueResolve = null;
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Place a function on the queue.
|
|
78
|
-
* The function may either return a Promise or a value.
|
|
79
|
-
* Return a Promise that is resolved with the result of the function.
|
|
80
|
-
*/
|
|
81
|
-
exclusiveLock(promiseFn) {
|
|
82
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
83
|
-
return this.lock(promiseFn, true);
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Place a function on the queue.
|
|
88
|
-
* This function may execute in parallel with other "multi" functions, but not with other functions on the exclusive
|
|
89
|
-
* queue.
|
|
90
|
-
*/
|
|
91
|
-
sharedLock(promiseFn) {
|
|
92
|
-
return this.lock(promiseFn, false);
|
|
93
|
-
}
|
|
94
|
-
lock(promiseFn, exclusive) {
|
|
95
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
96
|
-
const context = yield this._lockNext(exclusive);
|
|
97
|
-
let timeout;
|
|
98
|
-
try {
|
|
99
|
-
if (DEBUG_MUTEX) {
|
|
100
|
-
const stack = new Error().stack;
|
|
101
|
-
timeout = setTimeout(() => {
|
|
102
|
-
logger.warn('Lock has not been released after 10 seconds', exclusive ? 'exclusive' : 'shared', stack);
|
|
103
|
-
}, 10000);
|
|
104
|
-
}
|
|
105
|
-
return yield promiseFn(context);
|
|
106
|
-
}
|
|
107
|
-
finally {
|
|
108
|
-
if (DEBUG_MUTEX) {
|
|
109
|
-
clearTimeout(timeout);
|
|
110
|
-
}
|
|
111
|
-
if (!exclusive) {
|
|
112
|
-
this.sharedCount -= 1;
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
this.exclusiveLocked = false;
|
|
116
|
-
}
|
|
117
|
-
this._tryNext();
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Convert a normal Promise-returning function into one that is automatically enqueued.
|
|
123
|
-
* The signature of the function stays the same - only the execution is potentially delayed.
|
|
124
|
-
* The only exception is that if the function would have returned a scalar value, it now
|
|
125
|
-
* returns a Promise.
|
|
126
|
-
*/
|
|
127
|
-
qu(fn) {
|
|
128
|
-
const self = this;
|
|
129
|
-
return function (...args) {
|
|
130
|
-
return self.exclusiveLock(() => {
|
|
131
|
-
return fn.apply(this, args);
|
|
132
|
-
});
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Like qu, but ensures there is never more than one function on
|
|
137
|
-
* the queue. Note that there may be one running as well as one
|
|
138
|
-
* on the queue.
|
|
139
|
-
*
|
|
140
|
-
* If a call to this function would result in a second item on
|
|
141
|
-
* the queue, the last promise this returned. In that case, any
|
|
142
|
-
* arguments passed to the function are ignored.
|
|
143
|
-
*/
|
|
144
|
-
quOnce(fn) {
|
|
145
|
-
let queueSize = 0;
|
|
146
|
-
const self = this;
|
|
147
|
-
let lastPromise = null;
|
|
148
|
-
return function (...args) {
|
|
149
|
-
if (queueSize >= 1) {
|
|
150
|
-
return lastPromise;
|
|
151
|
-
}
|
|
152
|
-
queueSize += 1;
|
|
153
|
-
lastPromise = self.exclusiveLock(() => {
|
|
154
|
-
queueSize -= 1;
|
|
155
|
-
return fn.apply(this, args);
|
|
156
|
-
});
|
|
157
|
-
return lastPromise;
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Transform a function into a queued batch processor.
|
|
162
|
-
*
|
|
163
|
-
* @param process The processing function. It takes a batch of items, and must return the same number of results.
|
|
164
|
-
* @param options.limit An optional limit to the number of items passed to a single batch.
|
|
165
|
-
* @param options.debounce Specify to add a delay between queuing a batch and processing the batch.
|
|
166
|
-
*/
|
|
167
|
-
batched(process, options) {
|
|
168
|
-
// Configure defaults
|
|
169
|
-
options = Object.assign({ limit: null, debounce: null }, options);
|
|
170
|
-
const limit = options.limit;
|
|
171
|
-
const debounce = options.debounce;
|
|
172
|
-
// The batch queue will currently always contain less entries than the number of queued "process" functions.
|
|
173
|
-
// This may change if we start splitting batches.
|
|
174
|
-
let queue = [];
|
|
175
|
-
return (items) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
176
|
-
// Batch entry for this set of items.
|
|
177
|
-
// It may be an unique entry for these items, or it may be shared with others.
|
|
178
|
-
let entry;
|
|
179
|
-
if (queue.length > 0 && (limit == null || queue[queue.length - 1].items.length + items.length <= limit)) {
|
|
180
|
-
// Add to last batch
|
|
181
|
-
entry = queue[queue.length - 1];
|
|
182
|
-
}
|
|
183
|
-
else {
|
|
184
|
-
// Add to queue
|
|
185
|
-
entry = { items: [], results: [], processed: false };
|
|
186
|
-
queue.push(entry);
|
|
187
|
-
}
|
|
188
|
-
const resultOffset = entry.items.length;
|
|
189
|
-
entry.items.push(...items);
|
|
190
|
-
yield this.exclusiveLock(() => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
191
|
-
if (entry.processed) {
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
194
|
-
if (debounce && queue.length == 1) {
|
|
195
|
-
// Add a debounce delay, during which time more items may be added to the batch.
|
|
196
|
-
// Only do this if the queue only contains a single batch.
|
|
197
|
-
yield new Promise((resolve) => setTimeout(resolve, debounce));
|
|
198
|
-
}
|
|
199
|
-
const batch = queue.shift();
|
|
200
|
-
try {
|
|
201
|
-
if (batch == null) {
|
|
202
|
-
// This should be caught by the `entry.processed` check above.
|
|
203
|
-
throw new Error('Internal error: No remaining batch to process');
|
|
204
|
-
}
|
|
205
|
-
if (batch !== entry) {
|
|
206
|
-
// This should be caught by the `entry.processed` check above.
|
|
207
|
-
// We should not be processing a batch without our own items in the current design.
|
|
208
|
-
// This may change if we start splitting batches.
|
|
209
|
-
throw new Error('Internal error: Batch mismatch');
|
|
210
|
-
}
|
|
211
|
-
const results = yield process(batch.items);
|
|
212
|
-
if (results == null || results.length != batch.items.length) {
|
|
213
|
-
throw new Error(`Expected ${batch.items.length} results, got ${results ? results.length : results}`);
|
|
214
|
-
}
|
|
215
|
-
batch.results.push(...results);
|
|
216
|
-
}
|
|
217
|
-
catch (error) {
|
|
218
|
-
batch.error = error;
|
|
219
|
-
}
|
|
220
|
-
finally {
|
|
221
|
-
batch.processed = true;
|
|
222
|
-
}
|
|
223
|
-
}));
|
|
224
|
-
if (entry.error) {
|
|
225
|
-
throw entry.error;
|
|
226
|
-
}
|
|
227
|
-
return entry.results.slice(resultOffset, resultOffset + items.length);
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
|
-
/**
|
|
231
|
-
* Wait until we are ready to execute the next task on the queue.
|
|
232
|
-
*
|
|
233
|
-
* This places a "Task" marker on the queue, and waits until we get to it.
|
|
234
|
-
*
|
|
235
|
-
* @param exclusive
|
|
236
|
-
*/
|
|
237
|
-
_lockNext(exclusive) {
|
|
238
|
-
var self = this;
|
|
239
|
-
return new Promise(function (resolve, reject) {
|
|
240
|
-
const task = {
|
|
241
|
-
execute: resolve,
|
|
242
|
-
exclusive
|
|
243
|
-
};
|
|
244
|
-
self.queue.push(task);
|
|
245
|
-
self._tryNext();
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
|
-
_tryNext() {
|
|
249
|
-
if (this.queue.length == 0) {
|
|
250
|
-
if (this.emptyQueueResolve && this.isFree()) {
|
|
251
|
-
this.emptyQueueResolve();
|
|
252
|
-
}
|
|
253
|
-
return false;
|
|
254
|
-
}
|
|
255
|
-
if (this.exclusiveLocked) {
|
|
256
|
-
return false;
|
|
257
|
-
}
|
|
258
|
-
var task = this.queue[0];
|
|
259
|
-
if (!task.exclusive) {
|
|
260
|
-
this.sharedCount += 1;
|
|
261
|
-
this.queue.shift();
|
|
262
|
-
task.execute(new SharedContext(this));
|
|
263
|
-
}
|
|
264
|
-
else if (this.sharedCount == 0) {
|
|
265
|
-
this.exclusiveLocked = true;
|
|
266
|
-
this.queue.shift();
|
|
267
|
-
task.execute(new ExclusiveContext(this));
|
|
268
|
-
}
|
|
269
|
-
else {
|
|
270
|
-
return false;
|
|
271
|
-
}
|
|
272
|
-
return true;
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
exports.Mutex = Mutex;
|
|
276
|
-
//# sourceMappingURL=Mutex.js.map
|
package/dist/Mutex.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Mutex.js","sourceRoot":"","sources":["../src/Mutex.ts"],"names":[],"mappings":";;;;AAAA,uCAA2C;AAE3C,MAAM,MAAM,GAAG,IAAA,wBAAc,EAAC,OAAO,CAAC,CAAC;AAKvC,MAAM,WAAW,GAAG,KAAK,CAAC;AAe1B,MAAM,gBAAgB;IACpB,YAAoB,KAAY;QAAZ,UAAK,GAAL,KAAK,CAAO;IAAG,CAAC;IAEpC,aAAa,CAAI,SAA6B;QAC5C,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;IAED,UAAU,CAAI,SAA6B;QACzC,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;CACF;AAED,MAAM,aAAa;IACjB,YAAoB,KAAY;QAAZ,UAAK,GAAL,KAAK,CAAO;IAAG,CAAC;IAE9B,aAAa,CAAI,SAA6B;;YAClD,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;QACxE,CAAC;KAAA;IAED,UAAU,CAAI,SAAmC;QAC/C,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;CACF;AAED;;;GAGG;AACH,MAAa,KAAK;IAQhB;QACE,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;QAChB,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC;QACrB,IAAI,CAAC,eAAe,GAAG,KAAK,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,IAAI,I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AAC,CAAC;QACxC,CAAC;aAAM,IAAI,IAAI,CAAC,WAAW,IAAI,CAAC,EAAE,CAAC;YACjC,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;YAC5B,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;YACnB,IAAI,CAAC,OAAO,CAAC,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC;QAC3C,CAAC;aAAM,CAAC;YACN,OAAO,KAAK,CAAC;QACf,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA5QD,sBA4QC"}
|
package/dist/ReactorPath.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ReactorPath = void 0;
|
|
4
|
-
const path = require("path");
|
|
5
|
-
const _ = require("lodash");
|
|
6
|
-
const minimatch_1 = require("minimatch");
|
|
7
|
-
class ReactorPath {
|
|
8
|
-
static join(...parts) {
|
|
9
|
-
if (parts.length === 0) {
|
|
10
|
-
return '';
|
|
11
|
-
}
|
|
12
|
-
return ReactorPath.normalize(parts.join('/'));
|
|
13
|
-
}
|
|
14
|
-
static equals(...paths) {
|
|
15
|
-
if (paths.length <= 1) {
|
|
16
|
-
throw new Error('need 2 or more paths to perform match');
|
|
17
|
-
}
|
|
18
|
-
paths = paths.map((p) => ReactorPath.normalize(p));
|
|
19
|
-
for (let i = 0; i < paths.length - 1; i++) {
|
|
20
|
-
if (paths[i] !== paths[i + 1]) {
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return true;
|
|
25
|
-
}
|
|
26
|
-
static matches(path, glob) {
|
|
27
|
-
return (0, minimatch_1.minimatch)(ReactorPath.normalize(path), glob);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
exports.ReactorPath = ReactorPath;
|
|
31
|
-
ReactorPath.IMAGE_EXTENSIONS = ['.png', '.jpeg', '.jpg', '.svg', '.gif'];
|
|
32
|
-
ReactorPath.isImage = _.memoize((filename) => {
|
|
33
|
-
const extension = path.extname(filename).toLowerCase();
|
|
34
|
-
return ReactorPath.IMAGE_EXTENSIONS.indexOf(extension) !== -1;
|
|
35
|
-
});
|
|
36
|
-
ReactorPath.isBinary = _.memoize((filename) => {
|
|
37
|
-
return ReactorPath.isImage(filename);
|
|
38
|
-
});
|
|
39
|
-
ReactorPath.normalize = _.memoize((directory) => {
|
|
40
|
-
directory = _.trim(directory, '/');
|
|
41
|
-
if (directory === '') {
|
|
42
|
-
return '';
|
|
43
|
-
}
|
|
44
|
-
return path.normalize(directory);
|
|
45
|
-
});
|
|
46
|
-
ReactorPath.startsWith = _.memoize((base, check) => {
|
|
47
|
-
return ReactorPath.normalize(base).startsWith(ReactorPath.normalize(check));
|
|
48
|
-
}, (base, check) => {
|
|
49
|
-
return `${base}:${check}`;
|
|
50
|
-
});
|
|
51
|
-
/**
|
|
52
|
-
*
|
|
53
|
-
*/
|
|
54
|
-
ReactorPath.split = _.memoize((directory) => {
|
|
55
|
-
directory = ReactorPath.normalize(directory);
|
|
56
|
-
if (directory == '') {
|
|
57
|
-
return [];
|
|
58
|
-
}
|
|
59
|
-
return directory.split('/');
|
|
60
|
-
});
|
|
61
|
-
//# sourceMappingURL=ReactorPath.js.map
|
package/dist/ReactorPath.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ReactorPath.js","sourceRoot":"","sources":["../src/ReactorPath.ts"],"names":[],"mappings":";;;AAAA,6BAA6B;AAC7B,4BAA4B;AAC5B,yCAAsC;AAEtC,MAAa,WAAW;IAoBtB,MAAM,CAAC,IAAI,CAAC,GAAG,KAAe;QAC5B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvB,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,OAAO,WAAW,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;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AAC;AACvC,CAAC,CAAC,CAAC;AAEI,qBAAS,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,SAAiB,EAAE,EAAE;IACjD,SAAS,GAAG,CAAC,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;IACnC,IAAI,SAAS,KAAK,EAAE,EAAE,CAAC;QACrB,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;AACnC,CAAC,CAAC,CAAC;AASI,sBAAU,GAAG,CAAC,CAAC,OAAO,CAC3B,CAAC,IAAY,EAAE,KAAa,EAAE,EAAE;IAC9B,OAAO,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,WAAW,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;AAC9E,CAAC,EACD,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;IACd,OAAO,GAAG,IAAI,IAAI,KAAK,EAAE,CAAC;AAC5B,CAAC,CACF,CAAC;AAEF;;GAEG;AACI,iBAAK,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,SAAiB,EAAE,EAAE;IAC7C,SAAS,GAAG,WAAW,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7C,IAAI,SAAS,IAAI,EAAE,EAAE,CAAC;QACpB,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAC9B,CAAC,CAAC,CAAC"}
|
package/dist/Validators.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateEmail = validateEmail;
|
|
4
|
-
exports.getEmailDomain = getEmailDomain;
|
|
5
|
-
exports.emailDomainsMatch = emailDomainsMatch;
|
|
6
|
-
const _ = require("lodash");
|
|
7
|
-
// Not 100% RFC 5322 compliant, but should match any email addresses in use.
|
|
8
|
-
// Source: http://www.regular-expressions.info/email.html
|
|
9
|
-
const emailRegEx = new RegExp("^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$", 'i');
|
|
10
|
-
function validateEmail(input) {
|
|
11
|
-
return emailRegEx.test(input);
|
|
12
|
-
}
|
|
13
|
-
// i know this doesnt work for all emails, but people with multiple '@' signs in their
|
|
14
|
-
// email addresses are wrong
|
|
15
|
-
function getEmailDomain(e) {
|
|
16
|
-
if (!e) {
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
return _.last(e.split('@')).trim();
|
|
20
|
-
}
|
|
21
|
-
function emailDomainsMatch(a, b) {
|
|
22
|
-
if (!validateEmail(a) || !validateEmail(b)) {
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
return getEmailDomain(a) === getEmailDomain(b);
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=Validators.js.map
|
package/dist/Validators.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Validators.js","sourceRoot":"","sources":["../src/Validators.ts"],"names":[],"mappings":";;AASA,sCAEC;AAID,wCAKC;AAED,8CAKC;AA3BD,4BAA4B;AAE5B,4EAA4E;AAC5E,yDAAyD;AACzD,MAAM,UAAU,GAAG,IAAI,MAAM,CAC3B,2IAA2I,EAC3I,GAAG,CACJ,CAAC;AAEF,SAAgB,aAAa,CAAC,KAAa;IACzC,OAAO,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAChC,CAAC;AAED,sFAAsF;AACtF,4BAA4B;AAC5B,SAAgB,cAAc,CAAC,CAAS;IACtC,IAAI,CAAC,CAAC,EAAE,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AACrC,CAAC;AAED,SAAgB,iBAAiB,CAAC,CAAS,EAAE,CAAS;IACpD,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3C,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,cAAc,CAAC,CAAC,CAAC,KAAK,cAAc,CAAC,CAAC,CAAC,CAAC;AACjD,CAAC"}
|
package/dist/async-throttle.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.throttle = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
/**
|
|
6
|
-
* Given an execution function, return a throttled execution function which executes a maximum of
|
|
7
|
-
* once every `wait_ms`.
|
|
8
|
-
*
|
|
9
|
-
* This is conceptually the same as _.throttle except this handles promises correctly
|
|
10
|
-
*/
|
|
11
|
-
const throttle = (func, options) => {
|
|
12
|
-
let pending_executions = [];
|
|
13
|
-
let leading = false;
|
|
14
|
-
let i;
|
|
15
|
-
const execute = () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
-
i = undefined;
|
|
17
|
-
const executions = pending_executions;
|
|
18
|
-
pending_executions = [];
|
|
19
|
-
const latest = executions[executions.length - 1];
|
|
20
|
-
try {
|
|
21
|
-
let res = yield func(...latest.args);
|
|
22
|
-
for (const execution of executions) {
|
|
23
|
-
execution.resolve(res);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
catch (err) {
|
|
27
|
-
for (const execution of executions) {
|
|
28
|
-
execution.reject(err);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
return (...args) => {
|
|
33
|
-
return new Promise((resolve, reject) => {
|
|
34
|
-
pending_executions.push({
|
|
35
|
-
args: args,
|
|
36
|
-
resolve: resolve,
|
|
37
|
-
reject: reject
|
|
38
|
-
});
|
|
39
|
-
if ((options === null || options === void 0 ? void 0 : options.leading) && !leading) {
|
|
40
|
-
leading = true;
|
|
41
|
-
execute();
|
|
42
|
-
}
|
|
43
|
-
if (i == null) {
|
|
44
|
-
i = setTimeout(execute, (options === null || options === void 0 ? void 0 : options.wait_ms) || 100);
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
|
-
exports.throttle = throttle;
|
|
50
|
-
//# sourceMappingURL=async-throttle.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"async-throttle.js","sourceRoot":"","sources":["../src/async-throttle.ts"],"names":[],"mappings":";;;;AAaA;;;;;GAKG;AACI,MAAM,QAAQ,GAAG,CAAqB,IAAiB,EAAE,OAAyB,EAAe,EAAE;IACxG,IAAI,kBAAkB,GAA+B,EAAE,CAAC;IAExD,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,IAAI,CAA6B,CAAC;IAElC,MAAM,OAAO,GAAG,GAAS,EAAE;QACzB,CAAC,GAAG,SAAS,CAAC;QACd,MAAM,UAAU,GAAG,kBAAkB,CAAC;QACtC,kBAAkB,GAAG,EAAE,CAAC;QAExB,MAAM,MAAM,GAAG,UAAU,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACjD,IAAI,CAAC;YACH,IAAI,GAAG,GAAG,MAAM,IAAI,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;YAErC,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;gBACnC,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YACzB,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;gBACnC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACxB,CAAC;QACH,CAAC;IACH,CAAC,CAAA,CAAC;IAEF,OAAO,CAAC,GAAG,IAAO,EAAE,EAAE;QACpB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,kBAAkB,CAAC,IAAI,CAAC;gBACtB,IAAI,EAAE,IAAI;gBACV,OAAO,EAAE,OAAO;gBAChB,MAAM,EAAE,MAAM;aACf,CAAC,CAAC;YAEH,IAAI,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,KAAI,CAAC,OAAO,EAAE,CAAC;gBACjC,OAAO,GAAG,IAAI,CAAC;gBACf,OAAO,EAAE,CAAC;YACZ,CAAC;YAED,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC;gBACd,CAAC,GAAG,UAAU,CAAC,OAAO,EAAE,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,KAAI,GAAG,CAAC,CAAC;YACnD,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC,CAAC;AA3CW,QAAA,QAAQ,YA2CnB"}
|
package/dist/clipboard.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.copyTextToClipboard = void 0;
|
|
4
|
-
const copyTextToClipboard = (str) => {
|
|
5
|
-
// Note: navigator.clipboard works only secure contexts, i.e. when using https.
|
|
6
|
-
// This will not work when developing locally with http
|
|
7
|
-
try {
|
|
8
|
-
navigator.clipboard.writeText(str).catch(() => { });
|
|
9
|
-
return true;
|
|
10
|
-
}
|
|
11
|
-
catch (_a) {
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
exports.copyTextToClipboard = copyTextToClipboard;
|
|
16
|
-
//# sourceMappingURL=clipboard.js.map
|
package/dist/clipboard.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"clipboard.js","sourceRoot":"","sources":["../src/clipboard.ts"],"names":[],"mappings":";;;AAAO,MAAM,mBAAmB,GAAG,CAAC,GAAW,EAAE,EAAE;IACjD,+EAA+E;IAC/E,uDAAuD;IACvD,IAAI,CAAC;QACH,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QACnD,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,WAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC,CAAC;AATW,QAAA,mBAAmB,uBAS9B"}
|
package/dist/color.js
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.colorToAHex = exports.colorToHex = exports.rgbaToAHex = exports.aHexToRgba = exports.getColorWithAlphaOptions = exports.getDarkenedColor = exports.getTransparentColor = exports.normalizeColorToHex = exports.isColor = exports.asColor = void 0;
|
|
4
|
-
// @ts-ignore
|
|
5
|
-
const hexToRgba = require("hex-to-rgba");
|
|
6
|
-
const color_1 = require("color");
|
|
7
|
-
const _ = require("lodash");
|
|
8
|
-
const hexOpacity = require("hex-opacity");
|
|
9
|
-
exports.asColor = _.memoize((color) => {
|
|
10
|
-
try {
|
|
11
|
-
return new color_1.default(color);
|
|
12
|
-
}
|
|
13
|
-
catch (ex) {
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
exports.isColor = _.memoize((color) => {
|
|
18
|
-
if (!color) {
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
return !!(0, exports.asColor)(color);
|
|
22
|
-
});
|
|
23
|
-
exports.normalizeColorToHex = _.memoize((color) => {
|
|
24
|
-
if (color.startsWith('#')) {
|
|
25
|
-
return color;
|
|
26
|
-
}
|
|
27
|
-
if ((0, exports.isColor)(color)) {
|
|
28
|
-
return (0, exports.asColor)(color).hex();
|
|
29
|
-
}
|
|
30
|
-
return (0, exports.colorToHex)(color);
|
|
31
|
-
});
|
|
32
|
-
const _isGradient = (color) => {
|
|
33
|
-
return color.indexOf('linear-gradient') !== -1;
|
|
34
|
-
};
|
|
35
|
-
exports.getTransparentColor = _.memoize((color, transparency) => {
|
|
36
|
-
if (_isGradient(color)) {
|
|
37
|
-
return color;
|
|
38
|
-
}
|
|
39
|
-
return new color_1.default(color).alpha(transparency).toString();
|
|
40
|
-
}, (a, b) => `${a}${b}`);
|
|
41
|
-
exports.getDarkenedColor = _.memoize((color, ratio) => {
|
|
42
|
-
if (_isGradient(color)) {
|
|
43
|
-
return color;
|
|
44
|
-
}
|
|
45
|
-
return new color_1.default(color).darken(ratio).toString();
|
|
46
|
-
}, (a, b) => `${a}${b}`);
|
|
47
|
-
const getColorWithAlphaOptions = (options) => {
|
|
48
|
-
const color = (0, exports.asColor)(options.color);
|
|
49
|
-
if (color.alpha() < 1) {
|
|
50
|
-
return color.toString();
|
|
51
|
-
}
|
|
52
|
-
return (0, exports.getTransparentColor)(options.color.toString(), options.alphaValueIfNotPresent);
|
|
53
|
-
};
|
|
54
|
-
exports.getColorWithAlphaOptions = getColorWithAlphaOptions;
|
|
55
|
-
/**
|
|
56
|
-
* #11223344 => rgba(17, 34, 51, 0.27)
|
|
57
|
-
*/
|
|
58
|
-
exports.aHexToRgba = _.memoize((hex) => {
|
|
59
|
-
if (!hex) {
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
62
|
-
return hexToRgba(hex);
|
|
63
|
-
});
|
|
64
|
-
/**
|
|
65
|
-
* rgba(17, 34, 51, 0.27) => #11223344
|
|
66
|
-
*/
|
|
67
|
-
exports.rgbaToAHex = _.memoize((str) => {
|
|
68
|
-
try {
|
|
69
|
-
let c = new color_1.default(str);
|
|
70
|
-
return hexOpacity.create(c.hex(), c.alpha());
|
|
71
|
-
}
|
|
72
|
-
catch (ex) { }
|
|
73
|
-
return null;
|
|
74
|
-
});
|
|
75
|
-
exports.colorToHex = _.memoize((str) => {
|
|
76
|
-
if (!str) {
|
|
77
|
-
return null;
|
|
78
|
-
}
|
|
79
|
-
const c = (0, exports.asColor)(str);
|
|
80
|
-
if (c) {
|
|
81
|
-
return c.hex();
|
|
82
|
-
}
|
|
83
|
-
const ctx = document.createElement('canvas').getContext('2d');
|
|
84
|
-
ctx.fillStyle = str;
|
|
85
|
-
return (0, exports.rgbaToAHex)(ctx.fillStyle) || '';
|
|
86
|
-
});
|
|
87
|
-
/**
|
|
88
|
-
* same as rgbaToAHex, but can also work with colour names like 'mediumpurple'
|
|
89
|
-
*/
|
|
90
|
-
exports.colorToAHex = _.memoize((str) => {
|
|
91
|
-
if (!str) {
|
|
92
|
-
return null;
|
|
93
|
-
}
|
|
94
|
-
const c = (0, exports.rgbaToAHex)(str);
|
|
95
|
-
if (c) {
|
|
96
|
-
return c;
|
|
97
|
-
}
|
|
98
|
-
const ctx = document.createElement('canvas').getContext('2d');
|
|
99
|
-
ctx.fillStyle = str;
|
|
100
|
-
return (0, exports.rgbaToAHex)(ctx.fillStyle) || '';
|
|
101
|
-
});
|
|
102
|
-
//# sourceMappingURL=color.js.map
|
package/dist/color.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"color.js","sourceRoot":"","sources":["../src/color.ts"],"names":[],"mappings":";;;AAAA,aAAa;AACb,yCAAyC;AACzC,iCAA0B;AAC1B,4BAA4B;AAC5B,0CAA0C;AAE7B,QAAA,OAAO,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;IACzC,IAAI,CAAC;QACH,OAAO,IAAI,eAAK,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;IAAC,OAAO,EAAE,EAAE,CAAC;QACZ,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC,CAAC,CAAC;AAEU,QAAA,OAAO,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;IACzC,IAAI,CAAC,KAAK,E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,CAAC;QACT,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,CAAC,GAAG,IAAA,eAAO,EAAC,GAAG,CAAC,CAAC;IACvB,IAAI,CAAC,EAAE,CAAC;QACN,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC;IACjB,CAAC;IAED,MAAM,GAAG,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IAC9D,GAAG,CAAC,SAAS,GAAG,GAAG,CAAC;IACpB,OAAO,IAAA,kBAAU,EAAC,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;AACzC,CAAC,CAAC,CAAC;AAEH;;GAEG;AACU,QAAA,WAAW,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,GAAW,EAAU,EAAE;IAC3D,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,CAAC,GAAG,IAAA,kBAAU,EAAC,GAAG,CAAC,CAAC;IAC1B,IAAI,CAAC,EAAE,CAAC;QACN,OAAO,CAAC,CAAC;IACX,CAAC;IAED,MAAM,GAAG,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IAC9D,GAAG,CAAC,SAAS,GAAG,GAAG,CAAC;IACpB,OAAO,IAAA,kBAAU,EAAC,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;AACzC,CAAC,CAAC,CAAC"}
|
package/dist/dates.js
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toRelative = exports.displayDateTime = exports.computeDateTimeParts = exports.ReactorDateFormats = exports.simpleDateTime = exports.parseDateTypesToLuxon = void 0;
|
|
4
|
-
const _ = require("lodash");
|
|
5
|
-
const luxon_1 = require("luxon");
|
|
6
|
-
const parseDateTypesToLuxon = (date) => {
|
|
7
|
-
if (_.isString(date)) {
|
|
8
|
-
return luxon_1.DateTime.fromISO(date);
|
|
9
|
-
}
|
|
10
|
-
if (luxon_1.DateTime.isDateTime(date)) {
|
|
11
|
-
return date;
|
|
12
|
-
}
|
|
13
|
-
if (date instanceof Date) {
|
|
14
|
-
return luxon_1.DateTime.fromJSDate(date);
|
|
15
|
-
}
|
|
16
|
-
throw new Error('Invalid date type');
|
|
17
|
-
};
|
|
18
|
-
exports.parseDateTypesToLuxon = parseDateTypesToLuxon;
|
|
19
|
-
/**
|
|
20
|
-
* Takes any date as accepted by new Date(x) where x is the date
|
|
21
|
-
* and returns the date as a string in the format yyyy-mm-dd hh:mm:ss
|
|
22
|
-
*
|
|
23
|
-
* @deprecated use displayDateTime instead
|
|
24
|
-
*/
|
|
25
|
-
const simpleDateTime = (date, _debugLocale = false) => {
|
|
26
|
-
return (0, exports.displayDateTime)({
|
|
27
|
-
format: ReactorDateFormats.SIMPLE,
|
|
28
|
-
local: true,
|
|
29
|
-
date,
|
|
30
|
-
_debugLocale
|
|
31
|
-
});
|
|
32
|
-
};
|
|
33
|
-
exports.simpleDateTime = simpleDateTime;
|
|
34
|
-
var ReactorDateFormats;
|
|
35
|
-
(function (ReactorDateFormats) {
|
|
36
|
-
/**
|
|
37
|
-
* @example 2025-06-12 13:02:46
|
|
38
|
-
*/
|
|
39
|
-
ReactorDateFormats["SIMPLE"] = "simple";
|
|
40
|
-
/**
|
|
41
|
-
* @example 2025-06-12T19:02:46.925Z
|
|
42
|
-
*/
|
|
43
|
-
ReactorDateFormats["ISO"] = "iso";
|
|
44
|
-
/**
|
|
45
|
-
* 6/12/2025, 7:02 PM
|
|
46
|
-
*/
|
|
47
|
-
ReactorDateFormats["LOCAL"] = "local";
|
|
48
|
-
})(ReactorDateFormats || (exports.ReactorDateFormats = ReactorDateFormats = {}));
|
|
49
|
-
const computeDateTimeParts = (options) => {
|
|
50
|
-
const { date, local, format, _debugLocale } = options;
|
|
51
|
-
let object = (0, exports.parseDateTypesToLuxon)(date);
|
|
52
|
-
if (local) {
|
|
53
|
-
object = object.toLocal();
|
|
54
|
-
if (_debugLocale) {
|
|
55
|
-
object = object.setLocale('en-US');
|
|
56
|
-
object = object.setZone('America/New_York');
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
object = object.toUTC();
|
|
61
|
-
}
|
|
62
|
-
let display_time = object.toFormat('HH:mm:ss');
|
|
63
|
-
let display_date = object.toISODate();
|
|
64
|
-
let display = `${display_date} ${display_time}`;
|
|
65
|
-
if (format === ReactorDateFormats.ISO) {
|
|
66
|
-
display = object.toISO();
|
|
67
|
-
}
|
|
68
|
-
else if (format === ReactorDateFormats.LOCAL) {
|
|
69
|
-
display = object.toLocaleString(luxon_1.DateTime.DATETIME_SHORT).replace('\u202f', ' ');
|
|
70
|
-
display_date = object.toLocaleString(luxon_1.DateTime.DATE_SHORT);
|
|
71
|
-
display_time = object.toLocaleString(luxon_1.DateTime.DATETIME_SHORT);
|
|
72
|
-
}
|
|
73
|
-
return {
|
|
74
|
-
display: display,
|
|
75
|
-
display_time,
|
|
76
|
-
display_date,
|
|
77
|
-
zone: object.zoneName,
|
|
78
|
-
datetime: object
|
|
79
|
-
};
|
|
80
|
-
};
|
|
81
|
-
exports.computeDateTimeParts = computeDateTimeParts;
|
|
82
|
-
const displayDateTime = (options) => {
|
|
83
|
-
let { display, zone } = (0, exports.computeDateTimeParts)(options);
|
|
84
|
-
if (options.zone) {
|
|
85
|
-
return `${display} (${zone})`;
|
|
86
|
-
}
|
|
87
|
-
return display;
|
|
88
|
-
};
|
|
89
|
-
exports.displayDateTime = displayDateTime;
|
|
90
|
-
const toRelative = (date, now) => {
|
|
91
|
-
let time = (0, exports.parseDateTypesToLuxon)(date);
|
|
92
|
-
return time.toRelative({ base: now ? (0, exports.parseDateTypesToLuxon)(now) : undefined });
|
|
93
|
-
};
|
|
94
|
-
exports.toRelative = toRelative;
|
|
95
|
-
//# sourceMapp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,CAAC,OAAyD,EAAE,EAAE;IAC3F,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,IAAA,4BAAoB,EAAC,OAAO,CAAC,CAAC;IACtD,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;QACjB,OAAO,GAAG,OAAO,KAAK,IAAI,GAAG,CAAC;IAChC,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AANW,QAAA,eAAe,mBAM1B;AAEK,MAAM,UAAU,GAAG,CAAC,IAAqB,EAAE,GAAqB,EAAE,EAAE;IACzE,IAAI,IAAI,GAAG,IAAA,6BAAqB,EAAC,IAAI,CAAC,CAAC;IACvC,OAAO,IAAI,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,IAAA,6BAAqB,EAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC;AACjF,CAAC,CAAC;AAHW,QAAA,UAAU,cAGrB"}
|
package/dist/file-input.js
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.readFileAsArrayBuffer = exports.readFileAsText = exports.saveFile = exports.selectFile = exports.selectFiles = exports.MimeTypes = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
var MimeTypes;
|
|
6
|
-
(function (MimeTypes) {
|
|
7
|
-
MimeTypes["A_JSON"] = "application/json";
|
|
8
|
-
MimeTypes["T_JSON"] = "text/json";
|
|
9
|
-
MimeTypes["VSIX"] = "application/vsix";
|
|
10
|
-
})(MimeTypes || (exports.MimeTypes = MimeTypes = {}));
|
|
11
|
-
const selectFiles = (options = {}) => {
|
|
12
|
-
const element = document.createElement('input');
|
|
13
|
-
element.setAttribute('type', 'file');
|
|
14
|
-
element.setAttribute('name', 'file');
|
|
15
|
-
if (!options.single) {
|
|
16
|
-
element.setAttribute('multiple', 'multiple');
|
|
17
|
-
}
|
|
18
|
-
if (options.mimeTypes) {
|
|
19
|
-
element.setAttribute('accept', options.mimeTypes.join(','));
|
|
20
|
-
}
|
|
21
|
-
return new Promise((resolve, reject) => {
|
|
22
|
-
element.onchange = (event) => {
|
|
23
|
-
// user selected something
|
|
24
|
-
if (element.files) {
|
|
25
|
-
const files = [];
|
|
26
|
-
for (let i = 0; i < element.files.length; i++) {
|
|
27
|
-
files.push(element.files.item(i));
|
|
28
|
-
}
|
|
29
|
-
resolve(files);
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
resolve([]);
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
element.style.display = 'none';
|
|
36
|
-
document.body.querySelector('#application').appendChild(element);
|
|
37
|
-
setTimeout(() => {
|
|
38
|
-
element.click();
|
|
39
|
-
}, 0);
|
|
40
|
-
}).finally(() => {
|
|
41
|
-
element.remove();
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
|
-
exports.selectFiles = selectFiles;
|
|
45
|
-
const selectFile = (...args_1) => tslib_1.__awaiter(void 0, [...args_1], void 0, function* (options = {}) {
|
|
46
|
-
const files = yield (0, exports.selectFiles)(Object.assign(Object.assign({}, options), { single: true }));
|
|
47
|
-
return files[0] || null;
|
|
48
|
-
});
|
|
49
|
-
exports.selectFile = selectFile;
|
|
50
|
-
const saveFile = (content, fileName) => {
|
|
51
|
-
const element = document.createElement('a');
|
|
52
|
-
element.setAttribute('download', fileName);
|
|
53
|
-
const blob = new Blob([content]);
|
|
54
|
-
const url = URL.createObjectURL(blob);
|
|
55
|
-
element.setAttribute('href', url);
|
|
56
|
-
element.click();
|
|
57
|
-
URL.revokeObjectURL(url);
|
|
58
|
-
element.remove();
|
|
59
|
-
};
|
|
60
|
-
exports.saveFile = saveFile;
|
|
61
|
-
const readFileAsText = (file) => {
|
|
62
|
-
return new Promise((resolve, reject) => {
|
|
63
|
-
const fileReader = new FileReader();
|
|
64
|
-
fileReader.onload = (fileLoadedEvent) => {
|
|
65
|
-
const textFromFileLoaded = fileLoadedEvent.target.result;
|
|
66
|
-
if (textFromFileLoaded) {
|
|
67
|
-
return resolve(textFromFileLoaded);
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
resolve(null);
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
fileReader.readAsText(file, 'UTF-8');
|
|
74
|
-
fileReader.onerror = (error) => reject(error);
|
|
75
|
-
});
|
|
76
|
-
};
|
|
77
|
-
exports.readFileAsText = readFileAsText;
|
|
78
|
-
const readFileAsArrayBuffer = (file) => {
|
|
79
|
-
return new Promise((resolve, reject) => {
|
|
80
|
-
const reader = new FileReader();
|
|
81
|
-
reader.readAsArrayBuffer(file);
|
|
82
|
-
reader.onload = () => resolve(reader.result);
|
|
83
|
-
reader.onerror = (error) => reject(error);
|
|
84
|
-
});
|
|
85
|
-
};
|
|
86
|
-
exports.readFileAsArrayBuffer = readFileAsArrayBuffer;
|
|
87
|
-
//# sourceMappingURL=file-input.js.map
|
package/dist/file-input.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file-input.js","sourceRoot":"","sources":["../src/file-input.ts"],"names":[],"mappings":";;;;AAAA,IAAY,SAIX;AAJD,WAAY,SAAS;IACnB,wCAA2B,CAAA;IAC3B,iCAAoB,CAAA;IACpB,sCAAyB,CAAA;AAC3B,CAAC,EAJW,SAAS,yBAAT,SAAS,QAIpB;AAOM,MAAM,WAAW,GAAG,CAAC,UAA+B,EAAE,EAAmB,EAAE;IAChF,MAAM,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAChD,OAAO,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,OAAO,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;QACpB,OAAO,CAAC,YAAY,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IA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,CAAC,OAAO,GAAG,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAChD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAdW,QAAA,cAAc,kBAczB;AAEK,MAAM,qBAAqB,GAAG,CAAC,IAAU,EAA+B,EAAE;IAC/E,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;QAChC,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;QAC/B,MAAM,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,MAAqB,CAAC,CAAC;QAC5D,MAAM,CAAC,OAAO,GAAG,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAPW,QAAA,qBAAqB,yBAOhC"}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,sDAA4B;AAC5B,kDAAwB;AACxB,uDAA6B;AAC7B,gEAAsC;AACtC,wDAA8B;AAC9B,kDAAwB;AACxB,yDAA+B;AAC/B,uDAA6B;AAC7B,uDAA6B;AAC7B,oDAA0B;AAC1B,2DAAiC;AACjC,kDAAwB"}
|
package/dist/logging.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getUtilsLogger = void 0;
|
|
4
|
-
const common_logger_1 = require("@journeyapps-labs/common-logger");
|
|
5
|
-
const logger = new common_logger_1.Logger({ name: 'Reactor utils' });
|
|
6
|
-
const getUtilsLogger = (name) => logger.childLogger(name);
|
|
7
|
-
exports.getUtilsLogger = getUtilsLogger;
|
|
8
|
-
//# sourceMappingURL=logging.js.map
|
package/dist/logging.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logging.js","sourceRoot":"","sources":["../src/logging.ts"],"names":[],"mappings":";;;AAAA,mEAAyD;AAEzD,MAAM,MAAM,GAAG,IAAI,sBAAM,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC,CAAC;AAE9C,MAAM,cAAc,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;AAA5D,QAAA,cAAc,kBAA8C"}
|
package/dist/retries.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.retryWithBackoff = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const logging_1 = require("./logging");
|
|
6
|
-
const logger = (0, logging_1.getUtilsLogger)('Retries');
|
|
7
|
-
const retryWithBackoff = (handler_1, ...args_1) => tslib_1.__awaiter(void 0, [handler_1, ...args_1], void 0, function* (handler, attempts = 10, hint) {
|
|
8
|
-
const INIT_BACKOFF = 500;
|
|
9
|
-
const MULTIPLIER = 0.5;
|
|
10
|
-
const executeWithAttempt = (...args_2) => tslib_1.__awaiter(void 0, [...args_2], void 0, function* (attempt = 1, current_backoff = INIT_BACKOFF) {
|
|
11
|
-
try {
|
|
12
|
-
return yield handler();
|
|
13
|
-
}
|
|
14
|
-
catch (err) {
|
|
15
|
-
if (hint && attempt < attempts) {
|
|
16
|
-
logger.debug(`${hint} failed on attempt ${attempt}`, err);
|
|
17
|
-
}
|
|
18
|
-
if (attempt >= attempts) {
|
|
19
|
-
if (hint) {
|
|
20
|
-
logger.error(`${hint} failed after ${attempts} attempts`, err);
|
|
21
|
-
}
|
|
22
|
-
throw err;
|
|
23
|
-
}
|
|
24
|
-
const backoff = Math.floor(current_backoff + current_backoff * MULTIPLIER);
|
|
25
|
-
yield new Promise((resolve) => {
|
|
26
|
-
setTimeout(resolve, backoff);
|
|
27
|
-
});
|
|
28
|
-
return executeWithAttempt(attempt + 1, backoff);
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
return executeWithAttempt();
|
|
32
|
-
});
|
|
33
|
-
exports.retryWithBackoff = retryWithBackoff;
|
|
34
|
-
//# sourceMappingURL=retries.js.map
|
package/dist/retries.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"retries.js","sourceRoot":"","sources":["../src/retries.ts"],"names":[],"mappings":";;;;AAAA,uCAA2C;AAE3C,MAAM,MAAM,GAAG,IAAA,wBAAc,EAAC,SAAS,CAAC,CAAC;AAElC,MAAM,gBAAgB,GAAG,uBAIlB,EAAE,sEAHd,OAAyB,EACzB,WAAmB,EAAE,EACrB,IAAa;IAEb,MAAM,YAAY,GAAG,GAAG,CAAC;IACzB,MAAM,UAAU,GAAG,GAAG,CAAC;IAEvB,MAAM,kBAAkB,GAAG,YAAoE,EAAE,2DAA/D,UAAkB,CAAC,EAAE,kBAA0B,YAAY;QAC3F,IAAI,CAAC;YACH,OAAO,MAAM,OAAO,EAAE,CAAC;QACzB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,IAAI,IAAI,OAAO,GAAG,QAAQ,EAAE,CAAC;gBAC/B,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,sBAAsB,OAAO,EAAE,EAAE,GAAG,CAAC,CAAC;YAC5D,CAAC;YAED,IAAI,OAAO,IAAI,QAAQ,EAAE,CAAC;gBACxB,IAAI,IAAI,EAAE,CAAC;oBACT,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,iBAAiB,QAAQ,WAAW,EAAE,GAAG,CAAC,CAAC;gBACjE,CAAC;gBACD,MAAM,GAAG,CAAC;YACZ,CAAC;YAED,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,eAAe,GAAG,eAAe,GAAG,UAAU,CAAC,CAAC;YAC3E,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;gBAC5B,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAC/B,CAAC,CAAC,CAAC;YAEH,OAAO,kBAAkB,CAAC,OAAO,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC;QAClD,CAAC;IACH,CAAC,CAAA,CAAC;IAEF,OAAO,kBAAkB,EAAE,CAAC;AAC9B,CAAC,CAAA,CAAC;AAjCW,QAAA,gBAAgB,oBAiC3B"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.formatNumber = exports.getIntlNumberFormatter = exports.trimString = void 0;
|
|
4
|
-
const _ = require("lodash");
|
|
5
|
-
/**
|
|
6
|
-
* If the provided string is longer than the
|
|
7
|
-
* maximum length, the string is returned with an ellipse
|
|
8
|
-
* @param str
|
|
9
|
-
* @param maxLength
|
|
10
|
-
*/
|
|
11
|
-
const trimString = (str, maxLength) => {
|
|
12
|
-
if (str.length <= maxLength) {
|
|
13
|
-
return str;
|
|
14
|
-
}
|
|
15
|
-
return str.substr(0, maxLength - 3) + '...';
|
|
16
|
-
};
|
|
17
|
-
exports.trimString = trimString;
|
|
18
|
-
exports.getIntlNumberFormatter = _.memoize((maximumFractionDigits = 2) => {
|
|
19
|
-
return new Intl.NumberFormat('en-US', { maximumFractionDigits: maximumFractionDigits });
|
|
20
|
-
});
|
|
21
|
-
const formatNumber = (number, maximumFractionDigits = 2) => {
|
|
22
|
-
return (0, exports.getIntlNumberFormatter)(maximumFractionDigits).format(number);
|
|
23
|
-
};
|
|
24
|
-
exports.formatNumber = formatNumber;
|
|
25
|
-
//# sourceMappingURL=string-manipulation.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"string-manipulation.js","sourceRoot":"","sources":["../src/string-manipulation.ts"],"names":[],"mappings":";;;AACA,4BAA4B;AAE5B;;;;;GAKG;AACI,MAAM,UAAU,GAAG,CAAC,GAAW,EAAE,SAAiB,EAAE,EAAE;IAC3D,IAAI,GAAG,CAAC,MAAM,IAAI,SAAS,EAAE,CAAC;QAC5B,OAAO,GAAG,CAAC;IACb,CAAC;IAED,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,SAAS,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC;AAC9C,CAAC,CAAC;AANW,QAAA,UAAU,cAMrB;AAEW,QAAA,sBAAsB,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,wBAAgC,CAAC,EAAE,EAAE;IACpF,OAAO,IAAI,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,CAAC,CAAC;AAC1F,CAAC,CAAC,CAAC;AAEI,MAAM,YAAY,GAAG,CAAC,MAAc,EAAE,wBAAgC,CAAC,EAAE,EAAE;IAChF,OAAO,IAAA,8BAAsB,EAAC,qBAAqB,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AACtE,CAAC,CAAC;AAFW,QAAA,YAAY,gBAEvB"}
|