|
@@ -1,23 +1,38 @@
|
|
|
import browser from 'webextension-polyfill';
|
|
|
+import { attachDebugger } from '../helper';
|
|
|
|
|
|
-export async function newWindow(block) {
|
|
|
- const { incognito, windowState } = block.data;
|
|
|
- const windowOptions = { incognito, state: windowState };
|
|
|
+export async function newWindow({ data, id }) {
|
|
|
+ const windowOptions = {
|
|
|
+ state: data.windowState,
|
|
|
+ incognito: data.incognito,
|
|
|
+ type: data.type || 'normal',
|
|
|
+ };
|
|
|
|
|
|
- if (windowState === 'normal') {
|
|
|
+ if (data.windowState === 'normal') {
|
|
|
['top', 'left', 'height', 'width'].forEach((key) => {
|
|
|
- if (block.data[key] <= 0) return;
|
|
|
+ if (data[key] <= 0) return;
|
|
|
|
|
|
- windowOptions[key] = block.data[key];
|
|
|
+ windowOptions[key] = data[key];
|
|
|
});
|
|
|
}
|
|
|
+ if (data.url) windowOptions.url = data.url;
|
|
|
+
|
|
|
+ const newWindowInstance = await browser.windows.create(windowOptions);
|
|
|
+ this.windowId = newWindowInstance.id;
|
|
|
+
|
|
|
+ if (data.url) {
|
|
|
+ const [tab] = newWindowInstance.tabs;
|
|
|
|
|
|
- const { id } = await browser.windows.create(windowOptions);
|
|
|
- this.windowId = id;
|
|
|
+ if (this.settings.debugMode)
|
|
|
+ await attachDebugger(tab.id, this.activeTab.id);
|
|
|
+
|
|
|
+ this.activeTab.id = tab.id;
|
|
|
+ this.activeTab.url = tab.url;
|
|
|
+ }
|
|
|
|
|
|
return {
|
|
|
- data: id,
|
|
|
- nextBlockId: this.getBlockConnections(block.id),
|
|
|
+ data: newWindowInstance.id,
|
|
|
+ nextBlockId: this.getBlockConnections(id),
|
|
|
};
|
|
|
}
|
|
|
|