sage-nexus-ui 1.13.9 → 1.13.11
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/_virtual/index.mjs +1 -1
- package/dist/_virtual/index2.mjs +1 -1
- package/dist/components/ActionBar.mjs +1 -1
- package/dist/components/NexusChat/ChatComponents/MessageList.mjs +1 -1
- package/dist/components/NexusChat/ChatHistory.mjs +1 -1
- package/dist/components/NexusChat/ChatHistoryHeader.mjs +1 -1
- package/dist/components/NexusChat/FABButton.mjs +1 -1
- package/dist/components/NexusChat/NexusChatWidget.mjs +1 -1
- package/dist/generated/version.mjs +1 -1
- package/dist/index.d.ts +6 -2
- package/dist/node_modules/hast-util-to-jsx-runtime/lib/index.mjs +1 -1
- package/dist/node_modules/unified/lib/index.mjs +1 -1
- package/package.json +1 -1
package/dist/_virtual/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getDefaultExportFromCjs as e}from"./_commonjsHelpers.mjs";import{__require as
|
|
1
|
+
import{getDefaultExportFromCjs as e}from"./_commonjsHelpers.mjs";import{__require as m}from"../node_modules/extend/index.mjs";var o=e(m());export{o as default};
|
package/dist/_virtual/index2.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getDefaultExportFromCjs as e}from"./_commonjsHelpers.mjs";import{__require as
|
|
1
|
+
import{getDefaultExportFromCjs as e}from"./_commonjsHelpers.mjs";import{__require as o}from"../node_modules/style-to-js/cjs/index.mjs";var s=e(o());export{s as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,Fragment as n,jsx as t}from"react/jsx-runtime";import{useTheme as i,useMediaQuery as r,AppBar as l,Toolbar as o
|
|
1
|
+
import{jsxs as e,Fragment as n,jsx as t}from"react/jsx-runtime";import{useTheme as i,useMediaQuery as r,AppBar as l,Toolbar as o}from"@mui/material";import{Box as s}from"./Box.mjs";import{Stack as c}from"./Stack.mjs";import{NexusHome as d}from"./NexusHome.mjs";import{ThemeToggle as x}from"./ThemeToggle.mjs";import a from"./NexusLogo.mjs";import{ActionBarTitle as f}from"./Typography.mjs";import{useRef as h,useState as u,useEffect as m}from"react";const p=({title:p,extraLeft:g,extraRight:w,homeHref:y,showHome:v=!0})=>{const I=i(),b=r(I.breakpoints.up("lg")),j=h(null),[C,B]=u(49),R=h(null),k=h(null),z=h(null),E=h(null),M=h(null),A=h(null),[L,S]=u(null),[H,T]=u(null);return m(()=>{const e=j.current;if(!e)return;const n=()=>B(e.getBoundingClientRect().height);n();const t=window.ResizeObserver;if(!t)return;const i=new t(n);return i.observe(e),()=>i.disconnect()},[]),m(()=>{if(!b)return S(null),void T(null);function e(){const e=k.current,n=z.current,t=R.current,i=E.current,r=M.current,l=A.current;if(!e||!n||!t)return;const o=e.getBoundingClientRect(),s=n.getBoundingClientRect(),c=t.getBoundingClientRect();if(i){const e=i.getBoundingClientRect().width||0,n=(o.right+s.left)/2,t=o.right+e/2+8,r=s.left-e/2-8,l=Math.min(Math.max(n,t),r);S(l-c.left)}else S(null);if(r&&l){const e=r.getBoundingClientRect().width||0,n=l.getBoundingClientRect(),t=(s.right+n.left)/2,i=s.right+e/2+8,o=n.left-e/2-8,d=Math.min(Math.max(t,i),o);T(d-c.left)}else T(null)}e(),window.addEventListener("resize",e);let n=null;const t=window.ResizeObserver;return t&&(n=new t(e),R.current&&n.observe(R.current)),()=>{window.removeEventListener("resize",e),n&&n.disconnect()}},[b,g,w]),e(n,{children:[t(l,{position:"sticky",component:"header",color:"inherit",elevation:0,ref:j,sx:{zIndex:{xs:I.zIndex.appBar,sm:I.zIndex.drawer+1},[I.breakpoints.up("sm")]:{position:"fixed"}},children:e(o,{variant:"dense",sx:{display:"flex",flexDirection:"column",alignItems:"stretch",py:{xs:.5,lg:0}},children:[e(c,{sx:{display:{xs:"flex",sm:"none"},width:"100%"},spacing:.25,children:[e(c,{direction:"row",sx:{justifyContent:"flex-end","& .MuiIconButton-root":{padding:"4px"},"& svg":{fontSize:"1.1rem"}},children:[v&&t(d,{href:y}),t(x,{})]}),t(f,{sx:{textAlign:"center",fontSize:"1.1rem"},children:p})]}),(g||w)&&e(c,{direction:"row",sx:{display:{xs:"flex",sm:"none"},justifyContent:"center",alignItems:"center",gap:1,width:"100%",mt:1},children:[g,w]}),e(c,{sx:{display:{xs:"none",sm:"flex",lg:"none"},width:"100%"},spacing:.5,children:[e(c,{direction:"row",sx:{alignItems:"center",width:"100%"},children:[t(s,{sx:{flex:1,display:"flex",alignItems:"center"},children:t(s,{sx:{height:"38px",pt:.5},children:t(a,{})})}),t(f,{children:p}),e(c,{direction:"row",sx:{flex:1,justifyContent:"flex-end",alignItems:"center",gap:1},children:[v&&t(d,{href:y}),t(x,{})]})]}),(g||w)&&e(c,{direction:"row",sx:{justifyContent:"center",alignItems:"center",gap:2,pb:.5},children:[g&&t(s,{children:g}),w&&t(s,{children:w})]})]}),t(s,{sx:{display:{xs:"none",lg:"block"},width:"100%"},children:e(s,{sx:{display:"flex",flexDirection:"row",alignItems:"center",width:"100%",position:"relative"},ref:R,children:[t(s,{sx:{display:"flex",alignItems:"center",flex:1,justifyContent:"flex-start"},children:t(s,{sx:{height:"38px",pt:.5},ref:k,children:t(a,{})})}),t(s,{sx:{display:"flex",justifyContent:"center",alignItems:"center",position:"absolute",left:0,right:0,pointerEvents:"none"},children:t(s,{sx:{pointerEvents:"auto",textAlign:"center"},children:t(s,{ref:z,children:t(f,{children:p})})})}),t(s,{sx:{display:g?"block":"none",position:"absolute",left:null!=L?`${L}px`:void 0,transform:"translateX(-50%)",pointerEvents:"auto",textAlign:"center"},children:t(s,{ref:E,children:g})}),t(s,{sx:{display:w?"block":"none",position:"absolute",left:null!=H?`${H}px`:void 0,transform:"translateX(-50%)",pointerEvents:"auto",textAlign:"center"},children:t(s,{ref:M,children:w})}),t(s,{sx:{display:"flex",alignItems:"center",flex:1,justifyContent:"flex-end"},children:e(s,{sx:{flex:"0 0 auto",display:"flex",alignItems:"center",gap:1},ref:A,children:[v&&t(d,{href:y}),t(x,{})]})})]})})]})}),t(s,{sx:{display:{xs:"none",sm:"block"},height:`${C}px`,flexShrink:0}})]})};export{p as ActionBar};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as t,jsx as
|
|
1
|
+
import{jsxs as t,jsx as r}from"react/jsx-runtime";import{useRef as e,useEffect as o}from"react";import{Box as n}from"../../Box.mjs";import i from"./MessageBubble.mjs";import l from"./StreamingBubble.mjs";import c from"./TypingIndicator.mjs";import{latestTraceLabel as s}from"./latestTraceLabel.mjs";const a=({messages:a,isTyping:m,streamingText:h,liveTraceEvents:g,highlightQuery:u,onAbort:p,avatarIcon:f,showActivity:v=!1})=>{const b=e(null),x=e(null),y=e(!1),I=e(a.length);o(()=>{const t=a[a.length-1];a.length>I.current&&"user"===t?.role&&(y.current=!1,b.current?.scrollIntoView({behavior:"smooth"})),I.current=a.length},[a]),o(()=>{y.current||b.current?.scrollIntoView({behavior:"smooth"})},[m,h]);const d=(h||"").trim().length>0,j=m&&d,w=m&&!j;return t(n,{ref:x,onScroll:()=>{y.current=!(()=>{const t=x.current;return!t||t.scrollHeight-t.scrollTop-t.clientHeight<80})()},sx:{flex:1,minHeight:0,overflowY:"auto",display:"flex",flexDirection:"column",gap:1.5,px:2,py:1.5},children:[a.filter(t=>"user"===t.role||t.content).map(t=>r(i,{message:t,highlightQuery:u,avatarIcon:f,showActivity:v},t.id)),j&&r(l,{text:h||"",traceEvents:g||[],highlightQuery:u,avatarIcon:f,onAbort:p,showActivity:v}),w&&r(c,{avatarIcon:f,traceLabel:g&&g.length>0?s(g):void 0}),r(n,{ref:b})]})};export{a as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{jsx as e,jsxs as o}from"react/jsx-runtime";import{useState as t,useCallback as n}from"react";import r from"@mui/icons-material/ChevronRight";import{Caption as i}from"../Typography.mjs";import{Box as s}from"../Box.mjs";import{Stack as a}from"../Stack.mjs";import{IconButton as l}from"../IconButton.mjs";import{ChatHistoryHeader as c}from"./ChatHistoryHeader.mjs";import{ChatHistoryButtonBase as h}from"./ChatHistoryButtonBase.mjs";const m=({conversations:m,activeConversationId:d,onSelectConversation:p,onDeleteConversation:C,onNewConversation:f,onClose:x,onSearchChange:v,title:g="Chat history",emptyText:y="No conversations yet",newChatTitle:u="New chat",deleteConversationTitle:w="Delete conversation",searchPlaceholder:j="Search chat histories",searchDebounceMs:S=300,width:T=288,sx:b,formatMessageCount:D=e=>`${e} messages`,isCollapsed:k=!1,onToggleCollapse:A,collapsedWidth:B=40})=>{const[H,M]=t(""),N=n(e=>{M(e),v?.(e)},[v]);return e(s,{sx:{width:k?B:T,minWidth:k?B:0,flexShrink:0,borderRight:1,borderColor:"divider",overflow:"hidden",transition:"width 0.2s ease, min-width 0.2s ease",display:"flex",flexDirection:"column"},children:k?e(s,{sx:{display:"flex",justifyContent:"center",alignItems:"flex-start",pt:1},children:e(l,{onClick:A,title:"Expand history",ariaLabel:"expand-history",children:e(r,{sx:{fontSize:16}})})}):o(a,{direction:"column",sx:[{flex:1,minHeight:0},...Array.isArray(b)?b:b?[b]:[]],children:[e(c,{title:g,newChatTitle:u,onNewConversation:f,onClose:x,onToggleCollapse:A,onSearchChange:N,searchPlaceholder:j,searchDebounceMs:S}),e(s,{component:"nav","aria-label":g,sx:{flex:1,overflowY:"auto",p:1},children:0===m.length?e(i,{sx:{display:"block",textAlign:"center",py:4},children:y}):m.map(o=>{const t=o.id===d;return e(h,{conversation:o,isActive:t,highlightQuery:H,onSelectConversation:p,onDeleteConversation:C,deleteConversationTitle:w,formatMessageCount:D},o.id)})})]})})};export{m as ChatHistory};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as r}from"react/jsx-runtime";import i from"@mui/icons-material/Add";import
|
|
1
|
+
import{jsxs as e,jsx as r}from"react/jsx-runtime";import i from"@mui/icons-material/Add";import o from"@mui/icons-material/ChevronLeft";import t from"@mui/icons-material/Clear";import a from"@mui/icons-material/Search";import{InputAdornment as l}from"@mui/material";import{useState as n,useEffect as s}from"react";import{Box as c}from"../Box.mjs";import{H3 as m}from"../Typography.mjs";import{IconButton as h}from"../IconButton.mjs";import{Stack as d}from"../Stack.mjs";import{TextField as p}from"../TextField.mjs";const f=({title:f,newChatTitle:u,onNewConversation:C,onClose:x,onToggleCollapse:b,onSearchChange:g,searchPlaceholder:S="Search chat histories",searchDebounceMs:w=300})=>{const[y,j]=n("");return s(()=>{if(!g)return;const e=window.setTimeout(()=>{g(y)},w);return()=>window.clearTimeout(e)},[g,w,y]),e(d,{direction:"column",spacing:1,sx:{px:2,py:2,borderBottom:1,borderColor:"divider"},children:[e(d,{direction:"row",spacing:2,sx:{alignItems:"center",justifyContent:"space-between"},children:[r(m,{children:f}),e(d,{direction:"row",sx:{alignItems:"center"},children:[r(h,{onClick:C,title:u,ariaLabel:u,disabled:!C,children:r(i,{sx:{fontSize:16}})}),b&&r(h,{onClick:b,title:"Collapse history",ariaLabel:"collapse-history",children:r(o,{sx:{fontSize:16}})}),x&&r(h,{onClick:x,title:"Close history",ariaLabel:"close-history",children:r(o,{sx:{fontSize:16}})})]})]}),e(c,{sx:{display:"flex",alignItems:"center",gap:.75},children:[r(p,{fullWidth:!0,size:"small",value:y,onChange:e=>j(e.target.value),placeholder:S,slotProps:{htmlInput:{"aria-label":"Search chat histories"},input:{startAdornment:r(l,{position:"start",children:r(a,{sx:{fontSize:16,color:"text.disabled"}})})}}}),r(h,{title:"Clear search",ariaLabel:"clear-search",onClick:()=>j(""),disabled:!y,children:r(t,{sx:{fontSize:14}})})]})]})};export{f as ChatHistoryHeader};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as t}from"react/jsx-runtime";import{Box as o}from"../Box.mjs";import{AiButton as
|
|
1
|
+
import{jsx as t}from"react/jsx-runtime";import{Box as o}from"../Box.mjs";import{AiButton as m}from"../AiButton.mjs";const e=({onOpen:e,fabLabel:r,placement:i="bottom-right"})=>t(o,{sx:{position:"fixed",bottom:{xs:16,sm:24},..."bottom-left"===i?{left:{xs:16,sm:24}}:{right:{xs:16,sm:24}},zIndex:t=>t.zIndex.appBar+50},children:t(m,{onClick:e,label:r,"aria-label":r})});export{e as FABButton};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,Fragment as t,jsx as
|
|
1
|
+
import{jsxs as e,Fragment as t,jsx as s}from"react/jsx-runtime";import{FABButton as o}from"./FABButton.mjs";import{GlassPaper as i}from"../GlassPaper.mjs";import a from"./WidgetParts/WidgetBody.mjs";import n from"./WidgetParts/WidgetHeader.mjs";import r from"./WidgetParts/WidgetInput.mjs";const m=["Summarise my latest data","What changed this week?","Show me the key trends","Help me understand my metrics"];function l({title:l="Ask Nexus",subtitle:d="Ready to help",fabLabel:p="Ask Nexus",avatarIcon:c,placeholder:x,emptyTitle:u="Ask Nexus",emptyDescription:g="Ask me anything about your data and I'll help you find answers.",dataSources:h,suggestedPrompts:f=m,isOpen:y,isTyping:b,messages:v,streamingText:T,liveTraceEvents:w,showActivity:A=!1,onOpen:P,onClose:S,onSend:I,onAbort:W,onExpandToFullPage:j,hideFab:k=!1,placement:B="bottom-right"}){if(k)return null;return e(t,{children:[y&&e(i,{elevation:8,sx:{boxShadow:e=>e.shadows[2],borderRadius:3,position:"fixed",bottom:{xs:16,sm:24},..."bottom-left"===B?{left:{xs:16,sm:24}}:{right:{xs:16,sm:24}},zIndex:e=>e.zIndex.appBar+50,display:"flex",flexDirection:"column",width:{xs:"calc(100vw - 32px)",sm:380},maxHeight:{xs:"min(560px, calc(100dvh - 88px))",sm:"min(520px, calc(100dvh - 104px))"},overflow:"hidden",p:0,"& > div":{display:"flex",flexDirection:"column",flex:1,minHeight:0}},children:[s(n,{title:l,subtitle:d,onExpandToFullPage:j,onClose:S,avatarIcon:c}),s(a,{avatarIcon:c,isTyping:b,liveTraceEvents:w,messages:v,onAbort:W,showActivity:A,streamingText:T,emptyTitle:u,emptyDescription:g,dataSources:h,suggestedPrompts:f,onSend:I}),s(r,{placeholder:x,isTyping:b,onSend:I})]}),!y&&s(o,{onOpen:P,fabLabel:p,placement:B})]})}export{l as NexusChatWidget};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const o="1.13.
|
|
1
|
+
const o="1.13.11";export{o as SAGE_NEXUS_UI_VERSION};
|
package/dist/index.d.ts
CHANGED
|
@@ -172,6 +172,9 @@ interface ChatHistoryProps {
|
|
|
172
172
|
width?: number | string;
|
|
173
173
|
sx?: BoxProps["sx"];
|
|
174
174
|
formatMessageCount?: (count: number) => string;
|
|
175
|
+
isCollapsed?: boolean;
|
|
176
|
+
onToggleCollapse?: () => void;
|
|
177
|
+
collapsedWidth?: number;
|
|
175
178
|
}
|
|
176
179
|
|
|
177
180
|
interface NexusChatDialogProps {
|
|
@@ -252,18 +255,19 @@ interface ChatInputProps {
|
|
|
252
255
|
}
|
|
253
256
|
declare const ChatInput: ({ onSend, disabled, placeholder, maxRows, sendButtonTitle, }: ChatInputProps) => react_jsx_runtime.JSX.Element;
|
|
254
257
|
|
|
255
|
-
declare const ChatHistory: ({ conversations, activeConversationId, onSelectConversation, onDeleteConversation, onNewConversation, onClose, onSearchChange, title, emptyText, newChatTitle, deleteConversationTitle, searchPlaceholder, searchDebounceMs, width, sx, formatMessageCount, }: ChatHistoryProps) => react_jsx_runtime.JSX.Element;
|
|
258
|
+
declare const ChatHistory: ({ conversations, activeConversationId, onSelectConversation, onDeleteConversation, onNewConversation, onClose, onSearchChange, title, emptyText, newChatTitle, deleteConversationTitle, searchPlaceholder, searchDebounceMs, width, sx, formatMessageCount, isCollapsed, onToggleCollapse, collapsedWidth, }: ChatHistoryProps) => react_jsx_runtime.JSX.Element;
|
|
256
259
|
|
|
257
260
|
interface ChatHistoryHeaderProps {
|
|
258
261
|
title: string;
|
|
259
262
|
newChatTitle: string;
|
|
260
263
|
onNewConversation?: () => void;
|
|
261
264
|
onClose?: () => void;
|
|
265
|
+
onToggleCollapse?: () => void;
|
|
262
266
|
onSearchChange?: (query: string) => void;
|
|
263
267
|
searchPlaceholder?: string;
|
|
264
268
|
searchDebounceMs?: number;
|
|
265
269
|
}
|
|
266
|
-
declare const ChatHistoryHeader: ({ title, newChatTitle, onNewConversation, onClose, onSearchChange, searchPlaceholder, searchDebounceMs, }: ChatHistoryHeaderProps) => react_jsx_runtime.JSX.Element;
|
|
270
|
+
declare const ChatHistoryHeader: ({ title, newChatTitle, onNewConversation, onClose, onToggleCollapse, onSearchChange, searchPlaceholder, searchDebounceMs, }: ChatHistoryHeaderProps) => react_jsx_runtime.JSX.Element;
|
|
267
271
|
|
|
268
272
|
interface ChatHistoryButtonBaseProps {
|
|
269
273
|
conversation: ChatHistoryConversation;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{stringify as e}from"../../comma-separated-tokens/index.mjs";import{ok as t}from"../../devlop/lib/default.mjs";import{svg as n,html as r}from"../../property-information/index.mjs";import{stringify as o}from"../../space-separated-tokens/index.mjs";import s from"../../../_virtual/
|
|
1
|
+
import{stringify as e}from"../../comma-separated-tokens/index.mjs";import{ok as t}from"../../devlop/lib/default.mjs";import{svg as n,html as r}from"../../property-information/index.mjs";import{stringify as o}from"../../space-separated-tokens/index.mjs";import s from"../../../_virtual/index2.mjs";import{whitespace as a}from"../../hast-util-whitespace/lib/index.mjs";import{name as i}from"../../estree-util-is-identifier-name/lib/index.mjs";import{VFileMessage as l}from"../../vfile-message/lib/index.mjs";import{find as p}from"../../property-information/lib/find.mjs";import{hastToReact as c}from"../../property-information/lib/hast-to-react.mjs";import{pointStart as u}from"../../unist-util-position/lib/index.mjs";const m={}.hasOwnProperty,f=new Map,d=/[A-Z]/g,y=new Set(["table","tbody","thead","tfoot","tr"]),x=new Set(["td","th"]),v="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function h(e,t){if(!t||void 0===t.Fragment)throw new TypeError("Expected `Fragment` in options");const o=t.filePath||void 0;let s;if(t.development){if("function"!=typeof t.jsxDEV)throw new TypeError("Expected `jsxDEV` in options when `development: true`");s=function(e,t){return n;function n(n,r,o,s){const a=Array.isArray(o.children),i=u(n);return t(r,o,s,a,{columnNumber:i?i.column-1:void 0,fileName:e,lineNumber:i?i.line:void 0},void 0)}}(o,t.jsxDEV)}else{if("function"!=typeof t.jsx)throw new TypeError("Expected `jsx` in production options");if("function"!=typeof t.jsxs)throw new TypeError("Expected `jsxs` in production options");s=function(e,t,n){return r;function r(e,r,o,s){const a=Array.isArray(o.children)?n:t;return s?a(r,o,s):a(r,o)}}(0,t.jsx,t.jsxs)}const a={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:s,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:o,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:!1!==t.passKeys,passNode:t.passNode||!1,schema:"svg"===t.space?n:r,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:!1!==t.tableCellAlignToStyle},i=g(a,e,void 0);return i&&"string"!=typeof i?i:a.create(e,a.Fragment,{children:i||void 0},void 0)}function g(e,r,o){return"element"===r.type?function(e,t,r){const o=e.schema;let s=o;"svg"===t.tagName.toLowerCase()&&"html"===o.space&&(s=n,e.schema=s);e.ancestors.push(t);const i=N(e,t.tagName,!1),l=function(e,t){const n={};let r,o;for(o in t.properties)if("children"!==o&&m.call(t.properties,o)){const s=w(e,o,t.properties[o]);if(s){const[o,a]=s;e.tableCellAlignToStyle&&"align"===o&&"string"==typeof a&&x.has(t.tagName)?r=a:n[o]=a}}if(r){(n.style||(n.style={}))["css"===e.stylePropertyNameCase?"text-align":"textAlign"]=r}return n}(e,t);let p=j(e,t);y.has(t.tagName)&&(p=p.filter(function(e){return"string"!=typeof e||!a(e)}));return b(e,l,i,t),E(l,p),e.ancestors.pop(),e.schema=o,e.create(t,i,l,r)}(e,r,o):"mdxFlowExpression"===r.type||"mdxTextExpression"===r.type?function(e,n){if(n.data&&n.data.estree&&e.evaluater){const r=n.data.estree.body[0];return t("ExpressionStatement"===r.type),e.evaluater.evaluateExpression(r.expression)}A(e,n.position)}(e,r):"mdxJsxFlowElement"===r.type||"mdxJsxTextElement"===r.type?function(e,r,o){const s=e.schema;let a=s;"svg"===r.name&&"html"===s.space&&(a=n,e.schema=a);e.ancestors.push(r);const i=null===r.name?e.Fragment:N(e,r.name,!0),l=function(e,n){const r={};for(const o of n.attributes)if("mdxJsxExpressionAttribute"===o.type)if(o.data&&o.data.estree&&e.evaluater){const n=o.data.estree.body[0];t("ExpressionStatement"===n.type);const s=n.expression;t("ObjectExpression"===s.type);const a=s.properties[0];t("SpreadElement"===a.type),Object.assign(r,e.evaluater.evaluateExpression(a.argument))}else A(e,n.position);else{const s=o.name;let a;if(o.value&&"object"==typeof o.value)if(o.value.data&&o.value.data.estree&&e.evaluater){const n=o.value.data.estree.body[0];t("ExpressionStatement"===n.type),a=e.evaluater.evaluateExpression(n.expression)}else A(e,n.position);else a=null===o.value||o.value;r[s]=a}return r}(e,r),p=j(e,r);return b(e,l,i,r),E(l,p),e.ancestors.pop(),e.schema=s,e.create(r,i,l,o)}(e,r,o):"mdxjsEsm"===r.type?function(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);A(e,t.position)}(e,r):"root"===r.type?function(e,t,n){const r={};return E(r,j(e,t)),e.create(t,e.Fragment,r,n)}(e,r,o):"text"===r.type?function(e,t){return t.value}(0,r):void 0}function b(e,t,n,r){"string"!=typeof n&&n!==e.Fragment&&e.passNode&&(t.node=r)}function E(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function j(e,t){const n=[];let r=-1;const o=e.passKeys?new Map:f;for(;++r<t.children.length;){const s=t.children[r];let a;if(e.passKeys){const e="element"===s.type?s.tagName:"mdxJsxFlowElement"===s.type||"mdxJsxTextElement"===s.type?s.name:void 0;if(e){const t=o.get(e)||0;a=e+"-"+t,o.set(e,t+1)}}const i=g(e,s,a);void 0!==i&&n.push(i)}return n}function w(t,n,r){const a=p(t.schema,n);if(!(null==r||"number"==typeof r&&Number.isNaN(r))){if(Array.isArray(r)&&(r=a.commaSeparated?e(r):o(r)),"style"===a.property){let e="object"==typeof r?r:function(e,t){try{return s(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};const n=t,r=new l("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw r.file=e.filePath||void 0,r.url=v+"#cannot-parse-style-attribute",r}}(t,String(r));return"css"===t.stylePropertyNameCase&&(e=function(e){const t={};let n;for(n in e)m.call(e,n)&&(t[C(n)]=e[n]);return t}(e)),["style",e]}return["react"===t.elementAttributeNameCase&&a.space?c[a.property]||a.property:a.attribute,r]}}function N(e,t,n){let r;if(n)if(t.includes(".")){const e=t.split(".");let n,o=-1;for(;++o<e.length;){const t=i(e[o])?{type:"Identifier",name:e[o]}:{type:"Literal",value:e[o]};n=n?{type:"MemberExpression",object:n,property:t,computed:Boolean(o&&"Literal"===t.type),optional:!1}:t}r=n}else r=i(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};else r={type:"Literal",value:t};if("Literal"===r.type){const t=r.value;return m.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);A(e)}function A(e,t){const n=new l("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=v+"#cannot-handle-mdx-estrees-without-createevaluater",n}function C(e){let t=e.replace(d,S);return"ms-"===t.slice(0,3)&&(t="-"+t),t}function S(e){return"-"+e.toLowerCase()}export{h as toJsxRuntime};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{bail as e}from"../../bail/index.mjs";import t from"../../../_virtual/
|
|
1
|
+
import{bail as e}from"../../bail/index.mjs";import t from"../../../_virtual/index.mjs";import s from"../../is-plain-obj/index.mjs";import{CallableInstance as r}from"./callable-instance.mjs";import{trough as n}from"../../trough/lib/index.mjs";import{VFile as i}from"../../vfile/lib/index.mjs";const o={}.hasOwnProperty;class c extends r{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=n()}copy(){const e=new c;let s=-1;for(;++s<this.attachers.length;){const t=this.attachers[s];e.use(...t)}return e.data(t(!0,{},this.namespace)),e}data(e,t){return"string"==typeof e?2===arguments.length?(p("data",this.frozen),this.namespace[e]=t,this):o.call(this.namespace,e)&&this.namespace[e]||void 0:e?(p("data",this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;const e=this;for(;++this.freezeIndex<this.attachers.length;){const[t,...s]=this.attachers[this.freezeIndex];if(!1===s[0])continue;!0===s[0]&&(s[0]=void 0);const r=t.call(e,...s);"function"==typeof r&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(e){this.freeze();const t=m(e),s=this.parser||this.Parser;return f("parse",s),s(String(t),t)}process(e,t){const s=this;return this.freeze(),f("process",this.parser||this.Parser),h("process",this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,n){const i=m(e),o=s.parse(i);function c(e,s){e||!s?n(e):r?r(s):t(void 0,s)}s.run(o,i,function(e,t,r){if(e||!t||!r)return c(e);const n=t,i=s.stringify(n,r);var o;"string"==typeof(o=i)||function(e){return Boolean(e&&"object"==typeof e&&"byteLength"in e&&"byteOffset"in e)}(o)?r.value=i:r.result=i,c(e,r)})}}processSync(t){let s,r=!1;return this.freeze(),f("processSync",this.parser||this.Parser),h("processSync",this.compiler||this.Compiler),this.process(t,function(t,n){r=!0,e(t),s=n}),l("processSync","process",r),s}run(e,t,s){u(e),this.freeze();const r=this.transformers;return s||"function"!=typeof t||(s=t,t=void 0),s?n(void 0,s):new Promise(n);function n(n,i){const o=m(t);r.run(e,o,function(t,r,o){const c=r||e;t?i(t):n?n(c):s(void 0,c,o)})}}runSync(t,s){let r,n=!1;return this.run(t,s,function(t,s){e(t),r=s,n=!0}),l("runSync","run",n),r}stringify(e,t){this.freeze();const s=m(t),r=this.compiler||this.Compiler;return h("stringify",r),u(e),r(e,s)}use(e,...r){const n=this.attachers,i=this.namespace;if(p("use",this.frozen),null==e);else if("function"==typeof e)f(e,r);else{if("object"!=typeof e)throw new TypeError("Expected usable value, not `"+e+"`");Array.isArray(e)?a(e):c(e)}return this;function o(e){if("function"==typeof e)f(e,[]);else{if("object"!=typeof e)throw new TypeError("Expected usable value, not `"+e+"`");if(Array.isArray(e)){const[t,...s]=e;f(t,s)}else c(e)}}function c(e){if(!("plugins"in e)&&!("settings"in e))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");a(e.plugins),e.settings&&(i.settings=t(!0,i.settings,e.settings))}function a(e){let t=-1;if(null==e);else{if(!Array.isArray(e))throw new TypeError("Expected a list of plugins, not `"+e+"`");for(;++t<e.length;){o(e[t])}}}function f(e,r){let i=-1,o=-1;for(;++i<n.length;)if(n[i][0]===e){o=i;break}if(-1===o)n.push([e,...r]);else if(r.length>0){let[i,...c]=r;const a=n[o][1];s(a)&&s(i)&&(i=t(!0,a,i)),n[o]=[e,i,...c]}}}}const a=(new c).freeze();function f(e,t){if("function"!=typeof t)throw new TypeError("Cannot `"+e+"` without `parser`")}function h(e,t){if("function"!=typeof t)throw new TypeError("Cannot `"+e+"` without `compiler`")}function p(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function u(e){if(!s(e)||"string"!=typeof e.type)throw new TypeError("Expected node, got `"+e+"`")}function l(e,t,s){if(!s)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function m(e){return function(e){return Boolean(e&&"object"==typeof e&&"message"in e&&"messages"in e)}(e)?e:new i(e)}export{c as Processor,a as unified};
|