diff options
author | Ilion Beyst <ilion.beyst@gmail.com> | 2021-12-29 21:24:57 +0100 |
---|---|---|
committer | Ilion Beyst <ilion.beyst@gmail.com> | 2021-12-29 21:25:29 +0100 |
commit | 0c6d978442b244ca3f29c1ffdd44b5007ae7ad93 (patch) | |
tree | baae5fa459a49ecd362e548e0649e2f58c669a70 | |
parent | 3eeaab6cec70e7a06a99a1ac2662974f71064bee (diff) | |
download | planetwars.dev-0c6d978442b244ca3f29c1ffdd44b5007ae7ad93.tar.xz planetwars.dev-0c6d978442b244ca3f29c1ffdd44b5007ae7ad93.zip |
separate out visualizer library
-rw-r--r-- | web/planetwars-rs/.gitignore (renamed from web/pw-frontend/planetwars-rs/.gitignore) | 0 | ||||
-rw-r--r-- | web/planetwars-rs/Cargo.toml (renamed from web/pw-frontend/planetwars-rs/Cargo.toml) | 0 | ||||
-rw-r--r-- | web/planetwars-rs/src/lib.rs (renamed from web/pw-frontend/planetwars-rs/src/lib.rs) | 0 | ||||
-rw-r--r-- | web/planetwars-rs/src/types.rs (renamed from web/pw-frontend/planetwars-rs/src/types.rs) | 0 | ||||
-rw-r--r-- | web/planetwars-rs/src/utils.rs (renamed from web/pw-frontend/planetwars-rs/src/utils.rs) | 0 | ||||
-rw-r--r-- | web/pw-frontend/package.json | 10 | ||||
-rw-r--r-- | web/pw-frontend/src/lib/Visualizer.svelte | 5 | ||||
-rw-r--r-- | web/pw-frontend/vite.config.js | 2 | ||||
-rw-r--r-- | web/pw-visualizer/.gitignore | 2 | ||||
-rw-r--r-- | web/pw-visualizer/index.html | 19 | ||||
-rw-r--r-- | web/pw-visualizer/package.json | 29 | ||||
-rw-r--r-- | web/pw-visualizer/src/LICENSE-MIT (renamed from web/pw-frontend/src/lib/visualizer/LICENSE-MIT) | 0 | ||||
-rw-r--r-- | web/pw-visualizer/src/README.md (renamed from web/pw-frontend/src/lib/visualizer/README.md) | 0 | ||||
-rw-r--r-- | web/pw-visualizer/src/index.html (renamed from web/pw-frontend/src/lib/visualizer/index.html) | 0 | ||||
-rw-r--r-- | web/pw-visualizer/src/index.ts (renamed from web/pw-frontend/src/lib/visualizer/index.ts) | 0 | ||||
-rw-r--r-- | web/pw-visualizer/src/src/games.ts (renamed from web/pw-frontend/src/lib/visualizer/src/games.ts) | 0 | ||||
-rw-r--r-- | web/pw-visualizer/src/style.css (renamed from web/pw-frontend/src/lib/visualizer/style.css) | 0 | ||||
-rw-r--r-- | web/pw-visualizer/src/voronoi/voronoi-core.d.ts (renamed from web/pw-frontend/src/lib/visualizer/voronoi/voronoi-core.d.ts) | 0 | ||||
-rw-r--r-- | web/pw-visualizer/src/voronoi/voronoi-core.js (renamed from web/pw-frontend/src/lib/visualizer/voronoi/voronoi-core.js) | 0 | ||||
-rw-r--r-- | web/pw-visualizer/src/voronoi/voronoi.ts (renamed from web/pw-frontend/src/lib/visualizer/voronoi/voronoi.ts) | 0 | ||||
-rw-r--r-- | web/pw-visualizer/src/webgl/buffer.ts (renamed from web/pw-frontend/src/lib/visualizer/webgl/buffer.ts) | 0 | ||||
-rw-r--r-- | web/pw-visualizer/src/webgl/index.ts (renamed from web/pw-frontend/src/lib/visualizer/webgl/index.ts) | 0 | ||||
-rw-r--r-- | web/pw-visualizer/src/webgl/renderer.ts (renamed from web/pw-frontend/src/lib/visualizer/webgl/renderer.ts) | 0 | ||||
-rw-r--r-- | web/pw-visualizer/src/webgl/shader.ts (renamed from web/pw-frontend/src/lib/visualizer/webgl/shader.ts) | 0 | ||||
-rw-r--r-- | web/pw-visualizer/src/webgl/text.ts (renamed from web/pw-frontend/src/lib/visualizer/webgl/text.ts) | 0 | ||||
-rw-r--r-- | web/pw-visualizer/src/webgl/texture.ts (renamed from web/pw-frontend/src/lib/visualizer/webgl/texture.ts) | 0 | ||||
-rw-r--r-- | web/pw-visualizer/src/webgl/util.ts (renamed from web/pw-frontend/src/lib/visualizer/webgl/util.ts) | 0 | ||||
-rw-r--r-- | web/pw-visualizer/src/webgl/vertexBufferLayout.ts (renamed from web/pw-frontend/src/lib/visualizer/webgl/vertexBufferLayout.ts) | 0 | ||||
-rw-r--r-- | web/pw-visualizer/tsconfig.json | 14 | ||||
-rw-r--r-- | web/pw-visualizer/vite.config.js | 24 |
30 files changed, 95 insertions, 10 deletions
diff --git a/web/pw-frontend/planetwars-rs/.gitignore b/web/planetwars-rs/.gitignore index a04eea2..a04eea2 100644 --- a/web/pw-frontend/planetwars-rs/.gitignore +++ b/web/planetwars-rs/.gitignore diff --git a/web/pw-frontend/planetwars-rs/Cargo.toml b/web/planetwars-rs/Cargo.toml index a5dc949..a5dc949 100644 --- a/web/pw-frontend/planetwars-rs/Cargo.toml +++ b/web/planetwars-rs/Cargo.toml diff --git a/web/pw-frontend/planetwars-rs/src/lib.rs b/web/planetwars-rs/src/lib.rs index f2ba7e1..f2ba7e1 100644 --- a/web/pw-frontend/planetwars-rs/src/lib.rs +++ b/web/planetwars-rs/src/lib.rs diff --git a/web/pw-frontend/planetwars-rs/src/types.rs b/web/planetwars-rs/src/types.rs index 2d7d8c0..2d7d8c0 100644 --- a/web/pw-frontend/planetwars-rs/src/types.rs +++ b/web/planetwars-rs/src/types.rs diff --git a/web/pw-frontend/planetwars-rs/src/utils.rs b/web/planetwars-rs/src/utils.rs index a903912..a903912 100644 --- a/web/pw-frontend/planetwars-rs/src/utils.rs +++ b/web/planetwars-rs/src/utils.rs diff --git a/web/pw-frontend/package.json b/web/pw-frontend/package.json index f011162..94d95a0 100644 --- a/web/pw-frontend/package.json +++ b/web/pw-frontend/package.json @@ -5,7 +5,7 @@ "scripts": { "dev": "vite", "build": "vite build", - "build-wasm": "wasm-pack build ./planetwars-rs --target web", + "build-wasm": "wasm-pack build ../planetwars-rs --target web", "preview": "vite preview", "check": "svelte-check --tsconfig ./tsconfig.json" }, @@ -13,7 +13,6 @@ "@originjs/vite-plugin-commonjs": "^1.0.1", "@sveltejs/vite-plugin-svelte": "^1.0.0-next.30", "@tsconfig/svelte": "^2.0.1", - "rollup-plugin-polyfill-node": "^0.8.0", "svelte": "^3.44.0", "svelte-check": "^2.2.7", "svelte-preprocess": "^4.9.8", @@ -23,11 +22,8 @@ "vite-plugin-wasm-pack": "^0.1.9" }, "dependencies": { - "buffer": "^6.0.3", - "extract-svg-path": "^2.1.0", - "load-svg": "^1.0.0", "moment": "^2.29.1", - "svg-mesh-3d": "^1.1.0", - "ts-heap": "^1.1.3" + "pw-visualizer": "file:../pw-visualizer", + "planetwars-rs": "file:../planetwars-rs/pkg" } } diff --git a/web/pw-frontend/src/lib/Visualizer.svelte b/web/pw-frontend/src/lib/Visualizer.svelte index 297659c..bcd6c7a 100644 --- a/web/pw-frontend/src/lib/Visualizer.svelte +++ b/web/pw-frontend/src/lib/Visualizer.svelte @@ -1,6 +1,6 @@ <script lang="ts"> import { onMount } from 'svelte'; - import * as visualizer from '../lib/visualizer/index'; + import * as visualizer from "pw-visualizer"; export let matchLog = null; @@ -20,6 +20,7 @@ visualizer.set_loading(false); } } + </script> <div id="main" class="loading"> @@ -57,5 +58,5 @@ </div> <style scoped> - @import 'visualizer/style.css'; + @import 'pw-visualizer/src/style.css'; </style> diff --git a/web/pw-frontend/vite.config.js b/web/pw-frontend/vite.config.js index a7fcc74..84889ec 100644 --- a/web/pw-frontend/vite.config.js +++ b/web/pw-frontend/vite.config.js @@ -7,7 +7,7 @@ import wasmPack from 'vite-plugin-wasm-pack'; export default defineConfig({ plugins: [ svelte(), - wasmPack(["./planetwars-rs"]), + wasmPack([], ["planetwars-rs"]), viteCommonjs({ transformMixedEsModules: true, }), diff --git a/web/pw-visualizer/.gitignore b/web/pw-visualizer/.gitignore new file mode 100644 index 0000000..25c8fdb --- /dev/null +++ b/web/pw-visualizer/.gitignore @@ -0,0 +1,2 @@ +node_modules +package-lock.json
\ No newline at end of file diff --git a/web/pw-visualizer/index.html b/web/pw-visualizer/index.html new file mode 100644 index 0000000..dc46fa0 --- /dev/null +++ b/web/pw-visualizer/index.html @@ -0,0 +1,19 @@ +<!DOCTYPE html> +<html lang="en"> + <!-- polyfill global --> + <script> + const global = globalThis; + </script> + <!-- end polyfill --> + + <head> + <meta charset="UTF-8" /> + <link rel="icon" href="/favicon.ico" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <title>Planetwars</title> + </head> + <body> + <div id="app"></div> + <script type="module" src="/src/main.ts"></script> + </body> +</html> diff --git a/web/pw-visualizer/package.json b/web/pw-visualizer/package.json new file mode 100644 index 0000000..bbeb6d2 --- /dev/null +++ b/web/pw-visualizer/package.json @@ -0,0 +1,29 @@ +{ + "name": "pw-visualizer", + "version": "0.0.1", + "type": "module", + "scripts": { + "dev": "vite", + "build": "vite build", + "build-wasm": "wasm-pack build ../planetwars-rs --target web" + }, + "files": ["src"], + "main": "src/index.ts", + "devDependencies": { + "@originjs/vite-plugin-commonjs": "^1.0.1", + "tslib": "^2.3.1", + "typescript": "^4.4.4", + "vite": "^2.7.2", + "vite-plugin-wasm-pack": "^0.1.9" + }, + "dependencies": { + "buffer": "^6.0.3", + "extract-svg-path": "^2.1.0", + "load-svg": "^1.0.0", + "svg-mesh-3d": "^1.1.0", + "ts-heap": "^1.1.3" + }, + "peerDependencies": { + "planetwars-rs": "file:../planetwars-rs/pkg" + } +} diff --git a/web/pw-frontend/src/lib/visualizer/LICENSE-MIT b/web/pw-visualizer/src/LICENSE-MIT index 8d459d1..8d459d1 100644 --- a/web/pw-frontend/src/lib/visualizer/LICENSE-MIT +++ b/web/pw-visualizer/src/LICENSE-MIT diff --git a/web/pw-frontend/src/lib/visualizer/README.md b/web/pw-visualizer/src/README.md index aaba256..aaba256 100644 --- a/web/pw-frontend/src/lib/visualizer/README.md +++ b/web/pw-visualizer/src/README.md diff --git a/web/pw-frontend/src/lib/visualizer/index.html b/web/pw-visualizer/src/index.html index c2b2c33..c2b2c33 100644 --- a/web/pw-frontend/src/lib/visualizer/index.html +++ b/web/pw-visualizer/src/index.html diff --git a/web/pw-frontend/src/lib/visualizer/index.ts b/web/pw-visualizer/src/index.ts index 363a1c5..363a1c5 100644 --- a/web/pw-frontend/src/lib/visualizer/index.ts +++ b/web/pw-visualizer/src/index.ts diff --git a/web/pw-frontend/src/lib/visualizer/src/games.ts b/web/pw-visualizer/src/src/games.ts index 4b9e7e2..4b9e7e2 100644 --- a/web/pw-frontend/src/lib/visualizer/src/games.ts +++ b/web/pw-visualizer/src/src/games.ts diff --git a/web/pw-frontend/src/lib/visualizer/style.css b/web/pw-visualizer/src/style.css index 8c5119e..8c5119e 100644 --- a/web/pw-frontend/src/lib/visualizer/style.css +++ b/web/pw-visualizer/src/style.css diff --git a/web/pw-frontend/src/lib/visualizer/voronoi/voronoi-core.d.ts b/web/pw-visualizer/src/voronoi/voronoi-core.d.ts index e908fbb..e908fbb 100644 --- a/web/pw-frontend/src/lib/visualizer/voronoi/voronoi-core.d.ts +++ b/web/pw-visualizer/src/voronoi/voronoi-core.d.ts diff --git a/web/pw-frontend/src/lib/visualizer/voronoi/voronoi-core.js b/web/pw-visualizer/src/voronoi/voronoi-core.js index 9dcc5b3..9dcc5b3 100644 --- a/web/pw-frontend/src/lib/visualizer/voronoi/voronoi-core.js +++ b/web/pw-visualizer/src/voronoi/voronoi-core.js diff --git a/web/pw-frontend/src/lib/visualizer/voronoi/voronoi.ts b/web/pw-visualizer/src/voronoi/voronoi.ts index a63bc9a..a63bc9a 100644 --- a/web/pw-frontend/src/lib/visualizer/voronoi/voronoi.ts +++ b/web/pw-visualizer/src/voronoi/voronoi.ts diff --git a/web/pw-frontend/src/lib/visualizer/webgl/buffer.ts b/web/pw-visualizer/src/webgl/buffer.ts index 2739fbe..2739fbe 100644 --- a/web/pw-frontend/src/lib/visualizer/webgl/buffer.ts +++ b/web/pw-visualizer/src/webgl/buffer.ts diff --git a/web/pw-frontend/src/lib/visualizer/webgl/index.ts b/web/pw-visualizer/src/webgl/index.ts index fdb7886..fdb7886 100644 --- a/web/pw-frontend/src/lib/visualizer/webgl/index.ts +++ b/web/pw-visualizer/src/webgl/index.ts diff --git a/web/pw-frontend/src/lib/visualizer/webgl/renderer.ts b/web/pw-visualizer/src/webgl/renderer.ts index c3b219f..c3b219f 100644 --- a/web/pw-frontend/src/lib/visualizer/webgl/renderer.ts +++ b/web/pw-visualizer/src/webgl/renderer.ts diff --git a/web/pw-frontend/src/lib/visualizer/webgl/shader.ts b/web/pw-visualizer/src/webgl/shader.ts index 942c4c2..942c4c2 100644 --- a/web/pw-frontend/src/lib/visualizer/webgl/shader.ts +++ b/web/pw-visualizer/src/webgl/shader.ts diff --git a/web/pw-frontend/src/lib/visualizer/webgl/text.ts b/web/pw-visualizer/src/webgl/text.ts index 3f1cec6..3f1cec6 100644 --- a/web/pw-frontend/src/lib/visualizer/webgl/text.ts +++ b/web/pw-visualizer/src/webgl/text.ts diff --git a/web/pw-frontend/src/lib/visualizer/webgl/texture.ts b/web/pw-visualizer/src/webgl/texture.ts index 9d6adcf..9d6adcf 100644 --- a/web/pw-frontend/src/lib/visualizer/webgl/texture.ts +++ b/web/pw-visualizer/src/webgl/texture.ts diff --git a/web/pw-frontend/src/lib/visualizer/webgl/util.ts b/web/pw-visualizer/src/webgl/util.ts index 3ed2b4d..3ed2b4d 100644 --- a/web/pw-frontend/src/lib/visualizer/webgl/util.ts +++ b/web/pw-visualizer/src/webgl/util.ts diff --git a/web/pw-frontend/src/lib/visualizer/webgl/vertexBufferLayout.ts b/web/pw-visualizer/src/webgl/vertexBufferLayout.ts index f44ed47..f44ed47 100644 --- a/web/pw-frontend/src/lib/visualizer/webgl/vertexBufferLayout.ts +++ b/web/pw-visualizer/src/webgl/vertexBufferLayout.ts diff --git a/web/pw-visualizer/tsconfig.json b/web/pw-visualizer/tsconfig.json new file mode 100644 index 0000000..05358cd --- /dev/null +++ b/web/pw-visualizer/tsconfig.json @@ -0,0 +1,14 @@ +{ + "compilerOptions": { + "target": "esnext", + "useDefineForClassFields": true, + "module": "esnext", + "esModuleInterop": true, + "moduleResolution": "node", + "resolveJsonModule": true, + "baseUrl": ".", + "allowJs": false, + "checkJs": false + }, + "include": ["src/**/*.d.ts", "src/**/*.ts", "src/**/*.js", "src/**/*.svelte"] +} diff --git a/web/pw-visualizer/vite.config.js b/web/pw-visualizer/vite.config.js new file mode 100644 index 0000000..61eed3e --- /dev/null +++ b/web/pw-visualizer/vite.config.js @@ -0,0 +1,24 @@ +import { defineConfig } from 'vite' +import { viteCommonjs } from '@originjs/vite-plugin-commonjs' +import wasmPack from 'vite-plugin-wasm-pack'; + +// https://vitejs.dev/config/ +export default defineConfig({ + plugins: [ + wasmPack([], ["planetwars-rs"]), + viteCommonjs({ + transformMixedEsModules: true, + }), + ], + build: { + commonjsOptions: { + transformMixedEsModules: true, + }, + }, + server: { + proxy: { + "/api/": "http://localhost:5000", + "/ws": "ws://localhost:5000/ws", + }, + }, +}) |