on-zero 0.4.50 → 0.5.0

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.
Files changed (39) hide show
  1. package/dist/cjs/createUseQuery.cjs +0 -6
  2. package/dist/cjs/createUseQuery.native.js +0 -6
  3. package/dist/cjs/createUseQuery.native.js.map +1 -1
  4. package/dist/cjs/createUseQueryDirect.cjs +1 -5
  5. package/dist/cjs/createUseQueryDirect.native.js +1 -5
  6. package/dist/cjs/createUseQueryDirect.native.js.map +1 -1
  7. package/dist/esm/createUseQuery.mjs +0 -6
  8. package/dist/esm/createUseQuery.mjs.map +1 -1
  9. package/dist/esm/createUseQuery.native.js +0 -6
  10. package/dist/esm/createUseQuery.native.js.map +1 -1
  11. package/dist/esm/createUseQueryDirect.mjs +1 -5
  12. package/dist/esm/createUseQueryDirect.mjs.map +1 -1
  13. package/dist/esm/createUseQueryDirect.native.js +1 -5
  14. package/dist/esm/createUseQueryDirect.native.js.map +1 -1
  15. package/package.json +2 -2
  16. package/src/createUseQuery.tsx +0 -13
  17. package/src/createUseQueryDirect.tsx +1 -10
  18. package/types/createUseQuery.d.ts.map +1 -1
  19. package/types/createUseQueryDirect.d.ts.map +1 -1
  20. package/dist/cjs/useContentStable.cjs +0 -66
  21. package/dist/cjs/useContentStable.native.js +0 -93
  22. package/dist/cjs/useContentStable.native.js.map +0 -1
  23. package/dist/cjs/useContentStable.test.cjs +0 -105
  24. package/dist/cjs/useContentStable.test.native.js +0 -108
  25. package/dist/cjs/useContentStable.test.native.js.map +0 -1
  26. package/dist/esm/useContentStable.mjs +0 -40
  27. package/dist/esm/useContentStable.mjs.map +0 -1
  28. package/dist/esm/useContentStable.native.js +0 -64
  29. package/dist/esm/useContentStable.native.js.map +0 -1
  30. package/dist/esm/useContentStable.test.mjs +0 -106
  31. package/dist/esm/useContentStable.test.mjs.map +0 -1
  32. package/dist/esm/useContentStable.test.native.js +0 -106
  33. package/dist/esm/useContentStable.test.native.js.map +0 -1
  34. package/src/useContentStable.test.ts +0 -61
  35. package/src/useContentStable.ts +0 -78
  36. package/types/useContentStable.d.ts +0 -3
  37. package/types/useContentStable.d.ts.map +0 -1
  38. package/types/useContentStable.test.d.ts +0 -2
  39. package/types/useContentStable.test.d.ts.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","useContentStable_exports","__export","isContentEqual","useContentStable","module","exports","import_react","require","_type_of","obj","Symbol","constructor","arraysShallowEqual","a","b","length","i","Object","is","objectsShallowEqual","ak","keys","bk","_iteratorNormalCompletion","_didIteratorError","_iteratorError","_iterator","iterator","_step","next","done","k","err","return"],"sources":["../../src/useContentStable.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,wBAAA;AAAAC,QAAA,CAAAD,wBAAA;EAAAE,cAAA,EAAAA,CAAA,KAAAA,cAAA;EAAAC,gBAAA,EAAAA,CAAA,KAAAA;AAAA;AA0BAC,MAAA,CAAAC,OAAA,GAAAV,YAAuB,CAAAK,wBAAA;AAEvB,IAAAM,YAAS,GAAAC,OAAA,QAA0E;AACjF,SAAIC,QAASA,CAAAC,GAAA,EAAO;EACpB,uBAAmB;;EACnB,OAAAA,GAAS,IAAI,OAAOC,MAAE,KAAQ,WAAK,IAAAD,GAAA,CAAAE,WAAA,KAAAD,MAAA,qBAAAD,GAAA;AACjC;AAAmC,SACrCG,mBAAAC,CAAA,EAAAC,CAAA;EACA,IAAAD,CAAA,KAAOC,CAAA;EACT,IAAAD,CAAA,CAAAE,MAAA,KAAAD,CAAA,CAAAC,MAAA;EAEA,SAASC,CAAA,MAAAA,CAAA,GAAAH,CAAA,CAAAE,MAAoB,EAAWC,CAAA,EAAoB;IAC1D,IAAI,CAAAC,MAAS,CAAAC,EAAA,CAAAL,CAAA,CAAAG,CAAO,GAAAF,CAAA,CAAAE,CAAA;EACpB;EACA,OAAM,IAAK;AACX;AACA,SAAAG,mBAAoBA,CAAAN,CAAA,EAAAC,CAAA;EAClB,IAAAD,CAAA,KACGC,CAAA,SAAO;EAAA,IACLM,EAA8B,GAACH,MAAA,CAAAI,IAAA,CAAAR,CAAA;EAAA,IAC/BS,EAA8B,GAACL,MAAA,CAAAI,IAAA,CAAAP,CAAA;EAAA,IAClCM,EAAA,CAAAL,MAAA,KAAAO,EAAA,CAAAP,MAAA;EAEA,IAAAQ,yBAAO;IAAAC,iBAAA;IAAAC,cAAA;EACX;IACA,KAAO,IAAAC,SAAA,GAAAN,EAAA,CAAAV,MAAA,CAAAiB,QAAA,KAAAC,KAAA,IAAAL,yBAAA,IAAAK,KAAA,GAAAF,SAAA,CAAAG,IAAA,IAAAC,IAAA,GAAAP,yBAAA;MACT,IAAAQ,CAAA,GAAAH,KAAA,CAAA7B,KAAA;MAEO,IAAS,CAAAkB,MAAA,CAAAC,EAAA,CAAAL,CAAA,CAAAkB,CAAe,GAAYjB,CAAA,CAAAiB,CAAqB;IAC9D;EACA,SAAIC,GAAM;IACVR,iBAAiB;IACjBC,cAAe,GAAAO,GAAM;EACrB,UAAM;IACN,IAAI;MACA,KAAAT,yBAAkB,IAAAG,SAAA,CAAAO,MAAA;QACpBP,SAAO,CAAAO,MAAA;MACT;IACA,UAAO;MACT,IAAAT,iBAAA;QAMO,MAASC,cAAoB;MAClC;IACA;EACE;EACF;AACA;AACF,SAAAvB,eAAAW,CAAA,EAAAC,CAAA","ignoreList":[]}
