@instantdb/react 0.22.75 → 0.22.76
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/commonjs/Cursors.js +1 -1
- package/dist/commonjs/Cursors.js.map +1 -1
- package/dist/commonjs/InstantReactWebDatabase.d.ts +1 -1
- package/dist/commonjs/InstantReactWebDatabase.d.ts.map +1 -1
- package/dist/commonjs/InstantReactWebDatabase.js.map +1 -1
- package/dist/commonjs/__types__/typeUtils.d.ts +20 -0
- package/dist/commonjs/__types__/typeUtils.d.ts.map +1 -0
- package/dist/commonjs/__types__/typeUtils.js +5 -0
- package/dist/commonjs/__types__/typeUtils.js.map +1 -0
- package/dist/commonjs/__types__/typesTests.d.ts +2 -0
- package/dist/commonjs/__types__/typesTests.d.ts.map +1 -0
- package/dist/commonjs/__types__/typesTests.js +53 -0
- package/dist/commonjs/__types__/typesTests.js.map +1 -0
- package/dist/commonjs/init.d.ts +3 -1
- package/dist/commonjs/init.d.ts.map +1 -1
- package/dist/commonjs/init.js +7 -2
- package/dist/commonjs/init.js.map +1 -1
- package/dist/esm/Cursors.js +1 -1
- package/dist/esm/Cursors.js.map +1 -1
- package/dist/esm/InstantReactWebDatabase.d.ts +1 -1
- package/dist/esm/InstantReactWebDatabase.d.ts.map +1 -1
- package/dist/esm/InstantReactWebDatabase.js.map +1 -1
- package/dist/esm/__types__/typeUtils.d.ts +20 -0
- package/dist/esm/__types__/typeUtils.d.ts.map +1 -0
- package/dist/esm/__types__/typeUtils.js +4 -0
- package/dist/esm/__types__/typeUtils.js.map +1 -0
- package/dist/esm/__types__/typesTests.d.ts +2 -0
- package/dist/esm/__types__/typesTests.d.ts.map +1 -0
- package/dist/esm/__types__/typesTests.js +51 -0
- package/dist/esm/__types__/typesTests.js.map +1 -0
- package/dist/esm/init.d.ts +3 -1
- package/dist/esm/init.d.ts.map +1 -1
- package/dist/esm/init.js +7 -2
- package/dist/esm/init.js.map +1 -1
- package/dist/standalone/index.js +50 -29
- package/dist/standalone/index.umd.cjs +10 -10
- package/package.json +6 -4
- package/src/Cursors.tsx +2 -2
- package/src/InstantReactWebDatabase.ts +4 -3
- package/src/__types__/typeUtils.ts +39 -0
- package/src/__types__/typesTests.ts +86 -0
- package/src/init.ts +17 -8
- package/tsconfig.json +3 -2
- package/tsconfig.test.json +5 -0
package/dist/standalone/index.js
CHANGED
|
@@ -3550,7 +3550,7 @@ function Nr(t) {
|
|
|
3550
3550
|
}, e;
|
|
3551
3551
|
}, {});
|
|
3552
3552
|
}
|
|
3553
|
-
const Bn = "v0.22.
|
|
3553
|
+
const Bn = "v0.22.76";
|
|
3554
3554
|
function fu(t, e) {
|
|
3555
3555
|
return {
|
|
3556
3556
|
info: t ? (...n) => console.info(...n, e()) : () => {
|
|
@@ -3967,22 +3967,29 @@ class mu {
|
|
|
3967
3967
|
this.initParams || this.handleError();
|
|
3968
3968
|
}, 1e4), this.conn.onmessage = (r) => {
|
|
3969
3969
|
const i = JSON.parse(r.data);
|
|
3970
|
-
if (i
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
}, this.onopen && this.onopen({ target: this }), clearTimeout(this.sseInitTimeout);
|
|
3976
|
-
return;
|
|
3977
|
-
}
|
|
3978
|
-
this.onmessage && this.onmessage({
|
|
3979
|
-
target: this,
|
|
3980
|
-
message: i
|
|
3981
|
-
});
|
|
3970
|
+
if (Array.isArray(i))
|
|
3971
|
+
for (const s of i)
|
|
3972
|
+
this.handleMessage(s);
|
|
3973
|
+
else
|
|
3974
|
+
this.handleMessage(i);
|
|
3982
3975
|
}, this.conn.onerror = (r) => {
|
|
3983
3976
|
this.handleError();
|
|
3984
3977
|
};
|
|
3985
3978
|
}
|
|
3979
|
+
handleMessage(e) {
|
|
3980
|
+
if (e.op === "sse-init") {
|
|
3981
|
+
this.initParams = {
|
|
3982
|
+
machineId: e["machine-id"],
|
|
3983
|
+
sessionId: e["session-id"],
|
|
3984
|
+
sseToken: e["sse-token"]
|
|
3985
|
+
}, this.onopen && this.onopen({ target: this }), clearTimeout(this.sseInitTimeout);
|
|
3986
|
+
return;
|
|
3987
|
+
}
|
|
3988
|
+
this.onmessage && this.onmessage({
|
|
3989
|
+
target: this,
|
|
3990
|
+
message: e
|
|
3991
|
+
});
|
|
3992
|
+
}
|
|
3986
3993
|
// Runs the onerror and closes the connection
|
|
3987
3994
|
handleError() {
|
|
3988
3995
|
try {
|
|
@@ -4647,7 +4654,11 @@ class Ku {
|
|
|
4647
4654
|
this._log.info("[socket][message]", c.id, f, "skip; this is no longer the current transport");
|
|
4648
4655
|
return;
|
|
4649
4656
|
}
|
|
4650
|
-
!this._wsOk && c.type === "ws" && (this._wsOk = !0), this._transportType = "ws",
|
|
4657
|
+
if (!this._wsOk && c.type === "ws" && (this._wsOk = !0), this._transportType = "ws", Array.isArray(d.message))
|
|
4658
|
+
for (const l of d.message)
|
|
4659
|
+
this._handleReceive(c.id, l);
|
|
4660
|
+
else
|
|
4661
|
+
this._handleReceive(c.id, d.message);
|
|
4651
4662
|
}, this._transportOnError = (d) => {
|
|
4652
4663
|
const c = d.target;
|
|
4653
4664
|
if (this._transport !== c) {
|
|
@@ -6150,11 +6161,12 @@ function fc(t, e) {
|
|
|
6150
6161
|
return ei(t._reactor.config.schema) !== ei(e);
|
|
6151
6162
|
}
|
|
6152
6163
|
function lc(t, e, n, r, i) {
|
|
6153
|
-
|
|
6154
|
-
|
|
6155
|
-
|
|
6156
|
-
|
|
6157
|
-
|
|
6164
|
+
var s;
|
|
6165
|
+
const o = Object.assign(Object.assign({}, t), { useDateObjects: (s = t.useDateObjects) !== null && s !== void 0 ? s : !1 }), a = mn[wn(o)];
|
|
6166
|
+
if (a)
|
|
6167
|
+
return fc(a, o.schema) && a._reactor.updateSchema(o.schema), a;
|
|
6168
|
+
const u = new Ku(Object.assign(Object.assign(Object.assign({}, ic), o), { cardinalityInference: !!o.schema }), e || Ki, n || qi, Object.assign(Object.assign({}, r || {}), { "@instantdb/core": Bn }), i), d = new dc(u);
|
|
6169
|
+
return mn[wn(o)] = d, hc(o.appId, o.devtool), d;
|
|
6158
6170
|
}
|
|
6159
6171
|
function hc(t, e) {
|
|
6160
6172
|
if (typeof window > "u" || typeof window.location > "u" || typeof document > "u" || typeof e == "boolean" && !e)
|
|
@@ -6804,7 +6816,15 @@ function gc(t, e, n) {
|
|
|
6804
6816
|
e && n && "ruleParams" in n && (e = Object.assign({ $$ruleParams: n.ruleParams }, e));
|
|
6805
6817
|
const r = e ? cc(e) : null, i = z(r), s = at(ri(t._reactor.getPreviousResult(r))), o = ge(
|
|
6806
6818
|
(u) => (s.current = ri(t._reactor.getPreviousResult(r)), r ? t.subscribeQuery(r, (c) => {
|
|
6807
|
-
s.current = Object.assign({
|
|
6819
|
+
s.current = Object.assign({
|
|
6820
|
+
isLoading: !c,
|
|
6821
|
+
// @ts-expect-error: ts thinks this will always be overwritten
|
|
6822
|
+
data: void 0,
|
|
6823
|
+
// @ts-expect-error: ts thinks this will always be overwritten
|
|
6824
|
+
pageInfo: void 0,
|
|
6825
|
+
// @ts-expect-error: ts thinks this will always be overwritten
|
|
6826
|
+
error: void 0
|
|
6827
|
+
}, c), u();
|
|
6808
6828
|
}) : () => {
|
|
6809
6829
|
}),
|
|
6810
6830
|
// Build a new subscribe function if the query changes
|
|
@@ -6818,10 +6838,10 @@ function Tc() {
|
|
|
6818
6838
|
n();
|
|
6819
6839
|
}, []);
|
|
6820
6840
|
function e(r, i) {
|
|
6821
|
-
|
|
6841
|
+
n(), t.current = setTimeout(i, r);
|
|
6822
6842
|
}
|
|
6823
6843
|
function n() {
|
|
6824
|
-
clearTimeout(t.current);
|
|
6844
|
+
t.current && clearTimeout(t.current);
|
|
6825
6845
|
}
|
|
6826
6846
|
return { set: e, clear: n };
|
|
6827
6847
|
}
|
|
@@ -7385,12 +7405,13 @@ const Qn = class Qn extends Cc {
|
|
|
7385
7405
|
Qn.EventSourceImpl = kt;
|
|
7386
7406
|
let In = Qn;
|
|
7387
7407
|
function xc(t) {
|
|
7388
|
-
|
|
7389
|
-
t,
|
|
7390
|
-
|
|
7391
|
-
|
|
7392
|
-
|
|
7393
|
-
|
|
7408
|
+
const e = {
|
|
7409
|
+
...t,
|
|
7410
|
+
useDateObjects: t.useDateObjects ?? !1
|
|
7411
|
+
};
|
|
7412
|
+
return new In(e, {
|
|
7413
|
+
"@instantdb/react": Bn
|
|
7414
|
+
});
|
|
7394
7415
|
}
|
|
7395
7416
|
const qc = xc;
|
|
7396
7417
|
function Wc({
|
|
@@ -7481,7 +7502,7 @@ function Wc({
|
|
|
7481
7502
|
},
|
|
7482
7503
|
children: a ? a({
|
|
7483
7504
|
color: E.color,
|
|
7484
|
-
presence: l.peers[g]
|
|
7505
|
+
presence: l == null ? void 0 : l.peers[g]
|
|
7485
7506
|
}) : /* @__PURE__ */ W.jsx($c, { ...E })
|
|
7486
7507
|
},
|
|
7487
7508
|
g
|