steamsheep-ts-game-engine 3.1.2 → 3.2.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 +26 -1
- package/dist/core/index.d.mts +2 -2
- package/dist/core/index.d.ts +2 -2
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +35 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +35 -7
- package/dist/index.mjs.map +1 -1
- package/dist/state/index.d.mts +2 -2
- package/dist/state/index.d.ts +2 -2
- package/dist/state/index.js +18 -4
- package/dist/state/index.js.map +1 -1
- package/dist/state/index.mjs +18 -4
- package/dist/state/index.mjs.map +1 -1
- package/dist/{store-PPh__zkF.d.ts → store-Bd5skpNR.d.ts} +1 -1
- package/dist/{store-5-3GQpi9.d.mts → store-CXGVzV4N.d.mts} +1 -1
- package/dist/systems/index.d.mts +39 -27
- package/dist/systems/index.d.ts +39 -27
- package/dist/systems/index.js +36 -7
- package/dist/systems/index.js.map +1 -1
- package/dist/systems/index.mjs +36 -8
- package/dist/systems/index.mjs.map +1 -1
- package/dist/{types-D-nDlnv3.d.mts → types-Cp9kSsBQ.d.mts} +248 -22
- package/dist/{types-D-nDlnv3.d.ts → types-Cp9kSsBQ.d.ts} +248 -22
- package/dist/ui/index.d.mts +1 -1
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.js +19 -5
- package/dist/ui/index.js.map +1 -1
- package/dist/ui/index.mjs +19 -5
- package/dist/ui/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -539,10 +539,35 @@ const performRitualAction: ActionDef<Stats, Items, Flags, Extra> = {
|
|
|
539
539
|
|
|
540
540
|
---
|
|
541
541
|
|
|
542
|
+
## ⚠️ 重要:通知系统使用
|
|
543
|
+
|
|
544
|
+
如果你使用 `showModal()` 或 `showToast()` 但没有看到显示,请确保在你的应用中渲染了 `OverlaySystem` 组件:
|
|
545
|
+
|
|
546
|
+
```tsx
|
|
547
|
+
import { OverlaySystem } from 'steamsheep-ts-game-engine';
|
|
548
|
+
|
|
549
|
+
function App() {
|
|
550
|
+
return (
|
|
551
|
+
<>
|
|
552
|
+
<YourGameUI />
|
|
553
|
+
{/* ⚠️ 必须添加这个组件 */}
|
|
554
|
+
<OverlaySystem />
|
|
555
|
+
</>
|
|
556
|
+
);
|
|
557
|
+
}
|
|
558
|
+
```
|
|
559
|
+
|
|
560
|
+
详细说明请查看:[通知系统使用指南](./docs/NOTIFICATION_SYSTEM.md)
|
|
561
|
+
|
|
562
|
+
---
|
|
563
|
+
|
|
542
564
|
## 📚 更多文档
|
|
543
565
|
|
|
566
|
+
- **[通知系统使用指南](./docs/NOTIFICATION_SYSTEM.md)** - 如果 showModal/showToast 不显示,请看这里!
|
|
567
|
+
- [事件系统单例问题](./docs/EVENT_SYSTEM_SINGLETON.md)
|
|
568
|
+
- [完整游戏流程示例](./examples/complete-game-flow.ts)
|
|
569
|
+
- [快速入门指南](./QUICK_START.md)
|
|
544
570
|
- [完整功能示例](./examples/complete-features-example.ts)
|
|
545
|
-
- [动态 Flag 示例](./examples/dynamic-flags-example.ts)
|
|
546
571
|
- [核心类型定义](./core/types.ts)
|
|
547
572
|
- [状态管理](./state/store.ts)
|
|
548
573
|
- [历史管理](./state/history.ts)
|
package/dist/core/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as GameState } from '../types-
|
|
2
|
-
export { A as ActionDef, E as EffectDef, F as FlagsBatchOperation, G as GameStoreActions, d as LocationDef, L as LogEntry, b as NotificationPayload, N as NotificationType, R as RequirementCheckResult, c as RequirementDef, S as StatRequirement, W as WorldState } from '../types-
|
|
1
|
+
import { a as GameState } from '../types-Cp9kSsBQ.mjs';
|
|
2
|
+
export { A as ActionDef, E as EffectDef, F as FlagsBatchOperation, G as GameStoreActions, d as LocationDef, L as LogEntry, b as NotificationPayload, N as NotificationType, R as RequirementCheckResult, c as RequirementDef, S as StatRequirement, W as WorldState } from '../types-Cp9kSsBQ.mjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* 系统消息常量
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as GameState } from '../types-
|
|
2
|
-
export { A as ActionDef, E as EffectDef, F as FlagsBatchOperation, G as GameStoreActions, d as LocationDef, L as LogEntry, b as NotificationPayload, N as NotificationType, R as RequirementCheckResult, c as RequirementDef, S as StatRequirement, W as WorldState } from '../types-
|
|
1
|
+
import { a as GameState } from '../types-Cp9kSsBQ.js';
|
|
2
|
+
export { A as ActionDef, E as EffectDef, F as FlagsBatchOperation, G as GameStoreActions, d as LocationDef, L as LogEntry, b as NotificationPayload, N as NotificationType, R as RequirementCheckResult, c as RequirementDef, S as StatRequirement, W as WorldState } from '../types-Cp9kSsBQ.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* 系统消息常量
|
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { A as ActionDef, E as EffectDef, F as FlagsBatchOperation, a as GameState, G as GameStoreActions, d as LocationDef, L as LogEntry, b as NotificationPayload, N as NotificationType, R as RequirementCheckResult, c as RequirementDef, S as StatRequirement, W as WorldState } from './types-
|
|
1
|
+
export { A as ActionDef, E as EffectDef, F as FlagsBatchOperation, a as GameState, G as GameStoreActions, d as LocationDef, L as LogEntry, b as NotificationPayload, N as NotificationType, R as RequirementCheckResult, c as RequirementDef, S as StatRequirement, W as WorldState } from './types-Cp9kSsBQ.mjs';
|
|
2
2
|
export { DEFAULT_CONFIG, DEFAULT_STATS, ENGINE_VERSION, LOG_TYPE_COLORS, SystemMessages, TIME_CONSTANTS, UI_CONSTANTS, VALIDATION, clamp, debounce, deepClone, delay, formatGameTime, formatNumber, generateId, get, getPercentage, getStateDiff, getTimeOfDay, isEmpty, randomChoice, randomInt, shuffle, throttle } from './core/index.mjs';
|
|
3
|
-
export { G as GameStore, c as createGameEngineStore } from './store-
|
|
3
|
+
export { G as GameStore, c as createGameEngineStore } from './store-CXGVzV4N.mjs';
|
|
4
4
|
export { HistoryManager, SnapshotInfo } from './state/index.mjs';
|
|
5
|
-
export { EngineEvents, EventBus, FlowSystem, QuerySystem, debugEventSystem, gameEvents, getEventListenerCounts, isEventBusSingleton } from './systems/index.mjs';
|
|
5
|
+
export { EngineEvents, EventBus, FlowSystem, QuerySystem, debugEventSystem, gameEvents, getEventListenerCounts, getGlobalEventBusInstance, isEventBusSingleton } from './systems/index.mjs';
|
|
6
6
|
export { Layout, LogStream, MainContent, OverlaySystem } from './ui/index.mjs';
|
|
7
7
|
import 'zustand/middleware';
|
|
8
8
|
import 'zustand';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { A as ActionDef, E as EffectDef, F as FlagsBatchOperation, a as GameState, G as GameStoreActions, d as LocationDef, L as LogEntry, b as NotificationPayload, N as NotificationType, R as RequirementCheckResult, c as RequirementDef, S as StatRequirement, W as WorldState } from './types-
|
|
1
|
+
export { A as ActionDef, E as EffectDef, F as FlagsBatchOperation, a as GameState, G as GameStoreActions, d as LocationDef, L as LogEntry, b as NotificationPayload, N as NotificationType, R as RequirementCheckResult, c as RequirementDef, S as StatRequirement, W as WorldState } from './types-Cp9kSsBQ.js';
|
|
2
2
|
export { DEFAULT_CONFIG, DEFAULT_STATS, ENGINE_VERSION, LOG_TYPE_COLORS, SystemMessages, TIME_CONSTANTS, UI_CONSTANTS, VALIDATION, clamp, debounce, deepClone, delay, formatGameTime, formatNumber, generateId, get, getPercentage, getStateDiff, getTimeOfDay, isEmpty, randomChoice, randomInt, shuffle, throttle } from './core/index.js';
|
|
3
|
-
export { G as GameStore, c as createGameEngineStore } from './store-
|
|
3
|
+
export { G as GameStore, c as createGameEngineStore } from './store-Bd5skpNR.js';
|
|
4
4
|
export { HistoryManager, SnapshotInfo } from './state/index.js';
|
|
5
|
-
export { EngineEvents, EventBus, FlowSystem, QuerySystem, debugEventSystem, gameEvents, getEventListenerCounts, isEventBusSingleton } from './systems/index.js';
|
|
5
|
+
export { EngineEvents, EventBus, FlowSystem, QuerySystem, debugEventSystem, gameEvents, getEventListenerCounts, getGlobalEventBusInstance, isEventBusSingleton } from './systems/index.js';
|
|
6
6
|
export { Layout, LogStream, MainContent, OverlaySystem } from './ui/index.js';
|
|
7
7
|
import 'zustand/middleware';
|
|
8
8
|
import 'zustand';
|
package/dist/index.js
CHANGED
|
@@ -522,6 +522,17 @@ var EventBus = class {
|
|
|
522
522
|
* 类型安全在订阅/发射时强制执行
|
|
523
523
|
*/
|
|
524
524
|
__publicField(this, "listeners", /* @__PURE__ */ new Map());
|
|
525
|
+
/**
|
|
526
|
+
* 实例 ID(用于调试)
|
|
527
|
+
* 每个 EventBus 实例都有唯一的 ID
|
|
528
|
+
*/
|
|
529
|
+
__publicField(this, "_id", Math.random().toString(36).substring(2, 9));
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* 获取实例 ID
|
|
533
|
+
*/
|
|
534
|
+
get id() {
|
|
535
|
+
return this._id;
|
|
525
536
|
}
|
|
526
537
|
/**
|
|
527
538
|
* 订阅事件
|
|
@@ -609,13 +620,16 @@ var EventBus = class {
|
|
|
609
620
|
this.listeners.clear();
|
|
610
621
|
}
|
|
611
622
|
};
|
|
612
|
-
var
|
|
623
|
+
var GLOBAL_SYMBOL = /* @__PURE__ */ Symbol.for("__STEAMSHEEP_GAME_EVENTS__");
|
|
613
624
|
function getGlobalEventBus() {
|
|
614
625
|
const globalObj = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof self !== "undefined" ? self : {};
|
|
615
|
-
if (!globalObj[
|
|
616
|
-
globalObj[
|
|
626
|
+
if (!globalObj[GLOBAL_SYMBOL]) {
|
|
627
|
+
globalObj[GLOBAL_SYMBOL] = new EventBus();
|
|
628
|
+
if (typeof window !== "undefined" && typeof console !== "undefined") {
|
|
629
|
+
console.log("[SteamSheep Engine] EventBus \u5355\u4F8B\u5DF2\u521B\u5EFA");
|
|
630
|
+
}
|
|
617
631
|
}
|
|
618
|
-
return globalObj[
|
|
632
|
+
return globalObj[GLOBAL_SYMBOL];
|
|
619
633
|
}
|
|
620
634
|
var gameEvents = getGlobalEventBus();
|
|
621
635
|
var EngineEvents = {
|
|
@@ -637,9 +651,14 @@ var EngineEvents = {
|
|
|
637
651
|
CUSTOM: "engine:custom_trigger"
|
|
638
652
|
};
|
|
639
653
|
function isEventBusSingleton() {
|
|
640
|
-
const
|
|
654
|
+
const GLOBAL_SYMBOL2 = /* @__PURE__ */ Symbol.for("__STEAMSHEEP_GAME_EVENTS__");
|
|
655
|
+
const globalObj = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof self !== "undefined" ? self : {};
|
|
656
|
+
return globalObj[GLOBAL_SYMBOL2] === gameEvents;
|
|
657
|
+
}
|
|
658
|
+
function getGlobalEventBusInstance() {
|
|
659
|
+
const GLOBAL_SYMBOL2 = /* @__PURE__ */ Symbol.for("__STEAMSHEEP_GAME_EVENTS__");
|
|
641
660
|
const globalObj = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof self !== "undefined" ? self : {};
|
|
642
|
-
return globalObj[
|
|
661
|
+
return globalObj[GLOBAL_SYMBOL2];
|
|
643
662
|
}
|
|
644
663
|
function getEventListenerCounts() {
|
|
645
664
|
const counts = {};
|
|
@@ -650,8 +669,13 @@ function getEventListenerCounts() {
|
|
|
650
669
|
return counts;
|
|
651
670
|
}
|
|
652
671
|
function debugEventSystem() {
|
|
672
|
+
const GLOBAL_SYMBOL2 = /* @__PURE__ */ Symbol.for("__STEAMSHEEP_GAME_EVENTS__");
|
|
653
673
|
console.log("\n========== EventBus \u8C03\u8BD5\u4FE1\u606F ==========");
|
|
654
674
|
console.log("\u5355\u4F8B\u72B6\u6001:", isEventBusSingleton() ? "\u2713 \u6B63\u5E38" : "\u2717 \u5F02\u5E38\uFF08\u591A\u4E2A\u5B9E\u4F8B\uFF09");
|
|
675
|
+
const instance = getGlobalEventBusInstance();
|
|
676
|
+
console.log("\u5B9E\u4F8B ID:", instance ? `EventBus@${instance._id || "unknown"}` : "\u672A\u627E\u5230");
|
|
677
|
+
console.log("Symbol Key:", GLOBAL_SYMBOL2.toString());
|
|
678
|
+
console.log("\u5BFC\u51FA\u5B9E\u4F8B:", gameEvents === instance ? "\u2713 \u4E00\u81F4" : "\u2717 \u4E0D\u4E00\u81F4");
|
|
655
679
|
const counts = getEventListenerCounts();
|
|
656
680
|
const eventCount = Object.keys(counts).length;
|
|
657
681
|
if (eventCount === 0) {
|
|
@@ -662,6 +686,10 @@ function debugEventSystem() {
|
|
|
662
686
|
console.log(` - ${event}: ${count} \u4E2A\u76D1\u542C\u5668`);
|
|
663
687
|
});
|
|
664
688
|
}
|
|
689
|
+
console.log("\n\u73AF\u5883\u4FE1\u606F:");
|
|
690
|
+
console.log(" - globalThis:", typeof globalThis !== "undefined" ? "\u2713" : "\u2717");
|
|
691
|
+
console.log(" - window:", typeof window !== "undefined" ? "\u2713" : "\u2717");
|
|
692
|
+
console.log(" - self:", typeof self !== "undefined" ? "\u2713" : "\u2717");
|
|
665
693
|
console.log("=====================================\n");
|
|
666
694
|
}
|
|
667
695
|
|
|
@@ -1716,6 +1744,7 @@ exports.gameEvents = gameEvents;
|
|
|
1716
1744
|
exports.generateId = generateId;
|
|
1717
1745
|
exports.get = get;
|
|
1718
1746
|
exports.getEventListenerCounts = getEventListenerCounts;
|
|
1747
|
+
exports.getGlobalEventBusInstance = getGlobalEventBusInstance;
|
|
1719
1748
|
exports.getPercentage = getPercentage;
|
|
1720
1749
|
exports.getStateDiff = getStateDiff;
|
|
1721
1750
|
exports.getTimeOfDay = getTimeOfDay;
|