@signaldb/core 2.0.0-beta.17 → 2.0.0-beta.19

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.
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "src/AsyncDataAdapter.ts": {
3
- "file": "index32.cjs.js",
3
+ "file": "index34.cjs.js",
4
4
  "name": "AsyncDataAdapter",
5
5
  "src": "src/AsyncDataAdapter.ts",
6
6
  "isDynamicEntry": true,
7
7
  "imports": [
8
8
  "src/getIndexInfo.ts",
9
9
  "src/utils/deepClone.ts",
10
- "src/utils/getMatchingKeys.ts",
10
+ "src/utils/idIndexQuery.ts",
11
11
  "src/utils/incrementalQueryUpdate.ts",
12
12
  "src/utils/isEqual.ts",
13
13
  "src/utils/match.ts",
@@ -15,24 +15,26 @@
15
15
  "src/utils/projectItems.ts",
16
16
  "src/utils/queryDelta.ts",
17
17
  "src/utils/queryId.ts",
18
- "src/utils/sortItems.ts"
18
+ "src/utils/sortItems.ts",
19
+ "src/utils/storageIndexQuery.ts"
19
20
  ]
20
21
  },
21
22
  "src/AutoFetchDataAdapter.ts": {
22
- "file": "index37.cjs.js",
23
+ "file": "index39.cjs.js",
23
24
  "name": "AutoFetchDataAdapter",
24
25
  "src": "src/AutoFetchDataAdapter.ts",
25
26
  "isDynamicEntry": true,
26
27
  "imports": [
27
28
  "src/getIndexInfo.ts",
28
29
  "src/utils/deepClone.ts",
29
- "src/utils/getMatchingKeys.ts",
30
+ "src/utils/idIndexQuery.ts",
30
31
  "src/utils/isEqual.ts",
31
32
  "src/utils/match.ts",
32
33
  "src/utils/modify.ts",
33
34
  "src/utils/project.ts",
34
35
  "src/utils/queryId.ts",
35
- "src/utils/sortItems.ts"
36
+ "src/utils/sortItems.ts",
37
+ "src/utils/storageIndexQuery.ts"
36
38
  ]
37
39
  },
38
40
  "src/Collection/Cursor.ts": {
@@ -56,7 +58,7 @@
56
58
  ]
57
59
  },
58
60
  "src/Collection/index.ts": {
59
- "file": "index28.cjs.js",
61
+ "file": "index29.cjs.js",
60
62
  "name": "Collection/index",
61
63
  "src": "src/Collection/index.ts",
62
64
  "isDynamicEntry": true,
@@ -73,7 +75,7 @@
73
75
  ]
74
76
  },
75
77
  "src/DefaultDataAdapter.ts": {
76
- "file": "index27.cjs.js",
78
+ "file": "index28.cjs.js",
77
79
  "name": "DefaultDataAdapter",
78
80
  "src": "src/DefaultDataAdapter.ts",
79
81
  "isDynamicEntry": true,
@@ -82,6 +84,7 @@
82
84
  "src/getIndexInfo.ts",
83
85
  "src/utils/EventEmitter.ts",
84
86
  "src/utils/deepClone.ts",
87
+ "src/utils/idIndexQuery.ts",
85
88
  "src/utils/incrementalQueryUpdate.ts",
86
89
  "src/utils/isEqual.ts",
87
90
  "src/utils/match.ts",
@@ -94,7 +97,7 @@
94
97
  ]
95
98
  },
96
99
  "src/WorkerDataAdapter.ts": {
97
- "file": "index34.cjs.js",
100
+ "file": "index36.cjs.js",
98
101
  "name": "WorkerDataAdapter",
99
102
  "src": "src/WorkerDataAdapter.ts",
100
103
  "isDynamicEntry": true,
@@ -110,7 +113,7 @@
110
113
  ]
111
114
  },
112
115
  "src/WorkerDataAdapterHost.ts": {
113
- "file": "index36.cjs.js",
116
+ "file": "index38.cjs.js",
114
117
  "name": "WorkerDataAdapterHost",
115
118
  "src": "src/WorkerDataAdapterHost.ts",
116
119
  "isDynamicEntry": true,
@@ -118,7 +121,7 @@
118
121
  "src/getIndexInfo.ts",
119
122
  "src/utils/compact.ts",
120
123
  "src/utils/deepClone.ts",
121
- "src/utils/getMatchingKeys.ts",
124
+ "src/utils/idIndexQuery.ts",
122
125
  "src/utils/incrementalQueryUpdate.ts",
123
126
  "src/utils/isEqual.ts",
124
127
  "src/utils/match.ts",
@@ -126,7 +129,8 @@
126
129
  "src/utils/projectItems.ts",
127
130
  "src/utils/queryDelta.ts",
128
131
  "src/utils/queryId.ts",
129
- "src/utils/sortItems.ts"
132
+ "src/utils/sortItems.ts",
133
+ "src/utils/storageIndexQuery.ts"
130
134
  ]
131
135
  },
132
136
  "src/createIndex.ts": {
@@ -148,13 +152,13 @@
148
152
  "isDynamicEntry": true
149
153
  },
