tinybase 7.3.1 → 7.3.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.
Files changed (142) hide show
  1. package/@types/mergeable-store/with-schemas/index.d.ts +1 -1
  2. package/min/omni/index.js +1 -1
  3. package/min/omni/index.js.gz +0 -0
  4. package/min/omni/with-schemas/index.js +1 -1
  5. package/min/omni/with-schemas/index.js.gz +0 -0
  6. package/min/persisters/index.js +1 -1
  7. package/min/persisters/index.js.gz +0 -0
  8. package/min/persisters/persister-browser/index.js +1 -1
  9. package/min/persisters/persister-browser/index.js.gz +0 -0
  10. package/min/persisters/persister-browser/with-schemas/index.js +1 -1
  11. package/min/persisters/persister-browser/with-schemas/index.js.gz +0 -0
  12. package/min/persisters/persister-cr-sqlite-wasm/index.js +1 -1
  13. package/min/persisters/persister-cr-sqlite-wasm/index.js.gz +0 -0
  14. package/min/persisters/persister-cr-sqlite-wasm/with-schemas/index.js +1 -1
  15. package/min/persisters/persister-cr-sqlite-wasm/with-schemas/index.js.gz +0 -0
  16. package/min/persisters/persister-durable-object-sql-storage/index.js +1 -1
  17. package/min/persisters/persister-durable-object-sql-storage/index.js.gz +0 -0
  18. package/min/persisters/persister-durable-object-sql-storage/with-schemas/index.js +1 -1
  19. package/min/persisters/persister-durable-object-sql-storage/with-schemas/index.js.gz +0 -0
  20. package/min/persisters/persister-durable-object-storage/index.js +1 -1
  21. package/min/persisters/persister-durable-object-storage/index.js.gz +0 -0
  22. package/min/persisters/persister-durable-object-storage/with-schemas/index.js +1 -1
  23. package/min/persisters/persister-durable-object-storage/with-schemas/index.js.gz +0 -0
  24. package/min/persisters/persister-electric-sql/index.js +1 -1
  25. package/min/persisters/persister-electric-sql/index.js.gz +0 -0
  26. package/min/persisters/persister-electric-sql/with-schemas/index.js +1 -1
  27. package/min/persisters/persister-electric-sql/with-schemas/index.js.gz +0 -0
  28. package/min/persisters/persister-expo-sqlite/index.js +1 -1
  29. package/min/persisters/persister-expo-sqlite/index.js.gz +0 -0
  30. package/min/persisters/persister-expo-sqlite/with-schemas/index.js +1 -1
  31. package/min/persisters/persister-expo-sqlite/with-schemas/index.js.gz +0 -0
  32. package/min/persisters/persister-file/index.js +1 -1
  33. package/min/persisters/persister-file/index.js.gz +0 -0
  34. package/min/persisters/persister-file/with-schemas/index.js +1 -1
  35. package/min/persisters/persister-file/with-schemas/index.js.gz +0 -0
  36. package/min/persisters/persister-libsql/index.js +1 -1
  37. package/min/persisters/persister-libsql/index.js.gz +0 -0
  38. package/min/persisters/persister-libsql/with-schemas/index.js +1 -1
  39. package/min/persisters/persister-libsql/with-schemas/index.js.gz +0 -0
  40. package/min/persisters/persister-partykit-client/index.js +1 -1
  41. package/min/persisters/persister-partykit-client/index.js.gz +0 -0
  42. package/min/persisters/persister-partykit-client/with-schemas/index.js +1 -1
  43. package/min/persisters/persister-partykit-client/with-schemas/index.js.gz +0 -0
  44. package/min/persisters/persister-partykit-server/index.js +1 -1
  45. package/min/persisters/persister-partykit-server/index.js.gz +0 -0
  46. package/min/persisters/persister-partykit-server/with-schemas/index.js +1 -1
  47. package/min/persisters/persister-partykit-server/with-schemas/index.js.gz +0 -0
  48. package/min/persisters/persister-pglite/index.js +1 -1
  49. package/min/persisters/persister-pglite/index.js.gz +0 -0
  50. package/min/persisters/persister-pglite/with-schemas/index.js +1 -1
  51. package/min/persisters/persister-pglite/with-schemas/index.js.gz +0 -0
  52. package/min/persisters/persister-postgres/index.js +1 -1
  53. package/min/persisters/persister-postgres/index.js.gz +0 -0
  54. package/min/persisters/persister-postgres/with-schemas/index.js +1 -1
  55. package/min/persisters/persister-postgres/with-schemas/index.js.gz +0 -0
  56. package/min/persisters/persister-powersync/index.js +1 -1
  57. package/min/persisters/persister-powersync/index.js.gz +0 -0
  58. package/min/persisters/persister-powersync/with-schemas/index.js +1 -1
  59. package/min/persisters/persister-powersync/with-schemas/index.js.gz +0 -0
  60. package/min/persisters/persister-react-native-sqlite/index.js +1 -1
  61. package/min/persisters/persister-react-native-sqlite/index.js.gz +0 -0
  62. package/min/persisters/persister-react-native-sqlite/with-schemas/index.js +1 -1
  63. package/min/persisters/persister-react-native-sqlite/with-schemas/index.js.gz +0 -0
  64. package/min/persisters/persister-sqlite-bun/index.js +1 -1
  65. package/min/persisters/persister-sqlite-bun/index.js.gz +0 -0
  66. package/min/persisters/persister-sqlite-bun/with-schemas/index.js +1 -1
  67. package/min/persisters/persister-sqlite-bun/with-schemas/index.js.gz +0 -0
  68. package/min/persisters/persister-sqlite-wasm/index.js +1 -1
  69. package/min/persisters/persister-sqlite-wasm/index.js.gz +0 -0
  70. package/min/persisters/persister-sqlite-wasm/with-schemas/index.js +1 -1
  71. package/min/persisters/persister-sqlite-wasm/with-schemas/index.js.gz +0 -0
  72. package/min/persisters/persister-sqlite3/index.js +1 -1
  73. package/min/persisters/persister-sqlite3/index.js.gz +0 -0
  74. package/min/persisters/persister-sqlite3/with-schemas/index.js +1 -1
  75. package/min/persisters/persister-sqlite3/with-schemas/index.js.gz +0 -0
  76. package/min/persisters/with-schemas/index.js +1 -1
  77. package/min/persisters/with-schemas/index.js.gz +0 -0
  78. package/min/synchronizers/synchronizer-ws-client/index.js +1 -1
  79. package/min/synchronizers/synchronizer-ws-client/index.js.gz +0 -0
  80. package/min/synchronizers/synchronizer-ws-client/with-schemas/index.js +1 -1
  81. package/min/synchronizers/synchronizer-ws-client/with-schemas/index.js.gz +0 -0
  82. package/min/synchronizers/synchronizer-ws-server/index.js +1 -1
  83. package/min/synchronizers/synchronizer-ws-server/index.js.gz +0 -0
  84. package/min/synchronizers/synchronizer-ws-server/with-schemas/index.js +1 -1
  85. package/min/synchronizers/synchronizer-ws-server/with-schemas/index.js.gz +0 -0
  86. package/min/synchronizers/synchronizer-ws-server-durable-object/index.js +1 -1
  87. package/min/synchronizers/synchronizer-ws-server-durable-object/index.js.gz +0 -0
  88. package/min/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js +1 -1
  89. package/min/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js.gz +0 -0
  90. package/min/ui-react-inspector/index.js +1 -1
  91. package/min/ui-react-inspector/index.js.gz +0 -0
  92. package/min/ui-react-inspector/with-schemas/index.js +1 -1
  93. package/min/ui-react-inspector/with-schemas/index.js.gz +0 -0
  94. package/omni/index.js +21 -9
  95. package/omni/with-schemas/index.js +21 -9
  96. package/package.json +18 -18
  97. package/persisters/index.js +10 -1
  98. package/persisters/persister-browser/index.js +17 -1
  99. package/persisters/persister-browser/with-schemas/index.js +17 -1
  100. package/persisters/persister-cr-sqlite-wasm/index.js +10 -1
  101. package/persisters/persister-cr-sqlite-wasm/with-schemas/index.js +10 -1
  102. package/persisters/persister-durable-object-sql-storage/index.js +10 -1
  103. package/persisters/persister-durable-object-sql-storage/with-schemas/index.js +10 -1
  104. package/persisters/persister-durable-object-storage/index.js +5 -6
  105. package/persisters/persister-durable-object-storage/with-schemas/index.js +5 -6
  106. package/persisters/persister-electric-sql/index.js +10 -1
  107. package/persisters/persister-electric-sql/with-schemas/index.js +10 -1
  108. package/persisters/persister-expo-sqlite/index.js +10 -1
  109. package/persisters/persister-expo-sqlite/with-schemas/index.js +10 -1
  110. package/persisters/persister-file/index.js +17 -1
  111. package/persisters/persister-file/with-schemas/index.js +17 -1
  112. package/persisters/persister-libsql/index.js +10 -1
  113. package/persisters/persister-libsql/with-schemas/index.js +10 -1
  114. package/persisters/persister-partykit-client/index.js +27 -2
  115. package/persisters/persister-partykit-client/with-schemas/index.js +27 -2
  116. package/persisters/persister-partykit-server/index.js +37 -2
  117. package/persisters/persister-partykit-server/with-schemas/index.js +37 -2
  118. package/persisters/persister-pglite/index.js +10 -1
  119. package/persisters/persister-pglite/with-schemas/index.js +10 -1
  120. package/persisters/persister-postgres/index.js +10 -1
  121. package/persisters/persister-postgres/with-schemas/index.js +10 -1
  122. package/persisters/persister-powersync/index.js +10 -1
  123. package/persisters/persister-powersync/with-schemas/index.js +10 -1
  124. package/persisters/persister-react-native-sqlite/index.js +10 -1
  125. package/persisters/persister-react-native-sqlite/with-schemas/index.js +10 -1
  126. package/persisters/persister-sqlite-bun/index.js +10 -1
  127. package/persisters/persister-sqlite-bun/with-schemas/index.js +10 -1
  128. package/persisters/persister-sqlite-wasm/index.js +10 -1
  129. package/persisters/persister-sqlite-wasm/with-schemas/index.js +10 -1
  130. package/persisters/persister-sqlite3/index.js +10 -1
  131. package/persisters/persister-sqlite3/with-schemas/index.js +10 -1
  132. package/persisters/with-schemas/index.js +10 -1
  133. package/readme.md +10 -2
  134. package/releases.md +1 -1
  135. package/synchronizers/synchronizer-ws-client/index.js +14 -1
  136. package/synchronizers/synchronizer-ws-client/with-schemas/index.js +14 -1
  137. package/synchronizers/synchronizer-ws-server/index.js +14 -1
  138. package/synchronizers/synchronizer-ws-server/with-schemas/index.js +14 -1
  139. package/synchronizers/synchronizer-ws-server-durable-object/index.js +14 -1
  140. package/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js +14 -1
  141. package/ui-react-inspector/index.js +10 -1
  142. package/ui-react-inspector/with-schemas/index.js +10 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tinybase",
