@moddable/typings 6.1.0 → 7.1.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.
Files changed (51) hide show
  1. package/base64.d.ts +1 -1
  2. package/commodetto/Bitmap.d.ts +1 -1
  3. package/commodetto/BufferOut.d.ts +2 -2
  4. package/commodetto/Convert.d.ts +3 -3
  5. package/commodetto/ReadGIF.d.ts +1 -1
  6. package/commodetto/ReadPNG.d.ts +2 -2
  7. package/commodetto/loadJPEG.d.ts +1 -1
  8. package/commodetto/parseBMF.d.ts +1 -1
  9. package/commodetto/parseNFNT.d.ts +1 -1
  10. package/commodetto/readJPEG.d.ts +2 -2
  11. package/crc.d.ts +2 -2
  12. package/{deflate.ts → deflate.d.ts} +1 -1
  13. package/display.d.ts +68 -0
  14. package/dns/parser.d.ts +61 -6
  15. package/dns/serializer.d.ts +3 -2
  16. package/embedded/RTC.d.ts +42 -0
  17. package/embedded/display.d.ts +68 -0
  18. package/embedded/storage/files.d.ts +75 -0
  19. package/embedded/storage/flash.d.ts +56 -0
  20. package/embedded/storage/key-value.d.ts +49 -0
  21. package/embedded_io/_common.d.ts +0 -1
  22. package/embedded_io/audio/in.d.ts +1 -3
  23. package/embedded_io/audio/out.d.ts +1 -3
  24. package/embedded_io/ble/_common.d.ts +14 -0
  25. package/embedded_io/ble/{client.d.ts → central.d.ts} +10 -24
  26. package/embedded_io/ble/peripheral.d.ts +91 -0
  27. package/embedded_io/digital.d.ts +8 -6
  28. package/embedded_io/digitalbank.d.ts +8 -6
  29. package/embedded_io/i2c.d.ts +3 -3
  30. package/embedded_io/serial.d.ts +3 -3
  31. package/embedded_io/smbus.d.ts +2 -3
  32. package/embedded_io/socket/tcp.d.ts +2 -3
  33. package/embedded_io/socket/udp.d.ts +1 -2
  34. package/embedded_io/spi.d.ts +4 -4
  35. package/embedded_network/http/client.d.ts +2 -4
  36. package/embedded_network/interface/ethernet.d.ts +42 -0
  37. package/embedded_network/interface/wifi.d.ts +60 -0
  38. package/embedded_network/mqtt/client.d.ts +4 -5
  39. package/embedded_network/ntp/client.d.ts +43 -0
  40. package/flash.d.ts +1 -1
  41. package/hex.d.ts +1 -1
  42. package/inflate.d.ts +1 -1
  43. package/neopixel.d.ts +43 -0
  44. package/neostrand.d.ts +173 -0
  45. package/package.json +1 -1
  46. package/pins/audioout.d.ts +1 -1
  47. package/qrcode.d.ts +1 -1
  48. package/securesocket.d.ts +1 -1
  49. package/socket.d.ts +1 -1
  50. package/xs.d.ts +3 -3
  51. package/zip.d.ts +1 -1
package/base64.d.ts CHANGED
@@ -21,7 +21,7 @@
21
21
  declare module "base64" {
22
22
  var Base64: {
23
23
  decode: (str: string) => ArrayBuffer;
24
- encode: (source: BufferLike | string) => string;
24
+ encode: (source: ByteBuffer | string) => string;
25
25
  }
26
26
  export {Base64 as default};
27
27
  }
