@c4h/chuci 0.2.4 → 0.2.6
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/CHANGELOG.md +32 -32
- package/LICENSE +20 -20
- package/README.ja.md +279 -143
- package/README.md +278 -224
- package/dist/chuci.js +3866 -3952
- package/dist/chuci.umd.js +177 -201
- package/package.json +8 -8
- package/src/components/swiper/cc-swiper-slide.ts +49 -49
- package/src/components/swiper/cc-swiper-styles.ts +28 -28
- package/src/components/swiper/cc-swiper.ts +379 -379
- package/src/components/swiper/swiper-styles.css +4 -4
- package/src/components/viewer/cc-viewer-3dmodel.ts +495 -495
- package/src/components/viewer/cc-viewer-base.ts +278 -278
- package/src/components/viewer/cc-viewer-gaussian.ts +384 -384
- package/src/components/viewer/cc-viewer-image.ts +189 -189
- package/src/components/viewer/cc-viewer-panorama.ts +85 -85
- package/src/components/viewer/cc-viewer-styles.ts +55 -55
- package/src/components/viewer/cc-viewer-video.ts +109 -109
- package/src/components/viewer/cc-viewer-youtube.ts +75 -75
- package/src/components/viewer/cc-viewer.ts +290 -290
- package/src/index.ts +24 -24
- package/src/types/css-modules.d.ts +1 -1
- package/src/types/global.d.ts +10 -10
- package/src/utils/base-element.ts +76 -76
package/README.md
CHANGED
|
@@ -1,225 +1,279 @@
|
|
|
1
|
-
# Chuci (楚辞)
|
|
2
|
-
|
|
3
|
-
[](https://github.com/code4history/Chuci/actions/workflows/ci.yml)
|
|
4
|
-
[](https://www.npmjs.com/package/@c4h/chuci)
|
|
5
|
-
[](https://opensource.org/licenses/MIT)
|
|
6
|
-
|
|
7
|
-
A standalone multimedia swiper and viewer web components library extracted from [Quyuan](https://github.com/code4history/Quyuan). Provides touch-enabled carousel and multimedia viewers without any framework dependencies.
|
|
8
|
-
|
|
9
|
-
## Features
|
|
10
|
-
|
|
11
|
-
- 🚀 **Framework-agnostic**: Pure Web Components, works with any framework or vanilla JS
|
|
12
|
-
- 📱 **Touch-enabled**: Built on Swiper.js for smooth touch interactions
|
|
13
|
-
- 🎬 **Multiple media types**: Support for images, panoramas, videos, YouTube, 3D models, and Gaussian splats
|
|
14
|
-
- 🔧 **Zero dependencies**: All dependencies are bundled (no Lit dependency)
|
|
15
|
-
- 📦 **Lightweight**: Optimized bundle size with tree-shaking support
|
|
16
|
-
- 🛠️ **TypeScript**: Full TypeScript support with type definitions
|
|
17
|
-
|
|
18
|
-
##
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
<script
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
**
|
|
113
|
-
-
|
|
114
|
-
-
|
|
115
|
-
-
|
|
116
|
-
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
- `
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
-
|
|
185
|
-
-
|
|
186
|
-
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
1
|
+
# Chuci (楚辞)
|
|
2
|
+
|
|
3
|
+
[](https://github.com/code4history/Chuci/actions/workflows/ci.yml)
|
|
4
|
+
[](https://www.npmjs.com/package/@c4h/chuci)
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
|
|
7
|
+
A standalone multimedia swiper and viewer web components library extracted from [Quyuan](https://github.com/code4history/Quyuan). Provides touch-enabled carousel and multimedia viewers without any framework dependencies.
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- 🚀 **Framework-agnostic**: Pure Web Components, works with any framework or vanilla JS
|
|
12
|
+
- 📱 **Touch-enabled**: Built on Swiper.js for smooth touch interactions
|
|
13
|
+
- 🎬 **Multiple media types**: Support for images, panoramas, videos, YouTube, 3D models, and Gaussian splats
|
|
14
|
+
- 🔧 **Zero dependencies**: All dependencies are bundled (no Lit dependency)
|
|
15
|
+
- 📦 **Lightweight**: Optimized bundle size with tree-shaking support
|
|
16
|
+
- 🛠️ **TypeScript**: Full TypeScript support with type definitions
|
|
17
|
+
|
|
18
|
+
## Requirements
|
|
19
|
+
|
|
20
|
+
- **Node.js**: 20 or higher
|
|
21
|
+
- **Package Manager**: pnpm 9.0.0 or higher (recommended)
|
|
22
|
+
- **Browser**: Any modern browser supporting Web Components
|
|
23
|
+
- Chrome/Edge 79+
|
|
24
|
+
- Firefox 63+
|
|
25
|
+
- Safari 12.1+
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
### Using pnpm (recommended)
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pnpm add @c4h/chuci
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Using npm
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npm install @c4h/chuci
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### CDN (Browser)
|
|
42
|
+
|
|
43
|
+
```html
|
|
44
|
+
<script src="https://cdn.jsdelivr.net/npm/@c4h/chuci@latest/dist/chuci.umd.js"></script>
|
|
45
|
+
<script>
|
|
46
|
+
// Components are available globally as Chuci
|
|
47
|
+
// Use custom elements directly in HTML
|
|
48
|
+
</script>
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Usage
|
|
52
|
+
|
|
53
|
+
### Basic Swiper
|
|
54
|
+
|
|
55
|
+
```html
|
|
56
|
+
<cc-swiper>
|
|
57
|
+
<cc-swiper-slide
|
|
58
|
+
thumbnail-url="thumb1.jpg"
|
|
59
|
+
image-url="full1.jpg"
|
|
60
|
+
image-type="image"
|
|
61
|
+
caption="First image">
|
|
62
|
+
</cc-swiper-slide>
|
|
63
|
+
<cc-swiper-slide
|
|
64
|
+
thumbnail-url="thumb2.jpg"
|
|
65
|
+
image-url="full2.jpg"
|
|
66
|
+
image-type="image"
|
|
67
|
+
caption="Second image">
|
|
68
|
+
</cc-swiper-slide>
|
|
69
|
+
</cc-swiper>
|
|
70
|
+
|
|
71
|
+
<script type="module">
|
|
72
|
+
import '@c4h/chuci'
|
|
73
|
+
</script>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Programmatic Usage
|
|
77
|
+
|
|
78
|
+
```javascript
|
|
79
|
+
import '@c4h/chuci';
|
|
80
|
+
|
|
81
|
+
// Get swiper element
|
|
82
|
+
const swiper = document.querySelector('cc-swiper');
|
|
83
|
+
|
|
84
|
+
// Open viewer programmatically
|
|
85
|
+
swiper.openViewer('path/to/image.jpg', 'image', 0);
|
|
86
|
+
|
|
87
|
+
// Listen to slide changes
|
|
88
|
+
swiper.addEventListener('slidechange', (e) => {
|
|
89
|
+
console.log('Current slide:', e.detail.activeIndex);
|
|
90
|
+
});
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### With Thumbnails Gallery
|
|
94
|
+
|
|
95
|
+
```html
|
|
96
|
+
<cc-swiper has-thumb>
|
|
97
|
+
<cc-swiper-slide thumbnail-url="..." image-url="..." image-type="image"></cc-swiper-slide>
|
|
98
|
+
<cc-swiper-slide thumbnail-url="..." image-url="..." image-type="image"></cc-swiper-slide>
|
|
99
|
+
</cc-swiper>
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Autoplay
|
|
103
|
+
|
|
104
|
+
```html
|
|
105
|
+
<cc-swiper autoplay>
|
|
106
|
+
<!-- slides -->
|
|
107
|
+
</cc-swiper>
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Supported Media Types
|
|
111
|
+
|
|
112
|
+
- **image**: Regular images (jpg, png, gif, etc.)
|
|
113
|
+
- **panorama**: 360° panoramic images
|
|
114
|
+
- **youtube**: YouTube videos (provide YouTube URL)
|
|
115
|
+
- **video**: HTML5 videos (mp4, webm, etc.)
|
|
116
|
+
- **3dmodel**: 3D models (OBJ/MTL format)
|
|
117
|
+
- **gaussian**: Gaussian splatting files (.splat, .ply)
|
|
118
|
+
|
|
119
|
+
## Components
|
|
120
|
+
|
|
121
|
+
### `<cc-swiper>`
|
|
122
|
+
|
|
123
|
+
Main carousel component.
|
|
124
|
+
|
|
125
|
+
**Attributes:**
|
|
126
|
+
- `has-thumb`: Show thumbnail gallery
|
|
127
|
+
- `autoplay`: Enable autoplay
|
|
128
|
+
|
|
129
|
+
**Methods:**
|
|
130
|
+
- `openViewer(imageUrl: string, imageType: string, slideIndex?: number)`: Programmatically open viewer
|
|
131
|
+
- `imageUrl`: URL of the media to display
|
|
132
|
+
- `imageType`: Type of media (see supported types above)
|
|
133
|
+
- `slideIndex`: Optional slide index (default: 0)
|
|
134
|
+
|
|
135
|
+
**Events:**
|
|
136
|
+
- `slidechange`: Fired when slide changes
|
|
137
|
+
- `detail.activeIndex`: Current active slide index
|
|
138
|
+
|
|
139
|
+
**Properties:**
|
|
140
|
+
- `slider`: Access to underlying Swiper instance
|
|
141
|
+
|
|
142
|
+
### `<cc-swiper-slide>`
|
|
143
|
+
|
|
144
|
+
Individual slide component.
|
|
145
|
+
|
|
146
|
+
**Attributes:**
|
|
147
|
+
- `thumbnail-url`: URL for thumbnail image (required)
|
|
148
|
+
- `image-url`: URL for full media (required)
|
|
149
|
+
- `image-type`: Media type (see supported types above) (required)
|
|
150
|
+
- `caption`: Optional caption text
|
|
151
|
+
|
|
152
|
+
**3D Model & Gaussian Splatting Attributes:**
|
|
153
|
+
- `material-url`: Material file URL for 3D models (OBJ/MTL)
|
|
154
|
+
- `debug-mode`: Enable debug information display (`"true"` or `"false"`)
|
|
155
|
+
- `camera-position`: Initial camera position as `"x,y,z"` (e.g., `"0,1,5"`)
|
|
156
|
+
- `camera-target`: Camera target position as `"x,y,z"` (e.g., `"0,0,0"`)
|
|
157
|
+
- `show-texture`: Show/hide texture for 3D models (`"true"` or `"false"`)
|
|
158
|
+
- `fit-to-container`: Fit model to container size (`"true"` or `"false"`)
|
|
159
|
+
|
|
160
|
+
### Viewer Components
|
|
161
|
+
|
|
162
|
+
All viewer components inherit from `CcViewerBase` and support:
|
|
163
|
+
|
|
164
|
+
**Methods:**
|
|
165
|
+
- `open(url: string)`: Open viewer with media URL
|
|
166
|
+
- `close()`: Close viewer
|
|
167
|
+
|
|
168
|
+
**Properties:**
|
|
169
|
+
- `showPrevButton` (boolean): Show/hide previous navigation button
|
|
170
|
+
- `showNextButton` (boolean): Show/hide next navigation button
|
|
171
|
+
|
|
172
|
+
**Events:**
|
|
173
|
+
- `close`: Fired when viewer is closed
|
|
174
|
+
- `navigate-prev`: Fired when previous button is clicked
|
|
175
|
+
- `navigate-next`: Fired when next button is clicked
|
|
176
|
+
|
|
177
|
+
### Media-specific Examples
|
|
178
|
+
|
|
179
|
+
#### 3D Model Viewer
|
|
180
|
+
```html
|
|
181
|
+
<cc-swiper-slide
|
|
182
|
+
thumbnail-url="thumb.jpg"
|
|
183
|
+
image-url="model.obj"
|
|
184
|
+
image-type="3dmodel"
|
|
185
|
+
material-url="model.mtl"
|
|
186
|
+
debug-mode="true"
|
|
187
|
+
camera-position="0,1,5"
|
|
188
|
+
camera-target="0,0,0"
|
|
189
|
+
show-texture="true">
|
|
190
|
+
</cc-swiper-slide>
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
#### Gaussian Splatting Viewer
|
|
194
|
+
```html
|
|
195
|
+
<cc-swiper-slide
|
|
196
|
+
thumbnail-url="thumb.jpg"
|
|
197
|
+
image-url="scene.splat"
|
|
198
|
+
image-type="gaussian"
|
|
199
|
+
debug-mode="true"
|
|
200
|
+
camera-position="0,0,10">
|
|
201
|
+
</cc-swiper-slide>
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
#### YouTube Video
|
|
205
|
+
```html
|
|
206
|
+
<cc-swiper-slide
|
|
207
|
+
thumbnail-url="thumb.jpg"
|
|
208
|
+
image-url="https://www.youtube.com/watch?v=VIDEO_ID"
|
|
209
|
+
image-type="youtube">
|
|
210
|
+
</cc-swiper-slide>
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
## Styling
|
|
214
|
+
|
|
215
|
+
CSS Custom Properties:
|
|
216
|
+
|
|
217
|
+
```css
|
|
218
|
+
cc-swiper {
|
|
219
|
+
--cc-slider-theme-color: #007aff;
|
|
220
|
+
--cc-slider-navigation-color: #007aff;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
cc-viewer-base,
|
|
224
|
+
cc-viewer-image,
|
|
225
|
+
cc-viewer-panorama,
|
|
226
|
+
cc-viewer-youtube,
|
|
227
|
+
cc-viewer-video,
|
|
228
|
+
cc-viewer-3dmodel,
|
|
229
|
+
cc-viewer-gaussian {
|
|
230
|
+
--cc-viewer-z-index: 1000;
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
## Browser Support
|
|
235
|
+
|
|
236
|
+
See [Requirements](#requirements) section for browser compatibility details.
|
|
237
|
+
|
|
238
|
+
## Development
|
|
239
|
+
|
|
240
|
+
```bash
|
|
241
|
+
# Install dependencies
|
|
242
|
+
pnpm install
|
|
243
|
+
|
|
244
|
+
# Start development server
|
|
245
|
+
pnpm run dev
|
|
246
|
+
|
|
247
|
+
# Run tests
|
|
248
|
+
pnpm test
|
|
249
|
+
|
|
250
|
+
# Build library
|
|
251
|
+
pnpm run build
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
## License
|
|
255
|
+
|
|
256
|
+
MIT License
|
|
257
|
+
|
|
258
|
+
Copyright (c) 2024-2026 Code for History
|
|
259
|
+
|
|
260
|
+
See [LICENSE](LICENSE) file for details.
|
|
261
|
+
|
|
262
|
+
## Migration from Quyuan
|
|
263
|
+
|
|
264
|
+
If you're migrating from the original Quyuan implementation:
|
|
265
|
+
|
|
266
|
+
1. Change imports from `quyuan` to `@c4h/chuci`
|
|
267
|
+
2. Component names remain the same (`cc-swiper`, `cc-swiper-slide`, etc.)
|
|
268
|
+
3. 3D model URLs no longer use pipe-separated format:
|
|
269
|
+
```html
|
|
270
|
+
<!-- Old -->
|
|
271
|
+
<cc-swiper-slide image-url="model.obj|model.mtl" ...>
|
|
272
|
+
|
|
273
|
+
<!-- New -->
|
|
274
|
+
<cc-swiper-slide image-url="model.obj" material-url="model.mtl" ...>
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
## Credits
|
|
278
|
+
|
|
225
279
|
Extracted from [Quyuan](https://github.com/code4history/Quyuan) by Code for History.
|