chore: add `.prettierrc` in repo root (#2145)

This commit is contained in:
Amr Bashir 2021-07-04 00:48:04 +02:00 committed by GitHub
parent e0a8e09cab
commit 66916b739f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
57 changed files with 5411 additions and 1089 deletions

View File

@ -217,41 +217,29 @@
"tauri-runtime": {
"path": "./core/tauri-runtime",
"manager": "rust",
"dependencies": [
"tauri-utils"
],
"dependencies": ["tauri-utils"],
"postversion": "node ../../.scripts/sync-prerelease.js ${ pkg.pkg } ${ release.type }"
},
"tauri-runtime-wry": {
"path": "./core/tauri-runtime-wry",
"manager": "rust",
"dependencies": [
"tauri-utils",
"tauri-runtime"
],
"dependencies": ["tauri-utils", "tauri-runtime"],
"postversion": "node ../../.scripts/sync-prerelease.js ${ pkg.pkg } ${ release.type }"
},
"tauri-codegen": {
"path": "./core/tauri-codegen",
"manager": "rust",
"dependencies": [
"tauri-utils"
]
"dependencies": ["tauri-utils"]
},
"tauri-macros": {
"path": "./core/tauri-macros",
"manager": "rust",
"dependencies": [
"tauri-codegen"
]
"dependencies": ["tauri-codegen"]
},
"tauri-build": {
"path": "./core/tauri-build",
"manager": "rust",
"dependencies": [
"tauri-codegen",
"tauri-utils"
],
"dependencies": ["tauri-codegen", "tauri-utils"],
"postversion": "node ../../.scripts/sync-cli-metadata.js ${ pkg.pkg } ${ release.type }"
},
"tauri": {
@ -268,9 +256,7 @@
"cli.js": {
"path": "./tooling/cli.js",
"manager": "javascript",
"dependencies": [
"cli.rs"
],
"dependencies": ["cli.rs"],
"postversion": "node ../../.scripts/sync-cli-metadata.js ${ pkg.pkg } ${ release.type }",
"assets": [
{
@ -282,9 +268,7 @@
"cli.rs": {
"path": "./tooling/cli.rs",
"manager": "rust",
"dependencies": [
"tauri-bundler"
],
"dependencies": ["tauri-bundler"],
"postversion": "cargo check"
},
"create-tauri-app": {
@ -292,4 +276,4 @@
"manager": "javascript"
}
}
}
}

5
.prettierrc.js Normal file
View File

@ -0,0 +1,5 @@
module.exports = {
singleQuote: true,
semi: false,
trailingComma: 'none'
}

View File

@ -10,36 +10,36 @@ we should look to find a more "rusty way" to import / "pin" a version value in o
rust binaries.
*/
const { readFileSync, writeFileSync } = require("fs");
const { readFileSync, writeFileSync } = require('fs')
const filePath = `../../tooling/cli.rs/metadata.json`;
const packageNickname = process.argv[2];
const bump = process.argv[3];
if (bump !== "prerelease") {
const filePath = `../../tooling/cli.rs/metadata.json`
const packageNickname = process.argv[2]
const bump = process.argv[3]
if (bump !== 'prerelease') {
throw new Error(
`We don't handle anything except prerelease right now. Exiting.`
);
)
}
const inc = (version) => {
const v = version.split("");
const n = v.pop();
return [...v, String(Number(n) + 1)].join("");
};
// read file into js object
const metadata = JSON.parse(readFileSync(filePath, "utf-8"));
// set field version
let version;
if (packageNickname === "cli.js") {
version = inc(metadata[packageNickname].version);
metadata[packageNickname].version = version;
} else {
version = inc(metadata[packageNickname]);
metadata[packageNickname] = version;
const v = version.split('')
const n = v.pop()
return [...v, String(Number(n) + 1)].join('')
}
writeFileSync(filePath, JSON.stringify(metadata, null, 2) + "\n");
console.log(`wrote ${version} for ${packageNickname} into metadata.json`);
console.dir(metadata);
// read file into js object
const metadata = JSON.parse(readFileSync(filePath, 'utf-8'))
// set field version
let version
if (packageNickname === 'cli.js') {
version = inc(metadata[packageNickname].version)
metadata[packageNickname].version = version
} else {
version = inc(metadata[packageNickname])
metadata[packageNickname] = version
}
writeFileSync(filePath, JSON.stringify(metadata, null, 2) + '\n')
console.log(`wrote ${version} for ${packageNickname} into metadata.json`)
console.dir(metadata)

View File

@ -8,7 +8,7 @@ This script is solely intended to be run as part of the `covector version` step
keep the `tauri-runtime`, `tauri-runtime-wry` and `tauri-driver` crates version without the `beta` or `beta-rc` suffix.
*/
const { readFileSync, writeFileSync } = require("fs")
const { readFileSync, writeFileSync } = require('fs')
const packageNickname = process.argv[2]
const bump = process.argv[3]
@ -19,7 +19,10 @@ let changelogPath
if (packageNickname === 'tauri-runtime') {
manifestPath = '../../core/tauri-runtime/Cargo.toml'
dependencyManifestPaths = ['../../core/tauri/Cargo.toml', '../../core/tauri-runtime-wry/Cargo.toml']
dependencyManifestPaths = [
'../../core/tauri/Cargo.toml',
'../../core/tauri-runtime-wry/Cargo.toml'
]
changelogPath = '../../core/tauri-runtime/CHANGELOG.md'
} else if (packageNickname === 'tauri-runtime-wry') {
manifestPath = '../../core/tauri-runtime-wry/Cargo.toml'
@ -33,16 +36,24 @@ if (packageNickname === 'tauri-runtime') {
throw new Error(`Unexpected package ${packageNickname}`)
}
let manifest = readFileSync(manifestPath, "utf-8")
manifest = manifest.replace(/version = "(\d+\.\d+\.\d+)-[^0-9\.]+\.0"/, 'version = "$1"')
let manifest = readFileSync(manifestPath, 'utf-8')
manifest = manifest.replace(
/version = "(\d+\.\d+\.\d+)-[^0-9\.]+\.0"/,
'version = "$1"'
)
writeFileSync(manifestPath, manifest)
let changelog = readFileSync(changelogPath, "utf-8")
let changelog = readFileSync(changelogPath, 'utf-8')
changelog = changelog.replace(/(\d+\.\d+\.\d+)-[^0-9\.]+\.0/, '$1')
writeFileSync(changelogPath, changelog)
for (const dependencyManifestPath of dependencyManifestPaths) {
let dependencyManifest = readFileSync(dependencyManifestPath, "utf-8")
dependencyManifest = dependencyManifest.replace(new RegExp(packageNickname + ' = { version = "(\\d+\\.\\d+\.\\d+)-[^0-9\.]+\.0"'), `${packageNickname} = { version = "$1"`)
let dependencyManifest = readFileSync(dependencyManifestPath, 'utf-8')
dependencyManifest = dependencyManifest.replace(
new RegExp(
packageNickname + ' = { version = "(\\d+\\.\\d+.\\d+)-[^0-9.]+.0"'
),
`${packageNickname} = { version = "$1"`
)
writeFileSync(dependencyManifestPath, dependencyManifest)
}

View File

@ -5,12 +5,12 @@
// polyfills
if (!String.prototype.startsWith) {
String.prototype.startsWith = function (searchString, position) {
position = position || 0;
return this.substr(position, searchString.length) === searchString;
};
position = position || 0
return this.substr(position, searchString.length) === searchString
}
}
(function () {
;(function () {
function uid() {
const length = new Int8Array(1)
window.crypto.getRandomValues(length)
@ -20,41 +20,41 @@ if (!String.prototype.startsWith) {
}
function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
var keys = Object.keys(object)
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
var symbols = Object.getOwnPropertySymbols(object)
if (enumerableOnly)
symbols = symbols.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
});
keys.push.apply(keys, symbols);
return Object.getOwnPropertyDescriptor(object, sym).enumerable
})
keys.push.apply(keys, symbols)
}
return keys;
return keys
}
function _objectSpread(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
var source = arguments[i] != null ? arguments[i] : {}
if (i % 2) {
ownKeys(source, true).forEach(function (key) {
_defineProperty(target, key, source[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;
return target
}
function _defineProperty(obj, key, value) {
@ -63,52 +63,52 @@ if (!String.prototype.startsWith) {
value: value,
enumerable: true,
configurable: true,
writable: true,
});
writable: true
})
} else {
obj[key] = value;
obj[key] = value
}
return obj;
return obj
}
if (!window.__TAURI__) {
window.__TAURI__ = {};
window.__TAURI__ = {}
}
window.__TAURI__.transformCallback = function transformCallback(
callback,
once
) {
var identifier = uid();
var identifier = uid()
window[identifier] = function (result) {
if (once) {
delete window[identifier];
delete window[identifier]
}
return callback && callback(result);
};
return callback && callback(result)
}
return identifier;
};
return identifier
}
window.__TAURI__._invoke = function invoke(cmd, args = {}, key = null) {
return new Promise(function (resolve, reject) {
var callback = window.__TAURI__.transformCallback(function (r) {
resolve(r);
delete window[error];
}, true);
resolve(r)
delete window[error]
}, true)
var error = window.__TAURI__.transformCallback(function (e) {
reject(e);
delete window[callback];
}, true);
reject(e)
delete window[callback]
}, true)
if (typeof cmd === "string") {
args.cmd = cmd;
} else if (typeof cmd === "object") {
args = cmd;
if (typeof cmd === 'string') {
args.cmd = cmd
} else if (typeof cmd === 'object') {
args = cmd
} else {
return reject(new Error("Invalid argument type."));
return reject(new Error('Invalid argument type.'))
}
if (window.rpc) {
@ -118,238 +118,259 @@ if (!String.prototype.startsWith) {
{
callback: callback,
error: error,
__invokeKey: key || __TAURI_INVOKE_KEY__,
__invokeKey: key || __TAURI_INVOKE_KEY__
},
args
)
);
)
} else {
window.addEventListener("DOMContentLoaded", function () {
window.addEventListener('DOMContentLoaded', function () {
window.rpc.notify(
cmd,
_objectSpread(
{
callback: callback,
error: error,
__invokeKey: key || __TAURI_INVOKE_KEY__,
__invokeKey: key || __TAURI_INVOKE_KEY__
},
args
)
);
});
)
})
}
});
};
})
}
// open <a href="..."> links with the Tauri API
function __openLinks() {
document.querySelector("body").addEventListener(
"click",
document.querySelector('body').addEventListener(
'click',
function (e) {
var target = e.target;
var target = e.target
while (target != null) {
if (
target.matches ? target.matches("a") : target.msMatchesSelector("a")
target.matches ? target.matches('a') : target.msMatchesSelector('a')
) {
if (
target.href &&
target.href.startsWith("http") &&
target.target === "_blank"
target.href.startsWith('http') &&
target.target === '_blank'
) {
window.__TAURI__._invoke('tauri', {
__tauriModule: "Shell",
message: {
cmd: "open",
path: target.href,
window.__TAURI__._invoke(
'tauri',
{
__tauriModule: 'Shell',
message: {
cmd: 'open',
path: target.href
}
},
}, _KEY_VALUE_);
e.preventDefault();
_KEY_VALUE_
)
e.preventDefault()
}
break;
break
}
target = target.parentElement;
target = target.parentElement
}
},
true
);
)
}
if (
document.readyState === "complete" ||
document.readyState === "interactive"
document.readyState === 'complete' ||
document.readyState === 'interactive'
) {
__openLinks();
__openLinks()
} else {
window.addEventListener(
"DOMContentLoaded",
'DOMContentLoaded',
function () {
__openLinks();
__openLinks()
},
true
);
)
}
// drag region
document.addEventListener('mousedown', (e) => {
if (e.target.hasAttribute("data-tauri-drag-region") && e.buttons === 1) {
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
e.detail === 2
? window.__TAURI__._invoke(
"tauri",
window.__TAURI__._invoke(
'tauri',
{
__tauriModule: "Window",
__tauriModule: 'Window',
message: {
cmd: "toggleMaximize",
},
cmd: e.detail === 2 ? 'toggleMaximize' : 'startDragging'
}
},
_KEY_VALUE_
)
: window.__TAURI__._invoke(
"tauri",
{
__tauriModule: "Window",
message: {
cmd: "startDragging",
},
},
_KEY_VALUE_
);
)
}
})
window.__TAURI__._invoke('tauri', {
__tauriModule: "Event",
message: {
cmd: "listen",
event: "tauri://window-created",
handler: window.__TAURI__.transformCallback(function (event) {
if (event.payload) {
var windowLabel = event.payload.label;
window.__TAURI__.__windows.push({ label: windowLabel });
}
}),
window.__TAURI__._invoke(
'tauri',
{
__tauriModule: 'Event',
message: {
cmd: 'listen',
event: 'tauri://window-created',
handler: window.__TAURI__.transformCallback(function (event) {
if (event.payload) {
var windowLabel = event.payload.label
window.__TAURI__.__windows.push({ label: windowLabel })
}
})
}
},
}, _KEY_VALUE_);
_KEY_VALUE_
)
let permissionSettable = false;
let permissionValue = "default";
let permissionSettable = false
let permissionValue = 'default'
function isPermissionGranted() {
if (window.Notification.permission !== "default") {
return Promise.resolve(window.Notification.permission === "granted");
if (window.Notification.permission !== 'default') {
return Promise.resolve(window.Notification.permission === 'granted')
}
return window.__TAURI__._invoke('tauri', {
__tauriModule: "Notification",
message: {
cmd: "isNotificationPermissionGranted",
return window.__TAURI__._invoke(
'tauri',
{
__tauriModule: 'Notification',
message: {
cmd: 'isNotificationPermissionGranted'
}
},
}, _KEY_VALUE_);
_KEY_VALUE_
)
}
function setNotificationPermission(value) {
permissionSettable = true;
window.Notification.permission = value;
permissionSettable = false;
permissionSettable = true
window.Notification.permission = value
permissionSettable = false
}
function requestPermission() {
return window.__TAURI__
.invoke('tauri', {
__tauriModule: "Notification",
message: {
cmd: "requestNotificationPermission",
.invoke(
'tauri',
{
__tauriModule: 'Notification',
message: {
cmd: 'requestNotificationPermission'
}
},
}, _KEY_VALUE_)
_KEY_VALUE_
)
.then(function (permission) {
setNotificationPermission(permission);
return permission;
});
setNotificationPermission(permission)
return permission
})
}
function sendNotification(options) {
if (typeof options === "object") {
Object.freeze(options);
if (typeof options === 'object') {
Object.freeze(options)
}
isPermissionGranted().then(function (permission) {
if (permission) {
return window.__TAURI__._invoke('tauri', {
__tauriModule: "Notification",
message: {
cmd: "notification",
options:
typeof options === "string"
? {
title: options,
}
: options,
return window.__TAURI__._invoke(
'tauri',
{
__tauriModule: 'Notification',
message: {
cmd: 'notification',
options:
typeof options === 'string'
? {
title: options
}
: options
}
},
}, _KEY_VALUE_);
_KEY_VALUE_
)
}
});
})
}
window.Notification = function (title, options) {
var opts = options || {};
var opts = options || {}
sendNotification(
Object.assign(opts, {
title: title,
title: title
})
);
};
)
}
window.Notification.requestPermission = requestPermission;
window.Notification.requestPermission = requestPermission
Object.defineProperty(window.Notification, "permission", {
Object.defineProperty(window.Notification, 'permission', {
enumerable: true,
get: function () {
return permissionValue;
return permissionValue
},
set: function (v) {
if (!permissionSettable) {
throw new Error("Readonly property");
throw new Error('Readonly property')
}
permissionValue = v;
},
});
permissionValue = v
}
})
isPermissionGranted().then(function (response) {
if (response === null) {
setNotificationPermission("default");
setNotificationPermission('default')
} else {
setNotificationPermission(response ? "granted" : "denied");
setNotificationPermission(response ? 'granted' : 'denied')
}
});
})
window.alert = function (message) {
window.__TAURI__._invoke('tauri', {
__tauriModule: "Dialog",
message: {
cmd: "messageDialog",
message: message,
window.__TAURI__._invoke(
'tauri',
{
__tauriModule: 'Dialog',
message: {
cmd: 'messageDialog',
message: message
}
},
}, _KEY_VALUE_);
};
_KEY_VALUE_
)
}
window.confirm = function (message) {
return window.__TAURI__._invoke('tauri', {
__tauriModule: "Dialog",
message: {
cmd: "askDialog",
message: message,
return window.__TAURI__._invoke(
'tauri',
{
__tauriModule: 'Dialog',
message: {
cmd: 'askDialog',
message: message
}
},
}, _KEY_VALUE_);
};
_KEY_VALUE_
)
}
// 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', {
__tauriModule: "Window",
message: {
cmd: "print"
return window.__TAURI__._invoke(
'tauri',
{
__tauriModule: 'Window',
message: {
cmd: 'print'
}
},
}, _KEY_VALUE_);
_KEY_VALUE_
)
}
}
})();
})()

