@runtypelabs/persona 4.25.0 → 4.26.1
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/animations/glyph-cycle.d.cts +1 -1
- package/dist/animations/glyph-cycle.d.ts +1 -1
- package/dist/animations/{types-Db61aI9J.d.cts → types-BwKTZhg9.d.cts} +14 -0
- package/dist/animations/{types-Db61aI9J.d.ts → types-BwKTZhg9.d.ts} +14 -0
- package/dist/animations/wipe.d.cts +1 -1
- package/dist/animations/wipe.d.ts +1 -1
- package/dist/animations-extra.d.cts +14 -0
- package/dist/animations-extra.d.ts +14 -0
- package/dist/approval-ui-QAKWNFNM.js +1 -0
- package/dist/approval-ui.cjs +2 -2
- package/dist/approval-ui.d.cts +186 -8
- package/dist/approval-ui.d.ts +186 -8
- package/dist/approval-ui.js +2 -2
- package/dist/{artifacts-ui-IGB5YKLO.js → artifacts-ui-NJGMM27I.js} +1 -1
- package/dist/artifacts-ui.cjs +4 -4
- package/dist/artifacts-ui.d.cts +186 -8
- package/dist/artifacts-ui.d.ts +186 -8
- package/dist/artifacts-ui.js +5 -5
- package/dist/chunk-2ANTRKTV.js +1 -0
- package/dist/chunk-4HPTPUC6.js +1 -0
- package/dist/chunk-6V3MNEKB.js +1 -0
- package/dist/chunk-GKPCIQPB.js +1 -0
- package/dist/chunk-HGUCGM3K.js +9 -0
- package/dist/chunk-IO5VVUKP.js +3 -0
- package/dist/chunk-J4J3Y2P2.js +1 -0
- package/dist/chunk-K6HKIP5K.js +1 -0
- package/dist/chunk-K7NA7G7J.js +1 -0
- package/dist/chunk-MXUTS3LB.js +1 -0
- package/dist/chunk-PDPVORUF.js +1 -0
- package/dist/chunk-QRKGQPU7.js +1 -0
- package/dist/chunk-S6PBWE75.js +1 -0
- package/dist/chunk-T7QM7YMF.js +1 -0
- package/dist/chunk-TR2H475E.js +1 -0
- package/dist/chunk-UPO4GUFC.js +1 -0
- package/dist/chunk-ZC66NAIR.js +1 -0
- package/dist/client-history-GOZWBDA5.js +1 -0
- package/dist/client-history.js +1 -0
- package/dist/client-stream-42FOI3EC.js +4 -0
- package/dist/client-stream.js +5 -0
- package/dist/codegen.cjs +1 -1
- package/dist/codegen.js +1 -1
- package/dist/context-mentions-E7HJYWO6.js +161 -0
- package/dist/{context-mentions-inline-I2RDEBAK.js → context-mentions-inline-QVESLW55.js} +1 -1
- package/dist/context-mentions.cjs +7 -7
- package/dist/context-mentions.d.cts +186 -8
- package/dist/context-mentions.d.ts +186 -8
- package/dist/context-mentions.js +8 -8
- package/dist/event-stream-view-FOIJHFQO.js +1 -0
- package/dist/event-stream-view.cjs +1 -1
- package/dist/event-stream-view.d.cts +189 -31
- package/dist/event-stream-view.d.ts +189 -31
- package/dist/event-stream-view.js +1 -1
- package/dist/forms-ui.d.cts +227 -667
- package/dist/forms-ui.d.ts +227 -667
- package/dist/history-shell-QDQ44PSE.js +3 -0
- package/dist/history-shell.js +3 -0
- package/dist/{history-view-BD6OXLNA.js → history-view-NCFBI5GR.js} +2 -2
- package/dist/history-view.cjs +2 -2
- package/dist/history-view.d.cts +35 -1
- package/dist/history-view.d.ts +35 -1
- package/dist/history-view.js +2 -2
- package/dist/index.cjs +80 -74
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +233 -738
- package/dist/index.d.ts +233 -738
- package/dist/index.global.js +3 -215
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +81 -75
- package/dist/index.js.map +1 -1
- package/dist/install.global.js +1 -1
- package/dist/install.global.js.map +1 -1
- package/dist/launcher.global.js +3 -67
- package/dist/launcher.global.js.map +1 -1
- package/dist/markdown-parsers.js +22 -22
- package/dist/runtype-tts-entry-NFBVWR7N.js +1 -0
- package/dist/runtype-tts.js +1 -1
- package/dist/session-actions-ISSKSI66.js +1 -0
- package/dist/session-actions.js +1 -0
- package/dist/session-reconnect.d.cts +186 -8
- package/dist/session-reconnect.d.ts +186 -8
- package/dist/smart-dom-reader.cjs +13 -13
- package/dist/smart-dom-reader.d.cts +186 -8
- package/dist/smart-dom-reader.d.ts +186 -8
- package/dist/smart-dom-reader.js +11 -11
- package/dist/theme-editor-preview.cjs +116 -98
- package/dist/theme-editor-preview.d.cts +188 -8
- package/dist/theme-editor-preview.d.ts +188 -8
- package/dist/theme-editor-preview.js +49 -54
- package/dist/theme-editor.cjs +2 -2
- package/dist/theme-editor.d.cts +187 -23
- package/dist/theme-editor.d.ts +187 -23
- package/dist/theme-editor.js +2 -2
- package/dist/theme-reference.d.cts +14 -0
- package/dist/theme-reference.d.ts +14 -0
- package/dist/ui-extras-entry-WAYFKVNW.js +3 -0
- package/dist/ui-extras.js +72 -0
- package/dist/voice-runtime-XLU6YK2N.js +17 -0
- package/dist/voice-runtime.cjs +17 -1
- package/dist/voice-runtime.d.cts +11656 -232
- package/dist/voice-runtime.d.ts +11656 -232
- package/dist/voice-runtime.js +17 -1
- package/dist/voice-worklet-player.cjs +19 -4
- package/dist/voice-worklet-player.d.cts +9 -10
- package/dist/voice-worklet-player.d.ts +9 -10
- package/dist/voice-worklet-player.js +19 -4
- package/dist/webmcp-polyfill.js +1 -1
- package/dist/webmcp-runtime-V6ZWW3PI.js +6 -0
- package/dist/webmcp-runtime.cjs +2 -2
- package/dist/webmcp-runtime.d.cts +1 -33
- package/dist/webmcp-runtime.d.ts +1 -33
- package/dist/webmcp-runtime.js +2 -2
- package/dist/widget.css +1 -1
- package/package.json +11 -5
- package/src/approval-paused-tool-settle.test.ts +325 -0
- package/src/client-approve.test.ts +311 -0
- package/src/client-history-eager.ts +9 -0
- package/src/client-history-loader.ts +23 -0
- package/src/client-history.ts +579 -0
- package/src/client-resume.ts +177 -0
- package/src/client-stream-eager.ts +12 -0
- package/src/client-stream-loader.ts +25 -0
- package/src/client-stream.ts +1880 -0
- package/src/client.test.ts +31 -1
- package/src/client.ts +293 -2607
- package/src/components/approval-actions.test.ts +27 -0
- package/src/components/approval-actions.ts +27 -3
- package/src/components/message-bubble.test.ts +19 -0
- package/src/components/message-bubble.ts +2 -0
- package/src/components/registry.ts +6 -6
- package/src/components/tool-bubble.test.ts +9 -0
- package/src/components/tool-bubble.ts +1 -0
- package/src/history-shell-bundle.test.ts +54 -0
- package/src/history-shell-eager.ts +12 -0
- package/src/history-shell-loader.ts +27 -0
- package/src/history-shell.ts +2362 -0
- package/src/history-view-loader.ts +2 -0
- package/src/history-view.ts +3 -0
- package/src/index-core.ts +6 -0
- package/src/index-global.ts +90 -248
- package/src/index.ts +13 -0
- package/src/install.ts +6 -4
- package/src/internal/runtype-history-provider.test.ts +1 -0
- package/src/internal/runtype-history-provider.ts +28 -13
- package/src/plugins/registry.ts +8 -8
- package/src/session-actions-chunk.test.ts +55 -0
- package/src/session-actions-eager.ts +11 -0
- package/src/session-actions-loader.ts +37 -0
- package/src/session-actions.ts +909 -0
- package/src/session-history.test.ts +3 -1
- package/src/session.ts +895 -1538
- package/src/session.voice.test.ts +1171 -5
- package/src/styles/widget.css +58 -0
- package/src/theme-editor/state.ts +91 -91
- package/src/types.ts +204 -5
- package/src/ui-ask-user-sheet.ts +382 -0
- package/src/ui-extras-eager.ts +10 -0
- package/src/ui-extras-entry.ts +9 -0
- package/src/ui-extras-loader.ts +26 -0
- package/src/ui.artifact-rail-resize.test.ts +2 -1
- package/src/ui.ask-user-chunk.test.ts +93 -0
- package/src/ui.history-chunk.test.ts +2 -1
- package/src/ui.history-config-provider.test.ts +2 -1
- package/src/ui.history-confirm-fallback.test.ts +142 -0
- package/src/ui.history-controller.test.ts +2 -1
- package/src/ui.history-lifecycle.test.ts +2 -1
- package/src/ui.history-render-hooks.test.ts +2 -1
- package/src/ui.history-shell.test.ts +2 -1
- package/src/ui.rail-overlay.test.ts +2 -1
- package/src/ui.rail-resize.test.ts +2 -1
- package/src/ui.rail-trigger-pending.test.ts +2 -1
- package/src/ui.ts +340 -2770
- package/src/utils/attachment-manager.ts +67 -67
- package/src/utils/constants.ts +3 -0
- package/src/utils/context-mention-controller.ts +323 -323
- package/src/utils/context-mention-manager.ts +40 -40
- package/src/utils/context-mention-orchestrator.ts +28 -0
- package/src/utils/event-stream-buffer.ts +50 -50
- package/src/utils/event-stream-store.ts +43 -43
- package/src/utils/throughput-tracker.ts +34 -34
- package/src/utils/virtual-scroller.ts +67 -67
- package/src/utils/visitor-store.test.ts +50 -0
- package/src/utils/visitor-store.ts +23 -5
- package/src/voice/__fixtures__/voice-wire/README.md +1 -0
- package/src/voice/__fixtures__/voice-wire/client/cancel.json +3 -0
- package/src/voice/__fixtures__/voice-wire/client/context.json +4 -0
- package/src/voice/__fixtures__/voice-wire/client/delegation_result.json +6 -0
- package/src/voice/__fixtures__/voice-wire/client/delegation_update.json +6 -0
- package/src/voice/__fixtures__/voice-wire/client/ping.json +3 -0
- package/src/voice/__fixtures__/voice-wire/client/playback_progress.json +5 -0
- package/src/voice/__fixtures__/voice-wire/client/start.json +3 -0
- package/src/voice/__fixtures__/voice-wire/server/artifact.json +11 -0
- package/src/voice/__fixtures__/voice-wire/server/attached.json +4 -0
- package/src/voice/__fixtures__/voice-wire/server/audio_clear.json +4 -0
- package/src/voice/__fixtures__/voice-wire/server/audio_end.json +3 -0
- package/src/voice/__fixtures__/voice-wire/server/delegation_cancelled.json +5 -0
- package/src/voice/__fixtures__/voice-wire/server/delegation_completed.json +8 -0
- package/src/voice/__fixtures__/voice-wire/server/delegation_started.json +15 -0
- package/src/voice/__fixtures__/voice-wire/server/error.json +6 -0
- package/src/voice/__fixtures__/voice-wire/server/metrics.json +10 -0
- package/src/voice/__fixtures__/voice-wire/server/pong.json +3 -0
- package/src/voice/__fixtures__/voice-wire/server/session_config.json +16 -0
- package/src/voice/__fixtures__/voice-wire/server/transcript_final.json +7 -0
- package/src/voice/__fixtures__/voice-wire/server/transcript_interim.json +4 -0
- package/src/voice/__fixtures__/voice-wire/server/transcript_partial.json +6 -0
- package/src/voice/__fixtures__/voice-wire/server/transcript_update.json +10 -0
- package/src/voice/__fixtures__/voice-wire/server/warning.json +5 -0
- package/src/voice/audio-playback-manager.test.ts +57 -0
- package/src/voice/audio-playback-manager.ts +120 -98
- package/src/voice/browser-voice-provider.ts +37 -37
- package/src/voice/fallback-speech-engine.ts +22 -16
- package/src/voice/keyed-voice-transcript.ts +314 -0
- package/src/voice/mic-state-styles.ts +182 -0
- package/src/voice/read-aloud-controller.ts +46 -44
- package/src/voice/runtype-speech-engine.ts +35 -33
- package/src/voice/runtype-voice-provider.ts +680 -189
- package/src/voice/session-voice-wiring.ts +266 -0
- package/src/voice/voice-delegation.test.ts +71 -0
- package/src/voice/voice-delegation.ts +364 -0
- package/src/voice/voice-turn-tracker.ts +6 -6
- package/src/voice/voice.test.ts +1060 -8
- package/src/voice/worklet-playback-engine.test.ts +81 -0
- package/src/voice/worklet-playback-engine.ts +21 -3
- package/src/voice-runtime-loader.ts +4 -1
- package/src/voice-runtime.ts +7 -0
- package/src/webmcp-runtime-entry.ts +41 -39
- package/dist/approval-ui-3NMYNXBD.js +0 -1
- package/dist/chunk-5EIIHQLQ.js +0 -1
- package/dist/chunk-7CO4T5KB.js +0 -1
- package/dist/chunk-EFJBUH5F.js +0 -1
- package/dist/chunk-R2TMIMDI.js +0 -3
- package/dist/chunk-UTVLOTWB.js +0 -9
- package/dist/context-mentions-45MODWOY.js +0 -161
- package/dist/event-stream-view-GL3ADRY2.js +0 -1
- package/dist/runtype-tts-entry-UJAEF7NZ.js +0 -1
- package/dist/voice-runtime-7DA7MJH4.js +0 -1
- package/dist/webmcp-runtime-JI7T4QYF.js +0 -6
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Approval decisions and LOCAL-tool resumes for `AgentWidgetClient`. Only
|
|
3
|
+
* the approval / ask-user-question / WebMCP resolve paths (themselves in the
|
|
4
|
+
* lazy `session-actions` chunk) call these, so the IIFE/CDN build ships them
|
|
5
|
+
* in the lazy `client-stream.js` chunk; the client's public methods keep
|
|
6
|
+
* their signatures and delegate here through a `ClientResumeHost`.
|
|
7
|
+
*/
|
|
8
|
+
import type {
|
|
9
|
+
AgentWidgetConfig,
|
|
10
|
+
AgentWidgetHeadersFunction,
|
|
11
|
+
ClientChatRequest,
|
|
12
|
+
ClientSession,
|
|
13
|
+
ClientToolDefinition
|
|
14
|
+
} from "./types";
|
|
15
|
+
import type { WebMcpBridge } from "./webmcp-runtime-entry";
|
|
16
|
+
import { builtInClientToolsForDispatch } from "./ask-user-question-tool";
|
|
17
|
+
import { DEFAULT_CLIENT_API_BASE } from "./utils/constants";
|
|
18
|
+
|
|
19
|
+
export type ClientResumeHost = {
|
|
20
|
+
readonly config: AgentWidgetConfig;
|
|
21
|
+
readonly headers: Record<string, string>;
|
|
22
|
+
readonly getHeaders?: AgentWidgetHeadersFunction;
|
|
23
|
+
readonly debug: boolean;
|
|
24
|
+
clientApiBase(): string;
|
|
25
|
+
getClientApiUrl(endpoint: "init" | "chat" | "resume"): string;
|
|
26
|
+
getWebMcpBridge(): Promise<WebMcpBridge | null>;
|
|
27
|
+
sendWithClientToolsDiff(
|
|
28
|
+
sessionId: string,
|
|
29
|
+
fullClientTools: ClientToolDefinition[] | undefined,
|
|
30
|
+
doFetch: (
|
|
31
|
+
toolFields: Pick<ClientChatRequest, "clientTools" | "clientToolsFingerprint">
|
|
32
|
+
) => Promise<Response>,
|
|
33
|
+
opts?: { emptyMeansReplace?: boolean }
|
|
34
|
+
): Promise<{ response: Response; commit: () => void }>;
|
|
35
|
+
initSession(): Promise<ClientSession>;
|
|
36
|
+
readVisitorToken(): Promise<string | null>;
|
|
37
|
+
isClientTokenMode(): boolean;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/** See `AgentWidgetClient.resolveApproval`. */
|
|
41
|
+
export async function resolveApproval(
|
|
42
|
+
h: ClientResumeHost,
|
|
43
|
+
approval: { agentId: string; executionId: string; approvalId: string },
|
|
44
|
+
decision: "approved" | "denied"
|
|
45
|
+
): Promise<Response> {
|
|
46
|
+
let headers: Record<string, string> = {
|
|
47
|
+
'Content-Type': 'application/json',
|
|
48
|
+
...h.headers
|
|
49
|
+
};
|
|
50
|
+
if (h.getHeaders) {
|
|
51
|
+
Object.assign(headers, await h.getHeaders());
|
|
52
|
+
}
|
|
53
|
+
const body = {
|
|
54
|
+
executionId: approval.executionId,
|
|
55
|
+
approvalId: approval.approvalId,
|
|
56
|
+
decision,
|
|
57
|
+
streamResponse: true,
|
|
58
|
+
};
|
|
59
|
+
const post = (path: string, extra?: Record<string, unknown>) =>
|
|
60
|
+
fetch(`${h.clientApiBase()}${path}`, {
|
|
61
|
+
method: 'POST',
|
|
62
|
+
headers,
|
|
63
|
+
body: JSON.stringify({ ...extra, ...body }),
|
|
64
|
+
});
|
|
65
|
+
const ownerRoute = `/v1/agents/${approval.agentId}/approve`;
|
|
66
|
+
|
|
67
|
+
if (!h.isClientTokenMode()) return post(ownerRoute);
|
|
68
|
+
|
|
69
|
+
// Same re-validation as `resumeFlow`: an approval can sit for a long time.
|
|
70
|
+
const { sessionId } = await h.initSession();
|
|
71
|
+
const response = await post('/v1/client/approve', { sessionId });
|
|
72
|
+
// A core without the route answers with its generic `Not Found`; an unknown
|
|
73
|
+
// or expired pause 404s with its own error, which the caller surfaces.
|
|
74
|
+
if (response.status === 404) {
|
|
75
|
+
const data = (await response.clone().json().catch(() => null)) as { error?: string } | null;
|
|
76
|
+
if (!data || data.error === 'Not Found') return post(ownerRoute);
|
|
77
|
+
}
|
|
78
|
+
return response;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** See `AgentWidgetClient.resumeFlow`. */
|
|
82
|
+
export async function resumeFlow(
|
|
83
|
+
h: ClientResumeHost,
|
|
84
|
+
executionId: string,
|
|
85
|
+
toolOutputs: Record<string, unknown>,
|
|
86
|
+
options?: { streamResponse?: boolean; signal?: AbortSignal; after?: string }
|
|
87
|
+
): Promise<Response> {
|
|
88
|
+
const isClientToken = h.isClientTokenMode();
|
|
89
|
+
const url = isClientToken
|
|
90
|
+
? h.getClientApiUrl('resume')
|
|
91
|
+
: `${h.config.apiUrl?.replace(/\/+$/, '') || DEFAULT_CLIENT_API_BASE}/resume`;
|
|
92
|
+
|
|
93
|
+
// The client-token resume route authenticates the session, not a Bearer
|
|
94
|
+
// key. A WebMCP approval can sit awaiting user input for a long time, so by
|
|
95
|
+
// the time we resume the original session may have expired. Re-validate (and
|
|
96
|
+
// silently re-init if needed) via initSession(): which returns the live
|
|
97
|
+
// session when `new Date() < expiresAt`, else mints a fresh one: instead of
|
|
98
|
+
// trusting the possibly-stale `this.clientSession`. (core#3889; BugBot
|
|
99
|
+
// PR #214 r3367875360.)
|
|
100
|
+
let resumeSessionId: string | undefined;
|
|
101
|
+
let resumeVisitorToken: string | null = null;
|
|
102
|
+
if (isClientToken) {
|
|
103
|
+
const session = await h.initSession();
|
|
104
|
+
resumeSessionId = session.sessionId;
|
|
105
|
+
if (session.durableRecovery?.enabled === true) {
|
|
106
|
+
resumeVisitorToken = await h.readVisitorToken();
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
let headers: Record<string, string> = {
|
|
111
|
+
'Content-Type': 'application/json',
|
|
112
|
+
...(resumeVisitorToken ? { 'X-Visitor-Token': resumeVisitorToken } : {}),
|
|
113
|
+
...h.headers
|
|
114
|
+
};
|
|
115
|
+
if (h.getHeaders) {
|
|
116
|
+
Object.assign(headers, await h.getHeaders());
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const body: Record<string, unknown> = {
|
|
120
|
+
executionId,
|
|
121
|
+
toolOutputs,
|
|
122
|
+
streamResponse: options?.streamResponse ?? true,
|
|
123
|
+
...(options?.after ? { after: options.after } : {}),
|
|
124
|
+
};
|
|
125
|
+
// Thread the (refreshed) sessionId through like `/v1/client/chat` does.
|
|
126
|
+
if (resumeSessionId) {
|
|
127
|
+
body.sessionId = resumeSessionId;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (isClientToken && resumeSessionId) {
|
|
131
|
+
// Mid-run WebMCP tool refresh (runtypelabs/core#5361): the paused tool
|
|
132
|
+
// may have navigated the page, so the dispatch-time snapshot the server
|
|
133
|
+
// persisted can be stale. Re-snapshot the registry — the same built-in +
|
|
134
|
+
// bridge composition as the payload builders, so fingerprints computed
|
|
135
|
+
// here and on chat turns describe the same tool space — and ship it via
|
|
136
|
+
// the shared diff-only protocol. `emptyMeansReplace` sends an explicit
|
|
137
|
+
// `clientTools: []` when the registry vanished after a non-empty send,
|
|
138
|
+
// so the server replaces the persisted set instead of keeping it frozen.
|
|
139
|
+
const fullClientTools = [
|
|
140
|
+
...builtInClientToolsForDispatch(h.config),
|
|
141
|
+
...((await (await h.getWebMcpBridge())?.snapshotForDispatch()) ?? []),
|
|
142
|
+
];
|
|
143
|
+
const { response, commit } = await h.sendWithClientToolsDiff(
|
|
144
|
+
resumeSessionId,
|
|
145
|
+
fullClientTools,
|
|
146
|
+
(toolFields) => {
|
|
147
|
+
const resumeRequest = { ...body, ...toolFields };
|
|
148
|
+
if (h.debug) {
|
|
149
|
+
// eslint-disable-next-line no-console
|
|
150
|
+
console.debug("[AgentWidgetClient] client token resume", resumeRequest);
|
|
151
|
+
}
|
|
152
|
+
return fetch(url, {
|
|
153
|
+
method: 'POST',
|
|
154
|
+
headers,
|
|
155
|
+
body: JSON.stringify(resumeRequest),
|
|
156
|
+
signal: options?.signal,
|
|
157
|
+
});
|
|
158
|
+
},
|
|
159
|
+
{ emptyMeansReplace: true }
|
|
160
|
+
);
|
|
161
|
+
// The server stores the refreshed registry before running the
|
|
162
|
+
// continuation pipeline, so an OK response means it holds this set under
|
|
163
|
+
// this fingerprint. Mirror chat's commit-on-success discipline: a failed
|
|
164
|
+
// resume must not record a fingerprint the server never stored.
|
|
165
|
+
if (response.ok) {
|
|
166
|
+
commit();
|
|
167
|
+
}
|
|
168
|
+
return response;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return fetch(url, {
|
|
172
|
+
method: 'POST',
|
|
173
|
+
headers,
|
|
174
|
+
body: JSON.stringify(body),
|
|
175
|
+
signal: options?.signal,
|
|
176
|
+
});
|
|
177
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Eager stream-processor registration for the bundled (ESM / CJS) builds.
|
|
3
|
+
*
|
|
4
|
+
* npm consumers bundle `client-stream.ts` anyway, so providing it up front
|
|
5
|
+
* keeps streaming free of the async chunk hop. Like
|
|
6
|
+
* `markdown-parsers-eager.ts`, this module must NOT be reachable from
|
|
7
|
+
* `index-global.ts`: the IIFE/CDN build fetches the `client-stream.js` chunk.
|
|
8
|
+
*/
|
|
9
|
+
import * as clientStream from "./client-stream";
|
|
10
|
+
import { provideClientStream } from "./client-stream-loader";
|
|
11
|
+
|
|
12
|
+
provideClientStream(clientStream);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createChunkLoader } from "./utils/chunk-loader";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Loader indirection for the SSE stream processor (`client-stream.ts`). The
|
|
5
|
+
* ESM/CJS fallback imports `./client-stream` directly (inlined by
|
|
6
|
+
* `--splitting false`); the IIFE/CDN build marks it external and registers a
|
|
7
|
+
* loader for the sibling `client-stream.js` chunk (see `index-global.ts`).
|
|
8
|
+
*/
|
|
9
|
+
export type ClientStreamModule = typeof import("./client-stream");
|
|
10
|
+
|
|
11
|
+
const { setLoader, load, provide, getSync } = createChunkLoader<ClientStreamModule>({
|
|
12
|
+
fallbackImport: () => import("./client-stream"),
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
/** Override how the chunk is fetched (the IIFE build registers a sibling-URL loader). */
|
|
16
|
+
export const setClientStreamLoader = setLoader;
|
|
17
|
+
|
|
18
|
+
/** Load the stream processor. Memoized; retries after rejection. */
|
|
19
|
+
export const loadClientStream = load;
|
|
20
|
+
|
|
21
|
+
/** Eagerly supply the module (`client-stream-eager.ts`: npm builds and tests). */
|
|
22
|
+
export const provideClientStream = provide;
|
|
23
|
+
|
|
24
|
+
/** Synchronous access once loaded/provided; null before that. */
|
|
25
|
+
export const getClientStreamSync = getSync;
|