summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile35
-rw-r--r--assets/rectangular.jpgbin0 -> 92324 bytes
-rw-r--r--assets/test.gifbin0 -> 3763 bytes
-rw-r--r--assets/upload.gifbin0 -> 4597 bytes
-rw-r--r--flake.lock149
-rw-r--r--flake.nix7
-rw-r--r--main.css63
-rw-r--r--src/Main.purs2
-rw-r--r--src/Main/Throwshade.purs18
-rw-r--r--src/UI.js4
-rw-r--r--src/UI.purs4
-rw-r--r--src/Utils.purs6
-rw-r--r--templates/throwshade/index.html38
13 files changed, 315 insertions, 11 deletions
diff --git a/Makefile b/Makefile
index 325b796..9eeb0a8 100644
--- a/Makefile
+++ b/Makefile
@@ -4,8 +4,9 @@ TEMPLATES_API=$(shell ls templates/api)
TEMPLATES_PUBNIX=$(shell ls templates/pubnix)
TEMPLATES_AUTH=$(shell ls templates/auth)
TEMPLATES_GREENCIRCLE=$(shell ls templates/greencircle)
+TEMPLATES_THROWSHADE=$(shell ls templates/greencircle)
-all: api pubnix extension auth greencircle
+all: api pubnix extension auth greencircle throwshade
dist:
mkdir -p dist/api/test
@@ -16,6 +17,8 @@ dist:
mkdir -p dist/auth/deploy
mkdir -p dist/greencircle/test
mkdir -p dist/greencircle/deploy
+ mkdir -p dist/throwshade/test
+ mkdir -p dist/throwshade/deploy
main.js: $(shell find src)
purs-nix bundle
@@ -109,6 +112,36 @@ dist/greencircle/%/$(template): config/%.m4 templates/greencircle/$(template)
endef
$(foreach template,$(TEMPLATES_GREENCIRCLE), $(eval $(GEN_RULE_GREENCIRCLE)))
+# throwshade
+deploy_throwshade: dist $(addprefix dist/throwshade/deploy/,$(TEMPLATES_THROWSHADE)) dist/throwshade/deploy/assets dist/throwshade/deploy/main.js dist/throwshade/deploy/main.css dist/throwshade/deploy/newton
+
+throwshade: dist $(addprefix dist/throwshade/test/,$(TEMPLATES_THROWSHADE)) dist/throwshade/test/assets dist/throwshade/test/main.js dist/throwshade/test/main.css dist/throwshade/test/newton
+
+dist/throwshade/%/newton: ${NEWTON_PATH}
+ rm -rf $@
+ mkdir -p $@
+ cp -r --no-preserve=mode,ownership $</snippets $@
+ install $</throwshade-*.js $@/throwshade.js
+ install $</throwshade-*.wasm $@/throwshade.wasm
+ chmod -R 0755 $@
+
+dist/throwshade/%/main.js: main.js dist
+ cp $< $@
+
+dist/throwshade/%/main.css: main.css dist
+ cp $< $@
+
+dist/throwshade/%/assets: $(shell find assets) dist
+ rm -rf $@
+ mkdir -p $@
+ cp -r assets/* $@
+
+define GEN_RULE_THROWSHADE
+dist/throwshade/%/$(template): config/%.m4 templates/throwshade/$(template)
+ sh -c "m4 $$^ >$$@"
+endef
+$(foreach template,$(TEMPLATES_THROWSHADE), $(eval $(GEN_RULE_THROWSHADE)))
+
# extension
extension: dist dist/extension/assets dist/extension/manifest.json dist/extension/background.js dist/extension/main.js dist/extension/main.css dist/extension/config.js
diff --git a/assets/rectangular.jpg b/assets/rectangular.jpg
new file mode 100644
index 0000000..5b7f79f
--- /dev/null
+++ b/assets/rectangular.jpg
Binary files differ
diff --git a/assets/test.gif b/assets/test.gif
new file mode 100644
index 0000000..b386852
--- /dev/null
+++ b/assets/test.gif
Binary files differ
diff --git a/assets/upload.gif b/assets/upload.gif
new file mode 100644
index 0000000..e4994a3
--- /dev/null
+++ b/assets/upload.gif
Binary files differ
diff --git a/flake.lock b/flake.lock
index a770068..3d4b372 100644
--- a/flake.lock
+++ b/flake.lock
@@ -1,5 +1,20 @@
{
"nodes": {
+ "crane": {
+ "locked": {
+ "lastModified": 1739638817,
+ "narHash": "sha256-pPiI27T416xAAUETorkLAgHQMiLT92moOrf0ItHhtPA=",
+ "owner": "ipetkov",
+ "repo": "crane",
+ "rev": "bef2b45cd1273a9e621fb5292de89f4ed59ad812",
+ "type": "github"
+ },
+ "original": {
+ "owner": "ipetkov",
+ "repo": "crane",
+ "type": "github"
+ }
+ },
"docs-search": {
"flake": false,
"locked": {
@@ -17,6 +32,24 @@
}
},
"flake-utils": {
+ "inputs": {
+ "systems": "systems"
+ },
+ "locked": {
+ "lastModified": 1731533236,
+ "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
+ "type": "github"
+ },
+ "original": {
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "type": "github"
+ }
+ },
+ "flake-utils_2": {
"locked": {
"lastModified": 1644229661,
"narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=",
@@ -31,7 +64,7 @@
"type": "github"
}
},
- "flake-utils_2": {
+ "flake-utils_3": {
"locked": {
"lastModified": 1618217525,
"narHash": "sha256-WGrhVczjXTiswQaoxQ+0PTfbLNeOQM6M36zvLn78AYg=",
@@ -46,7 +79,7 @@
"type": "github"
}
},
- "flake-utils_3": {
+ "flake-utils_4": {
"locked": {
"lastModified": 1618217525,
"narHash": "sha256-WGrhVczjXTiswQaoxQ+0PTfbLNeOQM6M36zvLn78AYg=",
@@ -78,7 +111,7 @@
},
"lint-utils": {
"inputs": {
- "flake-utils": "flake-utils",
+ "flake-utils": "flake-utils_2",
"nixpkgs": [
"purs-nix",
"nixpkgs"
@@ -130,8 +163,46 @@
"type": "github"
}
},
+ "newton": {
+ "inputs": {
+ "crane": "crane",
+ "flake-utils": "flake-utils",
+ "nixpkgs": "nixpkgs",
+ "rust-overlay": "rust-overlay",
+ "st": "st"
+ },
+ "locked": {
+ "lastModified": 1739851074,
+ "narHash": "sha256-Bx2LdbFBfGX+CpBGTbBRHXfbxBbF8L9aERZfal7jBDU=",
+ "ref": "refs/heads/master",
+ "rev": "0a078977d4b033739e85b95942a3f02711c4b9a3",
+ "revCount": 17,
+ "type": "git",
+ "url": "ssh://git@github.com/lcolonq/newton"
+ },
+ "original": {
+ "type": "git",
+ "url": "ssh://git@github.com/lcolonq/newton"
+ }
+ },
"nixpkgs": {
"locked": {
+ "lastModified": 1739482815,
+ "narHash": "sha256-/5Lwtmp/8j+ro32gXzitucSdyjJ6QehfJCL58WNA7N0=",
+ "owner": "NixOS",
+ "repo": "nixpkgs",
+ "rev": "ba0939c506a03c60a765cd7f7c43794816540eec",
+ "type": "github"
+ },
+ "original": {
+ "owner": "NixOS",
+ "ref": "nixpkgs-unstable",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
+ "nixpkgs_2": {
+ "locked": {
"lastModified": 1730643484,
"narHash": "sha256-FZN70acnL7V0gfmtLTdsi4J1o51bfaBYDTi3E7b7z3U=",
"owner": "NixOS",
@@ -146,7 +217,7 @@
"type": "github"
}
},
- "nixpkgs_2": {
+ "nixpkgs_3": {
"locked": {
"lastModified": 1704161960,
"narHash": "sha256-QGua89Pmq+FBAro8NriTuoO/wNaUtugt29/qqA8zeeM=",
@@ -162,7 +233,7 @@
"type": "github"
}
},
- "nixpkgs_3": {
+ "nixpkgs_4": {
"locked": {
"lastModified": 1656549732,
"narHash": "sha256-eILutFZGjfk2bEzfim8S/qyYc//0S1KsCeO+OWbtoR0=",
@@ -196,7 +267,7 @@
"ps-tools": {
"inputs": {
"make-shell": "make-shell_2",
- "nixpkgs": "nixpkgs_3",
+ "nixpkgs": "nixpkgs_4",
"utils": "utils"
},
"locked": {
@@ -219,7 +290,7 @@
"get-flake": "get-flake",
"lint-utils": "lint-utils",
"make-shell": "make-shell",
- "nixpkgs": "nixpkgs_2",
+ "nixpkgs": "nixpkgs_3",
"parsec": "parsec",
"ps-tools": "ps-tools",
"utils": "utils_2"
@@ -241,7 +312,8 @@
},
"root": {
"inputs": {
- "nixpkgs": "nixpkgs",
+ "newton": "newton",
+ "nixpkgs": "nixpkgs_2",
"ps-tools": [
"purs-nix",
"ps-tools"
@@ -249,9 +321,66 @@
"purs-nix": "purs-nix"
}
},
+ "rust-overlay": {
+ "inputs": {
+ "nixpkgs": [
+ "newton",
+ "nixpkgs"
+ ]
+ },
+ "locked": {
+ "lastModified": 1739673031,
+ "narHash": "sha256-Z/GT8ebbvc4goxN4A0A5ACj26G1HaGJO+VetrPuC5Mo=",
+ "owner": "oxalica",
+ "repo": "rust-overlay",
+ "rev": "538528d55318e0c8af1c307dcf10b7629b988fc3",
+ "type": "github"
+ },
+ "original": {
+ "owner": "oxalica",
+ "repo": "rust-overlay",
+ "type": "github"
+ }
+ },
+ "st": {
+ "inputs": {
+ "nixpkgs": [
+ "newton",
+ "nixpkgs"
+ ]
+ },
+ "locked": {
+ "lastModified": 1738300089,
+ "narHash": "sha256-kcLup2C1MlD/yiN7quujBSGfEH6356QggnqI+sVQHR4=",
+ "owner": "lcolonq",
+ "repo": "st",
+ "rev": "e982b1d75eda54ab6b3051675fb21d32b3731bb5",
+ "type": "github"
+ },
+ "original": {
+ "owner": "lcolonq",
+ "repo": "st",
+ "type": "github"
+ }
+ },
+ "systems": {
+ "locked": {
+ "lastModified": 1681028828,
+ "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
+ "owner": "nix-systems",
+ "repo": "default",
+ "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nix-systems",
+ "repo": "default",
+ "type": "github"
+ }
+ },
"utils": {
"inputs": {
- "flake-utils": "flake-utils_2"
+ "flake-utils": "flake-utils_3"
},
"locked": {
"lastModified": 1656044990,
@@ -270,7 +399,7 @@
},
"utils_2": {
"inputs": {
- "flake-utils": "flake-utils_3"
+ "flake-utils": "flake-utils_4"
},
"locked": {
"lastModified": 1656044990,
diff --git a/flake.nix b/flake.nix
index a5c4d87..57669da 100644
--- a/flake.nix
+++ b/flake.nix
@@ -5,6 +5,10 @@
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
ps-tools.follows = "purs-nix/ps-tools";
purs-nix.url = "github:purs-nix/purs-nix/ps-0.15";
+ newton = {
+ # url = "github:lcolonq/newton";
+ url = "git+ssh://git@github.com/lcolonq/newton";
+ };
};
outputs = { self, nixpkgs, ... }@inputs:
@@ -14,6 +18,8 @@
ps-tools = inputs.ps-tools.legacyPackages.${system};
purs-nix = inputs.purs-nix { inherit system; };
+ NEWTON_PATH = inputs.newton.packages.${system}.wasm.throwshade;
+
purescript = purs-nix.purs {
dependencies = [
"console"
@@ -82,6 +88,7 @@
};
in {
devShells.x86_64-linux.default = pkgs.mkShell {
+ inherit NEWTON_PATH;
buildInputs = [
pkgs.nodejs
(purescript.command {})
diff --git a/main.css b/main.css
index 1612f71..6492bf8 100644
--- a/main.css
+++ b/main.css
@@ -501,3 +501,66 @@ a.lcolonq-button-link :active {
font-weight: bold;
color: red;
}
+
+/* throwshade */
+#lcolonq-throwshade {
+ overflow-x: hidden;
+ overflow-y: hidden;
+ height: 100vh;
+ display: flex;
+ flex-direction: column;
+ justify-content: space-evenly;
+ background-image: url("./assets/rectangular.jpg");
+ background-size: 100% 100%;
+}
+.lcolonq-throwshade-canvas {
+ width: 100%;
+ height: 60%;
+ display: flex;
+ flex-direction: column;
+ justify-content: space-evenly;
+}
+.lcolonq-throwshade-canvas canvas {
+ margin: auto;
+ display: block;
+ width: auto;
+ height: 100%;
+ image-rendering: pixelated;
+}
+#lcolonq-throwshade-bottom {
+ flex-grow: 1;
+ height: 40%;
+ display: flex;
+ flex-direction: row;
+ justify-content: space-evenly;
+ padding-top: 0.6rem;
+}
+#lcolonq-throwshade-bottom-left {
+ flex-grow: 1;
+ padding-bottom: 1rem;
+ padding-left: 0.7rem;
+ padding-right: 1rem;
+}
+#lcolonq-throwshade-textarea {
+ width: 100%;
+ height: 100%;
+ resize: none;
+ border: none;
+ overflow: auto;
+ outline: none;
+ box-shadow: none;
+ background-color: rgb(0 0 0 / 0.8);
+}
+#lcolonq-throwshade-bottom-right {
+ flex-grow: 1;
+ padding-bottom: 1rem;
+ padding-left: 0.7rem;
+ padding-right: 1rem;
+ display: flex;
+ flex-direction: column;
+ justify-content: space-evenly;
+ max-width: 40%;
+}
+#lcolonq-throwshade-bottom-right img {
+ height: 40%;
+}
diff --git a/src/Main.purs b/src/Main.purs
index 6fff10b..34ca80b 100644
--- a/src/Main.purs
+++ b/src/Main.purs
@@ -14,6 +14,7 @@ import Main.Menu as Menu
import Main.OBS as OBS
import Main.Pubnix as Pubnix
import Main.Register as Register
+import Main.Throwshade as Throwshade
main :: Effect Unit
main = case Config.mode of
@@ -26,4 +27,5 @@ main = case Config.mode of
"menu" -> Menu.main
"auth" -> Auth.main
"greencircle" -> Greencircle.main
+ "throwshade" -> Throwshade.main
_ -> throw $ "unknown mode: " <> Config.mode
diff --git a/src/Main/Throwshade.purs b/src/Main/Throwshade.purs
new file mode 100644
index 0000000..ad1ad2c
--- /dev/null
+++ b/src/Main/Throwshade.purs
@@ -0,0 +1,18 @@
+module Main.Throwshade where
+
+import Prelude
+
+import Effect (Effect)
+import Effect.Class (liftEffect)
+import Effect.Console (log)
+import UI (setShader)
+import Utils (byId, getTextArea, listen)
+
+main :: Effect Unit
+main = do
+ liftEffect $ log "hello it is throwshade"
+ input <- byId "lcolonq-throwshade-textarea"
+ test <- byId "lcolonq-throwshade-button-test"
+ listen test "click" \_ -> do
+ s <- getTextArea input
+ setShader s
diff --git a/src/UI.js b/src/UI.js
index c5089e6..a6dd0fa 100644
--- a/src/UI.js
+++ b/src/UI.js
@@ -22,3 +22,7 @@ export const _submitRedeem = (url) => (el) => () => {
body: data,
});
};
+
+export const _setShader = (shader) => () => {
+ window.wasmBindings.set_shader(shader);
+};
diff --git a/src/UI.purs b/src/UI.purs
index 3da0814..44117a0 100644
--- a/src/UI.purs
+++ b/src/UI.purs
@@ -29,3 +29,7 @@ redirect url = liftEffect $ _redirect url
foreign import _submitRedeem :: String -> DOM.El.Element -> Effect Unit
submitRedeem :: forall m. MonadEffect m => DOM.El.Element -> m Unit
submitRedeem el = liftEffect $ _submitRedeem (Config.secureApiServer <> "/redeem") el
+
+foreign import _setShader :: String -> Effect Unit
+setShader :: forall m. MonadEffect m => String -> m Unit
+setShader s = liftEffect $ _setShader s
diff --git a/src/Utils.purs b/src/Utils.purs
index e4fd125..7be7be8 100644
--- a/src/Utils.purs
+++ b/src/Utils.purs
@@ -26,6 +26,7 @@ import Web.Event.EventTarget as Ev.Tar
import Web.HTML as HTML
import Web.HTML.HTMLDocument as HTML.Doc
import Web.HTML.HTMLInputElement as HTML.Input
+import Web.HTML.HTMLTextAreaElement as HTML.TextArea
import Web.HTML.Window as HTML.Win
maybeToArray :: forall a. Maybe a -> Array a
@@ -91,6 +92,11 @@ appendText parent s = do
setText :: forall m. MonadEffect m => DOM.Element -> String -> m Unit
setText e s = liftEffect $ DOM.Node.setTextContent s $ DOM.El.toNode e
+getTextArea :: forall m. MonadEffect m => DOM.Element -> m String
+getTextArea e = case HTML.TextArea.fromElement e of
+ Just inp -> liftEffect $ HTML.TextArea.value inp
+ Nothing -> liftEffect $ throw "element is not a text area"
+
getValue :: forall m. MonadEffect m => DOM.Element -> m String
getValue e = case HTML.Input.fromElement e of
Just inp -> liftEffect $ HTML.Input.value inp
diff --git a/templates/throwshade/index.html b/templates/throwshade/index.html
new file mode 100644
index 0000000..2bf006a
--- /dev/null
+++ b/templates/throwshade/index.html
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
+ <title>LLLLColonq ShaderVerse Prime: The NEXTus (shado-realm)</title>
+ <link rel="icon" href="./assets/mrgreen.png">
+ <link rel="stylesheet" type="text/css" href="./main.css">
+ <script type="module">
+CONFIG_SUBST
+ globalThis.mode = "throwshade";
+ </script>
+ <script type="module">
+ import init, * as bindings from "./newton/throwshade.js";
+ const wasm = await init({ module_or_path: "./newton/throwshade.wasm" });
+ window.wasmBindings = bindings;
+ console.log("initialized, starting...");
+ window.wasmBindings.main_js();
+ </script>
+ <script type="module" src="./main.js"></script>
+ </head>
+ <body id="lcolonq-throwshade">
+ <div id="teleia-parent" class="lcolonq-throwshade-canvas"></div>
+ <div id="lcolonq-throwshade-bottom">
+ <div id="lcolonq-throwshade-bottom-left">
+ <textarea id="lcolonq-throwshade-textarea">
+vec4 shade(vec2 cs) {
+ return vec4(0.0, 1.0, 0.0, 1.0);
+}
+</textarea>
+ </div>
+ <div id="lcolonq-throwshade-bottom-right">
+ <img id="lcolonq-throwshade-button-test" src="./assets/test.gif"></img>
+ <img id="lcolonq-throwshade-button-submit" src="./assets/upload.gif"></img>
+ </div>
+ </div>
+ </body>
+</html>