Initial commit
This commit is contained in:
100
node_modules/@tauri-apps/api/menu/base.cjs
generated
vendored
Normal file
100
node_modules/@tauri-apps/api/menu/base.cjs
generated
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
'use strict';
|
||||
|
||||
var tslib_es6 = require('../external/tslib/tslib.es6.cjs');
|
||||
var core = require('../core.cjs');
|
||||
var image = require('../image.cjs');
|
||||
|
||||
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
var _MenuItemBase_id, _MenuItemBase_kind;
|
||||
function injectChannel(i) {
|
||||
var _a;
|
||||
if ('items' in i) {
|
||||
i.items = (_a = i.items) === null || _a === void 0 ? void 0 : _a.map((item) => 'rid' in item ? item : injectChannel(item));
|
||||
}
|
||||
else if ('action' in i && i.action) {
|
||||
const handler = new core.Channel();
|
||||
handler.onmessage = i.action;
|
||||
delete i.action;
|
||||
return { ...i, handler };
|
||||
}
|
||||
return i;
|
||||
}
|
||||
async function newMenu(kind, opts) {
|
||||
const handler = new core.Channel();
|
||||
if (opts && typeof opts === 'object') {
|
||||
if ('action' in opts && opts.action) {
|
||||
handler.onmessage = opts.action;
|
||||
delete opts.action;
|
||||
}
|
||||
// about predefined menu item icon
|
||||
if ('item' in opts
|
||||
&& opts.item
|
||||
&& typeof opts.item === 'object'
|
||||
&& 'About' in opts.item
|
||||
&& opts.item.About
|
||||
&& typeof opts.item.About === 'object'
|
||||
&& 'icon' in opts.item.About
|
||||
&& opts.item.About.icon) {
|
||||
opts.item.About.icon = image.transformImage(opts.item.About.icon);
|
||||
}
|
||||
// icon menu item icon
|
||||
if ('icon' in opts && opts.icon) {
|
||||
opts.icon = image.transformImage(opts.icon);
|
||||
}
|
||||
// submenu items
|
||||
if ('items' in opts && opts.items) {
|
||||
function prepareItem(i) {
|
||||
var _a;
|
||||
if ('rid' in i) {
|
||||
return [i.rid, i.kind];
|
||||
}
|
||||
if ('item' in i && typeof i.item === 'object' && ((_a = i.item.About) === null || _a === void 0 ? void 0 : _a.icon)) {
|
||||
i.item.About.icon = image.transformImage(i.item.About.icon);
|
||||
}
|
||||
if ('icon' in i && i.icon) {
|
||||
i.icon = image.transformImage(i.icon);
|
||||
}
|
||||
if ('items' in i && i.items) {
|
||||
// @ts-expect-error the `prepareItem` return doesn't exactly match
|
||||
// this is fine, because the difference is in `[number, string]` variant
|
||||
i.items = i.items.map(prepareItem);
|
||||
}
|
||||
return injectChannel(i);
|
||||
}
|
||||
// @ts-expect-error the `prepareItem` return doesn't exactly match
|
||||
// this is fine, because the difference is in `[number, string]` variant
|
||||
opts.items = opts.items.map(prepareItem);
|
||||
}
|
||||
}
|
||||
return core.invoke('plugin:menu|new', {
|
||||
kind,
|
||||
options: opts,
|
||||
handler
|
||||
});
|
||||
}
|
||||
class MenuItemBase extends core.Resource {
|
||||
/** The id of this item. */
|
||||
get id() {
|
||||
return tslib_es6.__classPrivateFieldGet(this, _MenuItemBase_id, "f");
|
||||
}
|
||||
/** @ignore */
|
||||
get kind() {
|
||||
return tslib_es6.__classPrivateFieldGet(this, _MenuItemBase_kind, "f");
|
||||
}
|
||||
/** @ignore */
|
||||
constructor(rid, id, kind) {
|
||||
super(rid);
|
||||
/** @ignore */
|
||||
_MenuItemBase_id.set(this, void 0);
|
||||
/** @ignore */
|
||||
_MenuItemBase_kind.set(this, void 0);
|
||||
tslib_es6.__classPrivateFieldSet(this, _MenuItemBase_id, id, "f");
|
||||
tslib_es6.__classPrivateFieldSet(this, _MenuItemBase_kind, kind, "f");
|
||||
}
|
||||
}
|
||||
_MenuItemBase_id = new WeakMap(), _MenuItemBase_kind = new WeakMap();
|
||||
|
||||
exports.MenuItemBase = MenuItemBase;
|
||||
exports.newMenu = newMenu;
|
||||
18
node_modules/@tauri-apps/api/menu/base.d.ts
generated
vendored
Normal file
18
node_modules/@tauri-apps/api/menu/base.d.ts
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
import { Resource } from '../core';
|
||||
import { CheckMenuItemOptions } from './checkMenuItem';
|
||||
import { IconMenuItemOptions } from './iconMenuItem';
|
||||
import { MenuOptions } from './menu';
|
||||
import { MenuItemOptions } from './menuItem';
|
||||
import { PredefinedMenuItemOptions } from './predefinedMenuItem';
|
||||
import { SubmenuOptions } from './submenu';
|
||||
export type ItemKind = 'MenuItem' | 'Predefined' | 'Check' | 'Icon' | 'Submenu' | 'Menu';
|
||||
export declare function newMenu(kind: ItemKind, opts?: MenuOptions | MenuItemOptions | SubmenuOptions | PredefinedMenuItemOptions | CheckMenuItemOptions | IconMenuItemOptions): Promise<[number, string]>;
|
||||
export declare class MenuItemBase extends Resource {
|
||||
#private;
|
||||
/** The id of this item. */
|
||||
get id(): string;
|
||||
/** @ignore */
|
||||
get kind(): string;
|
||||
/** @ignore */
|
||||
protected constructor(rid: number, id: string, kind: ItemKind);
|
||||
}
|
||||
97
node_modules/@tauri-apps/api/menu/base.js
generated
vendored
Normal file
97
node_modules/@tauri-apps/api/menu/base.js
generated
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
import { __classPrivateFieldGet, __classPrivateFieldSet } from '../external/tslib/tslib.es6.js';
|
||||
import { Resource, Channel, invoke } from '../core.js';
|
||||
import { transformImage } from '../image.js';
|
||||
|
||||
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
var _MenuItemBase_id, _MenuItemBase_kind;
|
||||
function injectChannel(i) {
|
||||
var _a;
|
||||
if ('items' in i) {
|
||||
i.items = (_a = i.items) === null || _a === void 0 ? void 0 : _a.map((item) => 'rid' in item ? item : injectChannel(item));
|
||||
}
|
||||
else if ('action' in i && i.action) {
|
||||
const handler = new Channel();
|
||||
handler.onmessage = i.action;
|
||||
delete i.action;
|
||||
return { ...i, handler };
|
||||
}
|
||||
return i;
|
||||
}
|
||||
async function newMenu(kind, opts) {
|
||||
const handler = new Channel();
|
||||
if (opts && typeof opts === 'object') {
|
||||
if ('action' in opts && opts.action) {
|
||||
handler.onmessage = opts.action;
|
||||
delete opts.action;
|
||||
}
|
||||
// about predefined menu item icon
|
||||
if ('item' in opts
|
||||
&& opts.item
|
||||
&& typeof opts.item === 'object'
|
||||
&& 'About' in opts.item
|
||||
&& opts.item.About
|
||||
&& typeof opts.item.About === 'object'
|
||||
&& 'icon' in opts.item.About
|
||||
&& opts.item.About.icon) {
|
||||
opts.item.About.icon = transformImage(opts.item.About.icon);
|
||||
}
|
||||
// icon menu item icon
|
||||
if ('icon' in opts && opts.icon) {
|
||||
opts.icon = transformImage(opts.icon);
|
||||
}
|
||||
// submenu items
|
||||
if ('items' in opts && opts.items) {
|
||||
function prepareItem(i) {
|
||||
var _a;
|
||||
if ('rid' in i) {
|
||||
return [i.rid, i.kind];
|
||||
}
|
||||
if ('item' in i && typeof i.item === 'object' && ((_a = i.item.About) === null || _a === void 0 ? void 0 : _a.icon)) {
|
||||
i.item.About.icon = transformImage(i.item.About.icon);
|
||||
}
|
||||
if ('icon' in i && i.icon) {
|
||||
i.icon = transformImage(i.icon);
|
||||
}
|
||||
if ('items' in i && i.items) {
|
||||
// @ts-expect-error the `prepareItem` return doesn't exactly match
|
||||
// this is fine, because the difference is in `[number, string]` variant
|
||||
i.items = i.items.map(prepareItem);
|
||||
}
|
||||
return injectChannel(i);
|
||||
}
|
||||
// @ts-expect-error the `prepareItem` return doesn't exactly match
|
||||
// this is fine, because the difference is in `[number, string]` variant
|
||||
opts.items = opts.items.map(prepareItem);
|
||||
}
|
||||
}
|
||||
return invoke('plugin:menu|new', {
|
||||
kind,
|
||||
options: opts,
|
||||
handler
|
||||
});
|
||||
}
|
||||
class MenuItemBase extends Resource {
|
||||
/** The id of this item. */
|
||||
get id() {
|
||||
return __classPrivateFieldGet(this, _MenuItemBase_id, "f");
|
||||
}
|
||||
/** @ignore */
|
||||
get kind() {
|
||||
return __classPrivateFieldGet(this, _MenuItemBase_kind, "f");
|
||||
}
|
||||
/** @ignore */
|
||||
constructor(rid, id, kind) {
|
||||
super(rid);
|
||||
/** @ignore */
|
||||
_MenuItemBase_id.set(this, void 0);
|
||||
/** @ignore */
|
||||
_MenuItemBase_kind.set(this, void 0);
|
||||
__classPrivateFieldSet(this, _MenuItemBase_id, id, "f");
|
||||
__classPrivateFieldSet(this, _MenuItemBase_kind, kind, "f");
|
||||
}
|
||||
}
|
||||
_MenuItemBase_id = new WeakMap(), _MenuItemBase_kind = new WeakMap();
|
||||
|
||||
export { MenuItemBase, newMenu };
|
||||
68
node_modules/@tauri-apps/api/menu/checkMenuItem.cjs
generated
vendored
Normal file
68
node_modules/@tauri-apps/api/menu/checkMenuItem.cjs
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
'use strict';
|
||||
|
||||
var base = require('./base.cjs');
|
||||
var core = require('../core.cjs');
|
||||
|
||||
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
/**
|
||||
* A check menu item inside a {@linkcode Menu} or {@linkcode Submenu}
|
||||
* and usually contains a text and a check mark or a similar toggle
|
||||
* that corresponds to a checked and unchecked states.
|
||||
*/
|
||||
class CheckMenuItem extends base.MenuItemBase {
|
||||
/** @ignore */
|
||||
constructor(rid, id) {
|
||||
super(rid, id, 'Check');
|
||||
}
|
||||
/** Create a new check menu item. */
|
||||
static async new(opts) {
|
||||
return base.newMenu('Check', opts).then(([rid, id]) => new CheckMenuItem(rid, id));
|
||||
}
|
||||
/** Returns the text of this check menu item. */
|
||||
async text() {
|
||||
return core.invoke('plugin:menu|text', { rid: this.rid, kind: this.kind });
|
||||
}
|
||||
/** Sets the text for this check menu item. */
|
||||
async setText(text) {
|
||||
return core.invoke('plugin:menu|set_text', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
text
|
||||
});
|
||||
}
|
||||
/** Returns whether this check menu item is enabled or not. */
|
||||
async isEnabled() {
|
||||
return core.invoke('plugin:menu|is_enabled', { rid: this.rid, kind: this.kind });
|
||||
}
|
||||
/** Sets whether this check menu item is enabled or not. */
|
||||
async setEnabled(enabled) {
|
||||
return core.invoke('plugin:menu|set_enabled', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
enabled
|
||||
});
|
||||
}
|
||||
/** Sets the accelerator for this check menu item. */
|
||||
async setAccelerator(accelerator) {
|
||||
return core.invoke('plugin:menu|set_accelerator', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
accelerator
|
||||
});
|
||||
}
|
||||
/** Returns whether this check menu item is checked or not. */
|
||||
async isChecked() {
|
||||
return core.invoke('plugin:menu|is_checked', { rid: this.rid });
|
||||
}
|
||||
/** Sets whether this check menu item is checked or not. */
|
||||
async setChecked(checked) {
|
||||
return core.invoke('plugin:menu|set_checked', {
|
||||
rid: this.rid,
|
||||
checked
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
exports.CheckMenuItem = CheckMenuItem;
|
||||
32
node_modules/@tauri-apps/api/menu/checkMenuItem.d.ts
generated
vendored
Normal file
32
node_modules/@tauri-apps/api/menu/checkMenuItem.d.ts
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
import { MenuItemBase } from './base';
|
||||
import { type MenuItemOptions } from '../menu';
|
||||
/** Options for creating a new check menu item. */
|
||||
export interface CheckMenuItemOptions extends MenuItemOptions {
|
||||
/** Whether the new check menu item is enabled or not. */
|
||||
checked?: boolean;
|
||||
}
|
||||
/**
|
||||
* A check menu item inside a {@linkcode Menu} or {@linkcode Submenu}
|
||||
* and usually contains a text and a check mark or a similar toggle
|
||||
* that corresponds to a checked and unchecked states.
|
||||
*/
|
||||
export declare class CheckMenuItem extends MenuItemBase {
|
||||
/** @ignore */
|
||||
protected constructor(rid: number, id: string);
|
||||
/** Create a new check menu item. */
|
||||
static new(opts: CheckMenuItemOptions): Promise<CheckMenuItem>;
|
||||
/** Returns the text of this check menu item. */
|
||||
text(): Promise<string>;
|
||||
/** Sets the text for this check menu item. */
|
||||
setText(text: string): Promise<void>;
|
||||
/** Returns whether this check menu item is enabled or not. */
|
||||
isEnabled(): Promise<boolean>;
|
||||
/** Sets whether this check menu item is enabled or not. */
|
||||
setEnabled(enabled: boolean): Promise<void>;
|
||||
/** Sets the accelerator for this check menu item. */
|
||||
setAccelerator(accelerator: string | null): Promise<void>;
|
||||
/** Returns whether this check menu item is checked or not. */
|
||||
isChecked(): Promise<boolean>;
|
||||
/** Sets whether this check menu item is checked or not. */
|
||||
setChecked(checked: boolean): Promise<void>;
|
||||
}
|
||||
66
node_modules/@tauri-apps/api/menu/checkMenuItem.js
generated
vendored
Normal file
66
node_modules/@tauri-apps/api/menu/checkMenuItem.js
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
import { MenuItemBase, newMenu } from './base.js';
|
||||
import { invoke } from '../core.js';
|
||||
|
||||
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
/**
|
||||
* A check menu item inside a {@linkcode Menu} or {@linkcode Submenu}
|
||||
* and usually contains a text and a check mark or a similar toggle
|
||||
* that corresponds to a checked and unchecked states.
|
||||
*/
|
||||
class CheckMenuItem extends MenuItemBase {
|
||||
/** @ignore */
|
||||
constructor(rid, id) {
|
||||
super(rid, id, 'Check');
|
||||
}
|
||||
/** Create a new check menu item. */
|
||||
static async new(opts) {
|
||||
return newMenu('Check', opts).then(([rid, id]) => new CheckMenuItem(rid, id));
|
||||
}
|
||||
/** Returns the text of this check menu item. */
|
||||
async text() {
|
||||
return invoke('plugin:menu|text', { rid: this.rid, kind: this.kind });
|
||||
}
|
||||
/** Sets the text for this check menu item. */
|
||||
async setText(text) {
|
||||
return invoke('plugin:menu|set_text', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
text
|
||||
});
|
||||
}
|
||||
/** Returns whether this check menu item is enabled or not. */
|
||||
async isEnabled() {
|
||||
return invoke('plugin:menu|is_enabled', { rid: this.rid, kind: this.kind });
|
||||
}
|
||||
/** Sets whether this check menu item is enabled or not. */
|
||||
async setEnabled(enabled) {
|
||||
return invoke('plugin:menu|set_enabled', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
enabled
|
||||
});
|
||||
}
|
||||
/** Sets the accelerator for this check menu item. */
|
||||
async setAccelerator(accelerator) {
|
||||
return invoke('plugin:menu|set_accelerator', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
accelerator
|
||||
});
|
||||
}
|
||||
/** Returns whether this check menu item is checked or not. */
|
||||
async isChecked() {
|
||||
return invoke('plugin:menu|is_checked', { rid: this.rid });
|
||||
}
|
||||
/** Sets whether this check menu item is checked or not. */
|
||||
async setChecked(checked) {
|
||||
return invoke('plugin:menu|set_checked', {
|
||||
rid: this.rid,
|
||||
checked
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export { CheckMenuItem };
|
||||
187
node_modules/@tauri-apps/api/menu/iconMenuItem.cjs
generated
vendored
Normal file
187
node_modules/@tauri-apps/api/menu/iconMenuItem.cjs
generated
vendored
Normal file
@@ -0,0 +1,187 @@
|
||||
'use strict';
|
||||
|
||||
var base = require('./base.cjs');
|
||||
var core = require('../core.cjs');
|
||||
var image = require('../image.cjs');
|
||||
|
||||
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
/**
|
||||
* A native Icon to be used for the menu item
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **Windows / Linux**: Unsupported.
|
||||
*/
|
||||
exports.NativeIcon = void 0;
|
||||
(function (NativeIcon) {
|
||||
/** An add item template image. */
|
||||
NativeIcon["Add"] = "Add";
|
||||
/** Advanced preferences toolbar icon for the preferences window. */
|
||||
NativeIcon["Advanced"] = "Advanced";
|
||||
/** A Bluetooth template image. */
|
||||
NativeIcon["Bluetooth"] = "Bluetooth";
|
||||
/** Bookmarks image suitable for a template. */
|
||||
NativeIcon["Bookmarks"] = "Bookmarks";
|
||||
/** A caution image. */
|
||||
NativeIcon["Caution"] = "Caution";
|
||||
/** A color panel toolbar icon. */
|
||||
NativeIcon["ColorPanel"] = "ColorPanel";
|
||||
/** A column view mode template image. */
|
||||
NativeIcon["ColumnView"] = "ColumnView";
|
||||
/** A computer icon. */
|
||||
NativeIcon["Computer"] = "Computer";
|
||||
/** An enter full-screen mode template image. */
|
||||
NativeIcon["EnterFullScreen"] = "EnterFullScreen";
|
||||
/** Permissions for all users. */
|
||||
NativeIcon["Everyone"] = "Everyone";
|
||||
/** An exit full-screen mode template image. */
|
||||
NativeIcon["ExitFullScreen"] = "ExitFullScreen";
|
||||
/** A cover flow view mode template image. */
|
||||
NativeIcon["FlowView"] = "FlowView";
|
||||
/** A folder image. */
|
||||
NativeIcon["Folder"] = "Folder";
|
||||
/** A burnable folder icon. */
|
||||
NativeIcon["FolderBurnable"] = "FolderBurnable";
|
||||
/** A smart folder icon. */
|
||||
NativeIcon["FolderSmart"] = "FolderSmart";
|
||||
/** A link template image. */
|
||||
NativeIcon["FollowLinkFreestanding"] = "FollowLinkFreestanding";
|
||||
/** A font panel toolbar icon. */
|
||||
NativeIcon["FontPanel"] = "FontPanel";
|
||||
/** A `go back` template image. */
|
||||
NativeIcon["GoLeft"] = "GoLeft";
|
||||
/** A `go forward` template image. */
|
||||
NativeIcon["GoRight"] = "GoRight";
|
||||
/** Home image suitable for a template. */
|
||||
NativeIcon["Home"] = "Home";
|
||||
/** An iChat Theater template image. */
|
||||
NativeIcon["IChatTheater"] = "IChatTheater";
|
||||
/** An icon view mode template image. */
|
||||
NativeIcon["IconView"] = "IconView";
|
||||
/** An information toolbar icon. */
|
||||
NativeIcon["Info"] = "Info";
|
||||
/** A template image used to denote invalid data. */
|
||||
NativeIcon["InvalidDataFreestanding"] = "InvalidDataFreestanding";
|
||||
/** A generic left-facing triangle template image. */
|
||||
NativeIcon["LeftFacingTriangle"] = "LeftFacingTriangle";
|
||||
/** A list view mode template image. */
|
||||
NativeIcon["ListView"] = "ListView";
|
||||
/** A locked padlock template image. */
|
||||
NativeIcon["LockLocked"] = "LockLocked";
|
||||
/** An unlocked padlock template image. */
|
||||
NativeIcon["LockUnlocked"] = "LockUnlocked";
|
||||
/** A horizontal dash, for use in menus. */
|
||||
NativeIcon["MenuMixedState"] = "MenuMixedState";
|
||||
/** A check mark template image, for use in menus. */
|
||||
NativeIcon["MenuOnState"] = "MenuOnState";
|
||||
/** A MobileMe icon. */
|
||||
NativeIcon["MobileMe"] = "MobileMe";
|
||||
/** A drag image for multiple items. */
|
||||
NativeIcon["MultipleDocuments"] = "MultipleDocuments";
|
||||
/** A network icon. */
|
||||
NativeIcon["Network"] = "Network";
|
||||
/** A path button template image. */
|
||||
NativeIcon["Path"] = "Path";
|
||||
/** General preferences toolbar icon for the preferences window. */
|
||||
NativeIcon["PreferencesGeneral"] = "PreferencesGeneral";
|
||||
/** A Quick Look template image. */
|
||||
NativeIcon["QuickLook"] = "QuickLook";
|
||||
/** A refresh template image. */
|
||||
NativeIcon["RefreshFreestanding"] = "RefreshFreestanding";
|
||||
/** A refresh template image. */
|
||||
NativeIcon["Refresh"] = "Refresh";
|
||||
/** A remove item template image. */
|
||||
NativeIcon["Remove"] = "Remove";
|
||||
/** A reveal contents template image. */
|
||||
NativeIcon["RevealFreestanding"] = "RevealFreestanding";
|
||||
/** A generic right-facing triangle template image. */
|
||||
NativeIcon["RightFacingTriangle"] = "RightFacingTriangle";
|
||||
/** A share view template image. */
|
||||
NativeIcon["Share"] = "Share";
|
||||
/** A slideshow template image. */
|
||||
NativeIcon["Slideshow"] = "Slideshow";
|
||||
/** A badge for a `smart` item. */
|
||||
NativeIcon["SmartBadge"] = "SmartBadge";
|
||||
/** Small green indicator, similar to iChat's available image. */
|
||||
NativeIcon["StatusAvailable"] = "StatusAvailable";
|
||||
/** Small clear indicator. */
|
||||
NativeIcon["StatusNone"] = "StatusNone";
|
||||
/** Small yellow indicator, similar to iChat's idle image. */
|
||||
NativeIcon["StatusPartiallyAvailable"] = "StatusPartiallyAvailable";
|
||||
/** Small red indicator, similar to iChat's unavailable image. */
|
||||
NativeIcon["StatusUnavailable"] = "StatusUnavailable";
|
||||
/** A stop progress template image. */
|
||||
NativeIcon["StopProgressFreestanding"] = "StopProgressFreestanding";
|
||||
/** A stop progress button template image. */
|
||||
NativeIcon["StopProgress"] = "StopProgress";
|
||||
/** An image of the empty trash can. */
|
||||
NativeIcon["TrashEmpty"] = "TrashEmpty";
|
||||
/** An image of the full trash can. */
|
||||
NativeIcon["TrashFull"] = "TrashFull";
|
||||
/** Permissions for a single user. */
|
||||
NativeIcon["User"] = "User";
|
||||
/** User account toolbar icon for the preferences window. */
|
||||
NativeIcon["UserAccounts"] = "UserAccounts";
|
||||
/** Permissions for a group of users. */
|
||||
NativeIcon["UserGroup"] = "UserGroup";
|
||||
/** Permissions for guests. */
|
||||
NativeIcon["UserGuest"] = "UserGuest";
|
||||
})(exports.NativeIcon || (exports.NativeIcon = {}));
|
||||
/**
|
||||
* An icon menu item inside a {@linkcode Menu} or {@linkcode Submenu}
|
||||
* and usually contains an icon and a text.
|
||||
*/
|
||||
class IconMenuItem extends base.MenuItemBase {
|
||||
/** @ignore */
|
||||
constructor(rid, id) {
|
||||
super(rid, id, 'Icon');
|
||||
}
|
||||
/** Create a new icon menu item. */
|
||||
static async new(opts) {
|
||||
return base.newMenu('Icon', opts).then(([rid, id]) => new IconMenuItem(rid, id));
|
||||
}
|
||||
/** Returns the text of this icon menu item. */
|
||||
async text() {
|
||||
return core.invoke('plugin:menu|text', { rid: this.rid, kind: this.kind });
|
||||
}
|
||||
/** Sets the text for this icon menu item. */
|
||||
async setText(text) {
|
||||
return core.invoke('plugin:menu|set_text', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
text
|
||||
});
|
||||
}
|
||||
/** Returns whether this icon menu item is enabled or not. */
|
||||
async isEnabled() {
|
||||
return core.invoke('plugin:menu|is_enabled', { rid: this.rid, kind: this.kind });
|
||||
}
|
||||
/** Sets whether this icon menu item is enabled or not. */
|
||||
async setEnabled(enabled) {
|
||||
return core.invoke('plugin:menu|set_enabled', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
enabled
|
||||
});
|
||||
}
|
||||
/** Sets the accelerator for this icon menu item. */
|
||||
async setAccelerator(accelerator) {
|
||||
return core.invoke('plugin:menu|set_accelerator', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
accelerator
|
||||
});
|
||||
}
|
||||
/** Sets an icon for this icon menu item */
|
||||
async setIcon(icon) {
|
||||
return core.invoke('plugin:menu|set_icon', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
icon: image.transformImage(icon)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
exports.IconMenuItem = IconMenuItem;
|
||||
160
node_modules/@tauri-apps/api/menu/iconMenuItem.d.ts
generated
vendored
Normal file
160
node_modules/@tauri-apps/api/menu/iconMenuItem.d.ts
generated
vendored
Normal file
@@ -0,0 +1,160 @@
|
||||
import { MenuItemBase } from './base';
|
||||
import { type MenuItemOptions } from '../menu';
|
||||
import { MenuIcon } from '../image';
|
||||
/**
|
||||
* A native Icon to be used for the menu item
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **Windows / Linux**: Unsupported.
|
||||
*/
|
||||
export declare enum NativeIcon {
|
||||
/** An add item template image. */
|
||||
Add = "Add",
|
||||
/** Advanced preferences toolbar icon for the preferences window. */
|
||||
Advanced = "Advanced",
|
||||
/** A Bluetooth template image. */
|
||||
Bluetooth = "Bluetooth",
|
||||
/** Bookmarks image suitable for a template. */
|
||||
Bookmarks = "Bookmarks",
|
||||
/** A caution image. */
|
||||
Caution = "Caution",
|
||||
/** A color panel toolbar icon. */
|
||||
ColorPanel = "ColorPanel",
|
||||
/** A column view mode template image. */
|
||||
ColumnView = "ColumnView",
|
||||
/** A computer icon. */
|
||||
Computer = "Computer",
|
||||
/** An enter full-screen mode template image. */
|
||||
EnterFullScreen = "EnterFullScreen",
|
||||
/** Permissions for all users. */
|
||||
Everyone = "Everyone",
|
||||
/** An exit full-screen mode template image. */
|
||||
ExitFullScreen = "ExitFullScreen",
|
||||
/** A cover flow view mode template image. */
|
||||
FlowView = "FlowView",
|
||||
/** A folder image. */
|
||||
Folder = "Folder",
|
||||
/** A burnable folder icon. */
|
||||
FolderBurnable = "FolderBurnable",
|
||||
/** A smart folder icon. */
|
||||
FolderSmart = "FolderSmart",
|
||||
/** A link template image. */
|
||||
FollowLinkFreestanding = "FollowLinkFreestanding",
|
||||
/** A font panel toolbar icon. */
|
||||
FontPanel = "FontPanel",
|
||||
/** A `go back` template image. */
|
||||
GoLeft = "GoLeft",
|
||||
/** A `go forward` template image. */
|
||||
GoRight = "GoRight",
|
||||
/** Home image suitable for a template. */
|
||||
Home = "Home",
|
||||
/** An iChat Theater template image. */
|
||||
IChatTheater = "IChatTheater",
|
||||
/** An icon view mode template image. */
|
||||
IconView = "IconView",
|
||||
/** An information toolbar icon. */
|
||||
Info = "Info",
|
||||
/** A template image used to denote invalid data. */
|
||||
InvalidDataFreestanding = "InvalidDataFreestanding",
|
||||
/** A generic left-facing triangle template image. */
|
||||
LeftFacingTriangle = "LeftFacingTriangle",
|
||||
/** A list view mode template image. */
|
||||
ListView = "ListView",
|
||||
/** A locked padlock template image. */
|
||||
LockLocked = "LockLocked",
|
||||
/** An unlocked padlock template image. */
|
||||
LockUnlocked = "LockUnlocked",
|
||||
/** A horizontal dash, for use in menus. */
|
||||
MenuMixedState = "MenuMixedState",
|
||||
/** A check mark template image, for use in menus. */
|
||||
MenuOnState = "MenuOnState",
|
||||
/** A MobileMe icon. */
|
||||
MobileMe = "MobileMe",
|
||||
/** A drag image for multiple items. */
|
||||
MultipleDocuments = "MultipleDocuments",
|
||||
/** A network icon. */
|
||||
Network = "Network",
|
||||
/** A path button template image. */
|
||||
Path = "Path",
|
||||
/** General preferences toolbar icon for the preferences window. */
|
||||
PreferencesGeneral = "PreferencesGeneral",
|
||||
/** A Quick Look template image. */
|
||||
QuickLook = "QuickLook",
|
||||
/** A refresh template image. */
|
||||
RefreshFreestanding = "RefreshFreestanding",
|
||||
/** A refresh template image. */
|
||||
Refresh = "Refresh",
|
||||
/** A remove item template image. */
|
||||
Remove = "Remove",
|
||||
/** A reveal contents template image. */
|
||||
RevealFreestanding = "RevealFreestanding",
|
||||
/** A generic right-facing triangle template image. */
|
||||
RightFacingTriangle = "RightFacingTriangle",
|
||||
/** A share view template image. */
|
||||
Share = "Share",
|
||||
/** A slideshow template image. */
|
||||
Slideshow = "Slideshow",
|
||||
/** A badge for a `smart` item. */
|
||||
SmartBadge = "SmartBadge",
|
||||
/** Small green indicator, similar to iChat's available image. */
|
||||
StatusAvailable = "StatusAvailable",
|
||||
/** Small clear indicator. */
|
||||
StatusNone = "StatusNone",
|
||||
/** Small yellow indicator, similar to iChat's idle image. */
|
||||
StatusPartiallyAvailable = "StatusPartiallyAvailable",
|
||||
/** Small red indicator, similar to iChat's unavailable image. */
|
||||
StatusUnavailable = "StatusUnavailable",
|
||||
/** A stop progress template image. */
|
||||
StopProgressFreestanding = "StopProgressFreestanding",
|
||||
/** A stop progress button template image. */
|
||||
StopProgress = "StopProgress",
|
||||
/** An image of the empty trash can. */
|
||||
TrashEmpty = "TrashEmpty",
|
||||
/** An image of the full trash can. */
|
||||
TrashFull = "TrashFull",
|
||||
/** Permissions for a single user. */
|
||||
User = "User",
|
||||
/** User account toolbar icon for the preferences window. */
|
||||
UserAccounts = "UserAccounts",
|
||||
/** Permissions for a group of users. */
|
||||
UserGroup = "UserGroup",
|
||||
/** Permissions for guests. */
|
||||
UserGuest = "UserGuest"
|
||||
}
|
||||
/** Options for creating a new icon menu item. */
|
||||
export interface IconMenuItemOptions extends MenuItemOptions {
|
||||
/**
|
||||
* Icon to be used for the new icon menu item.
|
||||
*
|
||||
* Note that you may need the `image-ico` or `image-png` Cargo features to use this API.
|
||||
* To enable it, change your Cargo.toml file:
|
||||
* ```toml
|
||||
* [dependencies]
|
||||
* tauri = { version = "...", features = ["...", "image-png"] }
|
||||
* ```
|
||||
*/
|
||||
icon?: MenuIcon;
|
||||
}
|
||||
/**
|
||||
* An icon menu item inside a {@linkcode Menu} or {@linkcode Submenu}
|
||||
* and usually contains an icon and a text.
|
||||
*/
|
||||
export declare class IconMenuItem extends MenuItemBase {
|
||||
/** @ignore */
|
||||
protected constructor(rid: number, id: string);
|
||||
/** Create a new icon menu item. */
|
||||
static new(opts: IconMenuItemOptions): Promise<IconMenuItem>;
|
||||
/** Returns the text of this icon menu item. */
|
||||
text(): Promise<string>;
|
||||
/** Sets the text for this icon menu item. */
|
||||
setText(text: string): Promise<void>;
|
||||
/** Returns whether this icon menu item is enabled or not. */
|
||||
isEnabled(): Promise<boolean>;
|
||||
/** Sets whether this icon menu item is enabled or not. */
|
||||
setEnabled(enabled: boolean): Promise<void>;
|
||||
/** Sets the accelerator for this icon menu item. */
|
||||
setAccelerator(accelerator: string | null): Promise<void>;
|
||||
/** Sets an icon for this icon menu item */
|
||||
setIcon(icon: MenuIcon | null): Promise<void>;
|
||||
}
|
||||
185
node_modules/@tauri-apps/api/menu/iconMenuItem.js
generated
vendored
Normal file
185
node_modules/@tauri-apps/api/menu/iconMenuItem.js
generated
vendored
Normal file
@@ -0,0 +1,185 @@
|
||||
import { MenuItemBase, newMenu } from './base.js';
|
||||
import { invoke } from '../core.js';
|
||||
import { transformImage } from '../image.js';
|
||||
|
||||
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
/**
|
||||
* A native Icon to be used for the menu item
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **Windows / Linux**: Unsupported.
|
||||
*/
|
||||
var NativeIcon;
|
||||
(function (NativeIcon) {
|
||||
/** An add item template image. */
|
||||
NativeIcon["Add"] = "Add";
|
||||
/** Advanced preferences toolbar icon for the preferences window. */
|
||||
NativeIcon["Advanced"] = "Advanced";
|
||||
/** A Bluetooth template image. */
|
||||
NativeIcon["Bluetooth"] = "Bluetooth";
|
||||
/** Bookmarks image suitable for a template. */
|
||||
NativeIcon["Bookmarks"] = "Bookmarks";
|
||||
/** A caution image. */
|
||||
NativeIcon["Caution"] = "Caution";
|
||||
/** A color panel toolbar icon. */
|
||||
NativeIcon["ColorPanel"] = "ColorPanel";
|
||||
/** A column view mode template image. */
|
||||
NativeIcon["ColumnView"] = "ColumnView";
|
||||
/** A computer icon. */
|
||||
NativeIcon["Computer"] = "Computer";
|
||||
/** An enter full-screen mode template image. */
|
||||
NativeIcon["EnterFullScreen"] = "EnterFullScreen";
|
||||
/** Permissions for all users. */
|
||||
NativeIcon["Everyone"] = "Everyone";
|
||||
/** An exit full-screen mode template image. */
|
||||
NativeIcon["ExitFullScreen"] = "ExitFullScreen";
|
||||
/** A cover flow view mode template image. */
|
||||
NativeIcon["FlowView"] = "FlowView";
|
||||
/** A folder image. */
|
||||
NativeIcon["Folder"] = "Folder";
|
||||
/** A burnable folder icon. */
|
||||
NativeIcon["FolderBurnable"] = "FolderBurnable";
|
||||
/** A smart folder icon. */
|
||||
NativeIcon["FolderSmart"] = "FolderSmart";
|
||||
/** A link template image. */
|
||||
NativeIcon["FollowLinkFreestanding"] = "FollowLinkFreestanding";
|
||||
/** A font panel toolbar icon. */
|
||||
NativeIcon["FontPanel"] = "FontPanel";
|
||||
/** A `go back` template image. */
|
||||
NativeIcon["GoLeft"] = "GoLeft";
|
||||
/** A `go forward` template image. */
|
||||
NativeIcon["GoRight"] = "GoRight";
|
||||
/** Home image suitable for a template. */
|
||||
NativeIcon["Home"] = "Home";
|
||||
/** An iChat Theater template image. */
|
||||
NativeIcon["IChatTheater"] = "IChatTheater";
|
||||
/** An icon view mode template image. */
|
||||
NativeIcon["IconView"] = "IconView";
|
||||
/** An information toolbar icon. */
|
||||
NativeIcon["Info"] = "Info";
|
||||
/** A template image used to denote invalid data. */
|
||||
NativeIcon["InvalidDataFreestanding"] = "InvalidDataFreestanding";
|
||||
/** A generic left-facing triangle template image. */
|
||||
NativeIcon["LeftFacingTriangle"] = "LeftFacingTriangle";
|
||||
/** A list view mode template image. */
|
||||
NativeIcon["ListView"] = "ListView";
|
||||
/** A locked padlock template image. */
|
||||
NativeIcon["LockLocked"] = "LockLocked";
|
||||
/** An unlocked padlock template image. */
|
||||
NativeIcon["LockUnlocked"] = "LockUnlocked";
|
||||
/** A horizontal dash, for use in menus. */
|
||||
NativeIcon["MenuMixedState"] = "MenuMixedState";
|
||||
/** A check mark template image, for use in menus. */
|
||||
NativeIcon["MenuOnState"] = "MenuOnState";
|
||||
/** A MobileMe icon. */
|
||||
NativeIcon["MobileMe"] = "MobileMe";
|
||||
/** A drag image for multiple items. */
|
||||
NativeIcon["MultipleDocuments"] = "MultipleDocuments";
|
||||
/** A network icon. */
|
||||
NativeIcon["Network"] = "Network";
|
||||
/** A path button template image. */
|
||||
NativeIcon["Path"] = "Path";
|
||||
/** General preferences toolbar icon for the preferences window. */
|
||||
NativeIcon["PreferencesGeneral"] = "PreferencesGeneral";
|
||||
/** A Quick Look template image. */
|
||||
NativeIcon["QuickLook"] = "QuickLook";
|
||||
/** A refresh template image. */
|
||||
NativeIcon["RefreshFreestanding"] = "RefreshFreestanding";
|
||||
/** A refresh template image. */
|
||||
NativeIcon["Refresh"] = "Refresh";
|
||||
/** A remove item template image. */
|
||||
NativeIcon["Remove"] = "Remove";
|
||||
/** A reveal contents template image. */
|
||||
NativeIcon["RevealFreestanding"] = "RevealFreestanding";
|
||||
/** A generic right-facing triangle template image. */
|
||||
NativeIcon["RightFacingTriangle"] = "RightFacingTriangle";
|
||||
/** A share view template image. */
|
||||
NativeIcon["Share"] = "Share";
|
||||
/** A slideshow template image. */
|
||||
NativeIcon["Slideshow"] = "Slideshow";
|
||||
/** A badge for a `smart` item. */
|
||||
NativeIcon["SmartBadge"] = "SmartBadge";
|
||||
/** Small green indicator, similar to iChat's available image. */
|
||||
NativeIcon["StatusAvailable"] = "StatusAvailable";
|
||||
/** Small clear indicator. */
|
||||
NativeIcon["StatusNone"] = "StatusNone";
|
||||
/** Small yellow indicator, similar to iChat's idle image. */
|
||||
NativeIcon["StatusPartiallyAvailable"] = "StatusPartiallyAvailable";
|
||||
/** Small red indicator, similar to iChat's unavailable image. */
|
||||
NativeIcon["StatusUnavailable"] = "StatusUnavailable";
|
||||
/** A stop progress template image. */
|
||||
NativeIcon["StopProgressFreestanding"] = "StopProgressFreestanding";
|
||||
/** A stop progress button template image. */
|
||||
NativeIcon["StopProgress"] = "StopProgress";
|
||||
/** An image of the empty trash can. */
|
||||
NativeIcon["TrashEmpty"] = "TrashEmpty";
|
||||
/** An image of the full trash can. */
|
||||
NativeIcon["TrashFull"] = "TrashFull";
|
||||
/** Permissions for a single user. */
|
||||
NativeIcon["User"] = "User";
|
||||
/** User account toolbar icon for the preferences window. */
|
||||
NativeIcon["UserAccounts"] = "UserAccounts";
|
||||
/** Permissions for a group of users. */
|
||||
NativeIcon["UserGroup"] = "UserGroup";
|
||||
/** Permissions for guests. */
|
||||
NativeIcon["UserGuest"] = "UserGuest";
|
||||
})(NativeIcon || (NativeIcon = {}));
|
||||
/**
|
||||
* An icon menu item inside a {@linkcode Menu} or {@linkcode Submenu}
|
||||
* and usually contains an icon and a text.
|
||||
*/
|
||||
class IconMenuItem extends MenuItemBase {
|
||||
/** @ignore */
|
||||
constructor(rid, id) {
|
||||
super(rid, id, 'Icon');
|
||||
}
|
||||
/** Create a new icon menu item. */
|
||||
static async new(opts) {
|
||||
return newMenu('Icon', opts).then(([rid, id]) => new IconMenuItem(rid, id));
|
||||
}
|
||||
/** Returns the text of this icon menu item. */
|
||||
async text() {
|
||||
return invoke('plugin:menu|text', { rid: this.rid, kind: this.kind });
|
||||
}
|
||||
/** Sets the text for this icon menu item. */
|
||||
async setText(text) {
|
||||
return invoke('plugin:menu|set_text', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
text
|
||||
});
|
||||
}
|
||||
/** Returns whether this icon menu item is enabled or not. */
|
||||
async isEnabled() {
|
||||
return invoke('plugin:menu|is_enabled', { rid: this.rid, kind: this.kind });
|
||||
}
|
||||
/** Sets whether this icon menu item is enabled or not. */
|
||||
async setEnabled(enabled) {
|
||||
return invoke('plugin:menu|set_enabled', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
enabled
|
||||
});
|
||||
}
|
||||
/** Sets the accelerator for this icon menu item. */
|
||||
async setAccelerator(accelerator) {
|
||||
return invoke('plugin:menu|set_accelerator', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
accelerator
|
||||
});
|
||||
}
|
||||
/** Sets an icon for this icon menu item */
|
||||
async setIcon(icon) {
|
||||
return invoke('plugin:menu|set_icon', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
icon: transformImage(icon)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export { IconMenuItem, NativeIcon };
|
||||
148
node_modules/@tauri-apps/api/menu/menu.cjs
generated
vendored
Normal file
148
node_modules/@tauri-apps/api/menu/menu.cjs
generated
vendored
Normal file
@@ -0,0 +1,148 @@
|
||||
'use strict';
|
||||
|
||||
var submenu = require('./submenu.cjs');
|
||||
var dpi = require('../dpi.cjs');
|
||||
var core = require('../core.cjs');
|
||||
var base = require('./base.cjs');
|
||||
|
||||
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
/** A type that is either a menu bar on the window
|
||||
* on Windows and Linux or as a global menu in the menubar on macOS.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **macOS**: if using {@linkcode Menu} for the global menubar, it can only contain {@linkcode Submenu}s.
|
||||
*/
|
||||
class Menu extends base.MenuItemBase {
|
||||
/** @ignore */
|
||||
constructor(rid, id) {
|
||||
super(rid, id, 'Menu');
|
||||
}
|
||||
/** Create a new menu. */
|
||||
static async new(opts) {
|
||||
return base.newMenu('Menu', opts).then(([rid, id]) => new Menu(rid, id));
|
||||
}
|
||||
/** Create a default menu. */
|
||||
static async default() {
|
||||
return core.invoke('plugin:menu|create_default').then(([rid, id]) => new Menu(rid, id));
|
||||
}
|
||||
/**
|
||||
* Add a menu item to the end of this menu.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **macOS:** Only {@linkcode Submenu}s can be added to a {@linkcode Menu}.
|
||||
*/
|
||||
async append(items) {
|
||||
return core.invoke('plugin:menu|append', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
items: (Array.isArray(items) ? items : [items]).map((i) => 'rid' in i ? [i.rid, i.kind] : i)
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Add a menu item to the beginning of this menu.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **macOS:** Only {@linkcode Submenu}s can be added to a {@linkcode Menu}.
|
||||
*/
|
||||
async prepend(items) {
|
||||
return core.invoke('plugin:menu|prepend', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
items: (Array.isArray(items) ? items : [items]).map((i) => 'rid' in i ? [i.rid, i.kind] : i)
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Add a menu item to the specified position in this menu.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **macOS:** Only {@linkcode Submenu}s can be added to a {@linkcode Menu}.
|
||||
*/
|
||||
async insert(items, position) {
|
||||
return core.invoke('plugin:menu|insert', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
items: (Array.isArray(items) ? items : [items]).map((i) => 'rid' in i ? [i.rid, i.kind] : i),
|
||||
position
|
||||
});
|
||||
}
|
||||
/** Remove a menu item from this menu. */
|
||||
async remove(item) {
|
||||
return core.invoke('plugin:menu|remove', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
item: [item.rid, item.kind]
|
||||
});
|
||||
}
|
||||
/** Remove a menu item from this menu at the specified position. */
|
||||
async removeAt(position) {
|
||||
return core.invoke('plugin:menu|remove_at', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
position
|
||||
}).then(submenu.itemFromKind);
|
||||
}
|
||||
/** Returns a list of menu items that has been added to this menu. */
|
||||
async items() {
|
||||
return core.invoke('plugin:menu|items', {
|
||||
rid: this.rid,
|
||||
kind: this.kind
|
||||
}).then((i) => i.map(submenu.itemFromKind));
|
||||
}
|
||||
/** Retrieves the menu item matching the given identifier. */
|
||||
async get(id) {
|
||||
return core.invoke('plugin:menu|get', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
id
|
||||
}).then((r) => (r ? submenu.itemFromKind(r) : null));
|
||||
}
|
||||
/**
|
||||
* Popup this menu as a context menu on the specified window.
|
||||
*
|
||||
* @param at If a position is provided, it is relative to the window's top-left corner.
|
||||
* If there isn't one provided, the menu will pop up at the current location of the mouse.
|
||||
*/
|
||||
async popup(at, window) {
|
||||
var _a;
|
||||
return core.invoke('plugin:menu|popup', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
window: (_a = window === null || window === void 0 ? void 0 : window.label) !== null && _a !== void 0 ? _a : null,
|
||||
at: at instanceof dpi.Position ? at : at ? new dpi.Position(at) : null
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Sets the app-wide menu and returns the previous one.
|
||||
*
|
||||
* If a window was not created with an explicit menu or had one set explicitly,
|
||||
* this menu will be assigned to it.
|
||||
*/
|
||||
async setAsAppMenu() {
|
||||
return core.invoke('plugin:menu|set_as_app_menu', {
|
||||
rid: this.rid
|
||||
}).then((r) => (r ? new Menu(r[0], r[1]) : null));
|
||||
}
|
||||
/**
|
||||
* Sets the window menu and returns the previous one.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **macOS:** Unsupported. The menu on macOS is app-wide and not specific to one
|
||||
* window, if you need to set it, use {@linkcode Menu.setAsAppMenu} instead.
|
||||
*/
|
||||
async setAsWindowMenu(window) {
|
||||
var _a;
|
||||
return core.invoke('plugin:menu|set_as_window_menu', {
|
||||
rid: this.rid,
|
||||
window: (_a = window === null || window === void 0 ? void 0 : window.label) !== null && _a !== void 0 ? _a : null
|
||||
}).then((r) => (r ? new Menu(r[0], r[1]) : null));
|
||||
}
|
||||
}
|
||||
|
||||
exports.Menu = Menu;
|
||||
86
node_modules/@tauri-apps/api/menu/menu.d.ts
generated
vendored
Normal file
86
node_modules/@tauri-apps/api/menu/menu.d.ts
generated
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
import { MenuItemOptions, SubmenuOptions, IconMenuItemOptions, PredefinedMenuItemOptions, CheckMenuItemOptions } from '../menu';
|
||||
import { MenuItem } from './menuItem';
|
||||
import { CheckMenuItem } from './checkMenuItem';
|
||||
import { IconMenuItem } from './iconMenuItem';
|
||||
import { PredefinedMenuItem } from './predefinedMenuItem';
|
||||
import { Submenu } from './submenu';
|
||||
import { type LogicalPosition, PhysicalPosition, Position } from '../dpi';
|
||||
import { type Window } from '../window';
|
||||
import { MenuItemBase } from './base';
|
||||
/** Options for creating a new menu. */
|
||||
export interface MenuOptions {
|
||||
/** Specify an id to use for the new menu. */
|
||||
id?: string;
|
||||
/** List of items to add to the new menu. */
|
||||
items?: Array<Submenu | MenuItem | PredefinedMenuItem | CheckMenuItem | IconMenuItem | MenuItemOptions | SubmenuOptions | IconMenuItemOptions | PredefinedMenuItemOptions | CheckMenuItemOptions>;
|
||||
}
|
||||
/** A type that is either a menu bar on the window
|
||||
* on Windows and Linux or as a global menu in the menubar on macOS.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **macOS**: if using {@linkcode Menu} for the global menubar, it can only contain {@linkcode Submenu}s.
|
||||
*/
|
||||
export declare class Menu extends MenuItemBase {
|
||||
/** @ignore */
|
||||
protected constructor(rid: number, id: string);
|
||||
/** Create a new menu. */
|
||||
static new(opts?: MenuOptions): Promise<Menu>;
|
||||
/** Create a default menu. */
|
||||
static default(): Promise<Menu>;
|
||||
/**
|
||||
* Add a menu item to the end of this menu.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **macOS:** Only {@linkcode Submenu}s can be added to a {@linkcode Menu}.
|
||||
*/
|
||||
append<T extends Submenu | MenuItem | PredefinedMenuItem | CheckMenuItem | IconMenuItem | MenuItemOptions | SubmenuOptions | IconMenuItemOptions | PredefinedMenuItemOptions | CheckMenuItemOptions>(items: T | T[]): Promise<void>;
|
||||
/**
|
||||
* Add a menu item to the beginning of this menu.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **macOS:** Only {@linkcode Submenu}s can be added to a {@linkcode Menu}.
|
||||
*/
|
||||
prepend<T extends Submenu | MenuItem | PredefinedMenuItem | CheckMenuItem | IconMenuItem | MenuItemOptions | SubmenuOptions | IconMenuItemOptions | PredefinedMenuItemOptions | CheckMenuItemOptions>(items: T | T[]): Promise<void>;
|
||||
/**
|
||||
* Add a menu item to the specified position in this menu.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **macOS:** Only {@linkcode Submenu}s can be added to a {@linkcode Menu}.
|
||||
*/
|
||||
insert<T extends Submenu | MenuItem | PredefinedMenuItem | CheckMenuItem | IconMenuItem | MenuItemOptions | SubmenuOptions | IconMenuItemOptions | PredefinedMenuItemOptions | CheckMenuItemOptions>(items: T | T[], position: number): Promise<void>;
|
||||
/** Remove a menu item from this menu. */
|
||||
remove(item: Submenu | MenuItem | PredefinedMenuItem | CheckMenuItem | IconMenuItem): Promise<void>;
|
||||
/** Remove a menu item from this menu at the specified position. */
|
||||
removeAt(position: number): Promise<Submenu | MenuItem | PredefinedMenuItem | CheckMenuItem | IconMenuItem | null>;
|
||||
/** Returns a list of menu items that has been added to this menu. */
|
||||
items(): Promise<Array<Submenu | MenuItem | PredefinedMenuItem | CheckMenuItem | IconMenuItem>>;
|
||||
/** Retrieves the menu item matching the given identifier. */
|
||||
get(id: string): Promise<Submenu | MenuItem | PredefinedMenuItem | CheckMenuItem | IconMenuItem | null>;
|
||||
/**
|
||||
* Popup this menu as a context menu on the specified window.
|
||||
*
|
||||
* @param at If a position is provided, it is relative to the window's top-left corner.
|
||||
* If there isn't one provided, the menu will pop up at the current location of the mouse.
|
||||
*/
|
||||
popup(at?: PhysicalPosition | LogicalPosition | Position, window?: Window): Promise<void>;
|
||||
/**
|
||||
* Sets the app-wide menu and returns the previous one.
|
||||
*
|
||||
* If a window was not created with an explicit menu or had one set explicitly,
|
||||
* this menu will be assigned to it.
|
||||
*/
|
||||
setAsAppMenu(): Promise<Menu | null>;
|
||||
/**
|
||||
* Sets the window menu and returns the previous one.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **macOS:** Unsupported. The menu on macOS is app-wide and not specific to one
|
||||
* window, if you need to set it, use {@linkcode Menu.setAsAppMenu} instead.
|
||||
*/
|
||||
setAsWindowMenu(window?: Window): Promise<Menu | null>;
|
||||
}
|
||||
146
node_modules/@tauri-apps/api/menu/menu.js
generated
vendored
Normal file
146
node_modules/@tauri-apps/api/menu/menu.js
generated
vendored
Normal file
@@ -0,0 +1,146 @@
|
||||
import { itemFromKind } from './submenu.js';
|
||||
import { Position } from '../dpi.js';
|
||||
import { invoke } from '../core.js';
|
||||
import { MenuItemBase, newMenu } from './base.js';
|
||||
|
||||
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
/** A type that is either a menu bar on the window
|
||||
* on Windows and Linux or as a global menu in the menubar on macOS.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **macOS**: if using {@linkcode Menu} for the global menubar, it can only contain {@linkcode Submenu}s.
|
||||
*/
|
||||
class Menu extends MenuItemBase {
|
||||
/** @ignore */
|
||||
constructor(rid, id) {
|
||||
super(rid, id, 'Menu');
|
||||
}
|
||||
/** Create a new menu. */
|
||||
static async new(opts) {
|
||||
return newMenu('Menu', opts).then(([rid, id]) => new Menu(rid, id));
|
||||
}
|
||||
/** Create a default menu. */
|
||||
static async default() {
|
||||
return invoke('plugin:menu|create_default').then(([rid, id]) => new Menu(rid, id));
|
||||
}
|
||||
/**
|
||||
* Add a menu item to the end of this menu.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **macOS:** Only {@linkcode Submenu}s can be added to a {@linkcode Menu}.
|
||||
*/
|
||||
async append(items) {
|
||||
return invoke('plugin:menu|append', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
items: (Array.isArray(items) ? items : [items]).map((i) => 'rid' in i ? [i.rid, i.kind] : i)
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Add a menu item to the beginning of this menu.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **macOS:** Only {@linkcode Submenu}s can be added to a {@linkcode Menu}.
|
||||
*/
|
||||
async prepend(items) {
|
||||
return invoke('plugin:menu|prepend', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
items: (Array.isArray(items) ? items : [items]).map((i) => 'rid' in i ? [i.rid, i.kind] : i)
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Add a menu item to the specified position in this menu.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **macOS:** Only {@linkcode Submenu}s can be added to a {@linkcode Menu}.
|
||||
*/
|
||||
async insert(items, position) {
|
||||
return invoke('plugin:menu|insert', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
items: (Array.isArray(items) ? items : [items]).map((i) => 'rid' in i ? [i.rid, i.kind] : i),
|
||||
position
|
||||
});
|
||||
}
|
||||
/** Remove a menu item from this menu. */
|
||||
async remove(item) {
|
||||
return invoke('plugin:menu|remove', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
item: [item.rid, item.kind]
|
||||
});
|
||||
}
|
||||
/** Remove a menu item from this menu at the specified position. */
|
||||
async removeAt(position) {
|
||||
return invoke('plugin:menu|remove_at', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
position
|
||||
}).then(itemFromKind);
|
||||
}
|
||||
/** Returns a list of menu items that has been added to this menu. */
|
||||
async items() {
|
||||
return invoke('plugin:menu|items', {
|
||||
rid: this.rid,
|
||||
kind: this.kind
|
||||
}).then((i) => i.map(itemFromKind));
|
||||
}
|
||||
/** Retrieves the menu item matching the given identifier. */
|
||||
async get(id) {
|
||||
return invoke('plugin:menu|get', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
id
|
||||
}).then((r) => (r ? itemFromKind(r) : null));
|
||||
}
|
||||
/**
|
||||
* Popup this menu as a context menu on the specified window.
|
||||
*
|
||||
* @param at If a position is provided, it is relative to the window's top-left corner.
|
||||
* If there isn't one provided, the menu will pop up at the current location of the mouse.
|
||||
*/
|
||||
async popup(at, window) {
|
||||
var _a;
|
||||
return invoke('plugin:menu|popup', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
window: (_a = window === null || window === void 0 ? void 0 : window.label) !== null && _a !== void 0 ? _a : null,
|
||||
at: at instanceof Position ? at : at ? new Position(at) : null
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Sets the app-wide menu and returns the previous one.
|
||||
*
|
||||
* If a window was not created with an explicit menu or had one set explicitly,
|
||||
* this menu will be assigned to it.
|
||||
*/
|
||||
async setAsAppMenu() {
|
||||
return invoke('plugin:menu|set_as_app_menu', {
|
||||
rid: this.rid
|
||||
}).then((r) => (r ? new Menu(r[0], r[1]) : null));
|
||||
}
|
||||
/**
|
||||
* Sets the window menu and returns the previous one.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **macOS:** Unsupported. The menu on macOS is app-wide and not specific to one
|
||||
* window, if you need to set it, use {@linkcode Menu.setAsAppMenu} instead.
|
||||
*/
|
||||
async setAsWindowMenu(window) {
|
||||
var _a;
|
||||
return invoke('plugin:menu|set_as_window_menu', {
|
||||
rid: this.rid,
|
||||
window: (_a = window === null || window === void 0 ? void 0 : window.label) !== null && _a !== void 0 ? _a : null
|
||||
}).then((r) => (r ? new Menu(r[0], r[1]) : null));
|
||||
}
|
||||
}
|
||||
|
||||
export { Menu };
|
||||
53
node_modules/@tauri-apps/api/menu/menuItem.cjs
generated
vendored
Normal file
53
node_modules/@tauri-apps/api/menu/menuItem.cjs
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
'use strict';
|
||||
|
||||
var base = require('./base.cjs');
|
||||
var core = require('../core.cjs');
|
||||
|
||||
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
/** A menu item inside a {@linkcode Menu} or {@linkcode Submenu} and contains only text. */
|
||||
class MenuItem extends base.MenuItemBase {
|
||||
/** @ignore */
|
||||
constructor(rid, id) {
|
||||
super(rid, id, 'MenuItem');
|
||||
}
|
||||
/** Create a new menu item. */
|
||||
static async new(opts) {
|
||||
return base.newMenu('MenuItem', opts).then(([rid, id]) => new MenuItem(rid, id));
|
||||
}
|
||||
/** Returns the text of this menu item. */
|
||||
async text() {
|
||||
return core.invoke('plugin:menu|text', { rid: this.rid, kind: this.kind });
|
||||
}
|
||||
/** Sets the text for this menu item. */
|
||||
async setText(text) {
|
||||
return core.invoke('plugin:menu|set_text', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
text
|
||||
});
|
||||
}
|
||||
/** Returns whether this menu item is enabled or not. */
|
||||
async isEnabled() {
|
||||
return core.invoke('plugin:menu|is_enabled', { rid: this.rid, kind: this.kind });
|
||||
}
|
||||
/** Sets whether this menu item is enabled or not. */
|
||||
async setEnabled(enabled) {
|
||||
return core.invoke('plugin:menu|set_enabled', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
enabled
|
||||
});
|
||||
}
|
||||
/** Sets the accelerator for this menu item. */
|
||||
async setAccelerator(accelerator) {
|
||||
return core.invoke('plugin:menu|set_accelerator', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
accelerator
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
exports.MenuItem = MenuItem;
|
||||
31
node_modules/@tauri-apps/api/menu/menuItem.d.ts
generated
vendored
Normal file
31
node_modules/@tauri-apps/api/menu/menuItem.d.ts
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
import { MenuItemBase } from './base';
|
||||
/** Options for creating a new menu item. */
|
||||
export interface MenuItemOptions {
|
||||
/** Specify an id to use for the new menu item. */
|
||||
id?: string;
|
||||
/** The text of the new menu item. */
|
||||
text: string;
|
||||
/** Whether the new menu item is enabled or not. */
|
||||
enabled?: boolean;
|
||||
/** Specify an accelerator for the new menu item. */
|
||||
accelerator?: string;
|
||||
/** Specify a handler to be called when this menu item is activated. */
|
||||
action?: (id: string) => void;
|
||||
}
|
||||
/** A menu item inside a {@linkcode Menu} or {@linkcode Submenu} and contains only text. */
|
||||
export declare class MenuItem extends MenuItemBase {
|
||||
/** @ignore */
|
||||
protected constructor(rid: number, id: string);
|
||||
/** Create a new menu item. */
|
||||
static new(opts: MenuItemOptions): Promise<MenuItem>;
|
||||
/** Returns the text of this menu item. */
|
||||
text(): Promise<string>;
|
||||
/** Sets the text for this menu item. */
|
||||
setText(text: string): Promise<void>;
|
||||
/** Returns whether this menu item is enabled or not. */
|
||||
isEnabled(): Promise<boolean>;
|
||||
/** Sets whether this menu item is enabled or not. */
|
||||
setEnabled(enabled: boolean): Promise<void>;
|
||||
/** Sets the accelerator for this menu item. */
|
||||
setAccelerator(accelerator: string | null): Promise<void>;
|
||||
}
|
||||
51
node_modules/@tauri-apps/api/menu/menuItem.js
generated
vendored
Normal file
51
node_modules/@tauri-apps/api/menu/menuItem.js
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
import { MenuItemBase, newMenu } from './base.js';
|
||||
import { invoke } from '../core.js';
|
||||
|
||||
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
/** A menu item inside a {@linkcode Menu} or {@linkcode Submenu} and contains only text. */
|
||||
class MenuItem extends MenuItemBase {
|
||||
/** @ignore */
|
||||
constructor(rid, id) {
|
||||
super(rid, id, 'MenuItem');
|
||||
}
|
||||
/** Create a new menu item. */
|
||||
static async new(opts) {
|
||||
return newMenu('MenuItem', opts).then(([rid, id]) => new MenuItem(rid, id));
|
||||
}
|
||||
/** Returns the text of this menu item. */
|
||||
async text() {
|
||||
return invoke('plugin:menu|text', { rid: this.rid, kind: this.kind });
|
||||
}
|
||||
/** Sets the text for this menu item. */
|
||||
async setText(text) {
|
||||
return invoke('plugin:menu|set_text', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
text
|
||||
});
|
||||
}
|
||||
/** Returns whether this menu item is enabled or not. */
|
||||
async isEnabled() {
|
||||
return invoke('plugin:menu|is_enabled', { rid: this.rid, kind: this.kind });
|
||||
}
|
||||
/** Sets whether this menu item is enabled or not. */
|
||||
async setEnabled(enabled) {
|
||||
return invoke('plugin:menu|set_enabled', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
enabled
|
||||
});
|
||||
}
|
||||
/** Sets the accelerator for this menu item. */
|
||||
async setAccelerator(accelerator) {
|
||||
return invoke('plugin:menu|set_accelerator', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
accelerator
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export { MenuItem };
|
||||
33
node_modules/@tauri-apps/api/menu/predefinedMenuItem.cjs
generated
vendored
Normal file
33
node_modules/@tauri-apps/api/menu/predefinedMenuItem.cjs
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
'use strict';
|
||||
|
||||
var base = require('./base.cjs');
|
||||
var core = require('../core.cjs');
|
||||
|
||||
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
/** A predefined (native) menu item which has a predefined behavior by the OS or by tauri. */
|
||||
class PredefinedMenuItem extends base.MenuItemBase {
|
||||
/** @ignore */
|
||||
constructor(rid, id) {
|
||||
super(rid, id, 'Predefined');
|
||||
}
|
||||
/** Create a new predefined menu item. */
|
||||
static async new(opts) {
|
||||
return base.newMenu('Predefined', opts).then(([rid, id]) => new PredefinedMenuItem(rid, id));
|
||||
}
|
||||
/** Returns the text of this predefined menu item. */
|
||||
async text() {
|
||||
return core.invoke('plugin:menu|text', { rid: this.rid, kind: this.kind });
|
||||
}
|
||||
/** Sets the text for this predefined menu item. */
|
||||
async setText(text) {
|
||||
return core.invoke('plugin:menu|set_text', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
text
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
exports.PredefinedMenuItem = PredefinedMenuItem;
|
||||
95
node_modules/@tauri-apps/api/menu/predefinedMenuItem.d.ts
generated
vendored
Normal file
95
node_modules/@tauri-apps/api/menu/predefinedMenuItem.d.ts
generated
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
import { MenuItemBase } from './base';
|
||||
import { Image } from '../image';
|
||||
/** A metadata for the about predefined menu item. */
|
||||
export interface AboutMetadata {
|
||||
/** Sets the application name. */
|
||||
name?: string;
|
||||
/** The application version. */
|
||||
version?: string;
|
||||
/**
|
||||
* The short version, e.g. "1.0".
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Windows / Linux:** Appended to the end of `version` in parentheses.
|
||||
*/
|
||||
shortVersion?: string;
|
||||
/**
|
||||
* The authors of the application.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **macOS:** Unsupported.
|
||||
*/
|
||||
authors?: string[];
|
||||
/**
|
||||
* Application comments.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **macOS:** Unsupported.
|
||||
*/
|
||||
comments?: string;
|
||||
/** The copyright of the application. */
|
||||
copyright?: string;
|
||||
/**
|
||||
* The license of the application.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **macOS:** Unsupported.
|
||||
*/
|
||||
license?: string;
|
||||
/**
|
||||
* The application website.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **macOS:** Unsupported.
|
||||
*/
|
||||
website?: string;
|
||||
/**
|
||||
* The website label.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **macOS:** Unsupported.
|
||||
*/
|
||||
websiteLabel?: string;
|
||||
/**
|
||||
* The credits.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Windows / Linux:** Unsupported.
|
||||
*/
|
||||
credits?: string;
|
||||
/**
|
||||
* The application icon.
|
||||
*
|
||||
* #### Platform-specific
|
||||
*
|
||||
* - **Windows:** Unsupported.
|
||||
*/
|
||||
icon?: string | Uint8Array | ArrayBuffer | number[] | Image;
|
||||
}
|
||||
/** Options for creating a new predefined menu item. */
|
||||
export interface PredefinedMenuItemOptions {
|
||||
/** The text of the new predefined menu item. */
|
||||
text?: string;
|
||||
/** The predefined item type */
|
||||
item: 'Separator' | 'Copy' | 'Cut' | 'Paste' | 'SelectAll' | 'Undo' | 'Redo' | 'Minimize' | 'Maximize' | 'Fullscreen' | 'Hide' | 'HideOthers' | 'ShowAll' | 'CloseWindow' | 'Quit' | 'Services' | 'BringAllToFront' | {
|
||||
About: AboutMetadata | null;
|
||||
};
|
||||
}
|
||||
/** A predefined (native) menu item which has a predefined behavior by the OS or by tauri. */
|
||||
export declare class PredefinedMenuItem extends MenuItemBase {
|
||||
/** @ignore */
|
||||
protected constructor(rid: number, id: string);
|
||||
/** Create a new predefined menu item. */
|
||||
static new(opts?: PredefinedMenuItemOptions): Promise<PredefinedMenuItem>;
|
||||
/** Returns the text of this predefined menu item. */
|
||||
text(): Promise<string>;
|
||||
/** Sets the text for this predefined menu item. */
|
||||
setText(text: string): Promise<void>;
|
||||
}
|
||||
31
node_modules/@tauri-apps/api/menu/predefinedMenuItem.js
generated
vendored
Normal file
31
node_modules/@tauri-apps/api/menu/predefinedMenuItem.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
import { MenuItemBase, newMenu } from './base.js';
|
||||
import { invoke } from '../core.js';
|
||||
|
||||
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
/** A predefined (native) menu item which has a predefined behavior by the OS or by tauri. */
|
||||
class PredefinedMenuItem extends MenuItemBase {
|
||||
/** @ignore */
|
||||
constructor(rid, id) {
|
||||
super(rid, id, 'Predefined');
|
||||
}
|
||||
/** Create a new predefined menu item. */
|
||||
static async new(opts) {
|
||||
return newMenu('Predefined', opts).then(([rid, id]) => new PredefinedMenuItem(rid, id));
|
||||
}
|
||||
/** Returns the text of this predefined menu item. */
|
||||
async text() {
|
||||
return invoke('plugin:menu|text', { rid: this.rid, kind: this.kind });
|
||||
}
|
||||
/** Sets the text for this predefined menu item. */
|
||||
async setText(text) {
|
||||
return invoke('plugin:menu|set_text', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
text
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export { PredefinedMenuItem };
|
||||
203
node_modules/@tauri-apps/api/menu/submenu.cjs
generated
vendored
Normal file
203
node_modules/@tauri-apps/api/menu/submenu.cjs
generated
vendored
Normal file
@@ -0,0 +1,203 @@
|
||||
'use strict';
|
||||
|
||||
var menuItem = require('./menuItem.cjs');
|
||||
var checkMenuItem = require('./checkMenuItem.cjs');
|
||||
var iconMenuItem = require('./iconMenuItem.cjs');
|
||||
var predefinedMenuItem = require('./predefinedMenuItem.cjs');
|
||||
var core = require('../core.cjs');
|
||||
var base = require('./base.cjs');
|
||||
var dpi = require('../dpi.cjs');
|
||||
var image = require('../image.cjs');
|
||||
|
||||
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
/** @ignore */
|
||||
function itemFromKind([rid, id, kind]) {
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
||||
switch (kind) {
|
||||
case 'Submenu':
|
||||
// @ts-expect-error constructor is protected for external usage only, safe for us to use
|
||||
return new Submenu(rid, id);
|
||||
case 'Predefined':
|
||||
// @ts-expect-error constructor is protected for external usage only, safe for us to use
|
||||
return new predefinedMenuItem.PredefinedMenuItem(rid, id);
|
||||
case 'Check':
|
||||
// @ts-expect-error constructor is protected for external usage only, safe for us to use
|
||||
return new checkMenuItem.CheckMenuItem(rid, id);
|
||||
case 'Icon':
|
||||
// @ts-expect-error constructor is protected for external usage only, safe for us to use
|
||||
return new iconMenuItem.IconMenuItem(rid, id);
|
||||
case 'MenuItem':
|
||||
default:
|
||||
// @ts-expect-error constructor is protected for external usage only, safe for us to use
|
||||
return new menuItem.MenuItem(rid, id);
|
||||
}
|
||||
/* eslint-enable @typescript-eslint/no-unsafe-return */
|
||||
}
|
||||
/** A type that is a submenu inside a {@linkcode Menu} or {@linkcode Submenu}. */
|
||||
class Submenu extends base.MenuItemBase {
|
||||
/** @ignore */
|
||||
constructor(rid, id) {
|
||||
super(rid, id, 'Submenu');
|
||||
}
|
||||
/** Create a new submenu. */
|
||||
static async new(opts) {
|
||||
return base.newMenu('Submenu', opts).then(([rid, id]) => new Submenu(rid, id));
|
||||
}
|
||||
/** Returns the text of this submenu. */
|
||||
async text() {
|
||||
return core.invoke('plugin:menu|text', { rid: this.rid, kind: this.kind });
|
||||
}
|
||||
/** Sets the text for this submenu. */
|
||||
async setText(text) {
|
||||
return core.invoke('plugin:menu|set_text', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
text
|
||||
});
|
||||
}
|
||||
/** Returns whether this submenu is enabled or not. */
|
||||
async isEnabled() {
|
||||
return core.invoke('plugin:menu|is_enabled', { rid: this.rid, kind: this.kind });
|
||||
}
|
||||
/** Sets whether this submenu is enabled or not. */
|
||||
async setEnabled(enabled) {
|
||||
return core.invoke('plugin:menu|set_enabled', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
enabled
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Add a menu item to the end of this submenu.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **macOS:** Only {@linkcode Submenu}s can be added to a {@linkcode Menu}.
|
||||
*/
|
||||
async append(items) {
|
||||
return core.invoke('plugin:menu|append', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
items: (Array.isArray(items) ? items : [items]).map((i) => 'rid' in i ? [i.rid, i.kind] : i)
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Add a menu item to the beginning of this submenu.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **macOS:** Only {@linkcode Submenu}s can be added to a {@linkcode Menu}.
|
||||
*/
|
||||
async prepend(items) {
|
||||
return core.invoke('plugin:menu|prepend', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
items: (Array.isArray(items) ? items : [items]).map((i) => 'rid' in i ? [i.rid, i.kind] : i)
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Add a menu item to the specified position in this submenu.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **macOS:** Only {@linkcode Submenu}s can be added to a {@linkcode Menu}.
|
||||
*/
|
||||
async insert(items, position) {
|
||||
return core.invoke('plugin:menu|insert', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
items: (Array.isArray(items) ? items : [items]).map((i) => 'rid' in i ? [i.rid, i.kind] : i),
|
||||
position
|
||||
});
|
||||
}
|
||||
/** Remove a menu item from this submenu. */
|
||||
async remove(item) {
|
||||
return core.invoke('plugin:menu|remove', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
item: [item.rid, item.kind]
|
||||
});
|
||||
}
|
||||
/** Remove a menu item from this submenu at the specified position. */
|
||||
async removeAt(position) {
|
||||
return core.invoke('plugin:menu|remove_at', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
position
|
||||
}).then(itemFromKind);
|
||||
}
|
||||
/** Returns a list of menu items that has been added to this submenu. */
|
||||
async items() {
|
||||
return core.invoke('plugin:menu|items', {
|
||||
rid: this.rid,
|
||||
kind: this.kind
|
||||
}).then((i) => i.map(itemFromKind));
|
||||
}
|
||||
/** Retrieves the menu item matching the given identifier. */
|
||||
async get(id) {
|
||||
return core.invoke('plugin:menu|get', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
id
|
||||
}).then((r) => (r ? itemFromKind(r) : null));
|
||||
}
|
||||
/**
|
||||
* Popup this submenu as a context menu on the specified window.
|
||||
*
|
||||
* If the position, is provided, it is relative to the window's top-left corner.
|
||||
*/
|
||||
async popup(at, window) {
|
||||
var _a;
|
||||
return core.invoke('plugin:menu|popup', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
window: (_a = window === null || window === void 0 ? void 0 : window.label) !== null && _a !== void 0 ? _a : null,
|
||||
at: at instanceof dpi.Position ? at : at ? new dpi.Position(at) : null
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Set this submenu as the Window menu for the application on macOS.
|
||||
*
|
||||
* This will cause macOS to automatically add window-switching items and
|
||||
* certain other items to the menu.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **Windows / Linux**: Unsupported.
|
||||
*/
|
||||
async setAsWindowsMenuForNSApp() {
|
||||
return core.invoke('plugin:menu|set_as_windows_menu_for_nsapp', {
|
||||
rid: this.rid
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Set this submenu as the Help menu for the application on macOS.
|
||||
*
|
||||
* This will cause macOS to automatically add a search box to the menu.
|
||||
*
|
||||
* If no menu is set as the Help menu, macOS will automatically use any menu
|
||||
* which has a title matching the localized word "Help".
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **Windows / Linux**: Unsupported.
|
||||
*/
|
||||
async setAsHelpMenuForNSApp() {
|
||||
return core.invoke('plugin:menu|set_as_help_menu_for_nsapp', {
|
||||
rid: this.rid
|
||||
});
|
||||
}
|
||||
/** Sets an icon for this submenu */
|
||||
async setIcon(icon) {
|
||||
return core.invoke('plugin:menu|set_icon', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
icon: image.transformImage(icon)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
exports.Submenu = Submenu;
|
||||
exports.itemFromKind = itemFromKind;
|
||||
97
node_modules/@tauri-apps/api/menu/submenu.d.ts
generated
vendored
Normal file
97
node_modules/@tauri-apps/api/menu/submenu.d.ts
generated
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
import { IconMenuItemOptions, PredefinedMenuItemOptions, CheckMenuItemOptions } from '../menu';
|
||||
import { MenuItem, type MenuItemOptions } from './menuItem';
|
||||
import { CheckMenuItem } from './checkMenuItem';
|
||||
import { IconMenuItem } from './iconMenuItem';
|
||||
import { PredefinedMenuItem } from './predefinedMenuItem';
|
||||
import { type LogicalPosition, PhysicalPosition, type Window } from '../window';
|
||||
import { type ItemKind, MenuItemBase } from './base';
|
||||
import { type MenuOptions } from './menu';
|
||||
import { MenuIcon } from '../image';
|
||||
/** @ignore */
|
||||
export declare function itemFromKind([rid, id, kind]: [number, string, ItemKind]): Submenu | MenuItem | PredefinedMenuItem | CheckMenuItem | IconMenuItem;
|
||||
export type SubmenuOptions = (Omit<MenuItemOptions, 'accelerator' | 'action'> & MenuOptions) & {
|
||||
/**
|
||||
* Icon to be used for the submenu.
|
||||
* Note: you may need the `image-ico` or `image-png` Cargo features to use this API.
|
||||
*/
|
||||
icon?: MenuIcon;
|
||||
};
|
||||
/** A type that is a submenu inside a {@linkcode Menu} or {@linkcode Submenu}. */
|
||||
export declare class Submenu extends MenuItemBase {
|
||||
/** @ignore */
|
||||
protected constructor(rid: number, id: string);
|
||||
/** Create a new submenu. */
|
||||
static new(opts: SubmenuOptions): Promise<Submenu>;
|
||||
/** Returns the text of this submenu. */
|
||||
text(): Promise<string>;
|
||||
/** Sets the text for this submenu. */
|
||||
setText(text: string): Promise<void>;
|
||||
/** Returns whether this submenu is enabled or not. */
|
||||
isEnabled(): Promise<boolean>;
|
||||
/** Sets whether this submenu is enabled or not. */
|
||||
setEnabled(enabled: boolean): Promise<void>;
|
||||
/**
|
||||
* Add a menu item to the end of this submenu.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **macOS:** Only {@linkcode Submenu}s can be added to a {@linkcode Menu}.
|
||||
*/
|
||||
append<T extends Submenu | MenuItem | PredefinedMenuItem | CheckMenuItem | IconMenuItem | MenuItemOptions | SubmenuOptions | IconMenuItemOptions | PredefinedMenuItemOptions | CheckMenuItemOptions>(items: T | T[]): Promise<void>;
|
||||
/**
|
||||
* Add a menu item to the beginning of this submenu.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **macOS:** Only {@linkcode Submenu}s can be added to a {@linkcode Menu}.
|
||||
*/
|
||||
prepend<T extends Submenu | MenuItem | PredefinedMenuItem | CheckMenuItem | IconMenuItem | MenuItemOptions | SubmenuOptions | IconMenuItemOptions | PredefinedMenuItemOptions | CheckMenuItemOptions>(items: T | T[]): Promise<void>;
|
||||
/**
|
||||
* Add a menu item to the specified position in this submenu.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **macOS:** Only {@linkcode Submenu}s can be added to a {@linkcode Menu}.
|
||||
*/
|
||||
insert<T extends Submenu | MenuItem | PredefinedMenuItem | CheckMenuItem | IconMenuItem | MenuItemOptions | SubmenuOptions | IconMenuItemOptions | PredefinedMenuItemOptions | CheckMenuItemOptions>(items: T | T[], position: number): Promise<void>;
|
||||
/** Remove a menu item from this submenu. */
|
||||
remove(item: Submenu | MenuItem | PredefinedMenuItem | CheckMenuItem | IconMenuItem): Promise<void>;
|
||||
/** Remove a menu item from this submenu at the specified position. */
|
||||
removeAt(position: number): Promise<Submenu | MenuItem | PredefinedMenuItem | CheckMenuItem | IconMenuItem | null>;
|
||||
/** Returns a list of menu items that has been added to this submenu. */
|
||||
items(): Promise<Array<Submenu | MenuItem | PredefinedMenuItem | CheckMenuItem | IconMenuItem>>;
|
||||
/** Retrieves the menu item matching the given identifier. */
|
||||
get(id: string): Promise<Submenu | MenuItem | PredefinedMenuItem | CheckMenuItem | IconMenuItem | null>;
|
||||
/**
|
||||
* Popup this submenu as a context menu on the specified window.
|
||||
*
|
||||
* If the position, is provided, it is relative to the window's top-left corner.
|
||||
*/
|
||||
popup(at?: PhysicalPosition | LogicalPosition, window?: Window): Promise<void>;
|
||||
/**
|
||||
* Set this submenu as the Window menu for the application on macOS.
|
||||
*
|
||||
* This will cause macOS to automatically add window-switching items and
|
||||
* certain other items to the menu.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **Windows / Linux**: Unsupported.
|
||||
*/
|
||||
setAsWindowsMenuForNSApp(): Promise<void>;
|
||||
/**
|
||||
* Set this submenu as the Help menu for the application on macOS.
|
||||
*
|
||||
* This will cause macOS to automatically add a search box to the menu.
|
||||
*
|
||||
* If no menu is set as the Help menu, macOS will automatically use any menu
|
||||
* which has a title matching the localized word "Help".
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **Windows / Linux**: Unsupported.
|
||||
*/
|
||||
setAsHelpMenuForNSApp(): Promise<void>;
|
||||
/** Sets an icon for this submenu */
|
||||
setIcon(icon: MenuIcon | null): Promise<void>;
|
||||
}
|
||||
200
node_modules/@tauri-apps/api/menu/submenu.js
generated
vendored
Normal file
200
node_modules/@tauri-apps/api/menu/submenu.js
generated
vendored
Normal file
@@ -0,0 +1,200 @@
|
||||
import { MenuItem } from './menuItem.js';
|
||||
import { CheckMenuItem } from './checkMenuItem.js';
|
||||
import { IconMenuItem } from './iconMenuItem.js';
|
||||
import { PredefinedMenuItem } from './predefinedMenuItem.js';
|
||||
import { invoke } from '../core.js';
|
||||
import { MenuItemBase, newMenu } from './base.js';
|
||||
import { Position } from '../dpi.js';
|
||||
import { transformImage } from '../image.js';
|
||||
|
||||
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
/** @ignore */
|
||||
function itemFromKind([rid, id, kind]) {
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
||||
switch (kind) {
|
||||
case 'Submenu':
|
||||
// @ts-expect-error constructor is protected for external usage only, safe for us to use
|
||||
return new Submenu(rid, id);
|
||||
case 'Predefined':
|
||||
// @ts-expect-error constructor is protected for external usage only, safe for us to use
|
||||
return new PredefinedMenuItem(rid, id);
|
||||
case 'Check':
|
||||
// @ts-expect-error constructor is protected for external usage only, safe for us to use
|
||||
return new CheckMenuItem(rid, id);
|
||||
case 'Icon':
|
||||
// @ts-expect-error constructor is protected for external usage only, safe for us to use
|
||||
return new IconMenuItem(rid, id);
|
||||
case 'MenuItem':
|
||||
default:
|
||||
// @ts-expect-error constructor is protected for external usage only, safe for us to use
|
||||
return new MenuItem(rid, id);
|
||||
}
|
||||
/* eslint-enable @typescript-eslint/no-unsafe-return */
|
||||
}
|
||||
/** A type that is a submenu inside a {@linkcode Menu} or {@linkcode Submenu}. */
|
||||
class Submenu extends MenuItemBase {
|
||||
/** @ignore */
|
||||
constructor(rid, id) {
|
||||
super(rid, id, 'Submenu');
|
||||
}
|
||||
/** Create a new submenu. */
|
||||
static async new(opts) {
|
||||
return newMenu('Submenu', opts).then(([rid, id]) => new Submenu(rid, id));
|
||||
}
|
||||
/** Returns the text of this submenu. */
|
||||
async text() {
|
||||
return invoke('plugin:menu|text', { rid: this.rid, kind: this.kind });
|
||||
}
|
||||
/** Sets the text for this submenu. */
|
||||
async setText(text) {
|
||||
return invoke('plugin:menu|set_text', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
text
|
||||
});
|
||||
}
|
||||
/** Returns whether this submenu is enabled or not. */
|
||||
async isEnabled() {
|
||||
return invoke('plugin:menu|is_enabled', { rid: this.rid, kind: this.kind });
|
||||
}
|
||||
/** Sets whether this submenu is enabled or not. */
|
||||
async setEnabled(enabled) {
|
||||
return invoke('plugin:menu|set_enabled', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
enabled
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Add a menu item to the end of this submenu.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **macOS:** Only {@linkcode Submenu}s can be added to a {@linkcode Menu}.
|
||||
*/
|
||||
async append(items) {
|
||||
return invoke('plugin:menu|append', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
items: (Array.isArray(items) ? items : [items]).map((i) => 'rid' in i ? [i.rid, i.kind] : i)
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Add a menu item to the beginning of this submenu.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **macOS:** Only {@linkcode Submenu}s can be added to a {@linkcode Menu}.
|
||||
*/
|
||||
async prepend(items) {
|
||||
return invoke('plugin:menu|prepend', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
items: (Array.isArray(items) ? items : [items]).map((i) => 'rid' in i ? [i.rid, i.kind] : i)
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Add a menu item to the specified position in this submenu.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **macOS:** Only {@linkcode Submenu}s can be added to a {@linkcode Menu}.
|
||||
*/
|
||||
async insert(items, position) {
|
||||
return invoke('plugin:menu|insert', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
items: (Array.isArray(items) ? items : [items]).map((i) => 'rid' in i ? [i.rid, i.kind] : i),
|
||||
position
|
||||
});
|
||||
}
|
||||
/** Remove a menu item from this submenu. */
|
||||
async remove(item) {
|
||||
return invoke('plugin:menu|remove', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
item: [item.rid, item.kind]
|
||||
});
|
||||
}
|
||||
/** Remove a menu item from this submenu at the specified position. */
|
||||
async removeAt(position) {
|
||||
return invoke('plugin:menu|remove_at', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
position
|
||||
}).then(itemFromKind);
|
||||
}
|
||||
/** Returns a list of menu items that has been added to this submenu. */
|
||||
async items() {
|
||||
return invoke('plugin:menu|items', {
|
||||
rid: this.rid,
|
||||
kind: this.kind
|
||||
}).then((i) => i.map(itemFromKind));
|
||||
}
|
||||
/** Retrieves the menu item matching the given identifier. */
|
||||
async get(id) {
|
||||
return invoke('plugin:menu|get', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
id
|
||||
}).then((r) => (r ? itemFromKind(r) : null));
|
||||
}
|
||||
/**
|
||||
* Popup this submenu as a context menu on the specified window.
|
||||
*
|
||||
* If the position, is provided, it is relative to the window's top-left corner.
|
||||
*/
|
||||
async popup(at, window) {
|
||||
var _a;
|
||||
return invoke('plugin:menu|popup', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
window: (_a = window === null || window === void 0 ? void 0 : window.label) !== null && _a !== void 0 ? _a : null,
|
||||
at: at instanceof Position ? at : at ? new Position(at) : null
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Set this submenu as the Window menu for the application on macOS.
|
||||
*
|
||||
* This will cause macOS to automatically add window-switching items and
|
||||
* certain other items to the menu.
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **Windows / Linux**: Unsupported.
|
||||
*/
|
||||
async setAsWindowsMenuForNSApp() {
|
||||
return invoke('plugin:menu|set_as_windows_menu_for_nsapp', {
|
||||
rid: this.rid
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Set this submenu as the Help menu for the application on macOS.
|
||||
*
|
||||
* This will cause macOS to automatically add a search box to the menu.
|
||||
*
|
||||
* If no menu is set as the Help menu, macOS will automatically use any menu
|
||||
* which has a title matching the localized word "Help".
|
||||
*
|
||||
* #### Platform-specific:
|
||||
*
|
||||
* - **Windows / Linux**: Unsupported.
|
||||
*/
|
||||
async setAsHelpMenuForNSApp() {
|
||||
return invoke('plugin:menu|set_as_help_menu_for_nsapp', {
|
||||
rid: this.rid
|
||||
});
|
||||
}
|
||||
/** Sets an icon for this submenu */
|
||||
async setIcon(icon) {
|
||||
return invoke('plugin:menu|set_icon', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
icon: transformImage(icon)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export { Submenu, itemFromKind };
|
||||
Reference in New Issue
Block a user