Add native package manifest

This commit is contained in:
Michael Zhang 2023-04-12 17:39:04 -05:00
parent 62f1fc1236
commit 733ab6f964
Signed by: michael
GPG key ID: BDA47A31A3C8EE6B
5 changed files with 48 additions and 4 deletions

13
package-lock.json generated
View file

@ -5,9 +5,22 @@
"packages": { "packages": {
"": { "": {
"devDependencies": { "devDependencies": {
"json5": "^2.2.3",
"typescript": "^5.0.4" "typescript": "^5.0.4"
} }
}, },
"node_modules/json5": {
"version": "2.2.3",
"resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz",
"integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==",
"dev": true,
"bin": {
"json5": "lib/cli.js"
},
"engines": {
"node": ">=6"
}
},
"node_modules/typescript": { "node_modules/typescript": {
"version": "5.0.4", "version": "5.0.4",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.4.tgz", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.4.tgz",

View file

@ -1,5 +1,6 @@
{ {
"devDependencies": { "devDependencies": {
"json5": "^2.2.3",
"typescript": "^5.0.4" "typescript": "^5.0.4"
} }
} }

View file

@ -1,15 +1,24 @@
{ {
"name": "Parasite", "name": "Parasite",
"background": { "background": {
"scripts": ["background.bundle.js"] "scripts": ["background.bundle.js"],
}, },
"browser_action": { "browser_action": {
"default_popup": "popup.html", "default_popup": "popup.html",
"default_icon": "icon-34.png" "default_icon": "icon-34.png"
}, },
"icons": {}, "icons": {},
"manifest_version": 2, "manifest_version": 2,
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'", "content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'",
"permissions": ["nativeMessaging", "tabs"] "applications": {
"gecko": {
"id": "ping_pong@example.org",
}
},
"permissions": ["nativeMessaging", "tabs"],
} }

View file

@ -0,0 +1,20 @@
// This is a file that describes how browsers should call the native messenger.
//
// On firefox, we just need to put this file in
// ~/.mozilla/native-messaging-hosts/[name].json
// See this[1] page for more details.
//
// On chrome, we need to put it in
// ~/.config/google-chrome/NativeMessagingHosts/[name].json
// See this[2] page for more details.
//
// [1]: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Native_manifests#linux
// [2]: https://developer.chrome.com/docs/apps/nativeMessaging/#native-messaging-host-location
{
"name": "io.mzhang.navigation_tools.parasite_messenger",
"description": "Example host for native messaging",
"path": "/path/to/native-messaging/app/ping_pong.py",
"type": "stdio",
"allowed_extensions": ["ping_pong@example.org"],
}

View file

@ -1,5 +1,6 @@
import path from "path"; import path from "path";
import webpack from "webpack"; import webpack from "webpack";
import json5 from "json5";
import CopyWebpackPlugin from "copy-webpack-plugin"; import CopyWebpackPlugin from "copy-webpack-plugin";
@ -46,9 +47,9 @@ const options: webpack.Configuration = {
// Copy the manifest, adding in the version and the description from the // Copy the manifest, adding in the version and the description from the
// package.json file. // package.json file.
{ {
from: "src/manifest.json", from: "src/manifest.json5",
transform: (content, _) => { transform: (content, _) => {
const oldContent = JSON.parse(content.toString()); const oldContent = json5.parse(content.toString());
const newContent = { const newContent = {
description: process.env.npm_package_description, description: process.env.npm_package_description,
version: process.env.npm_package_version, version: process.env.npm_package_version,