Skip to content

Commit 023e46a

Browse files
committed
typings updates for Pebble and beyond
1 parent 255b570 commit 023e46a

10 files changed

Lines changed: 158 additions & 8 deletions

File tree

examples/manifest_typings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
"embedded:sensor/Accelerometer": "$(TYPINGS)/pebble/accelerometer",
7373
"embedded:sensor/Battery": "$(TYPINGS)/pebble/battery",
7474
"embedded:sensor/Compass": "$(TYPINGS)/pebble/compass",
75+
"embedded:sensor/Location": "$(TYPINGS)/pebble/location",
7576
"embedded:provider/builtin": "$(TYPINGS)/pebble/device",
7677
"pebble/button": "$(TYPINGS)/pebble/button",
7778
"pebble/message": "$(TYPINGS)/pebble/message"
@@ -82,6 +83,8 @@
8283
"types": [
8384
"$(TYPINGS)/pebble/global",
8485
"$(TYPINGS)/pebble/piu",
86+
"$(TYPINGS)/pebble/poco",
87+
"$(TYPINGS)/easing",
8588
"$(TYPINGS)/piu/MC-types"
8689
]
8790
}

typings/commodetto/Bitmap.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ declare module "commodetto/Bitmap" {
4545
static readonly RGB444 = 13
4646
static readonly JPEG = 14
4747
static readonly PNG = 15
48+
static readonly MonochromeAligned = 21
49+
static readonly MonochromePebble = 22
50+
static readonly MonochromeARGB2222 = 23
51+
static readonly MonochromeGray4 = 24
4852

4953
static readonly RLE = 0x80
5054
}

typings/embedded/storage/key-value.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2024-2025 Moddable Tech, Inc.
2+
* Copyright (c) 2024-2026 Moddable Tech, Inc.
33
*
44
* This file is part of the Moddable SDK Runtime.
55
*
@@ -20,6 +20,7 @@
2020

