@5even7/dlc-ui 0.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/CHANGELOG.md +15 -0
- package/LICENSE +21 -0
- package/README.md +248 -0
- package/dist/capsule.cjs +1036 -0
- package/dist/capsule.mjs +831 -0
- package/dist/color.cjs +929 -0
- package/dist/color.mjs +760 -0
- package/dist/index.cjs +2430 -0
- package/dist/index.mjs +2431 -0
- package/dist/index.umd.js +2436 -0
- package/dist/index.umd.min.js +1 -0
- package/dist/progress.cjs +1751 -0
- package/dist/progress.mjs +1658 -0
- package/dist/vue2.cjs +2483 -0
- package/dist/vue2.mjs +2426 -0
- package/dist/vue3.cjs +2485 -0
- package/dist/vue3.mjs +2428 -0
- package/package.json +121 -0
- package/styles/base.css +54 -0
- package/styles/capsule.css +81 -0
- package/styles/color.css +18 -0
- package/styles/progress.css +107 -0
- package/styles/theme.css +4 -0
- package/types/capsule.d.ts +13 -0
- package/types/color.d.ts +13 -0
- package/types/index.d.ts +204 -0
- package/types/progress.d.ts +14 -0
- package/types/vue2.d.ts +1 -0
- package/types/vue3.d.ts +47 -0
package/package.json
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@5even7/dlc-ui",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
7
|
+
"description": "DLC 星云胶囊组件(WebGL2 实时渲染,Canvas2D 自动降级),供 H5 / Vue2 / Vue3 使用。",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://gitee.com/K_a1/cosmic-capsules.git"
|
|
12
|
+
},
|
|
13
|
+
"main": "./dist/index.cjs",
|
|
14
|
+
"module": "./dist/index.mjs",
|
|
15
|
+
"types": "./types/index.d.ts",
|
|
16
|
+
"unpkg": "./dist/index.umd.min.js",
|
|
17
|
+
"jsdelivr": "./dist/index.umd.min.js",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./types/index.d.ts",
|
|
21
|
+
"import": "./dist/index.mjs",
|
|
22
|
+
"require": "./dist/index.cjs",
|
|
23
|
+
"default": "./dist/index.mjs"
|
|
24
|
+
},
|
|
25
|
+
"./capsule": {
|
|
26
|
+
"types": "./types/capsule.d.ts",
|
|
27
|
+
"import": "./dist/capsule.mjs",
|
|
28
|
+
"require": "./dist/capsule.cjs",
|
|
29
|
+
"default": "./dist/capsule.mjs"
|
|
30
|
+
},
|
|
31
|
+
"./progress": {
|
|
32
|
+
"types": "./types/progress.d.ts",
|
|
33
|
+
"import": "./dist/progress.mjs",
|
|
34
|
+
"require": "./dist/progress.cjs",
|
|
35
|
+
"default": "./dist/progress.mjs"
|
|
36
|
+
},
|
|
37
|
+
"./color": {
|
|
38
|
+
"types": "./types/color.d.ts",
|
|
39
|
+
"import": "./dist/color.mjs",
|
|
40
|
+
"require": "./dist/color.cjs",
|
|
41
|
+
"default": "./dist/color.mjs"
|
|
42
|
+
},
|
|
43
|
+
"./vue3": {
|
|
44
|
+
"types": "./types/vue3.d.ts",
|
|
45
|
+
"import": "./dist/vue3.mjs",
|
|
46
|
+
"require": "./dist/vue3.cjs",
|
|
47
|
+
"default": "./dist/vue3.mjs"
|
|
48
|
+
},
|
|
49
|
+
"./vue2": {
|
|
50
|
+
"types": "./types/vue2.d.ts",
|
|
51
|
+
"import": "./dist/vue2.mjs",
|
|
52
|
+
"require": "./dist/vue2.cjs",
|
|
53
|
+
"default": "./dist/vue2.mjs"
|
|
54
|
+
},
|
|
55
|
+
"./style.css": "./styles/theme.css",
|
|
56
|
+
"./capsule/style.css": "./styles/capsule.css",
|
|
57
|
+
"./progress/style.css": "./styles/progress.css",
|
|
58
|
+
"./color/style.css": "./styles/color.css",
|
|
59
|
+
"./package.json": "./package.json"
|
|
60
|
+
},
|
|
61
|
+
"files": [
|
|
62
|
+
"dist",
|
|
63
|
+
"styles",
|
|
64
|
+
"types",
|
|
65
|
+
"README.md",
|
|
66
|
+
"LICENSE",
|
|
67
|
+
"CHANGELOG.md"
|
|
68
|
+
],
|
|
69
|
+
"peerDependencies": {
|
|
70
|
+
"vue": ">=2.7.0"
|
|
71
|
+
},
|
|
72
|
+
"peerDependenciesMeta": {
|
|
73
|
+
"vue": {
|
|
74
|
+
"optional": true
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
"sideEffects": [
|
|
78
|
+
"./styles/theme.css"
|
|
79
|
+
],
|
|
80
|
+
"scripts": {
|
|
81
|
+
"build": "rollup -c && node scripts/copy-css.mjs",
|
|
82
|
+
"test": "node --test tests/",
|
|
83
|
+
"serve": "node scripts/serve.mjs",
|
|
84
|
+
"demo:h5": "node scripts/serve.mjs",
|
|
85
|
+
"demo:vue3": "npm --prefix examples/vue3 run dev",
|
|
86
|
+
"demo:vue2": "npm --prefix examples/vue2 run dev",
|
|
87
|
+
"prepublishOnly": "npm run build && npm test"
|
|
88
|
+
},
|
|
89
|
+
"keywords": [
|
|
90
|
+
"capsule",
|
|
91
|
+
"progress",
|
|
92
|
+
"webgl",
|
|
93
|
+
"canvas",
|
|
94
|
+
"nebula",
|
|
95
|
+
"background",
|
|
96
|
+
"color",
|
|
97
|
+
"vue",
|
|
98
|
+
"vue2",
|
|
99
|
+
"vue3",
|
|
100
|
+
"h5",
|
|
101
|
+
"component"
|
|
102
|
+
],
|
|
103
|
+
"license": "MIT",
|
|
104
|
+
"engines": {
|
|
105
|
+
"node": ">=18"
|
|
106
|
+
},
|
|
107
|
+
"devDependencies": {
|
|
108
|
+
"@babel/core": "^7.26.0",
|
|
109
|
+
"@babel/preset-env": "^7.26.0",
|
|
110
|
+
"@rollup/plugin-babel": "^6.0.4",
|
|
111
|
+
"@rollup/plugin-commonjs": "^28.0.1",
|
|
112
|
+
"@rollup/plugin-node-resolve": "^15.3.0",
|
|
113
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
114
|
+
"intersection-observer": "^0.12.2",
|
|
115
|
+
"jsdom": "^24.1.0",
|
|
116
|
+
"pepjs": "^0.5.3",
|
|
117
|
+
"resize-observer-polyfill": "^1.5.1",
|
|
118
|
+
"rollup": "^4.24.0",
|
|
119
|
+
"vue": "^3.4.0"
|
|
120
|
+
}
|
|
121
|
+
}
|
package/styles/base.css
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @5even7/dlc-ui — shared base styles.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
.hj-capsule-root {
|
|
6
|
+
--hj-radius: 999px;
|
|
7
|
+
--hj-font: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
|
|
8
|
+
"PingFang SC", "Microsoft YaHei", sans-serif;
|
|
9
|
+
--hj-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
|
10
|
+
--hj-bg: #faf8f2;
|
|
11
|
+
--hj-ink: #20231f;
|
|
12
|
+
--hj-muted: #77786f;
|
|
13
|
+
--hj-copy-width: 39%;
|
|
14
|
+
--hj-copy-min-width: 164px;
|
|
15
|
+
--hj-copy-pad-x: 24px;
|
|
16
|
+
--hj-copy-gradient: linear-gradient(
|
|
17
|
+
90deg,
|
|
18
|
+
#faf8f2 0%,
|
|
19
|
+
#faf8f2 74%,
|
|
20
|
+
rgba(250, 248, 242, 0.97) 84%,
|
|
21
|
+
rgba(250, 248, 242, 0) 100%
|
|
22
|
+
);
|
|
23
|
+
--hj-shadow: 0 16px 42px rgba(32, 35, 31, 0.08), 0 3px 10px rgba(32, 35, 31, 0.04);
|
|
24
|
+
--hj-name-size: 20px;
|
|
25
|
+
--hj-copy-left: 30px;
|
|
26
|
+
--hj-value-right: 30px;
|
|
27
|
+
--hj-copy-max-width: 54%;
|
|
28
|
+
|
|
29
|
+
position: relative;
|
|
30
|
+
display: block;
|
|
31
|
+
overflow: hidden;
|
|
32
|
+
box-sizing: border-box;
|
|
33
|
+
border-radius: var(--hj-radius);
|
|
34
|
+
background: var(--hj-bg);
|
|
35
|
+
isolation: isolate;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.hj-capsule-root *,
|
|
39
|
+
.hj-capsule-root *::before,
|
|
40
|
+
.hj-capsule-root *::after {
|
|
41
|
+
box-sizing: border-box;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.hj-capsule-canvas,
|
|
45
|
+
.hj-progress-canvas {
|
|
46
|
+
position: absolute;
|
|
47
|
+
inset: 0;
|
|
48
|
+
z-index: 1;
|
|
49
|
+
display: block;
|
|
50
|
+
width: 100%;
|
|
51
|
+
height: 100%;
|
|
52
|
+
border-radius: inherit;
|
|
53
|
+
pointer-events: none;
|
|
54
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/* ---------- Cosmic capsule copy layer ---------- */
|
|
2
|
+
|
|
3
|
+
.hj-capsule-copy {
|
|
4
|
+
position: absolute;
|
|
5
|
+
top: 0;
|
|
6
|
+
bottom: 0;
|
|
7
|
+
left: 0;
|
|
8
|
+
z-index: 4;
|
|
9
|
+
display: flex;
|
|
10
|
+
width: var(--hj-copy-width);
|
|
11
|
+
min-width: var(--hj-copy-min-width);
|
|
12
|
+
flex-direction: column;
|
|
13
|
+
justify-content: center;
|
|
14
|
+
padding: 16px 12px 16px var(--hj-copy-pad-x);
|
|
15
|
+
color: var(--hj-copy-color, var(--hj-ink));
|
|
16
|
+
background: var(--hj-copy-bg, var(--hj-copy-gradient));
|
|
17
|
+
pointer-events: none;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.hj-capsule-code {
|
|
21
|
+
margin-bottom: 8px;
|
|
22
|
+
color: var(--hj-muted);
|
|
23
|
+
font-family: var(--hj-mono);
|
|
24
|
+
font-size: 9px;
|
|
25
|
+
letter-spacing: 0.16em;
|
|
26
|
+
text-transform: uppercase;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.hj-capsule-name {
|
|
30
|
+
display: block;
|
|
31
|
+
font-size: var(--hj-name-size);
|
|
32
|
+
font-weight: 650;
|
|
33
|
+
line-height: 1;
|
|
34
|
+
letter-spacing: 0.04em;
|
|
35
|
+
white-space: nowrap;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.hj-capsule-brand {
|
|
39
|
+
display: block;
|
|
40
|
+
margin-top: 10px;
|
|
41
|
+
font-size: 12px;
|
|
42
|
+
font-weight: 520;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.hj-capsule-state {
|
|
46
|
+
display: block;
|
|
47
|
+
margin-top: 5px;
|
|
48
|
+
color: #9d7a35;
|
|
49
|
+
font-family: var(--hj-mono);
|
|
50
|
+
font-size: 7px;
|
|
51
|
+
letter-spacing: 0.14em;
|
|
52
|
+
line-height: 1.4;
|
|
53
|
+
text-transform: uppercase;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.hj-capsule-root[data-theme="dark"] {
|
|
57
|
+
border: 0;
|
|
58
|
+
background: #202126;
|
|
59
|
+
box-shadow: none;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.hj-capsule-root[data-theme="dark"] .hj-capsule-copy {
|
|
63
|
+
color: #ffffff;
|
|
64
|
+
--hj-copy-gradient: linear-gradient(
|
|
65
|
+
90deg,
|
|
66
|
+
#202126 0%,
|
|
67
|
+
#202126 72%,
|
|
68
|
+
rgba(32, 33, 38, 0.98) 84%,
|
|
69
|
+
rgba(32, 33, 38, 0) 100%
|
|
70
|
+
);
|
|
71
|
+
background: var(--hj-copy-gradient);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.hj-capsule-root[data-theme="dark"] .hj-capsule-code,
|
|
75
|
+
.hj-capsule-root[data-theme="dark"] .hj-capsule-brand {
|
|
76
|
+
color: rgba(255, 255, 255, 0.72);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.hj-capsule-root[data-theme="dark"] .hj-capsule-state {
|
|
80
|
+
color: #6be7dc;
|
|
81
|
+
}
|
package/styles/color.css
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/* dlc-color: nebula background layer (same renderer as CosmicCapsule). */
|
|
2
|
+
|
|
3
|
+
.dlc-color-layer {
|
|
4
|
+
position: absolute;
|
|
5
|
+
inset: 0;
|
|
6
|
+
z-index: var(--dlc-color-layer-z, -1);
|
|
7
|
+
overflow: hidden;
|
|
8
|
+
border-radius: inherit;
|
|
9
|
+
pointer-events: none;
|
|
10
|
+
background: var(--dlc-color-bg, transparent);
|
|
11
|
+
opacity: var(--dlc-color-opacity, 1);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.dlc-color-canvas {
|
|
15
|
+
display: block;
|
|
16
|
+
width: 100%;
|
|
17
|
+
height: 100%;
|
|
18
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/* ---------- Progress capsule ---------- */
|
|
2
|
+
|
|
3
|
+
.hj-progress-root {
|
|
4
|
+
--hj-bg: #202126;
|
|
5
|
+
border: 1px solid rgba(0, 0, 0, 0.34);
|
|
6
|
+
color: #ffffff;
|
|
7
|
+
box-shadow: var(--hj-shadow);
|
|
8
|
+
cursor: ew-resize;
|
|
9
|
+
touch-action: none;
|
|
10
|
+
user-select: none;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.hj-progress-root[data-draggable="false"] {
|
|
14
|
+
cursor: default;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.hj-progress-root:focus-visible {
|
|
18
|
+
outline: 2px solid rgba(255, 255, 255, 0.8);
|
|
19
|
+
outline-offset: 4px;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.hj-progress-canvas {
|
|
23
|
+
transition: filter 180ms ease, opacity 160ms ease;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.hj-progress-overlay {
|
|
27
|
+
z-index: 2;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.hj-progress-root.has-webgl-progress > .hj-progress-canvas:not(.hj-progress-overlay) {
|
|
31
|
+
opacity: 0;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.hj-progress-root.is-dragging .hj-progress-canvas {
|
|
35
|
+
filter: saturate(1.15) brightness(1.08);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.hj-progress-copy {
|
|
39
|
+
position: absolute;
|
|
40
|
+
top: 50%;
|
|
41
|
+
left: var(--hj-copy-left);
|
|
42
|
+
z-index: 4;
|
|
43
|
+
display: flex;
|
|
44
|
+
max-width: var(--hj-copy-max-width);
|
|
45
|
+
flex-direction: column;
|
|
46
|
+
gap: 5px;
|
|
47
|
+
padding: var(--hj-progress-copy-pad, 0);
|
|
48
|
+
border-radius: 8px;
|
|
49
|
+
background: var(--hj-progress-copy-bg, transparent);
|
|
50
|
+
color: var(--hj-progress-copy-color, #ffffff);
|
|
51
|
+
transform: translateY(-50%);
|
|
52
|
+
pointer-events: none;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.hj-progress-name {
|
|
56
|
+
font-family: var(--hj-font);
|
|
57
|
+
font-size: 20px;
|
|
58
|
+
font-weight: 650;
|
|
59
|
+
line-height: 1;
|
|
60
|
+
letter-spacing: 0.10em;
|
|
61
|
+
white-space: nowrap;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.hj-progress-subtitle {
|
|
65
|
+
color: rgba(255, 255, 255, 0.42);
|
|
66
|
+
font-size: 8px;
|
|
67
|
+
font-weight: 600;
|
|
68
|
+
letter-spacing: 0.08em;
|
|
69
|
+
white-space: nowrap;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.hj-progress-value {
|
|
73
|
+
position: absolute;
|
|
74
|
+
top: 50%;
|
|
75
|
+
right: var(--hj-value-right);
|
|
76
|
+
z-index: 5;
|
|
77
|
+
min-width: 24%;
|
|
78
|
+
color: #ffffff;
|
|
79
|
+
font-size: 44px;
|
|
80
|
+
font-weight: 480;
|
|
81
|
+
line-height: 1;
|
|
82
|
+
text-align: right;
|
|
83
|
+
letter-spacing: -0.045em;
|
|
84
|
+
text-shadow: 0 2px 12px rgba(0, 0, 0, 0.24);
|
|
85
|
+
transform: translateY(-50%);
|
|
86
|
+
pointer-events: none;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.hj-progress-drag-label {
|
|
90
|
+
position: absolute;
|
|
91
|
+
right: 32px;
|
|
92
|
+
bottom: 11px;
|
|
93
|
+
z-index: 5;
|
|
94
|
+
color: rgba(255, 255, 255, 0.28);
|
|
95
|
+
font-family: var(--hj-mono);
|
|
96
|
+
font-size: 7px;
|
|
97
|
+
letter-spacing: 0.18em;
|
|
98
|
+
opacity: 0;
|
|
99
|
+
transition: opacity 160ms ease;
|
|
100
|
+
pointer-events: none;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.hj-progress-root:hover .hj-progress-drag-label,
|
|
104
|
+
.hj-progress-root:focus-visible .hj-progress-drag-label,
|
|
105
|
+
.hj-progress-root.is-dragging .hj-progress-drag-label {
|
|
106
|
+
opacity: 1;
|
|
107
|
+
}
|
package/styles/theme.css
ADDED
package/types/color.d.ts
ADDED
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
export type Quality = 'auto' | 'low' | 'medium' | 'high';
|
|
2
|
+
export type ColorTuple = [string, string, string, string];
|
|
3
|
+
|
|
4
|
+
export interface CapsulePreset {
|
|
5
|
+
id: string;
|
|
6
|
+
code: string;
|
|
7
|
+
name: string;
|
|
8
|
+
group: 'warm' | 'cold';
|
|
9
|
+
theme?: 'light' | 'dark';
|
|
10
|
+
subtitle?: string;
|
|
11
|
+
seed: number;
|
|
12
|
+
speed: number;
|
|
13
|
+
colors: ColorTuple;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface ProgressPreset {
|
|
17
|
+
id: string;
|
|
18
|
+
code: string;
|
|
19
|
+
name: string;
|
|
20
|
+
group: 'progress';
|
|
21
|
+
subtitle?: string;
|
|
22
|
+
initialProgress: number;
|
|
23
|
+
loadRate: number;
|
|
24
|
+
edgeStyle: 'flow' | 'tide';
|
|
25
|
+
colors: ColorTuple;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface Copy {
|
|
29
|
+
brandName: string;
|
|
30
|
+
dragLabel: string;
|
|
31
|
+
valueSuffix: string;
|
|
32
|
+
progressAria: string;
|
|
33
|
+
capsuleAria: string;
|
|
34
|
+
enabled?: boolean;
|
|
35
|
+
code?: string;
|
|
36
|
+
name?: string;
|
|
37
|
+
subtitle?: string;
|
|
38
|
+
state?: string;
|
|
39
|
+
background?: string;
|
|
40
|
+
color?: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface CapsuleOptions {
|
|
44
|
+
preset?: string | CapsulePreset;
|
|
45
|
+
width?: number | string;
|
|
46
|
+
height?: number | string;
|
|
47
|
+
colors?: string[];
|
|
48
|
+
seed?: number;
|
|
49
|
+
speed?: number;
|
|
50
|
+
interactive?: boolean;
|
|
51
|
+
renderer?: 'auto' | 'webgl2' | 'canvas2d';
|
|
52
|
+
showCopy?: boolean;
|
|
53
|
+
quality?: Quality;
|
|
54
|
+
respectReducedMotion?: boolean;
|
|
55
|
+
copy?: Partial<Copy>;
|
|
56
|
+
cssVars?: Record<string, string>;
|
|
57
|
+
[key: string]: unknown;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface ProgressOptions {
|
|
61
|
+
preset?: string | ProgressPreset;
|
|
62
|
+
width?: number | string;
|
|
63
|
+
height?: number | string;
|
|
64
|
+
value?: number;
|
|
65
|
+
min?: number;
|
|
66
|
+
max?: number;
|
|
67
|
+
draggable?: boolean;
|
|
68
|
+
keyboard?: boolean;
|
|
69
|
+
edgeStyle?: 'flow' | 'tide';
|
|
70
|
+
colors?: string[];
|
|
71
|
+
renderer?: 'auto' | 'webgl2' | 'canvas2d';
|
|
72
|
+
showCopy?: boolean;
|
|
73
|
+
quality?: Quality;
|
|
74
|
+
respectReducedMotion?: boolean;
|
|
75
|
+
copy?: Partial<Copy>;
|
|
76
|
+
cssVars?: Record<string, string>;
|
|
77
|
+
[key: string]: unknown;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface ColorBackgroundOptions {
|
|
81
|
+
preset?: string | CapsulePreset;
|
|
82
|
+
colors?: string[];
|
|
83
|
+
seed?: number;
|
|
84
|
+
speed?: number;
|
|
85
|
+
renderer?: 'auto' | 'webgl2' | 'canvas2d';
|
|
86
|
+
quality?: Quality;
|
|
87
|
+
mouseColor?: boolean;
|
|
88
|
+
respectReducedMotion?: boolean;
|
|
89
|
+
opacity?: number;
|
|
90
|
+
fallbackColor?: boolean | string;
|
|
91
|
+
[key: string]: unknown;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export interface Emitter {
|
|
95
|
+
on(event: string, handler: (...args: any[]) => void): () => void;
|
|
96
|
+
off(event: string, handler: (...args: any[]) => void): boolean;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export interface CapsuleController extends Emitter {
|
|
100
|
+
element: HTMLElement;
|
|
101
|
+
canvas: HTMLCanvasElement;
|
|
102
|
+
preset: CapsulePreset;
|
|
103
|
+
setPreset(ref: string | CapsulePreset): this;
|
|
104
|
+
setColors(colors: string[]): this;
|
|
105
|
+
setSize(width?: number | string, height?: number | string): this;
|
|
106
|
+
randomize(): this;
|
|
107
|
+
pause(): this;
|
|
108
|
+
resume(): this;
|
|
109
|
+
setQuality(quality: Quality): this;
|
|
110
|
+
dispose(): void;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export interface ProgressController extends Emitter {
|
|
114
|
+
element: HTMLElement;
|
|
115
|
+
canvas: HTMLCanvasElement;
|
|
116
|
+
preset: ProgressPreset;
|
|
117
|
+
setValue(value: number, source?: string): this;
|
|
118
|
+
getValue(): number;
|
|
119
|
+
setRange(min: number, max: number): this;
|
|
120
|
+
setPreset(ref: string | ProgressPreset): this;
|
|
121
|
+
setColors(colors: string[]): this;
|
|
122
|
+
setSize(width?: number | string, height?: number | string): this;
|
|
123
|
+
randomize(): this;
|
|
124
|
+
pause(): this;
|
|
125
|
+
resume(): this;
|
|
126
|
+
setQuality(quality: Quality): this;
|
|
127
|
+
dispose(): void;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export interface ColorBackgroundController extends Emitter {
|
|
131
|
+
element: HTMLElement;
|
|
132
|
+
layer: HTMLElement;
|
|
133
|
+
canvas: HTMLCanvasElement;
|
|
134
|
+
preset: CapsulePreset;
|
|
135
|
+
setPreset(ref: string | CapsulePreset): this;
|
|
136
|
+
setColors(colors: string[]): this;
|
|
137
|
+
setQuality(quality: Quality): this;
|
|
138
|
+
setOpacity(value: number): this;
|
|
139
|
+
randomize(): this;
|
|
140
|
+
pause(): this;
|
|
141
|
+
resume(): this;
|
|
142
|
+
dispose(): void;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export declare class ProgressCapsuleController {
|
|
146
|
+
value: number;
|
|
147
|
+
webglActive: boolean;
|
|
148
|
+
setProgress(nextValue: number, source?: string): void;
|
|
149
|
+
update(delta: number, paused: boolean, now: number): void;
|
|
150
|
+
draw(): void;
|
|
151
|
+
randomize(): void;
|
|
152
|
+
dispose(): void;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export declare function createCapsule(container: HTMLElement, options?: CapsuleOptions): CapsuleController;
|
|
156
|
+
export declare function createProgressCapsule(container: HTMLElement, options?: ProgressOptions): ProgressController;
|
|
157
|
+
export declare function createColorBackground(host: HTMLElement, options?: ColorBackgroundOptions): ColorBackgroundController;
|
|
158
|
+
|
|
159
|
+
export declare const PRESETS: CapsulePreset[];
|
|
160
|
+
export declare const PROGRESS_PRESETS: ProgressPreset[];
|
|
161
|
+
export declare const ALL_PRESETS: Array<CapsulePreset | ProgressPreset>;
|
|
162
|
+
export declare function validatePreset(preset: CapsulePreset): boolean;
|
|
163
|
+
export declare function validateProgressPreset(preset: ProgressPreset): boolean;
|
|
164
|
+
export declare function getPreset(kind: 'capsule' | 'progress', ref: string): CapsulePreset | ProgressPreset;
|
|
165
|
+
|
|
166
|
+
export declare const DEFAULTS: {
|
|
167
|
+
capsule: Required<Pick<CapsuleOptions, 'width' | 'height' | 'quality' | 'respectReducedMotion' | 'interactive' | 'mouseColor' | 'renderer' | 'showCopy'>>;
|
|
168
|
+
progress: Required<Pick<ProgressOptions, 'width' | 'height' | 'min' | 'max' | 'draggable' | 'keyboard' | 'edgeStyle' | 'quality' | 'respectReducedMotion' | 'renderer' | 'showCopy'>>;
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
export declare const COPY: Copy;
|
|
172
|
+
export declare function parseSize(value: number | string): string;
|
|
173
|
+
export declare const QUALITY_TIERS: Record<'low' | 'medium' | 'high', { dpr: number }>;
|
|
174
|
+
export declare function dprCapFor(quality: Quality): number;
|
|
175
|
+
export declare function pauseAll(): void;
|
|
176
|
+
export declare function resumeAll(): void;
|
|
177
|
+
export declare function hexToRgb01(hex: string): [number, number, number];
|
|
178
|
+
export declare function hexToRgba(hex: string, alpha?: number): string;
|
|
179
|
+
export declare function validateColors(colors: unknown): boolean;
|
|
180
|
+
|
|
181
|
+
export declare class CosmicRenderer {
|
|
182
|
+
constructor(canvas: HTMLCanvasElement, preset: CapsulePreset, options?: { dprCap?: number });
|
|
183
|
+
draw(elapsedSeconds: number, paused?: boolean): void;
|
|
184
|
+
setPreset(preset: CapsulePreset): void;
|
|
185
|
+
setDprCap(cap: number): void;
|
|
186
|
+
randomize(): void;
|
|
187
|
+
resize(): void;
|
|
188
|
+
dispose(): void;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export declare class FallbackRenderer {
|
|
192
|
+
constructor(canvas: HTMLCanvasElement, preset: CapsulePreset);
|
|
193
|
+
draw(elapsedSeconds: number): void;
|
|
194
|
+
setPreset(preset: CapsulePreset): void;
|
|
195
|
+
resize(): void;
|
|
196
|
+
dispose(): void;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export declare class ProgressFlowRenderer {
|
|
200
|
+
constructor(canvas: HTMLCanvasElement, preset: ProgressPreset);
|
|
201
|
+
draw(time: number, progress: number, effectImage?: HTMLImageElement | null): void;
|
|
202
|
+
resize(width: number, height: number, dpr: number): void;
|
|
203
|
+
dispose(): void;
|
|
204
|
+
}
|
package/types/vue2.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CosmicCapsule, ProgressCapsule, default } from './vue3.js';
|
package/types/vue3.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { CapsuleOptions, ProgressOptions } from './index.js';
|
|
2
|
+
|
|
3
|
+
export interface CosmicCapsuleComponent {
|
|
4
|
+
name: 'CosmicCapsule';
|
|
5
|
+
props: (keyof CapsuleOptions)[];
|
|
6
|
+
emits: string[];
|
|
7
|
+
mounted: () => void;
|
|
8
|
+
beforeUnmount: () => void;
|
|
9
|
+
render: (h: Function) => any;
|
|
10
|
+
methods: {
|
|
11
|
+
randomize(): any;
|
|
12
|
+
pause(): any;
|
|
13
|
+
resume(): any;
|
|
14
|
+
setPreset(preset: CapsuleOptions['preset']): any;
|
|
15
|
+
setSize(width?: number | string, height?: number | string): any;
|
|
16
|
+
setColors(colors: string[]): any;
|
|
17
|
+
setQuality(quality: CapsuleOptions['quality']): any;
|
|
18
|
+
getController(): any;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface ProgressCapsuleComponent {
|
|
23
|
+
name: 'ProgressCapsule';
|
|
24
|
+
props: (keyof ProgressOptions)[];
|
|
25
|
+
emits: string[];
|
|
26
|
+
mounted: () => void;
|
|
27
|
+
beforeUnmount: () => void;
|
|
28
|
+
render: (h: Function) => any;
|
|
29
|
+
methods: {
|
|
30
|
+
setValue(value: number): any;
|
|
31
|
+
getValue(): number | undefined;
|
|
32
|
+
setRange(min: number, max: number): any;
|
|
33
|
+
randomize(): any;
|
|
34
|
+
pause(): any;
|
|
35
|
+
resume(): any;
|
|
36
|
+
setPreset(preset: ProgressOptions['preset']): any;
|
|
37
|
+
setSize(width?: number | string, height?: number | string): any;
|
|
38
|
+
setColors(colors: string[]): any;
|
|
39
|
+
setQuality(quality: ProgressOptions['quality']): any;
|
|
40
|
+
getController(): any;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export declare const CosmicCapsule: CosmicCapsuleComponent;
|
|
45
|
+
export declare const ProgressCapsule: ProgressCapsuleComponent;
|
|
46
|
+
declare const _default: { CosmicCapsule: CosmicCapsuleComponent; ProgressCapsule: ProgressCapsuleComponent };
|
|
47
|
+
export default _default;
|