@instantdb/core 0.22.92 → 0.22.93
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/commonjs/Reactor.d.ts.map +1 -1
- package/dist/commonjs/SyncTable.d.ts.map +1 -1
- package/dist/commonjs/SyncTable.js +7 -6
- package/dist/commonjs/SyncTable.js.map +1 -1
- package/dist/esm/Reactor.d.ts.map +1 -1
- package/dist/esm/SyncTable.d.ts.map +1 -1
- package/dist/esm/SyncTable.js +7 -6
- package/dist/esm/SyncTable.js.map +1 -1
- package/dist/standalone/index.js +6 -6
- package/dist/standalone/index.umd.cjs +1 -1
- package/package.json +2 -2
- package/src/SyncTable.ts +18 -14
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instantdb/core",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.93",
|
|
4
4
|
"description": "Instant's core local abstraction",
|
|
5
5
|
"homepage": "https://github.com/instantdb/instant/tree/main/client/packages/core",
|
|
6
6
|
"repository": {
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"mutative": "^1.0.10",
|
|
55
55
|
"uuid": "^11.1.0",
|
|
56
|
-
"@instantdb/version": "0.22.
|
|
56
|
+
"@instantdb/version": "0.22.93"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|
|
59
59
|
"test": "vitest",
|
package/src/SyncTable.ts
CHANGED
|
@@ -199,20 +199,18 @@ function applyChangesToStore(
|
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
201
|
|
|
202
|
+
type ChangedFieldsOfChanges = {
|
|
203
|
+
[eid: string]: { [field: string]: { oldValue: unknown; newValue: unknown } };
|
|
204
|
+
};
|
|
205
|
+
|
|
202
206
|
function changedFieldsOfChanges(
|
|
203
207
|
store: s.Store,
|
|
204
208
|
attrsStore: s.AttrsStore,
|
|
205
209
|
changes: SyncUpdateTriplesMsg['txes'][number]['changes'],
|
|
206
|
-
): {
|
|
207
|
-
[eid: string]: SyncTransaction<
|
|
208
|
-
any,
|
|
209
|
-
any,
|
|
210
|
-
any
|
|
211
|
-
>['updated'][number]['changedFields'];
|
|
212
|
-
} {
|
|
210
|
+
): ChangedFieldsOfChanges {
|
|
213
211
|
// This will be more complicated when we include links, we can either add a
|
|
214
212
|
// changedLinks field or we can have something like 'bookshelves.title`
|
|
215
|
-
const changedFields = {};
|
|
213
|
+
const changedFields: ChangedFieldsOfChanges = {};
|
|
216
214
|
for (const { action, triple } of changes) {
|
|
217
215
|
const [e, a, v] = triple;
|
|
218
216
|
const field = attrsStore.getAttr(a)?.['forward-identity']?.[2];
|
|
@@ -222,7 +220,6 @@ function changedFieldsOfChanges(
|
|
|
222
220
|
changedFields[e] = fields;
|
|
223
221
|
|
|
224
222
|
const oldNew = fields[field] ?? {};
|
|
225
|
-
fields[field] = oldNew;
|
|
226
223
|
|
|
227
224
|
switch (action) {
|
|
228
225
|
case 'added':
|
|
@@ -235,12 +232,15 @@ function changedFieldsOfChanges(
|
|
|
235
232
|
}
|
|
236
233
|
break;
|
|
237
234
|
}
|
|
235
|
+
|
|
236
|
+
fields[field] = oldNew;
|
|
238
237
|
}
|
|
239
238
|
|
|
240
|
-
for (const
|
|
241
|
-
const { oldValue, newValue }
|
|
242
|
-
|
|
243
|
-
|
|
239
|
+
for (const [_eid, fields] of Object.entries(changedFields)) {
|
|
240
|
+
for (const [k, { oldValue, newValue }] of Object.entries(fields)) {
|
|
241
|
+
if (oldValue === newValue) {
|
|
242
|
+
delete fields[k];
|
|
243
|
+
}
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
246
|
return changedFields;
|
|
@@ -783,7 +783,11 @@ export class SyncTable {
|
|
|
783
783
|
updated.push({
|
|
784
784
|
oldEntity: ent.entity,
|
|
785
785
|
newEntity: entity,
|
|
786
|
-
changedFields: changedFields || {}
|
|
786
|
+
changedFields: (changedFields || {}) as SyncTransaction<
|
|
787
|
+
any,
|
|
788
|
+
any,
|
|
789
|
+
any
|
|
790
|
+
>['updated'][number]['changedFields'],
|
|
787
791
|
});
|
|
788
792
|
ent.entity = entity;
|
|
789
793
|
} else {
|