@copilotkit/react-native 2.0.0-rc.5 → 2.0.0-rc.51

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 (113) hide show
  1. package/README.md +334 -2
  2. package/USAGE.md +382 -21
  3. package/dist/CopilotKitProvider-CBVQLdzn.d.cts +77 -0
  4. package/dist/{CopilotKitProvider-CE4bc6CP.mjs → CopilotKitProvider-CCBBonxr.mjs} +63 -43
  5. package/dist/CopilotKitProvider-CCBBonxr.mjs.map +1 -0
  6. package/dist/CopilotKitProvider-CtQg_0S-.d.mts +77 -0
  7. package/dist/{CopilotKitProvider-Byw3cqe2.cjs → CopilotKitProvider-QdcQrrSA.cjs} +69 -42
  8. package/dist/CopilotKitProvider-QdcQrrSA.cjs.map +1 -0
  9. package/dist/{Markdown-C_9Re36O.cjs → Markdown-DLopAh5W.cjs} +10 -10
  10. package/dist/Markdown-DLopAh5W.cjs.map +1 -0
  11. package/dist/{Markdown-JsYh7oSA.d.mts → Markdown-Du-b_Qpr.d.mts} +3 -3
  12. package/dist/{Markdown-1ips7myr.d.cts → Markdown-UXZdDjzs.d.cts} +3 -3
  13. package/dist/{Markdown-C6AsLHmd.mjs → Markdown-VxtPJ_yh.mjs} +4 -4
  14. package/dist/Markdown-VxtPJ_yh.mjs.map +1 -0
  15. package/dist/{MarkdownRendererContext-CAnuohIS.mjs → MarkdownRendererContext-EobUsERg.mjs} +1 -1
  16. package/dist/{MarkdownRendererContext-CAnuohIS.mjs.map → MarkdownRendererContext-EobUsERg.mjs.map} +1 -1
  17. package/dist/MarkdownRendererContext-cDEHvbw9.cjs +40 -0
  18. package/dist/{MarkdownRendererContext-BRNe808d.cjs.map → MarkdownRendererContext-cDEHvbw9.cjs.map} +1 -1
  19. package/dist/chunk-C0xms8kb.cjs +34 -0
  20. package/dist/components/index.cjs +78 -175
  21. package/dist/components/index.cjs.map +1 -1
  22. package/dist/components/index.d.cts +2 -2
  23. package/dist/components/index.d.mts +2 -2
  24. package/dist/components/index.mjs +76 -174
  25. package/dist/components/index.mjs.map +1 -1
  26. package/dist/generative-ui/index.cjs +612 -0
  27. package/dist/generative-ui/index.cjs.map +1 -0
  28. package/dist/generative-ui/index.d.cts +341 -0
  29. package/dist/generative-ui/index.d.mts +341 -0
  30. package/dist/generative-ui/index.mjs +549 -0
  31. package/dist/generative-ui/index.mjs.map +1 -0
  32. package/dist/headless.cjs +3 -2
  33. package/dist/headless.d.cts +3 -3
  34. package/dist/headless.d.mts +3 -3
  35. package/dist/headless.mjs +2 -2
  36. package/dist/index.cjs +132 -162
  37. package/dist/index.cjs.map +1 -1
  38. package/dist/index.d.cts +37 -19
  39. package/dist/index.d.mts +37 -19
  40. package/dist/index.mjs +131 -162
  41. package/dist/index.mjs.map +1 -1
  42. package/dist/polyfills/encoding.cjs +115 -5
  43. package/dist/polyfills/encoding.cjs.map +1 -1
  44. package/dist/polyfills/encoding.d.cts +31 -1
  45. package/dist/polyfills/encoding.d.mts +31 -1
  46. package/dist/polyfills/encoding.mjs +113 -6
  47. package/dist/polyfills/encoding.mjs.map +1 -1
  48. package/dist/polyfills/streams.cjs +1 -1
  49. package/dist/polyfills.cjs +218 -2
  50. package/dist/polyfills.cjs.map +1 -1
  51. package/dist/polyfills.mjs +217 -1
  52. package/dist/polyfills.mjs.map +1 -1
  53. package/package.json +51 -21
  54. package/project.json +6 -1
  55. package/scripts/__tests__/verify-polyfill-barrel.test.mjs +150 -0
  56. package/scripts/verify-polyfill-barrel.mjs +158 -11
  57. package/src/CopilotChat.tsx +114 -93
  58. package/src/CopilotKitProvider.tsx +101 -130
  59. package/src/CopilotPopup.tsx +2 -2
  60. package/src/CopilotSidebar.tsx +7 -5
  61. package/src/__mocks__/react-native.ts +31 -0
  62. package/src/__mocks__/test-copilotkit.tsx +9 -3
  63. package/src/__tests__/attachments-integration.test.tsx +15 -2
  64. package/src/__tests__/copilot-chat-agentid.test.tsx +15 -2
  65. package/src/__tests__/copilot-chat-attachments.test.tsx +15 -2
  66. package/src/__tests__/copilot-chat-configuration.test.tsx +82 -0
  67. package/src/__tests__/copilot-chat-threads.test.tsx +232 -0
  68. package/src/__tests__/copilot-popup.test.tsx +15 -2
  69. package/src/__tests__/copilot-sidebar.test.tsx +15 -2
  70. package/src/__tests__/copilotkit-alias-exports.test.ts +16 -0
  71. package/src/__tests__/copilotkit-provider.test.tsx +68 -73
  72. package/src/__tests__/generative-ui-harness.tsx +243 -0
  73. package/src/__tests__/generative-ui-provider-props.test-d.tsx +106 -0
  74. package/src/__tests__/generative-ui-rn-mock.tsx +54 -0
  75. package/src/__tests__/generative-ui-wiring.test.tsx +720 -0
  76. package/src/__tests__/generative-ui.test.tsx +1000 -0
  77. package/src/__tests__/headless-entry-surface.test.ts +979 -61
  78. package/src/__tests__/headless-integration.test.tsx +11 -1
  79. package/src/__tests__/use-attachments.test.ts +27 -2
  80. package/src/components/CopilotChat.tsx +106 -233
  81. package/src/components/CopilotModal.tsx +1 -1
  82. package/src/components/Markdown.tsx +4 -4
  83. package/src/components/__tests__/CopilotChat-edge-cases.test.tsx +5 -1
  84. package/src/components/__tests__/CopilotChat.test.tsx +12 -4
  85. package/src/components/__tests__/CopilotChatInterrupt.test.tsx +208 -0
  86. package/src/components/__tests__/Markdown.code-alias.test.tsx +1 -1
  87. package/src/components/index.ts +6 -0
  88. package/src/components/messages/AssistantMessage.tsx +3 -3
  89. package/src/components/messages/TypingIndicator.tsx +4 -4
  90. package/src/generative-ui/GenerativeUIActivity.tsx +235 -0
  91. package/src/generative-ui/GenerativeUIProvider.tsx +171 -0
  92. package/src/generative-ui/GenerativeUISurface.tsx +303 -0
  93. package/src/generative-ui/host.tsx +138 -0
  94. package/src/generative-ui/index.ts +93 -0
  95. package/src/generative-ui/internal.ts +55 -0
  96. package/src/headless.ts +4 -0
  97. package/src/hooks/use-attachments.ts +95 -139
  98. package/src/index.ts +10 -4
  99. package/src/polyfills/__tests__/encoding-utf8.test.ts +112 -0
  100. package/src/polyfills/encoding.ts +160 -4
  101. package/src/types.d.ts +0 -13
  102. package/tsdown.config.ts +1 -0
  103. package/dist/CopilotKitProvider-BWjzCdHN.d.mts +0 -121
  104. package/dist/CopilotKitProvider-Btm10msB.d.cts +0 -121
  105. package/dist/CopilotKitProvider-Byw3cqe2.cjs.map +0 -1
  106. package/dist/CopilotKitProvider-CE4bc6CP.mjs.map +0 -1
  107. package/dist/Markdown-C6AsLHmd.mjs.map +0 -1
  108. package/dist/Markdown-C_9Re36O.cjs.map +0 -1
  109. package/dist/MarkdownRendererContext-BRNe808d.cjs +0 -72
  110. package/dist/streaming-fetch-Bm91EsRc.cjs +0 -225
  111. package/dist/streaming-fetch-Bm91EsRc.cjs.map +0 -1
  112. package/dist/streaming-fetch-Dm1oN4f2.mjs +0 -219
  113. package/dist/streaming-fetch-Dm1oN4f2.mjs.map +0 -1
@@ -1,7 +1,8 @@
1
- import { t as MarkdownRendererProvider } from "./MarkdownRendererContext-CAnuohIS.mjs";
1
+ import { t as MarkdownRendererProvider } from "./MarkdownRendererContext-EobUsERg.mjs";
2
2
  import React, { useEffect, useMemo, useRef, useState } from "react";
3
3
  import { CopilotKitContext, LicenseContext } from "@copilotkit/react-core/context";
4
- import { CopilotKitCoreReact } from "@copilotkit/react-core/headless";
4
+ import { CopilotKitCoreReact, ɵuseOwnedCore } from "@copilotkit/react-core/headless";
5
+ import { ɵreportProviderConfigDiagnostics, ɵresolveProviderConfig } from "@copilotkit/core";
5
6
  import { createLicenseContextValue } from "@copilotkit/shared";
6
7
  import { jsx } from "react/jsx-runtime";
7
8
 
@@ -33,48 +34,67 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp, creden
33
34
  const resolvedHeaders = typeof headersProp === "function" ? headersProp() : headersProp;
34
35
  const stableHeaders = useMemo(() => resolvedHeaders ?? {}, [JSON.stringify(resolvedHeaders)]);
35
36
  const stableProperties = useMemo(() => properties ?? {}, [JSON.stringify(properties)]);