View File

@ -75,10 +75,7 @@
{
"label": "CI/CD",
"type": "category",
"items": [
"usage/ci-cd/workflow",
"usage/ci-cd/cross-platform"
]
"items": ["usage/ci-cd/workflow", "usage/ci-cd/cross-platform"]
},
"usage/contributor-guide"
]

File diff suppressed because one or more lines are too long

View File

@ -41,7 +41,7 @@ body {
color: #f0f4f5;
border: solid 1px rgba(255, 255, 255, 0.055);
box-shadow: 0 1px 5px 0 rgb(0 0 0 / 20%);
font-family: "Courier New", Courier, monospace;
font-family: 'Courier New', Courier, monospace;
font-size: 12px;
word-wrap: break-word;
padding: 0px 15px;
@ -80,7 +80,7 @@ button:active {
.button {
border: 0;
border-radius: 0.25rem;
background: #67D6ED;
background: #67d6ed;
color: rgb(0, 0, 0);
font-family: system-ui, sans-serif;
font-size: 1rem;
@ -120,9 +120,9 @@ button:active {
}
.nv_selected {
color: #67D6ED;
color: #67d6ed;
padding-left: 8px;
border-left: solid 5px #67D6ED;
border-left: solid 5px #67d6ed;
}
.content {
@ -138,14 +138,14 @@ main {
height: 100%;
}
[type="radio"]:checked~label {
[type='radio']:checked ~ label {
background: rgb(36, 37, 38);
color: #67D6ED;
color: #67d6ed;
border-bottom: 1px solid transparent;
z-index: 2;
}
[type="radio"]:checked~label~.content {
[type='radio']:checked ~ label ~ .content {
z-index: 1;
}

View File

@ -1,26 +1,26 @@
import svelte from "rollup-plugin-svelte";
import resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import livereload from "rollup-plugin-livereload";
import { terser } from "rollup-plugin-terser";
import svelte from 'rollup-plugin-svelte'
import resolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import livereload from 'rollup-plugin-livereload'
import { terser } from 'rollup-plugin-terser'
const production = !process.env.ROLLUP_WATCH;
const production = !process.env.ROLLUP_WATCH
export default {
input: "src/main.js",
input: 'src/main.js',
output: {
sourcemap: true,
format: "iife",
name: "app",
file: "public/build/bundle.js",
format: 'iife',
name: 'app',
file: 'public/build/bundle.js'
},
plugins: [
svelte({
compilerOptions: {
// enable run-time checks when not in production
dev: !production,
dev: !production
},
emitCss: false,
emitCss: false
}),
// If you have external dependencies installed from
@ -30,7 +30,7 @@ export default {
// https://github.com/rollup/plugins/tree/master/packages/commonjs
resolve({
browser: true,
dedupe: ["svelte"],
dedupe: ['svelte']
}),
commonjs(),
@ -40,38 +40,38 @@ export default {
// Watch the `public` directory and refresh the
// browser on changes when not in production
!production && livereload("public"),
!production && livereload('public'),
// If we're building for production (npm run build
// instead of npm run dev), minify
production && terser(),
production && terser()
],
watch: {
clearScreen: false,
},
};
clearScreen: false
}
}
function serve() {
let server;
let server
function toExit() {
if (server) server.kill(0);
if (server) server.kill(0)
}
return {
writeBundle() {
if (server) return;
server = require("child_process").spawn(
"npm",
["run", "start", "--", "--dev"],
if (server) return
server = require('child_process').spawn(
'npm',
['run', 'start', '--', '--dev'],
{
stdio: ["ignore", "inherit", "inherit"],
shell: true,
stdio: ['ignore', 'inherit', 'inherit'],
shell: true
}
);
)
process.on("SIGTERM", toExit);
process.on("exit", toExit);
},
};
process.on('SIGTERM', toExit)
process.on('exit', toExit)
}
}
}

View File

@ -24,11 +24,7 @@
"name": "theme",
"takesValue": true,
"description": "App theme",
"possibleValues": [
"light",
"dark",
"system"
]
"possibleValues": ["light", "dark", "system"]
},
{
"short": "v",

View File

@ -1,7 +1,7 @@
import App from "./App.svelte";
import App from './App.svelte'
const app = new App({
target: document.body,
});
target: document.body
})
export default app;
export default app

View File

@ -1,62 +1,68 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Tauri</title>
</head>
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Tauri</title>
</head>
<body>
<h1>Tauri Commands</h1>
<div>Response: <span id="response"></span></div>
<div>Without Args: <span id="response-optional"></span></div>
<div id="container"></div>
<script>
function runCommand(commandName, args, optional) {
const id = optional ? '#response-optional' : '#response'
const result = document.querySelector(id)
window.__TAURI__
.invoke(commandName, args)
.then((response) => {
result.innerText = `Ok(${response})`
})
.catch((error) => {
result.innerText = `Err(${error})`
})
}
<body>
<h1>Tauri Commands</h1>
<div>Response: <span id="response"></span></div>
<div >Without Args: <span id="response-optional"></span></div>
<div id="container"></div>
<script>
function runCommand(commandName, args, optional) {
const id = optional ? "#response-optional" : "#response";
const result = document.querySelector(id)
window.__TAURI__.invoke(commandName, args).then(response => {
result.innerText = `Ok(${response})`
}).catch(error => {
result.innerText = `Err(${error})`
})
}
const container = document.querySelector('#container')
const commands = [
{ name: 'borrow_cmd' },
{ name: 'window_label' },
{ name: 'simple_command' },
{ name: 'stateful_command' },
{ name: 'async_simple_command' },
{ name: 'future_simple_command'},
{ name: 'async_stateful_command' },
{ name: 'simple_command_with_result' },
{ name: 'stateful_command_with_result' },
{ name: 'async_simple_command_with_result' },
{ name: 'future_simple_command_with_return' },
{ name: 'future_simple_command_with_result' },
{ name: 'async_stateful_command_with_result' },
{ name: 'command_arguments_wild' },
{ name: 'command_arguments_struct', args: { "Person": { "name": "ferris", age: 6 } } },
{ name: 'command_arguments_tuple_struct', args: { "InlinePerson": [ "ferris", 6 ] } },
]
for (const command of commands) {
const { name } = command
const args = command.args ?? { argument: 'value' }
const button = document.createElement('button')
button.innerHTML = `Run ${name}`;
button.addEventListener("click", function () {
runCommand(name, args, false)
runCommand(name, Object.create(null), true)
});
container.appendChild(button);
}
</script>
</body>
const container = document.querySelector('#container')
const commands = [
{ name: 'borrow_cmd' },
{ name: 'window_label' },
{ name: 'simple_command' },
{ name: 'stateful_command' },
{ name: 'async_simple_command' },
{ name: 'future_simple_command' },
{ name: 'async_stateful_command' },
{ name: 'simple_command_with_result' },
{ name: 'stateful_command_with_result' },
{ name: 'async_simple_command_with_result' },
{ name: 'future_simple_command_with_return' },
{ name: 'future_simple_command_with_result' },
{ name: 'async_stateful_command_with_result' },
{ name: 'command_arguments_wild' },
{
name: 'command_arguments_struct',
args: { Person: { name: 'ferris', age: 6 } }
},
{
name: 'command_arguments_tuple_struct',
args: { InlinePerson: ['ferris', 6] }
}
]
for (const command of commands) {
const { name } = command
const args = command.args ?? { argument: 'value' }
const button = document.createElement('button')
button.innerHTML = `Run ${name}`
button.addEventListener('click', function () {
runCommand(name, args, false)
runCommand(name, Object.create(null), true)
})
container.appendChild(button)
}
</script>
</body>
</html>

View File

@ -1,11 +1,7 @@
{
"build": {
"distDir": [
"../index.html"
],
"devPath": [
"../index.html"
],
"distDir": ["../index.html"],
"devPath": ["../index.html"],
"beforeDevCommand": "",
"beforeBuildCommand": "",
"withGlobalTauri": true
@ -58,4 +54,4 @@
"active": false
}
}
}
}

