summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornatrixaeria <janng@gmx.de>2019-06-11 20:24:45 +0200
committernatrixaeria <janng@gmx.de>2019-06-11 20:24:45 +0200
commitb21428c0ea29452e3edc5a11f72fa3e614ea617e (patch)
treef8f04744fe61700e59d68eec1de8dc562c1ed689
parent8276c94169c7f6027691f124c63b61c815ab15a5 (diff)
Remove the WebInterface directory
and create webhogg project folder
-rw-r--r--WebInterface/wasm/asm-paint/.gitignore6
-rw-r--r--WebInterface/wasm/asm-paint/Cargo.toml29
-rw-r--r--WebInterface/wasm/asm-paint/README.md53
-rwxr-xr-xWebInterface/wasm/asm-paint/deploy2
-rw-r--r--WebInterface/wasm/asm-paint/index.html24
-rw-r--r--WebInterface/wasm/asm-paint/lighttpd.config29
-rw-r--r--WebInterface/wasm/asm-paint/loader.js2
-rwxr-xr-xWebInterface/wasm/asm-paint/run3
-rw-r--r--WebInterface/wasm/asm-paint/src/app.rs19
-rw-r--r--WebInterface/wasm/asm-paint/src/canvas.rs39
-rw-r--r--WebInterface/wasm/asm-paint/src/client_logger.rs46
-rw-r--r--WebInterface/wasm/asm-paint/src/lib.rs20
-rw-r--r--WebInterface/wasm/asm-paint/src/shader.rs97
-rw-r--r--WebInterface/wasm/asm-paint/src/site.rs28
-rw-r--r--WebInterface/wasm/webhogg/Cargo.toml36
-rwxr-xr-xWebInterface/wasm/webhogg/deploy.py137
-rw-r--r--WebInterface/wasm/webhogg/game_logic.js393
-rw-r--r--WebInterface/wasm/webhogg/graphics.js401
-rw-r--r--WebInterface/wasm/webhogg/index.html24
-rwxr-xr-xWebInterface/wasm/webhogg/killpy2
-rw-r--r--WebInterface/wasm/webhogg/loader.js9
-rwxr-xr-xWebInterface/wasm/webhogg/run6
-rw-r--r--WebInterface/wasm/webhogg/src/canvas.rs36
-rw-r--r--WebInterface/wasm/webhogg/src/client_logger.rs47
-rw-r--r--WebInterface/wasm/webhogg/src/lib.rs44
-rw-r--r--WebInterface/wasm/webhogg/src/webhogg_exception.rs39
-rw-r--r--WebInterface/wasm/webhogg/target/.rustc_info.json1
-rw-r--r--WebInterface/wasm/webhogg/update.py29
-rw-r--r--WebInterface/wasm/webhogg/webhogg.js112
-rw-r--r--webhogg/wasm/Cargo.toml11
-rw-r--r--webhogg/wasm/src/main.rs3
31 files changed, 14 insertions, 1713 deletions
diff --git a/WebInterface/wasm/asm-paint/.gitignore b/WebInterface/wasm/asm-paint/.gitignore
deleted file mode 100644
index 4e30131..0000000
--- a/WebInterface/wasm/asm-paint/.gitignore
+++ /dev/null
@@ -1,6 +0,0 @@
-/target
-**/*.rs.bk
-Cargo.lock
-bin/
-pkg/
-wasm-pack.log
diff --git a/WebInterface/wasm/asm-paint/Cargo.toml b/WebInterface/wasm/asm-paint/Cargo.toml
deleted file mode 100644
index ceb1866..0000000
--- a/WebInterface/wasm/asm-paint/Cargo.toml
+++ /dev/null
@@ -1,29 +0,0 @@
-[package]
-name = "asm-paint-rs"
-version = "0.1.0"
-authors = [
- "natrixaeria",
- "TrueDoctor"
-]
-edition = "2018"
-
-[lib]
-crate-type = ["cdylib"]
-
-[dependencies]
-wasm-bindgen = "0.2"
-log = "0.4"
-fern = "0.5"
-
-[dependencies.web-sys]
-version = "0.3.22"
-features = [
- 'Document',
- 'Element',
- 'HtmlCanvasElement',
- 'WebGl2RenderingContext',
- 'WebGlShader',
- 'WebGlProgram',
- 'WebGlBuffer',
- 'Window'
-]
diff --git a/WebInterface/wasm/asm-paint/README.md b/WebInterface/wasm/asm-paint/README.md
deleted file mode 100644
index 5fcb76f..0000000
--- a/WebInterface/wasm/asm-paint/README.md
+++ /dev/null
@@ -1,53 +0,0 @@
-# πŸ¦€πŸ•ΈοΈ `wasm-pack-template`
-
-A template for kick starting a Rust and WebAssembly project using
-[`wasm-pack`](https://github.com/rustwasm/wasm-pack).
-
-[**πŸ“š Read this template tutorial! πŸ“š**][template-docs]
-
-This template is designed for compiling Rust libraries into WebAssembly and
-publishing the resulting package to NPM.
-
-Be sure to check out [other `wasm-pack` tutorials online][tutorials] for other
-templates and usages of `wasm-pack`.
-
-[tutorials]: https://rustwasm.github.io/docs/wasm-pack/tutorials/index.html
-[template-docs]: https://rustwasm.github.io/docs/wasm-pack/tutorials/npm-browser-packages/index.html
-
-## 🚴 Usage
-
-### πŸ‘ Use `cargo generate` to Clone this Template
-
-[Learn more about `cargo generate` here.](https://github.com/ashleygwilliams/cargo-generate)
-
-```
-cargo generate --git https://github.com/rustwasm/wasm-pack-template.git --name my-project
-cd my-project
-```
-
-### πŸ› οΈ Build with `wasm-pack build`
-
-```
-wasm-pack build
-```
-
-### πŸ”¬ Test in Headless Browsers with `wasm-pack test`
-
-```
-wasm-pack test --headless --firefox
-```
-
-### 🎁 Publish to NPM with `wasm-pack publish`
-
-```
-wasm-pack publish
-```
-
-## πŸ”‹ Batteries Included
-
-* [`wasm-bindgen`](https://github.com/rustwasm/wasm-bindgen) for communicating
- between WebAssembly and JavaScript.
-* [`console_error_panic_hook`](https://github.com/rustwasm/console_error_panic_hook)
- for logging panic messages to the developer console.
-* [`wee_alloc`](https://github.com/rustwasm/wee_alloc), an allocator optimized
- for small code size.
diff --git a/WebInterface/wasm/asm-paint/deploy b/WebInterface/wasm/asm-paint/deploy
deleted file mode 100755
index 13d1d0a..0000000
--- a/WebInterface/wasm/asm-paint/deploy
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/sh
-lighttpd -f ./lighttpd.config
diff --git a/WebInterface/wasm/asm-paint/index.html b/WebInterface/wasm/asm-paint/index.html
deleted file mode 100644
index c4f3734..0000000
--- a/WebInterface/wasm/asm-paint/index.html
+++ /dev/null
@@ -1,24 +0,0 @@
-<!doctype html>
-<html>
- <head>
- <meta charset="UTF-8">
- <title> Scribblio </title>
- <script src='loader.js' type='module'></script>
- <style>
- body {
- margin: 0;
- background: black;
- }
- #canvas {
- width: 100%;
- height: 100%;
- }
- img {
- background: violet;
- }
- </style>
- </head>
- <body>
- <canvas id='canvas'></canvas>
- </body>
-</html>
diff --git a/WebInterface/wasm/asm-paint/lighttpd.config b/WebInterface/wasm/asm-paint/lighttpd.config
deleted file mode 100644
index 5fae32d..0000000
--- a/WebInterface/wasm/asm-paint/lighttpd.config
+++ /dev/null
@@ -1,29 +0,0 @@
-server.http-parseopts = (
- "header-strict" => "enable",
- "host-strict" => "enable",
- "host-normalize" => "enable",
- "url-normalize" => "enable",
- "url-normalize-unreserved" => "enable",
- "url-normalize-required" => "enable",
- "url-ctrls-reject" => "enable",
- "url-path-2f-decode" => "enable",
- "url-path-dotseg-remove" => "enable",
- "url-query-20-plus" => "enable"
-)
-
-server.document-root = "/home/jan/projects/DiscoBot/WebInterface/wasm/asm-paint"
-server.port = 8080
-dir-listing.activate = "enable"
-index-file.names = ( "index.html" )
-mimetype.assign = (
- ".html" => "text/html",
- ".txt" => "text/plain",
- ".css" => "text/css",
- ".js" => "application/x-javascript",
- ".jpg" => "image/jpeg",
- ".jpeg" => "image/jpeg",
- ".gif" => "image/gif",
- ".png" => "image/png",
- ".wasm" => "application/wasm",
- "" => "application/octet-stream"
-)
diff --git a/WebInterface/wasm/asm-paint/loader.js b/WebInterface/wasm/asm-paint/loader.js
deleted file mode 100644
index 4566ee1..0000000
--- a/WebInterface/wasm/asm-paint/loader.js
+++ /dev/null
@@ -1,2 +0,0 @@
-import {default as init} from './pkg/asm_paint_rs.js'
-init('./pkg/asm_paint_rs_bg.wasm');
diff --git a/WebInterface/wasm/asm-paint/run b/WebInterface/wasm/asm-paint/run
deleted file mode 100755
index 1da1e35..0000000
--- a/WebInterface/wasm/asm-paint/run
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-wasm-pack build --release --target web
diff --git a/WebInterface/wasm/asm-paint/src/app.rs b/WebInterface/wasm/asm-paint/src/app.rs
deleted file mode 100644
index 005764d..0000000
--- a/WebInterface/wasm/asm-paint/src/app.rs
+++ /dev/null
@@ -1,19 +0,0 @@
-use crate::site::Site;
-
-pub struct App {
- site: Site,
-}
-
-impl App {
- pub fn new() -> Option<Self> {
- Some(Self {
- site: Site::from_current()?,
- })
- }
-
- pub fn run(&mut self) {
- let mut canvas = self.site.create_canvas().unwrap();
- canvas.init().unwrap();
- info!("canvas initialisation was succuessfull");
- }
-}
diff --git a/WebInterface/wasm/asm-paint/src/canvas.rs b/WebInterface/wasm/asm-paint/src/canvas.rs
deleted file mode 100644
index 400e258..0000000
--- a/WebInterface/wasm/asm-paint/src/canvas.rs
+++ /dev/null
@@ -1,39 +0,0 @@
-use web_sys;
-use web_sys::{WebGl2RenderingContext};
-use wasm_bindgen::JsCast;
-use crate::shader::Shaders;
-
-pub struct Canvas {
- element: web_sys::HtmlCanvasElement,
- ctx: WebGl2RenderingContext,
- shaders: Shaders,
-}
-
-impl Canvas {
- pub fn new(element: web_sys::Element) -> Option<Self> {
- let element: web_sys::HtmlCanvasElement =
- element.dyn_into::<web_sys::HtmlCanvasElement>()
- .ok()?;
- debug!("create webgl2 context");
- let ctx = element.get_context("webgl2").ok()??
- .dyn_into::<WebGl2RenderingContext>().ok()?;
- info!("created webgl2 context successfully");
- Some(Self {
- element, ctx,
- shaders: Shaders::new(),
- })
- }
-
- pub fn init(&mut self) -> Result<(), ()> {
- self.shaders.init(&self.ctx).map_err(|_|())?;
- self.ctx.clear_color(1.0, 0.2, 1.0, 1.0);
- self.ctx.clear(WebGl2RenderingContext::COLOR_BUFFER_BIT);
- Ok(())
- }
-}
-
-impl Drop for Canvas {
- fn drop(&mut self) {
- self.shaders.remove(&self.ctx);
- }
-}
diff --git a/WebInterface/wasm/asm-paint/src/client_logger.rs b/WebInterface/wasm/asm-paint/src/client_logger.rs
deleted file mode 100644
index f71918f..0000000
--- a/WebInterface/wasm/asm-paint/src/client_logger.rs
+++ /dev/null
@@ -1,46 +0,0 @@
-use wasm_bindgen::prelude::*;
-
-#[wasm_bindgen]
-extern "C" {
- #[wasm_bindgen(js_namespace=console, js_name=debug)]
- fn __console_debug_colored2(f: &str, c1: &str, c2: &str);
- #[wasm_bindgen(js_namespace=console, js_name=info)]
- fn __console_info_colored2(f: &str, c1: &str, c2: &str);
- #[wasm_bindgen(js_namespace=console, js_name=warn)]
- fn __console_warn_colored2(f: &str, c1: &str, c2: &str);
- #[wasm_bindgen(js_namespace=console, js_name=error)]
- fn __console_error_colored2(f: &str, c1: &str, c2: &str);
-}
-
-fn log(rec: &log::Record) {
- let log_fn = match rec.level() {
- log::Level::Trace | log::Level::Debug => __console_debug_colored2,
- log::Level::Info => __console_info_colored2,
- log::Level::Warn => __console_warn_colored2,
- log::Level::Error => __console_error_colored2,
- };
- log_fn(&format!("{}", rec.args()),
- &format!("color: {}", match rec.level() {
- log::Level::Trace => "violet",
- log::Level::Debug => "blue",
- log::Level::Info => "green",
- log::Level::Warn => "orange",
- log::Level::Error => "red"
- }), "");
-}
-
-pub fn init_logger() {
- fern::Dispatch::new().format(|out, message, record|{
- out.finish(format_args!(
- "%c{}%c {} > {}",
- record.level(),
- record.target(),
- message
- )
- )
- })
- .level(log::LevelFilter::Debug)
- .chain(fern::Output::call(log))
- .apply().unwrap();
-}
-
diff --git a/WebInterface/wasm/asm-paint/src/lib.rs b/WebInterface/wasm/asm-paint/src/lib.rs
deleted file mode 100644
index 6c773c5..0000000
--- a/WebInterface/wasm/asm-paint/src/lib.rs
+++ /dev/null
@@ -1,20 +0,0 @@
-mod client_logger;
-mod shader;
-mod canvas;
-mod site;
-mod app;
-
-use wasm_bindgen::prelude::*;
-
-#[macro_use]
-extern crate log;
-
-#[wasm_bindgen(start)]
-pub fn entry() {
- client_logger::init_logger();
-
- info!("begin running wasm application");
-
- let mut app = app::App::new().unwrap();
- app.run();
-}
diff --git a/WebInterface/wasm/asm-paint/src/shader.rs b/WebInterface/wasm/asm-paint/src/shader.rs
deleted file mode 100644
index 3352bcf..0000000
--- a/WebInterface/wasm/asm-paint/src/shader.rs
+++ /dev/null
@@ -1,97 +0,0 @@
-use web_sys::{WebGlProgram, WebGl2RenderingContext};
-
-const VERTEX_SHADER: &str =
-r#"#version 300 es
-in vec4 pos;
-void main() {
- gl_Position = pos;
-}
-"#;
-
-const FRAGMENT_SHADER: &str =
-r#"#version 300 es
-precision mediump float;
-out vec4 color;
-
-void main() {
- color = vec4(1, 0, 0, 1);
-}
-"#;
-
-pub struct Shaders {
- program: Option<WebGlProgram>,
- pos_loc: i32,
-}
-
-impl Shaders {
- pub fn new() -> Self {
- Self {
- program: None,
- pos_loc: -1
- }
- }
-
- fn create_program(&mut self, ctx: &WebGl2RenderingContext) -> Result<(), String> {
- self.program = Some(ctx.create_program().ok_or("could not create program id")?);
- Ok(())
- }
-
- fn create_shader(&mut self, ctx: &WebGl2RenderingContext,
- shader_type: u32, source: &str) -> Result<(), String> {
- let program = self.program.as_ref().ok_or("could not find created program")?;
- let shader = ctx.create_shader(shader_type)
- .ok_or("could not create shader")?;
- ctx.shader_source(&shader, source);
- ctx.compile_shader(&shader);
- let status = ctx.get_shader_parameter(&shader, WebGl2RenderingContext::COMPILE_STATUS);
- if status == wasm_bindgen::JsValue::TRUE {
- ctx.attach_shader(program, &shader);
- Ok(())
- } else {
- Err(format!("\n{}", ctx.get_shader_info_log(&shader).unwrap_or_default()))
- }
- }
-
- fn create_vertex_shader(&mut self, ctx: &WebGl2RenderingContext) -> Result<(), String> {
- self.create_shader(ctx, WebGl2RenderingContext::VERTEX_SHADER, VERTEX_SHADER)
- }
-
- fn create_fragment_shader(&mut self, ctx: &WebGl2RenderingContext) -> Result<(), String> {
- self.create_shader(ctx, WebGl2RenderingContext::FRAGMENT_SHADER, FRAGMENT_SHADER)
- }
-
- fn compile(&mut self, ctx: &WebGl2RenderingContext) -> Result<(), String> {
- let program = self.program.as_ref().ok_or("could not find created program")?;
- ctx.link_program(program);
- let status = ctx.get_program_parameter(program, WebGl2RenderingContext::LINK_STATUS);
- if status == wasm_bindgen::JsValue::TRUE {
- Ok(())
- } else {
- Err(format!("\n{}", ctx.get_program_info_log(program).unwrap_or_default()))
- }
- }
-
- pub fn init(&mut self, ctx: &WebGl2RenderingContext) -> Result<(), String> {
- debug!("create program");
- self.create_program(ctx)
- .map_err(|e| { error!("webgl2 create program: {}", e); e})?;
- debug!("create vertex shader");
- self.create_vertex_shader(ctx)
- .map_err(|e| { error!("webgl2 create vertex shader: {}", e); e})?;
- debug!("create fragment shader");
- self.create_fragment_shader(ctx)
- .map_err(|e| { error!("webgl2 create fragment shader: {}", e); e})?;
- debug!("compile shader program");
- self.compile(ctx)
- .map_err(|e| { error!("webgl2 shader: {}", e); e})?;
- let program = self.program.as_ref().ok_or("could not find created program")?;
- self.pos_loc = ctx.get_attrib_location(program, "pos");
- trace!("got attrib location 'pos'({})", self.pos_loc);
- info!("initialised shader program");
- Ok(())
- }
-
- pub fn remove(&mut self, ctx: &WebGl2RenderingContext) {
- ctx.delete_program(self.program.as_ref())
- }
-}
diff --git a/WebInterface/wasm/asm-paint/src/site.rs b/WebInterface/wasm/asm-paint/src/site.rs
deleted file mode 100644
index 4ae0237..0000000
--- a/WebInterface/wasm/asm-paint/src/site.rs
+++ /dev/null
@@ -1,28 +0,0 @@
-use web_sys;
-use crate::canvas::Canvas;
-
-pub struct Site {
- window: web_sys::Window,
- document: web_sys::Document,
-}
-
-impl Site {
- pub fn from_current() -> Option<Self> {
- let window = web_sys::window()
- .or_else(|| {error!("unable to query window"); None})?;
- let document = window.document()
- .or_else(|| {error!("unable to query document"); None})?;
- Some(Self {
- window, document
- })
- }
-
- pub fn create_canvas(&self) -> Option<Canvas> {
- debug!("gain canvas element");
- let element = self.document.get_element_by_id("canvas")
- .or_else(|| {error!("could not gain canvas element"); None})?;
- Canvas::new(element)
- .or_else(|| {error!("could not create a webgl2 canvas.
- Your browser doesn't seem to support webgl2"); None})
- }
-}
diff --git a/WebInterface/wasm/webhogg/Cargo.toml b/WebInterface/wasm/webhogg/Cargo.toml
deleted file mode 100644
index 9d6e2ac..0000000
--- a/WebInterface/wasm/webhogg/Cargo.toml
+++ /dev/null
@@ -1,36 +0,0 @@
-[package]
-name = "webhogg"
-version = "0.1.0"
-authors = [
- "natrixaeria",
- "TrueDoctor"
-]
-edition = "2018"
-
-[lib]
-crate-type = ["cdylib"]
-
-[dependencies]
-js-sys = "0.3"
-wasm-bindgen = "0.2"
-log = "0.4"
-fern = "0.5"
-
-[dependencies.web-sys]
-version = "0.3.22"
-features = [
- 'Document',
- 'Event',
- 'MessageEvent',
- 'Element',
- 'HtmlCanvasElement',
- 'WorkerGlobalScope',
- 'DedicatedWorkerGlobalScope',
- 'OffscreenCanvas',
- 'WebGl2RenderingContext',
- 'WebGlShader',
- 'WebGlProgram',
- 'WebGlBuffer',
- 'Window',
- 'Worker'
-]
diff --git a/WebInterface/wasm/webhogg/deploy.py b/WebInterface/wasm/webhogg/deploy.py
deleted file mode 100755
index 0655242..0000000
--- a/WebInterface/wasm/webhogg/deploy.py
+++ /dev/null
@@ -1,137 +0,0 @@
-#!/usr/bin/env python3
-
-from threading import Thread
-from socket import socket, SOL_SOCKET, SO_REUSEADDR
-
-def enable_csp():
- global ADD_HEADERS
- ALL = ["'self'", "developer.mozilla.org"]
- CSP = {
- 'script-src': ["'unsafe-inline'", *ALL],
- 'worker-src': [*ALL],
- 'style-src': ["'unsafe-inline'", *ALL],
- 'default-src': [*ALL],
- }
-
- ADD_HEADERS = 'Content-Security-Policy: ' + '; '.join(
- k + ' ' + ' '.join(v) for k, v in CSP.items())
- # ADD_HEADERS += '\r\n' + ADD_HEADERS.replace('cy: ', 'cy-Report-Only: ')
- print(ADD_HEADERS)
- ADD_HEADERS = '\r\n' + ADD_HEADERS
-
-ADD_HEADERS = ''
-
-class Client:
- def __init__(self, sock, addr):
- self.sock, self.addr = sock, addr
- self.thread = None
-
- def rec(self):
- b = b''
- while not b.endswith(b'\r\n\r\n'):
- b += self.sock.recv(1)
- lines = b.replace(b'\r\n', b'\n').decode('utf-8').strip('\n').split('\n')
- method, loc, ver = lines[0].split(' ')
- print(f'request from \'{self.addr}\': "{loc}"')
- attrs = {key: value for key, value in (i.split(': ') for i in lines[1:])}
- return method, loc, attrs, ver
-
- def sen(self, loc, ver):
- print(f'request {loc}')
- closing = False
- if loc.startswith('/'):
- loc = loc[1:]
- if not loc:
- loc = 'index.html'
- try:
- if loc == 'favicon.ico':
- raise FileNotFoundError
- f = open(loc, 'rb')
- c = f.read()
- f.close()
- print(f'successfully requested {loc}')
- if loc.endswith('.js'):
- mime = 'application/javascript'
- elif loc.endswith('.html'):
- mime = 'text/html'
- elif loc.endswith('.wasm'):
- mime = 'application/wasm'
- else:
- mime = 'text/plain'
- packet = f'HTTP/1.1 200 Success\r\nContent-Length: {len(c)}\r\nContent-Type: {mime}{ADD_HEADERS}\r\n\r\n'.encode('utf-8') + c
- pl = len(packet)
- if pl != self.sock.send(packet):
- self.sock.close()
- closing = True
- except FileNotFoundError:
- print(f'error request {loc}')
- self.sock.send(f'HTTP/1.1 404 Not Found\r\nContent-Length: 0\r\nContent-Type: text/plain\r\n\r\n'.encode('utf-8'))
- finally:
- try:
- f.close()
- except:
- ...
- if closing:
- return True
-
- def run(self):
- while True:
- method, loc, attrs, ver = self.rec()
- if self.sen(loc, ver): break
-
- def run_threaded(self):
- self.thread = Thread(target=self.run)
- self.thread.start()
-
-
-def run_server(addr, port):
- ws = socket()
- ws.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
- ws.bind((addr, port))
- ws.listen()
-
- clients = []
-
- while True:
- c, a = ws.accept()
- print(f'{a[0]}:{a[1]} connected')
- client = Client(c, a)
- clients.append(clients)
- client.run_threaded()
- print('lnuertdenuvtdevn')
-
-
-if __name__ == '__main__':
- from sys import argv
- daemon = False
- addr = 'localhost'
- flag = None
- for arg in argv[1:]:
- if flag is not None:
- if flag == 'addr':
- addr = arg
- elif flag == 'port':
- port = int(arg)
- flag = None
- elif arg in ('-d', '--daemon'):
- daemon = True
- elif arg in ('-a', '--addr', '--address'):
- flag = 'addr'
- elif arg in ('-p', '--port'):
- flag = 'port'
- elif arg in ('--csp',):
- enable_csp()
- else:
- print(f'warn: ignore invalid argument "{arg}"')
- daemon = len(argv) > 1 and argv[1] in ('-d', '--daemon')
- if ':' in addr:
- addr, port = addr.split(':')
- port = int(port)
- if daemon:
- import sys
- from os import getcwd
- from daemon import DaemonContext
- with DaemonContext(working_directory=getcwd(), stderr=sys.stderr):
- run_server(addr, port)
- else:
- run_server(addr, port)
diff --git a/WebInterface/wasm/webhogg/game_logic.js b/WebInterface/wasm/webhogg/game_logic.js
deleted file mode 100644
index fad5d82..0000000
--- a/WebInterface/wasm/webhogg/game_logic.js
+++ /dev/null
@@ -1,393 +0,0 @@
-const __exports = {};
-let wasm;
-
-const heap = new Array(32);
-
-heap.fill(undefined);
-
-heap.push(undefined, null, true, false);
-
-let heap_next = heap.length;
-
-function addHeapObject(obj) {
- if (heap_next === heap.length) heap.push(heap.length + 1);
- const idx = heap_next;
- heap_next = heap[idx];
-
- heap[idx] = obj;
- return idx;
-}
-/**
-* @param {any} worker
-* @returns {void}
-*/
-function game_logic_entry(worker) {
- return wasm.game_logic_entry(addHeapObject(worker));
-}
-__exports.game_logic_entry = game_logic_entry
-
-/**
-* @param {any} worker
-* @param {any} ecanvas
-* @returns {void}
-*/
-function graphics_entry(worker, ecanvas) {
- return wasm.graphics_entry(addHeapObject(worker), addHeapObject(ecanvas));
-}
-__exports.graphics_entry = graphics_entry
-
-let cachedTextDecoder = new TextDecoder('utf-8');
-
-let cachegetUint8Memory = null;
-function getUint8Memory() {
- if (cachegetUint8Memory === null || cachegetUint8Memory.buffer !== wasm.memory.buffer) {
- cachegetUint8Memory = new Uint8Array(wasm.memory.buffer);
- }
- return cachegetUint8Memory;
-}
-
-function getStringFromWasm(ptr, len) {
- return cachedTextDecoder.decode(getUint8Memory().subarray(ptr, ptr + len));
-}
-
-function __wbg_debug_eacd5b227c4c01c7(arg0, arg1, arg2, arg3, arg4, arg5) {
- let varg0 = getStringFromWasm(arg0, arg1);
- let varg2 = getStringFromWasm(arg2, arg3);
- let varg4 = getStringFromWasm(arg4, arg5);
- console.debug(varg0, varg2, varg4);
-}
-__exports.__wbg_debug_eacd5b227c4c01c7 = __wbg_debug_eacd5b227c4c01c7
-
-function __wbg_info_be654745b6a55079(arg0, arg1, arg2, arg3, arg4, arg5) {
- let varg0 = getStringFromWasm(arg0, arg1);
- let varg2 = getStringFromWasm(arg2, arg3);
- let varg4 = getStringFromWasm(arg4, arg5);
- console.info(varg0, varg2, varg4);
-}
-__exports.__wbg_info_be654745b6a55079 = __wbg_info_be654745b6a55079
-
-function __wbg_warn_804a0523852c6d10(arg0, arg1, arg2, arg3, arg4, arg5) {
- let varg0 = getStringFromWasm(arg0, arg1);
- let varg2 = getStringFromWasm(arg2, arg3);
- let varg4 = getStringFromWasm(arg4, arg5);
- console.warn(varg0, varg2, varg4);
-}
-__exports.__wbg_warn_804a0523852c6d10 = __wbg_warn_804a0523852c6d10
-
-function __wbg_error_56a861ecc80f27e1(arg0, arg1, arg2, arg3, arg4, arg5) {
- let varg0 = getStringFromWasm(arg0, arg1);
- let varg2 = getStringFromWasm(arg2, arg3);
- let varg4 = getStringFromWasm(arg4, arg5);
- console.error(varg0, varg2, varg4);
-}
-__exports.__wbg_error_56a861ecc80f27e1 = __wbg_error_56a861ecc80f27e1
-
-function getObject(idx) { return heap[idx]; }
-
-function __widl_f_set_onmessage_DedicatedWorkerGlobalScope(arg0, arg1) {
- getObject(arg0).onmessage = getObject(arg1);
-}
-__exports.__widl_f_set_onmessage_DedicatedWorkerGlobalScope = __widl_f_set_onmessage_DedicatedWorkerGlobalScope
-
-function __widl_f_data_MessageEvent(arg0) {
- return addHeapObject(getObject(arg0).data);
-}
-__exports.__widl_f_data_MessageEvent = __widl_f_data_MessageEvent
-
-function isLikeNone(x) {
- return x === undefined || x === null;
-}
-
-let cachegetUint32Memory = null;
-function getUint32Memory() {
- if (cachegetUint32Memory === null || cachegetUint32Memory.buffer !== wasm.memory.buffer) {
- cachegetUint32Memory = new Uint32Array(wasm.memory.buffer);
- }
- return cachegetUint32Memory;
-}
-
-function handleError(exnptr, e) {
- const view = getUint32Memory();
- view[exnptr / 4] = 1;
- view[exnptr / 4 + 1] = addHeapObject(e);
-}
-
-function __widl_f_get_context_OffscreenCanvas(arg0, arg1, arg2, exnptr) {
- let varg1 = getStringFromWasm(arg1, arg2);
- try {
-
- const val = getObject(arg0).getContext(varg1);
- return isLikeNone(val) ? 0 : addHeapObject(val);
-
- } catch (e) {
- handleError(exnptr, e);
- }
-}
-__exports.__widl_f_get_context_OffscreenCanvas = __widl_f_get_context_OffscreenCanvas
-
-function __widl_instanceof_WebGL2RenderingContext(idx) { return getObject(idx) instanceof WebGL2RenderingContext ? 1 : 0; }
-__exports.__widl_instanceof_WebGL2RenderingContext = __widl_instanceof_WebGL2RenderingContext
-
-function __widl_f_clear_WebGL2RenderingContext(arg0, arg1) {
- getObject(arg0).clear(arg1 >>> 0);
-}
-__exports.__widl_f_clear_WebGL2RenderingContext = __widl_f_clear_WebGL2RenderingContext
-
-function __widl_f_clear_color_WebGL2RenderingContext(arg0, arg1, arg2, arg3, arg4) {
- getObject(arg0).clearColor(arg1, arg2, arg3, arg4);
-}
-__exports.__widl_f_clear_color_WebGL2RenderingContext = __widl_f_clear_color_WebGL2RenderingContext
-
-function __widl_f_post_message_Worker(arg0, arg1, exnptr) {
- try {
- getObject(arg0).postMessage(getObject(arg1));
- } catch (e) {
- handleError(exnptr, e);
- }
-}
-__exports.__widl_f_post_message_Worker = __widl_f_post_message_Worker
-
-function __wbg_new0_b4c0f6100aa61878() {
- return addHeapObject(new Date());
-}
-__exports.__wbg_new0_b4c0f6100aa61878 = __wbg_new0_b4c0f6100aa61878
-
-function __wbg_toISOString_580e1bcc780bf968(arg0) {
- return addHeapObject(getObject(arg0).toISOString());
-}
-__exports.__wbg_toISOString_580e1bcc780bf968 = __wbg_toISOString_580e1bcc780bf968
-
-function __wbg_get_48d637c66043532c(arg0, arg1, exnptr) {
- try {
- return addHeapObject(Reflect.get(getObject(arg0), getObject(arg1)));
- } catch (e) {
- handleError(exnptr, e);
- }
-}
-__exports.__wbg_get_48d637c66043532c = __wbg_get_48d637c66043532c
-
-function __wbindgen_string_new(p, l) { return addHeapObject(getStringFromWasm(p, l)); }
-__exports.__wbindgen_string_new = __wbindgen_string_new
-
-let WASM_VECTOR_LEN = 0;
-
-let cachedTextEncoder = new TextEncoder('utf-8');
-
-let passStringToWasm;
-if (typeof cachedTextEncoder.encodeInto === 'function') {
- passStringToWasm = function(arg) {
-
-
- let size = arg.length;
- let ptr = wasm.__wbindgen_malloc(size);
- let offset = 0;
- {
- const mem = getUint8Memory();
- for (; offset < arg.length; offset++) {
- const code = arg.charCodeAt(offset);
- if (code > 0x7F) break;
- mem[ptr + offset] = code;
- }
- }
-
- if (offset !== arg.length) {
- arg = arg.slice(offset);
- ptr = wasm.__wbindgen_realloc(ptr, size, size = offset + arg.length * 3);
- const view = getUint8Memory().subarray(ptr + offset, ptr + size);
- const ret = cachedTextEncoder.encodeInto(arg, view);
-
- offset += ret.written;
- }
- WASM_VECTOR_LEN = offset;
- return ptr;
- };
-} else {
- passStringToWasm = function(arg) {
-
-
- let size = arg.length;
- let ptr = wasm.__wbindgen_malloc(size);
- let offset = 0;
- {
- const mem = getUint8Memory();
- for (; offset < arg.length; offset++) {
- const code = arg.charCodeAt(offset);
- if (code > 0x7F) break;
- mem[ptr + offset] = code;
- }
- }
-
- if (offset !== arg.length) {
- const buf = cachedTextEncoder.encode(arg.slice(offset));
- ptr = wasm.__wbindgen_realloc(ptr, size, size = offset + buf.length);
- getUint8Memory().set(buf, ptr + offset);
- offset += buf.length;
- }
- WASM_VECTOR_LEN = offset;
- return ptr;
- };
-}
-
-function __wbindgen_string_get(i, len_ptr) {
- let obj = getObject(i);
- if (typeof(obj) !== 'string') return 0;
- const ptr = passStringToWasm(obj);
- getUint32Memory()[len_ptr / 4] = WASM_VECTOR_LEN;
- return ptr;
-}
-__exports.__wbindgen_string_get = __wbindgen_string_get
-
-function __wbindgen_debug_string(i, len_ptr) {
- const debug_str =
- val => {
- // primitive types
- const type = typeof val;
- if (type == 'number' || type == 'boolean' || val == null) {
- return `${val}`;
- }
- if (type == 'string') {
- return `"${val}"`;
- }
- if (type == 'symbol') {
- const description = val.description;
- if (description == null) {
- return 'Symbol';
- } else {
- return `Symbol(${description})`;
- }
- }
- if (type == 'function') {
- const name = val.name;
- if (typeof name == 'string' && name.length > 0) {
- return `Function(${name})`;
- } else {
- return 'Function';
- }
- }
- // objects
- if (Array.isArray(val)) {
- const length = val.length;
- let debug = '[';
- if (length > 0) {
- debug += debug_str(val[0]);
- }
- for(let i = 1; i < length; i++) {
- debug += ', ' + debug_str(val[i]);
- }
- debug += ']';
- return debug;
- }
- // Test for built-in
- const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
- let className;
- if (builtInMatches.length > 1) {
- className = builtInMatches[1];
- } else {
- // Failed to match the standard '[object ClassName]'
- return toString.call(val);
- }
- if (className == 'Object') {
- // we're a user defined class or Object
- // JSON.stringify avoids problems with cycles, and is generally much
- // easier than looping through ownProperties of `val`.
- try {
- return 'Object(' + JSON.stringify(val) + ')';
- } catch (_) {
- return 'Object';
- }
- }
- // errors
- if (val instanceof Error) {
- return `${val.name}: ${val.message}
- ${val.stack}`;
- }
- // TODO we could test for more things here, like `Set`s and `Map`s.
- return className;
-}
-;
-const toString = Object.prototype.toString;
-const val = getObject(i);
-const debug = debug_str(val);
-const ptr = passStringToWasm(debug);
-getUint32Memory()[len_ptr / 4] = WASM_VECTOR_LEN;
-return ptr;
-}
-__exports.__wbindgen_debug_string = __wbindgen_debug_string
-
-function dropObject(idx) {
- if (idx < 36) return;
- heap[idx] = heap_next;
- heap_next = idx;
-}
-
-function takeObject(idx) {
- const ret = getObject(idx);
- dropObject(idx);
- return ret;
-}
-
-function __wbindgen_cb_drop(i) {
- const obj = takeObject(i).original;
- if (obj.cnt-- == 1) {
- obj.a = 0;
- return 1;
- }
- return 0;
-}
-__exports.__wbindgen_cb_drop = __wbindgen_cb_drop
-
-function __wbindgen_throw(ptr, len) {
- throw new Error(getStringFromWasm(ptr, len));
-}
-__exports.__wbindgen_throw = __wbindgen_throw
-
-function __wbindgen_closure_wrapper55(a, b, _ignored) {
- const f = wasm.__wbg_function_table.get(23);
- const d = wasm.__wbg_function_table.get(24);
- const cb = function(arg0) {
- this.cnt++;
- let a = this.a;
- this.a = 0;
- try {
- return f(a, b, addHeapObject(arg0));
-
- } finally {
- if (--this.cnt === 0) d(a, b);
- else this.a = a;
-
- }
-
- };
- cb.a = a;
- cb.cnt = 1;
- let real = cb.bind(cb);
- real.original = cb;
- return addHeapObject(real);
-}
-__exports.__wbindgen_closure_wrapper55 = __wbindgen_closure_wrapper55
-
-function __wbindgen_object_clone_ref(idx) {
- return addHeapObject(getObject(idx));
-}
-__exports.__wbindgen_object_clone_ref = __wbindgen_object_clone_ref
-
-function __wbindgen_object_drop_ref(i) { dropObject(i); }
-__exports.__wbindgen_object_drop_ref = __wbindgen_object_drop_ref
-
-//!IMPORTANT_STUFF
-const WASM_URL = './pkg/webhogg_bg.wasm';
-
-const imports = { './webhogg': __exports };
-
-onmessage = function (e) {
- console.log('transport canvas');
-
- let res = WebAssembly.instantiateStreaming(fetch(WASM_URL), imports);
-
- res.then(result => {
- wasm = result.instance.exports;
- game_logic_entry(graphics);
- });
- let graphics = new Worker('./graphics.js', {type: 'module', credentials: 'include'});
- graphics.postMessage(e.data, [e.data.canvas]);
-}
diff --git a/WebInterface/wasm/webhogg/graphics.js b/WebInterface/wasm/webhogg/graphics.js
deleted file mode 100644
index 11ddf89..0000000
--- a/WebInterface/wasm/webhogg/graphics.js
+++ /dev/null
@@ -1,401 +0,0 @@
-const __exports = {};
-let wasm;
-
-const heap = new Array(32);
-
-heap.fill(undefined);
-
-heap.push(undefined, null, true, false);
-
-let heap_next = heap.length;
-
-function addHeapObject(obj) {
- if (heap_next === heap.length) heap.push(heap.length + 1);
- const idx = heap_next;
- heap_next = heap[idx];
-
- heap[idx] = obj;
- return idx;
-}
-/**
-* @param {any} worker
-* @returns {void}
-*/
-function game_logic_entry(worker) {
- return wasm.game_logic_entry(addHeapObject(worker));
-}
-__exports.game_logic_entry = game_logic_entry
-
-/**
-* @param {any} worker
-* @param {any} ecanvas
-* @returns {void}
-*/
-function graphics_entry(worker, ecanvas) {
- return wasm.graphics_entry(addHeapObject(worker), addHeapObject(ecanvas));
-}
-__exports.graphics_entry = graphics_entry
-
-let cachedTextDecoder = new TextDecoder('utf-8');
-
-let cachegetUint8Memory = null;
-function getUint8Memory() {
- if (cachegetUint8Memory === null || cachegetUint8Memory.buffer !== wasm.memory.buffer) {
- cachegetUint8Memory = new Uint8Array(wasm.memory.buffer);
- }
- return cachegetUint8Memory;
-}
-
-function getStringFromWasm(ptr, len) {
- return cachedTextDecoder.decode(getUint8Memory().subarray(ptr, ptr + len));
-}
-
-function __wbg_debug_eacd5b227c4c01c7(arg0, arg1, arg2, arg3, arg4, arg5) {
- let varg0 = getStringFromWasm(arg0, arg1);
- let varg2 = getStringFromWasm(arg2, arg3);
- let varg4 = getStringFromWasm(arg4, arg5);
- console.debug(varg0, varg2, varg4);
-}
-__exports.__wbg_debug_eacd5b227c4c01c7 = __wbg_debug_eacd5b227c4c01c7
-
-function __wbg_info_be654745b6a55079(arg0, arg1, arg2, arg3, arg4, arg5) {
- let varg0 = getStringFromWasm(arg0, arg1);
- let varg2 = getStringFromWasm(arg2, arg3);
- let varg4 = getStringFromWasm(arg4, arg5);
- console.info(varg0, varg2, varg4);
-}
-__exports.__wbg_info_be654745b6a55079 = __wbg_info_be654745b6a55079
-
-function __wbg_warn_804a0523852c6d10(arg0, arg1, arg2, arg3, arg4, arg5) {
- let varg0 = getStringFromWasm(arg0, arg1);
- let varg2 = getStringFromWasm(arg2, arg3);
- let varg4 = getStringFromWasm(arg4, arg5);
- console.warn(varg0, varg2, varg4);
-}
-__exports.__wbg_warn_804a0523852c6d10 = __wbg_warn_804a0523852c6d10
-
-function __wbg_error_56a861ecc80f27e1(arg0, arg1, arg2, arg3, arg4, arg5) {
- let varg0 = getStringFromWasm(arg0, arg1);
- let varg2 = getStringFromWasm(arg2, arg3);
- let varg4 = getStringFromWasm(arg4, arg5);
- console.error(varg0, varg2, varg4);
-}
-__exports.__wbg_error_56a861ecc80f27e1 = __wbg_error_56a861ecc80f27e1
-
-function getObject(idx) { return heap[idx]; }
-
-function __widl_f_set_onmessage_DedicatedWorkerGlobalScope(arg0, arg1) {
- getObject(arg0).onmessage = getObject(arg1);
-}
-__exports.__widl_f_set_onmessage_DedicatedWorkerGlobalScope = __widl_f_set_onmessage_DedicatedWorkerGlobalScope
-
-function __widl_f_data_MessageEvent(arg0) {
- return addHeapObject(getObject(arg0).data);
-}
-__exports.__widl_f_data_MessageEvent = __widl_f_data_MessageEvent
-
-function isLikeNone(x) {
- return x === undefined || x === null;
-}
-
-let cachegetUint32Memory = null;
-function getUint32Memory() {
- if (cachegetUint32Memory === null || cachegetUint32Memory.buffer !== wasm.memory.buffer) {
- cachegetUint32Memory = new Uint32Array(wasm.memory.buffer);
- }
- return cachegetUint32Memory;
-}
-
-function handleError(exnptr, e) {
- const view = getUint32Memory();
- view[exnptr / 4] = 1;
- view[exnptr / 4 + 1] = addHeapObject(e);
-}
-
-function __widl_f_get_context_OffscreenCanvas(arg0, arg1, arg2, exnptr) {
- let varg1 = getStringFromWasm(arg1, arg2);
- try {
-
- const val = getObject(arg0).getContext(varg1);
- return isLikeNone(val) ? 0 : addHeapObject(val);
-
- } catch (e) {
- handleError(exnptr, e);
- }
-}
-__exports.__widl_f_get_context_OffscreenCanvas = __widl_f_get_context_OffscreenCanvas
-
-function __widl_instanceof_WebGL2RenderingContext(idx) { return getObject(idx) instanceof WebGL2RenderingContext ? 1 : 0; }
-__exports.__widl_instanceof_WebGL2RenderingContext = __widl_instanceof_WebGL2RenderingContext
-
-function __widl_f_clear_WebGL2RenderingContext(arg0, arg1) {
- getObject(arg0).clear(arg1 >>> 0);
-}
-__exports.__widl_f_clear_WebGL2RenderingContext = __widl_f_clear_WebGL2RenderingContext
-
-function __widl_f_clear_color_WebGL2RenderingContext(arg0, arg1, arg2, arg3, arg4) {
- getObject(arg0).clearColor(arg1, arg2, arg3, arg4);
-}
-__exports.__widl_f_clear_color_WebGL2RenderingContext = __widl_f_clear_color_WebGL2RenderingContext
-
-function __widl_f_post_message_Worker(arg0, arg1, exnptr) {
- try {
- getObject(arg0).postMessage(getObject(arg1));
- } catch (e) {
- handleError(exnptr, e);
- }
-}
-__exports.__widl_f_post_message_Worker = __widl_f_post_message_Worker
-
-function __wbg_new0_b4c0f6100aa61878() {
- return addHeapObject(new Date());
-}
-__exports.__wbg_new0_b4c0f6100aa61878 = __wbg_new0_b4c0f6100aa61878
-
-function __wbg_toISOString_580e1bcc780bf968(arg0) {
- return addHeapObject(getObject(arg0).toISOString());
-}
-__exports.__wbg_toISOString_580e1bcc780bf968 = __wbg_toISOString_580e1bcc780bf968
-
-function __wbg_get_48d637c66043532c(arg0, arg1, exnptr) {
- try {
- return addHeapObject(Reflect.get(getObject(arg0), getObject(arg1)));
- } catch (e) {
- handleError(exnptr, e);
- }
-}
-__exports.__wbg_get_48d637c66043532c = __wbg_get_48d637c66043532c
-
-function __wbindgen_string_new(p, l) { return addHeapObject(getStringFromWasm(p, l)); }
-__exports.__wbindgen_string_new = __wbindgen_string_new
-
-let WASM_VECTOR_LEN = 0;
-
-let cachedTextEncoder = new TextEncoder('utf-8');
-
-let passStringToWasm;
-if (typeof cachedTextEncoder.encodeInto === 'function') {
- passStringToWasm = function(arg) {
-
-
- let size = arg.length;
- let ptr = wasm.__wbindgen_malloc(size);
- let offset = 0;
- {
- const mem = getUint8Memory();
- for (; offset < arg.length; offset++) {
- const code = arg.charCodeAt(offset);
- if (code > 0x7F) break;
- mem[ptr + offset] = code;
- }
- }
-
- if (offset !== arg.length) {
- arg = arg.slice(offset);
- ptr = wasm.__wbindgen_realloc(ptr, size, size = offset + arg.length * 3);
- const view = getUint8Memory().subarray(ptr + offset, ptr + size);
- const ret = cachedTextEncoder.encodeInto(arg, view);
-
- offset += ret.written;
- }
- WASM_VECTOR_LEN = offset;
- return ptr;
- };
-} else {
- passStringToWasm = function(arg) {
-
-
- let size = arg.length;
- let ptr = wasm.__wbindgen_malloc(size);
- let offset = 0;
- {
- const mem = getUint8Memory();
- for (; offset < arg.length; offset++) {
- const code = arg.charCodeAt(offset);
- if (code > 0x7F) break;
- mem[ptr + offset] = code;
- }
- }
-
- if (offset !== arg.length) {
- const buf = cachedTextEncoder.encode(arg.slice(offset));
- ptr = wasm.__wbindgen_realloc(ptr, size, size = offset + buf.length);
- getUint8Memory().set(buf, ptr + offset);
- offset += buf.length;
- }
- WASM_VECTOR_LEN = offset;
- return ptr;
- };
-}
-
-function __wbindgen_string_get(i, len_ptr) {
- let obj = getObject(i);
- if (typeof(obj) !== 'string') return 0;
- const ptr = passStringToWasm(obj);
- getUint32Memory()[len_ptr / 4] = WASM_VECTOR_LEN;
- return ptr;
-}
-__exports.__wbindgen_string_get = __wbindgen_string_get
-
-function __wbindgen_debug_string(i, len_ptr) {
- const debug_str =
- val => {
- // primitive types
- const type = typeof val;
- if (type == 'number' || type == 'boolean' || val == null) {
- return `${val}`;
- }
- if (type == 'string') {
- return `"${val}"`;
- }
- if (type == 'symbol') {
- const description = val.description;
- if (description == null) {
- return 'Symbol';
- } else {
- return `Symbol(${description})`;
- }
- }
- if (type == 'function') {
- const name = val.name;
- if (typeof name == 'string' && name.length > 0) {
- return `Function(${name})`;
- } else {
- return 'Function';
- }
- }
- // objects
- if (Array.isArray(val)) {
- const length = val.length;
- let debug = '[';
- if (length > 0) {
- debug += debug_str(val[0]);
- }
- for(let i = 1; i < length; i++) {
- debug += ', ' + debug_str(val[i]);
- }
- debug += ']';
- return debug;
- }
- // Test for built-in
- const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
- let className;
- if (builtInMatches.length > 1) {
- className = builtInMatches[1];
- } else {
- // Failed to match the standard '[object ClassName]'
- return toString.call(val);
- }
- if (className == 'Object') {
- // we're a user defined class or Object
- // JSON.stringify avoids problems with cycles, and is generally much
- // easier than looping through ownProperties of `val`.
- try {
- return 'Object(' + JSON.stringify(val) + ')';
- } catch (_) {
- return 'Object';
- }
- }
- // errors
- if (val instanceof Error) {
- return `${val.name}: ${val.message}
- ${val.stack}`;
- }
- // TODO we could test for more things here, like `Set`s and `Map`s.
- return className;
-}
-;
-const toString = Object.prototype.toString;
-const val = getObject(i);
-const debug = debug_str(val);
-const ptr = passStringToWasm(debug);
-getUint32Memory()[len_ptr / 4] = WASM_VECTOR_LEN;
-return ptr;
-}
-__exports.__wbindgen_debug_string = __wbindgen_debug_string
-
-function dropObject(idx) {
- if (idx < 36) return;
- heap[idx] = heap_next;
- heap_next = idx;
-}
-
-function takeObject(idx) {
- const ret = getObject(idx);
- dropObject(idx);
- return ret;
-}
-
-function __wbindgen_cb_drop(i) {
- const obj = takeObject(i).original;
- if (obj.cnt-- == 1) {
- obj.a = 0;
- return 1;
- }
- return 0;
-}
-__exports.__wbindgen_cb_drop = __wbindgen_cb_drop
-
-function __wbindgen_throw(ptr, len) {
- throw new Error(getStringFromWasm(ptr, len));
-}
-__exports.__wbindgen_throw = __wbindgen_throw
-
-function __wbindgen_closure_wrapper55(a, b, _ignored) {
- const f = wasm.__wbg_function_table.get(23);
- const d = wasm.__wbg_function_table.get(24);
- const cb = function(arg0) {
- this.cnt++;
- let a = this.a;
- this.a = 0;
- try {
- return f(a, b, addHeapObject(arg0));
-
- } finally {
- if (--this.cnt === 0) d(a, b);
- else this.a = a;
-
- }
-
- };
- cb.a = a;
- cb.cnt = 1;
- let real = cb.bind(cb);
- real.original = cb;
- return addHeapObject(real);
-}
-__exports.__wbindgen_closure_wrapper55 = __wbindgen_closure_wrapper55
-
-function __wbindgen_object_clone_ref(idx) {
- return addHeapObject(getObject(idx));
-}
-__exports.__wbindgen_object_clone_ref = __wbindgen_object_clone_ref
-
-function __wbindgen_object_drop_ref(i) { dropObject(i); }
-__exports.__wbindgen_object_drop_ref = __wbindgen_object_drop_ref
-
-//!IMPORTANT_STUFF
-const WASM_URL = './pkg/webhogg_bg.wasm';
-
-const imports = { './webhogg': __exports };
-
-let res = WebAssembly.instantiateStreaming(fetch(WASM_URL), imports);
-
-let first = true;
-let msg = null;
-onmessage = function (e) {
- if (first) {
- first = false;
- console.log('got context: ', e.data);
- msg = e.data;
- }
-}
-while (msg === null) {
- console.log('yay');
- res.then(result => {
- wasm = result.instance.exports;
- console.log('context sndng: ', msg);
- graphics_entry(self, msg);
- });
- break;
-}
diff --git a/WebInterface/wasm/webhogg/index.html b/WebInterface/wasm/webhogg/index.html
deleted file mode 100644
index ad951a6..0000000
--- a/WebInterface/wasm/webhogg/index.html
+++ /dev/null
@@ -1,24 +0,0 @@
-<!doctype html>
-<html>
- <head>
- <meta charset="UTF-8">
- <title>webhogg</title>
- <style>
- body {
- margin: 0;
- background: black;
- }
- #canvas {
- width: 100%;
- height: 100%;
- }
- img {
- background: violet;
- }
- </style>
- </head>
- <body>
- <canvas id='canvas'></canvas>
- </body>
- <script src='loader.js'></script>
-</html>
diff --git a/WebInterface/wasm/webhogg/killpy b/WebInterface/wasm/webhogg/killpy
deleted file mode 100755
index 5e2b9bc..0000000
--- a/WebInterface/wasm/webhogg/killpy
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/sh
-killall python3
diff --git a/WebInterface/wasm/webhogg/loader.js b/WebInterface/wasm/webhogg/loader.js
deleted file mode 100644
index 51c4354..0000000
--- a/WebInterface/wasm/webhogg/loader.js
+++ /dev/null
@@ -1,9 +0,0 @@
-let canvas = document.getElementById('canvas');
-
-let game_logic = new Worker(
- './game_logic.js',
- {type: 'module', credentials: 'include'}
-);
-
-let ofc = canvas.transferControlToOffscreen();
-game_logic.postMessage({canvas: ofc}, [ofc]);
diff --git a/WebInterface/wasm/webhogg/run b/WebInterface/wasm/webhogg/run
deleted file mode 100755
index 484835a..0000000
--- a/WebInterface/wasm/webhogg/run
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/bin/sh
-
-wasm-pack build --release --target web
-python update.py
-sh killpy
-python3 deploy.py -d -a 0.0.0.0:8080
diff --git a/WebInterface/wasm/webhogg/src/canvas.rs b/WebInterface/wasm/webhogg/src/canvas.rs
deleted file mode 100644
index bc694ed..0000000
--- a/WebInterface/wasm/webhogg/src/canvas.rs
+++ /dev/null
@@ -1,36 +0,0 @@
-use web_sys::WebGl2RenderingContext as WebGl2;
-use wasm_bindgen::JsCast;
-use crate::webhogg_exception::WebhoggException;
-use web_sys::OffscreenCanvas as ECanvas;
-
-pub struct Canvas {
- ctx: WebGl2,
-}
-
-impl Canvas {
- pub fn from_existing(canvas: &ECanvas) -> Result<Self, WebhoggException> {
- info!("messages lol");
- let ctx = canvas.get_context("webgl2")
- .map_err(|x| WebhoggException::WebGlContextError(
- format!("obtained invalid webgl2 context js value: {:?}", x)))?
- .ok_or(WebhoggException::WebGlContextError(
- "could not obtaine webgl2 context".to_string()))?
- .dyn_into::<WebGl2>()
- .map_err(|_| WebhoggException::WebGlContextError(
- "obtained invalid webgl2 context js object".to_string()))?;
- info!("successfully obtained webgl2 context");
- ctx.clear_color(0.6, 0.0, 0.6, 1.0);
- ctx.clear(WebGl2::COLOR_BUFFER_BIT);
- Ok(Self {
- ctx,
- })
- }
-
- pub fn gl<'a>(&'a self) -> &'a WebGl2 {
- &self.ctx
- }
-
- pub fn gl_mut<'a>(&'a mut self) -> &'a mut WebGl2 {
- &mut self.ctx
- }
-}
diff --git a/WebInterface/wasm/webhogg/src/client_logger.rs b/WebInterface/wasm/webhogg/src/client_logger.rs
deleted file mode 100644
index f537631..0000000
--- a/WebInterface/wasm/webhogg/src/client_logger.rs
+++ /dev/null
@@ -1,47 +0,0 @@
-use wasm_bindgen::prelude::*;
-
-#[wasm_bindgen]
-extern "C" {
- #[wasm_bindgen(js_namespace=console, js_name=debug)]
- fn __console_debug_colored2(f: &str, c1: &str, c2: &str);
- #[wasm_bindgen(js_namespace=console, js_name=info)]
- fn __console_info_colored2(f: &str, c1: &str, c2: &str);
- #[wasm_bindgen(js_namespace=console, js_name=warn)]
- fn __console_warn_colored2(f: &str, c1: &str, c2: &str);
- #[wasm_bindgen(js_namespace=console, js_name=error)]
- fn __console_error_colored2(f: &str, c1: &str, c2: &str);
-}
-
-fn log(rec: &log::Record) {
- let log_fn = match rec.level() {
- log::Level::Trace | log::Level::Debug => __console_debug_colored2,
- log::Level::Info => __console_info_colored2,
- log::Level::Warn => __console_warn_colored2,
- log::Level::Error => __console_error_colored2,
- };
- log_fn(&format!("{}", rec.args()),
- &format!("color: {}", match rec.level() {
- log::Level::Trace => "violet",
- log::Level::Debug => "blue",
- log::Level::Info => "green",
- log::Level::Warn => "orange",
- log::Level::Error => "red"
- }), "");
-}
-
-pub fn init_logger() {
- fern::Dispatch::new().format(|out, message, record|{
- out.finish(format_args!(
- "%c{}%c |{}| {} > {}",
- record.level(),
- String::from(js_sys::Date::new_0().to_iso_string()),
- record.target(),
- message
- )
- )
- })
- .level(log::LevelFilter::Debug)
- .chain(fern::Output::call(log))
- .apply().unwrap();
-}
-
diff --git a/WebInterface/wasm/webhogg/src/lib.rs b/WebInterface/wasm/webhogg/src/lib.rs
deleted file mode 100644
index 6d9fca9..0000000
--- a/WebInterface/wasm/webhogg/src/lib.rs
+++ /dev/null
@@ -1,44 +0,0 @@
-mod client_logger;
-mod webhogg_exception;
-mod canvas;
-
-use wasm_bindgen::prelude::*;
-use web_sys::Worker;
-use web_sys::OffscreenCanvas as ECanvas;
-
-#[macro_use]
-extern crate log;
-
-#[wasm_bindgen]
-pub fn game_logic_entry(worker: web_sys::Worker) {
- client_logger::init_logger();
-
- info!("hello from game logic wasm");
- worker.post_message(&wasm_bindgen::JsValue::from_str("premsg frm wasm_gLe"))
- .unwrap();
- info!("game logic terminated");
-}
-
-#[wasm_bindgen]
-pub fn graphics_entry(worker: web_sys::DedicatedWorkerGlobalScope,
- ecanvas: JsValue) {
- client_logger::init_logger();
-
- let ecanvas: ECanvas = js_sys::Reflect::get(&ecanvas,
- &wasm_bindgen::JsValue::from_str("canvas"))
- .map_err(|e| error!("could not load canvas"))
- .unwrap().into();
-
- info!("hello from graphics wasm {:?}", ecanvas);
- let handler = wasm_bindgen::closure::Closure::once_into_js(
- (|e: web_sys::MessageEvent| {
- info!("things are getting wired: {:?}", e.data());
- }));
- worker.set_onmessage(Some(&js_sys::Function::from(handler)));
-
- let canvas = canvas::Canvas::from_existing(&ecanvas)
- .map_err(|e| error!("{}", e))
- .unwrap();
-
- info!("graphics terminated");
-}
diff --git a/WebInterface/wasm/webhogg/src/webhogg_exception.rs b/WebInterface/wasm/webhogg/src/webhogg_exception.rs
deleted file mode 100644
index 46eedd6..0000000
--- a/WebInterface/wasm/webhogg/src/webhogg_exception.rs
+++ /dev/null
@@ -1,39 +0,0 @@
-use std::error::Error;
-
-#[derive(Debug)]
-pub enum WebhoggException {
- DomError(String),
- WebGlContextError(String),
-}
-
-impl WebhoggException {
- fn err_name(&self) -> &str {
- match self {
- WebhoggException::DomError(_) => "DomError",
- WebhoggException::WebGlContextError(_) => "WebGlContextError",
- }
- }
-}
-
-impl Error for WebhoggException {
- fn description(&self) -> &str {
- match self {
- WebhoggException::DomError(desc) => desc,
- WebhoggException::WebGlContextError(desc) => desc,
- }
- }
-
- fn cause(&self) -> Option<&dyn Error> {
- self.source()
- }
-
- fn source(&self) -> Option<&(dyn Error + 'static)> {
- None
- }
-}
-
-impl std::fmt::Display for WebhoggException {
- fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
- write!(f, "WebhoggException::{} {}", self.err_name(), self.description())
- }
-}
diff --git a/WebInterface/wasm/webhogg/target/.rustc_info.json b/WebInterface/wasm/webhogg/target/.rustc_info.json
deleted file mode 100644
index 6f83518..0000000
--- a/WebInterface/wasm/webhogg/target/.rustc_info.json
+++ /dev/null
@@ -1 +0,0 @@
-{"rustc_fingerprint":5653700290818914945,"outputs":{"1164083562126845933":["rustc 1.34.1 (fc50f328b 2019-04-24)\nbinary: rustc\ncommit-hash: fc50f328b0353b285421b8ff5d4100966387a997\ncommit-date: 2019-04-24\nhost: x86_64-unknown-linux-gnu\nrelease: 1.34.1\nLLVM version: 8.0\n",""],"6217262102979750783":["___.wasm\nlib___.rlib\n___.wasm\nlib___.a\n/home/jan/.rustup/toolchains/stable-x86_64-unknown-linux-gnu\ndebug_assertions\nproc_macro\ntarget_arch=\"wasm32\"\ntarget_endian=\"little\"\ntarget_env=\"\"\ntarget_os=\"unknown\"\ntarget_pointer_width=\"32\"\ntarget_vendor=\"unknown\"\n","warning: dropping unsupported crate type `dylib` for target `wasm32-unknown-unknown`\n\nwarning: dropping unsupported crate type `proc-macro` for target `wasm32-unknown-unknown`\n\n"],"1617349019360157463":["___\nlib___.rlib\nlib___.so\nlib___.so\nlib___.a\nlib___.so\n/home/jan/.rustup/toolchains/stable-x86_64-unknown-linux-gnu\ndebug_assertions\nproc_macro\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"gnu\"\ntarget_family=\"unix\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_os=\"linux\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"unknown\"\nunix\n",""]},"successes":{}} \ No newline at end of file
diff --git a/WebInterface/wasm/webhogg/update.py b/WebInterface/wasm/webhogg/update.py
deleted file mode 100644
index aad9395..0000000
--- a/WebInterface/wasm/webhogg/update.py
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/usr/bin/env python
-
-ISC = '//!IMPORTANT_STUFF'
-
-def rf(fn):
- f = open(fn)
- c = f.read()
- f.close()
- return c
-
-nc = rf('pkg/webhogg.js')
-m1 = rf('game_logic.js')
-m2 = rf('graphics.js')
-
-nc = nc.split('function init(module) {')[0].strip('\n')
-nc = nc.replace('export function ', 'function ')
-m1 = m1.split('//!IMPORTANT_STUFF')[-1]
-m2 = m2.split('//!IMPORTANT_STUFF')[-1]
-
-nc += '\n' * 2 + ISC
-
-m1 = nc + m1
-m2 = nc + m2
-
-with open('game_logic.js', 'w') as f:
- f.write(m1)
-
-with open('graphics.js', 'w') as f:
- f.write(m2)
diff --git a/WebInterface/wasm/webhogg/webhogg.js b/WebInterface/wasm/webhogg/webhogg.js
deleted file mode 100644
index c01d70f..0000000
--- a/WebInterface/wasm/webhogg/webhogg.js
+++ /dev/null
@@ -1,112 +0,0 @@
-const __exports = {};
-
-let cachedTextDecoder = new TextDecoder('utf-8');
-
-let cachegetUint8Memory = null;
-function getUint8Memory() {
- if (cachegetUint8Memory === null || cachegetUint8Memory.buffer !== wasm.memory.buffer) {
- cachegetUint8Memory = new Uint8Array(wasm.memory.buffer);
- }
- return cachegetUint8Memory;
-}
-
-function getStringFromWasm(ptr, len) {
- return cachedTextDecoder.decode(getUint8Memory().subarray(ptr, ptr + len));
-}
-
-function __wbg_debug_eacd5b227c4c01c7(arg0, arg1, arg2, arg3, arg4, arg5) {
- let varg0 = getStringFromWasm(arg0, arg1);
- let varg2 = getStringFromWasm(arg2, arg3);
- let varg4 = getStringFromWasm(arg4, arg5);
- console.debug(varg0, varg2, varg4);
-}
-__exports.__wbg_debug_eacd5b227c4c01c7 = __wbg_debug_eacd5b227c4c01c7
-
-function __wbg_info_be654745b6a55079(arg0, arg1, arg2, arg3, arg4, arg5) {
- let varg0 = getStringFromWasm(arg0, arg1);
- let varg2 = getStringFromWasm(arg2, arg3);
- let varg4 = getStringFromWasm(arg4, arg5);
- console.info(varg0, varg2, varg4);
-}
-__exports.__wbg_info_be654745b6a55079 = __wbg_info_be654745b6a55079
-
-function __wbg_warn_804a0523852c6d10(arg0, arg1, arg2, arg3, arg4, arg5) {
- let varg0 = getStringFromWasm(arg0, arg1);
- let varg2 = getStringFromWasm(arg2, arg3);
- let varg4 = getStringFromWasm(arg4, arg5);
- console.warn(varg0, varg2, varg4);
-}
-__exports.__wbg_warn_804a0523852c6d10 = __wbg_warn_804a0523852c6d10
-
-function __wbg_error_56a861ecc80f27e1(arg0, arg1, arg2, arg3, arg4, arg5) {
- let varg0 = getStringFromWasm(arg0, arg1);
- let varg2 = getStringFromWasm(arg2, arg3);
- let varg4 = getStringFromWasm(arg4, arg5);
- console.error(varg0, varg2, varg4);
-}
-__exports.__wbg_error_56a861ecc80f27e1 = __wbg_error_56a861ecc80f27e1
-
-export function game_logic_entry(worker) {
- return wasm.game_logic_entry(addHeapObject(worker));
-}
-__exports.game_logic_entry = game_logic_entry
-
-/**
-* @returns {void}
-*/
-export function graphics_entry() {
- return wasm.graphics_entry();
-}
-__exports.graphics_entry = graphics_entry
-
-function __wbindgen_throw(ptr, len) {
- throw new Error(getStringFromWasm(ptr, len));
-}
-__exports.__wbindgen_throw = __wbindgen_throw
-
-function init_r(module) {
- let result;
- const imports = { './webhogg': __exports };
-
- if (module instanceof URL || typeof module === 'string' || module instanceof Request) {
-
- const response = fetch(module);
- if (typeof WebAssembly.instantiateStreaming === 'function') {
- result = WebAssembly.instantiateStreaming(response, imports)
- .catch(e => {
- console.warn("`WebAssembly.instantiateStreaming` failed. Assuming this is because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
- return response
- .then(r => r.arrayBuffer())
- .then(bytes => WebAssembly.instantiate(bytes, imports));
- });
- } else {
- result = response
- .then(r => r.arrayBuffer())
- .then(bytes => WebAssembly.instantiate(bytes, imports));
- }
- } else {
-
- result = WebAssembly.instantiate(module, imports)
- .then(result => {
- if (result instanceof WebAssembly.Instance) {
- return { instance: result, module };
- } else {
- return result;
- }
- });
- }
- return result;
-}
-
-function _init_x(result, worker) {
- return result.then(({instance, module}) => {
- wasm = instance.exports;
- wasm.game_logic_entry(worker);
- //init_r.__wbindgen_wasm_module = module;
- //wasm.__wbindgen_start();
- return wasm;
- });
-}
-
-export default init_r;
-export var init_x = _init_x;
diff --git a/webhogg/wasm/Cargo.toml b/webhogg/wasm/Cargo.toml
new file mode 100644
index 0000000..79a96f3
--- /dev/null
+++ b/webhogg/wasm/Cargo.toml
@@ -0,0 +1,11 @@
+[package]
+name = "wasm"
+version = "0.1.0"
+authors = [
+ "natrixaeria",
+ "TrueDoctor <dennis@kobert.dev>"
+]
+edition = "2018"
+description = "WebAssembly frontend for the webhogg project"
+
+[dependencies]
diff --git a/webhogg/wasm/src/main.rs b/webhogg/wasm/src/main.rs
new file mode 100644
index 0000000..e7a11a9
--- /dev/null
+++ b/webhogg/wasm/src/main.rs
@@ -0,0 +1,3 @@
+fn main() {
+ println!("Hello, world!");
+}