36
- const copilotkitRef = useRef(null);
37
- if (copilotkitRef.current === null) {
38
- const instance = new CopilotKitCoreReact({
39
- runtimeUrl,
40
- runtimeTransport: useSingleEndpoint === true ? "single" : useSingleEndpoint === false ? "rest" : "auto",
37
+ const resolvedConfig = useMemo(() => ɵresolveProviderConfig({
38
+ runtimeUrl,
39
+ useSingleEndpoint,
40
+ properties: stableProperties
41
+ }), [
42
+ runtimeUrl,
43
+ useSingleEndpoint,
44
+ stableProperties
45
+ ]);
46
+ const loggedDiagnosticsRef = useRef(/* @__PURE__ */ new Set());
47
+ ɵreportProviderConfigDiagnostics(resolvedConfig.diagnostics, {
48
+ isProduction: process.env.NODE_ENV === "production",
49
+ logged: loggedDiagnosticsRef.current
50
+ });
51
+ const copilotkit = ɵuseOwnedCore(useRef(null), () => new CopilotKitCoreReact({
52
+ runtimeUrl: resolvedConfig.runtimeUrl,
53
+ runtimeTransport: resolvedConfig.runtimeTransport,
54
+ deferInitialConnection: true,
55
+ headers: stableHeaders,
56
+ credentials,
57
+ messageFilter,
58
+ properties: resolvedConfig.properties,
59
+ debug,
60
+ defaultThrottleMs,
61
+ onError
62
+ }));
63
+ useEffect(() => {
64
+ copilotkit.setErrorHandler(onError);
65
+ }, [copilotkit, onError]);
66
+ useEffect(() => {
67
+ copilotkit.ɵupdateConfig({
68
+ messageFilter,
69
+ runtimeUrl: resolvedConfig.runtimeUrl,
70
+ runtimeTransport: resolvedConfig.runtimeTransport,
41
71
  headers: stableHeaders,
42
72
  credentials,
43
- messageFilter,
44
- properties: stableProperties,
45
- debug
73
+ properties: resolvedConfig.properties,
74
+ debug,
75
+ defaultThrottleMs
46
76
  });
47
- if (defaultThrottleMs !== void 0) instance.setDefaultThrottleMs(defaultThrottleMs);
48
- copilotkitRef.current = instance;
49
- }
50
- const copilotkit = copilotkitRef.current;
51
- useEffect(() => {
52
- copilotkit.setRuntimeUrl(runtimeUrl);
53
- copilotkit.setRuntimeTransport(useSingleEndpoint === true ? "single" : useSingleEndpoint === false ? "rest" : "auto");
54
- copilotkit.setHeaders(stableHeaders);
55
- copilotkit.setCredentials(credentials);
56
- copilotkit.setMessageFilter(messageFilter);
57
- copilotkit.setProperties(stableProperties);
58
- copilotkit.setDebug(debug);
77
+ copilotkit.connect();
59
78
  }, [
60
- runtimeUrl,
61
- useSingleEndpoint,
79
+ copilotkit,
80
+ messageFilter,
81
+ resolvedConfig.runtimeUrl,
82
+ resolvedConfig.runtimeTransport,
62
83
  stableHeaders,
63
84
  credentials,
64
- messageFilter,
65
- stableProperties,
85
+ resolvedConfig.properties,
66
86
  debug,
67
- copilotkit
87
+ defaultThrottleMs
68
88
  ]);
69
- useEffect(() => {
70
- copilotkit.setDefaultThrottleMs(defaultThrottleMs);
71
- }, [copilotkit, defaultThrottleMs]);
72
89
  const [executingToolCallIds, setExecutingToolCallIds] = useState(() => /* @__PURE__ */ new Set());
73
- const [runtimeLicenseStatus, setRuntimeLicenseStatus] = useState(void 0);
74
- const onErrorRef = useRef(onError);
90
+ const [runtimeInfo, setRuntimeInfo] = useState(null);
91
+ const runtimeLicenseStatus = runtimeInfo?.licenseStatus;
75
92
  useEffect(() => {
76
- onErrorRef.current = onError;
77
- }, [onError]);
93
+ const syncRuntimeInfo = () => setRuntimeInfo(copilotkit.ɵruntimeInfo);
94
+ const unsubscribe = copilotkit.ɵsubscribeToRuntimeInfo(syncRuntimeInfo);
95
+ syncRuntimeInfo();
96
+ return unsubscribe;
97
+ }, [copilotkit]);
78
98
  useEffect(() => {
79
99
  const subscription = copilotkit.subscribe({
80
100
  onToolExecutionStart: ({ toolCallId }) => {
@@ -92,13 +112,6 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp, creden
92
112
  next.delete(toolCallId);
93
113
  return next;
94
114
  });
95
- },
96
- onError: (event) => {
97
- if (onErrorRef.current) onErrorRef.current(event);
98
- else console.error(`[CopilotKit] Error (${event.code}):`, event.error, event.context ?? {});
99
- },
100
- onRuntimeConnectionStatusChanged: () => {
101
- setRuntimeLicenseStatus(copilotkit.licenseStatus);
102
115
  }
103
116
  });
104
117
  return () => subscription.unsubscribe();
@@ -119,7 +132,14 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp, creden
119
132
  })
120
133
  });
121
134
  };
135
+ /**
136
+ * Alias of {@link CopilotKitProvider}: the same component under its v1 name,
137
+ * so `<CopilotKit>` keeps working. `CopilotKitProvider` is the preferred name.
138
+ *
139
+ * @alias
140
+ */
141
+ const CopilotKit = CopilotKitProvider;
122
142
 
123
143
  //#endregion
