codicent-app-sdk 0.3.75 → 0.3.77

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.
Files changed (111) hide show
  1. package/README.md +1 -0
  2. package/dist/cjs/components/AiInput.js +1 -1
  3. package/dist/cjs/components/AudioIcon.js +1 -1
  4. package/dist/cjs/components/ChatInput.js +1 -1
  5. package/dist/cjs/components/ChatMessage.d.ts.map +1 -1
  6. package/dist/cjs/components/ChatMessage.js +1 -1
  7. package/dist/cjs/components/CombinedPlaceholderDialog.js +1 -1
  8. package/dist/cjs/components/Footer.js +1 -1
  9. package/dist/cjs/components/Header.js +1 -1
  10. package/dist/cjs/components/HtmlView.js +1 -1
  11. package/dist/cjs/components/MessageInput.js +1 -1
  12. package/dist/cjs/components/MessageItem.js +1 -1
  13. package/dist/cjs/components/Profile.js +1 -1
  14. package/dist/cjs/components/Prompt.d.ts.map +1 -1
  15. package/dist/cjs/components/Prompt.js +1 -1
  16. package/dist/cjs/components/SnapFooter.js +1 -1
  17. package/dist/cjs/components/TextHeader.js +1 -1
  18. package/dist/cjs/components/TypingIndicator.js +1 -1
  19. package/dist/cjs/components/UploadFile.js +1 -1
  20. package/dist/cjs/components/UrlProcessor.js +1 -1
  21. package/dist/cjs/components/VoiceIcon.js +1 -1
  22. package/dist/cjs/config/index.d.ts +2 -0
  23. package/dist/cjs/config/index.d.ts.map +1 -1
  24. package/dist/cjs/config/index.js +1 -1
  25. package/dist/cjs/hooks/index.d.ts +1 -1
  26. package/dist/cjs/hooks/index.d.ts.map +1 -1
  27. package/dist/cjs/hooks/useAuthState.js +1 -1
  28. package/dist/cjs/hooks/useCodicentState.js +1 -1
  29. package/dist/cjs/hooks/useLocalization.d.ts +13 -2
  30. package/dist/cjs/hooks/useLocalization.d.ts.map +1 -1
  31. package/dist/cjs/hooks/useLocalization.js +1 -1
  32. package/dist/cjs/hooks/useLocalizationStub.d.ts +1 -0
  33. package/dist/cjs/hooks/useLocalizationStub.d.ts.map +1 -0
  34. package/dist/cjs/index.js +1 -1
  35. package/dist/cjs/node_modules/i18next/dist/esm/i18next.js +1 -1
  36. package/dist/cjs/node_modules/react-i18next/dist/es/context.js +1 -1
  37. package/dist/cjs/node_modules/react-i18next/dist/es/defaults.js +1 -1
  38. package/dist/cjs/node_modules/react-i18next/dist/es/i18nInstance.js +1 -1
  39. package/dist/cjs/node_modules/react-i18next/dist/es/initReactI18next.js +1 -1
  40. package/dist/cjs/node_modules/react-i18next/dist/es/unescape.js +1 -1
  41. package/dist/cjs/node_modules/react-i18next/dist/es/useTranslation.js +1 -1
  42. package/dist/cjs/node_modules/react-i18next/dist/es/utils.js +1 -1
  43. package/dist/cjs/pages/AppFrame.js +1 -1
  44. package/dist/cjs/pages/CrmPage.js +1 -1
  45. package/dist/cjs/pages/FormAccept.js +1 -1
  46. package/dist/cjs/pages/FormInvite.js +1 -1
  47. package/dist/cjs/pages/Login.js +1 -1
  48. package/dist/cjs/pages/Sales.js +1 -1
  49. package/dist/cjs/pages/Search.js +1 -1
  50. package/dist/cjs/pages/Snap.js +1 -1
  51. package/dist/cjs/services/index.d.ts +1 -0
  52. package/dist/cjs/services/index.d.ts.map +1 -1
  53. package/dist/cjs/services/translationService.d.ts +37 -0
  54. package/dist/cjs/services/translationService.d.ts.map +1 -0
  55. package/dist/cjs/services/translationService.js +1 -0
  56. package/dist/esm/components/AiInput.js +1 -1
  57. package/dist/esm/components/AudioIcon.js +1 -1
  58. package/dist/esm/components/ChatInput.js +1 -1
  59. package/dist/esm/components/ChatMessage.d.ts.map +1 -1
  60. package/dist/esm/components/ChatMessage.js +1 -1
  61. package/dist/esm/components/CombinedPlaceholderDialog.js +1 -1
  62. package/dist/esm/components/Footer.js +1 -1
  63. package/dist/esm/components/Header.js +1 -1
  64. package/dist/esm/components/HtmlView.js +1 -1
  65. package/dist/esm/components/MessageInput.js +1 -1
  66. package/dist/esm/components/MessageItem.js +1 -1
  67. package/dist/esm/components/Profile.js +1 -1
  68. package/dist/esm/components/Prompt.d.ts.map +1 -1
  69. package/dist/esm/components/Prompt.js +1 -1
  70. package/dist/esm/components/SnapFooter.js +1 -1
  71. package/dist/esm/components/TextHeader.js +1 -1
  72. package/dist/esm/components/TypingIndicator.js +1 -1
  73. package/dist/esm/components/UploadFile.js +1 -1
  74. package/dist/esm/components/UrlProcessor.js +1 -1
  75. package/dist/esm/components/VoiceIcon.js +1 -1
  76. package/dist/esm/config/index.d.ts +2 -0
  77. package/dist/esm/config/index.d.ts.map +1 -1
  78. package/dist/esm/config/index.js +1 -1
  79. package/dist/esm/hooks/index.d.ts +1 -1
  80. package/dist/esm/hooks/index.d.ts.map +1 -1
  81. package/dist/esm/hooks/useAuthState.js +1 -1
  82. package/dist/esm/hooks/useCodicentState.js +1 -1
  83. package/dist/esm/hooks/useLocalization.d.ts +13 -2
  84. package/dist/esm/hooks/useLocalization.d.ts.map +1 -1
  85. package/dist/esm/hooks/useLocalization.js +1 -1
  86. package/dist/esm/hooks/useLocalizationStub.d.ts +1 -0
  87. package/dist/esm/hooks/useLocalizationStub.d.ts.map +1 -0
  88. package/dist/esm/index.js +1 -1
  89. package/dist/esm/node_modules/i18next/dist/esm/i18next.js +1 -1
  90. package/dist/esm/node_modules/react-i18next/dist/es/context.js +1 -1
  91. package/dist/esm/node_modules/react-i18next/dist/es/defaults.js +1 -1
  92. package/dist/esm/node_modules/react-i18next/dist/es/i18nInstance.js +1 -1
  93. package/dist/esm/node_modules/react-i18next/dist/es/initReactI18next.js +1 -1
  94. package/dist/esm/node_modules/react-i18next/dist/es/unescape.js +1 -1
  95. package/dist/esm/node_modules/react-i18next/dist/es/useTranslation.js +1 -1
  96. package/dist/esm/node_modules/react-i18next/dist/es/utils.js +1 -1
  97. package/dist/esm/pages/AppFrame.js +1 -1
  98. package/dist/esm/pages/CrmPage.js +1 -1
  99. package/dist/esm/pages/FormAccept.js +1 -1
  100. package/dist/esm/pages/FormInvite.js +1 -1
  101. package/dist/esm/pages/Login.js +1 -1
  102. package/dist/esm/pages/Sales.js +1 -1
  103. package/dist/esm/pages/Search.js +1 -1
  104. package/dist/esm/pages/Snap.js +1 -1
  105. package/dist/esm/services/index.d.ts +1 -0
  106. package/dist/esm/services/index.d.ts.map +1 -1
  107. package/dist/esm/services/translationService.d.ts +37 -0
  108. package/dist/esm/services/translationService.d.ts.map +1 -0
  109. package/dist/esm/services/translationService.js +1 -0
  110. package/dist/index.d.ts +56 -7
  111. package/package.json +1 -3
