Add tauri extension

This commit is contained in:
2024-10-04 18:49:13 -03:00
parent 10cd001665
commit e04fa03af8
3 changed files with 41 additions and 50 deletions

View File

@ -15,8 +15,11 @@
"clean": "rimraf build",
"build": "npm run clean && tsc && node scripts/esbuild.js"
},
"dependencies": {},
"peerDependencies": {
"@tauri-apps/plugin-http": "^2.0.0"
},
"devDependencies": {
"@tauri-apps/plugin-http": "^2.0.0",
"@types/node": "^20.10.6",
"dotenv": "^16.3.1",
"esbuild-node-externals": "^1.12.0",

62
pnpm-lock.yaml generated
View File

@ -4,27 +4,13 @@ settings:
autoInstallPeers: true
excludeLinksFromLockfile: false
dependencies:
json-bigint:
specifier: ^1.0.0
version: 1.0.0
devDependencies:
'@types/json-bigint':
specifier: ^1.0.4
version: 1.0.4
'@types/jsonwebtoken':
specifier: ^9.0.5
version: 9.0.7
'@tauri-apps/plugin-http':
specifier: ^2.0.0
version: 2.0.0
'@types/node':
specifier: ^20.10.6
version: 20.10.6
'@types/uuid':
specifier: ^9.0.7
version: 9.0.8
cross-env:
specifier: ^7.0.3
version: 7.0.3
dotenv:
specifier: ^16.3.1
version: 16.3.1
@ -371,34 +357,30 @@ packages:
dev: true
optional: true
/@types/estree@1.0.6:
resolution: {integrity: sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==}
/@tauri-apps/api@2.0.1:
resolution: {integrity: sha512-eoQWT+Tq1qSwQpHV+nw1eNYe5B/nm1PoRjQCRiEOS12I1b+X4PUcREfXVX8dPcBT6GrzWGDtaecY0+1p0Rfqlw==}
dev: true
/@types/json-bigint@1.0.4:
resolution: {integrity: sha512-ydHooXLbOmxBbubnA7Eh+RpBzuaIiQjh8WGJYQB50JFGFrdxW7JzVlyEV7fAXw0T2sqJ1ysTneJbiyNLqZRAag==}
/@tauri-apps/plugin-http@2.0.0:
resolution: {integrity: sha512-UfKAICL25ayluV/SjiEQujz8q/2uyAzp3u9uaHFkaIyKS5usBL8DoqSwi4eKz2mEjkbxTwldhDEXG4CEfTE0JQ==}
dependencies:
'@tauri-apps/api': 2.0.1
dev: true
/@types/estree@1.0.6:
resolution: {integrity: sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==}
dev: true
/@types/json-schema@7.0.15:
resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==}
dev: true
/@types/jsonwebtoken@9.0.7:
resolution: {integrity: sha512-ugo316mmTYBl2g81zDFnZ7cfxlut3o+/EQdaP7J8QN2kY6lJ22hmQYCK5EHcJHbrW+dkCGSCPgbG8JtYj6qSrg==}
dependencies:
'@types/node': 20.10.6
dev: true
/@types/node@20.10.6:
resolution: {integrity: sha512-Vac8H+NlRNNlAmDfGUP7b5h/KA+AtWIzuXy0E6OyP8f1tCLYAtPvKRRDJjAPqhpCb0t6U2j7/xqAuLEebW2kiw==}
dependencies:
undici-types: 5.26.5
dev: true
/@types/uuid@9.0.8:
resolution: {integrity: sha512-jg+97EGIcY9AGHJJRaaPVgetKDsrTgbRjQ5Msgjh/DQKEFl0DtyRr/VCOyD1T2R1MNeWPK/u7JoGhlDZnKBAfA==}
dev: true
/acorn-jsx@5.3.2(acorn@8.12.1):
resolution: {integrity: sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==}
peerDependencies:
@ -452,10 +434,6 @@ packages:
resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==}
dev: true
/bignumber.js@9.1.2:
resolution: {integrity: sha512-2/mKyZH9K85bzOEfhXDBFZTGd1CTs+5IHpeFQo9luiBG7hghdC851Pj2WAhb6E3R6b9tZj/XKhbg4fum+Kepug==}
dev: false
/brace-expansion@1.1.11:
resolution: {integrity: sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==}
dependencies:
@ -497,14 +475,6 @@ packages:
resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==}
dev: true
/cross-env@7.0.3:
resolution: {integrity: sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==}
engines: {node: '>=10.14', npm: '>=6', yarn: '>=1'}
hasBin: true
dependencies:
cross-spawn: 7.0.3
dev: true
/cross-spawn@7.0.3:
resolution: {integrity: sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==}
engines: {node: '>= 8'}
@ -838,12 +808,6 @@ packages:
argparse: 2.0.1
dev: true
/json-bigint@1.0.0:
resolution: {integrity: sha512-SiPv/8VpZuWbvLSMtTDU8hEfrZWg/mH/nV/b4o0CYbSxu1UIQPLdwKOCIyLQX+VIPO5vrLX3i8qtqFyhdPSUSQ==}
dependencies:
bignumber.js: 9.1.2
dev: false
/json-buffer@3.0.1:
resolution: {integrity: sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==}
dev: true

24
src/tauri/api.ts Normal file
View File

@ -0,0 +1,24 @@
// Copyright (c) Tribufu. All Rights Reserved.
// SPDX-License-Identifier: MIT
import { TribufuApi } from "../api";
import { TribufuApiOptions } from "../options";
let fetchFn: typeof fetch | undefined;
if (window && (window as any).__TAURI__) {
fetchFn = (await import("@tauri-apps/plugin-http")).fetch;
}
export type TribufuTauriApiOptions = Omit<TribufuApiOptions, "fetch">;
/**
* **Tribufu Tauri API**
*
* Use this class to interact with the Tribufu API in a Tauri application.
*/
export class TribufuTauriApi extends TribufuApi {
constructor(options?: TribufuTauriApiOptions | null) {
super({ ...options, fetch: fetchFn });
}
}