3
- "version": "7.3.1",
3
+ "version": "7.3.3",
4
4
  "author": "jamesgpearce",
5
5
  "repository": "github:tinyplex/tinybase",
6
6
  "license": "MIT",
@@ -22,31 +22,31 @@
22
22
  "sideEffects": false,
23
23
  "peerDependencies": {
24
24
  "@automerge/automerge-repo": "^2.5.1",
25
- "@cloudflare/workers-types": "^4.20251230.0",
26
- "@electric-sql/pglite": "^0.3.14",
27
- "@libsql/client": "^0.15.15",
28
- "@powersync/common": "^1.44.0",
29
- "@sinclair/typebox": "^0.34.45",
30
- "@sqlite.org/sqlite-wasm": "^3.50.4-build1",
25
+ "@cloudflare/workers-types": "^4.20260210.0",
26
+ "@electric-sql/pglite": "^0.3.15",
27
+ "@libsql/client": "^0.17.0",
28
+ "@powersync/common": "^1.46.0",
29
+ "@sinclair/typebox": "^0.34.48",
30
+ "@sqlite.org/sqlite-wasm": "^3.51.2-build6",
31
31
  "@vlcn.io/crsqlite-wasm": "^0.16.0",
32
32
  "arktype": "^2.1.29",
33
- "bun": "^1.3.5",
34
- "effect": "^3.19.13",
33
+ "bun": "^1.3.9",
34
+ "effect": "^3.19.16",
35
35
  "electric-sql": "^0.12.1",
36
- "expo": "^54.0.10",
36
+ "expo": "^54.0.33",
37
37
  "expo-sqlite": "^16.0.10",
38
38
  "partykit": "^0.0.115",
39
- "partysocket": "^1.1.10",
40
- "postgres": "^3.4.7",
41
- "react": "^19.0.0",
42
- "react-dom": "^19.0.0",
43
- "react-native-mmkv": "4.1.0",
39
+ "partysocket": "^1.1.13",
40
+ "postgres": "^3.4.8",
41
+ "react": "^19.2.4",
42
+ "react-dom": "^19.2.4",
43
+ "react-native-mmkv": "4.1.2",
44
44
  "react-native-sqlite-storage": "^6.0.1",
45
45
  "sqlite3": "^5.1.7",
46
46
  "valibot": "^1.2.0",
47
- "ws": "^8.18.3",
48
- "yjs": "^13.6.28",
49
- "zod": "^4.2.1"
47
+ "ws": "^8.19.0",
48
+ "yjs": "^13.6.29",
49
+ "zod": "^4.3.6"
50
50
  },
