@ebbjs/storage 0.3.0 → 1.1.0

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.
@@ -1,270 +1,277 @@
1
- import { l as _e, a as Me, f as se, b as V, m as Ee, c as oe, r as Fe, w as Ne, R as Oe, i as je, d as re, e as ke, g as Se, h as ie, j as Pe, k as xe, n as J, o as H } from "../replica-record-D3lkFACh.js";
1
+ import { l as Ee, a as Fe, f as oe, b as K, m as Ne, c as se, d as Oe, r as xe, e as ke, w as Se, R as je, i as Ce, g as re, h as Pe, j as Ae, k as De, n as ie, o as Re, p as Le, q as Ke, s as Ve, t as B, u as Ue, v as Ye, x as J } from "../replica-record-BaptWabD.js";
2
+ import { y as st } from "../replica-record-BaptWabD.js";
2
3
  import { isFieldMap as ce } from "@ebbjs/core";
3
- const fe = (c, f) => {
4
- if (c === f) return !0;
5
- const a = ce(c), l = ce(f);
6
- if (a !== l || !a || !l) return !1;
7
- const p = Object.keys(c.map), d = Object.keys(f.map);
8
- if (p.length !== d.length) return !1;
9
- for (const h of p) {
10
- const y = c.map[h], k = f.map[h];
11
- if (y === void 0 || k === void 0 || !fe(y, k)) return !1;
4
+ const ae = (c, a) => {
5
+ if (c === a) return !0;
6
+ const u = ce(c), l = ce(a);
7
+ if (u !== l || !u || !l) return !1;
8
+ const p = Object.keys(c.map), y = Object.keys(a.map);
9
+ if (p.length !== y.length) return !1;
10
+ for (const m of p) {
11
+ const h = c.map[m], I = a.map[m];
12
+ if (h === void 0 || I === void 0 || !ae(h, I)) return !1;
12
13
  }
13
14
  return !0;
14
- }, Ae = (c, f) => {
15
- const a = Object.keys(c);
16
- if (a.length !== Object.keys(f).length) return !1;
17
- for (const l of a) {
18
- const p = c[l], d = f[l];
19
- if (p === void 0 || d === void 0 || !fe(p, d)) return !1;
15
+ }, ze = (c, a) => {
16
+ const u = Object.keys(c);
17
+ if (u.length !== Object.keys(a).length) return !1;
18
+ for (const l of u) {
19
+ const p = c[l], y = a[l];
20
+ if (p === void 0 || y === void 0 || !ae(p, y)) return !1;
20
21
  }
21
22
  return !0;
22
- }, U = (c) => c == null, Re = (c, f) => U(c) || U(f) ? U(c) !== U(f) : c.type !== f.type || c.updated_hlc !== f.updated_hlc || c.deleted_hlc !== f.deleted_hlc ? !0 : !Ae(c.data.fields, f.data.fields), Ce = {
23
+ }, V = (c) => c == null, Be = (c, a) => V(c) || V(a) ? V(c) !== V(a) : c.type !== a.type || c.exists !== a.exists || c.created_hlc !== a.created_hlc || c.updated_hlc !== a.updated_hlc || c.deleted_hlc !== a.deleted_hlc ? !0 : !ze(c.data.fields, a.data.fields), Je = {
23
24
  holds: () => !0
24
- }, De = 1024, Le = 16, Ke = 3e4, le = (c, f) => c === void 0 ? f : !Number.isFinite(c) || c <= 0 ? Number.POSITIVE_INFINITY : Math.max(1, Math.floor(c)), Ve = (c) => c === void 0 ? Ke : !Number.isFinite(c) || c <= 0 ? Number.POSITIVE_INFINITY : c, Ue = (c) => {
25
+ }, He = 1024, We = 16, Ge = 3e4, le = (c, a) => c === void 0 ? a : !Number.isFinite(c) || c <= 0 ? Number.POSITIVE_INFINITY : Math.max(1, Math.floor(c)), Qe = (c) => c === void 0 ? Ge : !Number.isFinite(c) || c <= 0 ? Number.POSITIVE_INFINITY : c, Xe = (c) => {
25
26
  typeof c == "object" && "unref" in c && typeof c.unref == "function" && c.unref();
26
- }, He = (c) => {
27
- const f = c?.materialization ?? Ce, a = (e) => f.holds(e), l = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map(), y = /* @__PURE__ */ new Map(), k = le(c?.journalCapacity, De), ae = le(c?.pinnedCapacity, Le), W = Ve(c?.pinnedTtlMs), g = /* @__PURE__ */ new Map(), v = /* @__PURE__ */ new Map(), S = /* @__PURE__ */ new Map();
28
- let G = 0;
29
- const M = /* @__PURE__ */ new Map();
30
- let I = [], w = 0, N = {}, m = {}, u = 0, O = 0, E = 0;
31
- const Y = /* @__PURE__ */ new Set(), F = () => {
32
- for (const e of Y)
27
+ }, tt = (c) => {
28
+ const a = c?.materialization ?? Je, u = (e) => a.holds(e), l = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new Map();
29
+ let y = /* @__PURE__ */ new Map();
30
+ const m = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map(), I = /* @__PURE__ */ new Map(), fe = le(c?.journalCapacity, He), ue = le(c?.pinnedCapacity, We), H = Qe(c?.pinnedTtlMs), g = /* @__PURE__ */ new Map(), v = /* @__PURE__ */ new Map(), j = /* @__PURE__ */ new Map();
31
+ let W = 0;
32
+ const E = /* @__PURE__ */ new Map();
33
+ let w = [], b = 0, O = {}, M = {}, d = 0, x = 0, F = 0;
34
+ const U = /* @__PURE__ */ new Set(), N = () => {
35
+ for (const e of U)
33
36
  try {
34
37
  e();
35
38
  } catch (t) {
36
39
  console.error("[Replica] change listener threw:", t);
37
40
  }
41
+ }, C = (e, t) => {
42
+ const s = p.get(e);
43
+ s === void 0 ? p.set(e, /* @__PURE__ */ new Set([t])) : s.add(t);
38
44
  }, P = (e, t) => {
39
- const o = p.get(e);
40
- o === void 0 ? p.set(e, /* @__PURE__ */ new Set([t])) : o.add(t);
41
- }, x = (e, t) => {
42
- const o = p.get(e);
43
- o !== void 0 && (o.delete(t), o.size === 0 && p.delete(e));
44
- }, Q = (e) => a(e.type) || g.has(e.id), A = (e) => {
45
+ const s = p.get(e);
46
+ s !== void 0 && (s.delete(t), s.size === 0 && p.delete(e));
47
+ }, G = (e) => u(e.type) || g.has(e.id), A = (e) => {
45
48
  const t = g.get(e);
46
49
  t !== void 0 && (t.timer !== null && clearTimeout(t.timer), g.delete(e));
47
- }, z = (e) => {
48
- v.has(e) && (v.delete(e), M.delete(e), S.set(e, ++G));
49
- }, X = (e) => {
50
+ }, Y = (e) => {
51
+ v.has(e) && (v.delete(e), E.delete(e), j.set(e, ++W));
52
+ }, Q = (e) => {
50
53
  A(e), g.set(e, { open: !0, timer: null });
51
54
  const t = [];
52
- for (const o of g.keys()) {
53
- if (g.size - t.length <= ae) break;
54
- t.push(o);
55
+ for (const s of g.keys()) {
56
+ if (g.size - t.length <= ue) break;
57
+ t.push(s);
55
58
  }
56
- t.length > 0 && j(t);
57
- }, ue = (e) => {
59
+ t.length > 0 && k(t);
60
+ }, de = (e) => {
58
61
  const t = g.get(e);
59
62
  if (!(t === void 0 || !t.open)) {
60
- if (t.open = !1, !Number.isFinite(W)) {
61
- j([e]);
63
+ if (t.open = !1, !Number.isFinite(H)) {
64
+ k([e]);
62
65
  return;
63
66
  }
64
- t.timer = setTimeout(() => j([e]), W), Ue(t.timer);
67
+ t.timer = setTimeout(() => k([e]), H), Xe(t.timer);
65
68
  }
66
- }, de = (e) => g.get(e)?.open === !0, R = (e, t, o) => {
67
- u += 1, I.push({ revision: u, id: e, type: t, deleted: o }), pe();
68
- }, Z = () => I.length - w, pe = () => {
69
- const e = Z() - k;
70
- e <= 0 || (w += e, O = I[w - 1].revision, w * 2 >= I.length && (I = I.slice(w), w = 0));
71
- }, C = (e) => h.has(e) ? h.get(e) ?? null : l.get(e) ?? null, D = (e) => h.has(e) ? h.get(e) ?? void 0 : l.get(e), $ = (e) => {
69
+ }, pe = (e) => g.get(e)?.open === !0, X = (e, t, s) => {
70
+ d += 1, w.push({ revision: d, id: e, deleted: t, components: s }), he();
71
+ }, Z = () => w.length - b, he = () => {
72
+ const e = Z() - fe;
73
+ e <= 0 || (b += e, x = w[b - 1].revision, b * 2 >= w.length && (w = w.slice(b), b = 0));
74
+ }, D = (e) => h.has(e) ? h.get(e) ?? null : l.get(e) ?? null, R = (e) => h.has(e) ? h.get(e) ?? void 0 : l.get(e), $ = (e) => {
72
75
  const t = new Set(p.get(e) ?? []);
73
- for (const [n, s] of h)
74
- s !== null && s.type === e ? t.add(n) : t.delete(n);
75
- const o = [];
76
+ for (const [n, o] of h)
77
+ o !== null && o.type === e ? t.add(n) : t.delete(n);
78
+ const s = [];
76
79
  for (const n of t) {
77
- const s = D(n);
78
- s !== void 0 && o.push(s);
80
+ const o = R(n);
81
+ o !== void 0 && s.push(o);
79
82
  }
80
- return o;
83
+ return s;
81
84
  }, q = (e, t) => {
82
- const o = t.update.subject_id, n = e.get(o);
83
- n === void 0 ? e.set(o, [t]) : n.push(t);
84
- }, ee = (e, t, o, n) => {
85
- const s = e.subject_id;
86
- if (!a(e.subject_type) && !g.has(s) && v.has(s)) {
87
- q(M, { update: e, gsn: t, hlc: o, position: n });
85
+ const s = t.update.subject_id, n = e.get(s);
86
+ n === void 0 ? e.set(s, [t]) : n.push(t);
87
+ }, ee = (e, t, s, n) => {
88
+ const o = e.subject_id, r = l.get(o) ?? null, i = Ue(e, r);
89
+ if (!u(i) && !g.has(o) && v.has(o)) {
90
+ q(E, { update: e, gsn: t, hlc: s, position: n });
88
91
  return;
89
92
  }
90
- const r = l.get(s) ?? null, i = J(r, e, t, o, H);
91
- if (i === null) {
92
- if (!a(e.subject_type) && !g.has(s)) return;
93
- q(y, { update: e, gsn: t, hlc: o, position: n });
93
+ const f = B(r, e, t, s, J);
94
+ if (f === null) {
95
+ if (!u(i) && !g.has(o)) return;
96
+ q(I, { update: e, gsn: t, hlc: s, position: n });
94
97
  return;
95
98
  }
96
- if (!Q(i)) {
97
- r !== null && (l.delete(s), x(r.type, s)), e.method === "put" && y.delete(s);
99
+ if (!G(f)) {
100
+ r !== null && (l.delete(o), P(r.type, o)), r === null && I.delete(o);
98
101
  return;
99
102
  }
100
- if (l.set(s, i), r !== null && r.type !== i.type && x(r.type, s), P(i.type, s), e.method === "put") {
101
- const b = y.get(s);
102
- if (b !== void 0) {
103
- y.delete(s);
104
- const K = b.filter((_) => _.gsn > t).sort((_, Te) => _.gsn - Te.gsn);
105
- let T = i;
106
- for (const _ of K)
107
- T = J(T, _.update, _.gsn, _.hlc, H) ?? T;
108
- T !== i && (l.set(s, T), i.type !== T.type && (x(i.type, s), P(T.type, s)));
103
+ if (l.set(o, f), r !== null && r.type !== f.type && P(r.type, o), C(f.type, o), r === null) {
104
+ const S = I.get(o);
105
+ if (S !== void 0) {
106
+ I.delete(o);
107
+ const _e = S.filter((T) => T.gsn > t).sort((T, Te) => T.gsn - Te.gsn);
108
+ let _ = f;
109
+ for (const T of _e)
110
+ _ = B(_, T.update, T.gsn, T.hlc, J) ?? _;
111
+ _ !== f && (l.set(o, _), f.type !== _.type && (P(f.type, o), C(_.type, o)));
109
112
  }
110
113
  }
111
114
  }, te = (e, t) => {
112
- const o = e ?? void 0, n = t ?? void 0;
113
- N = ie(N, Pe(o, n)), m = ie(m, xe(o, n));
115
+ const s = e ?? void 0, n = t ?? void 0;
116
+ O = ie(O, Re(s, n)), M = ie(M, Le(s, n));
117
+ const o = Ke(s, n);
118
+ o !== null && (y = Ve(y, o));
114
119
  }, L = (e, t) => {
115
- const o = l.get(e) ?? null, n = d.get(e);
116
- let s = o;
120
+ const s = l.get(e) ?? null, n = m.get(e);
121
+ let o = s;
117
122
  if (n !== void 0)
118
- for (const i of n)
119
- s = J(s, i.update, 0, i.hlc, H);
120
- const r = s !== null && Q(s) ? s : null;
121
- if ((r === null || a(r.type)) && A(e), n === void 0 || n.length === 0 ? h.delete(e) : h.set(e, r), te(t, r), r === null) {
122
- s !== null ? R(e, s.type, s.deleted_hlc !== null) : t !== null && R(e, t.type, !0);
123
+ for (const f of n)
124
+ o = B(o, f.update, 0, f.hlc, J);
125
+ const r = o !== null && G(o) ? o : null;
126
+ (r === null || u(r.type)) && A(e), n === void 0 || n.length === 0 ? h.delete(e) : h.set(e, r), te(t, r);
127
+ const i = (f) => X(e, f, Ye(t, r));
128
+ if (r === null) {
129
+ o !== null ? i(o.deleted_hlc !== null) : t !== null && i(!0);
123
130
  return;
124
131
  }
125
- Re(t, r) && R(e, r.type, r.deleted_hlc !== null);
126
- }, B = (e, t) => {
127
- e.has(t) || e.set(t, C(t));
132
+ Be(t, r) && i(r.deleted_hlc !== null);
133
+ }, z = (e, t) => {
134
+ e.has(t) || e.set(t, D(t));
128
135
  }, ne = (e, t) => {
129
- const o = [];
130
- for (const [n, s] of d)
131
- s.some((r) => r.actionId === e) && (B(t, n), o.push(n));
132
- for (const n of o) {
133
- const r = (d.get(n) ?? []).filter((i) => i.actionId !== e);
134
- r.length === 0 ? d.delete(n) : d.set(n, r);
136
+ const s = [];
137
+ for (const [n, o] of m)
138
+ o.some((r) => r.actionId === e) && (z(t, n), s.push(n));
139
+ for (const n of s) {
140
+ const r = (m.get(n) ?? []).filter((i) => i.actionId !== e);
141
+ r.length === 0 ? m.delete(n) : m.set(n, r);
135
142
  }
136
- return o;
137
- }, he = (e, t, o) => {
143
+ return s;
144
+ }, ge = (e, t, s) => {
138
145
  const n = /* @__PURE__ */ new Map();
139
- for (const i of t) B(n, i.subject_id);
140
- const s = ne(e.id, n);
141
- for (const i of t) ee(i, e.gsn, e.hlc, o);
142
- o > E && (E = o);
146
+ for (const i of t) z(n, i.subject_id);
147
+ const o = ne(e.id, n);
148
+ for (const i of t) ee(i, e.gsn, e.hlc, s);
149
+ s > F && (F = s);
143
150
  const r = new Set(t.map((i) => i.subject_id));
144
- for (const i of s) r.add(i);
151
+ for (const i of o) r.add(i);
145
152
  for (const i of r) L(i, n.get(i) ?? null);
146
- return F(), u;
147
- }, ge = (e) => {
148
- const t = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set();
153
+ return N(), d;
154
+ }, me = (e) => {
155
+ const t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Set();
149
156
  for (const n of e.updates) {
150
- const s = n.subject_id;
151
- B(t, s), o.add(s);
152
- const r = { actionId: e.id, update: n, hlc: e.hlc }, i = d.get(s);
153
- i === void 0 ? d.set(s, [r]) : i.push(r);
157
+ const o = n.subject_id;
158
+ z(t, o), s.add(o);
159
+ const r = { actionId: e.id, update: n, hlc: e.hlc }, i = m.get(o);
160
+ i === void 0 ? m.set(o, [r]) : i.push(r);
154
161
  }
155
- for (const n of o) L(n, t.get(n) ?? null);
156
- return F(), u;
157
- }, ye = (e) => {
158
- const t = /* @__PURE__ */ new Map(), o = ne(e, t);
159
- for (const n of o) L(n, t.get(n) ?? null);
160
- return F(), u;
161
- }, j = (e) => {
162
+ for (const n of s) L(n, t.get(n) ?? null);
163
+ return N(), d;
164
+ }, Ie = (e) => {
165
+ const t = /* @__PURE__ */ new Map(), s = ne(e, t);
166
+ for (const n of s) L(n, t.get(n) ?? null);
167
+ return N(), d;
168
+ }, k = (e) => {
162
169
  const t = /* @__PURE__ */ new Set();
163
- let o = !1;
170
+ let s = !1;
164
171
  for (const n of e) {
165
172
  if (t.has(n)) continue;
166
- t.add(n), z(n), A(n), M.delete(n);
167
- const s = C(n), r = l.get(n);
168
- l.delete(n), d.delete(n), h.delete(n), y.delete(n), r !== void 0 && x(r.type, n), te(s, null);
169
- const i = s ?? r ?? null;
170
- i !== null && (o = !0, R(n, i.type, !0));
173
+ t.add(n), Y(n), A(n), E.delete(n);
174
+ const o = D(n), r = l.get(n);
175
+ l.delete(n), m.delete(n), h.delete(n), I.delete(n), r !== void 0 && P(r.type, n), te(o, null);
176
+ const i = o ?? r ?? null;
177
+ i !== null && (s = !0, X(n, !0, ke(i)));
171
178
  }
172
- return o && F(), u;
179
+ return s && N(), d;
173
180
  }, ve = (e) => {
174
- if (!je(e)) return u;
175
- l.clear(), p.clear(), y.clear(), d.clear(), h.clear(), M.clear(), v.clear(), S.clear();
176
- for (const s of g.keys()) A(s);
177
- I.length = 0, w = 0;
178
- const t = {}, o = {}, n = (s, r) => {
179
- const i = s[r.key];
180
- i === void 0 ? s[r.key] = { [r.rowId]: r.value } : i[r.rowId] = r.value;
181
+ if (!Ce(e)) return d;
182
+ l.clear(), p.clear(), I.clear(), m.clear(), h.clear(), E.clear(), v.clear(), j.clear();
183
+ for (const o of g.keys()) A(o);
184
+ w.length = 0, b = 0;
185
+ const t = {}, s = {}, n = (o, r) => {
186
+ const i = o[r.key];
187
+ i === void 0 ? o[r.key] = { [r.rowId]: r.value } : i[r.rowId] = r.value;
181
188
  };
182
- for (const s of e.entities) {
183
- if (!a(s.type)) continue;
184
- const r = re(s);
185
- l.set(r.id, r), P(r.type, r.id);
186
- const i = ke(r);
189
+ for (const o of e.entities) {
190
+ if (!u(o.type)) continue;
191
+ const r = re(o);
192
+ l.set(r.id, r), C(r.type, r.id);
193
+ const i = Pe(r);
187
194
  i !== null && n(t, i);
188
- const b = Se(r);
189
- b !== null && n(o, b);
195
+ const f = Ae(r);
196
+ f !== null && n(s, f);
190
197
  }
191
- return N = t, m = o, u = e.revision > u ? e.revision : u + 1, O = u, E = e.position, F(), u;
192
- }, Ie = () => {
198
+ return y = De(l.values()), O = t, M = s, d = e.revision > d ? e.revision : d + 1, x = d, F = e.position, N(), d;
199
+ }, ye = () => {
193
200
  let e = Number.POSITIVE_INFINITY;
194
- for (const n of y.values())
195
- for (const s of n) e = Math.min(e, s.position);
196
- const t = e === Number.POSITIVE_INFINITY ? E : Math.min(E, e - 1), o = [];
201
+ for (const n of I.values())
202
+ for (const o of n) e = Math.min(e, o.position);
203
+ const t = e === Number.POSITIVE_INFINITY ? F : Math.min(F, e - 1), s = [];
197
204
  for (const n of l.values())
198
- a(n.type) && o.push(Ne(n));
205
+ u(n.type) && s.push(Se(n));
199
206
  return {
200
- format: Oe,
207
+ format: je,
201
208
  position: t,
202
- revision: u,
203
- entities: o
209
+ revision: d,
210
+ entities: s
204
211
  };
205
212
  }, we = () => {
206
- const e = {}, t = {}, o = new Set(p.keys());
213
+ const e = {}, t = {}, s = new Set(p.keys());
207
214
  for (const r of h.values())
208
- r !== null && o.add(r.type);
209
- let n = 0, s = 0;
210
- for (const r of o) {
215
+ r !== null && s.add(r.type);
216
+ let n = 0, o = 0;
217
+ for (const r of s) {
211
218
  const i = $(r).length;
212
- i !== 0 && (e[r] = i, n += i, a(r) && (t[r] = i, s += i));
219
+ i !== 0 && (e[r] = i, n += i, u(r) && (t[r] = i, o += i));
213
220
  }
214
221
  return {
215
222
  entities: n,
216
223
  byType: e,
217
- held: s,
224
+ held: o,
218
225
  heldByType: t,
219
226
  pinned: g.size,
220
- revision: u,
221
- position: E,
227
+ revision: d,
228
+ position: F,
222
229
  changes: Z(),
223
- changeFloor: O
230
+ changeFloor: x
224
231
  };
225
- }, me = (e) => {
226
- if (e < O) return [];
232
+ }, be = (e) => {
233
+ if (e < x) return [];
227
234
  const t = [];
228
- for (let o = w; o < I.length; o += 1) {
229
- const n = I[o];
235
+ for (let s = b; s < w.length; s += 1) {
236
+ const n = w[s];
230
237
  n.revision > e && t.push(n);
231
238
  }
232
239
  return t;
233
- }, be = (e, t, o) => {
234
- const n = C(e);
235
- l.set(e, t), P(t.type, e), X(e);
236
- for (const s of o) ee(s.update, s.gsn, s.hlc, s.position);
237
- L(e, n), F();
240
+ }, Me = (e, t, s) => {
241
+ const n = D(e);
242
+ l.set(e, t), C(t.type, e), Q(e);
243
+ for (const o of s) ee(o.update, o.gsn, o.hlc, o.position);
244
+ L(e, n), N();
238
245
  };
239
246
  return {
240
247
  get revision() {
241
- return u;
248
+ return d;
242
249
  },
243
250
  get changeFloor() {
244
- return O;
251
+ return x;
245
252
  },
246
- get: D,
253
+ get: R,
247
254
  base: (e) => l.get(e),
248
255
  iterate: $,
249
- isHeld: a,
256
+ isHeld: u,
250
257
  open: (e) => {
251
- const t = D(e);
258
+ const t = R(e);
252
259
  if (t !== void 0)
253
- return a(t.type) || X(e), Promise.resolve(t);
254
- const o = v.get(e);
255
- if (o !== void 0) return o;
260
+ return u(t.type) || Q(e), Promise.resolve(t);
261
+ const s = v.get(e);
262
+ if (s !== void 0) return s;
256
263
  const n = c?.readEntity;
257
264
  if (n === void 0) return Promise.resolve(null);
258
- const s = ++G;
259
- S.set(e, s);
265
+ const o = ++W;
266
+ j.set(e, o);
260
267
  const r = n(e).then(
261
268
  (i) => {
262
- if (v.get(e) === r && v.delete(e), S.get(e) !== s) return null;
263
- const b = M.get(e) ?? [];
264
- if (M.delete(e), i === null) return null;
265
- if (a(i.type)) return i;
266
- const K = re(i);
267
- return be(e, K, b), D(e) ?? K;
269
+ if (v.get(e) === r && v.delete(e), j.get(e) !== o) return null;
270
+ const f = E.get(e) ?? [];
271
+ if (E.delete(e), i === null) return null;
272
+ if (u(i.type)) return i;
273
+ const S = re(i);
274
+ return Me(e, S, f), R(e) ?? S;
268
275
  },
269
276
  (i) => {
270
277
  throw v.get(e) === r && v.delete(e), i;
@@ -273,36 +280,38 @@ const fe = (c, f) => {
273
280
  return v.set(e, r), r;
274
281
  },
275
282
  close: (e) => {
276
- const t = C(e);
283
+ const t = D(e);
277
284
  if (t === null) {
278
- z(e);
285
+ Y(e);
279
286
  return;
280
287
  }
281
- a(t.type) || (z(e), g.has(e) ? ue(e) : j([e]));
288
+ u(t.type) || (Y(e), g.has(e) ? de(e) : k([e]));
282
289
  },
283
- isOpen: de,
284
- changesSince: me,
290
+ isOpen: pe,
291
+ changesSince: be,
285
292
  stats: we,
286
- relationships: (e) => e.sourceId !== void 0 ? V(m[se(e.as, e.type, e.sourceId)]) : e.targetId !== void 0 ? V(N[Fe(e.as, e.type, e.targetId)]) : [],
287
- memberships: (e) => e.groupId !== void 0 ? V(N[Ee(e.groupId)]) : e.entityId !== void 0 ? V(m[oe(e.entityId)]) : [],
288
- relationshipLinks: (e) => Me(m[se(e.as, e.type, e.sourceId)]),
289
- membershipLinks: (e) => _e(m[oe(e)]),
290
- ingest: he,
291
- optimistic: ge,
292
- discard: ye,
293
+ relationships: (e) => e.sourceId !== void 0 ? K(M[oe(e.as, e.type, e.sourceId)]) : e.targetId !== void 0 ? K(O[xe(e.as, e.type, e.targetId)]) : [],
294
+ components: (e) => Oe(y, e),
295
+ memberships: (e) => e.groupId !== void 0 ? K(O[Ne(e.groupId)]) : e.entityId !== void 0 ? K(M[se(e.entityId)]) : [],
296
+ relationshipLinks: (e) => Fe(M[oe(e.as, e.type, e.sourceId)]),
297
+ membershipLinks: (e) => Ee(M[se(e)]),
298
+ ingest: ge,
299
+ optimistic: me,
300
+ discard: Ie,
293
301
  load: ve,
294
- toRecord: Ie,
295
- evict: j,
296
- subscribe: (e) => (Y.add(e), () => {
297
- Y.delete(e);
302
+ toRecord: ye,
303
+ evict: k,
304
+ subscribe: (e) => (U.add(e), () => {
305
+ U.delete(e);
298
306
  })
299
307
  };
300
308
  };
301
309
  export {
302
- Le as DEFAULT_PINNED_CAPACITY,
303
- Ke as DEFAULT_PINNED_TTL_MS,
304
- J as applyUpdate,
305
- Re as contentChanged,
306
- He as createReplica,
307
- Ce as holdAll
310
+ We as DEFAULT_PINNED_CAPACITY,
311
+ Ge as DEFAULT_PINNED_TTL_MS,
312
+ B as applyUpdate,
313
+ Be as contentChanged,
314
+ tt as createReplica,
315
+ st as foldEntityAction,
316
+ Je as holdAll
308
317
  };