@ikonai/sdk-ui 1.0.68 → 1.0.69
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/assets/ui-worker-BQcelAkD.js +2838 -0
- package/ikon-ui-core.d.ts +2 -0
- package/index.js +59 -47
- package/package.json +1 -1
- package/ui-store-ops.d.ts +1 -0
- package/assets/ui-worker-BemkVCay.js +0 -2831
package/ikon-ui-core.d.ts
CHANGED
|
@@ -53,6 +53,7 @@ export declare class IkonUiCore {
|
|
|
53
53
|
private readonly useUiWorker;
|
|
54
54
|
private liveSnapshot;
|
|
55
55
|
private unsubscribeLiveSnapshotCapture?;
|
|
56
|
+
private readonly seedStreamIds;
|
|
56
57
|
constructor(config?: IkonUiCoreConfig);
|
|
57
58
|
dispose(): void;
|
|
58
59
|
private clearAllState;
|
|
@@ -74,6 +75,7 @@ export declare class IkonUiCore {
|
|
|
74
75
|
private applyUiStoreOp;
|
|
75
76
|
private handleProtocolMessage;
|
|
76
77
|
private handleGlobalState;
|
|
78
|
+
private evictSeedStreams;
|
|
77
79
|
private handleUiUpdate;
|
|
78
80
|
private handleUiStyles;
|
|
79
81
|
private handleUiStylesBatch;
|
package/index.js
CHANGED
|
@@ -1112,7 +1112,7 @@ function Pt(e) {
|
|
|
1112
1112
|
t.push(r.asString());
|
|
1113
1113
|
return t;
|
|
1114
1114
|
}
|
|
1115
|
-
const pt = 76337612, kt = 185396121,
|
|
1115
|
+
const pt = 76337612, kt = 185396121, vt = 250031587, Mt = 388632637, Bt = 417197284, Vt = 425972532, Gt = 469070965, xt = 470595159, Ht = 594855258, Yt = 617065367, Wt = 661691032, Kt = 781727218, $t = 834078886, Xt = 1043273762, jt = 1236999138, zt = 1286979607, Jt = 1368629611, qt = 1437068682, Qt = 1668375353, Zt = 1715899485, er = 1942830531, tr = 1999510636, rr = 2033288346, sr = 2079864626, nr = 2142346422, ir = 2228539873, or = 2232517119, ar = 2598291686, lr = 2719718823, Ir = 2810953526, Er = 2840065720, _r = 2885165957, hr = 3542818975, ur = 3586157513, cr = 3717933110, fr = 4062655306;
|
|
1116
1116
|
function Tr(e) {
|
|
1117
1117
|
const t = {};
|
|
1118
1118
|
return me(t), t;
|
|
@@ -1138,12 +1138,12 @@ function Ar(e, t) {
|
|
|
1138
1138
|
t.InstallId = r.asString();
|
|
1139
1139
|
break;
|
|
1140
1140
|
}
|
|
1141
|
-
case
|
|
1141
|
+
case vt: {
|
|
1142
1142
|
if (r.isNull) throw new Error();
|
|
1143
1143
|
t.Theme = r.asString();
|
|
1144
1144
|
break;
|
|
1145
1145
|
}
|
|
1146
|
-
case
|
|
1146
|
+
case Mt: {
|
|
1147
1147
|
if (r.isNull) throw new Error();
|
|
1148
1148
|
t.UserAgent = r.asString();
|
|
1149
1149
|
break;
|
|
@@ -1387,7 +1387,7 @@ function pr(e, t) {
|
|
|
1387
1387
|
}
|
|
1388
1388
|
case gr: {
|
|
1389
1389
|
if (r.isNull) throw new Error();
|
|
1390
|
-
t.Parameters =
|
|
1390
|
+
t.Parameters = vr(r.asArray());
|
|
1391
1391
|
break;
|
|
1392
1392
|
}
|
|
1393
1393
|
case br: {
|
|
@@ -1404,14 +1404,14 @@ function kr(e) {
|
|
|
1404
1404
|
t.push(r.asString());
|
|
1405
1405
|
return t;
|
|
1406
1406
|
}
|
|
1407
|
-
function
|
|
1407
|
+
function vr(e) {
|
|
1408
1408
|
const t = [];
|
|
1409
1409
|
let r;
|
|
1410
1410
|
for (; (r = e.next()) !== null; )
|
|
1411
1411
|
t.push(Xr(r.asObject()));
|
|
1412
1412
|
return t;
|
|
1413
1413
|
}
|
|
1414
|
-
const
|
|
1414
|
+
const Mr = 607861992, Br = 894485888, Vr = 972460562, Gr = 1368629611, xr = 1883521406, Hr = 2603556958, Yr = 3609695522, Wr = 4075263697, Kr = 4257460908;
|
|
1415
1415
|
function $r(e) {
|
|
1416
1416
|
const t = {};
|
|
1417
1417
|
return ge(t), t;
|
|
@@ -1427,7 +1427,7 @@ function jr(e, t) {
|
|
|
1427
1427
|
let r;
|
|
1428
1428
|
for (; (r = e.next()) !== null; )
|
|
1429
1429
|
switch (r.fieldId) {
|
|
1430
|
-
case
|
|
1430
|
+
case Mr: {
|
|
1431
1431
|
if (r.isNull) throw new Error();
|
|
1432
1432
|
t.HasDefaultValue = r.asBool();
|
|
1433
1433
|
break;
|
|
@@ -1568,9 +1568,9 @@ function ls(e, t) {
|
|
|
1568
1568
|
const Is = 2097188, Es = 979822885, _s = 2374537704;
|
|
1569
1569
|
function hs(e) {
|
|
1570
1570
|
const t = {};
|
|
1571
|
-
return
|
|
1571
|
+
return ve(t), t;
|
|
1572
1572
|
}
|
|
1573
|
-
function
|
|
1573
|
+
function ve(e) {
|
|
1574
1574
|
return e.StyleId = "", e.Style = /* @__PURE__ */ Object.create(null), e;
|
|
1575
1575
|
}
|
|
1576
1576
|
function us(e, t) {
|
|
@@ -1579,7 +1579,7 @@ function us(e, t) {
|
|
|
1579
1579
|
}
|
|
1580
1580
|
function cs(e, t) {
|
|
1581
1581
|
const r = t ?? hs();
|
|
1582
|
-
return
|
|
1582
|
+
return ve(r), fs(e, r), r;
|
|
1583
1583
|
}
|
|
1584
1584
|
function fs(e, t) {
|
|
1585
1585
|
let r;
|
|
@@ -1613,9 +1613,9 @@ function Ss(e) {
|
|
|
1613
1613
|
const As = 2097192, ds = 2136687806;
|
|
1614
1614
|
function Ns(e) {
|
|
1615
1615
|
const t = {};
|
|
1616
|
-
return
|
|
1616
|
+
return Me(t), t;
|
|
1617
1617
|
}
|
|
1618
|
-
function
|
|
1618
|
+
function Me(e) {
|
|
1619
1619
|
return e.Styles = [], e;
|
|
1620
1620
|
}
|
|
1621
1621
|
function ys(e, t) {
|
|
@@ -1624,7 +1624,7 @@ function ys(e, t) {
|
|
|
1624
1624
|
}
|
|
1625
1625
|
function ws(e, t) {
|
|
1626
1626
|
const r = t ?? Ns();
|
|
1627
|
-
return
|
|
1627
|
+
return Me(r), Cs(e, r), r;
|
|
1628
1628
|
}
|
|
1629
1629
|
function Cs(e, t) {
|
|
1630
1630
|
let r;
|
|
@@ -1695,13 +1695,13 @@ function Ve(e) {
|
|
|
1695
1695
|
}
|
|
1696
1696
|
function ks(e, t) {
|
|
1697
1697
|
const r = O.create(e);
|
|
1698
|
-
return
|
|
1698
|
+
return vs(r, t);
|
|
1699
1699
|
}
|
|
1700
|
-
function
|
|
1700
|
+
function vs(e, t) {
|
|
1701
1701
|
const r = t ?? ps();
|
|
1702
|
-
return Ve(r),
|
|
1702
|
+
return Ve(r), Ms(e, r), r;
|
|
1703
1703
|
}
|
|
1704
|
-
function
|
|
1704
|
+
function Ms(e, t) {
|
|
1705
1705
|
let r;
|
|
1706
1706
|
for (; (r = e.next()) !== null; )
|
|
1707
1707
|
switch (r.fieldId) {
|
|
@@ -1856,13 +1856,13 @@ function We(e) {
|
|
|
1856
1856
|
}
|
|
1857
1857
|
function kn(e, t) {
|
|
1858
1858
|
const r = O.create(e);
|
|
1859
|
-
return
|
|
1859
|
+
return vn(r, t);
|
|
1860
1860
|
}
|
|
1861
|
-
function
|
|
1861
|
+
function vn(e, t) {
|
|
1862
1862
|
const r = t ?? pn();
|
|
1863
|
-
return We(r),
|
|
1863
|
+
return We(r), Mn(e, r), r;
|
|
1864
1864
|
}
|
|
1865
|
-
function
|
|
1865
|
+
function Mn(e, t) {
|
|
1866
1866
|
let r;
|
|
1867
1867
|
for (; (r = e.next()) !== null; )
|
|
1868
1868
|
switch (r.fieldId) {
|
|
@@ -2796,7 +2796,7 @@ function qe(e, t, r) {
|
|
|
2796
2796
|
const s = t.get(e.id);
|
|
2797
2797
|
let n = e, i = !1;
|
|
2798
2798
|
if (s?.textUpdates && s.textUpdates.length > 0) {
|
|
2799
|
-
const u =
|
|
2799
|
+
const u = Mi(e, s.textUpdates);
|
|
2800
2800
|
n = u.node, i = u.changed;
|
|
2801
2801
|
}
|
|
2802
2802
|
let o = !1, a = n.props;
|
|
@@ -2804,12 +2804,12 @@ function qe(e, t, r) {
|
|
|
2804
2804
|
for (const [u, A] of s.changedProps.entries()) {
|
|
2805
2805
|
const c = a[u];
|
|
2806
2806
|
if (A === void 0)
|
|
2807
|
-
(c !== void 0 || u in a) && (o || (a =
|
|
2807
|
+
(c !== void 0 || u in a) && (o || (a = M(a), o = !0), delete a[u]);
|
|
2808
2808
|
else if (Q(A)) {
|
|
2809
|
-
const S =
|
|
2810
|
-
p(S, c) || (o || (a =
|
|
2809
|
+
const S = M(A);
|
|
2810
|
+
p(S, c) || (o || (a = M(a), o = !0), a[u] = S);
|
|
2811
2811
|
} else
|
|
2812
|
-
p(A, c) || (o || (a =
|
|
2812
|
+
p(A, c) || (o || (a = M(a), o = !0), a[u] = A);
|
|
2813
2813
|
}
|
|
2814
2814
|
let I = !1, _ = n.styleIds;
|
|
2815
2815
|
s?.styleIds !== void 0 && (et(n.styleIds, s.styleIds) || (_ = s.styleIds, I = !0));
|
|
@@ -2915,7 +2915,7 @@ function Ze(e, t) {
|
|
|
2915
2915
|
function et(e, t) {
|
|
2916
2916
|
return p(e, t);
|
|
2917
2917
|
}
|
|
2918
|
-
function
|
|
2918
|
+
function vi(e, t) {
|
|
2919
2919
|
if (t.length === 0)
|
|
2920
2920
|
return e;
|
|
2921
2921
|
const r = [...t].sort((i, o) => i.start - o.start);
|
|
@@ -2932,7 +2932,7 @@ function Mi(e, t) {
|
|
|
2932
2932
|
}
|
|
2933
2933
|
return s;
|
|
2934
2934
|
}
|
|
2935
|
-
function
|
|
2935
|
+
function Mi(e, t, r) {
|
|
2936
2936
|
if (t.length === 0)
|
|
2937
2937
|
return { node: e, changed: !1 };
|
|
2938
2938
|
const s = /* @__PURE__ */ new Map();
|
|
@@ -2952,8 +2952,8 @@ function tt(e, t, r) {
|
|
|
2952
2952
|
E ? E.push(l) : _.set(l.propertyName, [l]);
|
|
2953
2953
|
}
|
|
2954
2954
|
for (const [l, E] of _.entries()) {
|
|
2955
|
-
const h = i[l], N =
|
|
2956
|
-
n || (i =
|
|
2955
|
+
const h = i[l], N = vi(typeof h == "string" ? h : "", E);
|
|
2956
|
+
n || (i = M(i), n = !0), i[l] = N;
|
|
2957
2957
|
}
|
|
2958
2958
|
}
|
|
2959
2959
|
let o = !1;
|
|
@@ -2989,7 +2989,7 @@ function Bi(e, t) {
|
|
|
2989
2989
|
s++;
|
|
2990
2990
|
return s;
|
|
2991
2991
|
}
|
|
2992
|
-
function
|
|
2992
|
+
function M(e) {
|
|
2993
2993
|
const t = {}, r = Object.keys(e);
|
|
2994
2994
|
for (let s = 0; s < r.length; s++) {
|
|
2995
2995
|
const n = r[s];
|
|
@@ -3023,7 +3023,7 @@ function p(e, t) {
|
|
|
3023
3023
|
return !1;
|
|
3024
3024
|
}
|
|
3025
3025
|
const z = Z("LiveSnapshot"), _e = 1, J = "ikon:live-snapshot", Vi = 300 * 1e3, Gi = 5e6, xi = 1e3;
|
|
3026
|
-
function
|
|
3026
|
+
function v() {
|
|
3027
3027
|
try {
|
|
3028
3028
|
return typeof localStorage > "u" ? null : localStorage;
|
|
3029
3029
|
} catch {
|
|
@@ -3046,7 +3046,7 @@ class Yi {
|
|
|
3046
3046
|
pending = null;
|
|
3047
3047
|
/** Remove every stored live snapshot (all apps and users) from localStorage. Call on logout. */
|
|
3048
3048
|
static clearAll() {
|
|
3049
|
-
const t =
|
|
3049
|
+
const t = v();
|
|
3050
3050
|
if (!t) return;
|
|
3051
3051
|
const r = `${J}:`, s = [];
|
|
3052
3052
|
try {
|
|
@@ -3064,7 +3064,7 @@ class Yi {
|
|
|
3064
3064
|
}
|
|
3065
3065
|
load() {
|
|
3066
3066
|
if (this.disabled) return null;
|
|
3067
|
-
const t =
|
|
3067
|
+
const t = v();
|
|
3068
3068
|
if (!t) return null;
|
|
3069
3069
|
let r;
|
|
3070
3070
|
try {
|
|
@@ -3110,7 +3110,7 @@ class Yi {
|
|
|
3110
3110
|
this.pending = null, t && this.writeNow(t.streams, t.styles);
|
|
3111
3111
|
}
|
|
3112
3112
|
writeNow(t, r) {
|
|
3113
|
-
const s =
|
|
3113
|
+
const s = v();
|
|
3114
3114
|
if (!s) return;
|
|
3115
3115
|
const n = [];
|
|
3116
3116
|
for (const a of t)
|
|
@@ -3141,7 +3141,7 @@ class Yi {
|
|
|
3141
3141
|
}
|
|
3142
3142
|
}
|
|
3143
3143
|
remove() {
|
|
3144
|
-
const t =
|
|
3144
|
+
const t = v();
|
|
3145
3145
|
if (t)
|
|
3146
3146
|
try {
|
|
3147
3147
|
t.removeItem(this.key);
|
|
@@ -3149,7 +3149,7 @@ class Yi {
|
|
|
3149
3149
|
}
|
|
3150
3150
|
}
|
|
3151
3151
|
pruneOtherUsers() {
|
|
3152
|
-
const t =
|
|
3152
|
+
const t = v();
|
|
3153
3153
|
if (!t) return;
|
|
3154
3154
|
const r = `${J}:${this.appId}:`, s = [];
|
|
3155
3155
|
try {
|
|
@@ -3185,7 +3185,7 @@ function Ki(e) {
|
|
|
3185
3185
|
}
|
|
3186
3186
|
function $i(e) {
|
|
3187
3187
|
return new Worker(
|
|
3188
|
-
"" + new URL("assets/ui-worker-
|
|
3188
|
+
"" + new URL("assets/ui-worker-BQcelAkD.js", import.meta.url).href,
|
|
3189
3189
|
{
|
|
3190
3190
|
type: "module",
|
|
3191
3191
|
name: e?.name
|
|
@@ -3218,6 +3218,9 @@ class Ji {
|
|
|
3218
3218
|
useUiWorker;
|
|
3219
3219
|
liveSnapshot = null;
|
|
3220
3220
|
unsubscribeLiveSnapshotCapture;
|
|
3221
|
+
// Main-thread (worker-disabled) twin of the worker's seedStreamIds: orphan boot seeds shielded from
|
|
3222
|
+
// GlobalState pruning until the first live update evicts them atomically. Unused in worker mode.
|
|
3223
|
+
seedStreamIds = /* @__PURE__ */ new Set();
|
|
3221
3224
|
constructor(t) {
|
|
3222
3225
|
const r = t?.threading?.uiWorker ?? "auto";
|
|
3223
3226
|
this.useUiWorker = r !== "disabled" && typeof Worker < "u", t?.liveSnapshot?.enabled && (this.liveSnapshot = new Yi(t.liveSnapshot)), t?.client && this.initialize(t.client, t);
|
|
@@ -3312,13 +3315,13 @@ class Ji {
|
|
|
3312
3315
|
this.uiWorker.postMessage({ type: "seed", bootStreamId: s.streamId ?? "boot", bootJson: s.json, styles: s.styles ?? [] });
|
|
3313
3316
|
return;
|
|
3314
3317
|
}
|
|
3315
|
-
if (this.uiStore.getSnapshots().some((
|
|
3316
|
-
for (const
|
|
3317
|
-
const
|
|
3318
|
-
this.uiStyles.set(
|
|
3318
|
+
if (this.uiStore.getSnapshots().some((o) => o.rootViewId)) return;
|
|
3319
|
+
for (const o of s.styles ?? []) {
|
|
3320
|
+
const a = { styleId: o.styleId, css: o.css, common: o.common };
|
|
3321
|
+
this.uiStyles.set(a.styleId, a), this.notifyUiStyle(a);
|
|
3319
3322
|
}
|
|
3320
|
-
const n = Ie({ Json: s.json });
|
|
3321
|
-
this.uiStore.apply(
|
|
3323
|
+
const n = Ie({ Json: s.json }), i = s.streamId ?? "boot";
|
|
3324
|
+
this.uiStore.apply(i, n), this.seedStreamIds.add(i), this.uiStore.enterSnapshotModeAll();
|
|
3322
3325
|
} catch {
|
|
3323
3326
|
}
|
|
3324
3327
|
}
|
|
@@ -3400,7 +3403,7 @@ class Ji {
|
|
|
3400
3403
|
return;
|
|
3401
3404
|
}
|
|
3402
3405
|
if (t.type === "ReplaceStreamSnapshot" || t.type === "PatchStreamSnapshot") {
|
|
3403
|
-
if (!this.uiStore.applyStoreOp(t))
|
|
3406
|
+
if (!this.uiStore.applyStoreOp(t) || t.type === "ReplaceStreamSnapshot" && t.fromSeed)
|
|
3404
3407
|
return;
|
|
3405
3408
|
const s = t.type === "ReplaceStreamSnapshot" ? t.snapshot.streamId : t.streamId, n = this.uiStore.getSnapshot(s);
|
|
3406
3409
|
if (!n?.rootViewId)
|
|
@@ -3451,16 +3454,25 @@ class Ji {
|
|
|
3451
3454
|
for (const n of Object.values(r.UIStreams ?? {}))
|
|
3452
3455
|
s.add(n.StreamId), this.uiStore.setCategory(n.StreamId, n.Info?.Category);
|
|
3453
3456
|
for (const n of this.uiStore.getSnapshots())
|
|
3454
|
-
s.has(n.streamId) || (this.uiStore.remove(n.streamId), this.notifyUiStreamCleared(n.streamId));
|
|
3457
|
+
this.seedStreamIds.has(n.streamId) || s.has(n.streamId) || (this.uiStore.remove(n.streamId), this.notifyUiStreamCleared(n.streamId));
|
|
3455
3458
|
}).catch((r) => {
|
|
3456
3459
|
C.error("Failed to handle global state", r);
|
|
3457
3460
|
});
|
|
3458
3461
|
}
|
|
3462
|
+
// Retire orphan boot seeds once a live update has rendered (main-thread twin of the worker's
|
|
3463
|
+
// evictSeedStreamsExcept). A seed sharing the live id is replaced in place, not removed.
|
|
3464
|
+
evictSeedStreams(t) {
|
|
3465
|
+
if (this.seedStreamIds.size !== 0) {
|
|
3466
|
+
for (const r of this.seedStreamIds)
|
|
3467
|
+
r !== t && (this.uiStore.remove(r), this.notifyUiStreamCleared(r));
|
|
3468
|
+
this.seedStreamIds.clear();
|
|
3469
|
+
}
|
|
3470
|
+
}
|
|
3459
3471
|
handleUiUpdate(t) {
|
|
3460
3472
|
const r = ae(t), s = `${r.senderId}_${r.trackId}`;
|
|
3461
3473
|
Xs(t).then((n) => {
|
|
3462
3474
|
const i = Ie(n);
|
|
3463
|
-
this.notifyUiUpdate(s, i), this.uiStore.apply(s, i), this.sendUiUpdateAck(r.trackId, i.snapshot.version, r.senderId);
|
|
3475
|
+
this.notifyUiUpdate(s, i), this.uiStore.apply(s, i) && this.evictSeedStreams(s), this.sendUiUpdateAck(r.trackId, i.snapshot.version, r.senderId);
|
|
3464
3476
|
}).catch((n) => {
|
|
3465
3477
|
n instanceof R ? C.warn("Failed to parse UI update", n.causeError ?? n) : C.error("Failed to apply UI update", n);
|
|
3466
3478
|
});
|
package/package.json
CHANGED