ice-web-components 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -4
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/types/components/ICELabel.d.ts +8 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/model/ICEBiosModel.d.ts +124 -0
- package/package.json +1 -1
|
@@ -8,6 +8,14 @@ export declare class ICELabel extends ICEWidget {
|
|
|
8
8
|
constructor(props?: any);
|
|
9
9
|
setText(text: string): this;
|
|
10
10
|
getText(): string;
|
|
11
|
+
/**
|
|
12
|
+
* 改文字颜色(动态强调 / 置灰用,比如 BIOS 自检行的灰→黄→绿、菜单选中态)。
|
|
13
|
+
*
|
|
14
|
+
* 必须走内层 `ICEText`:文字是它画的,构造期 `style` 已经下沉到那一层,
|
|
15
|
+
* 之后再 `setState({ style })` 只会改到外壳容器,屏幕上的字纹丝不动。
|
|
16
|
+
* 只覆盖 `fillStyle`,字号 / 字体 / 对齐这些原样保留。
|
|
17
|
+
*/
|
|
18
|
+
setTextColor(color: string): this;
|
|
11
19
|
/**
|
|
12
20
|
* 让标签自身占据文字的实测尺寸。
|
|
13
21
|
*
|
package/dist/types/index.d.ts
CHANGED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 掌机 BIOS 的纯逻辑(不碰 canvas、不碰 DOM)。
|
|
3
|
+
*
|
|
4
|
+
* 掌机开机先跑一段「自检 → 菜单」的引导,然后才把控制权交给卡带:
|
|
5
|
+
* 自检**按时序推进**(页面每帧调 `tick(dt)`),菜单是**光标 + 确认**的老式控制台交互。
|
|
6
|
+
* 页面只负责把 `getSteps()` / `getMenuEntries()` 画成文字,并执行 `confirm()` 返回的动作 ——
|
|
7
|
+
* 状态机与渲染分开,所以「自检要跑多久、菜单怎么绕、设置存到哪」都能在 node 里单测。
|
|
8
|
+
*
|
|
9
|
+
* 约定:
|
|
10
|
+
* - 自检项由 `steps` 注入(默认 5 项:CPU / RAM / VRAM / SOUND / CART),每项有自己的耗时;
|
|
11
|
+
* - 相位机:`post`(自检中)→ `menu`(启动菜单)或 `boot`(直接启动,快速启动开着时);
|
|
12
|
+
* `settings`(设置页)从菜单进、`back()` 回菜单;
|
|
13
|
+
* - 菜单光标上下**循环**(到头绕回去,老式 BIOS 都这样),进设置前记下位置、回来还停在那儿;
|
|
14
|
+
* - 设置(快速启动 / 默认卡带)落到注入的存储里;坏数据、写盘失败一律降级,绝不抛。
|
|
15
|
+
*/
|
|
16
|
+
export declare type ICEBiosPhase = 'post' | 'menu' | 'settings' | 'boot';
|
|
17
|
+
export interface ICEBiosStep {
|
|
18
|
+
/** 稳定 key(页面拿它做节点 id / 维护增量更新) */
|
|
19
|
+
key: string;
|
|
20
|
+
label: string;
|
|
21
|
+
detail: string;
|
|
22
|
+
/** 这一项「检测」要花多久(毫秒) */
|
|
23
|
+
duration: number;
|
|
24
|
+
}
|
|
25
|
+
export interface ICEBiosStepState extends ICEBiosStep {
|
|
26
|
+
state: 'pending' | 'running' | 'ok';
|
|
27
|
+
/** 当前项的进度 0..1;非当前项是 0 或 1 */
|
|
28
|
+
progress: number;
|
|
29
|
+
}
|
|
30
|
+
export interface ICEBiosCartridge {
|
|
31
|
+
key: string;
|
|
32
|
+
label: string;
|
|
33
|
+
}
|
|
34
|
+
export interface ICEBiosMenuEntry {
|
|
35
|
+
key: string;
|
|
36
|
+
label: string;
|
|
37
|
+
type: 'cartridge' | 'settings' | 'boot';
|
|
38
|
+
}
|
|
39
|
+
export interface ICEBiosSettings {
|
|
40
|
+
/** 开着就跳过菜单直接启动默认卡带(开机自检还是要跑) */
|
|
41
|
+
quickBoot: boolean;
|
|
42
|
+
defaultCartridge: string;
|
|
43
|
+
}
|
|
44
|
+
export declare type ICEBiosAction = {
|
|
45
|
+
type: 'boot';
|
|
46
|
+
cartridge: string;
|
|
47
|
+
} | {
|
|
48
|
+
type: 'settings';
|
|
49
|
+
} | {
|
|
50
|
+
type: 'menu';
|
|
51
|
+
} | {
|
|
52
|
+
type: 'none';
|
|
53
|
+
};
|
|
54
|
+
export interface ICEBiosStorage {
|
|
55
|
+
getItem(key: string): string | null;
|
|
56
|
+
setItem(key: string, value: string): void;
|
|
57
|
+
}
|
|
58
|
+
export interface ICEBiosOptions {
|
|
59
|
+
cartridges: ICEBiosCartridge[];
|
|
60
|
+
/** 自检项,默认 `ICE_BIOS_DEFAULT_STEPS` */
|
|
61
|
+
steps?: ICEBiosStep[];
|
|
62
|
+
/** 初始设置(优先级低于存储里的值) */
|
|
63
|
+
settings?: Partial<ICEBiosSettings>;
|
|
64
|
+
/** 存储实现;传 null 表示只放内存;不传则用 globalThis.localStorage(没有就退化成内存) */
|
|
65
|
+
storage?: ICEBiosStorage | null;
|
|
66
|
+
/** 存储键前缀,默认 `ice-arcade-bios-` */
|
|
67
|
+
prefix?: string;
|
|
68
|
+
}
|
|
69
|
+
export declare type ICEBiosListener = (model: ICEBiosModel) => void;
|
|
70
|
+
/** 默认自检项:每一项都是一句「老式 BIOS 会印在屏幕上的话」。 */
|
|
71
|
+
export declare const ICE_BIOS_DEFAULT_STEPS: ICEBiosStep[];
|
|
72
|
+
export declare class ICEBiosModel {
|
|
73
|
+
private steps;
|
|
74
|
+
private cartridges;
|
|
75
|
+
private storage;
|
|
76
|
+
private storageKey;
|
|
77
|
+
private listeners;
|
|
78
|
+
private phase;
|
|
79
|
+
private elapsed;
|
|
80
|
+
private cursor;
|
|
81
|
+
private cursorBeforeSettings;
|
|
82
|
+
private settings;
|
|
83
|
+
constructor(options: ICEBiosOptions);
|
|
84
|
+
getPhase(): ICEBiosPhase;
|
|
85
|
+
getCartridges(): ICEBiosCartridge[];
|
|
86
|
+
getPostElapsed(): number;
|
|
87
|
+
/** 自检总时长(毫秒)。 */
|
|
88
|
+
getPostDuration(): number;
|
|
89
|
+
/** 自检进度 0..1(按时间算,页面拿它画进度条)。 */
|
|
90
|
+
getPostProgress(): number;
|
|
91
|
+
/** 自检项与它们此刻的状态(当前项 running、前面的 ok)。 */
|
|
92
|
+
getSteps(): ICEBiosStepState[];
|
|
93
|
+
/** 菜单项:卡带列表 + 设置 + 退出并启动。 */
|
|
94
|
+
getMenuEntries(): ICEBiosMenuEntry[];
|
|
95
|
+
getCursor(): number;
|
|
96
|
+
getSelectedEntry(): ICEBiosMenuEntry | null;
|
|
97
|
+
getSettings(): ICEBiosSettings;
|
|
98
|
+
isQuickBoot(): boolean;
|
|
99
|
+
getDefaultCartridge(): string;
|
|
100
|
+
/** 推进自检(页面每帧调用),返回是否发生了变化。 */
|
|
101
|
+
tick(delta: number): boolean;
|
|
102
|
+
moveCursor(delta: number): void;
|
|
103
|
+
setCursor(index: number): void;
|
|
104
|
+
/** 确认当前项:只返回动作,执行动作是页面的事(好测)。 */
|
|
105
|
+
confirm(): ICEBiosAction;
|
|
106
|
+
/** 返回上一层(设置 → 菜单)。 */
|
|
107
|
+
back(): void;
|
|
108
|
+
/** 从游戏里回到 BIOS 菜单(掌机的「复位」)。 */
|
|
109
|
+
openMenu(): void;
|
|
110
|
+
/** 重新跑一遍自检(再开一次机)。 */
|
|
111
|
+
restart(): void;
|
|
112
|
+
toggleQuickBoot(): boolean;
|
|
113
|
+
setDefaultCartridge(key: string): void;
|
|
114
|
+
addChangeListener(listener: ICEBiosListener): () => void;
|
|
115
|
+
private __alignCursorToDefault;
|
|
116
|
+
/** 卡带 key 必须真的存在,否则回退到第一个卡带。 */
|
|
117
|
+
private __normalizeCartridge;
|
|
118
|
+
private __load;
|
|
119
|
+
private __readStorage;
|
|
120
|
+
private __save;
|
|
121
|
+
private __defaultStorage;
|
|
122
|
+
private notify;
|
|
123
|
+
}
|
|
124
|
+
export default ICEBiosModel;
|