diff --git a/Cargo.lock b/Cargo.lock index 0a3fa5bff..868133c0f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -272,7 +272,7 @@ dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "publicsuffix 1.5.4 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", "try_from 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -661,7 +661,7 @@ dependencies = [ "pest_derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", "walkdir 2.2.9 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1629,7 +1629,7 @@ dependencies = [ "mime_guess 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "native-tls 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", "serde_urlencoded 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1775,7 +1775,7 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.42" +version = "1.0.44" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1952,7 +1952,7 @@ dependencies = [ "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", "sysinfo 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "tar 0.4.26 (registry+https://github.com/rust-lang/crates.io-index)", "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2702,7 +2702,7 @@ dependencies = [ "checksum serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)" = "1217f97ab8e8904b57dd22eb61cde455fa7446a9c1cf43966066da047c1f3702" "checksum serde_derive 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)" = "a8c6faef9a2e64b0064f48570289b4bf8823b7581f1d6157c1b52152306651d0" "checksum serde_json 0.9.10 (registry+https://github.com/rust-lang/crates.io-index)" = "ad8bcf487be7d2e15d3d543f04312de991d631cfe1b43ea0ade69e6a8a5b16a1" -"checksum serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)" = "1a3351dcbc1f067e2c92ab7c3c1f288ad1a4cffc470b5aaddb4c2e0a3ae80043" +"checksum serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)" = "48c575e0cc52bdd09b47f330f646cf59afc586e9c4e3ccd6fc1f625b8ea1dad7" "checksum serde_urlencoded 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "642dd69105886af2efd227f75a520ec9b44a820d65bc133a9131f7d229fd165a" "checksum sha-1 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "23962131a91661d643c98940b20fcaffe62d776a823247be80a48fcb8b6fce68" "checksum sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d" diff --git a/cli/tauri.js/bin/tauri.js b/cli/tauri.js/bin/tauri.js index 60af2333d..f2047ddd0 100755 --- a/cli/tauri.js/bin/tauri.js +++ b/cli/tauri.js/bin/tauri.js @@ -31,6 +31,7 @@ const tauri = function (command) { process.argv.splice(2, 1) } console.log(`[tauri]: running ${command}`) + // eslint-disable-next-line security/detect-non-literal-require require(`./tauri-${command}`) } else { console.log(`Invalid command ${command}. Use one of ${cmds.join(',')}.`) diff --git a/cli/tauri.js/test/jest/__tests__/tauri.spec.js b/cli/tauri.js/test/jest/__tests__/tauri.spec.js index 8a4f4f5c5..6d7b3107c 100644 --- a/cli/tauri.js/test/jest/__tests__/tauri.spec.js +++ b/cli/tauri.js/test/jest/__tests__/tauri.spec.js @@ -1,3 +1,4 @@ +// eslint-disable-next-line node/no-missing-require const { tauri } = require('bin/tauri') describe('[CLI] tauri.js', () => { diff --git a/examples/gatsby/themed-site/src-tauri/Cargo.toml b/examples/gatsby/themed-site/src-tauri/Cargo.toml index e2bcd0e75..5cf155a31 100644 --- a/examples/gatsby/themed-site/src-tauri/Cargo.toml +++ b/examples/gatsby/themed-site/src-tauri/Cargo.toml @@ -21,7 +21,7 @@ icon = [ ] [dependencies] -serde_json = "1.0.41" +serde_json = "1.0.44" serde = "1.0" serde_derive = "1.0" tiny_http = "0.6" @@ -29,7 +29,7 @@ phf = "0.7.24" includedir = "0.5.0" [dependencies.tauri] - version = "0.1.2" + version = "^0.1" features = [ "edge" ] [features] diff --git a/examples/vue/quasar-app/package.json b/examples/vue/quasar-app/package.json index 0dfcc9363..b41b86a9d 100644 --- a/examples/vue/quasar-app/package.json +++ b/examples/vue/quasar-app/package.json @@ -22,10 +22,10 @@ }, "dependencies": { "@quasar/extras": "^1.0.0", - "quasar": "^1.5.7" + "quasar": "1.5.8" }, "devDependencies": { - "@quasar/app": "^1.3.5", + "@quasar/app": "1.3.6", "@vue/eslint-config-standard": "^4.0.0", "babel-eslint": "^10.0.1", "eslint": "^5.10.0", diff --git a/examples/vue/quasar-app/src-tauri/Cargo.toml b/examples/vue/quasar-app/src-tauri/Cargo.toml index e9b035b4e..623b1f595 100644 --- a/examples/vue/quasar-app/src-tauri/Cargo.toml +++ b/examples/vue/quasar-app/src-tauri/Cargo.toml @@ -21,7 +21,7 @@ icon = [ ] [dependencies] -serde_json = "1.0.41" +serde_json = "1.0.44" serde = "1.0" serde_derive = "1.0" tiny_http = "0.6" diff --git a/examples/vue/quasar-app/src-tauri/tauri.js b/examples/vue/quasar-app/src-tauri/tauri.js index 52437fc0f..f7ecda676 100644 --- a/examples/vue/quasar-app/src-tauri/tauri.js +++ b/examples/vue/quasar-app/src-tauri/tauri.js @@ -8,6 +8,8 @@ * **/ +// open links with the Tauri API + /** * @module tauri * @description This API interface makes powerful interactions available @@ -24,7 +26,7 @@ function s4() { .substring(1) } -var uid = function () { +const uid = function () { return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4() } @@ -46,12 +48,8 @@ var __reject = new Promise(function (reject) { window.tauri = { invoke: function invoke(args) { - - window.parent.postMessage({ - type: 'tauri-invoke', - payload: JSON.stringify(args) - }, '*') - + Object.freeze(args); + window.external.invoke(JSON.stringify(args)); }, @@ -60,7 +58,7 @@ window.tauri = { this.invoke({ cmd: 'listen', event: event, - handler: window.tauri.transformCallback(handler, once), + handler: this.transformCallback(handler, once), once: once }); }, @@ -214,55 +212,24 @@ window.tauri = { 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' + }); } }; - -window.addEventListener('message', function (event) { - event.data.type === 'tauri-callback' && window[event.data.callback](event.data.payload) -}) - -// init tauri API - -window.onTauriInit = function () { - alert('mounted') - console.log(window.tauri) -} - -function __initTauri () { - if (window.onTauriInit !== void 0) { - window.onTauriInit() - } - alert('INIT') -} - -if (window.top === window.self) { - // detect if we are in an iframe - // technically "dev mode" - window.addEventListener('message', function (event) { - alert(JSON.stringify(event.data.payload)) - if (event.data.type === 'tauri-invoke') { - window.external.invoke(event.data.payload) - } - }, true) -} else { - // this is an iframe - window.addEventListener('message', function (event) { - alert(JSON.stringify(event)) - alert(JSON.stringify(event.data)) - alert(JSON.stringify(event.data.payload)) - }, true) -} - -window.addEventListener('DOMContentLoaded', function () { - // open links with the Tauri API - document.querySelector('body').addEventListener('click', function (e) { - var target = e.target - while (target != null) { - if (target.matches ? target.matches('a') : target.msMatchesSelector('a')) { - window.tauri.open(target.href) - break - } - target = target.parentElement - } - }, true) -}, true) diff --git a/examples/vue/quasar-app/yarn.lock b/examples/vue/quasar-app/yarn.lock index 6f043f8df..6b14bf122 100644 --- a/examples/vue/quasar-app/yarn.lock +++ b/examples/vue/quasar-app/yarn.lock @@ -845,10 +845,10 @@ resolved "https://registry.npmjs.org/@positron/stack-trace/-/stack-trace-1.0.0.tgz#14fcc712a530038ef9be1ce6952315a839f466a8" integrity sha1-FPzHEqUwA475vhzmlSMVqDn0Zqg= -"@quasar/app@^1.3.5": - version "1.3.5" - resolved "https://registry.npmjs.org/@quasar/app/-/app-1.3.5.tgz#23f829f2093882dd675e1f5acf5349b17cc17f34" - integrity sha512-2wTIzkLODo74NJmTmxtzBukQFfOXGCadrjMh1eoknR5r0y3tPnVSTwnvQKMPVEUUf2L4WMKAkGhsEXN0QkyAtw== +"@quasar/app@1.3.6": + version "1.3.6" + resolved "https://registry.npmjs.org/@quasar/app/-/app-1.3.6.tgz#ff70a85567184c795e2e3d5bb149c9c4c69ef7e3" + integrity sha512-xrn6PJg1tkI9/Y4DWTZgnEtVLyWJY8hCyJvk14HN4tv9S6EfmLK+DV0GY7FkhX2KfpIWO5nDblmxoGl44BhVNw== dependencies: "@quasar/babel-preset-app" "1.1.7" "@quasar/fastclick" "1.1.4" @@ -898,7 +898,7 @@ strip-ansi "6.0.0" stylus "0.54.7" stylus-loader "3.0.2" - terser-webpack-plugin "2.2.1" + terser-webpack-plugin "2.2.2" url-loader "3.0.0" vue "2.6.10" vue-loader "15.7.2" @@ -4081,7 +4081,7 @@ find-cache-dir@^2.0.0, find-cache-dir@^2.1.0: make-dir "^2.0.0" pkg-dir "^3.0.0" -find-cache-dir@^3.0.0: +find-cache-dir@^3.0.0, find-cache-dir@^3.1.0: version "3.1.0" resolved "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-3.1.0.tgz#9935894999debef4cf9f677fdf646d002c4cdecb" integrity sha512-zw+EFiNBNPgI2NTrKkDd1xd7q0cs6wr/iWnr/oUkI0yF9K9GqQ+riIt4aiyFaaqpaWbxPrJXHI+QvmNUQbX+0Q== @@ -7833,10 +7833,10 @@ qs@~6.5.2: resolved "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz#cb3ae806e8740444584ef154ce8ee98d403f3e36" integrity sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA== -quasar@^1.5.7: - version "1.5.7" - resolved "https://registry.npmjs.org/quasar/-/quasar-1.5.7.tgz#b21ae7858513a75175435bb889e24c570bf4bf9c" - integrity sha512-b/0LDYS5SleQUCb92yxLGrakpv5Bssl61mmxYqABootOU1rSytFjupkC2+hB+KBtWvjgGhjpty+Kir8/0X78zA== +quasar@1.5.8: + version "1.5.8" + resolved "https://registry.npmjs.org/quasar/-/quasar-1.5.8.tgz#c0d5ffcde8ee7b1fd1bbe96965d0928be54ab099" + integrity sha512-wgkVqpG3zcdBfuyPa57GiBQYzEYD95Y7yNZGXhxSMupvlwtG/l5+IFGaTI9kfp9f38rzCBjrsJsp/m9Cqxe2ig== query-string@^4.1.0: version "4.3.4" @@ -8363,7 +8363,7 @@ schema-utils@^1.0.0: ajv-errors "^1.0.0" ajv-keywords "^3.1.0" -schema-utils@^2.1.0, schema-utils@^2.5.0, schema-utils@^2.6.0: +schema-utils@^2.1.0, schema-utils@^2.5.0, schema-utils@^2.6.0, schema-utils@^2.6.1: version "2.6.1" resolved "https://registry.npmjs.org/schema-utils/-/schema-utils-2.6.1.tgz#eb78f0b945c7bcfa2082b3565e8db3548011dc4f" integrity sha512-0WXHDs1VDJyo+Zqs9TKLKyD/h7yDpHUhEFsM2CzkICFdoX1av+GBq/J2xRTFfsQO5kBfhZzANf2VcIm84jqDbg== @@ -8454,6 +8454,11 @@ serialize-javascript@^2.1.0: resolved "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-2.1.0.tgz#9310276819efd0eb128258bb341957f6eb2fc570" integrity sha512-a/mxFfU00QT88umAJQsNWOnUKckhNCqOl028N48e7wFmo2/EHpTo9Wso+iJJCMrQnmFvcjto5RJdAHEvVhcyUQ== +serialize-javascript@^2.1.1: + version "2.1.2" + resolved "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-2.1.2.tgz#ecec53b0e0317bdc95ef76ab7074b7384785fa61" + integrity sha512-rs9OggEUF0V4jUSecXazOYsLfu7OGK2qIn3c7IPBiffz32XniEp/TX9Xmc9LQfK2nQ2QKHvZ2oygKUGU0lG4jQ== + serve-index@^1.9.1: version "1.9.1" resolved "https://registry.npmjs.org/serve-index/-/serve-index-1.9.1.tgz#d3768d69b1e7d82e5ce050fff5b453bea12a9239" @@ -9260,18 +9265,18 @@ tempfile@^2.0.0: temp-dir "^1.0.0" uuid "^3.0.1" -terser-webpack-plugin@2.2.1: - version "2.2.1" - resolved "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-2.2.1.tgz#5569e6c7d8be79e5e43d6da23acc3b6ba77d22bd" - integrity sha512-jwdauV5Al7zopR6OAYvIIRcxXCSvLjZjr7uZE8l2tIWb/ryrGN48sJftqGf5k9z09tWhajx53ldp0XPI080YnA== +terser-webpack-plugin@2.2.2: + version "2.2.2" + resolved "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-2.2.2.tgz#2a6e00237125564a455ad69b22e08ee59420473a" + integrity sha512-/CHMNswPMAwuD2kd++qys8UmBRmsshPSzHw4BlDwurPtK9YjeK93OV89YWkJulHk972cs07K/7Z92V6PNjWF8A== dependencies: cacache "^13.0.1" - find-cache-dir "^3.0.0" + find-cache-dir "^3.1.0" jest-worker "^24.9.0" - schema-utils "^2.5.0" - serialize-javascript "^2.1.0" + schema-utils "^2.6.1" + serialize-javascript "^2.1.1" source-map "^0.6.1" - terser "^4.3.9" + terser "^4.4.2" webpack-sources "^1.4.3" terser-webpack-plugin@^1.4.1: @@ -9289,7 +9294,7 @@ terser-webpack-plugin@^1.4.1: webpack-sources "^1.4.0" worker-farm "^1.7.0" -terser@^4.1.2, terser@^4.3.9: +terser@^4.1.2: version "4.4.1" resolved "https://registry.npmjs.org/terser/-/terser-4.4.1.tgz#f3a469c125d9a0eb52f1e6a7fdff587bd6e35902" integrity sha512-e05giplw+8sIYh50qXYHZmr0b76O5dOSm9JwSDebGFLri4ItYzxsnumiAK+yuI56R+H7uIjT9KbVEKNkrprzHw== @@ -9298,6 +9303,15 @@ terser@^4.1.2, terser@^4.3.9: source-map "~0.6.1" source-map-support "~0.5.12" +terser@^4.4.2: + version "4.4.2" + resolved "https://registry.npmjs.org/terser/-/terser-4.4.2.tgz#448fffad0245f4c8a277ce89788b458bfd7706e8" + integrity sha512-Uufrsvhj9O1ikwgITGsZ5EZS6qPokUOkCegS7fYOdGTv+OA90vndUbU6PEjr5ePqHfNUbGyMO7xyIZv2MhsALQ== + dependencies: + commander "^2.20.0" + source-map "~0.6.1" + source-map-support "~0.5.12" + text-table@^0.2.0: version "0.2.0" resolved "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" diff --git a/tauri/Cargo.toml b/tauri/Cargo.toml index f12e55a06..62097d69c 100644 --- a/tauri/Cargo.toml +++ b/tauri/Cargo.toml @@ -10,7 +10,7 @@ edition = "2018" [dependencies] web-view = "0.5.4" -serde_json = "1.0.42" +serde_json = "1.0.44" serde = "1.0" serde_derive = "1.0" dirs = "2.0.2"