@energy8platform/platform-core 0.25.4 → 0.26.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/game-spec.d.ts +3 -0
- package/dist/index.cjs.js +1772 -187
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +77 -9
- package/dist/index.esm.js +1772 -187
- package/dist/index.esm.js.map +1 -1
- package/dist/loading.cjs.js +237 -90
- package/dist/loading.cjs.js.map +1 -1
- package/dist/loading.d.ts +52 -2
- package/dist/loading.esm.js +235 -90
- package/dist/loading.esm.js.map +1 -1
- package/dist/shell.cjs.js +1539 -97
- package/dist/shell.cjs.js.map +1 -1
- package/dist/shell.d.ts +43 -11
- package/dist/shell.esm.js +1538 -98
- package/dist/shell.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/game-spec/types.ts +3 -0
- package/src/loading/CSSPreloader.ts +21 -115
- package/src/loading/index.ts +6 -0
- package/src/loading/variants/energy8.ts +105 -0
- package/src/loading/variants/index.ts +19 -0
- package/src/loading/variants/types.ts +36 -0
- package/src/loading/variants/voidmoon.ts +134 -0
- package/src/shell/GameShell.ts +87 -41
- package/src/shell/components/BuyBonus.ts +160 -14
- package/src/shell/components/GameInfo.ts +104 -5
- package/src/shell/components/Settings.ts +9 -10
- package/src/shell/components/pickers.ts +66 -10
- package/src/shell/components/primitives.ts +4 -3
- package/src/shell/i18n.ts +23 -0
- package/src/shell/index.ts +2 -1
- package/src/shell/keyboard.ts +229 -0
- package/src/shell/locales.ts +864 -0
- package/src/shell/shell.css.ts +37 -14
- package/src/shell/types.ts +8 -0
- package/src/shell/version.ts +1 -1
- package/src/types.ts +8 -0
package/dist/loading.cjs.js
CHANGED
|
@@ -36,7 +36,7 @@ const GRADIENT_DEFS = `
|
|
|
36
36
|
<stop stop-color="#316FB0"/><stop stop-color="#1FCDE6" offset=".5"/><stop stop-color="#29FEE7" offset="1"/>
|
|
37
37
|
</linearGradient>`;
|
|
38
38
|
/** Max width of the loader bar in SVG units */
|
|
39
|
-
const LOADER_BAR_MAX_WIDTH = 174;
|
|
39
|
+
const LOADER_BAR_MAX_WIDTH$1 = 174;
|
|
40
40
|
/**
|
|
41
41
|
* Build the Energy8 SVG logo with a loader bar, using unique IDs.
|
|
42
42
|
*
|
|
@@ -69,61 +69,27 @@ ${defs}
|
|
|
69
69
|
</svg>`;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
|
|
73
|
-
const RECT_ID = 'ge-pl-loader-rect';
|
|
74
|
-
const TEXT_ID = 'ge-pl-loader-text';
|
|
75
|
-
const
|
|
76
|
-
const LOGO_SVG = buildLogoSVG({
|
|
72
|
+
/** Element ids the lifecycle handle binds to (also asserted by tests). */
|
|
73
|
+
const RECT_ID$1 = 'ge-pl-loader-rect';
|
|
74
|
+
const TEXT_ID$1 = 'ge-pl-loader-text';
|
|
75
|
+
const LOGO_SVG$1 = buildLogoSVG({
|
|
77
76
|
idPrefix: 'pl',
|
|
78
77
|
svgClass: 'ge-logo-svg',
|
|
79
78
|
clipRectClass: 'ge-clip-rect',
|
|
80
|
-
clipRectId: RECT_ID,
|
|
79
|
+
clipRectId: RECT_ID$1,
|
|
81
80
|
textClass: 'ge-preloader-svg-text',
|
|
82
|
-
textId: TEXT_ID,
|
|
81
|
+
textId: TEXT_ID$1,
|
|
83
82
|
});
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
return
|
|
88
|
-
return Math.max(0, Math.min(1, p));
|
|
89
|
-
}
|
|
90
|
-
function createCSSPreloader(container, config) {
|
|
91
|
-
if (document.getElementById(PRELOADER_ID))
|
|
92
|
-
return;
|
|
93
|
-
const bgColor = typeof config?.backgroundColor === 'string'
|
|
94
|
-
? config.backgroundColor
|
|
95
|
-
: typeof config?.backgroundColor === 'number'
|
|
96
|
-
? `#${config.backgroundColor.toString(16).padStart(6, '0')}`
|
|
97
|
-
: '#0a0a1a';
|
|
98
|
-
const bgGradient = config?.backgroundGradient ?? `linear-gradient(135deg, ${bgColor} 0%, #1a1a3e 100%)`;
|
|
99
|
-
const customHTML = config?.cssPreloaderHTML ?? '';
|
|
100
|
-
const overlay = document.createElement('div');
|
|
101
|
-
overlay.id = PRELOADER_ID;
|
|
102
|
-
overlay.innerHTML = customHTML || `
|
|
83
|
+
/** The default Energy8-branded preloader: animated wordmark + shimmering loader bar. */
|
|
84
|
+
const energy8Variant = {
|
|
85
|
+
buildContentHTML() {
|
|
86
|
+
return `
|
|
103
87
|
<div class="ge-preloader-content">
|
|
104
|
-
${LOGO_SVG}
|
|
88
|
+
${LOGO_SVG$1}
|
|
105
89
|
</div>
|
|
106
90
|
`;
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
#${PRELOADER_ID} {
|
|
110
|
-
position: absolute;
|
|
111
|
-
top: 0; left: 0;
|
|
112
|
-
width: 100%; height: 100%;
|
|
113
|
-
background: ${bgGradient};
|
|
114
|
-
display: flex;
|
|
115
|
-
align-items: center;
|
|
116
|
-
justify-content: center;
|
|
117
|
-
z-index: 10000;
|
|
118
|
-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
119
|
-
transition: opacity 0.4s ease-out;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
#${PRELOADER_ID}.ge-preloader-hidden {
|
|
123
|
-
opacity: 0;
|
|
124
|
-
pointer-events: none;
|
|
125
|
-
}
|
|
126
|
-
|
|
91
|
+
},
|
|
92
|
+
css: `
|
|
127
93
|
.ge-preloader-content {
|
|
128
94
|
display: flex;
|
|
129
95
|
flex-direction: column;
|
|
@@ -174,6 +140,219 @@ function createCSSPreloader(container, config) {
|
|
|
174
140
|
0%, 100% { opacity: 0.5; }
|
|
175
141
|
50% { opacity: 1; }
|
|
176
142
|
}
|
|
143
|
+
`,
|
|
144
|
+
mount(overlay) {
|
|
145
|
+
const rectEl = overlay.querySelector(`#${RECT_ID$1}`);
|
|
146
|
+
const textEl = overlay.querySelector(`#${TEXT_ID$1}`);
|
|
147
|
+
// Custom HTML mode (or missing logo) — no progress target; lifecycle inert.
|
|
148
|
+
if (!rectEl || !textEl)
|
|
149
|
+
return null;
|
|
150
|
+
let driven = false;
|
|
151
|
+
return {
|
|
152
|
+
setProgress(p, showPercentage) {
|
|
153
|
+
if (!driven) {
|
|
154
|
+
rectEl.classList.add('driven');
|
|
155
|
+
driven = true;
|
|
156
|
+
}
|
|
157
|
+
rectEl.setAttribute('width', String(p * LOADER_BAR_MAX_WIDTH$1));
|
|
158
|
+
if (showPercentage) {
|
|
159
|
+
textEl.textContent = `${Math.round(p * 100)}%`;
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
showTapText(text) {
|
|
163
|
+
textEl.textContent = text;
|
|
164
|
+
textEl.classList.add('ge-svg-pulse');
|
|
165
|
+
},
|
|
166
|
+
};
|
|
167
|
+
},
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
/** Element ids the lifecycle handle binds to. */
|
|
171
|
+
const RECT_ID = 'ge-vm-loader-rect';
|
|
172
|
+
const TEXT_ID = 'ge-vm-loader-text';
|
|
173
|
+
/** Max width (SVG units) of the voidmoon loader bar fill. Spans the first 'o' → end of the crescent. */
|
|
174
|
+
const LOADER_BAR_MAX_WIDTH = 751;
|
|
175
|
+
/**
|
|
176
|
+
* "voidmoon" wordmark — the official logo, embedded verbatim as SVG outlines:
|
|
177
|
+
* thin white letters with the final "o" of "moon" rendered as a purple crescent
|
|
178
|
+
* (#9D63FE). The glyphs live in a flipped group (`translate(0,941) scale(1,-1)`)
|
|
179
|
+
* exactly as exported; the loader bar + status text are added beneath it in the
|
|
180
|
+
* outer (un-flipped) viewBox space.
|
|
181
|
+
*/
|
|
182
|
+
const LOGO_SVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="301 339 1075 335" class="ge-vm-logo-svg" style="overflow:visible" role="img">
|
|
183
|
+
<title>voidmoon</title>
|
|
184
|
+
<g transform="translate(0,941) scale(1,-1)">
|
|
185
|
+
<g fill="#ffffff" fill-rule="evenodd">
|
|
186
|
+
<path d="M627 562 c-4 -2 -7 -6 -7 -12 0 -13 14 -18 23 -10 3 3 3 5 4 9 0 7 -2 11 -7 13 -5 2 -9 2 -13 0z"/>
|
|
187
|
+
<path d="M780 531 l0 -31 -6 5 c-14 14 -35 17 -56 10 -24 -8 -40 -28 -42 -53 0 -11 1 -19 6 -30 8 -16 22 -27 40 -32 8 -2 23 -2 31 0 18 4 34 17 42 33 2 5 4 11 5 14 1 3 1 24 1 61 l0 55 -10 0 -11 0 0 -32z m-24 -38 c20 -10 28 -31 20 -50 -3 -6 -13 -16 -19 -19 -21 -10 -45 -2 -56 18 -2 4 -2 7 -3 14 -1 14 4 24 15 33 8 6 15 8 27 8 9 -1 10 -1 16 -4z"/>
|
|
188
|
+
<path d="M520 518 c-26 -6 -45 -25 -50 -51 -1 -9 -1 -11 0 -19 3 -12 7 -21 15 -30 8 -8 16 -13 28 -17 6 -2 9 -2 19 -2 10 0 13 0 20 2 21 8 36 24 41 46 1 8 1 13 0 22 -5 23 -21 40 -44 47 -6 2 -23 3 -29 2z m29 -25 c9 -4 16 -11 20 -19 2 -5 3 -6 3 -15 0 -10 -1 -11 -3 -16 -8 -15 -23 -24 -40 -23 -9 1 -15 3 -22 8 -22 15 -21 48 2 63 7 4 14 6 24 6 8 -1 10 -1 16 -4z"/>
|
|
189
|
+
<path d="M869 518 c-21 -4 -35 -18 -40 -38 -1 -6 -1 -14 -1 -43 l1 -35 10 0 11 0 0 37 c0 33 1 38 2 41 3 7 7 11 13 14 5 2 8 3 13 3 11 0 20 -5 25 -16 l3 -5 0 -37 1 -37 10 0 10 0 0 37 c0 35 1 37 3 42 5 10 14 16 26 16 11 0 21 -7 25 -17 2 -5 2 -7 2 -41 0 -19 0 -36 1 -37 0 -1 3 -1 11 -1 l10 1 0 35 c0 23 0 38 -1 42 -2 9 -8 21 -14 27 -20 17 -51 17 -68 -1 l-5 -5 -5 5 c-9 9 -19 13 -31 14 -5 0 -10 0 -12 -1z"/>
|
|
190
|
+
<path d="M1077 517 c-9 -1 -20 -7 -27 -12 -7 -6 -14 -16 -18 -25 -4 -11 -5 -25 -3 -35 5 -21 21 -37 42 -44 38 -12 78 14 81 53 1 15 -4 31 -14 43 -14 17 -38 25 -61 20z m25 -22 c19 -5 31 -24 28 -42 -4 -26 -34 -41 -59 -29 -20 10 -27 32 -17 52 8 16 29 25 48 19z"/>
|
|
191
|
+
<path d="M1282 516 c-18 -5 -34 -21 -38 -39 -1 -4 -1 -18 -1 -40 l1 -35 10 -1 10 0 0 32 c0 20 0 35 1 38 2 11 8 18 18 23 7 3 18 3 26 0 6 -3 12 -9 15 -16 2 -4 3 -6 3 -40 l1 -36 10 0 11 0 0 33 c0 38 0 43 -6 54 -7 14 -19 24 -34 28 -7 1 -20 1 -27 -1z"/>
|
|
192
|
+
<path d="M329 515 c0 -1 2 -5 4 -9 2 -5 13 -28 24 -53 12 -24 21 -45 22 -46 2 -4 10 -7 15 -7 4 0 11 3 13 6 3 2 50 105 50 108 0 1 -3 1 -11 1 l-11 0 -7 -14 c-3 -8 -12 -28 -20 -45 -7 -17 -13 -31 -14 -31 -1 -1 -3 5 -17 35 -19 43 -23 53 -24 54 -1 1 -5 1 -13 1 -6 0 -11 0 -11 0z"/>
|
|
193
|
+
<path d="M623 514 c0 -1 0 -26 0 -57 l1 -55 10 0 10 0 0 56 0 57 -10 0 c-7 0 -10 0 -11 -1z"/>
|
|
194
|
+
</g>
|
|
195
|
+
<g fill="#9D63FE" fill-rule="evenodd">
|
|
196
|
+
<path d="M1150 515 c-3 0 -6 -1 -6 -1 0 -1 2 -2 5 -2 10 -4 26 -17 31 -27 11 -21 8 -44 -7 -62 -5 -7 -17 -16 -24 -18 -3 -1 -5 -2 -4 -2 0 -2 16 -3 24 -3 35 3 59 40 49 74 -2 8 -7 18 -13 24 -5 6 -15 13 -23 16 -8 3 -24 4 -32 1z"/>
|
|
197
|
+
</g>
|
|
198
|
+
</g>
|
|
199
|
+
|
|
200
|
+
<rect x="469" y="600" width="751" height="9" rx="4.5" fill="rgba(255,255,255,0.12)"/>
|
|
201
|
+
<clipPath id="vm-loader-clip">
|
|
202
|
+
<rect id="${RECT_ID}" x="469" y="600" width="0" height="9" rx="4.5" class="ge-vm-clip-rect"/>
|
|
203
|
+
</clipPath>
|
|
204
|
+
<rect x="469" y="600" width="751" height="9" rx="4.5" fill="#9D63FE" clip-path="url(#vm-loader-clip)"/>
|
|
205
|
+
|
|
206
|
+
<text id="${TEXT_ID}" x="844.5" y="650" text-anchor="middle" class="ge-vm-text">Loading...</text>
|
|
207
|
+
</svg>`;
|
|
208
|
+
const voidmoonVariant = {
|
|
209
|
+
buildContentHTML() {
|
|
210
|
+
return `
|
|
211
|
+
<div class="ge-vm-content">
|
|
212
|
+
${LOGO_SVG}
|
|
213
|
+
</div>
|
|
214
|
+
`;
|
|
215
|
+
},
|
|
216
|
+
css: `
|
|
217
|
+
.ge-vm-content {
|
|
218
|
+
display: flex;
|
|
219
|
+
flex-direction: column;
|
|
220
|
+
align-items: center;
|
|
221
|
+
width: 82%;
|
|
222
|
+
max-width: 680px;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
.ge-vm-logo-svg {
|
|
226
|
+
width: 100%;
|
|
227
|
+
height: auto;
|
|
228
|
+
filter: drop-shadow(0 0 26px rgba(157, 99, 254, 0.3));
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/* Shimmer the loader bar while waiting */
|
|
232
|
+
.ge-vm-clip-rect {
|
|
233
|
+
animation: ge-vm-fill 2s ease-in-out infinite;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
@keyframes ge-vm-fill {
|
|
237
|
+
0% { width: 0; }
|
|
238
|
+
50% { width: 751; }
|
|
239
|
+
100% { width: 0; }
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/* Stop shimmer once JS-driven progress takes over. */
|
|
243
|
+
.ge-vm-clip-rect.driven {
|
|
244
|
+
animation: none;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
.ge-vm-text {
|
|
248
|
+
fill: rgba(255, 255, 255, 0.6);
|
|
249
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
250
|
+
font-size: 20px;
|
|
251
|
+
font-weight: 600;
|
|
252
|
+
letter-spacing: 3px;
|
|
253
|
+
animation: ge-vm-pulse 1.5s ease-in-out infinite;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
@keyframes ge-vm-pulse {
|
|
257
|
+
0%, 100% { opacity: 0.4; }
|
|
258
|
+
50% { opacity: 1; }
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/* Tap-to-start CTA pulse. Compound selector outweighs the ambient
|
|
262
|
+
.ge-vm-text rule, swapping the animation cleanly. */
|
|
263
|
+
.ge-vm-text.ge-vm-tap-pulse {
|
|
264
|
+
animation: ge-vm-tap 1.2s ease-in-out infinite;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
@keyframes ge-vm-tap {
|
|
268
|
+
0%, 100% { opacity: 0.5; }
|
|
269
|
+
50% { opacity: 1; }
|
|
270
|
+
}
|
|
271
|
+
`,
|
|
272
|
+
mount(overlay) {
|
|
273
|
+
const rectEl = overlay.querySelector(`#${RECT_ID}`);
|
|
274
|
+
const textEl = overlay.querySelector(`#${TEXT_ID}`);
|
|
275
|
+
if (!rectEl || !textEl)
|
|
276
|
+
return null;
|
|
277
|
+
let driven = false;
|
|
278
|
+
return {
|
|
279
|
+
setProgress(p, showPercentage) {
|
|
280
|
+
if (!driven) {
|
|
281
|
+
rectEl.classList.add('driven');
|
|
282
|
+
driven = true;
|
|
283
|
+
}
|
|
284
|
+
rectEl.setAttribute('width', String(p * LOADER_BAR_MAX_WIDTH));
|
|
285
|
+
if (showPercentage) {
|
|
286
|
+
textEl.textContent = `${Math.round(p * 100)}%`;
|
|
287
|
+
}
|
|
288
|
+
},
|
|
289
|
+
showTapText(text) {
|
|
290
|
+
textEl.textContent = text;
|
|
291
|
+
textEl.classList.add('ge-vm-tap-pulse');
|
|
292
|
+
},
|
|
293
|
+
};
|
|
294
|
+
},
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* Registry of selectable preloader variants. Add a new variant by writing a
|
|
299
|
+
* file in this folder and adding one entry here — `PreloaderVariantName` and
|
|
300
|
+
* `LoadingScreenConfig.preloaderVariant` widen automatically.
|
|
301
|
+
*/
|
|
302
|
+
const VARIANTS = {
|
|
303
|
+
energy8: energy8Variant,
|
|
304
|
+
voidmoon: voidmoonVariant,
|
|
305
|
+
};
|
|
306
|
+
/** Default variant used when `preloaderVariant` is omitted or unknown. */
|
|
307
|
+
const DEFAULT_VARIANT_NAME = 'energy8';
|
|
308
|
+
|
|
309
|
+
const PRELOADER_ID = '__ge-css-preloader__';
|
|
310
|
+
const REMOVE_FADE_TIMEOUT_MS = 600;
|
|
311
|
+
let state = null;
|
|
312
|
+
function clampProgress(p) {
|
|
313
|
+
if (!Number.isFinite(p))
|
|
314
|
+
return 0;
|
|
315
|
+
return Math.max(0, Math.min(1, p));
|
|
316
|
+
}
|
|
317
|
+
function createCSSPreloader(container, config) {
|
|
318
|
+
if (document.getElementById(PRELOADER_ID))
|
|
319
|
+
return;
|
|
320
|
+
const bgColor = typeof config?.backgroundColor === 'string'
|
|
321
|
+
? config.backgroundColor
|
|
322
|
+
: typeof config?.backgroundColor === 'number'
|
|
323
|
+
? `#${config.backgroundColor.toString(16).padStart(6, '0')}`
|
|
324
|
+
: '#0a0a1a';
|
|
325
|
+
const bgGradient = config?.backgroundGradient ?? `linear-gradient(135deg, ${bgColor} 0%, #1a1a3e 100%)`;
|
|
326
|
+
const customHTML = config?.cssPreloaderHTML ?? '';
|
|
327
|
+
// Pick the visual identity. Unknown names fall back to the default so a bad
|
|
328
|
+
// config value degrades to a working preloader rather than a blank overlay.
|
|
329
|
+
const variant = VARIANTS[config?.preloaderVariant ?? DEFAULT_VARIANT_NAME] ??
|
|
330
|
+
VARIANTS[DEFAULT_VARIANT_NAME];
|
|
331
|
+
const overlay = document.createElement('div');
|
|
332
|
+
overlay.id = PRELOADER_ID;
|
|
333
|
+
overlay.innerHTML = customHTML || variant.buildContentHTML(config);
|
|
334
|
+
const styleEl = document.createElement('style');
|
|
335
|
+
// Shared overlay infrastructure (positioning / background / fade) plus the
|
|
336
|
+
// variant's own content styling and animations.
|
|
337
|
+
styleEl.textContent = `
|
|
338
|
+
#${PRELOADER_ID} {
|
|
339
|
+
position: absolute;
|
|
340
|
+
top: 0; left: 0;
|
|
341
|
+
width: 100%; height: 100%;
|
|
342
|
+
background: ${bgGradient};
|
|
343
|
+
display: flex;
|
|
344
|
+
align-items: center;
|
|
345
|
+
justify-content: center;
|
|
346
|
+
z-index: 10000;
|
|
347
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
348
|
+
transition: opacity 0.4s ease-out;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
#${PRELOADER_ID}.ge-preloader-hidden {
|
|
352
|
+
opacity: 0;
|
|
353
|
+
pointer-events: none;
|
|
354
|
+
}
|
|
355
|
+
${variant.css}
|
|
177
356
|
`;
|
|
178
357
|
// The absolute overlay needs a positioned ancestor. Only override a STATIC container, and
|
|
179
358
|
// remember the prior inline value so removeCSSPreloader can restore it (an inline `relative`
|
|
@@ -182,41 +361,18 @@ function createCSSPreloader(container, config) {
|
|
|
182
361
|
container.style.position = container.style.position || 'relative';
|
|
183
362
|
container.appendChild(styleEl);
|
|
184
363
|
container.appendChild(overlay);
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
// Custom HTML mode — no logo SVG, lifecycle API becomes mostly inert.
|
|
189
|
-
// We still record state so removeCSSPreloader works.
|
|
190
|
-
state = {
|
|
191
|
-
container,
|
|
192
|
-
prevPosition,
|
|
193
|
-
overlay,
|
|
194
|
-
styleEl,
|
|
195
|
-
rectEl: null,
|
|
196
|
-
textEl: null,
|
|
197
|
-
showPercentage: false,
|
|
198
|
-
tapToStart: config?.tapToStart !== false,
|
|
199
|
-
tapToStartText: config?.tapToStartText ?? 'TAP TO START',
|
|
200
|
-
driven: false,
|
|
201
|
-
tapState: 'idle',
|
|
202
|
-
tapPromise: null,
|
|
203
|
-
tapResolve: null,
|
|
204
|
-
tapHandler: null,
|
|
205
|
-
removed: false,
|
|
206
|
-
};
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
364
|
+
// Custom HTML bypasses the variant's content, so there is no progress target
|
|
365
|
+
// to bind to and the handle stays null (lifecycle API becomes inert).
|
|
366
|
+
const handle = customHTML ? null : variant.mount(overlay, config);
|
|
209
367
|
state = {
|
|
210
368
|
container,
|
|
211
369
|
prevPosition,
|
|
212
370
|
overlay,
|
|
213
371
|
styleEl,
|
|
214
|
-
|
|
215
|
-
textEl,
|
|
372
|
+
handle,
|
|
216
373
|
showPercentage: config?.showPercentage === true,
|
|
217
374
|
tapToStart: config?.tapToStart !== false,
|
|
218
375
|
tapToStartText: config?.tapToStartText ?? 'TAP TO START',
|
|
219
|
-
driven: false,
|
|
220
376
|
tapState: 'idle',
|
|
221
377
|
tapPromise: null,
|
|
222
378
|
tapResolve: null,
|
|
@@ -229,17 +385,9 @@ function setCSSPreloaderProgress(progress) {
|
|
|
229
385
|
return;
|
|
230
386
|
if (state.tapState === 'waiting' || state.tapState === 'resolved')
|
|
231
387
|
return;
|
|
232
|
-
if (!state.
|
|
388
|
+
if (!state.handle)
|
|
233
389
|
return;
|
|
234
|
-
|
|
235
|
-
if (!state.driven) {
|
|
236
|
-
state.rectEl.classList.add('driven');
|
|
237
|
-
state.driven = true;
|
|
238
|
-
}
|
|
239
|
-
state.rectEl.setAttribute('width', String(p * LOADER_BAR_MAX_WIDTH));
|
|
240
|
-
if (state.showPercentage && state.textEl) {
|
|
241
|
-
state.textEl.textContent = `${Math.round(p * 100)}%`;
|
|
242
|
-
}
|
|
390
|
+
state.handle.setProgress(clampProgress(progress), state.showPercentage);
|
|
243
391
|
}
|
|
244
392
|
function waitCSSPreloaderTap() {
|
|
245
393
|
if (!state) {
|
|
@@ -251,10 +399,7 @@ function waitCSSPreloaderTap() {
|
|
|
251
399
|
return Promise.resolve();
|
|
252
400
|
if (state.tapPromise)
|
|
253
401
|
return state.tapPromise;
|
|
254
|
-
|
|
255
|
-
state.textEl.textContent = state.tapToStartText;
|
|
256
|
-
state.textEl.classList.add('ge-svg-pulse');
|
|
257
|
-
}
|
|
402
|
+
state.handle?.showTapText(state.tapToStartText);
|
|
258
403
|
state.overlay.style.cursor = 'pointer';
|
|
259
404
|
state.tapState = 'waiting';
|
|
260
405
|
state.tapPromise = new Promise((resolve) => {
|
|
@@ -308,7 +453,9 @@ function removeCSSPreloader(_container) {
|
|
|
308
453
|
});
|
|
309
454
|
}
|
|
310
455
|
|
|
311
|
-
exports.
|
|
456
|
+
exports.DEFAULT_VARIANT_NAME = DEFAULT_VARIANT_NAME;
|
|
457
|
+
exports.LOADER_BAR_MAX_WIDTH = LOADER_BAR_MAX_WIDTH$1;
|
|
458
|
+
exports.VARIANTS = VARIANTS;
|
|
312
459
|
exports.buildLogoSVG = buildLogoSVG;
|
|
313
460
|
exports.createCSSPreloader = createCSSPreloader;
|
|
314
461
|
exports.removeCSSPreloader = removeCSSPreloader;
|
package/dist/loading.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loading.cjs.js","sources":["../src/loading/logo.ts","../src/loading/CSSPreloader.ts"],"sourcesContent":[null,null],"names":[],"mappings":";;AAAA;;;;;;;AAOG;AAEH;AACA,MAAM,cAAc,GAAG;;;;;+XAKwW;AAE/X;AACA,MAAM,aAAa,GAAG;;;;;;;;;;;;;;;;;;sBAkBA;AAEtB;AACO,
|
|
1
|
+
{"version":3,"file":"loading.cjs.js","sources":["../src/loading/logo.ts","../src/loading/variants/energy8.ts","../src/loading/variants/voidmoon.ts","../src/loading/variants/index.ts","../src/loading/CSSPreloader.ts"],"sourcesContent":[null,null,null,null,null],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UAAU,GAAG,IAAI;IACzB;AAEA,IAAA,KAAK,CAAC,OAAO,GAAG,IAAI;IACpB,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,GAAG,KAAK;AAC3D,IAAA,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,qBAAqB,CAAC;AAE5C,IAAA,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,KAAI;QACnC,IAAI,OAAO,GAAG,KAAK;QACnB,MAAM,MAAM,GAAG,MAAK;AAClB,YAAA,IAAI,OAAO;gBAAE;YACb,OAAO,GAAG,IAAI;YACd,OAAO,CAAC,MAAM,EAAE;YAChB,OAAO,CAAC,MAAM,EAAE;;;AAGhB,YAAA,SAAS,CAAC,KAAK,CAAC,QAAQ,GAAG,YAAY;YACvC,KAAK,GAAG,IAAI;AACZ,YAAA,OAAO,EAAE;AACX,QAAA,CAAC;AAED,QAAA,OAAO,CAAC,gBAAgB,CAAC,eAAe,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AACjE,QAAA,UAAU,CAAC,MAAM,EAAE,sBAAsB,CAAC;AAC5C,IAAA,CAAC,CAAC;AACJ;;;;;;;;;;;"}
|
package/dist/loading.d.ts
CHANGED
|
@@ -1,3 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A live binding between the CSS preloader's lifecycle API
|
|
3
|
+
* (`setCSSPreloaderProgress` / `waitCSSPreloaderTap`) and the variant's own
|
|
4
|
+
* DOM. Returned by {@link PreloaderVariant.mount}; `null` when the variant has
|
|
5
|
+
* no progress target (e.g. a custom-HTML override), which makes the lifecycle
|
|
6
|
+
* inert.
|
|
7
|
+
*/
|
|
8
|
+
interface PreloaderVariantHandle {
|
|
9
|
+
/** Drive the progress indicator. `p` is already clamped to [0, 1]. */
|
|
10
|
+
setProgress(p: number, showPercentage: boolean): void;
|
|
11
|
+
/** Swap the waiting indicator to the tap-to-start cue. */
|
|
12
|
+
showTapText(text: string): void;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A selectable visual identity for the CSS preloader. Encapsulates the markup,
|
|
16
|
+
* its scoped CSS (animations + logo styling), and how progress/tap are driven —
|
|
17
|
+
* everything `CSSPreloader.ts` does NOT own (it keeps overlay/background/fade
|
|
18
|
+
* infrastructure and the shared tap-listener machinery).
|
|
19
|
+
*/
|
|
20
|
+
interface PreloaderVariant {
|
|
21
|
+
/** Inner HTML for the overlay (including the variant's own content wrapper). */
|
|
22
|
+
buildContentHTML(config?: LoadingScreenConfig): string;
|
|
23
|
+
/** Variant-specific CSS appended after the shared base styles. */
|
|
24
|
+
css: string;
|
|
25
|
+
/**
|
|
26
|
+
* Bind to the freshly-mounted overlay and return a handle, or `null` if the
|
|
27
|
+
* variant's progress target is absent (lifecycle then becomes inert).
|
|
28
|
+
*/
|
|
29
|
+
mount(overlay: HTMLElement, config?: LoadingScreenConfig): PreloaderVariantHandle | null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Registry of selectable preloader variants. Add a new variant by writing a
|
|
34
|
+
* file in this folder and adding one entry here — `PreloaderVariantName` and
|
|
35
|
+
* `LoadingScreenConfig.preloaderVariant` widen automatically.
|
|
36
|
+
*/
|
|
37
|
+
declare const VARIANTS: {
|
|
38
|
+
readonly energy8: PreloaderVariant;
|
|
39
|
+
readonly voidmoon: PreloaderVariant;
|
|
40
|
+
};
|
|
41
|
+
/** Default variant used when `preloaderVariant` is omitted or unknown. */
|
|
42
|
+
declare const DEFAULT_VARIANT_NAME = "energy8";
|
|
43
|
+
type PreloaderVariantName = keyof typeof VARIANTS;
|
|
44
|
+
|
|
1
45
|
interface AssetEntry {
|
|
2
46
|
alias: string;
|
|
3
47
|
src: string | string[];
|
|
@@ -12,6 +56,12 @@ interface AssetManifest {
|
|
|
12
56
|
bundles: AssetBundle[];
|
|
13
57
|
}
|
|
14
58
|
interface LoadingScreenConfig {
|
|
59
|
+
/**
|
|
60
|
+
* Which visual identity the CSS preloader renders. Defaults to `'energy8'`;
|
|
61
|
+
* an unknown value falls back to the default. Ignored when `cssPreloaderHTML`
|
|
62
|
+
* is set (custom HTML bypasses the variant).
|
|
63
|
+
*/
|
|
64
|
+
preloaderVariant?: PreloaderVariantName;
|
|
15
65
|
/** Background color (hex number or CSS string) */
|
|
16
66
|
backgroundColor?: number | string;
|
|
17
67
|
/** Background gradient (CSS string applied to the CSS preloader) */
|
|
@@ -81,5 +131,5 @@ interface LogoSVGOptions {
|
|
|
81
131
|
*/
|
|
82
132
|
declare function buildLogoSVG(opts: LogoSVGOptions): string;
|
|
83
133
|
|
|
84
|
-
export { LOADER_BAR_MAX_WIDTH, buildLogoSVG, createCSSPreloader, removeCSSPreloader, setCSSPreloaderProgress, waitCSSPreloaderTap };
|
|
85
|
-
export type { AssetBundle, AssetEntry, AssetManifest, LoadingScreenConfig };
|
|
134
|
+
export { DEFAULT_VARIANT_NAME, LOADER_BAR_MAX_WIDTH, VARIANTS, buildLogoSVG, createCSSPreloader, removeCSSPreloader, setCSSPreloaderProgress, waitCSSPreloaderTap };
|
|
135
|
+
export type { AssetBundle, AssetEntry, AssetManifest, LoadingScreenConfig, PreloaderVariant, PreloaderVariantHandle, PreloaderVariantName };
|