View File

@ -4,4 +4,4 @@
"scripts": {
"tauri": "node ../../tooling/cli.js/bin/tauri"
}
}
}

View File

@ -1,11 +1,7 @@
{
"build": {
"distDir": [
"../index.html"
],
"devPath": [
"../index.html"
],
"distDir": ["../index.html"],
"devPath": ["../index.html"],
"beforeDevCommand": "",
"beforeBuildCommand": ""
},

View File

@ -1,75 +1,74 @@
<!DOCTYPE html>
<html>
<body>
<div id="window-label"></div>
<div id="container"></div>
<div id="response"></div>
<body>
<div id="window-label"></div>
<div id="container"></div>
<div id="response"></div>
<script>
var WebviewWindow = window.__TAURI__.window.WebviewWindow
var thisTauriWindow = window.__TAURI__.window.getCurrent()
var windowLabel = thisTauriWindow.label
var windowLabelContainer = document.getElementById('window-label')
windowLabelContainer.innerHTML = 'This is the ' + windowLabel + ' window.'
<script>
var WebviewWindow = window.__TAURI__.window.WebviewWindow
var thisTauriWindow = window.__TAURI__.window.getCurrent();
var windowLabel = thisTauriWindow.label;
var windowLabelContainer = document.getElementById("window-label");
windowLabelContainer.innerHTML =
"This is the " + windowLabel + " window.";
var container = document.getElementById('container')
var container = document.getElementById("container");
function createWindowMessageBtn(label) {
var tauriWindow = WebviewWindow.getByLabel(label)
var button = document.createElement("button");
button.innerHTML = "Send message to " + label;
button.addEventListener("click", function () {
tauriWindow.emit("clicked", "message from " + windowLabel);
});
container.appendChild(button);
}
// global listener
window.__TAURI__.event.listen("clicked", function (event) {
responseContainer.innerHTML += "Got " + JSON.stringify(event) + " on global listener<br><br>";
})
window.__TAURI__.event.listen('tauri://window-created', function (event) {
createWindowMessageBtn(event.payload.label)
})
var responseContainer = document.getElementById("response");
// listener tied to this window
thisTauriWindow.listen("clicked", function (event) {
responseContainer.innerHTML += "Got " + JSON.stringify(event) + " on window listener<br><br>";
});
var createWindowButton = document.createElement("button");
createWindowButton.innerHTML = "Create window";
createWindowButton.addEventListener("click", function () {
var webviewWindow = new WebviewWindow(Math.random().toString());
webviewWindow.once('tauri://created', function () {
responseContainer.innerHTML += "Created new webview"
})
webviewWindow.once('tauri://error', function () {
responseContainer.innerHTML += "Error creating new webview"
})
});
container.appendChild(createWindowButton);
var globalMessageButton = document.createElement("button");
globalMessageButton.innerHTML = "Send global message";
globalMessageButton.addEventListener("click", function () {
// emit to all windows
window.__TAURI__.event.emit("clicked", "message from " + windowLabel);
});
container.appendChild(globalMessageButton);
var allWindows = window.__TAURI__.window.getAll()
for (var index in allWindows) {
var label = allWindows[index].label;
if (label === windowLabel) {
continue;
function createWindowMessageBtn(label) {
var tauriWindow = WebviewWindow.getByLabel(label)
var button = document.createElement('button')
button.innerHTML = 'Send message to ' + label
button.addEventListener('click', function () {
tauriWindow.emit('clicked', 'message from ' + windowLabel)
})
container.appendChild(button)
}
createWindowMessageBtn(label)
}
</script>
</body>
// global listener
window.__TAURI__.event.listen('clicked', function (event) {
responseContainer.innerHTML +=
'Got ' + JSON.stringify(event) + ' on global listener<br><br>'
})
window.__TAURI__.event.listen('tauri://window-created', function (event) {
createWindowMessageBtn(event.payload.label)
})
var responseContainer = document.getElementById('response')
// listener tied to this window
thisTauriWindow.listen('clicked', function (event) {
responseContainer.innerHTML +=
'Got ' + JSON.stringify(event) + ' on window listener<br><br>'
})
var createWindowButton = document.createElement('button')
createWindowButton.innerHTML = 'Create window'
createWindowButton.addEventListener('click', function () {
var webviewWindow = new WebviewWindow(Math.random().toString())
webviewWindow.once('tauri://created', function () {
responseContainer.innerHTML += 'Created new webview'
})
webviewWindow.once('tauri://error', function () {
responseContainer.innerHTML += 'Error creating new webview'
})
})
container.appendChild(createWindowButton)
var globalMessageButton = document.createElement('button')
globalMessageButton.innerHTML = 'Send global message'
globalMessageButton.addEventListener('click', function () {
// emit to all windows
window.__TAURI__.event.emit('clicked', 'message from ' + windowLabel)
})
container.appendChild(globalMessageButton)
var allWindows = window.__TAURI__.window.getAll()
for (var index in allWindows) {
var label = allWindows[index].label
if (label === windowLabel) {
continue
}
createWindowMessageBtn(label)
}
</script>
</body>
</html>

View File

@ -8,4 +8,4 @@
"tauri": "node ../../tooling/cli.js/bin/tauri"
},
"private": true
}
}