124
- export { CopilotKitProvider as t };
125
- //# sourceMappingURL=CopilotKitProvider-CE4bc6CP.mjs.map
144
+ export { CopilotKitProvider as n, CopilotKit as t };
145
+ //# sourceMappingURL=CopilotKitProvider-CCBBonxr.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CopilotKitProvider-CCBBonxr.mjs","names":[],"sources":["../src/CopilotKitProvider.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useRef, useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport {\n CopilotKitContext,\n LicenseContext,\n} from \"@copilotkit/react-core/context\";\nimport type {\n CopilotKitContextValue,\n CopilotKitCoreReact as CopilotKitCoreReactInstance,\n} from \"@copilotkit/react-core/context\";\nimport {\n CopilotKitCoreReact,\n ɵuseOwnedCore,\n} from \"@copilotkit/react-core/headless\";\nimport type {\n ɵCopilotKitProviderBaseOptions,\n ɵRuntimeInfo,\n} from \"@copilotkit/core\";\nimport {\n ɵreportProviderConfigDiagnostics,\n ɵresolveProviderConfig,\n} from \"@copilotkit/core\";\nimport { createLicenseContextValue } from \"@copilotkit/shared\";\nimport { MarkdownRendererProvider } from \"./components/MarkdownRendererContext\";\nimport type { MarkdownRendererValue } from \"./components/MarkdownRendererContext\";\n\nexport interface CopilotKitNativeProviderProps extends Pick<\n ɵCopilotKitProviderBaseOptions,\n | \"credentials\"\n | \"messageFilter\"\n | \"useSingleEndpoint\"\n | \"properties\"\n | \"onError\"\n | \"debug\"\n | \"defaultThrottleMs\"\n> {\n children: ReactNode;\n /** URL of the CopilotKit runtime endpoint */\n runtimeUrl: string;\n /** Custom headers sent with every request */\n headers?: Record<string, string> | (() => Record<string, string>);\n /**\n * Custom markdown renderer for assistant messages. Either a component (escape\n * hatch — receives `content` and an optional `isStreaming` flag) used instead\n * of the built-in renderer, or a `{ style, animate }` config object to\n * configure the built-in React Native renderer (the `CopilotMarkdown` used by\n * the default `AssistantMessage`) without writing a wrapper.\n */\n markdownRenderer?: MarkdownRendererValue;\n // Cloud features (publicApiKey, licenseToken) — not yet supported on React Native\n}\n\n/**\n * CopilotKit provider for React Native.\n *\n * A lightweight alternative to the web CopilotKitProvider that avoids\n * web-only dependencies (DOM, CSS, Radix UI, Lit, etc).\n *\n * Polyfills are auto-imported when `@copilotkit/react-native` is loaded,\n * so a separate `import \"@copilotkit/react-native/polyfills\"` is no longer\n * required (though it remains available for advanced use).\n *\n * Usage:\n * ```tsx\n * import { CopilotKitProvider } from \"@copilotkit/react-native\";\n *\n * function App() {\n * return (\n * <CopilotKitProvider runtimeUrl=\"https://your-runtime/api/copilotkit\">\n * <ChatScreen />\n * </CopilotKitProvider>\n * );\n * }\n * ```\n */\nexport const CopilotKitProvider: React.FC<CopilotKitNativeProviderProps> = ({\n children,\n runtimeUrl,\n headers: headersProp,\n credentials,\n messageFilter,\n useSingleEndpoint,\n properties,\n onError,\n debug,\n defaultThrottleMs,\n markdownRenderer,\n}) => {\n // Resolve headers from function or static object (matches web provider pattern)\n const resolvedHeaders =\n typeof headersProp === \"function\" ? headersProp() : headersProp;\n\n // Stabilize headers/properties references to avoid effect churn when callers\n // pass inline object literals (e.g. headers={{}} or the undefined default).\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const stableHeaders = useMemo(\n () => resolvedHeaders ?? {},\n [JSON.stringify(resolvedHeaders)],\n );\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const stableProperties = useMemo(\n () => properties ?? {},\n [JSON.stringify(properties)],\n );\n\n // Transport mapping and config checks come from core.\n const resolvedConfig = useMemo(\n () =>\n ɵresolveProviderConfig({\n runtimeUrl,\n useSingleEndpoint,\n properties: stableProperties,\n }),\n [runtimeUrl, useSingleEndpoint, stableProperties],\n );\n const loggedDiagnosticsRef = useRef(new Set<string>());\n ɵreportProviderConfigDiagnostics(resolvedConfig.diagnostics, {\n isProduction: process.env.NODE_ENV === \"production\",\n logged: loggedDiagnosticsRef.current,\n });\n\n // One core for the provider lifetime, disposed on unmount (StrictMode\n // safe, see `ɵuseOwnedCore`).\n const copilotkitRef = useRef<CopilotKitCoreReactInstance | null>(null);\n const copilotkit = ɵuseOwnedCore(\n copilotkitRef,\n (): CopilotKitCoreReactInstance =>\n new CopilotKitCoreReact({\n runtimeUrl: resolvedConfig.runtimeUrl,\n runtimeTransport: resolvedConfig.runtimeTransport,\n // `/info` starts from the effect below, so a render React discards\n // never fetches it (#5801).\n deferInitialConnection: true,\n headers: stableHeaders,\n credentials,\n messageFilter,\n properties: resolvedConfig.properties,\n debug,\n // Set at construction so child hooks see it on their first render.\n defaultThrottleMs,\n onError,\n }),\n );\n\n // Core calls `onError`, and logs the error itself when there is none.\n useEffect(() => {\n copilotkit.setErrorHandler(onError);\n }, [copilotkit, onError]);\n\n // Sync props to the core. Core applies only what changed.\n useEffect(() => {\n copilotkit.ɵupdateConfig({\n messageFilter,\n runtimeUrl: resolvedConfig.runtimeUrl,\n runtimeTransport: resolvedConfig.runtimeTransport,\n headers: stableHeaders,\n credentials,\n properties: resolvedConfig.properties,\n debug,\n defaultThrottleMs,\n });\n copilotkit.connect();\n }, [\n copilotkit,\n messageFilter,\n resolvedConfig.runtimeUrl,\n resolvedConfig.runtimeTransport,\n stableHeaders,\n credentials,\n resolvedConfig.properties,\n debug,\n defaultThrottleMs,\n ]);\n\n // Track executing tool call IDs at the provider level.\n // Critical for HITL reconnection: onToolExecutionStart fires before child\n // components mount, so we must capture the state here.\n const [executingToolCallIds, setExecutingToolCallIds] = useState<\n ReadonlySet<string>\n >(() => new Set());\n\n const [runtimeInfo, setRuntimeInfo] = useState<ɵRuntimeInfo | null>(null);\n const runtimeLicenseStatus = runtimeInfo?.licenseStatus;\n\n // Project core's runtime info snapshot; the catch-up read reflects a status\n // that settled before this effect ran.\n useEffect(() => {\n const syncRuntimeInfo = () => setRuntimeInfo(copilotkit.ɵruntimeInfo);\n const unsubscribe = copilotkit.ɵsubscribeToRuntimeInfo(syncRuntimeInfo);\n syncRuntimeInfo();\n return unsubscribe;\n }, [copilotkit]);\n\n // Tool execution tracking.\n // Tool call IDs are tracked at the provider level because onToolExecutionStart\n // fires before child components mount — critical for HITL reconnection.\n useEffect(() => {\n const subscription = copilotkit.subscribe({\n onToolExecutionStart: ({ toolCallId }) => {\n setExecutingToolCallIds((prev) => {\n if (prev.has(toolCallId)) return prev;\n const next = new Set(prev);\n next.add(toolCallId);\n return next;\n });\n },\n onToolExecutionEnd: ({ toolCallId }) => {\n setExecutingToolCallIds((prev) => {\n if (!prev.has(toolCallId)) return prev;\n const next = new Set(prev);\n next.delete(toolCallId);\n return next;\n });\n },\n });\n return () => subscription.unsubscribe();\n }, [copilotkit]);\n\n const contextValue: CopilotKitContextValue = useMemo(\n () => ({\n copilotkit,\n executingToolCallIds,\n }),\n [copilotkit, executingToolCallIds],\n );\n\n // License context — driven by server-reported status via /info endpoint\n const licenseContextValue = useMemo(\n () => createLicenseContextValue(runtimeLicenseStatus),\n [runtimeLicenseStatus],\n );\n\n return (\n <CopilotKitContext.Provider value={contextValue}>\n <LicenseContext.Provider value={licenseContextValue}>\n <MarkdownRendererProvider renderer={markdownRenderer}>\n {children}\n </MarkdownRendererProvider>\n </LicenseContext.Provider>\n </CopilotKitContext.Provider>\n );\n};\n\n/**\n * Alias of {@link CopilotKitProvider}: the same component under its v1 name,\n * so `<CopilotKit>` keeps working. `CopilotKitProvider` is the preferred name.\n *\n * @alias\n */\nexport const CopilotKit = CopilotKitProvider;\n\n/**\n * Alias of {@link CopilotKitNativeProviderProps}, the props of\n * {@link CopilotKit}. Prefer `CopilotKitProviderProps` in new code.\n */\nexport type CopilotKitProps = CopilotKitNativeProviderProps;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2EA,MAAa,sBAA+D,EAC1E,UACA,YACA,SAAS,aACT,aACA,eACA,mBACA,YACA,SACA,OACA,mBACA,uBACI;CAEJ,MAAM,kBACJ,OAAO,gBAAgB,aAAa,aAAa,GAAG;CAKtD,MAAM,gBAAgB,cACd,mBAAmB,EAAE,EAC3B,CAAC,KAAK,UAAU,gBAAgB,CAAC,CAClC;CAED,MAAM,mBAAmB,cACjB,cAAc,EAAE,EACtB,CAAC,KAAK,UAAU,WAAW,CAAC,CAC7B;CAGD,MAAM,iBAAiB,cAEnB,uBAAuB;EACrB;EACA;EACA,YAAY;EACb,CAAC,EACJ;EAAC;EAAY;EAAmB;EAAiB,CAClD;CACD,MAAM,uBAAuB,uBAAO,IAAI,KAAa,CAAC;AACtD,kCAAiC,eAAe,aAAa;EAC3D,cAAc,QAAQ,IAAI,aAAa;EACvC,QAAQ,qBAAqB;EAC9B,CAAC;CAKF,MAAM,aAAa,cADG,OAA2C,KAAK,QAIlE,IAAI,oBAAoB;EACtB,YAAY,eAAe;EAC3B,kBAAkB,eAAe;EAGjC,wBAAwB;EACxB,SAAS;EACT;EACA;EACA,YAAY,eAAe;EAC3B;EAEA;EACA;EACD,CAAC,CACL;AAGD,iBAAgB;AACd,aAAW,gBAAgB,QAAQ;IAClC,CAAC,YAAY,QAAQ,CAAC;AAGzB,iBAAgB;AACd,aAAW,cAAc;GACvB;GACA,YAAY,eAAe;GAC3B,kBAAkB,eAAe;GACjC,SAAS;GACT;GACA,YAAY,eAAe;GAC3B;GACA;GACD,CAAC;AACF,aAAW,SAAS;IACnB;EACD;EACA;EACA,eAAe;EACf,eAAe;EACf;EACA;EACA,eAAe;EACf;EACA;EACD,CAAC;CAKF,MAAM,CAAC,sBAAsB,2BAA2B,+BAEhD,IAAI,KAAK,CAAC;CAElB,MAAM,CAAC,aAAa,kBAAkB,SAA8B,KAAK;CACzE,MAAM,uBAAuB,aAAa;AAI1C,iBAAgB;EACd,MAAM,wBAAwB,eAAe,WAAW,aAAa;EACrE,MAAM,cAAc,WAAW,wBAAwB,gBAAgB;AACvE,mBAAiB;AACjB,SAAO;IACN,CAAC,WAAW,CAAC;AAKhB,iBAAgB;EACd,MAAM,eAAe,WAAW,UAAU;GACxC,uBAAuB,EAAE,iBAAiB;AACxC,6BAAyB,SAAS;AAChC,SAAI,KAAK,IAAI,WAAW,CAAE,QAAO;KACjC,MAAM,OAAO,IAAI,IAAI,KAAK;AAC1B,UAAK,IAAI,WAAW;AACpB,YAAO;MACP;;GAEJ,qBAAqB,EAAE,iBAAiB;AACtC,6BAAyB,SAAS;AAChC,SAAI,CAAC,KAAK,IAAI,WAAW,CAAE,QAAO;KAClC,MAAM,OAAO,IAAI,IAAI,KAAK;AAC1B,UAAK,OAAO,WAAW;AACvB,YAAO;MACP;;GAEL,CAAC;AACF,eAAa,aAAa,aAAa;IACtC,CAAC,WAAW,CAAC;CAEhB,MAAM,eAAuC,eACpC;EACL;EACA;EACD,GACD,CAAC,YAAY,qBAAqB,CACnC;CAGD,MAAM,sBAAsB,cACpB,0BAA0B,qBAAqB,EACrD,CAAC,qBAAqB,CACvB;AAED,QACE,oBAAC,kBAAkB;EAAS,OAAO;YACjC,oBAAC,eAAe;GAAS,OAAO;aAC9B,oBAAC;IAAyB,UAAU;IACjC;KACwB;IACH;GACC;;;;;;;;AAUjC,MAAa,aAAa"}
@@ -0,0 +1,77 @@
1
+ import { r as MarkdownStyle } from "./Markdown-Du-b_Qpr.mjs";
2
+ import React, { ReactNode } from "react";
3
+ import { ɵCopilotKitProviderBaseOptions } from "@copilotkit/core";
4
+
5
+ //#region src/components/MarkdownRendererContext.d.ts
6
+ interface NativeMarkdownRendererProps {
7
+ content: string;
8
+ isStreaming?: boolean;
9
+ }
10
+ type NativeMarkdownRenderer = React.ComponentType<NativeMarkdownRendererProps>;
11
+ /** Config for the built-in RN renderer (pass instead of a component). */
12
+ interface DefaultMarkdownRendererProps {
13
+ style?: MarkdownStyle;
14
+ animate?: boolean;
15
+ }
16
+ type MarkdownRendererValue = NativeMarkdownRenderer | DefaultMarkdownRendererProps;
17
+ declare const MarkdownRendererProvider: React.FC<{
18
+ renderer?: MarkdownRendererValue;
19
+ children: React.ReactNode;
20
+ }>;
21
+ declare function useMarkdownRenderer(): MarkdownRendererValue | undefined;
22
+ //#endregion
23
+ //#region src/CopilotKitProvider.d.ts
24
+ interface CopilotKitNativeProviderProps extends Pick<ɵCopilotKitProviderBaseOptions, "credentials" | "messageFilter" | "useSingleEndpoint" | "properties" | "onError" | "debug" | "defaultThrottleMs"> {
25
+ children: ReactNode;
26
+ /** URL of the CopilotKit runtime endpoint */
27
+ runtimeUrl: string;
28
+ /** Custom headers sent with every request */
29
+ headers?: Record<string, string> | (() => Record<string, string>);
30
+ /**
31
+ * Custom markdown renderer for assistant messages. Either a component (escape
32
+ * hatch — receives `content` and an optional `isStreaming` flag) used instead
33
+ * of the built-in renderer, or a `{ style, animate }` config object to
34
+ * configure the built-in React Native renderer (the `CopilotMarkdown` used by
35
+ * the default `AssistantMessage`) without writing a wrapper.
36
+ */
37
+ markdownRenderer?: MarkdownRendererValue;
38
+ }
39
+ /**
40
+ * CopilotKit provider for React Native.
41
+ *
42
+ * A lightweight alternative to the web CopilotKitProvider that avoids
43
+ * web-only dependencies (DOM, CSS, Radix UI, Lit, etc).
44
+ *
45
+ * Polyfills are auto-imported when `@copilotkit/react-native` is loaded,
46
+ * so a separate `import "@copilotkit/react-native/polyfills"` is no longer
47
+ * required (though it remains available for advanced use).
48
+ *
49
+ * Usage:
50
+ * ```tsx
51
+ * import { CopilotKitProvider } from "@copilotkit/react-native";
52
+ *
53
+ * function App() {
54
+ * return (
55
+ * <CopilotKitProvider runtimeUrl="https://your-runtime/api/copilotkit">
56
+ * <ChatScreen />
57
+ * </CopilotKitProvider>
58
+ * );
59
+ * }
60
+ * ```
61
+ */
62
+ declare const CopilotKitProvider: React.FC<CopilotKitNativeProviderProps>;
63
+ /**
64
+ * Alias of {@link CopilotKitProvider}: the same component under its v1 name,
65
+ * so `<CopilotKit>` keeps working. `CopilotKitProvider` is the preferred name.
66
+ *
67
+ * @alias
68
+ */
69
+ declare const CopilotKit: React.FC<CopilotKitNativeProviderProps>;
70
+ /**
71
+ * Alias of {@link CopilotKitNativeProviderProps}, the props of
72
+ * {@link CopilotKit}. Prefer `CopilotKitProviderProps` in new code.
73
+ */
74
+ type CopilotKitProps = CopilotKitNativeProviderProps;
75
+ //#endregion
76
+ export { MarkdownRendererProvider as a, useMarkdownRenderer as c, CopilotKitProvider as i, CopilotKitNativeProviderProps as n, NativeMarkdownRenderer as o, CopilotKitProps as r, NativeMarkdownRendererProps as s, CopilotKit as t };
77
+ //# sourceMappingURL=CopilotKitProvider-CtQg_0S-.d.mts.map
@@ -1,8 +1,10 @@
1
- const require_MarkdownRendererContext = require('./MarkdownRendererContext-BRNe808d.cjs');
1
+ const require_chunk = require('./chunk-C0xms8kb.cjs');
2
+ const require_MarkdownRendererContext = require('./MarkdownRendererContext-cDEHvbw9.cjs');
2
3
  let react = require("react");
