@nimbus2d/core 0.0.1
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/dist/index.mjs +18433 -0
- package/package.json +39 -0
- package/src/base/EventEmitter.js +187 -0
- package/src/base/Subsystem.js +183 -0
- package/src/base/index.js +6 -0
- package/src/core/Application/AppState.js +27 -0
- package/src/core/Application/Application.js +480 -0
- package/src/core/Application/DefaultConfig.js +63 -0
- package/src/core/Application/index.js +7 -0
- package/src/core/AssetManager/AssetManager.js +711 -0
- package/src/core/AssetManager/AssetTypes.js +108 -0
- package/src/core/AssetManager/adapters/IResourceAdapter.js +50 -0
- package/src/core/AssetManager/adapters/PixiAdapter.js +90 -0
- package/src/core/AssetManager/core/RefCounter.js +167 -0
- package/src/core/AssetManager/core/ResourceCache.js +281 -0
- package/src/core/AssetManager/core/ResourceEntry.js +191 -0
- package/src/core/AssetManager/core/ResourceEventBus.js +127 -0
- package/src/core/AssetManager/handlers/IResourceHandler.js +45 -0
- package/src/core/AssetManager/index.js +26 -0
- package/src/core/AssetManager/plugins/IResourcePlugin.js +56 -0
- package/src/core/Camera/Camera.js +534 -0
- package/src/core/Camera/CameraTypes.js +59 -0
- package/src/core/Camera/index.js +13 -0
- package/src/core/ConfigSystem/ConfigLayer.js +230 -0
- package/src/core/ConfigSystem/ConfigLayerType.js +31 -0
- package/src/core/ConfigSystem/ConfigMerger.js +50 -0
- package/src/core/ConfigSystem/ConfigPath.js +96 -0
- package/src/core/ConfigSystem/ConfigSystem.js +378 -0
- package/src/core/ConfigSystem/ConfigTypes.js +29 -0
- package/src/core/ConfigSystem/ConfigWatcher.js +84 -0
- package/src/core/ConfigSystem/index.js +19 -0
- package/src/core/EventBus/EventBus.js +797 -0
- package/src/core/EventBus/Interceptor.js +26 -0
- package/src/core/EventBus/PerformanceStats.js +105 -0
- package/src/core/EventBus/index.js +7 -0
- package/src/core/Lifecycle/Lifecycle.js +265 -0
- package/src/core/Lifecycle/LifecycleState.js +31 -0
- package/src/core/Lifecycle/index.js +6 -0
- package/src/core/Logger/ConsoleHandler.js +55 -0
- package/src/core/Logger/LogHandler.js +34 -0
- package/src/core/Logger/LogLevel.js +38 -0
- package/src/core/Logger/Logger.js +234 -0
- package/src/core/Logger/index.js +8 -0
- package/src/core/PluginSystem/Plugin.js +156 -0
- package/src/core/PluginSystem/PluginEntry.js +102 -0
- package/src/core/PluginSystem/PluginState.js +30 -0
- package/src/core/PluginSystem/PluginSystem.js +530 -0
- package/src/core/PluginSystem/index.js +8 -0
- package/src/core/PoolManager/DefaultConfig.js +19 -0
- package/src/core/PoolManager/ObjectPool.js +326 -0
- package/src/core/PoolManager/PoolManager.js +253 -0
- package/src/core/PoolManager/PoolTypes.js +92 -0
- package/src/core/PoolManager/index.js +15 -0
- package/src/core/SceneManager/FadeTransition.js +64 -0
- package/src/core/SceneManager/MaskTransition.js +234 -0
- package/src/core/SceneManager/Scene.js +221 -0
- package/src/core/SceneManager/SceneManager.js +658 -0
- package/src/core/SceneManager/SceneState.js +29 -0
- package/src/core/SceneManager/SlideTransition.js +113 -0
- package/src/core/SceneManager/Transition.js +102 -0
- package/src/core/SceneManager/ZoomTransition.js +119 -0
- package/src/core/SceneManager/index.js +12 -0
- package/src/core/SpriteGPULayer/SpriteGPULayer.js +321 -0
- package/src/core/SpriteGPULayer/SpriteGPULayerTypes.js +49 -0
- package/src/core/SpriteGPULayer/index.js +11 -0
- package/src/core/Timeline/Clip.js +101 -0
- package/src/core/Timeline/DefaultConfig.js +41 -0
- package/src/core/Timeline/Easing.js +176 -0
- package/src/core/Timeline/Timeline.js +458 -0
- package/src/core/Timeline/TimelineTypes.js +89 -0
- package/src/core/Timeline/Track.js +202 -0
- package/src/core/Timeline/index.js +22 -0
- package/src/errors/ConfigError.js +47 -0
- package/src/errors/LifecycleError.js +58 -0
- package/src/errors/NimbusError.js +43 -0
- package/src/errors/PluginError.js +138 -0
- package/src/errors/ResourceError.js +166 -0
- package/src/errors/SceneError.js +124 -0
- package/src/errors/SubsystemError.js +68 -0
- package/src/errors/index.js +53 -0
- package/src/index.js +86 -0
- package/src/types/index.js +141 -0
- package/src/utils/MemoryChecker.js +374 -0
- package/src/utils/Validator.js +60 -0
- package/src/utils/index.js +84 -0
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nimbus2d/core",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Nimbus2D 核心框架 - 基于 PixiJS v8 的微内核 + 插件化 2D 游戏开发框架",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.mjs",
|
|
7
|
+
"module": "./dist/index.mjs",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.mjs",
|
|
11
|
+
"default": "./dist/index.mjs"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"src"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "vite build",
|
|
20
|
+
"dev": "vite build --watch"
|
|
21
|
+
},
|
|
22
|
+
"peerDependencies": {
|
|
23
|
+
"pixi.js": "^8.0.0"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"nimbus2d",
|
|
27
|
+
"game-framework",
|
|
28
|
+
"pixijs",
|
|
29
|
+
"2d",
|
|
30
|
+
"plugin",
|
|
31
|
+
"microkernel"
|
|
32
|
+
],
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "https://github.com/nimbus2d/nimbus-2d.git",
|
|
37
|
+
"directory": "packages/@nimbus2d/core"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// Nimbus2D - 事件发射器基类
|
|
3
|
+
// ----------------------------------------------------------------------------
|
|
4
|
+
// 职责:
|
|
5
|
+
// 提供基础事件能力(on/off/once/emit/removeAllListeners),
|
|
6
|
+
// 是所有事件相关类的基类。
|
|
7
|
+
//
|
|
8
|
+
// 设计决策:
|
|
9
|
+
// - 轻量级实现,不依赖第三方库
|
|
10
|
+
// - on/once 返回取消注册函数(Function)
|
|
11
|
+
// - off 返回 boolean(是否注销成功)
|
|
12
|
+
// - emit 返回 boolean(true 表示有监听器被调用)
|
|
13
|
+
// - 监听器按注册顺序调用
|
|
14
|
+
// - once 监听器触发后自动移除
|
|
15
|
+
// - emit 时如果监听器抛错,捕获并 console.error,不影响其他监听器
|
|
16
|
+
// ============================================================================
|
|
17
|
+
|
|
18
|
+
class EventEmitter {
|
|
19
|
+
/**
|
|
20
|
+
* 构造函数
|
|
21
|
+
*/
|
|
22
|
+
constructor() {
|
|
23
|
+
/** @type {Map<string, Array<{fn: Function, once: boolean}>>} 事件监听器映射表 */
|
|
24
|
+
this._listeners = new Map()
|
|
25
|
+
|
|
26
|
+
/** @type {boolean} 是否已销毁 */
|
|
27
|
+
this._destroyed = false
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* 注册事件监听器
|
|
32
|
+
* @param {string} event - 事件名称
|
|
33
|
+
* @param {Function} listener - 监听回调
|
|
34
|
+
* @returns {Function} 取消注册函数
|
|
35
|
+
*/
|
|
36
|
+
on(event, listener) {
|
|
37
|
+
if (this._destroyed) return () => {}
|
|
38
|
+
if (typeof listener !== 'function') {
|
|
39
|
+
console.warn(`[EventEmitter] on() 监听器必须是函数: ${event}`)
|
|
40
|
+
return () => {}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (!this._listeners.has(event)) {
|
|
44
|
+
this._listeners.set(event, [])
|
|
45
|
+
}
|
|
46
|
+
this._listeners.get(event).push({ fn: listener, once: false })
|
|
47
|
+
|
|
48
|
+
// 返回取消注册函数
|
|
49
|
+
return () => this.off(event, listener)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* 注册一次性事件监听器(触发一次后自动移除)
|
|
54
|
+
* @param {string} event - 事件名称
|
|
55
|
+
* @param {Function} listener - 监听回调
|
|
56
|
+
* @returns {Function} 取消注册函数
|
|
57
|
+
*/
|
|
58
|
+
once(event, listener) {
|
|
59
|
+
if (this._destroyed) return () => {}
|
|
60
|
+
if (typeof listener !== 'function') {
|
|
61
|
+
console.warn(`[EventEmitter] once() 监听器必须是函数: ${event}`)
|
|
62
|
+
return () => {}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (!this._listeners.has(event)) {
|
|
66
|
+
this._listeners.set(event, [])
|
|
67
|
+
}
|
|
68
|
+
this._listeners.get(event).push({ fn: listener, once: true })
|
|
69
|
+
|
|
70
|
+
// 返回取消注册函数
|
|
71
|
+
return () => this.off(event, listener)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* 移除事件监听器
|
|
76
|
+
* @param {string} event - 事件名称
|
|
77
|
+
* @param {Function} listener - 要移除的监听回调
|
|
78
|
+
* @returns {boolean} 是否注销成功
|
|
79
|
+
*/
|
|
80
|
+
off(event, listener) {
|
|
81
|
+
if (this._destroyed) return false
|
|
82
|
+
|
|
83
|
+
const list = this._listeners.get(event)
|
|
84
|
+
if (!list) return false
|
|
85
|
+
|
|
86
|
+
// 移除匹配的监听器(只移除第一个匹配的)
|
|
87
|
+
const index = list.findIndex((entry) => entry.fn === listener)
|
|
88
|
+
if (index === -1) return false
|
|
89
|
+
|
|
90
|
+
list.splice(index, 1)
|
|
91
|
+
|
|
92
|
+
// 如果该事件已无监听器,清理 Map 条目
|
|
93
|
+
if (list.length === 0) {
|
|
94
|
+
this._listeners.delete(event)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return true
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* 触发事件
|
|
102
|
+
* @param {string} event - 事件名称
|
|
103
|
+
* @param {...*} args - 传递给监听器的参数
|
|
104
|
+
* @returns {boolean} true 表示有监听器被调用
|
|
105
|
+
*/
|
|
106
|
+
emit(event, ...args) {
|
|
107
|
+
if (this._destroyed) return false
|
|
108
|
+
|
|
109
|
+
const list = this._listeners.get(event)
|
|
110
|
+
if (!list || list.length === 0) return false
|
|
111
|
+
|
|
112
|
+
// 复制监听器列表,避免迭代中修改列表
|
|
113
|
+
const listeners = list.slice()
|
|
114
|
+
|
|
115
|
+
// 收集需要移除的 once 监听器
|
|
116
|
+
const toRemove = []
|
|
117
|
+
|
|
118
|
+
for (const entry of listeners) {
|
|
119
|
+
try {
|
|
120
|
+
entry.fn(...args)
|
|
121
|
+
} catch (err) {
|
|
122
|
+
console.error(`[EventEmitter] 事件 "${event}" 监听器执行出错:`, err)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (entry.once) {
|
|
126
|
+
toRemove.push(entry)
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// 移除已触发的 once 监听器
|
|
131
|
+
for (const entry of toRemove) {
|
|
132
|
+
const index = list.indexOf(entry)
|
|
133
|
+
if (index !== -1) {
|
|
134
|
+
list.splice(index, 1)
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// 如果该事件已无监听器,清理 Map 条目
|
|
139
|
+
if (list.length === 0) {
|
|
140
|
+
this._listeners.delete(event)
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return true
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* 移除指定事件的所有监听器(不传参则移除所有事件的所有监听器)
|
|
148
|
+
* @param {string} [event] - 事件名称,不传则移除所有
|
|
149
|
+
*/
|
|
150
|
+
removeAllListeners(event) {
|
|
151
|
+
if (this._destroyed) return
|
|
152
|
+
|
|
153
|
+
if (event) {
|
|
154
|
+
this._listeners.delete(event)
|
|
155
|
+
} else {
|
|
156
|
+
this._listeners.clear()
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* 获取指定事件的监听器数量
|
|
162
|
+
* @param {string} event - 事件名称
|
|
163
|
+
* @returns {number} 监听器数量
|
|
164
|
+
*/
|
|
165
|
+
listenerCount(event) {
|
|
166
|
+
const list = this._listeners.get(event)
|
|
167
|
+
return list ? list.length : 0
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* 获取所有已注册的事件名称
|
|
172
|
+
* @returns {string[]} 事件名称数组
|
|
173
|
+
*/
|
|
174
|
+
eventNames() {
|
|
175
|
+
return Array.from(this._listeners.keys())
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* 销毁,清理所有监听器
|
|
180
|
+
*/
|
|
181
|
+
destroy() {
|
|
182
|
+
this._destroyed = true
|
|
183
|
+
this._listeners.clear()
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export { EventEmitter }
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// Nimbus2D - 子系统基类
|
|
3
|
+
// ----------------------------------------------------------------------------
|
|
4
|
+
// 职责:
|
|
5
|
+
// 提供完整的生命周期骨架(initialize/update/activate/deactivate/destroy),
|
|
6
|
+
// 便于 Lifecycle 集中调度。
|
|
7
|
+
//
|
|
8
|
+
// 设计决策:
|
|
9
|
+
// - 继承 EventEmitter,提供事件能力
|
|
10
|
+
// - 构造函数使用位置参数:constructor(eventBus, config, logger=null)
|
|
11
|
+
// - initialize() 仅设置 _isInitialized(不设置 _isActive)
|
|
12
|
+
// - _isActive 默认 false,需显式调用 activate() 才置为 true
|
|
13
|
+
// - Logger 参数可选(解决 Logger 鸡生蛋问题)
|
|
14
|
+
// - initialize() 状态检查抛 SubsystemStateError
|
|
15
|
+
// - destroy() 为 async 方法(子类异步销毁)
|
|
16
|
+
// - 子类通过重写生命周期方法扩展行为
|
|
17
|
+
// ============================================================================
|
|
18
|
+
|
|
19
|
+
import { EventEmitter } from './EventEmitter.js'
|
|
20
|
+
import { SubsystemStateError } from '../errors/SubsystemError.js'
|
|
21
|
+
|
|
22
|
+
class Subsystem extends EventEmitter {
|
|
23
|
+
/**
|
|
24
|
+
* 构造函数
|
|
25
|
+
* @param {import('../core/EventBus/EventBus.js').EventBus} eventBus - 全局事件总线
|
|
26
|
+
* @param {import('../core/ConfigSystem/ConfigSystem.js').ConfigSystem} config - 配置系统
|
|
27
|
+
* @param {import('../core/Logger/Logger.js').Logger|null} [logger=null] - 日志系统(可选,Logger 自身传 null)
|
|
28
|
+
*/
|
|
29
|
+
constructor(eventBus, config, logger = null) {
|
|
30
|
+
super()
|
|
31
|
+
|
|
32
|
+
/** @type {import('../core/EventBus/EventBus.js').EventBus} 全局事件总线 */
|
|
33
|
+
this._eventBus = eventBus
|
|
34
|
+
|
|
35
|
+
/** @type {import('../core/ConfigSystem/ConfigSystem.js').ConfigSystem} 配置系统 */
|
|
36
|
+
this._config = config
|
|
37
|
+
|
|
38
|
+
/** @type {import('../core/Logger/Logger.js').Logger|null} 日志系统(可能为 null) */
|
|
39
|
+
this._logger = logger
|
|
40
|
+
|
|
41
|
+
/** @type {boolean} 是否已初始化 */
|
|
42
|
+
this._isInitialized = false
|
|
43
|
+
|
|
44
|
+
/** @type {boolean} 是否已激活 */
|
|
45
|
+
this._isActive = false
|
|
46
|
+
|
|
47
|
+
/** @type {boolean} 是否已销毁 */
|
|
48
|
+
this._isDestroyed = false
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// --------------------------------------------------------------------------
|
|
52
|
+
// 生命周期方法
|
|
53
|
+
// --------------------------------------------------------------------------
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* 初始化子系统
|
|
57
|
+
* 默认行为:
|
|
58
|
+
* 1. 检查状态(必须未初始化且未销毁,否则抛 SubsystemStateError)
|
|
59
|
+
* 2. 标记 _isInitialized = true(注意:不设置 _isActive = true)
|
|
60
|
+
* 3. emit 'initialized' 事件
|
|
61
|
+
* 子类重写时应先调用 super.initialize()
|
|
62
|
+
* @returns {Promise<void>}
|
|
63
|
+
*/
|
|
64
|
+
async initialize() {
|
|
65
|
+
if (this._isInitialized) {
|
|
66
|
+
throw new SubsystemStateError(this.name, 'INITIALIZED', ['CREATED'])
|
|
67
|
+
}
|
|
68
|
+
if (this._isDestroyed) {
|
|
69
|
+
throw new SubsystemStateError(this.name, 'DESTROYED', ['CREATED'])
|
|
70
|
+
}
|
|
71
|
+
this._isInitialized = true
|
|
72
|
+
this.emit('initialized', { name: this.name })
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* 每帧更新
|
|
77
|
+
* 子类重写此方法执行每帧逻辑
|
|
78
|
+
* @param {number} delta - 距上一帧的时间增量(秒)
|
|
79
|
+
* @returns {void}
|
|
80
|
+
*/
|
|
81
|
+
update(delta) {
|
|
82
|
+
// 基类空实现,子类按需重写
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* 激活子系统
|
|
87
|
+
* 默认行为:
|
|
88
|
+
* 1. 检查 _isInitialized(必须为 true)
|
|
89
|
+
* 2. 检查 _isDestroyed(不能已销毁)
|
|
90
|
+
* 3. 标记 _isActive = true
|
|
91
|
+
* 4. emit 'activated' 事件
|
|
92
|
+
* @returns {void}
|
|
93
|
+
*/
|
|
94
|
+
activate() {
|
|
95
|
+
if (this._isDestroyed) return
|
|
96
|
+
if (!this._isInitialized) {
|
|
97
|
+
console.warn(`[Subsystem] ${this.name} 未初始化,不能激活`)
|
|
98
|
+
return
|
|
99
|
+
}
|
|
100
|
+
this._isActive = true
|
|
101
|
+
this.emit('activated', { name: this.name })
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* 停用子系统
|
|
106
|
+
* 默认行为:
|
|
107
|
+
* 1. 标记 _isActive = false
|
|
108
|
+
* 2. emit 'deactivated' 事件
|
|
109
|
+
* @returns {void}
|
|
110
|
+
*/
|
|
111
|
+
deactivate() {
|
|
112
|
+
if (this._isDestroyed) return
|
|
113
|
+
this._isActive = false
|
|
114
|
+
this.emit('deactivated', { name: this.name })
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* 销毁子系统
|
|
119
|
+
* 默认行为:
|
|
120
|
+
* 1. 标记 _isDestroyed = true, _isActive = false, _isInitialized = false
|
|
121
|
+
* 2. 调用 removeAllListeners()
|
|
122
|
+
* 3. 释放引用
|
|
123
|
+
* 4. emit 'destroyed' 事件
|
|
124
|
+
* 子类重写时应调用 super.destroy()
|
|
125
|
+
* @returns {Promise<void>}
|
|
126
|
+
*/
|
|
127
|
+
async destroy() {
|
|
128
|
+
if (this._isDestroyed) return
|
|
129
|
+
|
|
130
|
+
this._isActive = false
|
|
131
|
+
this._isInitialized = false
|
|
132
|
+
this._isDestroyed = true
|
|
133
|
+
|
|
134
|
+
// 先 emit destroyed 事件(removeAllListeners 后 emit 无效)
|
|
135
|
+
this.emit('destroyed', { name: this.name })
|
|
136
|
+
|
|
137
|
+
// 清理事件监听器
|
|
138
|
+
this.removeAllListeners()
|
|
139
|
+
|
|
140
|
+
// 释放引用
|
|
141
|
+
this._eventBus = null
|
|
142
|
+
this._config = null
|
|
143
|
+
this._logger = null
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// --------------------------------------------------------------------------
|
|
147
|
+
// Getter
|
|
148
|
+
// --------------------------------------------------------------------------
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* 子系统名称(子类可重写)
|
|
152
|
+
* @type {string}
|
|
153
|
+
*/
|
|
154
|
+
get name() {
|
|
155
|
+
return this.constructor.name
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* 是否已初始化
|
|
160
|
+
* @type {boolean}
|
|
161
|
+
*/
|
|
162
|
+
get isInitialized() {
|
|
163
|
+
return this._isInitialized
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* 是否已激活
|
|
168
|
+
* @type {boolean}
|
|
169
|
+
*/
|
|
170
|
+
get isActive() {
|
|
171
|
+
return this._isActive
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* 是否已销毁
|
|
176
|
+
* @type {boolean}
|
|
177
|
+
*/
|
|
178
|
+
get isDestroyed() {
|
|
179
|
+
return this._isDestroyed
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export { Subsystem }
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// Nimbus2D - 基类统一导出
|
|
3
|
+
// ============================================================================
|
|
4
|
+
|
|
5
|
+
export { EventEmitter } from './EventEmitter.js'
|
|
6
|
+
export { Subsystem } from './Subsystem.js'
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// Nimbus2D - 应用状态枚举
|
|
3
|
+
// ----------------------------------------------------------------------------
|
|
4
|
+
// 定义 Application 启动器的所有合法状态。
|
|
5
|
+
//
|
|
6
|
+
// 状态转换流程:
|
|
7
|
+
// CREATED → STARTING → RUNNING → STOPPING → DESTROYED
|
|
8
|
+
// ============================================================================
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 应用状态枚举
|
|
12
|
+
* @enum {string}
|
|
13
|
+
*/
|
|
14
|
+
const AppState = {
|
|
15
|
+
/** 已创建(初始状态) */
|
|
16
|
+
CREATED: 'CREATED',
|
|
17
|
+
/** 启动中 */
|
|
18
|
+
STARTING: 'STARTING',
|
|
19
|
+
/** 运行中 */
|
|
20
|
+
RUNNING: 'RUNNING',
|
|
21
|
+
/** 停止中 */
|
|
22
|
+
STOPPING: 'STOPPING',
|
|
23
|
+
/** 已销毁(终态) */
|
|
24
|
+
DESTROYED: 'DESTROYED'
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { AppState }
|