2121
declare module "embedded:storage/key-value" {
2222
export interface StorageOpenOptions {
23+
format?: StorageFormat;
2324
path: string;
2425
mode?: "r" | "r+";
2526
}

typings/embedded_network/http/client.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ declare module "embedded:network/http/client" {
3131
method?: string
3232
path?: string
3333
headers?: Map<string, string|string[]>
34-
onHeaders?: (this: HTTPRequest, status:number, headers: Map<String, string>) => void
34+
headersMask?: Array<string>
35+
onHeaders?: (this: HTTPRequest, status:number, headers: Map<string, string>, statusText: string) => void
3536
onReadable?: (this: HTTPRequest, count: number) => void
3637
onWritable?: (this: HTTPRequest, count: number) => void
3738
onDone?: (this: HTTPRequest, error: Error|null) => void // note: error is empty Error object

typings/pebble/device.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ declare module "embedded:provider/builtin" {
4343
readonly language: string,
4444
readonly serialNumber: string,
4545
}
46-
//@@ keyValue
47-
//@@ files
46+
readonly files: import("embedded:storage/files").Directory;
47+
readonly keyValue: typeof import("embedded:storage/key-value").default;
4848
}
4949

5050
export default device;

typings/pebble/global.d.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,21 @@ interface ConnectionState {
4343

4444
type TimeEventType = "secondchange" | "minutechange" | "hourchange" | "daychange";
4545

46-
type PebbleEventType = TimeEventType | "connected";
46+
type PebbleEventType = TimeEventType | "connected" | "resize";
4747

4848
type TimeChangeCallback = (event: TimeChangeEvent) => void;
4949

5050
type ConnectedCallback = () => void;
5151

52+
type ResizeCallback = (progress: number) => void;
53+
5254
interface watch {
5355
addEventListener(event: TimeEventType, callback: TimeChangeCallback): void;
5456
addEventListener(event: "connected", callback: ConnectedCallback): void;
57+
addEventListener(event: "resize", callback: ResizeCallback): void;
5558
removeEventListener(event: TimeEventType, callback: TimeChangeCallback): void;
5659
removeEventListener(event: "connected", callback: ConnectedCallback): void;
60+
removeEventListener(event: "resize", callback: ResizeCallback): void;
5761
readonly connected: ConnectionState;
5862
}
5963

@@ -96,6 +100,7 @@ declare const Container: ContainerConstructor;
96100
declare const Content: ContentConstructor;
97101
declare const Label: LabelConstructor;
98102
declare const Link: LinkConstructor;
103+
declare const Locals: Locals;
99104
declare const Port: PortConstructor;
100105
declare const Row: RowConstructor;
101106
declare const Skin: SkinConstructor;
@@ -114,3 +119,10 @@ declare const SVGImage: SVGImageConsructor;
114119
*/
115120

116121
// device is defined in typings/pebble/device.d.ts
122+
123+
declare module "embedded:storage/files" {
124+
interface DirectoryOpenFileOptions {
125+
size?: number;
126+
}
127+
}
128+

typings/pebble/location.d.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright (c) 2025-2026 Moddable Tech, Inc.
3+
*
4+
* This file is part of the Moddable SDK Tools.
5+
*
6+
* The Moddable SDK Tools is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* The Moddable SDK Tools is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with the Moddable SDK Tools. If not, see <http://www.gnu.org/licenses/>.
18+
*
19+
*/
20+
21+
interface LocationSample {
22+
latitude: number;
23+
longitude: number;
24+
altitude?: number;
25+
accuracy?: number;
26+
altitudeAccuracy?: number;
27+
heading?: number;
28+
speed?: number;
29+
timestamp?: number;
30+
}
31+
32+
interface LocationOptions {
33+
onSample?: () => void;
34+
onError?: (error: Error) => void;
35+
}
36+
37+
interface LocationConfiguration {
38+
enableHighAccuracy?: boolean;
39+
timeout?: number;
40+
maximumAge?: number;
41+
}
42+
43+
declare class Location {
44+
constructor(options: LocationOptions);
45+
close(): void;
46+
configure(options: LocationConfiguration): void;
47+
sample(): LocationSample | undefined;
48+
}
49+
50+
export default Location;

typings/pebble/poco.d.ts

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/*
2+
* Copyright (c) 2025-2026 Moddable Tech, Inc.
3+
*
4+
* This file is part of the Moddable SDK Tools.
5+
*
6+
* The Moddable SDK Tools is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* The Moddable SDK Tools is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with the Moddable SDK Tools. If not, see <http://www.gnu.org/licenses/>.
18+
*
19+
*/
20+
21+
/// <reference path="../commodetto/Poco.d.ts" />
22+
23+
24+
declare module "commodetto/Poco" {
25+
import Bitmap from "commodetto/Bitmap";
26+
27+
interface FontConstructor {
28+
new(family: string, size: number): Font;
29+
}
30+
31+
interface PocoPrototype {
32+
Font: FontConstructor;
33+
unobstructed: {
34+
readonly x: number;
35+
readonly y: number;
36+
readonly width: number;
37+
readonly height: number
38+
};
39+
drawLine(x0: number, y0: number, x1: number, y1: number, color: number, width: number): void;
40+
drawRoundRect(x0: number, y0: number, x1: number, y1: number, color: number, radius: number, corners: number): void;
41+
frameRoundRect(x0: number, y0: number, x1: number, y1: number, color: number, radius: number): void;
42+
drawCircle(color: number, x: number, y: number, r: number, from: number, to: number): void;
43+
drawDCI(dci: PebbleDrawCommandImage | PebbleDrawCommandSequence, x: number, y: number): void;
44+
}
45+
46+
class PebbleBitmap extends Bitmap {
47+
constructor(id: number | string);
48+
}
49+
50+
class PebbleDrawCommandList {
51+
scale(x: number, y: number): this;
52+
scale(scale: number): this;
53+
rotate(angle: number, cx: number, cy: number): this;
54+
}
55+
56+
class PebbleDrawCommandImage extends PebbleDrawCommandList {
57+
constructor(id: number | string);
58+
readonly width: number;
59+
readonly height: number;
60+
clone(): PebbleDrawCommandImage;
61+
}
62+
63+
class PebbleDrawCommandSequence {
64+
constructor(id: number | string);
65+
readonly width: number;
66+
readonly height: number;
67+
readonly duration: number;
68+
readonly frameDuration: number;
69+
time: number;
70+
clone(): PebbleDrawCommandSequence;
71+
}
72+
73+
interface PocoConstructor {
74+
PebbleBitmap: typeof PebbleBitmap;
75+
PebbleDrawCommandImage: typeof PebbleDrawCommandImage;
76+
PebbleDrawCommandSequence: typeof PebbleDrawCommandSequence;
77+
PebbleDrawCommandList: typeof PebbleDrawCommandList;
78+
}
79+
}

typings/web/fetch.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
declare module "web/fetch" {
2-
import {URLSearchParams} from "url"
2+
import {URL, URLSearchParams} from "url"
33
import Headers from "headers"
44

55
class Response {
@@ -21,7 +21,7 @@ declare module "web/fetch" {
2121
body?: string | ByteBuffer | URLSearchParams;
2222
}
2323

24-
function fetch(resource: string, options?: RequestInit): Promise<Response>;
24+
function fetch(resource: string | URL, options?: RequestInit): Promise<Response>;
2525

2626
export { fetch };
2727
export default fetch;

typings/web/url.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ declare module "url" {
3939
}
4040

4141
class URLSearchParams implements Iterable<[string, string]>{
42-
constructor(it?: string[][] | Record<string, string> | string)
42+
constructor(it?: string[][] | Record<string, { toString(): string }> | string)
4343
readonly length: number;
4444
append(name: string, value: string): void;
4545
delete(name: string, value?: string): void;

0 commit comments

Comments
 (0)