diff --git a/editor/src/components/canvas/canvas-strategies/canvas-strategies.spec.browser2.tsx b/editor/src/components/canvas/canvas-strategies/canvas-strategies.spec.browser2.tsx index 76aa5bc31052..d09d11f50667 100644 --- a/editor/src/components/canvas/canvas-strategies/canvas-strategies.spec.browser2.tsx +++ b/editor/src/components/canvas/canvas-strategies/canvas-strategies.spec.browser2.tsx @@ -175,7 +175,6 @@ describe('Strategy Fitness', () => { RegisteredCanvasStrategies, pickCanvasStateFromEditorState( renderResult.getEditorState().editor, - renderResult.getEditorState().derived, renderResult.getEditorState().builtInDependencies, ), interactionSession, @@ -225,7 +224,6 @@ describe('Strategy Fitness', () => { RegisteredCanvasStrategies, pickCanvasStateFromEditorState( renderResult.getEditorState().editor, - renderResult.getEditorState().derived, renderResult.getEditorState().builtInDependencies, ), interactionSession, @@ -316,7 +314,6 @@ describe('Strategy Fitness', () => { RegisteredCanvasStrategies, pickCanvasStateFromEditorState( renderResult.getEditorState().editor, - renderResult.getEditorState().derived, renderResult.getEditorState().builtInDependencies, ), interactionSession, @@ -366,7 +363,6 @@ describe('Strategy Fitness', () => { RegisteredCanvasStrategies, pickCanvasStateFromEditorState( renderResult.getEditorState().editor, - renderResult.getEditorState().derived, renderResult.getEditorState().builtInDependencies, ), interactionSession, @@ -416,7 +412,6 @@ describe('Strategy Fitness', () => { RegisteredCanvasStrategies, pickCanvasStateFromEditorState( renderResult.getEditorState().editor, - renderResult.getEditorState().derived, renderResult.getEditorState().builtInDependencies, ), interactionSession, diff --git a/editor/src/components/canvas/canvas-strategies/canvas-strategies.tsx b/editor/src/components/canvas/canvas-strategies/canvas-strategies.tsx index 912021b47d02..8f2944c1a30c 100644 --- a/editor/src/components/canvas/canvas-strategies/canvas-strategies.tsx +++ b/editor/src/components/canvas/canvas-strategies/canvas-strategies.tsx @@ -170,7 +170,6 @@ export const RegisteredCanvasStrategies: Array = [ export function pickCanvasStateFromEditorState( editorState: EditorState, - derivedState: DerivedState, builtInDependencies: BuiltInDependencies, ): InteractionCanvasState { return { @@ -178,7 +177,6 @@ export function pickCanvasStateFromEditorState( interactionTarget: getInteractionTargetFromEditorState(editorState), projectContents: editorState.projectContents, nodeModules: editorState.nodeModules.files, - remixRoutingTable: derivedState.remixData?.routingTable ?? null, openFile: editorState.canvas.openFile?.filename, scale: editorState.canvas.scale, canvasOffset: editorState.canvas.roundedCanvasOffset, @@ -190,7 +188,6 @@ export function pickCanvasStateFromEditorState( export function pickCanvasStateFromEditorStateWithMetadata( editorState: EditorState, - derivedState: DerivedState, builtInDependencies: BuiltInDependencies, metadata: ElementInstanceMetadataMap, allElementProps?: AllElementProps, @@ -200,7 +197,6 @@ export function pickCanvasStateFromEditorStateWithMetadata( interactionTarget: getInteractionTargetFromEditorState(editorState), projectContents: editorState.projectContents, nodeModules: editorState.nodeModules.files, - remixRoutingTable: derivedState.remixData?.routingTable ?? null, openFile: editorState.canvas.openFile?.filename, scale: editorState.canvas.scale, canvasOffset: editorState.canvas.roundedCanvasOffset, @@ -267,7 +263,7 @@ const getApplicableStrategiesSelector = createSelector( store.strategyState.sortedApplicableStrategies, ), (store: EditorStorePatched): InteractionCanvasState => { - return pickCanvasStateFromEditorState(store.editor, store.derived, store.builtInDependencies) + return pickCanvasStateFromEditorState(store.editor, store.builtInDependencies) }, (store: EditorStorePatched) => store.editor.canvas.interactionSession, (store: EditorStorePatched) => store.strategyState.customStrategyState, diff --git a/editor/src/components/canvas/canvas-strategies/canvas-strategy-types.ts b/editor/src/components/canvas/canvas-strategies/canvas-strategy-types.ts index 7e7d132b7058..9178eb342e65 100644 --- a/editor/src/components/canvas/canvas-strategies/canvas-strategy-types.ts +++ b/editor/src/components/canvas/canvas-strategies/canvas-strategy-types.ts @@ -90,7 +90,6 @@ export interface InteractionCanvasState { interactionTarget: InteractionTarget projectContents: ProjectContentTreeRoot nodeModules: NodeModules - remixRoutingTable: RemixRoutingTable | null builtInDependencies: BuiltInDependencies openFile: string | null | undefined scale: number diff --git a/editor/src/components/canvas/canvas-strategies/post-action-options/navigator-reparent.ts b/editor/src/components/canvas/canvas-strategies/post-action-options/navigator-reparent.ts index dc6ce9a94b5c..dd64e3921eef 100644 --- a/editor/src/components/canvas/canvas-strategies/post-action-options/navigator-reparent.ts +++ b/editor/src/components/canvas/canvas-strategies/post-action-options/navigator-reparent.ts @@ -43,7 +43,6 @@ import { staticReparentAndUpdatePosition } from './post-action-paste' function getNavigatorReparentCommands( data: NavigatorReparentPostActionMenuData, editor: EditorState, - derivedState: DerivedState, builtInDependencies: BuiltInDependencies, ): Array | null { const wrapperUID = generateUidWithExistingComponents(editor.projectContents) @@ -121,7 +120,6 @@ function getNavigatorReparentCommands( openFile: editor.canvas.openFile?.filename ?? null, pasteTargetsToIgnore: [], projectContents: editor.projectContents, - remixRoutingTable: derivedState.remixData?.routingTable ?? null, startingMetadata: editor.jsxMetadata, startingElementPathTrees: editor.elementPathTree, startingAllElementProps: editor.allElementProps, @@ -153,7 +151,7 @@ export const PropsPreservedNavigatorReparentPostActionChoice = ( name: 'Reparent with variables preserved', id: PropsPreservedNavigatorReparentPostActionChoiceId, run: (editor, derived, builtInDependencies) => - getNavigatorReparentCommands(data, editor, derived, builtInDependencies), + getNavigatorReparentCommands(data, editor, builtInDependencies), }) export const PropsReplacedNavigatorReparentPostActionChoiceId = @@ -188,12 +186,7 @@ export const PropsReplacedNavigatorReparentPostActionChoice = ( name: 'Reparent with variables replaced', id: PropsReplacedNavigatorReparentPostActionChoiceId, run: (editor, derived, builtInDependencies) => { - const reparentCommands = getNavigatorReparentCommands( - data, - editor, - derived, - builtInDependencies, - ) + const reparentCommands = getNavigatorReparentCommands(data, editor, builtInDependencies) if (reparentCommands == null) { return null } diff --git a/editor/src/components/canvas/canvas-strategies/post-action-options/post-action-paste.ts b/editor/src/components/canvas/canvas-strategies/post-action-options/post-action-paste.ts index 0d967a0156e9..257c4e3b972f 100644 --- a/editor/src/components/canvas/canvas-strategies/post-action-options/post-action-paste.ts +++ b/editor/src/components/canvas/canvas-strategies/post-action-options/post-action-paste.ts @@ -72,7 +72,6 @@ import type { PostActionChoice } from './post-action-options' interface EditorStateContext { projectContents: ProjectContentTreeRoot nodeModules: NodeModules - remixRoutingTable: RemixRoutingTable | null openFile: string | null pasteTargetsToIgnore: Array builtInDependencies: BuiltInDependencies @@ -267,7 +266,7 @@ export function staticReparentAndUpdatePosition( const commands = elementsToInsert.flatMap((elementToInsert) => { return [ - updateFunctionCommand('always', (editor, derivedState, commandLifecycle) => { + updateFunctionCommand('always', (editor, commandLifecycle) => { const newPath = oldPathToNewPathMapping[EP.toString(elementToInsert.elementPath)] if (newPath == null) { @@ -316,7 +315,6 @@ export function staticReparentAndUpdatePosition( return foldAndApplyCommandsInner( editor, - derivedState, [], [...propertyCommands, updateSelectedViews('always', [...editor.selectedViews, newPath])], commandLifecycle, @@ -370,7 +368,6 @@ export const PropsPreservedPastePostActionChoice = ( openFile: store.canvas.openFile?.filename ?? null, pasteTargetsToIgnore: postActionMenuData.pasteTargetsToIgnore, projectContents: store.projectContents, - remixRoutingTable: derived.remixData?.routingTable ?? null, startingMetadata: store.jsxMetadata, startingElementPathTrees: store.elementPathTree, startingAllElementProps: store.allElementProps, @@ -411,7 +408,6 @@ export const PropsReplacedPastePostActionChoice = ( openFile: store.canvas.openFile?.filename ?? null, pasteTargetsToIgnore: postActionMenuData.pasteTargetsToIgnore, projectContents: store.projectContents, - remixRoutingTable: derived.remixData?.routingTable ?? null, startingMetadata: store.jsxMetadata, startingElementPathTrees: store.elementPathTree, startingAllElementProps: store.allElementProps, @@ -469,7 +465,6 @@ export const PropsPreservedPasteHerePostActionChoice = ( openFile: editor.canvas.openFile?.filename ?? null, pasteTargetsToIgnore: [], projectContents: editor.projectContents, - remixRoutingTable: derived.remixData?.routingTable ?? null, startingMetadata: editor.jsxMetadata, startingElementPathTrees: editor.elementPathTree, startingAllElementProps: editor.allElementProps, @@ -537,7 +532,6 @@ export const PropsReplacedPasteHerePostActionChoice = ( openFile: editor.canvas.openFile?.filename ?? null, pasteTargetsToIgnore: [], projectContents: editor.projectContents, - remixRoutingTable: derived.remixData?.routingTable ?? null, startingMetadata: editor.jsxMetadata, startingElementPathTrees: editor.elementPathTree, startingAllElementProps: editor.allElementProps, @@ -698,7 +692,7 @@ function pasteToReplaceCommands( const pasteCommands = targets.flatMap((target) => { return [ - updateFunctionCommand('always', (updatedEditor, updatedDerivedState, commandLifecycle) => { + updateFunctionCommand('always', (updatedEditor, commandLifecycle) => { const element = MetadataUtils.findElementByElementPath(editor.jsxMetadata, target) const position = MetadataUtils.getFrameOrZeroRectInCanvasCoords(target, editor.jsxMetadata) const strategy = MetadataUtils.isPositionAbsolute(element) @@ -735,7 +729,6 @@ function pasteToReplaceCommands( openFile: editor.canvas.openFile?.filename ?? null, pasteTargetsToIgnore: [], projectContents: updatedEditor.projectContents, - remixRoutingTable: updatedDerivedState.remixData?.routingTable ?? null, startingMetadata: editor.jsxMetadata, startingElementPathTrees: editor.elementPathTree, startingAllElementProps: editor.allElementProps, @@ -757,13 +750,7 @@ function pasteToReplaceCommands( if (commands == null) { return [] } - return foldAndApplyCommandsInner( - updatedEditor, - updatedDerivedState, - [], - commands, - commandLifecycle, - ).statePatches + return foldAndApplyCommandsInner(updatedEditor, [], commands, commandLifecycle).statePatches }), ] }, [] as Array) diff --git a/editor/src/components/canvas/canvas-strategies/strategies/absolute-duplicate-strategy.spec.tsx b/editor/src/components/canvas/canvas-strategies/strategies/absolute-duplicate-strategy.spec.tsx index 4c6a8a366c41..eed70c211351 100644 --- a/editor/src/components/canvas/canvas-strategies/strategies/absolute-duplicate-strategy.spec.tsx +++ b/editor/src/components/canvas/canvas-strategies/strategies/absolute-duplicate-strategy.spec.tsx @@ -1,5 +1,4 @@ import type { EditorState } from '../../../editor/store/editor-state' -import { emptyDerivedState } from '../../../editor/store/editor-state' import { elementPath } from '../../../../core/shared/element-path' import type { ElementPath } from '../../../../core/shared/project-file-types' import { getEditorState, makeTestProjectCodeWithSnippet } from '../../ui-jsx.test-utils' @@ -13,10 +12,7 @@ import type { CanvasVector } from '../../../../core/shared/math-utils' import { canvasPoint, canvasRectangle, localRectangle } from '../../../../core/shared/math-utils' import type { Modifiers } from '../../../../utils/modifiers' import { altModifier } from '../../../../utils/modifiers' -import { - pickCanvasStateFromEditorState, - pickCanvasStateFromEditorStateWithMetadata, -} from '../canvas-strategies' +import { pickCanvasStateFromEditorStateWithMetadata } from '../canvas-strategies' import type { InteractionSession } from '../interaction-state' import { boundingArea } from '../interaction-state' import { createMouseInteractionForTests } from '../interaction-state.test-utils' @@ -79,7 +75,6 @@ function dragByPixelsIsApplicable( absoluteDuplicateStrategy( pickCanvasStateFromEditorStateWithMetadata( editorState, - emptyDerivedState(editorState), createBuiltInDependenciesList(null), metadata, ), diff --git a/editor/src/components/canvas/canvas-strategies/strategies/absolute-duplicate-strategy.tsx b/editor/src/components/canvas/canvas-strategies/strategies/absolute-duplicate-strategy.tsx index fb232e862a7c..2d10584c43d5 100644 --- a/editor/src/components/canvas/canvas-strategies/strategies/absolute-duplicate-strategy.tsx +++ b/editor/src/components/canvas/canvas-strategies/strategies/absolute-duplicate-strategy.tsx @@ -129,11 +129,10 @@ export function absoluteDuplicateStrategy( ...maybeAddContainLayoutCommand(commonParentPath), setElementsToRerenderCommand([...selectedElements, ...newPaths]), updateSelectedViews('always', selectedElements), - updateFunctionCommand('always', (editorState, derivedState, commandLifecycle) => + updateFunctionCommand('always', (editorState, commandLifecycle) => runMoveStrategy( canvasState, editorState, - derivedState, interactionSession, commandLifecycle, strategyLifecycle, @@ -156,7 +155,6 @@ export function absoluteDuplicateStrategy( function runMoveStrategy( canvasState: InteractionCanvasState, editorState: EditorState, - derivedState: DerivedState, interactionSession: InteractionSession, commandLifecycle: InteractionLifecycle, strategyLifecycle: InteractionLifecycle, @@ -169,8 +167,7 @@ function runMoveStrategy( 'do-not-run-applicability-check', )?.strategy.apply(strategyLifecycle).commands ?? [] - return foldAndApplyCommandsInner(editorState, derivedState, [], moveCommands, commandLifecycle) - .statePatches + return foldAndApplyCommandsInner(editorState, [], moveCommands, commandLifecycle).statePatches } type IsAbsoluteMoveApplicableResult = diff --git a/editor/src/components/canvas/canvas-strategies/strategies/absolute-reparent-strategy-canvas.spec.tsx b/editor/src/components/canvas/canvas-strategies/strategies/absolute-reparent-strategy-canvas.spec.tsx index 3227e7e32d28..f354a8d6a8f5 100644 --- a/editor/src/components/canvas/canvas-strategies/strategies/absolute-reparent-strategy-canvas.spec.tsx +++ b/editor/src/components/canvas/canvas-strategies/strategies/absolute-reparent-strategy-canvas.spec.tsx @@ -21,7 +21,6 @@ import { import type { CanvasPoint } from '../../../../core/shared/math-utils' import { canvasPoint, canvasRectangle } from '../../../../core/shared/math-utils' import type { EditorState } from '../../../editor/store/editor-state' -import { emptyDerivedState } from '../../../editor/store/editor-state' import { foldAndApplyCommands } from '../../commands/commands' import { getEditorStateWithSelectedViews, @@ -134,7 +133,6 @@ function reparentElement( const canvasState = pickCanvasStateFromEditorStateWithMetadata( editorState, - emptyDerivedState(editorState), createBuiltInDependenciesList(null), startingMetadata, ) @@ -164,7 +162,6 @@ function reparentElement( const finalEditor = foldAndApplyCommands( editorState, - emptyDerivedState(editorState), editorState, [], strategyResult.commands, diff --git a/editor/src/components/canvas/canvas-strategies/strategies/absolute-reparent-strategy-only-move.spec.tsx b/editor/src/components/canvas/canvas-strategies/strategies/absolute-reparent-strategy-only-move.spec.tsx index 857fda9670a1..9b08ef99eee1 100644 --- a/editor/src/components/canvas/canvas-strategies/strategies/absolute-reparent-strategy-only-move.spec.tsx +++ b/editor/src/components/canvas/canvas-strategies/strategies/absolute-reparent-strategy-only-move.spec.tsx @@ -5,12 +5,11 @@ import type { SpecialSizeMeasurements, } from '../../../../core/shared/element-template' import type { CanvasVector } from '../../../../core/shared/math-utils' -import { CanvasPoint, canvasPoint, canvasRectangle } from '../../../../core/shared/math-utils' +import { canvasPoint, canvasRectangle } from '../../../../core/shared/math-utils' import type { ElementPath } from '../../../../core/shared/project-file-types' import type { Modifiers } from '../../../../utils/modifiers' import { cmdModifier } from '../../../../utils/modifiers' import type { AllElementProps, EditorState } from '../../../editor/store/editor-state' -import { emptyDerivedState } from '../../../editor/store/editor-state' import { foldAndApplyCommands } from '../../commands/commands' import { getEditorState, @@ -18,13 +17,10 @@ import { testPrintCodeFromEditorState, } from '../../ui-jsx.test-utils' import { absoluteMoveStrategy } from './absolute-move-strategy' -import { - pickCanvasStateFromEditorState, - pickCanvasStateFromEditorStateWithMetadata, -} from '../canvas-strategies' +import { pickCanvasStateFromEditorStateWithMetadata } from '../canvas-strategies' import { defaultCustomStrategyState } from '../canvas-strategy-types' import type { InteractionSession } from '../interaction-state' -import { boundingArea, StrategyState } from '../interaction-state' +import { boundingArea } from '../interaction-state' import { createMouseInteractionForTests } from '../interaction-state.test-utils' jest.mock('../../canvas-utils', () => ({ @@ -104,7 +100,6 @@ function dragByPixels( const strategyResult = absoluteMoveStrategy( pickCanvasStateFromEditorStateWithMetadata( editorState, - emptyDerivedState(editorState), createBuiltInDependenciesList(null), startingMetadata, startingAllElementProps, @@ -118,7 +113,6 @@ function dragByPixels( const finalEditor = foldAndApplyCommands( editorState, - emptyDerivedState(editorState), editorState, [], strategyResult.commands, diff --git a/editor/src/components/canvas/canvas-strategies/strategies/absolute-reparent-strategy.spec.tsx b/editor/src/components/canvas/canvas-strategies/strategies/absolute-reparent-strategy.spec.tsx index 1379d5b53a2b..0312740052df 100644 --- a/editor/src/components/canvas/canvas-strategies/strategies/absolute-reparent-strategy.spec.tsx +++ b/editor/src/components/canvas/canvas-strategies/strategies/absolute-reparent-strategy.spec.tsx @@ -15,7 +15,7 @@ import { import type { CanvasPoint } from '../../../../core/shared/math-utils' import { canvasPoint, canvasRectangle } from '../../../../core/shared/math-utils' import type { EditorState } from '../../../editor/store/editor-state' -import { deriveState, emptyDerivedState } from '../../../editor/store/editor-state' +import { deriveState } from '../../../editor/store/editor-state' import { patchedCreateRemixDerivedDataMemo } from '../../../editor/store/remix-derived-data' import { foldAndApplyCommands } from '../../commands/commands' import { @@ -202,7 +202,6 @@ function reparentElement( const canvasState = pickCanvasStateFromEditorStateWithMetadata( editorState, - deriveState(editorState, null, 'patched', patchedCreateRemixDerivedDataMemo), createBuiltInDependenciesList(null), startingMetadata, ) @@ -234,7 +233,6 @@ function reparentElement( return foldAndApplyCommands( editorState, - emptyDerivedState(editorState), editorState, [], strategyResult.commands, diff --git a/editor/src/components/canvas/canvas-strategies/strategies/absolute-resize-bounding-box-strategy.spec.tsx b/editor/src/components/canvas/canvas-strategies/strategies/absolute-resize-bounding-box-strategy.spec.tsx index bf6a9629c30c..5288ac38d8b0 100644 --- a/editor/src/components/canvas/canvas-strategies/strategies/absolute-resize-bounding-box-strategy.spec.tsx +++ b/editor/src/components/canvas/canvas-strategies/strategies/absolute-resize-bounding-box-strategy.spec.tsx @@ -17,7 +17,6 @@ import { shiftModifier, } from '../../../../utils/modifiers' import type { AllElementProps, EditorState } from '../../../editor/store/editor-state' -import { emptyDerivedState } from '../../../editor/store/editor-state' import type { EdgePosition } from '../../canvas-types' import { foldAndApplyCommands } from '../../commands/commands' import { @@ -25,14 +24,9 @@ import { makeTestProjectCodeWithSnippet, testPrintCodeFromEditorState, } from '../../ui-jsx.test-utils' -import { - pickCanvasStateFromEditorState, - pickCanvasStateFromEditorStateWithMetadata, -} from '../canvas-strategies' -import { StrategyState } from '../interaction-state' +import { pickCanvasStateFromEditorStateWithMetadata } from '../canvas-strategies' import { createMouseInteractionForTests } from '../interaction-state.test-utils' import { absoluteResizeBoundingBoxStrategy } from './absolute-resize-bounding-box-strategy' -import { defaultCustomStrategyState } from '../canvas-strategy-types' import { createBuiltInDependenciesList } from '../../../../core/es-modules/package-manager/built-in-dependencies-list' function multiselectResizeElements( @@ -59,7 +53,6 @@ function multiselectResizeElements( const strategyResult = absoluteResizeBoundingBoxStrategy( pickCanvasStateFromEditorStateWithMetadata( initialEditor, - emptyDerivedState(initialEditor), createBuiltInDependenciesList(null), metadata, allElementProps, @@ -77,7 +70,6 @@ function multiselectResizeElements( return foldAndApplyCommands( initialEditor, - emptyDerivedState(initialEditor), initialEditor, [], strategyResult.commands, diff --git a/editor/src/components/canvas/canvas-strategies/strategies/convert-to-absolute-and-move-strategy.spec.tsx b/editor/src/components/canvas/canvas-strategies/strategies/convert-to-absolute-and-move-strategy.spec.tsx index cb9077da8631..acc22d8b6336 100644 --- a/editor/src/components/canvas/canvas-strategies/strategies/convert-to-absolute-and-move-strategy.spec.tsx +++ b/editor/src/components/canvas/canvas-strategies/strategies/convert-to-absolute-and-move-strategy.spec.tsx @@ -10,21 +10,16 @@ import { canvasPoint, canvasRectangle } from '../../../../core/shared/math-utils import type { ElementPath } from '../../../../core/shared/project-file-types' import { emptyModifiers } from '../../../../utils/modifiers' import type { EditorState } from '../../../editor/store/editor-state' -import { emptyDerivedState } from '../../../editor/store/editor-state' import { foldAndApplyCommands } from '../../commands/commands' import { getEditorState, makeTestProjectCodeWithSnippet, testPrintCodeFromEditorState, } from '../../ui-jsx.test-utils' -import { - pickCanvasStateFromEditorState, - pickCanvasStateFromEditorStateWithMetadata, -} from '../canvas-strategies' -import { defaultCustomStrategyState } from '../canvas-strategy-types' +import { pickCanvasStateFromEditorStateWithMetadata } from '../canvas-strategies' import { convertToAbsoluteAndMoveStrategy } from './convert-to-absolute-and-move-strategy' import type { InteractionSession } from '../interaction-state' -import { boundingArea, StrategyState } from '../interaction-state' +import { boundingArea } from '../interaction-state' import { createMouseInteractionForTests } from '../interaction-state.test-utils' function prepareEditorState(codeSnippet: string, selectedViews: Array): EditorState { @@ -190,7 +185,6 @@ function dragByPixels( convertToAbsoluteAndMoveStrategy( pickCanvasStateFromEditorStateWithMetadata( editorState, - emptyDerivedState(editorState), createBuiltInDependenciesList(null), metadata, ), @@ -199,7 +193,6 @@ function dragByPixels( const finalEditor = foldAndApplyCommands( editorState, - emptyDerivedState(editorState), editorState, [], strategyResultCommands, diff --git a/editor/src/components/canvas/canvas-strategies/strategies/drag-to-insert-metastrategy.tsx b/editor/src/components/canvas/canvas-strategies/strategies/drag-to-insert-metastrategy.tsx index 71cabe69318a..a7ee0f6feeb8 100644 --- a/editor/src/components/canvas/canvas-strategies/strategies/drag-to-insert-metastrategy.tsx +++ b/editor/src/components/canvas/canvas-strategies/strategies/drag-to-insert-metastrategy.tsx @@ -14,11 +14,7 @@ import { canvasRectangle, offsetPoint, zeroCanvasPoint } from '../../../../core/ import type { ElementPath } from '../../../../core/shared/project-file-types' import { CSSCursor, Utils } from '../../../../uuiui-deps' import type { InsertionSubject } from '../../../editor/editor-modes' -import type { - DerivedState, - EditorState, - EditorStatePatch, -} from '../../../editor/store/editor-state' +import type { EditorState, EditorStatePatch } from '../../../editor/store/editor-state' import { foldAndApplyCommandsInner } from '../../commands/commands' import type { InsertElementInsertionSubject } from '../../commands/insert-element-insertion-subject' import { insertElementInsertionSubject } from '../../commands/insert-element-insertion-subject' @@ -229,12 +225,11 @@ function dragToInsertStrategyFactory( const reparentCommand = updateFunctionCommand( 'always', - (editorState, derivedState, transient): Array => { + (editorState, transient): Array => { return runTargetStrategiesForFreshlyInsertedElement( reparentStrategyToUse, canvasState.builtInDependencies, editorState, - derivedState, customStrategyState, interactionSession, transient, @@ -251,10 +246,9 @@ function dragToInsertStrategyFactory( ? [ updateFunctionCommand( 'always', - (editorState, derivedState, lifecycle): Array => + (editorState, lifecycle): Array => foldAndApplyCommandsInner( editorState, - derivedState, [], [ wrapInContainerCommand( @@ -343,7 +337,6 @@ function runTargetStrategiesForFreshlyInsertedElement( reparentStrategyToUse: CanvasStrategyFactory, builtInDependencies: BuiltInDependencies, editorState: EditorState, - derivedState: DerivedState, customStrategyState: CustomStrategyState, interactionSession: InteractionSession, commandLifecycle: InteractionLifecycle, @@ -387,7 +380,6 @@ function runTargetStrategiesForFreshlyInsertedElement( // so its index amongst its starting siblings isn't relevant. const canvasState = pickCanvasStateFromEditorStateWithMetadata( editorState, - derivedState, builtInDependencies, patchedMetadata, ) @@ -410,12 +402,7 @@ function runTargetStrategiesForFreshlyInsertedElement( } else { const reparentCommands = strategy.apply(strategyLifeCycle).commands - return foldAndApplyCommandsInner( - editorState, - derivedState, - [], - reparentCommands, - commandLifecycle, - ).statePatches + return foldAndApplyCommandsInner(editorState, [], reparentCommands, commandLifecycle) + .statePatches } } diff --git a/editor/src/components/canvas/canvas-strategies/strategies/draw-to-insert-metastrategy.tsx b/editor/src/components/canvas/canvas-strategies/strategies/draw-to-insert-metastrategy.tsx index c85dd2347088..8dec77d65f2c 100644 --- a/editor/src/components/canvas/canvas-strategies/strategies/draw-to-insert-metastrategy.tsx +++ b/editor/src/components/canvas/canvas-strategies/strategies/draw-to-insert-metastrategy.tsx @@ -20,11 +20,7 @@ import { canvasPoint, canvasRectangle } from '../../../../core/shared/math-utils import type { ElementPath } from '../../../../core/shared/project-file-types' import { cmdModifier } from '../../../../utils/modifiers' import type { InsertionSubject } from '../../../editor/editor-modes' -import type { - DerivedState, - EditorState, - EditorStatePatch, -} from '../../../editor/store/editor-state' +import type { EditorState, EditorStatePatch } from '../../../editor/store/editor-state' import type { CanvasCommand } from '../../commands/commands' import { foldAndApplyCommandsInner } from '../../commands/commands' import type { InsertElementInsertionSubject } from '../../commands/insert-element-insertion-subject' @@ -210,12 +206,11 @@ export function drawToInsertStrategyFactory( if (insertionCommand != null) { const reparentCommand = updateFunctionCommand( 'always', - (editorState, derivedState): Array => { + (editorState): Array => { return runTargetStrategiesForFreshlyInsertedElementToReparent( reparentStrategyToUse, canvasState.builtInDependencies, editorState, - derivedState, customStrategyState, interactionSession, insertionSubject, @@ -228,11 +223,10 @@ export function drawToInsertStrategyFactory( const resizeCommand = updateFunctionCommand( 'always', - (editorState, derivedState, commandLifecycle): Array => { + (editorState, commandLifecycle): Array => { return runTargetStrategiesForFreshlyInsertedElementToResize( canvasState.builtInDependencies, editorState, - derivedState, customStrategyState, interactionSession, commandLifecycle, @@ -250,10 +244,9 @@ export function drawToInsertStrategyFactory( ? [ updateFunctionCommand( 'always', - (editorState, derivedState, lifecycle): Array => + (editorState, lifecycle): Array => foldAndApplyCommandsInner( editorState, - derivedState, [], [ wrapInContainerCommand( @@ -299,12 +292,11 @@ export function drawToInsertStrategyFactory( if (insertionCommand != null) { const reparentCommand = updateFunctionCommand( 'always', - (editorState, derivedState): Array => { + (editorState): Array => { return runTargetStrategiesForFreshlyInsertedElementToReparent( reparentStrategyToUse, canvasState.builtInDependencies, editorState, - derivedState, customStrategyState, interactionSession, insertionSubject, @@ -322,10 +314,9 @@ export function drawToInsertStrategyFactory( ? [ updateFunctionCommand( 'always', - (editorState, derivedState, lifecycle): Array => + (editorState, lifecycle): Array => foldAndApplyCommandsInner( editorState, - derivedState, [], [ wrapInContainerCommand( @@ -568,7 +559,6 @@ function runTargetStrategiesForFreshlyInsertedElementToReparent( reparentStrategyToUse: CanvasStrategyFactory, builtInDependencies: BuiltInDependencies, editorState: EditorState, - derivedState: DerivedState, customStrategyState: CustomStrategyState, interactionSession: InteractionSession, insertionSubject: InsertionSubject, @@ -576,7 +566,7 @@ function runTargetStrategiesForFreshlyInsertedElementToReparent( strategyLifecycle: InteractionLifecycle, startingMetadata: ElementInstanceMetadataMap, ): Array { - const canvasState = pickCanvasStateFromEditorState(editorState, derivedState, builtInDependencies) + const canvasState = pickCanvasStateFromEditorState(editorState, builtInDependencies) const rootPath = getRootPath(startingMetadata) if (rootPath == null) { @@ -628,19 +618,13 @@ function runTargetStrategiesForFreshlyInsertedElementToReparent( const reparentCommands = strategy.apply(strategyLifecycle).commands // We only want the commands that are applied at the end of the reparent, as we'll be resizing afterwards - return foldAndApplyCommandsInner( - editorState, - derivedState, - [], - reparentCommands, - 'end-interaction', - ).statePatches + return foldAndApplyCommandsInner(editorState, [], reparentCommands, 'end-interaction') + .statePatches } function runTargetStrategiesForFreshlyInsertedElementToResize( builtInDependencies: BuiltInDependencies, editorState: EditorState, - derivedState: DerivedState, customStrategyState: CustomStrategyState, interactionSession: InteractionSession, commandLifecycle: InteractionLifecycle, @@ -672,7 +656,6 @@ function runTargetStrategiesForFreshlyInsertedElementToResize( // element's index, we will need to update the elementPathTree with the new element and pass it in here. const canvasState = pickCanvasStateFromEditorStateWithMetadata( editorState, - derivedState, builtInDependencies, patchedMetadata, ) @@ -693,6 +676,5 @@ function runTargetStrategiesForFreshlyInsertedElementToResize( const resizeCommands = resizeStrategy != null ? resizeStrategy.strategy.apply(strategyLifecycle).commands : [] - return foldAndApplyCommandsInner(editorState, derivedState, [], resizeCommands, commandLifecycle) - .statePatches + return foldAndApplyCommandsInner(editorState, [], resizeCommands, commandLifecycle).statePatches } diff --git a/editor/src/components/canvas/canvas-strategies/strategies/flex-reparent-to-absolute-strategy.tsx b/editor/src/components/canvas/canvas-strategies/strategies/flex-reparent-to-absolute-strategy.tsx index cbc630c87959..16bcf25ffb40 100644 --- a/editor/src/components/canvas/canvas-strategies/strategies/flex-reparent-to-absolute-strategy.tsx +++ b/editor/src/components/canvas/canvas-strategies/strategies/flex-reparent-to-absolute-strategy.tsx @@ -105,10 +105,9 @@ export function baseFlexReparentToAbsoluteStrategy( ...escapeHatchCommands, updateFunctionCommand( 'always', - (editorState, derivedState, commandLifecycle): Array => { + (editorState, commandLifecycle): Array => { const updatedCanvasState = pickCanvasStateFromEditorState( editorState, - derivedState, canvasState.builtInDependencies, ) const absoluteReparentStrategyToUse = baseAbsoluteReparentStrategy( @@ -125,7 +124,6 @@ export function baseFlexReparentToAbsoluteStrategy( return foldAndApplyCommandsInner( editorState, - derivedState, [], reparentCommands, commandLifecycle, diff --git a/editor/src/components/canvas/canvas-strategies/strategies/keyboard-interaction.test-utils.tsx b/editor/src/components/canvas/canvas-strategies/strategies/keyboard-interaction.test-utils.tsx index 5cdc9dbadcc5..f146ca5fd9a0 100644 --- a/editor/src/components/canvas/canvas-strategies/strategies/keyboard-interaction.test-utils.tsx +++ b/editor/src/components/canvas/canvas-strategies/strategies/keyboard-interaction.test-utils.tsx @@ -11,13 +11,8 @@ import { canvasRectangle } from '../../../../core/shared/math-utils' import type { KeyCharacter } from '../../../../utils/keyboard' import type { Modifiers } from '../../../../utils/modifiers' import type { EditorState } from '../../../editor/store/editor-state' -import { deriveState, emptyDerivedState } from '../../../editor/store/editor-state' -import { patchedCreateRemixDerivedDataMemo } from '../../../editor/store/remix-derived-data' import { foldAndApplyCommands } from '../../commands/commands' -import { - pickCanvasStateFromEditorState, - pickCanvasStateFromEditorStateWithMetadata, -} from '../canvas-strategies' +import { pickCanvasStateFromEditorStateWithMetadata } from '../canvas-strategies' import type { CanvasStrategy, CustomStrategyState, @@ -66,7 +61,6 @@ export function pressKeys( const strategy = strategyFactoryFunction( pickCanvasStateFromEditorStateWithMetadata( editorState, - emptyDerivedState(editorState), createBuiltInDependenciesList(null), metadata, ), @@ -83,11 +77,8 @@ export function pressKeys( expect(strategyResult.customStatePatch).toEqual({}) expect(strategyResult.status).toEqual('success') - const derivedState = deriveState(editorState, null, 'patched', patchedCreateRemixDerivedDataMemo) - const finalEditor = foldAndApplyCommands( editorState, - derivedState, editorState, [], strategyResult.commands, diff --git a/editor/src/components/canvas/commands/add-contain-layout-if-needed-command.ts b/editor/src/components/canvas/commands/add-contain-layout-if-needed-command.ts index 01bb19cd318a..26aee91a329a 100644 --- a/editor/src/components/canvas/commands/add-contain-layout-if-needed-command.ts +++ b/editor/src/components/canvas/commands/add-contain-layout-if-needed-command.ts @@ -4,7 +4,7 @@ import { emptyComments, jsExpressionValue } from '../../../core/shared/element-t import type { ElementPath } from '../../../core/shared/project-file-types' import { PropertyPath } from '../../../core/shared/project-file-types' import * as PP from '../../../core/shared/property-path' -import type { DerivedState, EditorState } from '../../editor/store/editor-state' +import type { EditorState } from '../../editor/store/editor-state' import { applyValuesAtPath } from './adjust-number-command' import type { BaseCommand, CommandFunction, WhenToRun } from './commands' @@ -26,7 +26,6 @@ export function addContainLayoutIfNeeded( export const runAddContainLayoutIfNeeded: CommandFunction = ( editorState: EditorState, - _derivedState: DerivedState, command: AddContainLayoutIfNeeded, ) => { const elementMetadata = MetadataUtils.findElementByElementPath( diff --git a/editor/src/components/canvas/commands/add-element-command.ts b/editor/src/components/canvas/commands/add-element-command.ts index 505cc589e95f..56986b1bf5ec 100644 --- a/editor/src/components/canvas/commands/add-element-command.ts +++ b/editor/src/components/canvas/commands/add-element-command.ts @@ -3,11 +3,7 @@ import { getElementPathFromInsertionPath, insertionPathToString, } from '../../editor/store/insertion-path' -import type { - DerivedState, - EditorState, - EditorStatePatch, -} from '../../../components/editor/store/editor-state' +import type { EditorState, EditorStatePatch } from '../../../components/editor/store/editor-state' import { forUnderlyingTargetFromEditorState } from '../../../components/editor/store/editor-state' import { getUtopiaJSXComponentsFromSuccess } from '../../../core/model/project-file-utils' import type { JSXElementChild } from '../../../core/shared/element-template' @@ -48,7 +44,6 @@ export function addElement( export const runAddElement: CommandFunction = ( editorState: EditorState, - _derivedState: DerivedState, command: AddElement, ) => { let editorStatePatches: Array = [] diff --git a/editor/src/components/canvas/commands/add-elements-command.ts b/editor/src/components/canvas/commands/add-elements-command.ts index 8b46024ba517..3443f7c3d9ae 100644 --- a/editor/src/components/canvas/commands/add-elements-command.ts +++ b/editor/src/components/canvas/commands/add-elements-command.ts @@ -3,11 +3,7 @@ import { getElementPathFromInsertionPath, insertionPathToString, } from '../../editor/store/insertion-path' -import type { - DerivedState, - EditorState, - EditorStatePatch, -} from '../../../components/editor/store/editor-state' +import type { EditorState, EditorStatePatch } from '../../../components/editor/store/editor-state' import { forUnderlyingTargetFromEditorState } from '../../../components/editor/store/editor-state' import { getUtopiaJSXComponentsFromSuccess } from '../../../core/model/project-file-utils' import type { JSXElementChild } from '../../../core/shared/element-template' @@ -49,7 +45,6 @@ export function addElements( export const runAddElements: CommandFunction = ( editorState: EditorState, - _derivedState: DerivedState, command: AddElements, ) => { let editorStatePatches: Array = [] diff --git a/editor/src/components/canvas/commands/add-imports-to-file-command.ts b/editor/src/components/canvas/commands/add-imports-to-file-command.ts index 6f8332a26954..d17295ba4243 100644 --- a/editor/src/components/canvas/commands/add-imports-to-file-command.ts +++ b/editor/src/components/canvas/commands/add-imports-to-file-command.ts @@ -1,5 +1,5 @@ import { mergeImports } from '../../../core/workers/common/project-file-utils' -import type { DerivedState, EditorState } from '../../../components/editor/store/editor-state' +import type { EditorState } from '../../../components/editor/store/editor-state' import type { Imports } from '../../../core/shared/project-file-types' import type { BaseCommand, WhenToRun, CommandFunction, CommandFunctionResult } from './commands' import { patchParseSuccessAtFilePath } from './patch-utils' @@ -25,7 +25,6 @@ export function addImportsToFile( export const runAddImportsToFile: CommandFunction = ( editorState: EditorState, - derivedState: DerivedState, command: AddImportsToFile, ): CommandFunctionResult => { const editorStatePatch = patchParseSuccessAtFilePath( diff --git a/editor/src/components/canvas/commands/add-to-reparented-to-paths-command.ts b/editor/src/components/canvas/commands/add-to-reparented-to-paths-command.ts index 4d082f1a824f..cc3c9d1d378b 100644 --- a/editor/src/components/canvas/commands/add-to-reparented-to-paths-command.ts +++ b/editor/src/components/canvas/commands/add-to-reparented-to-paths-command.ts @@ -1,5 +1,5 @@ import type { Spec } from 'immutability-helper' -import type { DerivedState, EditorState } from '../../editor/store/editor-state' +import type { EditorState } from '../../editor/store/editor-state' import type { ElementPath } from '../../../core/shared/project-file-types' import type { BaseCommand, CommandFunction, CommandFunctionResult, WhenToRun } from './commands' @@ -21,7 +21,6 @@ export function addToReparentedToPaths( export const runAddToReparentedToPaths: CommandFunction = ( editorState: EditorState, - __: DerivedState, command: AddToReparentedToPaths, ): CommandFunctionResult => { const editorStatePatch: Spec = { diff --git a/editor/src/components/canvas/commands/adjust-css-length-command.ts b/editor/src/components/canvas/commands/adjust-css-length-command.ts index 465eadf83955..6d2e547c3c09 100644 --- a/editor/src/components/canvas/commands/adjust-css-length-command.ts +++ b/editor/src/components/canvas/commands/adjust-css-length-command.ts @@ -18,9 +18,8 @@ import { import { roundTo } from '../../../core/shared/math-utils' import type { ElementPath, PropertyPath } from '../../../core/shared/project-file-types' import * as PP from '../../../core/shared/property-path' -import type { DerivedState, EditorState } from '../../editor/store/editor-state' -import { deriveState, modifyUnderlyingForOpenFile } from '../../editor/store/editor-state' -import { patchedCreateRemixDerivedDataMemo } from '../../editor/store/remix-derived-data' +import type { EditorState } from '../../editor/store/editor-state' +import { modifyUnderlyingForOpenFile } from '../../editor/store/editor-state' import type { CSSNumber, FlexDirection } from '../../inspector/common/css-utils' import { parseCSSPercent, parseCSSPx, printCSSNumber } from '../../inspector/common/css-utils' import type { BaseCommand, CommandFunction, WhenToRun } from './commands' @@ -79,7 +78,6 @@ interface UpdatedPropsAndCommandDescription { export const runAdjustCssLengthProperties: CommandFunction = ( editorState: EditorState, - _derivedState: DerivedState, command: AdjustCssLengthProperties, ) => { let commandDescriptions: Array = [] diff --git a/editor/src/components/canvas/commands/adjust-number-command.spec.tsx b/editor/src/components/canvas/commands/adjust-number-command.spec.tsx index bb4024924131..41ac2e58d9f5 100644 --- a/editor/src/components/canvas/commands/adjust-number-command.spec.tsx +++ b/editor/src/components/canvas/commands/adjust-number-command.spec.tsx @@ -60,7 +60,6 @@ describe('adjustNumberProperty', () => { const result = runAdjustNumberProperty( renderResult.getEditorState().editor, - renderResult.getEditorState().derived, adjustNumberPropertyCommand, ) @@ -116,7 +115,6 @@ describe('adjustNumberProperty', () => { const result = runAdjustNumberProperty( renderResult.getEditorState().editor, - renderResult.getEditorState().derived, adjustNumberPropertyCommand, ) diff --git a/editor/src/components/canvas/commands/adjust-number-command.ts b/editor/src/components/canvas/commands/adjust-number-command.ts index d29f98895a9a..6750b8a0b328 100644 --- a/editor/src/components/canvas/commands/adjust-number-command.ts +++ b/editor/src/components/canvas/commands/adjust-number-command.ts @@ -13,15 +13,13 @@ import { } from '../../../core/shared/jsx-attributes' import type { ElementPath, PropertyPath } from '../../../core/shared/project-file-types' import * as PP from '../../../core/shared/property-path' -import type { DerivedState, EditorState, EditorStatePatch } from '../../editor/store/editor-state' +import type { EditorState, EditorStatePatch } from '../../editor/store/editor-state' import { - deriveState, modifyUnderlyingElementForOpenFile, withUnderlyingTargetFromEditorState, } from '../../editor/store/editor-state' import type { BaseCommand, CommandFunction, WhenToRun } from './commands' import { patchParseSuccessAtElementPath } from './patch-utils' -import { patchedCreateRemixDerivedDataMemo } from '../../editor/store/remix-derived-data' export interface AdjustNumberProperty extends BaseCommand { type: 'ADJUST_NUMBER_PROPERTY' @@ -67,7 +65,6 @@ export function adjustNumberInequalityCondition( export const runAdjustNumberProperty: CommandFunction = ( editorState: EditorState, - derivedState: DerivedState, command: AdjustNumberProperty, ) => { // Handle updating the existing value, treating a value that can't be parsed diff --git a/editor/src/components/canvas/commands/commands.ts b/editor/src/components/canvas/commands/commands.ts index 7b32af337005..889bf9536c69 100644 --- a/editor/src/components/canvas/commands/commands.ts +++ b/editor/src/components/canvas/commands/commands.ts @@ -2,8 +2,7 @@ import update from 'immutability-helper' import { applyUtopiaJSXComponentsChanges } from '../../../core/model/project-file-utils' import type { TopLevelElement, UtopiaJSXComponent } from '../../../core/shared/element-template' import type { Imports } from '../../../core/shared/project-file-types' -import type { DerivedState, EditorState, EditorStatePatch } from '../../editor/store/editor-state' -import { deriveState } from '../../editor/store/editor-state' +import type { EditorState, EditorStatePatch } from '../../editor/store/editor-state' import type { CommandDescription } from '../canvas-strategies/interaction-state' import type { AdjustCssLengthProperties } from './adjust-css-length-command' import { runAdjustCssLengthProperties } from './adjust-css-length-command' @@ -84,18 +83,13 @@ import type { AddElements } from './add-elements-command' import { runAddElements } from './add-elements-command' import type { QueueGroupTrueUp } from './queue-group-true-up-command' import { runQueueGroupTrueUp } from './queue-group-true-up-command' -import { patchedCreateRemixDerivedDataMemo } from '../../editor/store/remix-derived-data' export interface CommandFunctionResult { editorStatePatches: Array commandDescription: string } -export type CommandFunction = ( - editorState: EditorState, - derivedState: DerivedState, - command: T, -) => CommandFunctionResult +export type CommandFunction = (editorState: EditorState, command: T) => CommandFunctionResult export type WhenToRun = 'mid-interaction' | 'always' | 'on-complete' @@ -143,88 +137,82 @@ export type CanvasCommand = export function runCanvasCommand( editorState: EditorState, - derivedState: DerivedState, command: CanvasCommand, commandLifecycle: InteractionLifecycle, ): CommandFunctionResult { switch (command.type) { case 'WILDCARD_PATCH': - return runWildcardPatch(editorState, derivedState, command) + return runWildcardPatch(editorState, command) case 'UPDATE_FUNCTION_COMMAND': - return runUpdateFunctionCommand(editorState, derivedState, command, commandLifecycle) + return runUpdateFunctionCommand(editorState, command, commandLifecycle) case 'STRATEGY_SWITCHED': return runStrategySwitchedCommand(command) case 'ADJUST_NUMBER_PROPERTY': - return runAdjustNumberProperty(editorState, derivedState, command) + return runAdjustNumberProperty(editorState, command) case 'ADJUST_CSS_LENGTH_PROPERTY': - return runAdjustCssLengthProperties(editorState, derivedState, command) + return runAdjustCssLengthProperties(editorState, command) case 'REPARENT_ELEMENT': - return runReparentElement(editorState, derivedState, command) + return runReparentElement(editorState, command) case 'DUPLICATE_ELEMENT': - return runDuplicateElement(editorState, derivedState, command) + return runDuplicateElement(editorState, command) case 'UPDATE_SELECTED_VIEWS': - return runUpdateSelectedViews(editorState, derivedState, command) + return runUpdateSelectedViews(editorState, command) case 'UPDATE_HIGHLIGHTED_VIEWS': - return runUpdateHighlightedViews(editorState, derivedState, command) + return runUpdateHighlightedViews(editorState, command) case 'SET_SNAPPING_GUIDELINES': - return runSetSnappingGuidelines(editorState, derivedState, command) + return runSetSnappingGuidelines(editorState, command) case 'CONVERT_TO_ABSOLUTE': - return runConvertToAbsolute(editorState, derivedState, command) + return runConvertToAbsolute(editorState, command) case 'SET_CSS_LENGTH_PROPERTY': - return runSetCssLengthProperty(editorState, derivedState, command) + return runSetCssLengthProperty(editorState, command) case 'REORDER_ELEMENT': - return runReorderElement(editorState, derivedState, command) + return runReorderElement(editorState, command) case 'SHOW_OUTLINE_HIGHLIGHT': - return runShowOutlineHighlight(editorState, derivedState, command) + return runShowOutlineHighlight(editorState, command) case 'SHOW_REORDER_INDICATOR': - return runShowReorderIndicator(editorState, derivedState, command) + return runShowReorderIndicator(editorState, command) case 'SET_CURSOR_COMMAND': - return runSetCursor(editorState, derivedState, command) + return runSetCursor(editorState, command) case 'SET_ELEMENTS_TO_RERENDER_COMMAND': - return runSetElementsToRerender(editorState, derivedState, command) + return runSetElementsToRerender(editorState, command) case 'APPEND_ELEMENTS_TO_RERENDER_COMMAND': - return runAppendElementsToRerender(editorState, derivedState, command) + return runAppendElementsToRerender(editorState, command) case 'PUSH_INTENDED_BOUNDS_AND_UPDATE_GROUPS': - return runPushIntendedBoundsAndUpdateGroups( - editorState, - derivedState, - command, - commandLifecycle, - ) + return runPushIntendedBoundsAndUpdateGroups(editorState, command, commandLifecycle) case 'DELETE_PROPERTIES': - return runDeleteProperties(editorState, derivedState, command) + return runDeleteProperties(editorState, command) case 'SET_PROPERTY': - return runSetProperty(editorState, derivedState, command) + return runSetProperty(editorState, command) case 'UPDATE_PROP_IF_EXISTS': - return runUpdatePropIfExists(editorState, derivedState, command) + return runUpdatePropIfExists(editorState, command) case 'ADD_IMPORTS_TO_FILE': - return runAddImportsToFile(editorState, derivedState, command) + return runAddImportsToFile(editorState, command) case 'ADD_TO_REPARENTED_TO_PATHS': - return runAddToReparentedToPaths(editorState, derivedState, command) + return runAddToReparentedToPaths(editorState, command) case 'INSERT_ELEMENT_INSERTION_SUBJECT': - return runInsertElementInsertionSubject(editorState, derivedState, command) + return runInsertElementInsertionSubject(editorState, command) case 'ADD_ELEMENT': - return runAddElement(editorState, derivedState, command) + return runAddElement(editorState, command) case 'ADD_ELEMENTS': - return runAddElements(editorState, derivedState, command) + return runAddElements(editorState, command) case 'HIGHLIGHT_ELEMENTS_COMMAND': - return runHighlightElementsCommand(editorState, derivedState, command) + return runHighlightElementsCommand(editorState, command) case 'CONVERT_CSS_PERCENT_TO_PX': - return runConvertCssPercentToPx(editorState, derivedState, command) + return runConvertCssPercentToPx(editorState, command) case 'HIDE_IN_NAVIGATOR_COMMAND': - return runHideInNavigatorCommand(editorState, derivedState, command) + return runHideInNavigatorCommand(editorState, command) case 'SHOW_TOAST_COMMAND': return runShowToastCommand(editorState, command, commandLifecycle) case 'ADD_CONTAIN_LAYOUT_IF_NEEDED': - return runAddContainLayoutIfNeeded(editorState, derivedState, command) + return runAddContainLayoutIfNeeded(editorState, command) case 'REARRANGE_CHILDREN': - return runRearrangeChildren(editorState, derivedState, command) + return runRearrangeChildren(editorState, command) case 'DELETE_ELEMENT': - return runDeleteElement(editorState, derivedState, command) + return runDeleteElement(editorState, command) case 'WRAP_IN_CONTAINER': - return runWrapInContainerCommand(editorState, derivedState, command) + return runWrapInContainerCommand(editorState, command) case 'QUEUE_GROUP_TRUE_UP': - return runQueueGroupTrueUp(editorState, derivedState, command) + return runQueueGroupTrueUp(editorState, command) default: const _exhaustiveCheck: never = command throw new Error(`Unhandled canvas command ${JSON.stringify(command)}`) @@ -233,13 +221,12 @@ export function runCanvasCommand( export function foldAndApplyCommandsSimple( editorState: EditorState, - derivedState: DerivedState, commands: Array, ): EditorState { const updatedEditorState = commands .filter((c) => c.whenToRun === 'always' || c.whenToRun === 'on-complete') .reduce((workingEditorState, command) => { - const patches = runCanvasCommand(workingEditorState, derivedState, command, 'end-interaction') + const patches = runCanvasCommand(workingEditorState, command, 'end-interaction') return updateEditorStateWithPatches(workingEditorState, patches.editorStatePatches) }, editorState) @@ -248,7 +235,6 @@ export function foldAndApplyCommandsSimple( export function foldAndApplyCommandsInner( editorState: EditorState, - derivedState: DerivedState, commandsToAccumulate: Array, commands: Array, commandLifecycle: InteractionLifecycle, @@ -259,7 +245,6 @@ export function foldAndApplyCommandsInner( } { let statePatches: Array = [] let workingEditorState: EditorState = editorState - let workingDerivedState: DerivedState = derivedState let workingCommandDescriptions: Array = [] function runCommand(command: CanvasCommand, shouldAccumulatePatches: boolean): void { @@ -272,12 +257,7 @@ export function foldAndApplyCommandsInner( if (shouldRunCommand) { // Run the command with our current states. - const commandResult = runCanvasCommand( - workingEditorState, - workingDerivedState, - command, - commandLifecycle, - ) + const commandResult = runCanvasCommand(workingEditorState, command, commandLifecycle) // Capture values from the result. const statePatch = commandResult.editorStatePatches // Apply the update to the editor state. @@ -288,12 +268,6 @@ export function foldAndApplyCommandsInner( description: commandResult.commandDescription, transient: command.whenToRun === 'mid-interaction', }) - workingDerivedState = deriveState( - workingEditorState, - workingDerivedState, - 'patched', - patchedCreateRemixDerivedDataMemo, - ) } } @@ -309,7 +283,6 @@ export function foldAndApplyCommandsInner( export function foldAndApplyCommands( editorState: EditorState, - derivedState: DerivedState, priorPatchedState: EditorState, commandsToAccumulate: Array, commands: Array, @@ -320,7 +293,6 @@ export function foldAndApplyCommands( } { const { statePatches, updatedEditorState, commandDescriptions } = foldAndApplyCommandsInner( editorState, - derivedState, commandsToAccumulate, commands, commandLifecycle, diff --git a/editor/src/components/canvas/commands/convert-css-percent-to-px-command.ts b/editor/src/components/canvas/commands/convert-css-percent-to-px-command.ts index 08ab718f1a3c..0310405cc418 100644 --- a/editor/src/components/canvas/commands/convert-css-percent-to-px-command.ts +++ b/editor/src/components/canvas/commands/convert-css-percent-to-px-command.ts @@ -12,7 +12,7 @@ import { } from '../../../core/shared/jsx-attributes' import type { ElementPath, PropertyPath } from '../../../core/shared/project-file-types' import * as PP from '../../../core/shared/property-path' -import type { DerivedState, EditorState } from '../../editor/store/editor-state' +import type { EditorState } from '../../editor/store/editor-state' import { withUnderlyingTargetFromEditorState } from '../../editor/store/editor-state' import type { CSSNumber } from '../../inspector/common/css-utils' import { parseCSSPercent, printCSSNumber } from '../../inspector/common/css-utils' @@ -43,7 +43,6 @@ export function convertCssPercentToPx( export const runConvertCssPercentToPx: CommandFunction = ( editorState: EditorState, - _derivedState: DerivedState, command: ConvertCssPercentToPx, ) => { // Identify the current value, whatever that may be. diff --git a/editor/src/components/canvas/commands/convert-to-absolute-command.spec.tsx b/editor/src/components/canvas/commands/convert-to-absolute-command.spec.tsx index 3b2a7b7b646b..4c24fc45017b 100644 --- a/editor/src/components/canvas/commands/convert-to-absolute-command.spec.tsx +++ b/editor/src/components/canvas/commands/convert-to-absolute-command.spec.tsx @@ -30,7 +30,6 @@ describe('convertToAbsolute', () => { const convertToAbsoluteCommand = convertToAbsolute('always', appInstancePath) const result = runConvertToAbsolute( renderResult.getEditorState().editor, - renderResult.getEditorState().derived, convertToAbsoluteCommand, ) diff --git a/editor/src/components/canvas/commands/convert-to-absolute-command.ts b/editor/src/components/canvas/commands/convert-to-absolute-command.ts index bad5c12ba983..7ecb5b1726ab 100644 --- a/editor/src/components/canvas/commands/convert-to-absolute-command.ts +++ b/editor/src/components/canvas/commands/convert-to-absolute-command.ts @@ -5,7 +5,7 @@ import type { ElementInstanceMetadataMap } from '../../../core/shared/element-te import { emptyComments, jsExpressionValue } from '../../../core/shared/element-template' import type { ValueAtPath } from '../../../core/shared/jsx-attributes' import type { ElementPath } from '../../../core/shared/project-file-types' -import type { DerivedState, EditorState, EditorStatePatch } from '../../editor/store/editor-state' +import type { EditorState, EditorStatePatch } from '../../editor/store/editor-state' import { stylePropPathMappingFn } from '../../inspector/common/property-path-hooks' import { applyValuesAtPath } from './adjust-number-command' import type { BaseCommand, CommandFunction, WhenToRun } from './commands' @@ -25,7 +25,6 @@ export function convertToAbsolute(transient: WhenToRun, target: ElementPath): Co export const runConvertToAbsolute: CommandFunction = ( editorState: EditorState, - _derivedState: DerivedState, command: ConvertToAbsolute, ) => { const propsToUpdate: Array = [ diff --git a/editor/src/components/canvas/commands/delete-element-command.ts b/editor/src/components/canvas/commands/delete-element-command.ts index 0667f6dbede4..00ff05e5098e 100644 --- a/editor/src/components/canvas/commands/delete-element-command.ts +++ b/editor/src/components/canvas/commands/delete-element-command.ts @@ -1,7 +1,7 @@ import { getUtopiaJSXComponentsFromSuccess } from '../../../core/model/project-file-utils' import * as EP from '../../../core/shared/element-path' import type { ElementPath } from '../../../core/shared/project-file-types' -import type { DerivedState, EditorState, EditorStatePatch } from '../../editor/store/editor-state' +import type { EditorState, EditorStatePatch } from '../../editor/store/editor-state' import { forUnderlyingTargetFromEditorState, removeElementAtPath, @@ -25,7 +25,6 @@ export function deleteElement(whenToRun: WhenToRun, target: ElementPath): Delete export const runDeleteElement: CommandFunction = ( editorState: EditorState, - _derivedState: DerivedState, command: DeleteElement, ) => { let editorStatePatches: Array = [] diff --git a/editor/src/components/canvas/commands/delete-properties-command.ts b/editor/src/components/canvas/commands/delete-properties-command.ts index 26c16647982b..f1d8501385b3 100644 --- a/editor/src/components/canvas/commands/delete-properties-command.ts +++ b/editor/src/components/canvas/commands/delete-properties-command.ts @@ -1,9 +1,5 @@ import type { JSXElement } from '../../../core/shared/element-template' -import type { - DerivedState, - EditorState, - EditorStatePatch, -} from '../../../components/editor/store/editor-state' +import type { EditorState, EditorStatePatch } from '../../../components/editor/store/editor-state' import { modifyUnderlyingElementForOpenFile } from '../../../components/editor/store/editor-state' import { foldEither } from '../../../core/shared/either' import { unsetJSXValuesAtPaths } from '../../../core/shared/jsx-attributes' @@ -34,7 +30,6 @@ export function deleteProperties( export const runDeleteProperties: CommandFunction = ( editorState: EditorState, - _derivedState: DerivedState, command: DeleteProperties, ) => { // Apply the update to the properties. diff --git a/editor/src/components/canvas/commands/duplicate-element-command.spec.tsx b/editor/src/components/canvas/commands/duplicate-element-command.spec.tsx index 5cf242d189db..e352f82d9469 100644 --- a/editor/src/components/canvas/commands/duplicate-element-command.spec.tsx +++ b/editor/src/components/canvas/commands/duplicate-element-command.spec.tsx @@ -1,10 +1,7 @@ import { createBuiltInDependenciesList } from '../../../core/es-modules/package-manager/built-in-dependencies-list' import * as EP from '../../../core/shared/element-path' import { complexDefaultProjectPreParsed } from '../../../sample-projects/sample-project-utils.test-utils' -import { - emptyDerivedState, - withUnderlyingTargetFromEditorState, -} from '../../editor/store/editor-state' +import { withUnderlyingTargetFromEditorState } from '../../editor/store/editor-state' import { DefaultStartingFeatureSwitches, makeTestProjectCodeWithSnippet, @@ -36,11 +33,7 @@ describe('runDuplicateElement', () => { const duplicateCommand = duplicateElement('always', targetPath, newUid) - const result = runDuplicateElement( - originalEditorState, - emptyDerivedState(originalEditorState), - duplicateCommand, - ) + const result = runDuplicateElement(originalEditorState, duplicateCommand) const patchedEditor = updateEditorStateWithPatches( originalEditorState, @@ -77,11 +70,7 @@ describe('runDuplicateElement', () => { const duplicateCommand = duplicateElement('always', targetPath, newUid) - const result = runDuplicateElement( - originalEditorState, - emptyDerivedState(originalEditorState), - duplicateCommand, - ) + const result = runDuplicateElement(originalEditorState, duplicateCommand) const patchedEditor = updateEditorStateWithPatches( originalEditorState, @@ -150,11 +139,7 @@ describe('runDuplicateElement', () => { const duplicateCommand = duplicateElement('always', targetPath, newUid) - const result = runDuplicateElement( - originalEditorState, - emptyDerivedState(originalEditorState), - duplicateCommand, - ) + const result = runDuplicateElement(originalEditorState, duplicateCommand) const patchedEditor = updateEditorStateWithPatches( originalEditorState, diff --git a/editor/src/components/canvas/commands/duplicate-element-command.ts b/editor/src/components/canvas/commands/duplicate-element-command.ts index 658f1243b142..b4c6ec0a8ad4 100644 --- a/editor/src/components/canvas/commands/duplicate-element-command.ts +++ b/editor/src/components/canvas/commands/duplicate-element-command.ts @@ -1,7 +1,7 @@ import * as EP from '../../../core/shared/element-path' import { isUtopiaJSXComponent } from '../../../core/shared/element-template' import type { ElementPath } from '../../../core/shared/project-file-types' -import type { DerivedState, EditorState, EditorStatePatch } from '../../editor/store/editor-state' +import type { EditorState, EditorStatePatch } from '../../editor/store/editor-state' import { withUnderlyingTargetFromEditorState } from '../../editor/store/editor-state' import { duplicate } from '../canvas-utils' import type { BaseCommand, CommandFunction, WhenToRun } from './commands' @@ -33,7 +33,6 @@ export function duplicateElement( export const runDuplicateElement: CommandFunction = ( editorState: EditorState, - _derivedState: DerivedState, command: DuplicateElement, ) => { const targetParent = EP.parentPath(command.target) diff --git a/editor/src/components/canvas/commands/hide-in-navigator-command.ts b/editor/src/components/canvas/commands/hide-in-navigator-command.ts index a63d15a06dd9..8e94e821b431 100644 --- a/editor/src/components/canvas/commands/hide-in-navigator-command.ts +++ b/editor/src/components/canvas/commands/hide-in-navigator-command.ts @@ -1,6 +1,6 @@ import * as EP from '../../../core/shared/element-path' import type { ElementPath } from '../../../core/shared/project-file-types' -import type { DerivedState, EditorState, EditorStatePatch } from '../../editor/store/editor-state' +import type { EditorState, EditorStatePatch } from '../../editor/store/editor-state' import type { BaseCommand, CommandFunction } from './commands' export interface HideInNavigatorCommand extends BaseCommand { @@ -17,8 +17,7 @@ export function hideInNavigatorCommand(elements: Array): HideInNavi } export const runHideInNavigatorCommand: CommandFunction = ( - editor: EditorState, - __: DerivedState, + _editor: EditorState, command: HideInNavigatorCommand, ) => { const editorStatePatch: EditorStatePatch = { diff --git a/editor/src/components/canvas/commands/highlight-element-command.ts b/editor/src/components/canvas/commands/highlight-element-command.ts index cd38a8b46d70..87ad87bba110 100644 --- a/editor/src/components/canvas/commands/highlight-element-command.ts +++ b/editor/src/components/canvas/commands/highlight-element-command.ts @@ -1,6 +1,6 @@ import * as EP from '../../../core/shared/element-path' import type { ElementPath } from '../../../core/shared/project-file-types' -import type { DerivedState, EditorState, EditorStatePatch } from '../../editor/store/editor-state' +import type { EditorState, EditorStatePatch } from '../../editor/store/editor-state' import type { BaseCommand, CommandFunction } from './commands' export interface HighlightElementsCommand extends BaseCommand { @@ -18,7 +18,6 @@ export function highlightElementsCommand(value: ElementPath[]): HighlightElement export const runHighlightElementsCommand: CommandFunction = ( _: EditorState, - __: DerivedState, command: HighlightElementsCommand, ) => { const editorStatePatch: EditorStatePatch = { diff --git a/editor/src/components/canvas/commands/insert-element-insertion-subject.ts b/editor/src/components/canvas/commands/insert-element-insertion-subject.ts index e4d3b01b1e1b..4e2c511e0986 100644 --- a/editor/src/components/canvas/commands/insert-element-insertion-subject.ts +++ b/editor/src/components/canvas/commands/insert-element-insertion-subject.ts @@ -6,7 +6,7 @@ import { optionalMap } from '../../../core/shared/optional-utils' import type { ElementPath } from '../../../core/shared/project-file-types' import { mergeImports } from '../../../core/workers/common/project-file-utils' import type { InsertionSubject } from '../../editor/editor-modes' -import type { DerivedState, EditorState, EditorStatePatch } from '../../editor/store/editor-state' +import type { EditorState, EditorStatePatch } from '../../editor/store/editor-state' import { forUnderlyingTargetFromEditorState } from '../../editor/store/editor-state' import type { InsertionPath } from '../../editor/store/insertion-path' import type { BaseCommand, CommandFunction, WhenToRun } from './commands' @@ -33,7 +33,6 @@ export function insertElementInsertionSubject( export const runInsertElementInsertionSubject: CommandFunction = ( editor: EditorState, - _derivedState: DerivedState, command: InsertElementInsertionSubject, ) => { let editorStatePatches: Array = [] diff --git a/editor/src/components/canvas/commands/patch-utils.ts b/editor/src/components/canvas/commands/patch-utils.ts index 28e4f1521f5a..7c9704a239b8 100644 --- a/editor/src/components/canvas/commands/patch-utils.ts +++ b/editor/src/components/canvas/commands/patch-utils.ts @@ -4,9 +4,8 @@ import type { ProjectContentsTree, ProjectContentTreeRoot } from '../../../compo import { getProjectFileByFilePath, getProjectContentKeyPathElements, - ProjectContentFile, } from '../../../components/assets' -import type { DerivedState, EditorState } from '../../editor/store/editor-state' +import type { EditorState } from '../../editor/store/editor-state' import { withUnderlyingTargetFromEditorState } from '../../editor/store/editor-state' import type { ElementPath, diff --git a/editor/src/components/canvas/commands/push-intended-bounds-and-update-groups-command.ts b/editor/src/components/canvas/commands/push-intended-bounds-and-update-groups-command.ts index 1d8f74c71492..b4ea81e780d3 100644 --- a/editor/src/components/canvas/commands/push-intended-bounds-and-update-groups-command.ts +++ b/editor/src/components/canvas/commands/push-intended-bounds-and-update-groups-command.ts @@ -17,12 +17,10 @@ import type { ElementPath } from '../../../core/shared/project-file-types' import * as PP from '../../../core/shared/property-path' import type { AllElementProps, - DerivedState, EditorState, EditorStatePatch, } from '../../editor/store/editor-state' -import { deriveState, trueUpElementChanged } from '../../editor/store/editor-state' -import { patchedCreateRemixDerivedDataMemo } from '../../editor/store/remix-derived-data' +import { trueUpElementChanged } from '../../editor/store/editor-state' import { cssPixelLength, type FlexDirection } from '../../inspector/common/css-utils' import { isHugFromStyleAttribute, @@ -73,28 +71,19 @@ export function pushIntendedBoundsAndUpdateGroups( export const runPushIntendedBoundsAndUpdateGroups = ( editor: EditorState, - derivedState: DerivedState, command: PushIntendedBoundsAndUpdateGroups, commandLifecycle: InteractionLifecycle, ): CommandFunctionResult => { const commandRanBecauseOfQueuedTrueUp = command.isStartingMetadata === 'live-metadata' const { updatedEditor: editorAfterResizingGroupChildren, resizedGroupChildren } = - getUpdateResizedGroupChildrenCommands(editor, derivedState, command) - - const derivedStateAfterResizingGroupChildren = deriveState( - editorAfterResizingGroupChildren, - derivedState, - 'patched', - patchedCreateRemixDerivedDataMemo, - ) + getUpdateResizedGroupChildrenCommands(editor, command) const { updatedEditor: editorAfterResizingAncestors, intendedBounds: resizeAncestorsIntendedBounds, } = getResizeAncestorGroupsCommands( editorAfterResizingGroupChildren, - derivedStateAfterResizingGroupChildren, command, commandRanBecauseOfQueuedTrueUp ? 'do-not-create-if-doesnt-exist' @@ -167,7 +156,6 @@ function rectangleFromChildrenBounds( function getUpdateResizedGroupChildrenCommands( editor: EditorState, - derivedState: DerivedState, command: PushIntendedBoundsAndUpdateGroups, ): { updatedEditor: EditorState; resizedGroupChildren: Array } { const targets: Array<{ @@ -314,7 +302,7 @@ function getUpdateResizedGroupChildrenCommands( ) }) - const updatedEditor = foldAndApplyCommandsSimple(editor, derivedState, commandsToRun) + const updatedEditor = foldAndApplyCommandsSimple(editor, commandsToRun) return { updatedEditor: updatedEditor, resizedGroupChildren: updatedElements, @@ -323,7 +311,6 @@ function getUpdateResizedGroupChildrenCommands( function getResizeAncestorGroupsCommands( editor: EditorState, - derivedState: DerivedState, command: PushIntendedBoundsAndUpdateGroups, addGroupSizeIfNonExistant: CreateIfNotExistant, ): { updatedEditor: EditorState; intendedBounds: Array } { @@ -440,7 +427,7 @@ function getResizeAncestorGroupsCommands( } }) - const updatedEditor = foldAndApplyCommandsSimple(editor, derivedState, commandsToRun) + const updatedEditor = foldAndApplyCommandsSimple(editor, commandsToRun) return { updatedEditor: updatedEditor, intendedBounds: Object.values(updatedGlobalFrames).filter(isNotNull), diff --git a/editor/src/components/canvas/commands/queue-group-true-up-command.ts b/editor/src/components/canvas/commands/queue-group-true-up-command.ts index 27e8a0e80769..0da8d7132aa2 100644 --- a/editor/src/components/canvas/commands/queue-group-true-up-command.ts +++ b/editor/src/components/canvas/commands/queue-group-true-up-command.ts @@ -4,12 +4,7 @@ import type { ElementInstanceMetadataMap } from '../../../core/shared/element-te import { MetadataUtils } from '../../../core/model/element-metadata-utils' import * as EP from '../../../core/shared/element-path' import type { ElementPath } from '../../../core/shared/project-file-types' -import type { - AllElementProps, - DerivedState, - EditorState, - TrueUpTarget, -} from '../../editor/store/editor-state' +import type { AllElementProps, EditorState, TrueUpTarget } from '../../editor/store/editor-state' import { trueUpElementChanged } from '../../editor/store/editor-state' import { allowGroupTrueUp } from '../canvas-strategies/strategies/group-helpers' import type { BaseCommand, CommandFunction } from './commands' @@ -30,7 +25,6 @@ export function queueGroupTrueUp(targets: Array): QueueGroupTrueUp export const runQueueGroupTrueUp: CommandFunction = ( editorState: EditorState, - __: DerivedState, command: QueueGroupTrueUp, ) => { return { diff --git a/editor/src/components/canvas/commands/rearrange-children-command.ts b/editor/src/components/canvas/commands/rearrange-children-command.ts index 0a259d289e4d..6d50743a3d81 100644 --- a/editor/src/components/canvas/commands/rearrange-children-command.ts +++ b/editor/src/components/canvas/commands/rearrange-children-command.ts @@ -1,7 +1,7 @@ import { getUtopiaJSXComponentsFromSuccess } from '../../../core/model/project-file-utils' import * as EP from '../../../core/shared/element-path' import type { ElementPath, StaticElementPath } from '../../../core/shared/project-file-types' -import type { DerivedState, EditorState } from '../../editor/store/editor-state' +import type { EditorState } from '../../editor/store/editor-state' import { withUnderlyingTargetFromEditorState } from '../../editor/store/editor-state' import type { BaseCommand, CommandFunction, WhenToRun } from './commands' import { getPatchForComponentChange } from './commands' @@ -28,7 +28,6 @@ export function rearrangeChildren( export const runRearrangeChildren: CommandFunction = ( editorState: EditorState, - _derivedState: DerivedState, command: RearrangeChildren, ) => { const patch = withUnderlyingTargetFromEditorState( diff --git a/editor/src/components/canvas/commands/reorder-element-command.spec.tsx b/editor/src/components/canvas/commands/reorder-element-command.spec.tsx index 9714fe0d2761..42c3ee32833a 100644 --- a/editor/src/components/canvas/commands/reorder-element-command.spec.tsx +++ b/editor/src/components/canvas/commands/reorder-element-command.spec.tsx @@ -1,10 +1,7 @@ import { absolute } from '../../../utils/utils' import * as EP from '../../../core/shared/element-path' import type { EditorState } from '../../editor/store/editor-state' -import { - emptyDerivedState, - withUnderlyingTargetFromEditorState, -} from '../../editor/store/editor-state' +import { withUnderlyingTargetFromEditorState } from '../../editor/store/editor-state' import { getEditorState, makeTestProjectCodeWithSnippet } from '../ui-jsx.test-utils' import { updateEditorStateWithPatches } from './commands' import { reorderElement, runReorderElement } from './reorder-element-command' @@ -81,11 +78,7 @@ describe('runReorderElement', () => { const reorderCommand = reorderElement('always', target, absolute(newIdx)) - const result = runReorderElement( - originalEditorState, - emptyDerivedState(originalEditorState), - reorderCommand, - ) + const result = runReorderElement(originalEditorState, reorderCommand) const patchedEditor = updateEditorStateWithPatches( originalEditorState, diff --git a/editor/src/components/canvas/commands/reorder-element-command.ts b/editor/src/components/canvas/commands/reorder-element-command.ts index 0bb6d9835ebb..ff93997cc8d8 100644 --- a/editor/src/components/canvas/commands/reorder-element-command.ts +++ b/editor/src/components/canvas/commands/reorder-element-command.ts @@ -2,7 +2,7 @@ import type { IndexPosition } from '../../../utils/utils' import { getUtopiaJSXComponentsFromSuccess } from '../../../core/model/project-file-utils' import * as EP from '../../../core/shared/element-path' import type { ElementPath } from '../../../core/shared/project-file-types' -import type { DerivedState, EditorState } from '../../editor/store/editor-state' +import type { EditorState } from '../../editor/store/editor-state' import { withUnderlyingTargetFromEditorState } from '../../editor/store/editor-state' import { reorderComponent } from '../canvas-utils' import type { BaseCommand, CommandFunction, WhenToRun } from './commands' @@ -29,7 +29,6 @@ export function reorderElement( export const runReorderElement: CommandFunction = ( editorState: EditorState, - _derivedState: DerivedState, command: ReorderElement, ) => { const patch = withUnderlyingTargetFromEditorState( diff --git a/editor/src/components/canvas/commands/reparent-element-command.spec.tsx b/editor/src/components/canvas/commands/reparent-element-command.spec.tsx index bfad1aa28b6a..ef5ea1a03d65 100644 --- a/editor/src/components/canvas/commands/reparent-element-command.spec.tsx +++ b/editor/src/components/canvas/commands/reparent-element-command.spec.tsx @@ -31,11 +31,7 @@ describe('runReparentElement', () => { const reparentCommand = reparentElement('always', targetPath, childInsertionPath(newParentPath)) - const result = runReparentElement( - originalEditorState, - renderResult.getEditorState().derived, - reparentCommand, - ) + const result = runReparentElement(originalEditorState, reparentCommand) const patchedEditor = updateEditorStateWithPatches( originalEditorState, @@ -86,11 +82,7 @@ describe('runReparentElement', () => { const reparentCommand = reparentElement('always', targetPath, childInsertionPath(newParentPath)) - const result = runReparentElement( - originalEditorState, - renderResult.getEditorState().derived, - reparentCommand, - ) + const result = runReparentElement(originalEditorState, reparentCommand) const oldFile = withUnderlyingTargetFromEditorState( targetPath, diff --git a/editor/src/components/canvas/commands/reparent-element-command.ts b/editor/src/components/canvas/commands/reparent-element-command.ts index b17cabe29c4e..6a5ff22bd0b7 100644 --- a/editor/src/components/canvas/commands/reparent-element-command.ts +++ b/editor/src/components/canvas/commands/reparent-element-command.ts @@ -8,7 +8,7 @@ import { getUtopiaJSXComponentsFromSuccess } from '../../../core/model/project-f import * as EP from '../../../core/shared/element-path' import type { ElementPath } from '../../../core/shared/project-file-types' import { mergeImports } from '../../../core/workers/common/project-file-utils' -import type { DerivedState, EditorState, EditorStatePatch } from '../../editor/store/editor-state' +import type { EditorState, EditorStatePatch } from '../../editor/store/editor-state' import { forUnderlyingTargetFromEditorState, removeElementAtPath, @@ -42,7 +42,6 @@ export function reparentElement( export const runReparentElement: CommandFunction = ( editorState: EditorState, - _derivedState: DerivedState, command: ReparentElement, ) => { let editorStatePatches: Array = [] diff --git a/editor/src/components/canvas/commands/set-css-length-command.spec.tsx b/editor/src/components/canvas/commands/set-css-length-command.spec.tsx index acae117dd86c..cb624278ce0c 100644 --- a/editor/src/components/canvas/commands/set-css-length-command.spec.tsx +++ b/editor/src/components/canvas/commands/set-css-length-command.spec.tsx @@ -50,7 +50,6 @@ describe('setCssLengthProperty', () => { const result = runSetCssLengthProperty( renderResult.getEditorState().editor, - renderResult.getEditorState().derived, setCSSPropertyCommand, ) @@ -228,7 +227,7 @@ function runCommandUpdateEditor( store: EditorStorePatched, command: SetCssLengthProperty, ): EditorState { - const result = runSetCssLengthProperty(store.editor, store.derived, command) + const result = runSetCssLengthProperty(store.editor, command) return updateEditorStateWithPatches(store.editor, result.editorStatePatches) } diff --git a/editor/src/components/canvas/commands/set-css-length-command.ts b/editor/src/components/canvas/commands/set-css-length-command.ts index 478d4c72f3ad..65fa62cd85ca 100644 --- a/editor/src/components/canvas/commands/set-css-length-command.ts +++ b/editor/src/components/canvas/commands/set-css-length-command.ts @@ -13,9 +13,8 @@ import { } from '../../../core/shared/jsx-attributes' import type { ElementPath, PropertyPath } from '../../../core/shared/project-file-types' import * as PP from '../../../core/shared/property-path' -import type { DerivedState, EditorState, EditorStatePatch } from '../../editor/store/editor-state' -import { deriveState, withUnderlyingTargetFromEditorState } from '../../editor/store/editor-state' -import { patchedCreateRemixDerivedDataMemo } from '../../editor/store/remix-derived-data' +import type { EditorState, EditorStatePatch } from '../../editor/store/editor-state' +import { withUnderlyingTargetFromEditorState } from '../../editor/store/editor-state' import type { CSSKeyword, CSSNumber, FlexDirection } from '../../inspector/common/css-utils' import { cssPixelLength, @@ -77,7 +76,6 @@ export function setCssLengthProperty( export const runSetCssLengthProperty: CommandFunction = ( editorState: EditorState, - _derivedState: DerivedState, command: SetCssLengthProperty, ) => { // in case of width or height change, delete min, max and flex props diff --git a/editor/src/components/canvas/commands/set-cursor-command.ts b/editor/src/components/canvas/commands/set-cursor-command.ts index 5a6e4d7191fc..908dde44b8a7 100644 --- a/editor/src/components/canvas/commands/set-cursor-command.ts +++ b/editor/src/components/canvas/commands/set-cursor-command.ts @@ -1,7 +1,6 @@ -import type { DerivedState, EditorState, EditorStatePatch } from '../../editor/store/editor-state' +import type { EditorState, EditorStatePatch } from '../../editor/store/editor-state' import type { CSSCursor } from '../canvas-types' import type { BaseCommand, CommandFunction } from './commands' -import { WhenToRun } from './commands' export interface SetCursorCommand extends BaseCommand { type: 'SET_CURSOR_COMMAND' @@ -18,7 +17,6 @@ export function setCursorCommand(value: CSSCursor | null): SetCursorCommand { export const runSetCursor: CommandFunction = ( _: EditorState, - __: DerivedState, command: SetCursorCommand, ) => { const editorStatePatch: EditorStatePatch = { diff --git a/editor/src/components/canvas/commands/set-elements-to-rerender-command.ts b/editor/src/components/canvas/commands/set-elements-to-rerender-command.ts index 48d138e896e5..1b6c52fa3368 100644 --- a/editor/src/components/canvas/commands/set-elements-to-rerender-command.ts +++ b/editor/src/components/canvas/commands/set-elements-to-rerender-command.ts @@ -1,6 +1,5 @@ import * as EP from '../../../core/shared/element-path' import type { - DerivedState, EditorState, EditorStatePatch, ElementsToRerender, @@ -25,7 +24,6 @@ export function setElementsToRerenderCommand( export const runSetElementsToRerender: CommandFunction = ( e: EditorState, - __: DerivedState, command: SetElementsToRerenderCommand, ) => { const editorStatePatch: EditorStatePatch = { @@ -69,7 +67,6 @@ function mergeElementsToRerender(l: ElementsToRerender, r: ElementsToRerender): export const runAppendElementsToRerender: CommandFunction = ( e: EditorState, - __: DerivedState, command: AppendElementsToRerenderCommand, ) => { const editorStatePatch: EditorStatePatch = { diff --git a/editor/src/components/canvas/commands/set-property-command.ts b/editor/src/components/canvas/commands/set-property-command.ts index f2ab599bf0d6..6c5802eb5e25 100644 --- a/editor/src/components/canvas/commands/set-property-command.ts +++ b/editor/src/components/canvas/commands/set-property-command.ts @@ -6,7 +6,7 @@ import type { PropertyPathPart, } from '../../../core/shared/project-file-types' import * as PP from '../../../core/shared/property-path' -import type { DerivedState, EditorState } from '../../editor/store/editor-state' +import type { EditorState } from '../../editor/store/editor-state' import { applyValuesAtPath } from './adjust-number-command' import type { BaseCommand, CommandFunction, WhenToRun } from './commands' @@ -49,7 +49,6 @@ export function setPropertyOmitNullProp( export const runSetProperty: CommandFunction = ( editorState: EditorState, - _derivedState: DerivedState, command: SetProperty, ) => { // Apply the update to the properties. diff --git a/editor/src/components/canvas/commands/set-snapping-guidelines-command.ts b/editor/src/components/canvas/commands/set-snapping-guidelines-command.ts index 3092e2a3b94d..6f23734b50d8 100644 --- a/editor/src/components/canvas/commands/set-snapping-guidelines-command.ts +++ b/editor/src/components/canvas/commands/set-snapping-guidelines-command.ts @@ -1,4 +1,4 @@ -import type { DerivedState, EditorState, EditorStatePatch } from '../../editor/store/editor-state' +import type { EditorState, EditorStatePatch } from '../../editor/store/editor-state' import type { GuidelineWithSnappingVectorAndPointsOfRelevance } from '../guideline' import type { BaseCommand, CommandFunction, WhenToRun } from './commands' @@ -20,7 +20,6 @@ export function setSnappingGuidelines( export const runSetSnappingGuidelines: CommandFunction = ( _: EditorState, - __: DerivedState, command: SetSnappingGuidelines, ) => { const editorStatePatch: EditorStatePatch = { diff --git a/editor/src/components/canvas/commands/show-outline-highlight-command.ts b/editor/src/components/canvas/commands/show-outline-highlight-command.ts index 564a8f055cee..dfed285f9396 100644 --- a/editor/src/components/canvas/commands/show-outline-highlight-command.ts +++ b/editor/src/components/canvas/commands/show-outline-highlight-command.ts @@ -1,5 +1,5 @@ import type { CanvasRectangle } from '../../../core/shared/math-utils' -import type { DerivedState, EditorState, EditorStatePatch } from '../../editor/store/editor-state' +import type { EditorState, EditorStatePatch } from '../../editor/store/editor-state' import type { BaseCommand, CommandFunction, WhenToRun } from './commands' export interface ShowOutlineHighlight extends BaseCommand { @@ -20,7 +20,6 @@ export function showOutlineHighlight( export const runShowOutlineHighlight: CommandFunction = ( _: EditorState, - __: DerivedState, command: ShowOutlineHighlight, ) => { const editorStatePatch: EditorStatePatch = { diff --git a/editor/src/components/canvas/commands/show-reorder-indicator-command.ts b/editor/src/components/canvas/commands/show-reorder-indicator-command.ts index 137924d9b53d..8b36126e3c12 100644 --- a/editor/src/components/canvas/commands/show-reorder-indicator-command.ts +++ b/editor/src/components/canvas/commands/show-reorder-indicator-command.ts @@ -8,7 +8,7 @@ import { } from '../../../core/shared/math-utils' import { forceNotNull } from '../../../core/shared/optional-utils' import type { ElementPath } from '../../../core/shared/project-file-types' -import type { DerivedState, EditorState, EditorStatePatch } from '../../editor/store/editor-state' +import type { EditorState, EditorStatePatch } from '../../editor/store/editor-state' import { singleAxisAutoLayoutContainerDirections } from '../canvas-strategies/strategies/flow-reorder-helpers' import type { SiblingPosition } from '../canvas-strategies/strategies/reparent-helpers/reparent-strategy-sibling-position-helpers' import { @@ -34,7 +34,6 @@ export function showReorderIndicator(target: ElementPath, index: number): ShowRe export const runShowReorderIndicator: CommandFunction = ( editor: EditorState, - __: DerivedState, command: ShowReorderIndicator, ) => { const targetParent = MetadataUtils.findElementByElementPath(editor.jsxMetadata, command.target) diff --git a/editor/src/components/canvas/commands/update-function-command.ts b/editor/src/components/canvas/commands/update-function-command.ts index ed841788fa71..f6f89c84bc85 100644 --- a/editor/src/components/canvas/commands/update-function-command.ts +++ b/editor/src/components/canvas/commands/update-function-command.ts @@ -1,4 +1,4 @@ -import type { DerivedState, EditorState, EditorStatePatch } from '../../editor/store/editor-state' +import type { EditorState, EditorStatePatch } from '../../editor/store/editor-state' import type { InteractionLifecycle } from '../canvas-strategies/canvas-strategy-types' import type { BaseCommand, CommandFunctionResult, WhenToRun } from './commands' @@ -6,7 +6,6 @@ export interface UpdateFunctionCommand extends BaseCommand { type: 'UPDATE_FUNCTION_COMMAND' updateFunction: ( editorState: EditorState, - derivedState: DerivedState, commandLifecycle: InteractionLifecycle, ) => Array } @@ -15,7 +14,6 @@ export function updateFunctionCommand( whenToRun: WhenToRun, updateFunction: ( editorState: EditorState, - derivedState: DerivedState, commandLifecycle: InteractionLifecycle, ) => Array, ): UpdateFunctionCommand { @@ -28,12 +26,11 @@ export function updateFunctionCommand( export const runUpdateFunctionCommand = ( editorState: EditorState, - derivedState: DerivedState, command: UpdateFunctionCommand, commandLifecycle: InteractionLifecycle, ): CommandFunctionResult => { return { - editorStatePatches: command.updateFunction(editorState, derivedState, commandLifecycle), + editorStatePatches: command.updateFunction(editorState, commandLifecycle), commandDescription: `Update Callback`, } } diff --git a/editor/src/components/canvas/commands/update-highlighted-views-command.ts b/editor/src/components/canvas/commands/update-highlighted-views-command.ts index 964e92a024a9..251813ce3fc3 100644 --- a/editor/src/components/canvas/commands/update-highlighted-views-command.ts +++ b/editor/src/components/canvas/commands/update-highlighted-views-command.ts @@ -1,6 +1,6 @@ import * as EP from '../../../core/shared/element-path' import type { ElementPath } from '../../../core/shared/project-file-types' -import type { DerivedState, EditorState, EditorStatePatch } from '../../editor/store/editor-state' +import type { EditorState, EditorStatePatch } from '../../editor/store/editor-state' import type { BaseCommand, CommandFunction, WhenToRun } from './commands' export interface UpdateHighlightedViews extends BaseCommand { @@ -21,7 +21,6 @@ export function updateHighlightedViews( export const runUpdateHighlightedViews: CommandFunction = ( _: EditorState, - __: DerivedState, command: UpdateHighlightedViews, ) => { const editorStatePatch = { diff --git a/editor/src/components/canvas/commands/update-prop-if-exists-command.ts b/editor/src/components/canvas/commands/update-prop-if-exists-command.ts index 67976974ae7a..5f24bd033341 100644 --- a/editor/src/components/canvas/commands/update-prop-if-exists-command.ts +++ b/editor/src/components/canvas/commands/update-prop-if-exists-command.ts @@ -9,7 +9,7 @@ import { import { getModifiableJSXAttributeAtPath } from '../../../core/shared/jsx-attributes' import type { ElementPath, PropertyPath } from '../../../core/shared/project-file-types' import * as PP from '../../../core/shared/property-path' -import type { DerivedState, EditorState } from '../../editor/store/editor-state' +import type { EditorState } from '../../editor/store/editor-state' import { withUnderlyingTargetFromEditorState } from '../../editor/store/editor-state' import { applyValuesAtPath } from './adjust-number-command' import type { BaseCommand, CommandFunction, WhenToRun } from './commands' @@ -38,7 +38,6 @@ export function updatePropIfExists( export const runUpdatePropIfExists: CommandFunction = ( editorState: EditorState, - _derivedState: DerivedState, command: UpdatePropIfExists, ) => { // check if the prop exists diff --git a/editor/src/components/canvas/commands/update-selected-views-command.spec.tsx b/editor/src/components/canvas/commands/update-selected-views-command.spec.tsx index 4491b21dd9c1..85ce9779b6ef 100644 --- a/editor/src/components/canvas/commands/update-selected-views-command.spec.tsx +++ b/editor/src/components/canvas/commands/update-selected-views-command.spec.tsx @@ -5,7 +5,6 @@ import { complexDefaultProjectPreParsed } from '../../../sample-projects/sample- import { DefaultStartingFeatureSwitches, renderTestEditorWithModel } from '../ui-jsx.test-utils' import { updateEditorStateWithPatches } from './commands' import { runUpdateSelectedViews, updateSelectedViews } from './update-selected-views-command' -import { emptyDerivedState } from '../../editor/store/editor-state' describe('updateSelectedViews', () => { it('updating selected views work', async () => { @@ -26,11 +25,7 @@ describe('updateSelectedViews', () => { const updateSelectedViewsCommand = updateSelectedViews('always', [targetPath]) - const result = runUpdateSelectedViews( - originalEditorState, - emptyDerivedState(originalEditorState), - updateSelectedViewsCommand, - ) + const result = runUpdateSelectedViews(originalEditorState, updateSelectedViewsCommand) const patchedEditor = updateEditorStateWithPatches( originalEditorState, diff --git a/editor/src/components/canvas/commands/update-selected-views-command.ts b/editor/src/components/canvas/commands/update-selected-views-command.ts index 099361239c0c..97638b4470af 100644 --- a/editor/src/components/canvas/commands/update-selected-views-command.ts +++ b/editor/src/components/canvas/commands/update-selected-views-command.ts @@ -1,6 +1,6 @@ import * as EP from '../../../core/shared/element-path' import type { ElementPath } from '../../../core/shared/project-file-types' -import type { DerivedState, EditorState, EditorStatePatch } from '../../editor/store/editor-state' +import type { EditorState, EditorStatePatch } from '../../editor/store/editor-state' import type { BaseCommand, CommandFunction, WhenToRun } from './commands' export interface UpdateSelectedViews extends BaseCommand { @@ -21,7 +21,6 @@ export function updateSelectedViews( export const runUpdateSelectedViews: CommandFunction = ( _: EditorState, - __: DerivedState, command: UpdateSelectedViews, ) => { const editorStatePatch: EditorStatePatch = { diff --git a/editor/src/components/canvas/commands/wildcard-patch-command.spec.tsx b/editor/src/components/canvas/commands/wildcard-patch-command.spec.tsx index 2242965053a1..d8d54d9c25ce 100644 --- a/editor/src/components/canvas/commands/wildcard-patch-command.spec.tsx +++ b/editor/src/components/canvas/commands/wildcard-patch-command.spec.tsx @@ -28,11 +28,7 @@ describe('wildcardPatch', () => { const wildcardCommand = wildcardPatch('always', { selectedViews: { $set: [] } }) - const result = runWildcardPatch( - renderResult.getEditorState().editor, - renderResult.getEditorState().derived, - wildcardCommand, - ) + const result = runWildcardPatch(renderResult.getEditorState().editor, wildcardCommand) const patchedEditor = updateEditorStateWithPatches( renderResult.getEditorState().editor, diff --git a/editor/src/components/canvas/commands/wildcard-patch-command.ts b/editor/src/components/canvas/commands/wildcard-patch-command.ts index 3df875e996fb..4a3a09357f79 100644 --- a/editor/src/components/canvas/commands/wildcard-patch-command.ts +++ b/editor/src/components/canvas/commands/wildcard-patch-command.ts @@ -1,4 +1,4 @@ -import type { DerivedState, EditorState, EditorStatePatch } from '../../editor/store/editor-state' +import type { EditorState, EditorStatePatch } from '../../editor/store/editor-state' import type { BaseCommand, CommandFunction, WhenToRun } from './commands' export interface WildcardPatch extends BaseCommand { @@ -16,7 +16,6 @@ export function wildcardPatch(whenToRun: WhenToRun, patch: EditorStatePatch): Wi export const runWildcardPatch: CommandFunction = ( _: EditorState, - __: DerivedState, command: WildcardPatch, ) => { return { diff --git a/editor/src/components/canvas/commands/wrap-in-container-command.spec.tsx b/editor/src/components/canvas/commands/wrap-in-container-command.spec.tsx index 4f488ac42433..5191e9527517 100644 --- a/editor/src/components/canvas/commands/wrap-in-container-command.spec.tsx +++ b/editor/src/components/canvas/commands/wrap-in-container-command.spec.tsx @@ -42,7 +42,7 @@ describe('wrapInContainerCommand', () => { expect(originalElement).not.toBeNull() const cmd = wrapInContainerCommand('always', targetPath, 'the-wrapper', 'fragment') - const result = runWrapInContainerCommand(editor, renderResult.getEditorState().derived, cmd) + const result = runWrapInContainerCommand(editor, cmd) const patchedEditor = updateEditorStateWithPatches(editor, result.editorStatePatches) const wrapperPath = EP.appendToPath(EP.parentPath(targetPath), 'the-wrapper') @@ -83,7 +83,7 @@ describe('wrapInContainerCommand', () => { expect(originalElement).not.toBeNull() const cmd = wrapInContainerCommand('always', targetPath, 'the-wrapper', 'conditional') - const result = runWrapInContainerCommand(editor, renderResult.getEditorState().derived, cmd) + const result = runWrapInContainerCommand(editor, cmd) const patchedEditor = updateEditorStateWithPatches(editor, result.editorStatePatches) const wrapperPath = EP.appendToPath(EP.parentPath(targetPath), 'the-wrapper') @@ -128,7 +128,7 @@ describe('wrapInContainerCommand', () => { expect(originalElement).toBeNull() const cmd = wrapInContainerCommand('always', targetPath, 'the-wrapper', 'fragment') - const result = runWrapInContainerCommand(editor, renderResult.getEditorState().derived, cmd) + const result = runWrapInContainerCommand(editor, cmd) const patchedEditor = updateEditorStateWithPatches(editor, result.editorStatePatches) const wrapperPath = EP.appendToPath(EP.parentPath(targetPath), 'the-wrapper') diff --git a/editor/src/components/canvas/commands/wrap-in-container-command.ts b/editor/src/components/canvas/commands/wrap-in-container-command.ts index bc6662dafccb..ed921494a559 100644 --- a/editor/src/components/canvas/commands/wrap-in-container-command.ts +++ b/editor/src/components/canvas/commands/wrap-in-container-command.ts @@ -9,7 +9,7 @@ import { jsxFragment, } from '../../../core/shared/element-template' import type { ElementPath, Imports } from '../../../core/shared/project-file-types' -import type { DerivedState, EditorState, EditorStatePatch } from '../../editor/store/editor-state' +import type { EditorState, EditorStatePatch } from '../../editor/store/editor-state' import { forUnderlyingTargetFromEditorState, removeElementAtPath, @@ -65,7 +65,6 @@ export function wrapInContainerCommand( export const runWrapInContainerCommand: CommandFunction = ( editor: EditorState, - _derivedState: DerivedState, command: WrapInContainerCommand, ) => { let editorStatePatches: Array = [] diff --git a/editor/src/components/editor/actions/actions.spec.tsx b/editor/src/components/editor/actions/actions.spec.tsx index 0d982927ab1e..50bf6181fc92 100644 --- a/editor/src/components/editor/actions/actions.spec.tsx +++ b/editor/src/components/editor/actions/actions.spec.tsx @@ -94,7 +94,6 @@ import { defaultUserState, deriveState, editorModelFromPersistentModel, - emptyDerivedState, getOpenUIJSFile, withUnderlyingTargetFromEditorState, } from '../store/editor-state' @@ -907,7 +906,7 @@ describe('INSERT_INSERTABLE', () => { null, ) - const actualResult = UPDATE_FNS.INSERT_INSERTABLE(action, editorState, derivedState) + const actualResult = UPDATE_FNS.INSERT_INSERTABLE(action, editorState) const cardFile = getProjectFileByFilePath(actualResult.projectContents, '/src/card.js') if (cardFile != null && isTextFile(cardFile)) { const parsed = cardFile.fileContents.parsed @@ -1020,7 +1019,7 @@ describe('INSERT_INSERTABLE', () => { null, ) - const actualResult = UPDATE_FNS.INSERT_INSERTABLE(action, editorState, derivedState) + const actualResult = UPDATE_FNS.INSERT_INSERTABLE(action, editorState) const cardFile = getProjectFileByFilePath(actualResult.projectContents, '/src/card.js') if (cardFile != null && isTextFile(cardFile)) { const parsed = cardFile.fileContents.parsed @@ -1127,7 +1126,7 @@ describe('INSERT_INSERTABLE', () => { const action = insertInsertable(childInsertionPath(targetPath), imgInsertable, 'add-size', null) - const actualResult = UPDATE_FNS.INSERT_INSERTABLE(action, editorState, derivedState) + const actualResult = UPDATE_FNS.INSERT_INSERTABLE(action, editorState) const cardFile = getProjectFileByFilePath(actualResult.projectContents, '/src/card.js') if (cardFile != null && isTextFile(cardFile)) { const parsed = cardFile.fileContents.parsed @@ -1230,7 +1229,7 @@ describe('INSERT_INSERTABLE', () => { type: 'back', }) - const actualResult = UPDATE_FNS.INSERT_INSERTABLE(action, editorState, derivedState) + const actualResult = UPDATE_FNS.INSERT_INSERTABLE(action, editorState) const cardFile = getProjectFileByFilePath(actualResult.projectContents, '/src/card.js') if (cardFile != null && isTextFile(cardFile)) { const parsed = cardFile.fileContents.parsed diff --git a/editor/src/components/editor/actions/actions.tsx b/editor/src/components/editor/actions/actions.tsx index 3805a99fcbc0..239d0c338560 100644 --- a/editor/src/components/editor/actions/actions.tsx +++ b/editor/src/components/editor/actions/actions.tsx @@ -611,7 +611,6 @@ export function editorMoveMultiSelectedTemplates( indexPosition: IndexPosition, newParent: InsertionPath | null, editor: EditorModel, - derivedState: DerivedState, ): { editor: EditorModel newPaths: Array @@ -640,7 +639,7 @@ export function editorMoveMultiSelectedTemplates( const { commands: reparentCommands, newPath } = outcomeResult const reorderCommand = reorderElement('on-complete', newPath, indexPosition) - const withCommandsApplied = foldAndApplyCommandsSimple(working, derivedState, [ + const withCommandsApplied = foldAndApplyCommandsSimple(working, [ ...reparentCommands, reorderCommand, ]) @@ -665,7 +664,6 @@ export function insertIntoWrapper( targets: ElementPath[], newParent: InsertionPath, editor: EditorModel, - derivedState: DerivedState, ): { editor: EditorModel newPaths: Array @@ -683,7 +681,7 @@ export function insertIntoWrapper( elementPathFromInsertionPath(newParent, EP.toUid(target)), ) - const updatedEditor = foldAndApplyCommandsSimple(editor, derivedState, [ + const updatedEditor = foldAndApplyCommandsSimple(editor, [ ...targets.map((path) => deleteElement('always', path)), addElements('always', newParent, elements), ]) @@ -2129,7 +2127,6 @@ export const UPDATE_FNS = { const detailsOfUpdate = null const { updatedEditor, newPath } = wrapElementInsertions( editor, - derived, action.targets, parentPath, action.whatToWrapWith.element, @@ -2172,7 +2169,6 @@ export const UPDATE_FNS = { orderedActionTargets, actualInsertionPath, includeToast(detailsOfUpdate, withWrapperViewAdded), - derived, ) return { @@ -2214,7 +2210,6 @@ export const UPDATE_FNS = { editorForAction: EditorModel, dispatch: EditorDispatch, builtInDependencies: BuiltInDependencies, - derived: DerivedState, ): EditorModel => { return toastOnGeneratedElementsSelected( `Cannot unwrap a generated element.`, @@ -2286,7 +2281,6 @@ export const UPDATE_FNS = { indexPosition, parentPath, workingEditor, - derived, ) return { @@ -2328,7 +2322,6 @@ export const UPDATE_FNS = { groupTrueUps.push(result.newPath) return foldAndApplyCommandsSimple( result.editor, - derived, createPinChangeCommandsForElementBecomingGroupChild( workingEditor.jsxMetadata, child, @@ -2849,7 +2842,7 @@ export const UPDATE_FNS = { }, } }, - RESET_PINS: (action: ResetPins, editor: EditorModel, derived: DerivedState): EditorModel => { + RESET_PINS: (action: ResetPins, editor: EditorModel): EditorModel => { const target = action.target const frame = MetadataUtils.getFrame(target, editor.jsxMetadata) @@ -2864,7 +2857,7 @@ export const UPDATE_FNS = { PP.create('style', 'bottom'), ]), ] - return foldAndApplyCommandsSimple(editor, derived, commands) + return foldAndApplyCommandsSimple(editor, commands) }, SET_CURSOR_OVERLAY: (action: SetCursorOverlay, editor: EditorModel): EditorModel => { if (editor.canvas.cursor === action.cursor) { @@ -3806,7 +3799,7 @@ export const UPDATE_FNS = { } } }, - TRUE_UP_GROUPS: (editor: EditorModel, derivedState: DerivedState): EditorModel => { + TRUE_UP_GROUPS: (editor: EditorModel): EditorModel => { const targetsToTrueUp = editor.trueUpGroupsForElementAfterDomWalkerRuns.flatMap( (trueUpTarget) => { return trueUpTargetToTargets(editor.jsxMetadata, editor.elementPathTree, trueUpTarget) @@ -3825,7 +3818,7 @@ export const UPDATE_FNS = { target: element, } }, targetsToTrueUp) - const editorWithGroupsTruedUp = foldAndApplyCommandsSimple(editor, derivedState, [ + const editorWithGroupsTruedUp = foldAndApplyCommandsSimple(editor, [ pushIntendedBoundsAndUpdateGroups(canvasFrameAndTargets, 'live-metadata'), ]) return { ...editorWithGroupsTruedUp, trueUpGroupsForElementAfterDomWalkerRuns: [] } @@ -4697,11 +4690,7 @@ export const UPDATE_FNS = { }, } }, - INSERT_INSERTABLE: ( - action: InsertInsertable, - editor: EditorModel, - derivedState: DerivedState, - ): EditorModel => { + INSERT_INSERTABLE: (action: InsertInsertable, editor: EditorModel): EditorModel => { const openFilename = editor.canvas.openFile?.filename if (openFilename == null) { return editor @@ -4888,7 +4877,6 @@ export const UPDATE_FNS = { trueUpElementChanged(newPath), ], }, - derivedState, groupCommands, ) @@ -5069,10 +5057,9 @@ export const UPDATE_FNS = { RUN_ESCAPE_HATCH: ( action: RunEscapeHatch, editor: EditorModel, - derivedState: DerivedState, builtInDependencies: BuiltInDependencies, ): EditorModel => { - const canvasState = pickCanvasStateFromEditorState(editor, derivedState, builtInDependencies) + const canvasState = pickCanvasStateFromEditorState(editor, builtInDependencies) if (areAllSelectedElementsNonAbsolute(action.targets, editor.jsxMetadata)) { const commands = getEscapeHatchCommands( action.targets, @@ -5080,19 +5067,13 @@ export const UPDATE_FNS = { canvasState, null, ).commands - return foldAndApplyCommandsSimple(editor, derivedState, commands) + return foldAndApplyCommandsSimple(editor, commands) } else { return editor } }, - SET_ELEMENTS_TO_RERENDER: ( - action: SetElementsToRerender, - derivedState: DerivedState, - editor: EditorModel, - ): EditorModel => { - return foldAndApplyCommandsSimple(editor, derivedState, [ - setElementsToRerenderCommand(action.value), - ]) + SET_ELEMENTS_TO_RERENDER: (action: SetElementsToRerender, editor: EditorModel): EditorModel => { + return foldAndApplyCommandsSimple(editor, [setElementsToRerenderCommand(action.value)]) }, TOGGLE_SELECTION_LOCK: (action: ToggleSelectionLock, editor: EditorModel): EditorModel => { const targets = action.targets @@ -5183,12 +5164,8 @@ export const UPDATE_FNS = { imageDragSessionState: action.imageDragSessionState, } }, - APPLY_COMMANDS: ( - action: ApplyCommandsAction, - editor: EditorModel, - derivedState: DerivedState, - ): EditorModel => { - return foldAndApplyCommandsSimple(editor, derivedState, action.commands) + APPLY_COMMANDS: (action: ApplyCommandsAction, editor: EditorModel): EditorModel => { + return foldAndApplyCommandsSimple(editor, action.commands) }, UPDATE_COLOR_SWATCHES: (action: UpdateColorSwatches, editor: EditorModel): EditorModel => { return { diff --git a/editor/src/components/editor/actions/wrap-unwrap-helpers.tsx b/editor/src/components/editor/actions/wrap-unwrap-helpers.tsx index c43a53c4ead9..63940e40ebce 100644 --- a/editor/src/components/editor/actions/wrap-unwrap-helpers.tsx +++ b/editor/src/components/editor/actions/wrap-unwrap-helpers.tsx @@ -331,7 +331,6 @@ export function fixParentContainingBlockSettings( export function wrapElementInsertions( editor: EditorState, - derivedState: DerivedState, targets: Array, parentPath: InsertionPath, rawElementToInsert: JSXElement | JSXFragment | JSXConditionalExpression, @@ -385,7 +384,7 @@ export function wrapElementInsertions( switch (staticTarget.type) { case 'CHILD_INSERTION': return { - updatedEditor: foldAndApplyCommandsSimple(editor, derivedState, [ + updatedEditor: foldAndApplyCommandsSimple(editor, [ addElement('always', staticTarget, elementToInsert, { importsToAdd, indexPosition }), ]), newPath: newPath, @@ -407,7 +406,7 @@ export function wrapElementInsertions( switch (staticTarget.type) { case 'CHILD_INSERTION': return { - updatedEditor: foldAndApplyCommandsSimple(editor, derivedState, [ + updatedEditor: foldAndApplyCommandsSimple(editor, [ addElement('always', staticTarget, elementToInsert, { importsToAdd, indexPosition }), ]), newPath: newPath, @@ -429,7 +428,7 @@ export function wrapElementInsertions( switch (staticTarget.type) { case 'CHILD_INSERTION': return { - updatedEditor: foldAndApplyCommandsSimple(editor, derivedState, [ + updatedEditor: foldAndApplyCommandsSimple(editor, [ addElement('always', staticTarget, elementToInsert, { importsToAdd, indexPosition }), ]), newPath: newPath, diff --git a/editor/src/components/editor/store/dispatch-strategies.tsx b/editor/src/components/editor/store/dispatch-strategies.tsx index 7edd11d87c73..67f2d990e5ca 100644 --- a/editor/src/components/editor/store/dispatch-strategies.tsx +++ b/editor/src/components/editor/store/dispatch-strategies.tsx @@ -77,7 +77,6 @@ export function interactionFinished( ) const canvasState: InteractionCanvasState = pickCanvasStateFromEditorState( newEditorState, - result.unpatchedDerived, result.builtInDependencies, ) const interactionSession = storedState.unpatchedEditor.canvas.interactionSession @@ -105,7 +104,6 @@ export function interactionFinished( } const commandResult = foldAndApplyCommands( newEditorState, - result.unpatchedDerived, storedState.patchedEditor, [], strategyResult.commands, @@ -155,7 +153,6 @@ export function interactionHardReset( } const canvasState: InteractionCanvasState = pickCanvasStateFromEditorState( newEditorState, - result.unpatchedDerived, result.builtInDependencies, ) const interactionSession = newEditorState.canvas.interactionSession @@ -194,7 +191,6 @@ export function interactionHardReset( ) const commandResult = foldAndApplyCommands( newEditorState, - result.unpatchedDerived, storedState.patchedEditor, [], strategyResult.commands, @@ -242,7 +238,6 @@ export function interactionUpdate( const newEditorState = result.unpatchedEditor const canvasState: InteractionCanvasState = pickCanvasStateFromEditorState( newEditorState, - result.unpatchedDerived, result.builtInDependencies, ) const interactionSession = newEditorState.canvas.interactionSession @@ -274,7 +269,6 @@ export function interactionUpdate( return handleUserChangedStrategy( result.builtInDependencies, newEditorState, - result.unpatchedDerived, storedState.patchedEditor, result.strategyState, strategy, @@ -292,7 +286,6 @@ export function interactionUpdate( return handleAccumulatingKeypresses( result.builtInDependencies, newEditorState, - result.unpatchedDerived, storedState.patchedEditor, result.strategyState, strategy, @@ -303,7 +296,6 @@ export function interactionUpdate( return handleUpdate( result.builtInDependencies, newEditorState, - result.unpatchedDerived, storedState.patchedEditor, result.strategyState, strategy, @@ -328,7 +320,6 @@ export function interactionStart( ) const canvasState: InteractionCanvasState = pickCanvasStateFromEditorState( newEditorState, - result.unpatchedDerived, result.builtInDependencies, ) const interactionSession = newEditorState.canvas.interactionSession @@ -362,7 +353,6 @@ export function interactionStart( ) const commandResult = foldAndApplyCommands( newEditorState, - result.unpatchedDerived, storedState.patchedEditor, [], strategyResult.commands, @@ -430,7 +420,6 @@ export function interactionCancel( function handleUserChangedStrategy( builtInDependencies: BuiltInDependencies, newEditorState: EditorState, - newDerivedState: DerivedState, storedEditorState: EditorState, strategyState: StrategyState, strategy: StrategyWithFitness | null, @@ -439,7 +428,6 @@ function handleUserChangedStrategy( ): HandleStrategiesResult { const canvasState: InteractionCanvasState = pickCanvasStateFromEditorState( newEditorState, - newDerivedState, builtInDependencies, ) @@ -469,7 +457,6 @@ function handleUserChangedStrategy( ) const commandResult = foldAndApplyCommands( newEditorState, - newDerivedState, storedEditorState, strategyChangedLogCommands.flatMap((c) => c.commands), strategyResult.commands, @@ -510,7 +497,6 @@ function handleUserChangedStrategy( function handleAccumulatingKeypresses( builtInDependencies: BuiltInDependencies, newEditorState: EditorState, - newDerivedState: DerivedState, storedEditorState: EditorState, strategyState: StrategyState, strategy: StrategyWithFitness | null, @@ -519,7 +505,6 @@ function handleAccumulatingKeypresses( ): HandleStrategiesResult { const canvasState: InteractionCanvasState = pickCanvasStateFromEditorState( newEditorState, - newDerivedState, builtInDependencies, ) // If there is a current strategy, produce the commands from it. @@ -554,7 +539,6 @@ function handleAccumulatingKeypresses( : strategyApplicationResult([]) const commandResult = foldAndApplyCommands( updatedEditorState, - newDerivedState, storedEditorState, strategyState.currentStrategyCommands, strategyResult.commands, @@ -595,7 +579,6 @@ function handleAccumulatingKeypresses( function handleUpdate( builtInDependencies: BuiltInDependencies, newEditorState: EditorState, - newDerivedState: DerivedState, storedEditorState: EditorState, strategyState: StrategyState, strategy: StrategyWithFitness | null, @@ -604,7 +587,6 @@ function handleUpdate( ): HandleStrategiesResult { const canvasState: InteractionCanvasState = pickCanvasStateFromEditorState( newEditorState, - newDerivedState, builtInDependencies, ) // If there is a current strategy, produce the commands from it. @@ -621,7 +603,6 @@ function handleUpdate( : strategyApplicationResult([]) const commandResult = foldAndApplyCommands( newEditorState, - newDerivedState, storedEditorState, [], strategyResult.commands, diff --git a/editor/src/components/editor/store/editor-state.spec.ts b/editor/src/components/editor/store/editor-state.spec.ts index b0567eff698a..463cbbb9a0d9 100644 --- a/editor/src/components/editor/store/editor-state.spec.ts +++ b/editor/src/components/editor/store/editor-state.spec.ts @@ -2,7 +2,6 @@ import type { EditorState } from './editor-state' import { createEditorState, defaultModifyParseSuccess, - emptyDerivedState, modifyUnderlyingTargetElement, StoryboardFilePath, } from './editor-state' diff --git a/editor/src/components/editor/store/editor-state.ts b/editor/src/components/editor/store/editor-state.ts index 6e006823ace6..52c94d3273dd 100644 --- a/editor/src/components/editor/store/editor-state.ts +++ b/editor/src/components/editor/store/editor-state.ts @@ -2182,7 +2182,7 @@ export interface DerivedState { remixData: RemixDerivedData | null } -export function emptyDerivedState(editor: EditorState): DerivedState { +function emptyDerivedState(editor: EditorState): DerivedState { return { navigatorTargets: [], visibleNavigatorTargets: [], diff --git a/editor/src/components/editor/store/editor-update.tsx b/editor/src/components/editor/store/editor-update.tsx index dc0a78a83d6c..2a4be9d35072 100644 --- a/editor/src/components/editor/store/editor-update.tsx +++ b/editor/src/components/editor/store/editor-update.tsx @@ -1,5 +1,4 @@ import type { EditorState, DerivedState, UserState, EditorStoreUnpatched } from './editor-state' -import { deriveState } from './editor-state' import type { EditorAction, EditorDispatch, @@ -14,7 +13,6 @@ import type { UtopiaTsWorkers } from '../../../core/workers/common/worker-types' import type { UiJsxCanvasContextData } from '../../canvas/ui-jsx-canvas' import type { BuiltInDependencies } from '../../../core/es-modules/package-manager/built-in-dependencies-list' import { foldAndApplyCommandsSimple } from '../../canvas/commands/commands' -import { unpatchedCreateRemixDerivedDataMemo } from './remix-derived-data' export function runLocalEditorAction( state: EditorState, @@ -162,7 +160,7 @@ export function runSimpleLocalEditorAction( case 'SHOW_MODAL': return UPDATE_FNS.SHOW_MODAL(action, state) case 'RESET_PINS': - return UPDATE_FNS.RESET_PINS(action, state, derivedState) + return UPDATE_FNS.RESET_PINS(action, state) case 'SET_CURSOR_OVERLAY': return UPDATE_FNS.SET_CURSOR_OVERLAY(action, state) case 'SET_Z_INDEX': @@ -239,7 +237,7 @@ export function runSimpleLocalEditorAction( case 'SAVE_DOM_REPORT': return UPDATE_FNS.SAVE_DOM_REPORT(action, state, spyCollector) case 'TRUE_UP_GROUPS': - return UPDATE_FNS.TRUE_UP_GROUPS(state, derivedState) + return UPDATE_FNS.TRUE_UP_GROUPS(state) case 'SET_PROP': return UPDATE_FNS.SET_PROP(action, state) case 'SET_FILEBROWSER_RENAMING_TARGET': @@ -259,7 +257,7 @@ export function runSimpleLocalEditorAction( case 'OPEN_FLOATING_INSERT_MENU': return UPDATE_FNS.OPEN_FLOATING_INSERT_MENU(action, state) case 'UNWRAP_ELEMENTS': - return UPDATE_FNS.UNWRAP_ELEMENTS(action, state, dispatch, builtInDependencies, derivedState) + return UPDATE_FNS.UNWRAP_ELEMENTS(action, state, dispatch, builtInDependencies) case 'INSERT_IMAGE_INTO_UI': return UPDATE_FNS.INSERT_IMAGE_INTO_UI(action, state, derivedState) case 'UPDATE_JSX_ELEMENT_NAME': @@ -336,7 +334,7 @@ export function runSimpleLocalEditorAction( case 'CLOSE_FLOATING_INSERT_MENU': return UPDATE_FNS.CLOSE_FLOATING_INSERT_MENU(action, state) case 'INSERT_INSERTABLE': - return UPDATE_FNS.INSERT_INSERTABLE(action, state, derivedState) + return UPDATE_FNS.INSERT_INSERTABLE(action, state) case 'SET_PROP_TRANSIENT': return UPDATE_FNS.SET_PROP_TRANSIENT(action, state) case 'CLEAR_TRANSIENT_PROPS': @@ -358,7 +356,7 @@ export function runSimpleLocalEditorAction( case 'FORCE_PARSE_FILE': return UPDATE_FNS.FORCE_PARSE_FILE(action, state) case 'RUN_ESCAPE_HATCH': - return UPDATE_FNS.RUN_ESCAPE_HATCH(action, state, derivedState, builtInDependencies) + return UPDATE_FNS.RUN_ESCAPE_HATCH(action, state, builtInDependencies) case 'TOGGLE_SELECTION_LOCK': return UPDATE_FNS.TOGGLE_SELECTION_LOCK(action, state) case 'UPDATE_AGAINST_GITHUB': @@ -366,7 +364,7 @@ export function runSimpleLocalEditorAction( case 'SET_IMAGE_DRAG_SESSION_STATE': return UPDATE_FNS.SET_FILE_BROWSER_DRAG_STATE(action, state) case 'APPLY_COMMANDS': - return UPDATE_FNS.APPLY_COMMANDS(action, state, derivedState) + return UPDATE_FNS.APPLY_COMMANDS(action, state) case 'UPDATE_COLOR_SWATCHES': return UPDATE_FNS.UPDATE_COLOR_SWATCHES(action, state) case 'SET_CONDITIONAL_OVERRIDDEN_CONDITION': @@ -395,13 +393,6 @@ export function runExecuteWithPostActionMenuAction( working.postActionInteractionSession.editorStateSnapshot, ) - const derivedState = deriveState( - editorState, - null, - 'unpatched', - unpatchedCreateRemixDerivedDataMemo, - ) - const commands = action.choice.run( editorState, working.postActionInteractionSession.derivedStateSnapshot, @@ -412,7 +403,7 @@ export function runExecuteWithPostActionMenuAction( return working } - const newEditorState = foldAndApplyCommandsSimple(editorState, derivedState, commands) + const newEditorState = foldAndApplyCommandsSimple(editorState, commands) return { ...working, unpatchedEditor: newEditorState, diff --git a/editor/src/components/inspector/common/property-controls-hooks.spec.tsx b/editor/src/components/inspector/common/property-controls-hooks.spec.tsx index 8a9ae98ad1b9..2d4c377a181f 100644 --- a/editor/src/components/inspector/common/property-controls-hooks.spec.tsx +++ b/editor/src/components/inspector/common/property-controls-hooks.spec.tsx @@ -15,11 +15,7 @@ import type { EditorState, EditorStorePatched, } from '../../editor/store/editor-state' -import { - editorModelFromPersistentModel, - emptyDerivedState, - StoryboardFilePath, -} from '../../editor/store/editor-state' +import { editorModelFromPersistentModel, StoryboardFilePath } from '../../editor/store/editor-state' import { NO_OP } from '../../../core/shared/utils' import * as EP from '../../../core/shared/element-path' import type { ElementPath } from '../../../core/shared/project-file-types' @@ -204,7 +200,7 @@ function callPropertyControlsHook( const initialEditorStore: EditorStorePatched = { editor: editorState, - derived: emptyDerivedState(editorState), + derived: null as any, strategyState: null as any, history: null as any, userState: null as any,