View File

@ -1,11 +1,7 @@
{
"build": {
"distDir": [
"../index.html"
],
"devPath": [
"../index.html"
],
"distDir": ["../index.html"],
"devPath": ["../index.html"],
"withGlobalTauri": true
},
"tauri": {
@ -49,4 +45,4 @@
"active": false
}
}
}
}

View File

@ -4,4 +4,4 @@
"scripts": {
"tauri": "node ../../tooling/cli.js/bin/tauri"
}
}
}

View File

@ -1,24 +1,22 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Tauri</title>
</head>
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Tauri</title>
</head>
<body>
<h1>index.html</h1>
<select id="route">
<option value="secondary.html">secondary.html</option>
<option value="nested/index.html">nested/index.html</option>
<option value="nested/secondary.html">nested/secondary.html</option>
</select>
<button id="open-window">New window</button>
<button id="go">Go</button>
<a id="link" href="secondary.html">Go</a>
<script src="index.js"></script>
</body>
<body>
<h1>index.html</h1>
<select id="route">
<option value="secondary.html">secondary.html</option>
<option value="nested/index.html">nested/index.html</option>
<option value="nested/secondary.html">nested/secondary.html</option>
</select>
<button id="open-window">New window</button>
<button id="go">Go</button>
<a id="link" href="secondary.html">Go</a>
<script src="index.js"></script>
</body>
</html>

View File

@ -8,7 +8,7 @@ routeSelect.addEventListener('change', (event) => {
})
document.querySelector('#go').addEventListener('click', () => {
window.location.href = (window.location.origin + '/' + routeSelect.value)
window.location.href = window.location.origin + '/' + routeSelect.value
})
document.querySelector('#open-window').addEventListener('click', () => {

View File

@ -1,17 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Tauri</title>
</head>
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Tauri</title>
</head>
<body>
<h1></h1>
<button onclick="window.history.back()">Back</button>
<script src="index.js"></script>
</body>
<body>
<h1></h1>
<button onclick="window.history.back()">Back</button>
<script src="index.js"></script>
</body>
</html>

View File

@ -1,17 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Tauri</title>
</head>
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Tauri</title>
</head>
<body>
<h1></h1>
<button onclick="window.history.back()">Back</button>
<script src="secondary.js"></script>
</body>
<body>
<h1></h1>
<button onclick="window.history.back()">Back</button>
<script src="secondary.js"></script>
</body>
</html>

View File

@ -1,17 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Tauri</title>
</head>
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Tauri</title>
</head>
<body>
<h1></h1>
<button onclick="window.history.back()">Back</button>
<script src="secondary.js"></script>
</body>
<body>
<h1></h1>
<button onclick="window.history.back()">Back</button>
<script src="secondary.js"></script>
</body>
</html>

View File

@ -54,4 +54,4 @@
"active": false
}
}
}
}

View File

@ -1,12 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Params</title>
</head>
<body>
<h1>Simple custom `Params` types check.</h1>
</body>
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Params</title>
</head>
<body>
<h1>Simple custom `Params` types check.</h1>
</body>
</html>

View File

@ -1,11 +1,7 @@
{
"build": {
"distDir": [
"../index.html"
],
"devPath": [
"../index.html"
],
"distDir": ["../index.html"],
"devPath": ["../index.html"],
"beforeDevCommand": "",
"beforeBuildCommand": ""
},
@ -57,4 +53,4 @@
"active": false
}
}
}
}

View File

@ -1,23 +1,21 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Sidecar</title>
</head>
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Sidecar</title>
</head>
<body>
<div></div>
<script>
const div = document.querySelector('div')
window.__TAURI__.event.listen('message', event => {
const p = document.createElement('p')
p.innerHTML = event.payload
div.appendChild(p)
})
</script>
</body>
<body>
<div></div>
<script>
const div = document.querySelector('div')
window.__TAURI__.event.listen('message', (event) => {
const p = document.createElement('p')
p.innerHTML = event.payload
div.appendChild(p)
})
</script>
</body>
</html>

View File

