@instantdb/core 0.22.162 → 0.22.163

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.
@@ -41,7 +41,7 @@ const M = {
41
41
  mutable: "mutable",
42
42
  immutable: "immutable"
43
43
  }, Tt = {};
44
- function Ae(n, e) {
44
+ function ke(n, e) {
45
45
  return n instanceof Map ? n.has(e) : Object.prototype.hasOwnProperty.call(n, e);
46
46
  }
47
47
  function $t(n, e) {
@@ -88,7 +88,7 @@ function yn(n, e = []) {
88
88
  if (r !== null && r?.original !== n.original)
89
89
  return null;
90
90
  const s = n.parent.type === 3, i = s ? Array.from(n.parent.setMap.keys()).indexOf(n.key) : n.key;
91
- if (!(s && t.size > i || Ae(t, i)))
91
+ if (!(s && t.size > i || ke(t, i)))
92
92
  return null;
93
93
  e.push(i);
94
94
  }
@@ -192,15 +192,15 @@ function bn(n, e) {
192
192
  function U(n) {
193
193
  n.copy || (n.copy = bn(n.original, n.options));
194
194
  }
195
- function Te(n) {
195
+ function Se(n) {
196
196
  if (!J(n))
197
197
  return At(n);
198
198
  if (Array.isArray(n))
199
- return n.map(Te);
199
+ return n.map(Se);
200
200
  if (n instanceof Map) {
201
201
  const t = Array.from(n.entries()).map(([r, s]) => [
202
202
  r,
203
- Te(s)
203
+ Se(s)
204
204
  ]);
205
205
  if (!vt(n)) {
206
206
  const r = Object.getPrototypeOf(n).constructor;
@@ -209,7 +209,7 @@ function Te(n) {
209
209
  return new Map(t);
210
210
  }
211
211
  if (n instanceof Set) {
212
- const t = Array.from(n).map(Te);
212
+ const t = Array.from(n).map(Se);
213
213
  if (!St(n)) {
214
214
  const r = Object.getPrototypeOf(n).constructor;
215
215
  return new r(t);
@@ -218,11 +218,11 @@ function Te(n) {
218
218
  }
219
219
  const e = Object.create(Object.getPrototypeOf(n));
220
220
  for (const t in n)
221
- e[t] = Te(n[t]);
221
+ e[t] = Se(n[t]);
222
222
  return e;
223
223
  }
224
224
  function xe(n) {
225
- return de(n) ? Te(n) : n;
225
+ return de(n) ? Se(n) : n;
226
226
  }
227
227
  function X(n) {
228
228
  var e;
@@ -390,7 +390,7 @@ function ur(n, e, t, r, s) {
390
390
  }
391
391
  function lr({ original: n, copy: e, assignedMap: t }, r, s, i, o) {
392
392
  t.forEach((a, c) => {
393
- const u = se(n, c), l = xe(se(e, c)), f = a ? Ae(n, c) ? M.Replace : M.Add : M.Remove;
393
+ const u = se(n, c), l = xe(se(e, c)), f = a ? ke(n, c) ? M.Replace : M.Add : M.Remove;
394
394
  if (re(u, l) && f === M.Replace)
395
395
  return;
396
396
  const d = r.concat(c), h = le(d, o);
@@ -665,7 +665,7 @@ const hr = Reflect.ownKeys(Ne), mn = /* @__PURE__ */ new WeakSet(), wn = {
665
665
  if (u)
666
666
  return u.bind(n.proxy);
667
667
  }
668
- if (!Ae(a, e)) {
668
+ if (!ke(a, e)) {
669
669
  const u = $t(a, e);
670
670
  return u ? "value" in u ? u.value : (
671
671
  // !case: support for getter
@@ -701,7 +701,7 @@ const hr = Reflect.ownKeys(Ne), mn = /* @__PURE__ */ new WeakSet(), wn = {
701
701
  if (i?.set)
702
702
  return i.set.call(n.proxy, t), !0;
703
703
  const o = Ye(z(n), e), a = S(o);
704
- return a && re(a.original, t) ? (n.copy[e] = t, n.assignedMap = (r = n.assignedMap) !== null && r !== void 0 ? r : /* @__PURE__ */ new Map(), n.assignedMap.set(e, !1), !0) : (re(t, o) && (t !== void 0 || Ae(n.original, e)) || (U(n), X(n), Ae(n.original, e) && re(t, n.original[e]) ? n.assignedMap.delete(e) : n.assignedMap.set(e, !0), n.copy[e] = t, Ot(n, e, t, Ie)), !0);
704
+ return a && re(a.original, t) ? (n.copy[e] = t, n.assignedMap = (r = n.assignedMap) !== null && r !== void 0 ? r : /* @__PURE__ */ new Map(), n.assignedMap.set(e, !1), !0) : (re(t, o) && (t !== void 0 || ke(n.original, e)) || (U(n), X(n), ke(n.original, e) && re(t, n.original[e]) ? n.assignedMap.delete(e) : n.assignedMap.set(e, !0), n.copy[e] = t, Ot(n, e, t, Ie)), !0);
705
705
  },
706
706
  has(n, e) {
707
707
  return e in z(n);
@@ -945,7 +945,7 @@ function Ue(n, e) {
945
945
  ) : !1;
946
946
  }
947
947
  function Ct(n) {
948
- if (!Se(n))
948
+ if (!ve(n))
949
949
  return n;
950
950
  const e = {};
951
951
  for (const [t, r] of Object.entries(n))
@@ -953,7 +953,7 @@ function Ct(n) {
953
953
  return e;
954
954
  }
955
955
  function Sn(n, e) {
956
- if (!Se(n) || !Se(e))
956
+ if (!ve(n) || !ve(e))
957
957
  return e;
958
958
  const t = { ...n };
959
959
  for (const r of Object.keys(e)) {
@@ -962,12 +962,12 @@ function Sn(n, e) {
962
962
  delete t[r];
963
963
  continue;
964
964
  }
965
- const s = Se(n[r]) && Se(e[r]);
965
+ const s = ve(n[r]) && ve(e[r]);
966
966
  t[r] = s ? Sn(n[r], e[r]) : e[r];
967
967
  }
968
968
  return t;
969
969
  }
970
- function Se(n) {
970
+ function ve(n) {
971
971
  return typeof n == "object" && n !== null && !Array.isArray(n);
972
972
  }
973
973
  function gr(n, e, t) {
@@ -1428,7 +1428,7 @@ function Et(n) {
1428
1428
  function Mt(n) {
1429
1429
  return n["value-type"] === "blob";
1430
1430
  }
1431
- function _e(n, e) {
1431
+ function Te(n, e) {
1432
1432
  return e.reduce((t, r) => t && t.get(r), n);
1433
1433
  }
1434
1434
  function H(n, e) {
@@ -1486,7 +1486,7 @@ function In(n, e) {
1486
1486
  return new ie(e.attrs, e.linkIndex);
1487
1487
  }
1488
1488
  function Ur(n, e) {
1489
- return _e(n.eav, [e]) !== void 0;
1489
+ return Te(n.eav, [e]) !== void 0;
1490
1490
  }
1491
1491
  function be(n, e, t, r) {
1492
1492
  const s = An(
@@ -1533,7 +1533,7 @@ let Lr = 0;
1533
1533
  function En(n, e, t) {
1534
1534
  const [r, s, i] = t;
1535
1535
  let o;
1536
- const a = _e(n.eav, [r, s, i]);
1536
+ const a = Te(n.eav, [r, s, i]);
1537
1537
  return a && (o = a[3]), o || Date.now() * 10 + Lr++;
1538
1538
  }
1539
1539
  function Mn(n, e, t) {
@@ -1545,7 +1545,7 @@ function Mn(n, e, t) {
1545
1545
  if (!a)
1546
1546
  return;
1547
1547
  a["checked-data-type"] === "date" && n.useDateObjects && (o = We(o));
1548
- const u = _e(n.eav, [s, i, o])?.[3] ?? En(n, a, r), l = [s, i, o, u];
1548
+ const u = Te(n.eav, [s, i, o])?.[3] ?? En(n, a, r), l = [s, i, o, u];
1549
1549
  xr(a) ? (N(n.eav, [s, i], /* @__PURE__ */ new Map([[o, l]])), N(n.aev, [i, s], /* @__PURE__ */ new Map([[o, l]]))) : (N(n.eav, [s, i, o], l), N(n.aev, [i, s, o], l)), Et(a) && N(n.vae, [o, i, s], l);
1550
1550
  }
1551
1551
  function Fr(n, e, t) {
@@ -1556,7 +1556,7 @@ function Fr(n, e, t) {
1556
1556
  if (!a) return;
1557
1557
  if (!Mt(a))
1558
1558
  throw new Error("merge operation is not supported for links");
1559
- const c = _e(n.eav, [s, i]);
1559
+ const c = Te(n.eav, [s, i]);
1560
1560
  if (!c) return;
1561
1561
  const u = c.values().next()?.value;
1562
1562
  if (!u) return;
@@ -1773,7 +1773,7 @@ function Gr(n, e, t) {
1773
1773
  return;
1774
1774
  const [s, i, o] = r;
1775
1775
  if (e.getAttr(i))
1776
- return _e(n.eav, [s, i]);
1776
+ return Te(n.eav, [s, i]);
1777
1777
  }
1778
1778
  function Hr(n, e, t) {
1779
1779
  const r = t.filter(
@@ -1872,7 +1872,7 @@ function is(n, e, t) {
1872
1872
  return Vr(n, Pt(t, e));
1873
1873
  }
1874
1874
  const os = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;
1875
- function me(n) {
1875
+ function we(n) {
1876
1876
  return typeof n == "string" && os.test(n);
1877
1877
  }
1878
1878
  const D = [];
@@ -1938,13 +1938,13 @@ const ea = (n) => {
1938
1938
  Rn = n;
1939
1939
  };
1940
1940
  let gs = 0;
1941
- function ke(n) {
1941
+ function Oe(n) {
1942
1942
  return Ve(`_${n}`, gs++);
1943
1943
  }
1944
1944
  function Ve(n, e) {
1945
1945
  return `?${n}-${e}`;
1946
1946
  }
1947
- class we extends Error {
1947
+ class _e extends Error {
1948
1948
  constructor(e) {
1949
1949
  super(e), this.name = "AttrNotFoundError";
1950
1950
  }
@@ -1952,7 +1952,7 @@ class we extends Error {
1952
1952
  function ms(n, e) {
1953
1953
  const t = Dn(n, e);
1954
1954
  if (!t)
1955
- throw new we(`Could not find id attr for ${e}`);
1955
+ throw new _e(`Could not find id attr for ${e}`);
1956
1956
  return t;
1957
1957
  }
1958
1958
  function Wt(n, e, t, r) {
@@ -1972,19 +1972,19 @@ function _s(n, e, t) {
1972
1972
  function xn(n, e, t, r, s) {
1973
1973
  const i = P(e, t, s), o = he(e, t, s), a = i || o;
1974
1974
  if (!a)
1975
- throw new we(`Could not find attr for ${[t, s]}`);
1975
+ throw new _e(`Could not find attr for ${[t, s]}`);
1976
1976
  if (a["value-type"] !== "ref")
1977
1977
  throw new Error(`Attr ${a.id} is not a ref`);
1978
1978
  const [c, u] = a["forward-identity"], [l, f] = a["reverse-identity"], d = r + 1, h = i ? [
1979
1979
  n(u, r),
1980
1980
  a.id,
1981
1981
  n(f, d),
1982
- ke("time")
1982
+ Oe("time")
1983
1983
  ] : [
1984
1984
  n(u, d),
1985
1985
  a.id,
1986
1986
  n(f, r),
1987
- ke("time")
1987
+ Oe("time")
1988
1988
  ];
1989
1989
  return [i ? f : u, d, h, a, !!i];
1990
1990
  }
@@ -2068,28 +2068,28 @@ function Ss(n, e, t, r, s, i) {
2068
2068
  s
2069
2069
  ), c = o || a;
2070
2070
  if (!c)
2071
- throw new we(
2071
+ throw new _e(
2072
2072
  `No attr for etype = ${t} label = ${s}`
2073
2073
  );
2074
2074
  if (i?.hasOwnProperty("$isNull")) {
2075
2075
  const u = P(e, t, "id");
2076
2076
  if (!u)
2077
- throw new we(
2077
+ throw new _e(
2078
2078
  `No attr for etype = ${t} label = id`
2079
2079
  );
2080
2080
  return [
2081
2081
  n(t, r),
2082
2082
  u.id,
2083
2083
  { $isNull: { attrId: c.id, isNull: i.$isNull, reverse: !o } },
2084
- ke("time")
2084
+ Oe("time")
2085
2085
  ];
2086
2086
  }
2087
2087
  return o ? [
2088
2088
  n(t, r),
2089
2089
  c.id,
2090
2090
  Ts(c, i),
2091
- ke("time")
2092
- ] : [i, c.id, n(t, r), ke("time")];
2091
+ Oe("time")
2092
+ ] : [i, c.id, n(t, r), Oe("time")];
2093
2093
  }
2094
2094
  function vs(n, e, t, r, s) {
2095
2095
  const [i, o, a] = s.reduce(
@@ -2246,7 +2246,7 @@ function js(n, e, t, { etype: r, level: s, form: i }, o) {
2246
2246
  }), w = p ? b[0] : b;
2247
2247
  return { [h]: w };
2248
2248
  } catch (m) {
2249
- if (m instanceof we)
2249
+ if (m instanceof _e)
2250
2250
  return { [h]: p ? void 0 : [] };
2251
2251
  throw m;
2252
2252
  }
@@ -2258,11 +2258,11 @@ function js(n, e, t, { etype: r, level: s, form: i }, o) {
2258
2258
  function Ds(n, e, t) {
2259
2259
  return t === "string" ? bs(n, e) : n > e ? 1 : -1;
2260
2260
  }
2261
- function ve(n, e, t, r, s) {
2261
+ function Ae(n, e, t, r, s) {
2262
2262
  return e === r || e == null && r == null ? hs(n, t) : r == null ? 1 : e == null ? -1 : Ds(e, r, s);
2263
2263
  }
2264
2264
  function Ke([n, e], [t, r], s) {
2265
- return ve(n, e, t, r, s);
2265
+ return Ae(n, e, t, r, s);
2266
2266
  }
2267
2267
  function ft(n) {
2268
2268
  return n == null ? n : new Date(n).getTime();
@@ -2364,7 +2364,7 @@ function Ks(n, e, t) {
2364
2364
  try {
2365
2365
  return qs(n, e, t);
2366
2366
  } catch (r) {
2367
- if (r instanceof we)
2367
+ if (r instanceof _e)
2368
2368
  return {};
2369
2369
  throw r;
2370
2370
  }
@@ -2870,7 +2870,7 @@ function _i(n, e) {
2870
2870
  function Ht(n, e) {
2871
2871
  typeof requestIdleCallback > "u" ? n() : requestIdleCallback(n, { timeout: e });
2872
2872
  }
2873
- const Oe = "__meta";
2873
+ const ge = "__meta";
2874
2874
  class zn {
2875
2875
  constructor(e, t) {
2876
2876
  }
@@ -2907,7 +2907,7 @@ class gt {
2907
2907
  async _initMeta() {
2908
2908
  this._meta.loadingPromise && await this._meta.loadingPromise;
2909
2909
  try {
2910
- const e = this._persister.getItem(Oe);
2910
+ const e = this._persister.getItem(ge);
2911
2911
  this._meta.loadingPromise = e;
2912
2912
  const t = await e;
2913
2913
  this._meta.isLoading = !1, this._meta.error = null, this._meta.loadingPromise = null, this._meta.attempts = 0;
@@ -2994,7 +2994,7 @@ class gt {
2994
2994
  const d = this._persister.removeItem(f);
2995
2995
  t.push(d.then(() => 1)), this._loadedKeys.delete(f), this._pendingSaveKeys.delete(f);
2996
2996
  }
2997
- const a = [], c = [[Oe, s]], u = s.objects ?? {};
2997
+ const a = [], c = [[ge, s]], u = s.objects ?? {};
2998
2998
  s.objects = u;
2999
2999
  for (const f of o)
3000
3000
  if (this._loadedKeys.has(f)) {
@@ -3023,7 +3023,7 @@ class gt {
3023
3023
  if (!this._gcOpts)
3024
3024
  return;
3025
3025
  const e = new Set(await this._persister.getAllKeys());
3026
- e.delete(Oe);
3026
+ e.delete(ge);
3027
3027
  const t = new Set(Object.keys(this.currentValue));
3028
3028
  for (const d of Object.keys(this._loadingKeys))
3029
3029
  t.add(d);
@@ -3121,6 +3121,14 @@ class gt {
3121
3121
  this._subs = this._subs.filter((t) => t !== e);
3122
3122
  };
3123
3123
  }
3124
+ // Removes any keys that we haven't loaded--used when
3125
+ // changing users to make sure we clean out all user data
3126
+ async clearUnloadedKeys() {
3127
+ let e = !1;
3128
+ for (const t of await this._persister.getAllKeys())
3129
+ t === ge || t in this.currentValue || (this._pendingSaveKeys.add(t), e = !0);
3130
+ e && await this._enqueuePersist();
3131
+ }
3124
3132
  }
3125
3133
  const Ti = 6, Si = ["kv", "querySubs", "syncSubs"];
3126
3134
  function vi(n) {
@@ -3164,7 +3172,7 @@ async function ki(n, e, t) {
3164
3172
  const h = t.put(d, l);
3165
3173
  s.add(h);
3166
3174
  }
3167
- const c = { objects: a }, u = t.put(c, Oe);
3175
+ const c = { objects: a }, u = t.put(c, ge);
3168
3176
  s.add(u);
3169
3177
  for (const l of s)
3170
3178
  l.onsuccess = () => {
@@ -3215,7 +3223,7 @@ async function Oi(n, e) {
3215
3223
  };
3216
3224
  c.objects[l] = h;
3217
3225
  }
3218
- const u = Jt(Oe, c, i);
3226
+ const u = Jt(ge, c, i);
3219
3227
  a.push(u), await Promise.all(a), await new Promise((l, f) => {
3220
3228
  s.oncomplete = (d) => l(d), s.onerror = (d) => f(d), s.onabort = (d) => f(d);
3221
3229
  });
@@ -3632,7 +3640,7 @@ function mt(n) {
3632
3640
  link: t
3633
3641
  }, e), {});
3634
3642
  }
3635
- const Hn = "v0.22.162";
3643
+ const Hn = "v0.22.163";
3636
3644
  function Ni(n, e) {
3637
3645
  return {
3638
3646
  info: n ? (...t) => console.info(...t, e()) : () => {
@@ -3812,7 +3820,7 @@ const nn = [
3812
3820
  o
3813
3821
  );
3814
3822
  }
3815
- }, ge = (n, e, t, r, s) => {
3823
+ }, me = (n, e, t, r, s) => {
3816
3824
  const i = qi(t), o = t.valueType === "json";
3817
3825
  if (typeof n == "object" && n !== null && !Array.isArray(n)) {
3818
3826
  if (o)
@@ -3865,12 +3873,12 @@ const nn = [
3865
3873
  s
3866
3874
  );
3867
3875
  if (a === "id") {
3868
- if (typeof e == "string" && !me(e))
3876
+ if (typeof e == "string" && !we(e))
3869
3877
  throw new A(
3870
3878
  `Invalid value for id field in entity '${o}'. Expected a UUID, but received: ${e}`,
3871
3879
  s
3872
3880
  );
3873
- ge(
3881
+ me(
3874
3882
  e,
3875
3883
  n,
3876
3884
  new L("string", !1, !0),
@@ -3881,12 +3889,12 @@ const nn = [
3881
3889
  }
3882
3890
  const u = c.attrs[a];
3883
3891
  if (Object.keys(c.links).includes(a)) {
3884
- if (typeof e == "string" && !me(e))
3892
+ if (typeof e == "string" && !we(e))
3885
3893
  throw new A(
3886
3894
  `Invalid value for link '${a}' in entity '${o}'. Expected a UUID, but received: ${e}`,
3887
3895
  s
3888
3896
  );
3889
- ge(
3897
+ me(
3890
3898
  e,
3891
3899
  n,
3892
3900
  new L("string", !1, !0),
@@ -3902,7 +3910,7 @@ const nn = [
3902
3910
  s
3903
3911
  );
3904
3912
  }
3905
- ge(e, n, u, t, s);
3913
+ me(e, n, u, t, s);
3906
3914
  }, Yn = (n, e, t, r) => {
3907
3915
  for (const [s, i] of Object.entries(n)) {
3908
3916
  if (s === "or" || s === "and") {
@@ -3917,7 +3925,7 @@ const nn = [
3917
3925
  continue;
3918
3926
  }
3919
3927
  if (s === "id") {
3920
- ge(
3928
+ me(
3921
3929
  i,
3922
3930
  "id",
3923
3931
  new L("string", !1, !0),
@@ -3947,7 +3955,7 @@ const nn = [
3947
3955
  );
3948
3956
  }
3949
3957
  if (a)
3950
- ge(
3958
+ me(
3951
3959
  i,
3952
3960
  s,
3953
3961
  a,
@@ -3955,13 +3963,13 @@ const nn = [
3955
3963
  `${r}.${s}`
3956
3964
  );
3957
3965
  else if (c) {
3958
- if (typeof i == "string" && !me(i))
3966
+ if (typeof i == "string" && !we(i))
3959
3967
  throw new A(
3960
3968
  `Invalid value for link '${s}' in entity '${e}'. Expected a UUID, but received: ${i}`,
3961
3969
  `${r}.${s}`
3962
3970
  );
3963
3971
  const u = new L("string", !1, !0);
3964
- ge(
3972
+ me(
3965
3973
  i,
3966
3974
  s,
3967
3975
  u,
@@ -4084,7 +4092,7 @@ const nn = [
4084
4092
  );
4085
4093
  }
4086
4094
  }
4087
- }, sn = (n) => typeof n != "string" ? !1 : ze(n) ? !0 : me(n);
4095
+ }, sn = (n) => typeof n != "string" ? !1 : ze(n) ? !0 : we(n);
4088
4096
  class Q extends Error {
4089
4097
  constructor(e) {
4090
4098
  super(e), this.name = "TransactionValidationError";
@@ -4154,7 +4162,7 @@ const Xn = (n) => n.length > 0 ? n.join(", ") : "none", Vi = (n, e) => new Q(
4154
4162
  }, Hi = (n, e) => {
4155
4163
  if (!e) return;
4156
4164
  const [t, r, s, i] = n;
4157
- if (!Array.isArray(s) && !me(s))
4165
+ if (!Array.isArray(s) && !we(s))
4158
4166
  throw new Q(
4159
4167
  `Invalid id for entity '${r}'. Expected a UUID, but received: ${s}`
4160
4168
  );
@@ -4357,7 +4365,7 @@ function cn(n, e, t, r) {
4357
4365
  const s = P(t, n.table, "id")?.id;
4358
4366
  if (!s)
4359
4367
  return -1;
4360
- const i = _e(e.eav, [r, s, r]);
4368
+ const i = Te(e.eav, [r, s, r]);
4361
4369
  return i ? i[3] : -1;
4362
4370
  }
4363
4371
  function un(n, e, t) {
@@ -4408,7 +4416,7 @@ function ro(n, e, t) {
4408
4416
  if (n.orderField === "serverCreatedAt") {
4409
4417
  t.sort(
4410
4418
  n.orderDirection === "asc" ? function(o, a) {
4411
- return ve(
4419
+ return Ae(
4412
4420
  o.entity.id,
4413
4421
  o.serverCreatedAt,
4414
4422
  a.entity.id,
@@ -4416,7 +4424,7 @@ function ro(n, e, t) {
4416
4424
  r
4417
4425
  );
4418
4426
  } : function(o, a) {
4419
- return ve(
4427
+ return Ae(
4420
4428
  a.entity.id,
4421
4429
  a.serverCreatedAt,
4422
4430
  o.entity.id,
@@ -4430,7 +4438,7 @@ function ro(n, e, t) {
4430
4438
  const s = n.orderField;
4431
4439
  t.sort(
4432
4440
  n.orderDirection === "asc" ? function(o, a) {
4433
- return ve(
4441
+ return Ae(
4434
4442
  o.entity.id,
4435
4443
  o.entity[s],
4436
4444
  a.entity.id,
@@ -4438,7 +4446,7 @@ function ro(n, e, t) {
4438
4446
  r
4439
4447
  );
4440
4448
  } : function(o, a) {
4441
- return ve(
4449
+ return Ae(
4442
4450
  a.entity.id,
4443
4451
  a.entity[s],
4444
4452
  o.entity.id,
@@ -5462,7 +5470,7 @@ class vo {
5462
5470
  ), this.versions = { ...s || {}, "@instantdb/core": Hn }, this.config.schema && (this._linkIndex = mt(this.config.schema)), !!go()) {
5463
5471
  if (!e.appId)
5464
5472
  throw new Error("Instant must be initialized with an appId.");
5465
- if (!me(e.appId))
5473
+ if (!we(e.appId))
5466
5474
  throw new Error(
5467
5475
  `Instant must be initialized with a valid appId. \`${e.appId}\` is not a valid uuid.`
5468
5476
  );
@@ -6638,6 +6646,13 @@ class vo {
6638
6646
  Object.keys(r).forEach((s) => {
6639
6647
  delete r[s].result;
6640
6648
  });
6649
+ }), this.querySubs.clearUnloadedKeys(), this._updatePendingMutations((r) => {
6650
+ for (const [s, i] of r.entries())
6651
+ this.mutationDeferredStore.get(s) && this._finishTransaction("error", s, {
6652
+ message: "User changed while transaction was in progress.",
6653
+ type: "user-changed"
6654
+ });
6655
+ r.clear();
6641
6656
  }), this._reconnectTimeoutMs = 0, this._transport.close(), this._oauthCallbackResponse = null, this.notifyAuthSubs(t);
6642
6657
  }
6643
6658
  sendMagicCode({ email: e }) {