Skip to content

Commit

Permalink
Remove inputSize in save files
Browse files Browse the repository at this point in the history
  • Loading branch information
RunDevelopment committed Oct 16, 2023
1 parent 2235515 commit d762c94
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 462 deletions.
23 changes: 11 additions & 12 deletions src/common/migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
NodeData,
OutputId,
SchemaId,
Size,
} from './common-types';
import { log } from './log';
import { legacyMigrations } from './migrations-legacy';
Expand Down Expand Up @@ -1352,20 +1353,18 @@ const writeOutputFrame: ModernMigration = (data) => {
};

const separateNodeWidthAndInputHeight: ModernMigration = (data) => {
const hasInputSize = (
nodeData: Mutable<ReadonlyNodeData>
): nodeData is Mutable<ReadonlyNodeData> & {
inputSize?: Record<InputId, Size>;
} => 'inputSize' in nodeData;

data.nodes.forEach((node) => {
let maxWidth = 0;
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
if (node.data.inputSize) {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const inputSize = node.data.inputSize as Record<
InputId,
{ height: number; width: number }
>;
if (!node.data.inputHeight) {
node.data.inputHeight = {};
}
if (hasInputSize(node.data)) {
const inputSize = node.data.inputSize!;
delete node.data.inputSize;
node.data.inputHeight ??= {};
for (const [inputId, { width, height }] of Object.entries(inputSize)) {
maxWidth = Math.max(maxWidth, width);
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
Expand Down
Loading

0 comments on commit d762c94

Please sign in to comment.