@declarion/react 0.419.0 → 0.421.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.
@@ -74,7 +74,8 @@ async function* u(i = {}) {
74
74
  entity: e.entity,
75
75
  degradedSeq: e.degraded_seq
76
76
  });
77
- } else if (m === "cache_reset" && h) {
77
+ } else if (m === "version_changed") yield { type: "version_changed" };
78
+ else if (m === "cache_reset" && h) {
78
79
  let e = JSON.parse(h);
79
80
  yield {
80
81
  type: "cache_reset",
@@ -5,29 +5,30 @@ import "./useChildrenData.js";
5
5
  import "./useActionData.js";
6
6
  import { useRealtimeThresholds as o } from "./useRealtimeThresholds.js";
7
7
  import { RECORD_DOCUMENTS_KEY as s } from "../lib/record-documents-key.js";
8
- import { reconcileListCaches as c } from "../lib/realtime-reconcile.js";
9
- import { ENTITY_AGGREGATE_KEY as l, entityOfRealtimeQueryKey as u, isEntityRowsKey as d, isRealtimeBackedQueryKey as f } from "../lib/realtime-query-keys.js";
10
- import { openResync as p, useResyncEngine as m } from "../lib/realtime-resync.js";
11
- import { isEntityLive as h, useRealtimeStore as g } from "../stores/realtime.js";
12
- import { cachedSchema as _ } from "./useSchema.js";
13
- import { awaitEmbedToken as v, clearEmbedToken as y, getEmbedToken as b, isEmbedTokenMode as x } from "../embed/token.js";
14
- import { refetchWhenIdle as S } from "../lib/refetch-when-idle.js";
15
- import { useEffect as C, useRef as w, useState as T } from "react";
16
- import { useQueryClient as E } from "@tanstack/react-query";
8
+ import { fetchProbe as c } from "../lib/versionTracker.js";
9
+ import { reconcileListCaches as l } from "../lib/realtime-reconcile.js";
10
+ import { ENTITY_AGGREGATE_KEY as u, entityOfRealtimeQueryKey as d, isEntityRowsKey as f, isRealtimeBackedQueryKey as p } from "../lib/realtime-query-keys.js";
11
+ import { openResync as m, useResyncEngine as h } from "../lib/realtime-resync.js";
12
+ import { isEntityLive as g, useRealtimeStore as _ } from "../stores/realtime.js";
13
+ import { cachedSchema as v } from "./useSchema.js";
14
+ import { awaitEmbedToken as y, clearEmbedToken as b, getEmbedToken as x, isEmbedTokenMode as S } from "../embed/token.js";
15
+ import { refetchWhenIdle as C } from "../lib/refetch-when-idle.js";
16
+ import { useEffect as w, useRef as T, useState as E } from "react";
17
+ import { useQueryClient as D } from "@tanstack/react-query";
17
18
  // src/hooks/useSSE.ts
18
- var D = 3e4, O = 1e3, k = 50, A = "replay_gap";
19
- function j() {
19
+ var O = 3e4, k = 1e3, A = 50, j = "replay_gap";
20
+ function M() {
20
21
  return typeof document > "u" || document.visibilityState !== "hidden";
21
22
  }
22
- function M() {
23
- let [e, t] = T(j);
24
- return C(() => {
23
+ function N() {
24
+ let [e, t] = E(M);
25
+ return w(() => {
25
26
  if (typeof document > "u") return;
26
- let e = () => t(j());
27
+ let e = () => t(M());
27
28
  return document.addEventListener("visibilitychange", e), () => document.removeEventListener("visibilitychange", e);
28
29
  }, []), e;
29
30
  }
30
- async function N(e, t, n) {
31
+ async function P(e, t, n) {
31
32
  if (t.length === 0) return;
32
33
  let r = /* @__PURE__ */ new Map();
33
34
  for (let e of t) {
@@ -35,10 +36,10 @@ async function N(e, t, n) {
35
36
  keylessReason: null,
36
37
  keyless: !1,
37
38
  rows: /* @__PURE__ */ new Map()
38
- }, n = V(e);
39
- if (n === null) t.keyless = !0, t.keylessReason = R(t.keylessReason, e.reason ?? "");
39
+ }, n = H(e);
40
+ if (n === null) t.keyless = !0, t.keylessReason = z(t.keylessReason, e.reason ?? "");
40
41
  else for (let r of n) {
41
- let n = B(r), i = t.rows.get(n);
42
+ let n = V(r), i = t.rows.get(n);
42
43
  t.rows.set(n, {
43
44
  pk: r,
44
45
  createdOnly: (i?.createdOnly ?? !0) && e.action === "created"
@@ -50,46 +51,46 @@ async function N(e, t, n) {
50
51
  for (let [t, a] of r) e.invalidateQueries({ predicate: (e) => {
51
52
  let n = e.queryKey;
52
53
  return n[0] === "entity-children" && n[3] === t;
53
- } }), t === "generated_document" && e.invalidateQueries({ predicate: (e) => e.queryKey[0] === s }), a.keyless ? F(e, t, a.keylessReason) : (U(e, t, [...a.rows.values()].map((e) => e.pk)), i.push(c(e, t, [...a.rows.values()], n).then((n) => {
54
- if (n) for (let n of ["entity-count", l]) for (let r of e.getQueryCache().findAll({ queryKey: [n, t] })) S(e, r);
54
+ } }), t === "generated_document" && e.invalidateQueries({ predicate: (e) => e.queryKey[0] === s }), a.keyless ? I(e, t, a.keylessReason) : (W(e, t, [...a.rows.values()].map((e) => e.pk)), i.push(l(e, t, [...a.rows.values()], n).then((n) => {
55
+ if (n) for (let n of ["entity-count", u]) for (let r of e.getQueryCache().findAll({ queryKey: [n, t] })) C(e, r);
55
56
  })));
56
57
  await Promise.all(i);
57
58
  }
58
- function P(e, t, n, r) {
59
+ function F(e, t, n, r) {
59
60
  let i = n.filter((e) => Object.keys(e).length > 0);
60
61
  if (i.length === 0 || i.length !== n.length) {
61
62
  r();
62
63
  return;
63
64
  }
64
- let a = i.map((e) => ({ pk: e })), o = K(e, [{
65
+ let a = i.map((e) => ({ pk: e })), o = q(e, [{
65
66
  entity: t,
66
67
  action: "updated",
67
- ids: i.map(B),
68
+ ids: i.map(V),
68
69
  objects: a
69
70
  }]);
70
- o.length === 0 ? r() : N(e, o);
71
+ o.length === 0 ? r() : P(e, o);
71
72
  }
72
- function F(e, t, n) {
73
- let r = (e) => z(e, t);
74
- n === L ? I(e, r) : e.invalidateQueries({ predicate: (e) => r(e.queryKey) });
73
+ function I(e, t, n) {
74
+ let r = (e) => B(e, t);
75
+ n === R ? L(e, r) : e.invalidateQueries({ predicate: (e) => r(e.queryKey) });
75
76
  }
76
- function I(e, t) {
77
+ function L(e, t) {
77
78
  e.removeQueries({ predicate: (e) => t(e.queryKey) && e.getObserversCount() > 0 }), e.invalidateQueries({
78
79
  predicate: (e) => t(e.queryKey),
79
80
  refetchType: "none"
80
81
  });
81
82
  }
82
- var L = "access_not_projectable";
83
- function R(e, t) {
84
- return e === L || t === L ? L : e ?? t;
85
- }
83
+ var R = "access_not_projectable";
86
84
  function z(e, t) {
87
- return e[1] === t && d(e);
85
+ return e === R || t === R ? R : e ?? t;
88
86
  }
89
- function B(e) {
90
- return JSON.stringify(Object.keys(e).sort().map((t) => [t, e[t]]));
87
+ function B(e, t) {
88
+ return e[1] === t && f(e);
91
89
  }
92
90
  function V(e) {
91
+ return JSON.stringify(Object.keys(e).sort().map((t) => [t, e[t]]));
92
+ }
93
+ function H(e) {
93
94
  if (e.ids.length === 0 || !e.objects || e.objects.length === 0) return null;
94
95
  let t = [];
95
96
  for (let n of e.objects) {
@@ -98,186 +99,187 @@ function V(e) {
98
99
  }
99
100
  return t;
100
101
  }
101
- function H(e) {
102
+ function U(e) {
102
103
  let t = Object.keys(e).sort(), n = [JSON.stringify(t.map((t) => [t, e[t]]))];
103
104
  return t.length === 1 && n.push(JSON.stringify(e[t[0]])), n;
104
105
  }
105
- function U(e, t, n) {
106
+ function W(e, t, n) {
106
107
  if (n.length === 0) return;
107
108
  let r = /* @__PURE__ */ new Set();
108
- for (let e of n) for (let t of H(e)) r.add(t);
109
+ for (let e of n) for (let t of U(e)) r.add(t);
109
110
  e.invalidateQueries({ predicate: (e) => {
110
111
  let n = e.queryKey;
111
112
  return n[0] === "entity-item" && n[1] === t && r.has(JSON.stringify(n[2] ?? null));
112
113
  } });
113
114
  }
114
- function W(e) {
115
- return f(e) || e[0] === "action-data" || e[0] === "action-data-cursor";
116
- }
117
115
  function G(e) {
118
- I(e, W);
116
+ return p(e) || e[0] === "action-data" || e[0] === "action-data-cursor";
119
117
  }
120
- function K(e, t) {
121
- let n = _(e), r = g.getState().degradedEntities;
122
- return t.filter((e) => h(n?.entities?.[e.entity]?.realtime, r, e.entity));
118
+ function K(e) {
119
+ L(e, G);
123
120
  }
124
- function q(e) {
125
- let t = _(e), n = g.getState().degradedEntities;
121
+ function q(e, t) {
122
+ let n = v(e), r = _.getState().degradedEntities;
123
+ return t.filter((e) => g(n?.entities?.[e.entity]?.realtime, r, e.entity));
124
+ }
125
+ function J(e) {
126
+ let t = v(e), n = _.getState().degradedEntities;
126
127
  e.invalidateQueries({
127
128
  predicate: (e) => {
128
- let r = u(e.queryKey);
129
- return r !== null && !h(t?.entities?.[r]?.realtime, n, r);
129
+ let r = d(e.queryKey);
130
+ return r !== null && !g(t?.entities?.[r]?.realtime, n, r);
130
131
  },
131
132
  refetchType: "active"
132
133
  });
133
134
  }
134
- function J(e, t) {
135
+ function Y(e, t) {
135
136
  return e.snapshotPoint !== null && t !== void 0 && Number(t) > e.snapshotPoint;
136
137
  }
137
- function Y() {
138
- let s = e((e) => e.isAuthenticated), c = e((e) => e.activeTenant?.id ?? ""), l = E(), u = w(null), d = w(""), f = w(""), h = w(Promise.resolve()), _ = w(0), S = M(), T = w(!S);
139
- m(l), o(), C(() => {
140
- let o = g.getState();
138
+ function X() {
139
+ let s = e((e) => e.isAuthenticated), l = e((e) => e.activeTenant?.id ?? ""), u = D(), d = T(null), f = T(""), p = T(""), g = T(Promise.resolve()), v = T(0), C = N(), E = T(!C);
140
+ h(u), o(), w(() => {
141
+ let o = _.getState();
141
142
  if (!s) {
142
- d.current = "", f.current = "", T.current = !S, o.clearConnectionInterruption();
143
+ f.current = "", p.current = "", E.current = !C, o.clearConnectionInterruption();
143
144
  return;
144
145
  }
145
- if (!S) {
146
- T.current = !0, u.current?.abort(), u.current = null, o.clearConnectionInterruption();
146
+ if (!C) {
147
+ E.current = !0, d.current?.abort(), d.current = null, o.clearConnectionInterruption();
147
148
  return;
148
149
  }
149
- o.holdConnectionInterruption(), T.current && (T.current = !1, d.current && q(l)), f.current !== c && (d.current = "", f.current = c);
150
- let m = !0, C = 0, w = null, E = [], j = null, M = null, P = (e) => {
151
- h.current = h.current.then(e).catch((e) => {
150
+ o.holdConnectionInterruption(), E.current && (E.current = !1, f.current && J(u)), p.current !== l && (f.current = "", p.current = l);
151
+ let h = !0, w = 0, T = null, D = [], M = null, N = null, F = (e) => {
152
+ g.current = g.current.then(e).catch((e) => {
152
153
  console.error("realtime: applying a change batch failed", e);
153
154
  });
154
- }, F = (e, t) => {
155
- f.current === t && (d.current = e);
156
- }, I = (e) => {
155
+ }, I = (e, t) => {
156
+ p.current === t && (f.current = e);
157
+ }, L = (e) => {
157
158
  if (!e) return;
158
- L();
159
- let t = f.current;
160
- P(() => F(e, t));
161
- }, L = () => {
162
- if (j !== null && (clearTimeout(j), j = null), E.length === 0) return;
163
- let e = E.splice(0, E.length), t = u.current?.signal, n = f.current;
164
- P(() => N(l, K(l, e), t).finally(() => {
165
- for (let t of e) t.eventID && F(t.eventID, n);
166
- }));
159
+ R();
160
+ let t = p.current;
161
+ F(() => I(e, t));
167
162
  }, R = () => {
168
- j === null && (j = setTimeout(L, k));
163
+ if (M !== null && (clearTimeout(M), M = null), D.length === 0) return;
164
+ let e = D.splice(0, D.length), t = d.current?.signal, n = p.current;
165
+ F(() => P(u, q(u, e), t).finally(() => {
166
+ for (let t of e) t.eventID && I(t.eventID, n);
167
+ }));
169
168
  }, z = () => {
170
- M !== null && (clearTimeout(M), M = null);
171
- }, B = (e) => {
172
- z();
173
- let t = g.getState().thresholds;
174
- t !== null && t !== "unreadable" && (M = setTimeout(() => {
175
- M = null, m && w === e && (e.silent = !0, g.getState().holdConnectionInterruption());
176
- }, t.silenceMs));
169
+ M === null && (M = setTimeout(R, A));
170
+ }, B = () => {
171
+ N !== null && (clearTimeout(N), N = null);
177
172
  }, V = (e) => {
178
- m && w === e && e.stated && (e.silent && (e.silent = !1, g.getState().clearConnectionInterruption()), B(e));
179
- }, H = g.subscribe((e, t) => {
180
- e.thresholds !== t.thresholds && w?.stated && !w.silent && B(w);
181
- }), U = (e) => {
182
- let t = g.getState(), n = new Set(e), r = /* @__PURE__ */ new Map();
173
+ B();
174
+ let t = _.getState().thresholds;
175
+ t !== null && t !== "unreadable" && (N = setTimeout(() => {
176
+ N = null, h && T === e && (e.silent = !0, _.getState().holdConnectionInterruption());
177
+ }, t.silenceMs));
178
+ }, H = (e) => {
179
+ h && T === e && e.stated && (e.silent && (e.silent = !1, _.getState().clearConnectionInterruption()), V(e));
180
+ }, U = _.subscribe((e, t) => {
181
+ e.thresholds !== t.thresholds && T?.stated && !T.silent && V(T);
182
+ }), W = (e) => {
183
+ let t = _.getState(), n = new Set(e), r = /* @__PURE__ */ new Map();
183
184
  for (let [e, { mark: i }] of t.degradedEntities) n.has(e) || r.set(e, i);
184
185
  let i = [...n].filter((e) => !t.degradedEntities.has(e));
185
186
  for (let e of n) t.markDegraded(e);
186
- r.size > 0 && p(l, {
187
+ r.size > 0 && m(u, {
187
188
  scope: {
188
189
  kind: "entities",
189
190
  entities: new Set(r.keys())
190
191
  },
191
192
  jitter: !0,
192
193
  carriedMarks: r
193
- }), i.length > 0 && N(l, i.map((e) => ({
194
+ }), i.length > 0 && P(u, i.map((e) => ({
194
195
  entity: e,
195
196
  action: "updated",
196
197
  ids: []
197
198
  })));
198
199
  };
199
- async function W() {
200
- for (; m;) {
200
+ async function G() {
201
+ for (; h;) {
201
202
  let o = new AbortController();
202
- u.current = o;
203
- let s = x(), c = s ? b() : null, f = {
204
- seq: ++_.current,
205
- presented: d.current !== "",
203
+ d.current = o;
204
+ let s = S(), l = s ? x() : null, p = {
205
+ seq: ++v.current,
206
+ presented: f.current !== "",
206
207
  stated: !1,
207
208
  silent: !1,
208
209
  snapshotPoint: null
209
210
  };
210
- w = f;
211
- let h = g.getState();
212
- h.holdConnectionInterruption(), f.presented ? h.startReplay() : h.endReplay();
213
- let S = /* @__PURE__ */ new Set();
211
+ T = p;
212
+ let g = _.getState();
213
+ g.holdConnectionInterruption(), p.presented ? g.startReplay() : g.endReplay();
214
+ let C = /* @__PURE__ */ new Set();
214
215
  try {
215
216
  for await (let t of n({
216
217
  signal: o.signal,
217
- lastEventID: d.current,
218
- bearerToken: c ?? void 0,
218
+ lastEventID: f.current,
219
+ bearerToken: l ?? void 0,
219
220
  credentials: s ? "omit" : void 0,
220
- onActivity: () => V(f)
221
+ onActivity: () => H(p)
221
222
  })) {
222
- if (!m) break;
223
- let n = g.getState();
223
+ if (!h) break;
224
+ let n = _.getState();
224
225
  if (t.type === "session_refresh") {
225
- G(l);
226
+ K(u);
226
227
  try {
227
- s ? (y(), await v()) : await i(), l.invalidateQueries({ queryKey: ["schema"] }), e.getState().refreshMe();
228
+ s ? (b(), await y()) : await i(), u.invalidateQueries({ queryKey: ["schema"] }), e.getState().refreshMe();
228
229
  } catch {}
229
230
  break;
230
231
  }
231
232
  if (t.type === "snapshot_complete") {
232
- C = 0, f.stated = !0, f.snapshotPoint = t.asOf ?? null, n.clearConnectionInterruption(), B(f);
233
+ w = 0, p.stated = !0, p.snapshotPoint = t.asOf ?? null, n.clearConnectionInterruption(), V(p);
233
234
  let e = t.known && t.asOf !== void 0;
234
- e ? n.clearRelayInterruption() : n.holdRelayInterruption(), f.presented || (t.asOf && I(String(t.asOf)), p(l, { scope: { kind: "all" } })), e && U(S ?? []), S = null;
235
+ e ? n.clearRelayInterruption() : n.holdRelayInterruption(), p.presented || (t.asOf && L(String(t.asOf)), m(u, { scope: { kind: "all" } })), e && W(C ?? []), C = null;
235
236
  } else if (t.type === "replay_complete") {
236
- L();
237
- let e = f.seq;
238
- P(() => {
239
- _.current === e && g.getState().endReplay();
237
+ R();
238
+ let e = p.seq;
239
+ F(() => {
240
+ v.current === e && _.getState().endReplay();
240
241
  });
241
- } else if (t.type === "checkpoint") I(t.eventID);
242
- else if (t.type === "cache_reset") I(t.eventID), t.reason !== A && J(f, t.eventID) && n.holdRelayInterruption(), p(l, {
242
+ } else if (t.type === "checkpoint") L(t.eventID);
243
+ else if (t.type === "version_changed") c().catch(() => {});
244
+ else if (t.type === "cache_reset") L(t.eventID), t.reason !== j && Y(p, t.eventID) && n.holdRelayInterruption(), m(u, {
243
245
  scope: { kind: "all" },
244
246
  jitter: !0
245
247
  });
246
248
  else if (t.type === "realtime_streaming") {
247
- if (I(t.eventID), !J(f, t.eventID)) continue;
248
- n.clearRelayInterruption(), U(t.degraded);
249
+ if (L(t.eventID), !Y(p, t.eventID)) continue;
250
+ n.clearRelayInterruption(), W(t.degraded);
249
251
  } else if (t.type === "realtime_degraded") {
250
- if (S !== null) {
251
- S.add(t.entity);
252
+ if (C !== null) {
253
+ C.add(t.entity);
252
254
  continue;
253
255
  }
254
- if (I(t.eventID), !J(f, t.eventID)) continue;
255
- n.markDegraded(t.entity), N(l, [{
256
+ if (L(t.eventID), !Y(p, t.eventID)) continue;
257
+ n.markDegraded(t.entity), P(u, [{
256
258
  entity: t.entity,
257
259
  action: "updated",
258
260
  ids: []
259
261
  }]);
260
- } else t.type === "entity_changed" && (E.push({
262
+ } else t.type === "entity_changed" && (D.push({
261
263
  entity: t.entity,
262
264
  action: t.action,
263
265
  eventID: t.eventID,
264
266
  ids: t.ids,
265
267
  objects: t.objects,
266
268
  reason: t.reason
267
- }), R());
269
+ }), z());
268
270
  }
269
271
  } catch (e) {
270
- if (!m || e instanceof DOMException && e.name === "AbortError") break;
272
+ if (!h || e instanceof DOMException && e.name === "AbortError") break;
271
273
  if (e instanceof t) {
272
- if (g.getState().holdConnectionInterruption(), z(), s) try {
273
- y(), await v(), C = 0;
274
+ if (_.getState().holdConnectionInterruption(), B(), s) try {
275
+ b(), await y(), w = 0;
274
276
  continue;
275
277
  } catch {
276
278
  a()();
277
279
  return;
278
280
  }
279
281
  try {
280
- await i(), C = 0;
282
+ await i(), w = 0;
281
283
  continue;
282
284
  } catch (e) {
283
285
  if (e instanceof r) {
@@ -287,20 +289,20 @@ function Y() {
287
289
  }
288
290
  }
289
291
  }
290
- if (z(), !m) break;
291
- g.getState().holdConnectionInterruption();
292
- let T = Math.min(O * 2 ** C, D), k = T * .5 * Math.random();
293
- await new Promise((e) => setTimeout(e, T + k)), C++;
292
+ if (B(), !h) break;
293
+ _.getState().holdConnectionInterruption();
294
+ let E = Math.min(k * 2 ** w, O), A = E * .5 * Math.random();
295
+ await new Promise((e) => setTimeout(e, E + A)), w++;
294
296
  }
295
297
  }
296
- return W(), () => {
297
- m = !1, w = null, u.current?.abort(), u.current = null, z(), H(), L();
298
+ return G(), () => {
299
+ h = !1, T = null, d.current?.abort(), d.current = null, B(), U(), R();
298
300
  };
299
301
  }, [
300
302
  s,
301
- c,
302
303
  l,
303
- S
304
+ u,
305
+ C
304
306
  ]);
305
307
  }
306
- export { N as applyEntityChanges, G as evictEntityBackedQueries, K as liveEntityChanges, q as refetchQueriesReplayDoesNotCover, P as settleOwnWrite, Y as useSSE };
308
+ export { P as applyEntityChanges, K as evictEntityBackedQueries, q as liveEntityChanges, J as refetchQueriesReplayDoesNotCover, F as settleOwnWrite, X as useSSE };
@@ -23,22 +23,25 @@ function l() {
23
23
  c.channel || typeof BroadcastChannel > "u" || (c.channel = s(), c.channel && c.channel.addEventListener("message", (e) => {
24
24
  let t = e.data;
25
25
  if (t && t.type === "drift" && t.delta && !c.hasReportedDrift) {
26
- c.hasReportedDrift = !0;
26
+ t.delta.kind === "schema-only" ? u(t.delta) : c.hasReportedDrift = !0;
27
27
  for (let e of c.listeners) e(t.delta);
28
28
  }
29
29
  }));
30
30
  }
31
31
  function u(e) {
32
+ c.firstSeen = e.observed, e.components && (c.firstComponents = e.components);
33
+ }
34
+ function d(e) {
32
35
  if (l(), !e) return;
33
36
  let t = e.get(a);
34
- t && (c.firstSeen ? t !== c.firstSeen && (c.hasReportedDrift || d().catch(() => {
35
- p({
37
+ t && (c.firstSeen ? t !== c.firstSeen && (c.hasReportedDrift || f().catch(() => {
38
+ m({
36
39
  kind: "unknown",
37
40
  observed: t
38
41
  });
39
42
  })) : c.firstSeen = t);
40
43
  }
41
- async function d() {
44
+ async function f() {
42
45
  l();
43
46
  let e;
44
47
  try {
@@ -66,20 +69,20 @@ async function d() {
66
69
  asset: t.asset_fingerprint,
67
70
  binary: t.binary_fingerprint
68
71
  } : void 0;
69
- c.firstSeen ||= n, !c.firstComponents && a && n === c.firstSeen && (c.firstComponents = a), n !== c.firstSeen && p({
70
- kind: f(c.firstComponents, a),
72
+ c.firstSeen ||= n, !c.firstComponents && a && n === c.firstSeen && (c.firstComponents = a), n !== c.firstSeen && m({
73
+ kind: p(c.firstComponents, a),
71
74
  observed: n,
72
75
  components: a
73
76
  });
74
77
  }
75
- function f(e, t) {
78
+ function p(e, t) {
76
79
  if (!e || !t) return "unknown";
77
80
  let n = e.schema !== t.schema, r = e.asset !== t.asset, i = e.binary !== t.binary;
78
81
  return n && !r && !i ? "schema-only" : r || i ? "asset-or-binary" : "unknown";
79
82
  }
80
- function p(i) {
83
+ function m(i) {
81
84
  if (!c.hasReportedDrift) {
82
- c.hasReportedDrift = !0, i.kind !== "schema-only" && (c.pendingReload = i);
85
+ i.kind === "schema-only" ? u(i) : (c.hasReportedDrift = !0, c.pendingReload = i);
83
86
  for (let e of c.listeners) e(i);
84
87
  if (c.channel) try {
85
88
  c.channel.postMessage({
@@ -90,12 +93,12 @@ function p(i) {
90
93
  r() && i.kind !== "schema-only" && t(n(), e.reloadRequired, { reason: `version drift: ${i.kind}` });
91
94
  }
92
95
  }
93
- function m() {
96
+ function h() {
94
97
  return c.pendingReload;
95
98
  }
96
- function h(e) {
99
+ function g(e) {
97
100
  return c.listeners.add(e), () => {
98
101
  c.listeners.delete(e);
99
102
  };
100
103
  }
101
- export { d as fetchProbe, u as observe, m as pendingReload, h as subscribe };
104
+ export { f as fetchProbe, d as observe, h as pendingReload, g as subscribe };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@declarion/react",
3
- "version": "0.419.0",
3
+ "version": "0.421.0",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "description": "React SDK for Declarion, the schema-driven business apps platform.",