diff --git a/LICENCE b/LICENCE index ab42830..92b012c 100644 --- a/LICENCE +++ b/LICENCE @@ -1,4 +1,4 @@ -Copyright (c) 2019-2024, flashwave +Copyright (c) 2019-2025, flashwave All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/README.md b/README.md index 941ccdf..6b18574 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ # Hanyuu -Hanyuu is the identity and authorisation server for Flashii. +Hanyuu *was* the identity and authorisation server for Flashii. +Its functionality has been absorbed by the main [Misuzu](https://patchii.net/flashii/misuzu) codebase. diff --git a/assets/oauth2.js/authorise.js b/assets/oauth2.js/authorise.js index ee47be0..9dba5b8 100644 --- a/assets/oauth2.js/authorise.js +++ b/assets/oauth2.js/authorise.js @@ -1,4 +1,5 @@ #include loading.jsx +#include sfx.js #include app/info.jsx #include app/scope.jsx #include header/header.js diff --git a/assets/oauth2.js/sfx.js b/assets/oauth2.js/sfx.js new file mode 100644 index 0000000..1e38a1f --- /dev/null +++ b/assets/oauth2.js/sfx.js @@ -0,0 +1,76 @@ +const HanyuuOAuth2Sfx = (() => { + const sfxPath = document.createElement('audio').canPlayType('audio/ogg;codecs=opus') !== '' + ? '/static/hanyuu.opus' + : '/static/hanyuu.caf'; + + const sfxList = { + 'signal-search': [0.549, 2.424], + 'menu-open': [2.606, 1.469], + 'menu-close': [4.076, 1.127], + 'menu-error': [5.203, .192], + 'type': [5.332, .125], + 'tiny-click': [5.457, .053], + 'invalid': [5.510, .232], + 'settings-menu': [5.742, .429], + 'settings-open': [6.171, .196], + 'settings-close': [6.367, .232], + 'option-up': [6.599, .097], + 'option-down': [6.696, .093], + }; + + const audioCtx = (() => { + const audioCtxObj = window.AudioContext || window.webkitAudioContext; + try { + return new audioCtxObj({ latencyHint: 'playback' }); + } catch(ex) { + return new audioCtxObj; + } + })(); + + let sndSpriteBuffer; + const playSound = async (name, loop) => { + if(audioCtx.state !== 'running') + await audioCtx.resume(); + + if(sndSpriteBuffer === undefined) + sndSpriteBuffer = await audioCtx.decodeAudioData( + (await $x.get(sfxPath, { type: 'arraybuffer' })).body() + ); + + const sfx = sfxList[name]; + if(!Array.isArray(sfx)) + throw 'sound does not exist'; + + const source = new AudioBufferSourceNode(audioCtx, { + buffer: sndSpriteBuffer, + }); + source.connect(audioCtx.destination); + + if(loop) { + source.loop = true; + source.loopStart = sfx[0]; + source.loopEnd = sfx[1]; + source.start(); + } else + source.start(0, sfx[0], sfx[1]); + + return source; + }; + + const playOnce = async name => { + // might want to add like random pitch or something later + await playSound(name); + }; + + const playLoop = async name => { + const source = await playSound(name, true); + const stop = () => { source.stop(); }; + + return { stop }; + }; + + return { + playOnce, + playLoop, + }; +})(); diff --git a/public/static/hanyuu.caf b/public/static/hanyuu.caf new file mode 100644 index 0000000..5e3f861 Binary files /dev/null and b/public/static/hanyuu.caf differ diff --git a/public/static/hanyuu.opus b/public/static/hanyuu.opus new file mode 100644 index 0000000..fc69061 Binary files /dev/null and b/public/static/hanyuu.opus differ diff --git a/src/OAuth2/OAuth2ErrorRoutes.php b/src/OAuth2/OAuth2ErrorRoutes.php deleted file mode 100644 index e69de29..0000000