fix: debug with type error checks

This commit is contained in:
pa
2025-07-16 11:04:54 +09:00
committed by Natsumi
parent 6d693e278c
commit 39381de29e
16 changed files with 188 additions and 105 deletions

View File

@@ -49,7 +49,7 @@ const avatarReq = {
}); });
}, },
/** /**
* @param {{ id: string, releaseStatus?: 'public' | 'private', name?: string, description?: string }} params * @param {{ id: string, releaseStatus?: 'public' | 'private', name?: string, description?: string,tags?: string[] }} params
* @returns {Promise<{json: any, params}>} * @returns {Promise<{json: any, params}>}
*/ */
saveAvatar(params) { saveAvatar(params) {

View File

@@ -34,12 +34,7 @@ const favoriteReq = {
}, },
/** /**
* @param {{ * @type {import('../types/favorite').addFavorite}
* type: string,
* favoriteId: string (objectId),
* tags: string
* }} params
* @return { Promise<{json: any, params}> }
*/ */
addFavorite(params) { addFavorite(params) {
return request('favorites', { return request('favorites', {

View File

@@ -75,7 +75,7 @@ const groupReq = {
/** /**
* *
* @param {{ groupId: string }} params * @param {{ groupId: string }} params
* @return { Promise<{json: any, params}> } * @return { Promise<{json: any, ref: any, cache?: boolean, params}> }
*/ */
getCachedGroup(params) { getCachedGroup(params) {
const groupStore = useGroupStore(); const groupStore = useGroupStore();

View File

@@ -52,8 +52,7 @@ const instanceReq = {
}, },
/** /**
* @param {{ worldId: string, instanceId: string, shortName: string }} instance * @type {import('../types/instance').getInstanceShortName}
* @returns {Promise<{instance, json: T, params: {}}>}
*/ */
getInstanceShortName(instance) { getInstanceShortName(instance) {
const params = {}; const params = {};

View File

@@ -59,7 +59,8 @@ const miscReq = {
/** /**
* @param {{ * @param {{
* fileId: string, * fileId: string,
* version: number * version: number,
* variant: string
* }} params * }} params
* @return { Promise<{json: any, params}> } * @return { Promise<{json: any, params}> }
*/ */

View File

@@ -3,8 +3,7 @@ import { useWorldStore } from '../stores';
const worldReq = { const worldReq = {
/** /**
* @param {{worldId: string}} params * @type {import('../types/world').getWorld}
* @returns {Promise<{json: any, params}>}
*/ */
getWorld(params) { getWorld(params) {
const worldStore = useWorldStore(); const worldStore = useWorldStore();
@@ -22,7 +21,7 @@ const worldReq = {
/** /**
* @param {{worldId: string}} params * @param {{worldId: string}} params
* @returns {Promise<{json: any, params}>} * @returns {Promise<{json: any, ref: any, cache?: boolean, params}>}
*/ */
getCachedWorld(params) { getCachedWorld(params) {
const worldStore = useWorldStore(); const worldStore = useWorldStore();

View File

@@ -274,7 +274,7 @@
:type="avatarDialog.isBlocked ? 'danger' : 'default'" :type="avatarDialog.isBlocked ? 'danger' : 'default'"
icon="el-icon-more" icon="el-icon-more"
circle></el-button> circle></el-button>
<el-dropdown-menu v-slot="dropdown"> <el-dropdown-menu>
<el-dropdown-item icon="el-icon-refresh" command="Refresh">{{ <el-dropdown-item icon="el-icon-refresh" command="Refresh">{{
t('dialog.avatar.actions.refresh') t('dialog.avatar.actions.refresh')
}}</el-dropdown-item> }}</el-dropdown-item>
@@ -481,7 +481,7 @@
icon="el-icon-s-order" icon="el-icon-s-order"
size="mini" size="mini"
circle></el-button> circle></el-button>
<el-dropdown-menu v-slot="dropdown"> <el-dropdown-menu>
<el-dropdown-item @click.native="copyAvatarId(avatarDialog.id)">{{ <el-dropdown-item @click.native="copyAvatarId(avatarDialog.id)">{{
t('dialog.avatar.info.copy_id') t('dialog.avatar.info.copy_id')
}}</el-dropdown-item> }}</el-dropdown-item>
@@ -793,7 +793,7 @@
showSetAvatarTagsDialog(D.id); showSetAvatarTagsDialog(D.id);
break; break;
case 'Change Styles and Author Tags': case 'Change Styles and Author Tags':
showSetAvatarStylesDialog(D.id); showSetAvatarStylesDialog();
break; break;
case 'Download Unity Package': case 'Download Unity Package':
openExternalLink(replaceVrcPackageUrl(avatarDialog.value.ref.unityPackageUrl)); openExternalLink(replaceVrcPackageUrl(avatarDialog.value.ref.unityPackageUrl));
@@ -1126,8 +1126,8 @@
}); });
return; return;
} }
miscRequest.getFileAnalysis({ fileId, version, variant, avatarId }).then((args) => { miscRequest.getFileAnalysis({ fileId, version, variant }).then((args) => {
if (!avatarDialog.value.visible || avatarDialog.value.id !== args.params.avatarId) { if (!avatarDialog.value.visible || avatarDialog.value.id !== avatarId) {
return; return;
} }
const ref = args.json; const ref = args.json;
@@ -1242,8 +1242,9 @@
function onFileChangeAvatarGallery(e) { function onFileChangeAvatarGallery(e) {
const clearFile = function () { const clearFile = function () {
if (document.querySelector('#AvatarGalleryUploadButton')) { const fileInput = /** @type {HTMLInputElement} */ (document.querySelector('#AvatarGalleryUploadButton'));
document.querySelector('#AvatarGalleryUploadButton').value = ''; if (fileInput) {
fileInput.value = '';
} }
}; };
const files = e.target.files || e.dataTransfer.files; const files = e.target.files || e.dataTransfer.files;
@@ -1270,16 +1271,16 @@
const r = new FileReader(); const r = new FileReader();
r.onload = function () { r.onload = function () {
avatarDialog.value.galleryLoading = true; avatarDialog.value.galleryLoading = true;
const base64Body = btoa(r.result); const base64Body = btoa(r.result.toString());
avatarRequest avatarRequest
.uploadAvatarGalleryImage(base64Body, avatarDialog.value.id) .uploadAvatarGalleryImage(base64Body, avatarDialog.value.id)
.then((args) => { .then(async (args) => {
$message({ $message({
message: t('message.avatar_gallery.uploaded'), message: t('message.avatar_gallery.uploaded'),
type: 'success' type: 'success'
}); });
console.log(args); console.log(args);
avatarDialog.value.galleryImages = getAvatarGallery(avatarDialog.value.id); avatarDialog.value.galleryImages = await getAvatarGallery(avatarDialog.value.id);
return args; return args;
}) })
.finally(() => { .finally(() => {
@@ -1323,12 +1324,12 @@
} else { } else {
moveArrayItem(fileIds, index, index + 1); moveArrayItem(fileIds, index, index + 1);
} }
avatarRequest.setAvatarGalleryOrder(fileIds).then((args) => { avatarRequest.setAvatarGalleryOrder(fileIds).then(async (args) => {
$message({ $message({
message: t('message.avatar_gallery.reordered'), message: t('message.avatar_gallery.reordered'),
type: 'success' type: 'success'
}); });
avatarDialog.value.galleryImages = getAvatarGallery(avatarDialog.value.id); avatarDialog.value.galleryImages = await getAvatarGallery(avatarDialog.value.id);
return args; return args;
}); });
} }

View File

@@ -113,8 +113,9 @@
function onFileChangeAvatarImage(e) { function onFileChangeAvatarImage(e) {
const clearFile = function () { const clearFile = function () {
if (document.querySelector('#AvatarImageUploadButton')) { const fileInput = /** @type{HTMLInputElement} */ (document.querySelector('#AvatarImageUploadButton'));
document.querySelector('#AvatarImageUploadButton').value = ''; if (fileInput) {
fileInput.value = '';
} }
}; };
const files = e.target.files || e.dataTransfer.files; const files = e.target.files || e.dataTransfer.files;
@@ -145,10 +146,10 @@
const r = new FileReader(); const r = new FileReader();
r.onload = async function (file) { r.onload = async function (file) {
try { try {
const base64File = await resizeImageToFitLimits(btoa(r.result)); const base64File = await resizeImageToFitLimits(btoa(r.result.toString()));
// 10MB // 10MB
const fileMd5 = await genMd5(base64File); const fileMd5 = await genMd5(base64File);
const fileSizeInBytes = parseInt(file.total, 10); const fileSizeInBytes = parseInt(file.total.toString(), 10);
const base64SignatureFile = await genSig(base64File); const base64SignatureFile = await genSig(base64File);
const signatureMd5 = await genMd5(base64SignatureFile); const signatureMd5 = await genMd5(base64SignatureFile);
const signatureSizeInBytes = parseInt(await genLength(base64SignatureFile), 10); const signatureSizeInBytes = parseInt(await genLength(base64SignatureFile), 10);
@@ -237,7 +238,7 @@
if (json.status !== 200) { if (json.status !== 200) {
changeAvatarImageDialogLoading.value = false; changeAvatarImageDialogLoading.value = false;
$throw('Avatar image upload failed', json, params.url); $throw(json.status, 'Avatar image upload failed', params.url);
} }
const args = { const args = {
json, json,
@@ -290,7 +291,7 @@
if (json.status !== 200) { if (json.status !== 200) {
changeAvatarImageDialogLoading.value = false; changeAvatarImageDialogLoading.value = false;
$throw('Avatar image upload failed', json, params.url); $throw(json.status, 'Avatar image upload failed', params.url);
} }
const args = { const args = {
json, json,

View File

@@ -557,8 +557,9 @@
function onFileChangeGallery(e) { function onFileChangeGallery(e) {
const clearFile = function () { const clearFile = function () {
if (document.querySelector('#GalleryUploadButton')) { const fileInput = /** @type {HTMLInputElement} */ (document.querySelector('#GalleryUploadButton'));
document.querySelector('#GalleryUploadButton').value = ''; if (fileInput) {
fileInput.value = '';
} }
}; };
const files = e.target.files || e.dataTransfer.files; const files = e.target.files || e.dataTransfer.files;
@@ -584,7 +585,7 @@
} }
const r = new FileReader(); const r = new FileReader();
r.onload = function () { r.onload = function () {
const base64Body = btoa(r.result); const base64Body = btoa(r.result.toString());
vrcPlusImageRequest.uploadGalleryImage(base64Body).then((args) => { vrcPlusImageRequest.uploadGalleryImage(base64Body).then((args) => {
handleGalleryImageAdd(args); handleGalleryImageAdd(args);
proxy.$message({ proxy.$message({
@@ -655,8 +656,9 @@
function onFileChangeVRCPlusIcon(e) { function onFileChangeVRCPlusIcon(e) {
const clearFile = function () { const clearFile = function () {
if (document.querySelector('#VRCPlusIconUploadButton')) { const fileInput = /** @type {HTMLInputElement} */ (document.querySelector('#VRCPlusIconUploadButton'));
document.querySelector('#VRCPlusIconUploadButton').value = ''; if (fileInput) {
fileInput.value = '';
} }
}; };
const files = e.target.files || e.dataTransfer.files; const files = e.target.files || e.dataTransfer.files;
@@ -682,7 +684,7 @@
} }
const r = new FileReader(); const r = new FileReader();
r.onload = function () { r.onload = function () {
const base64Body = btoa(r.result); const base64Body = btoa(r.result.toString());
vrcPlusIconRequest.uploadVRCPlusIcon(base64Body).then((args) => { vrcPlusIconRequest.uploadVRCPlusIcon(base64Body).then((args) => {
if (Object.keys(VRCPlusIconsTable.value).length !== 0) { if (Object.keys(VRCPlusIconsTable.value).length !== 0) {
VRCPlusIconsTable.value.unshift(args.json); VRCPlusIconsTable.value.unshift(args.json);
@@ -777,8 +779,9 @@
function onFileChangeEmoji(e) { function onFileChangeEmoji(e) {
const clearFile = function () { const clearFile = function () {
if (document.querySelector('#EmojiUploadButton')) { const fileInput = /** @type {HTMLInputElement} */ (document.querySelector('#EmojiUploadButton'));
document.querySelector('#EmojiUploadButton').value = ''; if (fileInput) {
fileInput.value = '';
} }
}; };
const files = e.target.files || e.dataTransfer.files; const files = e.target.files || e.dataTransfer.files;
@@ -818,10 +821,10 @@
if (emojiAnimLoopPingPong.value) { if (emojiAnimLoopPingPong.value) {
params.loopStyle = 'pingpong'; params.loopStyle = 'pingpong';
} }
const base64Body = btoa(r.result); const base64Body = btoa(r.result.toString());
vrcPlusImageRequest.uploadEmoji(base64Body, params).then((args) => { vrcPlusImageRequest.uploadEmoji(base64Body, params).then((args) => {
if (Object.keys(emojiTable).length !== 0) { if (Object.keys(emojiTable.value).length !== 0) {
emojiTable.unshift(args.json); emojiTable.value.unshift(args.json);
} }
proxy.$message({ proxy.$message({
message: t('message.emoji.uploaded'), message: t('message.emoji.uploaded'),
@@ -873,8 +876,9 @@
function onFileChangeSticker(e) { function onFileChangeSticker(e) {
const clearFile = function () { const clearFile = function () {
if (document.querySelector('#StickerUploadButton')) { const fileInput = /** @type {HTMLInputElement} */ (document.querySelector('#StickerUploadButton'));
document.querySelector('#StickerUploadButton').value = ''; if (fileInput) {
fileInput.value = '';
} }
}; };
const files = e.target.files || e.dataTransfer.files; const files = e.target.files || e.dataTransfer.files;
@@ -904,7 +908,7 @@
tag: 'sticker', tag: 'sticker',
maskTag: 'square' maskTag: 'square'
}; };
const base64Body = btoa(r.result); const base64Body = btoa(r.result.toString());
vrcPlusImageRequest.uploadSticker(base64Body, params).then((args) => { vrcPlusImageRequest.uploadSticker(base64Body, params).then((args) => {
handleStickerAdd(args); handleStickerAdd(args);
proxy.$message({ proxy.$message({
@@ -939,8 +943,9 @@
function onFileChangePrint(e) { function onFileChangePrint(e) {
const clearFile = function () { const clearFile = function () {
if (document.querySelector('#PrintUploadButton')) { const fileInput = /** @type {HTMLInputElement} */ (document.querySelector('#PrintUploadButton'));
document.querySelector('#PrintUploadButton').value = ''; if (fileInput) {
fileInput.value = '';
} }
}; };
const files = e.target.files || e.dataTransfer.files; const files = e.target.files || e.dataTransfer.files;
@@ -975,7 +980,7 @@
// worldId: '', // worldId: '',
timestamp timestamp
}; };
const base64Body = btoa(r.result); const base64Body = btoa(r.result.toString());
const cropWhiteBorder = printCropBorder.value; const cropWhiteBorder = printCropBorder.value;
vrcPlusImageRequest.uploadPrint(base64Body, cropWhiteBorder, params).then((args) => { vrcPlusImageRequest.uploadPrint(base64Body, cropWhiteBorder, params).then((args) => {
proxy.$message({ proxy.$message({

View File

@@ -84,8 +84,9 @@
function onFileChangeGallery(e) { function onFileChangeGallery(e) {
const clearFile = function () { const clearFile = function () {
if (document.querySelector('#GalleryUploadButton')) { const fileInput = /** @type{HTMLInputElement} */ (document.querySelector('#GalleryUploadButton'));
document.querySelector('#GalleryUploadButton').value = ''; if (fileInput) {
fileInput.value = '';
} }
}; };
const files = e.target.files || e.dataTransfer.files; const files = e.target.files || e.dataTransfer.files;
@@ -111,7 +112,7 @@
} }
const r = new FileReader(); const r = new FileReader();
r.onload = function () { r.onload = function () {
const base64Body = btoa(r.result); const base64Body = btoa(r.result.toString());
vrcPlusImageRequest.uploadGalleryImage(base64Body).then((args) => { vrcPlusImageRequest.uploadGalleryImage(base64Body).then((args) => {
handleGalleryImageAdd(args); handleGalleryImageAdd(args);
$message({ $message({

View File

@@ -90,7 +90,7 @@
watch( watch(
() => VRCXUpdateDialog, () => VRCXUpdateDialog,
(newVal) => { (newVal) => {
if (newVal.visible) { if (newVal.value.visible) {
nextTick(() => { nextTick(() => {
adjustDialogZ(VRCXUpdateDialogRef.value.$el); adjustDialogZ(VRCXUpdateDialogRef.value.$el);
}); });

View File

@@ -3,15 +3,6 @@ export type getFavorites = (params: { n: number; offset: number }) => Promise<{
params: { n: number; offset: number }; params: { n: number; offset: number };
}>; }>;
interface getFavoritesResponseItem {
favoriteId: string;
id: string;
tags: string[];
type: 'world' | 'friend' | 'avatar';
}
type getFavoritesResponseList = getFavoritesResponseItem[] | undefined;
export type getFavoriteAvatars = (params: { export type getFavoriteAvatars = (params: {
n: number; n: number;
offset: number; offset: number;
@@ -21,6 +12,36 @@ export type getFavoriteAvatars = (params: {
params: { n: number; offset: number; tag: string }; params: { n: number; offset: number; tag: string };
}>; }>;
export type getFavoriteWorlds = (params: {
n: number;
offset: number;
}) => Promise<{
json: getFavoriteWorldsResponseList;
params: { n: number; offset: number };
}>;
export type addFavorite = (params: {
type: string;
favoriteId: string;
tags: string;
}) => Promise<{
json: addFavoriteResponse;
params: {
type: string;
favoriteId: string;
tags: string;
};
}>;
interface getFavoritesResponseItem {
favoriteId: string;
id: string;
tags: string[];
type: string;
}
type getFavoritesResponseList = getFavoritesResponseItem[] | undefined;
interface UnityPackage { interface UnityPackage {
assetVersion: number; assetVersion: number;
created_at: string; created_at: string;
@@ -46,7 +67,7 @@ interface Styles {
secondary: null; secondary: null;
} }
interface AvatarFavoriteItem { interface getFavoriteAvatarsResponseItem {
acknowledgements?: null | string; acknowledgements?: null | string;
authorId: string; authorId: string;
authorName: string; authorName: string;
@@ -73,14 +94,6 @@ interface AvatarFavoriteItem {
type getFavoriteAvatarsResponseList = getFavoriteAvatarsResponseItem[]; type getFavoriteAvatarsResponseList = getFavoriteAvatarsResponseItem[];
export type getFavoriteWorlds = (params: {
n: number;
offset: number;
}) => Promise<{
json: getFavoriteWorldsResponseList;
params: { n: number; offset: number };
}>;
interface getFavoriteWorldsResponseItem { interface getFavoriteWorldsResponseItem {
id: string; id: string;
name: string; name: string;
@@ -109,3 +122,10 @@ interface getFavoriteWorldsResponseItem {
} }
type getFavoriteWorldsResponseList = getFavoriteWorldsResponseItem[]; type getFavoriteWorldsResponseList = getFavoriteWorldsResponseItem[];
interface addFavoriteResponse {
favoriteId: string;
id: string;
type: 'world' | 'friend' | 'avatar';
tags: string[];
}

View File

@@ -79,37 +79,6 @@ declare global {
}; };
} }
declare const API: {
// HTTP request methods
$bulk: (options: any, args?: any) => Promise<any>;
bulk: (options: any) => Promise<any>;
// Event system
$emit: (event: string, ...args: any[]) => void;
$off: (event: string, handler?: Function) => void;
$on: (event: string, handler: Function) => void;
// Debug functions
debug: boolean | ((message: any) => void);
debugCurrentUserDiff: boolean | ((data: any) => void);
debugFriendState: boolean | ((data: any) => void);
debugGameLog: boolean | ((data: any) => void);
debugPhotonLogging: boolean | ((data: any) => void);
debugUserDiff: boolean | ((data: any) => void);
debugWebRequests: boolean | ((data: any) => void);
debugWebSocket: boolean | ((data: any) => void);
// Configuration
dontLogMeOut: boolean;
endpointDomain: string;
endpointDomainVrchat: string;
websocketDomain: string;
websocketDomainVrchat: string;
// Error handling
errorNoty: (error: any) => void;
};
const CefSharp: { const CefSharp: {
PostMessage: (message: any) => void; PostMessage: (message: any) => void;
BindObjectAsync: (...args: string[]) => Promise<any>; BindObjectAsync: (...args: string[]) => Promise<any>;
@@ -419,11 +388,37 @@ declare global {
setCookies(cookie: string): Promise<void>; setCookies(cookie: string): Promise<void>;
execute(options: { execute(options: {
url: string; url: string;
method: string; method?: string;
uploadFilePUT?: boolean;
fileData?: string;
fileMIME?: string;
headers?: Record<string, string>; headers?: Record<string, string>;
data?: any; data?: any;
}): Promise<{ status: number; data: string }>; }): Promise<{ status: number; data: string }>;
}; };
const electron: {
openFileDialog: () => Promise<string>;
openDirectoryDialog: () => Promise<string>;
desktopNotification: (
displayName: string,
body?: string,
image?: string
) => Promise<void>;
onWindowPositionChanged: (
Function: (event: any, position: { x: number; y: number }) => void
) => void;
onWindowSizeChanged: (
Function: (
event: any,
size: { width: number; height: number }
) => void
) => void;
onWindowStateChange: (
Function: (event: any, state: { windowState: any }) => void
) => void;
restartApp: () => Promise<void>;
};
} }
export {}; export {};

View File

@@ -1,9 +1,9 @@
export type getGroup = (params: { export type getGroup = (params: {
groupId: string; groupId: string;
includeRoles: boolean; includeRoles?: boolean;
}) => Promise<{ }) => Promise<{
json: getGroupResponse; json: getGroupResponse;
params: { groupId: string; includeRoles: boolean }; params: { groupId: string; includeRoles?: boolean };
}>; }>;
interface Group { interface Group {

View File

@@ -6,6 +6,16 @@ export type getInstance = (params: {
params: { worldId: string; instanceId: string }; params: { worldId: string; instanceId: string };
}>; }>;
export type getInstanceShortName = (instance: {
worldId: string;
instanceId: string;
shortName?: string;
}) => Promise<{
json: getInstanceShortNameResponse;
instance: { worldId: string; instanceId: string };
params?: { shortName: string };
}>;
interface getInstanceResponse { interface getInstanceResponse {
active: boolean; active: boolean;
ageGate: boolean; ageGate: boolean;
@@ -91,3 +101,8 @@ interface WorldUnityPackage {
unityVersion: string; unityVersion: string;
worldSignature: string; worldSignature: string;
} }
interface getInstanceShortNameResponse {
secureName: string;
shortName: string;
}

51
src/types/world.d.ts vendored Normal file
View File

@@ -0,0 +1,51 @@
export type getWorld = (params: { worldId: string }) => Promise<{
json: getWorldResponse;
params: { worldId: string };
}>;
interface getWorldResponse {
authorId: string;
authorName: string;
capacity: number;
created_at: string;
defaultContentSettings: Record<string, unknown>;
description: string;
favorites: number;
featured: boolean;
heat: number;
id: string;
imageUrl: string;
instances: any[];
labsPublicationDate: string;
name: string;
occupants: number;
organization: string;
popularity: number;
previewYoutubeId: string | null;
privateOccupants: number;
publicOccupants: number;
publicationDate: string;
recommendedCapacity: number;
releaseStatus: string;
tags: string[];
thumbnailImageUrl: string;
udonProducts: any[];
unityPackages: UnityPackage[];
updated_at: string;
urlList: any[];
version: number;
visits: number;
}
interface UnityPackage {
assetUrl: string;
assetUrlObject: Record<string, unknown>;
assetVersion: number;
created_at: string;
id: string;
platform: string;
pluginUrl: string;
pluginUrlObject: Record<string, unknown>;
unitySortNumber: number;
unityVersion: string;
}