@@ -1,105 +0,0 @@
1
- var import_vitest = require("vitest");
2
- var import_useContentStable = require("./useContentStable.cjs");
3
- (0, import_vitest.describe)("isContentEqual", () => {
4
- (0, import_vitest.it)("treats primitives by value", () => {
5
- (0, import_vitest.expect)((0, import_useContentStable.isContentEqual)(1, 1)).toBe(true);
6
- (0, import_vitest.expect)((0, import_useContentStable.isContentEqual)("a", "a")).toBe(true);
7
- (0, import_vitest.expect)((0, import_useContentStable.isContentEqual)(true, true)).toBe(true);
8
- (0, import_vitest.expect)((0, import_useContentStable.isContentEqual)(void 0, void 0)).toBe(true);
9
- (0, import_vitest.expect)((0, import_useContentStable.isContentEqual)(null, null)).toBe(true);
10
- (0, import_vitest.expect)((0, import_useContentStable.isContentEqual)(1, 2)).toBe(false);
11
- (0, import_vitest.expect)((0, import_useContentStable.isContentEqual)("a", "b")).toBe(false);
12
- (0, import_vitest.expect)((0, import_useContentStable.isContentEqual)(null, void 0)).toBe(false);
13
- });
14
- (0, import_vitest.it)("treats arrays by length + per-element strict-eq", () => {
15
- (0, import_vitest.expect)((0, import_useContentStable.isContentEqual)([], [])).toBe(true);
16
- (0, import_vitest.expect)((0, import_useContentStable.isContentEqual)([1, 2, 3], [1, 2, 3])).toBe(true);
17
- (0, import_vitest.expect)((0, import_useContentStable.isContentEqual)([1, 2, 3], [1, 2])).toBe(false);
18
- (0, import_vitest.expect)((0, import_useContentStable.isContentEqual)([1, 2, 3], [1, 2, 4])).toBe(false);
19
- (0, import_vitest.expect)((0, import_useContentStable.isContentEqual)([{
20
- id: 1
21
- }], [{
22
- id: 1
23
- }])).toBe(false);
24
- const row = {
25
- id: 1
26
- };
27
- (0, import_vitest.expect)((0, import_useContentStable.isContentEqual)([row], [row])).toBe(true);
28
- });
29
- (0, import_vitest.it)("treats objects by same keys + per-value strict-eq", () => {
30
- (0, import_vitest.expect)((0, import_useContentStable.isContentEqual)({}, {})).toBe(true);
31
- (0, import_vitest.expect)((0, import_useContentStable.isContentEqual)({
32
- a: 1,
33
- b: 2
34
- }, {
35
- a: 1,
36
- b: 2
37
- })).toBe(true);
38
- (0, import_vitest.expect)((0, import_useContentStable.isContentEqual)({
39
- a: 1
40
- }, {
41
- a: 1,
42
- b: 2
43
- })).toBe(false);
44
- (0, import_vitest.expect)((0, import_useContentStable.isContentEqual)({
45
- a: 1
46
- }, {
47
- a: 2
48
- })).toBe(false);
49
- (0, import_vitest.expect)((0, import_useContentStable.isContentEqual)({
50
- row: {
51
- id: 1
52
- }
53
- }, {
54
- row: {
55
- id: 1
56
- }
57
- })).toBe(false);
58
- });
59
- (0, import_vitest.it)("rejects mismatched array vs object", () => {
60
- (0, import_vitest.expect)((0, import_useContentStable.isContentEqual)([], {})).toBe(false);
61
- (0, import_vitest.expect)((0, import_useContentStable.isContentEqual)([1], {
62
- 0: 1
63
- })).toBe(false);
64
- });
65
- (0, import_vitest.it)("handles a typical zero singular-query refresh \u2014 same row content", () => {
66
- const prev = {
67
- id: "s1",
68
- name: "warden",
69
- level: 1,
70
- hp: 60,
71
- maxHp: 60
72
- };
73
- const next = {
74
- id: "s1",
75
- name: "warden",
76
- level: 1,
77
- hp: 60,
78
- maxHp: 60
79
- };
80
- (0, import_vitest.expect)((0, import_useContentStable.isContentEqual)(prev, next)).toBe(true);
81
- });
82
- (0, import_vitest.it)("detects a real refresh \u2014 one field changed", () => {
83
- const prev = {
84
- id: "s1",
85
- hp: 60
86
- };
87
- const next = {
88
- id: "s1",
89
- hp: 59
90
- };
91
- (0, import_vitest.expect)((0, import_useContentStable.isContentEqual)(prev, next)).toBe(false);
92
- });
93
- (0, import_vitest.it)('handles zero info objects ({type: "complete"} vs {type: "unknown"})', () => {
94
- (0, import_vitest.expect)((0, import_useContentStable.isContentEqual)({
95
- type: "complete"
96
- }, {
97
- type: "complete"
98
- })).toBe(true);
99
- (0, import_vitest.expect)((0, import_useContentStable.isContentEqual)({
100
- type: "complete"
101
- }, {
102
- type: "unknown"
103
- })).toBe(false);
104
- });
105
- });
@@ -1,108 +0,0 @@
1
- "use strict";
2
-
3
- var import_vitest = require("vitest");
4
- var import_useContentStable = require("./useContentStable.native.js");
5
- (0, import_vitest.describe)("isContentEqual", function () {
6
- (0, import_vitest.it)("treats primitives by value", function () {
7
- (0, import_vitest.expect)((0, import_useContentStable.isContentEqual)(1, 1)).toBe(true);
8
- (0, import_vitest.expect)((0, import_useContentStable.isContentEqual)("a", "a")).toBe(true);
9
- (0, import_vitest.expect)((0, import_useContentStable.isContentEqual)(true, true)).toBe(true);
10
- (0, import_vitest.expect)((0, import_useContentStable.isContentEqual)(void 0, void 0)).toBe(true);
11
- (0, import_vitest.expect)((0, import_useContentStable.isContentEqual)(null, null)).toBe(true);
12
- (0, import_vitest.expect)((0, import_useContentStable.isContentEqual)(1, 2)).toBe(false);
13
- (0, import_vitest.expect)((0, import_useContentStable.isContentEqual)("a", "b")).toBe(false);
14
- (0, import_vitest.expect)((0, import_useContentStable.isContentEqual)(null, void 0)).toBe(false);
15
- });
16
- (0, import_vitest.it)("treats arrays by length + per-element strict-eq", function () {
17
- (0, import_vitest.expect)((0, import_useContentStable.isContentEqual)([], [])).toBe(true);
18
- (0, import_vitest.expect)((0, import_useContentStable.isContentEqual)([1, 2, 3], [1, 2, 3])).toBe(true);
19
- (0, import_vitest.expect)((0, import_useContentStable.isContentEqual)([1, 2, 3], [1, 2])).toBe(false);
20
- (0, import_vitest.expect)((0, import_useContentStable.isContentEqual)([1, 2, 3], [1, 2, 4])).toBe(false);
21
- (0, import_vitest.expect)((0, import_useContentStable.isContentEqual)([{
22
- id: 1
23
- }], [{
24
- id: 1
25
- }])).toBe(false);
26
- var row = {
27
- id: 1
28
- };
29
- (0, import_vitest.expect)((0, import_useContentStable.isContentEqual)([row], [row])).toBe(true);
30
- });
31
- (0, import_vitest.it)("treats objects by same keys + per-value strict-eq", function () {
32
- (0, import_vitest.expect)((0, import_useContentStable.isContentEqual)({}, {})).toBe(true);
33
- (0, import_vitest.expect)((0, import_useContentStable.isContentEqual)({
34
- a: 1,
35
- b: 2
36
- }, {
37
- a: 1,
38
- b: 2
39
- })).toBe(true);
40
- (0, import_vitest.expect)((0, import_useContentStable.isContentEqual)({
41
- a: 1
42
- }, {
43
- a: 1,
44
- b: 2
45
- })).toBe(false);
46
- (0, import_vitest.expect)((0, import_useContentStable.isContentEqual)({
47
- a: 1
48
- }, {
49
- a: 2
50
- })).toBe(false);
51
- (0, import_vitest.expect)((0, import_useContentStable.isContentEqual)({
52
- row: {
53
- id: 1
54
- }
55
- }, {
56
- row: {
57
- id: 1
58
- }
59
- })).toBe(false);
60
- });
61
- (0, import_vitest.it)("rejects mismatched array vs object", function () {
62
- (0, import_vitest.expect)((0, import_useContentStable.isContentEqual)([], {})).toBe(false);
63
- (0, import_vitest.expect)((0, import_useContentStable.isContentEqual)([1], {
64
- 0: 1
65
- })).toBe(false);
66
- });
67
- (0, import_vitest.it)("handles a typical zero singular-query refresh \u2014 same row content", function () {
68
- var prev = {
69
- id: "s1",
70
- name: "warden",
71
- level: 1,
72
- hp: 60,
73
- maxHp: 60
74
- };
75
- var next = {
76
- id: "s1",
77
- name: "warden",
78
- level: 1,
79
- hp: 60,
80
- maxHp: 60
81
- };
82
- (0, import_vitest.expect)((0, import_useContentStable.isContentEqual)(prev, next)).toBe(true);
83
- });
84
- (0, import_vitest.it)("detects a real refresh \u2014 one field changed", function () {
85
- var prev = {
86
- id: "s1",
87
- hp: 60
88
- };
89
- var next = {
90
- id: "s1",
91
- hp: 59
92
- };
93
- (0, import_vitest.expect)((0, import_useContentStable.isContentEqual)(prev, next)).toBe(false);
94
- });
95
- (0, import_vitest.it)('handles zero info objects ({type: "complete"} vs {type: "unknown"})', function () {
96
- (0, import_vitest.expect)((0, import_useContentStable.isContentEqual)({
97
- type: "complete"
98
- }, {
99
- type: "complete"
100
- })).toBe(true);
101
- (0, import_vitest.expect)((0, import_useContentStable.isContentEqual)({
102
- type: "complete"
103
- }, {
104
- type: "unknown"
105
- })).toBe(false);
106
- });
107
- });
108
- //# sourceMappingURL=useContentStable.test.native.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["import_vitest","require","import_useContentStable","describe","it","expect","isContentEqual","toBe","id"],"sources":["../../src/useContentStable.test.ts"],"sourcesContent":[null],"mappings":"AAAA;;AACA,IAAAA,aAAA,GAAAC,OAAA,SAA+B;AAAA,IAE/BC,uBAAA,GAASD,OAAA,+BAAwB;AAC/B,IAAAD,aAA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A,CAAAK,MAAG,MAAAH,uBAAA,CAAAI,cAAA,GAID,GACA,GACA,EACD,GAED,GACE,GACA,EACA,GAAAC,IAAA;IACD,IAAAP,aAAA,CAAAK,MAAA,MAAAH,uBAAA,CAAAI,cAAA,GAED;MACEE,EAAA;IACA,EACD,GACF","ignoreList":[]}
@@ -1,40 +0,0 @@
1
- import { useRef } from "react";
2
- function arraysShallowEqual(a, b) {
3
- if (a === b) return true;
4
- if (a.length !== b.length) return false;
5
- for (let i = 0; i < a.length; i++) {
6
- if (!Object.is(a[i], b[i])) return false;
7
- }
8
- return true;
9
- }
10
- function objectsShallowEqual(a, b) {
11
- if (a === b) return true;
12
- const ak = Object.keys(a);
13
- const bk = Object.keys(b);
14
- if (ak.length !== bk.length) return false;
15
- for (const k of ak) {
16
- if (!Object.is(a[k], b[k])) return false;
17
- }
18
- return true;
19
- }
20
- function isContentEqual(a, b) {
21
- if (Object.is(a, b)) return true;
22
- if (a === null || b === null || a === void 0 || b === void 0) return false;
23
- if (typeof a !== "object" || typeof b !== "object") return false;
24
- const aIsArr = Array.isArray(a);
25
- const bIsArr = Array.isArray(b);
26
- if (aIsArr !== bIsArr) return false;
27
- if (aIsArr && bIsArr) {
28
- return arraysShallowEqual(a, b);
29
- }
30
- return objectsShallowEqual(a, b);
31
- }
32
- function useContentStable(value) {
33
- const ref = useRef(value);
34
- if (!isContentEqual(ref.current, value)) {
35
- ref.current = value;
36
- }
37
- return ref.current;
38
- }
39
- export { isContentEqual, useContentStable };
40
- //# sourceMappingURL=useContentStable.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["useRef","arraysShallowEqual","a","b","length","i","Object","is","objectsShallowEqual","ak","keys","bk","k","isContentEqual","aIsArr","Array","isArray","bIsArr","useContentStable","value","ref","current"],"sources":["../../src/useContentStable.ts"],"sourcesContent":[null],"mappings":"AA0BA,SAASA,MAAA,QAAc;AAEvB,SAASC,mBAAmBC,CAAA,EAAuBC,CAAA,EAAgC;EACjF,IAAID,CAA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A,IAAUG,MAAA,EAAQ;IACpB,OAAOhB,kBAAA,CAAmBC,CAAA,EAAyBC,CAAuB;EAC5E;EACA,OAAOK,mBAAA,CAAoBN,CAAA,EAAaC,CAAW;AACrD;AAMO,SAASe,iBAAoBC,KAAA,EAAa;EAC/C,MAAMC,GAAA,GAAMpB,MAAA,CAAUmB,KAAK;EAC3B,IAAI,CAACN,cAAA,CAAeO,GAAA,CAAIC,OAAA,EAASF,KAAK,GAAG;IACvCC,GAAA,CAAIC,OAAA,GAAUF,KAAA;EAChB;EACA,OAAOC,GAAA,CAAIC,OAAA;AACb","ignoreList":[]}
@@ -1,64 +0,0 @@
1
- import { useRef } from "react";
2
- function _type_of(obj) {
3
- "@swc/helpers - typeof";
4
-
5
- return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
6
- }
7
- function arraysShallowEqual(a, b) {
8
- if (a === b) return true;
9
- if (a.length !== b.length) return false;
10
- for (var i = 0; i < a.length; i++) {
11
- if (!Object.is(a[i], b[i])) return false;
12
- }
13
- return true;
14
- }
15
- function objectsShallowEqual(a, b) {
16
- if (a === b) return true;
17
- var ak = Object.keys(a);
18
- var bk = Object.keys(b);
19
- if (ak.length !== bk.length) return false;
20
- var _iteratorNormalCompletion = true,
21
- _didIteratorError = false,
22
- _iteratorError = void 0;
23
- try {
24
- for (var _iterator = ak[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
25
- var k = _step.value;
26
- if (!Object.is(a[k], b[k])) return false;
27
- }
28
- } catch (err) {
29
- _didIteratorError = true;
30
- _iteratorError = err;
31
- } finally {
32
- try {
33
- if (!_iteratorNormalCompletion && _iterator.return != null) {
34
- _iterator.return();
35
- }
36
- } finally {
37
- if (_didIteratorError) {
38
- throw _iteratorError;
39
- }
40
- }
41
- }
42
- return true;
43
- }
44
- function isContentEqual(a, b) {
45
- if (Object.is(a, b)) return true;
46
- if (a === null || b === null || a === void 0 || b === void 0) return false;
47
- if ((typeof a === "undefined" ? "undefined" : _type_of(a)) !== "object" || (typeof b === "undefined" ? "undefined" : _type_of(b)) !== "object") return false;
48
- var aIsArr = Array.isArray(a);
49
- var bIsArr = Array.isArray(b);
50
- if (aIsArr !== bIsArr) return false;
51
- if (aIsArr && bIsArr) {
52
- return arraysShallowEqual(a, b);
53
- }
54
- return objectsShallowEqual(a, b);
55
- }
56
- function useContentStable(value) {
57
- var ref = useRef(value);
58
- if (!isContentEqual(ref.current, value)) {
59
- ref.current = value;
60
- }
61
- return ref.current;
62
- }
63
- export { isContentEqual, useContentStable };
64
- //# sourceMappingURL=useContentStable.native.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["useRef","_type_of","obj","Symbol","constructor","arraysShallowEqual","a","b","length","i","Object","is","objectsShallowEqual","ak","keys","bk","_iteratorNormalCompletion","_didIteratorError","_iteratorError","_iterator","iterator","_step","next","done","k","value","err","return","isContentEqual"],"sources":["../../src/useContentStable.ts"],"sourcesContent":[null],"mappings":"AA0BA,SAASA,MAAA,QAAc;AAEvB,SAASC,SAAAC,GAAA;EACP,uBAAoB;;EACpB,OAAMA,GAAA,WAAaC,MAAQ,gBAAO,IAAAD,GAAA,CAAAE,WAAA,KAAAD,MAAA,qBAAAD,GAAA;AAClC;AACE,SAAKG,kBAAkBA,CAACC,CAAC,EAAGC,CAAA;EAC9B,IAAAD,CAAA,KAAAC,CAAA;EACA,IAAAD,CAAA,CAAAE,MAAO,KAAAD,CAAA,CAAAC,MAAA;EACT,SAAAC,CAAA,MAAAA,CAAA,GAAAH,CAAA,CAAAE,MAAA,EAAAC,CAAA;IAEA,KAASC,MAAA,CAAAC,EAAA,CAAAL,CAAA,CAAAG,CAAA,GAAAF,CAAA,CAAAE,CAAA,CAAoB,GAAW,OAAoB;EAC1D;EACA,OAAM,IAAK;AACX;AACA,SAAOG,mBAAcA,CAAAN,CAAQ,EAAAC,CAAA;EAC7B,IAAAD,CAAA,KAAAC,CAAW,SAAS;EAClB,IAAAM,EACE,GAACH,MAAO,CAAAI,IAAA,CAAAR,CAAA;EAAA,IACLS,EAA8B,GAACL,MAAA,CAAAI,IAAA,CAAAP,CAAA;EAAA,IAC/BM,EAA8B,CAACL,MAAA,KAAAO,EAAA,CAAAP,MAAA;EAAA,IAClCQ,yBAAA;IAAAC,iBAAA;IAAAC,cAAA;EAEA;IACJ,SAAAC,SAAA,GAAAN,EAAA,CAAAV,MAAA,CAAAiB,QAAA,KAAAC,KAAA,IAAAL,yBAAA,IAAAK,KAAA,GAAAF,SAAA,CAAAG,IAAA,IAAAC,IAAA,GAAAP,yBAAA;MACA,IAAOQ,CAAA,GAAAH,KAAA,CAAAI,KAAA;MACT,KAAAf,MAAA,CAAAC,EAAA,CAAAL,CAAA,CAAAkB,CAAA,GAAAjB,CAAA,CAAAiB,CAAA;IAEO;EACL,SAAIE,GAAO,EAAG;IACdT,iBAAkB,OAAM;IACxBC,cAAW,GAAMQ,GAAA;EACjB,UAAM;IACN,IAAM;MACF,KAAAV,yBAA0B,IAAAG,SAAA,CAAAQ,MAAA;QAC1BR,SAAU,CAAAQ,MAAQ;MACpB;IACF;MACA,IAAOV,iBAAA,EAAoB;QAC7B,MAAAC,cAAA;MAMO;IACL;EACA;EACE,OAAI;AAAU;AAEhB,SAAOU,cAAIA,CAAAtB,CAAA,EAAAC,CAAA;EACb,IAAAG,MAAA,CAAAC,EAAA,CAAAL,CAAA,EAAAC,CAAA","ignoreList":[]}
@@ -1,106 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { isContentEqual } from "./useContentStable.mjs";
3
- describe("isContentEqual", () => {
4
- it("treats primitives by value", () => {
5
- expect(isContentEqual(1, 1)).toBe(true);
6
- expect(isContentEqual("a", "a")).toBe(true);
7
- expect(isContentEqual(true, true)).toBe(true);
8
- expect(isContentEqual(void 0, void 0)).toBe(true);
9
- expect(isContentEqual(null, null)).toBe(true);
10
- expect(isContentEqual(1, 2)).toBe(false);
11
- expect(isContentEqual("a", "b")).toBe(false);
12
- expect(isContentEqual(null, void 0)).toBe(false);
13
- });
14
- it("treats arrays by length + per-element strict-eq", () => {
15
- expect(isContentEqual([], [])).toBe(true);
16
- expect(isContentEqual([1, 2, 3], [1, 2, 3])).toBe(true);
17
- expect(isContentEqual([1, 2, 3], [1, 2])).toBe(false);
18
- expect(isContentEqual([1, 2, 3], [1, 2, 4])).toBe(false);
19
- expect(isContentEqual([{
20
- id: 1
21
- }], [{
22
- id: 1
23
- }])).toBe(false);
24
- const row = {
25
- id: 1
26
- };
27
- expect(isContentEqual([row], [row])).toBe(true);
28
- });
29
- it("treats objects by same keys + per-value strict-eq", () => {
30
- expect(isContentEqual({}, {})).toBe(true);
31
- expect(isContentEqual({
32
- a: 1,
33
- b: 2
34
- }, {
35
- a: 1,
36
- b: 2
37
- })).toBe(true);
38
- expect(isContentEqual({
39
- a: 1
40
- }, {
41
- a: 1,
42
- b: 2
43
- })).toBe(false);
44
- expect(isContentEqual({
45
- a: 1
46
- }, {
47
- a: 2
48
- })).toBe(false);
49
- expect(isContentEqual({
50
- row: {
51
- id: 1
52
- }
53
- }, {
54
- row: {
55
- id: 1
56
- }
57
- })).toBe(false);
58
- });
59
- it("rejects mismatched array vs object", () => {
60
- expect(isContentEqual([], {})).toBe(false);
61
- expect(isContentEqual([1], {
62
- 0: 1
63
- })).toBe(false);
64
- });
65
- it("handles a typical zero singular-query refresh \u2014 same row content", () => {
66
- const prev = {
67
- id: "s1",
68
- name: "warden",
69
- level: 1,
70
- hp: 60,
71
- maxHp: 60
72
- };
73
- const next = {
74
- id: "s1",
75
- name: "warden",
76
- level: 1,
77
- hp: 60,
78
- maxHp: 60
79
- };
80
- expect(isContentEqual(prev, next)).toBe(true);
81
- });
82
- it("detects a real refresh \u2014 one field changed", () => {
83
- const prev = {
84
- id: "s1",
85
- hp: 60
86
- };
87
- const next = {
88
- id: "s1",
89
- hp: 59
90
- };
91
- expect(isContentEqual(prev, next)).toBe(false);
92
- });
93
- it('handles zero info objects ({type: "complete"} vs {type: "unknown"})', () => {
94
- expect(isContentEqual({
95
- type: "complete"
96
- }, {
97
- type: "complete"
98
- })).toBe(true);
99
- expect(isContentEqual({
100
- type: "complete"
101
- }, {
102
- type: "unknown"
103
- })).toBe(false);
104
- });
105
- });
106
- //# sourceMappingURL=useContentStable.test.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["describe","expect","it","isContentEqual","toBe","id","row","a","b","prev","name","level","hp","maxHp","next","type"],"sources":["../../src/useContentStable.test.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,QAAA,EAAUC,MAAA,EAAQC,EAAA,QAAU;AACrC,SAASC,cAAA,QAAsB;AAE/BH,QAAA,CAAS,kBAAkB,MAAM;EAC/BE,EAAA,CAAG,8BAA8B,MAAM;IACrCD,MAAA,CAAOE,cAAA,CAAe,GAAG,CAAC,CAAC,EAAEC,IAAA,CAAK,IAAI;IACtCH,MAAA,CAAOE,cAAA,CAAe,KAAK,GAAG,CAAC,EAAEC,IAAA,CAAK,IAAI;IAC1CH,MAAA,CAAOE,cAAA,CAAe,MAAM,IAAI,CAAC,EAAEC,IAAA,CAAK,IAAI;IAC5CH,MAAA,CAAOE,cAAA,CAAe,QAAW,MAAS,CAAC,EAAEC,IAAA,CAAK,IAAI;IACtDH,MAAA,CAAOE,cAAA,CAAe,MAAM,IAAI,CAAC,EAAEC,IAAA,CAAK,IAAI;IAC5CH,MAAA,CAAOE,cAAA,CAAe,GAAG,CAAC,CAAC,EAAEC,IAAA,CAAK,KAAK;IACvCH,MAAA,CAAOE,cAAA,CAAe,KAAK,GAAG,CAAC,EAAEC,IAAA,CAAK,KAAK;IAC3CH,MAAA,CAAOE,cAAA,CAAe,MAAM,MAAS,CAAC,EAAEC,IAAA,CAAK,KAAK;EACpD,CAAC;EAEDF,EAAA,CAAG,mDAAmD,MAAM;IAC1DD,MAAA,CAAOE,cAAA,CAAe,EAAC,EAAG,EAAE,CAAC,EAAEC,IAAA,CAAK,IAAI;IACxCH,MAAA,CA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,IAAI;IAC5EH,MAAA,CAAOE,cAAA,CAAe;MAAEY,IAAA,EAAM;IAAW,GAAG;MAAEA,IAAA,EAAM;IAAU,CAAC,CAAC,EAAEX,IAAA,CAAK,KAAK;EAC9E,CAAC;AACH,CAAC","ignoreList":[]}
@@ -1,106 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { isContentEqual } from "./useContentStable.native.js";
3
- describe("isContentEqual", function () {
4
- it("treats primitives by value", function () {
5
- expect(isContentEqual(1, 1)).toBe(true);
6
- expect(isContentEqual("a", "a")).toBe(true);
7
- expect(isContentEqual(true, true)).toBe(true);
8
- expect(isContentEqual(void 0, void 0)).toBe(true);
9
- expect(isContentEqual(null, null)).toBe(true);
10
- expect(isContentEqual(1, 2)).toBe(false);
11
- expect(isContentEqual("a", "b")).toBe(false);
12
- expect(isContentEqual(null, void 0)).toBe(false);
13
- });
14
- it("treats arrays by length + per-element strict-eq", function () {
15
- expect(isContentEqual([], [])).toBe(true);
16
- expect(isContentEqual([1, 2, 3], [1, 2, 3])).toBe(true);
17
- expect(isContentEqual([1, 2, 3], [1, 2])).toBe(false);
18
- expect(isContentEqual([1, 2, 3], [1, 2, 4])).toBe(false);
19
- expect(isContentEqual([{
20
- id: 1
21
- }], [{
22
- id: 1
23
- }])).toBe(false);
24
- var row = {
25
- id: 1
26
- };
27
- expect(isContentEqual([row], [row])).toBe(true);
28
- });
29
- it("treats objects by same keys + per-value strict-eq", function () {
30
- expect(isContentEqual({}, {})).toBe(true);
31
- expect(isContentEqual({
32
- a: 1,
33
- b: 2
34
- }, {
35
- a: 1,
36
- b: 2
37
- })).toBe(true);
38
- expect(isContentEqual({
39
- a: 1
40
- }, {
41
- a: 1,
42
- b: 2
43
- })).toBe(false);
44
- expect(isContentEqual({
45
- a: 1
46
- }, {
47
- a: 2
48
- })).toBe(false);
49
- expect(isContentEqual({
50
- row: {
51
- id: 1
52
- }
53
- }, {
54
- row: {
55
- id: 1
56
- }
57
- })).toBe(false);
58
- });
59
- it("rejects mismatched array vs object", function () {
60
- expect(isContentEqual([], {})).toBe(false);
61
- expect(isContentEqual([1], {
62
- 0: 1
63
- })).toBe(false);
64
- });
65
- it("handles a typical zero singular-query refresh \u2014 same row content", function () {
66
- var prev = {
67
- id: "s1",
68
- name: "warden",
69
- level: 1,
70
- hp: 60,
71
- maxHp: 60
72
- };
73
- var next = {
74
- id: "s1",
75
- name: "warden",
76
- level: 1,
77
- hp: 60,
78
- maxHp: 60
79
- };
80
- expect(isContentEqual(prev, next)).toBe(true);
81
- });
82
- it("detects a real refresh \u2014 one field changed", function () {
83
- var prev = {
84
- id: "s1",
85
- hp: 60
86
- };
87
- var next = {
88
- id: "s1",
89
- hp: 59
90
- };
91
- expect(isContentEqual(prev, next)).toBe(false);
92
- });
93
- it('handles zero info objects ({type: "complete"} vs {type: "unknown"})', function () {
94
- expect(isContentEqual({
95
- type: "complete"
96
- }, {
97
- type: "complete"
98
- })).toBe(true);
99
- expect(isContentEqual({
100
- type: "complete"
101
- }, {
102
- type: "unknown"
103
- })).toBe(false);
104
- });
105
- });
106
- //# sourceMappingURL=useContentStable.test.native.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["describe","expect","it","isContentEqual","toBe","id"],"sources":["../../src/useContentStable.test.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,QAAA,EAAUC,MAAA,EAAQC,EAAA,QAAU;AACrC,SAASC,cAAA,QAAsB;AAE/BH,QAAA,CAAS,kBAAkB,YAAM;EAC/BE,EAAA,CAAG,8BAA8B,YAAM;IACrCD,MAAA,CAAOE,cAAA,CAAe,GAAG,CAAC,CAAC,EAAEC,IAAA,CAAK,IAAI;IACtCH,MAAA,CAAOE,cAAA,CAAe,KAAK,GAAG,CAAC,EAAEC,IAAA,CAAK,IAAI;IAC1CH,MAAA,CAAOE,cAAA,CAAe,MAAM,IAAI,CAAC,EAAEC,IAAA,CAAK,IAAI;IAC5CH,MAAA,CAAOE,cAAA,CAAe,QAAW,MAAS,CAAC,EAAEC,IAAA,CAAK,IAAI;IACtDH,MAAA,CAAOE,cAAA,CAAe,MAAM,IAAI,CAAC,EAAEC,IAAA,CAAK,IAAI;IAC5CH,MAAA,CAAOE,cAAA,CAAe,GAAG,CAAC,CAAC,EAAEC,IAAA,CAAK,KAAK;IACvCH,MAAA,CAAOE,cAAA,CAAe,KAAK,GAAG,CAAC,EAAEC,IAAA,CAAK,KAAK;IAC3CH,MAAA,CAAOE,cAAA,CAAe,MAAM,MAAS,CAAC,EAAEC,IAAA,CAAK,KAAK;EACpD,CAAC;EAEDF,EAAA,CAAG,mDAAmD,YAAM;IAC1DD,MAAA,CAAOE,cAAA,CAAe,EAAC,EAAG,EAAE,CAAC,EAAEC,IAAA,CAAK,IAAI;IACxCH,MAAA,CAAOE,cAAA,CAAe,CACtB,GACA,GAEA,EAEA,GACA,GACD,GAEE,EACD,GAAAC,IAAO;IACPH,MAAA,CAAOE,cAAA,CAAe,CACtB,GACA,GAEA,EACD,GAEE,GACD,EACA,GAAAC,IAAO;IACRH,MAAA,CAAAE,cAAA,EAEE,GAID,GACA,EACA,GACD,GAEE,GACD,EACA,GAAAC,IAAM,MAAO,CAAE;IACfH,MAAA,CAAOE,cAAA,CAAe,CACvB;MAEEE,EAAA;IACD,EACA,GACD;MACFA,EAAA","ignoreList":[]}
@@ -1,61 +0,0 @@
1
- import { describe, expect, it } from 'vitest'
2
- import { isContentEqual } from './useContentStable'
3
-
4
- describe('isContentEqual', () => {
5
- it('treats primitives by value', () => {
6
- expect(isContentEqual(1, 1)).toBe(true)
7
- expect(isContentEqual('a', 'a')).toBe(true)
8
- expect(isContentEqual(true, true)).toBe(true)
9
- expect(isContentEqual(undefined, undefined)).toBe(true)
10
- expect(isContentEqual(null, null)).toBe(true)
11
- expect(isContentEqual(1, 2)).toBe(false)
12
- expect(isContentEqual('a', 'b')).toBe(false)
13
- expect(isContentEqual(null, undefined)).toBe(false)
14
- })
15
-
16
- it('treats arrays by length + per-element strict-eq', () => {
17
- expect(isContentEqual([], [])).toBe(true)
18
- expect(isContentEqual([1, 2, 3], [1, 2, 3])).toBe(true)
19
- expect(isContentEqual([1, 2, 3], [1, 2])).toBe(false)
20
- expect(isContentEqual([1, 2, 3], [1, 2, 4])).toBe(false)
21
- // distinct objects with same fields → strict-eq fails per element
22
- expect(isContentEqual([{ id: 1 }], [{ id: 1 }])).toBe(false)
23
- // same object ref shared → strict-eq holds
24
- const row = { id: 1 }
25
- expect(isContentEqual([row], [row])).toBe(true)
26
- })
27
-
28
- it('treats objects by same keys + per-value strict-eq', () => {
29
- expect(isContentEqual({}, {})).toBe(true)
30
- expect(isContentEqual({ a: 1, b: 2 }, { a: 1, b: 2 })).toBe(true)
31
- expect(isContentEqual({ a: 1 }, { a: 1, b: 2 })).toBe(false)
32
- expect(isContentEqual({ a: 1 }, { a: 2 })).toBe(false)
33
- // distinct nested objects → strict-eq fails on the nested value
34
- expect(isContentEqual({ row: { id: 1 } }, { row: { id: 1 } })).toBe(false)
35
- })
36
-
37
- it('rejects mismatched array vs object', () => {
38
- expect(isContentEqual([], {})).toBe(false)
39
- expect(isContentEqual([1], { 0: 1 })).toBe(false)
40
- })
41
-
42
- it('handles a typical zero singular-query refresh — same row content', () => {
43
- // simulating zero's deepClone: the row is a fresh object but every field
44
- // matches the previous snapshot. shallow strict-eq sees fresh nested but
45
- // top-level keys are primitives → equal.
46
- const prev = { id: 's1', name: 'warden', level: 1, hp: 60, maxHp: 60 }
47
- const next = { id: 's1', name: 'warden', level: 1, hp: 60, maxHp: 60 }
48
- expect(isContentEqual(prev, next)).toBe(true)
49
- })
50
-
51
- it('detects a real refresh — one field changed', () => {
52
- const prev = { id: 's1', hp: 60 }
53
- const next = { id: 's1', hp: 59 }
54
- expect(isContentEqual(prev, next)).toBe(false)
55
- })
56
-
57
- it('handles zero info objects ({type: "complete"} vs {type: "unknown"})', () => {
58
- expect(isContentEqual({ type: 'complete' }, { type: 'complete' })).toBe(true)
59
- expect(isContentEqual({ type: 'complete' }, { type: 'unknown' })).toBe(false)
60
- })
61
- })