diff --git a/app/client/package.json b/app/client/package.json index 91f497ea9d..185ff7a7bd 100644 --- a/app/client/package.json +++ b/app/client/package.json @@ -146,6 +146,7 @@ "marked": "^4.0.18", "memoize-one": "^6.0.0", "micro-memoize": "^4.0.10", + "microdiff": "^1.4.0", "moment": "2.29.4", "moment-timezone": "^0.5.35", "nanoid": "^2.0.4", diff --git a/app/client/src/ce/workers/Evaluation/evaluationUtils.ts b/app/client/src/ce/workers/Evaluation/evaluationUtils.ts index 1df27bf905..344afcb72e 100644 --- a/app/client/src/ce/workers/Evaluation/evaluationUtils.ts +++ b/app/client/src/ce/workers/Evaluation/evaluationUtils.ts @@ -992,3 +992,30 @@ export const isNotEntity = (entity: DataTreeEntity) => { export const isEntityAction = (entity: DataTreeEntity) => { return isAction(entity); }; +export const convertMicroDiffToDeepDiff = ( + microDiffDifferences: Record[], +) => + microDiffDifferences.map((v: Record) => { + const { oldValue, path, type, value } = v; + //convert microDiff format to deepDiff format + if (type === "CREATE") { + return { + kind: "N", + path, + rhs: value, + }; + } + if (type === "REMOVE") { + return { + kind: "D", + path, + lhs: oldValue, + }; + } + return { + kind: "E", + path, + lhs: oldValue, + rhs: value, + }; + }); diff --git a/app/client/src/workers/common/DataTreeEvaluator/index.ts b/app/client/src/workers/common/DataTreeEvaluator/index.ts index 100d955ae0..c8c9f5c233 100644 --- a/app/client/src/workers/common/DataTreeEvaluator/index.ts +++ b/app/client/src/workers/common/DataTreeEvaluator/index.ts @@ -37,6 +37,7 @@ import type { import { EvaluationSubstitutionType } from "entities/DataTree/dataTreeFactory"; import { ENTITY_TYPE } from "@appsmith/entities/DataTree/types"; import type { DataTreeDiff } from "@appsmith/workers/Evaluation/evaluationUtils"; +import { convertMicroDiffToDeepDiff } from "@appsmith/workers/Evaluation/evaluationUtils"; import { addDependantsOfNestedPropertyPaths, @@ -127,6 +128,7 @@ import { DependencyMapUtils } from "entities/DependencyMap/DependencyMapUtils"; import { isWidgetActionOrJsObject } from "@appsmith/entities/DataTree/utils"; import DataStore from "workers/Evaluation/dataStore"; import { updateTreeWithData } from "workers/Evaluation/dataStore/utils"; +import microDiff from "microdiff"; import { profileFn, type WebworkerSpanData, @@ -501,7 +503,6 @@ export default class DataTreeEvaluator { //get difference in js collection body to be parsed const oldUnEvalTreeJSCollections = getJSEntities(this.oldUnEvalTree); const localUnEvalTreeJSCollection = getJSEntities(localUnEvalTree); - const jsDifferences: Diff< Record, Record @@ -509,12 +510,13 @@ export default class DataTreeEvaluator { "SetupUpdateTree.Diff1", undefined, webworkerTelemetry, - () => { - return ( - diff(oldUnEvalTreeJSCollections, localUnEvalTreeJSCollection) || [] - ); - }, + () => + convertMicroDiffToDeepDiff( + microDiff(oldUnEvalTreeJSCollections, localUnEvalTreeJSCollection) || + [], + ), ); + const jsTranslatedDiffs = flatten( jsDifferences.map((diff) => translateDiffEventToDataTreeDiffEvent(diff, localUnEvalTree), diff --git a/app/client/yarn.lock b/app/client/yarn.lock index b0b1b6c1e1..8f5471a465 100644 --- a/app/client/yarn.lock +++ b/app/client/yarn.lock @@ -13314,6 +13314,7 @@ __metadata: marked: ^4.0.18 memoize-one: ^6.0.0 micro-memoize: ^4.0.10 + microdiff: ^1.4.0 moment: 2.29.4 moment-timezone: ^0.5.35 msw: ^0.28.0 @@ -24707,6 +24708,13 @@ __metadata: languageName: node linkType: hard +"microdiff@npm:^1.4.0": + version: 1.4.0 + resolution: "microdiff@npm:1.4.0" + checksum: 4cae2ec4d0540b65656837a7c47a17d6428a1be2909d268a579921183c9c21a86e0dfa0c8ade8c60f9127887783a17d54ce7be16d5556708a0e58312bca8803d + languageName: node + linkType: hard + "micromatch@npm:4.0.5, micromatch@npm:^4.0.0, micromatch@npm:^4.0.2, micromatch@npm:^4.0.4, micromatch@npm:^4.0.5": version: 4.0.5 resolution: "micromatch@npm:4.0.5"