@signaldb/core 1.7.1 → 2.0.0-beta.1

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 (93) hide show
  1. package/dist/.vite/manifest.json +138 -82
  2. package/dist/AsyncDataAdapter.d.ts +64 -0
  3. package/dist/AutoFetchDataAdapter.d.ts +112 -0
  4. package/dist/Collection/Cursor.d.ts +9 -9
  5. package/dist/Collection/Observer.d.ts +3 -2
  6. package/dist/Collection/index.d.ts +54 -46
  7. package/dist/Collection/types.d.ts +4 -9
  8. package/dist/DataAdapter.d.ts +34 -0
  9. package/dist/DefaultDataAdapter.d.ts +33 -0
  10. package/dist/WorkerDataAdapter.d.ts +25 -0
  11. package/dist/WorkerDataAdapterHost.d.ts +62 -0
  12. package/dist/createIndex.d.ts +7 -0
  13. package/dist/createStorageAdapter.d.ts +9 -0
  14. package/dist/{Collection/getIndexInfo.d.ts → getIndexInfo.d.ts} +17 -19
  15. package/dist/index.cjs.js +21 -17
  16. package/dist/index.cjs10.js +15 -26
  17. package/dist/index.cjs11.js +13 -10
  18. package/dist/index.cjs12.js +348 -3
  19. package/dist/index.cjs13.js +396 -110
  20. package/dist/index.cjs14.js +178 -68
  21. package/dist/index.cjs15.js +384 -8
  22. package/dist/index.cjs16.js +572 -20
  23. package/dist/index.cjs17.js +12 -4
  24. package/dist/index.cjs18.js +24 -5
  25. package/dist/index.cjs2.js +29 -32
  26. package/dist/index.cjs20.js +5 -13
  27. package/dist/index.cjs21.js +99 -21
  28. package/dist/index.cjs22.js +108 -58
  29. package/dist/index.cjs23.js +5 -82
  30. package/dist/index.cjs24.js +23 -14
  31. package/dist/index.cjs25.js +8 -27
  32. package/dist/index.cjs26.js +27 -7
  33. package/dist/index.cjs27.js +44 -5
  34. package/dist/index.cjs28.js +6 -27
  35. package/dist/index.cjs29.js +7 -40
  36. package/dist/index.cjs3.js +198 -444
  37. package/dist/index.cjs30.js +5 -0
  38. package/dist/index.cjs31.js +7 -0
  39. package/dist/index.cjs32.js +29 -0
  40. package/dist/index.cjs33.js +42 -0
  41. package/dist/index.cjs4.js +3 -165
  42. package/dist/index.cjs5.js +3 -66
  43. package/dist/index.cjs6.js +27 -3
  44. package/dist/index.cjs7.js +10 -3
  45. package/dist/index.cjs8.js +3 -3
  46. package/dist/index.cjs9.js +131 -3
  47. package/dist/index.d.ts +11 -8
  48. package/dist/index.mjs +15 -11
  49. package/dist/index10.mjs +15 -26
  50. package/dist/index11.mjs +13 -10
  51. package/dist/index12.mjs +348 -3
  52. package/dist/index13.mjs +396 -110
  53. package/dist/index14.mjs +178 -67
  54. package/dist/index15.mjs +384 -8
  55. package/dist/index16.mjs +572 -20
  56. package/dist/index17.mjs +12 -4
  57. package/dist/index18.mjs +24 -5
  58. package/dist/index2.mjs +29 -32
  59. package/dist/index20.mjs +5 -13
  60. package/dist/index21.mjs +99 -21
  61. package/dist/index22.mjs +108 -58
  62. package/dist/index23.mjs +5 -81
  63. package/dist/index24.mjs +23 -14
  64. package/dist/index25.mjs +8 -27
  65. package/dist/index26.mjs +27 -7
  66. package/dist/index27.mjs +44 -5
  67. package/dist/index28.mjs +6 -27
  68. package/dist/index29.mjs +7 -40
  69. package/dist/index3.mjs +198 -445
  70. package/dist/index30.mjs +6 -0
  71. package/dist/index31.mjs +8 -0
  72. package/dist/index32.mjs +30 -0
  73. package/dist/index33.mjs +43 -0
  74. package/dist/index4.mjs +3 -165
  75. package/dist/index5.mjs +3 -65
  76. package/dist/index6.mjs +27 -3
  77. package/dist/index7.mjs +10 -3
  78. package/dist/index8.mjs +3 -3
  79. package/dist/index9.mjs +131 -3
  80. package/dist/types/IndexProvider.d.ts +12 -7
  81. package/dist/types/StorageAdapter.d.ts +20 -0
  82. package/dist/utils/batchOnNextTick.d.ts +16 -0
  83. package/dist/utils/objectId.d.ts +8 -0
  84. package/dist/utils/queryId.d.ts +9 -0
  85. package/package.json +1 -1
  86. package/dist/AutoFetchCollection.d.ts +0 -60
  87. package/dist/Collection/createIndex.d.ts +0 -15
  88. package/dist/ReplicatedCollection.d.ts +0 -60
  89. package/dist/createMemoryAdapter.d.ts +0 -7
  90. package/dist/persistence/combinePersistenceAdapters.d.ts +0 -32
  91. package/dist/persistence/createPersistenceAdapter.d.ts +0 -9
  92. package/dist/types/MemoryAdapter.d.ts +0 -15
  93. package/dist/types/PersistenceAdapter.d.ts +0 -20
