-
Notifications
You must be signed in to change notification settings - Fork 18
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
Create an example without depending on TypeScript, Webpack, Node.js, npm #12
Comments
+1 a build could be served on a gh-pages branch via github.io. |
I'd like to confirm whether I understand both of you correctly. You'd like to have a simpler way to download a pre-built version of the app, right? Or is the issue that the app itself is too complex, and you would prefer to also have a separate repo that contains a super simple test app that doesn't require Webpack / TypeScript / etc. to build it? |
I don't generally install Node.js. I fetch the Node.js nightly archive and get rid of everything except the Never tried Webpack. I have no use for TypeScript. I do want to experiment with DirectSockets, I will start by using txiki.js to create a local TCP socket. I think you are making the assumption that |
The intention of this repository is to demonstrate how an Isolated Web App could be built using a typical developer workflow. For that we chose Webpack / Typescript but of course there are others. Modifying this example to remove all its dependencies would defeat the purpose. |
I think that is your preference based on the context of your environment. Some developers don't use or depend on external libraries, package managers. Just JavaScript as specified by Ecmascript; Web API's, DOM methods, HTML shipped in the given browser.
How so? You can easily create a different example without dependence on thord-party libraries. Not everybody installs Node.js. Node.js, or Deno (V8) JavaScript engines. QuickJS, txiki.js, Bun, etc. do exist and are used by modern web developers. Not everybody uses TypeScript or Webpack. At the bare minimum you can provide detailed explanation of what
in README is expected to look like. I will first use a QuickJS server module https://github.com/guest271314/webserver-c/tree/quickjs-webserver, because Node.js is too expensive (40MB to run, over 80MB executable) to justify using in a temporary file system running on RAM, or as an embedded application. There are quite a few repositories on GitHub that are using QuickJS compiled to WASM as a JavaScript runtime in the scope of a "worker" server - nobody that I am aware of has even tried to compile V8 to WASM to embed in a system, let alone Node.js. |
Ok. |
Just peeking at https://github.com/GoogleChromeLabs/telnet-client/blob/main/webpack.wbn.js you are still using That is a Node.js artifact. We are using Ecmascript/HTML That is one issue with writing source code in Node.js. I use I think I can implement the front-end. I just need to know what the server looks like at a low-level, so I can implement this myself using C, C++, QuickJS, txiki.js, Deno, etc. To me TypeScript is just a hyped-up linter; an entirely different language from JavaScript, that just happens to compile to JavaScript. I can write JavaScript without errors without TypeScript. In fact, I enjoy doing so. If I'm going to compile something it's gonna be C, C++, or Rust - not TypeScript, without any compelling reason to do so other than
I'm not typical, nor a follower. Just describe, in detail, the technical process in your README and I'll implement an example myself, using various programming languages and JavaScript engines for a local server. To me it makes no sense to download Node.js (the last time I fetched the Nightly build it was ~100MB) just to build a local server, when we can do so in C for less than 1MB executable and ~5MB running. That's fine if you think Node.js, TypeScript, Webpack are required for your environment. I think the public example should be far more generic, so developers in the field can just plug-and-play whatever server they want to or have developed other than Node.js (using `require()!). I think that's fair. |
This was my desire though now I realise it's different from the original poster's. |
I think on the front-end all we have to do is create an Isolated Web Application, or per DirectSockets repository, a Progressive Web Application, include some Chromium/Chrome flags, then go. On the server side I think we can use a Unix socket, not just telnet. This is what I am asking for. The bare bones, low-level explanation, without assuming the developer has Node.js, TypeScript, Webpack installed and depending on those applications, languages, and libraries just to create a local socket that we can connect to using Direct Scckets API. We should be able to use |
@reillyeon Alright, I downloaded the repository and launched the app with |
Looking at reports of this issue on the xterm.js project, it seems like this behavior is expected and in a real interactive terminal application the backspace key needs to be handled by the application, not the terminal. Enabling local echo simply duplicates keyboard input back to the terminal itself. |
That's why I said this example is way too over-complicated. After downloading Node.js, webpack, and packages this should just work. More importantly this should work without Node.js, webpack, etc. The only thing DirectSockets does is enable socket connections, which we can do using Linux built-ins. |
You continue to miss the point of why this example project exists. It's goal is to be just complicated enough to prove that complex projects can be built into an Isolated Web App. If you want to build something simpler you are free to do so. I will be closing this issue. There are other developer resources that are being developed to explain how to build an IWA that will be published when this work is closer to launching that may be helpful to you. |
So this is about Isolated Web Apps and not DirectSockets. Still, the dependencies and code in the repository is unnecessarily complicated, for no apparent reason, and the code doesn't work anyway, Folks over on DirectSockets are being referred to this example when it doesn't even work! |
Looking at WICG/direct-sockets#46 (comment), the reduced Direct Socket API example seems to be https://direct-sockets-ntp.glitch.me/. |
I'll try that over the next few days. Thanks. |
@tomayac There is no 'Isolated App Origins' filed in chrome://flags on Chromium 117.0.5891.0 (Developer Build) (64-bit) Revision f8142065670523d0c5a8b91ba26e8cdc09e9933f-refs/heads/main@{#1170895}. |
@tomayac Not working. |
Listen to the people. This is too complicated (for no good reason) - to not work after jumping through all the different hoops that keep changing just to try to experiment with Direct Sockets. |
It is true that the 'Isolated App Origins' flag no longer exists, so the Direct Socket demo's instructions are unfortunately outdated. The only way to demo Direct Sockets at the moment is by creating an IWA, like the telnet client, and installing that. |
That doesn't work. See above where errors are thrown. Have you folks tested this? Why all the unnecessary dependencies? The socket connection is user-defined. We should be able to do this using Bash, C, whatever. |
I'm alright with using an Isolated Web App. Unfortunately, Direct ockets has been tied in to Isolated Web Apps. But y'all keep moving the goal-posts on installation requirements in Chromium. I know I am far more interested in Direct Sockets than IWA. I will do what it takes to get to experiment to perhaps eventually test Direct Sockets. Since you are now the custodians or access to Direct Sockets, kindly describe precisely what I need to do to create an Isolated Web App where TCPSocket, et al. will be exposed and defined globally, and I can take it from there - without necessarily using TypeScript or installing Node.js. |
This is an experimental technology where the complete design is not yet available. This is why the requirements for using the API are shifting. Once it has been enabled by default the requirements will be stable. I have asked the owner of https://direct-sockets-ntp.glitch.me/ to update the instructions for running it. |
@GrapeGreen A step-by-step documentation on how to get Direct Sockets exposed - without dependence on Node.js, TypeScript, Webpack, npm will be very helpful. The goal posts keep moving. We can use a Bash shell script of txiki.js for a TCP socket so we don't need to install a whole bunch of packages just to use Direct Sockets. Can you kindly put together such a step-by-step outline? |
Just a sidenote here that using the wbn-sign npm package to bundle your IWA requires Node anyway, because JavaScript's Web Crypto API doesn't support Ed25519 yet and thus Node's crypto library must be available in order to use the tools. If you don't want to have Node installed, then the alternative would be to use the Golang tool for bundling and signing your code. If you don't want to depend on Webpack / Rollup (still requiers Node tho), you can use the CLI tools of the wbn & wbn-sign libraries (latter requires Node). |
We have now updated the instructions at https://direct-sockets-ntp.glitch.me/ - let me know if it works for you :) |
|
No, it doesn't. There is a 404 error then a syntax error when requesting the manifest.json file. |
I'm curious -- why do you need to fetch the manifest directly? The installation flow from url doesn't require that -- have you taken a look at the instructions? If that's a must, call GET on https://direct-sockets-ntp.glitch.me/manifest.webmanifest |
I'm notifying you the link you shared evidently does not load the manifest.json file. Maybe your code needs to make a GET request for manifest.webmanifest instead of manifest.json because right now the Web site does not prompt the user to Install anything. |
Ah, thanks for that, fixed. The website is not supposed to prompt you to install an IWA -- have you checked the provided instructions? It should be installable from the command line, not from the UI. |
I don't know what to tell you. Doesn't work under any variation of CLI flags or using chrome://apps
|
Alright, got it working. The app launcher looks like
the browser launcher
|
@GrapeGreen Now the question is how do we create a completely local version where the source code can be modified and launched from localhost? |
When I create a local TCP server with e.g., txiki.js I'm getting an error
|
The netstat report uses It's a little weird that you get "hostname couldn't be resolved" instead of something more specific like "invalid peer address". |
Alright got it working with this in txiki.js
and this at DevTools
Now do I modify the |
Ah... Turn off the Internet and this doesn't work. This (DirectSockets and to the extent applicable Isolated Web Apps) needs to work offline, completely locally. |
When this is enabled outside of development IWAs are going to be installed from Signed Web Bundles, which you can test today with the The As a workaround, you can make an app installed this way work offline by adding a Service Worker and implementing offline functionality in the same way you would for any web app. |
This should be enabled in any environment the developer decides to use Direct Sockets. I'll dive in to creating a minimal Web Bundle. Full disclosure: My ultimate use case for doing so is to embed an |
What you are intending to do is intentionally unsupported. |
Why? I don't see a reason for all of this elaborate process. You can't really prevent the use case I laid out from happening. I've done this multiple ways already, both using Web API's and browser extension code, e.g., https://github.com/guest271314/requestNativeScripts. We already have Native Messaging over IPC, I'm basically going to implement Native Messaging using Streams and Direct Sockets. See https://bugs.chromium.org/p/chromium/issues/detail?id=1214621. |
Keep in mind what I described is already possible. Because the Isolated Web App is a Direct Sockets should just be enabled by flag with origins specified the user wants to expose the feature. That vastly simplifies the process. |
Is there an example of that process? The below doesn't appear to work.
|
The command line flag throws:
|
@reillyeon Alright, I got the Are you sure Direct Sockets is working correctly? I tested txiki.js TCP server https://github.com/saghul/txiki.js/blob/master/tests/test-web-streams.js and Deno TCP server https://deno.land/manual@v1.36.1/examples/tcp_echo. When we do something like
then call That's why this shouldn't be gated behind Isolated Web Apps and Web Bundles. Not so easy to test. We have to jump through a few hoops to finally find this out. |
It looks like to close the connection we have to call |
The draft spec for Direct Sockets contains information about the closing behavior, maybe they can help? E.g.: https://wicg.github.io/direct-sockets/#close-method |
Using Where and how to we modify or remove the default (CSP, COEp, CORP) headers in the plugin before signing the Web Bundle? |
If you are using the Webpack plugin, you can override headers by specifying the |
I think I tried that and it didn't work. To be clear is it possible to remove the CSP, COEP, COOP headers and still have Direct Sockets exposed? |
|
No, this is what Reilly has been saying above. A key requirement to expose this API safely is to have these headers set and being in the context of an IWA. |
Well, I've already gotten around that a couple ways, it's just minimally tedious. You can't really prevent users from working around these things. We can still communicate with an extension and from the extension communicate with any arbitrary Web page via IPC messaging; and we can create a WebRTC connection between the IWA and the arbitrary Web page, among other approaches. The Direct Sockets thing should really be exposed as an extension, so developers can simply write in a manifest which origins they want that feature exposed on. |
@cmfcmf E.g., there is really no way for you to prevent this from happening https://github.com/guest271314/offscreen-webrtc in an IWA. The Direct Sockets shouldn't be gated behind IWA so folks don;t have to try to find ways to break your your gear and expose said breakage. |
This should be possible with without depending on TypeScript, Webpack, Node.js, npm.
The text was updated successfully, but these errors were encountered: