diff --git a/.gitignore b/.gitignore index 4780c76fe..ddfa0195c 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,9 @@ # nano .swp +# vimlocal +.vimlocal + # Node.js node_modules report.*.json diff --git a/packages/client/src/components/media-list.vue b/packages/client/src/components/media-list.vue index f89ab262d..247f39817 100644 --- a/packages/client/src/components/media-list.vue +++ b/packages/client/src/components/media-list.vue @@ -6,7 +6,7 @@ - + @@ -125,14 +125,14 @@ onMounted(() => { const previewable = (file: foundkey.entities.DriveFile): boolean => { if (file.type === 'image/svg+xml') return true; // svgのwebpublic/thumbnailはpngなのでtrue // FILE_TYPE_BROWSERSAFEに適合しないものはブラウザで表示するのに不適切 - if (isModule(file)) return true; + if (isModule(file)) return true; return (file.type.startsWith('video') || file.type.startsWith('image')) && FILE_TYPE_BROWSERSAFE.includes(file.type); }; const isModule = (file: foundkey.entities.DriveFile): boolean => { - return FILE_EXT_TRACKER_MODULES.filter((ext) => { - return file.name.toLowerCase().endsWith("." + ext); - }).length > 0; + return FILE_EXT_TRACKER_MODULES.filter((ext) => { + return file.name.toLowerCase().endsWith("." + ext); + }).length > 0; }; diff --git a/packages/client/src/components/mod-player.vue b/packages/client/src/components/mod-player.vue index 290cb2a05..861bb38fb 100644 --- a/packages/client/src/components/mod-player.vue +++ b/packages/client/src/components/mod-player.vue @@ -1,30 +1,30 @@ - - {{ $ts.sensitive }} - {{ $ts.clickToShow }} - + + {{ $ts.sensitive }} + {{ $ts.clickToShow }} + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + @@ -35,7 +35,7 @@ import { defaultStore } from '@/store'; import { ChiptuneJsPlayer, ChiptuneJsConfig } from '@/scripts/chiptune2'; const props = defineProps<{ - module: foundkey.entities.DriveFile + module: foundkey.entities.DriveFile }>(); let hide = ref((defaultStore.state.nsfw === 'force') ? true : props.module.isSensitive && (defaultStore.state.nsfw !== 'ignore')); @@ -47,269 +47,269 @@ const player = ref(new ChiptuneJsPlayer(new ChiptuneJsConfig(1))); const rowBuffer = 24; let buffer = null; player.value.load(props.module.url).then((result) => { - buffer = result; - try { - player.value.play(buffer); - display(); + buffer = result; + try { + player.value.play(buffer); + display(); } catch (e) { - console.warn(e); + console.warn(e); } - player.value.stop(); + player.value.stop(); }).catch((error) => { - console.error(error); + console.error(error); }); function playPause() { - player.value.addHandler('onRowChange', () => { - progress.value.max = player.value.duration(); - progress.value.value = player.value.position() % player.value.duration(); - display(); + player.value.addHandler('onRowChange', () => { + progress.value.max = player.value.duration(); + progress.value.value = player.value.position() % player.value.duration(); + display(); }); - if (player.value.currentPlayingNode === null) { - player.value.play(buffer); - playing.value = true; - } else { - player.value.togglePause(); - playing.value = !player.value.currentPlayingNode.paused; - } + if (player.value.currentPlayingNode === null) { + player.value.play(buffer); + playing.value = true; + } else { + player.value.togglePause(); + playing.value = !player.value.currentPlayingNode.paused; + } } function stop() { - player.value.stop(); - playing.value = false; - try { - player.value.play(buffer); - display(); - } catch (e) { - console.warn(e); - } - player.value.stop(); - progress.value.value = 0; - player.value.handlers = []; + player.value.stop(); + playing.value = false; + try { + player.value.play(buffer); + display(); + } catch (e) { + console.warn(e); + } + player.value.stop(); + progress.value.value = 0; + player.value.handlers = []; } function display() { - if (!displayCanvas.value) { - stop(); - return; - } + if (!displayCanvas.value) { + stop(); + return; + } - const canvas = displayCanvas.value; + const canvas = displayCanvas.value; - const pattern = player.value.getPattern(); - const row = player.value.getRow(); - let nbChannels = 0; - if (player.value.currentPlayingNode) { - nbChannels = player.value.currentPlayingNode.nbChannels; - } - if (canvas.width !== 12 + 84 * nbChannels + 2) { - canvas.width = 12 + 84 * nbChannels + 2; - canvas.height = 12 * rowBuffer; - } - const nbRows = player.value.getPatternNumRows(pattern); - const ctx = canvas.getContext('2d'); - ctx.font = '10px monospace'; - ctx.fillStyle = 'black'; - ctx.fillRect(0, 0, canvas.width, canvas.height); - ctx.fillStyle = 'gray'; - for (let rowOffset = 0; rowOffset < rowBuffer; rowOffset++) { - const rowToDraw = row - rowBuffer / 2 + rowOffset; - if (rowToDraw >= 0 && rowToDraw < nbRows) { - let rowText = parseInt(rowToDraw).toString(16); - if (rowText.length === 1) { - rowText = '0' + rowText; - } - ctx.fillStyle = 'gray'; - if (rowToDraw % 4 === 0) { - ctx.fillStyle = 'yellow'; - } - if (rowToDraw === row) { - ctx.fillStyle = 'white'; - } - ctx.fillText(rowText, 0, 10 + rowOffset * 12); - ctx.fillStyle = 'gray'; - if (rowToDraw === row) { - ctx.fillStyle = 'white'; - } - for (let channel = 0; channel < nbChannels; channel++) { - const part = player.value.getPatternRowChannel(pattern, rowToDraw, channel); - ctx.fillText("|" + part, 12 + 84 * channel, 10 + rowOffset * 12); - } - } - } + const pattern = player.value.getPattern(); + const row = player.value.getRow(); + let nbChannels = 0; + if (player.value.currentPlayingNode) { + nbChannels = player.value.currentPlayingNode.nbChannels; + } + if (canvas.width !== 12 + 84 * nbChannels + 2) { + canvas.width = 12 + 84 * nbChannels + 2; + canvas.height = 12 * rowBuffer; + } + const nbRows = player.value.getPatternNumRows(pattern); + const ctx = canvas.getContext('2d'); + ctx.font = '10px monospace'; + ctx.fillStyle = 'black'; + ctx.fillRect(0, 0, canvas.width, canvas.height); + ctx.fillStyle = 'gray'; + for (let rowOffset = 0; rowOffset < rowBuffer; rowOffset++) { + const rowToDraw = row - rowBuffer / 2 + rowOffset; + if (rowToDraw >= 0 && rowToDraw < nbRows) { + let rowText = parseInt(rowToDraw).toString(16); + if (rowText.length === 1) { + rowText = '0' + rowText; + } + ctx.fillStyle = 'gray'; + if (rowToDraw % 4 === 0) { + ctx.fillStyle = 'yellow'; + } + if (rowToDraw === row) { + ctx.fillStyle = 'white'; + } + ctx.fillText(rowText, 0, 10 + rowOffset * 12); + ctx.fillStyle = 'gray'; + if (rowToDraw === row) { + ctx.fillStyle = 'white'; + } + for (let channel = 0; channel < nbChannels; channel++) { + const part = player.value.getPatternRowChannel(pattern, rowToDraw, channel); + ctx.fillText("|" + part, 12 + 84 * channel, 10 + rowOffset * 12); + } + } + } } diff --git a/packages/client/src/const.ts b/packages/client/src/const.ts index 6db6faf20..16744c64b 100644 --- a/packages/client/src/const.ts +++ b/packages/client/src/const.ts @@ -48,41 +48,41 @@ export const FILE_TYPE_BROWSERSAFE = [ ]; export const FILE_EXT_TRACKER_MODULES = [ - 'mod', - 's3m', - 'xm', - 'it', - 'mptm', - 'stm', - 'nst', - 'm15', - 'stk', - 'wow', - 'ult', - '669', - 'mtm', - 'med', - 'far', - 'mdl', - 'ams', - 'dsm', - 'amf', - 'okt', - 'dmf', - 'ptm', - 'psm', - 'mt2', - 'dbm', - 'digi', - 'imf', - 'j2b', - 'gdm', - 'umx', - 'plm', - 'mo3', - 'xpk', - 'ppm', - 'mmcmp' + 'mod', + 's3m', + 'xm', + 'it', + 'mptm', + 'stm', + 'nst', + 'm15', + 'stk', + 'wow', + 'ult', + '669', + 'mtm', + 'med', + 'far', + 'mdl', + 'ams', + 'dsm', + 'amf', + 'okt', + 'dmf', + 'ptm', + 'psm', + 'mt2', + 'dbm', + 'digi', + 'imf', + 'j2b', + 'gdm', + 'umx', + 'plm', + 'mo3', + 'xpk', + 'ppm', + 'mmcmp' ]; /* https://github.com/sindresorhus/file-type/blob/main/supported.js diff --git a/packages/client/src/scripts/chiptune2.ts b/packages/client/src/scripts/chiptune2.ts index 97701c664..5e9a88de0 100644 --- a/packages/client/src/scripts/chiptune2.ts +++ b/packages/client/src/scripts/chiptune2.ts @@ -109,7 +109,7 @@ ChiptuneJsPlayer.prototype.load = function (input) { }; ChiptuneJsPlayer.prototype.play = function (buffer: ArrayBuffer) { - this.unlock(); + this.unlock(); this.stop(); const processNode = this.createLibopenmptNode(buffer, this.buffer); if (processNode === null) {