@lvetechs/micro-app 1.1.2 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +76 -2
- package/dist/functions/mountMicroApp.d.ts +91 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.js +12 -12
- package/dist/index.mjs +328 -283
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -26,7 +26,43 @@ npm install @lvetechs/micro-app
|
|
|
26
26
|
|
|
27
27
|
## 在 React 项目中使用
|
|
28
28
|
|
|
29
|
-
###
|
|
29
|
+
### 方式一:mountMicroApp(推荐)
|
|
30
|
+
|
|
31
|
+
使用 `mountMicroApp` 简化微应用挂载,自动创建容器:
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
import { mountMicroApp } from '@lvetechs/micro-app'
|
|
35
|
+
import { useEffect, useRef } from 'react'
|
|
36
|
+
|
|
37
|
+
function App() {
|
|
38
|
+
const appRef = useRef<ReturnType<typeof mountMicroApp> | null>(null)
|
|
39
|
+
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
// 创建并挂载微应用
|
|
42
|
+
const result = mountMicroApp({
|
|
43
|
+
app: {
|
|
44
|
+
name: 'my-app',
|
|
45
|
+
entry: 'http://localhost:3001',
|
|
46
|
+
container: 'app-container', // 无需手动创建容器
|
|
47
|
+
},
|
|
48
|
+
onStatusChange: (status) => console.log('状态:', status),
|
|
49
|
+
onError: (error) => console.error('错误:', error),
|
|
50
|
+
onLoad: () => console.log('加载完成'),
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
result.mount()
|
|
54
|
+
appRef.current = result
|
|
55
|
+
|
|
56
|
+
return () => {
|
|
57
|
+
result.destroy()
|
|
58
|
+
}
|
|
59
|
+
}, [])
|
|
60
|
+
|
|
61
|
+
return <div id="app-container" />
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### 方式二:createMicroApp
|
|
30
66
|
|
|
31
67
|
```tsx
|
|
32
68
|
import { createMicroApp } from '@lvetechs/micro-app'
|
|
@@ -231,7 +267,45 @@ function App() {
|
|
|
231
267
|
|
|
232
268
|
## 在 Vue 项目中使用
|
|
233
269
|
|
|
234
|
-
###
|
|
270
|
+
### 方式一:mountMicroApp(推荐)
|
|
271
|
+
|
|
272
|
+
使用 `mountMicroApp` 简化微应用挂载,自动创建容器:
|
|
273
|
+
|
|
274
|
+
```vue
|
|
275
|
+
<script setup lang="ts">
|
|
276
|
+
import { onMounted, onUnmounted, ref } from 'vue'
|
|
277
|
+
import { mountMicroApp } from '@lvetechs/micro-app'
|
|
278
|
+
|
|
279
|
+
const appRef = ref<ReturnType<typeof mountMicroApp> | null>(null)
|
|
280
|
+
|
|
281
|
+
onMounted(() => {
|
|
282
|
+
// 创建并挂载微应用
|
|
283
|
+
const result = mountMicroApp({
|
|
284
|
+
app: {
|
|
285
|
+
name: 'my-app',
|
|
286
|
+
entry: 'http://localhost:3001',
|
|
287
|
+
container: 'app-container', // 无需手动创建容器
|
|
288
|
+
},
|
|
289
|
+
onStatusChange: (status) => console.log('状态:', status),
|
|
290
|
+
onError: (error) => console.error('错误:', error),
|
|
291
|
+
onLoad: () => console.log('加载完成'),
|
|
292
|
+
})
|
|
293
|
+
|
|
294
|
+
result.mount()
|
|
295
|
+
appRef.value = result
|
|
296
|
+
})
|
|
297
|
+
|
|
298
|
+
onUnmounted(() => {
|
|
299
|
+
appRef.value?.destroy()
|
|
300
|
+
})
|
|
301
|
+
</script>
|
|
302
|
+
|
|
303
|
+
<template>
|
|
304
|
+
<div id="app-container" />
|
|
305
|
+
</template>
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
### 方式二:createMicroApp
|
|
235
309
|
|
|
236
310
|
与 React 项目相同,使用 `createMicroApp` 函数:
|
|
237
311
|
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { SubAppConfig, MicroAppStatus, MicroAppService } from '../types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 简化的微应用配置
|
|
5
|
+
*/
|
|
6
|
+
export interface SimpleSubAppConfig {
|
|
7
|
+
/** 应用名称 */
|
|
8
|
+
name: string;
|
|
9
|
+
/** 应用入口 URL */
|
|
10
|
+
entry: string;
|
|
11
|
+
/** 挂载容器选择器 */
|
|
12
|
+
container: string;
|
|
13
|
+
/** 路由规则 */
|
|
14
|
+
activeRule?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* mountMicroApp 配置
|
|
18
|
+
*/
|
|
19
|
+
export interface MountMicroAppOptions {
|
|
20
|
+
/** 子应用配置 */
|
|
21
|
+
app: SimpleSubAppConfig;
|
|
22
|
+
/** 错误回调 */
|
|
23
|
+
onError?: (error: Error) => void;
|
|
24
|
+
/** 状态变化回调 */
|
|
25
|
+
onStatusChange?: (status: MicroAppStatus) => void;
|
|
26
|
+
/** 加载完成回调 */
|
|
27
|
+
onLoad?: () => void;
|
|
28
|
+
/** 加载模式 */
|
|
29
|
+
mode?: 'iframe' | 'dynamic';
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* mountMicroApp 返回值
|
|
33
|
+
*/
|
|
34
|
+
export interface MountResult {
|
|
35
|
+
/** 启动应用 */
|
|
36
|
+
mount: () => void;
|
|
37
|
+
/** 卸载应用 */
|
|
38
|
+
unmount: () => void;
|
|
39
|
+
/** 重新加载 */
|
|
40
|
+
reload: () => void;
|
|
41
|
+
/** 销毁 */
|
|
42
|
+
destroy: () => void;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* 创建并挂载微应用的简化函数
|
|
46
|
+
*
|
|
47
|
+
* @param options 配置项
|
|
48
|
+
* @returns 控制函数
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* // React 使用
|
|
52
|
+
* useEffect(() => {
|
|
53
|
+
* const { mount } = mountMicroApp({
|
|
54
|
+
* app: { name: 'my-app', entry: 'http://localhost:3001', container: '#app' }
|
|
55
|
+
* })
|
|
56
|
+
* mount()
|
|
57
|
+
* return () => destroy()
|
|
58
|
+
* }, [])
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* // Vue 使用
|
|
62
|
+
* onMounted(() => {
|
|
63
|
+
* const { mount } = mountMicroApp({
|
|
64
|
+
* app: { name: 'my-app', entry: 'http://localhost:3001', container: '#app' }
|
|
65
|
+
* })
|
|
66
|
+
* mount()
|
|
67
|
+
* })
|
|
68
|
+
*
|
|
69
|
+
* onUnmounted(() => {
|
|
70
|
+
* result?.destroy()
|
|
71
|
+
* })
|
|
72
|
+
*/
|
|
73
|
+
export declare function mountMicroApp(options: MountMicroAppOptions): MountResult;
|
|
74
|
+
/**
|
|
75
|
+
* 批量挂载多个微应用
|
|
76
|
+
*
|
|
77
|
+
* @param apps 子应用配置数组
|
|
78
|
+
* @param options 全局配置
|
|
79
|
+
* @returns 应用名称到控制函数的映射
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* const apps = mountMicroApps([
|
|
83
|
+
* { name: 'app1', entry: 'http://localhost:3001', container: '#app1' },
|
|
84
|
+
* { name: 'app2', entry: 'http://localhost:3002', container: '#app2' },
|
|
85
|
+
* ])
|
|
86
|
+
*
|
|
87
|
+
* // 启动所有
|
|
88
|
+
* Object.values(apps).forEach(app => app.mount())
|
|
89
|
+
*/
|
|
90
|
+
export declare function mountMicroApps(apps: SimpleSubAppConfig[], options?: Omit<MountMicroAppOptions, 'app'>): Record<string, MountResult>;
|
|
91
|
+
export type { MicroAppService, MicroAppStatus, SubAppConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -8,12 +8,13 @@
|
|
|
8
8
|
* 同时支持 React 和 Vue
|
|
9
9
|
*
|
|
10
10
|
* 使用方式:
|
|
11
|
-
* - React: import { MicroApp, createMicroApp } from '@lvetechs/micro-app'
|
|
12
|
-
* - Vue: import { createMicroApp } from '@lvetechs/micro-app'
|
|
13
|
-
* 并使用 src/components/MicroAppVue.vue 组件
|
|
11
|
+
* - React: import { MicroApp, createMicroApp, mountMicroApp } from '@lvetechs/micro-app'
|
|
12
|
+
* - Vue: import { createMicroApp, mountMicroApp } from '@lvetechs/micro-app'
|
|
14
13
|
*/
|
|
15
14
|
export type { MicroAppStatus, LoadMode, SubAppConfig, MicroAppInfo, MicroAppInstance, MicroAppOptions, MicroAppService, } from './types';
|
|
16
15
|
export { createMicroApp } from './core/MicroAppManager';
|
|
16
|
+
export { mountMicroApp, mountMicroApps } from './functions/mountMicroApp';
|
|
17
|
+
export type { MountMicroAppOptions, MountResult, SimpleSubAppConfig } from './functions/mountMicroApp';
|
|
17
18
|
export { MicroApp } from './components/MicroApp';
|
|
18
19
|
export type { MicroAppProps } from './components/MicroApp';
|
|
19
20
|
export { ErrorBoundary } from './components/ErrorBoundary';
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(L,_){typeof exports=="object"&&typeof module<"u"?_(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],_):(L=typeof globalThis<"u"?globalThis:L||self,_(L.LveMicroApp={},L.React))})(this,function(L,_){"use strict";var
|
|
1
|
+
(function(L,_){typeof exports=="object"&&typeof module<"u"?_(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],_):(L=typeof globalThis<"u"?globalThis:L||self,_(L.LveMicroApp={},L.React))})(this,function(L,_){"use strict";var ea=Object.defineProperty;var ta=(L,_,G)=>_ in L?ea(L,_,{enumerable:!0,configurable:!0,writable:!0,value:G}):L[_]=G;var $=(L,_,G)=>ta(L,typeof _!="symbol"?_+"":_,G);function G(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const h=G(_);class qt{constructor(t,r){$(this,"manager");$(this,"name");this.name=t,this.manager=r}getStatus(){return this.manager.getAppStatus(this.name)}getInfo(){return this.manager.getAppInfo(this.name)}start(){this.manager.startApp(this.name)}stop(){this.manager.stopApp(this.name)}restart(){this.manager.restartApp(this.name)}updateStatus(t,r){this.manager.updateAppStatus(this.name,t,r)}onStatusChange(t){return this.manager.onStatusChange(this.name,t)}async checkHealth(){return this.manager.checkAppHealth(this.name)}}class Kt{constructor(t){$(this,"apps",new Map);$(this,"configMap",new Map);$(this,"instances",new Map);$(this,"statusListeners",new Map);$(this,"appChangeListeners",new Set);$(this,"options");$(this,"initialized",!1);this.options=t,this.initialize()}initialize(){this.initialized&&(console.warn("[MicroApp] 已初始化,重新初始化..."),this.apps.clear(),this.configMap.clear(),this.instances.clear());const t=[...this.options.apps].sort((r,n)=>(n.priority??0)-(r.priority??0));for(const r of t)if(r.enabled!==!1){this.configMap.set(r.name,r);const n=r.container;this.apps.set(r.name,{name:r.name,status:"idle",entry:r.entry,container:n}),this.instances.set(r.name,new qt(r.name,this))}this.initialized=!0,console.log("[MicroApp] 初始化完成",this.getAppNames())}getAppNames(){return Array.from(this.apps.keys())}getApps(){const t={};return this.apps.forEach((r,n)=>{t[n]=r}),t}getApp(t){return this.apps.get(t)}getAppStatus(t){var r;return((r=this.apps.get(t))==null?void 0:r.status)??"idle"}getAppInfo(t){return this.apps.get(t)}getAppInstance(t){return this.instances.get(t)}getAllAppInstances(){return this.instances}startApp(t){const r=this.apps.get(t),n=this.configMap.get(t);if(!r||!n){console.warn(`[MicroApp] 应用 ${t} 不存在`);return}if(r.status==="running"){console.log(`[MicroApp] 应用 ${t} 已在运行中`);return}this.updateAppStatus(t,"starting"),console.log(t,n,r,9999),this.loadApp(t,n,r)}async loadApp(t,r,n){var i,s,c,l,u,p;const o=n.container;if(!o){const f=new Error(`[MicroApp] 应用 ${t} 的容器不存在`);this.updateAppStatus(t,"error",f.message),(s=(i=this.options).onError)==null||s.call(i,f,t);return}try{await this.loadIframe(t,r.entry,o),this.updateAppStatus(t,"running"),(l=(c=this.options).onLoad)==null||l.call(c,t)}catch(f){const m=f instanceof Error?f:new Error(String(f));this.updateAppStatus(t,"error",m.message),(p=(u=this.options).onError)==null||p.call(u,m,t)}}loadIframe(t,r,n){async function o(i){try{const s=await fetch(i,{method:"HEAD",mode:"no-cors"});return!!(s.status===0||s.ok)}catch{}}return new Promise(async(i,s)=>{if(!await o(r))throw new Error(`iframe 加载失败: ${r}`);const l=document.createElement("iframe");l.src=r,l.style.width="100%",l.style.height="100%",l.style.border="none",l.setAttribute("sandbox","allow-scripts allow-forms allow-popups allow-top-navigation");const u=document.querySelector(n);if(!u){s(new Error(`容器不存在: ${n}`));return}u.innerHTML="",u.appendChild(l),l.onload=()=>{console.log(`[MicroApp] ${t} iframe 加载成功`),i()},l.onerror=()=>{s(new Error(`iframe 加载失败: ${r}`))}})}stopApp(t){const r=this.apps.get(t);if(!r){console.warn(`[MicroApp] 应用 ${t} 不存在`);return}if(!(r.status==="stopped"||r.status==="idle")){if(r.container){const n=document.querySelector(r.container);n&&(n.innerHTML="")}this.updateAppStatus(t,"stopped")}}restartApp(t){if(!this.configMap.get(t)){console.warn(`[MicroApp] 应用 ${t} 不存在`);return}this.stopApp(t),setTimeout(()=>{this.startApp(t)},300)}updateAppStatus(t,r,n){var c,l;const o=this.apps.get(t);if(!o)return;const i={...o,status:r,error:n,lastCheckTime:Date.now()};r==="running"&&!o.startTime&&(i.startTime=Date.now()),this.apps.set(t,i);const s=this.statusListeners.get(t);s&&s.forEach(u=>u(r,i)),this.appChangeListeners.forEach(u=>{u(t,r,i)}),(l=(c=this.options).onStatusChange)==null||l.call(c,t,r)}onStatusChange(t,r){return this.statusListeners.has(t)||this.statusListeners.set(t,new Set),this.statusListeners.get(t).add(r),()=>{const n=this.statusListeners.get(t);n&&(n.delete(r),n.size===0&&this.statusListeners.delete(t))}}onAppChange(t){return this.appChangeListeners.add(t),()=>{this.appChangeListeners.delete(t)}}async checkAppHealth(t){const r=this.apps.get(t);if(!r)return!1;try{return await new Promise(n=>setTimeout(n,100)),r.status==="running"?(this.updateAppStatus(t,"running"),!0):!1}catch(n){return this.updateAppStatus(t,"error",n instanceof Error?n.message:"健康检查失败"),!1}}destroy(){this.apps.forEach((t,r)=>{this.stopApp(r)}),this.apps.clear(),this.configMap.clear(),this.instances.clear(),this.statusListeners.clear(),this.appChangeListeners.clear(),this.initialized=!1,console.log("[MicroApp] 已销毁")}}function Oe(e){const t=new Kt(e);return{start:()=>{Object.values(t.getApps()).forEach(n=>{n.status!=="running"&&t.startApp(n.name)})},stop:()=>{const r=t.getApps();Object.keys(r).forEach(n=>{t.stopApp(n)})},startApp:r=>{var n;try{t.startApp(r)}catch(o){(n=e.onError)==null||n.call(e,o instanceof Error?o:new Error(String(o)),r)}},stopApp:r=>{var n;try{t.stopApp(r)}catch(o){(n=e.onError)==null||n.call(e,o instanceof Error?o:new Error(String(o)),r)}},restartApp:r=>{var n;try{t.restartApp(r)}catch(o){(n=e.onError)==null||n.call(e,o instanceof Error?o:new Error(String(o)),r)}},getApp:r=>t.getAppInstance(r)||null,getAllApps:()=>t.getAllAppInstances(),onAppChange:r=>t.onAppChange((n,o)=>{r(n,o)}),onStatusChange:(r,n)=>t.onStatusChange(r,o=>{n(o)}),destroy:()=>{t.destroy()}}}function Je(e){const{app:t,onError:r,onStatusChange:n,onLoad:o}=e,i=t.container.startsWith("#")?t.container:`#${t.container}`;let s=document.querySelector(i);s||(s=document.createElement("div"),s.id=i.replace("#",""),s.className="micro-app-container",document.body.appendChild(s));const c=Oe({apps:[{name:t.name,entry:t.entry,container:i,active_rule:t.activeRule,enabled:!0}],onError:l=>{r==null||r(l)},onStatusChange:(l,u)=>{n==null||n(u)},onLoad:()=>{o==null||o()}});return{mount:()=>{c.startApp(t.name)},unmount:()=>{c.stopApp(t.name)},reload:()=>{c.restartApp(t.name)},destroy:()=>{c.destroy()}}}function Ht(e,t){const r={};for(const n of e)r[n.name]=Je({app:n,...t});return r}var Pe={exports:{}},re={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var
|
|
9
|
+
*/var Ge;function Jt(){if(Ge)return re;Ge=1;var e=_,t=Symbol.for("react.element"),r=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function s(c,l,u){var p,f={},m=null,w=null;u!==void 0&&(m=""+u),l.key!==void 0&&(m=""+l.key),l.ref!==void 0&&(w=l.ref);for(p in l)n.call(l,p)&&!i.hasOwnProperty(p)&&(f[p]=l[p]);if(c&&c.defaultProps)for(p in l=c.defaultProps,l)f[p]===void 0&&(f[p]=l[p]);return{$$typeof:t,type:c,key:m,ref:w,props:f,_owner:o.current}}return re.Fragment=r,re.jsx=s,re.jsxs=s,re}var ne={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,20 +14,20 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var
|
|
18
|
-
|
|
17
|
+
*/var Xe;function Gt(){return Xe||(Xe=1,process.env.NODE_ENV!=="production"&&function(){var e=_,t=Symbol.for("react.element"),r=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),s=Symbol.for("react.provider"),c=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),p=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),w=Symbol.for("react.offscreen"),C=Symbol.iterator,O="@@iterator";function E(a){if(a===null||typeof a!="object")return null;var d=C&&a[C]||a[O];return typeof d=="function"?d:null}var N=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function v(a){{for(var d=arguments.length,g=new Array(d>1?d-1:0),b=1;b<d;b++)g[b-1]=arguments[b];P("error",a,g)}}function P(a,d,g){{var b=N.ReactDebugCurrentFrame,A=b.getStackAddendum();A!==""&&(d+="%s",g=g.concat([A]));var T=g.map(function(S){return String(S)});T.unshift("Warning: "+d),Function.prototype.apply.call(console[a],console,T)}}var j=!1,B=!1,de=!1,we=!1,pe=!1,Re;Re=Symbol.for("react.module.reference");function he(a){return!!(typeof a=="string"||typeof a=="function"||a===n||a===i||pe||a===o||a===u||a===p||we||a===w||j||B||de||typeof a=="object"&&a!==null&&(a.$$typeof===m||a.$$typeof===f||a.$$typeof===s||a.$$typeof===c||a.$$typeof===l||a.$$typeof===Re||a.getModuleId!==void 0))}function Ue(a,d,g){var b=a.displayName;if(b)return b;var A=d.displayName||d.name||"";return A!==""?g+"("+A+")":g}function wt(a){return a.displayName||"Context"}function K(a){if(a==null)return null;if(typeof a.tag=="number"&&v("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof a=="function")return a.displayName||a.name||null;if(typeof a=="string")return a;switch(a){case n:return"Fragment";case r:return"Portal";case i:return"Profiler";case o:return"StrictMode";case u:return"Suspense";case p:return"SuspenseList"}if(typeof a=="object")switch(a.$$typeof){case c:var d=a;return wt(d)+".Consumer";case s:var g=a;return wt(g._context)+".Provider";case l:return Ue(a,a.render,"ForwardRef");case f:var b=a.displayName||null;return b!==null?b:K(a.type)||"Memo";case m:{var A=a,T=A._payload,S=A._init;try{return K(S(T))}catch{return null}}}return null}var H=Object.assign,me=0,Rt,Ct,St,Nt,_t,Ot,Pt;function At(){}At.__reactDisabledLog=!0;function _n(){{if(me===0){Rt=console.log,Ct=console.info,St=console.warn,Nt=console.error,_t=console.group,Ot=console.groupCollapsed,Pt=console.groupEnd;var a={configurable:!0,enumerable:!0,value:At,writable:!0};Object.defineProperties(console,{info:a,log:a,warn:a,error:a,group:a,groupCollapsed:a,groupEnd:a})}me++}}function On(){{if(me--,me===0){var a={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:H({},a,{value:Rt}),info:H({},a,{value:Ct}),warn:H({},a,{value:St}),error:H({},a,{value:Nt}),group:H({},a,{value:_t}),groupCollapsed:H({},a,{value:Ot}),groupEnd:H({},a,{value:Pt})})}me<0&&v("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var $e=N.ReactCurrentDispatcher,Be;function Ce(a,d,g){{if(Be===void 0)try{throw Error()}catch(A){var b=A.stack.trim().match(/\n( *(at )?)/);Be=b&&b[1]||""}return`
|
|
18
|
+
`+Be+a}}var We=!1,Se;{var Pn=typeof WeakMap=="function"?WeakMap:Map;Se=new Pn}function Tt(a,d){if(!a||We)return"";{var g=Se.get(a);if(g!==void 0)return g}var b;We=!0;var A=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var T;T=$e.current,$e.current=null,_n();try{if(d){var S=function(){throw Error()};if(Object.defineProperty(S.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(S,[])}catch(I){b=I}Reflect.construct(a,[],S)}else{try{S.call()}catch(I){b=I}a.call(S.prototype)}}else{try{throw Error()}catch(I){b=I}a()}}catch(I){if(I&&b&&typeof I.stack=="string"){for(var R=I.stack.split(`
|
|
19
19
|
`),F=b.stack.split(`
|
|
20
20
|
`),D=R.length-1,k=F.length-1;D>=1&&k>=0&&R[D]!==F[k];)k--;for(;D>=1&&k>=0;D--,k--)if(R[D]!==F[k]){if(D!==1||k!==1)do if(D--,k--,k<0||R[D]!==F[k]){var M=`
|
|
21
|
-
`+R[D].replace(" at new "," at ");return a.displayName&&M.includes("<anonymous>")&&(M=M.replace("<anonymous>",a.displayName)),typeof a=="function"&&Se.set(a,M),M}while(D>=1&&k>=0);break}}}finally{
|
|
21
|
+
`+R[D].replace(" at new "," at ");return a.displayName&&M.includes("<anonymous>")&&(M=M.replace("<anonymous>",a.displayName)),typeof a=="function"&&Se.set(a,M),M}while(D>=1&&k>=0);break}}}finally{We=!1,$e.current=T,On(),Error.prepareStackTrace=A}var te=a?a.displayName||a.name:"",J=te?Ce(te):"";return typeof a=="function"&&Se.set(a,J),J}function An(a,d,g){return Tt(a,!1)}function Tn(a){var d=a.prototype;return!!(d&&d.isReactComponent)}function Ne(a,d,g){if(a==null)return"";if(typeof a=="function")return Tt(a,Tn(a));if(typeof a=="string")return Ce(a);switch(a){case u:return Ce("Suspense");case p:return Ce("SuspenseList")}if(typeof a=="object")switch(a.$$typeof){case l:return An(a.render);case f:return Ne(a.type,d,g);case m:{var b=a,A=b._payload,T=b._init;try{return Ne(T(A),d,g)}catch{}}}return""}var ve=Object.prototype.hasOwnProperty,jt={},Dt=N.ReactDebugCurrentFrame;function _e(a){if(a){var d=a._owner,g=Ne(a.type,a._source,d?d.type:null);Dt.setExtraStackFrame(g)}else Dt.setExtraStackFrame(null)}function jn(a,d,g,b,A){{var T=Function.call.bind(ve);for(var S in a)if(T(a,S)){var R=void 0;try{if(typeof a[S]!="function"){var F=Error((b||"React class")+": "+g+" type `"+S+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof a[S]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw F.name="Invariant Violation",F}R=a[S](d,S,b,g,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(D){R=D}R&&!(R instanceof Error)&&(_e(A),v("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",b||"React class",g,S,typeof R),_e(null)),R instanceof Error&&!(R.message in jt)&&(jt[R.message]=!0,_e(A),v("Failed %s type: %s",g,R.message),_e(null))}}}var Dn=Array.isArray;function Ye(a){return Dn(a)}function kn(a){{var d=typeof Symbol=="function"&&Symbol.toStringTag,g=d&&a[Symbol.toStringTag]||a.constructor.name||"Object";return g}}function Ln(a){try{return kt(a),!1}catch{return!0}}function kt(a){return""+a}function Lt(a){if(Ln(a))return v("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",kn(a)),kt(a)}var Ft=N.ReactCurrentOwner,Fn={key:!0,ref:!0,__self:!0,__source:!0},It,Mt;function In(a){if(ve.call(a,"ref")){var d=Object.getOwnPropertyDescriptor(a,"ref").get;if(d&&d.isReactWarning)return!1}return a.ref!==void 0}function Mn(a){if(ve.call(a,"key")){var d=Object.getOwnPropertyDescriptor(a,"key").get;if(d&&d.isReactWarning)return!1}return a.key!==void 0}function Vn(a,d){typeof a.ref=="string"&&Ft.current}function Un(a,d){{var g=function(){It||(It=!0,v("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",d))};g.isReactWarning=!0,Object.defineProperty(a,"key",{get:g,configurable:!0})}}function $n(a,d){{var g=function(){Mt||(Mt=!0,v("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",d))};g.isReactWarning=!0,Object.defineProperty(a,"ref",{get:g,configurable:!0})}}var Bn=function(a,d,g,b,A,T,S){var R={$$typeof:t,type:a,key:d,ref:g,props:S,_owner:T};return R._store={},Object.defineProperty(R._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(R,"_self",{configurable:!1,enumerable:!1,writable:!1,value:b}),Object.defineProperty(R,"_source",{configurable:!1,enumerable:!1,writable:!1,value:A}),Object.freeze&&(Object.freeze(R.props),Object.freeze(R)),R};function Wn(a,d,g,b,A){{var T,S={},R=null,F=null;g!==void 0&&(Lt(g),R=""+g),Mn(d)&&(Lt(d.key),R=""+d.key),In(d)&&(F=d.ref,Vn(d,A));for(T in d)ve.call(d,T)&&!Fn.hasOwnProperty(T)&&(S[T]=d[T]);if(a&&a.defaultProps){var D=a.defaultProps;for(T in D)S[T]===void 0&&(S[T]=D[T])}if(R||F){var k=typeof a=="function"?a.displayName||a.name||"Unknown":a;R&&Un(S,k),F&&$n(S,k)}return Bn(a,R,F,A,b,Ft.current,S)}}var ze=N.ReactCurrentOwner,Vt=N.ReactDebugCurrentFrame;function ee(a){if(a){var d=a._owner,g=Ne(a.type,a._source,d?d.type:null);Vt.setExtraStackFrame(g)}else Vt.setExtraStackFrame(null)}var qe;qe=!1;function Ke(a){return typeof a=="object"&&a!==null&&a.$$typeof===t}function Ut(){{if(ze.current){var a=K(ze.current.type);if(a)return`
|
|
22
22
|
|
|
23
|
-
Check the render method of \``+a+"`."}return""}}function
|
|
23
|
+
Check the render method of \``+a+"`."}return""}}function Yn(a){return""}var $t={};function zn(a){{var d=Ut();if(!d){var g=typeof a=="string"?a:a.displayName||a.name;g&&(d=`
|
|
24
24
|
|
|
25
|
-
Check the top-level render call using <`+g+">.")}return d}}function
|
|
25
|
+
Check the top-level render call using <`+g+">.")}return d}}function Bt(a,d){{if(!a._store||a._store.validated||a.key!=null)return;a._store.validated=!0;var g=zn(d);if($t[g])return;$t[g]=!0;var b="";a&&a._owner&&a._owner!==ze.current&&(b=" It was passed a child from "+K(a._owner.type)+"."),ee(a),v('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',g,b),ee(null)}}function Wt(a,d){{if(typeof a!="object")return;if(Ye(a))for(var g=0;g<a.length;g++){var b=a[g];Ke(b)&&Bt(b,d)}else if(Ke(a))a._store&&(a._store.validated=!0);else if(a){var A=E(a);if(typeof A=="function"&&A!==a.entries)for(var T=A.call(a),S;!(S=T.next()).done;)Ke(S.value)&&Bt(S.value,d)}}}function qn(a){{var d=a.type;if(d==null||typeof d=="string")return;var g;if(typeof d=="function")g=d.propTypes;else if(typeof d=="object"&&(d.$$typeof===l||d.$$typeof===f))g=d.propTypes;else return;if(g){var b=K(d);jn(g,a.props,"prop",b,a)}else if(d.PropTypes!==void 0&&!qe){qe=!0;var A=K(d);v("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",A||"Unknown")}typeof d.getDefaultProps=="function"&&!d.getDefaultProps.isReactClassApproved&&v("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Kn(a){{for(var d=Object.keys(a.props),g=0;g<d.length;g++){var b=d[g];if(b!=="children"&&b!=="key"){ee(a),v("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",b),ee(null);break}}a.ref!==null&&(ee(a),v("Invalid attribute `ref` supplied to `React.Fragment`."),ee(null))}}var Yt={};function zt(a,d,g,b,A,T){{var S=he(a);if(!S){var R="";(a===void 0||typeof a=="object"&&a!==null&&Object.keys(a).length===0)&&(R+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var F=Yn();F?R+=F:R+=Ut();var D;a===null?D="null":Ye(a)?D="array":a!==void 0&&a.$$typeof===t?(D="<"+(K(a.type)||"Unknown")+" />",R=" Did you accidentally export a JSX literal instead of a component?"):D=typeof a,v("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",D,R)}var k=Wn(a,d,g,A,T);if(k==null)return k;if(S){var M=d.children;if(M!==void 0)if(b)if(Ye(M)){for(var te=0;te<M.length;te++)Wt(M[te],a);Object.freeze&&Object.freeze(M)}else v("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Wt(M,a)}if(ve.call(d,"key")){var J=K(a),I=Object.keys(d).filter(function(Qn){return Qn!=="key"}),He=I.length>0?"{key: someKey, "+I.join(": ..., ")+": ...}":"{key: someKey}";if(!Yt[J+He]){var Zn=I.length>0?"{"+I.join(": ..., ")+": ...}":"{}";v(`A props object containing a "key" prop is being spread into JSX:
|
|
26
26
|
let props = %s;
|
|
27
27
|
<%s {...props} />
|
|
28
28
|
React keys must be passed directly to JSX without using spread:
|
|
29
29
|
let props = %s;
|
|
30
|
-
<%s key={someKey} {...props} />`,
|
|
30
|
+
<%s key={someKey} {...props} />`,He,J,Zn,J),Yt[J+He]=!0}}return a===n?Kn(k):qn(k),k}}function Hn(a,d,g){return zt(a,d,g,!0)}function Jn(a,d,g){return zt(a,d,g,!1)}var Gn=Jn,Xn=Hn;ne.Fragment=n,ne.jsx=Gn,ne.jsxs=Xn}()),ne}process.env.NODE_ENV==="production"?Pe.exports=Jt():Pe.exports=Gt();var y=Pe.exports;/**
|
|
31
31
|
* @remix-run/router v1.23.2
|
|
32
32
|
*
|
|
33
33
|
* Copyright (c) Remix Software Inc.
|
|
@@ -36,7 +36,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
36
36
|
* LICENSE.md file in the root directory of this source tree.
|
|
37
37
|
*
|
|
38
38
|
* @license MIT
|
|
39
|
-
*/function ae(){return ae=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},ae.apply(this,arguments)}var z;(function(e){e.Pop="POP",e.Push="PUSH",e.Replace="REPLACE"})(z||(z={}));const
|
|
39
|
+
*/function ae(){return ae=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},ae.apply(this,arguments)}var z;(function(e){e.Pop="POP",e.Push="PUSH",e.Replace="REPLACE"})(z||(z={}));const Ze="popstate";function Xt(e){e===void 0&&(e={});function t(n,o){let{pathname:i,search:s,hash:c}=n.location;return Ae("",{pathname:i,search:s,hash:c},o.state&&o.state.usr||null,o.state&&o.state.key||"default")}function r(n,o){return typeof o=="string"?o:oe(o)}return Qt(t,r,null,e)}function x(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function V(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function Zt(){return Math.random().toString(36).substr(2,8)}function Qe(e,t){return{usr:e.state,key:e.key,idx:t}}function Ae(e,t,r,n){return r===void 0&&(r=null),ae({pathname:typeof e=="string"?e:e.pathname,search:"",hash:""},typeof t=="string"?X(t):t,{state:r,key:t&&t.key||n||Zt()})}function oe(e){let{pathname:t="/",search:r="",hash:n=""}=e;return r&&r!=="?"&&(t+=r.charAt(0)==="?"?r:"?"+r),n&&n!=="#"&&(t+=n.charAt(0)==="#"?n:"#"+n),t}function X(e){let t={};if(e){let r=e.indexOf("#");r>=0&&(t.hash=e.substr(r),e=e.substr(0,r));let n=e.indexOf("?");n>=0&&(t.search=e.substr(n),e=e.substr(0,n)),e&&(t.pathname=e)}return t}function Qt(e,t,r,n){n===void 0&&(n={});let{window:o=document.defaultView,v5Compat:i=!1}=n,s=o.history,c=z.Pop,l=null,u=p();u==null&&(u=0,s.replaceState(ae({},s.state,{idx:u}),""));function p(){return(s.state||{idx:null}).idx}function f(){c=z.Pop;let E=p(),N=E==null?null:E-u;u=E,l&&l({action:c,location:O.location,delta:N})}function m(E,N){c=z.Push;let v=Ae(O.location,E,N);u=p()+1;let P=Qe(v,u),j=O.createHref(v);try{s.pushState(P,"",j)}catch(B){if(B instanceof DOMException&&B.name==="DataCloneError")throw B;o.location.assign(j)}i&&l&&l({action:c,location:O.location,delta:1})}function w(E,N){c=z.Replace;let v=Ae(O.location,E,N);u=p();let P=Qe(v,u),j=O.createHref(v);s.replaceState(P,"",j),i&&l&&l({action:c,location:O.location,delta:0})}function C(E){let N=o.location.origin!=="null"?o.location.origin:o.location.href,v=typeof E=="string"?E:oe(E);return v=v.replace(/ $/,"%20"),x(N,"No window.location.(origin|href) available to create URL for href: "+v),new URL(v,N)}let O={get action(){return c},get location(){return e(o,s)},listen(E){if(l)throw new Error("A history only accepts one active listener");return o.addEventListener(Ze,f),l=E,()=>{o.removeEventListener(Ze,f),l=null}},createHref(E){return t(o,E)},createURL:C,encodeLocation(E){let N=C(E);return{pathname:N.pathname,search:N.search,hash:N.hash}},push:m,replace:w,go(E){return s.go(E)}};return O}var et;(function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"})(et||(et={}));function er(e,t,r){return r===void 0&&(r="/"),tr(e,t,r)}function tr(e,t,r,n){let o=typeof t=="string"?X(t):t,i=q(o.pathname||"/",r);if(i==null)return null;let s=tt(e);rr(s);let c=null;for(let l=0;c==null&&l<s.length;++l){let u=pr(i);c=fr(s[l],u)}return c}function tt(e,t,r,n){t===void 0&&(t=[]),r===void 0&&(r=[]),n===void 0&&(n="");let o=(i,s,c)=>{let l={relativePath:c===void 0?i.path||"":c,caseSensitive:i.caseSensitive===!0,childrenIndex:s,route:i};l.relativePath.startsWith("/")&&(x(l.relativePath.startsWith(n),'Absolute route path "'+l.relativePath+'" nested under path '+('"'+n+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),l.relativePath=l.relativePath.slice(n.length));let u=W([n,l.relativePath]),p=r.concat(l);i.children&&i.children.length>0&&(x(i.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+u+'".')),tt(i.children,t,p,u)),!(i.path==null&&!i.index)&&t.push({path:u,score:ur(u,i.index),routesMeta:p})};return e.forEach((i,s)=>{var c;if(i.path===""||!((c=i.path)!=null&&c.includes("?")))o(i,s);else for(let l of rt(i.path))o(i,s,l)}),t}function rt(e){let t=e.split("/");if(t.length===0)return[];let[r,...n]=t,o=r.endsWith("?"),i=r.replace(/\?$/,"");if(n.length===0)return o?[i,""]:[i];let s=rt(n.join("/")),c=[];return c.push(...s.map(l=>l===""?i:[i,l].join("/"))),o&&c.push(...s),c.map(l=>e.startsWith("/")&&l===""?"/":l)}function rr(e){e.sort((t,r)=>t.score!==r.score?r.score-t.score:cr(t.routesMeta.map(n=>n.childrenIndex),r.routesMeta.map(n=>n.childrenIndex)))}const nr=/^:[\w-]+$/,ar=3,or=2,ir=1,sr=10,lr=-2,nt=e=>e==="*";function ur(e,t){let r=e.split("/"),n=r.length;return r.some(nt)&&(n+=lr),t&&(n+=or),r.filter(o=>!nt(o)).reduce((o,i)=>o+(nr.test(i)?ar:i===""?ir:sr),n)}function cr(e,t){return e.length===t.length&&e.slice(0,-1).every((n,o)=>n===t[o])?e[e.length-1]-t[t.length-1]:0}function fr(e,t,r){let{routesMeta:n}=e,o={},i="/",s=[];for(let c=0;c<n.length;++c){let l=n[c],u=c===n.length-1,p=i==="/"?t:t.slice(i.length)||"/",f=Te({path:l.relativePath,caseSensitive:l.caseSensitive,end:u},p),m=l.route;if(!f)return null;Object.assign(o,f.params),s.push({params:o,pathname:W([i,f.pathname]),pathnameBase:yr(W([i,f.pathnameBase])),route:m}),f.pathnameBase!=="/"&&(i=W([i,f.pathnameBase]))}return s}function Te(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[r,n]=dr(e.path,e.caseSensitive,e.end),o=t.match(r);if(!o)return null;let i=o[0],s=i.replace(/(.)\/+$/,"$1"),c=o.slice(1);return{params:n.reduce((u,p,f)=>{let{paramName:m,isOptional:w}=p;if(m==="*"){let O=c[f]||"";s=i.slice(0,i.length-O.length).replace(/(.)\/+$/,"$1")}const C=c[f];return w&&!C?u[m]=void 0:u[m]=(C||"").replace(/%2F/g,"/"),u},{}),pathname:i,pathnameBase:s,pattern:e}}function dr(e,t,r){t===void 0&&(t=!1),r===void 0&&(r=!0),V(e==="*"||!e.endsWith("*")||e.endsWith("/*"),'Route path "'+e+'" will be treated as if it were '+('"'+e.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+e.replace(/\*$/,"/*")+'".'));let n=[],o="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(s,c,l)=>(n.push({paramName:c,isOptional:l!=null}),l?"/?([^\\/]+)?":"/([^\\/]+)"));return e.endsWith("*")?(n.push({paramName:"*"}),o+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):r?o+="\\/*$":e!==""&&e!=="/"&&(o+="(?:(?=\\/|$))"),[new RegExp(o,t?void 0:"i"),n]}function pr(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return V(!1,'The URL path "'+e+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+t+").")),e}}function q(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let r=t.endsWith("/")?t.length-1:t.length,n=e.charAt(r);return n&&n!=="/"?null:e.slice(r)||"/"}const hr=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,mr=e=>hr.test(e);function vr(e,t){t===void 0&&(t="/");let{pathname:r,search:n="",hash:o=""}=typeof e=="string"?X(e):e,i;if(r)if(mr(r))i=r;else{if(r.includes("//")){let s=r;r=r.replace(/\/\/+/g,"/"),V(!1,"Pathnames cannot have embedded double slashes - normalizing "+(s+" -> "+r))}r.startsWith("/")?i=at(r.substring(1),"/"):i=at(r,t)}else i=t;return{pathname:i,search:Er(n),hash:br(o)}}function at(e,t){let r=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(o=>{o===".."?r.length>1&&r.pop():o!=="."&&r.push(o)}),r.length>1?r.join("/"):"/"}function je(e,t,r,n){return"Cannot include a '"+e+"' character in a manually specified "+("`to."+t+"` field ["+JSON.stringify(n)+"]. Please separate it out to the ")+("`to."+r+"` field. Alternatively you may provide the full path as ")+'a string in <Link to="..."> and the router will parse it for you.'}function gr(e){return e.filter((t,r)=>r===0||t.route.path&&t.route.path.length>0)}function ot(e,t){let r=gr(e);return t?r.map((n,o)=>o===r.length-1?n.pathname:n.pathnameBase):r.map(n=>n.pathnameBase)}function it(e,t,r,n){n===void 0&&(n=!1);let o;typeof e=="string"?o=X(e):(o=ae({},e),x(!o.pathname||!o.pathname.includes("?"),je("?","pathname","search",o)),x(!o.pathname||!o.pathname.includes("#"),je("#","pathname","hash",o)),x(!o.search||!o.search.includes("#"),je("#","search","hash",o)));let i=e===""||o.pathname==="",s=i?"/":o.pathname,c;if(s==null)c=r;else{let f=t.length-1;if(!n&&s.startsWith("..")){let m=s.split("/");for(;m[0]==="..";)m.shift(),f-=1;o.pathname=m.join("/")}c=f>=0?t[f]:"/"}let l=vr(o,c),u=s&&s!=="/"&&s.endsWith("/"),p=(i||s===".")&&r.endsWith("/");return!l.pathname.endsWith("/")&&(u||p)&&(l.pathname+="/"),l}const W=e=>e.join("/").replace(/\/\/+/g,"/"),yr=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),Er=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,br=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function xr(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}const st=["post","put","patch","delete"];new Set(st);const wr=["get",...st];new Set(wr);/**
|
|
40
40
|
* React Router v6.30.3
|
|
41
41
|
*
|
|
42
42
|
* Copyright (c) Remix Software Inc.
|
|
@@ -45,9 +45,9 @@ React keys must be passed directly to JSX without using spread:
|
|
|
45
45
|
* LICENSE.md file in the root directory of this source tree.
|
|
46
46
|
*
|
|
47
47
|
* @license MIT
|
|
48
|
-
*/function ie(){return ie=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},ie.apply(this,arguments)}const se=h.createContext(null);process.env.NODE_ENV!=="production"&&(se.displayName="DataRouter");const
|
|
48
|
+
*/function ie(){return ie=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},ie.apply(this,arguments)}const se=h.createContext(null);process.env.NODE_ENV!=="production"&&(se.displayName="DataRouter");const De=h.createContext(null);process.env.NODE_ENV!=="production"&&(De.displayName="DataRouterState");const Rr=h.createContext(null);process.env.NODE_ENV!=="production"&&(Rr.displayName="Await");const U=h.createContext(null);process.env.NODE_ENV!=="production"&&(U.displayName="Navigation");const le=h.createContext(null);process.env.NODE_ENV!=="production"&&(le.displayName="Location");const Y=h.createContext({outlet:null,matches:[],isDataRoute:!1});process.env.NODE_ENV!=="production"&&(Y.displayName="Route");const ke=h.createContext(null);process.env.NODE_ENV!=="production"&&(ke.displayName="RouteError");function Cr(e,t){let{relative:r}=t===void 0?{}:t;ue()||(process.env.NODE_ENV!=="production"?x(!1,"useHref() may be used only in the context of a <Router> component."):x(!1));let{basename:n,navigator:o}=h.useContext(U),{hash:i,pathname:s,search:c}=ce(e,{relative:r}),l=s;return n!=="/"&&(l=s==="/"?n:W([n,s])),o.createHref({pathname:l,search:c,hash:i})}function ue(){return h.useContext(le)!=null}function Z(){return ue()||(process.env.NODE_ENV!=="production"?x(!1,"useLocation() may be used only in the context of a <Router> component."):x(!1)),h.useContext(le).location}const lt="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function ut(e){h.useContext(U).static||h.useLayoutEffect(e)}function ct(){let{isDataRoute:e}=h.useContext(Y);return e?Mr():Sr()}function Sr(){ue()||(process.env.NODE_ENV!=="production"?x(!1,"useNavigate() may be used only in the context of a <Router> component."):x(!1));let e=h.useContext(se),{basename:t,future:r,navigator:n}=h.useContext(U),{matches:o}=h.useContext(Y),{pathname:i}=Z(),s=JSON.stringify(ot(o,r.v7_relativeSplatPath)),c=h.useRef(!1);return ut(()=>{c.current=!0}),h.useCallback(function(u,p){if(p===void 0&&(p={}),process.env.NODE_ENV!=="production"&&V(c.current,lt),!c.current)return;if(typeof u=="number"){n.go(u);return}let f=it(u,JSON.parse(s),i,p.relative==="path");e==null&&t!=="/"&&(f.pathname=f.pathname==="/"?t:W([t,f.pathname])),(p.replace?n.replace:n.push)(f,p.state,p)},[t,n,s,i,e])}function ce(e,t){let{relative:r}=t===void 0?{}:t,{future:n}=h.useContext(U),{matches:o}=h.useContext(Y),{pathname:i}=Z(),s=JSON.stringify(ot(o,n.v7_relativeSplatPath));return h.useMemo(()=>it(e,JSON.parse(s),i,r==="path"),[e,s,i,r])}function Nr(e,t){return _r(e,t)}function _r(e,t,r,n){ue()||(process.env.NODE_ENV!=="production"?x(!1,"useRoutes() may be used only in the context of a <Router> component."):x(!1));let{navigator:o}=h.useContext(U),{matches:i}=h.useContext(Y),s=i[i.length-1],c=s?s.params:{},l=s?s.pathname:"/",u=s?s.pathnameBase:"/",p=s&&s.route;if(process.env.NODE_ENV!=="production"){let v=p&&p.path||"";pt(l,!p||v.endsWith("*"),"You rendered descendant <Routes> (or called `useRoutes()`) at "+('"'+l+'" (under <Route path="'+v+'">) but the ')+`parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
|
|
49
49
|
|
|
50
|
-
`+('Please change the parent <Route path="'+v+'"> to <Route ')+('path="'+(v==="/"?"*":v+"/*")+'">.'))}let f=Z(),m;if(t){var w;let v=typeof t=="string"?X(t):t;u==="/"||(w=v.pathname)!=null&&w.startsWith(u)||(process.env.NODE_ENV!=="production"?x(!1,"When overriding the location using `<Routes location>` or `useRoutes(routes, location)`, the location pathname must begin with the portion of the URL pathname that was "+('matched by all parent routes. The current pathname base is "'+u+'" ')+('but pathname "'+v.pathname+'" was given in the `location` prop.')):x(!1)),m=v}else m=f;let C=m.pathname||"/",O=C;if(u!=="/"){let v=u.replace(/^\//,"").split("/");O="/"+C.replace(/^\//,"").split("/").slice(v.length).join("/")}let E=Zt(e,{pathname:O});process.env.NODE_ENV!=="production"&&(process.env.NODE_ENV!=="production"&&V(p||E!=null,'No routes matched location "'+m.pathname+m.search+m.hash+'" '),process.env.NODE_ENV!=="production"&&V(E==null||E[E.length-1].route.element!==void 0||E[E.length-1].route.Component!==void 0||E[E.length-1].route.lazy!==void 0,'Matched leaf route at location "'+m.pathname+m.search+m.hash+'" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.'));let N=Tr(E&&E.map(v=>Object.assign({},v,{params:Object.assign({},c,v.params),pathname:W([u,o.encodeLocation?o.encodeLocation(v.pathname).pathname:v.pathname]),pathnameBase:v.pathnameBase==="/"?u:W([u,o.encodeLocation?o.encodeLocation(v.pathnameBase).pathname:v.pathnameBase])})),i,r,n);return t&&N?h.createElement(le.Provider,{value:{location:ie({pathname:"/",search:"",hash:"",state:null,key:"default"},m),navigationType:z.Pop}},N):N}function Nr(){let e=Lr(),t=Er(e)?e.status+" "+e.statusText:e instanceof Error?e.message:JSON.stringify(e),r=e instanceof Error?e.stack:null,n="rgba(200,200,200, 0.5)",o={padding:"0.5rem",backgroundColor:n},i={padding:"2px 4px",backgroundColor:n},s=null;return process.env.NODE_ENV!=="production"&&(console.error("Error handled by React Router default ErrorBoundary:",e),s=h.createElement(h.Fragment,null,h.createElement("p",null,"💿 Hey developer 👋"),h.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",h.createElement("code",{style:i},"ErrorBoundary")," or"," ",h.createElement("code",{style:i},"errorElement")," prop on your route."))),h.createElement(h.Fragment,null,h.createElement("h2",null,"Unexpected Application Error!"),h.createElement("h3",{style:{fontStyle:"italic"}},t),r?h.createElement("pre",{style:o},r):null,s)}const _r=h.createElement(Nr,null);class Or extends h.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,r){return r.location!==t.location||r.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:r.error,location:r.location,revalidation:t.revalidation||r.revalidation}}componentDidCatch(t,r){console.error("React Router caught the following error during render",t,r)}render(){return this.state.error!==void 0?h.createElement(Y.Provider,{value:this.props.routeContext},h.createElement(De.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function Pr(e){let{routeContext:t,match:r,children:n}=e,o=h.useContext(se);return o&&o.static&&o.staticContext&&(r.route.errorElement||r.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=r.route.id),h.createElement(Y.Provider,{value:t},n)}function Tr(e,t,r,n){var o;if(t===void 0&&(t=[]),r===void 0&&(r=null),n===void 0&&(n=null),e==null){var i;if(!r)return null;if(r.errors)e=r.matches;else if((i=n)!=null&&i.v7_partialHydration&&t.length===0&&!r.initialized&&r.matches.length>0)e=r.matches;else return null}let s=e,c=(o=r)==null?void 0:o.errors;if(c!=null){let p=s.findIndex(f=>f.route.id&&(c==null?void 0:c[f.route.id])!==void 0);p>=0||(process.env.NODE_ENV!=="production"?x(!1,"Could not find a matching route for errors on route IDs: "+Object.keys(c).join(",")):x(!1)),s=s.slice(0,Math.min(s.length,p+1))}let l=!1,u=-1;if(r&&n&&n.v7_partialHydration)for(let p=0;p<s.length;p++){let f=s[p];if((f.route.HydrateFallback||f.route.hydrateFallbackElement)&&(u=p),f.route.id){let{loaderData:m,errors:w}=r,C=f.route.loader&&m[f.route.id]===void 0&&(!w||w[f.route.id]===void 0);if(f.route.lazy||C){l=!0,u>=0?s=s.slice(0,u+1):s=[s[0]];break}}}return s.reduceRight((p,f,m)=>{let w,C=!1,O=null,E=null;r&&(w=c&&f.route.id?c[f.route.id]:void 0,O=f.route.errorElement||_r,l&&(u<0&&m===0?(dt("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),C=!0,E=null):u===m&&(C=!0,E=f.route.hydrateFallbackElement||null)));let N=t.concat(s.slice(0,m+1)),v=()=>{let P;return w?P=O:C?P=E:f.route.Component?P=h.createElement(f.route.Component,null):f.route.element?P=f.route.element:P=p,h.createElement(Pr,{match:f,routeContext:{outlet:p,matches:N,isDataRoute:r!=null},children:P})};return r&&(f.route.ErrorBoundary||f.route.errorElement||m===0)?h.createElement(Or,{location:r.location,revalidation:r.revalidation,component:O,error:w,children:v(),routeContext:{outlet:null,matches:N,isDataRoute:!0}}):v()},null)}var ct=function(e){return e.UseBlocker="useBlocker",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e}(ct||{}),fe=function(e){return e.UseBlocker="useBlocker",e.UseLoaderData="useLoaderData",e.UseActionData="useActionData",e.UseRouteError="useRouteError",e.UseNavigation="useNavigation",e.UseRouteLoaderData="useRouteLoaderData",e.UseMatches="useMatches",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e.UseRouteId="useRouteId",e}(fe||{});function ke(e){return e+" must be used within a data router. See https://reactrouter.com/v6/routers/picking-a-router."}function Ar(e){let t=h.useContext(se);return t||(process.env.NODE_ENV!=="production"?x(!1,ke(e)):x(!1)),t}function jr(e){let t=h.useContext(je);return t||(process.env.NODE_ENV!=="production"?x(!1,ke(e)):x(!1)),t}function Dr(e){let t=h.useContext(Y);return t||(process.env.NODE_ENV!=="production"?x(!1,ke(e)):x(!1)),t}function Le(e){let t=Dr(e),r=t.matches[t.matches.length-1];return r.route.id||(process.env.NODE_ENV!=="production"?x(!1,e+' can only be used on routes that contain a unique "id"'):x(!1)),r.route.id}function kr(){return Le(fe.UseRouteId)}function Lr(){var e;let t=h.useContext(De),r=jr(fe.UseRouteError),n=Le(fe.UseRouteError);return t!==void 0?t:(e=r.errors)==null?void 0:e[n]}function Fr(){let{router:e}=Ar(ct.UseNavigateStable),t=Le(fe.UseNavigateStable),r=h.useRef(!1);return lt(()=>{r.current=!0}),h.useCallback(function(o,i){i===void 0&&(i={}),process.env.NODE_ENV!=="production"&&V(r.current,st),r.current&&(typeof o=="number"?e.navigate(o):e.navigate(o,ie({fromRouteId:t},i)))},[e,t])}const ft={};function dt(e,t,r){!t&&!ft[e]&&(ft[e]=!0,process.env.NODE_ENV!=="production"&&V(!1,r))}const pt={};function Ir(e,t){process.env.NODE_ENV!=="production"&&!pt[t]&&(pt[t]=!0,console.warn(t))}const ht=(e,t,r)=>Ir(e,"⚠️ React Router Future Flag Warning: "+t+". "+("You can use the `"+e+"` future flag to opt-in early. ")+("For more information, see "+r+"."));function Mr(e,t){(e==null?void 0:e.v7_startTransition)===void 0&&ht("v7_startTransition","React Router will begin wrapping state updates in `React.startTransition` in v7","https://reactrouter.com/v6/upgrading/future#v7_starttransition"),(e==null?void 0:e.v7_relativeSplatPath)===void 0&&ht("v7_relativeSplatPath","Relative route resolution within Splat routes is changing in v7","https://reactrouter.com/v6/upgrading/future#v7_relativesplatpath")}function mt(e){process.env.NODE_ENV!=="production"?x(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>."):x(!1)}function Vr(e){let{basename:t="/",children:r=null,location:n,navigationType:o=z.Pop,navigator:i,static:s=!1,future:c}=e;ue()&&(process.env.NODE_ENV!=="production"?x(!1,"You cannot render a <Router> inside another <Router>. You should never have more than one in your app."):x(!1));let l=t.replace(/^\/*/,"/"),u=h.useMemo(()=>({basename:l,navigator:i,static:s,future:ie({v7_relativeSplatPath:!1},c)}),[l,c,i,s]);typeof n=="string"&&(n=X(n));let{pathname:p="/",search:f="",hash:m="",state:w=null,key:C="default"}=n,O=h.useMemo(()=>{let E=q(p,l);return E==null?null:{location:{pathname:E,search:f,hash:m,state:w,key:C},navigationType:o}},[l,p,f,m,w,C,o]);return process.env.NODE_ENV!=="production"&&V(O!=null,'<Router basename="'+l+'"> is not able to match the URL '+('"'+p+f+m+'" because it does not start with the ')+"basename, so the <Router> won't render anything."),O==null?null:h.createElement(U.Provider,{value:u},h.createElement(le.Provider,{children:r,value:O}))}function Ur(e){let{children:t,location:r}=e;return Cr(Fe(t),r)}new Promise(()=>{});function Fe(e,t){t===void 0&&(t=[]);let r=[];return h.Children.forEach(e,(n,o)=>{if(!h.isValidElement(n))return;let i=[...t,o];if(n.type===h.Fragment){r.push.apply(r,Fe(n.props.children,i));return}n.type!==mt&&(process.env.NODE_ENV!=="production"?x(!1,"["+(typeof n.type=="string"?n.type:n.type.name)+"] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>"):x(!1)),!n.props.index||!n.props.children||(process.env.NODE_ENV!=="production"?x(!1,"An index route cannot have child routes."):x(!1));let s={id:n.props.id||i.join("-"),caseSensitive:n.props.caseSensitive,element:n.props.element,Component:n.props.Component,index:n.props.index,path:n.props.path,loader:n.props.loader,action:n.props.action,errorElement:n.props.errorElement,ErrorBoundary:n.props.ErrorBoundary,hasErrorBoundary:n.props.ErrorBoundary!=null||n.props.errorElement!=null,shouldRevalidate:n.props.shouldRevalidate,handle:n.props.handle,lazy:n.props.lazy};n.props.children&&(s.children=Fe(n.props.children,i)),r.push(s)}),r}/**
|
|
50
|
+
`+('Please change the parent <Route path="'+v+'"> to <Route ')+('path="'+(v==="/"?"*":v+"/*")+'">.'))}let f=Z(),m;if(t){var w;let v=typeof t=="string"?X(t):t;u==="/"||(w=v.pathname)!=null&&w.startsWith(u)||(process.env.NODE_ENV!=="production"?x(!1,"When overriding the location using `<Routes location>` or `useRoutes(routes, location)`, the location pathname must begin with the portion of the URL pathname that was "+('matched by all parent routes. The current pathname base is "'+u+'" ')+('but pathname "'+v.pathname+'" was given in the `location` prop.')):x(!1)),m=v}else m=f;let C=m.pathname||"/",O=C;if(u!=="/"){let v=u.replace(/^\//,"").split("/");O="/"+C.replace(/^\//,"").split("/").slice(v.length).join("/")}let E=er(e,{pathname:O});process.env.NODE_ENV!=="production"&&(process.env.NODE_ENV!=="production"&&V(p||E!=null,'No routes matched location "'+m.pathname+m.search+m.hash+'" '),process.env.NODE_ENV!=="production"&&V(E==null||E[E.length-1].route.element!==void 0||E[E.length-1].route.Component!==void 0||E[E.length-1].route.lazy!==void 0,'Matched leaf route at location "'+m.pathname+m.search+m.hash+'" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.'));let N=jr(E&&E.map(v=>Object.assign({},v,{params:Object.assign({},c,v.params),pathname:W([u,o.encodeLocation?o.encodeLocation(v.pathname).pathname:v.pathname]),pathnameBase:v.pathnameBase==="/"?u:W([u,o.encodeLocation?o.encodeLocation(v.pathnameBase).pathname:v.pathnameBase])})),i,r,n);return t&&N?h.createElement(le.Provider,{value:{location:ie({pathname:"/",search:"",hash:"",state:null,key:"default"},m),navigationType:z.Pop}},N):N}function Or(){let e=Ir(),t=xr(e)?e.status+" "+e.statusText:e instanceof Error?e.message:JSON.stringify(e),r=e instanceof Error?e.stack:null,n="rgba(200,200,200, 0.5)",o={padding:"0.5rem",backgroundColor:n},i={padding:"2px 4px",backgroundColor:n},s=null;return process.env.NODE_ENV!=="production"&&(console.error("Error handled by React Router default ErrorBoundary:",e),s=h.createElement(h.Fragment,null,h.createElement("p",null,"💿 Hey developer 👋"),h.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",h.createElement("code",{style:i},"ErrorBoundary")," or"," ",h.createElement("code",{style:i},"errorElement")," prop on your route."))),h.createElement(h.Fragment,null,h.createElement("h2",null,"Unexpected Application Error!"),h.createElement("h3",{style:{fontStyle:"italic"}},t),r?h.createElement("pre",{style:o},r):null,s)}const Pr=h.createElement(Or,null);class Ar extends h.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,r){return r.location!==t.location||r.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:r.error,location:r.location,revalidation:t.revalidation||r.revalidation}}componentDidCatch(t,r){console.error("React Router caught the following error during render",t,r)}render(){return this.state.error!==void 0?h.createElement(Y.Provider,{value:this.props.routeContext},h.createElement(ke.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function Tr(e){let{routeContext:t,match:r,children:n}=e,o=h.useContext(se);return o&&o.static&&o.staticContext&&(r.route.errorElement||r.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=r.route.id),h.createElement(Y.Provider,{value:t},n)}function jr(e,t,r,n){var o;if(t===void 0&&(t=[]),r===void 0&&(r=null),n===void 0&&(n=null),e==null){var i;if(!r)return null;if(r.errors)e=r.matches;else if((i=n)!=null&&i.v7_partialHydration&&t.length===0&&!r.initialized&&r.matches.length>0)e=r.matches;else return null}let s=e,c=(o=r)==null?void 0:o.errors;if(c!=null){let p=s.findIndex(f=>f.route.id&&(c==null?void 0:c[f.route.id])!==void 0);p>=0||(process.env.NODE_ENV!=="production"?x(!1,"Could not find a matching route for errors on route IDs: "+Object.keys(c).join(",")):x(!1)),s=s.slice(0,Math.min(s.length,p+1))}let l=!1,u=-1;if(r&&n&&n.v7_partialHydration)for(let p=0;p<s.length;p++){let f=s[p];if((f.route.HydrateFallback||f.route.hydrateFallbackElement)&&(u=p),f.route.id){let{loaderData:m,errors:w}=r,C=f.route.loader&&m[f.route.id]===void 0&&(!w||w[f.route.id]===void 0);if(f.route.lazy||C){l=!0,u>=0?s=s.slice(0,u+1):s=[s[0]];break}}}return s.reduceRight((p,f,m)=>{let w,C=!1,O=null,E=null;r&&(w=c&&f.route.id?c[f.route.id]:void 0,O=f.route.errorElement||Pr,l&&(u<0&&m===0?(pt("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),C=!0,E=null):u===m&&(C=!0,E=f.route.hydrateFallbackElement||null)));let N=t.concat(s.slice(0,m+1)),v=()=>{let P;return w?P=O:C?P=E:f.route.Component?P=h.createElement(f.route.Component,null):f.route.element?P=f.route.element:P=p,h.createElement(Tr,{match:f,routeContext:{outlet:p,matches:N,isDataRoute:r!=null},children:P})};return r&&(f.route.ErrorBoundary||f.route.errorElement||m===0)?h.createElement(Ar,{location:r.location,revalidation:r.revalidation,component:O,error:w,children:v(),routeContext:{outlet:null,matches:N,isDataRoute:!0}}):v()},null)}var ft=function(e){return e.UseBlocker="useBlocker",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e}(ft||{}),fe=function(e){return e.UseBlocker="useBlocker",e.UseLoaderData="useLoaderData",e.UseActionData="useActionData",e.UseRouteError="useRouteError",e.UseNavigation="useNavigation",e.UseRouteLoaderData="useRouteLoaderData",e.UseMatches="useMatches",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e.UseRouteId="useRouteId",e}(fe||{});function Le(e){return e+" must be used within a data router. See https://reactrouter.com/v6/routers/picking-a-router."}function Dr(e){let t=h.useContext(se);return t||(process.env.NODE_ENV!=="production"?x(!1,Le(e)):x(!1)),t}function kr(e){let t=h.useContext(De);return t||(process.env.NODE_ENV!=="production"?x(!1,Le(e)):x(!1)),t}function Lr(e){let t=h.useContext(Y);return t||(process.env.NODE_ENV!=="production"?x(!1,Le(e)):x(!1)),t}function Fe(e){let t=Lr(e),r=t.matches[t.matches.length-1];return r.route.id||(process.env.NODE_ENV!=="production"?x(!1,e+' can only be used on routes that contain a unique "id"'):x(!1)),r.route.id}function Fr(){return Fe(fe.UseRouteId)}function Ir(){var e;let t=h.useContext(ke),r=kr(fe.UseRouteError),n=Fe(fe.UseRouteError);return t!==void 0?t:(e=r.errors)==null?void 0:e[n]}function Mr(){let{router:e}=Dr(ft.UseNavigateStable),t=Fe(fe.UseNavigateStable),r=h.useRef(!1);return ut(()=>{r.current=!0}),h.useCallback(function(o,i){i===void 0&&(i={}),process.env.NODE_ENV!=="production"&&V(r.current,lt),r.current&&(typeof o=="number"?e.navigate(o):e.navigate(o,ie({fromRouteId:t},i)))},[e,t])}const dt={};function pt(e,t,r){!t&&!dt[e]&&(dt[e]=!0,process.env.NODE_ENV!=="production"&&V(!1,r))}const ht={};function Vr(e,t){process.env.NODE_ENV!=="production"&&!ht[t]&&(ht[t]=!0,console.warn(t))}const mt=(e,t,r)=>Vr(e,"⚠️ React Router Future Flag Warning: "+t+". "+("You can use the `"+e+"` future flag to opt-in early. ")+("For more information, see "+r+"."));function Ur(e,t){(e==null?void 0:e.v7_startTransition)===void 0&&mt("v7_startTransition","React Router will begin wrapping state updates in `React.startTransition` in v7","https://reactrouter.com/v6/upgrading/future#v7_starttransition"),(e==null?void 0:e.v7_relativeSplatPath)===void 0&&mt("v7_relativeSplatPath","Relative route resolution within Splat routes is changing in v7","https://reactrouter.com/v6/upgrading/future#v7_relativesplatpath")}function vt(e){process.env.NODE_ENV!=="production"?x(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>."):x(!1)}function $r(e){let{basename:t="/",children:r=null,location:n,navigationType:o=z.Pop,navigator:i,static:s=!1,future:c}=e;ue()&&(process.env.NODE_ENV!=="production"?x(!1,"You cannot render a <Router> inside another <Router>. You should never have more than one in your app."):x(!1));let l=t.replace(/^\/*/,"/"),u=h.useMemo(()=>({basename:l,navigator:i,static:s,future:ie({v7_relativeSplatPath:!1},c)}),[l,c,i,s]);typeof n=="string"&&(n=X(n));let{pathname:p="/",search:f="",hash:m="",state:w=null,key:C="default"}=n,O=h.useMemo(()=>{let E=q(p,l);return E==null?null:{location:{pathname:E,search:f,hash:m,state:w,key:C},navigationType:o}},[l,p,f,m,w,C,o]);return process.env.NODE_ENV!=="production"&&V(O!=null,'<Router basename="'+l+'"> is not able to match the URL '+('"'+p+f+m+'" because it does not start with the ')+"basename, so the <Router> won't render anything."),O==null?null:h.createElement(U.Provider,{value:u},h.createElement(le.Provider,{children:r,value:O}))}function Br(e){let{children:t,location:r}=e;return Nr(Ie(t),r)}new Promise(()=>{});function Ie(e,t){t===void 0&&(t=[]);let r=[];return h.Children.forEach(e,(n,o)=>{if(!h.isValidElement(n))return;let i=[...t,o];if(n.type===h.Fragment){r.push.apply(r,Ie(n.props.children,i));return}n.type!==vt&&(process.env.NODE_ENV!=="production"?x(!1,"["+(typeof n.type=="string"?n.type:n.type.name)+"] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>"):x(!1)),!n.props.index||!n.props.children||(process.env.NODE_ENV!=="production"?x(!1,"An index route cannot have child routes."):x(!1));let s={id:n.props.id||i.join("-"),caseSensitive:n.props.caseSensitive,element:n.props.element,Component:n.props.Component,index:n.props.index,path:n.props.path,loader:n.props.loader,action:n.props.action,errorElement:n.props.errorElement,ErrorBoundary:n.props.ErrorBoundary,hasErrorBoundary:n.props.ErrorBoundary!=null||n.props.errorElement!=null,shouldRevalidate:n.props.shouldRevalidate,handle:n.props.handle,lazy:n.props.lazy};n.props.children&&(s.children=Ie(n.props.children,i)),r.push(s)}),r}/**
|
|
51
51
|
* React Router DOM v6.30.3
|
|
52
52
|
*
|
|
53
53
|
* Copyright (c) Remix Software Inc.
|
|
@@ -56,4 +56,4 @@ React keys must be passed directly to JSX without using spread:
|
|
|
56
56
|
* LICENSE.md file in the root directory of this source tree.
|
|
57
57
|
*
|
|
58
58
|
* @license MIT
|
|
59
|
-
*/function Q(){return Q=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},Q.apply(this,arguments)}function Ie(e,t){if(e==null)return{};var r={},n=Object.keys(e),o,i;for(i=0;i<n.length;i++)o=n[i],!(t.indexOf(o)>=0)&&(r[o]=e[o]);return r}const ge="get",ye="application/x-www-form-urlencoded";function Ee(e){return e!=null&&typeof e.tagName=="string"}function $r(e){return Ee(e)&&e.tagName.toLowerCase()==="button"}function Br(e){return Ee(e)&&e.tagName.toLowerCase()==="form"}function Wr(e){return Ee(e)&&e.tagName.toLowerCase()==="input"}function Yr(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function zr(e,t){return e.button===0&&(!t||t==="_self")&&!Yr(e)}let be=null;function qr(){if(be===null)try{new FormData(document.createElement("form"),0),be=!1}catch{be=!0}return be}const Kr=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Me(e){return e!=null&&!Kr.has(e)?(process.env.NODE_ENV!=="production"&&V(!1,'"'+e+'" is not a valid `encType` for `<Form>`/`<fetcher.Form>` '+('and will default to "'+ye+'"')),null):e}function Hr(e,t){let r,n,o,i,s;if(Br(e)){let c=e.getAttribute("action");n=c?q(c,t):null,r=e.getAttribute("method")||ge,o=Me(e.getAttribute("enctype"))||ye,i=new FormData(e)}else if($r(e)||Wr(e)&&(e.type==="submit"||e.type==="image")){let c=e.form;if(c==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let l=e.getAttribute("formaction")||c.getAttribute("action");if(n=l?q(l,t):null,r=e.getAttribute("formmethod")||c.getAttribute("method")||ge,o=Me(e.getAttribute("formenctype"))||Me(c.getAttribute("enctype"))||ye,i=new FormData(c,e),!qr()){let{name:u,type:p,value:f}=e;if(p==="image"){let m=u?u+".":"";i.append(m+"x","0"),i.append(m+"y","0")}else u&&i.append(u,f)}}else{if(Ee(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');r=ge,n=null,o=ye,s=e}return i&&o==="text/plain"&&(s=i,i=void 0),{action:n,method:r.toLowerCase(),encType:o,formData:i,body:s}}const Jr=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],Gr=["aria-current","caseSensitive","className","end","style","to","viewTransition","children"],Xr=["fetcherKey","navigate","reloadDocument","replace","state","method","action","onSubmit","relative","preventScrollReset","viewTransition"],Zr="6";try{window.__reactRouterVersion=Zr}catch{}const vt=h.createContext({isTransitioning:!1});process.env.NODE_ENV!=="production"&&(vt.displayName="ViewTransition");const Qr=h.createContext(new Map);process.env.NODE_ENV!=="production"&&(Qr.displayName="Fetchers");const gt=h["startTransition"];function en(e){let{basename:t,children:r,future:n,window:o}=e,i=h.useRef();i.current==null&&(i.current=Jt({window:o,v5Compat:!0}));let s=i.current,[c,l]=h.useState({action:s.action,location:s.location}),{v7_startTransition:u}=n||{},p=h.useCallback(f=>{u&>?gt(()=>l(f)):l(f)},[l,u]);return h.useLayoutEffect(()=>s.listen(p),[s,p]),h.useEffect(()=>Mr(n),[n]),h.createElement(Vr,{basename:t,children:r,location:c.location,navigationType:c.action,navigator:s,future:n})}process.env.NODE_ENV;const tn=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",rn=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,yt=h.forwardRef(function(t,r){let{onClick:n,relative:o,reloadDocument:i,replace:s,state:c,target:l,to:u,preventScrollReset:p,viewTransition:f}=t,m=Ie(t,Jr),{basename:w}=h.useContext(U),C,O=!1;if(typeof u=="string"&&rn.test(u)&&(C=u,tn))try{let P=new URL(window.location.href),j=u.startsWith("//")?new URL(P.protocol+u):new URL(u),B=q(j.pathname,w);j.origin===P.origin&&B!=null?u=B+j.search+j.hash:O=!0}catch{process.env.NODE_ENV!=="production"&&V(!1,'<Link to="'+u+'"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.')}let E=wr(u,{relative:o}),N=sn(u,{replace:s,state:c,target:l,preventScrollReset:p,relative:o,viewTransition:f});function v(P){n&&n(P),P.defaultPrevented||N(P)}return h.createElement("a",Q({},m,{href:C||E,onClick:O||i?n:v,ref:r,target:l}))});process.env.NODE_ENV!=="production"&&(yt.displayName="Link");const nn=h.forwardRef(function(t,r){let{"aria-current":n="page",caseSensitive:o=!1,className:i="",end:s=!1,style:c,to:l,viewTransition:u,children:p}=t,f=Ie(t,Gr),m=ce(l,{relative:f.relative}),w=Z(),C=h.useContext(je),{navigator:O,basename:E}=h.useContext(U),N=C!=null&&pn(m)&&u===!0,v=O.encodeLocation?O.encodeLocation(m).pathname:m.pathname,P=w.pathname,j=C&&C.navigation&&C.navigation.location?C.navigation.location.pathname:null;o||(P=P.toLowerCase(),j=j?j.toLowerCase():null,v=v.toLowerCase()),j&&E&&(j=q(j,E)||j);const B=v!=="/"&&v.endsWith("/")?v.length-1:v.length;let de=P===v||!s&&P.startsWith(v)&&P.charAt(B)==="/",we=j!=null&&(j===v||!s&&j.startsWith(v)&&j.charAt(v.length)==="/"),pe={isActive:de,isPending:we,isTransitioning:N},Re=de?n:void 0,he;typeof i=="function"?he=i(pe):he=[i,de?"active":null,we?"pending":null,N?"transitioning":null].filter(Boolean).join(" ");let Ve=typeof c=="function"?c(pe):c;return h.createElement(yt,Q({},f,{"aria-current":Re,className:he,ref:r,style:Ve,to:l,viewTransition:u}),typeof p=="function"?p(pe):p)});process.env.NODE_ENV!=="production"&&(nn.displayName="NavLink");const an=h.forwardRef((e,t)=>{let{fetcherKey:r,navigate:n,reloadDocument:o,replace:i,state:s,method:c=ge,action:l,onSubmit:u,relative:p,preventScrollReset:f,viewTransition:m}=e,w=Ie(e,Xr),C=fn(),O=dn(l,{relative:p}),E=c.toLowerCase()==="get"?"get":"post",N=v=>{if(u&&u(v),v.defaultPrevented)return;v.preventDefault();let P=v.nativeEvent.submitter,j=(P==null?void 0:P.getAttribute("formmethod"))||c;C(P||v.currentTarget,{fetcherKey:r,method:j,navigate:n,replace:i,state:s,relative:p,preventScrollReset:f,viewTransition:m})};return h.createElement("form",Q({ref:t,method:E,action:O,onSubmit:o?u:N},w))});process.env.NODE_ENV!=="production"&&(an.displayName="Form"),process.env.NODE_ENV;var xe;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(xe||(xe={}));var Et;(function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(Et||(Et={}));function on(e){return e+" must be used within a data router. See https://reactrouter.com/v6/routers/picking-a-router."}function bt(e){let t=h.useContext(se);return t||(process.env.NODE_ENV!=="production"?x(!1,on(e)):x(!1)),t}function sn(e,t){let{target:r,replace:n,state:o,preventScrollReset:i,relative:s,viewTransition:c}=t===void 0?{}:t,l=ut(),u=Z(),p=ce(e,{relative:s});return h.useCallback(f=>{if(zr(f,r)){f.preventDefault();let m=n!==void 0?n:oe(u)===oe(p);l(e,{replace:m,state:o,preventScrollReset:i,relative:s,viewTransition:c})}},[u,l,p,n,o,r,e,i,s,c])}function ln(){if(typeof document>"u")throw new Error("You are calling submit during the server render. Try calling submit within a `useEffect` or callback instead.")}let un=0,cn=()=>"__"+String(++un)+"__";function fn(){let{router:e}=bt(xe.UseSubmit),{basename:t}=h.useContext(U),r=kr();return h.useCallback(function(n,o){o===void 0&&(o={}),ln();let{action:i,method:s,encType:c,formData:l,body:u}=Hr(n,t);if(o.navigate===!1){let p=o.fetcherKey||cn();e.fetch(p,r,o.action||i,{preventScrollReset:o.preventScrollReset,formData:l,body:u,formMethod:o.method||s,formEncType:o.encType||c,flushSync:o.flushSync})}else e.navigate(o.action||i,{preventScrollReset:o.preventScrollReset,formData:l,body:u,formMethod:o.method||s,formEncType:o.encType||c,replace:o.replace,state:o.state,fromRouteId:r,flushSync:o.flushSync,viewTransition:o.viewTransition})},[e,t,r])}function dn(e,t){let{relative:r}=t===void 0?{}:t,{basename:n}=h.useContext(U),o=h.useContext(Y);o||(process.env.NODE_ENV!=="production"?x(!1,"useFormAction must be used inside a RouteContext"):x(!1));let[i]=o.matches.slice(-1),s=Q({},ce(e||".",{relative:r})),c=Z();if(e==null){s.search=c.search;let l=new URLSearchParams(s.search),u=l.getAll("index");if(u.some(f=>f==="")){l.delete("index"),u.filter(m=>m).forEach(m=>l.append("index",m));let f=l.toString();s.search=f?"?"+f:""}}return(!e||e===".")&&i.route.index&&(s.search=s.search?s.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(s.pathname=s.pathname==="/"?n:W([n,s.pathname])),oe(s)}function pn(e,t){t===void 0&&(t={});let r=h.useContext(vt);r==null&&(process.env.NODE_ENV!=="production"?x(!1,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?"):x(!1));let{basename:n}=bt(xe.useViewTransitionState),o=ce(e,{relative:t.relative});if(!r.isTransitioning)return!1;let i=q(r.currentLocation.pathname,n)||r.currentLocation.pathname,s=q(r.nextLocation.pathname,n)||r.nextLocation.pathname;return Te(o.pathname,s)!=null||Te(o.pathname,i)!=null}function hn({appName:e,appPath:t,children:r,onStatusChange:n}){return y.jsx(y.Fragment,{children:r})}class mn extends _.Component{constructor(t){super(t),this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,r){const{appName:n,onError:o}=this.props;this.setState({errorInfo:r}),console.error(`[ErrorBoundary][${n}] 🛡️ 捕获到运行时错误:`,t),console.error(`[ErrorBoundary][${n}] 组件栈:`,r.componentStack),o==null||o(t,r)}render(){const{hasError:t,error:r,errorInfo:n}=this.state,{appName:o,children:i,onReset:s}=this.props;return t?y.jsx("div",{className:"flex items-center justify-center min-h-[400px] p-6",children:y.jsx("div",{className:"w-full max-w-lg",children:y.jsxs("div",{className:"bg-white rounded-lg shadow-lg border border-red-200 overflow-hidden",children:[y.jsx("div",{className:"bg-red-50 border-b border-red-200 px-6 py-4",children:y.jsxs("div",{className:"flex items-center gap-3",children:[y.jsx("span",{className:"text-2xl",children:"🛡️"}),y.jsxs("div",{children:[y.jsxs("h3",{className:"text-lg font-semibold text-red-800",children:["子应用 [",o,"] 运行出错"]}),y.jsx("p",{className:"text-sm text-red-600 mt-0.5",children:"该错误已被隔离,不影响其他子应用的正常运行"})]})]})}),y.jsxs("div",{className:"px-6 py-4 space-y-4",children:[r&&y.jsxs("div",{children:[y.jsx("p",{className:"text-sm font-medium text-gray-700 mb-1",children:"错误信息:"}),y.jsx("div",{className:"bg-red-50 rounded-md px-4 py-3 text-sm text-red-700 font-mono break-all",children:r.message})]}),(n==null?void 0:n.componentStack)&&y.jsxs("details",{className:"group",children:[y.jsxs("summary",{className:"text-sm font-medium text-gray-700 cursor-pointer hover:text-gray-900 select-none",children:[y.jsx("span",{className:"group-open:hidden",children:"▶ 展开错误堆栈"}),y.jsx("span",{className:"hidden group-open:inline",children:"▼ 收起错误堆栈"})]}),y.jsx("pre",{className:"mt-2 bg-gray-50 rounded-md px-4 py-3 text-xs text-gray-600 overflow-x-auto max-h-48 overflow-y-auto whitespace-pre-wrap",children:n.componentStack})]}),y.jsx("div",{className:"bg-blue-50 rounded-md px-4 py-3",children:y.jsx("p",{className:"text-sm text-blue-700",children:"点击重试会完整重载该子应用,或返回继续使用其他功能。"})})]}),y.jsxs("div",{className:"px-6 py-4 bg-gray-50 border-t border-gray-200 flex gap-3",children:[y.jsx("button",{onClick:s,className:"px-4 py-2 bg-blue-600 text-white text-sm font-medium rounded-md hover:bg-blue-700 transition-colors",children:"重试加载"}),y.jsx("button",{onClick:()=>window.history.back(),className:"px-4 py-2 bg-white text-gray-700 text-sm font-medium rounded-md border border-gray-300 hover:bg-gray-50 transition-colors",children:"返回上一页"})]})]})})}):i}}function vn({appName:e,children:t,onError:r}){const[n,o]=_.useState(0),i=_.useCallback(()=>{console.log(`[ErrorBoundary][${e}] 触发 key 重置,完整重建子应用`),o(l=>l+1)},[e]),s=_.useCallback((l,u)=>{c({type:"SET_ERROR",error:l}),r==null||r(l,u)},[r]),[,c]=_.useReducer((l,u)=>{switch(u.type){case"SET_ERROR":return{...l,hasError:!0,error:u.error??null};case"RESET_ERROR":return{...l,hasError:!1,error:null};case"ROUTE_CHANGED":return l.hasError?(i(),{...l,hasError:!1,error:null}):l;default:return l}},{hasError:!1,error:null,errorInfo:null});return _.useEffect(()=>{c({type:"ROUTE_CHANGED"})},[location.pathname]),y.jsx(mn,{appName:e,onError:s,onReset:i,children:t},n)}function gn(){const[e,t]=_.useState(null),r=_.useCallback(n=>{const o=n instanceof Error?n:new Error(n);t(o)},[]);if(e)throw e;return r}function yn({url:e,containerId:t,mode:r="iframe",iframeStyle:n,onError:o,onLoad:i}){const s=_.useRef(null),c=gn();async function l(u){try{const p=await fetch(u,{method:"HEAD",mode:"no-cors"});return!!(p.status===0||p.ok)}catch(p){c(p instanceof Error?p:new Error("请求失败"))}}return _.useEffect(()=>{if(!s.current)return;const u=s.current;r==="iframe"&&(async()=>{const f=document.createElement("iframe"),m=document.querySelector(".micro-app-container");return await l(e)&&(f.src=e,f.style.width="100%",f.style.height=m?m.offsetHeight+"px":"100%",f.style.border="none",f.setAttribute("sandbox","allow-same-origin allow-scripts allow-forms allow-popups allow-top-navigation"),Object.assign(f.style,n||{})),u.appendChild(f),()=>{u.contains(f)&&u.removeChild(f)}})()},[e,t,r,n,o,i]),y.jsx("div",{ref:s,id:t,style:{width:"100%",height:"100%",position:"relative"}})}function En({apps:e}){return y.jsx(Ur,{children:e.map(t=>{const r=t.active_rule?t.active_rule:`/${t.name}/*`,n=t.active_rule||`/app/${t.name}`;return y.jsx(mt,{path:r,element:y.jsx(hn,{appName:t.name,appPath:n,children:y.jsx(vn,{appName:t.name,children:y.jsx(_.Suspense,{fallback:y.jsx("div",{className:"flex items-center justify-center h-96",children:y.jsx("div",{className:"text-center",children:y.jsxs("p",{className:"mt-4 text-gray-600",children:["正在加载 ",t.name,"..."]})})}),children:y.jsx("div",{id:t.container.replace("#",""),"data-micro-app":t.name,className:"micro-app-container w-full h-full flex-1",children:t.entry&&y.jsx(yn,{url:t.entry,containerId:t.container.replace("#",""),mode:"iframe"})})})})})},t.name)})})}function bn(e){return e.active_rule?e.active_rule:`/${e.name}/*`}function xn({apps:e,activeApp:t,onError:r,onStatusChange:n,onLoad:o,children:i}){const s=ut(),c=_.useRef(new Set),l=_.useRef({onError:r,onStatusChange:n,onLoad:o});l.current={onError:r,onStatusChange:n,onLoad:o};const u=_.useMemo(()=>He({apps:e,onError:l.current.onError,onStatusChange:(f,m)=>{var w,C;(C=(w=l.current).onStatusChange)==null||C.call(w,f,m)},onLoad:l.current.onLoad}),[e]);return _.useEffect(()=>{if(!t)return;const p=e.find(w=>w.name===t);if(!p)return;const f=bn(p);s(f);const m=()=>{if(!document.querySelector(p.container)){requestAnimationFrame(m);return}c.current.has(t)||(u.startApp(t),c.current.add(t))};requestAnimationFrame(m),e.forEach(w=>{w.name!==t&&c.current.has(w.name)&&(u.stopApp(w.name),c.current.delete(w.name))})},[t,e,u,s]),y.jsxs("div",{className:"micro-app-wrapper",children:[y.jsx(En,{apps:e}),i]})}function wn(e){return y.jsx(en,{children:y.jsx(xn,{...e})})}class Rn extends _.Component{constructor(r){super(r);$(this,"handleRetry",()=>{var r,n;this.setState({hasError:!1,error:null}),(n=(r=this.props).onRetry)==null||n.call(r,this.props.appName)});this.state={hasError:!1,error:null}}static getDerivedStateFromError(r){return{hasError:!0,error:r}}componentDidCatch(r,n){var o,i;console.error(`[${this.props.appName||"ErrorBoundary"}] 捕获错误:`,r,n),(i=(o=this.props).onError)==null||i.call(o,r,this.props.appName)}render(){var r;return this.state.hasError?this.props.fallback?this.props.fallback:y.jsx("div",{className:"micro-app-error flex flex-col items-center justify-center h-full p-4 bg-gray-50 rounded",children:y.jsxs("div",{className:"text-center",children:[y.jsx("div",{className:"text-red-500 text-4xl mb-2",children:"⚠️"}),y.jsxs("h3",{className:"text-lg font-semibold text-gray-800 mb-2",children:[this.props.appName||"应用"," 加载失败"]}),y.jsx("p",{className:"text-sm text-gray-500 mb-4",children:((r=this.state.error)==null?void 0:r.message)||"应用渲染时发生错误"}),y.jsx("button",{onClick:this.handleRetry,className:"px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700 transition-colors",children:"重试"})]})}):this.props.children}}const Cn="1.0.0";L.ErrorBoundary=Rn,L.MicroApp=wn,L.createMicroApp=He,L.version=Cn,Object.defineProperty(L,Symbol.toStringTag,{value:"Module"})});
|
|
59
|
+
*/function Q(){return Q=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},Q.apply(this,arguments)}function Me(e,t){if(e==null)return{};var r={},n=Object.keys(e),o,i;for(i=0;i<n.length;i++)o=n[i],!(t.indexOf(o)>=0)&&(r[o]=e[o]);return r}const ge="get",ye="application/x-www-form-urlencoded";function Ee(e){return e!=null&&typeof e.tagName=="string"}function Wr(e){return Ee(e)&&e.tagName.toLowerCase()==="button"}function Yr(e){return Ee(e)&&e.tagName.toLowerCase()==="form"}function zr(e){return Ee(e)&&e.tagName.toLowerCase()==="input"}function qr(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Kr(e,t){return e.button===0&&(!t||t==="_self")&&!qr(e)}let be=null;function Hr(){if(be===null)try{new FormData(document.createElement("form"),0),be=!1}catch{be=!0}return be}const Jr=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Ve(e){return e!=null&&!Jr.has(e)?(process.env.NODE_ENV!=="production"&&V(!1,'"'+e+'" is not a valid `encType` for `<Form>`/`<fetcher.Form>` '+('and will default to "'+ye+'"')),null):e}function Gr(e,t){let r,n,o,i,s;if(Yr(e)){let c=e.getAttribute("action");n=c?q(c,t):null,r=e.getAttribute("method")||ge,o=Ve(e.getAttribute("enctype"))||ye,i=new FormData(e)}else if(Wr(e)||zr(e)&&(e.type==="submit"||e.type==="image")){let c=e.form;if(c==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let l=e.getAttribute("formaction")||c.getAttribute("action");if(n=l?q(l,t):null,r=e.getAttribute("formmethod")||c.getAttribute("method")||ge,o=Ve(e.getAttribute("formenctype"))||Ve(c.getAttribute("enctype"))||ye,i=new FormData(c,e),!Hr()){let{name:u,type:p,value:f}=e;if(p==="image"){let m=u?u+".":"";i.append(m+"x","0"),i.append(m+"y","0")}else u&&i.append(u,f)}}else{if(Ee(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');r=ge,n=null,o=ye,s=e}return i&&o==="text/plain"&&(s=i,i=void 0),{action:n,method:r.toLowerCase(),encType:o,formData:i,body:s}}const Xr=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],Zr=["aria-current","caseSensitive","className","end","style","to","viewTransition","children"],Qr=["fetcherKey","navigate","reloadDocument","replace","state","method","action","onSubmit","relative","preventScrollReset","viewTransition"],en="6";try{window.__reactRouterVersion=en}catch{}const gt=h.createContext({isTransitioning:!1});process.env.NODE_ENV!=="production"&&(gt.displayName="ViewTransition");const tn=h.createContext(new Map);process.env.NODE_ENV!=="production"&&(tn.displayName="Fetchers");const yt=h["startTransition"];function rn(e){let{basename:t,children:r,future:n,window:o}=e,i=h.useRef();i.current==null&&(i.current=Xt({window:o,v5Compat:!0}));let s=i.current,[c,l]=h.useState({action:s.action,location:s.location}),{v7_startTransition:u}=n||{},p=h.useCallback(f=>{u&&yt?yt(()=>l(f)):l(f)},[l,u]);return h.useLayoutEffect(()=>s.listen(p),[s,p]),h.useEffect(()=>Ur(n),[n]),h.createElement($r,{basename:t,children:r,location:c.location,navigationType:c.action,navigator:s,future:n})}process.env.NODE_ENV;const nn=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",an=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Et=h.forwardRef(function(t,r){let{onClick:n,relative:o,reloadDocument:i,replace:s,state:c,target:l,to:u,preventScrollReset:p,viewTransition:f}=t,m=Me(t,Xr),{basename:w}=h.useContext(U),C,O=!1;if(typeof u=="string"&&an.test(u)&&(C=u,nn))try{let P=new URL(window.location.href),j=u.startsWith("//")?new URL(P.protocol+u):new URL(u),B=q(j.pathname,w);j.origin===P.origin&&B!=null?u=B+j.search+j.hash:O=!0}catch{process.env.NODE_ENV!=="production"&&V(!1,'<Link to="'+u+'"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.')}let E=Cr(u,{relative:o}),N=un(u,{replace:s,state:c,target:l,preventScrollReset:p,relative:o,viewTransition:f});function v(P){n&&n(P),P.defaultPrevented||N(P)}return h.createElement("a",Q({},m,{href:C||E,onClick:O||i?n:v,ref:r,target:l}))});process.env.NODE_ENV!=="production"&&(Et.displayName="Link");const on=h.forwardRef(function(t,r){let{"aria-current":n="page",caseSensitive:o=!1,className:i="",end:s=!1,style:c,to:l,viewTransition:u,children:p}=t,f=Me(t,Zr),m=ce(l,{relative:f.relative}),w=Z(),C=h.useContext(De),{navigator:O,basename:E}=h.useContext(U),N=C!=null&&mn(m)&&u===!0,v=O.encodeLocation?O.encodeLocation(m).pathname:m.pathname,P=w.pathname,j=C&&C.navigation&&C.navigation.location?C.navigation.location.pathname:null;o||(P=P.toLowerCase(),j=j?j.toLowerCase():null,v=v.toLowerCase()),j&&E&&(j=q(j,E)||j);const B=v!=="/"&&v.endsWith("/")?v.length-1:v.length;let de=P===v||!s&&P.startsWith(v)&&P.charAt(B)==="/",we=j!=null&&(j===v||!s&&j.startsWith(v)&&j.charAt(v.length)==="/"),pe={isActive:de,isPending:we,isTransitioning:N},Re=de?n:void 0,he;typeof i=="function"?he=i(pe):he=[i,de?"active":null,we?"pending":null,N?"transitioning":null].filter(Boolean).join(" ");let Ue=typeof c=="function"?c(pe):c;return h.createElement(Et,Q({},f,{"aria-current":Re,className:he,ref:r,style:Ue,to:l,viewTransition:u}),typeof p=="function"?p(pe):p)});process.env.NODE_ENV!=="production"&&(on.displayName="NavLink");const sn=h.forwardRef((e,t)=>{let{fetcherKey:r,navigate:n,reloadDocument:o,replace:i,state:s,method:c=ge,action:l,onSubmit:u,relative:p,preventScrollReset:f,viewTransition:m}=e,w=Me(e,Qr),C=pn(),O=hn(l,{relative:p}),E=c.toLowerCase()==="get"?"get":"post",N=v=>{if(u&&u(v),v.defaultPrevented)return;v.preventDefault();let P=v.nativeEvent.submitter,j=(P==null?void 0:P.getAttribute("formmethod"))||c;C(P||v.currentTarget,{fetcherKey:r,method:j,navigate:n,replace:i,state:s,relative:p,preventScrollReset:f,viewTransition:m})};return h.createElement("form",Q({ref:t,method:E,action:O,onSubmit:o?u:N},w))});process.env.NODE_ENV!=="production"&&(sn.displayName="Form"),process.env.NODE_ENV;var xe;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(xe||(xe={}));var bt;(function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(bt||(bt={}));function ln(e){return e+" must be used within a data router. See https://reactrouter.com/v6/routers/picking-a-router."}function xt(e){let t=h.useContext(se);return t||(process.env.NODE_ENV!=="production"?x(!1,ln(e)):x(!1)),t}function un(e,t){let{target:r,replace:n,state:o,preventScrollReset:i,relative:s,viewTransition:c}=t===void 0?{}:t,l=ct(),u=Z(),p=ce(e,{relative:s});return h.useCallback(f=>{if(Kr(f,r)){f.preventDefault();let m=n!==void 0?n:oe(u)===oe(p);l(e,{replace:m,state:o,preventScrollReset:i,relative:s,viewTransition:c})}},[u,l,p,n,o,r,e,i,s,c])}function cn(){if(typeof document>"u")throw new Error("You are calling submit during the server render. Try calling submit within a `useEffect` or callback instead.")}let fn=0,dn=()=>"__"+String(++fn)+"__";function pn(){let{router:e}=xt(xe.UseSubmit),{basename:t}=h.useContext(U),r=Fr();return h.useCallback(function(n,o){o===void 0&&(o={}),cn();let{action:i,method:s,encType:c,formData:l,body:u}=Gr(n,t);if(o.navigate===!1){let p=o.fetcherKey||dn();e.fetch(p,r,o.action||i,{preventScrollReset:o.preventScrollReset,formData:l,body:u,formMethod:o.method||s,formEncType:o.encType||c,flushSync:o.flushSync})}else e.navigate(o.action||i,{preventScrollReset:o.preventScrollReset,formData:l,body:u,formMethod:o.method||s,formEncType:o.encType||c,replace:o.replace,state:o.state,fromRouteId:r,flushSync:o.flushSync,viewTransition:o.viewTransition})},[e,t,r])}function hn(e,t){let{relative:r}=t===void 0?{}:t,{basename:n}=h.useContext(U),o=h.useContext(Y);o||(process.env.NODE_ENV!=="production"?x(!1,"useFormAction must be used inside a RouteContext"):x(!1));let[i]=o.matches.slice(-1),s=Q({},ce(e||".",{relative:r})),c=Z();if(e==null){s.search=c.search;let l=new URLSearchParams(s.search),u=l.getAll("index");if(u.some(f=>f==="")){l.delete("index"),u.filter(m=>m).forEach(m=>l.append("index",m));let f=l.toString();s.search=f?"?"+f:""}}return(!e||e===".")&&i.route.index&&(s.search=s.search?s.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(s.pathname=s.pathname==="/"?n:W([n,s.pathname])),oe(s)}function mn(e,t){t===void 0&&(t={});let r=h.useContext(gt);r==null&&(process.env.NODE_ENV!=="production"?x(!1,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?"):x(!1));let{basename:n}=xt(xe.useViewTransitionState),o=ce(e,{relative:t.relative});if(!r.isTransitioning)return!1;let i=q(r.currentLocation.pathname,n)||r.currentLocation.pathname,s=q(r.nextLocation.pathname,n)||r.nextLocation.pathname;return Te(o.pathname,s)!=null||Te(o.pathname,i)!=null}function vn({appName:e,appPath:t,children:r,onStatusChange:n}){return y.jsx(y.Fragment,{children:r})}class gn extends _.Component{constructor(t){super(t),this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,r){const{appName:n,onError:o}=this.props;this.setState({errorInfo:r}),console.error(`[ErrorBoundary][${n}] 🛡️ 捕获到运行时错误:`,t),console.error(`[ErrorBoundary][${n}] 组件栈:`,r.componentStack),o==null||o(t,r)}render(){const{hasError:t,error:r,errorInfo:n}=this.state,{appName:o,children:i,onReset:s}=this.props;return t?y.jsx("div",{className:"flex items-center justify-center min-h-[400px] p-6",children:y.jsx("div",{className:"w-full max-w-lg",children:y.jsxs("div",{className:"bg-white rounded-lg shadow-lg border border-red-200 overflow-hidden",children:[y.jsx("div",{className:"bg-red-50 border-b border-red-200 px-6 py-4",children:y.jsxs("div",{className:"flex items-center gap-3",children:[y.jsx("span",{className:"text-2xl",children:"🛡️"}),y.jsxs("div",{children:[y.jsxs("h3",{className:"text-lg font-semibold text-red-800",children:["子应用 [",o,"] 运行出错"]}),y.jsx("p",{className:"text-sm text-red-600 mt-0.5",children:"该错误已被隔离,不影响其他子应用的正常运行"})]})]})}),y.jsxs("div",{className:"px-6 py-4 space-y-4",children:[r&&y.jsxs("div",{children:[y.jsx("p",{className:"text-sm font-medium text-gray-700 mb-1",children:"错误信息:"}),y.jsx("div",{className:"bg-red-50 rounded-md px-4 py-3 text-sm text-red-700 font-mono break-all",children:r.message})]}),(n==null?void 0:n.componentStack)&&y.jsxs("details",{className:"group",children:[y.jsxs("summary",{className:"text-sm font-medium text-gray-700 cursor-pointer hover:text-gray-900 select-none",children:[y.jsx("span",{className:"group-open:hidden",children:"▶ 展开错误堆栈"}),y.jsx("span",{className:"hidden group-open:inline",children:"▼ 收起错误堆栈"})]}),y.jsx("pre",{className:"mt-2 bg-gray-50 rounded-md px-4 py-3 text-xs text-gray-600 overflow-x-auto max-h-48 overflow-y-auto whitespace-pre-wrap",children:n.componentStack})]}),y.jsx("div",{className:"bg-blue-50 rounded-md px-4 py-3",children:y.jsx("p",{className:"text-sm text-blue-700",children:"点击重试会完整重载该子应用,或返回继续使用其他功能。"})})]}),y.jsxs("div",{className:"px-6 py-4 bg-gray-50 border-t border-gray-200 flex gap-3",children:[y.jsx("button",{onClick:s,className:"px-4 py-2 bg-blue-600 text-white text-sm font-medium rounded-md hover:bg-blue-700 transition-colors",children:"重试加载"}),y.jsx("button",{onClick:()=>window.history.back(),className:"px-4 py-2 bg-white text-gray-700 text-sm font-medium rounded-md border border-gray-300 hover:bg-gray-50 transition-colors",children:"返回上一页"})]})]})})}):i}}function yn({appName:e,children:t,onError:r}){const[n,o]=_.useState(0),i=_.useCallback(()=>{console.log(`[ErrorBoundary][${e}] 触发 key 重置,完整重建子应用`),o(l=>l+1)},[e]),s=_.useCallback((l,u)=>{c({type:"SET_ERROR",error:l}),r==null||r(l,u)},[r]),[,c]=_.useReducer((l,u)=>{switch(u.type){case"SET_ERROR":return{...l,hasError:!0,error:u.error??null};case"RESET_ERROR":return{...l,hasError:!1,error:null};case"ROUTE_CHANGED":return l.hasError?(i(),{...l,hasError:!1,error:null}):l;default:return l}},{hasError:!1,error:null,errorInfo:null});return _.useEffect(()=>{c({type:"ROUTE_CHANGED"})},[location.pathname]),y.jsx(gn,{appName:e,onError:s,onReset:i,children:t},n)}function En(){const[e,t]=_.useState(null),r=_.useCallback(n=>{const o=n instanceof Error?n:new Error(n);t(o)},[]);if(e)throw e;return r}function bn({url:e,containerId:t,mode:r="iframe",iframeStyle:n,onError:o,onLoad:i}){const s=_.useRef(null),c=En();async function l(u){try{const p=await fetch(u,{method:"HEAD",mode:"no-cors"});return!!(p.status===0||p.ok)}catch(p){c(p instanceof Error?p:new Error("请求失败"))}}return _.useEffect(()=>{if(!s.current)return;const u=s.current;r==="iframe"&&(async()=>{const f=document.createElement("iframe"),m=document.querySelector(".micro-app-container");return await l(e)&&(f.src=e,f.style.width="100%",f.style.height=m?m.offsetHeight+"px":"100%",f.style.border="none",f.setAttribute("sandbox","allow-same-origin allow-scripts allow-forms allow-popups allow-top-navigation"),Object.assign(f.style,n||{})),u.appendChild(f),()=>{u.contains(f)&&u.removeChild(f)}})()},[e,t,r,n,o,i]),y.jsx("div",{ref:s,id:t,style:{width:"100%",height:"100%",position:"relative"}})}function xn({apps:e}){return y.jsx(Br,{children:e.map(t=>{const r=t.active_rule?t.active_rule:`/${t.name}/*`,n=t.active_rule||`/app/${t.name}`;return y.jsx(vt,{path:r,element:y.jsx(vn,{appName:t.name,appPath:n,children:y.jsx(yn,{appName:t.name,children:y.jsx(_.Suspense,{fallback:y.jsx("div",{className:"flex items-center justify-center h-96",children:y.jsx("div",{className:"text-center",children:y.jsxs("p",{className:"mt-4 text-gray-600",children:["正在加载 ",t.name,"..."]})})}),children:y.jsx("div",{id:t.container.replace("#",""),"data-micro-app":t.name,className:"micro-app-container w-full h-full flex-1",children:t.entry&&y.jsx(bn,{url:t.entry,containerId:t.container.replace("#",""),mode:"iframe"})})})})})},t.name)})})}function wn(e){return e.active_rule?e.active_rule:`/${e.name}/*`}function Rn({apps:e,activeApp:t,onError:r,onStatusChange:n,onLoad:o,children:i}){const s=ct(),c=_.useRef(new Set),l=_.useRef({onError:r,onStatusChange:n,onLoad:o});l.current={onError:r,onStatusChange:n,onLoad:o};const u=_.useMemo(()=>Oe({apps:e,onError:l.current.onError,onStatusChange:(f,m)=>{var w,C;(C=(w=l.current).onStatusChange)==null||C.call(w,f,m)},onLoad:l.current.onLoad}),[e]);return _.useEffect(()=>{if(!t)return;const p=e.find(w=>w.name===t);if(!p)return;const f=wn(p);s(f);const m=()=>{if(!document.querySelector(p.container)){requestAnimationFrame(m);return}c.current.has(t)||(u.startApp(t),c.current.add(t))};requestAnimationFrame(m),e.forEach(w=>{w.name!==t&&c.current.has(w.name)&&(u.stopApp(w.name),c.current.delete(w.name))})},[t,e,u,s]),y.jsxs("div",{className:"micro-app-wrapper",children:[y.jsx(xn,{apps:e}),i]})}function Cn(e){return y.jsx(rn,{children:y.jsx(Rn,{...e})})}class Sn extends _.Component{constructor(r){super(r);$(this,"handleRetry",()=>{var r,n;this.setState({hasError:!1,error:null}),(n=(r=this.props).onRetry)==null||n.call(r,this.props.appName)});this.state={hasError:!1,error:null}}static getDerivedStateFromError(r){return{hasError:!0,error:r}}componentDidCatch(r,n){var o,i;console.error(`[${this.props.appName||"ErrorBoundary"}] 捕获错误:`,r,n),(i=(o=this.props).onError)==null||i.call(o,r,this.props.appName)}render(){var r;return this.state.hasError?this.props.fallback?this.props.fallback:y.jsx("div",{className:"micro-app-error flex flex-col items-center justify-center h-full p-4 bg-gray-50 rounded",children:y.jsxs("div",{className:"text-center",children:[y.jsx("div",{className:"text-red-500 text-4xl mb-2",children:"⚠️"}),y.jsxs("h3",{className:"text-lg font-semibold text-gray-800 mb-2",children:[this.props.appName||"应用"," 加载失败"]}),y.jsx("p",{className:"text-sm text-gray-500 mb-4",children:((r=this.state.error)==null?void 0:r.message)||"应用渲染时发生错误"}),y.jsx("button",{onClick:this.handleRetry,className:"px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700 transition-colors",children:"重试"})]})}):this.props.children}}const Nn="1.0.0";L.ErrorBoundary=Sn,L.MicroApp=Cn,L.createMicroApp=Oe,L.mountMicroApp=Je,L.mountMicroApps=Ht,L.version=Nn,Object.defineProperty(L,Symbol.toStringTag,{value:"Module"})});
|