@kubohiroya/turbowarp-plus-editor-workbench 0.11.0 → 0.11.1
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.
- package/dist/sprite-tabs.d.ts +3 -1
- package/dist/sprite-tabs.js +22 -17
- package/package.json +1 -1
- package/src/sprite-tabs.ts +27 -18
package/dist/sprite-tabs.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { NativeAssetPanel } from '@kubohiroya/turbowarp-plus-editor-sprite-panes/sprite-asset-pane';
|
|
3
|
-
import type { NativeAssetPanelRenderer, NativeAssetSelector, SpriteAssetKind, SpriteAssetLayout, SpriteAssetPreviewItem, SpriteVariable } from '@kubohiroya/turbowarp-plus-editor-sprite-panes/sprite-asset-pane';
|
|
3
|
+
import type { NativeAssetPanelRenderer, NativeAssetSelector, SpriteAssetKind, SpriteAssetLayout, SpriteAssetPreviewItem, SpriteVariable, SpriteVariablePaneProps } from '@kubohiroya/turbowarp-plus-editor-sprite-panes/sprite-asset-pane';
|
|
4
4
|
import type { SpritePropertiesPanelProps } from '@kubohiroya/turbowarp-plus-editor-sprite-panes/sprite-properties';
|
|
5
5
|
import type { SpriteSearchResult } from '@kubohiroya/turbowarp-plus-editor-sprite-panes/sprite-editor-toolbar';
|
|
6
6
|
import type { DockviewStagePane } from './dockview-stage.ts';
|
|
@@ -177,6 +177,8 @@ type SpriteTabsProps<Snapshot> = Omit<TabOptions<Snapshot>, 'activateSection' |
|
|
|
177
177
|
writeProperties?: SpritePropertiesPanelProps['onChange'];
|
|
178
178
|
writeVariable?(targetId: string, id: string, value: SpriteVariable['value']): void;
|
|
179
179
|
editVariable?(targetId: string, edit: SpriteVariableEdit): SpriteVariableEditError | void;
|
|
180
|
+
/** Wrap a variables pane while receiving its docked view and original target identities. */
|
|
181
|
+
wrapVariablePane?(viewId: string, targetId: string, editable: boolean, pane: React.ReactElement<SpriteVariablePaneProps>): React.ReactNode;
|
|
180
182
|
/** What this target sends and receives. `scanTargetMessages` builds it from the runtime. */
|
|
181
183
|
getMessages?(targetId: string): TargetMessages;
|
|
182
184
|
/** Open the block that sends or receives a message. */
|
package/dist/sprite-tabs.js
CHANGED
|
@@ -1481,7 +1481,7 @@ function SpriteTabs(props) {
|
|
|
1481
1481
|
props.openCodeSearchResult?.(view.targetId, result.id);
|
|
1482
1482
|
else if (section === 'variables') {
|
|
1483
1483
|
const field = assetPreviewSlots.find(slot => slot.id === view.id)?.element;
|
|
1484
|
-
[...(field?.querySelectorAll('
|
|
1484
|
+
[...(field?.querySelectorAll('[data-variable-id]') ?? [])]
|
|
1485
1485
|
.find(input => input.dataset.variableId === result.id)?.focus();
|
|
1486
1486
|
}
|
|
1487
1487
|
else if (section === 'messages') {
|
|
@@ -1505,22 +1505,27 @@ function SpriteTabs(props) {
|
|
|
1505
1505
|
workspace?.refreshSurfaces();
|
|
1506
1506
|
return result;
|
|
1507
1507
|
})
|
|
1508
|
-
}) : kind === 'variables' ?
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1508
|
+
}) : kind === 'variables' ? renderVariablePane(id, targetId, editable) :
|
|
1509
|
+
props.getAssetPreview && React.createElement(AssetPreview, {
|
|
1510
|
+
locale: props.locale, kind, selected, renderLayout, scrollTop, data: props.getAssetPreview(targetId, kind)
|
|
1511
|
+
}), element, id)));
|
|
1512
|
+
function renderVariablePane(id, targetId, editable) {
|
|
1513
|
+
const pane = React.createElement(SpriteAssetPane, {
|
|
1514
|
+
kind: 'variables', locale: props.locale, editable, variables: props.getVariables?.(targetId) ?? [],
|
|
1515
|
+
properties: props.getProperties?.(targetId),
|
|
1516
|
+
targetId,
|
|
1517
|
+
onWriteProperties(id, patch) {
|
|
1518
|
+
props.writeProperties?.(id, patch);
|
|
1519
|
+
workspace?.refreshSurfaces();
|
|
1520
|
+
},
|
|
1521
|
+
onWrite(variableId, value) {
|
|
1522
|
+
props.writeVariable?.(targetId, variableId, value);
|
|
1523
|
+
workspace?.refreshSurfaces();
|
|
1524
|
+
},
|
|
1525
|
+
onEdit: props.editVariable && (edit => props.editVariable(targetId, edit))
|
|
1526
|
+
});
|
|
1527
|
+
return props.wrapVariablePane?.(id, targetId, editable, pane) ?? pane;
|
|
1528
|
+
}
|
|
1524
1529
|
}
|
|
1525
1530
|
export function useSpriteTabs({ available, enabled, locale, ...props }) {
|
|
1526
1531
|
const controller = React.useRef(null);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubohiroya/turbowarp-plus-editor-workbench",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.1",
|
|
4
4
|
"description": "The TurboWarp Plus Editor workbench: layout, dockable sprite tabs, stage, debugger tab and file menu",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MPL-2.0",
|
package/src/sprite-tabs.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type {DockviewGroupPanel, GroupPanelPartInitParameters, IDockviewPanel, S
|
|
|
5
5
|
import {createSpriteLayoutMenu} from './sprite-layout-menu.ts';
|
|
6
6
|
import {NativeAssetPanel, SpriteAssetPane} from '@kubohiroya/turbowarp-plus-editor-sprite-panes/sprite-asset-pane';
|
|
7
7
|
import type {NativeAssetPanelRenderer, NativeAssetSelector, SpriteAssetKind, SpriteAssetLayout, SpriteAssetPreviewItem,
|
|
8
|
-
SpriteVariable} from '@kubohiroya/turbowarp-plus-editor-sprite-panes/sprite-asset-pane';
|
|
8
|
+
SpriteVariable, SpriteVariablePaneProps} from '@kubohiroya/turbowarp-plus-editor-sprite-panes/sprite-asset-pane';
|
|
9
9
|
import type {SpritePropertiesPanelProps} from '@kubohiroya/turbowarp-plus-editor-sprite-panes/sprite-properties';
|
|
10
10
|
import {SpriteEditorToolbar, spriteEditorSections} from '@kubohiroya/turbowarp-plus-editor-sprite-panes/sprite-editor-toolbar';
|
|
11
11
|
import type {SpriteSearchResult} from '@kubohiroya/turbowarp-plus-editor-sprite-panes/sprite-editor-toolbar';
|
|
@@ -1390,6 +1390,9 @@ type SpriteTabsProps<Snapshot> = Omit<TabOptions<Snapshot>, 'activateSection' |
|
|
|
1390
1390
|
writeProperties?: SpritePropertiesPanelProps['onChange'];
|
|
1391
1391
|
writeVariable?(targetId: string, id: string, value: SpriteVariable['value']): void;
|
|
1392
1392
|
editVariable?(targetId: string, edit: SpriteVariableEdit): SpriteVariableEditError | void;
|
|
1393
|
+
/** Wrap a variables pane while receiving its docked view and original target identities. */
|
|
1394
|
+
wrapVariablePane?(viewId: string, targetId: string, editable: boolean,
|
|
1395
|
+
pane: React.ReactElement<SpriteVariablePaneProps>): React.ReactNode;
|
|
1393
1396
|
/** What this target sends and receives. `scanTargetMessages` builds it from the runtime. */
|
|
1394
1397
|
getMessages?(targetId: string): TargetMessages;
|
|
1395
1398
|
/** Open the block that sends or receives a message. */
|
|
@@ -1577,7 +1580,7 @@ function SpriteTabs<Snapshot>(props: SpriteTabsProps<Snapshot>) {
|
|
|
1577
1580
|
if (section === 'code') props.openCodeSearchResult?.(view.targetId, result.id);
|
|
1578
1581
|
else if (section === 'variables') {
|
|
1579
1582
|
const field = assetPreviewSlots.find(slot => slot.id === view.id)?.element;
|
|
1580
|
-
[...(field?.querySelectorAll<
|
|
1583
|
+
[...(field?.querySelectorAll<HTMLElement>('[data-variable-id]') ?? [])]
|
|
1581
1584
|
.find(input => input.dataset.variableId === result.id)?.focus();
|
|
1582
1585
|
} else if (section === 'messages') {
|
|
1583
1586
|
const pane = assetPreviewSlots.find(slot => slot.id === view.id)?.element;
|
|
@@ -1598,22 +1601,28 @@ function SpriteTabs<Snapshot>(props: SpriteTabsProps<Snapshot>) {
|
|
|
1598
1601
|
if (!result) workspace?.refreshSurfaces();
|
|
1599
1602
|
return result;
|
|
1600
1603
|
})
|
|
1601
|
-
}) : kind === 'variables' ?
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
}
|
|
1615
|
-
|
|
1616
|
-
|
|
1604
|
+
}) : kind === 'variables' ? renderVariablePane(id, targetId, editable) :
|
|
1605
|
+
props.getAssetPreview && React.createElement(AssetPreview, {
|
|
1606
|
+
locale: props.locale, kind, selected, renderLayout, scrollTop, data: props.getAssetPreview(targetId, kind)
|
|
1607
|
+
}), element, id)));
|
|
1608
|
+
|
|
1609
|
+
function renderVariablePane(id: string, targetId: string, editable: boolean) {
|
|
1610
|
+
const pane = React.createElement<SpriteVariablePaneProps>(SpriteAssetPane, {
|
|
1611
|
+
kind: 'variables', locale: props.locale, editable, variables: props.getVariables?.(targetId) ?? [],
|
|
1612
|
+
properties: props.getProperties?.(targetId),
|
|
1613
|
+
targetId,
|
|
1614
|
+
onWriteProperties(id: string, patch: Parameters<SpritePropertiesPanelProps['onChange']>[1]) {
|
|
1615
|
+
props.writeProperties?.(id, patch);
|
|
1616
|
+
workspace?.refreshSurfaces();
|
|
1617
|
+
},
|
|
1618
|
+
onWrite(variableId, value) {
|
|
1619
|
+
props.writeVariable?.(targetId, variableId, value);
|
|
1620
|
+
workspace?.refreshSurfaces();
|
|
1621
|
+
},
|
|
1622
|
+
onEdit: props.editVariable && (edit => props.editVariable!(targetId, edit))
|
|
1623
|
+
});
|
|
1624
|
+
return props.wrapVariablePane?.(id, targetId, editable, pane) ?? pane;
|
|
1625
|
+
}
|
|
1617
1626
|
}
|
|
1618
1627
|
|
|
1619
1628
|
export function useSpriteTabs<Snapshot>({available, enabled, locale, ...props}:
|