@@ -1 +1 @@
1
- import{jsxs as o,jsx as e}from"react/jsx-runtime";import{useState as t,useRef as i,useMemo as n,useCallback as r,useEffect as s}from"react";import{useSearchParams as a,useNavigate as p}from"react-router-dom";import"../components/Markdown.js";import"../components/Textarea.js";import"../components/Button.js";import{Text as l}from"../components/Text.js";import"../components/Spinner.js";import"../components/TextHeader.js";import"../components/TypingIndicator.js";import"../components/Dialog.js";import"../components/ChatInput.js";import{CombinedPlaceholderDialog as m}from"../components/CombinedPlaceholderDialog.js";import"../components/ChatMessage.js";import"../components/Header.js";import"../services/codicent.js";import"../utils/MessageContent.js";import"../node_modules/tinycolor2/esm/tinycolor.js";import"../_virtual/index.js";import"../config/index.js";import"../lib/wavtools/lib/wav_packer.js";import"../lib/wavtools/lib/analysis/audio_analysis.js";import"../lib/wavtools/lib/wav_stream_player.js";import"../lib/wavtools/lib/wav_recorder.js";import"./AppFrame.js";import"./Search.js";import"./Login.js";import"./CrmPage.js";import"./ImageView.js";import"./FormInvite.js";import"./FormAccept.js";import"./Sales.js";import"../stores/chatStore.js";import c from"../hooks/useLocalization.js";import{useTemplateVariables as d}from"../hooks/useTemplateVariables.js";import"../hooks/useAppStyles.js";import"../components/FileThumbnail.js";import h from"../components/MessageInput.js";import"../components/UploadFile.js";import u from"../components/SnapFooter.js";import"../components/Profile.js";import"../components/MessageItem.js";import"../components/Content.js";import"../components/AiInput.js";import"../components/SearchBox.js";import"../components/HtmlView.js";import"../components/Footer.js";import"../components/Page.js";import{makeStyles as g}from"../node_modules/@griffel/react/makeStyles.esm.js";const f=g({container:{position:"relative",height:"100vh",width:"100vw",overflow:"auto"},flashOverlay:{position:"fixed",top:0,left:0,width:"100%",height:"100%",backgroundColor:"transparent",transition:"background-color 0.2s ease-out",pointerEvents:"none",zIndex:3},video:{position:"absolute",top:0,left:0,width:"100%",height:"100%",objectFit:"cover",zIndex:1},canvas:{display:"none"},bottomControls:{position:"fixed",bottom:"100px",width:"100%",display:"flex",justifyContent:"center",alignItems:"center",zIndex:2,boxSizing:"border-box"},controlContainer:{width:"100%",maxWidth:"600px",position:"relative"},sendButton:{position:"absolute",right:"10px",bottom:"10px",width:"50px",height:"50px",borderRadius:"50%",backgroundColor:"#0078d4",color:"white",border:"none",cursor:"pointer",display:"flex",justifyContent:"center",alignItems:"center"},topControls:{position:"fixed",top:"20px",width:"100%",display:"flex",justifyContent:"space-between",alignItems:"center",zIndex:2,padding:"0 10px",boxSizing:"border-box"},backButton:{width:"60px",height:"60px",borderRadius:"50%",backgroundColor:"transparent",color:"white",border:"none",cursor:"pointer"},input:{padding:"5px",width:"200px",fontSize:"larger",backgroundColor:"#fff8"},bottomButtons:{position:"fixed",bottom:"0px",width:"100%",display:"flex",justifyContent:"space-around",alignItems:"center",zIndex:2,boxSizing:"border-box"},iconButton:{width:"60px",height:"60px",borderRadius:"50%",backgroundColor:"transparent",color:"white",border:"none",cursor:"pointer"},centerText:{position:"fixed",top:"30%",left:"50%",transform:"translate(-50%, -50%)",zIndex:2,textAlign:"center"}}),w=({state:g,audio:w})=>{const j=f(),{service:b}=g,[x,v]=t(null),[y,C]=t(!0),k=i(null),I=i(null),[F]=a(),S=F.get("extra"),T=F.get("template"),[z,V]=t(""),[$]=t("log"),B=n((()=>new Audio("/audio/camera.mp3")),[]),[E,M]=t(!1),N=p(),{t:P}=c(),{extractTemplateVariables:_}=d(b.uploadFile),[A,H]=t(_(T||"")),[D,L]=t(A.length>0),[O,R]=t(""),[U,W]=t(100),K=r((()=>A.map((o=>`#${o.value}`)).join(" ")),[A]);s((()=>{const o=K();R(`${S?" #"+S:""}${o.length>0?" "+o:""}`.trim())}),[A,S,K]),s((()=>{if(window.visualViewport){const o=()=>{const o=window.visualViewport?window.innerHeight-window.visualViewport.height:0;W(o>150?o+20:100)};return window.visualViewport.addEventListener("resize",o),o(),()=>{window.visualViewport&&window.visualViewport.removeEventListener("resize",o)}}}),[]);const q=async o=>{try{const e=new FormData;e.append("file",o);const t=await b.uploadFile(o.name,e),i=K(),n=`${$?" #"+$:""}${S?" #"+S:""}${i.length>0?" "+i:""} #photo #file:${t}`;await b.sendMessage(n)}catch(o){alert(P("Failed to send image:")+" "+o)}};return s((()=>()=>{x&&x.getTracks().forEach((o=>o.stop()))}),[x]),o("div",{className:j.container,children:[e("div",{className:j.flashOverlay,style:{backgroundColor:E?"#ffffff":"transparent"}}),e("video",{ref:k,autoPlay:!0,playsInline:!0,className:j.video}),e("canvas",{ref:I,width:"640",height:"480",className:j.canvas}),!x&&e(l,{weight:"semibold",size:400,className:j.centerText,children:P("Klicka på Byt kamera för att starta!")}),e("div",{className:j.bottomControls,style:{bottom:`${U}px`},children:e("div",{className:j.controlContainer,children:e(h,{defaultText:z,onSend:async()=>{if(""===z.trim())return;const o=K(),e=`${$?" #"+$:""}${S?" #"+S:""}${o.length>0?" "+o:""} ${z}`;try{await b.sendMessage(e),V("")}catch(o){alert(P("Failed to send message: ")+o)}},rows:4,onChange:V,disableSend:!0})})}),e("div",{className:j.bottomButtons,children:e(u,{audio:w,onHome:()=>N("/"),onTakePhoto:()=>{const o=I.current,e=k.current;if(o&&e){o.width=e.videoWidth,o.height=e.videoHeight;const t=o.getContext("2d");t&&(B.play(),M(!0),setTimeout((()=>M(!1)),100),t.drawImage(e,0,0,o.width,o.height),o.toBlob((o=>{if(o){const e=new File([o],"snapshot.png",{type:"image/png"});q(e)}})))}},onSwichCamera:()=>{C((o=>!o)),(async()=>{x&&x.getTracks().forEach((o=>o.stop()));const o={video:{facingMode:y?"user":"environment"},audio:!1};try{const e=await navigator.mediaDevices.getUserMedia(o);v(e),k.current&&(k.current.srcObject=e,k.current.play())}catch(o){console.error("Error accessing the camera: ",o),o instanceof Error?alert(P("Error accessing the camera:")+" "+o.message):alert(P("Error accessing the camera"))}})()},tag:O})}),e(m,{open:D,templateVariables:A,filePlaceholders:[],onTemplateVariablesChange:H,onFilePlaceholdersChange:()=>{},onConfirm:()=>L(!1),onCancel:()=>{L(!1),N(-1)},uploadFile:b.uploadFile})]})};export{w as default};
1
+ import{jsxs as o,jsx as e}from"react/jsx-runtime";import{useState as t,useRef as i,useMemo as n,useCallback as r,useEffect as s}from"react";import{useSearchParams as a,useNavigate as p}from"react-router-dom";import"../components/Markdown.js";import"../components/Textarea.js";import"../components/Button.js";import{Text as l}from"../components/Text.js";import"../components/Spinner.js";import"../components/TextHeader.js";import"../components/TypingIndicator.js";import"../services/codicent.js";import"../utils/MessageContent.js";import"../node_modules/tinycolor2/esm/tinycolor.js";import"../_virtual/index.js";import"../config/index.js";import"../lib/wavtools/lib/wav_packer.js";import"../lib/wavtools/lib/analysis/audio_analysis.js";import"../lib/wavtools/lib/wav_stream_player.js";import"../lib/wavtools/lib/wav_recorder.js";import"./AppFrame.js";import"./Search.js";import"./Login.js";import"./CrmPage.js";import"./ImageView.js";import"./FormInvite.js";import"./FormAccept.js";import"./Sales.js";import"../stores/chatStore.js";import{useTemplateVariables as m}from"../hooks/useTemplateVariables.js";import"../hooks/useAppStyles.js";import c from"../hooks/useLocalization.js";import"../components/Dialog.js";import"../components/ChatInput.js";import{CombinedPlaceholderDialog as d}from"../components/CombinedPlaceholderDialog.js";import"../components/ChatMessage.js";import"../components/Header.js";import"../components/FileThumbnail.js";import h from"../components/MessageInput.js";import"../components/UploadFile.js";import u from"../components/SnapFooter.js";import"../components/Profile.js";import"../components/MessageItem.js";import"../components/Content.js";import"../components/AiInput.js";import"../components/SearchBox.js";import"../components/HtmlView.js";import"../components/Footer.js";import"../components/Page.js";import{makeStyles as g}from"../node_modules/@griffel/react/makeStyles.esm.js";const f=g({container:{position:"relative",height:"100vh",width:"100vw",overflow:"auto"},flashOverlay:{position:"fixed",top:0,left:0,width:"100%",height:"100%",backgroundColor:"transparent",transition:"background-color 0.2s ease-out",pointerEvents:"none",zIndex:3},video:{position:"absolute",top:0,left:0,width:"100%",height:"100%",objectFit:"cover",zIndex:1},canvas:{display:"none"},bottomControls:{position:"fixed",bottom:"100px",width:"100%",display:"flex",justifyContent:"center",alignItems:"center",zIndex:2,boxSizing:"border-box"},controlContainer:{width:"100%",maxWidth:"600px",position:"relative"},sendButton:{position:"absolute",right:"10px",bottom:"10px",width:"50px",height:"50px",borderRadius:"50%",backgroundColor:"#0078d4",color:"white",border:"none",cursor:"pointer",display:"flex",justifyContent:"center",alignItems:"center"},topControls:{position:"fixed",top:"20px",width:"100%",display:"flex",justifyContent:"space-between",alignItems:"center",zIndex:2,padding:"0 10px",boxSizing:"border-box"},backButton:{width:"60px",height:"60px",borderRadius:"50%",backgroundColor:"transparent",color:"white",border:"none",cursor:"pointer"},input:{padding:"5px",width:"200px",fontSize:"larger",backgroundColor:"#fff8"},bottomButtons:{position:"fixed",bottom:"0px",width:"100%",display:"flex",justifyContent:"space-around",alignItems:"center",zIndex:2,boxSizing:"border-box"},iconButton:{width:"60px",height:"60px",borderRadius:"50%",backgroundColor:"transparent",color:"white",border:"none",cursor:"pointer"},centerText:{position:"fixed",top:"30%",left:"50%",transform:"translate(-50%, -50%)",zIndex:2,textAlign:"center"}}),w=({state:g,audio:w})=>{const j=f(),{service:b}=g,[x,v]=t(null),[y,C]=t(!0),k=i(null),I=i(null),[F]=a(),S=F.get("extra"),T=F.get("template"),[z,V]=t(""),[$]=t("log"),B=n((()=>new Audio("/audio/camera.mp3")),[]),[E,M]=t(!1),N=p(),{t:P}=c(),{extractTemplateVariables:_}=m(b.uploadFile),[A,H]=t(_(T||"")),[D,L]=t(A.length>0),[O,R]=t(""),[U,W]=t(100),K=r((()=>A.map((o=>`#${o.value}`)).join(" ")),[A]);s((()=>{const o=K();R(`${S?" #"+S:""}${o.length>0?" "+o:""}`.trim())}),[A,S,K]),s((()=>{if(window.visualViewport){const o=()=>{const o=window.visualViewport?window.innerHeight-window.visualViewport.height:0;W(o>150?o+20:100)};return window.visualViewport.addEventListener("resize",o),o(),()=>{window.visualViewport&&window.visualViewport.removeEventListener("resize",o)}}}),[]);const q=async o=>{try{const e=new FormData;e.append("file",o);const t=await b.uploadFile(o.name,e),i=K(),n=`${$?" #"+$:""}${S?" #"+S:""}${i.length>0?" "+i:""} #photo #file:${t}`;await b.sendMessage(n)}catch(o){alert(P("Failed to send image:")+" "+o)}};return s((()=>()=>{x&&x.getTracks().forEach((o=>o.stop()))}),[x]),o("div",{className:j.container,children:[e("div",{className:j.flashOverlay,style:{backgroundColor:E?"#ffffff":"transparent"}}),e("video",{ref:k,autoPlay:!0,playsInline:!0,className:j.video}),e("canvas",{ref:I,width:"640",height:"480",className:j.canvas}),!x&&e(l,{weight:"semibold",size:400,className:j.centerText,children:P("Klicka på Byt kamera för att starta!")}),e("div",{className:j.bottomControls,style:{bottom:`${U}px`},children:e("div",{className:j.controlContainer,children:e(h,{defaultText:z,onSend:async()=>{if(""===z.trim())return;const o=K(),e=`${$?" #"+$:""}${S?" #"+S:""}${o.length>0?" "+o:""} ${z}`;try{await b.sendMessage(e),V("")}catch(o){alert(P("Failed to send message: ")+o)}},rows:4,onChange:V,disableSend:!0})})}),e("div",{className:j.bottomButtons,children:e(u,{audio:w,onHome:()=>N("/"),onTakePhoto:()=>{const o=I.current,e=k.current;if(o&&e){o.width=e.videoWidth,o.height=e.videoHeight;const t=o.getContext("2d");t&&(B.play(),M(!0),setTimeout((()=>M(!1)),100),t.drawImage(e,0,0,o.width,o.height),o.toBlob((o=>{if(o){const e=new File([o],"snapshot.png",{type:"image/png"});q(e)}})))}},onSwichCamera:()=>{C((o=>!o)),(async()=>{x&&x.getTracks().forEach((o=>o.stop()));const o={video:{facingMode:y?"user":"environment"},audio:!1};try{const e=await navigator.mediaDevices.getUserMedia(o);v(e),k.current&&(k.current.srcObject=e,k.current.play())}catch(o){console.error("Error accessing the camera: ",o),o instanceof Error?alert(P("Error accessing the camera:")+" "+o.message):alert(P("Error accessing the camera"))}})()},tag:O})}),e(d,{open:D,templateVariables:A,filePlaceholders:[],onTemplateVariablesChange:H,onFilePlaceholdersChange:()=>{},onConfirm:()=>L(!1),onCancel:()=>{L(!1),N(-1)},uploadFile:b.uploadFile})]})};export{w as default};
@@ -1,3 +1,4 @@
1
1
  export { CodicentService } from "./codicent";
