From 86d36b71f6e81645ff5bbc082e3eb66fc86f74b5 Mon Sep 17 00:00:00 2001 From: nekosu Date: Tue, 22 Aug 2023 15:51:40 +0800 Subject: [PATCH] feat: introduce wasm --- .github/workflows/ci.yml | 16 ++++++++++ .gitignore | 3 ++ packages/client/index.html | 1 + packages/client/public/render.wasm | 1 + packages/client/src/data/task.ts | 20 ++++++++++++ packages/client/src/native | 1 + packages/client/src/router/index.ts | 5 +++ packages/client/src/views/EditView.vue | 8 +++++ packages/client/src/views/VisualView.vue | 23 ++++++++++++++ packages/client/src/wasm.d.ts | 3 ++ render/CMakeLists.txt | 9 ++++++ render/main.cpp | 40 ++++++++++++++++++++++++ 12 files changed, 130 insertions(+) create mode 120000 packages/client/public/render.wasm create mode 120000 packages/client/src/native create mode 100644 packages/client/src/views/VisualView.vue create mode 100644 packages/client/src/wasm.d.ts create mode 100644 render/CMakeLists.txt create mode 100644 render/main.cpp diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e97bf42..99f0152 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,6 +32,22 @@ jobs: submodules: true # Fetch Hugo themes (true OR recursive) fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod + - name: Setup emsdk + uses: mymindstorm/setup-emsdk@v11 + + - name: Install cmake + run: | + sudo apt-get update + sudo apt-get install cmake + + - name: Build wasm module + run: | + cd render + mkdir build + cd build + emcmake cmake .. + cmake --build . + - name: Use Node.js 18 uses: actions/setup-node@v3 with: diff --git a/.gitignore b/.gitignore index 2929ed9..5ceafdf 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,6 @@ coverage running *.zip + +build +CMakeUserPresets.json diff --git a/packages/client/index.html b/packages/client/index.html index 7792c8d..c460d2d 100644 --- a/packages/client/index.html +++ b/packages/client/index.html @@ -20,5 +20,6 @@
+ diff --git a/packages/client/public/render.wasm b/packages/client/public/render.wasm new file mode 120000 index 0000000..4171db2 --- /dev/null +++ b/packages/client/public/render.wasm @@ -0,0 +1 @@ +../src/native/render.wasm \ No newline at end of file diff --git a/packages/client/src/data/task.ts b/packages/client/src/data/task.ts index aef8ed5..2fe3686 100644 --- a/packages/client/src/data/task.ts +++ b/packages/client/src/data/task.ts @@ -31,6 +31,26 @@ function wrapNext(v?: string | string[]) { return v ? (typeof v === 'string' ? [v] : v) : [] } +export const taskForwardIndex = computed(() => { + const res: Record = {} + for (const name in taskIndex.value) { + const st = new Set() + const keys = ['next', 'timeout_next', 'runout_next'] as const + const task = getTask(taskIndex.value[name]) + if (!task) { + continue + } + for (const key of keys) { + let arr = wrapNext(task[key]) + for (const to of arr) { + st.add(to) + } + } + res[name] = [...st] + } + return res +}) + export const taskBackwardIndex = computed(() => { const res: Record = {} for (const name in taskIndex.value) { diff --git a/packages/client/src/native b/packages/client/src/native new file mode 120000 index 0000000..24ec704 --- /dev/null +++ b/packages/client/src/native @@ -0,0 +1 @@ +../../../render/build/Release \ No newline at end of file diff --git a/packages/client/src/router/index.ts b/packages/client/src/router/index.ts index 8fdf694..d21fea0 100644 --- a/packages/client/src/router/index.ts +++ b/packages/client/src/router/index.ts @@ -3,6 +3,7 @@ import { createRouter, createWebHistory } from 'vue-router' import EditView from '@/views/EditView.vue' import EvalView from '@/views/EvalView.vue' import RoiView from '@/views/RoiView.vue' +import VisualView from '@/views/VisualView.vue' const router = createRouter({ history: createWebHistory(), @@ -22,6 +23,10 @@ const router = createRouter({ { path: '/roi', component: RoiView + }, + { + path: '/visual', + component: VisualView } ] }) diff --git a/packages/client/src/views/EditView.vue b/packages/client/src/views/EditView.vue index 73c04ff..955bfa8 100644 --- a/packages/client/src/views/EditView.vue +++ b/packages/client/src/views/EditView.vue @@ -5,6 +5,7 @@ import { FileDownloadOutlined, FileUploadOutlined, HealthAndSafetyOutlined, + MapOutlined, NavigateBeforeOutlined, NavigateNextOutlined, RedoOutlined, @@ -97,6 +98,13 @@ function doValidate() { + + +