mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-02 17:52:29 +08:00
Tidy up
This commit is contained in:
parent
00e585e864
commit
0e8144e52f
@ -27,7 +27,7 @@ Informal and incomplete list of things needed in v3.
|
||||
- [x] Error
|
||||
- [x] Question
|
||||
- [x] OpenFile
|
||||
- [ ] SaveFile
|
||||
- [x] SaveFile
|
||||
- [ ] Events
|
||||
- [ ] Screens
|
||||
- [x] Clipboard
|
||||
|
@ -87,28 +87,6 @@ tasks:
|
||||
cmds:
|
||||
- npm install
|
||||
|
||||
build-runtime-dev:
|
||||
dir: internal/runtime/dev
|
||||
deps:
|
||||
- install-runtime-dev-deps
|
||||
sources:
|
||||
- ./*.js
|
||||
generates:
|
||||
- ../ipc_websocket.js
|
||||
cmds:
|
||||
- node build.js
|
||||
|
||||
build-runtime-ipc:
|
||||
dir: internal/runtime
|
||||
deps:
|
||||
- install-runtime-dev-deps
|
||||
sources:
|
||||
- ./desktop/ipc.js
|
||||
generates:
|
||||
- ipc.js
|
||||
cmds:
|
||||
- npx esbuild desktop/ipc.js --bundle --minify --outfile=ipc.js
|
||||
|
||||
test-runtime:
|
||||
dir: internal/runtime
|
||||
cmds:
|
||||
@ -128,10 +106,9 @@ tasks:
|
||||
- build-runtime-debug-darwin
|
||||
- build-runtime-debug-windows
|
||||
- build-runtime-debug-linux
|
||||
- build-runtime-dev
|
||||
- build-runtime-ipc
|
||||
|
||||
cmds:
|
||||
- task: test-runtime
|
||||
- cmd: echo "build complete"
|
||||
|
||||
build-runtime:
|
||||
dir: internal/runtime
|
||||
|
@ -56,3 +56,5 @@ require (
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
mvdan.cc/sh/v3 v3.6.0 // indirect
|
||||
)
|
||||
|
||||
replace github.com/wailsapp/wails/v2 => ../v2
|
@ -3,22 +3,19 @@
|
||||
package runtime
|
||||
|
||||
var RuntimeAssetsBundle = &RuntimeAssets{
|
||||
desktopIPC: DesktopIPC,
|
||||
runtimeDesktopJS: DesktopRuntime,
|
||||
}
|
||||
|
||||
type RuntimeAssets struct {
|
||||
desktopIPC []byte
|
||||
websocketIPC []byte
|
||||
runtimeDesktopJS []byte
|
||||
}
|
||||
|
||||
func (r *RuntimeAssets) DesktopIPC() []byte {
|
||||
return r.desktopIPC
|
||||
return []byte("")
|
||||
}
|
||||
|
||||
func (r *RuntimeAssets) WebsocketIPC() []byte {
|
||||
return r.websocketIPC
|
||||
return []byte("")
|
||||
}
|
||||
|
||||
func (r *RuntimeAssets) RuntimeDesktopJS() []byte {
|
||||
|
@ -3,23 +3,19 @@
|
||||
package runtime
|
||||
|
||||
var RuntimeAssetsBundle = &RuntimeAssets{
|
||||
desktopIPC: DesktopIPC,
|
||||
websocketIPC: WebsocketIPC,
|
||||
runtimeDesktopJS: DesktopRuntime,
|
||||
}
|
||||
|
||||
type RuntimeAssets struct {
|
||||
desktopIPC []byte
|
||||
websocketIPC []byte
|
||||
runtimeDesktopJS []byte
|
||||
}
|
||||
|
||||
func (r *RuntimeAssets) DesktopIPC() []byte {
|
||||
return r.desktopIPC
|
||||
return []byte("")
|
||||
}
|
||||
|
||||
func (r *RuntimeAssets) WebsocketIPC() []byte {
|
||||
return r.websocketIPC
|
||||
return []byte("")
|
||||
}
|
||||
|
||||
func (r *RuntimeAssets) RuntimeDesktopJS() []byte {
|
||||
|
@ -1,67 +0,0 @@
|
||||
/*
|
||||
_ __ _ __
|
||||
| | / /___ _(_) /____
|
||||
| | /| / / __ `/ / / ___/
|
||||
| |/ |/ / /_/ / / (__ )
|
||||
|__/|__/\__,_/_/_/____/
|
||||
The electron alternative for Go
|
||||
(c) Lea Anthony 2019-present
|
||||
*/
|
||||
/* jshint esversion: 6 */
|
||||
|
||||
import {Call} from './calls';
|
||||
|
||||
// This is where we bind go method wrappers
|
||||
window.go = {};
|
||||
|
||||
export function SetBindings(bindingsMap) {
|
||||
try {
|
||||
bindingsMap = JSON.parse(bindingsMap);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
|
||||
// Initialise the bindings map
|
||||
window.go = window.go || {};
|
||||
|
||||
// Iterate package names
|
||||
Object.keys(bindingsMap).forEach((packageName) => {
|
||||
|
||||
// Create inner map if it doesn't exist
|
||||
window.go[packageName] = window.go[packageName] || {};
|
||||
|
||||
// Iterate struct names
|
||||
Object.keys(bindingsMap[packageName]).forEach((structName) => {
|
||||
|
||||
// Create inner map if it doesn't exist
|
||||
window.go[packageName][structName] = window.go[packageName][structName] || {};
|
||||
|
||||
Object.keys(bindingsMap[packageName][structName]).forEach((methodName) => {
|
||||
|
||||
window.go[packageName][structName][methodName] = function () {
|
||||
|
||||
// No timeout by default
|
||||
let timeout = 0;
|
||||
|
||||
// Actual function
|
||||
function dynamic() {
|
||||
const args = [].slice.call(arguments);
|
||||
return Call([packageName, structName, methodName].join('.'), args, timeout);
|
||||
}
|
||||
|
||||
// Allow setting timeout to function
|
||||
dynamic.setTimeout = function (newTimeout) {
|
||||
timeout = newTimeout;
|
||||
};
|
||||
|
||||
// Allow getting timeout to function
|
||||
dynamic.getTimeout = function () {
|
||||
return timeout;
|
||||
};
|
||||
|
||||
return dynamic;
|
||||
}();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
/**
|
||||
* @description: Use the system default browser to open the url
|
||||
* @param {string} url
|
||||
* @return {void}
|
||||
*/
|
||||
export function BrowserOpenURL(url) {
|
||||
window.WailsInvoke('BO:' + url);
|
||||
}
|
@ -1,189 +0,0 @@
|
||||
/*
|
||||
_ __ _ __
|
||||
| | / /___ _(_) /____
|
||||
| | /| / / __ `/ / / ___/
|
||||
| |/ |/ / /_/ / / (__ )
|
||||
|__/|__/\__,_/_/_/____/
|
||||
The electron alternative for Go
|
||||
(c) Lea Anthony 2019-present
|
||||
*/
|
||||
/* jshint esversion: 6 */
|
||||
|
||||
export const callbacks = {};
|
||||
|
||||
/**
|
||||
* Returns a number from the native browser random function
|
||||
*
|
||||
* @returns number
|
||||
*/
|
||||
function cryptoRandom() {
|
||||
let array = new Uint32Array(1);
|
||||
return window.crypto.getRandomValues(array)[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a number using da old-skool Math.Random
|
||||
* I likes to call it LOLRandom
|
||||
*
|
||||
* @returns number
|
||||
*/
|
||||
function basicRandom() {
|
||||
return Math.random() * 9007199254740991;
|
||||
}
|
||||
|
||||
// Pick a random number function based on browser capability
|
||||
let randomFunc;
|
||||
if (window.crypto) {
|
||||
randomFunc = cryptoRandom;
|
||||
} else {
|
||||
randomFunc = basicRandom;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Call sends a message to the backend to call the binding with the
|
||||
* given data. A promise is returned and will be completed when the
|
||||
* backend responds. This will be resolved when the call was successful
|
||||
* or rejected if an error is passed back.
|
||||
* There is a timeout mechanism. If the call doesn't respond in the given
|
||||
* time (in milliseconds) then the promise is rejected.
|
||||
*
|
||||
* @export
|
||||
* @param {string} name
|
||||
* @param {any=} args
|
||||
* @param {number=} timeout
|
||||
* @returns
|
||||
*/
|
||||
export function Call(name, args, timeout) {
|
||||
|
||||
// Timeout infinite by default
|
||||
if (timeout == null) {
|
||||
timeout = 0;
|
||||
}
|
||||
|
||||
let windowID = window.wails.window.ID();
|
||||
|
||||
// Create a promise
|
||||
return new Promise(function (resolve, reject) {
|
||||
|
||||
// Create a unique callbackID
|
||||
let callbackID;
|
||||
do {
|
||||
callbackID = name + '-' + randomFunc();
|
||||
} while (callbacks[callbackID]);
|
||||
|
||||
let timeoutHandle;
|
||||
// Set timeout
|
||||
if (timeout > 0) {
|
||||
timeoutHandle = setTimeout(function () {
|
||||
reject(Error('Call to ' + name + ' timed out. Request ID: ' + callbackID));
|
||||
}, timeout);
|
||||
}
|
||||
|
||||
// Store callback
|
||||
callbacks[callbackID] = {
|
||||
timeoutHandle: timeoutHandle,
|
||||
reject: reject,
|
||||
resolve: resolve
|
||||
};
|
||||
|
||||
try {
|
||||
const payload = {
|
||||
name,
|
||||
args,
|
||||
callbackID,
|
||||
windowID,
|
||||
};
|
||||
|
||||
// Make the call
|
||||
window.WailsInvoke('C' + JSON.stringify(payload));
|
||||
} catch (e) {
|
||||
// eslint-disable-next-line
|
||||
console.error(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
window.ObfuscatedCall = (id, args, timeout) => {
|
||||
|
||||
// Timeout infinite by default
|
||||
if (timeout == null) {
|
||||
timeout = 0;
|
||||
}
|
||||
|
||||
// Create a promise
|
||||
return new Promise(function (resolve, reject) {
|
||||
|
||||
// Create a unique callbackID
|
||||
let callbackID;
|
||||
do {
|
||||
callbackID = id + '-' + randomFunc();
|
||||
} while (callbacks[callbackID]);
|
||||
|
||||
let timeoutHandle;
|
||||
// Set timeout
|
||||
if (timeout > 0) {
|
||||
timeoutHandle = setTimeout(function () {
|
||||
reject(Error('Call to method ' + id + ' timed out. Request ID: ' + callbackID));
|
||||
}, timeout);
|
||||
}
|
||||
|
||||
// Store callback
|
||||
callbacks[callbackID] = {
|
||||
timeoutHandle: timeoutHandle,
|
||||
reject: reject,
|
||||
resolve: resolve
|
||||
};
|
||||
|
||||
try {
|
||||
const payload = {
|
||||
id,
|
||||
args,
|
||||
callbackID,
|
||||
windowID: window.wails.window.ID(),
|
||||
};
|
||||
|
||||
// Make the call
|
||||
window.WailsInvoke('c' + JSON.stringify(payload));
|
||||
} catch (e) {
|
||||
// eslint-disable-next-line
|
||||
console.error(e);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Called by the backend to return data to a previously called
|
||||
* binding invocation
|
||||
*
|
||||
* @export
|
||||
* @param {string} incomingMessage
|
||||
*/
|
||||
export function Callback(incomingMessage) {
|
||||
// Parse the message
|
||||
let message;
|
||||
try {
|
||||
message = JSON.parse(incomingMessage);
|
||||
} catch (e) {
|
||||
const error = `Invalid JSON passed to callback: ${e.message}. Message: ${incomingMessage}`;
|
||||
runtime.LogDebug(error);
|
||||
throw new Error(error);
|
||||
}
|
||||
let callbackID = message.callbackid;
|
||||
let callbackData = callbacks[callbackID];
|
||||
if (!callbackData) {
|
||||
const error = `Callback '${callbackID}' not registered!!!`;
|
||||
console.error(error); // eslint-disable-line
|
||||
throw new Error(error);
|
||||
}
|
||||
clearTimeout(callbackData.timeoutHandle);
|
||||
|
||||
delete callbacks[callbackID];
|
||||
|
||||
if (message.error) {
|
||||
callbackData.reject(message.error);
|
||||
} else {
|
||||
callbackData.resolve(message.result);
|
||||
}
|
||||
}
|
@ -1,212 +0,0 @@
|
||||
/*
|
||||
_ __ _ __
|
||||
| | / /___ _(_) /____
|
||||
| | /| / / __ `/ / / ___/
|
||||
| |/ |/ / /_/ / / (__ )
|
||||
|__/|__/\__,_/_/_/____/
|
||||
The electron alternative for Go
|
||||
(c) Lea Anthony 2019-present
|
||||
*/
|
||||
/* jshint esversion: 6 */
|
||||
|
||||
// Defines a single listener with a maximum number of times to callback
|
||||
|
||||
/**
|
||||
* The Listener class defines a listener! :-)
|
||||
*
|
||||
* @class Listener
|
||||
*/
|
||||
class Listener {
|
||||
/**
|
||||
* Creates an instance of Listener.
|
||||
* @param {string} eventName
|
||||
* @param {function} callback
|
||||
* @param {number} maxCallbacks
|
||||
* @memberof Listener
|
||||
*/
|
||||
constructor(eventName, callback, maxCallbacks) {
|
||||
this.eventName = eventName;
|
||||
// Default of -1 means infinite
|
||||
this.maxCallbacks = maxCallbacks || -1;
|
||||
// Callback invokes the callback with the given data
|
||||
// Returns true if this listener should be destroyed
|
||||
this.Callback = (data) => {
|
||||
callback.apply(null, data);
|
||||
// If maxCallbacks is infinite, return false (do not destroy)
|
||||
if (this.maxCallbacks === -1) {
|
||||
return false;
|
||||
}
|
||||
// Decrement maxCallbacks. Return true if now 0, otherwise false
|
||||
this.maxCallbacks -= 1;
|
||||
return this.maxCallbacks === 0;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export const eventListeners = {};
|
||||
|
||||
/**
|
||||
* Registers an event listener that will be invoked `maxCallbacks` times before being destroyed
|
||||
*
|
||||
* @export
|
||||
* @param {string} eventName
|
||||
* @param {function} callback
|
||||
* @param {number} maxCallbacks
|
||||
* @returns {function} A function to cancel the listener
|
||||
*/
|
||||
export function EventsOnMultiple(eventName, callback, maxCallbacks) {
|
||||
eventListeners[eventName] = eventListeners[eventName] || [];
|
||||
const thisListener = new Listener(eventName, callback, maxCallbacks);
|
||||
eventListeners[eventName].push(thisListener);
|
||||
return () => listenerOff(thisListener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers an event listener that will be invoked every time the event is emitted
|
||||
*
|
||||
* @export
|
||||
* @param {string} eventName
|
||||
* @param {function} callback
|
||||
* @returns {function} A function to cancel the listener
|
||||
*/
|
||||
export function EventsOn(eventName, callback) {
|
||||
return EventsOnMultiple(eventName, callback, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers an event listener that will be invoked once then destroyed
|
||||
*
|
||||
* @export
|
||||
* @param {string} eventName
|
||||
* @param {function} callback
|
||||
* @returns {function} A function to cancel the listener
|
||||
*/
|
||||
export function EventsOnce(eventName, callback) {
|
||||
return EventsOnMultiple(eventName, callback, 1);
|
||||
}
|
||||
|
||||
function notifyListeners(eventData) {
|
||||
|
||||
// Get the event name
|
||||
let eventName = eventData.name;
|
||||
|
||||
// Check if we have any listeners for this event
|
||||
if (eventListeners[eventName]) {
|
||||
|
||||
// Keep a list of listener indexes to destroy
|
||||
const newEventListenerList = eventListeners[eventName].slice();
|
||||
|
||||
// Iterate listeners
|
||||
for (let count = 0; count < eventListeners[eventName].length; count += 1) {
|
||||
|
||||
// Get next listener
|
||||
const listener = eventListeners[eventName][count];
|
||||
|
||||
let data = eventData.data;
|
||||
|
||||
// Do the callback
|
||||
const destroy = listener.Callback(data);
|
||||
if (destroy) {
|
||||
// if the listener indicated to destroy itself, add it to the destroy list
|
||||
newEventListenerList.splice(count, 1);
|
||||
}
|
||||
}
|
||||
|
||||
// Update callbacks with new list of listeners
|
||||
if (newEventListenerList.length === 0) {
|
||||
removeListener(eventName);
|
||||
} else {
|
||||
eventListeners[eventName] = newEventListenerList;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify informs frontend listeners that an event was emitted with the given data
|
||||
*
|
||||
* @export
|
||||
* @param {string} notifyMessage - encoded notification message
|
||||
|
||||
*/
|
||||
export function EventsNotify(notifyMessage) {
|
||||
// Parse the message
|
||||
let message;
|
||||
try {
|
||||
message = JSON.parse(notifyMessage);
|
||||
} catch (e) {
|
||||
const error = 'Invalid JSON passed to Notify: ' + notifyMessage;
|
||||
throw new Error(error);
|
||||
}
|
||||
notifyListeners(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Emit an event with the given name and data
|
||||
*
|
||||
* @export
|
||||
* @param {string} eventName
|
||||
*/
|
||||
export function EventsEmit(eventName) {
|
||||
|
||||
const payload = {
|
||||
name: eventName,
|
||||
data: [].slice.apply(arguments).slice(1),
|
||||
};
|
||||
|
||||
// Notify JS listeners
|
||||
notifyListeners(payload);
|
||||
|
||||
// Notify Go listeners
|
||||
window.WailsInvoke('EE' + JSON.stringify(payload));
|
||||
}
|
||||
|
||||
function removeListener(eventName) {
|
||||
// Remove local listeners
|
||||
delete eventListeners[eventName];
|
||||
|
||||
// Notify Go listeners
|
||||
window.WailsInvoke('EX' + eventName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Off unregisters a listener previously registered with On,
|
||||
* optionally multiple listeneres can be unregistered via `additionalEventNames`
|
||||
*
|
||||
* @param {string} eventName
|
||||
* @param {...string} additionalEventNames
|
||||
*/
|
||||
export function EventsOff(eventName, ...additionalEventNames) {
|
||||
removeListener(eventName)
|
||||
|
||||
if (additionalEventNames.length > 0) {
|
||||
additionalEventNames.forEach(eventName => {
|
||||
removeListener(eventName)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Off unregisters all event listeners previously registered with On
|
||||
*/
|
||||
export function EventsOffAll() {
|
||||
const eventNames = Object.keys(eventListeners);
|
||||
for (let i = 0; i !== eventNames.length; i++) {
|
||||
removeListener(eventNames[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* listenerOff unregisters a listener previously registered with EventsOn
|
||||
*
|
||||
* @param {Listener} listener
|
||||
*/
|
||||
function listenerOff(listener) {
|
||||
const eventName = listener.eventName;
|
||||
// Remove local listener
|
||||
eventListeners[eventName] = eventListeners[eventName].filter(l => l !== listener);
|
||||
|
||||
// Clean up if there are no event listeners left
|
||||
if (eventListeners[eventName].length === 0) {
|
||||
removeListener(eventName);
|
||||
}
|
||||
}
|
@ -1,132 +0,0 @@
|
||||
import { EventsOnMultiple, EventsNotify, eventListeners, EventsOn, EventsEmit, EventsOffAll, EventsOnce, EventsOff } from './events'
|
||||
import { expect, describe, it, beforeAll, vi, afterEach, beforeEach } from 'vitest'
|
||||
// Edit an assertion and save to see HMR in action
|
||||
|
||||
beforeAll(() => {
|
||||
window.WailsInvoke = vi.fn(() => {})
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
EventsOffAll();
|
||||
vi.resetAllMocks()
|
||||
})
|
||||
|
||||
describe('EventsOnMultiple', () => {
|
||||
it('should stop after a specified number of times', () => {
|
||||
const cb = vi.fn()
|
||||
EventsOnMultiple('a', cb, 5)
|
||||
EventsNotify(JSON.stringify({name: 'a', data: {}}))
|
||||
EventsNotify(JSON.stringify({name: 'a', data: {}}))
|
||||
EventsNotify(JSON.stringify({name: 'a', data: {}}))
|
||||
EventsNotify(JSON.stringify({name: 'a', data: {}}))
|
||||
EventsNotify(JSON.stringify({name: 'a', data: {}}))
|
||||
EventsNotify(JSON.stringify({name: 'a', data: {}}))
|
||||
expect(cb).toBeCalledTimes(5);
|
||||
expect(window.WailsInvoke).toBeCalledTimes(1);
|
||||
expect(window.WailsInvoke).toHaveBeenLastCalledWith('EXa');
|
||||
})
|
||||
|
||||
it('should return a cancel fn', () => {
|
||||
const cb = vi.fn()
|
||||
const cancel = EventsOnMultiple('a', cb, 5)
|
||||
EventsNotify(JSON.stringify({name: 'a', data: {}}))
|
||||
EventsNotify(JSON.stringify({name: 'a', data: {}}))
|
||||
cancel()
|
||||
EventsNotify(JSON.stringify({name: 'a', data: {}}))
|
||||
EventsNotify(JSON.stringify({name: 'a', data: {}}))
|
||||
expect(cb).toBeCalledTimes(2)
|
||||
expect(window.WailsInvoke).toBeCalledTimes(1);
|
||||
expect(window.WailsInvoke).toHaveBeenLastCalledWith('EXa');
|
||||
})
|
||||
})
|
||||
|
||||
describe('EventsOn', () => {
|
||||
it('should create a listener with a count of -1', () => {
|
||||
EventsOn('a', () => {})
|
||||
expect(eventListeners['a'][0].maxCallbacks).toBe(-1)
|
||||
})
|
||||
|
||||
it('should return a cancel fn', () => {
|
||||
const cancel = EventsOn('a', () => {})
|
||||
cancel();
|
||||
expect(window.WailsInvoke).toBeCalledTimes(1);
|
||||
expect(window.WailsInvoke).toHaveBeenLastCalledWith('EXa');
|
||||
})
|
||||
})
|
||||
|
||||
describe('EventsOnce', () => {
|
||||
it('should create a listener with a count of 1', () => {
|
||||
EventsOnce('a', () => {})
|
||||
expect(eventListeners['a'][0].maxCallbacks).toBe(1)
|
||||
})
|
||||
|
||||
it('should return a cancel fn', () => {
|
||||
const cancel = EventsOn('a', () => {})
|
||||
cancel();
|
||||
expect(window.WailsInvoke).toBeCalledTimes(1);
|
||||
expect(window.WailsInvoke).toHaveBeenLastCalledWith('EXa');
|
||||
})
|
||||
})
|
||||
|
||||
describe('EventsNotify', () => {
|
||||
it('should inform a listener', () => {
|
||||
const cb = vi.fn()
|
||||
EventsOn('a', cb)
|
||||
EventsNotify(JSON.stringify({name: 'a', data: ["one", "two", "three"]}))
|
||||
expect(cb).toBeCalledTimes(1);
|
||||
expect(cb).toHaveBeenLastCalledWith("one", "two", "three");
|
||||
expect(window.WailsInvoke).toBeCalledTimes(0);
|
||||
})
|
||||
})
|
||||
|
||||
describe('EventsEmit', () => {
|
||||
it('should emit an event', () => {
|
||||
EventsEmit('a', 'one', 'two', 'three')
|
||||
expect(window.WailsInvoke).toBeCalledTimes(1);
|
||||
const calledWith = window.WailsInvoke.calls[0][0];
|
||||
expect(calledWith.slice(0, 2)).toBe('EE')
|
||||
expect(JSON.parse(calledWith.slice(2))).toStrictEqual({data: ["one", "two", "three"], name: "a"})
|
||||
})
|
||||
})
|
||||
|
||||
describe('EventsOff', () => {
|
||||
beforeEach(() => {
|
||||
EventsOn('a', () => {})
|
||||
EventsOn('a', () => {})
|
||||
EventsOn('a', () => {})
|
||||
EventsOn('b', () => {})
|
||||
EventsOn('c', () => {})
|
||||
})
|
||||
|
||||
it('should cancel all event listeners for a single type', () => {
|
||||
EventsOff('a')
|
||||
expect(eventListeners['a']).toBeUndefined()
|
||||
expect(eventListeners['b']).not.toBeUndefined()
|
||||
expect(eventListeners['c']).not.toBeUndefined()
|
||||
expect(window.WailsInvoke).toBeCalledTimes(1);
|
||||
expect(window.WailsInvoke).toHaveBeenLastCalledWith('EXa');
|
||||
})
|
||||
|
||||
it('should cancel all event listeners for multiple types', () => {
|
||||
EventsOff('a', 'b')
|
||||
expect(eventListeners['a']).toBeUndefined()
|
||||
expect(eventListeners['b']).toBeUndefined()
|
||||
expect(eventListeners['c']).not.toBeUndefined()
|
||||
expect(window.WailsInvoke).toBeCalledTimes(2);
|
||||
expect(window.WailsInvoke.calls).toStrictEqual([['EXa'], ['EXb']]);
|
||||
})
|
||||
})
|
||||
|
||||
describe('EventsOffAll', () => {
|
||||
it('should cancel all event listeners', () => {
|
||||
EventsOn('a', () => {})
|
||||
EventsOn('a', () => {})
|
||||
EventsOn('a', () => {})
|
||||
EventsOn('b', () => {})
|
||||
EventsOn('c', () => {})
|
||||
EventsOffAll()
|
||||
expect(eventListeners).toStrictEqual({})
|
||||
expect(window.WailsInvoke).toBeCalledTimes(3);
|
||||
expect(window.WailsInvoke.calls).toStrictEqual([['EXa'], ['EXb'], ['EXc']]);
|
||||
})
|
||||
})
|
@ -1,45 +0,0 @@
|
||||
/*
|
||||
_ __ _ __
|
||||
| | / /___ _(_) /____
|
||||
| | /| / / __ `/ / / ___/
|
||||
| |/ |/ / /_/ / / (__ )
|
||||
|__/|__/\__,_/_/_/____/
|
||||
The electron alternative for Go
|
||||
(c) Lea Anthony 2019-present
|
||||
*/
|
||||
/* jshint esversion: 9 */
|
||||
|
||||
|
||||
|
||||
let postMessage = null;
|
||||
|
||||
(function () {
|
||||
// Credit: https://stackoverflow.com/a/2631521
|
||||
let _deeptest = function (s) {
|
||||
let obj = window[s.shift()];
|
||||
while (obj && s.length) obj = obj[s.shift()];
|
||||
return obj;
|
||||
};
|
||||
let windows = _deeptest(["chrome", "webview", "postMessage"]);
|
||||
let mac_linux = _deeptest(["webkit", "messageHandlers", "external", "postMessage"]);
|
||||
|
||||
if (!windows && !mac_linux) {
|
||||
console.error("Unsupported Platform");
|
||||
return;
|
||||
}
|
||||
|
||||
if (windows) {
|
||||
postMessage = (message) => window.chrome.webview.postMessage(message);
|
||||
}
|
||||
if (mac_linux) {
|
||||
postMessage = (message) => window.webkit.messageHandlers.external.postMessage(message);
|
||||
}
|
||||
})();
|
||||
|
||||
export function invoke(message, id) {
|
||||
if( id && id !== -1) {
|
||||
postMessage("WINDOWID:"+ id + ":" + message);
|
||||
} else {
|
||||
postMessage(message);
|
||||
}
|
||||
}
|
@ -1,113 +0,0 @@
|
||||
/*
|
||||
_ __ _ __
|
||||
| | / /___ _(_) /____
|
||||
| | /| / / __ `/ / / ___/
|
||||
| |/ |/ / /_/ / / (__ )
|
||||
|__/|__/\__,_/_/_/____/
|
||||
The electron alternative for Go
|
||||
(c) Lea Anthony 2019-present
|
||||
*/
|
||||
|
||||
/* jshint esversion: 6 */
|
||||
|
||||
/**
|
||||
* Sends a log message to the backend with the given level + message
|
||||
*
|
||||
* @param {string} level
|
||||
* @param {string} message
|
||||
*/
|
||||
function sendLogMessage(level, message) {
|
||||
|
||||
// Log Message format:
|
||||
// l[type][message]
|
||||
window.WailsInvoke('L' + level + message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log the given trace message with the backend
|
||||
*
|
||||
* @export
|
||||
* @param {string} message
|
||||
*/
|
||||
export function LogTrace(message) {
|
||||
sendLogMessage('T', message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log the given message with the backend
|
||||
*
|
||||
* @export
|
||||
* @param {string} message
|
||||
*/
|
||||
export function LogPrint(message) {
|
||||
sendLogMessage('P', message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log the given debug message with the backend
|
||||
*
|
||||
* @export
|
||||
* @param {string} message
|
||||
*/
|
||||
export function LogDebug(message) {
|
||||
sendLogMessage('D', message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log the given info message with the backend
|
||||
*
|
||||
* @export
|
||||
* @param {string} message
|
||||
*/
|
||||
export function LogInfo(message) {
|
||||
sendLogMessage('I', message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log the given warning message with the backend
|
||||
*
|
||||
* @export
|
||||
* @param {string} message
|
||||
*/
|
||||
export function LogWarning(message) {
|
||||
sendLogMessage('W', message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log the given error message with the backend
|
||||
*
|
||||
* @export
|
||||
* @param {string} message
|
||||
*/
|
||||
export function LogError(message) {
|
||||
sendLogMessage('E', message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log the given fatal message with the backend
|
||||
*
|
||||
* @export
|
||||
* @param {string} message
|
||||
*/
|
||||
export function LogFatal(message) {
|
||||
sendLogMessage('F', message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Log level to the given log level
|
||||
*
|
||||
* @export
|
||||
* @param {number} loglevel
|
||||
*/
|
||||
export function SetLogLevel(loglevel) {
|
||||
sendLogMessage('S', loglevel);
|
||||
}
|
||||
|
||||
// Log levels
|
||||
export const LogLevel = {
|
||||
TRACE: 1,
|
||||
DEBUG: 2,
|
||||
INFO: 3,
|
||||
WARNING: 4,
|
||||
ERROR: 5,
|
||||
};
|
@ -9,21 +9,11 @@ The electron alternative for Go
|
||||
*/
|
||||
/* jshint esversion: 9 */
|
||||
|
||||
import {invoke} from "./ipc.js";
|
||||
import {Callback, callbacks} from './calls';
|
||||
import {EventsNotify, eventListeners} from "./events";
|
||||
import {SetBindings} from "./bindings";
|
||||
|
||||
|
||||
import {Info, Warning, Error, Question, OpenFile, SaveFile, dialogCallback, dialogErrorCallback, } from "./dialogs";
|
||||
|
||||
import * as Clipboard from './clipboard';
|
||||
import {newWindow} from "./window";
|
||||
|
||||
// export function Environment() {
|
||||
// return Call(":wails:Environment");
|
||||
// }
|
||||
|
||||
// Internal wails endpoints
|
||||
window.wails = {
|
||||
...newRuntime(-1),
|
||||
@ -37,10 +27,6 @@ window._wails = {
|
||||
|
||||
export function newRuntime(id) {
|
||||
return {
|
||||
// Log: newLog(id),
|
||||
// Browser: newBrowser(id),
|
||||
// Screen: newScreen(id),
|
||||
// Events: newEvents(id),
|
||||
Clipboard: {
|
||||
...Clipboard
|
||||
},
|
||||
@ -53,17 +39,6 @@ export function newRuntime(id) {
|
||||
SaveFile,
|
||||
},
|
||||
Window: newWindow(id),
|
||||
Application: {
|
||||
Show: () => invoke("S"),
|
||||
Hide: () => invoke("H"),
|
||||
Quit: () => invoke("Q"),
|
||||
}
|
||||
// GetWindow: function (windowID) {
|
||||
// if (!windowID) {
|
||||
// return this.Window;
|
||||
// }
|
||||
// return newWindow(windowID);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,25 +0,0 @@
|
||||
/*
|
||||
_ __ _ __
|
||||
| | / /___ _(_) /____
|
||||
| | /| / / __ `/ / / ___/
|
||||
| |/ |/ / /_/ / / (__ )
|
||||
|__/|__/\__,_/_/_/____/
|
||||
The electron alternative for Go
|
||||
(c) Lea Anthony 2019-present
|
||||
*/
|
||||
|
||||
/* jshint esversion: 9 */
|
||||
|
||||
|
||||
import {Call} from "./calls";
|
||||
|
||||
|
||||
/**
|
||||
* Gets the all screens. Call this anew each time you want to refresh data from the underlying windowing system.
|
||||
* @export
|
||||
* @typedef {import('../wrapper/runtime').Screen} Screen
|
||||
* @return {Promise<{Screen[]}>} The screens
|
||||
*/
|
||||
export function ScreenGetAll() {
|
||||
return Call(":wails:ScreenGetAll");
|
||||
}
|
@ -20,6 +20,10 @@ export function newWindow(id) {
|
||||
// SetSystemDefaultTheme: () => call('WASDT'),
|
||||
// SetLightTheme: () => call('WALT'),
|
||||
// SetDarkTheme: () => call('WADT'),
|
||||
// IsFullscreen: () => call('WIF'),
|
||||
// IsMaximized: () => call('WIM'),
|
||||
// IsMinimized: () => call('WIMN'),
|
||||
// IsWindowed: () => call('WIF'),
|
||||
Center: () => call('Center'),
|
||||
SetTitle: (title) => call('SetTitle', {title}),
|
||||
Fullscreen: () => call('Fullscreen'),
|
||||
@ -39,19 +43,6 @@ export function newWindow(id) {
|
||||
UnMaximise: () => call('UnMaximise'),
|
||||
Minimise: () => call('Minimise'),
|
||||
UnMinimise: () => call('UnMinimise'),
|
||||
SetBackgroundColour: (r, g, b, a) => call('SetBackgroundColour', {R, G, B, A}),
|
||||
SetBackgroundColour: (r, g, b, a) => call('SetBackgroundColour', {r, g, b, a}),
|
||||
}
|
||||
}
|
||||
|
||||
// export function IsFullscreen: ()=> // return Call(":wails:WindowIsFullscreen"),
|
||||
//
|
||||
|
||||
// export function IsMaximised: ()=> // return Call(":wails:WindowIsMaximised"),
|
||||
//
|
||||
|
||||
// export function IsMinimised: ()=> // return Call(":wails:WindowIsMinimised"),
|
||||
//
|
||||
|
||||
// export function IsNormal: ()=> // return Call(":wails:WindowIsNormal"),
|
||||
//
|
||||
|
||||
|
@ -1,54 +0,0 @@
|
||||
<script>
|
||||
|
||||
import {overlayVisible} from './store'
|
||||
import {fade,} from 'svelte/transition';
|
||||
</script>
|
||||
|
||||
{#if $overlayVisible }
|
||||
<div class="wails-reconnect-overlay" transition:fade="{{ duration: 300 }}">
|
||||
<div class="wails-reconnect-overlay-content">
|
||||
<div class="wails-reconnect-overlay-loadingspinner"></div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
.wails-reconnect-overlay {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
backdrop-filter: blur(2px) saturate(0%) contrast(50%) brightness(25%);
|
||||
z-index: 999999
|
||||
}
|
||||
|
||||
.wails-reconnect-overlay-content {
|
||||
position: relative;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
margin: 0;
|
||||
background-image: url(data:image/png;base64,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);
|
||||
background-repeat: no-repeat;
|
||||
background-position: center
|
||||
}
|
||||
|
||||
.wails-reconnect-overlay-loadingspinner {
|
||||
pointer-events: none;
|
||||
width: 2.5em;
|
||||
height: 2.5em;
|
||||
border: .4em solid transparent;
|
||||
border-color: #f00 #eee0 #f00 #eee0;
|
||||
border-radius: 50%;
|
||||
animation: loadingspin 1s linear infinite;
|
||||
margin: auto;
|
||||
padding: 2.5em
|
||||
}
|
||||
|
||||
@keyframes loadingspin {
|
||||
100% {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
@ -1,15 +0,0 @@
|
||||
/* jshint esversion: 8 */
|
||||
const esbuild = require("esbuild");
|
||||
const sveltePlugin = require("esbuild-svelte");
|
||||
|
||||
esbuild
|
||||
.build({
|
||||
entryPoints: ["main.js"],
|
||||
bundle: true,
|
||||
minify: true,
|
||||
outfile: "../ipc_websocket.js",
|
||||
plugins: [sveltePlugin({compileOptions: {css: true}})],
|
||||
logLevel: "info",
|
||||
sourcemap: "inline",
|
||||
})
|
||||
.catch(() => process.exit(1));
|
@ -1,8 +0,0 @@
|
||||
export function log(message) {
|
||||
// eslint-disable-next-line
|
||||
console.log(
|
||||
'%c wails dev %c ' + message + ' ',
|
||||
'background: #aa0000; color: #fff; border-radius: 3px 0px 0px 3px; padding: 1px; font-size: 0.7rem',
|
||||
'background: #009900; color: #fff; border-radius: 0px 3px 3px 0px; padding: 1px; font-size: 0.7rem'
|
||||
);
|
||||
}
|
@ -1,125 +0,0 @@
|
||||
/*
|
||||
_ __ _ __
|
||||
| | / /___ _(_) /____
|
||||
| | /| / / __ `/ / / ___/
|
||||
| |/ |/ / /_/ / / (__ )
|
||||
|__/|__/\__,_/_/_/____/
|
||||
The electron alternative for Go
|
||||
(c) Lea Anthony 2019-present
|
||||
*/
|
||||
/* jshint esversion: 6 */
|
||||
|
||||
import {log} from "./log";
|
||||
import Overlay from "./Overlay.svelte";
|
||||
import {hideOverlay, showOverlay} from "./store";
|
||||
|
||||
let components = {};
|
||||
|
||||
let wailsInvokeInternal = null;
|
||||
let messageQueue = [];
|
||||
|
||||
window.WailsInvoke = (message) => {
|
||||
if (!wailsInvokeInternal) {
|
||||
console.log("Queueing: " + message);
|
||||
messageQueue.push(message);
|
||||
return;
|
||||
}
|
||||
wailsInvokeInternal(message);
|
||||
};
|
||||
|
||||
window.addEventListener('DOMContentLoaded', () => {
|
||||
components.overlay = new Overlay({
|
||||
target: document.body,
|
||||
anchor: document.querySelector('#wails-spinner'),
|
||||
});
|
||||
});
|
||||
|
||||
let websocket = null;
|
||||
let connectTimer;
|
||||
|
||||
window.onbeforeunload = function () {
|
||||
if (websocket) {
|
||||
websocket.onclose = function () {
|
||||
};
|
||||
websocket.close();
|
||||
websocket = null;
|
||||
}
|
||||
};
|
||||
|
||||
// ...and attempt to connect
|
||||
connect();
|
||||
|
||||
function setupIPCBridge() {
|
||||
wailsInvokeInternal = (message) => {
|
||||
websocket.send(message);
|
||||
};
|
||||
for (let i = 0; i < messageQueue.length; i++) {
|
||||
console.log("sending queued message: " + messageQueue[i]);
|
||||
window.WailsInvoke(messageQueue[i]);
|
||||
}
|
||||
messageQueue = [];
|
||||
}
|
||||
|
||||
// Handles incoming websocket connections
|
||||
function handleConnect() {
|
||||
log('Connected to backend');
|
||||
hideOverlay();
|
||||
setupIPCBridge();
|
||||
clearInterval(connectTimer);
|
||||
websocket.onclose = handleDisconnect;
|
||||
websocket.onmessage = handleMessage;
|
||||
}
|
||||
|
||||
// Handles websocket disconnects
|
||||
function handleDisconnect() {
|
||||
log('Disconnected from backend');
|
||||
websocket = null;
|
||||
showOverlay();
|
||||
connect();
|
||||
}
|
||||
|
||||
function _connect() {
|
||||
if (websocket == null) {
|
||||
websocket = new WebSocket('ws://' + window.location.host + '/wails/ipc');
|
||||
websocket.onopen = handleConnect;
|
||||
websocket.onerror = function (e) {
|
||||
e.stopImmediatePropagation();
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
websocket = null;
|
||||
return false;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Try to connect to the backend every .5s
|
||||
function connect() {
|
||||
_connect();
|
||||
connectTimer = setInterval(_connect, 500);
|
||||
}
|
||||
|
||||
function handleMessage(message) {
|
||||
|
||||
if (message.data === "reload") {
|
||||
window.runtime.WindowReload();
|
||||
return;
|
||||
}
|
||||
if (message.data === "reloadapp") {
|
||||
window.runtime.WindowReloadApp()
|
||||
return;
|
||||
}
|
||||
|
||||
// As a bridge we ignore js and css injections
|
||||
switch (message.data[0]) {
|
||||
// Notifications
|
||||
case 'n':
|
||||
window.wails.EventsNotify(message.data.slice(1));
|
||||
break;
|
||||
case 'c':
|
||||
const callbackData = message.data.slice(1);
|
||||
window.wails.Callback(callbackData);
|
||||
break;
|
||||
default:
|
||||
log('Unknown message: ' + message.data);
|
||||
}
|
||||
}
|
1536
v3/internal/runtime/dev/package-lock.json
generated
1536
v3/internal/runtime/dev/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,18 +0,0 @@
|
||||
{
|
||||
"name": "dev",
|
||||
"version": "3.0.0",
|
||||
"description": "Wails JS Dev",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
"build": "run-p build:*",
|
||||
"build:dev": "node build.js"
|
||||
},
|
||||
"author": "Lea Anthony <lea.anthony@gmail.com>",
|
||||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
"esbuild": "^0.12.17",
|
||||
"esbuild-svelte": "^0.5.6",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"svelte": "^3.49.0"
|
||||
}
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
import {writable} from 'svelte/store';
|
||||
|
||||
/** Overlay */
|
||||
export const overlayVisible = writable(false);
|
||||
|
||||
export function showOverlay() {
|
||||
overlayVisible.set(true);
|
||||
}
|
||||
|
||||
export function hideOverlay() {
|
||||
overlayVisible.set(false);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
package runtime
|
||||
|
||||
import _ "embed"
|
||||
|
||||
//go:embed ipc_websocket.js
|
||||
var WebsocketIPC []byte
|
||||
|
||||
//go:embed ipc.js
|
||||
var DesktopIPC []byte
|
@ -1 +0,0 @@
|
||||
(()=>{var o=null;(function(){let s=function(e){let n=window[e.shift()];for(;n&&e.length;)n=n[e.shift()];return n},t=s(["chrome","webview","postMessage"]),i=s(["webkit","messageHandlers","external","postMessage"]);if(!t&&!i){console.error("Unsupported Platform");return}t&&(o=e=>window.chrome.webview.postMessage(e)),i&&(o=e=>window.webkit.messageHandlers.external.postMessage(e))})();function l(s,t){o(t&&t!==-1?"WINDOWID:"+t+":"+s:s)}})();
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1 +1 @@
|
||||
(()=>{var M=Object.defineProperty;var D=(t,e)=>{for(var n in e)M(t,n,{get:e[n],enumerable:!0})};var c=null;(function(){let t=function(o){let i=window[o.shift()];for(;i&&o.length;)i=i[o.shift()];return i},e=t(["chrome","webview","postMessage"]),n=t(["webkit","messageHandlers","external","postMessage"]);if(!e&&!n){console.error("Unsupported Platform");return}e&&(c=o=>window.chrome.webview.postMessage(o)),n&&(c=o=>window.webkit.messageHandlers.external.postMessage(o))})();function u(t,e){c(e&&e!==-1?"WINDOWID:"+e+":"+t:t)}var m={};function T(){let t=new Uint32Array(1);return window.crypto.getRandomValues(t)[0]}function W(){return Math.random()*9007199254740991}var w;window.crypto?w=T:w=W;window.ObfuscatedCall=(t,e,n)=>(n==null&&(n=0),new Promise(function(o,i){let r;do r=t+"-"+w();while(m[r]);let p;n>0&&(p=setTimeout(function(){i(Error("Call to method "+t+" timed out. Request ID: "+r))},n)),m[r]={timeoutHandle:p,reject:i,resolve:o};try{let f={id:t,args:e,callbackID:r,windowID:window.wails.window.ID()};window.WailsInvoke("c"+JSON.stringify(f))}catch(f){console.error(f)}}));window.go={};var F=window.location.origin+"/wails/runtime";function h(t,e){let n=new URL(F);return n.searchParams.append("method",t),n.searchParams.append("args",JSON.stringify(e)),new Promise((o,i)=>{fetch(n).then(r=>{if(r.ok)return r.headers.get("content-type")&&r.headers.get("content-type").indexOf("application/json")!==-1?r.json():r.text();i(Error(r.statusText))}).then(r=>o(r)).catch(r=>i(r))})}function s(t,e){return!e||e===-1?function(n,o){return o=o||{},h(t+"."+n,o)}:function(n,o){return o=o||{},o.windowID=e,h(t+"."+n,o)}}var H="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var x=(t=21)=>{let e="",n=t;for(;n--;)e+=H[Math.random()*64|0];return e};var P=s("dialog"),l=new Map;function U(){let t;do t=x();while(l.has(t));return t}function g(t,e,n){let o=l.get(t);o&&(n?o.resolve(JSON.parse(e)):o.resolve(e),l.delete(t))}function S(t,e){let n=l.get(t);n&&(n.reject(e),l.delete(t))}function a(t,e){return new Promise((n,o)=>{let i=U();e=e||{},e["dialog-id"]=i,l.set(i,{resolve:n,reject:o}),P(t,e).catch(r=>{o(r),l.delete(i)})})}function b(t){return a("Info",t)}function y(t){return a("Warning",t)}function v(t){return a("Error",t)}function C(t){return a("Question",t)}function k(t){return a("OpenFile",t)}function E(t){return a("SaveFile",t)}var d={};D(d,{SetText:()=>J,Text:()=>L});var O=s("clipboard");function J(t){return O("SetText",{text:t})}function L(){return O("Text")}function I(t){let e=s("window",t);return{Center:()=>e("Center"),SetTitle:n=>e("SetTitle",{title:n}),Fullscreen:()=>e("Fullscreen"),UnFullscreen:()=>e("UnFullscreen"),SetSize:(n,o)=>e("SetSize",{width:n,height:o}),Size:()=>e("Size"),SetMaxSize:(n,o)=>e("SetMaxSize",{width:n,height:o}),SetMinSize:(n,o)=>e("SetMinSize",{width:n,height:o}),SetAlwaysOnTop:n=>e("SetAlwaysOnTop",{alwaysOnTop:n}),SetPosition:(n,o)=>e("SetPosition",{x:n,y:o}),Position:()=>e("Position"),Screen:()=>e("Screen"),Hide:()=>e("Hide"),Maximise:()=>e("Maximise"),Show:()=>e("Show"),ToggleMaximise:()=>e("ToggleMaximise"),UnMaximise:()=>e("UnMaximise"),Minimise:()=>e("Minimise"),UnMinimise:()=>e("UnMinimise"),SetBackgroundColour:(n,o,i,r)=>e("SetBackgroundColour",{R,G,B,A})}}window.wails={...z(-1)};window._wails={dialogCallback:g,dialogErrorCallback:S};function z(t){return{Clipboard:{...d},Dialog:{Info:b,Warning:y,Error:v,Question:C,OpenFile:k,SaveFile:E},Window:I(t),Application:{Show:()=>u("S"),Hide:()=>u("H"),Quit:()=>u("Q")}}}console.log("Wails v3.0.0 Debug Mode Enabled");})();
|
||||
(()=>{var T=Object.defineProperty;var F=(n,e)=>{for(var t in e)T(n,t,{get:e[t],enumerable:!0})};var b=window.location.origin+"/wails/runtime";function m(n,e){let t=new URL(b);return t.searchParams.append("method",n),t.searchParams.append("args",JSON.stringify(e)),new Promise((i,o)=>{fetch(t).then(r=>{if(r.ok)return r.headers.get("content-type")&&r.headers.get("content-type").indexOf("application/json")!==-1?r.json():r.text();o(Error(r.statusText))}).then(r=>i(r)).catch(r=>o(r))})}function a(n,e){return!e||e===-1?function(t,i){return i=i||{},m(n+"."+t,i)}:function(t,i){return i=i||{},i.windowID=e,m(n+"."+t,i)}}var O="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var s=(n=21)=>{let e="",t=n;for(;t--;)e+=O[Math.random()*64|0];return e};var U=a("dialog"),l=new Map;function z(){let n;do n=s();while(l.has(n));return n}function d(n,e,t){let i=l.get(n);i&&(t?i.resolve(JSON.parse(e)):i.resolve(e),l.delete(n))}function f(n,e){let t=l.get(n);t&&(t.reject(e),l.delete(n))}function u(n,e){return new Promise((t,i)=>{let o=z();e=e||{},e["dialog-id"]=o,l.set(o,{resolve:t,reject:i}),U(n,e).catch(r=>{i(r),l.delete(o)})})}function p(n){return u("Info",n)}function w(n){return u("Warning",n)}function S(n){return u("Error",n)}function x(n){return u("Question",n)}function g(n){return u("OpenFile",n)}function h(n){return u("SaveFile",n)}var c={};F(c,{SetText:()=>E,Text:()=>P});var M=a("clipboard");function E(n){return M("SetText",{text:n})}function P(){return M("Text")}function C(n){let e=a("window",n);return{Center:()=>e("Center"),SetTitle:t=>e("SetTitle",{title:t}),Fullscreen:()=>e("Fullscreen"),UnFullscreen:()=>e("UnFullscreen"),SetSize:(t,i)=>e("SetSize",{width:t,height:i}),Size:()=>e("Size"),SetMaxSize:(t,i)=>e("SetMaxSize",{width:t,height:i}),SetMinSize:(t,i)=>e("SetMinSize",{width:t,height:i}),SetAlwaysOnTop:t=>e("SetAlwaysOnTop",{alwaysOnTop:t}),SetPosition:(t,i)=>e("SetPosition",{x:t,y:i}),Position:()=>e("Position"),Screen:()=>e("Screen"),Hide:()=>e("Hide"),Maximise:()=>e("Maximise"),Show:()=>e("Show"),ToggleMaximise:()=>e("ToggleMaximise"),UnMaximise:()=>e("UnMaximise"),Minimise:()=>e("Minimise"),UnMinimise:()=>e("UnMinimise"),SetBackgroundColour:(t,i,o,r)=>e("SetBackgroundColour",{r:t,g:i,b:o,a:r})}}window.wails={...R(-1)};window._wails={dialogCallback:d,dialogErrorCallback:f};function R(n){return{Clipboard:{...c},Dialog:{Info:p,Warning:w,Error:S,Question:x,OpenFile:g,SaveFile:h},Window:C(n)}}console.log("Wails v3.0.0 Debug Mode Enabled");})();
|
||||
|
@ -1 +1 @@
|
||||
(()=>{var M=Object.defineProperty;var D=(t,e)=>{for(var n in e)M(t,n,{get:e[n],enumerable:!0})};var c=null;(function(){let t=function(o){let i=window[o.shift()];for(;i&&o.length;)i=i[o.shift()];return i},e=t(["chrome","webview","postMessage"]),n=t(["webkit","messageHandlers","external","postMessage"]);if(!e&&!n){console.error("Unsupported Platform");return}e&&(c=o=>window.chrome.webview.postMessage(o)),n&&(c=o=>window.webkit.messageHandlers.external.postMessage(o))})();function u(t,e){c(e&&e!==-1?"WINDOWID:"+e+":"+t:t)}var m={};function T(){let t=new Uint32Array(1);return window.crypto.getRandomValues(t)[0]}function W(){return Math.random()*9007199254740991}var w;window.crypto?w=T:w=W;window.ObfuscatedCall=(t,e,n)=>(n==null&&(n=0),new Promise(function(o,i){let r;do r=t+"-"+w();while(m[r]);let p;n>0&&(p=setTimeout(function(){i(Error("Call to method "+t+" timed out. Request ID: "+r))},n)),m[r]={timeoutHandle:p,reject:i,resolve:o};try{let f={id:t,args:e,callbackID:r,windowID:window.wails.window.ID()};window.WailsInvoke("c"+JSON.stringify(f))}catch(f){console.error(f)}}));window.go={};var F=window.location.origin+"/wails/runtime";function h(t,e){let n=new URL(F);return n.searchParams.append("method",t),n.searchParams.append("args",JSON.stringify(e)),new Promise((o,i)=>{fetch(n).then(r=>{if(r.ok)return r.headers.get("content-type")&&r.headers.get("content-type").indexOf("application/json")!==-1?r.json():r.text();i(Error(r.statusText))}).then(r=>o(r)).catch(r=>i(r))})}function s(t,e){return!e||e===-1?function(n,o){return o=o||{},h(t+"."+n,o)}:function(n,o){return o=o||{},o.windowID=e,h(t+"."+n,o)}}var H="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var x=(t=21)=>{let e="",n=t;for(;n--;)e+=H[Math.random()*64|0];return e};var P=s("dialog"),l=new Map;function U(){let t;do t=x();while(l.has(t));return t}function g(t,e,n){let o=l.get(t);o&&(n?o.resolve(JSON.parse(e)):o.resolve(e),l.delete(t))}function S(t,e){let n=l.get(t);n&&(n.reject(e),l.delete(t))}function a(t,e){return new Promise((n,o)=>{let i=U();e=e||{},e["dialog-id"]=i,l.set(i,{resolve:n,reject:o}),P(t,e).catch(r=>{o(r),l.delete(i)})})}function b(t){return a("Info",t)}function y(t){return a("Warning",t)}function v(t){return a("Error",t)}function C(t){return a("Question",t)}function k(t){return a("OpenFile",t)}function E(t){return a("SaveFile",t)}var d={};D(d,{SetText:()=>J,Text:()=>L});var O=s("clipboard");function J(t){return O("SetText",{text:t})}function L(){return O("Text")}function I(t){let e=s("window",t);return{Center:()=>e("Center"),SetTitle:n=>e("SetTitle",{title:n}),Fullscreen:()=>e("Fullscreen"),UnFullscreen:()=>e("UnFullscreen"),SetSize:(n,o)=>e("SetSize",{width:n,height:o}),Size:()=>e("Size"),SetMaxSize:(n,o)=>e("SetMaxSize",{width:n,height:o}),SetMinSize:(n,o)=>e("SetMinSize",{width:n,height:o}),SetAlwaysOnTop:n=>e("SetAlwaysOnTop",{alwaysOnTop:n}),SetPosition:(n,o)=>e("SetPosition",{x:n,y:o}),Position:()=>e("Position"),Screen:()=>e("Screen"),Hide:()=>e("Hide"),Maximise:()=>e("Maximise"),Show:()=>e("Show"),ToggleMaximise:()=>e("ToggleMaximise"),UnMaximise:()=>e("UnMaximise"),Minimise:()=>e("Minimise"),UnMinimise:()=>e("UnMinimise"),SetBackgroundColour:(n,o,i,r)=>e("SetBackgroundColour",{R,G,B,A})}}window.wails={...z(-1)};window._wails={dialogCallback:g,dialogErrorCallback:S};function z(t){return{Clipboard:{...d},Dialog:{Info:b,Warning:y,Error:v,Question:C,OpenFile:k,SaveFile:E},Window:I(t),Application:{Show:()=>u("S"),Hide:()=>u("H"),Quit:()=>u("Q")}}}console.log("Wails v3.0.0 Debug Mode Enabled");})();
|
||||
(()=>{var T=Object.defineProperty;var F=(n,e)=>{for(var t in e)T(n,t,{get:e[t],enumerable:!0})};var b=window.location.origin+"/wails/runtime";function m(n,e){let t=new URL(b);return t.searchParams.append("method",n),t.searchParams.append("args",JSON.stringify(e)),new Promise((i,o)=>{fetch(t).then(r=>{if(r.ok)return r.headers.get("content-type")&&r.headers.get("content-type").indexOf("application/json")!==-1?r.json():r.text();o(Error(r.statusText))}).then(r=>i(r)).catch(r=>o(r))})}function a(n,e){return!e||e===-1?function(t,i){return i=i||{},m(n+"."+t,i)}:function(t,i){return i=i||{},i.windowID=e,m(n+"."+t,i)}}var O="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var s=(n=21)=>{let e="",t=n;for(;t--;)e+=O[Math.random()*64|0];return e};var U=a("dialog"),l=new Map;function z(){let n;do n=s();while(l.has(n));return n}function d(n,e,t){let i=l.get(n);i&&(t?i.resolve(JSON.parse(e)):i.resolve(e),l.delete(n))}function f(n,e){let t=l.get(n);t&&(t.reject(e),l.delete(n))}function u(n,e){return new Promise((t,i)=>{let o=z();e=e||{},e["dialog-id"]=o,l.set(o,{resolve:t,reject:i}),U(n,e).catch(r=>{i(r),l.delete(o)})})}function p(n){return u("Info",n)}function w(n){return u("Warning",n)}function S(n){return u("Error",n)}function x(n){return u("Question",n)}function g(n){return u("OpenFile",n)}function h(n){return u("SaveFile",n)}var c={};F(c,{SetText:()=>E,Text:()=>P});var M=a("clipboard");function E(n){return M("SetText",{text:n})}function P(){return M("Text")}function C(n){let e=a("window",n);return{Center:()=>e("Center"),SetTitle:t=>e("SetTitle",{title:t}),Fullscreen:()=>e("Fullscreen"),UnFullscreen:()=>e("UnFullscreen"),SetSize:(t,i)=>e("SetSize",{width:t,height:i}),Size:()=>e("Size"),SetMaxSize:(t,i)=>e("SetMaxSize",{width:t,height:i}),SetMinSize:(t,i)=>e("SetMinSize",{width:t,height:i}),SetAlwaysOnTop:t=>e("SetAlwaysOnTop",{alwaysOnTop:t}),SetPosition:(t,i)=>e("SetPosition",{x:t,y:i}),Position:()=>e("Position"),Screen:()=>e("Screen"),Hide:()=>e("Hide"),Maximise:()=>e("Maximise"),Show:()=>e("Show"),ToggleMaximise:()=>e("ToggleMaximise"),UnMaximise:()=>e("UnMaximise"),Minimise:()=>e("Minimise"),UnMinimise:()=>e("UnMinimise"),SetBackgroundColour:(t,i,o,r)=>e("SetBackgroundColour",{r:t,g:i,b:o,a:r})}}window.wails={...R(-1)};window._wails={dialogCallback:d,dialogErrorCallback:f};function R(n){return{Clipboard:{...c},Dialog:{Info:p,Warning:w,Error:S,Question:x,OpenFile:g,SaveFile:h},Window:C(n)}}console.log("Wails v3.0.0 Debug Mode Enabled");})();
|
||||
|
@ -1 +1 @@
|
||||
(()=>{var M=Object.defineProperty;var D=(t,e)=>{for(var n in e)M(t,n,{get:e[n],enumerable:!0})};var c=null;(function(){let t=function(o){let i=window[o.shift()];for(;i&&o.length;)i=i[o.shift()];return i},e=t(["chrome","webview","postMessage"]),n=t(["webkit","messageHandlers","external","postMessage"]);if(!e&&!n){console.error("Unsupported Platform");return}e&&(c=o=>window.chrome.webview.postMessage(o)),n&&(c=o=>window.webkit.messageHandlers.external.postMessage(o))})();function u(t,e){c(e&&e!==-1?"WINDOWID:"+e+":"+t:t)}var m={};function T(){let t=new Uint32Array(1);return window.crypto.getRandomValues(t)[0]}function W(){return Math.random()*9007199254740991}var w;window.crypto?w=T:w=W;window.ObfuscatedCall=(t,e,n)=>(n==null&&(n=0),new Promise(function(o,i){let r;do r=t+"-"+w();while(m[r]);let p;n>0&&(p=setTimeout(function(){i(Error("Call to method "+t+" timed out. Request ID: "+r))},n)),m[r]={timeoutHandle:p,reject:i,resolve:o};try{let f={id:t,args:e,callbackID:r,windowID:window.wails.window.ID()};window.WailsInvoke("c"+JSON.stringify(f))}catch(f){console.error(f)}}));window.go={};var F=window.location.origin+"/wails/runtime";function h(t,e){let n=new URL(F);return n.searchParams.append("method",t),n.searchParams.append("args",JSON.stringify(e)),new Promise((o,i)=>{fetch(n).then(r=>{if(r.ok)return r.headers.get("content-type")&&r.headers.get("content-type").indexOf("application/json")!==-1?r.json():r.text();i(Error(r.statusText))}).then(r=>o(r)).catch(r=>i(r))})}function s(t,e){return!e||e===-1?function(n,o){return o=o||{},h(t+"."+n,o)}:function(n,o){return o=o||{},o.windowID=e,h(t+"."+n,o)}}var H="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var x=(t=21)=>{let e="",n=t;for(;n--;)e+=H[Math.random()*64|0];return e};var P=s("dialog"),l=new Map;function U(){let t;do t=x();while(l.has(t));return t}function g(t,e,n){let o=l.get(t);o&&(n?o.resolve(JSON.parse(e)):o.resolve(e),l.delete(t))}function S(t,e){let n=l.get(t);n&&(n.reject(e),l.delete(t))}function a(t,e){return new Promise((n,o)=>{let i=U();e=e||{},e["dialog-id"]=i,l.set(i,{resolve:n,reject:o}),P(t,e).catch(r=>{o(r),l.delete(i)})})}function b(t){return a("Info",t)}function y(t){return a("Warning",t)}function v(t){return a("Error",t)}function C(t){return a("Question",t)}function k(t){return a("OpenFile",t)}function E(t){return a("SaveFile",t)}var d={};D(d,{SetText:()=>J,Text:()=>L});var O=s("clipboard");function J(t){return O("SetText",{text:t})}function L(){return O("Text")}function I(t){let e=s("window",t);return{Center:()=>e("Center"),SetTitle:n=>e("SetTitle",{title:n}),Fullscreen:()=>e("Fullscreen"),UnFullscreen:()=>e("UnFullscreen"),SetSize:(n,o)=>e("SetSize",{width:n,height:o}),Size:()=>e("Size"),SetMaxSize:(n,o)=>e("SetMaxSize",{width:n,height:o}),SetMinSize:(n,o)=>e("SetMinSize",{width:n,height:o}),SetAlwaysOnTop:n=>e("SetAlwaysOnTop",{alwaysOnTop:n}),SetPosition:(n,o)=>e("SetPosition",{x:n,y:o}),Position:()=>e("Position"),Screen:()=>e("Screen"),Hide:()=>e("Hide"),Maximise:()=>e("Maximise"),Show:()=>e("Show"),ToggleMaximise:()=>e("ToggleMaximise"),UnMaximise:()=>e("UnMaximise"),Minimise:()=>e("Minimise"),UnMinimise:()=>e("UnMinimise"),SetBackgroundColour:(n,o,i,r)=>e("SetBackgroundColour",{R,G,B,A})}}window.wails={...z(-1)};window._wails={dialogCallback:g,dialogErrorCallback:S};function z(t){return{Clipboard:{...d},Dialog:{Info:b,Warning:y,Error:v,Question:C,OpenFile:k,SaveFile:E},Window:I(t),Application:{Show:()=>u("S"),Hide:()=>u("H"),Quit:()=>u("Q")}}}console.log("Wails v3.0.0 Debug Mode Enabled");})();
|
||||
(()=>{var T=Object.defineProperty;var F=(n,e)=>{for(var t in e)T(n,t,{get:e[t],enumerable:!0})};var b=window.location.origin+"/wails/runtime";function m(n,e){let t=new URL(b);return t.searchParams.append("method",n),t.searchParams.append("args",JSON.stringify(e)),new Promise((i,o)=>{fetch(t).then(r=>{if(r.ok)return r.headers.get("content-type")&&r.headers.get("content-type").indexOf("application/json")!==-1?r.json():r.text();o(Error(r.statusText))}).then(r=>i(r)).catch(r=>o(r))})}function a(n,e){return!e||e===-1?function(t,i){return i=i||{},m(n+"."+t,i)}:function(t,i){return i=i||{},i.windowID=e,m(n+"."+t,i)}}var O="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var s=(n=21)=>{let e="",t=n;for(;t--;)e+=O[Math.random()*64|0];return e};var U=a("dialog"),l=new Map;function z(){let n;do n=s();while(l.has(n));return n}function d(n,e,t){let i=l.get(n);i&&(t?i.resolve(JSON.parse(e)):i.resolve(e),l.delete(n))}function f(n,e){let t=l.get(n);t&&(t.reject(e),l.delete(n))}function u(n,e){return new Promise((t,i)=>{let o=z();e=e||{},e["dialog-id"]=o,l.set(o,{resolve:t,reject:i}),U(n,e).catch(r=>{i(r),l.delete(o)})})}function p(n){return u("Info",n)}function w(n){return u("Warning",n)}function S(n){return u("Error",n)}function x(n){return u("Question",n)}function g(n){return u("OpenFile",n)}function h(n){return u("SaveFile",n)}var c={};F(c,{SetText:()=>E,Text:()=>P});var M=a("clipboard");function E(n){return M("SetText",{text:n})}function P(){return M("Text")}function C(n){let e=a("window",n);return{Center:()=>e("Center"),SetTitle:t=>e("SetTitle",{title:t}),Fullscreen:()=>e("Fullscreen"),UnFullscreen:()=>e("UnFullscreen"),SetSize:(t,i)=>e("SetSize",{width:t,height:i}),Size:()=>e("Size"),SetMaxSize:(t,i)=>e("SetMaxSize",{width:t,height:i}),SetMinSize:(t,i)=>e("SetMinSize",{width:t,height:i}),SetAlwaysOnTop:t=>e("SetAlwaysOnTop",{alwaysOnTop:t}),SetPosition:(t,i)=>e("SetPosition",{x:t,y:i}),Position:()=>e("Position"),Screen:()=>e("Screen"),Hide:()=>e("Hide"),Maximise:()=>e("Maximise"),Show:()=>e("Show"),ToggleMaximise:()=>e("ToggleMaximise"),UnMaximise:()=>e("UnMaximise"),Minimise:()=>e("Minimise"),UnMinimise:()=>e("UnMinimise"),SetBackgroundColour:(t,i,o,r)=>e("SetBackgroundColour",{r:t,g:i,b:o,a:r})}}window.wails={...R(-1)};window._wails={dialogCallback:d,dialogErrorCallback:f};function R(n){return{Clipboard:{...c},Dialog:{Info:p,Warning:w,Error:S,Question:x,OpenFile:g,SaveFile:h},Window:C(n)}}console.log("Wails v3.0.0 Debug Mode Enabled");})();
|
||||
|
Loading…
Reference in New Issue
Block a user