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,585 @@
|
|
|
1
|
+
import { PLATFORMS as e, SCREEN as t, _setPlatform as n } from "./platform.js";
|
|
2
|
+
import { ButtonRegistry as r, PebbleAppContext as i, useApp as a, useButton as o, useFormattedTime as s, useInterval as c, useListNavigation as l, useLongButton as u, useTime as d } from "./hooks.js";
|
|
3
|
+
import { ActionBar as f, Badge as p, Card as m, Circle as h, Group as g, Image as _, Line as v, Rect as y, StatusBar as b, Text as x, Window as S } from "./components.js";
|
|
4
|
+
import { render as C } from "preact";
|
|
5
|
+
//#region src/pebble-dom.ts
|
|
6
|
+
var w = new Set([
|
|
7
|
+
"pbl-root",
|
|
8
|
+
"pbl-rect",
|
|
9
|
+
"pbl-circle",
|
|
10
|
+
"pbl-text",
|
|
11
|
+
"pbl-line",
|
|
12
|
+
"pbl-image",
|
|
13
|
+
"pbl-group",
|
|
14
|
+
"pbl-statusbar",
|
|
15
|
+
"pbl-actionbar"
|
|
16
|
+
]), T = 1;
|
|
17
|
+
function E(e) {
|
|
18
|
+
return {
|
|
19
|
+
id: T++,
|
|
20
|
+
type: e,
|
|
21
|
+
props: {},
|
|
22
|
+
children: [],
|
|
23
|
+
parent: null,
|
|
24
|
+
onRender: null,
|
|
25
|
+
onComputeLayout: null,
|
|
26
|
+
_dirty: !0
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function D(e) {
|
|
30
|
+
return {
|
|
31
|
+
id: T++,
|
|
32
|
+
type: "#text",
|
|
33
|
+
value: e,
|
|
34
|
+
parent: null
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function O(e, t) {
|
|
38
|
+
t.parent && A(t.parent, t), t.parent = e, e.children.push(t);
|
|
39
|
+
}
|
|
40
|
+
function k(e, t, n) {
|
|
41
|
+
t.parent && A(t.parent, t), t.parent = e;
|
|
42
|
+
let r = e.children.indexOf(n);
|
|
43
|
+
r >= 0 ? e.children.splice(r, 0, t) : e.children.push(t);
|
|
44
|
+
}
|
|
45
|
+
function A(e, t) {
|
|
46
|
+
e.children = e.children.filter((e) => e !== t), t.parent = null;
|
|
47
|
+
}
|
|
48
|
+
function j(e, t, n) {
|
|
49
|
+
n === void 0 ? delete e.props[t] : e.props[t] = n;
|
|
50
|
+
}
|
|
51
|
+
function M(e, t) {
|
|
52
|
+
e.value = t;
|
|
53
|
+
}
|
|
54
|
+
function N(e) {
|
|
55
|
+
return e.type === "#text" ? e.value : e.children.map(N).join("");
|
|
56
|
+
}
|
|
57
|
+
function P(e, t, n = 0) {
|
|
58
|
+
if (t(e, n), e.type !== "#text") for (let r of e.children) P(r, t, n + 1);
|
|
59
|
+
}
|
|
60
|
+
function F(e) {
|
|
61
|
+
let t = e;
|
|
62
|
+
for (; t.parent;) t = t.parent;
|
|
63
|
+
return t;
|
|
64
|
+
}
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region src/pebble-output.ts
|
|
67
|
+
var I = {
|
|
68
|
+
black: {
|
|
69
|
+
r: 0,
|
|
70
|
+
g: 0,
|
|
71
|
+
b: 0
|
|
72
|
+
},
|
|
73
|
+
white: {
|
|
74
|
+
r: 255,
|
|
75
|
+
g: 255,
|
|
76
|
+
b: 255
|
|
77
|
+
},
|
|
78
|
+
red: {
|
|
79
|
+
r: 255,
|
|
80
|
+
g: 0,
|
|
81
|
+
b: 0
|
|
82
|
+
},
|
|
83
|
+
green: {
|
|
84
|
+
r: 0,
|
|
85
|
+
g: 255,
|
|
86
|
+
b: 0
|
|
87
|
+
},
|
|
88
|
+
blue: {
|
|
89
|
+
r: 0,
|
|
90
|
+
g: 0,
|
|
91
|
+
b: 255
|
|
92
|
+
},
|
|
93
|
+
yellow: {
|
|
94
|
+
r: 255,
|
|
95
|
+
g: 255,
|
|
96
|
+
b: 0
|
|
97
|
+
},
|
|
98
|
+
orange: {
|
|
99
|
+
r: 255,
|
|
100
|
+
g: 128,
|
|
101
|
+
b: 0
|
|
102
|
+
},
|
|
103
|
+
cyan: {
|
|
104
|
+
r: 0,
|
|
105
|
+
g: 255,
|
|
106
|
+
b: 255
|
|
107
|
+
},
|
|
108
|
+
magenta: {
|
|
109
|
+
r: 255,
|
|
110
|
+
g: 0,
|
|
111
|
+
b: 255
|
|
112
|
+
},
|
|
113
|
+
clear: {
|
|
114
|
+
r: 0,
|
|
115
|
+
g: 0,
|
|
116
|
+
b: 0
|
|
117
|
+
},
|
|
118
|
+
lightGray: {
|
|
119
|
+
r: 192,
|
|
120
|
+
g: 192,
|
|
121
|
+
b: 192
|
|
122
|
+
},
|
|
123
|
+
darkGray: {
|
|
124
|
+
r: 64,
|
|
125
|
+
g: 64,
|
|
126
|
+
b: 64
|
|
127
|
+
}
|
|
128
|
+
}, L = {
|
|
129
|
+
gothic14: {
|
|
130
|
+
family: "Bitham-Black",
|
|
131
|
+
size: 14
|
|
132
|
+
},
|
|
133
|
+
gothic14Bold: {
|
|
134
|
+
family: "Bitham-Black",
|
|
135
|
+
size: 14
|
|
136
|
+
},
|
|
137
|
+
gothic18: {
|
|
138
|
+
family: "Bitham-Black",
|
|
139
|
+
size: 18
|
|
140
|
+
},
|
|
141
|
+
gothic18Bold: {
|
|
142
|
+
family: "Bitham-Black",
|
|
143
|
+
size: 18
|
|
144
|
+
},
|
|
145
|
+
gothic24: {
|
|
146
|
+
family: "Bitham-Black",
|
|
147
|
+
size: 24
|
|
148
|
+
},
|
|
149
|
+
gothic24Bold: {
|
|
150
|
+
family: "Bitham-Black",
|
|
151
|
+
size: 24
|
|
152
|
+
},
|
|
153
|
+
gothic28: {
|
|
154
|
+
family: "Bitham-Black",
|
|
155
|
+
size: 28
|
|
156
|
+
},
|
|
157
|
+
gothic28Bold: {
|
|
158
|
+
family: "Bitham-Black",
|
|
159
|
+
size: 28
|
|
160
|
+
},
|
|
161
|
+
bitham30Black: {
|
|
162
|
+
family: "Bitham-Black",
|
|
163
|
+
size: 30
|
|
164
|
+
},
|
|
165
|
+
bitham42Bold: {
|
|
166
|
+
family: "Bitham-Black",
|
|
167
|
+
size: 42
|
|
168
|
+
},
|
|
169
|
+
bitham42Light: {
|
|
170
|
+
family: "Bitham-Black",
|
|
171
|
+
size: 42
|
|
172
|
+
},
|
|
173
|
+
bitham34MediumNumbers: {
|
|
174
|
+
family: "Bitham-Black",
|
|
175
|
+
size: 34
|
|
176
|
+
},
|
|
177
|
+
bitham42MediumNumbers: {
|
|
178
|
+
family: "Bitham-Black",
|
|
179
|
+
size: 42
|
|
180
|
+
}
|
|
181
|
+
}, R = "gothic18";
|
|
182
|
+
function z(e, t) {
|
|
183
|
+
let n = e[t];
|
|
184
|
+
return typeof n == "number" ? n : 0;
|
|
185
|
+
}
|
|
186
|
+
function B(e, t) {
|
|
187
|
+
let n = e[t];
|
|
188
|
+
return typeof n == "string" ? n : void 0;
|
|
189
|
+
}
|
|
190
|
+
var V = class {
|
|
191
|
+
poco;
|
|
192
|
+
colorCache = /* @__PURE__ */ new Map();
|
|
193
|
+
fontCache = /* @__PURE__ */ new Map();
|
|
194
|
+
constructor(e) {
|
|
195
|
+
this.poco = e;
|
|
196
|
+
}
|
|
197
|
+
render(e, t = {}) {
|
|
198
|
+
let { poco: n } = this, r = t.dirty;
|
|
199
|
+
r ? n.begin(r.x, r.y, r.w, r.h) : n.begin();
|
|
200
|
+
let i = this.getColor(t.backgroundColor ?? "black");
|
|
201
|
+
n.fillRectangle(i, 0, 0, n.width, n.height), this.renderChildren(e, 0, 0), n.end();
|
|
202
|
+
}
|
|
203
|
+
getColor(e) {
|
|
204
|
+
let t = e ?? "black", n = this.colorCache.get(t);
|
|
205
|
+
if (n !== void 0) return n;
|
|
206
|
+
let r = I[t] ?? I.white, i = this.poco.makeColor(r.r, r.g, r.b);
|
|
207
|
+
return this.colorCache.set(t, i), i;
|
|
208
|
+
}
|
|
209
|
+
getFont(e) {
|
|
210
|
+
let t = e ?? R, n = this.fontCache.get(t);
|
|
211
|
+
if (n !== void 0) return n;
|
|
212
|
+
let r = L[t] ?? L[R], i = this.poco.Font, a = new i(r.family, r.size);
|
|
213
|
+
return this.fontCache.set(t, a), a;
|
|
214
|
+
}
|
|
215
|
+
renderChildren(e, t, n) {
|
|
216
|
+
for (let r of e.children) r.type !== "#text" && this.renderNode(r, t, n);
|
|
217
|
+
}
|
|
218
|
+
renderNode(e, t, n) {
|
|
219
|
+
let r = e.props;
|
|
220
|
+
if (r._hidden) return;
|
|
221
|
+
let i = z(r, "x") + t, a = z(r, "y") + n;
|
|
222
|
+
switch (e.type) {
|
|
223
|
+
case "pbl-rect": {
|
|
224
|
+
let t = z(r, "w") || z(r, "width"), n = z(r, "h") || z(r, "height"), o = B(r, "fill"), s = B(r, "stroke");
|
|
225
|
+
if (o && this.poco.fillRectangle(this.getColor(o), i, a, t, n), s) {
|
|
226
|
+
let e = z(r, "strokeWidth") || 1, o = this.getColor(s);
|
|
227
|
+
this.poco.fillRectangle(o, i, a, t, e), this.poco.fillRectangle(o, i, a + n - e, t, e), this.poco.fillRectangle(o, i, a, e, n), this.poco.fillRectangle(o, i + t - e, a, e, n);
|
|
228
|
+
}
|
|
229
|
+
this.renderChildren(e, i, a);
|
|
230
|
+
break;
|
|
231
|
+
}
|
|
232
|
+
case "pbl-text": {
|
|
233
|
+
let t = N(e);
|
|
234
|
+
if (!t) break;
|
|
235
|
+
let n = z(r, "w") || z(r, "width") || this.poco.width - i, o = this.getFont(B(r, "font")), s = this.getColor(B(r, "color") ?? "white"), c = B(r, "align") ?? "left", l = i;
|
|
236
|
+
if (c === "center" || c === "right") {
|
|
237
|
+
let e = this.poco.getTextWidth(t, o);
|
|
238
|
+
l = c === "center" ? i + Math.floor((n - e) / 2) : i + n - e;
|
|
239
|
+
}
|
|
240
|
+
this.poco.drawText(t, o, s, l, a);
|
|
241
|
+
break;
|
|
242
|
+
}
|
|
243
|
+
case "pbl-line": {
|
|
244
|
+
let e = z(r, "x2") + t, o = z(r, "y2") + n, s = this.getColor(B(r, "color") ?? B(r, "stroke") ?? "white"), c = z(r, "strokeWidth") || 1;
|
|
245
|
+
if (i === e) {
|
|
246
|
+
let e = Math.min(a, o), t = Math.abs(o - a) || 1;
|
|
247
|
+
this.poco.fillRectangle(s, i, e, c, t);
|
|
248
|
+
} else if (a === o) {
|
|
249
|
+
let t = Math.min(i, e), n = Math.abs(e - i) || 1;
|
|
250
|
+
this.poco.fillRectangle(s, t, a, n, c);
|
|
251
|
+
}
|
|
252
|
+
break;
|
|
253
|
+
}
|
|
254
|
+
case "pbl-circle": break;
|
|
255
|
+
case "pbl-image": {
|
|
256
|
+
let e = r.bitmap;
|
|
257
|
+
e && this.poco.drawBitmap(e, i, a);
|
|
258
|
+
break;
|
|
259
|
+
}
|
|
260
|
+
case "pbl-group":
|
|
261
|
+
this.renderChildren(e, i, a);
|
|
262
|
+
break;
|
|
263
|
+
case "pbl-statusbar":
|
|
264
|
+
case "pbl-actionbar": break;
|
|
265
|
+
case "pbl-root":
|
|
266
|
+
this.renderChildren(e, t, n);
|
|
267
|
+
break;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
function H(e) {
|
|
272
|
+
return e && e in I ? e : "black";
|
|
273
|
+
}
|
|
274
|
+
function U(e) {
|
|
275
|
+
return e && e in L ? e : R;
|
|
276
|
+
}
|
|
277
|
+
//#endregion
|
|
278
|
+
//#region src/pebble-dom-shim.ts
|
|
279
|
+
function W(e) {
|
|
280
|
+
let t = e.childNodes;
|
|
281
|
+
e.firstChild = t[0] ?? null;
|
|
282
|
+
for (let n = 0; n < t.length; n++) {
|
|
283
|
+
let r = t[n];
|
|
284
|
+
r.parentNode = e, r.nextSibling = t[n + 1] ?? null;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
function G(e) {
|
|
288
|
+
let t = e;
|
|
289
|
+
if (!w.has(t)) throw Error(`react-pebble: unknown element tag "${e}"`);
|
|
290
|
+
let n = E(t);
|
|
291
|
+
return {
|
|
292
|
+
nodeType: 1,
|
|
293
|
+
nodeName: e.toUpperCase(),
|
|
294
|
+
localName: e,
|
|
295
|
+
tagName: e.toUpperCase(),
|
|
296
|
+
_pbl: n,
|
|
297
|
+
attributes: {},
|
|
298
|
+
parentNode: null,
|
|
299
|
+
childNodes: [],
|
|
300
|
+
firstChild: null,
|
|
301
|
+
nextSibling: null,
|
|
302
|
+
appendChild(e) {
|
|
303
|
+
return e.parentNode && e.parentNode.removeChild(e), this.childNodes.push(e), O(n, e._pbl), W(this), e;
|
|
304
|
+
},
|
|
305
|
+
insertBefore(e, t) {
|
|
306
|
+
if (e.parentNode && e.parentNode.removeChild(e), t === null) return this.appendChild(e);
|
|
307
|
+
let r = this.childNodes.indexOf(t);
|
|
308
|
+
return r < 0 ? this.appendChild(e) : (this.childNodes.splice(r, 0, e), k(n, e._pbl, t._pbl), W(this), e);
|
|
309
|
+
},
|
|
310
|
+
removeChild(e) {
|
|
311
|
+
let t = this.childNodes.indexOf(e);
|
|
312
|
+
return t >= 0 && this.childNodes.splice(t, 1), A(n, e._pbl), e.parentNode = null, e.nextSibling = null, W(this), e;
|
|
313
|
+
},
|
|
314
|
+
remove() {
|
|
315
|
+
this.parentNode && this.parentNode.removeChild(this);
|
|
316
|
+
},
|
|
317
|
+
setAttribute(e, t) {
|
|
318
|
+
this.attributes[e] = t, j(n, e, t);
|
|
319
|
+
},
|
|
320
|
+
removeAttribute(e) {
|
|
321
|
+
delete this.attributes[e], j(n, e, void 0);
|
|
322
|
+
},
|
|
323
|
+
getAttribute(e) {
|
|
324
|
+
return this.attributes[e];
|
|
325
|
+
},
|
|
326
|
+
addEventListener(e, t) {
|
|
327
|
+
let r = `on${e[0]?.toUpperCase()}${e.slice(1)}`;
|
|
328
|
+
this.attributes[r] = t, j(n, r, t);
|
|
329
|
+
},
|
|
330
|
+
removeEventListener(e, t) {
|
|
331
|
+
let r = `on${e[0]?.toUpperCase()}${e.slice(1)}`;
|
|
332
|
+
delete this.attributes[r], j(n, r, void 0);
|
|
333
|
+
}
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
function K(e) {
|
|
337
|
+
let t = D(e), n = {
|
|
338
|
+
nodeType: 3,
|
|
339
|
+
nodeName: "#text",
|
|
340
|
+
_pbl: t,
|
|
341
|
+
data: e,
|
|
342
|
+
nodeValue: e,
|
|
343
|
+
textContent: e,
|
|
344
|
+
parentNode: null,
|
|
345
|
+
childNodes: [],
|
|
346
|
+
firstChild: null,
|
|
347
|
+
nextSibling: null
|
|
348
|
+
};
|
|
349
|
+
return Object.defineProperty(n, "data", {
|
|
350
|
+
get() {
|
|
351
|
+
return t.value;
|
|
352
|
+
},
|
|
353
|
+
set(e) {
|
|
354
|
+
M(t, e);
|
|
355
|
+
}
|
|
356
|
+
}), Object.defineProperty(n, "nodeValue", {
|
|
357
|
+
get() {
|
|
358
|
+
return t.value;
|
|
359
|
+
},
|
|
360
|
+
set(e) {
|
|
361
|
+
M(t, e);
|
|
362
|
+
}
|
|
363
|
+
}), Object.defineProperty(n, "textContent", {
|
|
364
|
+
get() {
|
|
365
|
+
return t.value;
|
|
366
|
+
},
|
|
367
|
+
set(e) {
|
|
368
|
+
M(t, e);
|
|
369
|
+
}
|
|
370
|
+
}), n;
|
|
371
|
+
}
|
|
372
|
+
var q = {
|
|
373
|
+
createElement: G,
|
|
374
|
+
createElementNS: (e, t) => G(t),
|
|
375
|
+
createTextNode: K
|
|
376
|
+
};
|
|
377
|
+
function J() {
|
|
378
|
+
let e = G("pbl-root");
|
|
379
|
+
return e.ownerDocument = q, e;
|
|
380
|
+
}
|
|
381
|
+
//#endregion
|
|
382
|
+
//#region src/pebble-reconciler.ts
|
|
383
|
+
typeof document > "u" && (globalThis.document = q);
|
|
384
|
+
function Y() {
|
|
385
|
+
let e = J();
|
|
386
|
+
return {
|
|
387
|
+
shimRoot: e,
|
|
388
|
+
pblRoot: e._pbl
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
function X(e, t) {
|
|
392
|
+
C(e, t.shimRoot);
|
|
393
|
+
}
|
|
394
|
+
function Z(e) {
|
|
395
|
+
C(null, e.shimRoot);
|
|
396
|
+
}
|
|
397
|
+
var Q = {
|
|
398
|
+
createContainer: Y,
|
|
399
|
+
updateContainer: X,
|
|
400
|
+
unmountContainer: Z
|
|
401
|
+
}, $ = class {
|
|
402
|
+
width;
|
|
403
|
+
height;
|
|
404
|
+
Font;
|
|
405
|
+
constructor(e, t, n) {
|
|
406
|
+
this.log = n, this.width = e, this.height = t, this.Font = class {
|
|
407
|
+
name;
|
|
408
|
+
size;
|
|
409
|
+
height;
|
|
410
|
+
constructor(e, t) {
|
|
411
|
+
this.name = e, this.size = t, this.height = t;
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
begin(e, t, n, r) {
|
|
416
|
+
this.log.push({
|
|
417
|
+
op: "begin",
|
|
418
|
+
x: e,
|
|
419
|
+
y: t,
|
|
420
|
+
width: n,
|
|
421
|
+
height: r
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
end() {
|
|
425
|
+
this.log.push({ op: "end" });
|
|
426
|
+
}
|
|
427
|
+
continue(e, t, n, r) {
|
|
428
|
+
this.log.push({
|
|
429
|
+
op: "continue",
|
|
430
|
+
x: e,
|
|
431
|
+
y: t,
|
|
432
|
+
width: n,
|
|
433
|
+
height: r
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
clip(e, t, n, r) {
|
|
437
|
+
this.log.push({
|
|
438
|
+
op: "clip",
|
|
439
|
+
x: e,
|
|
440
|
+
y: t,
|
|
441
|
+
width: n,
|
|
442
|
+
height: r
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
origin(e, t) {
|
|
446
|
+
this.log.push({
|
|
447
|
+
op: "origin",
|
|
448
|
+
x: e,
|
|
449
|
+
y: t
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
makeColor(e, t, n) {
|
|
453
|
+
return (e & 255) << 16 | (t & 255) << 8 | n & 255;
|
|
454
|
+
}
|
|
455
|
+
fillRectangle(e, t, n, r, i) {
|
|
456
|
+
this.log.push({
|
|
457
|
+
op: "fillRectangle",
|
|
458
|
+
color: e,
|
|
459
|
+
x: t,
|
|
460
|
+
y: n,
|
|
461
|
+
width: r,
|
|
462
|
+
height: i
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
blendRectangle(e, t, n, r, i, a) {
|
|
466
|
+
this.log.push({
|
|
467
|
+
op: "blendRectangle",
|
|
468
|
+
color: e,
|
|
469
|
+
blend: t,
|
|
470
|
+
x: n,
|
|
471
|
+
y: r,
|
|
472
|
+
width: i,
|
|
473
|
+
height: a
|
|
474
|
+
});
|
|
475
|
+
}
|
|
476
|
+
drawPixel(e, t, n) {
|
|
477
|
+
this.log.push({
|
|
478
|
+
op: "drawPixel",
|
|
479
|
+
color: e,
|
|
480
|
+
x: t,
|
|
481
|
+
y: n
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
drawBitmap(e, t, n) {
|
|
485
|
+
this.log.push({
|
|
486
|
+
op: "drawBitmap",
|
|
487
|
+
x: t,
|
|
488
|
+
y: n
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
drawMonochrome(e, t, n, r, i) {
|
|
492
|
+
this.log.push({
|
|
493
|
+
op: "drawMonochrome",
|
|
494
|
+
fore: t,
|
|
495
|
+
back: n,
|
|
496
|
+
x: r,
|
|
497
|
+
y: i
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
drawText(e, t, n, r, i) {
|
|
501
|
+
this.log.push({
|
|
502
|
+
op: "drawText",
|
|
503
|
+
text: e,
|
|
504
|
+
font: t,
|
|
505
|
+
color: n,
|
|
506
|
+
x: r,
|
|
507
|
+
y: i
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
getTextWidth(e, t) {
|
|
511
|
+
let n = t.size ?? 14;
|
|
512
|
+
return Math.round(e.length * n * .6);
|
|
513
|
+
}
|
|
514
|
+
};
|
|
515
|
+
function ee(e, t) {
|
|
516
|
+
return typeof screen < "u" && screen && t ? {
|
|
517
|
+
poco: new t(screen),
|
|
518
|
+
info: {
|
|
519
|
+
isReal: !0,
|
|
520
|
+
platform: "alloy",
|
|
521
|
+
screenWidth: screen.width,
|
|
522
|
+
screenHeight: screen.height
|
|
523
|
+
}
|
|
524
|
+
} : {
|
|
525
|
+
poco: new $(200, 228, e),
|
|
526
|
+
info: {
|
|
527
|
+
isReal: !1,
|
|
528
|
+
platform: "mock",
|
|
529
|
+
screenWidth: 200,
|
|
530
|
+
screenHeight: 228
|
|
531
|
+
}
|
|
532
|
+
};
|
|
533
|
+
}
|
|
534
|
+
function te() {
|
|
535
|
+
if (typeof watch > "u" || !watch) return () => void 0;
|
|
536
|
+
let e = (e) => {
|
|
537
|
+
if (typeof e != "string") return;
|
|
538
|
+
let t = e.toLowerCase();
|
|
539
|
+
if (t === "up" || t === "down" || t === "select" || t === "back") return t;
|
|
540
|
+
}, t = (t) => {
|
|
541
|
+
let n = e(t?.button);
|
|
542
|
+
n && r.emit(n);
|
|
543
|
+
}, n = (t) => {
|
|
544
|
+
let n = e(t?.button);
|
|
545
|
+
n && r.emit(`long_${n}`);
|
|
546
|
+
};
|
|
547
|
+
return watch.addEventListener("button", t), watch.addEventListener("buttonClick", t), watch.addEventListener("longClick", n), () => {
|
|
548
|
+
typeof watch > "u" || !watch || (watch.removeEventListener("button", t), watch.removeEventListener("buttonClick", t), watch.removeEventListener("longClick", n));
|
|
549
|
+
};
|
|
550
|
+
}
|
|
551
|
+
function ne(e) {
|
|
552
|
+
typeof Promise < "u" ? Promise.resolve().then(e) : setTimeout(e, 0);
|
|
553
|
+
}
|
|
554
|
+
function re(e, t = {}) {
|
|
555
|
+
let n = [], r = Y(), { poco: i, info: a } = ee(n, t.poco), o = new V(i), s = !1, c = () => {
|
|
556
|
+
s = !1, n.length = 0, o.render(r.pblRoot, { backgroundColor: t.backgroundColor });
|
|
557
|
+
}, l = () => {
|
|
558
|
+
s || (s = !0, ne(c));
|
|
559
|
+
}, u = t, d = u._commit ?? u.__c, f = (e, t) => {
|
|
560
|
+
d && d(e, t), l();
|
|
561
|
+
};
|
|
562
|
+
u._commit = f, u.__c = f, X(e, r), c();
|
|
563
|
+
let p = te();
|
|
564
|
+
return {
|
|
565
|
+
update(e) {
|
|
566
|
+
X(e, r), l();
|
|
567
|
+
},
|
|
568
|
+
unmount() {
|
|
569
|
+
Z(r), u._commit = d, u.__c = d, p();
|
|
570
|
+
},
|
|
571
|
+
get platform() {
|
|
572
|
+
return a;
|
|
573
|
+
},
|
|
574
|
+
get drawLog() {
|
|
575
|
+
return n;
|
|
576
|
+
},
|
|
577
|
+
get _root() {
|
|
578
|
+
return r.pblRoot;
|
|
579
|
+
}
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
//#endregion
|
|
583
|
+
export { f as ActionBar, p as Badge, r as ButtonRegistry, I as COLOR_PALETTE, m as Card, h as Circle, w as ELEMENT_TYPES, L as FONT_PALETTE, g as Group, _ as Image, v as Line, e as PLATFORMS, i as PebbleAppContext, V as PocoRenderer, y as Rect, t as SCREEN, b as StatusBar, x as Text, S as Window, n as _setPlatform, O as appendChildNode, E as createNode, D as createTextNode, F as findRoot, N as getTextContent, k as insertBeforeNode, Q as reconciler, A as removeChildNode, re as render, H as resolveColorName, U as resolveFontName, j as setAttribute, M as setTextNodeValue, a as useApp, o as useButton, s as useFormattedTime, c as useInterval, l as useListNavigation, u as useLongButton, d as useTime, P as walkTree };
|
|
584
|
+
|
|
585
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/pebble-dom.ts","../../src/pebble-output.ts","../../src/pebble-dom-shim.ts","../../src/pebble-reconciler.ts","../../src/pebble-render.ts"],"sourcesContent":["/**\n * pebble-dom.ts — Virtual DOM layer for React Pebble\n *\n * Modeled after Ink's dom.ts but stripped of Yoga layout.\n * Pebble uses absolute positioning (x, y, w, h) rather than flexbox,\n * so nodes are just plain JS objects with type, props, and children.\n *\n * Each node type maps to a Pebble drawing primitive:\n * pbl-root → Container root (the Window)\n * pbl-rect → fillRect / drawRect\n * pbl-circle → fillCircle / drawCircle\n * pbl-text → drawText\n * pbl-line → drawLine\n * pbl-image → drawImage (bitmap)\n * pbl-group → Logical grouping with offset (no draw call)\n * #text → Raw text content (only valid inside pbl-text)\n */\n\n// ---------------------------------------------------------------------------\n// Element types\n// ---------------------------------------------------------------------------\n\nexport type ElementType =\n | 'pbl-root'\n | 'pbl-rect'\n | 'pbl-circle'\n | 'pbl-text'\n | 'pbl-line'\n | 'pbl-image'\n | 'pbl-group'\n | 'pbl-statusbar'\n | 'pbl-actionbar';\n\nexport const ELEMENT_TYPES: ReadonlySet<ElementType> = new Set<ElementType>([\n 'pbl-root',\n 'pbl-rect',\n 'pbl-circle',\n 'pbl-text',\n 'pbl-line',\n 'pbl-image',\n 'pbl-group',\n 'pbl-statusbar',\n 'pbl-actionbar',\n]);\n\n// ---------------------------------------------------------------------------\n// Node shapes\n// ---------------------------------------------------------------------------\n\n/**\n * Loose prop bag — element-specific shapes are documented on each component\n * wrapper, but the reconciler treats them uniformly.\n */\nexport type NodeProps = Record<string, unknown> & {\n _hidden?: boolean;\n};\n\nexport interface DOMElement {\n id: number;\n type: ElementType;\n props: NodeProps;\n children: Array<DOMElement | TextNode>;\n parent: DOMElement | null;\n /** Called by the reconciler after each commit; wired up by `render()`. */\n onRender: (() => void) | null;\n /** Optional layout pass; we currently don't use this. */\n onComputeLayout: (() => void) | null;\n /** Internal dirty flag (currently informational only). */\n _dirty: boolean;\n}\n\nexport interface TextNode {\n id: number;\n type: '#text';\n value: string;\n parent: DOMElement | null;\n /** Saved value while the node is hidden by Suspense. */\n _hiddenValue?: string;\n}\n\nexport type AnyNode = DOMElement | TextNode;\n\n// ---------------------------------------------------------------------------\n// Node creation\n// ---------------------------------------------------------------------------\n\nlet nextNodeId = 1;\n\nexport function createNode(type: ElementType): DOMElement {\n return {\n id: nextNodeId++,\n type,\n props: {},\n children: [],\n parent: null,\n onRender: null,\n onComputeLayout: null,\n _dirty: true,\n };\n}\n\nexport function createTextNode(text: string): TextNode {\n return {\n id: nextNodeId++,\n type: '#text',\n value: text,\n parent: null,\n };\n}\n\n// ---------------------------------------------------------------------------\n// Tree manipulation\n// ---------------------------------------------------------------------------\n\nexport function appendChildNode(parent: DOMElement, child: AnyNode): void {\n if (child.parent) {\n removeChildNode(child.parent, child);\n }\n child.parent = parent;\n parent.children.push(child);\n}\n\nexport function insertBeforeNode(\n parent: DOMElement,\n child: AnyNode,\n beforeChild: AnyNode,\n): void {\n if (child.parent) {\n removeChildNode(child.parent, child);\n }\n child.parent = parent;\n const idx = parent.children.indexOf(beforeChild);\n if (idx >= 0) {\n parent.children.splice(idx, 0, child);\n } else {\n parent.children.push(child);\n }\n}\n\nexport function removeChildNode(parent: DOMElement, child: AnyNode): void {\n parent.children = parent.children.filter((c) => c !== child);\n child.parent = null;\n}\n\n// ---------------------------------------------------------------------------\n// Property / attribute helpers\n// ---------------------------------------------------------------------------\n\nexport function setAttribute(node: DOMElement, key: string, value: unknown): void {\n if (value === undefined) {\n delete node.props[key];\n } else {\n node.props[key] = value;\n }\n}\n\nexport function setTextNodeValue(node: TextNode, text: string): void {\n node.value = text;\n}\n\n// ---------------------------------------------------------------------------\n// Tree traversal helpers\n// ---------------------------------------------------------------------------\n\nexport function getTextContent(node: AnyNode): string {\n if (node.type === '#text') {\n return node.value;\n }\n return node.children.map(getTextContent).join('');\n}\n\nexport type Visitor = (node: AnyNode, depth: number) => void;\n\nexport function walkTree(root: AnyNode, visitor: Visitor, depth = 0): void {\n visitor(root, depth);\n if (root.type !== '#text') {\n for (const child of root.children) {\n walkTree(child, visitor, depth + 1);\n }\n }\n}\n\nexport function findRoot(node: AnyNode): DOMElement {\n let current: AnyNode = node;\n while (current.parent) {\n current = current.parent;\n }\n // The root is always a DOMElement (created via createNode).\n return current as DOMElement;\n}\n","/**\n * pebble-output.ts — Poco output layer for react-pebble on Pebble Alloy.\n *\n * Walks the virtual DOM tree (pebble-dom) and issues draw calls against\n * a `commodetto/Poco` renderer, which writes into the watch framebuffer.\n *\n * Key differences from a canvas-style API:\n *\n * - **No stateful color or font.** Every draw call takes the color (an int\n * produced by `poco.makeColor(r, g, b)`) and font (a `new poco.Font(...)`\n * object) as arguments. We maintain per-Poco caches so we resolve each\n * named color / font exactly once.\n * - **No native line, circle, or stroked rectangle.** Poco only has\n * `fillRectangle`, `drawText`, and bitmap draws. Outlines (stroke) are\n * emulated as four thin fillRectangles. Axis-aligned lines likewise.\n * Circles and diagonal lines would need the `commodetto/outline` extension\n * — they're currently stubbed (TODO for a later pass).\n * - **Text alignment is manual.** `drawText(text, font, color, x, y)` only\n * draws at a point. For center/right alignment we measure with\n * `getTextWidth` and compute the origin ourselves.\n */\n\nimport type Poco from 'commodetto/Poco';\nimport type { PocoColor, PocoFont } from 'commodetto/Poco';\nimport type { DOMElement, NodeProps } from './pebble-dom.js';\nimport { getTextContent } from './pebble-dom.js';\n\n// ---------------------------------------------------------------------------\n// Named palette — mapped to RGB, then resolved to PocoColor via a cache.\n// ---------------------------------------------------------------------------\n\nexport interface RGB {\n r: number;\n g: number;\n b: number;\n}\n\nexport const COLOR_PALETTE: Readonly<Record<string, RGB>> = {\n black: { r: 0, g: 0, b: 0 },\n white: { r: 255, g: 255, b: 255 },\n red: { r: 255, g: 0, b: 0 },\n green: { r: 0, g: 255, b: 0 },\n blue: { r: 0, g: 0, b: 255 },\n yellow: { r: 255, g: 255, b: 0 },\n orange: { r: 255, g: 128, b: 0 },\n cyan: { r: 0, g: 255, b: 255 },\n magenta: { r: 255, g: 0, b: 255 },\n clear: { r: 0, g: 0, b: 0 },\n lightGray: { r: 192, g: 192, b: 192 },\n darkGray: { r: 64, g: 64, b: 64 },\n};\n\n// ---------------------------------------------------------------------------\n// Named font shortcuts — mapped to (family, size) pairs.\n//\n// The family names here need to match fonts available in the Moddable\n// manifest. The Alloy scaffold ships \"Bitham-Black\" as a default — we use\n// it for every logical font for now. Revisit once we add custom font\n// resources to the library manifest.\n// ---------------------------------------------------------------------------\n\nexport interface FontSpec {\n family: string;\n size: number;\n}\n\nexport const FONT_PALETTE: Readonly<Record<string, FontSpec>> = {\n gothic14: { family: 'Bitham-Black', size: 14 },\n gothic14Bold: { family: 'Bitham-Black', size: 14 },\n gothic18: { family: 'Bitham-Black', size: 18 },\n gothic18Bold: { family: 'Bitham-Black', size: 18 },\n gothic24: { family: 'Bitham-Black', size: 24 },\n gothic24Bold: { family: 'Bitham-Black', size: 24 },\n gothic28: { family: 'Bitham-Black', size: 28 },\n gothic28Bold: { family: 'Bitham-Black', size: 28 },\n bitham30Black: { family: 'Bitham-Black', size: 30 },\n bitham42Bold: { family: 'Bitham-Black', size: 42 },\n bitham42Light: { family: 'Bitham-Black', size: 42 },\n bitham34MediumNumbers: { family: 'Bitham-Black', size: 34 },\n bitham42MediumNumbers: { family: 'Bitham-Black', size: 42 },\n};\n\nconst DEFAULT_FONT_KEY = 'gothic18';\n\n// ---------------------------------------------------------------------------\n// Prop accessors — the DOM is loosely typed so we coerce here.\n// ---------------------------------------------------------------------------\n\nfunction num(p: NodeProps, key: string): number {\n const v = p[key];\n return typeof v === 'number' ? v : 0;\n}\n\nfunction str(p: NodeProps, key: string): string | undefined {\n const v = p[key];\n return typeof v === 'string' ? v : undefined;\n}\n\n// ---------------------------------------------------------------------------\n// Renderer options\n// ---------------------------------------------------------------------------\n\nexport interface RenderOptions {\n backgroundColor?: string;\n /**\n * Incremental update region. If provided, `poco.begin(x, y, w, h)` is used\n * to clip drawing to just that region. Otherwise the full frame is redrawn.\n */\n dirty?: { x: number; y: number; w: number; h: number };\n}\n\n// ---------------------------------------------------------------------------\n// PocoRenderer — owns a Poco instance plus color/font caches\n// ---------------------------------------------------------------------------\n\nexport class PocoRenderer {\n readonly poco: Poco;\n private readonly colorCache = new Map<string, PocoColor>();\n private readonly fontCache = new Map<string, PocoFont>();\n\n constructor(poco: Poco) {\n this.poco = poco;\n }\n\n /**\n * Render the full tree into a fresh frame.\n */\n render(rootNode: DOMElement, options: RenderOptions = {}): void {\n const { poco } = this;\n const dirty = options.dirty;\n\n if (dirty) {\n poco.begin(dirty.x, dirty.y, dirty.w, dirty.h);\n } else {\n poco.begin();\n }\n\n // Clear to background\n const bg = this.getColor(options.backgroundColor ?? 'black');\n poco.fillRectangle(bg, 0, 0, poco.width, poco.height);\n\n // Walk the tree\n this.renderChildren(rootNode, 0, 0);\n\n poco.end();\n }\n\n /** Resolve a color name (or pass-through int) to a PocoColor. */\n getColor(name: string | undefined): PocoColor {\n const key = name ?? 'black';\n const cached = this.colorCache.get(key);\n if (cached !== undefined) return cached;\n\n const rgb = COLOR_PALETTE[key] ?? COLOR_PALETTE.white!;\n const color = this.poco.makeColor(rgb.r, rgb.g, rgb.b);\n this.colorCache.set(key, color);\n return color;\n }\n\n /** Resolve a font name to a PocoFont (cached). */\n getFont(name: string | undefined): PocoFont {\n const key = name ?? DEFAULT_FONT_KEY;\n const cached = this.fontCache.get(key);\n if (cached !== undefined) return cached;\n\n const spec = FONT_PALETTE[key] ?? FONT_PALETTE[DEFAULT_FONT_KEY]!;\n // `poco.Font` is a constructor hanging off the Poco instance.\n const FontCtor = this.poco.Font;\n const font = new FontCtor(spec.family, spec.size);\n this.fontCache.set(key, font);\n return font;\n }\n\n // -------------------------------------------------------------------------\n // Private: node renderers\n // -------------------------------------------------------------------------\n\n private renderChildren(node: DOMElement, ox: number, oy: number): void {\n for (const child of node.children) {\n if (child.type === '#text') continue;\n this.renderNode(child, ox, oy);\n }\n }\n\n private renderNode(node: DOMElement, ox: number, oy: number): void {\n const p = node.props;\n if (p._hidden) return;\n\n const x = num(p, 'x') + ox;\n const y = num(p, 'y') + oy;\n\n switch (node.type) {\n case 'pbl-rect': {\n const w = num(p, 'w') || num(p, 'width');\n const h = num(p, 'h') || num(p, 'height');\n const fill = str(p, 'fill');\n const stroke = str(p, 'stroke');\n\n if (fill) {\n this.poco.fillRectangle(this.getColor(fill), x, y, w, h);\n }\n if (stroke) {\n // Emulate outline with four thin fill rects.\n const sw = num(p, 'strokeWidth') || 1;\n const c = this.getColor(stroke);\n this.poco.fillRectangle(c, x, y, w, sw); // top\n this.poco.fillRectangle(c, x, y + h - sw, w, sw); // bottom\n this.poco.fillRectangle(c, x, y, sw, h); // left\n this.poco.fillRectangle(c, x + w - sw, y, sw, h); // right\n }\n\n this.renderChildren(node, x, y);\n break;\n }\n\n case 'pbl-text': {\n const text = getTextContent(node);\n if (!text) break;\n\n const boxW = num(p, 'w') || num(p, 'width') || this.poco.width - x;\n const font = this.getFont(str(p, 'font'));\n const color = this.getColor(str(p, 'color') ?? 'white');\n const align = str(p, 'align') ?? 'left';\n\n let tx = x;\n if (align === 'center' || align === 'right') {\n const tw = this.poco.getTextWidth(text, font);\n if (align === 'center') {\n tx = x + Math.floor((boxW - tw) / 2);\n } else {\n tx = x + boxW - tw;\n }\n }\n\n this.poco.drawText(text, font, color, tx, y);\n break;\n }\n\n case 'pbl-line': {\n // Only axis-aligned lines are supported natively. Diagonals would\n // need the commodetto/outline extension — TODO.\n const x2 = num(p, 'x2') + ox;\n const y2 = num(p, 'y2') + oy;\n const c = this.getColor(str(p, 'color') ?? str(p, 'stroke') ?? 'white');\n const sw = num(p, 'strokeWidth') || 1;\n\n if (x === x2) {\n // Vertical\n const top = Math.min(y, y2);\n const h = Math.abs(y2 - y) || 1;\n this.poco.fillRectangle(c, x, top, sw, h);\n } else if (y === y2) {\n // Horizontal\n const left = Math.min(x, x2);\n const w = Math.abs(x2 - x) || 1;\n this.poco.fillRectangle(c, left, y, w, sw);\n }\n // else: diagonal line — silently skipped for now\n break;\n }\n\n case 'pbl-circle': {\n // TODO: implement via commodetto/outline extension (blendOutline)\n // or a Bresenham-style approximation. Stubbed for now.\n break;\n }\n\n case 'pbl-image': {\n const bitmap = p.bitmap;\n if (bitmap) {\n this.poco.drawBitmap(bitmap as never, x, y);\n }\n break;\n }\n\n case 'pbl-group': {\n this.renderChildren(node, x, y);\n break;\n }\n\n case 'pbl-statusbar':\n case 'pbl-actionbar': {\n // Alloy has no built-in status/action bar UI; these are no-ops for now.\n // An app that wants a status bar should draw its own.\n break;\n }\n\n case 'pbl-root': {\n this.renderChildren(node, ox, oy);\n break;\n }\n }\n }\n}\n\n// ---------------------------------------------------------------------------\n// Compatibility shims — still useful for mock-mode tests that want to\n// resolve a color name without constructing a Poco. These return *names*\n// rather than native handles.\n// ---------------------------------------------------------------------------\n\nexport function resolveColorName(color: string | undefined): string {\n if (!color) return 'black';\n return color in COLOR_PALETTE ? color : 'black';\n}\n\nexport function resolveFontName(font: string | undefined): string {\n if (!font) return DEFAULT_FONT_KEY;\n return font in FONT_PALETTE ? font : DEFAULT_FONT_KEY;\n}\n","/**\n * pebble-dom-shim.ts — A minimal DOM-like adapter over `pebble-dom` so\n * Preact's `render(vnode, parentDom)` can drive it.\n *\n * Preact's diff loop mutates a tree of DOM-shaped nodes by calling:\n * - document.createElement(tag)\n * - document.createTextNode(text)\n * - parent.appendChild(child), .insertBefore(child, ref), .removeChild(child)\n * - element.setAttribute(name, value), .removeAttribute(name)\n * - element.addEventListener(name, handler), .removeEventListener(...)\n * - element.nodeType, .nodeName, .parentNode, .childNodes, .firstChild,\n * .nextSibling\n *\n * This file implements the minimum surface Preact actually touches when\n * rendering into a headless tree. Each \"element\" carries a reference to the\n * underlying pebble-dom node so the renderer can walk both views\n * interchangeably.\n *\n * The shim is deliberately NOT a full undom — it only does what Preact 10\n * needs. If we trip on a missing method, add it here rather than including\n * undom (which would push the bundle back up).\n */\n\nimport type { AnyNode, DOMElement, ElementType, TextNode } from './pebble-dom.js';\nimport {\n ELEMENT_TYPES,\n appendChildNode,\n createNode,\n createTextNode,\n insertBeforeNode,\n removeChildNode,\n setAttribute,\n setTextNodeValue,\n} from './pebble-dom.js';\n\n// ---------------------------------------------------------------------------\n// DOM node interfaces the shim exposes to Preact\n// ---------------------------------------------------------------------------\n\ninterface ShimNodeBase {\n readonly nodeType: number;\n nodeName: string;\n parentNode: ShimElement | null;\n childNodes: ShimNode[];\n firstChild: ShimNode | null;\n nextSibling: ShimNode | null;\n /** The backing pebble-dom node. */\n readonly _pbl: AnyNode;\n}\n\nexport interface ShimElement extends ShimNodeBase {\n readonly nodeType: 1;\n readonly localName: string;\n readonly tagName: string;\n readonly _pbl: DOMElement;\n attributes: Record<string, unknown>;\n\n appendChild<T extends ShimNode>(child: T): T;\n insertBefore<T extends ShimNode>(child: T, ref: ShimNode | null): T;\n removeChild<T extends ShimNode>(child: T): T;\n remove(): void;\n\n setAttribute(name: string, value: unknown): void;\n removeAttribute(name: string): void;\n getAttribute(name: string): unknown;\n\n addEventListener(name: string, handler: (...args: unknown[]) => unknown): void;\n removeEventListener(name: string, handler: (...args: unknown[]) => unknown): void;\n}\n\nexport interface ShimText extends ShimNodeBase {\n readonly nodeType: 3;\n readonly _pbl: TextNode;\n data: string;\n nodeValue: string;\n textContent: string;\n}\n\nexport type ShimNode = ShimElement | ShimText;\n\n// ---------------------------------------------------------------------------\n// Shim factories\n// ---------------------------------------------------------------------------\n\nfunction linkSiblings(parent: ShimElement): void {\n const kids = parent.childNodes;\n parent.firstChild = kids[0] ?? null;\n for (let i = 0; i < kids.length; i++) {\n const node = kids[i]!;\n node.parentNode = parent;\n node.nextSibling = kids[i + 1] ?? null;\n }\n}\n\nexport function createShimElement(tag: string): ShimElement {\n // Accept both 'pbl-rect' and friendly aliases from components. Unknown\n // tags are rejected loudly so typos surface at render time.\n const pblType = tag as ElementType;\n if (!ELEMENT_TYPES.has(pblType)) {\n throw new Error(`react-pebble: unknown element tag \"${tag}\"`);\n }\n\n const pbl = createNode(pblType);\n\n const el: ShimElement = {\n nodeType: 1,\n nodeName: tag.toUpperCase(),\n localName: tag,\n tagName: tag.toUpperCase(),\n _pbl: pbl,\n attributes: {},\n parentNode: null,\n childNodes: [],\n firstChild: null,\n nextSibling: null,\n\n appendChild(child) {\n // Detach from any prior parent in the shim view\n if (child.parentNode) {\n child.parentNode.removeChild(child);\n }\n this.childNodes.push(child);\n appendChildNode(pbl, child._pbl);\n linkSiblings(this);\n return child;\n },\n\n insertBefore(child, ref) {\n if (child.parentNode) {\n child.parentNode.removeChild(child);\n }\n if (ref === null) {\n return this.appendChild(child);\n }\n const idx = this.childNodes.indexOf(ref);\n if (idx < 0) {\n return this.appendChild(child);\n }\n this.childNodes.splice(idx, 0, child);\n insertBeforeNode(pbl, child._pbl, ref._pbl);\n linkSiblings(this);\n return child;\n },\n\n removeChild(child) {\n const idx = this.childNodes.indexOf(child);\n if (idx >= 0) {\n this.childNodes.splice(idx, 1);\n }\n removeChildNode(pbl, child._pbl);\n child.parentNode = null;\n child.nextSibling = null;\n linkSiblings(this);\n return child;\n },\n\n remove() {\n if (this.parentNode) {\n this.parentNode.removeChild(this);\n }\n },\n\n setAttribute(name, value) {\n this.attributes[name] = value;\n setAttribute(pbl, name, value);\n },\n\n removeAttribute(name) {\n delete this.attributes[name];\n setAttribute(pbl, name, undefined);\n },\n\n getAttribute(name) {\n return this.attributes[name];\n },\n\n addEventListener(name, handler) {\n // Event handlers are stored in props (on* style) so the button wiring\n // in pebble-render.ts can find them the same way React props do.\n const key = `on${name[0]?.toUpperCase()}${name.slice(1)}`;\n this.attributes[key] = handler;\n setAttribute(pbl, key, handler);\n },\n\n removeEventListener(name, _handler) {\n const key = `on${name[0]?.toUpperCase()}${name.slice(1)}`;\n delete this.attributes[key];\n setAttribute(pbl, key, undefined);\n },\n };\n\n return el;\n}\n\nexport function createShimText(data: string): ShimText {\n const pbl = createTextNode(data);\n\n const node: ShimText = {\n nodeType: 3,\n nodeName: '#text',\n _pbl: pbl,\n data,\n nodeValue: data,\n textContent: data,\n parentNode: null,\n childNodes: [],\n firstChild: null,\n nextSibling: null,\n };\n\n // Keep pebble-dom in sync whenever data/nodeValue/textContent is assigned.\n // Preact mutates `.data` directly on text updates.\n Object.defineProperty(node, 'data', {\n get() {\n return pbl.value;\n },\n set(next: string) {\n setTextNodeValue(pbl, next);\n },\n });\n Object.defineProperty(node, 'nodeValue', {\n get() {\n return pbl.value;\n },\n set(next: string) {\n setTextNodeValue(pbl, next);\n },\n });\n Object.defineProperty(node, 'textContent', {\n get() {\n return pbl.value;\n },\n set(next: string) {\n setTextNodeValue(pbl, next);\n },\n });\n\n return node;\n}\n\n// ---------------------------------------------------------------------------\n// Shim \"document\" — what Preact reaches via `parentDom.ownerDocument` etc.\n// ---------------------------------------------------------------------------\n\nexport interface ShimDocument {\n createElement(tag: string): ShimElement;\n createElementNS(ns: string | null, tag: string): ShimElement;\n createTextNode(data: string): ShimText;\n}\n\nexport const shimDocument: ShimDocument = {\n createElement: createShimElement,\n createElementNS: (_ns, tag) => createShimElement(tag),\n createTextNode: createShimText,\n};\n\n// ---------------------------------------------------------------------------\n// Root container — the \"parent DOM\" handed to preact.render().\n// ---------------------------------------------------------------------------\n\nexport function createShimRoot(): ShimElement {\n const root = createShimElement('pbl-root');\n // Preact reads `ownerDocument` off the parent.\n (root as unknown as { ownerDocument: ShimDocument }).ownerDocument = shimDocument;\n return root;\n}\n","/**\n * pebble-reconciler.ts — Preact-backed reconciler for react-pebble.\n *\n * Replaces the old react-reconciler host config. We don't need a custom\n * reconciler at all with Preact — Preact's `render(vnode, parentDom)` does\n * the diffing, and we provide a DOM-shaped container via `pebble-dom-shim`\n * so Preact writes into our pebble-dom tree instead of a real DOM.\n *\n * The public surface (for pebble-render.ts) is:\n * - createReconcilerContainer() → a pair of root shim + pebble-dom root\n * - updateContainer(vnode, container) → runs preact.render()\n * - unmountContainer(container) → runs preact.render(null, ...)\n */\n\nimport { render as preactRender } from 'preact';\nimport type { ComponentChild } from 'preact';\nimport type { DOMElement } from './pebble-dom.js';\nimport { createShimRoot, shimDocument } from './pebble-dom-shim.js';\nimport type { ShimElement } from './pebble-dom-shim.js';\n\n// Preact's render() references `document` internally. In non-browser\n// environments (Node mock mode, Alloy XS) we shim it with our pebble-dom\n// adapter so Preact doesn't crash.\nif (typeof document === 'undefined') {\n (globalThis as unknown as { document: unknown }).document = shimDocument;\n}\n\nexport interface PebbleContainer {\n shimRoot: ShimElement;\n pblRoot: DOMElement;\n}\n\nexport function createContainer(): PebbleContainer {\n const shimRoot = createShimRoot();\n return {\n shimRoot,\n pblRoot: shimRoot._pbl,\n };\n}\n\nexport function updateContainer(vnode: ComponentChild, container: PebbleContainer): void {\n preactRender(vnode, container.shimRoot as unknown as Element);\n}\n\nexport function unmountContainer(container: PebbleContainer): void {\n preactRender(null, container.shimRoot as unknown as Element);\n}\n\n// For backwards-compat with the old default export pattern.\nexport default {\n createContainer,\n updateContainer,\n unmountContainer,\n};\n","/**\n * pebble-render.ts — Entry point for react-pebble on Pebble Alloy.\n *\n * Bridges Preact's output (via a DOM-shim over pebble-dom) to Moddable's\n * Poco renderer, which draws into the watch framebuffer. Also hosts the\n * Node mock path used for unit tests and local development.\n *\n * Platform detection is via `typeof screen`:\n * - screen exists → Alloy/XS runtime → real Poco draws\n * - screen undefined → Node → mock Poco records calls to an in-memory log\n */\n\nimport { options } from 'preact';\nimport type { ComponentChild } from 'preact';\nimport type Poco from 'commodetto/Poco';\nimport type { PocoBitmap, PocoColor, PocoFont } from 'commodetto/Poco';\nimport type { DOMElement } from './pebble-dom.js';\nimport { PocoRenderer } from './pebble-output.js';\nimport type { PebbleButton, PebbleButtonHandler } from './hooks/index.js';\nimport { ButtonRegistry } from './hooks/index.js';\nimport type { PebbleContainer } from './pebble-reconciler.js';\nimport {\n createContainer,\n updateContainer,\n unmountContainer,\n} from './pebble-reconciler.js';\n\n// ---------------------------------------------------------------------------\n// Public types\n// ---------------------------------------------------------------------------\n\nexport interface PebblePlatformInfo {\n isReal: boolean;\n platform: 'alloy' | 'mock';\n screenWidth: number;\n screenHeight: number;\n}\n\nexport interface DrawCall {\n op: string;\n [key: string]: unknown;\n}\n\nexport interface RenderOptions {\n backgroundColor?: string;\n}\n\nexport interface PebbleApp {\n update(newElement: ComponentChild): void;\n unmount(): void;\n readonly platform: PebblePlatformInfo;\n readonly drawLog: readonly DrawCall[];\n readonly _root: DOMElement;\n}\n\n// ---------------------------------------------------------------------------\n// Mock Poco — records every draw call into a shared log so tests can assert.\n// ---------------------------------------------------------------------------\n\nclass MockPoco {\n readonly width: number;\n readonly height: number;\n readonly Font: new (name: string, size: number) => PocoFont;\n\n constructor(width: number, height: number, private readonly log: DrawCall[]) {\n this.width = width;\n this.height = height;\n const FontImpl = class {\n readonly name: string;\n readonly size: number;\n readonly height: number;\n constructor(name: string, size: number) {\n this.name = name;\n this.size = size;\n this.height = size;\n }\n };\n this.Font = FontImpl as unknown as new (name: string, size: number) => PocoFont;\n }\n\n begin(x?: number, y?: number, width?: number, height?: number): void {\n this.log.push({ op: 'begin', x, y, width, height });\n }\n end(): void {\n this.log.push({ op: 'end' });\n }\n continue(x: number, y: number, width: number, height: number): void {\n this.log.push({ op: 'continue', x, y, width, height });\n }\n clip(x?: number, y?: number, width?: number, height?: number): void {\n this.log.push({ op: 'clip', x, y, width, height });\n }\n origin(x?: number, y?: number): void {\n this.log.push({ op: 'origin', x, y });\n }\n\n makeColor(r: number, g: number, b: number): PocoColor {\n return ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff);\n }\n\n fillRectangle(color: PocoColor, x: number, y: number, width: number, height: number): void {\n this.log.push({ op: 'fillRectangle', color, x, y, width, height });\n }\n blendRectangle(\n color: PocoColor,\n blend: number,\n x: number,\n y: number,\n width: number,\n height: number,\n ): void {\n this.log.push({ op: 'blendRectangle', color, blend, x, y, width, height });\n }\n drawPixel(color: PocoColor, x: number, y: number): void {\n this.log.push({ op: 'drawPixel', color, x, y });\n }\n drawBitmap(_bits: PocoBitmap, x: number, y: number): void {\n this.log.push({ op: 'drawBitmap', x, y });\n }\n drawMonochrome(\n _monochrome: PocoBitmap,\n fore: PocoColor,\n back: PocoColor | undefined,\n x: number,\n y: number,\n ): void {\n this.log.push({ op: 'drawMonochrome', fore, back, x, y });\n }\n\n drawText(text: string, font: PocoFont, color: PocoColor, x: number, y: number): void {\n this.log.push({ op: 'drawText', text, font, color, x, y });\n }\n getTextWidth(text: string, font: PocoFont): number {\n const size = (font as unknown as { size?: number }).size ?? 14;\n return Math.round(text.length * size * 0.6);\n }\n}\n\n// ---------------------------------------------------------------------------\n// Poco construction — real on Alloy, mock in Node\n// ---------------------------------------------------------------------------\n\nfunction createPoco(\n log: DrawCall[],\n pocoCtor: typeof Poco | undefined,\n): { poco: Poco; info: PebblePlatformInfo } {\n if (typeof screen !== 'undefined' && screen && pocoCtor) {\n const poco = new pocoCtor(screen);\n return {\n poco,\n info: {\n isReal: true,\n platform: 'alloy',\n screenWidth: screen.width,\n screenHeight: screen.height,\n },\n };\n }\n\n const width = 200;\n const height = 228;\n const mock = new MockPoco(width, height, log);\n return {\n poco: mock as unknown as Poco,\n info: {\n isReal: false,\n platform: 'mock',\n screenWidth: width,\n screenHeight: height,\n },\n };\n}\n\n// ---------------------------------------------------------------------------\n// Button wiring — see moddable.d.ts for the known/unknown event names.\n// ---------------------------------------------------------------------------\n\nfunction wireWatchButtons(): () => void {\n if (typeof watch === 'undefined' || !watch) return () => undefined;\n\n const normalize = (raw: unknown): PebbleButton | undefined => {\n if (typeof raw !== 'string') return undefined;\n const low = raw.toLowerCase();\n if (low === 'up' || low === 'down' || low === 'select' || low === 'back') {\n return low;\n }\n return undefined;\n };\n\n const onShort = (payload?: { button?: unknown }) => {\n const b = normalize(payload?.button);\n if (b) ButtonRegistry.emit(b);\n };\n const onLong = (payload?: { button?: unknown }) => {\n const b = normalize(payload?.button);\n if (b) ButtonRegistry.emit(`long_${b}`);\n };\n\n watch.addEventListener('button', onShort);\n watch.addEventListener('buttonClick', onShort);\n watch.addEventListener('longClick', onLong);\n\n return () => {\n if (typeof watch === 'undefined' || !watch) return;\n watch.removeEventListener('button', onShort);\n watch.removeEventListener('buttonClick', onShort);\n watch.removeEventListener('longClick', onLong);\n };\n}\n\n// ---------------------------------------------------------------------------\n// Redraw scheduling\n//\n// Preact renders are synchronous; when any component calls setState, Preact\n// re-runs the diff and mutates the shim tree in place. We hook into that\n// by scheduling a Poco redraw on the next tick.\n// ---------------------------------------------------------------------------\n\nfunction scheduleMicrotask(fn: () => void): void {\n // Prefer Promise.resolve().then for microtask batching; fall back to\n // setTimeout(0) if Promise isn't wired up in some host.\n if (typeof Promise !== 'undefined') {\n Promise.resolve().then(fn);\n } else {\n setTimeout(fn, 0);\n }\n}\n\n// ---------------------------------------------------------------------------\n// Public render API\n// ---------------------------------------------------------------------------\n\nexport interface RenderOptionsExt extends RenderOptions {\n /**\n * Pre-imported Poco constructor. Alloy entry files must import Poco at\n * the top and pass it here so the Moddable bundler resolves it correctly.\n */\n poco?: typeof Poco;\n}\n\nexport function render(element: ComponentChild, options: RenderOptionsExt = {}): PebbleApp {\n const drawLog: DrawCall[] = [];\n const container: PebbleContainer = createContainer();\n const { poco, info } = createPoco(drawLog, options.poco);\n const renderer = new PocoRenderer(poco);\n\n let pending = false;\n const redraw = () => {\n pending = false;\n drawLog.length = 0;\n renderer.render(container.pblRoot, { backgroundColor: options.backgroundColor });\n };\n\n const schedule = () => {\n if (pending) return;\n pending = true;\n scheduleMicrotask(redraw);\n };\n\n // Monkey-patch the shim root to redraw on any mutation.\n // Preact calls appendChild/insertBefore/removeChild/setAttribute on the\n // tree during diff; we only need to schedule a redraw when the diff\n // settles, which is right after the top-level render() call returns.\n // For that we just trigger a redraw synchronously after updateContainer.\n\n // Hook Preact's commit phase so hook-driven state updates trigger a redraw\n // without polling. options._commit is an undocumented-but-stable hook that\n // fires once per root-level diff settle.\n type PreactOptionsWithCommit = typeof options & {\n _commit?: (root: unknown, queue: unknown[]) => void;\n __c?: (root: unknown, queue: unknown[]) => void;\n };\n const opts = options as PreactOptionsWithCommit;\n const prevCommit = opts._commit ?? opts.__c;\n const commitHook = (root: unknown, queue: unknown[]) => {\n if (prevCommit) prevCommit(root, queue);\n schedule();\n };\n opts._commit = commitHook;\n opts.__c = commitHook;\n\n updateContainer(element, container);\n // Always paint once on mount.\n redraw();\n\n // Subscribe to watch events on-device.\n const unwireButtons = wireWatchButtons();\n\n return {\n update(newElement) {\n updateContainer(newElement, container);\n schedule();\n },\n unmount() {\n unmountContainer(container);\n // Restore prior commit hook (in case another app was rendered).\n opts._commit = prevCommit;\n opts.__c = prevCommit;\n unwireButtons();\n },\n get platform() {\n return info;\n },\n get drawLog() {\n return drawLog as readonly DrawCall[];\n },\n get _root() {\n return container.pblRoot;\n },\n };\n}\n"],"mappings":";;;;;AAiCA,IAAa,IAA0C,IAAI,IAAiB;CAC1E;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC,EA2CE,IAAa;AAEjB,SAAgB,EAAW,GAA+B;AACxD,QAAO;EACL,IAAI;EACJ;EACA,OAAO,EAAE;EACT,UAAU,EAAE;EACZ,QAAQ;EACR,UAAU;EACV,iBAAiB;EACjB,QAAQ;EACT;;AAGH,SAAgB,EAAe,GAAwB;AACrD,QAAO;EACL,IAAI;EACJ,MAAM;EACN,OAAO;EACP,QAAQ;EACT;;AAOH,SAAgB,EAAgB,GAAoB,GAAsB;AAKxE,CAJI,EAAM,UACR,EAAgB,EAAM,QAAQ,EAAM,EAEtC,EAAM,SAAS,GACf,EAAO,SAAS,KAAK,EAAM;;AAG7B,SAAgB,EACd,GACA,GACA,GACM;AAIN,CAHI,EAAM,UACR,EAAgB,EAAM,QAAQ,EAAM,EAEtC,EAAM,SAAS;CACf,IAAM,IAAM,EAAO,SAAS,QAAQ,EAAY;AAChD,CAAI,KAAO,IACT,EAAO,SAAS,OAAO,GAAK,GAAG,EAAM,GAErC,EAAO,SAAS,KAAK,EAAM;;AAI/B,SAAgB,EAAgB,GAAoB,GAAsB;AAExE,CADA,EAAO,WAAW,EAAO,SAAS,QAAQ,MAAM,MAAM,EAAM,EAC5D,EAAM,SAAS;;AAOj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MACrB,QAAQ,SAAS,CAAC,KAAK,EAAG,GAE1B,WAAW,GAAI,EAAE;;AAgBrB,SAAgB,GAAO,GAAyB,IAA4B,EAAE,EAAa;CACzF,IAAM,IAAsB,EAAE,EACxB,IAA6B,GAAiB,EAC9C,EAAE,SAAM,YAAS,GAAW,GAAS,EAAQ,KAAK,EAClD,IAAW,IAAI,EAAa,EAAK,EAEnC,IAAU,IACR,UAAe;AAGnB,EAFA,IAAU,IACV,EAAQ,SAAS,GACjB,EAAS,OAAO,EAAU,SAAS,EAAE,iBAAiB,EAAQ,iBAAiB,CAAC;IAG5E,UAAiB;AACjB,QACJ,IAAU,IACV,GAAkB,EAAO;IAgBrB,IAAO,GACP,IAAa,EAAK,WAAW,EAAK,KAClC,KAAc,GAAe,MAAqB;AAEtD,EADI,KAAY,EAAW,GAAM,EAAM,EACvC,GAAU;;AAOZ,CALA,EAAK,UAAU,GACf,EAAK,MAAM,GAEX,EAAgB,GAAS,EAAU,EAEnC,GAAQ;CAGR,IAAM,IAAgB,IAAkB;AAExC,QAAO;EACL,OAAO,GAAY;AAEjB,GADA,EAAgB,GAAY,EAAU,EACtC,GAAU;;EAEZ,UAAU;AAKR,GAJA,EAAiB,EAAU,EAE3B,EAAK,UAAU,GACf,EAAK,MAAM,GACX,GAAe;;EAEjB,IAAI,WAAW;AACb,UAAO;;EAET,IAAI,UAAU;AACZ,UAAO;;EAET,IAAI,QAAQ;AACV,UAAO,EAAU;;EAEpB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e={emery:{name:`emery`,width:200,height:228,isRound:!1},gabbro:{name:`gabbro`,width:200,height:228,isRound:!1},basalt:{name:`basalt`,width:144,height:168,isRound:!1},chalk:{name:`chalk`,width:180,height:180,isRound:!0},diorite:{name:`diorite`,width:144,height:168,isRound:!1},aplite:{name:`aplite`,width:144,height:168,isRound:!1}},t={width:200,height:228,isRound:!1,platform:`emery`};function n(n){let r=e[n];r&&(t.width=r.width,t.height=r.height,t.isRound=r.isRound,t.platform=r.name)}exports.PLATFORMS=e,exports.SCREEN=t,exports._setPlatform=n;
|
|
2
|
+
//# sourceMappingURL=platform.cjs.map
|