mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-03 10:41:14 +08:00
Tidy up runtime JS
This commit is contained in:
parent
368f0e48bc
commit
8534b32a9f
@ -17,7 +17,7 @@ export const callbacks = {};
|
|||||||
* @returns number
|
* @returns number
|
||||||
*/
|
*/
|
||||||
function cryptoRandom() {
|
function cryptoRandom() {
|
||||||
var array = new Uint32Array(1);
|
let array = new Uint32Array(1);
|
||||||
return window.crypto.getRandomValues(array)[0];
|
return window.crypto.getRandomValues(array)[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ function basicRandom() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Pick a random number function based on browser capability
|
// Pick a random number function based on browser capability
|
||||||
var randomFunc;
|
let randomFunc;
|
||||||
if (window.crypto) {
|
if (window.crypto) {
|
||||||
randomFunc = cryptoRandom;
|
randomFunc = cryptoRandom;
|
||||||
} else {
|
} else {
|
||||||
@ -67,12 +67,12 @@ export function Call(name, args, timeout) {
|
|||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
|
|
||||||
// Create a unique callbackID
|
// Create a unique callbackID
|
||||||
var callbackID;
|
let callbackID;
|
||||||
do {
|
do {
|
||||||
callbackID = name + '-' + randomFunc();
|
callbackID = name + '-' + randomFunc();
|
||||||
} while (callbacks[callbackID]);
|
} while (callbacks[callbackID]);
|
||||||
|
|
||||||
var timeoutHandle;
|
let timeoutHandle;
|
||||||
// Set timeout
|
// Set timeout
|
||||||
if (timeout > 0) {
|
if (timeout > 0) {
|
||||||
timeoutHandle = setTimeout(function () {
|
timeoutHandle = setTimeout(function () {
|
||||||
@ -115,12 +115,12 @@ window.ObfuscatedCall = (id, args, timeout) => {
|
|||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
|
|
||||||
// Create a unique callbackID
|
// Create a unique callbackID
|
||||||
var callbackID;
|
let callbackID;
|
||||||
do {
|
do {
|
||||||
callbackID = id + '-' + randomFunc();
|
callbackID = id + '-' + randomFunc();
|
||||||
} while (callbacks[callbackID]);
|
} while (callbacks[callbackID]);
|
||||||
|
|
||||||
var timeoutHandle;
|
let timeoutHandle;
|
||||||
// Set timeout
|
// Set timeout
|
||||||
if (timeout > 0) {
|
if (timeout > 0) {
|
||||||
timeoutHandle = setTimeout(function () {
|
timeoutHandle = setTimeout(function () {
|
||||||
|
@ -16,7 +16,7 @@ let postMessage = null;
|
|||||||
(function () {
|
(function () {
|
||||||
// Credit: https://stackoverflow.com/a/2631521
|
// Credit: https://stackoverflow.com/a/2631521
|
||||||
let _deeptest = function (s) {
|
let _deeptest = function (s) {
|
||||||
var obj = window[s.shift()];
|
let obj = window[s.shift()];
|
||||||
while (obj && s.length) obj = obj[s.shift()];
|
while (obj && s.length) obj = obj[s.shift()];
|
||||||
return obj;
|
return obj;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user