@moddable/typings 5.12.0 → 6.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/Resource.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  /*
2
2
  * Copyright (c) 2019-2020 Bradley Farias
3
+ * Copyright (c) 2025 Moddable Tech, Inc.
3
4
  *
4
5
  * This file is part of the Moddable SDK Tools.
5
6
  *
@@ -19,12 +20,17 @@
19
20
  */
20
21
 
21
22
  declare module "Resource" {
22
- class Resource extends HostBuffer {
23
- constructor(path: string);
23
+ interface ResourcePrototype extends HostBuffer {
24
24
  slice(begin: number, end?: number): ArrayBuffer;
25
25
  slice(begin: number, end?: number, copy?: boolean): HostBuffer;
26
- static exists(path: string): boolean;
27
26
  }
28
27
 
28
+ export interface ResourceConstructor {
29
+ new(path: string): ResourcePrototype;
30
+
31
+ exists(path: string): boolean;
32
+ }
33
+ const Resource: ResourceConstructor
34
+
29
35
  export {Resource as default};
30
36
  }
@@ -0,0 +1,53 @@
1
+ /*
2
+ * Copyright (c) 2025 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 "commodetto/BufferOut" {
22
+ import type Bitmap from "commodetto/Bitmap";
23
+ import type {Rectangle} from "commodetto/Poco";
24
+
25
+ interface BufferOutOptions {
26
+ width: number;
27
+ height: number;
28
+ pixelFormat: number;
29
+ buffer?: BufferLike;
30
+ }
31
+
32
+ class BufferOut {
33
+ constructor(options: BufferOutOptions);
34
+ begin(x: number, y: number, width: number, height: number): void;
35
+ end(): void;
36
+ continue(x: number, y: number, width: number, height: number): void;
37
+ send(
38
+ pixels: BufferLike,
39
+ offset: number,
40
+ count: number
41
+ ): void;
42
+
43
+ pixelsToBytes(count: number): number;
44
+ adaptInvalid(area: Rectangle): void;
45
+
46
+ readonly width: number;
47
+ readonly height: number;
48
+ readonly pixelFormat: number;
49
+ readonly bitmap: Bitmap;
50
+ }
51
+
52
+ export {BufferOut as default};
53
+ }
@@ -0,0 +1,29 @@
1
+ /*
2
+ * Copyright (c) 2025 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 "commodetto/Convert" {
22
+ class Convert {
23
+ constructor(srcFormat: number, dstFormat: number, clut?: BufferLike);
24
+ process(src: BufferLike, dst: BufferLike): void;
25
+ process(src: BufferLike, srcOffset: number, srcCount: number, dst: BufferLike, dstOffset: number, dstCount: number): void;
26
+ }
27
+
28
+ export {Convert as default};
29
+ }
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2019-2020 Bradley Farias
2
+ * Copyright (c) 2019-2025 Bradley Farias
3
3
  *
4
4
  * This file is part of the Moddable SDK Tools.
5
5
  *
@@ -19,8 +19,16 @@
19
19
  */
20
20
 
21
21
  declare module "commodetto/PixelsOut" {
22
+ import type {Rectangle} from "commodetto/Poco";
23
+
24
+ interface PixelsOutOptions {
25
+ width: number;
26
+ height: number;
27
+ pixelFormat: number;
28
+ }
29
+
22
30
  class PixelsOut {
23
- constructor(width: number, height: number, pixelFormat: number);
31
+ constructor(options: PixelsOutOptions);
24
32
  begin(x: number, y: number, width: number, height: number): void;
25
33
  end(): void;
26
34
  continue(x: number, y: number, width: number, height: number): void;
@@ -30,7 +38,7 @@ declare module "commodetto/PixelsOut" {
30
38
  count: number
31
39
  ): void;
32
40
 
33
- adaptInvalid(area: { x: number, y: number, width: number, height: number }): void;
41
+ adaptInvalid(area: Rectangle): void;
34
42
  pixelsToBytes(count: number): number;
35
43
  /**
36
44
  * The width of the PixelsOut instance in pixels.
@@ -49,18 +57,18 @@ declare module "commodetto/PixelsOut" {
49
57
  * Returns true if the PixelsOut supports asynchronous rendering.
50
58
  * This means pixels passed to send are not copied, and must remain unchanged through the completion of the next call to send or end.
51
59
  */
52
- readonly async: boolean;
60
+ readonly async?: boolean;
53
61
  /**
54
62
  * Optionally returns a pointer to a HostBuffer that contains a native PixelsOutDispatchRecord.
55
63
  * Returns undefined if no native dispatch table is available.
56
64
  * The native PixelsOutDispatchRecord allows native code to call the PixelsOut's begin, send, continue, end, and adaptInvalid functions directly, without going through the XS virtual machine.
57
65
  * The native dispatch table is strictly an optimization and provides only functionality in the JavaScript API.
58
66
  */
59
- readonly c_dispatch: HostBuffer | undefined;
67
+ readonly c_dispatch?: HostBuffer | undefined;
60
68
  /**
61
69
  * (Not documented yet)
62
70
  */
63
- clut: unknown;
71
+ clut?: unknown;
64
72
  }
65
73
 
66
74
  export {PixelsOut as default};
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2020 Moddable Tech, Inc.
2
+ * Copyright (c) 2020-2025 Moddable Tech, Inc.
3
3
  *
4
4
  * This file is part of the Moddable SDK Tools.
5
5
  *
@@ -23,14 +23,22 @@ declare module "commodetto/Poco" {
23
23
  import PixelsOut from "commodetto/PixelsOut"
24
24
  import Bitmap from "commodetto/Bitmap"
25
25
 
26
- type Rectangle = {
26
+ export type Rectangle = {
27
27
  x: number,
28
28
  y: number,
29
29
  width: number,
30
30
  height: number,
31
31
  }
32
32
 
33
- type Font = any //@@ share full interface with commodetto/parseBMF
33
+ export type Font = {
34
+ readonly byteLength: number
35
+ readonly height: number
36
+ readonly ascent: number
37
+ readonly position: number
38
+ readonly charCount: number,
39
+ readonly leading: number,
40
+ bitmap: Bitmap
41
+ }
34
42
 
35
43
  export interface PocoPrototype {
36
44
  close(): void
@@ -68,8 +76,6 @@ declare module "commodetto/Poco" {
68
76
  fillPattern(bits: Bitmap, x: number, y: number, w: number, h: number): void
69
77
  fillPattern(bits: Bitmap, x: number, y: number, w: number, h: number, sx: number, sy: number, sw: number, sh: number): void
70
78
 
71
- drawFrame(frame: ArrayBuffer | HostBuffer, stream: { width: number, height: number }, x: number, y: number): void
72
-
73
79
  drawText(text: string, font: Font, color: number, x: number, y: number, width?: number): void
74
80
  getTextWidth(text: string, font: Font): number
75
81
 
@@ -79,8 +85,6 @@ declare module "commodetto/Poco" {
79
85
  bitmapRemove(bits: Bitmap): void
80
86
  compact(): void
81
87
 
82
- drawQRCode(qrcode:ArrayBuffer, x: number, y: number, scale: number, fore: number)
83
-
84
88
  readonly width: number
85
89
  readonly height: number
86
90
  readonly pixelsOut: PixelsOut
@@ -96,7 +100,7 @@ declare module "commodetto/Poco" {
96
100
  new(pixelsOut: PixelsOut, options?: PocoDictionary): PocoPrototype
97
101
  }
98
102
 
99
- var Poco: PocoConstructor
103
+ const Poco: PocoConstructor
100
104
 
101
105
  global {
102
106
  const screen: PixelsOut
@@ -0,0 +1,56 @@
1
+ /*
2
+ * Copyright (c) 2025 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 "commodetto/ReadGIF" {
22
+ import Bitmap from "commodetto/Bitmap"
23
+
24
+ class ReadGIF extends Bitmap {
25
+ constructor(buffer: BufferLike);
26
+ close(): void;
27
+ first(): void;
28
+ next(): void;
29
+
30
+ readonly duration: number
31
+ readonly frameBounds: {x: number, y: number, width: number, height: number}
32
+ readonly frameCount: number
33
+ readonly frameDuration: number
34
+ readonly frameNumber: number
35
+ readonly frameX: number
36
+ readonly frameY: number
37
+ readonly frameWidth: number
38
+ readonly frameHeight: number
39
+
40
+ readonly transparent: boolean;
41
+ transparentColor: number;
42
+
43
+ readonly ready: boolean
44
+ avaiable: number
45
+ }
46
+
47
+ export {ReadGIF as default};
48
+ }
49
+
50
+ declare module "commodetto/Poco" {
51
+ import ReadGIF from "commodetto/ReadGIF"
52
+
53
+ interface PocoPrototype {
54
+ drawBitmapWithKeyColor(reader: ReadGIF, x: number, y: number): void
55
+ }
56
+ }
@@ -0,0 +1,43 @@
1
+ /*
2
+ * Copyright (c) 2025 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 "commodetto/ReadPNG" {
22
+ import Bitmap from "commodetto/Bitmap"
23
+
24
+ interface ReadPNG {
25
+ read(): Uint8Array;
26
+
27
+ readonly width: number;
28
+ readonly height: number;
29
+ readonly channels: number;
30
+ readonly depth: number;
31
+ readonly palette?: ArrayBuffer;
32
+ }
33
+
34
+ interface ReadPNGConstructor {
35
+ new(buffer: BufferLike, options?: { pixelFormat: number }): ReadPNG
36
+
37
+ decompress(data: BufferLike, pixelFormat: number, alphaPixelFormat?: number): Bitmap;
38
+ }
39
+
40
+ const ReadPNG: ReadPNGConstructor
41
+
42
+ export {ReadPNG as default};
43
+ }
@@ -0,0 +1,25 @@
1
+ /*
2
+ * Copyright (c) 2025 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 "commodetto/loadJPEG" {
22
+ import Bitmap from "commodetto/Bitmap"
23
+
24
+ export default function (data: BufferLike, options?: {pixelFormat?: number}): Bitmap;
25
+ }
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2020-2022 Moddable Tech, Inc.
2
+ * Copyright (c) 2020-2025 Moddable Tech, Inc.
3
3
  *
4
4
  * This file is part of the Moddable SDK Tools.
5
5
  *
@@ -19,16 +19,7 @@
19
19
  */
20
20
 
21
21
  declare module "commodetto/parseBMF" {
22
- import Bitmap from "commodetto/Bitmap"
22
+ import type {Font} from "commodetto/Poco"
23
23
 
24
- type Font = {
25
- readonly byteLength: number
26
- height: number
27
- ascent: number
28
- position: number
29
- charCount: number,
30
- bitmap: Bitmap
31
- }
32
-
33
24
  export default function (bmp: BufferLike): Font
34
25
  }
@@ -0,0 +1,25 @@
1
+ /*
2
+ * Copyright (c) 2025 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 "commodetto/parseNFNT" {
22
+ import type {Font} from "commodetto/Poco"
23
+
24
+ export default function (bmp: BufferLike): Font
25
+ }
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2020-2022 Moddable Tech, Inc.
2
+ * Copyright (c) 2020-2025 Moddable Tech, Inc.
3
3
  *
4
4
  * This file is part of the Moddable SDK Tools.
5
5
  *
@@ -27,7 +27,7 @@ declare module "commodetto/readJPEG" {
27
27
  }
28
28
 
29
29
  class JPEG {
30
- constructor(buffer: (BufferLike), options?: { pixelFormat: number })
30
+ constructor(buffer?: (BufferLike), options?: { pixelFormat: number })
31
31
 
32
32
  read(): Block
33
33
  push(buffer: BufferLike): void
@@ -0,0 +1,34 @@
1
+ /*
2
+ * Copyright (c) 2025 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 "commodetto/readStream" {
22
+
23
+ class Stream {
24
+ constructor(buffer: ArrayBuffer | HostBuffer, options?: {loop?: boolean});
25
+ next(): ArrayBuffer | HostBuffer
26
+
27
+ readonly width: number;
28
+ readonly height: number;
29
+ readonly pixelFormat: number;
30
+ readonly buffer: ArrayBuffer | HostBuffer;
31
+ }
32
+
33
+ export default Stream;
34
+ }
package/deflate.ts ADDED
@@ -0,0 +1,36 @@
1
+ /*
2
+ * Copyright (c) 2025 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 "deflate" {
22
+
23
+ class Deflate {
24
+ constructor(options?: {windowBits?: number, level?: number, strategy?: number});
25
+ close(): void;
26
+
27
+ push(buffer: BufferLike | string, end?: boolean): boolean;
28
+
29
+ onData: (data: ArrayBuffer) => void;
30
+ onEnd: (status: number) => void;
31
+
32
+ readonly result?: Uint8Array;
33
+ }
34
+
35
+ export {Deflate as default};
36
+ }
@@ -37,7 +37,7 @@ declare module "embedded:io/bluetoothle/central" {
37
37
  authenticate?: boolean,
38
38
  keyboard?: boolean | "yes/no",
39
39
  display?: boolean,
40
- lazy?: boolean
40
+ immediate?: boolean
41
41
  }
42
42
 
43
43
  interface GATTSecurityState {
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2022 Shinya Ishikawa
2
+ * Copyright (c) 2022-2025 Shinya Ishikawa
3
3
  *
4
4
  * This file is part of the Moddable SDK Tools.
5
5
  *
@@ -52,7 +52,7 @@ declare module "embedded:io/serial" {
52
52
  dataTerminalReady?: PinSpecifier;
53
53
  requestToSend?: PinSpecifier;
54
54
  break?: boolean;
55
- })
55
+ }): void
56
56
  get format(): "number" | "buffer"
57
57
  set format(value: "number" | "buffer")
58
58
  }
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2022 Shinya Ishikawa
2
+ * Copyright (c) 2022-2025 Shinya Ishikawa
3
3
  *
4
4
  * This file is part of the Moddable SDK Tools.
5
5
  *
@@ -33,10 +33,10 @@ declare module "embedded:io/smbus" {
33
33
  readBuffer(register: number, byteLength: number): ArrayBuffer;
34
34
  readBuffer(register: number, buffer: Buffer): void;
35
35
  writeBuffer(register: number, buffer: Buffer): void;
36
- readQuick();
37
- writeQuick();
36
+ readQuick(): void;
37
+ writeQuick(): void;
38
38
  receiveByte(): number;
39
- sendByte(command: number);
39
+ sendByte(command: number): void;
40
40
  }
41
41
 
42
42
  export default SMBus;
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2022 Shinya Ishikawa
2
+ * Copyright (c) 2022-2025 Shinya Ishikawa
3
3
  *
4
4
  * This file is part of the Moddable SDK Tools.
5
5
  *
@@ -37,7 +37,6 @@ declare module "embedded:io/socket/udp" {
37
37
  address: string;
38
38
  port: number;
39
39
  };
40
- read(buffer: Buffer);
41
40
  get format(): "buffer"
42
41
  set format(value: "buffer")
43
42
  }
package/file.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2019-2020 Bradley Farias
2
+ * Copyright (c) 2019-2025 Bradley Farias
3
3
  *
4
4
  * This file is part of the Moddable SDK Tools.
5
5
  *
@@ -56,8 +56,8 @@ declare module "file" {
56
56
  }
57
57
 
58
58
  class Directory {
59
- static create(path): void;
60
- static delete(path): void;
59
+ static create(path: string): void;
60
+ static delete(path: string): void;
61
61
  }
62
62
 
63
63
  class System {
package/inflate.d.ts ADDED
@@ -0,0 +1,37 @@
1
+ /*
2
+ * Copyright (c) 2025 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 "inflate" {
22
+
23
+ class Inflate {
24
+ constructor(options?: {windowBits?: number});
25
+ close(): void;
26
+
27
+ push(buffer: BufferLike, end?: boolean): number;
28
+
29
+ onData: (data: ArrayBuffer) => void;
30
+ onEnd: (status: number) => void;
31
+
32
+ readonly result?: Uint8Array;
33
+ readonly strm: {readonly avail_in: number}
34
+ }
35
+
36
+ export {Inflate as default};
37
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moddable/typings",
3
- "version": "5.12.0",
3
+ "version": "6.0.0",
4
4
  "main": "",
5
5
  "types": [
6
6
  "xs.d.ts",
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2020 Moddable Tech, Inc.
2
+ * Copyright (c) 2020-2025 Moddable Tech, Inc.
3
3
  *
4
4
  * This file is part of the Moddable SDK Tools.
5
5
  *
@@ -80,7 +80,7 @@ declare module 'pins/audioout' {
80
80
  stop(): void
81
81
  callback: AudioOutCallback
82
82
  callbacks: AudioOutCallback[]
83
- readonly mix: undefined
83
+ mix(): never
84
84
  }
85
85
  export { AudioOut as default }
86
86
  }
package/pins/rmt.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2021 Satoshi Tanaka
2
+ * Copyright (c) 2021-2025 Satoshi Tanaka
3
3
  *
4
4
  * This file is part of the Moddable SDK Tools.
5
5
  *
@@ -42,7 +42,7 @@ declare module 'pins/rmt' {
42
42
  public write(firstValue: 0 | 1, durations: number[]): void;
43
43
  public onWritable: () => void;
44
44
  public read(buffer: ArrayBuffer | ArrayBufferLike): {buffer: ArrayBuffer, count: number, phase: 0 | 1};
45
- public close();
45
+ public close(): void;
46
46
  }
47
47
  export { RMT as default }
48
48
  }
package/piu/MC.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2020-21 Shinya Ishikawa
2
+ * Copyright (c) 2020-2025 Shinya Ishikawa
3
3
  *
4
4
  * This file is part of the Moddable SDK Tools.
5
5
  *
@@ -19,6 +19,8 @@
19
19
  */
20
20
 
21
21
  declare module "piu/MC" {
22
+ import {} from "commodetto/Poco"; // for global screen
23
+
22
24
  /* type aliases */
23
25
  type Coordinates = {
24
26
  top?: number;
@@ -64,19 +66,29 @@ declare module "piu/MC" {
64
66
  ) => TemplateStyle<Partial<ConstructorParameters<T>[1]>, T>;
65
67
 
66
68
  type TemplateComponent<P, C extends new (...args: any) => any> = {
67
- new (dictionary: P): InstanceType<C>;
69
+ new (behaviorData?: any, dictionary?: P): InstanceType<C>;
68
70
  template: TemplateComponentFactory<C>;
69
71
  };
70
72
  type TemplateComponentFactory<T extends new (...args: any) => any> = (
71
73
  func: (param: any) => ConstructorParameters<T>[1]
72
74
  ) => TemplateComponent<Parameters<typeof func>[0], T>;
73
75
 
74
- interface Behavior {}
75
-
76
- interface BehaviorConstructor {
77
- new(any): Behavior;
76
+ interface Behavior<T extends Content = Content>{
77
+ onCreate?(content: T, data: object, context: any): void;
78
+ onDisplaying?(content: T): void;
79
+ onFinished?(content: T): void;
80
+ onTimeChanged?(content: T): void;
81
+ onTouchBegan?(content: T, id: number, x: number, y: number, ticks: number): void;
82
+ onTouchCancelled?(content: T, id: number): void;
83
+ onTouchended?( content: T, id: number, x: number, y: number, ticks: number): void;
84
+ onTouchMoved?( content: T, id: number, x: number, y: number, ticks: number): void;
85
+ // TODO: complete callbacks
78
86
  }
79
87
 
88
+ interface BehaviorConstructor<T extends Content = Content> {
89
+ new(): Behavior<T>;
90
+ }
91
+
80
92
  interface Content {
81
93
  // TODO: consider type parameter to avoid any
82
94
  adjust(x: number, y: number): void;
@@ -93,33 +105,7 @@ declare module "piu/MC" {
93
105
  sizeBy(width: number, height: number): void;
94
106
  start(): void;
95
107
  stop(): void;
96
- onCreate(content: Content, data: object, context: object): void;
97
- onDisplaying(content: Content): void;
98
- onFinished(content: Content): void;
99
- onTimeChanged(content: Content): void;
100
- onTouchBegan(
101
- content: Content,
102
- id: string,
103
- x: number,
104
- y: number,
105
- ticks: number
106
- ): void;
107
- onTouchCancelled(content: Content, id: string): void;
108
- onTouchended(
109
- content: Content,
110
- id: string,
111
- x: number,
112
- y: number,
113
- ticks: number
114
- ): void;
115
- onTouchMoved(
116
- content: Content,
117
- id: string,
118
- x: number,
119
- y: number,
120
- ticks: number
121
- ): void;
122
- // TODO: Avoid any
108
+
123
109
  readonly previous: Content | null;
124
110
  readonly next: Content | null;
125
111
  readonly container: Container | null;
@@ -164,17 +150,16 @@ declare module "piu/MC" {
164
150
  Behavior?: BehaviorConstructor;
165
151
  skin?: Skin | SkinDictionary;
166
152
  Skin?: SkinConstructor;
167
- style?: Style;
153
+ style?: Style | StyleDictionary;
168
154
  Style?: StyleConstructor;
169
155
  visible?: boolean;
170
156
  }
171
157
  interface ContentConstructor {
172
- new(behaviorData: any, dictionary: ContentDictionary): Content;
173
- (behaviorData: any, dictionary: ContentDictionary): Content;
158
+ new(behaviorData?: any, dictionary?: ContentDictionary): Content;
159
+ (behaviorData?: any, dictionary?: ContentDictionary): Content;
174
160
  readonly prototype: Content;
175
161
 
176
162
  template: TemplateComponentFactory<typeof Content>;
177
- getAll<T>(this: { new (): T }): T[];
178
163
  }
179
164
 
180
165
  interface Style {
@@ -189,7 +174,7 @@ declare module "piu/MC" {
189
174
  interface StyleConstructor {
190
175
  new(dictionary: StyleDictionary): Style;
191
176
 
192
- template<T>(this: T, any): T;
177
+ template<T>(this: T, dictionary: StyleDictionary): T;
193
178
  }
194
179
 
195
180
  interface TextStyleDictionary extends StyleDictionaryBase {
@@ -243,7 +228,7 @@ declare module "piu/MC" {
243
228
  }
244
229
 
245
230
  interface TextureSkinDictionary extends Coordinates, Bounds {
246
- texture?: Texture;
231
+ texture?: Texture | TextureDictionary;
247
232
  Texture?: TextureConstructor;
248
233
  color?: Color | Color[];
249
234
  states?: number;
@@ -291,9 +276,10 @@ declare module "piu/MC" {
291
276
  contents?: Content[];
292
277
  }
293
278
  interface ContainerConstructor {
294
- new(behaviorData: any, dictionary?: ContainerDictionary);
279
+ new(behaviorData?: any, dictionary?: ContainerDictionary): Container;
280
+ (behaviorData?: any, dictionary?: ContainerDictionary): Container;
295
281
 
296
- template<T>(this: T, any): T;
282
+ template<T>(this: T, fn: (arg: any) => ContainerDictionary): T;
297
283
  }
298
284
 
299
285
  interface Label extends Content {
@@ -303,9 +289,10 @@ declare module "piu/MC" {
303
289
  string?: string;
304
290
  }
305
291
  interface LabelConstructor {
306
- new(behaviorData: any, dictionary: LabelDictionary): Label;
292
+ new(behaviorData?: any, dictionary?: LabelDictionary): Label;
293
+ (behaviorData?: any, dictionary?: LabelDictionary): Label;
307
294
 
308
- template<T>(this: T, any): T;
295
+ template<T>(this: T, fn: (arg: any) => LabelDictionary): T;
309
296
  }
310
297
 
311
298
  interface Port extends Content {
@@ -404,12 +391,18 @@ declare module "piu/MC" {
404
391
  interface PortConstructor extends ContentConstructor {
405
392
  }
406
393
 
394
+ interface TextBlock {
395
+ behavior?: object | null;
396
+ style?: Style | null;
397
+ spans: (string | TextSpan)[] | string,
398
+ }
399
+
400
+ interface TextSpan extends TextBlock {
401
+ link?: any
402
+ }
403
+
407
404
  interface Text extends Content {
408
- blocks: {
409
- behavior: object | null;
410
- style: Style | null;
411
- spans: string | string[];
412
- }[];
405
+ blocks: TextBlock[],
413
406
  string: string;
414
407
  begin(): void;
415
408
  beginBlock(style?: Style, behavior?: object): void;
@@ -420,17 +413,14 @@ declare module "piu/MC" {
420
413
  endSpan(): void;
421
414
  }
422
415
  interface TextDictionary extends ContentDictionary {
423
- blocks?: {
424
- behavior?: Behavior;
425
- style?: Style;
426
- spans: string | string[];
427
- }[];
428
- string: string;
416
+ blocks?: TextBlock[],
417
+ string?: string;
429
418
  }
430
- interface TextConstructor extends ContentConstructor {
431
- new(behaviorData: any, dictionary: TextDictionary): Text;
419
+ interface TextConstructor {
420
+ new(behaviorData?: any, dictionary?: TextDictionary): Text;
421
+ (behaviorData?: any, dictionary?: TextDictionary): Text;
432
422
 
433
- template<T>(this: T, any): T;
423
+ template<T>(this: T, fn: (arg: any) => TextDictionary): T;
434
424
  }
435
425
 
436
426
  interface Application extends Container {
@@ -445,9 +435,9 @@ declare module "piu/MC" {
445
435
  pixels?: number;
446
436
  }
447
437
  interface ApplicationConstructor {
448
- new(behaviorData: any, dictionary: ApplicationDictionary): Application;
438
+ new(behaviorData?: any, dictionary?: ApplicationDictionary): Application;
449
439
 
450
- template<T>(this: T, any): T;
440
+ template<T>(this: T, fn: (arg: any) => ApplicationDictionary): T;
451
441
  }
452
442
 
453
443
  interface Column extends Container {
@@ -471,10 +461,11 @@ declare module "piu/MC" {
471
461
  interface ImageDictionary extends ContentDictionary {
472
462
  path: string;
473
463
  }
474
- interface ImageConstructor extends ContentConstructor {
475
- new(behaviorData: any, dictionary: ImageDictionary): Image;
464
+ interface ImageConstructor {
465
+ new(behaviorData?: any, dictionary?: ImageDictionary): Image;
466
+ (behaviorData?: any, dictionary?: ImageDictionary): Image;
476
467
 
477
- template<T>(this: T, any): T;
468
+ template<T>(this: T, fn: (arg: any) => ImageDictionary): T;
478
469
  }
479
470
 
480
471
  interface Die extends Layout {
@@ -510,10 +501,43 @@ declare module "piu/MC" {
510
501
  interface ScrollerDictionary extends ContainerDictionary {
511
502
  loop?: boolean;
512
503
  }
513
- interface ScrollerConstructor extends ContainerConstructor {
514
- new(behaviorData: any, dictionary: ScrollerDictionary): Scroller;
504
+ interface ScrollerConstructor {
505
+ new(behaviorData?: any, dictionary?: ScrollerDictionary): Scroller;
506
+ (behaviorData?: any, dictionary?: ScrollerDictionary): Scroller;
507
+
508
+ template<T>(this: T, fn: (arg: any) => ScrollerDictionary): T;
509
+ }
510
+
511
+ interface LinkDictionary {
512
+ Behavior?: BehaviorConstructor;
513
+ }
514
+ interface Link {
515
+ readonly container: Container;
516
+ state: number;
517
+ captureTouch(id: number, x: number, y: number, ticks: number): void;
518
+ }
519
+ interface LinkConstructor {
520
+ new(behaviorData?: any, dictionary?: LinkDictionary): Link;
521
+ (behaviorData?: any, dictionary?: LinkDictionary): Link;
522
+
523
+ template<T>(this: T, fn: (arg: any) => LinkDictionary): T;
524
+ }
525
+
526
+ interface Locals {
527
+ new(name?: string, language?: string): Locals
528
+ language: string;
529
+ get(textToLocalize: string): string
515
530
  }
516
531
 
532
+ interface blendColors {
533
+ (a: number, c1: number, c2: number): Color
534
+ }
535
+ interface hsl {
536
+ (h: number, s: number, l: number): Color
537
+ }
538
+ interface hsla {
539
+ (h: number, s: number, l: number, a: number): Color
540
+ }
517
541
  interface rgb {
518
542
  (r: number, g: number, b: number): Color
519
543
  }
@@ -534,11 +558,18 @@ declare module "piu/MC" {
534
558
  const Row: RowConstructor
535
559
  const Column: ColumnConstructor
536
560
  const Layout: LayoutConstructor
561
+ const Image: ImageConstructor
537
562
  const Die: DieConstructor
538
563
  const Port: PortConstructor
539
564
  const Label: LabelConstructor
540
565
  const Transition: TransitionConstructor
541
566
  const Text: TextConstructor
567
+ const Link: LinkConstructor
568
+ const application: Application
569
+ const Locals: Locals
570
+ const blendColors: blendColors
571
+ const hsl: hsl
572
+ const hsla: hsla
542
573
  const rgb: rgb
543
574
  const rgba: rgba
544
575
  }
@@ -0,0 +1,42 @@
1
+ /*
2
+ * Copyright (c) 2025 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/QRCode" {
23
+ import { Content, ContentDictionary } from "piu/MC";
24
+
25
+ interface QRCode extends Content {
26
+ string: string
27
+ }
28
+ interface QRCodeDictionary extends ContentDictionary {
29
+ string?: string,
30
+ maxVersion?: number,
31
+ }
32
+ interface QRCodeConstructor {
33
+ new(behaviorData?: any, dictionary?: QRCodeDictionary): QRCode;
34
+ (behaviorData?: any, dictionary?: QRCodeDictionary): QRCode;
35
+
36
+ template<T>(this: T, fn: (arg: any) => QRCodeDictionary): T;
37
+ }
38
+
39
+ global {
40
+ const QRCode: QRCodeConstructor
41
+ }
42
+ }
package/piu/Timeline.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2020-2021 Shinya Ishikawa
2
+ * Copyright (c) 2020-2025 Shinya Ishikawa
3
3
  *
4
4
  * This file is part of the Moddable SDK Tools.
5
5
  *
@@ -27,14 +27,14 @@ declare module "piu/Timeline" {
27
27
  target: object,
28
28
  fromProperties: object,
29
29
  duration: number,
30
- easing?: string,
30
+ easing?: (fraction: number) => number,
31
31
  delay?: number
32
32
  ): Timeline;
33
33
  on(
34
34
  target: object,
35
35
  onProperties: object,
36
36
  duration: number,
37
- easing?: number,
37
+ easing?: (fraction: number) => number,
38
38
  delay?: number
39
39
  ): Timeline;
40
40
  seekTo(time: number): void;
@@ -42,7 +42,7 @@ declare module "piu/Timeline" {
42
42
  target: object,
43
43
  fromProperties: object,
44
44
  duration: number,
45
- easing?: string,
45
+ easing?: (fraction: number) => number,
46
46
  delay?: number
47
47
  ): Timeline;
48
48
  }
package/piu/shape.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2022 Moddable Tech, Inc
2
+ * Copyright (c) 2022-2025 Moddable Tech, Inc
3
3
  *
4
4
  * This file is part of the Moddable SDK Tools.
5
5
  *
@@ -31,10 +31,10 @@ declare module "piu/shape" {
31
31
  string?: string;
32
32
  }
33
33
  interface ShapeConstructor {
34
- new (behaviorData: any, dictionary: ShapeDictionary): Shape;
35
- (behaviorData: any, dictionary: ShapeDictionary): Shape;
34
+ new(behaviorData?: any, dictionary?: ShapeDictionary): Shape;
35
+ (behaviorData?: any, dictionary?: ShapeDictionary): Shape;
36
36
 
37
- template<T>(this: T, any): T;
37
+ template<T>(this: T, fn: (arg: object) => ShapeDictionary): T;
38
38
  }
39
39
 
40
40
  global {
package/socket.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2019-2020 Bradley Farias
2
+ * Copyright (c) 2019-2025 Bradley Farias
3
3
  *
4
4
  * This file is part of the Moddable SDK Tools.
5
5
  *
@@ -67,15 +67,15 @@ declare module "socket" {
67
67
  callback: (message: MessageStatus, value?: number) => void;
68
68
  }
69
69
  class RawSocket extends SocketBase {
70
- write(ip: string, data: ArrayBuffer);
70
+ write(ip: string, data: ArrayBuffer): void;
71
71
  write(): number;
72
72
  }
73
73
  class TCPSocket extends SocketBase {
74
- write(data: WriteData, ...moreData: WriteData[]);
74
+ write(data: WriteData, ...moreData: WriteData[]): void;
75
75
  write(): number;
76
76
  }
77
77
  class UDPSocket extends SocketBase {
78
- write(ip: string, port: number, data: ArrayBuffer);
78
+ write(ip: string, port: number, data: ArrayBuffer): void;
79
79
  write(): number;
80
80
  }
81
81
  export type ListenerOptions = {
package/text/decoder.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2022 Satoshi Tanaka
2
+ * Copyright (c) 2022-2025 Satoshi Tanaka
3
3
  *
4
4
  * This file is part of the Moddable SDK Tools.
5
5
  *
@@ -31,7 +31,7 @@ declare module "text/decoder" {
31
31
  decode(input?: Uint8Array | ArrayBufferLike, options?: TextDecodeOptions): string;
32
32
  }
33
33
 
34
- var TextDecoder: {
34
+ const TextDecoder: {
35
35
  prototype: TextDecoder;
36
36
  new(label?: "utf-8", options?: TextDecoderOptions): TextDecoder;
37
37
  };
package/text/encoder.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2022 Satoshi Tanaka
2
+ * Copyright (c) 2022-2025 Satoshi Tanaka
3
3
  *
4
4
  * This file is part of the Moddable SDK Tools.
5
5
  *
@@ -29,7 +29,7 @@ declare module "text/encoder" {
29
29
  encodeInto(source: string, destination: Uint8Array): TextEncoderEncodeIntoResult;
30
30
  }
31
31
 
32
- var TextEncoder: {
32
+ const TextEncoder: {
33
33
  prototype: TextEncoder;
34
34
  new(): TextEncoder;
35
35
  };
package/websocket.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2019-2020 Bradley Farias
2
+ * Copyright (c) 2019-2025 Bradley Farias
3
3
  *
4
4
  * This file is part of the Moddable SDK Tools.
5
5
  *
@@ -36,7 +36,7 @@ declare module "websocket" {
36
36
 
37
37
  constructor(options: WebSocketClientOptions);
38
38
  close(): void;
39
- write(data: string | ArrayBuffer);
39
+ write(data: string | ArrayBuffer): void;
40
40
  callback: WebSocketClientCallback;
41
41
  }
42
42
 
package/xs.d.ts CHANGED
@@ -58,7 +58,7 @@ interface StringConstructor {
58
58
 
59
59
  interface ArrayBufferConstructor {
60
60
  fromString(string: string): ArrayBuffer;
61
- fromBigInt(value: BigInt): ArrayBuffer;
61
+ fromBigInt(value: bigint): ArrayBuffer;
62
62
  }
63
63
 
64
64
  interface ArrayBuffer {
@@ -82,8 +82,8 @@ interface Uint8ArrayConstructor {
82
82
  }
83
83
 
84
84
  interface BigIntConstructor {
85
- bitLength(value: BigInt): number
86
- fromArrayBuffer(buffer: ArrayBufferLike): BigInt
85
+ bitLength(value: bigint): number
86
+ fromArrayBuffer(buffer: ArrayBufferLike): bigint
87
87
  }
88
88
 
89
89
  // integer math proposal
@@ -96,4 +96,8 @@ interface Math {
96
96
  mod(a: number, b: number): number
97
97
  }
98
98
 
99
+ // xs host objects, host functions
100
+ declare function Native(name: string): new (...args: any[]) => any;
101
+ declare function native(name: string): (...args: any[]) => any;
102
+
99
103
  // Compartment?