150
154
  "src/createReactivityAdapter.ts": {
151
- "file": "index30.cjs.js",
155
+ "file": "index31.cjs.js",
152
156
  "name": "createReactivityAdapter",
153
157
  "src": "src/createReactivityAdapter.ts",
154
158
  "isDynamicEntry": true
155
159
  },
156
160
  "src/createStorageAdapter.ts": {
157
- "file": "index29.cjs.js",
161
+ "file": "index30.cjs.js",
158
162
  "name": "createStorageAdapter",
159
163
  "src": "src/createStorageAdapter.ts",
160
164
  "isDynamicEntry": true
@@ -199,13 +203,13 @@
199
203
  "isDynamicEntry": true
200
204
  },
201
205
  "src/utils/batchOnNextTick.ts": {
202
- "file": "index33.cjs.js",
206
+ "file": "index35.cjs.js",
203
207
  "name": "utils/batchOnNextTick",
204
208
  "src": "src/utils/batchOnNextTick.ts",
205
209
  "isDynamicEntry": true
206
210
  },
207
211
  "src/utils/compact.ts": {
208
- "file": "index35.cjs.js",
212
+ "file": "index37.cjs.js",
209
213
  "name": "utils/compact",
210
214
  "src": "src/utils/compact.ts",
211
215
  "isDynamicEntry": true
@@ -238,6 +242,15 @@
238
242
  "src/utils/serializeValue.ts"
239
243
  ]
240
244
  },
245
+ "src/utils/idIndexQuery.ts": {
246
+ "file": "index27.cjs.js",
247
+ "name": "utils/idIndexQuery",
248
+ "src": "src/utils/idIndexQuery.ts",
249
+ "isDynamicEntry": true,
250
+ "imports": [
251
+ "src/utils/isFieldExpression.ts"
252
+ ]
253
+ },
241
254
  "src/utils/incrementalQueryUpdate.ts": {
242
255
  "file": "index25.cjs.js",
243
256
  "name": "utils/incrementalQueryUpdate",
@@ -323,7 +336,7 @@
323
336
  "isDynamicEntry": true
324
337
  },
325
338
  "src/utils/reactiveOrAsync.ts": {
326
- "file": "index31.cjs.js",
339
+ "file": "index32.cjs.js",
327
340
  "name": "utils/reactiveOrAsync",
328
341
  "src": "src/utils/reactiveOrAsync.ts",
329
342
  "isDynamicEntry": true
@@ -349,6 +362,15 @@
349
362
  "src/utils/get.ts"
350
363
  ]
351
364
  },
