@nil-/xit 0.2.4 → 0.2.5
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/index.js +1 -3
- package/package.json +4 -4
- package/test/Frame.svelte +78 -0
- package/test/Frame.svelte.d.ts +16 -0
- package/test.d.ts +0 -8
- package/test.js +0 -31
package/assets/index.js
CHANGED
|
@@ -2230,9 +2230,7 @@ const _e = async (s) => new Promise((t, e) => {
|
|
|
2230
2230
|
const r = new k(), o = new Ct(
|
|
2231
2231
|
s.id,
|
|
2232
2232
|
a.data.code,
|
|
2233
|
-
a.data.files.map(
|
|
2234
|
-
(h) => new Bt(h.target, h.metadata)
|
|
2235
|
-
)
|
|
2233
|
+
a.data.files.map((h) => new Bt(h.target, h.metadata))
|
|
2236
2234
|
);
|
|
2237
2235
|
r.finish(o.pack(r)), St(
|
|
2238
2236
|
s.host,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nil-/xit",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"svelte": "^5.7.1"
|
|
6
6
|
},
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
"types": "./index.d.ts",
|
|
12
12
|
"default": "./index.js"
|
|
13
13
|
},
|
|
14
|
-
"./test": {
|
|
15
|
-
"types": "./test.d.ts",
|
|
16
|
-
"
|
|
14
|
+
"./test/Frame.svelte": {
|
|
15
|
+
"types": "./test/Frame.svelte.d.ts",
|
|
16
|
+
"svelte": "./test/Frame.svelte"
|
|
17
17
|
},
|
|
18
18
|
"./components/layouts/Container.svelte": {
|
|
19
19
|
"types": "./components/layouts/Container.svelte.d.ts",
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
<script lang="ts">import { xit } from "../index";
|
|
2
|
+
import { get } from "svelte/store";
|
|
3
|
+
let {
|
|
4
|
+
decoder,
|
|
5
|
+
selected = -1,
|
|
6
|
+
load
|
|
7
|
+
} = $props();
|
|
8
|
+
let { signals, values, frame, frame_ui } = xit();
|
|
9
|
+
const frame_info = async (tag, decoder2) => {
|
|
10
|
+
const { values: values2, unsub } = await frame("frame_info", tag);
|
|
11
|
+
const load2 = async (key) => {
|
|
12
|
+
const v = values2.json(key, [], {
|
|
13
|
+
decode: decoder2,
|
|
14
|
+
encode: () => {
|
|
15
|
+
return new Uint8Array();
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
return Promise.all(
|
|
19
|
+
get(v).map((v2) => {
|
|
20
|
+
const [frame_id, mark, g] = v2.split(":");
|
|
21
|
+
if (g !== "V") {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (mark === "T") {
|
|
25
|
+
return frame_ui(frame_id, tag);
|
|
26
|
+
} else if (mark === "U") {
|
|
27
|
+
return frame_ui(frame_id);
|
|
28
|
+
}
|
|
29
|
+
}).filter((v2) => v2 != null)
|
|
30
|
+
);
|
|
31
|
+
};
|
|
32
|
+
const [inputs, outputs] = await Promise.all([load2("inputs"), load2("outputs")]);
|
|
33
|
+
unsub();
|
|
34
|
+
return { inputs, outputs };
|
|
35
|
+
};
|
|
36
|
+
const tags = values.json("tags", [], {
|
|
37
|
+
decode: decoder,
|
|
38
|
+
encode: () => new Uint8Array()
|
|
39
|
+
});
|
|
40
|
+
const finalize = signals.string("finalize");
|
|
41
|
+
let a_inputs = $state(null);
|
|
42
|
+
let a_outputs = $state(null);
|
|
43
|
+
let title = $state("");
|
|
44
|
+
const update = (v) => {
|
|
45
|
+
a_inputs = null;
|
|
46
|
+
a_outputs = null;
|
|
47
|
+
const t = $tags;
|
|
48
|
+
if (0 <= v && v < t.length) {
|
|
49
|
+
frame_info(t[v], decoder).then(({ inputs, outputs }) => {
|
|
50
|
+
a_inputs = inputs;
|
|
51
|
+
a_outputs = outputs;
|
|
52
|
+
});
|
|
53
|
+
title = t[selected];
|
|
54
|
+
} else {
|
|
55
|
+
title = "";
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
$effect(() => {
|
|
59
|
+
update(selected);
|
|
60
|
+
});
|
|
61
|
+
</script>
|
|
62
|
+
|
|
63
|
+
<svelte:head>
|
|
64
|
+
<title>nil - xit {title}</title>
|
|
65
|
+
</svelte:head>
|
|
66
|
+
|
|
67
|
+
<svelte:window
|
|
68
|
+
onkeydown={(event) => {
|
|
69
|
+
if ((event.ctrlKey || event.metaKey) && event.key === "s") {
|
|
70
|
+
if (0 <= selected && selected < $tags.length) {
|
|
71
|
+
finalize($tags[selected]);
|
|
72
|
+
event.preventDefault();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}}
|
|
76
|
+
/>
|
|
77
|
+
|
|
78
|
+
{@render load($tags.sort(), { inputs: a_inputs, outputs: a_outputs })}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
2
|
+
import type { CoDec, Action } from "../index";
|
|
3
|
+
type $$ComponentProps = {
|
|
4
|
+
decoder: CoDec<any>["decode"];
|
|
5
|
+
selected?: number;
|
|
6
|
+
load: Snippet<[
|
|
7
|
+
string[],
|
|
8
|
+
{
|
|
9
|
+
inputs: Action<HTMLElement>[] | null;
|
|
10
|
+
outputs: Action<HTMLElement>[] | null;
|
|
11
|
+
}
|
|
12
|
+
]>;
|
|
13
|
+
};
|
|
14
|
+
declare const Frame: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
15
|
+
type Frame = ReturnType<typeof Frame>;
|
|
16
|
+
export default Frame;
|
package/test.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { CoDec } from "./index";
|
|
2
|
-
export declare const xit_test: () => {
|
|
3
|
-
xit: import("./index").Context;
|
|
4
|
-
frame_info: (tag: string, decoder: CoDec<any>["decode"]) => Promise<{
|
|
5
|
-
inputs: import("./index").Action<HTMLElement>[];
|
|
6
|
-
outputs: import("./index").Action<HTMLElement>[];
|
|
7
|
-
}>;
|
|
8
|
-
};
|
package/test.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { xit } from "./index";
|
|
2
|
-
import { get } from "svelte/store";
|
|
3
|
-
export const xit_test = () => {
|
|
4
|
-
const x = xit();
|
|
5
|
-
return {
|
|
6
|
-
xit: x,
|
|
7
|
-
frame_info: async (tag, decoder) => {
|
|
8
|
-
const { values, unsub } = await x.frame("frame_info", tag);
|
|
9
|
-
const load = async (key) => {
|
|
10
|
-
const v = values.json(key, [], { decode: decoder, encode: () => { return new Uint8Array(); } });
|
|
11
|
-
return Promise.all(get(v)
|
|
12
|
-
.map(v => {
|
|
13
|
-
const [frame_id, mark, g] = v.split(":");
|
|
14
|
-
if (g !== "V") {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
if (mark === "T") {
|
|
18
|
-
return x.frame_ui(frame_id, tag);
|
|
19
|
-
}
|
|
20
|
-
else if (mark === "U") {
|
|
21
|
-
return x.frame_ui(frame_id);
|
|
22
|
-
}
|
|
23
|
-
})
|
|
24
|
-
.filter(v => v != null));
|
|
25
|
-
};
|
|
26
|
-
const [inputs, outputs] = await Promise.all([load("inputs"), load("outputs")]);
|
|
27
|
-
unsub();
|
|
28
|
-
return { inputs, outputs };
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
};
|