-
Notifications
You must be signed in to change notification settings - Fork 22.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
updated native messaging host example #36626
Conversation
files/en-us/mozilla/add-ons/webextensions/native_messaging/index.md
Outdated
Show resolved
Hide resolved
const message = await readFullAsync(header[0]); | ||
return message; | ||
const buffer = new ArrayBuffer(0, { | ||
maxByteLength: 1024 ** 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[mdn-linter] reported by reviewdog 🐶
maxByteLength: 1024 ** 2 | |
maxByteLength: 1024 ** 2, |
const writable = new WritableStream({ | ||
write(value) { | ||
process.stdout.write(value); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[mdn-linter] reported by reviewdog 🐶
} | |
}, |
const { | ||
exit | ||
} = process; | ||
const { | ||
argv: args | ||
} = process; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[mdn-linter] reported by reviewdog 🐶
const { | |
exit | |
} = process; | |
const { | |
argv: args | |
} = process; | |
const { exit } = process; | |
const { argv: args } = process; |
new Uint8Array(new Uint32Array([message.length]).buffer), | ||
message, | ||
]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[mdn-linter] reported by reviewdog 🐶
new Uint8Array(new Uint32Array([message.length]).buffer), | |
message, | |
]) | |
new Uint8Array(new Uint32Array([message.length]).buffer), | |
message, | |
]) |
]) | ||
.stream() | ||
.pipeTo(writable, { | ||
preventClose: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[mdn-linter] reported by reviewdog 🐶
preventClose: true | |
preventClose: true, |
Could you make minimal changes required to make it work, rather than copying entire source code over? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for opening this PR!
While it is true that procFS is not supported on macOS, and that alternatives should be used, this PR includes many other changes that are not strictly required. Could you modify the PR, to only include the strictly necessary changes? That is basically replacing the use of /proc/pid/fd/1
with process.stdout
.
I updated the PR to use process.stdout instead :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR still makes many unnecessary changes. Please take a look at the diff at https://github.com/mdn/content/pull/36626/files
There are many more changes than strictly necessary.
c1c556d
to
4a5b85e
Compare
my fork was outdated and I used revert before syncing so I don't know what happened. I re-forked and opened a new PR to keep the change minimal: |
Description
The current host example does not work on MacOS. Mac does not have
/proc/PID/fd/1
Motivation
Replaced the example with a working one.
Additional details
Readers would be able to use this example. It has been tested against Firefox and Chromium based browsers.
Author repo: https://github.com/guest271314/NativeMessagingHosts/blob/main/nm_nodejs.js
Related issues and pull requests
Fixes #36513