@c4h/chuci 0.1.0 → 0.2.1
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 +143 -143
- package/README.md +224 -224
- package/dist/chuci.js +9068 -6596
- package/dist/chuci.umd.js +165 -166
- package/dist/index.d.ts +1 -0
- package/package.json +36 -33
- 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 -361
- package/src/components/swiper/swiper-styles.css +4 -4
- package/src/components/viewer/cc-viewer-3dmodel.ts +491 -491
- package/src/components/viewer/cc-viewer-base.ts +278 -278
- package/src/components/viewer/cc-viewer-gaussian.ts +380 -380
- 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/dist/assets/azumaya_panorama1.png +0 -0
- package/dist/chuci.cjs +0 -4483
- package/dist/index-8VMexD2a.cjs +0 -255
- package/dist/index-kvsisbKS.js +0 -2125
- package/dist/index.html +0 -241
- package/dist/test-image.html +0 -63
|
@@ -1,110 +1,110 @@
|
|
|
1
|
-
import { CcViewerBase } from './cc-viewer-base'
|
|
2
|
-
|
|
3
|
-
export class CcViewerVideo extends CcViewerBase {
|
|
4
|
-
private videoUrl = ''
|
|
5
|
-
private fitToContainer = false
|
|
6
|
-
|
|
7
|
-
static get observedAttributes() {
|
|
8
|
-
return ['show', 'fit-to-container']
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null) {
|
|
12
|
-
if (name === 'show') {
|
|
13
|
-
this.isShow = newValue === 'true'
|
|
14
|
-
} else if (name === 'fit-to-container') {
|
|
15
|
-
this.fitToContainer = newValue === 'true'
|
|
16
|
-
}
|
|
17
|
-
super.attributeChangedCallback(name, oldValue, newValue)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
protected doOpen(url: string): void {
|
|
21
|
-
this.videoUrl = url
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
protected doClose(): void {
|
|
25
|
-
// Pause video before closing
|
|
26
|
-
const video = this.query('video')
|
|
27
|
-
if (video && 'pause' in video) {
|
|
28
|
-
(video as HTMLVideoElement).pause()
|
|
29
|
-
}
|
|
30
|
-
this.videoUrl = ''
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
protected getViewerContent(): string {
|
|
34
|
-
return `
|
|
35
|
-
<div class="video-container">
|
|
36
|
-
${this.videoUrl ? `
|
|
37
|
-
<video
|
|
38
|
-
src="${this.videoUrl}"
|
|
39
|
-
controls
|
|
40
|
-
controlsList="nodownload"
|
|
41
|
-
class="${this.fitToContainer ? 'fit-to-container' : ''}"
|
|
42
|
-
>
|
|
43
|
-
Your browser does not support the video tag.
|
|
44
|
-
</video>
|
|
45
|
-
` : '<div class="video-error">No video URL provided</div>'}
|
|
46
|
-
</div>
|
|
47
|
-
`
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
protected getCustomStyles(): string {
|
|
51
|
-
return `
|
|
52
|
-
.video-container {
|
|
53
|
-
display: flex;
|
|
54
|
-
justify-content: center;
|
|
55
|
-
align-items: center;
|
|
56
|
-
width: 100%;
|
|
57
|
-
height: 100%;
|
|
58
|
-
background: #000;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
video {
|
|
62
|
-
max-width: 100%;
|
|
63
|
-
max-height: 100%;
|
|
64
|
-
width: auto;
|
|
65
|
-
height: auto;
|
|
66
|
-
outline: none;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
video.fit-to-container {
|
|
70
|
-
width: 100%;
|
|
71
|
-
height: 100%;
|
|
72
|
-
object-fit: contain;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
.video-error {
|
|
76
|
-
color: #fff;
|
|
77
|
-
text-align: center;
|
|
78
|
-
padding: 20px;
|
|
79
|
-
}
|
|
80
|
-
`
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
protected onAfterRender(): void {
|
|
84
|
-
const video = this.query('video')
|
|
85
|
-
if (video) {
|
|
86
|
-
video.addEventListener('error', (e) => this.handleVideoError(e))
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
private handleVideoError(_e: Event) {
|
|
91
|
-
const container = this.query('.video-container')
|
|
92
|
-
if (container) {
|
|
93
|
-
container.innerHTML = `
|
|
94
|
-
<div class="video-error">
|
|
95
|
-
Failed to load video: ${this.videoUrl}
|
|
96
|
-
</div>
|
|
97
|
-
`
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
if (!customElements.get('cc-viewer-video')) {
|
|
103
|
-
customElements.define('cc-viewer-video', CcViewerVideo)
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
declare global {
|
|
107
|
-
interface HTMLElementTagNameMap {
|
|
108
|
-
'cc-viewer-video': CcViewerVideo
|
|
109
|
-
}
|
|
1
|
+
import { CcViewerBase } from './cc-viewer-base'
|
|
2
|
+
|
|
3
|
+
export class CcViewerVideo extends CcViewerBase {
|
|
4
|
+
private videoUrl = ''
|
|
5
|
+
private fitToContainer = false
|
|
6
|
+
|
|
7
|
+
static get observedAttributes() {
|
|
8
|
+
return ['show', 'fit-to-container']
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null) {
|
|
12
|
+
if (name === 'show') {
|
|
13
|
+
this.isShow = newValue === 'true'
|
|
14
|
+
} else if (name === 'fit-to-container') {
|
|
15
|
+
this.fitToContainer = newValue === 'true'
|
|
16
|
+
}
|
|
17
|
+
super.attributeChangedCallback(name, oldValue, newValue)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
protected doOpen(url: string): void {
|
|
21
|
+
this.videoUrl = url
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
protected doClose(): void {
|
|
25
|
+
// Pause video before closing
|
|
26
|
+
const video = this.query('video')
|
|
27
|
+
if (video && 'pause' in video) {
|
|
28
|
+
(video as HTMLVideoElement).pause()
|
|
29
|
+
}
|
|
30
|
+
this.videoUrl = ''
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
protected getViewerContent(): string {
|
|
34
|
+
return `
|
|
35
|
+
<div class="video-container">
|
|
36
|
+
${this.videoUrl ? `
|
|
37
|
+
<video
|
|
38
|
+
src="${this.videoUrl}"
|
|
39
|
+
controls
|
|
40
|
+
controlsList="nodownload"
|
|
41
|
+
class="${this.fitToContainer ? 'fit-to-container' : ''}"
|
|
42
|
+
>
|
|
43
|
+
Your browser does not support the video tag.
|
|
44
|
+
</video>
|
|
45
|
+
` : '<div class="video-error">No video URL provided</div>'}
|
|
46
|
+
</div>
|
|
47
|
+
`
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
protected getCustomStyles(): string {
|
|
51
|
+
return `
|
|
52
|
+
.video-container {
|
|
53
|
+
display: flex;
|
|
54
|
+
justify-content: center;
|
|
55
|
+
align-items: center;
|
|
56
|
+
width: 100%;
|
|
57
|
+
height: 100%;
|
|
58
|
+
background: #000;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
video {
|
|
62
|
+
max-width: 100%;
|
|
63
|
+
max-height: 100%;
|
|
64
|
+
width: auto;
|
|
65
|
+
height: auto;
|
|
66
|
+
outline: none;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
video.fit-to-container {
|
|
70
|
+
width: 100%;
|
|
71
|
+
height: 100%;
|
|
72
|
+
object-fit: contain;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.video-error {
|
|
76
|
+
color: #fff;
|
|
77
|
+
text-align: center;
|
|
78
|
+
padding: 20px;
|
|
79
|
+
}
|
|
80
|
+
`
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
protected onAfterRender(): void {
|
|
84
|
+
const video = this.query('video')
|
|
85
|
+
if (video) {
|
|
86
|
+
video.addEventListener('error', (e) => this.handleVideoError(e))
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
private handleVideoError(_e: Event) {
|
|
91
|
+
const container = this.query('.video-container')
|
|
92
|
+
if (container) {
|
|
93
|
+
container.innerHTML = `
|
|
94
|
+
<div class="video-error">
|
|
95
|
+
Failed to load video: ${this.videoUrl}
|
|
96
|
+
</div>
|
|
97
|
+
`
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (!customElements.get('cc-viewer-video')) {
|
|
103
|
+
customElements.define('cc-viewer-video', CcViewerVideo)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
declare global {
|
|
107
|
+
interface HTMLElementTagNameMap {
|
|
108
|
+
'cc-viewer-video': CcViewerVideo
|
|
109
|
+
}
|
|
110
110
|
}
|
|
@@ -1,76 +1,76 @@
|
|
|
1
|
-
import { CcViewerBase } from './cc-viewer-base'
|
|
2
|
-
|
|
3
|
-
export class CcViewerYoutube extends CcViewerBase {
|
|
4
|
-
private videoUrl = ''
|
|
5
|
-
|
|
6
|
-
static get observedAttributes() {
|
|
7
|
-
return ['show']
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null) {
|
|
11
|
-
if (name === 'show') {
|
|
12
|
-
this.isShow = newValue === 'true'
|
|
13
|
-
}
|
|
14
|
-
super.attributeChangedCallback(name, oldValue, newValue)
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
protected doOpen(videoUrl: string): void {
|
|
18
|
-
// Convert YouTube URL to embed format
|
|
19
|
-
const videoId = this.extractYouTubeId(videoUrl)
|
|
20
|
-
if (videoId) {
|
|
21
|
-
this.videoUrl = `https://www.youtube.com/embed/${videoId}`
|
|
22
|
-
} else {
|
|
23
|
-
this.videoUrl = videoUrl
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
private extractYouTubeId(url: string): string | null {
|
|
28
|
-
// Handle various YouTube URL formats
|
|
29
|
-
const patterns = [
|
|
30
|
-
/(?:youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/)([^&\n?#]+)/,
|
|
31
|
-
/youtube\.com\/watch\?.*v=([^&\n?#]+)/
|
|
32
|
-
]
|
|
33
|
-
|
|
34
|
-
for (const pattern of patterns) {
|
|
35
|
-
const match = url.match(pattern)
|
|
36
|
-
if (match) {
|
|
37
|
-
return match[1]
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return null
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
protected doClose(): void {
|
|
45
|
-
const iframeEl = this.query('.iframe') as HTMLIFrameElement
|
|
46
|
-
if (iframeEl) {
|
|
47
|
-
iframeEl.src = ''
|
|
48
|
-
}
|
|
49
|
-
this.videoUrl = ''
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
protected getViewerContent(): string {
|
|
53
|
-
return `<iframe class="iframe" src="${this.videoUrl}" allowfullscreen></iframe>`
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
protected getCustomStyles(): string {
|
|
57
|
-
return `
|
|
58
|
-
.iframe {
|
|
59
|
-
position: relative;
|
|
60
|
-
width: 100%;
|
|
61
|
-
height: 100%;
|
|
62
|
-
border: 0;
|
|
63
|
-
}
|
|
64
|
-
`
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (!customElements.get('cc-viewer-youtube')) {
|
|
69
|
-
customElements.define('cc-viewer-youtube', CcViewerYoutube)
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
declare global {
|
|
73
|
-
interface HTMLElementTagNameMap {
|
|
74
|
-
'cc-viewer-youtube': CcViewerYoutube
|
|
75
|
-
}
|
|
1
|
+
import { CcViewerBase } from './cc-viewer-base'
|
|
2
|
+
|
|
3
|
+
export class CcViewerYoutube extends CcViewerBase {
|
|
4
|
+
private videoUrl = ''
|
|
5
|
+
|
|
6
|
+
static get observedAttributes() {
|
|
7
|
+
return ['show']
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null) {
|
|
11
|
+
if (name === 'show') {
|
|
12
|
+
this.isShow = newValue === 'true'
|
|
13
|
+
}
|
|
14
|
+
super.attributeChangedCallback(name, oldValue, newValue)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
protected doOpen(videoUrl: string): void {
|
|
18
|
+
// Convert YouTube URL to embed format
|
|
19
|
+
const videoId = this.extractYouTubeId(videoUrl)
|
|
20
|
+
if (videoId) {
|
|
21
|
+
this.videoUrl = `https://www.youtube.com/embed/${videoId}`
|
|
22
|
+
} else {
|
|
23
|
+
this.videoUrl = videoUrl
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
private extractYouTubeId(url: string): string | null {
|
|
28
|
+
// Handle various YouTube URL formats
|
|
29
|
+
const patterns = [
|
|
30
|
+
/(?:youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/)([^&\n?#]+)/,
|
|
31
|
+
/youtube\.com\/watch\?.*v=([^&\n?#]+)/
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
for (const pattern of patterns) {
|
|
35
|
+
const match = url.match(pattern)
|
|
36
|
+
if (match) {
|
|
37
|
+
return match[1]
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return null
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
protected doClose(): void {
|
|
45
|
+
const iframeEl = this.query('.iframe') as HTMLIFrameElement
|
|
46
|
+
if (iframeEl) {
|
|
47
|
+
iframeEl.src = ''
|
|
48
|
+
}
|
|
49
|
+
this.videoUrl = ''
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
protected getViewerContent(): string {
|
|
53
|
+
return `<iframe class="iframe" src="${this.videoUrl}" allowfullscreen></iframe>`
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
protected getCustomStyles(): string {
|
|
57
|
+
return `
|
|
58
|
+
.iframe {
|
|
59
|
+
position: relative;
|
|
60
|
+
width: 100%;
|
|
61
|
+
height: 100%;
|
|
62
|
+
border: 0;
|
|
63
|
+
}
|
|
64
|
+
`
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (!customElements.get('cc-viewer-youtube')) {
|
|
69
|
+
customElements.define('cc-viewer-youtube', CcViewerYoutube)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
declare global {
|
|
73
|
+
interface HTMLElementTagNameMap {
|
|
74
|
+
'cc-viewer-youtube': CcViewerYoutube
|
|
75
|
+
}
|
|
76
76
|
}
|