@tauri-apps/api
Advanced tools
Comparing version 2.0.0-beta.6 to 2.0.0-beta.7
@@ -49,6 +49,8 @@ type EventTarget = { | ||
WINDOW_THEME_CHANGED = "tauri://theme-changed", | ||
WINDOW_CREATED = "tauri://window-created", | ||
WEBVIEW_CREATED = "tauri://webview-created", | ||
FILE_DROP = "tauri://file-drop", | ||
FILE_DROP_HOVER = "tauri://file-drop-hover", | ||
FILE_DROP_CANCELLED = "tauri://file-drop-cancelled" | ||
DRAG = "tauri://drag", | ||
DROP = "tauri://drop", | ||
DROP_OVER = "tauri://drop-over", | ||
DROP_CANCELLED = "tauri://drag-cancelled" | ||
} | ||
@@ -55,0 +57,0 @@ /** |
@@ -25,6 +25,8 @@ import { invoke, transformCallback } from './core.js'; | ||
TauriEvent["WINDOW_THEME_CHANGED"] = "tauri://theme-changed"; | ||
TauriEvent["WINDOW_CREATED"] = "tauri://window-created"; | ||
TauriEvent["WEBVIEW_CREATED"] = "tauri://webview-created"; | ||
TauriEvent["FILE_DROP"] = "tauri://file-drop"; | ||
TauriEvent["FILE_DROP_HOVER"] = "tauri://file-drop-hover"; | ||
TauriEvent["FILE_DROP_CANCELLED"] = "tauri://file-drop-cancelled"; | ||
TauriEvent["DRAG"] = "tauri://drag"; | ||
TauriEvent["DROP"] = "tauri://drop"; | ||
TauriEvent["DROP_OVER"] = "tauri://drop-over"; | ||
TauriEvent["DROP_CANCELLED"] = "tauri://drag-cancelled"; | ||
})(TauriEvent || (TauriEvent = {})); | ||
@@ -31,0 +33,0 @@ /** |
{ | ||
"name": "@tauri-apps/api", | ||
"version": "2.0.0-beta.6", | ||
"version": "2.0.0-beta.7", | ||
"description": "Tauri API definitions", | ||
@@ -5,0 +5,0 @@ "funding": { |
@@ -20,13 +20,18 @@ /** | ||
import { WebviewWindow } from './webviewWindow'; | ||
interface FileDropPayload { | ||
interface DragDropPayload { | ||
paths: string[]; | ||
position: PhysicalPosition; | ||
} | ||
/** The file drop event types. */ | ||
type FileDropEvent = ({ | ||
type: 'hover'; | ||
} & FileDropPayload) | ({ | ||
type: 'drop'; | ||
} & FileDropPayload) | { | ||
type: 'cancel'; | ||
interface DragOverPayload { | ||
position: PhysicalPosition; | ||
} | ||
/** The drag and drop event types. */ | ||
type DragDropEvent = ({ | ||
type: 'dragged'; | ||
} & DragDropPayload) | ({ | ||
type: 'dragOver'; | ||
} & DragOverPayload) | ({ | ||
type: 'dropped'; | ||
} & DragDropPayload) | { | ||
type: 'cancelled'; | ||
}; | ||
@@ -292,3 +297,3 @@ /** | ||
* import { getCurrent } from "@tauri-apps/api/webview"; | ||
* const unlisten = await getCurrent().onFileDropEvent((event) => { | ||
* const unlisten = await getCurrent().onDragDropEvent((event) => { | ||
* if (event.payload.type === 'hover') { | ||
@@ -310,3 +315,3 @@ * console.log('User hovering', event.payload.paths); | ||
*/ | ||
onFileDropEvent(handler: EventCallback<FileDropEvent>): Promise<UnlistenFn>; | ||
onDragDropEvent(handler: EventCallback<DragDropEvent>): Promise<UnlistenFn>; | ||
} | ||
@@ -342,7 +347,7 @@ /** | ||
/** | ||
* Whether the file drop is enabled or not on the webview. By default it is enabled. | ||
* Whether the drag and drop is enabled or not on the webview. By default it is enabled. | ||
* | ||
* Disabling it is required to use drag and drop on the frontend on Windows. | ||
* Disabling it is required to use HTML5 drag and drop on the frontend on Windows. | ||
*/ | ||
fileDropEnabled?: boolean; | ||
dragDropEnabled?: boolean; | ||
/** | ||
@@ -376,2 +381,2 @@ * Whether clicking an inactive webview also clicks through to the webview on macOS. | ||
export { Webview, getCurrent, getAll }; | ||
export type { FileDropEvent, FileDropPayload, WebviewOptions }; | ||
export type { DragDropEvent, DragDropPayload, WebviewOptions }; |
@@ -423,3 +423,3 @@ import { PhysicalPosition, PhysicalSize } from './dpi.js'; | ||
* import { getCurrent } from "@tauri-apps/api/webview"; | ||
* const unlisten = await getCurrent().onFileDropEvent((event) => { | ||
* const unlisten = await getCurrent().onDragDropEvent((event) => { | ||
* if (event.payload.type === 'hover') { | ||
@@ -441,8 +441,8 @@ * console.log('User hovering', event.payload.paths); | ||
*/ | ||
async onFileDropEvent(handler) { | ||
const unlistenFileDrop = await this.listen(TauriEvent.FILE_DROP, (event) => { | ||
async onDragDropEvent(handler) { | ||
const unlistenDrag = await this.listen(TauriEvent.DRAG, (event) => { | ||
handler({ | ||
...event, | ||
payload: { | ||
type: 'drop', | ||
type: 'dragged', | ||
paths: event.payload.paths, | ||
@@ -453,7 +453,7 @@ position: mapPhysicalPosition(event.payload.position) | ||
}); | ||
const unlistenFileHover = await this.listen(TauriEvent.FILE_DROP_HOVER, (event) => { | ||
const unlistenDrop = await this.listen(TauriEvent.DROP, (event) => { | ||
handler({ | ||
...event, | ||
payload: { | ||
type: 'hover', | ||
type: 'dropped', | ||
paths: event.payload.paths, | ||
@@ -464,8 +464,18 @@ position: mapPhysicalPosition(event.payload.position) | ||
}); | ||
const unlistenCancel = await this.listen(TauriEvent.FILE_DROP_CANCELLED, (event) => { | ||
handler({ ...event, payload: { type: 'cancel' } }); | ||
const unlistenDragOver = await this.listen(TauriEvent.DROP_CANCELLED, (event) => { | ||
handler({ | ||
...event, | ||
payload: { | ||
type: 'dragOver', | ||
position: mapPhysicalPosition(event.payload.position) | ||
} | ||
}); | ||
}); | ||
const unlistenCancel = await this.listen(TauriEvent.DROP_CANCELLED, (event) => { | ||
handler({ ...event, payload: { type: 'cancelled' } }); | ||
}); | ||
return () => { | ||
unlistenFileDrop(); | ||
unlistenFileHover(); | ||
unlistenDrag(); | ||
unlistenDrop(); | ||
unlistenDragOver(); | ||
unlistenCancel(); | ||
@@ -472,0 +482,0 @@ }; |
@@ -5,3 +5,3 @@ import { Webview, WebviewLabel, WebviewOptions } from './webview'; | ||
import type { EventName, EventCallback, UnlistenFn } from './event'; | ||
import type { FileDropEvent, FileDropPayload } from './webview'; | ||
import type { DragDropEvent, DragDropPayload } from './webview'; | ||
/** | ||
@@ -107,2 +107,2 @@ * Get an instance of `Webview` for the current webview window. | ||
export { WebviewWindow, getCurrent, getAll }; | ||
export type { FileDropEvent, FileDropPayload }; | ||
export type { DragDropEvent, DragDropPayload }; |
@@ -18,3 +18,3 @@ /** | ||
import { WebviewWindow } from './webviewWindow'; | ||
import type { FileDropEvent, FileDropPayload } from './webview'; | ||
import type { DragDropEvent, DragDropPayload } from './webview'; | ||
import { Image } from './image'; | ||
@@ -1062,3 +1062,3 @@ /** | ||
* import { getCurrent } from "@tauri-apps/api/webview"; | ||
* const unlisten = await getCurrent().onFileDropEvent((event) => { | ||
* const unlisten = await getCurrent().onDragDropEvent((event) => { | ||
* if (event.payload.type === 'hover') { | ||
@@ -1080,3 +1080,3 @@ * console.log('User hovering', event.payload.paths); | ||
*/ | ||
onFileDropEvent(handler: EventCallback<FileDropEvent>): Promise<UnlistenFn>; | ||
onDragDropEvent(handler: EventCallback<DragDropEvent>): Promise<UnlistenFn>; | ||
/** | ||
@@ -1476,2 +1476,2 @@ * Listen to window focus change. | ||
export { Window, CloseRequestedEvent, getCurrent, getAll, LogicalSize, PhysicalSize, LogicalPosition, PhysicalPosition, UserAttentionType, Effect, EffectState, currentMonitor, primaryMonitor, availableMonitors }; | ||
export type { Effects, Theme, TitleBarStyle, ScaleFactorChanged, WindowOptions, Color, FileDropEvent, FileDropPayload }; | ||
export type { Effects, Theme, TitleBarStyle, ScaleFactorChanged, WindowOptions, Color, DragDropEvent, DragDropPayload }; |
@@ -1468,3 +1468,3 @@ import { PhysicalPosition, PhysicalSize } from './dpi.js'; | ||
* import { getCurrent } from "@tauri-apps/api/webview"; | ||
* const unlisten = await getCurrent().onFileDropEvent((event) => { | ||
* const unlisten = await getCurrent().onDragDropEvent((event) => { | ||
* if (event.payload.type === 'hover') { | ||
@@ -1486,8 +1486,8 @@ * console.log('User hovering', event.payload.paths); | ||
*/ | ||
async onFileDropEvent(handler) { | ||
const unlistenFileDrop = await this.listen(TauriEvent.FILE_DROP, (event) => { | ||
async onDragDropEvent(handler) { | ||
const unlistenDrag = await this.listen(TauriEvent.DRAG, (event) => { | ||
handler({ | ||
...event, | ||
payload: { | ||
type: 'drop', | ||
type: 'dragged', | ||
paths: event.payload.paths, | ||
@@ -1498,7 +1498,7 @@ position: mapPhysicalPosition(event.payload.position) | ||
}); | ||
const unlistenFileHover = await this.listen(TauriEvent.FILE_DROP_HOVER, (event) => { | ||
const unlistenDrop = await this.listen(TauriEvent.DROP, (event) => { | ||
handler({ | ||
...event, | ||
payload: { | ||
type: 'hover', | ||
type: 'dropped', | ||
paths: event.payload.paths, | ||
@@ -1509,8 +1509,18 @@ position: mapPhysicalPosition(event.payload.position) | ||
}); | ||
const unlistenCancel = await this.listen(TauriEvent.FILE_DROP_CANCELLED, (event) => { | ||
handler({ ...event, payload: { type: 'cancel' } }); | ||
const unlistenDragOver = await this.listen(TauriEvent.DROP_OVER, (event) => { | ||
handler({ | ||
...event, | ||
payload: { | ||
type: 'dragOver', | ||
position: mapPhysicalPosition(event.payload.position) | ||
} | ||
}); | ||
}); | ||
const unlistenCancel = await this.listen(TauriEvent.DROP_CANCELLED, (event) => { | ||
handler({ ...event, payload: { type: 'cancelled' } }); | ||
}); | ||
return () => { | ||
unlistenFileDrop(); | ||
unlistenFileHover(); | ||
unlistenDrag(); | ||
unlistenDrop(); | ||
unlistenDragOver(); | ||
unlistenCancel(); | ||
@@ -1517,0 +1527,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
544430
13616