@djangocfg/ui-tools 2.1.293 → 2.1.297
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/{DocsLayout-XB55R7YG.mjs → DocsLayout-3HNAQQRE.mjs} +3 -3
- package/dist/{DocsLayout-XB55R7YG.mjs.map → DocsLayout-3HNAQQRE.mjs.map} +1 -1
- package/dist/{DocsLayout-PLWQJBGU.cjs → DocsLayout-O4ONSD67.cjs} +48 -48
- package/dist/{DocsLayout-PLWQJBGU.cjs.map → DocsLayout-O4ONSD67.cjs.map} +1 -1
- package/dist/{chunk-EFWOJPA6.mjs → chunk-DKJTH4GE.mjs} +25 -6
- package/dist/chunk-DKJTH4GE.mjs.map +1 -0
- package/dist/{chunk-5Q4UMSWB.cjs → chunk-QTO5LWMK.cjs} +25 -6
- package/dist/chunk-QTO5LWMK.cjs.map +1 -0
- package/dist/index.cjs +9 -9
- package/dist/index.d.cts +40 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.mjs +4 -4
- package/package.json +6 -6
- package/src/components/markdown/MarkdownMessage.tsx +74 -5
- package/src/tools/OpenapiViewer/README.md +2 -1
- package/dist/chunk-5Q4UMSWB.cjs.map +0 -1
- package/dist/chunk-EFWOJPA6.mjs.map +0 -1
- package/src/tools/ImageViewer/@refactoring/00-PLAN.md +0 -71
- package/src/tools/ImageViewer/@refactoring/01-TYPES.md +0 -121
- package/src/tools/ImageViewer/@refactoring/02-UTILS.md +0 -143
- package/src/tools/ImageViewer/@refactoring/03-HOOKS.md +0 -261
- package/src/tools/ImageViewer/@refactoring/04-COMPONENTS.md +0 -427
- package/src/tools/ImageViewer/@refactoring/05-EXECUTION-CHECKLIST.md +0 -126
- package/src/tools/OpenapiViewer/.claude/.sidecar/activity.jsonl +0 -6
- package/src/tools/OpenapiViewer/.claude/.sidecar/history/2026-04-22.md +0 -35
- package/src/tools/OpenapiViewer/.claude/.sidecar/map_cache.json +0 -30
- package/src/tools/OpenapiViewer/.claude/.sidecar/review.md +0 -35
- package/src/tools/OpenapiViewer/.claude/.sidecar/scan.log +0 -3
- package/src/tools/OpenapiViewer/.claude/.sidecar/tasks/T-001.md +0 -18
- package/src/tools/OpenapiViewer/.claude/.sidecar/tasks/T-002.md +0 -18
- package/src/tools/OpenapiViewer/.claude/.sidecar/tasks/T-003.md +0 -18
- package/src/tools/OpenapiViewer/.claude/.sidecar/tasks/T-004.md +0 -18
- package/src/tools/OpenapiViewer/.claude/.sidecar/tasks/T-005.md +0 -18
- package/src/tools/OpenapiViewer/.claude/.sidecar/usage.json +0 -5
- package/src/tools/OpenapiViewer/.claude/project-map.md +0 -23
- package/src/tools/VideoPlayer/@refactoring/00-PLAN.md +0 -91
- package/src/tools/VideoPlayer/@refactoring/01-TYPES.md +0 -284
- package/src/tools/VideoPlayer/@refactoring/02-UTILS.md +0 -141
- package/src/tools/VideoPlayer/@refactoring/03-HOOKS.md +0 -178
- package/src/tools/VideoPlayer/@refactoring/04-COMPONENTS.md +0 -95
- package/src/tools/VideoPlayer/@refactoring/05-EXECUTION-CHECKLIST.md +0 -139
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
context_files:
|
|
3
|
-
- .claude/project-map.md
|
|
4
|
-
created_at: '2026-04-22T16:47:48.101004Z'
|
|
5
|
-
id: T-002
|
|
6
|
-
priority: high
|
|
7
|
-
source: sidecar_review
|
|
8
|
-
source_item_id: 4654646dd66d
|
|
9
|
-
status: pending
|
|
10
|
-
title: '[gap] The project map lists source directories (components, context, hooks,
|
|
11
|
-
utils) typ'
|
|
12
|
-
---
|
|
13
|
-
|
|
14
|
-
The project map lists source directories (components, context, hooks, utils) typical of a React library, but recent commits mention backend (Django) and frontend framework (Next.js) concepts not covered. Key areas like 'layouts/', 'navigation/', and Django app structure have no documentation in the provided map.
|
|
15
|
-
|
|
16
|
-
**Files:** .claude/project-map.md
|
|
17
|
-
|
|
18
|
-
**Action:** Expand the project map to document the actual codebase structure, including Django apps, Next.js pages/layouts, and how the frontend and backend integrate.
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
context_files:
|
|
3
|
-
- .claude/project-map.md
|
|
4
|
-
created_at: '2026-04-22T16:47:48.101333Z'
|
|
5
|
-
id: T-003
|
|
6
|
-
priority: high
|
|
7
|
-
source: sidecar_review
|
|
8
|
-
source_item_id: c81e59d10f1a
|
|
9
|
-
status: pending
|
|
10
|
-
title: '[gap] No dependencies are listed in the analysis, but recent commits reference
|
|
11
|
-
specifi'
|
|
12
|
-
---
|
|
13
|
-
|
|
14
|
-
No dependencies are listed in the analysis, but recent commits reference specific packages and tools (e.g., 'drf-spectacular', 'Nextra'). The project map provides no dependency information, which is a critical gap for understanding the project's environment.
|
|
15
|
-
|
|
16
|
-
**Files:** .claude/project-map.md
|
|
17
|
-
|
|
18
|
-
**Action:** Add a 'Dependencies' section to the project map or ensure dependency files (pyproject.toml, package.json) are included in the documentation analysis.
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
context_files:
|
|
3
|
-
- .claude/project-map.md
|
|
4
|
-
created_at: '2026-04-22T16:47:48.101697Z'
|
|
5
|
-
id: T-004
|
|
6
|
-
priority: medium
|
|
7
|
-
source: sidecar_review
|
|
8
|
-
source_item_id: ba6f809d9f15
|
|
9
|
-
status: pending
|
|
10
|
-
title: '[contradiction] The project map''s ''Entry Points'' list React component entry
|
|
11
|
-
files (e.g., ''./inde'
|
|
12
|
-
---
|
|
13
|
-
|
|
14
|
-
The project map's 'Entry Points' list React component entry files (e.g., './index.tsx'), but commits suggest a Django/Next.js application with different entry points (e.g., Django's manage.py, Next.js's pages/).
|
|
15
|
-
|
|
16
|
-
**Files:** .claude/project-map.md
|
|
17
|
-
|
|
18
|
-
**Action:** Update the entry points list in the project map to reflect the actual application entry points (e.g., main Django ASGI/WSGI file, Next.js entry).
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
context_files:
|
|
3
|
-
- .claude/project-map.md
|
|
4
|
-
created_at: '2026-04-22T16:47:48.102118Z'
|
|
5
|
-
id: T-005
|
|
6
|
-
priority: medium
|
|
7
|
-
source: sidecar_review
|
|
8
|
-
source_item_id: 4bd49eecdaa4
|
|
9
|
-
status: pending
|
|
10
|
-
title: '[staleness] The project map was generated on 2026-04-22, but it describes
|
|
11
|
-
a React library ar'
|
|
12
|
-
---
|
|
13
|
-
|
|
14
|
-
The project map was generated on 2026-04-22, but it describes a React library architecture that contradicts the Django/Next.js work shown in commits from 2026-04-17 to 2026-04-22. The map's content is stale relative to the project's true evolution.
|
|
15
|
-
|
|
16
|
-
**Files:** .claude/project-map.md
|
|
17
|
-
|
|
18
|
-
**Action:** Regenerate the project map using a tool that accurately reflects the current codebase structure and technology stack.
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
# Project Map
|
|
2
|
-
> react-component-library — An interactive OpenAPI 3.x viewer component with a Stripe/Scalar-style documentation layout and integrated playground.
|
|
3
|
-
> Generated: 2026-04-22T13:15:40.111463+00:00
|
|
4
|
-
|
|
5
|
-
## Structure
|
|
6
|
-
|
|
7
|
-
- `components/` — Re-export barrel file for the library's public component APIs. **[entry: index.ts]**
|
|
8
|
-
- `components/DocsLayout/` — Main documentation layout component and its sub-components, handling sidebar, API display, and interactive playground sheet. **[entry: index.tsx]**
|
|
9
|
-
- `components/shared/` — Shared UI panels (request/response editors) used by the DocsLayout and mobile interactions.
|
|
10
|
-
- `context/` — React context for managing the playground state, such as endpoint drafts and API calls.
|
|
11
|
-
- `hooks/` — Custom React hooks for managing state like API schemas, endpoint drafts, and responsive behavior. **[entry: index.ts]**
|
|
12
|
-
- `utils/` — Utility functions for API key management, URL building, schema exporting, and data formatting. **[entry: index.ts]**
|
|
13
|
-
|
|
14
|
-
## Entry Points
|
|
15
|
-
|
|
16
|
-
- `./index.tsx`
|
|
17
|
-
- `components/index.ts`
|
|
18
|
-
- `components/DocsLayout/index.tsx`
|
|
19
|
-
- `hooks/index.ts`
|
|
20
|
-
- `utils/index.ts`
|
|
21
|
-
|
|
22
|
-
---
|
|
23
|
-
Model: cache | Tokens: 0
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
# VideoPlayer Refactoring Plan
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
|
|
5
|
-
The VideoPlayer is already reasonably well-organized with a `providers/` subfolder. This refactoring focuses on incremental improvements rather than major restructuring.
|
|
6
|
-
|
|
7
|
-
**Total: 2,024 lines across 10 files**
|
|
8
|
-
|
|
9
|
-
## Current Structure (Before)
|
|
10
|
-
|
|
11
|
-
```
|
|
12
|
-
VideoPlayer/
|
|
13
|
-
├── index.ts (68 lines) # Public exports
|
|
14
|
-
├── types.ts (369 lines) # All types + helper functions ⚠️
|
|
15
|
-
├── VideoPlayer.tsx (202 lines) # Main orchestrator
|
|
16
|
-
├── VideoPlayerContext.tsx (125 lines) # Streaming context
|
|
17
|
-
├── VideoControls.tsx (139 lines) # Vidstack controls
|
|
18
|
-
├── VideoErrorFallback.tsx (174 lines) # Error UI
|
|
19
|
-
├── README.md
|
|
20
|
-
└── providers/
|
|
21
|
-
├── index.ts (8 lines)
|
|
22
|
-
├── VidstackProvider.tsx (332 lines) # YouTube/Vimeo/HLS/DASH
|
|
23
|
-
├── NativeProvider.tsx (206 lines) # HTML5 <video>
|
|
24
|
-
└── StreamProvider.tsx (401 lines) # HTTP Range + Blob ⚠️
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
**Issues Identified:**
|
|
28
|
-
1. `types.ts` (369 lines) - Contains types AND helper functions
|
|
29
|
-
2. `StreamProvider.tsx` (401 lines) - Largest file, multiple concerns
|
|
30
|
-
3. Position caching logic duplicated in VidstackProvider & StreamProvider
|
|
31
|
-
4. No dedicated hooks/ folder
|
|
32
|
-
|
|
33
|
-
## Target Structure (After)
|
|
34
|
-
|
|
35
|
-
```
|
|
36
|
-
VideoPlayer/
|
|
37
|
-
├── index.ts # Public API
|
|
38
|
-
├── README.md
|
|
39
|
-
├── types/
|
|
40
|
-
│ ├── index.ts # Re-exports all types
|
|
41
|
-
│ ├── sources.ts # Source type definitions
|
|
42
|
-
│ ├── player.ts # Player props and config types
|
|
43
|
-
│ └── provider.ts # Provider-specific types
|
|
44
|
-
├── hooks/
|
|
45
|
-
│ ├── index.ts
|
|
46
|
-
│ └── useVideoPositionCache.ts # Extracted caching logic
|
|
47
|
-
├── utils/
|
|
48
|
-
│ ├── index.ts
|
|
49
|
-
│ ├── resolvers.ts # resolvePlayerMode, resolveFileSource
|
|
50
|
-
│ └── stream.ts # Stream URL generation helpers
|
|
51
|
-
├── components/
|
|
52
|
-
│ ├── index.ts
|
|
53
|
-
│ ├── VideoPlayer.tsx # Main component
|
|
54
|
-
│ ├── VideoControls.tsx # Vidstack controls
|
|
55
|
-
│ └── VideoErrorFallback.tsx # Error UI
|
|
56
|
-
├── context/
|
|
57
|
-
│ ├── index.ts
|
|
58
|
-
│ └── VideoPlayerContext.tsx
|
|
59
|
-
└── providers/
|
|
60
|
-
├── index.ts
|
|
61
|
-
├── VidstackProvider.tsx
|
|
62
|
-
├── NativeProvider.tsx
|
|
63
|
-
└── StreamProvider.tsx
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
## Benefits
|
|
67
|
-
|
|
68
|
-
1. **DRY Principle** - Extract duplicated position caching logic
|
|
69
|
-
2. **Separation of Concerns** - Types split by domain
|
|
70
|
-
3. **Consistent Structure** - Matches AudioPlayer/ImageViewer patterns
|
|
71
|
-
4. **Maintainability** - Easier to find and modify specific functionality
|
|
72
|
-
5. **Testability** - Hooks and utils can be unit tested
|
|
73
|
-
|
|
74
|
-
## Execution Phases
|
|
75
|
-
|
|
76
|
-
| Phase | Description | Files |
|
|
77
|
-
|-------|-------------|-------|
|
|
78
|
-
| 1 | Create folder structure | types/, hooks/, utils/, components/, context/ |
|
|
79
|
-
| 2 | Split types | sources.ts, player.ts, provider.ts |
|
|
80
|
-
| 3 | Extract utils | resolvers.ts, stream.ts |
|
|
81
|
-
| 4 | Extract hooks | useVideoPositionCache.ts |
|
|
82
|
-
| 5 | Move components | VideoPlayer.tsx, VideoControls.tsx, VideoErrorFallback.tsx |
|
|
83
|
-
| 6 | Move context | VideoPlayerContext.tsx |
|
|
84
|
-
| 7 | Update exports | index.ts |
|
|
85
|
-
| 8 | Cleanup and verify | Delete old files, run pnpm check |
|
|
86
|
-
|
|
87
|
-
## Risk Assessment
|
|
88
|
-
|
|
89
|
-
- **Low Risk**: Incremental changes, no logic modifications
|
|
90
|
-
- **Testing**: Run `pnpm check` after each phase
|
|
91
|
-
- **Providers**: Already well-organized, minimal changes needed
|
|
@@ -1,284 +0,0 @@
|
|
|
1
|
-
# Phase 1: Types Split
|
|
2
|
-
|
|
3
|
-
## Goal
|
|
4
|
-
|
|
5
|
-
Split the 369-line `types.ts` into domain-specific files and move helper functions to utils.
|
|
6
|
-
|
|
7
|
-
## Current Structure
|
|
8
|
-
|
|
9
|
-
```typescript
|
|
10
|
-
// types.ts (369 lines)
|
|
11
|
-
// Contains:
|
|
12
|
-
// 1. Source types (UrlSource, YouTubeSource, VimeoSource, HLSSource, etc.)
|
|
13
|
-
// 2. Player types (PlayerMode, AspectRatioValue, VideoPlayerProps, etc.)
|
|
14
|
-
// 3. Provider types (VidstackProviderProps, NativeProviderProps, etc.)
|
|
15
|
-
// 4. Helper functions (resolvePlayerMode, resolveFileSource, isSimpleStreamSource)
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
## Target Files
|
|
19
|
-
|
|
20
|
-
### types/sources.ts (~120 lines)
|
|
21
|
-
|
|
22
|
-
All source type definitions:
|
|
23
|
-
|
|
24
|
-
```typescript
|
|
25
|
-
/**
|
|
26
|
-
* Video source type definitions
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
// URL source (direct video URL)
|
|
30
|
-
export interface UrlSource {
|
|
31
|
-
type: 'url';
|
|
32
|
-
url: string;
|
|
33
|
-
mimeType?: string;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// YouTube embed
|
|
37
|
-
export interface YouTubeSource {
|
|
38
|
-
type: 'youtube';
|
|
39
|
-
videoId: string;
|
|
40
|
-
startTime?: number;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// Vimeo embed
|
|
44
|
-
export interface VimeoSource {
|
|
45
|
-
type: 'vimeo';
|
|
46
|
-
videoId: string;
|
|
47
|
-
startTime?: number;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// HLS streaming
|
|
51
|
-
export interface HLSSource {
|
|
52
|
-
type: 'hls';
|
|
53
|
-
url: string;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// DASH streaming
|
|
57
|
-
export interface DASHSource {
|
|
58
|
-
type: 'dash';
|
|
59
|
-
url: string;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// HTTP Range streaming with auth
|
|
63
|
-
export interface StreamSource {
|
|
64
|
-
type: 'stream';
|
|
65
|
-
streamKey: string;
|
|
66
|
-
fileName: string;
|
|
67
|
-
fileSize?: number;
|
|
68
|
-
mimeType?: string;
|
|
69
|
-
getStreamUrl: (streamKey: string) => Promise<string>;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// Simple stream (resolved via context)
|
|
73
|
-
export interface SimpleStreamSource {
|
|
74
|
-
type: 'stream';
|
|
75
|
-
streamKey: string;
|
|
76
|
-
fileName: string;
|
|
77
|
-
fileSize?: number;
|
|
78
|
-
mimeType?: string;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// Blob (ArrayBuffer)
|
|
82
|
-
export interface BlobSource {
|
|
83
|
-
type: 'blob';
|
|
84
|
-
data: ArrayBuffer;
|
|
85
|
-
mimeType?: string;
|
|
86
|
-
fileName?: string;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// Data URL (base64)
|
|
90
|
-
export interface DataUrlSource {
|
|
91
|
-
type: 'data-url';
|
|
92
|
-
dataUrl: string;
|
|
93
|
-
mimeType?: string;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// Union of all sources
|
|
97
|
-
export type VideoSourceUnion =
|
|
98
|
-
| UrlSource
|
|
99
|
-
| YouTubeSource
|
|
100
|
-
| VimeoSource
|
|
101
|
-
| HLSSource
|
|
102
|
-
| DASHSource
|
|
103
|
-
| StreamSource
|
|
104
|
-
| BlobSource
|
|
105
|
-
| DataUrlSource;
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
### types/player.ts (~100 lines)
|
|
109
|
-
|
|
110
|
-
Player configuration and main component types:
|
|
111
|
-
|
|
112
|
-
```typescript
|
|
113
|
-
/**
|
|
114
|
-
* Player configuration types
|
|
115
|
-
*/
|
|
116
|
-
|
|
117
|
-
import type { ReactNode, CSSProperties } from 'react';
|
|
118
|
-
import type { VideoSourceUnion } from './sources';
|
|
119
|
-
|
|
120
|
-
// Player mode
|
|
121
|
-
export type PlayerMode = 'auto' | 'vidstack' | 'native' | 'streaming';
|
|
122
|
-
|
|
123
|
-
// Aspect ratio
|
|
124
|
-
export type AspectRatioValue = number | 'auto' | 'fill';
|
|
125
|
-
|
|
126
|
-
// Common settings
|
|
127
|
-
export interface CommonPlayerSettings {
|
|
128
|
-
autoPlay?: boolean;
|
|
129
|
-
muted?: boolean;
|
|
130
|
-
loop?: boolean;
|
|
131
|
-
playsInline?: boolean;
|
|
132
|
-
controls?: boolean;
|
|
133
|
-
preload?: 'none' | 'metadata' | 'auto';
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// Common events
|
|
137
|
-
export interface CommonPlayerEvents {
|
|
138
|
-
onPlay?: () => void;
|
|
139
|
-
onPause?: () => void;
|
|
140
|
-
onEnded?: () => void;
|
|
141
|
-
onTimeUpdate?: (currentTime: number) => void;
|
|
142
|
-
onError?: (error: Error) => void;
|
|
143
|
-
onLoadStart?: () => void;
|
|
144
|
-
onCanPlay?: () => void;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
// Error fallback props
|
|
148
|
-
export interface ErrorFallbackProps {
|
|
149
|
-
error: Error | null;
|
|
150
|
-
source: VideoSourceUnion;
|
|
151
|
-
retry?: () => void;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
// Main component props
|
|
155
|
-
export interface VideoPlayerProps extends CommonPlayerSettings, CommonPlayerEvents {
|
|
156
|
-
source: VideoSourceUnion;
|
|
157
|
-
mode?: PlayerMode;
|
|
158
|
-
aspectRatio?: AspectRatioValue;
|
|
159
|
-
poster?: string;
|
|
160
|
-
className?: string;
|
|
161
|
-
style?: CSSProperties;
|
|
162
|
-
errorFallback?: (props: ErrorFallbackProps) => ReactNode;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
// Ref API
|
|
166
|
-
export interface VideoPlayerRef {
|
|
167
|
-
play: () => Promise<void>;
|
|
168
|
-
pause: () => void;
|
|
169
|
-
seek: (time: number) => void;
|
|
170
|
-
setVolume: (volume: number) => void;
|
|
171
|
-
setMuted: (muted: boolean) => void;
|
|
172
|
-
requestFullscreen: () => Promise<void>;
|
|
173
|
-
exitFullscreen: () => Promise<void>;
|
|
174
|
-
readonly currentTime: number;
|
|
175
|
-
readonly duration: number;
|
|
176
|
-
readonly paused: boolean;
|
|
177
|
-
readonly muted: boolean;
|
|
178
|
-
readonly volume: number;
|
|
179
|
-
readonly isFullscreen: boolean;
|
|
180
|
-
}
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
### types/provider.ts (~80 lines)
|
|
184
|
-
|
|
185
|
-
Provider-specific types:
|
|
186
|
-
|
|
187
|
-
```typescript
|
|
188
|
-
/**
|
|
189
|
-
* Provider-specific types
|
|
190
|
-
*/
|
|
191
|
-
|
|
192
|
-
import type { ReactNode } from 'react';
|
|
193
|
-
import type { VideoSourceUnion, StreamSource, BlobSource, DataUrlSource } from './sources';
|
|
194
|
-
import type { CommonPlayerSettings, CommonPlayerEvents, AspectRatioValue, ErrorFallbackProps } from './player';
|
|
195
|
-
|
|
196
|
-
// Vidstack provider props
|
|
197
|
-
export interface VidstackProviderProps extends CommonPlayerSettings, CommonPlayerEvents {
|
|
198
|
-
source: VideoSourceUnion;
|
|
199
|
-
aspectRatio?: AspectRatioValue;
|
|
200
|
-
poster?: string;
|
|
201
|
-
className?: string;
|
|
202
|
-
errorFallback?: (props: ErrorFallbackProps) => ReactNode;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
// Native provider props
|
|
206
|
-
export interface NativeProviderProps extends CommonPlayerSettings, CommonPlayerEvents {
|
|
207
|
-
source: VideoSourceUnion;
|
|
208
|
-
aspectRatio?: AspectRatioValue;
|
|
209
|
-
poster?: string;
|
|
210
|
-
className?: string;
|
|
211
|
-
disableContextMenu?: boolean;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
// Stream provider props
|
|
215
|
-
export interface StreamProviderProps extends CommonPlayerSettings, CommonPlayerEvents {
|
|
216
|
-
source: StreamSource | BlobSource | DataUrlSource;
|
|
217
|
-
aspectRatio?: AspectRatioValue;
|
|
218
|
-
poster?: string;
|
|
219
|
-
className?: string;
|
|
220
|
-
errorFallback?: (props: ErrorFallbackProps) => ReactNode;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
// File source resolution options
|
|
224
|
-
export interface ResolveFileSourceOptions {
|
|
225
|
-
fileName: string;
|
|
226
|
-
content: string | ArrayBuffer;
|
|
227
|
-
mimeType?: string;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
// Context value
|
|
231
|
-
export interface VideoPlayerContextValue {
|
|
232
|
-
getStreamUrl?: (streamKey: string) => Promise<string>;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
export interface VideoPlayerProviderProps {
|
|
236
|
-
getStreamUrl: (streamKey: string) => Promise<string>;
|
|
237
|
-
children: ReactNode;
|
|
238
|
-
}
|
|
239
|
-
```
|
|
240
|
-
|
|
241
|
-
### types/index.ts
|
|
242
|
-
|
|
243
|
-
Re-export all types:
|
|
244
|
-
|
|
245
|
-
```typescript
|
|
246
|
-
/**
|
|
247
|
-
* VideoPlayer types - Public API
|
|
248
|
-
*/
|
|
249
|
-
|
|
250
|
-
// Source types
|
|
251
|
-
export type {
|
|
252
|
-
UrlSource,
|
|
253
|
-
YouTubeSource,
|
|
254
|
-
VimeoSource,
|
|
255
|
-
HLSSource,
|
|
256
|
-
DASHSource,
|
|
257
|
-
StreamSource,
|
|
258
|
-
SimpleStreamSource,
|
|
259
|
-
BlobSource,
|
|
260
|
-
DataUrlSource,
|
|
261
|
-
VideoSourceUnion,
|
|
262
|
-
} from './sources';
|
|
263
|
-
|
|
264
|
-
// Player types
|
|
265
|
-
export type {
|
|
266
|
-
PlayerMode,
|
|
267
|
-
AspectRatioValue,
|
|
268
|
-
CommonPlayerSettings,
|
|
269
|
-
CommonPlayerEvents,
|
|
270
|
-
ErrorFallbackProps,
|
|
271
|
-
VideoPlayerProps,
|
|
272
|
-
VideoPlayerRef,
|
|
273
|
-
} from './player';
|
|
274
|
-
|
|
275
|
-
// Provider types
|
|
276
|
-
export type {
|
|
277
|
-
VidstackProviderProps,
|
|
278
|
-
NativeProviderProps,
|
|
279
|
-
StreamProviderProps,
|
|
280
|
-
ResolveFileSourceOptions,
|
|
281
|
-
VideoPlayerContextValue,
|
|
282
|
-
VideoPlayerProviderProps,
|
|
283
|
-
} from './provider';
|
|
284
|
-
```
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
# Phase 2: Utils Extraction
|
|
2
|
-
|
|
3
|
-
## Goal
|
|
4
|
-
|
|
5
|
-
Extract helper functions from types.ts into dedicated utils files.
|
|
6
|
-
|
|
7
|
-
## Files to Create
|
|
8
|
-
|
|
9
|
-
### utils/resolvers.ts
|
|
10
|
-
|
|
11
|
-
Player mode and source resolution:
|
|
12
|
-
|
|
13
|
-
```typescript
|
|
14
|
-
/**
|
|
15
|
-
* Video source and player mode resolvers
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
import type { VideoSourceUnion, PlayerMode, SimpleStreamSource, StreamSource } from '../types';
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Determine the appropriate player mode for a given source
|
|
22
|
-
*/
|
|
23
|
-
export function resolvePlayerMode(source: VideoSourceUnion): PlayerMode {
|
|
24
|
-
switch (source.type) {
|
|
25
|
-
case 'youtube':
|
|
26
|
-
case 'vimeo':
|
|
27
|
-
case 'hls':
|
|
28
|
-
case 'dash':
|
|
29
|
-
return 'vidstack';
|
|
30
|
-
case 'stream':
|
|
31
|
-
case 'blob':
|
|
32
|
-
case 'data-url':
|
|
33
|
-
return 'streaming';
|
|
34
|
-
case 'url':
|
|
35
|
-
default:
|
|
36
|
-
return 'native';
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Check if source is a simple stream (needs context resolution)
|
|
42
|
-
*/
|
|
43
|
-
export function isSimpleStreamSource(
|
|
44
|
-
source: VideoSourceUnion
|
|
45
|
-
): source is SimpleStreamSource {
|
|
46
|
-
return (
|
|
47
|
-
source.type === 'stream' &&
|
|
48
|
-
!('getStreamUrl' in source)
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Resolve simple stream source with context getStreamUrl
|
|
54
|
-
*/
|
|
55
|
-
export function resolveStreamSource(
|
|
56
|
-
source: SimpleStreamSource,
|
|
57
|
-
getStreamUrl: (streamKey: string) => Promise<string>
|
|
58
|
-
): StreamSource {
|
|
59
|
-
return {
|
|
60
|
-
...source,
|
|
61
|
-
getStreamUrl,
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
### utils/fileSource.ts
|
|
67
|
-
|
|
68
|
-
File content to source conversion:
|
|
69
|
-
|
|
70
|
-
```typescript
|
|
71
|
-
/**
|
|
72
|
-
* File source resolution utilities
|
|
73
|
-
*/
|
|
74
|
-
|
|
75
|
-
import type { VideoSourceUnion, ResolveFileSourceOptions } from '../types';
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Convert file content to appropriate VideoSource
|
|
79
|
-
*/
|
|
80
|
-
export function resolveFileSource(options: ResolveFileSourceOptions): VideoSourceUnion {
|
|
81
|
-
const { fileName, content, mimeType } = options;
|
|
82
|
-
|
|
83
|
-
// Data URL string
|
|
84
|
-
if (typeof content === 'string' && content.startsWith('data:')) {
|
|
85
|
-
return {
|
|
86
|
-
type: 'data-url',
|
|
87
|
-
dataUrl: content,
|
|
88
|
-
mimeType,
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// Regular URL string
|
|
93
|
-
if (typeof content === 'string') {
|
|
94
|
-
return {
|
|
95
|
-
type: 'url',
|
|
96
|
-
url: content,
|
|
97
|
-
mimeType,
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// ArrayBuffer -> Blob source
|
|
102
|
-
return {
|
|
103
|
-
type: 'blob',
|
|
104
|
-
data: content,
|
|
105
|
-
mimeType: mimeType || guessMimeType(fileName),
|
|
106
|
-
fileName,
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Guess MIME type from file extension
|
|
112
|
-
*/
|
|
113
|
-
function guessMimeType(fileName: string): string {
|
|
114
|
-
const ext = fileName.split('.').pop()?.toLowerCase();
|
|
115
|
-
const mimeTypes: Record<string, string> = {
|
|
116
|
-
mp4: 'video/mp4',
|
|
117
|
-
webm: 'video/webm',
|
|
118
|
-
ogg: 'video/ogg',
|
|
119
|
-
mov: 'video/quicktime',
|
|
120
|
-
avi: 'video/x-msvideo',
|
|
121
|
-
mkv: 'video/x-matroska',
|
|
122
|
-
};
|
|
123
|
-
return mimeTypes[ext || ''] || 'video/mp4';
|
|
124
|
-
}
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
### utils/index.ts
|
|
128
|
-
|
|
129
|
-
```typescript
|
|
130
|
-
/**
|
|
131
|
-
* VideoPlayer utilities - Public API
|
|
132
|
-
*/
|
|
133
|
-
|
|
134
|
-
export {
|
|
135
|
-
resolvePlayerMode,
|
|
136
|
-
isSimpleStreamSource,
|
|
137
|
-
resolveStreamSource,
|
|
138
|
-
} from './resolvers';
|
|
139
|
-
|
|
140
|
-
export { resolveFileSource } from './fileSource';
|
|
141
|
-
```
|