fix:plugin引入类型检查

This commit is contained in:
ShakeFlower 2025-04-25 09:04:32 +08:00
parent a76b68ef87
commit 2ef2b89985
3 changed files with 14 additions and 5 deletions

View File

@ -1101,7 +1101,7 @@ editor_file = function (editor, callback) {
for (var id_ in plmap) { for (var id_ in plmap) {
plraw = plraw.replace('"' + id_ + '"', plmap[id_]) plraw = plraw.replace('"' + id_ + '"', plmap[id_])
} }
var datastr = '/// <reference path="../runtime.d.ts" />\nvar plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = \n'; var datastr = '// @ts-check\n/// <reference path="../runtime.d.ts" />\nvar plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = \n';
datastr += plraw; datastr += plraw;
fs.writeFile('project/plugins.js', encode(datastr), 'base64', function (err, data) { fs.writeFile('project/plugins.js', encode(datastr), 'base64', function (err, data) {
callback(err); callback(err);

View File

@ -1,5 +1,6 @@
// @ts-check
/// <reference path="../runtime.d.ts" /> /// <reference path="../runtime.d.ts" />
var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
{ {
"init": function () { "init": function () {

14
runtime.d.ts vendored
View File

@ -11,6 +11,7 @@ type rgbarray = [number, number, number, number]
type Events = MotaAction[] | string type Events = MotaAction[] | string
type Block = { type Block = {
disable: boolean,
x: number, x: number,
y: number, y: number,
id: number, id: number,
@ -281,11 +282,11 @@ type gameStatus = {
// event事件 // event事件
shops: {} shops: {}
event: { event: {
id: string id?: string | null
data: any data: any
selection: any selection: any
ui: any ui: any
interval: number interval?: number | null
} }
autoEvents: Events autoEvents: Events
textAttribute: { textAttribute: {
@ -324,6 +325,11 @@ type gameStatus = {
/** @file control.js 主要用来进行游戏控制,比如行走控制、自动寻路、存读档等等游戏核心内容。 */ /** @file control.js 主要用来进行游戏控制,比如行走控制、自动寻路、存读档等等游戏核心内容。 */
interface control { interface control {
_updateDamage_damage(floorId: string, onMap: boolean): void
_updateDamage_extraDamage(floorId: string, onMap: boolean): void
/** 物品数据显示 */
getItemDetail(floorId: string): void
/** /**
* , Ctrl键进行穿墙, * , Ctrl键进行穿墙,
@ -2243,6 +2249,7 @@ interface items {
/** @file ui.js 主要用来进行UI窗口的绘制如对话框、怪物手册、楼传器、存读档界面等等。*/ /** @file ui.js 主要用来进行UI窗口的绘制如对话框、怪物手册、楼传器、存读档界面等等。*/
interface ui { interface ui {
_buildFont(fontSize?: number | string, bold?: boolean, italic?: boolean, font?: string): string
/** /**
* contextnull * contextnull
@ -3006,7 +3013,8 @@ type CoreMixin = {
favorite: [] favorite: []
readonly favoriteName: {} readonly favoriteName: {}
} }
readonly initStatus: gameStatus; readonly initStatus: gameStatus
readonly canvas: { [key: string]: CanvasRenderingContext2D }
readonly dymCanvas: { [key: string]: CanvasRenderingContext2D } readonly dymCanvas: { [key: string]: CanvasRenderingContext2D }
/** 游戏状态 */ /** 游戏状态 */
readonly status: gameStatus readonly status: gameStatus