@radishon/lumina 1.0.9 → 1.1.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/dist/index.mjs CHANGED
@@ -1,311 +1,36 @@
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
- };
1
+ import {
2
+ SEQUENCES
3
+ } from "./chunk-QRENGH6F.mjs";
170
4
 
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);
5
+ // src/LuminaLoading.tsx
6
+ import React, { useEffect, useRef, useState } from "react";
7
+ function LuminaLoading({
8
+ type = "claude",
9
+ speed = 180,
10
+ chars,
11
+ color,
12
+ fallback = null
13
+ }) {
14
+ const [mounted, setMounted] = useState(false);
15
+ const ref = useRef(null);
16
+ useEffect(() => {
17
+ import("./Lumina-UMNW6GSY.mjs");
18
+ setMounted(true);
19
+ }, []);
20
+ useEffect(() => {
21
+ const el = ref.current;
22
+ if (!el) return;
23
+ if (type) el.setAttribute("type", type);
24
+ el.setAttribute("speed", String(speed));
25
+ if (chars) el.setAttribute("chars", JSON.stringify(chars));
26
+ if (color) el.setAttribute("color", color);
27
+ }, [type, speed, chars, color]);
28
+ if (!mounted) {
29
+ return fallback;
30
+ }
31
+ return React.createElement("lumina-loading", { ref });
305
32
  }
306
- var Lumina_default = LuminaElement;
307
33
  export {
308
- Lumina_default as Lumina,
309
- Lumina_default as LuminaElement,
34
+ LuminaLoading,
310
35
  SEQUENCES
311
36
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@radishon/lumina",
3
- "version": "1.0.9",
3
+ "version": "1.1.1",
4
4
  "description": "A beautiful animated loading indicator web component for all frameworks",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -9,8 +9,8 @@
9
9
  "dist"
10
10
  ],
11
11
  "scripts": {
12
- "build": "tsup src/index.ts --format cjs,esm --dts",
13
- "dev": "tsup src/index.ts --format cjs,esm --dts --watch",
12
+ "build": "tsup",
13
+ "dev": "tsup --watch",
14
14
  "prepublishOnly": "npm run build"
15
15
  },
16
16
  "keywords": [
@@ -29,8 +29,16 @@
29
29
  "publishConfig": {
30
30
  "access": "public"
31
31
  },
32
- "peerDependencies": {},
32
+ "peerDependencies": {
33
+ "react": ">=16.8.0"
34
+ },
35
+ "peerDependenciesMeta": {
36
+ "react": {
37
+ "optional": true
38
+ }
39
+ },
33
40
  "devDependencies": {
41
+ "@types/react": "^18.3.28",
34
42
  "tsup": "^8.0.0",
35
43
  "typescript": "^5.0.0"
36
44
  }