Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions examples/manifest_typings.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,18 @@
"embedded:io/socket/*": [
"$(TYPINGS)/embedded_io/socket/*"
],
"embedded:io/socket/tcp/*": [
"$(TYPINGS)/embedded_io/socket/tcp/*"
],
"embedded:network/http/*": [
"$(TYPINGS)/embedded_network/http/*"
],
"embedded:network/http/server/route/*": [
"$(TYPINGS)/embedded_network/http/server/route/*"
],
"embedded:network/http/server/route/ws/*": [
"$(TYPINGS)/embedded_network/http/server/route/ws/*"
],
"embedded:network/mqtt/*": [
"$(TYPINGS)/embedded_network/mqtt/*"
],
Expand Down
5 changes: 2 additions & 3 deletions typings/embedded_network/dns/resolver/udp.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,14 @@ declare module "embedded:network/dns/resolver/udp" {

interface Options {
host: string
onResolved: ((host:string, address:any) => null)
onError: ((host:string) => null)
onResolved: ((host: string, address: any) => void)
onError: ((host: string) => void)
}

class Resolver {
constructor(options: Record<string, any>)
close(): void
resolve(options: Options): void

}
interface Resolver extends Disposable {}

Expand Down
9 changes: 6 additions & 3 deletions typings/embedded_network/http/server.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ declare module "embedded:network/http/server" {
onResponse?(this: HTTPConnection, response: HTTPResponse): void;
onWritable?(this: HTTPConnection, count: number): void;
onDone?(this: HTTPConnection): void;
onError?(this: HTTPConnection): void;
onError?(this: HTTPConnection, error: string): void;
}

export interface HTTPConnection extends Disposable {
Expand All @@ -52,12 +52,15 @@ declare module "embedded:network/http/server" {
write(bytes?: ByteBuffer): number;
route: HTTPConnectionHandlers;
format: "buffer";
protocol?: string;
}

export interface HTTPServerOptions {
io: typeof Listener;
socket: { io: typeof Listener } & Record<string, any>;
port?: number;
onConnect(this: HTTPServer, connection: HTTPConnection): void;
keepAlive?: number;
onConnect?(this: HTTPServer, connection: HTTPConnection): void;
onRoute?(this: HTTPServer, request: HTTPRequest): any;
}

class HTTPServer {
Expand Down
33 changes: 33 additions & 0 deletions typings/embedded_network/http/server/route/static.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright (c) 2026 Moddable Tech, Inc.
*
* This file is part of the Moddable SDK Tools.
*
* The Moddable SDK Tools is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Moddable SDK Tools is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the Moddable SDK Tools. If not, see <http://www.gnu.org/licenses/>.
*
*/

declare module "embedded:network/http/server/route/static" {
import type { HTTPConnectionHandlers } from "embedded:network/http/server";

export interface StaticRoute extends HTTPConnectionHandlers {
data: ByteBuffer | string;
contentType?: string;
headers?: Map<string, string | number>;
status?: number;
}

const route: StaticRoute;
export default route;
}
26 changes: 26 additions & 0 deletions typings/embedded_network/http/server/route/ws/handshake.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright (c) 2026 Moddable Tech, Inc.
*
* This file is part of the Moddable SDK Tools.
*
* The Moddable SDK Tools is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Moddable SDK Tools is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the Moddable SDK Tools. If not, see <http://www.gnu.org/licenses/>.
*
*/

declare module "embedded:network/http/server/route/ws/handshake" {
import type { HTTPConnectionHandlers } from "embedded:network/http/server";

const route: HTTPConnectionHandlers;
export default route;
}
7 changes: 6 additions & 1 deletion typings/embedded_network/interface/wifi.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,20 @@ declare module "embedded:network/interface/wifi" {
channel: number;
RSSI: number;
BSSID?: string;
security: string;
}

export interface WiFiScanOptions {
onFound?: (result: WiFiScanResult) => void;
onFound: (result: WiFiScanResult) => void;
onComplete?: () => void;
channel?: number;
}

export interface WiFiConnectOptions {
SSID: string;
password?: string;
secure?: boolean;
channel?: number;
}

export interface WiFiStaticAddress {
Expand All @@ -70,7 +73,9 @@ declare module "embedded:network/interface/wifi" {
readonly address: string | undefined;
readonly MAC: string | undefined;
readonly SSID: string | undefined;
readonly BSSID: string | undefined;
readonly RSSI: number | undefined;
readonly channel: number | undefined;
}
interface WiFi extends Disposable {}

Expand Down
21 changes: 9 additions & 12 deletions typings/embedded_network/websocket/client.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,31 @@
*
*/

// websocketclient.d.ts
// websocket/client.d.ts

declare module "embedded:network/websocket/client" {
interface WebSocketClientOptions {
import type TCP from "embedded:io/socket/tcp";
import type TLSSocket from "embedded:io/socket/tcp/tls";

export interface WebSocketClientOptions {
onReadable?: (this: WebSocketClient, count: number, options: { more: boolean; binary: boolean }) => void;
onWritable?: (this: WebSocketClient, count: number) => void;
onControl?: (this: WebSocketClient, opcode: number, data: ArrayBuffer) => void;
onClose?: (this: WebSocketClient) => void;
onError?: (this: WebSocketClient) => void;
format?: "buffer" | "number";
target?: any;
attach?: {
constructor: new (options: any) => any;
};
attach?: TCP | TLSSocket;
host?: string;
path?: string;
port?: number;
protocol?: string;
headers?: Map<string, string>;
dns?: {
io: new (options: any) => any;
};
socket?: {
io: new (options: any) => any;
};
dns?: { io: new (options: any) => any } & Record<string, any>;
socket?: { io: new (options: any) => any } & Record<string, any>;
}

interface WebSocketWriteOptions {
export interface WebSocketWriteOptions {
opcode?: number;
binary?: boolean;
more?: boolean;
Expand Down
36 changes: 36 additions & 0 deletions typings/embedded_provider/builtin.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ declare module "embedded:provider/builtin" {
import SPI from "embedded:io/spi";
import Serial from "embedded:io/serial";
import type { PinSpecifier } from "embedded:io/_common";
import type Listener from "embedded:io/socket/listener";
import type UDP from "embedded:io/socket/udp";
import type Resolver from "embedded:network/dns/resolver/udp";
import type HTTPServer from "embedded:network/http/server";
import type NTP from "embedded:network/ntp/client";
import type WebSocketClient from "embedded:network/websocket/client";

const device: {
io: {
Digital: typeof Digital;
Expand All @@ -52,6 +59,35 @@ declare module "embedded:provider/builtin" {
SPI: { default: ConstructorParameters<typeof SPI>[0] };
Serial: { default: ConstructorParameters<typeof Serial>[0] };
pin: { [name: string]: PinSpecifier };
network: {
dns: {
resolver: Record<string, any>;
};
http: {
server: {
io: typeof HTTPServer;
socket: { io: typeof Listener } & Record<string, any>;
};
};
ntp: {
client: {
io: typeof NTP;
dns: { io: typeof Resolver } & Record<string, any>;
socket: { io: typeof UDP } & Record<string, any>;
servers: string[];
};
};
ws: {
io: typeof WebSocketClient;
dns: { io: new (options: any) => any } & Record<string, any>;
socket: { io: new (options: any) => any } & Record<string, any>;
};
wss: {
io: typeof WebSocketClient;
dns: { io: new (options: any) => any } & Record<string, any>;
socket: { io: new (options: any) => any } & Record<string, any>;
};
};
};
export default device;
}