@esportsplus/reactivity 0.1.22 → 0.1.23

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/macro.d.ts CHANGED
@@ -2,7 +2,7 @@ import CustomFunction from '@esportsplus/custom-function';
2
2
  import { Computed, Options } from './types';
3
3
  type Function<A extends unknown[], R> = Computed<(...args: A) => R>['fn'];
4
4
  declare class Macro<A extends unknown[], R> extends CustomFunction {
5
- #private;
5
+ private factory;
6
6
  constructor(fn: Function<A, R>, options?: Options);
7
7
  dispose(): void;
8
8
  }
package/build/macro.js CHANGED
@@ -1,15 +1,15 @@
1
1
  import CustomFunction from '@esportsplus/custom-function';
2
2
  import { computed } from './signal';
3
3
  class Macro extends CustomFunction {
4
- #factory;
4
+ factory;
5
5
  constructor(fn, options = {}) {
6
6
  super((...args) => {
7
- return this.#factory.get()(...args);
7
+ return this.factory.get()(...args);
8
8
  });
9
- this.#factory = computed(fn, options);
9
+ this.factory = computed(fn, options);
10
10
  }
11
11
  dispose() {
12
- this.#factory.dispose();
12
+ this.factory.dispose();
13
13
  }
14
14
  }
15
15
  export default (fn, options = {}) => {
@@ -26,7 +26,7 @@ type Events<T> = {
26
26
  };
27
27
  type Node<T extends Object> = ReactiveObject<T>;
28
28
  declare class ReactiveArray<T> extends Array<T> {
29
- #private;
29
+ private signal;
30
30
  constructor(data: T[]);
31
31
  set length(n: number);
32
32
  private trigger;
@@ -45,7 +45,7 @@ declare class ReactiveArray<T> extends Array<T> {
45
45
  unshift(...items: T[]): number;
46
46
  }
47
47
  declare class ReactiveObjectArray<T extends Object> extends ReactiveArray<Node<T>> {
48
- #private;
48
+ private options;
49
49
  constructor(data: T[], options?: Options);
50
50
  fill(): never;
51
51
  reverse(): never;
@@ -11,10 +11,10 @@ function unsupported(method) {
11
11
  throw new Error(`Reactivity: '${method}' is not supported on reactive object array`);
12
12
  }
13
13
  class ReactiveArray extends Array {
14
- #signal;
14
+ signal;
15
15
  constructor(data) {
16
16
  super(...data);
17
- this.#signal = signal(false);
17
+ this.signal = signal(false);
18
18
  }
19
19
  set length(n) {
20
20
  if (n > this.length) {
@@ -23,13 +23,13 @@ class ReactiveArray extends Array {
23
23
  this.splice(n);
24
24
  }
25
25
  trigger() {
26
- this.#signal.set(!this.#signal.value);
26
+ this.signal.set(!this.signal.value);
27
27
  }
28
28
  dispatch(event, data) {
29
- this.#signal.dispatch(event, data);
29
+ this.signal.dispatch(event, data);
30
30
  }
31
31
  dispose() {
32
- this.#signal.dispose();
32
+ this.signal.dispose();
33
33
  }
34
34
  fill(value, start, end) {
35
35
  super.fill(value, start, end);
@@ -38,10 +38,10 @@ class ReactiveArray extends Array {
38
38
  return this;
39
39
  }
40
40
  on(event, listener) {
41
- this.#signal.on(event, listener);
41
+ this.signal.on(event, listener);
42
42
  }
43
43
  once(event, listener) {
44
- this.#signal.once(event, listener);
44
+ this.signal.once(event, listener);
45
45
  }
46
46
  pop() {
47
47
  let item = super.pop();
@@ -90,7 +90,7 @@ class ReactiveArray extends Array {
90
90
  return removed;
91
91
  }
92
92
  track() {
93
- this.#signal.get();
93
+ this.signal.get();
94
94
  }
95
95
  unshift(...items) {
96
96
  let length = super.unshift(...items);
@@ -100,10 +100,10 @@ class ReactiveArray extends Array {
100
100
  }
101
101
  }
102
102
  class ReactiveObjectArray extends ReactiveArray {
103
- #options;
103
+ options;
104
104
  constructor(data, options = {}) {
105
105
  super(factory(data, options));
106
- this.#options = options;
106
+ this.options = options;
107
107
  }
108
108
  fill() {
109
109
  return unsupported('fill');
@@ -115,7 +115,7 @@ class ReactiveObjectArray extends ReactiveArray {
115
115
  return dispose(super.pop());
116
116
  }
117
117
  push(...values) {
118
- return super.push(...factory(values, this.#options));
118
+ return super.push(...factory(values, this.options));
119
119
  }
120
120
  shift() {
121
121
  return dispose(super.shift());
@@ -124,10 +124,10 @@ class ReactiveObjectArray extends ReactiveArray {
124
124
  return unsupported('sort');
125
125
  }
126
126
  splice(start, deleteCount = super.length, ...values) {
127
- return dispose(super.splice(start, deleteCount, ...factory(values, this.#options)));
127
+ return dispose(super.splice(start, deleteCount, ...factory(values, this.options)));
128
128
  }
129
129
  unshift(...values) {
130
- return super.unshift(...factory(values, this.#options));
130
+ return super.unshift(...factory(values, this.options));
131
131
  }
132
132
  }
133
133
  export { ReactiveArray, ReactiveObjectArray };
@@ -2,7 +2,9 @@ import CustomFunction from '@esportsplus/custom-function';
2
2
  import { Options } from './types';
3
3
  type Function<A extends unknown[], R extends Promise<unknown>> = (...args: A) => R;
4
4
  declare class Resource<A extends unknown[], R extends Promise<unknown>> extends CustomFunction {
5
- #private;
5
+ private arguments;
6
+ private okay;
7
+ private response;
6
8
  stop: boolean | null;
7
9
  constructor(fn: Function<A, R>, options?: Options);
8
10
  get data(): Awaited<R>;
package/build/resource.js CHANGED
@@ -1,48 +1,48 @@
1
1
  import CustomFunction from '@esportsplus/custom-function';
2
2
  import { signal } from './signal';
3
3
  class Resource extends CustomFunction {
4
- #data;
5
- #input;
6
- #ok;
4
+ arguments;
5
+ okay;
6
+ response;
7
7
  stop = null;
8
8
  constructor(fn, options = {}) {
9
9
  super((...args) => {
10
10
  this.stop = null;
11
- this.#input.set(args);
12
- this.#ok.set(null);
11
+ this.arguments.set(args);
12
+ this.okay.set(null);
13
13
  fn(...args)
14
14
  .then((value) => {
15
15
  if (this.stop === true) {
16
16
  return;
17
17
  }
18
- this.#data.set(value);
19
- this.#ok.set(true);
18
+ this.response.set(value);
19
+ this.okay.set(true);
20
20
  })
21
21
  .catch(() => {
22
22
  if (this.stop === true) {
23
23
  return;
24
24
  }
25
- this.#data.set(undefined);
26
- this.#ok.set(false);
25
+ this.response.set(undefined);
26
+ this.okay.set(false);
27
27
  });
28
28
  });
29
- this.#data = signal(undefined, options);
30
- this.#input = signal(null, options);
31
- this.#ok = signal(null, options);
29
+ this.response = signal(undefined, options);
30
+ this.arguments = signal(null, options);
31
+ this.okay = signal(null, options);
32
32
  }
33
33
  get data() {
34
- return this.#data.get();
34
+ return this.response.get();
35
35
  }
36
36
  get input() {
37
- return this.#input.get();
37
+ return this.arguments.get();
38
38
  }
39
39
  get ok() {
40
- return this.#ok.get();
40
+ return this.okay.get();
41
41
  }
42
42
  dispose() {
43
- this.#data.dispose();
44
- this.#input.dispose();
45
- this.#ok.dispose();
43
+ this.arguments.dispose();
44
+ this.okay.dispose();
45
+ this.response.dispose();
46
46
  }
47
47
  }
48
48
  export default (fn, options = {}) => {
package/package.json CHANGED
@@ -16,5 +16,5 @@
16
16
  "prepublishOnly": "npm run build"
17
17
  },
18
18
  "types": "build/index.d.ts",
19
- "version": "0.1.22"
19
+ "version": "0.1.23"
20
20
  }
package/src/macro.ts CHANGED
@@ -7,19 +7,19 @@ type Function<A extends unknown[], R> = Computed<(...args: A) => R>['fn'];
7
7
 
8
8
 
9
9
  class Macro<A extends unknown[], R> extends CustomFunction {
10
- #factory: Computed<(...args: A) => R>;
10
+ private factory: Computed<(...args: A) => R>;
11
11
 
12
12
 
13
13
  constructor(fn: Function<A,R>, options: Options = {}) {
14
14
  super((...args: A) => {
15
- return this.#factory.get()(...args);
15
+ return this.factory.get()(...args);
16
16
  });
17
- this.#factory = computed(fn, options);
17
+ this.factory = computed(fn, options);
18
18
  }
19
19
 
20
20
 
21
21
  dispose() {
22
- this.#factory.dispose();
22
+ this.factory.dispose();
23
23
  }
24
24
  }
25
25
 
@@ -33,12 +33,12 @@ function unsupported(method: string): never {
33
33
 
34
34
 
35
35
  class ReactiveArray<T> extends Array<T> {
36
- #signal: Signal<boolean>;
36
+ private signal: Signal<boolean>;
37
37
 
38
38
 
39
39
  constructor(data: T[]) {
40
40
  super(...data);
41
- this.#signal = signal(false);
41
+ this.signal = signal(false);
42
42
  }
43
43
 
44
44
 
@@ -52,16 +52,16 @@ class ReactiveArray<T> extends Array<T> {
52
52
 
53
53
 
54
54
  private trigger() {
55
- this.#signal.set(!this.#signal.value);
55
+ this.signal.set(!this.signal.value);
56
56
  }
57
57
 
58
58
 
59
59
  dispatch<E extends keyof Events<T>>(event: E, data?: Events<T>[E]) {
60
- this.#signal.dispatch(event, data);
60
+ this.signal.dispatch(event, data);
61
61
  }
62
62
 
63
63
  dispose() {
64
- this.#signal.dispose();
64
+ this.signal.dispose();
65
65
  }
66
66
 
67
67
  fill(value: T, start?: number, end?: number) {
@@ -74,11 +74,11 @@ class ReactiveArray<T> extends Array<T> {
74
74
  }
75
75
 
76
76
  on<E extends keyof Events<T>>(event: E, listener: Listener<Events<T>[E]>) {
77
- this.#signal.on(event, listener);
77
+ this.signal.on(event, listener);
78
78
  }
79
79
 
80
80
  once<E extends keyof Events<T>>(event: E, listener: Listener<Events<T>[E]>) {
81
- this.#signal.once(event, listener);
81
+ this.signal.once(event, listener);
82
82
  }
83
83
 
84
84
  pop() {
@@ -146,7 +146,7 @@ class ReactiveArray<T> extends Array<T> {
146
146
  }
147
147
 
148
148
  track() {
149
- this.#signal.get();
149
+ this.signal.get();
150
150
  }
151
151
 
152
152
  unshift(...items: T[]) {
@@ -164,12 +164,12 @@ class ReactiveArray<T> extends Array<T> {
164
164
  // - @ts-ignore flags are supressing a type mismatch error
165
165
  // - Input values are being transformed by this class into nodes
166
166
  class ReactiveObjectArray<T extends Object> extends ReactiveArray<Node<T>> {
167
- #options: Options;
167
+ private options: Options;
168
168
 
169
169
 
170
170
  constructor(data: T[], options: Options = {}) {
171
171
  super( factory(data, options) );
172
- this.#options = options;
172
+ this.options = options;
173
173
  }
174
174
 
175
175
 
@@ -187,7 +187,7 @@ class ReactiveObjectArray<T extends Object> extends ReactiveArray<Node<T>> {
187
187
 
188
188
  // @ts-ignore
189
189
  push(...values: T[]) {
190
- return super.push(...factory(values, this.#options));
190
+ return super.push(...factory(values, this.options));
191
191
  }
192
192
 
193
193
  shift() {
@@ -200,12 +200,12 @@ class ReactiveObjectArray<T extends Object> extends ReactiveArray<Node<T>> {
200
200
 
201
201
  // @ts-ignore
202
202
  splice(start: number, deleteCount: number = super.length, ...values: T[]) {
203
- return dispose( super.splice(start, deleteCount, ...factory(values, this.#options)) );
203
+ return dispose( super.splice(start, deleteCount, ...factory(values, this.options)) );
204
204
  }
205
205
 
206
206
  // @ts-ignore
207
207
  unshift(...values: T[]) {
208
- return super.unshift(...factory(values, this.#options));
208
+ return super.unshift(...factory(values, this.options));
209
209
  }
210
210
  }
211
211
 
package/src/resource.ts CHANGED
@@ -7,9 +7,9 @@ type Function<A extends unknown[], R extends Promise<unknown>> = (...args: A) =>
7
7
 
8
8
 
9
9
  class Resource<A extends unknown[], R extends Promise<unknown>> extends CustomFunction {
10
- #data: Signal<Awaited<R>>;
11
- #input: Signal<A | null>;
12
- #ok: Signal<boolean | null>;
10
+ private arguments: Signal<A | null>;
11
+ private okay: Signal<boolean | null>;
12
+ private response: Signal<Awaited<R>>;
13
13
 
14
14
  stop: boolean | null = null;
15
15
 
@@ -18,8 +18,8 @@ class Resource<A extends unknown[], R extends Promise<unknown>> extends CustomFu
18
18
  super((...args: A) => {
19
19
  this.stop = null;
20
20
 
21
- this.#input.set(args);
22
- this.#ok.set(null);
21
+ this.arguments.set(args);
22
+ this.okay.set(null);
23
23
 
24
24
  fn(...args)
25
25
  .then((value) => {
@@ -27,41 +27,41 @@ class Resource<A extends unknown[], R extends Promise<unknown>> extends CustomFu
27
27
  return;
28
28
  }
29
29
 
30
- this.#data.set(value as Awaited<R>);
31
- this.#ok.set(true);
30
+ this.response.set(value as Awaited<R>);
31
+ this.okay.set(true);
32
32
  })
33
33
  .catch(() => {
34
34
  if (this.stop === true) {
35
35
  return;
36
36
  }
37
37
 
38
- this.#data.set(undefined as Awaited<R>);
39
- this.#ok.set(false);
38
+ this.response.set(undefined as Awaited<R>);
39
+ this.okay.set(false);
40
40
  });
41
41
  });
42
- this.#data = signal(undefined as Awaited<R>, options);
43
- this.#input = signal<A | null>(null, options);
44
- this.#ok = signal<boolean | null>(null, options);
42
+ this.response = signal(undefined as Awaited<R>, options);
43
+ this.arguments = signal<A | null>(null, options);
44
+ this.okay = signal<boolean | null>(null, options);
45
45
  }
46
46
 
47
47
 
48
48
  get data() {
49
- return this.#data.get();
49
+ return this.response.get();
50
50
  }
51
51
 
52
52
  get input() {
53
- return this.#input.get();
53
+ return this.arguments.get();
54
54
  }
55
55
 
56
56
  get ok() {
57
- return this.#ok.get();
57
+ return this.okay.get();
58
58
  }
59
59
 
60
60
 
61
61
  dispose() {
62
- this.#data.dispose();
63
- this.#input.dispose();
64
- this.#ok.dispose();
62
+ this.arguments.dispose();
63
+ this.okay.dispose();
64
+ this.response.dispose();
65
65
  }
66
66
  }
67
67