@signaldb/core 2.0.0-beta.6 → 2.0.0-beta.8

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 (126) hide show
  1. package/dist/.vite/manifest.json +118 -84
  2. package/dist/AsyncDataAdapter.d.ts +4 -6
  3. package/dist/AutoFetchDataAdapter.d.ts +4 -6
  4. package/dist/Collection/Cursor.d.ts +3 -3
  5. package/dist/Collection/index.d.ts +8 -9
  6. package/dist/Collection/types.d.ts +2 -2
  7. package/dist/DataAdapter.d.ts +3 -4
  8. package/dist/DefaultDataAdapter.d.ts +3 -5
  9. package/dist/WorkerDataAdapter.d.ts +2 -4
  10. package/dist/WorkerDataAdapterHost.d.ts +5 -5
  11. package/dist/createIndex.d.ts +2 -2
  12. package/dist/createIndexProvider.d.ts +2 -2
  13. package/dist/createReactivityAdapter.d.ts +2 -2
  14. package/dist/createStorageAdapter.d.ts +1 -1
  15. package/dist/getIndexInfo.d.ts +3 -4
  16. package/dist/index.cjs.js +33 -34
  17. package/dist/index.mjs +17 -35
  18. package/dist/index10.cjs.js +23 -0
  19. package/dist/index10.mjs +21 -17
  20. package/dist/index11.cjs.js +45 -0
  21. package/dist/index11.mjs +44 -15
  22. package/dist/index12.cjs.js +22 -0
  23. package/dist/index12.mjs +21 -47
  24. package/dist/index13.cjs.js +45 -0
  25. package/dist/index13.mjs +44 -365
  26. package/dist/index14.cjs.js +86 -0
  27. package/dist/index14.mjs +85 -416
  28. package/dist/index15.cjs.js +15 -0
  29. package/dist/index15.mjs +14 -206
  30. package/dist/index16.cjs.js +136 -0
  31. package/dist/index16.mjs +135 -388
  32. package/dist/index17.cjs.js +47 -0
  33. package/dist/index17.mjs +45 -578
  34. package/dist/index18.cjs.js +15 -0
  35. package/dist/index18.mjs +14 -157
  36. package/dist/index19.cjs.js +23 -0
  37. package/dist/index19.mjs +22 -26
  38. package/dist/index2.cjs.js +33 -0
  39. package/dist/index2.mjs +32 -258
  40. package/dist/index20.cjs.js +37 -0
  41. package/dist/index20.mjs +36 -41
  42. package/dist/index21.cjs.js +35 -0
  43. package/dist/index21.mjs +34 -16
  44. package/dist/index22.cjs.js +25 -0
  45. package/dist/index22.mjs +24 -104
  46. package/dist/index23.cjs.js +19 -0
  47. package/dist/index23.mjs +18 -128
  48. package/dist/index24.cjs.js +342 -0
  49. package/dist/index24.mjs +340 -6
  50. package/dist/index25.cjs.js +519 -0
  51. package/dist/index25.mjs +518 -27
  52. package/dist/index26.cjs.js +11 -0
  53. package/dist/index26.mjs +10 -10
  54. package/dist/index27.cjs.js +11 -0
  55. package/dist/index27.mjs +10 -29
  56. package/dist/index28.cjs.js +90 -0
  57. package/dist/index28.mjs +88 -46
  58. package/dist/index29.cjs.js +370 -0
  59. package/dist/index29.mjs +369 -8
  60. package/dist/index3.cjs.js +19 -0
  61. package/dist/index3.mjs +18 -539
  62. package/dist/index30.cjs.js +72 -0
  63. package/dist/index30.mjs +71 -9
  64. package/dist/index31.cjs.js +191 -0
  65. package/dist/index31.mjs +190 -7
  66. package/dist/index32.cjs.js +21 -0
  67. package/dist/index32.mjs +20 -42
  68. package/dist/index33.cjs.js +336 -0
  69. package/dist/index33.mjs +335 -29
  70. package/dist/index34.cjs.js +539 -0
  71. package/dist/index34.mjs +537 -4
  72. package/dist/index4.cjs.js +150 -0
  73. package/dist/index4.mjs +149 -5
  74. package/dist/index5.cjs.js +254 -0
  75. package/dist/index5.mjs +252 -4
  76. package/dist/index6.cjs.js +125 -0
  77. package/dist/index6.mjs +124 -29
  78. package/dist/index7.cjs.js +33 -0
  79. package/dist/index7.mjs +32 -12
  80. package/dist/index8.cjs.js +12 -0
  81. package/dist/index8.mjs +10 -4
  82. package/dist/index9.cjs.js +11 -0
  83. package/dist/index9.mjs +10 -133
  84. package/dist/types/IndexProvider.d.ts +2 -2
  85. package/dist/types/Modifier.d.ts +1 -1
  86. package/dist/types/ReactivityAdapter.d.ts +1 -1
  87. package/dist/utils/createSignal.d.ts +2 -2
  88. package/dist/utils/getMatchingKeys.d.ts +2 -2
  89. package/dist/utils/isFieldExpression.d.ts +1 -1
  90. package/dist/utils/match.d.ts +1 -1
  91. package/dist/utils/modify.d.ts +1 -1
  92. package/dist/utils/queryId.d.ts +2 -2
  93. package/package.json +1 -1
  94. package/dist/index.cjs10.js +0 -18
  95. package/dist/index.cjs11.js +0 -15
  96. package/dist/index.cjs12.js +0 -48
  97. package/dist/index.cjs13.js +0 -365
  98. package/dist/index.cjs14.js +0 -416
  99. package/dist/index.cjs15.js +0 -206
  100. package/dist/index.cjs16.js +0 -388
  101. package/dist/index.cjs17.js +0 -579
  102. package/dist/index.cjs18.js +0 -157
  103. package/dist/index.cjs19.js +0 -26
  104. package/dist/index.cjs2.js +0 -259
  105. package/dist/index.cjs20.js +0 -42
  106. package/dist/index.cjs21.js +0 -16
  107. package/dist/index.cjs22.js +0 -104
  108. package/dist/index.cjs23.js +0 -129
  109. package/dist/index.cjs24.js +0 -7
  110. package/dist/index.cjs25.js +0 -27
  111. package/dist/index.cjs26.js +0 -10
  112. package/dist/index.cjs27.js +0 -29
  113. package/dist/index.cjs28.js +0 -46
  114. package/dist/index.cjs29.js +0 -8
  115. package/dist/index.cjs3.js +0 -540
  116. package/dist/index.cjs30.js +0 -9
  117. package/dist/index.cjs31.js +0 -7
  118. package/dist/index.cjs32.js +0 -42
  119. package/dist/index.cjs33.js +0 -29
  120. package/dist/index.cjs34.js +0 -5
  121. package/dist/index.cjs4.js +0 -5
  122. package/dist/index.cjs5.js +0 -5
  123. package/dist/index.cjs6.js +0 -29
  124. package/dist/index.cjs7.js +0 -12
  125. package/dist/index.cjs8.js +0 -5
  126. package/dist/index.cjs9.js +0 -133
