@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.
Files changed (160) hide show
  1. package/DS18X20.d.ts +40 -0
  2. package/{embedded_io/system.d.ts → ResourceIterator.d.ts} +4 -15
  3. package/ble/bleclient.d.ts +1 -0
  4. package/ble/bleserver.d.ts +1 -0
  5. package/ble/btutils.d.ts +3 -0
  6. package/ble/connection.d.ts +1 -0
  7. package/ble/gap.d.ts +2 -0
  8. package/ble/gatt.d.ts +4 -0
  9. package/ble/hidclient.d.ts +5 -0
  10. package/ble/sm.d.ts +3 -0
  11. package/captiveportal.d.ts +71 -0
  12. package/commodetto/Poco.d.ts +10 -2
  13. package/commodetto/ReadGIF.d.ts +1 -1
  14. package/commodetto/outline.d.ts +4 -1
  15. package/commodetto/parseRLE.d.ts +1 -1
  16. package/commodetto/readJPEG.d.ts +1 -1
  17. package/config/analog.d.ts +31 -0
  18. package/config/digital.d.ts +32 -0
  19. package/config/dns.d.ts +33 -0
  20. package/config/dnssd.d.ts +31 -0
  21. package/config/files.d.ts +27 -0
  22. package/config/flash.d.ts +27 -0
  23. package/config/httpclient.d.ts +34 -0
  24. package/config/httpsclient.d.ts +34 -0
  25. package/config/httpserver.d.ts +33 -0
  26. package/config/i2c.d.ts +33 -0
  27. package/config/mqtt.d.ts +27 -0
  28. package/config/mqttclient.d.ts +31 -0
  29. package/config/mqttsclient.d.ts +32 -0
  30. package/config/ntp.d.ts +34 -0
  31. package/config/pulsecount.d.ts +30 -0
  32. package/config/pwm.d.ts +30 -0
  33. package/config/serial.d.ts +31 -0
  34. package/config/socket.d.ts +34 -0
  35. package/config/spi.d.ts +31 -0
  36. package/config/storage.d.ts +27 -0
  37. package/config/system.d.ts +27 -0
  38. package/config/tls.d.ts +30 -0
  39. package/config/update.d.ts +27 -0
  40. package/config/wsclient.d.ts +31 -0
  41. package/config/wssclient.d.ts +32 -0
  42. package/crc.d.ts +1 -1
  43. package/dns/server.d.ts +1 -0
  44. package/embedded/RTC/zephyr-builtin.d.ts +48 -0
  45. package/embedded/RTC.d.ts +18 -7
  46. package/embedded/display.d.ts +8 -3
  47. package/embedded/storage/files.d.ts +10 -7
  48. package/embedded/storage/flash.d.ts +2 -2
  49. package/embedded/storage/key-value.d.ts +27 -6
  50. package/embedded/system.d.ts +49 -0
  51. package/embedded_io/_common.d.ts +42 -3
  52. package/embedded_io/analog.d.ts +7 -7
  53. package/embedded_io/audio/in.d.ts +3 -2
  54. package/embedded_io/audio/out.d.ts +12 -4
  55. package/embedded_io/ble/central.d.ts +5 -4
  56. package/embedded_io/ble/peripheral.d.ts +6 -5
  57. package/embedded_io/crypt/digest.d.ts +2 -2
  58. package/embedded_io/digital.d.ts +4 -3
  59. package/embedded_io/digitalbank.d.ts +9 -5
  60. package/embedded_io/i2c.d.ts +9 -6
  61. package/embedded_io/image/in/camera.d.ts +82 -0
  62. package/embedded_io/pulsecount.d.ts +7 -5
  63. package/embedded_io/pwm.d.ts +11 -5
  64. package/embedded_io/serial.d.ts +33 -16
  65. package/embedded_io/smbus.d.ts +1 -1
  66. package/embedded_io/socket/listener.d.ts +3 -2
  67. package/embedded_io/socket/tcp/tls.d.ts +41 -12
  68. package/embedded_io/socket/tcp.d.ts +26 -12
  69. package/embedded_io/socket/udp.d.ts +17 -12
  70. package/embedded_io/spi.d.ts +8 -6
  71. package/embedded_network/dns/resolver/udp.d.ts +13 -6
  72. package/embedded_network/dns/server/udp.d.ts +39 -0
  73. package/embedded_network/dnssd.d.ts +9 -7
  74. package/embedded_network/http/client.d.ts +23 -8
  75. package/embedded_network/http/server/route/serversentevents.d.ts +48 -0
  76. package/embedded_network/http/server/route/static.d.ts +41 -0
  77. package/embedded_network/http/server/route/webdav.d.ts +42 -0
  78. package/embedded_network/http/server/route/ws/handshake.d.ts +28 -0
  79. package/embedded_network/http/server.d.ts +28 -6
  80. package/embedded_network/interface/ethernet.d.ts +3 -3
  81. package/embedded_network/interface/wifi/accesspoint.d.ts +2 -2
  82. package/embedded_network/interface/wifi.d.ts +21 -12
  83. package/embedded_network/mdns.d.ts +2 -2
  84. package/embedded_network/mqtt/client.d.ts +55 -16
  85. package/embedded_network/ntp/client.d.ts +16 -8
  86. package/embedded_network/websocket/client.d.ts +49 -29
  87. package/embedded_provider/builtin.d.ts +40 -34
  88. package/file.d.ts +4 -0
  89. package/flash.d.ts +1 -0
  90. package/global.d.ts +0 -3
  91. package/host/default.d.ts +31 -0
  92. package/host/esp32/moddable_six.d.ts +50 -0
  93. package/host/esp32/moddable_two.d.ts +55 -0
  94. package/host/generic.d.ts +47 -0
  95. package/host/index.d.ts +24 -0
  96. package/host/lin.d.ts +30 -0
  97. package/host/mac.d.ts +30 -0
  98. package/host/pebble.d.ts +70 -0
  99. package/host/win.d.ts +30 -0
  100. package/http.d.ts +2 -0
  101. package/mcpack.d.ts +20 -0
  102. package/mdns.d.ts +1 -0
  103. package/modules.d.ts +1 -1
  104. package/mqtt/js.d.ts +22 -4
  105. package/neopixel.d.ts +2 -2
  106. package/onewire.d.ts +31 -0
  107. package/package.json +14 -4
  108. package/pebble/accelerometer.d.ts +5 -5
  109. package/pebble/battery.d.ts +3 -3
  110. package/pebble/button.d.ts +2 -2
  111. package/pebble/compass.d.ts +3 -3
  112. package/pebble/dictation.d.ts +2 -2
  113. package/pebble/global.d.ts +37 -3
  114. package/pebble/health.d.ts +2 -2
  115. package/pebble/location.d.ts +2 -2
  116. package/pebble/message.d.ts +5 -5
  117. package/pebble/piu.d.ts +2 -57
  118. package/pebble/poco.d.ts +2 -2
  119. package/pebble/texture.d.ts +33 -0
  120. package/pebble/touch.d.ts +47 -0
  121. package/ping.d.ts +1 -0
  122. package/pins/analog.d.ts +1 -0
  123. package/pins/audioin.d.ts +1 -0
  124. package/pins/digital.d.ts +1 -0
  125. package/pins/i2c.d.ts +1 -0
  126. package/pins/pwm.d.ts +1 -0
  127. package/pins/rmt.d.ts +1 -0
  128. package/pins/servo.d.ts +1 -0
  129. package/pins/smbus.d.ts +1 -0
  130. package/piu/MC-types.d.ts +231 -97
  131. package/piu/MC.d.ts +2 -1
  132. package/piu/QRCode.d.ts +5 -0
  133. package/piu/RoundRect.d.ts +53 -0
  134. package/piu/SVGImage.d.ts +62 -0
  135. package/piu/Timeline.d.ts +17 -21
  136. package/pococolorcell.d.ts +25 -0
  137. package/pocoqrcode.d.ts +25 -0
  138. package/pocostatic.d.ts +25 -0
  139. package/preference.d.ts +1 -0
  140. package/securesocket.d.ts +1 -0
  141. package/sntp.d.ts +1 -0
  142. package/socket.d.ts +6 -0
  143. package/ssl/session.d.ts +60 -0
  144. package/time.d.ts +1 -1
  145. package/tsconfig.es2024.json +0 -1
  146. package/tsconfig.es2025.json +1 -1
  147. package/web/bluetooth.d.ts +112 -0
  148. package/web/decompressionstream.d.ts +1 -1
  149. package/web/eventsource.d.ts +12 -7
  150. package/web/fetch-streams.d.ts +57 -0
  151. package/web/fetch.d.ts +1 -1
  152. package/web/serial.d.ts +58 -0
  153. package/web/websocket.d.ts +18 -13
  154. package/web/webstorage.d.ts +3 -0
  155. package/web/worker.d.ts +2 -0
  156. package/websocket.d.ts +2 -0
  157. package/wifi.d.ts +1 -0
  158. package/xs.d.ts +54 -6
  159. package/display.d.ts +0 -68
  160. package/pebble/device.d.ts +0 -51