3
- react = require_MarkdownRendererContext.__toESM(react);
4
+ react = require_chunk.__toESM(react);
4
5
  let _copilotkit_react_core_context = require("@copilotkit/react-core/context");
5
6
  let _copilotkit_react_core_headless = require("@copilotkit/react-core/headless");
7
+ let _copilotkit_core = require("@copilotkit/core");
6
8
  let _copilotkit_shared = require("@copilotkit/shared");
7
9
  let react_jsx_runtime = require("react/jsx-runtime");
8
10
 
@@ -34,48 +36,67 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp, creden
34
36
  const resolvedHeaders = typeof headersProp === "function" ? headersProp() : headersProp;
35
37
  const stableHeaders = (0, react.useMemo)(() => resolvedHeaders ?? {}, [JSON.stringify(resolvedHeaders)]);
36
38
  const stableProperties = (0, react.useMemo)(() => properties ?? {}, [JSON.stringify(properties)]);
37
- const copilotkitRef = (0, react.useRef)(null);
38
- if (copilotkitRef.current === null) {
39
- const instance = new _copilotkit_react_core_headless.CopilotKitCoreReact({
40
- runtimeUrl,
41
- runtimeTransport: useSingleEndpoint === true ? "single" : useSingleEndpoint === false ? "rest" : "auto",
39
+ const resolvedConfig = (0, react.useMemo)(() => (0, _copilotkit_core.ɵresolveProviderConfig)({
40
+ runtimeUrl,
41
+ useSingleEndpoint,
42
+ properties: stableProperties
43
+ }), [
44
+ runtimeUrl,
45
+ useSingleEndpoint,
46
+ stableProperties
47
+ ]);
48
+ const loggedDiagnosticsRef = (0, react.useRef)(/* @__PURE__ */ new Set());
49
+ (0, _copilotkit_core.ɵreportProviderConfigDiagnostics)(resolvedConfig.diagnostics, {
50
+ isProduction: process.env.NODE_ENV === "production",
51
+ logged: loggedDiagnosticsRef.current
52
+ });
53
+ const copilotkit = (0, _copilotkit_react_core_headless.ɵuseOwnedCore)((0, react.useRef)(null), () => new _copilotkit_react_core_headless.CopilotKitCoreReact({
54
+ runtimeUrl: resolvedConfig.runtimeUrl,
55
+ runtimeTransport: resolvedConfig.runtimeTransport,
56
+ deferInitialConnection: true,
57
+ headers: stableHeaders,
58
+ credentials,
59
+ messageFilter,
60
+ properties: resolvedConfig.properties,
61
+ debug,
62
+ defaultThrottleMs,
63
+ onError
64
+ }));
65
+ (0, react.useEffect)(() => {
66
+ copilotkit.setErrorHandler(onError);
67
+ }, [copilotkit, onError]);
68
+ (0, react.useEffect)(() => {
69
+ copilotkit.ɵupdateConfig({
70
+ messageFilter,
71
+ runtimeUrl: resolvedConfig.runtimeUrl,
72
+ runtimeTransport: resolvedConfig.runtimeTransport,
42
73
  headers: stableHeaders,
43
74
  credentials,
44
- messageFilter,
45
- properties: stableProperties,
46
- debug
75
+ properties: resolvedConfig.properties,
76
+ debug,
77
+ defaultThrottleMs
47
78
  });
48
- if (defaultThrottleMs !== void 0) instance.setDefaultThrottleMs(defaultThrottleMs);
49
- copilotkitRef.current = instance;
50
- }
51
- const copilotkit = copilotkitRef.current;
52
- (0, react.useEffect)(() => {
53
- copilotkit.setRuntimeUrl(runtimeUrl);
54
- copilotkit.setRuntimeTransport(useSingleEndpoint === true ? "single" : useSingleEndpoint === false ? "rest" : "auto");
55
- copilotkit.setHeaders(stableHeaders);
56
- copilotkit.setCredentials(credentials);
57
- copilotkit.setMessageFilter(messageFilter);
58
- copilotkit.setProperties(stableProperties);
59
- copilotkit.setDebug(debug);
79
+ copilotkit.connect();
60
80
  }, [
61
- runtimeUrl,
62
- useSingleEndpoint,
81
+ copilotkit,
82
+ messageFilter,
83
+ resolvedConfig.runtimeUrl,
84
+ resolvedConfig.runtimeTransport,
63
85
  stableHeaders,
64
86
  credentials,
65
- messageFilter,
66
- stableProperties,
87
+ resolvedConfig.properties,
67
88
  debug,
68
- copilotkit
89
+ defaultThrottleMs
69
90
  ]);
70
- (0, react.useEffect)(() => {
71
- copilotkit.setDefaultThrottleMs(defaultThrottleMs);
72
- }, [copilotkit, defaultThrottleMs]);
73
91
  const [executingToolCallIds, setExecutingToolCallIds] = (0, react.useState)(() => /* @__PURE__ */ new Set());
74
- const [runtimeLicenseStatus, setRuntimeLicenseStatus] = (0, react.useState)(void 0);
75
- const onErrorRef = (0, react.useRef)(onError);
92
+ const [runtimeInfo, setRuntimeInfo] = (0, react.useState)(null);
93
+ const runtimeLicenseStatus = runtimeInfo?.licenseStatus;
76
94
  (0, react.useEffect)(() => {
77
- onErrorRef.current = onError;
78
- }, [onError]);
95
+ const syncRuntimeInfo = () => setRuntimeInfo(copilotkit.ɵruntimeInfo);
96
+ const unsubscribe = copilotkit.ɵsubscribeToRuntimeInfo(syncRuntimeInfo);
97
+ syncRuntimeInfo();
98
+ return unsubscribe;
99
+ }, [copilotkit]);
79
100
  (0, react.useEffect)(() => {
80
101
  const subscription = copilotkit.subscribe({
81
102
  onToolExecutionStart: ({ toolCallId }) => {
@@ -93,13 +114,6 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp, creden
93
114
  next.delete(toolCallId);
94
115
  return next;
95
116
  });
96
- },
97
- onError: (event) => {
98
- if (onErrorRef.current) onErrorRef.current(event);
99
- else console.error(`[CopilotKit] Error (${event.code}):`, event.error, event.context ?? {});
100
- },
101
- onRuntimeConnectionStatusChanged: () => {
102
- setRuntimeLicenseStatus(copilotkit.licenseStatus);
103
117
  }
104
118
  });
105
119
  return () => subscription.unsubscribe();
@@ -120,12 +134,25 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp, creden
120
134
  })
121
135
  });
122
136
  };
137
+ /**
138
+ * Alias of {@link CopilotKitProvider}: the same component under its v1 name,
139
+ * so `<CopilotKit>` keeps working. `CopilotKitProvider` is the preferred name.
140
+ *
141
+ * @alias
142
+ */
143
+ const CopilotKit = CopilotKitProvider;
123
144
 
124
145
  //#endregion