365
+ "src/utils/storageIndexQuery.ts": {
366
+ "file": "index33.cjs.js",
367
+ "name": "utils/storageIndexQuery",
368
+ "src": "src/utils/storageIndexQuery.ts",
369
+ "isDynamicEntry": true,
370
+ "imports": [
371
+ "src/utils/getMatchingKeys.ts"
372
+ ]
373
+ },
352
374
  "src/utils/uniqueBy.ts": {
353
375
  "file": "index3.cjs.js",
354
376
  "name": "utils/uniqueBy",
@@ -42,10 +42,15 @@ export default class WorkerDataAdapter implements DataAdapter {
42
42
  private execInBackground;
43
43
  private queryItemsById;
44
44
  private flattenPendingWrites;
45
+ private static pushPendingEntry;
46
+ private static dropPendingEntry;
47
+ private static writeFlatEntry;
45
48
  private static providesFullItems;
46
49
  private observableItems;
47
50
  private observableItemsByIds;
48
51
  private servedResult;
52
+ private advanceServedResult;
53
+ private changesetForIds;
49
54
  private computeServedResult;
50
55
  /**
51
56
  * Registers a write's effect locally and notifies every active query it
package/dist/index.cjs.js CHANGED
@@ -6,15 +6,15 @@ const require_randomId = require("./index9.cjs.js");
6
6
  const require_get = require("./index11.cjs.js");
7
7
  const require_serializeValue = require("./index13.cjs.js");
8
8
  const require_modify = require("./index20.cjs.js");
9
- const require_DefaultDataAdapter = require("./index27.cjs.js");
10
- const require_index = require("./index28.cjs.js");
11
- const require_createStorageAdapter = require("./index29.cjs.js");
12
- const require_createReactivityAdapter = require("./index30.cjs.js");
13
- const require_reactiveOrAsync = require("./index31.cjs.js");
14
- const require_AsyncDataAdapter = require("./index32.cjs.js");
15
- const require_WorkerDataAdapter = require("./index34.cjs.js");
16
- const require_WorkerDataAdapterHost = require("./index36.cjs.js");
17
- const require_AutoFetchDataAdapter = require("./index37.cjs.js");
9
+ const require_DefaultDataAdapter = require("./index28.cjs.js");
10
+ const require_index = require("./index29.cjs.js");
11
+ const require_createStorageAdapter = require("./index30.cjs.js");
12
+ const require_createReactivityAdapter = require("./index31.cjs.js");
13
+ const require_reactiveOrAsync = require("./index32.cjs.js");
14
+ const require_AsyncDataAdapter = require("./index34.cjs.js");
15
+ const require_WorkerDataAdapter = require("./index36.cjs.js");
16
+ const require_WorkerDataAdapterHost = require("./index38.cjs.js");
17
+ const require_AutoFetchDataAdapter = require("./index39.cjs.js");
18
18
  exports.AsyncDataAdapter = require_AsyncDataAdapter.default;
19
19
  exports.AutoFetchDataAdapter = require_AutoFetchDataAdapter.default;
20
20
  exports.Collection = require_index.default;
package/dist/index.mjs CHANGED
@@ -5,13 +5,13 @@ import randomId from "./index9.mjs";
5
5
  import get from "./index11.mjs";
6
6
  import serializeValue from "./index13.mjs";
7
7
  import modify from "./index20.mjs";
8
- import DefaultDataAdapter from "./index27.mjs";
9
- import Collection from "./index28.mjs";
10
- import createStorageAdapter from "./index29.mjs";
11
- import createReactivityAdapter from "./index30.mjs";
12
- import reactiveOrAsync, { unwrap } from "./index31.mjs";
13
- import AsyncDataAdapter from "./index32.mjs";
14
- import WorkerDataAdapter from "./index34.mjs";
15
- import WorkerDataAdapterHost from "./index36.mjs";
16
- import AutoFetchDataAdapter from "./index37.mjs";
8
+ import DefaultDataAdapter from "./index28.mjs";
9
+ import Collection from "./index29.mjs";
10
+ import createStorageAdapter from "./index30.mjs";
11
+ import createReactivityAdapter from "./index31.mjs";
12
+ import reactiveOrAsync, { unwrap } from "./index32.mjs";
13
+ import AsyncDataAdapter from "./index34.mjs";
14
+ import WorkerDataAdapter from "./index36.mjs";
15
+ import WorkerDataAdapterHost from "./index38.mjs";
16
+ import AutoFetchDataAdapter from "./index39.mjs";
17
17
  export { AsyncDataAdapter, AutoFetchDataAdapter, Collection, Cursor, DefaultDataAdapter, EventEmitter, WorkerDataAdapter, WorkerDataAdapterHost, createReactivityAdapter, createStorageAdapter, get, isEqual, modify, randomId, reactiveOrAsync, serializeValue, unwrap };
@@ -105,11 +105,16 @@ function getIndexInfo(queryFunctions, selector) {
105
105
  let hasNonIndexField = false;
106
106
  const matchedBefore = matched;
107
107
  const idsBefore = ids;
108
+ let orIds = [];
109
+ let orMatched = false;
108
110
  const process$or = ($orNew) => {
109
111
  if (hasNonIndexField || $orNew && $orNew.length > 0) {
110
112
  newSelector.$or = $or;
111
113
  matched = matchedBefore;
112
114
  ids = idsBefore;
115
+ } else if (orMatched) {
116
+ ids = matchedBefore ? require_intersection.default(idsBefore, orIds) : orIds;
117
+ matched = true;
113
118
  }
114
119
  return {
115
120
  matched,
@@ -119,8 +124,8 @@ function getIndexInfo(queryFunctions, selector) {
119
124
  };
120
125
  const $orNewOrPromise = Array.isArray($or) ? optimizeLogicGate(queryFunctions, $or, (match, selIds) => {
121
126
  if (match) {
122
- ids = [...new Set([...ids, ...selIds])];
123
- matched = true;
127
+ orIds = [...new Set([...orIds, ...selIds])];
128
+ orMatched = true;
124
129
  } else hasNonIndexField = true;
125
130
  }) : void 0;
126
131
  if ($orNewOrPromise instanceof Promise) return $orNewOrPromise.then(($orNew) => process$or($orNew));
package/dist/index17.mjs CHANGED
@@ -105,11 +105,16 @@ function getIndexInfo(queryFunctions, selector) {
105
105
  let hasNonIndexField = false;
106
106
  const matchedBefore = matched;
107
107
  const idsBefore = ids;
108
+ let orIds = [];
109
+ let orMatched = false;
108
110
  const process$or = ($orNew) => {
109
111
  if (hasNonIndexField || $orNew && $orNew.length > 0) {
110
112
  newSelector.$or = $or;
111
113
  matched = matchedBefore;
112
114
  ids = idsBefore;
115
+ } else if (orMatched) {
116
+ ids = matchedBefore ? intersection(idsBefore, orIds) : orIds;
117
+ matched = true;
113
118
  }
114
119
  return {
115
120
  matched,
@@ -119,8 +124,8 @@ function getIndexInfo(queryFunctions, selector) {
119
124
  };
120
125
  const $orNewOrPromise = Array.isArray($or) ? optimizeLogicGate(queryFunctions, $or, (match, selIds) => {
121
126
  if (match) {
122
- ids = [...new Set([...ids, ...selIds])];
123
- matched = true;
127
+ orIds = [...new Set([...orIds, ...selIds])];
128
+ orMatched = true;
124
129
  } else hasNonIndexField = true;
125
130
  }) : void 0;
126
131
  if ($orNewOrPromise instanceof Promise) return $orNewOrPromise.then(($orNew) => process$or($orNew));