@pulse-editor/react-api 0.1.1-alpha.6 → 0.1.1-alpha.7

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.
@@ -1,4 +1,9 @@
1
1
  import { AgentTool } from "@pulse-editor/shared-utils";
2
- export default function useAgentTools(moduleName: string): {
2
+ /**
3
+ * Add or use agent tools in the editor.
4
+ * @param moduleName
5
+ * @returns
6
+ */
7
+ export default function useAgentTools(): {
3
8
  installAgentTool: (tool: AgentTool) => Promise<void>;
4
9
  };
@@ -1,5 +1,5 @@
1
1
  import { Agent } from "@pulse-editor/shared-utils";
2
- export default function useAgents(moduleName: string): {
2
+ export default function useAgents(): {
3
3
  installAgent: (config: Agent) => Promise<void>;
4
4
  runAgentMethod: (agentName: string, methodName: string, parameters: Record<string, any>, abortSignal?: AbortSignal) => Promise<Record<string, any>>;
5
5
  isReady: boolean;
@@ -1,3 +1,3 @@
1
- export default function useFetch(moduleName: string): {
1
+ export default function useFetch(): {
2
2
  fetch: (uri: string, options?: RequestInit) => Promise<Response>;
3
3
  };
@@ -1,5 +1,5 @@
1
1
  import { FileViewModel } from "@pulse-editor/shared-utils";
2
- export default function useFileView(moduleName: string): {
2
+ export default function useFileView(): {
3
3
  viewFile: FileViewModel | undefined;
4
4
  updateViewFile: (file: FileViewModel) => void;
5
5
  setIsLoaded: import("react").Dispatch<import("react").SetStateAction<boolean>>;
@@ -1,4 +1,4 @@
1
1
  import { NotificationTypeEnum } from "@pulse-editor/shared-utils";
2
- export default function useNotification(moduleName: string): {
2
+ export default function useNotification(): {
3
3
  openNotification: (text: string, type: NotificationTypeEnum) => void;
4
4
  };
@@ -1,3 +1,3 @@
1
- export default function useOCR(moduleName: string): {
1
+ export default function useOCR(): {
2
2
  recognizeText: (uri: string) => Promise<string>;
3
3
  };
@@ -1,3 +1,3 @@
1
- export default function useTerminal(moduleName: string): {
1
+ export default function useTerminal(): {
2
2
  websocketUrl: string | undefined;
3
3
  };
@@ -1,3 +1,3 @@
1
- export default function useTheme(moduleName: string): {
1
+ export default function useTheme(): {
2
2
  theme: string;
3
3
  };
@@ -1,6 +1,6 @@
1
1
  import { InterModuleCommunication } from "@pulse-editor/shared-utils";
2
2
  import { ReceiverHandlerMap } from "@pulse-editor/shared-utils";
3
- export default function useIMC(moduleName: string, handlerMap: ReceiverHandlerMap): {
3
+ export default function useIMC(handlerMap: ReceiverHandlerMap): {
4
4
  imc: InterModuleCommunication | undefined;
5
5
  isReady: boolean;
6
6
  };
package/dist/main.js CHANGED
@@ -1 +1 @@
1
- import{InterModuleCommunication as e,IMCMessageTypeEnum as n}from"@pulse-editor/shared-utils";import{useState as t,useEffect as i}from"react";function o(o,s){const[a,r]=t(void 0),[d,c]=t(!1),w=window.parent;return i((()=>{const t=new e(o);return t.initThisWindow(window),t.updateReceiverHandlerMap(s),t.initOtherWindow(w),r(t),t.sendMessage(n.Ready).then((()=>{c(!0)})),()=>{t.close()}}),[]),{imc:a,isReady:d}}function s(e){const[s,a]=t(void 0),[r,d]=t(!1),c=new Map,{imc:w,isReady:u}=o(e,c);return i((()=>{u&&w?.sendMessage(n.RequestViewFile).then((e=>{a(e)}))}),[u]),i((()=>{r&&w?.sendMessage(n.Loaded)}),[r,w]),{viewFile:s,updateViewFile:function(e){w?.sendMessage(n.WriteViewFile,e)},setIsLoaded:d}}function a(e){const[i,s]=t("light"),a=new Map;return a.set(n.ThemeChange,(async(e,n)=>{const t=n.payload;s((e=>t))})),o(e,a),{theme:i}}function r(e){const t=new Map,{imc:i}=o(e,t);return{openNotification:function(e,t){if(!i)throw new Error("IMC is not initialized.");i.sendMessage(n.Notification,{text:e,type:t})}}}function d(e){const t=new Map,{imc:i,isReady:s}=o(e,t);return{installAgent:async function(e){if(!i)throw new Error("IMC not initialized.");await i.sendMessage(n.InstallAgent,e).catch((e=>{throw new Error(e)}))},runAgentMethod:async function(e,t,o,s){if(!i)throw new Error("IMC not initialized.");return await i.sendMessage(n.RunAgentMethod,{agentName:e,methodName:t,parameters:o},s).then((e=>e))},isReady:s}}function c(e){const t=new Map,{imc:i}=o(e,t);return{recognizeText:async function(e){if(!i)throw new Error("IMC is not initialized.");return(await i.sendMessage(n.OCR,{uri:e})).payload.text}}}function w(e){const s=new Map,{imc:a,isReady:r}=o(e,s),[d,c]=t(void 0);return i((()=>{r&&a?.sendMessage(n.RequestTerminal).then((e=>{const{websocketUrl:t}=e;c(t),a.sendMessage(n.Loaded)}))}),[r]),{websocketUrl:d}}export{d as useAgents,s as useFileView,r as useNotification,c as useOCR,w as useTerminal,a as useTheme};
1
+ import{InterModuleCommunication as e,IMCMessageTypeEnum as n}from"@pulse-editor/shared-utils";import{useState as t,useEffect as i}from"react";function o(o){const[s,r]=t(void 0),[a,d]=t(!1),[c,u]=t(!1),w=window.parent;return i((()=>(u(!0),()=>{s?.close()})),[]),i((()=>{if(!c)return;if(void 0!==s)return;const t=new e;t.initThisWindow(window),t.updateReceiverHandlerMap(o),t.initOtherWindow(w),r(t),t.sendMessage(n.Ready).then((()=>{d(!0)}))}),[c,s]),{imc:s,isReady:a}}function s(){const[e,s]=t(void 0),[r,a]=t(!1),d=new Map,{imc:c,isReady:u}=o(d);return i((()=>{u&&c?.sendMessage(n.RequestViewFile).then((e=>{s(e)}))}),[u]),i((()=>{r&&c?.sendMessage(n.Loaded)}),[r,c]),{viewFile:e,updateViewFile:function(e){c?.sendMessage(n.WriteViewFile,e)},setIsLoaded:a}}function r(){const[e,i]=t("light"),s=new Map;return s.set(n.ThemeChange,(async(e,n)=>{const t=n.payload;i((e=>t))})),o(s),{theme:e}}function a(){const e=new Map,{imc:t}=o(e);return{openNotification:function(e,i){if(!t)throw new Error("IMC is not initialized.");t.sendMessage(n.Notification,{text:e,type:i})}}}function d(){const e=new Map,{imc:t,isReady:i}=o(e);return{installAgent:async function(e){if(!t)throw new Error("IMC not initialized.");await t.sendMessage(n.InstallAgent,e).catch((e=>{throw new Error(e)}))},runAgentMethod:async function(e,i,o,s){if(!t)throw new Error("IMC not initialized.");return await t.sendMessage(n.RunAgentMethod,{agentName:e,methodName:i,parameters:o},s).then((e=>e))},isReady:i}}function c(){const e=new Map,{imc:t}=o(e);return{recognizeText:async function(e){if(!t)throw new Error("IMC is not initialized.");return(await t.sendMessage(n.OCR,{uri:e})).payload.text}}}function u(){const e=new Map,{imc:s,isReady:r}=o(e),[a,d]=t(void 0);return i((()=>{r&&s?.sendMessage(n.RequestTerminal).then((e=>{const{websocketUrl:t}=e;d(t),s.sendMessage(n.Loaded)}))}),[r]),{websocketUrl:a}}export{d as useAgents,s as useFileView,a as useNotification,c as useOCR,u as useTerminal,r as useTheme};
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@pulse-editor/react-api",
3
- "version": "0.1.1-alpha.6",
3
+ "version": "0.1.1-alpha.7",
4
+ "main": "dist/main.js",
4
5
  "files": [
5
6
  "dist"
6
7
  ],
@@ -37,7 +38,7 @@
37
38
  "typescript-eslint": "^8.30.1"
38
39
  },
39
40
  "peerDependencies": {
40
- "@pulse-editor/shared-utils": "0.1.1-alpha.6",
41
+ "@pulse-editor/shared-utils": "0.1.1-alpha.7",
41
42
  "react": "^19.0.0",
42
43
  "react-dom": "^19.0.0"
43
44
  }