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