diff --git a/es/features/runningTree.d.ts b/es/features/runningTree.d.ts index a9822429..1e187f16 100644 --- a/es/features/runningTree.d.ts +++ b/es/features/runningTree.d.ts @@ -159,7 +159,7 @@ declare class ListNode, ids: string[], action?: ED[T]['Action']): void; - composeOperations(includeModiBranch?: boolean): Array<{ + composeOperations(paths?: string[]): Array<{ entity: keyof ED; operation: ED[keyof ED]['Operation']; }> | undefined; @@ -219,10 +219,10 @@ declare class SingleNode | undefined; @@ -257,7 +257,7 @@ declare class VirtualNode extends Node; - composeOperations(includeModiBranch?: boolean): Array<{ + composeOperations(paths?: string[]): Array<{ entity: keyof ED; operation: ED[keyof ED]['Operation']; }> | undefined; @@ -291,7 +291,7 @@ export declare class RunningTree extends private findNode; destroyNode(path: string, isPage: boolean): void; begin(): () => void; - redoBranchOperations(path: string, allowInTxn?: boolean): void; + redoBranchOperations(path: string): void; redoBranchModis(path: string): void; getFreshValue(path: string): Partial | Partial[] | undefined; isDirty(path: string): boolean; diff --git a/es/features/runningTree.js b/es/features/runningTree.js index b5a6048b..7a130ca4 100644 --- a/es/features/runningTree.js +++ b/es/features/runningTree.js @@ -830,14 +830,15 @@ class ListNode extends EntityNode { ids.forEach((id) => this.updateItemInner(lsn, data, id, action)); this.setDirty(); } - composeOperations(includeModiBranch) { + composeOperations(paths) { if (!this.dirty) { return; } const intrinsticFilter = this.getIntrinsticFilters(); const ulmLsn = this.ulManager.maxLsn; + paths?.shift(); for (const id in this.children) { - const childOperations = this.children[id].composeOperations(includeModiBranch); + const childOperations = this.children[id].composeOperations(paths); if (childOperations) { childOperations.forEach((childOperation) => this.ulManager.push(ulmLsn + 100, childOperation.operation)); } @@ -1320,20 +1321,20 @@ class SingleNode extends EntityNode { } /** * - * @param includeModiBranch 如果显式置了boolean,代表只要考虑前项路径或者后项路径 + * @param path 如果指定了某条路径,则只处理这条路径上的operation(区分modi的前后项) * @returns */ - composeOperations(includeModiBranch) { + composeOperations(paths) { if (this.dirty) { const lsnMax = this.ulManager.maxLsn; + const path = paths?.shift(); for (const ele in this.children) { - if (ele.includes(MODI_NEXT_PATH_SUFFIX) && false === includeModiBranch || - (!ele.includes(MODI_NEXT_PATH_SUFFIX) && true === includeModiBranch)) { + if (path && path !== ele) { continue; } const ele2 = ele.includes(':') ? ele.slice(0, ele.indexOf(':')) : ele; const child = this.children[ele]; - const childOperations = child.composeOperations(includeModiBranch); + const childOperations = child.composeOperations(paths?.length ? paths : undefined); if (childOperations) { if (child instanceof SingleNode) { assert(childOperations.length === 1); @@ -1696,18 +1697,18 @@ class VirtualNode extends Node { throw err; } } - composeOperations(includeModiBranch) { + composeOperations(paths) { /** * 当一个virtualNode有多个子结点,而这些子结点的前缀一致时,标识这些子结点其实是指向同一个对象,此时需要合并 */ const operationss = []; const operationDict = {}; + const path = paths?.shift(); for (const ele in this.children) { - if (ele.includes(MODI_NEXT_PATH_SUFFIX) && false === includeModiBranch || - (!ele.includes(MODI_NEXT_PATH_SUFFIX) && true === includeModiBranch)) { + if (path && path !== ele) { continue; } - const operation = this.children[ele].composeOperations(includeModiBranch); + const operation = this.children[ele].composeOperations(paths?.length ? paths : undefined); if (operation) { const idx = ele.indexOf(':') !== -1 ? ele.slice(0, ele.indexOf(':')) : ele; if (operationDict[idx]) { @@ -1952,10 +1953,11 @@ export class RunningTree extends Feature { begin() { return this.cache.begin(); } - redoBranchOperations(path, allowInTxn) { - const { root } = analyzePath(path); + redoBranchOperations(path) { + const paths = path.split('.'); + const root = paths.shift(); const rootNode = this.root[root]; - const opers = rootNode.composeOperations(path.includes(MODI_NEXT_PATH_SUFFIX)); + const opers = rootNode.composeOperations(paths); if (opers) { this.cache.redoOperation(opers); } diff --git a/lib/features/runningTree.d.ts b/lib/features/runningTree.d.ts index a9822429..1e187f16 100644 --- a/lib/features/runningTree.d.ts +++ b/lib/features/runningTree.d.ts @@ -159,7 +159,7 @@ declare class ListNode, ids: string[], action?: ED[T]['Action']): void; - composeOperations(includeModiBranch?: boolean): Array<{ + composeOperations(paths?: string[]): Array<{ entity: keyof ED; operation: ED[keyof ED]['Operation']; }> | undefined; @@ -219,10 +219,10 @@ declare class SingleNode | undefined; @@ -257,7 +257,7 @@ declare class VirtualNode extends Node; - composeOperations(includeModiBranch?: boolean): Array<{ + composeOperations(paths?: string[]): Array<{ entity: keyof ED; operation: ED[keyof ED]['Operation']; }> | undefined; @@ -291,7 +291,7 @@ export declare class RunningTree extends private findNode; destroyNode(path: string, isPage: boolean): void; begin(): () => void; - redoBranchOperations(path: string, allowInTxn?: boolean): void; + redoBranchOperations(path: string): void; redoBranchModis(path: string): void; getFreshValue(path: string): Partial | Partial[] | undefined; isDirty(path: string): boolean; diff --git a/lib/features/runningTree.js b/lib/features/runningTree.js index 784f8ce2..5d0877a6 100644 --- a/lib/features/runningTree.js +++ b/lib/features/runningTree.js @@ -833,14 +833,15 @@ class ListNode extends EntityNode { ids.forEach((id) => this.updateItemInner(lsn, data, id, action)); this.setDirty(); } - composeOperations(includeModiBranch) { + composeOperations(paths) { if (!this.dirty) { return; } const intrinsticFilter = this.getIntrinsticFilters(); const ulmLsn = this.ulManager.maxLsn; + paths?.shift(); for (const id in this.children) { - const childOperations = this.children[id].composeOperations(includeModiBranch); + const childOperations = this.children[id].composeOperations(paths); if (childOperations) { childOperations.forEach((childOperation) => this.ulManager.push(ulmLsn + 100, childOperation.operation)); } @@ -1323,20 +1324,20 @@ class SingleNode extends EntityNode { } /** * - * @param includeModiBranch 如果显式置了boolean,代表只要考虑前项路径或者后项路径 + * @param path 如果指定了某条路径,则只处理这条路径上的operation(区分modi的前后项) * @returns */ - composeOperations(includeModiBranch) { + composeOperations(paths) { if (this.dirty) { const lsnMax = this.ulManager.maxLsn; + const path = paths?.shift(); for (const ele in this.children) { - if (ele.includes(exports.MODI_NEXT_PATH_SUFFIX) && false === includeModiBranch || - (!ele.includes(exports.MODI_NEXT_PATH_SUFFIX) && true === includeModiBranch)) { + if (path && path !== ele) { continue; } const ele2 = ele.includes(':') ? ele.slice(0, ele.indexOf(':')) : ele; const child = this.children[ele]; - const childOperations = child.composeOperations(includeModiBranch); + const childOperations = child.composeOperations(paths?.length ? paths : undefined); if (childOperations) { if (child instanceof SingleNode) { (0, assert_1.assert)(childOperations.length === 1); @@ -1699,18 +1700,18 @@ class VirtualNode extends Node { throw err; } } - composeOperations(includeModiBranch) { + composeOperations(paths) { /** * 当一个virtualNode有多个子结点,而这些子结点的前缀一致时,标识这些子结点其实是指向同一个对象,此时需要合并 */ const operationss = []; const operationDict = {}; + const path = paths?.shift(); for (const ele in this.children) { - if (ele.includes(exports.MODI_NEXT_PATH_SUFFIX) && false === includeModiBranch || - (!ele.includes(exports.MODI_NEXT_PATH_SUFFIX) && true === includeModiBranch)) { + if (path && path !== ele) { continue; } - const operation = this.children[ele].composeOperations(includeModiBranch); + const operation = this.children[ele].composeOperations(paths?.length ? paths : undefined); if (operation) { const idx = ele.indexOf(':') !== -1 ? ele.slice(0, ele.indexOf(':')) : ele; if (operationDict[idx]) { @@ -1955,10 +1956,11 @@ class RunningTree extends Feature_1.Feature { begin() { return this.cache.begin(); } - redoBranchOperations(path, allowInTxn) { - const { root } = analyzePath(path); + redoBranchOperations(path) { + const paths = path.split('.'); + const root = paths.shift(); const rootNode = this.root[root]; - const opers = rootNode.composeOperations(path.includes(exports.MODI_NEXT_PATH_SUFFIX)); + const opers = rootNode.composeOperations(paths); if (opers) { this.cache.redoOperation(opers); } diff --git a/src/features/runningTree.ts b/src/features/runningTree.ts index bfb4ac61..0f589c88 100644 --- a/src/features/runningTree.ts +++ b/src/features/runningTree.ts @@ -1039,7 +1039,7 @@ class ListNode< this.setDirty(); } - composeOperations(includeModiBranch?: boolean): + composeOperations(paths?: string[]): | Array<{ entity: keyof ED; operation: ED[keyof ED]['Operation'] }> | undefined { if (!this.dirty) { @@ -1049,8 +1049,9 @@ class ListNode< const intrinsticFilter = this.getIntrinsticFilters(); const ulmLsn = this.ulManager.maxLsn; + paths?.shift(); for (const id in this.children) { - const childOperations = this.children[id].composeOperations(includeModiBranch); + const childOperations = this.children[id].composeOperations(paths); if (childOperations) { childOperations.forEach( (childOperation) => this.ulManager.push(ulmLsn + 100, childOperation.operation as any) @@ -1619,23 +1620,23 @@ class SingleNode | undefined { if (this.dirty) { const lsnMax = this.ulManager.maxLsn; + const path = paths?.shift(); for (const ele in this.children) { - if (ele.includes(MODI_NEXT_PATH_SUFFIX) && false === includeModiBranch || - (!ele.includes(MODI_NEXT_PATH_SUFFIX) && true === includeModiBranch)) { + if (path && path !== ele) { continue; } const ele2 = ele.includes(':') ? ele.slice(0, ele.indexOf(':')) : ele; const child = this.children[ele]; - const childOperations = child!.composeOperations(includeModiBranch); + const childOperations = child!.composeOperations(paths?.length ? paths : undefined); if (childOperations) { if (child instanceof SingleNode) { assert(childOperations.length === 1); @@ -2031,18 +2032,18 @@ class VirtualNode extends Node { throw err; } } - composeOperations(includeModiBranch?: boolean): Array<{ entity: keyof ED, operation: ED[keyof ED]['Operation'] }> | undefined { + composeOperations(paths?: string[]): Array<{ entity: keyof ED, operation: ED[keyof ED]['Operation'] }> | undefined { /** * 当一个virtualNode有多个子结点,而这些子结点的前缀一致时,标识这些子结点其实是指向同一个对象,此时需要合并 */ const operationss = []; const operationDict: Record = {}; + const path = paths?.shift(); for (const ele in this.children) { - if (ele.includes(MODI_NEXT_PATH_SUFFIX) && false === includeModiBranch || - (!ele.includes(MODI_NEXT_PATH_SUFFIX) && true === includeModiBranch)) { + if (path && path !== ele) { continue; } - const operation = this.children[ele].composeOperations(includeModiBranch); + const operation = this.children[ele].composeOperations(paths?.length ? paths : undefined); if (operation) { const idx = ele.indexOf(':') !== -1 ? ele.slice(0, ele.indexOf(':')) : ele; if (operationDict[idx]) { @@ -2361,11 +2362,12 @@ export class RunningTree extends Feature return this.cache.begin()!; } - redoBranchOperations(path: string, allowInTxn?: boolean) { - const { root } = analyzePath(path); + redoBranchOperations(path: string) { + const paths = path.split('.'); + const root = paths.shift(); - const rootNode = this.root[root]; - const opers = rootNode.composeOperations(path.includes(MODI_NEXT_PATH_SUFFIX)); + const rootNode = this.root[root!]; + const opers = rootNode.composeOperations(paths); if (opers) { this.cache.redoOperation(opers); }