Deprecate GetCircularReplacer and make GetCircularReplacer dotnet by default. Format of the save is now incompatible with old versions.
This commit is contained in:
parent
6786417349
commit
621dc9b53f
6 changed files with 19 additions and 43 deletions
|
@ -1,6 +1,8 @@
|
|||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
import { FindContainerById, MakeDFSIterator } from './itertools';
|
||||
import { IEditorState } from '../Interfaces/IEditorState';
|
||||
import { IHistoryState } from '../Interfaces/IHistoryState';
|
||||
import { IContainerModel } from '../Interfaces/IContainerModel';
|
||||
|
||||
/**
|
||||
* Revive the Editor state
|
||||
|
@ -32,7 +34,9 @@ export function ReviveState(state: IHistoryState): void {
|
|||
for (const symbol of state.symbols.values()) {
|
||||
symbol.linkedContainers = new Set(symbol.linkedContainers);
|
||||
}
|
||||
state.containers = new Map(state.containers);
|
||||
|
||||
const containers: Array<{ Key: string, Value: IContainerModel }> = (state.containers) as any;
|
||||
state.containers = new Map(containers.map(({ Key, Value }: {Key: string, Value: IContainerModel}) => [Key, Value]));
|
||||
|
||||
const root = FindContainerById(state.containers, state.mainContainer);
|
||||
|
||||
|
@ -64,43 +68,13 @@ export function GetCircularReplacer(): (key: any, value: object | Map<string, an
|
|||
}
|
||||
|
||||
if (key === 'containers') {
|
||||
return Array.from((value as Map<string, any>).entries());
|
||||
return [...(value as Map<string, any>).entries()]
|
||||
.map(([Key, Value]: [string, any]) => ({ Key, Value }));
|
||||
}
|
||||
|
||||
if (key === 'symbols') {
|
||||
return Array.from((value as Map<string, any>).entries());
|
||||
}
|
||||
|
||||
if (key === 'linkedContainers') {
|
||||
return Array.from(value as Set<string>);
|
||||
}
|
||||
|
||||
return value;
|
||||
};
|
||||
}
|
||||
|
||||
export function GetCircularReplacerToDotnet(): (key: any, value: object | Map<string, any> | null) => object | null | undefined {
|
||||
return (key: any, value: object | null) => {
|
||||
if (key === 'parent') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (key === 'containers') {
|
||||
return [...(value as Map<string, any>).entries()].map((keyPair: [string, any]) => {
|
||||
return {
|
||||
Key: keyPair[0],
|
||||
Value: keyPair[1]
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
if (key === 'symbols') {
|
||||
return [...(value as Map<string, any>).entries()].map((keyPair: [string, any]) => {
|
||||
return {
|
||||
Key: keyPair[0],
|
||||
Value: keyPair[1]
|
||||
};
|
||||
});
|
||||
return [...(value as Map<string, any>).entries()]
|
||||
.map(([Key, Value]: [string, any]) => ({ Key, Value }));
|
||||
}
|
||||
|
||||
if (key === 'linkedContainers') {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue