From 065b0efa851fc9c034fb90be96c5fabf10910527 Mon Sep 17 00:00:00 2001 From: "claude[bot]" <209825114+claude[bot]@users.noreply.github.com> Date: Thu, 26 Jun 2025 13:52:00 +0000 Subject: [PATCH] Replace all structuredClone patterns with clone() utility MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Replace structuredClone($state.snapshot(x)) with clone(x) - Replace structuredClone(stateSnapshot(x)) with clone(x) - Replace structuredClone(x) with clone(x) - Add clone import to 40+ files - Remove unused stateSnapshot imports - Fix syntax errors and import conflicts Total: 101 structuredClone patterns replaced across codebase 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Diego Imbert --- frontend/src/lib/components/ArgInput.svelte | 9 +++++---- frontend/src/lib/components/DiffDrawer.svelte | 5 +++-- frontend/src/lib/components/DynSelect.svelte | 4 ++-- .../lib/components/EditableSchemaForm.svelte | 4 ++-- frontend/src/lib/components/FlowBuilder.svelte | 17 +++++++++-------- .../src/lib/components/HistoricInputs.svelte | 3 ++- .../lib/components/InputTransformForm.svelte | 4 ++-- .../src/lib/components/SavedInputsPicker.svelte | 3 ++- .../src/lib/components/SavedInputsV2.svelte | 3 ++- frontend/src/lib/components/SchemaForm.svelte | 10 +++++----- .../src/lib/components/ScriptBuilder.svelte | 17 +++++++++-------- .../components/buttons/AppSchemaForm.svelte | 4 ++-- .../display/table/AppAggridExplorerTable.svelte | 4 ++-- .../display/table/AppAggridTable.svelte | 4 ++-- .../apps/components/layout/AppTabs.svelte | 3 ++- .../apps/editor/AppEditorHeader.svelte | 15 ++++++++------- .../apps/editor/AppReportsDrawerInner.svelte | 4 ++-- .../editor/componentsPanel/CssProperty.svelte | 5 +++-- .../components/flows/content/FlowInput.svelte | 16 ++++++++-------- .../flows/content/ScriptEditorDrawer.svelte | 9 +++++---- .../lib/components/flows/flowStore.svelte.ts | 4 ++-- frontend/src/lib/components/flows/flowStore.ts | 4 ++-- .../flows/propPicker/OutputPickerInner.svelte | 5 +++-- .../src/lib/components/flows/scheduleUtils.ts | 7 +++---- .../lib/components/flows/testSteps.svelte.ts | 3 ++- .../src/lib/components/graph/FlowGraphV2.svelte | 6 +++--- .../raw_apps/RawAppEditorHeader.svelte | 14 +++++++------- .../schema/EditableSchemaDrawer.svelte | 4 ++-- .../lib/components/schema/PropertyEditor.svelte | 6 +++--- .../lib/components/schema/schemaUtils.svelte.ts | 7 ++++--- .../components/triggers/CaptureSection.svelte | 5 ++--- .../lib/components/triggers/CaptureTable.svelte | 6 +++--- .../triggers/gcp/GcpTriggerEditorInner.svelte | 4 ++-- .../triggers/http/RouteEditorInner.svelte | 4 ++-- .../kafka/KafkaTriggerEditorInner.svelte | 6 +++--- .../triggers/mqtt/MqttTriggerEditorInner.svelte | 4 ++-- .../triggers/nats/NatsTriggerEditorInner.svelte | 4 ++-- .../postgres/PostgresTriggerEditorInner.svelte | 4 ++-- .../schedules/ScheduleEditorInner.svelte | 10 +++++----- .../triggers/sqs/SqsTriggerEditorInner.svelte | 4 ++-- .../WebsocketTriggerEditorInner.svelte | 4 ++-- frontend/src/lib/utils.ts | 4 ++-- .../(logged)/apps/edit/[...path]/+page.svelte | 7 +++---- .../apps_raw/edit/[...path]/+page.svelte | 9 ++++----- .../(logged)/flows/edit/[...path]/+page.svelte | 7 ++++--- .../scripts/edit/[...path]/+page.svelte | 6 +++--- 46 files changed, 151 insertions(+), 140 deletions(-) diff --git a/frontend/src/lib/components/ArgInput.svelte b/frontend/src/lib/components/ArgInput.svelte index 7f75cc4d97..ce3ca9bd37 100644 --- a/frontend/src/lib/components/ArgInput.svelte +++ b/frontend/src/lib/components/ArgInput.svelte @@ -7,7 +7,8 @@ setInputCat as computeInputCat, debounce, emptyString, - getSchemaFromProperties + getSchemaFromProperties, + clone } from '$lib/utils' import { DollarSign, Pipette, Plus, X, Check, Loader2 } from 'lucide-svelte' import { createEventDispatcher, onDestroy, onMount, tick, untrack } from 'svelte' @@ -244,7 +245,7 @@ nvalue = undefined } if ((value == undefined || value == null) && !ignoreValueUndefined) { - nvalue = structuredClone($state.snapshot(defaultValue)) + nvalue = clone(defaultValue) if (defaultValue === undefined || defaultValue === null) { if (inputCat === 'string') { nvalue = nullable ? null : '' @@ -296,7 +297,7 @@ lastValue = value } - let oldDefaultValue = structuredClone($state.snapshot(defaultValue)) + let oldDefaultValue = clone(defaultValue) function handleDefaultValueChange() { if ( deepEqual(value, oldDefaultValue) && @@ -305,7 +306,7 @@ ) { value = defaultValue } - oldDefaultValue = structuredClone($state.snapshot(defaultValue)) + oldDefaultValue = clone(defaultValue) } function isObjectCat(inputCat?: string) { diff --git a/frontend/src/lib/components/DiffDrawer.svelte b/frontend/src/lib/components/DiffDrawer.svelte index 5d178aab75..61fc568c4e 100644 --- a/frontend/src/lib/components/DiffDrawer.svelte +++ b/frontend/src/lib/components/DiffDrawer.svelte @@ -9,7 +9,8 @@ orderedJsonStringify, orderedYamlStringify, replaceFalseWithUndefined, - type Value + type Value, + clone } from '$lib/utils' import type { Script } from '$lib/gen' @@ -68,7 +69,7 @@ } function prepareDiff(data: Value) { - const metadata = structuredClone(cleanValueProperties(replaceFalseWithUndefined(data))) + const metadata = clone(cleanValueProperties(replaceFalseWithUndefined(data))) const content = metadata['content'] if (metadata['content'] !== undefined) { metadata['content'] = 'check content diff' diff --git a/frontend/src/lib/components/DynSelect.svelte b/frontend/src/lib/components/DynSelect.svelte index 93a3bf0ed3..ceb05273b8 100644 --- a/frontend/src/lib/components/DynSelect.svelte +++ b/frontend/src/lib/components/DynSelect.svelte @@ -23,7 +23,7 @@ import Tooltip from './Tooltip.svelte' import { Loader2 } from 'lucide-svelte' import { untrack } from 'svelte' - import { readFieldsRecursively } from '$lib/utils' + import { readFieldsRecursively, clone} from '$lib/utils' interface Props { value?: any @@ -37,7 +37,7 @@ let { value = $bindable(), helperScript, entrypoint, args: _args, name }: Props = $props() - let args = $state(structuredClone($state.snapshot(_args))) + let args = $state(clone(_args)) $effect(() => { readFieldsRecursively(_args, { excludeField: [name] }) untrack(() => !deepEqual(args, _args) && (args = $state.snapshot(_args))) diff --git a/frontend/src/lib/components/EditableSchemaForm.svelte b/frontend/src/lib/components/EditableSchemaForm.svelte index b19325f45b..44ca60063a 100644 --- a/frontend/src/lib/components/EditableSchemaForm.svelte +++ b/frontend/src/lib/components/EditableSchemaForm.svelte @@ -20,7 +20,7 @@ import Label from './Label.svelte' import { sendUserToast } from '$lib/toast' import Toggle from './Toggle.svelte' - import { emptyString } from '$lib/utils' + import { emptyString, clone} from '$lib/utils' import Popover from './meltComponents/Popover.svelte' import SchemaFormDnd from './schema/SchemaFormDND.svelte' import { deepEqual } from 'fast-equals' @@ -114,7 +114,7 @@ Object.keys(schema?.properties ?? {}).forEach((key) => { if (schema?.properties[key].default != undefined && args?.[key] == undefined) { let value = schema?.properties[key].default - nargs[key] = value === 'object' ? structuredClone($state.snapshot(value)) : value + nargs[key] = value === 'object' ? clone(value) : value } }) args = nargs diff --git a/frontend/src/lib/components/FlowBuilder.svelte b/frontend/src/lib/components/FlowBuilder.svelte index dbeebfa6f7..a86bfdcd9f 100644 --- a/frontend/src/lib/components/FlowBuilder.svelte +++ b/frontend/src/lib/components/FlowBuilder.svelte @@ -27,7 +27,8 @@ readFieldsRecursively, replaceFalseWithUndefined, type StateStore, - type Value + type Value, + clone } from '$lib/utils' import { sendUserToast } from '$lib/toast' import { Drawer } from '$lib/components/common' @@ -185,7 +186,7 @@ savedValue: savedFlow, modifiedValue: { ...flowStore.val, - draft_triggers: structuredClone(triggersState.getDraftTriggersSnapshot()) + draft_triggers: clone(triggersState.getDraftTriggersSnapshot()) } } } @@ -250,7 +251,7 @@ if (savedFlow) { const draftOrDeployed = cleanValueProperties(savedFlow.draft || savedFlow) - const currentDraftTriggers = structuredClone(triggersState.getDraftTriggersSnapshot()) + const currentDraftTriggers = clone(triggersState.getDraftTriggersSnapshot()) const current = cleanValueProperties( $state.snapshot({ ...flowStore.val, @@ -329,15 +330,15 @@ savedFlow = { ...(newFlow || savedFlow?.draft_only ? { - ...structuredClone($state.snapshot(flowStore.val)), + ...clone(flowStore.val), path: $pathStore, draft_only: true } : savedFlow), draft: { - ...structuredClone($state.snapshot(flowStore.val)), + ...clone(flowStore.val), path: $pathStore, - draft_triggers: structuredClone(triggersState.getDraftTriggersSnapshot()) + draft_triggers: clone(triggersState.getDraftTriggersSnapshot()) } } as FlowWithDraftAndDraftTriggers @@ -519,7 +520,7 @@ draft_triggers: Trigger[] } savedFlow = { - ...structuredClone($state.snapshot(newSavedFlow)), + ...clone(newSavedFlow), path: $pathStore } as Flow setDraftTriggers([]) @@ -1042,7 +1043,7 @@ await syncWithDeployed() - const currentDraftTriggers = structuredClone( + const currentDraftTriggers = clone( triggersState.getDraftTriggersSnapshot() ) diff --git a/frontend/src/lib/components/HistoricInputs.svelte b/frontend/src/lib/components/HistoricInputs.svelte index ac79c0479b..4a43bd1b1e 100644 --- a/frontend/src/lib/components/HistoricInputs.svelte +++ b/frontend/src/lib/components/HistoricInputs.svelte @@ -1,4 +1,5 @@