chore: add prettierignore and fmt the repo (#5192)

Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
This commit is contained in:
Amr Bashir 2022-09-18 14:16:35 +02:00 committed by GitHub
parent ecb489a77c
commit 1d7171a1ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 255 additions and 243 deletions

11
.prettierignore Normal file
View File

@ -0,0 +1,11 @@
/.github
/.husky
/.vscode
/audits
node_modules
target
dist
/core/tauri/scripts
/tooling/cli/templates
/tooling/cli/node
/tooling/cli/schema.json

View File

@ -1,5 +1,5 @@
#!/usr/bin/env node
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
@ -10,26 +10,26 @@ 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 packageNickname = process.argv[2]
const filePath = packageNickname === 'cli.js' ? `../../../tooling/cli/metadata.json` : `../../tooling/cli/metadata.json`
const filePath =
packageNickname === 'cli.js'
? `../../../tooling/cli/metadata.json`
: `../../tooling/cli/metadata.json`
const bump = process.argv[3]
let index = null
switch (bump) {
case 'major':
index = 0;
break;
index = 0
break
case 'minor':
index = 1;
break;
index = 1
break
case 'patch':
index = 2;
break;
index = 2
break
default:
throw new Error('unexpected bump ' + bump)
}

View File

@ -30,9 +30,7 @@
"active": true,
"dialog": false,
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDE5QzMxNjYwNTM5OEUwNTgKUldSWTRKaFRZQmJER1h4d1ZMYVA3dnluSjdpN2RmMldJR09hUFFlZDY0SlFqckkvRUJhZDJVZXAK",
"endpoints": [
"http://localhost:3007"
],
"endpoints": ["http://localhost:3007"],
"windows": {
"installMode": "quiet"
}

View File

@ -1,10 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Isolation Secure Script</title>
</head>
<body>
<script src="index.js"></script>
</body>
<head>
<meta charset="UTF-8" />
<title>Isolation Secure Script</title>
</head>
<body>
<script src="index.js"></script>
</body>
</html>

View File

@ -1,4 +1,4 @@
window.__TAURI_ISOLATION_HOOK__= (payload) => {
window.__TAURI_ISOLATION_HOOK__ = (payload) => {
console.log('hook', payload)
return payload
}

View File

@ -1,84 +1,84 @@
<!DOCTYPE html>
<html>
<head>
<style>
#response {
white-space: pre-wrap;
}
</style>
</head>
<body>
<div id="window-label"></div>
<div id="container"></div>
<div id="response"></div>
<script>
var WebviewWindow = window.__TAURI__.window.WebviewWindow
var appWindow = window.__TAURI__.window.appWindow
var windowLabel = appWindow.label
var windowLabelContainer = document.getElementById('window-label')
windowLabelContainer.innerText = 'This is the ' + windowLabel + ' window.'
var container = document.getElementById('container')
function createWindowMessageBtn(label) {
var tauriWindow = WebviewWindow.getByLabel(label)
var button = document.createElement('button')
button.innerText = '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\n\n'
})
window.__TAURI__.event.listen('tauri://window-created', function (event) {
createWindowMessageBtn(event.payload.label)
})
var responseContainer = document.getElementById('response')
// listener tied to this window
appWindow.listen('clicked', function (event) {
responseContainer.innerText +=
'Got ' + JSON.stringify(event) + ' on window listener\n\n'
})
var createWindowButton = document.createElement('button')
createWindowButton.innerHTML = 'Create window'
createWindowButton.addEventListener('click', function () {
var webviewWindow = new WebviewWindow(Math.random().toString().replace('.', ''))
webviewWindow.once('tauri://created', function () {
responseContainer.innerHTML += 'Created new webview'
})
webviewWindow.once('tauri://error', function (e) {
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
<head>
<style>
#response {
white-space: pre-wrap;
}
createWindowMessageBtn(label)
}
</script>
</body>
</style>
</head>
</html>
<body>
<div id="window-label"></div>
<div id="container"></div>
<div id="response"></div>
<script>
var WebviewWindow = window.__TAURI__.window.WebviewWindow
var appWindow = window.__TAURI__.window.appWindow
var windowLabel = appWindow.label
var windowLabelContainer = document.getElementById('window-label')
windowLabelContainer.innerText = 'This is the ' + windowLabel + ' window.'
var container = document.getElementById('container')
function createWindowMessageBtn(label) {
var tauriWindow = WebviewWindow.getByLabel(label)
var button = document.createElement('button')
button.innerText = '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\n\n'
})
window.__TAURI__.event.listen('tauri://window-created', function (event) {
createWindowMessageBtn(event.payload.label)
})
var responseContainer = document.getElementById('response')
// listener tied to this window
appWindow.listen('clicked', function (event) {
responseContainer.innerText +=
'Got ' + JSON.stringify(event) + ' on window listener\n\n'
})
var createWindowButton = document.createElement('button')
createWindowButton.innerHTML = 'Create window'
createWindowButton.addEventListener('click', function () {
var webviewWindow = new WebviewWindow(
Math.random().toString().replace('.', '')
)
webviewWindow.once('tauri://created', function () {
responseContainer.innerHTML += 'Created new webview'
})
webviewWindow.once('tauri://error', function (e) {
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

@ -1,21 +1,19 @@
<!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>Back</button>
<script>
const button = document.querySelector('button')
button.addEventListener('click', () => window.history.back())
</script>
<script src="secondary.js"></script>
</body>
<body>
<h1></h1>
<button>Back</button>
<script>
const button = document.querySelector('button')
button.addEventListener('click', () => window.history.back())
</script>
<script src="secondary.js"></script>
</body>
</html>

View File

@ -1,54 +1,54 @@
<!DOCTYPE html>
<html>
<head>
<style>
#response {
white-space: pre-wrap;
}
</style>
</head>
<head>
<style>
#response {
white-space: pre-wrap;
}
</style>
</head>
<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.innerText = '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.innerText = 'This is the ' + windowLabel + ' window.'
var container = document.getElementById('container')
var container = document.getElementById('container')
var responseContainer = document.getElementById('response')
function runCommand(commandName, args, optional) {
window.__TAURI__
.invoke(commandName, args)
.then((response) => {
responseContainer.innerText += `Ok(${response})\n\n`
})
.catch((error) => {
responseContainer.innerText += `Err(${error})\n\n`
})
}
window.__TAURI__.event.listen('tauri://window-created', function (event) {
responseContainer.innerText += 'Got window-created event\n\n'
})
var responseContainer = document.getElementById('response')
function runCommand(commandName, args, optional) {
window.__TAURI__
.invoke(commandName, args)
.then((response) => {
responseContainer.innerText += `Ok(${response})\n\n`
})
.catch((error) => {
responseContainer.innerText += `Err(${error})\n\n`
})
}
window.__TAURI__.event.listen('tauri://window-created', function (event) {
responseContainer.innerText += 'Got window-created event\n\n'
})
var createWindowButton = document.createElement('button')
var windowId = Math.random().toString().replace('.', '')
var windowNumber = 1
createWindowButton.innerHTML = 'Create child window ' + windowNumber
createWindowButton.addEventListener('click', function () {
runCommand('create_child_window', { id: `child-${windowId}-${windowNumber}` })
windowNumber += 1
var createWindowButton = document.createElement('button')
var windowId = Math.random().toString().replace('.', '')
var windowNumber = 1
createWindowButton.innerHTML = 'Create child window ' + windowNumber
})
container.appendChild(createWindowButton)
</script>
</body>
</html>
createWindowButton.addEventListener('click', function () {
runCommand('create_child_window', {
id: `child-${windowId}-${windowNumber}`
})
windowNumber += 1
createWindowButton.innerHTML = 'Create child window ' + windowNumber
})
container.appendChild(createWindowButton)
</script>
</body>
</html>

View File

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

View File

@ -1,49 +1,56 @@
<!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>
<style>
.container {
display: flex;
}
.container > div {
flex: 1;
}
</style>
</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>
<style>
.container {
display: flex;
}
.container > div {
flex: 1;
}
</style>
</head>
<body>
<div class="container">
<div id="backend"></div>
<div id="frontend"></div>
</div>
<script>
function addMessage(div, message) {
const p = document.createElement('p')
p.innerText = message
div.appendChild(p)
}
<body>
<div class="container">
<div id="backend"></div>
<div id="frontend"></div>
</div>
<script>
function addMessage(div, message) {
const p = document.createElement('p')
p.innerText = message
div.appendChild(p)
}
const backendDiv = document.getElementById('backend')
window.__TAURI__.event.listen('message', (event) => {
addMessage(backendDiv, event.payload)
})
const frontendDiv = document.getElementById('frontend')
const { Command } = window.__TAURI__.shell
const command = Command.sidecar('binaries/app')
command.on('close', data => {
addMessage(frontendDiv, `command finished with code ${data.code} and signal ${data.signal}`)
})
command.on('error', error => addMessage(frontendDiv, `command error: "${error}"`))
command.stdout.on('data', line => addMessage(frontendDiv, `command stdout: "${line}"`))
command.stderr.on('data', line => addMessage(frontendDiv, `command stderr: "${line}"`))
command.spawn()
</script>
</body>
const backendDiv = document.getElementById('backend')
window.__TAURI__.event.listen('message', (event) => {
addMessage(backendDiv, event.payload)
})
const frontendDiv = document.getElementById('frontend')
const { Command } = window.__TAURI__.shell
const command = Command.sidecar('binaries/app')
command.on('close', (data) => {
addMessage(
frontendDiv,
`command finished with code ${data.code} and signal ${data.signal}`
)
})
command.on('error', (error) =>
addMessage(frontendDiv, `command error: "${error}"`)
)
command.stdout.on('data', (line) =>
addMessage(frontendDiv, `command stdout: "${line}"`)
)
command.stderr.on('data', (line) =>
addMessage(frontendDiv, `command stderr: "${line}"`)
)
command.spawn()
</script>
</body>
</html>

View File

@ -15,4 +15,4 @@
"execa": "5.1.1",
"pkg": "5.2.1"
}
}
}

