mirror of
https://github.com/tridactyl/tridactyl.git
synced 2026-09-10 07:16:33 -04:00
Remove commandline_background
This commit removes commandline_background.ts. I believe this is useful because the only thing it did was provide recvExStr, which just triggered a synthetic "onLine" event the only consumer of which was the parser. Since we already used controller_background + acceptExCmd in some places, it made sense to me to directly use controller_background + acceptExCmd everywhere.
This commit is contained in:
parent
3208b75a64
commit
85b3e33719
|
|
@ -54,7 +54,6 @@ Here's an example: you're writing the [`native()`](https://github.com/tridactyl/
|
|||
|
||||
### src/background/
|
||||
|
||||
- commandline_background.ts: A remnant of Tridactyl's previous architecture, where the command line was controlled from the background script. Not used much anymore besides for executing arbitrary ex commands.
|
||||
- config_rc.ts: Functions related to loading and executing the tridactylrc.
|
||||
- controller_background.ts: Parses and executes ex commands.
|
||||
- download_background.ts: Utility functions related to downloading that have to live in the background because downloading APIs aren't available to other processes.
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import * as perf from "@src/perf"
|
|||
import { listenForCounters } from "@src/perf"
|
||||
import * as messaging from "@src/lib/messaging"
|
||||
import * as excmds from "@src/.excmds_background.generated"
|
||||
import * as commandline_background from "@src/background/commandline_background"
|
||||
import * as convert from "@src/lib/convert"
|
||||
import * as config from "@src/lib/config"
|
||||
import * as dom from "@src/lib/dom"
|
||||
|
|
@ -23,7 +22,6 @@ import { AutoContain } from "@src/lib/autocontainers"
|
|||
;(window as any).tri = Object.assign(Object.create(null), {
|
||||
messaging,
|
||||
excmds,
|
||||
commandline_background,
|
||||
convert,
|
||||
config,
|
||||
dom,
|
||||
|
|
@ -57,10 +55,6 @@ browser.tabs.onActivated.addListener(ev => {
|
|||
}
|
||||
})
|
||||
})
|
||||
//
|
||||
|
||||
// Send commandline to controller
|
||||
commandline_background.onLine.addListener(BackgroundController.acceptExCmd)
|
||||
|
||||
// {{{ Clobber CSP
|
||||
|
||||
|
|
|
|||
|
|
@ -1,33 +0,0 @@
|
|||
import { activeTabId } from "@src/lib/webext"
|
||||
import * as Messaging from "@src/lib/messaging"
|
||||
|
||||
export type onLineCallback = (exStr: string) => void
|
||||
|
||||
/** CommandLine API for inclusion in background script
|
||||
|
||||
Receives messages from commandline_frame
|
||||
*/
|
||||
export const onLine = {
|
||||
addListener: function(cb: onLineCallback) {
|
||||
listeners.add(cb)
|
||||
return () => {
|
||||
listeners.delete(cb)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
const listeners = new Set<onLineCallback>()
|
||||
|
||||
/** Receive events from commandline_frame and pass to listeners */
|
||||
function recvExStr(exstr: string) {
|
||||
for (let listener of listeners) {
|
||||
listener(exstr)
|
||||
}
|
||||
}
|
||||
|
||||
Messaging.addListener(
|
||||
"commandline_background",
|
||||
Messaging.attributeCaller({
|
||||
recvExStr,
|
||||
}),
|
||||
)
|
||||
|
|
@ -136,11 +136,6 @@ export function focus() {
|
|||
clInput.addEventListener("blur", noblur)
|
||||
}
|
||||
|
||||
/** @hidden **/
|
||||
async function sendExstr(exstr) {
|
||||
Messaging.message("commandline_background", "recvExStr", [exstr])
|
||||
}
|
||||
|
||||
/** @hidden **/
|
||||
let HISTORY_SEARCH_STRING: string
|
||||
|
||||
|
|
@ -376,7 +371,7 @@ export function accept_line() {
|
|||
}
|
||||
cmdline_history_position = 0
|
||||
|
||||
sendExstr(command)
|
||||
return Messaging.message("controller_background", "acceptExCmd", [command])
|
||||
}
|
||||
|
||||
/** @hidden **/
|
||||
|
|
|
|||
|
|
@ -108,7 +108,6 @@ import { messageTab, messageActiveTab } from "@src/lib/messaging"
|
|||
import { flatten } from "@src/lib/itertools"
|
||||
import "@src/lib/number.mod"
|
||||
import { firefoxVersionAtLeast } from "@src/lib/webext"
|
||||
import * as CommandLineBackground from "@src/background/commandline_background"
|
||||
import * as rc from "@src/background/config_rc"
|
||||
import * as excmd_parser from "@src/parsers/exmode"
|
||||
import { mapstrToKeyseq } from "@src/lib/keyseq"
|
||||
|
|
@ -189,7 +188,7 @@ export async function rssexec(url: string, type?: string, ...title: string[]) {
|
|||
} else {
|
||||
rsscmd += " " + url
|
||||
}
|
||||
return Messaging.message("commandline_background", "recvExStr", [rsscmd])
|
||||
return Messaging.message("controller_background", "acceptExCmd", [rsscmd])
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1030,7 +1029,7 @@ export async function open(...urlarr: string[]) {
|
|||
// Setting window.location to about:blank results in a page we can't access, tabs.update works.
|
||||
if (!ABOUT_WHITELIST.includes(url) && url.match(/^(about|file):.*/)) {
|
||||
// Open URLs that firefox won't let us by running `firefox <URL>` on the command line
|
||||
p = Messaging.message("commandline_background", "recvExStr", ["nativeopen " + url])
|
||||
p = Messaging.message("controller_background", "acceptExCmd", ["nativeopen " + url])
|
||||
} else if (url.match(/^javascript:/)) {
|
||||
let bookmarklet = url.replace(/^javascript:/, "")
|
||||
;(document.body as any).append(
|
||||
|
|
@ -1068,7 +1067,7 @@ export async function open_quiet(...urlarr: string[]) {
|
|||
let p = Promise.resolve()
|
||||
|
||||
if (!ABOUT_WHITELIST.includes(url) && url.match(/^(about|file):.*/)) {
|
||||
return Messaging.message("commandline_background", "recvExStr", ["nativeopen " + url])
|
||||
return Messaging.message("controller_background", "acceptExCmd", ["nativeopen " + url])
|
||||
}
|
||||
|
||||
return ownTab().then(tab => openInTab(tab, { loadReplace: true }, urlarr))
|
||||
|
|
@ -1640,7 +1639,7 @@ export async function loadaucmds(cmdType: "DocStart" | "DocLoad" | "DocEnd" | "T
|
|||
const ausites = Object.keys(aucmds)
|
||||
const aukeyarr = ausites.filter(e => window.document.location.href.search(e) >= 0)
|
||||
for (let aukey of aukeyarr) {
|
||||
Messaging.message("commandline_background", "recvExStr", [aucmds[aukey]])
|
||||
Messaging.message("controller_background", "acceptExCmd", [aucmds[aukey]])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3452,17 +3451,6 @@ export function unset(...keys: string[]) {
|
|||
config.unset(...target)
|
||||
}
|
||||
|
||||
// not required as we automatically save all config
|
||||
////#background
|
||||
//export function saveconfig(){
|
||||
// config.save(config.get("storageloc"))
|
||||
//}
|
||||
|
||||
////#background
|
||||
//export function mktridactylrc(){
|
||||
// saveconfig()
|
||||
//}
|
||||
|
||||
// }}}
|
||||
|
||||
// {{{ HINTMODE
|
||||
|
|
@ -3806,7 +3794,7 @@ export async function hint(option?: string, selectors?: string, ...rest: string[
|
|||
*/
|
||||
//#content
|
||||
export function run_exstr(...commands: string[]) {
|
||||
return Messaging.message("commandline_background", "recvExStr", commands)
|
||||
return Messaging.message("controller_background", "acceptExCmd", commands)
|
||||
}
|
||||
|
||||
// }}}
|
||||
|
|
|
|||
|
|
@ -130,8 +130,8 @@ function addSettingInputs() {
|
|||
let input = ev.target
|
||||
if (ev.key == "Enter") {
|
||||
;(window as any).tri.messaging.message(
|
||||
"commandline_background",
|
||||
"recvExStr",
|
||||
"controller_background",
|
||||
"acceptExCmd",
|
||||
["set " + input.name + " " + input.value],
|
||||
)
|
||||
} else {
|
||||
|
|
@ -198,7 +198,7 @@ function addResetConfigButton() {
|
|||
)
|
||||
if (p == sentence) {
|
||||
;(window as any).tri.messaging
|
||||
.message("commandline_background", "recvExStr", [sentence])
|
||||
.message("controller_background", "acceptExCmd", [sentence])
|
||||
.then(_ => alert("Config reset!"))
|
||||
} else {
|
||||
alert(`Config not reset because '${p}' != '${sentence}'`)
|
||||
|
|
|
|||
|
|
@ -52,8 +52,8 @@ export class Logger {
|
|||
}
|
||||
if (getContext() == "content")
|
||||
return browser.runtime.sendMessage({
|
||||
type: "commandline_background",
|
||||
command: "recvExStr",
|
||||
type: "controller_background",
|
||||
command: "acceptExCmd",
|
||||
args: ["fillcmdline # " + message.join(" ")],
|
||||
})
|
||||
else
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ export type TabMessageType =
|
|||
| "commandline_frame"
|
||||
export type NonTabMessageType =
|
||||
| "owntab_background"
|
||||
| "commandline_background"
|
||||
| "controller_background"
|
||||
| "browser_proxy_background"
|
||||
| "download_background"
|
||||
|
|
|
|||
Loading…
Reference in a new issue