修改扩展导入失败提示,修改扩展模板为esm,添加cost和getIndex的类型注释,跟进并修复其他类型注释

This commit is contained in:
nonameShijian 2024-04-14 01:11:00 +08:00
parent dcb703b240
commit 6bb7e44704
5 changed files with 151 additions and 40 deletions

View File

@ -517,72 +517,86 @@ export class Game {
* @overload * @overload
* @param { 'character' } type * @param { 'character' } type
* @param {( * @param {(
* lib: Library, * lib: InstanceType<typeof import('../library/index.js').Library>,
* game: typeof Game, * game: InstanceType<typeof Game>,
* ui: UI, * ui: InstanceType<typeof import('../ui/index.js').UI>,
* get: Get, * get: InstanceType<typeof import('../get/index.js').Get>,
* ai: AI, * ai: InstanceType<typeof import('../ai/index.js').AI>,
* _status: Status * _status: InstanceType<typeof import('../status/index.js').status>
* ) => importCharacterConfig } content * ) => importCharacterConfig } content
* @param {*} [url] * @param {*} [url]
*/ */
import(type: 'character', content: (lib: any, game: typeof Game, ui: any, get: any, ai: any, _status: any) => importCharacterConfig, url?: any): any; import(type: 'character', content: (lib: InstanceType<typeof import('../library/index.js').Library>, game: InstanceType<typeof Game>, ui: InstanceType<typeof import('../ui/index.js').UI>, get: InstanceType<typeof import('../get/index.js').Get>, ai: InstanceType<typeof import('../ai/index.js').AI>, _status: InstanceType<typeof import('../status/index.js').status>) => importCharacterConfig, url?: any): any;
/** /**
* @overload * @overload
* @param { 'card' } type * @param { 'card' } type
* @param {( * @param {(
* lib: Library, * lib: InstanceType<typeof import('../library/index.js').Library>,
* game: typeof Game, * game: InstanceType<typeof Game>,
* ui: UI, * ui: InstanceType<typeof import('../ui/index.js').UI>,
* get: Get, * get: InstanceType<typeof import('../get/index.js').Get>,
* ai: AI, * ai: InstanceType<typeof import('../ai/index.js').AI>,
* _status: Status * _status: InstanceType<typeof import('../status/index.js').status>
* ) => importCardConfig } content * ) => importCardConfig } content
* @param {*} [url] * @param {*} [url]
*/ */
import(type: 'card', content: (lib: any, game: typeof Game, ui: any, get: any, ai: any, _status: any) => importCardConfig, url?: any): any; import(type: 'card', content: (lib: InstanceType<typeof import('../library/index.js').Library>, game: InstanceType<typeof Game>, ui: InstanceType<typeof import('../ui/index.js').UI>, get: InstanceType<typeof import('../get/index.js').Get>, ai: InstanceType<typeof import('../ai/index.js').AI>, _status: InstanceType<typeof import('../status/index.js').status>) => importCardConfig, url?: any): any;
/** /**
* @overload * @overload
* @param { 'mode' } type * @param { 'mode' } type
* @param {( * @param {(
* lib: Library, * lib: InstanceType<typeof import('../library/index.js').Library>,
* game: typeof Game, * game: InstanceType<typeof Game>,
* ui: UI, * ui: InstanceType<typeof import('../ui/index.js').UI>,
* get: Get, * get: InstanceType<typeof import('../get/index.js').Get>,
* ai: AI, * ai: InstanceType<typeof import('../ai/index.js').AI>,
* _status: Status * _status: InstanceType<typeof import('../status/index.js').status>
* ) => importModeConfig } content * ) => importModeConfig } content
* @param {*} [url] * @param {*} [url]
*/ */
import(type: 'mode', content: (lib: any, game: typeof Game, ui: any, get: any, ai: any, _status: any) => importModeConfig, url?: any): any; import(type: 'mode', content: (lib: InstanceType<typeof import('../library/index.js').Library>, game: InstanceType<typeof Game>, ui: InstanceType<typeof import('../ui/index.js').UI>, get: InstanceType<typeof import('../get/index.js').Get>, ai: InstanceType<typeof import('../ai/index.js').AI>, _status: InstanceType<typeof import('../status/index.js').status>) => importModeConfig, url?: any): any;
/** /**
* @overload * @overload
* @param { 'player' } type * @param { 'player' } type
* @param {( * @param {(
* lib: Library, * lib: InstanceType<typeof import('../library/index.js').Library>,
* game: typeof Game, * game: InstanceType<typeof Game>,
* ui: UI, * ui: InstanceType<typeof import('../ui/index.js').UI>,
* get: Get, * get: InstanceType<typeof import('../get/index.js').Get>,
* ai: AI, * ai: InstanceType<typeof import('../ai/index.js').AI>,
* _status: Status * _status: InstanceType<typeof import('../status/index.js').status>
* ) => importPlayerConfig } content * ) => importPlayerConfig } content
* @param {*} [url] * @param {*} [url]
*/ */
import(type: 'player', content: (lib: any, game: typeof Game, ui: any, get: any, ai: any, _status: any) => importPlayerConfig, url?: any): any; import(type: 'player', content: (lib: InstanceType<typeof import('../library/index.js').Library>, game: InstanceType<typeof Game>, ui: InstanceType<typeof import('../ui/index.js').UI>, get: InstanceType<typeof import('../get/index.js').Get>, ai: InstanceType<typeof import('../ai/index.js').AI>, _status: InstanceType<typeof import('../status/index.js').status>) => importPlayerConfig, url?: any): any;
/** /**
* @overload * @overload
* @param { 'extension' } type * @param { 'extension' } type
* @param {( * @param {(
* lib: Library, * lib: InstanceType<typeof import('../library/index.js').Library>,
* game: typeof Game, * game: InstanceType<typeof Game>,
* ui: UI, * ui: InstanceType<typeof import('../ui/index.js').UI>,
* get: Get, * get: InstanceType<typeof import('../get/index.js').Get>,
* ai: AI, * ai: InstanceType<typeof import('../ai/index.js').AI>,
* _status: Status * _status: InstanceType<typeof import('../status/index.js').status>
* ) => importExtensionConfig } content * ) => importExtensionConfig } content
* @param {*} [url] * @param {*} [url]
*/ */
import(type: 'extension', content: (lib: any, game: typeof Game, ui: any, get: any, ai: any, _status: any) => importExtensionConfig, url?: any): any; import(type: 'extension', content: (lib: InstanceType<typeof import('../library/index.js').Library>, game: InstanceType<typeof Game>, ui: InstanceType<typeof import('../ui/index.js').UI>, get: InstanceType<typeof import('../get/index.js').Get>, ai: InstanceType<typeof import('../ai/index.js').AI>, _status: InstanceType<typeof import('../status/index.js').status>) => importExtensionConfig, url?: any): any;
/**
* @overload
* @param { 'play' } type
* @param {(
* lib: InstanceType<typeof import('../library/index.js').Library>,
* game: InstanceType<typeof Game>,
* ui: InstanceType<typeof import('../ui/index.js').UI>,
* get: InstanceType<typeof import('../get/index.js').Get>,
* ai: InstanceType<typeof import('../ai/index.js').AI>,
* _status: InstanceType<typeof import('../status/index.js').status>
* ) => importPlayConfig } content
* @param {*} [url]
*/
import(type: 'play', content: (lib: InstanceType<typeof import('../library/index.js').Library>, game: InstanceType<typeof Game>, ui: InstanceType<typeof import('../ui/index.js').UI>, get: InstanceType<typeof import('../get/index.js').Get>, ai: InstanceType<typeof import('../ai/index.js').AI>, _status: InstanceType<typeof import('../status/index.js').status>) => importPlayConfig, url?: any): any;
loadExtension(object: any): Promise<any>; loadExtension(object: any): Promise<any>;
/** /**
* *
@ -611,9 +625,9 @@ export class Game {
removeFile: ((filename: string, callback?: ((e: Error) => void) | undefined) => void) | undefined; removeFile: ((filename: string, callback?: ((e: Error) => void) | undefined) => void) | undefined;
/** /**
* *
* @type { undefined | ((dir: string, success: (folders: string[], files: string[]) => any, failure: (e: Error) => void) => void) } * @type { undefined | ((dir: string, success: (folders: string[], files: string[]) => any, failure?: (e: Error) => void) => void) }
*/ */
getFileList: ((dir: string, success: (folders: string[], files: string[]) => any, failure: (e: Error) => void) => void) | undefined; getFileList: ((dir: string, success: (folders: string[], files: string[]) => any, failure?: ((e: Error) => void) | undefined) => void) | undefined;
/** /**
* *
* @type { undefined | ((list: string | string[], callback: Function, file?: boolean) => void) } * @type { undefined | ((list: string | string[], callback: Function, file?: boolean) => void) }
@ -959,8 +973,9 @@ export class Game {
addGlobalSkill(skill: string, player?: any): boolean; addGlobalSkill(skill: string, player?: any): boolean;
/** /**
* @param { string } skill * @param { string } skill
* @param { lib.element.Player } player
*/ */
removeGlobalSkill(skill: string): void; removeGlobalSkill(skill: string, player: lib.element.Player): void;
resetSkills(): void; resetSkills(): void;
/** /**
* @param { string } extensionName * @param { string } extensionName
@ -1371,6 +1386,7 @@ export type GameHistory = {
everything: GameEventPromise[]; everything: GameEventPromise[];
}; };
export type Video = { export type Video = {
name?: string;
type: string; type: string;
player?: string; player?: string;
content?: string | any[]; content?: string | any[];

View File

@ -896,6 +896,7 @@ export class Player extends HTMLDivElement {
lose(...args: any[]): any; lose(...args: any[]): any;
damage(...args: any[]): any; damage(...args: any[]): any;
recover(...args: any[]): any; recover(...args: any[]): any;
recoverTo(...args: any[]): any;
doubleDraw(): any; doubleDraw(): any;
loseHp(num: any): any; loseHp(num: any): any;
loseMaxHp(...args: any[]): any; loseMaxHp(...args: any[]): any;

View File

@ -4043,7 +4043,10 @@ export class Library {
readonly nodews: Element.NodeWS; readonly nodews: Element.NodeWS;
}; };
card: { card: {
list: never[]; /**
* @type { [CardBaseUIData['suit'], CardBaseUIData['number'], string][] }
*/
list: [CardBaseUIData['suit'], CardBaseUIData['number'], string][];
cooperation_damage: { cooperation_damage: {
fullskin: boolean; fullskin: boolean;
}; };

View File

@ -45,6 +45,24 @@ export class status {
* @type { boolean | void } * @type { boolean | void }
*/ */
connectMode: boolean | void; connectMode: boolean | void;
/**
* @type { boolean | void }
*/
importingExtension: boolean | void;
/**
* @type { Promise<any>[] | void }
*/
extensionLoaded: Promise<any>[] | void;
/**
* @type { Promise<any>[] | void }
*/
extensionLoading: Promise<any>[] | void;
/**
* @type { { [key: string]: Promise<any>[] } | void }
*/
importing: void | {
[key: string]: Promise<any>[];
};
} }
export let _status: status; export let _status: status;
export function setStatus(instance?: status | undefined): void; export function setStatus(instance?: status | undefined): void;

View File

@ -195,7 +195,6 @@ declare interface importCharacterConfig {
* *
*/ */
game?: SMap<any>; game?: SMap<any>;
/** /**
* *
* *
@ -538,6 +537,80 @@ declare interface importExtensionConfig {
[key: string]: any; [key: string]: any;
} }
/**
*
*/
declare interface importPlayConfig {
/** 扩展名 */
name: string;
arenaReady?: Function;
/**
*
*/
video?: Function;
/**
*
* */
skill?: SMap<Skill>;
/**
*
*
* */
card?: SMap<any>;
translate?: SMap<string>;
/**
* lib.element
*
*
*/
element?: SMap<any>;
/**
* ai
*
*
*/
ai?: SMap<any>;
/**
* ui
*
*
*/
ui?: SMap<any>;
/**
* game
*
*
*/
game?: SMap<any>;
/**
*
*
* get
*
*/
get?: SMap<any>;
/**
*
*
*
*
* "帮助条目":
* ```jsx
* <ul>
* <li>1-1
* <li>1-2
* </ul>
* <ol>
* <li>2-1
* <li>2-2
* </ul>
* ```
* (modeextensioncard卡包character武将包)
*/
help?: SMap<string>;
[key: string]: any;
}
/** /**
* *
* *