~glacambre/firenvim

1da57aaa445fa2d74099c9223c5ee238f0ca25fb — glacambre 3 years ago 03a9bab
Create stub that compiles and correctly requires files.
8 files changed, 75 insertions(+), 8 deletions(-)

M package.json
A src/background.ts
A src/content.ts
A src/firenvim.d.ts
D src/firenvim.ts
M src/manifest.json
A src/native_manifest.json
M tsconfig.json
M package.json => package.json +5 -4
@@ 7,12 7,13 @@
    "typescript": "^2.5.3",
    "web-ext": "^1.8.1",
    "browserify": "^14.5.0",
    "msgpack5": "^3.6.0"
    "promised-neovim-client": "^2.0.2"
  },
  "scripts": {
    "build": "tsc && browserify build/firenvim.js -o build/firenvim.js && cp src/manifest.json build/manifest.json",
    "run": "web-ext run --source-dir=./build --keep-profile-changes --firefox-profile=$HOME/.mozilla/firefox/firenvim.profile",
    "package": "web-ext build"
    "build": "((cargo build --release && (unlink ~/bin/firenvim ; cp target/release/firenvim ~/bin)) & tsc && browserify target/*.js -o target/background.js && cp src/manifest.json target/manifest.json && cp src/native_manifest.json $HOME/.mozilla/native-messaging-hosts/firenvim.json) || true",
    "run": "web-ext run --source-dir=./target --keep-profile-changes --firefox-profile=$HOME/.mozilla/firefox/firenvim.profile",
    "package": "web-ext target",
    "clean": "rm -rf target"
  },
  "author": "glacambre",
  "keywords": [

A src/background.ts => src/background.ts +16 -0
@@ 0,0 1,16 @@
///<reference path="firenvim.d.ts" />

console.log("Firenvim content script loaded.");
let NvimProcess = require("./NeovimProcess.js").NeovimProcess;
let nvim = new NvimProcess();

require("promised-neovim-client").attach(nvim.stdin, nvim.stdout).then((nvim: any) => {
    nvim.on("request", (method: any, args: any, resp: any) => {
        console.log("request", method, args, resp)
    });
    nvim.on("notification", (method: any, args: any) => {
        console.log("notification", method, args)
    });
}).catch((err: any) => console.log(err));

console.log("Promised-neovim-cleint required.");

A src/content.ts => src/content.ts +3 -0
@@ 0,0 1,3 @@
///<reference path="firenvim.d.ts" />

console.log("Firenvim content script loaded.");

A src/firenvim.d.ts => src/firenvim.d.ts +29 -0
@@ 0,0 1,29 @@
declare class WebextensionEventTarget {
    addListener(f: Function): void;
    removeListener(f: Function): void;
}

declare class RuntimeOnConnect extends WebextensionEventTarget{}

declare class PortError {
    message: string;
}

declare class PortOnDisconnect extends WebextensionEventTarget{}

declare class PortOnMessage extends WebextensionEventTarget{}

declare class Port {
    name: string;
    disconnect(): void;
    error: PortError;
    onDisconnect: PortOnDisconnect;
    onMessage: PortOnMessage;
    postMessage(msg: string): void;
}

declare namespace browser.runtime {
    function connect(): Port;
    function connectNative(name: string): Port;
    let onConnect: RuntimeOnConnect;
}

D src/firenvim.ts => src/firenvim.ts +0 -1
@@ 1,1 0,0 @@
console.log("hello")

M src/manifest.json => src/manifest.json +14 -2
@@ 10,8 10,20 @@
      "matches": [
        "<all_urls>"
      ],
      "js": ["firenvim.js"]
      "js": ["content.js"]
    }
  ]
  ],

  "background": {
    "scripts": ["background.js"]
  },

  "applications": {
    "gecko": {
      "id": "firenvim@lacamb.re",
      "strict_min_version": "50.0"
    }
  },

  "permissions": ["nativeMessaging"]
}

A src/native_manifest.json => src/native_manifest.json +7 -0
@@ 0,0 1,7 @@
{
  "name": "firenvim",
  "description": "Turn Firefox into a Neovim client.",
  "path": "/home/me/bin/firenvim",
  "type": "stdio",
  "allowed_extensions": [ "firenvim@lacamb.re" ]
}

M tsconfig.json => tsconfig.json +1 -1
@@ 2,7 2,7 @@
  "compilerOptions": {
    "moduleResolution": "Node",
    "noImplicitAny": true,
    "outDir": "./build",
    "outDir": "./target",
    "sourceMap": true,
    "target": "ES2017",
    "typeRoots": ["node_modules/@types", "node_modules/web-ext-types/"],