Skip to content

Commit

Permalink
feat(icons): add and test icon generation for tauri (tauri-apps#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
nothingismagick authored Nov 17, 2019
1 parent 94ead18 commit 596f621
Show file tree
Hide file tree
Showing 19 changed files with 2,135 additions and 88 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,4 @@ package-lock.json


src-tauri
test/jest/tmp
64 changes: 32 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# tauri [WIP]
## A fresh take on creating cross-platform apps.
[![status](https://img.shields.io/badge/Status-Internal%20Review-yellow.svg)](https://github.com/quasarframework/quasar/tree/tauri)
[![version](https://img.shields.io/badge/Version-unreleased-yellow.svg)](https://github.com/tauri-apps/tauri/tree/dev) <img align="right" src="/tauri-logo.png" height="240" width="240">
[![version](https://img.shields.io/badge/Version-unreleased-yellow.svg)](https://github.com/tauri-apps/tauri/tree/dev) <img align="right" src="/app-icon.png" height="240" width="240">

[![Chat Server](https://img.shields.io/badge/chat-on%20discord-7289da.svg)](https://discord.gg/SpmNs4S)
[![devto](https://img.shields.io/badge/dev.to-blog-black.svg)](https://dev.to/tauri)
Expand All @@ -10,64 +10,64 @@
[![support](https://img.shields.io/badge/Sponsor-Opencollective-blue.svg)](https://opencollective.com/tauri)


**Tauri** is a tool for building tiny, blazing fast binaries for all
**Tauri** is a tool for building tiny, blazing fast binaries for all
major desktop platforms. It was incubated at Quasar Framework.

Whether you are just starting out making apps for your meetup or
regularly crunch terabyte datasets, we are absolutely confident that
Whether you are just starting out making apps for your meetup or
regularly crunch terabyte datasets, we are absolutely confident that
you will love using Tauri as much as we love making and maintaining it.

## Who Tauri is For
Because of the way Tauri has been built and can be extended, developers
are able to interface not only with the entire Rust ecosystem, but also
with many other programming languages. Being freed of the heaviest thing
in the universe and the many shortcomings of server-side Javascript
Because of the way Tauri has been built and can be extended, developers
are able to interface not only with the entire Rust ecosystem, but also
with many other programming languages. Being freed of the heaviest thing
in the universe and the many shortcomings of server-side Javascript
suddenly opens up whole new avenues for high-performance, security-focused
applications that need the purebred power, agility and community
applications that need the purebred power, agility and community
acceptance of a low-level language.

We expect to witness an entire new class of applications being built with
Tauri. From a simple calender to locally crunching massive realtime
We expect to witness an entire new class of applications being built with
Tauri. From a simple calender to locally crunching massive realtime
feeds at particle colliders or even mesh-network based distributed message-
passing ecosystems - the bar has been raised and gauntlet thrown.
passing ecosystems - the bar has been raised and gauntlet thrown.

What will you make?

## 5 Reasons to consider Tauri
- **BUNDLE SIZE** of a vanilla Tauri app is less than 3 MB - about 140 MB smaller than what you get with Electron.
- **MEMORY FOOTPRINT** is less than half of the size of an Electron app built from the same codebase.
- **SECURITY** is Tauri's biggest priority and we take it so seriously that we innovate to keep hackers out of your apps.
- **MEMORY FOOTPRINT** is less than half of the size of an Electron app built from the same codebase.
- **SECURITY** is Tauri's biggest priority and we take it so seriously that we innovate to keep hackers out of your apps.
- **RELIABILITY** of the underlying code base is why critical libraries have been forked and will be perpetually maintained.
- **FLOSS** licensing is regretfully impossible with downstream Chromium consumers, like Electron. Sources: [0](https://lists.gnu.org/archive/html/libreplanet-discuss/2017-01/msg00056.html) [1](https://lists.gnu.org/archive/html/directory-discuss/2017-12/msg00008.html) [2](https://lists.gnu.org/archive/html/libreplanet-discuss/2019-02/msg00001.html)

## Technical Details
The user interface in Tauri apps currently leverages Cocoa/WebKit on macOS,
gtk-webkit2 on Linux and MSHTML (IE10/11) or Webkit via Edge on Windows.
**Tauri** is based on the MIT licensed prior work known as
The user interface in Tauri apps currently leverages Cocoa/WebKit on macOS,
gtk-webkit2 on Linux and MSHTML (IE10/11) or Webkit via Edge on Windows.
**Tauri** is based on the MIT licensed prior work known as
[webview](https://github.com/zserge/webview).

The default binding to the underlying webview library currently uses Rust,
but other languages like Golang or Python (and many others) are possible
but other languages like Golang or Python (and many others) are possible
(and only a PR away).

> Rust is blazingly fast and memory-efficient: with no runtime or garbage
collector, it can power performance-critical services, run on embedded
> Rust is blazingly fast and memory-efficient: with no runtime or garbage
collector, it can power performance-critical services, run on embedded
devices, and easily integrate with other languages. Rust’s rich type system
and ownership model guarantee memory-safety and thread-safety — and enable
you to eliminate many classes of bugs at compile-time. Rust has great
you to eliminate many classes of bugs at compile-time. Rust has great
documentation, a friendly compiler with useful error messages, and top-notch
tooling — an integrated package manager and build tool, smart multi-editor
support with auto-completion and type inspections, an auto-formatter, and
support with auto-completion and type inspections, an auto-formatter, and
more. - [https://www.rust-lang.org/](https://www.rust-lang.org/)

This combination of power, safety and usability are why we chose Rust to be
the default binding for Tauri. It is our intention to provide the most safe
and performant native app experience (for devs and app consumers), out of
the box.
and performant native app experience (for devs and app consumers), out of
the box.

To this end, we have spent a great deal of time creating an especially secure
localhost-free backend for the security conscious application-artisans. This
means that your app does not use a localhost server, as is generally the case with
To this end, we have spent a great deal of time creating an especially secure
localhost-free backend for the security conscious application-artisans. This
means that your app does not use a localhost server, as is generally the case with
cordova apps. This also has the positive side effect, that less code is needed
and the final binaries are smaller.

Expand All @@ -93,12 +93,12 @@ you through the process. Here is a bit of a status report.
- [ ] Tray (coming soon)
- [x] Copy Buffer

#### API
#### API
- [ ] answer - enable rust to direct the UI
- [ ] bridge - enable Quasar Bridge
- [x] event - enable binding to message
- [x] execute - STDOUT Passthrough with Command Invocation
- [x] listFiles - list files in a directory
- [x] listFiles - list files in a directory
- [x] open - open link in a browser
- [x] readBinaryFile - read binary file from local filesystem
- [x] readTextFile - read text file from local filesystem
Expand Down Expand Up @@ -161,20 +161,20 @@ projects here in this repository, in order to guarantee the security of the
code and our ability to enhance it with features that may not be needed for
other consumers.

We hope that this code is useful, but make no claims to suitability or
We hope that this code is useful, but make no claims to suitability or
guarantees that it will work outside of the Quasar ecosystem.

This has been done with our best attempt at due diligence and in
respect of the original authors. Thankyou - this project would never have
been possible without your amazing contribution to open-source and we are
honoured to carry the torch further. Of special note:
- [zserge](https://github.com/zserge) for the original webview approach and
- [zserge](https://github.com/zserge) for the original webview approach and
go bindings
- [Boscop](https://github.com/Boscop) for the Rust Bindings
- [Burtonago](https://github.com/burtonageo) for the Cargo Bundle prototype

## Contributing
Please make sure to read the [Contributing Guide](./.github/CONTRIBUTING.md)
Please make sure to read the [Contributing Guide](./.github/CONTRIBUTING.md)
before making a pull request.

Thank you to all the people who already contributed to Tauri!
Expand Down
File renamed without changes
5 changes: 3 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = {
collectCoverage: true,
coverageDirectory: '<rootDir>/test/jest/coverage',
collectCoverageFrom: [
'<rootDir>/mode/**/*.js',
'<rootDir>/mode/**/*.js'
],
coverageReporters: ['json-summary', 'text', 'lcov'],
coverageThreshold: {
Expand All @@ -29,7 +29,8 @@ module.exports = {
moduleFileExtensions: ['js', 'json'],
moduleNameMapper: {
'^~/(.*)$': '<rootDir>/$1',
'^mode/(.*)$': '<rootDir>/mode/$1'
'^mode/(.*)$': '<rootDir>/mode/$1',
'^test/(.*)$': '<rootDir>/test/$1'
},
transform: {}
}
3 changes: 1 addition & 2 deletions mode/bin/tauri-dev.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const
parseArgs = require('minimist')
const parseArgs = require('minimist')

const argv = parseArgs(process.argv.slice(2), {
alias: {
Expand Down
61 changes: 61 additions & 0 deletions mode/bin/tauri-icon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
const parseArgs = require('minimist')
const { appDir, tauriDir } = require('../helpers/app-paths')
const logger = require('../helpers/logger')
const log = logger('app:tauri')
const warn = logger('app:tauri (icon)', 'red')
const { tauricon } = require('../helpers/tauricon')
const { resolve } = require('path')

/**
* @type {object}
* @property {boolean} h
* @property {boolean} help
* @property {string|boolean} f
* @property {string|boolean} force
* @property {boolean} l
* @property {boolean} log
* @property {boolean} c
* @property {boolean} config
* @property {boolean} s
* @property {boolean} source
* @property {boolean} t
* @property {boolean} target
*/
const argv = parseArgs(process.argv.slice(2), {
alias: {
h: 'help',
l: 'log',
c: 'config',
s: 'source',
t: 'target'
},
boolean: ['h', 'l']
})

if (argv.help) {
console.log(`
Description
Create all the icons you need for your Tauri app.
Usage
$ tauri icon
Options
--help, -h Displays this message
--log, l Logging [boolean]
--icon, i Source icon (png, 1240x1240 with transparency)
--target, t Target folder (default: 'src-tauri/icons')
--compression, c Compression type [pngquant|optipng|zopfli]
`)
process.exit(0)
}

tauricon.make(
argv.i || resolve(appDir, 'app-icon.png'),
argv.t || resolve(tauriDir, 'icons'),
argv.c || 'optipng'
).then(() => {
log('(tauricon) Completed')
}).catch(e => {
warn(e)
})
7 changes: 4 additions & 3 deletions mode/bin/tauri-init.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const
parseArgs = require('minimist')
const parseArgs = require('minimist')
const appPaths = require('../helpers/app-paths')
const logger = require('../helpers/logger')
const log = logger('app:tauri')
Expand All @@ -13,6 +12,8 @@ const warn = logger('app:tauri (init)', 'red')
* @property {string|boolean} force
* @property {boolean} l
* @property {boolean} log
* @property {boolean} d
* @property {boolean} directory
*/
const argv = parseArgs(process.argv.slice(2), {
alias: {
Expand Down Expand Up @@ -44,7 +45,7 @@ const { inject } = require('../template')

const target = appPaths.tauriDir

if (inject(target, 'all', argv.f, argv.l, argv.d)) {
if (inject(target, 'all', argv.f || null, argv.l || null, argv.d || null)) {
log('tauri init successful')
} else {
warn('tauri init unsuccessful')
Expand Down
12 changes: 10 additions & 2 deletions mode/bin/tauri.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
#!/usr/bin/env node

const cmds = ['init', 'dev', 'build', 'help']
const cmds = ['init', 'dev', 'build', 'help', 'icon']

const cmd = process.argv[2]

/**
* @description This is the bootstrapper that in turn calls subsequent
* Tauri Commands
*
* @param {string|array} command
*/
const tauri = function (command) {
if (typeof command === 'object') { // technically we just care about an array
command = command[0]
}
if (!command || command === '-h' || command === '--help' || command === 'help') {
console.log(`
Description
Expand Down
3 changes: 1 addition & 2 deletions mode/helpers/app-paths.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const
{ existsSync } = require('fs')
const { existsSync } = require('fs')
const { resolve, join, normalize, sep } = require('path')

/**
Expand Down
92 changes: 92 additions & 0 deletions mode/helpers/tauricon.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
exports.options = {
// folder determines in which path to drop the generated file
// prefix is the first part of the generated file's name
// infix adds e.g. '44x44' based on the size in sizes to the generated file's name
// suffix adds a file-ending to the generated file's name
// sizes determines the pixel width and height to use
background_color: '#000074',
theme_color: '#02aa9b',
sharp: 'kernel: sharp.kernel.lanczos3', // one of [nearest|cubic|lanczos2|lanczos3]
minify: {
batch: false,
overwrite: true,
available: ['pngquant', 'optipng', 'zopfli'],
type: 'pngquant',
pngcrushOptions: {
reduce: true
},
pngquantOptions: {
quality: [0.6, 0.8],
floyd: 0.1, // 0.1 - 1
speed: 10 // 1 - 10
},
optipngOptions: {
optimizationLevel: 4,
bitDepthReduction: true,
colorTypeReduction: true,
paletteReduction: true
},
zopfliOptions: {
transparent: true,
more: true
}
},
splash_type: 'generate',
tauri: {
linux: {
folder: '.',
prefix: '',
infix: true,
suffix: '.png',
sizes: [
32, 128
]
},
linux_2x: {
folder: '.',
prefix: '128x128@2x',
infix: false,
suffix: '.png',
sizes: [
256
]
},
defaults: {
folder: '.',
prefix: 'icon',
infix: false,
suffix: '.png',
sizes: [
512
]
},
appx_logo: {
folder: '.',
prefix: 'StoreLogo',
infix: false,
suffix: '.png',
sizes: [
50
]
},
appx_square: {
folder: '.',
prefix: 'Square',
infix: true,
suffix: 'Logo.png',
sizes: [
30,
44,
71,
89,
107,
142,
150,
284,
310
]
}
// todo: look at capacitor and cordova for insight into what icons
// we need for those distribution targets
}
}
Loading

0 comments on commit 596f621

Please sign in to comment.