core
Invoke your custom commands.
This package is also accessible with window.__TAURI__.core
when app.withGlobalTauri
in tauri.conf.json
is set to true
.
Classes
Channel<T>
Type Parameters
Type Parameter | Default type |
---|---|
T | unknown |
Constructors
new Channel()
Returns
Channel
<T
>
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/core.ts#L37
Properties
Property | Type | Defined in |
---|---|---|
id | number | Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/core.ts#L28 |
Accessors
onmessage
Parameters
Parameter | Type |
---|---|
handler | (response ) => void |
Returns
Function
Parameters
Parameter | Type |
---|---|
response | T |
Returns
void
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/core.ts#L79
Methods
toJSON()
Returns
string
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/core.ts#L83
PluginListener
Constructors
new PluginListener()
Parameters
Parameter | Type |
---|---|
plugin | string |
event | string |
channelId | number |
Returns
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/core.ts#L93
Properties
Property | Type | Defined in |
---|---|---|
channelId | number | Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/core.ts#L91 |
event | string | Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/core.ts#L90 |
plugin | string | Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/core.ts#L89 |
Methods
unregister()
Returns
Promise
<void
>
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/core.ts#L99
Resource
A rust-backed resource stored through tauri::Manager::resources_table
API.
The resource lives in the main process and does not exist
in the Javascript world, and thus will not be cleaned up automatiacally
except on application exit. If you want to clean it up early, call Resource.close
Example
Extended by
Constructors
new Resource()
Parameters
Parameter | Type |
---|---|
rid | number |
Returns
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/core.ts#L246
Accessors
rid
Returns
number
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/core.ts#L242
Methods
close()
Destroys and cleans up this resource from memory. You should not call any method on this object anymore and should drop any reference to it.
Returns
Promise
<void
>
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/core.ts#L254
Interfaces
InvokeOptions
Since
2.0.0
Properties
Property | Type | Defined in |
---|---|---|
headers | Record <string , string > | Headers | Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/core.ts#L157 |
Type Aliases
InvokeArgs
Command arguments.
Since
1.0.0
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/core.ts#L151
PermissionState
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/core.ts#L126
Functions
addPluginListener()
Adds a listener to a plugin event.
Type Parameters
Type Parameter |
---|
T |
Parameters
Parameter | Type |
---|---|
plugin | string |
event | string |
cb | (payload ) => void |
Returns
The listener object to stop listening to the events.
Since
2.0.0
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/core.ts#L114
checkPermissions()
Get permission state for a plugin.
This should be used by plugin authors to wrap their actual implementation.
Type Parameters
Type Parameter |
---|
T |
Parameters
Parameter | Type |
---|---|
plugin | string |
Returns
Promise
<T
>
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/core.ts#L133
convertFileSrc()
Convert a device file path to an URL that can be loaded by the webview.
Note that asset:
and http://asset.localhost
must be added to app.security.csp
in tauri.conf.json
.
Example CSP value: "csp": "default-src 'self' ipc: http://ipc.localhost; img-src 'self' asset: http://asset.localhost"
to use the asset protocol on image sources.
Additionally, "enable" : "true"
must be added to app.security.assetProtocol
in tauri.conf.json
and its access scope must be defined on the scope
array on the same assetProtocol
object.
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
filePath | string | undefined | The file path. |
protocol | string | 'asset' | The protocol to use. Defaults to asset . You only need to set this when using a custom protocol. |
Returns
string
the URL that can be used as source on the webview.
Example
Since
1.0.0
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/core.ts#L213
invoke()
Sends a message to the backend.
Type Parameters
Type Parameter |
---|
T |
Parameters
Parameter | Type | Description |
---|---|---|
cmd | string | The command name. |
args | InvokeArgs | The optional arguments to pass to the command. |
options ? | InvokeOptions | The request options. |
Returns
Promise
<T
>
A promise resolving or rejecting to the backend response.
Example
Since
1.0.0
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/core.ts#L175
isTauri()
Returns
boolean
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/core.ts#L261
requestPermissions()
Request permissions.
This should be used by plugin authors to wrap their actual implementation.
Type Parameters
Type Parameter |
---|
T |
Parameters
Parameter | Type |
---|---|
plugin | string |
Returns
Promise
<T
>
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/core.ts#L142
transformCallback()
Transforms a callback function to a string identifier that can be passed to the backend.
The backend uses the identifier to eval()
the callback.
Type Parameters
Type Parameter | Default type |
---|---|
T | unknown |
Parameters
Parameter | Type | Default value |
---|---|---|
callback ? | (response ) => void | undefined |
once ? | boolean | false |
Returns
number
A unique identifier associated with the callback function.
Since
1.0.0
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/core.ts#L20
© 2024 Tauri Contributors. CC-BY / MIT