@nativedesktop/react 0.4.41 → 0.4.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +39 -1
- package/dist/packages/react/src/dialogs.d.ts +2 -0
- package/dist/packages/react/src/generated/intrinsics.d.ts +1 -0
- package/dist/packages/react/src/generated/schema-meta.d.ts +1 -1
- package/dist/packages/react/src/index.d.ts +2 -2
- package/dist/packages/react/src/webview.d.ts +21 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -746,7 +746,7 @@ var widgetCommands = {
|
|
|
746
746
|
tabview: [],
|
|
747
747
|
grid: [],
|
|
748
748
|
listview: [],
|
|
749
|
-
webview: ["goBack", "goForward", "reload", "stop", "executeJavaScript", "setZoom", "setUserAgent", "openDevTools", "addUserScript", "removeUserScript", "clearUserScripts", "registerScriptMessage", "unregisterScriptMessage", "respondScheme", "respondPermission", "resetPermissions", "respondDownload", "getCookies", "setCookie", "deleteCookie", "findStart", "findNext", "findPrevious", "findStop", "saveSession", "restoreSession", "setMuted", "setContextMenuItems", "listExtensions", "watchExtensions", "listExtensionActions", "readExtensionAction", "installExtension", "uninstallExtension", "setExtensionEnabled", "focus"],
|
|
749
|
+
webview: ["goBack", "goForward", "reload", "stop", "executeJavaScript", "setZoom", "setUserAgent", "openDevTools", "addUserScript", "removeUserScript", "clearUserScripts", "registerScriptMessage", "unregisterScriptMessage", "respondScheme", "respondPermission", "resetPermissions", "respondDownload", "startDownload", "pauseDownload", "resumeDownload", "cancelDownload", "getCookies", "setCookie", "deleteCookie", "findStart", "findNext", "findPrevious", "findStop", "saveSession", "restoreSession", "setMuted", "setContextMenuItems", "listExtensions", "watchExtensions", "listExtensionActions", "readExtensionAction", "triggerExtensionAction", "installExtension", "uninstallExtension", "setExtensionEnabled", "focus"],
|
|
750
750
|
nativeview: [],
|
|
751
751
|
splitview: ["revealSidebar", "concealSidebar"],
|
|
752
752
|
headerbar: [],
|
|
@@ -1969,6 +1969,7 @@ var pendingExtensions = new Map;
|
|
|
1969
1969
|
var pendingActions = new Map;
|
|
1970
1970
|
var pendingWatches = new Map;
|
|
1971
1971
|
var pendingActionState = new Map;
|
|
1972
|
+
var pendingTriggers = new Map;
|
|
1972
1973
|
var seq2 = 0;
|
|
1973
1974
|
function nextId(prefix) {
|
|
1974
1975
|
return `${prefix}${++seq2}`;
|
|
@@ -2109,11 +2110,27 @@ function onExtensionsChanged(e) {
|
|
|
2109
2110
|
function readExtensionAction(node) {
|
|
2110
2111
|
return request(node, pendingActionState, "ext", "readExtensionAction", {});
|
|
2111
2112
|
}
|
|
2113
|
+
function triggerExtensionAction(node, extensionId) {
|
|
2114
|
+
const id = nextId("ext");
|
|
2115
|
+
return new Promise((resolve2, reject2) => {
|
|
2116
|
+
pendingTriggers.set(id, { resolve: resolve2, reject: reject2 });
|
|
2117
|
+
sendCommand(node, "triggerExtensionAction", { id, extensionId });
|
|
2118
|
+
});
|
|
2119
|
+
}
|
|
2112
2120
|
function listExtensionActions(node) {
|
|
2113
2121
|
return request(node, pendingActions, "ext", "listExtensionActions", {});
|
|
2114
2122
|
}
|
|
2115
2123
|
function onExtensionActions(e) {
|
|
2116
2124
|
const result = e.data;
|
|
2125
|
+
const trigger = pendingTriggers.get(result.id);
|
|
2126
|
+
if (trigger) {
|
|
2127
|
+
pendingTriggers.delete(result.id);
|
|
2128
|
+
if (result.ok)
|
|
2129
|
+
trigger.resolve();
|
|
2130
|
+
else
|
|
2131
|
+
trigger.reject(new Error(result.error ?? "triggerExtensionAction failed"));
|
|
2132
|
+
return;
|
|
2133
|
+
}
|
|
2117
2134
|
const state3 = pendingActionState.get(result.id);
|
|
2118
2135
|
if (state3) {
|
|
2119
2136
|
pendingActionState.delete(result.id);
|
|
@@ -2135,6 +2152,21 @@ function onExtensionActions(e) {
|
|
|
2135
2152
|
function setContextMenuItems(node, items) {
|
|
2136
2153
|
sendCommand(node, "setContextMenuItems", { items });
|
|
2137
2154
|
}
|
|
2155
|
+
function respondDownload(node, id, path) {
|
|
2156
|
+
sendCommand(node, "respondDownload", path ? { id, path } : { id });
|
|
2157
|
+
}
|
|
2158
|
+
function startDownload(node, url) {
|
|
2159
|
+
sendCommand(node, "startDownload", { url });
|
|
2160
|
+
}
|
|
2161
|
+
function pauseDownload(node, id) {
|
|
2162
|
+
sendCommand(node, "pauseDownload", { id });
|
|
2163
|
+
}
|
|
2164
|
+
function resumeDownload(node, id) {
|
|
2165
|
+
sendCommand(node, "resumeDownload", { id });
|
|
2166
|
+
}
|
|
2167
|
+
function cancelDownload(node, id) {
|
|
2168
|
+
sendCommand(node, "cancelDownload", { id });
|
|
2169
|
+
}
|
|
2138
2170
|
// src/dialogs.ts
|
|
2139
2171
|
var pending = new Map;
|
|
2140
2172
|
function checkAvailable(node, reject2) {
|
|
@@ -2503,8 +2535,10 @@ export {
|
|
|
2503
2535
|
useCallback,
|
|
2504
2536
|
use,
|
|
2505
2537
|
uninstallExtension,
|
|
2538
|
+
triggerExtensionAction,
|
|
2506
2539
|
system,
|
|
2507
2540
|
startTransition,
|
|
2541
|
+
startDownload,
|
|
2508
2542
|
showToast,
|
|
2509
2543
|
showTabOverview,
|
|
2510
2544
|
showAlert,
|
|
@@ -2517,11 +2551,14 @@ export {
|
|
|
2517
2551
|
saveSession,
|
|
2518
2552
|
saveFile,
|
|
2519
2553
|
revealPath,
|
|
2554
|
+
resumeDownload,
|
|
2555
|
+
respondDownload,
|
|
2520
2556
|
render,
|
|
2521
2557
|
registerExports,
|
|
2522
2558
|
recentDocuments,
|
|
2523
2559
|
readExtensionAction,
|
|
2524
2560
|
performRefresh,
|
|
2561
|
+
pauseDownload,
|
|
2525
2562
|
openPath,
|
|
2526
2563
|
openFile,
|
|
2527
2564
|
openExternal,
|
|
@@ -2560,6 +2597,7 @@ export {
|
|
|
2560
2597
|
createPool,
|
|
2561
2598
|
createContext,
|
|
2562
2599
|
clipboard,
|
|
2600
|
+
cancelDownload,
|
|
2563
2601
|
audio,
|
|
2564
2602
|
app,
|
|
2565
2603
|
Suspense2 as Suspense,
|
|
@@ -242,6 +242,7 @@ export declare namespace JSX {
|
|
|
242
242
|
label: {
|
|
243
243
|
text?: string;
|
|
244
244
|
ellipsize?: boolean;
|
|
245
|
+
ellipsizeMode?: "end" | "middle" | "start";
|
|
245
246
|
variant?: "body" | "title1" | "title2" | "title3" | "title4" | "heading" | "caption" | "captionHeading" | "monospace";
|
|
246
247
|
enabled?: boolean;
|
|
247
248
|
tooltip?: string;
|
|
@@ -29,7 +29,7 @@ export type WidgetCommandNames = {
|
|
|
29
29
|
"checkbox": "focus";
|
|
30
30
|
"radio": "focus";
|
|
31
31
|
"select": "focus";
|
|
32
|
-
"webview": "goBack" | "goForward" | "reload" | "stop" | "executeJavaScript" | "setZoom" | "setUserAgent" | "openDevTools" | "addUserScript" | "removeUserScript" | "clearUserScripts" | "registerScriptMessage" | "unregisterScriptMessage" | "respondScheme" | "respondPermission" | "resetPermissions" | "respondDownload" | "getCookies" | "setCookie" | "deleteCookie" | "findStart" | "findNext" | "findPrevious" | "findStop" | "saveSession" | "restoreSession" | "setMuted" | "setContextMenuItems" | "listExtensions" | "watchExtensions" | "listExtensionActions" | "readExtensionAction" | "installExtension" | "uninstallExtension" | "setExtensionEnabled" | "focus";
|
|
32
|
+
"webview": "goBack" | "goForward" | "reload" | "stop" | "executeJavaScript" | "setZoom" | "setUserAgent" | "openDevTools" | "addUserScript" | "removeUserScript" | "clearUserScripts" | "registerScriptMessage" | "unregisterScriptMessage" | "respondScheme" | "respondPermission" | "resetPermissions" | "respondDownload" | "startDownload" | "pauseDownload" | "resumeDownload" | "cancelDownload" | "getCookies" | "setCookie" | "deleteCookie" | "findStart" | "findNext" | "findPrevious" | "findStop" | "saveSession" | "restoreSession" | "setMuted" | "setContextMenuItems" | "listExtensions" | "watchExtensions" | "listExtensionActions" | "readExtensionAction" | "triggerExtensionAction" | "installExtension" | "uninstallExtension" | "setExtensionEnabled" | "focus";
|
|
33
33
|
"splitview": "revealSidebar" | "concealSidebar";
|
|
34
34
|
"toolbarview": "revealTopBars" | "concealTopBars";
|
|
35
35
|
"searchinput": "focus" | "activateLeadingIcon" | "activateTrailingIcon";
|
|
@@ -7,8 +7,8 @@ export type { SpacingScale } from "./metrics.ts";
|
|
|
7
7
|
export { getAppDataDir, ensureAppDataDir } from "./paths.ts";
|
|
8
8
|
export { defineNativeComponent } from "./native-component.ts";
|
|
9
9
|
export type { NativeComponentOptions, NativeComponentProps, NativeComponentRef } from "./native-component.ts";
|
|
10
|
-
export { executeJavaScript, onJavaScriptResult, getCookies, onCookiesResult, saveSession, onSessionSaved, setContextMenuItems, listExtensions, onExtensionsList, listExtensionActions, readExtensionAction, onExtensionActions, watchExtensions, onExtensionsChanged, installExtension, uninstallExtension, setExtensionEnabled, } from "./webview.ts";
|
|
11
|
-
export type { Cookie, ContextMenuContext, ContextMenuItem, ContextMenuItemClick, ExtensionAction, ExtensionActionState, ExtensionsChange, InstalledExtension, } from "./webview.ts";
|
|
10
|
+
export { executeJavaScript, onJavaScriptResult, getCookies, onCookiesResult, saveSession, onSessionSaved, setContextMenuItems, listExtensions, onExtensionsList, listExtensionActions, readExtensionAction, triggerExtensionAction, onExtensionActions, watchExtensions, onExtensionsChanged, installExtension, uninstallExtension, setExtensionEnabled, respondDownload, startDownload, pauseDownload, resumeDownload, cancelDownload, } from "./webview.ts";
|
|
11
|
+
export type { Cookie, DownloadRequest, DownloadState, DownloadUpdate, ContextMenuContext, ContextMenuItem, ContextMenuItemClick, ExtensionAction, ExtensionActionState, ExtensionsChange, InstalledExtension, } from "./webview.ts";
|
|
12
12
|
export { showAlert, openFile, saveFile, showAbout, showTabOverview, onAlertResult, onOpenFileResult, onSaveFileResult, } from "./dialogs.ts";
|
|
13
13
|
export type { DialogButton, ShowAlertOptions, AlertResult, OpenFileOptions as WindowOpenFileOptions, OpenFileResult as WindowOpenFileResult, SaveFileOptions as WindowSaveFileOptions, SaveFileResult as WindowSaveFileResult, ShowAboutOptions, } from "./dialogs.ts";
|
|
14
14
|
export { showToast, dismissToast, onToastButtonClicked, onToastDismissed } from "./toast.ts";
|
|
@@ -70,6 +70,7 @@ export interface ExtensionActionState {
|
|
|
70
70
|
enabled: boolean;
|
|
71
71
|
}
|
|
72
72
|
export declare function readExtensionAction(node: NdNodeRef<"webview">): Promise<ExtensionActionState>;
|
|
73
|
+
export declare function triggerExtensionAction(node: NdNodeRef<"webview">, extensionId: string): Promise<void>;
|
|
73
74
|
export declare function listExtensionActions(node: NdNodeRef<"webview">): Promise<ExtensionAction[]>;
|
|
74
75
|
export declare function onExtensionActions(e: {
|
|
75
76
|
data: unknown;
|
|
@@ -96,3 +97,23 @@ export interface ContextMenuItemClick {
|
|
|
96
97
|
wasChecked?: boolean;
|
|
97
98
|
}
|
|
98
99
|
export declare function setContextMenuItems(node: NdNodeRef<"webview">, items: ContextMenuItem[]): void;
|
|
100
|
+
export interface DownloadRequest {
|
|
101
|
+
id?: string;
|
|
102
|
+
url: string;
|
|
103
|
+
suggestedFilename?: string;
|
|
104
|
+
}
|
|
105
|
+
export type DownloadState = "running" | "done" | "failed" | "cancelled";
|
|
106
|
+
export interface DownloadUpdate {
|
|
107
|
+
id: string;
|
|
108
|
+
state: DownloadState;
|
|
109
|
+
received: number;
|
|
110
|
+
total: number;
|
|
111
|
+
path: string;
|
|
112
|
+
speed?: number;
|
|
113
|
+
paused?: boolean;
|
|
114
|
+
}
|
|
115
|
+
export declare function respondDownload(node: NdNodeRef<"webview">, id: string, path?: string): void;
|
|
116
|
+
export declare function startDownload(node: NdNodeRef<"webview">, url: string): void;
|
|
117
|
+
export declare function pauseDownload(node: NdNodeRef<"webview">, id: string): void;
|
|
118
|
+
export declare function resumeDownload(node: NdNodeRef<"webview">, id: string): void;
|
|
119
|
+
export declare function cancelDownload(node: NdNodeRef<"webview">, id: string): void;
|