123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235 |
- /* eslint-disable */
- /**
- * * THIS FILE IS GENERATED AUTOMATICALLY.
- * DO NOT EDIT.
- *
- * Please whitelist these API functions in tauri.conf.js
- *
- **/
- // open <a href="..."> links with the Tauri API
- /**
- * @module tauri
- * @description This API interface makes powerful interactions available
- * to be run on client side applications. They are opt-in features, and
- * must be enabled in tauri.conf.js
- *
- * Each binding MUST provide these interfaces in order to be compliant,
- * and also whitelist them based upon the developer's settings.
- */
- function s4() {
- return Math.floor((1 + Math.random()) * 0x10000)
- .toString(16)
- .substring(1)
- }
- const uid = function () {
- return s4() + s4() + '-' + s4() + '-' + s4() + '-' +
- s4() + '-' + s4() + s4() + s4()
- }
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
- function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
- var __reject = new Promise(function (reject) {
- reject;
- });
- window.tauri = {
-
- invoke: function invoke(args) {
- Object.freeze(args);
- window.external.invoke(JSON.stringify(args));
- },
-
- listen: function listen(event, handler) {
- var once = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
- this.invoke({
- cmd: 'listen',
- event: event,
- handler: this.transformCallback(handler, once),
- once: once
- });
- },
-
- emit: function emit(evt, payload) {
- this.invoke({
- cmd: 'emit',
- event: evt,
- payload: payload
- });
- },
-
- transformCallback: function transformCallback(callback) {
- var once = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
- var identifier = Object.freeze(uid());
- window[identifier] = function (result) {
- if (once) {
- delete window[identifier];
- }
- return callback && callback(result);
- };
- return identifier;
- },
-
- promisified: function promisified(args) {
- var _this = this;
- return new Promise(function (resolve, reject) {
- _this.invoke(_objectSpread({
- callback: _this.transformCallback(resolve),
- error: _this.transformCallback(reject)
- }, args));
- });
- },
-
- readTextFile: function readTextFile(path) {
-
- Object.freeze(path);
- return this.promisified({
- cmd: 'readTextFile',
- path: path
- });
-
- },
-
- readBinaryFile: function readBinaryFile(path) {
-
- Object.freeze(path);
- return this.promisified({
- cmd: 'readBinaryFile',
- path: path
- });
-
- },
-
- writeFile: function writeFile(cfg) {
-
- Object.freeze(cfg);
- this.invoke({
- cmd: 'writeFile',
- file: cfg.file,
- contents: cfg.contents
- });
-
- },
-
- listFiles: function listFiles(path) {
-
- Object.freeze(path);
- return this.promisified({
- cmd: 'listFiles',
- path: path
- });
-
- },
-
- listDirs: function listDirs(path) {
-
- Object.freeze(path);
- return this.promisified({
- cmd: 'listDirs',
- path: path
- });
-
- },
-
- setTitle: function setTitle(title) {
-
- Object.freeze(title);
- this.invoke({
- cmd: 'setTitle',
- title: title
- });
-
- },
-
- open: function open(uri) {
-
- Object.freeze(uri);
- this.invoke({
- cmd: 'open',
- uri: uri
- });
-
- },
-
- execute: function execute(command, args) {
-
- Object.freeze(command);
- if (typeof args === 'string' || _typeof(args) === 'object') {
- Object.freeze(args);
- }
- return this.promisified({
- cmd: 'execute',
- command: command,
- args: typeof args === 'string' ? [args] : args
- });
-
- },
- bridge: function bridge(command, payload) {
-
- Object.freeze(command);
- if (typeof payload === 'string' || _typeof(payload) === 'object') {
- Object.freeze(payload);
- }
- return this.promisified({
- cmd: 'bridge',
- command: command,
- payload: _typeof(payload) === 'object' ? [payload] : payload
- });
-
- },
-
- setup: function setup() {
- document.querySelector('body').addEventListener('click', function (e) {
- var target = e.target;
- while (target != null) {
- if (target.matches ? target.matches('a') : target.msMatchesSelector('a')) {
- tauri.open(target.href);
- break;
- }
- target = target.parentElement;
- }
- }, true);
- window.tauri.invoke({
- cmd: 'init'
- });
- }
- };
|