Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3338261cfa | |||
| 888ec95185 | |||
| 673af0e39c | |||
| dc8774718d | |||
| 9a87888f5a | |||
| d61c3b6643 | |||
| c8554418de |
23
changelog.md
23
changelog.md
@@ -1,5 +1,28 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 2026-01-02 - 1.7.0 - feat(recorder)
|
||||||
|
lazy-load rrweb and rrweb-player from CDN via SioServiceLibLoader and switch sio-recorder to use the loader
|
||||||
|
|
||||||
|
- Add SioServiceLibLoader service to lazy-load rrweb and rrweb-player (and inject rrweb-player CSS)
|
||||||
|
- Add versions file (CDN_VERSIONS and CDN_BASE) and export loader from ts_web/index.ts
|
||||||
|
- Update sio-recorder to use the loader for recording and playback instead of bundling rrweb/rrweb-player
|
||||||
|
- Remove rrweb, rrweb-player and rrweb-snapshot from dependencies and bump lucide and @design.estate/dees-wcctools versions
|
||||||
|
- Small package.json changes: remove --skiplibcheck from build script and bump @git.zone/tstest devDependency
|
||||||
|
|
||||||
|
## 2025-12-18 - 1.6.1 - fix(sio-combox)
|
||||||
|
tweak dropdown shadow and bind close event on conversation selector
|
||||||
|
|
||||||
|
- Replaced unsafeCSS(shadows.xl) with explicit box-shadow values for the combox dropdown to adjust visual appearance
|
||||||
|
- Added @close listener on <sio-conversation-selector> to call this.close(), enabling the selector to close the combox when it emits a close event
|
||||||
|
- Affected file: ts_web/elements/sio-combox.ts
|
||||||
|
|
||||||
|
## 2025-12-18 - 1.6.0 - feat(conversation-selector)
|
||||||
|
add conversation status badges to conversation selector and include status in sample data
|
||||||
|
|
||||||
|
- Introduce TConversationStatus type and add optional status property to IConversation
|
||||||
|
- Render status badges in sio-conversation-selector with CSS classes and a getBadgeLabel helper
|
||||||
|
- Update sample conversations in sio-combox.ts to include statuses: 'new', 'needs-action', 'waiting', 'resolved'
|
||||||
|
|
||||||
## 2025-12-17 - 1.5.0 - feat(combox)
|
## 2025-12-17 - 1.5.0 - feat(combox)
|
||||||
Introduce singleton SioCombox attached to document.body with open/close/toggle API and animated show/hide; integrate SioFab to use the singleton and update styles/positioning
|
Introduce singleton SioCombox attached to document.body with open/close/toggle API and animated show/hide; integrate SioFab to use the singleton and update styles/positioning
|
||||||
|
|
||||||
|
|||||||
13
package.json
13
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@social.io/catalog",
|
"name": "@social.io/catalog",
|
||||||
"version": "1.5.0",
|
"version": "1.7.0",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "catalog for social.io",
|
"description": "catalog for social.io",
|
||||||
"main": "dist_ts_web/index.js",
|
"main": "dist_ts_web/index.js",
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "tstest test/",
|
"test": "tstest test/",
|
||||||
"build": "tsbuild tsfolders --allowimplicitany --skiplibcheck && tsbundle element --production",
|
"build": "tsbuild tsfolders --allowimplicitany && tsbundle element --production",
|
||||||
"watch": "tswatch element",
|
"watch": "tswatch element",
|
||||||
"buildDocs": "tsdoc"
|
"buildDocs": "tsdoc"
|
||||||
},
|
},
|
||||||
@@ -17,19 +17,16 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@design.estate/dees-domtools": "^2.3.6",
|
"@design.estate/dees-domtools": "^2.3.6",
|
||||||
"@design.estate/dees-element": "^2.1.3",
|
"@design.estate/dees-element": "^2.1.3",
|
||||||
"@design.estate/dees-wcctools": "^2.0.1",
|
"@design.estate/dees-wcctools": "^3.4.0",
|
||||||
"@losslessone_private/loint-pubapi": "^1.0.14",
|
"@losslessone_private/loint-pubapi": "^1.0.14",
|
||||||
"@social.io/interfaces": "^1.2.1",
|
"@social.io/interfaces": "^1.2.1",
|
||||||
"lucide": "^0.561.0",
|
"lucide": "^0.562.0"
|
||||||
"rrweb": "2.0.0-alpha.4",
|
|
||||||
"rrweb-player": "1.0.0-alpha.4",
|
|
||||||
"rrweb-snapshot": "2.0.0-alpha.4"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@git.zone/tsbuild": "^4.0.2",
|
"@git.zone/tsbuild": "^4.0.2",
|
||||||
"@git.zone/tsbundle": "^2.6.3",
|
"@git.zone/tsbundle": "^2.6.3",
|
||||||
"@git.zone/tsrun": "^2.0.1",
|
"@git.zone/tsrun": "^2.0.1",
|
||||||
"@git.zone/tstest": "^3.1.3",
|
"@git.zone/tstest": "^3.1.4",
|
||||||
"@git.zone/tswatch": "^2.3.13",
|
"@git.zone/tswatch": "^2.3.13",
|
||||||
"@push.rocks/projectinfo": "^5.0.2",
|
"@push.rocks/projectinfo": "^5.0.2",
|
||||||
"@push.rocks/smartenv": "^6.0.0",
|
"@push.rocks/smartenv": "^6.0.0",
|
||||||
|
|||||||
1541
pnpm-lock.yaml
generated
1541
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@social.io/catalog',
|
name: '@social.io/catalog',
|
||||||
version: '1.5.0',
|
version: '1.7.0',
|
||||||
description: 'catalog for social.io'
|
description: 'catalog for social.io'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,24 +79,28 @@ export class SioCombox extends DeesElement {
|
|||||||
lastMessage: 'Thanks for your help with the login issue!',
|
lastMessage: 'Thanks for your help with the login issue!',
|
||||||
time: '2 min ago',
|
time: '2 min ago',
|
||||||
unread: true,
|
unread: true,
|
||||||
|
status: 'new',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: '2',
|
id: '2',
|
||||||
title: 'Billing Question',
|
title: 'Billing Question',
|
||||||
lastMessage: 'I need help understanding my invoice',
|
lastMessage: 'I need help understanding my invoice',
|
||||||
time: '1 hour ago',
|
time: '1 hour ago',
|
||||||
|
status: 'needs-action',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: '3',
|
id: '3',
|
||||||
title: 'Feature Request',
|
title: 'Feature Request',
|
||||||
lastMessage: 'That would be great! Looking forward to it',
|
lastMessage: 'That would be great! Looking forward to it',
|
||||||
time: 'Yesterday',
|
time: 'Yesterday',
|
||||||
|
status: 'waiting',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: '4',
|
id: '4',
|
||||||
title: 'General Inquiry',
|
title: 'General Inquiry',
|
||||||
lastMessage: 'Thank you for the information',
|
lastMessage: 'Thank you for the information',
|
||||||
time: '2 days ago',
|
time: '2 days ago',
|
||||||
|
status: 'resolved',
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -255,7 +259,7 @@ export class SioCombox extends DeesElement {
|
|||||||
background: ${bdTheme('background')};
|
background: ${bdTheme('background')};
|
||||||
border-radius: ${unsafeCSS(radius['2xl'])};
|
border-radius: ${unsafeCSS(radius['2xl'])};
|
||||||
border: 1px solid ${bdTheme('border')};
|
border: 1px solid ${bdTheme('border')};
|
||||||
box-shadow: ${unsafeCSS(shadows.xl)};
|
box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.35), 0 12px 24px -8px rgb(0 0 0 / 0.15);
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
font-family: ${unsafeCSS(fontFamilies.sans)};
|
font-family: ${unsafeCSS(fontFamilies.sans)};
|
||||||
transform-origin: bottom right;
|
transform-origin: bottom right;
|
||||||
@@ -397,6 +401,7 @@ export class SioCombox extends DeesElement {
|
|||||||
.conversations=${this.conversations}
|
.conversations=${this.conversations}
|
||||||
.selectedConversationId=${this.selectedConversationId}
|
.selectedConversationId=${this.selectedConversationId}
|
||||||
@conversation-selected=${this.handleConversationSelected}
|
@conversation-selected=${this.handleConversationSelected}
|
||||||
|
@close=${() => this.close()}
|
||||||
></sio-conversation-selector>
|
></sio-conversation-selector>
|
||||||
|
|
||||||
<sio-conversation-view
|
<sio-conversation-view
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ import { spacing, radius, shadows, transitions } from './00tokens.js';
|
|||||||
import { fontFamilies, typography } from './00fonts.js';
|
import { fontFamilies, typography } from './00fonts.js';
|
||||||
|
|
||||||
// Types
|
// Types
|
||||||
|
export type TConversationStatus = 'new' | 'waiting' | 'needs-action' | 'resolved';
|
||||||
|
|
||||||
export interface IConversation {
|
export interface IConversation {
|
||||||
id: string;
|
id: string;
|
||||||
title: string;
|
title: string;
|
||||||
@@ -23,6 +25,7 @@ export interface IConversation {
|
|||||||
time: string;
|
time: string;
|
||||||
unread?: boolean;
|
unread?: boolean;
|
||||||
avatar?: string;
|
avatar?: string;
|
||||||
|
status?: TConversationStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
@@ -232,6 +235,38 @@ export class SioConversationSelector extends DeesElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.badge {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
padding: 2px ${unsafeCSS(spacing["2"])};
|
||||||
|
font-size: 0.625rem;
|
||||||
|
font-weight: 600;
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.025em;
|
||||||
|
border-radius: ${unsafeCSS(radius.full)};
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.badge.new {
|
||||||
|
background: ${bdTheme('primary')}20;
|
||||||
|
color: ${bdTheme('primary')};
|
||||||
|
}
|
||||||
|
|
||||||
|
.badge.waiting {
|
||||||
|
background: ${bdTheme('muted')};
|
||||||
|
color: ${bdTheme('mutedForeground')};
|
||||||
|
}
|
||||||
|
|
||||||
|
.badge.needs-action {
|
||||||
|
background: hsl(38 92% 50% / 0.15);
|
||||||
|
color: hsl(38 92% 40%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.badge.resolved {
|
||||||
|
background: ${bdTheme('success')}20;
|
||||||
|
color: ${bdTheme('success')};
|
||||||
|
}
|
||||||
|
|
||||||
.empty-state {
|
.empty-state {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@@ -331,6 +366,7 @@ export class SioConversationSelector extends DeesElement {
|
|||||||
<span class="conversation-title">
|
<span class="conversation-title">
|
||||||
${conv.title}
|
${conv.title}
|
||||||
${conv.unread ? html`<span class="unread-dot"></span>` : ''}
|
${conv.unread ? html`<span class="unread-dot"></span>` : ''}
|
||||||
|
${conv.status ? html`<span class="badge ${conv.status}">${this.getBadgeLabel(conv.status)}</span>` : ''}
|
||||||
</span>
|
</span>
|
||||||
<span class="conversation-time">${conv.time}</span>
|
<span class="conversation-time">${conv.time}</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -389,4 +425,14 @@ export class SioConversationSelector extends DeesElement {
|
|||||||
composed: true
|
composed: true
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private getBadgeLabel(status: TConversationStatus): string {
|
||||||
|
const labels: Record<TConversationStatus, string> = {
|
||||||
|
'new': 'New',
|
||||||
|
'waiting': 'Waiting',
|
||||||
|
'needs-action': 'Action',
|
||||||
|
'resolved': 'Resolved',
|
||||||
|
};
|
||||||
|
return labels[status];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -160,27 +160,6 @@ export class SioDropdownMenu extends DeesElement {
|
|||||||
background: ${bdTheme('border')};
|
background: ${bdTheme('border')};
|
||||||
margin: ${unsafeCSS(spacing["1"])} 0;
|
margin: ${unsafeCSS(spacing["1"])} 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Mobile adjustments */
|
|
||||||
@media (max-width: 600px) {
|
|
||||||
.dropdown {
|
|
||||||
position: fixed;
|
|
||||||
top: auto !important;
|
|
||||||
left: ${unsafeCSS(spacing["4"])} !important;
|
|
||||||
right: ${unsafeCSS(spacing["4"])};
|
|
||||||
bottom: ${unsafeCSS(spacing["4"])};
|
|
||||||
width: auto;
|
|
||||||
transform-origin: bottom center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.dropdown.open {
|
|
||||||
transform: translateY(0) scale(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
.dropdown:not(.open) {
|
|
||||||
transform: translateY(10px) scale(0.95);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`,
|
`,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -6,11 +6,7 @@ import {
|
|||||||
property,
|
property,
|
||||||
query,
|
query,
|
||||||
} from '@design.estate/dees-element';
|
} from '@design.estate/dees-element';
|
||||||
import * as rrwebMod from 'rrweb';
|
import { SioServiceLibLoader } from '../services/SioServiceLibLoader.js';
|
||||||
import rrwebPlayerMod from 'rrweb-player';
|
|
||||||
|
|
||||||
const rrweb: any = rrwebMod;
|
|
||||||
const rrwebPlayer: typeof rrwebPlayerMod.default = rrwebPlayerMod as any;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use rrweb's eventWithTime if you like strict typing:
|
* Use rrweb's eventWithTime if you like strict typing:
|
||||||
@@ -106,6 +102,10 @@ export class SioRecorder extends DeesElement {
|
|||||||
*/
|
*/
|
||||||
private async startRecording(): Promise<void> {
|
private async startRecording(): Promise<void> {
|
||||||
await this.domtoolsPromise;
|
await this.domtoolsPromise;
|
||||||
|
|
||||||
|
// Load rrweb from CDN
|
||||||
|
const rrweb = await SioServiceLibLoader.getInstance().loadRrweb();
|
||||||
|
|
||||||
this.status = 'recording';
|
this.status = 'recording';
|
||||||
this.events = [];
|
this.events = [];
|
||||||
|
|
||||||
@@ -148,7 +148,12 @@ export class SioRecorder extends DeesElement {
|
|||||||
private async playRecording(): Promise<void> {
|
private async playRecording(): Promise<void> {
|
||||||
await this.domtoolsPromise;
|
await this.domtoolsPromise;
|
||||||
if (!this.playbackDiv) return;
|
if (!this.playbackDiv) return;
|
||||||
const replayer = new rrwebPlayer({
|
|
||||||
|
// Load rrweb-player from CDN
|
||||||
|
const rrwebPlayerBundle = await SioServiceLibLoader.getInstance().loadRrwebPlayer();
|
||||||
|
const RrwebPlayer = rrwebPlayerBundle.default;
|
||||||
|
|
||||||
|
const replayer = new RrwebPlayer({
|
||||||
target: this.playbackDiv, // customizable root element
|
target: this.playbackDiv, // customizable root element
|
||||||
props: {
|
props: {
|
||||||
events: this.events as any,
|
events: this.events as any,
|
||||||
|
|||||||
@@ -1 +1,2 @@
|
|||||||
export * from './elements/index.js';
|
export * from './elements/index.js';
|
||||||
|
export * from './services/SioServiceLibLoader.js';
|
||||||
|
|||||||
200
ts_web/services/SioServiceLibLoader.ts
Normal file
200
ts_web/services/SioServiceLibLoader.ts
Normal file
@@ -0,0 +1,200 @@
|
|||||||
|
import { CDN_BASE, CDN_VERSIONS } from './versions.js';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* rrweb record options
|
||||||
|
*/
|
||||||
|
export interface IRrwebRecordOptions {
|
||||||
|
emit: (event: any) => void;
|
||||||
|
recordCanvas?: boolean;
|
||||||
|
recordCrossOriginIframes?: boolean;
|
||||||
|
checkoutEveryNms?: number;
|
||||||
|
[key: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* rrweb record function type
|
||||||
|
*/
|
||||||
|
export type TRrwebRecordFn = (options: IRrwebRecordOptions) => () => void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bundle type for rrweb recording library
|
||||||
|
*/
|
||||||
|
export interface IRrwebBundle {
|
||||||
|
record: TRrwebRecordFn;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* rrweb-player constructor options
|
||||||
|
*/
|
||||||
|
export interface IRrwebPlayerOptions {
|
||||||
|
target: HTMLElement;
|
||||||
|
props: {
|
||||||
|
events: any[];
|
||||||
|
root?: HTMLElement;
|
||||||
|
showController?: boolean;
|
||||||
|
width?: number;
|
||||||
|
height?: number;
|
||||||
|
[key: string]: any;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* rrweb-player instance
|
||||||
|
*/
|
||||||
|
export interface IRrwebPlayerInstance {
|
||||||
|
play: () => Promise<void>;
|
||||||
|
pause: () => void;
|
||||||
|
[key: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* rrweb-player constructor type
|
||||||
|
*/
|
||||||
|
export type TRrwebPlayerConstructor = new (options: IRrwebPlayerOptions) => IRrwebPlayerInstance;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bundle type for rrweb-player
|
||||||
|
*/
|
||||||
|
export interface IRrwebPlayerBundle {
|
||||||
|
default: TRrwebPlayerConstructor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Singleton service for lazy-loading rrweb libraries from CDN.
|
||||||
|
*
|
||||||
|
* This reduces initial bundle size by loading libraries only when needed.
|
||||||
|
* Libraries are cached after first load to avoid duplicate fetches.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* ```typescript
|
||||||
|
* const libLoader = SioServiceLibLoader.getInstance();
|
||||||
|
* const rrweb = await libLoader.loadRrweb();
|
||||||
|
* const stopFn = rrweb.record({ emit: (event) => { ... } });
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
|
export class SioServiceLibLoader {
|
||||||
|
private static instance: SioServiceLibLoader;
|
||||||
|
|
||||||
|
// Cached library references
|
||||||
|
private rrwebLib: IRrwebBundle | null = null;
|
||||||
|
private rrwebPlayerLib: IRrwebPlayerBundle | null = null;
|
||||||
|
|
||||||
|
// Loading promises to prevent duplicate concurrent loads
|
||||||
|
private rrwebLoadingPromise: Promise<IRrwebBundle> | null = null;
|
||||||
|
private rrwebPlayerLoadingPromise: Promise<IRrwebPlayerBundle> | null = null;
|
||||||
|
|
||||||
|
private constructor() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the singleton instance of SioServiceLibLoader
|
||||||
|
*/
|
||||||
|
public static getInstance(): SioServiceLibLoader {
|
||||||
|
if (!SioServiceLibLoader.instance) {
|
||||||
|
SioServiceLibLoader.instance = new SioServiceLibLoader();
|
||||||
|
}
|
||||||
|
return SioServiceLibLoader.instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load rrweb recording library from CDN
|
||||||
|
* @returns Promise resolving to rrweb module with record function
|
||||||
|
*/
|
||||||
|
public async loadRrweb(): Promise<IRrwebBundle> {
|
||||||
|
if (this.rrwebLib) {
|
||||||
|
return this.rrwebLib;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.rrwebLoadingPromise) {
|
||||||
|
return this.rrwebLoadingPromise;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.rrwebLoadingPromise = (async () => {
|
||||||
|
const url = `${CDN_BASE}/rrweb@${CDN_VERSIONS.rrweb}/+esm`;
|
||||||
|
const module = await import(/* @vite-ignore */ url);
|
||||||
|
|
||||||
|
this.rrwebLib = {
|
||||||
|
record: module.record,
|
||||||
|
};
|
||||||
|
return this.rrwebLib;
|
||||||
|
})();
|
||||||
|
|
||||||
|
return this.rrwebLoadingPromise;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load rrweb-player from CDN
|
||||||
|
* @returns Promise resolving to rrweb-player module
|
||||||
|
*/
|
||||||
|
public async loadRrwebPlayer(): Promise<IRrwebPlayerBundle> {
|
||||||
|
if (this.rrwebPlayerLib) {
|
||||||
|
return this.rrwebPlayerLib;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.rrwebPlayerLoadingPromise) {
|
||||||
|
return this.rrwebPlayerLoadingPromise;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.rrwebPlayerLoadingPromise = (async () => {
|
||||||
|
const url = `${CDN_BASE}/rrweb-player@${CDN_VERSIONS.rrwebPlayer}/+esm`;
|
||||||
|
const module = await import(/* @vite-ignore */ url);
|
||||||
|
|
||||||
|
// Inject rrweb-player CSS styles
|
||||||
|
await this.injectRrwebPlayerStyles();
|
||||||
|
|
||||||
|
this.rrwebPlayerLib = {
|
||||||
|
default: module.default,
|
||||||
|
};
|
||||||
|
return this.rrwebPlayerLib;
|
||||||
|
})();
|
||||||
|
|
||||||
|
return this.rrwebPlayerLoadingPromise;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inject rrweb-player CSS styles into the document head
|
||||||
|
*/
|
||||||
|
private async injectRrwebPlayerStyles(): Promise<void> {
|
||||||
|
const styleId = 'rrweb-player-cdn-styles';
|
||||||
|
if (document.getElementById(styleId)) {
|
||||||
|
return; // Already injected
|
||||||
|
}
|
||||||
|
|
||||||
|
const cssUrl = `${CDN_BASE}/rrweb-player@${CDN_VERSIONS.rrwebPlayer}/dist/style.css`;
|
||||||
|
try {
|
||||||
|
const response = await fetch(cssUrl);
|
||||||
|
const cssText = await response.text();
|
||||||
|
|
||||||
|
const style = document.createElement('style');
|
||||||
|
style.id = styleId;
|
||||||
|
style.textContent = cssText;
|
||||||
|
document.head.appendChild(style);
|
||||||
|
} catch (error) {
|
||||||
|
console.warn('Failed to load rrweb-player styles from CDN:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Preload all rrweb libraries in parallel
|
||||||
|
* Useful for warming the cache before recording is needed
|
||||||
|
*/
|
||||||
|
public async preloadAll(): Promise<void> {
|
||||||
|
await Promise.all([
|
||||||
|
this.loadRrweb(),
|
||||||
|
this.loadRrwebPlayer(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a specific library is already loaded
|
||||||
|
*/
|
||||||
|
public isLoaded(library: 'rrweb' | 'rrwebPlayer'): boolean {
|
||||||
|
switch (library) {
|
||||||
|
case 'rrweb':
|
||||||
|
return this.rrwebLib !== null;
|
||||||
|
case 'rrwebPlayer':
|
||||||
|
return this.rrwebPlayerLib !== null;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
13
ts_web/services/versions.ts
Normal file
13
ts_web/services/versions.ts
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
/**
|
||||||
|
* CDN versions for lazy-loaded libraries.
|
||||||
|
* Keep these in sync with package.json for type compatibility.
|
||||||
|
*/
|
||||||
|
export const CDN_VERSIONS = {
|
||||||
|
rrweb: '2.0.0-alpha.4',
|
||||||
|
rrwebPlayer: '1.0.0-alpha.4',
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base CDN URL for jsdelivr ESM imports
|
||||||
|
*/
|
||||||
|
export const CDN_BASE = 'https://cdn.jsdelivr.net/npm';
|
||||||
Reference in New Issue
Block a user