51
51
  "peerDependenciesMeta": {
52
52
  "@automerge/automerge-repo": {
@@ -479,7 +479,16 @@ const jsonParse = JSON.parse;
479
479
  const jsonStringWithUndefined = (obj) =>
480
480
  jsonString(obj, (_key, value) => (isUndefined(value) ? UNDEFINED : value));
481
481
  const jsonParseWithUndefined = (str) =>
482
- jsonParse(str, (_key, value) => (value === UNDEFINED ? void 0 : value));
482
+ // JSON.parse reviver removes properties with undefined values
483
+ replaceUndefinedString(jsonParse(str));
484
+ const replaceUndefinedString = (obj) =>
485
+ obj === UNDEFINED
486
+ ? void 0
487
+ : isArray(obj)
488
+ ? arrayMap(obj, replaceUndefinedString)
489
+ : isObject(obj)
490
+ ? objMap(obj, replaceUndefinedString)
491
+ : obj;
483
492
 
484
493
  const textEncoder = /* @__PURE__ */ new GLOBAL.TextEncoder();
485
494
  const getHash = (string) => {
@@ -26,12 +26,14 @@ const tryCatch = async (action, then1, then2) => {
26
26
  };
27
27
 
28
28
  const arrayForEach = (array, cb) => array.forEach(cb);
29
+ const arrayMap = (array, cb) => array.map(cb);
29
30
  const arrayClear = (array, to) => array.splice(0, to);
30
31
  const arrayPush = (array, ...values) => array.push(...values);
31
32
  const arrayShift = (array) => array.shift();
32
33
 
33
34
  const object = Object;
34
35
  const getPrototypeOf = (obj) => object.getPrototypeOf(obj);
36
+ const objEntries = object.entries;
35
37
  const isObject = (obj) =>
36
38
  !isNullish(obj) &&
37
39
  ifNotNullish(
@@ -45,6 +47,11 @@ const isObject = (obj) =>
45
47
  );
46
48
  const objIds = object.keys;
47
49
  const objFreeze = object.freeze;
50
+ const objNew = (entries = []) => object.fromEntries(entries);
51
+ const objToArray = (obj, cb) =>
52
+ arrayMap(objEntries(obj), ([id, value]) => cb(value, id));
53
+ const objMap = (obj, cb) =>
54
+ objNew(objToArray(obj, (value, id) => [id, cb(value, id)]));
48
55
  const objSize = (obj) => size(objIds(obj));
49
56
  const objIsEmpty = (obj) => isObject(obj) && objSize(obj) == 0;
50
57
 
@@ -53,7 +60,16 @@ const jsonParse = JSON.parse;
53
60
  const jsonStringWithUndefined = (obj) =>
54
61
  jsonString(obj, (_key, value) => (isUndefined(value) ? UNDEFINED : value));
55
62
  const jsonParseWithUndefined = (str) =>
56
- jsonParse(str, (_key, value) => (value === UNDEFINED ? void 0 : value));
63
+ // JSON.parse reviver removes properties with undefined values
64
+ replaceUndefinedString(jsonParse(str));
65
+ const replaceUndefinedString = (obj) =>
66
+ obj === UNDEFINED
67
+ ? void 0
68
+ : isArray(obj)
69
+ ? arrayMap(obj, replaceUndefinedString)
70
+ : isObject(obj)
71
+ ? objMap(obj, replaceUndefinedString)
72
+ : obj;
57
73
 
58
74
  const collSize = (coll) => coll?.size ?? 0;
59
75
  const collHas = (coll, keyOrValue) => coll?.has(keyOrValue) ?? false;
@@ -26,12 +26,14 @@ const tryCatch = async (action, then1, then2) => {
26
26
  };
27
27
 
28
28
  const arrayForEach = (array, cb) => array.forEach(cb);
29
+ const arrayMap = (array, cb) => array.map(cb);
29
30
  const arrayClear = (array, to) => array.splice(0, to);
30
31
  const arrayPush = (array, ...values) => array.push(...values);
31
32
  const arrayShift = (array) => array.shift();
32
33
 
33
34
  const object = Object;
34
35
  const getPrototypeOf = (obj) => object.getPrototypeOf(obj);
36
+ const objEntries = object.entries;
35
37
  const isObject = (obj) =>
36
38
  !isNullish(obj) &&
37
39
  ifNotNullish(
@@ -45,6 +47,11 @@ const isObject = (obj) =>
45
47
  );
46
48
  const objIds = object.keys;
47
49
  const objFreeze = object.freeze;
50
+ const objNew = (entries = []) => object.fromEntries(entries);
51
+ const objToArray = (obj, cb) =>
52
+ arrayMap(objEntries(obj), ([id, value]) => cb(value, id));
53
+ const objMap = (obj, cb) =>
54
+ objNew(objToArray(obj, (value, id) => [id, cb(value, id)]));
48
55
  const objSize = (obj) => size(objIds(obj));
49
56
  const objIsEmpty = (obj) => isObject(obj) && objSize(obj) == 0;
50
57
 
@@ -53,7 +60,16 @@ const jsonParse = JSON.parse;
53
60
  const jsonStringWithUndefined = (obj) =>
54
61
  jsonString(obj, (_key, value) => (isUndefined(value) ? UNDEFINED : value));
55
62
  const jsonParseWithUndefined = (str) =>
56
- jsonParse(str, (_key, value) => (value === UNDEFINED ? void 0 : value));
63
+ // JSON.parse reviver removes properties with undefined values
64
+ replaceUndefinedString(jsonParse(str));
65
+ const replaceUndefinedString = (obj) =>
66
+ obj === UNDEFINED
67
+ ? void 0
68
+ : isArray(obj)
69
+ ? arrayMap(obj, replaceUndefinedString)
70
+ : isObject(obj)
71
+ ? objMap(obj, replaceUndefinedString)
72
+ : obj;
57
73
 
58
74
  const collSize = (coll) => coll?.size ?? 0;
59
75
  const collHas = (coll, keyOrValue) => coll?.has(keyOrValue) ?? false;
@@ -304,7 +304,16 @@ const jsonParse = JSON.parse;
304
304
  const jsonStringWithUndefined = (obj) =>
305
305
  jsonString(obj, (_key, value) => (isUndefined(value) ? UNDEFINED : value));
306
306
  const jsonParseWithUndefined = (str) =>
307
- jsonParse(str, (_key, value) => (value === UNDEFINED ? void 0 : value));
307
+ // JSON.parse reviver removes properties with undefined values
308
+ replaceUndefinedString(jsonParse(str));
309
+ const replaceUndefinedString = (obj) =>
310
+ obj === UNDEFINED
311
+ ? void 0
312
+ : isArray(obj)
313
+ ? arrayMap(obj, replaceUndefinedString)
314
+ : isObject(obj)
315
+ ? objMap(obj, replaceUndefinedString)
316
+ : obj;
308
317
 
309
318
  const INTEGER = /^\d+$/;
310
319
  const getPoolFunctions = () => {
@@ -304,7 +304,16 @@ const jsonParse = JSON.parse;
304
304
  const jsonStringWithUndefined = (obj) =>
305
305
  jsonString(obj, (_key, value) => (isUndefined(value) ? UNDEFINED : value));
306
306
  const jsonParseWithUndefined = (str) =>
307
- jsonParse(str, (_key, value) => (value === UNDEFINED ? void 0 : value));
307
+ // JSON.parse reviver removes properties with undefined values
308
+ replaceUndefinedString(jsonParse(str));
309
+ const replaceUndefinedString = (obj) =>
310
+ obj === UNDEFINED
311
+ ? void 0
312
+ : isArray(obj)
313
+ ? arrayMap(obj, replaceUndefinedString)
314
+ : isObject(obj)
315
+ ? objMap(obj, replaceUndefinedString)
316
+ : obj;
308
317
 
309
318
  const INTEGER = /^\d+$/;
310
319
  const getPoolFunctions = () => {
@@ -99,7 +99,16 @@ const jsonParse = JSON.parse;
99
99
  const jsonStringWithUndefined = (obj) =>
100
100
  jsonString(obj, (_key, value) => (isUndefined(value) ? UNDEFINED : value));
101
101
  const jsonParseWithUndefined = (str) =>
102
- jsonParse(str, (_key, value) => (value === UNDEFINED ? void 0 : value));
102
+ // JSON.parse reviver removes properties with undefined values
103
+ replaceUndefinedString(jsonParse(str));
104
+ const replaceUndefinedString = (obj) =>
105
+ obj === UNDEFINED
106
+ ? void 0
107
+ : isArray(obj)
108
+ ? arrayMap(obj, replaceUndefinedString)
109
+ : isObject(obj)
110
+ ? objMap(obj, replaceUndefinedString)
111
+ : obj;
103
112
 
104
113
  const collSize = (coll) => coll?.size ?? 0;
105
114
  const collHas = (coll, keyOrValue) => coll?.has(keyOrValue) ?? false;
@@ -99,7 +99,16 @@ const jsonParse = JSON.parse;
99
99
  const jsonStringWithUndefined = (obj) =>
100
100
  jsonString(obj, (_key, value) => (isUndefined(value) ? UNDEFINED : value));
101
101
  const jsonParseWithUndefined = (str) =>
102
- jsonParse(str, (_key, value) => (value === UNDEFINED ? void 0 : value));
102
+ // JSON.parse reviver removes properties with undefined values
103
+ replaceUndefinedString(jsonParse(str));
104
+ const replaceUndefinedString = (obj) =>
105
+ obj === UNDEFINED
106
+ ? void 0
107
+ : isArray(obj)
108
+ ? arrayMap(obj, replaceUndefinedString)
109
+ : isObject(obj)
110
+ ? objMap(obj, replaceUndefinedString)
111
+ : obj;
103
112
 
104
113
  const collSize = (coll) => coll?.size ?? 0;
105
114
  const collHas = (coll, keyOrValue) => coll?.has(keyOrValue) ?? false;
@@ -468,12 +468,9 @@ const createDurableObjectStoragePersister = (
468
468
  storagePrefix + type + slice(jsonStringWithUndefined(ids), 1, -1);
469
469
  const deconstructKey = (key) => {
470
470
  if (strStartsWith(key, storagePrefix)) {
471
- const type = slice(key, storagePrefix.length, 1);
471
+ const type = slice(key, size(storagePrefix), size(storagePrefix) + 1);
472
472
  return type == T || type == V
473
- ? [
474
- type,
475
- ...JSON.parse('[' + slice(key, storagePrefix.length + 1) + ']'),
476
- ]
473
+ ? [type, ...JSON.parse('[' + slice(key, size(storagePrefix) + 1) + ']')]
477
474
  : void 0;
478
475
  }
479
476
  };
@@ -522,7 +519,9 @@ const createDurableObjectStoragePersister = (
522
519
  : 0,
523
520
  ),
524
521
  );
525
- return [tables, values];
522
+ return objIsEmpty(tables[0]) && objIsEmpty(values[0])
523
+ ? void 0
524
+ : [tables, values];
526
525
  };
527
526
  const setPersisted = async (
528
527
  getContent,
@@ -468,12 +468,9 @@ const createDurableObjectStoragePersister = (
468
468
  storagePrefix + type + slice(jsonStringWithUndefined(ids), 1, -1);
469
469
  const deconstructKey = (key) => {
470
470
  if (strStartsWith(key, storagePrefix)) {
471
- const type = slice(key, storagePrefix.length, 1);
471
+ const type = slice(key, size(storagePrefix), size(storagePrefix) + 1);
472
472
  return type == T || type == V
473
- ? [
474
- type,
475
- ...JSON.parse('[' + slice(key, storagePrefix.length + 1) + ']'),
476
- ]
473
+ ? [type, ...JSON.parse('[' + slice(key, size(storagePrefix) + 1) + ']')]
477
474
  : void 0;
478
475
  }
479
476
  };
@@ -522,7 +519,9 @@ const createDurableObjectStoragePersister = (
522
519
  : 0,
523
520
  ),
524
521
  );
525
- return [tables, values];
522
+ return objIsEmpty(tables[0]) && objIsEmpty(values[0])
523
+ ? void 0
524
+ : [tables, values];
526
525
  };
527
526
  const setPersisted = async (
528
527
  getContent,
@@ -304,7 +304,16 @@ const jsonParse = JSON.parse;
304
304
  const jsonStringWithUndefined = (obj) =>
305
305
  jsonString(obj, (_key, value) => (isUndefined(value) ? UNDEFINED : value));
306
306
  const jsonParseWithUndefined = (str) =>
307
- jsonParse(str, (_key, value) => (value === UNDEFINED ? void 0 : value));
307
+ // JSON.parse reviver removes properties with undefined values
308
+ replaceUndefinedString(jsonParse(str));
309
+ const replaceUndefinedString = (obj) =>
310
+ obj === UNDEFINED
311
+ ? void 0
312
+ : isArray(obj)
313
+ ? arrayMap(obj, replaceUndefinedString)
314
+ : isObject(obj)
315
+ ? objMap(obj, replaceUndefinedString)
316
+ : obj;
308
317
 
309
318
  const INTEGER = /^\d+$/;
310
319
  const getPoolFunctions = () => {
@@ -304,7 +304,16 @@ const jsonParse = JSON.parse;
304
304
  const jsonStringWithUndefined = (obj) =>
305
305
  jsonString(obj, (_key, value) => (isUndefined(value) ? UNDEFINED : value));
306
306
  const jsonParseWithUndefined = (str) =>
307
- jsonParse(str, (_key, value) => (value === UNDEFINED ? void 0 : value));
307
+ // JSON.parse reviver removes properties with undefined values
308
+ replaceUndefinedString(jsonParse(str));
309
+ const replaceUndefinedString = (obj) =>
310
+ obj === UNDEFINED
311
+ ? void 0
312
+ : isArray(obj)
313
+ ? arrayMap(obj, replaceUndefinedString)
314
+ : isObject(obj)
315
+ ? objMap(obj, replaceUndefinedString)
316
+ : obj;
308
317
 
309
318
  const INTEGER = /^\d+$/;
310
319
  const getPoolFunctions = () => {
@@ -306,7 +306,16 @@ const jsonParse = JSON.parse;
306
306
  const jsonStringWithUndefined = (obj) =>
307
307
  jsonString(obj, (_key, value) => (isUndefined(value) ? UNDEFINED : value));
308
308
  const jsonParseWithUndefined = (str) =>
309
- jsonParse(str, (_key, value) => (value === UNDEFINED ? void 0 : value));
309
+ // JSON.parse reviver removes properties with undefined values
310
+ replaceUndefinedString(jsonParse(str));
311
+ const replaceUndefinedString = (obj) =>
312
+ obj === UNDEFINED
313
+ ? void 0
314
+ : isArray(obj)
315
+ ? arrayMap(obj, replaceUndefinedString)
316
+ : isObject(obj)
317
+ ? objMap(obj, replaceUndefinedString)
318
+ : obj;
310
319
 
311
320
  const INTEGER = /^\d+$/;
312
321
  const getPoolFunctions = () => {
@@ -306,7 +306,16 @@ const jsonParse = JSON.parse;
306
306
  const jsonStringWithUndefined = (obj) =>
307
307
  jsonString(obj, (_key, value) => (isUndefined(value) ? UNDEFINED : value));
308
308
  const jsonParseWithUndefined = (str) =>
309
- jsonParse(str, (_key, value) => (value === UNDEFINED ? void 0 : value));
309
+ // JSON.parse reviver removes properties with undefined values
310
+ replaceUndefinedString(jsonParse(str));
311
+ const replaceUndefinedString = (obj) =>
312
+ obj === UNDEFINED
313
+ ? void 0
314
+ : isArray(obj)
315
+ ? arrayMap(obj, replaceUndefinedString)
316
+ : isObject(obj)
317
+ ? objMap(obj, replaceUndefinedString)
318
+ : obj;
310
319
 
311
320
  const INTEGER = /^\d+$/;
312
321
  const getPoolFunctions = () => {
@@ -28,12 +28,14 @@ const tryCatch = async (action, then1, then2) => {
28
28
  };
29
29
 
30
30
  const arrayForEach = (array, cb) => array.forEach(cb);
31
+ const arrayMap = (array, cb) => array.map(cb);
31
32
  const arrayClear = (array, to) => array.splice(0, to);
32
33
  const arrayPush = (array, ...values) => array.push(...values);
33
34
  const arrayShift = (array) => array.shift();
34
35
 
35
36
  const object = Object;
36
37
  const getPrototypeOf = (obj) => object.getPrototypeOf(obj);
38
+ const objEntries = object.entries;
37
39
  const isObject = (obj) =>
38
40
  !isNullish(obj) &&
39
41
  ifNotNullish(
@@ -47,6 +49,11 @@ const isObject = (obj) =>
47
49
  );
48
50
  const objIds = object.keys;
49
51
  const objFreeze = object.freeze;
52
+ const objNew = (entries = []) => object.fromEntries(entries);
53
+ const objToArray = (obj, cb) =>
54
+ arrayMap(objEntries(obj), ([id, value]) => cb(value, id));
55
+ const objMap = (obj, cb) =>
56
+ objNew(objToArray(obj, (value, id) => [id, cb(value, id)]));
50
57
  const objSize = (obj) => size(objIds(obj));
51
58
  const objIsEmpty = (obj) => isObject(obj) && objSize(obj) == 0;
52
59
 
@@ -55,7 +62,16 @@ const jsonParse = JSON.parse;
55
62
  const jsonStringWithUndefined = (obj) =>
56
63
  jsonString(obj, (_key, value) => (isUndefined(value) ? UNDEFINED : value));
57
64
  const jsonParseWithUndefined = (str) =>
58
- jsonParse(str, (_key, value) => (value === UNDEFINED ? void 0 : value));
65
+ // JSON.parse reviver removes properties with undefined values
66
+ replaceUndefinedString(jsonParse(str));
67
+ const replaceUndefinedString = (obj) =>
68
+ obj === UNDEFINED
69
+ ? void 0
70
+ : isArray(obj)
71
+ ? arrayMap(obj, replaceUndefinedString)
72
+ : isObject(obj)
73
+ ? objMap(obj, replaceUndefinedString)
74
+ : obj;
59
75
 
60
76
  const collSize = (coll) => coll?.size ?? 0;
61
77
  const collHas = (coll, keyOrValue) => coll?.has(keyOrValue) ?? false;
@@ -28,12 +28,14 @@ const tryCatch = async (action, then1, then2) => {
28
28
  };
29
29
 
30
30
  const arrayForEach = (array, cb) => array.forEach(cb);
31
+ const arrayMap = (array, cb) => array.map(cb);
31
32
  const arrayClear = (array, to) => array.splice(0, to);
32
33
  const arrayPush = (array, ...values) => array.push(...values);
33
34
  const arrayShift = (array) => array.shift();
34
35
 
35
36
  const object = Object;
36
37
  const getPrototypeOf = (obj) => object.getPrototypeOf(obj);
38
+ const objEntries = object.entries;
37
39
  const isObject = (obj) =>
38
40
  !isNullish(obj) &&
39
41
  ifNotNullish(
@@ -47,6 +49,11 @@ const isObject = (obj) =>
47
49
  );
48
50
  const objIds = object.keys;
49
51
  const objFreeze = object.freeze;
52
+ const objNew = (entries = []) => object.fromEntries(entries);
53
+ const objToArray = (obj, cb) =>
54
+ arrayMap(objEntries(obj), ([id, value]) => cb(value, id));
55
+ const objMap = (obj, cb) =>
56
+ objNew(objToArray(obj, (value, id) => [id, cb(value, id)]));
50
57
  const objSize = (obj) => size(objIds(obj));
51
58
  const objIsEmpty = (obj) => isObject(obj) && objSize(obj) == 0;
52
59
 
@@ -55,7 +62,16 @@ const jsonParse = JSON.parse;
55
62
  const jsonStringWithUndefined = (obj) =>
56
63
  jsonString(obj, (_key, value) => (isUndefined(value) ? UNDEFINED : value));
57
64
  const jsonParseWithUndefined = (str) =>
58
- jsonParse(str, (_key, value) => (value === UNDEFINED ? void 0 : value));
65
+ // JSON.parse reviver removes properties with undefined values
66
+ replaceUndefinedString(jsonParse(str));
67
+ const replaceUndefinedString = (obj) =>
68
+ obj === UNDEFINED
69
+ ? void 0
70
+ : isArray(obj)
71
+ ? arrayMap(obj, replaceUndefinedString)
72
+ : isObject(obj)
73
+ ? objMap(obj, replaceUndefinedString)
74
+ : obj;
59
75
 
60
76
  const collSize = (coll) => coll?.size ?? 0;
61
77
  const collHas = (coll, keyOrValue) => coll?.has(keyOrValue) ?? false;
@@ -304,7 +304,16 @@ const jsonParse = JSON.parse;
304
304
  const jsonStringWithUndefined = (obj) =>
305
305
  jsonString(obj, (_key, value) => (isUndefined(value) ? UNDEFINED : value));
306
306
  const jsonParseWithUndefined = (str) =>
307
- jsonParse(str, (_key, value) => (value === UNDEFINED ? void 0 : value));
307
+ // JSON.parse reviver removes properties with undefined values
308
+ replaceUndefinedString(jsonParse(str));
309
+ const replaceUndefinedString = (obj) =>
310
+ obj === UNDEFINED
311
+ ? void 0
312
+ : isArray(obj)
313
+ ? arrayMap(obj, replaceUndefinedString)
314
+ : isObject(obj)
315
+ ? objMap(obj, replaceUndefinedString)
316
+ : obj;
308
317
 
309
318
  const INTEGER = /^\d+$/;
310
319
  const getPoolFunctions = () => {
@@ -304,7 +304,16 @@ const jsonParse = JSON.parse;
304
304
  const jsonStringWithUndefined = (obj) =>
305
305
  jsonString(obj, (_key, value) => (isUndefined(value) ? UNDEFINED : value));
306
306
  const jsonParseWithUndefined = (str) =>
307
- jsonParse(str, (_key, value) => (value === UNDEFINED ? void 0 : value));
307
+ // JSON.parse reviver removes properties with undefined values
308
+ replaceUndefinedString(jsonParse(str));
309
+ const replaceUndefinedString = (obj) =>
310
+ obj === UNDEFINED
311
+ ? void 0
312
+ : isArray(obj)
313
+ ? arrayMap(obj, replaceUndefinedString)
314
+ : isObject(obj)
315
+ ? objMap(obj, replaceUndefinedString)
316
+ : obj;
308
317
 
309
318
  const INTEGER = /^\d+$/;
310
319
  const getPoolFunctions = () => {
@@ -2,6 +2,7 @@ const getTypeOf = (thing) => typeof thing;
2
2
  const EMPTY_STRING = '';
3
3
  const STRING = getTypeOf(EMPTY_STRING);
4
4
  const MESSAGE = 'message';
5
+ const UNDEFINED = '\uFFFC';
5
6
  const strStartsWith = (str, prefix) => str.startsWith(prefix);
6
7
 
7
8
  const getIfNotFunction = (predicate) => (value, then, otherwise) =>
@@ -30,12 +31,14 @@ const tryCatch = async (action, then1, then2) => {
30
31
  };
31
32
 
32
33
  const arrayForEach = (array, cb) => array.forEach(cb);
34
+ const arrayMap = (array, cb) => array.map(cb);
33
35
  const arrayClear = (array, to) => array.splice(0, to);
34
36
  const arrayPush = (array, ...values) => array.push(...values);
35
37
  const arrayShift = (array) => array.shift();
36
38
 
37
39
  const object = Object;
38
40
  const getPrototypeOf = (obj) => object.getPrototypeOf(obj);
41
+ const objEntries = object.entries;
39
42
  const isObject = (obj) =>
40
43
  !isNullish(obj) &&
41
44
  ifNotNullish(
@@ -49,6 +52,11 @@ const isObject = (obj) =>
49
52
  );
50
53
  const objIds = object.keys;
51
54
  const objFreeze = object.freeze;
55
+ const objNew = (entries = []) => object.fromEntries(entries);
56
+ const objToArray = (obj, cb) =>
57
+ arrayMap(objEntries(obj), ([id, value]) => cb(value, id));
58
+ const objMap = (obj, cb) =>
59
+ objNew(objToArray(obj, (value, id) => [id, cb(value, id)]));
52
60
  const objSize = (obj) => size(objIds(obj));
53
61
  const objIsEmpty = (obj) => isObject(obj) && objSize(obj) == 0;
54
62
 
@@ -58,6 +66,19 @@ const jsonStringWithMap = (obj) =>
58
66
  jsonString(obj, (_key, value) =>
59
67
  isInstanceOf(value, Map) ? object.fromEntries([...value]) : value,
60
68
  );
69
+ const jsonStringWithUndefined = (obj) =>
70
+ jsonString(obj, (_key, value) => (isUndefined(value) ? UNDEFINED : value));
71
+ const jsonParseWithUndefined = (str) =>
72
+ // JSON.parse reviver removes properties with undefined values
73
+ replaceUndefinedString(jsonParse(str));
74
+ const replaceUndefinedString = (obj) =>
75
+ obj === UNDEFINED
76
+ ? void 0
77
+ : isArray(obj)
78
+ ? arrayMap(obj, replaceUndefinedString)
79
+ : isObject(obj)
80
+ ? objMap(obj, replaceUndefinedString)
81
+ : obj;
61
82
 
62
83
  const collSize = (coll) => coll?.size ?? 0;
63
84
  const collHas = (coll, keyOrValue) => coll?.has(keyOrValue) ?? false;
@@ -435,13 +456,17 @@ const SET_CHANGES = 's';
435
456
  const STORE_PATH = '/store';
436
457
  const PUT = 'PUT';
437
458
  const construct = (prefix, type, payload) =>
438
- prefix + type + (isString(payload) ? payload : jsonStringWithMap(payload));
459
+ prefix +
460
+ type +
461
+ (isString(payload) ? payload : jsonStringWithUndefined(payload));
439
462
  const deconstruct = (prefix, message, stringified) => {
440
463
  const prefixSize = size(prefix);
441
464
  return strStartsWith(message, prefix)
442
465
  ? [
443
466
  message[prefixSize],
444
- (stringified ? jsonParse : String)(slice(message, prefixSize + 1)),
467
+ (stringified ? jsonParseWithUndefined : String)(
468
+ slice(message, prefixSize + 1),
469
+ ),
445
470
  ]
446
471
  : void 0;
447
472
  };
@@ -2,6 +2,7 @@ const getTypeOf = (thing) => typeof thing;
2
2
  const EMPTY_STRING = '';
3
3
  const STRING = getTypeOf(EMPTY_STRING);
4
4
  const MESSAGE = 'message';
5
+ const UNDEFINED = '\uFFFC';
5
6
  const strStartsWith = (str, prefix) => str.startsWith(prefix);
6
7
 
7
8
  const getIfNotFunction = (predicate) => (value, then, otherwise) =>
@@ -30,12 +31,14 @@ const tryCatch = async (action, then1, then2) => {
30
31
  };
31
32
 
32
33
  const arrayForEach = (array, cb) => array.forEach(cb);
34
+ const arrayMap = (array, cb) => array.map(cb);
33
35
  const arrayClear = (array, to) => array.splice(0, to);
34
36
  const arrayPush = (array, ...values) => array.push(...values);
35
37
  const arrayShift = (array) => array.shift();
36
38
 
37
39
  const object = Object;
38
40
  const getPrototypeOf = (obj) => object.getPrototypeOf(obj);
41
+ const objEntries = object.entries;
39
42
  const isObject = (obj) =>
40
43
  !isNullish(obj) &&
41
44
  ifNotNullish(
@@ -49,6 +52,11 @@ const isObject = (obj) =>
49
52
  );
50
53
  const objIds = object.keys;
51
54
  const objFreeze = object.freeze;
55
+ const objNew = (entries = []) => object.fromEntries(entries);
56
+ const objToArray = (obj, cb) =>
57
+ arrayMap(objEntries(obj), ([id, value]) => cb(value, id));
58
+ const objMap = (obj, cb) =>
59
+ objNew(objToArray(obj, (value, id) => [id, cb(value, id)]));
52
60
  const objSize = (obj) => size(objIds(obj));
53
61
  const objIsEmpty = (obj) => isObject(obj) && objSize(obj) == 0;
54
62
 
@@ -58,6 +66,19 @@ const jsonStringWithMap = (obj) =>
58
66
  jsonString(obj, (_key, value) =>
59
67
  isInstanceOf(value, Map) ? object.fromEntries([...value]) : value,
60
68
  );
69
+ const jsonStringWithUndefined = (obj) =>
70
+ jsonString(obj, (_key, value) => (isUndefined(value) ? UNDEFINED : value));
71
+ const jsonParseWithUndefined = (str) =>
72
+ // JSON.parse reviver removes properties with undefined values
73
+ replaceUndefinedString(jsonParse(str));
74
+ const replaceUndefinedString = (obj) =>
75
+ obj === UNDEFINED
76
+ ? void 0
77
+ : isArray(obj)
78
+ ? arrayMap(obj, replaceUndefinedString)
79
+ : isObject(obj)
80
+ ? objMap(obj, replaceUndefinedString)
81
+ : obj;
61
82
 
62
83
  const collSize = (coll) => coll?.size ?? 0;
63
84
  const collHas = (coll, keyOrValue) => coll?.has(keyOrValue) ?? false;
@@ -435,13 +456,17 @@ const SET_CHANGES = 's';
435
456
  const STORE_PATH = '/store';
436
457
  const PUT = 'PUT';
437
458
  const construct = (prefix, type, payload) =>
438
- prefix + type + (isString(payload) ? payload : jsonStringWithMap(payload));
459
+ prefix +
460
+ type +
461
+ (isString(payload) ? payload : jsonStringWithUndefined(payload));
439
462
  const deconstruct = (prefix, message, stringified) => {
440
463
  const prefixSize = size(prefix);
441
464
  return strStartsWith(message, prefix)
442
465
  ? [
443
466
  message[prefixSize],
444
- (stringified ? jsonParse : String)(slice(message, prefixSize + 1)),
467
+ (stringified ? jsonParseWithUndefined : String)(
468
+ slice(message, prefixSize + 1),
469
+ ),
445
470
  ]
446
471
  : void 0;
447
472
  };