@esportsplus/reactivity 0.1.18 → 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/macro.d.ts +1 -1
- package/build/signal.d.ts +3 -3
- package/build/signal.js +3 -0
- 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 -371
- package/src/types.ts +54 -54
- package/src/utilities.ts +5 -5
- package/tsconfig.json +10 -9
package/.editorconfig
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
root = true
|
|
2
|
-
|
|
3
|
-
[*]
|
|
4
|
-
indent_style = space
|
|
5
|
-
indent_size = 4
|
|
6
|
-
charset = utf-8
|
|
7
|
-
trim_trailing_whitespace = true
|
|
8
|
-
insert_final_newline = true
|
|
9
|
-
end_of_line = lf
|
|
1
|
+
root = true
|
|
2
|
+
|
|
3
|
+
[*]
|
|
4
|
+
indent_style = space
|
|
5
|
+
indent_size = 4
|
|
6
|
+
charset = utf-8
|
|
7
|
+
trim_trailing_whitespace = true
|
|
8
|
+
insert_final_newline = true
|
|
9
|
+
end_of_line = lf
|
package/.gitattributes
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
# Auto detect text files and perform LF normalization
|
|
2
|
-
* text=auto
|
|
1
|
+
# Auto detect text files and perform LF normalization
|
|
2
|
+
* text=auto
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# To get started with Dependabot version updates, you'll need to specify which
|
|
2
|
+
# package ecosystems to update and where the package manifests are located.
|
|
3
|
+
# Please see the documentation for all configuration options:
|
|
4
|
+
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
|
|
5
|
+
|
|
6
|
+
version: 2
|
|
7
|
+
registries:
|
|
8
|
+
npm-npmjs:
|
|
9
|
+
token: ${{secrets.NPM_TOKEN}}
|
|
10
|
+
type: npm-registry
|
|
11
|
+
url: https://registry.npmjs.org
|
|
12
|
+
updates:
|
|
13
|
+
- package-ecosystem: "npm"
|
|
14
|
+
directory: "/"
|
|
15
|
+
groups:
|
|
16
|
+
production-dependencies:
|
|
17
|
+
dependency-type: "production"
|
|
18
|
+
development-dependencies:
|
|
19
|
+
dependency-type: "development"
|
|
20
|
+
registries:
|
|
21
|
+
- npm-npmjs
|
|
22
|
+
schedule:
|
|
23
|
+
interval: "daily"
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
name: publish to npm
|
|
2
|
+
on:
|
|
3
|
+
release:
|
|
4
|
+
types: [published]
|
|
5
|
+
workflow_dispatch:
|
|
6
|
+
workflow_run:
|
|
7
|
+
workflows: [bump]
|
|
8
|
+
types:
|
|
9
|
+
- completed
|
|
10
|
+
jobs:
|
|
11
|
+
publish:
|
|
12
|
+
secrets:
|
|
13
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN_PUBLISHING }}
|
|
14
|
+
uses: esportsplus/workflows/.github/workflows/publish.yml@main
|
package/build/macro.d.ts
CHANGED
|
@@ -6,5 +6,5 @@ declare class Macro<A extends unknown[], R> extends CustomFunction {
|
|
|
6
6
|
constructor(fn: Function<A, R>, options?: Options);
|
|
7
7
|
dispose(): void;
|
|
8
8
|
}
|
|
9
|
-
declare const _default: <A extends unknown[], R>(fn:
|
|
9
|
+
declare const _default: <A extends unknown[], R>(fn: Function<A, R>, options?: Options) => Macro<A, R>;
|
|
10
10
|
export default _default;
|
package/build/signal.d.ts
CHANGED
|
@@ -20,12 +20,12 @@ declare class Reactive<T> {
|
|
|
20
20
|
once<T>(event: Event, listener: Listener<T>): void;
|
|
21
21
|
set(value: T): T;
|
|
22
22
|
}
|
|
23
|
-
declare const computed: <T>(fn:
|
|
23
|
+
declare const computed: <T>(fn: Computed<T>['fn'], options?: Options) => Computed<T>;
|
|
24
24
|
declare const dispose: <T extends {
|
|
25
25
|
dispose: VoidFunction;
|
|
26
|
-
}>(dispose?: T | T
|
|
26
|
+
}>(dispose?: T[] | T | null) => T | T[] | null | undefined;
|
|
27
27
|
declare const effect: (fn: Effect['fn']) => Effect;
|
|
28
|
-
declare const root: <T>(fn: (instance: Root) => T
|
|
28
|
+
declare const root: <T>(fn: NeverAsync<(instance: Root) => T>, scheduler?: Scheduler) => T;
|
|
29
29
|
declare const signal: <T>(value: T, options?: Options) => Signal<T>;
|
|
30
30
|
export { computed, dispose, effect, root, signal };
|
|
31
31
|
export { Reactive };
|
package/build/signal.js
CHANGED
|
@@ -257,6 +257,9 @@ const effect = (fn) => {
|
|
|
257
257
|
const root = (fn, scheduler) => {
|
|
258
258
|
let o = observer, s = scope;
|
|
259
259
|
if (scheduler === undefined) {
|
|
260
|
+
if (o?.type === EFFECT) {
|
|
261
|
+
scope = o.root;
|
|
262
|
+
}
|
|
260
263
|
if (scope === null) {
|
|
261
264
|
throw new Error('Reactivity: `root` cannot be created without a task scheduler');
|
|
262
265
|
}
|
package/package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
{
|
|
2
|
-
"author": "ICJR",
|
|
3
|
-
"dependencies": {
|
|
4
|
-
"@esportsplus/custom-function": "^0.0.1"
|
|
5
|
-
},
|
|
6
|
-
"devDependencies": {
|
|
7
|
-
"@esportsplus/typescript": "^0.0.
|
|
8
|
-
},
|
|
9
|
-
"main": "build/index.js",
|
|
10
|
-
"name": "@esportsplus/reactivity",
|
|
11
|
-
"private": false,
|
|
12
|
-
"scripts": {
|
|
13
|
-
"build": "tsc && tsc-alias",
|
|
14
|
-
"-": "-",
|
|
15
|
-
"prepare": "npm run build",
|
|
16
|
-
"prepublishOnly": "npm run build"
|
|
17
|
-
},
|
|
18
|
-
"types": "build/index.d.ts",
|
|
19
|
-
"version": "0.1.
|
|
20
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"author": "ICJR",
|
|
3
|
+
"dependencies": {
|
|
4
|
+
"@esportsplus/custom-function": "^0.0.1"
|
|
5
|
+
},
|
|
6
|
+
"devDependencies": {
|
|
7
|
+
"@esportsplus/typescript": "^0.0.21"
|
|
8
|
+
},
|
|
9
|
+
"main": "build/index.js",
|
|
10
|
+
"name": "@esportsplus/reactivity",
|
|
11
|
+
"private": false,
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "tsc && tsc-alias",
|
|
14
|
+
"-": "-",
|
|
15
|
+
"prepare": "npm run build",
|
|
16
|
+
"prepublishOnly": "npm run build"
|
|
17
|
+
},
|
|
18
|
+
"types": "build/index.d.ts",
|
|
19
|
+
"version": "0.1.20"
|
|
20
|
+
}
|
package/readme.md
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
https://github.com/maverick-js/signals
|
|
1
|
+
https://github.com/maverick-js/signals
|
|
2
2
|
https://github.com/modderme123/reactively
|
package/src/constants.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
const CLEAN = 0;
|
|
2
|
-
|
|
3
|
-
const CHECK = 1;
|
|
4
|
-
|
|
5
|
-
const DIRTY = 2;
|
|
6
|
-
|
|
7
|
-
const DISPOSED = 3;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const COMPUTED = 0;
|
|
11
|
-
|
|
12
|
-
const EFFECT = 1;
|
|
13
|
-
|
|
14
|
-
const ROOT = 2;
|
|
15
|
-
|
|
16
|
-
const SIGNAL = 3;
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
const CLEAN = 0;
|
|
2
|
+
|
|
3
|
+
const CHECK = 1;
|
|
4
|
+
|
|
5
|
+
const DIRTY = 2;
|
|
6
|
+
|
|
7
|
+
const DISPOSED = 3;
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
const COMPUTED = 0;
|
|
11
|
+
|
|
12
|
+
const EFFECT = 1;
|
|
13
|
+
|
|
14
|
+
const ROOT = 2;
|
|
15
|
+
|
|
16
|
+
const SIGNAL = 3;
|
|
17
|
+
|
|
18
|
+
|
|
19
19
|
export { CHECK, CLEAN, COMPUTED, DIRTY, DISPOSED, EFFECT, ROOT, SIGNAL };
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { default as macro } from './macro';
|
|
2
|
-
export { default as resource } from './resource';
|
|
3
|
-
export { default as reactive } from './reactive';
|
|
4
|
-
export { computed, dispose, effect, root, signal } from './signal';
|
|
5
|
-
export * from './constants';
|
|
1
|
+
export { default as macro } from './macro';
|
|
2
|
+
export { default as resource } from './resource';
|
|
3
|
+
export { default as reactive } from './reactive';
|
|
4
|
+
export { computed, dispose, effect, root, signal } from './signal';
|
|
5
|
+
export * from './constants';
|
|
6
6
|
export * from './types';
|
package/src/macro.ts
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import CustomFunction from '@esportsplus/custom-function';
|
|
2
|
-
import { computed } from './signal';
|
|
3
|
-
import { Computed, Options } from './types';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
type Function<A extends unknown[], R> = Computed<(...args: A) => R>['fn'];
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class Macro<A extends unknown[], R> extends CustomFunction {
|
|
10
|
-
#factory: Computed<(...args: A) => R>;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
constructor(fn: Function<A,R>, options: Options = {}) {
|
|
14
|
-
super((...args: A) => {
|
|
15
|
-
return this.#factory.get()(...args);
|
|
16
|
-
});
|
|
17
|
-
this.#factory = computed(fn, options);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
dispose() {
|
|
22
|
-
this.#factory.dispose();
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
export default <A extends unknown[], R>(fn: Function<A,R>, options: Options = {}) => {
|
|
28
|
-
return new Macro(fn, options);
|
|
1
|
+
import CustomFunction from '@esportsplus/custom-function';
|
|
2
|
+
import { computed } from './signal';
|
|
3
|
+
import { Computed, Options } from './types';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
type Function<A extends unknown[], R> = Computed<(...args: A) => R>['fn'];
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Macro<A extends unknown[], R> extends CustomFunction {
|
|
10
|
+
#factory: Computed<(...args: A) => R>;
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
constructor(fn: Function<A,R>, options: Options = {}) {
|
|
14
|
+
super((...args: A) => {
|
|
15
|
+
return this.#factory.get()(...args);
|
|
16
|
+
});
|
|
17
|
+
this.#factory = computed(fn, options);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
dispose() {
|
|
22
|
+
this.#factory.dispose();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
export default <A extends unknown[], R>(fn: Function<A,R>, options: Options = {}) => {
|
|
28
|
+
return new Macro(fn, options);
|
|
29
29
|
};
|