@moddable/typings 1.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 (89) hide show
  1. package/Resource.d.ts +30 -0
  2. package/base64.d.ts +27 -0
  3. package/ble/hidclient.d.ts +95 -0
  4. package/ble/index.d.ts +1 -0
  5. package/ble.d.ts +732 -0
  6. package/commodetto/Bitmap.d.ts +53 -0
  7. package/commodetto/PixelsOut.d.ts +67 -0
  8. package/commodetto/Poco.d.ts +104 -0
  9. package/commodetto/index.d.ts +1 -0
  10. package/commodetto/outline.d.ts +101 -0
  11. package/commodetto/parseBMF.d.ts +34 -0
  12. package/commodetto/parseBMP.d.ts +25 -0
  13. package/commodetto/parseRLE.d.ts +25 -0
  14. package/commodetto/readJPEG.d.ts +39 -0
  15. package/console.d.ts +39 -0
  16. package/crc.d.ts +35 -0
  17. package/debug.d.ts +26 -0
  18. package/deepEqual.d.ts +23 -0
  19. package/dns/index.d.ts +1 -0
  20. package/dns/parser.d.ts +37 -0
  21. package/dns/serializer.d.ts +41 -0
  22. package/dns/server.d.ts +27 -0
  23. package/dns.d.ts +55 -0
  24. package/embedded_io/_common.d.ts +27 -0
  25. package/embedded_io/analog.d.ts +39 -0
  26. package/embedded_io/digital.d.ts +65 -0
  27. package/embedded_io/digitalbank.d.ts +56 -0
  28. package/embedded_io/i2c.d.ts +44 -0
  29. package/embedded_io/index.d.ts +1 -0
  30. package/embedded_io/pulsecount.d.ts +39 -0
  31. package/embedded_io/pwm.d.ts +38 -0
  32. package/embedded_io/serial.d.ts +61 -0
  33. package/embedded_io/smbus.d.ts +43 -0
  34. package/embedded_io/socket/listener.d.ts +36 -0
  35. package/embedded_io/socket/tcp.d.ts +51 -0
  36. package/embedded_io/socket/udp.d.ts +46 -0
  37. package/embedded_io/spi.d.ts +45 -0
  38. package/embedded_io/system.d.ts +36 -0
  39. package/embedded_provider/builtin.d.ts +57 -0
  40. package/embedded_provider/index.d.ts +1 -0
  41. package/file.d.ts +67 -0
  42. package/flash.d.ts +33 -0
  43. package/global.d.ts +9 -0
  44. package/hex.d.ts +27 -0
  45. package/http.d.ts +125 -0
  46. package/instrumentation.d.ts +60 -0
  47. package/mc/config.d.ts +24 -0
  48. package/mc/index.d.ts +1 -0
  49. package/mcpack.d.ts +41 -0
  50. package/mdns.d.ts +47 -0
  51. package/modules.d.ts +28 -0
  52. package/net.d.ts +67 -0
  53. package/package.json +14 -0
  54. package/ping.d.ts +38 -0
  55. package/pins/analog.d.ts +26 -0
  56. package/pins/audioin.d.ts +31 -0
  57. package/pins/audioout.d.ts +85 -0
  58. package/pins/digital/monitor.d.ts +41 -0
  59. package/pins/digital.d.ts +46 -0
  60. package/pins/i2c.d.ts +40 -0
  61. package/pins/index.d.ts +1 -0
  62. package/pins/pwm.d.ts +28 -0
  63. package/pins/rmt.d.ts +48 -0
  64. package/pins/servo.d.ts +28 -0
  65. package/pins/smbus.d.ts +47 -0
  66. package/piu/CombTransition.d.ts +25 -0
  67. package/piu/MC.d.ts +580 -0
  68. package/piu/Sound.d.ts +43 -0
  69. package/piu/Timeline.d.ts +50 -0
  70. package/piu/WipeTransition.d.ts +25 -0
  71. package/piu/index.d.ts +1 -0
  72. package/piu/shape.d.ts +43 -0
  73. package/preference.d.ts +29 -0
  74. package/securesocket.d.ts +38 -0
  75. package/sntp.d.ts +42 -0
  76. package/socket.d.ts +97 -0
  77. package/structuredClone.d.ts +23 -0
  78. package/telnet.d.ts +27 -0
  79. package/text/decoder.d.ts +46 -0
  80. package/text/encoder.d.ts +38 -0
  81. package/text/index.d.ts +1 -0
  82. package/time.d.ts +31 -0
  83. package/timer.d.ts +47 -0
  84. package/uuid.d.ts +24 -0
  85. package/websocket.d.ts +58 -0
  86. package/wifi.d.ts +61 -0
  87. package/worker.d.ts +44 -0
  88. package/xs.d.ts +89 -0
  89. package/zip.d.ts +29 -0
