@kubohiroya/turbowarp-plus-editor-workbench 0.6.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,6 +14,17 @@ export interface WindowPosition {left: number; top: number; width: number; heigh
14
14
  /** Panels that were open in one separate window when the layout was saved. */
15
15
  export interface SavedPopout {panels: string[]; position?: WindowPosition}
16
16
 
17
+ /** Coordinates along the drawer's available travel, with at least one axis at an edge. */
18
+ export interface StageDrawerPosition {x: number; y: number}
19
+
20
+ export interface StageDrawerLayout {
21
+ open: boolean;
22
+ /** Keep the drawer selected after it folds into the edge. */
23
+ selected: boolean;
24
+ position?: StageDrawerPosition;
25
+ width?: number;
26
+ }
27
+
17
28
  export interface WorkspaceLayout {
18
29
  version: 1;
19
30
  project: string;
@@ -21,6 +32,7 @@ export interface WorkspaceLayout {
21
32
  activeGroup: string;
22
33
  editingView?: string;
23
34
  panels: Record<string, PanelReference>;
35
+ stageDrawer?: StageDrawerLayout;
24
36
  /** Separate windows are restored docked; the user reopens each one. */
25
37
  popouts?: SavedPopout[];
26
38
  }
@@ -191,11 +203,27 @@ export function readWorkspaceLayout(raw: string, project?: string): WorkspaceLay
191
203
  if (editingView !== undefined && (!validId(editingView) || panels[editingView]?.kind !== 'sprite')) return;
192
204
  const popouts = readPopouts(input.popouts, panels);
193
205
  if (!popouts) return;
206
+ const stageDrawer = readStageDrawer(input.stageDrawer);
194
207
  return {version: 1, project: input.project, grid: {root, width, height, orientation}, activeGroup: input.activeGroup,
195
208
  editingView: typeof editingView === 'string' ? editingView : undefined, panels,
209
+ ...(stageDrawer && {stageDrawer}),
196
210
  ...(popouts.length && {popouts})};
197
211
  }
198
212
 
213
+ function readStageDrawer(input: unknown): StageDrawerLayout | undefined {
214
+ if (!record(input) || typeof input.open !== 'boolean' || typeof input.selected !== 'boolean') return;
215
+ const {position, width} = input;
216
+ const fraction = (value: unknown): value is number => size(value) && value <= 1;
217
+ const edge = (value: number) => value === 0 || value === 1;
218
+ return {
219
+ open: input.open,
220
+ selected: input.open || input.selected,
221
+ ...(size(width) && width > 0 && {width}),
222
+ ...(record(position) && fraction(position.x) && fraction(position.y) &&
223
+ (edge(position.x) || edge(position.y)) && {position: {x: position.x, y: position.y}})
224
+ };
225
+ }
226
+
199
227
  function readPopouts(input: unknown, panels: WorkspaceLayout['panels']): SavedPopout[] | undefined {
200
228
  if (input === undefined) return [];
201
229
  if (!Array.isArray(input) || input.length > limit) return;