summaryrefslogtreecommitdiff
path: root/packages/frontend/src/utility
diff options
context:
space:
mode:
authorsyuilo <4439005+syuilo@users.noreply.github.com>2025-03-20 19:00:09 +0900
committersyuilo <4439005+syuilo@users.noreply.github.com>2025-03-20 19:00:09 +0900
commit6015254e59ba0526efbfa139c89546458663ccbd (patch)
tree97adc609448eb3ce96730051193042c9eec470db /packages/frontend/src/utility
parentUpdate eslint.config.js (diff)
downloadsharkey-6015254e59ba0526efbfa139c89546458663ccbd.tar.gz
sharkey-6015254e59ba0526efbfa139c89546458663ccbd.tar.bz2
sharkey-6015254e59ba0526efbfa139c89546458663ccbd.zip
lint fixes
Diffstat (limited to 'packages/frontend/src/utility')
-rw-r--r--packages/frontend/src/utility/focus-trap.ts4
-rw-r--r--packages/frontend/src/utility/focus.ts4
-rw-r--r--packages/frontend/src/utility/fullscreen.ts4
-rw-r--r--packages/frontend/src/utility/hotkey.ts6
-rw-r--r--packages/frontend/src/utility/init-chart.ts2
-rw-r--r--packages/frontend/src/utility/physics.ts2
-rw-r--r--packages/frontend/src/utility/select-file.ts2
-rw-r--r--packages/frontend/src/utility/snowfall-effect.ts6
-rw-r--r--packages/frontend/src/utility/sound.ts4
-rw-r--r--packages/frontend/src/utility/sticky-sidebar.ts2
-rw-r--r--packages/frontend/src/utility/upload/isWebpSupported.ts2
11 files changed, 19 insertions, 19 deletions
diff --git a/packages/frontend/src/utility/focus-trap.ts b/packages/frontend/src/utility/focus-trap.ts
index fd17fa38a0..13d3bc56d2 100644
--- a/packages/frontend/src/utility/focus-trap.ts
+++ b/packages/frontend/src/utility/focus-trap.ts
@@ -50,7 +50,7 @@ function releaseFocusTrap(el: HTMLElement): void {
const highestZIndexElement = getHighestZIndexElement();
- if (el.parentElement != null && el !== document.body) {
+ if (el.parentElement != null && el !== window.document.body) {
el.parentElement.childNodes.forEach((siblingNode) => {
const siblingEl = getHTMLElementOrNull(siblingNode);
if (!siblingEl) return;
@@ -104,7 +104,7 @@ export function focusTrap(el: HTMLElement, hasInteractionWithOtherFocusTrappedEl
el.inert = false;
}
- if (el.parentElement != null && el !== document.body) {
+ if (el.parentElement != null && el !== window.document.body) {
el.parentElement.childNodes.forEach((siblingNode) => {
const siblingEl = getHTMLElementOrNull(siblingNode);
if (!siblingEl) return;
diff --git a/packages/frontend/src/utility/focus.ts b/packages/frontend/src/utility/focus.ts
index e3fd928d1d..cbbe8226d7 100644
--- a/packages/frontend/src/utility/focus.ts
+++ b/packages/frontend/src/utility/focus.ts
@@ -58,7 +58,7 @@ export const focusParent = (input: MaybeHTMLElement | null | undefined, self = f
const focusOrScroll = (element: HTMLElement, scroll: boolean) => {
if (scroll) {
- const scrollContainer = getScrollContainer(element) ?? document.documentElement;
+ const scrollContainer = getScrollContainer(element) ?? window.document.documentElement;
const scrollContainerTop = getScrollPosition(scrollContainer);
const stickyTop = getStickyTop(element, scrollContainer);
const stickyBottom = getStickyBottom(element, scrollContainer);
@@ -74,7 +74,7 @@ const focusOrScroll = (element: HTMLElement, scroll: boolean) => {
scrollContainer.scrollTo({ top: scrollTo, behavior: 'instant' });
}
- if (document.activeElement !== element) {
+ if (window.document.activeElement !== element) {
element.focus({ preventScroll: true });
}
};
diff --git a/packages/frontend/src/utility/fullscreen.ts b/packages/frontend/src/utility/fullscreen.ts
index 7a0a018ef3..6702393cf1 100644
--- a/packages/frontend/src/utility/fullscreen.ts
+++ b/packages/frontend/src/utility/fullscreen.ts
@@ -35,8 +35,8 @@ export const requestFullscreen = ({ videoEl, playerEl, options }: RequestFullscr
export const exitFullscreen = ({ videoEl }: ExitFullscreenProps) => {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
- if (document.exitFullscreen != null) {
- document.exitFullscreen();
+ if (window.document.exitFullscreen != null) {
+ window.document.exitFullscreen();
return;
}
if (videoEl.webkitExitFullscreen != null) {
diff --git a/packages/frontend/src/utility/hotkey.ts b/packages/frontend/src/utility/hotkey.ts
index fe62139a74..81fc28d7c8 100644
--- a/packages/frontend/src/utility/hotkey.ts
+++ b/packages/frontend/src/utility/hotkey.ts
@@ -54,9 +54,9 @@ export const makeHotkey = (keymap: Keymap) => {
const actions = parseKeymap(keymap);
return (ev: KeyboardEvent) => {
if ('pswp' in window && window.pswp != null) return;
- if (document.activeElement != null) {
- if (IGNORE_ELEMENTS.includes(document.activeElement.tagName.toLowerCase())) return;
- if (getHTMLElementOrNull(document.activeElement)?.isContentEditable) return;
+ if (window.document.activeElement != null) {
+ if (IGNORE_ELEMENTS.includes(window.document.activeElement.tagName.toLowerCase())) return;
+ if (getHTMLElementOrNull(window.document.activeElement)?.isContentEditable) return;
}
for (const action of actions) {
if (matchPatterns(ev, action)) {
diff --git a/packages/frontend/src/utility/init-chart.ts b/packages/frontend/src/utility/init-chart.ts
index 9775b9fec4..260899c1d7 100644
--- a/packages/frontend/src/utility/init-chart.ts
+++ b/packages/frontend/src/utility/init-chart.ts
@@ -50,7 +50,7 @@ export function initChart() {
);
// フォントカラー
- Chart.defaults.color = getComputedStyle(document.documentElement).getPropertyValue('--MI_THEME-fg');
+ Chart.defaults.color = getComputedStyle(window.document.documentElement).getPropertyValue('--MI_THEME-fg');
Chart.defaults.borderColor = store.s.darkMode ? 'rgba(255, 255, 255, 0.1)' : 'rgba(0, 0, 0, 0.1)';
diff --git a/packages/frontend/src/utility/physics.ts b/packages/frontend/src/utility/physics.ts
index 8a4e9319b3..5de34fd094 100644
--- a/packages/frontend/src/utility/physics.ts
+++ b/packages/frontend/src/utility/physics.ts
@@ -28,7 +28,7 @@ export function physics(container: HTMLElement) {
// create renderer
const render = Matter.Render.create({
engine: engine,
- //element: document.getElementById('debug'),
+ //element: window.document.getElementById('debug'),
options: {
width: containerWidth,
height: containerHeight,
diff --git a/packages/frontend/src/utility/select-file.ts b/packages/frontend/src/utility/select-file.ts
index 1bee4986f6..b9b3687483 100644
--- a/packages/frontend/src/utility/select-file.ts
+++ b/packages/frontend/src/utility/select-file.ts
@@ -25,7 +25,7 @@ export function chooseFileFromPc(
const nameConverter = options?.nameConverter ?? (() => undefined);
return new Promise((res, rej) => {
- const input = document.createElement('input');
+ const input = window.document.createElement('input');
input.type = 'file';
input.multiple = multiple;
input.onchange = () => {
diff --git a/packages/frontend/src/utility/snowfall-effect.ts b/packages/frontend/src/utility/snowfall-effect.ts
index d88bdb6660..5c86969876 100644
--- a/packages/frontend/src/utility/snowfall-effect.ts
+++ b/packages/frontend/src/utility/snowfall-effect.ts
@@ -156,7 +156,7 @@ export class SnowfallEffect {
easing: 0.0005,
};
/**
- * @throws {Error} - Thrown when it fails to get WebGL context for the canvas
+ * @throws {Error} - Thrown when it fails to get WebGL context for the canvas
*/
constructor(options: {
sakura?: boolean;
@@ -172,7 +172,7 @@ export class SnowfallEffect {
const gl = canvas.getContext('webgl2', { antialias: true });
if (gl == null) throw new Error('Failed to get WebGL context');
- document.body.append(canvas);
+ window.document.body.append(canvas);
this.canvas = canvas;
this.gl = gl;
@@ -190,7 +190,7 @@ export class SnowfallEffect {
}
private initCanvas(): HTMLCanvasElement {
- const canvas = document.createElement('canvas');
+ const canvas = window.document.createElement('canvas');
Object.assign(canvas.style, {
position: 'fixed',
diff --git a/packages/frontend/src/utility/sound.ts b/packages/frontend/src/utility/sound.ts
index 120f480b63..796af0e5ca 100644
--- a/packages/frontend/src/utility/sound.ts
+++ b/packages/frontend/src/utility/sound.ts
@@ -226,7 +226,7 @@ export function createSourceNode(buffer: AudioBuffer, opts: {
* @param file ファイルのURL(ドライブIDではない)
*/
export async function getSoundDuration(file: string): Promise<number> {
- const audioEl = document.createElement('audio');
+ const audioEl = window.document.createElement('audio');
audioEl.src = file;
return new Promise((resolve) => {
const si = setInterval(() => {
@@ -249,7 +249,7 @@ export function isMute(): boolean {
}
// noinspection RedundantIfStatementJS
- if (prefer.s['sound.useSoundOnlyWhenActive'] && document.visibilityState === 'hidden') {
+ if (prefer.s['sound.useSoundOnlyWhenActive'] && window.document.visibilityState === 'hidden') {
// ブラウザがアクティブな時のみサウンドを出力する
return true;
}
diff --git a/packages/frontend/src/utility/sticky-sidebar.ts b/packages/frontend/src/utility/sticky-sidebar.ts
index 50f1e6ecc8..867c9b8324 100644
--- a/packages/frontend/src/utility/sticky-sidebar.ts
+++ b/packages/frontend/src/utility/sticky-sidebar.ts
@@ -18,7 +18,7 @@ export class StickySidebar {
this.container = container;
this.el = this.container.children[0] as HTMLElement;
this.el.style.position = 'sticky';
- this.spacer = document.createElement('div');
+ this.spacer = window.document.createElement('div');
this.container.prepend(this.spacer);
this.marginTop = marginTop;
this.offsetTop = this.container.getBoundingClientRect().top;
diff --git a/packages/frontend/src/utility/upload/isWebpSupported.ts b/packages/frontend/src/utility/upload/isWebpSupported.ts
index 2511236ecc..affd81fd57 100644
--- a/packages/frontend/src/utility/upload/isWebpSupported.ts
+++ b/packages/frontend/src/utility/upload/isWebpSupported.ts
@@ -6,7 +6,7 @@
let isWebpSupportedCache: boolean | undefined;
export function isWebpSupported() {
if (isWebpSupportedCache === undefined) {
- const canvas = document.createElement('canvas');
+ const canvas = window.document.createElement('canvas');
canvas.width = 1;
canvas.height = 1;
isWebpSupportedCache = canvas.toDataURL('image/webp').startsWith('data:image/webp');