Files
VRCX/src/repository/shared.js
Natsumi 938fff63d0 Electron support for Linux (#1074)
* init

* SQLite changes

* Move html folder, edit build scripts

* AppApi interface

* Build flags

* AppApi inheritance

* Finishing touches

* Merge upstream changes

* Test CI

* Fix class inits

* Rename AppApi

* Merge upstream changes

* Fix SQLiteLegacy on Linux, Add Linux interop, build tools

* Linux specific localisation strings

* Make it run

* Bring back most of Linux functionality

* Clean up

* Fix TTS voices

* Fix UI var

* Changes

* Electron minimise to tray

* Remove separate toggle for WlxOverlay

* Fixes

* Touchups

* Move csproj

* Window zoom, Desktop Notifications, VR check on Linux

* Fix desktop notifications, VR check spam

* Fix building on Linux

* Clean up

* Fix WebApi headers

* Rewrite VRCX updater

* Clean up

* Linux updater

* Add Linux to build action

* init

* SQLite changes

* Move html folder, edit build scripts

* AppApi interface

* Build flags

* AppApi inheritance

* Finishing touches

* Merge upstream changes

* Test CI

* Fix class inits

* Rename AppApi

* Merge upstream changes

* Fix SQLiteLegacy on Linux, Add Linux interop, build tools

* Linux specific localisation strings

* Make it run

* Bring back most of Linux functionality

* Clean up

* Fix TTS voices

* Changes

* Electron minimise to tray

* Remove separate toggle for WlxOverlay

* Fixes

* Touchups

* Move csproj

* Window zoom, Desktop Notifications, VR check on Linux

* Fix desktop notifications, VR check spam

* Fix building on Linux

* Clean up

* Fix WebApi headers

* Rewrite VRCX updater

* Clean up

* Linux updater

* Add Linux to build action

* Test updater

* Rebase and handle merge conflicts

* Fix Linux updater

* Fix Linux app restart

* Fix friend order

* Handle AppImageInstaller, show an install message on Linux

* Updates to the AppImage installer

* Fix Linux updater, fix set version, check for .NET, copy wine prefix

* Handle random errors

* Rotate tall prints

* try fix Linux restart bug

* Final

---------

Co-authored-by: rs189 <35667100+rs189@users.noreply.github.com>
2025-01-11 13:09:44 +13:00

107 lines
2.7 KiB
JavaScript

// requires binding of SharedVariable
function transformKey(key) {
return String(key).toLowerCase();
}
class SharedRepository {
remove(key) {
var _key = transformKey(key);
return SharedVariable.Remove(_key);
}
async getString(key, defaultValue = null) {
var _key = transformKey(key);
var value = await SharedVariable.Get(_key);
if (value === null || value === undefined) {
return defaultValue;
}
return value;
}
async setString(key, value) {
var _key = transformKey(key);
var _value = String(value);
await SharedVariable.Set(_key, _value);
}
async getBool(key, defaultValue = null) {
var value = await this.getString(key, null);
if (value === null || value === undefined) {
return defaultValue;
}
return value === 'true';
}
async setBool(key, value) {
await this.setString(key, value ? 'true' : 'false');
}
async getInt(key, defaultValue = null) {
var value = await this.getString(key, null);
if (value === null || value === undefined) {
return defaultValue;
}
value = parseInt(value, 10);
if (isNaN(value) === true) {
return defaultValue;
}
return value;
}
async setInt(key, value) {
await this.setString(key, value);
}
async getFloat(key, defaultValue = null) {
var value = await this.getString(key, null);
if (value === null || value === undefined) {
return defaultValue;
}
value = parseFloat(value);
if (isNaN(value) === true) {
return defaultValue;
}
return value;
}
async setFloat(key, value) {
await this.setString(key, value);
}
async getObject(key, defaultValue = null) {
var value = await this.getString(key, null);
if (value === null || value === undefined) {
return defaultValue;
}
try {
value = JSON.parse(value);
} catch (err) {}
if (value !== Object(value)) {
return defaultValue;
}
return value;
}
async setObject(key, value) {
await this.setString(key, JSON.stringify(value));
}
async getArray(key, defaultValue = null) {
var value = await this.getObject(key, null);
if (Array.isArray(value) === false) {
return defaultValue;
}
return value;
}
async setArray(key, value) {
await this.setObject(key, value);
}
}
var self = new SharedRepository();
window.sharedRepository = self;
export { self as default, SharedRepository };