@showlotus/open-scriptable 0.1.9 → 0.1.11

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
@@ -14,7 +14,10 @@ const code = await new Request(url).loadString();
14
14
  eval(code);
15
15
  ```
16
16
 
17
- <img src="./res/hello-world.jpeg" alt="small" width="300">
17
+ <div>
18
+ <img src="./res/hello-world/light.png" alt="light" width="300">
19
+ <img src="./res/hello-world/dark.jpeg" alt="dark" width="300">
20
+ </div>
18
21
 
19
22
  ## 组件列表
20
23
 
@@ -39,11 +42,18 @@ const code = await new Request(url).loadString();
39
42
  eval(code);
40
43
  ```
41
44
 
42
- <div>
45
+ <!-- <div>
43
46
  <img src="./res/count-down/light.jpeg" alt="light" width="300">
44
47
  <img src="./res/count-down/dark.jpeg" alt="dark" width="300">
48
+ </div> -->
49
+
50
+ <div>
51
+ <img src="./res/count-down/light-v2.jpeg" alt="light" width="300">
52
+ <img src="./res/count-down/dark-v2.jpeg" alt="dark" width="300">
45
53
  </div>
46
54
 
55
+ ### 月度消费组件
56
+
47
57
  ## 开发
48
58
 
49
59
  ```bash
@@ -1 +1 @@
1
- let t;t=config.runsInWidget?config.widgetFamily||"small":"large";const o={small:3,medium:3,large:7}[t];const e=new ListWidget;e.useDefaultPadding(),e.backgroundColor=Color.dynamic(new Color("#FFFFFF"),new Color("#1c1c1c")),e.spacing=8;const n=Object.entries(__GLOBAL_CONFIG__.days||{}).map(([t,o])=>({name:t,date:o})).sort((t,o)=>t.date>o.date?1:-1).filter(t=>{const[o,e,n]=t.date.split("-").map(Number),a=new Date;return o>a.getFullYear()||o===a.getFullYear()&&(e>a.getMonth()+1||e===a.getMonth()+1&&n>=a.getDate())}).slice(0,o);if(n.length<o)for(let a=n.length;a<o;a++)n.push({name:"",date:"",isEmpty:!0});n.forEach((o,a)=>{const l=e.addStack();l.layoutHorizontally();const r=l.addStack();r.layoutVertically(),r.spacing=1;const i=r.addStack();i.layoutHorizontally(),i.spacing=2;const d=i.addText(o.name);d.font=Font.systemFont(16),d.textColor=Color.dynamic(new Color("#000000"),new Color("#FFFFFF"));const s=r.addStack();s.layoutHorizontally(),s.spacing=2;const c=o.isEmpty?null:function(t){try{const[o,e,n]=t.split("-").map(Number);return new Date(o,e-1,n)}catch(o){return null}}(o.date),g=s.addText(o.isEmpty?" ":function(o){const e=["周日","周一","周二","周三","周四","周五","周六"][o.getDay()],n=(o.getMonth()+1).toString().padStart(2,"0"),a=o.getDate().toString().padStart(2,"0");return`${o.getFullYear()}/${n}/${a}${"small"===t?"":`, ${e}`}`}(c));g.font=Font.regularRoundedSystemFont(9),g.textColor=Color.dynamic(new Color("#979797"),new Color("#8e8e8e")),l.addSpacer();const m=l.addStack();m.layoutHorizontally(),m.bottomAlignContent(),m.spacing=2;const u=o.isEmpty?" ":function(t){const o=new Date;o.setHours(0,0,0,0);const e=t.getTime()-o.getTime();return Math.floor(e/864e5)}(c),F=m.addStack();F.spacing=2,F.topAlignContent();const y=F.addText(u.toString());y.font=Font.boldRoundedSystemFont(22),y.textColor=Color.dynamic(new Color("#000000"),new Color("#FFFFFF")),y.rightAlignText();const p=m.addStack();if(p.setPadding(0,0,4,0),!o.isEmpty){const t=p.addText("天");t.font=Font.boldRoundedSystemFont(10),t.textColor=Color.dynamic(new Color("#979797"),new Color("#8e8e8e")),t.rightAlignText()}if(a<n.length-1){const n=e.addStack();n.layoutHorizontally(),n.setPadding(0,0,0,0),n.size=new Size("small"===t?126:306,1),n.borderWidth=1,n.borderColor=o.isEmpty?new Color("#FFFFFF",0):Color.dynamic(new Color("#E5E5E5"),new Color("#333333")),n.cornerRadius=1}}),config.runsInWidget?Script.setWidget(e):config.runsInApp&&("small"===t?e.presentSmall():"medium"===t?e.presentMedium():"large"===t&&e.presentLarge()),Script.complete();
1
+ !function(){let t;t=config.runsInWidget?config.widgetFamily||"small":"medium";const e={small:3,medium:3,large:7}[t],n=new ListWidget;n.backgroundColor=Color.dynamic(new Color("#FFFFFF"),new Color("#1c1c1c")),n.spacing=8;const o=Object.entries(function(t,e=""){try{return __GLOBAL_CONFIG__[t]}catch(n){return e}}("days",{})||{}).map(([t,e])=>({name:t,date:e})).sort((t,e)=>t.date>e.date?1:-1).filter(t=>{const[e,n,o]=t.date.split("-").map(Number),a=new Date;return e>a.getFullYear()||e===a.getFullYear()&&(n>a.getMonth()+1||n===a.getMonth()+1&&o>=a.getDate())}).slice(0,e);if(o.length<e)for(let a=o.length;a<e;a++)o.push({name:"",date:"",isEmpty:!0});o.forEach((e,a)=>{const l=n.addStack();l.layoutHorizontally();const r=l.addStack();r.layoutVertically(),r.spacing=1;const c=r.addStack();c.layoutHorizontally(),c.spacing=2;const i=c.addText(e.name);i.font=Font.mediumRoundedSystemFont(14),i.textColor=Color.dynamic(new Color("#000000"),new Color("#FFFFFF"));const d=r.addStack();d.layoutHorizontally(),d.spacing=2;const s=e.isEmpty?null:function(t){try{const[e,n,o]=t.split("-").map(Number);return new Date(e,n-1,o)}catch(e){return null}}(e.date),g=d.addText(e.isEmpty?" ":function(e){const n=["周日","周一","周二","周三","周四","周五","周六"][e.getDay()],o=(e.getMonth()+1).toString().padStart(2,"0"),a=e.getDate().toString().padStart(2,"0");return`${e.getFullYear()}/${o}/${a}${"small"===t?"":`, ${n}`}`}(s));g.font=Font.regularRoundedSystemFont(10),g.textColor=Color.dynamic(new Color("#979797"),new Color("#8e8e8e")),l.addSpacer();const m=l.addStack();m.layoutHorizontally(),m.bottomAlignContent(),m.spacing=2;const u=e.isEmpty?" ":function(t){const e=new Date;e.setHours(0,0,0,0);const n=t.getTime()-e.getTime();return Math.floor(n/864e5)}(s),y=m.addStack();y.spacing=2,y.topAlignContent();const F=y.addText(u.toString());F.font=Font.mediumRoundedSystemFont(24),F.textColor=Color.dynamic(new Color("#000000"),new Color("#FFFFFF")),F.rightAlignText();const p=m.addStack();if(p.setPadding(0,0,4,0),!e.isEmpty){const t=p.addText("天");t.font=Font.boldRoundedSystemFont(10),t.textColor=Color.dynamic(new Color("#979797"),new Color("#8e8e8e")),t.rightAlignText()}if(a<o.length-1){const e=n.addStack();e.layoutHorizontally(),e.centerAlignContent();const o="small"===t?126:305,a=1,l=new DrawContext;l.size=new Size(o,a),l.opaque=!1,l.respectScreenScale=!0,l.setFillColor(Color.dynamic(new Color("#E5E5E5"),new Color("#333333")));const r=new Path;r.addRoundedRect(new Rect(0,0,o,a),a/2,a/2),l.addPath(r),l.fillPath();e.addImage(l.getImage()).centerAlignImage()}}),config.runsInWidget?Script.setWidget(n):config.runsInApp&&("small"===t?n.presentSmall():"medium"===t?n.presentMedium():"large"===t&&n.presentLarge()),Script.complete()}();
@@ -1 +1 @@
1
- let e;e=config.runsInWidget&&config.widgetFamily||"small";const n=new ListWidget,t=new LinearGradient;t.colors=[new Color("#ffcb8e"),new Color("#6e35ff")],t.locations=[0,1],t.startPoint=new Point(0,0),t.endPoint=new Point(1,1),n.backgroundGradient=t;const o=n.addText(`Hello, ${__GLOBAL_CONFIG__.name||"World"}`);o.font=Font.boldSystemFont(16),o.textColor=Color.dynamic(new Color("#FFFFFF"),new Color("#000000")),o.centerAlignText(),config.runsInWidget?Script.setWidget(n):"small"===e?n.presentSmall():"medium"===e?n.presentMedium():"large"===e&&n.presentLarge(),Script.complete();
1
+ !function(){let o;o=config.runsInWidget&&config.widgetFamily||"small";const n=new ListWidget;n.backgroundColor=Color.dynamic(new Color("#FFFFFF"),new Color("#1c1c1c"));const e=n.addText(`Hello, ${function(o,n=""){try{return __GLOBAL_CONFIG__[o]}catch(e){return n}}("name","World")}`);e.textColor=Color.dynamic(new Color("#000000"),new Color("#FFFFFF")),e.font=Font.boldSystemFont(16),e.centerAlignText(),console.log("config:"),console.log(JSON.stringify(config,null,2)),config.runsInWidget?Script.setWidget(n):"small"===o?n.presentSmall():"medium"===o?n.presentMedium():"large"===o&&n.presentLarge(),Script.complete()}();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@showlotus/open-scriptable",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "description": "Open-source Scriptable scripts for iOS Widgets",
5
5
  "type": "module",
6
6
  "packageManager": "pnpm@8.10.0",
package/scriptable.d.ts CHANGED
@@ -837,7 +837,7 @@ declare global {
837
837
  /** 缩放因子 */
838
838
  respectScreenScale: boolean;
839
839
 
840
- constructor(size: Size);
840
+ constructor();
841
841
 
842
842
  /** 获取图像 */
843
843
  getImage(): Image;
@@ -853,6 +853,8 @@ declare global {
853
853
  setLineWidth(width: number): void;
854
854
  /** 填充矩形 */
855
855
  fill(rect: Rect): void;
856
+ /** 填充矩形 */
857
+ fillRect(rect: Rect): void;
856
858
  /** 填充椭圆 */
857
859
  fillEllipse(rect: Rect): void;
858
860
  /** 描边矩形 */