@moddable/typings 1.0.0 → 1.0.3
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/commodetto/Poco.d.ts +2 -0
- package/commodetto/outline.d.ts +2 -1
- package/easing.d.ts +34 -0
- package/embedded_io/socket/tcp.d.ts +19 -19
- package/embedded_io/socket/tls.d.ts +16 -0
- package/embedded_network/dns/resolver/udp.d.ts +37 -0
- package/embedded_network/http/client.d.ts +54 -0
- package/embedded_network/mqtt/client.d.ts +74 -0
- package/headers.d.ts +25 -0
- package/mqtt/js.d.ts +337 -0
- package/package.json +1 -3
- package/pins/digital.d.ts +1 -1
- package/piu/MC.d.ts +0 -35
- package/qrcode.d.ts +32 -0
- package/time.d.ts +2 -1
- package/url.d.ts +56 -0
- package/wifi.d.ts +11 -9
package/commodetto/Poco.d.ts
CHANGED
|
@@ -79,6 +79,8 @@ declare module "commodetto/Poco" {
|
|
|
79
79
|
bitmapRemove(bits: Bitmap): void
|
|
80
80
|
compact(): void
|
|
81
81
|
|
|
82
|
+
drawQRCode(qrcode:ArrayBuffer, x: number, y: number, scale: number, fore: number)
|
|
83
|
+
|
|
82
84
|
readonly width: number
|
|
83
85
|
readonly height: number
|
|
84
86
|
readonly pixelsOut: PixelsOut
|
package/commodetto/outline.d.ts
CHANGED
|
@@ -59,7 +59,8 @@ declare module "commodetto/outline" {
|
|
|
59
59
|
clone(): Outline
|
|
60
60
|
rotate(angle: number): Outline
|
|
61
61
|
rotate(angle: number, cx: number, cy: number): Outline
|
|
62
|
-
scale(
|
|
62
|
+
scale(scale: number): Outline
|
|
63
|
+
scale(xScale: number, yScale: number): Outline
|
|
63
64
|
translate(x: number, y: number): Outline
|
|
64
65
|
|
|
65
66
|
readonly bounds: {
|
package/easing.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
type EasingFunction = (value: number) => number;
|
|
2
|
+
|
|
3
|
+
interface Math {
|
|
4
|
+
backEaseIn: EasingFunction,
|
|
5
|
+
backEaseInOut: EasingFunction,
|
|
6
|
+
backEaseOut: EasingFunction,
|
|
7
|
+
bounceEaseIn: EasingFunction,
|
|
8
|
+
bounceEaseInOut: EasingFunction,
|
|
9
|
+
bounceEaseOut: EasingFunction,
|
|
10
|
+
circularEaseIn: EasingFunction,
|
|
11
|
+
circularEaseInOut: EasingFunction,
|
|
12
|
+
circularEaseOut: EasingFunction,
|
|
13
|
+
cubicEaseIn: EasingFunction,
|
|
14
|
+
cubicEaseInOut: EasingFunction,
|
|
15
|
+
cubicEaseOut: EasingFunction,
|
|
16
|
+
elasticEaseIn: EasingFunction,
|
|
17
|
+
elasticEaseInOut: EasingFunction,
|
|
18
|
+
elasticEaseOut: EasingFunction,
|
|
19
|
+
exponentialEaseIn: EasingFunction,
|
|
20
|
+
exponentialEaseInOut: EasingFunction,
|
|
21
|
+
exponentialEaseOut: EasingFunction,
|
|
22
|
+
quadEaseIn: EasingFunction,
|
|
23
|
+
quadEaseInOut: EasingFunction,
|
|
24
|
+
quadEaseOut: EasingFunction,
|
|
25
|
+
quartEaseIn: EasingFunction,
|
|
26
|
+
quartEaseInOut: EasingFunction,
|
|
27
|
+
quartEaseOut: EasingFunction,
|
|
28
|
+
quintEaseIn: EasingFunction,
|
|
29
|
+
quintEaseInOut: EasingFunction,
|
|
30
|
+
quintEaseOut: EasingFunction,
|
|
31
|
+
sineEaseIn: EasingFunction,
|
|
32
|
+
sineEaseInOut: EasingFunction,
|
|
33
|
+
sineEaseOut: EasingFunction
|
|
34
|
+
}
|
|
@@ -20,23 +20,25 @@
|
|
|
20
20
|
|
|
21
21
|
declare module "embedded:io/socket/tcp" {
|
|
22
22
|
import type { Buffer } from "embedded:io/_common";
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
23
|
+
export type Options = ((({
|
|
24
|
+
address: string;
|
|
25
|
+
} | {
|
|
26
|
+
host: string;
|
|
27
|
+
}) & {
|
|
28
|
+
port: number;
|
|
29
|
+
}) | {
|
|
30
|
+
from: TCP;
|
|
31
|
+
}) & {
|
|
32
|
+
nodelay?: boolean;
|
|
33
|
+
onReadable?: (this: TCP, bytes: number) => void;
|
|
34
|
+
onWritable?: (this: TCP, bytes: number) => void;
|
|
35
|
+
onError?: (this: TCP) => void;
|
|
36
|
+
format?: "number" | "buffer";
|
|
37
|
+
target?: any;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export default class TCP {
|
|
41
|
+
constructor(options: Options)
|
|
40
42
|
readonly remoteAddress: string | undefined;
|
|
41
43
|
readonly remotePort: number | undefined;
|
|
42
44
|
read(byteLength?: number): number | ArrayBuffer;
|
|
@@ -46,6 +48,4 @@ declare module "embedded:io/socket/tcp" {
|
|
|
46
48
|
get format(): "number" | "buffer"
|
|
47
49
|
set format(value: "number" | "buffer")
|
|
48
50
|
}
|
|
49
|
-
|
|
50
|
-
export default TCP;
|
|
51
51
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
declare module "embedded:io/socket/tcp/tls" {
|
|
2
|
+
import { Options as TCPOptions } from "embedded:io/socket/tcp"
|
|
3
|
+
export type Options = TCPOptions & {
|
|
4
|
+
host: string
|
|
5
|
+
secure: Record<string, any> // should be called "tls" according to std?
|
|
6
|
+
}
|
|
7
|
+
export default class TLSSocket {
|
|
8
|
+
constructor(options: Options)
|
|
9
|
+
close(): undefined
|
|
10
|
+
read(count: number|ArrayBufferLike) : undefined|ArrayBufferLike
|
|
11
|
+
write(buffer: ArrayBufferLike) : number
|
|
12
|
+
set format(format: string)
|
|
13
|
+
get format() : string
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
@@ -0,0 +1,37 @@
|
|
|
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 "embedded:network/dns/resolver/udp" {
|
|
22
|
+
|
|
23
|
+
interface Options {
|
|
24
|
+
host: string
|
|
25
|
+
onResolved: ((host:string, address:any) => null)
|
|
26
|
+
onError: ((host:string) => null)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
class Resolver {
|
|
30
|
+
constructor(options: Record<string, any>)
|
|
31
|
+
close(): void
|
|
32
|
+
resolve(options: Options): void
|
|
33
|
+
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export default Resolver
|
|
37
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
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 "embedded:network/http/client" {
|
|
22
|
+
import type { Buffer } from "embedded:io/_common"
|
|
23
|
+
|
|
24
|
+
export interface ClientOptions {
|
|
25
|
+
socket: any
|
|
26
|
+
port?:number
|
|
27
|
+
host: string
|
|
28
|
+
dns: any
|
|
29
|
+
onError?: (err:any)=>void
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface RequestOptions {
|
|
33
|
+
method?: string
|
|
34
|
+
path?: string
|
|
35
|
+
headers?: Map<string, string|string[]>
|
|
36
|
+
onHeaders?: (this: HTTPRequest, status:number, headers: Map<String, string>) => void
|
|
37
|
+
onReadable?: (this: HTTPRequest, count: number) => void
|
|
38
|
+
onWritable?: (this: HTTPRequest, count: number) => void
|
|
39
|
+
onDone?: (this: HTTPRequest, error: Error|null) => void // note: error is empty Error object
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface HTTPRequest {
|
|
43
|
+
read(byteLength?: number): ArrayBuffer|undefined;
|
|
44
|
+
read(buffer: Buffer): void;
|
|
45
|
+
write(value: Buffer|undefined): void;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export default class HTTPClient {
|
|
49
|
+
constructor(options: ClientOptions)
|
|
50
|
+
request(options: RequestOptions): HTTPRequest
|
|
51
|
+
close(): void
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
declare module "embedded:network/mqtt/client" {
|
|
2
|
+
import type { Buffer } from "embedded:io/_common"
|
|
3
|
+
|
|
4
|
+
interface onReadableOptions {
|
|
5
|
+
more: boolean,
|
|
6
|
+
topic?: string,
|
|
7
|
+
QoS?: number,
|
|
8
|
+
byteLength?: number,
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface onControlMessage {
|
|
12
|
+
operation: number, // MQTTClient.CONNACK, etc...
|
|
13
|
+
id: number,
|
|
14
|
+
payload?: Buffer, // for SUBACK
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface Will {
|
|
18
|
+
topic?: string,
|
|
19
|
+
message?: string|Buffer,
|
|
20
|
+
QoS?: number,
|
|
21
|
+
retain?: boolean,
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface Options {
|
|
25
|
+
host: string,
|
|
26
|
+
port?: number,
|
|
27
|
+
user?: string,
|
|
28
|
+
password?: string,
|
|
29
|
+
id?: string,
|
|
30
|
+
clean?: boolean,
|
|
31
|
+
will?: any,
|
|
32
|
+
keepAlive?: number, // milliseconds
|
|
33
|
+
onReadable?: (count: number, options: onReadableOptions) => void,
|
|
34
|
+
onWritable?: (count: number) => void,
|
|
35
|
+
onControl?: (opcode: number, message: onControlMessage) => void,
|
|
36
|
+
onClose?: () => void,
|
|
37
|
+
onError?: (error: any) => void,
|
|
38
|
+
dns: Record<string, any>,
|
|
39
|
+
socket: Record<string, any>,
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
interface WriteOptions {
|
|
43
|
+
operation?: number,
|
|
44
|
+
id?: number,
|
|
45
|
+
topic: string,
|
|
46
|
+
QoS?: number,
|
|
47
|
+
retain?: boolean,
|
|
48
|
+
duplicate?: boolean,
|
|
49
|
+
byteLength?: number,
|
|
50
|
+
items?: any[], // being lazy here
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export default class MQTTClient {
|
|
54
|
+
constructor(options: Options)
|
|
55
|
+
read(count: number): ArrayBuffer
|
|
56
|
+
write(data: Buffer, options: WriteOptions): number
|
|
57
|
+
close(): void
|
|
58
|
+
|
|
59
|
+
static CONNECT: 1
|
|
60
|
+
static CONNACK: 2
|
|
61
|
+
static PUBLISH: 3
|
|
62
|
+
static PUBACK: 4
|
|
63
|
+
static PUBREC: 5
|
|
64
|
+
static PUBREL: 6
|
|
65
|
+
static PUBCOMP: 7
|
|
66
|
+
static SUBSCRIBE: 8
|
|
67
|
+
static SUBACK: 9
|
|
68
|
+
static UNSUBSCRIBE: 10
|
|
69
|
+
static UNSUBACK: 11
|
|
70
|
+
static PINGREQ: 12
|
|
71
|
+
static PINGRESP: 13
|
|
72
|
+
static DISCONNECT: 14
|
|
73
|
+
}
|
|
74
|
+
}
|
package/headers.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2024 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 "headers" {
|
|
22
|
+
class Headers extends Map<String, String> {}
|
|
23
|
+
|
|
24
|
+
export { Headers as default };
|
|
25
|
+
}
|
package/mqtt/js.d.ts
ADDED
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
// Adapted from https://github.com/mqttjs/MQTT.js
|
|
2
|
+
//
|
|
3
|
+
// The MIT License (MIT)
|
|
4
|
+
//
|
|
5
|
+
// Copyright (c) 2015-2016 MQTT.js contributors
|
|
6
|
+
// *MQTT.js contributors listed at <https://github.com/mqttjs/MQTT.js#contributors>*
|
|
7
|
+
// Copyright 2011-2014 by Adam
|
|
8
|
+
//
|
|
9
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
10
|
+
// and associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
11
|
+
// including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
12
|
+
// and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
13
|
+
// subject to the following conditions:
|
|
14
|
+
// The above copyright notice and this permission notice shall be included in all copies or
|
|
15
|
+
// substantial portions of the Software.
|
|
16
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
|
|
17
|
+
// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
18
|
+
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
19
|
+
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
21
|
+
|
|
22
|
+
declare module "mqtt/js" {
|
|
23
|
+
|
|
24
|
+
type QoS = 0 | 1 | 2
|
|
25
|
+
|
|
26
|
+
export interface IClientOptions /*extends ISecureClientOptions*/ {
|
|
27
|
+
// port?: number // port is made into a number subsequently
|
|
28
|
+
// host?: string // host does NOT include port
|
|
29
|
+
// hostname?: string
|
|
30
|
+
// path?: string
|
|
31
|
+
// protocol?: "wss" | "ws" | "mqtt" | "mqtts" | "tcp" | "ssl" | "wx" | "wxs"
|
|
32
|
+
|
|
33
|
+
// wsOptions?: ClientOptions | ClientRequestArgs
|
|
34
|
+
keepalive?: number // 10 seconds, set to 0 to disable
|
|
35
|
+
clientId?: string // 'mqttxs_' + Math.random().toString(16).substr(2, 8)
|
|
36
|
+
// protocolId?: string // 'MQTT'
|
|
37
|
+
// protocolVersion?: number //4
|
|
38
|
+
clean?: boolean //true, set to false to receive QoS 1 and 2 messages while offline
|
|
39
|
+
reconnectPeriod?: number //1000 milliseconds, interval between two reconnections
|
|
40
|
+
connectTimeout?: number //30 * 1000 milliseconds, time to wait before a CONNACK is received
|
|
41
|
+
username?: string //the username required by your broker, if any
|
|
42
|
+
password?: string //the password required by your broker, if any
|
|
43
|
+
// queueQoSZero?: boolean
|
|
44
|
+
// reschedulePings?: boolean
|
|
45
|
+
// servers?: Array<{
|
|
46
|
+
// host: string
|
|
47
|
+
// port: number
|
|
48
|
+
// protocol?: "wss" | "ws" | "mqtt" | "mqtts" | "tcp" | "ssl" | "wx" | "wxs"
|
|
49
|
+
// }>
|
|
50
|
+
resubscribe?: boolean // true, set to false to disable re-subscribe functionality
|
|
51
|
+
// a message that will sent by the broker automatically when the client disconnect badly
|
|
52
|
+
will?: {
|
|
53
|
+
topic: string // the topic to publish
|
|
54
|
+
payload: ArrayBuffer | string // the message to publish
|
|
55
|
+
qos: QoS // the QoS
|
|
56
|
+
retain: boolean // the retain flag
|
|
57
|
+
// properies object of will
|
|
58
|
+
// properties?: {
|
|
59
|
+
// willDelayInterval?: number
|
|
60
|
+
// payloadFormatIndicator?: boolean
|
|
61
|
+
// messageExpiryInterval?: number
|
|
62
|
+
// contentType?: string
|
|
63
|
+
// responseTopic?: string
|
|
64
|
+
// correlationData?: ArrayBuffer
|
|
65
|
+
// userProperties?: UserProperties
|
|
66
|
+
// }
|
|
67
|
+
}
|
|
68
|
+
// transformWsUrl?: (url: string, options: IClientOptions, client: MqttClient) => string
|
|
69
|
+
// properties?: {
|
|
70
|
+
// sessionExpiryInterval?: number
|
|
71
|
+
// receiveMaximum?: number
|
|
72
|
+
// maximumPacketSize?: number
|
|
73
|
+
// topicAliasMaximum?: number
|
|
74
|
+
// requestResponseInformation?: boolean
|
|
75
|
+
// requestProblemInformation?: boolean
|
|
76
|
+
// userProperties?: UserProperties
|
|
77
|
+
// authenticationMethod?: string
|
|
78
|
+
// authenticationData?: Buffer
|
|
79
|
+
// }
|
|
80
|
+
// messageIdProvider?: IMessageIdProvider
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface IClientPublishOptions {
|
|
84
|
+
qos?: QoS
|
|
85
|
+
retain?: boolean
|
|
86
|
+
dup?: boolean // whether or not mark a message as duplicate
|
|
87
|
+
// MQTT 5.0 properties object
|
|
88
|
+
// properties?: {
|
|
89
|
+
// payloadFormatIndicator?: boolean
|
|
90
|
+
// messageExpiryInterval?: number
|
|
91
|
+
// topicAlias?: number
|
|
92
|
+
// responseTopic?: string
|
|
93
|
+
// correlationData?: Buffer
|
|
94
|
+
// userProperties?: UserProperties
|
|
95
|
+
// subscriptionIdentifier?: number
|
|
96
|
+
// contentType?: string
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export interface IClientSubscribeOptions {
|
|
100
|
+
// the QoS
|
|
101
|
+
qos: QoS
|
|
102
|
+
// nl?: boolean // no local flag
|
|
103
|
+
// rap?: boolean // Retain As Published flag
|
|
104
|
+
// rh?: number // Retain Handling option
|
|
105
|
+
// MQTT 5.0 properies object of subscribe
|
|
106
|
+
// properties?: {
|
|
107
|
+
// subscriptionIdentifier?: number
|
|
108
|
+
// userProperties?: UserProperties
|
|
109
|
+
// }
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface ISubscriptionGrant {
|
|
113
|
+
topic: string // is a subscribed to topic
|
|
114
|
+
qos: QoS // is the granted qos level on it
|
|
115
|
+
// nl?: boolean // no local flag
|
|
116
|
+
// rap?: boolean // Retain As Published flag
|
|
117
|
+
// rh?: number // Retain Handling option
|
|
118
|
+
}
|
|
119
|
+
// export interface ISubscriptionRequest {
|
|
120
|
+
// topic: string // is a subscribed to topic
|
|
121
|
+
// qos: QoS // is the granted qos level on it
|
|
122
|
+
// nl?: boolean // no local flag
|
|
123
|
+
// rap?: boolean // Retain As Published flag
|
|
124
|
+
// rh?: number // Retain Handling option
|
|
125
|
+
// }
|
|
126
|
+
|
|
127
|
+
export interface ISubscriptionMap {
|
|
128
|
+
// object which has topic names as object keys and as value the options, like {'test1': {qos: 0}, 'test2': {qos: 2}}.
|
|
129
|
+
[topic: string]: {
|
|
130
|
+
qos: QoS
|
|
131
|
+
// nl?: boolean
|
|
132
|
+
// rap?: boolean
|
|
133
|
+
// rh?: number
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
//export type OnConnectCallback = (packet: IConnackPacket) => void
|
|
138
|
+
export type OnConnectCallback = () => void
|
|
139
|
+
//export type OnDisconnectCallback = (packet: IDisconnectPacket) => void
|
|
140
|
+
export type ClientSubscribeCallback = (err: Error, granted: ISubscriptionGrant[]) => void
|
|
141
|
+
export type OnMessageCallback = (
|
|
142
|
+
topic: string,
|
|
143
|
+
payload: ArrayBuffer
|
|
144
|
+
//packet: IPublishPacket
|
|
145
|
+
) => void
|
|
146
|
+
//export type OnPacketCallback = (packet: Packet) => void
|
|
147
|
+
export type OnCloseCallback = () => void
|
|
148
|
+
export type OnErrorCallback = (error: Error) => void
|
|
149
|
+
//export type PacketCallback = (error?: Error, packet?: Packet) => any
|
|
150
|
+
export type PacketCallback = (error?: Error) => any
|
|
151
|
+
//export type CloseCallback = (error?: Error) => void
|
|
152
|
+
export type CloseCallback = () => void
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* MqttClient constructor
|
|
156
|
+
*
|
|
157
|
+
* @param {Stream} stream - stream
|
|
158
|
+
* @param {Object} [options] - connection options
|
|
159
|
+
* (see Connection#connect)
|
|
160
|
+
*/
|
|
161
|
+
export class Client /*extends events.EventEmitter*/ {
|
|
162
|
+
public connected: boolean
|
|
163
|
+
// public disconnecting: boolean
|
|
164
|
+
// public disconnected: boolean
|
|
165
|
+
public reconnecting: boolean
|
|
166
|
+
// public options: IClientOptions
|
|
167
|
+
// public queueQoSZero: boolean
|
|
168
|
+
|
|
169
|
+
constructor(url: string, options: IClientOptions)
|
|
170
|
+
|
|
171
|
+
public on(event: "connect", cb: OnConnectCallback): this
|
|
172
|
+
public on(event: "message", cb: OnMessageCallback): this
|
|
173
|
+
//public on(event: "packetsend" | "packetreceive", cb: OnPacketCallback): this
|
|
174
|
+
//public on(event: "disconnect", cb: OnDisconnectCallback): this
|
|
175
|
+
public on(event: "error", cb: OnErrorCallback): this
|
|
176
|
+
public on(event: "close", cb: OnCloseCallback): this
|
|
177
|
+
public on(event: "end" | "reconnect" | "offline", cb: () => void): this
|
|
178
|
+
//public on(event: "end" | "reconnect" | "offline" | "outgoingEmpty", cb: () => void): this
|
|
179
|
+
public on(event: string, cb: Function): this
|
|
180
|
+
|
|
181
|
+
// public once(event: "connect", cb: OnConnectCallback): this
|
|
182
|
+
// public once(event: "message", cb: OnMessageCallback): this
|
|
183
|
+
// public once(event: "packetsend" | "packetreceive", cb: OnPacketCallback): this
|
|
184
|
+
// public once(event: "disconnect", cb: OnDisconnectCallback): this
|
|
185
|
+
// public once(event: "error", cb: OnErrorCallback): this
|
|
186
|
+
// public once(event: "close", cb: OnCloseCallback): this
|
|
187
|
+
// public once(event: "end" | "reconnect" | "offline" | "outgoingEmpty", cb: () => void): this
|
|
188
|
+
// public once(event: string, cb: Function): this
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* publish - publish <message> to <topic>
|
|
192
|
+
*
|
|
193
|
+
* @param {String} topic - topic to publish to
|
|
194
|
+
* @param {(String|Buffer)} message - message to publish
|
|
195
|
+
*
|
|
196
|
+
* @param {Object} [opts] - publish options, includes:
|
|
197
|
+
* @param {Number} [opts.qos] - qos level to publish on
|
|
198
|
+
* @param {Boolean} [opts.retain] - whether or not to retain the message
|
|
199
|
+
* @param {Function}[opts.cbStorePut] - function(){}
|
|
200
|
+
* called when message is put into `outgoingStore`
|
|
201
|
+
*
|
|
202
|
+
* @param {Function} [callback] - function(err){}
|
|
203
|
+
* called when publish succeeds or fails
|
|
204
|
+
*
|
|
205
|
+
* @returns {Client} this - for chaining
|
|
206
|
+
* @api public
|
|
207
|
+
*
|
|
208
|
+
* @example client.publish('topic', 'message')
|
|
209
|
+
* @example
|
|
210
|
+
* client.publish('topic', 'message', {qos: 1, retain: true})
|
|
211
|
+
* @example client.publish('topic', 'message', console.log)
|
|
212
|
+
*/
|
|
213
|
+
public publish(
|
|
214
|
+
topic: string,
|
|
215
|
+
message: string | ArrayBuffer,
|
|
216
|
+
opts: IClientPublishOptions,
|
|
217
|
+
callback?: PacketCallback
|
|
218
|
+
): this
|
|
219
|
+
public publish(topic: string, message: string | ArrayBuffer, callback?: PacketCallback): this
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* subscribe - subscribe to <topic>
|
|
223
|
+
*
|
|
224
|
+
* @param {String, Array, Object} topic - topic(s) to subscribe to, supports objects in the form {'topic': qos}
|
|
225
|
+
* @param {Object} [opts] - optional subscription options, includes:
|
|
226
|
+
* @param {Number} [opts.qos] - subscribe qos level
|
|
227
|
+
* @param {Function} [callback] - function(err, granted){} where:
|
|
228
|
+
* {Error} err - subscription error (none at the moment!)
|
|
229
|
+
* {Array} granted - array of {topic: 't', qos: 0}
|
|
230
|
+
* @returns {MqttClient} this - for chaining
|
|
231
|
+
* @api public
|
|
232
|
+
* @example client.subscribe('topic')
|
|
233
|
+
* @example client.subscribe('topic', {qos: 1})
|
|
234
|
+
* @example client.subscribe({'topic': 0, 'topic2': 1}, console.log)
|
|
235
|
+
* @example client.subscribe('topic', console.log)
|
|
236
|
+
*/
|
|
237
|
+
public subscribe(
|
|
238
|
+
topic: string | string[],
|
|
239
|
+
opts: IClientSubscribeOptions,
|
|
240
|
+
callback?: ClientSubscribeCallback
|
|
241
|
+
): this
|
|
242
|
+
public subscribe(
|
|
243
|
+
topic: string | string[] | ISubscriptionMap,
|
|
244
|
+
callback?: ClientSubscribeCallback
|
|
245
|
+
): this
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* unsubscribe - unsubscribe from topic(s)
|
|
249
|
+
*
|
|
250
|
+
* @param {String, Array} topic - topics to unsubscribe from
|
|
251
|
+
* @param {Object} opts - opts of unsubscribe
|
|
252
|
+
* @param {Function} [callback] - callback fired on unsuback
|
|
253
|
+
* @returns {MqttClient} this - for chaining
|
|
254
|
+
* @api public
|
|
255
|
+
* @example client.unsubscribe('topic')
|
|
256
|
+
* @example client.unsubscribe('topic', console.log)
|
|
257
|
+
* @example client.unsubscribe('topic', opts, console.log)
|
|
258
|
+
*/
|
|
259
|
+
public unsubscribe(topic: string | string[], opts?: Object, callback?: PacketCallback): this
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* end - close connection
|
|
263
|
+
*
|
|
264
|
+
* @returns {MqttClient} this - for chaining
|
|
265
|
+
* @param {Boolean} force - do not wait for all in-flight messages to be acked
|
|
266
|
+
* @param {Object} opts - opts disconnect
|
|
267
|
+
* @param {Function} cb - called when the client has been closed
|
|
268
|
+
*
|
|
269
|
+
* @api public
|
|
270
|
+
*/
|
|
271
|
+
public end(force?: boolean, opts?: Object, cb?: CloseCallback): this
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* removeOutgoingMessage - remove a message in outgoing store
|
|
275
|
+
* the outgoing callback will be called withe Error('Message removed') if the message is removed
|
|
276
|
+
*
|
|
277
|
+
* @param {Number} mid - messageId to remove message
|
|
278
|
+
* @returns {MqttClient} this - for chaining
|
|
279
|
+
* @api public
|
|
280
|
+
*
|
|
281
|
+
* @example client.removeOutgoingMessage(client.getLastMessageId());
|
|
282
|
+
*/
|
|
283
|
+
//public removeOutgoingMessage(mid: number): this
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* reconnect - connect again using the same options as connect()
|
|
287
|
+
*
|
|
288
|
+
* @param {Object} [opts] - optional reconnect options, includes:
|
|
289
|
+
* {Store} incomingStore - a store for the incoming packets
|
|
290
|
+
* {Store} outgoingStore - a store for the outgoing packets
|
|
291
|
+
* if opts is not given, current stores are used
|
|
292
|
+
*
|
|
293
|
+
* @returns {MqttClient} this - for chaining
|
|
294
|
+
*
|
|
295
|
+
* @api public
|
|
296
|
+
*/
|
|
297
|
+
public reconnect(): this
|
|
298
|
+
//public reconnect(opts?: IClientReconnectOptions): this
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Handle messages with backpressure support, one at a time.
|
|
302
|
+
* Override at will.
|
|
303
|
+
*
|
|
304
|
+
* @param packet packet the packet
|
|
305
|
+
* @param callback callback call when finished
|
|
306
|
+
* @api public
|
|
307
|
+
*/
|
|
308
|
+
//public handleMessage(packet: Packet, callback: PacketCallback): void
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Handle auth packages for MQTT 5 enhanced authentication methods such
|
|
312
|
+
* as challenge response authentication.
|
|
313
|
+
*
|
|
314
|
+
* Challenge-response authentication flow would look something like this:
|
|
315
|
+
*
|
|
316
|
+
* --> CONNECT | authMethod = "mathChallenge" -->
|
|
317
|
+
* <-- AUTH | authMethod = "mathChallenge", authData = "12 + 34" <--
|
|
318
|
+
* --> AUTH | authMethod = "mathChallenge", authData = "46" -->
|
|
319
|
+
* <-- CONNACK | reasonCode = SUCCESS <--
|
|
320
|
+
*
|
|
321
|
+
* This form of authentication has several advantages over traditional
|
|
322
|
+
* credential-based approaches. For instance authentication without the direct
|
|
323
|
+
* exchange of authentication secrets.
|
|
324
|
+
*
|
|
325
|
+
* @param packet the auth packet to handle
|
|
326
|
+
* @param callback call when finished
|
|
327
|
+
* @api public
|
|
328
|
+
*/
|
|
329
|
+
//public handleAuth(packet: IAuthPacket, callback: PacketCallback): void
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* getLastMessageId
|
|
333
|
+
*/
|
|
334
|
+
public getLastMessageId(): number
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
}
|
package/package.json
CHANGED
package/pins/digital.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ declare module 'pins/digital' {
|
|
|
25
25
|
type InputPullUpDown = 3
|
|
26
26
|
type Output = 8
|
|
27
27
|
type OutputOpenDrain = 9
|
|
28
|
-
type Mode = Input | InputPullUp | InputPullDown | InputPullUpDown | Output | OutputOpenDrain
|
|
28
|
+
export type Mode = Input | InputPullUp | InputPullDown | InputPullUpDown | Output | OutputOpenDrain
|
|
29
29
|
export class Digital {
|
|
30
30
|
public constructor(dictionary: { pin: number; mode: number; port?: string })
|
|
31
31
|
public constructor(pin: number, mode: number)
|
package/piu/MC.d.ts
CHANGED
|
@@ -543,38 +543,3 @@ declare module "piu/MC" {
|
|
|
543
543
|
const rgba: rgba
|
|
544
544
|
}
|
|
545
545
|
}
|
|
546
|
-
|
|
547
|
-
type PiuInterpolator = (value: number) => number;
|
|
548
|
-
|
|
549
|
-
interface Math {
|
|
550
|
-
backEaseIn: PiuInterpolator,
|
|
551
|
-
backEaseInOut: PiuInterpolator,
|
|
552
|
-
backEaseOut: PiuInterpolator,
|
|
553
|
-
bounceEaseIn: PiuInterpolator,
|
|
554
|
-
bounceEaseInOut: PiuInterpolator,
|
|
555
|
-
bounceEaseOut: PiuInterpolator,
|
|
556
|
-
circularEaseIn: PiuInterpolator,
|
|
557
|
-
circularEaseInOut: PiuInterpolator,
|
|
558
|
-
circularEaseOut: PiuInterpolator,
|
|
559
|
-
cubicEaseIn: PiuInterpolator,
|
|
560
|
-
cubicEaseInOut: PiuInterpolator,
|
|
561
|
-
cubicEaseOut: PiuInterpolator,
|
|
562
|
-
elasticEaseIn: PiuInterpolator,
|
|
563
|
-
elasticEaseInOut: PiuInterpolator,
|
|
564
|
-
elasticEaseOut: PiuInterpolator,
|
|
565
|
-
exponentialEaseIn: PiuInterpolator,
|
|
566
|
-
exponentialEaseInOut: PiuInterpolator,
|
|
567
|
-
exponentialEaseOut: PiuInterpolator,
|
|
568
|
-
quadEaseIn: PiuInterpolator,
|
|
569
|
-
quadEaseInOut: PiuInterpolator,
|
|
570
|
-
quadEaseOut: PiuInterpolator,
|
|
571
|
-
quartEaseIn: PiuInterpolator,
|
|
572
|
-
quartEaseInOut: PiuInterpolator,
|
|
573
|
-
quartEaseOut: PiuInterpolator,
|
|
574
|
-
quintEaseIn: PiuInterpolator,
|
|
575
|
-
quintEaseInOut: PiuInterpolator,
|
|
576
|
-
quintEaseOut: PiuInterpolator,
|
|
577
|
-
sineEaseIn: PiuInterpolator,
|
|
578
|
-
sineEaseInOut: PiuInterpolator,
|
|
579
|
-
sineEaseOut: PiuInterpolator
|
|
580
|
-
}
|
package/qrcode.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2024 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 "qrcode" {
|
|
22
|
+
interface qrcode extends ArrayBuffer {
|
|
23
|
+
size: number;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
var qrCode: (options: {
|
|
27
|
+
input: string | BufferLike,
|
|
28
|
+
maxVersion?: number
|
|
29
|
+
}) => qrcode;
|
|
30
|
+
|
|
31
|
+
export { qrCode as default };
|
|
32
|
+
}
|
package/time.d.ts
CHANGED
package/url.d.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2024 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 "url" {
|
|
22
|
+
|
|
23
|
+
class URL {
|
|
24
|
+
constructor(url: string, base?: string)
|
|
25
|
+
hash: string;
|
|
26
|
+
host: string;
|
|
27
|
+
hostname: string;
|
|
28
|
+
href: string;
|
|
29
|
+
readonly origin: string;
|
|
30
|
+
password: string;
|
|
31
|
+
pathname: string;
|
|
32
|
+
port: string;
|
|
33
|
+
protocol: string;
|
|
34
|
+
search: string;
|
|
35
|
+
readonly searchParams: URLSearchParams;
|
|
36
|
+
username: string;
|
|
37
|
+
toJSON(): string;
|
|
38
|
+
toString(): string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
class URLSearchParams implements Iterable<[string, string]>{
|
|
42
|
+
constructor(it?: string[][] | Record<string, string> | string)
|
|
43
|
+
readonly length: number;
|
|
44
|
+
append(name: string, value: string): void;
|
|
45
|
+
delete(name: string, value?: string): void;
|
|
46
|
+
get(name: string): string | null;
|
|
47
|
+
getAll(name: string): string[];
|
|
48
|
+
has(name: string, value?: string): boolean;
|
|
49
|
+
set(name: string, value: string): void;
|
|
50
|
+
toString(): string;
|
|
51
|
+
updatePairs(): void;
|
|
52
|
+
updateParts(): void;
|
|
53
|
+
[Symbol.iterator](): IterableIterator<[string, string]>;
|
|
54
|
+
}
|
|
55
|
+
export { URL, URLSearchParams }
|
|
56
|
+
}
|
package/wifi.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2019-
|
|
2
|
+
* Copyright (c) 2019-2024 Bradley Farias
|
|
3
3
|
*
|
|
4
4
|
* This file is part of the Moddable SDK Tools.
|
|
5
5
|
*
|
|
@@ -20,11 +20,11 @@
|
|
|
20
20
|
|
|
21
21
|
declare module "wifi" {
|
|
22
22
|
export type WiFiOptions = {
|
|
23
|
-
bssid?:
|
|
23
|
+
bssid?: ArrayBuffer,
|
|
24
24
|
ssid: string,
|
|
25
25
|
password?: string
|
|
26
26
|
}
|
|
27
|
-
export type WiFiCallback = (message: "connect" | "gotIP" | "lostIP" | "disconnect") => void
|
|
27
|
+
export type WiFiCallback = (message: "connect" | "gotIP" | "lostIP" | "disconnect" | "station_connect" | "station_disconnect") => void
|
|
28
28
|
export type WiFiScanCallback = (item: {
|
|
29
29
|
ssid: string,
|
|
30
30
|
authentication: string,
|
|
@@ -44,12 +44,14 @@ declare module "wifi" {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
class WiFi {
|
|
47
|
-
static gotIP: "gotIP";
|
|
48
|
-
static lostIP: "lostIP";
|
|
49
|
-
static connected: "connect";
|
|
50
|
-
static disconnected: "disconnect";
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
static readonly gotIP: "gotIP";
|
|
48
|
+
static readonly lostIP: "lostIP";
|
|
49
|
+
static readonly connected: "connect";
|
|
50
|
+
static readonly disconnected: "disconnect";
|
|
51
|
+
static readonly station_connected: "station_connect";
|
|
52
|
+
static readonly station_disconnected: "station_disconnect";
|
|
53
|
+
|
|
54
|
+
constructor(options?: WiFiOptions, callback?: WiFiCallback);
|
|
53
55
|
close(): void;
|
|
54
56
|
static scan(options: ScanOptions, callback: WiFiScanCallback): void;
|
|
55
57
|
static mode: StationMode | AccessPointMode;
|