@moddable/typings 9.5.0 → 10.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DS18X20.d.ts +40 -0
- package/{embedded_io/system.d.ts → ResourceIterator.d.ts} +4 -9
- package/ble/bleclient.d.ts +1 -0
- package/ble/bleserver.d.ts +1 -0
- package/ble/btutils.d.ts +3 -0
- package/ble/connection.d.ts +1 -0
- package/ble/gap.d.ts +2 -0
- package/ble/gatt.d.ts +4 -0
- package/ble/hidclient.d.ts +5 -0
- package/ble/sm.d.ts +3 -0
- package/captiveportal.d.ts +5 -5
- package/commodetto/Poco.d.ts +10 -2
- package/commodetto/ReadGIF.d.ts +1 -1
- package/commodetto/outline.d.ts +4 -1
- package/commodetto/parseRLE.d.ts +1 -1
- package/commodetto/readJPEG.d.ts +1 -1
- package/config/analog.d.ts +31 -0
- package/config/digital.d.ts +32 -0
- package/config/dns.d.ts +33 -0
- package/config/dnssd.d.ts +31 -0
- package/config/files.d.ts +27 -0
- package/config/flash.d.ts +27 -0
- package/config/httpclient.d.ts +34 -0
- package/config/httpsclient.d.ts +34 -0
- package/config/httpserver.d.ts +33 -0
- package/config/i2c.d.ts +33 -0
- package/config/mqtt.d.ts +27 -0
- package/config/mqttclient.d.ts +31 -0
- package/config/mqttsclient.d.ts +32 -0
- package/config/ntp.d.ts +34 -0
- package/config/pulsecount.d.ts +30 -0
- package/config/pwm.d.ts +30 -0
- package/config/serial.d.ts +31 -0
- package/config/socket.d.ts +34 -0
- package/config/spi.d.ts +31 -0
- package/config/storage.d.ts +27 -0
- package/config/system.d.ts +27 -0
- package/config/tls.d.ts +30 -0
- package/config/update.d.ts +27 -0
- package/config/wsclient.d.ts +31 -0
- package/config/wssclient.d.ts +32 -0
- package/crc.d.ts +1 -1
- package/dns/server.d.ts +1 -0
- package/embedded/RTC/zephyr-builtin.d.ts +48 -0
- package/embedded/RTC.d.ts +18 -7
- package/embedded/display.d.ts +8 -3
- package/embedded/storage/files.d.ts +10 -7
- package/embedded/storage/flash.d.ts +2 -2
- package/embedded/storage/key-value.d.ts +27 -6
- package/embedded/system.d.ts +49 -0
- package/embedded_io/_common.d.ts +42 -3
- package/embedded_io/analog.d.ts +7 -7
- package/embedded_io/audio/in.d.ts +3 -2
- package/embedded_io/audio/out.d.ts +12 -4
- package/embedded_io/ble/central.d.ts +5 -4
- package/embedded_io/ble/peripheral.d.ts +6 -5
- package/embedded_io/crypt/digest.d.ts +2 -2
- package/embedded_io/digital.d.ts +4 -3
- package/embedded_io/digitalbank.d.ts +9 -5
- package/embedded_io/i2c.d.ts +9 -6
- package/embedded_io/image/in/camera.d.ts +82 -0
- package/embedded_io/pulsecount.d.ts +7 -5
- package/embedded_io/pwm.d.ts +11 -5
- package/embedded_io/serial.d.ts +33 -16
- package/embedded_io/socket/listener.d.ts +3 -2
- package/embedded_io/socket/tcp/tls.d.ts +41 -12
- package/embedded_io/socket/tcp.d.ts +26 -12
- package/embedded_io/socket/udp.d.ts +17 -12
- package/embedded_io/spi.d.ts +8 -6
- package/embedded_network/dns/resolver/udp.d.ts +13 -6
- package/embedded_network/dns/server/udp.d.ts +39 -0
- package/embedded_network/dnssd.d.ts +9 -7
- package/embedded_network/http/client.d.ts +21 -7
- package/embedded_network/http/server/route/serversentevents.d.ts +48 -0
- package/embedded_network/http/server/route/static.d.ts +41 -0
- package/embedded_network/http/server/route/webdav.d.ts +42 -0
- package/embedded_network/http/server/route/ws/handshake.d.ts +28 -0
- package/embedded_network/http/server.d.ts +27 -6
- package/embedded_network/interface/ethernet.d.ts +3 -3
- package/embedded_network/interface/wifi/accesspoint.d.ts +2 -2
- package/embedded_network/interface/wifi.d.ts +21 -12
- package/embedded_network/mdns.d.ts +2 -2
- package/embedded_network/mqtt/client.d.ts +55 -16
- package/embedded_network/ntp/client.d.ts +16 -8
- package/embedded_network/websocket/client.d.ts +47 -28
- package/embedded_provider/builtin.d.ts +40 -34
- package/file.d.ts +4 -0
- package/flash.d.ts +1 -0
- package/global.d.ts +0 -3
- package/host/default.d.ts +31 -0
- package/host/esp32/moddable_six.d.ts +50 -0
- package/host/esp32/moddable_two.d.ts +55 -0
- package/host/generic.d.ts +47 -0
- package/host/index.d.ts +24 -0
- package/host/lin.d.ts +30 -0
- package/host/mac.d.ts +30 -0
- package/host/pebble.d.ts +70 -0
- package/host/win.d.ts +30 -0
- package/http.d.ts +2 -0
- package/mcpack.d.ts +20 -0
- package/mdns.d.ts +1 -0
- package/modules.d.ts +1 -1
- package/mqtt/js.d.ts +22 -4
- package/neopixel.d.ts +2 -2
- package/onewire.d.ts +31 -0
- package/package.json +14 -4
- package/pebble/accelerometer.d.ts +5 -5
- package/pebble/battery.d.ts +3 -3
- package/pebble/button.d.ts +2 -2
- package/pebble/compass.d.ts +3 -3
- package/pebble/dictation.d.ts +2 -2
- package/pebble/global.d.ts +37 -3
- package/pebble/health.d.ts +2 -2
- package/pebble/location.d.ts +2 -2
- package/pebble/message.d.ts +5 -5
- package/pebble/piu.d.ts +2 -57
- package/pebble/poco.d.ts +2 -2
- package/pebble/texture.d.ts +33 -0
- package/pebble/touch.d.ts +47 -0
- package/ping.d.ts +1 -0
- package/pins/analog.d.ts +1 -0
- package/pins/audioin.d.ts +1 -0
- package/pins/digital.d.ts +1 -0
- package/pins/i2c.d.ts +1 -0
- package/pins/pwm.d.ts +1 -0
- package/pins/rmt.d.ts +1 -0
- package/pins/servo.d.ts +1 -0
- package/pins/smbus.d.ts +1 -0
- package/piu/MC-types.d.ts +231 -97
- package/piu/MC.d.ts +2 -1
- package/piu/QRCode.d.ts +5 -0
- package/piu/RoundRect.d.ts +53 -0
- package/piu/SVGImage.d.ts +62 -0
- package/piu/Timeline.d.ts +17 -21
- package/pococolorcell.d.ts +25 -0
- package/pocoqrcode.d.ts +25 -0
- package/pocostatic.d.ts +25 -0
- package/preference.d.ts +1 -0
- package/securesocket.d.ts +1 -0
- package/sntp.d.ts +1 -0
- package/socket.d.ts +6 -0
- package/ssl/session.d.ts +60 -0
- package/time.d.ts +1 -1
- package/tsconfig.es2024.json +0 -1
- package/tsconfig.es2025.json +1 -1
- package/web/bluetooth.d.ts +112 -0
- package/web/decompressionstream.d.ts +1 -1
- package/web/eventsource.d.ts +12 -7
- package/web/fetch-streams.d.ts +57 -0
- package/web/fetch.d.ts +1 -1
- package/web/serial.d.ts +58 -0
- package/web/websocket.d.ts +18 -13
- package/web/webstorage.d.ts +3 -0
- package/web/worker.d.ts +2 -0
- package/websocket.d.ts +2 -0
- package/wifi.d.ts +1 -0
- package/xs.d.ts +52 -5
- package/data/location/nmea.d.ts +0 -103
- package/data/location/ubx.d.ts +0 -78
- package/display.d.ts +0 -68
- package/embedded/sensor/Barometer-Humidity-Temperature/BME280.d.ts +0 -102
- package/embedded/sensor/Location/GPS.d.ts +0 -96
- package/embedded/sensor/Location/IP.d.ts +0 -67
- package/pebble/device.d.ts +0 -51
package/piu/MC-types.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* Copyright (c) 2020-2025 Shinya Ishikawa
|
|
3
|
+
* Copyright (c) 2026 Moddable Tech, Inc.
|
|
3
4
|
*
|
|
4
5
|
* This file is part of the Moddable SDK Tools.
|
|
5
6
|
*
|
|
@@ -56,6 +57,7 @@ export type TouchProperty = {
|
|
|
56
57
|
// TODO: more accurate constructor parameters
|
|
57
58
|
export type TemplateStyle<P, C extends new (...args: any) => any> = {
|
|
58
59
|
new (dictionary?: P): InstanceType<C>;
|
|
60
|
+
(): InstanceType<C>;
|
|
59
61
|
template: TemplateStyleFactory<C>;
|
|
60
62
|
};
|
|
61
63
|
export type TemplateStyleFactory<T extends new (...args: any) => any> = (
|
|
@@ -64,14 +66,54 @@ export type TemplateStyleFactory<T extends new (...args: any) => any> = (
|
|
|
64
66
|
|
|
65
67
|
export type TemplateComponent<P, C extends new (...args: any) => any> = {
|
|
66
68
|
new (behaviorData?: any, dictionary?: P): InstanceType<C>;
|
|
69
|
+
(behaviorData?: any, dictionary?: P): InstanceType<C>;
|
|
67
70
|
template: TemplateComponentFactory<C>;
|
|
68
71
|
};
|
|
69
72
|
export type TemplateComponentFactory<T extends new (...args: any) => any> = (
|
|
70
73
|
func: (param: any) => ConstructorParameters<T>[1]
|
|
71
74
|
) => TemplateComponent<Parameters<typeof func>[0], T>;
|
|
72
75
|
|
|
76
|
+
/*
|
|
77
|
+
Templates
|
|
78
|
+
|
|
79
|
+
Content.template, Container.template, ... return a constructor that may be called
|
|
80
|
+
with or without new.
|
|
81
|
+
|
|
82
|
+
The instantiating data is untyped unless its type is given explicitly:
|
|
83
|
+
|
|
84
|
+
const Item = Container.template<ItemData>($ => ({ ... }));
|
|
85
|
+
|
|
86
|
+
Then $ has that type in the function, and the data is checked where Item is instantiated.
|
|
87
|
+
It may be omitted there only when its type allows undefined.
|
|
88
|
+
*/
|
|
89
|
+
export type TemplateArguments<D, $> = undefined extends $ ? [behaviorData?: $, dictionary?: D] : [behaviorData: $, dictionary?: D];
|
|
90
|
+
export interface Template<C, D, $ = any> {
|
|
91
|
+
new(...args: TemplateArguments<D, $>): C;
|
|
92
|
+
(...args: TemplateArguments<D, $>): C;
|
|
93
|
+
readonly prototype: C;
|
|
94
|
+
|
|
95
|
+
template<$2 = $>(fn: (this: C, data: NoInfer<$2>, dictionary?: D) => D): Template<C, D, $2>;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/*
|
|
99
|
+
Skin.template, Style.template, and Texture.template return a function that creates
|
|
100
|
+
the asset on first use. It is the value of the Skin, Style, and Texture properties
|
|
101
|
+
of dictionaries.
|
|
102
|
+
*/
|
|
103
|
+
export type AssetTemplate<T> = {
|
|
104
|
+
new(): T;
|
|
105
|
+
(): T;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
/*
|
|
109
|
+
Behavior
|
|
110
|
+
|
|
111
|
+
The events Piu triggers are declared here. A behavior may implement any other
|
|
112
|
+
method to receive events triggered by bubble, defer, delegate, distribute,
|
|
113
|
+
firstThat, and lastThat.
|
|
114
|
+
*/
|
|
73
115
|
export interface Behavior<T extends Content = Content> {
|
|
74
|
-
onCreate?(content: T, data:
|
|
116
|
+
onCreate?(content: T, data: any, context: any): void;
|
|
75
117
|
onDisplaying?(content: T): void;
|
|
76
118
|
onFinished?(content: T): void;
|
|
77
119
|
onTimeChanged?(content: T): void;
|
|
@@ -79,40 +121,79 @@ export interface Behavior<T extends Content = Content> {
|
|
|
79
121
|
onTouchCancelled?(content: T, id: number): void;
|
|
80
122
|
onTouchEnded?(content: T, id: number, x: number, y: number, ticks: number): void;
|
|
81
123
|
onTouchMoved?(content: T, id: number, x: number, y: number, ticks: number): void;
|
|
82
|
-
|
|
124
|
+
/*
|
|
125
|
+
The events below were added after these typings were first published. They are declared
|
|
126
|
+
loosely so that a behavior which already has a method of the same name, with whatever
|
|
127
|
+
parameters, still type-checks. Piu calls them as:
|
|
128
|
+
|
|
129
|
+
onDraw(port, x, y, width, height)
|
|
130
|
+
onFitHorizontally(layout, width), onFitVertically(layout, height) layouts
|
|
131
|
+
onMeasureHorizontally(content, width), onMeasureVertically(content, height) layouts and ports
|
|
132
|
+
onScrolled(content) on a scroller and on each of its contents, each with its own content
|
|
133
|
+
onTransitionBeginning(container), onTransitionEnded(container)
|
|
134
|
+
onAdapt(layout)
|
|
135
|
+
onFocused(application), onUnfocused(application)
|
|
136
|
+
onKeyDown(application, key), onKeyUp(application, key)
|
|
137
|
+
onMessage(application, message), onQuit(application)
|
|
138
|
+
*/
|
|
139
|
+
onDraw?(...args: any[]): any;
|
|
140
|
+
onFitHorizontally?(...args: any[]): any;
|
|
141
|
+
onFitVertically?(...args: any[]): any;
|
|
142
|
+
onMeasureHorizontally?(...args: any[]): any;
|
|
143
|
+
onMeasureVertically?(...args: any[]): any;
|
|
144
|
+
onScrolled?(...args: any[]): any;
|
|
145
|
+
onTransitionBeginning?(...args: any[]): any;
|
|
146
|
+
onTransitionEnded?(...args: any[]): any;
|
|
147
|
+
onAdapt?(...args: any[]): any;
|
|
148
|
+
onFocused?(...args: any[]): any;
|
|
149
|
+
onUnfocused?(...args: any[]): any;
|
|
150
|
+
onKeyDown?(...args: any[]): any;
|
|
151
|
+
onKeyUp?(...args: any[]): any;
|
|
152
|
+
onMessage?(...args: any[]): any;
|
|
153
|
+
onQuit?(...args: any[]): any;
|
|
83
154
|
}
|
|
84
|
-
|
|
85
155
|
export interface BehaviorConstructor<T extends Content = Content> {
|
|
86
156
|
new(): Behavior<T>;
|
|
87
157
|
}
|
|
158
|
+
// the type of the Behavior global: class X extends Behavior, or class X extends Behavior<Label>
|
|
159
|
+
export interface BehaviorClass {
|
|
160
|
+
new<C extends Content = Content>(): Behavior<C>;
|
|
161
|
+
readonly prototype: Behavior<any>;
|
|
162
|
+
}
|
|
88
163
|
|
|
89
164
|
export interface Content {
|
|
90
165
|
// TODO: consider type parameter to avoid any
|
|
91
166
|
adjust(x: number, y: number): void;
|
|
92
|
-
bubble(id: string, ...extras: any[]):
|
|
93
|
-
captureTouch(id: string, x: number, y: number, ticks: number): void;
|
|
167
|
+
bubble(id: string, ...extras: any[]): any;
|
|
168
|
+
captureTouch(id: number | string, x: number, y: number, ticks: number): void;
|
|
94
169
|
defer(id: string, ...extras: any[]): void;
|
|
95
|
-
delegate(id: string, ...extras: any[]):
|
|
170
|
+
delegate(id: string, ...extras: any[]): any;
|
|
96
171
|
distribute(id: string, ...extras: any[]): void;
|
|
97
172
|
focus(): void;
|
|
98
173
|
hit(x: number, y: number): Content | undefined;
|
|
99
|
-
measure(): Size
|
|
174
|
+
measure(): Required<Size>;
|
|
100
175
|
moveBy(x: number, y: number): void;
|
|
101
176
|
render(): void;
|
|
102
177
|
sizeBy(width: number, height: number): void;
|
|
103
178
|
start(): void;
|
|
104
179
|
stop(): void;
|
|
105
180
|
|
|
106
|
-
readonly previous: Content |
|
|
107
|
-
readonly next: Content |
|
|
108
|
-
readonly container: Container |
|
|
181
|
+
readonly previous: Content | undefined;
|
|
182
|
+
readonly next: Content | undefined;
|
|
183
|
+
readonly container: Container | undefined;
|
|
184
|
+
readonly application: Application | undefined;
|
|
109
185
|
readonly index: number;
|
|
186
|
+
readonly running: boolean;
|
|
187
|
+
readonly type: string;
|
|
110
188
|
name: string;
|
|
111
189
|
active: boolean;
|
|
190
|
+
/** @deprecated anchor is a property of dictionaries, not of contents */
|
|
112
191
|
anchor: string;
|
|
113
|
-
behavior: object;
|
|
114
|
-
|
|
115
|
-
|
|
192
|
+
get behavior(): object | undefined;
|
|
193
|
+
set behavior(it: object | null | undefined);
|
|
194
|
+
coordinates: Coordinates & Size;
|
|
195
|
+
get bounds(): Required<Bounds>;
|
|
196
|
+
set bounds(it: Bounds);
|
|
116
197
|
backgroundTouch: boolean;
|
|
117
198
|
exclusiveTouch: boolean;
|
|
118
199
|
multipleTouch: boolean;
|
|
@@ -122,14 +203,18 @@ export interface Content {
|
|
|
122
203
|
fraction: number;
|
|
123
204
|
interval: number;
|
|
124
205
|
loop: boolean;
|
|
125
|
-
|
|
126
|
-
offset: undefined | Position;
|
|
127
|
-
position: undefined | Position
|
|
128
|
-
|
|
206
|
+
get offset(): undefined | Required<Position>;
|
|
207
|
+
set offset(it: undefined | Position);
|
|
208
|
+
get position(): undefined | Required<Position>;
|
|
209
|
+
set position(it: undefined | Position);
|
|
210
|
+
get size(): Required<Size>;
|
|
211
|
+
set size(it: Size);
|
|
129
212
|
state: number;
|
|
130
213
|
variant: number;
|
|
131
|
-
skin: Skin |
|
|
132
|
-
|
|
214
|
+
get skin(): Skin | undefined;
|
|
215
|
+
set skin(it: Skin | null | undefined);
|
|
216
|
+
get style(): Style | undefined;
|
|
217
|
+
set style(it: Style | null | undefined);
|
|
133
218
|
visible: boolean;
|
|
134
219
|
x: number;
|
|
135
220
|
y: number;
|
|
@@ -143,36 +228,55 @@ export interface ContentDictionary
|
|
|
143
228
|
TimeProperty,
|
|
144
229
|
TouchProperty {
|
|
145
230
|
name?: string;
|
|
146
|
-
anchor?:
|
|
147
|
-
Behavior?:
|
|
148
|
-
behavior?:
|
|
231
|
+
anchor?: PropertyKey;
|
|
232
|
+
Behavior?: new () => object;
|
|
233
|
+
behavior?: object;
|
|
149
234
|
skin?: Skin | SkinDictionary;
|
|
150
|
-
Skin?: SkinConstructor
|
|
235
|
+
Skin?: SkinConstructor | AssetTemplate<Skin>;
|
|
151
236
|
style?: Style | StyleDictionary;
|
|
152
|
-
Style?: StyleConstructor
|
|
237
|
+
Style?: StyleConstructor | AssetTemplate<Style>;
|
|
153
238
|
visible?: boolean;
|
|
154
239
|
}
|
|
155
|
-
export interface ContentConstructor {
|
|
156
|
-
|
|
157
|
-
(
|
|
158
|
-
readonly prototype: Content;
|
|
159
|
-
|
|
160
|
-
template: TemplateComponentFactory<ContentConstructor>;
|
|
240
|
+
export interface ContentConstructor extends Template<Content, ContentDictionary> {
|
|
241
|
+
// as published: the function may return undefined, and the dictionary of the result is unchecked
|
|
242
|
+
template<$2 = any>(fn: (this: Content, data: NoInfer<$2>, dictionary?: ContentDictionary) => ContentDictionary | undefined): Template<Content, any, $2>;
|
|
161
243
|
}
|
|
162
244
|
|
|
163
245
|
export interface Style {
|
|
164
|
-
measure(string: string): Size
|
|
246
|
+
measure(string: string): Required<Size>;
|
|
247
|
+
|
|
248
|
+
// each is undefined when the style does not specify it
|
|
249
|
+
readonly bottom: number | undefined;
|
|
250
|
+
readonly color: Color[] | undefined;
|
|
251
|
+
readonly family: string | undefined;
|
|
252
|
+
readonly horizontal: string | undefined;
|
|
253
|
+
readonly indentation: number | undefined;
|
|
254
|
+
readonly leading: number | undefined;
|
|
255
|
+
readonly left: number | undefined;
|
|
256
|
+
readonly margins: Coordinates;
|
|
257
|
+
readonly right: number | undefined;
|
|
258
|
+
readonly size: string | undefined; // "18px", "120%", "smaller", ...
|
|
259
|
+
readonly stretch: string | undefined;
|
|
260
|
+
readonly style: string | undefined;
|
|
261
|
+
readonly top: number | undefined;
|
|
262
|
+
readonly vertical: string | undefined;
|
|
263
|
+
readonly weight: number | string | undefined; // 100 to 900, "lighter", "bolder"
|
|
165
264
|
}
|
|
166
265
|
export interface StyleDictionaryBase {
|
|
266
|
+
archive?: ArrayBufferLike;
|
|
167
267
|
color?: Color | Color[];
|
|
268
|
+
decoration?: string;
|
|
168
269
|
font?: string;
|
|
169
270
|
horizontal?: string;
|
|
271
|
+
indentation?: number;
|
|
272
|
+
margins?: Coordinates;
|
|
170
273
|
top?: number;
|
|
171
274
|
}
|
|
172
275
|
export interface StyleConstructor {
|
|
173
|
-
new(dictionary
|
|
276
|
+
new(dictionary?: StyleDictionary): Style;
|
|
277
|
+
readonly prototype: Style;
|
|
174
278
|
|
|
175
|
-
template<T>(this: T, dictionary: StyleDictionary): T
|
|
279
|
+
template<T>(this: T, dictionary: StyleDictionary): T & AssetTemplate<Style>;
|
|
176
280
|
}
|
|
177
281
|
|
|
178
282
|
export interface TextStyleDictionary extends StyleDictionaryBase {
|
|
@@ -192,13 +296,28 @@ export interface Texture {
|
|
|
192
296
|
}
|
|
193
297
|
export interface TextureDictionary {
|
|
194
298
|
path: string;
|
|
299
|
+
archive?: ArrayBufferLike;
|
|
300
|
+
}
|
|
301
|
+
export interface TextureAlphaColorDictionary {
|
|
302
|
+
alpha: string;
|
|
303
|
+
color: string;
|
|
304
|
+
archive?: ArrayBufferLike;
|
|
195
305
|
}
|
|
196
306
|
export interface TextureConstructor {
|
|
197
307
|
new(path: string): Texture;
|
|
308
|
+
new(dictionary: TextureAlphaColorDictionary): Texture;
|
|
198
309
|
new(dictionary: TextureDictionary): Texture;
|
|
199
310
|
readonly prototype: Texture;
|
|
200
311
|
|
|
201
|
-
template:
|
|
312
|
+
template(path: string | TextureDictionary | TextureAlphaColorDictionary): TemplateStyle<Partial<undefined>, TextureConstructor>;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
export interface CLUT extends HostBuffer {
|
|
316
|
+
readonly colors: number[];
|
|
317
|
+
}
|
|
318
|
+
export interface CLUTConstructor {
|
|
319
|
+
new(path: string): CLUT;
|
|
320
|
+
readonly prototype: CLUT;
|
|
202
321
|
}
|
|
203
322
|
|
|
204
323
|
export interface Skin {
|
|
@@ -217,6 +336,8 @@ export interface Skin {
|
|
|
217
336
|
right?: number;
|
|
218
337
|
bottom?: number;
|
|
219
338
|
left?: number;
|
|
339
|
+
x?: number;
|
|
340
|
+
y?: number;
|
|
220
341
|
}
|
|
221
342
|
export interface SkinConstructor {
|
|
222
343
|
new(dictionary: SkinDictionary): Skin;
|
|
@@ -226,14 +347,15 @@ export interface SkinConstructor {
|
|
|
226
347
|
}
|
|
227
348
|
|
|
228
349
|
export interface TextureSkinDictionary extends Coordinates, Bounds {
|
|
229
|
-
texture?: Texture | TextureDictionary;
|
|
230
|
-
Texture?: TextureConstructor
|
|
350
|
+
texture?: Texture | TextureDictionary | TextureAlphaColorDictionary;
|
|
351
|
+
Texture?: TextureConstructor | AssetTemplate<Texture>;
|
|
231
352
|
color?: Color | Color[];
|
|
232
353
|
states?: number;
|
|
233
354
|
variants?: number;
|
|
234
355
|
tiles?: Coordinates;
|
|
235
356
|
}
|
|
236
|
-
|
|
357
|
+
// left, right, top, and bottom are the borders when there is no borders property
|
|
358
|
+
export interface ColorSkinDictionary extends Coordinates {
|
|
237
359
|
borders?: Coordinates;
|
|
238
360
|
fill?: Color | Color[];
|
|
239
361
|
stroke?: Color | Color[];
|
|
@@ -247,50 +369,49 @@ export interface Transition {
|
|
|
247
369
|
duration?: number;
|
|
248
370
|
}
|
|
249
371
|
export interface TransitionConstructor {
|
|
250
|
-
new(duration: number, interpolator?: (value: number) => number, first?: any, last?: any): Transition
|
|
372
|
+
new(duration: number, interpolator?: ((value: number) => number) | null, first?: any, last?: any): Transition
|
|
373
|
+
readonly prototype: Transition;
|
|
251
374
|
}
|
|
252
375
|
|
|
253
376
|
export interface Container extends Content {
|
|
254
377
|
clip: boolean;
|
|
255
|
-
readonly first: Content |
|
|
256
|
-
readonly last: Content |
|
|
378
|
+
readonly first: Content | undefined;
|
|
379
|
+
readonly last: Content | undefined;
|
|
257
380
|
readonly length: number;
|
|
258
381
|
readonly transitioning: boolean;
|
|
259
382
|
add(content: Content): void;
|
|
260
383
|
content(at: number | string): Content | undefined;
|
|
261
384
|
empty(start?: number, stop?: number): void;
|
|
262
|
-
firstThat(id: string, ...extras: any[]):
|
|
385
|
+
firstThat(id: string, ...extras: any[]): any;
|
|
263
386
|
insert(content: Content, before: Content): void;
|
|
264
|
-
lastThat(id: string, ...extras: any[]):
|
|
387
|
+
lastThat(id: string, ...extras: any[]): any;
|
|
265
388
|
remove(content: Content): void;
|
|
266
389
|
replace(content: Content, by: Content): void;
|
|
267
|
-
|
|
390
|
+
// a falsy transition completes the transition that is running
|
|
391
|
+
run(transition: Transition | null, ...extras: any[]): void;
|
|
268
392
|
swap(content0: Content, content1: Content): void;
|
|
393
|
+
/** @deprecated an event of Behavior, not a function of containers */
|
|
269
394
|
onTransitionBeginning(container: Container): void;
|
|
395
|
+
/** @deprecated an event of Behavior, not a function of containers */
|
|
270
396
|
onTransitionEnded(container: Container): void;
|
|
271
397
|
}
|
|
398
|
+
// falsy values are skipped, so cond && Content(...) is allowed
|
|
399
|
+
export type Contents = Content | null | undefined | false | 0 | "" | Contents[];
|
|
272
400
|
export interface ContainerDictionary extends ContentDictionary {
|
|
273
401
|
clip?: boolean;
|
|
274
|
-
contents?:
|
|
402
|
+
contents?: Contents[];
|
|
275
403
|
}
|
|
276
|
-
export interface ContainerConstructor {
|
|
277
|
-
new(behaviorData?: any, dictionary?: ContainerDictionary): Container;
|
|
278
|
-
(behaviorData?: any, dictionary?: ContainerDictionary): Container;
|
|
279
|
-
|
|
280
|
-
template<T>(this: T, fn: (arg: any) => ContainerDictionary): T;
|
|
404
|
+
export interface ContainerConstructor extends Template<Container, ContainerDictionary> {
|
|
281
405
|
}
|
|
282
406
|
|
|
283
407
|
export interface Label extends Content {
|
|
284
408
|
string: string;
|
|
285
409
|
}
|
|
286
410
|
export interface LabelDictionary extends ContentDictionary {
|
|
411
|
+
ellipsis?: boolean;
|
|
287
412
|
string?: string;
|
|
288
413
|
}
|
|
289
|
-
export interface LabelConstructor {
|
|
290
|
-
new(behaviorData?: any, dictionary?: LabelDictionary): Label;
|
|
291
|
-
(behaviorData?: any, dictionary?: LabelDictionary): Label;
|
|
292
|
-
|
|
293
|
-
template<T>(this: T, fn: (arg: any) => LabelDictionary): T;
|
|
414
|
+
export interface LabelConstructor extends Template<Label, LabelDictionary> {
|
|
294
415
|
}
|
|
295
416
|
|
|
296
417
|
export interface Port extends Content {
|
|
@@ -305,7 +426,8 @@ export interface Port extends Content {
|
|
|
305
426
|
x: number,
|
|
306
427
|
y: number,
|
|
307
428
|
width: number,
|
|
308
|
-
height: number
|
|
429
|
+
height: number,
|
|
430
|
+
ellipsis?: boolean
|
|
309
431
|
): void;
|
|
310
432
|
drawSkin(
|
|
311
433
|
skin: Skin,
|
|
@@ -322,8 +444,8 @@ export interface Port extends Content {
|
|
|
322
444
|
color: Color,
|
|
323
445
|
x: number,
|
|
324
446
|
y: number,
|
|
325
|
-
width
|
|
326
|
-
height
|
|
447
|
+
width?: number,
|
|
448
|
+
height?: number
|
|
327
449
|
): void;
|
|
328
450
|
drawStyle(
|
|
329
451
|
string: string,
|
|
@@ -370,7 +492,7 @@ export interface Port extends Content {
|
|
|
370
492
|
width?: number,
|
|
371
493
|
height?: number
|
|
372
494
|
): void;
|
|
373
|
-
measureString(string: string, style: Style): Size
|
|
495
|
+
measureString(string: string, style: Style): Required<Size>;
|
|
374
496
|
popClip(): void;
|
|
375
497
|
pushClip(
|
|
376
498
|
x?: number,
|
|
@@ -378,6 +500,7 @@ export interface Port extends Content {
|
|
|
378
500
|
width?: number,
|
|
379
501
|
height?: number
|
|
380
502
|
): void;
|
|
503
|
+
/** @deprecated an event of Behavior, not a function of ports */
|
|
381
504
|
onDraw(
|
|
382
505
|
port: Port,
|
|
383
506
|
x: number,
|
|
@@ -386,12 +509,16 @@ export interface Port extends Content {
|
|
|
386
509
|
height: number
|
|
387
510
|
): void;
|
|
388
511
|
}
|
|
389
|
-
export interface PortConstructor extends
|
|
512
|
+
export interface PortConstructor extends Template<Port, ContentDictionary> {
|
|
513
|
+
// as published: the function may return undefined, and the dictionary of the result is unchecked
|
|
514
|
+
template<$2 = any>(fn: (this: Port, data: NoInfer<$2>, dictionary?: ContentDictionary) => ContentDictionary | undefined): Template<Port, any, $2>;
|
|
390
515
|
}
|
|
391
516
|
|
|
392
517
|
export interface TextBlock {
|
|
518
|
+
/** @deprecated not read by Piu: use link */
|
|
393
519
|
behavior?: object | null;
|
|
394
520
|
style?: Style | null;
|
|
521
|
+
link?: Link | null;
|
|
395
522
|
spans: (string | TextSpan)[] | string,
|
|
396
523
|
}
|
|
397
524
|
|
|
@@ -400,57 +527,66 @@ export interface TextSpan extends TextBlock {
|
|
|
400
527
|
}
|
|
401
528
|
|
|
402
529
|
export interface Text extends Content {
|
|
403
|
-
blocks
|
|
530
|
+
// a string in blocks is a block of one span in the style of the text
|
|
531
|
+
get blocks(): TextBlock[];
|
|
532
|
+
set blocks(it: (TextBlock | string)[]);
|
|
404
533
|
string: string;
|
|
405
534
|
begin(): void;
|
|
406
|
-
|
|
407
|
-
|
|
535
|
+
// link, when present, receives the touch events of the block or span
|
|
536
|
+
beginBlock(style?: Style | null, link?: Link | null): void;
|
|
537
|
+
beginSpan(style?: Style | null, link?: Link | null): void;
|
|
408
538
|
concat(string: string): void;
|
|
409
539
|
end(): void;
|
|
410
540
|
endBlock(): void;
|
|
411
541
|
endSpan(): void;
|
|
412
542
|
}
|
|
413
543
|
export interface TextDictionary extends ContentDictionary {
|
|
414
|
-
blocks?: TextBlock[],
|
|
544
|
+
blocks?: (TextBlock | string)[],
|
|
415
545
|
string?: string;
|
|
416
546
|
}
|
|
417
|
-
export interface TextConstructor {
|
|
418
|
-
new(behaviorData?: any, dictionary?: TextDictionary): Text;
|
|
419
|
-
(behaviorData?: any, dictionary?: TextDictionary): Text;
|
|
420
|
-
|
|
421
|
-
template<T>(this: T, fn: (arg: any) => TextDictionary): T;
|
|
547
|
+
export interface TextConstructor extends Template<Text, TextDictionary> {
|
|
422
548
|
}
|
|
423
549
|
|
|
424
550
|
export interface Application extends Container {
|
|
425
551
|
displayListLength: number;
|
|
426
552
|
commandListLength: number;
|
|
427
553
|
touchCount: number;
|
|
554
|
+
// set with the data of a color table (a CLUT or a Resource); reads back as the 16 colors in use
|
|
555
|
+
get clut(): HostBuffer | undefined;
|
|
556
|
+
set clut(it: HostBuffer);
|
|
557
|
+
rotation: number | undefined;
|
|
558
|
+
animateColors(colors: Color[]): void;
|
|
559
|
+
keyDown(key: any): void;
|
|
560
|
+
keyUp(key: any): void;
|
|
561
|
+
postMessage(json: any): void;
|
|
428
562
|
purge(): void;
|
|
429
563
|
}
|
|
430
564
|
export interface ApplicationDictionary extends ContainerDictionary {
|
|
431
565
|
displayListLength?: number;
|
|
432
566
|
commandListLength?: number;
|
|
433
567
|
touchCount?: number;
|
|
568
|
+
regionLength?: number;
|
|
434
569
|
pixels?: number;
|
|
435
570
|
}
|
|
436
|
-
export interface ApplicationConstructor {
|
|
437
|
-
new(behaviorData?: any, dictionary?: ApplicationDictionary): Application;
|
|
438
|
-
|
|
439
|
-
template<T>(this: T, fn: (arg: any) => ApplicationDictionary): T;
|
|
571
|
+
export interface ApplicationConstructor extends Template<Application, ApplicationDictionary> {
|
|
440
572
|
}
|
|
441
573
|
|
|
442
574
|
export interface Column extends Container {
|
|
443
575
|
}
|
|
444
|
-
export interface ColumnConstructor extends
|
|
576
|
+
export interface ColumnConstructor extends Template<Column, ContainerDictionary> {
|
|
445
577
|
}
|
|
446
578
|
|
|
447
579
|
export interface Layout extends Container {
|
|
580
|
+
/** @deprecated an event of Behavior, not a function of layouts */
|
|
448
581
|
onFitHorizontally(layout: Layout, width: number): void;
|
|
582
|
+
/** @deprecated an event of Behavior, not a function of layouts */
|
|
449
583
|
onFitVertically(layout: Layout, height: number): void;
|
|
584
|
+
/** @deprecated an event of Behavior, not a function of layouts */
|
|
450
585
|
onMeasureHorizontally(layout: Layout, width: number): void;
|
|
586
|
+
/** @deprecated an event of Behavior, not a function of layouts */
|
|
451
587
|
onMeasureVertically(layout: Layout, height: number): void;
|
|
452
588
|
}
|
|
453
|
-
export interface LayoutConstructor extends
|
|
589
|
+
export interface LayoutConstructor extends Template<Layout, ContainerDictionary> {
|
|
454
590
|
}
|
|
455
591
|
|
|
456
592
|
export interface Image extends Content {
|
|
@@ -459,12 +595,9 @@ export interface Image extends Content {
|
|
|
459
595
|
}
|
|
460
596
|
export interface ImageDictionary extends ContentDictionary {
|
|
461
597
|
path: string;
|
|
598
|
+
archive?: ArrayBufferLike;
|
|
462
599
|
}
|
|
463
|
-
export interface ImageConstructor {
|
|
464
|
-
new(behaviorData?: any, dictionary?: ImageDictionary): Image;
|
|
465
|
-
(behaviorData?: any, dictionary?: ImageDictionary): Image;
|
|
466
|
-
|
|
467
|
-
template<T>(this: T, fn: (arg: any) => ImageDictionary): T;
|
|
600
|
+
export interface ImageConstructor extends Template<Image, ImageDictionary> {
|
|
468
601
|
}
|
|
469
602
|
|
|
470
603
|
export interface Die extends Layout {
|
|
@@ -479,47 +612,48 @@ export interface Die extends Layout {
|
|
|
479
612
|
attach(content: Content): void;
|
|
480
613
|
detach(): void;
|
|
481
614
|
}
|
|
482
|
-
export interface
|
|
615
|
+
export interface DieDictionary extends ContainerDictionary {
|
|
616
|
+
regionLength?: number;
|
|
617
|
+
}
|
|
618
|
+
export interface DieConstructor extends Template<Die, DieDictionary> {
|
|
483
619
|
}
|
|
484
620
|
|
|
485
621
|
export interface Row extends Container {
|
|
486
622
|
}
|
|
487
|
-
export interface RowConstructor extends
|
|
623
|
+
export interface RowConstructor extends Template<Row, ContainerDictionary> {
|
|
488
624
|
}
|
|
489
625
|
|
|
490
626
|
export interface Scroller extends Container {
|
|
491
|
-
readonly constraint: Position
|
|
627
|
+
readonly constraint: Required<Position>;
|
|
492
628
|
loop: boolean;
|
|
493
|
-
|
|
629
|
+
looping: boolean;
|
|
630
|
+
get scroll(): Required<Position>;
|
|
631
|
+
set scroll(it: Position);
|
|
494
632
|
tracking: boolean;
|
|
495
|
-
reveal(bounds: Bounds): void;
|
|
633
|
+
reveal(bounds: Bounds, centerVertically?: boolean, centerHorizontally?: boolean): void;
|
|
496
634
|
scrollBy(dx: number, dy: number): void;
|
|
497
635
|
scrollTo(x: number, y: number): void;
|
|
636
|
+
/** @deprecated an event of Behavior, not a function of scrollers */
|
|
498
637
|
onScrolled(scroller: Scroller): void;
|
|
499
638
|
}
|
|
500
639
|
export interface ScrollerDictionary extends ContainerDictionary {
|
|
501
640
|
loop?: boolean;
|
|
641
|
+
looping?: boolean;
|
|
502
642
|
}
|
|
503
|
-
export interface ScrollerConstructor {
|
|
504
|
-
new(behaviorData?: any, dictionary?: ScrollerDictionary): Scroller;
|
|
505
|
-
(behaviorData?: any, dictionary?: ScrollerDictionary): Scroller;
|
|
506
|
-
|
|
507
|
-
template<T>(this: T, fn: (arg: any) => ScrollerDictionary): T;
|
|
643
|
+
export interface ScrollerConstructor extends Template<Scroller, ScrollerDictionary> {
|
|
508
644
|
}
|
|
509
645
|
|
|
510
646
|
export interface LinkDictionary {
|
|
511
|
-
|
|
647
|
+
anchor?: PropertyKey;
|
|
648
|
+
Behavior?: new () => object;
|
|
649
|
+
behavior?: object;
|
|
512
650
|
}
|
|
513
651
|
export interface Link {
|
|
514
|
-
readonly container: Container;
|
|
652
|
+
readonly container: Container | undefined;
|
|
515
653
|
state: number;
|
|
516
654
|
captureTouch(id: number, x: number, y: number, ticks: number): void;
|
|
517
655
|
}
|
|
518
|
-
export interface LinkConstructor {
|
|
519
|
-
new(behaviorData?: any, dictionary?: LinkDictionary): Link;
|
|
520
|
-
(behaviorData?: any, dictionary?: LinkDictionary): Link;
|
|
521
|
-
|
|
522
|
-
template<T>(this: T, fn: (arg: any) => LinkDictionary): T;
|
|
656
|
+
export interface LinkConstructor extends Template<Link, LinkDictionary> {
|
|
523
657
|
}
|
|
524
658
|
|
|
525
659
|
export interface Locals {
|
|
@@ -529,7 +663,7 @@ export interface Locals {
|
|
|
529
663
|
}
|
|
530
664
|
|
|
531
665
|
export interface blendColors {
|
|
532
|
-
(a: number, c1:
|
|
666
|
+
(a: number, c1: Color, c2: Color): Extract<Color, number>
|
|
533
667
|
}
|
|
534
668
|
export interface hsl {
|
|
535
669
|
(h: number, s: number, l: number): Extract<Color, number>
|
package/piu/MC.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ declare module "piu/MC" {
|
|
|
28
28
|
const Skin: MC.SkinConstructor
|
|
29
29
|
const Texture: MC.TextureConstructor
|
|
30
30
|
const Style: MC.StyleConstructor
|
|
31
|
-
const Behavior: MC.
|
|
31
|
+
const Behavior: MC.BehaviorClass
|
|
32
32
|
const Content: MC.ContentConstructor
|
|
33
33
|
const Container: MC.ContainerConstructor
|
|
34
34
|
const Application: MC.ApplicationConstructor
|
|
@@ -43,6 +43,7 @@ declare module "piu/MC" {
|
|
|
43
43
|
const Transition: MC.TransitionConstructor
|
|
44
44
|
const Text: MC.TextConstructor
|
|
45
45
|
const Link: MC.LinkConstructor
|
|
46
|
+
const CLUT: MC.CLUTConstructor
|
|
46
47
|
const application: MC.Application
|
|
47
48
|
const Locals: MC.Locals
|
|
48
49
|
const blendColors: MC.blendColors
|
package/piu/QRCode.d.ts
CHANGED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 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
|
+
// modules/piu/MC/outline/piuRoundRect.js (and the same content on Pebble)
|
|
22
|
+
|
|
23
|
+
declare module "piu/RoundRect" {
|
|
24
|
+
import { Content, ContentDictionary } from "piu/MC";
|
|
25
|
+
|
|
26
|
+
interface RoundRect extends Content {
|
|
27
|
+
corners: number;
|
|
28
|
+
radius: number;
|
|
29
|
+
}
|
|
30
|
+
interface RoundRectDictionary extends ContentDictionary {
|
|
31
|
+
corners?: number;
|
|
32
|
+
radius?: number;
|
|
33
|
+
}
|
|
34
|
+
interface RoundRectConstructor {
|
|
35
|
+
new(behaviorData?: any, dictionary?: RoundRectDictionary): RoundRect;
|
|
36
|
+
(behaviorData?: any, dictionary?: RoundRectDictionary): RoundRect;
|
|
37
|
+
|
|
38
|
+
template<T>(this: T, fn: (arg: any) => RoundRectDictionary): T;
|
|
39
|
+
|
|
40
|
+
readonly topLeft: 1;
|
|
41
|
+
readonly topRight: 2;
|
|
42
|
+
readonly bottomLeft: 4;
|
|
43
|
+
readonly bottomRight: 8;
|
|
44
|
+
}
|
|
45
|
+
const RoundRect: RoundRectConstructor;
|
|
46
|
+
|
|
47
|
+
global {
|
|
48
|
+
const RoundRect: RoundRectConstructor
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export { RoundRect };
|
|
52
|
+
export default RoundRect;
|
|
53
|
+
}
|