This commit is contained in:
Ruben Fiszel
2025-06-24 09:02:32 +02:00
parent 27e12a1527
commit d6a0c026d4
3 changed files with 28 additions and 12 deletions
@@ -180,6 +180,26 @@
componentSettings.item.data.componentInput = appInput
}
}
let templateChangeTimeout: NodeJS.Timeout | undefined = undefined
function onTemplateChange(e: CustomEvent<{ code: string }>) {
if (componentSettings?.item.data.componentInput?.type === 'templatev2') {
if (templateChangeTimeout) {
clearTimeout(templateChangeTimeout)
}
templateChangeTimeout = setTimeout(() => {
if (componentSettings?.item.data.componentInput?.type === 'templatev2') {
inferDeps(
'`' + e.detail.code + '`',
$worldStore.outputsById,
componentSettings?.item.data.componentInput,
app
)
console.log('inferred deps for', componentSettings?.item.data.id)
}
}, 200)
}
}
</script>
<svelte:window onkeydown={keydown} />
@@ -284,16 +304,7 @@
fontSize={12}
bind:code={componentSettings.item.data.componentInput.eval}
{extraLib}
on:change={(e) => {
if (componentSettings?.item.data.componentInput?.type === 'templatev2') {
inferDeps(
'`' + e.detail.code + '`',
$worldStore.outputsById,
componentSettings?.item.data.componentInput,
app
)
}
}}
on:change={onTemplateChange}
/>
</div>
{#if componentSettings.item.data?.componentInput?.type === 'templatev2'}
@@ -6,8 +6,12 @@
const { runnableComponents } = getContext<AppViewerContext>('AppViewerContext')
export let item: GridItem
export let ownId: string
interface Props {
item: GridItem
ownId: string
}
let { item = $bindable(), ownId }: Props = $props()
const componentsWithEventHandler = [
'modalcomponent',
@@ -68,6 +68,7 @@
}
function inferDepsFromCode(code: string) {
console.log('inferDepsFromCode', id)
if (componentInput) {
inferDeps(code, $worldStore.outputsById, componentInput, app)
}