From 10b078c86540790334da551a9245ee349a063e89 Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Sun, 5 Oct 2025 13:31:12 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20getHighEntropyValues=E3=81=8C=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E3=81=A7=E3=81=8D=E3=81=AA=E3=81=84=E5=A0=B4=E5=90=88?= =?UTF-8?q?=E3=81=AF=E7=94=9F=E3=81=AEUA=E3=82=92=E8=BF=94=E3=81=99?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/frontend/package.json | 2 - .../src/utility/get-user-environment.ts | 23 ++++------ pnpm-lock.yaml | 43 ++++++++----------- 3 files changed, 26 insertions(+), 42 deletions(-) diff --git a/packages/frontend/package.json b/packages/frontend/package.json index 4f327e0b0b..0200269fcd 100644 --- a/packages/frontend/package.json +++ b/packages/frontend/package.json @@ -33,7 +33,6 @@ "aiscript-vscode": "github:aiscript-dev/aiscript-vscode#v0.1.15", "analytics": "0.8.19", "astring": "1.9.0", - "bowser": "2.12.1", "broadcast-channel": "7.1.0", "buraha": "0.0.1", "canvas-confetti": "1.9.3", @@ -106,7 +105,6 @@ "@storybook/vue3-vite": "9.1.8", "@tabler/icons-webfont": "3.35.0", "@testing-library/vue": "8.1.0", - "@types/bowser": "1.1.5", "@types/canvas-confetti": "1.9.0", "@types/estree": "1.0.8", "@types/matter-js": "0.20.2", diff --git a/packages/frontend/src/utility/get-user-environment.ts b/packages/frontend/src/utility/get-user-environment.ts index a1f63defb1..aa39025347 100644 --- a/packages/frontend/src/utility/get-user-environment.ts +++ b/packages/frontend/src/utility/get-user-environment.ts @@ -3,19 +3,17 @@ * SPDX-License-Identifier: AGPL-3.0-only */ -// Type Reference Only import (実物はlazy-loadされる) -import type * as BowserTypeReferenceOnly from 'bowser'; - -type BowserTypeTypeReferenceOnly = typeof BowserTypeReferenceOnly; - -let Bowser: BowserTypeTypeReferenceOnly | null = null; - export type UserEnvironment = { os: string; browser: string; screenWidth: number; screenHeight: number; - viaGetHighEntropyValues: boolean; + viaGetHighEntropyValues: true; +} | { + userAgent: string; + screenWidth: number; + screenHeight: number; + viaGetHighEntropyValues: false; }; export async function getUserEnvironment(): Promise { @@ -56,14 +54,9 @@ export async function getUserEnvironment(): Promise { } } -async function getViaUa(): Promise { - if (Bowser == null) { - Bowser = (await import('bowser')).default; - } - const parsed = Bowser.parse(navigator.userAgent); +function getViaUa(): UserEnvironment { return { - os: `${parsed.os.name ?? 'Unknown'} ${parsed.os.version ?? ''} ${parsed.os.versionName ? `(${parsed.os.versionName})` : ''}`.trim(), - browser: `${parsed.browser.name ?? 'Unknown'} ${parsed.browser.version ?? ''}`.trim(), + userAgent: navigator.userAgent, screenWidth: window.innerWidth, screenHeight: window.innerHeight, viaGetHighEntropyValues: false, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index cf850dc765..60efe3b63f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -757,9 +757,6 @@ importers: astring: specifier: 1.9.0 version: 1.9.0 - bowser: - specifier: 2.12.1 - version: 2.12.1 broadcast-channel: specifier: 7.1.0 version: 7.1.0 @@ -971,9 +968,6 @@ importers: '@testing-library/vue': specifier: 8.1.0 version: 8.1.0(@vue/compiler-sfc@3.5.22)(@vue/server-renderer@3.5.22(vue@3.5.22(typescript@5.9.2)))(vue@3.5.22(typescript@5.9.2)) - '@types/bowser': - specifier: 1.1.5 - version: 1.1.5 '@types/canvas-confetti': specifier: 1.9.0 version: 1.9.0 @@ -4598,10 +4592,6 @@ packages: '@types/body-parser@1.19.6': resolution: {integrity: sha512-HLFeCYgz89uk22N5Qg3dvGvsv46B8GLvKKo1zKG4NybA8U2DiEO3w9lqGg29t/tfLRJpJ6iQxnVw4OnB7MoM9g==} - '@types/bowser@1.1.5': - resolution: {integrity: sha512-7qUcVaL3NZ40tLPPlbk9fKL++vT/BBT0vbq+R97KH1lnZQmcZwvqa3rnAcCE48ai2dZm9ETr9TnQXhztGsvPIw==} - deprecated: This is a stub types definition. bowser provides its own type definitions, so you do not need this installed. - '@types/braces@3.0.1': resolution: {integrity: sha512-+euflG6ygo4bn0JHtn4pYqcXwRtLvElQ7/nnjDu7iYG56H0+OhCd7d6Ug0IE3WcFpZozBKW2+80FUbv5QGk5AQ==} @@ -15405,10 +15395,6 @@ snapshots: '@types/connect': 3.4.36 '@types/node': 22.18.6 - '@types/bowser@1.1.5': - dependencies: - bowser: 2.12.1 - '@types/braces@3.0.1': {} '@types/canvas-confetti@1.9.0': {} @@ -15758,7 +15744,7 @@ snapshots: '@typescript-eslint/types': 8.44.1 '@typescript-eslint/typescript-estree': 8.44.1(typescript@5.9.2) '@typescript-eslint/visitor-keys': 8.44.1 - debug: 4.4.1(supports-color@10.2.0) + debug: 4.4.1(supports-color@5.5.0) eslint: 9.36.0 typescript: 5.9.2 transitivePeerDependencies: @@ -15787,7 +15773,7 @@ snapshots: '@typescript-eslint/types': 8.44.1 '@typescript-eslint/typescript-estree': 8.44.1(typescript@5.9.2) '@typescript-eslint/utils': 8.44.1(eslint@9.36.0)(typescript@5.9.2) - debug: 4.4.1(supports-color@10.2.0) + debug: 4.4.1(supports-color@5.5.0) eslint: 9.36.0 ts-api-utils: 2.1.0(typescript@5.9.2) typescript: 5.9.2 @@ -15802,7 +15788,7 @@ snapshots: '@typescript-eslint/tsconfig-utils': 8.44.1(typescript@5.9.2) '@typescript-eslint/types': 8.44.1 '@typescript-eslint/visitor-keys': 8.44.1 - debug: 4.4.1(supports-color@10.2.0) + debug: 4.4.1(supports-color@5.5.0) fast-glob: 3.3.3 is-glob: 4.0.3 minimatch: 9.0.5 @@ -15841,7 +15827,7 @@ snapshots: '@ampproject/remapping': 2.3.0 '@bcoe/v8-coverage': 1.0.2 ast-v8-to-istanbul: 0.3.3 - debug: 4.4.1(supports-color@10.2.0) + debug: 4.4.1(supports-color@5.5.0) istanbul-lib-coverage: 3.2.2 istanbul-lib-report: 3.0.1 istanbul-lib-source-maps: 5.0.6 @@ -17671,7 +17657,7 @@ snapshots: esbuild-register@3.5.0(esbuild@0.25.10): dependencies: - debug: 4.4.1(supports-color@10.2.0) + debug: 4.4.1(supports-color@5.5.0) esbuild: 0.25.10 transitivePeerDependencies: - supports-color @@ -18647,7 +18633,7 @@ snapshots: http-proxy-agent@7.0.2: dependencies: agent-base: 7.1.3 - debug: 4.4.1(supports-color@10.2.0) + debug: 4.4.3 transitivePeerDependencies: - supports-color @@ -18680,6 +18666,13 @@ snapshots: - supports-color optional: true + https-proxy-agent@7.0.6: + dependencies: + agent-base: 7.1.3 + debug: 4.4.3 + transitivePeerDependencies: + - supports-color + https-proxy-agent@7.0.6(supports-color@10.2.0): dependencies: agent-base: 7.1.3 @@ -19022,7 +19015,7 @@ snapshots: istanbul-lib-source-maps@5.0.6: dependencies: '@jridgewell/trace-mapping': 0.3.29 - debug: 4.4.1(supports-color@10.2.0) + debug: 4.4.1(supports-color@5.5.0) istanbul-lib-coverage: 3.2.2 transitivePeerDependencies: - supports-color @@ -19411,7 +19404,7 @@ snapshots: decimal.js: 10.5.0 html-encoding-sniffer: 4.0.0 http-proxy-agent: 7.0.2 - https-proxy-agent: 7.0.6(supports-color@10.2.0) + https-proxy-agent: 7.0.6 is-potential-custom-element-name: 1.0.1 nwsapi: 2.2.16 parse5: 7.3.0 @@ -22731,7 +22724,7 @@ snapshots: vite-node@3.2.4(@types/node@22.18.6)(sass@1.93.2)(terser@5.44.0)(tsx@4.20.6): dependencies: cac: 6.7.14 - debug: 4.4.1(supports-color@10.2.0) + debug: 4.4.1(supports-color@5.5.0) es-module-lexer: 1.7.0 pathe: 2.0.3 vite: 7.1.7(@types/node@22.18.6)(sass@1.93.2)(terser@5.44.0)(tsx@4.20.6) @@ -22787,7 +22780,7 @@ snapshots: '@vitest/spy': 3.2.4 '@vitest/utils': 3.2.4 chai: 5.2.0 - debug: 4.4.1(supports-color@10.2.0) + debug: 4.4.1(supports-color@5.5.0) expect-type: 1.2.1 magic-string: 0.30.19 pathe: 2.0.3 @@ -22875,7 +22868,7 @@ snapshots: vue-eslint-parser@10.2.0(eslint@9.36.0): dependencies: - debug: 4.4.1(supports-color@10.2.0) + debug: 4.4.1(supports-color@5.5.0) eslint: 9.36.0 eslint-scope: 8.4.0 eslint-visitor-keys: 4.2.1