Remove the Rust/WASM crate and its build step
Nothing live used it: main.js awaited the wasm init() on every page load, but the only consumer, components/util/wasm/AutoScroll.vue, was never imported. Dropping it removes the rust:slim + wasm-pack stage from the vue image, the two Vite plugins that existed only for it, and the src/wasm/ guard in `make check-vue`, so a fresh clone builds without a Rust toolchain. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -29,7 +29,7 @@
|
|||||||
#
|
#
|
||||||
# NOT TESTED HERE: THE VUE BUILD
|
# NOT TESTED HERE: THE VUE BUILD
|
||||||
# Deliberately skipped. `docker compose up --build` in the deploy job
|
# Deliberately skipped. `docker compose up --build` in the deploy job
|
||||||
# already runs the full frontend build (wasm-pack + vite) while building the
|
# already runs the full frontend build (npm ci + vite) while building the
|
||||||
# vue image, and a failed image build aborts `up` BEFORE any container is
|
# vue image, and a failed image build aborts `up` BEFORE any container is
|
||||||
# replaced, so the old site keeps serving. Building it a second time here
|
# replaced, so the old site keeps serving. Building it a second time here
|
||||||
# would cost the Pi several minutes per push to learn nothing new. The same
|
# would cost the Pi several minutes per push to learn nothing new. The same
|
||||||
|
|||||||
@@ -20,9 +20,6 @@ gitea-runner/.runner
|
|||||||
gitea-runner/act_runner
|
gitea-runner/act_runner
|
||||||
gitea-runner/nohup.out
|
gitea-runner/nohup.out
|
||||||
|
|
||||||
# Rust build artifacts
|
|
||||||
**/target/
|
|
||||||
|
|
||||||
# Python bytecode
|
# Python bytecode
|
||||||
__pycache__/
|
__pycache__/
|
||||||
*.pyc
|
*.pyc
|
||||||
@@ -31,9 +28,6 @@ __pycache__/
|
|||||||
# Virtualenv `make check-python` builds on demand from python/requirements-dev.txt
|
# Virtualenv `make check-python` builds on demand from python/requirements-dev.txt
|
||||||
/.venv/
|
/.venv/
|
||||||
|
|
||||||
# Generated WASM output
|
|
||||||
vue/src/wasm/
|
|
||||||
|
|
||||||
# Logs
|
# Logs
|
||||||
logs
|
logs
|
||||||
*.log
|
*.log
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ Vite dev server proxies `/api`, `/gitea`, `/py` and `/radio`; the targets defaul
|
|||||||
cd vue && npm run build
|
cd vue && npm run build
|
||||||
```
|
```
|
||||||
|
|
||||||
`npm run build` compiles the Rust crate first and needs `wasm-pack`. `npm run build:js` (plain `vite build`) is the check to use when only the JS changed and `src/wasm/` already exists.
|
`npm run build` is a plain `vite build`.
|
||||||
|
|
||||||
### Regenerate GraphQL (after editing schema files)
|
### Regenerate GraphQL (after editing schema files)
|
||||||
|
|
||||||
|
|||||||
+3
-4
@@ -165,10 +165,9 @@ docker compose -f docker-compose.yml -f docker-compose.dev.yml up --build
|
|||||||
The override layer changes five services and disables one:
|
The override layer changes five services and disables one:
|
||||||
|
|
||||||
- **vue** — `npm run dev` instead of a one-shot build; `./vue` is bind-mounted
|
- **vue** — `npm run dev` instead of a one-shot build; `./vue` is bind-mounted
|
||||||
for hot reload, with anonymous-volume masks on `/app/node_modules` and
|
for hot reload, with an anonymous-volume mask on `/app/node_modules` so the
|
||||||
`/app/src/wasm` so the image's installed deps and compiled WASM are not hidden
|
image's installed deps are not hidden by the bind mount. You don't need
|
||||||
by the bind mount. You need neither `node_modules` nor a Rust toolchain on the
|
`node_modules` on the host.
|
||||||
host.
|
|
||||||
- **nginx** — `DEV_MODE=true`, which makes the entrypoint self-sign a
|
- **nginx** — `DEV_MODE=true`, which makes the entrypoint self-sign a
|
||||||
`CN=localhost` certificate (once, kept in `certbot/conf`) and render
|
`CN=localhost` certificate (once, kept in `certbot/conf`) and render
|
||||||
`nginx_dev.conf.template`: `/` proxies to the Vite dev server, both `:80` and
|
`nginx_dev.conf.template`: `/` proxies to the Vite dev server, both `:80` and
|
||||||
|
|||||||
@@ -11,8 +11,7 @@
|
|||||||
# WHAT IT NEEDS ON THE HOST
|
# WHAT IT NEEDS ON THE HOST
|
||||||
# check-backend / generate Go (the version in backend/go.mod)
|
# check-backend / generate Go (the version in backend/go.mod)
|
||||||
# check-python python3 with the venv module
|
# check-python python3 with the venv module
|
||||||
# check-vue Node + `npm install` done in vue/, and the
|
# check-vue Node + `npm install` done in vue/
|
||||||
# generated vue/src/wasm/ directory (see below)
|
|
||||||
# check-compose / dev Docker with the compose plugin
|
# check-compose / dev Docker with the compose plugin
|
||||||
# Nothing here installs a toolchain; a missing one fails that target only.
|
# Nothing here installs a toolchain; a missing one fails that target only.
|
||||||
#
|
#
|
||||||
@@ -69,26 +68,12 @@ $(VENV_STAMP): python/requirements.txt python/requirements-dev.txt
|
|||||||
check-python: $(VENV_STAMP)
|
check-python: $(VENV_STAMP)
|
||||||
cd python && ../$(VENV)/bin/python -m pytest tests -q
|
cd python && ../$(VENV)/bin/python -m pytest tests -q
|
||||||
|
|
||||||
# `npx vite build`, NOT `npm run build`: the npm script first runs wasm-pack to
|
# A Vite build is enough to catch a broken import or template; there is no
|
||||||
# compile the Rust crate, which needs a Rust toolchain most machines (and the
|
# test runner or linter for the frontend.
|
||||||
# Pi) do not have. The Vite half alone is enough to catch a broken import or
|
|
||||||
# template.
|
|
||||||
#
|
|
||||||
# It does still need the OUTPUT of that Rust step, vue/src/wasm/, which is
|
|
||||||
# generated and gitignored — so a fresh clone has none and Vite would fail with
|
|
||||||
# a bare "could not resolve ../wasm/..." error. The guards below say what is
|
|
||||||
# actually wrong instead.
|
|
||||||
#
|
#
|
||||||
# The build goes to a temp directory that is removed afterwards (success or
|
# The build goes to a temp directory that is removed afterwards (success or
|
||||||
# failure), so the check never leaves a vue/dist behind or overwrites one.
|
# failure), so the check never leaves a vue/dist behind or overwrites one.
|
||||||
check-vue:
|
check-vue:
|
||||||
@test -d vue/src/wasm || { \
|
|
||||||
echo "check-vue: vue/src/wasm/ is missing."; \
|
|
||||||
echo " It is the generated (gitignored) output of the Rust crate in vue/crates/"; \
|
|
||||||
echo " and the Vite build imports it. Create it with wasm-pack:"; \
|
|
||||||
echo " cd vue && npm run build:wasm"; \
|
|
||||||
echo " (needs a Rust toolchain; the vue image builds it for you, see vue/Dockerfile)."; \
|
|
||||||
exit 1; }
|
|
||||||
@test -d vue/node_modules || { \
|
@test -d vue/node_modules || { \
|
||||||
echo "check-vue: vue/node_modules/ is missing. Run: cd vue && npm install"; \
|
echo "check-vue: vue/node_modules/ is missing. Run: cd vue && npm install"; \
|
||||||
exit 1; }
|
exit 1; }
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ certbot ── SSL Certificate Management (disabled in dev)
|
|||||||
|
|
||||||
## Tech Stack
|
## Tech Stack
|
||||||
|
|
||||||
**Frontend** - Vue 3, Vite, Tailwind CSS v4, Pinia, Vue Router, markdown-it (wikilinks + KaTeX), Rust/WASM
|
**Frontend** - Vue 3, Vite, Tailwind CSS v4, Pinia, Vue Router, markdown-it (wikilinks + KaTeX)
|
||||||
|
|
||||||
**Backend** - Go (Gin), gqlgen (GraphQL), GORM, PostgreSQL, JWT auth, WebSockets
|
**Backend** - Go (Gin), gqlgen (GraphQL), GORM, PostgreSQL, JWT auth, WebSockets
|
||||||
|
|
||||||
@@ -349,7 +349,6 @@ These files are git-ignored and must be created manually:
|
|||||||
|
|
||||||
## Future Ideas
|
## Future Ideas
|
||||||
|
|
||||||
- More Rust to WASM
|
|
||||||
- ML for chatboards
|
- ML for chatboards
|
||||||
- Cache requests
|
- Cache requests
|
||||||
- Design more webpages
|
- Design more webpages
|
||||||
|
|||||||
@@ -32,14 +32,12 @@ services:
|
|||||||
command: ["npm", "run", "dev"]
|
command: ["npm", "run", "dev"]
|
||||||
volumes:
|
volumes:
|
||||||
- ./vue:/app
|
- ./vue:/app
|
||||||
# The two bare paths are ANONYMOUS-VOLUME MASKS, not typos. Binding
|
# The bare path is an ANONYMOUS-VOLUME MASK, not a typo. Binding
|
||||||
# ./vue over /app would otherwise hide the node_modules and WASM
|
# ./vue over /app would otherwise hide the node_modules that were
|
||||||
# output that were installed/built *inside* the image. Declaring
|
# installed *inside* the image. Declaring it as an anonymous volume
|
||||||
# them as anonymous volumes re-exposes the image's copies on top of
|
# re-exposes the image's copy on top of the bind mount, so the
|
||||||
# the bind mount, so `npm ci` and wasm-pack results survive and the
|
# `npm ci` result survives and the host does not need node_modules.
|
||||||
# host does not need node_modules or a Rust toolchain at all.
|
|
||||||
- /app/node_modules
|
- /app/node_modules
|
||||||
- /app/src/wasm
|
|
||||||
environment:
|
environment:
|
||||||
- NODE_ENV=development
|
- NODE_ENV=development
|
||||||
backend:
|
backend:
|
||||||
|
|||||||
@@ -15,9 +15,8 @@ add_header Strict-Transport-Security "max-age=63072000; includeSubDomains" alway
|
|||||||
# locked-down CSP by declaring Content-Security-Policy again themselves
|
# locked-down CSP by declaring Content-Security-Policy again themselves
|
||||||
# (a later add_header of the same name within one response wins).
|
# (a later add_header of the same name within one response wins).
|
||||||
#
|
#
|
||||||
# ponytail: no site-wide CSP from nginx here. The SPA needs
|
# ponytail: no site-wide CSP from nginx here. Gitea (proxied at /gitea/)
|
||||||
# 'wasm-unsafe-eval' for its Rust module, Gitea (proxied at /gitea/) relies
|
# relies on inline <script> blocks its own templates generate, so a shared
|
||||||
# on inline <script> blocks its own templates generate, so a shared
|
|
||||||
# script-src would need 'unsafe-inline' — which voids almost all of CSP's
|
# script-src would need 'unsafe-inline' — which voids almost all of CSP's
|
||||||
# value. If a real CSP matters again, give the SPA document its own
|
# value. If a real CSP matters again, give the SPA document its own
|
||||||
# script-src 'self' 'wasm-unsafe-eval' location, separate from Gitea.
|
# script-src 'self' location, separate from Gitea.
|
||||||
|
|||||||
+2
-26
@@ -1,5 +1,5 @@
|
|||||||
# =============================================================================
|
# =============================================================================
|
||||||
# Vue frontend image — compiles Rust to WASM, then builds the SPA.
|
# Vue frontend image — builds the SPA.
|
||||||
#
|
#
|
||||||
# THIS IS A BUILD CONTAINER, NOT A SERVER. In production the container runs
|
# THIS IS A BUILD CONTAINER, NOT A SERVER. In production the container runs
|
||||||
# `vite build` into /output (the shared vue_dist volume) and EXITS. nginx then
|
# `vite build` into /output (the shared vue_dist volume) and EXITS. nginx then
|
||||||
@@ -7,16 +7,7 @@
|
|||||||
# success case, not a failure. The dev override replaces the CMD with the Vite
|
# success case, not a failure. The dev override replaces the CMD with the Vite
|
||||||
# dev server, and then it does stay running.
|
# dev server, and then it does stay running.
|
||||||
#
|
#
|
||||||
# STAGE 1 — WASM
|
# package.json + package-lock.json are copied first so `npm ci` is cached
|
||||||
# Builds crates/stp_wasm with wasm-pack into src/wasm. Only that crate
|
|
||||||
# directory is copied in, so touching Vue source never invalidates the (slow)
|
|
||||||
# Rust layer. The two cache mounts persist the cargo registry and the Rust
|
|
||||||
# target directory between builds on the host — on a Raspberry Pi this turns
|
|
||||||
# a very long compile into an incremental one. src/wasm is gitignored: it is
|
|
||||||
# generated, never committed.
|
|
||||||
#
|
|
||||||
# STAGE 2 — Vue
|
|
||||||
# package.json + package-lock.json are copied first so `npm ci` is cached
|
|
||||||
# independently of source changes; the npm cache is also a BuildKit cache
|
# independently of source changes; the npm cache is also a BuildKit cache
|
||||||
# mount. `npm ci` (not `npm install`) installs exactly the lockfile, so a
|
# mount. `npm ci` (not `npm install`) installs exactly the lockfile, so a
|
||||||
# rebuild can never silently pick up a different dependency version.
|
# rebuild can never silently pick up a different dependency version.
|
||||||
@@ -26,21 +17,7 @@
|
|||||||
# --emptyOutDir is required: /output is a mounted volume, and vite refuses to
|
# --emptyOutDir is required: /output is a mounted volume, and vite refuses to
|
||||||
# clear a directory outside the project root without it. Without the flag,
|
# clear a directory outside the project root without it. Without the flag,
|
||||||
# stale assets from a previous build would accumulate and be served.
|
# stale assets from a previous build would accumulate and be served.
|
||||||
#
|
|
||||||
# Note stage 2 is not named and is the final stage; both base images are
|
|
||||||
# multi-arch so this builds on the Pi unchanged.
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# Stage 1: Build WASM from Rust
|
|
||||||
FROM rust:slim AS wasm-builder
|
|
||||||
RUN rustup target add wasm32-unknown-unknown \
|
|
||||||
&& cargo install wasm-pack
|
|
||||||
WORKDIR /wasm
|
|
||||||
COPY crates/stp_wasm/ crates/stp_wasm/
|
|
||||||
RUN --mount=type=cache,target=/usr/local/cargo/registry \
|
|
||||||
--mount=type=cache,target=/wasm/crates/stp_wasm/target \
|
|
||||||
wasm-pack build crates/stp_wasm --target web --out-dir ../../src/wasm
|
|
||||||
|
|
||||||
# Stage 2: Build Vue frontend
|
|
||||||
FROM node:22-slim
|
FROM node:22-slim
|
||||||
RUN apt-get update && apt-get install -y make git && rm -rf /var/lib/apt/lists/*
|
RUN apt-get update && apt-get install -y make git && rm -rf /var/lib/apt/lists/*
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
@@ -48,5 +25,4 @@ COPY package.json package-lock.json ./
|
|||||||
RUN --mount=type=cache,target=/root/.npm \
|
RUN --mount=type=cache,target=/root/.npm \
|
||||||
npm ci
|
npm ci
|
||||||
COPY . .
|
COPY . .
|
||||||
COPY --from=wasm-builder /wasm/src/wasm/ src/wasm/
|
|
||||||
CMD ["sh", "-c", "npx vite build --outDir /output --emptyOutDir"]
|
CMD ["sh", "-c", "npx vite build --outDir /output --emptyOutDir"]
|
||||||
|
|||||||
+3
-8
@@ -44,7 +44,7 @@ has to be a bare uvicorn.
|
|||||||
|
|
||||||
```
|
```
|
||||||
src/
|
src/
|
||||||
main.js entry point — awaits the wasm init, then mounts <App>
|
main.js entry point — mounts <App>
|
||||||
App.vue empty shell; all chrome lives in the layouts
|
App.vue empty shell; all chrome lives in the layouts
|
||||||
router/index.js route table + the single admin route guard
|
router/index.js route table + the single admin route guard
|
||||||
graphql.js the entire GraphQL client (one axios POST)
|
graphql.js the entire GraphQL client (one axios POST)
|
||||||
@@ -55,8 +55,6 @@ src/
|
|||||||
views/ page components, one directory per area
|
views/ page components, one directory per area
|
||||||
assets/styles.css design tokens + base styles (see Styling)
|
assets/styles.css design tokens + base styles (see Styling)
|
||||||
js/ small shared helpers
|
js/ small shared helpers
|
||||||
wasm/ GENERATED by `npm run build:wasm`; gitignored, do not edit
|
|
||||||
crates/stp_wasm the Rust source for the above
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Routing
|
## Routing
|
||||||
@@ -317,10 +315,8 @@ renders any page's boxes.
|
|||||||
- **Production** (`npm run build`): `dist/` is built into the nginx container
|
- **Production** (`npm run build`): `dist/` is built into the nginx container
|
||||||
and served as static files, with nginx doing the same reverse-proxying.
|
and served as static files, with nginx doing the same reverse-proxying.
|
||||||
|
|
||||||
Note `npm run build` runs `build:wasm` first, which needs **wasm-pack** on the
|
`npm run build` is a plain `vite build`. It is also the local check that the
|
||||||
PATH. If you only want the Vue bundle and `src/wasm/` is already populated,
|
app still compiles — there is no test runner or linter.
|
||||||
`npm run build:js` (plain `vite build`) skips that step. It is also the local
|
|
||||||
check that the app still compiles — there is no test runner or linter.
|
|
||||||
|
|
||||||
## Live vs legacy views
|
## Live vs legacy views
|
||||||
|
|
||||||
@@ -340,7 +336,6 @@ in its header comment; the summary:
|
|||||||
| `views/CV/CV{General,Backend,Frontend,Security,Electrical,Hospitality,Analyst,Temp}.vue` | commented out of `CV.vue`'s list; unreachable |
|
| `views/CV/CV{General,Backend,Frontend,Security,Electrical,Hospitality,Analyst,Temp}.vue` | commented out of `CV.vue`'s list; unreachable |
|
||||||
| `views/unused/CoverLetters.vue` | **live** despite the directory — it is the "Cover Letter" tab on `/cv` |
|
| `views/unused/CoverLetters.vue` | **live** despite the directory — it is the "Cover Letter" tab on `/cv` |
|
||||||
| `views/unused/Notes.vue` | no route points at it; not imported |
|
| `views/unused/Notes.vue` | no route points at it; not imported |
|
||||||
| `components/util/wasm/AutoScroll.vue` | Rust port of the JS AutoScroll; not imported |
|
|
||||||
| `components/util/{MusicPlayer,ObjectTable}.vue` | not imported |
|
| `components/util/{MusicPlayer,ObjectTable}.vue` | not imported |
|
||||||
| `components/elle/Elle.vue`, `components/borders/UtenaFrame.vue` | decorative; not imported |
|
| `components/elle/Elle.vue`, `components/borders/UtenaFrame.vue` | decorative; not imported |
|
||||||
| `stores/models.js`, `js/mobile-automata.mjs` | not imported |
|
| `stores/models.js`, `js/mobile-automata.mjs` | not imported |
|
||||||
|
|||||||
Generated
-136
@@ -1,136 +0,0 @@
|
|||||||
# This file is automatically @generated by Cargo.
|
|
||||||
# It is not intended for manual editing.
|
|
||||||
version = 4
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "bumpalo"
|
|
||||||
version = "3.19.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "5dd9dc738b7a8311c7ade152424974d8115f2cdad61e8dab8dac9f2362298510"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "cfg-if"
|
|
||||||
version = "1.0.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "js-sys"
|
|
||||||
version = "0.3.85"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "8c942ebf8e95485ca0d52d97da7c5a2c387d0e7f0ba4c35e93bfcaee045955b3"
|
|
||||||
dependencies = [
|
|
||||||
"once_cell",
|
|
||||||
"wasm-bindgen",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "once_cell"
|
|
||||||
version = "1.21.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "proc-macro2"
|
|
||||||
version = "1.0.106"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934"
|
|
||||||
dependencies = [
|
|
||||||
"unicode-ident",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "quote"
|
|
||||||
version = "1.0.44"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "21b2ebcf727b7760c461f091f9f0f539b77b8e87f2fd88131e7f1b433b3cece4"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rustversion"
|
|
||||||
version = "1.0.22"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "stp_wasm"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"js-sys",
|
|
||||||
"wasm-bindgen",
|
|
||||||
"web-sys",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "syn"
|
|
||||||
version = "2.0.116"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "3df424c70518695237746f84cede799c9c58fcb37450d7b23716568cc8bc69cb"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"unicode-ident",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "unicode-ident"
|
|
||||||
version = "1.0.24"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "wasm-bindgen"
|
|
||||||
version = "0.2.108"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "64024a30ec1e37399cf85a7ffefebdb72205ca1c972291c51512360d90bd8566"
|
|
||||||
dependencies = [
|
|
||||||
"cfg-if",
|
|
||||||
"once_cell",
|
|
||||||
"rustversion",
|
|
||||||
"wasm-bindgen-macro",
|
|
||||||
"wasm-bindgen-shared",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "wasm-bindgen-macro"
|
|
||||||
version = "0.2.108"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "008b239d9c740232e71bd39e8ef6429d27097518b6b30bdf9086833bd5b6d608"
|
|
||||||
dependencies = [
|
|
||||||
"quote",
|
|
||||||
"wasm-bindgen-macro-support",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "wasm-bindgen-macro-support"
|
|
||||||
version = "0.2.108"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "5256bae2d58f54820e6490f9839c49780dff84c65aeab9e772f15d5f0e913a55"
|
|
||||||
dependencies = [
|
|
||||||
"bumpalo",
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn",
|
|
||||||
"wasm-bindgen-shared",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "wasm-bindgen-shared"
|
|
||||||
version = "0.2.108"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "1f01b580c9ac74c8d8f0c0e4afb04eeef2acf145458e52c03845ee9cd23e3d12"
|
|
||||||
dependencies = [
|
|
||||||
"unicode-ident",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "web-sys"
|
|
||||||
version = "0.3.85"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "312e32e551d92129218ea9a2452120f4aabc03529ef03e4d0d82fb2780608598"
|
|
||||||
dependencies = [
|
|
||||||
"js-sys",
|
|
||||||
"wasm-bindgen",
|
|
||||||
]
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "stp_wasm"
|
|
||||||
version = "0.1.0"
|
|
||||||
edition = "2024"
|
|
||||||
|
|
||||||
[lib]
|
|
||||||
crate-type = ["cdylib"]
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
js-sys = "0.3.85"
|
|
||||||
wasm-bindgen = "0.2.108"
|
|
||||||
web-sys = { version = "0.3.85", features = [
|
|
||||||
"console",
|
|
||||||
"Document",
|
|
||||||
"Element",
|
|
||||||
"HtmlElement",
|
|
||||||
"Window",
|
|
||||||
"Animation",
|
|
||||||
"CssStyleDeclaration",
|
|
||||||
"ResizeObserver",
|
|
||||||
"ResizeObserverEntry",
|
|
||||||
"ResizeObserverSize",
|
|
||||||
"EventTarget",
|
|
||||||
"MouseEvent",
|
|
||||||
] }
|
|
||||||
@@ -1,259 +0,0 @@
|
|||||||
use std::cell::RefCell;
|
|
||||||
use std::rc::Rc;
|
|
||||||
use wasm_bindgen::prelude::*;
|
|
||||||
use web_sys::HtmlElement;
|
|
||||||
|
|
||||||
const SPEED: f64 = 0.0005; // % per frame
|
|
||||||
const PAUSE: i32 = 2000; // ms at top/bottom
|
|
||||||
|
|
||||||
struct Inner {
|
|
||||||
el: HtmlElement,
|
|
||||||
pos: f64,
|
|
||||||
direction: f64, // 1.0 = down, -1.0 = up
|
|
||||||
hovered: bool,
|
|
||||||
cached_scroll_height: f64,
|
|
||||||
raf_id: Option<i32>,
|
|
||||||
pause_timeout_id: Option<i32>,
|
|
||||||
resize_observer: Option<web_sys::ResizeObserver>,
|
|
||||||
// closures kept alive
|
|
||||||
tick_closure: Option<Closure<dyn FnMut()>>,
|
|
||||||
resize_closure: Option<Closure<dyn FnMut(js_sys::Array)>>,
|
|
||||||
mouseenter_closure: Option<Closure<dyn FnMut()>>,
|
|
||||||
mouseleave_closure: Option<Closure<dyn FnMut()>>,
|
|
||||||
start_after_pause_closure: Option<Closure<dyn FnMut()>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[wasm_bindgen]
|
|
||||||
pub struct AutoScroller {
|
|
||||||
inner: Rc<RefCell<Inner>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Inner {
|
|
||||||
fn measure_scroll_height(&mut self) {
|
|
||||||
self.cached_scroll_height = self.el.scroll_height() as f64;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn stop_loop(&mut self) {
|
|
||||||
let window = web_sys::window().unwrap();
|
|
||||||
if let Some(id) = self.raf_id.take() {
|
|
||||||
window.cancel_animation_frame(id).ok();
|
|
||||||
}
|
|
||||||
if let Some(id) = self.pause_timeout_id.take() {
|
|
||||||
window.clear_timeout_with_handle(id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn start_loop(inner: &Rc<RefCell<Inner>>) {
|
|
||||||
{
|
|
||||||
let mut s = inner.borrow_mut();
|
|
||||||
s.stop_loop();
|
|
||||||
}
|
|
||||||
schedule_tick(inner);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn schedule_tick(inner: &Rc<RefCell<Inner>>) {
|
|
||||||
let inner_clone = Rc::clone(inner);
|
|
||||||
|
|
||||||
// Create a fresh tick closure each frame
|
|
||||||
let closure = Closure::once(move || {
|
|
||||||
tick(&inner_clone);
|
|
||||||
});
|
|
||||||
|
|
||||||
let mut s = inner.borrow_mut();
|
|
||||||
let window = web_sys::window().unwrap();
|
|
||||||
let id = window
|
|
||||||
.request_animation_frame(closure.as_ref().unchecked_ref())
|
|
||||||
.unwrap();
|
|
||||||
s.raf_id = Some(id);
|
|
||||||
// Store the closure to keep it alive until the frame fires
|
|
||||||
s.tick_closure = Some(closure);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn tick(inner: &Rc<RefCell<Inner>>) {
|
|
||||||
let should_continue;
|
|
||||||
{
|
|
||||||
let mut s = inner.borrow_mut();
|
|
||||||
s.raf_id = None;
|
|
||||||
|
|
||||||
if s.hovered {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if s.cached_scroll_height == 0.0 {
|
|
||||||
drop(s);
|
|
||||||
schedule_tick(inner);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let reached_bottom = s.pos >= 1.0;
|
|
||||||
let reached_top = s.pos <= 0.0;
|
|
||||||
|
|
||||||
if reached_bottom {
|
|
||||||
s.pos = 0.999;
|
|
||||||
s.direction = -1.0;
|
|
||||||
drop(s);
|
|
||||||
schedule_pause(inner);
|
|
||||||
return;
|
|
||||||
} else if reached_top && s.direction == -1.0 {
|
|
||||||
s.pos = 0.001;
|
|
||||||
s.direction = 1.0;
|
|
||||||
drop(s);
|
|
||||||
schedule_pause(inner);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
s.pos += s.direction * SPEED;
|
|
||||||
s.el.set_scroll_top((s.pos * s.cached_scroll_height) as i32);
|
|
||||||
should_continue = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if should_continue {
|
|
||||||
schedule_tick(inner);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn schedule_pause(inner: &Rc<RefCell<Inner>>) {
|
|
||||||
{
|
|
||||||
let mut s = inner.borrow_mut();
|
|
||||||
s.stop_loop();
|
|
||||||
}
|
|
||||||
|
|
||||||
let inner_clone = Rc::clone(inner);
|
|
||||||
let closure = Closure::once(move || {
|
|
||||||
start_loop(&inner_clone);
|
|
||||||
});
|
|
||||||
|
|
||||||
let mut s = inner.borrow_mut();
|
|
||||||
let window = web_sys::window().unwrap();
|
|
||||||
let id = window
|
|
||||||
.set_timeout_with_callback_and_timeout_and_arguments_0(
|
|
||||||
closure.as_ref().unchecked_ref(),
|
|
||||||
PAUSE,
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
s.pause_timeout_id = Some(id);
|
|
||||||
s.start_after_pause_closure = Some(closure);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[wasm_bindgen]
|
|
||||||
impl AutoScroller {
|
|
||||||
#[wasm_bindgen(constructor)]
|
|
||||||
pub fn new(el: HtmlElement) -> AutoScroller {
|
|
||||||
let inner = Rc::new(RefCell::new(Inner {
|
|
||||||
el,
|
|
||||||
pos: 0.0,
|
|
||||||
direction: 1.0,
|
|
||||||
hovered: false,
|
|
||||||
cached_scroll_height: 0.0,
|
|
||||||
raf_id: None,
|
|
||||||
pause_timeout_id: None,
|
|
||||||
resize_observer: None,
|
|
||||||
tick_closure: None,
|
|
||||||
resize_closure: None,
|
|
||||||
mouseenter_closure: None,
|
|
||||||
mouseleave_closure: None,
|
|
||||||
start_after_pause_closure: None,
|
|
||||||
}));
|
|
||||||
|
|
||||||
// Set up mouseenter listener
|
|
||||||
{
|
|
||||||
let inner_clone = Rc::clone(&inner);
|
|
||||||
let closure = Closure::wrap(Box::new(move || {
|
|
||||||
let mut s = inner_clone.borrow_mut();
|
|
||||||
s.hovered = true;
|
|
||||||
s.stop_loop();
|
|
||||||
}) as Box<dyn FnMut()>);
|
|
||||||
let s = inner.borrow();
|
|
||||||
s.el
|
|
||||||
.add_event_listener_with_callback("mouseenter", closure.as_ref().unchecked_ref())
|
|
||||||
.unwrap();
|
|
||||||
drop(s);
|
|
||||||
inner.borrow_mut().mouseenter_closure = Some(closure);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set up mouseleave listener
|
|
||||||
{
|
|
||||||
let inner_clone = Rc::clone(&inner);
|
|
||||||
let closure = Closure::wrap(Box::new(move || {
|
|
||||||
{
|
|
||||||
let mut s = inner_clone.borrow_mut();
|
|
||||||
s.hovered = false;
|
|
||||||
if s.cached_scroll_height > 0.0 {
|
|
||||||
s.pos = s.el.scroll_top() as f64 / s.cached_scroll_height;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
start_loop(&inner_clone);
|
|
||||||
}) as Box<dyn FnMut()>);
|
|
||||||
let s = inner.borrow();
|
|
||||||
s.el
|
|
||||||
.add_event_listener_with_callback("mouseleave", closure.as_ref().unchecked_ref())
|
|
||||||
.unwrap();
|
|
||||||
drop(s);
|
|
||||||
inner.borrow_mut().mouseleave_closure = Some(closure);
|
|
||||||
}
|
|
||||||
|
|
||||||
AutoScroller { inner }
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn start(&self) {
|
|
||||||
// Measure initial scroll height
|
|
||||||
self.inner.borrow_mut().measure_scroll_height();
|
|
||||||
|
|
||||||
// Set up resize observer
|
|
||||||
let inner_clone = Rc::clone(&self.inner);
|
|
||||||
let resize_closure = Closure::wrap(Box::new(move |_entries: js_sys::Array| {
|
|
||||||
inner_clone.borrow_mut().measure_scroll_height();
|
|
||||||
}) as Box<dyn FnMut(js_sys::Array)>);
|
|
||||||
|
|
||||||
let observer =
|
|
||||||
web_sys::ResizeObserver::new(resize_closure.as_ref().unchecked_ref()).unwrap();
|
|
||||||
|
|
||||||
// Clone the element ref and drop the borrow before calling observe(),
|
|
||||||
// because observe() can fire the resize callback synchronously,
|
|
||||||
// which would conflict with an active borrow.
|
|
||||||
let el_clone = self.inner.borrow().el.clone();
|
|
||||||
observer.observe(&el_clone);
|
|
||||||
|
|
||||||
{
|
|
||||||
let mut s = self.inner.borrow_mut();
|
|
||||||
s.resize_observer = Some(observer);
|
|
||||||
s.resize_closure = Some(resize_closure);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Start with a pause then begin scrolling
|
|
||||||
schedule_pause(&self.inner);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn destroy(&self) {
|
|
||||||
let mut s = self.inner.borrow_mut();
|
|
||||||
s.stop_loop();
|
|
||||||
|
|
||||||
if let Some(observer) = s.resize_observer.take() {
|
|
||||||
observer.disconnect();
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(ref closure) = s.mouseenter_closure {
|
|
||||||
s.el
|
|
||||||
.remove_event_listener_with_callback(
|
|
||||||
"mouseenter",
|
|
||||||
closure.as_ref().unchecked_ref(),
|
|
||||||
)
|
|
||||||
.ok();
|
|
||||||
}
|
|
||||||
if let Some(ref closure) = s.mouseleave_closure {
|
|
||||||
s.el
|
|
||||||
.remove_event_listener_with_callback(
|
|
||||||
"mouseleave",
|
|
||||||
closure.as_ref().unchecked_ref(),
|
|
||||||
)
|
|
||||||
.ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
s.mouseenter_closure = None;
|
|
||||||
s.mouseleave_closure = None;
|
|
||||||
s.resize_closure = None;
|
|
||||||
s.tick_closure = None;
|
|
||||||
s.start_after_pause_closure = None;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,135 +0,0 @@
|
|||||||
use std::cell::RefCell;
|
|
||||||
use std::rc::Rc;
|
|
||||||
use wasm_bindgen::prelude::*;
|
|
||||||
use web_sys::HtmlElement;
|
|
||||||
|
|
||||||
const SPEED: f64 = 0.5; // pixels per frame
|
|
||||||
|
|
||||||
struct Inner {
|
|
||||||
container: HtmlElement,
|
|
||||||
item1: HtmlElement,
|
|
||||||
offset: f64,
|
|
||||||
cached_width: f64,
|
|
||||||
raf_id: Option<i32>,
|
|
||||||
resize_observer: Option<web_sys::ResizeObserver>,
|
|
||||||
// closures kept alive
|
|
||||||
animate_closure: Option<Closure<dyn FnMut()>>,
|
|
||||||
resize_closure: Option<Closure<dyn FnMut(js_sys::Array)>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[wasm_bindgen]
|
|
||||||
pub struct HeadlineScroller {
|
|
||||||
inner: Rc<RefCell<Inner>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Inner {
|
|
||||||
fn measure_width(&mut self) {
|
|
||||||
let container_width = self.container.offset_width() as f64;
|
|
||||||
let item_width = self.item1.scroll_width() as f64;
|
|
||||||
self.cached_width = container_width.max(item_width);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn schedule_frame(inner: &Rc<RefCell<Inner>>) {
|
|
||||||
let inner_clone = Rc::clone(inner);
|
|
||||||
|
|
||||||
let closure = Closure::once(move || {
|
|
||||||
animate(&inner_clone);
|
|
||||||
});
|
|
||||||
|
|
||||||
let mut s = inner.borrow_mut();
|
|
||||||
let window = web_sys::window().unwrap();
|
|
||||||
let id = window
|
|
||||||
.request_animation_frame(closure.as_ref().unchecked_ref())
|
|
||||||
.unwrap();
|
|
||||||
s.raf_id = Some(id);
|
|
||||||
s.animate_closure = Some(closure);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn animate(inner: &Rc<RefCell<Inner>>) {
|
|
||||||
{
|
|
||||||
let mut s = inner.borrow_mut();
|
|
||||||
s.raf_id = None;
|
|
||||||
|
|
||||||
if s.cached_width == 0.0 {
|
|
||||||
drop(s);
|
|
||||||
schedule_frame(inner);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
s.offset -= SPEED;
|
|
||||||
|
|
||||||
if s.offset <= -s.cached_width {
|
|
||||||
s.offset += s.cached_width;
|
|
||||||
}
|
|
||||||
|
|
||||||
let transform = format!("translateX({}px)", s.offset);
|
|
||||||
s.container.style().set_property("transform", &transform).ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
schedule_frame(inner);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[wasm_bindgen]
|
|
||||||
impl HeadlineScroller {
|
|
||||||
#[wasm_bindgen(constructor)]
|
|
||||||
pub fn new(container: HtmlElement, item1: HtmlElement) -> HeadlineScroller {
|
|
||||||
let inner = Rc::new(RefCell::new(Inner {
|
|
||||||
container,
|
|
||||||
item1,
|
|
||||||
offset: 0.0,
|
|
||||||
cached_width: 0.0,
|
|
||||||
raf_id: None,
|
|
||||||
resize_observer: None,
|
|
||||||
animate_closure: None,
|
|
||||||
resize_closure: None,
|
|
||||||
}));
|
|
||||||
|
|
||||||
HeadlineScroller { inner }
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn start(&self) {
|
|
||||||
// Measure initial width
|
|
||||||
self.inner.borrow_mut().measure_width();
|
|
||||||
|
|
||||||
// Set up resize observer
|
|
||||||
let inner_clone = Rc::clone(&self.inner);
|
|
||||||
let resize_closure = Closure::wrap(Box::new(move |_entries: js_sys::Array| {
|
|
||||||
inner_clone.borrow_mut().measure_width();
|
|
||||||
}) as Box<dyn FnMut(js_sys::Array)>);
|
|
||||||
|
|
||||||
let observer =
|
|
||||||
web_sys::ResizeObserver::new(resize_closure.as_ref().unchecked_ref()).unwrap();
|
|
||||||
|
|
||||||
// Clone the element ref and drop the borrow before calling observe(),
|
|
||||||
// because observe() can fire the resize callback synchronously,
|
|
||||||
// which would conflict with an active borrow.
|
|
||||||
let container_clone = self.inner.borrow().container.clone();
|
|
||||||
observer.observe(&container_clone);
|
|
||||||
|
|
||||||
{
|
|
||||||
let mut s = self.inner.borrow_mut();
|
|
||||||
s.resize_observer = Some(observer);
|
|
||||||
s.resize_closure = Some(resize_closure);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Start animation loop
|
|
||||||
schedule_frame(&self.inner);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn destroy(&self) {
|
|
||||||
let mut s = self.inner.borrow_mut();
|
|
||||||
|
|
||||||
let window = web_sys::window().unwrap();
|
|
||||||
if let Some(id) = s.raf_id.take() {
|
|
||||||
window.cancel_animation_frame(id).ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(observer) = s.resize_observer.take() {
|
|
||||||
observer.disconnect();
|
|
||||||
}
|
|
||||||
|
|
||||||
s.animate_closure = None;
|
|
||||||
s.resize_closure = None;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
mod auto_scroll;
|
|
||||||
mod headline;
|
|
||||||
|
|
||||||
pub use auto_scroll::AutoScroller;
|
|
||||||
pub use headline::HeadlineScroller;
|
|
||||||
Generated
+1
-348
@@ -28,9 +28,7 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@vitejs/plugin-vue": "^6.0.1",
|
"@vitejs/plugin-vue": "^6.0.1",
|
||||||
"vite": "^7.3.2",
|
"vite": "^7.3.2",
|
||||||
"vite-plugin-top-level-await": "^1.6.0",
|
"vite-plugin-vue-devtools": "^8.0.3"
|
||||||
"vite-plugin-vue-devtools": "^8.0.3",
|
|
||||||
"vite-plugin-wasm": "^3.6.0"
|
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "^20.19.0 || >=22.12.0"
|
"node": "^20.19.0 || >=22.12.0"
|
||||||
@@ -1225,24 +1223,6 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/@rollup/plugin-virtual": {
|
|
||||||
"version": "3.0.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/@rollup/plugin-virtual/-/plugin-virtual-3.0.2.tgz",
|
|
||||||
"integrity": "sha512-10monEYsBp3scM4/ND4LNH5Rxvh3e/cVeL3jWTgZ2SrQ+BmUoQcopVQvnaMcOnykb1VkxUFuDAN+0FnpTFRy2A==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
|
||||||
"engines": {
|
|
||||||
"node": ">=14.0.0"
|
|
||||||
},
|
|
||||||
"peerDependencies": {
|
|
||||||
"rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0"
|
|
||||||
},
|
|
||||||
"peerDependenciesMeta": {
|
|
||||||
"rollup": {
|
|
||||||
"optional": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@rollup/rollup-android-arm-eabi": {
|
"node_modules/@rollup/rollup-android-arm-eabi": {
|
||||||
"version": "4.59.0",
|
"version": "4.59.0",
|
||||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.59.0.tgz",
|
"resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.59.0.tgz",
|
||||||
@@ -1568,293 +1548,6 @@
|
|||||||
"win32"
|
"win32"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@swc/core": {
|
|
||||||
"version": "1.15.24",
|
|
||||||
"resolved": "https://registry.npmjs.org/@swc/core/-/core-1.15.24.tgz",
|
|
||||||
"integrity": "sha512-5Hj8aNasue7yusUt8LGCUe/AjM7RMAce8ZoyDyiFwx7Al+GbYKL+yE7g4sJk8vEr1dKIkTRARkNIJENc4CjkBQ==",
|
|
||||||
"dev": true,
|
|
||||||
"hasInstallScript": true,
|
|
||||||
"license": "Apache-2.0",
|
|
||||||
"dependencies": {
|
|
||||||
"@swc/counter": "^0.1.3",
|
|
||||||
"@swc/types": "^0.1.26"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=10"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"type": "opencollective",
|
|
||||||
"url": "https://opencollective.com/swc"
|
|
||||||
},
|
|
||||||
"optionalDependencies": {
|
|
||||||
"@swc/core-darwin-arm64": "1.15.24",
|
|
||||||
"@swc/core-darwin-x64": "1.15.24",
|
|
||||||
"@swc/core-linux-arm-gnueabihf": "1.15.24",
|
|
||||||
"@swc/core-linux-arm64-gnu": "1.15.24",
|
|
||||||
"@swc/core-linux-arm64-musl": "1.15.24",
|
|
||||||
"@swc/core-linux-ppc64-gnu": "1.15.24",
|
|
||||||
"@swc/core-linux-s390x-gnu": "1.15.24",
|
|
||||||
"@swc/core-linux-x64-gnu": "1.15.24",
|
|
||||||
"@swc/core-linux-x64-musl": "1.15.24",
|
|
||||||
"@swc/core-win32-arm64-msvc": "1.15.24",
|
|
||||||
"@swc/core-win32-ia32-msvc": "1.15.24",
|
|
||||||
"@swc/core-win32-x64-msvc": "1.15.24"
|
|
||||||
},
|
|
||||||
"peerDependencies": {
|
|
||||||
"@swc/helpers": ">=0.5.17"
|
|
||||||
},
|
|
||||||
"peerDependenciesMeta": {
|
|
||||||
"@swc/helpers": {
|
|
||||||
"optional": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@swc/core-darwin-arm64": {
|
|
||||||
"version": "1.15.24",
|
|
||||||
"resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.15.24.tgz",
|
|
||||||
"integrity": "sha512-uM5ZGfFXjtvtJ+fe448PVBEbn/CSxS3UAyLj3O9xOqKIWy3S6hPTXSPbszxkSsGDYKi+YFhzAsR4r/eXLxEQ0g==",
|
|
||||||
"cpu": [
|
|
||||||
"arm64"
|
|
||||||
],
|
|
||||||
"dev": true,
|
|
||||||
"license": "Apache-2.0 AND MIT",
|
|
||||||
"optional": true,
|
|
||||||
"os": [
|
|
||||||
"darwin"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">=10"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@swc/core-darwin-x64": {
|
|
||||||
"version": "1.15.24",
|
|
||||||
"resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.15.24.tgz",
|
|
||||||
"integrity": "sha512-fMIb/Zfn929pw25VMBhV7Ji2Dl+lCWtUPNdYJQYOke+00E5fcQ9ynxtP8+qhUo/HZc+mYQb1gJxwHM9vty+lXg==",
|
|
||||||
"cpu": [
|
|
||||||
"x64"
|
|
||||||
],
|
|
||||||
"dev": true,
|
|
||||||
"license": "Apache-2.0 AND MIT",
|
|
||||||
"optional": true,
|
|
||||||
"os": [
|
|
||||||
"darwin"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">=10"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@swc/core-linux-arm-gnueabihf": {
|
|
||||||
"version": "1.15.24",
|
|
||||||
"resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.15.24.tgz",
|
|
||||||
"integrity": "sha512-vOkjsyjjxnoYx3hMEWcGxQrMgnNrRm6WAegBXrN8foHtDAR+zpdhpGF5a4lj1bNPgXAvmysjui8cM1ov/Clkaw==",
|
|
||||||
"cpu": [
|
|
||||||
"arm"
|
|
||||||
],
|
|
||||||
"dev": true,
|
|
||||||
"license": "Apache-2.0",
|
|
||||||
"optional": true,
|
|
||||||
"os": [
|
|
||||||
"linux"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">=10"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@swc/core-linux-arm64-gnu": {
|
|
||||||
"version": "1.15.24",
|
|
||||||
"resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.15.24.tgz",
|
|
||||||
"integrity": "sha512-h/oNu+upkXJ6Cicnq7YGVj9PkdfarLCdQa8l/FlHYvfv8CEiMaeeTnpLU7gSBH/rGxosM6Qkfa/J9mThGF9CLA==",
|
|
||||||
"cpu": [
|
|
||||||
"arm64"
|
|
||||||
],
|
|
||||||
"dev": true,
|
|
||||||
"libc": [
|
|
||||||
"glibc"
|
|
||||||
],
|
|
||||||
"license": "Apache-2.0 AND MIT",
|
|
||||||
"optional": true,
|
|
||||||
"os": [
|
|
||||||
"linux"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">=10"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@swc/core-linux-arm64-musl": {
|
|
||||||
"version": "1.15.24",
|
|
||||||
"resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.15.24.tgz",
|
|
||||||
"integrity": "sha512-ZpF/pRe1guk6sKzQI9D1jAORtjTdNlyeXn9GDz8ophof/w2WhojRblvSDJaGe7rJjcPN8AaOkhwdRUh7q8oYIg==",
|
|
||||||
"cpu": [
|
|
||||||
"arm64"
|
|
||||||
],
|
|
||||||
"dev": true,
|
|
||||||
"libc": [
|
|
||||||
"musl"
|
|
||||||
],
|
|
||||||
"license": "Apache-2.0 AND MIT",
|
|
||||||
"optional": true,
|
|
||||||
"os": [
|
|
||||||
"linux"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">=10"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@swc/core-linux-ppc64-gnu": {
|
|
||||||
"version": "1.15.24",
|
|
||||||
"resolved": "https://registry.npmjs.org/@swc/core-linux-ppc64-gnu/-/core-linux-ppc64-gnu-1.15.24.tgz",
|
|
||||||
"integrity": "sha512-QZEsZfisHTSJlmyChgDFNmKPb3W6Lhbfo/O76HhIngfEdnQNmukS38/VSe1feho+xkV5A5hETyCbx3sALBZKAQ==",
|
|
||||||
"cpu": [
|
|
||||||
"ppc64"
|
|
||||||
],
|
|
||||||
"dev": true,
|
|
||||||
"libc": [
|
|
||||||
"glibc"
|
|
||||||
],
|
|
||||||
"license": "Apache-2.0 AND MIT",
|
|
||||||
"optional": true,
|
|
||||||
"os": [
|
|
||||||
"linux"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">=10"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@swc/core-linux-s390x-gnu": {
|
|
||||||
"version": "1.15.24",
|
|
||||||
"resolved": "https://registry.npmjs.org/@swc/core-linux-s390x-gnu/-/core-linux-s390x-gnu-1.15.24.tgz",
|
|
||||||
"integrity": "sha512-DLdJKVsJgglqQrJBuoUYNmzm3leI7kUZhLbZGHv42onfKsGf6JDS3+bzCUQfte/XOqDjh/tmmn1DR/CF/tCJFw==",
|
|
||||||
"cpu": [
|
|
||||||
"s390x"
|
|
||||||
],
|
|
||||||
"dev": true,
|
|
||||||
"libc": [
|
|
||||||
"glibc"
|
|
||||||
],
|
|
||||||
"license": "Apache-2.0 AND MIT",
|
|
||||||
"optional": true,
|
|
||||||
"os": [
|
|
||||||
"linux"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">=10"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@swc/core-linux-x64-gnu": {
|
|
||||||
"version": "1.15.24",
|
|
||||||
"resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.15.24.tgz",
|
|
||||||
"integrity": "sha512-IpLYfposPA/XLxYOKpRfeccl1p5dDa3+okZDHHTchBkXEaVCnq5MADPmIWwIYj1tudt7hORsEHccG5no6IUQRw==",
|
|
||||||
"cpu": [
|
|
||||||
"x64"
|
|
||||||
],
|
|
||||||
"dev": true,
|
|
||||||
"libc": [
|
|
||||||
"glibc"
|
|
||||||
],
|
|
||||||
"license": "Apache-2.0 AND MIT",
|
|
||||||
"optional": true,
|
|
||||||
"os": [
|
|
||||||
"linux"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">=10"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@swc/core-linux-x64-musl": {
|
|
||||||
"version": "1.15.24",
|
|
||||||
"resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.15.24.tgz",
|
|
||||||
"integrity": "sha512-JHy3fMSc0t/EPWgo74+OK5TGr51aElnzqfUPaiRf2qJ/BfX5CUCfMiWVBuhI7qmVMBnk1jTRnL/xZnOSHDPLYg==",
|
|
||||||
"cpu": [
|
|
||||||
"x64"
|
|
||||||
],
|
|
||||||
"dev": true,
|
|
||||||
"libc": [
|
|
||||||
"musl"
|
|
||||||
],
|
|
||||||
"license": "Apache-2.0 AND MIT",
|
|
||||||
"optional": true,
|
|
||||||
"os": [
|
|
||||||
"linux"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">=10"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@swc/core-win32-arm64-msvc": {
|
|
||||||
"version": "1.15.24",
|
|
||||||
"resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.15.24.tgz",
|
|
||||||
"integrity": "sha512-Txj+qUH1z2bUd1P3JvwByfjKFti3cptlAxhWgmunBUUxy/IW3CXLZ6l6Gk4liANadKkU71nIU1X30Z5vpMT3BA==",
|
|
||||||
"cpu": [
|
|
||||||
"arm64"
|
|
||||||
],
|
|
||||||
"dev": true,
|
|
||||||
"license": "Apache-2.0 AND MIT",
|
|
||||||
"optional": true,
|
|
||||||
"os": [
|
|
||||||
"win32"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">=10"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@swc/core-win32-ia32-msvc": {
|
|
||||||
"version": "1.15.24",
|
|
||||||
"resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.15.24.tgz",
|
|
||||||
"integrity": "sha512-15D/nl3XwrhFpMv+MADFOiVwv3FvH9j8c6Rf8EXBT3Q5LoMh8YnDnSgPYqw1JzPnksvsBX6QPXLiPqmcR/Z4qQ==",
|
|
||||||
"cpu": [
|
|
||||||
"ia32"
|
|
||||||
],
|
|
||||||
"dev": true,
|
|
||||||
"license": "Apache-2.0 AND MIT",
|
|
||||||
"optional": true,
|
|
||||||
"os": [
|
|
||||||
"win32"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">=10"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@swc/core-win32-x64-msvc": {
|
|
||||||
"version": "1.15.24",
|
|
||||||
"resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.15.24.tgz",
|
|
||||||
"integrity": "sha512-PR0PlTlPra2JbaDphrOAzm6s0v9rA0F17YzB+XbWD95B4g2cWcZY9LAeTa4xll70VLw9Jr7xBrlohqlQmelMFQ==",
|
|
||||||
"cpu": [
|
|
||||||
"x64"
|
|
||||||
],
|
|
||||||
"dev": true,
|
|
||||||
"license": "Apache-2.0 AND MIT",
|
|
||||||
"optional": true,
|
|
||||||
"os": [
|
|
||||||
"win32"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">=10"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@swc/counter": {
|
|
||||||
"version": "0.1.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/@swc/counter/-/counter-0.1.3.tgz",
|
|
||||||
"integrity": "sha512-e2BR4lsJkkRlKZ/qCHPw9ZaSxc0MVUd7gtbtaB7aMvHeJVYe8sOB8DBZkP2DtISHGSku9sCK6T6cnY0CtXrOCQ==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "Apache-2.0"
|
|
||||||
},
|
|
||||||
"node_modules/@swc/types": {
|
|
||||||
"version": "0.1.26",
|
|
||||||
"resolved": "https://registry.npmjs.org/@swc/types/-/types-0.1.26.tgz",
|
|
||||||
"integrity": "sha512-lyMwd7WGgG79RS7EERZV3T8wMdmPq3xwyg+1nmAM64kIhx5yl+juO2PYIHb7vTiPgPCj8LYjsNV2T5wiQHUEaw==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "Apache-2.0",
|
|
||||||
"dependencies": {
|
|
||||||
"@swc/counter": "^0.1.3"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@swc/wasm": {
|
|
||||||
"version": "1.15.24",
|
|
||||||
"resolved": "https://registry.npmjs.org/@swc/wasm/-/wasm-1.15.24.tgz",
|
|
||||||
"integrity": "sha512-vFjzOE8dhJcfeTbM4+HO9Qy58IINV0ysqStAgw81uds+KqCeUDM9huN+SZ5lWZ6U+5nf8VcZoEw5N81xMtAidg==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "Apache-2.0"
|
|
||||||
},
|
|
||||||
"node_modules/@tailwindcss/node": {
|
"node_modules/@tailwindcss/node": {
|
||||||
"version": "4.1.18",
|
"version": "4.1.18",
|
||||||
"resolved": "https://registry.npmjs.org/@tailwindcss/node/-/node-4.1.18.tgz",
|
"resolved": "https://registry.npmjs.org/@tailwindcss/node/-/node-4.1.18.tgz",
|
||||||
@@ -4051,20 +3744,6 @@
|
|||||||
"integrity": "sha512-Xn0w3MtiQ6zoz2vFyUVruaCL53O/DwUvkEeOvj+uulMm0BkUGYWmBYVyElqZaSLhY6ZD0ulfU3aBra2aVT4xfA==",
|
"integrity": "sha512-Xn0w3MtiQ6zoz2vFyUVruaCL53O/DwUvkEeOvj+uulMm0BkUGYWmBYVyElqZaSLhY6ZD0ulfU3aBra2aVT4xfA==",
|
||||||
"license": "(WTFPL OR MIT)"
|
"license": "(WTFPL OR MIT)"
|
||||||
},
|
},
|
||||||
"node_modules/uuid": {
|
|
||||||
"version": "10.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-10.0.0.tgz",
|
|
||||||
"integrity": "sha512-8XkAphELsDnEGrDxUOHB3RGvXz6TeuYSGEZBOjtTtPm2lwhGBjLgOzLHB63IUWfBpNucQjND6d3AOudO+H3RWQ==",
|
|
||||||
"dev": true,
|
|
||||||
"funding": [
|
|
||||||
"https://github.com/sponsors/broofa",
|
|
||||||
"https://github.com/sponsors/ctavan"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
|
||||||
"bin": {
|
|
||||||
"uuid": "dist/bin/uuid"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/vite": {
|
"node_modules/vite": {
|
||||||
"version": "7.3.2",
|
"version": "7.3.2",
|
||||||
"resolved": "https://registry.npmjs.org/vite/-/vite-7.3.2.tgz",
|
"resolved": "https://registry.npmjs.org/vite/-/vite-7.3.2.tgz",
|
||||||
@@ -4208,22 +3887,6 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/vite-plugin-top-level-await": {
|
|
||||||
"version": "1.6.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/vite-plugin-top-level-await/-/vite-plugin-top-level-await-1.6.0.tgz",
|
|
||||||
"integrity": "sha512-bNhUreLamTIkoulCR9aDXbTbhLk6n1YE8NJUTTxl5RYskNRtzOR0ASzSjBVRtNdjIfngDXo11qOsybGLNsrdww==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"@rollup/plugin-virtual": "^3.0.2",
|
|
||||||
"@swc/core": "^1.12.14",
|
|
||||||
"@swc/wasm": "^1.12.14",
|
|
||||||
"uuid": "10.0.0"
|
|
||||||
},
|
|
||||||
"peerDependencies": {
|
|
||||||
"vite": ">=2.8"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/vite-plugin-vue-devtools": {
|
"node_modules/vite-plugin-vue-devtools": {
|
||||||
"version": "8.0.5",
|
"version": "8.0.5",
|
||||||
"resolved": "https://registry.npmjs.org/vite-plugin-vue-devtools/-/vite-plugin-vue-devtools-8.0.5.tgz",
|
"resolved": "https://registry.npmjs.org/vite-plugin-vue-devtools/-/vite-plugin-vue-devtools-8.0.5.tgz",
|
||||||
@@ -4299,16 +3962,6 @@
|
|||||||
"vite": "^3.0.0-0 || ^4.0.0-0 || ^5.0.0-0 || ^6.0.0-0 || ^7.0.0-0"
|
"vite": "^3.0.0-0 || ^4.0.0-0 || ^5.0.0-0 || ^6.0.0-0 || ^7.0.0-0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/vite-plugin-wasm": {
|
|
||||||
"version": "3.6.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/vite-plugin-wasm/-/vite-plugin-wasm-3.6.0.tgz",
|
|
||||||
"integrity": "sha512-mL/QPziiIA4RAA6DkaZZzOstdwbW5jO4Vz7Zenj0wieKWBlNvIvX5L5ljum9lcUX0ShNfBgCNLKTjNkRVVqcsw==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
|
||||||
"peerDependencies": {
|
|
||||||
"vite": "^2 || ^3 || ^4 || ^5 || ^6 || ^7 || ^8"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/vue": {
|
"node_modules/vue": {
|
||||||
"version": "3.5.26",
|
"version": "3.5.26",
|
||||||
"resolved": "https://registry.npmjs.org/vue/-/vue-3.5.26.tgz",
|
"resolved": "https://registry.npmjs.org/vue/-/vue-3.5.26.tgz",
|
||||||
|
|||||||
+2
-6
@@ -7,10 +7,8 @@
|
|||||||
"node": "^20.19.0 || >=22.12.0"
|
"node": "^20.19.0 || >=22.12.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build:wasm": "wasm-pack build crates/stp_wasm --target web --out-dir ../../src/wasm",
|
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"build": "npm run build:wasm && vite build",
|
"build": "vite build",
|
||||||
"build:js": "vite build",
|
|
||||||
"preview": "vite preview"
|
"preview": "vite preview"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -34,8 +32,6 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@vitejs/plugin-vue": "^6.0.1",
|
"@vitejs/plugin-vue": "^6.0.1",
|
||||||
"vite": "^7.3.2",
|
"vite": "^7.3.2",
|
||||||
"vite-plugin-top-level-await": "^1.6.0",
|
"vite-plugin-vue-devtools": "^8.0.3"
|
||||||
"vite-plugin-vue-devtools": "^8.0.3",
|
|
||||||
"vite-plugin-wasm": "^3.6.0"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,36 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div ref="container" class="overflow-y-auto">
|
|
||||||
<slot />
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
/**
|
|
||||||
* Rust/wasm port of components/util/AutoScroll.vue — the whole rAF loop lives in
|
|
||||||
* the AutoScroller struct from src/wasm/.
|
|
||||||
*
|
|
||||||
* Note the two-step teardown: destroy() detaches the loop and listeners, free()
|
|
||||||
* releases the Rust-side memory. Skipping free() leaks the wasm allocation, which
|
|
||||||
* JS garbage collection cannot reclaim.
|
|
||||||
*
|
|
||||||
* STATUS: not imported anywhere; the JS AutoScroll is what the widgets use.
|
|
||||||
*/
|
|
||||||
import { useTemplateRef, onMounted, onBeforeUnmount } from "vue";
|
|
||||||
import { AutoScroller } from "@/wasm/stp_wasm.js";
|
|
||||||
|
|
||||||
const container = useTemplateRef("container");
|
|
||||||
|
|
||||||
let scroller = null;
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
if (!container.value) return;
|
|
||||||
scroller = new AutoScroller(container.value);
|
|
||||||
scroller.start();
|
|
||||||
});
|
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
|
||||||
scroller?.destroy();
|
|
||||||
scroller?.free();
|
|
||||||
scroller = null;
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
@@ -1,10 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* App entry point. Mounts <App> on #app with the router and a fresh Pinia.
|
* App entry point. Mounts <App> on #app with the router and a fresh Pinia.
|
||||||
*
|
|
||||||
* The top-level `await init()` loads the Rust/wasm bundle before anything else
|
|
||||||
* renders, so components that reach for a wasm export (components/util/wasm/)
|
|
||||||
* never see an uninitialised module. Top-level await in an entry module is what
|
|
||||||
* `vite-plugin-top-level-await` in vite.config.js is there to support.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { createApp } from "vue";
|
import { createApp } from "vue";
|
||||||
@@ -12,9 +7,6 @@ import { createPinia } from "pinia";
|
|||||||
import App from "./App.vue";
|
import App from "./App.vue";
|
||||||
import router from "./router";
|
import router from "./router";
|
||||||
import "./assets/styles.css";
|
import "./assets/styles.css";
|
||||||
import init from "@/wasm/stp_wasm.js";
|
|
||||||
|
|
||||||
await init();
|
|
||||||
|
|
||||||
const app = createApp(App);
|
const app = createApp(App);
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ import { defineConfig, loadEnv } from "vite";
|
|||||||
import tailwindcss from "@tailwindcss/vite";
|
import tailwindcss from "@tailwindcss/vite";
|
||||||
import vue from "@vitejs/plugin-vue";
|
import vue from "@vitejs/plugin-vue";
|
||||||
import vueDevTools from "vite-plugin-vue-devtools";
|
import vueDevTools from "vite-plugin-vue-devtools";
|
||||||
import wasm from "vite-plugin-wasm";
|
|
||||||
import topLevelAwait from "vite-plugin-top-level-await";
|
|
||||||
|
|
||||||
// Dev-server proxy targets (frontend-only `npm run dev`).
|
// Dev-server proxy targets (frontend-only `npm run dev`).
|
||||||
//
|
//
|
||||||
@@ -66,8 +64,6 @@ export default defineConfig(({ mode }) => {
|
|||||||
vue(),
|
vue(),
|
||||||
...(process.env.NODE_ENV !== "production" ? [vueDevTools()] : []),
|
...(process.env.NODE_ENV !== "production" ? [vueDevTools()] : []),
|
||||||
tailwindcss(),
|
tailwindcss(),
|
||||||
wasm(),
|
|
||||||
topLevelAwait(),
|
|
||||||
],
|
],
|
||||||
resolve: {
|
resolve: {
|
||||||
alias: {
|
alias: {
|
||||||
|
|||||||
Reference in New Issue
Block a user