@energy8platform/platform-core 0.16.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.
Files changed (57) hide show
  1. package/README.md +482 -0
  2. package/bin/simulate.ts +139 -0
  3. package/dist/dev-bridge.cjs.js +237 -0
  4. package/dist/dev-bridge.cjs.js.map +1 -0
  5. package/dist/dev-bridge.d.ts +141 -0
  6. package/dist/dev-bridge.esm.js +235 -0
  7. package/dist/dev-bridge.esm.js.map +1 -0
  8. package/dist/index.cjs.js +569 -0
  9. package/dist/index.cjs.js.map +1 -0
  10. package/dist/index.d.ts +439 -0
  11. package/dist/index.esm.js +560 -0
  12. package/dist/index.esm.js.map +1 -0
  13. package/dist/loading.cjs.js +190 -0
  14. package/dist/loading.cjs.js.map +1 -0
  15. package/dist/loading.d.ts +86 -0
  16. package/dist/loading.esm.js +185 -0
  17. package/dist/loading.esm.js.map +1 -0
  18. package/dist/lua.cjs.js +1129 -0
  19. package/dist/lua.cjs.js.map +1 -0
  20. package/dist/lua.d.ts +319 -0
  21. package/dist/lua.esm.js +1119 -0
  22. package/dist/lua.esm.js.map +1 -0
  23. package/dist/simulation.cjs.js +374 -0
  24. package/dist/simulation.cjs.js.map +1 -0
  25. package/dist/simulation.d.ts +190 -0
  26. package/dist/simulation.esm.js +368 -0
  27. package/dist/simulation.esm.js.map +1 -0
  28. package/dist/vite.cjs.js +179 -0
  29. package/dist/vite.cjs.js.map +1 -0
  30. package/dist/vite.d.ts +13 -0
  31. package/dist/vite.esm.js +176 -0
  32. package/dist/vite.esm.js.map +1 -0
  33. package/package.json +100 -0
  34. package/scripts/install-simulate.mjs +101 -0
  35. package/src/EventEmitter.ts +55 -0
  36. package/src/PlatformSession.ts +156 -0
  37. package/src/dev-bridge/DevBridge.ts +305 -0
  38. package/src/dev-bridge/index.ts +2 -0
  39. package/src/index.ts +98 -0
  40. package/src/loading/CSSPreloader.ts +129 -0
  41. package/src/loading/index.ts +3 -0
  42. package/src/loading/logo.ts +95 -0
  43. package/src/lua/ActionRouter.ts +132 -0
  44. package/src/lua/LuaEngine.ts +412 -0
  45. package/src/lua/LuaEngineAPI.ts +314 -0
  46. package/src/lua/PersistentState.ts +80 -0
  47. package/src/lua/SessionManager.ts +227 -0
  48. package/src/lua/SimulationRunner.ts +192 -0
  49. package/src/lua/fengari.d.ts +10 -0
  50. package/src/lua/index.ts +28 -0
  51. package/src/lua/types.ts +149 -0
  52. package/src/simulation/NativeSimulationRunner.ts +367 -0
  53. package/src/simulation/ParallelSimulationRunner.ts +156 -0
  54. package/src/simulation/SimulationWorker.ts +44 -0
  55. package/src/simulation/index.ts +21 -0
  56. package/src/types.ts +85 -0
  57. package/src/vite/index.ts +196 -0
