@showlotus/open-scriptable 0.1.15 → 0.1.17
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 +1 -1
- package/dist/dev.js +1 -1
- package/dist/hello-world.js +1 -1
- package/package.json +1 -1
package/dist/count-down.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function I(r,y=""){try{return __GLOBAL_CONFIG__[r]}catch(d){return y}}function L(){let r;config.runsInWidget?r=config.widgetFamily||"small":r="large";const d={small:3,medium:3,large:7}[r];function S(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 h(t){const o=["周日","周一","周二","周三","周四","周五","周六"][t.getDay()],n=(t.getMonth()+1).toString().padStart(2,"0"),a=t.getDate().toString().padStart(2,"0");return`${t.getFullYear()}/${n}/${a}${r==="small"?"":`, ${o}`}`}function x(t){try{const[e,o,n]=t.split("-").map(Number);return new Date(e,o-1,n)}catch(e){return null}}function D(t,e,o){const n=new DrawContext;n.size=new Size(t,e),n.opaque=!1,n.respectScreenScale=!0,n.setFillColor(o);const a=new Path;return a.addRoundedRect(new Rect(0,0,t,e),e/2,e/2),n.addPath(a),n.fillPath(),n.getImage()}const l=new ListWidget;l.backgroundColor=Color.dynamic(new Color("#FFFFFF"),new Color("#1c1c1c")),l.spacing=8;const s=Object.entries(I("days",{})||{}).map(([t,e])=>({name:t,date:e,isEmpty:!1})).sort((t,e)=>t.date>e.date?1:-1).filter(t=>{const[e,o,n]=t.date.split("-").map(Number),a=new Date;return e>a.getFullYear()?!0:e===a.getFullYear()?o>a.getMonth()+1||o===a.getMonth()+1&&n>=a.getDate():!1}).slice(0,d);if(s.length>0&&s.length<d)for(let t=s.length;t<d;t++)s.push({name:"",date:"",isEmpty:!0});s.forEach((t,e)=>{const o=l.addStack();o.layoutHorizontally();const n=o.addStack();n.layoutVertically(),n.spacing=1;const a=n.addStack();a.layoutHorizontally(),a.spacing=2;const g=a.addText(t.name);g.font=Font.mediumRoundedSystemFont(14),g.textColor=Color.dynamic(new Color("#000000"),new Color("#FFFFFF"));const m=n.addStack();m.layoutHorizontally(),m.spacing=2;const p=t.isEmpty?null:x(t.date),C=m.addText(t.isEmpty?" ":h(p));C.font=Font.regularRoundedSystemFont(10),C.textColor=Color.dynamic(new Color("#979797"),new Color("#8e8e8e")),o.addSpacer();const c=o.addStack();c.layoutHorizontally(),c.bottomAlignContent(),c.spacing=2;const T=t.isEmpty?" ":S(p),f=c.addStack();f.spacing=2,f.topAlignContent();const u=f.addText(T.toString());u.font=Font.mediumRoundedSystemFont(24),u.textColor=Color.dynamic(new Color("#000000"),new Color("#FFFFFF")),u.rightAlignText();const F=c.addStack();if(F.setPadding(0,0,4,0),!t.isEmpty){const i=F.addText("天");i.font=Font.boldRoundedSystemFont(10),i.textColor=Color.dynamic(new Color("#979797"),new Color("#8e8e8e")),i.rightAlignText()}if(e<s.length-1){const i=l.addStack();i.layoutHorizontally(),i.centerAlignContent();const k=r==="small"?126:305,z=1;let w=new Color("#8C8C8C",.2);t.isEmpty&&(w=new Color("#ffffff",0)),i.addImage(D(k,z,w)).centerAlignImage()}}),config.runsInWidget?Script.setWidget(l):config.runsInApp&&(r==="small"?l.presentSmall():r==="medium"?l.presentMedium():r==="large"&&l.presentLarge()),Script.complete()}L();
|
package/dist/dev.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var n=(a,t,e)=>new Promise((o,c)=>{var s=r=>{try{i(e.next(r))}catch(l){c(l)}},u=r=>{try{i(e.throw(r))}catch(l){c(l)}},i=r=>r.done?o(r.value):Promise.resolve(r.value).then(s,u);i((e=e.apply(a,t)).next())});function w(){return n(this,null,function*(){function a(t,e=3e3){return n(this,null,function*(){const o=n(null,null,function*(){return yield new Request(t).loadString()}),c=n(null,null,function*(){throw yield new Promise(s=>{Timer.schedule(e,!1,s)}),new Error(`Timeout after ${e} ms`)});return Promise.race([o,c])})}try{const e=yield a("http://192.168.5.2:3000/src/hello-world.ts");yield new Function(e)()}catch(t){console.error(t)}finally{Script.complete()}})}w();
|
package/dist/hello-world.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
var s=(n,o,e)=>new Promise((g,i)=>{var l=t=>{try{r(e.next(t))}catch(c){i(c)}},d=t=>{try{r(e.throw(t))}catch(c){i(c)}},r=t=>t.done?g(t.value):Promise.resolve(t.value).then(l,d);r((e=e.apply(n,o)).next())});function f(n,o=""){try{return __GLOBAL_CONFIG__[n]}catch(e){return o}}function F(){return s(this,null,function*(){let n;config.runsInWidget?n=config.widgetFamily||"small":n="small";function o(g){const i=new ListWidget;i.backgroundColor=Color.dynamic(new Color("#FFFFFF"),new Color("#1c1c1c"));const l=i.addText(`Hello, ${f("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 e;return config.runsInWidget?(e=o(),Script.setWidget(e)):(e=o(),n==="small"?e.presentSmall():n==="medium"?e.presentMedium():n==="large"&&e.presentLarge()),e})}F();
|