@signaldb/core 1.0.0 → 1.2.0
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/README.md +2 -2
- package/dist/.vite/manifest.json +78 -64
- package/dist/Collection/index.d.ts +39 -16
- package/dist/Collection/types.d.ts +1 -1
- package/dist/devtools.d.ts +4 -0
- package/dist/index.cjs.js +19 -11
- package/dist/index.cjs10.js +27 -6
- package/dist/index.cjs11.js +6 -3
- package/dist/index.cjs12.js +3 -35
- package/dist/index.cjs13.js +141 -16
- package/dist/index.cjs14.js +38 -5
- package/dist/index.cjs15.js +2 -42
- package/dist/index.cjs16.js +5 -11
- package/dist/index.cjs17.js +40 -17
- package/dist/index.cjs18.js +11 -245
- package/dist/index.cjs19.js +16 -67
- package/dist/index.cjs2.js +104 -615
- package/dist/index.cjs20.js +251 -67
- package/dist/index.cjs21.js +68 -8
- package/dist/index.cjs22.js +83 -22
- package/dist/index.cjs23.js +8 -135
- package/dist/index.cjs24.js +25 -16
- package/dist/index.cjs25.js +144 -5
- package/dist/index.cjs26.js +5 -17
- package/dist/index.cjs27.js +15 -21
- package/dist/index.cjs28.js +21 -39
- package/dist/index.cjs29.js +40 -27
- package/dist/index.cjs3.js +669 -136
- package/dist/index.cjs30.js +27 -7
- package/dist/index.cjs31.js +9 -0
- package/dist/index.cjs4.js +166 -63
- package/dist/index.cjs5.js +66 -3
- package/dist/index.cjs6.js +2 -2
- package/dist/index.cjs7.js +2 -2
- package/dist/index.cjs8.js +2 -2
- package/dist/index.cjs9.js +3 -28
- package/dist/index.d.ts +2 -0
- package/dist/index.mjs +20 -12
- package/dist/index10.mjs +27 -6
- package/dist/index11.mjs +6 -3
- package/dist/index12.mjs +3 -34
- package/dist/index13.mjs +141 -16
- package/dist/index14.mjs +37 -5
- package/dist/index15.mjs +2 -41
- package/dist/index16.mjs +5 -11
- package/dist/index17.mjs +39 -17
- package/dist/index18.mjs +11 -244
- package/dist/index19.mjs +16 -66
- package/dist/index2.mjs +80 -615
- package/dist/index20.mjs +251 -67
- package/dist/index21.mjs +67 -8
- package/dist/index22.mjs +82 -22
- package/dist/index23.mjs +8 -135
- package/dist/index24.mjs +25 -15
- package/dist/index25.mjs +144 -5
- package/dist/index26.mjs +5 -17
- package/dist/index27.mjs +15 -21
- package/dist/index28.mjs +21 -39
- package/dist/index29.mjs +40 -27
- package/dist/index3.mjs +669 -136
- package/dist/index30.mjs +27 -7
- package/dist/index31.mjs +10 -0
- package/dist/index4.mjs +166 -62
- package/dist/index5.mjs +65 -3
- package/dist/index6.mjs +2 -2
- package/dist/index7.mjs +2 -2
- package/dist/index8.mjs +2 -2
- package/dist/index9.mjs +3 -28
- package/dist/persistence/combinePersistenceAdapters.d.ts +7 -7
- package/dist/types/MemoryAdapter.d.ts +2 -2
- package/dist/utils/EventEmitter.d.ts +75 -0
- package/dist/utils/deepClone.d.ts +2 -2
- package/dist/utils/set.d.ts +2 -2
- package/dist/utils/uniqueBy.d.ts +2 -2
- package/package.json +1 -1
- package/dist/types/EventEmitter.d.ts +0 -25
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<p align="center">
|
|
2
2
|
<a href="#">
|
|
3
|
-
<img src="/docs/public/logo.svg" width="150px" alt="SignalDB Logo" />
|
|
3
|
+
<img src="https://raw.githubusercontent.com/maxnowack/signaldb/refs/heads/main/docs/public/logo.svg" width="150px" alt="SignalDB Logo" />
|
|
4
4
|
</a>
|
|
5
5
|
</p>
|
|
6
6
|
|
|
@@ -63,6 +63,6 @@ See [Contributing.md](https://github.com/maxnowack/signaldb/blob/main/CONTRIBUTI
|
|
|
63
63
|
## Troubleshooting
|
|
64
64
|
|
|
65
65
|
If you encounter any issues, there are several ways to get support.
|
|
66
|
-
- Join our [Discord server](https://discord.gg/
|
|
66
|
+
- Join our [Discord server](https://discord.gg/qMvXKXxBTp).
|
|
67
67
|
- [Start a discussion](https://github.com/maxnowack/signaldb/discussions/new/choose)
|
|
68
68
|
- [Open an issue](https://github.com/maxnowack/signaldb/issues/new)
|
package/dist/.vite/manifest.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
"file": "index.
|
|
4
|
-
"name": "
|
|
5
|
-
"src": "
|
|
2
|
+
"__vite-browser-external": {
|
|
3
|
+
"file": "index.cjs15.js",
|
|
4
|
+
"name": "_virtual/__vite-browser-external",
|
|
5
|
+
"src": "__vite-browser-external",
|
|
6
|
+
"isDynamicEntry": true
|
|
6
7
|
},
|
|
7
8
|
"src/AutoFetchCollection.ts": {
|
|
8
|
-
"file": "index.
|
|
9
|
-
"name": "
|
|
9
|
+
"file": "index.cjs4.js",
|
|
10
|
+
"name": "AutoFetchCollection",
|
|
10
11
|
"src": "src/AutoFetchCollection.ts",
|
|
11
12
|
"imports": [
|
|
12
13
|
"src/ReplicatedCollection.ts",
|
|
@@ -14,8 +15,8 @@
|
|
|
14
15
|
]
|
|
15
16
|
},
|
|
16
17
|
"src/Collection/Cursor.ts": {
|
|
17
|
-
"file": "index.
|
|
18
|
-
"name": "
|
|
18
|
+
"file": "index.cjs20.js",
|
|
19
|
+
"name": "Collection/Cursor",
|
|
19
20
|
"src": "src/Collection/Cursor.ts",
|
|
20
21
|
"imports": [
|
|
21
22
|
"src/utils/sortItems.ts",
|
|
@@ -24,8 +25,8 @@
|
|
|
24
25
|
]
|
|
25
26
|
},
|
|
26
27
|
"src/Collection/Observer.ts": {
|
|
27
|
-
"file": "index.
|
|
28
|
-
"name": "
|
|
28
|
+
"file": "index.cjs25.js",
|
|
29
|
+
"name": "Collection/Observer",
|
|
29
30
|
"src": "src/Collection/Observer.ts",
|
|
30
31
|
"imports": [
|
|
31
32
|
"src/utils/isEqual.ts",
|
|
@@ -33,8 +34,8 @@
|
|
|
33
34
|
]
|
|
34
35
|
},
|
|
35
36
|
"src/Collection/createIndex.ts": {
|
|
36
|
-
"file": "index.
|
|
37
|
-
"name": "
|
|
37
|
+
"file": "index.cjs14.js",
|
|
38
|
+
"name": "Collection/createIndex",
|
|
38
39
|
"src": "src/Collection/createIndex.ts",
|
|
39
40
|
"imports": [
|
|
40
41
|
"src/createIndexProvider.ts",
|
|
@@ -44,20 +45,19 @@
|
|
|
44
45
|
]
|
|
45
46
|
},
|
|
46
47
|
"src/Collection/getIndexInfo.ts": {
|
|
47
|
-
"file": "index.
|
|
48
|
-
"name": "
|
|
48
|
+
"file": "index.cjs21.js",
|
|
49
|
+
"name": "Collection/getIndexInfo",
|
|
49
50
|
"src": "src/Collection/getIndexInfo.ts",
|
|
50
51
|
"imports": [
|
|
51
|
-
"../../../node_modules/tslib/tslib.es6.mjs",
|
|
52
52
|
"src/utils/intersection.ts"
|
|
53
53
|
]
|
|
54
54
|
},
|
|
55
55
|
"src/Collection/index.ts": {
|
|
56
|
-
"file": "index.
|
|
57
|
-
"name": "
|
|
56
|
+
"file": "index.cjs3.js",
|
|
57
|
+
"name": "Collection/index",
|
|
58
58
|
"src": "src/Collection/index.ts",
|
|
59
59
|
"imports": [
|
|
60
|
-
"src/
|
|
60
|
+
"src/utils/EventEmitter.ts",
|
|
61
61
|
"src/utils/match.ts",
|
|
62
62
|
"src/utils/modify.ts",
|
|
63
63
|
"src/utils/isEqual.ts",
|
|
@@ -71,8 +71,8 @@
|
|
|
71
71
|
]
|
|
72
72
|
},
|
|
73
73
|
"src/ReplicatedCollection.ts": {
|
|
74
|
-
"file": "index.
|
|
75
|
-
"name": "
|
|
74
|
+
"file": "index.cjs22.js",
|
|
75
|
+
"name": "ReplicatedCollection",
|
|
76
76
|
"src": "src/ReplicatedCollection.ts",
|
|
77
77
|
"imports": [
|
|
78
78
|
"src/Collection/index.ts",
|
|
@@ -82,26 +82,39 @@
|
|
|
82
82
|
]
|
|
83
83
|
},
|
|
84
84
|
"src/createIndexProvider.ts": {
|
|
85
|
-
"file": "index.
|
|
86
|
-
"name": "
|
|
85
|
+
"file": "index.cjs6.js",
|
|
86
|
+
"name": "createIndexProvider",
|
|
87
87
|
"src": "src/createIndexProvider.ts"
|
|
88
88
|
},
|
|
89
89
|
"src/createMemoryAdapter.ts": {
|
|
90
|
-
"file": "index.
|
|
91
|
-
"name": "
|
|
90
|
+
"file": "index.cjs7.js",
|
|
91
|
+
"name": "createMemoryAdapter",
|
|
92
92
|
"src": "src/createMemoryAdapter.ts"
|
|
93
93
|
},
|
|
94
94
|
"src/createReactivityAdapter.ts": {
|
|
95
|
-
"file": "index.
|
|
96
|
-
"name": "
|
|
95
|
+
"file": "index.cjs9.js",
|
|
96
|
+
"name": "createReactivityAdapter",
|
|
97
97
|
"src": "src/createReactivityAdapter.ts"
|
|
98
98
|
},
|
|
99
|
+
"src/devtools.ts": {
|
|
100
|
+
"file": "index.cjs2.js",
|
|
101
|
+
"name": "devtools",
|
|
102
|
+
"src": "src/devtools.ts",
|
|
103
|
+
"imports": [
|
|
104
|
+
"src/Collection/index.ts"
|
|
105
|
+
],
|
|
106
|
+
"dynamicImports": [
|
|
107
|
+
"__vite-browser-external",
|
|
108
|
+
"__vite-browser-external"
|
|
109
|
+
]
|
|
110
|
+
},
|
|
99
111
|
"src/index.ts": {
|
|
100
112
|
"file": "index.cjs.js",
|
|
101
|
-
"name": "
|
|
113
|
+
"name": "index",
|
|
102
114
|
"src": "src/index.ts",
|
|
103
115
|
"isEntry": true,
|
|
104
116
|
"imports": [
|
|
117
|
+
"src/devtools.ts",
|
|
105
118
|
"src/Collection/index.ts",
|
|
106
119
|
"src/AutoFetchCollection.ts",
|
|
107
120
|
"src/persistence/combinePersistenceAdapters.ts",
|
|
@@ -112,45 +125,46 @@
|
|
|
112
125
|
"src/utils/isEqual.ts",
|
|
113
126
|
"src/utils/modify.ts",
|
|
114
127
|
"src/utils/randomId.ts",
|
|
128
|
+
"src/utils/EventEmitter.ts",
|
|
115
129
|
"src/Collection/createIndex.ts"
|
|
116
130
|
]
|
|
117
131
|
},
|
|
118
132
|
"src/persistence/combinePersistenceAdapters.ts": {
|
|
119
|
-
"file": "index.
|
|
120
|
-
"name": "
|
|
133
|
+
"file": "index.cjs5.js",
|
|
134
|
+
"name": "persistence/combinePersistenceAdapters",
|
|
121
135
|
"src": "src/persistence/combinePersistenceAdapters.ts",
|
|
122
136
|
"imports": [
|
|
123
137
|
"src/persistence/createPersistenceAdapter.ts"
|
|
124
138
|
]
|
|
125
139
|
},
|
|
126
140
|
"src/persistence/createPersistenceAdapter.ts": {
|
|
127
|
-
"file": "index.
|
|
128
|
-
"name": "
|
|
141
|
+
"file": "index.cjs8.js",
|
|
142
|
+
"name": "persistence/createPersistenceAdapter",
|
|
129
143
|
"src": "src/persistence/createPersistenceAdapter.ts"
|
|
130
144
|
},
|
|
131
|
-
"src/
|
|
145
|
+
"src/utils/EventEmitter.ts": {
|
|
132
146
|
"file": "index.cjs13.js",
|
|
133
|
-
"name": "
|
|
134
|
-
"src": "src/
|
|
147
|
+
"name": "utils/EventEmitter",
|
|
148
|
+
"src": "src/utils/EventEmitter.ts"
|
|
135
149
|
},
|
|
136
150
|
"src/utils/createSignal.ts": {
|
|
137
|
-
"file": "index.
|
|
138
|
-
"name": "
|
|
151
|
+
"file": "index.cjs19.js",
|
|
152
|
+
"name": "utils/createSignal",
|
|
139
153
|
"src": "src/utils/createSignal.ts"
|
|
140
154
|
},
|
|
141
155
|
"src/utils/deepClone.ts": {
|
|
142
|
-
"file": "index.
|
|
143
|
-
"name": "
|
|
156
|
+
"file": "index.cjs17.js",
|
|
157
|
+
"name": "utils/deepClone",
|
|
144
158
|
"src": "src/utils/deepClone.ts"
|
|
145
159
|
},
|
|
146
160
|
"src/utils/get.ts": {
|
|
147
|
-
"file": "index.
|
|
148
|
-
"name": "
|
|
161
|
+
"file": "index.cjs27.js",
|
|
162
|
+
"name": "utils/get",
|
|
149
163
|
"src": "src/utils/get.ts"
|
|
150
164
|
},
|
|
151
165
|
"src/utils/getMatchingKeys.ts": {
|
|
152
|
-
"file": "index.
|
|
153
|
-
"name": "
|
|
166
|
+
"file": "index.cjs28.js",
|
|
167
|
+
"name": "utils/getMatchingKeys",
|
|
154
168
|
"src": "src/utils/getMatchingKeys.ts",
|
|
155
169
|
"imports": [
|
|
156
170
|
"src/utils/isFieldExpression.ts",
|
|
@@ -158,33 +172,33 @@
|
|
|
158
172
|
]
|
|
159
173
|
},
|
|
160
174
|
"src/utils/intersection.ts": {
|
|
161
|
-
"file": "index.
|
|
162
|
-
"name": "
|
|
175
|
+
"file": "index.cjs26.js",
|
|
176
|
+
"name": "utils/intersection",
|
|
163
177
|
"src": "src/utils/intersection.ts"
|
|
164
178
|
},
|
|
165
179
|
"src/utils/isEqual.ts": {
|
|
166
|
-
"file": "index.
|
|
167
|
-
"name": "
|
|
180
|
+
"file": "index.cjs10.js",
|
|
181
|
+
"name": "utils/isEqual",
|
|
168
182
|
"src": "src/utils/isEqual.ts"
|
|
169
183
|
},
|
|
170
184
|
"src/utils/isFieldExpression.ts": {
|
|
171
|
-
"file": "index.
|
|
172
|
-
"name": "
|
|
185
|
+
"file": "index.cjs29.js",
|
|
186
|
+
"name": "utils/isFieldExpression",
|
|
173
187
|
"src": "src/utils/isFieldExpression.ts"
|
|
174
188
|
},
|
|
175
189
|
"src/utils/match.ts": {
|
|
176
|
-
"file": "index.
|
|
177
|
-
"name": "
|
|
190
|
+
"file": "index.cjs16.js",
|
|
191
|
+
"name": "utils/match",
|
|
178
192
|
"src": "src/utils/match.ts"
|
|
179
193
|
},
|
|
180
194
|
"src/utils/modify.ts": {
|
|
181
|
-
"file": "index.
|
|
182
|
-
"name": "
|
|
195
|
+
"file": "index.cjs11.js",
|
|
196
|
+
"name": "utils/modify",
|
|
183
197
|
"src": "src/utils/modify.ts"
|
|
184
198
|
},
|
|
185
199
|
"src/utils/project.ts": {
|
|
186
|
-
"file": "index.
|
|
187
|
-
"name": "
|
|
200
|
+
"file": "index.cjs24.js",
|
|
201
|
+
"name": "utils/project",
|
|
188
202
|
"src": "src/utils/project.ts",
|
|
189
203
|
"imports": [
|
|
190
204
|
"src/utils/get.ts",
|
|
@@ -192,31 +206,31 @@
|
|
|
192
206
|
]
|
|
193
207
|
},
|
|
194
208
|
"src/utils/randomId.ts": {
|
|
195
|
-
"file": "index.
|
|
196
|
-
"name": "
|
|
209
|
+
"file": "index.cjs12.js",
|
|
210
|
+
"name": "utils/randomId",
|
|
197
211
|
"src": "src/utils/randomId.ts"
|
|
198
212
|
},
|
|
199
213
|
"src/utils/serializeValue.ts": {
|
|
200
|
-
"file": "index.
|
|
201
|
-
"name": "
|
|
214
|
+
"file": "index.cjs18.js",
|
|
215
|
+
"name": "utils/serializeValue",
|
|
202
216
|
"src": "src/utils/serializeValue.ts"
|
|
203
217
|
},
|
|
204
218
|
"src/utils/set.ts": {
|
|
205
|
-
"file": "index.
|
|
206
|
-
"name": "
|
|
219
|
+
"file": "index.cjs30.js",
|
|
220
|
+
"name": "utils/set",
|
|
207
221
|
"src": "src/utils/set.ts"
|
|
208
222
|
},
|
|
209
223
|
"src/utils/sortItems.ts": {
|
|
210
|
-
"file": "index.
|
|
211
|
-
"name": "
|
|
224
|
+
"file": "index.cjs23.js",
|
|
225
|
+
"name": "utils/sortItems",
|
|
212
226
|
"src": "src/utils/sortItems.ts",
|
|
213
227
|
"imports": [
|
|
214
228
|
"src/utils/get.ts"
|
|
215
229
|
]
|
|
216
230
|
},
|
|
217
231
|
"src/utils/uniqueBy.ts": {
|
|
218
|
-
"file": "index.
|
|
219
|
-
"name": "
|
|
232
|
+
"file": "index.cjs31.js",
|
|
233
|
+
"name": "utils/uniqueBy",
|
|
220
234
|
"src": "src/utils/uniqueBy.ts"
|
|
221
235
|
}
|
|
222
236
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type MemoryAdapter from '../types/MemoryAdapter';
|
|
2
2
|
import type ReactivityAdapter from '../types/ReactivityAdapter';
|
|
3
3
|
import type PersistenceAdapter from '../types/PersistenceAdapter';
|
|
4
|
-
import EventEmitter from '../
|
|
4
|
+
import EventEmitter from '../utils/EventEmitter';
|
|
5
5
|
import type Selector from '../types/Selector';
|
|
6
6
|
import type Modifier from '../types/Modifier';
|
|
7
7
|
import type IndexProvider from '../types/IndexProvider';
|
|
@@ -12,6 +12,7 @@ export type { CursorOptions } from './Cursor';
|
|
|
12
12
|
export type { ObserveCallbacks } from './Observer';
|
|
13
13
|
export { default as createIndex } from './createIndex';
|
|
14
14
|
export interface CollectionOptions<T extends BaseItem<I>, I, U = T> {
|
|
15
|
+
name?: string;
|
|
15
16
|
memory?: MemoryAdapter;
|
|
16
17
|
reactivity?: ReactivityAdapter;
|
|
17
18
|
transform?: Transform<T, U>;
|
|
@@ -21,9 +22,9 @@ export interface CollectionOptions<T extends BaseItem<I>, I, U = T> {
|
|
|
21
22
|
fieldTracking?: boolean;
|
|
22
23
|
}
|
|
23
24
|
interface CollectionEvents<T extends BaseItem, U = T> {
|
|
24
|
-
added: (item: T) => void;
|
|
25
|
-
changed: (item: T, modifier: Modifier<T>) => void;
|
|
26
|
-
removed: (item: T) => void;
|
|
25
|
+
'added': (item: T) => void;
|
|
26
|
+
'changed': (item: T, modifier: Modifier<T>) => void;
|
|
27
|
+
'removed': (item: T) => void;
|
|
27
28
|
'persistence.init': () => void;
|
|
28
29
|
'persistence.error': (error: Error) => void;
|
|
29
30
|
'persistence.transmitted': () => void;
|
|
@@ -34,14 +35,14 @@ interface CollectionEvents<T extends BaseItem, U = T> {
|
|
|
34
35
|
'persistence.pushCompleted': () => void;
|
|
35
36
|
'observer.created': <O extends FindOptions<T>>(selector?: Selector<T>, options?: O) => void;
|
|
36
37
|
'observer.disposed': <O extends FindOptions<T>>(selector?: Selector<T>, options?: O) => void;
|
|
37
|
-
getItems: (selector: Selector<T> | undefined) => void;
|
|
38
|
-
find: <O extends FindOptions<T>>(selector: Selector<T> | undefined, options: O | undefined, cursor: Cursor<T, U>) => void;
|
|
39
|
-
findOne: <O extends FindOptions<T>>(selector: Selector<T>, options: O | undefined, item: U | undefined) => void;
|
|
40
|
-
insert: (item: Omit<T, 'id'> & Partial<Pick<T, 'id'>>) => void;
|
|
41
|
-
updateOne: (selector: Selector<T>, modifier: Modifier<T>) => void;
|
|
42
|
-
updateMany: (selector: Selector<T>, modifier: Modifier<T>) => void;
|
|
43
|
-
removeOne: (selector: Selector<T>) => void;
|
|
44
|
-
removeMany: (selector: Selector<T>) => void;
|
|
38
|
+
'getItems': (selector: Selector<T> | undefined) => void;
|
|
39
|
+
'find': <O extends FindOptions<T>>(selector: Selector<T> | undefined, options: O | undefined, cursor: Cursor<T, U>) => void;
|
|
40
|
+
'findOne': <O extends FindOptions<T>>(selector: Selector<T>, options: O | undefined, item: U | undefined) => void;
|
|
41
|
+
'insert': (item: Omit<T, 'id'> & Partial<Pick<T, 'id'>>) => void;
|
|
42
|
+
'updateOne': (selector: Selector<T>, modifier: Modifier<T>) => void;
|
|
43
|
+
'updateMany': (selector: Selector<T>, modifier: Modifier<T>) => void;
|
|
44
|
+
'removeOne': (selector: Selector<T>) => void;
|
|
45
|
+
'removeMany': (selector: Selector<T>) => void;
|
|
45
46
|
'_debug.getItems': (callstack: string, selector: Selector<T> | undefined, measuredTime: number) => void;
|
|
46
47
|
'_debug.find': <O extends FindOptions<T>>(callstack: string, selector: Selector<T> | undefined, options: O | undefined, cursor: Cursor<T, U>) => void;
|
|
47
48
|
'_debug.findOne': <O extends FindOptions<T>>(callstack: string, selector: Selector<T>, options: O | undefined, item: U | undefined) => void;
|
|
@@ -60,10 +61,15 @@ interface CollectionEvents<T extends BaseItem, U = T> {
|
|
|
60
61
|
* @template U - The transformed item type after applying transformations (default is T).
|
|
61
62
|
*/
|
|
62
63
|
export default class Collection<T extends BaseItem<I> = BaseItem, I = any, U = T> extends EventEmitter<CollectionEvents<T, U>> {
|
|
63
|
-
static collections
|
|
64
|
-
static debugMode
|
|
65
|
-
static batchOperationInProgress
|
|
66
|
-
static fieldTracking
|
|
64
|
+
private static collections;
|
|
65
|
+
private static debugMode;
|
|
66
|
+
private static batchOperationInProgress;
|
|
67
|
+
private static fieldTracking;
|
|
68
|
+
private static onCreationCallbacks;
|
|
69
|
+
private static onDisposeCallbacks;
|
|
70
|
+
static getCollections(): Collection<any, any, any>[];
|
|
71
|
+
static onCreation(callback: (collection: Collection<any>) => void): void;
|
|
72
|
+
static onDispose(callback: (collection: Collection<any>) => void): void;
|
|
67
73
|
/**
|
|
68
74
|
* Enables debug mode for all collections.
|
|
69
75
|
*/
|
|
@@ -81,6 +87,7 @@ export default class Collection<T extends BaseItem<I> = BaseItem, I = any, U = T
|
|
|
81
87
|
* @param callback - The batch operation to execute.
|
|
82
88
|
*/
|
|
83
89
|
static batch(callback: () => void): void;
|
|
90
|
+
readonly name: string;
|
|
84
91
|
private options;
|
|
85
92
|
private persistenceAdapter;
|
|
86
93
|
private isPullingSignal;
|
|
@@ -93,6 +100,7 @@ export default class Collection<T extends BaseItem<I> = BaseItem, I = any, U = T
|
|
|
93
100
|
private isDisposed;
|
|
94
101
|
private postBatchCallbacks;
|
|
95
102
|
private fieldTracking;
|
|
103
|
+
private persistenceReadyPromise;
|
|
96
104
|
/**
|
|
97
105
|
* Initializes a new instance of the `Collection` class with optional configuration.
|
|
98
106
|
* Sets up memory, persistence, reactivity, and indices as specified in the options.
|
|
@@ -100,6 +108,7 @@ export default class Collection<T extends BaseItem<I> = BaseItem, I = any, U = T
|
|
|
100
108
|
* @template I - The type of the unique identifier for the items.
|
|
101
109
|
* @template U - The transformed item type after applying transformations (default is T).
|
|
102
110
|
* @param options - Optional configuration for the collection.
|
|
111
|
+
* @param options.name - An optional name for the collection.
|
|
103
112
|
* @param options.memory - The in-memory adapter for storing items.
|
|
104
113
|
* @param options.reactivity - The reactivity adapter for observing changes in the collection.
|
|
105
114
|
* @param options.transform - A transformation function to apply to items when retrieving them.
|
|
@@ -146,6 +155,20 @@ export default class Collection<T extends BaseItem<I> = BaseItem, I = any, U = T
|
|
|
146
155
|
* @param enable - A boolean indicating whether to enable (`true`) or disable (`false`) field tracking.
|
|
147
156
|
*/
|
|
148
157
|
setFieldTracking(enable: boolean): void;
|
|
158
|
+
/**
|
|
159
|
+
* Resolves when the persistence adapter finished initializing
|
|
160
|
+
* and the collection is ready to be used.
|
|
161
|
+
* @returns A promise that resolves when the collection is ready.
|
|
162
|
+
* @example
|
|
163
|
+
* ```ts
|
|
164
|
+
* const collection = new Collection({
|
|
165
|
+
* persistence: // ...
|
|
166
|
+
* })
|
|
167
|
+
* await collection.isReady()
|
|
168
|
+
*
|
|
169
|
+
* collection.insert({ name: 'Item 1' })
|
|
170
|
+
*/
|
|
171
|
+
isReady(): Promise<void>;
|
|
149
172
|
private profile;
|
|
150
173
|
private executeInDebugMode;
|
|
151
174
|
private rebuildIndices;
|
|
@@ -2,7 +2,7 @@ import type ReactivityAdapter from '../types/ReactivityAdapter';
|
|
|
2
2
|
export type BaseItem<I = any> = {
|
|
3
3
|
id: I;
|
|
4
4
|
} & Record<string, any>;
|
|
5
|
-
export type Transform<T, U = T> = ((
|
|
5
|
+
export type Transform<T, U = T> = ((document: T) => U) | null | undefined;
|
|
6
6
|
export type SortSpecifier<T> = {
|
|
7
7
|
[P in keyof T]?: -1 | 1;
|
|
8
8
|
} & Record<string, -1 | 1>;
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
3
|
+
const devtools = require("./index.cjs2.js");
|
|
4
|
+
const index = require("./index.cjs3.js");
|
|
5
|
+
const AutoFetchCollection = require("./index.cjs4.js");
|
|
6
|
+
const combinePersistenceAdapters = require("./index.cjs5.js");
|
|
7
|
+
const createIndexProvider = require("./index.cjs6.js");
|
|
8
|
+
const createMemoryAdapter = require("./index.cjs7.js");
|
|
9
|
+
const createPersistenceAdapter = require("./index.cjs8.js");
|
|
10
|
+
const createReactivityAdapter = require("./index.cjs9.js");
|
|
11
|
+
const isEqual = require("./index.cjs10.js");
|
|
12
|
+
const modify = require("./index.cjs11.js");
|
|
13
|
+
const randomId = require("./index.cjs12.js");
|
|
14
|
+
const EventEmitter = require("./index.cjs13.js");
|
|
15
|
+
const createIndex = require("./index.cjs14.js");
|
|
16
|
+
/* istanbul ignore if -- @preserve */
|
|
17
|
+
if (process.env.NODE_ENV !== "production") {
|
|
18
|
+
devtools();
|
|
19
|
+
}
|
|
20
|
+
exports.loadDeveloperTools = devtools;
|
|
14
21
|
exports.Collection = index.default;
|
|
15
22
|
exports.AutoFetchCollection = AutoFetchCollection;
|
|
16
23
|
exports.combinePersistenceAdapters = combinePersistenceAdapters.default;
|
|
@@ -21,4 +28,5 @@ exports.createReactivityAdapter = createReactivityAdapter;
|
|
|
21
28
|
exports.isEqual = isEqual;
|
|
22
29
|
exports.modify = modify;
|
|
23
30
|
exports.randomId = randomId;
|
|
31
|
+
exports.EventEmitter = EventEmitter;
|
|
24
32
|
exports.createIndex = createIndex.default;
|
package/dist/index.cjs10.js
CHANGED
|
@@ -1,8 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
function isEqual(a, b) {
|
|
3
|
+
if (Object.is(a, b))
|
|
4
|
+
return true;
|
|
5
|
+
if (a instanceof RegExp && b instanceof RegExp)
|
|
6
|
+
return a.toString() === b.toString();
|
|
7
|
+
if (a instanceof Date && b instanceof Date)
|
|
8
|
+
return a.getTime() === b.getTime();
|
|
9
|
+
if (typeof a !== "object")
|
|
10
|
+
return false;
|
|
11
|
+
if (typeof b !== "object")
|
|
12
|
+
return false;
|
|
13
|
+
if (a === null)
|
|
14
|
+
return false;
|
|
15
|
+
if (b === null)
|
|
16
|
+
return false;
|
|
17
|
+
const aKeys = Object.keys(a);
|
|
18
|
+
const bKeys = Object.keys(b);
|
|
19
|
+
if (aKeys.length !== bKeys.length)
|
|
20
|
+
return false;
|
|
21
|
+
for (const key of aKeys) {
|
|
22
|
+
if (!bKeys.includes(key))
|
|
23
|
+
return false;
|
|
24
|
+
if (!isEqual(a[key], b[key]))
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
return true;
|
|
7
28
|
}
|
|
8
|
-
module.exports =
|
|
29
|
+
module.exports = isEqual;
|
package/dist/index.cjs11.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
const mingo = require("mingo");
|
|
3
|
+
function modify(item, modifier) {
|
|
4
|
+
const clonedItem = { ...item };
|
|
5
|
+
mingo.update(clonedItem, modifier);
|
|
6
|
+
return clonedItem;
|
|
4
7
|
}
|
|
5
|
-
module.exports =
|
|
8
|
+
module.exports = modify;
|
package/dist/index.cjs12.js
CHANGED
|
@@ -1,37 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const get = require("./index.cjs26.js");
|
|
5
|
-
const getMatchingKeys = require("./index.cjs27.js");
|
|
6
|
-
const serializeValue = require("./index.cjs16.js");
|
|
7
|
-
function createExternalIndex(field, index) {
|
|
8
|
-
return createIndexProvider({
|
|
9
|
-
query(selector) {
|
|
10
|
-
const keys = getMatchingKeys(field, selector);
|
|
11
|
-
if (keys == null)
|
|
12
|
-
return { matched: false };
|
|
13
|
-
const itemPositions = keys.reduce((memo, key) => [...memo, ...index.get(key) || []], []);
|
|
14
|
-
return {
|
|
15
|
-
matched: true,
|
|
16
|
-
positions: itemPositions,
|
|
17
|
-
fields: [field]
|
|
18
|
-
};
|
|
19
|
-
},
|
|
20
|
-
rebuild() {
|
|
21
|
-
}
|
|
22
|
-
});
|
|
2
|
+
function randomId() {
|
|
3
|
+
return Math.floor(Math.random() * 1e17).toString(16);
|
|
23
4
|
}
|
|
24
|
-
|
|
25
|
-
const index = /* @__PURE__ */ new Map();
|
|
26
|
-
return Object.assign(Object.assign({}, createExternalIndex(field, index)), { rebuild(items) {
|
|
27
|
-
index.clear();
|
|
28
|
-
items.forEach((item, i) => {
|
|
29
|
-
const value = serializeValue(get(item, field));
|
|
30
|
-
const current = index.get(value) || /* @__PURE__ */ new Set();
|
|
31
|
-
current.add(i);
|
|
32
|
-
index.set(value, current);
|
|
33
|
-
});
|
|
34
|
-
} });
|
|
35
|
-
}
|
|
36
|
-
exports.createExternalIndex = createExternalIndex;
|
|
37
|
-
exports.default = createIndex;
|
|
5
|
+
module.exports = randomId;
|