@showlotus/open-scriptable 0.1.22 → 0.1.23

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/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Open-source Scriptable scripts for iOS Widgets
2
2
 
3
+ 参考文档:
4
+
5
+ - [Scriptable API 文档](https://docs.scriptable.app/)
6
+
3
7
  ## 使用示例
4
8
 
5
9
  ```javascript
@@ -1,4 +1,4 @@
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++) {
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() + 12), (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
2
  const t = U[e] || { name: "", date: "", isEmpty: !0, eventUrl: "" }, o = i.addStack();
3
3
  o.layoutHorizontally();
4
4
  const n = o.addStack();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@showlotus/open-scriptable",
3
- "version": "0.1.22",
3
+ "version": "0.1.23",
4
4
  "description": "Open-source Scriptable scripts for iOS Widgets",
5
5
  "type": "module",
6
6
  "packageManager": "pnpm@8.10.0",