@ -1,3 +1,3 @@
setInterval(() => {
console.log(`[${new Date().toLocaleTimeString()}] new message`)
console.log(`[${new Date().toLocaleTimeString()}] new message`)
}, 500)

View File

@ -1,11 +1,7 @@
{
"build": {
"distDir": [
"../index.html"
],
"devPath": [
"../index.html"
],
"distDir": ["../index.html"],
"devPath": ["../index.html"],
"beforeDevCommand": "",
"beforeBuildCommand": "",
"withGlobalTauri": true

View File

@ -1,23 +1,21 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Sidecar</title>
</head>
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Sidecar</title>
</head>
<body>
<div></div>
<script>
const div = document.querySelector('div')
window.__TAURI__.event.listen('message', event => {
const p = document.createElement('p')
p.innerHTML = event.payload
div.appendChild(p)
})
</script>
</body>
<body>
<div></div>
<script>
const div = document.querySelector('div')
window.__TAURI__.event.listen('message', (event) => {
const p = document.createElement('p')
p.innerHTML = event.payload
div.appendChild(p)
})
</script>
</body>
</html>

View File

@ -1,11 +1,7 @@
{
"build": {
"distDir": [
"../index.html"
],
"devPath": [
"../index.html"
],
"distDir": ["../index.html"],
"devPath": ["../index.html"],
"beforeDevCommand": "yarn package",
"beforeBuildCommand": "yarn package",
"withGlobalTauri": true

View File

@ -8,7 +8,7 @@ module.exports = {
terminal: false
})
rl.on('line', function(line){
rl.on('line', function (line) {
cb(line)
})
},

View File

@ -1,9 +1,9 @@
const { write, onMessage } = require('./communication')
onMessage(line => {
onMessage((line) => {
write(`read ${line}`)
})
setInterval(() => {
write(`[${new Date().toLocaleTimeString()}] new message`)
write(`[${new Date().toLocaleTimeString()}] new message`)
}, 500)

View File

@ -1,16 +1,14 @@
<!DOCTYPE html>
<html>
<body>
<h1>This is the main window!</h1>
<script>
document.addEventListener('DOMContentLoaded', () => {
// we delay here just so we can see the splashscreen for a while
setTimeout(() => {
window.__TAURI__.invoke('close_splashscreen')
}, 2000)
})
</script>
</body>
<body>
<h1>This is the main window!</h1>
<script>
document.addEventListener('DOMContentLoaded', () => {
// we delay here just so we can see the splashscreen for a while
setTimeout(() => {
window.__TAURI__.invoke('close_splashscreen')
}, 2000)
})
</script>
</body>
</html>

View File

@ -1,28 +1,26 @@
<!DOCTYPE html>
<html>
<head>
<title>Splashscreen</title>
<style>
body {
margin: 0;
}
<head>
<title>Splashscreen</title>
<style>
body {
margin: 0;
}
.splashscreen-image {
background-color: #444;
background-image: url('icon.png');
background-position: center;
background-repeat: no-repeat;
background-size: 50%;
width: 100vw !important;
height: 100vh !important;
overflow: hidden;
}
</style>
</head>
.splashscreen-image {
background-color: #444;
background-image: url('icon.png');
background-position: center;
background-repeat: no-repeat;
background-size: 50%;
width: 100vw !important;
height: 100vh !important;
overflow: hidden;
}
</style>
</head>
<body>
<div class="splashscreen-image" />
</body>
</html>
<body>
<div class="splashscreen-image" />
</body>
</html>

View File

@ -48,4 +48,4 @@
"active": false
}
}
}
}

View File

@ -1,57 +1,65 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Tauri</title>
</head>
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Tauri</title>
</head>
<body>
<h3>Counter</h3>
<div>
<button id="increment-btn">Increment counter</button>
</div>
<h3>Database</h3>
<div>
<input id="store-input" placeholder="The value to store" />
<button id="store-btn">Store</button>
</div>
<div>
<button id="read-btn">Read</button>
</div>
<div id="response"></div>
<body>
<h3>Counter</h3>
<div>
<button id="increment-btn">Increment counter</button>
</div>
<h3>Database</h3>
<div>
<input id="store-input" placeholder="The value to store">
<button id="store-btn">Store</button>
</div>
<div>
<button id="read-btn">Read</button>
</div>
<div id="response"></div>
<script>
const KEY = 'db-key'
const storeBtn = document.querySelector('#store-btn')
const readBtn = document.querySelector('#read-btn')
const incrementBtn = document.querySelector('#increment-btn')
const storeInput = document.querySelector('#store-input')
const responseContainer = document.querySelector('#response')
<script>
const KEY = 'db-key'
const storeBtn = document.querySelector('#store-btn')
const readBtn = document.querySelector('#read-btn')
const incrementBtn = document.querySelector('#increment-btn')
const storeInput = document.querySelector('#store-input')
const responseContainer = document.querySelector('#response')
function updateResponse(response) {
responseContainer.innerHTML =
typeof response === 'string' ? response : JSON.stringify(response)
}
function updateResponse(response) {
responseContainer.innerHTML = typeof response === "string" ? response : JSON.stringify(response)
}
incrementBtn.addEventListener('click', () => {
window.__TAURI__
.invoke('increment_counter')
.then(updateResponse)
.catch(updateResponse)
})
incrementBtn.addEventListener('click', () => {
window.__TAURI__.invoke('increment_counter').then(updateResponse).catch(updateResponse)
})
storeBtn.addEventListener('click', () => {
window.__TAURI__.invoke('db_insert', {
key: KEY,
value: storeInput.value
}).then(updateResponse).catch(updateResponse)
})
readBtn.addEventListener('click', () => {
window.__TAURI__.invoke('db_read', {
key: KEY
}).then(updateResponse).catch(updateResponse)
})
</script>
</body>
storeBtn.addEventListener('click', () => {
window.__TAURI__
.invoke('db_insert', {
key: KEY,
value: storeInput.value
})
.then(updateResponse)
.catch(updateResponse)
})
readBtn.addEventListener('click', () => {
window.__TAURI__
.invoke('db_read', {
key: KEY
})
.then(updateResponse)
.catch(updateResponse)
})
</script>
</body>
</html>

View File

@ -4,4 +4,4 @@
"scripts": {
"tauri": "node ../../tooling/cli.js/bin/tauri"
}
}
}

View File

@ -1,11 +1,7 @@
{
"build": {
"distDir": [
"../index.html"
],
"devPath": [
"../index.html"
],
"distDir": ["../index.html"],
"devPath": ["../index.html"],
"beforeDevCommand": "",
"beforeBuildCommand": "",
"withGlobalTauri": true
@ -58,4 +54,4 @@
"active": false
}
}
}
}

View File

@ -4,4 +4,4 @@
"scripts": {
"tauri": "node ../../tooling/cli.js/bin/tauri"
}
}
}

View File

@ -1,11 +1,7 @@
{
"build": {
"distDir": [
"../index.html"
],
"devPath": [
"../index.html"
],
"distDir": ["../index.html"],
"devPath": ["../index.html"],
"beforeDevCommand": "",
"beforeBuildCommand": ""
},
@ -62,4 +58,4 @@
]
}
}
}
}

View File

