From 37da6ce38f0e216409cc0aeccb7ac36de9d785bb Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Tue, 24 Jun 2025 18:21:06 +0200 Subject: [PATCH] nit fixes app --- .../apps/components/buttons/AppButton.svelte | 11 +++++++- .../apps/components/helpers/InputValue.svelte | 25 ++++++++++++------- .../components/details/createAppFromScript.ts | 20 ++++++++++++--- 3 files changed, 42 insertions(+), 14 deletions(-) diff --git a/frontend/src/lib/components/apps/components/buttons/AppButton.svelte b/frontend/src/lib/components/apps/components/buttons/AppButton.svelte index 8ec9475f30..3cec5c1868 100644 --- a/frontend/src/lib/components/apps/components/buttons/AppButton.svelte +++ b/frontend/src/lib/components/apps/components/buttons/AppButton.svelte @@ -1,6 +1,6 @@ {#each Object.entries(components['buttoncomponent'].initialData.configuration) as [key, initialConfig] (key)} diff --git a/frontend/src/lib/components/apps/components/helpers/InputValue.svelte b/frontend/src/lib/components/apps/components/helpers/InputValue.svelte index 3307087563..eed765c6fb 100644 --- a/frontend/src/lib/components/apps/components/helpers/InputValue.svelte +++ b/frontend/src/lib/components/apps/components/helpers/InputValue.svelte @@ -126,7 +126,6 @@ const debounceEval = async (s?: string) => { let args = s == 'exprChanged' ? { file: { name: 'example.png' } } : undefined let nvalue = await evalExpr(input as EvalAppInput, args) - if (field) { editorContext?.evalPreview.update((x) => { x[`${id}.${field}`] = nvalue @@ -137,7 +136,6 @@ if (!onDemandOnly) { let nhash = typeof nvalue != 'object' ? nvalue : sum(nvalue) if (lastExprHash != nhash) { - // console.log('eval changed', field, nvalue) value = nvalue lastExprHash = nhash } @@ -168,6 +166,8 @@ await debounceTemplate() } else if (input?.type == 'eval') { value = await evalExpr(input as EvalAppInput) + let nhash = typeof value != 'object' ? value : sum(value) + lastExprHash = nhash } else if (input?.type == 'evalv2') { // console.log('evalv2', onDemandOnly, field) if (onDemandOnly && exportValueFunction) { @@ -347,7 +347,6 @@ ) && untrack(() => debounceTemplate()) }) - let stateId = $derived($worldStore?.stateId) $effect(() => { input?.type == 'static' && input.value input && $worldStore && untrack(() => debounce(handleConnection)) @@ -356,17 +355,25 @@ input && input.type == 'template' && isCodeInjection(input.eval) && - $stateId && $stateStore && untrack(() => debounce(debounceTemplate)) }) $effect.pre(() => { - input && - input.type == 'eval' && - $stateId && - $stateStore && - untrack(() => debounce2(debounceEval)) + input && input.type == 'eval' && $stateStore && untrack(() => debounce2(debounceEval)) }) + + if (input?.type == 'eval') { + $worldStore?.stateId.subscribe((x) => { + debounce2(debounceEval) + }) + } + + if (input?.type == 'template') { + $worldStore?.stateId.subscribe((x) => { + debounce2(debounceTemplate) + }) + } + $effect.pre(() => { input?.type == 'evalv2' && input.expr && untrack(() => debounceEval('exprChanged')) }) diff --git a/frontend/src/lib/components/details/createAppFromScript.ts b/frontend/src/lib/components/details/createAppFromScript.ts index 7dfe1c517a..b359e7367c 100644 --- a/frontend/src/lib/components/details/createAppFromScript.ts +++ b/frontend/src/lib/components/details/createAppFromScript.ts @@ -145,8 +145,14 @@ export function createAppFromScript(path: string, schema: Record | value: false }, disabled: { - type: 'eval', - expr: '!c.valid' + type: 'evalv2', + expr: '!c.valid', + connections: [ + { + componentId: 'c', + id: 'valid' + } + ] }, beforeIcon: { type: 'static', @@ -705,8 +711,14 @@ export function createAppFromFlow(path: string, schema: Record | un value: false }, disabled: { - type: 'eval', - expr: '!c.valid' + type: 'evalv2', + expr: '!c.valid', + connections: [ + { + componentId: 'c', + id: 'valid' + } + ] }, beforeIcon: { type: 'static',