nuxt-parley 1.9.17 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -117,6 +117,10 @@ All client-only: the server renders a placeholder, so no `<ClientOnly>` is neede
117
117
  | `<ChatPage>` | The whole chat: contact list, conversation and call view. Slots: `empty`, `header-actions`, `conversation-top`, `above-input`. |
118
118
  | `<ChatCall>` | The call view (vue-parley's `Call`). Render it near the app root, with `<ChatPage :render-call="false" />`, to keep a call on screen while the user navigates. |
119
119
  | `<ChatList>`, `<ChatConversation>`, `<ChatHeader>`, `<ChatMessages>`, `<ChatInput>`, `<ChatBubble>` | Building blocks for a custom layout. |
120
+ | `<Whiteboard>` / `<ChatWhiteboard>` | Interactive whiteboard with drawing tools, shapes, multi-layer support, zoom/pan gestures, and live streaming. |
121
+ | `<WhiteboardDialog>` / `<ChatWhiteboardDialog>` | Modal dialog wrapping the whiteboard with responsive bottom dock, participant strips, and share-to-call integration. |
122
+ | `<WhiteboardRgbPicker>` / `<ChatWhiteboardRgbPicker>` | RGB color picker for custom whiteboard colors. |
123
+ | `<CallPaintBoard>` / `<ChatCallPaintBoard>` | In-call annotation and paint board. |
120
124
 
121
125
  With `primitives: true`, `BIcon` (a Phosphor icon by name), `BEmojiPicker` and `BVirtualVerticalList` are registered too. The chat's controls are PrimeVue components; use PrimeVue's own `Button`, `Dialog` and so on in your pages. `prefix` prefixes every name.
122
126
 
@@ -124,11 +128,18 @@ With `primitives: true`, `BIcon` (a Phosphor icon by name), `BEmojiPicker` and `
124
128
 
125
129
  | Name | What it is |
126
130
  | --- | --- |
131
+ | `useParley()`, `useParleyChat()` | High-level composable for the active conversation, contact, messages, drafts, unread totals, sending messages, and chat actions. |
132
+ | `useParleyCall()` | High-level composable for voice and video calls: reactive session, duration, controls (audio, video, flashlight, screen share, whiteboard share, camera flip), participants, and signaling observation. |
133
+ | `useParleyWhiteboard()` | Composable for controlling whiteboard dialog visibility and syncing stream sharing with an active call session. |
134
+ | `useParleyMedia()` | Composable for downloading, caching, and retrieving media blobs, file sizes, and albums. |
135
+ | `formatDuration(seconds)` | Formats duration in seconds to `mm:ss` or `hh:mm:ss`. |
136
+ | `formatBytes(bytes)` | Formats byte numbers to human-readable `Bytes`, `KB`, `MB`, `GB`. |
137
+ | `CallMessageType` | Signalling message types enum (`Signal`, `Join`, `TrackType`, `Call`, `Hangup`, `Presence`). |
127
138
  | `useChatStore`, `useMessagesStore`, `useMediaStore`, `useProfileStore`, `useCallStore` | vue-parley's Pinia stores. Usable anywhere, including plugins and middleware. |
128
139
  | `provideCallHandlers(handlers)` | Supplies call handlers from inside a component. |
129
140
  | `messageMedia(message)` | A message's photo and video album (`media`, or `imageUrl` as photos). Albums are sent with `media`: upload each item, and return it on the message. |
130
141
  | `resetChat()` | Forgets everything the chat loaded for the signed-in user (conversations, threads, drafts, shared media, the downloaded-file cache) and ends a running call. Call it on sign-out or an account switch; the handlers stay. |
131
- | `defineParleyConfig(fn)` | Typed helper for `app/parley.config.ts`. |
142
+ | `defineParleyConfig(fn | object)` | Typed helper for `app/parley.config.ts`. Supports both config functions and static options objects. |
132
143
 
133
144
  The stores get their handlers from the config file. Used on the server, they exist but have no handlers.
134
145
 
package/dist/module.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
2
  export { ParleyConfig } from '../dist/runtime/config.js';
3
- export { CallHandlers, CallKind, CallMessage, CallMessageSchema, CallPublishOptions, ChatEvent, ChatFilter, ChatHandlers, ChatOptions, ChatUser, Contact, ContactsPage, Credential, ExtendedMessage, FetchContactsParams, FetchMessagesParams, FetchProfileAttachmentsParams, MediaDownloadOptions, MediaHandlers, MediaItem, Message, MessageReader, MessageType, MessagesHandlers, ProfileAttachmentsPage, ProfileHandlers, SendMessageOptions, SignalData, TurnConfig, UploadProgressEvent } from 'vue-parley';
3
+ export { ArrowShape, BaseShape, CallHandlers, CallKind, CallMediaState, CallMember, CallMessage, CallMessageSchema, CallMessageType, CallPhase, CallPublishOptions, CanvasTheme, ChatEvent, ChatFilter, ChatHandlers, ChatOptions, ChatUser, CircleShape, Contact, ContactsPage, Credential, EmojiSelection, ExtendedMessage, FetchContactsParams, FetchMessagesParams, FetchProfileAttachmentsParams, GridStyle, LineShape, MediaDownloadOptions, MediaHandlers, MediaItem, MenuOption, Message, MessageOptions, MessageReader, MessageType, MessagesHandlers, ParticipantStatus, ProfileAttachmentsPage, ProfileHandlers, RectShape, SendMessageOptions, ServicePresence, ShapeType, SignalData, StarShape, StateKeys, StickyShape, TextShape, TrackType, TriangleShape, TurnConfig, UploadProgressEvent, UserRoleKey, WhiteboardExposed, WhiteboardPage, WhiteboardShape, WhiteboardTool, status } from 'vue-parley';
4
4
 
5
5
  interface ModuleOptions {
6
6
  /**
package/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=4.0.0"
6
6
  },
7
- "version": "1.9.17",
7
+ "version": "1.10.0",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.3",
10
10
  "unbuild": "unknown"
package/dist/module.mjs CHANGED
@@ -10,7 +10,15 @@ const COMPONENTS = {
10
10
  ChatMessages: "ChatMessages",
11
11
  ChatInput: "ChatInput",
12
12
  ChatBubble: "ChatBubble",
13
- ChatCall: "Call"
13
+ ChatCall: "Call",
14
+ Whiteboard: "Whiteboard",
15
+ ChatWhiteboard: "Whiteboard",
16
+ WhiteboardDialog: "WhiteboardDialog",
17
+ ChatWhiteboardDialog: "WhiteboardDialog",
18
+ WhiteboardRgbPicker: "WhiteboardRgbPicker",
19
+ ChatWhiteboardRgbPicker: "WhiteboardRgbPicker",
20
+ CallPaintBoard: "CallPaintBoard",
21
+ ChatCallPaintBoard: "CallPaintBoard"
14
22
  };
15
23
  const PRIMITIVES = ["BEmojiPicker", "BIcon", "BVirtualVerticalList"];
16
24
  const COMPOSABLES = [
@@ -19,11 +27,19 @@ const COMPOSABLES = [
19
27
  "useMediaStore",
20
28
  "useProfileStore",
21
29
  "useCallStore",
30
+ "useParley",
31
+ "useParleyChat",
32
+ "useParleyCall",
33
+ "useParleyWhiteboard",
34
+ "useParleyMedia",
22
35
  "provideCallHandlers",
23
36
  // Not a composable either: hosts call it when the signed-in user changes.
24
37
  "resetChat",
25
38
  // Not a composable, but hosts need it wherever they map an album to or from their backend.
26
- "messageMedia"
39
+ "messageMedia",
40
+ "formatDuration",
41
+ "formatBytes",
42
+ "CallMessageType"
27
43
  ];
28
44
  const module$1 = defineNuxtModule({
29
45
  meta: {
@@ -0,0 +1,4 @@
1
+ export * from './useParley.js';
2
+ export * from './useParleyCall.js';
3
+ export * from './useParleyWhiteboard.js';
4
+ export * from './useParleyMedia.js';
@@ -0,0 +1,4 @@
1
+ export * from "./useParley.js";
2
+ export * from "./useParleyCall.js";
3
+ export * from "./useParleyWhiteboard.js";
4
+ export * from "./useParleyMedia.js";
@@ -0,0 +1,32 @@
1
+ import type { ComputedRef, WritableComputedRef } from 'vue';
2
+ import type { Contact, Message, StateKeys } from 'vue-parley';
3
+ import { useChatStore, useMessagesStore, useProfileStore } from '../parley.js';
4
+ export interface UseParleyReturn {
5
+ chatStore: ReturnType<typeof useChatStore>;
6
+ messagesStore: ReturnType<typeof useMessagesStore>;
7
+ profileStore: ReturnType<typeof useProfileStore>;
8
+ activeConversationId: WritableComputedRef<string | null>;
9
+ activeContact: ComputedRef<Contact | null>;
10
+ activeMessages: ComputedRef<Message[]>;
11
+ isLoadingMessages: ComputedRef<boolean>;
12
+ draft: WritableComputedRef<string>;
13
+ typingUser: ComputedRef<string | null>;
14
+ contacts: ComputedRef<readonly Contact[]>;
15
+ unreadTotal: ComputedRef<number>;
16
+ selectConversation: (id: string | null) => void;
17
+ getContact: (id: string) => Contact | null;
18
+ addContact: (contact: Contact, filter?: StateKeys) => void;
19
+ updateContact: (id: string, updates: Partial<Contact>) => void;
20
+ fetchConversations: (state?: StateKeys, page?: number, search?: string) => Promise<void>;
21
+ deleteConversation: (id: string) => Promise<void>;
22
+ endConversation: ((id: string) => Promise<void>) | undefined;
23
+ setDraft: (channelId: string, text: string) => void;
24
+ fetchMessages: (conversationId: string, page?: number) => Promise<void>;
25
+ sendMessage: (text: string) => Promise<void>;
26
+ reset: () => Promise<void>;
27
+ }
28
+ /**
29
+ * High-level composable for chat conversation and messages state and actions.
30
+ */
31
+ export declare function useParley(): UseParleyReturn;
32
+ export declare const useParleyChat: typeof useParley;
@@ -0,0 +1,110 @@
1
+ import { computed } from "vue";
2
+ import { resetChat, useChatStore, useMessagesStore, useProfileStore } from "../parley.js";
3
+ export function useParley() {
4
+ const chatStore = useChatStore();
5
+ const messagesStore = useMessagesStore();
6
+ const profileStore = useProfileStore();
7
+ const activeConversationId = computed({
8
+ get: () => chatStore.activeConversationId,
9
+ set: (id) => chatStore.setSelectedChat(id)
10
+ });
11
+ const activeContact = computed(
12
+ () => activeConversationId.value ? chatStore.getContactById(activeConversationId.value) : null
13
+ );
14
+ const activeMessages = computed(
15
+ () => activeConversationId.value ? messagesStore.messagesMap[activeConversationId.value] ?? [] : []
16
+ );
17
+ const isLoadingMessages = computed(
18
+ () => activeConversationId.value ? !!messagesStore.messagesLoadingMap[activeConversationId.value] : false
19
+ );
20
+ const draft = computed({
21
+ get: () => activeConversationId.value ? messagesStore.drafts[activeConversationId.value] ?? "" : "",
22
+ set: (text) => {
23
+ if (activeConversationId.value) {
24
+ messagesStore.setDraft(activeConversationId.value, text);
25
+ }
26
+ }
27
+ });
28
+ const typingUser = computed(
29
+ () => activeConversationId.value ? chatStore.typingByConversation[activeConversationId.value] ?? null : null
30
+ );
31
+ const contacts = computed(
32
+ () => chatStore.conversationStates[""]?.data ?? []
33
+ );
34
+ const unreadTotal = computed(() => {
35
+ let count = 0;
36
+ for (const key of ["", "online", "ended", "active"]) {
37
+ const list = chatStore.conversationStates[key]?.data ?? [];
38
+ for (const contact of list) {
39
+ count += contact.unreadCount ?? 0;
40
+ }
41
+ }
42
+ return count;
43
+ });
44
+ const selectConversation = (id) => {
45
+ chatStore.setSelectedChat(id);
46
+ };
47
+ const getContact = (id) => chatStore.getContactById(id);
48
+ const addContact = (contact, filter = "") => {
49
+ chatStore.addContact(contact, filter);
50
+ };
51
+ const updateContact = (id, updates) => {
52
+ chatStore.updateContact(id, updates);
53
+ };
54
+ const fetchConversations = (state = "", page = 1, search = "") => {
55
+ return chatStore.fetchConversations(state, page, search);
56
+ };
57
+ const deleteConversation = (id) => {
58
+ return chatStore.deleteConversation(id);
59
+ };
60
+ const endConversation = chatStore.endConversation ? (id) => chatStore.endConversation(id) : void 0;
61
+ const setDraft = (channelId, text) => {
62
+ messagesStore.setDraft(channelId, text);
63
+ };
64
+ const fetchMessages = (conversationId, page = 1) => {
65
+ return messagesStore.fetchMessages(conversationId, page);
66
+ };
67
+ const sendMessage = async (text) => {
68
+ const channel = activeConversationId.value;
69
+ if (!channel) {
70
+ throw new Error("[nuxt-parley] Cannot send message: no active conversation");
71
+ }
72
+ const message = {
73
+ id: "",
74
+ conversationId: channel,
75
+ date: /* @__PURE__ */ new Date(),
76
+ type: "text",
77
+ text,
78
+ senderId: profileStore.userId,
79
+ isEdited: false,
80
+ isSent: false,
81
+ isRead: false
82
+ };
83
+ await messagesStore.sendMessage([message]);
84
+ };
85
+ return {
86
+ chatStore,
87
+ messagesStore,
88
+ profileStore,
89
+ activeConversationId,
90
+ activeContact,
91
+ activeMessages,
92
+ isLoadingMessages,
93
+ draft,
94
+ typingUser,
95
+ contacts,
96
+ unreadTotal,
97
+ selectConversation,
98
+ getContact,
99
+ addContact,
100
+ updateContact,
101
+ fetchConversations,
102
+ deleteConversation,
103
+ endConversation,
104
+ setDraft,
105
+ fetchMessages,
106
+ sendMessage,
107
+ reset: resetChat
108
+ };
109
+ }
110
+ export const useParleyChat = useParley;
@@ -0,0 +1,72 @@
1
+ import type { ComputedRef } from 'vue';
2
+ import type { CallHandlers, CallMediaState, CallMessageSchema, CallPhase, ParticipantStatus } from 'vue-parley';
3
+ import { useCallStore } from '../parley.js';
4
+ export interface ParleyCallParticipant {
5
+ id: string;
6
+ userId: string;
7
+ name: string;
8
+ isSelf: boolean;
9
+ joinedAt?: number;
10
+ media?: CallMediaState;
11
+ camera?: MediaStream;
12
+ screen?: MediaStream;
13
+ status: ParticipantStatus;
14
+ }
15
+ export interface UseParleyCallReturn {
16
+ callStore: ReturnType<typeof useCallStore>;
17
+ session: ComputedRef<ReturnType<typeof useCallStore>['session']>;
18
+ isActive: ComputedRef<boolean>;
19
+ isMinimized: ComputedRef<boolean>;
20
+ isVideoCall: ComputedRef<boolean>;
21
+ channelId: ComputedRef<string | null>;
22
+ elapsedTime: ComputedRef<number>;
23
+ formattedDuration: ComputedRef<string>;
24
+ canShareScreen: ComputedRef<boolean>;
25
+ isAudioOn: ComputedRef<boolean>;
26
+ isVideoOn: ComputedRef<boolean>;
27
+ isScreenSharing: ComputedRef<boolean>;
28
+ isWhiteboardSharing: ComputedRef<boolean>;
29
+ isFlashlightOn: ComputedRef<boolean>;
30
+ isFlashlightSupported: ComputedRef<boolean>;
31
+ canFlipCamera: ComputedRef<boolean>;
32
+ facingMode: ComputedRef<string>;
33
+ cameras: ComputedRef<MediaDeviceInfo[]>;
34
+ localStream: ComputedRef<MediaStream | null>;
35
+ screenStream: ComputedRef<MediaStream | null>;
36
+ whiteboardStream: ComputedRef<MediaStream | null>;
37
+ participants: ComputedRef<ParleyCallParticipant[]>;
38
+ participantCount: ComputedRef<number>;
39
+ tileCount: ComputedRef<number>;
40
+ phase: ComputedRef<CallPhase>;
41
+ remoteVideos: ComputedRef<Record<string, unknown>>;
42
+ remoteScreens: ComputedRef<Record<string, unknown>>;
43
+ startCall: (channel: string, options?: {
44
+ video?: boolean;
45
+ }) => void;
46
+ endCall: () => void;
47
+ minimize: () => void;
48
+ maximize: () => void;
49
+ toggleMinimize: () => void;
50
+ toggleAudio: () => void;
51
+ toggleVideo: () => void;
52
+ toggleFlashlight: () => void;
53
+ toggleScreenShare: () => Promise<void> | undefined;
54
+ flipCamera: () => Promise<unknown>;
55
+ switchCamera: (deviceId: string) => Promise<unknown>;
56
+ retryPeer: (id: string) => void;
57
+ startWhiteboardShare: (stream: MediaStream) => Promise<void>;
58
+ stopWhiteboardShare: () => void;
59
+ observeCall: (message: CallMessageSchema, channel?: string) => void;
60
+ ongoingCall: (channel: string | null | undefined) => {
61
+ video: boolean;
62
+ count: number;
63
+ max: number;
64
+ full: boolean;
65
+ } | null;
66
+ setHandlers: (handlers: CallHandlers) => void;
67
+ }
68
+ /**
69
+ * High-level composable for managing voice and video calls in Nuxt.
70
+ * Exposes reactive call state, active session controls, screen sharing, duration, and signaling helpers.
71
+ */
72
+ export declare function useParleyCall(): UseParleyCallReturn;
@@ -0,0 +1,111 @@
1
+ import { computed } from "vue";
2
+ import { useCallStore } from "../parley.js";
3
+ import { formatDuration } from "../utils/format.js";
4
+ export function useParleyCall() {
5
+ const callStore = useCallStore();
6
+ const session = computed(() => callStore.session);
7
+ const isActive = computed(() => callStore.isActive);
8
+ const isMinimized = computed(() => callStore.isMinimized);
9
+ const isVideoCall = computed(() => callStore.isVideoCall);
10
+ const channelId = computed(() => callStore.channelId);
11
+ const elapsedTime = computed(() => callStore.elapsedTime);
12
+ const canShareScreen = computed(() => callStore.canShareScreen);
13
+ const formattedDuration = computed(() => formatDuration(elapsedTime.value));
14
+ const isAudioOn = computed(() => session.value?.media.isAudioOn.value ?? false);
15
+ const isVideoOn = computed(() => session.value?.media.isVideoOn.value ?? false);
16
+ const isScreenSharing = computed(() => session.value?.media.isScreenSharing.value ?? false);
17
+ const isWhiteboardSharing = computed(() => session.value?.media.isWhiteboardSharing.value ?? false);
18
+ const isFlashlightOn = computed(() => session.value?.media.isFlashlightOn.value ?? false);
19
+ const isFlashlightSupported = computed(() => session.value?.media.isFlashlightSupported.value ?? false);
20
+ const canFlipCamera = computed(() => session.value?.media.canFlipCamera.value ?? false);
21
+ const facingMode = computed(() => session.value?.media.facingMode.value ?? "user");
22
+ const cameras = computed(() => session.value?.media.cameras.value ?? []);
23
+ const localStream = computed(() => session.value?.media.localStream.value ?? null);
24
+ const screenStream = computed(() => session.value?.media.screenStream.value ?? null);
25
+ const whiteboardStream = computed(() => session.value?.media.whiteboardStream.value ?? null);
26
+ const participants = computed(() => session.value?.participants.value ?? []);
27
+ const participantCount = computed(() => session.value?.participantCount.value ?? 0);
28
+ const tileCount = computed(() => session.value?.tileCount.value ?? 0);
29
+ const phase = computed(() => session.value?.phase.value ?? (callStore.isActive ? "connecting" : "ended"));
30
+ const remoteVideos = computed(() => session.value?.peers.remoteVideos ?? {});
31
+ const remoteScreens = computed(() => session.value?.peers.remoteScreens ?? {});
32
+ const startCall = (channel, options) => callStore.startCall(channel, options);
33
+ const endCall = () => callStore.endCall();
34
+ const minimize = () => callStore.minimize();
35
+ const maximize = () => callStore.maximize();
36
+ const toggleMinimize = () => {
37
+ if (callStore.isMinimized) callStore.maximize();
38
+ else callStore.minimize();
39
+ };
40
+ const toggleAudio = () => session.value?.media.toggleAudio();
41
+ const toggleVideo = () => session.value?.media.toggleVideo();
42
+ const toggleFlashlight = () => session.value?.media.toggleFlashlight();
43
+ const toggleScreenShare = () => session.value?.toggleScreenShare();
44
+ const flipCamera = async () => session.value?.flipCamera();
45
+ const switchCamera = async (deviceId) => session.value?.switchCamera(deviceId);
46
+ const retryPeer = (id) => session.value?.retryPeer(id);
47
+ const startWhiteboardShare = async (stream) => {
48
+ await session.value?.startWhiteboardShare(stream);
49
+ };
50
+ const stopWhiteboardShare = () => {
51
+ session.value?.stopWhiteboardShare();
52
+ };
53
+ const observeCall = (message, channel) => {
54
+ callStore.observeCall(message, channel);
55
+ };
56
+ const ongoingCall = (channel) => {
57
+ return callStore.ongoingCall(channel);
58
+ };
59
+ const setHandlers = (handlers) => {
60
+ callStore.setHandlers(handlers);
61
+ };
62
+ return {
63
+ callStore,
64
+ session,
65
+ isActive,
66
+ isMinimized,
67
+ isVideoCall,
68
+ channelId,
69
+ elapsedTime,
70
+ formattedDuration,
71
+ canShareScreen,
72
+ // Media
73
+ isAudioOn,
74
+ isVideoOn,
75
+ isScreenSharing,
76
+ isWhiteboardSharing,
77
+ isFlashlightOn,
78
+ isFlashlightSupported,
79
+ canFlipCamera,
80
+ facingMode,
81
+ cameras,
82
+ localStream,
83
+ screenStream,
84
+ whiteboardStream,
85
+ // Participants
86
+ participants,
87
+ participantCount,
88
+ tileCount,
89
+ phase,
90
+ remoteVideos,
91
+ remoteScreens,
92
+ // Actions
93
+ startCall,
94
+ endCall,
95
+ minimize,
96
+ maximize,
97
+ toggleMinimize,
98
+ toggleAudio,
99
+ toggleVideo,
100
+ toggleFlashlight,
101
+ toggleScreenShare,
102
+ flipCamera,
103
+ switchCamera,
104
+ retryPeer,
105
+ startWhiteboardShare,
106
+ stopWhiteboardShare,
107
+ observeCall,
108
+ ongoingCall,
109
+ setHandlers
110
+ };
111
+ }
@@ -0,0 +1,30 @@
1
+ import type { MediaDownloadOptions, Message } from 'vue-parley';
2
+ /**
3
+ * Composable for downloading, caching, and handling media files in Parley.
4
+ */
5
+ export declare function useParleyMedia(): {
6
+ mediaStore: import("pinia").Store<"media", Pick<{
7
+ clearCache: () => Promise<void>;
8
+ setHandlers: (val: import("vue-parley").MediaHandlers) => void;
9
+ fetchFileSize: (url: string) => Promise<number | null>;
10
+ getCachedBlob: (url: string) => Promise<Blob | null>;
11
+ download: (url: string, opts?: MediaDownloadOptions) => Promise<Blob>;
12
+ }, never>, Pick<{
13
+ clearCache: () => Promise<void>;
14
+ setHandlers: (val: import("vue-parley").MediaHandlers) => void;
15
+ fetchFileSize: (url: string) => Promise<number | null>;
16
+ getCachedBlob: (url: string) => Promise<Blob | null>;
17
+ download: (url: string, opts?: MediaDownloadOptions) => Promise<Blob>;
18
+ }, never>, Pick<{
19
+ clearCache: () => Promise<void>;
20
+ setHandlers: (val: import("vue-parley").MediaHandlers) => void;
21
+ fetchFileSize: (url: string) => Promise<number | null>;
22
+ getCachedBlob: (url: string) => Promise<Blob | null>;
23
+ download: (url: string, opts?: MediaDownloadOptions) => Promise<Blob>;
24
+ }, "setHandlers" | "clearCache" | "fetchFileSize" | "getCachedBlob" | "download">>;
25
+ download: (url: string, opts?: MediaDownloadOptions) => Promise<Blob>;
26
+ getCachedBlob: (url: string) => Promise<Blob | null>;
27
+ getFileSize: (url: string) => Promise<number | null>;
28
+ clearCache: () => Promise<void>;
29
+ messageMedia: (message: Pick<Message, "media" | "imageUrl">) => import("vue-parley").MediaItem[];
30
+ };
@@ -0,0 +1,16 @@
1
+ import { messageMedia, useMediaStore } from "../parley.js";
2
+ export function useParleyMedia() {
3
+ const mediaStore = useMediaStore();
4
+ const download = (url, opts) => mediaStore.download(url, opts);
5
+ const getCachedBlob = (url) => mediaStore.getCachedBlob(url);
6
+ const getFileSize = (url) => mediaStore.fetchFileSize(url);
7
+ const clearCache = () => mediaStore.clearCache();
8
+ return {
9
+ mediaStore,
10
+ download,
11
+ getCachedBlob,
12
+ getFileSize,
13
+ clearCache,
14
+ messageMedia: (message) => messageMedia(message)
15
+ };
16
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Composable for managing the interactive whiteboard dialog and syncing drawing stream with active calls.
3
+ */
4
+ export declare function useParleyWhiteboard(): {
5
+ isOpen: import("vue").Ref<boolean, boolean>;
6
+ isSharing: import("vue").ComputedRef<any>;
7
+ open: () => void;
8
+ close: () => void;
9
+ toggle: () => void;
10
+ startShare: (stream: MediaStream) => Promise<void>;
11
+ stopShare: () => void;
12
+ onStreamStart: (stream: MediaStream) => Promise<void>;
13
+ onStreamStop: () => void;
14
+ };
@@ -0,0 +1,35 @@
1
+ import { computed, ref } from "vue";
2
+ import { useCallStore } from "../parley.js";
3
+ export function useParleyWhiteboard() {
4
+ const callStore = useCallStore();
5
+ const isOpen = ref(false);
6
+ const isSharing = computed(() => callStore.session?.media.isWhiteboardSharing.value ?? false);
7
+ const open = () => {
8
+ isOpen.value = true;
9
+ };
10
+ const close = () => {
11
+ isOpen.value = false;
12
+ };
13
+ const toggle = () => {
14
+ isOpen.value = !isOpen.value;
15
+ };
16
+ const startShare = async (stream) => {
17
+ await callStore.session?.startWhiteboardShare(stream);
18
+ };
19
+ const stopShare = () => {
20
+ callStore.session?.stopWhiteboardShare();
21
+ };
22
+ const onStreamStart = (stream) => startShare(stream);
23
+ const onStreamStop = () => stopShare();
24
+ return {
25
+ isOpen,
26
+ isSharing,
27
+ open,
28
+ close,
29
+ toggle,
30
+ startShare,
31
+ stopShare,
32
+ onStreamStart,
33
+ onStreamStop
34
+ };
35
+ }
@@ -3,7 +3,8 @@ import type { ChatOptions } from 'vue-parley';
3
3
  /**
4
4
  * Returns what `createChat()` needs: the backend handlers and the signed-in user. Runs once, in
5
5
  * the browser, inside a Nuxt plugin, so composables such as `useRuntimeConfig()` work here.
6
+ * Can be a ChatOptions object or a function returning ChatOptions (sync or async).
6
7
  */
7
- export type ParleyConfig = (nuxtApp: NuxtApp) => ChatOptions | Promise<ChatOptions>;
8
+ export type ParleyConfig = ChatOptions | ((nuxtApp: NuxtApp) => ChatOptions | Promise<ChatOptions>);
8
9
  /** Typed identity helper for `app/parley.config.ts`. Auto-imported. */
9
10
  export declare function defineParleyConfig(config: ParleyConfig): ParleyConfig;
@@ -1,5 +1,6 @@
1
1
  import { createChat } from "./parley.js";
2
2
  export async function installParley(nuxtApp, config) {
3
3
  if (!config) return;
4
- nuxtApp.vueApp.use(createChat(await config(nuxtApp)));
4
+ const options = typeof config === "function" ? await config(nuxtApp) : config;
5
+ nuxtApp.vueApp.use(createChat(options));
5
6
  }
@@ -1 +1,3 @@
1
- export { Call, ChatBubble, ChatConversation, ChatHeader, ChatInput, ChatList, ChatMessages, ChatPage, BEmojiPicker, BIcon, BVirtualVerticalList, createChat, messageMedia, provideCallHandlers, resetChat, useCallStore, useChatStore, useMediaStore, useMessagesStore, useProfileStore, } from 'vue-parley';
1
+ export { BEmojiPicker, BIcon, BVirtualVerticalList, Call, CallMessageType, CallPaintBoard, ChatBubble, ChatConversation, ChatHeader, ChatInput, ChatList, ChatMessages, ChatPage, createChat, messageMedia, provideCallHandlers, resetChat, useCallStore, useChatStore, useMediaStore, useMessagesStore, useProfileStore, Whiteboard, WhiteboardDialog, WhiteboardRgbPicker, } from 'vue-parley';
2
+ export * from './composables/index.js';
3
+ export * from './utils/format.js';
@@ -1,5 +1,10 @@
1
1
  export {
2
+ BEmojiPicker,
3
+ BIcon,
4
+ BVirtualVerticalList,
2
5
  Call,
6
+ CallMessageType,
7
+ CallPaintBoard,
3
8
  ChatBubble,
4
9
  ChatConversation,
5
10
  ChatHeader,
@@ -7,9 +12,6 @@ export {
7
12
  ChatList,
8
13
  ChatMessages,
9
14
  ChatPage,
10
- BEmojiPicker,
11
- BIcon,
12
- BVirtualVerticalList,
13
15
  createChat,
14
16
  messageMedia,
15
17
  provideCallHandlers,
@@ -18,5 +20,10 @@ export {
18
20
  useChatStore,
19
21
  useMediaStore,
20
22
  useMessagesStore,
21
- useProfileStore
23
+ useProfileStore,
24
+ Whiteboard,
25
+ WhiteboardDialog,
26
+ WhiteboardRgbPicker
22
27
  } from "vue-parley";
28
+ export * from "./composables/index.js";
29
+ export * from "./utils/format.js";
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Format total seconds to mm:ss or hh:mm:ss.
3
+ */
4
+ export declare function formatDuration(totalSeconds: number): string;
5
+ /**
6
+ * Format bytes to human readable format (Bytes, KB, MB, GB).
7
+ */
8
+ export declare function formatBytes(bytes: number): string;
@@ -0,0 +1,18 @@
1
+ export function formatDuration(totalSeconds) {
2
+ if (!Number.isFinite(totalSeconds) || totalSeconds < 0) return "00:00";
3
+ const seconds = Math.floor(totalSeconds % 60);
4
+ const minutes = Math.floor(totalSeconds / 60 % 60);
5
+ const hours = Math.floor(totalSeconds / 3600);
6
+ const pad = (val) => val.toString().padStart(2, "0");
7
+ if (hours > 0) {
8
+ return `${pad(hours)}:${pad(minutes)}:${pad(seconds)}`;
9
+ }
10
+ return `${pad(minutes)}:${pad(seconds)}`;
11
+ }
12
+ export function formatBytes(bytes) {
13
+ if (bytes <= 0 || !Number.isFinite(bytes)) return "0 KB";
14
+ const k = 1024;
15
+ const sizes = ["Bytes", "KB", "MB", "GB"];
16
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
17
+ return `${Number.parseFloat((bytes / Math.pow(k, i)).toFixed(1))} ${sizes[i]}`;
18
+ }
package/dist/types.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { type ParleyConfig } from '../dist/runtime/config.js'
2
2
 
3
- export { type CallHandlers, type CallKind, type CallMessage, type CallMessageSchema, type CallPublishOptions, type ChatEvent, type ChatFilter, type ChatHandlers, type ChatOptions, type ChatUser, type Contact, type ContactsPage, type Credential, type ExtendedMessage, type FetchContactsParams, type FetchMessagesParams, type FetchProfileAttachmentsParams, type MediaDownloadOptions, type MediaHandlers, type MediaItem, type Message, type MessageReader, type MessageType, type MessagesHandlers, type ProfileAttachmentsPage, type ProfileHandlers, type SendMessageOptions, type SignalData, type TurnConfig, type UploadProgressEvent } from 'vue-parley'
3
+ export { type ArrowShape, type BaseShape, type CallHandlers, type CallKind, type CallMediaState, type CallMember, type CallMessage, type CallMessageSchema, type CallMessageType, type CallPhase, type CallPublishOptions, type CanvasTheme, type ChatEvent, type ChatFilter, type ChatHandlers, type ChatOptions, type ChatUser, type CircleShape, type Contact, type ContactsPage, type Credential, type EmojiSelection, type ExtendedMessage, type FetchContactsParams, type FetchMessagesParams, type FetchProfileAttachmentsParams, type GridStyle, type LineShape, type MediaDownloadOptions, type MediaHandlers, type MediaItem, type MenuOption, type Message, type MessageOptions, type MessageReader, type MessageType, type MessagesHandlers, type ParticipantStatus, type ProfileAttachmentsPage, type ProfileHandlers, type RectShape, type SendMessageOptions, type ServicePresence, type ShapeType, type SignalData, type StarShape, type StateKeys, type StickyShape, type TextShape, type TrackType, type TriangleShape, type TurnConfig, type UploadProgressEvent, type UserRoleKey, type WhiteboardExposed, type WhiteboardPage, type WhiteboardShape, type WhiteboardTool, type status } from 'vue-parley'
4
4
 
5
5
  export { default } from './module.mjs'
6
6
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-parley",
3
- "version": "1.9.17",
3
+ "version": "1.10.0",
4
4
  "description": "Nuxt module for vue-parley: a drop-in chat and video-call UI, wired into Pinia and i18n for you.",
5
5
  "license": "MIT",
6
6
  "author": "SaeedP11 <saeed_abdi.p11@outlook.com>",
@@ -40,6 +40,16 @@
40
40
  "files": [
41
41
  "dist"
42
42
  ],
43
+ "scripts": {
44
+ "prepack": "nuxt-module-build build",
45
+ "dev": "nuxi dev playground",
46
+ "dev:build": "nuxi build playground",
47
+ "dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
48
+ "lint": "eslint .",
49
+ "test": "vitest run",
50
+ "test:watch": "vitest watch",
51
+ "typecheck": "vue-tsc --noEmit && nuxi typecheck playground"
52
+ },
43
53
  "dependencies": {
44
54
  "@nuxt/kit": "^4.5.2",
45
55
  "@pinia/nuxt": "^1.0.2",
@@ -71,13 +81,11 @@
71
81
  "vue": "^3.5.43",
72
82
  "vue-tsc": "^3.3.11"
73
83
  },
74
- "scripts": {
75
- "dev": "nuxi dev playground",
76
- "dev:build": "nuxi build playground",
77
- "dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
78
- "lint": "eslint .",
79
- "test": "vitest run",
80
- "test:watch": "vitest watch",
81
- "typecheck": "vue-tsc --noEmit && nuxi typecheck playground"
84
+ "pnpm": {
85
+ "onlyBuiltDependencies": [
86
+ "@parcel/watcher",
87
+ "esbuild",
88
+ "unrs-resolver"
89
+ ]
82
90
  }
83
- }
91
+ }