@signaldb/core 2.0.0-beta.2 → 2.0.0-beta.21
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 +183 -80
- package/dist/AsyncDataAdapter.d.ts +53 -7
- package/dist/AutoFetchDataAdapter.d.ts +4 -6
- package/dist/Collection/Cursor.d.ts +56 -4
- package/dist/Collection/Observer.d.ts +33 -0
- package/dist/Collection/index.d.ts +66 -19
- package/dist/Collection/types.d.ts +9 -2
- package/dist/DataAdapter.d.ts +24 -6
- package/dist/DefaultDataAdapter.d.ts +5 -5
- package/dist/WorkerDataAdapter.d.ts +57 -5
- package/dist/WorkerDataAdapterHost.d.ts +9 -7
- package/dist/createIndex.d.ts +2 -2
- package/dist/createIndexProvider.d.ts +2 -2
- package/dist/createReactivityAdapter.d.ts +2 -2
- package/dist/createStorageAdapter.d.ts +1 -1
- package/dist/getIndexInfo.d.ts +3 -4
- package/dist/index.cjs.js +33 -31
- package/dist/index.d.ts +6 -1
- package/dist/index.mjs +17 -32
- package/dist/index10.cjs.js +11 -0
- package/dist/index10.mjs +10 -18
- package/dist/index11.cjs.js +23 -0
- package/dist/index11.mjs +22 -15
- package/dist/index12.cjs.js +45 -0
- package/dist/index12.mjs +44 -353
- package/dist/index13.cjs.js +22 -0
- package/dist/index13.mjs +21 -419
- package/dist/index14.cjs.js +45 -0
- package/dist/index14.mjs +44 -206
- package/dist/index15.cjs.js +86 -0
- package/dist/index15.mjs +85 -388
- package/dist/index16.cjs.js +15 -0
- package/dist/index16.mjs +14 -579
- package/dist/index17.cjs.js +141 -0
- package/dist/index17.mjs +140 -152
- package/dist/index18.cjs.js +47 -0
- package/dist/index18.mjs +46 -26
- package/dist/index19.cjs.js +15 -0
- package/dist/index19.mjs +14 -41
- package/dist/index2.cjs.js +33 -0
- package/dist/index2.mjs +32 -258
- package/dist/index20.cjs.js +23 -0
- package/dist/index20.mjs +22 -16
- package/dist/index21.cjs.js +37 -0
- package/dist/index21.mjs +36 -104
- package/dist/index22.cjs.js +35 -0
- package/dist/index22.mjs +34 -128
- package/dist/index23.cjs.js +21 -0
- package/dist/index23.mjs +20 -7
- package/dist/index24.cjs.js +19 -0
- package/dist/index24.mjs +18 -27
- package/dist/index25.cjs.js +157 -0
- package/dist/index25.mjs +156 -11
- package/dist/index26.cjs.js +38 -0
- package/dist/index26.mjs +37 -29
- package/dist/index27.cjs.js +42 -0
- package/dist/index27.mjs +41 -46
- package/dist/index28.cjs.js +347 -0
- package/dist/index28.mjs +345 -7
- package/dist/index29.cjs.js +602 -0
- package/dist/index29.mjs +601 -7
- package/dist/index3.cjs.js +19 -0
- package/dist/index3.mjs +18 -556
- package/dist/index30.cjs.js +11 -0
- package/dist/index30.mjs +10 -42
- package/dist/index31.cjs.js +11 -0
- package/dist/index31.mjs +10 -29
- package/dist/index32.cjs.js +90 -0
- package/dist/index32.mjs +89 -10
- package/dist/index33.cjs.js +53 -0
- package/dist/index33.mjs +52 -5
- package/dist/index34.cjs.js +453 -0
- package/dist/index34.mjs +453 -0
- package/dist/index35.cjs.js +72 -0
- package/dist/index35.mjs +72 -0
- package/dist/index36.cjs.js +580 -0
- package/dist/index36.mjs +580 -0
- package/dist/index37.cjs.js +21 -0
- package/dist/index37.mjs +21 -0
- package/dist/index38.cjs.js +363 -0
- package/dist/index38.mjs +363 -0
- package/dist/index39.cjs.js +513 -0
- package/dist/index39.mjs +513 -0
- package/dist/index4.cjs.js +209 -0
- package/dist/index4.mjs +204 -5
- package/dist/index5.cjs.js +187 -0
- package/dist/index5.mjs +186 -5
- package/dist/index6.cjs.js +303 -0
- package/dist/index6.mjs +301 -28
- package/dist/index7.cjs.js +125 -0
- package/dist/index7.mjs +124 -12
- package/dist/index8.cjs.js +33 -0
- package/dist/index8.mjs +32 -5
- package/dist/index9.cjs.js +12 -0
- package/dist/index9.mjs +11 -133
- package/dist/types/IndexProvider.d.ts +2 -2
- package/dist/types/Modifier.d.ts +1 -1
- package/dist/types/ReactivityAdapter.d.ts +1 -1
- package/dist/types/StorageAdapter.d.ts +9 -1
- package/dist/utils/applyQueryOptions.d.ts +15 -0
- package/dist/utils/createSignal.d.ts +2 -2
- package/dist/utils/getMatchingKeys.d.ts +2 -2
- package/dist/utils/idIndexQuery.d.ts +20 -0
- package/dist/utils/incrementalQueryUpdate.d.ts +62 -0
- package/dist/utils/isFieldExpression.d.ts +1 -1
- package/dist/utils/match.d.ts +1 -1
- package/dist/utils/modify.d.ts +1 -1
- package/dist/utils/projectItems.d.ts +12 -0
- package/dist/utils/queryDelta.d.ts +83 -0
- package/dist/utils/queryId.d.ts +2 -2
- package/dist/utils/reactiveOrAsync.d.ts +59 -0
- package/dist/utils/storageIndexQuery.d.ts +20 -0
- package/package.json +1 -1
- package/dist/index.cjs10.js +0 -18
- package/dist/index.cjs11.js +0 -15
- package/dist/index.cjs12.js +0 -353
- package/dist/index.cjs13.js +0 -419
- package/dist/index.cjs14.js +0 -206
- package/dist/index.cjs15.js +0 -388
- package/dist/index.cjs16.js +0 -579
- package/dist/index.cjs17.js +0 -152
- package/dist/index.cjs18.js +0 -26
- package/dist/index.cjs19.js +0 -42
- package/dist/index.cjs2.js +0 -259
- package/dist/index.cjs20.js +0 -16
- package/dist/index.cjs21.js +0 -104
- package/dist/index.cjs22.js +0 -129
- package/dist/index.cjs23.js +0 -7
- package/dist/index.cjs24.js +0 -27
- package/dist/index.cjs25.js +0 -10
- package/dist/index.cjs26.js +0 -29
- package/dist/index.cjs27.js +0 -46
- package/dist/index.cjs28.js +0 -8
- package/dist/index.cjs29.js +0 -7
- package/dist/index.cjs3.js +0 -557
- package/dist/index.cjs30.js +0 -42
- package/dist/index.cjs31.js +0 -29
- package/dist/index.cjs32.js +0 -9
- package/dist/index.cjs33.js +0 -5
- package/dist/index.cjs4.js +0 -5
- package/dist/index.cjs5.js +0 -5
- package/dist/index.cjs6.js +0 -29
- package/dist/index.cjs7.js +0 -12
- package/dist/index.cjs8.js +0 -5
- package/dist/index.cjs9.js +0 -133
package/dist/index.cjs22.js
DELETED
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
-
const intersection = require("./index.cjs29.js");
|
|
4
|
-
function getMergedIndexInfo(queryFunctions, selector) {
|
|
5
|
-
return queryFunctions.reduce((memoOrPromise, queryFunction) => {
|
|
6
|
-
const resultOrPromise = queryFunction(selector);
|
|
7
|
-
const processResult = (memo2, result) => {
|
|
8
|
-
if (!result.matched)
|
|
9
|
-
return memo2;
|
|
10
|
-
const optimizedSelector = result.keepSelector ? memo2.optimizedSelector : Object.fromEntries(Object.entries(memo2.optimizedSelector).filter(([key]) => !result.fields.includes(key)));
|
|
11
|
-
return {
|
|
12
|
-
matched: true,
|
|
13
|
-
ids: [...new Set(memo2.matched ? intersection(memo2.ids, result.ids) : result.ids)],
|
|
14
|
-
optimizedSelector
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
if (resultOrPromise instanceof Promise) {
|
|
18
|
-
return resultOrPromise.then(async (result) => {
|
|
19
|
-
const memo2 = memoOrPromise instanceof Promise ? await memoOrPromise : memoOrPromise;
|
|
20
|
-
return processResult(memo2, result);
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
const memo = memoOrPromise;
|
|
24
|
-
if (memo instanceof Promise)
|
|
25
|
-
throw new Error("Mixing async and sync index providers is not supported");
|
|
26
|
-
return processResult(memo, resultOrPromise);
|
|
27
|
-
}, {
|
|
28
|
-
matched: false,
|
|
29
|
-
ids: [],
|
|
30
|
-
optimizedSelector: { ...selector }
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
function optimizeLogicGate(queryFunctions, logicGate, idsCallback) {
|
|
34
|
-
return logicGate.reduce((memoOrPromise, sel) => {
|
|
35
|
-
const getSelector = (indexInfo) => {
|
|
36
|
-
const { matched: selMatched, ids: selIds, optimizedSelector: optimizedSelector2 } = indexInfo;
|
|
37
|
-
if (selMatched) {
|
|
38
|
-
idsCallback(true, selIds);
|
|
39
|
-
if (Object.keys(optimizedSelector2).length > 0) {
|
|
40
|
-
return optimizedSelector2;
|
|
41
|
-
}
|
|
42
|
-
} else {
|
|
43
|
-
idsCallback(false, []);
|
|
44
|
-
return sel;
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
const indexInfoOrPromise = getIndexInfo(queryFunctions, sel);
|
|
48
|
-
if (indexInfoOrPromise instanceof Promise) {
|
|
49
|
-
return indexInfoOrPromise.then(async (indexInfo) => {
|
|
50
|
-
const memo2 = memoOrPromise instanceof Promise ? await memoOrPromise : memoOrPromise;
|
|
51
|
-
const optimizedSelector2 = getSelector(indexInfo);
|
|
52
|
-
if (optimizedSelector2)
|
|
53
|
-
memo2.push(optimizedSelector2);
|
|
54
|
-
return memo2;
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
const memo = memoOrPromise;
|
|
58
|
-
if (memo instanceof Promise)
|
|
59
|
-
throw new Error("Mixing async and sync index providers is not supported");
|
|
60
|
-
const optimizedSelector = getSelector(indexInfoOrPromise);
|
|
61
|
-
if (optimizedSelector)
|
|
62
|
-
memo.push(optimizedSelector);
|
|
63
|
-
return memo;
|
|
64
|
-
}, []);
|
|
65
|
-
}
|
|
66
|
-
function getIndexInfo(queryFunctions, selector) {
|
|
67
|
-
if (selector == null || Object.keys(selector).length <= 0) {
|
|
68
|
-
return {
|
|
69
|
-
matched: false,
|
|
70
|
-
ids: [],
|
|
71
|
-
optimizedSelector: selector
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
const { $and, $or, ...rest } = selector;
|
|
75
|
-
const flatInfoOrPromise = getMergedIndexInfo(queryFunctions, rest);
|
|
76
|
-
const processFlatInfo = (flatInfo) => {
|
|
77
|
-
let { matched, ids } = flatInfo;
|
|
78
|
-
const newSelector = flatInfo.optimizedSelector;
|
|
79
|
-
const $andNewOrPromise = Array.isArray($and) ? optimizeLogicGate(queryFunctions, $and, (match, selIds) => {
|
|
80
|
-
if (!match)
|
|
81
|
-
return;
|
|
82
|
-
ids = matched ? intersection(ids, selIds) : selIds;
|
|
83
|
-
matched = true;
|
|
84
|
-
}) : void 0;
|
|
85
|
-
const process$and = ($andNew) => {
|
|
86
|
-
if ($andNew && $andNew.length > 0)
|
|
87
|
-
newSelector.$and = $andNew;
|
|
88
|
-
let hasNonIndexField = false;
|
|
89
|
-
const matchedBefore = matched;
|
|
90
|
-
const idsBefore = ids;
|
|
91
|
-
const process$or = ($orNew) => {
|
|
92
|
-
if ($orNew && $orNew.length > 0)
|
|
93
|
-
newSelector.$or = $orNew;
|
|
94
|
-
if (hasNonIndexField) {
|
|
95
|
-
newSelector.$or = $or;
|
|
96
|
-
matched = matchedBefore;
|
|
97
|
-
ids = idsBefore;
|
|
98
|
-
}
|
|
99
|
-
return {
|
|
100
|
-
matched,
|
|
101
|
-
ids: ids || [],
|
|
102
|
-
optimizedSelector: newSelector
|
|
103
|
-
};
|
|
104
|
-
};
|
|
105
|
-
const $orNewOrPromise = Array.isArray($or) ? optimizeLogicGate(queryFunctions, $or, (match, selIds) => {
|
|
106
|
-
if (match) {
|
|
107
|
-
ids = [.../* @__PURE__ */ new Set([...ids, ...selIds])];
|
|
108
|
-
matched = true;
|
|
109
|
-
} else {
|
|
110
|
-
hasNonIndexField = true;
|
|
111
|
-
}
|
|
112
|
-
}) : void 0;
|
|
113
|
-
if ($orNewOrPromise instanceof Promise) {
|
|
114
|
-
return $orNewOrPromise.then(($orNew) => process$or($orNew));
|
|
115
|
-
}
|
|
116
|
-
return process$or($orNewOrPromise);
|
|
117
|
-
};
|
|
118
|
-
if ($andNewOrPromise instanceof Promise) {
|
|
119
|
-
return $andNewOrPromise.then(($andNew) => process$and($andNew));
|
|
120
|
-
}
|
|
121
|
-
return process$and($andNewOrPromise);
|
|
122
|
-
};
|
|
123
|
-
if (flatInfoOrPromise instanceof Promise) {
|
|
124
|
-
return flatInfoOrPromise.then(processFlatInfo);
|
|
125
|
-
}
|
|
126
|
-
return processFlatInfo(flatInfoOrPromise);
|
|
127
|
-
}
|
|
128
|
-
exports.default = getIndexInfo;
|
|
129
|
-
exports.getMergedIndexInfo = getMergedIndexInfo;
|
package/dist/index.cjs23.js
DELETED
package/dist/index.cjs24.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const get = require("./index.cjs10.js");
|
|
3
|
-
const set = require("./index.cjs31.js");
|
|
4
|
-
function project(item, fields) {
|
|
5
|
-
const allFieldsDeactivated = Object.values(fields).every((value) => value === 0);
|
|
6
|
-
if (allFieldsDeactivated) {
|
|
7
|
-
const result2 = { ...item };
|
|
8
|
-
Object.keys(fields).forEach((key) => {
|
|
9
|
-
const fieldValue = get(item, key);
|
|
10
|
-
if (fieldValue === void 0)
|
|
11
|
-
return;
|
|
12
|
-
set(result2, key, void 0, true);
|
|
13
|
-
});
|
|
14
|
-
return result2;
|
|
15
|
-
}
|
|
16
|
-
const result = {};
|
|
17
|
-
Object.entries(fields).forEach(([key, value]) => {
|
|
18
|
-
const fieldValue = get(item, key);
|
|
19
|
-
if (fieldValue === void 0)
|
|
20
|
-
return;
|
|
21
|
-
if (fieldValue == null && value !== 1)
|
|
22
|
-
return;
|
|
23
|
-
set(result, key, value === 1 ? fieldValue : void 0);
|
|
24
|
-
});
|
|
25
|
-
return result;
|
|
26
|
-
}
|
|
27
|
-
module.exports = project;
|
package/dist/index.cjs25.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const fastSort = require("fast-sort");
|
|
3
|
-
const get = require("./index.cjs10.js");
|
|
4
|
-
function sortItems(items, sortFields) {
|
|
5
|
-
return fastSort.sort(items).by(Object.entries(sortFields).map(([key, value]) => {
|
|
6
|
-
const order = value === 1 ? "asc" : "desc";
|
|
7
|
-
return { [order]: (i) => get(i, key) };
|
|
8
|
-
}));
|
|
9
|
-
}
|
|
10
|
-
module.exports = sortItems;
|
package/dist/index.cjs26.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const isFieldExpression = require("./index.cjs30.js");
|
|
3
|
-
const serializeValue = require("./index.cjs11.js");
|
|
4
|
-
function getMatchingKeys(field, selector) {
|
|
5
|
-
const result = { include: null, exclude: null };
|
|
6
|
-
const fieldSelector = selector[field];
|
|
7
|
-
if (fieldSelector instanceof RegExp)
|
|
8
|
-
return result;
|
|
9
|
-
if (fieldSelector == null)
|
|
10
|
-
return result;
|
|
11
|
-
if (isFieldExpression(fieldSelector)) {
|
|
12
|
-
if (fieldSelector.$ne != null) {
|
|
13
|
-
result.exclude = [serializeValue(fieldSelector.$ne)];
|
|
14
|
-
return result;
|
|
15
|
-
}
|
|
16
|
-
if (Array.isArray(fieldSelector.$in) && fieldSelector.$in.length > 0) {
|
|
17
|
-
result.include = fieldSelector.$in.map(serializeValue);
|
|
18
|
-
return result;
|
|
19
|
-
}
|
|
20
|
-
if (Array.isArray(fieldSelector.$nin) && fieldSelector.$nin.length > 0) {
|
|
21
|
-
result.exclude = fieldSelector.$nin.map(serializeValue);
|
|
22
|
-
return result;
|
|
23
|
-
}
|
|
24
|
-
return { include: null, exclude: null };
|
|
25
|
-
}
|
|
26
|
-
result.include = [serializeValue(fieldSelector)];
|
|
27
|
-
return result;
|
|
28
|
-
}
|
|
29
|
-
module.exports = getMatchingKeys;
|
package/dist/index.cjs27.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
function batchOnNextTick(onFlush) {
|
|
3
|
-
const queues = /* @__PURE__ */ new Map();
|
|
4
|
-
function enqueue(key, args) {
|
|
5
|
-
return new Promise((resolve, reject) => {
|
|
6
|
-
let q = queues.get(key);
|
|
7
|
-
if (!q) {
|
|
8
|
-
q = {
|
|
9
|
-
timer: null,
|
|
10
|
-
items: [],
|
|
11
|
-
flush: () => flush(key)
|
|
12
|
-
};
|
|
13
|
-
queues.set(key, q);
|
|
14
|
-
}
|
|
15
|
-
q.items.push({ args, resolve, reject });
|
|
16
|
-
if (q.timer == null) {
|
|
17
|
-
q.timer = setTimeout(() => {
|
|
18
|
-
q.timer = null;
|
|
19
|
-
void q.flush();
|
|
20
|
-
}, 0);
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
async function flush(key) {
|
|
25
|
-
const q = queues.get(key);
|
|
26
|
-
if (!q || q.items.length === 0)
|
|
27
|
-
return;
|
|
28
|
-
if (q.timer != null) {
|
|
29
|
-
clearTimeout(q.timer);
|
|
30
|
-
q.timer = null;
|
|
31
|
-
}
|
|
32
|
-
const items = q.items.splice(0);
|
|
33
|
-
onFlush(key, items.map((i) => i.args)).then((results) => {
|
|
34
|
-
for (const [index, result] of results.entries()) {
|
|
35
|
-
const { resolve } = items[index];
|
|
36
|
-
resolve(result);
|
|
37
|
-
}
|
|
38
|
-
}).catch((error) => {
|
|
39
|
-
for (const { reject } of items) {
|
|
40
|
-
reject(error);
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
return { enqueue, flush };
|
|
45
|
-
}
|
|
46
|
-
module.exports = batchOnNextTick;
|
package/dist/index.cjs28.js
DELETED