@ -12,7 +12,7 @@
"directory": "tooling/cli.js"
},
"scripts": {
"format": "prettier --write --end-of-line=auto \"./**/*.{js,jsx,ts,tsx,html,css,json}\" --ignore-path .gitignore",
"format": "prettier --write --end-of-line=auto \"./**/*.{cjs,js,jsx,ts,tsx,html,css,json}\" --ignore-path .gitignore",
"postinstall": "husky install"
},
"devDependencies": {

View File

@ -1,31 +1,20 @@
{
"extends": [
"config:base"
],
"extends": ["config:base"],
"schedule": "after 3am on Wednesday",
"ignorePaths": [],
"labels": [
"chore"
],
"enabledManagers": [
"cargo",
"npm"
],
"labels": ["chore"],
"enabledManagers": ["cargo", "npm"],
"cargo": {
"enabled": true
},
"packageRules": [
{
"packagePatterns": [
"*"
],
"packagePatterns": ["*"],
"enabled": false
},
{
"enabled": true,
"paths": [
"core/tauri/**"
],
"paths": ["core/tauri/**"],
"groupName": "Tauri Core",
"groupSlug": "allTauriCore",
"commitMessagePrefix": "chore(deps)",
@ -36,9 +25,7 @@
},
{
"enabled": true,
"paths": [
"core/tauri-build/**"
],
"paths": ["core/tauri-build/**"],
"groupName": "Tauri Build",
"groupSlug": "allTauriBuild",
"commitMessagePrefix": "chore(deps)",
@ -49,9 +36,7 @@
},
{
"enabled": true,
"paths": [
"core/tauri-codegen/**"
],
"paths": ["core/tauri-codegen/**"],
"groupName": "Tauri Codegen",
"groupSlug": "allTauriCodegen",
"commitMessagePrefix": "chore(deps)",
@ -62,9 +47,7 @@
},
{
"enabled": true,
"paths": [
"core/tauri-macros/**"
],
"paths": ["core/tauri-macros/**"],
"groupName": "Tauri Macros",
"groupSlug": "allTauriMacros",
"commitMessagePrefix": "chore(deps)",
@ -75,9 +58,7 @@
},
{
"enabled": true,
"paths": [
"core/tauri-utils/**"
],
"paths": ["core/tauri-utils/**"],
"groupName": "Tauri Utils",
"groupSlug": "allTauriUtils",
"commitMessagePrefix": "chore(deps)",
@ -88,9 +69,7 @@
},
{
"enabled": true,
"paths": [
"tooling/cli.rs/**"
],
"paths": ["tooling/cli.rs/**"],
"groupName": "Tauri CLI",
"groupSlug": "allTauriCLI",
"commitMessagePrefix": "chore(deps)",
@ -101,9 +80,7 @@
},
{
"enabled": true,
"paths": [
"tooling/bundler/**"
],
"paths": ["tooling/bundler/**"],
"groupName": "Tauri Bundler",
"groupSlug": "allTauriBundler",
"commitMessagePrefix": "chore(deps)",
@ -114,9 +91,7 @@
},
{
"enabled": true,
"paths": [
"tooling/cli.js/**"
],
"paths": ["tooling/cli.js/**"],
"groupName": "Tauri JS CLI",
"groupSlug": "allTauriJSCLI",
"commitMessagePrefix": "chore(deps)",
@ -127,9 +102,7 @@
},
{
"enabled": true,
"paths": [
"tooling/api/**"
],
"paths": ["tooling/api/**"],
"groupName": "Tauri API Definitions",
"groupSlug": "allTauriAPIDefinitions",
"commitMessagePrefix": "chore(deps)",
@ -140,9 +113,7 @@
},
{
"enabled": true,
"paths": [
"tooling/create-tauri-app/**"
],
"paths": ["tooling/create-tauri-app/**"],
"groupName": "create-tauri-app",
"groupSlug": "allCTA",
"commitMessagePrefix": "chore(deps)",

View File

@ -17,8 +17,8 @@
"lint": "eslint --ext ts \"./src/**/*.ts\"",
"lint-fix": "eslint --fix --ext ts \"./src/**/*.ts\"",
"lint:lockfile": "lockfile-lint --path yarn.lock --type yarn --validate-https --allowed-hosts npm yarn",
"format": "prettier --write --end-of-line=auto \"./**/*.{js,jsx,ts,tsx,html,css,json}\" --ignore-path .gitignore",
"format:check": "prettier --check --end-of-line=auto \"./**/*.{js,jsx,ts,tsx,html,css,json}\" --ignore-path .gitignore"
"format": "prettier --write --end-of-line=auto \"./**/*.{cjs,js,jsx,ts,tsx,html,css,json}\" --ignore-path .gitignore",
"format:check": "prettier --check --end-of-line=auto \"./**/*.{cjs,js,jsx,ts,tsx,html,css,json}\" --ignore-path .gitignore"
},
"repository": {
"type": "git",

View File

@ -41,9 +41,7 @@ writeFileSync('dist/package.json', JSON.stringify(outputPkg, undefined, 2))
/**
* copy necessary files like `CHANGELOG.md` and Licenses to `./dist`
*/
const files = readdirSync('.').filter(
(f) => f.startsWith('LICENSE')
)
const files = readdirSync('.').filter((f) => f.startsWith('LICENSE'))
files.forEach((f) => copyFileSync(f, `dist/${f}`))
/**

View File

@ -1,5 +1,5 @@
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica,
Arial, sans-serif;
margin: auto;
max-width: 38rem;

View File

@ -1,59 +1,59 @@
// Create web worker
const THRESHOLD = 10000000;
const worker = new Worker("worker.js");
const THRESHOLD = 10000000
const worker = new Worker('worker.js')
/** @type {HTMLButtonElement} */
const start = document.getElementById("start");
const start = document.getElementById('start')
/** @type {HTMLParagraphElement} */
const status = document.getElementById("status");
const results = document.getElementById("results");
const status = document.getElementById('status')
const results = document.getElementById('results')
const ITERATIONS = 1;
const ITERATIONS = 1
let resolver;
let resolver
const onMessage = (message) => {
// Update the UI
let prefix = "[Calculating]";
let prefix = '[Calculating]'
if (message.data.status === "done") {
if (message.data.status === 'done') {
// tell tauri that we are done
window.__TAURI__.invoke("tauri", {
__tauriModule: "Process",
window.__TAURI__.invoke('tauri', {
__tauriModule: 'Process',
message: {
cmd: "exit",
exitCode: 0,
},
});
cmd: 'exit',
exitCode: 0
}
})
}
status.innerHTML = `${prefix} Found <code>${message.data.count}</code> prime numbers in <code>${message.data.time}ms</code>`;
status.innerHTML = `${prefix} Found <code>${message.data.count}</code> prime numbers in <code>${message.data.time}ms</code>`
if (message.data.status === "done") {
resolver(message.data.time);
if (message.data.status === 'done') {
resolver(message.data.time)
}
};
}
worker.addEventListener("message", onMessage);
worker.addEventListener('message', onMessage)
const benchmark = () => {
return new Promise((resolve) => {
const startTime = Date.now();
resolver = resolve;
worker.postMessage({ value: THRESHOLD, startTime });
});
};
const startTime = Date.now()
resolver = resolve
worker.postMessage({ value: THRESHOLD, startTime })
})
}
const calculate = async () => {
let total = 0;
let total = 0
for (let i = 0; i < ITERATIONS; i++) {
const result = await benchmark();
total += result;
const result = await benchmark()
total += result
}
const average = total / ITERATIONS;
const average = total / ITERATIONS
results.innerText = `Average time: ${average}ms`;
};
results.innerText = `Average time: ${average}ms`
}
window.addEventListener("DOMContentLoaded", calculate);
window.addEventListener('DOMContentLoaded', calculate)

View File

@ -1,45 +1,45 @@
const isPrime = (number) => {
if (number % 2 === 0 && number > 2) {
return false;
return false
}
let start = 2;
const limit = Math.sqrt(number);
let start = 2
const limit = Math.sqrt(number)
while (start <= limit) {
if (number % start++ < 1) {
return false;
return false
}
}
return number > 1;
};
return number > 1
}
addEventListener("message", (e) => {
const { startTime } = e.data;
addEventListener('message', (e) => {
const { startTime } = e.data
let n = 0;
let total = 0;
const THRESHOLD = e.data.value;
const primes = [];
let n = 0
let total = 0
const THRESHOLD = e.data.value
const primes = []
let previous = startTime;
let previous = startTime
while (++n <= THRESHOLD) {
if (isPrime(n)) {
primes.push(n);
total++;
primes.push(n)
total++
const now = Date.now();
const now = Date.now()
if (now - previous > 250) {
previous = now;
previous = now
postMessage({
status: "calculating",
status: 'calculating',
count: total,
time: Date.now() - startTime,
});
time: Date.now() - startTime
})
}
}
}
postMessage({ status: "done", count: total, time: Date.now() - startTime });
});
postMessage({ status: 'done', count: total, time: Date.now() - startTime })
})

View File

@ -54,4 +54,4 @@
"active": false
}
}
}
}

View File

@ -10,39 +10,39 @@
<h1>Welcome to Tauri!</h1>
<script>
window.addEventListener("DOMContentLoaded", (event) => {
window.addEventListener('DOMContentLoaded', (event) => {
window.__TAURI__
.invoke("tauri", {
__tauriModule: "Fs",
.invoke('tauri', {
__tauriModule: 'Fs',
message: {
cmd: "readBinaryFile",
path: ".tauri_3mb.json",
cmd: 'readBinaryFile',
path: '.tauri_3mb.json',
options: {
// home folder
dir: 11,
},
},
dir: 11
}
}
})
.then((_data) => {
window.__TAURI__.invoke("tauri", {
__tauriModule: "Process",
window.__TAURI__.invoke('tauri', {
__tauriModule: 'Process',
message: {
cmd: "exit",
exitCode: 0,
},
});
cmd: 'exit',
exitCode: 0
}
})
})
.catch((_error) => {
// error
window.__TAURI__.invoke("tauri", {
__tauriModule: "Process",
window.__TAURI__.invoke('tauri', {
__tauriModule: 'Process',
message: {
cmd: "exit",
exitCode: 1,
},
});
});
});
cmd: 'exit',
exitCode: 1
}
})
})
})
</script>
</body>
</html>

