@showlotus/open-scriptable 0.1.26-alpha.0 → 0.1.26-alpha.1

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.
@@ -1,42 +1,34 @@
1
- return var B = Object.defineProperty, N = Object.defineProperties;
2
- var J = Object.getOwnPropertyDescriptors;
3
- var A = Object.getOwnPropertySymbols;
4
- var Q = Object.prototype.hasOwnProperty, X = Object.prototype.propertyIsEnumerable;
5
- var K = (s, a, l) => a in s ? B(s, a, { enumerable: !0, configurable: !0, writable: !0, value: l }) : s[a] = l, p = (s, a) => { for (var l in a || (a = {}))
6
- Q.call(a, l) && K(s, l, a[l]); if (A)
7
- for (var l of A(a))
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
- C(t) !== void 0 ? g.layout = C(t) : w[t.trim().toLowerCase()] ? g.theme = w[t.trim().toLowerCase()] : L.push(t);
20
- } const S = p(p({}, s), g); function V(t, e) { return S[t] || e; } const b = g.calendarTypes || L.join("/") || S.calendarTypes || "", T = ((I = C(S.layout)) != null ? I : "single") === "double" && a !== "small", F = (T ? { small: 3, medium: 6, large: 14 } : { small: 3, medium: 3, large: 7 })[a], z = { 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) }, H = { default: z, transparent: P(p({}, z), { backgroundColor: new Color("#000000", 0) }) }, M = V("theme", "default"), y = H[M] || H.default; function $(t, e) { const o = new DateFormatter; return o.dateFormat = e, o.string(t); } function G(t) { const e = new Date; e.setHours(0, 0, 0, 0); const o = t.getTime() - e.getTime(); return Math.floor(o / (1e3 * 60 * 60 * 24)); } function O(t) { return `calshow:${Math.floor(t.getTime() / 1e3) - 978307200}`; } async function j() { const t = await Calendar.forEvents(), e = new Date, o = new Date; return o.setMonth(o.getMonth() + 12), (await CalendarEvent.between(e, o, t)).map(n => { const d = a === "small" ? "yyyy/MM/dd" : T ? "yyyy/MM/dd EEEE" : `yyyy/MM/dd EEEE${n.isAllDay ? "" : " HH:mm"}`, m = $(n.startDate, d); return { name: n.title, date: n.startDate, dateStr: m, isEmpty: !1, type: n.calendar.title, color: "#" + n.calendar.color.hex, eventUrl: `x-apple-calevent://${n.identifier.replace(/:/g, "/")}`, calshowUrl: O(n.startDate) }; }).filter(n => !(n.type === "中国大陆节假日" && /(|)/.test(n.name))).filter(n => b.trim().length > 0 ? b.split("/").includes(n.type) : !0); } const q = await j(), i = new ListWidget; i.backgroundColor = y.backgroundColor, M === "transparent" && (i.backgroundStyle = "transparent"), i.spacing = 8; function x(t) { return q[t] || { name: "", date: "", isEmpty: !0, eventUrl: "", calshowUrl: "" }; } function h(t, e) { const o = t.addStack(); o.layoutVertically(), o.spacing = 1, e.eventUrl && (o.url = e.eventUrl); const r = o.addStack(); r.layoutHorizontally(), r.spacing = 2; const c = r.addText(e.name); c.font = Font.mediumRoundedSystemFont(14), c.textColor = e.color ? new Color(e.color) : y.dateTitleTextColor; const n = o.addStack(); n.layoutHorizontally(), n.spacing = 2; const d = n.addText(e.isEmpty ? " " : e.dateStr); d.font = Font.mediumRoundedSystemFont(10), d.textColor = y.dateDescriptionTextColor, t.addSpacer(); const m = t.addStack(); m.layoutHorizontally(), m.bottomAlignContent(), m.spacing = 2; const u = e.isEmpty ? " " : G(e.date), f = m.addStack(); f.spacing = 2, f.topAlignContent(); const D = f.addText(u.toString()); D.font = Font.mediumRoundedSystemFont(24), D.textColor = e.color ? new Color(e.color) : y.daysTextColor, D.rightAlignText(); const R = m.addStack(); if (R.setPadding(0, 0, 4, 0), !e.isEmpty) {
21
- const E = R.addText("天");
22
- E.font = Font.mediumRoundedSystemFont(10), E.textColor = y.daysUnitTextColor, E.rightAlignText();
23
- } } function k(t, e) { const o = t.addStack(); o.layoutHorizontally(), o.addSpacer(), o.backgroundColor = e.isEmpty ? y.emptyLineColor : y.lineColor, o.setPadding(.5, 0, .5, 0); } if (T) {
24
- const e = F / 2;
25
- for (let o = 0; o < e; o++) {
26
- const r = i.addStack();
27
- r.layoutHorizontally();
28
- const c = x(o * 2), n = x(o * 2 + 1), d = r.addStack();
29
- d.layoutVertically(), d.spacing = 8;
30
- const m = d.addStack();
31
- m.layoutHorizontally(), h(m, c), o < e - 1 && k(d, c), r.addSpacer(12);
32
- const u = r.addStack();
33
- u.layoutVertically(), u.spacing = 8;
34
- const f = u.addStack();
35
- f.layoutHorizontally(), h(f, n), o < e - 1 && k(u, n);
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 t = 0; t < F; t++) {
40
- const e = x(t), o = i.addStack();
41
- o.layoutHorizontally(), h(o, e), t < F - 1 && k(i, e);
42
- } config.runsInWidget ? Script.setWidget(i) : config.runsInApp && (a === "small" ? i.presentSmall() : a === "medium" ? i.presentMedium() : a === "large" && i.presentLarge()), Script.complete(); }
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(); }
@@ -1,8 +1 @@
1
- return var C = Object.defineProperty;
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()); }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@showlotus/open-scriptable",
3
- "version": "0.1.26-alpha.0",
3
+ "version": "0.1.26-alpha.1",
4
4
  "description": "Open-source Scriptable scripts for iOS Widgets",
5
5
  "type": "module",
6
6
  "packageManager": "pnpm@8.10.0",