@pickaxeproject/react 1.2.8 → 1.3.0

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 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),s=require("./Addons/Document/Provider.js"),i=require("./ResponseProvider.js"),o=require("./DimensionProvider.js");const r=t.createContext({});exports.PickaxeContext=r,exports.PickaxeProvider=({children:a,userId:n="",studioUserId:d="",deploymentId:c="",styles:l,colors:u,limits:p={},misc:h={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0},translations:m,chatInput:F="",responsiveBy:x="viewport",loadFont:I=!0,forceMobile:y=!1,isEmbed:b=!1,onGenerateComplete:f})=>{const[g,S]=t.useState(""),[j,P]=t.useState(""),[v,w]=t.useState(null),[k,C]=t.useState(!1),[O,q]=t.useState(!0),[D,H]=t.useState(!0),[B,E]=t.useState(!1);return t.useEffect((()=>{C(!1)}),[null==l?void 0:l.font]),e.jsx(r.Provider,Object.assign({value:Object.assign({formId:g,chatId:j,userId:n,studioUserId:d,deploymentId:c,pickaxe:v,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},l),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},u),misc:h,translations:Object.assign({"new-chat":"New chat","see-history":"See history","see-input":"See input","hide-input":"Hide input",processing:"Processing...",uploading:"Uploading...",loading:"Loading...","powered-by-pickaxe":"Powered by Pickaxe","form-doc-placeholder":"Paste a website/video link or drag a file"},m),chatInput:F,responsiveBy:x,isFontLoaded:k,isNewChat:O,isShowIceBreaker:D,isShowHistory:B,loadFont:I,forceMobile:y,isEmbed:b,setIsFontLoaded:C,setFormId:S,setChatId:P,setPickaxe:w,setIsNewChat:q,setIsShowIceBreaker:H,setIsShowHistory:E},f&&{onGenerateComplete:f})},{children:e.jsx(i.default,Object.assign({limits:p},{children:e.jsx(o.default,{children:e.jsx(s.default,{children:a})})}))}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),s=require("./Addons/Document/Provider.js"),i=require("./ResponseProvider.js"),r=require("./DimensionProvider.js");const o=t.createContext({});exports.PickaxeContext=o,exports.PickaxeProvider=({children:a,userId:n="",studioUserId:d="",deploymentId:c="",embedUserId:l="",styles:u,colors:p,limits:h={},misc:m={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0},translations:F,chatInput:I="",responsiveBy:x="viewport",loadFont:b=!0,forceMobile:y=!1,isEmbed:f=!1,onGenerateComplete:g})=>{const[S,j]=t.useState(""),[P,v]=t.useState(""),[w,k]=t.useState(null),[C,O]=t.useState(!1),[q,D]=t.useState(!0),[H,U]=t.useState(!0),[B,E]=t.useState(!1);return t.useEffect((()=>{O(!1)}),[null==u?void 0:u.font]),e.jsx(o.Provider,Object.assign({value:Object.assign({formId:S,chatId:P,userId:n,studioUserId:d,deploymentId:c,embedUserId:l,pickaxe:w,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},u),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},p),misc:m,translations:Object.assign({"new-chat":"New chat","see-history":"See history","see-input":"See input","hide-input":"Hide input",processing:"Processing...",uploading:"Uploading...",loading:"Loading...","powered-by-pickaxe":"Powered by Pickaxe","form-doc-placeholder":"Paste a website/video link or drag a file"},F),chatInput:I,responsiveBy:x,isFontLoaded:C,isNewChat:q,isShowIceBreaker:H,isShowHistory:B,loadFont:b,forceMobile:y,isEmbed:f,setIsFontLoaded:O,setFormId:j,setChatId:v,setPickaxe:k,setIsNewChat:D,setIsShowIceBreaker:U,setIsShowHistory:E},g&&{onGenerateComplete:g})},{children:e.jsx(i.default,Object.assign({limits:h},{children:e.jsx(r.default,{children:e.jsx(s.default,{children:a})})}))}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),r=require("react/jsx-runtime"),n=require("react"),s=require("./hooks/usePickaxeMarkdownContext.js"),t=require("react-markdown"),i=require("remark-gfm"),l=require("remark-math"),d=require("rehype-katex"),a=require("rehype-raw"),o=require("./Custom/A/index.js"),c=require("./Custom/P/index.js"),u=require("./Custom/Img/index.js"),h=require("./Custom/Iframe/index.js"),x=require("./Custom/Code/index.js"),p=require("./Custom/common/LinkPreview.js"),j=require("../../../../common/cn.js");function m(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var f=m(t),g=m(i),b=m(l),k=m(d),w=m(a);exports.PickaxeMarkdownRenderer=({className:t,style:i,value:l,recursion:d=!1,children:a,maxLines:m,multiLineBreaks:q,onExpandClick:v})=>{const{theme:y,accentColor:C,websiteMetadatas:D}=s.usePickaxeMarkdownContext(),[O,M]=n.useState({width:0,height:0}),[P,S]=n.useState(null),$=n.useRef(null),E=n.useMemo((()=>{if(!l)return"";let e=l.trim();return e=e.replace(/<!--[\s\S]*?-->/g,""),e=e.replace(/\u200B/g,""),e=e.replace(/\\[\s\S]*?\\]/g,(e=>"$$"+e.substring(2,e.length-2)+"$$")).replace(/\\\(\s*[\s\S]*?\s*\\\)/g,(e=>"$"+e.substring(2,e.length-2)+"$")),q&&(e=e.replace(/```[\s\S]*?```|(\n(?=\n))/g,((e,r)=>r?"\n\n<br/>\n":e))),e||""}),[l,q]);n.useEffect((()=>{if(!m)return void S(null);if(!$.current||!E||P)return;const e=$.current,r=parseInt(window.getComputedStyle(e).lineHeight,10),n=m*r;if(!(O.height>n))return;const s=Math.floor(O.width/8),t=Math.floor(s*m);S(E.slice(0,t)+'<span class="pxe-expand-btn">...</span>')}),[E,m,O,P]);const N={h1:({node:e,children:n})=>r.jsx("h1",{children:n}),h2:({node:e,children:n})=>r.jsx("h2",{children:n}),h3:({node:e,children:n})=>r.jsx("h3",{children:n}),h4:({node:e,children:n})=>r.jsx("h4",{children:n}),h5:({node:e,children:n})=>r.jsx("h5",{children:n}),p:c.default,a:o.default,ol:({node:e,children:n})=>r.jsx("ol",{children:n}),ul:({node:e,children:n})=>r.jsx("ul",{children:n}),li:({node:e,children:n})=>r.jsx("li",{children:n}),table:({children:e})=>r.jsx("div",Object.assign({className:"pxe-markdown-table"},{children:r.jsx("table",{children:e})})),th:({node:e,children:n})=>r.jsx("th",{children:n}),tr:({node:e,children:n})=>r.jsx("tr",Object.assign({style:{border:"dark"===y?"1px solid #30363D":"1px solid #D0D7DE"}},{children:n})),td:({node:e,children:n})=>r.jsx("td",{children:n}),code:x.default,blockquote:({node:e,children:n})=>r.jsx("blockquote",Object.assign({style:{borderLeft:"dark"===y?"4px solid #30363D":"4px solid #D0D7DE",color:"dark"===y?"#8B8B8B":"#656D76"}},{children:n})),img:u.default,iframe:h.default,hr:()=>r.jsx("hr",{style:{border:0,borderTop:"dark"===y?"1px solid #30363D":"1px solid #D0D7DE"}}),span:n=>{var{node:s,children:t}=n,i=e.__rest(n,["node","children"]);return"pxe-expand-btn"===i.className?r.jsx("span",Object.assign({},i,{style:Object.assign({display:"inline",fontWeight:500,color:C,marginLeft:".25rem",userSelect:"none"},v&&{cursor:"pointer"})},v&&{onClick:v},{children:t})):r.jsx("span",Object.assign({},i,{children:t}))},br:()=>r.jsx("br",{})};n.useEffect((()=>{if(!$.current)return;const e=new ResizeObserver((e=>{for(const r of e){const{width:e,height:n}=r.contentRect;M({width:e,height:n})}}));return e.observe($.current),()=>{e.disconnect()}}),[]);const _=P||E,B=!d&&D.length>0?"\n\n---":"";return r.jsxs("div",Object.assign({className:"pxe-markdown",ref:$,style:Object.assign({position:"relative",overflowWrap:"break-word",display:"grid",gridTemplateColumns:"repeat(1, minmax(0, 1fr))",gap:".625rem"},i)},{children:[r.jsx(f.default,Object.assign({className:j.default(!d&&"pxe-prose",t),components:N,remarkPlugins:[g.default,b.default],rehypePlugins:[k.default,w.default]},{children:`${_}${B}`})),!d&&D.length>0&&r.jsx("div",Object.assign({className:"pxe-link-previews"},{children:D.map(((e,n)=>r.jsx(p.default,{data:e},n)))})),a]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),r=require("react/jsx-runtime"),n=require("react"),s=require("./hooks/usePickaxeMarkdownContext.js"),t=require("react-markdown"),i=require("remark-gfm"),l=require("remark-math"),d=require("rehype-katex"),a=require("rehype-raw"),o=require("./Custom/A/index.js"),c=require("./Custom/P/index.js"),u=require("./Custom/Img/index.js"),h=require("./Custom/Iframe/index.js"),x=require("./Custom/Code/index.js"),p=require("./Custom/common/LinkPreview.js"),j=require("../../../../common/cn.js");function m(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var f=m(t),g=m(i),b=m(l),k=m(d),w=m(a);exports.PickaxeMarkdownRenderer=({className:t,style:i,value:l,recursion:d=!1,children:a,maxLines:m,multiLineBreaks:q,onExpandClick:v})=>{const{theme:y,accentColor:C,websiteMetadatas:D}=s.usePickaxeMarkdownContext(),[O,$]=n.useState({width:0,height:0}),[M,P]=n.useState(null),S=n.useRef(null),E=n.useMemo((()=>{if(!l)return"";let e=l.trim();return e=e.replace(/<!--[\s\S]*?-->/g,""),e=e.replace(/\u200B/g,""),e=e.replace(/\\[\s\S]*?\\]/g,(e=>"$$"+e.substring(2,e.length-2)+"$$")).replace(/\\\(\s*[\s\S]*?\s*\\\)/g,(e=>"$$"+e.substring(2,e.length-2)+"$$")),q&&(e=e.replace(/```[\s\S]*?```|(\n(?=\n))/g,((e,r)=>r?"\n\n<br/>\n":e))),e||""}),[l,q]);n.useEffect((()=>{if(!m)return void P(null);if(!S.current||!E||M)return;const e=S.current,r=parseInt(window.getComputedStyle(e).lineHeight,10),n=m*r;if(!(O.height>n))return;const s=Math.floor(O.width/8),t=Math.floor(s*m);P(E.slice(0,t)+'<span class="pxe-expand-btn">...</span>')}),[E,m,O,M]);const N={h1:({node:e,children:n})=>r.jsx("h1",{children:n}),h2:({node:e,children:n})=>r.jsx("h2",{children:n}),h3:({node:e,children:n})=>r.jsx("h3",{children:n}),h4:({node:e,children:n})=>r.jsx("h4",{children:n}),h5:({node:e,children:n})=>r.jsx("h5",{children:n}),p:c.default,a:o.default,ol:({node:e,children:n})=>r.jsx("ol",{children:n}),ul:({node:e,children:n})=>r.jsx("ul",{children:n}),li:({node:e,children:n})=>r.jsx("li",{children:n}),table:({children:e})=>r.jsx("div",Object.assign({className:"pxe-markdown-table"},{children:r.jsx("table",{children:e})})),th:({node:e,children:n})=>r.jsx("th",{children:n}),tr:({node:e,children:n})=>r.jsx("tr",Object.assign({style:{border:"dark"===y?"1px solid #30363D":"1px solid #D0D7DE"}},{children:n})),td:({node:e,children:n})=>r.jsx("td",{children:n}),code:x.default,blockquote:({node:e,children:n})=>r.jsx("blockquote",Object.assign({style:{borderLeft:"dark"===y?"4px solid #30363D":"4px solid #D0D7DE",color:"dark"===y?"#8B8B8B":"#656D76"}},{children:n})),img:u.default,iframe:h.default,hr:()=>r.jsx("hr",{style:{border:0,borderTop:"dark"===y?"1px solid #30363D":"1px solid #D0D7DE"}}),span:n=>{var{node:s,children:t}=n,i=e.__rest(n,["node","children"]);return"pxe-expand-btn"===i.className?r.jsx("span",Object.assign({},i,{style:Object.assign({display:"inline",fontWeight:500,color:C,marginLeft:".25rem",userSelect:"none"},v&&{cursor:"pointer"})},v&&{onClick:v},{children:t})):r.jsx("span",Object.assign({},i,{children:t}))},br:()=>r.jsx("br",{})};n.useEffect((()=>{if(!S.current)return;const e=new ResizeObserver((e=>{for(const r of e){const{width:e,height:n}=r.contentRect;$({width:e,height:n})}}));return e.observe(S.current),()=>{e.disconnect()}}),[]);const _=M||E,B=!d&&D.length>0?"\n\n---":"";return r.jsxs("div",Object.assign({className:"pxe-markdown",ref:S,style:Object.assign({position:"relative",overflowWrap:"break-word",display:"grid",gridTemplateColumns:"repeat(1, minmax(0, 1fr))",gap:".625rem"},i)},{children:[r.jsx(f.default,Object.assign({className:j.default(!d&&"pxe-prose",t),components:N,remarkPlugins:[g.default,[b.default,{singleDollarTextMath:!1}]],rehypePlugins:[k.default,w.default]},{children:`${_}${B}`})),!d&&D.length>0&&r.jsx("div",Object.assign({className:"pxe-link-previews"},{children:D.map(((e,n)=>r.jsx(p.default,{data:e},n)))})),a]}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),t=require("@tanstack/react-query"),r=require("./usePickaxeContext.js"),i=require("../../common/api/index.js");exports.useHistory=({enabled:o=!0}={enabled:!0})=>{const{formId:s,pickaxe:a,studioUserId:d}=r.usePickaxeContext();return t.useInfiniteQuery({queryKey:["form",s,"history"],queryFn:({pageParam:t=0})=>(({formId:t,place:r,studioId:o})=>e.__awaiter(void 0,void 0,void 0,(function*(){let e=`/pickaxe/history?formid=${t}&place=${r}`;o&&(e+=`&studioId=${o}`);const s=yield i.default.get(e),a=s.data;if(200!==s.status)throw new Error("[_getHistory] Failed to fetch history "+a);return{next:a.history.length<5?void 0:r+25,data:a.history}})))(Object.assign({formId:s,place:t},d&&(null==a?void 0:a.studioid)&&{studioId:a.studioid})),getNextPageParam:e=>e.next,enabled:o&&!!s})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),t=require("@tanstack/react-query"),r=require("./usePickaxeContext.js"),i=require("../../common/api/index.js");exports.useHistory=({enabled:d=!0}={enabled:!0})=>{const{formId:s,pickaxe:o,studioUserId:a,embedUserId:u}=r.usePickaxeContext(),n=t.useInfiniteQuery({queryKey:["form",s,"history"],queryFn:({pageParam:t=0})=>(({formId:t,place:r,studioId:d,embedUserId:s})=>e.__awaiter(void 0,void 0,void 0,(function*(){let e=`/pickaxe/history?formid=${t}&place=${r}`;d&&(e+=`&studioId=${d}`),s&&(e+=`&embedUserId=${s}`);const o=yield i.default.get(e),a=o.data;if(200!==o.status)throw new Error("[_getHistory] Failed to fetch history "+a);return{next:a.history.length<5?void 0:r+25,data:a.history}})))(Object.assign(Object.assign({formId:s,place:t},a&&(null==o?void 0:o.studioid)&&{studioId:o.studioid}),u&&{embedUserId:u})),getNextPageParam:e=>e.next,enabled:d&&!!s});return n};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),t=require("@tanstack/react-query"),s=require("../../common/api/index.js");exports.useSubmit=()=>t.useMutation({mutationFn:t=>(({formId:t,responseId:i,documentId:a,studioUserId:r,deploymentId:o,pickaxe:d,value:n,valueObj:u})=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=yield s.default.post("/pickaxe/submit",Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({origin:"pickaxe",formId:t},i&&{responseId:i}),a&&{documentId:a}),r&&{studioUserId:r}),o&&{deploymentId:o}),d&&{pickaxe:d}),n&&{value:n}),u&&{valueObj:u})),c=e.data;if(200!==e.status)throw new Error("[_getHistory] Failed to fetch history "+c);return c})))(t)});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),t=require("@tanstack/react-query"),s=require("../../common/api/index.js");exports.useSubmit=()=>t.useMutation({mutationFn:t=>(({formId:t,responseId:i,documentId:r,studioUserId:a,deploymentId:d,embedUserId:o,pickaxe:n,value:u,valueObj:c})=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=yield s.default.post("/pickaxe/submit",Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({origin:"pickaxe",formId:t},i&&{responseId:i}),r&&{documentId:r}),a&&{studioUserId:a}),d&&{deploymentId:d}),o&&{embedUserId:o}),n&&{pickaxe:n}),u&&{value:u}),c&&{valueObj:c})),b=e.data;if(200!==e.status)throw new Error("[_getHistory] Failed to fetch history "+b);return b})))(t)});
@@ -39,6 +39,7 @@ type PickaxeContextType = {
39
39
  userId: string;
40
40
  studioUserId: string;
41
41
  deploymentId: string;
42
+ embedUserId: string;
42
43
  pickaxe: Pickaxe | null;
43
44
  styles: PickaxeProviderStyles;
44
45
  colors: PickaxeProviderColors;
@@ -67,6 +68,7 @@ export interface IPickaxeProviderProps {
67
68
  userId?: string;
68
69
  studioUserId?: string;
69
70
  deploymentId?: string;
71
+ embedUserId?: string;
70
72
  styles?: Partial<PickaxeProviderStyles>;
71
73
  colors?: Partial<PickaxeProviderColors>;
72
74
  limits?: Record<string, PickaxeLimitData>;
@@ -80,5 +82,5 @@ export interface IPickaxeProviderProps {
80
82
  onGenerateComplete?: (responseId: string) => void;
81
83
  }
82
84
  export declare const PickaxeContext: import("react").Context<PickaxeContextType>;
83
- export declare const PickaxeProvider: ({ children, userId, studioUserId, deploymentId, styles, colors, limits, misc, translations, chatInput, responsiveBy, loadFont, forceMobile, isEmbed, onGenerateComplete, }: IPickaxeProviderProps) => import("react/jsx-runtime").JSX.Element;
85
+ export declare const PickaxeProvider: ({ children, userId, studioUserId, deploymentId, embedUserId, styles, colors, limits, misc, translations, chatInput, responsiveBy, loadFont, forceMobile, isEmbed, onGenerateComplete, }: IPickaxeProviderProps) => import("react/jsx-runtime").JSX.Element;
84
86
  export {};
@@ -4,6 +4,7 @@ export declare const usePickaxeContext: () => {
4
4
  userId: string;
5
5
  studioUserId: string;
6
6
  deploymentId: string;
7
+ embedUserId: string;
7
8
  pickaxe: import("../../types/pickaxe").Pickaxe | null;
8
9
  styles: import("../../components/Pickaxe/Provider").PickaxeProviderStyles;
9
10
  colors: import("../../components/Pickaxe/Provider").PickaxeProviderColors;
@@ -5,6 +5,7 @@ type MutationParams = {
5
5
  documentId?: string;
6
6
  studioUserId?: string;
7
7
  deploymentId?: string;
8
+ embedUserId?: string;
8
9
  pickaxe?: Partial<Pickaxe>;
9
10
  value?: string;
10
11
  valueObj?: Record<string, string>;
@@ -7,6 +7,7 @@ type MutationParams = {
7
7
  studioId?: string;
8
8
  studioUserId?: string;
9
9
  deploymentId?: string;
10
+ embedUserId?: string;
10
11
  messages?: {
11
12
  role: ChatRole;
12
13
  message: string;
@@ -1 +1 @@
1
- import{jsx as e}from"react/jsx-runtime";import{createContext as i,useState as o,useEffect as s}from"react";import t from"./Addons/Document/Provider.js";import r from"./ResponseProvider.js";import n from"./DimensionProvider.js";const a=i({}),d=({children:i,userId:d="",studioUserId:c="",deploymentId:l="",styles:m,colors:p,limits:h={},misc:F={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0},translations:I,chatInput:u="",responsiveBy:y="viewport",loadFont:b=!0,forceMobile:f=!1,isEmbed:g=!1,onGenerateComplete:w})=>{const[P,j]=o(""),[v,x]=o(""),[S,k]=o(null),[C,O]=o(!1),[D,H]=o(!0),[B,L]=o(!0),[T,E]=o(!1);return s((()=>{O(!1)}),[null==m?void 0:m.font]),e(a.Provider,Object.assign({value:Object.assign({formId:P,chatId:v,userId:d,studioUserId:c,deploymentId:l,pickaxe:S,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},m),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},p),misc:F,translations:Object.assign({"new-chat":"New chat","see-history":"See history","see-input":"See input","hide-input":"Hide input",processing:"Processing...",uploading:"Uploading...",loading:"Loading...","powered-by-pickaxe":"Powered by Pickaxe","form-doc-placeholder":"Paste a website/video link or drag a file"},I),chatInput:u,responsiveBy:y,isFontLoaded:C,isNewChat:D,isShowIceBreaker:B,isShowHistory:T,loadFont:b,forceMobile:f,isEmbed:g,setIsFontLoaded:O,setFormId:j,setChatId:x,setPickaxe:k,setIsNewChat:H,setIsShowIceBreaker:L,setIsShowHistory:E},w&&{onGenerateComplete:w})},{children:e(r,Object.assign({limits:h},{children:e(n,{children:e(t,{children:i})})}))}))};export{a as PickaxeContext,d as PickaxeProvider};
1
+ import{jsx as e}from"react/jsx-runtime";import{createContext as s,useState as i,useEffect as o}from"react";import t from"./Addons/Document/Provider.js";import r from"./ResponseProvider.js";import n from"./DimensionProvider.js";const d=s({}),a=({children:s,userId:a="",studioUserId:c="",deploymentId:l="",embedUserId:m="",styles:p,colors:h,limits:F={},misc:I={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0},translations:u,chatInput:b="",responsiveBy:y="viewport",loadFont:f=!0,forceMobile:g=!1,isEmbed:w=!1,onGenerateComplete:P})=>{const[j,v]=i(""),[x,S]=i(""),[k,C]=i(null),[O,D]=i(!1),[H,U]=i(!0),[B,L]=i(!0),[T,E]=i(!1);return o((()=>{D(!1)}),[null==p?void 0:p.font]),e(d.Provider,Object.assign({value:Object.assign({formId:j,chatId:x,userId:a,studioUserId:c,deploymentId:l,embedUserId:m,pickaxe:k,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},p),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},h),misc:I,translations:Object.assign({"new-chat":"New chat","see-history":"See history","see-input":"See input","hide-input":"Hide input",processing:"Processing...",uploading:"Uploading...",loading:"Loading...","powered-by-pickaxe":"Powered by Pickaxe","form-doc-placeholder":"Paste a website/video link or drag a file"},u),chatInput:b,responsiveBy:y,isFontLoaded:O,isNewChat:H,isShowIceBreaker:B,isShowHistory:T,loadFont:f,forceMobile:g,isEmbed:w,setIsFontLoaded:D,setFormId:v,setChatId:S,setPickaxe:C,setIsNewChat:U,setIsShowIceBreaker:L,setIsShowHistory:E},P&&{onGenerateComplete:P})},{children:e(r,Object.assign({limits:F},{children:e(n,{children:e(t,{children:s})})}))}))};export{d as PickaxeContext,a as PickaxeProvider};
@@ -1 +1 @@
1
- import{__rest as e}from"../../../../_virtual/_tslib.js";import{jsxs as r,jsx as n}from"react/jsx-runtime";import{useState as i,useRef as t,useMemo as o,useEffect as s}from"react";import{usePickaxeMarkdownContext as l}from"./hooks/usePickaxeMarkdownContext.js";import d from"react-markdown";import c from"remark-gfm";import a from"remark-math";import h from"rehype-katex";import m from"rehype-raw";import p from"./Custom/A/index.js";import u from"./Custom/P/index.js";import g from"./Custom/Img/index.js";import f from"./Custom/Iframe/index.js";import b from"./Custom/Code/index.js";import x from"./Custom/common/LinkPreview.js";import k from"../../../../common/cn.js";const j=({className:j,style:w,value:v,recursion:C=!1,children:D,maxLines:y,multiLineBreaks:O,onExpandClick:$})=>{const{theme:N,accentColor:S,websiteMetadatas:B}=l(),[L,P]=i({width:0,height:0}),[E,M]=i(null),I=t(null),q=o((()=>{if(!v)return"";let e=v.trim();return e=e.replace(/<!--[\s\S]*?-->/g,""),e=e.replace(/\u200B/g,""),e=e.replace(/\\[\s\S]*?\\]/g,(e=>"$$"+e.substring(2,e.length-2)+"$$")).replace(/\\\(\s*[\s\S]*?\s*\\\)/g,(e=>"$"+e.substring(2,e.length-2)+"$")),O&&(e=e.replace(/```[\s\S]*?```|(\n(?=\n))/g,((e,r)=>r?"\n\n<br/>\n":e))),e||""}),[v,O]);s((()=>{if(!y)return void M(null);if(!I.current||!q||E)return;const e=I.current,r=parseInt(window.getComputedStyle(e).lineHeight,10),n=y*r;if(!(L.height>n))return;const i=Math.floor(L.width/8),t=Math.floor(i*y);M(q.slice(0,t)+'<span class="pxe-expand-btn">...</span>')}),[q,y,L,E]);const R={h1:({node:e,children:r})=>n("h1",{children:r}),h2:({node:e,children:r})=>n("h2",{children:r}),h3:({node:e,children:r})=>n("h3",{children:r}),h4:({node:e,children:r})=>n("h4",{children:r}),h5:({node:e,children:r})=>n("h5",{children:r}),p:u,a:p,ol:({node:e,children:r})=>n("ol",{children:r}),ul:({node:e,children:r})=>n("ul",{children:r}),li:({node:e,children:r})=>n("li",{children:r}),table:({children:e})=>n("div",Object.assign({className:"pxe-markdown-table"},{children:n("table",{children:e})})),th:({node:e,children:r})=>n("th",{children:r}),tr:({node:e,children:r})=>n("tr",Object.assign({style:{border:"dark"===N?"1px solid #30363D":"1px solid #D0D7DE"}},{children:r})),td:({node:e,children:r})=>n("td",{children:r}),code:b,blockquote:({node:e,children:r})=>n("blockquote",Object.assign({style:{borderLeft:"dark"===N?"4px solid #30363D":"4px solid #D0D7DE",color:"dark"===N?"#8B8B8B":"#656D76"}},{children:r})),img:g,iframe:f,hr:()=>n("hr",{style:{border:0,borderTop:"dark"===N?"1px solid #30363D":"1px solid #D0D7DE"}}),span:r=>{var{node:i,children:t}=r,o=e(r,["node","children"]);return"pxe-expand-btn"===o.className?n("span",Object.assign({},o,{style:Object.assign({display:"inline",fontWeight:500,color:S,marginLeft:".25rem",userSelect:"none"},$&&{cursor:"pointer"})},$&&{onClick:$},{children:t})):n("span",Object.assign({},o,{children:t}))},br:()=>n("br",{})};s((()=>{if(!I.current)return;const e=new ResizeObserver((e=>{for(const r of e){const{width:e,height:n}=r.contentRect;P({width:e,height:n})}}));return e.observe(I.current),()=>{e.disconnect()}}),[]);const T=E||q,W=!C&&B.length>0?"\n\n---":"";return r("div",Object.assign({className:"pxe-markdown",ref:I,style:Object.assign({position:"relative",overflowWrap:"break-word",display:"grid",gridTemplateColumns:"repeat(1, minmax(0, 1fr))",gap:".625rem"},w)},{children:[n(d,Object.assign({className:k(!C&&"pxe-prose",j),components:R,remarkPlugins:[c,a],rehypePlugins:[h,m]},{children:`${T}${W}`})),!C&&B.length>0&&n("div",Object.assign({className:"pxe-link-previews"},{children:B.map(((e,r)=>n(x,{data:e},r)))})),D]}))};export{j as PickaxeMarkdownRenderer};
1
+ import{__rest as e}from"../../../../_virtual/_tslib.js";import{jsxs as r,jsx as n}from"react/jsx-runtime";import{useState as i,useRef as t,useMemo as o,useEffect as s}from"react";import{usePickaxeMarkdownContext as l}from"./hooks/usePickaxeMarkdownContext.js";import d from"react-markdown";import c from"remark-gfm";import a from"remark-math";import h from"rehype-katex";import m from"rehype-raw";import p from"./Custom/A/index.js";import u from"./Custom/P/index.js";import g from"./Custom/Img/index.js";import f from"./Custom/Iframe/index.js";import b from"./Custom/Code/index.js";import x from"./Custom/common/LinkPreview.js";import k from"../../../../common/cn.js";const j=({className:j,style:w,value:D,recursion:v=!1,children:C,maxLines:y,multiLineBreaks:O,onExpandClick:$})=>{const{theme:N,accentColor:S,websiteMetadatas:B}=l(),[L,M]=i({width:0,height:0}),[P,E]=i(null),I=t(null),T=o((()=>{if(!D)return"";let e=D.trim();return e=e.replace(/<!--[\s\S]*?-->/g,""),e=e.replace(/\u200B/g,""),e=e.replace(/\\[\s\S]*?\\]/g,(e=>"$$"+e.substring(2,e.length-2)+"$$")).replace(/\\\(\s*[\s\S]*?\s*\\\)/g,(e=>"$$"+e.substring(2,e.length-2)+"$$")),O&&(e=e.replace(/```[\s\S]*?```|(\n(?=\n))/g,((e,r)=>r?"\n\n<br/>\n":e))),e||""}),[D,O]);s((()=>{if(!y)return void E(null);if(!I.current||!T||P)return;const e=I.current,r=parseInt(window.getComputedStyle(e).lineHeight,10),n=y*r;if(!(L.height>n))return;const i=Math.floor(L.width/8),t=Math.floor(i*y);E(T.slice(0,t)+'<span class="pxe-expand-btn">...</span>')}),[T,y,L,P]);const q={h1:({node:e,children:r})=>n("h1",{children:r}),h2:({node:e,children:r})=>n("h2",{children:r}),h3:({node:e,children:r})=>n("h3",{children:r}),h4:({node:e,children:r})=>n("h4",{children:r}),h5:({node:e,children:r})=>n("h5",{children:r}),p:u,a:p,ol:({node:e,children:r})=>n("ol",{children:r}),ul:({node:e,children:r})=>n("ul",{children:r}),li:({node:e,children:r})=>n("li",{children:r}),table:({children:e})=>n("div",Object.assign({className:"pxe-markdown-table"},{children:n("table",{children:e})})),th:({node:e,children:r})=>n("th",{children:r}),tr:({node:e,children:r})=>n("tr",Object.assign({style:{border:"dark"===N?"1px solid #30363D":"1px solid #D0D7DE"}},{children:r})),td:({node:e,children:r})=>n("td",{children:r}),code:b,blockquote:({node:e,children:r})=>n("blockquote",Object.assign({style:{borderLeft:"dark"===N?"4px solid #30363D":"4px solid #D0D7DE",color:"dark"===N?"#8B8B8B":"#656D76"}},{children:r})),img:g,iframe:f,hr:()=>n("hr",{style:{border:0,borderTop:"dark"===N?"1px solid #30363D":"1px solid #D0D7DE"}}),span:r=>{var{node:i,children:t}=r,o=e(r,["node","children"]);return"pxe-expand-btn"===o.className?n("span",Object.assign({},o,{style:Object.assign({display:"inline",fontWeight:500,color:S,marginLeft:".25rem",userSelect:"none"},$&&{cursor:"pointer"})},$&&{onClick:$},{children:t})):n("span",Object.assign({},o,{children:t}))},br:()=>n("br",{})};s((()=>{if(!I.current)return;const e=new ResizeObserver((e=>{for(const r of e){const{width:e,height:n}=r.contentRect;M({width:e,height:n})}}));return e.observe(I.current),()=>{e.disconnect()}}),[]);const R=P||T,W=!v&&B.length>0?"\n\n---":"";return r("div",Object.assign({className:"pxe-markdown",ref:I,style:Object.assign({position:"relative",overflowWrap:"break-word",display:"grid",gridTemplateColumns:"repeat(1, minmax(0, 1fr))",gap:".625rem"},w)},{children:[n(d,Object.assign({className:k(!v&&"pxe-prose",j),components:q,remarkPlugins:[c,[a,{singleDollarTextMath:!1}]],rehypePlugins:[h,m]},{children:`${R}${W}`})),!v&&B.length>0&&n("div",Object.assign({className:"pxe-link-previews"},{children:B.map(((e,r)=>n(x,{data:e},r)))})),C]}))};export{j as PickaxeMarkdownRenderer};
@@ -1 +1 @@
1
- import{__awaiter as t}from"../../_virtual/_tslib.js";import{useInfiniteQuery as o}from"@tanstack/react-query";import{usePickaxeContext as e}from"./usePickaxeContext.js";import i from"../../common/api/index.js";const r=({enabled:r=!0}={enabled:!0})=>{const{formId:d,pickaxe:a,studioUserId:s}=e();return o({queryKey:["form",d,"history"],queryFn:({pageParam:o=0})=>(({formId:o,place:e,studioId:r})=>t(void 0,void 0,void 0,(function*(){let t=`/pickaxe/history?formid=${o}&place=${e}`;r&&(t+=`&studioId=${r}`);const d=yield i.get(t),a=d.data;if(200!==d.status)throw new Error("[_getHistory] Failed to fetch history "+a);return{next:a.history.length<5?void 0:e+25,data:a.history}})))(Object.assign({formId:d,place:o},s&&(null==a?void 0:a.studioid)&&{studioId:a.studioid})),getNextPageParam:t=>t.next,enabled:r&&!!d})};export{r as useHistory};
1
+ import{__awaiter as e}from"../../_virtual/_tslib.js";import{useInfiniteQuery as t}from"@tanstack/react-query";import{usePickaxeContext as o}from"./usePickaxeContext.js";import r from"../../common/api/index.js";const d=({enabled:d=!0}={enabled:!0})=>{const{formId:i,pickaxe:s,studioUserId:a,embedUserId:n}=o(),m=t({queryKey:["form",i,"history"],queryFn:({pageParam:t=0})=>(({formId:t,place:o,studioId:d,embedUserId:i})=>e(void 0,void 0,void 0,(function*(){let e=`/pickaxe/history?formid=${t}&place=${o}`;d&&(e+=`&studioId=${d}`),i&&(e+=`&embedUserId=${i}`);const s=yield r.get(e),a=s.data;if(200!==s.status)throw new Error("[_getHistory] Failed to fetch history "+a);return{next:a.history.length<5?void 0:o+25,data:a.history}})))(Object.assign(Object.assign({formId:i,place:t},a&&(null==s?void 0:s.studioid)&&{studioId:s.studioid}),n&&{embedUserId:n})),getNextPageParam:e=>e.next,enabled:d&&!!i});return m};export{d as useHistory};
@@ -1 +1 @@
1
- import{__awaiter as t}from"../../_virtual/_tslib.js";import{useMutation as e}from"@tanstack/react-query";import s from"../../common/api/index.js";const i=()=>e({mutationFn:e=>(({formId:e,responseId:i,documentId:o,studioUserId:a,deploymentId:n,pickaxe:r,value:d,valueObj:c})=>t(void 0,void 0,void 0,(function*(){const t=yield s.post("/pickaxe/submit",Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({origin:"pickaxe",formId:e},i&&{responseId:i}),o&&{documentId:o}),a&&{studioUserId:a}),n&&{deploymentId:n}),r&&{pickaxe:r}),d&&{value:d}),c&&{valueObj:c})),m=t.data;if(200!==t.status)throw new Error("[_getHistory] Failed to fetch history "+m);return m})))(e)});export{i as useSubmit};
1
+ import{__awaiter as e}from"../../_virtual/_tslib.js";import{useMutation as t}from"@tanstack/react-query";import s from"../../common/api/index.js";const i=()=>t({mutationFn:t=>(({formId:t,responseId:i,documentId:o,studioUserId:d,deploymentId:r,embedUserId:a,pickaxe:n,value:c,valueObj:m})=>e(void 0,void 0,void 0,(function*(){const e=yield s.post("/pickaxe/submit",Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({origin:"pickaxe",formId:t},i&&{responseId:i}),o&&{documentId:o}),d&&{studioUserId:d}),r&&{deploymentId:r}),a&&{embedUserId:a}),n&&{pickaxe:n}),c&&{value:c}),m&&{valueObj:m})),u=e.data;if(200!==e.status)throw new Error("[_getHistory] Failed to fetch history "+u);return u})))(t)});export{i as useSubmit};
@@ -39,6 +39,7 @@ type PickaxeContextType = {
39
39
  userId: string;
40
40
  studioUserId: string;
41
41
  deploymentId: string;
42
+ embedUserId: string;
42
43
  pickaxe: Pickaxe | null;
43
44
  styles: PickaxeProviderStyles;
44
45
  colors: PickaxeProviderColors;
@@ -67,6 +68,7 @@ export interface IPickaxeProviderProps {
67
68
  userId?: string;
68
69
  studioUserId?: string;
69
70
  deploymentId?: string;
71
+ embedUserId?: string;
70
72
  styles?: Partial<PickaxeProviderStyles>;
71
73
  colors?: Partial<PickaxeProviderColors>;
72
74
  limits?: Record<string, PickaxeLimitData>;
@@ -80,5 +82,5 @@ export interface IPickaxeProviderProps {
80
82
  onGenerateComplete?: (responseId: string) => void;
81
83
  }
82
84
  export declare const PickaxeContext: import("react").Context<PickaxeContextType>;
83
- export declare const PickaxeProvider: ({ children, userId, studioUserId, deploymentId, styles, colors, limits, misc, translations, chatInput, responsiveBy, loadFont, forceMobile, isEmbed, onGenerateComplete, }: IPickaxeProviderProps) => import("react/jsx-runtime").JSX.Element;
85
+ export declare const PickaxeProvider: ({ children, userId, studioUserId, deploymentId, embedUserId, styles, colors, limits, misc, translations, chatInput, responsiveBy, loadFont, forceMobile, isEmbed, onGenerateComplete, }: IPickaxeProviderProps) => import("react/jsx-runtime").JSX.Element;
84
86
  export {};
@@ -4,6 +4,7 @@ export declare const usePickaxeContext: () => {
4
4
  userId: string;
5
5
  studioUserId: string;
6
6
  deploymentId: string;
7
+ embedUserId: string;
7
8
  pickaxe: import("../../types/pickaxe").Pickaxe | null;
8
9
  styles: import("../../components/Pickaxe/Provider").PickaxeProviderStyles;
9
10
  colors: import("../../components/Pickaxe/Provider").PickaxeProviderColors;
@@ -5,6 +5,7 @@ type MutationParams = {
5
5
  documentId?: string;
6
6
  studioUserId?: string;
7
7
  deploymentId?: string;
8
+ embedUserId?: string;
8
9
  pickaxe?: Partial<Pickaxe>;
9
10
  value?: string;
10
11
  valueObj?: Record<string, string>;
@@ -7,6 +7,7 @@ type MutationParams = {
7
7
  studioId?: string;
8
8
  studioUserId?: string;
9
9
  deploymentId?: string;
10
+ embedUserId?: string;
10
11
  messages?: {
11
12
  role: ChatRole;
12
13
  message: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pickaxeproject/react",
3
- "version": "1.2.8",
3
+ "version": "1.3.0",
4
4
  "description": "Client utility library for Pickaxe",
5
5
  "repository": {
6
6
  "type": "git",