react-pebble 0.1.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/dist/lib/compiler.cjs +3 -0
- package/dist/lib/compiler.cjs.map +1 -0
- package/dist/lib/compiler.js +54 -0
- package/dist/lib/compiler.js.map +1 -0
- package/dist/lib/components.cjs +2 -0
- package/dist/lib/components.cjs.map +1 -0
- package/dist/lib/components.js +80 -0
- package/dist/lib/components.js.map +1 -0
- package/dist/lib/hooks.cjs +2 -0
- package/dist/lib/hooks.cjs.map +1 -0
- package/dist/lib/hooks.js +99 -0
- package/dist/lib/hooks.js.map +1 -0
- package/dist/lib/index.cjs +2 -0
- package/dist/lib/index.cjs.map +1 -0
- package/dist/lib/index.js +585 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/platform.cjs +2 -0
- package/dist/lib/platform.cjs.map +1 -0
- package/dist/lib/platform.js +52 -0
- package/dist/lib/platform.js.map +1 -0
- package/dist/lib/plugin.cjs +60 -0
- package/dist/lib/plugin.cjs.map +1 -0
- package/dist/lib/plugin.js +102 -0
- package/dist/lib/plugin.js.map +1 -0
- package/dist/lib/src/compiler/index.d.ts +40 -0
- package/dist/lib/src/components/index.d.ts +129 -0
- package/dist/lib/src/hooks/index.d.ts +75 -0
- package/dist/lib/src/index.d.ts +36 -0
- package/dist/lib/src/pebble-dom-shim.d.ts +45 -0
- package/dist/lib/src/pebble-dom.d.ts +59 -0
- package/dist/lib/src/pebble-output.d.ts +44 -0
- package/dist/lib/src/pebble-reconciler.d.ts +16 -0
- package/dist/lib/src/pebble-render.d.ts +31 -0
- package/dist/lib/src/platform.d.ts +30 -0
- package/dist/lib/src/plugin/index.d.ts +20 -0
- package/package.json +90 -0
- package/scripts/compile-to-piu.ts +1794 -0
- package/scripts/deploy.sh +46 -0
- package/src/compiler/index.ts +114 -0
- package/src/components/index.tsx +280 -0
- package/src/hooks/index.ts +311 -0
- package/src/index.ts +126 -0
- package/src/pebble-dom-shim.ts +266 -0
- package/src/pebble-dom.ts +190 -0
- package/src/pebble-output.ts +310 -0
- package/src/pebble-reconciler.ts +54 -0
- package/src/pebble-render.ts +311 -0
- package/src/platform.ts +50 -0
- package/src/plugin/index.ts +274 -0
- package/src/types/moddable.d.ts +156 -0
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ambient declarations for the Pebble Alloy runtime (Moddable XS / Poco).
|
|
3
|
+
*
|
|
4
|
+
* IMPORTANT: this file MUST remain a script (no top-level imports or
|
|
5
|
+
* exports). As soon as you add an `export`, TypeScript treats it as a
|
|
6
|
+
* module and `declare module 'commodetto/Poco'` stops working ambiently.
|
|
7
|
+
*
|
|
8
|
+
* Only the surface actually used by react-pebble is declared. When you
|
|
9
|
+
* reach for a Moddable API that isn't here, add it — keep this file the
|
|
10
|
+
* single source of truth for the runtime shape.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
14
|
+
// `screen` — the framebuffer the Poco renderer draws into.
|
|
15
|
+
// Probed shape: { width, height, frameBuffer, unobstructed }.
|
|
16
|
+
// ---------------------------------------------------------------------------
|
|
17
|
+
|
|
18
|
+
interface ModdableScreen {
|
|
19
|
+
readonly width: number;
|
|
20
|
+
readonly height: number;
|
|
21
|
+
readonly frameBuffer: unknown;
|
|
22
|
+
readonly unobstructed: unknown;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
declare const screen: ModdableScreen | undefined;
|
|
26
|
+
|
|
27
|
+
// ---------------------------------------------------------------------------
|
|
28
|
+
// `watch` — system event bus (time ticks, buttons, connection state).
|
|
29
|
+
//
|
|
30
|
+
// `addEventListener` accepts any string without validation. The list of
|
|
31
|
+
// events that actually fire is observed empirically:
|
|
32
|
+
// - secondchange / minutechange / hourchange / daychange (confirmed)
|
|
33
|
+
// - button events: unconfirmed — see pebble-render.ts wireWatchButtons()
|
|
34
|
+
// for the current best-guess subscription names.
|
|
35
|
+
// ---------------------------------------------------------------------------
|
|
36
|
+
|
|
37
|
+
type WatchTickEvent = 'secondchange' | 'minutechange' | 'hourchange' | 'daychange';
|
|
38
|
+
type WatchButtonEvent = 'button' | 'buttonDown' | 'buttonUp' | 'buttonClick' | 'longClick';
|
|
39
|
+
type WatchEvent = WatchTickEvent | WatchButtonEvent | (string & {});
|
|
40
|
+
|
|
41
|
+
interface WatchButtonPayload {
|
|
42
|
+
/** Which hardware button — empirically unknown; cast at use site. */
|
|
43
|
+
button?: 'up' | 'down' | 'select' | 'back' | string;
|
|
44
|
+
[key: string]: unknown;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
interface ModdableWatch {
|
|
48
|
+
addEventListener(event: WatchEvent, handler: (payload?: WatchButtonPayload) => void): void;
|
|
49
|
+
removeEventListener(event: WatchEvent, handler: (payload?: WatchButtonPayload) => void): void;
|
|
50
|
+
/** Unexplained method on the prototype — possibly the internal dispatch path. */
|
|
51
|
+
do?: (...args: unknown[]) => unknown;
|
|
52
|
+
/** Connection / pairing state — unexplored. */
|
|
53
|
+
connected?: unknown;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
declare const watch: ModdableWatch | undefined;
|
|
57
|
+
|
|
58
|
+
// ---------------------------------------------------------------------------
|
|
59
|
+
// `trace` — low-level log function Moddable provides alongside `console`.
|
|
60
|
+
// ---------------------------------------------------------------------------
|
|
61
|
+
|
|
62
|
+
declare function trace(message: string): void;
|
|
63
|
+
|
|
64
|
+
// ---------------------------------------------------------------------------
|
|
65
|
+
// Module declarations for Moddable / Commodetto imports.
|
|
66
|
+
// These resolve at runtime via the Moddable manifest.json `modules` section.
|
|
67
|
+
// Kept ambient (no top-level import/export) so they augment TS's module
|
|
68
|
+
// resolution without requiring /// <reference> directives.
|
|
69
|
+
// ---------------------------------------------------------------------------
|
|
70
|
+
|
|
71
|
+
declare module 'commodetto/Poco' {
|
|
72
|
+
/** Integer color handle produced by `Poco.prototype.makeColor`. */
|
|
73
|
+
export type PocoColor = number;
|
|
74
|
+
|
|
75
|
+
/** Opaque font resource. Construction is platform-specific. */
|
|
76
|
+
export interface PocoFont {
|
|
77
|
+
readonly height: number;
|
|
78
|
+
[key: string]: unknown;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** Opaque bitmap resource. */
|
|
82
|
+
export interface PocoBitmap {
|
|
83
|
+
readonly width: number;
|
|
84
|
+
readonly height: number;
|
|
85
|
+
[key: string]: unknown;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export default class Poco {
|
|
89
|
+
constructor(
|
|
90
|
+
pixelsOut: ModdableScreen | unknown,
|
|
91
|
+
options?: { displayListLength?: number; rotation?: 0 | 90 | 180 | 270 },
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
readonly width: number;
|
|
95
|
+
readonly height: number;
|
|
96
|
+
|
|
97
|
+
begin(x?: number, y?: number, width?: number, height?: number): void;
|
|
98
|
+
end(continueFrame?: boolean): void;
|
|
99
|
+
continue(x: number, y: number, width: number, height: number): void;
|
|
100
|
+
|
|
101
|
+
clip(x?: number, y?: number, width?: number, height?: number): void;
|
|
102
|
+
origin(x?: number, y?: number): void;
|
|
103
|
+
|
|
104
|
+
makeColor(r: number, g: number, b: number): PocoColor;
|
|
105
|
+
|
|
106
|
+
fillRectangle(color: PocoColor, x: number, y: number, width: number, height: number): void;
|
|
107
|
+
blendRectangle(
|
|
108
|
+
color: PocoColor,
|
|
109
|
+
blend: number,
|
|
110
|
+
x: number,
|
|
111
|
+
y: number,
|
|
112
|
+
width: number,
|
|
113
|
+
height: number,
|
|
114
|
+
): void;
|
|
115
|
+
drawPixel(color: PocoColor, x: number, y: number): void;
|
|
116
|
+
|
|
117
|
+
drawBitmap(
|
|
118
|
+
bits: PocoBitmap,
|
|
119
|
+
x: number,
|
|
120
|
+
y: number,
|
|
121
|
+
sx?: number,
|
|
122
|
+
sy?: number,
|
|
123
|
+
sw?: number,
|
|
124
|
+
sh?: number,
|
|
125
|
+
): void;
|
|
126
|
+
|
|
127
|
+
drawMonochrome(
|
|
128
|
+
monochrome: PocoBitmap,
|
|
129
|
+
fore: PocoColor,
|
|
130
|
+
back: PocoColor | undefined,
|
|
131
|
+
x: number,
|
|
132
|
+
y: number,
|
|
133
|
+
sx?: number,
|
|
134
|
+
sy?: number,
|
|
135
|
+
sw?: number,
|
|
136
|
+
sh?: number,
|
|
137
|
+
): void;
|
|
138
|
+
|
|
139
|
+
drawText(text: string, font: PocoFont, color: PocoColor, x: number, y: number): void;
|
|
140
|
+
getTextWidth(text: string, font: PocoFont): number;
|
|
141
|
+
|
|
142
|
+
/** Font constructor — available on Poco instances as `render.Font`. */
|
|
143
|
+
readonly Font: new (name: string, size: number) => PocoFont;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
declare module 'commodetto/PocoCore' {
|
|
148
|
+
export { default } from 'commodetto/Poco';
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Outline extension module — adds blendOutline / blendPolygon to Poco.prototype.
|
|
152
|
+
// Importing this module has the side-effect of installing those methods.
|
|
153
|
+
declare module 'commodetto/outline/PocoOutline' {
|
|
154
|
+
const _default: Readonly<Record<string, never>>;
|
|
155
|
+
export default _default;
|
|
156
|
+
}
|