@@ -22,7 +22,7 @@ declare module "commodetto/Bitmap" {
22
22
  type PixelFormat = number
23
23
 
24
24
  class Bitmap {
25
- constructor(width: number, height: number, format: PixelFormat, buffer: BufferLike, offset: number, byteLength?: number)
25
+ constructor(width: number, height: number, format: PixelFormat, buffer: ByteBuffer, offset: number, byteLength?: number)
26
26
 
27
27
  readonly pixelFormat: PixelFormat
28
28
  readonly offset: number
@@ -26,7 +26,7 @@ declare module "commodetto/BufferOut" {
26
26
  width: number;
27
27
  height: number;
28
28
  pixelFormat: number;
29
- buffer?: BufferLike;
29
+ buffer?: ByteBuffer;
30
30
  }
31
31
 
32
32
  class BufferOut {
@@ -35,7 +35,7 @@ declare module "commodetto/BufferOut" {
35
35
  end(): void;
36
36
  continue(x: number, y: number, width: number, height: number): void;
37
37
  send(
38
- pixels: BufferLike,
38
+ pixels: ByteBuffer,
39
39
  offset: number,
40
40
  count: number
41
41
  ): void;
@@ -20,9 +20,9 @@
20
20
 
21
21
  declare module "commodetto/Convert" {
22
22
  class Convert {
23
- constructor(srcFormat: number, dstFormat: number, clut?: BufferLike);
24
- process(src: BufferLike, dst: BufferLike): void;
25
- process(src: BufferLike, srcOffset: number, srcCount: number, dst: BufferLike, dstOffset: number, dstCount: number): void;
23
+ constructor(srcFormat: number, dstFormat: number, clut?: ByteBuffer);
24
+ process(src: ByteBuffer, dst: ByteBuffer): void;
25
+ process(src: ByteBuffer, srcOffset: number, srcCount: number, dst: ByteBuffer, dstOffset: number, dstCount: number): void;
26
26
  }
27
27
 
28
28
  export {Convert as default};
@@ -22,7 +22,7 @@ declare module "commodetto/ReadGIF" {
22
22
  import Bitmap from "commodetto/Bitmap"
23
23
 
24
24
  class ReadGIF extends Bitmap {
25
- constructor(buffer: BufferLike);
25
+ constructor(buffer: ByteBuffer);
26
26
  close(): void;
27
27
  first(): void;
28
28
  next(): void;
@@ -32,9 +32,9 @@ declare module "commodetto/ReadPNG" {
32
32
  }
33
33
 
34
34
  interface ReadPNGConstructor {
35
- new(buffer: BufferLike, options?: { pixelFormat: number }): ReadPNG
35
+ new(buffer: ByteBuffer, options?: { pixelFormat: number }): ReadPNG
36
36
 
37
- decompress(data: BufferLike, pixelFormat: number, alphaPixelFormat?: number): Bitmap;
37
+ decompress(data: ByteBuffer, pixelFormat: number, alphaPixelFormat?: number): Bitmap;
38
38
  }
39
39
 
40
40
  const ReadPNG: ReadPNGConstructor
@@ -21,5 +21,5 @@
21
21
  declare module "commodetto/loadJPEG" {
22
22
  import Bitmap from "commodetto/Bitmap"
23
23
 
24
- export default function (data: BufferLike, options?: {pixelFormat?: number}): Bitmap;
24
+ export default function (data: ByteBuffer, options?: {pixelFormat?: number}): Bitmap;
25
25
  }
@@ -21,5 +21,5 @@
21
21
  declare module "commodetto/parseBMF" {
22
22
  import type {Font} from "commodetto/Poco"
23
23
 
24
- export default function (bmp: BufferLike): Font
24
+ export default function (bmp: ByteBuffer): Font
25
25
  }
@@ -21,5 +21,5 @@
21
21
  declare module "commodetto/parseNFNT" {
22
22
  import type {Font} from "commodetto/Poco"
23
23
 
24
- export default function (bmp: BufferLike): Font
24
+ export default function (bmp: ByteBuffer): Font
25
25
  }
@@ -27,10 +27,10 @@ declare module "commodetto/readJPEG" {
27
27
  }
28
28
 
29
29
  class JPEG {
30
- constructor(buffer?: (BufferLike), options?: { pixelFormat: number })
30
+ constructor(buffer?: (ByteBuffer), options?: { pixelFormat: number })
31
31
 
32
32
  read(): Block
33
- push(buffer: BufferLike): void
33
+ push(buffer: ByteBuffer): void
34
34
 
35
35
  readonly ready: boolean
36
36
  }
package/crc.d.ts CHANGED
@@ -22,13 +22,13 @@ declare module "crc" {
22
22
  class CRC8 {
23
23
  constructor(polynomial: number, initial_value?: number, reflectInput?: boolean, reflectOutput?: boolean, xorOutput?: number)
24
24
  close(): void
25
- checksum(bytes: BufferLike): number
25
+ checksum(bytes: ByteBuffer): number
26
26
  reset(): this
27
27
  }
28
28
  class CRC16 {
29
29
  constructor(polynomial: number, initial_value?: number, reflectInput?: boolean, reflectOutput?: boolean, xorOutput?: number)
30
30
  close(): void
31
- checksum(bytes: BufferLike): number
31
+ checksum(bytes: ByteBuffer): number
32
32
  reset(): this
33
33
  }
34
34
  export {CRC8 as default, CRC8, CRC16};
@@ -24,7 +24,7 @@ declare module "deflate" {
24
24
  constructor(options?: {windowBits?: number, level?: number, strategy?: number});
25
25
  close(): void;
26
26
 
27
- push(buffer: BufferLike | string, end?: boolean): boolean;
27
+ push(buffer: ByteBuffer | string, end?: boolean): boolean;
28
28
 
29
29
  onData: (data: ArrayBuffer) => void;
30
30
  onEnd: (status: number) => void;
package/display.d.ts ADDED
@@ -0,0 +1,68 @@
1
+ /*
2
+ * Copyright (c) 2025 Moddable Tech, Inc.
3
+ *
4
+ * This file is part of the Moddable SDK Runtime.
5
+ *
6
+ * The Moddable SDK Runtime is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Lesser 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 Runtime 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 Lesser General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Lesser General Public License
17
+ * along with the Moddable SDK Runtime. If not, see <http://www.gnu.org/licenses/>.
18
+ *
19
+ */
20
+
21
+ declare module "embedded:display" {
22
+ export interface DisplayConstructorOptions {
23
+ format?: number;
24
+ rotation?: number;
25
+ brightness?: number;
26
+ flip?: "h" | "v" | "hv";
27
+ }
28
+
29
+ export interface DisplayConfigureOptions {
30
+ brightness?: number;
31
+ format?: number;
32
+ rotation?: number;
33
+ }
34
+
35
+ export interface DisplayConfiguration {
36
+ brightness?: number;
37
+ format?: number;
38
+ rotation?: number;
39
+ }
40
+
41
+ export interface DisplayBeginOptions {
42
+ x: number;
43
+ y: number;
44
+ width: number;
45
+ height: number;
46
+ continue?: boolean;
47
+ }
48
+
49
+ export interface DisplayRectangle {
50
+ x: number;
51
+ y: number;
52
+ width: number;
53
+ height: number;
54
+ }
55
+
56
+ export default class Display {
57
+ constructor(options: DisplayConstructorOptions);
58
+ close(): void;
59
+ configure(options: DisplayConfigureOptions): void;
60
+ get configuration(): DisplayConfiguration;
61
+ begin(options?: DisplayBeginOptions): void;
62
+ send(buffer: ByteBuffer): void;
63
+ end(): void;
64
+ adapInvalid(options: DisplayRectangle): void;
65
+ get width(): number;
66
+ get height(): number;
67
+ }
68
+ }
package/dns/parser.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  /*
2
2
  * Copyright (c) 2019-2020 Bradley Farias
3
+ * Copyright (c) 2026 Moddable Tech, Inc.
3
4
  *
4
5
  * This file is part of the Moddable SDK Tools.
5
6
  *
@@ -19,19 +20,73 @@
19
20
  */
20
21
 
21
22
  declare module "dns/parser" {
23
+ interface DNSQuestion {
24
+ qname: string[];
25
+ qtype: number;
26
+ qclass: number;
27
+ }
28
+
29
+ interface DNSSRVData {
30
+ priority: number;
31
+ weight: number;
32
+ port: number;
33
+ target: string[];
34
+ }
35
+
36
+ interface DNSAnswerA {
37
+ qname: string[];
38
+ qtype: 0x0001;
39
+ qclass: number;
40
+ ttl: number;
41
+ rdata: string;
42
+ }
43
+
44
+ interface DNSAnswerPTR {
45
+ qname: string[];
46
+ qtype: 0x000C;
47
+ qclass: number;
48
+ ttl: number;
49
+ rdata: string[];
50
+ }
51
+
52
+ interface DNSAnswerTXT {
53
+ qname: string[];
54
+ qtype: 0x0010;
55
+ qclass: number;
56
+ ttl: number;
57
+ rdata: string[];
58
+ }
59
+
60
+ interface DNSAnswerSRV {
61
+ qname: string[];
62
+ qtype: 0x0021;
63
+ qclass: number;
64
+ ttl: number;
65
+ rdata: DNSSRVData;
66
+ }
67
+
68
+ interface DNSAnswerOther {
69
+ qname: string[];
70
+ qtype: number;
71
+ qclass: number;
72
+ ttl: number;
73
+ rdata: "UNHANDLED";
74
+ }
75
+
76
+ type DNSAnswer = DNSAnswerA | DNSAnswerPTR | DNSAnswerTXT | DNSAnswerSRV | DNSAnswerOther;
77
+
22
78
  class Parser {
23
- constructor(buffer: ArrayBuffer);
79
+ constructor(buffer: ByteBuffer);
24
80
  get id(): number;
25
81
  get flags(): number;
26
82
  get questions(): number;
27
83
  get answers(): number;
28
84
  get authorities(): number;
29
85
  get additionals(): number;
30
- // TODO: not use unknown
31
- question(index: number): unknown;
32
- answer(index: number): unknown;
33
- authority(index: number): unknown;
34
- additional(index: number): unknown;
86
+ question(index: number): DNSQuestion;
87
+ answer(index: number): DNSAnswer;
88
+ authority(index: number): DNSAnswer;
89
+ additional(index: number): DNSAnswer;
35
90
  }
36
91
  export {Parser as default};
37
92
  }
@@ -25,14 +25,15 @@ declare module "dns/serializer" {
25
25
  opcode?: (typeof DNS.OPCODE)[keyof (typeof DNS.OPCODE)],
26
26
  query?: boolean,
27
27
  authoritative?: boolean,
28
- id?: number
28
+ id?: number,
29
+ recursionDesired?: boolean,
29
30
  });
30
31
  add(
31
32
  section: (typeof DNS.SECTION)[keyof (typeof DNS.SECTION)],
32
33
  name: string,
33
34
  type: (typeof DNS.RR)[keyof (typeof DNS.RR)],
34
35
  classType: (typeof DNS.CLASS)[keyof (typeof DNS.CLASS)],
35
- ttl: number,
36
+ ttl?: number,
36
37
  data?: ArrayBuffer
37
38
  ): void;
38
39
  build(): ArrayBuffer;
@@ -0,0 +1,42 @@
1
+ /*
2
+ * Copyright (c) 2025 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:RTC" {
22
+ import type {PortSpecifier} from "embedded:io/_common";
23
+
24
+ export interface RTCOptions {
25
+ target?: any;
26
+ port?: PortSpecifier;
27
+ onAlarm?: () => void;
28
+ }
29
+
30
+ export interface RTCConfigureOptions {
31
+ alarm?: number;
32
+ }
33
+
34
+ export class RTC {
35
+ constructor(options: RTCOptions);
36
+ close(): void;
37
+ time: number;
38
+ configure(options: RTCConfigureOptions): void;
39
+ }
40
+
41
+ export default RTC;
42
+ }
@@ -0,0 +1,68 @@
1
+ /*
2
+ * Copyright (c) 2025 Moddable Tech, Inc.
3
+ *
4
+ * This file is part of the Moddable SDK Runtime.
5
+ *
6
+ * The Moddable SDK Runtime is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Lesser 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 Runtime 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 Lesser General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Lesser General Public License
17
+ * along with the Moddable SDK Runtime. If not, see <http://www.gnu.org/licenses/>.
18
+ *
19
+ */
20
+
21
+ declare module "embedded:display" {
22
+ import type Bitmap from "commodetto/Bitmap";
23
+ import type { Rectangle } from "commodetto/Poco";
24
+
25
+ export interface DisplayConstructorOptions {
26
+ port: string;
27
+ }
28
+
29
+ export interface DisplayConfigureOptions {
30
+ brightness?: number; // 0-1 range
31
+ rotation?: 0 | 90 | 180 | 270;
32
+ format?: typeof Bitmap.RGB565LE | typeof Bitmap.RGB24 | typeof Bitmap.Gray256;
33
+ }
34
+
35
+ export interface DisplayConfiguration {
36
+ brightness: number; // 0-1 range
37
+ rotation: 0 | 90 | 180 | 270;
38
+ format: typeof Bitmap.RGB565LE | typeof Bitmap.RGB24 | typeof Bitmap.Gray256;
39
+ }
40
+
41
+ export interface DisplayBeginOptions {
42
+ x: number;
43
+ y: number;
44
+ width: number;
45
+ height: number;
46
+ }
47
+
48
+ class Display {
49
+ constructor(options: DisplayConstructorOptions);
50
+ close(): void;
51
+
52
+ configure(options: DisplayConfigureOptions): void;
53
+ get configuration(): DisplayConfiguration;
54
+
55
+ begin(options: DisplayBeginOptions): void;
56
+ begin(): void;
57
+ send(buffer: ByteBuffer): void;
58
+ send(buffer: ByteBuffer, offset: number, length: number): void;
59
+ end(): void;
60
+
61
+ adapInvalid(rectangle: Rectangle): void;
62
+
63
+ get width(): number;
64
+ get height(): number;
65
+ }
66
+
67
+ export default Display;
68
+ }
@@ -0,0 +1,75 @@
1
+ /*
2
+ * Copyright (c) 2024-2025 Moddable Tech, Inc.
3
+ *
4
+ * This file is part of the Moddable SDK Runtime.
5
+ *
6
+ * The Moddable SDK Runtime is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Lesser 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 Runtime 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 Lesser General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Lesser General Public License
17
+ * along with the Moddable SDK Runtime. If not, see <http://www.gnu.org/licenses/>.
18
+ *
19
+ */
20
+
21
+ declare module "embedded:storage/files" {
22
+ export class Status {
23
+ size: number;
24
+ mode: number;
25
+ isFile(): boolean;
26
+ isDirectory(): boolean;
27
+ isSymbolicLink(): boolean;
28
+ }
29
+
30
+ export class File {
31
+ // Use Directory.openFile() to create File instances
32
+ close(): void;
33
+
34
+ read(count: number, position: number): ArrayBuffer;
35
+ read(buffer: ByteBuffer, position: number): number;
36
+ write(buffer: ByteBuffer, position: number): void;
37
+
38
+ status(): Status;
39
+ setSize(length: number): void;
40
+ flush(): void;
41
+ }
42
+
43
+ export interface DirectoryOpenFileOptions {
44
+ path: string;
45
+ mode?: "r" | "r+" | "w" | "w+";
46
+ }
47
+
48
+ export interface DirectoryOpenDirectoryOptions {
49
+ path: string;
50
+ }
51
+
52
+ export interface DirectoryStatusOptions {
53
+ resolveTarget?: boolean;
54
+ }
55
+
56
+ export class Directory {
57
+ // use device.files to access file system root
58
+ close(): void;
59
+
60
+ openFile(options: DirectoryOpenFileOptions): File;
61
+ openDirectory(options: DirectoryOpenDirectoryOptions): Directory;
62
+
63
+ delete(path: string): boolean;
64
+ move(from: string, to: string, toDirectory?: Directory): void;
65
+
66
+ status(path: string, options?: DirectoryStatusOptions): Status;
67
+
68
+ createDirectory(path: string): boolean;
69
+ createLink(path: string, target: string): void;
70
+ readLink(path: string): string;
71
+
72
+ scan(path?: string): IterableIterator<string>;
73
+ [Symbol.iterator](): IterableIterator<string>;
74
+ }
75
+ }
@@ -0,0 +1,56 @@
1
+ /*
2
+ * Copyright (c) 2025 Moddable Tech, Inc.
3
+ *
4
+ * This file is part of the Moddable SDK Runtime.
5
+ *
6
+ * The Moddable SDK Runtime is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Lesser 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 Runtime 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 Lesser General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Lesser General Public License
17
+ * along with the Moddable SDK Runtime. If not, see <http://www.gnu.org/licenses/>.
18
+ *
19
+ */
20
+
21
+ declare module "embedded:storage/flash" {
22
+ export interface FlashOpenOptions {
23
+ path: string;
24
+ mode?: "r" | "r+";
25
+ }
26
+
27
+ export interface FlashStatus {
28
+ size: number;
29
+ blockLength: number;
30
+ blocks: number;
31
+ writeAlign: number;
32
+ eraseValue: number;
33
+ }
34
+
35
+ export class Flash {
36
+ // Use the default export's open() method to create Flash instances
37
+ close(): void;
38
+
39
+ eraseBlock(start: number, end?: number): void;
40
+
41
+ read(byteLength: number, byteOffset: number): ArrayBuffer;
42
+ read(buffer: ByteBuffer, byteOffset: number): number;
43
+ write(buffer: ByteBuffer, byteOffset: number): void;
44
+
45
+ status(): FlashStatus;
46
+
47
+ format: "buffer";
48
+ }
49
+
50
+ const FlashStorage: {
51
+ open(options: FlashOpenOptions): Flash;
52
+ [Symbol.iterator](): IterableIterator<string>;
53
+ };
54
+
55
+ export default FlashStorage;
56
+ }
@@ -0,0 +1,49 @@
1
+ /*
2
+ * Copyright (c) 2024-2025 Moddable Tech, Inc.
3
+ *
4
+ * This file is part of the Moddable SDK Runtime.
5
+ *
6
+ * The Moddable SDK Runtime is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Lesser 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 Runtime 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 Lesser General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Lesser General Public License
17
+ * along with the Moddable SDK Runtime. If not, see <http://www.gnu.org/licenses/>.
18
+ *
19
+ */
20
+
21
+ declare module "embedded:storage/key-value" {
22
+ export interface StorageOpenOptions {
23
+ path: string;
24
+ mode?: "r" | "r+";
25
+ }
26
+
27
+ export type StorageFormat = "buffer" | "string" | "uint8" | "int8" | "uint16" | "int16" | "uint32" | "int32" | "uint64" | "int64";
28
+
29
+ export class Storage {
30
+ // Use the default export's open() method to create Storage instances
31
+ close(): void;
32
+
33
+ delete(key: string): void;
34
+
35
+ read(key: string): ArrayBuffer | string | number | bigint;
36
+ read(key: string, buffer: ByteBuffer): number;
37
+ write(key: string, value: ByteBuffer | string | number | bigint): void;
38
+
39
+ [Symbol.iterator](): IterableIterator<string>;
40
+
41
+ format: StorageFormat;
42
+ }
43
+
44
+ const KeyValueStorage: {
45
+ open(options: StorageOpenOptions): Storage;
46
+ };
47
+
48
+ export default KeyValueStorage;
49
+ }
@@ -23,5 +23,4 @@ declare module "embedded:io/_common" {
23
23
  // This should be extended for future specification
24
24
  export type PinSpecifier = number
25
25
  export type PortSpecifier = number
26
- export type Buffer = ArrayBuffer | HostBuffer | Uint8Array | Uint8ClampedArray | Int8Array | SharedArrayBuffer | DataView
27
26
  }
@@ -18,8 +18,6 @@
18
18
  *
19
19
  */
20
20
  declare module "embedded:io/audio/in" {
21
- import { Buffer } from "embedded:io/_common";
22
-
23
21
  type AudioType = "LPCM";
24
22
 
25
23
  interface AudioInOptions {
@@ -36,7 +34,7 @@ declare module "embedded:io/audio/in" {
36
34
  onReadable?: (this: AudioIn, byteLength: number, sampleCount?: number) => void;
37
35
  });
38
36
  read(byteLength?: number): ArrayBuffer
39
- read(buffer: Buffer): number
37
+ read(buffer: ByteBuffer): number
40
38
  start(): void;
41
39
  stop(options?: { flush?: boolean }): void
42
40
  close(): void;
@@ -18,8 +18,6 @@
18
18
  *
19
19
  */
20
20
  declare module "embedded:io/audio/out" {
21
- import { Buffer } from "embedded:io/_common";
22
-
23
21
  type AudioType = "LPCM";
24
22
 
25
23
  interface AudioOutOptions {
@@ -35,7 +33,7 @@ declare module "embedded:io/audio/out" {
35
33
  constructor(options?: AudioOutOptions & {
36
34
  onWritable?: (this: AudioOut, byteLength: number, sampleCount?: number) => void;
37
35
  });
38
- write(buffer: Buffer): void;
36
+ write(buffer: ByteBuffer): void;
39
37
  start(): void;
40
38
  stop(options?: { flush?: boolean }): void;
41
39
 
@@ -0,0 +1,14 @@
1
+ declare module "embedded:io/bluetoothle/_common" {
2
+ export interface GATTSecurityOptions {
3
+ bond?: boolean,
4
+ authenticate?: boolean,
5
+ ioCapabilities?: "none" | "display" | "numbers" | "display+numbers" | "display+confirm",
6
+ immediate?: boolean
7
+ }
8
+ export interface GATTSecurityState {
9
+ encrypted: boolean,
10
+ authenticated: boolean,
11
+ bonded: boolean,
12
+ keySize: number
13
+ }
14
+ }