@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
@@ -23,15 +23,15 @@ declare module "web/websocket" {
23
23
 
24
24
  interface WebSocketClientOptions {
25
25
  url: string;
26
- protocol?: string;
26
+ protocol?: string | string[];
27
27
  keepalive?: number;
28
- headers?: Headers | Record<string, string>;
28
+ headers?: Headers | Map<string, string>;
29
29
  ws?: any;
30
30
  wss?: any;
31
31
  }
32
32
 
33
33
  interface WebSocketAttachOptions {
34
- attach: any;
34
+ attach: import("embedded:io/socket/tcp").default;
35
35
  }
36
36
 
37
37
  interface WebSocketCloseEvent {
@@ -55,7 +55,7 @@ declare module "web/websocket" {
55
55
  type WebSocketEventListener = (event: any) => void;
56
56
 
57
57
  class WebSocket {
58
- constructor(url: string, protocol?: string);
58
+ constructor(url: string, protocols?: string | string[]);
59
59
  constructor(options: WebSocketClientOptions);
60
60
  constructor(options: WebSocketAttachOptions);
61
61
 
@@ -76,15 +76,15 @@ declare module "web/websocket" {
76
76
  readonly readyState: number;
77
77
  readonly url: string;
78
78
 
79
- onclose?(event: WebSocketCloseEvent): void;
80
- onerror?(event: WebSocketErrorEvent): void;
81
- onmessage?(event: WebSocketMessageEvent): void;
82
- onopen?(event: WebSocketEvent): void;
79
+ onclose: ((this: WebSocket, event: WebSocketCloseEvent) => void) | null;
80
+ onerror: ((this: WebSocket, event: WebSocketErrorEvent) => void) | null;
81
+ onmessage: ((this: WebSocket, event: WebSocketMessageEvent) => void) | null;
82
+ onopen: ((this: WebSocket, event: WebSocketEvent) => void) | null;
83
83
 
84
- addEventListener(event: "close", listener: (event: WebSocketCloseEvent) => void): void;
85
- addEventListener(event: "error", listener: (event: WebSocketErrorEvent) => void): void;
86
- addEventListener(event: "message", listener: (event: WebSocketMessageEvent) => void): void;
87
- addEventListener(event: "open", listener: (event: WebSocketEvent) => void): void;
84
+ addEventListener(event: "close", listener: (this: WebSocket, event: WebSocketCloseEvent) => void): void;
85
+ addEventListener(event: "error", listener: (this: WebSocket, event: WebSocketErrorEvent) => void): void;
86
+ addEventListener(event: "message", listener: (this: WebSocket, event: WebSocketMessageEvent) => void): void;
87
+ addEventListener(event: "open", listener: (this: WebSocket, event: WebSocketEvent) => void): void;
88
88
 
89
89
  removeEventListener(event: "close" | "error" | "message" | "open", listener: WebSocketEventListener): void;
90
90
 
@@ -93,4 +93,9 @@ declare module "web/websocket" {
93
93
  }
94
94
 
95
95
  export default WebSocket;
96
- }
96
+ }
97
+
98
+ // the specifier of the module in the Moddable SDK runtime
99
+ declare module "WebSocket" {
100
+ export { default } from "web/websocket";
101
+ }
@@ -18,6 +18,9 @@
18
18
  *
19
19
  */
20
20
 
21
+ // the manifest that supplies this module includes the manifests of these configurations
22
+ /// <reference path="../config/storage.d.ts" />
23
+
21
24
  declare module "webstorage" {
22
25
  class WebStorage {
23
26
  constructor(kvp: any);
package/web/worker.d.ts CHANGED
@@ -37,6 +37,8 @@ declare module "worker" {
37
37
  symbol?: number;
38
38
  };
39
39
  nativeStack?: number;
40
+ core?: number;
41
+ priority?: number;
40
42
  }
41
43
 
42
44
  interface MessagePort {
package/websocket.d.ts CHANGED
@@ -28,6 +28,7 @@ declare module "websocket" {
28
28
  }
29
29
  export type WebSocketClientCallback = (message: number, value?: any) => void;
30
30
 
31
+ /** @deprecated Use WebSocket, or the ECMA-419 embedded:network/websocket/client and the embedded:network/http/server/route/ws/handshake route */
31
32
  export class Client {
32
33
  static readonly connect: number;
33
34
  static readonly handshake: number;
@@ -43,6 +44,7 @@ declare module "websocket" {
43
44
  export type WebSocketServerOptions = ListenerOptions
44
45
  export type WebSocketServerCallback = (message: number, value?: any) => void;
45
46
 
47
+ /** @deprecated Use WebSocket, or the ECMA-419 embedded:network/websocket/client and the embedded:network/http/server/route/ws/handshake route */
46
48
  export class Server {
47
49
  static readonly connect: number;
48
50
  static readonly handshake: number;
package/wifi.d.ts CHANGED
@@ -42,6 +42,7 @@ declare module "wifi" {
42
42
  max?: number
43
43
  }
44
44
 
45
+ /** @deprecated Use the ECMA-419 Wi-Fi network interface, embedded:network/interface/wifi */
45
46
  class WiFi {
46
47
  static readonly gotIP: "gotIP";
47
48
  static readonly lostIP: "lostIP";
package/xs.d.ts CHANGED
@@ -19,7 +19,7 @@
19
19
  */
20
20
 
21
21
  interface Trace {
22
- (...log: (string | number | boolean)[]):void;
22
+ (...log: unknown[]):void;
23
23
  left(log: string | ArrayBufferLike, conversation?: string):void;
24
24
  center(log: string | ArrayBufferLike, conversation?: string):void;
25
25
  right(log: string | ArrayBufferLike, conversation?: string):void;
@@ -53,7 +53,7 @@ interface JSON {
53
53
  }
54
54
 
55
55
  interface StringConstructor {
56
- fromArrayBuffer(buffer: ArrayBufferLike): string;
56
+ fromArrayBuffer(buffer: ArrayBufferLike, byteOffset?: number, byteLength?: number): string;
57
57
  }
58
58
 
59
59
  interface ArrayBufferConstructor {
@@ -63,17 +63,26 @@ interface ArrayBufferConstructor {
63
63
 
64
64
  interface ArrayBuffer {
65
65
  concat(...buffers: ArrayBufferLike[]): ArrayBuffer;
66
+
67
+ // immutable ArrayBuffers (not yet in every XS deployment: only where mxImmutableArrayBuffers is enabled)
68
+ readonly immutable: boolean;
69
+ sliceToImmutable(start?: number, end?: number): ArrayBuffer;
70
+ transferToImmutable(newByteLength?: number): ArrayBuffer;
71
+ }
72
+
73
+ interface ToBase64Options {
74
+ alphabet?: "base64url" | "base64";
75
+ omitPadding?: boolean;
66
76
  }
67
77
 
68
78
  interface Uint8Array {
69
79
  toHex(): string;
70
- toBase64(): string
80
+ toBase64(options?: ToBase64Options): string
71
81
  }
72
82
 
73
83
  interface FromBase64Options {
74
84
  alphabet?: "base64url" | "base64";
75
85
  lastChunkHandling?: "stop-before-partial" | "strict" | "loose";
76
- omitPadding?: boolean;
77
86
  }
78
87
 
79
88
  interface Uint8ArrayConstructor {
@@ -91,7 +100,8 @@ interface Math {
91
100
  idiv(a: number, b: number): number
92
101
  imod(a: number, b: number): number
93
102
  imuldiv(a: number, b: number, c: number): number
94
- irandom(a: number, b: number): number
103
+ irandom(min: number, max: number): number
104
+ irandom(max: number): number
95
105
  irem(a: number, b: number): number
96
106
  mod(a: number, b: number): number
97
107
  }
@@ -100,4 +110,42 @@ interface Math {
100
110
  declare function Native(name: string): new (...args: any[]) => any;
101
111
  declare function native(name: string): (...args: any[]) => any;
102
112
 
103
- // Compartment?
113
+
114
+ /*
115
+ Compartment (see documentation/xs/XS Compartment.md)
116
+ */
117
+ interface ModuleDescriptor {
118
+ source?: string | ModuleSource | object;
119
+ importMeta?: object;
120
+ specifier?: string;
121
+ namespace?: string | object;
122
+ compartment?: Compartment;
123
+ archive?: object;
124
+ path?: string;
125
+ }
126
+ interface CompartmentOptions {
127
+ globals?: object;
128
+ globalLexicals?: object;
129
+ modules?: Record<string, ModuleDescriptor>;
130
+ loadHook?: (specifier: string) => Promise<ModuleDescriptor>;
131
+ loadNowHook?: (specifier: string) => ModuleDescriptor;
132
+ resolveHook?: (importSpecifier: string, referrerSpecifier: string) => string;
133
+ }
134
+ declare class Compartment {
135
+ constructor(options?: CompartmentOptions);
136
+ readonly globalThis: Record<PropertyKey, any>;
137
+ evaluate(script: string): any;
138
+ import(specifier: string): Promise<any>;
139
+ importNow(specifier: string): any;
140
+ }
141
+ declare class ModuleSource {
142
+ constructor(source: string);
143
+ readonly bindings: object[];
144
+ readonly needsImport: boolean;
145
+ readonly needsImportMeta: boolean;
146
+ }
147
+
148
+ /*
149
+ abort hook: when a function, XS calls it before aborting. Returning false ignores the abort.
150
+ */
151
+ declare var abort: ((message: string, exception?: any) => boolean | void) | undefined;
package/display.d.ts DELETED
@@ -1,68 +0,0 @@
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
- }
@@ -1,51 +0,0 @@
1
- /*
2
- * Copyright (c) 2025-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:provider/builtin" {
22
-
23
- const device: {
24
- readonly network: {
25
- http: {
26
- io: typeof import("embedded:network/http/client").default;
27
- protocol: "http";
28
- };
29
- https: {
30
- io: typeof import("embedded:network/http/client").default;
31
- protocol: "https";
32
- };
33
- ws: {
34
- io: typeof import("embedded:network/websocket/client").default;
35
- secure: false;
36
- };
37
- wss: {
38
- io: typeof import("embedded:network/websocket/client").default;
39
- secure: true;
40
- };
41
- };
42
- readonly info: {
43
- readonly language: string,
44
- readonly serialNumber: string,
45
- }
46
- readonly files: import("embedded:storage/files").Directory;
47
- readonly keyValue: typeof import("embedded:storage/key-value").default;
48
- }
49
-
50
- export default device;
51
- }