Skip to content

Commit

Permalink
Regenerate typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
bobrippling committed Jul 27, 2023
1 parent ddc9ac3 commit 73218e4
Showing 1 changed file with 185 additions and 17 deletions.
202 changes: 185 additions & 17 deletions typescript/types/main.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ type SetUIArg<Mode> = Mode | {
mode: Mode,
back?: () => void,
remove?: () => void,
redraw?: () => void,
};

type NRFFilters = {
Expand Down Expand Up @@ -841,6 +842,16 @@ declare class NRF {
*/
static on(event: "disconnect", callback: (reason: number) => void): void;

/**
* Called when the Nordic Bluetooth stack (softdevice) generates an error. In pretty
* much all cases an Exception will also have been thrown.
* @param {string} event - The event to listen to.
* @param {(msg: any) => void} callback - A function that is executed when the event occurs. Its arguments are:
* * `msg` The error string
* @url http://www.espruino.com/Reference#l_NRF_error
*/
static on(event: "error", callback: (msg: any) => void): void;

/**
* Contains updates on the security of the current Bluetooth link.
* See Nordic's `ble_gap_evt_auth_status_t` structure for more information.
Expand Down Expand Up @@ -964,6 +975,17 @@ declare class NRF {
*/
static restart(callback?: any): void;

/**
* Delete all data stored for all peers (bonding data used for secure connections). This cannot be done
* while a connection is active, so if there is a connection it will be postponed until everything is disconnected
* (which can be done by calling `NRF.disconnect()` and waiting).
* Booting your device while holding all buttons down together should also have the same effect.
*
* @param {any} [callback] - [optional] A function to be called while the softdevice is uninitialised. Use with caution - accessing console/bluetooth will almost certainly result in a crash.
* @url http://www.espruino.com/Reference#l_NRF_eraseBonds
*/
static eraseBonds(callback?: any): void;

/**
* Get this device's default Bluetooth MAC address.
* For Puck.js, the last 5 characters of this (e.g. `ee:ff`) are used in the
Expand Down Expand Up @@ -1222,8 +1244,9 @@ declare class NRF {
* hid : new Uint8Array(...), // optional, default is undefined. Enable BLE HID support
* uart : true, // optional, default is true. Enable BLE UART support
* advertise: [ '180D' ] // optional, list of service UUIDs to advertise
* ancs : true, // optional, Bangle.js-only, enable Apple ANCS support for notifications
* ams : true // optional, Bangle.js-only, enable Apple AMS support for media control
* ancs : true, // optional, Bangle.js-only, enable Apple ANCS support for notifications (see `NRF.ancs*`)
* ams : true // optional, Bangle.js-only, enable Apple AMS support for media control (see `NRF.ams*`)
* cts : true // optional, Bangle.js-only, enable Apple Current Time Service support (see `NRF.ctsGetTime`)
* });
* ```
* To enable BLE HID, you must set `hid` to an array which is the BLE report
Expand Down Expand Up @@ -1747,6 +1770,55 @@ declare class NRF {
*/
static amsCommand(id: any): void;

/**
* Check if Apple Current Time Service (CTS) is currently active on the BLE connection
*
* @returns {boolean} True if Apple Current Time Service (CTS) has been initialised and is active
* @url http://www.espruino.com/Reference#l_NRF_ctsIsActive
*/
static ctsIsActive(): boolean;

/**
* Returns time information from the Current Time Service
* (if requested with `NRF.ctsGetTime` and is activated by calling `NRF.setServices(..., {..., cts:true})`)
* ```
* {
* date : // Date object with the current date
* day : // if known, 0=sun,1=mon (matches JS `Date`)
* reason : [ // reason for the date change
* "external", // External time change
* "manual", // Manual update
* "timezone", // Timezone changed
* "DST", // Daylight savings
* ]
* timezone // if LTI characteristic exists, this is the timezone
* dst // if LTI characteristic exists, this is the dst adjustment
* }
* ```
* For instance this can be used as follows to update Espruino's time:
* ```
* E.on('CTS',e=>{
* setTime(e.date.getTime()/1000);
* });
* NRF.ctsGetTime(); // also returns a promise with CTS info
* ```
* @param {string} event - The event to listen to.
* @param {(info: any) => void} callback - A function that is executed when the event occurs. Its arguments are:
* * `info` An object (see below)
* @url http://www.espruino.com/Reference#l_NRF_CTS
*/
static on(event: "CTS", callback: (info: any) => void): void;

/**
* Read the time from CTS - creates an `NRF.on('CTS', ...)` event as well
* ```
* NRF.ctsGetTime(); // also returns a promise
* ```
* @returns {any} A `Promise` that is resolved (or rejected) when time is received
* @url http://www.espruino.com/Reference#l_NRF_ctsGetTime
*/
static ctsGetTime(): Promise<void>;

/**
* Search for available devices matching the given filters. Since we have no UI
* here, Espruino will pick the FIRST device it finds, or it'll call `catch`.
Expand Down Expand Up @@ -3538,6 +3610,16 @@ declare class Bangle {
*/
static on(event: "lcdPower", callback: (on: boolean) => void): void;

/**
* Has the backlight been turned on or off? Can be used to stop tasks that are no
* longer useful if want to see in sun screen only. Also see `Bangle.isBacklightOn()`
* @param {string} event - The event to listen to.
* @param {(on: boolean) => void} callback - A function that is executed when the event occurs. Its arguments are:
* * `on` `true` if backlight is on
* @url http://www.espruino.com/Reference#l_Bangle_backlight
*/
static on(event: "backlight", callback: (on: boolean) => void): void;

/**
* Has the screen been locked? Also see `Bangle.isLocked()`
* @param {string} event - The event to listen to.
Expand Down Expand Up @@ -3664,6 +3746,26 @@ declare class Bangle {
*/
static on(event: "midnight", callback: () => void): void;

/**
* This function can be used to turn Bangle.js's LCD backlight off or on.
* This function resets the Bangle's 'activity timer' (like pressing a button or
* the screen would) so after a time period of inactivity set by
* `Bangle.setOptions({backlightTimeout: X});` the backlight will turn off.
* If you want to keep the backlight on permanently (until apps are changed) you can
* do:
* ```
* Bangle.setOptions({backlightTimeout: 0}) // turn off the timeout
* Bangle.setBacklight(1); // keep screen on
* ```
* Of course, the backlight depends on `Bangle.setLCDPower` too, so any lcdPowerTimeout/setLCDTimeout will
* also turn the backlight off. The use case is when you require the backlight timeout
* to be shorter than the power timeout.
*
* @param {boolean} isOn - True if the LCD backlight should be on, false if not
* @url http://www.espruino.com/Reference#l_Bangle_setBacklight
*/
static setBacklight(isOn: boolean): void;

/**
* This function can be used to turn Bangle.js's LCD off or on.
* This function resets the Bangle's 'activity timer' (like pressing a button or
Expand Down Expand Up @@ -3805,7 +3907,7 @@ declare class Bangle {
static setLCDTimeout(isOn: number): void;

/**
* Set how often the watch should poll for new acceleration/gyro data and kick the
* Set how often the watch should poll its sensors (accel/hr/mag) for new data and kick the
* Watchdog timer. It isn't recommended that you make this interval much larger
* than 1000ms, but values up to 4000ms are allowed.
* Calling this will set `Bangle.setOptions({powerSave: false})` - disabling the
Expand Down Expand Up @@ -3890,6 +3992,13 @@ declare class Bangle {
*/
static isLCDOn(): boolean;

/**
* Also see the `Bangle.backlight` event
* @returns {boolean} Is the backlight on or not?
* @url http://www.espruino.com/Reference#l_Bangle_isBacklightOn
*/
static isBacklightOn(): boolean;

/**
* This function can be used to lock or unlock Bangle.js (e.g. whether buttons and
* touchscreen work or not)
Expand Down Expand Up @@ -4361,7 +4470,8 @@ declare class Bangle {
* (function() {
* var sui = Bangle.setUI;
* Bangle.setUI = function(mode, cb) {
* if (mode!="clock") return sui(mode,cb);
* var m = ("object"==typeof mode) ? mode.mode : mode;
* if (m!="clock") return sui(mode,cb);
* sui(); // clear
* Bangle.CLOCK=1;
* Bangle.swipeHandler = Bangle.showLauncher;
Expand All @@ -4376,18 +4486,19 @@ declare class Bangle {
* mode : "custom",
* back : function() {}, // optional - add a 'back' icon in top-left widget area and call this function when it is pressed , also call it when the hardware button is clicked (does not override btn if defined)
* remove : function() {}, // optional - add a handler for when the UI should be removed (eg stop any intervals/timers here)
* touch : function(n,e) {}, // optional - handler for 'touch' events
* swipe : function(dir) {}, // optional - handler for 'swipe' events
* drag : function(e) {}, // optional - handler for 'drag' events (Bangle.js 2 only)
* btn : function(n) {}, // optional - handler for 'button' events (n==1 on Bangle.js 2, n==1/2/3 depending on button for Bangle.js 1)
* redraw : function() {}, // optional - add a handler to redraw the UI. Not needed but it can allow widgets/etc to provide other functionality that requires the screen to be redrawn
* touch : function(n,e) {}, // optional - (mode:custom only) handler for 'touch' events
* swipe : function(dir) {}, // optional - (mode:custom only) handler for 'swipe' events
* drag : function(e) {}, // optional - (mode:custom only) handler for 'drag' events (Bangle.js 2 only)
* btn : function(n) {}, // optional - (mode:custom only) handler for 'button' events (n==1 on Bangle.js 2, n==1/2/3 depending on button for Bangle.js 1)
* clock : 0 // optional - if set the behavior of 'clock' mode is added (does not override btn if defined)
* });
* ```
* If `remove` is specified, `Bangle.showLauncher`, `Bangle.showClock`, `Bangle.load` and some apps
* may choose to just call the `remove` function and then load a new app without resetting Bangle.js.
* As a result, **if you specify 'remove' you should make sure you test that after calling `Bangle.setUI()`
* without arguments your app is completely unloaded**, otherwise you may end up with memory leaks or
* other issues when switching apps.
* other issues when switching apps. Please see http://www.espruino.com/Bangle.js+Fast+Load for more details on this.
*
* @param {any} type - The type of UI input: 'updown', 'leftright', 'clock', 'clockupdown' or undefined to cancel. Can also be an object (see below)
* @param {any} callback - A function with one argument which is the direction
Expand Down Expand Up @@ -6872,6 +6983,7 @@ interface DateConstructor {
new(): Date;
new(value: number | string): Date;
new(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date;
(arg?: any): string;
}

interface Date {
Expand Down Expand Up @@ -8166,7 +8278,9 @@ declare class E {
static toFlatString(...args: any[]): string | undefined;

/**
* By default, strings in Espruino are standard 8 bit binary strings.
* By default, strings in Espruino are standard 8 bit binary strings
* unless they contain Unicode chars or a `\u####` escape code
* that doesn't map to the range 0..255.
* However calling E.asUTF8 will convert one of those strings to
* UTF8.
* ```
Expand All @@ -8177,13 +8291,42 @@ declare class E {
* u.length // 1
* u[0] // hamburger emoji
* ```
* **NOTE:** UTF8 is currently only available on Bangle.js devices
*
* @param {any} str - The string to turn into a UTF8 Unicode String
* @returns {any} A String
* @url http://www.espruino.com/Reference#l_E_asUTF8
*/
static asUTF8(str: any): string;

/**
* Given a UTF8 String (see `E.asUTF8`) this returns the underlying representation
* of that String.
* ```
* E.fromUTF8("\u03C0") == "\xCF\x80"
* ```
* **NOTE:** UTF8 is currently only available on Bangle.js devices
*
* @param {any} str - The string to check
* @returns {any} A String
* @url http://www.espruino.com/Reference#l_E_fromUTF8
*/
static fromUTF8(str: any): string;

/**
* By default, strings in Espruino are standard 8 bit binary strings
* unless they contain Unicode chars or a `\u####` escape code
* that doesn't map to the range 0..255.
* This checks if a String is being treated by Espruino as a UTF8 String
* See `E.asUTF8` to convert to a UTF8 String
* **NOTE:** UTF8 is currently only available on Bangle.js devices
*
* @param {any} str - The string to check
* @returns {boolean} True if the given String is treated as UTF8 by Espruino
* @url http://www.espruino.com/Reference#l_E_isUTF8
*/
static isUTF8(str: any): boolean;

/**
* This creates a Uint8Array from the given arguments. These are handled as
* follows:
Expand Down Expand Up @@ -9120,6 +9263,26 @@ interface Object {
*/
on(event: any, listener: any): void;

/**
* Register an event listener for this object, for instance `Serial1.addListener('data', function(d) {...})`.
* An alias for `Object.on`
*
* @param {any} event - The name of the event, for instance 'data'
* @param {any} listener - The listener to call when this event is received
* @url http://www.espruino.com/Reference#l_Object_addListener
*/
addListener(event: any, listener: any): void;

/**
* Register an event listener for this object, for instance `Serial1.addListener('data', function(d) {...})`.
* An alias for `Object.on`
*
* @param {any} event - The name of the event, for instance 'data'
* @param {any} listener - The listener to call when this event is received
* @url http://www.espruino.com/Reference#l_Object_prependListener
*/
prependListener(event: any, listener: any): void;

/**
* Call any event listeners that were added to this object with `Object.on`, for
* instance `obj.emit('data', 'Foo')`.
Expand Down Expand Up @@ -9807,21 +9970,22 @@ declare const Promise: PromiseConstructor
* This means that while `StorageFile` files exist in the same area as those from
* `Storage`, they should be read using `Storage.open` (and not `Storage.read`).
* ```
* f = s.open("foobar","w");
* f = require("Storage").open("foobar","w");
* f.write("Hell");
* f.write("o World\n");
* f.write("Hello\n");
* f.write("World 2\n");
* f.write("Hello World 3\n");
* // there's no need to call 'close'
* // then
* f = s.open("foobar","r");
* f = require("Storage").open("foobar","r");
* f.read(13) // "Hello World\nH"
* f.read(13) // "ello\nWorld 2\n"
* f.read(13) // "Hello World 3"
* f.read(13) // "\n"
* f.read(13) // undefined
* // or
* f = s.open("foobar","r");
* f = require("Storage").open("foobar","r");
* f.readLine() // "Hello World\n"
* f.readLine() // "Hello\n"
* f.readLine() // "World 2\n"
Expand Down Expand Up @@ -10255,6 +10419,7 @@ interface StringConstructor {
* @url http://www.espruino.com/Reference#l_String_String
*/
new(...str: any[]): any;
(arg?: any): string;
}

interface String {
Expand Down Expand Up @@ -10499,7 +10664,8 @@ interface RegExpConstructor {
* @returns {any} A RegExp object
* @url http://www.espruino.com/Reference#l_RegExp_RegExp
*/
new(regex: any, flags: any): RegExp;
new(...value: any[]): RegExp;
(value: any): RegExp;
}

interface RegExp {
Expand Down Expand Up @@ -10588,7 +10754,8 @@ interface NumberConstructor {
* @returns {any} A Number object
* @url http://www.espruino.com/Reference#l_Number_Number
*/
new(...value: any[]): any;
new(...value: any[]): Number;
(value: any): number;
}

interface Number {
Expand Down Expand Up @@ -10728,7 +10895,8 @@ interface BooleanConstructor {
* @returns {boolean} A Boolean object
* @url http://www.espruino.com/Reference#l_Boolean_Boolean
*/
new(value: any): boolean;
new(...value: any[]): Number;
(value: any): boolean;
}

interface Boolean {
Expand Down Expand Up @@ -13494,7 +13662,7 @@ declare module "Storage" {
* List all files in the flash storage area matching the specified regex (ignores
* StorageFiles), and then hash their filenames *and* file locations.
* Identical files may have different hashes (e.g. if Storage is compacted and the
* file moves) but the changes of different files having the same hash are
* file moves) but the chances of different files having the same hash are
* extremely small.
* ```
* // Hash files
Expand Down

0 comments on commit 73218e4

Please sign in to comment.