@moddable/typings 9.0.1 → 10.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DS18X20.d.ts +40 -0
- package/{embedded_io/system.d.ts → ResourceIterator.d.ts} +4 -15
- package/ble/bleclient.d.ts +1 -0
- package/ble/bleserver.d.ts +1 -0
- package/ble/btutils.d.ts +3 -0
- package/ble/connection.d.ts +1 -0
- package/ble/gap.d.ts +2 -0
- package/ble/gatt.d.ts +4 -0
- package/ble/hidclient.d.ts +5 -0
- package/ble/sm.d.ts +3 -0
- package/captiveportal.d.ts +71 -0
- package/commodetto/Poco.d.ts +10 -2
- package/commodetto/ReadGIF.d.ts +1 -1
- package/commodetto/outline.d.ts +4 -1
- package/commodetto/parseRLE.d.ts +1 -1
- package/commodetto/readJPEG.d.ts +1 -1
- package/config/analog.d.ts +31 -0
- package/config/digital.d.ts +32 -0
- package/config/dns.d.ts +33 -0
- package/config/dnssd.d.ts +31 -0
- package/config/files.d.ts +27 -0
- package/config/flash.d.ts +27 -0
- package/config/httpclient.d.ts +34 -0
- package/config/httpsclient.d.ts +34 -0
- package/config/httpserver.d.ts +33 -0
- package/config/i2c.d.ts +33 -0
- package/config/mqtt.d.ts +27 -0
- package/config/mqttclient.d.ts +31 -0
- package/config/mqttsclient.d.ts +32 -0
- package/config/ntp.d.ts +34 -0
- package/config/pulsecount.d.ts +30 -0
- package/config/pwm.d.ts +30 -0
- package/config/serial.d.ts +31 -0
- package/config/socket.d.ts +34 -0
- package/config/spi.d.ts +31 -0
- package/config/storage.d.ts +27 -0
- package/config/system.d.ts +27 -0
- package/config/tls.d.ts +30 -0
- package/config/update.d.ts +27 -0
- package/config/wsclient.d.ts +31 -0
- package/config/wssclient.d.ts +32 -0
- package/crc.d.ts +1 -1
- package/dns/server.d.ts +1 -0
- package/embedded/RTC/zephyr-builtin.d.ts +48 -0
- package/embedded/RTC.d.ts +18 -7
- package/embedded/display.d.ts +8 -3
- package/embedded/storage/files.d.ts +10 -7
- package/embedded/storage/flash.d.ts +2 -2
- package/embedded/storage/key-value.d.ts +27 -6
- package/embedded/system.d.ts +49 -0
- package/embedded_io/_common.d.ts +42 -3
- package/embedded_io/analog.d.ts +7 -7
- package/embedded_io/audio/in.d.ts +3 -2
- package/embedded_io/audio/out.d.ts +12 -4
- package/embedded_io/ble/central.d.ts +5 -4
- package/embedded_io/ble/peripheral.d.ts +6 -5
- package/embedded_io/crypt/digest.d.ts +2 -2
- package/embedded_io/digital.d.ts +4 -3
- package/embedded_io/digitalbank.d.ts +9 -5
- package/embedded_io/i2c.d.ts +9 -6
- package/embedded_io/image/in/camera.d.ts +82 -0
- package/embedded_io/pulsecount.d.ts +7 -5
- package/embedded_io/pwm.d.ts +11 -5
- package/embedded_io/serial.d.ts +33 -16
- package/embedded_io/smbus.d.ts +1 -1
- package/embedded_io/socket/listener.d.ts +3 -2
- package/embedded_io/socket/tcp/tls.d.ts +41 -12
- package/embedded_io/socket/tcp.d.ts +26 -12
- package/embedded_io/socket/udp.d.ts +17 -12
- package/embedded_io/spi.d.ts +8 -6
- package/embedded_network/dns/resolver/udp.d.ts +13 -6
- package/embedded_network/dns/server/udp.d.ts +39 -0
- package/embedded_network/dnssd.d.ts +9 -7
- package/embedded_network/http/client.d.ts +23 -8
- package/embedded_network/http/server/route/serversentevents.d.ts +48 -0
- package/embedded_network/http/server/route/static.d.ts +41 -0
- package/embedded_network/http/server/route/webdav.d.ts +42 -0
- package/embedded_network/http/server/route/ws/handshake.d.ts +28 -0
- package/embedded_network/http/server.d.ts +28 -6
- package/embedded_network/interface/ethernet.d.ts +3 -3
- package/embedded_network/interface/wifi/accesspoint.d.ts +2 -2
- package/embedded_network/interface/wifi.d.ts +21 -12
- package/embedded_network/mdns.d.ts +2 -2
- package/embedded_network/mqtt/client.d.ts +55 -16
- package/embedded_network/ntp/client.d.ts +16 -8
- package/embedded_network/websocket/client.d.ts +49 -29
- package/embedded_provider/builtin.d.ts +40 -34
- package/file.d.ts +4 -0
- package/flash.d.ts +1 -0
- package/global.d.ts +0 -3
- package/host/default.d.ts +31 -0
- package/host/esp32/moddable_six.d.ts +50 -0
- package/host/esp32/moddable_two.d.ts +55 -0
- package/host/generic.d.ts +47 -0
- package/host/index.d.ts +24 -0
- package/host/lin.d.ts +30 -0
- package/host/mac.d.ts +30 -0
- package/host/pebble.d.ts +70 -0
- package/host/win.d.ts +30 -0
- package/http.d.ts +2 -0
- package/mcpack.d.ts +20 -0
- package/mdns.d.ts +1 -0
- package/modules.d.ts +1 -1
- package/mqtt/js.d.ts +22 -4
- package/neopixel.d.ts +2 -2
- package/onewire.d.ts +31 -0
- package/package.json +14 -4
- package/pebble/accelerometer.d.ts +5 -5
- package/pebble/battery.d.ts +3 -3
- package/pebble/button.d.ts +2 -2
- package/pebble/compass.d.ts +3 -3
- package/pebble/dictation.d.ts +2 -2
- package/pebble/global.d.ts +37 -3
- package/pebble/health.d.ts +2 -2
- package/pebble/location.d.ts +2 -2
- package/pebble/message.d.ts +5 -5
- package/pebble/piu.d.ts +2 -57
- package/pebble/poco.d.ts +2 -2
- package/pebble/texture.d.ts +33 -0
- package/pebble/touch.d.ts +47 -0
- package/ping.d.ts +1 -0
- package/pins/analog.d.ts +1 -0
- package/pins/audioin.d.ts +1 -0
- package/pins/digital.d.ts +1 -0
- package/pins/i2c.d.ts +1 -0
- package/pins/pwm.d.ts +1 -0
- package/pins/rmt.d.ts +1 -0
- package/pins/servo.d.ts +1 -0
- package/pins/smbus.d.ts +1 -0
- package/piu/MC-types.d.ts +231 -97
- package/piu/MC.d.ts +2 -1
- package/piu/QRCode.d.ts +5 -0
- package/piu/RoundRect.d.ts +53 -0
- package/piu/SVGImage.d.ts +62 -0
- package/piu/Timeline.d.ts +17 -21
- package/pococolorcell.d.ts +25 -0
- package/pocoqrcode.d.ts +25 -0
- package/pocostatic.d.ts +25 -0
- package/preference.d.ts +1 -0
- package/securesocket.d.ts +1 -0
- package/sntp.d.ts +1 -0
- package/socket.d.ts +6 -0
- package/ssl/session.d.ts +60 -0
- package/time.d.ts +1 -1
- package/tsconfig.es2024.json +0 -1
- package/tsconfig.es2025.json +1 -1
- package/web/bluetooth.d.ts +112 -0
- package/web/decompressionstream.d.ts +1 -1
- package/web/eventsource.d.ts +12 -7
- package/web/fetch-streams.d.ts +57 -0
- package/web/fetch.d.ts +1 -1
- package/web/serial.d.ts +58 -0
- package/web/websocket.d.ts +18 -13
- package/web/webstorage.d.ts +3 -0
- package/web/worker.d.ts +2 -0
- package/websocket.d.ts +2 -0
- package/wifi.d.ts +1 -0
- package/xs.d.ts +54 -6
- package/display.d.ts +0 -68
- package/pebble/device.d.ts +0 -51
package/embedded/display.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ declare module "embedded:display" {
|
|
|
30
30
|
brightness?: number; // 0-1 range
|
|
31
31
|
rotation?: 0 | 90 | 180 | 270;
|
|
32
32
|
format?: typeof Bitmap.RGB565LE | typeof Bitmap.RGB24 | typeof Bitmap.Gray256;
|
|
33
|
+
flip?: "" | "h" | "v" | "hv";
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
export interface DisplayConfiguration {
|
|
@@ -43,9 +44,10 @@ declare module "embedded:display" {
|
|
|
43
44
|
y: number;
|
|
44
45
|
width: number;
|
|
45
46
|
height: number;
|
|
47
|
+
continue?: boolean; // true to continue updating the same frame buffer
|
|
46
48
|
}
|
|
47
49
|
|
|
48
|
-
class Display {
|
|
50
|
+
class Display implements Disposable {
|
|
49
51
|
constructor(options: DisplayConstructorOptions);
|
|
50
52
|
close(): void;
|
|
51
53
|
|
|
@@ -58,12 +60,15 @@ declare module "embedded:display" {
|
|
|
58
60
|
send(buffer: ByteBuffer, offset: number, length: number): void;
|
|
59
61
|
end(): void;
|
|
60
62
|
|
|
61
|
-
|
|
63
|
+
adaptInvalid(rectangle: Rectangle): void;
|
|
62
64
|
|
|
63
65
|
get width(): number;
|
|
64
66
|
get height(): number;
|
|
67
|
+
|
|
68
|
+
corner?: number; // circular & roundrect displays
|
|
69
|
+
|
|
70
|
+
[Symbol.dispose](): void;
|
|
65
71
|
}
|
|
66
|
-
interface Display extends Disposable {}
|
|
67
72
|
|
|
68
73
|
export default Display;
|
|
69
74
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2024-
|
|
2
|
+
* Copyright (c) 2024-2026 Moddable Tech, Inc.
|
|
3
3
|
*
|
|
4
4
|
* This file is part of the Moddable SDK Runtime.
|
|
5
5
|
*
|
|
@@ -27,7 +27,7 @@ declare module "embedded:storage/files" {
|
|
|
27
27
|
isSymbolicLink(): boolean;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
export class File {
|
|
30
|
+
export class File implements Disposable {
|
|
31
31
|
// Use Directory.openFile() to create File instances
|
|
32
32
|
close(): void;
|
|
33
33
|
|
|
@@ -38,8 +38,8 @@ declare module "embedded:storage/files" {
|
|
|
38
38
|
status(): Status;
|
|
39
39
|
setSize(length: number): void;
|
|
40
40
|
flush(): void;
|
|
41
|
+
[Symbol.dispose](): void;
|
|
41
42
|
}
|
|
42
|
-
export interface File extends Disposable {}
|
|
43
43
|
|
|
44
44
|
export interface DirectoryOpenFileOptions {
|
|
45
45
|
path: string;
|
|
@@ -54,7 +54,7 @@ declare module "embedded:storage/files" {
|
|
|
54
54
|
resolveTarget?: boolean;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
export class Directory {
|
|
57
|
+
export class Directory implements Disposable {
|
|
58
58
|
// use device.files to access file system root
|
|
59
59
|
close(): void;
|
|
60
60
|
|
|
@@ -70,8 +70,11 @@ declare module "embedded:storage/files" {
|
|
|
70
70
|
createLink?(path: string, target: string): void;
|
|
71
71
|
readLink?(path: string): string;
|
|
72
72
|
|
|
73
|
-
scan(path?: string):
|
|
74
|
-
[Symbol.iterator]():
|
|
73
|
+
scan(path?: string): IteratorObject<string, undefined, unknown>;
|
|
74
|
+
[Symbol.iterator](): IteratorObject<string, undefined, unknown>;
|
|
75
|
+
[Symbol.dispose](): void;
|
|
75
76
|
}
|
|
76
|
-
|
|
77
|
+
|
|
78
|
+
const root: Directory;
|
|
79
|
+
export default root;
|
|
77
80
|
}
|
|
@@ -32,7 +32,7 @@ declare module "embedded:storage/flash" {
|
|
|
32
32
|
eraseValue: number;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
export class Flash {
|
|
35
|
+
export class Flash implements Disposable {
|
|
36
36
|
// Use the default export's open() method to create Flash instances
|
|
37
37
|
close(): void;
|
|
38
38
|
|
|
@@ -45,8 +45,8 @@ declare module "embedded:storage/flash" {
|
|
|
45
45
|
status(): FlashStatus;
|
|
46
46
|
|
|
47
47
|
format: "buffer";
|
|
48
|
+
[Symbol.dispose](): void;
|
|
48
49
|
}
|
|
49
|
-
export interface Flash extends Disposable {}
|
|
50
50
|
|
|
51
51
|
const FlashStorage: {
|
|
52
52
|
open(options: FlashOpenOptions): Flash;
|
|
@@ -27,24 +27,45 @@ declare module "embedded:storage/key-value" {
|
|
|
27
27
|
|
|
28
28
|
export type StorageFormat = "buffer" | "string" | "uint8" | "int8" | "uint16" | "int16" | "uint32" | "int32" | "uint64" | "int64";
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
// the type read() returns for each format
|
|
31
|
+
export interface StorageFormats {
|
|
32
|
+
buffer: ArrayBuffer;
|
|
33
|
+
string: string;
|
|
34
|
+
uint8: number;
|
|
35
|
+
int8: number;
|
|
36
|
+
uint16: number;
|
|
37
|
+
int16: number;
|
|
38
|
+
uint32: number;
|
|
39
|
+
int32: number;
|
|
40
|
+
uint64: bigint;
|
|
41
|
+
int64: bigint;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/*
|
|
45
|
+
F is the format named in the options passed to open(). Naming it there
|
|
46
|
+
(format: "string") fixes the type read() returns.
|
|
47
|
+
When the options name no format, read() is typed as returning any of the types,
|
|
48
|
+
because the format can be changed later through the format property.
|
|
49
|
+
*/
|
|
50
|
+
export class Storage<F extends StorageFormat = StorageFormat> implements Disposable {
|
|
31
51
|
// Use the default export's open() method to create Storage instances
|
|
32
52
|
close(): void;
|
|
33
53
|
|
|
34
54
|
delete(key: string): void;
|
|
35
55
|
|
|
36
|
-
read(key: string):
|
|
56
|
+
read(key: string): StorageFormats[F] | undefined;
|
|
37
57
|
read(key: string, buffer: ByteBuffer): number | undefined;
|
|
38
58
|
write(key: string, value: ByteBuffer | string | number | bigint): void;
|
|
39
59
|
|
|
40
|
-
[Symbol.iterator]():
|
|
60
|
+
[Symbol.iterator](): Iterator<string>;
|
|
41
61
|
|
|
42
|
-
format:
|
|
62
|
+
get format(): F;
|
|
63
|
+
set format(value: StorageFormat);
|
|
64
|
+
[Symbol.dispose](): void;
|
|
43
65
|
}
|
|
44
|
-
export interface Storage extends Disposable {}
|
|
45
66
|
|
|
46
67
|
const KeyValueStorage: {
|
|
47
|
-
open(options: StorageOpenOptions): Storage
|
|
68
|
+
open<F extends StorageFormat = StorageFormat>(options: StorageOpenOptions & { format?: F }): Storage<F>;
|
|
48
69
|
};
|
|
49
70
|
|
|
50
71
|
export default KeyValueStorage;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2026 Moddable Tech, Inc.
|
|
3
|
+
*
|
|
4
|
+
* This file is part of the Moddable SDK Tools.
|
|
5
|
+
*
|
|
6
|
+
* The Moddable SDK Tools is free software: you can redistribute it and/or modify
|
|
7
|
+
* it under the terms of the GNU General Public License as published by
|
|
8
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
* (at your option) any later version.
|
|
10
|
+
*
|
|
11
|
+
* The Moddable SDK Tools is distributed in the hope that it will be useful,
|
|
12
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
* GNU General Public License for more details.
|
|
15
|
+
*
|
|
16
|
+
* You should have received a copy of the GNU General Public License
|
|
17
|
+
* along with the Moddable SDK Tools. If not, see <http://www.gnu.org/licenses/>.
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/// <reference path="../config/system.d.ts" />
|
|
22
|
+
|
|
23
|
+
declare module "embedded:system" {
|
|
24
|
+
interface RestartOptions {
|
|
25
|
+
type?: "soft" | "hard";
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Every method is optional: a host provides only those appropriate to it, so test for a method before calling it.
|
|
30
|
+
*/
|
|
31
|
+
interface System {
|
|
32
|
+
restart?(options?: RestartOptions): never;
|
|
33
|
+
shutdown?(): never;
|
|
34
|
+
exit?(reason?: unknown): never;
|
|
35
|
+
/**
|
|
36
|
+
* @param duration milliseconds
|
|
37
|
+
*/
|
|
38
|
+
sleep?(duration: number): void;
|
|
39
|
+
/**
|
|
40
|
+
* nRF52 extension. Without a duration, enters System OFF sleep; with a duration, enters System ON sleep
|
|
41
|
+
* with RAM powered off, waking after `duration` milliseconds. Either way, wake-up reboots.
|
|
42
|
+
* Returns without sleeping in debug builds.
|
|
43
|
+
*/
|
|
44
|
+
deepSleep?(duration?: number): void;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const System: Readonly<System>;
|
|
48
|
+
export default System;
|
|
49
|
+
}
|
package/embedded_io/_common.d.ts
CHANGED
|
@@ -20,7 +20,46 @@
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
declare module "embedded:io/_common" {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Pin and port specifiers are host-dependent values (ECMA-419 9.1 and 9.2).
|
|
25
|
+
* A host declares its own by merging `pin` and/or `port` into this interface, for example:
|
|
26
|
+
*
|
|
27
|
+
* declare module "embedded:io/_common" {
|
|
28
|
+
* interface HostSpecifiers {
|
|
29
|
+
* pin: {port: string; pin: number};
|
|
30
|
+
* port: string;
|
|
31
|
+
* }
|
|
32
|
+
* }
|
|
33
|
+
*
|
|
34
|
+
* A host that declares nothing uses numbers.
|
|
35
|
+
*/
|
|
36
|
+
export interface HostSpecifiers {}
|
|
37
|
+
|
|
38
|
+
export type PinSpecifier = HostSpecifiers extends {pin: infer T} ? T : number
|
|
39
|
+
export type PortSpecifier = HostSpecifiers extends {port: infer T} ? T : number
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The constructor options that select the hardware of an IO class are host-dependent too.
|
|
43
|
+
* ECMA-419 defines them as pins. A host that selects hardware another way, such as by name
|
|
44
|
+
* from a devicetree, declares the options of a class by merging a property with the name
|
|
45
|
+
* of the class into this interface, for example:
|
|
46
|
+
*
|
|
47
|
+
* declare module "embedded:io/_common" {
|
|
48
|
+
* interface HostOptions {
|
|
49
|
+
* PWM: {port: PortSpecifier; channel?: number};
|
|
50
|
+
* }
|
|
51
|
+
* }
|
|
52
|
+
*
|
|
53
|
+
* These replace the hardware options ECMA-419 defines for the class: its other options are unchanged.
|
|
54
|
+
*/
|
|
55
|
+
export interface HostOptions {}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The constructor options of IO class `Name`: the host's hardware options if it declares any,
|
|
59
|
+
* otherwise `Hardware` (those of ECMA-419), together with `Rest`.
|
|
60
|
+
*/
|
|
61
|
+
export type IOOptions<Name extends string, Hardware, Rest> =
|
|
62
|
+
Flatten<(HostOptions extends Record<Name, infer T> ? T : Hardware) & Rest>
|
|
63
|
+
|
|
64
|
+
type Flatten<T> = {[K in keyof T]: T[K]}
|
|
26
65
|
}
|
package/embedded_io/analog.d.ts
CHANGED
|
@@ -20,22 +20,22 @@
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
declare module "embedded:io/analog" {
|
|
23
|
-
import { PinSpecifier } from "embedded:io/_common";
|
|
24
|
-
class Analog {
|
|
25
|
-
constructor(options: {
|
|
23
|
+
import { PinSpecifier, IOOptions } from "embedded:io/_common";
|
|
24
|
+
class Analog implements Disposable {
|
|
25
|
+
constructor(options: IOOptions<"Analog", {
|
|
26
26
|
pin: PinSpecifier;
|
|
27
|
+
}, {
|
|
27
28
|
resolution?: number;
|
|
28
|
-
onReadable?: (this: Analog) => void;
|
|
29
29
|
format?: "number";
|
|
30
|
-
|
|
30
|
+
target?: any;
|
|
31
|
+
}>);
|
|
31
32
|
readonly resolution: number;
|
|
32
|
-
onReadable?: () => void;
|
|
33
33
|
read(): number;
|
|
34
34
|
close(): void;
|
|
35
35
|
get format(): "number"
|
|
36
36
|
set format(value: "number")
|
|
37
37
|
target?: any;
|
|
38
|
+
[Symbol.dispose](): void;
|
|
38
39
|
}
|
|
39
|
-
interface Analog extends Disposable {}
|
|
40
40
|
export default Analog;
|
|
41
41
|
}
|
|
@@ -29,7 +29,8 @@ declare module "embedded:io/audio/in" {
|
|
|
29
29
|
target?: any;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
class AudioIn {
|
|
32
|
+
class AudioIn implements Disposable {
|
|
33
|
+
target?: any;
|
|
33
34
|
constructor(options: AudioInOptions & {
|
|
34
35
|
onReadable?: (this: AudioIn, byteLength: number, sampleCount?: number) => void;
|
|
35
36
|
});
|
|
@@ -44,8 +45,8 @@ declare module "embedded:io/audio/in" {
|
|
|
44
45
|
readonly audioType: AudioType;
|
|
45
46
|
get format(): "buffer"
|
|
46
47
|
set format(value: "buffer")
|
|
48
|
+
[Symbol.dispose](): void;
|
|
47
49
|
}
|
|
48
|
-
interface AudioIn extends Disposable {}
|
|
49
50
|
|
|
50
51
|
export { AudioIn as default };
|
|
51
52
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2025 Satoshi Tanaka
|
|
2
|
+
* Copyright (c) 2025-2026 Satoshi Tanaka
|
|
3
3
|
*
|
|
4
4
|
* This file is part of the Moddable SDK Tools.
|
|
5
5
|
*
|
|
@@ -29,8 +29,9 @@ declare module "embedded:io/audio/out" {
|
|
|
29
29
|
target?: any;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
class AudioOut {
|
|
33
|
-
|
|
32
|
+
class AudioOut implements Disposable {
|
|
33
|
+
target?: any;
|
|
34
|
+
constructor(options: AudioOutOptions & {
|
|
34
35
|
onWritable?: (this: AudioOut, byteLength: number, sampleCount?: number) => void;
|
|
35
36
|
});
|
|
36
37
|
write(buffer: ByteBuffer): void;
|
|
@@ -45,8 +46,15 @@ declare module "embedded:io/audio/out" {
|
|
|
45
46
|
get format(): "buffer"
|
|
46
47
|
set format(value: "buffer")
|
|
47
48
|
volume: number;
|
|
49
|
+
[Symbol.dispose](): void;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
namespace AudioOut {
|
|
53
|
+
class Async extends AudioOut {
|
|
54
|
+
constructor(options: AudioOutOptions);
|
|
55
|
+
write(buffer: ByteBuffer, callback?: (this: Async, error: Error | null) => void): void;
|
|
56
|
+
}
|
|
48
57
|
}
|
|
49
|
-
interface AudioOut extends Disposable {}
|
|
50
58
|
|
|
51
59
|
export { AudioOut as default };
|
|
52
60
|
}
|
|
@@ -17,13 +17,13 @@ declare module "embedded:io/bluetoothle/central" {
|
|
|
17
17
|
onReadable?: (this: GAPClient, count: number) => void;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
class GAPClient {
|
|
20
|
+
class GAPClient implements Disposable {
|
|
21
21
|
constructor(options: GAPClientOptions);
|
|
22
22
|
target: any;
|
|
23
23
|
close(): void;
|
|
24
24
|
read(): Advertisement;
|
|
25
|
+
[Symbol.dispose](): void;
|
|
25
26
|
}
|
|
26
|
-
interface GAPClient extends Disposable {}
|
|
27
27
|
|
|
28
28
|
interface GATTClientNotifiedValue extends ArrayBuffer {
|
|
29
29
|
handle: number
|
|
@@ -58,7 +58,7 @@ declare module "embedded:io/bluetoothle/central" {
|
|
|
58
58
|
get uuid(): string;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
class GATTClient {
|
|
61
|
+
class GATTClient implements Disposable {
|
|
62
62
|
constructor(options: GATTClientOptions);
|
|
63
63
|
target: any;
|
|
64
64
|
|
|
@@ -100,8 +100,9 @@ declare module "embedded:io/bluetoothle/central" {
|
|
|
100
100
|
write: 8;
|
|
101
101
|
writeWithOutResponse: 4;
|
|
102
102
|
};
|
|
103
|
+
[Symbol.dispose](): void;
|
|
103
104
|
}
|
|
104
|
-
interface GATTClient extends Disposable {}
|
|
105
105
|
|
|
106
106
|
export { GATTClient, GAPClient };
|
|
107
|
+
export type { Advertisement, GAPClientOptions, GATTClientNotifiedValue, GATTClientWriteOptions, GATTClientOptions, GATTClientService, GATTClientCharacteristic, GATTClientDescriptor };
|
|
107
108
|
}
|
|
@@ -15,10 +15,10 @@ declare module "embedded:io/bluetoothle/peripheral" {
|
|
|
15
15
|
|
|
16
16
|
interface GATTServerConnection extends Disposable {
|
|
17
17
|
close(): void;
|
|
18
|
-
notify(characteristic: GATTServerCharacteristic, value:
|
|
18
|
+
notify(characteristic: GATTServerCharacteristic, value: ByteBuffer, callback?: (error?: Error) => void): void;
|
|
19
19
|
replyToPasskey(action: "input" | "compareNumber" | "outOfBand", value: number | boolean | ArrayBuffer): void;
|
|
20
20
|
disconnect(): void;
|
|
21
|
-
readonly
|
|
21
|
+
readonly maximumWrite: number;
|
|
22
22
|
readonly remoteAddress: string | undefined;
|
|
23
23
|
}
|
|
24
24
|
|
|
@@ -36,7 +36,7 @@ declare module "embedded:io/bluetoothle/peripheral" {
|
|
|
36
36
|
onRead?(this: GATTServerCharacteristic, connection: GATTServerConnection): ByteBuffer;
|
|
37
37
|
onWrite?(this: GATTServerCharacteristic, value: ArrayBuffer, connection: GATTServerConnection): void;
|
|
38
38
|
onSubscribe?(this: GATTServerCharacteristic, connection: GATTServerConnection): void;
|
|
39
|
-
onUnsubscribe?(
|
|
39
|
+
onUnsubscribe?(this: GATTServerCharacteristic, connection: GATTServerConnection): void;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
interface GATTServerDescriptor {
|
|
@@ -55,7 +55,7 @@ declare module "embedded:io/bluetoothle/peripheral" {
|
|
|
55
55
|
[ADType: number]: ByteBuffer;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
class GATTServer {
|
|
58
|
+
class GATTServer implements Disposable {
|
|
59
59
|
constructor(options: GATTServerOptions);
|
|
60
60
|
|
|
61
61
|
close(): void;
|
|
@@ -87,8 +87,9 @@ declare module "embedded:io/bluetoothle/peripheral" {
|
|
|
87
87
|
dualModeController: 8;
|
|
88
88
|
dualModeHost: 16;
|
|
89
89
|
}
|
|
90
|
+
[Symbol.dispose](): void;
|
|
90
91
|
}
|
|
91
|
-
interface GATTServer extends Disposable {}
|
|
92
92
|
|
|
93
93
|
export { GATTServer };
|
|
94
|
+
export type { GATTServerOptions, GATTServerConnection, GATTServerService, GATTServerCharacteristic, GATTServerDescriptor, GATTServerAdvertisingRecords };
|
|
94
95
|
}
|
|
@@ -31,7 +31,7 @@ declare module "embedded:io/crypt/digest" {
|
|
|
31
31
|
}
|
|
32
32
|
type DigestOptions = DigestOptionsBase | DigestOptionsGHASH;
|
|
33
33
|
|
|
34
|
-
class Digest {
|
|
34
|
+
class Digest implements Disposable {
|
|
35
35
|
constructor(options: DigestOptions);
|
|
36
36
|
write(data: ByteBuffer): void;
|
|
37
37
|
read(): ArrayBuffer;
|
|
@@ -40,8 +40,8 @@ declare module "embedded:io/crypt/digest" {
|
|
|
40
40
|
close(): void;
|
|
41
41
|
readonly blockSize: number;
|
|
42
42
|
readonly outputSize: number;
|
|
43
|
+
[Symbol.dispose](): void;
|
|
43
44
|
}
|
|
44
|
-
interface Digest extends Disposable {}
|
|
45
45
|
|
|
46
46
|
export default Digest;
|
|
47
47
|
}
|
package/embedded_io/digital.d.ts
CHANGED
|
@@ -32,7 +32,8 @@ declare module "embedded:io/digital" {
|
|
|
32
32
|
| typeof Digital.OutputOpenDrain
|
|
33
33
|
| typeof Digital.ActiveLow
|
|
34
34
|
|
|
35
|
-
class Digital {
|
|
35
|
+
class Digital implements Disposable {
|
|
36
|
+
target?: any;
|
|
36
37
|
static readonly Input: number
|
|
37
38
|
static readonly InputPullUp: number
|
|
38
39
|
static readonly InputPullDown: number
|
|
@@ -57,14 +58,14 @@ declare module "embedded:io/digital" {
|
|
|
57
58
|
edge?: Edge;
|
|
58
59
|
}));
|
|
59
60
|
|
|
60
|
-
write(value:
|
|
61
|
+
write(value: number): void;
|
|
61
62
|
read(): 0 | 1;
|
|
62
63
|
close(): void;
|
|
63
64
|
|
|
64
65
|
get format(): "number"
|
|
65
66
|
set format(value: "number")
|
|
67
|
+
[Symbol.dispose](): void;
|
|
66
68
|
}
|
|
67
|
-
interface Digital extends Disposable {}
|
|
68
69
|
|
|
69
70
|
export default Digital;
|
|
70
71
|
}
|
|
@@ -19,6 +19,8 @@
|
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
21
|
declare module "embedded:io/digitalbank" {
|
|
22
|
+
import { IOOptions } from "embedded:io/_common";
|
|
23
|
+
|
|
22
24
|
type Mode =
|
|
23
25
|
| typeof DigitalBank.Input
|
|
24
26
|
| typeof DigitalBank.InputPullUp
|
|
@@ -28,7 +30,8 @@ declare module "embedded:io/digitalbank" {
|
|
|
28
30
|
| typeof DigitalBank.OutputOpenDrain
|
|
29
31
|
| typeof DigitalBank.ActiveLow
|
|
30
32
|
|
|
31
|
-
class DigitalBank {
|
|
33
|
+
class DigitalBank implements Disposable {
|
|
34
|
+
target?: any;
|
|
32
35
|
static readonly Input: number
|
|
33
36
|
static readonly InputPullUp: number
|
|
34
37
|
static readonly InputPullDown: number
|
|
@@ -37,10 +40,11 @@ declare module "embedded:io/digitalbank" {
|
|
|
37
40
|
static readonly OutputOpenDrain: number
|
|
38
41
|
static readonly ActiveLow: number
|
|
39
42
|
|
|
40
|
-
constructor(dictionary: {
|
|
43
|
+
constructor(dictionary: IOOptions<"DigitalBank", {
|
|
44
|
+
bank?: number | string;
|
|
45
|
+
}, {
|
|
41
46
|
pins: number;
|
|
42
47
|
mode: Mode;
|
|
43
|
-
bank?: number | string;
|
|
44
48
|
activeLow?: boolean;
|
|
45
49
|
initialValue?: number;
|
|
46
50
|
rises?: number;
|
|
@@ -48,7 +52,7 @@ declare module "embedded:io/digitalbank" {
|
|
|
48
52
|
onReadable?: (this: DigitalBank, trigger: number) => void;
|
|
49
53
|
format?: "number";
|
|
50
54
|
target?: any;
|
|
51
|
-
})
|
|
55
|
+
}>)
|
|
52
56
|
|
|
53
57
|
close(): void;
|
|
54
58
|
read(): number;
|
|
@@ -56,8 +60,8 @@ declare module "embedded:io/digitalbank" {
|
|
|
56
60
|
|
|
57
61
|
get format(): "number"
|
|
58
62
|
set format(value: "number")
|
|
63
|
+
[Symbol.dispose](): void;
|
|
59
64
|
}
|
|
60
|
-
interface DigitalBank extends Disposable {}
|
|
61
65
|
|
|
62
66
|
export default DigitalBank;
|
|
63
67
|
}
|
package/embedded_io/i2c.d.ts
CHANGED
|
@@ -20,17 +20,20 @@
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
declare module "embedded:io/i2c" {
|
|
23
|
-
import { PinSpecifier, PortSpecifier } from "embedded:io/_common";
|
|
24
|
-
class I2C {
|
|
25
|
-
|
|
23
|
+
import { PinSpecifier, PortSpecifier, IOOptions } from "embedded:io/_common";
|
|
24
|
+
class I2C implements Disposable {
|
|
25
|
+
target?: any;
|
|
26
|
+
constructor(options: IOOptions<"I2C", {
|
|
26
27
|
data: PinSpecifier;
|
|
27
28
|
clock: PinSpecifier;
|
|
29
|
+
port?: PortSpecifier;
|
|
30
|
+
}, {
|
|
28
31
|
hz: number;
|
|
29
32
|
address: number;
|
|
30
|
-
|
|
33
|
+
timeout?: number; // milliseconds (Moddable SDK extension)
|
|
31
34
|
format?: "buffer";
|
|
32
35
|
target?: any;
|
|
33
|
-
});
|
|
36
|
+
}>);
|
|
34
37
|
readonly resolution: number;
|
|
35
38
|
|
|
36
39
|
write(value: ByteBuffer, stop?: boolean): void;
|
|
@@ -41,8 +44,8 @@ declare module "embedded:io/i2c" {
|
|
|
41
44
|
close(): void;
|
|
42
45
|
get format(): "buffer"
|
|
43
46
|
set format(value: "buffer")
|
|
47
|
+
[Symbol.dispose](): void;
|
|
44
48
|
}
|
|
45
|
-
interface I2C extends Disposable {}
|
|
46
49
|
|
|
47
50
|
export default I2C;
|
|
48
51
|
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2026 Moddable Tech, Inc.
|
|
3
|
+
*
|
|
4
|
+
* This file is part of the Moddable SDK Tools.
|
|
5
|
+
*
|
|
6
|
+
* The Moddable SDK Tools is free software: you can redistribute it and/or modify
|
|
7
|
+
* it under the terms of the GNU General Public License as published by
|
|
8
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
* (at your option) any later version.
|
|
10
|
+
*
|
|
11
|
+
* The Moddable SDK Tools is distributed in the hope that it will be useful,
|
|
12
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
* GNU General Public License for more details.
|
|
15
|
+
*
|
|
16
|
+
* You should have received a copy of the GNU General Public License
|
|
17
|
+
* along with the Moddable SDK Tools. If not, see <http://www.gnu.org/licenses/>.
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
declare module "embedded:io/image/in/camera" {
|
|
22
|
+
// pixel format constants are those of commodetto/Bitmap; "jpeg" selects compressed frames
|
|
23
|
+
export type ImageType = number | "jpeg";
|
|
24
|
+
|
|
25
|
+
export interface CameraFrame extends HostBuffer, Disposable {
|
|
26
|
+
readonly camera: Camera;
|
|
27
|
+
close(): void;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface CameraConfiguration {
|
|
31
|
+
brightness?: number;
|
|
32
|
+
contrast?: number;
|
|
33
|
+
saturation?: number;
|
|
34
|
+
sharpness?: number;
|
|
35
|
+
denoise?: number;
|
|
36
|
+
whiteBalance?: number;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export type Format = "buffer" | "buffer/disposable";
|
|
40
|
+
|
|
41
|
+
export interface Options<F extends Format = Format> {
|
|
42
|
+
width?: number;
|
|
43
|
+
height?: number;
|
|
44
|
+
imageType?: ImageType;
|
|
45
|
+
format?: F;
|
|
46
|
+
onReadable?: (this: Camera<F>, count: number) => void;
|
|
47
|
+
target?: any;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/*
|
|
51
|
+
F is the format named in the options when the camera is created. Naming it there
|
|
52
|
+
(format: "buffer") fixes the type read() with no argument returns:
|
|
53
|
+
a CameraFrame for "buffer/disposable", an ArrayBuffer for "buffer".
|
|
54
|
+
When the options name no format, read() is typed as returning either, because the
|
|
55
|
+
format can be changed later through the format property.
|
|
56
|
+
*/
|
|
57
|
+
interface Camera<F extends Format = Format> extends Disposable {
|
|
58
|
+
target?: any;
|
|
59
|
+
close(): void;
|
|
60
|
+
// format "buffer/disposable" returns the frame without copying; close it to release it to the camera
|
|
61
|
+
read(): (F extends "buffer/disposable" ? CameraFrame : ArrayBuffer) | undefined;
|
|
62
|
+
read(buffer: ByteBuffer): number | undefined;
|
|
63
|
+
start(): void;
|
|
64
|
+
stop(): void;
|
|
65
|
+
configure(options: CameraConfiguration): void;
|
|
66
|
+
get format(): F;
|
|
67
|
+
set format(value: Format);
|
|
68
|
+
readonly imageType: ImageType;
|
|
69
|
+
readonly width: number;
|
|
70
|
+
readonly height: number;
|
|
71
|
+
readonly identification: { model: string };
|
|
72
|
+
readonly configuration: CameraConfiguration;
|
|
73
|
+
[Symbol.dispose](): void;
|
|
74
|
+
}
|
|
75
|
+
interface CameraConstructor {
|
|
76
|
+
new <F extends Format = Format>(options: Options<F>): Camera<F>;
|
|
77
|
+
readonly prototype: Camera;
|
|
78
|
+
}
|
|
79
|
+
const Camera: CameraConstructor;
|
|
80
|
+
|
|
81
|
+
export default Camera;
|
|
82
|
+
}
|
|
@@ -19,23 +19,25 @@
|
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
21
|
declare module "embedded:io/pulsecount" {
|
|
22
|
-
import { PinSpecifier } from "embedded:io/_common";
|
|
23
|
-
class PulseCount {
|
|
24
|
-
|
|
22
|
+
import { PinSpecifier, IOOptions } from "embedded:io/_common";
|
|
23
|
+
class PulseCount implements Disposable {
|
|
24
|
+
target?: any;
|
|
25
|
+
constructor (options: IOOptions<"PulseCount", {
|
|
25
26
|
signal: PinSpecifier;
|
|
26
27
|
control: PinSpecifier;
|
|
28
|
+
}, {
|
|
27
29
|
onReadable?: (this: PulseCount) => void;
|
|
28
30
|
onError?: (this: PulseCount) => void;
|
|
29
31
|
format?: "number";
|
|
30
32
|
target?: any;
|
|
31
|
-
});
|
|
33
|
+
}>);
|
|
32
34
|
read(): number;
|
|
33
35
|
write(count: number): void;
|
|
34
36
|
close(): void;
|
|
35
37
|
get format(): "number";
|
|
36
38
|
set format(value: "number");
|
|
39
|
+
[Symbol.dispose](): void;
|
|
37
40
|
}
|
|
38
|
-
interface PulseCount extends Disposable {}
|
|
39
41
|
|
|
40
42
|
export default PulseCount;
|
|
41
43
|
}
|