@nil-/xit 0.4.4 → 0.4.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nil-/xit",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.5",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"svelte": "^5.7.1"
|
|
6
6
|
},
|
|
@@ -19,6 +19,10 @@
|
|
|
19
19
|
"types": "./test/Main.svelte.d.ts",
|
|
20
20
|
"svelte": "./test/Main.svelte"
|
|
21
21
|
},
|
|
22
|
+
"./test/ReadOnlyValueLoader.svelte": {
|
|
23
|
+
"types": "./test/ReadOnlyValueLoader.svelte.d.ts",
|
|
24
|
+
"svelte": "./test/ReadOnlyValueLoader.svelte"
|
|
25
|
+
},
|
|
22
26
|
"./components/layouts/Container.svelte": {
|
|
23
27
|
"types": "./components/layouts/Container.svelte.d.ts",
|
|
24
28
|
"svelte": "./components/layouts/Container.svelte"
|
package/test/Main.svelte
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts">import TestFrame from "./Frame.svelte";
|
|
2
2
|
import Split from "../components/layouts/Split.svelte";
|
|
3
3
|
import Scrollable from "../components/layouts/Scrollable.svelte";
|
|
4
|
-
import {
|
|
4
|
+
import { config } from "$xit/config.js";
|
|
5
5
|
let selected = $state(-1);
|
|
6
6
|
</script>
|
|
7
7
|
|
|
@@ -25,7 +25,7 @@ let selected = $state(-1);
|
|
|
25
25
|
</Scrollable>
|
|
26
26
|
{/snippet}
|
|
27
27
|
|
|
28
|
-
<TestFrame decoder={codec.decode} {selected}>
|
|
28
|
+
<TestFrame decoder={config.codec.decode} {selected}>
|
|
29
29
|
{#snippet load({ tags, inputs, outputs })}
|
|
30
30
|
<Scrollable>
|
|
31
31
|
<Split vertical offset={200}>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<script lang="ts">import { onDestroy } from "svelte";
|
|
2
|
+
import { xit } from "../";
|
|
3
|
+
import { config } from "$xit/config.js";
|
|
4
|
+
const { loaded_data, frames } = $props();
|
|
5
|
+
const { load_frame_data } = xit();
|
|
6
|
+
let unmounted = false;
|
|
7
|
+
const unsubs = [];
|
|
8
|
+
let data = $state(frames.map((v) => null));
|
|
9
|
+
const load = async (frame, index) => {
|
|
10
|
+
const frame_data = await load_frame_data(frame.id, frame.tag);
|
|
11
|
+
if (unmounted) {
|
|
12
|
+
frame_data.unsub();
|
|
13
|
+
} else {
|
|
14
|
+
unsubs.push(frame_data.unsub);
|
|
15
|
+
unsubs.push(frame_data.values.json(config.key, null, config.codec).subscribe((v) => data[index] = v));
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
onDestroy(() => {
|
|
19
|
+
unmounted = true;
|
|
20
|
+
unsubs.forEach((c) => c());
|
|
21
|
+
});
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
{#if loaded_data != null}
|
|
25
|
+
{#await Promise.all(frames.map(load)) then frame_data}
|
|
26
|
+
{@render loaded_data(data)}
|
|
27
|
+
{/await}
|
|
28
|
+
{/if}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
2
|
+
type $$ComponentProps = {
|
|
3
|
+
loaded_data?: Snippet<[any[]]>;
|
|
4
|
+
frames: {
|
|
5
|
+
id: string;
|
|
6
|
+
tag?: string;
|
|
7
|
+
}[];
|
|
8
|
+
};
|
|
9
|
+
declare const ReadOnlyValueLoader: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
10
|
+
type ReadOnlyValueLoader = ReturnType<typeof ReadOnlyValueLoader>;
|
|
11
|
+
export default ReadOnlyValueLoader;
|