native-messaging-nodejs 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/background.js ADDED
@@ -0,0 +1,26 @@
1
+ chrome.runtime.onInstalled.addListener((reason) => {
2
+ console.log(reason);
3
+ });
4
+
5
+ globalThis.name = chrome.runtime.getManifest().short_name;
6
+
7
+ globalThis.port = chrome.runtime.connectNative(globalThis.name);
8
+ port.onMessage.addListener((message) => {
9
+ console.log(message);
10
+ });
11
+ port.onDisconnect.addListener((_) => {
12
+ if (chrome.runtime.lastError) {
13
+ console.log(chrome.runtime.lastError);
14
+ }
15
+ });
16
+
17
+ // https://developer.chrome.com/docs/extensions/develop/concepts/native-messaging#native-messaging-host-protocol
18
+ // The maximum size of the message sent to the native messaging host is 64 MiB.
19
+ // try {port.postMessage(Array((209715*65)))} catch (e) {console.log(e)}
20
+ // Error: Message exceeded maximum allowed size of 64MiB.
21
+ try {
22
+ port.postMessage(Array(209715 /* * 64 */));
23
+ } catch (e) {
24
+ console.log(e);
25
+ }
26
+
package/manifest.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "name": "nm-node",
3
+ "short_name": "nm_nodejs",
4
+ "version": "1.0",
5
+ "description": "Node.js Native Messaging host",
6
+ "manifest_version": 3,
7
+ "permissions": ["nativeMessaging"],
8
+ "background": {
9
+ "service_worker": "background.js",
10
+ "type": "module"
11
+ },
12
+ "action": {},
13
+ "homepage_url": "https://github.com/guest271314/native-messaging-nodejs"
14
+ }
package/nm_nodejs.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "name": "nm_nodejs",
3
+ "description": "Node.js Native Messaging Host",
4
+ "path": "",
5
+ "type": "stdio",
6
+ "allowed_origins": []
7
+ }
package/package.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "native-messaging-nodejs",
3
+ "version": "0.0.1",
4
+ "description": "Node.js Native Messaging host",
5
+ "keywords": [
6
+ "Native Messaging",
7
+ "Native Messaging host"
8
+ ],
9
+ "homepage": "https://github.com/guest271314/native-messaging-nodejs",
10
+ "bugs": {
11
+ "url": "https://github.com/guest271314/native-messaging-nodejs/issues"
12
+ },
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/guest271314/native-messaging-nodejs.git"
16
+ },
17
+ "license": "SEE LICENSE IN LICENSE",
18
+ "author": "guest271314",
19
+ "type": "esm",
20
+ "main": "nm_nodejs.js"
21
+ }