@esportsplus/reactivity 0.0.28 → 0.0.29
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/build/effect.d.ts +7 -0
- package/build/effect.js +3 -0
- package/build/index.d.ts +5 -1
- package/build/index.js +5 -1
- package/build/macro.d.ts +9 -0
- package/build/macro.js +8 -0
- package/build/promise.d.ts +8 -0
- package/build/promise.js +38 -0
- package/build/reactive.d.ts +11 -0
- package/build/reactive.js +27 -0
- package/package.json +1 -2
- package/src/effect.ts +5 -0
- package/src/index.ts +5 -1
- package/src/{api/macro.ts → macro.ts} +3 -3
- package/src/{api/promise.ts → promise.ts} +2 -2
- package/src/{api/store.ts → reactive.ts} +3 -3
- package/src/api/effect.ts +0 -5
- package/src/api/index.ts +0 -4
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
declare const _default: (fn: (this: import("./types").Context, previous: unknown) => unknown, options?: import("./types").Options | undefined) => {
|
|
2
|
+
dispose: () => void;
|
|
3
|
+
on: (event: symbol, listener: import("./types").Listener) => void;
|
|
4
|
+
once: (event: symbol, listener: import("./types").Listener) => void;
|
|
5
|
+
reset: () => void;
|
|
6
|
+
};
|
|
7
|
+
export default _default;
|
package/build/effect.js
ADDED
package/build/index.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { default as effect } from './effect';
|
|
2
|
+
export { default as macro } from './macro';
|
|
3
|
+
export { default as promise } from './promise';
|
|
2
4
|
export * as core from './signal';
|
|
5
|
+
export { root } from './signal';
|
|
6
|
+
export { default as reactive } from './reactive';
|
|
3
7
|
export { DISPOSE, RESET, UPDATE } from './symbols';
|
package/build/index.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { default as effect } from './effect';
|
|
2
|
+
export { default as macro } from './macro';
|
|
3
|
+
export { default as promise } from './promise';
|
|
2
4
|
export * as core from './signal';
|
|
5
|
+
export { root } from './signal';
|
|
6
|
+
export { default as reactive } from './reactive';
|
|
3
7
|
export { DISPOSE, RESET, UPDATE } from './symbols';
|
package/build/macro.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { computed } from './signal';
|
|
2
|
+
import { Computed } from './types';
|
|
3
|
+
declare const _default: <T extends <A, R>(...args: A[]) => R>(fn: T extends Promise<unknown> ? never : (this: import("./types").Context, previous: T) => T, options?: Parameters<typeof computed>[1]) => {
|
|
4
|
+
dispose: () => void;
|
|
5
|
+
on: (event: symbol, listener: import("./types").Listener) => void;
|
|
6
|
+
once: (event: symbol, listener: import("./types").Listener) => void;
|
|
7
|
+
reset: () => void;
|
|
8
|
+
};
|
|
9
|
+
export default _default;
|
package/build/macro.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { computed } from './signal';
|
|
2
|
+
declare const _default: (fn: <A, R extends Promise<any>>(...args: A[]) => R, options?: Parameters<typeof computed>[1]) => {
|
|
3
|
+
dispose: () => void;
|
|
4
|
+
on: (event: symbol, listener: import("./types").Listener) => void;
|
|
5
|
+
once: (event: symbol, listener: import("./types").Listener) => void;
|
|
6
|
+
reset: () => void;
|
|
7
|
+
};
|
|
8
|
+
export default _default;
|
package/build/promise.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { read, root, signal, write } from './signal';
|
|
2
|
+
import context from './context';
|
|
3
|
+
export default (fn, options = {}) => {
|
|
4
|
+
let input, nodes = {
|
|
5
|
+
data: signal(options?.value, options),
|
|
6
|
+
status: signal(undefined, options)
|
|
7
|
+
};
|
|
8
|
+
function host(...args) {
|
|
9
|
+
input = args;
|
|
10
|
+
root(() => {
|
|
11
|
+
fn(...args)
|
|
12
|
+
.then((value) => {
|
|
13
|
+
write(nodes.data, value);
|
|
14
|
+
})
|
|
15
|
+
.catch(() => {
|
|
16
|
+
write(nodes.data, undefined);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
Object.defineProperties(host, {
|
|
21
|
+
data: {
|
|
22
|
+
get() {
|
|
23
|
+
return read(nodes.data);
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
input: {
|
|
27
|
+
get() {
|
|
28
|
+
return input;
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
status: {
|
|
32
|
+
get() {
|
|
33
|
+
return read(nodes.status);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
return context.nodes(host, nodes);
|
|
38
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { computed, signal } from './signal';
|
|
2
|
+
import { Context } from './types';
|
|
3
|
+
type Infer<T> = T extends (...args: unknown[]) => unknown ? ReturnType<T> : T extends Record<PropertyKey, unknown> ? {
|
|
4
|
+
[K in keyof T]: T[K];
|
|
5
|
+
} : T;
|
|
6
|
+
type Never = {
|
|
7
|
+
[K in keyof Context]?: never;
|
|
8
|
+
};
|
|
9
|
+
type Options = Parameters<typeof computed>[1] | Parameters<typeof signal>[1];
|
|
10
|
+
declare const _default: <T extends Record<PropertyKey, unknown>>(data: T & Never, options?: Options) => Required<Infer<T> & Context & Partial<Context>> extends infer T_1 ? { [K in keyof T_1]: Required<Infer<T> & Context & Partial<Context>>[K]; } : never;
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { computed, read, signal, write } from './signal';
|
|
2
|
+
import context from './context';
|
|
3
|
+
export default (data, options = {}) => {
|
|
4
|
+
let host = {}, nodes = {};
|
|
5
|
+
for (let key in data) {
|
|
6
|
+
if (typeof data[key] === 'function') {
|
|
7
|
+
nodes[key] = computed(data[key], options);
|
|
8
|
+
Object.defineProperty(host, key, {
|
|
9
|
+
get() {
|
|
10
|
+
return read(nodes[key]);
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
nodes[key] = signal(data[key], options);
|
|
16
|
+
Object.defineProperty(host, key, {
|
|
17
|
+
get() {
|
|
18
|
+
return read(nodes[key]);
|
|
19
|
+
},
|
|
20
|
+
set(data) {
|
|
21
|
+
write(nodes[key], data);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return context.nodes(host, nodes);
|
|
27
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"author": "ICJR",
|
|
3
|
-
"description": "Reactivity",
|
|
4
3
|
"devDependencies": {
|
|
5
4
|
"@esportsplus/rspack": "^0.0.15"
|
|
6
5
|
},
|
|
@@ -14,5 +13,5 @@
|
|
|
14
13
|
"prepublishOnly": "npm run build"
|
|
15
14
|
},
|
|
16
15
|
"types": "build/index.d.ts",
|
|
17
|
-
"version": "0.0.
|
|
16
|
+
"version": "0.0.29"
|
|
18
17
|
}
|
package/src/effect.ts
ADDED
package/src/index.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { default as effect } from './effect';
|
|
2
|
+
export { default as macro } from './macro';
|
|
3
|
+
export { default as promise } from './promise';
|
|
2
4
|
export * as core from './signal';
|
|
5
|
+
export { root } from './signal';
|
|
6
|
+
export { default as reactive } from './reactive';
|
|
3
7
|
export { DISPOSE, RESET, UPDATE } from './symbols';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { computed, read } from '
|
|
2
|
-
import { Computed } from '
|
|
3
|
-
import context from '
|
|
1
|
+
import { computed, read } from './signal';
|
|
2
|
+
import { Computed } from './types';
|
|
3
|
+
import context from './context';
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
export default <T extends <A, R>(...args: A[]) => R>(fn: Computed<T>['fn'], options: Parameters<typeof computed>[1] = {}) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { computed, read, signal, write } from '
|
|
2
|
-
import { Context, Signal } from '
|
|
3
|
-
import context from '
|
|
1
|
+
import { computed, read, signal, write } from './signal';
|
|
2
|
+
import { Context, Signal } from './types';
|
|
3
|
+
import context from './context';
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
type Infer<T> =
|
package/src/api/effect.ts
DELETED
package/src/api/index.ts
DELETED