quote0 0.0.0

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 (3) hide show
  1. package/LICENSE +21 -0
  2. package/dist/index.mjs +2 -0
  3. package/package.json +49 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Mr. Will
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/index.mjs ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import"dotenv/config";import e from"yargs";import{hideBin as t}from"yargs/helpers";import{Box as n,Text as r,render as i}from"ink";import a from"node:fs/promises";import o from"ky";import s from"node:path";import c from"react";import l from"ink-spinner";import u from"satori";import d from"sharp";import{jsx as f,jsxs as p}from"react/jsx-runtime";const m={quote0ApiKey:process.env.QUOTE0_API_KEY,quote0DeviceId:process.env.QUOTE0_DEVICEID,dotApiEndpoint:`https://dot.mindreset.tech/api`,quote0Width:296,quote0Height:152,composeApiUrl:e=>e.startsWith(`/`)?m.dotApiEndpoint+e:m.dotApiEndpoint+`/`+e,fetchApi:async(e,t)=>{let n=m.composeApiUrl(e),r=Object.assign({method:`GET`,headers:{"Content-Type":`application/json`,Authorization:`Bearer `+m.quote0ApiKey}},t??{});try{let e=await fetch(n,r);if(e.ok)return await e.json();throw Error(`API request failed with status ${e.status}: ${e.statusText}`)}catch(e){throw e}}};async function h(){return await m.fetchApi(`/authV2/open/device/${m.quote0DeviceId}/status`)}async function g(e){return await m.fetchApi(`/authV2/open/device/${m.quote0DeviceId}/image`,{method:`POST`,body:JSON.stringify(e)})}const _={border:(...e)=>({borderTop:e.includes(`top`),borderRight:e.includes(`right`),borderBottom:e.includes(`bottom`),borderLeft:e.includes(`left`)})};e(t(process.argv)).command(`status`,`Check device status`,e=>e,async e=>{try{let e=await h();i(p(n,{borderStyle:`round`,flexDirection:`column`,children:[p(n,{justifyContent:`space-between`,width:`100%`,borderStyle:`single`,..._.border(`bottom`),borderDimColor:!0,paddingX:1,children:[p(n,{gap:1,children:[f(r,{children:e.alias}),f(r,{dimColor:!0,children:e.location}),f(r,{dimColor:!0,children:e.status.battery})]}),p(r,{children:[f(r,{dimColor:!0,children:`Device ID: `}),e.deviceId]})]}),p(n,{flexDirection:`column`,paddingX:1,children:[p(n,{justifyContent:`space-between`,width:`100%`,children:[f(r,{dimColor:!0,children:`Status`}),f(r,{children:e.status.current})]}),p(n,{justifyContent:`space-between`,width:`100%`,children:[f(r,{dimColor:!0,children:`Last Render`}),f(r,{children:e.renderInfo.last})]}),p(n,{justifyContent:`space-between`,width:`100%`,children:[f(r,{dimColor:!0,children:`Next Render (Battery)`}),f(r,{children:e.renderInfo.next.battery})]}),p(n,{justifyContent:`space-between`,width:`100%`,children:[f(r,{dimColor:!0,children:`Next Render (Power)`}),f(r,{children:e.renderInfo.next.power})]}),p(n,{justifyContent:`space-between`,width:`100%`,children:[f(r,{dimColor:!0,children:`Current Images`}),f(r,{children:e.renderInfo.current.image.length})]}),p(n,{justifyContent:`space-between`,width:`100%`,children:[f(r,{dimColor:!0,children:`Version`}),p(r,{children:[f(r,{dimColor:!0,children:`v`}),e.status.version]})]})]})]}))}catch(e){console.error(e)}}).command(`prepare`,`Download necessary resources`,e=>e,async e=>{let t=[{filename:`DepartureMono-Regular.otf`,url:`https://departuremono.com/assets/DepartureMono-Regular.otf`}];await a.mkdir(`cache/resources`,{recursive:!0}),i(f(()=>{let[e,i]=c.useState(t.map(()=>({percent:0,done:!1})));return c.useEffect(()=>{(async()=>{await Promise.all(t.map(async({filename:e,url:t},n)=>{let r=await o.get(t,{onDownloadProgress:e=>{i(t=>{let r=[...t];return r[n].percent=e.percent,r})}}).bytes();await a.writeFile(s.join(`cache/resources`,e),r),i(e=>{let t=[...e];return t[n].done=!0,t})}))})()},[]),p(n,{flexDirection:`column`,borderStyle:`round`,children:[p(n,{justifyContent:`space-between`,borderStyle:`single`,..._.border(`bottom`),borderDimColor:!0,paddingX:1,children:[f(r,{children:`Downloading…`}),p(r,{dimColor:!0,children:[e.filter(e=>e.done).length,`/`,t.length]})]}),f(n,{flexDirection:`column`,paddingX:1,children:t.map(({filename:t},i)=>p(n,{justifyContent:`space-between`,children:[p(r,{children:[e[i].done?f(r,{dimColor:!0,children:`✓`}):f(l,{}),` `,t]}),p(r,{children:[Math.round(e[i].percent*100),`%`]})]},i))})]})},{}))}).command(`serve`,`Start periodically rendering and pushing images`,e=>e,async e=>{let t=[`SVG Rendering`,`SVG Saving`,`PNG Conversion`,`PNG Saving`,`Base64 Encoding`,`Pushing to Device`];i(f(()=>{let[e,i]=c.useState(-1),o=()=>{i(e=>e+1)};return c.useEffect(()=>{(async()=>{o();let e=await u(f(`div`,{style:{width:m.quote0Width,height:m.quote0Height,color:`black`,backgroundColor:`white`,fontFamily:`Departure Mono`,fontSize:`11px`,lineHeight:`12px`},children:`hello, world`}),{width:m.quote0Width,height:m.quote0Height,fonts:[{name:`Departure Mono`,data:await a.readFile(s.join(`cache/resources`,`DepartureMono-Regular.otf`)),weight:400,style:`normal`}]});o(),await a.writeFile(`cache/out.svg`,e),o();let t=await d(Buffer.from(e)).png().toBuffer();o(),await a.writeFile(`cache/out.png`,t),o();let n=t.toString(`base64`);o(),await g({image:n,ditherType:`NONE`}),o()})()},[]),p(n,{flexDirection:`column`,borderStyle:`round`,children:[f(n,{borderStyle:`single`,..._.border(`bottom`),borderDimColor:!0,paddingX:1,children:f(r,{children:`Progress`})}),f(n,{flexDirection:`column`,paddingX:1,children:t.map((t,i)=>f(n,{justifyContent:`space-between`,children:p(r,{children:[e===i?f(l,{}):f(r,{dimColor:!0,children:e>i?`✓`:` `}),` `,t]})},i))})]})},{}))}).demandCommand(1,`Please specify a command`).parse();export{};
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "quote0",
3
+ "version": "0.0.0",
4
+ "description": "Access your Quote/0 from the command line.",
5
+ "type": "module",
6
+ "main": "dist/index.mjs",
7
+ "scripts": {
8
+ "build": "tsc --noEmit && tsdown",
9
+ "dev": "tsx src/index.tsx",
10
+ "start": "node dist/index.mjs",
11
+ "format": "prettier . --write",
12
+ "changeset": "changeset"
13
+ },
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "keywords": [
18
+ "quote0",
19
+ "e-ink",
20
+ "cli"
21
+ ],
22
+ "author": "Mr. Will (https://github.com/MrWillCom)",
23
+ "license": "MIT",
24
+ "repository": "MrWillCom/quote0",
25
+ "bugs": {
26
+ "url": "https://github.com/MrWillCom/quote0/issues"
27
+ },
28
+ "packageManager": "pnpm@10.30.1+sha512.3590e550d5384caa39bd5c7c739f72270234b2f6059e13018f975c313b1eb9fefcc09714048765d4d9efe961382c312e624572c0420762bdc5d5940cdf9be73a",
29
+ "devDependencies": {
30
+ "@changesets/cli": "^2.29.8",
31
+ "@types/node": "^25.3.0",
32
+ "@types/react": "^19.2.14",
33
+ "@types/yargs": "^17.0.35",
34
+ "prettier": "3.8.1",
35
+ "tsdown": "^0.20.3",
36
+ "tsx": "^4.21.0",
37
+ "typescript": "^5.9.3"
38
+ },
39
+ "dependencies": {
40
+ "dotenv": "^17.3.1",
41
+ "ink": "^6.8.0",
42
+ "ink-spinner": "^5.0.0",
43
+ "ky": "^1.14.3",
44
+ "react": "^19.2.4",
45
+ "satori": "^0.19.2",
46
+ "sharp": "^0.34.5",
47
+ "yargs": "^18.0.0"
48
+ }
49
+ }