@shimotsuki/core 2.0.31 → 2.0.32

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.d.ts CHANGED
@@ -1026,8 +1026,7 @@ declare class Manager {
1026
1026
  /**启动 */
1027
1027
  boot(): Promise<void>;
1028
1028
  /**合并对象 */
1029
- use(target: string, source: string): this;
1030
- use<T extends object>(target: T, source: T): this;
1029
+ merge<K extends keyof Manager, T extends object>(target: K, source: T): this;
1031
1030
  }
1032
1031
  declare const cat: Manager;
1033
1032
 
package/dist/index.js CHANGED
@@ -2775,57 +2775,41 @@ class Manager {
2775
2775
  /**音频 */
2776
2776
  #audio = null;
2777
2777
  get audio() {
2778
- if (!this.#initialized)
2779
- throw new Error('[CAT] 未初始化');
2780
2778
  return this.#audio;
2781
2779
  }
2782
2780
  /**事件 */
2783
2781
  #event = null;
2784
2782
  get event() {
2785
- if (!this.#initialized)
2786
- throw new Error('[CAT] 未初始化');
2787
2783
  return this.#event;
2788
2784
  }
2789
2785
  /**gui */
2790
2786
  #gui = null;
2791
2787
  get gui() {
2792
- if (!this.#initialized)
2793
- throw new Error('[CAT] 未初始化');
2794
2788
  return this.#gui;
2795
2789
  }
2796
2790
  /**本地存储 */
2797
2791
  #storage = null;
2798
2792
  get storage() {
2799
- if (!this.#initialized)
2800
- throw new Error('[CAT] 未初始化');
2801
2793
  return this.#storage;
2802
2794
  }
2803
2795
  /**资源 */
2804
2796
  #res = null;
2805
2797
  get res() {
2806
- if (!this.#initialized)
2807
- throw new Error('[CAT] 未初始化');
2808
2798
  return this.#res;
2809
2799
  }
2810
2800
  /**工具类 */
2811
2801
  #util = null;
2812
2802
  get util() {
2813
- if (!this.#initialized)
2814
- throw new Error('[CAT] 未初始化');
2815
2803
  return this.#util;
2816
2804
  }
2817
2805
  /**类 */
2818
2806
  #socialGameClient = null;
2819
2807
  get socialGameClient() {
2820
- if (!this.#initialized)
2821
- throw new Error('[CAT] 未初始化');
2822
2808
  return this.#socialGameClient;
2823
2809
  }
2824
2810
  /**数据存储 */
2825
2811
  #store = null;
2826
2812
  get store() {
2827
- if (!this.#initialized)
2828
- throw new Error('[CAT] 未初始化');
2829
2813
  return this.#store;
2830
2814
  }
2831
2815
  /**GUI */
@@ -2837,7 +2821,7 @@ class Manager {
2837
2821
  /**GUI资源配置 */
2838
2822
  setConfig = ({ gui_bundleName = 'resources', audio_local_store_key = 'game_audio' } = {}) => {
2839
2823
  if (this.#initialized) {
2840
- throw new Error('Manager 已初始化,无法修改配置');
2824
+ throw new Error('[CAT] 已初始化,无法修改配置');
2841
2825
  }
2842
2826
  this.#gui_bundle_name = gui_bundleName;
2843
2827
  this.#audio_local_store_key = audio_local_store_key;
@@ -2846,7 +2830,7 @@ class Manager {
2846
2830
  /**启动 */
2847
2831
  async boot() {
2848
2832
  if (this.#initialized) {
2849
- throw new Error('Manager 已初始化');
2833
+ throw new Error('[CAT] 已初始化');
2850
2834
  }
2851
2835
  try {
2852
2836
  this.#store = new CoreStore(this);
@@ -2860,23 +2844,19 @@ class Manager {
2860
2844
  this.#initialized = true;
2861
2845
  }
2862
2846
  catch (err) {
2863
- throw new Error(`Manager 初始化失败: ${err instanceof Error ? err.message : String(err)}`);
2847
+ console.error(`[CAT] 初始化失败:`, err);
2848
+ throw err;
2864
2849
  }
2865
2850
  }
2866
- use(target, source) {
2851
+ /**合并对象 */
2852
+ merge(target, source) {
2867
2853
  if (!this.#initialized)
2868
2854
  throw new Error('[CAT] 未初始化');
2869
- // 如果 target 是字符串,检查实例上是否有对应的属性
2870
- if (typeof target === 'string') {
2871
- Reflect.set(this, target, source);
2872
- return this;
2873
- }
2874
- // 如果 target 是对象,直接合并
2875
- if (target !== null && typeof target === 'object') {
2876
- Object.assign(target, source);
2855
+ if (typeof target !== 'string') {
2856
+ throw new Error(`merge方法第一个参数应该为string类型`);
2877
2857
  }
2878
- else {
2879
- throw new Error('target 必须是字符串或对象');
2858
+ if (Reflect.get(this, target)) {
2859
+ Reflect.set(this, target, source);
2880
2860
  }
2881
2861
  return this;
2882
2862
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shimotsuki/core",
3
- "version": "2.0.31",
3
+ "version": "2.0.32",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",