146
+ Object.defineProperty(exports, 'CopilotKit', {
147
+ enumerable: true,
148
+ get: function () {
149
+ return CopilotKit;
150
+ }
151
+ });
125
152
  Object.defineProperty(exports, 'CopilotKitProvider', {
126
153
  enumerable: true,
127
154
  get: function () {
128
155
  return CopilotKitProvider;
129
156
  }
130
157
  });
131
- //# sourceMappingURL=CopilotKitProvider-Byw3cqe2.cjs.map
158
+ //# sourceMappingURL=CopilotKitProvider-QdcQrrSA.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CopilotKitProvider-QdcQrrSA.cjs","names":["CopilotKitCoreReact","CopilotKitContext","LicenseContext","MarkdownRendererProvider"],"sources":["../src/CopilotKitProvider.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useRef, useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport {\n CopilotKitContext,\n LicenseContext,\n} from \"@copilotkit/react-core/context\";\nimport type {\n CopilotKitContextValue,\n CopilotKitCoreReact as CopilotKitCoreReactInstance,\n} from \"@copilotkit/react-core/context\";\nimport {\n CopilotKitCoreReact,\n ɵuseOwnedCore,\n} from \"@copilotkit/react-core/headless\";\nimport type {\n ɵCopilotKitProviderBaseOptions,\n ɵRuntimeInfo,\n} from \"@copilotkit/core\";\nimport {\n ɵreportProviderConfigDiagnostics,\n ɵresolveProviderConfig,\n} from \"@copilotkit/core\";\nimport { createLicenseContextValue } from \"@copilotkit/shared\";\nimport { MarkdownRendererProvider } from \"./components/MarkdownRendererContext\";\nimport type { MarkdownRendererValue } from \"./components/MarkdownRendererContext\";\n\nexport interface CopilotKitNativeProviderProps extends Pick<\n ɵCopilotKitProviderBaseOptions,\n | \"credentials\"\n | \"messageFilter\"\n | \"useSingleEndpoint\"\n | \"properties\"\n | \"onError\"\n | \"debug\"\n | \"defaultThrottleMs\"\n> {\n children: ReactNode;\n /** URL of the CopilotKit runtime endpoint */\n runtimeUrl: string;\n /** Custom headers sent with every request */\n headers?: Record<string, string> | (() => Record<string, string>);\n /**\n * Custom markdown renderer for assistant messages. Either a component (escape\n * hatch — receives `content` and an optional `isStreaming` flag) used instead\n * of the built-in renderer, or a `{ style, animate }` config object to\n * configure the built-in React Native renderer (the `CopilotMarkdown` used by\n * the default `AssistantMessage`) without writing a wrapper.\n */\n markdownRenderer?: MarkdownRendererValue;\n // Cloud features (publicApiKey, licenseToken) — not yet supported on React Native\n}\n\n/**\n * CopilotKit provider for React Native.\n *\n * A lightweight alternative to the web CopilotKitProvider that avoids\n * web-only dependencies (DOM, CSS, Radix UI, Lit, etc).\n *\n * Polyfills are auto-imported when `@copilotkit/react-native` is loaded,\n * so a separate `import \"@copilotkit/react-native/polyfills\"` is no longer\n * required (though it remains available for advanced use).\n *\n * Usage:\n * ```tsx\n * import { CopilotKitProvider } from \"@copilotkit/react-native\";\n *\n * function App() {\n * return (\n * <CopilotKitProvider runtimeUrl=\"https://your-runtime/api/copilotkit\">\n * <ChatScreen />\n * </CopilotKitProvider>\n * );\n * }\n * ```\n */\nexport const CopilotKitProvider: React.FC<CopilotKitNativeProviderProps> = ({\n children,\n runtimeUrl,\n headers: headersProp,\n credentials,\n messageFilter,\n useSingleEndpoint,\n properties,\n onError,\n debug,\n defaultThrottleMs,\n markdownRenderer,\n}) => {\n // Resolve headers from function or static object (matches web provider pattern)\n const resolvedHeaders =\n typeof headersProp === \"function\" ? headersProp() : headersProp;\n\n // Stabilize headers/properties references to avoid effect churn when callers\n // pass inline object literals (e.g. headers={{}} or the undefined default).\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const stableHeaders = useMemo(\n () => resolvedHeaders ?? {},\n [JSON.stringify(resolvedHeaders)],\n );\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const stableProperties = useMemo(\n () => properties ?? {},\n [JSON.stringify(properties)],\n );\n\n // Transport mapping and config checks come from core.\n const resolvedConfig = useMemo(\n () =>\n ɵresolveProviderConfig({\n runtimeUrl,\n useSingleEndpoint,\n properties: stableProperties,\n }),\n [runtimeUrl, useSingleEndpoint, stableProperties],\n );\n const loggedDiagnosticsRef = useRef(new Set<string>());\n ɵreportProviderConfigDiagnostics(resolvedConfig.diagnostics, {\n isProduction: process.env.NODE_ENV === \"production\",\n logged: loggedDiagnosticsRef.current,\n });\n\n // One core for the provider lifetime, disposed on unmount (StrictMode\n // safe, see `ɵuseOwnedCore`).\n const copilotkitRef = useRef<CopilotKitCoreReactInstance | null>(null);\n const copilotkit = ɵuseOwnedCore(\n copilotkitRef,\n (): CopilotKitCoreReactInstance =>\n new CopilotKitCoreReact({\n runtimeUrl: resolvedConfig.runtimeUrl,\n runtimeTransport: resolvedConfig.runtimeTransport,\n // `/info` starts from the effect below, so a render React discards\n // never fetches it (#5801).\n deferInitialConnection: true,\n headers: stableHeaders,\n credentials,\n messageFilter,\n properties: resolvedConfig.properties,\n debug,\n // Set at construction so child hooks see it on their first render.\n defaultThrottleMs,\n onError,\n }),\n );\n\n // Core calls `onError`, and logs the error itself when there is none.\n useEffect(() => {\n copilotkit.setErrorHandler(onError);\n }, [copilotkit, onError]);\n\n // Sync props to the core. Core applies only what changed.\n useEffect(() => {\n copilotkit.ɵupdateConfig({\n messageFilter,\n runtimeUrl: resolvedConfig.runtimeUrl,\n runtimeTransport: resolvedConfig.runtimeTransport,\n headers: stableHeaders,\n credentials,\n properties: resolvedConfig.properties,\n debug,\n defaultThrottleMs,\n });\n copilotkit.connect();\n }, [\n copilotkit,\n messageFilter,\n resolvedConfig.runtimeUrl,\n resolvedConfig.runtimeTransport,\n stableHeaders,\n credentials,\n resolvedConfig.properties,\n debug,\n defaultThrottleMs,\n ]);\n\n // Track executing tool call IDs at the provider level.\n // Critical for HITL reconnection: onToolExecutionStart fires before child\n // components mount, so we must capture the state here.\n const [executingToolCallIds, setExecutingToolCallIds] = useState<\n ReadonlySet<string>\n >(() => new Set());\n\n const [runtimeInfo, setRuntimeInfo] = useState<ɵRuntimeInfo | null>(null);\n const runtimeLicenseStatus = runtimeInfo?.licenseStatus;\n\n // Project core's runtime info snapshot; the catch-up read reflects a status\n // that settled before this effect ran.\n useEffect(() => {\n const syncRuntimeInfo = () => setRuntimeInfo(copilotkit.ɵruntimeInfo);\n const unsubscribe = copilotkit.ɵsubscribeToRuntimeInfo(syncRuntimeInfo);\n syncRuntimeInfo();\n return unsubscribe;\n }, [copilotkit]);\n\n // Tool execution tracking.\n // Tool call IDs are tracked at the provider level because onToolExecutionStart\n // fires before child components mount — critical for HITL reconnection.\n useEffect(() => {\n const subscription = copilotkit.subscribe({\n onToolExecutionStart: ({ toolCallId }) => {\n setExecutingToolCallIds((prev) => {\n if (prev.has(toolCallId)) return prev;\n const next = new Set(prev);\n next.add(toolCallId);\n return next;\n });\n },\n onToolExecutionEnd: ({ toolCallId }) => {\n setExecutingToolCallIds((prev) => {\n if (!prev.has(toolCallId)) return prev;\n const next = new Set(prev);\n next.delete(toolCallId);\n return next;\n });\n },\n });\n return () => subscription.unsubscribe();\n }, [copilotkit]);\n\n const contextValue: CopilotKitContextValue = useMemo(\n () => ({\n copilotkit,\n executingToolCallIds,\n }),\n [copilotkit, executingToolCallIds],\n );\n\n // License context — driven by server-reported status via /info endpoint\n const licenseContextValue = useMemo(\n () => createLicenseContextValue(runtimeLicenseStatus),\n [runtimeLicenseStatus],\n );\n\n return (\n <CopilotKitContext.Provider value={contextValue}>\n <LicenseContext.Provider value={licenseContextValue}>\n <MarkdownRendererProvider renderer={markdownRenderer}>\n {children}\n </MarkdownRendererProvider>\n </LicenseContext.Provider>\n </CopilotKitContext.Provider>\n );\n};\n\n/**\n * Alias of {@link CopilotKitProvider}: the same component under its v1 name,\n * so `<CopilotKit>` keeps working. `CopilotKitProvider` is the preferred name.\n *\n * @alias\n */\nexport const CopilotKit = CopilotKitProvider;\n\n/**\n * Alias of {@link CopilotKitNativeProviderProps}, the props of\n * {@link CopilotKit}. Prefer `CopilotKitProviderProps` in new code.\n */\nexport type CopilotKitProps = CopilotKitNativeProviderProps;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2EA,MAAa,sBAA+D,EAC1E,UACA,YACA,SAAS,aACT,aACA,eACA,mBACA,YACA,SACA,OACA,mBACA,uBACI;CAEJ,MAAM,kBACJ,OAAO,gBAAgB,aAAa,aAAa,GAAG;CAKtD,MAAM,yCACE,mBAAmB,EAAE,EAC3B,CAAC,KAAK,UAAU,gBAAgB,CAAC,CAClC;CAED,MAAM,4CACE,cAAc,EAAE,EACtB,CAAC,KAAK,UAAU,WAAW,CAAC,CAC7B;CAGD,MAAM,uFAEqB;EACrB;EACA;EACA,YAAY;EACb,CAAC,EACJ;EAAC;EAAY;EAAmB;EAAiB,CAClD;CACD,MAAM,yDAA8B,IAAI,KAAa,CAAC;AACtD,wDAAiC,eAAe,aAAa;EAC3D,cAAc,QAAQ,IAAI,aAAa;EACvC,QAAQ,qBAAqB;EAC9B,CAAC;CAKF,MAAM,kFAD2D,KAAK,QAIlE,IAAIA,oDAAoB;EACtB,YAAY,eAAe;EAC3B,kBAAkB,eAAe;EAGjC,wBAAwB;EACxB,SAAS;EACT;EACA;EACA,YAAY,eAAe;EAC3B;EAEA;EACA;EACD,CAAC,CACL;AAGD,4BAAgB;AACd,aAAW,gBAAgB,QAAQ;IAClC,CAAC,YAAY,QAAQ,CAAC;AAGzB,4BAAgB;AACd,aAAW,cAAc;GACvB;GACA,YAAY,eAAe;GAC3B,kBAAkB,eAAe;GACjC,SAAS;GACT;GACA,YAAY,eAAe;GAC3B;GACA;GACD,CAAC;AACF,aAAW,SAAS;IACnB;EACD;EACA;EACA,eAAe;EACf,eAAe;EACf;EACA;EACA,eAAe;EACf;EACA;EACD,CAAC;CAKF,MAAM,CAAC,sBAAsB,qEAErB,IAAI,KAAK,CAAC;CAElB,MAAM,CAAC,aAAa,sCAAgD,KAAK;CACzE,MAAM,uBAAuB,aAAa;AAI1C,4BAAgB;EACd,MAAM,wBAAwB,eAAe,WAAW,aAAa;EACrE,MAAM,cAAc,WAAW,wBAAwB,gBAAgB;AACvE,mBAAiB;AACjB,SAAO;IACN,CAAC,WAAW,CAAC;AAKhB,4BAAgB;EACd,MAAM,eAAe,WAAW,UAAU;GACxC,uBAAuB,EAAE,iBAAiB;AACxC,6BAAyB,SAAS;AAChC,SAAI,KAAK,IAAI,WAAW,CAAE,QAAO;KACjC,MAAM,OAAO,IAAI,IAAI,KAAK;AAC1B,UAAK,IAAI,WAAW;AACpB,YAAO;MACP;;GAEJ,qBAAqB,EAAE,iBAAiB;AACtC,6BAAyB,SAAS;AAChC,SAAI,CAAC,KAAK,IAAI,WAAW,CAAE,QAAO;KAClC,MAAM,OAAO,IAAI,IAAI,KAAK;AAC1B,UAAK,OAAO,WAAW;AACvB,YAAO;MACP;;GAEL,CAAC;AACF,eAAa,aAAa,aAAa;IACtC,CAAC,WAAW,CAAC;CAEhB,MAAM,yCACG;EACL;EACA;EACD,GACD,CAAC,YAAY,qBAAqB,CACnC;CAGD,MAAM,iGAC4B,qBAAqB,EACrD,CAAC,qBAAqB,CACvB;AAED,QACE,2CAACC,iDAAkB;EAAS,OAAO;YACjC,2CAACC,8CAAe;GAAS,OAAO;aAC9B,2CAACC;IAAyB,UAAU;IACjC;KACwB;IACH;GACC;;;;;;;;AAUjC,MAAa,aAAa"}
@@ -1,9 +1,9 @@
1
- const require_MarkdownRendererContext = require('./MarkdownRendererContext-BRNe808d.cjs');
1
+ const require_chunk = require('./chunk-C0xms8kb.cjs');
2
2
  let react = require("react");
