@moddable/typings 9.5.0 → 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 -9
- 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 +5 -5
- 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/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 +21 -7
- 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 +27 -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 +47 -28
- 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 +52 -5
- package/data/location/nmea.d.ts +0 -103
- package/data/location/ubx.d.ts +0 -78
- package/display.d.ts +0 -68
- package/embedded/sensor/Barometer-Humidity-Temperature/BME280.d.ts +0 -102
- package/embedded/sensor/Location/GPS.d.ts +0 -96
- package/embedded/sensor/Location/IP.d.ts +0 -67
- package/pebble/device.d.ts +0 -51
package/embedded_io/serial.d.ts
CHANGED
|
@@ -19,44 +19,61 @@
|
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
21
|
declare module "embedded:io/serial" {
|
|
22
|
-
import { PinSpecifier, PortSpecifier } from "embedded:io/_common";
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
|
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?:
|
|
53
|
-
requestToSend?:
|
|
64
|
+
dataTerminalReady?: boolean;
|
|
65
|
+
requestToSend?: boolean;
|
|
54
66
|
break?: boolean;
|
|
55
67
|
}): void
|
|
56
|
-
get format():
|
|
57
|
-
set format(value:
|
|
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
|
-
|
|
76
|
+
const Serial: SerialConstructor;
|
|
60
77
|
|
|
61
78
|
export default Serial;
|
|
62
79
|
}
|
|
@@ -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?:
|
|
46
|
+
format?: F
|
|
32
47
|
target?: any
|
|
33
|
-
onReadable?: (this:
|
|
34
|
-
onWritable?: (this:
|
|
35
|
-
onError?: (this:
|
|
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
|
-
|
|
43
|
-
|
|
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
|
-
|
|
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():
|
|
50
|
-
set format(value:
|
|
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
|
-
|
|
53
|
-
export default
|
|
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
|
|
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
|
|
30
|
-
onWritable?: (this: TCP
|
|
31
|
-
onError?: (this: TCP) => void;
|
|
32
|
-
format?:
|
|
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
|
-
|
|
37
|
-
|
|
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
|
|
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():
|
|
46
|
-
set format(value:
|
|
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
|
-
|
|
62
|
+
const TCP: TCPConstructor;
|
|
49
63
|
export default TCP;
|
|
50
64
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2022-
|
|
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
|
-
|
|
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
|
-
|
|
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():
|
|
36
|
-
|
|
37
|
-
|
|
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
|
}
|
package/embedded_io/spi.d.ts
CHANGED
|
@@ -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
|
-
|
|
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:
|
|
26
|
-
onError:
|
|
32
|
+
onResolved?: (this: Resolver, host: string, address: string) => void
|
|
33
|
+
onError?: (this: Resolver, host: string) => void
|
|
27
34
|
}
|
|
28
35
|
|
|
29
|
-
class Resolver {
|
|
30
|
-
|
|
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
|
|
35
|
+
socket: ClientSocket
|
|
24
36
|
port?: number
|
|
25
37
|
host: string
|
|
26
|
-
dns
|
|
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,17 +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):
|
|
56
|
+
read(buffer: ByteBuffer): number | undefined;
|
|
44
57
|
write(): number;
|
|
45
58
|
write(value: ByteBuffer|undefined): number;
|
|
46
59
|
}
|
|
47
60
|
|
|
48
|
-
class HTTPClient {
|
|
61
|
+
class HTTPClient implements Disposable {
|
|
62
|
+
target?: any
|
|
49
63
|
constructor(options: ClientOptions)
|
|
50
64
|
request(options: RequestOptions): HTTPRequest
|
|
51
65
|
close(): void
|
|
66
|
+
[Symbol.dispose](): void
|
|
52
67
|
}
|
|
53
|
-
interface HTTPClient extends Disposable {}
|
|
54
68
|
export default HTTPClient;
|
|
55
69
|
|
|
56
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
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
// a WebDAV (RFC 4918) server over a directory. It composes with other routes: onRoute returns handlers for
|
|
22
|
+
// requests under prefix, and undefined for the rest
|
|
23
|
+
declare module "embedded:network/http/server/route/webdav" {
|
|
24
|
+
import type { HTTPConnectionHandlers, HTTPRequest } from "embedded:network/http/server";
|
|
25
|
+
import type { Directory } from "embedded:storage/files";
|
|
26
|
+
|
|
27
|
+
export interface WebDAVOptions {
|
|
28
|
+
directory: Directory; // the directory to serve
|
|
29
|
+
prefix?: string; // request path under which the directory is served, such as "/dav"; defaults to ""
|
|
30
|
+
log?: boolean; // trace requests; defaults to false
|
|
31
|
+
appleDouble?: boolean; // accept macOS "._" metadata files; defaults to true
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
class WebDAV {
|
|
35
|
+
constructor(options: WebDAVOptions);
|
|
36
|
+
onRoute(request: HTTPRequest): HTTPConnectionHandlers | undefined;
|
|
37
|
+
readonly directory: Directory;
|
|
38
|
+
readonly prefix: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export default WebDAV;
|
|
42
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
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 complete a WebSocket handshake. Spread them into a route; in its onDone, detach the socket and
|
|
22
|
+
// attach a WebSocket to it. To choose a subprotocol, set the connection's protocol before the response is sent
|
|
23
|
+
declare module "embedded:network/http/server/route/ws/handshake" {
|
|
24
|
+
import type { HTTPConnectionHandlers } from "embedded:network/http/server";
|
|
25
|
+
|
|
26
|
+
const route: HTTPConnectionHandlers;
|
|
27
|
+
export default route;
|
|
28
|
+
}
|