react-pebble 0.1.0 → 0.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.
- package/LICENSE +21 -0
- package/dist/lib/compiler.cjs +2 -2
- package/dist/lib/compiler.cjs.map +1 -1
- package/dist/lib/compiler.js +21 -18
- package/dist/lib/compiler.js.map +1 -1
- package/dist/lib/components.cjs +1 -1
- package/dist/lib/components.cjs.map +1 -1
- package/dist/lib/components.js +44 -5
- package/dist/lib/components.js.map +1 -1
- package/dist/lib/hooks.cjs +1 -1
- package/dist/lib/hooks.cjs.map +1 -1
- package/dist/lib/hooks.js +198 -3
- package/dist/lib/hooks.js.map +1 -1
- package/dist/lib/index.cjs +1 -1
- package/dist/lib/index.cjs.map +1 -1
- package/dist/lib/index.js +231 -108
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/plugin.cjs +25 -5
- package/dist/lib/plugin.cjs.map +1 -1
- package/dist/lib/plugin.js +62 -35
- package/dist/lib/plugin.js.map +1 -1
- package/dist/lib/src/compiler/index.d.ts +2 -0
- package/dist/lib/src/components/index.d.ts +28 -1
- package/dist/lib/src/hooks/index.d.ts +182 -0
- package/dist/lib/src/index.d.ts +4 -4
- package/dist/lib/src/pebble-output.d.ts +15 -0
- package/dist/lib/src/plugin/index.d.ts +6 -0
- package/package.json +10 -11
- package/scripts/compile-to-piu.ts +346 -35
- package/scripts/deploy.sh +0 -0
- package/scripts/test-emulator.sh +371 -0
- package/src/compiler/index.ts +11 -3
- package/src/components/index.tsx +75 -1
- package/src/hooks/index.ts +507 -19
- package/src/index.ts +26 -0
- package/src/pebble-output.ts +408 -48
- package/src/plugin/index.ts +101 -49
- package/src/types/moddable.d.ts +26 -4
package/dist/lib/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { PLATFORMS as e, SCREEN as t, _setPlatform as n } from "./platform.js";
|
|
2
|
-
import { ButtonRegistry as r,
|
|
3
|
-
import { ActionBar as
|
|
4
|
-
import { render as
|
|
2
|
+
import { ButtonRegistry as r, Easing as i, PebbleAppContext as a, lerp as o, useAccelerometer as s, useAnimation as c, useApp as l, useBattery as u, useButton as d, useCompass as f, useConnection as p, useFetch as m, useFormattedTime as h, useInterval as g, useKVStorage as _, useListNavigation as v, useLocalStorage as y, useLongButton as b, useTime as x, useWebSocket as S } from "./hooks.js";
|
|
3
|
+
import { ActionBar as ee, Badge as te, Card as ne, Circle as re, Column as C, Group as ie, Image as w, Line as ae, Rect as oe, Row as T, StatusBar as E, Text as D, Window as O } from "./components.js";
|
|
4
|
+
import { render as k } from "preact";
|
|
5
5
|
//#region src/pebble-dom.ts
|
|
6
|
-
var
|
|
6
|
+
var A = new Set([
|
|
7
7
|
"pbl-root",
|
|
8
8
|
"pbl-rect",
|
|
9
9
|
"pbl-circle",
|
|
@@ -13,10 +13,10 @@ var w = new Set([
|
|
|
13
13
|
"pbl-group",
|
|
14
14
|
"pbl-statusbar",
|
|
15
15
|
"pbl-actionbar"
|
|
16
|
-
]),
|
|
17
|
-
function
|
|
16
|
+
]), j = 1;
|
|
17
|
+
function M(e) {
|
|
18
18
|
return {
|
|
19
|
-
id:
|
|
19
|
+
id: j++,
|
|
20
20
|
type: e,
|
|
21
21
|
props: {},
|
|
22
22
|
children: [],
|
|
@@ -26,45 +26,45 @@ function E(e) {
|
|
|
26
26
|
_dirty: !0
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
|
-
function
|
|
29
|
+
function N(e) {
|
|
30
30
|
return {
|
|
31
|
-
id:
|
|
31
|
+
id: j++,
|
|
32
32
|
type: "#text",
|
|
33
33
|
value: e,
|
|
34
34
|
parent: null
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
|
-
function
|
|
38
|
-
t.parent &&
|
|
37
|
+
function P(e, t) {
|
|
38
|
+
t.parent && I(t.parent, t), t.parent = e, e.children.push(t);
|
|
39
39
|
}
|
|
40
|
-
function
|
|
41
|
-
t.parent &&
|
|
40
|
+
function F(e, t, n) {
|
|
41
|
+
t.parent && I(t.parent, t), t.parent = e;
|
|
42
42
|
let r = e.children.indexOf(n);
|
|
43
43
|
r >= 0 ? e.children.splice(r, 0, t) : e.children.push(t);
|
|
44
44
|
}
|
|
45
|
-
function
|
|
45
|
+
function I(e, t) {
|
|
46
46
|
e.children = e.children.filter((e) => e !== t), t.parent = null;
|
|
47
47
|
}
|
|
48
|
-
function
|
|
48
|
+
function L(e, t, n) {
|
|
49
49
|
n === void 0 ? delete e.props[t] : e.props[t] = n;
|
|
50
50
|
}
|
|
51
|
-
function
|
|
51
|
+
function R(e, t) {
|
|
52
52
|
e.value = t;
|
|
53
53
|
}
|
|
54
|
-
function
|
|
55
|
-
return e.type === "#text" ? e.value : e.children.map(
|
|
54
|
+
function z(e) {
|
|
55
|
+
return e.type === "#text" ? e.value : e.children.map(z).join("");
|
|
56
56
|
}
|
|
57
|
-
function
|
|
58
|
-
if (t(e, n), e.type !== "#text") for (let r of e.children)
|
|
57
|
+
function B(e, t, n = 0) {
|
|
58
|
+
if (t(e, n), e.type !== "#text") for (let r of e.children) B(r, t, n + 1);
|
|
59
59
|
}
|
|
60
|
-
function
|
|
60
|
+
function V(e) {
|
|
61
61
|
let t = e;
|
|
62
62
|
for (; t.parent;) t = t.parent;
|
|
63
63
|
return t;
|
|
64
64
|
}
|
|
65
65
|
//#endregion
|
|
66
66
|
//#region src/pebble-output.ts
|
|
67
|
-
var
|
|
67
|
+
var H = {
|
|
68
68
|
black: {
|
|
69
69
|
r: 0,
|
|
70
70
|
g: 0,
|
|
@@ -125,37 +125,37 @@ var I = {
|
|
|
125
125
|
g: 64,
|
|
126
126
|
b: 64
|
|
127
127
|
}
|
|
128
|
-
},
|
|
128
|
+
}, U = {
|
|
129
129
|
gothic14: {
|
|
130
|
-
family: "
|
|
130
|
+
family: "Gothic",
|
|
131
131
|
size: 14
|
|
132
132
|
},
|
|
133
133
|
gothic14Bold: {
|
|
134
|
-
family: "
|
|
134
|
+
family: "Gothic-Bold",
|
|
135
135
|
size: 14
|
|
136
136
|
},
|
|
137
137
|
gothic18: {
|
|
138
|
-
family: "
|
|
138
|
+
family: "Gothic",
|
|
139
139
|
size: 18
|
|
140
140
|
},
|
|
141
141
|
gothic18Bold: {
|
|
142
|
-
family: "
|
|
142
|
+
family: "Gothic-Bold",
|
|
143
143
|
size: 18
|
|
144
144
|
},
|
|
145
145
|
gothic24: {
|
|
146
|
-
family: "
|
|
146
|
+
family: "Gothic",
|
|
147
147
|
size: 24
|
|
148
148
|
},
|
|
149
149
|
gothic24Bold: {
|
|
150
|
-
family: "
|
|
150
|
+
family: "Gothic-Bold",
|
|
151
151
|
size: 24
|
|
152
152
|
},
|
|
153
153
|
gothic28: {
|
|
154
|
-
family: "
|
|
154
|
+
family: "Gothic",
|
|
155
155
|
size: 28
|
|
156
156
|
},
|
|
157
157
|
gothic28Bold: {
|
|
158
|
-
family: "
|
|
158
|
+
family: "Gothic-Bold",
|
|
159
159
|
size: 28
|
|
160
160
|
},
|
|
161
161
|
bitham30Black: {
|
|
@@ -163,31 +163,71 @@ var I = {
|
|
|
163
163
|
size: 30
|
|
164
164
|
},
|
|
165
165
|
bitham42Bold: {
|
|
166
|
-
family: "Bitham-
|
|
166
|
+
family: "Bitham-Bold",
|
|
167
167
|
size: 42
|
|
168
168
|
},
|
|
169
169
|
bitham42Light: {
|
|
170
|
-
family: "Bitham-
|
|
170
|
+
family: "Bitham-Light",
|
|
171
171
|
size: 42
|
|
172
172
|
},
|
|
173
173
|
bitham34MediumNumbers: {
|
|
174
|
-
family: "Bitham
|
|
174
|
+
family: "Bitham",
|
|
175
175
|
size: 34
|
|
176
176
|
},
|
|
177
177
|
bitham42MediumNumbers: {
|
|
178
|
-
family: "Bitham
|
|
178
|
+
family: "Bitham",
|
|
179
|
+
size: 42
|
|
180
|
+
},
|
|
181
|
+
robotoCondensed21: {
|
|
182
|
+
family: "Roboto-Condensed",
|
|
183
|
+
size: 21
|
|
184
|
+
},
|
|
185
|
+
roboto21: {
|
|
186
|
+
family: "Roboto",
|
|
187
|
+
size: 21
|
|
188
|
+
},
|
|
189
|
+
droid28: {
|
|
190
|
+
family: "Droid-Serif",
|
|
191
|
+
size: 28
|
|
192
|
+
},
|
|
193
|
+
leco20: {
|
|
194
|
+
family: "LECO",
|
|
195
|
+
size: 20
|
|
196
|
+
},
|
|
197
|
+
leco26: {
|
|
198
|
+
family: "LECO",
|
|
199
|
+
size: 26
|
|
200
|
+
},
|
|
201
|
+
leco28: {
|
|
202
|
+
family: "LECO",
|
|
203
|
+
size: 28
|
|
204
|
+
},
|
|
205
|
+
leco32: {
|
|
206
|
+
family: "LECO",
|
|
207
|
+
size: 32
|
|
208
|
+
},
|
|
209
|
+
leco36: {
|
|
210
|
+
family: "LECO",
|
|
211
|
+
size: 36
|
|
212
|
+
},
|
|
213
|
+
leco38: {
|
|
214
|
+
family: "LECO",
|
|
215
|
+
size: 38
|
|
216
|
+
},
|
|
217
|
+
leco42: {
|
|
218
|
+
family: "LECO",
|
|
179
219
|
size: 42
|
|
180
220
|
}
|
|
181
|
-
},
|
|
182
|
-
function
|
|
221
|
+
}, W = "gothic18";
|
|
222
|
+
function G(e, t) {
|
|
183
223
|
let n = e[t];
|
|
184
224
|
return typeof n == "number" ? n : 0;
|
|
185
225
|
}
|
|
186
|
-
function
|
|
226
|
+
function K(e, t) {
|
|
187
227
|
let n = e[t];
|
|
188
228
|
return typeof n == "string" ? n : void 0;
|
|
189
229
|
}
|
|
190
|
-
var
|
|
230
|
+
var q = class {
|
|
191
231
|
poco;
|
|
192
232
|
colorCache = /* @__PURE__ */ new Map();
|
|
193
233
|
fontCache = /* @__PURE__ */ new Map();
|
|
@@ -203,13 +243,13 @@ var V = class {
|
|
|
203
243
|
getColor(e) {
|
|
204
244
|
let t = e ?? "black", n = this.colorCache.get(t);
|
|
205
245
|
if (n !== void 0) return n;
|
|
206
|
-
let r =
|
|
246
|
+
let r = H[t] ?? H.white, i = this.poco.makeColor(r.r, r.g, r.b);
|
|
207
247
|
return this.colorCache.set(t, i), i;
|
|
208
248
|
}
|
|
209
249
|
getFont(e) {
|
|
210
|
-
let t = e ??
|
|
250
|
+
let t = e ?? W, n = this.fontCache.get(t);
|
|
211
251
|
if (n !== void 0) return n;
|
|
212
|
-
let r =
|
|
252
|
+
let r = U[t] ?? U[W], i = this.poco.Font, a = new i(r.family, r.size);
|
|
213
253
|
return this.fontCache.set(t, a), a;
|
|
214
254
|
}
|
|
215
255
|
renderChildren(e, t, n) {
|
|
@@ -218,65 +258,148 @@ var V = class {
|
|
|
218
258
|
renderNode(e, t, n) {
|
|
219
259
|
let r = e.props;
|
|
220
260
|
if (r._hidden) return;
|
|
221
|
-
let i =
|
|
261
|
+
let i = G(r, "x") + t, a = G(r, "y") + n;
|
|
222
262
|
switch (e.type) {
|
|
223
263
|
case "pbl-rect": {
|
|
224
|
-
let t =
|
|
225
|
-
if (
|
|
226
|
-
|
|
264
|
+
let t = G(r, "w") || G(r, "width"), n = G(r, "h") || G(r, "height"), o = K(r, "fill"), s = K(r, "stroke"), c = G(r, "borderRadius");
|
|
265
|
+
if (c > 0) {
|
|
266
|
+
if (o && this.fillRoundRect(this.getColor(o), i, a, t, n, c), s) {
|
|
267
|
+
let e = G(r, "strokeWidth") || 1;
|
|
268
|
+
this.strokeRoundRect(this.getColor(s), i, a, t, n, c, e);
|
|
269
|
+
}
|
|
270
|
+
} else if (o && this.poco.fillRectangle(this.getColor(o), i, a, t, n), s) {
|
|
271
|
+
let e = G(r, "strokeWidth") || 1, o = this.getColor(s);
|
|
227
272
|
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
273
|
}
|
|
229
274
|
this.renderChildren(e, i, a);
|
|
230
275
|
break;
|
|
231
276
|
}
|
|
232
277
|
case "pbl-text": {
|
|
233
|
-
let t =
|
|
278
|
+
let t = z(e);
|
|
234
279
|
if (!t) break;
|
|
235
|
-
let n =
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
280
|
+
let n = G(r, "w") || G(r, "width") || this.poco.width - i, o = G(r, "h") || G(r, "height") || 0, s = this.getFont(K(r, "font")), c = this.getColor(K(r, "color") ?? "white"), l = K(r, "align") ?? "left", u = s.height || 16, d = this.wrapText(t, s, n), f = a;
|
|
281
|
+
for (let e of d) {
|
|
282
|
+
if (o > 0 && f - a + u > o) break;
|
|
283
|
+
let t = i;
|
|
284
|
+
if (l === "center" || l === "right") {
|
|
285
|
+
let r = this.poco.getTextWidth(e, s);
|
|
286
|
+
t = l === "center" ? i + Math.floor((n - r) / 2) : i + n - r;
|
|
287
|
+
}
|
|
288
|
+
this.poco.drawText(e, s, c, t, f), f += u;
|
|
239
289
|
}
|
|
240
|
-
this.poco.drawText(t, o, s, l, a);
|
|
241
290
|
break;
|
|
242
291
|
}
|
|
243
292
|
case "pbl-line": {
|
|
244
|
-
let e =
|
|
293
|
+
let e = G(r, "x2") + t, o = G(r, "y2") + n, s = this.getColor(K(r, "color") ?? K(r, "stroke") ?? "white"), c = G(r, "strokeWidth") || 1;
|
|
245
294
|
if (i === e) {
|
|
246
295
|
let e = Math.min(a, o), t = Math.abs(o - a) || 1;
|
|
247
296
|
this.poco.fillRectangle(s, i, e, c, t);
|
|
248
297
|
} else if (a === o) {
|
|
249
298
|
let t = Math.min(i, e), n = Math.abs(e - i) || 1;
|
|
250
299
|
this.poco.fillRectangle(s, t, a, n, c);
|
|
300
|
+
} else this.drawDiagonalLine(s, i, a, e, o, c);
|
|
301
|
+
break;
|
|
302
|
+
}
|
|
303
|
+
case "pbl-circle": {
|
|
304
|
+
let e = G(r, "r") || G(r, "radius");
|
|
305
|
+
if (e <= 0) break;
|
|
306
|
+
let t = K(r, "fill"), n = K(r, "stroke"), o = G(r, "strokeWidth") || 1;
|
|
307
|
+
if (t) {
|
|
308
|
+
let n = this.getColor(t);
|
|
309
|
+
this.fillCircle(n, i + e, a + e, e);
|
|
310
|
+
}
|
|
311
|
+
if (n) {
|
|
312
|
+
let t = this.getColor(n);
|
|
313
|
+
this.strokeCircle(t, i + e, a + e, e, o);
|
|
251
314
|
}
|
|
252
315
|
break;
|
|
253
316
|
}
|
|
254
|
-
case "pbl-circle": break;
|
|
255
317
|
case "pbl-image": {
|
|
256
318
|
let e = r.bitmap;
|
|
257
|
-
|
|
319
|
+
if (e) {
|
|
320
|
+
let t = G(r, "rotation"), n = G(r, "scale");
|
|
321
|
+
if (t || n && n !== 1) {
|
|
322
|
+
let r = e, o = this.poco;
|
|
323
|
+
o.drawBitmapWithTransform ? o.drawBitmapWithTransform(r, i, a, t, n || 1) : this.poco.drawBitmap(r, i, a);
|
|
324
|
+
} else this.poco.drawBitmap(e, i, a);
|
|
325
|
+
}
|
|
258
326
|
break;
|
|
259
327
|
}
|
|
260
328
|
case "pbl-group":
|
|
261
329
|
this.renderChildren(e, i, a);
|
|
262
330
|
break;
|
|
263
|
-
case "pbl-statusbar":
|
|
264
|
-
|
|
331
|
+
case "pbl-statusbar": {
|
|
332
|
+
let e = K(r, "backgroundColor") ?? "black", t = K(r, "color") ?? "white", n = this.poco.width;
|
|
333
|
+
this.poco.fillRectangle(this.getColor(e), 0, 0, n, 16);
|
|
334
|
+
let i = this.getFont("gothic14"), a = /* @__PURE__ */ new Date(), o = `${a.getHours().toString().padStart(2, "0")}:${a.getMinutes().toString().padStart(2, "0")}`, s = this.poco.getTextWidth(o, i);
|
|
335
|
+
this.poco.drawText(o, i, this.getColor(t), Math.floor((n - s) / 2), 1);
|
|
336
|
+
let c = K(r, "separator") ?? "none";
|
|
337
|
+
if (c === "line") this.poco.fillRectangle(this.getColor(t), 0, 15, n, 1);
|
|
338
|
+
else if (c === "dotted") for (let e = 0; e < n; e += 3) this.poco.fillRectangle(this.getColor(t), e, 15, 1, 1);
|
|
339
|
+
break;
|
|
340
|
+
}
|
|
341
|
+
case "pbl-actionbar": {
|
|
342
|
+
let e = K(r, "backgroundColor") ?? "darkGray", t = this.poco.width - 30, n = this.poco.height;
|
|
343
|
+
this.poco.fillRectangle(this.getColor(e), t, 0, 30, n);
|
|
344
|
+
let i = this.getColor("white"), a = t + 15;
|
|
345
|
+
this.poco.fillRectangle(i, a - 3, Math.floor(n / 6) - 3, 6, 6), this.poco.fillRectangle(i, a - 3, Math.floor(n / 2) - 3, 6, 6), this.poco.fillRectangle(i, a - 3, Math.floor(n * 5 / 6) - 3, 6, 6);
|
|
346
|
+
break;
|
|
347
|
+
}
|
|
265
348
|
case "pbl-root":
|
|
266
349
|
this.renderChildren(e, t, n);
|
|
267
350
|
break;
|
|
268
351
|
}
|
|
269
352
|
}
|
|
353
|
+
fillCircle(e, t, n, r) {
|
|
354
|
+
let { poco: i } = this, a = r, o = 0, s = 1 - r, c = -1, l = -1;
|
|
355
|
+
for (; a >= o;) n + o !== c && (i.fillRectangle(e, t - a, n + o, a * 2 + 1, 1), c = n + o), n - o !== l && o !== 0 && (i.fillRectangle(e, t - a, n - o, a * 2 + 1, 1), l = n - o), n + a !== c && (i.fillRectangle(e, t - o, n + a, o * 2 + 1, 1), c = n + a), n - a !== l && (i.fillRectangle(e, t - o, n - a, o * 2 + 1, 1), l = n - a), o++, s < 0 ? s += 2 * o + 1 : (a--, s += 2 * (o - a) + 1);
|
|
356
|
+
}
|
|
357
|
+
strokeCircle(e, t, n, r, i) {
|
|
358
|
+
let { poco: a } = this, o = r, s = 0, c = 1 - r;
|
|
359
|
+
for (; o >= s;) a.fillRectangle(e, t + o, n + s, i, i), a.fillRectangle(e, t - o, n + s, i, i), a.fillRectangle(e, t + o, n - s, i, i), a.fillRectangle(e, t - o, n - s, i, i), a.fillRectangle(e, t + s, n + o, i, i), a.fillRectangle(e, t - s, n + o, i, i), a.fillRectangle(e, t + s, n - o, i, i), a.fillRectangle(e, t - s, n - o, i, i), s++, c < 0 ? c += 2 * s + 1 : (o--, c += 2 * (s - o) + 1);
|
|
360
|
+
}
|
|
361
|
+
drawDiagonalLine(e, t, n, r, i, a) {
|
|
362
|
+
let { poco: o } = this, s = Math.abs(r - t), c = Math.abs(i - n), l = t < r ? 1 : -1, u = n < i ? 1 : -1, d = s - c, f = t, p = n;
|
|
363
|
+
for (; o.fillRectangle(e, f, p, a, a), !(f === r && p === i);) {
|
|
364
|
+
let e = 2 * d;
|
|
365
|
+
e > -c && (d -= c, f += l), e < s && (d += s, p += u);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
fillRoundRect(e, t, n, r, i, a) {
|
|
369
|
+
let { poco: o } = this, s = Math.min(a, Math.floor(r / 2), Math.floor(i / 2));
|
|
370
|
+
o.fillRectangle(e, t, n + s, r, i - s * 2), o.fillRectangle(e, t + s, n, r - s * 2, s), o.fillRectangle(e, t + s, n + i - s, r - s * 2, s), this.fillQuarterCircles(e, t + s, n + s, t + r - s - 1, n + i - s - 1, s);
|
|
371
|
+
}
|
|
372
|
+
strokeRoundRect(e, t, n, r, i, a, o) {
|
|
373
|
+
let { poco: s } = this, c = Math.min(a, Math.floor(r / 2), Math.floor(i / 2));
|
|
374
|
+
s.fillRectangle(e, t + c, n, r - c * 2, o), s.fillRectangle(e, t + c, n + i - o, r - c * 2, o), s.fillRectangle(e, t, n + c, o, i - c * 2), s.fillRectangle(e, t + r - o, n + c, o, i - c * 2), this.strokeQuarterCircles(e, t + c, n + c, t + r - c - 1, n + i - c - 1, c, o);
|
|
375
|
+
}
|
|
376
|
+
fillQuarterCircles(e, t, n, r, i, a) {
|
|
377
|
+
let { poco: o } = this, s = a, c = 0, l = 1 - a;
|
|
378
|
+
for (; s >= c;) o.fillRectangle(e, t - s, n - c, s, 1), o.fillRectangle(e, t - c, n - s, c, 1), o.fillRectangle(e, r + 1, n - c, s, 1), o.fillRectangle(e, r + 1, n - s, c, 1), o.fillRectangle(e, t - s, i + c, s, 1), o.fillRectangle(e, t - c, i + s, c, 1), o.fillRectangle(e, r + 1, i + c, s, 1), o.fillRectangle(e, r + 1, i + s, c, 1), c++, l < 0 ? l += 2 * c + 1 : (s--, l += 2 * (c - s) + 1);
|
|
379
|
+
}
|
|
380
|
+
strokeQuarterCircles(e, t, n, r, i, a, o) {
|
|
381
|
+
let { poco: s } = this, c = a, l = 0, u = 1 - a;
|
|
382
|
+
for (; c >= l;) s.fillRectangle(e, t - c, n - l, o, o), s.fillRectangle(e, t - l, n - c, o, o), s.fillRectangle(e, r + c, n - l, o, o), s.fillRectangle(e, r + l, n - c, o, o), s.fillRectangle(e, t - c, i + l, o, o), s.fillRectangle(e, t - l, i + c, o, o), s.fillRectangle(e, r + c, i + l, o, o), s.fillRectangle(e, r + l, i + c, o, o), l++, u < 0 ? u += 2 * l + 1 : (c--, u += 2 * (l - c) + 1);
|
|
383
|
+
}
|
|
384
|
+
wrapText(e, t, n) {
|
|
385
|
+
if (this.poco.getTextWidth(e, t) <= n) return [e];
|
|
386
|
+
let r = e.split(" "), i = [], a = "";
|
|
387
|
+
for (let e of r) {
|
|
388
|
+
let r = a ? `${a} ${e}` : e;
|
|
389
|
+
this.poco.getTextWidth(r, t) <= n ? a = r : (a && i.push(a), a = e);
|
|
390
|
+
}
|
|
391
|
+
return a && i.push(a), i;
|
|
392
|
+
}
|
|
270
393
|
};
|
|
271
|
-
function
|
|
272
|
-
return e && e in
|
|
394
|
+
function se(e) {
|
|
395
|
+
return e && e in H ? e : "black";
|
|
273
396
|
}
|
|
274
|
-
function
|
|
275
|
-
return e && e in
|
|
397
|
+
function ce(e) {
|
|
398
|
+
return e && e in U ? e : W;
|
|
276
399
|
}
|
|
277
400
|
//#endregion
|
|
278
401
|
//#region src/pebble-dom-shim.ts
|
|
279
|
-
function
|
|
402
|
+
function J(e) {
|
|
280
403
|
let t = e.childNodes;
|
|
281
404
|
e.firstChild = t[0] ?? null;
|
|
282
405
|
for (let n = 0; n < t.length; n++) {
|
|
@@ -284,10 +407,10 @@ function W(e) {
|
|
|
284
407
|
r.parentNode = e, r.nextSibling = t[n + 1] ?? null;
|
|
285
408
|
}
|
|
286
409
|
}
|
|
287
|
-
function
|
|
410
|
+
function Y(e) {
|
|
288
411
|
let t = e;
|
|
289
|
-
if (!
|
|
290
|
-
let n =
|
|
412
|
+
if (!A.has(t)) throw Error(`react-pebble: unknown element tag "${e}"`);
|
|
413
|
+
let n = M(t);
|
|
291
414
|
return {
|
|
292
415
|
nodeType: 1,
|
|
293
416
|
nodeName: e.toUpperCase(),
|
|
@@ -300,41 +423,41 @@ function G(e) {
|
|
|
300
423
|
firstChild: null,
|
|
301
424
|
nextSibling: null,
|
|
302
425
|
appendChild(e) {
|
|
303
|
-
return e.parentNode && e.parentNode.removeChild(e), this.childNodes.push(e),
|
|
426
|
+
return e.parentNode && e.parentNode.removeChild(e), this.childNodes.push(e), P(n, e._pbl), J(this), e;
|
|
304
427
|
},
|
|
305
428
|
insertBefore(e, t) {
|
|
306
429
|
if (e.parentNode && e.parentNode.removeChild(e), t === null) return this.appendChild(e);
|
|
307
430
|
let r = this.childNodes.indexOf(t);
|
|
308
|
-
return r < 0 ? this.appendChild(e) : (this.childNodes.splice(r, 0, e),
|
|
431
|
+
return r < 0 ? this.appendChild(e) : (this.childNodes.splice(r, 0, e), F(n, e._pbl, t._pbl), J(this), e);
|
|
309
432
|
},
|
|
310
433
|
removeChild(e) {
|
|
311
434
|
let t = this.childNodes.indexOf(e);
|
|
312
|
-
return t >= 0 && this.childNodes.splice(t, 1),
|
|
435
|
+
return t >= 0 && this.childNodes.splice(t, 1), I(n, e._pbl), e.parentNode = null, e.nextSibling = null, J(this), e;
|
|
313
436
|
},
|
|
314
437
|
remove() {
|
|
315
438
|
this.parentNode && this.parentNode.removeChild(this);
|
|
316
439
|
},
|
|
317
440
|
setAttribute(e, t) {
|
|
318
|
-
this.attributes[e] = t,
|
|
441
|
+
this.attributes[e] = t, L(n, e, t);
|
|
319
442
|
},
|
|
320
443
|
removeAttribute(e) {
|
|
321
|
-
delete this.attributes[e],
|
|
444
|
+
delete this.attributes[e], L(n, e, void 0);
|
|
322
445
|
},
|
|
323
446
|
getAttribute(e) {
|
|
324
447
|
return this.attributes[e];
|
|
325
448
|
},
|
|
326
449
|
addEventListener(e, t) {
|
|
327
450
|
let r = `on${e[0]?.toUpperCase()}${e.slice(1)}`;
|
|
328
|
-
this.attributes[r] = t,
|
|
451
|
+
this.attributes[r] = t, L(n, r, t);
|
|
329
452
|
},
|
|
330
453
|
removeEventListener(e, t) {
|
|
331
454
|
let r = `on${e[0]?.toUpperCase()}${e.slice(1)}`;
|
|
332
|
-
delete this.attributes[r],
|
|
455
|
+
delete this.attributes[r], L(n, r, void 0);
|
|
333
456
|
}
|
|
334
457
|
};
|
|
335
458
|
}
|
|
336
|
-
function
|
|
337
|
-
let t =
|
|
459
|
+
function le(e) {
|
|
460
|
+
let t = N(e), n = {
|
|
338
461
|
nodeType: 3,
|
|
339
462
|
nodeName: "#text",
|
|
340
463
|
_pbl: t,
|
|
@@ -351,54 +474,54 @@ function K(e) {
|
|
|
351
474
|
return t.value;
|
|
352
475
|
},
|
|
353
476
|
set(e) {
|
|
354
|
-
|
|
477
|
+
R(t, e);
|
|
355
478
|
}
|
|
356
479
|
}), Object.defineProperty(n, "nodeValue", {
|
|
357
480
|
get() {
|
|
358
481
|
return t.value;
|
|
359
482
|
},
|
|
360
483
|
set(e) {
|
|
361
|
-
|
|
484
|
+
R(t, e);
|
|
362
485
|
}
|
|
363
486
|
}), Object.defineProperty(n, "textContent", {
|
|
364
487
|
get() {
|
|
365
488
|
return t.value;
|
|
366
489
|
},
|
|
367
490
|
set(e) {
|
|
368
|
-
|
|
491
|
+
R(t, e);
|
|
369
492
|
}
|
|
370
493
|
}), n;
|
|
371
494
|
}
|
|
372
|
-
var
|
|
373
|
-
createElement:
|
|
374
|
-
createElementNS: (e, t) =>
|
|
375
|
-
createTextNode:
|
|
495
|
+
var X = {
|
|
496
|
+
createElement: Y,
|
|
497
|
+
createElementNS: (e, t) => Y(t),
|
|
498
|
+
createTextNode: le
|
|
376
499
|
};
|
|
377
|
-
function
|
|
378
|
-
let e =
|
|
379
|
-
return e.ownerDocument =
|
|
500
|
+
function ue() {
|
|
501
|
+
let e = Y("pbl-root");
|
|
502
|
+
return e.ownerDocument = X, e;
|
|
380
503
|
}
|
|
381
504
|
//#endregion
|
|
382
505
|
//#region src/pebble-reconciler.ts
|
|
383
|
-
typeof document > "u" && (globalThis.document =
|
|
384
|
-
function
|
|
385
|
-
let e =
|
|
506
|
+
typeof document > "u" && (globalThis.document = X);
|
|
507
|
+
function Z() {
|
|
508
|
+
let e = ue();
|
|
386
509
|
return {
|
|
387
510
|
shimRoot: e,
|
|
388
511
|
pblRoot: e._pbl
|
|
389
512
|
};
|
|
390
513
|
}
|
|
391
|
-
function
|
|
392
|
-
|
|
514
|
+
function Q(e, t) {
|
|
515
|
+
k(e, t.shimRoot);
|
|
393
516
|
}
|
|
394
|
-
function
|
|
395
|
-
|
|
517
|
+
function $(e) {
|
|
518
|
+
k(null, e.shimRoot);
|
|
396
519
|
}
|
|
397
|
-
var
|
|
398
|
-
createContainer:
|
|
399
|
-
updateContainer:
|
|
400
|
-
unmountContainer:
|
|
401
|
-
},
|
|
520
|
+
var de = {
|
|
521
|
+
createContainer: Z,
|
|
522
|
+
updateContainer: Q,
|
|
523
|
+
unmountContainer: $
|
|
524
|
+
}, fe = class {
|
|
402
525
|
width;
|
|
403
526
|
height;
|
|
404
527
|
Font;
|
|
@@ -512,7 +635,7 @@ var Q = {
|
|
|
512
635
|
return Math.round(e.length * n * .6);
|
|
513
636
|
}
|
|
514
637
|
};
|
|
515
|
-
function
|
|
638
|
+
function pe(e, t) {
|
|
516
639
|
return typeof screen < "u" && screen && t ? {
|
|
517
640
|
poco: new t(screen),
|
|
518
641
|
info: {
|
|
@@ -522,7 +645,7 @@ function ee(e, t) {
|
|
|
522
645
|
screenHeight: screen.height
|
|
523
646
|
}
|
|
524
647
|
} : {
|
|
525
|
-
poco: new
|
|
648
|
+
poco: new fe(200, 228, e),
|
|
526
649
|
info: {
|
|
527
650
|
isReal: !1,
|
|
528
651
|
platform: "mock",
|
|
@@ -531,7 +654,7 @@ function ee(e, t) {
|
|
|
531
654
|
}
|
|
532
655
|
};
|
|
533
656
|
}
|
|
534
|
-
function
|
|
657
|
+
function me() {
|
|
535
658
|
if (typeof watch > "u" || !watch) return () => void 0;
|
|
536
659
|
let e = (e) => {
|
|
537
660
|
if (typeof e != "string") return;
|
|
@@ -548,25 +671,25 @@ function te() {
|
|
|
548
671
|
typeof watch > "u" || !watch || (watch.removeEventListener("button", t), watch.removeEventListener("buttonClick", t), watch.removeEventListener("longClick", n));
|
|
549
672
|
};
|
|
550
673
|
}
|
|
551
|
-
function
|
|
674
|
+
function he(e) {
|
|
552
675
|
typeof Promise < "u" ? Promise.resolve().then(e) : setTimeout(e, 0);
|
|
553
676
|
}
|
|
554
|
-
function
|
|
555
|
-
let n = [], r =
|
|
677
|
+
function ge(e, t = {}) {
|
|
678
|
+
let n = [], r = Z(), { poco: i, info: a } = pe(n, t.poco), o = new q(i), s = !1, c = () => {
|
|
556
679
|
s = !1, n.length = 0, o.render(r.pblRoot, { backgroundColor: t.backgroundColor });
|
|
557
680
|
}, l = () => {
|
|
558
|
-
s || (s = !0,
|
|
681
|
+
s || (s = !0, he(c));
|
|
559
682
|
}, u = t, d = u._commit ?? u.__c, f = (e, t) => {
|
|
560
683
|
d && d(e, t), l();
|
|
561
684
|
};
|
|
562
|
-
u._commit = f, u.__c = f,
|
|
563
|
-
let p =
|
|
685
|
+
u._commit = f, u.__c = f, Q(e, r), c();
|
|
686
|
+
let p = me();
|
|
564
687
|
return {
|
|
565
688
|
update(e) {
|
|
566
|
-
|
|
689
|
+
Q(e, r), l();
|
|
567
690
|
},
|
|
568
691
|
unmount() {
|
|
569
|
-
|
|
692
|
+
$(r), u._commit = d, u.__c = d, p();
|
|
570
693
|
},
|
|
571
694
|
get platform() {
|
|
572
695
|
return a;
|
|
@@ -580,6 +703,6 @@ function re(e, t = {}) {
|
|
|
580
703
|
};
|
|
581
704
|
}
|
|
582
705
|
//#endregion
|
|
583
|
-
export {
|
|
706
|
+
export { ee as ActionBar, te as Badge, r as ButtonRegistry, H as COLOR_PALETTE, ne as Card, re as Circle, C as Column, A as ELEMENT_TYPES, i as Easing, U as FONT_PALETTE, ie as Group, w as Image, ae as Line, e as PLATFORMS, a as PebbleAppContext, q as PocoRenderer, oe as Rect, T as Row, t as SCREEN, E as StatusBar, D as Text, O as Window, n as _setPlatform, P as appendChildNode, M as createNode, N as createTextNode, V as findRoot, z as getTextContent, F as insertBeforeNode, o as lerp, de as reconciler, I as removeChildNode, ge as render, se as resolveColorName, ce as resolveFontName, L as setAttribute, R as setTextNodeValue, s as useAccelerometer, c as useAnimation, l as useApp, u as useBattery, d as useButton, f as useCompass, p as useConnection, m as useFetch, h as useFormattedTime, g as useInterval, _ as useKVStorage, v as useListNavigation, y as useLocalStorage, b as useLongButton, x as useTime, S as useWebSocket, B as walkTree };
|
|
584
707
|
|
|
585
708
|
//# sourceMappingURL=index.js.map
|