Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const [major, minor, patch] = extInfo.version.split(".");
nvim.set_client_info(extInfo.name,
{ major, minor, patch },
"ui",
{},
{},
);
await confReady;
nvim.ui_attach(cols, rows, {
ext_linegrid: true,
ext_messages: getConfForUrl(url).cmdline === "firenvim",
rgb: true,
});
let resizeReqId = 0;
browser.runtime.onMessage.addListener((request: any, sender: any, sendResponse: any) => {
if (request.selector === selector
&& request.funcName[0] === "resize"
&& request.args[0] > resizeReqId) {
const [id, width, height] = request.args;
resizeReqId = id;
// We need to put the keyHandler at the origin in order to avoid
// issues when it slips out of the viewport
keyHandler.style.left = `0px`;
keyHandler.style.top = `0px`;
// It's tempting to try to optimize this by only calling
// ui_try_resize when nCols is different from cols and nRows is
// different from rows but we can't because redraw notifications
// might happen without us actually calling ui_try_resize and then
// the sizes wouldn't be in sync anymore
const [cellWidth, cellHeight] = getCharSize(host);
const nCols = Math.floor(width / cellWidth);
mounted: function() {
this.snackbar = new MDCSnackbar(this.$refs.snackbar);
this.snackbar.foundation_.autoDismissTimeoutMs_ = 31556952000; // 1 year
this.snackbar.closeOnEscape = false;
browser.runtime.onMessage.addListener(this.onMessage);
browser.runtime.sendMessage({id: 'selectFrameId'});
}
};
const openTabLists = async () => {
const currentWindow = await browser.windows.getCurrent();
const windowId = currentWindow.id;
const tabs = await getAllInWindow(windowId);
let tabsRes = tabs.filter(i =>
browser.runtime.getURL('index.html#/app/') === i.url
|| browser.runtime.getURL('index.html#/app') === i.url
);
if (tabsRes.length === 0) {
await browser.tabs.create({url: browser.runtime.getURL('index.html#/app/')})
} else {
let latestTab = tabsRes.splice(tabsRes.length - 1, 1);
const tabIndex = tabs.findIndex(tab => tab.id === latestTab[0].id);
browser.tabs.highlight({windowId, tabs: tabIndex});
/*å…³é—其他tab*/
if (tabsRes.length !== 0) {
let ids = [];
tabsRes.map(i => ids.push(i.id));
browser.tabs.remove(ids);
}
}
};
async function sendMessage(message, options = {}) {
await browser.runtime
.sendMessage({
message: message,
...options
})
.catch(() => {});
}
const backgroundResponse = await fetchFromBackgroundScript({
...data,
type: clientEvent,
query: queryWithRequestId,
}) || {};
const {
data: {
validation,
},
} = backgroundResponse;
if (!validation.success) {
return null;
}
const port = browser.runtime.connect({ name: requestId });
port.onMessage.addListener(response => postToClientScript(requestId, {
response,
}));
port.postMessage({
type: contentSubscribeEvent,
});
const unsubscribe = () => port.postMessage({
type: contentUnsubscribeEvent,
});
return {
unsubscribe,
};
}
export function sendMessage(id, payload) {
return browser.runtime
.sendMessage(id, JSON.parse(JSON.stringify(payload)))
.then(response => {
if (response === undefined || response === null) {
return Promise.reject(
new NoResponseError(
`${Manager.getPlugin(id).name} plugin did not respond`
)
)
} else if (response.error) {
const error =
response.status === 'fatal'
? new FatalError(response.error)
: new Error(response.error)
error.sender = id
return Promise.reject(error)
} else {
import browser from 'webextension-polyfill'
import ExtensionPane from 'extension/src/lib/ExtenionPane'
const pane = new ExtensionPane()
browser.runtime.onMessage.addListener(msg => {
switch (msg.text) {
case 'toggle':
if (pane.isOpen) {
return pane.close()
}
return pane.open(msg)
case 'add':
return pane.add(msg)
case 'save-page':
if (pane.isOpen) {
return pane.saveCurrentPage()
}
return pane.open(msg)
default:
break
}
editRegion(request.rect, target => {
if (target) {
browser.runtime.sendMessage({
selectTarget: true,
target: [[target]],
selectNext: request.selectNext,
})
} else {
browser.runtime.sendMessage({
cancelSelectTarget: true,
selectNext: request.selectNext,
})
}
})
} else {
document.getElementById("disableFirenvim").addEventListener("click", () => {
browser.runtime.sendMessage( { funcName: ["toggleDisabled"] })
.then(updateDisableButton);
});
displayErrorsAndWarnings();
handleKeyDown = e => {
switch (e.key) {
case 'Escape':
browser.runtime.sendMessage({
key: 'closeSaka',
searchHistory: [...this.props.searchHistory]
});
break;
case 'Backspace':
if (ctrlKey(e)) {
e.preventDefault();
this.closeTab();
} else if (!e.repeat && e.target.value === '') {
browser.runtime.sendMessage({
key: 'closeSaka',
searchHistory: [...this.props.searchHistory]
});
}
break;
case 'ArrowLeft':
case 'ArrowRight':
break;
case 'ArrowDown':
e.preventDefault();
this.props.updateSearchHistory(this.state.searchString);
this.incrementSelectedIndex(1);
break;
case 'ArrowUp':
e.preventDefault();
this.props.updateSearchHistory(this.state.searchString);