@noatgnu/cupcake-vanilla 1.4.6 → 1.4.7

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 CHANGED
File without changes
@@ -3066,10 +3066,11 @@ class DesktopService {
3066
3066
  backendStatusSubject = new Subject();
3067
3067
  windowStateSubject = new Subject();
3068
3068
  wailsRuntime = null;
3069
+ wailsRuntimeReady = Promise.resolve(null);
3069
3070
  constructor() {
3070
3071
  if (this.hasWails()) {
3071
3072
  this._runtime = 'wails';
3072
- this.loadWailsRuntime();
3073
+ this.wailsRuntimeReady = this.loadWailsRuntime();
3073
3074
  }
3074
3075
  else if (this.hasElectron()) {
3075
3076
  this._runtime = 'electron';
@@ -3080,7 +3081,7 @@ class DesktopService {
3080
3081
  }
3081
3082
  async loadWailsRuntime() {
3082
3083
  if (this.wailsRuntime)
3083
- return;
3084
+ return this.wailsRuntime;
3084
3085
  try {
3085
3086
  const wails = await import('@wailsio/runtime');
3086
3087
  this.wailsRuntime = { Call: wails.Call, Events: wails.Events };
@@ -3089,6 +3090,7 @@ class DesktopService {
3089
3090
  catch {
3090
3091
  this.wailsRuntime = null;
3091
3092
  }
3093
+ return this.wailsRuntime;
3092
3094
  }
3093
3095
  hasElectron() {
3094
3096
  return typeof window !== 'undefined' &&
@@ -3129,8 +3131,9 @@ class DesktopService {
3129
3131
  if (this._runtime === 'electron' && window.electronAPI) {
3130
3132
  return window.electronAPI.getAppVersion();
3131
3133
  }
3132
- if (this._runtime === 'wails' && this.wailsRuntime) {
3133
- return this.wailsRuntime.Call.ByName('main.App.GetAppVersion');
3134
+ const wails = this._runtime === 'wails' ? await this.wailsRuntimeReady : null;
3135
+ if (wails) {
3136
+ return wails.Call.ByName('main.App.GetAppVersion');
3134
3137
  }
3135
3138
  return '0.0.0';
3136
3139
  }
@@ -3171,8 +3174,9 @@ class DesktopService {
3171
3174
  if (this._runtime === 'electron' && window.electronAPI) {
3172
3175
  return window.electronAPI.showOpenDialog(options);
3173
3176
  }
3174
- if (this._runtime === 'wails' && this.wailsRuntime) {
3175
- return this.wailsRuntime.Call.ByName('main.App.OpenFile', options?.title || 'Select File');
3177
+ const wails = this._runtime === 'wails' ? await this.wailsRuntimeReady : null;
3178
+ if (wails) {
3179
+ return wails.Call.ByName('main.App.OpenFile', options?.title || 'Select File');
3176
3180
  }
3177
3181
  throw new Error('Not running in desktop environment');
3178
3182
  }
@@ -3198,8 +3202,9 @@ class DesktopService {
3198
3202
  if (this._runtime === 'electron' && window.electronAPI) {
3199
3203
  return window.electronAPI.getBackendPort();
3200
3204
  }
3201
- if (this._runtime === 'wails' && this.wailsRuntime) {
3202
- return this.wailsRuntime.Call.ByName('main.App.GetBackendPort');
3205
+ const wails = this._runtime === 'wails' ? await this.wailsRuntimeReady : null;
3206
+ if (wails) {
3207
+ return wails.Call.ByName('main.App.GetBackendPort');
3203
3208
  }
3204
3209
  return 8000;
3205
3210
  }
@@ -3207,8 +3212,9 @@ class DesktopService {
3207
3212
  if (this._runtime === 'electron' && window.electronAPI) {
3208
3213
  return window.electronAPI.isBackendReady();
3209
3214
  }
3210
- if (this._runtime === 'wails' && this.wailsRuntime) {
3211
- return this.wailsRuntime.Call.ByName('main.App.IsBackendReady');
3215
+ const wails = this._runtime === 'wails' ? await this.wailsRuntimeReady : null;
3216
+ if (wails) {
3217
+ return wails.Call.ByName('main.App.IsBackendReady');
3212
3218
  }
3213
3219
  return false;
3214
3220
  }
@@ -3238,8 +3244,9 @@ class DesktopService {
3238
3244
  return this.windowStateSubject.asObservable();
3239
3245
  }
3240
3246
  async logToFile(message) {
3241
- if (this._runtime === 'wails' && this.wailsRuntime) {
3242
- return this.wailsRuntime.Call.ByName('main.App.LogToFile', message);
3247
+ const wails = this._runtime === 'wails' ? await this.wailsRuntimeReady : null;
3248
+ if (wails) {
3249
+ return wails.Call.ByName('main.App.LogToFile', message);
3243
3250
  }
3244
3251
  }
3245
3252
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.1", ngImport: i0, type: DesktopService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });