|
23 | 23 | Copy, |
24 | 24 | Check, |
25 | 25 | RefreshCw, |
26 | | - Package, |
27 | 26 | Loader2, |
28 | 27 | Code |
29 | 28 | } from '@lucide/svelte'; |
30 | 29 | import { getSchemaMetadata } from '$lib/services/schema/schemaPath'; |
31 | 30 | import { getAppInputSchema, getAppOutputSchema } from '$lib/services/packages.svelte'; |
32 | 31 |
|
33 | 32 | interface Props { |
34 | | - packageId: string; |
| 33 | + packageName: string; |
35 | 34 | descriptorId: string; |
36 | 35 | } |
37 | 36 |
|
38 | | - let { packageId, descriptorId }: Props = $props(); |
| 37 | + let { packageName, descriptorId }: Props = $props(); |
39 | 38 |
|
40 | 39 | // State management |
41 | 40 | let descriptorInputSchema: object | null = $state(null); |
|
45 | 44 | let error = $state<string | null>(null); |
46 | 45 | let activeTab = $state('command'); |
47 | 46 | let commandCopied = $state(false); |
| 47 | + let niwrapExecutionData = $state<{ |
| 48 | + success: true; |
| 49 | + cargs: string[]; |
| 50 | + outputObject: any; |
| 51 | +} | { |
| 52 | + success: false; |
| 53 | + error: string; |
| 54 | +} | null>(null); |
48 | 55 |
|
49 | 56 | // Memoized computations |
50 | | - const niwrapExecutionData = $derived.by(() => { |
| 57 | + $effect(() => { |
51 | 58 | if (!descriptorConfig || Object.keys(descriptorConfig).length === 0) { |
52 | | - return { success: false, error: 'No configuration provided', cargs: [], outputFiles: [], outputObject: {} }; |
| 59 | + niwrapExecutionData = { success: false, error: 'No configuration provided' }; |
53 | 60 | } |
54 | | - return niwrapExecute(descriptorConfig); |
| 61 | + niwrapExecute(descriptorConfig).then((d) => niwrapExecutionData = d); |
55 | 62 | }); |
56 | 63 |
|
57 | 64 | const commandArgs = $derived(() => { |
| 65 | + if (!niwrapExecutionData) return []; |
| 66 | +
|
58 | 67 | if (!niwrapExecutionData.success) { |
59 | 68 | return niwrapDeathMessage(); |
60 | 69 | } |
|
67 | 76 | }); |
68 | 77 |
|
69 | 78 | const outputFiles = $derived.by(() => { |
| 79 | + if (!niwrapExecutionData) return []; |
70 | 80 | const ret = []; |
71 | 81 | if (!niwrapExecutionData.success) return []; |
72 | 82 | for (const [key, value] of Object.entries(niwrapExecutionData.outputObject)) { |
73 | 83 | if (!(typeof value === 'string')) continue; |
74 | 84 | const keyMetadata = descriptorOutputSchema && getSchemaMetadata(descriptorOutputSchema, key); |
75 | | - console.log(descriptorOutputSchema) |
76 | | - console.log(key) |
77 | 85 | ret.push({ |
78 | 86 | path: '/outputs/' + value, |
79 | 87 | title: keyMetadata?.title ?? 'Title', |
|
83 | 91 | } |
84 | 92 | return ret; |
85 | 93 | }); |
86 | | - const niwrapError = $derived(niwrapExecutionData.success ? null : niwrapExecutionData.error); |
| 94 | + const niwrapError = $derived(niwrapExecutionData?.success ? null : niwrapExecutionData?.error ?? "???"); |
87 | 95 | const hasConfig = $derived(Object.keys(descriptorConfig).length > 0); |
88 | 96 | const hasOutputs = $derived(outputFiles.length > 0); |
89 | 97 |
|
90 | 98 | // Schema fetching with retry logic |
91 | 99 | async function fetchSchema() { |
92 | | - if (!packageId || !descriptorId) return; |
| 100 | + if (!packageName || !descriptorId) return; |
93 | 101 |
|
94 | 102 | isLoading = true; |
95 | 103 | error = null; |
96 | 104 |
|
97 | 105 | try { |
98 | | - const inputSchema = await getAppInputSchema(packageId, descriptorId); |
99 | | - const outputSchema = await getAppOutputSchema(packageId, descriptorId); |
| 106 | + const inputSchema = await getAppInputSchema(packageName, descriptorId); |
| 107 | + const outputSchema = await getAppOutputSchema(packageName, descriptorId); |
100 | 108 | descriptorInputSchema = inputSchema; |
101 | 109 | descriptorOutputSchema = outputSchema; |
102 | 110 | } catch (err) { |
|
0 commit comments