diff --git a/.github/workflows/sync.yml b/.github/workflows/sync.yml index aeb76eb0..6464f883 100644 --- a/.github/workflows/sync.yml +++ b/.github/workflows/sync.yml @@ -19,4 +19,4 @@ jobs: run: .github/sync-to-mirrors.sh env: BUILD_BASE: ./plugins - API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }} \ No newline at end of file + API_TOKEN_GITHUB: ${{ secrets.ORG_TAURI_BOT_PAT }} diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 95ee6b2e..00000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "rust-analyzer.cargo.features": ["sqlite"] -} diff --git a/plugins/authenticator/guest-js/dist/index.d.ts b/plugins/authenticator/guest-js/dist/index.d.ts new file mode 100644 index 00000000..15a751bf --- /dev/null +++ b/plugins/authenticator/guest-js/dist/index.d.ts @@ -0,0 +1,7 @@ +export declare class Authenticator { + init(): Promise; + register(challenge: string, application: string): Promise; + verifyRegistration(challenge: string, application: string, registerData: string, clientData: string): Promise; + sign(challenge: string, application: string, keyHandle: string): Promise; + verifySignature(challenge: string, application: string, signData: string, clientData: string, keyHandle: string, pubkey: string): Promise; +} diff --git a/plugins/autostart/guest-js/dist/index.d.ts b/plugins/autostart/guest-js/dist/index.d.ts new file mode 100644 index 00000000..992c1846 --- /dev/null +++ b/plugins/autostart/guest-js/dist/index.d.ts @@ -0,0 +1,3 @@ +export declare function isEnabled(): Promise; +export declare function enable(): Promise; +export declare function disable(): Promise; diff --git a/plugins/fs-extra/guest-js/dist/index.d.ts b/plugins/fs-extra/guest-js/dist/index.d.ts new file mode 100644 index 00000000..1b835801 --- /dev/null +++ b/plugins/fs-extra/guest-js/dist/index.d.ts @@ -0,0 +1,87 @@ +export interface Permissions { + /** + * `true` if these permissions describe a readonly (unwritable) file. + */ + readonly: boolean; + /** + * The underlying raw `st_mode` bits that contain the standard Unix permissions for this file. + */ + mode: number | undefined; +} +/** + * Metadata information about a file. + * This structure is returned from the `metadata` function or method + * and represents known metadata about a file such as its permissions, size, modification times, etc. + */ +export interface Metadata { + /** + * The last access time of this metadata. + */ + accessedAt: Date; + /** + * The creation time listed in this metadata. + */ + createdAt: Date; + /** + * The last modification time listed in this metadata. + */ + modifiedAt: Date; + /** + * `true` if this metadata is for a directory. + */ + isDir: boolean; + /** + * `true` if this metadata is for a regular file. + */ + isFile: boolean; + /** + * `true` if this metadata is for a symbolic link. + */ + isSymlink: boolean; + /** + * The size of the file, in bytes, this metadata is for. + */ + size: number; + /** + * The permissions of the file this metadata is for. + */ + permissions: Permissions; + /** + * The ID of the device containing the file. Only available on Unix. + */ + dev: number | undefined; + /** + * The inode number. Only available on Unix. + */ + ino: number | undefined; + /** + * The rights applied to this file. Only available on Unix. + */ + mode: number | undefined; + /** + * The number of hard links pointing to this file. Only available on Unix. + */ + nlink: number | undefined; + /** + * The user ID of the owner of this file. Only available on Unix. + */ + uid: number | undefined; + /** + * The group ID of the owner of this file. Only available on Unix. + */ + gid: number | undefined; + /** + * The device ID of this file (if it is a special one). Only available on Unix. + */ + rdev: number | undefined; + /** + * The block size for filesystem I/O. Only available on Unix. + */ + blksize: number | undefined; + /** + * The number of blocks allocated to the file, in 512-byte units. Only available on Unix. + */ + blocks: number | undefined; +} +export declare function metadata(path: string): Promise; +export declare function exists(path: string): Promise; diff --git a/plugins/fs-watch/guest-js/dist/index.d.ts b/plugins/fs-watch/guest-js/dist/index.d.ts new file mode 100644 index 00000000..a9219d0d --- /dev/null +++ b/plugins/fs-watch/guest-js/dist/index.d.ts @@ -0,0 +1,45 @@ +import { UnlistenFn } from "@tauri-apps/api/event"; +export interface WatchOptions { + recursive?: boolean; +} +export interface DebouncedWatchOptions extends WatchOptions { + delayMs?: number; +} +export interface RawEvent { + path: string | null; + operation: number; + cookie: number | null; +} +export type DebouncedEvent = { + type: "NoticeWrite"; + payload: string; +} | { + type: "NoticeRemove"; + payload: string; +} | { + type: "Create"; + payload: string; +} | { + type: "Write"; + payload: string; +} | { + type: "Chmod"; + payload: string; +} | { + type: "Remove"; + payload: string; +} | { + type: "Rename"; + payload: string; +} | { + type: "Rescan"; + payload: null; +} | { + type: "Error"; + payload: { + error: string; + path: string | null; + }; +}; +export declare function watch(paths: string | string[], options: DebouncedWatchOptions, cb: (event: DebouncedEvent) => void): Promise; +export declare function watchImmediate(paths: string | string[], options: WatchOptions, cb: (event: RawEvent) => void): Promise; diff --git a/plugins/log/guest-js/dist/index.d.ts b/plugins/log/guest-js/dist/index.d.ts new file mode 100644 index 00000000..f74f4588 --- /dev/null +++ b/plugins/log/guest-js/dist/index.d.ts @@ -0,0 +1,87 @@ +import { UnlistenFn } from "@tauri-apps/api/event"; +export type LogOptions = { + file?: string; + line?: number; +} & Record; +/** + * Logs a message at the error level. + * + * @param message + * + * # Examples + * + * ```js + * import { error } from 'tauri-plugin-log-api'; + * + * const err_info = "No connection"; + * const port = 22; + * + * error(`Error: ${err_info} on port ${port}`); + * ``` + */ +export declare function error(message: string, options?: LogOptions): Promise; +/** + * Logs a message at the warn level. + * + * @param message + * + * # Examples + * + * ```js + * import { warn } from 'tauri-plugin-log-api'; + * + * const warn_description = "Invalid Input"; + * + * warn(`Warning! {warn_description}!`); + * ``` + */ +export declare function warn(message: string, options?: LogOptions): Promise; +/** + * Logs a message at the info level. + * + * @param message + * + * # Examples + * + * ```js + * import { info } from 'tauri-plugin-log-api'; + * + * const conn_info = { port: 40, speed: 3.20 }; + * + * info(`Connected to port {conn_info.port} at {conn_info.speed} Mb/s`); + * ``` + */ +export declare function info(message: string, options?: LogOptions): Promise; +/** + * Logs a message at the debug level. + * + * @param message + * + * # Examples + * + * ```js + * import { debug } from 'tauri-plugin-log-api'; + * + * const pos = { x: 3.234, y: -1.223 }; + * + * debug(`New position: x: {pos.x}, y: {pos.y}`); + * ``` + */ +export declare function debug(message: string, options?: LogOptions): Promise; +/** + * Logs a message at the trace level. + * + * @param message + * + * # Examples + * + * ```js + * import { trace } from 'tauri-plugin-log-api'; + * + * let pos = { x: 3.234, y: -1.223 }; + * + * trace(`Position is: x: {pos.x}, y: {pos.y}`); + * ``` + */ +export declare function trace(message: string, options?: LogOptions): Promise; +export declare function attachConsole(): Promise; diff --git a/plugins/positioner/guest-js/dist/index.d.ts b/plugins/positioner/guest-js/dist/index.d.ts new file mode 100644 index 00000000..c03d4d05 --- /dev/null +++ b/plugins/positioner/guest-js/dist/index.d.ts @@ -0,0 +1,27 @@ +/** + * Well known window positions. + */ +export declare enum Position { + TopLeft = 0, + TopRight = 1, + BottomLeft = 2, + BottomRight = 3, + TopCenter = 4, + BottomCenter = 5, + LeftCenter = 6, + RightCenter = 7, + Center = 8, + TrayLeft = 9, + TrayBottomLeft = 10, + TrayRight = 11, + TrayBottomRight = 12, + TrayCenter = 13, + TrayBottomCenter = 14 +} +/** + * Moves the `Window` to the given {@link Position} using `WindowExt.move_window()` + * All positions are relative to the **current** screen. + * + * @param to The {@link Position} to move to. + */ +export declare function moveWindow(to: Position): Promise; diff --git a/plugins/sql/guest-js/dist/index.d.ts b/plugins/sql/guest-js/dist/index.d.ts new file mode 100644 index 00000000..6b38ccb3 --- /dev/null +++ b/plugins/sql/guest-js/dist/index.d.ts @@ -0,0 +1,95 @@ +export interface QueryResult { + /** The number of rows affected by the query. */ + rowsAffected: number; + /** + * The last inserted `id`. + * + * This value is always `0` when using the Postgres driver. If the + * last inserted id is required on Postgres, the `select` function + * must be used, with a `RETURNING` clause + * (`INSERT INTO todos (title) VALUES ($1) RETURNING id`). + */ + lastInsertId: number; +} +/** + * **Database** + * + * The `Database` class serves as the primary interface for + * communicating with the rust side of the sql plugin. + */ +export default class Database { + path: string; + constructor(path: string); + /** + * **load** + * + * A static initializer which connects to the underlying database and + * returns a `Database` instance once a connection to the database is established. + * + * # Sqlite + * + * The path is relative to `tauri::api::path::BaseDirectory::App` and must start with `sqlite:`. + * + * @example + * ```ts + * const db = await Database.load("sqlite:test.db"); + * ``` + */ + static load(path: string): Promise; + /** + * **get** + * + * A static initializer which synchronously returns an instance of + * the Database class while deferring the actual database connection + * until the first invocation or selection on the database. + * + * # Sqlite + * + * The path is relative to `tauri::api::path::BaseDirectory::App` and must start with `sqlite:`. + * + * @example + * ```ts + * const db = Database.get("sqlite:test.db"); + * ``` + */ + static get(path: string): Database; + /** + * **execute** + * + * Passes a SQL expression to the database for execution. + * + * @example + * ```ts + * const result = await db.execute( + * "UPDATE todos SET title = $1, completed = $2 WHERE id = $3", + * [ todos.title, todos.status, todos.id ] + * ); + * ``` + */ + execute(query: string, bindValues?: unknown[]): Promise; + /** + * **select** + * + * Passes in a SELECT query to the database for execution. + * + * @example + * ```ts + * const result = await db.select( + * "SELECT * from todos WHERE id = $1", id + * ); + * ``` + */ + select(query: string, bindValues?: unknown[]): Promise; + /** + * **close** + * + * Closes the database connection pool. + * + * @example + * ```ts + * const success = await db.close() + * ``` + * @param db - Optionally state the name of a database if you are managing more than one. Otherwise, all database pools will be in scope. + */ + close(db?: string): Promise; +} diff --git a/plugins/store/guest-js/dist/index.d.ts b/plugins/store/guest-js/dist/index.d.ts new file mode 100644 index 00000000..80961098 --- /dev/null +++ b/plugins/store/guest-js/dist/index.d.ts @@ -0,0 +1,105 @@ +import { UnlistenFn } from "@tauri-apps/api/event"; +/** + * A key-value store persisted by the backend layer. + */ +export declare class Store { + path: string; + constructor(path: string); + /** + * Inserts a key-value pair into the store. + * + * @param key + * @param value + * @returns + */ + set(key: string, value: unknown): Promise; + /** + * Returns the value for the given `key` or `null` the key does not exist. + * + * @param key + * @returns + */ + get(key: string): Promise; + /** + * Returns `true` if the given `key` exists in the store. + * + * @param key + * @returns + */ + has(key: string): Promise; + /** + * Removes a key-value pair from the store. + * + * @param key + * @returns + */ + delete(key: string): Promise; + /** + * Clears the store, removing all key-value pairs. + * + * Note: To clear the storage and reset it to it's `default` value, use `reset` instead. + * @returns + */ + clear(): Promise; + /** + * Resets the store to it's `default` value. + * + * If no default value has been set, this method behaves identical to `clear`. + * @returns + */ + reset(): Promise; + /** + * Returns a list of all key in the store. + * + * @returns + */ + keys(): Promise; + /** + * Returns a list of all values in the store. + * + * @returns + */ + values(): Promise; + /** + * Returns a list of all entries in the store. + * + * @returns + */ + entries(): Promise>; + /** + * Returns the number of key-value pairs in the store. + * + * @returns + */ + length(): Promise; + /** + * Attempts to load the on-disk state at the stores `path` into memory. + * + * This method is useful if the on-disk state was edited by the user and you want to synchronize the changes. + * + * Note: This method does not emit change events. + * @returns + */ + load(): Promise; + /** + * Saves the store to disk at the stores `path`. + * + * As the store is only persistet to disk before the apps exit, changes might be lost in a crash. + * This method let's you persist the store to disk whenever you deem necessary. + * @returns + */ + save(): Promise; + /** + * Listen to changes on a store key. + * @param key + * @param cb + * @returns A promise resolving to a function to unlisten to the event. + */ + onKeyChange(key: string, cb: (value: T | null) => void): Promise; + /** + * Listen to changes on the store. + * @param cb + * @returns A promise resolving to a function to unlisten to the event. + */ + onChange(cb: (key: string, value: unknown) => void): Promise; +} diff --git a/plugins/stronghold/guest-js/dist/index.d.ts b/plugins/stronghold/guest-js/dist/index.d.ts new file mode 100644 index 00000000..f7c279c9 --- /dev/null +++ b/plugins/stronghold/guest-js/dist/index.d.ts @@ -0,0 +1,99 @@ +type BytesDto = string | number[]; +export type ClientPath = string | Iterable | ArrayLike | ArrayBuffer; +export type VaultPath = string | Iterable | ArrayLike | ArrayBuffer; +export type RecordPath = string | Iterable | ArrayLike | ArrayBuffer; +export type StoreKey = string | Iterable | ArrayLike | ArrayBuffer; +export interface ConnectionLimits { + maxPendingIncoming?: number; + maxPendingOutgoing?: number; + maxEstablishedIncoming?: number; + maxEstablishedOutgoing?: number; + maxEstablishedPerPeer?: number; + maxEstablishedTotal?: number; +} +export interface PeerAddress { + known: string[]; + use_relay_fallback: boolean; +} +export interface AddressInfo { + peers: Map; + relays: string[]; +} +export interface ClientAccess { + useVaultDefault?: boolean; + useVaultExceptions?: Map; + writeVaultDefault?: boolean; + writeVaultExceptions?: Map; + cloneVaultDefault?: boolean; + cloneVaultExceptions?: Map; + readStore?: boolean; + writeStore?: boolean; +} +export interface Permissions { + default?: ClientAccess; + exceptions?: Map; +} +export interface NetworkConfig { + requestTimeout?: Duration; + connectionTimeout?: Duration; + connectionsLimit?: ConnectionLimits; + enableMdns?: boolean; + enableRelay?: boolean; + addresses?: AddressInfo; + peerPermissions?: Map; + permissionsDefault?: Permissions; +} +export interface Duration { + millis: number; + nanos: number; +} +export declare class Location { + type: string; + payload: Record; + constructor(type: string, payload: Record); + static generic(vault: VaultPath, record: RecordPath): Location; + static counter(vault: VaultPath, counter: number): Location; +} +declare class ProcedureExecutor { + procedureArgs: Record; + constructor(procedureArgs: Record); + generateSLIP10Seed(outputLocation: Location, sizeBytes?: number): Promise; + deriveSLIP10(chain: number[], source: "Seed" | "Key", sourceLocation: Location, outputLocation: Location): Promise; + recoverBIP39(mnemonic: string, outputLocation: Location, passphrase?: string): Promise; + generateBIP39(outputLocation: Location, passphrase?: string): Promise; + getEd25519PublicKey(privateKeyLocation: Location): Promise; + signEd25519(privateKeyLocation: Location, msg: string): Promise; +} +export declare class Client { + path: string; + name: BytesDto; + constructor(path: string, name: ClientPath); + getVault(name: VaultPath): Vault; + getStore(): Store; +} +export declare class Store { + path: string; + client: BytesDto; + constructor(path: string, client: BytesDto); + get(key: StoreKey): Promise; + insert(key: StoreKey, value: number[], lifetime?: Duration): Promise; + remove(key: StoreKey): Promise; +} +export declare class Vault extends ProcedureExecutor { + path: string; + client: BytesDto; + name: BytesDto; + constructor(path: string, client: ClientPath, name: VaultPath); + insert(recordPath: RecordPath, secret: number[]): Promise; + remove(location: Location): Promise; +} +export declare class Stronghold { + path: string; + constructor(path: string, password: string); + private reload; + unload(): Promise; + loadClient(client: ClientPath): Promise; + createClient(client: ClientPath): Promise; + save(): Promise; +} +export {}; diff --git a/plugins/upload/guest-js/dist/index.d.ts b/plugins/upload/guest-js/dist/index.d.ts new file mode 100644 index 00000000..a2da48ea --- /dev/null +++ b/plugins/upload/guest-js/dist/index.d.ts @@ -0,0 +1,3 @@ +type ProgressHandler = (progress: number, total: number) => void; +export default function upload(url: string, filePath: string, progressHandler?: ProgressHandler, headers?: Map): Promise; +export {}; diff --git a/plugins/websocket/guest-js/dist/index.d.ts b/plugins/websocket/guest-js/dist/index.d.ts new file mode 100644 index 00000000..2631651f --- /dev/null +++ b/plugins/websocket/guest-js/dist/index.d.ts @@ -0,0 +1,18 @@ +export interface MessageKind { + type: T; + data: D; +} +export interface CloseFrame { + code: number; + reason: string; +} +export type Message = MessageKind<"Text", string> | MessageKind<"Binary", number[]> | MessageKind<"Ping", number[]> | MessageKind<"Pong", number[]> | MessageKind<"Close", CloseFrame | null>; +export default class WebSocket { + id: number; + private readonly listeners; + constructor(id: number, listeners: Array<(arg: Message) => void>); + static connect(url: string, options?: unknown): Promise; + addListener(cb: (arg: Message) => void): void; + send(message: Message | string | number[]): Promise; + disconnect(): Promise; +} diff --git a/tsconfig.base.json b/tsconfig.base.json index 30864e46..82270536 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -12,7 +12,9 @@ "pretty": true, "sourceMap": true, "strict": true, - "target": "ES2019" + "target": "ES2019", + "declaration": true, + "declarationDir": "dist" }, "exclude": ["dist", "node_modules", "test/types"] }