From 12a8b6bb63ab52cd4828f16d26d94079fa576436 Mon Sep 17 00:00:00 2001 From: LLLL Colonq Date: Tue, 18 Feb 2025 00:33:43 -0500 Subject: Add throwshade --- Makefile | 35 +++++++++- assets/rectangular.jpg | Bin 0 -> 92324 bytes assets/test.gif | Bin 0 -> 3763 bytes assets/upload.gif | Bin 0 -> 4597 bytes flake.lock | 149 +++++++++++++++++++++++++++++++++++++--- flake.nix | 7 ++ main.css | 63 +++++++++++++++++ src/Main.purs | 2 + src/Main/Throwshade.purs | 18 +++++ src/UI.js | 4 ++ src/UI.purs | 4 ++ src/Utils.purs | 6 ++ templates/throwshade/index.html | 38 ++++++++++ 13 files changed, 315 insertions(+), 11 deletions(-) create mode 100644 assets/rectangular.jpg create mode 100644 assets/test.gif create mode 100644 assets/upload.gif create mode 100644 src/Main/Throwshade.purs create mode 100644 templates/throwshade/index.html 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 $$$@" +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 Binary files /dev/null and b/assets/rectangular.jpg differ diff --git a/assets/test.gif b/assets/test.gif new file mode 100644 index 0000000..b386852 Binary files /dev/null and b/assets/test.gif differ diff --git a/assets/upload.gif b/assets/upload.gif new file mode 100644 index 0000000..e4994a3 Binary files /dev/null and b/assets/upload.gif 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,7 +163,45 @@ "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=", @@ -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 @@ + + + + + + LLLLColonq ShaderVerse Prime: The NEXTus (shado-realm) + + + + + + + +
+
+
+ +
+
+ + +
+
+ + -- cgit v1.2.3