@radishon/lumina 1.0.8 → 1.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/README.md +28 -0
- package/dist/Lumina-UMNW6GSY.mjs +6 -0
- package/dist/chunk-QRENGH6F.mjs +311 -0
- package/dist/index.d.mts +12 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.js +348 -284
- package/dist/index.mjs +32 -304
- package/package.json +12 -4
package/README.md
CHANGED
|
@@ -42,6 +42,22 @@ pnpm add @radishon/lumina
|
|
|
42
42
|
|
|
43
43
|
### React
|
|
44
44
|
|
|
45
|
+
**方式一:使用 React 组件(推荐,Next.js App Router 兼容)**
|
|
46
|
+
|
|
47
|
+
```tsx
|
|
48
|
+
import { LuminaLoading } from '@radishon/lumina';
|
|
49
|
+
|
|
50
|
+
function App() {
|
|
51
|
+
return (
|
|
52
|
+
<div className="loading-container">
|
|
53
|
+
<LuminaLoading type="star" speed={100} />
|
|
54
|
+
</div>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
**方式二:直接使用 Web Component**
|
|
60
|
+
|
|
45
61
|
```tsx
|
|
46
62
|
import '@radishon/lumina';
|
|
47
63
|
|
|
@@ -54,6 +70,8 @@ function App() {
|
|
|
54
70
|
}
|
|
55
71
|
```
|
|
56
72
|
|
|
73
|
+
**注意**:方式二在 Next.js App Router 中需要额外配置 SSR,建议使用方式一。
|
|
74
|
+
|
|
57
75
|
### Vue 3
|
|
58
76
|
|
|
59
77
|
**重要配置**:需要在 `vite.config.js` 或 `vue.config.js` 中配置 `isCustomElement` 来禁用 Vue 对 Web Component 的解析:
|
|
@@ -256,6 +274,16 @@ el.speed = 200;
|
|
|
256
274
|
| `chars` | `string[]` | `null` | 自定义字符序列(JSON 数组格式),优先级高于 `type` |
|
|
257
275
|
| `color` | `string` | `null` | 自定义颜色值,支持所有 CSS 颜色格式,优先级高于预设颜色 |
|
|
258
276
|
|
|
277
|
+
## LuminaLoading React 组件 Props
|
|
278
|
+
|
|
279
|
+
| 属性 | 类型 | 默认值 | 说明 |
|
|
280
|
+
|------|------|--------|------|
|
|
281
|
+
| `type` | `SequenceKey` | `'claude'` | 动画序列类型 |
|
|
282
|
+
| `speed` | `number` | `180` | 动画帧切换速度(毫秒) |
|
|
283
|
+
| `chars` | `string[]` | `null` | 自定义字符序列 |
|
|
284
|
+
| `color` | `string` | `null` | 自定义颜色值 |
|
|
285
|
+
| `fallback` | `React.ReactNode` | `null` | SSR 时显示的占位内容 |
|
|
286
|
+
|
|
259
287
|
## 可用的序列类型
|
|
260
288
|
|
|
261
289
|
Lumina 提供了 32 种精心设计的动画序列:
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
// src/sequence.ts
|
|
2
|
+
var SEQUENCES = {
|
|
3
|
+
claude: {
|
|
4
|
+
name: "CLAUDE \u8F68\u8FF9",
|
|
5
|
+
chars: ["\u2732", "\u2731", "\u273A", "\u273B", "\u273C", "\u273D", "\u273E"],
|
|
6
|
+
color: "#fadb14"
|
|
7
|
+
},
|
|
8
|
+
diamond: {
|
|
9
|
+
name: "\u83F1\u5F62\u8109\u51B2",
|
|
10
|
+
chars: ["\u25C7", "\u25C6", "\u25C8", "\u25C6", "\u25C7", "\u25C6", "\u25C8", "\u25C6"],
|
|
11
|
+
color: "#40a9ff"
|
|
12
|
+
},
|
|
13
|
+
circle: {
|
|
14
|
+
name: "\u67D4\u5149\u5706\u73AF",
|
|
15
|
+
chars: ["\xB7", "\u2219", "\u2218", "\u25CB", "\u25CC", "\u25CD", "\u25CE", "\u25CF", "\u25D0", "\u25D1", "\u25D2", "\u25D3"],
|
|
16
|
+
color: "#b37feb"
|
|
17
|
+
},
|
|
18
|
+
step: {
|
|
19
|
+
name: "\u9636\u68AF\u8282\u594F",
|
|
20
|
+
chars: ["\u2591", "\u2592", "\u2593", "\u2588", "\u2593", "\u2592", "\u2591"],
|
|
21
|
+
color: "#73d13d"
|
|
22
|
+
},
|
|
23
|
+
flower: {
|
|
24
|
+
name: "\u5F00\u82B1\u7EFD\u653E",
|
|
25
|
+
chars: ["\u2740", "\u2741", "\u273F", "\u2743", "\u274B", "\u273E", "\u2740"],
|
|
26
|
+
color: "#ffadd2"
|
|
27
|
+
},
|
|
28
|
+
star: {
|
|
29
|
+
name: "\u661F\u8FB0\u56DE\u73AF",
|
|
30
|
+
chars: ["\u2726", "\u2727", "\u2729", "\u272A", "\u272B", "\u272C", "\u272D", "\u272E", "\u272F"],
|
|
31
|
+
color: "#ffffff"
|
|
32
|
+
},
|
|
33
|
+
snow: {
|
|
34
|
+
name: "\u96EA\u82B1\u6676\u683C",
|
|
35
|
+
chars: ["\xB7", "\u2744", "\u2745", "\u2746", "\u2744", "\u2745", "\u2746"],
|
|
36
|
+
color: "#e6f7ff"
|
|
37
|
+
},
|
|
38
|
+
spiral: {
|
|
39
|
+
name: "\u87BA\u65CB\u56DE\u58F0",
|
|
40
|
+
chars: ["\u25C9", "\u25CE", "\u25CB", "\u25CC", "\u25CD", "\u25CF", "\u25D0", "\u25D1"],
|
|
41
|
+
color: "#fadb14"
|
|
42
|
+
},
|
|
43
|
+
braille: {
|
|
44
|
+
name: "\u5E03\u83B1\u53F6\u7801",
|
|
45
|
+
chars: ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"],
|
|
46
|
+
color: "#00ff00"
|
|
47
|
+
},
|
|
48
|
+
cypher: {
|
|
49
|
+
name: "\u5BC6\u7801\u77E9\u9635",
|
|
50
|
+
chars: ["\u259E", "\u259A", "\u259C", "\u2599", "\u259F", "\u259B"],
|
|
51
|
+
color: "#00d8ff"
|
|
52
|
+
},
|
|
53
|
+
moon: {
|
|
54
|
+
name: "\u6708\u76F8\u53D8\u5316",
|
|
55
|
+
chars: ["\u{1F311}", "\u{1F312}", "\u{1F313}", "\u{1F314}", "\u{1F315}", "\u{1F316}", "\u{1F317}", "\u{1F318}"],
|
|
56
|
+
color: "#fffae6"
|
|
57
|
+
},
|
|
58
|
+
wave: {
|
|
59
|
+
name: "\u6CE2\u6D6A\u8D77\u4F0F",
|
|
60
|
+
chars: ["_", "\u23BD", "\u23BC", "\u23BB", "\u23BA", "\u23BB", "\u23BC", "\u23BD"],
|
|
61
|
+
color: "#ff4d4f"
|
|
62
|
+
},
|
|
63
|
+
compass: {
|
|
64
|
+
name: "\u65B9\u5411\u7F57\u76D8",
|
|
65
|
+
chars: ["\u2191", "\u2197", "\u2192", "\u2198", "\u2193", "\u2199", "\u2190", "\u2196"],
|
|
66
|
+
color: "#ff4500"
|
|
67
|
+
},
|
|
68
|
+
pixel: {
|
|
69
|
+
name: "\u50CF\u7D20\u65B9\u5757",
|
|
70
|
+
chars: ["\u25A3", "\u25A4", "\u25A5", "\u25A6", "\u25A7", "\u25A8", "\u25A9"],
|
|
71
|
+
color: "#722ed1"
|
|
72
|
+
},
|
|
73
|
+
clock: {
|
|
74
|
+
name: "\u65F6\u949F\u6307\u9488",
|
|
75
|
+
chars: ["\u{1F550}", "\u{1F551}", "\u{1F552}", "\u{1F553}", "\u{1F554}", "\u{1F555}", "\u{1F556}", "\u{1F557}", "\u{1F558}", "\u{1F559}", "\u{1F55A}", "\u{1F55B}"],
|
|
76
|
+
color: "#ffbb96"
|
|
77
|
+
},
|
|
78
|
+
// 音乐风格
|
|
79
|
+
equalizer: {
|
|
80
|
+
name: "\u97F3\u9891\u5747\u8861",
|
|
81
|
+
chars: ["\u2581", "\u2582", "\u2583", "\u2584", "\u2585", "\u2586", "\u2587", "\u2588", "\u2587", "\u2586", "\u2585", "\u2584"],
|
|
82
|
+
color: "#00bcd4"
|
|
83
|
+
},
|
|
84
|
+
waveform: {
|
|
85
|
+
name: "\u6CE2\u5F62\u632F\u8361",
|
|
86
|
+
chars: ["\u223F", "\u25E0", "\u25E1", "\u223F", "\u25E0", "\u25E1"],
|
|
87
|
+
color: "#ff5722"
|
|
88
|
+
},
|
|
89
|
+
// 游戏风格
|
|
90
|
+
dice: {
|
|
91
|
+
name: "\u9AB0\u5B50\u6EDA\u52A8",
|
|
92
|
+
chars: ["\u2680", "\u2681", "\u2682", "\u2683", "\u2684", "\u2685", "\u2680", "\u2681"],
|
|
93
|
+
color: "#607d8b"
|
|
94
|
+
},
|
|
95
|
+
// 动态几何
|
|
96
|
+
bounce: {
|
|
97
|
+
name: "\u5F39\u8DF3\u7403",
|
|
98
|
+
chars: ["\u2801", "\u2803", "\u2807", "\u2847", "\u28C7", "\u28E7", "\u28F7", "\u28FF", "\u28F7", "\u28E7", "\u28C7", "\u2847"],
|
|
99
|
+
color: "#ff6b6b"
|
|
100
|
+
},
|
|
101
|
+
radar: {
|
|
102
|
+
name: "\u96F7\u8FBE\u626B\u63CF",
|
|
103
|
+
chars: ["\u25D0", "\u25D1", "\u25D2", "\u25D3", "\u25D0", "\u25D1", "\u25D2", "\u25D3"],
|
|
104
|
+
color: "#00d4aa"
|
|
105
|
+
},
|
|
106
|
+
// 数字符号
|
|
107
|
+
dots: {
|
|
108
|
+
name: "\u70B9\u9635\u547C\u5438",
|
|
109
|
+
chars: ["\xB7", "\u22EF", "\u22EF\u22EF", "\xB7\xB7\xB7\xB7", "\u22EF\u22EF\u22EF", "\xB7\xB7\xB7\xB7\xB7\xB7", "\u22EF\u22EF\u22EF\u22EF", "\xB7\xB7\xB7\xB7\xB7\xB7\xB7\xB7"],
|
|
110
|
+
color: "#4d96ff"
|
|
111
|
+
},
|
|
112
|
+
// 液体流体
|
|
113
|
+
liquid: {
|
|
114
|
+
name: "\u6DB2\u4F53\u6643\u52A8",
|
|
115
|
+
chars: ["\u223D", "\u223E", "\u223F", "\u223D", "\u223E", "\u223F", "\u2240", "\u223D"],
|
|
116
|
+
color: "#118ab2"
|
|
117
|
+
},
|
|
118
|
+
ripple: {
|
|
119
|
+
name: "\u6C34\u7EB9\u6269\u6563",
|
|
120
|
+
chars: ["\u25CB", "\u25CE", "\u25C9", "\u25CF", "\u25CB", "\u25CE", "\u25C9", "\u25CF"],
|
|
121
|
+
color: "#073b4c"
|
|
122
|
+
},
|
|
123
|
+
bubble: {
|
|
124
|
+
name: "\u6C14\u6CE1\u6D6E\u8D77",
|
|
125
|
+
chars: ["\u2218", "\u25CB", "\u25CC", "\u25CD", "\u25CE", "\u25CF", "\u25CB", "\u2218"],
|
|
126
|
+
color: "#48cae4"
|
|
127
|
+
},
|
|
128
|
+
// 光谱渐变
|
|
129
|
+
gradient: {
|
|
130
|
+
name: "\u6E10\u53D8\u6761",
|
|
131
|
+
chars: ["\u258F", "\u258E", "\u258D", "\u258C", "\u258B", "\u258A", "\u2589", "\u2588", "\u2589", "\u258A", "\u258B", "\u258C"],
|
|
132
|
+
color: "#ee82ee"
|
|
133
|
+
},
|
|
134
|
+
spectrum: {
|
|
135
|
+
name: "\u5149\u8C31\u626B\u63CF",
|
|
136
|
+
chars: ["\u2591\u2592\u2593", "\u2592\u2593\u2588", "\u2593\u2588\u2591", "\u2588\u2591\u2592", "\u2591\u2592\u2593", "\u2592\u2593\u2588"],
|
|
137
|
+
color: "#ff69b4"
|
|
138
|
+
},
|
|
139
|
+
// 中国传统
|
|
140
|
+
bagua: {
|
|
141
|
+
name: "\u516B\u5366",
|
|
142
|
+
chars: ["\u2630", "\u2631", "\u2632", "\u2633", "\u2634", "\u2635", "\u2636", "\u2637"],
|
|
143
|
+
color: "#8d6e63"
|
|
144
|
+
},
|
|
145
|
+
// 几何角落
|
|
146
|
+
corners: {
|
|
147
|
+
name: "\u89D2\u843D\u65CB\u8F6C",
|
|
148
|
+
chars: ["\u231C", "\u231D", "\u231F", "\u231E", "\u231C", "\u231D", "\u231F", "\u231E"],
|
|
149
|
+
color: "#80cbc4"
|
|
150
|
+
},
|
|
151
|
+
// 扑克纸牌
|
|
152
|
+
cards: {
|
|
153
|
+
name: "\u7EB8\u724C",
|
|
154
|
+
chars: ["\u{1F0A1}", "\u{1F0A2}", "\u{1F0A3}", "\u{1F0A4}", "\u{1F0A5}", "\u{1F0A6}", "\u{1F0A7}", "\u{1F0A8}"],
|
|
155
|
+
color: "#c62828"
|
|
156
|
+
},
|
|
157
|
+
// 装饰符号
|
|
158
|
+
ornament: {
|
|
159
|
+
name: "\u88C5\u9970\u7B26",
|
|
160
|
+
chars: ["\u2766", "\u2767", "\u2740", "\u273F", "\u2741", "\u2742", "\u2743", "\u2747", "\u2748"],
|
|
161
|
+
color: "#e91e63"
|
|
162
|
+
},
|
|
163
|
+
// 危险警告
|
|
164
|
+
radiation: {
|
|
165
|
+
name: "\u8F90\u5C04\u8B66\u544A",
|
|
166
|
+
chars: ["\u2622", "\u2623", "\u2620", "\u269B", "\u262E", "\u2622", "\u2623", "\u2620"],
|
|
167
|
+
color: "#76ff03"
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
// src/Lumina.ts
|
|
172
|
+
var LuminaElement = class extends HTMLElement {
|
|
173
|
+
constructor() {
|
|
174
|
+
super();
|
|
175
|
+
this._index = 0;
|
|
176
|
+
this._timer = null;
|
|
177
|
+
this._div = null;
|
|
178
|
+
this.attachShadow({ mode: "open" });
|
|
179
|
+
}
|
|
180
|
+
static get observedAttributes() {
|
|
181
|
+
return ["type", "speed", "chars", "color"];
|
|
182
|
+
}
|
|
183
|
+
connectedCallback() {
|
|
184
|
+
this.render();
|
|
185
|
+
this.startAnimation();
|
|
186
|
+
}
|
|
187
|
+
disconnectedCallback() {
|
|
188
|
+
if (this._timer) {
|
|
189
|
+
clearInterval(this._timer);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
193
|
+
if (oldValue !== newValue) {
|
|
194
|
+
if (name === "speed" && this._timer) {
|
|
195
|
+
this.startAnimation();
|
|
196
|
+
}
|
|
197
|
+
if (name === "type" || name === "chars" || name === "color") {
|
|
198
|
+
this.render();
|
|
199
|
+
this.startAnimation();
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
get type() {
|
|
204
|
+
return this.getAttribute("type") || "claude";
|
|
205
|
+
}
|
|
206
|
+
set type(value) {
|
|
207
|
+
this.setAttribute("type", value);
|
|
208
|
+
}
|
|
209
|
+
get speed() {
|
|
210
|
+
const speed = this.getAttribute("speed");
|
|
211
|
+
return speed !== null ? parseInt(speed, 10) : 180;
|
|
212
|
+
}
|
|
213
|
+
set speed(value) {
|
|
214
|
+
this.setAttribute("speed", String(value));
|
|
215
|
+
}
|
|
216
|
+
get chars() {
|
|
217
|
+
const charsAttr = this.getAttribute("chars");
|
|
218
|
+
if (charsAttr) {
|
|
219
|
+
try {
|
|
220
|
+
const parsed = JSON.parse(charsAttr);
|
|
221
|
+
if (Array.isArray(parsed) && parsed.every((item) => typeof item === "string")) {
|
|
222
|
+
return parsed;
|
|
223
|
+
}
|
|
224
|
+
} catch {
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return null;
|
|
228
|
+
}
|
|
229
|
+
set chars(value) {
|
|
230
|
+
if (value === null) {
|
|
231
|
+
this.removeAttribute("chars");
|
|
232
|
+
} else {
|
|
233
|
+
this.setAttribute("chars", JSON.stringify(value));
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
get color() {
|
|
237
|
+
return this.getAttribute("color");
|
|
238
|
+
}
|
|
239
|
+
set color(value) {
|
|
240
|
+
if (value === null) {
|
|
241
|
+
this.removeAttribute("color");
|
|
242
|
+
} else {
|
|
243
|
+
this.setAttribute("color", value);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
getChars() {
|
|
247
|
+
const customChars = this.chars;
|
|
248
|
+
if (customChars) {
|
|
249
|
+
return customChars;
|
|
250
|
+
}
|
|
251
|
+
const config = SEQUENCES[this.type] || SEQUENCES["claude"];
|
|
252
|
+
return config.chars;
|
|
253
|
+
}
|
|
254
|
+
getConfig() {
|
|
255
|
+
return SEQUENCES[this.type] || SEQUENCES["claude"];
|
|
256
|
+
}
|
|
257
|
+
getColor() {
|
|
258
|
+
const customColor = this.color;
|
|
259
|
+
if (customColor) {
|
|
260
|
+
return customColor;
|
|
261
|
+
}
|
|
262
|
+
const config = this.getConfig();
|
|
263
|
+
return config.color;
|
|
264
|
+
}
|
|
265
|
+
render() {
|
|
266
|
+
const chars = this.getChars();
|
|
267
|
+
const color = this.getColor();
|
|
268
|
+
const currentChar = chars[this._index] || chars[0];
|
|
269
|
+
this.shadowRoot.innerHTML = `
|
|
270
|
+
<style>
|
|
271
|
+
:host {
|
|
272
|
+
display: inline-block;
|
|
273
|
+
}
|
|
274
|
+
.container {
|
|
275
|
+
color: ${color};
|
|
276
|
+
text-shadow: 0 0 20px ${color}66;
|
|
277
|
+
font-size: 42px;
|
|
278
|
+
height: 60px;
|
|
279
|
+
display: flex;
|
|
280
|
+
align-items: center;
|
|
281
|
+
justify-content: center;
|
|
282
|
+
transition: all 0.2s ease;
|
|
283
|
+
font-family: monospace;
|
|
284
|
+
}
|
|
285
|
+
</style>
|
|
286
|
+
<div class="container">${currentChar}</div>
|
|
287
|
+
`;
|
|
288
|
+
this._div = this.shadowRoot.querySelector(".container");
|
|
289
|
+
}
|
|
290
|
+
startAnimation() {
|
|
291
|
+
if (this._timer) {
|
|
292
|
+
clearInterval(this._timer);
|
|
293
|
+
}
|
|
294
|
+
const chars = this.getChars();
|
|
295
|
+
this._timer = setInterval(() => {
|
|
296
|
+
this._index = (this._index + 1) % chars.length;
|
|
297
|
+
if (this._div) {
|
|
298
|
+
this._div.textContent = chars[this._index];
|
|
299
|
+
}
|
|
300
|
+
}, this.speed);
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
if (typeof customElements !== "undefined" && !customElements.get("lumina-loading")) {
|
|
304
|
+
customElements.define("lumina-loading", LuminaElement);
|
|
305
|
+
}
|
|
306
|
+
var Lumina_default = LuminaElement;
|
|
307
|
+
|
|
308
|
+
export {
|
|
309
|
+
SEQUENCES,
|
|
310
|
+
Lumina_default
|
|
311
|
+
};
|
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
1
3
|
interface SequenceConfig {
|
|
2
4
|
name: string;
|
|
3
5
|
chars: string[];
|
|
@@ -30,4 +32,13 @@ declare class LuminaElement extends HTMLElement {
|
|
|
30
32
|
private startAnimation;
|
|
31
33
|
}
|
|
32
34
|
|
|
33
|
-
|
|
35
|
+
interface LuminaLoadingProps {
|
|
36
|
+
type?: SequenceKey;
|
|
37
|
+
speed?: number;
|
|
38
|
+
chars?: string[];
|
|
39
|
+
color?: string;
|
|
40
|
+
fallback?: React.ReactNode;
|
|
41
|
+
}
|
|
42
|
+
declare function LuminaLoading({ type, speed, chars, color, fallback, }: LuminaLoadingProps): React.ReactElement<any, string | React.JSXElementConstructor<any>> | null;
|
|
43
|
+
|
|
44
|
+
export { LuminaElement as Lumina, LuminaElement, LuminaLoading, SEQUENCES, type SequenceConfig, type SequenceKey };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
1
3
|
interface SequenceConfig {
|
|
2
4
|
name: string;
|
|
3
5
|
chars: string[];
|
|
@@ -30,4 +32,13 @@ declare class LuminaElement extends HTMLElement {
|
|
|
30
32
|
private startAnimation;
|
|
31
33
|
}
|
|
32
34
|
|
|
33
|
-
|
|
35
|
+
interface LuminaLoadingProps {
|
|
36
|
+
type?: SequenceKey;
|
|
37
|
+
speed?: number;
|
|
38
|
+
chars?: string[];
|
|
39
|
+
color?: string;
|
|
40
|
+
fallback?: React.ReactNode;
|
|
41
|
+
}
|
|
42
|
+
declare function LuminaLoading({ type, speed, chars, color, fallback, }: LuminaLoadingProps): React.ReactElement<any, string | React.JSXElementConstructor<any>> | null;
|
|
43
|
+
|
|
44
|
+
export { LuminaElement as Lumina, LuminaElement, LuminaLoading, SEQUENCES, type SequenceConfig, type SequenceKey };
|