@@ -0,0 +1,125 @@
1
+ //#region src/utils/EventEmitter.ts
2
+ /**
3
+ * A strongly‑typed EventEmitter.
4
+ */
5
+ var EventEmitter = class {
6
+ _maxListeners = 100;
7
+ /**
8
+ * We store a set of the listeners for each event.
9
+ */
10
+ _listenerStore = /* @__PURE__ */ new Map();
11
+ setMaxListeners(max) {
12
+ this._maxListeners = max;
13
+ return this;
14
+ }
15
+ /**
16
+ * Subscribe to an event with a listener function.
17
+ * @param eventName The event name (key of E).
18
+ * @param listener A function that receives the emitted arguments.
19
+ * @returns The emitter instance (for chaining).
20
+ */
21
+ on(eventName, listener) {
22
+ let listenersSet = this._listenerStore.get(eventName);
23
+ if (!listenersSet) {
24
+ listenersSet = /* @__PURE__ */ new Set();
25
+ this._listenerStore.set(eventName, listenersSet);
26
+ }
27
+ listenersSet.add(listener);
28
+ if (listenersSet.size > this._maxListeners) console.warn(`Possible EventEmitter memory leak detected. ${listenersSet.size} ${String(eventName)} listeners added. Use emitter.setMaxListeners() to increase limit.`);
29
+ return this;
30
+ }
31
+ /**
32
+ * Subscribe to an event with a listener function.
33
+ * @param eventName The event name (key of E).
34
+ * @param listener A function that receives the emitted arguments.
35
+ * @returns The emitter instance (for chaining).
36
+ */
37
+ addListener(eventName, listener) {
38
+ return this.on(eventName, listener);
39
+ }
40
+ /**
41
+ * Subscribe to an event, handling it only once. Automatically removes
42
+ * the listener after it fires the first time.
43
+ * @param eventName The event name (key of E).
44
+ * @param listener A function that receives the emitted arguments.
45
+ * @returns The emitter instance (for chaining).
46
+ */
47
+ once(eventName, listener) {
48
+ const onceWrapper = ((...args) => {
49
+ listener(...args);
50
+ this.off(eventName, onceWrapper);
51
+ });
52
+ return this.on(eventName, onceWrapper);
53
+ }
54
+ /**
55
+ * Unsubscribe a previously subscribed listener.
56
+ * @param eventName The event name (key of E).
57
+ * @param listener The original function passed to `on` or `once`.
58
+ * @returns The emitter instance (for chaining).
59
+ */
60
+ off(eventName, listener) {
61
+ const listenersSet = this._listenerStore.get(eventName);
62
+ if (!listenersSet) return this;
63
+ listenersSet.delete(listener);
64
+ if (listenersSet.size === 0) this._listenerStore.delete(eventName);
65
+ return this;
66
+ }
67
+ /**
68
+ * Unsubscribe a previously subscribed listener.
69
+ * @param eventName The event name (key of E).
70
+ * @param listener The original function passed to `on` or `once`.
71
+ * @returns The emitter instance (for chaining).
72
+ */
73
+ removeListener(eventName, listener) {
74
+ return this.off(eventName, listener);
75
+ }
76
+ /**
77
+ * Emit (dispatch) an event with a variable number of arguments.
78
+ * @param eventName The event name (key of E).
79
+ * @param args The arguments to pass to subscribed listeners.
80
+ */
81
+ emit(eventName, ...args) {
82
+ this.listeners(eventName).forEach((listener) => {
83
+ listener(...args);
84
+ });
85
+ }
86
+ /**
87
+ * Returns the array of listener functions currently registered for a given event.
88
+ * @param eventName The event name (key of E).
89
+ * @returns An array of listener functions.
90
+ */
91
+ listeners(eventName) {
92
+ const listenersSet = this._listenerStore.get(eventName);
93
+ if (!listenersSet) return [];
94
+ return [...listenersSet.values()];
95
+ }
96
+ /**
97
+ * Returns the number of listeners for a given event.
98
+ * @param eventName The event name (key of E).
99
+ * @returns The number of listeners.
100
+ */
101
+ listenerCount(eventName) {
102
+ const listenersSet = this._listenerStore.get(eventName);
103
+ return listenersSet ? listenersSet.size : 0;
104
+ }
105
+ /**
106
+ * Removes all listeners for a given event, or all events if none is specified.
107
+ * @param eventName Optional. If omitted, clears all events’ listeners.
108
+ * @returns The emitter instance (for chaining).
109
+ */
110
+ removeAllListeners(eventName) {
111
+ if (eventName === void 0) {
112
+ for (const [eventName_, listenersSet] of this._listenerStore.entries()) for (const listener of listenersSet.values()) this.off(eventName_, listener);
113
+ this._listenerStore.clear();
114
+ } else {
115
+ const listenersSet = this._listenerStore.get(eventName);
116
+ if (listenersSet) {
117
+ for (const listener of listenersSet.values()) this.off(eventName, listener);
118
+ this._listenerStore.delete(eventName);
119
+ }
120
+ }
121
+ return this;
122
+ }
123
+ };
124
+ //#endregion
125
+ exports.default = EventEmitter;
package/dist/index6.mjs CHANGED
@@ -1,30 +1,125 @@
1
- function isEqual(a, b) {
2
- if (Object.is(a, b))
3
- return true;
4
- if (a instanceof RegExp && b instanceof RegExp)
5
- return a.toString() === b.toString();
6
- if (a instanceof Date && b instanceof Date)
7
- return a.getTime() === b.getTime();
8
- if (typeof a !== "object")
9
- return false;
10
- if (typeof b !== "object")
11
- return false;
12
- if (a === null)
13
- return false;
14
- if (b === null)
15
- return false;
16
- const aKeys = Object.keys(a);
17
- const bKeys = Object.keys(b);
18
- if (aKeys.length !== bKeys.length)
19
- return false;
20
- for (const key of aKeys) {
21
- if (!bKeys.includes(key))
22
- return false;
23
- if (!isEqual(a[key], b[key]))
24
- return false;
25
- }
26
- return true;
27
- }
28
- export {
29
- isEqual as default
1
+ //#region src/utils/EventEmitter.ts
2
+ /**
3
+ * A strongly‑typed EventEmitter.
4
+ */
5
+ var EventEmitter = class {
6
+ _maxListeners = 100;
7
+ /**
8
+ * We store a set of the listeners for each event.
9
+ */
10
+ _listenerStore = /* @__PURE__ */ new Map();
11
+ setMaxListeners(max) {
12
+ this._maxListeners = max;
13
+ return this;
14
+ }
15
+ /**
16
+ * Subscribe to an event with a listener function.
17
+ * @param eventName The event name (key of E).
18
+ * @param listener A function that receives the emitted arguments.
19
+ * @returns The emitter instance (for chaining).
20
+ */
21
+ on(eventName, listener) {
22
+ let listenersSet = this._listenerStore.get(eventName);
23
+ if (!listenersSet) {
24
+ listenersSet = /* @__PURE__ */ new Set();
25
+ this._listenerStore.set(eventName, listenersSet);
26
+ }
27
+ listenersSet.add(listener);
28
+ if (listenersSet.size > this._maxListeners) console.warn(`Possible EventEmitter memory leak detected. ${listenersSet.size} ${String(eventName)} listeners added. Use emitter.setMaxListeners() to increase limit.`);
29
+ return this;
30
+ }
31
+ /**
32
+ * Subscribe to an event with a listener function.
33
+ * @param eventName The event name (key of E).
34
+ * @param listener A function that receives the emitted arguments.
35
+ * @returns The emitter instance (for chaining).
36
+ */
37
+ addListener(eventName, listener) {
38
+ return this.on(eventName, listener);
39
+ }
40
+ /**
41
+ * Subscribe to an event, handling it only once. Automatically removes
42
+ * the listener after it fires the first time.
43
+ * @param eventName The event name (key of E).
44
+ * @param listener A function that receives the emitted arguments.
45
+ * @returns The emitter instance (for chaining).
46
+ */
47
+ once(eventName, listener) {
48
+ const onceWrapper = ((...args) => {
49
+ listener(...args);
50
+ this.off(eventName, onceWrapper);
51
+ });
52
+ return this.on(eventName, onceWrapper);
53
+ }
54
+ /**
55
+ * Unsubscribe a previously subscribed listener.
56
+ * @param eventName The event name (key of E).
57
+ * @param listener The original function passed to `on` or `once`.
58
+ * @returns The emitter instance (for chaining).
59
+ */
60
+ off(eventName, listener) {
61
+ const listenersSet = this._listenerStore.get(eventName);
62
+ if (!listenersSet) return this;
63
+ listenersSet.delete(listener);
64
+ if (listenersSet.size === 0) this._listenerStore.delete(eventName);
65
+ return this;
66
+ }
67
+ /**
68
+ * Unsubscribe a previously subscribed listener.
69
+ * @param eventName The event name (key of E).
70
+ * @param listener The original function passed to `on` or `once`.
71
+ * @returns The emitter instance (for chaining).
72
+ */
73
+ removeListener(eventName, listener) {
74
+ return this.off(eventName, listener);
75
+ }
76
+ /**
77
+ * Emit (dispatch) an event with a variable number of arguments.
78
+ * @param eventName The event name (key of E).
79
+ * @param args The arguments to pass to subscribed listeners.
80
+ */
81
+ emit(eventName, ...args) {
82
+ this.listeners(eventName).forEach((listener) => {
83
+ listener(...args);
84
+ });
85
+ }
86
+ /**
87
+ * Returns the array of listener functions currently registered for a given event.
88
+ * @param eventName The event name (key of E).
89
+ * @returns An array of listener functions.
90
+ */
91
+ listeners(eventName) {
92
+ const listenersSet = this._listenerStore.get(eventName);
93
+ if (!listenersSet) return [];
94
+ return [...listenersSet.values()];
95
+ }
96
+ /**
97
+ * Returns the number of listeners for a given event.
98
+ * @param eventName The event name (key of E).
99
+ * @returns The number of listeners.
100
+ */
101
+ listenerCount(eventName) {
102
+ const listenersSet = this._listenerStore.get(eventName);
103
+ return listenersSet ? listenersSet.size : 0;
104
+ }
105
+ /**
106
+ * Removes all listeners for a given event, or all events if none is specified.
107
+ * @param eventName Optional. If omitted, clears all events’ listeners.
108
+ * @returns The emitter instance (for chaining).
109
+ */
110
+ removeAllListeners(eventName) {
111
+ if (eventName === void 0) {
112
+ for (const [eventName_, listenersSet] of this._listenerStore.entries()) for (const listener of listenersSet.values()) this.off(eventName_, listener);
113
+ this._listenerStore.clear();
114
+ } else {
115
+ const listenersSet = this._listenerStore.get(eventName);
116
+ if (listenersSet) {
117
+ for (const listener of listenersSet.values()) this.off(eventName, listener);
118
+ this._listenerStore.delete(eventName);
119
+ }
120
+ }
121
+ return this;
122
+ }
30
123
  };
124
+ //#endregion
125
+ export { EventEmitter as default };
@@ -0,0 +1,33 @@
1
+ //#region src/utils/createSignal.ts
2
+ /**
3
+ * Creates a reactive signal for managing state and triggering dependencies.
4
+ * The signal holds a value and provides methods to get and set the value,
5
+ * with optional equality checks and dependency tracking.
6
+ * @template T - The type of the value held by the signal.
7
+ * @param reactivityAdapter - An optional reactivity adapter for managing dependencies.
8
+ * @param initialValue - The initial value of the signal.
9
+ * @param isEqual - A custom equality function to determine if the new value is different
10
+ * from the current value (default is `Object.is`).
11
+ * @returns A signal object with `get` and `set` methods to manage the value.
12
+ */
13
+ function createSignal(reactivityAdapter, initialValue, isEqual = Object.is) {
14
+ let value = initialValue;
15
+ const dependency = reactivityAdapter?.create();
16
+ const isInReactiveScope = () => {
17
+ if (!reactivityAdapter?.isInScope) return true;
18
+ return reactivityAdapter.isInScope();
19
+ };
20
+ return {
21
+ get() {
22
+ if (dependency && isInReactiveScope()) dependency.depend();
23
+ return value;
24
+ },
25
+ set(newValue) {
26
+ if (isEqual(value, newValue)) return;
27
+ value = newValue;
28
+ if (dependency) dependency.notify();
29
+ }
30
+ };
31
+ }
32
+ //#endregion
33
+ exports.default = createSignal;
package/dist/index7.mjs CHANGED
@@ -1,13 +1,33 @@
1
- import { update } from "mingo";
2
- import deepClone from "./index20.mjs";
3
- function modify(item, modifier) {
4
- const hasOperators = Object.keys(modifier).some((key) => key.startsWith("$"));
5
- if (!hasOperators)
6
- return modifier;
7
- const clonedItem = deepClone(item);
8
- update(clonedItem, modifier);
9
- return clonedItem;
1
+ //#region src/utils/createSignal.ts
2
+ /**
3
+ * Creates a reactive signal for managing state and triggering dependencies.
4
+ * The signal holds a value and provides methods to get and set the value,
5
+ * with optional equality checks and dependency tracking.
6
+ * @template T - The type of the value held by the signal.
7
+ * @param reactivityAdapter - An optional reactivity adapter for managing dependencies.
8
+ * @param initialValue - The initial value of the signal.
9
+ * @param isEqual - A custom equality function to determine if the new value is different
10
+ * from the current value (default is `Object.is`).
11
+ * @returns A signal object with `get` and `set` methods to manage the value.
12
+ */
13
+ function createSignal(reactivityAdapter, initialValue, isEqual = Object.is) {
14
+ let value = initialValue;
15
+ const dependency = reactivityAdapter?.create();
16
+ const isInReactiveScope = () => {
17
+ if (!reactivityAdapter?.isInScope) return true;
18
+ return reactivityAdapter.isInScope();
19
+ };
20
+ return {
21
+ get() {
22
+ if (dependency && isInReactiveScope()) dependency.depend();
23
+ return value;
24
+ },
25
+ set(newValue) {
26
+ if (isEqual(value, newValue)) return;
27
+ value = newValue;
28
+ if (dependency) dependency.notify();
29
+ }
30
+ };
10
31
  }
11
- export {
12
- modify as default
13
- };
32
+ //#endregion
33
+ export { createSignal as default };
@@ -0,0 +1,12 @@
1
+ //#region src/utils/randomId.ts
2
+ /**
3
+ * creates a random id
4
+ * @returns a random string of 16 characters
5
+ * @example
6
+ * randomId() // '1234567890abcdef'
7
+ */
8
+ function randomId() {
9
+ return Array.from({ length: 16 }, () => "abcdefghijklmnopqrstuvwxyz0123456789"[Math.floor(Math.random() * 36)]).join("");
10
+ }
11
+ //#endregion
12
+ exports.default = randomId;
package/dist/index8.mjs CHANGED
@@ -1,6 +1,12 @@
1
+ //#region src/utils/randomId.ts
2
+ /**
3
+ * creates a random id
4
+ * @returns a random string of 16 characters
5
+ * @example
6
+ * randomId() // '1234567890abcdef'
7
+ */
1
8
  function randomId() {
2
- return Array.from({ length: 16 }, () => "abcdefghijklmnopqrstuvwxyz0123456789"[Math.floor(Math.random() * 36)]).join("");
9
+ return Array.from({ length: 16 }, () => "abcdefghijklmnopqrstuvwxyz0123456789"[Math.floor(Math.random() * 36)]).join("");
3
10
  }
4
- export {
5
- randomId as default
6
- };
11
+ //#endregion
12
+ export { randomId as default };
@@ -0,0 +1,11 @@
1
+ //#region src/createIndexProvider.ts
2
+ /**
3
+ * Creates an IndexProvider based on the given definition.
4
+ * @param definition - The definition of the IndexProvider.
5
+ * @returns The created IndexProvider.
6
+ */
7
+ function createIndexProvider(definition) {
8
+ return definition;
9
+ }
10
+ //#endregion
11
+ exports.default = createIndexProvider;
package/dist/index9.mjs CHANGED
@@ -1,134 +1,11 @@
1
- class EventEmitter {
2
- _maxListeners = 100;
3
- /**
4
- * We store a set of the listeners for each event.
5
- */
6
- _listenerStore = /* @__PURE__ */ new Map();
7
- setMaxListeners(max) {
8
- this._maxListeners = max;
9
- return this;
10
- }
11
- /**
12
- * Subscribe to an event with a listener function.
13
- * @param eventName The event name (key of E).
14
- * @param listener A function that receives the emitted arguments.
15
- * @returns The emitter instance (for chaining).
16
- */
17
- on(eventName, listener) {
18
- let listenersSet = this._listenerStore.get(eventName);
19
- if (!listenersSet) {
20
- listenersSet = /* @__PURE__ */ new Set();
21
- this._listenerStore.set(eventName, listenersSet);
22
- }
23
- listenersSet.add(listener);
24
- if (listenersSet.size > this._maxListeners) {
25
- console.warn(`Possible EventEmitter memory leak detected. ${listenersSet.size} ${String(eventName)} listeners added. Use emitter.setMaxListeners() to increase limit.`);
26
- }
27
- return this;
28
- }
29
- /**
30
- * Subscribe to an event with a listener function.
31
- * @param eventName The event name (key of E).
32
- * @param listener A function that receives the emitted arguments.
33
- * @returns The emitter instance (for chaining).
34
- */
35
- addListener(eventName, listener) {
36
- return this.on(eventName, listener);
37
- }
38
- /**
39
- * Subscribe to an event, handling it only once. Automatically removes
40
- * the listener after it fires the first time.
41
- * @param eventName The event name (key of E).
42
- * @param listener A function that receives the emitted arguments.
43
- * @returns The emitter instance (for chaining).
44
- */
45
- once(eventName, listener) {
46
- const onceWrapper = ((...args) => {
47
- listener(...args);
48
- this.off(eventName, onceWrapper);
49
- });
50
- return this.on(eventName, onceWrapper);
51
- }
52
- /**
53
- * Unsubscribe a previously subscribed listener.
54
- * @param eventName The event name (key of E).
55
- * @param listener The original function passed to `on` or `once`.
56
- * @returns The emitter instance (for chaining).
57
- */
58
- off(eventName, listener) {
59
- const listenersSet = this._listenerStore.get(eventName);
60
- if (!listenersSet)
61
- return this;
62
- listenersSet.delete(listener);
63
- if (listenersSet.size === 0) {
64
- this._listenerStore.delete(eventName);
65
- }
66
- return this;
67
- }
68
- /**
69
- * Unsubscribe a previously subscribed listener.
70
- * @param eventName The event name (key of E).
71
- * @param listener The original function passed to `on` or `once`.
72
- * @returns The emitter instance (for chaining).
73
- */
74
- removeListener(eventName, listener) {
75
- return this.off(eventName, listener);
76
- }
77
- /**
78
- * Emit (dispatch) an event with a variable number of arguments.
79
- * @param eventName The event name (key of E).
80
- * @param args The arguments to pass to subscribed listeners.
81
- */
82
- emit(eventName, ...args) {
83
- this.listeners(eventName).forEach((listener) => {
84
- listener(...args);
85
- });
86
- }
87
- /**
88
- * Returns the array of listener functions currently registered for a given event.
89
- * @param eventName The event name (key of E).
90
- * @returns An array of listener functions.
91
- */
92
- listeners(eventName) {
93
- const listenersSet = this._listenerStore.get(eventName);
94
- if (!listenersSet)
95
- return [];
96
- return [...listenersSet.values()];
97
- }
98
- /**
99
- * Returns the number of listeners for a given event.
100
- * @param eventName The event name (key of E).
101
- * @returns The number of listeners.
102
- */
103
- listenerCount(eventName) {
104
- const listenersSet = this._listenerStore.get(eventName);
105
- return listenersSet ? listenersSet.size : 0;
106
- }
107
- /**
108
- * Removes all listeners for a given event, or all events if none is specified.
109
- * @param eventName Optional. If omitted, clears all events’ listeners.
110
- * @returns The emitter instance (for chaining).
111
- */
112
- removeAllListeners(eventName) {
113
- if (eventName === void 0) {
114
- for (const [eventName_, listenersSet] of this._listenerStore.entries()) {
115
- for (const listener of listenersSet.values()) {
116
- this.off(eventName_, listener);
117
- }
118
- }
119
- this._listenerStore.clear();
120
- } else {
121
- const listenersSet = this._listenerStore.get(eventName);
122
- if (listenersSet) {
123
- for (const listener of listenersSet.values()) {
124
- this.off(eventName, listener);
125
- }
126
- this._listenerStore.delete(eventName);
127
- }
128
- }
129
- return this;
130
- }
1
+ //#region src/createIndexProvider.ts
2
+ /**
3
+ * Creates an IndexProvider based on the given definition.
4
+ * @param definition - The definition of the IndexProvider.
5
+ * @returns The created IndexProvider.
6
+ */
7
+ function createIndexProvider(definition) {
8
+ return definition;
131
9
  }
132
- export {
133
- EventEmitter as default
134
- };
10
+ //#endregion
11
+ export { createIndexProvider as default };
@@ -1,5 +1,5 @@
1
- import type { BaseItem } from '../Collection';
2
- import type { FlatSelector } from './Selector';
1
+ import { BaseItem } from '../Collection';
2
+ import { FlatSelector } from './Selector';
3
3
  export type IndexResult<IdType> = {
4
4
  ids: IdType[];
5
5
  fields: string[];
@@ -1,4 +1,4 @@
1
- import type { DotNotation, GetType } from './Selector';
1
+ import { DotNotation, GetType } from './Selector';
2
2
  type Dictionary<T> = Record<string, T>;
3
3
  type PartialMapTo<T, M> = Partial<Record<DotNotation<T>, M>> & Dictionary<M>;
4
4
  type OnlyElementsOfArrays<T> = T extends any[] ? Partial<T[0]> : never;
@@ -1,4 +1,4 @@
1
- import type Dependency from './Dependency';
1
+ import { default as Dependency } from './Dependency';
2
2
  export default interface ReactivityAdapter<T extends Dependency = Dependency> {
3
3
  create(): T;
4
4
  onDispose?(callback: () => void, Dependency: T): void;
@@ -1,5 +1,5 @@
1
- import type ReactivityAdapter from '../types/ReactivityAdapter';
2
- import type Signal from '../types/Signal';
1
+ import { default as ReactivityAdapter } from '../types/ReactivityAdapter';
2
+ import { default as Signal } from '../types/Signal';
3
3
  /**
4
4
  * Creates a reactive signal for managing state and triggering dependencies.
5
5
  * The signal holds a value and provides methods to get and set the value,
@@ -1,5 +1,5 @@
1
- import type { BaseItem } from '../Collection/types';
2
- import type { FlatSelector } from '../types/Selector';
1
+ import { BaseItem } from '../Collection/types';
2
+ import { FlatSelector } from '../types/Selector';
3
3
  type KeyResult = {
4
4
  include: (string | null)[] | null;
5
5
  exclude: (string | null)[] | null;
@@ -1,4 +1,4 @@
1
- import type { FieldExpression } from '../types/Selector';
1
+ import { FieldExpression } from '../types/Selector';
2
2
  /**
3
3
  * Determines whether a given object is a valid field expression.
4
4
  * A field expression is an object containing query operators supported by MongoDB-style queries.
@@ -1,4 +1,4 @@
1
- import type Selector from '../types/Selector';
1
+ import { default as Selector } from '../types/Selector';
2
2
  type BaseItem = Record<string, any>;
3
3
  /**
4
4
  * Tests whether a given item matches a specified selector.
@@ -1,4 +1,4 @@
1
- import type Modifier from '../types/Modifier';
1
+ import { default as Modifier } from '../types/Modifier';
2
2
  /**
3
3
  * Applies a modifier to an object and returns a new modified object.
4
4
  * @template T - The type of the object to be modified.
@@ -1,5 +1,5 @@
1
- import type { QueryOptions } from '../DataAdapter';
2
- import type Selector from '../types/Selector';
1
+ import { QueryOptions } from '../DataAdapter';
2
+ import { default as Selector } from '../types/Selector';
3
3
  /**
4
4
  * Generates a unique identifier for a query based on its selector and options.
5
5
  * @param selector - The selector object.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@signaldb/core",
3
- "version": "2.0.0-beta.6",
3
+ "version": "2.0.0-beta.8",
4
4
  "description": "SignalDB is a client-side database that provides a simple MongoDB-like interface to the data with first-class typescript support to achieve an optimistic UI. Data persistence can be achieved by using storage providers that store the data through a JSON interface to places such as localStorage.",
5
5
  "scripts": {
6
6
  "build": "rimraf dist && vite build",
@@ -1,18 +0,0 @@
1
- "use strict";
2
- function get(value, path) {
3
- const normalized = path.replaceAll(/\[(\w+)\]/g, ".$1");
4
- if (normalized.includes("..") || normalized.startsWith(".") || normalized.endsWith(".")) {
5
- return;
6
- }
7
- const segments = normalized.split(".");
8
- let current = value;
9
- for (const key of segments) {
10
- if (current == null)
11
- return;
12
- current = current[key];
13
- }
14
- if (current === void 0)
15
- return;
16
- return current;
17
- }
18
- module.exports = get;
@@ -1,15 +0,0 @@
1
- "use strict";
2
- function serializeValue(value) {
3
- if (value == null)
4
- return null;
5
- if (typeof value === "string")
6
- return value;
7
- if (typeof value === "number")
8
- return value.toString();
9
- if (typeof value === "boolean")
10
- return value.toString();
11
- if (value instanceof Date)
12
- return value.toISOString();
13
- return JSON.stringify(value);
14
- }
15
- module.exports = serializeValue;