3
- react = require_MarkdownRendererContext.__toESM(react);
3
+ react = require_chunk.__toESM(react);
4
4
  let react_jsx_runtime = require("react/jsx-runtime");
5
- let _copilotkit_markdown_renderer_react_native = require("@copilotkit/markdown-renderer/react-native");
6
- let _copilotkit_markdown_renderer = require("@copilotkit/markdown-renderer");
5
+ let _copilotkit_markdown_react_native = require("@copilotkit/markdown/react-native");
6
+ let _copilotkit_markdown = require("@copilotkit/markdown");
7
7
 
8
8
  //#region src/components/Markdown.tsx
9
9
  /**
@@ -12,12 +12,12 @@ let _copilotkit_markdown_renderer = require("@copilotkit/markdown-renderer");
12
12
  * @public
13
13
  */
14
14
  const defaultMarkdownStyles = {
15
- ..._copilotkit_markdown_renderer_react_native.defaultMarkdownStyles,
16
- code: _copilotkit_markdown_renderer_react_native.defaultMarkdownStyles.inlineCode
15
+ ..._copilotkit_markdown_react_native.defaultMarkdownStyles,
16
+ code: _copilotkit_markdown_react_native.defaultMarkdownStyles.inlineCode
17
17
  };
18
18
  /**
19
19
  * GFM markdown renderer for React Native. Delegates to the shared
20
- * `StreamingMarkdownRenderer` from `@copilotkit/markdown-renderer/react-native`.
20
+ * `StreamingMarkdownRenderer` from `@copilotkit/markdown/react-native`.
21
21
  *
22
22
  * Public API is backward-compatible with the previous basic renderer:
23
23
  * - `CopilotMarkdownProps` — same shape.
@@ -27,7 +27,7 @@ const defaultMarkdownStyles = {
27
27
  * @public
28
28
  */
