From fe139f31cd580f683bfc2c268eb8e03bea9d9c6d Mon Sep 17 00:00:00 2001 From: Neko Ayaka Date: Tue, 7 Apr 2026 01:38:02 +0800 Subject: [PATCH] chore(stage-*): configured https, now dev:web:https or pnpm -F @proj-airi/stage-web dev:https works --- apps/stage-pocket/package.json | 1 + apps/stage-pocket/vite.config.ts | 11 ++++---- apps/stage-tamagotchi/package.json | 2 ++ apps/stage-web/package.json | 3 +++ apps/stage-web/vite.config.ts | 29 +++++++++++++++++++- package.json | 1 + packages/stage-ui/package.json | 1 + pnpm-lock.yaml | 43 ++++++++++++++++++++++++++++++ pnpm-workspace.yaml | 1 + 9 files changed, 85 insertions(+), 7 deletions(-) diff --git a/apps/stage-pocket/package.json b/apps/stage-pocket/package.json index 89d5d794c..97218e24b 100644 --- a/apps/stage-pocket/package.json +++ b/apps/stage-pocket/package.json @@ -99,6 +99,7 @@ "vue-i18n": "^11.3.0", "vue-router": "^5.0.4", "vue-sonner": "^2.0.9", + "web-haptics": "catalog:", "workbox-window": "^7.4.0", "xsschema": "catalog:", "yauzl": "^3.2.1", diff --git a/apps/stage-pocket/vite.config.ts b/apps/stage-pocket/vite.config.ts index 67acd2611..05f25ea36 100644 --- a/apps/stage-pocket/vite.config.ts +++ b/apps/stage-pocket/vite.config.ts @@ -19,6 +19,7 @@ import VueDevTools from 'vite-plugin-vue-devtools' import Layouts from 'vite-plugin-vue-layouts' import VueMacros from 'vue-macros/vite' +import { tryCatch } from '@moeru/std' import { Download } from '@proj-airi/unplugin-fetch/vite' import { DownloadLive2DSDK } from '@proj-airi/unplugin-live2d-sdk/vite' import { defineConfig } from 'vite' @@ -27,6 +28,7 @@ import { defineConfig } from 'vite' function isEnvTruthy(value: string | undefined | null): boolean { if (value == null) return false + // eslint-disable-next-line e18e/prefer-static-regex return /^(?:1|true|t|yes|y|on)$/i.test(value.trim()) } @@ -107,12 +109,9 @@ export default defineConfig({ : [mkcert((() => { // Workaround: plugin's bundled downloader has a feaxios bug, prefer system mkcert const command = process.platform === 'win32' ? 'where' : 'which' - try { - return { mkcertPath: execSync(`${command} mkcert`, { stdio: 'pipe' }).toString().trim().split(/\r?\n/)[0] } - } - catch { - return {} - } + // eslint-disable-next-line e18e/prefer-static-regex + const { data } = tryCatch(() => ({ mkcertPath: execSync(`${command} mkcert`, { stdio: 'pipe' }).toString().trim().split(/\r?\n/)[0] })) + return data })())], Info(), diff --git a/apps/stage-tamagotchi/package.json b/apps/stage-tamagotchi/package.json index 6a7fcab8c..a3cfb7e64 100644 --- a/apps/stage-tamagotchi/package.json +++ b/apps/stage-tamagotchi/package.json @@ -125,6 +125,7 @@ "vue-i18n": "^11.3.0", "vue-router": "^5.0.4", "vue-sonner": "catalog:", + "web-haptics": "catalog:", "xsschema": "catalog:", "zod": "^4.3.6" }, @@ -186,6 +187,7 @@ "unplugin-yaml": "^4.0.1", "vite": "catalog:", "vite-bundle-visualizer": "^1.2.1", + "vite-plugin-mkcert": "catalog:", "vite-plugin-vue-devtools": "^8.1.1", "vite-plugin-vue-layouts": "^0.11.0", "vue-macros": "^3.1.2", diff --git a/apps/stage-web/package.json b/apps/stage-web/package.json index 5eab8f639..5ec7d303d 100644 --- a/apps/stage-web/package.json +++ b/apps/stage-web/package.json @@ -12,6 +12,7 @@ "scripts": { "build": "vite build", "dev": "vite --host", + "dev:https": "vite --host -- --mkcert", "lint": "eslint .", "preview": "vite preview", "typecheck": "vue-tsc --noEmit" @@ -95,6 +96,7 @@ "vue-i18n": "^11.3.0", "vue-router": "^5.0.4", "vue-sonner": "^2.0.9", + "web-haptics": "catalog:", "workbox-window": "^7.4.0", "xsschema": "catalog:", "yauzl": "^3.2.1", @@ -137,6 +139,7 @@ "unplugin-yaml": "^4.0.1", "vite": "catalog:", "vite-bundle-visualizer": "^1.2.1", + "vite-plugin-mkcert": "catalog:", "vite-plugin-pwa": "^1.2.0", "vite-plugin-vue-devtools": "^8.1.1", "vite-plugin-vue-layouts": "^0.11.0", diff --git a/apps/stage-web/vite.config.ts b/apps/stage-web/vite.config.ts index 925b00af9..9ef172faa 100644 --- a/apps/stage-web/vite.config.ts +++ b/apps/stage-web/vite.config.ts @@ -1,5 +1,7 @@ +import process, { cwd, env } from 'node:process' + +import { execSync } from 'node:child_process' import { join, resolve } from 'node:path' -import { cwd, env } from 'node:process' import VueI18n from '@intlify/unplugin-vue-i18n/vite' import templateCompilerOptions from '@tresjs/core/template-compiler-options' @@ -8,10 +10,12 @@ import Unocss from 'unocss/vite' import Info from 'unplugin-info/vite' import VueRouter from 'unplugin-vue-router/vite' import Yaml from 'unplugin-yaml/vite' +import Mkcert from 'vite-plugin-mkcert' import VueDevTools from 'vite-plugin-vue-devtools' import Layouts from 'vite-plugin-vue-layouts' import VueMacros from 'vue-macros/vite' +import { tryCatch } from '@moeru/std' import { Download } from '@proj-airi/unplugin-fetch/vite' import { DownloadLive2DSDK } from '@proj-airi/unplugin-live2d-sdk/vite' import { createS3Provider, WarpDrivePlugin } from '@proj-airi/vite-plugin-warpdrive' @@ -22,6 +26,17 @@ import { VitePWA } from 'vite-plugin-pwa' const stageUIAssetsRoot = resolve(join(import.meta.dirname, '..', '..', 'packages', 'stage-ui', 'src', 'assets')) const sharedCacheDir = resolve(join(import.meta.dirname, '..', '..', '.cache')) +function hasFlagEnableMkcert(): boolean { + if (process.argv.includes('--mkcert')) { + return true + } + if (env.STAGE_WEB_ENABLE_MKCERT === 'true') { + return true + } + + return false +} + export default defineConfig({ optimizeDeps: { exclude: [ @@ -88,6 +103,18 @@ export default defineConfig({ }, plugins: [ + ...( + hasFlagEnableMkcert() + ? [Mkcert((() => { + // Workaround: plugin's bundled downloader has a feaxios bug, prefer system mkcert + const command = process.platform === 'win32' ? 'where' : 'which' + // eslint-disable-next-line e18e/prefer-static-regex + const { data } = tryCatch(() => ({ mkcertPath: execSync(`${command} mkcert`, { stdio: 'pipe' }).toString().trim().split(/\r?\n/)[0] })) + return data + })())] + : [] + ), + Info(), Yaml(), diff --git a/package.json b/package.json index d52e632c2..b0447b7ec 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "dev:docs": "pnpm -rF @proj-airi/docs run dev", "dev:ui": "pnpm -rF @proj-airi/stage-ui run story:dev", "dev:web": "pnpm -rF @proj-airi/stage-web run dev", + "dev:web:https": "pnpm -rF @proj-airi/stage-web run dev:https", "dev:server-auth": "pnpm -rF @proj-airi/ui-server-auth run dev", "dev:pocket:ios": "pnpm -rF @proj-airi/stage-pocket run dev:ios", "dev:pocket:android": "pnpm -rF @proj-airi/stage-pocket run dev:android", diff --git a/packages/stage-ui/package.json b/packages/stage-ui/package.json index 29cb3e02b..6d702a666 100644 --- a/packages/stage-ui/package.json +++ b/packages/stage-ui/package.json @@ -138,6 +138,7 @@ "vue-i18n": "^11.3.0", "vue-router": "^5.0.4", "vue-sonner": "^2.0.9", + "web-haptics": "catalog:", "xast-util-to-xml": "^4.0.0", "xastscript": "^4.0.0", "xsschema": "catalog:", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a13ae0884..59f9f161b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -297,6 +297,9 @@ catalogs: vue-sonner: specifier: 2.0.9 version: 2.0.9 + web-haptics: + specifier: ^0.0.6 + version: 0.0.6 ws: specifier: ^8.20.0 version: 8.20.0 @@ -915,6 +918,9 @@ importers: vue-sonner: specifier: ^2.0.9 version: 2.0.9(vue@3.5.30(typescript@5.9.3)) + web-haptics: + specifier: 'catalog:' + version: 0.0.6(react@19.2.3)(vue@3.5.30(typescript@5.9.3)) workbox-window: specifier: ^7.4.0 version: 7.4.0 @@ -1330,6 +1336,9 @@ importers: vue-sonner: specifier: 'catalog:' version: 2.0.9(vue@3.5.30(typescript@5.9.3)) + web-haptics: + specifier: 'catalog:' + version: 0.0.6(react@19.2.3)(vue@3.5.30(typescript@5.9.3)) xsschema: specifier: 'catalog:' version: 0.4.0-beta.13(@valibot/to-json-schema@1.0.0-rc.0(valibot@1.3.1(typescript@5.9.3)))(zod-to-json-schema@3.25.1(zod@4.3.6))(zod@4.3.6) @@ -1508,6 +1517,9 @@ importers: vite-bundle-visualizer: specifier: ^1.2.1 version: 1.2.1(rolldown@1.0.0-rc.9)(rollup@4.60.0) + vite-plugin-mkcert: + specifier: 'catalog:' + version: 1.17.10(vite@8.0.2(@types/node@24.12.0)(esbuild@0.27.2)(jiti@2.6.1)(less@4.6.4)(terser@5.46.1)(tsx@4.21.0)(yaml@2.8.3)) vite-plugin-vue-devtools: specifier: ^8.1.1 version: 8.1.1(vite@8.0.2(@types/node@24.12.0)(esbuild@0.27.2)(jiti@2.6.1)(less@4.6.4)(terser@5.46.1)(tsx@4.21.0)(yaml@2.8.3))(vue@3.5.30(typescript@5.9.3)) @@ -1763,6 +1775,9 @@ importers: vue-sonner: specifier: ^2.0.9 version: 2.0.9(vue@3.5.30(typescript@5.9.3)) + web-haptics: + specifier: 'catalog:' + version: 0.0.6(react@19.2.3)(vue@3.5.30(typescript@5.9.3)) workbox-window: specifier: ^7.4.0 version: 7.4.0 @@ -1884,6 +1899,9 @@ importers: vite-bundle-visualizer: specifier: ^1.2.1 version: 1.2.1(rolldown@1.0.0-rc.9)(rollup@4.60.0) + vite-plugin-mkcert: + specifier: 'catalog:' + version: 1.17.10(vite@8.0.2(@types/node@24.12.0)(esbuild@0.27.2)(jiti@2.6.1)(less@4.6.4)(terser@5.46.1)(tsx@4.21.0)(yaml@2.8.3)) vite-plugin-pwa: specifier: ^1.2.0 version: 1.2.0(vite@8.0.2(@types/node@24.12.0)(esbuild@0.27.2)(jiti@2.6.1)(less@4.6.4)(terser@5.46.1)(tsx@4.21.0)(yaml@2.8.3))(workbox-build@7.4.0)(workbox-window@7.4.0) @@ -3125,6 +3143,9 @@ importers: vue-sonner: specifier: ^2.0.9 version: 2.0.9(vue@3.5.30(typescript@5.9.3)) + web-haptics: + specifier: 'catalog:' + version: 0.0.6(react@19.2.3)(vue@3.5.30(typescript@5.9.3)) xast-util-to-xml: specifier: ^4.0.0 version: 4.0.0 @@ -17478,6 +17499,23 @@ packages: resolution: {integrity: sha512-rQicL7OwuqWdQWI33JkSXKcp7cuv1mJG8u3jRQwx/8aDsmhbTHs9ZRmNYOL+LX0wX8edIEQX8jj4bB60GoXtKA==} engines: {node: '>=18.0.0', npm: '>=8.0.0'} + web-haptics@0.0.6: + resolution: {integrity: sha512-eCzcf1LDi20+Fr0x9V3OkX92k0gxEQXaHajmhXHitsnk6SxPeshv8TBtBRqxyst8HI1uf2FyFVE7QS3jo1gkrw==} + peerDependencies: + react: '>=18' + react-dom: '>=18' + svelte: '>=4' + vue: '>=3' + peerDependenciesMeta: + react: + optional: true + react-dom: + optional: true + svelte: + optional: true + vue: + optional: true + web-namespaces@2.0.1: resolution: {integrity: sha512-bKr1DkiNa2krS7qxNtdrtHAmzuYGFQLiQ13TsorsdT6ULTkPLKuu5+GsFpDlg6JFjUTwX2DyhMPG2be8uPrqsQ==} @@ -33060,6 +33098,11 @@ snapshots: transitivePeerDependencies: - supports-color + web-haptics@0.0.6(react@19.2.3)(vue@3.5.30(typescript@5.9.3)): + optionalDependencies: + react: 19.2.3 + vue: 3.5.30(typescript@5.9.3) + web-namespaces@2.0.1: {} web-streams-polyfill@3.3.3: {} diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index e15cb2f37..65e458f5b 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -124,6 +124,7 @@ catalog: vite-plugin-mkcert: ^1.17.10 vue: ^3.5.30 vue-sonner: 2.0.9 + web-haptics: ^0.0.6 ws: ^8.20.0 xsschema: 0.4.0-beta.13 yaml: ^2.8.3