@jaaq/jaaq-sdk-js 1.0.1 → 1.1.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 +733 -92
- package/dist/embed/embed-collection.html +275 -0
- package/dist/embed/embed.html +270 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/jaaq-sdk.min.js.map +1 -1
- package/dist/ui/index.cjs +5051 -0
- package/dist/ui/index.cjs.map +1 -0
- package/dist/ui/index.d.ts +378 -0
- package/dist/ui/index.mjs +5044 -0
- package/dist/ui/index.mjs.map +1 -0
- package/dist/ui/jaaq-ui-bundled.min.js +8 -0
- package/dist/ui/jaaq-ui-bundled.min.js.map +1 -0
- package/dist/ui/jaaq-ui.min.js +8 -0
- package/dist/ui/jaaq-ui.min.js.map +1 -0
- package/dist/ui/react/index.cjs +4756 -0
- package/dist/ui/react/index.cjs.map +1 -0
- package/dist/ui/react/index.d.ts +182 -0
- package/dist/ui/react/index.mjs +4735 -0
- package/dist/ui/react/index.mjs.map +1 -0
- package/dist/ui/react/jaaq-ui-react.min.js +8 -0
- package/dist/ui/react/jaaq-ui-react.min.js.map +1 -0
- package/dist/ui/vanilla/index.cjs +5052 -0
- package/dist/ui/vanilla/index.cjs.map +1 -0
- package/dist/ui/vanilla/index.d.ts +465 -0
- package/dist/ui/vanilla/index.mjs +5044 -0
- package/dist/ui/vanilla/index.mjs.map +1 -0
- package/dist/ui/vanilla/jaaq-vanilla-bundled.min.js +8 -0
- package/dist/ui/vanilla/jaaq-vanilla-bundled.min.js.map +1 -0
- package/dist/ui/vanilla/jaaq-vanilla.min.js +8 -0
- package/dist/ui/vanilla/jaaq-vanilla.min.js.map +1 -0
- package/dist/ui/webcomponents/index.cjs +4619 -0
- package/dist/ui/webcomponents/index.cjs.map +1 -0
- package/dist/ui/webcomponents/index.d.ts +288 -0
- package/dist/ui/webcomponents/index.mjs +4614 -0
- package/dist/ui/webcomponents/index.mjs.map +1 -0
- package/dist/ui/webcomponents/jaaq-webcomponents-bundled.min.js +8 -0
- package/dist/ui/webcomponents/jaaq-webcomponents-bundled.min.js.map +1 -0
- package/dist/ui/webcomponents/jaaq-webcomponents.min.js +8 -0
- package/dist/ui/webcomponents/jaaq-webcomponents.min.js.map +1 -0
- package/package.json +42 -2
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registers JAAQ custom elements (<jaaq-video-player> and <jaaq-collection-player>)
|
|
3
|
+
* Safe to call multiple times - only registers if not already registered
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* import { registerJaaqComponents } from '@jaaq/jaaq-sdk-js/ui/webcomponents';
|
|
7
|
+
* registerJaaqComponents();
|
|
8
|
+
*/
|
|
9
|
+
declare function registerJaaqComponents(): void;
|
|
10
|
+
/**
|
|
11
|
+
* Checks if the JAAQ web components are already registered
|
|
12
|
+
* @returns True if components are registered, false otherwise
|
|
13
|
+
*/
|
|
14
|
+
declare function isRegistered(): boolean;
|
|
15
|
+
|
|
16
|
+
type FetchLike = typeof globalThis.fetch;
|
|
17
|
+
type RequestOptions = Parameters<typeof globalThis.fetch>[1];
|
|
18
|
+
interface HttpClient {
|
|
19
|
+
get<T>(_path: string, _init?: RequestOptions): Promise<T>;
|
|
20
|
+
post<T>(_path: string, _body?: unknown, _init?: RequestOptions): Promise<T>;
|
|
21
|
+
put<T>(_path: string, _body?: unknown, _init?: RequestOptions): Promise<T>;
|
|
22
|
+
patch<T>(_path: string, _body?: unknown, _init?: RequestOptions): Promise<T>;
|
|
23
|
+
delete<T>(_path: string, _init?: RequestOptions): Promise<T>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
type VideoDTO = {
|
|
27
|
+
id: string;
|
|
28
|
+
videoId: string;
|
|
29
|
+
question: string;
|
|
30
|
+
status: number;
|
|
31
|
+
transcription: string;
|
|
32
|
+
subtitle: string;
|
|
33
|
+
createdAt: string;
|
|
34
|
+
videoUrl: string;
|
|
35
|
+
published: boolean;
|
|
36
|
+
tags: string[];
|
|
37
|
+
severity: number | null;
|
|
38
|
+
duration: number;
|
|
39
|
+
description: string;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
type VideosResource = {
|
|
43
|
+
getById(_id: string): Promise<VideoDTO>;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
type CollectionDTO = {
|
|
47
|
+
id: string;
|
|
48
|
+
name: string;
|
|
49
|
+
description: string;
|
|
50
|
+
imageUrl: string;
|
|
51
|
+
createdAt: string;
|
|
52
|
+
videos: VideoDTO[];
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
type CollectionsResource = {
|
|
56
|
+
list(): Promise<CollectionDTO[]>;
|
|
57
|
+
getById(_id: string): Promise<CollectionDTO>;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
interface SDKConfig {
|
|
61
|
+
baseUrl?: string;
|
|
62
|
+
apiKey: string;
|
|
63
|
+
clientId: string;
|
|
64
|
+
fetch?: FetchLike;
|
|
65
|
+
timeoutMs?: number;
|
|
66
|
+
}
|
|
67
|
+
declare class JaaqClient {
|
|
68
|
+
readonly videos: VideosResource;
|
|
69
|
+
readonly collections: CollectionsResource;
|
|
70
|
+
private constructor();
|
|
71
|
+
/**
|
|
72
|
+
* Public "friend" constructor that remains inside the class boundary.
|
|
73
|
+
* This method is callable from the module-level build function
|
|
74
|
+
* without exposing `new JaaqClient(...)` to consumers.
|
|
75
|
+
*/
|
|
76
|
+
static fromHttp(http: HttpClient): JaaqClient;
|
|
77
|
+
/**
|
|
78
|
+
* OO-friendly static initializer.
|
|
79
|
+
* Delegates to the single source of truth: `buildClient`.
|
|
80
|
+
*/
|
|
81
|
+
static init(config: SDKConfig): JaaqClient;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Configuration options for video player components
|
|
86
|
+
*/
|
|
87
|
+
type PlayerConfig = {
|
|
88
|
+
/** Video ID to load */
|
|
89
|
+
videoId: string;
|
|
90
|
+
/** API key for authentication (required if no client provided) */
|
|
91
|
+
apiKey?: string;
|
|
92
|
+
/** Client ID for authentication (required if no client provided) */
|
|
93
|
+
clientId?: string;
|
|
94
|
+
/** Existing JaaqClient instance to use instead of creating a new one */
|
|
95
|
+
client?: JaaqClient;
|
|
96
|
+
/** Custom API base URL */
|
|
97
|
+
baseUrl?: string;
|
|
98
|
+
/** Whether to automatically start playback when video loads */
|
|
99
|
+
autoplay?: boolean;
|
|
100
|
+
/** Whether to show player controls */
|
|
101
|
+
controls?: boolean;
|
|
102
|
+
/** CSS width of the player container */
|
|
103
|
+
width?: string;
|
|
104
|
+
/** CSS height of the player container */
|
|
105
|
+
height?: string;
|
|
106
|
+
/** Additional CSS class name(s) to apply to the player */
|
|
107
|
+
className?: string;
|
|
108
|
+
/** Whether to show the JAAQ logo */
|
|
109
|
+
showLogo?: boolean;
|
|
110
|
+
/** Whether to show the video title */
|
|
111
|
+
showTitle?: boolean;
|
|
112
|
+
/** Whether to show the author name */
|
|
113
|
+
showAuthor?: boolean;
|
|
114
|
+
/** Whether to show the description */
|
|
115
|
+
showDescription?: boolean;
|
|
116
|
+
/** Whether to show captions button */
|
|
117
|
+
showCaptions?: boolean;
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* Current state of the video player
|
|
121
|
+
*/
|
|
122
|
+
type PlayerState = {
|
|
123
|
+
/** Whether the video is currently playing */
|
|
124
|
+
isPlaying: boolean;
|
|
125
|
+
/** Current playback time in seconds */
|
|
126
|
+
currentTime: number;
|
|
127
|
+
/** Total video duration in seconds */
|
|
128
|
+
duration: number;
|
|
129
|
+
/** Current volume level (0-1) */
|
|
130
|
+
volume: number;
|
|
131
|
+
/** Whether the audio is muted */
|
|
132
|
+
isMuted: boolean;
|
|
133
|
+
/** Whether the player is in fullscreen mode */
|
|
134
|
+
isFullscreen: boolean;
|
|
135
|
+
/** Whether the video is currently loading */
|
|
136
|
+
isLoading: boolean;
|
|
137
|
+
/** Error message if an error occurred, null otherwise */
|
|
138
|
+
error: string | null;
|
|
139
|
+
/** Loaded video data, null if not yet loaded */
|
|
140
|
+
videoData: VideoDTO | null;
|
|
141
|
+
/** Whether captions are currently enabled */
|
|
142
|
+
captionsEnabled: boolean;
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* Map of player event names to their payload types
|
|
146
|
+
*/
|
|
147
|
+
type PlayerEventMap = {
|
|
148
|
+
/** Fired when playback starts */
|
|
149
|
+
play: void;
|
|
150
|
+
/** Fired when playback pauses */
|
|
151
|
+
pause: void;
|
|
152
|
+
/** Fired when playback time updates, provides current time in seconds */
|
|
153
|
+
timeupdate: number;
|
|
154
|
+
/** Fired when volume changes, provides new volume level (0-1) */
|
|
155
|
+
volumechange: number;
|
|
156
|
+
/** Fired when playback reaches the end */
|
|
157
|
+
ended: void;
|
|
158
|
+
/** Fired when an error occurs, provides Error object */
|
|
159
|
+
error: Error;
|
|
160
|
+
/** Fired when video metadata is loaded, provides VideoDTO */
|
|
161
|
+
loaded: VideoDTO;
|
|
162
|
+
/** Fired when fullscreen state changes, provides boolean fullscreen state */
|
|
163
|
+
fullscreenchange: boolean;
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Custom web component for JAAQ video player with Shadow DOM encapsulation
|
|
168
|
+
* Provides a framework-agnostic video player with custom controls and HLS support
|
|
169
|
+
*
|
|
170
|
+
* @example
|
|
171
|
+
* // Declarative usage
|
|
172
|
+
* <jaaq-video-player
|
|
173
|
+
* video-id="video-123"
|
|
174
|
+
* api-key="key"
|
|
175
|
+
* client-id="client"
|
|
176
|
+
* autoplay="false">
|
|
177
|
+
* </jaaq-video-player>
|
|
178
|
+
*
|
|
179
|
+
* @example
|
|
180
|
+
* // Programmatic usage
|
|
181
|
+
* const player = document.createElement('jaaq-video-player');
|
|
182
|
+
* player.setAttribute('video-id', 'video-123');
|
|
183
|
+
* player.addEventListener('jaaq:play', () => console.log('Playing'));
|
|
184
|
+
* document.body.appendChild(player);
|
|
185
|
+
*/
|
|
186
|
+
declare class JaaqVideoPlayerElement extends HTMLElement {
|
|
187
|
+
private player;
|
|
188
|
+
private container;
|
|
189
|
+
private clientInstance;
|
|
190
|
+
private connected;
|
|
191
|
+
static get observedAttributes(): string[];
|
|
192
|
+
constructor();
|
|
193
|
+
connectedCallback(): void;
|
|
194
|
+
disconnectedCallback(): void;
|
|
195
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
196
|
+
private render;
|
|
197
|
+
private updateContainerStyles;
|
|
198
|
+
private initPlayer;
|
|
199
|
+
private attachPlayerEvents;
|
|
200
|
+
private emitError;
|
|
201
|
+
private destroyPlayer;
|
|
202
|
+
/**
|
|
203
|
+
* Gets the current JaaqClient instance
|
|
204
|
+
*/
|
|
205
|
+
get client(): JaaqClient | null;
|
|
206
|
+
/**
|
|
207
|
+
* Sets a JaaqClient instance for the player to use
|
|
208
|
+
* Reinitializes the player if already connected
|
|
209
|
+
*/
|
|
210
|
+
set client(value: JaaqClient | null);
|
|
211
|
+
/**
|
|
212
|
+
* Gets the current video ID
|
|
213
|
+
*/
|
|
214
|
+
get videoId(): string | null;
|
|
215
|
+
/**
|
|
216
|
+
* Sets the video ID
|
|
217
|
+
* Updates the video-id attribute and triggers player reinitialization
|
|
218
|
+
*/
|
|
219
|
+
set videoId(value: string | null);
|
|
220
|
+
/**
|
|
221
|
+
* Starts or resumes video playback
|
|
222
|
+
*/
|
|
223
|
+
play(): void;
|
|
224
|
+
/**
|
|
225
|
+
* Pauses video playback
|
|
226
|
+
*/
|
|
227
|
+
pause(): void;
|
|
228
|
+
/**
|
|
229
|
+
* Sets the playback volume
|
|
230
|
+
* @param volume - Volume level between 0 (silent) and 1 (maximum)
|
|
231
|
+
*/
|
|
232
|
+
setVolume(volume: number): void;
|
|
233
|
+
/**
|
|
234
|
+
* Toggles audio mute state
|
|
235
|
+
*/
|
|
236
|
+
toggleMute(): void;
|
|
237
|
+
/**
|
|
238
|
+
* Seeks to a specific time in the video
|
|
239
|
+
* @param time - Target time in seconds
|
|
240
|
+
*/
|
|
241
|
+
seek(time: number): void;
|
|
242
|
+
/**
|
|
243
|
+
* Returns the current player state
|
|
244
|
+
* @returns Current player state object or null if player not initialized
|
|
245
|
+
*/
|
|
246
|
+
getState(): PlayerState | null;
|
|
247
|
+
/**
|
|
248
|
+
* Destroys the player instance and cleans up resources
|
|
249
|
+
*/
|
|
250
|
+
destroy(): void;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
declare class JaaqCollectionPlayerElement extends HTMLElement {
|
|
254
|
+
private splide;
|
|
255
|
+
private container;
|
|
256
|
+
private carouselElement;
|
|
257
|
+
private clientInstance;
|
|
258
|
+
private connected;
|
|
259
|
+
private collectionData;
|
|
260
|
+
private autoplayTimeoutId;
|
|
261
|
+
static get observedAttributes(): string[];
|
|
262
|
+
constructor();
|
|
263
|
+
connectedCallback(): void;
|
|
264
|
+
disconnectedCallback(): void;
|
|
265
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
266
|
+
private getBooleanAttr;
|
|
267
|
+
private render;
|
|
268
|
+
private initCarousel;
|
|
269
|
+
private showLoading;
|
|
270
|
+
private renderCarousel;
|
|
271
|
+
private initSplide;
|
|
272
|
+
private handleSlideChange;
|
|
273
|
+
private destroyCarousel;
|
|
274
|
+
private emitError;
|
|
275
|
+
get client(): JaaqClient | null;
|
|
276
|
+
set client(value: JaaqClient | null);
|
|
277
|
+
get collectionId(): string | null;
|
|
278
|
+
set collectionId(value: string | null);
|
|
279
|
+
refresh(): void;
|
|
280
|
+
next(): void;
|
|
281
|
+
prev(): void;
|
|
282
|
+
go(index: number): void;
|
|
283
|
+
destroy(): void;
|
|
284
|
+
getCollection(): CollectionDTO | null;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
export { JaaqCollectionPlayerElement, JaaqVideoPlayerElement, isRegistered, registerJaaqComponents };
|
|
288
|
+
export type { PlayerConfig, PlayerEventMap, PlayerState };
|