2
2
  export * from "./codicent";
3
+ export * from "./translationService";
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC"}
@@ -0,0 +1,37 @@
1
+ import { CodicentService } from "./codicent";
2
+ export interface TranslationService {
3
+ /**
4
+ * Auto-translate text using AI service
5
+ */
6
+ translateText: (text: string, targetLanguage: string, service?: CodicentService) => Promise<string>;
7
+ /**
8
+ * Save translation to localStorage
9
+ */
10
+ saveTranslation: (key: string, value: string, language: string) => void;
11
+ /**
12
+ * Get stored translations from localStorage
13
+ */
14
+ getStoredTranslations: (language?: string) => Record<string, any>;
15
+ /**
16
+ * Clear stored translations
17
+ */
18
+ clearStoredTranslations: (language?: string) => void;
19
+ }
20
+ /**
21
+ * Auto-translate text using Codicent AI service
22
+ */
23
+ export declare const translateText: (text: string, targetLanguage: string, service?: CodicentService) => Promise<string>;
24
+ /**
25
+ * Save translation to localStorage
26
+ */
27
+ export declare const saveTranslation: (key: string, value: string, language: string) => void;
28
+ /**
29
+ * Get stored translations from localStorage
30
+ */
31
+ export declare const getStoredTranslations: (language?: string) => Record<string, any>;
32
+ /**
33
+ * Clear stored translations
34
+ */
35
+ export declare const clearStoredTranslations: (language?: string) => void;
36
+ export declare const translationService: TranslationService;
37
+ //# sourceMappingURL=translationService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translationService.d.ts","sourceRoot":"","sources":["../../../src/services/translationService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,aAAa,EAAE,CACb,IAAI,EAAE,MAAM,EACZ,cAAc,EAAE,MAAM,EACtB,OAAO,CAAC,EAAE,eAAe,KACtB,OAAO,CAAC,MAAM,CAAC,CAAC;IAErB;;OAEG;IACH,eAAe,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAExE;;OAEG;IACH,qBAAqB,EAAE,CAAC,QAAQ,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAElE;;OAEG;IACH,uBAAuB,EAAE,CAAC,QAAQ,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;CACtD;AAED;;GAEG;AACH,eAAO,MAAM,aAAa,SAClB,MAAM,kBACI,MAAM,YACZ,eAAe,KACxB,OAAO,CAAC,MAAM,CAuBhB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,QACrB,MAAM,SACJ,MAAM,YACH,MAAM,KACf,IAiBF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,qBAAqB,cACrB,MAAM,KAChB,MAAM,CAAC,MAAM,EAAE,GAAG,CAgBpB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,uBAAuB,cAAe,MAAM,KAAG,IAuB3D,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,kBAKhC,CAAC"}
@@ -0,0 +1 @@
1
+ const t=async(t,a,e)=>{if(!e)return console.warn("[TranslationService] No CodicentService provided for auto-translation"),t;try{const r=`Translate the following text to ${a}. Return only the translation, no explanation:\n\n${t}`,o=(await e.sendMessage(r)).trim().replace(/^["']|["']$/g,"");return console.log(`🌐 [TranslationService] Auto-translated "${t}" to "${o}"`),o}catch(a){return console.error("[TranslationService] Auto-translation failed:",a),t}},a=(t,a,e)=>{try{const r=JSON.parse(localStorage.getItem("app-translations")||"{}");r[e]||(r[e]={}),r[e][t]=a,localStorage.setItem("app-translations",JSON.stringify(r)),console.log(`💾 [TranslationService] Saved translation for ${e}: ${t} = ${a}`)}catch(t){console.error("[TranslationService] Failed to save translation:",t)}},e=t=>{try{const a=JSON.parse(localStorage.getItem("app-translations")||"{}");return t?a[t]||{}:a}catch(t){return console.error("[TranslationService] Failed to get stored translations:",t),{}}},r=t=>{try{if(t){const a=JSON.parse(localStorage.getItem("app-translations")||"{}");delete a[t],localStorage.setItem("app-translations",JSON.stringify(a))}else localStorage.removeItem("app-translations");console.log("🗑️ [TranslationService] Cleared stored translations"+(t?` for ${t}`:""))}catch(t){console.error("[TranslationService] Failed to clear stored translations:",t)}},o={translateText:t,saveTranslation:a,getStoredTranslations:e,clearStoredTranslations:r};export{r as clearStoredTranslations,e as getStoredTranslations,a as saveTranslation,t as translateText,o as translationService};
package/dist/index.d.ts CHANGED
@@ -128,6 +128,42 @@ declare class CodicentService {
128
128
  updateTodoStatus: (messageId: string, status: "done" | "undone") => Promise<boolean>;
129
129
  }
130
130
 
131
+ interface TranslationService {
132
+ /**
133
+ * Auto-translate text using AI service
134
+ */
135
+ translateText: (text: string, targetLanguage: string, service?: CodicentService) => Promise<string>;
136
+ /**
137
+ * Save translation to localStorage
138
+ */
139
+ saveTranslation: (key: string, value: string, language: string) => void;
140
+ /**
141
+ * Get stored translations from localStorage
142
+ */
143
+ getStoredTranslations: (language?: string) => Record<string, any>;
144
+ /**
145
+ * Clear stored translations
146
+ */
147
+ clearStoredTranslations: (language?: string) => void;
148
+ }
149
+ /**
150
+ * Auto-translate text using Codicent AI service
151
+ */
152
+ declare const translateText: (text: string, targetLanguage: string, service?: CodicentService) => Promise<string>;
153
+ /**
154
+ * Save translation to localStorage
155
+ */
156
+ declare const saveTranslation: (key: string, value: string, language: string) => void;
157
+ /**
158
+ * Get stored translations from localStorage
159
+ */
160
+ declare const getStoredTranslations: (language?: string) => Record<string, any>;
161
+ /**
162
+ * Clear stored translations
163
+ */
164
+ declare const clearStoredTranslations: (language?: string) => void;
165
+ declare const translationService: TranslationService;
166
+
131
167
  declare const Markdown: ({ content }: {
132
168
  content: string;
133
169
  }) => react_jsx_runtime.JSX.Element;
@@ -467,12 +503,6 @@ declare const useRealtimeVoiceAI: (apiKey: string, tools: {
467
503
  handler: Function;
468
504
  }[]) => RealtimeVoice | undefined;
469
505
 
470
- declare const useLocalization: () => {
471
- t: (key: string) => string;
472
- currentLanguage: string;
473
- setCurrentLanguage: React$1.Dispatch<React$1.SetStateAction<string>>;
474
- };
475
-
476
506
  interface TemplateVariable {
477
507
  name: string;
478
508
  value: string;
@@ -522,6 +552,23 @@ declare const useToaster: () => {
522
552
  ToasterComponent: () => react_jsx_runtime.JSX.Element;
523
553
  };
524
554
 
555
+ interface LanguageSource {
556
+ source: "force_config" | "url_param" | "browser" | "default";
557
+ language: string;
558
+ }
559
+ /**
560
+ * Enhanced translation hook that supports both static translations and auto-translation
561
+ */
562
+ declare function useLocalization(): {
563
+ t: (key: string) => string;
564
+ translateAsync: (text: string) => Promise<string>;
565
+ currentLanguage: string;
566
+ setCurrentLanguage: (lang: string) => void;
567
+ getLanguageInfo: () => LanguageSource;
568
+ isForced: boolean;
569
+ translationVersion: number;
570
+ };
571
+
525
572
  interface CombinedPlaceholderDialogProps {
526
573
  open: boolean;
527
574
  templateVariables: TemplateVariable[];
@@ -731,6 +778,7 @@ interface AppConfigOptions {
731
778
  APP_CHAT_TITLE: undefined | string;
732
779
  APP_CONFIG: AppConfig;
733
780
  APP_FOOTER_COLOR: undefined | string;
781
+ TRANSLATIONS: Record<string, Record<string, string>> | undefined;
734
782
  APP_FOOTER_SELECTED_COLOR: undefined | string;
735
783
  APP_FOOTER_TEXT_COLOR: undefined | string;
736
784
  APP_HEADER_COLOR: undefined | string;
@@ -813,6 +861,7 @@ interface AppConfigOptions {
813
861
  SHOW_SAVE_BUTTON_TEXT: boolean;
814
862
  FORM_BACKGROUND_IMAGE_URL: undefined | string;
815
863
  AUTO_TRANSLATE: boolean;
864
+ FORCE_LANGUAGE: string | undefined;
816
865
  APP_LOGBOOK_TITLE: undefined | string;
817
866
  LOGIN_WELCOME_TEXT: string | undefined;
818
867
  LOGIN_HIDE_WELCOME: boolean;
@@ -868,4 +917,4 @@ declare const Sales: React__default.FC<{
868
917
  state: CodicentAppState;
869
918
  }>;
870
919
 
871
- export { AiInput, AppConfig, AppConfigOptions, AppFrame, AppInfo, AppStateDefinition, AppStateMachine, AudioIcon, AudioRecorder, AudioRecorderState, Button, ChatInput, ChatMessage, CodicentAppState, CodicentService, CodicentServiceOptions, ColorPicker, CombinedPlaceholderDialog, Content, CrmPage, DatePicker, FilePlaceholder, FileThumbnail, Footer, FormAccept, FormInvite, Header, HtmlView, ImageViewer as ImageView, Input, Label, Login, Logout, Markdown, Message$1 as Message, Content$1 as MessageContent, MessageInput, MessageItem, Page, Profile, Prompt, RealtimeVoice, Sales, Search, SearchBox, Snap, SnapFooter, Spinner, StateContext, TemplateVariable, Text, TextHeader, Textarea, TimePicker, Title, TypingIndicator, UploadFile, UploadFileProps, UploadFileRef, UrlProcessor, UseAuthState, UserInfo, VoiceIcon, WavRecorder, WavStreamPlayer, createAppStateMachine, generateBrandVariants, getConfigValue, getGpsLocation, getTimeString, initCodicentApp, isMobileDevice, log, useAppStyles, useAudioRecorder, useAuthState, useChat, useCodicentApp, useCodicentState, useLocalization, useRealtimeVoiceAI, useStateWithLocalStorage, useTemplateVariables, useToaster, useTools, withWakeLock };
920
+ export { AiInput, AppConfig, AppConfigOptions, AppFrame, AppInfo, AppStateDefinition, AppStateMachine, AudioIcon, AudioRecorder, AudioRecorderState, Button, ChatInput, ChatMessage, CodicentAppState, CodicentService, CodicentServiceOptions, ColorPicker, CombinedPlaceholderDialog, Content, CrmPage, DatePicker, FilePlaceholder, FileThumbnail, Footer, FormAccept, FormInvite, Header, HtmlView, ImageViewer as ImageView, Input, Label, Login, Logout, Markdown, Message$1 as Message, Content$1 as MessageContent, MessageInput, MessageItem, Page, Profile, Prompt, RealtimeVoice, Sales, Search, SearchBox, Snap, SnapFooter, Spinner, StateContext, TemplateVariable, Text, TextHeader, Textarea, TimePicker, Title, TranslationService, TypingIndicator, UploadFile, UploadFileProps, UploadFileRef, UrlProcessor, UseAuthState, UserInfo, VoiceIcon, WavRecorder, WavStreamPlayer, clearStoredTranslations, createAppStateMachine, generateBrandVariants, getConfigValue, getGpsLocation, getStoredTranslations, getTimeString, initCodicentApp, isMobileDevice, log, saveTranslation, translateText, translationService, useAppStyles, useAudioRecorder, useAuthState, useChat, useCodicentApp, useCodicentState, useLocalization, useRealtimeVoiceAI, useStateWithLocalStorage, useTemplateVariables, useToaster, useTools, withWakeLock };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codicent-app-sdk",
3
- "version": "0.3.75",
3
+ "version": "0.3.77",
4
4
  "description": "SDK for building AI-powered applications with Codicent",
5
5
  "type": "module",
6
6
  "main": "dist/cjs/index.js",
@@ -77,11 +77,9 @@
77
77
  "@types/react-dom": "^18.0.11",
78
78
  "@types/react-json-editor-ajrm": "^2.5.6",
79
79
  "gh-pages": "^5.0.0",
80
- "i18next": "^23.0.0",
81
80
  "jest": "^29.4.3",
82
81
  "jest-environment-jsdom": "^29.4.3",
83
82
  "mermaid": "^11.3.0",
84
- "react-i18next": "^12.0.0",
85
83
  "react-markdown": "^9.0.1",
86
84
  "rehype-raw": "^7.0.0",
87
85
  "rehype-sanitize": "^6.0.0",