@instantdb/solidjs 0.22.173 → 0.22.174

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.
@@ -760,14 +760,14 @@ function Xt(t) {
760
760
  const l = n;
761
761
  l.finalities.draft.push((f, d) => {
762
762
  var p, y;
763
- const b = C(c);
763
+ const g = C(c);
764
764
  let w = l.type === 3 ? l.setMap : l.copy;
765
- const m = be(w, r), g = C(m);
766
- if (g) {
767
- let _ = g.original;
768
- g.operated && (_ = Jt(m)), Mt(g), jt(g, ze, f, d), l.options.enableAutoFreeze && (l.options.updatedValues = (p = l.options.updatedValues) !== null && p !== void 0 ? p : /* @__PURE__ */ new WeakMap(), l.options.updatedValues.set(_, g.original)), We(w, r, _);
765
+ const m = be(w, r), b = C(m);
766
+ if (b) {
767
+ let _ = b.original;
768
+ b.operated && (_ = Jt(m)), Mt(b), jt(b, ze, f, d), l.options.enableAutoFreeze && (l.options.updatedValues = (p = l.options.updatedValues) !== null && p !== void 0 ? p : /* @__PURE__ */ new WeakMap(), l.options.updatedValues.set(_, b.original)), We(w, r, _);
769
769
  }
770
- (y = b.callbacks) === null || y === void 0 || y.forEach((_) => {
770
+ (y = g.callbacks) === null || y === void 0 || y.forEach((_) => {
771
771
  _(f, d);
772
772
  });
773
773
  });
@@ -895,11 +895,11 @@ const ts = (t) => function e(n, r, s) {
895
895
  };
896
896
  if (!ae(f, w) && typeof f == "object" && f !== null)
897
897
  throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");
898
- const [m, g] = es(f, w);
898
+ const [m, b] = es(f, w);
899
899
  if (typeof r != "function") {
900
900
  if (!ae(f, w))
901
901
  throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");
902
- return [m, g];
902
+ return [m, b];
903
903
  }
904
904
  let _;
905
905
  try {
@@ -919,20 +919,20 @@ const ts = (t) => function e(n, r, s) {
919
919
  rootDraft: k,
920
920
  value: T,
921
921
  useRawReturn: !0
922
- }), g([D]);
922
+ }), b([D]);
923
923
  }
924
924
  if (T !== void 0)
925
- return typeof T == "object" && T !== null && Rt({ rootDraft: k, value: T }), g([T]);
925
+ return typeof T == "object" && T !== null && Rt({ rootDraft: k, value: T }), b([T]);
926
926
  }
927
927
  if (T === m || T === void 0)
928
- return g([]);
928
+ return b([]);
929
929
  const P = C(T);
930
930
  if (w === P.options) {
931
931
  if (P.operated)
932
932
  throw new Error("Cannot return a modified child draft.");
933
- return g([dn(T)]);
933
+ return b([dn(T)]);
934
934
  }
935
- return g([T]);
935
+ return b([T]);
936
936
  };