package/dist/index26.mjs CHANGED
@@ -1,10 +1,30 @@
1
- function uniqueBy(array, fn) {
2
- const set = /* @__PURE__ */ new Set();
3
- return array.filter((element) => {
4
- const value = typeof fn === "function" ? fn(element) : element[fn];
5
- return !set.has(value) && set.add(value);
6
- });
1
+ import isFieldExpression from "./index33.mjs";
2
+ import serializeValue from "./index11.mjs";
3
+ function getMatchingKeys(field, selector) {
4
+ const result = { include: null, exclude: null };
5
+ const fieldSelector = selector[field];
6
+ if (fieldSelector instanceof RegExp)
7
+ return result;
8
+ if (fieldSelector == null)
9
+ return result;
10
+ if (isFieldExpression(fieldSelector)) {
11
+ if (fieldSelector.$ne != null) {
12
+ result.exclude = [serializeValue(fieldSelector.$ne)];
13
+ return result;
14
+ }
15
+ if (Array.isArray(fieldSelector.$in) && fieldSelector.$in.length > 0) {
16
+ result.include = fieldSelector.$in.map(serializeValue);
17
+ return result;
18
+ }
19
+ if (Array.isArray(fieldSelector.$nin) && fieldSelector.$nin.length > 0) {
20
+ result.exclude = fieldSelector.$nin.map(serializeValue);
21
+ return result;
22
+ }
23
+ return { include: null, exclude: null };
24
+ }
25
+ result.include = [serializeValue(fieldSelector)];
26
+ return result;
7
27
  }
8
28
  export {
9
- uniqueBy as default
29
+ getMatchingKeys as default
10
30
  };
package/dist/index27.mjs CHANGED
@@ -1,8 +1,47 @@
1
- function intersection(...arrays) {
2
- if (arrays.length === 0)
3
- return [];
4
- return [...new Set(arrays.reduce((a, b) => a.filter((c) => b.includes(c))))];
1
+ function batchOnNextTick(onFlush) {
2
+ const queues = /* @__PURE__ */ new Map();
3
+ function enqueue(key, args) {
4
+ return new Promise((resolve, reject) => {
5
+ let q = queues.get(key);
6
+ if (!q) {
7
+ q = {
8
+ timer: null,
9
+ items: [],
10
+ flush: () => flush(key)
11
+ };
12
+ queues.set(key, q);
13
+ }
14
+ q.items.push({ args, resolve, reject });
15
+ if (q.timer == null) {
16
+ q.timer = setTimeout(() => {
17
+ q.timer = null;
18
+ void q.flush();
19
+ }, 0);
20
+ }
21
+ });
22
+ }
23
+ async function flush(key) {
24
+ const q = queues.get(key);
25
+ if (!q || q.items.length === 0)
26
+ return;
27
+ if (q.timer != null) {
28
+ clearTimeout(q.timer);
29
+ q.timer = null;
30
+ }
31
+ const items = q.items.splice(0);
32
+ onFlush(key, items.map((i) => i.args)).then((results) => {
33
+ for (const [index, result] of results.entries()) {
34
+ const { resolve } = items[index];
35
+ resolve(result);
36
+ }
37
+ }).catch((error) => {
38
+ for (const { reject } of items) {
39
+ reject(error);
40
+ }
41
+ });
42
+ }
43
+ return { enqueue, flush };
5
44
  }
6
45
  export {
7
- intersection as default
46
+ batchOnNextTick as default
8
47
  };
package/dist/index28.mjs CHANGED
@@ -1,30 +1,9 @@
1
- import isFieldExpression from "./index29.mjs";
2
- import serializeValue from "./index20.mjs";
3
- function getMatchingKeys(field, selector) {
4
- const result = { include: null, exclude: null };
5
- const fieldSelector = selector[field];
6
- if (fieldSelector instanceof RegExp)
7
- return result;
8
- if (fieldSelector == null)
9
- return result;
10
- if (isFieldExpression(fieldSelector)) {
11
- if (fieldSelector.$ne != null) {
12
- result.exclude = [serializeValue(fieldSelector.$ne)];
13
- return result;
14
- }
15
- if (Array.isArray(fieldSelector.$in) && fieldSelector.$in.length > 0) {
16
- result.include = fieldSelector.$in.map(serializeValue);
17
- return result;
18
- }
19
- if (Array.isArray(fieldSelector.$nin) && fieldSelector.$nin.length > 0) {
20
- result.exclude = fieldSelector.$nin.map(serializeValue);
21
- return result;
22
- }
23
- return { include: null, exclude: null };
24
- }
25
- result.include = [serializeValue(fieldSelector)];
26
- return result;
1
+ function truthy(value) {
2
+ return !!value;
3
+ }
4
+ function compact(array) {
5
+ return array.filter(truthy);
27
6
  }
28
7
  export {
29
- getMatchingKeys as default
8
+ compact as default
30
9
  };
package/dist/index29.mjs CHANGED
@@ -1,43 +1,10 @@
1
- const expressionKeys = /* @__PURE__ */ new Set([
2
- "$eq",
3
- "$gt",
4
- "$gte",
5
- "$lt",
6
- "$lte",
7
- "$in",
8
- "$nin",
9
- "$ne",
10
- "$exists",
11
- "$not",
12
- "$expr",
13
- "$jsonSchema",
14
- "$mod",
15
- "$regex",
16
- "$options",
17
- "$text",
18
- "$where",
19
- "$all",
20
- "$elemMatch",
21
- "$size",
22
- "$bitsAllClear",
23
- "$bitsAllSet",
24
- "$bitsAnyClear",
25
- "$bitsAnySet"
26
- ]);
27
- function isFieldExpression(expression) {
28
- if (typeof expression !== "object" || expression == null) {
29
- return false;
30
- }
31
- const keys = Object.keys(expression);
32
- if (keys.length === 0) {
33
- return false;
34
- }
35
- const hasInvalidKeys = keys.some((key) => !expressionKeys.has(key));
36
- if (hasInvalidKeys)
37
- return false;
38
- const hasValidKeys = keys.every((key) => expressionKeys.has(key));
39
- return hasValidKeys;
1
+ function uniqueBy(array, fn) {
2
+ const set = /* @__PURE__ */ new Set();
3
+ return array.filter((element) => {
4
+ const value = typeof fn === "function" ? fn(element) : element[fn];
5
+ return !set.has(value) && set.add(value);
6
+ });
40
7
  }
41
8
  export {
42
- isFieldExpression as default
9
+ uniqueBy as default
43
10
  };