@nil-/xit 0.3.0 → 0.4.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/assets/bundler.js +53 -53
- package/assets/index.js +60 -51
- package/index.d.ts +2 -2
- package/package.json +1 -1
- package/test/Frame.svelte +18 -18
- package/test/Frame.svelte.d.ts +7 -3
- package/test/Main.svelte +63 -0
- package/test/Main.svelte.d.ts +3 -0
package/assets/index.js
CHANGED
|
@@ -312,7 +312,7 @@ class P {
|
|
|
312
312
|
return i;
|
|
313
313
|
}
|
|
314
314
|
}
|
|
315
|
-
class
|
|
315
|
+
class y {
|
|
316
316
|
/**
|
|
317
317
|
* Create a FlatBufferBuilder.
|
|
318
318
|
*/
|
|
@@ -363,7 +363,7 @@ class k {
|
|
|
363
363
|
const i = ~(this.bb.capacity() - this.space + e) + 1 & t - 1;
|
|
364
364
|
for (; this.space < i + t + e; ) {
|
|
365
365
|
const a = this.bb.capacity();
|
|
366
|
-
this.bb =
|
|
366
|
+
this.bb = y.growByteBuffer(this.bb), this.space += this.bb.capacity() - a;
|
|
367
367
|
}
|
|
368
368
|
this.pad(i);
|
|
369
369
|
}
|
|
@@ -748,7 +748,7 @@ class Ct {
|
|
|
748
748
|
return N.createFileInfo(t, e, i);
|
|
749
749
|
}
|
|
750
750
|
}
|
|
751
|
-
class
|
|
751
|
+
class R {
|
|
752
752
|
constructor() {
|
|
753
753
|
n(this, "bb", null);
|
|
754
754
|
n(this, "bb_pos", 0);
|
|
@@ -757,39 +757,46 @@ class A {
|
|
|
757
757
|
return this.bb_pos = t, this.bb = e, this;
|
|
758
758
|
}
|
|
759
759
|
static getRootAsFrameCache(t, e) {
|
|
760
|
-
return (e || new
|
|
760
|
+
return (e || new R()).__init(t.readInt32(t.position()) + t.position(), t);
|
|
761
761
|
}
|
|
762
762
|
static getSizePrefixedRootAsFrameCache(t, e) {
|
|
763
|
-
return t.setPosition(t.position() + f), (e || new
|
|
763
|
+
return t.setPosition(t.position() + f), (e || new R()).__init(t.readInt32(t.position()) + t.position(), t);
|
|
764
764
|
}
|
|
765
765
|
id(t) {
|
|
766
766
|
const e = this.bb.__offset(this.bb_pos, 4);
|
|
767
767
|
return e ? this.bb.__string(this.bb_pos + e, t) : null;
|
|
768
768
|
}
|
|
769
|
-
|
|
769
|
+
target(t) {
|
|
770
770
|
const e = this.bb.__offset(this.bb_pos, 6);
|
|
771
771
|
return e ? this.bb.__string(this.bb_pos + e, t) : null;
|
|
772
772
|
}
|
|
773
|
+
content(t) {
|
|
774
|
+
const e = this.bb.__offset(this.bb_pos, 8);
|
|
775
|
+
return e ? this.bb.__string(this.bb_pos + e, t) : null;
|
|
776
|
+
}
|
|
773
777
|
files(t, e) {
|
|
774
|
-
const i = this.bb.__offset(this.bb_pos,
|
|
778
|
+
const i = this.bb.__offset(this.bb_pos, 10);
|
|
775
779
|
return i ? (e || new N()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + i) + t * 4), this.bb) : null;
|
|
776
780
|
}
|
|
777
781
|
filesLength() {
|
|
778
|
-
const t = this.bb.__offset(this.bb_pos,
|
|
782
|
+
const t = this.bb.__offset(this.bb_pos, 10);
|
|
779
783
|
return t ? this.bb.__vector_len(this.bb_pos + t) : 0;
|
|
780
784
|
}
|
|
781
785
|
static startFrameCache(t) {
|
|
782
|
-
t.startObject(
|
|
786
|
+
t.startObject(4);
|
|
783
787
|
}
|
|
784
788
|
static addId(t, e) {
|
|
785
789
|
t.addFieldOffset(0, e, 0);
|
|
786
790
|
}
|
|
787
|
-
static
|
|
791
|
+
static addTarget(t, e) {
|
|
788
792
|
t.addFieldOffset(1, e, 0);
|
|
789
793
|
}
|
|
790
|
-
static
|
|
794
|
+
static addContent(t, e) {
|
|
791
795
|
t.addFieldOffset(2, e, 0);
|
|
792
796
|
}
|
|
797
|
+
static addFiles(t, e) {
|
|
798
|
+
t.addFieldOffset(3, e, 0);
|
|
799
|
+
}
|
|
793
800
|
static createFilesVector(t, e) {
|
|
794
801
|
t.startVector(4, e.length, 4);
|
|
795
802
|
for (let i = e.length - 1; i >= 0; i--)
|
|
@@ -801,28 +808,29 @@ class A {
|
|
|
801
808
|
}
|
|
802
809
|
static endFrameCache(t) {
|
|
803
810
|
const e = t.endObject();
|
|
804
|
-
return t.requiredField(e, 4), t.requiredField(e, 6), t.requiredField(e, 8), e;
|
|
811
|
+
return t.requiredField(e, 4), t.requiredField(e, 6), t.requiredField(e, 8), t.requiredField(e, 10), e;
|
|
805
812
|
}
|
|
806
|
-
static createFrameCache(t, e, i, a) {
|
|
807
|
-
return
|
|
813
|
+
static createFrameCache(t, e, i, a, r) {
|
|
814
|
+
return R.startFrameCache(t), R.addId(t, e), R.addTarget(t, i), R.addContent(t, a), R.addFiles(t, r), R.endFrameCache(t);
|
|
808
815
|
}
|
|
809
816
|
unpack() {
|
|
810
|
-
return new Bt(this.id(), this.content(), this.bb.createObjList(this.files.bind(this), this.filesLength()));
|
|
817
|
+
return new Bt(this.id(), this.target(), this.content(), this.bb.createObjList(this.files.bind(this), this.filesLength()));
|
|
811
818
|
}
|
|
812
819
|
unpackTo(t) {
|
|
813
|
-
t.id = this.id(), t.content = this.content(), t.files = this.bb.createObjList(this.files.bind(this), this.filesLength());
|
|
820
|
+
t.id = this.id(), t.target = this.target(), t.content = this.content(), t.files = this.bb.createObjList(this.files.bind(this), this.filesLength());
|
|
814
821
|
}
|
|
815
822
|
}
|
|
816
823
|
class Bt {
|
|
817
|
-
constructor(t = null, e = null, i = []) {
|
|
824
|
+
constructor(t = null, e = null, i = null, a = []) {
|
|
818
825
|
n(this, "id");
|
|
826
|
+
n(this, "target");
|
|
819
827
|
n(this, "content");
|
|
820
828
|
n(this, "files");
|
|
821
|
-
this.id = t, this.
|
|
829
|
+
this.id = t, this.target = e, this.content = i, this.files = a;
|
|
822
830
|
}
|
|
823
831
|
pack(t) {
|
|
824
|
-
const e = this.id !== null ? t.createString(this.id) : 0, i = this.content !== null ? t.createString(this.content) : 0,
|
|
825
|
-
return
|
|
832
|
+
const e = this.id !== null ? t.createString(this.id) : 0, i = this.target !== null ? t.createString(this.target) : 0, a = this.content !== null ? t.createString(this.content) : 0, r = R.createFilesVector(t, t.createObjectOffsetList(this.files));
|
|
833
|
+
return R.createFrameCache(t, e, i, a, r);
|
|
826
834
|
}
|
|
827
835
|
}
|
|
828
836
|
var _;
|
|
@@ -1414,7 +1422,7 @@ class Gt {
|
|
|
1414
1422
|
return X.createTaggedSignalRequest(t, e, i);
|
|
1415
1423
|
}
|
|
1416
1424
|
}
|
|
1417
|
-
class
|
|
1425
|
+
class T {
|
|
1418
1426
|
constructor() {
|
|
1419
1427
|
n(this, "bb", null);
|
|
1420
1428
|
n(this, "bb_pos", 0);
|
|
@@ -1423,10 +1431,10 @@ class R {
|
|
|
1423
1431
|
return this.bb_pos = t, this.bb = e, this;
|
|
1424
1432
|
}
|
|
1425
1433
|
static getRootAsTaggedSignalResponse(t, e) {
|
|
1426
|
-
return (e || new
|
|
1434
|
+
return (e || new T()).__init(t.readInt32(t.position()) + t.position(), t);
|
|
1427
1435
|
}
|
|
1428
1436
|
static getSizePrefixedRootAsTaggedSignalResponse(t, e) {
|
|
1429
|
-
return t.setPosition(t.position() + f), (e || new
|
|
1437
|
+
return t.setPosition(t.position() + f), (e || new T()).__init(t.readInt32(t.position()) + t.position(), t);
|
|
1430
1438
|
}
|
|
1431
1439
|
id(t) {
|
|
1432
1440
|
const e = this.bb.__offset(this.bb_pos, 4);
|
|
@@ -1470,7 +1478,7 @@ class R {
|
|
|
1470
1478
|
return t.requiredField(e, 4), t.requiredField(e, 6), t.requiredField(e, 8), e;
|
|
1471
1479
|
}
|
|
1472
1480
|
static createTaggedSignalResponse(t, e, i, a) {
|
|
1473
|
-
return
|
|
1481
|
+
return T.startTaggedSignalResponse(t), T.addId(t, e), T.addTag(t, i), T.addSignals(t, a), T.endTaggedSignalResponse(t);
|
|
1474
1482
|
}
|
|
1475
1483
|
unpack() {
|
|
1476
1484
|
return new ce(this.id(), this.tag(), this.bb.createObjList(this.signals.bind(this), this.signalsLength()));
|
|
@@ -1487,8 +1495,8 @@ class ce {
|
|
|
1487
1495
|
this.id = t, this.tag = e, this.signals = i;
|
|
1488
1496
|
}
|
|
1489
1497
|
pack(t) {
|
|
1490
|
-
const e = this.id !== null ? t.createString(this.id) : 0, i = this.tag !== null ? t.createString(this.tag) : 0, a =
|
|
1491
|
-
return
|
|
1498
|
+
const e = this.id !== null ? t.createString(this.id) : 0, i = this.tag !== null ? t.createString(this.tag) : 0, a = T.createSignalsVector(t, t.createObjectOffsetList(this.signals));
|
|
1499
|
+
return T.createTaggedSignalResponse(t, e, i, a);
|
|
1492
1500
|
}
|
|
1493
1501
|
}
|
|
1494
1502
|
class $ {
|
|
@@ -1617,7 +1625,7 @@ class Ht {
|
|
|
1617
1625
|
return S.createValue(t, e, this.valueType, i);
|
|
1618
1626
|
}
|
|
1619
1627
|
}
|
|
1620
|
-
class
|
|
1628
|
+
class k {
|
|
1621
1629
|
constructor() {
|
|
1622
1630
|
n(this, "bb", null);
|
|
1623
1631
|
n(this, "bb_pos", 0);
|
|
@@ -1626,10 +1634,10 @@ class T {
|
|
|
1626
1634
|
return this.bb_pos = t, this.bb = e, this;
|
|
1627
1635
|
}
|
|
1628
1636
|
static getRootAsTaggedValueResponse(t, e) {
|
|
1629
|
-
return (e || new
|
|
1637
|
+
return (e || new k()).__init(t.readInt32(t.position()) + t.position(), t);
|
|
1630
1638
|
}
|
|
1631
1639
|
static getSizePrefixedRootAsTaggedValueResponse(t, e) {
|
|
1632
|
-
return t.setPosition(t.position() + f), (e || new
|
|
1640
|
+
return t.setPosition(t.position() + f), (e || new k()).__init(t.readInt32(t.position()) + t.position(), t);
|
|
1633
1641
|
}
|
|
1634
1642
|
id(t) {
|
|
1635
1643
|
const e = this.bb.__offset(this.bb_pos, 4);
|
|
@@ -1673,7 +1681,7 @@ class T {
|
|
|
1673
1681
|
return t.requiredField(e, 4), t.requiredField(e, 6), t.requiredField(e, 8), e;
|
|
1674
1682
|
}
|
|
1675
1683
|
static createTaggedValueResponse(t, e, i, a) {
|
|
1676
|
-
return
|
|
1684
|
+
return k.startTaggedValueResponse(t), k.addId(t, e), k.addTag(t, i), k.addValues(t, a), k.endTaggedValueResponse(t);
|
|
1677
1685
|
}
|
|
1678
1686
|
unpack() {
|
|
1679
1687
|
return new ue(this.id(), this.tag(), this.bb.createObjList(this.values.bind(this), this.valuesLength()));
|
|
@@ -1690,8 +1698,8 @@ class ue {
|
|
|
1690
1698
|
this.id = t, this.tag = e, this.values = i;
|
|
1691
1699
|
}
|
|
1692
1700
|
pack(t) {
|
|
1693
|
-
const e = this.id !== null ? t.createString(this.id) : 0, i = this.tag !== null ? t.createString(this.tag) : 0, a =
|
|
1694
|
-
return
|
|
1701
|
+
const e = this.id !== null ? t.createString(this.id) : 0, i = this.tag !== null ? t.createString(this.tag) : 0, a = k.createValuesVector(t, t.createObjectOffsetList(this.values));
|
|
1702
|
+
return k.createTaggedValueResponse(t, e, i, a);
|
|
1695
1703
|
}
|
|
1696
1704
|
}
|
|
1697
1705
|
class D {
|
|
@@ -1851,7 +1859,7 @@ class Rt {
|
|
|
1851
1859
|
return it.createUniqueFrameSubscribe(t, e);
|
|
1852
1860
|
}
|
|
1853
1861
|
}
|
|
1854
|
-
class
|
|
1862
|
+
class A {
|
|
1855
1863
|
constructor() {
|
|
1856
1864
|
n(this, "bb", null);
|
|
1857
1865
|
n(this, "bb_pos", 0);
|
|
@@ -1860,10 +1868,10 @@ class y {
|
|
|
1860
1868
|
return this.bb_pos = t, this.bb = e, this;
|
|
1861
1869
|
}
|
|
1862
1870
|
static getRootAsUniqueSignalNotify(t, e) {
|
|
1863
|
-
return (e || new
|
|
1871
|
+
return (e || new A()).__init(t.readInt32(t.position()) + t.position(), t);
|
|
1864
1872
|
}
|
|
1865
1873
|
static getSizePrefixedRootAsUniqueSignalNotify(t, e) {
|
|
1866
|
-
return t.setPosition(t.position() + f), (e || new
|
|
1874
|
+
return t.setPosition(t.position() + f), (e || new A()).__init(t.readInt32(t.position()) + t.position(), t);
|
|
1867
1875
|
}
|
|
1868
1876
|
frameId(t) {
|
|
1869
1877
|
const e = this.bb.__offset(this.bb_pos, 4);
|
|
@@ -1901,7 +1909,7 @@ class y {
|
|
|
1901
1909
|
return t.requiredField(e, 4), t.requiredField(e, 6), e;
|
|
1902
1910
|
}
|
|
1903
1911
|
static createUniqueSignalNotify(t, e, i, a, r) {
|
|
1904
|
-
return
|
|
1912
|
+
return A.startUniqueSignalNotify(t), A.addFrameId(t, e), A.addSignalId(t, i), A.addValueType(t, a), A.addValue(t, r), A.endUniqueSignalNotify(t);
|
|
1905
1913
|
}
|
|
1906
1914
|
unpack() {
|
|
1907
1915
|
return new Zt(this.frameId(), this.signalId(), this.valueType(), (() => {
|
|
@@ -1926,7 +1934,7 @@ class Zt {
|
|
|
1926
1934
|
}
|
|
1927
1935
|
pack(t) {
|
|
1928
1936
|
const e = this.frameId !== null ? t.createString(this.frameId) : 0, i = this.signalId !== null ? t.createString(this.signalId) : 0, a = t.createObjectOffset(this.value);
|
|
1929
|
-
return
|
|
1937
|
+
return A.createUniqueSignalNotify(t, e, i, this.valueType, a);
|
|
1930
1938
|
}
|
|
1931
1939
|
}
|
|
1932
1940
|
class nt {
|
|
@@ -2227,8 +2235,9 @@ const _e = async (s) => new Promise((t, e) => {
|
|
|
2227
2235
|
}), i.addEventListener("message", async (a) => {
|
|
2228
2236
|
if (a.data.ok) {
|
|
2229
2237
|
if (a.data.files) {
|
|
2230
|
-
const r = new
|
|
2238
|
+
const r = new y(), o = new Bt(
|
|
2231
2239
|
s.id,
|
|
2240
|
+
a.data.target,
|
|
2232
2241
|
a.data.code,
|
|
2233
2242
|
a.data.files.map((h) => new Ct(h.target, h.metadata))
|
|
2234
2243
|
);
|
|
@@ -2277,12 +2286,12 @@ const _e = async (s) => new Promise((t, e) => {
|
|
|
2277
2286
|
e,
|
|
2278
2287
|
t != null ? _.Client_Tagged_Value_Request : _.Client_Unique_Value_Request,
|
|
2279
2288
|
(() => {
|
|
2280
|
-
const c = new
|
|
2289
|
+
const c = new y(), d = t != null ? new Wt(s, t) : new $t(s);
|
|
2281
2290
|
return c.finish(d.pack(c)), c.asUint8Array();
|
|
2282
2291
|
})(),
|
|
2283
2292
|
t != null ? (c, d) => {
|
|
2284
2293
|
if (c === _.Server_Tagged_Value_Response) {
|
|
2285
|
-
const b =
|
|
2294
|
+
const b = k.getRootAsTaggedValueResponse(
|
|
2286
2295
|
new P(d)
|
|
2287
2296
|
);
|
|
2288
2297
|
if (b.id() === s && t === b.tag())
|
|
@@ -2311,7 +2320,7 @@ const _e = async (s) => new Promise((t, e) => {
|
|
|
2311
2320
|
O.subscribe((V) => {
|
|
2312
2321
|
if (V == null || o)
|
|
2313
2322
|
return;
|
|
2314
|
-
const m = new
|
|
2323
|
+
const m = new y(), p = t != null ? new Yt(s, t) : new Jt(s);
|
|
2315
2324
|
p.value = new Ht(
|
|
2316
2325
|
b,
|
|
2317
2326
|
F,
|
|
@@ -2363,13 +2372,13 @@ const _e = async (s) => new Promise((t, e) => {
|
|
|
2363
2372
|
e,
|
|
2364
2373
|
t != null ? _.Client_Tagged_Signal_Request : _.Client_Unique_Signal_Request,
|
|
2365
2374
|
(() => {
|
|
2366
|
-
const h = new
|
|
2375
|
+
const h = new y(), c = t != null ? new Gt(s, t) : new Xt(s);
|
|
2367
2376
|
return h.finish(c.pack(h)), h.asUint8Array();
|
|
2368
2377
|
})(),
|
|
2369
2378
|
(h, c) => {
|
|
2370
2379
|
if (t != null) {
|
|
2371
2380
|
if (h === _.Server_Tagged_Signal_Response)
|
|
2372
|
-
return
|
|
2381
|
+
return T.getRootAsTaggedSignalResponse(new P(c));
|
|
2373
2382
|
} else if (h === _.Server_Unique_Signal_Response)
|
|
2374
2383
|
return C.getRootAsUniqueSignalResponse(new P(c));
|
|
2375
2384
|
}
|
|
@@ -2384,7 +2393,7 @@ const _e = async (s) => new Promise((t, e) => {
|
|
|
2384
2393
|
for (let h = 0; h < o; ++h) {
|
|
2385
2394
|
const c = a.signals(h), { id: d, type: b } = { id: c.id(), type: c.type() };
|
|
2386
2395
|
r[b].set(d, (F) => {
|
|
2387
|
-
const O = new
|
|
2396
|
+
const O = new y(), V = b, m = Kt(V, F), p = t != null ? new Dt(s, t, d, V, m) : new Zt(s, d, V, m);
|
|
2388
2397
|
O.finish(p.pack(O));
|
|
2389
2398
|
const I = t != null ? _.Client_Tagged_Signal_Notify : _.Client_Unique_Signal_Notify;
|
|
2390
2399
|
i.publish(dt([ht(I), O.asUint8Array()]));
|
|
@@ -2450,12 +2459,12 @@ const _e = async (s) => new Promise((t, e) => {
|
|
|
2450
2459
|
p
|
|
2451
2460
|
), { action: O } = await d(F);
|
|
2452
2461
|
o.on_connect(() => {
|
|
2453
|
-
const p = new
|
|
2462
|
+
const p = new y(), I = e != null ? new qt(t, e) : new Rt(t);
|
|
2454
2463
|
p.finish(I.pack(p));
|
|
2455
2464
|
const G = e != null ? _.Client_Tagged_Frame_Subscribe : _.Client_Unique_Frame_Subscribe;
|
|
2456
2465
|
o.publish(dt([ht(G), p.asUint8Array()]));
|
|
2457
2466
|
}), o.start();
|
|
2458
|
-
const V = new
|
|
2467
|
+
const V = new y(), m = e != null ? new Ot(t, e) : new Ut(t);
|
|
2459
2468
|
return V.finish(m.pack(V)), St(
|
|
2460
2469
|
s,
|
|
2461
2470
|
e != null ? _.Client_Tagged_Frame_Loaded : _.Client_Unique_Frame_Loaded,
|
|
@@ -2465,12 +2474,12 @@ const _e = async (s) => new Promise((t, e) => {
|
|
|
2465
2474
|
I.set("nil.xit", {
|
|
2466
2475
|
values: te(h),
|
|
2467
2476
|
signals: ee(c),
|
|
2468
|
-
frame_ui: a,
|
|
2469
|
-
frame: r,
|
|
2470
2477
|
resub: () => o.start(),
|
|
2471
2478
|
unsub: () => o.stop(),
|
|
2472
2479
|
id: t,
|
|
2473
|
-
tag: e
|
|
2480
|
+
tag: e,
|
|
2481
|
+
load_frame_ui: a,
|
|
2482
|
+
load_frame_data: r
|
|
2474
2483
|
});
|
|
2475
2484
|
const { destroy: G } = O(p, I);
|
|
2476
2485
|
return {
|
|
@@ -2489,12 +2498,12 @@ const _e = async (s) => new Promise((t, e) => {
|
|
|
2489
2498
|
Mt({ id: t, tag: e ?? null, host: s, service: i })
|
|
2490
2499
|
]);
|
|
2491
2500
|
i.on_connect(() => {
|
|
2492
|
-
const d = new
|
|
2501
|
+
const d = new y(), b = e != null ? new qt(t, e) : new Rt(t);
|
|
2493
2502
|
d.finish(b.pack(d));
|
|
2494
2503
|
const F = e != null ? _.Client_Tagged_Frame_Subscribe : _.Client_Unique_Frame_Subscribe;
|
|
2495
2504
|
i.publish(dt([ht(F), d.asUint8Array()]));
|
|
2496
2505
|
}), i.start();
|
|
2497
|
-
const o = new
|
|
2506
|
+
const o = new y(), h = e != null ? new Ot(t, e) : new Ut(t);
|
|
2498
2507
|
o.finish(h.pack(o));
|
|
2499
2508
|
const c = e != null ? _.Client_Tagged_Frame_Loaded : _.Client_Unique_Frame_Loaded;
|
|
2500
2509
|
return St(s, c, o.asUint8Array()), {
|
package/index.d.ts
CHANGED
|
@@ -36,12 +36,12 @@ export type Frame = {
|
|
|
36
36
|
export type Context = {
|
|
37
37
|
values: Values;
|
|
38
38
|
signals: Signals;
|
|
39
|
-
frame_ui: (f: string, tag?: string) => Promise<Action<HTMLElement>>;
|
|
40
|
-
frame: (f: string, tag?: string) => Promise<Frame>;
|
|
41
39
|
resub: () => void;
|
|
42
40
|
unsub: () => void;
|
|
43
41
|
id: string;
|
|
44
42
|
tag: string | null;
|
|
43
|
+
load_frame_ui: (f: string, tag?: string) => Promise<Action<HTMLElement>>;
|
|
44
|
+
load_frame_data: (f: string, tag?: string) => Promise<Frame>;
|
|
45
45
|
};
|
|
46
46
|
export declare const json_string: {
|
|
47
47
|
encode: (o: any) => Uint8Array<ArrayBufferLike>;
|
package/package.json
CHANGED
package/test/Frame.svelte
CHANGED
|
@@ -5,9 +5,9 @@ let {
|
|
|
5
5
|
selected = -1,
|
|
6
6
|
load
|
|
7
7
|
} = $props();
|
|
8
|
-
let { signals, values,
|
|
8
|
+
let { signals, values, load_frame_data, load_frame_ui } = xit();
|
|
9
9
|
const frame_info = async (tag, decoder2) => {
|
|
10
|
-
const { values: values2, unsub } = await
|
|
10
|
+
const { values: values2, unsub } = await load_frame_data("frame_info", tag);
|
|
11
11
|
const load2 = async (key) => {
|
|
12
12
|
const v = values2.json(key, [], {
|
|
13
13
|
decode: decoder2,
|
|
@@ -22,9 +22,13 @@ const frame_info = async (tag, decoder2) => {
|
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
24
24
|
if (mark === "T") {
|
|
25
|
-
return
|
|
25
|
+
return load_frame_ui(frame_id, tag).then((f) => {
|
|
26
|
+
return { name: frame_id, action: f };
|
|
27
|
+
});
|
|
26
28
|
} else if (mark === "U") {
|
|
27
|
-
return
|
|
29
|
+
return load_frame_ui(frame_id).then((f) => {
|
|
30
|
+
return { name: frame_id, action: f };
|
|
31
|
+
});
|
|
28
32
|
}
|
|
29
33
|
}).filter((v2) => v2 != null)
|
|
30
34
|
);
|
|
@@ -38,21 +42,17 @@ const tags = values.json("tags", [], {
|
|
|
38
42
|
encode: () => new Uint8Array()
|
|
39
43
|
});
|
|
40
44
|
const finalize = signals.string("finalize");
|
|
41
|
-
let a_inputs = $state(
|
|
42
|
-
let a_outputs = $state(
|
|
43
|
-
let title = $
|
|
44
|
-
const update = (v) => {
|
|
45
|
-
a_inputs =
|
|
46
|
-
a_outputs =
|
|
45
|
+
let a_inputs = $state([]);
|
|
46
|
+
let a_outputs = $state([]);
|
|
47
|
+
let title = $derived(selected > $tags.length ? "" : $tags[selected]);
|
|
48
|
+
const update = async (v) => {
|
|
49
|
+
a_inputs = [];
|
|
50
|
+
a_outputs = [];
|
|
47
51
|
const t = $tags;
|
|
48
52
|
if (0 <= v && v < t.length) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
});
|
|
53
|
-
title = t[selected];
|
|
54
|
-
} else {
|
|
55
|
-
title = "";
|
|
53
|
+
const { inputs, outputs } = await frame_info(t[v], decoder);
|
|
54
|
+
a_inputs = inputs;
|
|
55
|
+
a_outputs = outputs;
|
|
56
56
|
}
|
|
57
57
|
};
|
|
58
58
|
$effect(() => {
|
|
@@ -75,4 +75,4 @@ $effect(() => {
|
|
|
75
75
|
}}
|
|
76
76
|
/>
|
|
77
77
|
|
|
78
|
-
{@render load($tags.sort(),
|
|
78
|
+
{@render load({ tags: $tags.sort(), inputs: a_inputs, outputs: a_outputs })}
|
package/test/Frame.svelte.d.ts
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import type { Snippet } from "svelte";
|
|
2
2
|
import type { CoDec, Action } from "../index";
|
|
3
|
+
type ActionItem = {
|
|
4
|
+
name: string;
|
|
5
|
+
action: Action<HTMLElement>;
|
|
6
|
+
};
|
|
3
7
|
type $$ComponentProps = {
|
|
4
8
|
decoder: CoDec<any>["decode"];
|
|
5
9
|
selected?: number;
|
|
6
10
|
load: Snippet<[
|
|
7
|
-
string[],
|
|
8
11
|
{
|
|
9
|
-
|
|
10
|
-
|
|
12
|
+
tags: string[];
|
|
13
|
+
inputs: ActionItem[];
|
|
14
|
+
outputs: ActionItem[];
|
|
11
15
|
}
|
|
12
16
|
]>;
|
|
13
17
|
};
|
package/test/Main.svelte
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
<script lang="ts">import TestFrame from "./Frame.svelte";
|
|
2
|
+
import Split from "../components/layouts/Split.svelte";
|
|
3
|
+
import Scrollable from "../components/layouts/Scrollable.svelte";
|
|
4
|
+
import { codec } from "$xit/codec.js";
|
|
5
|
+
import {} from "../index";
|
|
6
|
+
let selected = $state(-1);
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
{#snippet combo(tags: string[])}
|
|
10
|
+
<div class="combo">
|
|
11
|
+
<select bind:value={selected}>
|
|
12
|
+
{#each tags as id, i}
|
|
13
|
+
<option value={i}>{id}</option>
|
|
14
|
+
{/each}
|
|
15
|
+
</select>
|
|
16
|
+
</div>
|
|
17
|
+
{/snippet}
|
|
18
|
+
|
|
19
|
+
{#snippet side(actions: { name: string; action: Action<HTMLElement> }[])}
|
|
20
|
+
<Scrollable>
|
|
21
|
+
<div class="items">
|
|
22
|
+
{#each actions as { action }}
|
|
23
|
+
<div style:display="contents" use:action></div>
|
|
24
|
+
{/each}
|
|
25
|
+
</div>
|
|
26
|
+
</Scrollable>
|
|
27
|
+
{/snippet}
|
|
28
|
+
|
|
29
|
+
<TestFrame decoder={codec.decode} {selected}>
|
|
30
|
+
{#snippet load({ tags, inputs, outputs })}
|
|
31
|
+
<Scrollable>
|
|
32
|
+
<Split vertical offset={200}>
|
|
33
|
+
{#snippet side_a()}
|
|
34
|
+
{@render side(outputs)}
|
|
35
|
+
{/snippet}
|
|
36
|
+
{#snippet side_b()}
|
|
37
|
+
{@render combo(tags)}
|
|
38
|
+
{@render side(inputs)}
|
|
39
|
+
{/snippet}
|
|
40
|
+
</Split>
|
|
41
|
+
</Scrollable>
|
|
42
|
+
{/snippet}
|
|
43
|
+
</TestFrame>
|
|
44
|
+
|
|
45
|
+
<style>
|
|
46
|
+
.items {
|
|
47
|
+
height: 100%;
|
|
48
|
+
display: flex;
|
|
49
|
+
flex-direction: column;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.combo {
|
|
53
|
+
padding-inline: 10px;
|
|
54
|
+
padding-bottom: 4px;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.combo > select {
|
|
58
|
+
width: 100%;
|
|
59
|
+
padding: 0px;
|
|
60
|
+
margin: 0px;
|
|
61
|
+
box-sizing: border-box;
|
|
62
|
+
}
|
|
63
|
+
</style>
|