@instantdb/core 0.22.86-experimental.split-store.20249342206.1 → 0.22.86-experimental.split-store.20250097559.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instantdb/core",
3
- "version": "0.22.86-experimental.split-store.20249342206.1",
3
+ "version": "0.22.86-experimental.split-store.20250097559.1",
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.86-experimental.split-store.20249342206.1"
56
+ "@instantdb/version": "0.22.86-experimental.split-store.20250097559.1"
57
57
  },
58
58
  "scripts": {
59
59
  "test": "vitest",
package/src/Reactor.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import weakHash from './utils/weakHash.ts';
3
3
  import instaql from './instaql.ts';
4
4
  import * as instaml from './instaml.ts';
5
- import * as sts from './store.ts';
5
+ import * as s from './store.ts';
6
6
  import uuid from './utils/uuid.ts';
7
7
  import IndexedDBStorage from './IndexedDBStorage.ts';
8
8
  import WindowNetworkListener from './WindowNetworkListener.js';
@@ -118,13 +118,13 @@ function querySubFromStorage(x, useDateObjects) {
118
118
  const v = typeof x === 'string' ? JSON.parse(x) : x;
119
119
 
120
120
  if (v?.result?.store) {
121
- const attrsStore = sts.attrsStoreFromJSON(
121
+ const attrsStore = s.attrsStoreFromJSON(
122
122
  v.result.attrsStore,
123
123
  v.result.store,
124
124
  );
125
125
  if (attrsStore) {
126
126
  const storeJSON = v.result.store;
127
- v.result.store = sts.fromJSON(attrsStore, {
127
+ v.result.store = s.fromJSON(attrsStore, {
128
128
  ...storeJSON,
129
129
  useDateObjects: useDateObjects,
130
130
  });
@@ -150,7 +150,7 @@ function querySubToStorage(_key, sub) {
150
150
  /** @type {import('./reactorTypes.ts').QuerySubResultInStorage} */
151
151
  const jsonResult = {
152
152
  ...result,
153
- store: sts.toJSON(result.store),
153
+ store: s.toJSON(result.store),
154
154
  attrsStore: result.attrsStore.toJSON(),
155
155
  };
156
156
 
@@ -203,7 +203,7 @@ function sortedMutationEntries(entries) {
203
203
  * @template {import('./presence.ts').RoomSchemaShape} [RoomSchema = {}]
204
204
  */
205
205
  export default class Reactor {
206
- /** @type {sts.AttrsStore | undefined} */
206
+ /** @type {s.AttrsStore | undefined} */
207
207
  attrs;
208
208
  _isOnline = true;
209
209
  _isShutdown = false;
@@ -335,7 +335,7 @@ export default class Reactor {
335
335
  },
336
336
  this._log,
337
337
  (triples) => {
338
- return sts.createStore(
338
+ return s.createStore(
339
339
  this.ensureAttrs(),
340
340
  triples,
341
341
  this.config.enableCardinalityInference,
@@ -589,7 +589,7 @@ export default class Reactor {
589
589
  const aggregate = result?.[0]?.data?.['aggregate'];
590
590
  const triples = extractTriples(result);
591
591
  const attrsStore = this.ensureAttrs();
592
- const store = sts.createStore(
592
+ const store = s.createStore(
593
593
  attrsStore,
594
594
  triples,
595
595
  enableCardinalityInference,
@@ -663,7 +663,7 @@ export default class Reactor {
663
663
  const hash = weakHash(q);
664
664
  const triples = extractTriples(result);
665
665
  const attrsStore = this.ensureAttrs();
666
- const store = sts.createStore(
666
+ const store = s.createStore(
667
667
  attrsStore,
668
668
  triples,
669
669
  enableCardinalityInference,
@@ -746,7 +746,6 @@ export default class Reactor {
746
746
  if (newAttrs.length) {
747
747
  const existingAttrs = Object.values(this.ensureAttrs().attrs);
748
748
  this._setAttrs([...existingAttrs, ...newAttrs]);
749
- this._setAttrs(newAttrs);
750
749
  }
751
750
 
752
751
  this._finishTransaction('synced', eventId);
@@ -931,7 +930,7 @@ export default class Reactor {
931
930
  }
932
931
 
933
932
  _setAttrs(attrs) {
934
- this.attrs = new sts.AttrsStoreClass(
933
+ this.attrs = new s.AttrsStoreClass(
935
934
  attrs.reduce((acc, attr) => {
936
935
  acc[attr.id] = attr;
937
936
  return acc;
@@ -1088,7 +1087,7 @@ export default class Reactor {
1088
1087
  // server attr-ids.
1089
1088
  /**
1090
1089
  *
1091
- * @param {sts.AttrsStore} attrs
1090
+ * @param {s.AttrsStore} attrs
1092
1091
  * @param {any} muts
1093
1092
  * @param {number} [processedTxId]
1094
1093
  */
@@ -1097,12 +1096,12 @@ export default class Reactor {
1097
1096
  if (!muts) return new Map();
1098
1097
  const findExistingAttr = (attr) => {
1099
1098
  const [_, etype, label] = attr['forward-identity'];
1100
- const existing = sts.getAttrByFwdIdentName(attrs, etype, label);
1099
+ const existing = s.getAttrByFwdIdentName(attrs, etype, label);
1101
1100
  return existing;
1102
1101
  };
1103
1102
  const findReverseAttr = (attr) => {
1104
1103
  const [_, etype, label] = attr['forward-identity'];
1105
- const revAttr = sts.getAttrByReverseIdentName(attrs, etype, label);
1104
+ const revAttr = s.getAttrByReverseIdentName(attrs, etype, label);
1106
1105
  return revAttr;
1107
1106
  };
1108
1107
  const mapping = { attrIdMap: {}, refSwapAttrIds: new Set() };
@@ -1180,7 +1179,7 @@ export default class Reactor {
1180
1179
  // Transact
1181
1180
 
1182
1181
  /**
1183
- * @returns {sts.AttrsStore}
1182
+ * @returns {s.AttrsStore}
1184
1183
  */
1185
1184
  optimisticAttrs() {
1186
1185
  const pendingMutationSteps = [...this._pendingMutations().values()] // hack due to Map()
@@ -1207,7 +1206,7 @@ export default class Reactor {
1207
1206
  }
1208
1207
 
1209
1208
  if (!deletedAttrIds.size && !pendingAttrs.length) {
1210
- return this.attrs || new sts.AttrsStoreClass({}, this._linkIndex);
1209
+ return this.attrs || new s.AttrsStoreClass({}, this._linkIndex);
1211
1210
  }
1212
1211
 
1213
1212
  const attrs = { ...(this.attrs?.attrs || {}) };
@@ -1218,7 +1217,7 @@ export default class Reactor {
1218
1217
  delete attrs[id];
1219
1218
  }
1220
1219
 
1221
- return new sts.AttrsStoreClass(attrs, this._linkIndex);
1220
+ return new s.AttrsStoreClass(attrs, this._linkIndex);
1222
1221
  }
1223
1222
 
1224
1223
  /** Runs instaql on a query and a store */
@@ -1264,7 +1263,7 @@ export default class Reactor {
1264
1263
  _applyOptimisticUpdates(store, attrsStore, mutations, processedTxId) {
1265
1264
  for (const [_, mut] of mutations) {
1266
1265
  if (!mut['tx-id'] || (processedTxId && mut['tx-id'] > processedTxId)) {
1267
- const result = sts.transact(store, attrsStore, mut['tx-steps']);
1266
+ const result = s.transact(store, attrsStore, mut['tx-steps']);
1268
1267
  store = result.store;
1269
1268
  attrsStore = result.attrsStore;
1270
1269
  }
package/src/store.ts CHANGED
@@ -519,6 +519,7 @@ function mergeTriple(store: Store, attrsStore: AttrsStore, rawTriple: Triple) {
519
519
  ];
520
520
 
521
521
  setInMap(store.eav, [eid, aid], new Map([[updatedValue, enhancedTriple]]));
522
+ setInMap(store.aev, [aid, eid], new Map([[updatedValue, enhancedTriple]]));
522
523
  }
523
524
 
524
525
  function deleteEntity(store: Store, attrsStore: AttrsStore, args: any[]) {