Updated NPM packages + cleaned up context object usage.

This commit is contained in:
flash 2024-02-10 17:23:47 +00:00
parent 7d23bea36c
commit 85a9fd2422
18 changed files with 250 additions and 267 deletions

130
package-lock.json generated
View file

@ -5,11 +5,11 @@
"packages": { "packages": {
"": { "": {
"dependencies": { "dependencies": {
"@swc/core": "^1.3.104", "@swc/core": "^1.4.0",
"autoprefixer": "^10.4.17", "autoprefixer": "^10.4.17",
"cssnano": "^6.0.3", "cssnano": "^6.0.3",
"html-minifier-terser": "^7.2.0", "html-minifier-terser": "^7.2.0",
"postcss": "^8.4.33" "postcss": "^8.4.35"
} }
}, },
"node_modules/@jridgewell/gen-mapping": { "node_modules/@jridgewell/gen-mapping": {
@ -65,9 +65,9 @@
} }
}, },
"node_modules/@swc/core": { "node_modules/@swc/core": {
"version": "1.3.105", "version": "1.4.0",
"resolved": "https://registry.npmjs.org/@swc/core/-/core-1.3.105.tgz", "resolved": "https://registry.npmjs.org/@swc/core/-/core-1.4.0.tgz",
"integrity": "sha512-me2VZyr3OjqRpFrYQJJYy7x/zbFSl9nt+MAGnIcBtjDsN00iTVqEaKxBjPBFQV9BDAgPz2SRWes/DhhVm5SmMw==", "integrity": "sha512-wc5DMI5BJftnK0Fyx9SNJKkA0+BZSJQx8430yutWmsILkHMBD3Yd9GhlMaxasab9RhgKqZp7Ht30hUYO5ZDvQg==",
"hasInstallScript": true, "hasInstallScript": true,
"dependencies": { "dependencies": {
"@swc/counter": "^0.1.1", "@swc/counter": "^0.1.1",
@ -81,16 +81,16 @@
"url": "https://opencollective.com/swc" "url": "https://opencollective.com/swc"
}, },
"optionalDependencies": { "optionalDependencies": {
"@swc/core-darwin-arm64": "1.3.105", "@swc/core-darwin-arm64": "1.4.0",
"@swc/core-darwin-x64": "1.3.105", "@swc/core-darwin-x64": "1.4.0",
"@swc/core-linux-arm-gnueabihf": "1.3.105", "@swc/core-linux-arm-gnueabihf": "1.4.0",
"@swc/core-linux-arm64-gnu": "1.3.105", "@swc/core-linux-arm64-gnu": "1.4.0",
"@swc/core-linux-arm64-musl": "1.3.105", "@swc/core-linux-arm64-musl": "1.4.0",
"@swc/core-linux-x64-gnu": "1.3.105", "@swc/core-linux-x64-gnu": "1.4.0",
"@swc/core-linux-x64-musl": "1.3.105", "@swc/core-linux-x64-musl": "1.4.0",
"@swc/core-win32-arm64-msvc": "1.3.105", "@swc/core-win32-arm64-msvc": "1.4.0",
"@swc/core-win32-ia32-msvc": "1.3.105", "@swc/core-win32-ia32-msvc": "1.4.0",
"@swc/core-win32-x64-msvc": "1.3.105" "@swc/core-win32-x64-msvc": "1.4.0"
}, },
"peerDependencies": { "peerDependencies": {
"@swc/helpers": "^0.5.0" "@swc/helpers": "^0.5.0"
@ -102,9 +102,9 @@
} }
}, },
"node_modules/@swc/core-darwin-arm64": { "node_modules/@swc/core-darwin-arm64": {
"version": "1.3.105", "version": "1.4.0",
"resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.3.105.tgz", "resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.4.0.tgz",
"integrity": "sha512-buWeweLVDXXmcnfIemH4PGnpjwsDTUGitnPchdftb0u1FU8zSSP/lw/pUCBDG/XvWAp7c/aFxgN4CyG0j7eayA==", "integrity": "sha512-UTJ/Vz+s7Pagef6HmufWt6Rs0aUu+EJF4Pzuwvr7JQQ5b1DZeAAUeUtkUTFx/PvCbM8Xfw4XdKBUZfrIKCfW8A==",
"cpu": [ "cpu": [
"arm64" "arm64"
], ],
@ -117,9 +117,9 @@
} }
}, },
"node_modules/@swc/core-darwin-x64": { "node_modules/@swc/core-darwin-x64": {
"version": "1.3.105", "version": "1.4.0",
"resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.3.105.tgz", "resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.4.0.tgz",
"integrity": "sha512-hFmXPApqjA/8sy/9NpljHVaKi1OvL9QkJ2MbbTCCbJERuHMpMUeMBUWipHRfepGHFhU+9B9zkEup/qJaJR4XIg==", "integrity": "sha512-f8v58u2GsGak8EtZFN9guXqE0Ep10Suny6xriaW2d8FGqESPyNrnBzli3aqkSeQk5gGqu2zJ7WiiKp3XoUOidA==",
"cpu": [ "cpu": [
"x64" "x64"
], ],
@ -132,9 +132,9 @@
} }
}, },
"node_modules/@swc/core-linux-arm-gnueabihf": { "node_modules/@swc/core-linux-arm-gnueabihf": {
"version": "1.3.105", "version": "1.4.0",
"resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.3.105.tgz", "resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.4.0.tgz",
"integrity": "sha512-mwXyMC41oMKkKrPpL8uJpOxw7fyfQoVtIw3Y5p0Blabk+espNYqix0E8VymHdRKuLmM//z5wVmMsuHdGBHvZeg==", "integrity": "sha512-q2KAkBzmPcTnRij/Y1fgHCKAGevUX/H4uUESrw1J5gmUg9Qip6onKV80lTumA1/aooGJ18LOsB31qdbwmZk9OA==",
"cpu": [ "cpu": [
"arm" "arm"
], ],
@ -147,9 +147,9 @@
} }
}, },
"node_modules/@swc/core-linux-arm64-gnu": { "node_modules/@swc/core-linux-arm64-gnu": {
"version": "1.3.105", "version": "1.4.0",
"resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.3.105.tgz", "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.4.0.tgz",
"integrity": "sha512-H7yEIVydnUtqBSUxwmO6vpIQn7j+Rr0DF6ZOORPyd/SFzQJK9cJRtmJQ3ZMzlJ1Bb+1gr3MvjgLEnmyCYEm2Hg==", "integrity": "sha512-SknGu96W0mzHtLHWm+62fk5+Omp9fMPFO7AWyGFmz2tr8EgRRXtTSrBUnWhAbgcalnhen48GsvtMdxf1KNputg==",
"cpu": [ "cpu": [
"arm64" "arm64"
], ],
@ -162,9 +162,9 @@
} }
}, },
"node_modules/@swc/core-linux-arm64-musl": { "node_modules/@swc/core-linux-arm64-musl": {
"version": "1.3.105", "version": "1.4.0",
"resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.3.105.tgz", "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.4.0.tgz",
"integrity": "sha512-Jg7RTFT3pGFdGt5elPV6oDkinRy7q9cXpenjXnJnM2uvx3jOwnsAhexPyCDHom8SHL0j+9kaLLC66T3Gz1E4UA==", "integrity": "sha512-/k3TDvpBRMDNskHooNN1KqwUhcwkfBlIYxRTnJvsfT2C7My4pffR+4KXmt0IKynlTTbCdlU/4jgX4801FSuliw==",
"cpu": [ "cpu": [
"arm64" "arm64"
], ],
@ -177,9 +177,9 @@
} }
}, },
"node_modules/@swc/core-linux-x64-gnu": { "node_modules/@swc/core-linux-x64-gnu": {
"version": "1.3.105", "version": "1.4.0",
"resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.3.105.tgz", "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.4.0.tgz",
"integrity": "sha512-DJghplpyusAmp1X5pW/y93MmS/u83Sx5GrpJxI6KLPa82+NItTgMcl8KBQmW5GYAJpVKZyaIvBanS5TdR8aN2w==", "integrity": "sha512-GYsTMvNt5+WTVlwwQzOOWsPMw6P/F41u5PGHWmfev8Nd4QJ1h3rWPySKk4mV42IJwH9MgQCVSl3ygwNqwl6kFg==",
"cpu": [ "cpu": [
"x64" "x64"
], ],
@ -192,9 +192,9 @@
} }
}, },
"node_modules/@swc/core-linux-x64-musl": { "node_modules/@swc/core-linux-x64-musl": {
"version": "1.3.105", "version": "1.4.0",
"resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.3.105.tgz", "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.4.0.tgz",
"integrity": "sha512-wD5jL2dZH/5nPNssBo6jhOvkI0lmWnVR4vnOXWjuXgjq1S0AJpO5jdre/6pYLmf26hft3M42bteDnjR4AAZ38w==", "integrity": "sha512-jGVPdM/VwF7kK/uYRW5N6FwzKf/FnDjGIR3RPvQokjYJy7Auk+3Oj21C0Jev7sIT9RYnO/TrFEoEozKeD/z2Qw==",
"cpu": [ "cpu": [
"x64" "x64"
], ],
@ -207,9 +207,9 @@
} }
}, },
"node_modules/@swc/core-win32-arm64-msvc": { "node_modules/@swc/core-win32-arm64-msvc": {
"version": "1.3.105", "version": "1.4.0",
"resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.3.105.tgz", "resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.4.0.tgz",
"integrity": "sha512-UqJtwILUHRw2+3UTPnRkZrzM/bGdQtbR4UFdp79mZQYfryeOUVNg7aJj/bWUTkKtLiZ3o+FBNrM/x2X1mJX5bA==", "integrity": "sha512-biHYm1AronEKlt47O/H8sSOBM2BKXMmWT+ApvlxUw50m1RGNnVnE0bgY7tylFuuSiWyXsQPJbmUV708JqORXVg==",
"cpu": [ "cpu": [
"arm64" "arm64"
], ],
@ -222,9 +222,9 @@
} }
}, },
"node_modules/@swc/core-win32-ia32-msvc": { "node_modules/@swc/core-win32-ia32-msvc": {
"version": "1.3.105", "version": "1.4.0",
"resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.3.105.tgz", "resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.4.0.tgz",
"integrity": "sha512-Z95C6vZgBEJ1snidYyjVKnVWiy/ZpPiIFIXGWkDr4ZyBgL3eZX12M6LzZ+NApHKffrbO4enbFyFomueBQgS2oA==", "integrity": "sha512-TL5L2tFQb19kJwv6+elToGBj74QXCn9j+hZfwQatvZEJRA5rDK16eH6oAE751dGUArhnWlW3Vj65hViPvTuycw==",
"cpu": [ "cpu": [
"ia32" "ia32"
], ],
@ -237,9 +237,9 @@
} }
}, },
"node_modules/@swc/core-win32-x64-msvc": { "node_modules/@swc/core-win32-x64-msvc": {
"version": "1.3.105", "version": "1.4.0",
"resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.3.105.tgz", "resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.4.0.tgz",
"integrity": "sha512-3J8fkyDPFsS3mszuYUY4Wfk7/B2oio9qXUwF3DzOs2MK+XgdyMLIptIxL7gdfitXJBH8k39uVjrIw1JGJDjyFA==", "integrity": "sha512-e2xVezU7XZ2Stzn4i7TOQe2Kn84oYdG0M3A7XI7oTdcpsKCcKwgiMoroiAhqCv+iN20KNqhnWwJiUiTj/qN5AA==",
"cpu": [ "cpu": [
"x64" "x64"
], ],
@ -252,9 +252,9 @@
} }
}, },
"node_modules/@swc/counter": { "node_modules/@swc/counter": {
"version": "0.1.2", "version": "0.1.3",
"resolved": "https://registry.npmjs.org/@swc/counter/-/counter-0.1.2.tgz", "resolved": "https://registry.npmjs.org/@swc/counter/-/counter-0.1.3.tgz",
"integrity": "sha512-9F4ys4C74eSTEUNndnER3VJ15oru2NumfQxS8geE+f3eB5xvfxpWyqE5XlVnxb/R14uoXi6SLbBwwiDSkv+XEw==" "integrity": "sha512-e2BR4lsJkkRlKZ/qCHPw9ZaSxc0MVUd7gtbtaB7aMvHeJVYe8sOB8DBZkP2DtISHGSku9sCK6T6cnY0CtXrOCQ=="
}, },
"node_modules/@swc/types": { "node_modules/@swc/types": {
"version": "0.1.5", "version": "0.1.5",
@ -322,9 +322,9 @@
"integrity": "sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==" "integrity": "sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww=="
}, },
"node_modules/browserslist": { "node_modules/browserslist": {
"version": "4.22.2", "version": "4.22.3",
"resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.22.2.tgz", "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.22.3.tgz",
"integrity": "sha512-0UgcrvQmBDvZHFGdYUehrCNIazki7/lUP3kkoi/r3YB2amZbFM9J43ZRkJTXBUZK4gmx56+Sqk9+Vs9mwZx9+A==", "integrity": "sha512-UAp55yfwNv0klWNapjs/ktHoguxuQNGnOzxYmfnXIS+8AsRDZkSDxg7R1AX3GKzn078SBI5dzwzj/Yx0Or0e3A==",
"funding": [ "funding": [
{ {
"type": "opencollective", "type": "opencollective",
@ -340,8 +340,8 @@
} }
], ],
"dependencies": { "dependencies": {
"caniuse-lite": "^1.0.30001565", "caniuse-lite": "^1.0.30001580",
"electron-to-chromium": "^1.4.601", "electron-to-chromium": "^1.4.648",
"node-releases": "^2.0.14", "node-releases": "^2.0.14",
"update-browserslist-db": "^1.0.13" "update-browserslist-db": "^1.0.13"
}, },
@ -378,9 +378,9 @@
} }
}, },
"node_modules/caniuse-lite": { "node_modules/caniuse-lite": {
"version": "1.0.30001579", "version": "1.0.30001585",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001579.tgz", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001585.tgz",
"integrity": "sha512-u5AUVkixruKHJjw/pj9wISlcMpgFWzSrczLZbrqBSxukQixmg0SJ5sZTpvaFvxU0HoQKd4yoyAogyrAz9pzJnA==", "integrity": "sha512-yr2BWR1yLXQ8fMpdS/4ZZXpseBgE7o4g41x3a6AJOqZuOi+iE/WdJYAuZ6Y95i4Ohd2Y+9MzIWRR+uGABH4s3Q==",
"funding": [ "funding": [
{ {
"type": "opencollective", "type": "opencollective",
@ -643,9 +643,9 @@
} }
}, },
"node_modules/electron-to-chromium": { "node_modules/electron-to-chromium": {
"version": "1.4.643", "version": "1.4.665",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.643.tgz", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.665.tgz",
"integrity": "sha512-QHscvvS7gt155PtoRC0dR2ilhL8E9LHhfTQEq1uD5AL0524rBLAwpAREFH06f87/e45B9XkR6Ki5dbhbCsVEIg==" "integrity": "sha512-UpyCWObBoD+nSZgOC2ToaIdZB0r9GhqT2WahPKiSki6ckkSuKhQNso8V2PrFcHBMleI/eqbKgVQgVC4Wni4ilw=="
}, },
"node_modules/entities": { "node_modules/entities": {
"version": "4.5.0", "version": "4.5.0",
@ -659,9 +659,9 @@
} }
}, },
"node_modules/escalade": { "node_modules/escalade": {
"version": "3.1.1", "version": "3.1.2",
"resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.2.tgz",
"integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", "integrity": "sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA==",
"engines": { "engines": {
"node": ">=6" "node": ">=6"
} }
@ -803,9 +803,9 @@
"integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==" "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ=="
}, },
"node_modules/postcss": { "node_modules/postcss": {
"version": "8.4.33", "version": "8.4.35",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.33.tgz", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.35.tgz",
"integrity": "sha512-Kkpbhhdjw2qQs2O2DGX+8m5OVqEcbB9HRBvuYM9pgrjEFUg30A9LmXNlTAUj4S9kgtGyrMbTzVjH7E+s5Re2yg==", "integrity": "sha512-u5U8qYpBCpN13BsiEB0CbR1Hhh4Gc0zLFuedrHJKMctHCHAGrMdG0PRM/KErzAL3CU6/eckEtmHNB3x6e3c0vA==",
"funding": [ "funding": [
{ {
"type": "opencollective", "type": "opencollective",

View file

@ -1,9 +1,9 @@
{ {
"dependencies": { "dependencies": {
"@swc/core": "^1.3.104", "@swc/core": "^1.4.0",
"autoprefixer": "^10.4.17", "autoprefixer": "^10.4.17",
"cssnano": "^6.0.3", "cssnano": "^6.0.3",
"html-minifier-terser": "^7.2.0", "html-minifier-terser": "^7.2.0",
"postcss": "^8.4.33" "postcss": "^8.4.35"
} }
} }

View file

@ -1,51 +1,15 @@
#include common.js const MamiContext = function(props) {
#include mszauth.js
#include txtrigs.js
#include audio/context.js
#include controls/views.js
#include sound/sndmgr.js
#include sound/sndlibrary.js
#include sound/sndpacks.js
const MamiContext = function(targetBody) {
const pub = {}; const pub = {};
let settings; for(const name in props) {
pub.setSettings = inst => settings = inst; if(!props.hasOwnProperty(name))
pub.getSettings = () => settings; continue;
const viewsCtx = new MamiViewsControl({ body: targetBody }); const value = props[name];
pub.getViews = () => viewsCtx; const descriptor = { enumerable: true };
descriptor[typeof value === 'function' ? 'get' : 'value'] = value;
Object.defineProperty(pub, name, descriptor);
}
const audioCtx = new MamiAudioContext; return Object.freeze(pub);
pub.getAudio = () => audioCtx;
const soundMgr = new MamiSoundManager(audioCtx);
const soundLib = new MamiSoundLibrary(soundMgr);
const soundPck = new MamiSoundPacks;
const sndPckPlay = new MamiSoundPackPlayer(soundLib);
pub.getSound = () => soundMgr;
pub.getSoundLibrary = () => soundLib;
pub.getSoundPacks = () => soundPck;
pub.getSoundPackPlayer = () => sndPckPlay;
const txtTriggers = new MamiTextTriggers;
pub.getTextTriggers = () => txtTriggers;
let eeprom;
pub.hasEEPROM = () => eeprom !== undefined;
pub.getEEPROM = () => eeprom;
pub.createEEPROM = () => {
if(eeprom !== undefined)
return;
eeprom = new EEPROM(
'1',
futami.get('eeprom2'),
MamiMisuzuAuth.getLine
);
};
return pub;
}; };

View file

@ -1,4 +1,4 @@
const Umi = { UI: {} }; window.Umi = { UI: {}, Protocol: { SockChat: { Protocol: {} } } };
#include animate.js #include animate.js
#include common.js #include common.js
@ -7,13 +7,16 @@ const Umi = { UI: {} };
#include messages.js #include messages.js
#include mszauth.js #include mszauth.js
#include server.js #include server.js
#include txtrigs.js
#include utility.js #include utility.js
#include weeb.js #include weeb.js
#include audio/autoplay.js #include audio/autoplay.js
#include audio/context.js #include audio/context.js
#include controls/views.js
#include eeprom/eeprom.js #include eeprom/eeprom.js
#include settings/backup.js #include settings/backup.js
#include settings/settings.js #include settings/settings.js
#include sound/context.js
#include sound/osukeys.js #include sound/osukeys.js
#include sound/umisound.js #include sound/umisound.js
#include ui/chat-layout.js #include ui/chat-layout.js
@ -29,33 +32,23 @@ const Umi = { UI: {} };
#include ui/uploads.js #include ui/uploads.js
(async () => { (async () => {
const ctx = new MamiContext(document.body), const views = new MamiViewsControl({ body: document.body });
views = ctx.getViews(); const loadingOverlay = new Umi.UI.LoadingOverlay('spinner', 'Loading...');
await views.push(loadingOverlay);
Object.defineProperty(window, 'mami', { loadingOverlay.setMessage('Loading environment...');
value: ctx,
writable: false,
});
const sndLib = ctx.getSoundLibrary(),
sndPacks = ctx.getSoundPacks();
const lo = new Umi.UI.LoadingOverlay('spinner', 'Loading...');
await views.push(lo);
lo.setMessage('Loading environment...');
try { try {
window.futami = await FutamiCommon.load(); window.futami = await FutamiCommon.load();
} catch(ex) { } catch(ex) {
console.error(ex); console.error(ex);
lo.setIcon('cross'); loadingOverlay.setIcon('cross');
lo.setHeader('Failed!'); loadingOverlay.setHeader('Failed!');
lo.setMessage('Failed to load common settings!'); loadingOverlay.setMessage('Failed to load common settings!');
return; return;
} }
lo.setMessage('Fetching credentials...'); loadingOverlay.setMessage('Fetching credentials...');
try { try {
const auth = await MamiMisuzuAuth.update(); const auth = await MamiMisuzuAuth.update();
if(!auth.ok) if(!auth.ok)
@ -75,10 +68,9 @@ const Umi = { UI: {} };
}, 600000); }, 600000);
lo.setMessage('Loading settings...'); loadingOverlay.setMessage('Loading settings...');
const settings = new MamiSettings('umi-'); const settings = new MamiSettings('umi-');
ctx.setSettings(settings);
settings.define('style', 'string', 'dark'); settings.define('style', 'string', 'dark');
settings.define('compactView', 'boolean', false); settings.define('compactView', 'boolean', false);
@ -132,13 +124,15 @@ const Umi = { UI: {} };
settings.define('notificationTriggers', 'string', '', noNotifSupport); settings.define('notificationTriggers', 'string', '', noNotifSupport);
lo.setMessage('Loading sounds...'); loadingOverlay.setMessage('Loading sounds...');
const soundCtx = new MamiSoundContext;
try { try {
const sounds = await futami.getJson('sounds2'); const sounds = await futami.getJson('sounds2');
if(Array.isArray(sounds.library)) if(Array.isArray(sounds.library))
sndLib.register(sounds.library, true); soundCtx.library.register(sounds.library, true);
if(Array.isArray(sounds.packs)) if(Array.isArray(sounds.packs))
sndPacks.register(sounds.packs, true); soundCtx.packs.register(sounds.packs, true);
} catch(ex) { } catch(ex) {
console.error(ex); console.error(ex);
} }
@ -150,39 +144,36 @@ const Umi = { UI: {} };
settings.watch('soundEnable', (v, n, i) => { settings.watch('soundEnable', (v, n, i) => {
if(v) { if(v) {
const audio = mami.getAudio(); if(!soundCtx.ready)
if(!audio.isReady()) soundCtx.reset();
audio.reset();
settings.touch('soundVolume'); settings.touch('soundVolume');
settings.touch('soundPack'); settings.touch('soundPack');
const player = mami.getSoundPackPlayer(); soundCtx.packPlayer.playEvent('server');
if(player !== null)
player.playEvent('server');
} }
mami.getAudio().setMuted(!v); soundCtx.muted = !v;
}); });
settings.watch('soundPack', (v, n, i) => { settings.watch('soundPack', (v, n, i) => {
const packs = mami.getSoundPacks(); const packs = soundCtx.packs;
if(!packs.has(v)) { if(!packs.has(v)) {
settings.delete(n); settings.delete(n);
return; return;
} }
const player = mami.getSoundPackPlayer(); const player = soundCtx.packPlayer;
player.loadPack(packs.get(v)); player.loadPack(packs.get(v));
if(!i) player.playEvent('server'); if(!i) player.playEvent('server');
}); });
settings.watch('soundVolume', v => { settings.watch('soundVolume', v => {
mami.getAudio().setVolume(v / 100); soundCtx.volume = v / 100;
}) })
lo.setMessage('Loading emoticons...'); loadingOverlay.setMessage('Loading emoticons...');
try { try {
const emotes = await futami.getJson('emotes'); const emotes = await futami.getJson('emotes');
MamiEmotes.loadLegacy(emotes); MamiEmotes.loadLegacy(emotes);
@ -223,7 +214,31 @@ const Umi = { UI: {} };
}); });
lo.setMessage('Preparing UI...'); let eeprom;
loadingOverlay.setMessage('Loading EEPROM...');
try {
await MamiEEPROM.init();
eeprom = new EEPROM('1', futami.get('eeprom2'), MamiMisuzuAuth.getLine);
} catch(ex) {
console.error(ex);
eeprom = undefined;
}
loadingOverlay.setMessage('Preparing UI...');
const textTriggers = new MamiTextTriggers;
// define this as late as possible'
const ctx = new MamiContext({
settings: settings,
views: views,
sound: soundCtx,
textTriggers: textTriggers,
eeprom: eeprom,
});
Object.defineProperty(window, 'mami', { enumerable: true, value: ctx });
// should be dynamic when possible // should be dynamic when possible
const layout = new Umi.UI.ChatLayout; const layout = new Umi.UI.ChatLayout;
@ -240,7 +255,7 @@ const Umi = { UI: {} };
settings.watch('minecraft', (v, n, i) => { settings.watch('minecraft', (v, n, i) => {
if(v !== 'no') { if(v !== 'no') {
if(i) if(i)
sndLib.play('minecraft:nether:enter'); soundCtx.library.play('minecraft:nether:enter');
else else
Umi.Sound.Play('join'); Umi.Sound.Play('join');
} }
@ -261,9 +276,8 @@ const Umi = { UI: {} };
settings.watch('playJokeSounds', v => { settings.watch('playJokeSounds', v => {
if(!v) return; if(!v) return;
const triggers = mami.getTextTriggers(); if(!textTriggers.hasTriggers())
if(!triggers.hasTriggers()) futami.getJson('texttriggers').then(trigInfos => textTriggers.addTriggers(trigInfos));
futami.getJson('texttriggers').then(trigInfos => triggers.addTriggers(trigInfos));
}); });
settings.watch('weeaboo', v => { settings.watch('weeaboo', v => {
@ -285,16 +299,7 @@ const Umi = { UI: {} };
}); });
lo.setMessage('Loading EEPROM...'); loadingOverlay.setMessage('Building menus...');
try {
await MamiEEPROM.init();
ctx.createEEPROM();
} catch(ex) {
console.error(ex);
}
lo.setMessage('Building menus...');
Umi.UI.Menus.Add('users', 'Users'); Umi.UI.Menus.Add('users', 'Users');
Umi.UI.Menus.Add('channels', 'Channels', !settings.get('showChannelList')); Umi.UI.Menus.Add('channels', 'Channels', !settings.get('showChannelList'));
@ -394,7 +399,7 @@ const Umi = { UI: {} };
$r(explode); $r(explode);
}, 1700); }, 1700);
sndLib.play('misc:explode'); soundCtx.library.play('misc:explode');
}, },
}, },
}); });
@ -413,12 +418,12 @@ const Umi = { UI: {} };
}, 'Clear Logs'); }, 'Clear Logs');
if(ctx.hasEEPROM()) { if(eeprom !== undefined) {
Umi.UI.Menus.Add('uploads', 'Upload History', !FUTAMI_DEBUG); Umi.UI.Menus.Add('uploads', 'Upload History', !FUTAMI_DEBUG);
const doUpload = async file => { const doUpload = async file => {
const uploadEntry = Umi.UI.Uploads.create(file.name); const uploadEntry = Umi.UI.Uploads.create(file.name);
const uploadTask = ctx.getEEPROM().create(file); const uploadTask = eeprom.create(file);
uploadTask.onProgress(prog => uploadEntry.setProgress(prog.progress)); uploadTask.onProgress(prog => uploadEntry.setProgress(prog.progress));
uploadEntry.addOption('Cancel', () => uploadTask.abort()); uploadEntry.addOption('Cancel', () => uploadTask.abort());
@ -433,7 +438,7 @@ const Umi = { UI: {} };
uploadEntry.addOption('Open', fileInfo.url); uploadEntry.addOption('Open', fileInfo.url);
uploadEntry.addOption('Insert', () => Umi.UI.Markup.InsertRaw(insertText, '')); uploadEntry.addOption('Insert', () => Umi.UI.Markup.InsertRaw(insertText, ''));
uploadEntry.addOption('Delete', () => { uploadEntry.addOption('Delete', () => {
ctx.getEEPROM().delete(fileInfo) eeprom.delete(fileInfo)
.then(() => uploadEntry.remove()) .then(() => uploadEntry.remove())
.catch(ex => { .catch(ex => {
console.error(ex); console.error(ex);
@ -529,7 +534,7 @@ const Umi = { UI: {} };
}); });
lo.setMessage('Connecting...'); loadingOverlay.setMessage('Connecting...');
Umi.Server.open(views, settings); Umi.Server.open(views, settings);
if(window.dispatchEvent) if(window.dispatchEvent)

View file

@ -225,7 +225,7 @@ Umi.Parsing = (function() {
}, },
}); });
if(mami.getSettings().get('motivationalImages')) if(mami.settings.get('motivationalImages'))
html = motivFrame( html = motivFrame(
extractMotiv(element), extractMotiv(element),
html html
@ -306,7 +306,7 @@ Umi.Parsing = (function() {
}, },
}); });
if(mami.getSettings().get('motivationalVideos')) if(mami.settings.get('motivationalVideos'))
html = motivFrame( html = motivFrame(
extractMotiv(element), extractMotiv(element),
html html

View file

@ -18,10 +18,6 @@
#include ui/loading-overlay.jsx #include ui/loading-overlay.jsx
#include sound/umisound.js #include sound/umisound.js
if(!Umi.Protocol) Umi.Protocol = {};
if(!Umi.Protocol.SockChat) Umi.Protocol.SockChat = {};
if(!Umi.Protocol.SockChat.Protocol) Umi.Protocol.SockChat.Protocol = {};
Umi.Protocol.SockChat.Protocol = function(views, settings) { Umi.Protocol.SockChat.Protocol = function(views, settings) {
const pub = {}; const pub = {};
Umi.Protocol.SockChat.Protocol.Instance = pub; Umi.Protocol.SockChat.Protocol.Instance = pub;
@ -102,18 +98,17 @@ Umi.Protocol.SockChat.Protocol = function(views, settings) {
}; };
const playBannedSfx = async () => { const playBannedSfx = async () => {
await mami.getSoundLibrary().play('touhou:pichuun'); await mami.sound.library.play('touhou:pichuun');
}; };
const playBannedBgm = async preload => { const playBannedBgm = async preload => {
const name = 'touhou:th10score'; const name = 'touhou:th10score';
const soundLib = mami.getSoundLibrary();
if(preload) { if(preload) {
await soundLib.loadBuffer(name); await mami.sound.library.loadBuffer(name);
return; return;
} }
const source = await soundLib.loadSource(name); const source = await mami.sound.library.loadSource(name);
source.setLoop(true, 10.512, 38.074); source.setLoop(true, 10.512, 38.074);
await source.play(); await source.play();
}; };
@ -564,10 +559,10 @@ Umi.Protocol.SockChat.Protocol = function(views, settings) {
if(settings.get('playJokeSounds')) if(settings.get('playJokeSounds'))
try { try {
const trigger = mami.getTextTriggers().getTrigger(text); const trigger = mami.textTriggers.getTrigger(text);
if(trigger.isSoundType()) { if(trigger.isSoundType()) {
sound = ''; sound = '';
mami.getSoundLibrary().play( mami.sound.library.play(
trigger.getRandomSoundName(), trigger.getRandomSoundName(),
trigger.getVolume(), trigger.getVolume(),
trigger.getRate() trigger.getRate()

View file

@ -0,0 +1,30 @@
#include audio/context.js
#include sound/sndmgr.js
#include sound/sndlibrary.js
#include sound/sndpacks.js
const MamiSoundContext = function() {
const audioCtx = new MamiAudioContext;
const manager = new MamiSoundManager(audioCtx);
const library = new MamiSoundLibrary(manager);
const packs = new MamiSoundPacks;
const packPlayer = new MamiSoundPackPlayer(library);
const pub = {};
Object.defineProperties(pub, {
audio: { value: audioCtx, enumerable: true },
manager: { value: manager, enumerable: true },
library: { value: library, enumerable: true },
packs: { value: packs, enumerable: true },
packPlayer: { value: packPlayer, enumerable: true },
ready: { get: audioCtx.isReady, enumerable: true },
volume: { get: audioCtx.getVolume, set: audioCtx.setVolume, enumerable: true },
muted: { get: audioCtx.isMuted, set: audioCtx.setMuted, enumerable: true },
});
pub.reset = audioCtx.reset;
return Object.freeze(pub);
};

View file

@ -20,7 +20,7 @@ const OsuKeys = (() => {
else else
soundName = `press${rng.next(1, 5)}`; soundName = `press${rng.next(1, 5)}`;
mami.getSoundLibrary().play( mami.sound.library.play(
`osu:key:${soundName}`, `osu:key:${soundName}`,
undefined, undefined,
sndRng ? (1.8 - (rng.sample() * 1.5)) : undefined sndRng ? (1.8 - (rng.sample() * 1.5)) : undefined

View file

@ -6,121 +6,117 @@ Umi.Sound = (() => {
if(!sound || sound === 'none') if(!sound || sound === 'none')
return; return;
const settings = mami.getSettings();
const sndLib = mami.getSoundLibrary();
const sndPackPlay = mami.getSoundPackPlayer();
switch(sound) { switch(sound) {
case 'join': case 'join':
if(!settings.get('soundEnableJoin')) if(!mami.settings.get('soundEnableJoin'))
return; return;
if(settings.get('seinfeld')) { if(mami.settings.get('seinfeld')) {
sndLib.play(Seinfeld.getRandom()); mami.sound.library.play(Seinfeld.getRandom());
break; break;
} }
switch(settings.get('minecraft')) { switch(mami.settings.get('minecraft')) {
case 'yes': case 'yes':
sndLib.play('minecraft:door:open'); mami.sound.library.play('minecraft:door:open');
break; break;
case 'old': case 'old':
sndLib.play('minecraft:door:open-old'); mami.sound.library.play('minecraft:door:open-old');
break; break;
default: default:
sndPackPlay.playEvent('join'); mami.sound.packPlayer.playEvent('join');
break; break;
} }
break; break;
case 'leave': case 'leave':
if(!settings.get('soundEnableLeave')) if(!mami.settings.get('soundEnableLeave'))
return; return;
switch(settings.get('minecraft')) { switch(mami.settings.get('minecraft')) {
case 'yes': case 'yes':
sndLib.play('minecraft:door:close'); mami.sound.library.play('minecraft:door:close');
break; break;
case 'old': case 'old':
sndLib.play('minecraft:door:close-old'); mami.sound.library.play('minecraft:door:close-old');
break; break;
default: default:
sndPackPlay.playEvent('leave'); mami.sound.packPlayer.playEvent('leave');
break; break;
} }
break; break;
case 'error': case 'error':
if(!settings.get('soundEnableError')) if(!mami.settings.get('soundEnableError'))
return; return;
sndPackPlay.playEvent('error'); mami.sound.packPlayer.playEvent('error');
break; break;
case 'server': case 'server':
if(!settings.get('soundEnableServer')) if(!mami.settings.get('soundEnableServer'))
return; return;
sndPackPlay.playEvent('server'); mami.sound.packPlayer.playEvent('server');
break; break;
case 'unban': case 'unban':
if(!settings.get('soundEnableServer')) if(!mami.settings.get('soundEnableServer'))
return; return;
sndPackPlay.playEvent(['unban', 'server']); mami.sound.packPlayer.playEvent(['unban', 'server']);
break; break;
case 'incoming': case 'incoming':
if(!settings.get('soundEnableIncoming')) if(!mami.settings.get('soundEnableIncoming'))
return; return;
if(settings.get('windowsLiveMessenger')) { if(mami.settings.get('windowsLiveMessenger')) {
sndLib.play('msn:incoming'); mami.sound.library.play('msn:incoming');
} else { } else {
sndPackPlay.playEvent('incoming'); mami.sound.packPlayer.playEvent('incoming');
} }
break; break;
case 'outgoing': case 'outgoing':
if(!settings.get('soundEnableOutgoing')) if(!mami.settings.get('soundEnableOutgoing'))
return; return;
sndPackPlay.playEvent('outgoing'); mami.sound.packPlayer.playEvent('outgoing');
break; break;
case 'private': case 'private':
case 'incoming-priv': case 'incoming-priv':
if(!settings.get('soundEnablePrivate')) if(!mami.settings.get('soundEnablePrivate'))
return; return;
sndPackPlay.playEvent(['incoming-priv', 'incoming']); mami.sound.packPlayer.playEvent(['incoming-priv', 'incoming']);
break; break;
case 'flood': case 'flood':
if(!settings.get('soundEnableForceLeave')) if(!mami.settings.get('soundEnableForceLeave'))
return; return;
sndPackPlay.playEvent(['flood', 'kick', 'leave']); mami.sound.packPlayer.playEvent(['flood', 'kick', 'leave']);
break; break;
case 'timeout': case 'timeout':
if(!settings.get('soundEnableForceLeave')) if(!mami.settings.get('soundEnableForceLeave'))
return; return;
sndPackPlay.playEvent(['timeout', 'leave']); mami.sound.packPlayer.playEvent(['timeout', 'leave']);
break; break;
case 'kick': case 'kick':
case 'forceLeave': case 'forceLeave':
if(!settings.get('soundEnableForceLeave')) if(!mami.settings.get('soundEnableForceLeave'))
return; return;
sndPackPlay.playEvent(['kick', 'leave']); mami.sound.packPlayer.playEvent(['kick', 'leave']);
break; break;
} }
}, },

View file

@ -55,11 +55,9 @@ const MamiDomainTransition = function(onImport, onDismiss) {
</div> </div>
</div>; </div>;
const soundLib = mami.getSoundLibrary();
const soundRNG = new MamiRNG(); const soundRNG = new MamiRNG();
const soundNames = soundLib.names(); const soundNames = mami.sound.library.names();
const playRandomSound = () => mami.sound.library.play(soundNames[soundRNG.next(soundNames.length)]);
const playRandomSound = () => soundLib.play(soundNames[soundRNG.next(soundNames.length)]);
for(let i = 0; i < 10; ++i) for(let i = 0; i < 10; ++i)
eggsTarget.appendChild(<i class="fas fa-egg fa-3x" onclick={() => playRandomSound()} />); eggsTarget.appendChild(<i class="fas fa-egg fa-3x" onclick={() => playRandomSound()} />);

View file

@ -34,7 +34,7 @@ Umi.UI.Emoticons = (function() {
}); });
}, },
Parse: function(element, message) { Parse: function(element, message) {
if(!mami.getSettings().get('enableEmoticons')) if(!mami.settings.get('enableEmoticons'))
return element; return element;
let inner = element.innerHTML; let inner = element.innerHTML;

View file

@ -37,12 +37,10 @@ Umi.UI.Hooks = (function() {
if(!document.hidden) if(!document.hidden)
return; return;
const settings = mami.getSettings(); if(mami.settings.get('flashTitle')) {
if(settings.get('flashTitle')) {
let titleText = ' ' + msg.getUser().getName(), let titleText = ' ' + msg.getUser().getName(),
channel = Umi.Channels.Current() || null; channel = Umi.Channels.Current() || null;
if(msg.getUser().isBot() && settings.get('showServerMsgInTitle')) if(msg.getUser().isBot() && mami.settings.get('showServerMsgInTitle'))
titleText = ' ' + msg.getText(); titleText = ' ' + msg.getText();
if(channel !== null && channel.getName() !== msg.getChannel()) if(channel !== null && channel.getName() !== msg.getChannel())
@ -54,14 +52,14 @@ Umi.UI.Hooks = (function() {
]); ]);
} }
if(settings.get('enableNotifications') && Umi.User.getCurrentUser() !== null) { if(mami.settings.get('enableNotifications') && Umi.User.getCurrentUser() !== null) {
const triggers = (settings.get('notificationTriggers') || '').toLowerCase().split(' '), const triggers = (mami.settings.get('notificationTriggers') || '').toLowerCase().split(' '),
options = {}; options = {};
triggers.push((Umi.User.getCurrentUser() || { getName: function() { return ''; } }).getName().toLowerCase()); triggers.push((Umi.User.getCurrentUser() || { getName: function() { return ''; } }).getName().toLowerCase());
options.body = 'Click here to see what they said.'; options.body = 'Click here to see what they said.';
if(settings.get('notificationShowMessage')) if(mami.settings.get('notificationShowMessage'))
options.body += "\n" + msg.getText(); options.body += "\n" + msg.getText();
const avatarUrl = futami.get('avatar'); const avatarUrl = futami.get('avatar');
@ -76,7 +74,7 @@ Umi.UI.Hooks = (function() {
if(message.toLowerCase().indexOf(' ' + trigger + ' ') >= 0) { if(message.toLowerCase().indexOf(' ' + trigger + ' ') >= 0) {
new Notification('{0} mentioned you!'.replace('{0}', msg.getUser().getName()), options); new Notification('{0} mentioned you!'.replace('{0}', msg.getUser().getName()), options);
if(settings.get('onlySoundOnMention')) if(mami.settings.get('onlySoundOnMention'))
Umi.Sound.Play('incoming'); Umi.Sound.Play('incoming');
break; break;
} }
@ -146,7 +144,7 @@ Umi.UI.Hooks = (function() {
const elemParent = elemInput.parentNode; const elemParent = elemInput.parentNode;
let height = 40; let height = 40;
if(mami.getSettings().get('expandTextBox') && elemInput.scrollHeight > elemInput.clientHeight) if(mami.settings.get('expandTextBox') && elemInput.scrollHeight > elemInput.clientHeight)
height = elemInput.scrollHeight; height = elemInput.scrollHeight;
if(height > 40) if(height > 40)

View file

@ -29,7 +29,6 @@ Umi.UI.Messages = (function() {
eMeta = null, eMeta = null,
eUser = null; eUser = null;
const settings = mami.getSettings();
const sender = msg.getUser(); const sender = msg.getUser();
let avatarUser = sender, let avatarUser = sender,
avatarSize = '80'; avatarSize = '80';
@ -61,7 +60,7 @@ Umi.UI.Messages = (function() {
+ ':' + msgDateTimeObj.getMinutes().toString().padStart(2, '0') + ':' + msgDateTimeObj.getMinutes().toString().padStart(2, '0')
+ ':' + msgDateTimeObj.getSeconds().toString().padStart(2, '0'); + ':' + msgDateTimeObj.getSeconds().toString().padStart(2, '0');
if(sender.isBot() && settings.get('fancyInfo')) { if(sender.isBot() && mami.settings.get('fancyInfo')) {
const botInfo = msg.getBotInfo(); const botInfo = msg.getBotInfo();
if(botInfo) { if(botInfo) {
@ -153,7 +152,7 @@ Umi.UI.Messages = (function() {
const urls = []; const urls = [];
if(settings.get('autoParseUrls')) { if(mami.settings.get('autoParseUrls')) {
const textSplit = eText.innerText.split(' '); const textSplit = eText.innerText.split(' ');
for(const textPart of textSplit) { for(const textPart of textSplit) {
const uri = Umi.URI.Parse(textPart); const uri = Umi.URI.Parse(textPart);
@ -177,7 +176,7 @@ Umi.UI.Messages = (function() {
} }
} }
if(settings.get('weeaboo')) { if(mami.settings.get('weeaboo')) {
eText.appendChild($t(Weeaboo.getTextSuffix(sender))); eText.appendChild($t(Weeaboo.getTextSuffix(sender)));
const kaomoji = Weeaboo.getRandomKaomoji(true, msg); const kaomoji = Weeaboo.getRandomKaomoji(true, msg);
@ -187,7 +186,7 @@ Umi.UI.Messages = (function() {
} }
} }
if(settings.get('weeaboo')) if(mami.settings.get('weeaboo'))
eUser.appendChild($t(Weeaboo.getNameSuffix(sender))); eUser.appendChild($t(Weeaboo.getNameSuffix(sender)));
} }
@ -210,14 +209,14 @@ Umi.UI.Messages = (function() {
lastMsgUser = sender.getId(); lastMsgUser = sender.getId();
lastMsgChannel = msg.getChannel(); lastMsgChannel = msg.getChannel();
if(settings.get('autoEmbedV1')) { if(mami.settings.get('autoEmbedV1')) {
const callEmbedOn = eBase.querySelectorAll('a[onclick^="Umi.Parser.SockChatBBcode.Embed"]'); const callEmbedOn = eBase.querySelectorAll('a[onclick^="Umi.Parser.SockChatBBcode.Embed"]');
for(const embedElem of callEmbedOn) for(const embedElem of callEmbedOn)
if(embedElem.dataset.embed !== '1') if(embedElem.dataset.embed !== '1')
embedElem.click(); embedElem.click();
} }
if(settings.get('autoScroll')) if(mami.settings.get('autoScroll'))
msgsList.scrollTop = msgsList.scrollHeight; msgsList.scrollTop = msgsList.scrollHeight;
if(window.CustomEvent) if(window.CustomEvent)

View file

@ -138,13 +138,13 @@ Umi.UI.Settings = (function() {
title: 'Sound pack', title: 'Sound pack',
type: 'select', type: 'select',
options: () => { options: () => {
const registry = mami.getSoundPacks(); const packs = mami.sound.packs;
const packs = {}; const options = {};
for(const name of registry.names()) for(const name of packs.names())
packs[name] = registry.info(name).getTitle(); options[name] = packs.info(name).getTitle();
return packs; return options;
}, },
}, },
{ {
@ -293,10 +293,10 @@ Umi.UI.Settings = (function() {
invoke: button => { invoke: button => {
button.disabled = true; button.disabled = true;
const triggers = mami.getTextTriggers(); const triggers = mami.textTriggers;
triggers.clearTriggers(); triggers.clearTriggers();
if(mami.getSettings().get('playJokeSounds')) if(mami.settings.get('playJokeSounds'))
futami.getJson('texttriggers', true) futami.getJson('texttriggers', true)
.then(trigInfos => triggers.addTriggers(trigInfos)) .then(trigInfos => triggers.addTriggers(trigInfos))
.finally(() => button.disabled = false); .finally(() => button.disabled = false);
@ -325,7 +325,7 @@ Umi.UI.Settings = (function() {
if(!confirm('Your current settings will be replaced with the ones in the export. Are you sure you want to continue?')) if(!confirm('Your current settings will be replaced with the ones in the export. Are you sure you want to continue?'))
return; return;
(new MamiSettingsBackup(mami.getSettings())).importUpload(document.body); (new MamiSettingsBackup(mami.settings)).importUpload(document.body);
}, },
}, },
{ {
@ -337,7 +337,7 @@ Umi.UI.Settings = (function() {
if(user !== null) if(user !== null)
fileName = `${user.getName()}'s settings.mami`; fileName = `${user.getName()}'s settings.mami`;
(new MamiSettingsBackup(mami.getSettings())).exportDownload(document.body, fileName); (new MamiSettingsBackup(mami.settings)).exportDownload(document.body, fileName);
}, },
}, },
{ {
@ -347,7 +347,7 @@ Umi.UI.Settings = (function() {
if(!confirm('This will reset all your settings to their defaults values. Are you sure you want to do this?')) if(!confirm('This will reset all your settings to their defaults values. Are you sure you want to do this?'))
return; return;
mami.getSettings().clear(); mami.settings.clear();
}, },
}, },
], ],
@ -394,7 +394,7 @@ Umi.UI.Settings = (function() {
type: 'button', type: 'button',
invoke: async button => { invoke: async button => {
button.disabled = true; button.disabled = true;
await (new MamiYouAreAnIdiot()).pushOn(mami.getViews()); await (new MamiYouAreAnIdiot()).pushOn(mami.views);
button.disabled = false; button.disabled = false;
}, },
}, },
@ -402,7 +402,7 @@ Umi.UI.Settings = (function() {
title: 'Reset audio context', title: 'Reset audio context',
type: 'button', type: 'button',
invoke: async () => { invoke: async () => {
mami.getAudio().reset(); mami.sound.reset();
}, },
}, },
], ],
@ -417,11 +417,10 @@ Umi.UI.Settings = (function() {
}; };
const createSetting = function(display) { const createSetting = function(display) {
const settings = mami.getSettings();
let setting; let setting;
if('name' in display) if('name' in display)
setting = settings.info(display.name); setting = mami.settings.info(display.name);
let input = display.type === 'select' let input = display.type === 'select'
? <select class="setting__input"/> ? <select class="setting__input"/>
@ -446,18 +445,18 @@ Umi.UI.Settings = (function() {
input.disabled = true; input.disabled = true;
if(display.type === 'checkbox') { if(display.type === 'checkbox') {
settings.watch(setting.name, v => input.checked = v); mami.settings.watch(setting.name, v => input.checked = v);
input.addEventListener('change', () => { input.addEventListener('change', () => {
if(display.confirm !== undefined && input.checked !== setting.fallback && !confirm(display.confirm)) { if(display.confirm !== undefined && input.checked !== setting.fallback && !confirm(display.confirm)) {
input.checked = setting.fallback; input.checked = setting.fallback;
return; return;
} }
settings.toggle(setting.name); mami.settings.toggle(setting.name);
}); });
} else { } else {
settings.watch(setting.name, v => input.value = v); mami.settings.watch(setting.name, v => input.value = v);
input.addEventListener('change', () => settings.set(setting.name, input.value)); input.addEventListener('change', () => mami.settings.set(setting.name, input.value));
} }
} }

View file

@ -21,9 +21,9 @@ Umi.UI.Users = (function() {
} }
if(isClosed) { if(isClosed) {
if(mami.getSettings().get('autoCloseUserContext')) if(mami.settings.get('autoCloseUserContext'))
toggleTimeouts[prefix] = setTimeout(function() { toggleTimeouts[prefix] = setTimeout(function() {
if(mami.getSettings().get('autoCloseUserContext')) if(mami.settings.get('autoCloseUserContext'))
toggleUser(id); toggleUser(id);
}, 300000); }, 300000);
@ -155,7 +155,7 @@ Umi.UI.Users = (function() {
if(isAFK) if(isAFK)
uName.appendChild($e({ attrs: { 'class': 'user-sidebar-afk' }, child: afkText })); uName.appendChild($e({ attrs: { 'class': 'user-sidebar-afk' }, child: afkText }));
if(sbUserName.length > 16 || mami.getSettings().get('marqueeAllNames')) { if(sbUserName.length > 16 || mami.settings.get('marqueeAllNames')) {
uName.appendChild($e({ uName.appendChild($e({
tag: 'marquee', tag: 'marquee',
attrs: { attrs: {
@ -205,7 +205,7 @@ Umi.UI.Users = (function() {
if(isAFK) if(isAFK)
uName.appendChild($e({ attrs: { 'class': 'user-sidebar-afk' }, child: afkText })); uName.appendChild($e({ attrs: { 'class': 'user-sidebar-afk' }, child: afkText }));
if(sbUserName.length > 16 || mami.getSettings().get('marqueeAllNames')) { if(sbUserName.length > 16 || mami.settings.get('marqueeAllNames')) {
uName.appendChild($e({ uName.appendChild($e({
tag: 'marquee', tag: 'marquee',
attrs: { attrs: {

View file

@ -27,8 +27,7 @@ Umi.UI.View = (function() {
return { return {
AccentColours: accentColours, AccentColours: accentColours,
AccentReload: function() { AccentReload: function() {
const settings = mami.getSettings() const style = mami.settings.get('style');
const style = settings.get('style');
if(!accentColours.hasOwnProperty(style)) if(!accentColours.hasOwnProperty(style))
return; return;
@ -39,11 +38,11 @@ Umi.UI.View = (function() {
const chat = $i('umi-chat'); const chat = $i('umi-chat');
if(chat instanceof Element) { if(chat instanceof Element) {
const compactView = settings.get('compactView'); const compactView = mami.settings.get('compactView');
chat.classList.toggle('chat--compact', compactView); chat.classList.toggle('chat--compact', compactView);
$i('umi-messages').classList.toggle('chat--compact', compactView); $i('umi-messages').classList.toggle('chat--compact', compactView);
const forceOldOff = settings.get('tmpDisableOldThemeSys'); const forceOldOff = mami.settings.get('tmpDisableOldThemeSys');
for(const name in accentColours) for(const name in accentColours)
if(accentColours.hasOwnProperty(name)) if(accentColours.hasOwnProperty(name))
chat.classList.toggle(`umi--${name}`, !forceOldOff && name === style); chat.classList.toggle(`umi--${name}`, !forceOldOff && name === style);

View file

@ -2,9 +2,9 @@ const UmiWebSocket = function(server, message, useWorker) {
if(typeof useWorker === 'undefined') if(typeof useWorker === 'undefined')
useWorker = (function() { useWorker = (function() {
// Overrides // Overrides
if(mami.getSettings().get('neverUseWorker')) if(mami.settings.get('neverUseWorker'))
return false; return false;
if(mami.getSettings().get('forceUseWorker')) if(mami.settings.get('forceUseWorker'))
return true; return true;
// Detect chromosomes // Detect chromosomes

View file

@ -23,7 +23,7 @@ const MamiYouAreAnIdiot = function() {
getElement: () => html, getElement: () => html,
onViewPush: async () => { onViewPush: async () => {
try { try {
soundSrc = await mami.getSoundLibrary().loadSource('misc:youare'); soundSrc = await mami.sound.library.loadSource('misc:youare');
soundSrc.setMuted(true); soundSrc.setMuted(true);
soundSrc.setLoop(true, 0.21, 5); soundSrc.setLoop(true, 0.21, 5);
soundSrc.play(); soundSrc.play();