@flexsurfer/reflex 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/dist/index.cjs CHANGED
@@ -259,6 +259,51 @@ function updateAppDbWithPatches(newDb, patches) {
259
259
 
260
260
  // src/immer-utils.ts
261
261
  var import_immer = require("immer");
262
+
263
+ // src/settings.ts
264
+ var import_fast_deep_equal = __toESM(require("fast-deep-equal"), 1);
265
+ var store = {
266
+ globalInterceptors: [],
267
+ globalEqualityCheck: import_fast_deep_equal.default
268
+ };
269
+ function replaceGlobalInterceptor(globalInterceptors, interceptor) {
270
+ return globalInterceptors.reduce((ret, existingInterceptor) => {
271
+ if (interceptor.id === existingInterceptor.id) {
272
+ return [...ret, interceptor];
273
+ } else {
274
+ return [...ret, existingInterceptor];
275
+ }
276
+ }, []);
277
+ }
278
+ function regGlobalInterceptor(interceptor) {
279
+ const { id } = interceptor;
280
+ const ids = store.globalInterceptors.map((i) => i.id);
281
+ if (ids.includes(id)) {
282
+ store.globalInterceptors = replaceGlobalInterceptor(store.globalInterceptors, interceptor);
283
+ } else {
284
+ store.globalInterceptors = [...store.globalInterceptors, interceptor];
285
+ }
286
+ }
287
+ function getGlobalInterceptors() {
288
+ return [...store.globalInterceptors];
289
+ }
290
+ function clearGlobalInterceptors(id) {
291
+ if (id === void 0) {
292
+ store.globalInterceptors = [];
293
+ } else {
294
+ store.globalInterceptors = store.globalInterceptors.filter((interceptor) => interceptor.id !== id);
295
+ }
296
+ }
297
+ function setGlobalEqualityCheck(equalityCheck) {
298
+ store.globalEqualityCheck = equalityCheck;
299
+ }
300
+ function getGlobalEqualityCheck() {
301
+ return store.globalEqualityCheck;
302
+ }
303
+
304
+ // src/immer-utils.ts
305
+ var import_fast_deep_equal2 = __toESM(require("fast-deep-equal"), 1);
306
+ var import_es6 = __toESM(require("fast-deep-equal/es6/index.js"), 1);
262
307
  function original(value) {
263
308
  return (0, import_immer.isDraft)(value) ? (0, import_immer.original)(value) : value;
264
309
  }
@@ -267,6 +312,9 @@ function current(value) {
267
312
  }
268
313
  function enableMapSet() {
269
314
  (0, import_immer.enableMapSet)();
315
+ if (getGlobalEqualityCheck() === import_fast_deep_equal2.default) {
316
+ setGlobalEqualityCheck(import_es6.default);
317
+ }
270
318
  }
271
319
 
272
320
  // src/interceptor.ts
@@ -604,47 +652,6 @@ regEffect(DISPATCH, (value) => {
604
652
  // src/events.ts
605
653
  var import_immer2 = require("immer");
606
654
 
607
- // src/settings.ts
608
- var import_fast_deep_equal = __toESM(require("fast-deep-equal"), 1);
609
- var store = {
610
- globalInterceptors: [],
611
- globalEqualityCheck: import_fast_deep_equal.default
612
- };
613
- function replaceGlobalInterceptor(globalInterceptors, interceptor) {
614
- return globalInterceptors.reduce((ret, existingInterceptor) => {
615
- if (interceptor.id === existingInterceptor.id) {
616
- return [...ret, interceptor];
617
- } else {
618
- return [...ret, existingInterceptor];
619
- }
620
- }, []);
621
- }
622
- function regGlobalInterceptor(interceptor) {
623
- const { id } = interceptor;
624
- const ids = store.globalInterceptors.map((i) => i.id);
625
- if (ids.includes(id)) {
626
- store.globalInterceptors = replaceGlobalInterceptor(store.globalInterceptors, interceptor);
627
- } else {
628
- store.globalInterceptors = [...store.globalInterceptors, interceptor];
629
- }
630
- }
631
- function getGlobalInterceptors() {
632
- return [...store.globalInterceptors];
633
- }
634
- function clearGlobalInterceptors(id) {
635
- if (id === void 0) {
636
- store.globalInterceptors = [];
637
- } else {
638
- store.globalInterceptors = store.globalInterceptors.filter((interceptor) => interceptor.id !== id);
639
- }
640
- }
641
- function setGlobalEqualityCheck(equalityCheck) {
642
- store.globalEqualityCheck = equalityCheck;
643
- }
644
- function getGlobalEqualityCheck() {
645
- return store.globalEqualityCheck;
646
- }
647
-
648
655
  // src/trace.ts
649
656
  var nextId = 1;
650
657
  var traces = [];
@@ -879,7 +886,7 @@ function defaultErrorHandler(originalError, reflexError) {
879
886
  regEventErrorHandler(defaultErrorHandler);
880
887
 
881
888
  // src/reaction.ts
882
- var import_fast_deep_equal2 = __toESM(require("fast-deep-equal"), 1);
889
+ var import_fast_deep_equal3 = __toESM(require("fast-deep-equal"), 1);
883
890
  var Reaction = class _Reaction {
884
891
  id = "";
885
892
  computeFn;
@@ -896,7 +903,7 @@ var Reaction = class _Reaction {
896
903
  constructor(computeFn, deps, equalityCheck) {
897
904
  this.computeFn = computeFn;
898
905
  this.deps = deps;
899
- this.equalityCheck = equalityCheck || import_fast_deep_equal2.default;
906
+ this.equalityCheck = equalityCheck || import_fast_deep_equal3.default;
900
907
  }
901
908
  static create(fn, deps, equalityCheck) {
902
909
  return new _Reaction(fn, deps, equalityCheck);
@@ -965,7 +972,7 @@ var Reaction = class _Reaction {
965
972
  const depValues = this.deps?.map((d) => d.getDepValue(notifyWatchers)) ?? [];
966
973
  const values = depValues.map(([value]) => value);
967
974
  const currentVersions = depValues.map(([, version]) => version);
968
- const versionsChanged = !(0, import_fast_deep_equal2.default)(currentVersions, this.depsVersions);
975
+ const versionsChanged = !(0, import_fast_deep_equal3.default)(currentVersions, this.depsVersions);
969
976
  if (this.value === void 0 || versionsChanged) {
970
977
  let newVal = this.computeFn(...values);
971
978
  changed = !this.equalityCheck(newVal, this.value);
package/dist/index.d.cts CHANGED
@@ -65,6 +65,8 @@ declare function current<T>(value: T): T;
65
65
  /**
66
66
  * Enable Map and Set support in Immer
67
67
  * This allows Immer to handle Map and Set objects properly in drafts
68
+ * Also updates the global equality check to use fast-deep-equal/es6 for proper Map/Set comparison,
69
+ * but only if the current equality check is still the default isEqual
68
70
  */
69
71
  declare function enableMapSet(): void;
70
72
 
package/dist/index.d.ts CHANGED
@@ -65,6 +65,8 @@ declare function current<T>(value: T): T;
65
65
  /**
66
66
  * Enable Map and Set support in Immer
67
67
  * This allows Immer to handle Map and Set objects properly in drafts
68
+ * Also updates the global equality check to use fast-deep-equal/es6 for proper Map/Set comparison,
69
+ * but only if the current equality check is still the default isEqual
68
70
  */
69
71
  declare function enableMapSet(): void;
70
72
 
package/dist/index.mjs CHANGED
@@ -181,6 +181,51 @@ function updateAppDbWithPatches(newDb, patches) {
181
181
 
182
182
  // src/immer-utils.ts
183
183
  import { isDraft, original as immerOriginal, current as immerCurrent, enableMapSet as immerEnableMapSet } from "immer";
184
+
185
+ // src/settings.ts
186
+ import isEqual from "fast-deep-equal";
187
+ var store = {
188
+ globalInterceptors: [],
189
+ globalEqualityCheck: isEqual
190
+ };
191
+ function replaceGlobalInterceptor(globalInterceptors, interceptor) {
192
+ return globalInterceptors.reduce((ret, existingInterceptor) => {
193
+ if (interceptor.id === existingInterceptor.id) {
194
+ return [...ret, interceptor];
195
+ } else {
196
+ return [...ret, existingInterceptor];
197
+ }
198
+ }, []);
199
+ }
200
+ function regGlobalInterceptor(interceptor) {
201
+ const { id } = interceptor;
202
+ const ids = store.globalInterceptors.map((i) => i.id);
203
+ if (ids.includes(id)) {
204
+ store.globalInterceptors = replaceGlobalInterceptor(store.globalInterceptors, interceptor);
205
+ } else {
206
+ store.globalInterceptors = [...store.globalInterceptors, interceptor];
207
+ }
208
+ }
209
+ function getGlobalInterceptors() {
210
+ return [...store.globalInterceptors];
211
+ }
212
+ function clearGlobalInterceptors(id) {
213
+ if (id === void 0) {
214
+ store.globalInterceptors = [];
215
+ } else {
216
+ store.globalInterceptors = store.globalInterceptors.filter((interceptor) => interceptor.id !== id);
217
+ }
218
+ }
219
+ function setGlobalEqualityCheck(equalityCheck) {
220
+ store.globalEqualityCheck = equalityCheck;
221
+ }
222
+ function getGlobalEqualityCheck() {
223
+ return store.globalEqualityCheck;
224
+ }
225
+
226
+ // src/immer-utils.ts
227
+ import isEqual2 from "fast-deep-equal";
228
+ import isEqualEs6 from "fast-deep-equal/es6/index.js";
184
229
  function original(value) {
185
230
  return isDraft(value) ? immerOriginal(value) : value;
186
231
  }
@@ -189,6 +234,9 @@ function current(value) {
189
234
  }
190
235
  function enableMapSet() {
191
236
  immerEnableMapSet();
237
+ if (getGlobalEqualityCheck() === isEqual2) {
238
+ setGlobalEqualityCheck(isEqualEs6);
239
+ }
192
240
  }
193
241
 
194
242
  // src/interceptor.ts
@@ -526,47 +574,6 @@ regEffect(DISPATCH, (value) => {
526
574
  // src/events.ts
527
575
  import { enablePatches, produceWithPatches } from "immer";
528
576
 
529
- // src/settings.ts
530
- import isEqual from "fast-deep-equal";
531
- var store = {
532
- globalInterceptors: [],
533
- globalEqualityCheck: isEqual
534
- };
535
- function replaceGlobalInterceptor(globalInterceptors, interceptor) {
536
- return globalInterceptors.reduce((ret, existingInterceptor) => {
537
- if (interceptor.id === existingInterceptor.id) {
538
- return [...ret, interceptor];
539
- } else {
540
- return [...ret, existingInterceptor];
541
- }
542
- }, []);
543
- }
544
- function regGlobalInterceptor(interceptor) {
545
- const { id } = interceptor;
546
- const ids = store.globalInterceptors.map((i) => i.id);
547
- if (ids.includes(id)) {
548
- store.globalInterceptors = replaceGlobalInterceptor(store.globalInterceptors, interceptor);
549
- } else {
550
- store.globalInterceptors = [...store.globalInterceptors, interceptor];
551
- }
552
- }
553
- function getGlobalInterceptors() {
554
- return [...store.globalInterceptors];
555
- }
556
- function clearGlobalInterceptors(id) {
557
- if (id === void 0) {
558
- store.globalInterceptors = [];
559
- } else {
560
- store.globalInterceptors = store.globalInterceptors.filter((interceptor) => interceptor.id !== id);
561
- }
562
- }
563
- function setGlobalEqualityCheck(equalityCheck) {
564
- store.globalEqualityCheck = equalityCheck;
565
- }
566
- function getGlobalEqualityCheck() {
567
- return store.globalEqualityCheck;
568
- }
569
-
570
577
  // src/trace.ts
571
578
  var nextId = 1;
572
579
  var traces = [];
@@ -801,7 +808,7 @@ function defaultErrorHandler(originalError, reflexError) {
801
808
  regEventErrorHandler(defaultErrorHandler);
802
809
 
803
810
  // src/reaction.ts
804
- import isEqual2 from "fast-deep-equal";
811
+ import isEqual3 from "fast-deep-equal";
805
812
  var Reaction = class _Reaction {
806
813
  id = "";
807
814
  computeFn;
@@ -818,7 +825,7 @@ var Reaction = class _Reaction {
818
825
  constructor(computeFn, deps, equalityCheck) {
819
826
  this.computeFn = computeFn;
820
827
  this.deps = deps;
821
- this.equalityCheck = equalityCheck || isEqual2;
828
+ this.equalityCheck = equalityCheck || isEqual3;
822
829
  }
823
830
  static create(fn, deps, equalityCheck) {
824
831
  return new _Reaction(fn, deps, equalityCheck);
@@ -887,7 +894,7 @@ var Reaction = class _Reaction {
887
894
  const depValues = this.deps?.map((d) => d.getDepValue(notifyWatchers)) ?? [];
888
895
  const values = depValues.map(([value]) => value);
889
896
  const currentVersions = depValues.map(([, version]) => version);
890
- const versionsChanged = !isEqual2(currentVersions, this.depsVersions);
897
+ const versionsChanged = !isEqual3(currentVersions, this.depsVersions);
891
898
  if (this.value === void 0 || versionsChanged) {
892
899
  let newVal = this.computeFn(...values);
893
900
  changed = !this.equalityCheck(newVal, this.value);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flexsurfer/reflex",
3
- "version": "0.1.22",
3
+ "version": "0.1.23",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",