CodePositive - PoC of VScode on Haiku

Recent WebPositive is stable enough to open the https://vscode.dev (Visual Studio Code for Web). And I found a reasonable way to run vscode-server(or -web) on Haiku.

So I made a custom HaikuLauncher (a.k.a MiniBrowser of HaikuWebKit) build. Combining them is CodePositive. The PoC project of viable VScode like option on Haiku.

It needs some hacks to run, and we need to improve nodejs of Haiku, and some tweks vscode-server part. But it shows some possibility we can get in future.

I don’t work on this much anymore now, as I should focus on porting firefox. But for other people can work on Web frontend or nodejs internals, is this project is interested in?

Native part repo:

VScodium instruction:

  1. Get minimal VScodium reh-web release
  1. extract and run following commandline
    ~/Desktop/code+> rm node
    ~/Desktop/code+> ls
    bin  extensions  node_modules  out  package.json  product.json  resources
    ~/Desktop/code+> node out/server-main.js 
    
    • We need rm node binry in the release, as it’s non-Haiku executable or node script finds that unintentionally and fails.
  2. find URL for the browser, like http://localhost:8000?tkn=34af3198-554f-4454-aef4-ae1d6b350711
    Server bound to 127.0.0.1:8000 (IPv4)
    Extension host agent listening on 8000
    
    [05:51:14] 
    
    
    
    
    Error: Not an executable
        at Module._extensions..node (node:internal/modules/cjs/loader:1454:18)
        at Module.load (node:internal/modules/cjs/loader:1208:32)
        at Module._load (node:internal/modules/cjs/loader:1024:12)
        at Module.require (node:internal/modules/cjs/loader:1233:19)
        at require (node:internal/modules/helpers:179:18)
        at bindings (/boot/home/Desktop/code+/node_modules/bindings/bindings.js:112:48)
        at Object.<anonymous> (/boot/home/Desktop/code+/node_modules/@vscode/spdlog/index.js:3:35)
        at Module._compile (node:internal/modules/cjs/loader:1358:14)
        at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
        at Module.load (node:internal/modules/cjs/loader:1208:32)
        at Module._load (node:internal/modules/cjs/loader:1024:12)
        at cjsLoader (node:internal/modules/esm/translators:348:17)
        at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:297:7)
        at ModuleJob.run (node:internal/modules/esm/module_job:222:25)
        at async ModuleLoader.import (node:internal/modules/esm/loader:316:24)
        at async Nk (file:///boot/home/Desktop/code+/out/vs/server/node/server.main.js:70:12830)
        at async Ok._createSpdLogLogger (file:///boot/home/Desktop/code+/out/vs/server/node/server.main.js:70:13904) {
      code: 'ERR_DLOPEN_FAILED'
    }
    [05:51:14] Error: Unsupported platform
        at Object.<anonymous> (/boot/home/Desktop/code+/node_modules/@vscode/deviceid/dist/index.js:24:11)
        at Module._compile (node:internal/modules/cjs/loader:1358:14)
        at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
        at Module.load (node:internal/modules/cjs/loader:1208:32)
        at Module._load (node:internal/modules/cjs/loader:1024:12)
        at cjsLoader (node:internal/modules/esm/translators:348:17)
        at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:297:7)
        at ModuleJob.run (node:internal/modules/esm/module_job:222:25)
        at async ModuleLoader.import (node:internal/modules/esm/loader:316:24)
        at async T3 (file:///boot/home/Desktop/code+/out/vs/server/node/server.main.js:70:58554)
        at async Promise.all (index 4)
        at async mD (file:///boot/home/Desktop/code+/out/vs/server/node/server.main.js:185:418)
        at async CD (file:///boot/home/Desktop/code+/out/vs/server/node/server.main.js:189:7437)
        at async file:///boot/home/Desktop/code+/out/server-main.js:16:5305
        at async Server.<anonymous> (file:///boot/home/Desktop/code+/out/server-main.js:25:81)
    Web UI available at http://localhost:8000?tkn=34af3198-554f-4454-aef4-ae1d6b350711
    [05:51:14] Extension host agent started.
    [05:51:14] [File Watcher (node.js)] Failed to watch /boot/home/.vscodium-server/data/Machine for changes using fs.watch() (Error: ENOSYS: function not implemented, watch '/boot/home/.vscodium-server/data/Machine')
    [05:51:14] [File Watcher (node.js)] Failed to watch /boot/home/.vscodium-server/extensions for changes using fs.watch() (Error: ENOSYS: function not implemented, watch '/boot/home/.vscodium-server/extensions')
    [05:51:14] [File Watcher (node.js)] Failed to watch /boot/home/.vscodium-server/extensions/extensions.json for changes using fs.watch() (Error: ENOSYS: function not implemented, watch '/boot/home/.vscodium-server/extensions/extensions.json')
    

Launch the CodePositive:

  • Without opening folder, you pass above URL with token
    ./CodePositive http://localhost:8000?tkn=34af3198-554f-4454-aef4-ae1d6b350711
    
  • With opening folder you should open like this
    ./CodePositive http://localhost:8000?folder=/boot/home/src/codepositive&tkn=34af3198-554f-4454-aef4-ae1d6b350711
    
    • Opening folder in CodePositive or some other operations result in freeze

Some TODOs:

  • Port some platform specific parts of node webapp to Haiku
    • VScode codebase supports ONLY support win32, mac, linux (even freebsd aren’t here), freebsd guy replaces “linux” string to “freebsd”, it may work on Haiku too.
  • Native app should run nodejs and connect automatically
    • app can spawn child process and get token URL from pipe, so above token passing step can be automated.
  • Bug fixes
21 Likes

Tips for serious hackers:

At first, it’s difficult (at least not handy) to build VScode webapp on Haiku. VScode build system uses yarn which is platform independent, but it utilize swc and esbuild for compiling TypeScript and bundling build results.

swc is rust tool for blazing fast web front compiling we need to port if we use it on Haiku first.

esbuild is golang written tool for very fast bundling JS/css other resources consists the web app optimized for web deployment or embedding into Electron app. esbuild has wasm compiled version option but its very slow.

So my recommendation to hack web frontend part today is developing and run server on a Linux/Mac machine on the same network, then connect from WebPositive to the server and test or debug on Haiku.

When you release to testers or end users, you can use the technique on topic can be used. Build reh-web release inage or so on Linux ot.r other environment and incorporate it.

3 Likes

You can use neutralino or parts of it, it is an alternative to electron!

Me pokes @BiPolar (had been looking for it earlier today also, forgot why though :rofl:

I’m not touching anything related to nodejs/npm/TypeScript/JS, as I have zero idea about any of that :smiley:

There is a TypeScript to binary compiler at GitHub - ASDAlexander77/TypeScriptCompiler: TypeScript Compiler (by LLVM) but it probably needs work to port to Haiku. It’s written in C++.

You deleted yarn :slight_smile:

Right, thanks for the reminder… it was on yarn: drop recipe. by OscarL · Pull Request #10801 · haikuports/haikuports · GitHub

Reason for that was:

From https://yarnpkg.com/getting-started/install:

"The preferred way to manage Yarn is by-project and through Corepack, a tool shipped by default with Node.js. Modern releases of Yarn aren’t meant to be installed globally, or from npm.

As in… makes little sense for us to package it into an .hpkg, given that it is supposed to be handled by some other tools instead.

2 Likes

Thanks for the explanation, now people know why it isn’t in the depot +1 :slight_smile:

Is this a standalone tool? I mean, can it be used to launch whatever web app in its own window/instance?
I’m not interested in running a web app off-line but just on launching it on a separate instance without any GUI elements or popup menu.

Yes this is currently just a feature limited browser app. You can open any website/webapp by passing URL.

I intend this app will have nodejs process control, but not implemented yet.

You can get HaikuLauncher itself that is buildable standalone.

If you want create custom WebView app, you can use this as a base.