Files
Foundry-VTT-Docker/resources/app/dist/database/documents/drawing.mjs
2025-01-04 00:34:03 +01:00

1 line
1.4 KiB
JavaScript

import BaseDrawing from"../../../common/documents/drawing.mjs";import ServerDocumentMixin from"../backend/server-document.mjs";export default class Drawing extends(ServerDocumentMixin(BaseDrawing)){static _migrationRegistry=[...super._migrationRegistry,{fn:migrateV10Fields,version:12},{fn:migrateNullValues,version:12},{fn:migrateInvisible,version:12},{fn:migrateInterface,version:"12.317"}]}function migrateV10Fields(t){const e={t:"r",f:"p"},i=Drawing._addDataFieldMigration(t,"type","shape.type",(t=>e[t.type]??t.type)),r=Drawing._addDataFieldMigration(t,"width","shape.width"),n=Drawing._addDataFieldMigration(t,"height","shape.height"),o=Drawing._addDataFieldMigration(t,"points","shape.points",(t=>Array.isArray(t.points)?t.points.flat():t.points));return i||r||n||o}function migrateNullValues(t){let e=!1;return null===t.fillColor&&(t.fillColor="#ffffff",e=!0),null===t.fontSize&&(t.fontSize=48,e=!0),null===t.strokeColor&&(t.strokeColor="#ffffff",e=!0),null===t.strokeWidth&&(t.strokeWidth=0,e=!0),null===t.textColor&&(t.textColor="#ffffff",e=!0),e}function migrateInvisible(t){let{text:e,textAlpha:i,fillType:r,fillAlpha:n,strokeWidth:o,strokeAlpha:a}=t;e??="",i??=1,r??=CONST.DRAWING_FILL_TYPES.NONE,n??=1,o??=8,a??=1;const l=""!==e&&i>0,f=r!==CONST.DRAWING_FILL_TYPES.NONE&&n>0;return!(l||f||o>0&&a>0)&&(t.strokeWidth=8,t.strokeColor="#ffffff",t.strokeAlpha=1,!0)}function migrateInterface(t){return t.interface=!!t.text,!0}