this post was submitted on 29 Nov 2023
5 points (85.7% liked)

JavaScript

2403 readers
2 users here now

founded 2 years ago
MODERATORS
 

Title. I'm trying to compile this but I can't seem to do so with node.js.

Thanks in advance.

top 5 comments
sorted by: hot top controversial new old
[–] shnizmuffin@lemmy.inbutts.lol 5 points 2 years ago (1 children)

Short answer: don't. Just serve the content using nginx and point a normal web browser at it.

Long answer: Apache Cordova.

[–] GustavoM@lemmy.world 1 points 2 years ago

Oh boy.

Thank you nonetheless.

[–] Macil@programming.dev 4 points 2 years ago

You can use Electron or Tauri to make an executable out of a web page.

[–] Shaner@programming.dev 1 points 2 years ago (1 children)

You could do it pretty easily in Go.

Basically just use embedfs to add your javascript and HTML.

https://pkg.go.dev/embed

Here's a complete working example with a http server from that page:

package main

import (
	"embed"
	"log"
	"net/http"
)

//go:embed internal/embedtest/testdata/*.txt
var content embed.FS

func main() {
	mutex := http.NewServeMux()
	mutex.Handle("/", http.FileServer(http.FS(content)))
	err := http.ListenAndServe(":8080", mutex)
	if err != nil {
		log.Fatal(err)
	}
}
[–] Shaner@programming.dev 1 points 2 years ago

I see you want a screen saver and this just runs an app to view in your browser. There are other methods but they are a bit trickier. It's not too hard to add an embedded interpreter but you'd probably have to do some porting to get it drawing to a native canvas.