29
29
  function CopilotMarkdown({ content, style, streamingAnimation = false }) {
30
- (0, _copilotkit_markdown_renderer.warnUnsupportedRichSyntaxOnce)(content);
30
+ (0, _copilotkit_markdown.warnUnsupportedRichSyntaxOnce)(content);
31
31
  let resolvedStyle = style;
32
32
  if (style?.code !== void 0) {
33
33
  const { code, ...rest } = style;
@@ -36,7 +36,7 @@ function CopilotMarkdown({ content, style, streamingAnimation = false }) {
36
36
  inlineCode: rest.inlineCode ?? code
37
37
  };
38
38
  }
39
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_copilotkit_markdown_renderer_react_native.StreamingMarkdownRenderer, {
39
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_copilotkit_markdown_react_native.StreamingMarkdownRenderer, {
40
40
  content,
41
41
  isComplete: true,
42
42
  style: resolvedStyle,
@@ -57,4 +57,4 @@ Object.defineProperty(exports, 'defaultMarkdownStyles', {
57
57
  return defaultMarkdownStyles;
58
58
  }
59
59
  });
60
- //# sourceMappingURL=Markdown-C_9Re36O.cjs.map
60
+ //# sourceMappingURL=Markdown-DLopAh5W.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Markdown-DLopAh5W.cjs","names":["_streamingDefaultStyles","StreamingMarkdownRenderer"],"sources":["../src/components/Markdown.tsx"],"sourcesContent":["import React from \"react\";\nimport {\n StreamingMarkdownRenderer,\n defaultMarkdownStyles as _streamingDefaultStyles,\n} from \"@copilotkit/markdown/react-native\";\nimport type { MarkdownStyle as StreamingMarkdownStyle } from \"@copilotkit/markdown/react-native\";\nimport { warnUnsupportedRichSyntaxOnce } from \"@copilotkit/markdown\";\n\n/**\n * Style map for CopilotMarkdown. Each key maps a node type to a React Native\n * style object. Extends the streaming renderer's style keys with a `code`\n * shorthand kept for backward compatibility (`list` already exists on the\n * base style and needs no alias).\n *\n * @public\n */\nexport type MarkdownStyle = StreamingMarkdownStyle & {\n /** Alias for `inlineCode`; kept for backward compatibility. */\n code?: Record<string, unknown>;\n};\n\n/**\n * Default styles that ship with CopilotMarkdown.\n *\n * @public\n */\nexport const defaultMarkdownStyles: MarkdownStyle = {\n ..._streamingDefaultStyles,\n // Back-compat alias: `code` = same as `inlineCode`\n code: _streamingDefaultStyles.inlineCode,\n};\n\nexport interface CopilotMarkdownProps {\n content: string;\n style?: MarkdownStyle;\n /**\n * Toggles `Intl.Segmenter`-based token segmentation in the parser. Defaults\n * to `false` (Hermes-safe: no Segmenter needed). Note: the React Native\n * renderer renders text directly and does not perform per-token fade-in\n * animation, so this currently has no visual effect — it is accepted for\n * backward compatibility.\n */\n streamingAnimation?: boolean;\n}\n\n/**\n * GFM markdown renderer for React Native. Delegates to the shared\n * `StreamingMarkdownRenderer` from `@copilotkit/markdown/react-native`.\n *\n * Public API is backward-compatible with the previous basic renderer:\n * - `CopilotMarkdownProps` — same shape.\n * - `MarkdownStyle` / `defaultMarkdownStyles` — same exports.\n * - `streamingAnimation` maps to `animate` (defaults `false` = Hermes-safe).\n *\n * @public\n */\nexport function CopilotMarkdown({\n content,\n style,\n streamingAnimation = false,\n}: CopilotMarkdownProps): React.ReactElement | null {\n // Translate the back-compat `code` alias onto `inlineCode` — the key the\n // streaming renderer actually reads. Without this, a caller migrating from\n // the previous renderer who passes `style={{ code: ... }}` would silently\n // lose inline-code styling. An explicit `inlineCode` wins over the alias.\n // Dev-only: nudge upgraders from the bundled Streamdown default when their\n // content needs math/syntax highlighting the built-in renderer doesn't do.\n warnUnsupportedRichSyntaxOnce(content);\n\n let resolvedStyle = style as StreamingMarkdownStyle | undefined;\n if (style?.code !== undefined) {\n const { code, ...rest } = style;\n resolvedStyle = {\n ...(rest as StreamingMarkdownStyle),\n inlineCode: (rest as StreamingMarkdownStyle).inlineCode ?? code,\n };\n }\n return (\n <StreamingMarkdownRenderer\n content={content}\n isComplete={true}\n style={resolvedStyle}\n animate={streamingAnimation}\n />\n );\n}\n"],"mappings":";;;;;;;;;;;;;AA0BA,MAAa,wBAAuC;CAClD,GAAGA;CAEH,MAAMA,wDAAwB;CAC/B;;;;;;;;;;;;AA0BD,SAAgB,gBAAgB,EAC9B,SACA,OACA,qBAAqB,SAC6B;AAOlD,yDAA8B,QAAQ;CAEtC,IAAI,gBAAgB;AACpB,KAAI,OAAO,SAAS,QAAW;EAC7B,MAAM,EAAE,MAAM,GAAG,SAAS;AAC1B,kBAAgB;GACd,GAAI;GACJ,YAAa,KAAgC,cAAc;GAC5D;;AAEH,QACE,2CAACC;EACU;EACT,YAAY;EACZ,OAAO;EACP,SAAS;GACT"}
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { MarkdownStyle } from "@copilotkit/markdown-renderer/react-native";
2
+ import { MarkdownStyle } from "@copilotkit/markdown/react-native";
3
3
 
4
4
  //#region src/components/Markdown.d.ts
5
5
  /**
@@ -33,7 +33,7 @@ interface CopilotMarkdownProps {
33
33
  }
34
34
  /**
35
35
  * GFM markdown renderer for React Native. Delegates to the shared
36
- * `StreamingMarkdownRenderer` from `@copilotkit/markdown-renderer/react-native`.
36
+ * `StreamingMarkdownRenderer` from `@copilotkit/markdown/react-native`.
37
37
  *
38
38
  * Public API is backward-compatible with the previous basic renderer:
39
39
  * - `CopilotMarkdownProps` — same shape.
@@ -49,4 +49,4 @@ declare function CopilotMarkdown({
49
49
  }: CopilotMarkdownProps): React.ReactElement | null;
50
50
  //#endregion
51
51
  export { defaultMarkdownStyles$1 as i, CopilotMarkdownProps as n, MarkdownStyle$1 as r, CopilotMarkdown as t };
52
- //# sourceMappingURL=Markdown-JsYh7oSA.d.mts.map
52
+ //# sourceMappingURL=Markdown-Du-b_Qpr.d.mts.map
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { MarkdownStyle } from "@copilotkit/markdown-renderer/react-native";
2
+ import { MarkdownStyle } from "@copilotkit/markdown/react-native";
3
3
 
4
4
  //#region src/components/Markdown.d.ts
5
5
  /**
@@ -33,7 +33,7 @@ interface CopilotMarkdownProps {
33
33
  }
34
34
  /**
35
35
  * GFM markdown renderer for React Native. Delegates to the shared
36
- * `StreamingMarkdownRenderer` from `@copilotkit/markdown-renderer/react-native`.
36
+ * `StreamingMarkdownRenderer` from `@copilotkit/markdown/react-native`.
37
37
  *
38
38
  * Public API is backward-compatible with the previous basic renderer:
39
39
  * - `CopilotMarkdownProps` — same shape.
@@ -49,4 +49,4 @@ declare function CopilotMarkdown({
49
49
  }: CopilotMarkdownProps): React.ReactElement | null;
50
50
  //#endregion
51
51
  export { defaultMarkdownStyles as i, CopilotMarkdownProps as n, MarkdownStyle$1 as r, CopilotMarkdown as t };
52
- //# sourceMappingURL=Markdown-1ips7myr.d.cts.map
52
+ //# sourceMappingURL=Markdown-UXZdDjzs.d.cts.map
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
  import { jsx } from "react/jsx-runtime";
3
- import { StreamingMarkdownRenderer, defaultMarkdownStyles } from "@copilotkit/markdown-renderer/react-native";
4
- import { warnUnsupportedRichSyntaxOnce } from "@copilotkit/markdown-renderer";
3
+ import { StreamingMarkdownRenderer, defaultMarkdownStyles } from "@copilotkit/markdown/react-native";
4
+ import { warnUnsupportedRichSyntaxOnce } from "@copilotkit/markdown";
5
5
 
6
6
  //#region src/components/Markdown.tsx
7
7
  /**
@@ -15,7 +15,7 @@ const defaultMarkdownStyles$1 = {
15
15
  };
16
16
  /**
17
17
  * GFM markdown renderer for React Native. Delegates to the shared
18
- * `StreamingMarkdownRenderer` from `@copilotkit/markdown-renderer/react-native`.
18
+ * `StreamingMarkdownRenderer` from `@copilotkit/markdown/react-native`.
19
19
  *
20
20
  * Public API is backward-compatible with the previous basic renderer:
21
21
  * - `CopilotMarkdownProps` — same shape.
@@ -44,4 +44,4 @@ function CopilotMarkdown({ content, style, streamingAnimation = false }) {
44
44
 
45
45
  //#endregion
46
46
  export { defaultMarkdownStyles$1 as n, CopilotMarkdown as t };
47
- //# sourceMappingURL=Markdown-C6AsLHmd.mjs.map
47
+ //# sourceMappingURL=Markdown-VxtPJ_yh.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Markdown-VxtPJ_yh.mjs","names":["defaultMarkdownStyles","_streamingDefaultStyles"],"sources":["../src/components/Markdown.tsx"],"sourcesContent":["import React from \"react\";\nimport {\n StreamingMarkdownRenderer,\n defaultMarkdownStyles as _streamingDefaultStyles,\n} from \"@copilotkit/markdown/react-native\";\nimport type { MarkdownStyle as StreamingMarkdownStyle } from \"@copilotkit/markdown/react-native\";\nimport { warnUnsupportedRichSyntaxOnce } from \"@copilotkit/markdown\";\n\n/**\n * Style map for CopilotMarkdown. Each key maps a node type to a React Native\n * style object. Extends the streaming renderer's style keys with a `code`\n * shorthand kept for backward compatibility (`list` already exists on the\n * base style and needs no alias).\n *\n * @public\n */\nexport type MarkdownStyle = StreamingMarkdownStyle & {\n /** Alias for `inlineCode`; kept for backward compatibility. */\n code?: Record<string, unknown>;\n};\n\n/**\n * Default styles that ship with CopilotMarkdown.\n *\n * @public\n */\nexport const defaultMarkdownStyles: MarkdownStyle = {\n ..._streamingDefaultStyles,\n // Back-compat alias: `code` = same as `inlineCode`\n code: _streamingDefaultStyles.inlineCode,\n};\n\nexport interface CopilotMarkdownProps {\n content: string;\n style?: MarkdownStyle;\n /**\n * Toggles `Intl.Segmenter`-based token segmentation in the parser. Defaults\n * to `false` (Hermes-safe: no Segmenter needed). Note: the React Native\n * renderer renders text directly and does not perform per-token fade-in\n * animation, so this currently has no visual effect — it is accepted for\n * backward compatibility.\n */\n streamingAnimation?: boolean;\n}\n\n/**\n * GFM markdown renderer for React Native. Delegates to the shared\n * `StreamingMarkdownRenderer` from `@copilotkit/markdown/react-native`.\n *\n * Public API is backward-compatible with the previous basic renderer:\n * - `CopilotMarkdownProps` — same shape.\n * - `MarkdownStyle` / `defaultMarkdownStyles` — same exports.\n * - `streamingAnimation` maps to `animate` (defaults `false` = Hermes-safe).\n *\n * @public\n */\nexport function CopilotMarkdown({\n content,\n style,\n streamingAnimation = false,\n}: CopilotMarkdownProps): React.ReactElement | null {\n // Translate the back-compat `code` alias onto `inlineCode` — the key the\n // streaming renderer actually reads. Without this, a caller migrating from\n // the previous renderer who passes `style={{ code: ... }}` would silently\n // lose inline-code styling. An explicit `inlineCode` wins over the alias.\n // Dev-only: nudge upgraders from the bundled Streamdown default when their\n // content needs math/syntax highlighting the built-in renderer doesn't do.\n warnUnsupportedRichSyntaxOnce(content);\n\n let resolvedStyle = style as StreamingMarkdownStyle | undefined;\n if (style?.code !== undefined) {\n const { code, ...rest } = style;\n resolvedStyle = {\n ...(rest as StreamingMarkdownStyle),\n inlineCode: (rest as StreamingMarkdownStyle).inlineCode ?? code,\n };\n }\n return (\n <StreamingMarkdownRenderer\n content={content}\n isComplete={true}\n style={resolvedStyle}\n animate={streamingAnimation}\n />\n );\n}\n"],"mappings":";;;;;;;;;;;AA0BA,MAAaA,0BAAuC;CAClD,GAAGC;CAEH,MAAMA,sBAAwB;CAC/B;;;;;;;;;;;;AA0BD,SAAgB,gBAAgB,EAC9B,SACA,OACA,qBAAqB,SAC6B;AAOlD,+BAA8B,QAAQ;CAEtC,IAAI,gBAAgB;AACpB,KAAI,OAAO,SAAS,QAAW;EAC7B,MAAM,EAAE,MAAM,GAAG,SAAS;AAC1B,kBAAgB;GACd,GAAI;GACJ,YAAa,KAAgC,cAAc;GAC5D;;AAEH,QACE,oBAAC;EACU;EACT,YAAY;EACZ,OAAO;EACP,SAAS;GACT"}
@@ -18,4 +18,4 @@ function useMarkdownRenderer() {
18
18
 
19
19
  //#endregion
20
20
  export { isNativeComponentRenderer as n, useMarkdownRenderer as r, MarkdownRendererProvider as t };
21
- //# sourceMappingURL=MarkdownRendererContext-CAnuohIS.mjs.map
21
+ //# sourceMappingURL=MarkdownRendererContext-EobUsERg.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"MarkdownRendererContext-CAnuohIS.mjs","names":[],"sources":["../src/components/MarkdownRendererContext.tsx"],"sourcesContent":["import React, { createContext, useContext } from \"react\";\nimport type { MarkdownStyle } from \"./Markdown\";\n\nexport interface NativeMarkdownRendererProps {\n content: string;\n isStreaming?: boolean;\n}\n\nexport type NativeMarkdownRenderer =\n React.ComponentType<NativeMarkdownRendererProps>;\n\n/** Config for the built-in RN renderer (pass instead of a component). */\nexport interface DefaultMarkdownRendererProps {\n style?: MarkdownStyle;\n animate?: boolean;\n}\nexport type MarkdownRendererValue =\n | NativeMarkdownRenderer\n | DefaultMarkdownRendererProps;\n\n/** A component is a function or an object carrying React's `$$typeof` (forwardRef/memo). */\nexport function isNativeComponentRenderer(\n value: unknown,\n): value is NativeMarkdownRenderer {\n if (typeof value === \"function\") return true;\n return !!value && typeof value === \"object\" && \"$$typeof\" in value;\n}\n\nconst Ctx = createContext<MarkdownRendererValue | undefined>(undefined);\n\nexport const MarkdownRendererProvider: React.FC<{\n renderer?: MarkdownRendererValue;\n children: React.ReactNode;\n}> = ({ renderer, children }) => (\n <Ctx.Provider value={renderer}>{children}</Ctx.Provider>\n);\n\nexport function useMarkdownRenderer(): MarkdownRendererValue | undefined {\n return useContext(Ctx);\n}\n"],"mappings":";;;;;AAqBA,SAAgB,0BACd,OACiC;AACjC,KAAI,OAAO,UAAU,WAAY,QAAO;AACxC,QAAO,CAAC,CAAC,SAAS,OAAO,UAAU,YAAY,cAAc;;AAG/D,MAAM,MAAM,cAAiD,OAAU;AAEvE,MAAa,4BAGP,EAAE,UAAU,eAChB,oBAAC,IAAI;CAAS,OAAO;CAAW;EAAwB;AAG1D,SAAgB,sBAAyD;AACvE,QAAO,WAAW,IAAI"}
1
+ {"version":3,"file":"MarkdownRendererContext-EobUsERg.mjs","names":[],"sources":["../src/components/MarkdownRendererContext.tsx"],"sourcesContent":["import React, { createContext, useContext } from \"react\";\nimport type { MarkdownStyle } from \"./Markdown\";\n\nexport interface NativeMarkdownRendererProps {\n content: string;\n isStreaming?: boolean;\n}\n\nexport type NativeMarkdownRenderer =\n React.ComponentType<NativeMarkdownRendererProps>;\n\n/** Config for the built-in RN renderer (pass instead of a component). */\nexport interface DefaultMarkdownRendererProps {\n style?: MarkdownStyle;\n animate?: boolean;\n}\nexport type MarkdownRendererValue =\n | NativeMarkdownRenderer\n | DefaultMarkdownRendererProps;\n\n/** A component is a function or an object carrying React's `$$typeof` (forwardRef/memo). */\nexport function isNativeComponentRenderer(\n value: unknown,\n): value is NativeMarkdownRenderer {\n if (typeof value === \"function\") return true;\n return !!value && typeof value === \"object\" && \"$$typeof\" in value;\n}\n\nconst Ctx = createContext<MarkdownRendererValue | undefined>(undefined);\n\nexport const MarkdownRendererProvider: React.FC<{\n renderer?: MarkdownRendererValue;\n children: React.ReactNode;\n}> = ({ renderer, children }) => (\n <Ctx.Provider value={renderer}>{children}</Ctx.Provider>\n);\n\nexport function useMarkdownRenderer(): MarkdownRendererValue | undefined {\n return useContext(Ctx);\n}\n"],"mappings":";;;;;AAqBA,SAAgB,0BACd,OACiC;AACjC,KAAI,OAAO,UAAU,WAAY,QAAO;AACxC,QAAO,CAAC,CAAC,SAAS,OAAO,UAAU,YAAY,cAAc;;AAG/D,MAAM,MAAM,cAAiD,OAAU;AAEvE,MAAa,4BAGP,EAAE,UAAU,eAChB,oBAAC,IAAI;CAAS,OAAO;CAAW;EAAwB;AAG1D,SAAgB,sBAAyD;AACvE,QAAO,WAAW,IAAI"}
@@ -0,0 +1,40 @@
1
+ const require_chunk = require('./chunk-C0xms8kb.cjs');
2
+ let react = require("react");
3
+ react = require_chunk.__toESM(react);
4
+ let react_jsx_runtime = require("react/jsx-runtime");
5
+
6
+ //#region src/components/MarkdownRendererContext.tsx
7
+ /** A component is a function or an object carrying React's `$$typeof` (forwardRef/memo). */
8
+ function isNativeComponentRenderer(value) {
9
+ if (typeof value === "function") return true;
10
+ return !!value && typeof value === "object" && "$$typeof" in value;
11
+ }
12
+ const Ctx = (0, react.createContext)(void 0);
13
+ const MarkdownRendererProvider = ({ renderer, children }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Ctx.Provider, {
14
+ value: renderer,
15
+ children
16
+ });
17
+ function useMarkdownRenderer() {
18
+ return (0, react.useContext)(Ctx);
19
+ }
20
+
21
+ //#endregion
22
+ Object.defineProperty(exports, 'MarkdownRendererProvider', {
23
+ enumerable: true,
24
+ get: function () {
25
+ return MarkdownRendererProvider;
26
+ }
27
+ });
28
+ Object.defineProperty(exports, 'isNativeComponentRenderer', {
29
+ enumerable: true,
30
+ get: function () {
31
+ return isNativeComponentRenderer;
32
+ }
33
+ });
34
+ Object.defineProperty(exports, 'useMarkdownRenderer', {
35
+ enumerable: true,
36
+ get: function () {
37
+ return useMarkdownRenderer;
38
+ }
39
+ });
40
+ //# sourceMappingURL=MarkdownRendererContext-cDEHvbw9.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"MarkdownRendererContext-BRNe808d.cjs","names":[],"sources":["../src/components/MarkdownRendererContext.tsx"],"sourcesContent":["import React, { createContext, useContext } from \"react\";\nimport type { MarkdownStyle } from \"./Markdown\";\n\nexport interface NativeMarkdownRendererProps {\n content: string;\n isStreaming?: boolean;\n}\n\nexport type NativeMarkdownRenderer =\n React.ComponentType<NativeMarkdownRendererProps>;\n\n/** Config for the built-in RN renderer (pass instead of a component). */\nexport interface DefaultMarkdownRendererProps {\n style?: MarkdownStyle;\n animate?: boolean;\n}\nexport type MarkdownRendererValue =\n | NativeMarkdownRenderer\n | DefaultMarkdownRendererProps;\n\n/** A component is a function or an object carrying React's `$$typeof` (forwardRef/memo). */\nexport function isNativeComponentRenderer(\n value: unknown,\n): value is NativeMarkdownRenderer {\n if (typeof value === \"function\") return true;\n return !!value && typeof value === \"object\" && \"$$typeof\" in value;\n}\n\nconst Ctx = createContext<MarkdownRendererValue | undefined>(undefined);\n\nexport const MarkdownRendererProvider: React.FC<{\n renderer?: MarkdownRendererValue;\n children: React.ReactNode;\n}> = ({ renderer, children }) => (\n <Ctx.Provider value={renderer}>{children}</Ctx.Provider>\n);\n\nexport function useMarkdownRenderer(): MarkdownRendererValue | undefined {\n return useContext(Ctx);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBA,SAAgB,0BACd,OACiC;AACjC,KAAI,OAAO,UAAU,WAAY,QAAO;AACxC,QAAO,CAAC,CAAC,SAAS,OAAO,UAAU,YAAY,cAAc;;AAG/D,MAAM,+BAAuD,OAAU;AAEvE,MAAa,4BAGP,EAAE,UAAU,eAChB,2CAAC,IAAI;CAAS,OAAO;CAAW;EAAwB;AAG1D,SAAgB,sBAAyD;AACvE,8BAAkB,IAAI"}
1
+ {"version":3,"file":"MarkdownRendererContext-cDEHvbw9.cjs","names":[],"sources":["../src/components/MarkdownRendererContext.tsx"],"sourcesContent":["import React, { createContext, useContext } from \"react\";\nimport type { MarkdownStyle } from \"./Markdown\";\n\nexport interface NativeMarkdownRendererProps {\n content: string;\n isStreaming?: boolean;\n}\n\nexport type NativeMarkdownRenderer =\n React.ComponentType<NativeMarkdownRendererProps>;\n\n/** Config for the built-in RN renderer (pass instead of a component). */\nexport interface DefaultMarkdownRendererProps {\n style?: MarkdownStyle;\n animate?: boolean;\n}\nexport type MarkdownRendererValue =\n | NativeMarkdownRenderer\n | DefaultMarkdownRendererProps;\n\n/** A component is a function or an object carrying React's `$$typeof` (forwardRef/memo). */\nexport function isNativeComponentRenderer(\n value: unknown,\n): value is NativeMarkdownRenderer {\n if (typeof value === \"function\") return true;\n return !!value && typeof value === \"object\" && \"$$typeof\" in value;\n}\n\nconst Ctx = createContext<MarkdownRendererValue | undefined>(undefined);\n\nexport const MarkdownRendererProvider: React.FC<{\n renderer?: MarkdownRendererValue;\n children: React.ReactNode;\n}> = ({ renderer, children }) => (\n <Ctx.Provider value={renderer}>{children}</Ctx.Provider>\n);\n\nexport function useMarkdownRenderer(): MarkdownRendererValue | undefined {\n return useContext(Ctx);\n}\n"],"mappings":";;;;;;;AAqBA,SAAgB,0BACd,OACiC;AACjC,KAAI,OAAO,UAAU,WAAY,QAAO;AACxC,QAAO,CAAC,CAAC,SAAS,OAAO,UAAU,YAAY,cAAc;;AAG/D,MAAM,+BAAuD,OAAU;AAEvE,MAAa,4BAGP,EAAE,UAAU,eAChB,2CAAC,IAAI;CAAS,OAAO;CAAW;EAAwB;AAG1D,SAAgB,sBAAyD;AACvE,8BAAkB,IAAI"}