fix: 构建

This commit is contained in:
unanmed 2024-02-08 17:14:33 +08:00
parent 877a6644c8
commit fb83588df5
5 changed files with 19 additions and 358 deletions

View File

@ -5,7 +5,7 @@
"type": "module",
"scripts": {
"dev": "ts-node-esm script/dev.ts",
"build": "vue-tsc --noEmit && ts-node-esm script/build.ts dist",
"build": "vue-tsc --noEmit && pnpm docs:build && ts-node-esm script/build.ts dist",
"preview": "vite preview",
"update": "ts-node-esm script/update.ts",
"declare": "ts-node-esm script/declare.ts",

View File

@ -114,16 +114,7 @@ const compress = type === 'dist';
'./dist/types/plugin.d.ts',
'utf-8'
);
const rep = pluginDTS.replace(
`declare const Mota: import('../game/system').IMota;
interface Window {
Mota: import('../game/system').IMota;
}`,
`declare const Mota: import('./index.d.ts').IMota;
interface Window {
Mota: import('./index.d.ts').IMota;
}`
);
const rep = pluginDTS.replaceAll(`../game/system`, `../index.d.ts`);
await fs.writeFile('./dist/types/plugin.d.ts', rep);
const js = ['functions.js', 'plugins.js'];
@ -154,7 +145,15 @@ interface Window {
console.log(e);
}
// 8. 压缩
// 8. 文档
try {
await fs.move('./docs/.vitepress/dist', './dist/_docs');
} catch (e) {
console.log('移动文档失败');
console.log(e);
}
// 9. 压缩
if (compress) {
try {
await fs.ensureDir('./out');

View File

@ -47,14 +47,14 @@ import * as statusBarTools from '@/plugin/ui/statusBar';
import * as toolboxTools from '@/plugin/ui/toolbox';
import * as UI from '@ui/index';
import Box from '@/components/box.vue';
import BoxAnimate from '@/components/boxAnimate.vue.vue';
import Colomn from '@/components/colomn.vue.vue';
import EnemyOne from '@/components/enemyOne.vue.vue';
import Scroll from '@/components/scroll.vue.vue';
import BoxAnimate from '@/components/boxAnimate.vue';
import Colomn from '@/components/colomn.vue';
import EnemyOne from '@/components/enemyOne.vue';
import Scroll from '@/components/scroll.vue';
import EnemyCritical from '@/panel/enemyCritical.vue';
import EnemySpecial from '@/panel/enemySpecial.vue.vue';
import EnemyTarget from '@/panel/enemyTarget.vue.vue';
import KeyboardPanel from '@/panel/keyboard.vue.vue';
import EnemySpecial from '@/panel/enemySpecial.vue';
import EnemyTarget from '@/panel/enemyTarget.vue';
import KeyboardPanel from '@/panel/keyboard.vue';
import { MCGenerator } from './main/layout';
// ----- 类注册

View File

@ -438,9 +438,6 @@ gameKey
.realize('viewMap', () => {
core.ui._drawViewMaps();
})
.realize('skillTree', () => {
core.useItem('skill1', true);
})
.realize('undo', () => {
core.doSL('autoSave', 'load');
})

337
src/types/plugin.d.ts vendored
View File

@ -14,342 +14,7 @@ type CanParseCss = keyof {
: never]: CSSStyleDeclaration[P];
};
interface PluginDeclaration
extends PluginUtils,
PluginUis,
PluginUse,
MiniMap,
PluginAchievement {
/**
*
*/
utils: GamePluginUtils;
loopMap: GamePluginLoopMap;
skillTree: GamePluginSkillTree;
study: GamePluginStudy;
hero: GamePluginHeroRealStatus;
replay: PluginReplay;
chase: PluginChase;
skills: Record<Chapter, Skill[]>;
skillEffects: SkillEffects;
/**
* 使core.addPop或core.plugin.addPop调用
* @param px
* @param py
* @param value
*/
addPop(px: number, py: number, value: string): void;
/** 添加变量 例所有的正在弹出的文字像这个就可以使用core.plugin.pop获取 */
pop: any[];
/** 状态栏信息,取反后刷新状态栏 */
readonly statusBarStatus: Ref<boolean>;
/**
*
* @param fn
*/
addAnimate(fn: (time: number) => void);
/**
*
* @param fn
*/
removeAnimate(fn: (time: number) => void);
/**
* undefined或null
* @param value
*/
has<T>(value: T): value is NonNullable<T>;
applyFragWith(
canvas: HTMLCanvasElement,
length?: number,
time?: number
): {
canvas: HTMLCanvasElement;
onEnd: Promise<void>;
animation: import('mutate-animate').Animation;
};
}
interface GamePluginUtils {
/**
* undefined或null
* @param value
*/
has<T>(value: T): value is NonNullable<T>;
/**
*
* @param arr
* @param delta
*/
slide<T>(arr: T[], delta: number): T[];
/**
*
* @param dir
*/
backDir(dir: Dir): Dir;
/**
*
* @param n
*/
maxGameScale(n?: number): void;
}
interface GamePluginLoopMap {
checkLoopMap(): void;
}
interface PluginUtils {
/**
* undefined或null
* @param value
*/
has<T>(value: T): value is NonNullable<T>;
/**
*
* @param damage
*/
getDamageColor(damage: number): string;
/**
* css字符串为CSSStyleDeclaration对象
* @param css css字符串
*/
parseCss(css: string): Partial<Record<CanParseCss, string>>;
/**
*
* @param text
*/
tip(
type: 'warn' | 'info' | 'success' | 'error' | 'warning' | 'loading',
text: string
): void;
/**
*
* @param index
*/
startChase(index: number): Promise<void>;
}
interface PluginUis {
/** 是否正在进行章节显示 */
readonly chapterShowed: Ref<boolean>;
/** 章节显示的内容 */
readonly chapterContent: Ref<boolean>;
/** 是否展示标记的怪物 */
readonly showMarkedEnemy: Ref<boolean>;
/**
*
*/
openSkill(): void;
}
interface PluginUse {
/** 是否是移动设备 */
readonly isMobile: boolean;
/**
*
* @param ele
* @param fn x y和鼠标事件或点击事件
* @param ondown
* @param global
*/
useDrag(
ele: HTMLElement,
fn: DragFn,
ondown?: DragFn,
onUp?: (e: MouseEvent | TouchEvent) => void,
global?: boolean
): void;
/**
*
* @param fn
*/
cancelGlobalDrag(fn: DragFn): void;
/**
*
* @param ele
* @param fn
*/
useWheel(
ele: HTMLElement,
fn: (x: number, y: number, z: number, e: WheelEvent) => void
): void;
/**
*
* @param ele
* @param fn
*/
useUp(ele: HTMLElement, fn: DragFn): void;
}
interface GamePluginSkillTree {
/**
*
* @param skill
*/
getSkillLevel(skill: number): number;
/**
*
* @param index
*/
getSkillFromIndex(index: number): Skill;
/**
*
* @param skill
*/
getSkillConsume(skill: number): number;
/**
*
* @param skill
*/
upgradeSkill(skill: number): boolean;
/**
*
*/
saveSkillTree(): number[];
/**
*
* @param data
*/
loadSkillTree(data: number[]): void;
}
interface MiniMap {
/**
*
*/
splitArea(): void;
}
interface GamePluginStudy {
/**
*
* @param enemy
* @param num
*/
studySkill(enemy: Enemy, num: number): void;
}
interface GamePluginHeroRealStatus {
/**
*
* @param name
* @param x
* @param y
* @param floorId
*/
getHeroStatusOn(name: 'all', floorId?: FloorIds): HeroStatus;
getHeroStatusOn(
name: (keyof HeroStatus)[],
floorId?: FloorIds
): Partial<HeroStatus>;
getHeroStatusOn<K extends keyof HeroStatus>(
name: K,
floorId?: FloorIds
): HeroStatus[K];
/**
*
* @param status
* @param name
* @param x
* @param y
* @param floorId
*/
getHeroStatusOf(
status: Partial<HeroStatus>,
name: 'all',
floorId?: FloorIds
): HeroStatus;
getHeroStatusOf(
status: Partial<HeroStatus>,
name: (keyof HeroStatus)[],
floorId?: FloorIds
): Partial<HeroStatus>;
getHeroStatusOf<K extends keyof HeroStatus>(
status: Partial<HeroStatus>,
name: K,
floorId?: FloorIds
): HeroStatus[K];
}
interface PluginAchievement {
/**
*
* @param type
* @param index
*/
completeAchievement(type: AchievementType, index: number): void;
/**
*
* @param type
* @param index
*/
hasCompletedAchievement(type: AchievementType, index: number): boolean;
/**
*
*/
getNowPoint(): number;
/**
*
*/
checkVisitedFloor(): void;
}
interface PluginReplay {
ready(): void;
readyClip(): number;
clip(...replace: string[]): void;
}
interface PluginChase {
chaseInit1(): void;
}
interface SkillEffects {
jumpIgnoreFloor: FloorIds[];
}
type Chapter = 'chapter1' | 'chapter2';
interface Skill {
index: number;
title: string;
desc: string[];
consume: string;
front: LocArr[];
loc: LocArr;
max: number;
effect: string[];
}
interface PluginDeclaration {}
type Forward<T> = {
[K in keyof T as T[K] extends Function