937
937
  return _ instanceof Promise ? _.then(O, (T) => {
938
938
  throw Pt(C(m)), T;
@@ -1497,7 +1497,7 @@ function Ve(t, e) {
1497
1497
  const [o, a] = r, c = t.aev.get(o);
1498
1498
  if (!c)
1499
1499
  return null;
1500
- const l = (i = ee(c, 2).find((b) => b[2] === a)) == null ? void 0 : i[0];
1500
+ const l = (i = ee(c, 2).find((g) => g[2] === a)) == null ? void 0 : i[0];
1501
1501
  if (!l)
1502
1502
  return null;
1503
1503
  const [f, d, p, ...y] = e;
@@ -1566,9 +1566,9 @@ function Dt(t, e, n) {
1566
1566
  if (a) {
1567
1567
  for (const f of a.keys()) {
1568
1568
  const d = e.getAttr(f);
1569
- d && d["on-delete-reverse"] === "cascade" && ee(a.get(f), 1).forEach(([p, y, b]) => {
1569
+ d && d["on-delete-reverse"] === "cascade" && ee(a.get(f), 1).forEach(([p, y, g]) => {
1570
1570
  var w;
1571
- return Dt(t, e, [b, (w = d["reverse-identity"]) == null ? void 0 : w[1]]);
1571
+ return Dt(t, e, [g, (w = d["reverse-identity"]) == null ? void 0 : w[1]]);
1572
1572
  }), // Fall back to deleting everything if we've rehydrated tx-steps from
1573
1573
  // the store that didn't set `etype` in deleteEntity
1574
1574
  (!s || // If we don't know about the attr, let's just get rid of it
@@ -1579,9 +1579,9 @@ function Dt(t, e, n) {
1579
1579
  }
1580
1580
  const c = t.vae.get(o) && ee(t.vae.get(o), 2);
1581
1581
  c && c.forEach((f) => {
1582
- var w, m, g;
1583
- const [d, p, y] = f, b = e.getAttr(p);
1584
- (!s || !b || ((w = b["reverse-identity"]) == null ? void 0 : w[1]) === s) && (oe(t.eav, [d, p, y]), oe(t.aev, [p, d, y]), oe(t.vae, [y, p, d])), b && b["on-delete"] === "cascade" && ((m = b["reverse-identity"]) == null ? void 0 : m[1]) === s && Dt(t, e, [d, (g = b["forward-identity"]) == null ? void 0 : g[1]]);
1582
+ var w, m, b;
1583
+ const [d, p, y] = f, g = e.getAttr(p);
1584
+ (!s || !g || ((w = g["reverse-identity"]) == null ? void 0 : w[1]) === s) && (oe(t.eav, [d, p, y]), oe(t.aev, [p, d, y]), oe(t.vae, [y, p, d])), g && g["on-delete"] === "cascade" && ((m = g["reverse-identity"]) == null ? void 0 : m[1]) === s && Dt(t, e, [d, (b = g["forward-identity"]) == null ? void 0 : b[1]]);
1585
1585
  }), ((l = t.vae.get(o)) == null ? void 0 : l.size) === 0 && oe(t.vae, [o]);
1586
1586
  }
1587
1587
  function ur(t, e, n) {
@@ -2072,8 +2072,8 @@ function ci(t, e, n, r, s, i) {
2072
2072
  }
2073
2073
  function ui(t, e, n, r, s) {
2074
2074
  const [i, o, a] = s.reduce((c, u) => {
2075
- const [l, f, d] = c, [p, y, b] = hr(t, e, l, f, u);
2076
- return [p, y, [...d, b]];
2075
+ const [l, f, d] = c, [p, y, g] = hr(t, e, l, f, u);
2076
+ return [p, y, [...d, g]];
2077
2077
  }, [n, r, []]);
2078
2078
  return [i, o, a];
2079
2079
  }
@@ -2159,20 +2159,20 @@ function wi(t, e, n, { etype: r, level: s, form: i }, o) {
2159
2159
  const a = Object.keys(i).filter((c) => c !== "$");
2160
2160
  return a.length ? Object.entries(o).map(function([u, l]) {
2161
2161
  return a.map(function(p) {
2162
- var b, w, m;
2163
- const y = !!(e.cardinalityInference && ((m = (w = (b = n.linkIndex) == null ? void 0 : b[r]) == null ? void 0 : w[p]) != null && m.isSingular));
2162
+ var g, w, m;
2163
+ const y = !!(e.cardinalityInference && ((m = (w = (g = n.linkIndex) == null ? void 0 : g[r]) == null ? void 0 : w[p]) != null && m.isSingular));
2164
2164
  try {
2165
- const [g, _, O] = gi(t, n, r, s, p, u), T = gr(e, n, {
2166
- etype: g,
2165
+ const [b, _, O] = gi(t, n, r, s, p, u), T = gr(e, n, {
2166
+ etype: b,
2167
2167
  level: _,
2168
2168
  form: i[p],
2169
2169
  join: O
2170
2170
  }), k = y ? T[0] : T;
2171
2171
  return { [p]: k };
2172
- } catch (g) {
2173
- if (g instanceof je)
2172
+ } catch (b) {
2173
+ if (b instanceof je)
2174
2174
  return { [p]: y ? void 0 : [] };
2175
- throw g;
2175
+ throw b;
2176
2176
  }
2177
2177
  }).reduce(function(p, y) {
2178
2178
  return { ...p, ...y };
@@ -2237,31 +2237,31 @@ function ki(t, e, n) {
2237
2237
  return r;
2238
2238
  }
2239
2239
  function Oi(t, e, { etype: n, pageInfo: r, dq: s, form: i }) {
2240
- var b, w;
2241
- const o = (b = i == null ? void 0 : i.$) == null ? void 0 : b.order, a = br(i), c = Ii(i);
2240
+ var g, w;
2241
+ const o = (g = i == null ? void 0 : i.$) == null ? void 0 : g.order, a = br(i), c = Ii(i);
2242
2242
  let u = zs(t, s);
2243
2243
  const l = r == null ? void 0 : r["start-cursor"], f = r == null ? void 0 : r["end-cursor"], d = Ai(e, n, l, o);
2244
2244
  if (d && ((w = d == null ? void 0 : d["forward-identity"]) == null ? void 0 : w[2]) !== "id") {
2245
- const m = d["checked-data-type"] === "date", g = d.id;
2245
+ const m = d["checked-data-type"] === "date", b = d.id;
2246
2246
  u = u.map(([_]) => {
2247
2247
  var T, k, P, $, D;
2248
- let O = (D = ($ = (P = (k = (T = t.eav.get(_)) == null ? void 0 : T.get(g)) == null ? void 0 : k.values()) == null ? void 0 : P.next()) == null ? void 0 : $.value) == null ? void 0 : D[2];
2248
+ let O = (D = ($ = (P = (k = (T = t.eav.get(_)) == null ? void 0 : T.get(b)) == null ? void 0 : k.values()) == null ? void 0 : P.next()) == null ? void 0 : $.value) == null ? void 0 : D[2];
2249
2249
  return m && (O = Ft(O)), [_, O];
2250
2250
  });
2251
2251
  }
2252
- u.sort(c === "asc" ? function(g, _) {
2253
- return it(g, _, d == null ? void 0 : d["checked-data-type"]);
2254
- } : function(g, _) {
2255
- return it(_, g, d == null ? void 0 : d["checked-data-type"]);
2252
+ u.sort(c === "asc" ? function(b, _) {
2253
+ return it(b, _, d == null ? void 0 : d["checked-data-type"]);
2254
+ } : function(b, _) {
2255
+ return it(_, b, d == null ? void 0 : d["checked-data-type"]);
2256
2256
  });
2257
2257
  let p = {};
2258
2258
  const y = ki(e, n, s);
2259
2259
  for (const m of u) {
2260
- const [g] = m;
2261
- if (p[g] || !a && l && d && mi(l, d, c, m) || f && d && Ti(f, d, c, m))
2260
+ const [b] = m;
2261
+ if (p[b] || !a && l && d && mi(l, d, c, m) || f && d && Ti(f, d, c, m))
2262
2262
  continue;
2263
- const _ = Ms(t, y, g);
2264
- _ && (p[g] = _);
2263
+ const _ = Ms(t, y, b);
2264
+ _ && (p[b] = _);
2265
2265
  }
2266
2266
  return p;
2267
2267
  }
@@ -2276,7 +2276,7 @@ function br(t) {
2276
2276
  return !e && !n && !r;
2277
2277
  }
2278
2278
  function Ci(t, e, { etype: n, level: r, form: s, join: i, pageInfo: o }) {
2279
- var d, p, y, b, w;
2279
+ var d, p, y, g, w;
2280
2280
  if (!br(s) && (!o || !o["start-cursor"]))
2281
2281
  return [];
2282
2282
  const a = li(yi(e, n, r, (d = s.$) == null ? void 0 : d.where), i), c = bi(ht, n, r), u = (p = s.$) == null ? void 0 : p.fields, l = Oi(t, e, {
@@ -2284,7 +2284,7 @@ function Ci(t, e, { etype: n, level: r, form: s, join: i, pageInfo: o }) {
2284
2284
  pageInfo: o,
2285
2285
  form: s,
2286
2286
  dq: { where: a, find: c, fields: u }
2287
- }), f = ((y = s.$) == null ? void 0 : y.limit) || ((b = s.$) == null ? void 0 : b.first) || ((w = s.$) == null ? void 0 : w.last);
2287
+ }), f = ((y = s.$) == null ? void 0 : y.limit) || ((g = s.$) == null ? void 0 : g.first) || ((w = s.$) == null ? void 0 : w.last);
2288
2288
  if (f != null) {
2289
2289
  r > 0 && ni && console.warn("WARNING: Limits in child queries are only run client-side. Data returned from the server will not have a limit.");
2290
2290
  const m = Object.entries(l);
@@ -2713,13 +2713,13 @@ function io(t) {
2713
2713
  function oo({ attrsStore: t, schema: e }, n) {
2714
2714
  var d, p;
2715
2715
  const r = /* @__PURE__ */ new Set(), s = [], i = [];
2716
- function o(y, b) {
2717
- return N(t, y, b) || s.find((w) => w["forward-identity"][1] === y && w["forward-identity"][2] === b);
2716
+ function o(y, g) {
2717
+ return N(t, y, g) || s.find((w) => w["forward-identity"][1] === y && w["forward-identity"][2] === g);
2718
2718
  }
2719
- function a(y, b) {
2720
- return Ae(t, y, b) || s.find((w) => {
2721
- var m, g;
2722
- return ((m = w["reverse-identity"]) == null ? void 0 : m[1]) === y && ((g = w["reverse-identity"]) == null ? void 0 : g[2]) === b;
2719
+ function a(y, g) {
2720
+ return Ae(t, y, g) || s.find((w) => {
2721
+ var m, b;
2722
+ return ((m = w["reverse-identity"]) == null ? void 0 : m[1]) === y && ((b = w["reverse-identity"]) == null ? void 0 : b[2]) === g;
2723
2723
  });
2724
2724
  }
2725
2725
  function c(y) {
@@ -2728,44 +2728,44 @@ function oo({ attrsStore: t, schema: e }, n) {
2728
2728
  function u(y) {
2729
2729
  y && "isUnsynced" in y && y.isUnsynced && !r.has(y.id) && (s.push(y), i.push(["add-attr", y]), r.add(y.id));
2730
2730
  }
2731
- function l(y, b) {
2732
- return b.indexOf(".") !== -1 && // attr names can have `.` in them, so use the attr we find with a `.`
2731
+ function l(y, g) {
2732
+ return g.indexOf(".") !== -1 && // attr names can have `.` in them, so use the attr we find with a `.`
2733
2733
  // before assuming it's a ref lookup.
2734
- !o(y, b);
2734
+ !o(y, g);
2735
2735
  }
2736
- function f(y, b) {
2737
- const w = o(y, b), m = a(y, b);
2738
- u(w), u(m), !w && !m && c(vn(e, y, b, so));
2736
+ function f(y, g) {
2737
+ const w = o(y, g), m = a(y, g);
2738
+ u(w), u(m), !w && !m && c(vn(e, y, g, so));
2739
2739
  }
2740
2740
  for (const y of n)
2741
- for (const { etype: b, lookupPair: w, linkLabel: m } of io(y)) {
2742
- const g = w[0];
2741
+ for (const { etype: g, lookupPair: w, linkLabel: m } of io(y)) {
2742
+ const b = w[0];
2743
2743
  if (m) {
2744
- f(b, m);
2745
- const _ = o(b, m), O = a(b, m);
2744
+ f(g, m);
2745
+ const _ = o(g, m), O = a(g, m);
2746
2746
  u(_), u(O);
2747
2747
  const T = ((d = _ == null ? void 0 : _["reverse-identity"]) == null ? void 0 : d[1]) || ((p = O == null ? void 0 : O["forward-identity"]) == null ? void 0 : p[1]) || m;
2748
- if (l(T, g))
2749
- f(T, Kt(g));
2748
+ if (l(T, b))
2749
+ f(T, Kt(b));
2750
2750
  else {
2751
- const k = o(T, g);
2752
- k || c(Be(e, T, g, zt)), u(k);
2751
+ const k = o(T, b);
2752
+ k || c(Be(e, T, b, zt)), u(k);
2753
2753
  }
2754
- } else if (l(b, g))
2755
- f(b, Kt(g));
2754
+ } else if (l(g, b))
2755
+ f(g, Kt(b));
2756
2756
  else {
2757
- const _ = o(b, g);
2758
- _ || c(Be(e, b, g, zt)), u(_);
2757
+ const _ = o(g, b);
2758
+ _ || c(Be(e, g, b, zt)), u(_);
2759
2759
  }
2760
2760
  }
2761
2761
  for (const y of n) {
2762
- const [b, w, m, g] = y;
2763
- if (eo.has(b)) {
2762
+ const [g, w, m, b] = y;
2763
+ if (eo.has(g)) {
2764
2764
  const _ = o(w, "id");
2765
2765
  u(_), _ || c(Be(e, w, "id", { "unique?": !0 }));
2766
- for (const O of Object.keys(g)) {
2766
+ for (const O of Object.keys(b)) {
2767
2767
  const T = o(w, O);
2768
- if (u(T), no.has(b) && (T || c(Be(e, w, O, O === "id" ? { "unique?": !0 } : null))), to.has(b)) {
2768
+ if (u(T), no.has(g) && (T || c(Be(e, w, O, O === "id" ? { "unique?": !0 } : null))), to.has(g)) {
2769
2769
  const k = a(w, O);
2770
2770
  !T && !k && c(vn(e, w, O)), u(k);
2771
2771
  }
@@ -2774,8 +2774,8 @@ function oo({ attrsStore: t, schema: e }, n) {
2774
2774
  }
2775
2775
  if (s.length) {
2776
2776
  const y = { ...t.attrs };
2777
- for (const b of s)
2778
- y[b.id] = b;
2777
+ for (const g of s)
2778
+ y[g.id] = g;
2779
2779
  return [new Te(y, t.linkIndex), i];
2780
2780
  }
2781
2781
  return [t, i];
@@ -2964,13 +2964,13 @@ class Wt {
2964
2964
  for (const [d, p] of Object.entries(r.objects))
2965
2965
  !n.has(d) && p.updatedAt < o - this._gcOpts.maxAgeMs && (s.push(this._persister.removeItem(d)), delete r.objects[d], i.removed.push(d), i.removedOldCount++);
2966
2966
  const a = Object.entries(r.objects);
2967
- a.sort(([d, p], [y, b]) => p.updatedAt - b.updatedAt);
2967
+ a.sort(([d, p], [y, g]) => p.updatedAt - g.updatedAt);
2968
2968
  const c = a.filter(([d]) => !n.has(d));
2969
2969
  if (a.length > this._gcOpts.maxEntries)
2970
2970
  for (const [d] of c.slice(0, a.length - this._gcOpts.maxEntries))
2971
2971
  s.push(this._persister.removeItem(d)), delete r.objects[d], i.removed.push(d), i.removedThresholdCount++;
2972
2972
  const u = Object.entries(r.objects);
2973
- u.sort(([d, p], [y, b]) => p.updatedAt - b.updatedAt);
2973
+ u.sort(([d, p], [y, g]) => p.updatedAt - g.updatedAt);
2974
2974
  const l = u.filter(([d]) => !n.has(d));
2975
2975
  let f = u.reduce((d, [p, y]) => d + y.size, 0);
2976
2976
  for (; f > 0 && f > this._gcOpts.maxSize && l.length; ) {
@@ -3072,16 +3072,16 @@ async function po(t, e, n) {
3072
3072
  var l, f, d;
3073
3073
  const a = {};
3074
3074
  for (const [p, y] of Object.entries(r)) {
3075
- const b = typeof y == "string" ? JSON.parse(y) : y;
3076
- if (b.lastAccessed) {
3075
+ const g = typeof y == "string" ? JSON.parse(y) : y;
3076
+ if (g.lastAccessed) {
3077
3077
  const m = {
3078
- createdAt: b.lastAccessed,
3079
- updatedAt: b.lastAccessed,
3080
- size: ((d = (f = (l = b.result) == null ? void 0 : l.store) == null ? void 0 : f.triples) == null ? void 0 : d.length) ?? 0
3078
+ createdAt: g.lastAccessed,
3079
+ updatedAt: g.lastAccessed,
3080
+ size: ((d = (f = (l = g.result) == null ? void 0 : l.store) == null ? void 0 : f.triples) == null ? void 0 : d.length) ?? 0
3081
3081
  };
3082
3082
  a[p] = m;
3083
3083
  }
3084
- const w = n.put(b, p);
3084
+ const w = n.put(g, p);
3085
3085
  s.add(w);
3086
3086
  }
3087
3087
  const c = { objects: a }, u = n.put(c, Ee);
@@ -3109,14 +3109,14 @@ async function yo(t, e) {
3109
3109
  y.onerror = (w) => {
3110
3110
  f(w);
3111
3111
  };
3112
- const b = [];
3112
+ const g = [];
3113
3113
  y.onsuccess = () => {
3114
3114
  const w = y.result;
3115
3115
  if (w) {
3116
- const m = w.key, g = w.value;
3117
- b.push([m, g]), w.continue();
3116
+ const m = w.key, b = w.value;
3117
+ g.push([m, b]), w.continue();
3118
3118
  } else
3119
- l(b);
3119
+ l(g);
3120
3120
  }, y.onerror = (w) => {
3121
3121
  f(w);
3122
3122
  };
@@ -3503,7 +3503,7 @@ function Mn(t) {
3503
3503
  }, e;
3504
3504
  }, {});
3505
3505
  }
3506
- const an = "v0.22.173";
3506
+ const an = "v0.22.174";
3507
3507
  function Eo(t, e) {
3508
3508
  return {
3509
3509
  info: t ? (...n) => console.info(...n, e()) : () => {
@@ -4327,8 +4327,8 @@ class Qo {
4327
4327
  s.values = l;
4328
4328
  const d = [];
4329
4329
  e: for (const [w, m] of Object.entries(u))
4330
- for (let g = 0; g < f.length; g++) {
4331
- const _ = f[g];
4330
+ for (let b = 0; b < f.length; b++) {
4331
+ const _ = f[b];
4332
4332
  if (Ss(_.store, w)) {
4333
4333
  Ln(_.store, l.attrsStore, m);
4334
4334
  const O = kt(s, _.store, l.attrsStore), T = zo(_.store, l.attrsStore, m)[w];
@@ -4336,34 +4336,34 @@ class Qo {
4336
4336
  oldEntity: _.entity,
4337
4337
  newEntity: O,
4338
4338
  changedFields: T || {}
4339
- }), _.entity = O) : c.push(g), delete u[w];
4339
+ }), _.entity = O) : c.push(b), delete u[w];
4340
4340
  continue e;
4341
4341
  }
4342
4342
  }
4343
4343
  const p = [];
4344
4344
  for (const [w, m] of Object.entries(u)) {
4345
- const g = this.createStore([]);
4346
- Ln(g, l.attrsStore, m);
4347
- const _ = kt(s, g, l.attrsStore);
4345
+ const b = this.createStore([]);
4346
+ Ln(b, l.attrsStore, m);
4347
+ const _ = kt(s, b, l.attrsStore);
4348
4348
  if (!_) {
4349
4349
  this.log.error("No entity found after applying change", {
4350
4350
  sub: s,
4351
4351
  changes: m,
4352
- store: g
4352
+ store: b
4353
4353
  });
4354
4354
  continue;
4355
4355
  }
4356
4356
  f.push({
4357
- store: g,
4357
+ store: b,
4358
4358
  entity: _,
4359
- serverCreatedAt: Un(s, g, l.attrsStore, _.id)
4359
+ serverCreatedAt: Un(s, b, l.attrsStore, _.id)
4360
4360
  }), p.push(_);
4361
4361
  }
4362
4362
  const y = [];
4363
4363
  for (const w of c.sort().reverse())
4364
4364
  y.push(f[w].entity), f.splice(w, 1);
4365
- const b = Wo(s, this.getAttrs);
4366
- Vo(s, b, f), this.notifyCbs(r, {
4365
+ const g = Wo(s, this.getAttrs);
4366
+ Vo(s, g, f), this.notifyCbs(r, {
4367
4367
  type: _e.SyncTransaction,
4368
4368
  data: Ge(s, (o = s.values) == null ? void 0 : o.entities),
4369
4369
  added: p,
@@ -4410,8 +4410,8 @@ function Bo({ WStream: t, opts: e, startStream: n, appendStream: r, registerStre
4410
4410
  const u = x();
4411
4411
  let l = !1, f = !1;
4412
4412
  const d = [], p = [], y = [];
4413
- let b = !1, w = 0, m = 0;
4414
- const g = [], _ = new TextEncoder();
4413
+ let g = !1, w = 0, m = 0;
4414
+ const b = [], _ = new TextEncoder();
4415
4415
  function O() {
4416
4416
  f = !0;
4417
4417
  for (const S of d)
@@ -4451,17 +4451,17 @@ function Bo({ WStream: t, opts: e, startStream: n, appendStream: r, registerStre
4451
4451
  A(o);
4452
4452
  }
4453
4453
  function ue() {
4454
- b = !0;
4454
+ g = !0;
4455
4455
  }
4456
4456
  function ge(S) {
4457
4457
  let A = w, M = 0, L = 0;
4458
- for (const { byteLen: K } of g) {
4458
+ for (const { byteLen: K } of b) {
4459
4459
  const ne = A + K;
4460
4460
  if (ne > S)
4461
4461
  break;
4462
4462
  A = ne, M++, L += K;
4463
4463
  }
4464
- M > 0 && (w += L, m -= L, g.splice(0, M));
4464
+ M > 0 && (w += L, m -= L, b.splice(0, M));
4465
4465
  }
4466
4466
  function V(S, A) {
4467
4467
  a = A, O(), S.error(A), P();
@@ -4475,11 +4475,11 @@ function Bo({ WStream: t, opts: e, startStream: n, appendStream: r, registerStre
4475
4475
  switch (S.type) {
4476
4476
  case "ok": {
4477
4477
  const { streamId: A, offset: M } = S;
4478
- o = A, ge(M), g.length && r({
4478
+ o = A, ge(M), b.length && r({
4479
4479
  streamId: A,
4480
- chunks: g.map((L) => L.chunk),
4480
+ chunks: b.map((L) => L.chunk),
4481
4481
  offset: w
4482
- }), b = !1;
4482
+ }), g = !1;
4483
4483
  break;
4484
4484
  }
4485
4485
  case "disconnect": {
@@ -4525,7 +4525,7 @@ function Bo({ WStream: t, opts: e, startStream: n, appendStream: r, registerStre
4525
4525
  onFlush: v,
4526
4526
  onConnectionReconnect: Z,
4527
4527
  onAppendFailed: G
4528
- }), b = !1;
4528
+ }), g = !1;
4529
4529
  return;
4530
4530
  }
4531
4531
  case "disconnect": {
@@ -4574,9 +4574,9 @@ function Bo({ WStream: t, opts: e, startStream: n, appendStream: r, registerStre
4574
4574
  const M = I(A);
4575
4575
  if (M) {
4576
4576
  const L = _.encode(S).length;
4577
- g.push({ chunk: S, byteLen: L });
4577
+ b.push({ chunk: S, byteLen: L });
4578
4578
  const K = w + m;
4579
- m += L, b || r({ streamId: M, chunks: [S], offset: K });
4579
+ m += L, g || r({ streamId: M, chunks: [S], offset: K });
4580
4580
  }
4581
4581
  },
4582
4582
  close() {
@@ -4644,22 +4644,22 @@ function Ho({ RStream: t, opts: e, startStream: n, cancelStream: r }) {
4644
4644
  const l = [];
4645
4645
  function f() {
4646
4646
  u = !0;
4647
- for (const g of l)
4648
- g();
4647
+ for (const b of l)
4648
+ b();
4649
4649
  }
4650
- function d(g) {
4651
- return l.push(g), () => {
4652
- const _ = l.indexOf(g);
4650
+ function d(b) {
4651
+ return l.push(b), () => {
4652
+ const _ = l.indexOf(b);
4653
4653
  _ !== -1 && l.splice(_, 1);
4654
4654
  };
4655
4655
  }
4656
- function p(g, _) {
4657
- g.error(_), f();
4656
+ function p(b, _) {
4657
+ b.error(_), f();
4658
4658
  }
4659
4659
  let y = 0;
4660
- async function b(g, _) {
4660
+ async function g(b, _) {
4661
4661
  c = x();
4662
- const O = { ...g || {}, eventId: c };
4662
+ const O = { ...b || {}, eventId: c };
4663
4663
  for await (const T of n(O)) {
4664
4664
  if (i)
4665
4665
  return;
@@ -4736,24 +4736,24 @@ function Ho({ RStream: t, opts: e, startStream: n, cancelStream: r }) {
4736
4736
  }
4737
4737
  }
4738
4738
  }
4739
- async function w(g) {
4739
+ async function w(b) {
4740
4740
  let _ = !0, O = 0;
4741
4741
  for (; _; ) {
4742
4742
  _ = !1;
4743
4743
  let T = Date.now() + Math.min(15e3, 500 * (O - 1));
4744
- const k = await b({ ...e, offset: s }, g);
4744
+ const k = await g({ ...e, offset: s }, b);
4745
4745
  k != null && k.retry && (_ = !0, O++, T < Date.now() - 3e5 && (O = 0), await new Promise((P) => {
4746
4746
  setTimeout(P, Math.max(0, T - Date.now()));
4747
4747
  }));
4748
4748
  }
4749
- !i && !u && (g.close(), f());
4749
+ !i && !u && (b.close(), f());
4750
4750
  }
4751
4751
  return {
4752
4752
  stream: new t({
4753
- start(g) {
4754
- w(g);
4753
+ start(b) {
4754
+ w(b);
4755
4755
  },
4756
- cancel(g) {
4756
+ cancel(b) {
4757
4757
  i = !0, c && r({ eventId: c }), f();
4758
4758
  }
4759
4759
  }),
@@ -5389,8 +5389,8 @@ class ua {
5389
5389
  case "init-ok": {
5390
5390
  this._setStatus(le.AUTHENTICATED), this._reconnectTimeoutMs = 0, this._setAttrs(n.attrs), this._flushPendingMessages(), this._sessionId = n["session-id"];
5391
5391
  for (const p of Object.keys(this._rooms)) {
5392
- const y = (i = (s = this._presence[p]) == null ? void 0 : s.result) == null ? void 0 : i.user, b = (o = this._rooms[p]) == null ? void 0 : o.roomType;
5393
- this._tryJoinRoom(b, p, y);
5392
+ const y = (i = (s = this._presence[p]) == null ? void 0 : s.result) == null ? void 0 : i.user, g = (o = this._rooms[p]) == null ? void 0 : o.roomType;
5393
+ this._tryJoinRoom(g, p, y);
5394
5394
  }
5395
5395
  break;
5396
5396
  }
@@ -5399,23 +5399,23 @@ class ua {
5399
5399
  break;
5400
5400
  }
5401
5401
  case "add-query-ok": {
5402
- const { q: p, result: y } = n, b = W(p);
5403
- if (!this._hasQueryListeners() && !this.querySubs.currentValue[b])
5402
+ const { q: p, result: y } = n, g = W(p);
5403
+ if (!this._hasQueryListeners() && !this.querySubs.currentValue[g])
5404
5404
  break;
5405
- const w = (c = (a = y == null ? void 0 : y[0]) == null ? void 0 : a.data) == null ? void 0 : c["page-info"], m = (l = (u = y == null ? void 0 : y[0]) == null ? void 0 : u.data) == null ? void 0 : l.aggregate, g = Pn(y), _ = this.ensureAttrs(), O = Ue(_, g, r, this.config.useDateObjects);
5405
+ const w = (c = (a = y == null ? void 0 : y[0]) == null ? void 0 : a.data) == null ? void 0 : c["page-info"], m = (l = (u = y == null ? void 0 : y[0]) == null ? void 0 : u.data) == null ? void 0 : l.aggregate, b = Pn(y), _ = this.ensureAttrs(), O = Ue(_, b, r, this.config.useDateObjects);
5406
5406
  this.querySubs.updateInPlace((T) => {
5407
- if (!T[b]) {
5408
- this._log.info("Missing value in querySubs", { hash: b, q: p });
5407
+ if (!T[g]) {
5408
+ this._log.info("Missing value in querySubs", { hash: g, q: p });
5409
5409
  return;
5410
5410
  }
5411
- T[b].result = {
5411
+ T[g].result = {
5412
5412
  store: O,
5413
5413
  attrsStore: _,
5414
5414
  pageInfo: w,
5415
5415
  aggregate: m,
5416
5416
  processedTxId: n["processed-tx-id"]
5417
5417
  };
5418
- }), this._cleanupPendingMutationsQueries(), this.notifyOne(b), this.notifyOneQueryOnce(b), this._cleanupPendingMutationsTimeout();
5418
+ }), this._cleanupPendingMutationsQueries(), this.notifyOne(g), this.notifyOneQueryOnce(g), this._cleanupPendingMutationsTimeout();
5419
5419
  break;
5420
5420
  }
5421
5421
  case "start-sync-ok": {
@@ -5451,15 +5451,15 @@ class ua {
5451
5451
  break;
5452
5452
  }
5453
5453
  case "refresh-ok": {
5454
- const { computations: p, attrs: y } = n, b = n["processed-tx-id"];
5454
+ const { computations: p, attrs: y } = n, g = n["processed-tx-id"];
5455
5455
  y && this._setAttrs(y), this._cleanupPendingMutationsTimeout();
5456
- const w = this._rewriteMutations(this.ensureAttrs(), this._pendingMutations(), b);
5456
+ const w = this._rewriteMutations(this.ensureAttrs(), this._pendingMutations(), g);
5457
5457
  w !== this._pendingMutations() && this.kv.updateInPlace((_) => {
5458
5458
  _.pendingMutations = w;
5459
5459
  });
5460
- const m = Ct(w.entries()), g = p.map((_) => {
5460
+ const m = Ct(w.entries()), b = p.map((_) => {
5461
5461
  var G, v, I, E;
5462
- const O = _["instaql-query"], T = _["instaql-result"], k = W(O), P = Pn(T), $ = this.ensureAttrs(), D = Ue($, P, r, this.config.useDateObjects), { store: ue, attrsStore: ge } = this._applyOptimisticUpdates(D, $, m, b), V = (v = (G = T == null ? void 0 : T[0]) == null ? void 0 : G.data) == null ? void 0 : v["page-info"], Z = (E = (I = T == null ? void 0 : T[0]) == null ? void 0 : I.data) == null ? void 0 : E.aggregate;
5462
+ const O = _["instaql-query"], T = _["instaql-result"], k = W(O), P = Pn(T), $ = this.ensureAttrs(), D = Ue($, P, r, this.config.useDateObjects), { store: ue, attrsStore: ge } = this._applyOptimisticUpdates(D, $, m, g), V = (v = (G = T == null ? void 0 : T[0]) == null ? void 0 : G.data) == null ? void 0 : v["page-info"], Z = (E = (I = T == null ? void 0 : T[0]) == null ? void 0 : I.data) == null ? void 0 : E.aggregate;
5463
5463
  return {
5464
5464
  q: O,
5465
5465
  hash: k,
@@ -5469,7 +5469,7 @@ class ua {
5469
5469
  aggregate: Z
5470
5470
  };
5471
5471
  });
5472
- g.forEach(({ hash: _, q: O, store: T, attrsStore: k, pageInfo: P, aggregate: $ }) => {
5472
+ b.forEach(({ hash: _, q: O, store: T, attrsStore: k, pageInfo: P, aggregate: $ }) => {
5473
5473
  this.querySubs.updateInPlace((D) => {
5474
5474
  if (!D[_]) {
5475
5475
  this._log.error("Missing value in querySubs", { hash: _, q: O });
@@ -5480,10 +5480,10 @@ class ua {
5480
5480
  attrsStore: k,
5481
5481
  pageInfo: P,
5482
5482
  aggregate: $,
5483
- processedTxId: b
5483
+ processedTxId: g
5484
5484
  };
5485
5485
  });
5486
- }), this._cleanupPendingMutationsQueries(), g.forEach(({ hash: _ }) => {
5486
+ }), this._cleanupPendingMutationsQueries(), b.forEach(({ hash: _ }) => {
5487
5487
  this.notifyOne(_);
5488
5488
  });
5489
5489
  break;
@@ -5494,22 +5494,22 @@ class ua {
5494
5494
  const w = this._rewriteMutations(this.ensureAttrs(), this._pendingMutations()).get(p);
5495
5495
  if (!w)
5496
5496
  break;
5497
- this._updatePendingMutations((g) => {
5498
- g.set(p, {
5499
- ...g.get(p),
5497
+ this._updatePendingMutations((b) => {
5498
+ b.set(p, {
5499
+ ...b.get(p),
5500
5500
  "tx-id": y,
5501
5501
  confirmed: Date.now()
5502
5502
  });
5503
5503
  });
5504
5504
  const m = [];
5505
- for (const g of w["tx-steps"])
5506
- if (g[0] === "add-attr") {
5507
- const _ = g[1];
5505
+ for (const b of w["tx-steps"])
5506
+ if (b[0] === "add-attr") {
5507
+ const _ = b[1];
5508
5508
  m.push(_);
5509
5509
  }
5510
5510
  if (m.length) {
5511
- const g = Object.values(this.ensureAttrs().attrs);
5512
- this._setAttrs([...g, ...m]);
5511
+ const b = Object.values(this.ensureAttrs().attrs);
5512
+ this._setAttrs([...b, ...m]);
5513
5513
  }
5514
5514
  this._finishTransaction("synced", p), this._cleanupPendingMutationsTimeout();
5515
5515
  break;
@@ -5724,9 +5724,9 @@ class ua {
5724
5724
  for (const p of l) {
5725
5725
  const [y] = p;
5726
5726
  if (y === "add-attr") {
5727
- const [w, m] = p, g = s(m);
5728
- if (g && m.id !== g.id) {
5729
- o.attrIdMap[m.id] = g.id, a = !0;
5727
+ const [w, m] = p, b = s(m);
5728
+ if (b && m.id !== b.id) {
5729
+ o.attrIdMap[m.id] = b.id, a = !0;
5730
5730
  continue;
5731
5731
  }
5732
5732
  if (m["value-type"] === "ref") {
@@ -5741,8 +5741,8 @@ class ua {
5741
5741
  a = !0;
5742
5742
  continue;
5743
5743
  }
5744
- const b = a ? Di(o, p) : p;
5745
- d.push(b);
5744
+ const g = a ? Di(o, p) : p;
5745
+ d.push(g);
5746
5746
  }
5747
5747
  return a ? d : l;
5748
5748
  }, u = /* @__PURE__ */ new Map();
@@ -5794,10 +5794,10 @@ class ua {
5794
5794
  if (l && s === l.querySubVersion && o === l.pendingMutationsVersion)
5795
5795
  return l;
5796
5796
  let f = u.store, d = u.attrsStore;
5797
- const { pageInfo: p, aggregate: y, processedTxId: b } = u, w = this._rewriteMutationsSorted(d, a);
5797
+ const { pageInfo: p, aggregate: y, processedTxId: g } = u, w = this._rewriteMutationsSorted(d, a);
5798
5798
  if (n) {
5799
- const g = this._applyOptimisticUpdates(f, d, w, b);
5800
- f = g.store, d = g.attrsStore;
5799
+ const b = this._applyOptimisticUpdates(f, d, w, g);
5800
+ f = b.store, d = b.attrsStore;
5801
5801
  }
5802
5802
  return { data: wr({ store: f, attrsStore: d, pageInfo: p, aggregate: y }, c), querySubVersion: s, pendingMutationsVersion: o };
5803
5803
  }
@@ -6431,8 +6431,8 @@ class ua {
6431
6431
  _notifyBroadcastSubs(e, n, r) {
6432
6432
  var s, i, o;
6433
6433
  (o = (i = (s = this._broadcastSubs) == null ? void 0 : s[e]) == null ? void 0 : i[n]) == null || o.forEach((a) => {
6434
- var l, f, d, p, y, b;
6435
- const c = (l = r.data) == null ? void 0 : l.data, u = r.data["peer-id"] === this._sessionId ? (d = (f = this._presence[e]) == null ? void 0 : f.result) == null ? void 0 : d.user : (b = (y = (p = this._presence[e]) == null ? void 0 : p.result) == null ? void 0 : y.peers) == null ? void 0 : b[r.data["peer-id"]];
6434
+ var l, f, d, p, y, g;
6435
+ const c = (l = r.data) == null ? void 0 : l.data, u = r.data["peer-id"] === this._sessionId ? (d = (f = this._presence[e]) == null ? void 0 : f.result) == null ? void 0 : d.user : (g = (y = (p = this._presence[e]) == null ? void 0 : p.result) == null ? void 0 : y.peers) == null ? void 0 : g[r.data["peer-id"]];
6436
6436
  return a(c, u);
6437
6437
  });
6438
6438
  }
@@ -6741,7 +6741,7 @@ const Ia = (t) => JSON.stringify(t), Fe = (t, e = !1) => JSON.stringify([t, e]),
6741
6741
  }, qn = ["bootstrap", "bootstrap", "bootstrap", 1], ja = (t, e, n, r) => {
6742
6742
  var ge, V, Z, G;
6743
6743
  const { entityName: s, entityQuery: i } = $a(e), o = ((ge = i.$) == null ? void 0 : ge.limit) || 10, a = s, c = Pa((V = i.$) == null ? void 0 : V.order), u = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map();
6744
- let d = !1, p = !0, y = null, b = null;
6744
+ let d = !1, p = !0, y = null, g = null;
6745
6745
  const w = (v) => {
6746
6746
  n({ error: v, data: void 0, canLoadNextPage: !1 });
6747
6747
  }, m = () => {
@@ -6754,7 +6754,7 @@ const Ia = (t) => JSON.stringify(t), Fe = (t, e = !1) => JSON.stringify([t, e]),
6754
6754
  chunks: v,
6755
6755
  canLoadNextPage: Ea(u)
6756
6756
  });
6757
- }, g = (v, I) => {
6757
+ }, b = (v, I) => {
6758
6758
  u.set(Fe(v, I.afterInclusive), I), m();
6759
6759
  }, _ = (v, I) => {
6760
6760
  l.set(Fe(v), I), $(), m();
@@ -6829,7 +6829,7 @@ const Ia = (t) => JSON.stringify(t), Fe = (t, e = !1) => JSON.stringify([t, e]),
6829
6829
  if (S.error)
6830
6830
  return w(S.error);
6831
6831
  const A = S.data[a], M = S.pageInfo[a];
6832
- Re(A && M, "Page info and rows"), g(v, {
6832
+ Re(A && M, "Page info and rows"), b(v, {
6833
6833
  data: A,
6834
6834
  status: "bootstrapping",
6835
6835
  hasMore: M.hasNextPage,
@@ -6862,7 +6862,7 @@ const Ia = (t) => JSON.stringify(t), Fe = (t, e = !1) => JSON.stringify([t, e]),
6862
6862
  if (L.error)
6863
6863
  return w(L.error);
6864
6864
  const K = L.data[a], ne = L.pageInfo[a];
6865
- Re(K && ne, "Expected rows and pageInfo"), g(v, {
6865
+ Re(K && ne, "Expected rows and pageInfo"), b(v, {
6866
6866
  data: K,
6867
6867
  status: "frozen",
6868
6868
  hasMore: ne.hasNextPage,
@@ -6890,7 +6890,7 @@ const Ia = (t) => JSON.stringify(t), Fe = (t, e = !1) => JSON.stringify([t, e]),
6890
6890
  const { cursor: R, afterInclusive: U } = Nn(I);
6891
6891
  P(R, U), k(E.endCursor);
6892
6892
  };
6893
- return b = t.subscribeQuery({
6893
+ return g = t.subscribeQuery({
6894
6894
  [a]: {
6895
6895
  ...i,
6896
6896
  $: {
@@ -6908,18 +6908,18 @@ const Ia = (t) => JSON.stringify(t), Fe = (t, e = !1) => JSON.stringify([t, e]),
6908
6908
  return w(v.error);
6909
6909
  const I = v.pageInfo[a], E = (U = v == null ? void 0 : v.data) == null ? void 0 : U[a];
6910
6910
  if (Re(E && I, "Expected rows and pageInfo"), E.length < o) {
6911
- g(qn, {
6911
+ b(qn, {
6912
6912
  data: E,
6913
6913
  status: "pre-bootstrap"
6914
6914
  });
6915
6915
  return;
6916
6916
  }
6917
6917
  const R = I.startCursor;
6918
- R && (u.delete(Fe(qn)), k(R, !0), T(I.startCursor), d = !0, await t._reactor.querySubs.flush(), b == null || b(), b = null);
6918
+ R && (u.delete(Fe(qn)), k(R, !0), T(I.startCursor), d = !0);
6919
6919
  }, r), {
6920
6920
  unsubscribe: () => {
6921
6921
  if (p) {
6922
- p = !1, b == null || b(), b = null;
6922
+ p = !1, g == null || g(), g = null;
6923
6923
  for (const v of f.values())
6924
6924
  v == null || v();
6925
6925
  f.clear();