@moddable/typings 7.0.0 → 7.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/ChatAudioIO.d.ts +2 -1
  2. package/base64.d.ts +1 -1
  3. package/commodetto/Bitmap.d.ts +5 -1
  4. package/commodetto/BufferOut.d.ts +2 -2
  5. package/commodetto/Convert.d.ts +3 -3
  6. package/commodetto/ReadGIF.d.ts +1 -1
  7. package/commodetto/ReadPNG.d.ts +2 -2
  8. package/commodetto/loadJPEG.d.ts +1 -1
  9. package/commodetto/parseBMF.d.ts +1 -1
  10. package/commodetto/parseNFNT.d.ts +1 -1
  11. package/commodetto/readJPEG.d.ts +2 -2
  12. package/crc.d.ts +2 -2
  13. package/deflate.d.ts +1 -1
  14. package/display.d.ts +1 -1
  15. package/dns/parser.d.ts +1 -1
  16. package/embedded/display.d.ts +2 -2
  17. package/embedded/storage/files.d.ts +2 -2
  18. package/embedded/storage/flash.d.ts +2 -2
  19. package/embedded/storage/key-value.d.ts +4 -3
  20. package/embedded_io/_common.d.ts +0 -1
  21. package/embedded_io/audio/in.d.ts +1 -3
  22. package/embedded_io/audio/out.d.ts +1 -3
  23. package/embedded_io/ble/central.d.ts +3 -4
  24. package/embedded_io/ble/peripheral.d.ts +6 -7
  25. package/embedded_io/i2c.d.ts +3 -3
  26. package/embedded_io/serial.d.ts +3 -3
  27. package/embedded_io/smbus.d.ts +2 -3
  28. package/embedded_io/socket/tcp.d.ts +2 -3
  29. package/embedded_io/socket/udp.d.ts +1 -2
  30. package/embedded_io/spi.d.ts +4 -4
  31. package/embedded_network/http/client.d.ts +7 -8
  32. package/embedded_network/mqtt/client.d.ts +4 -6
  33. package/embedded_network/websocket/client.d.ts +74 -0
  34. package/flash.d.ts +1 -1
  35. package/global.d.ts +10 -7
  36. package/hex.d.ts +1 -1
  37. package/inflate.d.ts +1 -1
  38. package/package.json +1 -1
  39. package/pebble/accelerometer.d.ts +46 -0
  40. package/pebble/battery.d.ts +38 -0
  41. package/pebble/button.d.ts +40 -0
  42. package/pebble/compass.d.ts +40 -0
  43. package/pebble/device.d.ts +51 -0
  44. package/pebble/global.d.ts +128 -0
  45. package/pebble/location.d.ts +50 -0
  46. package/pebble/message.d.ts +46 -0
  47. package/pebble/piu.d.ts +97 -0
  48. package/pebble/poco.d.ts +79 -0
  49. package/pins/audioout.d.ts +1 -1
  50. package/piu/MC-types.d.ts +543 -0
  51. package/piu/MC.d.ts +78 -526
  52. package/qrcode.d.ts +6 -4
  53. package/securesocket.d.ts +1 -1
  54. package/socket.d.ts +1 -1
  55. package/web/fetch.d.ts +28 -0
  56. package/{url.d.ts → web/url.d.ts} +1 -1
  57. package/web/websocket.d.ts +62 -0
  58. package/web/webstorage.d.ts +11 -0
  59. package/xs.d.ts +3 -3
  60. package/zip.d.ts +1 -1
  61. /package/{headers.d.ts → web/headers.d.ts} +0 -0
  62. /package/{structuredClone.d.ts → web/structuredClone.d.ts} +0 -0
  63. /package/{worker.d.ts → web/worker.d.ts} +0 -0
