chore(api): remove type-fest (#4605)

This commit is contained in:
Lucas Fernandes Nogueira 2022-07-06 10:07:46 -03:00 committed by GitHub
parent fa028ebf3c
commit d5e910ebcc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 39 additions and 46 deletions

View File

@ -0,0 +1,5 @@
---
"api": patch
---
Remove the `type-fest` dependency, changing the OS types to the specific enum instead of allowing any string.

View File

@ -67,8 +67,5 @@
"typedoc": "0.23.5",
"typedoc-plugin-markdown": "3.13.3",
"typescript": "4.7.4"
},
"dependencies": {
"type-fest": "2.16.0"
}
}

View File

@ -23,10 +23,36 @@
* @module
*/
import { LiteralUnion } from 'type-fest'
import { isWindows } from './helpers/os-check'
import { invokeTauriCommand } from './helpers/tauri'
type Platform =
| 'linux'
| 'darwin'
| 'ios'
| 'freebsd'
| 'dragonfly'
| 'netbsd'
| 'openbsd'
| 'solaris'
| 'android'
| 'win32'
type OsType = 'Linux' | 'Darwin' | 'Windows_NT'
type Arch =
| 'x86'
| 'x86_64'
| 'arm'
| 'aarch64'
| 'mips'
| 'mips64'
| 'powerpc'
| 'powerpc64'
| 'riscv64'
| 's390x'
| 'sparc64'
/**
* The operating system-specific end-of-line marker.
* - `\n` on POSIX
@ -43,22 +69,8 @@ const EOL = isWindows() ? '\r\n' : '\n'
* const platformName = await platform();
* ```
*/
async function platform(): Promise<
LiteralUnion<
| 'linux'
| 'darwin'
| 'ios'
| 'freebsd'
| 'dragonfly'
| 'netbsd'
| 'openbsd'
| 'solaris'
| 'android'
| 'win32',
string
>
> {
return invokeTauriCommand<string>({
async function platform(): Promise<Platform> {
return invokeTauriCommand<Platform>({
__tauriModule: 'Os',
message: {
cmd: 'platform'
@ -91,10 +103,8 @@ async function version(): Promise<string> {
* const osType = await type();
* ```
*/
async function type(): Promise<
LiteralUnion<'Linux' | 'Darwin' | 'Windows_NT', string>
> {
return invokeTauriCommand<string>({
async function type(): Promise<OsType> {
return invokeTauriCommand<OsType>({
__tauriModule: 'Os',
message: {
cmd: 'osType'
@ -111,23 +121,8 @@ async function type(): Promise<
* const archName = await arch();
* ```
*/
async function arch(): Promise<
LiteralUnion<
| 'x86'
| 'x86_64'
| 'arm'
| 'aarch64'
| 'mips'
| 'mips64'
| 'powerpc'
| 'powerpc64'
| 'riscv64'
| 's390x'
| 'sparc64',
string
>
> {
return invokeTauriCommand<string>({
async function arch(): Promise<Arch> {
return invokeTauriCommand<Arch>({
__tauriModule: 'Os',
message: {
cmd: 'arch'
@ -153,3 +148,4 @@ async function tempdir(): Promise<string> {
}
export { EOL, platform, version, type, arch, tempdir }
export type { Platform, OsType, Arch }

View File

@ -3255,11 +3255,6 @@ type-check@^0.4.0, type-check@~0.4.0:
dependencies:
prelude-ls "^1.2.1"
type-fest@2.16.0:
version "2.16.0"
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-2.16.0.tgz#1250fbd64dafaf4c8e405e393ef3fb16d9651db2"
integrity sha512-qpaThT2HQkFb83gMOrdKVsfCN7LKxP26Yq+smPzY1FqoHRjqmjqHXA7n5Gkxi8efirtbeEUxzfEdePthQWCuHw==
type-fest@^0.20.2:
version "0.20.2"
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.20.2.tgz#1bf207f4b28f91583666cb5fbd327887301cd5f4"