@@ -20,21 +20,27 @@
20
20
 
21
21
 
22
22
  declare module "embedded:io/pwm" {
23
- import { PinSpecifier } from "embedded:io/_common";
24
- class PWM {
25
- constructor(options: {
23
+ import { PinSpecifier, PortSpecifier, IOOptions } from "embedded:io/_common";
24
+ class PWM implements Disposable {
25
+ target?: any;
26
+ constructor(options: IOOptions<"PWM", {
26
27
  pin: PinSpecifier;
28
+ port?: PortSpecifier; // Moddable SDK extension
29
+ } | {
30
+ from: PWM; // Moddable SDK extension: take over the pin of an open instance, which is closed
31
+ }, {
27
32
  hz?: number;
33
+ resolution?: number; // Moddable SDK extension
28
34
  format?: "number";
29
35
  target?: any;
30
- });
36
+ }>);
31
37
  readonly resolution: number;
32
38
  readonly hz: number;
33
39
  write(value: number): void;
34
40
  close(): void;
35
41
  get format(): "number"
36
42
  set format(value: "number")
43
+ [Symbol.dispose](): void;
37
44
  }
38
- interface PWM extends Disposable {}
39
45
  export default PWM;
40
46
  }
@@ -19,44 +19,61 @@
19
19
  */
20
20
 
21
21
  declare module "embedded:io/serial" {
22
- import { PinSpecifier, PortSpecifier } from "embedded:io/_common";
23
- class Serial {
24
- constructor(options: ({
22
+ import { PinSpecifier, PortSpecifier, IOOptions } from "embedded:io/_common";
23
+ export type Format = "number" | "buffer";
24
+
25
+ export type Options<F extends Format = Format> = IOOptions<"Serial", ({
25
26
  receive: PinSpecifier;
26
27
  transmit?: PinSpecifier;
27
28
  } | {
28
- recevice?: PinSpecifier;
29
+ receive?: PinSpecifier;
29
30
  transmit: PinSpecifier;
30
31
  }) & {
31
- baud: number;
32
- flowControl?: "hardware" | "none";
33
32
  dataTerminalReady?: PinSpecifier;
34
33
  requestToSend?: PinSpecifier;
35
34
  clearToSend?: PinSpecifier;
36
35
  dataSetReady?: PinSpecifier;
37
36
  port: PortSpecifier;
38
- onReadable?: (this: Serial, bytes: number) => void;
39
- onWritable?: (this: Serial, bytes: number) => void;
40
- format?: "number" | "buffer";
37
+ }, {
38
+ baud: number;
39
+ flowControl?: "hardware" | "none";
40
+ onReadable?: (this: Serial<F>, bytes: number) => void;
41
+ onWritable?: (this: Serial<F>, bytes: number) => void;
42
+ format?: F;
41
43
  target?: any;
42
- });
44
+ }>;
45
+
46
+ /*
47
+ F is the format named in the options when the serial port is created. Naming it there
48
+ (format: "buffer") fixes the type read() with no argument returns:
49
+ a byte for "number", an ArrayBuffer for "buffer".
50
+ When the options name no format, read() is typed as returning either, because the
51
+ format can be changed later through the format property.
52
+ */
53
+ interface Serial<F extends Format = Format> extends Disposable {
54
+ target?: any;
43
55
  readonly resolution: number;
44
56
  close(): void;
45
- read(): number | ArrayBuffer | undefined;
57
+ read(): (F extends "number" ? number : ArrayBuffer) | undefined;
46
58
  read(byteLength: number): ArrayBuffer | undefined;
47
59
  read(buffer: ByteBuffer): number | undefined;
48
60
  write(value: number | ByteBuffer): void;
49
61
  flush(): void;
50
62
  flush(input: number, output: number): void;
51
63
  set(options: {
52
- dataTerminalReady?: PinSpecifier;
53
- requestToSend?: PinSpecifier;
64
+ dataTerminalReady?: boolean;
65
+ requestToSend?: boolean;
54
66
  break?: boolean;
55
67
  }): void
56
- get format(): "number" | "buffer"
57
- set format(value: "number" | "buffer")
68
+ get format(): F
69
+ set format(value: Format)
70
+ [Symbol.dispose](): void;
71
+ }
72
+ interface SerialConstructor {
73
+ new <F extends Format = Format>(options: Options<F>): Serial<F>;
74
+ readonly prototype: Serial;
58
75
  }
59
- interface Serial extends Disposable {}
76
+ const Serial: SerialConstructor;
60
77
 
61
78
  export default Serial;
62
79
  }
@@ -22,7 +22,7 @@ declare module "embedded:io/smbus" {
22
22
  import I2C from "embedded:io/i2c"
23
23
 
24
24
  class SMBus extends I2C {
25
- constructor(options: ConstructorParameters<typeof I2C> & {
25
+ constructor(options: ConstructorParameters<typeof I2C>[0] & {
26
26
  stop?: boolean;
27
27
  });
28
28
  readUint8(register: number): number;
@@ -20,7 +20,8 @@
20
20
 
21
21
  declare module "embedded:io/socket/listener" {
22
22
  import TCP from "embedded:io/socket/tcp"
23
- class Listener {
23
+ class Listener implements Disposable {
24
+ target?: any;
24
25
  constructor(options: {
25
26
  port?: number;
26
27
  address?: string;
@@ -33,7 +34,7 @@ declare module "embedded:io/socket/listener" {
33
34
  get format(): "socket/tcp"
34
35
  set format(value: "socket/tcp")
35
36
  readonly port: number;
37
+ [Symbol.dispose](): void;
36
38
  }
37
- interface Listener extends Disposable {}
38
39
  export default Listener;
39
40
  }
@@ -22,33 +22,62 @@ declare module "embedded:io/socket/tcp/tls" {
22
22
  verify?: boolean
23
23
  }
24
24
 
25
+ export type Format = "number" | "buffer"
26
+
27
+ /*
28
+ The socket property of a network client provider, and of the options of a network client.
29
+ The client creates its socket with io, passing the other properties as options.
30
+ For a secure connection io is TLS, tls has the TLS options (the client supplies host),
31
+ and TCP is the socket TLS runs over.
32
+ */
33
+ export type ClientSocket = {
34
+ io: typeof TCP | typeof TLS
35
+ tls?: Partial<TLSOptions>
36
+ TCP?: { io: typeof TCP, [option: string]: unknown }
37
+ [option: string]: unknown
38
+ }
39
+
25
40
  /** Extends the TCP socket's options object. Listed explicitly so the callbacks
26
41
  can be typed with `this` as the TLS socket rather than the TCP socket. */
27
- export type Options = {
42
+ export type Options<F extends Format = Format> = {
28
43
  address: string
29
44
  port: number
30
45
  noDelay?: boolean
31
- format?: "number" | "buffer"
46
+ format?: F
32
47
  target?: any
33
- onReadable?: (this: TLSSocket, bytes: number) => void
34
- onWritable?: (this: TLSSocket, bytes: number) => void
35
- onError?: (this: TLSSocket) => void
48
+ onReadable?: (this: TLS<F>, bytes: number) => void
49
+ onWritable?: (this: TLS<F>, bytes: number) => void
50
+ onError?: (this: TLS<F>) => void
36
51
 
37
52
  tls: TLSOptions
38
53
  /** The TCP socket this TLS socket runs over. A Moddable SDK extension. */
39
54
  TCP: { io: new (options: TCPOptions) => TCP } & Partial<TCPOptions>
40
55
  }
41
56
 
42
- class TLSSocket {
43
- constructor(options: Options)
57
+ /*
58
+ F is the format named in the options when the socket is created. Naming it there
59
+ (format: "buffer") fixes the type read() with no argument returns:
60
+ a byte for "number", an ArrayBuffer for "buffer".
61
+ When the options name no format, read() is typed as returning either, because the
62
+ format can be changed later through the format property.
63
+ */
64
+ interface TLS<F extends Format = Format> extends Disposable {
65
+ target?: any
44
66
  close(): void
45
- read(): number | ArrayBuffer
67
+ readonly remoteAddress: string | undefined
68
+ readonly remotePort: number | undefined
69
+ read(): F extends "number" ? number : ArrayBuffer
46
70
  read(byteLength: number): ArrayBuffer
47
71
  read(buffer: ByteBuffer): number
48
72
  write(buffer: ByteBuffer, options?: { more?: boolean, byteLength?: number }): number
49
- get format(): "number" | "buffer"
50
- set format(value: "number" | "buffer")
73
+ get format(): F
74
+ set format(value: Format)
75
+ [Symbol.dispose](): void
76
+ }
77
+ interface TLSConstructor {
78
+ new <F extends Format = Format>(options: Options<F>): TLS<F>
79
+ readonly prototype: TLS
51
80
  }
52
- interface TLSSocket extends Disposable {}
53
- export default TLSSocket;
81
+ const TLS: TLSConstructor
82
+ export default TLS;
54
83
  }
@@ -19,32 +19,46 @@
19
19
  */
20
20
 
21
21
  declare module "embedded:io/socket/tcp" {
22
- export type Options = (({
22
+ export type Format = "number" | "buffer";
23
+
24
+ export type Options<F extends Format = Format> = (({
23
25
  address: string;
24
26
  port: number;
25
27
  }) | {
26
28
  from: TCP;
27
29
  }) & {
28
30
  noDelay?: boolean;
29
- onReadable?: (this: TCP, bytes: number) => void;
30
- onWritable?: (this: TCP, bytes: number) => void;
31
- onError?: (this: TCP) => void;
32
- format?: "number" | "buffer";
31
+ onReadable?: (this: TCP<F>, bytes: number) => void;
32
+ onWritable?: (this: TCP<F>, bytes: number) => void;
33
+ onError?: (this: TCP<F>) => void;
34
+ format?: F;
33
35
  target?: any;
34
36
  };
35
-
36
- class TCP {
37
- constructor(options: Options)
37
+
38
+ /*
39
+ F is the format named in the options when the socket is created. Naming it there
40
+ (format: "buffer") fixes the type read() with no argument returns:
41
+ a byte for "number", an ArrayBuffer for "buffer".
42
+ When the options name no format, read() is typed as returning either, because the
43
+ format can be changed later through the format property.
44
+ */
45
+ interface TCP<F extends Format = Format> extends Disposable {
46
+ target?: any;
38
47
  readonly remoteAddress: string | undefined;
39
48
  readonly remotePort: number | undefined;
40
- read(): number | ArrayBuffer;
49
+ read(): F extends "number" ? number : ArrayBuffer;
41
50
  read(byteLength: number): ArrayBuffer;
42
51
  read(buffer: ByteBuffer): number;
43
52
  write(value: number | ByteBuffer): number;
44
53
  close(): void;
45
- get format(): "number" | "buffer"
46
- set format(value: "number" | "buffer")
54
+ get format(): F
55
+ set format(value: Format)
56
+ [Symbol.dispose](): void;
57
+ }
58
+ interface TCPConstructor {
59
+ new <F extends Format = Format>(options: Options<F>): TCP<F>;
60
+ readonly prototype: TCP;
47
61
  }
48
- interface TCP extends Disposable {}
62
+ const TCP: TCPConstructor;
49
63
  export default TCP;
50
64
  }
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2022-2025 Shinya Ishikawa
2
+ * Copyright (c) 2022-2026 Shinya Ishikawa
3
3
  *
4
4
  * This file is part of the Moddable SDK Tools.
5
5
  *
@@ -19,28 +19,33 @@
19
19
  */
20
20
 
21
21
  declare module "embedded:io/socket/udp" {
22
- class UDP {
22
+ export interface UDPPacket extends ArrayBuffer {
23
+ address: string; // sender's IP address
24
+ port: number; // sender's port
25
+ }
26
+
27
+ class UDP implements Disposable {
28
+ target?: any;
23
29
  constructor(options: {
24
30
  port?: number;
25
31
  address?: string;
32
+ timeToLive?: number; // Moddable SDK extension
26
33
  onReadable?: (this: UDP, packets: number) => void;
27
- onError?: () => void;
34
+ onWritable?: (this: UDP, count: number) => void;
35
+ onError?: (this: UDP) => void;
28
36
  format?: "buffer";
29
37
  target?: any;
30
- } & ({} | {
31
- multicast: string;
32
- timeToLive: number;
33
- }))
38
+ });
34
39
  write(buffer: ByteBuffer, address: string, port: number): void;
35
- read(): ArrayBuffer & {
36
- address: string;
37
- port: number;
38
- };
40
+ read(): UDPPacket | undefined;
41
+ read(buffer: ByteBuffer): number;
42
+ add(multicastAddress: string): void;
43
+ remove(multicastAddress: string): void;
39
44
  close(): void;
40
45
  get format(): "buffer"
41
46
  set format(value: "buffer")
47
+ [Symbol.dispose](): void;
42
48
  }
43
- interface UDP extends Disposable {}
44
49
 
45
50
  export default UDP
46
51
  }
@@ -19,20 +19,22 @@
19
19
  */
20
20
 
21
21
  declare module "embedded:io/spi" {
22
- import { PinSpecifier, PortSpecifier } from "embedded:io/_common";
23
- class SPI {
24
- constructor(options: {
22
+ import { PinSpecifier, PortSpecifier, IOOptions } from "embedded:io/_common";
23
+ class SPI implements Disposable {
24
+ target?: any;
25
+ constructor(options: IOOptions<"SPI", {
25
26
  out?: PinSpecifier;
26
27
  in?: PinSpecifier;
27
28
  clock: PinSpecifier;
28
29
  select?: PinSpecifier;
30
+ port?: PortSpecifier;
31
+ }, {
29
32
  active?: 1 | 0;
30
33
  hz: number;
31
34
  mode?: number;
32
- port?: PortSpecifier;
33
35
  format?: "buffer";
34
36
  target?: any;
35
- })
37
+ }>)
36
38
  read(byteLength: number): ArrayBuffer;
37
39
  read(buffer: ByteBuffer): void;
38
40
  write(buffer: ByteBuffer): void;
@@ -41,7 +43,7 @@ declare module "embedded:io/spi" {
41
43
  close(): void;
42
44
  get format(): "buffer";
43
45
  set format(value: "buffer");
46
+ [Symbol.dispose](): void;
44
47
  }
45
- interface SPI extends Disposable {}
46
48
  export default SPI;
47
49
  }
@@ -19,20 +19,27 @@
19
19
  */
20
20
 
21
21
  declare module "embedded:network/dns/resolver/udp" {
22
+ import type UDP from "embedded:io/socket/udp";
23
+
24
+ export interface DNSResolverProvider {
25
+ io: typeof Resolver
26
+ servers: string[]
27
+ socket: { io: typeof UDP, [option: string]: unknown }
28
+ }
22
29
 
23
30
  interface Options {
24
31
  host: string
25
- onResolved: ((host:string, address:any) => null)
26
- onError: ((host:string) => null)
32
+ onResolved?: (this: Resolver, host: string, address: string) => void
33
+ onError?: (this: Resolver, host: string) => void
27
34
  }
28
35
 
29
- class Resolver {
30
- constructor(options: Record<string, any>)
36
+ class Resolver implements Disposable {
37
+ target?: any
38
+ constructor(options: Omit<DNSResolverProvider, "io"> & { target?: any })
31
39
  close(): void
32
40
  resolve(options: Options): void
33
-
41
+ [Symbol.dispose](): void
34
42
  }
35
- interface Resolver extends Disposable {}
36
43
 
37
44
  export default Resolver
38
45
  }
@@ -0,0 +1,39 @@
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:network/dns/server/udp" {
22
+ import type UDP from "embedded:io/socket/udp";
23
+
24
+ export interface Options {
25
+ socket: { io: typeof UDP };
26
+ // returns the address for the name, or a falsy value when the name is not served
27
+ onResolve: (name: string) => string | undefined | null | false;
28
+ ttl?: number; // seconds, defaults to 60
29
+ port?: number; // defaults to 53
30
+ }
31
+
32
+ class Server implements Disposable {
33
+ constructor(options: Options);
34
+ close(): void;
35
+ [Symbol.dispose](): void;
36
+ }
37
+
38
+ export default Server;
39
+ }
@@ -30,12 +30,13 @@ declare module "embedded:network/dnssd" {
30
30
 
31
31
  export interface DNSSDOptions {
32
32
  socket: DNSSDSocketOptions;
33
+ target?: any;
33
34
  }
34
35
 
35
36
  export interface ClaimOptions {
36
37
  host: string;
37
- onReady?(): void;
38
- onError?(): void;
38
+ onReady?(this: ClaimHandle): void;
39
+ onError?(this: ClaimHandle): void;
39
40
  }
40
41
 
41
42
  export interface ClaimHandle extends Disposable {
@@ -52,9 +53,9 @@ declare module "embedded:network/dnssd" {
52
53
 
53
54
  export interface DiscoverOptions {
54
55
  serviceType: string;
55
- onFound?(service: ServiceObject): void;
56
- onUpdate?(service: ServiceObject): void;
57
- onLost?(service: ServiceObject): void;
56
+ onFound?(this: DiscoverHandle, service: ServiceObject): void;
57
+ onUpdate?(this: DiscoverHandle, service: ServiceObject): void;
58
+ onLost?(this: DiscoverHandle, service: ServiceObject): void;
58
59
  }
59
60
 
60
61
  export interface DiscoverHandle extends Disposable {
@@ -74,13 +75,14 @@ declare module "embedded:network/dnssd" {
74
75
  updateTXT(txt: Map<string, string | ByteBuffer>): void;
75
76
  }
76
77
 
77
- class DNSSD {
78
+ class DNSSD implements Disposable {
79
+ target?: any;
78
80
  constructor(options: DNSSDOptions);
79
81
  close(): void;
80
82
  claim(options: ClaimOptions): ClaimHandle;
81
83
  discover(options: DiscoverOptions): DiscoverHandle;
82
84
  advertise(options: AdvertiseOptions): AdvertiseHandle;
85
+ [Symbol.dispose](): void;
83
86
  }
84
- interface DNSSD extends Disposable {}
85
87
  export default DNSSD;
86
88
  }
@@ -19,18 +19,31 @@
19
19
  */
20
20
 
21
21
  declare module "embedded:network/http/client" {
22
+ import type TCP from "embedded:io/socket/tcp";
23
+ import type TLS from "embedded:io/socket/tcp/tls";
24
+ import type { ClientSocket } from "embedded:io/socket/tcp/tls";
25
+ import type { DNSResolverProvider } from "embedded:network/dns/resolver/udp";
26
+
27
+ export interface HTTPClientProvider {
28
+ io: typeof HTTPClient
29
+ dns: DNSResolverProvider
30
+ socket: ClientSocket
31
+ port?: number
32
+ }
33
+
22
34
  export interface ClientOptions {
23
- socket?: any
35
+ socket: ClientSocket
24
36
  port?: number
25
37
  host: string
26
- dns?: any
27
- onError?: (err:any)=>void
38
+ dns: DNSResolverProvider
39
+ onError?: (this: HTTPClient, err:any)=>void
40
+ target?: any
28
41
  }
29
42
 
30
43
  export interface RequestOptions {
31
44
  method?: string
32
45
  path?: string
33
- headers?: Map<string, string|string[]>
46
+ headers?: Map<string, string | string[] | number>
34
47
  headersMask?: Array<string>
35
48
  onHeaders?: (this: HTTPRequest, status:number, headers: Map<string, string>, statusText: string) => void
36
49
  onReadable?: (this: HTTPRequest, count: number) => void
@@ -40,16 +53,18 @@ declare module "embedded:network/http/client" {
40
53
 
41
54
  export interface HTTPRequest {
42
55
  read(byteLength?: number): ArrayBuffer|undefined;
43
- read(buffer: ByteBuffer): void;
44
- write(value: ByteBuffer|undefined): void;
56
+ read(buffer: ByteBuffer): number | undefined;
57
+ write(): number;
58
+ write(value: ByteBuffer|undefined): number;
45
59
  }
46
60
 
47
- class HTTPClient {
61
+ class HTTPClient implements Disposable {
62
+ target?: any
48
63
  constructor(options: ClientOptions)
49
64
  request(options: RequestOptions): HTTPRequest
50
65
  close(): void
66
+ [Symbol.dispose](): void
51
67
  }
52
- interface HTTPClient extends Disposable {}
53
68
  export default HTTPClient;
54
69
 
55
70
  }
@@ -0,0 +1,48 @@
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
+ // handlers that accept a Server-Sent Events request. Spread them into a route and add onConnection, which
22
+ // is called once the event stream is open, with a connection whose write sends an event
23
+ declare module "embedded:network/http/server/route/serversentevents" {
24
+ import type { HTTPConnection, HTTPConnectionHandlers } from "embedded:network/http/server";
25
+
26
+ export interface ServerSentEvent {
27
+ data?: string;
28
+ event?: string;
29
+ id?: string;
30
+ }
31
+
32
+ export interface ServerSentEventsConnection extends Omit<HTTPConnection, "write"> {
33
+ write(event?: ServerSentEvent): void; // no event sends a keep-alive comment
34
+ }
35
+
36
+ export interface ServerSentEventsRoute extends HTTPConnectionHandlers {
37
+ onConnection?(this: ServerSentEventsConnection): void;
38
+ }
39
+
40
+ const route: HTTPConnectionHandlers;
41
+ export default route;
42
+ }
43
+
44
+ declare module "embedded:network/http/server" {
45
+ interface HTTPRouteTypes {
46
+ serversentevents: import("embedded:network/http/server/route/serversentevents").ServerSentEventsRoute;
47
+ }
48
+ }
@@ -0,0 +1,41 @@
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
+ // handlers that respond with fixed content. Spread them into a route and add the content:
22
+ // { ...StaticRoute, data: "<html>…</html>", contentType: "text/html" }
23
+ declare module "embedded:network/http/server/route/static" {
24
+ import type { HTTPConnectionHandlers } from "embedded:network/http/server";
25
+
26
+ export interface StaticRoute extends HTTPConnectionHandlers {
27
+ data: ByteBuffer | string; // a string is sent with chunked transfer encoding
28
+ contentType?: string; // defaults to "text/html"
29
+ headers?: Map<string, string | number>;
30
+ status?: number;
31
+ }
32
+
33
+ const route: HTTPConnectionHandlers;
34
+ export default route;
35
+ }
36
+
37
+ declare module "embedded:network/http/server" {
38
+ interface HTTPRouteTypes {
39
+ static: import("embedded:network/http/server/route/static").StaticRoute;
40
+ }
41
+ }