@memoreco/ui 0.2.10 → 0.2.12
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/index.js +77 -43
- package/dist/index.mjs +4462 -3739
- package/dist/ui/src/components/chat/ChatPanel.d.ts +4 -0
- package/dist/ui/src/components/chat/MarkdownText.d.ts +10 -0
- package/dist/ui/src/components/chat/TimecodeTag.d.ts +16 -0
- package/dist/ui/src/components/chat/index.d.ts +17 -0
- package/dist/ui/src/components/chat/sse.d.ts +25 -0
- package/dist/ui/src/components/chat/storage.d.ts +22 -0
- package/dist/ui/src/components/chat/suggestions.d.ts +12 -0
- package/dist/ui/src/components/chat/time-utils.d.ts +19 -0
- package/dist/ui/src/components/chat/types.d.ts +138 -0
- package/dist/ui/src/components/toast.d.ts +1 -1
- package/dist/ui/src/index.d.ts +3 -1
- package/package.json +20 -19
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ChatPanelProps } from './types';
|
|
2
|
+
|
|
3
|
+
export declare function ChatPanel({ transport, language, storageKey, persist, playerReady, onPlayMoment, onAddToNotes, followUps, emptyStateTitle, emptyStateSubtitle, inputPlaceholder, variant, className, }: ChatPanelProps): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
export default ChatPanel;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface MarkdownTextProps {
|
|
2
|
+
/** Markdown content to render */
|
|
3
|
+
markdown: string;
|
|
4
|
+
/** Callback when a time reference is clicked */
|
|
5
|
+
onSeekToMoment: (seconds: number, endSeconds?: number) => void;
|
|
6
|
+
/** Size variant */
|
|
7
|
+
size?: "sm" | "md";
|
|
8
|
+
}
|
|
9
|
+
export declare function MarkdownText({ markdown, onSeekToMoment, size, }: MarkdownTextProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export default MarkdownText;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface TimecodeTagProps {
|
|
2
|
+
/** Display label (formatted timecode) */
|
|
3
|
+
label: string;
|
|
4
|
+
/** Start time in seconds */
|
|
5
|
+
seconds: number;
|
|
6
|
+
/** Optional end time in seconds (for time ranges) */
|
|
7
|
+
endSeconds?: number;
|
|
8
|
+
/** Whether the tag is disabled */
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
/** Click handler */
|
|
11
|
+
onClick: (seconds: number, endSeconds?: number) => void;
|
|
12
|
+
/** Size variant */
|
|
13
|
+
size?: "sm" | "md";
|
|
14
|
+
}
|
|
15
|
+
export declare function TimecodeTag({ label, seconds, endSeconds, disabled, onClick, size, }: TimecodeTagProps): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export default TimecodeTag;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chat Component Module
|
|
3
|
+
*
|
|
4
|
+
* Unified chat UI component for use across dashboard and web apps.
|
|
5
|
+
*/
|
|
6
|
+
export { ChatPanel } from './ChatPanel';
|
|
7
|
+
export { default as ChatPanelDefault } from './ChatPanel';
|
|
8
|
+
export { TimecodeTag } from './TimecodeTag';
|
|
9
|
+
export { MarkdownText } from './MarkdownText';
|
|
10
|
+
export { safeReadChatFromStorage, safeWriteChatToStorage, safeRemoveChatFromStorage, messagesToStored, storedToMessages, } from './storage';
|
|
11
|
+
export { parseSseEvent, readSseStream } from './sse';
|
|
12
|
+
export { parseTimecodeToSeconds, formatSecondsAsTimecode, linkifyTimeReferencesInMarkdown, } from './time-utils';
|
|
13
|
+
export { getDefaultSuggestions, getBrowserLanguage, DEFAULT_SUGGESTIONS } from './suggestions';
|
|
14
|
+
export type { ChatPanelProps, ChatTransport, ChatStreamRequest, ChatMessage, ChatResponse, ChatAnswerItem, ChatMoment, ChatSuggestion, StoredChatMessage, } from './types';
|
|
15
|
+
export type { TimecodeTagProps } from './TimecodeTag';
|
|
16
|
+
export type { MarkdownTextProps } from './MarkdownText';
|
|
17
|
+
export type { SSEEvent, SSEChunkEvent, SSECompleteEvent, SSEErrorEvent } from './sse';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SSE (Server-Sent Events) Parser
|
|
3
|
+
*
|
|
4
|
+
* Utilities for parsing SSE streams from chat endpoints.
|
|
5
|
+
*/
|
|
6
|
+
export interface SSEChunkEvent {
|
|
7
|
+
type: "chunk";
|
|
8
|
+
token: string;
|
|
9
|
+
}
|
|
10
|
+
export interface SSECompleteEvent {
|
|
11
|
+
type: "complete";
|
|
12
|
+
}
|
|
13
|
+
export interface SSEErrorEvent {
|
|
14
|
+
type: "error";
|
|
15
|
+
message: string;
|
|
16
|
+
}
|
|
17
|
+
export type SSEEvent = SSEChunkEvent | SSECompleteEvent | SSEErrorEvent;
|
|
18
|
+
/**
|
|
19
|
+
* Parse a raw SSE event string into a structured event.
|
|
20
|
+
*/
|
|
21
|
+
export declare function parseSseEvent(rawEvent: string): SSEEvent | null;
|
|
22
|
+
/**
|
|
23
|
+
* Read an SSE stream and yield parsed events.
|
|
24
|
+
*/
|
|
25
|
+
export declare function readSseStream(response: Response, signal: AbortSignal): AsyncGenerator<SSEEvent>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { StoredChatMessage, ChatMessage } from './types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Safely read chat history from localStorage.
|
|
5
|
+
*/
|
|
6
|
+
export declare function safeReadChatFromStorage(key: string): StoredChatMessage[] | null;
|
|
7
|
+
/**
|
|
8
|
+
* Safely write chat history to localStorage.
|
|
9
|
+
*/
|
|
10
|
+
export declare function safeWriteChatToStorage(key: string, value: StoredChatMessage[]): void;
|
|
11
|
+
/**
|
|
12
|
+
* Safely remove chat history from localStorage.
|
|
13
|
+
*/
|
|
14
|
+
export declare function safeRemoveChatFromStorage(key: string): void;
|
|
15
|
+
/**
|
|
16
|
+
* Convert ChatMessage array to StoredChatMessage array for persistence.
|
|
17
|
+
*/
|
|
18
|
+
export declare function messagesToStored(messages: ChatMessage[]): StoredChatMessage[];
|
|
19
|
+
/**
|
|
20
|
+
* Convert StoredChatMessage array to ChatMessage array.
|
|
21
|
+
*/
|
|
22
|
+
export declare function storedToMessages(stored: StoredChatMessage[]): ChatMessage[];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ChatSuggestion } from './types';
|
|
2
|
+
|
|
3
|
+
export declare const DEFAULT_SUGGESTIONS: Record<string, ChatSuggestion[]>;
|
|
4
|
+
/**
|
|
5
|
+
* Get default suggestions for a language.
|
|
6
|
+
* Falls back to English if the language is not supported.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getDefaultSuggestions(language: string): ChatSuggestion[];
|
|
9
|
+
/**
|
|
10
|
+
* Get browser language code (first two characters).
|
|
11
|
+
*/
|
|
12
|
+
export declare function getBrowserLanguage(): string;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Time/Timecode Utilities
|
|
3
|
+
*
|
|
4
|
+
* Parse and format timecodes for chat time references.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Parse a timecode string (MM:SS or HH:MM:SS) to seconds.
|
|
8
|
+
* Returns null if the timecode is invalid.
|
|
9
|
+
*/
|
|
10
|
+
export declare function parseTimecodeToSeconds(timecode: string): number | null;
|
|
11
|
+
/**
|
|
12
|
+
* Format seconds as a timecode string (MM:SS or H:MM:SS).
|
|
13
|
+
*/
|
|
14
|
+
export declare function formatSecondsAsTimecode(totalSeconds: number): string;
|
|
15
|
+
/**
|
|
16
|
+
* Convert time references in markdown text to hash links.
|
|
17
|
+
* Converts "00:33" to "[00:33](#t=33)" and "00:33 - 00:53" to "[00:33](#t=33&e=53)".
|
|
18
|
+
*/
|
|
19
|
+
export declare function linkifyTimeReferencesInMarkdown(markdown: string): string;
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared Chat Component Types
|
|
3
|
+
*
|
|
4
|
+
* Types shared across all chat implementations (dashboard, share, collection).
|
|
5
|
+
*/
|
|
6
|
+
export interface ChatMoment {
|
|
7
|
+
startSeconds: number;
|
|
8
|
+
endSeconds: number;
|
|
9
|
+
label: string;
|
|
10
|
+
modality?: "transcript" | "vision";
|
|
11
|
+
}
|
|
12
|
+
export interface ChatAnswerItem {
|
|
13
|
+
text: string;
|
|
14
|
+
moments: ChatMoment[];
|
|
15
|
+
}
|
|
16
|
+
export interface ChatResponse {
|
|
17
|
+
title?: string;
|
|
18
|
+
items: ChatAnswerItem[];
|
|
19
|
+
followUps: string[];
|
|
20
|
+
grounding: "embeddings" | "transcript_only";
|
|
21
|
+
language: string;
|
|
22
|
+
}
|
|
23
|
+
export interface ChatMessage {
|
|
24
|
+
role: "user" | "assistant";
|
|
25
|
+
content: string;
|
|
26
|
+
response?: ChatResponse;
|
|
27
|
+
status?: "thinking" | "streaming" | "complete";
|
|
28
|
+
timestamp: Date;
|
|
29
|
+
}
|
|
30
|
+
export interface ChatSuggestion {
|
|
31
|
+
id: string;
|
|
32
|
+
label: string;
|
|
33
|
+
prompt: string;
|
|
34
|
+
}
|
|
35
|
+
export interface StoredChatMessage {
|
|
36
|
+
role: "user" | "assistant";
|
|
37
|
+
content: string;
|
|
38
|
+
response?: ChatResponse;
|
|
39
|
+
status?: "thinking" | "streaming" | "complete";
|
|
40
|
+
timestamp: string;
|
|
41
|
+
}
|
|
42
|
+
export interface ChatStreamRequest {
|
|
43
|
+
prompt: string;
|
|
44
|
+
language: string;
|
|
45
|
+
history: Array<{
|
|
46
|
+
role: "user" | "assistant";
|
|
47
|
+
content: string;
|
|
48
|
+
}>;
|
|
49
|
+
regenerate: boolean;
|
|
50
|
+
}
|
|
51
|
+
export interface ChatTransport {
|
|
52
|
+
/**
|
|
53
|
+
* Stream chat response via SSE.
|
|
54
|
+
* Returns a Response object with a readable body that emits SSE events.
|
|
55
|
+
*/
|
|
56
|
+
stream: (request: ChatStreamRequest, signal: AbortSignal) => Promise<Response>;
|
|
57
|
+
/**
|
|
58
|
+
* Optional: Get hydrated response with structured data (follow-ups, moments).
|
|
59
|
+
* Called after streaming completes to enhance the response.
|
|
60
|
+
*/
|
|
61
|
+
hydrate?: (request: ChatStreamRequest, signal: AbortSignal) => Promise<ChatResponse | null>;
|
|
62
|
+
/**
|
|
63
|
+
* Optional: Fetch dynamic suggestions for the chat.
|
|
64
|
+
*/
|
|
65
|
+
suggestions?: (language: string) => Promise<ChatSuggestion[]>;
|
|
66
|
+
}
|
|
67
|
+
export interface ChatPanelProps {
|
|
68
|
+
/**
|
|
69
|
+
* Chat transport for API communication.
|
|
70
|
+
* Injected by the wrapper component to allow different backends.
|
|
71
|
+
*/
|
|
72
|
+
transport: ChatTransport;
|
|
73
|
+
/**
|
|
74
|
+
* Language code for localization (e.g., "en", "es", "fr").
|
|
75
|
+
*/
|
|
76
|
+
language: string;
|
|
77
|
+
/**
|
|
78
|
+
* Unique key for localStorage persistence.
|
|
79
|
+
* If not provided or persist is false, chat history won't be saved.
|
|
80
|
+
*/
|
|
81
|
+
storageKey?: string;
|
|
82
|
+
/**
|
|
83
|
+
* Whether to persist chat history to localStorage.
|
|
84
|
+
* @default true if storageKey is provided
|
|
85
|
+
*/
|
|
86
|
+
persist?: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Whether the media player is ready for seeking.
|
|
89
|
+
* Disables time tag clicks when false.
|
|
90
|
+
*/
|
|
91
|
+
playerReady?: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Callback when a time moment is clicked.
|
|
94
|
+
* Receives the start time in seconds.
|
|
95
|
+
*/
|
|
96
|
+
onPlayMoment?: (params: {
|
|
97
|
+
startSeconds: number;
|
|
98
|
+
endSeconds?: number;
|
|
99
|
+
}) => void;
|
|
100
|
+
/**
|
|
101
|
+
* Optional callback to add answer text to notes.
|
|
102
|
+
* If provided, shows "Add to notes" button.
|
|
103
|
+
*/
|
|
104
|
+
onAddToNotes?: (markdown: string) => void;
|
|
105
|
+
/**
|
|
106
|
+
* Configuration for follow-up suggestions.
|
|
107
|
+
*/
|
|
108
|
+
followUps?: {
|
|
109
|
+
enabled: boolean;
|
|
110
|
+
max: number;
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* Empty state title.
|
|
114
|
+
* @default "Ask about this recording"
|
|
115
|
+
*/
|
|
116
|
+
emptyStateTitle?: string;
|
|
117
|
+
/**
|
|
118
|
+
* Empty state subtitle.
|
|
119
|
+
* @default "Get insights grounded in the transcript and visual content"
|
|
120
|
+
*/
|
|
121
|
+
emptyStateSubtitle?: string;
|
|
122
|
+
/**
|
|
123
|
+
* Input placeholder text.
|
|
124
|
+
* @default "Ask about the video..."
|
|
125
|
+
*/
|
|
126
|
+
inputPlaceholder?: string;
|
|
127
|
+
/**
|
|
128
|
+
* CSS class variant for styling.
|
|
129
|
+
* - "default": Dashboard styling (larger, more spacious)
|
|
130
|
+
* - "compact": Share/embed styling (smaller, more compact)
|
|
131
|
+
* @default "default"
|
|
132
|
+
*/
|
|
133
|
+
variant?: "default" | "compact";
|
|
134
|
+
/**
|
|
135
|
+
* Optional CSS class name for the container.
|
|
136
|
+
*/
|
|
137
|
+
className?: string;
|
|
138
|
+
}
|
|
@@ -2,5 +2,5 @@ import { Toaster as Sonner, toast } from 'sonner';
|
|
|
2
2
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
type ToasterProps = React.ComponentProps<typeof Sonner>;
|
|
5
|
-
declare const Toaster: ({ ...props }: ToasterProps) => import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
declare const Toaster: ({ closeButton, ...props }: ToasterProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
6
|
export { Toaster, toast };
|
package/dist/ui/src/index.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export { ThumbnailCard } from './components/thumbnail-card';
|
|
|
22
22
|
export { ThumbnailPreviewOverlay } from './components/thumbnail-preview';
|
|
23
23
|
export { ThumbnailStrip } from './components/thumbnail-strip';
|
|
24
24
|
export { Squircle } from './components/squircle';
|
|
25
|
+
export { ChatPanel, TimecodeTag, MarkdownText, safeReadChatFromStorage, safeWriteChatToStorage, safeRemoveChatFromStorage, messagesToStored, storedToMessages, parseSseEvent, readSseStream, parseTimecodeToSeconds, formatSecondsAsTimecode, linkifyTimeReferencesInMarkdown, getDefaultSuggestions, getBrowserLanguage, DEFAULT_SUGGESTIONS, } from './components/chat';
|
|
25
26
|
export type { ButtonProps } from './components/button';
|
|
26
27
|
export type { CardProps } from './components/card';
|
|
27
28
|
export type { InputProps } from './components/input';
|
|
@@ -35,5 +36,6 @@ export type { LinkCopyButtonProps } from './components/link-copy-button';
|
|
|
35
36
|
export type { ThumbnailCardProps } from './components/thumbnail-card';
|
|
36
37
|
export type { ThumbnailPreviewOverlayProps } from './components/thumbnail-preview';
|
|
37
38
|
export type { ThumbnailStripProps, ThumbnailData as UIThumbnailData } from './components/thumbnail-strip';
|
|
39
|
+
export type { ChatPanelProps, ChatTransport, ChatStreamRequest, ChatMessage, ChatResponse, ChatAnswerItem, ChatMoment, ChatSuggestion, StoredChatMessage, TimecodeTagProps, MarkdownTextProps, SSEEvent, SSEChunkEvent, SSECompleteEvent, SSEErrorEvent, } from './components/chat';
|
|
38
40
|
export { cn } from './lib/utils';
|
|
39
|
-
export declare const UI_LIBRARY_VERSION = "0.2.
|
|
41
|
+
export declare const UI_LIBRARY_VERSION = "0.2.12";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memoreco/ui",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.12",
|
|
4
4
|
"description": "Memoreco shared UI components with Shadcn",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -16,19 +16,6 @@
|
|
|
16
16
|
"files": [
|
|
17
17
|
"dist"
|
|
18
18
|
],
|
|
19
|
-
"scripts": {
|
|
20
|
-
"dev": "vite build --watch",
|
|
21
|
-
"build": "vite build",
|
|
22
|
-
"lint": "eslint src/ --ext .ts,.tsx",
|
|
23
|
-
"lint:fix": "eslint src/ --ext .ts,.tsx --fix",
|
|
24
|
-
"type-check": "tsc --noEmit",
|
|
25
|
-
"test": "vitest --run --passWithNoTests",
|
|
26
|
-
"test:ui": "vitest --ui",
|
|
27
|
-
"clean": "rimraf dist",
|
|
28
|
-
"release:check": "pnpm run lint && pnpm run type-check && pnpm run test && pnpm run build",
|
|
29
|
-
"release:publish": "node scripts/publish.mjs",
|
|
30
|
-
"prepublishOnly": "pnpm run release:check"
|
|
31
|
-
},
|
|
32
19
|
"dependencies": {
|
|
33
20
|
"@monokai/monoco": "^0.3.2",
|
|
34
21
|
"@radix-ui/react-accordion": "^1.2.11",
|
|
@@ -41,13 +28,13 @@
|
|
|
41
28
|
"class-variance-authority": "^0.7.0",
|
|
42
29
|
"clsx": "^2.1.0",
|
|
43
30
|
"lucide-react": "^0.542.0",
|
|
31
|
+
"react-markdown": "^10.1.0",
|
|
32
|
+
"remark-gfm": "^4.0.1",
|
|
44
33
|
"sonner": "^2.0.7",
|
|
45
34
|
"tailwind-merge": "^2.2.1"
|
|
46
35
|
},
|
|
47
36
|
"devDependencies": {
|
|
48
|
-
"@
|
|
49
|
-
"@memoreco/utils": "workspace:*",
|
|
50
|
-
"@types/node": "^20.19.17",
|
|
37
|
+
"@types/node": "^22.19.0",
|
|
51
38
|
"@types/react": "^19.1.12",
|
|
52
39
|
"@types/react-dom": "^19.1.9",
|
|
53
40
|
"@vitejs/plugin-react": "^4.2.1",
|
|
@@ -60,11 +47,25 @@
|
|
|
60
47
|
"typescript": "^5.9.2",
|
|
61
48
|
"vite": "^5.0.12",
|
|
62
49
|
"vite-plugin-dts": "^3.7.2",
|
|
63
|
-
"vitest": "^1.2.2"
|
|
50
|
+
"vitest": "^1.2.2",
|
|
51
|
+
"@memoreco/utils": "0.2.0",
|
|
52
|
+
"@memoreco/types": "0.2.0"
|
|
64
53
|
},
|
|
65
54
|
"peerDependencies": {
|
|
66
55
|
"react": ">=18.0.0",
|
|
67
56
|
"react-dom": ">=18.0.0"
|
|
68
57
|
},
|
|
69
|
-
"sideEffects": false
|
|
58
|
+
"sideEffects": false,
|
|
59
|
+
"scripts": {
|
|
60
|
+
"dev": "vite build --watch",
|
|
61
|
+
"build": "vite build",
|
|
62
|
+
"lint": "eslint src/ --ext .ts,.tsx",
|
|
63
|
+
"lint:fix": "eslint src/ --ext .ts,.tsx --fix",
|
|
64
|
+
"type-check": "tsc --noEmit",
|
|
65
|
+
"test": "vitest --run --passWithNoTests",
|
|
66
|
+
"test:ui": "vitest --ui",
|
|
67
|
+
"clean": "rimraf dist",
|
|
68
|
+
"release:check": "pnpm run lint && pnpm run type-check && pnpm run test && pnpm run build",
|
|
69
|
+
"release:publish": "node scripts/publish.mjs"
|
|
70
|
+
}
|
|
70
71
|
}
|