@ebay/muse-boot-default 1.3.5 → 2.0.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/MUSE_README.md ADDED
@@ -0,0 +1,400 @@
1
+ # Plugin Integration Guide: @ebay/muse-boot-default
2
+
3
+ **Generated**: 2026-03-28
4
+ **Plugin Type**: boot
5
+
6
+ ---
7
+
8
+ ## 1. Plugin Purpose & Overview
9
+
10
+ ### Purpose
11
+
12
+ `@ebay/muse-boot-default` is the default bootstrap plugin for MUSE applications. It orchestrates the entire application startup sequence, loading plugins in the correct order and initializing the MUSE runtime environment.
13
+
14
+ ### Key Capabilities
15
+
16
+ **Bootstrap Orchestration**
17
+ - Loads and executes plugins in the correct order: boot → init → lib → normal
18
+ - Manages the plugin loading lifecycle with parallel loading for optimal performance
19
+ - Provides loading progress feedback to users
20
+ - Handles error states and recovery during bootstrap
21
+
22
+ **MUSE Global Environment Setup**
23
+ - Initializes `window.MUSE_GLOBAL` with core utilities and configuration
24
+ - Sets up the shared modules system (`__shared__`)
25
+ - Configures app variables, plugin variables, and configuration merging
26
+ - Provides message engine for parent-child communication (sub-app scenarios)
27
+
28
+ **Plugin Loading System**
29
+ - Supports multiple plugin sources: CDN, local development, linked plugins
30
+ - Implements parallel loading for lib and normal plugins
31
+ - Handles ES module and UMD plugin formats
32
+ - Supports `forcePlugins` query parameter for debugging/testing
33
+
34
+ **Service Worker Registration**
35
+ - Registers service workers for offline support
36
+ - Manages service worker lifecycle
37
+
38
+ **Error Handling & Loading UI**
39
+ - Displays loading progress during bootstrap
40
+ - Shows error messages when bootstrap fails
41
+ - Provides fallback UI for failed states
42
+
43
+ ### Integration Role
44
+
45
+ As a **boot plugin**, this plugin:
46
+ - **MUST be the first plugin loaded** in any MUSE application
47
+ - Does not use the js-plugin extension point system (it runs before plugins are loaded)
48
+ - Provides the foundational environment that allows other plugins to function
49
+ - Is typically referenced in `index.html` as the entry script
50
+
51
+ ---
52
+
53
+ ## 2. Extension Points Exposed
54
+
55
+ This plugin does not expose extension points. As a boot plugin, it runs before the js-plugin system is initialized and focuses solely on loading other plugins and setting up the runtime environment.
56
+
57
+ ---
58
+
59
+ ## 3. Extension Points Contributed
60
+
61
+ This plugin does not contribute to extension points from other plugins. As the first plugin to load, there are no other plugins available to extend when this plugin runs.
62
+
63
+ ### Bootstrap Integration Points
64
+
65
+ While this plugin doesn't use extension points, it provides several integration mechanisms through `window.MUSE_GLOBAL`:
66
+
67
+ #### `waitForLoaders`
68
+ **Type**: `Array<Promise | AsyncFunction>`
69
+ **File Reference**: `src/boot.js:23, 273-286`
70
+
71
+ Plugins can register async loaders that must complete before the app starts:
72
+
73
+ ```javascript
74
+ // In an init plugin
75
+ window.MUSE_GLOBAL.waitFor(async () => {
76
+ await performAuth();
77
+ return true; // Return false to prevent app from starting
78
+ });
79
+ ```
80
+
81
+ ---
82
+
83
+ #### `initEntries`
84
+ **Type**: `Array<{ func: Function, order?: number }>`
85
+ **File Reference**: `src/boot.js:44, 201-208`
86
+
87
+ Init plugins can register initialization functions executed after init plugins load:
88
+
89
+ ```javascript
90
+ // In an init plugin
91
+ window.MUSE_GLOBAL.initEntries.push({
92
+ order: 10,
93
+ func: async () => {
94
+ await initialize();
95
+ // Return false to prevent app from starting
96
+ }
97
+ });
98
+ ```
99
+
100
+ ---
101
+
102
+ #### `appEntries`
103
+ **Type**: `Array<{ name: string, func: Function }>`
104
+ **File Reference**: `src/boot.js:43, 289-314`
105
+
106
+ Lib plugins can register app entry points (typically from `@ebay/muse-lib-react`):
107
+
108
+ ```javascript
109
+ // In a lib plugin with isAppEntry: true
110
+ window.MUSE_GLOBAL.appEntries.push({
111
+ name: '@ebay/muse-lib-react',
112
+ func: renderApp
113
+ });
114
+ ```
115
+
116
+ ---
117
+
118
+ #### `pluginEntries`
119
+ **Type**: `Array<{ func: Function }>`
120
+ **File Reference**: `src/boot.js:45, 267-270`
121
+
122
+ Build system can register plugin initialization code:
123
+
124
+ ```javascript
125
+ window.MUSE_GLOBAL.pluginEntries.push({
126
+ func: () => {
127
+ // Plugin initialization
128
+ }
129
+ });
130
+ ```
131
+
132
+ ---
133
+
134
+ ## 4. Exported Functionality
135
+
136
+ This plugin sets up `window.MUSE_GLOBAL` with the following utilities and systems:
137
+
138
+ ### Global Utilities
139
+
140
+ #### `msgEngine`
141
+ **File Reference**: `src/boot.js:38`, `src/msgEngine.js`
142
+ **Purpose**: Message passing system for parent-child window communication
143
+
144
+ **Why it exists**: Enables MUSE apps embedded in iframes to communicate with their parent windows.
145
+
146
+ **Methods**:
147
+ - `sendToParent(message)` - Send message to parent window
148
+ - `addListener(key, handler)` - Listen for messages
149
+ - `removeListener(key)` - Remove message listener
150
+
151
+ ---
152
+
153
+ #### `loading`
154
+ **File Reference**: `src/boot.js:39`, `src/loading.js`
155
+ **Purpose**: Loading UI management
156
+
157
+ **Why it exists**: Provides user feedback during the bootstrap process.
158
+
159
+ **Methods**:
160
+ - `init()` - Initialize loading UI
161
+ - `showMessage(message)` - Display loading message
162
+ - `hide()` - Hide loading UI
163
+
164
+ ---
165
+
166
+ #### `error`
167
+ **File Reference**: `src/boot.js:40`, `src/error.js`
168
+ **Purpose**: Error UI management
169
+
170
+ **Why it exists**: Displays error messages when bootstrap fails.
171
+
172
+ **Methods**:
173
+ - `showMessage(message)` - Display error message
174
+
175
+ ---
176
+
177
+ #### `getPublicPath(pluginName, assetPath)`
178
+ **File Reference**: `src/boot.js:51-76`
179
+ **Purpose**: Resolve public asset paths for plugins
180
+
181
+ **Why it exists**: Allows plugins to reference their public assets (images, fonts, etc.) correctly regardless of deployment environment.
182
+
183
+ **Usage**:
184
+ ```javascript
185
+ const logoUrl = window.MUSE_GLOBAL.getPublicPath('@ebay/my-plugin', 'logo.png');
186
+ // Returns: /muse-assets/cdn/p/my-plugin/v1.0.0/dist/logo.png
187
+ ```
188
+
189
+ ---
190
+
191
+ #### `waitFor(asyncFuncOrPromise)`
192
+ **File Reference**: `src/boot.js:47-49`
193
+ **Purpose**: Register async operations that must complete before app starts
194
+
195
+ **Why it exists**: Allows init plugins to perform async initialization (auth, config loading) before the main app renders.
196
+
197
+ **Usage**:
198
+ ```javascript
199
+ // In init plugin
200
+ window.MUSE_GLOBAL.waitFor(async () => {
201
+ const user = await fetchUser();
202
+ window.MUSE_GLOBAL.currentUser = user;
203
+ });
204
+ ```
205
+
206
+ ---
207
+
208
+ #### `getUser()`
209
+ **File Reference**: `src/boot.js:42`
210
+ **Purpose**: Get current user (default returns null, overridden by init plugins)
211
+
212
+ **Why it exists**: Provides a standard way to access user information across plugins.
213
+
214
+ ---
215
+
216
+ ### Shared Modules System
217
+
218
+ #### `__shared__`
219
+ **File Reference**: `src/boot.js:78-83`
220
+ **Purpose**: Runtime module sharing container
221
+
222
+ **Why it exists**: Enables lib plugins to provide shared modules (React, Redux, etc.) that other plugins consume without bundling.
223
+
224
+ **Properties**:
225
+ - `modules` - Container for shared modules
226
+ - `register(id, module)` - Register a shared module
227
+ - `require(id)` - Require a shared module
228
+ - `parseMuseId(id)` - Parse MUSE module identifier
229
+
230
+ **Note**: This is managed by `@ebay/muse-modules` package.
231
+
232
+ ---
233
+
234
+ ### Configuration System
235
+
236
+ #### `appConfig`
237
+ **File Reference**: `src/boot.js:27-37`
238
+ **Purpose**: Merged app and environment configuration
239
+
240
+ **Why it exists**: Provides a single source of truth for app configuration, with env config overriding app config.
241
+
242
+ **Usage**:
243
+ ```javascript
244
+ const routerType = window.MUSE_GLOBAL.appConfig.routerType;
245
+ ```
246
+
247
+ ---
248
+
249
+ #### `appVariables`
250
+ **File Reference**: `src/boot.js:35`
251
+ **Purpose**: App-level runtime variables
252
+
253
+ ---
254
+
255
+ #### `pluginVariables`
256
+ **File Reference**: `src/boot.js:36`
257
+ **Purpose**: Plugin-level runtime variables
258
+
259
+ ---
260
+
261
+ ### Environment Flags
262
+
263
+ #### `isSubApp`
264
+ **File Reference**: `src/boot.js:41`
265
+ **Purpose**: Boolean indicating if app is running in an iframe
266
+
267
+ **Why it exists**: Allows plugins to adjust behavior when embedded as a sub-app.
268
+
269
+ ---
270
+
271
+ #### `isDev`
272
+ **File Reference**: `src/boot.js:86`
273
+ **Purpose**: Boolean indicating development mode
274
+
275
+ ---
276
+
277
+ #### `isLocal`
278
+ **File Reference**: From `MUSE_GLOBAL`
279
+ **Purpose**: Boolean indicating local development mode
280
+
281
+ ---
282
+
283
+ #### `isE2eTest`
284
+ **File Reference**: `src/boot.js:86`
285
+ **Purpose**: Boolean indicating E2E test mode
286
+
287
+ ---
288
+
289
+ ## 5. Integration Examples
290
+
291
+ **Note**: This boot plugin does not use the js-plugin extension point system. The examples below show how to integrate with the bootstrap environment it provides.
292
+
293
+ ### Example 1: Creating an Init Plugin
294
+
295
+ Init plugins run after boot and before lib/normal plugins. They're perfect for authentication, configuration loading, or permission checks.
296
+
297
+ ```javascript
298
+ // src/index.js in an init plugin
299
+ const initFunc = async () => {
300
+ // Perform authentication
301
+ const user = await fetch('/api/user').then(r => r.json());
302
+
303
+ // Make user available globally
304
+ window.MUSE_GLOBAL.getUser = () => user;
305
+
306
+ // If auth fails, return false to prevent app from starting
307
+ if (!user) {
308
+ window.MUSE_GLOBAL.error.showMessage('Authentication failed');
309
+ return false;
310
+ }
311
+
312
+ return true; // Continue startup
313
+ };
314
+
315
+ // Register init entry
316
+ window.MUSE_GLOBAL.initEntries.push({
317
+ order: 10, // Lower numbers run first
318
+ func: initFunc
319
+ });
320
+ ```
321
+
322
+ ---
323
+
324
+ ### Example 2: Using waitFor for Async Initialization
325
+
326
+ ```javascript
327
+ // In an init plugin
328
+ window.MUSE_GLOBAL.waitFor(async () => {
329
+ // Load configuration from API
330
+ const config = await fetch('/api/config').then(r => r.json());
331
+
332
+ // Store in MUSE_GLOBAL
333
+ window.MUSE_GLOBAL.appVariables.apiEndpoint = config.apiEndpoint;
334
+
335
+ // Return false to prevent app start if config fails
336
+ if (!config) return false;
337
+ });
338
+ ```
339
+
340
+ ---
341
+
342
+ ### Example 3: Registering an App Entry (Lib Plugin)
343
+
344
+ ```javascript
345
+ // In a lib plugin like @ebay/muse-lib-react
346
+ const renderApp = () => {
347
+ const root = createRoot(document.getElementById('root'));
348
+ root.render(<App />);
349
+ };
350
+
351
+ window.MUSE_GLOBAL.appEntries.push({
352
+ name: '@ebay/muse-lib-react',
353
+ func: renderApp
354
+ });
355
+ ```
356
+
357
+ ---
358
+
359
+ ### Example 4: Using getPublicPath for Assets
360
+
361
+ ```javascript
362
+ // In any plugin after bootstrap
363
+ import React from 'react';
364
+
365
+ const MyComponent = () => {
366
+ const logoPath = window.MUSE_GLOBAL.getPublicPath(
367
+ '@ebay/my-plugin',
368
+ 'images/logo.png'
369
+ );
370
+
371
+ return <img src={logoPath} alt="Logo" />;
372
+ };
373
+ ```
374
+
375
+ ---
376
+
377
+ ### Example 5: Force Loading Specific Plugin Versions
378
+
379
+ For debugging or testing, use the `forcePlugins` query parameter:
380
+
381
+ ```
382
+ https://myapp.com?forcePlugins=@ebay/my-plugin@1.2.3;other-plugin@2.0.0
383
+ ```
384
+
385
+ This overrides the deployed plugin versions with specific versions.
386
+
387
+ ---
388
+
389
+ ## Notes
390
+
391
+ - **This is a boot plugin** (`muse.type: "boot"`) - it MUST be loaded first via `index.html`
392
+ - Does not use js-plugin extension points (runs before plugin system is initialized)
393
+ - Provides the foundational environment for all other plugins
394
+ - Handles plugin loading order: boot → init → lib → normal
395
+ - Init plugins can use `initEntries` or `waitFor` to perform async initialization
396
+ - Lib plugins with `isAppEntry: true` register app entry functions
397
+ - The `forcePlugins` query parameter is useful for debugging specific plugin versions
398
+ - Service worker registration is automatic but can be customized
399
+ - All plugin loading happens in parallel for performance (within each type group)
400
+ - The loading UI provides user feedback during the bootstrap process
@@ -1,2 +1,20 @@
1
- (()=>{var e={30:e=>{"use strict";var n=[];function t(e){for(var t=-1,o=0;o<n.length;o++)if(n[o].identifier===e){t=o;break}return t}function o(e,o){for(var r={},a=[],s=0;s<e.length;s++){var l=e[s],d=o.base?l[0]+o.base:l[0],c=r[d]||0,p="".concat(d," ").concat(c);r[d]=c+1;var u=t(p),A={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==u)n[u].references++,n[u].updater(A);else{var m=i(A,o);o.byIndex=s,n.splice(s,0,{identifier:p,updater:m,references:1})}a.push(p)}return a}function i(e,n){var t=n.domAPI(n);t.update(e);return function(n){if(n){if(n.css===e.css&&n.media===e.media&&n.sourceMap===e.sourceMap&&n.supports===e.supports&&n.layer===e.layer)return;t.update(e=n)}else t.remove()}}e.exports=function(e,i){var r=o(e=e||[],i=i||{});return function(e){e=e||[];for(var a=0;a<r.length;a++){var s=t(r[a]);n[s].references--}for(var l=o(e,i),d=0;d<r.length;d++){var c=t(r[d]);0===n[c].references&&(n[c].updater(),n.splice(c,1))}r=l}}},78:(e,n,t)=>{"use strict";e.exports=function(e){var n=t.nc;n&&e.setAttribute("nonce",n)}},103:e=>{"use strict";e.exports=function(e,n){if(n.styleSheet)n.styleSheet.cssText=e;else{for(;n.firstChild;)n.removeChild(n.firstChild);n.appendChild(document.createTextNode(e))}}},104:(e,n,t)=>{e.exports=function(){if("undefined"!==typeof self)return self;if("undefined"!==typeof window)return window;if("undefined"!==typeof t.g)return t.g;throw new Error("unable to locate global object")}()},122:e=>{"use strict";e.exports=function(e){var n=document.createElement("style");return e.setAttributes(n,e.attributes),e.insert(n,e.options),n}},123:e=>{e.exports=function(e){try{var n;const t=/((^@[^/]+\/)?([^@/]+))@(\d+)\.(\d+)\.(\d+)([^./][^/]*)?\/(.+)$/.exec(e);return t?{name:t[1],path:t[8],id:"".concat(t[1],"/").concat(t[8]),museId:e,version:t.slice(4,7).map(Number),preRelease:null===(n=t[7])||void 0===n?void 0:n.replace("-","")}:null}catch(t){return null}}},142:e=>{"use strict";e.exports=function(e){var n=e[1],t=e[3];if(!t)return n;if("function"===typeof btoa){var o=btoa(unescape(encodeURIComponent(JSON.stringify(t)))),i="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(o),r="/*# ".concat(i," */");return[n].concat([r]).join("\n")}return[n].join("\n")}},267:(e,n,t)=>{e.exports={config:t(753),require:t(506),register:t(914),parseMuseId:t(123),findMuseModule:t(734)}},293:e=>{"use strict";var n={};e.exports=function(e,t){var o=function(e){if("undefined"===typeof n[e]){var t=document.querySelector(e);if(window.HTMLIFrameElement&&t instanceof window.HTMLIFrameElement)try{t=t.contentDocument.head}catch(o){t=null}n[e]=t}return n[e]}(e);if(!o)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");o.appendChild(t)}},487:e=>{"use strict";e.exports=function(e){if("undefined"===typeof document)return{update:function(){},remove:function(){}};var n=e.insertStyleElement(e);return{update:function(t){!function(e,n,t){var o="";t.supports&&(o+="@supports (".concat(t.supports,") {")),t.media&&(o+="@media ".concat(t.media," {"));var i="undefined"!==typeof t.layer;i&&(o+="@layer".concat(t.layer.length>0?" ".concat(t.layer):""," {")),o+=t.css,i&&(o+="}"),t.media&&(o+="}"),t.supports&&(o+="}");var r=t.sourceMap;r&&"undefined"!==typeof btoa&&(o+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(r))))," */")),n.styleTagTransform(o,e,n.options)}(n,e,t)},remove:function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(n)}}}},506:(e,n,t)=>{const o=t(734);var i={};e.exports=e=>{var n=i[e];n||(museModule=n,i[e]=o(e));const t=i[e];if(!t)throw new Error("Muse shared module not found: "+e);return t.__require__(t.id)}},733:(e,n,t)=>{const o=t(123);e.exports=function(e){e.cache||(e.cache={}),e.modules||(e.modules={}),Object.keys(e.modules).forEach(n=>{const t=o(n);t&&(e.cache[t.id]||(e.cache[t.id]=[]),e.cache[t.id].push(t))})}},734:(e,n,t)=>{const o=t(123),i=t(733),r=t(753),a=(e,n)=>[0,1,2].map(t=>Math.abs(e[t]-n[t])),s=(e,n)=>{for(let t=0;t<3;t++){if(e[t]<n[t])return!0;if(e[t]>n[t])return!1}return!1},l=(e,n)=>!s(e,n);e.exports=function(e,n){if(e=e.replace(/\\/g,"/").replace(/\/+/g,"/"),n||(n=MUSE_GLOBAL.__shared__),n.modules[e])return n.modules[e];let t=n.cache;t||(i(n),t=n.cache);const d=o(e);if(!d)return null;const c=t[d.id];if(!c)return null;let p=c[0],u=a(d.version,p.version);for(let o=1;o<c.length;o++){const e=c[o];if(d.version.join(".")===e.version.join(".")){p=e;break}if(l(p.version,d.version)&&s(e.version,d.version))continue;const n=a(e.version,d.version);(s(p.version,d.version)&&l(e.version,d.version)||s(n,u))&&(u=n,p=e)}switch(r.matchVersion){case"major":if(0!==u[0])return null;break;case"minor":if(0!==u[0]||0!==u[1])return null;break;case"patch":if(0!==u[0]||0!==u[1]||0!==u[2])return null}return n.modules[p.museId]}},753:()=>{},774:e=>{"use strict";e.exports=function(e){var n=[];return n.toString=function(){return this.map(function(n){var t="",o="undefined"!==typeof n[5];return n[4]&&(t+="@supports (".concat(n[4],") {")),n[2]&&(t+="@media ".concat(n[2]," {")),o&&(t+="@layer".concat(n[5].length>0?" ".concat(n[5]):""," {")),t+=e(n),o&&(t+="}"),n[2]&&(t+="}"),n[4]&&(t+="}"),t}).join("")},n.i=function(e,t,o,i,r){"string"===typeof e&&(e=[[null,e,void 0]]);var a={};if(o)for(var s=0;s<this.length;s++){var l=this[s][0];null!=l&&(a[l]=!0)}for(var d=0;d<e.length;d++){var c=[].concat(e[d]);o&&a[c[0]]||("undefined"!==typeof r&&("undefined"===typeof c[5]||(c[1]="@layer".concat(c[5].length>0?" ".concat(c[5]):""," {").concat(c[1],"}")),c[5]=r),t&&(c[2]?(c[1]="@media ".concat(c[2]," {").concat(c[1],"}"),c[2]=t):c[2]=t),i&&(c[4]?(c[1]="@supports (".concat(c[4],") {").concat(c[1],"}"),c[4]=i):c[4]="".concat(i)),n.push(c))}},n}},860:(e,n,t)=>{"use strict";t.d(n,{A:()=>s});var o=t(142),i=t.n(o),r=t(774),a=t.n(r)()(i());a.push([e.id,"#muse-loading-node {\n position: fixed;\n display: grid;\n place-items: center;\n left: 0;\n top: 0%;\n width: 100%;\n height: 100%;\n z-index: 99999;\n /* background-color: #fff; */\n transition: opacity ease-out 0.3s;\n line-height: 1.5 !important;\n}\n\n#muse-loading-node .muse-loading-node-inner {\n position: relative;\n display: grid;\n place-items: center;\n}\n\n/* #muse-loading-node .muse-loading-node-inner > svg {\n width: 120px;\n height: 120px;\n} */\n\n#muse-loading-node .muse-loading-node-inner > img {\n position: absolute;\n width: 60px;\n}\n\n#muse-loading-node div > label {\n display: block;\n text-align: center;\n font-family: Helvetica, Arial, sans-serif;\n color: #888;\n font-size: 13px;\n}\n\n@keyframes ldio-klconu2768 {\n 0% {\n transform: rotate(0deg);\n }\n 50% {\n transform: rotate(180deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n}\n.ldio-klconu2768 div {\n position: absolute;\n animation: ldio-klconu2768 1s linear infinite;\n width: 140px;\n height: 140px;\n top: 30px;\n left: 30px;\n border-radius: 50%;\n box-shadow: 0 4px 0 0 #00b4d8;\n transform-origin: 70px 72px;\n}\n.loadingio-spinner-eclipse-p5fn84x4bh8 {\n width: 200px;\n height: 200px;\n display: inline-block;\n overflow: hidden;\n}\n.ldio-klconu2768 {\n width: 100%;\n height: 100%;\n position: relative;\n transform: translateZ(0) scale(1);\n -webkit-backface-visibility: hidden;\n backface-visibility: hidden;\n transform-origin: 0 0; /* see note above */\n}\n.ldio-klconu2768 div {\n box-sizing: content-box;\n}\n/* generated by https://loading.io/ */\n\n#muse-error-node {\n position: fixed;\n left: 0;\n top: 0;\n height: 100%;\n width: 100%;\n font-family: Helvetica, Arial, sans-serif;\n color: red;\n line-height: 150%;\n font-size: 14px;\n display: grid;\n place-items: center;\n}\n\n#muse-error-node .muse-error-node-inner {\n min-width: 500px;\n max-width: 800px;\n border: 1px solid red;\n border-radius: 3px;\n padding: 15px;\n}\n#muse-error-node h4 {\n margin-top: 0;\n margin-bottom: 10px;\n font-size: 16px;\n}\n#muse-error-node li {\n padding: 3px 0;\n}\n#muse-error-node p {\n color: #777;\n font-style: italic;\n font-size: 13px;\n}\n\n#muse-error-node p a {\n color: #039be5;\n text-decoration: none;\n}\n\n#muse-error-node p a:hover {\n text-decoration: underline;\n}\n\n.muse-theme-dark {\n background-color: #141414;\n}\n","",{version:3,sources:["webpack://./src/style.css"],names:[],mappings:"AAAA;EACE,eAAe;EACf,aAAa;EACb,mBAAmB;EACnB,OAAO;EACP,OAAO;EACP,WAAW;EACX,YAAY;EACZ,cAAc;EACd,4BAA4B;EAC5B,iCAAiC;EACjC,2BAA2B;AAC7B;;AAEA;EACE,kBAAkB;EAClB,aAAa;EACb,mBAAmB;AACrB;;AAEA;;;GAGG;;AAEH;EACE,kBAAkB;EAClB,WAAW;AACb;;AAEA;EACE,cAAc;EACd,kBAAkB;EAClB,yCAAyC;EACzC,WAAW;EACX,eAAe;AACjB;;AAEA;EACE;IACE,uBAAuB;EACzB;EACA;IACE,yBAAyB;EAC3B;EACA;IACE,yBAAyB;EAC3B;AACF;AACA;EACE,kBAAkB;EAClB,6CAA6C;EAC7C,YAAY;EACZ,aAAa;EACb,SAAS;EACT,UAAU;EACV,kBAAkB;EAClB,6BAA6B;EAC7B,2BAA2B;AAC7B;AACA;EACE,YAAY;EACZ,aAAa;EACb,qBAAqB;EACrB,gBAAgB;AAClB;AACA;EACE,WAAW;EACX,YAAY;EACZ,kBAAkB;EAClB,iCAAiC;EACjC,mCAA2B;UAA3B,2BAA2B;EAC3B,qBAAqB,EAAE,mBAAmB;AAC5C;AACA;EACE,uBAAuB;AACzB;AACA,qCAAqC;;AAErC;EACE,eAAe;EACf,OAAO;EACP,MAAM;EACN,YAAY;EACZ,WAAW;EACX,yCAAyC;EACzC,UAAU;EACV,iBAAiB;EACjB,eAAe;EACf,aAAa;EACb,mBAAmB;AACrB;;AAEA;EACE,gBAAgB;EAChB,gBAAgB;EAChB,qBAAqB;EACrB,kBAAkB;EAClB,aAAa;AACf;AACA;EACE,aAAa;EACb,mBAAmB;EACnB,eAAe;AACjB;AACA;EACE,cAAc;AAChB;AACA;EACE,WAAW;EACX,kBAAkB;EAClB,eAAe;AACjB;;AAEA;EACE,cAAc;EACd,qBAAqB;AACvB;;AAEA;EACE,0BAA0B;AAC5B;;AAEA;EACE,yBAAyB;AAC3B",sourcesContent:["#muse-loading-node {\n position: fixed;\n display: grid;\n place-items: center;\n left: 0;\n top: 0%;\n width: 100%;\n height: 100%;\n z-index: 99999;\n /* background-color: #fff; */\n transition: opacity ease-out 0.3s;\n line-height: 1.5 !important;\n}\n\n#muse-loading-node .muse-loading-node-inner {\n position: relative;\n display: grid;\n place-items: center;\n}\n\n/* #muse-loading-node .muse-loading-node-inner > svg {\n width: 120px;\n height: 120px;\n} */\n\n#muse-loading-node .muse-loading-node-inner > img {\n position: absolute;\n width: 60px;\n}\n\n#muse-loading-node div > label {\n display: block;\n text-align: center;\n font-family: Helvetica, Arial, sans-serif;\n color: #888;\n font-size: 13px;\n}\n\n@keyframes ldio-klconu2768 {\n 0% {\n transform: rotate(0deg);\n }\n 50% {\n transform: rotate(180deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n}\n.ldio-klconu2768 div {\n position: absolute;\n animation: ldio-klconu2768 1s linear infinite;\n width: 140px;\n height: 140px;\n top: 30px;\n left: 30px;\n border-radius: 50%;\n box-shadow: 0 4px 0 0 #00b4d8;\n transform-origin: 70px 72px;\n}\n.loadingio-spinner-eclipse-p5fn84x4bh8 {\n width: 200px;\n height: 200px;\n display: inline-block;\n overflow: hidden;\n}\n.ldio-klconu2768 {\n width: 100%;\n height: 100%;\n position: relative;\n transform: translateZ(0) scale(1);\n backface-visibility: hidden;\n transform-origin: 0 0; /* see note above */\n}\n.ldio-klconu2768 div {\n box-sizing: content-box;\n}\n/* generated by https://loading.io/ */\n\n#muse-error-node {\n position: fixed;\n left: 0;\n top: 0;\n height: 100%;\n width: 100%;\n font-family: Helvetica, Arial, sans-serif;\n color: red;\n line-height: 150%;\n font-size: 14px;\n display: grid;\n place-items: center;\n}\n\n#muse-error-node .muse-error-node-inner {\n min-width: 500px;\n max-width: 800px;\n border: 1px solid red;\n border-radius: 3px;\n padding: 15px;\n}\n#muse-error-node h4 {\n margin-top: 0;\n margin-bottom: 10px;\n font-size: 16px;\n}\n#muse-error-node li {\n padding: 3px 0;\n}\n#muse-error-node p {\n color: #777;\n font-style: italic;\n font-size: 13px;\n}\n\n#muse-error-node p a {\n color: #039be5;\n text-decoration: none;\n}\n\n#muse-error-node p a:hover {\n text-decoration: underline;\n}\n\n.muse-theme-dark {\n background-color: #141414;\n}\n"],sourceRoot:""}]),a.locals={};const s=a},914:(e,n,t)=>{const o=t(104),i=t(123);e.exports=function(e,n){for(const t in e){if(!i(t))continue;e[t];o.MUSE_GLOBAL.__shared__.modules[t]={id:t,__require__:n}}}}},n={};function t(o){var i=n[o];if(void 0!==i)return i.exports;var r=n[o]={id:o,exports:{}};return e[o](r,r.exports,t),r.exports}t.n=e=>{var n=e&&e.__esModule?()=>e.default:()=>e;return t.d(n,{a:n}),n},t.d=(e,n)=>{for(var o in n)t.o(n,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:n[o]})},t.g=function(){if("object"===typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"===typeof window)return window}}(),t.o=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),(()=>{var e;t.g.importScripts&&(e=t.g.location+"");var n=t.g.document;if(!e&&n&&(n.currentScript&&"SCRIPT"===n.currentScript.tagName.toUpperCase()&&(e=n.currentScript.src),!e)){var o=n.getElementsByTagName("script");if(o.length)for(var i=o.length-1;i>-1&&(!e||!/^http(s?):/.test(e));)e=o[i--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),t.p=e})(),t.nc=void 0,(()=>{"use strict";function e(n){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(n)}function n(n){var t=function(n,t){if("object"!=e(n)||!n)return n;var o=n[Symbol.toPrimitive];if(void 0!==o){var i=o.call(n,t||"default");if("object"!=e(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(n)}(n,"string");return"symbol"==e(t)?t:t+""}function o(e,t,o){return(t=n(t))in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}function i(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);n&&(o=o.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),t.push.apply(t,o)}return t}function r(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?i(Object(t),!0).forEach(function(n){o(e,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):i(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}return e}var a=t(267),s=t.n(a);const l=t.p+"static/media/logo.0629cb217459ef0a31a2.png",d={init(){var e;const{app:n,cdn:t}=window.MUSE_GLOBAL,o=document.createElement("div"),i=n.iconId?"".concat(t,"/p/app-icon.").concat(n.name,"/v0.0.").concat(n.iconId,"/dist/icon.png"):l;o.innerHTML='\n <div>\n <div class=\'muse-loading-node-inner\'>\n <div class="loadingio-spinner-eclipse-p5fn84x4bh8"><div class="ldio-klconu2768"><div>\n </div></div></div>\n <img src="'.concat(i,'" aria-label="logo" />\n </div>\n <label>Starting...</label>\n </div>\n '),o.id="muse-loading-node",("dark"===(null===(e=n.config)||void 0===e?void 0:e.theme)&&!localStorage.getItem("muse.theme")||localStorage.getItem("muse.theme")&&"dark"===localStorage.getItem("muse.theme"))&&document.body.classList.add("muse-theme-dark"),document.body.appendChild(o),this.mountNode=o,this.labelNode=o.querySelector("label")},hide(){this.mountNode&&(setTimeout(()=>{this.mountNode.style.opacity=0},10),setTimeout(()=>{document.body.removeChild(this.mountNode),delete this.mountNode},800),delete this.labelNode)},showMessage(e){this.labelNode&&(this.labelNode.innerHTML=e||"")}},c={errors:[],init(){const e=document.createElement("div");e.innerHTML="",e.id="muse-error-node",document.body.appendChild(e),this.mountNode=e},showMessage(e){const n=null!==e&&void 0!==e&&e.splice?e:[e];this.errors.push(...n),this.update()},update(){var e;this.mountNode||this.init();const n=1===this.errors.length?"<div>".concat(this.errors[0],"</div>"):"<ul>\n ".concat(this.errors.map(e=>"<li>"+e+"</li>").join(""),"\n </ul>");this.mountNode.innerHTML='\n <div class="muse-error-node-inner">\n <h4>Failed to load:</h4>\n '.concat(n,'\n <p>* Unexpected error happened, please refresh to retry or <a href="').concat((null===(e=window.MUSE_GLOBAL.appConfig)||void 0===e?void 0:e.supportLink)||"#",'">contact support</a>.</p>\n </div>\n ')}};const p=function(){const{serviceWorker:e}=window.MUSE_GLOBAL;if(navigator.serviceWorker)return e&&"https:"===window.location.protocol?(d.showMessage("Registering Muse service worker."),new Promise(n=>{let t=!1;setTimeout(()=>{t||(console.log("Failed to register service worker in 10 seconds. Skip it."),n())},1e4),navigator.serviceWorker.register(e,{}).then(function(){t=!0,console.log("Service Worker register done."),n()}).catch(()=>{t=!0,console.log("Failed to register service worker, skip it."),n()})})):void 0},u=()=>{};async function A(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:u,t=0;await Promise.all(e.map(async e=>{await function(e,n){if(n=n||u,!e.then||!e.catch)return e.url?new Promise((t,o)=>{const i=document.querySelector("head"),r=document.createElement("script");r.src=e.url,e.esModule&&(r.type="module"),i.appendChild(r),r.onload=()=>{n(),t()},r.onerror=()=>{c.showMessage("Failed to load resource: ".concat(e.url," .")),o()}}):void 0;e.then(n)}(e),n(++t)}))}function m(e){return e.startsWith("@")?e.replace("/","."):e}const f=()=>Math.random().toString(36).substring(2),h={listeners:{},promises:{},iframes:{},register(e,n){this.iframes[e]=n},unregister(e){delete this.iframes[e]},getIframe(e){return"string"===typeof e?this.iframes[e]:e},init(){this.addListener("handle-muse-app-check",(e,n)=>{var t,o,i,r;"assert-muse-app"===(null===e||void 0===e?void 0:e.type)&&"parent"===(null===(t=n.data)||void 0===t||null===(o=t.from)||void 0===o?void 0:o.clientKey)&&(this.sendToParent({promiseId:null===n||void 0===n||null===(i=n.data)||void 0===i?void 0:i.promiseId,data:{app:window.MUSE_GLOBAL.app.name,env:window.MUSE_GLOBAL.env.name}}),window.MUSE_GLOBAL.parentApp=null===n||void 0===n||null===(r=n.data)||void 0===r?void 0:r.from)}),window.addEventListener("message",e=>{var n,t,o;if("muse"===(null===e||void 0===e||null===(n=e.data)||void 0===n?void 0:n.type)){var i;if(console.log("on muse post msg: ",e),null!==e&&void 0!==e&&null!==(t=e.data)&&void 0!==t&&null!==(o=t.payload)&&void 0!==o&&o.promiseId)this.resolvePromise(e.data.payload.promiseId,null===e||void 0===e||null===(i=e.data.payload)||void 0===i?void 0:i.data);Object.entries(this.listeners).forEach(n=>{let[t,o]=n;try{o(e.data.payload,e)}catch(i){console.log('Warning: failed to process message "'.concat(t,'"'),e,i)}})}},!1)},resolve(e,n){},addListener(e,n){this.listeners[e]=n},removeListener(e){delete this.listeners[e]},sendToChild(e,n){let t=null,o=null,i=null;arguments.length>2&&void 0!==arguments[2]&&arguments[2]&&(i=f(),t=new Promise((e,n)=>{o=this.promises[i]={resolve:e,reject:n}}));try{var r,a;null===(r=this.getIframe(n))||void 0===r||null===(a=r.contentWindow)||void 0===a||a.postMessage({type:"muse",promiseId:i,from:{app:window.MUSE_GLOBAL.appName,env:window.MUSE_GLOBAL.envName,clientKey:"parent"},payload:e},"*")}catch(s){console.log("Failed to post message to child: ",e),t&&o.reject(s)}return t},sendToParent(e){let n=null,t=null,o=null;if(arguments.length>1&&void 0!==arguments[1]&&arguments[1]&&(o=f(),n=new Promise((e,n)=>{t=this.promises[o]={resolve:e,reject:n}})),window.parent&&window.parent!==window)try{window.parent.postMessage({type:"muse",promiseId:o,from:{app:window.MUSE_GLOBAL.appName,env:window.MUSE_GLOBAL.envName,type:"child"},payload:e},"*")}catch(i){console.log("Failed to send message to parent: ",e),n&&t.reject(i)}return n},assertMuseApp(e){return new Promise((n,t)=>{this.sendToChild({type:"assert-muse-app"},this.getIframe(e),!0).then(n),setTimeout(()=>t(new Error("Muse app check timeout.")),300)})},getParentUrl(){return new Promise((e,n)=>{this.sendToParent({type:"get-parent-url"},!0).then(e),setTimeout(()=>n(new Error("Get parent url timeout.")),300)})},parentNavigate(e){this.sendToParent({type:"parent-navigate",url:e})},resolvePromise(e,n){var t;null===(t=this.promises[e])||void 0===t||t.resolve(n),delete this.promises[e]},resolveParent(e,n){h.sendToParent({promiseId:e,data:n})},resolveChild(e,n,t){h.sendToChild({promiseId:e,data:n},null===t||void 0===t?void 0:t.source)}};h.addListener("handle-muse-app-check",(e,n)=>{var t,o,i;"assert-muse-app"===(null===e||void 0===e?void 0:e.type)&&"parent"===(null===(t=n.data)||void 0===t||null===(o=t.from)||void 0===o?void 0:o.clientKey)&&h.resolveParent(null===n||void 0===n||null===(i=n.data)||void 0===i?void 0:i.promiseId,{app:window.MUSE_GLOBAL.appName,env:window.MUSE_GLOBAL.envName})}),h.addListener("parent-navigate",e=>{"parent-navigate"===(null===e||void 0===e?void 0:e.type)&&null!==e&&void 0!==e&&e.url&&(window.location.href=e.url)}),h.addListener("get-parent-url",(e,n)=>{var t;"get-parent-url"===(null===e||void 0===e?void 0:e.type)&&(console.log("get-parent-url: ",window.location.href),h.resolveChild(null===n||void 0===n||null===(t=n.data)||void 0===t?void 0:t.promiseId,window.location.href,n))});const g=h,v=e=>{const n=window.history,t=n[e];n[e]=function(n){const o=t.apply(this,arguments),i=new Event("muse_boot_"+e.toLowerCase());return i.state=n,window.dispatchEvent(i),o}};v("pushState"),v("replaceState");const w=()=>{g.sendToParent({type:"child-route-change",path:window.location.href.replace(window.location.origin,"")})};window.addEventListener("popstate",w),window.addEventListener("muse_boot_pushstate",w),window.addEventListener("muse_boot_replacestate",w);var E=t(30),y=t.n(E),b=t(487),C=t.n(b),B=t(293),x=t.n(B),M=t(78),L=t.n(M),k=t(122),S=t.n(k),O=t(103),_=t.n(O),P=t(860),j={base:11914653};j.styleTagTransform=_(),j.setAttributes=L(),j.insert=x().bind(null,"head"),j.domAPI=C(),j.insertStyleElement=S();y()(P.A,j);P.A&&P.A.locals&&P.A.locals;!function(){if(!window.MUSE_GLOBAL)throw new Error("There must be a global window.MUSE_GLOBAL object");d.init(),g.init();const e=Date.now(),n=[];let t,o="success";(async function(){var e,n;const t=window.sessionStorage.getItem("MUSE_TEMP_temp-redirect-url");if(t)return window.sessionStorage.removeItem("MUSE_TEMP_temp-redirect-url"),void(window.location=t);const o=window.MUSE_GLOBAL;d.showMessage("Starting...");const i=o.waitForLoaders||[],a=Object.assign({},null===(e=o.app)||void 0===e?void 0:e.config);Object.entries((null===(n=o.env)||void 0===n?void 0:n.config)||{}).forEach(e=>{let[n,t]=e;null!==t&&void 0!==t&&""!==t&&(a[n]=t)}),Object.assign(o,{appVariables:o.appVariables||{},pluginVariables:o.pluginVariables||{},appConfig:a,msgEngine:g,loading:d,error:c,isSubApp:window.parent!==window,getUser:()=>null,appEntries:o.appEntries||[],initEntries:o.initEntries||[],pluginEntries:o.pluginEntries||[],waitFor:e=>{i.push(e)},getPublicPath:(e,n)=>{var t;if(!n)throw new Error("assetPath is required for getPublicPath method.");n=n.replace(/^\/*/,"");const i=m(e);if(o.isDev){var r;const t=null===(r=o.plugins.find(e=>!!e.localPlugins))||void 0===r?void 0:r.localPlugins;if(t&&t.includes(e))return"/muse-assets/local/p/".concat(i,"/").concat(n)}const a=null===(t=window.MUSE_GLOBAL.plugins)||void 0===t?void 0:t.find(n=>n.name===e);if(!a)return;let{version:s}=a||{};s.startsWith("v")||(s="v".concat(s));let l="".concat(window.MUSE_GLOBAL.cdn,"/p/").concat(i,"/").concat(s);return window.MUSE_GLOBAL.isDev||window.MUSE_GLOBAL.isLocal?l+="/dev/".concat(n):l+="/dist/".concat(n),l},__shared__:{modules:{},register:s().register,require:s().require,parseMuseId:s().parseMuseId}});const{cdn:l="",initEntries:u,pluginEntries:f,appEntries:h,isDev:v=!1,isE2eTest:w=!1}=o;let{plugins:E=[]}=window.MUSE_GLOBAL;window.MUSE_CONFIG=o,g.sendToParent({type:"app-state-change",state:"app-starting"}),p();const y=E.find(e=>"boot"===e.type);y&&console.log("Loading Muse app by ".concat(y.name,"@").concat(y.version||y.url,"..."));const b=new URLSearchParams(window.location.search).get("forcePlugins");if(b){const e=b.split(";").filter(Boolean).reduce((e,n)=>{let t="";n.startsWith("@")&&"@"===n[0]&&(n=n.substring(1),t="@");const o=n.split("@",2);if(2===o.length){const[n,i]=o[0].split("!");e["".concat(t).concat(n)]={version:o[1],type:i}}return e},{});E=E.map(n=>{if(!e[n.name])return n;const t=r(r({},n),{},{version:e[n.name].version});return delete e[n.name],t}).filter(e=>"null"!==e.version);for(const n in e)"null"!==e[n].version&&E.push({name:n,type:e[n].type,version:e[n].version})}console.log("Plugins(".concat(E.length,"):")),E.forEach(e=>{let n="";if(e.linkedTo)n="Linked to: "+e.linkedTo;else if(e.isLocalLib){var t;n="Local:"+((null===(t=/\d{4,}/.exec(e.url))||void 0===t?void 0:t[0])||document.location.port)}else e.url&&(n=e.url);n&&(n=" (".concat(n,")")),console.log(" * ".concat(e.name,"@").concat(e.version||"local").concat(n))}),g.sendToParent({type:"app-state-change",state:"app-loading"});const C=E.filter(e=>"init"===e.type).map(e=>r({url:!e.isLocal&&!e.linkedTo&&(e.url||"".concat(l,"/p/").concat(m(e.name),"/v").concat(e.version,"/dist/main.js"))},e)).filter(Boolean);if(C.length>0&&(d.showMessage("Loading init plugins 1/".concat(C.length,"...")),await A(C,e=>d.showMessage("Loading init plugins ".concat(Math.min(e+1,C.length),"/").concat(C.length,"...")))),u.length>0){d.showMessage("Executing init entries..."),u.sort((e,n)=>(e.order||10)-(n.order||10));for(const e of u)if(!1===await e.func())return}const B=v?"dev":w?"test":"dist",x=E.filter(e=>"boot"!==e.type&&"init"!==e.type).map(e=>r({url:!e.isLocal&&!e.linkedTo&&(e.url||"".concat(l,"/p/").concat(m(e.name),"/v").concat(e.version,"/").concat(B,"/main.js"))},e)).filter(Boolean),M=x.filter(e=>"lib"===e.type);d.showMessage("Loading lib plugins 1/".concat(M.length,"...")),await A(M.filter(e=>!e.esModule),e=>d.showMessage("Loading lib plugins ".concat(Math.min(e+1,M.length),"/").concat(M.length,"...")));const L=x.filter(e=>"normal"===e.type||!e.type);d.showMessage("Loading normal plugins 1/".concat(L.length,"...")),await A(L.filter(e=>!e.esModule),e=>d.showMessage("Loading normal plugins ".concat(Math.min(e+1,L.length),"/").concat(L.length,"...")));const k=x.filter(e=>e.esModule);if(await A(k.filter(e=>e.esModule),e=>d.showMessage("Loading es plugins ".concat(Math.min(e+1,k.length),"/").concat(k.length,"..."))),f.length>0&&(d.showMessage("Executing plugin entries..."),f.forEach(e=>e.func())),i.length>0&&(d.showMessage("Executing custom loaders ..."),(await Promise.all(i.map(async e=>e.then?await e:await e()))).some(e=>!1===e)))return;let S=a.entry;if(!S){if(1!==h.length)throw 0===h.length?new Error("No app entry found. You need a plugin deployed to the app to provide an app entry."):new Error("Multiple entries found: ".concat(h.map(e=>e.name).join(", "),". You need to specify one entry in app config."));S=h[0].name}const O=h.find(e=>e.name===S);if(!O)throw new Error("The specified app entry was not found: ".concat(S,"."));console.log("Starting the app from ".concat(S,"...")),d.showMessage("Starting the app..."),await O.func(),d.hide()})().then(()=>{const n=Date.now();g.sendToParent({type:"app-state-change",state:"app-loaded"}),console.log("Muse app started in ".concat((n-e)/1e3," seconds."))}).catch(e=>{console.log("Failed to start the app."),o="failure",t=(null===e||void 0===e?void 0:e.message)||"App failed to start.",n.push(e),e&&console.error(e),d.hide(),null!==e&&void 0!==e&&e.message&&c.showMessage(e.message),g.sendToParent({type:"app-state-change",state:"app-failed"})}).finally(()=>{const i=new CustomEvent("muse_boot_completed",{detail:{result:o,metrics:[{name:"app-start-result",payload:{duration:Date.now()-e,status:o,errorMsg:t,url:document.location.href}},{name:"app-start-exceptions",payload:n}]}});window.dispatchEvent(i)})}()})()})();
1
+ (function(){try{if(typeof document<`u`){var e=document.createElement(`style`);e.appendChild(document.createTextNode(`#muse-loading-node{z-index:99999;place-items:center;width:100%;height:100%;transition:opacity .3s ease-out;display:grid;position:fixed;top:0%;left:0;line-height:1.5!important}#muse-loading-node .muse-loading-node-inner{place-items:center;display:grid;position:relative}#muse-loading-node .muse-loading-node-inner>img{width:60px;position:absolute}#muse-loading-node div>label{text-align:center;color:#888;font-family:Helvetica,Arial,sans-serif;font-size:13px;display:block}@keyframes ldio-klconu2768{0%{transform:rotate(0)}50%{transform:rotate(180deg)}to{transform:rotate(360deg)}}.ldio-klconu2768 div{transform-origin:70px 72px;border-radius:50%;width:140px;height:140px;animation:1s linear infinite ldio-klconu2768;position:absolute;top:30px;left:30px;box-shadow:0 4px #00b4d8}.loadingio-spinner-eclipse-p5fn84x4bh8{width:200px;height:200px;display:inline-block;overflow:hidden}.ldio-klconu2768{backface-visibility:hidden;transform-origin:0 0;width:100%;height:100%;position:relative;transform:translateZ(0)scale(1)}.ldio-klconu2768 div{box-sizing:content-box}#muse-error-node{color:red;place-items:center;width:100%;height:100%;font-family:Helvetica,Arial,sans-serif;font-size:14px;line-height:150%;display:grid;position:fixed;top:0;left:0}#muse-error-node .muse-error-node-inner{border:1px solid red;border-radius:3px;min-width:500px;max-width:800px;padding:15px}#muse-error-node h4{margin-top:0;margin-bottom:10px;font-size:16px}#muse-error-node li{padding:3px 0}#muse-error-node p{color:#777;font-size:13px;font-style:italic}#muse-error-node p a{color:#039be5;text-decoration:none}#muse-error-node p a:hover{text-decoration:underline}.muse-theme-dark{background-color:#141414}`)),document.head.appendChild(e)}}catch(e){console.error(`vite-plugin-css-injected-by-js`,e)}})();var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n)),l=o((()=>{})),u=o(((e,t)=>{function n(e){try{let t=/((^@[^/]+\/)?([^@/]+))@(\d+)\.(\d+)\.(\d+)([^./][^/]*)?\/(.+)$/.exec(e);return t?{name:t[1],path:t[8],id:`${t[1]}/${t[8]}`,museId:e,version:t.slice(4,7).map(Number),preRelease:t[7]?.replace(`-`,``)}:null}catch{return null}}t.exports=n})),d=o(((e,t)=>{var n=u();function r(e){e.cache||={},e.modules||={},Object.keys(e.modules).forEach(t=>{let r=n(t);r&&(e.cache[r.id]||(e.cache[r.id]=[]),e.cache[r.id].push(r))})}t.exports=r})),f=o(((e,t)=>{var n=u(),r=d(),i=l(),a=(e,t)=>[0,1,2].map(n=>Math.abs(e[n]-t[n])),o=(e,t)=>{for(let n=0;n<3;n++){if(e[n]<t[n])return!0;if(e[n]>t[n])return!1}return!1},s=(e,t)=>!o(e,t);function c(e,t){if(e=e.replace(/\\/g,`/`).replace(/\/+/g,`/`),t||=MUSE_GLOBAL.__shared__,t.modules[e])return t.modules[e];let c=t.cache;c||=(r(t),t.cache);let l=n(e);if(!l)return null;let u=c[l.id];if(!u)return null;let d=u[0],f=a(l.version,d.version);for(let e=1;e<u.length;e++){let t=u[e];if(l.version.join(`.`)===t.version.join(`.`)){d=t;break}if(s(d.version,l.version)&&o(t.version,l.version))continue;let n=a(t.version,l.version);(o(d.version,l.version)&&s(t.version,l.version)||o(n,f))&&(f=n,d=t)}switch(i.matchVersion){case`major`:if(f[0]!==0)return null;break;case`minor`:if(f[0]!==0||f[1]!==0)return null;break;case`patch`:if(f[0]!==0||f[1]!==0||f[2]!==0)return null;break;case`all`:break;default:break}return t.modules[d.museId]}t.exports=c})),p=o(((e,t)=>{var n=f(),r={};t.exports=e=>{var t=r[e];t||(museModule=t,r[e]=n(e));let i=r[e];if(!i)throw Error(`Muse shared module not found: `+e);return i.__require__(i.id)}})),m=o(((e,t)=>{t.exports=function(){if(typeof self<`u`)return self;if(typeof window<`u`)return window;if(typeof global<`u`)return global;throw Error(`unable to locate global object`)}()})),h=o(((e,t)=>{var n=m(),r=u();function i(e,t){for(let i in e)r(i)&&(e[i],n.MUSE_GLOBAL.__shared__.modules[i]={id:i,__require__:t})}t.exports=i})),g=c(o(((e,t)=>{t.exports={config:l(),require:p(),register:h(),parseMuseId:u(),findMuseModule:f()}}))(),1),_=`/assets/logo-CIFLYZ7b.png`,v={init(){let{app:e,cdn:t}=window.MUSE_GLOBAL,n=document.createElement(`div`);n.innerHTML=`
2
+ <div>
3
+ <div class='muse-loading-node-inner'>
4
+ <div class="loadingio-spinner-eclipse-p5fn84x4bh8"><div class="ldio-klconu2768"><div>
5
+ </div></div></div>
6
+ <img src="${e.iconId?`${t}/p/app-icon.${e.name}/v0.0.${e.iconId}/dist/icon.png`:_}" aria-label="logo" />
7
+ </div>
8
+ <label>Starting...</label>
9
+ </div>
10
+ `,n.id=`muse-loading-node`,(e.config?.theme===`dark`&&!localStorage.getItem(`muse.theme`)||localStorage.getItem(`muse.theme`)&&localStorage.getItem(`muse.theme`)===`dark`)&&document.body.classList.add(`muse-theme-dark`),document.body.appendChild(n),this.mountNode=n,this.labelNode=n.querySelector(`label`)},hide(){this.mountNode&&(setTimeout(()=>{this.mountNode.style.opacity=0},10),setTimeout(()=>{document.body.removeChild(this.mountNode),delete this.mountNode},800),delete this.labelNode)},showMessage(e){this.labelNode&&(this.labelNode.innerHTML=e||``)}},y={errors:[],init(){let e=document.createElement(`div`);e.innerHTML=``,e.id=`muse-error-node`,document.body.appendChild(e),this.mountNode=e},showMessage(e){let t=e?.splice?e:[e];this.errors.push(...t),this.update()},update(){this.mountNode||this.init();let e=this.errors.length===1?`<div>${this.errors[0]}</div>`:`<ul>
11
+ ${this.errors.map(e=>`<li>`+e+`</li>`).join(``)}
12
+ </ul>`;this.mountNode.innerHTML=`
13
+ <div class="muse-error-node-inner">
14
+ <h4>Failed to load:</h4>
15
+ ${e}
16
+ <p>* Unexpected error happened, please refresh to retry or <a href="${window.MUSE_GLOBAL.appConfig?.supportLink||`#`}">contact support</a>.</p>
17
+ </div>
18
+ `}};function b(){let{serviceWorker:e}=window.MUSE_GLOBAL;if(navigator.serviceWorker&&e&&window.location.protocol===`https:`)return v.showMessage(`Registering Muse service worker.`),new Promise(t=>{let n=!1;setTimeout(()=>{n||(console.log(`Failed to register service worker in 10 seconds. Skip it.`),t())},1e4),navigator.serviceWorker.register(e,{}).then(function(){n=!0,console.log(`Service Worker register done.`),t()}).catch(()=>{n=!0,console.log(`Failed to register service worker, skip it.`),t()})})}var x=()=>{};function S(e,t){if(t||=x,e.then&&e.catch){e.then(t);return}if(e.url)return new Promise((n,r)=>{let i=document.querySelector(`head`),a=document.createElement(`script`);a.setAttribute(`crossorigin`,`anonymous`),a.src=e.url,a.type=`module`,i.appendChild(a),a.onload=()=>{t(),n()},a.onerror=()=>{y.showMessage(`Failed to load resource: ${e.url} .`),r()}})}async function C(e,t=x){let n=0;await Promise.all(e.map(async e=>{await S(e),t(++n)}))}function w(e){return e.startsWith(`@`)?e.replace(`/`,`.`):e}var T=()=>Math.random().toString(36).substring(2),E={listeners:{},promises:{},iframes:{},register(e,t){this.iframes[e]=t},unregister(e){delete this.iframes[e]},getIframe(e){return typeof e==`string`?this.iframes[e]:e},init(){this.addListener(`handle-muse-app-check`,(e,t)=>{e?.type===`assert-muse-app`&&t.data?.from?.clientKey===`parent`&&(this.sendToParent({promiseId:t?.data?.promiseId,data:{app:window.MUSE_GLOBAL.app.name,env:window.MUSE_GLOBAL.env.name}}),window.MUSE_GLOBAL.parentApp=t?.data?.from)}),window.addEventListener(`message`,e=>{e?.data?.type===`muse`&&(console.log(`on muse post msg: `,e),e?.data?.payload?.promiseId&&this.resolvePromise(e.data.payload.promiseId,e?.data.payload?.data),Object.entries(this.listeners).forEach(([t,n])=>{try{n(e.data.payload,e)}catch(n){console.log(`Warning: failed to process message "${t}"`,e,n)}}))},!1)},resolve(e,t){},addListener(e,t){this.listeners[e]=t},removeListener(e){delete this.listeners[e]},sendToChild(e,t,n=!1){let r=null,i=null,a=null;n&&(a=T(),r=new Promise((e,t)=>{i=this.promises[a]={resolve:e,reject:t}}));try{this.getIframe(t)?.contentWindow?.postMessage({type:`muse`,promiseId:a,from:{app:window.MUSE_GLOBAL.appName,env:window.MUSE_GLOBAL.envName,clientKey:`parent`},payload:e},`*`)}catch(t){console.log(`Failed to post message to child: `,e),r&&i.reject(t)}return r},sendToParent(e,t=!1){let n=null,r=null,i=null;if(t&&(i=T(),n=new Promise((e,t)=>{r=this.promises[i]={resolve:e,reject:t}})),window.parent&&window.parent!==window)try{window.parent.postMessage({type:`muse`,promiseId:i,from:{app:window.MUSE_GLOBAL.appName,env:window.MUSE_GLOBAL.envName,type:`child`},payload:e},`*`)}catch(t){console.log(`Failed to send message to parent: `,e),n&&r.reject(t)}return n},assertMuseApp(e){return new Promise((t,n)=>{this.sendToChild({type:`assert-muse-app`},this.getIframe(e),!0).then(t),setTimeout(()=>n(Error(`Muse app check timeout.`)),300)})},getParentUrl(){return new Promise((e,t)=>{this.sendToParent({type:`get-parent-url`},!0).then(e),setTimeout(()=>t(Error(`Get parent url timeout.`)),300)})},parentNavigate(e){this.sendToParent({type:`parent-navigate`,url:e})},resolvePromise(e,t){this.promises[e]?.resolve(t),delete this.promises[e]},resolveParent(e,t){E.sendToParent({promiseId:e,data:t})},resolveChild(e,t,n){E.sendToChild({promiseId:e,data:t},n?.source)}};E.addListener(`handle-muse-app-check`,(e,t)=>{e?.type===`assert-muse-app`&&t.data?.from?.clientKey===`parent`&&E.resolveParent(t?.data?.promiseId,{app:window.MUSE_GLOBAL.appName,env:window.MUSE_GLOBAL.envName})}),E.addListener(`parent-navigate`,e=>{e?.type===`parent-navigate`&&e?.url&&(window.location.href=e.url)}),E.addListener(`get-parent-url`,(e,t)=>{e?.type===`get-parent-url`&&(console.log(`get-parent-url: `,window.location.href),E.resolveChild(t?.data?.promiseId,window.location.href,t))});var D=e=>{let t=window.history,n=t[e];t[e]=function(t){let r=n.apply(this,arguments),i=new Event(`muse_boot_`+e.toLowerCase());return i.state=t,window.dispatchEvent(i),r}};D(`pushState`),D(`replaceState`);var O=()=>{E.sendToParent({type:`child-route-change`,path:window.location.href.replace(window.location.origin,``)})};window.addEventListener(`popstate`,O),window.addEventListener(`muse_boot_pushstate`,O),window.addEventListener(`muse_boot_replacestate`,O);async function k(){let e=window.sessionStorage.getItem(`MUSE_TEMP_temp-redirect-url`);if(e){window.sessionStorage.removeItem(`MUSE_TEMP_temp-redirect-url`),window.location=e;return}let t=window.MUSE_GLOBAL;v.showMessage(`Starting...`);let n=t.waitForLoaders||[],r=Object.assign({},t.app?.config);Object.entries(t.env?.config||{}).forEach(([e,t])=>{t!=null&&t!==``&&(r[e]=t)}),Object.assign(t,{appVariables:t.appVariables||{},pluginVariables:t.pluginVariables||{},appConfig:r,msgEngine:E,loading:v,error:y,isSubApp:window.parent!==window,getUser:()=>null,appEntries:t.appEntries||[],initEntries:t.initEntries||[],pluginEntries:t.pluginEntries||[],waitFor:e=>{n.push(e)},getPublicPath:(e,n)=>{if(!n)throw Error(`assetPath is required for getPublicPath method.`);n=n.replace(/^\/*/,``);let r=w(e);if(t.isDev){let i=t.plugins.find(e=>!!e.localPlugins)?.localPlugins;if(i&&i.includes(e))return`/muse-assets/local/p/${r}/${n}`}let i=window.MUSE_GLOBAL.plugins?.find(t=>t.name===e);if(!i)return;let{version:a}=i||{};a.startsWith(`v`)||(a=`v${a}`);let o=`${window.MUSE_GLOBAL.cdn}/p/${r}/${a}`;return window.MUSE_GLOBAL.isDev||window.MUSE_GLOBAL.isLocal?o+=`/dev/${n}`:o+=`/dist/${n}`,o},__shared__:{modules:{},register:g.default.register,require:g.default.require,parseMuseId:g.default.parseMuseId}});let{cdn:i=``,initEntries:a,pluginEntries:o,appEntries:s,isDev:c=!1,isE2eTest:l=!1}=t,{plugins:u=[]}=window.MUSE_GLOBAL;window.MUSE_CONFIG=t,E.sendToParent({type:`app-state-change`,state:`app-starting`}),b();let d=u.find(e=>e.type===`boot`);d&&console.log(`Loading Muse app by ${d.name}@${d.version||d.url}...`);let f=new URLSearchParams(window.location.search).get(`forcePlugins`);if(f){let e=f.split(`;`).filter(Boolean).reduce((e,t)=>{let n=``;t.startsWith(`@`)&&t[0]===`@`&&(t=t.substring(1),n=`@`);let r=t.split(`@`,2);if(r.length===2){let[t,i]=r[0].split(`!`);e[`${n}${t}`]={version:r[1],type:i}}return e},{});u=u.map(t=>{if(!e[t.name])return t;let n={...t,version:e[t.name].version};return delete e[t.name],n}).filter(e=>e.version!==`null`);for(let t in e)e[t].version!==`null`&&u.push({name:t,type:e[t].type,version:e[t].version})}console.log(`Plugins(${u.length}):`),u.forEach(e=>{let t=``;e.linkedTo?t=`Linked to: `+e.linkedTo:e.isLocalLib?t=`Local:`+(/\d{4,}/.exec(e.url)?.[0]||document.location.port):e.url&&(t=e.url),t&&=` (${t})`,console.log(` * ${e.name}@${e.version||`local`}${t}`)}),E.sendToParent({type:`app-state-change`,state:`app-loading`});let p=u.filter(e=>e.type===`init`).map(e=>({url:e.isLocal||e.linkedTo?!1:e.url||`${i}/p/${w(e.name)}/v${e.version}/dist/main.js`,...e})).filter(Boolean);if(p.length>0&&(v.showMessage(`Loading init plugins 1/${p.length}...`),await C(p,e=>v.showMessage(`Loading init plugins ${Math.min(e+1,p.length)}/${p.length}...`))),a.length>0){v.showMessage(`Executing init entries...`),a.sort((e,t)=>(e.order||10)-(t.order||10));for(let e of a)if(await e.func()===!1)return}let m=c?`dev`:l?`test`:`dist`,h={},_=u.filter(e=>e.type!==`boot`&&e.type!==`init`).map(e=>{let t={url:e.isLocal||e.linkedTo?!1:e.url||`${i}/p/${w(e.name)}/v${e.version}/${m}/main.js`,...e};return h[t.url]=!1,t}).filter(Boolean),x=_.filter(e=>e.type===`lib`).sort((e,t)=>t.name.localeCompare(e.name)),S=_.filter(e=>e.type===`normal`||!e.type),T=[...x,...S],D=typeof PerformanceObserver<`u`&&new PerformanceObserver(e=>{let t=Object.keys(h);for(let n of e.getEntries())t.some(e=>n.name.endsWith(e))&&(h[n.name]=!0,v.showMessage(`Loading plugins ${Object.values(h).filter(Boolean).length}/${T.length}...`))});if(D?.observe({type:`resource`,buffered:!0}),v.showMessage(`Loading plugins 1/${T.length}...`),await new Promise((e,n)=>{let r=document.querySelector(`head`),i=document.createElement(`script`);i.setAttribute(`crossorigin`,`anonymous`),i.crossOrigin=`anonymous`,i.type=`module`,t.__onMusePluginsLoaded=e;let a=[],o=new Set,s=Object.fromEntries(x.map(e=>[e.name,e]));function c(e){if(!o.has(e.name)){o.add(e.name);for(let t of e.deps||[])s[t]&&c(s[t]);a.push(e)}}for(let e of x)c(e);i.textContent=[...a,...S].map(e=>`import ${JSON.stringify(e.url)}; // ${e.name}\n`).join(``)+`window.MUSE_GLOBAL.__onMusePluginsLoaded();
19
+ `,r.appendChild(i)}),D?.disconnect(),o.length>0&&(v.showMessage(`Executing plugin entries...`),o.forEach(e=>e.func())),n.length>0&&(v.showMessage(`Executing custom loaders ...`),(await Promise.all(n.map(async e=>e.then?await e:await e()))).some(e=>e===!1)))return;let O=r.entry;if(!O)if(s.length===1)O=s[0].name;else if(s.length===0)throw Error(`No app entry found. You need a plugin deployed to the app to provide an app entry.`);else throw Error(`Multiple entries found: ${s.map(e=>e.name).join(`, `)}. You need to specify one entry in app config.`);let k=s.find(e=>e.name===O);if(k)console.log(`Starting the app from ${O}...`),v.showMessage(`Starting the app...`),await k.func();else throw Error(`The specified app entry was not found: ${O}.`);v.hide()}function A(){if(!window.MUSE_GLOBAL)throw Error(`There must be a global window.MUSE_GLOBAL object`);v.init(),E.init();let e=Date.now(),t=[],n=`success`,r;k().then(()=>{let t=Date.now();E.sendToParent({type:`app-state-change`,state:`app-loaded`}),console.log(`Muse app started in ${(t-e)/1e3} seconds.`)}).catch(e=>{console.log(`Failed to start the app.`),n=`failure`,r=e?.message||`App failed to start.`,t.push(e),e&&console.error(e),v.hide(),e?.message&&y.showMessage(e.message),E.sendToParent({type:`app-state-change`,state:`app-failed`})}).finally(()=>{let i=new CustomEvent(`muse_boot_completed`,{detail:{result:n,metrics:[{name:`app-start-result`,payload:{duration:Date.now()-e,status:n,errorMsg:r,url:document.location.href}},{name:`app-start-exceptions`,payload:t}]}});window.dispatchEvent(i)})}A();
2
20
  //# sourceMappingURL=boot.js.map