@@ -0,0 +1,190 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Shared Energy8 SVG logo with an embedded loader bar.
5
+ *
6
+ * The loader bar fill is controlled via a `<clipPath>` whose `<rect>` width
7
+ * is animatable. Different consumers customise gradient IDs and the clip
8
+ * element's ID/class to avoid collisions when both CSSPreloader and
9
+ * LoadingScene appear in the same DOM.
10
+ */
11
+ /** SVG path data for the Energy8 wordmark — reused across loaders */
12
+ const WORDMARK_PATHS = `
13
+ <path d="m241 81.75h-19.28c-1.77 0-6.73 4.98-7.43 6.99l-4.36 12.22c-0.49 1.37 0.05 2.92 1.06 4.32-2.07 1.19-3.69 3.08-4.36 5.43l-3.25 10.41c-0.86 2.89 2.39 6.63 4.31 6.63h19.28c1.96 0 7.4-5.56 7.96-7.51l2.96-10.22c0.63-2.25 0.1-3.98-1.22-4.99 2.55-1.56 3.86-4.14 4.55-6.31l2.77-9.31c0.74-2.57-1.37-7.66-2.99-7.66zm-13.36 28.31-2.27 7.03h-8.28l2.58-8.28h8.28l-0.31 1.25zm4.06-16.97-2.11 6.7h-7.04l2.25-7.34h7.26l-0.36 0.64z" fill="url(#GID0)"/>
14
+ <path d="m202.5 81.75-9.31 14.97-2.32-14.97h-11.82l4.32 25.15-0.57 4.91-8.64 26.44 15.31-12.76 5.63-16.48 19.96-27.26h-12.56z" fill="url(#GID1)"/>
15
+ <path d="m174.2 81.75h-19.78l-5.75 5.16-10.79 33.2c-0.77 2.53 2.48 6.93 4.87 6.93h17.38c2.63 0 7.85-5.34 8.32-6.83l5.37-18.14h-15.17l-2.2 7.64h3.78l-2.25 7.2h-8.01l7.1-25.52h7.58l-1.48 8.4 12.78-5.98c1.28-0.63 1.97-3.99 1.61-6.61-0.36-2.34-1.64-5.45-3.36-5.45z" fill="url(#GID2)"/>
16
+ <path d="m140.6 81.75h-70.6l-5.36 19.37-4.26-19.37h-46.76l2.95 5.88-10.58 39.28h26.84l2.95-9.52-15.63-0.13 2.55-8.34h8.74l8.47-9.81h-14.61l2.11-7.3h15.47l2.54-8.71 2.58 4.74-11.4 39.07h11.05l6.46-21.49 8.84 36.33 19.18-55.67-1.83-3.36 3.68 4.09-12.07 40.1h28.18l3.39-10.31h-17.01l2.67-8.03h9.98l7.58-9.52h-14.28l1.93-6.6h14.61l3.25-9.73 2.81 5.12-11.3 38.89h11.05l5.23-17.81h1.62l1.48 17.6h10.69l-1.48-16.81c4.75-1.28 7.52-5.9 8.64-9.81l2.95-11.3c0.86-2.73-1.43-6.85-3.3-6.85zm-9.8 17.3h-8.69l2.54-7.84h8.35l-2.2 7.84z" fill="url(#GID3)"/>
17
+ <path d="m205.9 148.9h-122.6l-2.61-3.12h-32.4l-2.51 3.12h-1.59c-5.34 0-7.94 4.88-7.94 7.65v0.03c0 4.2 3.55 7.6 7.74 7.6h103.6l2.11 3.12h36.09l1.82-3.12h18.3c5.25 0 6.64-5.3 6.64-7.35v-0.25c0-4.23-2.9-7.68-6.64-7.68zm-0.7 12.83h-160.6c-3.69 0-6.11-2.58-6.11-5.47v-0.03c0-2.89 2.1-5.47 5.61-5.47h161.1c3.45 0 4.89 3.12 4.89 5.65v0.17c0 2.57-2.11 5.15-4.89 5.15z" fill="url(#GID4)"/>`;
18
+ /** Gradient definitions template (gradient IDs are replaced per-consumer) */
19
+ const GRADIENT_DEFS = `
20
+ <linearGradient id="GID0" x1="223.7" x2="223.7" y1="81.75" y2="127.8" gradientUnits="userSpaceOnUse">
21
+ <stop stop-color="#663BA6"/><stop stop-color="#7939C2" offset=".349"/><stop stop-color="#8A2FC0" offset=".6615"/><stop stop-color="#791BA3" offset="1"/>
22
+ </linearGradient>
23
+ <linearGradient id="GID1" x1="194.6" x2="194.6" y1="81.75" y2="138.3" gradientUnits="userSpaceOnUse">
24
+ <stop stop-color="#663BA6"/><stop stop-color="#7939C2" offset=".349"/><stop stop-color="#8A2FC0" offset=".6615"/><stop stop-color="#791BA3" offset="1"/>
25
+ </linearGradient>
26
+ <linearGradient id="GID2" x1="157.8" x2="157.8" y1="81.75" y2="127" gradientUnits="userSpaceOnUse">
27
+ <stop stop-color="#663BA6"/><stop stop-color="#7939C2" offset=".349"/><stop stop-color="#8A2FC0" offset=".6615"/><stop stop-color="#791BA3" offset="1"/>
28
+ </linearGradient>
29
+ <linearGradient id="GID3" x1="79.96" x2="79.96" y1="81.75" y2="141.8" gradientUnits="userSpaceOnUse">
30
+ <stop stop-color="#663BA6"/><stop stop-color="#7939C2" offset=".349"/><stop stop-color="#8A2FC0" offset=".6615"/><stop stop-color="#791BA3" offset="1"/>
31
+ </linearGradient>
32
+ <linearGradient id="GID4" x1="36.18" x2="212.5" y1="156.6" y2="156.6" gradientUnits="userSpaceOnUse">
33
+ <stop stop-color="#316FB0"/><stop stop-color="#1FCDE6" offset=".5"/><stop stop-color="#29FEE7" offset="1"/>
34
+ </linearGradient>
35
+ <linearGradient id="GID5" x1="40.27" x2="208.2" y1="156.4" y2="156.4" gradientUnits="userSpaceOnUse">
36
+ <stop stop-color="#316FB0"/><stop stop-color="#1FCDE6" offset=".5"/><stop stop-color="#29FEE7" offset="1"/>
37
+ </linearGradient>`;
38
+ /** Max width of the loader bar in SVG units */
39
+ const LOADER_BAR_MAX_WIDTH = 174;
40
+ /**
41
+ * Build the Energy8 SVG logo with a loader bar, using unique IDs.
42
+ *
43
+ * @param opts - Configuration to avoid element ID collisions
44
+ * @returns SVG markup string
45
+ */
46
+ function buildLogoSVG(opts) {
47
+ const { idPrefix, svgClass, svgStyle, clipRectClass, clipRectId, textId, textContent, textClass } = opts;
48
+ // Replace gradient ID placeholders with prefixed versions
49
+ const paths = WORDMARK_PATHS.replace(/GID(\d)/g, `${idPrefix}$1`);
50
+ const defs = GRADIENT_DEFS.replace(/GID(\d)/g, `${idPrefix}$1`);
51
+ const clipId = `${idPrefix}-loader-clip`;
52
+ const fillGradientId = `${idPrefix}5`;
53
+ const classAttr = svgClass ? ` class="${svgClass}"` : '';
54
+ const styleAttr = svgStyle ? ` style="${svgStyle}"` : '';
55
+ const rectClassAttr = clipRectClass ? ` class="${clipRectClass}"` : '';
56
+ const rectIdAttr = clipRectId ? ` id="${clipRectId}"` : '';
57
+ const txtIdAttr = textId ? ` id="${textId}"` : '';
58
+ const txtClassAttr = textClass ? ` class="${textClass}"` : '';
59
+ return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 250 200" fill="none"${classAttr}${styleAttr}>
60
+ ${paths}
61
+ <clipPath id="${clipId}">
62
+ <rect${rectIdAttr} x="37" y="148" width="0" height="20"${rectClassAttr}/>
63
+ </clipPath>
64
+ <path d="m204.5 152.6h-159.8c-2.78 0-4.45 1.69-4.45 3.99v0.11c0 2.04 1.42 3.43 3.64 3.43h160.6c2.88 0 3.67-2.07 3.67-3.43v-0.25c0-2.04-1.48-3.85-3.67-3.85z" fill="url(#${fillGradientId})" clip-path="url(#${clipId})"/>
65
+ <text${txtIdAttr} x="125" y="196" text-anchor="middle" fill="rgba(255,255,255,0.6)" font-family="-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif" font-size="8" font-weight="600" letter-spacing="1.5"${txtClassAttr}>${textContent ?? 'Loading...'}</text>
66
+ <defs>
67
+ ${defs}
68
+ </defs>
69
+ </svg>`;
70
+ }
71
+
72
+ const PRELOADER_ID = '__ge-css-preloader__';
73
+ /**
74
+ * Inline SVG logo with animated loader bar.
75
+ * The `#loader` path acts as the progress fill — animated via clipPath.
76
+ */
77
+ const LOGO_SVG = buildLogoSVG({
78
+ idPrefix: 'pl',
79
+ svgClass: 'ge-logo-svg',
80
+ clipRectClass: 'ge-clip-rect',
81
+ textClass: 'ge-preloader-svg-text',
82
+ });
83
+ /**
84
+ * Creates a lightweight CSS-only preloader that appears instantly,
85
+ * BEFORE PixiJS/WebGL is initialized.
86
+ *
87
+ * Displays the Energy8 logo SVG with an animated loader bar.
88
+ */
89
+ function createCSSPreloader(container, config) {
90
+ if (document.getElementById(PRELOADER_ID))
91
+ return;
92
+ const bgColor = typeof config?.backgroundColor === 'string'
93
+ ? config.backgroundColor
94
+ : typeof config?.backgroundColor === 'number'
95
+ ? `#${config.backgroundColor.toString(16).padStart(6, '0')}`
96
+ : '#0a0a1a';
97
+ const bgGradient = config?.backgroundGradient ?? `linear-gradient(135deg, ${bgColor} 0%, #1a1a3e 100%)`;
98
+ const customHTML = config?.cssPreloaderHTML ?? '';
99
+ const el = document.createElement('div');
100
+ el.id = PRELOADER_ID;
101
+ el.innerHTML = customHTML || `
102
+ <div class="ge-preloader-content">
103
+ ${LOGO_SVG}
104
+ </div>
105
+ `;
106
+ const style = document.createElement('style');
107
+ style.textContent = `
108
+ #${PRELOADER_ID} {
109
+ position: absolute;
110
+ top: 0; left: 0;
111
+ width: 100%; height: 100%;
112
+ background: ${bgGradient};
113
+ display: flex;
114
+ align-items: center;
115
+ justify-content: center;
116
+ z-index: 10000;
117
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
118
+ transition: opacity 0.4s ease-out;
119
+ }
120
+
121
+ #${PRELOADER_ID}.ge-preloader-hidden {
122
+ opacity: 0;
123
+ pointer-events: none;
124
+ }
125
+
126
+ .ge-preloader-content {
127
+ display: flex;
128
+ flex-direction: column;
129
+ align-items: center;
130
+ width: 80%;
131
+ max-width: 700px;
132
+ }
133
+
134
+ .ge-logo-svg {
135
+ width: 100%;
136
+ height: auto;
137
+ filter: drop-shadow(0 0 30px rgba(121, 57, 194, 0.4));
138
+ }
139
+
140
+ /* Animate the loader clip-rect to shimmer while waiting */
141
+ .ge-clip-rect {
142
+ animation: ge-loader-fill 2s ease-in-out infinite;
143
+ }
144
+
145
+ @keyframes ge-loader-fill {
146
+ 0% { width: 0; }
147
+ 50% { width: 174; }
148
+ 100% { width: 0; }
149
+ }
150
+
151
+ /* Animate the SVG text opacity */
152
+ .ge-preloader-svg-text {
153
+ animation: ge-pulse 1.5s ease-in-out infinite;
154
+ }
155
+
156
+ @keyframes ge-pulse {
157
+ 0%, 100% { opacity: 0.4; }
158
+ 50% { opacity: 1; }
159
+ }
160
+ `;
161
+ container.style.position = container.style.position || 'relative';
162
+ container.appendChild(style);
163
+ container.appendChild(el);
164
+ }
165
+ /**
166
+ * Remove the CSS preloader with a smooth fade-out transition.
167
+ */
168
+ function removeCSSPreloader(container) {
169
+ const el = document.getElementById(PRELOADER_ID);
170
+ if (!el)
171
+ return;
172
+ el.classList.add('ge-preloader-hidden');
173
+ // Remove after transition
174
+ el.addEventListener('transitionend', () => {
175
+ el.remove();
176
+ // Also remove the style element
177
+ const styles = container.querySelectorAll('style');
178
+ for (const style of styles) {
179
+ if (style.textContent?.includes(PRELOADER_ID)) {
180
+ style.remove();
181
+ }
182
+ }
183
+ });
184
+ }
185
+
186
+ exports.LOADER_BAR_MAX_WIDTH = LOADER_BAR_MAX_WIDTH;
187
+ exports.buildLogoSVG = buildLogoSVG;
188
+ exports.createCSSPreloader = createCSSPreloader;
189
+ exports.removeCSSPreloader = removeCSSPreloader;
190
+ //# sourceMappingURL=loading.cjs.js.map
@@ -0,0 +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;A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GAEb;IAED,MAAM,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC;IAC7C,KAAK,CAAC,WAAW,GAAG;OACf,YAAY,CAAA;;;;oBAIC,UAAU,CAAA;;;;;;;;;OASvB,YAAY,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuChB;AAED,IAAA,SAAS,CAAC,KAAK,CAAC,QAAQ,GAAG,SAAS,CAAC,KAAK,CAAC,QAAQ,IAAI,UAAU;AACjE,IAAA,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC;AAC5B,IAAA,SAAS,CAAC,WAAW,CAAC,EAAE,CAAC;AAC3B;AAEA;;AAEG;AACG,SAAU,kBAAkB,CAAC,SAAsB,EAAA;IACvD,MAAM,EAAE,GAAG,QAAQ,CAAC,cAAc,CAAC,YAAY,CAAC;AAChD,IAAA,IAAI,CAAC,EAAE;QAAE;AAET,IAAA,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,qBAAqB,CAAC;;AAGvC,IAAA,EAAE,CAAC,gBAAgB,CAAC,eAAe,EAAE,MAAK;QACxC,EAAE,CAAC,MAAM,EAAE;;QAEX,MAAM,MAAM,GAAG,SAAS,CAAC,gBAAgB,CAAC,OAAO,CAAC;AAClD,QAAA,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;YAC1B,IAAI,KAAK,CAAC,WAAW,EAAE,QAAQ,CAAC,YAAY,CAAC,EAAE;gBAC7C,KAAK,CAAC,MAAM,EAAE;YAChB;QACF;AACF,IAAA,CAAC,CAAC;AACJ;;;;;;;"}
@@ -0,0 +1,86 @@
1
+ interface AssetEntry {
2
+ alias: string;
3
+ src: string | string[];
4
+ /** Optional loader-specific data (e.g. parser hints) */
5
+ data?: Record<string, unknown>;
6
+ }
7
+ interface AssetBundle {
8
+ name: string;
9
+ assets: AssetEntry[];
10
+ }
11
+ interface AssetManifest {
12
+ bundles: AssetBundle[];
13
+ }
14
+ interface LoadingScreenConfig {
15
+ /** Background color (hex number or CSS string) */
16
+ backgroundColor?: number | string;
17
+ /** Background gradient (CSS string applied to the CSS preloader) */
18
+ backgroundGradient?: string;
19
+ /** Logo texture alias (must be in 'preload' bundle — engine-specific) */
20
+ logoAsset?: string;
21
+ /** Logo scale (default: 1) */
22
+ logoScale?: number;
23
+ /** Show percentage text below the loader bar */
24
+ showPercentage?: boolean;
25
+ /** Custom progress text formatter */
26
+ progressTextFormatter?: (progress: number) => string;
27
+ /** Show "Tap to start" after loading (needed for mobile audio unlock) */
28
+ tapToStart?: boolean;
29
+ /** "Tap to start" label text */
30
+ tapToStartText?: string;
31
+ /** Minimum display time in ms (so the user sees the brand, even if loading is fast) */
32
+ minDisplayTime?: number;
33
+ /** CSS preloader custom HTML (shown before the renderer is ready) */
34
+ cssPreloaderHTML?: string;
35
+ }
36
+
37
+ /**
38
+ * Creates a lightweight CSS-only preloader that appears instantly,
39
+ * BEFORE PixiJS/WebGL is initialized.
40
+ *
41
+ * Displays the Energy8 logo SVG with an animated loader bar.
42
+ */
43
+ declare function createCSSPreloader(container: HTMLElement, config?: LoadingScreenConfig): void;
44
+ /**
45
+ * Remove the CSS preloader with a smooth fade-out transition.
46
+ */
47
+ declare function removeCSSPreloader(container: HTMLElement): void;
48
+
49
+ /**
50
+ * Shared Energy8 SVG logo with an embedded loader bar.
51
+ *
52
+ * The loader bar fill is controlled via a `<clipPath>` whose `<rect>` width
53
+ * is animatable. Different consumers customise gradient IDs and the clip
54
+ * element's ID/class to avoid collisions when both CSSPreloader and
55
+ * LoadingScene appear in the same DOM.
56
+ */
57
+ /** Max width of the loader bar in SVG units */
58
+ declare const LOADER_BAR_MAX_WIDTH = 174;
59
+ interface LogoSVGOptions {
60
+ /** Prefix for gradient/clip IDs to avoid collisions (e.g. 'pl' or 'ls') */
61
+ idPrefix: string;
62
+ /** Optional CSS class on the root <svg> */
63
+ svgClass?: string;
64
+ /** Optional inline style on the root <svg> */
65
+ svgStyle?: string;
66
+ /** Optional CSS class on the clip <rect> */
67
+ clipRectClass?: string;
68
+ /** Optional id on the clip <rect> (for JS access) */
69
+ clipRectId?: string;
70
+ /** Optional id on the percentage <text> */
71
+ textId?: string;
72
+ /** Default text content */
73
+ textContent?: string;
74
+ /** Optional CSS class on the <text> */
75
+ textClass?: string;
76
+ }
77
+ /**
78
+ * Build the Energy8 SVG logo with a loader bar, using unique IDs.
79
+ *
80
+ * @param opts - Configuration to avoid element ID collisions
81
+ * @returns SVG markup string
82
+ */
83
+ declare function buildLogoSVG(opts: LogoSVGOptions): string;
84
+
85
+ export { LOADER_BAR_MAX_WIDTH, buildLogoSVG, createCSSPreloader, removeCSSPreloader };
86
+ export type { AssetBundle, AssetEntry, AssetManifest, LoadingScreenConfig };
@@ -0,0 +1,185 @@
1
+ /**
2
+ * Shared Energy8 SVG logo with an embedded loader bar.
3
+ *
4
+ * The loader bar fill is controlled via a `<clipPath>` whose `<rect>` width
5
+ * is animatable. Different consumers customise gradient IDs and the clip
6
+ * element's ID/class to avoid collisions when both CSSPreloader and
7
+ * LoadingScene appear in the same DOM.
8
+ */
9
+ /** SVG path data for the Energy8 wordmark — reused across loaders */
10
+ const WORDMARK_PATHS = `
11
+ <path d="m241 81.75h-19.28c-1.77 0-6.73 4.98-7.43 6.99l-4.36 12.22c-0.49 1.37 0.05 2.92 1.06 4.32-2.07 1.19-3.69 3.08-4.36 5.43l-3.25 10.41c-0.86 2.89 2.39 6.63 4.31 6.63h19.28c1.96 0 7.4-5.56 7.96-7.51l2.96-10.22c0.63-2.25 0.1-3.98-1.22-4.99 2.55-1.56 3.86-4.14 4.55-6.31l2.77-9.31c0.74-2.57-1.37-7.66-2.99-7.66zm-13.36 28.31-2.27 7.03h-8.28l2.58-8.28h8.28l-0.31 1.25zm4.06-16.97-2.11 6.7h-7.04l2.25-7.34h7.26l-0.36 0.64z" fill="url(#GID0)"/>
12
+ <path d="m202.5 81.75-9.31 14.97-2.32-14.97h-11.82l4.32 25.15-0.57 4.91-8.64 26.44 15.31-12.76 5.63-16.48 19.96-27.26h-12.56z" fill="url(#GID1)"/>
13
+ <path d="m174.2 81.75h-19.78l-5.75 5.16-10.79 33.2c-0.77 2.53 2.48 6.93 4.87 6.93h17.38c2.63 0 7.85-5.34 8.32-6.83l5.37-18.14h-15.17l-2.2 7.64h3.78l-2.25 7.2h-8.01l7.1-25.52h7.58l-1.48 8.4 12.78-5.98c1.28-0.63 1.97-3.99 1.61-6.61-0.36-2.34-1.64-5.45-3.36-5.45z" fill="url(#GID2)"/>
14
+ <path d="m140.6 81.75h-70.6l-5.36 19.37-4.26-19.37h-46.76l2.95 5.88-10.58 39.28h26.84l2.95-9.52-15.63-0.13 2.55-8.34h8.74l8.47-9.81h-14.61l2.11-7.3h15.47l2.54-8.71 2.58 4.74-11.4 39.07h11.05l6.46-21.49 8.84 36.33 19.18-55.67-1.83-3.36 3.68 4.09-12.07 40.1h28.18l3.39-10.31h-17.01l2.67-8.03h9.98l7.58-9.52h-14.28l1.93-6.6h14.61l3.25-9.73 2.81 5.12-11.3 38.89h11.05l5.23-17.81h1.62l1.48 17.6h10.69l-1.48-16.81c4.75-1.28 7.52-5.9 8.64-9.81l2.95-11.3c0.86-2.73-1.43-6.85-3.3-6.85zm-9.8 17.3h-8.69l2.54-7.84h8.35l-2.2 7.84z" fill="url(#GID3)"/>
15
+ <path d="m205.9 148.9h-122.6l-2.61-3.12h-32.4l-2.51 3.12h-1.59c-5.34 0-7.94 4.88-7.94 7.65v0.03c0 4.2 3.55 7.6 7.74 7.6h103.6l2.11 3.12h36.09l1.82-3.12h18.3c5.25 0 6.64-5.3 6.64-7.35v-0.25c0-4.23-2.9-7.68-6.64-7.68zm-0.7 12.83h-160.6c-3.69 0-6.11-2.58-6.11-5.47v-0.03c0-2.89 2.1-5.47 5.61-5.47h161.1c3.45 0 4.89 3.12 4.89 5.65v0.17c0 2.57-2.11 5.15-4.89 5.15z" fill="url(#GID4)"/>`;
16
+ /** Gradient definitions template (gradient IDs are replaced per-consumer) */
17
+ const GRADIENT_DEFS = `
18
+ <linearGradient id="GID0" x1="223.7" x2="223.7" y1="81.75" y2="127.8" gradientUnits="userSpaceOnUse">
19
+ <stop stop-color="#663BA6"/><stop stop-color="#7939C2" offset=".349"/><stop stop-color="#8A2FC0" offset=".6615"/><stop stop-color="#791BA3" offset="1"/>
20
+ </linearGradient>
21
+ <linearGradient id="GID1" x1="194.6" x2="194.6" y1="81.75" y2="138.3" gradientUnits="userSpaceOnUse">
22
+ <stop stop-color="#663BA6"/><stop stop-color="#7939C2" offset=".349"/><stop stop-color="#8A2FC0" offset=".6615"/><stop stop-color="#791BA3" offset="1"/>
23
+ </linearGradient>
24
+ <linearGradient id="GID2" x1="157.8" x2="157.8" y1="81.75" y2="127" gradientUnits="userSpaceOnUse">
25
+ <stop stop-color="#663BA6"/><stop stop-color="#7939C2" offset=".349"/><stop stop-color="#8A2FC0" offset=".6615"/><stop stop-color="#791BA3" offset="1"/>
26
+ </linearGradient>
27
+ <linearGradient id="GID3" x1="79.96" x2="79.96" y1="81.75" y2="141.8" gradientUnits="userSpaceOnUse">
28
+ <stop stop-color="#663BA6"/><stop stop-color="#7939C2" offset=".349"/><stop stop-color="#8A2FC0" offset=".6615"/><stop stop-color="#791BA3" offset="1"/>
29
+ </linearGradient>
30
+ <linearGradient id="GID4" x1="36.18" x2="212.5" y1="156.6" y2="156.6" gradientUnits="userSpaceOnUse">
31
+ <stop stop-color="#316FB0"/><stop stop-color="#1FCDE6" offset=".5"/><stop stop-color="#29FEE7" offset="1"/>
32
+ </linearGradient>
33
+ <linearGradient id="GID5" x1="40.27" x2="208.2" y1="156.4" y2="156.4" gradientUnits="userSpaceOnUse">
34
+ <stop stop-color="#316FB0"/><stop stop-color="#1FCDE6" offset=".5"/><stop stop-color="#29FEE7" offset="1"/>
35
+ </linearGradient>`;
36
+ /** Max width of the loader bar in SVG units */
37
+ const LOADER_BAR_MAX_WIDTH = 174;
38
+ /**
39
+ * Build the Energy8 SVG logo with a loader bar, using unique IDs.
40
+ *
41
+ * @param opts - Configuration to avoid element ID collisions
42
+ * @returns SVG markup string
43
+ */
44
+ function buildLogoSVG(opts) {
45
+ const { idPrefix, svgClass, svgStyle, clipRectClass, clipRectId, textId, textContent, textClass } = opts;
46
+ // Replace gradient ID placeholders with prefixed versions
47
+ const paths = WORDMARK_PATHS.replace(/GID(\d)/g, `${idPrefix}$1`);
48
+ const defs = GRADIENT_DEFS.replace(/GID(\d)/g, `${idPrefix}$1`);
49
+ const clipId = `${idPrefix}-loader-clip`;
50
+ const fillGradientId = `${idPrefix}5`;
51
+ const classAttr = svgClass ? ` class="${svgClass}"` : '';
52
+ const styleAttr = svgStyle ? ` style="${svgStyle}"` : '';
53
+ const rectClassAttr = clipRectClass ? ` class="${clipRectClass}"` : '';
54
+ const rectIdAttr = clipRectId ? ` id="${clipRectId}"` : '';
55
+ const txtIdAttr = textId ? ` id="${textId}"` : '';
56
+ const txtClassAttr = textClass ? ` class="${textClass}"` : '';
57
+ return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 250 200" fill="none"${classAttr}${styleAttr}>
58
+ ${paths}
59
+ <clipPath id="${clipId}">
60
+ <rect${rectIdAttr} x="37" y="148" width="0" height="20"${rectClassAttr}/>
61
+ </clipPath>
62
+ <path d="m204.5 152.6h-159.8c-2.78 0-4.45 1.69-4.45 3.99v0.11c0 2.04 1.42 3.43 3.64 3.43h160.6c2.88 0 3.67-2.07 3.67-3.43v-0.25c0-2.04-1.48-3.85-3.67-3.85z" fill="url(#${fillGradientId})" clip-path="url(#${clipId})"/>
63
+ <text${txtIdAttr} x="125" y="196" text-anchor="middle" fill="rgba(255,255,255,0.6)" font-family="-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif" font-size="8" font-weight="600" letter-spacing="1.5"${txtClassAttr}>${textContent ?? 'Loading...'}</text>
64
+ <defs>
65
+ ${defs}
66
+ </defs>
67
+ </svg>`;
68
+ }
69
+
70
+ const PRELOADER_ID = '__ge-css-preloader__';
71
+ /**
72
+ * Inline SVG logo with animated loader bar.
73
+ * The `#loader` path acts as the progress fill — animated via clipPath.
74
+ */
75
+ const LOGO_SVG = buildLogoSVG({
76
+ idPrefix: 'pl',
77
+ svgClass: 'ge-logo-svg',
78
+ clipRectClass: 'ge-clip-rect',
79
+ textClass: 'ge-preloader-svg-text',
80
+ });
81
+ /**
82
+ * Creates a lightweight CSS-only preloader that appears instantly,
83
+ * BEFORE PixiJS/WebGL is initialized.
84
+ *
85
+ * Displays the Energy8 logo SVG with an animated loader bar.
86
+ */
87
+ function createCSSPreloader(container, config) {
88
+ if (document.getElementById(PRELOADER_ID))
89
+ return;
90
+ const bgColor = typeof config?.backgroundColor === 'string'
91
+ ? config.backgroundColor
92
+ : typeof config?.backgroundColor === 'number'
93
+ ? `#${config.backgroundColor.toString(16).padStart(6, '0')}`
94
+ : '#0a0a1a';
95
+ const bgGradient = config?.backgroundGradient ?? `linear-gradient(135deg, ${bgColor} 0%, #1a1a3e 100%)`;
96
+ const customHTML = config?.cssPreloaderHTML ?? '';
97
+ const el = document.createElement('div');
98
+ el.id = PRELOADER_ID;
99
+ el.innerHTML = customHTML || `
100
+ <div class="ge-preloader-content">
101
+ ${LOGO_SVG}
102
+ </div>
103
+ `;
104
+ const style = document.createElement('style');
105
+ style.textContent = `
106
+ #${PRELOADER_ID} {
107
+ position: absolute;
108
+ top: 0; left: 0;
109
+ width: 100%; height: 100%;
110
+ background: ${bgGradient};
111
+ display: flex;
112
+ align-items: center;
113
+ justify-content: center;
114
+ z-index: 10000;
115
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
116
+ transition: opacity 0.4s ease-out;
117
+ }
118
+
119
+ #${PRELOADER_ID}.ge-preloader-hidden {
120
+ opacity: 0;
121
+ pointer-events: none;
122
+ }
123
+
124
+ .ge-preloader-content {
125
+ display: flex;
126
+ flex-direction: column;
127
+ align-items: center;
128
+ width: 80%;
129
+ max-width: 700px;
130
+ }
131
+
132
+ .ge-logo-svg {
133
+ width: 100%;
134
+ height: auto;
135
+ filter: drop-shadow(0 0 30px rgba(121, 57, 194, 0.4));
136
+ }
137
+
138
+ /* Animate the loader clip-rect to shimmer while waiting */
139
+ .ge-clip-rect {
140
+ animation: ge-loader-fill 2s ease-in-out infinite;
141
+ }
142
+
143
+ @keyframes ge-loader-fill {
144
+ 0% { width: 0; }
145
+ 50% { width: 174; }
146
+ 100% { width: 0; }
147
+ }
148
+
149
+ /* Animate the SVG text opacity */
150
+ .ge-preloader-svg-text {
151
+ animation: ge-pulse 1.5s ease-in-out infinite;
152
+ }
153
+
154
+ @keyframes ge-pulse {
155
+ 0%, 100% { opacity: 0.4; }
156
+ 50% { opacity: 1; }
157
+ }
158
+ `;
159
+ container.style.position = container.style.position || 'relative';
160
+ container.appendChild(style);
161
+ container.appendChild(el);
162
+ }
163
+ /**
164
+ * Remove the CSS preloader with a smooth fade-out transition.
165
+ */
166
+ function removeCSSPreloader(container) {
167
+ const el = document.getElementById(PRELOADER_ID);
168
+ if (!el)
169
+ return;
170
+ el.classList.add('ge-preloader-hidden');
171
+ // Remove after transition
172
+ el.addEventListener('transitionend', () => {
173
+ el.remove();
174
+ // Also remove the style element
175
+ const styles = container.querySelectorAll('style');
176
+ for (const style of styles) {
177
+ if (style.textContent?.includes(PRELOADER_ID)) {
178
+ style.remove();
179
+ }
180
+ }
181
+ });
182
+ }
183
+
184
+ export { LOADER_BAR_MAX_WIDTH, buildLogoSVG, createCSSPreloader, removeCSSPreloader };
185
+ //# sourceMappingURL=loading.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loading.esm.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,MAAM,oBAAoB,GAAG;AAqBpC;;;;;AAKG;AACG,S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