tgui-core 1.0.6 → 1.0.7
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/README.md +2 -2
- package/dist/assets.d.ts +4 -0
- package/dist/assets.js +26 -0
- package/dist/common/collections.d.ts +78 -0
- package/dist/common/collections.js +139 -0
- package/dist/common/color.d.ts +30 -0
- package/dist/common/color.js +74 -0
- package/dist/common/events.d.ts +15 -0
- package/dist/common/events.js +37 -0
- package/{common/exhaustive.ts → dist/common/exhaustive.d.ts} +17 -19
- package/dist/common/exhaustive.js +6 -0
- package/{common/fp.ts → dist/common/fp.d.ts} +23 -38
- package/dist/common/fp.js +14 -0
- package/dist/common/keycodes.d.ts +85 -0
- package/dist/common/keycodes.js +88 -0
- package/{common/keys.ts → dist/common/keys.d.ts} +39 -39
- package/dist/common/keys.js +4 -0
- package/dist/common/math.d.ts +48 -0
- package/dist/common/math.js +27 -0
- package/dist/common/perf.d.ts +24 -0
- package/dist/common/perf.js +35 -0
- package/dist/common/random.d.ts +16 -0
- package/dist/common/random.js +11 -0
- package/dist/common/react.d.ts +28 -0
- package/dist/common/react.js +28 -0
- package/dist/common/redux.d.ts +69 -0
- package/dist/common/redux.js +70 -0
- package/dist/common/storage.js +124 -0
- package/dist/common/string.d.ts +70 -0
- package/dist/common/string.js +86 -0
- package/dist/common/timer.d.ts +23 -0
- package/dist/common/timer.js +28 -0
- package/dist/common/type-utils.d.ts +9 -0
- package/dist/common/type-utils.js +25 -0
- package/dist/common/types.d.ts +4 -0
- package/dist/common/types.js +1 -0
- package/dist/common/uuid.d.ts +14 -0
- package/dist/common/uuid.js +15 -0
- package/dist/common/vector.d.ts +18 -0
- package/dist/common/vector.js +24 -0
- package/dist/components/AnimatedNumber.d.ts +59 -0
- package/dist/components/AnimatedNumber.js +73 -0
- package/dist/components/Autofocus.d.ts +4 -0
- package/dist/components/Autofocus.js +17 -0
- package/dist/components/Blink.d.ts +26 -0
- package/dist/components/Blink.js +56 -0
- package/dist/components/BlockQuote.d.ts +3 -0
- package/dist/components/BlockQuote.js +10 -0
- package/dist/components/BodyZoneSelector.d.ts +28 -0
- package/dist/components/BodyZoneSelector.js +115 -0
- package/dist/components/Box.d.ts +91 -0
- package/dist/components/Box.js +127 -0
- package/dist/components/Button.d.ts +73 -0
- package/dist/components/Button.js +256 -0
- package/dist/components/ByondUi.js +72 -0
- package/dist/components/Chart.d.ts +28 -0
- package/dist/components/Chart.js +96 -0
- package/dist/components/Collapsible.d.ts +11 -0
- package/dist/components/Collapsible.js +27 -0
- package/dist/components/ColorBox.d.ts +8 -0
- package/dist/components/ColorBox.js +17 -0
- package/dist/components/Dialog.d.ts +23 -0
- package/dist/components/Dialog.js +57 -0
- package/dist/components/Dimmer.d.ts +3 -0
- package/dist/components/Dimmer.js +10 -0
- package/dist/components/Divider.d.ts +11 -0
- package/dist/components/Divider.js +18 -0
- package/dist/components/DmIcon.d.ts +30 -0
- package/dist/components/DmIcon.js +28 -0
- package/dist/components/DraggableControl.js +174 -0
- package/dist/components/Dropdown.d.ts +48 -0
- package/dist/components/Dropdown.js +152 -0
- package/dist/components/FakeTerminal.js +38 -0
- package/dist/components/FitText.d.ts +22 -0
- package/dist/components/FitText.js +63 -0
- package/dist/components/Flex.d.ts +27 -0
- package/dist/components/Flex.js +63 -0
- package/dist/components/Icon.d.ts +25 -0
- package/dist/components/Icon.js +42 -0
- package/dist/components/Image.d.ts +20 -0
- package/dist/components/Image.js +35 -0
- package/dist/components/InfinitePlane.js +139 -0
- package/dist/components/Input.d.ts +61 -0
- package/dist/components/Input.js +84 -0
- package/dist/components/KeyListener.d.ts +15 -0
- package/dist/components/KeyListener.js +23 -0
- package/dist/components/Knob.d.ts +49 -0
- package/dist/components/Knob.js +131 -0
- package/dist/components/LabeledControls.d.ts +11 -0
- package/dist/components/LabeledControls.js +39 -0
- package/dist/components/LabeledList.d.ts +27 -0
- package/dist/components/LabeledList.js +85 -0
- package/dist/components/MenuBar.d.ts +33 -0
- package/dist/components/MenuBar.js +162 -0
- package/dist/components/Modal.d.ts +3 -0
- package/dist/components/Modal.js +18 -0
- package/dist/components/NoticeBox.d.ts +17 -0
- package/dist/components/NoticeBox.js +23 -0
- package/dist/components/NumberInput.d.ts +45 -0
- package/dist/components/NumberInput.js +215 -0
- package/dist/components/Popper.d.ts +27 -0
- package/dist/components/Popper.js +194 -0
- package/dist/components/ProgressBar.d.ts +19 -0
- package/dist/components/ProgressBar.js +32 -0
- package/dist/components/RestrictedInput.js +149 -0
- package/dist/components/RoundGauge.d.ts +53 -0
- package/dist/components/RoundGauge.js +112 -0
- package/dist/components/Section.d.ts +63 -0
- package/dist/components/Section.js +61 -0
- package/dist/components/Slider.d.ts +46 -0
- package/dist/components/Slider.js +116 -0
- package/dist/components/Stack.d.ts +27 -0
- package/dist/components/Stack.js +60 -0
- package/dist/components/StyleableSection.d.ts +11 -0
- package/dist/components/StyleableSection.js +12 -0
- package/dist/components/Table.d.ts +29 -0
- package/dist/components/Table.js +58 -0
- package/dist/components/Tabs.d.ts +23 -0
- package/dist/components/Tabs.js +56 -0
- package/dist/components/TextArea.d.ts +39 -0
- package/dist/components/TextArea.js +124 -0
- package/dist/components/TimeDisplay.js +32 -0
- package/dist/components/Tooltip.d.ts +25 -0
- package/dist/components/Tooltip.js +81 -0
- package/dist/components/TrackOutsideClicks.d.ts +13 -0
- package/dist/components/TrackOutsideClicks.js +24 -0
- package/dist/components/VirtualList.d.ts +8 -0
- package/dist/components/VirtualList.js +34 -0
- package/{components/index.ts → dist/components/index.d.ts} +0 -1
- package/dist/components/index.js +92 -0
- package/dist/constants.d.ts +107 -0
- package/dist/constants.js +317 -0
- package/dist/events.d.ts +25 -0
- package/dist/events.js +123 -0
- package/dist/format.d.ts +16 -0
- package/dist/format.js +110 -0
- package/dist/hotkeys.d.ts +25 -0
- package/dist/hotkeys.js +123 -0
- package/dist/http.d.ts +4 -0
- package/dist/http.js +8 -0
- package/dist/popper-Dm3m9eeZ.js +907 -0
- package/package.json +23 -11
- package/.editorconfig +0 -10
- package/.eslintrc.cjs +0 -78
- package/.gitattributes +0 -4
- package/.prettierrc.yml +0 -1
- package/.vscode/extensions.json +0 -6
- package/.vscode/settings.json +0 -5
- package/common/collections.ts +0 -349
- package/common/color.ts +0 -94
- package/common/events.ts +0 -45
- package/common/keycodes.ts +0 -86
- package/common/math.ts +0 -98
- package/common/perf.ts +0 -72
- package/common/random.ts +0 -32
- package/common/react.ts +0 -65
- package/common/redux.ts +0 -196
- package/common/storage.js +0 -196
- package/common/string.ts +0 -173
- package/common/timer.ts +0 -68
- package/common/type-utils.ts +0 -41
- package/common/types.ts +0 -9
- package/common/uuid.ts +0 -24
- package/common/vector.ts +0 -51
- package/components/AnimatedNumber.tsx +0 -185
- package/components/Autofocus.tsx +0 -23
- package/components/Blink.jsx +0 -69
- package/components/BlockQuote.tsx +0 -15
- package/components/BodyZoneSelector.tsx +0 -149
- package/components/Box.tsx +0 -255
- package/components/Button.tsx +0 -415
- package/components/ByondUi.jsx +0 -116
- package/components/Chart.tsx +0 -160
- package/components/Collapsible.tsx +0 -45
- package/components/ColorBox.tsx +0 -30
- package/components/Dialog.tsx +0 -85
- package/components/Dimmer.tsx +0 -19
- package/components/Divider.tsx +0 -26
- package/components/DmIcon.tsx +0 -72
- package/components/DraggableControl.jsx +0 -282
- package/components/Dropdown.tsx +0 -246
- package/components/FakeTerminal.jsx +0 -52
- package/components/FitText.tsx +0 -99
- package/components/Flex.tsx +0 -105
- package/components/Icon.tsx +0 -91
- package/components/Image.tsx +0 -63
- package/components/InfinitePlane.jsx +0 -192
- package/components/Input.tsx +0 -181
- package/components/KeyListener.tsx +0 -40
- package/components/Knob.tsx +0 -185
- package/components/LabeledControls.tsx +0 -50
- package/components/LabeledList.tsx +0 -130
- package/components/MenuBar.tsx +0 -233
- package/components/Modal.tsx +0 -25
- package/components/NoticeBox.tsx +0 -48
- package/components/NumberInput.tsx +0 -328
- package/components/Popper.tsx +0 -100
- package/components/ProgressBar.tsx +0 -79
- package/components/RestrictedInput.jsx +0 -301
- package/components/RoundGauge.tsx +0 -189
- package/components/Section.tsx +0 -125
- package/components/Slider.tsx +0 -173
- package/components/Stack.tsx +0 -101
- package/components/StyleableSection.tsx +0 -30
- package/components/Table.tsx +0 -90
- package/components/Tabs.tsx +0 -90
- package/components/TextArea.tsx +0 -198
- package/components/TimeDisplay.jsx +0 -64
- package/components/Tooltip.tsx +0 -147
- package/components/TrackOutsideClicks.tsx +0 -35
- package/components/VirtualList.tsx +0 -69
- package/global.d.ts +0 -173
- package/src/assets.ts +0 -43
- package/src/constants.ts +0 -355
- package/src/events.ts +0 -237
- package/src/format.ts +0 -173
- package/src/hotkeys.ts +0 -212
- package/src/http.ts +0 -16
- package/styles/base.scss +0 -32
- package/styles/colors.scss +0 -92
- package/styles/components/BlockQuote.scss +0 -20
- package/styles/components/Button.scss +0 -175
- package/styles/components/ColorBox.scss +0 -12
- package/styles/components/Dialog.scss +0 -105
- package/styles/components/Dimmer.scss +0 -22
- package/styles/components/Divider.scss +0 -27
- package/styles/components/Dropdown.scss +0 -72
- package/styles/components/Flex.scss +0 -31
- package/styles/components/Icon.scss +0 -25
- package/styles/components/Input.scss +0 -68
- package/styles/components/Knob.scss +0 -131
- package/styles/components/LabeledList.scss +0 -49
- package/styles/components/MenuBar.scss +0 -75
- package/styles/components/Modal.scss +0 -14
- package/styles/components/NoticeBox.scss +0 -65
- package/styles/components/NumberInput.scss +0 -76
- package/styles/components/ProgressBar.scss +0 -63
- package/styles/components/RoundGauge.scss +0 -88
- package/styles/components/Section.scss +0 -143
- package/styles/components/Slider.scss +0 -54
- package/styles/components/Stack.scss +0 -59
- package/styles/components/Table.scss +0 -44
- package/styles/components/Tabs.scss +0 -144
- package/styles/components/TextArea.scss +0 -84
- package/styles/components/Tooltip.scss +0 -24
- package/styles/functions.scss +0 -79
- package/styles/main.scss +0 -58
- package/styles/reset.scss +0 -68
- package/tsconfig.json +0 -33
package/README.md
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
A collection of utilities and components for the [tgui](https://github.com/tgstation/tgstation) framework.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
This package was built to help the various downstream SS13 servers stay up to date with TGUI without having to keep a local version of each file.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
You can view the code on [GitHub](https://github.com/jlsnow301/tgui-core).
|
|
8
8
|
|
|
9
9
|
## Installation
|
|
10
10
|
|
package/dist/assets.d.ts
ADDED
package/dist/assets.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file
|
|
3
|
+
* @copyright 2020 Aleksej Komarov
|
|
4
|
+
* @license MIT
|
|
5
|
+
*/
|
|
6
|
+
const l = [/v4shim/i], d = {}, r = (t) => d[t] || t, f = (t) => (p) => (n) => {
|
|
7
|
+
const { type: i, payload: e } = n;
|
|
8
|
+
if (i === "asset/stylesheet") {
|
|
9
|
+
Byond.loadCss(e);
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
if (i === "asset/mappings") {
|
|
13
|
+
for (const s of Object.keys(e)) {
|
|
14
|
+
if (l.some((c) => c.test(s)))
|
|
15
|
+
continue;
|
|
16
|
+
const o = e[s], a = s.split(".").pop();
|
|
17
|
+
d[s] = o, a === "css" && Byond.loadCss(o), a === "js" && Byond.loadJs(o);
|
|
18
|
+
}
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
p(n);
|
|
22
|
+
};
|
|
23
|
+
export {
|
|
24
|
+
f as assetMiddleware,
|
|
25
|
+
r as resolveAsset
|
|
26
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file
|
|
3
|
+
* @copyright 2020 Aleksej Komarov
|
|
4
|
+
* @license MIT
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Iterates over elements of collection, returning an array of all elements
|
|
8
|
+
* iteratee returns truthy for. The predicate is invoked with three
|
|
9
|
+
* arguments: (value, index|key, collection).
|
|
10
|
+
*
|
|
11
|
+
* If collection is 'null' or 'undefined', it will be returned "as is"
|
|
12
|
+
* without emitting any errors (which can be useful in some cases).
|
|
13
|
+
*/
|
|
14
|
+
export declare const filter: <T>(collection: T[], iterateeFn: (input: T, index: number, collection: T[]) => boolean) => T[];
|
|
15
|
+
type MapFunction = {
|
|
16
|
+
<T, U>(collection: T[], iterateeFn: (value: T, index: number, collection: T[]) => U): U[];
|
|
17
|
+
<T, U, K extends string | number>(collection: Record<K, T>, iterateeFn: (value: T, index: K, collection: Record<K, T>) => U): U[];
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Creates an array of values by running each element in collection
|
|
21
|
+
* thru an iteratee function. The iteratee is invoked with three
|
|
22
|
+
* arguments: (value, index|key, collection).
|
|
23
|
+
*
|
|
24
|
+
* If collection is 'null' or 'undefined', it will be returned "as is"
|
|
25
|
+
* without emitting any errors (which can be useful in some cases).
|
|
26
|
+
*/
|
|
27
|
+
export declare const map: MapFunction;
|
|
28
|
+
/**
|
|
29
|
+
* Creates an array of elements, sorted in ascending order by the results
|
|
30
|
+
* of running each element in a collection thru each iteratee.
|
|
31
|
+
*
|
|
32
|
+
* Iteratees are called with one argument (value).
|
|
33
|
+
*/
|
|
34
|
+
export declare const sortBy: <T>(array: T[], ...iterateeFns: ((input: T) => unknown)[]) => T[];
|
|
35
|
+
export declare const sort: <T>(array: T[]) => T[];
|
|
36
|
+
/**
|
|
37
|
+
* Returns a range of numbers from start to end, exclusively.
|
|
38
|
+
* For example, range(0, 5) will return [0, 1, 2, 3, 4].
|
|
39
|
+
*/
|
|
40
|
+
export declare const range: (start: number, end: number) => number[];
|
|
41
|
+
type ReduceFunction = {
|
|
42
|
+
<T, U>(array: T[], reducerFn: (accumulator: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U;
|
|
43
|
+
<T>(array: T[], reducerFn: (accumulator: T, currentValue: T, currentIndex: number, array: T[]) => T): T;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* A fast implementation of reduce.
|
|
47
|
+
*/
|
|
48
|
+
export declare const reduce: ReduceFunction;
|
|
49
|
+
/**
|
|
50
|
+
* Creates a duplicate-free version of an array, using SameValueZero for
|
|
51
|
+
* equality comparisons, in which only the first occurrence of each element
|
|
52
|
+
* is kept. The order of result values is determined by the order they occur
|
|
53
|
+
* in the array.
|
|
54
|
+
*
|
|
55
|
+
* It accepts iteratee which is invoked for each element in array to generate
|
|
56
|
+
* the criterion by which uniqueness is computed. The order of result values
|
|
57
|
+
* is determined by the order they occur in the array. The iteratee is
|
|
58
|
+
* invoked with one argument: value.
|
|
59
|
+
*/
|
|
60
|
+
export declare const uniqBy: <T extends unknown>(array: T[], iterateeFn?: (value: T) => unknown) => T[];
|
|
61
|
+
export declare const uniq: <T>(array: T[]) => T[];
|
|
62
|
+
type Zip<T extends unknown[][]> = {
|
|
63
|
+
[I in keyof T]: T[I] extends (infer U)[] ? U : never;
|
|
64
|
+
}[];
|
|
65
|
+
/**
|
|
66
|
+
* Creates an array of grouped elements, the first of which contains
|
|
67
|
+
* the first elements of the given arrays, the second of which contains
|
|
68
|
+
* the second elements of the given arrays, and so on.
|
|
69
|
+
*/
|
|
70
|
+
export declare const zip: <T extends unknown[][]>(...arrays: T) => Zip<T>;
|
|
71
|
+
export declare const binaryInsertWith: <T, U = unknown>(collection: readonly T[], value: T, getKey: (value: T) => U) => T[];
|
|
72
|
+
/**
|
|
73
|
+
* This method takes a collection of items and a number, returning a collection
|
|
74
|
+
* of collections, where the maximum amount of items in each is that second arg
|
|
75
|
+
*/
|
|
76
|
+
export declare const paginate: <T>(collection: T[], maxPerPage: number) => T[][];
|
|
77
|
+
export declare const deepMerge: (...objects: any[]) => any;
|
|
78
|
+
export {};
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file
|
|
3
|
+
* @copyright 2020 Aleksej Komarov
|
|
4
|
+
* @license MIT
|
|
5
|
+
*/
|
|
6
|
+
const y = (t, n) => {
|
|
7
|
+
if (t == null)
|
|
8
|
+
return t;
|
|
9
|
+
if (Array.isArray(t)) {
|
|
10
|
+
const s = [];
|
|
11
|
+
for (let e = 0; e < t.length; e++) {
|
|
12
|
+
const r = t[e];
|
|
13
|
+
n(r, e, t) && s.push(r);
|
|
14
|
+
}
|
|
15
|
+
return s;
|
|
16
|
+
}
|
|
17
|
+
throw new Error(`filter() can't iterate on type ${typeof t}`);
|
|
18
|
+
}, d = (t, n) => {
|
|
19
|
+
if (t == null)
|
|
20
|
+
return t;
|
|
21
|
+
if (Array.isArray(t)) {
|
|
22
|
+
const s = [];
|
|
23
|
+
for (let e = 0; e < t.length; e++)
|
|
24
|
+
s.push(n(t[e], e, t));
|
|
25
|
+
return s;
|
|
26
|
+
}
|
|
27
|
+
if (typeof t == "object") {
|
|
28
|
+
const s = [];
|
|
29
|
+
for (let e in t)
|
|
30
|
+
Object.prototype.hasOwnProperty.call(t, e) && s.push(n(t[e], e, t));
|
|
31
|
+
return s;
|
|
32
|
+
}
|
|
33
|
+
throw new Error(`map() can't iterate on type ${typeof t}`);
|
|
34
|
+
}, p = (t, n) => {
|
|
35
|
+
const s = t.criteria, e = n.criteria, r = s.length;
|
|
36
|
+
for (let u = 0; u < r; u++) {
|
|
37
|
+
const i = s[u], f = e[u];
|
|
38
|
+
if (i < f)
|
|
39
|
+
return -1;
|
|
40
|
+
if (i > f)
|
|
41
|
+
return 1;
|
|
42
|
+
}
|
|
43
|
+
return 0;
|
|
44
|
+
}, l = (t, ...n) => {
|
|
45
|
+
if (!Array.isArray(t))
|
|
46
|
+
return t;
|
|
47
|
+
let s = t.length, e = [];
|
|
48
|
+
for (let u = 0; u < s; u++) {
|
|
49
|
+
const i = t[u];
|
|
50
|
+
e.push({
|
|
51
|
+
criteria: n.map((f) => f(i)),
|
|
52
|
+
value: i
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
e.sort(p);
|
|
56
|
+
const r = [];
|
|
57
|
+
for (; s--; )
|
|
58
|
+
r[s] = e[s].value;
|
|
59
|
+
return r;
|
|
60
|
+
}, A = (t) => l(t), m = (t, n) => new Array(n - t).fill(null).map((s, e) => e + t), w = (t, n, s) => {
|
|
61
|
+
const e = t.length;
|
|
62
|
+
let r, u;
|
|
63
|
+
for (s === void 0 ? (r = 1, u = t[0]) : (r = 0, u = s); r < e; r++)
|
|
64
|
+
u = n(u, t[r], r, t);
|
|
65
|
+
return u;
|
|
66
|
+
}, c = (t, n) => {
|
|
67
|
+
const { length: s } = t, e = [], r = n ? [] : e;
|
|
68
|
+
let u = -1;
|
|
69
|
+
t:
|
|
70
|
+
for (; ++u < s; ) {
|
|
71
|
+
let i = t[u];
|
|
72
|
+
const f = n ? n(i) : i;
|
|
73
|
+
if (f === f) {
|
|
74
|
+
let o = r.length;
|
|
75
|
+
for (; o--; )
|
|
76
|
+
if (r[o] === f)
|
|
77
|
+
continue t;
|
|
78
|
+
n && r.push(f), e.push(i);
|
|
79
|
+
} else
|
|
80
|
+
r.includes(f) || (r !== e && r.push(f), e.push(i));
|
|
81
|
+
}
|
|
82
|
+
return e;
|
|
83
|
+
}, b = (t) => c(t), v = (...t) => {
|
|
84
|
+
if (t.length === 0)
|
|
85
|
+
return [];
|
|
86
|
+
const n = t.length, s = t[0].length, e = [];
|
|
87
|
+
for (let r = 0; r < s; r++) {
|
|
88
|
+
const u = [];
|
|
89
|
+
for (let i = 0; i < n; i++)
|
|
90
|
+
u.push(t[i][r]);
|
|
91
|
+
e.push(u);
|
|
92
|
+
}
|
|
93
|
+
return e;
|
|
94
|
+
}, g = (t, n, s) => {
|
|
95
|
+
if (n.length === 0)
|
|
96
|
+
return 0;
|
|
97
|
+
const e = t(s);
|
|
98
|
+
let [r, u] = [0, n.length], i, f = 0;
|
|
99
|
+
for (; r < u; )
|
|
100
|
+
if (f = r + u >> 1, i = t(n[f]), i < e)
|
|
101
|
+
r = f + 1;
|
|
102
|
+
else {
|
|
103
|
+
if (i === e)
|
|
104
|
+
return f;
|
|
105
|
+
u = f;
|
|
106
|
+
}
|
|
107
|
+
return i > e ? f : f + 1;
|
|
108
|
+
}, j = (t, n, s) => {
|
|
109
|
+
const e = [...t];
|
|
110
|
+
return e.splice(g(s, t, n), 0, n), e;
|
|
111
|
+
}, O = (t, n) => {
|
|
112
|
+
const s = [];
|
|
113
|
+
let e = [], r = n;
|
|
114
|
+
for (const u of t)
|
|
115
|
+
e.push(u), r--, r || (r = n, s.push(e), e = []);
|
|
116
|
+
return e.length && s.push(e), s;
|
|
117
|
+
}, h = (t) => typeof t == "object" && t !== null, a = (...t) => {
|
|
118
|
+
const n = {};
|
|
119
|
+
for (const s of t)
|
|
120
|
+
for (const e of Object.keys(s)) {
|
|
121
|
+
const r = n[e], u = s[e];
|
|
122
|
+
Array.isArray(r) && Array.isArray(u) ? n[e] = [...r, ...u] : h(r) && h(u) ? n[e] = a(r, u) : n[e] = u;
|
|
123
|
+
}
|
|
124
|
+
return n;
|
|
125
|
+
};
|
|
126
|
+
export {
|
|
127
|
+
j as binaryInsertWith,
|
|
128
|
+
a as deepMerge,
|
|
129
|
+
y as filter,
|
|
130
|
+
d as map,
|
|
131
|
+
O as paginate,
|
|
132
|
+
m as range,
|
|
133
|
+
w as reduce,
|
|
134
|
+
A as sort,
|
|
135
|
+
l as sortBy,
|
|
136
|
+
b as uniq,
|
|
137
|
+
c as uniqBy,
|
|
138
|
+
v as zip
|
|
139
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file
|
|
3
|
+
* @copyright 2020 Aleksej Komarov
|
|
4
|
+
* @license MIT
|
|
5
|
+
*/
|
|
6
|
+
export declare class Color {
|
|
7
|
+
r: number;
|
|
8
|
+
g: number;
|
|
9
|
+
b: number;
|
|
10
|
+
a: number;
|
|
11
|
+
constructor(r?: number, g?: number, b?: number, a?: number);
|
|
12
|
+
toString(): string;
|
|
13
|
+
/** Darkens a color by a given percent. Returns a color, which can have toString called to get it's rgba() css value. */
|
|
14
|
+
darken(percent: number): Color;
|
|
15
|
+
/** Brightens a color by a given percent. Returns a color, which can have toString called to get it's rgba() css value. */
|
|
16
|
+
lighten(percent: number): Color;
|
|
17
|
+
/**
|
|
18
|
+
* Creates a color from the CSS hex color notation.
|
|
19
|
+
*/
|
|
20
|
+
static fromHex(hex: string): Color;
|
|
21
|
+
/**
|
|
22
|
+
* Linear interpolation of two colors.
|
|
23
|
+
*/
|
|
24
|
+
static lerp(c1: Color, c2: Color, n: number): Color;
|
|
25
|
+
/**
|
|
26
|
+
* Loops up the color in the provided list of colors
|
|
27
|
+
* with linear interpolation.
|
|
28
|
+
*/
|
|
29
|
+
static lookup(value: number, colors: Color[]): Color;
|
|
30
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
var b = Object.defineProperty;
|
|
2
|
+
var l = (i, t, s) => t in i ? b(i, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : i[t] = s;
|
|
3
|
+
var e = (i, t, s) => (l(i, typeof t != "symbol" ? t + "" : t, s), s);
|
|
4
|
+
/**
|
|
5
|
+
* @file
|
|
6
|
+
* @copyright 2020 Aleksej Komarov
|
|
7
|
+
* @license MIT
|
|
8
|
+
*/
|
|
9
|
+
class n {
|
|
10
|
+
constructor(t = 0, s = 0, r = 0, a = 1) {
|
|
11
|
+
e(this, "r");
|
|
12
|
+
e(this, "g");
|
|
13
|
+
e(this, "b");
|
|
14
|
+
e(this, "a");
|
|
15
|
+
this.r = t, this.g = s, this.b = r, this.a = a;
|
|
16
|
+
}
|
|
17
|
+
toString() {
|
|
18
|
+
let t = this.a;
|
|
19
|
+
return typeof t == "string" && (t = parseFloat(this.a)), isNaN(t) && (t = 1), `rgba(${this.r | 0}, ${this.g | 0}, ${this.b | 0}, ${t})`;
|
|
20
|
+
}
|
|
21
|
+
/** Darkens a color by a given percent. Returns a color, which can have toString called to get it's rgba() css value. */
|
|
22
|
+
darken(t) {
|
|
23
|
+
return t /= 100, new n(
|
|
24
|
+
this.r - this.r * t,
|
|
25
|
+
this.g - this.g * t,
|
|
26
|
+
this.b - this.b * t,
|
|
27
|
+
this.a
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
/** Brightens a color by a given percent. Returns a color, which can have toString called to get it's rgba() css value. */
|
|
31
|
+
lighten(t) {
|
|
32
|
+
return this.darken(-t);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Creates a color from the CSS hex color notation.
|
|
36
|
+
*/
|
|
37
|
+
static fromHex(t) {
|
|
38
|
+
return new n(
|
|
39
|
+
parseInt(t.slice(1, 3), 16),
|
|
40
|
+
parseInt(t.slice(3, 5), 16),
|
|
41
|
+
parseInt(t.slice(5, 7), 16)
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Linear interpolation of two colors.
|
|
46
|
+
*/
|
|
47
|
+
static lerp(t, s, r) {
|
|
48
|
+
return new n(
|
|
49
|
+
(s.r - t.r) * r + t.r,
|
|
50
|
+
(s.g - t.g) * r + t.g,
|
|
51
|
+
(s.b - t.b) * r + t.b,
|
|
52
|
+
(s.a - t.a) * r + t.a
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Loops up the color in the provided list of colors
|
|
57
|
+
* with linear interpolation.
|
|
58
|
+
*/
|
|
59
|
+
static lookup(t, s) {
|
|
60
|
+
const r = s.length;
|
|
61
|
+
if (r < 2)
|
|
62
|
+
throw new Error("Needs at least two colors!");
|
|
63
|
+
const a = t * (r - 1);
|
|
64
|
+
if (t < 1e-4)
|
|
65
|
+
return s[0];
|
|
66
|
+
if (t >= 1 - 1e-4)
|
|
67
|
+
return s[r - 1];
|
|
68
|
+
const g = a % 1, h = a | 0;
|
|
69
|
+
return this.lerp(s[h], s[h + 1], g);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
export {
|
|
73
|
+
n as Color
|
|
74
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file
|
|
3
|
+
* @copyright 2020 Aleksej Komarov
|
|
4
|
+
* @license MIT
|
|
5
|
+
*/
|
|
6
|
+
type Fn = (...args: any[]) => void;
|
|
7
|
+
export declare class EventEmitter {
|
|
8
|
+
private listeners;
|
|
9
|
+
constructor();
|
|
10
|
+
on(name: string, listener: Fn): void;
|
|
11
|
+
off(name: string, listener: Fn): void;
|
|
12
|
+
emit(name: string, ...params: any[]): void;
|
|
13
|
+
clear(): void;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
var h = Object.defineProperty;
|
|
2
|
+
var c = (e, s, t) => s in e ? h(e, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[s] = t;
|
|
3
|
+
var n = (e, s, t) => (c(e, typeof s != "symbol" ? s + "" : s, t), t);
|
|
4
|
+
/**
|
|
5
|
+
* @file
|
|
6
|
+
* @copyright 2020 Aleksej Komarov
|
|
7
|
+
* @license MIT
|
|
8
|
+
*/
|
|
9
|
+
class u {
|
|
10
|
+
constructor() {
|
|
11
|
+
n(this, "listeners");
|
|
12
|
+
this.listeners = {};
|
|
13
|
+
}
|
|
14
|
+
on(s, t) {
|
|
15
|
+
this.listeners[s] = this.listeners[s] || [], this.listeners[s].push(t);
|
|
16
|
+
}
|
|
17
|
+
off(s, t) {
|
|
18
|
+
const r = this.listeners[s];
|
|
19
|
+
if (!r)
|
|
20
|
+
throw new Error(`There is no listeners for "${s}"`);
|
|
21
|
+
this.listeners[s] = r.filter((i) => i !== t);
|
|
22
|
+
}
|
|
23
|
+
emit(s, ...t) {
|
|
24
|
+
const r = this.listeners[s];
|
|
25
|
+
if (r)
|
|
26
|
+
for (let i = 0, l = r.length; i < l; i += 1) {
|
|
27
|
+
const o = r[i];
|
|
28
|
+
o(...t);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
clear() {
|
|
32
|
+
this.listeners = {};
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export {
|
|
36
|
+
u as EventEmitter
|
|
37
|
+
};
|
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Throws an error such that a non-exhaustive check will error at compile time
|
|
3
|
-
* when using TypeScript, rather than at runtime.
|
|
4
|
-
*
|
|
5
|
-
* For example:
|
|
6
|
-
* enum Color { Red, Green, Blue }
|
|
7
|
-
* switch (color) {
|
|
8
|
-
* case Color.Red:
|
|
9
|
-
* return "red";
|
|
10
|
-
* case Color.Green:
|
|
11
|
-
* return "green";
|
|
12
|
-
* default:
|
|
13
|
-
* // This will error at compile time that we forgot blue.
|
|
14
|
-
* exhaustiveCheck(color);
|
|
15
|
-
* }
|
|
16
|
-
*/
|
|
17
|
-
export const exhaustiveCheck
|
|
18
|
-
throw new Error(`Unhandled case: ${input}`);
|
|
19
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* Throws an error such that a non-exhaustive check will error at compile time
|
|
3
|
+
* when using TypeScript, rather than at runtime.
|
|
4
|
+
*
|
|
5
|
+
* For example:
|
|
6
|
+
* enum Color { Red, Green, Blue }
|
|
7
|
+
* switch (color) {
|
|
8
|
+
* case Color.Red:
|
|
9
|
+
* return "red";
|
|
10
|
+
* case Color.Green:
|
|
11
|
+
* return "green";
|
|
12
|
+
* default:
|
|
13
|
+
* // This will error at compile time that we forgot blue.
|
|
14
|
+
* exhaustiveCheck(color);
|
|
15
|
+
* }
|
|
16
|
+
*/
|
|
17
|
+
export declare const exhaustiveCheck: (input: never) => never;
|
|
@@ -1,38 +1,23 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file
|
|
3
|
-
* @copyright 2020 Aleksej Komarov
|
|
4
|
-
* @license MIT
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* const
|
|
17
|
-
*
|
|
18
|
-
* const
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
export const flow =
|
|
25
|
-
(...funcs: Array<Func | Func[]>) =>
|
|
26
|
-
(input: any, ...rest: any[]): any => {
|
|
27
|
-
let output = input;
|
|
28
|
-
|
|
29
|
-
for (let func of funcs) {
|
|
30
|
-
// Recurse into the array of functions
|
|
31
|
-
if (Array.isArray(func)) {
|
|
32
|
-
output = flow(...func)(output, ...rest);
|
|
33
|
-
} else if (func) {
|
|
34
|
-
output = func(output, ...rest);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return output;
|
|
38
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* @file
|
|
3
|
+
* @copyright 2020 Aleksej Komarov
|
|
4
|
+
* @license MIT
|
|
5
|
+
*/
|
|
6
|
+
type Func = (...args: any[]) => any;
|
|
7
|
+
/**
|
|
8
|
+
* Creates a function that returns the result of invoking the given
|
|
9
|
+
* functions, where each successive invocation is supplied the return
|
|
10
|
+
* value of the previous.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* const add2 = (x) => x + 2;
|
|
15
|
+
* const multiplyBy3 = (x) => x * 3;
|
|
16
|
+
* const subtract5 = (x) => x - 5;
|
|
17
|
+
*
|
|
18
|
+
* const composedFunction = flow(add2, multiplyBy3, subtract5); // ((4 + 2) * 3) - 5 = 13
|
|
19
|
+
* const composedFunction2 = flow([add2, multiplyBy3], subtract5); // ((4 + 2) * 3) - 5 = 13
|
|
20
|
+
*
|
|
21
|
+
*/
|
|
22
|
+
export declare const flow: (...funcs: Array<Func | Func[]>) => (input: any, ...rest: any[]) => any;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file
|
|
3
|
+
* @copyright 2020 Aleksej Komarov
|
|
4
|
+
* @license MIT
|
|
5
|
+
*/
|
|
6
|
+
const l = (...t) => (e, ...o) => {
|
|
7
|
+
let r = e;
|
|
8
|
+
for (let f of t)
|
|
9
|
+
Array.isArray(f) ? r = l(...f)(r, ...o) : f && (r = f(r, ...o));
|
|
10
|
+
return r;
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
l as flow
|
|
14
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* All possible browser keycodes, in one file.
|
|
3
|
+
*
|
|
4
|
+
* @file
|
|
5
|
+
* @copyright 2020 Aleksej Komarov
|
|
6
|
+
* @license MIT
|
|
7
|
+
*/
|
|
8
|
+
export declare const KEY_BACKSPACE = 8;
|
|
9
|
+
export declare const KEY_TAB = 9;
|
|
10
|
+
export declare const KEY_ENTER = 13;
|
|
11
|
+
export declare const KEY_SHIFT = 16;
|
|
12
|
+
export declare const KEY_CTRL = 17;
|
|
13
|
+
export declare const KEY_ALT = 18;
|
|
14
|
+
export declare const KEY_PAUSE = 19;
|
|
15
|
+
export declare const KEY_CAPSLOCK = 20;
|
|
16
|
+
export declare const KEY_ESCAPE = 27;
|
|
17
|
+
export declare const KEY_SPACE = 32;
|
|
18
|
+
export declare const KEY_PAGEUP = 33;
|
|
19
|
+
export declare const KEY_PAGEDOWN = 34;
|
|
20
|
+
export declare const KEY_END = 35;
|
|
21
|
+
export declare const KEY_HOME = 36;
|
|
22
|
+
export declare const KEY_LEFT = 37;
|
|
23
|
+
export declare const KEY_UP = 38;
|
|
24
|
+
export declare const KEY_RIGHT = 39;
|
|
25
|
+
export declare const KEY_DOWN = 40;
|
|
26
|
+
export declare const KEY_INSERT = 45;
|
|
27
|
+
export declare const KEY_DELETE = 46;
|
|
28
|
+
export declare const KEY_0 = 48;
|
|
29
|
+
export declare const KEY_1 = 49;
|
|
30
|
+
export declare const KEY_2 = 50;
|
|
31
|
+
export declare const KEY_3 = 51;
|
|
32
|
+
export declare const KEY_4 = 52;
|
|
33
|
+
export declare const KEY_5 = 53;
|
|
34
|
+
export declare const KEY_6 = 54;
|
|
35
|
+
export declare const KEY_7 = 55;
|
|
36
|
+
export declare const KEY_8 = 56;
|
|
37
|
+
export declare const KEY_9 = 57;
|
|
38
|
+
export declare const KEY_A = 65;
|
|
39
|
+
export declare const KEY_B = 66;
|
|
40
|
+
export declare const KEY_C = 67;
|
|
41
|
+
export declare const KEY_D = 68;
|
|
42
|
+
export declare const KEY_E = 69;
|
|
43
|
+
export declare const KEY_F = 70;
|
|
44
|
+
export declare const KEY_G = 71;
|
|
45
|
+
export declare const KEY_H = 72;
|
|
46
|
+
export declare const KEY_I = 73;
|
|
47
|
+
export declare const KEY_J = 74;
|
|
48
|
+
export declare const KEY_K = 75;
|
|
49
|
+
export declare const KEY_L = 76;
|
|
50
|
+
export declare const KEY_M = 77;
|
|
51
|
+
export declare const KEY_N = 78;
|
|
52
|
+
export declare const KEY_O = 79;
|
|
53
|
+
export declare const KEY_P = 80;
|
|
54
|
+
export declare const KEY_Q = 81;
|
|
55
|
+
export declare const KEY_R = 82;
|
|
56
|
+
export declare const KEY_S = 83;
|
|
57
|
+
export declare const KEY_T = 84;
|
|
58
|
+
export declare const KEY_U = 85;
|
|
59
|
+
export declare const KEY_V = 86;
|
|
60
|
+
export declare const KEY_W = 87;
|
|
61
|
+
export declare const KEY_X = 88;
|
|
62
|
+
export declare const KEY_Y = 89;
|
|
63
|
+
export declare const KEY_Z = 90;
|
|
64
|
+
export declare const KEY_F1 = 112;
|
|
65
|
+
export declare const KEY_F2 = 113;
|
|
66
|
+
export declare const KEY_F3 = 114;
|
|
67
|
+
export declare const KEY_F4 = 115;
|
|
68
|
+
export declare const KEY_F5 = 116;
|
|
69
|
+
export declare const KEY_F6 = 117;
|
|
70
|
+
export declare const KEY_F7 = 118;
|
|
71
|
+
export declare const KEY_F8 = 119;
|
|
72
|
+
export declare const KEY_F9 = 120;
|
|
73
|
+
export declare const KEY_F10 = 121;
|
|
74
|
+
export declare const KEY_F11 = 122;
|
|
75
|
+
export declare const KEY_F12 = 123;
|
|
76
|
+
export declare const KEY_SEMICOLON = 186;
|
|
77
|
+
export declare const KEY_EQUAL = 187;
|
|
78
|
+
export declare const KEY_COMMA = 188;
|
|
79
|
+
export declare const KEY_MINUS = 189;
|
|
80
|
+
export declare const KEY_PERIOD = 190;
|
|
81
|
+
export declare const KEY_SLASH = 191;
|
|
82
|
+
export declare const KEY_LEFT_BRACKET = 219;
|
|
83
|
+
export declare const KEY_BACKSLASH = 220;
|
|
84
|
+
export declare const KEY_RIGHT_BRACKET = 221;
|
|
85
|
+
export declare const KEY_QUOTE = 222;
|