@signaldb/core 1.7.2 → 1.8.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.
- package/dist/.vite/manifest.json +88 -59
- package/dist/AutoFetchCollection.d.ts +3 -3
- package/dist/Collection/Cursor.d.ts +10 -7
- package/dist/Collection/index.d.ts +27 -11
- package/dist/Collection/types.d.ts +1 -0
- package/dist/ReplicatedCollection.d.ts +4 -4
- package/dist/index.cjs.js +26 -27
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +14 -28
- package/dist/index10.cjs.js +265 -0
- package/dist/index10.mjs +263 -28
- package/dist/index11.cjs.js +125 -0
- package/dist/index11.mjs +124 -12
- package/dist/index12.cjs.js +15 -0
- package/dist/index12.mjs +14 -5
- package/dist/index13.cjs.js +23 -0
- package/dist/index13.mjs +22 -133
- package/dist/index14.cjs.js +12 -0
- package/dist/index14.mjs +11 -73
- package/dist/index15.cjs.js +22 -0
- package/dist/index15.mjs +21 -10
- package/dist/index16.cjs.js +33 -0
- package/dist/index16.mjs +32 -27
- package/dist/index17.cjs.js +15 -0
- package/dist/index17.mjs +14 -142
- package/dist/index18.cjs.js +98 -0
- package/dist/index18.mjs +97 -7
- package/dist/index19.cjs.js +11 -0
- package/dist/index19.mjs +10 -41
- package/dist/index2.cjs.js +23 -0
- package/dist/index2.mjs +22 -260
- package/dist/index20.cjs.js +45 -0
- package/dist/index20.mjs +44 -15
- package/dist/index21.cjs.js +45 -0
- package/dist/index21.mjs +44 -26
- package/dist/index22.cjs.js +69 -0
- package/dist/index22.mjs +66 -77
- package/dist/index23.cjs.js +778 -0
- package/dist/index23.mjs +775 -81
- package/dist/index24.cjs.js +11 -0
- package/dist/index24.mjs +10 -18
- package/dist/index25.cjs.js +81 -0
- package/dist/index25.mjs +80 -29
- package/dist/index26.cjs.js +98 -0
- package/dist/index26.mjs +96 -8
- package/dist/index27.cjs.js +154 -0
- package/dist/index27.mjs +153 -7
- package/dist/index28.cjs.js +11 -0
- package/dist/index28.mjs +10 -29
- package/dist/index29.cjs.js +11 -0
- package/dist/index29.mjs +10 -42
- package/dist/index3.cjs.js +19 -0
- package/dist/index3.mjs +18 -788
- package/dist/index4.cjs.js +37 -0
- package/dist/index4.mjs +36 -167
- package/dist/index5.cjs.js +35 -0
- package/dist/index5.mjs +34 -67
- package/dist/index6.cjs.js +47 -0
- package/dist/index6.mjs +46 -5
- package/dist/index7.cjs.js +33 -0
- package/dist/index7.mjs +32 -5
- package/dist/index8.cjs.js +19 -0
- package/dist/index8.mjs +18 -5
- package/dist/index9.cjs.js +139 -0
- package/dist/index9.mjs +138 -5
- package/dist/utils/deepClone.d.ts +1 -1
- package/package.json +3 -3
- package/dist/index.cjs10.js +0 -29
- package/dist/index.cjs11.js +0 -12
- package/dist/index.cjs12.js +0 -5
- package/dist/index.cjs13.js +0 -133
- package/dist/index.cjs14.js +0 -74
- package/dist/index.cjs15.js +0 -10
- package/dist/index.cjs16.js +0 -27
- package/dist/index.cjs17.js +0 -142
- package/dist/index.cjs18.js +0 -7
- package/dist/index.cjs19.js +0 -42
- package/dist/index.cjs2.js +0 -261
- package/dist/index.cjs20.js +0 -15
- package/dist/index.cjs21.js +0 -26
- package/dist/index.cjs22.js +0 -79
- package/dist/index.cjs23.js +0 -84
- package/dist/index.cjs24.js +0 -18
- package/dist/index.cjs25.js +0 -29
- package/dist/index.cjs26.js +0 -9
- package/dist/index.cjs27.js +0 -7
- package/dist/index.cjs28.js +0 -29
- package/dist/index.cjs29.js +0 -42
- package/dist/index.cjs3.js +0 -788
- package/dist/index.cjs4.js +0 -167
- package/dist/index.cjs5.js +0 -68
- package/dist/index.cjs6.js +0 -5
- package/dist/index.cjs7.js +0 -5
- package/dist/index.cjs8.js +0 -5
- package/dist/index.cjs9.js +0 -5
package/dist/index11.mjs
CHANGED
|
@@ -1,13 +1,125 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
+
}
|
|
13
123
|
};
|
|
124
|
+
//#endregion
|
|
125
|
+
export { EventEmitter as default };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
let mingo = require("mingo");
|
|
2
|
+
//#region src/utils/match.ts
|
|
3
|
+
/**
|
|
4
|
+
* Tests whether a given item matches a specified selector.
|
|
5
|
+
* Uses the `mingo` library to evaluate the query.
|
|
6
|
+
* @template T - The type of the item being tested.
|
|
7
|
+
* @param item - The item to test against the selector.
|
|
8
|
+
* @param selector - The query selector used to match the item.
|
|
9
|
+
* @returns A boolean indicating whether the item matches the selector.
|
|
10
|
+
*/
|
|
11
|
+
function match(item, selector) {
|
|
12
|
+
return new mingo.Query(selector).test(item);
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
exports.default = match;
|
package/dist/index12.mjs
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { Query } from "mingo";
|
|
2
|
+
//#region src/utils/match.ts
|
|
3
|
+
/**
|
|
4
|
+
* Tests whether a given item matches a specified selector.
|
|
5
|
+
* Uses the `mingo` library to evaluate the query.
|
|
6
|
+
* @template T - The type of the item being tested.
|
|
7
|
+
* @param item - The item to test against the selector.
|
|
8
|
+
* @param selector - The query selector used to match the item.
|
|
9
|
+
* @returns A boolean indicating whether the item matches the selector.
|
|
10
|
+
*/
|
|
11
|
+
function match(item, selector) {
|
|
12
|
+
return new Query(selector).test(item);
|
|
3
13
|
}
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
};
|
|
14
|
+
//#endregion
|
|
15
|
+
export { match as default };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const require_deepClone = require("./index6.cjs.js");
|
|
2
|
+
let mingo = require("mingo");
|
|
3
|
+
//#region src/utils/modify.ts
|
|
4
|
+
/**
|
|
5
|
+
* Applies a modifier to an object and returns a new modified object.
|
|
6
|
+
* @template T - The type of the object to be modified.
|
|
7
|
+
* @param item - The object to be modified.
|
|
8
|
+
* @param modifier - The modifier to apply. This can be any transformation logic.
|
|
9
|
+
* @returns - Returns a new object with the modifications applied.
|
|
10
|
+
* @example
|
|
11
|
+
* const item = { a: 1, b: 2 }
|
|
12
|
+
* const modifier = { $set: { b: 3, c: 4 } }
|
|
13
|
+
* const result = modify(item, modifier)
|
|
14
|
+
* // result: { a: 1, b: 3, c: 4 }
|
|
15
|
+
*/
|
|
16
|
+
function modify(item, modifier) {
|
|
17
|
+
if (!Object.keys(modifier).some((key) => key.startsWith("$"))) return modifier;
|
|
18
|
+
const clonedItem = require_deepClone.default(item);
|
|
19
|
+
(0, mingo.update)(clonedItem, modifier);
|
|
20
|
+
return clonedItem;
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
exports.default = modify;
|
package/dist/index13.mjs
CHANGED
|
@@ -1,134 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
+
import deepClone from "./index6.mjs";
|
|
2
|
+
import { update } from "mingo";
|
|
3
|
+
//#region src/utils/modify.ts
|
|
4
|
+
/**
|
|
5
|
+
* Applies a modifier to an object and returns a new modified object.
|
|
6
|
+
* @template T - The type of the object to be modified.
|
|
7
|
+
* @param item - The object to be modified.
|
|
8
|
+
* @param modifier - The modifier to apply. This can be any transformation logic.
|
|
9
|
+
* @returns - Returns a new object with the modifications applied.
|
|
10
|
+
* @example
|
|
11
|
+
* const item = { a: 1, b: 2 }
|
|
12
|
+
* const modifier = { $set: { b: 3, c: 4 } }
|
|
13
|
+
* const result = modify(item, modifier)
|
|
14
|
+
* // result: { a: 1, b: 3, c: 4 }
|
|
15
|
+
*/
|
|
16
|
+
function modify(item, modifier) {
|
|
17
|
+
if (!Object.keys(modifier).some((key) => key.startsWith("$"))) return modifier;
|
|
18
|
+
const clonedItem = deepClone(item);
|
|
19
|
+
update(clonedItem, modifier);
|
|
20
|
+
return clonedItem;
|
|
131
21
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
};
|
|
22
|
+
//#endregion
|
|
23
|
+
export { modify 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 Math.floor(Math.random() * 0x16345785d8a0000).toString(16);
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
exports.default = randomId;
|
package/dist/index14.mjs
CHANGED
|
@@ -1,74 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
const fieldSelector = selector[field];
|
|
12
|
-
const filteresForNull = fieldSelector == null || fieldSelector.$exists === false;
|
|
13
|
-
const keys = filteresForNull ? { include: null, exclude: [...index.keys()].filter((key) => key != null) } : getMatchingKeys(field, selector);
|
|
14
|
-
if (keys.include == null && keys.exclude == null)
|
|
15
|
-
return { matched: false };
|
|
16
|
-
let includedPositions = [];
|
|
17
|
-
if (keys.include == null) {
|
|
18
|
-
for (const set of index.values()) {
|
|
19
|
-
for (const pos of set) {
|
|
20
|
-
includedPositions.push(pos);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
} else {
|
|
24
|
-
for (const key of keys.include) {
|
|
25
|
-
const posSet = index.get(key);
|
|
26
|
-
if (posSet) {
|
|
27
|
-
for (const pos of posSet) {
|
|
28
|
-
includedPositions.push(pos);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
if (keys.exclude != null) {
|
|
34
|
-
const excludeSet = /* @__PURE__ */ new Set();
|
|
35
|
-
for (const key of keys.exclude) {
|
|
36
|
-
const posSet = index.get(key);
|
|
37
|
-
if (posSet) {
|
|
38
|
-
for (const pos of posSet) {
|
|
39
|
-
excludeSet.add(pos);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
includedPositions = includedPositions.filter((pos) => !excludeSet.has(pos));
|
|
44
|
-
}
|
|
45
|
-
return {
|
|
46
|
-
matched: true,
|
|
47
|
-
positions: includedPositions,
|
|
48
|
-
fields: [field],
|
|
49
|
-
keepSelector: filteresForNull
|
|
50
|
-
};
|
|
51
|
-
},
|
|
52
|
-
rebuild() {
|
|
53
|
-
}
|
|
54
|
-
});
|
|
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 Math.floor(Math.random() * 0x16345785d8a0000).toString(16);
|
|
55
10
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return {
|
|
59
|
-
...createExternalIndex(field, index),
|
|
60
|
-
rebuild(items) {
|
|
61
|
-
index.clear();
|
|
62
|
-
items.forEach((item, i) => {
|
|
63
|
-
const value = serializeValue(get(item, field));
|
|
64
|
-
const current = index.get(value) || /* @__PURE__ */ new Set();
|
|
65
|
-
current.add(i);
|
|
66
|
-
index.set(value, current);
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
export {
|
|
72
|
-
createExternalIndex,
|
|
73
|
-
createIndex as default
|
|
74
|
-
};
|
|
11
|
+
//#endregion
|
|
12
|
+
export { randomId as default };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region src/utils/serializeValue.ts
|
|
2
|
+
/**
|
|
3
|
+
* Serializes a value into a string representation.
|
|
4
|
+
* Handles various types, including strings, numbers, booleans, dates, and objects.
|
|
5
|
+
* Falls back to JSON stringification for unsupported types.
|
|
6
|
+
* @param value - The value to serialize.
|
|
7
|
+
* - Strings are returned as-is.
|
|
8
|
+
* - Numbers and booleans are converted to their string representation.
|
|
9
|
+
* - Dates are converted to ISO string format.
|
|
10
|
+
* - Other values are stringified using `JSON.stringify`.
|
|
11
|
+
* @returns A string representation of the value.
|
|
12
|
+
*/
|
|
13
|
+
function serializeValue(value) {
|
|
14
|
+
if (value == null) return null;
|
|
15
|
+
if (typeof value === "string") return value;
|
|
16
|
+
if (typeof value === "number") return value.toString();
|
|
17
|
+
if (typeof value === "boolean") return value.toString();
|
|
18
|
+
if (value instanceof Date) return value.toISOString();
|
|
19
|
+
return JSON.stringify(value);
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
exports.default = serializeValue;
|
package/dist/index15.mjs
CHANGED
|
@@ -1,11 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
//#region src/utils/serializeValue.ts
|
|
2
|
+
/**
|
|
3
|
+
* Serializes a value into a string representation.
|
|
4
|
+
* Handles various types, including strings, numbers, booleans, dates, and objects.
|
|
5
|
+
* Falls back to JSON stringification for unsupported types.
|
|
6
|
+
* @param value - The value to serialize.
|
|
7
|
+
* - Strings are returned as-is.
|
|
8
|
+
* - Numbers and booleans are converted to their string representation.
|
|
9
|
+
* - Dates are converted to ISO string format.
|
|
10
|
+
* - Other values are stringified using `JSON.stringify`.
|
|
11
|
+
* @returns A string representation of the value.
|
|
12
|
+
*/
|
|
13
|
+
function serializeValue(value) {
|
|
14
|
+
if (value == null) return null;
|
|
15
|
+
if (typeof value === "string") return value;
|
|
16
|
+
if (typeof value === "number") return value.toString();
|
|
17
|
+
if (typeof value === "boolean") return value.toString();
|
|
18
|
+
if (value instanceof Date) return value.toISOString();
|
|
19
|
+
return JSON.stringify(value);
|
|
8
20
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
21
|
+
//#endregion
|
|
22
|
+
export { serializeValue 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/index16.mjs
CHANGED
|
@@ -1,28 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
+
};
|
|
25
31
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
};
|
|
32
|
+
//#endregion
|
|
33
|
+
export { createSignal as default };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/utils/intersection.ts
|
|
2
|
+
/**
|
|
3
|
+
* Computes the intersection of multiple arrays, returning an array of unique elements
|
|
4
|
+
* that are present in all the input arrays.
|
|
5
|
+
* @template T - The type of elements in the arrays.
|
|
6
|
+
* @param arrays - A variable number of arrays to compute the intersection of.
|
|
7
|
+
* @returns An array containing the unique elements found in all the input arrays.
|
|
8
|
+
* - If no arrays are provided, returns an empty array.
|
|
9
|
+
*/
|
|
10
|
+
function intersection(...arrays) {
|
|
11
|
+
if (arrays.length === 0) return [];
|
|
12
|
+
return [...new Set(arrays.reduce((a, b) => a.filter((c) => b.includes(c))))];
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
exports.default = intersection;
|