@noatgnu/cupcake-vanilla 1.4.6 → 1.4.8
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,14 +3090,24 @@ 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' &&
|
|
3095
3097
|
window.electronAPI !== undefined &&
|
|
3096
3098
|
window.electronAPI.isElectron === true;
|
|
3097
3099
|
}
|
|
3100
|
+
/**
|
|
3101
|
+
* Wails only injects `window._wails` once the page has finished loading, which is after
|
|
3102
|
+
* this service is constructed, so the asset-server origin is checked as well: the `wails:`
|
|
3103
|
+
* scheme on Linux/macOS and the `wails.localhost` host on Windows.
|
|
3104
|
+
*/
|
|
3098
3105
|
hasWails() {
|
|
3099
|
-
|
|
3106
|
+
if (typeof window === 'undefined')
|
|
3107
|
+
return false;
|
|
3108
|
+
return '_wails' in window ||
|
|
3109
|
+
window.location.protocol === 'wails:' ||
|
|
3110
|
+
window.location.hostname === 'wails.localhost';
|
|
3100
3111
|
}
|
|
3101
3112
|
get runtime() {
|
|
3102
3113
|
return this._runtime;
|
|
@@ -3129,8 +3140,9 @@ class DesktopService {
|
|
|
3129
3140
|
if (this._runtime === 'electron' && window.electronAPI) {
|
|
3130
3141
|
return window.electronAPI.getAppVersion();
|
|
3131
3142
|
}
|
|
3132
|
-
|
|
3133
|
-
|
|
3143
|
+
const wails = this._runtime === 'wails' ? await this.wailsRuntimeReady : null;
|
|
3144
|
+
if (wails) {
|
|
3145
|
+
return wails.Call.ByName('main.App.GetAppVersion');
|
|
3134
3146
|
}
|
|
3135
3147
|
return '0.0.0';
|
|
3136
3148
|
}
|
|
@@ -3171,8 +3183,9 @@ class DesktopService {
|
|
|
3171
3183
|
if (this._runtime === 'electron' && window.electronAPI) {
|
|
3172
3184
|
return window.electronAPI.showOpenDialog(options);
|
|
3173
3185
|
}
|
|
3174
|
-
|
|
3175
|
-
|
|
3186
|
+
const wails = this._runtime === 'wails' ? await this.wailsRuntimeReady : null;
|
|
3187
|
+
if (wails) {
|
|
3188
|
+
return wails.Call.ByName('main.App.OpenFile', options?.title || 'Select File');
|
|
3176
3189
|
}
|
|
3177
3190
|
throw new Error('Not running in desktop environment');
|
|
3178
3191
|
}
|
|
@@ -3198,8 +3211,9 @@ class DesktopService {
|
|
|
3198
3211
|
if (this._runtime === 'electron' && window.electronAPI) {
|
|
3199
3212
|
return window.electronAPI.getBackendPort();
|
|
3200
3213
|
}
|
|
3201
|
-
|
|
3202
|
-
|
|
3214
|
+
const wails = this._runtime === 'wails' ? await this.wailsRuntimeReady : null;
|
|
3215
|
+
if (wails) {
|
|
3216
|
+
return wails.Call.ByName('main.App.GetBackendPort');
|
|
3203
3217
|
}
|
|
3204
3218
|
return 8000;
|
|
3205
3219
|
}
|
|
@@ -3207,8 +3221,9 @@ class DesktopService {
|
|
|
3207
3221
|
if (this._runtime === 'electron' && window.electronAPI) {
|
|
3208
3222
|
return window.electronAPI.isBackendReady();
|
|
3209
3223
|
}
|
|
3210
|
-
|
|
3211
|
-
|
|
3224
|
+
const wails = this._runtime === 'wails' ? await this.wailsRuntimeReady : null;
|
|
3225
|
+
if (wails) {
|
|
3226
|
+
return wails.Call.ByName('main.App.IsBackendReady');
|
|
3212
3227
|
}
|
|
3213
3228
|
return false;
|
|
3214
3229
|
}
|
|
@@ -3238,8 +3253,9 @@ class DesktopService {
|
|
|
3238
3253
|
return this.windowStateSubject.asObservable();
|
|
3239
3254
|
}
|
|
3240
3255
|
async logToFile(message) {
|
|
3241
|
-
|
|
3242
|
-
|
|
3256
|
+
const wails = this._runtime === 'wails' ? await this.wailsRuntimeReady : null;
|
|
3257
|
+
if (wails) {
|
|
3258
|
+
return wails.Call.ByName('main.App.LogToFile', message);
|
|
3243
3259
|
}
|
|
3244
3260
|
}
|
|
3245
3261
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.1", ngImport: i0, type: DesktopService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|