package/piu/shape.d.ts ADDED
@@ -0,0 +1,43 @@
1
+ /*
2
+ * Copyright (c) 2022 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
+
22
+ declare module "piu/shape" {
23
+ import { Content, ContentDictionary } from "piu/MC";
24
+ import { Outline } from "commodetto/outline";
25
+
26
+ interface Shape extends Content {
27
+ fillOutline: Outline,
28
+ strokeOutline: Outline,
29
+ }
30
+ interface ShapeDictionary extends ContentDictionary {
31
+ string?: string;
32
+ }
33
+ interface ShapeConstructor {
34
+ new (behaviorData: any, dictionary: ShapeDictionary): Shape;
35
+ (behaviorData: any, dictionary: ShapeDictionary): Shape;
36
+
37
+ template<T>(this: T, any): T;
38
+ }
39
+
40
+ global {
41
+ const Shape: ShapeConstructor
42
+ }
43
+ }
@@ -0,0 +1,29 @@
1
+ /*
2
+ * Copyright (c) 2019-2020 Bradley Farias
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 "preference" {
22
+ var Preference: {
23
+ set: (domain: string, key: string, value: string | boolean | number | ArrayBuffer) => void;
24
+ get: (domain: string, key: string) => string | boolean | number | ArrayBuffer | undefined;
25
+ delete: (domain: string, key: string) => void;
26
+ keys: (domain: string) => string[];
27
+ }
28
+ export {Preference as default};
29
+ }
@@ -0,0 +1,38 @@
1
+ /*
2
+ * Copyright (c) 2023 Richard Lea
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 "securesocket" {
22
+ import { Socket } from "socket";
23
+
24
+ type WriteData = number | string | BufferLike;
25
+
26
+ export default class SecureSocket {
27
+ sock: typeof Socket;
28
+
29
+ constructor(dict: { [k: string]: any });
30
+
31
+ read<T extends typeof String | typeof ArrayBuffer>(
32
+ type: T,
33
+ until?: number
34
+ ): T extends typeof String ? string : ArrayBuffer;
35
+ write(data: WriteData, ...moreData: WriteData[]): void;
36
+ close(): void;
37
+ }
38
+ }
package/sntp.d.ts ADDED
@@ -0,0 +1,42 @@
1
+ /*
2
+ * Copyright (c) 2019-2020 Bradley Farias
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 "sntp" {
22
+ type SNTPOptions = {
23
+ host: string
24
+ };
25
+ type SNTPUnableToRetrieveTime = -1;
26
+ type SNTPTimeRetrieved = 1;
27
+ type SNTPRetry = 2;
28
+ type SNTPCallbackMessage = (
29
+ SNTPUnableToRetrieveTime |
30
+ SNTPTimeRetrieved |
31
+ SNTPRetry
32
+ )
33
+ type SNTPCallback = (message: SNTPCallbackMessage, value?: number) => void;
34
+ class SNTP {
35
+ static readonly time: SNTPTimeRetrieved;
36
+ static readonly retry: SNTPRetry;
37
+ static readonly error: SNTPUnableToRetrieveTime;
38
+
39
+ constructor(options: SNTPOptions, callback: SNTPCallback);
40
+ }
41
+ export {SNTP as default};
42
+ }
package/socket.d.ts ADDED
@@ -0,0 +1,97 @@
1
+ /*
2
+ * Copyright (c) 2019-2020 Bradley Farias
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 "socket" {
22
+ type RawSocketOptions = {
23
+ host?: string,
24
+ address?: string,
25
+ port: number,
26
+ kind: "RAW",
27
+ protocol?: number,
28
+ };
29
+ export type TCPSocketOptions = {
30
+ kind?: "TCP",
31
+ host?: string,
32
+ addresss?: string,
33
+ port?: number,
34
+ noDelay?: boolean,
35
+ keepalive?: {
36
+ idle: number,
37
+ interval: number,
38
+ count: number
39
+ }
40
+ };
41
+ type UDPSocketOptions = {
42
+ host?: string,
43
+ addresss?: string,
44
+ port: number,
45
+ kind: "UDP",
46
+ };
47
+ type WriteData = number | string | BufferLike;
48
+
49
+ type MessageError = -2;
50
+ type MessageDisconnect = -1;
51
+ type MessageConnect = 1;
52
+ type MessageDataReceived = 2;
53
+ type MessageDataSent = 3;
54
+ type MessageStatus = (
55
+ MessageError |
56
+ MessageDisconnect |
57
+ MessageConnect |
58
+ MessageDataReceived |
59
+ MessageDataSent
60
+ );
61
+ abstract class SocketBase {
62
+ close(): void;
63
+ read<T extends typeof String | typeof ArrayBuffer>(
64
+ type: T,
65
+ until?: number
66
+ ): T extends typeof String ? string : ArrayBuffer;
67
+ callback: (message: MessageStatus, value?: number) => void;
68
+ }
69
+ class RawSocket extends SocketBase {
70
+ write(ip: string, data: ArrayBuffer);
71
+ write(): number;
72
+ }
73
+ class TCPSocket extends SocketBase {
74
+ write(data: WriteData, ...moreData: WriteData[]);
75
+ write(): number;
76
+ }
77
+ class UDPSocket extends SocketBase {
78
+ write(ip: string, port: number, data: ArrayBuffer);
79
+ write(): number;
80
+ }
81
+ export type ListenerOptions = {
82
+ port?: number,
83
+ address?: string
84
+ };
85
+ class Listener {
86
+ constructor(options: ListenerOptions);
87
+ callback: (this: Listener) => void;
88
+ }
89
+ var Socket: {
90
+ new <T extends RawSocketOptions | TCPSocketOptions | UDPSocketOptions>(
91
+ dictionary: T
92
+ ): T extends RawSocketOptions ?
93
+ RawSocket : T extends TCPSocketOptions ? TCPSocket : UDPSocket;
94
+ new ({listener: Listener}): TCPSocket;
95
+ };
96
+ export {Socket, Listener};
97
+ }
@@ -0,0 +1,23 @@
1
+ /*
2
+ * Copyright (c) 2022 Shinya Ishikawa
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 "structuredClone" {
22
+ export default function structuredClone<T = unknown>(a: T): T
23
+ }
package/telnet.d.ts ADDED
@@ -0,0 +1,27 @@
1
+ /*
2
+ * Copyright (c) 2019-2020 Bradley Farias
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 "telnet" {
22
+ class Telnet {
23
+ constructor({port: number});
24
+ close(): void;
25
+ }
26
+ export {Telnet as default};
27
+ }
@@ -0,0 +1,46 @@
1
+ /*
2
+ * Copyright (c) 2022 Satoshi Tanaka
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 "text/decoder" {
22
+ interface TextDecoderOptions {
23
+ fatal?: boolean;
24
+ ignoreBOM?: boolean;
25
+ }
26
+ interface TextDecodeOptions {
27
+ stream?: boolean;
28
+ }
29
+
30
+ interface TextDecoder extends TextDecoderCommon {
31
+ decode(input?: Uint8Array | ArrayBufferLike, options?: TextDecodeOptions): string;
32
+ }
33
+
34
+ var TextDecoder: {
35
+ prototype: TextDecoder;
36
+ new(label?: "utf-8", options?: TextDecoderOptions): TextDecoder;
37
+ };
38
+
39
+ interface TextDecoderCommon {
40
+ readonly encoding: string;
41
+ readonly fatal: boolean;
42
+ readonly ignoreBOM: boolean;
43
+ }
44
+
45
+ export { TextDecoder as default };
46
+ }
@@ -0,0 +1,38 @@
1
+ /*
2
+ * Copyright (c) 2022 Satoshi Tanaka
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 "text/encoder" {
22
+
23
+ interface TextEncoderEncodeIntoResult {
24
+ read: number;
25
+ written: number;
26
+ }
27
+ interface TextEncoder {
28
+ encode(input: string): Uint8Array;
29
+ encodeInto(source: string, destination: Uint8Array): TextEncoderEncodeIntoResult;
30
+ }
31
+
32
+ var TextEncoder: {
33
+ prototype: TextEncoder;
34
+ new(): TextEncoder;
35
+ };
36
+
37
+ export { TextEncoder as default };
38
+ }
@@ -0,0 +1 @@
1
+ // Blank
package/time.d.ts ADDED
@@ -0,0 +1,31 @@
1
+ /*
2
+ * Copyright (c) 2019-2020 Bradley Farias
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 "time" {
22
+ var Time: {
23
+ set: (
24
+ seconds: number
25
+ ) => void,
26
+ timezone: number;
27
+ dst: number;
28
+ ticks: number;
29
+ }
30
+ export {Time as default};
31
+ }
package/timer.d.ts ADDED
@@ -0,0 +1,47 @@
1
+ /*
2
+ * Copyright (c) 2019-2020 Bradley Farias
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 "timer" {
22
+ export type TimerCallback = (timer: Timer) => void;
23
+
24
+ class Timer {
25
+ private constructor()
26
+ static set: (
27
+ callback: TimerCallback,
28
+ interval?: number,
29
+ repeat?: number
30
+ ) => Timer
31
+ static repeat: (
32
+ callback: TimerCallback,
33
+ interval: number,
34
+ ) => Timer
35
+ static schedule: (
36
+ timer: Timer,
37
+ interval?: number,
38
+ repeat?: number
39
+ ) => void;
40
+ static clear: (timer: Timer | undefined | null) => void;
41
+ static delay: (milliseconds: number) => void;
42
+
43
+ private brand: boolean;
44
+ }
45
+
46
+ export {Timer as default};
47
+ }
package/uuid.d.ts ADDED
@@ -0,0 +1,24 @@
1
+ /*
2
+ * Copyright (c) 2019-2020 Bradley Farias
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 "uuid" {
22
+ var UUID: () => string;
23
+ export {UUID as default};
24
+ }
package/websocket.d.ts ADDED
@@ -0,0 +1,58 @@
1
+ /*
2
+ * Copyright (c) 2019-2020 Bradley Farias
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 "websocket" {
22
+ import type {TCPSocketOptions, ListenerOptions} from "socket";
23
+
24
+ export type WebSocketClientOptions = TCPSocketOptions & {
25
+ path?: string,
26
+ protocol?: string,
27
+ headers?: string[]
28
+ }
29
+ export type WebSocketClientCallback = (message: number, value?: any) => void;
30
+
31
+ export class Client {
32
+ static readonly connect: number;
33
+ static readonly handshake: number;
34
+ static readonly receive: number;
35
+ static readonly disconnect: number;
36
+
37
+ constructor(options: WebSocketClientOptions);
38
+ close(): void;
39
+ write(data: string | ArrayBuffer);
40
+ callback: WebSocketClientCallback;
41
+ }
42
+
43
+ export type WebSocketServerOptions = ListenerOptions
44
+ export type WebSocketServerCallback = (message: number, value?: any) => void;
45
+
46
+ export class Server {
47
+ static readonly connect: number;
48
+ static readonly handshake: number;
49
+ static readonly receive: number;
50
+ static readonly disconnect: number;
51
+ static readonly subprotocol: number;
52
+
53
+ constructor(options: WebSocketServerOptions);
54
+ close(): void;
55
+ write(message: string | ArrayBuffer): void;
56
+ callback: WebSocketServerCallback;
57
+ }
58
+ }
package/wifi.d.ts ADDED
@@ -0,0 +1,61 @@
1
+ /*
2
+ * Copyright (c) 2019-2020 Bradley Farias
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 "wifi" {
22
+ export type WiFiOptions = {
23
+ bssid?: string,
24
+ ssid: string,
25
+ password?: string
26
+ }
27
+ export type WiFiCallback = (message: "connect" | "gotIP" | "lostIP" | "disconnect") => void
28
+ export type WiFiScanCallback = (item: {
29
+ ssid: string,
30
+ authentication: string,
31
+ rssi: number,
32
+ bssid: ArrayBuffer,
33
+ } | null) => void;
34
+ export type StationMode = 1;
35
+ export type AccessPointMode = 2;
36
+ export type ScanOptions = {hidden?: boolean, channel?: number}
37
+ export type AccessPointOptions = {
38
+ ssid: string,
39
+ password?: string,
40
+ channel?: number,
41
+ hidden?: boolean,
42
+ interval?: number,
43
+ max?: number
44
+ }
45
+
46
+ class WiFi {
47
+ static gotIP: "gotIP";
48
+ static lostIP: "lostIP";
49
+ static connected: "connect";
50
+ static disconnected: "disconnect";
51
+
52
+ constructor(options: WiFiOptions, callback: WiFiCallback);
53
+ close(): void;
54
+ static scan(options: ScanOptions, callback: WiFiScanCallback): void;
55
+ static mode: StationMode | AccessPointMode;
56
+ static connect(options?: WiFiOptions): void;
57
+ static disconnect(): void;
58
+ static accessPoint(options: AccessPointOptions): void;
59
+ }
60
+ export {WiFi as default};
61
+ }
package/worker.d.ts ADDED
@@ -0,0 +1,44 @@
1
+ /*
2
+ * Copyright (c) 2020 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 "worker" {
22
+ export interface Self {
23
+ onmessage(message: any): void;
24
+ postMessage(message: any): void;
25
+ }
26
+
27
+ class Worker implements Self {
28
+ constructor(module: string, options?: object)
29
+ terminate(): void;
30
+
31
+ onmessage(message: any): void;
32
+ postMessage(message: any): void;
33
+ }
34
+
35
+ export class SharedWorker {
36
+ constructor(module: string, options?: object)
37
+ }
38
+
39
+ global {
40
+ const self: Self
41
+ }
42
+
43
+ export {Worker as default}
44
+ }