-
Notifications
You must be signed in to change notification settings - Fork 91
/
index.d.ts
153 lines (153 loc) · 5.3 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
declare module "updater" {
export default updater;
export type Platform = {
/**
* - The URL to the package
*/
url: string;
/**
* - The path to the executable
*/
execPath: string;
};
export type Packages = {
/**
* - The Windows package
*/
win: Platform;
/**
* - The macOS package
*/
mac: Platform;
/**
* - The Linux 32-bit package
*/
linux32: Platform;
/**
* - The Linux 64-bit package
*/
linux64: Platform;
};
export type Manifest = {
/**
* - The name of the application
*/
name: string;
/**
* - The current version of the application
*/
version: string;
/**
* - The URL to the remote manifest file
*/
manifestUrl: string;
/**
* - The packages for the application
*/
packages: Packages;
};
export type UpdaterOptions = {
/**
* - The path to a directory to download the updates to and unpack them in. Defaults to [`os.tmpdir()`](https://nodejs.org/api/os.html#os_os_tmpdir)
*/
temporaryDirectory: string;
};
/**
* @typedef {object} Platform
* @property {string} url - The URL to the package
* @property {string} execPath - The path to the executable
*/
/**
* @typedef {object} Packages
* @property {Platform} win - The Windows package
* @property {Platform} mac - The macOS package
* @property {Platform} linux32 - The Linux 32-bit package
* @property {Platform} linux64 - The Linux 64-bit package
*/
/**
* @typedef {object} Manifest
* @property {string} name - The name of the application
* @property {string} version - The current version of the application
* @property {string} manifestUrl - The URL to the remote manifest file
* @property {Packages} packages - The packages for the application
*/
/**
* @typedef {object} UpdaterOptions
* @property {string} temporaryDirectory - The path to a directory to download the updates to and unpack them in. Defaults to [`os.tmpdir()`](https://nodejs.org/api/os.html#os_os_tmpdir)
*/
class updater {
/**
* Creates new instance of updater.
*
* @constructor
* @param {Manifest} manifest - See the [manifest schema](https://github.com/nwutils/nw-updater?tab=readme-ov-file#manifest-schema).
* @param {UpdaterOptions} options - Optional
*/
constructor(manifest: Manifest, options: UpdaterOptions);
manifest: Manifest;
options: {
temporaryDirectory: any;
};
/**
* Check the latest available version of the application by requesting the manifest specified in `manifestUrl`.
*
* @async
* @method
* @returns {Promise.<boolean>}
*/
checkNewVersion(): Promise<boolean>;
/**
* Downloads the new app to a temorary folder.
*
* @async
* @method
* @param {Manifest} newManifest - see [manifest schema](https://github.com/nwutils/nw-updater?tab=readme-ov-file#manifest-schema) below
* @returns {Promise.<void>}
*/
download(newManifest: Manifest): Promise<void>;
/**
* Returns executed application path.
*
* @returns {string}
*/
getAppPath(): string;
/**
* Returns current application executable.
*
* @returns {string}
*/
getAppExec(): string;
/**
* Will unpack the `filename` in temporary folder.
* For Windows, [unzip](https://www.mkssoftware.com/docs/man1/unzip.1.asp) is used (which is [not signed](https://github.com/edjafarov/node-webkit-updater/issues/68)).
*
* @param {string} filename
* @param {function} cb - Callback arguments: error, unpacked directory
* @param {object} manifest
*/
unpack(filename: string, cb: Function, manifest: object): void;
/**
* Runs installer
* @param {string} appPath
* @param {array} args - Arguments which will be passed when running the new app
* @param {object} options - Optional
* @returns {function}
*/
runInstaller(appPath: string, args: any[], options: object, ...args: any[]): Function;
/**
* Installs the app (copies current application to `copyPath`)
* @param {string} copyPath
* @param {function} cb - Callback arguments: error
*/
install(copyPath: string, cb: Function, ...args: any[]): void;
/**
* Runs the app from original app executable path.
* @param {string} execPath
* @param {array} args - Arguments passed to the app being ran.
* @param {object} options - Optional. See `spawn` from nodejs docs.
*
* Note: if this doesn't work, try `gui.Shell.openItem(execPath)` (see [node-webkit Shell](https://github.com/rogerwang/node-webkit/wiki/Shell)).
*/
run(execPath: string, args: any[], options: object, ...args: any[]): void;
}
}