@tauri-apps/api
Advanced tools
Comparing version 2.0.0-beta.5 to 2.0.0-beta.6
import { Resource } from './core'; | ||
export interface ImageSize { | ||
width: number; | ||
height: number; | ||
} | ||
/** An RGBA Image in row-major order from top to bottom. */ | ||
export declare class Image extends Resource { | ||
private constructor(); | ||
/** | ||
* Creates an Image from a resource ID. For internal use only. | ||
* | ||
* @ignore | ||
*/ | ||
constructor(rid: number); | ||
/** Creates a new Image using RGBA data, in row-major order from top to bottom, and with specified width and height. */ | ||
@@ -35,7 +44,5 @@ static new(rgba: number[] | Uint8Array | ArrayBuffer, width: number, height: number): Promise<Image>; | ||
/** Returns the RGBA data for this image, in row-major order from top to bottom. */ | ||
rgba(): Promise<ArrayBuffer | number[]>; | ||
/** Returns the width of this image. */ | ||
width(): Promise<number>; | ||
/** Returns the height of this image. */ | ||
height(): Promise<number>; | ||
rgba(): Promise<Uint8Array>; | ||
/** Returns the size of this image. */ | ||
size(): Promise<ImageSize>; | ||
} | ||
@@ -42,0 +49,0 @@ /** |
17
image.js
@@ -8,2 +8,7 @@ import { Resource, invoke } from './core.js'; | ||
class Image extends Resource { | ||
/** | ||
* Creates an Image from a resource ID. For internal use only. | ||
* | ||
* @ignore | ||
*/ | ||
constructor(rid) { | ||
@@ -57,12 +62,8 @@ super(rid); | ||
rid: this.rid | ||
}); | ||
}).then((buffer) => new Uint8Array(buffer)); | ||
} | ||
/** Returns the width of this image. */ | ||
async width() { | ||
return invoke('plugin:image|width', { rid: this.rid }); | ||
/** Returns the size of this image. */ | ||
async size() { | ||
return invoke('plugin:image|size', { rid: this.rid }); | ||
} | ||
/** Returns the height of this image. */ | ||
async height() { | ||
return invoke('plugin:image|height', { rid: this.rid }); | ||
} | ||
} | ||
@@ -69,0 +70,0 @@ /** |
{ | ||
"name": "@tauri-apps/api", | ||
"version": "2.0.0-beta.5", | ||
"version": "2.0.0-beta.6", | ||
"description": "Tauri API definitions", | ||
@@ -5,0 +5,0 @@ "funding": { |
@@ -460,5 +460,5 @@ /** | ||
* ```typescript | ||
* import { dirname, appDataDir } from '@tauri-apps/api/path'; | ||
* const appDataDirPath = await appDataDir(); | ||
* const dir = await dirname(appDataDirPath); | ||
* import { dirname } from '@tauri-apps/api/path'; | ||
* const dir = await dirname('/path/to/somedir/'); | ||
* assert(dir === 'somedir'); | ||
* ``` | ||
@@ -473,6 +473,5 @@ * | ||
* ```typescript | ||
* import { extname, resolveResource } from '@tauri-apps/api/path'; | ||
* const resourcePath = await resolveResource('app.conf'); | ||
* const ext = await extname(resourcePath); | ||
* assert(ext === 'conf'); | ||
* import { extname } from '@tauri-apps/api/path'; | ||
* const ext = await extname('/path/to/file.html'); | ||
* assert(ext === 'html'); | ||
* ``` | ||
@@ -487,8 +486,6 @@ * | ||
* ```typescript | ||
* import { basename, resolveResource } from '@tauri-apps/api/path'; | ||
* const resourcePath = await resolveResource('app.conf'); | ||
* const base = await basename(resourcePath); | ||
* import { basename } from '@tauri-apps/api/path'; | ||
* const base = await basename('path/to/app.conf'); | ||
* assert(base === 'app.conf'); | ||
* ``` | ||
* | ||
* @param ext An optional file extension to be removed from the returned path. | ||
@@ -495,0 +492,0 @@ * |
19
path.js
@@ -581,5 +581,5 @@ import { invoke } from './core.js'; | ||
* ```typescript | ||
* import { dirname, appDataDir } from '@tauri-apps/api/path'; | ||
* const appDataDirPath = await appDataDir(); | ||
* const dir = await dirname(appDataDirPath); | ||
* import { dirname } from '@tauri-apps/api/path'; | ||
* const dir = await dirname('/path/to/somedir/'); | ||
* assert(dir === 'somedir'); | ||
* ``` | ||
@@ -596,6 +596,5 @@ * | ||
* ```typescript | ||
* import { extname, resolveResource } from '@tauri-apps/api/path'; | ||
* const resourcePath = await resolveResource('app.conf'); | ||
* const ext = await extname(resourcePath); | ||
* assert(ext === 'conf'); | ||
* import { extname } from '@tauri-apps/api/path'; | ||
* const ext = await extname('/path/to/file.html'); | ||
* assert(ext === 'html'); | ||
* ``` | ||
@@ -612,8 +611,6 @@ * | ||
* ```typescript | ||
* import { basename, resolveResource } from '@tauri-apps/api/path'; | ||
* const resourcePath = await resolveResource('app.conf'); | ||
* const base = await basename(resourcePath); | ||
* import { basename } from '@tauri-apps/api/path'; | ||
* const base = await basename('path/to/app.conf'); | ||
* assert(base === 'app.conf'); | ||
* ``` | ||
* | ||
* @param ext An optional file extension to be removed from the returned path. | ||
@@ -620,0 +617,0 @@ * |
@@ -109,3 +109,12 @@ import type { Menu, Submenu } from './menu'; | ||
private constructor(); | ||
/** Gets a tray icon using the provided id. */ | ||
static getById(id: string): Promise<TrayIcon | null>; | ||
/** | ||
* Removes a tray icon using the provided id from tauri's internal state. | ||
* | ||
* Note that this may cause the tray icon to disappear | ||
* if it wasn't cloned somewhere else or referenced by JS. | ||
*/ | ||
static removeById(id: string): Promise<void>; | ||
/** | ||
* Creates a new {@linkcode TrayIcon} | ||
@@ -112,0 +121,0 @@ * |
15
tray.js
@@ -1,2 +0,2 @@ | ||
import { Resource, Channel, invoke } from './core.js'; | ||
import { Resource, invoke, Channel } from './core.js'; | ||
import { transformImage } from './image.js'; | ||
@@ -30,3 +30,16 @@ | ||
} | ||
/** Gets a tray icon using the provided id. */ | ||
static async getById(id) { | ||
return invoke('plugin:tray|get_by_id', { id }).then((rid) => rid ? new TrayIcon(rid, id) : null); | ||
} | ||
/** | ||
* Removes a tray icon using the provided id from tauri's internal state. | ||
* | ||
* Note that this may cause the tray icon to disappear | ||
* if it wasn't cloned somewhere else or referenced by JS. | ||
*/ | ||
static async removeById(id) { | ||
return invoke('plugin:tray|remove_by_id', { id }); | ||
} | ||
/** | ||
* Creates a new {@linkcode TrayIcon} | ||
@@ -33,0 +46,0 @@ * |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
542211
13565