View File

@ -57,4 +57,4 @@
"active": false
}
}
}
}

View File

@ -10,15 +10,15 @@
<h1>Welcome to Tauri!</h1>
<script>
window.addEventListener("DOMContentLoaded", (event) => {
window.__TAURI__.invoke("tauri", {
__tauriModule: "Process",
window.addEventListener('DOMContentLoaded', (event) => {
window.__TAURI__.invoke('tauri', {
__tauriModule: 'Process',
message: {
cmd: "exit",
exitCode: 0,
},
});
});
cmd: 'exit',
exitCode: 0
}
})
})
</script>
</body>
</html>

View File

@ -54,4 +54,4 @@
"active": false
}
}
}
}

View File

@ -24,8 +24,8 @@
"lint": "eslint --ext ts \"./src/**/*.ts\"",
"lint-fix": "eslint --fix --ext ts \"./src/**/*.ts\"",
"lint:lockfile": "lockfile-lint --path yarn.lock --type yarn --validate-https --allowed-hosts npm yarn",
"format": "prettier --write --end-of-line=auto \"./**/*.{js,jsx,ts,tsx,html,css,json}\" --ignore-path .gitignore",
"format:check": "prettier --check --end-of-line=auto \"./**/*.{js,jsx,ts,tsx,html,css,json}\" --ignore-path .gitignore"
"format": "prettier --write --end-of-line=auto \"./**/*.{cjs,js,jsx,ts,tsx,html,css,json}\" --ignore-path .gitignore",
"format:check": "prettier --check --end-of-line=auto \"./**/*.{cjs,js,jsx,ts,tsx,html,css,json}\" --ignore-path .gitignore"
},
"repository": {
"type": "git",

View File

@ -228,17 +228,11 @@
"properties": {
"beforeBuildCommand": {
"description": "a shell command to run before `tauri build` kicks in",
"type": [
"string",
"null"
]
"type": ["string", "null"]
},
"beforeDevCommand": {
"description": "a shell command to run before `tauri dev` kicks in",
"type": [
"string",
"null"
]
"type": ["string", "null"]
},
"devPath": {
"description": "The path or URL to use on development.",
@ -260,20 +254,14 @@
},
"features": {
"description": "features passed to `cargo` commands",
"type": [
"array",
"null"
],
"type": ["array", "null"],
"items": {
"type": "string"
}
},
"runner": {
"description": "The binary used to build and run the application.",
"type": [
"string",
"null"
]
"type": ["string", "null"]
},
"withGlobalTauri": {
"description": "Whether we should inject the Tauri API on `window.__TAURI__` or not.",
@ -292,16 +280,10 @@
"type": "boolean"
},
"category": {
"type": [
"string",
"null"
]
"type": ["string", "null"]
},
"copyright": {
"type": [
"string",
"null"
]
"type": ["string", "null"]
},
"deb": {
"default": {
@ -315,36 +297,24 @@
]
},
"externalBin": {
"type": [
"array",
"null"
],
"type": ["array", "null"],
"items": {
"type": "string"
}
},
"icon": {
"description": "The app's icons",
"type": [
"array",
"null"
],
"type": ["array", "null"],
"items": {
"type": "string"
}
},
"identifier": {
"description": "The app's identifier",
"type": [
"string",
"null"
]
"type": ["string", "null"]
},
"longDescription": {
"type": [
"string",
"null"
]
"type": ["string", "null"]
},
"macOS": {
"default": {
@ -358,19 +328,13 @@
},
"resources": {
"description": "App resources to bundle. Each resource is a path to a file or directory. Glob patterns are supported.",
"type": [
"array",
"null"
],
"type": ["array", "null"],
"items": {
"type": "string"
}
},
"shortDescription": {
"type": [
"string",
"null"
]
"type": ["string", "null"]
},
"targets": {
"description": "The bundle targets, currently supports [\"deb\", \"app\", \"msi\", \"appimage\", \"dmg\"] or \"all\"",
@ -415,197 +379,129 @@
"CliArg": {
"description": "A CLI argument definition",
"type": "object",
"required": [
"name"
],
"required": ["name"],
"properties": {
"conflictsWith": {
"description": "Sets a conflicting argument by name i.e. when using this argument, the following argument can't be present and vice versa.",
"type": [
"string",
"null"
]
"type": ["string", "null"]
},
"conflictsWithAll": {
"description": "The same as conflictsWith but allows specifying multiple two-way conflicts per argument.",
"type": [
"array",
"null"
],
"type": ["array", "null"],
"items": {
"type": "string"
}
},
"description": {
"description": "The argument description which will be shown on the help information. Typically, this is a short (one line) description of the arg.",
"type": [
"string",
"null"
]
"type": ["string", "null"]
},
"index": {
"description": "The positional argument index, starting at 1.\n\nThe index refers to position according to other positional argument. It does not define position in the argument list as a whole. When utilized with multiple=true, only the last positional argument may be defined as multiple (i.e. the one with the highest index).",
"type": [
"integer",
"null"
],
"type": ["integer", "null"],
"format": "uint64",
"minimum": 0.0
},
"longDescription": {
"description": "The argument long description which will be shown on the help information. Typically this a more detailed (multi-line) message that describes the argument.",
"type": [
"string",
"null"
]
"type": ["string", "null"]
},
"maxValues": {
"description": "Specifies the maximum number of values are for this argument. For example, if you had a -f <file> argument where you wanted up to 3 'files', you would set .max_values(3), and this argument would be satisfied if the user provided, 1, 2, or 3 values.",
"type": [
"integer",
"null"
],
"type": ["integer", "null"],
"format": "uint64",
"minimum": 0.0
},
"minValues": {
"description": "Specifies the minimum number of values for this argument. For example, if you had a -f <file> argument where you wanted at least 2 'files', you would set `minValues: 2`, and this argument would be satisfied if the user provided, 2 or more values.",
"type": [
"integer",
"null"
],
"type": ["integer", "null"],
"format": "uint64",
"minimum": 0.0
},
"multiple": {
"description": "Specifies that the argument may appear more than once.\n\n- For flags, this results in the number of occurrences of the flag being recorded. For example -ddd or -d -d -d would count as three occurrences. - For options there is a distinct difference in multiple occurrences vs multiple values. For example, --opt val1 val2 is one occurrence, but two values. Whereas --opt val1 --opt val2 is two occurrences.",
"type": [
"boolean",
"null"
]
"type": ["boolean", "null"]
},
"multipleOccurrences": {
"description": "specifies that the argument may appear more than once.",
"type": [
"boolean",
"null"
]
"type": ["boolean", "null"]
},
"name": {
"description": "The unique argument name",
"type": "string"
},
"numberOfValues": {
"type": [
"integer",
"null"
],
"type": ["integer", "null"],
"format": "uint64",
"minimum": 0.0
},
"possibleValues": {
"description": "Specifies a list of possible values for this argument. At runtime, the CLI verifies that only one of the specified values was used, or fails with an error message.",
"type": [
"array",
"null"
],
"type": ["array", "null"],
"items": {
"type": "string"
}
},
"requireEquals": {
"description": "Requires that options use the --option=val syntax i.e. an equals between the option and associated value.",
"type": [
"boolean",
"null"
]
"type": ["boolean", "null"]
},
"required": {
"description": "Sets whether or not the argument is required by default.\n\n- Required by default means it is required, when no other conflicting rules have been evaluated - Conflicting rules take precedence over being required.",
"type": [
"boolean",
"null"
]
"type": ["boolean", "null"]
},
"requiredIfEq": {
"description": "Allows specifying that an argument is required conditionally with the signature [arg, value] the requirement will only become valid if the `arg`'s value equals `${value}`.",
"type": [
"array",
"null"
],
"type": ["array", "null"],
"items": {
"type": "string"
}
},
"requiredUnlessPresent": {
"description": "Sets an arg that override this arg's required setting i.e. this arg will be required unless this other argument is present.",
"type": [
"string",
"null"
]
"type": ["string", "null"]
},
"requiredUnlessPresentAll": {
"description": "Sets args that override this arg's required setting i.e. this arg will be required unless all these other arguments are present.",
"type": [
"array",
"null"
],
"type": ["array", "null"],
"items": {
"type": "string"
}
},
"requiredUnlessPresentAny": {
"description": "Sets args that override this arg's required setting i.e. this arg will be required unless at least one of these other arguments are present.",
"type": [
"array",
"null"
],
"type": ["array", "null"],
"items": {
"type": "string"
}
},
"requires": {
"description": "Tets an argument by name that is required when this one is present i.e. when using this argument, the following argument must be present.",
"type": [
"string",
"null"
]
"type": ["string", "null"]
},
"requiresAll": {
"description": "Sts multiple arguments by names that are required when this one is present i.e. when using this argument, the following arguments must be present.",
"type": [
"array",
"null"
],
"type": ["array", "null"],
"items": {
"type": "string"
}
},
"requiresIf": {
"description": "Allows a conditional requirement with the signature [arg, value] the requirement will only become valid if `arg`'s value equals `${value}`.",
"type": [
"array",
"null"
],
"type": ["array", "null"],
"items": {
"type": "string"
}
},
"short": {
"description": "The short version of the argument, without the preceding -.\n\nNOTE: Any leading - characters will be stripped, and only the first non - character will be used as the short version.",
"type": [
"string",
"null"
],
"type": ["string", "null"],
"maxLength": 1,
"minLength": 1
},
"takesValue": {
"description": "Specifies that the argument takes a value at run time.\n\nNOTE: values for arguments may be specified in any of the following methods - Using a space such as -o value or --option value - Using an equals and no space such as -o=value or --option=value - Use a short and no space such as -ovalue",
"type": [
"boolean",
"null"
]
"type": ["boolean", "null"]
}
},
"additionalProperties": false
@ -616,48 +512,30 @@
"properties": {
"afterHelp": {
"description": "adds additional help information to be displayed in addition to auto-generated help this information is displayed after the auto-generated help information this is often used to describe how to use the arguments, or caveats to be noted.",
"type": [
"string",
"null"
]
"type": ["string", "null"]
},
"args": {
"description": "list of args for the command",
"type": [
"array",
"null"
],
"type": ["array", "null"],
"items": {
"$ref": "#/definitions/CliArg"
}
},
"beforeHelp": {
"description": "adds additional help information to be displayed in addition to auto-generated help this information is displayed before the auto-generated help information. this is often used for header information",
"type": [
"string",
"null"
]
"type": ["string", "null"]
},
"description": {
"description": "command description which will be shown on the help information",
"type": [
"string",
"null"
]
"type": ["string", "null"]
},
"longDescription": {
"description": "command long description which will be shown on the help information",
"type": [
"string",
"null"
]
"type": ["string", "null"]
},
"subcommands": {
"description": "list of subcommands of this command.\n\nsubcommands are effectively sub-apps, because they can contain their own arguments, subcommands, usage, etc. they also function just like the app command, in that they get their own auto generated help and usage",
"type": [
"object",
"null"
],
"type": ["object", "null"],
"additionalProperties": {
"$ref": "#/definitions/CliConfig"
}
@ -669,10 +547,7 @@
"type": "object",
"properties": {
"depends": {
"type": [
"array",
"null"
],
"type": ["array", "null"],
"items": {
"type": "string"
}
@ -791,43 +666,25 @@
"type": "object",
"properties": {
"entitlements": {
"type": [
"string",
"null"
]
"type": ["string", "null"]
},
"exceptionDomain": {
"type": [
"string",
"null"
]
"type": ["string", "null"]
},
"frameworks": {
"type": [
"array",
"null"
],
"type": ["array", "null"],
"items": {
"type": "string"
}
},
"license": {
"type": [
"string",
"null"
]
"type": ["string", "null"]
},
"minimumSystemVersion": {
"type": [
"string",
"null"
]
"type": ["string", "null"]
},
"signingIdentity": {
"type": [
"string",
"null"
]
"type": ["string", "null"]
},
"useBootstrapper": {
"default": false,
@ -851,17 +708,11 @@
"properties": {
"productName": {
"description": "App name. Automatically converted to kebab-case on Linux.",
"type": [
"string",
"null"
]
"type": ["string", "null"]
},
"version": {
"description": "App version.",
"type": [
"string",
"null"
]
"type": ["string", "null"]
}
},
"additionalProperties": false
@ -870,10 +721,7 @@
"type": "object",
"properties": {
"csp": {
"type": [
"string",
"null"
]
"type": ["string", "null"]
}
},
"additionalProperties": false
@ -898,9 +746,7 @@
},
"SystemTrayConfig": {
"type": "object",
"required": [
"iconPath"
],
"required": ["iconPath"],
"properties": {
"iconPath": {
"description": "Path to the icon to use on the system tray.\n\nIt is forced to be a `.png` file on Linux and macOS, and a `.ico` file on Windows.",
@ -1051,27 +897,18 @@
"dialog": {
"description": "Display built-in dialog or use event system if disabled.",
"default": true,
"type": [
"boolean",
"null"
]
"type": ["boolean", "null"]
},
"endpoints": {
"description": "The updater endpoints.",
"type": [
"array",
"null"
],
"type": ["array", "null"],
"items": {
"type": "string"
}
},
"pubkey": {
"description": "Optional pubkey.",
"type": [
"string",
"null"
]
"type": ["string", "null"]
}
},
"additionalProperties": false
@ -1116,33 +953,21 @@
},
"height": {
"description": "The window height.",
"type": [
"number",
"null"
],
"type": ["number", "null"],
"format": "double"
},
"label": {
"description": "The window identifier.",
"type": [
"string",
"null"
]
"type": ["string", "null"]
},
"maxHeight": {
"description": "The max window height.",
"type": [
"number",
"null"
],
"type": ["number", "null"],
"format": "double"
},
"maxWidth": {
"description": "The max window width.",
"type": [
"number",
"null"
],
"type": ["number", "null"],
"format": "double"
},
"maximized": {
@ -1152,18 +977,12 @@
},
"minHeight": {
"description": "The min window height.",
"type": [
"number",
"null"
],
"type": ["number", "null"],
"format": "double"
},
"minWidth": {
"description": "The min window width.",
"type": [
"number",
"null"
],
"type": ["number", "null"],
"format": "double"
},
"resizable": {
@ -1173,10 +992,7 @@
},
"title": {
"description": "The window title.",
"type": [
"string",
"null"
]
"type": ["string", "null"]
},
"transparent": {
"description": "Whether the window is transparent or not.",
@ -1185,10 +1001,7 @@
},
"url": {
"description": "The window webview URL.",
"type": [
"string",
"null"
]
"type": ["string", "null"]
},
"visible": {
"description": "Whether the window is visible or not.",
@ -1197,26 +1010,17 @@
},
"width": {
"description": "The window width.",
"type": [
"number",
"null"
],
"type": ["number", "null"],
"format": "double"
},
"x": {
"description": "The horizontal position of the window's top left corner",
"type": [
"number",
"null"
],
"type": ["number", "null"],
"format": "double"
},
"y": {
"description": "The vertical position of the window's top left corner",
"type": [
"number",
"null"
],
"type": ["number", "null"],
"format": "double"
}
},
@ -1226,22 +1030,13 @@
"type": "object",
"properties": {
"certificateThumbprint": {
"type": [
"string",
"null"
]
"type": ["string", "null"]
},
"digestAlgorithm": {
"type": [
"string",
"null"
]
"type": ["string", "null"]
},
"timestampUrl": {
"type": [
"string",
"null"
]
"type": ["string", "null"]
},
"wix": {
"anyOf": [
@ -1301,10 +1096,7 @@
},
"license": {
"description": "Path to the license file.",
"type": [
"string",
"null"
]
"type": ["string", "null"]
},
"mergeRefs": {
"default": [],
@ -1318,13 +1110,10 @@
"type": "boolean"
},
"template": {
"type": [
"string",
"null"
]
"type": ["string", "null"]
}
},
"additionalProperties": false
}
}
}
}

View File

@ -27,8 +27,8 @@
"lint": "eslint --ext ts \"./src/**/*.ts\"",
"lint-fix": "eslint --fix --ext ts \"./src/**/*.ts\"",
"lint:lockfile": "lockfile-lint --path yarn.lock --type yarn --validate-https --allowed-hosts npm yarn",
"format": "prettier --write --end-of-line=auto \"./**/*.{js,jsx,ts,tsx,html,css,json}\" --ignore-path .gitignore",
"format:check": "prettier --check --end-of-line=auto \"./**/*.{js,jsx,ts,tsx,html,css,json}\" --ignore-path .gitignore",
"format": "prettier --write --end-of-line=auto \"./**/*.{cjs,js,jsx,ts,tsx,html,css,json}\" --ignore-path .gitignore",
"format:check": "prettier --check --end-of-line=auto \"./**/*.{cjs,js,jsx,ts,tsx,html,css,json}\" --ignore-path .gitignore",
"test": "jest --runInBand"
},
"dependencies": {