@instantdb/react-common 1.0.40-branch-drewh-user-sync-less-often.26546252190.1 → 1.0.40-branch-python-sdk-v1.26548577482.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/standalone/index.js
CHANGED
|
@@ -4166,7 +4166,7 @@ function pr(n) {
|
|
|
4166
4166
|
}, e;
|
|
4167
4167
|
}, {});
|
|
4168
4168
|
}
|
|
4169
|
-
const fs = "v1.0.40-branch-
|
|
4169
|
+
const fs = "v1.0.40-branch-python-sdk-v1.26548577482.1";
|
|
4170
4170
|
function Ua(n, e) {
|
|
4171
4171
|
return {
|
|
4172
4172
|
info: n ? (...t) => console.info(...t, e()) : () => {
|
|
@@ -5586,11 +5586,11 @@ const Te = {
|
|
|
5586
5586
|
AUTHENTICATED: "authenticated",
|
|
5587
5587
|
CLOSED: "closed",
|
|
5588
5588
|
ERRORED: "errored"
|
|
5589
|
-
}, ic = 3e4, oc = 3e4, ac = 200, cc = {
|
|
5589
|
+
}, ic = 3e4, oc = 3e4, ac = 200, cc = 1e3 * 60, uc = {
|
|
5590
5590
|
apiURI: "https://api.instantdb.com",
|
|
5591
5591
|
websocketURI: "wss://api.instantdb.com/runtime/session"
|
|
5592
5592
|
}, Vt = "_instant_oauth_redirect", Qt = "_instant_extra_fields_id", gt = "oauthExtraFields", Fe = "currentUser";
|
|
5593
|
-
function
|
|
5593
|
+
function lc({ transportType: n, appId: e, apiURI: t, wsURI: r, EventSourceImpl: s }) {
|
|
5594
5594
|
if (!s)
|
|
5595
5595
|
return new mr(`${r}?app_id=${e}`);
|
|
5596
5596
|
switch (n) {
|
|
@@ -5602,7 +5602,7 @@ function uc({ transportType: n, appId: e, apiURI: t, wsURI: r, EventSourceImpl:
|
|
|
5602
5602
|
throw new Error("Unknown transport type " + n);
|
|
5603
5603
|
}
|
|
5604
5604
|
}
|
|
5605
|
-
function
|
|
5605
|
+
function fc() {
|
|
5606
5606
|
return typeof window < "u" || typeof chrome < "u";
|
|
5607
5607
|
}
|
|
5608
5608
|
const Sr = {
|
|
@@ -5611,7 +5611,7 @@ const Sr = {
|
|
|
5611
5611
|
"refresh-presence": !0,
|
|
5612
5612
|
"patch-presence": !0
|
|
5613
5613
|
};
|
|
5614
|
-
function
|
|
5614
|
+
function dc(n, e) {
|
|
5615
5615
|
var r;
|
|
5616
5616
|
const t = typeof n == "string" ? JSON.parse(n) : n;
|
|
5617
5617
|
if ((r = t == null ? void 0 : t.result) != null && r.store) {
|
|
@@ -5626,7 +5626,7 @@ function fc(n, e) {
|
|
|
5626
5626
|
}
|
|
5627
5627
|
return t;
|
|
5628
5628
|
}
|
|
5629
|
-
function
|
|
5629
|
+
function hc(n, e) {
|
|
5630
5630
|
const { result: t, ...r } = e, s = (
|
|
5631
5631
|
/** @type {import('./reactorTypes.ts').QuerySubInStorage} */
|
|
5632
5632
|
r
|
|
@@ -5641,7 +5641,7 @@ function dc(n, e) {
|
|
|
5641
5641
|
}
|
|
5642
5642
|
return s;
|
|
5643
5643
|
}
|
|
5644
|
-
function
|
|
5644
|
+
function pc(n, e) {
|
|
5645
5645
|
switch (n) {
|
|
5646
5646
|
case "pendingMutations":
|
|
5647
5647
|
return new Map(typeof e == "string" ? JSON.parse(e) : e);
|
|
@@ -5649,7 +5649,7 @@ function hc(n, e) {
|
|
|
5649
5649
|
return e;
|
|
5650
5650
|
}
|
|
5651
5651
|
}
|
|
5652
|
-
function
|
|
5652
|
+
function yc(n, e) {
|
|
5653
5653
|
switch (n) {
|
|
5654
5654
|
case "pendingMutations":
|
|
5655
5655
|
return [...e.entries()];
|
|
@@ -5657,7 +5657,7 @@ function pc(n, e) {
|
|
|
5657
5657
|
return e;
|
|
5658
5658
|
}
|
|
5659
5659
|
}
|
|
5660
|
-
function
|
|
5660
|
+
function bc(n, e, t) {
|
|
5661
5661
|
const r = e == null ? void 0 : e.result, s = t == null ? void 0 : t.result;
|
|
5662
5662
|
return r && !s && t && (t.result = r), t || e;
|
|
5663
5663
|
}
|
|
@@ -5667,7 +5667,7 @@ function Bt(n) {
|
|
|
5667
5667
|
return a == c ? r < i ? -1 : r > i ? 1 : 0 : a - c;
|
|
5668
5668
|
});
|
|
5669
5669
|
}
|
|
5670
|
-
class
|
|
5670
|
+
class gc {
|
|
5671
5671
|
constructor(e, t = os, r = as, s, i) {
|
|
5672
5672
|
/** @type {s.AttrsStore | undefined} */
|
|
5673
5673
|
p(this, "attrs");
|
|
@@ -5869,7 +5869,7 @@ class bc {
|
|
|
5869
5869
|
}
|
|
5870
5870
|
this._log.info("[socket][close]", t.id, "schedule reconnect, ms =", this._reconnectTimeoutMs), this._scheduleReconnect();
|
|
5871
5871
|
});
|
|
5872
|
-
if (this._EventSource = i, this.config = { ...
|
|
5872
|
+
if (this._EventSource = i, this.config = { ...uc, ...e }, this.queryCacheLimit = this.config.queryCacheLimit ?? 10, this._pendingTxCleanupTimeout = this.config.pendingTxCleanupTimeout ?? oc, this._pendingMutationCleanupThreshold = this.config.pendingMutationCleanupThreshold ?? ac, this._log = Ua(e.verbose || Cn || cs, () => this._reactorStats()), this.versions = { ...s || {}, "@instantdb/core": fs }, this.config.schema && (this._linkIndex = pr(this.config.schema)), !!fc()) {
|
|
5873
5873
|
if (!e.appId)
|
|
5874
5874
|
throw new Error("Instant must be initialized with an appId.");
|
|
5875
5875
|
if (!Ve(e.appId))
|
|
@@ -5895,7 +5895,12 @@ class bc {
|
|
|
5895
5895
|
RStream: this.config.ReadableStream || ReadableStream,
|
|
5896
5896
|
trySend: this._trySendAuthed.bind(this),
|
|
5897
5897
|
log: this._log
|
|
5898
|
-
}), this._oauthCallbackResponse = this._oauthLoginInit(),
|
|
5898
|
+
}), this._oauthCallbackResponse = this._oauthLoginInit(), this.getCurrentUser().then((o) => {
|
|
5899
|
+
this.syncUserToEndpoint(o.user);
|
|
5900
|
+
}), setInterval(async () => {
|
|
5901
|
+
const o = await this.getCurrentUser();
|
|
5902
|
+
this.syncUserToEndpoint(o.user);
|
|
5903
|
+
}, cc), r.getIsOnline().then((o) => {
|
|
5899
5904
|
this._isOnline = o, this._startSocket(), r.listen((a) => {
|
|
5900
5905
|
a !== this._isOnline && (this._log.info("[network] online =", a), this._isOnline = a, this._isOnline ? this._startSocket() : (this._log.info("Changing status from", this.status, "to", Te.CLOSED), this._setStatus(Te.CLOSED)));
|
|
5901
5906
|
});
|
|
@@ -5934,9 +5939,9 @@ class bc {
|
|
|
5934
5939
|
_initStorage(e) {
|
|
5935
5940
|
this.querySubs = new hn({
|
|
5936
5941
|
persister: new e(this.config.appId, "querySubs"),
|
|
5937
|
-
merge:
|
|
5938
|
-
serialize:
|
|
5939
|
-
parse: (t, r) =>
|
|
5942
|
+
merge: bc,
|
|
5943
|
+
serialize: hc,
|
|
5944
|
+
parse: (t, r) => dc(r, this.config.useDateObjects),
|
|
5940
5945
|
// objectSize
|
|
5941
5946
|
objectSize: (t) => {
|
|
5942
5947
|
var r, s, i;
|
|
@@ -5955,8 +5960,8 @@ class bc {
|
|
|
5955
5960
|
}), this.querySubs.onKeyLoaded = (t) => this._onQuerySubLoaded(t), this.kv = new hn({
|
|
5956
5961
|
persister: new e(this.config.appId, "kv"),
|
|
5957
5962
|
merge: this._onMergeKv,
|
|
5958
|
-
serialize:
|
|
5959
|
-
parse:
|
|
5963
|
+
serialize: yc,
|
|
5964
|
+
parse: pc,
|
|
5960
5965
|
objectSize: () => 0,
|
|
5961
5966
|
logger: this._log,
|
|
5962
5967
|
saveThrottleMs: 100,
|
|
@@ -6599,7 +6604,7 @@ class bc {
|
|
|
6599
6604
|
return;
|
|
6600
6605
|
}
|
|
6601
6606
|
const e = this._transport;
|
|
6602
|
-
this._transport =
|
|
6607
|
+
this._transport = lc({
|
|
6603
6608
|
transportType: this._transportType,
|
|
6604
6609
|
appId: this.config.appId,
|
|
6605
6610
|
apiURI: this.config.apiURI,
|
|
@@ -6797,7 +6802,7 @@ class bc {
|
|
|
6797
6802
|
async syncUserToEndpoint(e) {
|
|
6798
6803
|
if (this.config.firstPartyPath)
|
|
6799
6804
|
try {
|
|
6800
|
-
|
|
6805
|
+
await fetch(this.config.firstPartyPath + "/", {
|
|
6801
6806
|
method: "POST",
|
|
6802
6807
|
body: JSON.stringify({
|
|
6803
6808
|
type: "sync-user",
|
|
@@ -6808,8 +6813,6 @@ class bc {
|
|
|
6808
6813
|
"Content-Type": "application/json"
|
|
6809
6814
|
}
|
|
6810
6815
|
});
|
|
6811
|
-
if (!t.ok)
|
|
6812
|
-
throw new Error(`HTTP error! status: ${t.status}`);
|
|
6813
6816
|
} catch (t) {
|
|
6814
6817
|
this._log.error("Error syncing user with external endpoint", t);
|
|
6815
6818
|
}
|
|
@@ -7163,9 +7166,9 @@ class bc {
|
|
|
7163
7166
|
}
|
|
7164
7167
|
}
|
|
7165
7168
|
let _t;
|
|
7166
|
-
function
|
|
7169
|
+
function _c(n, e) {
|
|
7167
7170
|
_t == null || _t.dispose();
|
|
7168
|
-
const t =
|
|
7171
|
+
const t = Ac(e), r = Tc(e, a), s = wc(mc(n));
|
|
7169
7172
|
function i(l) {
|
|
7170
7173
|
var f;
|
|
7171
7174
|
l.source === s.element.contentWindow && ((f = l.data) == null ? void 0 : f.type) === "close" && t.isVisible() && a();
|
|
@@ -7187,10 +7190,10 @@ function gc(n, e) {
|
|
|
7187
7190
|
}
|
|
7188
7191
|
return u();
|
|
7189
7192
|
}
|
|
7190
|
-
function
|
|
7193
|
+
function mc(n) {
|
|
7191
7194
|
return `${Cn || us ? "http://localhost:3000" : "https://instantdb.com"}/_devtool?appId=${n}`;
|
|
7192
7195
|
}
|
|
7193
|
-
function
|
|
7196
|
+
function wc(n) {
|
|
7194
7197
|
const e = document.createElement("iframe");
|
|
7195
7198
|
return e.src = n, e.className = "instant-devtool-iframe", Object.assign(e.style, {
|
|
7196
7199
|
width: "100%",
|
|
@@ -7199,7 +7202,7 @@ function mc(n) {
|
|
|
7199
7202
|
border: "none"
|
|
7200
7203
|
}), { element: e };
|
|
7201
7204
|
}
|
|
7202
|
-
function
|
|
7205
|
+
function Tc(n, e) {
|
|
7203
7206
|
const t = `
|
|
7204
7207
|
<svg width="32" height="32" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
7205
7208
|
<rect width="512" height="512" fill="black"/>
|
|
@@ -7209,7 +7212,7 @@ function wc(n, e) {
|
|
|
7209
7212
|
return r.innerHTML = t, r.className = "instant-devtool-toggler", Object.assign(r.style, {
|
|
7210
7213
|
// pos
|
|
7211
7214
|
position: "fixed",
|
|
7212
|
-
...
|
|
7215
|
+
...Sc(n.position),
|
|
7213
7216
|
height: "32px",
|
|
7214
7217
|
width: "32px",
|
|
7215
7218
|
// layout
|
|
@@ -7224,7 +7227,7 @@ function wc(n, e) {
|
|
|
7224
7227
|
cursor: "pointer"
|
|
7225
7228
|
}), r.addEventListener("click", e), { element: r };
|
|
7226
7229
|
}
|
|
7227
|
-
function
|
|
7230
|
+
function Sc(n) {
|
|
7228
7231
|
switch (n) {
|
|
7229
7232
|
case "bottom-left":
|
|
7230
7233
|
return { bottom: "24px", left: "24px" };
|
|
@@ -7236,7 +7239,7 @@ function Tc(n) {
|
|
|
7236
7239
|
return { top: "24px", left: "24px" };
|
|
7237
7240
|
}
|
|
7238
7241
|
}
|
|
7239
|
-
function
|
|
7242
|
+
function vc(n) {
|
|
7240
7243
|
switch (n) {
|
|
7241
7244
|
case "bottom-left":
|
|
7242
7245
|
return { bottom: "24px", right: "24px", left: "60px", top: "72px" };
|
|
@@ -7248,11 +7251,11 @@ function Sc(n) {
|
|
|
7248
7251
|
return { top: "24px", right: "24px", left: "60px", bottom: "72px" };
|
|
7249
7252
|
}
|
|
7250
7253
|
}
|
|
7251
|
-
function
|
|
7254
|
+
function Ac(n) {
|
|
7252
7255
|
const e = document.createElement("div");
|
|
7253
7256
|
Object.assign(e.style, {
|
|
7254
7257
|
position: "fixed",
|
|
7255
|
-
...
|
|
7258
|
+
...vc(n.position),
|
|
7256
7259
|
display: "block",
|
|
7257
7260
|
borderRadius: "4px",
|
|
7258
7261
|
border: "1px #ccc solid",
|
|
@@ -7269,10 +7272,10 @@ function Ze(n, e) {
|
|
|
7269
7272
|
if (!n)
|
|
7270
7273
|
throw new Error("[assertion error] " + e);
|
|
7271
7274
|
}
|
|
7272
|
-
const
|
|
7275
|
+
const Oc = (n) => JSON.stringify(n), rt = (n, e = !1) => JSON.stringify([n, e]), vr = (n) => {
|
|
7273
7276
|
const [e, t] = JSON.parse(n);
|
|
7274
7277
|
return { cursor: e, afterInclusive: t };
|
|
7275
|
-
}, Ne = (n, e, t = !1) => `${n}:${rt(e, t)}`,
|
|
7278
|
+
}, Ne = (n, e, t = !1) => `${n}:${rt(e, t)}`, Ec = (n) => !!n.endCursor, kc = (n) => {
|
|
7276
7279
|
var t;
|
|
7277
7280
|
const e = Array.from(n.values());
|
|
7278
7281
|
return e.length === 0 ? !1 : ((t = e[e.length - 1]) == null ? void 0 : t.hasMore) || !1;
|
|
@@ -7289,7 +7292,7 @@ const Ac = (n) => JSON.stringify(n), rt = (n, e = !1) => JSON.stringify([n, e]),
|
|
|
7289
7292
|
};
|
|
7290
7293
|
}, _s = (n) => n && Object.keys(n).length > 0 ? n : {
|
|
7291
7294
|
serverCreatedAt: "asc"
|
|
7292
|
-
},
|
|
7295
|
+
}, Cc = (n, e) => {
|
|
7293
7296
|
const t = [
|
|
7294
7297
|
...Array.from(e.values()).slice().reverse(),
|
|
7295
7298
|
...Array.from(n.values())
|
|
@@ -7298,7 +7301,7 @@ const Ac = (n) => JSON.stringify(n), rt = (n, e = !1) => JSON.stringify([n, e]),
|
|
|
7298
7301
|
...Array.from(n.values()).flatMap((s) => s.data)
|
|
7299
7302
|
];
|
|
7300
7303
|
return { chunks: t, data: r };
|
|
7301
|
-
}, Gt = ["bootstrap", "bootstrap", "bootstrap", 1],
|
|
7304
|
+
}, Gt = ["bootstrap", "bootstrap", "bootstrap", 1], Ic = (n, e, t, r) => {
|
|
7302
7305
|
var B, z, ee, q;
|
|
7303
7306
|
const { entityName: s, entityQuery: i } = ms(e), o = ((B = i.$) == null ? void 0 : B.limit) || 10, a = s, c = _s((z = i.$) == null ? void 0 : z.order), u = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map();
|
|
7304
7307
|
let h = !1, y = !0, b = null, g = null;
|
|
@@ -7307,12 +7310,12 @@ const Ac = (n) => JSON.stringify(n), rt = (n, e = !1) => JSON.stringify([n, e]),
|
|
|
7307
7310
|
}, S = () => {
|
|
7308
7311
|
if (!y)
|
|
7309
7312
|
return;
|
|
7310
|
-
const { chunks: E, data: j } =
|
|
7313
|
+
const { chunks: E, data: j } = Cc(u, l);
|
|
7311
7314
|
t({
|
|
7312
7315
|
data: { [a]: j },
|
|
7313
7316
|
// @ts-expect-error hidden debug variable
|
|
7314
7317
|
chunks: E,
|
|
7315
|
-
canLoadNextPage:
|
|
7318
|
+
canLoadNextPage: kc(u)
|
|
7316
7319
|
});
|
|
7317
7320
|
}, _ = (E, j) => {
|
|
7318
7321
|
u.set(rt(E, j.afterInclusive), j), S();
|
|
@@ -7436,9 +7439,9 @@ const Ac = (n) => JSON.stringify(n), rt = (n, e = !1) => JSON.stringify([n, e]),
|
|
|
7436
7439
|
if (!E)
|
|
7437
7440
|
return;
|
|
7438
7441
|
const [j, M] = E;
|
|
7439
|
-
if (!(M != null && M.hasMore) || !
|
|
7442
|
+
if (!(M != null && M.hasMore) || !Ec(M))
|
|
7440
7443
|
return;
|
|
7441
|
-
const U = `${j}:${
|
|
7444
|
+
const U = `${j}:${Oc(M.endCursor)}`;
|
|
7442
7445
|
U != b && (b = U, R(j, M), O(M.endCursor));
|
|
7443
7446
|
}, G = () => {
|
|
7444
7447
|
const E = Array.from(u.entries()).at(-1);
|
|
@@ -7494,7 +7497,7 @@ const Ac = (n) => JSON.stringify(n), rt = (n, e = !1) => JSON.stringify([n, e]),
|
|
|
7494
7497
|
},
|
|
7495
7498
|
loadNextPage: G
|
|
7496
7499
|
};
|
|
7497
|
-
},
|
|
7500
|
+
}, Pc = (n, e, t) => {
|
|
7498
7501
|
var u, l, f, h;
|
|
7499
7502
|
if (!e)
|
|
7500
7503
|
return {
|
|
@@ -7531,22 +7534,22 @@ const Ac = (n) => JSON.stringify(n), rt = (n, e = !1) => JSON.stringify([n, e]),
|
|
|
7531
7534
|
if (!t || !r)
|
|
7532
7535
|
throw new Q("No query provided for infinite query");
|
|
7533
7536
|
return { entityName: t, entityQuery: r };
|
|
7534
|
-
},
|
|
7537
|
+
}, Rc = {
|
|
7535
7538
|
apiURI: "https://api.instantdb.com",
|
|
7536
7539
|
websocketURI: "wss://api.instantdb.com/runtime/session"
|
|
7537
7540
|
};
|
|
7538
|
-
function
|
|
7541
|
+
function Mc() {
|
|
7539
7542
|
return globalThis.__instantDbSchemaHashStore = globalThis.__instantDbSchemaHashStore ?? /* @__PURE__ */ new WeakMap(), globalThis.__instantDbSchemaHashStore;
|
|
7540
7543
|
}
|
|
7541
|
-
function
|
|
7544
|
+
function jc() {
|
|
7542
7545
|
return globalThis.__instantDbStore = globalThis.__instantDbStore ?? {}, globalThis.__instantDbStore;
|
|
7543
7546
|
}
|
|
7544
7547
|
function pn(n) {
|
|
7545
7548
|
const e = n.__adminToken, t = n.__extraDedupeKey;
|
|
7546
7549
|
return n.appId + "_" + (n.websocketURI || "default_ws_uri") + "_" + (n.apiURI || "default_api_uri") + "_" + (e || "client_only") + "_" + n.useDateObjects + "_" + (t || "");
|
|
7547
7550
|
}
|
|
7548
|
-
const yn =
|
|
7549
|
-
class
|
|
7551
|
+
const yn = jc(), Or = Mc();
|
|
7552
|
+
class $c {
|
|
7550
7553
|
constructor(e) {
|
|
7551
7554
|
p(this, "db");
|
|
7552
7555
|
/**
|
|
@@ -7663,7 +7666,7 @@ class jc {
|
|
|
7663
7666
|
this.db = e;
|
|
7664
7667
|
}
|
|
7665
7668
|
}
|
|
7666
|
-
class
|
|
7669
|
+
class xc {
|
|
7667
7670
|
constructor(e) {
|
|
7668
7671
|
p(this, "db");
|
|
7669
7672
|
/**
|
|
@@ -7721,7 +7724,7 @@ class $c {
|
|
|
7721
7724
|
this.db = e;
|
|
7722
7725
|
}
|
|
7723
7726
|
}
|
|
7724
|
-
class
|
|
7727
|
+
class Dc {
|
|
7725
7728
|
constructor(e) {
|
|
7726
7729
|
p(this, "db");
|
|
7727
7730
|
/**
|
|
@@ -7750,14 +7753,14 @@ class xc {
|
|
|
7750
7753
|
function ws(n) {
|
|
7751
7754
|
return JSON.parse(JSON.stringify(n));
|
|
7752
7755
|
}
|
|
7753
|
-
class
|
|
7756
|
+
class Uc {
|
|
7754
7757
|
constructor(e) {
|
|
7755
7758
|
p(this, "_reactor");
|
|
7756
7759
|
p(this, "auth");
|
|
7757
7760
|
p(this, "storage");
|
|
7758
7761
|
p(this, "streams");
|
|
7759
7762
|
p(this, "tx", kn());
|
|
7760
|
-
this._reactor = e, this.auth = new
|
|
7763
|
+
this._reactor = e, this.auth = new $c(this._reactor), this.storage = new xc(this._reactor), this.streams = new Dc(this._reactor);
|
|
7761
7764
|
}
|
|
7762
7765
|
/**
|
|
7763
7766
|
* Use this to write data! You can create, update, delete, and link objects
|
|
@@ -7835,7 +7838,7 @@ class Dc {
|
|
|
7835
7838
|
* });
|
|
7836
7839
|
*/
|
|
7837
7840
|
subscribeInfiniteQuery(e, t, r) {
|
|
7838
|
-
return
|
|
7841
|
+
return Ic(this, e, t, r);
|
|
7839
7842
|
}
|
|
7840
7843
|
/**
|
|
7841
7844
|
* Listen for the logged in state. This is useful
|
|
@@ -7962,10 +7965,10 @@ function Er(n) {
|
|
|
7962
7965
|
const t = se(n);
|
|
7963
7966
|
return Or.set(n, t), t;
|
|
7964
7967
|
}
|
|
7965
|
-
function
|
|
7968
|
+
function Lc(n, e) {
|
|
7966
7969
|
return Er(n._reactor.config.schema) !== Er(e);
|
|
7967
7970
|
}
|
|
7968
|
-
function
|
|
7971
|
+
function Fc(n, e, t, r, s) {
|
|
7969
7972
|
var u;
|
|
7970
7973
|
const i = {
|
|
7971
7974
|
...n,
|
|
@@ -7973,15 +7976,15 @@ function Lc(n, e, t, r, s) {
|
|
|
7973
7976
|
useDateObjects: n.useDateObjects ?? !1
|
|
7974
7977
|
}, o = yn[pn(i)];
|
|
7975
7978
|
if (o)
|
|
7976
|
-
return
|
|
7977
|
-
const a = new
|
|
7978
|
-
...
|
|
7979
|
+
return Lc(o, i.schema) && o._reactor.updateSchema(i.schema), o;
|
|
7980
|
+
const a = new gc({
|
|
7981
|
+
...Rc,
|
|
7979
7982
|
...i,
|
|
7980
7983
|
cardinalityInference: !!i.schema
|
|
7981
|
-
}, e || os, t || as, { ...r || {}, "@instantdb/core": fs }, s), c = new
|
|
7982
|
-
return yn[pn(i)] = c,
|
|
7984
|
+
}, e || os, t || as, { ...r || {}, "@instantdb/core": fs }, s), c = new Uc(a);
|
|
7985
|
+
return yn[pn(i)] = c, Nc(i.appId, i.devtool), c;
|
|
7983
7986
|
}
|
|
7984
|
-
function
|
|
7987
|
+
function Nc(n, e) {
|
|
7985
7988
|
if (typeof window > "u" || typeof window.location > "u" || typeof document > "u" || typeof e == "boolean" && !e)
|
|
7986
7989
|
return;
|
|
7987
7990
|
const t = {
|
|
@@ -7989,7 +7992,7 @@ function Fc(n, e) {
|
|
|
7989
7992
|
allowedHosts: ["localhost"],
|
|
7990
7993
|
...typeof e == "object" ? e : {}
|
|
7991
7994
|
};
|
|
7992
|
-
t.allowedHosts.includes(window.location.hostname) &&
|
|
7995
|
+
t.allowedHosts.includes(window.location.hostname) && _c(n, t);
|
|
7993
7996
|
}
|
|
7994
7997
|
const kr = {
|
|
7995
7998
|
isLoading: !0,
|
|
@@ -8006,7 +8009,7 @@ function Cr(n) {
|
|
|
8006
8009
|
...n || {}
|
|
8007
8010
|
};
|
|
8008
8011
|
}
|
|
8009
|
-
function
|
|
8012
|
+
function Kc(n, e, t, r) {
|
|
8010
8013
|
e && t && "ruleParams" in t && (e = { $$ruleParams: t.ruleParams, ...e });
|
|
8011
8014
|
const s = e ? ws(e) : null, i = se(s), o = ke(
|
|
8012
8015
|
Cr(n._reactor.getPreviousResult(s))
|
|
@@ -8041,18 +8044,18 @@ function Nc(n, e, t, r) {
|
|
|
8041
8044
|
}
|
|
8042
8045
|
), query: s, queryHash: i };
|
|
8043
8046
|
}
|
|
8044
|
-
const
|
|
8047
|
+
const qc = {
|
|
8045
8048
|
error: void 0,
|
|
8046
8049
|
data: void 0,
|
|
8047
8050
|
isLoading: !0,
|
|
8048
8051
|
canLoadNextPage: !1
|
|
8049
8052
|
};
|
|
8050
|
-
function
|
|
8053
|
+
function Wc({
|
|
8051
8054
|
core: n,
|
|
8052
8055
|
query: e,
|
|
8053
8056
|
opts: t
|
|
8054
8057
|
}) {
|
|
8055
|
-
const r = ke(null), s = se(e), i = se(t), o =
|
|
8058
|
+
const r = ke(null), s = se(e), i = se(t), o = Pc(n, e, t), a = ke({
|
|
8056
8059
|
...o,
|
|
8057
8060
|
isLoading: !o.data && !o.error
|
|
8058
8061
|
}), c = Ae(
|
|
@@ -8085,7 +8088,7 @@ function qc({
|
|
|
8085
8088
|
...At(
|
|
8086
8089
|
c,
|
|
8087
8090
|
() => a.current,
|
|
8088
|
-
() =>
|
|
8091
|
+
() => qc
|
|
8089
8092
|
),
|
|
8090
8093
|
loadNextPage: () => {
|
|
8091
8094
|
var f;
|
|
@@ -8093,7 +8096,7 @@ function qc({
|
|
|
8093
8096
|
}
|
|
8094
8097
|
};
|
|
8095
8098
|
}
|
|
8096
|
-
function
|
|
8099
|
+
function zc() {
|
|
8097
8100
|
const n = ke(null);
|
|
8098
8101
|
je(() => {
|
|
8099
8102
|
t();
|
|
@@ -8106,8 +8109,8 @@ function Wc() {
|
|
|
8106
8109
|
}
|
|
8107
8110
|
return { set: e, clear: t };
|
|
8108
8111
|
}
|
|
8109
|
-
const
|
|
8110
|
-
function
|
|
8112
|
+
const Vc = 1e3;
|
|
8113
|
+
function Qc(n, e, t) {
|
|
8111
8114
|
const r = ke(t);
|
|
8112
8115
|
r.current = t, je(() => n.core._reactor.subscribeTopic(
|
|
8113
8116
|
n.type,
|
|
@@ -8118,7 +8121,7 @@ function Vc(n, e, t) {
|
|
|
8118
8121
|
}
|
|
8119
8122
|
), [n.id, e]);
|
|
8120
8123
|
}
|
|
8121
|
-
function
|
|
8124
|
+
function Bc(n, e) {
|
|
8122
8125
|
return je(() => n.core._reactor.joinRoom(n.type, n.id), [n.id]), Ae(
|
|
8123
8126
|
(r) => {
|
|
8124
8127
|
n.core._reactor.publishTopic({
|
|
@@ -8131,7 +8134,7 @@ function Qc(n, e) {
|
|
|
8131
8134
|
[n.id, e]
|
|
8132
8135
|
);
|
|
8133
8136
|
}
|
|
8134
|
-
function
|
|
8137
|
+
function Gc(n, e = {}) {
|
|
8135
8138
|
var o, a;
|
|
8136
8139
|
const [t, r] = Pr(() => n.core._reactor.getPresence(n.type, n.id, e) ?? {
|
|
8137
8140
|
peers: {},
|
|
@@ -8156,14 +8159,14 @@ function Bc(n, e = {}) {
|
|
|
8156
8159
|
publishPresence: s
|
|
8157
8160
|
}), [t, s]);
|
|
8158
8161
|
}
|
|
8159
|
-
function
|
|
8162
|
+
function Hc(n, e, t) {
|
|
8160
8163
|
je(
|
|
8161
8164
|
() => n.core._reactor.joinRoom(n.type, n.id, e),
|
|
8162
8165
|
[n.id]
|
|
8163
8166
|
), je(() => n.core._reactor.publishPresence(n.type, n.id, e), [n.type, n.id, t ?? JSON.stringify(e)]);
|
|
8164
8167
|
}
|
|
8165
|
-
function
|
|
8166
|
-
const r =
|
|
8168
|
+
function Jc(n, e, t = {}) {
|
|
8169
|
+
const r = zc(), s = Pe.usePresence(n, {
|
|
8167
8170
|
keys: [e]
|
|
8168
8171
|
}), i = Jt(() => {
|
|
8169
8172
|
const l = n._core._reactor.getPresence(
|
|
@@ -8177,7 +8180,7 @@ function Hc(n, e, t = {}) {
|
|
|
8177
8180
|
(l) => {
|
|
8178
8181
|
n.core._reactor.publishPresence(n.type, n.id, {
|
|
8179
8182
|
[e]: l
|
|
8180
|
-
}), l && ((t == null ? void 0 : t.timeout) === null || (t == null ? void 0 : t.timeout) === 0 || r.set((t == null ? void 0 : t.timeout) ??
|
|
8183
|
+
}), l && ((t == null ? void 0 : t.timeout) === null || (t == null ? void 0 : t.timeout) === 0 || r.set((t == null ? void 0 : t.timeout) ?? Vc, () => {
|
|
8181
8184
|
n.core._reactor.publishPresence(n.type, n.id, {
|
|
8182
8185
|
[e]: null
|
|
8183
8186
|
});
|
|
@@ -8200,13 +8203,13 @@ function Hc(n, e, t = {}) {
|
|
|
8200
8203
|
};
|
|
8201
8204
|
}
|
|
8202
8205
|
const Pe = {
|
|
8203
|
-
useTopicEffect:
|
|
8204
|
-
usePublishTopic:
|
|
8205
|
-
usePresence:
|
|
8206
|
-
useSyncPresence:
|
|
8207
|
-
useTypingIndicator:
|
|
8206
|
+
useTopicEffect: Qc,
|
|
8207
|
+
usePublishTopic: Bc,
|
|
8208
|
+
usePresence: Gc,
|
|
8209
|
+
useSyncPresence: Hc,
|
|
8210
|
+
useTypingIndicator: Jc
|
|
8208
8211
|
};
|
|
8209
|
-
class
|
|
8212
|
+
class Yc {
|
|
8210
8213
|
constructor(e, t, r) {
|
|
8211
8214
|
p(this, "core");
|
|
8212
8215
|
/** @deprecated use `core` instead */
|
|
@@ -8293,7 +8296,7 @@ class Jc {
|
|
|
8293
8296
|
this.core = e, this._core = this.core, this.type = t, this.id = r;
|
|
8294
8297
|
}
|
|
8295
8298
|
}
|
|
8296
|
-
const
|
|
8299
|
+
const Zc = {
|
|
8297
8300
|
isLoading: !0,
|
|
8298
8301
|
user: void 0,
|
|
8299
8302
|
error: void 0
|
|
@@ -8397,7 +8400,7 @@ class Ht {
|
|
|
8397
8400
|
* auth.user ? { goals: {} } : null,
|
|
8398
8401
|
* );
|
|
8399
8402
|
*/
|
|
8400
|
-
p(this, "useQuery", (e, t) =>
|
|
8403
|
+
p(this, "useQuery", (e, t) => Kc(this.core, e, t).state);
|
|
8401
8404
|
/**
|
|
8402
8405
|
* Listen for the logged in state. This is useful
|
|
8403
8406
|
* for deciding when to show a login screen.
|
|
@@ -8521,7 +8524,7 @@ class Ht {
|
|
|
8521
8524
|
* },
|
|
8522
8525
|
* });
|
|
8523
8526
|
*/
|
|
8524
|
-
p(this, "useInfiniteQuery", (e, t) =>
|
|
8527
|
+
p(this, "useInfiniteQuery", (e, t) => Wc({
|
|
8525
8528
|
core: this.core,
|
|
8526
8529
|
query: e,
|
|
8527
8530
|
opts: t
|
|
@@ -8554,7 +8557,7 @@ class Ht {
|
|
|
8554
8557
|
const t = this.useAuth();
|
|
8555
8558
|
return t.isLoading || t.error || t.user ? null : /* @__PURE__ */ ht.jsx(ht.Fragment, { children: e });
|
|
8556
8559
|
});
|
|
8557
|
-
this.core =
|
|
8560
|
+
this.core = Fc(
|
|
8558
8561
|
e,
|
|
8559
8562
|
// @ts-expect-error because TS can't resolve subclass statics
|
|
8560
8563
|
e.Store || this.constructor.Store,
|
|
@@ -8578,7 +8581,7 @@ class Ht {
|
|
|
8578
8581
|
* const { peers } = db.rooms.usePresence(room);
|
|
8579
8582
|
*/
|
|
8580
8583
|
room(e = "_defaultRoomType", t = "_defaultRoomId") {
|
|
8581
|
-
return new
|
|
8584
|
+
return new Yc(this.core, e, t);
|
|
8582
8585
|
}
|
|
8583
8586
|
_useAuth() {
|
|
8584
8587
|
const e = ke(
|
|
@@ -8589,7 +8592,7 @@ class Ht {
|
|
|
8589
8592
|
return At(
|
|
8590
8593
|
t,
|
|
8591
8594
|
() => e.current,
|
|
8592
|
-
() =>
|
|
8595
|
+
() => Zc
|
|
8593
8596
|
);
|
|
8594
8597
|
}
|
|
8595
8598
|
/**
|
|
@@ -8609,5 +8612,5 @@ class Ht {
|
|
|
8609
8612
|
p(Ht, "Store"), p(Ht, "NetworkListener"), p(Ht, "EventSourceImpl");
|
|
8610
8613
|
export {
|
|
8611
8614
|
Ht as InstantReactAbstractDatabase,
|
|
8612
|
-
|
|
8615
|
+
Kc as useQueryInternal
|
|
8613
8616
|
};
|