@pulse-editor/react-api 0.1.1-alpha.23 → 0.1.1-alpha.25

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.
@@ -2,7 +2,7 @@
2
2
  * Use speech-to-speech API to listen to user input and read the output
3
3
  * provided by you.
4
4
  */
5
- export default function UseSpeech2Speech(): {
5
+ export default function useSpeech2Speech(): {
6
6
  isReady: boolean;
7
7
  userInput: string;
8
8
  isUserStopped: boolean;
package/dist/main.d.ts CHANGED
@@ -1,17 +1,16 @@
1
1
  import useAgentTools from "./hooks/agent/use-agent-tools";
2
2
  import useAgents from "./hooks/agent/use-agents";
3
- import useFetch from "./hooks/editor/use-fetch";
4
3
  import useFileView from "./hooks/editor/use-file-view";
5
4
  import useLoading from "./hooks/editor/use-loading";
6
5
  import useNotification from "./hooks/editor/use-notification";
7
6
  import useTheme from "./hooks/editor/use-theme";
8
7
  import useToolbar from "./hooks/editor/use-toolbar";
9
8
  import useExtCommand from "./hooks/extension/use-ext-command";
10
- import useImageGen from "./hooks/modality/use-image-gen";
11
- import useLLM from "./hooks/modality/use-llm";
12
- import useOCR from "./hooks/modality/use-ocr";
13
- import useSTT from "./hooks/modality/use-stt";
14
- import useTTS from "./hooks/modality/use-tts";
15
- import useVideoGen from "./hooks/modality/use-video-gen";
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";
16
15
  import useTerminal from "./hooks/terminal/use-terminal";
17
- export { useAgentTools, useAgents, useFetch, useFileView, useNotification, useTheme, useToolbar, useImageGen, useVideoGen, useLLM, useOCR, useSTT, useTTS, useExtCommand, useTerminal, useLoading, };
16
+ export { useAgentTools, useAgents, useFileView, useNotification, useTheme, useToolbar, useImageGen as ModalityImageGen, useVideoGen as ModalityVideoGen, useLLM as ModalityLLM, useOCR as ModalityOCR, useSTT as ModalitySTT, useTTS as ModalityTTS, useExtCommand, useTerminal, useLoading, };
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 r(r){const[o,a]=t(void 0),[s,c]=t(!1),[d,u]=t(!1),f=window.parent;return i(()=>(u(!0),()=>{u(!1),o?.close(),a(void 0)}),[]),i(()=>{!async function(){if(!d)return;if(void 0!==o)return;const t=new e;t.initThisWindow(window),t.updateReceiverHandlerMap(r),await t.initOtherWindow(f),a(t),t.sendMessage(n.ExtReady).then(()=>{c(!0)})}()},[d,o]),{imc:o,isReady:s}}function o(){return r(new Map),{}}function a(){const e=new Map,{imc:t,isReady:i}=r(e);return{runAgentMethod:async function(e,i,r,o,a){if(!t)throw new Error("IMC not initialized.");return await t.sendMessage(n.RunAgentMethod,{agentName:e,methodName:i,parameters:r,llmConfig:a},o).then(e=>e)},isReady:i}}function s(){const e=new Map,{imc:t}=r(e);return{fetch:function(e,i){if(!t)throw new Error("IMC is not initialized.");return t.sendMessage(n.Fetch,JSON.stringify({uri:e,options:i}))}}}function c(){const[e,o]=t(void 0),a=new Map,{imc:s,isReady:c}=r(a);return i(()=>{c&&s?.sendMessage(n.RequestViewFile).then(e=>{o(e)})},[c]),{viewModel:e,updateViewModel:function(e){s?.sendMessage(n.WriteViewFile,e)}}}function d(){const e=new Map,{imc:o,isReady:a}=r(e),[s,c]=t(!0);return i(()=>{a&&o?.sendMessage(n.UseLoading,{isLoading:s})},[s]),{isReady:a,toggleLoading:function(e){c(n=>e)}}}function u(){const e=new Map,{imc:t}=r(e);return{openNotification:function(e,i){if(!t)throw new Error("IMC is not initialized.");t.sendMessage(n.Notification,{text:e,type:i})}}}function f(){const[e,i]=t("light"),o=new Map;return o.set(n.ThemeChange,async(e,n)=>{const t=n.payload;i(e=>t)}),r(o),{theme:e}}function w(){return{}}function m(e,o){const{isReady:a,imc:s}=r(u()),[c,d]=t(o);function u(){return new Map([[n.RunExtCommand,async(n,t)=>{if(!e)throw new Error("Extension command is not available");const{name:i,args:r}=t.payload;if(i===e.name){const n=e.parameters;if(Object.keys(r).length!==Object.keys(n).length)throw new Error(`Invalid number of parameters: expected ${Object.keys(n).length}, got ${Object.keys(r).length}`);for(const[n,t]of Object.entries(r)){if(void 0===e.parameters[n])throw new Error(`Invalid parameter: ${n}`);if(typeof t!==e.parameters[n].type)throw new Error(`Invalid type for parameter ${n}: expected ${e.parameters[n].type}, got ${typeof t}. Value received: ${t}`)}if(c){const e=await c(r);if(e)return e}}}]])}return i(()=>{s?.updateReceiverHandlerMap(u())},[c,s]),{isReady:a,updateHandler:function(e){d(()=>e)}}}function p(){const e=new Map,{imc:t,isReady:i}=r(e);return{runImageGen:async function(e,i,r){if(!t)throw new Error("IMC not initialized.");if(!e&&!i)throw new Error("At least one of textPrompt or imagePrompt is required.");return await t.sendMessage(n.UseImageGen,{textPrompt:e,imagePrompt:i,imageModelConfig:r}).then(e=>e)},isReady:i}}function M(){const e=new Map,{imc:t,isReady:i}=r(e);return{runLLM:async function(e,i){if(!t)throw new Error("IMC not initialized.");return await t.sendMessage(n.UseLLM,{prompt:e,llmConfig:i}).then(e=>e)},isReady:i}}function g(){const e=new Map,{imc:t}=r(e);return{recognizeText:async function(e){if(!t)throw new Error("IMC is not initialized.");return(await t.sendMessage(n.UseOCR,{image:e})).payload.text}}}function l(){const e=new Map,{imc:t,isReady:i}=r(e);return{runSTT:async function(e,i){if(!t)throw new Error("IMC not initialized.");return await t.sendMessage(n.UseSTT,{audio:e,sttConfig:i}).then(e=>e)},isReady:i}}function y(){const e=new Map,{imc:t,isReady:i}=r(e);return{runTTS:async function(e,i){if(!t)throw new Error("IMC not initialized.");return await t.sendMessage(n.UseTTS,{text:e,ttsConfig:i}).then(e=>e)},isReady:i}}function h(){const e=new Map,{imc:t,isReady:i}=r(e);return{runVideoGen:async function(e,i,r,o){if(!t)throw new Error("IMC not initialized.");if(!i&&!r)throw new Error("At least one of textPrompt or imagePrompt is required.");return await t.sendMessage(n.UseVideoGen,{duration:e,textPrompt:i,imagePrompt:r,videoModelConfig:o}).then(e=>e)},isReady:i}}function R(){const e=new Map,{imc:o,isReady:a}=r(e),[s,c]=t(void 0),[d,u]=t(void 0);return i(()=>{a&&o?.sendMessage(n.RequestTerminal).then(e=>{const{websocketUrl:n,projectHomePath:t}=e;c(n),u(t)})},[a]),{websocketUrl:s,projectHomePath:d}}export{o as useAgentTools,a as useAgents,m as useExtCommand,s as useFetch,c as useFileView,p as useImageGen,M as useLLM,d as useLoading,u as useNotification,g as useOCR,l as useSTT,y as useTTS,R as useTerminal,f as useTheme,w as useToolbar,h as useVideoGen};
1
+ import{InterModuleCommunication as e,IMCMessageTypeEnum as t}from"@pulse-editor/shared-utils";import{useState as n,useEffect as i}from"react";function o(o){const[r,a]=n(void 0),[s,d]=n(!1),[c,u]=n(!1),f=window.parent;return i(()=>(u(!0),()=>{u(!1),r?.close(),a(void 0)}),[]),i(()=>{!async function(){if(!c)return;if(void 0!==r)return;const n=new e;n.initThisWindow(window),n.updateReceiverHandlerMap(o),await n.initOtherWindow(f),a(n),n.sendMessage(t.ExtReady).then(()=>{d(!0)})}()},[c,r]),{imc:r,isReady:s}}function r(){return o(new Map),{}}function a(){const e=new Map,{imc:n,isReady:i}=o(e);return{runAgentMethod:async function(e,i,o,r,a){if(!n)throw new Error("IMC not initialized.");return await n.sendMessage(t.EditorRunAgentMethod,{agentName:e,methodName:i,parameters:o,llmConfig:a},r).then(e=>e)},isReady:i}}function s(){const[e,r]=n(void 0),a=new Map,{imc:s,isReady:d}=o(a);return i(()=>{d&&s?.sendMessage(t.PlatformReadFile).then(e=>{r(e)})},[d]),{viewModel:e,updateViewModel:function(e){s?.sendMessage(t.PlatformWriteFile,e)}}}function d(){const e=new Map,{imc:r,isReady:a}=o(e),[s,d]=n(!0);return i(()=>{a&&r?.sendMessage(t.EditorLoadingExt,{isLoading:s})},[s]),{isReady:a,toggleLoading:function(e){d(t=>e)}}}function c(){const e=new Map,{imc:n}=o(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"),r=new Map;return r.set(t.EditorThemeUpdate,async(e,t)=>{const n=t.payload;i(e=>n)}),o(r),{theme:e}}function f(){return{}}function m(e,r){const{isReady:a,imc:s}=o(u()),[d,c]=n(r);function u(){return new Map([[t.EditorRunExtCommand,async(t,n)=>{if(!e)throw new Error("Extension command is not available");const{name:i,args:o}=n.payload;if(i===e.name){const t=e.parameters;if(Object.keys(o).length!==Object.keys(t).length)throw new Error(`Invalid number of parameters: expected ${Object.keys(t).length}, got ${Object.keys(o).length}`);for(const[t,n]of Object.entries(o)){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(o);if(e)return e}}}]])}return i(()=>{s?.updateReceiverHandlerMap(u())},[d,s]),{isReady:a,updateHandler:function(e){c(()=>e)}}}function w(){const e=new Map,{imc:n,isReady:i}=o(e);return{runImageGen:async function(e,i,o){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:o}).then(e=>e)},isReady:i}}function l(){const e=new Map,{imc:n,isReady:i}=o(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 p(){const e=new Map,{imc:n}=o(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}=o(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}=o(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}=o(e);return{runVideoGen:async function(e,i,o,r){if(!n)throw new Error("IMC not initialized.");if(!i&&!o)throw new Error("At least one of textPrompt or imagePrompt is required.");return await n.sendMessage(t.ModalityVideoGen,{duration:e,textPrompt:i,imagePrompt:o,videoModelConfig:r}).then(e=>e)},isReady:i}}function h(){const e=new Map,{imc:r,isReady:a}=o(e),[s,d]=n(void 0),[c,u]=n(void 0);return i(()=>{a&&r?.sendMessage(t.PlatformCreateTerminal).then(e=>{const{websocketUrl:t,projectHomePath:n}=e;d(t),u(n)})},[a]),{websocketUrl:s,projectHomePath:c}}export{w as ModalityImageGen,l as ModalityLLM,p as ModalityOCR,M as ModalitySTT,y as ModalityTTS,g as ModalityVideoGen,r as useAgentTools,a as useAgents,m as useExtCommand,s as useFileView,d as useLoading,c as useNotification,h as useTerminal,u as useTheme,f as useToolbar};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pulse-editor/react-api",
3
- "version": "0.1.1-alpha.23",
3
+ "version": "0.1.1-alpha.25",
4
4
  "main": "dist/main.js",
5
5
  "files": [
6
6
  "dist"
@@ -38,7 +38,7 @@
38
38
  "typescript-eslint": "^8.30.1"
39
39
  },
40
40
  "peerDependencies": {
41
- "@pulse-editor/shared-utils": "0.1.1-alpha.23",
41
+ "@pulse-editor/shared-utils": "0.1.1-alpha.25",
42
42
  "react": "^19.0.0",
43
43
  "react-dom": "^19.0.0"
44
44
  }
@@ -1,3 +0,0 @@
1
- export default function useFetch(): {
2
- fetch: (uri: string, options?: RequestInit) => Promise<Response>;
3
- };