@fluxlay/react 1.1.1 → 1.2.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.
package/README.md CHANGED
@@ -7,7 +7,7 @@ SDK for building [Fluxlay](https://fluxlay.com) wallpapers with React.
7
7
  ```sh
8
8
  npm install @fluxlay/react
9
9
  # or
10
- pnpm add @fluxlay/react
10
+ bun add @fluxlay/react
11
11
  ```
12
12
 
13
13
  Also import the stylesheet in your entry file:
package/dist/index.d.mts CHANGED
@@ -112,8 +112,19 @@ interface MediaMetadataInfo {
112
112
  /** Whether media is currently playing. */
113
113
  isPlaying: boolean;
114
114
  }
115
+ /**
116
+ * A single custom property value set by the end user via the Fluxlay settings UI.
117
+ *
118
+ * Mapping by manifest property type:
119
+ * - `number` / `range`: `number`
120
+ * - `text` / `select` / `color` / `font`: `string`
121
+ * - `boolean`: `boolean`
122
+ * - `multi-select`: `string[]`
123
+ * - `image` / `file`: absolute filesystem path as `string`, or `null` when the user has not picked a file.
124
+ */
125
+ type PropertyValue = number | string | boolean | string[] | null;
115
126
  /** Custom property values set by the end user via the Fluxlay settings UI. */
116
- type PropertyValues = Record<string, number | string | boolean>;
127
+ type PropertyValues = Record<string, PropertyValue>;
117
128
  //#endregion
118
129
  //#region src/hooks/use-audio.d.ts
119
130
  /** Options for the audio stream. */
@@ -133,6 +144,17 @@ interface AudioOptions {
133
144
  */
134
145
  declare function useAudio(options?: AudioOptions): AudioInfo;
135
146
  //#endregion
147
+ //#region src/lib/file-url.d.ts
148
+ /**
149
+ * Build a URL the wallpaper webview can use to load a local file referenced
150
+ * by an `image` or `file` property value.
151
+ *
152
+ * The file is served by the Fluxlay desktop app via `GET /v1/file` and is
153
+ * restricted to paths currently assigned to an `image` / `file` property of
154
+ * the active wallpaper. Returns `null` when the path is missing.
155
+ */
156
+ declare function getPropertyFileUrl(path: string | null | undefined): string | null;
157
+ //#endregion
136
158
  //#region src/hooks/use-media-metadata.d.ts
137
159
  /** Options for the media metadata stream. */
138
160
  interface MediaMetadataOptions {
@@ -380,4 +402,4 @@ declare const TerminalThemes: {
380
402
  };
381
403
  };
382
404
  //#endregion
383
- export { AudioOptions, MediaMetadataOptions, ShellOptions, type ShellResult, SystemMonitorOptions, TerminalInstance, TerminalThemes, UseShellOptions, UseTerminalOptions, runShell, useAudio, useMediaMetadata, useMousePosition, useProperties, useShell, useSystemMonitor, useTerminal };
405
+ export { AudioOptions, MediaMetadataOptions, ShellOptions, type ShellResult, SystemMonitorOptions, TerminalInstance, TerminalThemes, UseShellOptions, UseTerminalOptions, getPropertyFileUrl, runShell, useAudio, useMediaMetadata, useMousePosition, useProperties, useShell, useSystemMonitor, useTerminal };
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import{useCallback as e,useEffect as t,useRef as n,useState as r}from"react";import{FitAddon as i}from"@xterm/addon-fit";import{Terminal as a}from"@xterm/xterm";import"@xterm/xterm/css/xterm.css";var o=class{get baseUrl(){return`http://127.0.0.1:${new URLSearchParams(window.location.search).get(`fluxlay_port`)||`1421`}/v1`}pendingInvokes=new Map;async invoke(e,t){let n=new URLSearchParams(window.location.search).get(`window_label`)||`main`,r=`${e}:${n}:${JSON.stringify(t)}`;if(this.pendingInvokes.has(r))return this.pendingInvokes.get(r);let i=(async()=>{try{let r=await fetch(`${this.baseUrl}/${e}?window_label=${n}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!r.ok)throw Error(`Failed to invoke ${e}: ${r.statusText}`);return await r.json()}finally{this.pendingInvokes.delete(r)}})();return this.pendingInvokes.set(r,i),i}subscribe(e,t,n){let r=new AbortController,i=new URLSearchParams(window.location.search).get(`window_label`)||`main`,a=new URLSearchParams({window_label:i,...n}),o=`${this.baseUrl}/${e}?${a.toString()}`;return(async()=>{try{let n=await fetch(o,{signal:r.signal});if(!n.ok||!n.body)throw Error(`Failed to subscribe to ${e}: ${n.statusText}`);let i=n.body.getReader(),a=new TextDecoder,s=``;for(;;){let{done:e,value:n}=await i.read();if(e)break;s+=a.decode(n,{stream:!0});let r=s.split(`
2
- `);s=r.pop()||``;for(let e of r){let n=e.trim();if(n)try{t(JSON.parse(n))}catch(e){console.error(`Failed to parse NDJSON line:`,e)}}}}catch(t){t.name!==`AbortError`&&console.error(`Error in subscription to ${e}:`,t)}})(),()=>{r.abort()}}};const s=new o;function c(e){let[n,i]=r({rms:0,peak:0,spectrum:[]}),a=e?.numBands;return t(()=>{let e={};a!==void 0&&(e.num_bands=String(a));let t=s.subscribe(`audio-stream`,e=>i(e),e);return()=>{t()}},[a]),n}const l=new o;function u(e){let[n,i]=r({title:null,artist:null,album:null,artwork:null,duration:null,elapsedTime:null,playbackRate:null,isPlaying:!1}),a=e?.intervalMs;return t(()=>{let e={};a!==void 0&&(e.interval_ms=String(a));let t=l.subscribe(`media-metadata-stream`,e=>i(e),e);return()=>{t()}},[a]),n}const d=new o;function f(){let[e,n]=r({x:0,y:0});return t(()=>{let e=new URLSearchParams(window.location.search).get(`window_label`)||`main`,t=d.subscribe(`mouse-stream`,e=>{n({x:e.x,y:-e.y})},{window_label:e});return()=>{t()}},[]),e}const p=new o;function m(){let[e,n]=r({});return t(()=>{p.invoke(`properties`,{}).then(n);let e=p.subscribe(`properties-stream`,e=>n(e));return()=>{e()}},[]),e}const h=new o;async function g(e,t){return await h.invoke(`run-script`,{scriptId:e,columns:t?.columns,lines:t?.lines})}function _(i,a={}){let{showStdout:o=!0,showStderr:s=!1,refreshInterval:c=3e4,terminal:l}=a,[u,d]=r(!1),[f,p]=r(null),[m,h]=r(null),_=n(a);t(()=>{_.current=a},[a]);let v=e(async()=>{if(!u){d(!0),p(null);try{let e=_.current,t=e.columns,n=e.lines;l&&(l.fitAddon.fit(),t=l.terminal.cols,n=l.terminal.rows);let r=await g(i,{...e,columns:t,lines:n});h(r),r.success||p(`Command failed with status ${r.statusCode}: ${r.stderr}`)}catch(e){p(String(e))}finally{d(!1)}}},[i,l]);return t(()=>{if(!l||!m)return;let{terminal:e}=l;if(e.reset(),m.success){let t=``;o&&(t+=m.stdout),s&&(t+=m.stderr);let n=t.trimEnd();if(n){e.write(n);let t=n.split(`
3
- `).length;e.resize(e.cols,Math.max(1,t))}else e.resize(e.cols,1)}else{let t=`Command failed with status ${m.statusCode}: ${m.stderr}`;e.write(`\x1b[31m${t.trimEnd()}\x1b[0m`),e.resize(e.cols,1)}},[l,m,o,s]),t(()=>{v()},[i]),t(()=>{if(!c)return;let e=setInterval(v,c);return()=>clearInterval(e)},[v,c]),{execute:v,isRunning:u,error:f,result:m}}const v=new o;function y(e){let[n,i]=r({cpuUsage:0,cpuPerCore:[],cpuFrequencyMhz:[],memoryTotal:0,memoryUsed:0,memoryUsage:0,swapTotal:0,swapUsed:0,swapUsage:0,batteryLevel:null,batteryCharging:null,networkRxBytesPerSec:0,networkTxBytesPerSec:0,diskReadBytesPerSec:0,diskWriteBytesPerSec:0,processCount:0,uptimeSecs:0,loadAverage:[0,0,0],disks:[],hostname:``,osName:``,cpuBrand:``,physicalCoreCount:0,logicalCoreCount:0,cpuArch:``,kernelVersion:``}),a=e?.cpuIntervalMs,o=e?.memoryIntervalMs,s=e?.networkIntervalMs,c=e?.diskIoIntervalMs,l=e?.diskSpaceIntervalMs,u=e?.batteryIntervalMs,d=e?.processIntervalMs,f=e?.loadAverageIntervalMs;return t(()=>{let e={};a!==void 0&&(e.cpu_interval_ms=String(a)),o!==void 0&&(e.memory_interval_ms=String(o)),s!==void 0&&(e.network_interval_ms=String(s)),c!==void 0&&(e.disk_io_interval_ms=String(c)),l!==void 0&&(e.disk_space_interval_ms=String(l)),u!==void 0&&(e.battery_interval_ms=String(u)),d!==void 0&&(e.process_interval_ms=String(d)),f!==void 0&&(e.load_average_interval_ms=String(f));let t=v.subscribe(`system-monitor-stream`,e=>i(e),e);return()=>{t()}},[a,o,s,c,l,u,d,f]),n}const b={dark:{default:{background:`#00000000`,foreground:`#ffffff`,cursor:`#00000000`,black:`#000000`,red:`#ef4444`,green:`#22c55e`,yellow:`#f59e0b`,blue:`#3b82f6`,magenta:`#a855f7`,cyan:`#06b6d4`,white:`#ffffff`,brightBlack:`#71717a`,brightRed:`#f87171`,brightGreen:`#4ade80`,brightYellow:`#fbbf24`,brightBlue:`#60a5fa`,brightMagenta:`#c084fc`,brightCyan:`#22d3ee`,brightWhite:`#ffffff`},modern:{background:`#00000000`,foreground:`#e2e8f0`,cursor:`#00000000`,black:`#1e293b`,red:`#f43f5e`,green:`#10b981`,yellow:`#f59e0b`,blue:`#3b82f6`,magenta:`#8b5cf6`,cyan:`#06b6d4`,white:`#f1f5f9`,brightBlack:`#475569`,brightRed:`#fb7185`,brightGreen:`#34d399`,brightYellow:`#fbbf24`,brightBlue:`#60a5fa`,brightMagenta:`#a78bfa`,brightCyan:`#22d3ee`,brightWhite:`#ffffff`}},light:{default:{background:`#00000000`,foreground:`#18181b`,cursor:`#00000000`,black:`#000000`,red:`#ef4444`,green:`#22c55e`,yellow:`#f59e0b`,blue:`#3b82f6`,magenta:`#a855f7`,cyan:`#06b6d4`,white:`#ffffff`,brightBlack:`#71717a`,brightRed:`#f87171`,brightGreen:`#4ade80`,brightYellow:`#fbbf24`,brightBlue:`#60a5fa`,brightMagenta:`#c084fc`,brightCyan:`#22d3ee`,brightWhite:`#ffffff`},modern:{background:`#00000000`,foreground:`#334155`,cursor:`#00000000`,black:`#0f172a`,red:`#dc2626`,green:`#16a34a`,yellow:`#d97706`,blue:`#2563eb`,magenta:`#7c3aed`,cyan:`#0891b2`,white:`#f8fafc`,brightBlack:`#64748b`,brightRed:`#ef4444`,brightGreen:`#22c55e`,brightYellow:`#f59e0b`,brightBlue:`#3b82f6`,brightMagenta:`#8b5cf6`,brightCyan:`#06b6d4`,brightWhite:`#ffffff`}},nord:{background:`#2E3440`,foreground:`#D8DEE9`,cursor:`#D8DEE9`,black:`#3B4252`,red:`#BF616A`,green:`#A3BE8C`,yellow:`#EBCB8B`,blue:`#81A1C1`,magenta:`#B48EAD`,cyan:`#88C0D0`,white:`#E5E9F0`,brightBlack:`#4C566A`,brightRed:`#BF616A`,brightGreen:`#A3BE8C`,brightYellow:`#EBCB8B`,brightBlue:`#81A1C1`,brightMagenta:`#B48EAD`,brightCyan:`#8FBCBB`,brightWhite:`#ECEFF4`},dracula:{background:`#282a36`,foreground:`#f8f8f2`,cursor:`#f8f8f2`,black:`#21222c`,red:`#ff5555`,green:`#50fa7b`,yellow:`#f1fa8c`,blue:`#bd93f9`,magenta:`#ff79c6`,cyan:`#8be9fd`,white:`#f8f8f2`,brightBlack:`#6272a4`,brightRed:`#ff6e6e`,brightGreen:`#69ff94`,brightYellow:`#ffffa5`,brightBlue:`#d6acff`,brightMagenta:`#ff92df`,brightCyan:`#a4ffff`,brightWhite:`#ffffff`},gruvbox:{dark:{background:`#282828`,foreground:`#ebdbb2`,cursor:`#ebdbb2`,black:`#282828`,red:`#cc241d`,green:`#98971a`,yellow:`#d79921`,blue:`#458588`,magenta:`#b16286`,cyan:`#689d6a`,white:`#a89984`,brightBlack:`#928374`,brightRed:`#fb4934`,brightGreen:`#b8bb26`,brightYellow:`#fabd2f`,brightBlue:`#83a598`,brightMagenta:`#d3869b`,brightCyan:`#8ec07c`,brightWhite:`#ebdbb2`},light:{background:`#fbf1c7`,foreground:`#3c3836`,cursor:`#3c3836`,black:`#fbf1c7`,red:`#cc241d`,green:`#98971a`,yellow:`#d79921`,blue:`#458588`,magenta:`#b16286`,cyan:`#689d6a`,white:`#7c6f64`,brightBlack:`#928374`,brightRed:`#9d0006`,brightGreen:`#79740e`,brightYellow:`#b57614`,brightBlue:`#076678`,brightMagenta:`#8f3f71`,brightCyan:`#427b58`,brightWhite:`#3c3836`}},solarized:{dark:{background:`#002b36`,foreground:`#839496`,cursor:`#93a1a1`,black:`#073642`,red:`#dc322f`,green:`#859900`,yellow:`#b58900`,blue:`#268bd2`,magenta:`#d33682`,cyan:`#2aa198`,white:`#eee8d5`,brightBlack:`#002b36`,brightRed:`#cb4b16`,brightGreen:`#586e75`,brightYellow:`#657b83`,brightBlue:`#839496`,brightMagenta:`#6c71c4`,brightCyan:`#93a1a1`,brightWhite:`#fdf6e3`},light:{background:`#fdf6e3`,foreground:`#657b83`,cursor:`#586e75`,black:`#073642`,red:`#dc322f`,green:`#859900`,yellow:`#b58900`,blue:`#268bd2`,magenta:`#d33682`,cyan:`#2aa198`,white:`#eee8d5`,brightBlack:`#002b36`,brightRed:`#cb4b16`,brightGreen:`#586e75`,brightYellow:`#657b83`,brightBlue:`#839496`,brightMagenta:`#6c71c4`,brightCyan:`#93a1a1`,brightWhite:`#fdf6e3`}},oneDark:{background:`#282c34`,foreground:`#abb2bf`,cursor:`#528bff`,black:`#282c34`,red:`#e06c75`,green:`#98c379`,yellow:`#e5c07b`,blue:`#61afef`,magenta:`#c678dd`,cyan:`#56b6c2`,white:`#abb2bf`,brightBlack:`#5c6370`,brightRed:`#e06c75`,brightGreen:`#98c379`,brightYellow:`#e5c07b`,brightBlue:`#61afef`,brightMagenta:`#c678dd`,brightCyan:`#56b6c2`,brightWhite:`#ffffff`},catppuccin:{latte:{background:`#eff1f5`,foreground:`#4c4f69`,cursor:`#dc8a78`,black:`#5c5f77`,red:`#d20f39`,green:`#40a02b`,yellow:`#df8e1d`,blue:`#1e66f5`,magenta:`#ea76cb`,cyan:`#179299`,white:`#acb0be`,brightBlack:`#6c6f85`,brightRed:`#d20f39`,brightGreen:`#40a02b`,brightYellow:`#df8e1d`,brightBlue:`#1e66f5`,brightMagenta:`#ea76cb`,brightCyan:`#179299`,brightWhite:`#bcc0cc`},frappe:{background:`#303446`,foreground:`#c6d0f5`,cursor:`#f2d5cf`,black:`#51576d`,red:`#e78284`,green:`#a6d189`,yellow:`#e5c890`,blue:`#8caaee`,magenta:`#f4b8e4`,cyan:`#81c8be`,white:`#b5bfe2`,brightBlack:`#626880`,brightRed:`#e78284`,brightGreen:`#a6d189`,brightYellow:`#e5c890`,brightBlue:`#8caaee`,brightMagenta:`#f4b8e4`,brightCyan:`#81c8be`,brightWhite:`#a5adce`},macchiato:{background:`#24273a`,foreground:`#cad3f5`,cursor:`#f4dbd6`,black:`#494d64`,red:`#ed8796`,green:`#a6da95`,yellow:`#eed49f`,blue:`#8aadf4`,magenta:`#f5bde6`,cyan:`#8bd5ca`,white:`#b8c0e0`,brightBlack:`#5b6078`,brightRed:`#ed8796`,brightGreen:`#a6da95`,brightYellow:`#eed49f`,brightBlue:`#8aadf4`,brightMagenta:`#f5bde6`,brightCyan:`#8bd5ca`,brightWhite:`#a5adcb`},mocha:{background:`#1e1e2e`,foreground:`#cdd6f4`,cursor:`#f5e0dc`,black:`#45475a`,red:`#f38ba8`,green:`#a6e3a1`,yellow:`#f9e2af`,blue:`#89b4fa`,magenta:`#f5c2e7`,cyan:`#94e2d5`,white:`#bac2de`,brightBlack:`#585b70`,brightRed:`#f38ba8`,brightGreen:`#a6e3a1`,brightYellow:`#f9e2af`,brightBlue:`#89b4fa`,brightMagenta:`#f5c2e7`,brightCyan:`#94e2d5`,brightWhite:`#a6adc8`}},monokaiPro:{background:`#2D2A2E`,foreground:`#FCFCFA`,cursor:`#FCFCFA`,black:`#403E41`,red:`#FF6188`,green:`#A9DC76`,yellow:`#FFD866`,blue:`#FC9867`,magenta:`#AB9DF2`,cyan:`#78DCE8`,white:`#FCFCFA`,brightBlack:`#727072`,brightRed:`#FF6188`,brightGreen:`#A9DC76`,brightYellow:`#FFD866`,brightBlue:`#FC9867`,brightMagenta:`#AB9DF2`,brightCyan:`#78DCE8`,brightWhite:`#FCFCFA`},tokyoNight:{background:`#1a1b26`,foreground:`#a9b1d6`,cursor:`#c0caf5`,black:`#32344a`,red:`#f7768e`,green:`#9ece6a`,yellow:`#e0af68`,blue:`#7aa2f7`,magenta:`#ad8ee6`,cyan:`#449dab`,white:`#787c99`,brightBlack:`#444b6a`,brightRed:`#ff7a93`,brightGreen:`#b9f27c`,brightYellow:`#ff9e64`,brightBlue:`#7da6ff`,brightMagenta:`#bb9af7`,brightCyan:`#0db9d7`,brightWhite:`#acb0d0`},nightOwl:{background:`#011627`,foreground:`#d6deeb`,cursor:`#80a4c2`,black:`#011627`,red:`#ef5350`,green:`#22da6e`,yellow:`#addb67`,blue:`#82aaff`,magenta:`#c792ea`,cyan:`#21c7a8`,white:`#ffffff`,brightBlack:`#575656`,brightRed:`#ef5350`,brightGreen:`#22da6e`,brightYellow:`#ffeb95`,brightBlue:`#82aaff`,brightMagenta:`#c792ea`,brightCyan:`#7fdbca`,brightWhite:`#ffffff`},everforest:{dark:{background:`#2b3339`,foreground:`#d3c6aa`,cursor:`#d3c6aa`,black:`#4b565c`,red:`#e67e80`,green:`#a7c080`,yellow:`#dbbc7f`,blue:`#7fbbb3`,magenta:`#d699b6`,cyan:`#83c092`,white:`#d3c6aa`,brightBlack:`#4b565c`,brightRed:`#e67e80`,brightGreen:`#a7c080`,brightYellow:`#dbbc7f`,brightBlue:`#7fbbb3`,brightMagenta:`#d699b6`,brightCyan:`#83c092`,brightWhite:`#d3c6aa`},light:{background:`#fdf6e3`,foreground:`#5c6a72`,cursor:`#5c6a72`,black:`#fdf6e3`,red:`#f85552`,green:`#8da101`,yellow:`#dfa000`,blue:`#3a94c5`,magenta:`#df69ba`,cyan:`#35a77c`,white:`#dfddc8`,brightBlack:`#5c6a72`,brightRed:`#f85552`,brightGreen:`#8da101`,brightYellow:`#dfa000`,brightBlue:`#3a94c5`,brightMagenta:`#df69ba`,brightCyan:`#35a77c`,brightWhite:`#5c6a72`}}};function x(e={}){let{fontSize:o=12,fontFamily:s=`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace`,theme:c=b.dark.default}=e,l=n(null),[u,d]=r(null);return t(()=>{if(!l.current)return;let e=document.createElement(`style`);e.textContent=`
2
+ `);s=r.pop()||``;for(let e of r){let n=e.trim();if(n)try{t(JSON.parse(n))}catch(e){console.error(`Failed to parse NDJSON line:`,e)}}}}catch(t){t.name!==`AbortError`&&console.error(`Error in subscription to ${e}:`,t)}})(),()=>{r.abort()}}};const s=new o;function c(e){let[n,i]=r({rms:0,peak:0,spectrum:[]}),a=e?.numBands;return t(()=>{let e={};a!==void 0&&(e.num_bands=String(a));let t=s.subscribe(`audio-stream`,e=>i(e),e);return()=>{t()}},[a]),n}function l(e){if(!e)return null;let t=new URLSearchParams(window.location.search),n=t.get(`fluxlay_port`)||`1421`,r=t.get(`window_label`)||`main`;return`http://127.0.0.1:${n}/v1/file?window_label=${encodeURIComponent(r)}&path=${encodeURIComponent(e)}`}const u=new o;function d(e){let[n,i]=r({title:null,artist:null,album:null,artwork:null,duration:null,elapsedTime:null,playbackRate:null,isPlaying:!1}),a=e?.intervalMs;return t(()=>{let e={};a!==void 0&&(e.interval_ms=String(a));let t=u.subscribe(`media-metadata-stream`,e=>i(e),e);return()=>{t()}},[a]),n}const f=new o;function p(){let[e,n]=r({x:0,y:0});return t(()=>{let e=new URLSearchParams(window.location.search).get(`window_label`)||`main`,t=f.subscribe(`mouse-stream`,e=>{n({x:e.x,y:-e.y})},{window_label:e});return()=>{t()}},[]),e}const m=new o;function h(){let[e,n]=r({});return t(()=>{m.invoke(`properties`,{}).then(n);let e=m.subscribe(`properties-stream`,e=>n(e));return()=>{e()}},[]),e}const g=new o;async function _(e,t){return await g.invoke(`run-script`,{scriptId:e,columns:t?.columns,lines:t?.lines})}function v(i,a={}){let{showStdout:o=!0,showStderr:s=!1,refreshInterval:c=3e4,terminal:l}=a,[u,d]=r(!1),[f,p]=r(null),[m,h]=r(null),g=n(a);t(()=>{g.current=a},[a]);let v=e(async()=>{if(!u){d(!0),p(null);try{let e=g.current,t=e.columns,n=e.lines;l&&(l.fitAddon.fit(),t=l.terminal.cols,n=l.terminal.rows);let r=await _(i,{...e,columns:t,lines:n});h(r),r.success||p(`Command failed with status ${r.statusCode}: ${r.stderr}`)}catch(e){p(String(e))}finally{d(!1)}}},[i,l]);return t(()=>{if(!l||!m)return;let{terminal:e}=l;if(e.reset(),m.success){let t=``;o&&(t+=m.stdout),s&&(t+=m.stderr);let n=t.trimEnd();if(n){e.write(n);let t=n.split(`
3
+ `).length;e.resize(e.cols,Math.max(1,t))}else e.resize(e.cols,1)}else{let t=`Command failed with status ${m.statusCode}: ${m.stderr}`;e.write(`\x1b[31m${t.trimEnd()}\x1b[0m`),e.resize(e.cols,1)}},[l,m,o,s]),t(()=>{v()},[i]),t(()=>{if(!c)return;let e=setInterval(v,c);return()=>clearInterval(e)},[v,c]),{execute:v,isRunning:u,error:f,result:m}}const y=new o;function b(e){let[n,i]=r({cpuUsage:0,cpuPerCore:[],cpuFrequencyMhz:[],memoryTotal:0,memoryUsed:0,memoryUsage:0,swapTotal:0,swapUsed:0,swapUsage:0,batteryLevel:null,batteryCharging:null,networkRxBytesPerSec:0,networkTxBytesPerSec:0,diskReadBytesPerSec:0,diskWriteBytesPerSec:0,processCount:0,uptimeSecs:0,loadAverage:[0,0,0],disks:[],hostname:``,osName:``,cpuBrand:``,physicalCoreCount:0,logicalCoreCount:0,cpuArch:``,kernelVersion:``}),a=e?.cpuIntervalMs,o=e?.memoryIntervalMs,s=e?.networkIntervalMs,c=e?.diskIoIntervalMs,l=e?.diskSpaceIntervalMs,u=e?.batteryIntervalMs,d=e?.processIntervalMs,f=e?.loadAverageIntervalMs;return t(()=>{let e={};a!==void 0&&(e.cpu_interval_ms=String(a)),o!==void 0&&(e.memory_interval_ms=String(o)),s!==void 0&&(e.network_interval_ms=String(s)),c!==void 0&&(e.disk_io_interval_ms=String(c)),l!==void 0&&(e.disk_space_interval_ms=String(l)),u!==void 0&&(e.battery_interval_ms=String(u)),d!==void 0&&(e.process_interval_ms=String(d)),f!==void 0&&(e.load_average_interval_ms=String(f));let t=y.subscribe(`system-monitor-stream`,e=>i(e),e);return()=>{t()}},[a,o,s,c,l,u,d,f]),n}const x={dark:{default:{background:`#00000000`,foreground:`#ffffff`,cursor:`#00000000`,black:`#000000`,red:`#ef4444`,green:`#22c55e`,yellow:`#f59e0b`,blue:`#3b82f6`,magenta:`#a855f7`,cyan:`#06b6d4`,white:`#ffffff`,brightBlack:`#71717a`,brightRed:`#f87171`,brightGreen:`#4ade80`,brightYellow:`#fbbf24`,brightBlue:`#60a5fa`,brightMagenta:`#c084fc`,brightCyan:`#22d3ee`,brightWhite:`#ffffff`},modern:{background:`#00000000`,foreground:`#e2e8f0`,cursor:`#00000000`,black:`#1e293b`,red:`#f43f5e`,green:`#10b981`,yellow:`#f59e0b`,blue:`#3b82f6`,magenta:`#8b5cf6`,cyan:`#06b6d4`,white:`#f1f5f9`,brightBlack:`#475569`,brightRed:`#fb7185`,brightGreen:`#34d399`,brightYellow:`#fbbf24`,brightBlue:`#60a5fa`,brightMagenta:`#a78bfa`,brightCyan:`#22d3ee`,brightWhite:`#ffffff`}},light:{default:{background:`#00000000`,foreground:`#18181b`,cursor:`#00000000`,black:`#000000`,red:`#ef4444`,green:`#22c55e`,yellow:`#f59e0b`,blue:`#3b82f6`,magenta:`#a855f7`,cyan:`#06b6d4`,white:`#ffffff`,brightBlack:`#71717a`,brightRed:`#f87171`,brightGreen:`#4ade80`,brightYellow:`#fbbf24`,brightBlue:`#60a5fa`,brightMagenta:`#c084fc`,brightCyan:`#22d3ee`,brightWhite:`#ffffff`},modern:{background:`#00000000`,foreground:`#334155`,cursor:`#00000000`,black:`#0f172a`,red:`#dc2626`,green:`#16a34a`,yellow:`#d97706`,blue:`#2563eb`,magenta:`#7c3aed`,cyan:`#0891b2`,white:`#f8fafc`,brightBlack:`#64748b`,brightRed:`#ef4444`,brightGreen:`#22c55e`,brightYellow:`#f59e0b`,brightBlue:`#3b82f6`,brightMagenta:`#8b5cf6`,brightCyan:`#06b6d4`,brightWhite:`#ffffff`}},nord:{background:`#2E3440`,foreground:`#D8DEE9`,cursor:`#D8DEE9`,black:`#3B4252`,red:`#BF616A`,green:`#A3BE8C`,yellow:`#EBCB8B`,blue:`#81A1C1`,magenta:`#B48EAD`,cyan:`#88C0D0`,white:`#E5E9F0`,brightBlack:`#4C566A`,brightRed:`#BF616A`,brightGreen:`#A3BE8C`,brightYellow:`#EBCB8B`,brightBlue:`#81A1C1`,brightMagenta:`#B48EAD`,brightCyan:`#8FBCBB`,brightWhite:`#ECEFF4`},dracula:{background:`#282a36`,foreground:`#f8f8f2`,cursor:`#f8f8f2`,black:`#21222c`,red:`#ff5555`,green:`#50fa7b`,yellow:`#f1fa8c`,blue:`#bd93f9`,magenta:`#ff79c6`,cyan:`#8be9fd`,white:`#f8f8f2`,brightBlack:`#6272a4`,brightRed:`#ff6e6e`,brightGreen:`#69ff94`,brightYellow:`#ffffa5`,brightBlue:`#d6acff`,brightMagenta:`#ff92df`,brightCyan:`#a4ffff`,brightWhite:`#ffffff`},gruvbox:{dark:{background:`#282828`,foreground:`#ebdbb2`,cursor:`#ebdbb2`,black:`#282828`,red:`#cc241d`,green:`#98971a`,yellow:`#d79921`,blue:`#458588`,magenta:`#b16286`,cyan:`#689d6a`,white:`#a89984`,brightBlack:`#928374`,brightRed:`#fb4934`,brightGreen:`#b8bb26`,brightYellow:`#fabd2f`,brightBlue:`#83a598`,brightMagenta:`#d3869b`,brightCyan:`#8ec07c`,brightWhite:`#ebdbb2`},light:{background:`#fbf1c7`,foreground:`#3c3836`,cursor:`#3c3836`,black:`#fbf1c7`,red:`#cc241d`,green:`#98971a`,yellow:`#d79921`,blue:`#458588`,magenta:`#b16286`,cyan:`#689d6a`,white:`#7c6f64`,brightBlack:`#928374`,brightRed:`#9d0006`,brightGreen:`#79740e`,brightYellow:`#b57614`,brightBlue:`#076678`,brightMagenta:`#8f3f71`,brightCyan:`#427b58`,brightWhite:`#3c3836`}},solarized:{dark:{background:`#002b36`,foreground:`#839496`,cursor:`#93a1a1`,black:`#073642`,red:`#dc322f`,green:`#859900`,yellow:`#b58900`,blue:`#268bd2`,magenta:`#d33682`,cyan:`#2aa198`,white:`#eee8d5`,brightBlack:`#002b36`,brightRed:`#cb4b16`,brightGreen:`#586e75`,brightYellow:`#657b83`,brightBlue:`#839496`,brightMagenta:`#6c71c4`,brightCyan:`#93a1a1`,brightWhite:`#fdf6e3`},light:{background:`#fdf6e3`,foreground:`#657b83`,cursor:`#586e75`,black:`#073642`,red:`#dc322f`,green:`#859900`,yellow:`#b58900`,blue:`#268bd2`,magenta:`#d33682`,cyan:`#2aa198`,white:`#eee8d5`,brightBlack:`#002b36`,brightRed:`#cb4b16`,brightGreen:`#586e75`,brightYellow:`#657b83`,brightBlue:`#839496`,brightMagenta:`#6c71c4`,brightCyan:`#93a1a1`,brightWhite:`#fdf6e3`}},oneDark:{background:`#282c34`,foreground:`#abb2bf`,cursor:`#528bff`,black:`#282c34`,red:`#e06c75`,green:`#98c379`,yellow:`#e5c07b`,blue:`#61afef`,magenta:`#c678dd`,cyan:`#56b6c2`,white:`#abb2bf`,brightBlack:`#5c6370`,brightRed:`#e06c75`,brightGreen:`#98c379`,brightYellow:`#e5c07b`,brightBlue:`#61afef`,brightMagenta:`#c678dd`,brightCyan:`#56b6c2`,brightWhite:`#ffffff`},catppuccin:{latte:{background:`#eff1f5`,foreground:`#4c4f69`,cursor:`#dc8a78`,black:`#5c5f77`,red:`#d20f39`,green:`#40a02b`,yellow:`#df8e1d`,blue:`#1e66f5`,magenta:`#ea76cb`,cyan:`#179299`,white:`#acb0be`,brightBlack:`#6c6f85`,brightRed:`#d20f39`,brightGreen:`#40a02b`,brightYellow:`#df8e1d`,brightBlue:`#1e66f5`,brightMagenta:`#ea76cb`,brightCyan:`#179299`,brightWhite:`#bcc0cc`},frappe:{background:`#303446`,foreground:`#c6d0f5`,cursor:`#f2d5cf`,black:`#51576d`,red:`#e78284`,green:`#a6d189`,yellow:`#e5c890`,blue:`#8caaee`,magenta:`#f4b8e4`,cyan:`#81c8be`,white:`#b5bfe2`,brightBlack:`#626880`,brightRed:`#e78284`,brightGreen:`#a6d189`,brightYellow:`#e5c890`,brightBlue:`#8caaee`,brightMagenta:`#f4b8e4`,brightCyan:`#81c8be`,brightWhite:`#a5adce`},macchiato:{background:`#24273a`,foreground:`#cad3f5`,cursor:`#f4dbd6`,black:`#494d64`,red:`#ed8796`,green:`#a6da95`,yellow:`#eed49f`,blue:`#8aadf4`,magenta:`#f5bde6`,cyan:`#8bd5ca`,white:`#b8c0e0`,brightBlack:`#5b6078`,brightRed:`#ed8796`,brightGreen:`#a6da95`,brightYellow:`#eed49f`,brightBlue:`#8aadf4`,brightMagenta:`#f5bde6`,brightCyan:`#8bd5ca`,brightWhite:`#a5adcb`},mocha:{background:`#1e1e2e`,foreground:`#cdd6f4`,cursor:`#f5e0dc`,black:`#45475a`,red:`#f38ba8`,green:`#a6e3a1`,yellow:`#f9e2af`,blue:`#89b4fa`,magenta:`#f5c2e7`,cyan:`#94e2d5`,white:`#bac2de`,brightBlack:`#585b70`,brightRed:`#f38ba8`,brightGreen:`#a6e3a1`,brightYellow:`#f9e2af`,brightBlue:`#89b4fa`,brightMagenta:`#f5c2e7`,brightCyan:`#94e2d5`,brightWhite:`#a6adc8`}},monokaiPro:{background:`#2D2A2E`,foreground:`#FCFCFA`,cursor:`#FCFCFA`,black:`#403E41`,red:`#FF6188`,green:`#A9DC76`,yellow:`#FFD866`,blue:`#FC9867`,magenta:`#AB9DF2`,cyan:`#78DCE8`,white:`#FCFCFA`,brightBlack:`#727072`,brightRed:`#FF6188`,brightGreen:`#A9DC76`,brightYellow:`#FFD866`,brightBlue:`#FC9867`,brightMagenta:`#AB9DF2`,brightCyan:`#78DCE8`,brightWhite:`#FCFCFA`},tokyoNight:{background:`#1a1b26`,foreground:`#a9b1d6`,cursor:`#c0caf5`,black:`#32344a`,red:`#f7768e`,green:`#9ece6a`,yellow:`#e0af68`,blue:`#7aa2f7`,magenta:`#ad8ee6`,cyan:`#449dab`,white:`#787c99`,brightBlack:`#444b6a`,brightRed:`#ff7a93`,brightGreen:`#b9f27c`,brightYellow:`#ff9e64`,brightBlue:`#7da6ff`,brightMagenta:`#bb9af7`,brightCyan:`#0db9d7`,brightWhite:`#acb0d0`},nightOwl:{background:`#011627`,foreground:`#d6deeb`,cursor:`#80a4c2`,black:`#011627`,red:`#ef5350`,green:`#22da6e`,yellow:`#addb67`,blue:`#82aaff`,magenta:`#c792ea`,cyan:`#21c7a8`,white:`#ffffff`,brightBlack:`#575656`,brightRed:`#ef5350`,brightGreen:`#22da6e`,brightYellow:`#ffeb95`,brightBlue:`#82aaff`,brightMagenta:`#c792ea`,brightCyan:`#7fdbca`,brightWhite:`#ffffff`},everforest:{dark:{background:`#2b3339`,foreground:`#d3c6aa`,cursor:`#d3c6aa`,black:`#4b565c`,red:`#e67e80`,green:`#a7c080`,yellow:`#dbbc7f`,blue:`#7fbbb3`,magenta:`#d699b6`,cyan:`#83c092`,white:`#d3c6aa`,brightBlack:`#4b565c`,brightRed:`#e67e80`,brightGreen:`#a7c080`,brightYellow:`#dbbc7f`,brightBlue:`#7fbbb3`,brightMagenta:`#d699b6`,brightCyan:`#83c092`,brightWhite:`#d3c6aa`},light:{background:`#fdf6e3`,foreground:`#5c6a72`,cursor:`#5c6a72`,black:`#fdf6e3`,red:`#f85552`,green:`#8da101`,yellow:`#dfa000`,blue:`#3a94c5`,magenta:`#df69ba`,cyan:`#35a77c`,white:`#dfddc8`,brightBlack:`#5c6a72`,brightRed:`#f85552`,brightGreen:`#8da101`,brightYellow:`#dfa000`,brightBlue:`#3a94c5`,brightMagenta:`#df69ba`,brightCyan:`#35a77c`,brightWhite:`#5c6a72`}}};function S(e={}){let{fontSize:o=12,fontFamily:s=`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace`,theme:c=x.dark.default}=e,l=n(null),[u,d]=r(null);return t(()=>{if(!l.current)return;let e=document.createElement(`style`);e.textContent=`
4
4
  .xterm-char-measure-element {
5
5
  position: absolute !important;
6
6
  top: 0 !important;
@@ -29,4 +29,4 @@ import{useCallback as e,useEffect as t,useRef as n,useState as r}from"react";imp
29
29
  .xterm-selection {
30
30
  display: none !important; /* Hide xterm's own selection overlay. */
31
31
  }
32
- `,document.head.appendChild(e);let t=new a({fontSize:o,fontFamily:s,disableStdin:!0,cursorBlink:!1,convertEol:!0,scrollback:0,theme:c}),n=new i;return t.loadAddon(n),t.open(l.current),t.write(`\x1B[?25l`),d({terminal:t,fitAddon:n}),()=>{document.head.contains(e)&&document.head.removeChild(e),t.dispose(),d(null)}},[o,s]),{terminalRef:l,instance:u}}export{b as TerminalThemes,g as runShell,c as useAudio,u as useMediaMetadata,f as useMousePosition,m as useProperties,_ as useShell,y as useSystemMonitor,x as useTerminal};
32
+ `,document.head.appendChild(e);let t=new a({fontSize:o,fontFamily:s,disableStdin:!0,cursorBlink:!1,convertEol:!0,scrollback:0,theme:c}),n=new i;return t.loadAddon(n),t.open(l.current),t.write(`\x1B[?25l`),d({terminal:t,fitAddon:n}),()=>{document.head.contains(e)&&document.head.removeChild(e),t.dispose(),d(null)}},[o,s]),{terminalRef:l,instance:u}}export{x as TerminalThemes,l as getPropertyFileUrl,_ as runShell,c as useAudio,d as useMediaMetadata,p as useMousePosition,h as useProperties,v as useShell,b as useSystemMonitor,S as useTerminal};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluxlay/react",
3
- "version": "1.1.1",
3
+ "version": "1.2.0",
4
4
  "description": "SDK for building Fluxlay wallpapers with React",
5
5
  "keywords": [
6
6
  "desktop",
@@ -23,21 +23,21 @@
23
23
  "default": "./dist/index.mjs"
24
24
  }
25
25
  },
26
+ "scripts": {
27
+ "build": "tsdown",
28
+ "check": "oxlint --type-aware --type-check --fix && oxfmt --write ."
29
+ },
26
30
  "dependencies": {
27
31
  "@xterm/addon-fit": "^0.11.0",
28
32
  "@xterm/xterm": "^6.0.0"
29
33
  },
30
34
  "devDependencies": {
31
35
  "@types/react": "^19.2.14",
32
- "react": "^19.2.4",
33
- "tsdown": "^0.21.7",
36
+ "react": "^19.2.5",
37
+ "tsdown": "^0.21.10",
34
38
  "typescript": "^5.9.3"
35
39
  },
36
40
  "peerDependencies": {
37
41
  "react": "^19.0.0"
38
- },
39
- "scripts": {
40
- "build": "tsdown",
41
- "check": "oxlint --type-aware --type-check --fix && oxfmt --write ."
42
42
  }
43
- }
43
+ }