@pulse-editor/react-api 0.1.1-alpha.0 → 0.1.1-beta.2

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.
@@ -0,0 +1 @@
1
+ import{IMCMessageTypeEnum as e}from"@pulse-editor/shared-utils";import t from"../lib/hooks/use-imc.js";function n(n){const r=new Map,{imc:i,isReady:a}=t(n,r);return{installAgent:async function(t){if(!i)throw new Error("IMC not initialized.");await i.sendMessage(e.InstallAgent,t).catch((e=>{throw new Error(e)}))},runAgentMethod:async function(t,n,r,a){if(!i)throw new Error("IMC not initialized.");return await i.sendMessage(e.RunAgentMethod,{agentName:t,methodName:n,parameters:r},a).then((e=>e))},isReady:a}}export{n as default};
@@ -0,0 +1 @@
1
+ import{IMCMessageTypeEnum as e}from"@pulse-editor/shared-utils";import{useState as i,useEffect as s}from"react";import t from"../lib/hooks/use-imc.js";function o(o){const[d,r]=i(void 0),[a,n]=i(!1),u=new Map,{imc:l,isReady:m}=t(o,u);return s((()=>{m&&l?.sendMessage(e.RequestViewFile).then((e=>{r(e)}))}),[m]),s((()=>{a&&l?.sendMessage(e.Loaded)}),[a,l]),{viewFile:d,updateViewFile:function(i){l?.sendMessage(e.WriteViewFile,i)},setIsLoaded:n}}export{o as default};
@@ -0,0 +1 @@
1
+ import{IMCMessageTypeEnum as i}from"@pulse-editor/shared-utils";import t from"../lib/hooks/use-imc.js";function o(o){const e=new Map,{imc:n}=t(o,e);return{openNotification:function(t,o){if(!n)throw new Error("IMC is not initialized.");n.sendMessage(i.Notification,{text:t,type:o})}}}export{o as default};
@@ -0,0 +1 @@
1
+ import{IMCMessageTypeEnum as e}from"@pulse-editor/shared-utils";import i from"../lib/hooks/use-imc.js";function t(t){const r=new Map,{imc:o}=i(t,r);return{recognizeText:async function(i){if(!o)throw new Error("IMC is not initialized.");return(await o.sendMessage(e.OCR,{uri:i})).payload.text}}}export{t as default};
@@ -0,0 +1 @@
1
+ import{IMCMessageTypeEnum as e}from"@pulse-editor/shared-utils";import s from"../lib/hooks/use-imc.js";import{useState as o,useEffect as t}from"react";function r(r){const i=new Map,{imc:a,isReady:n}=s(r,i),[d,m]=o(void 0);return t((()=>{n&&a?.sendMessage(e.RequestTerminal).then((s=>{const{websocketUrl:o}=s;m(o),a.sendMessage(e.Loaded)}))}),[n]),{websocketUrl:d}}export{r as default};
@@ -0,0 +1 @@
1
+ import{IMCMessageTypeEnum as e}from"@pulse-editor/shared-utils";import{useState as t}from"react";import o from"../lib/hooks/use-imc.js";function r(r){const[s,a]=t("light"),i=new Map;return i.set(e.ThemeChange,(async(e,t)=>{const o=t.payload;a((e=>o))})),o(r,i),{theme:s}}export{r as default};
@@ -0,0 +1 @@
1
+ import{InterModuleCommunication as e,IMCMessageTypeEnum as i}from"@pulse-editor/shared-utils";import{useState as t,useEffect as n}from"react";function r(r,o){const[d,s]=t(void 0),[a,c]=t(!1),p=window.parent;return n((()=>{const t=new e(r);return t.initThisWindow(window),t.updateReceiverHandlerMap(o),t.initOtherWindow(p),s(t),t.sendMessage(i.Ready).then((()=>{c(!0)})),()=>{t.close()}}),[]),{imc:d,isReady:a}}export{r as default};
package/dist/main.js CHANGED
@@ -1 +1 @@
1
- "use strict";var e=require("@pulse-editor/shared-utils"),n=require("react");function t(t,s){const[i,a]=n.useState(void 0),[o,r]=n.useState(!1),u=window.parent;return n.useEffect((()=>{const n=new e.InterModuleCommunication(t);return n.initThisWindow(window),n.updateReceiverHandlerMap(s),n.initOtherWindow(u),a(n),n.sendMessage(e.IMCMessageTypeEnum.Ready).then((()=>{r(!0)})),()=>{n.close()}}),[]),{imc:i,isReady:o}}exports.useAgents=function(n){const s=new Map,{imc:i,isReady:a}=t(n,s);return{installAgent:async function(n){if(!i)throw new Error("IMC not initialized.");await i.sendMessage(e.IMCMessageTypeEnum.InstallAgent,n).catch((e=>{throw new Error(e)}))},runAgentMethod:async function(n,t,s,a){if(!i)throw new Error("IMC not initialized.");return await i.sendMessage(e.IMCMessageTypeEnum.RunAgentMethod,{agentName:n,methodName:t,parameters:s},a).then((e=>e))},isReady:a}},exports.useFileView=function(s){const[i,a]=n.useState(void 0),[o,r]=n.useState(!1),u=new Map,{imc:c,isReady:M}=t(s,u);return n.useEffect((()=>{M&&c?.sendMessage(e.IMCMessageTypeEnum.RequestViewFile).then((e=>{a(e)}))}),[M]),n.useEffect((()=>{o&&c?.sendMessage(e.IMCMessageTypeEnum.Loaded)}),[o,c]),{viewFile:i,updateViewFile:function(n){c?.sendMessage(e.IMCMessageTypeEnum.WriteViewFile,n)},setIsLoaded:r}},exports.useNotification=function(n){const s=new Map,{imc:i}=t(n,s);return{openNotification:function(n,t){if(!i)throw new Error("IMC is not initialized.");i.sendMessage(e.IMCMessageTypeEnum.Notification,{text:n,type:t})}}},exports.useOCR=function(n){const s=new Map,{imc:i}=t(n,s);return{recognizeText:async function(n){if(!i)throw new Error("IMC is not initialized.");return(await i.sendMessage(e.IMCMessageTypeEnum.OCR,{uri:n})).payload.text}}},exports.useTerminal=function(s){const i=new Map,{imc:a,isReady:o}=t(s,i),[r,u]=n.useState(void 0);return n.useEffect((()=>{o&&a?.sendMessage(e.IMCMessageTypeEnum.RequestTerminal).then((n=>{const{websocketUrl:t}=n;u(t),a.sendMessage(e.IMCMessageTypeEnum.Loaded)}))}),[o]),{websocketUrl:r}},exports.useTheme=function(s){const[i,a]=n.useState("light"),o=new Map;return o.set(e.IMCMessageTypeEnum.ThemeChange,(async(e,n)=>{const t=n.payload;a((e=>t))})),t(s,o),{theme:i}};
1
+ export{default as useFileView}from"./hooks/use-file-view.js";export{default as useTheme}from"./hooks/use-theme.js";export{default as useNotification}from"./hooks/use-notification.js";export{default as useAgents}from"./hooks/use-agents.js";export{default as useOCR}from"./hooks/use-orc.js";export{default as useTerminal}from"./hooks/use-terminal.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pulse-editor/react-api",
3
- "version": "0.1.1-alpha.0",
3
+ "version": "0.1.1-beta.2",
4
4
  "main": "dist/main.js",
5
5
  "type": "module",
6
6
  "files": [
@@ -35,7 +35,7 @@
35
35
  "typescript-eslint": "^8.30.1"
36
36
  },
37
37
  "peerDependencies": {
38
- "@pulse-editor/shared-utils": "0.1.1-alpha.0",
38
+ "@pulse-editor/shared-utils": "0.1.1-beta.1",
39
39
  "react": "^19.0.0",
40
40
  "react-dom": "^19.0.0"
41
41
  }