@@ -0,0 +1,543 @@
1
+ /*
2
+ * Copyright (c) 2020-2025 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
+ /* type aliases */
22
+ type Coordinates = {
23
+ top?: number;
24
+ right?: number;
25
+ bottom?: number;
26
+ left?: number;
27
+ };
28
+ type Position = {
29
+ x?: number;
30
+ y?: number;
31
+ };
32
+ type Size = {
33
+ width?: number;
34
+ height?: number;
35
+ };
36
+ type Bounds = Position & Size;
37
+ type Color = string;
38
+ type ContentState = {
39
+ state?: number;
40
+ variant?: number;
41
+ };
42
+ type TimeProperty = {
43
+ time?: number;
44
+ duration?: number;
45
+ fraction?: number;
46
+ interval?: number;
47
+ loop?: boolean;
48
+ };
49
+ type TouchProperty = {
50
+ active?: boolean;
51
+ backgroundTouch?: boolean;
52
+ exclusiveTouch?: boolean;
53
+ multipleTouch?: boolean;
54
+ };
55
+
56
+ // TODO: more accurate constructor parameters
57
+ type TemplateStyle<P, C extends new (...args: any) => any> = {
58
+ new (dictionary?: P): InstanceType<C>;
59
+ template: TemplateStyleFactory<C>;
60
+ };
61
+ type TemplateStyleFactory<T extends new (...args: any) => any> = (
62
+ param: ConstructorParameters<T>[0]
63
+ ) => TemplateStyle<Partial<ConstructorParameters<T>[1]>, T>;
64
+
65
+ type TemplateComponent<P, C extends new (...args: any) => any> = {
66
+ new (behaviorData?: any, dictionary?: P): InstanceType<C>;
67
+ template: TemplateComponentFactory<C>;
68
+ };
69
+ type TemplateComponentFactory<T extends new (...args: any) => any> = (
70
+ func: (param: any) => ConstructorParameters<T>[1]
71
+ ) => TemplateComponent<Parameters<typeof func>[0], T>;
72
+
73
+ interface Behavior<T extends Content = Content>{
74
+ onCreate?(content: T, data: object, context: any): void;
75
+ onDisplaying?(content: T): void;
76
+ onFinished?(content: T): void;
77
+ onTimeChanged?(content: T): void;
78
+ onTouchBegan?(content: T, id: number, x: number, y: number, ticks: number): void;
79
+ onTouchCancelled?(content: T, id: number): void;
80
+ onTouchended?( content: T, id: number, x: number, y: number, ticks: number): void;
81
+ onTouchMoved?( content: T, id: number, x: number, y: number, ticks: number): void;
82
+ // TODO: complete callbacks
83
+ }
84
+
85
+ interface BehaviorConstructor<T extends Content = Content> {
86
+ new(): Behavior<T>;
87
+ }
88
+
89
+ interface Content {
90
+ // TODO: consider type parameter to avoid any
91
+ adjust(x: number, y: number): void;
92
+ bubble(id: string, ...extras: any[]): void;
93
+ captureTouch(id: string, x: number, y: number, ticks: number): void;
94
+ defer(id: string, ...extras: any[]): void;
95
+ delegate(id: string, ...extras: any[]): void;
96
+ distribute(id: string, ...extras: any[]): void;
97
+ focus(): void;
98
+ hit(x: number, y: number): Content | undefined;
99
+ measure(): Size;
100
+ moveBy(x: number, y: number): void;
101
+ render(): void;
102
+ sizeBy(width: number, height: number): void;
103
+ start(): void;
104
+ stop(): void;
105
+
106
+ readonly previous: Content | null;
107
+ readonly next: Content | null;
108
+ readonly container: Container | null;
109
+ readonly index: number;
110
+ name: string;
111
+ active: boolean;
112
+ anchor: string;
113
+ behavior: object;
114
+ coordinates: Coordinates;
115
+ bounds: Bounds;
116
+ backgroundTouch: boolean;
117
+ exclusiveTouch: boolean;
118
+ multipleTouch: boolean;
119
+
120
+ time: number;
121
+ duration: number;
122
+ fraction: number;
123
+ interval: number;
124
+ loop: boolean;
125
+ running: boolean;
126
+ offset: undefined | Position;
127
+ position: undefined | Position;
128
+ size: Size;
129
+ state: number;
130
+ variant: number;
131
+ skin: Skin | null;
132
+ style: Style | null;
133
+ visible: boolean;
134
+ x: number;
135
+ y: number;
136
+ width: number;
137
+ height: number;
138
+ }
139
+ interface ContentDictionary
140
+ extends Coordinates,
141
+ Size,
142
+ ContentState,
143
+ TimeProperty,
144
+ TouchProperty {
145
+ name?: string;
146
+ anchor?: string;
147
+ Behavior?: BehaviorConstructor;
148
+ skin?: Skin | SkinDictionary;
149
+ Skin?: SkinConstructor;
150
+ style?: Style | StyleDictionary;
151
+ Style?: StyleConstructor;
152
+ visible?: boolean;
153
+ }
154
+ interface ContentConstructor {
155
+ new(behaviorData?: any, dictionary?: ContentDictionary): Content;
156
+ (behaviorData?: any, dictionary?: ContentDictionary): Content;
157
+ readonly prototype: Content;
158
+
159
+ template: TemplateComponentFactory<ContentConstructor>;
160
+ }
161
+
162
+ interface Style {
163
+ measure(string: string): Size;
164
+ }
165
+ interface StyleDictionaryBase {
166
+ color?: Color | Color[];
167
+ font?: string;
168
+ horizontal?: string;
169
+ top?: number;
170
+ }
171
+ interface StyleConstructor {
172
+ new(dictionary: StyleDictionary): Style;
173
+
174
+ template<T>(this: T, dictionary: StyleDictionary): T;
175
+ }
176
+
177
+ interface TextStyleDictionary extends StyleDictionaryBase {
178
+ leading?: number;
179
+ right?: number;
180
+ bottom?: number;
181
+ left?: number;
182
+ }
183
+ interface LabelStyleDictionary extends StyleDictionaryBase {
184
+ vertical?: string;
185
+ }
186
+ type StyleDictionary = LabelStyleDictionary | TextStyleDictionary;
187
+
188
+ interface Texture {
189
+ readonly height: number;
190
+ readonly width: number;
191
+ }
192
+ interface TextureDictionary {
193
+ path: string;
194
+ }
195
+ interface TextureConstructor {
196
+ new(path: string): Texture;
197
+ new(dictionary: TextureDictionary): Texture;
198
+ readonly prototype: Texture;
199
+
200
+ template: TemplateStyleFactory<TextureConstructor>;
201
+ }
202
+
203
+ interface Skin {
204
+ borders: Coordinates;
205
+ fill: Color | Color[];
206
+ stroke: Color | Color[];
207
+ texture: Texture;
208
+ color: Color;
209
+ bounds: Bounds;
210
+ height: number;
211
+ width: number;
212
+ states?: number;
213
+ variants?: number;
214
+ tiles?: Coordinates;
215
+ top?: number;
216
+ right?: number;
217
+ bottom?: number;
218
+ left?: number;
219
+ }
220
+ interface SkinConstructor {
221
+ new(dictionary: SkinDictionary): Skin;
222
+ readonly prototype: Skin;
223
+
224
+ template: TemplateStyleFactory<SkinConstructor>;
225
+ }
226
+
227
+ interface TextureSkinDictionary extends Coordinates, Bounds {
228
+ texture?: Texture | TextureDictionary;
229
+ Texture?: TextureConstructor;
230
+ color?: Color | Color[];
231
+ states?: number;
232
+ variants?: number;
233
+ tiles?: Coordinates;
234
+ }
235
+ interface ColorSkinDictionary {
236
+ borders?: Coordinates;
237
+ fill?: Color | Color[];
238
+ stroke?: Color | Color[];
239
+ }
240
+ type SkinDictionary = ColorSkinDictionary | TextureSkinDictionary;
241
+
242
+ interface Transition {
243
+ onBegin(container: Container, ...extras: any[]): void;
244
+ onEnd(container: Container, ...extras: any[]): void;
245
+ onStep(fraction: number): void;
246
+ duration?: number;
247
+ }
248
+ interface TransitionConstructor {
249
+ new(duration: number, interpolator?: (value: number) => number, first?: any, last?: any): Transition
250
+ }
251
+
252
+ interface Container extends Content {
253
+ clip: boolean;
254
+ readonly first: Content | null;
255
+ readonly last: Content | null;
256
+ readonly length: number;
257
+ readonly transitioning: boolean;
258
+ add(content: Content): void;
259
+ content(at: number | string): Content | undefined;
260
+ empty(start?: number, stop?: number): void;
261
+ firstThat(id: string, ...extras: any[]): void;
262
+ insert(content: Content, before: Content): void;
263
+ lastThat(id: string, ...extras: any[]): void;
264
+ remove(content: Content): void;
265
+ replace(content: Content, by: Content): void;
266
+ run(transition: Transition, ...extras: any[]): void;
267
+ swap(content0: Content, content1: Content): void;
268
+ onTransitionBeginning(container: Container): void;
269
+ onTransitionEnded(container: Container): void;
270
+ }
271
+ interface ContainerDictionary extends ContentDictionary {
272
+ clip?: boolean;
273
+ contents?: Content[];
274
+ }
275
+ interface ContainerConstructor {
276
+ new(behaviorData?: any, dictionary?: ContainerDictionary): Container;
277
+ (behaviorData?: any, dictionary?: ContainerDictionary): Container;
278
+
279
+ template<T>(this: T, fn: (arg: any) => ContainerDictionary): T;
280
+ }
281
+
282
+ interface Label extends Content {
283
+ string: string;
284
+ }
285
+ interface LabelDictionary extends ContentDictionary {
286
+ string?: string;
287
+ }
288
+ interface LabelConstructor {
289
+ new(behaviorData?: any, dictionary?: LabelDictionary): Label;
290
+ (behaviorData?: any, dictionary?: LabelDictionary): Label;
291
+
292
+ template<T>(this: T, fn: (arg: any) => LabelDictionary): T;
293
+ }
294
+
295
+ interface Port extends Content {
296
+ drawContent(
297
+ x: number,
298
+ y: number,
299
+ width: number,
300
+ height: number
301
+ ): void;
302
+ drawLabel(
303
+ string: string,
304
+ x: number,
305
+ y: number,
306
+ width: number,
307
+ height: number
308
+ ): void;
309
+ drawSkin(
310
+ skin: Skin,
311
+ x: number,
312
+ y: number,
313
+ width: number,
314
+ height: number,
315
+ variant?: number,
316
+ state?: number
317
+ ): void;
318
+ drawString(
319
+ string: string,
320
+ style: Style,
321
+ color: Color,
322
+ x: number,
323
+ y: number,
324
+ width: number,
325
+ height: number
326
+ ): void;
327
+ drawStyle(
328
+ string: string,
329
+ style: Style,
330
+ x: number,
331
+ y: number,
332
+ width: number,
333
+ height: number,
334
+ ellipsis?: boolean,
335
+ state?: number
336
+ ): void;
337
+ drawTexture(
338
+ texture: Texture,
339
+ color: Color,
340
+ x: number,
341
+ y: number,
342
+ sx: number,
343
+ sy: number,
344
+ sw: number,
345
+ sh: number
346
+ ): void;
347
+ fillColor(
348
+ color: Color,
349
+ x: number,
350
+ y: number,
351
+ width: number,
352
+ height: number
353
+ ): void;
354
+ fillTexture(
355
+ texture: Texture,
356
+ color: Color,
357
+ x: number,
358
+ y: number,
359
+ width: number,
360
+ height: number,
361
+ sx?: number,
362
+ sy?: number,
363
+ sw?: number,
364
+ sh?: number
365
+ ): void;
366
+ invalidate(
367
+ x?: number,
368
+ y?: number,
369
+ width?: number,
370
+ height?: number
371
+ ): void;
372
+ measureString(string: string, style: Style): Size;
373
+ popClip(): void;
374
+ pushClip(
375
+ x?: number,
376
+ y?: number,
377
+ width?: number,
378
+ height?: number
379
+ ): void;
380
+ onDraw(
381
+ port: Port,
382
+ x: number,
383
+ y: number,
384
+ width: number,
385
+ height: number
386
+ ): void;
387
+ }
388
+ interface PortConstructor extends ContentConstructor {
389
+ }
390
+
391
+ interface TextBlock {
392
+ behavior?: object | null;
393
+ style?: Style | null;
394
+ spans: (string | TextSpan)[] | string,
395
+ }
396
+
397
+ interface TextSpan extends TextBlock {
398
+ link?: any
399
+ }
400
+
401
+ interface Text extends Content {
402
+ blocks: TextBlock[],
403
+ string: string;
404
+ begin(): void;
405
+ beginBlock(style?: Style, behavior?: object): void;
406
+ beginSpan(style: Style, behavior?: object): void;
407
+ concat(string: string): void;
408
+ end(): void;
409
+ endBlock(): void;
410
+ endSpan(): void;
411
+ }
412
+ interface TextDictionary extends ContentDictionary {
413
+ blocks?: TextBlock[],
414
+ string?: string;
415
+ }
416
+ interface TextConstructor {
417
+ new(behaviorData?: any, dictionary?: TextDictionary): Text;
418
+ (behaviorData?: any, dictionary?: TextDictionary): Text;
419
+
420
+ template<T>(this: T, fn: (arg: any) => TextDictionary): T;
421
+ }
422
+
423
+ interface Application extends Container {
424
+ displayListLength: number;
425
+ commandListLength: number;
426
+ touchCount: number;
427
+ }
428
+ interface ApplicationDictionary extends ContainerDictionary {
429
+ displayListLength?: number;
430
+ commandListLength?: number;
431
+ touchCount?: number;
432
+ pixels?: number;
433
+ }
434
+ interface ApplicationConstructor {
435
+ new(behaviorData?: any, dictionary?: ApplicationDictionary): Application;
436
+
437
+ template<T>(this: T, fn: (arg: any) => ApplicationDictionary): T;
438
+ }
439
+
440
+ interface Column extends Container {
441
+ }
442
+ interface ColumnConstructor extends ContainerConstructor {
443
+ }
444
+
445
+ interface Layout extends Container {
446
+ onFitHorizontally(layout: Layout, width: number): void;
447
+ onFitVertically(layout: Layout, height: number): void;
448
+ onMeasureHorizontally(layout: Layout, width: number): void;
449
+ onMeasureVertically(layout: Layout, height: number): void;
450
+ }
451
+ interface LayoutConstructor extends ContainerConstructor {
452
+ }
453
+
454
+ interface Image extends Content {
455
+ readonly frameCount: never;
456
+ frameIndex: number;
457
+ }
458
+ interface ImageDictionary extends ContentDictionary {
459
+ path: string;
460
+ }
461
+ interface ImageConstructor {
462
+ new(behaviorData?: any, dictionary?: ImageDictionary): Image;
463
+ (behaviorData?: any, dictionary?: ImageDictionary): Image;
464
+
465
+ template<T>(this: T, fn: (arg: any) => ImageDictionary): T;
466
+ }
467
+
468
+ interface Die extends Layout {
469
+ set(x: number, y: number, width: number, height: number): Die;
470
+ sub(x: number, y: number, width: number, height: number): Die;
471
+ and(x: number, y: number, width: number, height: number): Die;
472
+ or(x: number, y: number, width: number, height: number): Die;
473
+ xor(x: number, y: number, width: number, height: number): Die;
474
+ fill(): Die;
475
+ empty(): Die;
476
+ cut(): void;
477
+ attach(content: Content): void;
478
+ detach(): void;
479
+ }
480
+ interface DieConstructor extends LayoutConstructor {
481
+ }
482
+
483
+ interface Row extends Container {
484
+ }
485
+ interface RowConstructor extends ContainerConstructor {
486
+ }
487
+
488
+ interface Scroller extends Container {
489
+ readonly constraint: Position;
490
+ loop: boolean;
491
+ scroll: Position;
492
+ tracking: boolean;
493
+ reveal(bounds: Bounds): void;
494
+ scrollBy(dx: number, dy: number): void;
495
+ scrollTo(x: number, y: number): void;
496
+ onScrolled(scroller: Scroller): void;
497
+ }
498
+ interface ScrollerDictionary extends ContainerDictionary {
499
+ loop?: boolean;
500
+ }
501
+ interface ScrollerConstructor {
502
+ new(behaviorData?: any, dictionary?: ScrollerDictionary): Scroller;
503
+ (behaviorData?: any, dictionary?: ScrollerDictionary): Scroller;
504
+
505
+ template<T>(this: T, fn: (arg: any) => ScrollerDictionary): T;
506
+ }
507
+
508
+ interface LinkDictionary {
509
+ Behavior?: BehaviorConstructor;
510
+ }
511
+ interface Link {
512
+ readonly container: Container;
513
+ state: number;
514
+ captureTouch(id: number, x: number, y: number, ticks: number): void;
515
+ }
516
+ interface LinkConstructor {
517
+ new(behaviorData?: any, dictionary?: LinkDictionary): Link;
518
+ (behaviorData?: any, dictionary?: LinkDictionary): Link;
519
+
520
+ template<T>(this: T, fn: (arg: any) => LinkDictionary): T;
521
+ }
522
+
523
+ interface Locals {
524
+ new(name?: string, language?: string): Locals
525
+ language: string;
526
+ get(textToLocalize: string): string
527
+ }
528
+
529
+ interface blendColors {
530
+ (a: number, c1: number, c2: number): Color
531
+ }
532
+ interface hsl {
533
+ (h: number, s: number, l: number): Color
534
+ }
535
+ interface hsla {
536
+ (h: number, s: number, l: number, a: number): Color
537
+ }
538
+ interface rgb {
539
+ (r: number, g: number, b: number): Color
540
+ }
541
+ interface rgba {
542
+ (r: number, g: number, b: number, a: number): Color
543
+ }