mirror of https://github.com/Alia5/GlosSI
Update SteamTweaks
parent
a07faa926c
commit
b26fd9faf5
@ -1,11 +1,44 @@
|
|||||||
import typescript from '@rollup/plugin-typescript';
|
import typescript from '@rollup/plugin-typescript';
|
||||||
|
import { readdirSync, lstatSync } from 'fs';
|
||||||
|
import path from 'path';
|
||||||
|
|
||||||
export default {
|
const getFileListForDir = (dir) => {
|
||||||
input: 'src/Tweaks/Overlay/HideFPSCounter.ts',
|
return readdirSync(dir).map((file) => {
|
||||||
output: {
|
const absolute = path.resolve(dir, file);
|
||||||
file: 'dist/glossiTweaks.js',
|
if (file.endsWith('.ts')) {
|
||||||
sourcemap: "inline",
|
return absolute;
|
||||||
format: 'es',
|
}
|
||||||
},
|
if (lstatSync(absolute).isDirectory()) {
|
||||||
plugins: [typescript()]
|
return getFileListForDir(absolute)
|
||||||
};
|
}
|
||||||
|
}).flat(999);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const tsPluginConf = typescript({
|
||||||
|
cacheDir: '.rollup.tscache'
|
||||||
|
});
|
||||||
|
|
||||||
|
export default [
|
||||||
|
{
|
||||||
|
input: 'src/GlosSITweaks.ts',
|
||||||
|
output: {
|
||||||
|
dir: 'dist',
|
||||||
|
sourcemap: "inline",
|
||||||
|
format: 'iife',
|
||||||
|
},
|
||||||
|
plugins: [tsPluginConf],
|
||||||
|
},
|
||||||
|
...getFileListForDir('src/Tweaks').map((file) => {
|
||||||
|
return {
|
||||||
|
input: file,
|
||||||
|
output: {
|
||||||
|
file: file.replace('src', 'dist').replace(/\.ts$/, '.js'),
|
||||||
|
sourcemap: "inline",
|
||||||
|
format: 'iife',
|
||||||
|
},
|
||||||
|
plugins: [tsPluginConf],
|
||||||
|
}
|
||||||
|
})
|
||||||
|
];
|
@ -0,0 +1,54 @@
|
|||||||
|
import type { SteamConfig } from './common/util/types';
|
||||||
|
class SteamTargetApi {
|
||||||
|
public getSteamSettings(): Promise<SteamConfig> {
|
||||||
|
return fetch('http://localhost:8756/steam_settings')
|
||||||
|
.then(
|
||||||
|
(res) => res.json().then(
|
||||||
|
(json) => (json as SteamConfig).UserLocalConfigStore as SteamConfig
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class GlosSIApiCtor {
|
||||||
|
public readonly SteamTarget: SteamTargetApi = new SteamTargetApi();
|
||||||
|
}
|
||||||
|
|
||||||
|
interface GlosSITweaks {
|
||||||
|
[tweakName: string]: { readonly install: () => unknown; readonly uninstall?: () => void }
|
||||||
|
}
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface Window {
|
||||||
|
GlosSITweaks: GlosSITweaks
|
||||||
|
GlosSIApi: InstanceType<typeof GlosSIApiCtor>;
|
||||||
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line
|
||||||
|
const GlosSIApi: InstanceType<typeof GlosSIApiCtor>;
|
||||||
|
const GlosSITweaks: GlosSITweaks
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const installGlosSIApi = () => {
|
||||||
|
window.GlosSITweaks = {
|
||||||
|
GlosSI: {
|
||||||
|
install: () => {
|
||||||
|
const api = new GlosSIApiCtor();
|
||||||
|
Object.assign(window, { GlosSIApi: api });
|
||||||
|
},
|
||||||
|
uninstall: () => {
|
||||||
|
Object.values(window.GlosSITweaks)
|
||||||
|
.forEach((obj) => obj.uninstall?.());
|
||||||
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
|
// @ts-ignore
|
||||||
|
delete window.GlosSIApi;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
window.GlosSITweaks.GlosSI.install();
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!window.GlosSITweaks || !window.GlosSIApi) {
|
||||||
|
installGlosSIApi();
|
||||||
|
}
|
Loading…
Reference in New Issue