@nil-/xit 0.4.12 → 0.4.14
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 +1 -1
- package/components/layouts/Container.svelte +3 -1
- package/components/layouts/Scrollable.svelte +2 -1
- package/components/layouts/Split.svelte +70 -44
- package/components/loaders/Helpers.d.ts +9 -8
- package/components/loaders/Reactive.svelte +50 -40
- package/components/loaders/ReadOnly.svelte +75 -49
- package/components/utilities/DividerOverlay.svelte +7 -4
- package/package.json +1 -2
- package/test/Frame.svelte +98 -58
- package/test/Frame.svelte.d.ts +3 -2
- package/test/Main.svelte +27 -21
- package/components/loaders/Reactive.svelte.d.ts +0 -3916
- package/components/loaders/ReadOnly.svelte.d.ts +0 -3916
package/test/Frame.svelte
CHANGED
|
@@ -1,63 +1,103 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { xit, type CoDec, type Action } from "..";
|
|
3
|
+
import { get } from "svelte/store";
|
|
4
|
+
|
|
5
|
+
import type { Snippet } from "svelte";
|
|
6
|
+
|
|
7
|
+
type ActionItem = {
|
|
8
|
+
name: string;
|
|
9
|
+
action: Action<HTMLElement>;
|
|
10
|
+
url: (tag: string) => string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
type Props = {
|
|
14
|
+
decoder: CoDec<any>["decode"];
|
|
15
|
+
selected?: number;
|
|
16
|
+
load: Snippet<
|
|
17
|
+
[
|
|
18
|
+
{
|
|
19
|
+
tags: string[];
|
|
20
|
+
inputs: ActionItem[];
|
|
21
|
+
outputs: ActionItem[];
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
>;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
let { decoder, selected = $bindable(-1), load }: Props = $props();
|
|
28
|
+
|
|
29
|
+
let { signals, values, load_frame_data, load_frame_ui } = xit();
|
|
30
|
+
|
|
31
|
+
const frame_info = async (tag: string, decoder: CoDec<any>["decode"]) => {
|
|
32
|
+
const { values, unsub } = await load_frame_data("frame_info", tag);
|
|
33
|
+
const load = async (key: string) => {
|
|
34
|
+
const v = values.json(key, [] as string[], {
|
|
35
|
+
decode: decoder,
|
|
36
|
+
encode: () => {
|
|
37
|
+
return new Uint8Array();
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
return Promise.all(
|
|
41
|
+
get(v)
|
|
42
|
+
.map((v) => {
|
|
43
|
+
const [frame_id, mark, g] = v.split(":");
|
|
44
|
+
if (g !== "V") {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (mark === "T") {
|
|
48
|
+
return load_frame_ui(frame_id, tag).then((f) => {
|
|
49
|
+
return {
|
|
50
|
+
name: frame_id,
|
|
51
|
+
action: f,
|
|
52
|
+
url: (tag) => `/?frame=${frame_id}&tag=${tag}`
|
|
53
|
+
} satisfies ActionItem;
|
|
54
|
+
});
|
|
55
|
+
} else if (mark === "U") {
|
|
56
|
+
return load_frame_ui(frame_id).then((f) => {
|
|
57
|
+
return {
|
|
58
|
+
name: frame_id,
|
|
59
|
+
action: f,
|
|
60
|
+
url: (tag) => `/?frame=${frame_id}`
|
|
61
|
+
} satisfies ActionItem;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
})
|
|
65
|
+
.filter((v) => v != null)
|
|
66
|
+
);
|
|
67
|
+
};
|
|
68
|
+
const [inputs, outputs] = await Promise.all([load("inputs"), load("outputs")]);
|
|
69
|
+
unsub();
|
|
70
|
+
return { inputs, outputs };
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const tags = values.json("tags", [] as string[], {
|
|
74
|
+
decode: decoder,
|
|
75
|
+
encode: () => new Uint8Array()
|
|
17
76
|
});
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
77
|
+
|
|
78
|
+
if ($tags.length > 0) {
|
|
79
|
+
selected = 0;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const finalize = signals.string("finalize");
|
|
83
|
+
|
|
84
|
+
let a_inputs = $state([] as ActionItem[]);
|
|
85
|
+
let a_outputs = $state([] as ActionItem[]);
|
|
86
|
+
let title = $derived(selected > $tags.length ? "" : $tags[selected]);
|
|
87
|
+
const update = async (v: number) => {
|
|
88
|
+
a_inputs = [];
|
|
89
|
+
a_outputs = [];
|
|
90
|
+
const t = $tags;
|
|
91
|
+
if (0 <= v && v < t.length) {
|
|
92
|
+
const { inputs, outputs } = await frame_info(t[v], decoder);
|
|
93
|
+
a_inputs = inputs;
|
|
94
|
+
a_outputs = outputs;
|
|
32
95
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return { inputs, outputs };
|
|
39
|
-
};
|
|
40
|
-
const tags = values.json("tags", [], {
|
|
41
|
-
decode: decoder,
|
|
42
|
-
encode: () => new Uint8Array()
|
|
43
|
-
});
|
|
44
|
-
const finalize = signals.string("finalize");
|
|
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 = [];
|
|
51
|
-
const t = $tags;
|
|
52
|
-
if (0 <= v && v < t.length) {
|
|
53
|
-
const { inputs, outputs } = await frame_info(t[v], decoder);
|
|
54
|
-
a_inputs = inputs;
|
|
55
|
-
a_outputs = outputs;
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
$effect(() => {
|
|
59
|
-
update(selected);
|
|
60
|
-
});
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
$effect(() => {
|
|
99
|
+
update(selected);
|
|
100
|
+
});
|
|
61
101
|
</script>
|
|
62
102
|
|
|
63
103
|
<svelte:head>
|
package/test/Frame.svelte.d.ts
CHANGED
|
@@ -3,8 +3,9 @@ import type { Snippet } from "svelte";
|
|
|
3
3
|
type ActionItem = {
|
|
4
4
|
name: string;
|
|
5
5
|
action: Action<HTMLElement>;
|
|
6
|
+
url: (tag: string) => string;
|
|
6
7
|
};
|
|
7
|
-
type
|
|
8
|
+
type Props = {
|
|
8
9
|
decoder: CoDec<any>["decode"];
|
|
9
10
|
selected?: number;
|
|
10
11
|
load: Snippet<[
|
|
@@ -15,6 +16,6 @@ type $$ComponentProps = {
|
|
|
15
16
|
}
|
|
16
17
|
]>;
|
|
17
18
|
};
|
|
18
|
-
declare const Frame: import("svelte").Component
|
|
19
|
+
declare const Frame: import("svelte").Component<Props, {}, "selected">;
|
|
19
20
|
type Frame = ReturnType<typeof Frame>;
|
|
20
21
|
export default Frame;
|
package/test/Main.svelte
CHANGED
|
@@ -1,22 +1,18 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import TestFrame from "./Frame.svelte";
|
|
3
|
+
import Split from "../components/layouts/Split.svelte";
|
|
4
|
+
import Scrollable from "../components/layouts/Scrollable.svelte";
|
|
5
|
+
|
|
6
|
+
import type { Snippet } from "svelte";
|
|
7
|
+
|
|
8
|
+
import { config } from "$xit/config.js";
|
|
9
|
+
|
|
10
|
+
let { children }: { children?: Snippet<[string]> } = $props();
|
|
11
|
+
|
|
12
|
+
let selected = $state(-1);
|
|
7
13
|
</script>
|
|
8
14
|
|
|
9
|
-
{
|
|
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
|
-
<TestFrame decoder={config.codec.decode} {selected}>
|
|
15
|
+
<TestFrame decoder={config.codec.decode} bind:selected>
|
|
20
16
|
{#snippet load({ tags, inputs, outputs })}
|
|
21
17
|
<Scrollable>
|
|
22
18
|
<Split vertical offset={200}>
|
|
@@ -30,11 +26,21 @@ let selected = $state(-1);
|
|
|
30
26
|
</Scrollable>
|
|
31
27
|
{/snippet}
|
|
32
28
|
{#snippet side_b()}
|
|
33
|
-
|
|
29
|
+
<div class="combo">
|
|
30
|
+
<select bind:value={selected}>
|
|
31
|
+
{#each tags as id, i}
|
|
32
|
+
<option value={i}>{id}</option>
|
|
33
|
+
{/each}
|
|
34
|
+
</select>
|
|
35
|
+
</div>
|
|
36
|
+
{#if 0 <= selected && selected < tags.length }
|
|
34
37
|
{@render children?.(tags[selected])}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
<div style="display: flex; flex-direction: column;">
|
|
39
|
+
{#each inputs as { name, url }}
|
|
40
|
+
<a href={url(tags[selected])} target="_blank">{name}</a>
|
|
41
|
+
{/each}
|
|
42
|
+
</div>
|
|
43
|
+
{/if}
|
|
38
44
|
{/snippet}
|
|
39
45
|
</Split>
|
|
40
46
|
</Scrollable>
|