@latticexyz/utils 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +187 -0
- package/README.md +3 -0
- package/jest.config.js +5 -0
- package/package.json +44 -0
- package/rollup.config.js +16 -0
- package/src/CoordMap.spec.ts +57 -0
- package/src/CoordMap.ts +106 -0
- package/src/area.ts +15 -0
- package/src/arrays.ts +19 -0
- package/src/console.ts +62 -0
- package/src/cubic.spec.ts +14 -0
- package/src/cubic.ts +109 -0
- package/src/deferred.ts +14 -0
- package/src/enums.ts +13 -0
- package/src/eth.ts +42 -0
- package/src/guards.ts +10 -0
- package/src/hash.ts +11 -0
- package/src/index.ts +34 -0
- package/src/iterable.spec.ts +56 -0
- package/src/iterable.ts +59 -0
- package/src/mobx.ts +26 -0
- package/src/objects.ts +16 -0
- package/src/pack.spec.ts +37 -0
- package/src/pack.ts +61 -0
- package/src/promise.ts +45 -0
- package/src/proxy.spec.ts +186 -0
- package/src/proxy.ts +101 -0
- package/src/random.ts +17 -0
- package/src/rx.spec.ts +45 -0
- package/src/rx.ts +124 -0
- package/src/sleep.ts +3 -0
- package/src/types.ts +48 -0
- package/src/uuid.ts +70 -0
- package/src/worker.ts +16 -0
- package/tsconfig.json +102 -0
- package/typedoc.json +9 -0
package/src/proxy.ts
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
import { IComputedValue, IObservableValue, reaction } from "mobx";
|
|
3
|
+
import DeepProxy from "proxy-deep";
|
|
4
|
+
import { deferred } from "./deferred";
|
|
5
|
+
import { isFunction, isObject } from "./guards";
|
|
6
|
+
import { Cached } from "./types";
|
|
7
|
+
|
|
8
|
+
function deepAccess(target: Record<string, unknown>, path: string[]): any {
|
|
9
|
+
if (path.length === 0) return target;
|
|
10
|
+
if (path.length === 1) return target[path[0]];
|
|
11
|
+
const [next, ...rest] = path;
|
|
12
|
+
const nextTarget = target[next];
|
|
13
|
+
if (!isObject(nextTarget)) throw new Error("Path does not exist on the target");
|
|
14
|
+
return deepAccess(nextTarget, rest);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Caches any function calls to the target until the target is ready.
|
|
19
|
+
* @param target T extends Cachable
|
|
20
|
+
* @returns Cached<T>
|
|
21
|
+
*/
|
|
22
|
+
export function cacheUntilReady<T extends Record<string, any>>(
|
|
23
|
+
target: IObservableValue<T | undefined> | IComputedValue<T | undefined>
|
|
24
|
+
): Cached<T> {
|
|
25
|
+
// The call queue contains the path and arguments of calls to the
|
|
26
|
+
// proxiedTarget while the target was not available yet.
|
|
27
|
+
// It also contains resolve and reject methods to fulfil the promise
|
|
28
|
+
// returned when calling the proxiedTarget once the target becomes available.
|
|
29
|
+
const callQueue: {
|
|
30
|
+
path: string[];
|
|
31
|
+
args?: any[];
|
|
32
|
+
resolve: (result: any) => void;
|
|
33
|
+
reject: (e: Error) => void;
|
|
34
|
+
}[] = [];
|
|
35
|
+
|
|
36
|
+
// The proxiedTarget proxies all calls to the target.
|
|
37
|
+
// If a function is called on the proxiedTarget while the target is not
|
|
38
|
+
// available, a promise is returned and the call will be stored in the callQueue
|
|
39
|
+
// until the target becomes available and the promise is fulfilled.
|
|
40
|
+
const proxiedTarget = new DeepProxy(
|
|
41
|
+
{},
|
|
42
|
+
{
|
|
43
|
+
get(_t, prop) {
|
|
44
|
+
const targetReady = target.get();
|
|
45
|
+
if (targetReady) {
|
|
46
|
+
// If the target is ready, relay all calls directly to the target
|
|
47
|
+
// (Except for the "proxied" key, which indicates whether the object is currently proxied)
|
|
48
|
+
if (prop === "proxied") return false;
|
|
49
|
+
return Reflect.get(targetReady, prop);
|
|
50
|
+
} else {
|
|
51
|
+
// Note: if the target is not available, accessing a property returns another proxy,
|
|
52
|
+
// not a Promise. It is possible to check whether a value is currently proxied using the proxied key.
|
|
53
|
+
if (prop === "proxied") return true;
|
|
54
|
+
if (prop === "name") return "ProxiedTarget";
|
|
55
|
+
if (prop === "toJSON") return () => ({ proxied: true });
|
|
56
|
+
return this.nest(() => void 0);
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
apply(_, thisArg, args) {
|
|
60
|
+
const targetReady = target.get();
|
|
61
|
+
if (targetReady) {
|
|
62
|
+
// If the target is ready, relay all calls directly to the target
|
|
63
|
+
const targetFunc = deepAccess(targetReady, this.path);
|
|
64
|
+
if (!isFunction(targetFunc)) throw new Error("Target is not callable");
|
|
65
|
+
return Reflect.apply(targetFunc, thisArg, args);
|
|
66
|
+
} else {
|
|
67
|
+
// Otherwise store the call and relay it to the target later once it's ready.
|
|
68
|
+
// The return value of this call is a promise, that gets resolved once the target is ready.
|
|
69
|
+
const [resolve, reject, promise] = deferred();
|
|
70
|
+
callQueue.push({ path: this.path, args, resolve, reject });
|
|
71
|
+
return promise;
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
reaction(
|
|
78
|
+
() => target.get(),
|
|
79
|
+
(targetReady) => {
|
|
80
|
+
if (!targetReady) return;
|
|
81
|
+
// Move all entries from callQueue to queuedCalls
|
|
82
|
+
const queuedCalls = callQueue.splice(0);
|
|
83
|
+
for (const { path, args, resolve, reject } of queuedCalls) {
|
|
84
|
+
const target = deepAccess(targetReady, path);
|
|
85
|
+
if (args && isFunction(target)) {
|
|
86
|
+
(async () => {
|
|
87
|
+
try {
|
|
88
|
+
resolve(await target(...args));
|
|
89
|
+
} catch (e: any) {
|
|
90
|
+
reject(e);
|
|
91
|
+
}
|
|
92
|
+
})();
|
|
93
|
+
} else {
|
|
94
|
+
resolve(target);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
return proxiedTarget as Cached<T>;
|
|
101
|
+
}
|
package/src/random.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param to Upper bound (included)
|
|
4
|
+
* @param from Lower bound (included). Default 0.
|
|
5
|
+
* @returns A random integer between from and to.
|
|
6
|
+
*/
|
|
7
|
+
export function random(to: number, from = 0): number {
|
|
8
|
+
return Math.floor(Math.random() * (to - from + 1)) + from;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @param array Array to pick a random element from.
|
|
13
|
+
* @returns Random element from the given array.
|
|
14
|
+
*/
|
|
15
|
+
export function pickRandom<T>(array: [T, ...T[]]): T {
|
|
16
|
+
return array[random(array.length - 1)];
|
|
17
|
+
}
|
package/src/rx.spec.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Subject } from "rxjs";
|
|
2
|
+
import { awaitStreamValue, streamToComputed } from "./rx";
|
|
3
|
+
import { sleep } from "./sleep";
|
|
4
|
+
|
|
5
|
+
describe("streamToComputed", () => {
|
|
6
|
+
it("should return a computed value that corresponds to the last stream value", () => {
|
|
7
|
+
const stream = new Subject<number>();
|
|
8
|
+
const comp = streamToComputed(stream);
|
|
9
|
+
expect(comp.get()).toBeUndefined();
|
|
10
|
+
|
|
11
|
+
stream.next(1);
|
|
12
|
+
expect(comp.get()).toBe(1);
|
|
13
|
+
|
|
14
|
+
stream.next(2);
|
|
15
|
+
expect(comp.get()).toBe(2);
|
|
16
|
+
|
|
17
|
+
stream.next(3);
|
|
18
|
+
stream.next(4);
|
|
19
|
+
expect(comp.get()).toBe(4);
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
describe("awaitStreamValue", () => {
|
|
24
|
+
it("should return a promise that resolves once the requested stream value is emitted", async () => {
|
|
25
|
+
const stream = new Subject<number>();
|
|
26
|
+
const promise = awaitStreamValue(stream, (v) => v === 1);
|
|
27
|
+
|
|
28
|
+
let isFulfilled = false;
|
|
29
|
+
(async () => {
|
|
30
|
+
await promise;
|
|
31
|
+
isFulfilled = true;
|
|
32
|
+
})();
|
|
33
|
+
|
|
34
|
+
await sleep(100);
|
|
35
|
+
expect(isFulfilled).toBe(false);
|
|
36
|
+
|
|
37
|
+
stream.next(2);
|
|
38
|
+
await sleep(100);
|
|
39
|
+
expect(isFulfilled).toBe(false);
|
|
40
|
+
|
|
41
|
+
stream.next(1);
|
|
42
|
+
await sleep(100);
|
|
43
|
+
expect(isFulfilled).toBe(true);
|
|
44
|
+
});
|
|
45
|
+
});
|
package/src/rx.ts
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import {
|
|
2
|
+
concatMap,
|
|
3
|
+
delay,
|
|
4
|
+
filter,
|
|
5
|
+
first,
|
|
6
|
+
mergeMap,
|
|
7
|
+
Observable,
|
|
8
|
+
of,
|
|
9
|
+
OperatorFunction,
|
|
10
|
+
pipe,
|
|
11
|
+
ReplaySubject,
|
|
12
|
+
scan,
|
|
13
|
+
Timestamp,
|
|
14
|
+
timestamp,
|
|
15
|
+
} from "rxjs";
|
|
16
|
+
import { computed, IComputedValue, IObservableValue, observable, reaction, runInAction, toJS } from "mobx";
|
|
17
|
+
import { deferred } from "./deferred";
|
|
18
|
+
import { awaitValue } from "./mobx";
|
|
19
|
+
|
|
20
|
+
export function filterNullish<T>(): OperatorFunction<T, NonNullable<T>> {
|
|
21
|
+
return pipe<Observable<T>, Observable<NonNullable<T>>>(
|
|
22
|
+
filter<T>((x: T) => x != null) as OperatorFunction<T, NonNullable<T>>
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function awaitPromise<T extends Promise<unknown>>(): OperatorFunction<T, Awaited<T>> {
|
|
27
|
+
return pipe(concatMap((x: T) => x)) as OperatorFunction<T, Awaited<T>>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* RxJS operator to stretch out an event stream by a given delay per event
|
|
32
|
+
* @param spacingDelayMs Delay between each event in ms
|
|
33
|
+
* @returns stream of events with at least spacingDelayMs spaceing between event
|
|
34
|
+
*/
|
|
35
|
+
export function stretch<T>(spacingDelayMs: number) {
|
|
36
|
+
return pipe(
|
|
37
|
+
timestamp<T>(),
|
|
38
|
+
scan((acc: (Timestamp<T> & { delay: number }) | null, curr: Timestamp<T>) => {
|
|
39
|
+
// calculate delay needed to offset next emission
|
|
40
|
+
let delay = 0;
|
|
41
|
+
if (acc !== null) {
|
|
42
|
+
const timeDelta = curr.timestamp - acc.timestamp;
|
|
43
|
+
delay = timeDelta > spacingDelayMs ? 0 : spacingDelayMs - timeDelta;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
timestamp: curr.timestamp,
|
|
48
|
+
delay: delay,
|
|
49
|
+
value: curr.value,
|
|
50
|
+
};
|
|
51
|
+
}, null),
|
|
52
|
+
filterNullish(),
|
|
53
|
+
mergeMap((i) => of(i.value).pipe(delay(i.delay)), 1)
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function observableToComputed<T>(obs: IObservableValue<T>): IComputedValue<T> {
|
|
58
|
+
return computed(() => obs.get());
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function computedToStream<T>(comp: IComputedValue<T> | IObservableValue<T>): Observable<T> {
|
|
62
|
+
const stream = new ReplaySubject<T>(1);
|
|
63
|
+
reaction(
|
|
64
|
+
() => comp.get(),
|
|
65
|
+
(value) => {
|
|
66
|
+
if (value != null) stream.next(value);
|
|
67
|
+
},
|
|
68
|
+
{ fireImmediately: true }
|
|
69
|
+
);
|
|
70
|
+
return stream;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function observableToStream<T>(obs: T): Observable<T> {
|
|
74
|
+
const stream = new ReplaySubject<T>(1);
|
|
75
|
+
reaction(
|
|
76
|
+
() => toJS(obs),
|
|
77
|
+
(value) => {
|
|
78
|
+
if (value != null) stream.next(value);
|
|
79
|
+
},
|
|
80
|
+
{ fireImmediately: true }
|
|
81
|
+
);
|
|
82
|
+
return stream;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function streamToComputed<T>(stream$: Observable<T>): IComputedValue<T | undefined> {
|
|
86
|
+
const value = observable.box<T | undefined>();
|
|
87
|
+
stream$.subscribe((val) => runInAction(() => value.set(val)));
|
|
88
|
+
return computed(() => value.get());
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export async function streamToDefinedComputed<T>(stream$: Observable<T>): Promise<IComputedValue<T>> {
|
|
92
|
+
const value = observable.box<T>();
|
|
93
|
+
stream$.subscribe((val) => runInAction(() => value.set(val)));
|
|
94
|
+
const computedValue = computed(() => value.get());
|
|
95
|
+
await awaitValue(computedValue);
|
|
96
|
+
return computedValue as IComputedValue<T>;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
*
|
|
101
|
+
* @param stream$ RxJS observable to check for the given value
|
|
102
|
+
* @param predicate Predicate to check
|
|
103
|
+
* @returns A promise that resolves with the requested value once the predicate is true
|
|
104
|
+
*/
|
|
105
|
+
export async function awaitStreamValue<T>(
|
|
106
|
+
stream$: Observable<T>,
|
|
107
|
+
predicate: (value: T) => boolean = (value) => value != null
|
|
108
|
+
): Promise<T> {
|
|
109
|
+
const [resolve, , promise] = deferred<T>();
|
|
110
|
+
stream$.pipe(first(predicate)).subscribe(resolve);
|
|
111
|
+
return promise;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Turns a stream into an updating object for easy access outside of rxjs
|
|
116
|
+
* @param stream$ Stream to turn into a wrapped value
|
|
117
|
+
* @returns Object with `current` key corresponding to last stream value
|
|
118
|
+
*/
|
|
119
|
+
export async function streamToWrappedValue<T>(stream$: Observable<T>): Promise<{ current: T }> {
|
|
120
|
+
const value: { current?: T } = {};
|
|
121
|
+
stream$.subscribe((v) => (value.current = v));
|
|
122
|
+
value.current = await awaitStreamValue(stream$);
|
|
123
|
+
return value as { current: T };
|
|
124
|
+
}
|
package/src/sleep.ts
ADDED
package/src/types.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { enableLogger } from "./console";
|
|
2
|
+
|
|
3
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
4
|
+
export type Func<A extends any[], R> = (...args: A) => R;
|
|
5
|
+
export type AsyncFunc<A extends any[], R> = R extends Promise<unknown> ? (...args: A) => R : (...args: A) => Promise<R>;
|
|
6
|
+
|
|
7
|
+
export type CachedValue<V, Proxied extends boolean> = Proxied extends true
|
|
8
|
+
? V extends Func<infer A, infer B>
|
|
9
|
+
? AsyncFunc<A, B>
|
|
10
|
+
: V extends Record<string, any>
|
|
11
|
+
? Cached<V> & { proxied: true }
|
|
12
|
+
: { proxied: true }
|
|
13
|
+
: V extends Func<infer A, infer B>
|
|
14
|
+
? Func<A, B>
|
|
15
|
+
: V extends Record<string, any>
|
|
16
|
+
? V
|
|
17
|
+
: V & { proxied: false };
|
|
18
|
+
|
|
19
|
+
export type Cached<C> =
|
|
20
|
+
| ({ proxied: false } & { [key in keyof C]: CachedValue<C[key], false> })
|
|
21
|
+
| ({ proxied: true } & { [key in keyof C]: CachedValue<C[key], true> });
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @deprecated Use Awaited<T> instead
|
|
25
|
+
*/
|
|
26
|
+
export type PromiseValue<T> = Awaited<T>;
|
|
27
|
+
|
|
28
|
+
export type ValueOf<T extends object> = T[keyof T];
|
|
29
|
+
|
|
30
|
+
export type Area = {
|
|
31
|
+
x: number;
|
|
32
|
+
y: number;
|
|
33
|
+
width: number;
|
|
34
|
+
height: number;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export type Coord = {
|
|
38
|
+
x: number;
|
|
39
|
+
y: number;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export type VoxelCoord = {
|
|
43
|
+
x: number;
|
|
44
|
+
y: number;
|
|
45
|
+
z: number;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export type Logger = ReturnType<typeof enableLogger>;
|
package/src/uuid.ts
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UUID.core.js - UUID.js for Minimalists
|
|
3
|
+
*
|
|
4
|
+
* @file
|
|
5
|
+
* @author LiosK
|
|
6
|
+
* @version v4.2.0
|
|
7
|
+
* @license Apache License 2.0: Copyright (c) 2010-2018 LiosK
|
|
8
|
+
* @url https://github.com/LiosK/UUID.js/blob/master/src/uuid.core.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @class
|
|
13
|
+
* @classdesc {@link UUID} object.
|
|
14
|
+
* @hideconstructor
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
// Core Component {{{
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Generates a version 4 UUID as a hexadecimal string.
|
|
21
|
+
* @returns {string} Hexadecimal UUID string.
|
|
22
|
+
*/
|
|
23
|
+
export const uuid = function () {
|
|
24
|
+
const rand = _getRandomInt,
|
|
25
|
+
hex = _hexAligner;
|
|
26
|
+
return (
|
|
27
|
+
hex(rand(32), 8) + // time_low
|
|
28
|
+
"-" +
|
|
29
|
+
hex(rand(16), 4) + // time_mid
|
|
30
|
+
"-" +
|
|
31
|
+
hex(0x4000 | rand(12), 4) + // time_hi_and_version
|
|
32
|
+
"-" +
|
|
33
|
+
hex(0x8000 | rand(14), 4) + // clock_seq_hi_and_reserved clock_seq_low
|
|
34
|
+
"-" +
|
|
35
|
+
hex(rand(48), 12)
|
|
36
|
+
); // node
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Returns an unsigned x-bit random integer.
|
|
41
|
+
* @private
|
|
42
|
+
* @param {number} x Unsigned integer ranging from 0 to 53, inclusive.
|
|
43
|
+
* @returns {number} Unsigned x-bit random integer (0 <= f(x) < 2^x).
|
|
44
|
+
*/
|
|
45
|
+
const _getRandomInt = function (x: number) {
|
|
46
|
+
if (x < 0 || x > 53) {
|
|
47
|
+
return NaN;
|
|
48
|
+
}
|
|
49
|
+
const n = 0 | (Math.random() * 0x40000000); // 1 << 30
|
|
50
|
+
return x > 30 ? n + (0 | (Math.random() * (1 << (x - 30)))) * 0x40000000 : n >>> (30 - x);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Converts an integer to a zero-filled hexadecimal string.
|
|
55
|
+
* @private
|
|
56
|
+
* @param {number} num
|
|
57
|
+
* @param {number} length
|
|
58
|
+
* @returns {string}
|
|
59
|
+
*/
|
|
60
|
+
const _hexAligner = function (num: number, length: number) {
|
|
61
|
+
let str = num.toString(16),
|
|
62
|
+
i = length - str.length,
|
|
63
|
+
z = "0";
|
|
64
|
+
for (; i > 0; i >>>= 1, z += z) {
|
|
65
|
+
if (i & 1) {
|
|
66
|
+
str = z + str;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return str;
|
|
70
|
+
};
|
package/src/worker.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { fromEvent, map, Observable } from "rxjs";
|
|
2
|
+
|
|
3
|
+
export interface DoWork<I, O> {
|
|
4
|
+
work(input$: Observable<I>): Observable<O>;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function fromWorker<I, O>(worker: Worker, input$: Observable<I>): Observable<O> {
|
|
8
|
+
input$.subscribe((event) => worker.postMessage(event));
|
|
9
|
+
return fromEvent<MessageEvent<O>>(worker, "message").pipe(map((e) => e.data));
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function runWorker<I, O>(worker: DoWork<I, O>) {
|
|
13
|
+
const input$ = fromEvent<MessageEvent<I>>(self, "message");
|
|
14
|
+
const output$ = worker.work(input$.pipe(map((event) => event.data)));
|
|
15
|
+
output$.subscribe((event) => self.postMessage(event));
|
|
16
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
/* Visit https://aka.ms/tsconfig.json to read more about this file */
|
|
4
|
+
|
|
5
|
+
/* Projects */
|
|
6
|
+
// "incremental": true, /* Enable incremental compilation */
|
|
7
|
+
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
|
|
8
|
+
// "tsBuildInfoFile": "./", /* Specify the folder for .tsbuildinfo incremental compilation files. */
|
|
9
|
+
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects */
|
|
10
|
+
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
|
|
11
|
+
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
|
|
12
|
+
|
|
13
|
+
/* Language and Environment */
|
|
14
|
+
"target": "es2019" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
|
|
15
|
+
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
|
16
|
+
// "jsx": "preserve", /* Specify what JSX code is generated. */
|
|
17
|
+
// "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
|
|
18
|
+
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
|
|
19
|
+
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h' */
|
|
20
|
+
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
|
|
21
|
+
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.` */
|
|
22
|
+
// "reactNamespace": "", /* Specify the object invoked for `createElement`. This only applies when targeting `react` JSX emit. */
|
|
23
|
+
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
|
|
24
|
+
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
|
|
25
|
+
|
|
26
|
+
/* Modules */
|
|
27
|
+
"module": "esnext" /* Specify what module code is generated. */,
|
|
28
|
+
"rootDir": "./src" /* Specify the root folder within your source files. */,
|
|
29
|
+
"moduleResolution": "node" /* Specify how TypeScript looks up a file from a given module specifier. */,
|
|
30
|
+
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
|
31
|
+
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
|
32
|
+
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
|
33
|
+
// "typeRoots": [], /* Specify multiple folders that act like `./node_modules/@types`. */
|
|
34
|
+
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
|
|
35
|
+
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
|
36
|
+
// "resolveJsonModule": true, /* Enable importing .json files */
|
|
37
|
+
// "noResolve": true, /* Disallow `import`s, `require`s or `<reference>`s from expanding the number of files TypeScript should add to a project. */
|
|
38
|
+
|
|
39
|
+
/* JavaScript Support */
|
|
40
|
+
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */
|
|
41
|
+
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
|
|
42
|
+
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`. */
|
|
43
|
+
|
|
44
|
+
/* Emit */
|
|
45
|
+
"declaration": true /* Generate .d.ts files from TypeScript and JavaScript files in your project. */,
|
|
46
|
+
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
|
|
47
|
+
// "emitDeclarationOnly": true /* Only output d.ts files and not JavaScript files. */,
|
|
48
|
+
"sourceMap": true /* Create source map files for emitted JavaScript files. */,
|
|
49
|
+
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output. */
|
|
50
|
+
"outDir": "dist" /* Specify an output folder for all emitted files. */,
|
|
51
|
+
// "removeComments": true, /* Disable emitting comments. */
|
|
52
|
+
// "noEmit": true, /* Disable emitting files from a compilation. */
|
|
53
|
+
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
|
54
|
+
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types */
|
|
55
|
+
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
|
|
56
|
+
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
|
|
57
|
+
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
|
58
|
+
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
|
|
59
|
+
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
|
|
60
|
+
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
|
|
61
|
+
// "newLine": "crlf", /* Set the newline character for emitting files. */
|
|
62
|
+
// "stripInternal": true, /* Disable emitting declarations that have `@internal` in their JSDoc comments. */
|
|
63
|
+
// "noEmitHelpers": true, /* Disable generating custom helper functions like `__extends` in compiled output. */
|
|
64
|
+
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
|
|
65
|
+
// "preserveConstEnums": true, /* Disable erasing `const enum` declarations in generated code. */
|
|
66
|
+
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
|
|
67
|
+
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
|
|
68
|
+
|
|
69
|
+
/* Interop Constraints */
|
|
70
|
+
"isolatedModules": true /* Ensure that each file can be safely transpiled without relying on other imports. */,
|
|
71
|
+
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
|
|
72
|
+
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */,
|
|
73
|
+
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
|
|
74
|
+
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
|
|
75
|
+
|
|
76
|
+
/* Type Checking */
|
|
77
|
+
"strict": true /* Enable all strict type-checking options. */,
|
|
78
|
+
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */
|
|
79
|
+
// "strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */
|
|
80
|
+
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
|
|
81
|
+
// "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */
|
|
82
|
+
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
|
|
83
|
+
// "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */
|
|
84
|
+
// "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */
|
|
85
|
+
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
|
|
86
|
+
// "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */
|
|
87
|
+
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */
|
|
88
|
+
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
|
|
89
|
+
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
|
|
90
|
+
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
|
|
91
|
+
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
|
|
92
|
+
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
|
|
93
|
+
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type */
|
|
94
|
+
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
|
|
95
|
+
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
|
|
96
|
+
|
|
97
|
+
/* Completeness */
|
|
98
|
+
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
|
99
|
+
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
|
100
|
+
},
|
|
101
|
+
"exclude": ["dist", "**/*.spec.ts"]
|
|
102
|
+
}
|
package/typedoc.json
ADDED