@esportsplus/reactivity 0.12.1 → 0.12.3

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.
@@ -58,6 +58,7 @@ declare class ReactiveArray<T> {
58
58
  unshift(...input: T[]): number;
59
59
  }
60
60
  declare const isReactiveArray: (value: any) => value is ReactiveArray<any>;
61
- export default function array<T>(input: T[]): API<T>;
61
+ declare const _default: <T>(input: T[]) => API<T>;
62
+ export default _default;
62
63
  export { isReactiveArray };
63
64
  export type { API as ReactiveArray };
@@ -171,7 +171,7 @@ function factory(input) {
171
171
  const isReactiveArray = (value) => {
172
172
  return isObject(value) && REACTIVE_ARRAY in value;
173
173
  };
174
- export default function array(input) {
174
+ export default (input) => {
175
175
  let proxy = new Proxy({}, {
176
176
  get(_, key) {
177
177
  if (isNumber(key)) {
@@ -199,6 +199,5 @@ export default function array(input) {
199
199
  }), wrapped = factory(input);
200
200
  let array = new ReactiveArray(wrapped, proxy);
201
201
  return proxy;
202
- }
203
- ;
202
+ };
204
203
  export { isReactiveArray };
@@ -10,6 +10,7 @@ declare class ReactiveObject<T extends Record<PropertyKey, unknown>> {
10
10
  dispose(): void;
11
11
  }
12
12
  declare const isReactiveObject: (value: any) => value is ReactiveObject<any>;
13
- export default function object<T extends Record<PropertyKey, unknown>>(input: T): ReactiveObject<T>;
13
+ declare const _default: <T extends Record<PropertyKey, unknown>>(input: T) => API<T>;
14
+ export default _default;
14
15
  export { isReactiveObject };
15
16
  export type { API as ReactiveObject };
@@ -73,8 +73,7 @@ class ReactiveObject {
73
73
  const isReactiveObject = (value) => {
74
74
  return isObject(value) && REACTIVE_OBJECT in value;
75
75
  };
76
- export default function object(input) {
76
+ export default (input) => {
77
77
  return new ReactiveObject(input);
78
- }
79
- ;
78
+ };
80
79
  export { isReactiveObject };
package/build/system.js CHANGED
@@ -172,24 +172,25 @@ function schedule() {
172
172
  }
173
173
  }
174
174
  function stabilize() {
175
- root(() => {
176
- stabilizer = STABILIZER_RUNNING;
177
- for (index = 0; index <= length; index++) {
178
- let computed = heap[index];
179
- heap[index] = undefined;
180
- while (computed !== undefined) {
181
- let next = computed.nextHeap;
182
- recompute(computed, false);
183
- computed = next;
184
- }
185
- }
186
- if (stabilizer === STABILIZER_RESCHEDULE) {
187
- microtask(stabilize);
188
- }
189
- else {
190
- stabilizer = STABILIZER_IDLE;
175
+ let o = observer;
176
+ observer = null;
177
+ stabilizer = STABILIZER_RUNNING;
178
+ for (index = 0; index <= length; index++) {
179
+ let computed = heap[index];
180
+ heap[index] = undefined;
181
+ while (computed !== undefined) {
182
+ let next = computed.nextHeap;
183
+ recompute(computed, false);
184
+ computed = next;
191
185
  }
192
- });
186
+ }
187
+ observer = o;
188
+ if (stabilizer === STABILIZER_RESCHEDULE) {
189
+ microtask(stabilize);
190
+ }
191
+ else {
192
+ stabilizer = STABILIZER_IDLE;
193
+ }
193
194
  }
194
195
  function unlink(link) {
195
196
  let { dep, nextDep, nextSub, prevSub } = link;
package/package.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "private": false,
13
13
  "type": "module",
14
14
  "types": "build/index.d.ts",
15
- "version": "0.12.1",
15
+ "version": "0.12.3",
16
16
  "scripts": {
17
17
  "build": "tsc && tsc-alias",
18
18
  "-": "-"
@@ -294,7 +294,7 @@ const isReactiveArray = (value: any): value is ReactiveArray<any> => {
294
294
  };
295
295
 
296
296
 
297
- export default function array<T>(input: T[]) {
297
+ export default <T>(input: T[]) => {
298
298
  let proxy = new Proxy({}, {
299
299
  get(_: any, key: any) {
300
300
  if (isNumber(key)) {
@@ -100,8 +100,8 @@ const isReactiveObject = (value: any): value is ReactiveObject<any> => {
100
100
  };
101
101
 
102
102
 
103
- export default function object<T extends Record<PropertyKey, unknown>>(input: T) {
104
- return new ReactiveObject<T>(input);
103
+ export default <T extends Record<PropertyKey, unknown>>(input: T) => {
104
+ return new ReactiveObject<T>(input) as API<T>;
105
105
  };
106
106
  export { isReactiveObject };
107
107
  export type { API as ReactiveObject };
package/src/system.ts CHANGED
@@ -253,30 +253,33 @@ function schedule() {
253
253
  }
254
254
 
255
255
  function stabilize() {
256
- root(() => {
257
- stabilizer = STABILIZER_RUNNING;
256
+ let o = observer;
258
257
 
259
- for (index = 0; index <= length; index++) {
260
- let computed = heap[index];
258
+ observer = null;
259
+ stabilizer = STABILIZER_RUNNING;
261
260
 
262
- heap[index] = undefined;
261
+ for (index = 0; index <= length; index++) {
262
+ let computed = heap[index];
263
263
 
264
- while (computed !== undefined) {
265
- let next = computed.nextHeap;
264
+ heap[index] = undefined;
266
265
 
267
- recompute(computed, false);
266
+ while (computed !== undefined) {
267
+ let next = computed.nextHeap;
268
268
 
269
- computed = next;
270
- }
271
- }
269
+ recompute(computed, false);
272
270
 
273
- if (stabilizer === STABILIZER_RESCHEDULE) {
274
- microtask(stabilize);
271
+ computed = next;
275
272
  }
276
- else {
277
- stabilizer = STABILIZER_IDLE;
278
- }
279
- });
273
+ }
274
+
275
+ observer = o;
276
+
277
+ if (stabilizer === STABILIZER_RESCHEDULE) {
278
+ microtask(stabilize);
279
+ }
280
+ else {
281
+ stabilizer = STABILIZER_IDLE;
282
+ }
280
283
  }
281
284
 
282
285
  // https://github.com/stackblitz/alien-signals/blob/v2.0.3/src/system.ts#L100