@showlotus/open-scriptable 0.1.26-alpha.0 → 0.1.26-alpha.2
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/count-down.js +28 -36
- package/dist/hello-world.js +1 -8
- package/package.json +1 -1
package/dist/count-down.js
CHANGED
|
@@ -1,42 +1,34 @@
|
|
|
1
|
-
return
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
X.call(a, l) && K(s, l, a[l]); return s; }, P = (s, a) => N(s, J(a));
|
|
9
|
-
async function tt(s = {}) { var U, I; let a; config.runsInWidget ? a = config.widgetFamily || "small" : a = "large"; const l = { single: "single", double: "double", 单列: "single", 双列: "double" }, w = { 透明: "transparent", transparent: "transparent" }; function C(t) { const e = t == null ? void 0 : t.trim().toLowerCase(); return e ? l[e] : void 0; } const W = ((U = args.widgetParameter) == null ? void 0 : U.trim().split(/,|,/).map(t => t.trim()).filter(Boolean)) || [], v = ["calendarTypes", "theme", "layout"], g = {}, L = []; for (const t of W) {
|
|
10
|
-
const e = t.indexOf("=");
|
|
11
|
-
if (e > 0) {
|
|
12
|
-
const o = t.slice(0, e).trim().toLowerCase(), r = v.find(n => n.toLowerCase() === o), c = t.slice(e + 1).trim();
|
|
13
|
-
if (r) {
|
|
14
|
-
const n = r === "layout" ? C(c) : w[c.trim().toLowerCase()];
|
|
15
|
-
g[r] = n || c;
|
|
1
|
+
return async function G(H = {}) { let c; config.runsInWidget ? c = config.widgetFamily || "small" : c = "large"; const M = { single: "single", double: "double", 单列: "single", 双列: "double" }, g = { 透明: "transparent", transparent: "transparent" }; function f(e) { const t = e?.trim().toLowerCase(); return t ? M[t] : void 0; } const U = args.widgetParameter?.trim().split(/,|,/).map(e => e.trim()).filter(Boolean) || [], I = ["calendarTypes", "theme", "layout"], u = {}, k = []; for (const e of U) {
|
|
2
|
+
const t = e.indexOf("=");
|
|
3
|
+
if (t > 0) {
|
|
4
|
+
const o = e.slice(0, t).trim().toLowerCase(), a = I.find(n => n.toLowerCase() === o), l = e.slice(t + 1).trim();
|
|
5
|
+
if (a) {
|
|
6
|
+
const n = a === "layout" ? f(l) : g[l.trim().toLowerCase()];
|
|
7
|
+
u[a] = n || l;
|
|
16
8
|
}
|
|
17
9
|
}
|
|
18
10
|
else
|
|
19
|
-
|
|
20
|
-
} const
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
} } function
|
|
24
|
-
const
|
|
25
|
-
for (let o = 0; o <
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
|
|
11
|
+
f(e) !== void 0 ? u.layout = f(e) : g[e.trim().toLowerCase()] ? u.theme = g[e.trim().toLowerCase()] : k.push(e);
|
|
12
|
+
} const C = { ...H, ...u }; function v(e, t) { return C[e] || t; } const D = u.calendarTypes || k.join("/") || C.calendarTypes || "", p = (f(C.layout) ?? "single") === "double" && c !== "small", w = (p ? { small: 3, medium: 6, large: 14 } : { small: 3, medium: 3, large: 7 })[c], E = { backgroundColor: Color.dynamic(new Color("#FFFFFF"), new Color("#1c1c1c")), dateTitleTextColor: Color.dynamic(new Color("#000000"), new Color("#FFFFFF")), dateDescriptionTextColor: Color.dynamic(new Color("#979797"), new Color("#8e8e8e")), daysTextColor: Color.dynamic(new Color("#000000"), new Color("#FFFFFF")), daysUnitTextColor: Color.dynamic(new Color("#979797"), new Color("#8e8e8e")), lineColor: new Color("#8C8C8C", .2), emptyLineColor: new Color("#ffffff", 0) }, L = { default: E, transparent: { ...E, backgroundColor: new Color("#000000", 0) } }, b = v("theme", "default"), d = L[b] || L.default; function R(e, t) { const o = new DateFormatter; return o.dateFormat = t, o.string(e); } function A(e) { const t = new Date; t.setHours(0, 0, 0, 0); const o = e.getTime() - t.getTime(); return Math.floor(o / (1e3 * 60 * 60 * 24)); } function K(e) { return `calshow:${Math.floor(e.getTime() / 1e3) - 978307200}`; } async function P() { const e = await Calendar.forEvents(), t = new Date, o = new Date; return o.setMonth(o.getMonth() + 12), (await CalendarEvent.between(t, o, e)).map(n => { const s = c === "small" ? "yyyy/MM/dd" : p ? "yyyy/MM/dd EEEE" : `yyyy/MM/dd EEEE${n.isAllDay ? "" : " HH:mm"}`, i = R(n.startDate, s); return { name: n.title, date: n.startDate, dateStr: i, isEmpty: !1, type: n.calendar.title, color: "#" + n.calendar.color.hex, eventUrl: `x-apple-calevent://${n.identifier.replace(/:/g, "/")}`, calshowUrl: K(n.startDate) }; }).filter(n => !(n.type === "中国大陆节假日" && /(|)/.test(n.name))).filter(n => D.trim().length > 0 ? D.split("/").includes(n.type) : !0); } const W = await P(), r = new ListWidget; r.backgroundColor = d.backgroundColor, b === "transparent" && (r.backgroundStyle = "transparent"), r.spacing = 8; function S(e) { return W[e] || { name: "", date: "", isEmpty: !0, eventUrl: "", calshowUrl: "" }; } function T(e, t) { const o = e.addStack(); o.layoutVertically(), o.spacing = 1, t.eventUrl && (o.url = t.eventUrl); const a = o.addStack(); a.layoutHorizontally(), a.spacing = 2; const l = a.addText(t.name); l.font = Font.mediumRoundedSystemFont(14), l.textColor = t.color ? new Color(t.color) : d.dateTitleTextColor; const n = o.addStack(); n.layoutHorizontally(), n.spacing = 2; const s = n.addText(t.isEmpty ? " " : t.dateStr); s.font = Font.mediumRoundedSystemFont(10), s.textColor = d.dateDescriptionTextColor, e.addSpacer(); const i = e.addStack(); i.layoutHorizontally(), i.bottomAlignContent(), i.spacing = 2; const m = t.isEmpty ? " " : A(t.date), y = i.addStack(); y.spacing = 2, y.topAlignContent(); const x = y.addText(m.toString()); x.font = Font.mediumRoundedSystemFont(24), x.textColor = t.color ? new Color(t.color) : d.daysTextColor, x.rightAlignText(); const z = i.addStack(); if (z.setPadding(0, 0, 4, 0), !t.isEmpty) {
|
|
13
|
+
const h = z.addText("天");
|
|
14
|
+
h.font = Font.mediumRoundedSystemFont(10), h.textColor = d.daysUnitTextColor, h.rightAlignText();
|
|
15
|
+
} } function F(e, t) { const o = e.addStack(); o.layoutHorizontally(), o.addSpacer(), o.backgroundColor = t.isEmpty ? d.emptyLineColor : d.lineColor, o.setPadding(.5, 0, .5, 0); } if (p) {
|
|
16
|
+
const t = w / 2;
|
|
17
|
+
for (let o = 0; o < t; o++) {
|
|
18
|
+
const a = r.addStack();
|
|
19
|
+
a.layoutHorizontally();
|
|
20
|
+
const l = S(o * 2), n = S(o * 2 + 1), s = a.addStack();
|
|
21
|
+
s.layoutVertically(), s.spacing = 8;
|
|
22
|
+
const i = s.addStack();
|
|
23
|
+
i.layoutHorizontally(), T(i, l), o < t - 1 && F(s, l), a.addSpacer(12);
|
|
24
|
+
const m = a.addStack();
|
|
25
|
+
m.layoutVertically(), m.spacing = 8;
|
|
26
|
+
const y = m.addStack();
|
|
27
|
+
y.layoutHorizontally(), T(y, n), o < t - 1 && F(m, n);
|
|
36
28
|
}
|
|
37
29
|
}
|
|
38
30
|
else
|
|
39
|
-
for (let
|
|
40
|
-
const
|
|
41
|
-
o.layoutHorizontally(),
|
|
42
|
-
} config.runsInWidget ? Script.setWidget(
|
|
31
|
+
for (let e = 0; e < w; e++) {
|
|
32
|
+
const t = S(e), o = r.addStack();
|
|
33
|
+
o.layoutHorizontally(), T(o, t), e < w - 1 && F(r, t);
|
|
34
|
+
} config.runsInWidget ? Script.setWidget(r) : config.runsInApp && (c === "small" ? r.presentSmall() : c === "medium" ? r.presentMedium() : c === "large" && r.presentLarge()), Script.complete(); }
|
package/dist/hello-world.js
CHANGED
|
@@ -1,8 +1 @@
|
|
|
1
|
-
return
|
|
2
|
-
var f = Object.getOwnPropertySymbols;
|
|
3
|
-
var y = Object.prototype.hasOwnProperty, S = Object.prototype.propertyIsEnumerable;
|
|
4
|
-
var F = (t, e, n) => e in t ? C(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n, r = (t, e) => { for (var n in e || (e = {}))
|
|
5
|
-
y.call(e, n) && F(t, n, e[n]); if (f)
|
|
6
|
-
for (var n of f(e))
|
|
7
|
-
S.call(e, n) && F(t, n, e[n]); return t; };
|
|
8
|
-
async function p(t) { var g, d, a; let e; config.runsInWidget ? e = config.widgetFamily || "small" : e = "small"; const n = (g = args.widgetParameter) == null ? void 0 : g.trim(), s = (a = (d = n == null ? void 0 : n.match(/(?:^|[,,])name=([^,,]+)/i)) == null ? void 0 : d[1]) == null ? void 0 : a.trim(), u = r(r({}, t), s || n ? { name: s || n } : {}); function w(m, i) { return u[m] || i; } function c(m) { const i = new ListWidget; i.backgroundColor = Color.dynamic(new Color("#FFFFFF"), new Color("#1c1c1c")); const l = i.addText(`Hello, ${w("name", "World")}`); return l.textColor = Color.dynamic(new Color("#000000"), new Color("#FFFFFF")), l.font = Font.boldSystemFont(16), l.centerAlignText(), console.log("config:"), console.log(JSON.stringify(config, null, 2)), i; } let o; config.runsInWidget ? (o = c(), Script.setWidget(o)) : (o = c(), e === "small" ? o.presentSmall() : e === "medium" ? o.presentMedium() : e === "large" && o.presentLarge()); }
|
|
1
|
+
return async function d(c) { let t; config.runsInWidget ? t = config.widgetFamily || "small" : t = "small"; const o = args.widgetParameter?.trim(), l = o?.match(/(?:^|[,,])name=([^,,]+)/i)?.[1]?.trim(), g = { ...c, ...l || o ? { name: l || o } : {} }; function a(s, n) { return g[s] || n; } function r(s) { const n = new ListWidget; n.backgroundColor = Color.dynamic(new Color("#FFFFFF"), new Color("#1c1c1c")); const i = n.addText(`Hello, ${a("name", "World")}`); return i.textColor = Color.dynamic(new Color("#000000"), new Color("#FFFFFF")), i.font = Font.boldSystemFont(16), i.centerAlignText(), console.log("config:"), console.log(JSON.stringify(config, null, 2)), n; } let e; config.runsInWidget ? (e = r(), Script.setWidget(e)) : (e = r(), t === "small" ? e.presentSmall() : t === "medium" ? e.presentMedium() : t === "large" && e.presentLarge()); }
|