{"action":"created","comment":{"url":"https://api.github.com/repos/tridactyl/tridactyl/pulls/comments/280998469","pull_request_review_id":233754563,"id":280998469,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI4MDk5ODQ2OQ==","diff_hunk":"@@ -0,0 +1,6 @@\n+import * as excmd_lib from \"@src/lib/excmd_lib\"\n+import * as _excmds from \"@src/excmds/_open\"\n+type ft = typeof _excmds","path":"src/excmds/open.ts","position":null,"original_position":3,"commit_id":"c272292789f042480fb54979bf9e585afac34d78","original_commit_id":"7720a205d062f9a4af548b5e9965898a9f9ee5b9","user":{"login":"saulrh","id":560724,"node_id":"MDQ6VXNlcjU2MDcyNA==","avatar_url":"https://avatars0.githubusercontent.com/u/560724?v=4","gravatar_id":"","url":"https://api.github.com/users/saulrh","html_url":"https://github.com/saulrh","followers_url":"https://api.github.com/users/saulrh/followers","following_url":"https://api.github.com/users/saulrh/following{/other_user}","gists_url":"https://api.github.com/users/saulrh/gists{/gist_id}","starred_url":"https://api.github.com/users/saulrh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saulrh/subscriptions","organizations_url":"https://api.github.com/users/saulrh/orgs","repos_url":"https://api.github.com/users/saulrh/repos","events_url":"https://api.github.com/users/saulrh/events{/privacy}","received_events_url":"https://api.github.com/users/saulrh/received_events","type":"User","site_admin":false},"body":"Though... I don't know if there's anything that says that that function has to be the actual entry point, so we could still move to a more declarative `excmds.ts` by building a script that loads all of the declarations and generates a skeleton with empty functions with appropriate signatures for typedoc...\r\n\r\nThat's kind of disgusting. I should go look into documentation tools that are less tightly coupled to the source language. Or maybe I can find some hook into typedoc that will let me convince it that an excmd declaration is actually a function...","created_at":"2019-05-04T23:32:30Z","updated_at":"2019-05-04T23:32:30Z","html_url":"https://github.com/tridactyl/tridactyl/pull/1502#discussion_r280998469","pull_request_url":"https://api.github.com/repos/tridactyl/tridactyl/pulls/1502","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/tridactyl/tridactyl/pulls/comments/280998469"},"html":{"href":"https://github.com/tridactyl/tridactyl/pull/1502#discussion_r280998469"},"pull_request":{"href":"https://api.github.com/repos/tridactyl/tridactyl/pulls/1502"}},"in_reply_to_id":279070400},"pull_request":{"url":"https://api.github.com/repos/tridactyl/tridactyl/pulls/1502","id":273459043,"node_id":"MDExOlB1bGxSZXF1ZXN0MjczNDU5MDQz","html_url":"https://github.com/tridactyl/tridactyl/pull/1502","diff_url":"https://github.com/tridactyl/tridactyl/pull/1502.diff","patch_url":"https://github.com/tridactyl/tridactyl/pull/1502.patch","issue_url":"https://api.github.com/repos/tridactyl/tridactyl/issues/1502","number":1502,"state":"open","locked":false,"title":"Start factoring excmd implementations out into libraries","user":{"login":"saulrh","id":560724,"node_id":"MDQ6VXNlcjU2MDcyNA==","avatar_url":"https://avatars0.githubusercontent.com/u/560724?v=4","gravatar_id":"","url":"https://api.github.com/users/saulrh","html_url":"https://github.com/saulrh","followers_url":"https://api.github.com/users/saulrh/followers","following_url":"https://api.github.com/users/saulrh/following{/other_user}","gists_url":"https://api.github.com/users/saulrh/gists{/gist_id}","starred_url":"https://api.github.com/users/saulrh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saulrh/subscriptions","organizations_url":"https://api.github.com/users/saulrh/orgs","repos_url":"https://api.github.com/users/saulrh/repos","events_url":"https://api.github.com/users/saulrh/events{/privacy}","received_events_url":"https://api.github.com/users/saulrh/received_events","type":"User","site_admin":false},"body":"This is a proof-of-concept for a refactor that will allow us to kill `excmd_macros.py`. We use Proxy objects to built wrappers that automatically forward commands to the right context. This _should_ duplicate the functionality of the mangling in  `excmd_macros.py`. Once all of the excmds have been migrated we can ditch that mangling altogether.\r\n\r\nBeyond the long-awaited death of `excmd_macros.py`, this should refactor should generally reduce friction throughout tridactyl. Many of our excmds (e.g. `:tabopen`) are called frequently from typescript; the signatures of excmds are heavily constrained in ways that make them difficult to call from typescript. Extracting typescript-native implementations of these excmds will allow us to use things like actual types, dramatically improving code ergonomics. Additionally, much of our functionality was in the exmcds file becuase it was the easiest way to get transparent multi-context operation and becuase importing excmds into another file just to get a single function was... not pretty. This refactor modularizes excmds, making them cleaner and easier to use throughout tridactyl. It also decouples the _declaration_ of an excmd from its _definition_, which gives us space to execute a large-scale refactor to improve ergonomics - for example, the type signatures of the functions used to execute exmcds could no longer be constrained by the limits of the string-mangling signature extractor (which cause some incredibly weird and opaque issues like \"you have to inline enum-like types instead of declaring them and using the actual type\"), and the declaration would have space to, for example, link individual arguments to completions sources so that we didn't have to broadcast the exstr to every completion so they could easy decide whether they had anything to do.\r\n\r\nIn this proof-of-concept PR, I extract `:tabopen`, `:nativeopen`, almost every variant on `:tab`, and some misc excmds related to rss and clipboard support. I wrap these in the aforementioned forwarding wrappers and update invocations of those exmcds and helpers to refer to the libs instead of `exmcds.ts`.\r\n\r\nsrc/content is for things that can only be invoked in the content script.\r\nsrc/background is for things that can only be invoked in the background script.\r\nsrc/lib is for things that can be invoked from anywhere.\r\n\r\nMakes sense, right? So, why not auto-generate wrappers in src/lib for things in src/background and src/content? The stuff in src/background and src/content can still only be run from the appropriate context, but the autogenerated wrappers in src/lib can be invoked from anywhere.\r\n\r\nThat said, I'm not going to do that immediately because it'd be a bit hairy and we already have a huge pile of hand-rolled wrappers that we'll want to back out in favor of this automated solution. For example, src/content/commandline_content.ts imports SELF and then adds a listener for itself, which is precisely what this approach is intended to replace. I also don't want to make this PR too huge up front; demonstrating this functionality by moving a few classes of excmd out of exmcds.ts and into stuff in src/background and src/content is good enough. So I've compromised and created new directories src/content_auto and src/background_auto that we can steadily move functionality into until src/background and src/content are empty, at which point we can search-replace X_auto with X throughout tridactyl.\r\n\r\nLimitations:\r\n\r\n* As of right now, everything you want to auto-wrap has to be async. The wrapper has to be async because it's sending a message and has to return the promise that comes out of the sent message, and I couldn't figure out how to dispatch based on the return type of the function being wrapped so the wrapper has to have the same type as the original module.\r\n* Support for src/commandline with the same kind of wrapper is sort of half-present but not really.","created_at":"2019-04-25T10:07:37Z","updated_at":"2019-05-04T23:32:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ca4b1b6db7cd2bb0ad7fea243f85de8106435750","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/tridactyl/tridactyl/pulls/1502/commits","review_comments_url":"https://api.github.com/repos/tridactyl/tridactyl/pulls/1502/comments","review_comment_url":"https://api.github.com/repos/tridactyl/tridactyl/pulls/comments{/number}","comments_url":"https://api.github.com/repos/tridactyl/tridactyl/issues/1502/comments","statuses_url":"https://api.github.com/repos/tridactyl/tridactyl/statuses/c272292789f042480fb54979bf9e585afac34d78","head":{"label":"saulrh:excmd-proxies","ref":"excmd-proxies","sha":"c272292789f042480fb54979bf9e585afac34d78","user":{"login":"saulrh","id":560724,"node_id":"MDQ6VXNlcjU2MDcyNA==","avatar_url":"https://avatars0.githubusercontent.com/u/560724?v=4","gravatar_id":"","url":"https://api.github.com/users/saulrh","html_url":"https://github.com/saulrh","followers_url":"https://api.github.com/users/saulrh/followers","following_url":"https://api.github.com/users/saulrh/following{/other_user}","gists_url":"https://api.github.com/users/saulrh/gists{/gist_id}","starred_url":"https://api.github.com/users/saulrh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saulrh/subscriptions","organizations_url":"https://api.github.com/users/saulrh/orgs","repos_url":"https://api.github.com/users/saulrh/repos","events_url":"https://api.github.com/users/saulrh/events{/privacy}","received_events_url":"https://api.github.com/users/saulrh/received_events","type":"User","site_admin":false},"repo":{"id":113781907,"node_id":"MDEwOlJlcG9zaXRvcnkxMTM3ODE5MDc=","name":"tridactyl","full_name":"saulrh/tridactyl","private":false,"owner":{"login":"saulrh","id":560724,"node_id":"MDQ6VXNlcjU2MDcyNA==","avatar_url":"https://avatars0.githubusercontent.com/u/560724?v=4","gravatar_id":"","url":"https://api.github.com/users/saulrh","html_url":"https://github.com/saulrh","followers_url":"https://api.github.com/users/saulrh/followers","following_url":"https://api.github.com/users/saulrh/following{/other_user}","gists_url":"https://api.github.com/users/saulrh/gists{/gist_id}","starred_url":"https://api.github.com/users/saulrh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saulrh/subscriptions","organizations_url":"https://api.github.com/users/saulrh/orgs","repos_url":"https://api.github.com/users/saulrh/repos","events_url":"https://api.github.com/users/saulrh/events{/privacy}","received_events_url":"https://api.github.com/users/saulrh/received_events","type":"User","site_admin":false},"html_url":"https://github.com/saulrh/tridactyl","description":"Implementing Vimperator/Pentadactyl as a WebExtension.","fork":true,"url":"https://api.github.com/repos/saulrh/tridactyl","forks_url":"https://api.github.com/repos/saulrh/tridactyl/forks","keys_url":"https://api.github.com/repos/saulrh/tridactyl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/saulrh/tridactyl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/saulrh/tridactyl/teams","hooks_url":"https://api.github.com/repos/saulrh/tridactyl/hooks","issue_events_url":"https://api.github.com/repos/saulrh/tridactyl/issues/events{/number}","events_url":"https://api.github.com/repos/saulrh/tridactyl/events","assignees_url":"https://api.github.com/repos/saulrh/tridactyl/assignees{/user}","branches_url":"https://api.github.com/repos/saulrh/tridactyl/branches{/branch}","tags_url":"https://api.github.com/repos/saulrh/tridactyl/tags","blobs_url":"https://api.github.com/repos/saulrh/tridactyl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/saulrh/tridactyl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/saulrh/tridactyl/git/refs{/sha}","trees_url":"https://api.github.com/repos/saulrh/tridactyl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/saulrh/tridactyl/statuses/{sha}","languages_url":"https://api.github.com/repos/saulrh/tridactyl/languages","stargazers_url":"https://api.github.com/repos/saulrh/tridactyl/stargazers","contributors_url":"https://api.github.com/repos/saulrh/tridactyl/contributors","subscribers_url":"https://api.github.com/repos/saulrh/tridactyl/subscribers","subscription_url":"https://api.github.com/repos/saulrh/tridactyl/subscription","commits_url":"https://api.github.com/repos/saulrh/tridactyl/commits{/sha}","git_commits_url":"https://api.github.com/repos/saulrh/tridactyl/git/commits{/sha}","comments_url":"https://api.github.com/repos/saulrh/tridactyl/comments{/number}","issue_comment_url":"https://api.github.com/repos/saulrh/tridactyl/issues/comments{/number}","contents_url":"https://api.github.com/repos/saulrh/tridactyl/contents/{+path}","compare_url":"https://api.github.com/repos/saulrh/tridactyl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/saulrh/tridactyl/merges","archive_url":"https://api.github.com/repos/saulrh/tridactyl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/saulrh/tridactyl/downloads","issues_url":"https://api.github.com/repos/saulrh/tridactyl/issues{/number}","pulls_url":"https://api.github.com/repos/saulrh/tridactyl/pulls{/number}","milestones_url":"https://api.github.com/repos/saulrh/tridactyl/milestones{/number}","notifications_url":"https://api.github.com/repos/saulrh/tridactyl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/saulrh/tridactyl/labels{/name}","releases_url":"https://api.github.com/repos/saulrh/tridactyl/releases{/id}","deployments_url":"https://api.github.com/repos/saulrh/tridactyl/deployments","created_at":"2017-12-10T20:41:37Z","updated_at":"2018-09-01T22:00:15Z","pushed_at":"2019-05-04T22:50:19Z","git_url":"git://github.com/saulrh/tridactyl.git","ssh_url":"git@github.com:saulrh/tridactyl.git","clone_url":"https://github.com/saulrh/tridactyl.git","svn_url":"https://github.com/saulrh/tridactyl","homepage":null,"size":17299,"stargazers_count":0,"watchers_count":0,"language":"TypeScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"tridactyl:master","ref":"master","sha":"a15af91be6ed54deabfd96b13572d64a0a06e9d0","user":{"login":"tridactyl","id":42609447,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQyNjA5NDQ3","avatar_url":"https://avatars3.githubusercontent.com/u/42609447?v=4","gravatar_id":"","url":"https://api.github.com/users/tridactyl","html_url":"https://github.com/tridactyl","followers_url":"https://api.github.com/users/tridactyl/followers","following_url":"https://api.github.com/users/tridactyl/following{/other_user}","gists_url":"https://api.github.com/users/tridactyl/gists{/gist_id}","starred_url":"https://api.github.com/users/tridactyl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tridactyl/subscriptions","organizations_url":"https://api.github.com/users/tridactyl/orgs","repos_url":"https://api.github.com/users/tridactyl/repos","events_url":"https://api.github.com/users/tridactyl/events{/privacy}","received_events_url":"https://api.github.com/users/tridactyl/received_events","type":"Organization","site_admin":false},"repo":{"id":83070966,"node_id":"MDEwOlJlcG9zaXRvcnk4MzA3MDk2Ng==","name":"tridactyl","full_name":"tridactyl/tridactyl","private":false,"owner":{"login":"tridactyl","id":42609447,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQyNjA5NDQ3","avatar_url":"https://avatars3.githubusercontent.com/u/42609447?v=4","gravatar_id":"","url":"https://api.github.com/users/tridactyl","html_url":"https://github.com/tridactyl","followers_url":"https://api.github.com/users/tridactyl/followers","following_url":"https://api.github.com/users/tridactyl/following{/other_user}","gists_url":"https://api.github.com/users/tridactyl/gists{/gist_id}","starred_url":"https://api.github.com/users/tridactyl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tridactyl/subscriptions","organizations_url":"https://api.github.com/users/tridactyl/orgs","repos_url":"https://api.github.com/users/tridactyl/repos","events_url":"https://api.github.com/users/tridactyl/events{/privacy}","received_events_url":"https://api.github.com/users/tridactyl/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/tridactyl/tridactyl","description":"A Vim-like interface for Firefox, inspired by Vimperator/Pentadactyl.","fork":false,"url":"https://api.github.com/repos/tridactyl/tridactyl","forks_url":"https://api.github.com/repos/tridactyl/tridactyl/forks","keys_url":"https://api.github.com/repos/tridactyl/tridactyl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tridactyl/tridactyl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tridactyl/tridactyl/teams","hooks_url":"https://api.github.com/repos/tridactyl/tridactyl/hooks","issue_events_url":"https://api.github.com/repos/tridactyl/tridactyl/issues/events{/number}","events_url":"https://api.github.com/repos/tridactyl/tridactyl/events","assignees_url":"https://api.github.com/repos/tridactyl/tridactyl/assignees{/user}","branches_url":"https://api.github.com/repos/tridactyl/tridactyl/branches{/branch}","tags_url":"https://api.github.com/repos/tridactyl/tridactyl/tags","blobs_url":"https://api.github.com/repos/tridactyl/tridactyl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tridactyl/tridactyl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tridactyl/tridactyl/git/refs{/sha}","trees_url":"https://api.github.com/repos/tridactyl/tridactyl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tridactyl/tridactyl/statuses/{sha}","languages_url":"https://api.github.com/repos/tridactyl/tridactyl/languages","stargazers_url":"https://api.github.com/repos/tridactyl/tridactyl/stargazers","contributors_url":"https://api.github.com/repos/tridactyl/tridactyl/contributors","subscribers_url":"https://api.github.com/repos/tridactyl/tridactyl/subscribers","subscription_url":"https://api.github.com/repos/tridactyl/tridactyl/subscription","commits_url":"https://api.github.com/repos/tridactyl/tridactyl/commits{/sha}","git_commits_url":"https://api.github.com/repos/tridactyl/tridactyl/git/commits{/sha}","comments_url":"https://api.github.com/repos/tridactyl/tridactyl/comments{/number}","issue_comment_url":"https://api.github.com/repos/tridactyl/tridactyl/issues/comments{/number}","contents_url":"https://api.github.com/repos/tridactyl/tridactyl/contents/{+path}","compare_url":"https://api.github.com/repos/tridactyl/tridactyl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tridactyl/tridactyl/merges","archive_url":"https://api.github.com/repos/tridactyl/tridactyl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tridactyl/tridactyl/downloads","issues_url":"https://api.github.com/repos/tridactyl/tridactyl/issues{/number}","pulls_url":"https://api.github.com/repos/tridactyl/tridactyl/pulls{/number}","milestones_url":"https://api.github.com/repos/tridactyl/tridactyl/milestones{/number}","notifications_url":"https://api.github.com/repos/tridactyl/tridactyl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tridactyl/tridactyl/labels{/name}","releases_url":"https://api.github.com/repos/tridactyl/tridactyl/releases{/id}","deployments_url":"https://api.github.com/repos/tridactyl/tridactyl/deployments","created_at":"2017-02-24T18:29:34Z","updated_at":"2019-05-04T23:13:19Z","pushed_at":"2019-05-04T22:40:51Z","git_url":"git://github.com/tridactyl/tridactyl.git","ssh_url":"git@github.com:tridactyl/tridactyl.git","clone_url":"https://github.com/tridactyl/tridactyl.git","svn_url":"https://github.com/tridactyl/tridactyl","homepage":"","size":17509,"stargazers_count":1671,"watchers_count":1671,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":158,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":312,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":158,"open_issues":312,"watchers":1671,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/tridactyl/tridactyl/pulls/1502"},"html":{"href":"https://github.com/tridactyl/tridactyl/pull/1502"},"issue":{"href":"https://api.github.com/repos/tridactyl/tridactyl/issues/1502"},"comments":{"href":"https://api.github.com/repos/tridactyl/tridactyl/issues/1502/comments"},"review_comments":{"href":"https://api.github.com/repos/tridactyl/tridactyl/pulls/1502/comments"},"review_comment":{"href":"https://api.github.com/repos/tridactyl/tridactyl/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/tridactyl/tridactyl/pulls/1502/commits"},"statuses":{"href":"https://api.github.com/repos/tridactyl/tridactyl/statuses/c272292789f042480fb54979bf9e585afac34d78"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"saulrh"}}