@pulse-editor/react-api 0.1.1-alpha.3 → 0.1.1-alpha.30
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/hooks/agent/use-agent-tools.d.ts +6 -0
- package/dist/hooks/agent/use-agents.d.ts +5 -0
- package/dist/hooks/ai-modality/use-image-gen.d.ts +8 -0
- package/dist/hooks/ai-modality/use-llm.d.ts +5 -0
- package/dist/hooks/ai-modality/use-ocr.d.ts +3 -0
- package/dist/hooks/ai-modality/use-speech2speech.d.ts +10 -0
- package/dist/hooks/ai-modality/use-stt.d.ts +5 -0
- package/dist/hooks/ai-modality/use-tts.d.ts +5 -0
- package/dist/hooks/ai-modality/use-video-gen.d.ts +8 -0
- package/dist/hooks/editor/use-command.d.ts +12 -0
- package/dist/hooks/editor/use-file-view.d.ts +5 -0
- package/dist/hooks/editor/use-loading.d.ts +4 -0
- package/dist/hooks/editor/use-mic.d.ts +4 -0
- package/dist/hooks/{use-notification.d.ts → editor/use-notification.d.ts} +1 -1
- package/dist/hooks/editor/use-theme.d.ts +3 -0
- package/dist/hooks/editor/use-toolbar.d.ts +1 -0
- package/dist/hooks/terminal/use-terminal.d.ts +4 -0
- package/dist/lib/{hooks/use-imc.d.ts → use-imc.d.ts} +1 -1
- package/dist/main.d.ts +16 -7
- package/dist/main.js +1 -1
- package/package.json +5 -4
- package/dist/hooks/use-agent-tools.d.ts +0 -4
- package/dist/hooks/use-agents.d.ts +0 -6
- package/dist/hooks/use-fetch.d.ts +0 -3
- package/dist/hooks/use-file-view.d.ts +0 -6
- package/dist/hooks/use-orc.d.ts +0 -3
- package/dist/hooks/use-terminal.d.ts +0 -3
- package/dist/hooks/use-theme.d.ts +0 -3
- package/dist/main.es.js +0 -1
- package/src/main.ts +0 -15
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { LLMConfig } from "@pulse-editor/shared-utils";
|
|
2
|
+
export default function useAgents(): {
|
|
3
|
+
runAgentMethod: (agentName: string, methodName: string, parameters: Record<string, any>, abortSignal?: AbortSignal, llmConfig?: LLMConfig) => Promise<any>;
|
|
4
|
+
isReady: boolean;
|
|
5
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ImageModelConfig } from "@pulse-editor/shared-utils";
|
|
2
|
+
export default function useImageGen(): {
|
|
3
|
+
runImageGen: (textPrompt?: string, imagePrompt?: string | ArrayBuffer, imageModelConfig?: ImageModelConfig) => Promise<{
|
|
4
|
+
arrayBuffer?: ArrayBuffer;
|
|
5
|
+
url?: string;
|
|
6
|
+
}>;
|
|
7
|
+
isReady: boolean;
|
|
8
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Use speech-to-speech API to listen to user input and read the output
|
|
3
|
+
* provided by you.
|
|
4
|
+
*/
|
|
5
|
+
export default function useSpeech2Speech(): {
|
|
6
|
+
isReady: boolean;
|
|
7
|
+
userInput: string;
|
|
8
|
+
isUserStopped: boolean;
|
|
9
|
+
respondAndRead: (text: string) => Promise<void>;
|
|
10
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { VideoModelConfig } from "@pulse-editor/shared-utils";
|
|
2
|
+
export default function useVideoGen(): {
|
|
3
|
+
runVideoGen: (duration: number, textPrompt?: string, imagePrompt?: string | ArrayBuffer, videoModelConfig?: VideoModelConfig) => Promise<{
|
|
4
|
+
url?: string;
|
|
5
|
+
arrayBuffer?: ArrayBuffer;
|
|
6
|
+
}>;
|
|
7
|
+
isReady: boolean;
|
|
8
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CommandInfo } from "@pulse-editor/shared-utils";
|
|
2
|
+
/**
|
|
3
|
+
* Register an extension command to listen to IMC messages from the core,
|
|
4
|
+
* and pass to the extension to handle.
|
|
5
|
+
*
|
|
6
|
+
* @param commandInfo Command information to register.
|
|
7
|
+
* @param callbackHandler Callback handler function to handle the command.
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
export default function useCommand(commandInfo: CommandInfo, callbackHandler?: (args: any) => Promise<string | void>): {
|
|
11
|
+
isReady: boolean;
|
|
12
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function useToolbar(): {};
|
|
@@ -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(
|
|
3
|
+
export default function useIMC(handlerMap: ReceiverHandlerMap): {
|
|
4
4
|
imc: InterModuleCommunication | undefined;
|
|
5
5
|
isReady: boolean;
|
|
6
6
|
};
|
package/dist/main.d.ts
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
1
|
+
import useAgentTools from "./hooks/agent/use-agent-tools";
|
|
2
|
+
import useAgents from "./hooks/agent/use-agents";
|
|
3
|
+
import useFileView from "./hooks/editor/use-file-view";
|
|
4
|
+
import useLoading from "./hooks/editor/use-loading";
|
|
5
|
+
import useNotification from "./hooks/editor/use-notification";
|
|
6
|
+
import useTheme from "./hooks/editor/use-theme";
|
|
7
|
+
import useToolbar from "./hooks/editor/use-toolbar";
|
|
8
|
+
import useCommand from "./hooks/editor/use-command";
|
|
9
|
+
import useImageGen from "./hooks/ai-modality/use-image-gen";
|
|
10
|
+
import useLLM from "./hooks/ai-modality/use-llm";
|
|
11
|
+
import useOCR from "./hooks/ai-modality/use-ocr";
|
|
12
|
+
import useSTT from "./hooks/ai-modality/use-stt";
|
|
13
|
+
import useTTS from "./hooks/ai-modality/use-tts";
|
|
14
|
+
import useVideoGen from "./hooks/ai-modality/use-video-gen";
|
|
15
|
+
import useTerminal from "./hooks/terminal/use-terminal";
|
|
16
|
+
export { useAgentTools, useAgents, useFileView, useNotification, useTheme, useToolbar, useImageGen, useVideoGen, useLLM, useOCR, useSTT, useTTS, useCommand, useTerminal, useLoading, };
|
package/dist/main.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{InterModuleCommunication as e,IMCMessageTypeEnum as t}from"@pulse-editor/shared-utils";import{useState as n,useEffect as i}from"react";function r(r){const[o,a]=n(void 0),[s,d]=n(!1),[c,u]=n(!1),f=window.parent;return i(()=>(u(!0),()=>{u(!1),o?.close(),a(void 0)}),[]),i(()=>{!async function(){if(!c)return;if(void 0!==o)return;const n=new e;n.initThisWindow(window),n.updateReceiverHandlerMap(r),await n.initOtherWindow(f),a(n),n.sendMessage(t.ExtReady).then(()=>{d(!0)})}()},[c,o]),{imc:o,isReady:s}}function o(){return r(new Map),{}}function a(){const e=new Map,{imc:n,isReady:i}=r(e);return{runAgentMethod:async function(e,i,r,o,a){if(!n)throw new Error("IMC not initialized.");return await n.sendMessage(t.EditorRunAgentMethod,{agentName:e,methodName:i,parameters:r,llmConfig:a},o).then(e=>e)},isReady:i}}function s(){const[e,o]=n(void 0),a=new Map,{imc:s,isReady:d}=r(a);return i(()=>{d&&s?.sendMessage(t.PlatformReadFile).then(e=>{o(e)})},[d]),{viewModel:e,updateViewModel:function(e){s?.sendMessage(t.PlatformWriteFile,e)}}}function d(){const e=new Map,{imc:o,isReady:a}=r(e),[s,d]=n(!0);return i(()=>{a&&o?.sendMessage(t.EditorLoadingExt,{isLoading:s})},[s]),{isReady:a,toggleLoading:function(e){d(t=>e)}}}function c(){const e=new Map,{imc:n}=r(e);return{openNotification:function(e,i){if(!n)throw new Error("IMC is not initialized.");n.sendMessage(t.EditorShowNotification,{text:e,type:i})}}}function u(){const[e,i]=n("light"),o=new Map;return o.set(t.EditorThemeUpdate,async(e,t)=>{const n=t.payload;i(e=>n)}),r(o),{theme:e}}function f(){return{}}function w(e,o){const{isReady:a,imc:s}=r(u()),[d,c]=n(void 0);function u(){return new Map([[t.EditorRunExtCommand,async(t,n)=>{if(!e)throw new Error("Extension command is not available");const{name:i,args:r}=n.payload;if(i===e.name){const t=e.parameters;if(Object.keys(r).length!==Object.keys(t).length)throw new Error(`Invalid number of parameters: expected ${Object.keys(t).length}, got ${Object.keys(r).length}`);for(const[t,n]of Object.entries(r)){if(void 0===e.parameters[t])throw new Error(`Invalid parameter: ${t}`);if(typeof n!==e.parameters[t].type)throw new Error(`Invalid type for parameter ${t}: expected ${e.parameters[t].type}, got ${typeof n}. Value received: ${n}`)}if(d){const e=await d(r);if(e)return e}}}]])}return i(()=>{s?.updateReceiverHandlerMap(u())},[d,s]),i(()=>{c(()=>o)},[o]),{isReady:a}}function m(){const e=new Map,{imc:n,isReady:i}=r(e);return{runImageGen:async function(e,i,r){if(!n)throw new Error("IMC not initialized.");if(!e&&!i)throw new Error("At least one of textPrompt or imagePrompt is required.");return await n.sendMessage(t.ModalityImageGen,{textPrompt:e,imagePrompt:i,imageModelConfig:r}).then(e=>e)},isReady:i}}function p(){const e=new Map,{imc:n,isReady:i}=r(e);return{runLLM:async function(e,i){if(!n)throw new Error("IMC not initialized.");return await n.sendMessage(t.ModalityLLM,{prompt:e,llmConfig:i}).then(e=>e)},isReady:i}}function l(){const e=new Map,{imc:n}=r(e);return{recognizeText:async function(e){if(!n)throw new Error("IMC is not initialized.");return(await n.sendMessage(t.ModalityOCR,{image:e})).payload.text}}}function M(){const e=new Map,{imc:n,isReady:i}=r(e);return{runSTT:async function(e,i){if(!n)throw new Error("IMC not initialized.");return await n.sendMessage(t.ModalitySTT,{audio:e,sttConfig:i}).then(e=>e)},isReady:i}}function y(){const e=new Map,{imc:n,isReady:i}=r(e);return{runTTS:async function(e,i){if(!n)throw new Error("IMC not initialized.");return await n.sendMessage(t.ModalityTTS,{text:e,ttsConfig:i}).then(e=>e)},isReady:i}}function g(){const e=new Map,{imc:n,isReady:i}=r(e);return{runVideoGen:async function(e,i,r,o){if(!n)throw new Error("IMC not initialized.");if(!i&&!r)throw new Error("At least one of textPrompt or imagePrompt is required.");return await n.sendMessage(t.ModalityVideoGen,{duration:e,textPrompt:i,imagePrompt:r,videoModelConfig:o}).then(e=>e)},isReady:i}}function h(){const e=new Map,{imc:o,isReady:a}=r(e),[s,d]=n(void 0),[c,u]=n(void 0);return i(()=>{a&&o?.sendMessage(t.PlatformCreateTerminal).then(e=>{const{websocketUrl:t,projectHomePath:n}=e;d(t),u(n)})},[a]),{websocketUrl:s,projectHomePath:c}}export{o as useAgentTools,a as useAgents,w as useCommand,s as useFileView,m as useImageGen,p as useLLM,d as useLoading,c as useNotification,l as useOCR,M as useSTT,y as useTTS,h as useTerminal,u as useTheme,f as useToolbar,g as useVideoGen};
|
package/package.json
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pulse-editor/react-api",
|
|
3
|
-
"version": "0.1.1-alpha.
|
|
4
|
-
"main": "
|
|
5
|
-
"type": "module",
|
|
3
|
+
"version": "0.1.1-alpha.30",
|
|
4
|
+
"main": "dist/main.js",
|
|
6
5
|
"files": [
|
|
7
6
|
"dist"
|
|
8
7
|
],
|
|
9
8
|
"publishConfig": {
|
|
10
9
|
"access": "public"
|
|
11
10
|
},
|
|
11
|
+
"types": "dist/main.d.ts",
|
|
12
|
+
"type": "module",
|
|
12
13
|
"scripts": {
|
|
13
14
|
"build": "npm run clean && rollup -c",
|
|
14
15
|
"lint": "eslint .",
|
|
@@ -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.
|
|
41
|
+
"@pulse-editor/shared-utils": "0.1.1-alpha.30",
|
|
41
42
|
"react": "^19.0.0",
|
|
42
43
|
"react-dom": "^19.0.0"
|
|
43
44
|
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { Agent } from "@pulse-editor/shared-utils";
|
|
2
|
-
export default function useAgents(moduleName: string): {
|
|
3
|
-
installAgent: (config: Agent) => Promise<void>;
|
|
4
|
-
runAgentMethod: (agentName: string, methodName: string, parameters: Record<string, any>, abortSignal?: AbortSignal) => Promise<Record<string, any>>;
|
|
5
|
-
isReady: boolean;
|
|
6
|
-
};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { FileViewModel } from "@pulse-editor/shared-utils";
|
|
2
|
-
export default function useFileView(moduleName: string): {
|
|
3
|
-
viewFile: FileViewModel | undefined;
|
|
4
|
-
updateViewFile: (file: FileViewModel) => void;
|
|
5
|
-
setIsLoaded: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
6
|
-
};
|
package/dist/hooks/use-orc.d.ts
DELETED
package/dist/main.es.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
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};
|
package/src/main.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import useFileView from "./hooks/use-file-view";
|
|
2
|
-
import useTheme from "./hooks/use-theme";
|
|
3
|
-
import useNotification from "./hooks/use-notification";
|
|
4
|
-
import useAgents from "./hooks/use-agents";
|
|
5
|
-
import useOCR from "./hooks/use-orc";
|
|
6
|
-
import useTerminal from "./hooks/use-terminal";
|
|
7
|
-
|
|
8
|
-
export {
|
|
9
|
-
useFileView,
|
|
10
|
-
useTheme,
|
|
11
|
-
useNotification,
|
|
12
|
-
useAgents,
|
|
13
|
-
useOCR,
|
|
14
|
-
useTerminal,
|
|
15
|
-
};
|