View File

@ -1,31 +1,29 @@
<!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" />
<style>
video {
width: 100vw;
height: 100vh;
}
</style>
</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" />
<style>
video {
width: 100vw;
height: 100vh;
}
</style>
</head>
<body>
<video id="video_source" controls="" autoplay="" name="media">
<source type="video/mp4" />
</video>
<script>
const { convertFileSrc } = window.__TAURI__.tauri
const video = document.getElementById('video_source')
const source = document.createElement('source')
source.type = 'video/mp4'
source.src = convertFileSrc('example/test_video.mp4', 'stream')
video.appendChild(source)
video.load()
</script>
</body>
</html>
<body>
<video id="video_source" controls="" autoplay="" name="media">
<source type="video/mp4" />
</video>
<script>
const { convertFileSrc } = window.__TAURI__.tauri
const video = document.getElementById('video_source')
const source = document.createElement('source')
source.type = 'video/mp4'
source.src = convertFileSrc('example/test_video.mp4', 'stream')
video.appendChild(source)
video.load()
</script>
</body>
</html>

View File

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

View File

@ -11,7 +11,7 @@
"url": "https://github.com/tauri-apps/tauri.git"
},
"scripts": {
"format": "prettier --write --end-of-line=auto \"./**/*.{cjs,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 .prettierignore",
"postinstall": "husky install"
},
"devDependencies": {

View File

@ -16,8 +16,8 @@
"npm-publish": "yarn build && cd ./dist && yarn publish --access public --loglevel silly",
"lint": "eslint --ext ts \"./src/**/*.ts\"",
"lint-fix": "eslint --fix --ext ts \"./src/**/*.ts\"",
"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",
"format": "prettier --write --end-of-line=auto \"./**/*.{cjs,js,jsx,ts,tsx,html,css,json}\" --ignore-path ../../.prettierignore",
"format:check": "prettier --check --end-of-line=auto \"./**/*.{cjs,js,jsx,ts,tsx,html,css,json}\" --ignore-path ../../.prettierignore",
"generate-docs": "typedoc"
},
"repository": {