@noodleseed/assistant 1.14.0 → 1.16.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.
- package/dist/{chunk-7WXGZJCA.js → chunk-7L52WJ2E.js} +101 -17
- package/dist/chunk-7L52WJ2E.js.map +1 -0
- package/dist/{chunk-RITHSCTD.js → chunk-NPV64PUX.js} +94 -20
- package/dist/chunk-NPV64PUX.js.map +1 -0
- package/dist/{client-BKIeuSVS.d.cts → client-401BAJqk.d.cts} +42 -3
- package/dist/{client-BccAX_om.d.ts → client-Ii_xTV09.d.ts} +42 -3
- package/dist/client.cjs +89 -19
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.js +1 -1
- package/dist/embed.global.js +540 -0
- package/dist/index.cjs +189 -33
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +2 -2
- package/dist/react/client.cjs +100 -23
- package/dist/react/client.cjs.map +1 -1
- package/dist/react/client.d.cts +3 -3
- package/dist/react/client.d.ts +3 -3
- package/dist/react/client.js +12 -5
- package/dist/react/client.js.map +1 -1
- package/dist/react.cjs +198 -36
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +7 -2
- package/dist/react.d.ts +7 -2
- package/dist/react.js +11 -5
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-7WXGZJCA.js.map +0 -1
- package/dist/chunk-RITHSCTD.js.map +0 -1
package/dist/react.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReactElement, RefAttributes } from 'react';
|
|
2
2
|
import { a as AssistantThemeMode } from './appearance-Cc-eqSbp.cjs';
|
|
3
3
|
import { AssistantAppearance, AssistantAppearanceWarning, NoodleAssistantElement } from './index.cjs';
|
|
4
|
-
import { c as AssistantClient, d as AssistantViewAvailableDetail, A as AssistantPageContext, a as AssistantContext, e as AssistantModelContextUpdate, f as AssistantClientEvent, g as AssistantErrorDetail } from './client-
|
|
4
|
+
import { c as AssistantClient, d as AssistantViewAvailableDetail, A as AssistantPageContext, a as AssistantContext, e as AssistantModelContextUpdate, f as AssistantClientEvent, g as AssistantErrorDetail } from './client-401BAJqk.cjs';
|
|
5
5
|
import 'ai';
|
|
6
6
|
|
|
7
7
|
interface NoodleAppViewProps {
|
|
@@ -23,7 +23,12 @@ interface NoodleAppViewProps {
|
|
|
23
23
|
declare function NoodleAppView({ client, view, theme, className, onError, }: NoodleAppViewProps): ReactElement;
|
|
24
24
|
|
|
25
25
|
interface NoodleAssistantProps<TPageContext extends AssistantPageContext = AssistantContext> {
|
|
26
|
-
|
|
26
|
+
/** In-app mount: the customer backend route that exchanges an embed secret for a session. */
|
|
27
|
+
readonly sessionEndpoint?: string;
|
|
28
|
+
/** Public mount: the non-secret embed id `noodle deploy` printed. Exclusive with `sessionEndpoint`. */
|
|
29
|
+
readonly embedId?: string;
|
|
30
|
+
/** Only for a dev or self-hosted service; a published page needs no origin. */
|
|
31
|
+
readonly serviceUrl?: string;
|
|
27
32
|
readonly theme?: AssistantThemeMode;
|
|
28
33
|
readonly appearance?: AssistantAppearance;
|
|
29
34
|
readonly open?: boolean;
|
package/dist/react.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReactElement, RefAttributes } from 'react';
|
|
2
2
|
import { a as AssistantThemeMode } from './appearance-Cc-eqSbp.js';
|
|
3
3
|
import { AssistantAppearance, AssistantAppearanceWarning, NoodleAssistantElement } from './index.js';
|
|
4
|
-
import { c as AssistantClient, d as AssistantViewAvailableDetail, A as AssistantPageContext, a as AssistantContext, e as AssistantModelContextUpdate, f as AssistantClientEvent, g as AssistantErrorDetail } from './client-
|
|
4
|
+
import { c as AssistantClient, d as AssistantViewAvailableDetail, A as AssistantPageContext, a as AssistantContext, e as AssistantModelContextUpdate, f as AssistantClientEvent, g as AssistantErrorDetail } from './client-Ii_xTV09.js';
|
|
5
5
|
import 'ai';
|
|
6
6
|
|
|
7
7
|
interface NoodleAppViewProps {
|
|
@@ -23,7 +23,12 @@ interface NoodleAppViewProps {
|
|
|
23
23
|
declare function NoodleAppView({ client, view, theme, className, onError, }: NoodleAppViewProps): ReactElement;
|
|
24
24
|
|
|
25
25
|
interface NoodleAssistantProps<TPageContext extends AssistantPageContext = AssistantContext> {
|
|
26
|
-
|
|
26
|
+
/** In-app mount: the customer backend route that exchanges an embed secret for a session. */
|
|
27
|
+
readonly sessionEndpoint?: string;
|
|
28
|
+
/** Public mount: the non-secret embed id `noodle deploy` printed. Exclusive with `sessionEndpoint`. */
|
|
29
|
+
readonly embedId?: string;
|
|
30
|
+
/** Only for a dev or self-hosted service; a published page needs no origin. */
|
|
31
|
+
readonly serviceUrl?: string;
|
|
27
32
|
readonly theme?: AssistantThemeMode;
|
|
28
33
|
readonly appearance?: AssistantAppearance;
|
|
29
34
|
readonly open?: boolean;
|
package/dist/react.js
CHANGED
|
@@ -3,8 +3,8 @@ import {
|
|
|
3
3
|
registerNoodleAssistant,
|
|
4
4
|
unmountAssistantApp,
|
|
5
5
|
updateAssistantAppTheme
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-7L52WJ2E.js";
|
|
7
|
+
import "./chunk-NPV64PUX.js";
|
|
8
8
|
import "./chunk-3YYTUJPJ.js";
|
|
9
9
|
import "./chunk-5FUTL2UF.js";
|
|
10
10
|
|
|
@@ -91,7 +91,9 @@ var NoodleAssistantWithRef = forwardRef(
|
|
|
91
91
|
element.addEventListener("assistant-event", assistantEvent);
|
|
92
92
|
element.addEventListener("assistant-appearance-warning", appearanceWarning);
|
|
93
93
|
registerNoodleAssistant();
|
|
94
|
-
element.sessionEndpoint = props.sessionEndpoint;
|
|
94
|
+
element.sessionEndpoint = props.sessionEndpoint ?? "";
|
|
95
|
+
element.embedId = props.embedId ?? "";
|
|
96
|
+
element.serviceUrl = props.serviceUrl ?? "";
|
|
95
97
|
element.appearance = props.appearance;
|
|
96
98
|
element.toggleAttribute("open", props.open === true);
|
|
97
99
|
if (props.context) element.updateContext(props.context);
|
|
@@ -116,12 +118,16 @@ var NoodleAssistantWithRef = forwardRef(
|
|
|
116
118
|
props.onSessionExpired,
|
|
117
119
|
props.open,
|
|
118
120
|
props.pageContext,
|
|
119
|
-
props.sessionEndpoint
|
|
121
|
+
props.sessionEndpoint,
|
|
122
|
+
props.embedId,
|
|
123
|
+
props.serviceUrl
|
|
120
124
|
]);
|
|
121
125
|
return createElement2("noodle-assistant", {
|
|
122
126
|
ref,
|
|
123
127
|
class: props.className,
|
|
124
|
-
"session-endpoint": props.sessionEndpoint,
|
|
128
|
+
...props.sessionEndpoint ? { "session-endpoint": props.sessionEndpoint } : {},
|
|
129
|
+
...props.embedId ? { "embed-id": props.embedId } : {},
|
|
130
|
+
...props.serviceUrl ? { "service-url": props.serviceUrl } : {},
|
|
125
131
|
...props.theme ? { theme: props.theme } : {}
|
|
126
132
|
});
|
|
127
133
|
}
|
package/dist/react.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/react.ts","../src/react-app-view.ts"],"sourcesContent":["import {\n createElement,\n forwardRef,\n type ReactElement,\n type RefAttributes,\n useEffect,\n useImperativeHandle,\n useRef,\n} from 'react';\nimport type { AssistantThemeMode } from './appearance.js';\nimport type { AssistantAppearance, AssistantAppearanceWarning } from './host-appearance.js';\n\nexport type { AssistantAppearance, AssistantAppearanceWarning } from './host-appearance.js';\n\nimport type {\n AssistantClientEvent,\n AssistantContext,\n AssistantModelContextUpdate,\n AssistantPageContext,\n} from './client.js';\nimport { type NoodleAssistantElement, registerNoodleAssistant } from './element.js';\nimport type { AssistantErrorDetail } from './transport.js';\n\nexport { NoodleAppView, type NoodleAppViewProps } from './react-app-view.js';\n\nexport interface NoodleAssistantProps<\n TPageContext extends AssistantPageContext = AssistantContext,\n> {\n readonly sessionEndpoint: string;\n readonly theme?: AssistantThemeMode;\n readonly appearance?: AssistantAppearance;\n readonly open?: boolean;\n readonly className?: string;\n readonly context?: AssistantContext;\n readonly pageContext?: TPageContext;\n readonly modelContext?: AssistantModelContextUpdate;\n readonly onEvent?: (event: AssistantClientEvent) => void;\n readonly onReady?: () => void;\n readonly onError?: (error: AssistantErrorDetail) => void;\n readonly onAppearanceWarning?: (warning: AssistantAppearanceWarning) => void;\n readonly onSessionExpired?: () => void;\n}\n\nconst NoodleAssistantWithRef = forwardRef<NoodleAssistantElement, NoodleAssistantProps>(\n function NoodleAssistant(props, forwardedRef): ReactElement {\n const ref = useRef<NoodleAssistantElement>(null);\n const readyNotified = useRef(false);\n useImperativeHandle(forwardedRef, () => ref.current as NoodleAssistantElement, []);\n useEffect(() => {\n const element = ref.current;\n if (!element) return;\n const ready = () => {\n if (readyNotified.current) return;\n readyNotified.current = true;\n props.onReady?.();\n };\n const error = (event: Event) =>\n props.onError?.((event as CustomEvent<AssistantErrorDetail>).detail);\n const expired = () => props.onSessionExpired?.();\n const assistantEvent = (event: Event) =>\n props.onEvent?.((event as CustomEvent<AssistantClientEvent>).detail);\n const appearanceWarning = (event: Event) =>\n props.onAppearanceWarning?.((event as CustomEvent<AssistantAppearanceWarning>).detail);\n element.addEventListener('assistant-ready', ready);\n element.addEventListener('assistant-error', error);\n element.addEventListener('assistant-session-expired', expired);\n element.addEventListener('assistant-event', assistantEvent);\n element.addEventListener('assistant-appearance-warning', appearanceWarning);\n registerNoodleAssistant();\n element.sessionEndpoint = props.sessionEndpoint;\n element.appearance = props.appearance;\n element.toggleAttribute('open', props.open === true);\n if (props.context) element.updateContext(props.context);\n if (props.pageContext) element.updatePageContext(props.pageContext);\n if (props.modelContext) element.updateModelContext(props.modelContext);\n // The canonical entry may have registered and upgraded the element before this effect ran.\n // Readiness is sticky once the shadow root exists, so late React listeners still fire once.\n if (element.shadowRoot) ready();\n return () => {\n element.removeEventListener('assistant-ready', ready);\n element.removeEventListener('assistant-error', error);\n element.removeEventListener('assistant-session-expired', expired);\n element.removeEventListener('assistant-event', assistantEvent);\n element.removeEventListener('assistant-appearance-warning', appearanceWarning);\n };\n }, [\n props.context,\n props.appearance,\n props.modelContext,\n props.onError,\n props.onAppearanceWarning,\n props.onEvent,\n props.onReady,\n props.onSessionExpired,\n props.open,\n props.pageContext,\n props.sessionEndpoint,\n ]);\n return createElement('noodle-assistant', {\n ref,\n class: props.className,\n 'session-endpoint': props.sessionEndpoint,\n ...(props.theme ? { theme: props.theme } : {}),\n });\n },\n);\n\nexport const NoodleAssistant = NoodleAssistantWithRef as <\n TPageContext extends AssistantPageContext = AssistantContext,\n>(\n props: NoodleAssistantProps<TPageContext> & RefAttributes<NoodleAssistantElement>,\n) => ReactElement;\n","import { createElement, type ReactElement, useEffect, useRef } from 'react';\nimport { mountAssistantApp, unmountAssistantApp, updateAssistantAppTheme } from './app-host.js';\nimport type { AssistantClient, AssistantViewAvailableDetail } from './client.js';\n\nexport interface NoodleAppViewProps {\n readonly client: AssistantClient;\n readonly view: AssistantViewAvailableDetail;\n readonly theme?: 'light' | 'dark';\n readonly className?: string;\n readonly onError?: (failure: {\n readonly code: 'view_render_timeout';\n readonly retryable: false;\n }) => void;\n}\n\n/**\n * Securely hosts one service-resolved MCP App inside a customer-owned React renderer.\n *\n * The bridge lifetime follows semantic view identity, so ordinary parent rerenders cannot reset an\n * in-progress App interaction.\n */\nexport function NoodleAppView({\n client,\n view,\n theme = 'light',\n className,\n onError,\n}: NoodleAppViewProps): ReactElement {\n const container = useRef<HTMLDivElement>(null);\n const mounted = useRef<HTMLElement>(null);\n const current = useRef({ view, theme, onError });\n const viewId = view.id;\n const resourceUri = view.resourceUri;\n\n useEffect(() => {\n current.current = { view, theme, onError };\n });\n\n useEffect(() => {\n const host = container.current;\n if (!host) return;\n const initialView = { ...current.current.view, id: viewId, resourceUri };\n const sandboxUrl = client.appSandboxUrl?.();\n const card = mountAssistantApp(\n initialView,\n {\n client,\n sendMessage: (message) => client.sendMessage(message),\n updateModelContext: (update) => client.updateModelContext(update),\n theme: current.current.theme,\n },\n {\n ...(sandboxUrl ? { sandboxUrl } : {}),\n getDetail: () => current.current.view,\n onRenderFailure: (failure) => current.current.onError?.(failure),\n },\n );\n if (!card) return;\n mounted.current = card;\n host.replaceChildren(card);\n return () => {\n if (mounted.current === card) mounted.current = null;\n void unmountAssistantApp(card);\n };\n }, [client, resourceUri, viewId]);\n\n useEffect(() => {\n if (mounted.current) updateAssistantAppTheme(mounted.current, theme);\n }, [theme]);\n\n return createElement('div', { ref: container, className });\n}\n"],"mappings":";;;;;;;;;;;AAAA;AAAA,EACE,iBAAAA;AAAA,EACA;AAAA,EAGA,aAAAC;AAAA,EACA;AAAA,EACA,UAAAC;AAAA,OACK;;;ACRP,SAAS,eAAkC,WAAW,cAAc;AAqB7D,SAAS,cAAc;AAAA,EAC5B;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR;AAAA,EACA;AACF,GAAqC;AACnC,QAAM,YAAY,OAAuB,IAAI;AAC7C,QAAM,UAAU,OAAoB,IAAI;AACxC,QAAM,UAAU,OAAO,EAAE,MAAM,OAAO,QAAQ,CAAC;AAC/C,QAAM,SAAS,KAAK;AACpB,QAAM,cAAc,KAAK;AAEzB,YAAU,MAAM;AACd,YAAQ,UAAU,EAAE,MAAM,OAAO,QAAQ;AAAA,EAC3C,CAAC;AAED,YAAU,MAAM;AACd,UAAM,OAAO,UAAU;AACvB,QAAI,CAAC,KAAM;AACX,UAAM,cAAc,EAAE,GAAG,QAAQ,QAAQ,MAAM,IAAI,QAAQ,YAAY;AACvE,UAAM,aAAa,OAAO,gBAAgB;AAC1C,UAAM,OAAO;AAAA,MACX;AAAA,MACA;AAAA,QACE;AAAA,QACA,aAAa,CAAC,YAAY,OAAO,YAAY,OAAO;AAAA,QACpD,oBAAoB,CAAC,WAAW,OAAO,mBAAmB,MAAM;AAAA,QAChE,OAAO,QAAQ,QAAQ;AAAA,MACzB;AAAA,MACA;AAAA,QACE,GAAI,aAAa,EAA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,cAAc;AAC1D,cAAQ,iBAAiB,gCAAgC,iBAAiB;AAC1E,8BAAwB;AACxB,cAAQ,kBAAkB,MAAM;AAChC,cAAQ,aAAa,MAAM;AAC3B,cAAQ,gBAAgB,QAAQ,MAAM,SAAS,IAAI;AACnD,UAAI,MAAM,QAAS,SAAQ,cAAc,MAAM,OAAO;AACtD,UAAI,MAAM,YAAa,SAAQ,kBAAkB,MAAM,WAAW;AAClE,UAAI,MAAM,aAAc,SAAQ,mBAAmB,MAAM,YAAY;AAGrE,UAAI,QAAQ,WAAY,OAAM;AAC9B,aAAO,MAAM;AACX,gBAAQ,oBAAoB,mBAAmB,KAAK;AACpD,gBAAQ,oBAAoB,mBAAmB,KAAK;AACpD,gBAAQ,oBAAoB,6BAA6B,OAAO;AAChE,gBAAQ,oBAAoB,mBAAmB,cAAc;AAC7D,gBAAQ,oBAAoB,gCAAgC,iBAAiB;AAAA,MAC/E;AAAA,IACF,GAAG;AAAA,MACD,MAAM;AAAA,MACN,MAAM;AAAA,MACN,MAAM;AAAA,MACN,MAAM;AAAA,MACN,MAAM;AAAA,MACN,MAAM;AAAA,MACN,MAAM;AAAA,MACN,MAAM;AAAA,MACN,MAAM;AAAA,MACN,MAAM;AAAA,MACN,MAAM;AAAA,IACR,CAAC;AACD,WAAOC,eAAc,oBAAoB;AAAA,MACvC;AAAA,MACA,OAAO,MAAM;AAAA,MACb,oBAAoB,MAAM;AAAA,MAC1B,GAAI,MAAM,QAAQ,EAAE,OAAO,MAAM,MAAM,IAAI,CAAC;AAAA,IAC9C,CAAC;AAAA,EACH;AACF;AAEO,IAAMC,mBAAkB;","names":["createElement","useEffect","useRef","useRef","useEffect","createElement","NoodleAssistant"]}
|
|
1
|
+
{"version":3,"sources":["../src/react.ts","../src/react-app-view.ts"],"sourcesContent":["import {\n createElement,\n forwardRef,\n type ReactElement,\n type RefAttributes,\n useEffect,\n useImperativeHandle,\n useRef,\n} from 'react';\nimport type { AssistantThemeMode } from './appearance.js';\nimport type { AssistantAppearance, AssistantAppearanceWarning } from './host-appearance.js';\n\nexport type { AssistantAppearance, AssistantAppearanceWarning } from './host-appearance.js';\n\nimport type {\n AssistantClientEvent,\n AssistantContext,\n AssistantModelContextUpdate,\n AssistantPageContext,\n} from './client.js';\nimport { type NoodleAssistantElement, registerNoodleAssistant } from './element.js';\nimport type { AssistantErrorDetail } from './transport.js';\n\nexport { NoodleAppView, type NoodleAppViewProps } from './react-app-view.js';\n\nexport interface NoodleAssistantProps<\n TPageContext extends AssistantPageContext = AssistantContext,\n> {\n /** In-app mount: the customer backend route that exchanges an embed secret for a session. */\n readonly sessionEndpoint?: string;\n /** Public mount: the non-secret embed id `noodle deploy` printed. Exclusive with `sessionEndpoint`. */\n readonly embedId?: string;\n /** Only for a dev or self-hosted service; a published page needs no origin. */\n readonly serviceUrl?: string;\n readonly theme?: AssistantThemeMode;\n readonly appearance?: AssistantAppearance;\n readonly open?: boolean;\n readonly className?: string;\n readonly context?: AssistantContext;\n readonly pageContext?: TPageContext;\n readonly modelContext?: AssistantModelContextUpdate;\n readonly onEvent?: (event: AssistantClientEvent) => void;\n readonly onReady?: () => void;\n readonly onError?: (error: AssistantErrorDetail) => void;\n readonly onAppearanceWarning?: (warning: AssistantAppearanceWarning) => void;\n readonly onSessionExpired?: () => void;\n}\n\nconst NoodleAssistantWithRef = forwardRef<NoodleAssistantElement, NoodleAssistantProps>(\n function NoodleAssistant(props, forwardedRef): ReactElement {\n const ref = useRef<NoodleAssistantElement>(null);\n const readyNotified = useRef(false);\n useImperativeHandle(forwardedRef, () => ref.current as NoodleAssistantElement, []);\n useEffect(() => {\n const element = ref.current;\n if (!element) return;\n const ready = () => {\n if (readyNotified.current) return;\n readyNotified.current = true;\n props.onReady?.();\n };\n const error = (event: Event) =>\n props.onError?.((event as CustomEvent<AssistantErrorDetail>).detail);\n const expired = () => props.onSessionExpired?.();\n const assistantEvent = (event: Event) =>\n props.onEvent?.((event as CustomEvent<AssistantClientEvent>).detail);\n const appearanceWarning = (event: Event) =>\n props.onAppearanceWarning?.((event as CustomEvent<AssistantAppearanceWarning>).detail);\n element.addEventListener('assistant-ready', ready);\n element.addEventListener('assistant-error', error);\n element.addEventListener('assistant-session-expired', expired);\n element.addEventListener('assistant-event', assistantEvent);\n element.addEventListener('assistant-appearance-warning', appearanceWarning);\n registerNoodleAssistant();\n element.sessionEndpoint = props.sessionEndpoint ?? '';\n element.embedId = props.embedId ?? '';\n element.serviceUrl = props.serviceUrl ?? '';\n element.appearance = props.appearance;\n element.toggleAttribute('open', props.open === true);\n if (props.context) element.updateContext(props.context);\n if (props.pageContext) element.updatePageContext(props.pageContext);\n if (props.modelContext) element.updateModelContext(props.modelContext);\n // The canonical entry may have registered and upgraded the element before this effect ran.\n // Readiness is sticky once the shadow root exists, so late React listeners still fire once.\n if (element.shadowRoot) ready();\n return () => {\n element.removeEventListener('assistant-ready', ready);\n element.removeEventListener('assistant-error', error);\n element.removeEventListener('assistant-session-expired', expired);\n element.removeEventListener('assistant-event', assistantEvent);\n element.removeEventListener('assistant-appearance-warning', appearanceWarning);\n };\n }, [\n props.context,\n props.appearance,\n props.modelContext,\n props.onError,\n props.onAppearanceWarning,\n props.onEvent,\n props.onReady,\n props.onSessionExpired,\n props.open,\n props.pageContext,\n props.sessionEndpoint,\n props.embedId,\n props.serviceUrl,\n ]);\n return createElement('noodle-assistant', {\n ref,\n class: props.className,\n ...(props.sessionEndpoint ? { 'session-endpoint': props.sessionEndpoint } : {}),\n ...(props.embedId ? { 'embed-id': props.embedId } : {}),\n ...(props.serviceUrl ? { 'service-url': props.serviceUrl } : {}),\n ...(props.theme ? { theme: props.theme } : {}),\n });\n },\n);\n\nexport const NoodleAssistant = NoodleAssistantWithRef as <\n TPageContext extends AssistantPageContext = AssistantContext,\n>(\n props: NoodleAssistantProps<TPageContext> & RefAttributes<NoodleAssistantElement>,\n) => ReactElement;\n","import { createElement, type ReactElement, useEffect, useRef } from 'react';\nimport { mountAssistantApp, unmountAssistantApp, updateAssistantAppTheme } from './app-host.js';\nimport type { AssistantClient, AssistantViewAvailableDetail } from './client.js';\n\nexport interface NoodleAppViewProps {\n readonly client: AssistantClient;\n readonly view: AssistantViewAvailableDetail;\n readonly theme?: 'light' | 'dark';\n readonly className?: string;\n readonly onError?: (failure: {\n readonly code: 'view_render_timeout';\n readonly retryable: false;\n }) => void;\n}\n\n/**\n * Securely hosts one service-resolved MCP App inside a customer-owned React renderer.\n *\n * The bridge lifetime follows semantic view identity, so ordinary parent rerenders cannot reset an\n * in-progress App interaction.\n */\nexport function NoodleAppView({\n client,\n view,\n theme = 'light',\n className,\n onError,\n}: NoodleAppViewProps): ReactElement {\n const container = useRef<HTMLDivElement>(null);\n const mounted = useRef<HTMLElement>(null);\n const current = useRef({ view, theme, onError });\n const viewId = view.id;\n const resourceUri = view.resourceUri;\n\n useEffect(() => {\n current.current = { view, theme, onError };\n });\n\n useEffect(() => {\n const host = container.current;\n if (!host) return;\n const initialView = { ...current.current.view, id: viewId, resourceUri };\n const sandboxUrl = client.appSandboxUrl?.();\n const card = mountAssistantApp(\n initialView,\n {\n client,\n sendMessage: (message) => client.sendMessage(message),\n updateModelContext: (update) => client.updateModelContext(update),\n theme: current.current.theme,\n },\n {\n ...(sandboxUrl ? { sandboxUrl } : {}),\n getDetail: () => current.current.view,\n onRenderFailure: (failure) => current.current.onError?.(failure),\n },\n );\n if (!card) return;\n mounted.current = card;\n host.replaceChildren(card);\n return () => {\n if (mounted.current === card) mounted.current = null;\n void unmountAssistantApp(card);\n };\n }, [client, resourceUri, viewId]);\n\n useEffect(() => {\n if (mounted.current) updateAssistantAppTheme(mounted.current, theme);\n }, [theme]);\n\n return createElement('div', { ref: container, className });\n}\n"],"mappings":";;;;;;;;;;;AAAA;AAAA,EACE,iBAAAA;AAAA,EACA;AAAA,EAGA,aAAAC;AAAA,EACA;AAAA,EACA,UAAAC;AAAA,OACK;;;ACRP,SAAS,eAAkC,WAAW,cAAc;AAqB7D,SAAS,cAAc;AAAA,EAC5B;AAA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,oBAAoB,6BAA6B,OAAO;AAChE,gBAAQ,oBAAoB,mBAAmB,cAAc;AAC7D,gBAAQ,oBAAoB,gCAAgC,iBAAiB;AAAA,MAC/E;AAAA,IACF,GAAG;AAAA,MACD,MAAM;AAAA,MACN,MAAM;AAAA,MACN,MAAM;AAAA,MACN,MAAM;AAAA,MACN,MAAM;AAAA,MACN,MAAM;AAAA,MACN,MAAM;AAAA,MACN,MAAM;AAAA,MACN,MAAM;AAAA,MACN,MAAM;AAAA,MACN,MAAM;AAAA,MACN,MAAM;AAAA,MACN,MAAM;AAAA,IACR,CAAC;AACD,WAAOC,eAAc,oBAAoB;AAAA,MACvC;AAAA,MACA,OAAO,MAAM;AAAA,MACb,GAAI,MAAM,kBAAkB,EAAE,oBAAoB,MAAM,gBAAgB,IAAI,CAAC;AAAA,MAC7E,GAAI,MAAM,UAAU,EAAE,YAAY,MAAM,QAAQ,IAAI,CAAC;AAAA,MACrD,GAAI,MAAM,aAAa,EAAE,eAAe,MAAM,WAAW,IAAI,CAAC;AAAA,MAC9D,GAAI,MAAM,QAAQ,EAAE,OAAO,MAAM,MAAM,IAAI,CAAC;AAAA,IAC9C,CAAC;AAAA,EACH;AACF;AAEO,IAAMC,mBAAkB;","names":["createElement","useEffect","useRef","useRef","useEffect","createElement","NoodleAssistant"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@noodleseed/assistant",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.16.0",
|
|
4
4
|
"description": "Embed the Noodle Seed customer-branded assistant in your web app with a Web Component, managed or custom React UI, DOM-free client, and backend session helper. Authoring and deploying the server is @noodleseed/one.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|