silentium 0.0.175 → 0.0.177
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 +14 -0
- package/dist/silentium.cjs +21 -2
- package/dist/silentium.cjs.map +1 -1
- package/dist/silentium.d.ts +5 -2
- package/dist/silentium.js +21 -2
- package/dist/silentium.js.map +1 -1
- package/dist/silentium.min.js +1 -1
- package/dist/silentium.min.mjs +1 -1
- package/dist/silentium.min.mjs.map +1 -1
- package/dist/silentium.mjs +21 -2
- package/dist/silentium.mjs.map +1 -1
- package/package.json +1 -1
- package/src/global.d.ts +13 -4
- package/src/helpers/DevTools.test.ts +1 -1
- package/src/helpers/DevTools.ts +43 -4
package/src/helpers/DevTools.ts
CHANGED
|
@@ -2,30 +2,69 @@ import { All } from "components/All";
|
|
|
2
2
|
import { Applied } from "components/Applied";
|
|
3
3
|
import { Primitive } from "components/Primitive";
|
|
4
4
|
import { Shared } from "components/Shared";
|
|
5
|
+
import { DestroyableType } from "types/DestroyableType";
|
|
5
6
|
import { MessageType } from "types/MessageType";
|
|
6
7
|
|
|
7
8
|
declare global {
|
|
8
9
|
interface GlobalThis {
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
silentiumDebug: {
|
|
11
|
+
value: ($message: MessageType) => unknown;
|
|
12
|
+
print: (...messages: MessageType[]) => void;
|
|
13
|
+
destroyable: (
|
|
14
|
+
onDestroy: () => void,
|
|
15
|
+
) => MessageType<any> & DestroyableType;
|
|
16
|
+
};
|
|
11
17
|
}
|
|
12
18
|
}
|
|
13
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Helps to print message value
|
|
22
|
+
*/
|
|
14
23
|
const silentiumPrint = (...messages: MessageType[]) => {
|
|
15
24
|
Applied(All(...messages.map((e) => Shared(e))), JSON.stringify).then(
|
|
16
25
|
console.log,
|
|
17
26
|
);
|
|
18
27
|
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Helps to debug current value of message
|
|
31
|
+
*/
|
|
19
32
|
const silentiumValue = ($message: MessageType) =>
|
|
20
33
|
Primitive($message).primitive();
|
|
21
34
|
|
|
35
|
+
class MessageDestroyable implements MessageType<any>, DestroyableType {
|
|
36
|
+
public constructor(private onDestroy: () => void) {}
|
|
37
|
+
|
|
38
|
+
public then() {
|
|
39
|
+
return this;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public catch() {
|
|
43
|
+
return this;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
public destroy() {
|
|
47
|
+
this.onDestroy();
|
|
48
|
+
return this;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Helps to debug destroying
|
|
54
|
+
*/
|
|
55
|
+
const silentiumDestroyable = (onDestroy: () => void) =>
|
|
56
|
+
new MessageDestroyable(onDestroy);
|
|
57
|
+
|
|
22
58
|
/**
|
|
23
59
|
* global functions for debuging
|
|
24
60
|
* silentium programs
|
|
25
61
|
*/
|
|
26
62
|
export function DevTools() {
|
|
27
63
|
if (typeof globalThis !== "undefined") {
|
|
28
|
-
(globalThis as any).
|
|
29
|
-
|
|
64
|
+
(globalThis as any).silentiumDebug = {
|
|
65
|
+
value: silentiumValue,
|
|
66
|
+
print: silentiumPrint,
|
|
67
|
+
destroyable: silentiumDestroyable,
|
|
68
|
+
};
|
|
30
69
|
}
|
|
31
70
|
}
|