silentium 0.0.176 → 0.0.179
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 +16 -0
- package/dist/silentium.cjs +3 -1
- package/dist/silentium.cjs.map +1 -1
- package/dist/silentium.d.ts +15 -6
- package/dist/silentium.js +3 -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 +3 -2
- package/dist/silentium.mjs.map +1 -1
- package/package.json +1 -1
- package/src/global.d.ts +1 -0
- package/src/helpers/DevTools.test.ts +17 -1
- package/src/helpers/DevTools.ts +14 -9
|
@@ -1,10 +1,26 @@
|
|
|
1
1
|
import { Of } from "base/Of";
|
|
2
2
|
import { DevTools } from "helpers/DevTools";
|
|
3
|
-
import { describe, expect, test } from "vitest";
|
|
3
|
+
import { describe, expect, test, vi } from "vitest";
|
|
4
4
|
|
|
5
5
|
describe("DevTools.test", () => {
|
|
6
6
|
DevTools();
|
|
7
7
|
test("raw value of silentium message", () => {
|
|
8
8
|
expect(silentiumDebug.value(Of(123))).toBe(123);
|
|
9
9
|
});
|
|
10
|
+
|
|
11
|
+
test("destroyable", async () => {
|
|
12
|
+
const destroyed = vi.fn();
|
|
13
|
+
const $m = silentiumDebug.destroyable(destroyed);
|
|
14
|
+
expect(await $m).toContain("Wait destroy");
|
|
15
|
+
|
|
16
|
+
$m.destroy();
|
|
17
|
+
expect(destroyed).toBeCalledTimes(1);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test("destroyable without reading value", () => {
|
|
21
|
+
const destroyed = vi.fn();
|
|
22
|
+
const $m = silentiumDebug.destroyable(destroyed);
|
|
23
|
+
$m.destroy();
|
|
24
|
+
expect(destroyed).toBeCalledTimes(1);
|
|
25
|
+
});
|
|
10
26
|
});
|
package/src/helpers/DevTools.ts
CHANGED
|
@@ -2,19 +2,23 @@ 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 { ConstructorType } from "types/ConstructorType";
|
|
5
6
|
import { DestroyableType } from "types/DestroyableType";
|
|
6
7
|
import { MessageType } from "types/MessageType";
|
|
7
8
|
|
|
8
9
|
declare global {
|
|
10
|
+
interface SilentiumDebug {
|
|
11
|
+
value: ($message: MessageType) => unknown;
|
|
12
|
+
print: (...messages: MessageType[]) => void;
|
|
13
|
+
destroyable: (onDestroy: () => void) => MessageType<any> & DestroyableType;
|
|
14
|
+
}
|
|
15
|
+
|
|
9
16
|
interface GlobalThis {
|
|
10
|
-
silentiumDebug:
|
|
11
|
-
value: ($message: MessageType) => unknown;
|
|
12
|
-
print: (...messages: MessageType[]) => void;
|
|
13
|
-
destroyable: (
|
|
14
|
-
onDestroy: () => void,
|
|
15
|
-
) => MessageType<any> & DestroyableType;
|
|
16
|
-
};
|
|
17
|
+
silentiumDebug: SilentiumDebug;
|
|
17
18
|
}
|
|
19
|
+
|
|
20
|
+
// @ts-expect-error global variable
|
|
21
|
+
const silentiumDebug: SilentiumDebug;
|
|
18
22
|
}
|
|
19
23
|
|
|
20
24
|
/**
|
|
@@ -32,10 +36,11 @@ const silentiumPrint = (...messages: MessageType[]) => {
|
|
|
32
36
|
const silentiumValue = ($message: MessageType) =>
|
|
33
37
|
Primitive($message).primitive();
|
|
34
38
|
|
|
35
|
-
class MessageDestroyable implements MessageType<any>, DestroyableType {
|
|
39
|
+
export class MessageDestroyable implements MessageType<any>, DestroyableType {
|
|
36
40
|
public constructor(private onDestroy: () => void) {}
|
|
37
41
|
|
|
38
|
-
public then() {
|
|
42
|
+
public then(resolve: ConstructorType<[string]>) {
|
|
43
|
+
resolve(`Wait destroy ${Date.now()}`);
|
|
39
44
|
return this;
|
|
40
45
|
}
|
|
41
46
|
|