@nebulaaa/launcher 1.0.0 → 1.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/launcher.cjs CHANGED
@@ -49,14 +49,16 @@ const LAUNCHER_RESERVED_KEYS = ['App', 'Version', 'Build', 'Language'];
49
49
  class Launcher extends plugin.Plugin {
50
50
  constructor(deps, cfg) {
51
51
  var _a;
52
- dict.Override(cfg !== null && cfg !== void 0 ? cfg : {}, {
53
- app: 'nebulaaa',
54
- version: '1.0.0',
55
- build: exports.Build.Dev,
56
- language: [cc.sys.Language.CHINESE, cc.sys.Language.ENGLISH],
57
- env: 'default',
52
+ // Override 为原地合并:在副本上操作避免变异调用方对象;返回值必须接住,
53
+ // 否则 cfg=null 时兜底写在临时对象上,后续 cfg.Build 读取仍然崩溃
54
+ cfg = dict.Override(Object.assign({}, (cfg !== null && cfg !== void 0 ? cfg : {})), {
55
+ App: 'nebulaaa',
56
+ Version: '1.0.0',
57
+ Build: exports.Build.Dev,
58
+ Language: [cc.sys.Language.CHINESE, cc.sys.Language.ENGLISH],
59
+ Workspace: 'default',
58
60
  });
59
- if ((env.MISC.BROWSER && cfg.Build === exports.Build.Dev) || cfg.Build === exports.Build.Alpha) {
61
+ if (env.MISC.BROWSER && (cfg.Build === exports.Build.Dev || cfg.Build === exports.Build.Alpha)) {
60
62
  const qs = web.GetQueryString();
61
63
  const whitelist = [...LAUNCHER_URL_OVERRIDABLE_KEYS, ...((_a = cfg.AllowedUrlKeys) !== null && _a !== void 0 ? _a : [])];
62
64
  dict.Each(qs, (key, value) => {
@@ -131,14 +133,13 @@ class Launcher extends plugin.Plugin {
131
133
  if (!ctx.Mnt) {
132
134
  ctx.Mnt = new cc.Node('mnt');
133
135
  ctx.Mnt.layer = 0;
134
- ctx.Scene.insertChild(this.Mnt, 0);
136
+ ctx.Scene.insertChild(ctx.Mnt, 0);
135
137
  }
136
138
  // Root
137
139
  ctx.Root = scene.getChildByName('Canvas');
138
- if (!this.Root) {
139
- // Canvas 是舞台的挂载前提,缺失时中止装配;仅记录日志,不向引擎事件派发抛出异常
140
- this.Logger.Error(`启动错误:场景 ${scene.name} 缺少名为 Canvas 的根节点,舞台装配中止`);
141
- return;
140
+ if (!ctx.Root) {
141
+ // Canvas 是舞台的挂载前提,缺失时中止装配
142
+ throw new Error(`启动错误:场景 ${scene.name} 缺少名为 Canvas 的根节点,舞台装配中止`);
142
143
  }
143
144
  // Stage
144
145
  ctx.Stage = ctx.Root.getChildByName('Stage');
@@ -151,14 +152,17 @@ class Launcher extends plugin.Plugin {
151
152
  wid.alignMode = cc.Widget.AlignMode.ON_WINDOW_RESIZE;
152
153
  wid.updateAlignment();
153
154
  ctx.Stage = node;
154
- this.Root.insertChild(this.Stage, 1);
155
+ ctx.Root.insertChild(ctx.Stage, 1);
155
156
  }
156
157
  // Canvas
157
158
  ctx.Canvas = ctx.Root.getComponent(cc.Canvas);
159
+ if (!ctx.Canvas) {
160
+ throw new Error('Root 缺少 Canvas 组件');
161
+ }
158
162
  // CameraUi
159
163
  ctx.CameraUi = (_b = (_a = ctx.Root.getChildByName('Camera')) === null || _a === void 0 ? void 0 : _a.getComponent(cc.Camera)) !== null && _b !== void 0 ? _b : null;
160
- if (!this.CameraUi) {
161
- this.Logger.Warn('启动警告:Canvas 缺少名为 Camera 的子节点,UI 相机不可用');
164
+ if (!ctx.CameraUi) {
165
+ throw new Error('Canvas 缺少名为 Camera 的子节点,UI 相机不可用');
162
166
  }
163
167
  this.Deps.EventBus.Sys.Notify(eventBus.EventMessage.Void(LAUNCHER_EVENT.STAGE_READY));
164
168
  }
@@ -1 +1 @@
1
- "use strict";var e,t=require("cc"),i=require("@nebulaaa/dict"),s=require("@nebulaaa/env"),n=require("@nebulaaa/event-bus"),a=require("@nebulaaa/ms"),r=require("@nebulaaa/plugin"),o=require("@nebulaaa/web");exports.Build=void 0,(e=exports.Build||(exports.Build={})).Dev="dev",e.Alpha="alpha",e.Beta="beta",e.Candidate="candidate",e.Release="release";const u={ENTER_BACKGROUND:"app@enter-background",ENTER_FOREGROUND:"app@enter-foreground",QUIT:"app@quit",LOW_MEMORY:"app@low-memory",STAGE_READY:"app@stage-ready"},l=["Workspace"],g=["App","Version","Build","Language"];class h extends r.Plugin{constructor(e,n){var a;if(i.Override(null!=n?n:{},{app:"nebulaaa",version:"1.0.0",build:exports.Build.Dev,language:[t.sys.Language.CHINESE,t.sys.Language.ENGLISH],env:"default"}),s.MISC.BROWSER&&n.Build===exports.Build.Dev||n.Build===exports.Build.Alpha){const e=o.GetQueryString(),t=[...l,...null!==(a=n.AllowedUrlKeys)&&void 0!==a?a:[]];i.Each(e,(e,i)=>{if(!g.includes(e)&&t.includes(e))try{n[e]=decodeURIComponent(i)}catch(t){n[e]=i}})}super(e,n),this.App=this.Cfg.App,this.Version=this.Cfg.Version,this.Build=this.Cfg.Build,this.IsDev=this.Cfg.Build===exports.Build.Dev,this.IsAlpha=this.Cfg.Build===exports.Build.Alpha,this.IsBeta=this.Cfg.Build===exports.Build.Beta,this.IsCandidate=this.Cfg.Build===exports.Build.Candidate,this.IsRelease=this.Cfg.Build===exports.Build.Release,this.Workspace=this.Cfg.Workspace,this.SupportedLanguages=this.Cfg.Language,this._runningLogic=!0,this._runningInternal=!0,this._timingPause=0,this._elapsed=0,t.director.once(t.Director.EVENT_BEFORE_SCENE_LAUNCH,this.onSceneLaunch,this),t.game.on(t.Game.EVENT_SHOW,this.internalResume,this),t.game.on(t.Game.EVENT_HIDE,this.internalPause,this),t.game.on(t.Game.EVENT_CLOSE,this.internalClose,this),t.game.on(t.Game.EVENT_LOW_MEMORY,this.internalLowMemory,this),this.Logger.Info(`🔥 ${this.App} ${this.Version}_${this.Build}`)}internalPause(){this._runningInternal=!1,this._timingPause=a.Now(),this.Deps.EventBus.Sys.Notify(n.EventMessage.Void(u.ENTER_BACKGROUND))}internalResume(){this._runningInternal=!0,this._timingPause>0&&(this._elapsed=a.Now()-this._timingPause,this._timingPause=0),this.Deps.EventBus.Sys.Notify(n.EventMessage.Void(u.ENTER_FOREGROUND))}internalClose(){this.Deps.EventBus.Sys.Notify(n.EventMessage.Void(u.QUIT)),t.game.targetOff(this),t.director.targetOff(this)}internalLowMemory(){this.Deps.EventBus.Sys.Notify(n.EventMessage.Void(u.LOW_MEMORY))}onSceneLaunch(e){var i,s;const a=this;if(a.Scene=e,a.Mnt=e.getChildByName("mnt"),a.Mnt||(a.Mnt=new t.Node("mnt"),a.Mnt.layer=0,a.Scene.insertChild(this.Mnt,0)),a.Root=e.getChildByName("Canvas"),this.Root){if(a.Stage=a.Root.getChildByName("Stage"),!a.Stage){const e=new t.Node("Stage");e.layer=t.Layers.BitMask.UI_2D;const i=e.addComponent(t.Widget);i.left=i.top=i.right=i.bottom=0,i.isAlignLeft=i.isAlignTop=i.isAlignBottom=i.isAlignRight=!0,i.alignMode=t.Widget.AlignMode.ON_WINDOW_RESIZE,i.updateAlignment(),a.Stage=e,this.Root.insertChild(this.Stage,1)}a.Canvas=a.Root.getComponent(t.Canvas),a.CameraUi=null!==(s=null===(i=a.Root.getChildByName("Camera"))||void 0===i?void 0:i.getComponent(t.Camera))&&void 0!==s?s:null,this.CameraUi||this.Logger.Warn("启动警告:Canvas 缺少名为 Camera 的子节点,UI 相机不可用"),this.Deps.EventBus.Sys.Notify(n.EventMessage.Void(u.STAGE_READY))}else this.Logger.Error(`启动错误:场景 ${e.name} 缺少名为 Canvas 的根节点,舞台装配中止`)}IsBuildOf(e){return this.Build===e}IsLanguageSupported(e){return this.Cfg.Language.includes(e)}Pause(){this._runningLogic=!1}Resume(){this._runningLogic=!0}get Elapsed(){return this._elapsed}get Running(){return this._runningInternal&&this._runningLogic}}exports.LAUNCHER_EVENT=u,exports.LAUNCHER_RESERVED_KEYS=g,exports.LAUNCHER_URL_OVERRIDABLE_KEYS=l,exports.Launcher=h;
1
+ "use strict";var e,t=require("cc"),i=require("@nebulaaa/dict"),s=require("@nebulaaa/env"),n=require("@nebulaaa/event-bus"),a=require("@nebulaaa/ms"),r=require("@nebulaaa/plugin"),o=require("@nebulaaa/web");exports.Build=void 0,(e=exports.Build||(exports.Build={})).Dev="dev",e.Alpha="alpha",e.Beta="beta",e.Candidate="candidate",e.Release="release";const u={ENTER_BACKGROUND:"app@enter-background",ENTER_FOREGROUND:"app@enter-foreground",QUIT:"app@quit",LOW_MEMORY:"app@low-memory",STAGE_READY:"app@stage-ready"},l=["Workspace"],g=["App","Version","Build","Language"];class h extends r.Plugin{constructor(e,n){var a;if(n=i.Override(Object.assign({},null!=n?n:{}),{App:"nebulaaa",Version:"1.0.0",Build:exports.Build.Dev,Language:[t.sys.Language.CHINESE,t.sys.Language.ENGLISH],Workspace:"default"}),s.MISC.BROWSER&&(n.Build===exports.Build.Dev||n.Build===exports.Build.Alpha)){const e=o.GetQueryString(),t=[...l,...null!==(a=n.AllowedUrlKeys)&&void 0!==a?a:[]];i.Each(e,(e,i)=>{if(!g.includes(e)&&t.includes(e))try{n[e]=decodeURIComponent(i)}catch(t){n[e]=i}})}super(e,n),this.App=this.Cfg.App,this.Version=this.Cfg.Version,this.Build=this.Cfg.Build,this.IsDev=this.Cfg.Build===exports.Build.Dev,this.IsAlpha=this.Cfg.Build===exports.Build.Alpha,this.IsBeta=this.Cfg.Build===exports.Build.Beta,this.IsCandidate=this.Cfg.Build===exports.Build.Candidate,this.IsRelease=this.Cfg.Build===exports.Build.Release,this.Workspace=this.Cfg.Workspace,this.SupportedLanguages=this.Cfg.Language,this._runningLogic=!0,this._runningInternal=!0,this._timingPause=0,this._elapsed=0,t.director.once(t.Director.EVENT_BEFORE_SCENE_LAUNCH,this.onSceneLaunch,this),t.game.on(t.Game.EVENT_SHOW,this.internalResume,this),t.game.on(t.Game.EVENT_HIDE,this.internalPause,this),t.game.on(t.Game.EVENT_CLOSE,this.internalClose,this),t.game.on(t.Game.EVENT_LOW_MEMORY,this.internalLowMemory,this),this.Logger.Info(`🔥 ${this.App} ${this.Version}_${this.Build}`)}internalPause(){this._runningInternal=!1,this._timingPause=a.Now(),this.Deps.EventBus.Sys.Notify(n.EventMessage.Void(u.ENTER_BACKGROUND))}internalResume(){this._runningInternal=!0,this._timingPause>0&&(this._elapsed=a.Now()-this._timingPause,this._timingPause=0),this.Deps.EventBus.Sys.Notify(n.EventMessage.Void(u.ENTER_FOREGROUND))}internalClose(){this.Deps.EventBus.Sys.Notify(n.EventMessage.Void(u.QUIT)),t.game.targetOff(this),t.director.targetOff(this)}internalLowMemory(){this.Deps.EventBus.Sys.Notify(n.EventMessage.Void(u.LOW_MEMORY))}onSceneLaunch(e){var i,s;const a=this;if(a.Scene=e,a.Mnt=e.getChildByName("mnt"),a.Mnt||(a.Mnt=new t.Node("mnt"),a.Mnt.layer=0,a.Scene.insertChild(a.Mnt,0)),a.Root=e.getChildByName("Canvas"),!a.Root)throw new Error(`启动错误:场景 ${e.name} 缺少名为 Canvas 的根节点,舞台装配中止`);if(a.Stage=a.Root.getChildByName("Stage"),!a.Stage){const e=new t.Node("Stage");e.layer=t.Layers.BitMask.UI_2D;const i=e.addComponent(t.Widget);i.left=i.top=i.right=i.bottom=0,i.isAlignLeft=i.isAlignTop=i.isAlignBottom=i.isAlignRight=!0,i.alignMode=t.Widget.AlignMode.ON_WINDOW_RESIZE,i.updateAlignment(),a.Stage=e,a.Root.insertChild(a.Stage,1)}if(a.Canvas=a.Root.getComponent(t.Canvas),!a.Canvas)throw new Error("Root 缺少 Canvas 组件");if(a.CameraUi=null!==(s=null===(i=a.Root.getChildByName("Camera"))||void 0===i?void 0:i.getComponent(t.Camera))&&void 0!==s?s:null,!a.CameraUi)throw new Error("Canvas 缺少名为 Camera 的子节点,UI 相机不可用");this.Deps.EventBus.Sys.Notify(n.EventMessage.Void(u.STAGE_READY))}IsBuildOf(e){return this.Build===e}IsLanguageSupported(e){return this.Cfg.Language.includes(e)}Pause(){this._runningLogic=!1}Resume(){this._runningLogic=!0}get Elapsed(){return this._elapsed}get Running(){return this._runningInternal&&this._runningLogic}}exports.LAUNCHER_EVENT=u,exports.LAUNCHER_RESERVED_KEYS=g,exports.LAUNCHER_URL_OVERRIDABLE_KEYS=l,exports.Launcher=h;
@@ -1 +1 @@
1
- import{sys as t,director as e,Director as i,game as n,Game as s,Node as a,Layers as o,Widget as r,Canvas as l,Camera as h}from"cc";import{Override as g,Each as u}from"@nebulaaa/dict";import{MISC as d}from"@nebulaaa/env";import{EventMessage as p}from"@nebulaaa/event-bus";import{Now as E}from"@nebulaaa/ms";import{Plugin as m}from"@nebulaaa/plugin";import{GetQueryString as C}from"@nebulaaa/web";var f;!function(t){t.Dev="dev",t.Alpha="alpha",t.Beta="beta",t.Candidate="candidate",t.Release="release"}(f||(f={}));const _={ENTER_BACKGROUND:"app@enter-background",ENTER_FOREGROUND:"app@enter-foreground",QUIT:"app@quit",LOW_MEMORY:"app@low-memory",STAGE_READY:"app@stage-ready"},c=["Workspace"],R=["App","Version","Build","Language"];class B extends m{constructor(a,o){var r;if(g(null!=o?o:{},{app:"nebulaaa",version:"1.0.0",build:f.Dev,language:[t.Language.CHINESE,t.Language.ENGLISH],env:"default"}),d.BROWSER&&o.Build===f.Dev||o.Build===f.Alpha){const t=C(),e=[...c,...null!==(r=o.AllowedUrlKeys)&&void 0!==r?r:[]];u(t,(t,i)=>{if(!R.includes(t)&&e.includes(t))try{o[t]=decodeURIComponent(i)}catch(e){o[t]=i}})}super(a,o),this.App=this.Cfg.App,this.Version=this.Cfg.Version,this.Build=this.Cfg.Build,this.IsDev=this.Cfg.Build===f.Dev,this.IsAlpha=this.Cfg.Build===f.Alpha,this.IsBeta=this.Cfg.Build===f.Beta,this.IsCandidate=this.Cfg.Build===f.Candidate,this.IsRelease=this.Cfg.Build===f.Release,this.Workspace=this.Cfg.Workspace,this.SupportedLanguages=this.Cfg.Language,this._runningLogic=!0,this._runningInternal=!0,this._timingPause=0,this._elapsed=0,e.once(i.EVENT_BEFORE_SCENE_LAUNCH,this.onSceneLaunch,this),n.on(s.EVENT_SHOW,this.internalResume,this),n.on(s.EVENT_HIDE,this.internalPause,this),n.on(s.EVENT_CLOSE,this.internalClose,this),n.on(s.EVENT_LOW_MEMORY,this.internalLowMemory,this),this.Logger.Info(`🔥 ${this.App} ${this.Version}_${this.Build}`)}internalPause(){this._runningInternal=!1,this._timingPause=E(),this.Deps.EventBus.Sys.Notify(p.Void(_.ENTER_BACKGROUND))}internalResume(){this._runningInternal=!0,this._timingPause>0&&(this._elapsed=E()-this._timingPause,this._timingPause=0),this.Deps.EventBus.Sys.Notify(p.Void(_.ENTER_FOREGROUND))}internalClose(){this.Deps.EventBus.Sys.Notify(p.Void(_.QUIT)),n.targetOff(this),e.targetOff(this)}internalLowMemory(){this.Deps.EventBus.Sys.Notify(p.Void(_.LOW_MEMORY))}onSceneLaunch(t){var e,i;const n=this;if(n.Scene=t,n.Mnt=t.getChildByName("mnt"),n.Mnt||(n.Mnt=new a("mnt"),n.Mnt.layer=0,n.Scene.insertChild(this.Mnt,0)),n.Root=t.getChildByName("Canvas"),this.Root){if(n.Stage=n.Root.getChildByName("Stage"),!n.Stage){const t=new a("Stage");t.layer=o.BitMask.UI_2D;const e=t.addComponent(r);e.left=e.top=e.right=e.bottom=0,e.isAlignLeft=e.isAlignTop=e.isAlignBottom=e.isAlignRight=!0,e.alignMode=r.AlignMode.ON_WINDOW_RESIZE,e.updateAlignment(),n.Stage=t,this.Root.insertChild(this.Stage,1)}n.Canvas=n.Root.getComponent(l),n.CameraUi=null!==(i=null===(e=n.Root.getChildByName("Camera"))||void 0===e?void 0:e.getComponent(h))&&void 0!==i?i:null,this.CameraUi||this.Logger.Warn("启动警告:Canvas 缺少名为 Camera 的子节点,UI 相机不可用"),this.Deps.EventBus.Sys.Notify(p.Void(_.STAGE_READY))}else this.Logger.Error(`启动错误:场景 ${t.name} 缺少名为 Canvas 的根节点,舞台装配中止`)}IsBuildOf(t){return this.Build===t}IsLanguageSupported(t){return this.Cfg.Language.includes(t)}Pause(){this._runningLogic=!1}Resume(){this._runningLogic=!0}get Elapsed(){return this._elapsed}get Running(){return this._runningInternal&&this._runningLogic}}export{f as Build,_ as LAUNCHER_EVENT,R as LAUNCHER_RESERVED_KEYS,c as LAUNCHER_URL_OVERRIDABLE_KEYS,B as Launcher};
1
+ import{sys as e,director as t,Director as i,game as n,Game as s,Node as a,Layers as o,Widget as r,Canvas as l,Camera as u}from"cc";import{Override as h,Each as g}from"@nebulaaa/dict";import{MISC as d}from"@nebulaaa/env";import{EventMessage as p}from"@nebulaaa/event-bus";import{Now as E}from"@nebulaaa/ms";import{Plugin as m}from"@nebulaaa/plugin";import{GetQueryString as C}from"@nebulaaa/web";var f;!function(e){e.Dev="dev",e.Alpha="alpha",e.Beta="beta",e.Candidate="candidate",e.Release="release"}(f||(f={}));const c={ENTER_BACKGROUND:"app@enter-background",ENTER_FOREGROUND:"app@enter-foreground",QUIT:"app@quit",LOW_MEMORY:"app@low-memory",STAGE_READY:"app@stage-ready"},_=["Workspace"],R=["App","Version","Build","Language"];class B extends m{constructor(a,o){var r;if(o=h(Object.assign({},null!=o?o:{}),{App:"nebulaaa",Version:"1.0.0",Build:f.Dev,Language:[e.Language.CHINESE,e.Language.ENGLISH],Workspace:"default"}),d.BROWSER&&(o.Build===f.Dev||o.Build===f.Alpha)){const e=C(),t=[..._,...null!==(r=o.AllowedUrlKeys)&&void 0!==r?r:[]];g(e,(e,i)=>{if(!R.includes(e)&&t.includes(e))try{o[e]=decodeURIComponent(i)}catch(t){o[e]=i}})}super(a,o),this.App=this.Cfg.App,this.Version=this.Cfg.Version,this.Build=this.Cfg.Build,this.IsDev=this.Cfg.Build===f.Dev,this.IsAlpha=this.Cfg.Build===f.Alpha,this.IsBeta=this.Cfg.Build===f.Beta,this.IsCandidate=this.Cfg.Build===f.Candidate,this.IsRelease=this.Cfg.Build===f.Release,this.Workspace=this.Cfg.Workspace,this.SupportedLanguages=this.Cfg.Language,this._runningLogic=!0,this._runningInternal=!0,this._timingPause=0,this._elapsed=0,t.once(i.EVENT_BEFORE_SCENE_LAUNCH,this.onSceneLaunch,this),n.on(s.EVENT_SHOW,this.internalResume,this),n.on(s.EVENT_HIDE,this.internalPause,this),n.on(s.EVENT_CLOSE,this.internalClose,this),n.on(s.EVENT_LOW_MEMORY,this.internalLowMemory,this),this.Logger.Info(`🔥 ${this.App} ${this.Version}_${this.Build}`)}internalPause(){this._runningInternal=!1,this._timingPause=E(),this.Deps.EventBus.Sys.Notify(p.Void(c.ENTER_BACKGROUND))}internalResume(){this._runningInternal=!0,this._timingPause>0&&(this._elapsed=E()-this._timingPause,this._timingPause=0),this.Deps.EventBus.Sys.Notify(p.Void(c.ENTER_FOREGROUND))}internalClose(){this.Deps.EventBus.Sys.Notify(p.Void(c.QUIT)),n.targetOff(this),t.targetOff(this)}internalLowMemory(){this.Deps.EventBus.Sys.Notify(p.Void(c.LOW_MEMORY))}onSceneLaunch(e){var t,i;const n=this;if(n.Scene=e,n.Mnt=e.getChildByName("mnt"),n.Mnt||(n.Mnt=new a("mnt"),n.Mnt.layer=0,n.Scene.insertChild(n.Mnt,0)),n.Root=e.getChildByName("Canvas"),!n.Root)throw new Error(`启动错误:场景 ${e.name} 缺少名为 Canvas 的根节点,舞台装配中止`);if(n.Stage=n.Root.getChildByName("Stage"),!n.Stage){const e=new a("Stage");e.layer=o.BitMask.UI_2D;const t=e.addComponent(r);t.left=t.top=t.right=t.bottom=0,t.isAlignLeft=t.isAlignTop=t.isAlignBottom=t.isAlignRight=!0,t.alignMode=r.AlignMode.ON_WINDOW_RESIZE,t.updateAlignment(),n.Stage=e,n.Root.insertChild(n.Stage,1)}if(n.Canvas=n.Root.getComponent(l),!n.Canvas)throw new Error("Root 缺少 Canvas 组件");if(n.CameraUi=null!==(i=null===(t=n.Root.getChildByName("Camera"))||void 0===t?void 0:t.getComponent(u))&&void 0!==i?i:null,!n.CameraUi)throw new Error("Canvas 缺少名为 Camera 的子节点,UI 相机不可用");this.Deps.EventBus.Sys.Notify(p.Void(c.STAGE_READY))}IsBuildOf(e){return this.Build===e}IsLanguageSupported(e){return this.Cfg.Language.includes(e)}Pause(){this._runningLogic=!1}Resume(){this._runningLogic=!0}get Elapsed(){return this._elapsed}get Running(){return this._runningInternal&&this._runningLogic}}export{f as Build,c as LAUNCHER_EVENT,R as LAUNCHER_RESERVED_KEYS,_ as LAUNCHER_URL_OVERRIDABLE_KEYS,B as Launcher};
package/dist/launcher.mjs CHANGED
@@ -47,14 +47,16 @@ const LAUNCHER_RESERVED_KEYS = ['App', 'Version', 'Build', 'Language'];
47
47
  class Launcher extends Plugin {
48
48
  constructor(deps, cfg) {
49
49
  var _a;
50
- Override(cfg !== null && cfg !== void 0 ? cfg : {}, {
51
- app: 'nebulaaa',
52
- version: '1.0.0',
53
- build: Build.Dev,
54
- language: [sys.Language.CHINESE, sys.Language.ENGLISH],
55
- env: 'default',
50
+ // Override 为原地合并:在副本上操作避免变异调用方对象;返回值必须接住,
51
+ // 否则 cfg=null 时兜底写在临时对象上,后续 cfg.Build 读取仍然崩溃
52
+ cfg = Override(Object.assign({}, (cfg !== null && cfg !== void 0 ? cfg : {})), {
53
+ App: 'nebulaaa',
54
+ Version: '1.0.0',
55
+ Build: Build.Dev,
56
+ Language: [sys.Language.CHINESE, sys.Language.ENGLISH],
57
+ Workspace: 'default',
56
58
  });
57
- if ((MISC.BROWSER && cfg.Build === Build.Dev) || cfg.Build === Build.Alpha) {
59
+ if (MISC.BROWSER && (cfg.Build === Build.Dev || cfg.Build === Build.Alpha)) {
58
60
  const qs = GetQueryString();
59
61
  const whitelist = [...LAUNCHER_URL_OVERRIDABLE_KEYS, ...((_a = cfg.AllowedUrlKeys) !== null && _a !== void 0 ? _a : [])];
60
62
  Each(qs, (key, value) => {
@@ -129,14 +131,13 @@ class Launcher extends Plugin {
129
131
  if (!ctx.Mnt) {
130
132
  ctx.Mnt = new Node('mnt');
131
133
  ctx.Mnt.layer = 0;
132
- ctx.Scene.insertChild(this.Mnt, 0);
134
+ ctx.Scene.insertChild(ctx.Mnt, 0);
133
135
  }
134
136
  // Root
135
137
  ctx.Root = scene.getChildByName('Canvas');
136
- if (!this.Root) {
137
- // Canvas 是舞台的挂载前提,缺失时中止装配;仅记录日志,不向引擎事件派发抛出异常
138
- this.Logger.Error(`启动错误:场景 ${scene.name} 缺少名为 Canvas 的根节点,舞台装配中止`);
139
- return;
138
+ if (!ctx.Root) {
139
+ // Canvas 是舞台的挂载前提,缺失时中止装配
140
+ throw new Error(`启动错误:场景 ${scene.name} 缺少名为 Canvas 的根节点,舞台装配中止`);
140
141
  }
141
142
  // Stage
142
143
  ctx.Stage = ctx.Root.getChildByName('Stage');
@@ -149,14 +150,17 @@ class Launcher extends Plugin {
149
150
  wid.alignMode = Widget.AlignMode.ON_WINDOW_RESIZE;
150
151
  wid.updateAlignment();
151
152
  ctx.Stage = node;
152
- this.Root.insertChild(this.Stage, 1);
153
+ ctx.Root.insertChild(ctx.Stage, 1);
153
154
  }
154
155
  // Canvas
155
156
  ctx.Canvas = ctx.Root.getComponent(Canvas);
157
+ if (!ctx.Canvas) {
158
+ throw new Error('Root 缺少 Canvas 组件');
159
+ }
156
160
  // CameraUi
157
161
  ctx.CameraUi = (_b = (_a = ctx.Root.getChildByName('Camera')) === null || _a === void 0 ? void 0 : _a.getComponent(Camera)) !== null && _b !== void 0 ? _b : null;
158
- if (!this.CameraUi) {
159
- this.Logger.Warn('启动警告:Canvas 缺少名为 Camera 的子节点,UI 相机不可用');
162
+ if (!ctx.CameraUi) {
163
+ throw new Error('Canvas 缺少名为 Camera 的子节点,UI 相机不可用');
160
164
  }
161
165
  this.Deps.EventBus.Sys.Notify(EventMessage.Void(LAUNCHER_EVENT.STAGE_READY));
162
166
  }
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nebulaaa/launcher",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "启动器插件",
5
5
  "author": "doooreyn",
6
6
  "license": "MIT",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nebulaaa/launcher",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "启动器插件",
5
5
  "main": "./dist/launcher.cjs",
6
6
  "module": "./dist/launcher.mjs",