@esportsplus/reactivity 0.1.19 → 0.1.20
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/.editorconfig +9 -9
- package/.gitattributes +2 -2
- package/.github/dependabot.yml +23 -0
- package/.github/workflows/bump.yml +7 -0
- package/.github/workflows/publish.yml +14 -0
- package/build/constants.js +1 -11
- package/build/index.js +6 -34
- package/build/macro.d.ts +1 -1
- package/build/macro.js +5 -10
- package/build/reactive/array.js +8 -12
- package/build/reactive/index.js +3 -5
- package/build/reactive/object.js +12 -15
- package/build/resource.js +7 -12
- package/build/signal.d.ts +3 -3
- package/build/signal.js +27 -34
- package/build/types.js +1 -2
- package/build/utilities.js +1 -5
- package/package.json +20 -20
- package/readme.md +1 -1
- package/src/constants.ts +18 -18
- package/src/index.ts +5 -5
- package/src/macro.ts +28 -28
- package/src/reactive/array.ts +212 -214
- package/src/reactive/index.ts +37 -37
- package/src/reactive/object.ts +76 -76
- package/src/resource.ts +70 -70
- package/src/signal.ts +375 -375
- package/src/types.ts +54 -54
- package/src/utilities.ts +5 -5
- package/tsconfig.json +10 -10
package/src/types.ts
CHANGED
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
import { Function, NeverAsync, Prettify } from '@esportsplus/typescript'
|
|
2
|
-
import { CHECK, CLEAN, COMPUTED, DIRTY, DISPOSED, EFFECT, ROOT, SIGNAL } from './constants';
|
|
3
|
-
import { Reactive } from './signal';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
type Base<T> = Omit<Reactive<T>, 'changed' | 'fn' | 'get' | 'scheduler' | 'set' | 'task' | 'tracking'>;
|
|
7
|
-
|
|
8
|
-
type Changed = (a: unknown, b: unknown) => boolean;
|
|
9
|
-
|
|
10
|
-
type Computed<T> = {
|
|
11
|
-
changed: Changed;
|
|
12
|
-
fn: NeverAsync<(instance: Computed<T>) => T>;
|
|
13
|
-
get(): T;
|
|
14
|
-
} & Base<T>;
|
|
15
|
-
|
|
16
|
-
type Effect = {
|
|
17
|
-
fn: NeverAsync<(instance: Effect) => void>;
|
|
18
|
-
root: Root;
|
|
19
|
-
task: Function;
|
|
20
|
-
} & Omit<Base<void>, 'value'>;
|
|
21
|
-
|
|
22
|
-
type Event = string;
|
|
23
|
-
|
|
24
|
-
type Listener<D> = {
|
|
25
|
-
once?: boolean;
|
|
26
|
-
|
|
27
|
-
<V>(event: { data?: D, value: V }): void;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
type Object = Record<PropertyKey, unknown>;
|
|
31
|
-
|
|
32
|
-
type Options = {
|
|
33
|
-
changed?: Changed;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
type Root = {
|
|
37
|
-
scheduler: Scheduler;
|
|
38
|
-
tracking: boolean;
|
|
39
|
-
value: void;
|
|
40
|
-
} & Omit<Reactive<void>, 'root'>;
|
|
41
|
-
|
|
42
|
-
type Scheduler = (fn: Function) => unknown;
|
|
43
|
-
|
|
44
|
-
type Signal<T> = {
|
|
45
|
-
changed: Changed;
|
|
46
|
-
get(): T;
|
|
47
|
-
set(value: T): T;
|
|
48
|
-
} & Base<T>;
|
|
49
|
-
|
|
50
|
-
type State = typeof CHECK | typeof CLEAN | typeof DIRTY | typeof DISPOSED;
|
|
51
|
-
|
|
52
|
-
type Type = typeof COMPUTED | typeof EFFECT | typeof ROOT | typeof SIGNAL;
|
|
53
|
-
|
|
54
|
-
|
|
1
|
+
import { Function, NeverAsync, Prettify } from '@esportsplus/typescript'
|
|
2
|
+
import { CHECK, CLEAN, COMPUTED, DIRTY, DISPOSED, EFFECT, ROOT, SIGNAL } from './constants';
|
|
3
|
+
import { Reactive } from './signal';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
type Base<T> = Omit<Reactive<T>, 'changed' | 'fn' | 'get' | 'scheduler' | 'set' | 'task' | 'tracking'>;
|
|
7
|
+
|
|
8
|
+
type Changed = (a: unknown, b: unknown) => boolean;
|
|
9
|
+
|
|
10
|
+
type Computed<T> = {
|
|
11
|
+
changed: Changed;
|
|
12
|
+
fn: NeverAsync<(instance: Computed<T>) => T>;
|
|
13
|
+
get(): T;
|
|
14
|
+
} & Base<T>;
|
|
15
|
+
|
|
16
|
+
type Effect = {
|
|
17
|
+
fn: NeverAsync<(instance: Effect) => void>;
|
|
18
|
+
root: Root;
|
|
19
|
+
task: Function;
|
|
20
|
+
} & Omit<Base<void>, 'value'>;
|
|
21
|
+
|
|
22
|
+
type Event = string;
|
|
23
|
+
|
|
24
|
+
type Listener<D> = {
|
|
25
|
+
once?: boolean;
|
|
26
|
+
|
|
27
|
+
<V>(event: { data?: D, value: V }): void;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
type Object = Record<PropertyKey, unknown>;
|
|
31
|
+
|
|
32
|
+
type Options = {
|
|
33
|
+
changed?: Changed;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
type Root = {
|
|
37
|
+
scheduler: Scheduler;
|
|
38
|
+
tracking: boolean;
|
|
39
|
+
value: void;
|
|
40
|
+
} & Omit<Reactive<void>, 'root'>;
|
|
41
|
+
|
|
42
|
+
type Scheduler = (fn: Function) => unknown;
|
|
43
|
+
|
|
44
|
+
type Signal<T> = {
|
|
45
|
+
changed: Changed;
|
|
46
|
+
get(): T;
|
|
47
|
+
set(value: T): T;
|
|
48
|
+
} & Base<T>;
|
|
49
|
+
|
|
50
|
+
type State = typeof CHECK | typeof CLEAN | typeof DIRTY | typeof DISPOSED;
|
|
51
|
+
|
|
52
|
+
type Type = typeof COMPUTED | typeof EFFECT | typeof ROOT | typeof SIGNAL;
|
|
53
|
+
|
|
54
|
+
|
|
55
55
|
export type { Changed, Computed, Effect, Event, Function, Listener, Object, Options, NeverAsync, Prettify, Root, Scheduler, Signal, State, Type };
|
package/src/utilities.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const { isArray } = Array;
|
|
2
|
-
|
|
3
|
-
const { defineProperty } = Object;
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
const { isArray } = Array;
|
|
2
|
+
|
|
3
|
+
const { defineProperty } = Object;
|
|
4
|
+
|
|
5
|
+
|
|
6
6
|
export { defineProperty, isArray };
|
package/tsconfig.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"baseUrl": ".",
|
|
4
|
-
"declaration": true,
|
|
5
|
-
"declarationDir": "build",
|
|
6
|
-
"outDir": "build"
|
|
7
|
-
},
|
|
8
|
-
"exclude": ["node_modules"],
|
|
9
|
-
"extends": "./node_modules/@esportsplus/typescript/tsconfig.base.json",
|
|
10
|
-
"include": ["src"]
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"baseUrl": ".",
|
|
4
|
+
"declaration": true,
|
|
5
|
+
"declarationDir": "build",
|
|
6
|
+
"outDir": "build"
|
|
7
|
+
},
|
|
8
|
+
"exclude": ["node_modules"],
|
|
9
|
+
"extends": "./node_modules/@esportsplus/typescript/tsconfig.base.json",
|
|
10
|
+
"include": ["src"]
|
|
11
11
|
}
|