|
@@ -10,7 +10,8 @@ if (!String.prototype.startsWith) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-;(function () {
|
|
|
+;
|
|
|
+(function () {
|
|
|
function uid() {
|
|
|
const length = new Int8Array(1)
|
|
|
window.crypto.getRandomValues(length)
|
|
@@ -92,7 +93,7 @@ if (!String.prototype.startsWith) {
|
|
|
return identifier
|
|
|
}
|
|
|
|
|
|
- window.__TAURI__._invoke = function invoke(cmd, args = {}, key = null) {
|
|
|
+ window.__TAURI_INVOKE__ = function invoke(cmd, args = {}, key = null) {
|
|
|
return new Promise(function (resolve, reject) {
|
|
|
var callback = window.__TAURI__.transformCallback(function (r) {
|
|
|
resolve(r)
|
|
@@ -114,8 +115,7 @@ if (!String.prototype.startsWith) {
|
|
|
if (window.rpc) {
|
|
|
window.rpc.notify(
|
|
|
cmd,
|
|
|
- _objectSpread(
|
|
|
- {
|
|
|
+ _objectSpread({
|
|
|
callback: callback,
|
|
|
error: error,
|
|
|
__invokeKey: key || __TAURI_INVOKE_KEY__
|
|
@@ -127,8 +127,7 @@ if (!String.prototype.startsWith) {
|
|
|
window.addEventListener('DOMContentLoaded', function () {
|
|
|
window.rpc.notify(
|
|
|
cmd,
|
|
|
- _objectSpread(
|
|
|
- {
|
|
|
+ _objectSpread({
|
|
|
callback: callback,
|
|
|
error: error,
|
|
|
__invokeKey: key || __TAURI_INVOKE_KEY__
|
|
@@ -156,9 +155,8 @@ if (!String.prototype.startsWith) {
|
|
|
target.href.startsWith('http') &&
|
|
|
target.target === '_blank'
|
|
|
) {
|
|
|
- window.__TAURI__._invoke(
|
|
|
- 'tauri',
|
|
|
- {
|
|
|
+ window.__TAURI_INVOKE__(
|
|
|
+ 'tauri', {
|
|
|
__tauriModule: 'Shell',
|
|
|
message: {
|
|
|
cmd: 'open',
|
|
@@ -197,9 +195,8 @@ if (!String.prototype.startsWith) {
|
|
|
document.addEventListener('mousedown', (e) => {
|
|
|
if (e.target.hasAttribute('data-tauri-drag-region') && e.buttons === 1) {
|
|
|
// start dragging if the element has a `tauri-drag-region` data attribute and maximize on double-clicking it
|
|
|
- window.__TAURI__._invoke(
|
|
|
- 'tauri',
|
|
|
- {
|
|
|
+ window.__TAURI_INVOKE__(
|
|
|
+ 'tauri', {
|
|
|
__tauriModule: 'Window',
|
|
|
message: {
|
|
|
cmd: 'manage',
|
|
@@ -215,9 +212,8 @@ if (!String.prototype.startsWith) {
|
|
|
}
|
|
|
})
|
|
|
|
|
|
- window.__TAURI__._invoke(
|
|
|
- 'tauri',
|
|
|
- {
|
|
|
+ window.__TAURI_INVOKE__(
|
|
|
+ 'tauri', {
|
|
|
__tauriModule: 'Event',
|
|
|
message: {
|
|
|
cmd: 'listen',
|
|
@@ -225,7 +221,9 @@ if (!String.prototype.startsWith) {
|
|
|
handler: window.__TAURI__.transformCallback(function (event) {
|
|
|
if (event.payload) {
|
|
|
var windowLabel = event.payload.label
|
|
|
- window.__TAURI__.__windows.push({ label: windowLabel })
|
|
|
+ window.__TAURI__.__windows.push({
|
|
|
+ label: windowLabel
|
|
|
+ })
|
|
|
}
|
|
|
})
|
|
|
}
|
|
@@ -240,9 +238,8 @@ if (!String.prototype.startsWith) {
|
|
|
if (window.Notification.permission !== 'default') {
|
|
|
return Promise.resolve(window.Notification.permission === 'granted')
|
|
|
}
|
|
|
- return window.__TAURI__._invoke(
|
|
|
- 'tauri',
|
|
|
- {
|
|
|
+ return window.__TAURI_INVOKE__(
|
|
|
+ 'tauri', {
|
|
|
__tauriModule: 'Notification',
|
|
|
message: {
|
|
|
cmd: 'isNotificationPermissionGranted'
|
|
@@ -259,10 +256,8 @@ if (!String.prototype.startsWith) {
|
|
|
}
|
|
|
|
|
|
function requestPermission() {
|
|
|
- return window.__TAURI__
|
|
|
- ._invoke(
|
|
|
- 'tauri',
|
|
|
- {
|
|
|
+ return window.__TAURI_INVOKE__(
|
|
|
+ 'tauri', {
|
|
|
__tauriModule: 'Notification',
|
|
|
message: {
|
|
|
cmd: 'requestNotificationPermission'
|
|
@@ -283,18 +278,14 @@ if (!String.prototype.startsWith) {
|
|
|
|
|
|
isPermissionGranted().then(function (permission) {
|
|
|
if (permission) {
|
|
|
- return window.__TAURI__._invoke(
|
|
|
- 'tauri',
|
|
|
- {
|
|
|
+ return window.__TAURI_INVOKE__(
|
|
|
+ 'tauri', {
|
|
|
__tauriModule: 'Notification',
|
|
|
message: {
|
|
|
cmd: 'notification',
|
|
|
- options:
|
|
|
- typeof options === 'string'
|
|
|
- ? {
|
|
|
- title: options
|
|
|
- }
|
|
|
- : options
|
|
|
+ options: typeof options === 'string' ? {
|
|
|
+ title: options
|
|
|
+ } : options
|
|
|
}
|
|
|
},
|
|
|
_KEY_VALUE_
|
|
@@ -336,9 +327,8 @@ if (!String.prototype.startsWith) {
|
|
|
})
|
|
|
|
|
|
window.alert = function (message) {
|
|
|
- window.__TAURI__._invoke(
|
|
|
- 'tauri',
|
|
|
- {
|
|
|
+ window.__TAURI_INVOKE__(
|
|
|
+ 'tauri', {
|
|
|
__tauriModule: 'Dialog',
|
|
|
message: {
|
|
|
cmd: 'messageDialog',
|
|
@@ -350,9 +340,8 @@ if (!String.prototype.startsWith) {
|
|
|
}
|
|
|
|
|
|
window.confirm = function (message) {
|
|
|
- return window.__TAURI__._invoke(
|
|
|
- 'tauri',
|
|
|
- {
|
|
|
+ return window.__TAURI_INVOKE__(
|
|
|
+ 'tauri', {
|
|
|
__tauriModule: 'Dialog',
|
|
|
message: {
|
|
|
cmd: 'askDialog',
|
|
@@ -366,9 +355,8 @@ if (!String.prototype.startsWith) {
|
|
|
// window.print works on Linux/Windows; need to use the API on macOS
|
|
|
if (navigator.userAgent.includes('Mac')) {
|
|
|
window.print = function () {
|
|
|
- return window.__TAURI__._invoke(
|
|
|
- 'tauri',
|
|
|
- {
|
|
|
+ return window.__TAURI_INVOKE__(
|
|
|
+ 'tauri', {
|
|
|
__tauriModule: 'Window',
|
|
|
message: {
|
|
|
cmd: 'manage',
|