-
Notifications
You must be signed in to change notification settings - Fork 1
/
api-type-definitions.cjs
104 lines (90 loc) · 3.33 KB
/
api-type-definitions.cjs
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
/**
* @file Type definitions for the API and reusable functions/objects.
*/
/**
* OPTIONAL: console.error is called by default if verbose: true.
*
* Your own custom logging function called with helpful warning/error
* messages from the internal validators. Only used if verbose: true.
*
* @callback {Function} CUSTOMLOGGER
* @param {string} message The human readable warning/error message
* @param {object} [error] Sometimes an error or options object is passed
* @return {void}
*/
/**
* @typedef {object} SPLASHER
* @property {number} [port=4443] Websocket port the splash screen window listens on to know when to close itself.
* @property {number} [closeSplashAfter=3000] ms to wait before auto-closing splash. -1 to only close if signaled via the websocket port.
*/
/**
* @typedef {object} AUTOUPDATE
* @property {string} versionUrl The url we hit to check for latest version.
* @property {Function} confirmNewVersion .
* @property {Function} downloadPath .
* @property {number} [downloadRetries=3] The amount of attempts to perform if a download fails
* @property {number} [extractRetries=3] The amount of attempts to perform if unzipping fails
* @property {Function} [onUpdate] .
* @property {Function} [validateZip] .
* @property {Function} [validateExtract] .
* @property {Function} [onRetry] .
* @property {Function} [onError] .
* @property {Function} [onComplete] .
*/
/**
* @typedef {object} NEWWINDOW
* @property {string} [entry] The file to load in the window, like 'index.html'.
* @property {object} [window] Any NW.js window subfield options.
* [Docs](https://docs.nwjs.io/en/latest/References/Manifest%20Format/#window-subfields)
*/
/**
* @typedef {object} OPTIONS
* @property {boolean} [verbose=true] Logs out helpful warnings/errors using `customLogger` or console.error.
* @property {CUSTOMLOGGER} [customLogger] Called (if verbose: true) with helpful warning/error messages from internal validators.
* @property {SPLASHER} [splasher] Settings for the splash screen
* @property {AUTOUPDATE} [autoUpdate] Settings for auto updating your app
* @property {NEWWINDOW} [newWindow] Settings for the main app window displayed after auto-update completes
*/
/**
* @typedef {object} DOWNLOADPROGRESSTOTAL
* @property {number} bytes The total number of bytes downloaded so far
* @property {number} percent Overall percent (0-100), if server returned the total filesize, otherwise stays 0
* @property {number} speed The download speed in bytes/sec (ex: 554732)
*/
/**
* @typedef {object} DOWNLOADPROGRESS
* @property {array} details An array of details
* @property {DOWNLOADPROGRESSTOTAL} total The total download bytes, current speed, and percent
*/
/**
* @type {CUSTOMLOGGER}
*/
let CUSTOMLOGGER;
/**
* @type {SPLASHER}
*/
let SPLASHER;
/**
* @type {AUTOUPDATE}
*/
let AUTOUPDATE;
/**
* @type {NEWWINDOW}
*/
let NEWWINDOW;
/**
* @type {OPTIONS}
*/
let OPTIONS;
/**
* @type {DOWNLOADPROGRESS}
*/
let DOWNLOADPROGRESS;
module.exports = {
AUTOUPDATE,
CUSTOMLOGGER,
DOWNLOADPROGRESS,
NEWWINDOW,
OPTIONS,
SPLASHER
};