@nativedesktop/react 0.4.41 → 0.4.43

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 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}`;
@@ -2020,8 +2021,12 @@ function request(node, pending, prefix, command, args) {
2020
2021
  }
2021
2022
  });
2022
2023
  }
2023
- function executeJavaScript(node, code, world) {
2024
- return request(node, pendingEvals, "js", "executeJavaScript", world ? { code, world } : { code });
2024
+ function executeJavaScript(node, code, world, options) {
2025
+ return request(node, pendingEvals, "js", "executeJavaScript", {
2026
+ code,
2027
+ ...world ? { world } : {},
2028
+ ...options?.userGesture ? { userGesture: true } : {}
2029
+ });
2025
2030
  }
2026
2031
  function onJavaScriptResult(e) {
2027
2032
  const result = e.data;
@@ -2109,11 +2114,27 @@ function onExtensionsChanged(e) {
2109
2114
  function readExtensionAction(node) {
2110
2115
  return request(node, pendingActionState, "ext", "readExtensionAction", {});
2111
2116
  }
2117
+ function triggerExtensionAction(node, extensionId) {
2118
+ const id = nextId("ext");
2119
+ return new Promise((resolve2, reject2) => {
2120
+ pendingTriggers.set(id, { resolve: resolve2, reject: reject2 });
2121
+ sendCommand(node, "triggerExtensionAction", { id, extensionId });
2122
+ });
2123
+ }
2112
2124
  function listExtensionActions(node) {
2113
2125
  return request(node, pendingActions, "ext", "listExtensionActions", {});
2114
2126
  }
2115
2127
  function onExtensionActions(e) {
2116
2128
  const result = e.data;
2129
+ const trigger = pendingTriggers.get(result.id);
2130
+ if (trigger) {
2131
+ pendingTriggers.delete(result.id);
2132
+ if (result.ok)
2133
+ trigger.resolve();
2134
+ else
2135
+ trigger.reject(new Error(result.error ?? "triggerExtensionAction failed"));
2136
+ return;
2137
+ }
2117
2138
  const state3 = pendingActionState.get(result.id);
2118
2139
  if (state3) {
2119
2140
  pendingActionState.delete(result.id);
@@ -2135,6 +2156,21 @@ function onExtensionActions(e) {
2135
2156
  function setContextMenuItems(node, items) {
2136
2157
  sendCommand(node, "setContextMenuItems", { items });
2137
2158
  }
2159
+ function respondDownload(node, id, path) {
2160
+ sendCommand(node, "respondDownload", path ? { id, path } : { id });
2161
+ }
2162
+ function startDownload(node, url) {
2163
+ sendCommand(node, "startDownload", { url });
2164
+ }
2165
+ function pauseDownload(node, id) {
2166
+ sendCommand(node, "pauseDownload", { id });
2167
+ }
2168
+ function resumeDownload(node, id) {
2169
+ sendCommand(node, "resumeDownload", { id });
2170
+ }
2171
+ function cancelDownload(node, id) {
2172
+ sendCommand(node, "cancelDownload", { id });
2173
+ }
2138
2174
  // src/dialogs.ts
2139
2175
  var pending = new Map;
2140
2176
  function checkAvailable(node, reject2) {
@@ -2503,8 +2539,10 @@ export {
2503
2539
  useCallback,
2504
2540
  use,
2505
2541
  uninstallExtension,
2542
+ triggerExtensionAction,
2506
2543
  system,
2507
2544
  startTransition,
2545
+ startDownload,
2508
2546
  showToast,
2509
2547
  showTabOverview,
2510
2548
  showAlert,
@@ -2517,11 +2555,14 @@ export {
2517
2555
  saveSession,
2518
2556
  saveFile,
2519
2557
  revealPath,
2558
+ resumeDownload,
2559
+ respondDownload,
2520
2560
  render,
2521
2561
  registerExports,
2522
2562
  recentDocuments,
2523
2563
  readExtensionAction,
2524
2564
  performRefresh,
2565
+ pauseDownload,
2525
2566
  openPath,
2526
2567
  openFile,
2527
2568
  openExternal,
@@ -2560,6 +2601,7 @@ export {
2560
2601
  createPool,
2561
2602
  createContext,
2562
2603
  clipboard,
2604
+ cancelDownload,
2563
2605
  audio,
2564
2606
  app,
2565
2607
  Suspense2 as Suspense,
@@ -10,6 +10,8 @@ export interface ShowAlertOptions {
10
10
  title: string;
11
11
  body?: string;
12
12
  buttons: DialogButton[];
13
+ defaultId?: string;
14
+ closeId?: string;
13
15
  }
14
16
  export interface AlertResult {
15
17
  buttonId: string;
@@ -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";
@@ -1,5 +1,7 @@
1
1
  import type { NdNodeRef } from "./generated/intrinsics.ts";
2
- export declare function executeJavaScript(node: NdNodeRef<"webview">, code: string, world?: string): Promise<string>;
2
+ export declare function executeJavaScript(node: NdNodeRef<"webview">, code: string, world?: string, options?: {
3
+ userGesture?: boolean;
4
+ }): Promise<string>;
3
5
  export declare function onJavaScriptResult(e: {
4
6
  data: unknown;
5
7
  }): void;
@@ -70,6 +72,7 @@ export interface ExtensionActionState {
70
72
  enabled: boolean;
71
73
  }
72
74
  export declare function readExtensionAction(node: NdNodeRef<"webview">): Promise<ExtensionActionState>;
75
+ export declare function triggerExtensionAction(node: NdNodeRef<"webview">, extensionId: string): Promise<void>;
73
76
  export declare function listExtensionActions(node: NdNodeRef<"webview">): Promise<ExtensionAction[]>;
74
77
  export declare function onExtensionActions(e: {
75
78
  data: unknown;
@@ -96,3 +99,23 @@ export interface ContextMenuItemClick {
96
99
  wasChecked?: boolean;
97
100
  }
98
101
  export declare function setContextMenuItems(node: NdNodeRef<"webview">, items: ContextMenuItem[]): void;
102
+ export interface DownloadRequest {
103
+ id?: string;
104
+ url: string;
105
+ suggestedFilename?: string;
106
+ }
107
+ export type DownloadState = "running" | "done" | "failed" | "cancelled";
108
+ export interface DownloadUpdate {
109
+ id: string;
110
+ state: DownloadState;
111
+ received: number;
112
+ total: number;
113
+ path: string;
114
+ speed?: number;
115
+ paused?: boolean;
116
+ }
117
+ export declare function respondDownload(node: NdNodeRef<"webview">, id: string, path?: string): void;
118
+ export declare function startDownload(node: NdNodeRef<"webview">, url: string): void;
119
+ export declare function pauseDownload(node: NdNodeRef<"webview">, id: string): void;
120
+ export declare function resumeDownload(node: NdNodeRef<"webview">, id: string): void;
121
+ export declare function cancelDownload(node: NdNodeRef<"webview">, id: string): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nativedesktop/react",
3
- "version": "0.4.41",
3
+ "version": "0.4.43",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/FormalSnake/NativeDesktop#readme",