@showlotus/open-scriptable 0.1.21 → 0.1.22

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.
Files changed (2) hide show
  1. package/dist/count-down.js +13 -13
  2. package/package.json +1 -1
@@ -1,8 +1,8 @@
1
- return async function W(D = {}) { var F; const h = { small: 3, medium: 3, large: 7 }; let l; config.runsInWidget ? l = config.widgetFamily || "small" : l = "large"; const y = h[l], f = (F = args.widgetParameter) == null ? void 0 : F.trim(), [C = "", M = "default"] = (f == null ? void 0 : f.split(",")) || [], p = { default: { 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) } }, k = w("theme", "default"), s = p[k] || p.default; function w(e, t) { return D[e] || t; } function E(e, t) { const o = new DateFormatter; return o.dateFormat = t, o.string(e); } function z(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 L(e, t, o) { const n = new DrawContext; n.size = new Size(e, t), n.opaque = !1, n.respectScreenScale = !0, n.setFillColor(o); const r = new Path; return r.addRoundedRect(new Rect(0, 0, e, t), t / 2, t / 2), n.addPath(r), n.fillPath(), n.getImage(); } async function R() { const e = await Calendar.forEvents(), t = new Date, o = new Date; return o.setMonth(o.getMonth() + 6), (await CalendarEvent.between(t, o, e)).map(a => { const c = E(a.startDate, `yyyy/MM/dd${a.isAllDay ? "" : " HH:mm"}${l === "small" ? "" : ", EEEE"}`); return { name: a.title, date: a.startDate, dateStr: c, isEmpty: !1, type: a.calendar.title, color: "#" + a.calendar.color.hex }; }).filter(a => !(a.type === "中国大陆节假日" && /(|)/.test(a.name))).filter(a => C.trim().length > 0 ? C.split("/").includes(a.type) : !0); } const b = await R(), i = new ListWidget; i.backgroundColor = s.backgroundColor, i.spacing = 8, Object.entries(w("days", {}) || {}).map(([e, t]) => ({ name: e, date: t, isEmpty: !1 })).sort((e, t) => e.date > t.date ? 1 : -1).filter(e => { const [t, o, n] = e.date.split("-").map(Number), r = new Date; return t > r.getFullYear() ? !0 : t === r.getFullYear() ? o > r.getMonth() + 1 || o === r.getMonth() + 1 && n >= r.getDate() : !1; }).slice(0, y); for (let e = 0; e < y; e++) {
2
- const t = b[e] || { name: "", date: "", isEmpty: !0 }, o = i.addStack();
1
+ return async function W(h = {}) { var F; const D = { small: 3, medium: 3, large: 7 }; let l; config.runsInWidget ? l = config.widgetFamily || "small" : l = "large"; const f = D[l], u = (F = args.widgetParameter) == null ? void 0 : F.trim(), [C = "", I = "default"] = (u == null ? void 0 : u.split(",")) || [], p = { default: { 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) } }, k = w("theme", "default"), s = p[k] || p.default; function w(e, t) { return h[e] || t; } function E(e, t) { const o = new DateFormatter; return o.dateFormat = t, o.string(e); } function z(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 L(e, t, o) { const n = new DrawContext; n.size = new Size(e, t), n.opaque = !1, n.respectScreenScale = !0, n.setFillColor(o); const r = new Path; return r.addRoundedRect(new Rect(0, 0, e, t), t / 2, t / 2), n.addPath(r), n.fillPath(), n.getImage(); } function M(e) { return `calshow:${Math.floor(e.getTime() / 1e3) - 978307200}`; } async function R() { const e = await Calendar.forEvents(), t = new Date, o = new Date; return o.setMonth(o.getMonth() + 6), (await CalendarEvent.between(t, o, e)).map(a => { const c = E(a.startDate, `yyyy/MM/dd${a.isAllDay ? "" : " HH:mm"}${l === "small" ? "" : ", EEEE"}`); return { name: a.title, date: a.startDate, dateStr: c, isEmpty: !1, type: a.calendar.title, color: "#" + a.calendar.color.hex, eventUrl: `x-apple-calevent://${a.identifier.replace(/:/g, "/")}`, calshowUrl: M(a.startDate) }; }).filter(a => !(a.type === "中国大陆节假日" && /(|)/.test(a.name))).filter(a => C.trim().length > 0 ? C.split("/").includes(a.type) : !0); } const U = await R(), i = new ListWidget; i.backgroundColor = s.backgroundColor, i.spacing = 8, Object.entries(w("days", {}) || {}).map(([e, t]) => ({ name: e, date: t, isEmpty: !1 })).sort((e, t) => e.date > t.date ? 1 : -1).filter(e => { const [t, o, n] = e.date.split("-").map(Number), r = new Date; return t > r.getFullYear() ? !0 : t === r.getFullYear() ? o > r.getMonth() + 1 || o === r.getMonth() + 1 && n >= r.getDate() : !1; }).slice(0, f); for (let e = 0; e < f; e++) {
2
+ const t = U[e] || { name: "", date: "", isEmpty: !0, eventUrl: "" }, o = i.addStack();
3
3
  o.layoutHorizontally();
4
4
  const n = o.addStack();
5
- n.layoutVertically(), n.spacing = 1;
5
+ n.layoutVertically(), n.spacing = 1, t.eventUrl && (n.url = t.eventUrl);
6
6
  const r = n.addStack();
7
7
  r.layoutHorizontally(), r.spacing = 2;
8
8
  const a = r.addText(t.name);
@@ -13,20 +13,20 @@ return async function W(D = {}) { var F; const h = { small: 3, medium: 3, large:
13
13
  x.font = Font.mediumRoundedSystemFont(10), x.textColor = s.dateDescriptionTextColor, o.addSpacer();
14
14
  const m = o.addStack();
15
15
  m.layoutHorizontally(), m.bottomAlignContent(), m.spacing = 2;
16
- const A = t.isEmpty ? " " : z(t.date), u = m.addStack();
17
- u.spacing = 2, u.topAlignContent();
18
- const g = u.addText(A.toString());
16
+ const b = t.isEmpty ? " " : z(t.date), y = m.addStack();
17
+ y.spacing = 2, y.topAlignContent();
18
+ const g = y.addText(b.toString());
19
19
  g.font = Font.mediumRoundedSystemFont(24), g.textColor = t.color ? new Color(t.color) : s.daysTextColor, g.rightAlignText();
20
- const S = m.addStack();
21
- if (S.setPadding(0, 0, 4, 0), !t.isEmpty) {
22
- const d = S.addText("天");
20
+ const T = m.addStack();
21
+ if (T.setPadding(0, 0, 4, 0), !t.isEmpty) {
22
+ const d = T.addText("天");
23
23
  d.font = Font.mediumRoundedSystemFont(10), d.textColor = s.daysUnitTextColor, d.rightAlignText();
24
24
  }
25
- if (e < y - 1) {
25
+ if (e < f - 1) {
26
26
  const d = i.addStack();
27
27
  d.layoutHorizontally(), d.centerAlignContent();
28
- const H = l === "small" ? 126 : 305, I = 1;
29
- let T = s.lineColor;
30
- t.isEmpty && (T = s.emptyLineColor), d.addImage(L(H, I, T)).centerAlignImage();
28
+ const A = l === "small" ? 126 : 305, H = 1;
29
+ let S = s.lineColor;
30
+ t.isEmpty && (S = s.emptyLineColor), d.addImage(L(A, H, S)).centerAlignImage();
31
31
  }
32
32
  } config.runsInWidget ? Script.setWidget(i) : config.runsInApp && (l === "small" ? i.presentSmall() : l === "medium" ? i.presentMedium() : l === "large" && i.presentLarge()), Script.complete(); }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@showlotus/open-scriptable",
3
- "version": "0.1.21",
3
+ "version": "0.1.22",
4
4
  "description": "Open-source Scriptable scripts for iOS Widgets",
5
5
  "type": "module",
6
6
  "packageManager": "pnpm@8.10.0",