chore: Add code folding regions to app.js for better organization

I thought it would be nice for app.js to roleplay as an organized code file. So I made a regex to prepend all existing manually commented code areas such as "App: FriendLog" with #region so that VSCode can fold them.

There were a couple uncommented regions that are now commented with summaries I can only describe as 'I tried'
This commit is contained in:
Teacup
2023-05-09 15:19:12 -04:00
committed by Natsumi
parent b63cbe64e6
commit 0ab84f1714
+166 -88
View File
@@ -4,6 +4,7 @@
// This work is licensed under the terms of the MIT license.
// For a copy, see <https://opensource.org/licenses/MIT>.
// #region | Imports
import '@fontsource/noto-sans-kr';
import '@fontsource/noto-sans-jp';
import Noty from 'noty';
@@ -24,11 +25,15 @@ import security from './security.js';
import database from './repository/database.js';
import * as localizedStrings from './localization/localizedStrings.js';
// #endregion
speechSynthesis.getVoices();
// #region | Hey look it's most of VRCX!
(async function () {
var $app = null;
// #region | Init
await CefSharp.BindObjectAsync(
'AppApi',
'WebApi',
@@ -42,6 +47,7 @@ speechSynthesis.getVoices();
await configRepository.init();
// #region | Init: Migrate old legacy database data to new format
if (configRepository.getBool('migrate_config_20201101') === null) {
var legacyConfigKeys = [
'orderFriendGroup0',
@@ -72,6 +78,8 @@ speechSynthesis.getVoices();
configRepository.setBool('migrate_config_20201101', true);
}
// #endregion
// #region | Init: drop/keyup event listeners
// Make sure file drops outside of the screenshot manager don't navigate to the file path dropped.
// This issue persists on prompts created with prompt(), unfortunately. Not sure how to fix that.
document.body.addEventListener('drop', function (e) {
@@ -97,6 +105,8 @@ speechSynthesis.getVoices();
$app.screenshotMetadataCarouselChange(carouselNavigation);
}
});
// #endregion
// #region | Init: Define VRCX database helper functions, flush timer
VRCXStorage.GetArray = async function (key) {
try {
@@ -133,6 +143,8 @@ speechSynthesis.getVoices();
workerTimers.setInterval(function () {
VRCXStorage.Flush();
}, 5 * 60 * 1000);
// #endregion
// #region | Init: Noty, Vue, Vue-Markdown, ElementUI, VueI18n, VueLazyLoad, Vue filters, dark stylesheet
Noty.overrideDefaults({
animation: {
@@ -241,10 +253,8 @@ speechSynthesis.getVoices();
$appDarkStyle.rel = 'stylesheet';
$appDarkStyle.href = `app.dark.css?_=${Date.now()}`;
document.head.appendChild($appDarkStyle);
//
// Languages
//
// #endregion
// #region | Init: Languages
var subsetOfLanguages = {
eng: 'English',
@@ -310,11 +320,11 @@ speechSynthesis.getVoices();
fsl: 'fr',
kvk: 'kr'
};
// #endregion
// #endregion
// #region | API: This is NOT all the api functions, not even close :(
//
// API
//
// #region | API: Base
var API = {};
API.eventHandlers = new Map();
@@ -670,7 +680,8 @@ speechSynthesis.getVoices();
.then((args) => this.$bulk(options, args));
};
// API: Config
// #endregion
// #region | API: Config
API.cachedConfig = {};
@@ -699,7 +710,8 @@ speechSynthesis.getVoices();
});
};
// API: Location
// #endregion
// #region | API: Location
API.parseLocation = function (tag) {
var _tag = String(tag || '');
@@ -1184,7 +1196,8 @@ speechSynthesis.getVoices();
}
});
// API: User
// #endregion
// #region | API: User
// changeUserName: PUT users/${userId} {displayName: string, currentPassword: string}
// changeUserEmail: PUT users/${userId} {email: string, currentPassword: string}
@@ -1960,7 +1973,8 @@ speechSynthesis.getVoices();
});
};
// API: World
// #endregion
// #region | API: World
API.cachedWorlds = new Map();
@@ -2360,7 +2374,8 @@ speechSynthesis.getVoices();
}
});
// API: Friend
// #endregion
// #region | API: Friend
API.$on('FRIEND:LIST', function (args) {
for (var json of args.json) {
@@ -2544,7 +2559,8 @@ speechSynthesis.getVoices();
});
};
// API: Avatar
// #endregion
// #region | API: Avatar
API.cachedAvatars = new Map();
@@ -2754,7 +2770,8 @@ speechSynthesis.getVoices();
});
};
// API: Notification
// #endregion
// #region | API: Notification
API.isNotificationsLoading = false;
@@ -3271,7 +3288,8 @@ speechSynthesis.getVoices();
return '';
};
// API: PlayerModeration
// #endregion
// #region | API: PlayerModeration
API.cachedPlayerModerations = new Map();
API.isPlayerModerationsLoading = false;
@@ -3444,7 +3462,8 @@ speechSynthesis.getVoices();
});
};
// API: AvatarModeration
// #endregion
// #region | API: AvatarModeration
API.cachedAvatarModerations = new Map();
@@ -3564,7 +3583,8 @@ speechSynthesis.getVoices();
return ref;
};
// API: Favorite
// #endregion
// #region | API: Favorite
API.cachedFavorites = new Map();
API.cachedFavoritesByObjectId = new Map();
@@ -4275,7 +4295,8 @@ speechSynthesis.getVoices();
});
};
// API: WebSocket
// #endregion
// #region | API: WebSocket
API.webSocket = null;
@@ -4659,7 +4680,8 @@ speechSynthesis.getVoices();
} catch (err) { }
};
// API: Visit
// #endregion
// #region | API: Visit
API.getVisits = function () {
return this.call('visits', {
@@ -4673,8 +4695,14 @@ speechSynthesis.getVoices();
});
};
// #endregion
// API
// #endregion
// #region | Misc
var extractFileId = (s) => {
var match = String(s).match(/file_[0-9A-Za-z-]+/);
return match ? match[0] : '';
@@ -4747,8 +4775,6 @@ speechSynthesis.getVoices();
return node;
};
// Misc
var $timers = [];
Vue.component('timer', {
@@ -4849,7 +4875,8 @@ speechSynthesis.getVoices();
}
}, 5000);
// initialise
// #endregion
// #region | initialise ... stuff. Don't look at me, I don't work here
var $app = {
data: {
@@ -5940,8 +5967,7 @@ speechSynthesis.getVoices();
break;
case 'invite':
this.speak(
`${
noty.senderUsername
`${noty.senderUsername
} has invited you to ${this.displayLocation(
noty.details.worldId,
noty.details.worldName
@@ -5999,8 +6025,7 @@ speechSynthesis.getVoices();
case 'PortalSpawn':
if (noty.displayName) {
this.speak(
`${
noty.displayName
`${noty.displayName
} has spawned a portal to ${this.displayLocation(
noty.instanceId,
noty.worldName
@@ -6123,8 +6148,7 @@ speechSynthesis.getVoices();
case 'invite':
AppApi.XSNotification(
'VRCX',
`${
noty.senderUsername
`${noty.senderUsername
} has invited you to ${this.displayLocation(
noty.details.worldId,
noty.details.worldName
@@ -6213,8 +6237,7 @@ speechSynthesis.getVoices();
if (noty.displayName) {
AppApi.XSNotification(
'VRCX',
`${
noty.displayName
`${noty.displayName
} has spawned a portal to ${this.displayLocation(
noty.instanceId,
noty.worldName
@@ -7371,7 +7394,8 @@ speechSynthesis.getVoices();
});
};
// App: Friends
// #endregion
// #region | App: Friends
$app.data.friends = new Map();
$app.data.pendingActiveFriends = new Set();
@@ -8354,7 +8378,8 @@ speechSynthesis.getVoices();
});
};
// App: Quick Search
// #endregion
// #region | App: Quick Search
$app.data.quickSearch = '';
$app.data.quickSearchItems = [];
@@ -8442,7 +8467,8 @@ speechSynthesis.getVoices();
}
};
// App: Quick Search User History
// #endregion
// #region | App: Quick Search User History
$app.data.showUserDialogHistory = new Set();
@@ -8464,7 +8490,8 @@ speechSynthesis.getVoices();
this.quickSearchItems = results;
};
// App: Feed
// #endregion
// #region | App: Feed
$app.methods.feedSearch = function (row) {
var value = this.feedTable.search.toUpperCase();
@@ -8979,7 +9006,8 @@ speechSynthesis.getVoices();
}
};
// App: gameLog
// #endregion
// #region | App: gameLog
$app.data.lastLocation = {
date: 0,
@@ -10522,8 +10550,7 @@ speechSynthesis.getVoices();
}
if (this.debugPhotonLogging) {
var displayName = this.getDisplayNameFromPhotonId(senderId);
var feed = `RPC ${displayName} ${
this.photonEventType[eventData.EventType]
var feed = `RPC ${displayName} ${this.photonEventType[eventData.EventType]
}${eventName}`;
console.log('VrcRpc:', feed);
}
@@ -11838,7 +11865,8 @@ speechSynthesis.getVoices();
this.$refs.menu.activeIndex = 'search';
};
// App: Search
// #endregion
// #region | App: Search
$app.data.searchText = '';
$app.data.searchUserResults = [];
@@ -12144,7 +12172,8 @@ speechSynthesis.getVoices();
);
};
// App: Favorite
// #endregion
// #region | App: Favorite
$app.data.favoriteObjects = new Map();
$app.data.favoriteFriends_ = [];
@@ -12430,7 +12459,8 @@ speechSynthesis.getVoices();
return this.favoriteAvatarsSorted;
};
// App: friendLog
// #endregion
// #region | App: friendLog
$app.data.friendLog = new Map();
$app.data.friendLogTable = {
@@ -12765,7 +12795,8 @@ speechSynthesis.getVoices();
});
};
// App: Moderation
// #endregion
// #region | App: Moderation
$app.data.playerModerationTable = {
data: [],
@@ -12850,7 +12881,8 @@ speechSynthesis.getVoices();
});
};
// App: Notification
// #endregion
// #region | App: Notification
$app.data.notificationTable = {
data: [],
@@ -13077,7 +13109,8 @@ speechSynthesis.getVoices();
);
}
// App: Profile + Settings
// #endregion
// #region | App: Profile + Settings
$app.data.configTreeData = [];
$app.data.currentUserTreeData = [];
@@ -14730,7 +14763,8 @@ speechSynthesis.getVoices();
);
};
// App: Dialog
// #endregion
// #region | App: Dialog
var adjustDialogZ = (el) => {
var z = 0;
@@ -14747,7 +14781,8 @@ speechSynthesis.getVoices();
}
};
// App: User Dialog
// #endregion
// #region | App: User Dialog
$app.data.userDialog = {
visible: false,
@@ -15370,7 +15405,8 @@ speechSynthesis.getVoices();
this.updateTimers();
};
// App: player list
// #endregion
// #region | App: player list
API.$on('LOGIN', function () {
$app.currentInstanceUserList.data = [];
@@ -15728,8 +15764,7 @@ speechSynthesis.getVoices();
if (type === 'search') {
try {
var response = await webApiService.execute({
url: `${
this.avatarRemoteDatabaseProvider
url: `${this.avatarRemoteDatabaseProvider
}?${type}=${encodeURIComponent(search)}&n=5000`,
method: 'GET',
headers: {
@@ -16188,7 +16223,8 @@ speechSynthesis.getVoices();
return avatars;
};
// App: World Dialog
// #endregion
// #region | App: World Dialog
$app.data.worldDialog = {
visible: false,
@@ -16832,7 +16868,8 @@ speechSynthesis.getVoices();
return platforms.join(', ');
};
// App: Avatar Dialog
// #endregion
// #region | App: Avatar Dialog
$app.data.avatarDialog = {
visible: false,
@@ -17182,7 +17219,8 @@ speechSynthesis.getVoices();
return platforms.join(', ');
};
// App: Favorite Dialog
// #endregion
// #region | App: Favorite Dialog
$app.data.favoriteDialog = {
visible: false,
@@ -17291,7 +17329,8 @@ speechSynthesis.getVoices();
$app.updateFavoriteDialog(args.params.objectId);
});
// App: Invite Dialog
// #endregion
// #region | App: Invite Dialog
$app.data.inviteDialog = {
visible: false,
@@ -17378,7 +17417,8 @@ speechSynthesis.getVoices();
});
};
// App: Social Status Dialog
// #endregion
// #region | App: Social Status Dialog
$app.data.socialStatusDialog = {
visible: false,
@@ -17440,7 +17480,8 @@ speechSynthesis.getVoices();
D.statusDescription = val.status;
};
// App: Language Dialog
// #endregion
// #region | App: Language Dialog
$app.data.languageDialog = {
visible: false,
@@ -17496,7 +17537,8 @@ speechSynthesis.getVoices();
D.visible = true;
};
// App: Bio Dialog
// #endregion
// #region | App: Bio Dialog
$app.data.bioDialog = {
visible: false,
@@ -17540,7 +17582,8 @@ speechSynthesis.getVoices();
D.visible = true;
};
// App: New Instance Dialog
// #endregion
// #region | App: New Instance Dialog
$app.data.newInstanceDialog = {
visible: false,
@@ -17758,7 +17801,8 @@ speechSynthesis.getVoices();
});
};
// App: Launch Options Dialog
// #endregion
// #region | App: Launch Options Dialog
$app.data.launchOptionsDialog = {
visible: false,
@@ -17809,7 +17853,8 @@ speechSynthesis.getVoices();
D.visible = true;
};
// App: Set World Tags Dialog
// #endregion
// #region | App: Set World Tags Dialog
$app.data.setWorldTagsDialog = {
visible: false,
@@ -17859,7 +17904,8 @@ speechSynthesis.getVoices();
});
};
// App: Notification position
// #endregion
// #region | App: Notification position
$app.data.notificationPositionDialog = {
visible: false
@@ -17872,7 +17918,8 @@ speechSynthesis.getVoices();
this.notificationPositionDialog.visible = true;
};
// App: Noty feed filters
// #endregion
// #region | App: Noty feed filters
$app.data.notyFeedFiltersDialog = {
visible: false
@@ -17885,7 +17932,8 @@ speechSynthesis.getVoices();
this.notyFeedFiltersDialog.visible = true;
};
// App: Wrist feed filters
// #endregion
// #region | App: Wrist feed filters
$app.data.wristFeedFiltersDialog = {
visible: false
@@ -17898,7 +17946,8 @@ speechSynthesis.getVoices();
this.wristFeedFiltersDialog.visible = true;
};
// App: Launch Dialog
// #endregion
// #region | App: Launch Dialog
$app.data.launchDialog = {
visible: false,
@@ -18075,7 +18124,8 @@ speechSynthesis.getVoices();
D.visible = false;
};
// App: Copy To Clipboard
// #endregion
// #region | App: Copy To Clipboard
$app.methods.copyToClipboard = function (text) {
var textArea = document.createElement('textarea');
@@ -18185,7 +18235,8 @@ speechSynthesis.getVoices();
this.copyToClipboard(text);
};
// App: VRCPlus Icons
// #endregion
// #region | App: VRCPlus Icons
API.$on('LOGIN', function () {
$app.VRCPlusIconsTable = [];
@@ -18418,7 +18469,8 @@ speechSynthesis.getVoices();
return 0;
};
// App: Invite Messages
// #endregion
// #region | App: Invite Messages
API.$on('LOGIN', function () {
$app.inviteMessageTable.data = [];
@@ -18482,7 +18534,8 @@ speechSynthesis.getVoices();
});
};
// App: Edit Invite Message Dialog
// #endregion
// #region | App: Edit Invite Message Dialog
$app.data.editInviteMessageDialog = {
visible: false,
@@ -18541,7 +18594,8 @@ speechSynthesis.getVoices();
this.editInviteMessageDialog.visible = false;
};
// App: Edit and Send Invite Response Message Dialog
// #endregion
// #region | App: Edit and Send Invite Response Message Dialog
$app.data.editAndSendInviteResponseDialog = {
visible: false,
@@ -18734,7 +18788,8 @@ speechSynthesis.getVoices();
this.sendInviteResponseConfirmDialog.visible = false;
};
// App: Invite Request Response Message Dialog
// #endregion
// #region | App: Invite Request Response Message Dialog
$app.data.sendInviteRequestResponseDialogVisible = false;
@@ -18759,7 +18814,8 @@ speechSynthesis.getVoices();
this.sendInviteRequestResponseDialogVisible = true;
};
// App: Invite Message Dialog
// #endregion
// #region | App: Invite Message Dialog
$app.data.editAndSendInviteDialog = {
visible: false,
@@ -19099,7 +19155,8 @@ speechSynthesis.getVoices();
this.sendInviteConfirmDialog.visible = false;
};
// App: Invite Request Message Dialog
// #endregion
// #region | App: Invite Request Message Dialog
$app.data.sendInviteRequestDialogVisible = false;
@@ -19126,7 +19183,8 @@ speechSynthesis.getVoices();
this.sendInviteRequestDialogVisible = true;
};
// App: Friends List
// #endregion
// #region | App: Friends List
API.$on('LOGIN', function () {
$app.friendsListTable.data = [];
@@ -22231,7 +22289,8 @@ speechSynthesis.getVoices();
});
};
// App: Previous Instances User Dialog
// #endregion
// #region | App: Previous Instances User Dialog
$app.data.previousInstancesUserDialogTable = {
data: [],
@@ -22330,7 +22389,8 @@ speechSynthesis.getVoices();
});
};
// App: Previous Instances World Dialog
// #endregion
// #region | App: Previous Instances World Dialog
$app.data.previousInstancesWorldDialogTable = {
data: [],
@@ -22413,7 +22473,8 @@ speechSynthesis.getVoices();
});
};
// App: Previous Instance Info Dialog
// #endregion
// #region | App: Previous Instance Info Dialog
$app.data.previousInstanceInfoDialogTable = {
data: [],
@@ -22865,7 +22926,8 @@ speechSynthesis.getVoices();
}
};
// App: world favorite import
// #endregion
// #region | App: world favorite import
$app.data.worldImportDialog = {
visible: false,
@@ -23026,7 +23088,8 @@ speechSynthesis.getVoices();
$app.worldExportLocalFavoriteGroup = null;
});
// App: world favorite export
// #endregion
// #region | App: world favorite export
$app.data.worldExportDialogRef = {};
$app.data.worldExportDialogVisible = false;
@@ -23100,7 +23163,8 @@ speechSynthesis.getVoices();
this.updateWorldExportDialog();
};
// App: avatar favorite import
// #endregion
// #region | App: avatar favorite import
$app.data.avatarImportDialog = {
visible: false,
@@ -23241,7 +23305,8 @@ speechSynthesis.getVoices();
$app.avatarExportFavoriteGroup = null;
});
// App: avatar favorite export
// #endregion
// #region | App: avatar favorite export
$app.data.avatarExportDialogRef = {};
$app.data.avatarExportDialogVisible = false;
@@ -23285,7 +23350,8 @@ speechSynthesis.getVoices();
this.updateAvatarExportDialog();
};
// App: friend favorite import
// #endregion
// #region | App: friend favorite import
$app.data.friendImportDialog = {
visible: false,
@@ -23424,7 +23490,8 @@ speechSynthesis.getVoices();
$app.friendExportFavoriteGroup = null;
});
// App: friend favorite export
// #endregion
// #region | App: friend favorite export
$app.data.friendExportDialogRef = {};
$app.data.friendExportDialogVisible = false;
@@ -23468,7 +23535,8 @@ speechSynthesis.getVoices();
this.updateFriendExportDialog();
};
// App: user dialog notes
// #endregion
// #region | App: user dialog notes
API.saveNote = function (params) {
return this.call('userNotes', {
@@ -23539,7 +23607,8 @@ speechSynthesis.getVoices();
});
};
// App: note export
// #endregion
// #region | App: note export
$app.data.noteExportDialog = {
visible: false,
@@ -23692,7 +23761,8 @@ speechSynthesis.getVoices();
this.avatarRemoteDatabaseProvider = provider;
};
// App: local world favorites
// #endregion
// #region | App: local world favorites
$app.data.localWorldFavoriteGroups = [];
$app.data.localWorldFavoritesList = [];
@@ -24031,7 +24101,8 @@ speechSynthesis.getVoices();
);
};
// App: ChatBox Blacklist
// #endregion
// #region | App: ChatBox Blacklist
$app.data.chatboxBlacklist = [
'NP: ',
'Now Playing',
@@ -24080,7 +24151,8 @@ speechSynthesis.getVoices();
return false;
};
// App: ChatBox User Blacklist
// #endregion
// #region | App: ChatBox User Blacklist
$app.data.chatboxUserBlacklist = new Map();
if (configRepository.getString('VRCX_chatboxUserBlacklist')) {
$app.data.chatboxUserBlacklist = new Map(
@@ -24114,7 +24186,8 @@ speechSynthesis.getVoices();
);
};
// App: Groups
// #endregion
// #region | App: Groups
API.cachedGroups = new Map();
@@ -25510,7 +25583,8 @@ speechSynthesis.getVoices();
);
};
// App: Language
// #endregion
// #region | App: Language
$app.data.appLanguage = 'en';
if (configRepository.getString('VRCX_appLanguage')) {
@@ -25541,6 +25615,8 @@ speechSynthesis.getVoices();
this.updateVRConfigVars();
};
// #endregion
// #region | App: Random unsorted app methods, data structs, API functions, and an API feedback/file analysis event
API.$on('USER:FEEDBACK', function (args) {
if (args.params.userId === this.currentUser.id) {
$app.currentUserFeedbackData = buildTreeData(args.json);
@@ -25694,7 +25770,9 @@ speechSynthesis.getVoices();
}
API.getFileAnalysis({ fileId, version });
};
// #endregion
$app = new Vue($app);
window.$app = $app;
})();
// #endregion