@lvce-editor/ports-view 0.5.0 → 0.6.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.
- package/dist/portsViewWorkerMain.js +23 -0
- package/package.json +1 -1
|
@@ -1632,6 +1632,10 @@ const focusLast = state => {
|
|
|
1632
1632
|
return focusIndex(state, ports.length - 1);
|
|
1633
1633
|
};
|
|
1634
1634
|
|
|
1635
|
+
const getComponentState = uid => {
|
|
1636
|
+
return get(uid).newState;
|
|
1637
|
+
};
|
|
1638
|
+
|
|
1635
1639
|
const mergeClassNames = (...classNames) => {
|
|
1636
1640
|
return classNames.filter(Boolean).join(' ');
|
|
1637
1641
|
};
|
|
@@ -2569,6 +2573,23 @@ const resize = (state, dimensions) => {
|
|
|
2569
2573
|
});
|
|
2570
2574
|
};
|
|
2571
2575
|
|
|
2576
|
+
const applyComponentState = (currentState, state) => {
|
|
2577
|
+
if (!state || typeof state !== 'object' || Array.isArray(state)) {
|
|
2578
|
+
throw new TypeError('Ports state must be an object');
|
|
2579
|
+
}
|
|
2580
|
+
const {
|
|
2581
|
+
uid
|
|
2582
|
+
} = state;
|
|
2583
|
+
const {
|
|
2584
|
+
uid: currentUid
|
|
2585
|
+
} = currentState;
|
|
2586
|
+
if (uid !== currentUid) {
|
|
2587
|
+
throw new Error(`Ports state uid must remain ${currentUid}`);
|
|
2588
|
+
}
|
|
2589
|
+
return state;
|
|
2590
|
+
};
|
|
2591
|
+
const setComponentState = wrapCommand(applyComponentState);
|
|
2592
|
+
|
|
2572
2593
|
const toggleFocusedPort = state => {
|
|
2573
2594
|
const {
|
|
2574
2595
|
editing,
|
|
@@ -2594,6 +2615,7 @@ const commandMap = {
|
|
|
2594
2615
|
'Ports.focusNext': wrapCommand(focusNext),
|
|
2595
2616
|
'Ports.focusPrevious': wrapCommand(focusPrevious),
|
|
2596
2617
|
'Ports.getCommandIds': getCommandIds,
|
|
2618
|
+
'Ports.getComponentState': getComponentState,
|
|
2597
2619
|
'Ports.getKeyBindings': getKeyBindings,
|
|
2598
2620
|
'Ports.handleAddPortInput': wrapCommand(handleAddPortInput),
|
|
2599
2621
|
'Ports.handleAddPortKeyDown': wrapCommand(handleAddPortKeyDown),
|
|
@@ -2610,6 +2632,7 @@ const commandMap = {
|
|
|
2610
2632
|
'Ports.render2': render2,
|
|
2611
2633
|
'Ports.renderEventListeners': renderEventListeners,
|
|
2612
2634
|
'Ports.resize': wrapCommand(resize),
|
|
2635
|
+
'Ports.setComponentState': setComponentState,
|
|
2613
2636
|
'Ports.setDeltaY': wrapCommand(setDeltaY),
|
|
2614
2637
|
'Ports.setPorts': wrapCommand(setPorts),
|
|
2615
2638
|
'Ports.startAddPort': wrapCommand(startAddPort),
|