@variousjs/various 5.1.1 → 5.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.
@@ -1,2 +1,3945 @@
1
- !function(){var e={700:function(e,t,r){var n;self,n=e=>(()=>{"use strict";var t={294:(e,t,r)=>{r.d(t,{default:()=>a});var n=r(942),o=r(63),s=r.n(o);function i(e,t=new WeakMap){if("object"!=typeof e||null===e)return e;if(t.has(e))return t.get(e);const r=Array.isArray(e)?[]:{};t.set(e,r);const n=Reflect.ownKeys(e);for(const o of n)r[o]=i(e[o],t);return r}class a{constructor(){var e;(0,n.Z)(this,"state",void 0),(0,n.Z)(this,"listeners",void 0),(0,n.Z)(this,"emits",void 0),(0,n.Z)(this,"timer",void 0),(0,n.Z)(this,"onStateChange",void 0),(0,n.Z)(this,"getStore",void 0),(0,n.Z)(this,"createStore",e=>{this.listeners=Reflect.ownKeys(e).reduce((t,r)=>{const n=r;return this.state[n]=e[n],{...t,[r]:[]}},{})}),(0,n.Z)(this,"subscribe",e=>{const t={};return Reflect.ownKeys(e).forEach(r=>{const n=r;this.listeners[n]||(this.listeners[n]=[]),this.listeners[n].push(e[n]),t[n]=e[n]}),()=>{Reflect.ownKeys(t).forEach(e=>{const r=e;this.listeners[r]=this.listeners[r].filter(e=>e!==t[r])})}}),(0,n.Z)(this,"emit",(e,t)=>{this.emits={...this.emits,...e},t?this.trigger():(clearTimeout(this.timer),this.timer=setTimeout(this.trigger))}),(0,n.Z)(this,"dispatch",(e,...t)=>e({getStore:this.getStore,emit:e=>this.emit(e,!0)},...t)),(0,n.Z)(this,"trigger",()=>{const e=this.emits,t=[],r=Reflect.ownKeys(e);for(let n=0;n<r.length;n+=1){const o=r[n];if(s()(this.state[o],e[o]))continue;const a=e[o],u=this.state[o];this.state[o]=i(e[o]),t.push({key:o,newValue:a,oldValue:u})}const n={};t.forEach(e=>{n[e.key]=[e.newValue,e.oldValue],this.listeners[e.key]&&this.listeners[e.key].forEach(t=>t(e.newValue,e.oldValue))}),t.length&&this.onStateChange(n),this.emits={},this.timer=void 0}),this.state={},this.listeners={},this.emits={},this.timer=void 0,this.onStateChange=()=>null,this.getStore=(e=this.state,function(t){return t?i(e[t]):e})}set onChange(e){this.onStateChange=e}}},63:e=>{e.exports=function e(t,r){if(t===r)return!0;if(t&&r&&"object"==typeof t&&"object"==typeof r){if(t.constructor!==r.constructor)return!1;var n,o,s;if(Array.isArray(t)){if((n=t.length)!=r.length)return!1;for(o=n;0!=o--;)if(!e(t[o],r[o]))return!1;return!0}if(t.constructor===RegExp)return t.source===r.source&&t.flags===r.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===r.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===r.toString();if((n=(s=Object.keys(t)).length)!==Object.keys(r).length)return!1;for(o=n;0!=o--;)if(!Object.prototype.hasOwnProperty.call(r,s[o]))return!1;for(o=n;0!=o--;){var i=s[o];if(!e(t[i],r[i]))return!1}return!0}return t!=t&&r!=r}},250:t=>{t.exports=e},942:(e,t,r)=>{function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}r.d(t,{Z:()=>n})}},r={};function n(e){var o=r[e];if(void 0!==o)return o.exports;var s=r[e]={exports:{}};return t[e](s,s.exports,n),s.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var o={};return(()=>{n.d(o,{default:()=>u});var e=n(942),t=n(294),r=n(250),s=n.n(r);const i=["name","prototype","length","propTypes","defaultProps","getDerivedStateFromProps","contextTypes","displayName"];class a extends t.default{constructor(...t){super(...t),(0,e.Z)(this,"connect",function(t){const{getStore:n,subscribe:o}=t;return function(...t){return function(a){class u extends r.Component{constructor(r){super(r),(0,e.Z)(this,"unsubscribe",void 0),(0,e.Z)(this,"state",{props:n()}),this.unsubscribe=o(t.reduce((e,t)=>({...e,[t]:()=>{this.setState({props:n()})}}),{}))}componentWillUnmount(){this.unsubscribe()}render(){const{props:e}=this.state,t={...e,...this.props};return s().createElement(a,t)}}return Object.getOwnPropertyNames(a).forEach(e=>{const t=e;i.includes(e)||(u[t]=a[t])}),u}}}(this)),(0,e.Z)(this,"useStore",function(e){const{getStore:t,subscribe:n}=e;return function(...e){const[o,s]=(0,r.useState)(t());return(0,r.useLayoutEffect)(()=>n(e.reduce((e,r)=>({...e,[r]:()=>{s(e=>({...e,[r]:t()[r]}))}}),{}))),o}}(this))}}const u=a})(),o.default})(),e.exports=n(r(953))},953:function(e){"use strict";e.exports=require("react")}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var s=t[n]={exports:{}};return e[n](s,s.exports,r),s.exports}r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,{a:t}),t},r.d=function(e,t){for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};!function(){"use strict";function e(){return e=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},e.apply(null,arguments)}r.r(n),r.d(n,{createComponent:function(){return Q},createConfig:function(){return X}});var t=r(953),o=r.n(t),s=r(700),i=r.n(s);const{createStore:a,getStore:u,connect:c,emit:l,subscribe:d,dispatch:m,useStore:p}=new(i());function f(){const e=u(),t=Object.keys(e),r={};return t.forEach(t=>{r[t]=e[t]}),r}const g=e=>{const t=U(e.$self,"various-component-fallback");return o().createElement("div",{className:t},"Loading")},h=({$error:e,$reload:t,$self:r})=>{const n=U(r,"various-component-error_fallback");return o().createElement("div",{className:n},o().createElement("h3",null,e.type),o().createElement("p",null,e.message),o().createElement("button",{type:"button",onClick:t},"Reload"))};var y=new class{constructor(){this.fallbackComponent=g,this.errorFallbackComponent=h,this.storeActions={},this.componentActions={},this.i18nConfigs={},this.middlewares={}}setMiddlewares(e){this.middlewares=e}getMiddlewares(){return this.middlewares}setI18nConfig(e,t){const r=P(e);this.i18nConfigs[r]={...this.i18nConfigs[r],...t}}getI18nConfig(e){const t=P(e);return this.i18nConfigs[t]}setGlobalI18nConfig(e){this.globalI18nConfig={...this.globalI18nConfig,...e}}getGlobalI18nConfig(){return this.globalI18nConfig}setComponentActions(e,t){const r=P(e);this.componentActions[r]=t}deleteComponentActions(e){const t=P(e);delete this.componentActions[t]}getComponentActions(e){const t=P(e);return this.componentActions[t]}setStoreActions(e){this.storeActions=e}getStoreActions(){return this.storeActions}setFallbackComponent(e){this.fallbackComponent=e}getFallbackComponent(){return this.fallbackComponent}setErrorFallbackComponent(e){this.errorFallbackComponent=e}getErrorFallbackComponent(){return this.errorFallbackComponent}};const w=e=>{const t=y.getMiddlewares(),r=t?.onLog?.(e);if(!1===r)return;const n={info:"blue",warn:"orange",error:"red"}[e.level],o=[`%c ${P(e)} `,`background:${n};border:1px solid ${n};padding:1px;border-radius:2px 0 0 2px;color: #fff;`];e.type&&(o[0]=`${o[0]}%c ${e.type} %c`,o.push(`border:1px solid ${n};padding:1px;border-radius:0 2px 2px 0;color:${n};`,"background:transparent")),"info"!==e.level&&(o[0]=` ${o[0]}`),window.console[e.level](...o,e.message)};var E=e=>({info(t,r){w({...e,level:"info",type:r,message:t})},warn(t,r){w({...e,level:"warn",type:r,message:t})},error(t,r){const n=y.getMiddlewares(),o=t instanceof A?t:new A({...e,type:r||"unknow",originalError:t instanceof Error?t:new Error(t)});n?.onError?.(o),w({...e,level:"error",type:r,message:t})}});const v=Symbol("MOUNTED_COMPONENTS"),b=Symbol("MESSAGE"),C=Symbol("CONFIG"),$=Symbol("DEPENDENCIES"),S=["beforeCreate","created","beforeMount","mounted","beforeUpdate","updated","beforeUnmount","unmounted","errorCaptured","renderTracked","renderTriggered","activated","deactivated","setup","data","render"],O=e=>async(t,r)=>{const n=y.getMiddlewares(),o=E(e);let s={trigger:e,event:t,value:r};if(n?.onMessage){const e=await n.onMessage(s);if(!1===e)return void o.warn("blocked by middleware","POST_MESSAGE");!0!==e&&(s={...s,...e})}l({[b]:{timestamp:+new Date,event:s.event,trigger:e,value:s.value}})};function R(e,t){const r=(t,r,n)=>{const o=y.getI18nConfig(e)||y.getGlobalI18nConfig();let s=n;if(void 0===s&&(s="string"==typeof r?r:t),!o)return x(new A({...e,type:"I18N",originalError:new Error("config not exist")})),s;if(o.loading)return s;const{lngStoreKey:i,resources:a}=o,c=u(i);if(void 0===i||void 0===c)return x(new A({...e,type:"I18N",originalError:new Error("locale key not defined")})),s;const l=a?.[c];if(!l)return x(new A({...e,type:"I18N",originalError:new Error(`locale resource \`${c}\` not exist`)})),s;if(!l[t])return x(new A({...e,type:"I18N",originalError:new Error(`locale key \`${t}\` not exist`)})),s;const d=l[t];if(!r||"string"==typeof r||"[object Object]"!==Object.prototype.toString.call(r))return d;const m=Object.keys(r);return m.length?m.reduce((e,t)=>{const n=new RegExp(`{\\s*${t}\\s*}`,"g");return e.replace(n,r[t].toString())},d):d};return r.update=(r,n)=>{const o={..."app"===n?y.getGlobalI18nConfig():y.getI18nConfig(e),...r};"app"===n?y.setGlobalI18nConfig(o):y.setI18nConfig(e,o),t()},r}const N=e=>`${e}?${+new Date}`,I=e=>window.requirejs.defined(e),j=e=>window.requirejs.specified(e),k=()=>u(v),M=(e,t)=>{const r=u($);if(t&&window.requirejs.defined(e))return;let n=N(r[e]);if(t){n=`${t}#${e}`;try{const{registry:r}=window.requirejs.s.contexts._;r?.[e].error&&(n=N(t))}catch(e){}}window.requirejs.undef(e),window.requirejs.config({paths:{[e]:n}})},P=e=>{const{name:t,module:r}=e;return r?`${t}.${r}`:t},x=e=>{const{name:t,module:r,type:n}=e;E({name:t,module:r}).error(e,n)};class A extends Error{constructor(e){super(e.originalError.message),this.type=e.type,this.originalError=e.originalError,this.module=e.module,this.name=e.name}}function D(e){const{componentNode:t,name:r,module:n,type:o,i18nUpdate:s}=e,i={};let a,c;return Object.getOwnPropertyNames(t).forEach(e=>{"function"==typeof t[e]&&("$onMessage"!==e?"$i18n"!==e?"vue3"===o&&S.includes(e)||(i[e]=t[e]):c=t[e]:a=t[e])}),c&&function(e,t,r){if(!e)return;const n=e();var o;null!=(o=n)&&"function"==typeof o.then?(t?y.setI18nConfig(t,{loading:!0,lngStoreKey:"",resources:{}}):y.setGlobalI18nConfig({loading:!0,lngStoreKey:"",resources:{}}),n.then(e=>{if(t)return y.setI18nConfig(t,{...e,loading:!1}),void r?.();const n=u(e.lngStoreKey);l({[e.lngStoreKey]:void 0},!0),l({[e.lngStoreKey]:n},!0),y.setGlobalI18nConfig({...e,loading:!1})}).catch(e=>{x(new A({name:t?.name||"app",module:t?.module,type:"I18N",originalError:e}))})):t?y.setI18nConfig(t,n):y.setGlobalI18nConfig(n)}(c,{name:r,module:n},s),y.setComponentActions({name:r,module:n},i),a?(m={name:r,module:n},p=a,d({[b](e){const{trigger:t,value:r,event:n}=e;m.name===t.name&&m.module===t.module||p({event:n,value:r,trigger:t})}})):()=>null;var m,p}function _(e){const t=k();((e,t)=>e.some(e=>e.name===t.name&&e.module===t.module))(t,e)||t.push(e),l({[v]:t},!0)}function T(e){const{name:t,module:r}=e;let n=k();n=n.filter(e=>e.name!==t||e.module!==r),l({[v]:n},!0),y.deleteComponentActions({name:t,module:r})}function F(e){const{name:t,module:r,url:n}=e,o=u($);return{name:t,module:r,url:n||o[t]}}function U(e,t){const{name:r,module:n}=e;return`${t} ${[r,n].filter(Boolean).join("-")}`}var q=e=>async function(t){const r=y.getMiddlewares(),n=E(e);let{name:o,module:s,action:i,value:a}=t;if(r?.onDispatch){const t=await r.onDispatch({target:{name:o,module:s},action:i,value:a,trigger:e});if(!1===t)return n.warn("blocked by middleware","DISPATCH"),Promise.resolve();!0!==t&&(o=t.target.name,s=t.target.module,i=t.action,a=t.value)}if("app"===o){const t=y.getStoreActions()[i];if(!t){const t=`action "${i}" is not present`,r=new A({...e,type:"DISPATCH",originalError:new Error(t)});throw x(r),r}return m(t,a,e)}const u=y.getComponentActions({name:o,module:s});if(!u){const t="component is not ready",r=new A({...e,type:"DISPATCH",originalError:new Error(t)});throw x(r),r}const c=u[i];if(!c){const t=`action "${i}" is not present`,r=new A({...e,type:"DISPATCH",originalError:new Error(t)});throw x(r),r}return Promise.resolve(c(a,e))},Z=(e,t=!0)=>{const r=u($),n=y.getMiddlewares(),{name:o,module:s,url:i}=e,a=+new Date,c=e=>{t&&x(e)};return i&&M(o,i),new Promise((e,t)=>{if(!i&&!r[o]&&!j(o)){const e=new A({name:o,module:s,type:"NOT_DEFINED",originalError:new Error(`module "${o}" not defined`)});return c(e),void t(e)}window.requirejs([o],r=>{const i=+new Date;if(n?.onLoad?.({name:o,module:s,loadStart:a,loadEnd:i,beenLoaded:I(o)}),!r){const e=new A({name:o,module:s,type:"INVALID_MODULE",originalError:new Error(`module "${o}" invalid`)});return M(o),c(e),void t(e)}const u="default"in r?r.default:r,l=s?r[s]:u;if(void 0===l&&s){const e=new A({name:o,module:s,type:"SUBMODULE_NOT_DEFINED",originalError:new Error(`submodule "${s}" not defined`)});return M(o),c(e),void t(e)}e(l)},e=>{const[r]=e.requireModules;M(o,i),M(r);let n="LOADING_ERROR";r!==o&&(n="SUBMODULE_LOADING_ERROR"),e.message.includes("https://requirejs.org/docs/errors.html")||(n=r===o?"SCRIPT_ERROR":"SUBMODULE_SCRIPT_ERROR");const s=new A({name:o,module:r===o?void 0:r,type:n,originalError:e});c(s),t(s)})})},K=function(r){const{name:n,module:s,url:i,watchKeys:a,onMounted:l}=r,d=a||Object.keys(u());class m extends t.Component{static displayName="various-react-component";state={componentReady:!1,isError:!1};unSubscribeMessage=()=>null;componentDidMount(){this.mountComponent()}componentWillUnmount(){this.error=void 0,this.ComponentNode=null,this.isUnMounted=!0,this.unSubscribeMessage(),T({name:n,module:s})}mountComponent=async()=>{try{const r=await Z({name:n,module:s,url:i},!1);if(this.isUnMounted)return;await(e=r,t={name:n,module:s},new Promise((r,n)=>{e.$$typeof||e.prototype?.isReactComponent||"function"==typeof e?r():n(new A({...t,originalError:new Error("not a valid React component"),type:"INVALID_COMPONENT"}))})),r.displayName=P({name:n,module:s}),_({name:n,module:s}),this.unSubscribeMessage=D({componentNode:r,name:n,module:s,i18nUpdate:()=>this.forceUpdate()}),this.ComponentNode=r,this.setState({componentReady:!0}),l?.()}catch(e){if(this.isUnMounted)return;this.error=e,this.setState({componentReady:!0,isError:!0})}var e,t};$postMessage=O({name:n,module:s});$dispatch=q({name:n,module:s});$t=R({name:n,module:s},()=>this.forceUpdate());$logger=E({name:n,module:s});$self=F({name:n,module:s,url:i});render(){const t=y.getFallbackComponent(),{$silent:r,$componentProps:s,$ref:i}=this.props,{componentReady:a,isError:u}=this.state,c=f(),l=this.ComponentNode;if(u)throw this.error;return a?o().createElement(l,e({},s,{$self:this.$self,$dispatch:this.$dispatch,$store:c,$postMessage:this.$postMessage,$t:this.$t,$logger:this.$logger,ref:i})):r||I(n)?null:o().createElement(t,{$self:this.$self,$store:c})}}const p=c(...d)(m);return p.displayName="various-connector",p},L=function(e){const{name:r,module:n,url:s,watchKeys:i,onMounted:a}=e,c=i||Object.keys(u()),l=e=>{const i=p(...c),u=(0,t.useRef)(),l=(0,t.useRef)(!1),d=(0,t.useRef)(),m=(0,t.useRef)(!1),f=(0,t.useRef)(),g=(0,t.useRef)(F({name:r,module:n,url:s})),h=(0,t.useRef)(null),w=(0,t.useRef)(),v=(0,t.useRef)(),b=(0,t.useRef)(),C=(0,t.useRef)(),$=(0,t.useRef)(),[S,N]=(0,t.useState)(!1),[j,k]=(0,t.useState)(!1),M=y.getFallbackComponent(),{$silent:P,$componentProps:x}=e,K=(0,t.useCallback)(()=>{const e=E({name:r,module:n}),t=q({name:r,module:n}),o=O({name:r,module:n}),s=R({name:r,module:n},()=>{$.current?.()});w.current=u.current.ref({...x}),v.current=u.current.ref({...i});const a=u.current.createApp({setup(){const e=u.current.ref(0);return $.current=()=>{e.value+=1},{key:e}},errorCaptured(e){const t=e;d.current=t.message?.includes("https://react")?new A({originalError:new Error("not a valid Vue component"),name:r,module:n,type:"INVALID_COMPONENT"}):t,k(!0)},render(){return u.current.h(f.current,{...w.current.value,various:{$dispatch:t,$logger:e,$postMessage:o,$t:s,$store:v.current.value,$self:g.current},key:this.key})}});a.mount(h.current),l.current=!0,b.current=()=>a.unmount()},[x,i]),L=(0,t.useCallback)(async()=>{try{const e=await Z({name:"vue"});u.current=e;const t=await Z({name:r,module:n,url:s},!1);if(m.current)return;await function(e,t){const r=new RegExp("^3\\.");return new Promise((n,o)=>{window.requirejs(["vue"],s=>{r.test(s.version)||o(new Error("Vue 3+ required, detected an incompatible version")),"function"!=typeof e?.render&&"function"!=typeof e?.setup?o(new A({...t,originalError:new Error("not a valid Vue component"),type:"INVALID_COMPONENT"})):n()})})}(t,{name:r,module:n}),_({name:r,module:n}),C.current=D({componentNode:t,name:r,module:n,type:"vue3",i18nUpdate(){$.current?.()}}),f.current=t,setTimeout(K),N(!0),a?.()}catch(e){if(m.current)return;d.current=e,N(!0),k(!0)}},[K]);if((0,t.useEffect)(()=>()=>{d.current=void 0,f.current=void 0,m.current=!0,T({name:r,module:n}),b.current?.(),C.current?.(),l.current=!1},[]),(0,t.useEffect)(()=>{l.current||L()},[L]),(0,t.useEffect)(()=>{w.current&&(w.current.value={...x})},[x]),(0,t.useEffect)(()=>{v.current&&(v.current.value={...i})},[i]),j)throw d.current;return o().createElement(o().Fragment,null,S||P||I(r)?null:o().createElement(M,{$self:g.current,$store:i}),o().createElement("div",{className:U({name:r,module:n},"various-vue-component"),ref:h}))};l.displayName=P({name:r,module:n});const d=e=>o().createElement(l,e);return d.displayName="various-vue-component",d};class G extends t.Component{static displayName="various-error-boundary";state={hasError:!1};componentDidCatch(e){const{name:t,module:r}=this.props,n=e instanceof A?e:new A({name:t,module:r,type:"app"===t?"APP_ERROR":"SCRIPT_ERROR",originalError:e});this.setState({hasError:!0}),this.error=n,x(n),M(this.props.name),T({name:t,module:r})}$self=F(this.props);reload=()=>{this.error=void 0,this.setState({hasError:!1})};render(){const e=y.getErrorFallbackComponent(),t=f();return this.state.hasError?o().createElement(e,{$self:this.$self,$reload:this.reload,$store:t,$error:this.error}):this.props.children}}var V=G,B=(e,t)=>{const{name:r,module:n,url:s,type:i="react"}=e,a=("vue3"===i?L:K)({name:r,module:n,url:s,watchKeys:t}),u=e=>{const{$silent:t,$ref:i,...u}=e||{},c={$componentProps:u,$silent:t,$ref:i};return o().createElement(V,{name:r,module:n,url:s},o().createElement(a,c))};return u.displayName="various-creator",u};let H;function W(e){if(H)return H;const t=new Promise((t,r)=>{if(e){if("string"==typeof e){const n=document.createElement("script");return n.src=e,n.onload=e=>t(e),n.onerror=e=>r(e),void document.head.appendChild(n)}window.requirejs=e,t(new Event("requirejs defined"))}else r(new A({name:"standalone",type:"NOT_DEFINED",originalError:new Error("requirejs not defined")}))});return H=t,H}function z(e){Object.entries(e).forEach(([e,t])=>{j(e)||("string"!=typeof t?window.define(e,[],()=>t):window.requirejs.config({paths:{[e]:`${t}#${e}`}}))})}a({[v]:[],[b]:null,[C]:{},[$]:{}});const J=r=>{const{dependencies:n,url:s,name:i,module:a,type:u,$componentProps:c,$ref:l,storeKeys:d}=r,[m,p]=(0,t.useState)(!1),g=(0,t.useRef)(),h=(0,t.useRef)(),[w,E]=(0,t.useState)(!1);if((0,t.useEffect)(()=>{W(n?.requirejs).then(()=>{const{requirejs:e,...t}=n||{};z(t),g.current=B({name:i,module:a,url:s,type:u},d),p(!0)}).catch(e=>{h.current=e,E(!0)})},[i,s,a,n,u,d]),w)throw h.current;if(!m){const e=y.getFallbackComponent();return o().createElement(e,{$self:{name:i,module:a,url:s},$store:f()})}const v=g.current;return o().createElement(v,e({},c,{ref:l}))};J.displayName="various-standalone";const Q=t=>{const r=r=>o().createElement(V,{name:"standalone",url:t.url,module:t.module},o().createElement(J,e({$componentProps:r},t)));return r.displayName="various-standalone-creator",Object.assign(r,{dispatch:e=>{l(e,!0)}})},X=e=>{const{baseDependencies:t,errorFallback:r,fallback:n,store:o}=e,{requirejs:s,...i}=t;r&&y.setErrorFallbackComponent(r),n&&y.setFallbackComponent(n),o&&l(o),W(s).then(()=>{z(i)}).catch(e=>{x(new A({name:"standalone",type:"CONFIG_ERROR",originalError:e}))})}}(),module.exports=n}();
1
+ /******/ (function() { // webpackBootstrap
2
+ /******/ var __webpack_modules__ = ({
3
+
4
+ /***/ "./node_modules/@babel/runtime/helpers/esm/extends.js":
5
+ /*!************************************************************!*\
6
+ !*** ./node_modules/@babel/runtime/helpers/esm/extends.js ***!
7
+ \************************************************************/
8
+ /***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9
+
10
+ "use strict";
11
+ __webpack_require__.r(__webpack_exports__);
12
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
13
+ /* harmony export */ "default": function() { return /* binding */ _extends; }
14
+ /* harmony export */ });
15
+ function _extends() {
16
+ return _extends = Object.assign ? Object.assign.bind() : function (n) {
17
+ for (var e = 1; e < arguments.length; e++) {
18
+ var t = arguments[e];
19
+ for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
20
+ }
21
+ return n;
22
+ }, _extends.apply(null, arguments);
23
+ }
24
+
25
+
26
+ /***/ }),
27
+
28
+ /***/ "./node_modules/@variousjs/requirejs/require.js":
29
+ /*!******************************************************!*\
30
+ !*** ./node_modules/@variousjs/requirejs/require.js ***!
31
+ \******************************************************/
32
+ /***/ (function() {
33
+
34
+ /** vim: et:ts=4:sw=4:sts=4
35
+ * @license RequireJS 2.3.6 Copyright jQuery Foundation and other contributors.
36
+ * Released under MIT license, https://github.com/requirejs/requirejs/blob/master/LICENSE
37
+ */
38
+ //Not using strict: uneven strict support in browsers, #392, and causes
39
+ //problems with requirejs.exec()/transpiler plugins that may not be strict.
40
+ /*jslint regexp: true, nomen: true, sloppy: true */
41
+ /*global window, navigator, document, importScripts, setTimeout, opera */
42
+
43
+ var requirejs, require, define;
44
+ (function (global, setTimeout) {
45
+ var req, s, head, baseElement, dataMain, src,
46
+ interactiveScript, currentlyAddingScript, mainScript, subPath,
47
+ version = '2.3.6',
48
+ commentRegExp = /\/\*[\s\S]*?\*\/|([^:"'=]|^)\/\/.*$/mg,
49
+ cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,
50
+ jsSuffixRegExp = /\.js$/,
51
+ currDirRegExp = /^\.\//,
52
+ op = Object.prototype,
53
+ ostring = op.toString,
54
+ hasOwn = op.hasOwnProperty,
55
+ isBrowser = !!(typeof window !== 'undefined' && typeof navigator !== 'undefined' && window.document),
56
+ isWebWorker = !isBrowser && typeof importScripts !== 'undefined',
57
+ //PS3 indicates loaded and complete, but need to wait for complete
58
+ //specifically. Sequence is 'loading', 'loaded', execution,
59
+ // then 'complete'. The UA check is unfortunate, but not sure how
60
+ //to feature test w/o causing perf issues.
61
+ readyRegExp = isBrowser && navigator.platform === 'PLAYSTATION 3' ?
62
+ /^complete$/ : /^(complete|loaded)$/,
63
+ defContextName = '_',
64
+ //Oh the tragedy, detecting opera. See the usage of isOpera for reason.
65
+ isOpera = typeof opera !== 'undefined' && opera.toString() === '[object Opera]',
66
+ contexts = {},
67
+ cfg = {},
68
+ globalDefQueue = [],
69
+ useInteractive = false;
70
+
71
+ //Could match something like ')//comment', do not lose the prefix to comment.
72
+ function commentReplace(match, singlePrefix) {
73
+ return singlePrefix || '';
74
+ }
75
+
76
+ function isFunction(it) {
77
+ return ostring.call(it) === '[object Function]';
78
+ }
79
+
80
+ function isArray(it) {
81
+ return ostring.call(it) === '[object Array]';
82
+ }
83
+
84
+ /**
85
+ * Helper function for iterating over an array. If the func returns
86
+ * a true value, it will break out of the loop.
87
+ */
88
+ function each(ary, func) {
89
+ if (ary) {
90
+ var i;
91
+ for (i = 0; i < ary.length; i += 1) {
92
+ if (ary[i] && func(ary[i], i, ary)) {
93
+ break;
94
+ }
95
+ }
96
+ }
97
+ }
98
+
99
+ /**
100
+ * Helper function for iterating over an array backwards. If the func
101
+ * returns a true value, it will break out of the loop.
102
+ */
103
+ function eachReverse(ary, func) {
104
+ if (ary) {
105
+ var i;
106
+ for (i = ary.length - 1; i > -1; i -= 1) {
107
+ if (ary[i] && func(ary[i], i, ary)) {
108
+ break;
109
+ }
110
+ }
111
+ }
112
+ }
113
+
114
+ function hasProp(obj, prop) {
115
+ return hasOwn.call(obj, prop);
116
+ }
117
+
118
+ function getOwn(obj, prop) {
119
+ return hasProp(obj, prop) && obj[prop];
120
+ }
121
+
122
+ /**
123
+ * Cycles over properties in an object and calls a function for each
124
+ * property value. If the function returns a truthy value, then the
125
+ * iteration is stopped.
126
+ */
127
+ function eachProp(obj, func) {
128
+ var prop;
129
+ for (prop in obj) {
130
+ if (hasProp(obj, prop)) {
131
+ if (func(obj[prop], prop)) {
132
+ break;
133
+ }
134
+ }
135
+ }
136
+ }
137
+
138
+ /**
139
+ * Simple function to mix in properties from source into target,
140
+ * but only if target does not already have a property of the same name.
141
+ */
142
+ function mixin(target, source, force, deepStringMixin) {
143
+ if (source) {
144
+ eachProp(source, function (value, prop) {
145
+ if (force || !hasProp(target, prop)) {
146
+ if (deepStringMixin && typeof value === 'object' && value &&
147
+ !isArray(value) && !isFunction(value) &&
148
+ !(value instanceof RegExp)) {
149
+
150
+ if (!target[prop]) {
151
+ target[prop] = {};
152
+ }
153
+ mixin(target[prop], value, force, deepStringMixin);
154
+ } else {
155
+ target[prop] = value;
156
+ }
157
+ }
158
+ });
159
+ }
160
+ return target;
161
+ }
162
+
163
+ //Similar to Function.prototype.bind, but the 'this' object is specified
164
+ //first, since it is easier to read/figure out what 'this' will be.
165
+ function bind(obj, fn) {
166
+ return function () {
167
+ return fn.apply(obj, arguments);
168
+ };
169
+ }
170
+
171
+ function scripts() {
172
+ return document.getElementsByTagName('script');
173
+ }
174
+
175
+ function defaultOnError(err) {
176
+ throw err;
177
+ }
178
+
179
+ //Allow getting a global that is expressed in
180
+ //dot notation, like 'a.b.c'.
181
+ function getGlobal(value) {
182
+ if (!value) {
183
+ return value;
184
+ }
185
+ var g = global;
186
+ each(value.split('.'), function (part) {
187
+ g = g[part];
188
+ });
189
+ return g;
190
+ }
191
+
192
+ /**
193
+ * Constructs an error with a pointer to an URL with more information.
194
+ * @param {String} id the error ID that maps to an ID on a web page.
195
+ * @param {String} message human readable error.
196
+ * @param {Error} [err] the original error, if there is one.
197
+ *
198
+ * @returns {Error}
199
+ */
200
+ function makeError(id, msg, err, requireModules) {
201
+ var e = new Error(msg + '\nhttps://requirejs.org/docs/errors.html#' + id);
202
+ e.requireType = id;
203
+ e.requireModules = requireModules;
204
+ if (err) {
205
+ e.originalError = err;
206
+ }
207
+ return e;
208
+ }
209
+
210
+ if (typeof define !== 'undefined') {
211
+ //If a define is already in play via another AMD loader,
212
+ //do not overwrite.
213
+ return;
214
+ }
215
+
216
+ if (typeof requirejs !== 'undefined') {
217
+ if (isFunction(requirejs)) {
218
+ //Do not overwrite an existing requirejs instance.
219
+ return;
220
+ }
221
+ cfg = requirejs;
222
+ requirejs = undefined;
223
+ }
224
+
225
+ //Allow for a require config object
226
+ if (typeof require !== 'undefined' && !isFunction(require)) {
227
+ //assume it is a config object.
228
+ cfg = require;
229
+ require = undefined;
230
+ }
231
+
232
+ function newContext(contextName) {
233
+ var inCheckLoaded, Module, context, handlers,
234
+ checkLoadedTimeoutId,
235
+ config = {
236
+ //Defaults. Do not set a default for map
237
+ //config to speed up normalize(), which
238
+ //will run faster if there is no default.
239
+ waitSeconds: 7,
240
+ baseUrl: './',
241
+ paths: {},
242
+ bundles: {},
243
+ pkgs: {},
244
+ shim: {},
245
+ config: {}
246
+ },
247
+ registry = {},
248
+ //registry of just enabled modules, to speed
249
+ //cycle breaking code when lots of modules
250
+ //are registered, but not activated.
251
+ enabledRegistry = {},
252
+ undefEvents = {},
253
+ defQueue = [],
254
+ defined = {},
255
+ urlFetched = {},
256
+ bundlesMap = {},
257
+ requireCounter = 1,
258
+ unnormalizedCounter = 1;
259
+
260
+ /**
261
+ * Trims the . and .. from an array of path segments.
262
+ * It will keep a leading path segment if a .. will become
263
+ * the first path segment, to help with module name lookups,
264
+ * which act like paths, but can be remapped. But the end result,
265
+ * all paths that use this function should look normalized.
266
+ * NOTE: this method MODIFIES the input array.
267
+ * @param {Array} ary the array of path segments.
268
+ */
269
+ function trimDots(ary) {
270
+ var i, part;
271
+ for (i = 0; i < ary.length; i++) {
272
+ part = ary[i];
273
+ if (part === '.') {
274
+ ary.splice(i, 1);
275
+ i -= 1;
276
+ } else if (part === '..') {
277
+ // If at the start, or previous value is still ..,
278
+ // keep them so that when converted to a path it may
279
+ // still work when converted to a path, even though
280
+ // as an ID it is less than ideal. In larger point
281
+ // releases, may be better to just kick out an error.
282
+ if (i === 0 || (i === 1 && ary[2] === '..') || ary[i - 1] === '..') {
283
+ continue;
284
+ } else if (i > 0) {
285
+ ary.splice(i - 1, 2);
286
+ i -= 2;
287
+ }
288
+ }
289
+ }
290
+ }
291
+
292
+ /**
293
+ * Given a relative module name, like ./something, normalize it to
294
+ * a real name that can be mapped to a path.
295
+ * @param {String} name the relative name
296
+ * @param {String} baseName a real name that the name arg is relative
297
+ * to.
298
+ * @param {Boolean} applyMap apply the map config to the value. Should
299
+ * only be done if this normalization is for a dependency ID.
300
+ * @returns {String} normalized name
301
+ */
302
+ function normalize(name, baseName, applyMap) {
303
+ var pkgMain, mapValue, nameParts, i, j, nameSegment, lastIndex,
304
+ foundMap, foundI, foundStarMap, starI, normalizedBaseParts,
305
+ baseParts = (baseName && baseName.split('/')),
306
+ map = config.map,
307
+ starMap = map && map['*'];
308
+
309
+ //Adjust any relative paths.
310
+ if (name) {
311
+ name = name.split('/');
312
+ lastIndex = name.length - 1;
313
+
314
+ // If wanting node ID compatibility, strip .js from end
315
+ // of IDs. Have to do this here, and not in nameToUrl
316
+ // because node allows either .js or non .js to map
317
+ // to same file.
318
+ if (config.nodeIdCompat && jsSuffixRegExp.test(name[lastIndex])) {
319
+ name[lastIndex] = name[lastIndex].replace(jsSuffixRegExp, '');
320
+ }
321
+
322
+ // Starts with a '.' so need the baseName
323
+ if (name[0].charAt(0) === '.' && baseParts) {
324
+ //Convert baseName to array, and lop off the last part,
325
+ //so that . matches that 'directory' and not name of the baseName's
326
+ //module. For instance, baseName of 'one/two/three', maps to
327
+ //'one/two/three.js', but we want the directory, 'one/two' for
328
+ //this normalization.
329
+ normalizedBaseParts = baseParts.slice(0, baseParts.length - 1);
330
+ name = normalizedBaseParts.concat(name);
331
+ }
332
+
333
+ trimDots(name);
334
+ name = name.join('/');
335
+ }
336
+
337
+ //Apply map config if available.
338
+ if (applyMap && map && (baseParts || starMap)) {
339
+ nameParts = name.split('/');
340
+
341
+ outerLoop: for (i = nameParts.length; i > 0; i -= 1) {
342
+ nameSegment = nameParts.slice(0, i).join('/');
343
+
344
+ if (baseParts) {
345
+ //Find the longest baseName segment match in the config.
346
+ //So, do joins on the biggest to smallest lengths of baseParts.
347
+ for (j = baseParts.length; j > 0; j -= 1) {
348
+ mapValue = getOwn(map, baseParts.slice(0, j).join('/'));
349
+
350
+ //baseName segment has config, find if it has one for
351
+ //this name.
352
+ if (mapValue) {
353
+ mapValue = getOwn(mapValue, nameSegment);
354
+ if (mapValue) {
355
+ //Match, update name to the new value.
356
+ foundMap = mapValue;
357
+ foundI = i;
358
+ break outerLoop;
359
+ }
360
+ }
361
+ }
362
+ }
363
+
364
+ //Check for a star map match, but just hold on to it,
365
+ //if there is a shorter segment match later in a matching
366
+ //config, then favor over this star map.
367
+ if (!foundStarMap && starMap && getOwn(starMap, nameSegment)) {
368
+ foundStarMap = getOwn(starMap, nameSegment);
369
+ starI = i;
370
+ }
371
+ }
372
+
373
+ if (!foundMap && foundStarMap) {
374
+ foundMap = foundStarMap;
375
+ foundI = starI;
376
+ }
377
+
378
+ if (foundMap) {
379
+ nameParts.splice(0, foundI, foundMap);
380
+ name = nameParts.join('/');
381
+ }
382
+ }
383
+
384
+ // If the name points to a package's name, use
385
+ // the package main instead.
386
+ pkgMain = getOwn(config.pkgs, name);
387
+
388
+ return pkgMain ? pkgMain : name;
389
+ }
390
+
391
+ function removeScript(name) {
392
+ if (isBrowser) {
393
+ each(scripts(), function (scriptNode) {
394
+ if (scriptNode.getAttribute('data-requiremodule') === name &&
395
+ scriptNode.getAttribute('data-requirecontext') === context.contextName) {
396
+ scriptNode.parentNode.removeChild(scriptNode);
397
+ return true;
398
+ }
399
+ });
400
+ }
401
+ }
402
+
403
+ function hasPathFallback(id) {
404
+ var pathConfig = getOwn(config.paths, id);
405
+ if (pathConfig && isArray(pathConfig) && pathConfig.length > 1) {
406
+ //Pop off the first array value, since it failed, and
407
+ //retry
408
+ pathConfig.shift();
409
+ context.require.undef(id);
410
+
411
+ //Custom require that does not do map translation, since
412
+ //ID is "absolute", already mapped/resolved.
413
+ context.makeRequire(null, {
414
+ skipMap: true
415
+ })([id]);
416
+
417
+ return true;
418
+ }
419
+ }
420
+
421
+ //Turns a plugin!resource to [plugin, resource]
422
+ //with the plugin being undefined if the name
423
+ //did not have a plugin prefix.
424
+ function splitPrefix(name) {
425
+ var prefix,
426
+ index = name ? name.indexOf('!') : -1;
427
+ if (index > -1) {
428
+ prefix = name.substring(0, index);
429
+ name = name.substring(index + 1, name.length);
430
+ }
431
+ return [prefix, name];
432
+ }
433
+
434
+ /**
435
+ * Creates a module mapping that includes plugin prefix, module
436
+ * name, and path. If parentModuleMap is provided it will
437
+ * also normalize the name via require.normalize()
438
+ *
439
+ * @param {String} name the module name
440
+ * @param {String} [parentModuleMap] parent module map
441
+ * for the module name, used to resolve relative names.
442
+ * @param {Boolean} isNormalized: is the ID already normalized.
443
+ * This is true if this call is done for a define() module ID.
444
+ * @param {Boolean} applyMap: apply the map config to the ID.
445
+ * Should only be true if this map is for a dependency.
446
+ *
447
+ * @returns {Object}
448
+ */
449
+ function makeModuleMap(name, parentModuleMap, isNormalized, applyMap) {
450
+ var url, pluginModule, suffix, nameParts,
451
+ prefix = null,
452
+ parentName = parentModuleMap ? parentModuleMap.name : null,
453
+ originalName = name,
454
+ isDefine = true,
455
+ normalizedName = '';
456
+
457
+ //If no name, then it means it is a require call, generate an
458
+ //internal name.
459
+ if (!name) {
460
+ isDefine = false;
461
+ name = '_@r' + (requireCounter += 1);
462
+ }
463
+
464
+ nameParts = splitPrefix(name);
465
+ prefix = nameParts[0];
466
+ name = nameParts[1];
467
+
468
+ if (prefix) {
469
+ prefix = normalize(prefix, parentName, applyMap);
470
+ pluginModule = getOwn(defined, prefix);
471
+ }
472
+
473
+ //Account for relative paths if there is a base name.
474
+ if (name) {
475
+ if (prefix) {
476
+ if (isNormalized) {
477
+ normalizedName = name;
478
+ } else if (pluginModule && pluginModule.normalize) {
479
+ //Plugin is loaded, use its normalize method.
480
+ normalizedName = pluginModule.normalize(name, function (name) {
481
+ return normalize(name, parentName, applyMap);
482
+ });
483
+ } else {
484
+ // If nested plugin references, then do not try to
485
+ // normalize, as it will not normalize correctly. This
486
+ // places a restriction on resourceIds, and the longer
487
+ // term solution is not to normalize until plugins are
488
+ // loaded and all normalizations to allow for async
489
+ // loading of a loader plugin. But for now, fixes the
490
+ // common uses. Details in #1131
491
+ normalizedName = name.indexOf('!') === -1 ?
492
+ normalize(name, parentName, applyMap) :
493
+ name;
494
+ }
495
+ } else {
496
+ //A regular module.
497
+ normalizedName = normalize(name, parentName, applyMap);
498
+
499
+ //Normalized name may be a plugin ID due to map config
500
+ //application in normalize. The map config values must
501
+ //already be normalized, so do not need to redo that part.
502
+ nameParts = splitPrefix(normalizedName);
503
+ prefix = nameParts[0];
504
+ normalizedName = nameParts[1];
505
+ isNormalized = true;
506
+
507
+ url = context.nameToUrl(normalizedName);
508
+ }
509
+ }
510
+
511
+ //If the id is a plugin id that cannot be determined if it needs
512
+ //normalization, stamp it with a unique ID so two matching relative
513
+ //ids that may conflict can be separate.
514
+ suffix = prefix && !pluginModule && !isNormalized ?
515
+ '_unnormalized' + (unnormalizedCounter += 1) :
516
+ '';
517
+
518
+ return {
519
+ prefix: prefix,
520
+ name: normalizedName,
521
+ parentMap: parentModuleMap,
522
+ unnormalized: !!suffix,
523
+ url: url,
524
+ originalName: originalName,
525
+ isDefine: isDefine,
526
+ id: (prefix ?
527
+ prefix + '!' + normalizedName :
528
+ normalizedName) + suffix
529
+ };
530
+ }
531
+
532
+ function getModule(depMap) {
533
+ var id = depMap.id,
534
+ mod = getOwn(registry, id);
535
+
536
+ if (!mod) {
537
+ mod = registry[id] = new context.Module(depMap);
538
+ }
539
+
540
+ return mod;
541
+ }
542
+
543
+ function on(depMap, name, fn) {
544
+ var id = depMap.id,
545
+ mod = getOwn(registry, id);
546
+
547
+ if (hasProp(defined, id) &&
548
+ (!mod || mod.defineEmitComplete)) {
549
+ if (name === 'defined') {
550
+ fn(defined[id]);
551
+ }
552
+ } else {
553
+ mod = getModule(depMap);
554
+ if (mod.error && name === 'error') {
555
+ fn(mod.error);
556
+ } else {
557
+ mod.on(name, fn);
558
+ }
559
+ }
560
+ }
561
+
562
+ function onError(err, errback) {
563
+ var ids = err.requireModules,
564
+ notified = false;
565
+
566
+ if (errback) {
567
+ errback(err);
568
+ } else {
569
+ each(ids, function (id) {
570
+ var mod = getOwn(registry, id);
571
+ if (mod) {
572
+ //Set error on module, so it skips timeout checks.
573
+ mod.error = err;
574
+ if (mod.events.error) {
575
+ notified = true;
576
+ mod.emit('error', err);
577
+ }
578
+ }
579
+ });
580
+
581
+ if (!notified) {
582
+ req.onError(err);
583
+ }
584
+ }
585
+ }
586
+
587
+ /**
588
+ * Internal method to transfer globalQueue items to this context's
589
+ * defQueue.
590
+ */
591
+ function takeGlobalQueue() {
592
+ //Push all the globalDefQueue items into the context's defQueue
593
+ if (globalDefQueue.length) {
594
+ each(globalDefQueue, function(queueItem) {
595
+ var id = queueItem[0];
596
+ if (typeof id === 'string') {
597
+ context.defQueueMap[id] = true;
598
+ }
599
+ defQueue.push(queueItem);
600
+ });
601
+ globalDefQueue = [];
602
+ }
603
+ }
604
+
605
+ handlers = {
606
+ 'require': function (mod) {
607
+ if (mod.require) {
608
+ return mod.require;
609
+ } else {
610
+ return (mod.require = context.makeRequire(mod.map));
611
+ }
612
+ },
613
+ 'exports': function (mod) {
614
+ mod.usingExports = true;
615
+ if (mod.map.isDefine) {
616
+ if (mod.exports) {
617
+ return (defined[mod.map.id] = mod.exports);
618
+ } else {
619
+ return (mod.exports = defined[mod.map.id] = {});
620
+ }
621
+ }
622
+ },
623
+ 'module': function (mod) {
624
+ if (mod.module) {
625
+ return mod.module;
626
+ } else {
627
+ return (mod.module = {
628
+ id: mod.map.id,
629
+ uri: mod.map.url,
630
+ config: function () {
631
+ return getOwn(config.config, mod.map.id) || {};
632
+ },
633
+ exports: mod.exports || (mod.exports = {})
634
+ });
635
+ }
636
+ }
637
+ };
638
+
639
+ function cleanRegistry(id) {
640
+ //Clean up machinery used for waiting modules.
641
+ delete registry[id];
642
+ delete enabledRegistry[id];
643
+ }
644
+
645
+ function breakCycle(mod, traced, processed) {
646
+ var id = mod.map.id;
647
+
648
+ if (mod.error) {
649
+ mod.emit('error', mod.error);
650
+ } else {
651
+ traced[id] = true;
652
+ each(mod.depMaps, function (depMap, i) {
653
+ var depId = depMap.id,
654
+ dep = getOwn(registry, depId);
655
+
656
+ //Only force things that have not completed
657
+ //being defined, so still in the registry,
658
+ //and only if it has not been matched up
659
+ //in the module already.
660
+ if (dep && !mod.depMatched[i] && !processed[depId]) {
661
+ if (getOwn(traced, depId)) {
662
+ mod.defineDep(i, defined[depId]);
663
+ mod.check(); //pass false?
664
+ } else {
665
+ breakCycle(dep, traced, processed);
666
+ }
667
+ }
668
+ });
669
+ processed[id] = true;
670
+ }
671
+ }
672
+
673
+ function checkLoaded() {
674
+ var err, usingPathFallback,
675
+ waitInterval = config.waitSeconds * 1000,
676
+ //It is possible to disable the wait interval by using waitSeconds of 0.
677
+ expired = waitInterval && (context.startTime + waitInterval) < new Date().getTime(),
678
+ noLoads = [],
679
+ reqCalls = [],
680
+ stillLoading = false,
681
+ needCycleCheck = true;
682
+
683
+ //Do not bother if this call was a result of a cycle break.
684
+ if (inCheckLoaded) {
685
+ return;
686
+ }
687
+
688
+ inCheckLoaded = true;
689
+
690
+ //Figure out the state of all the modules.
691
+ eachProp(enabledRegistry, function (mod) {
692
+ var map = mod.map,
693
+ modId = map.id;
694
+
695
+ //Skip things that are not enabled or in error state.
696
+ if (!mod.enabled) {
697
+ return;
698
+ }
699
+
700
+ if (!map.isDefine) {
701
+ reqCalls.push(mod);
702
+ }
703
+
704
+ if (!mod.error) {
705
+ //If the module should be executed, and it has not
706
+ //been inited and time is up, remember it.
707
+ if (!mod.inited && expired) {
708
+ if (hasPathFallback(modId)) {
709
+ usingPathFallback = true;
710
+ stillLoading = true;
711
+ } else {
712
+ noLoads.push(modId);
713
+ removeScript(modId);
714
+ }
715
+ } else if (!mod.inited && mod.fetched && map.isDefine) {
716
+ stillLoading = true;
717
+ if (!map.prefix) {
718
+ //No reason to keep looking for unfinished
719
+ //loading. If the only stillLoading is a
720
+ //plugin resource though, keep going,
721
+ //because it may be that a plugin resource
722
+ //is waiting on a non-plugin cycle.
723
+ return (needCycleCheck = false);
724
+ }
725
+ }
726
+ }
727
+ });
728
+
729
+ if (expired && noLoads.length) {
730
+ //If wait time expired, throw error of unloaded modules.
731
+ err = makeError('timeout', 'Load timeout for modules: ' + noLoads, null, noLoads);
732
+ err.contextName = context.contextName;
733
+ return onError(err);
734
+ }
735
+
736
+ //Not expired, check for a cycle.
737
+ if (needCycleCheck) {
738
+ each(reqCalls, function (mod) {
739
+ breakCycle(mod, {}, {});
740
+ });
741
+ }
742
+
743
+ //If still waiting on loads, and the waiting load is something
744
+ //other than a plugin resource, or there are still outstanding
745
+ //scripts, then just try back later.
746
+ if ((!expired || usingPathFallback) && stillLoading) {
747
+ //Something is still waiting to load. Wait for it, but only
748
+ //if a timeout is not already in effect.
749
+ if ((isBrowser || isWebWorker) && !checkLoadedTimeoutId) {
750
+ checkLoadedTimeoutId = setTimeout(function () {
751
+ checkLoadedTimeoutId = 0;
752
+ checkLoaded();
753
+ }, 50);
754
+ }
755
+ }
756
+
757
+ inCheckLoaded = false;
758
+ }
759
+
760
+ Module = function (map) {
761
+ this.events = getOwn(undefEvents, map.id) || {};
762
+ this.map = map;
763
+ this.shim = getOwn(config.shim, map.id);
764
+ this.depExports = [];
765
+ this.depMaps = [];
766
+ this.depMatched = [];
767
+ this.pluginMaps = {};
768
+ this.depCount = 0;
769
+
770
+ /* this.exports this.factory
771
+ this.depMaps = [],
772
+ this.enabled, this.fetched
773
+ */
774
+ };
775
+
776
+ Module.prototype = {
777
+ init: function (depMaps, factory, errback, options) {
778
+ options = options || {};
779
+
780
+ //Do not do more inits if already done. Can happen if there
781
+ //are multiple define calls for the same module. That is not
782
+ //a normal, common case, but it is also not unexpected.
783
+ if (this.inited) {
784
+ return;
785
+ }
786
+
787
+ this.factory = factory;
788
+
789
+ if (errback) {
790
+ //Register for errors on this module.
791
+ this.on('error', errback);
792
+ } else if (this.events.error) {
793
+ //If no errback already, but there are error listeners
794
+ //on this module, set up an errback to pass to the deps.
795
+ errback = bind(this, function (err) {
796
+ this.emit('error', err);
797
+ });
798
+ }
799
+
800
+ //Do a copy of the dependency array, so that
801
+ //source inputs are not modified. For example
802
+ //"shim" deps are passed in here directly, and
803
+ //doing a direct modification of the depMaps array
804
+ //would affect that config.
805
+ this.depMaps = depMaps && depMaps.slice(0);
806
+
807
+ this.errback = errback;
808
+
809
+ //Indicate this module has be initialized
810
+ this.inited = true;
811
+
812
+ this.ignore = options.ignore;
813
+
814
+ //Could have option to init this module in enabled mode,
815
+ //or could have been previously marked as enabled. However,
816
+ //the dependencies are not known until init is called. So
817
+ //if enabled previously, now trigger dependencies as enabled.
818
+ if (options.enabled || this.enabled) {
819
+ //Enable this module and dependencies.
820
+ //Will call this.check()
821
+ this.enable();
822
+ } else {
823
+ this.check();
824
+ }
825
+ },
826
+
827
+ defineDep: function (i, depExports) {
828
+ //Because of cycles, defined callback for a given
829
+ //export can be called more than once.
830
+ if (!this.depMatched[i]) {
831
+ this.depMatched[i] = true;
832
+ this.depCount -= 1;
833
+ this.depExports[i] = depExports;
834
+ }
835
+ },
836
+
837
+ fetch: function () {
838
+ if (this.fetched) {
839
+ return;
840
+ }
841
+ this.fetched = true;
842
+
843
+ context.startTime = (new Date()).getTime();
844
+
845
+ var map = this.map;
846
+
847
+ //If the manager is for a plugin managed resource,
848
+ //ask the plugin to load it now.
849
+ if (this.shim) {
850
+ context.makeRequire(this.map, {
851
+ enableBuildCallback: true
852
+ })(this.shim.deps || [], bind(this, function () {
853
+ return map.prefix ? this.callPlugin() : this.load();
854
+ }));
855
+ } else {
856
+ //Regular dependency.
857
+ return map.prefix ? this.callPlugin() : this.load();
858
+ }
859
+ },
860
+
861
+ load: function () {
862
+ var url = this.map.url;
863
+
864
+ //Regular dependency.
865
+ if (!urlFetched[url]) {
866
+ urlFetched[url] = true;
867
+ context.load(this.map.id, url);
868
+ }
869
+ },
870
+
871
+ /**
872
+ * Checks if the module is ready to define itself, and if so,
873
+ * define it.
874
+ */
875
+ check: function () {
876
+ if (!this.enabled || this.enabling) {
877
+ return;
878
+ }
879
+
880
+ var err, cjsModule,
881
+ id = this.map.id,
882
+ depExports = this.depExports,
883
+ exports = this.exports,
884
+ factory = this.factory;
885
+
886
+ if (!this.inited) {
887
+ // Only fetch if not already in the defQueue.
888
+ if (!hasProp(context.defQueueMap, id)) {
889
+ this.fetch();
890
+ }
891
+ } else if (this.error) {
892
+ this.emit('error', this.error);
893
+ } else if (!this.defining) {
894
+ //The factory could trigger another require call
895
+ //that would result in checking this module to
896
+ //define itself again. If already in the process
897
+ //of doing that, skip this work.
898
+ this.defining = true;
899
+
900
+ if (this.depCount < 1 && !this.defined) {
901
+ if (isFunction(factory)) {
902
+ //If there is an error listener, favor passing
903
+ //to that instead of throwing an error. However,
904
+ //only do it for define()'d modules. require
905
+ //errbacks should not be called for failures in
906
+ //their callbacks (#699). However if a global
907
+ //onError is set, use that.
908
+ if ((this.events.error && this.map.isDefine) ||
909
+ req.onError !== defaultOnError) {
910
+ try {
911
+ exports = context.execCb(id, factory, depExports, exports);
912
+ } catch (e) {
913
+ err = e;
914
+ }
915
+ } else {
916
+ exports = context.execCb(id, factory, depExports, exports);
917
+ }
918
+
919
+ // Favor return value over exports. If node/cjs in play,
920
+ // then will not have a return value anyway. Favor
921
+ // module.exports assignment over exports object.
922
+ if (this.map.isDefine && exports === undefined) {
923
+ cjsModule = this.module;
924
+ if (cjsModule) {
925
+ exports = cjsModule.exports;
926
+ } else if (this.usingExports) {
927
+ //exports already set the defined value.
928
+ exports = this.exports;
929
+ }
930
+ }
931
+
932
+ if (err) {
933
+ err.requireMap = this.map;
934
+ err.requireModules = this.map.isDefine ? [this.map.id] : null;
935
+ err.requireType = this.map.isDefine ? 'define' : 'require';
936
+ return onError((this.error = err));
937
+ }
938
+
939
+ } else {
940
+ //Just a literal value
941
+ exports = factory;
942
+ }
943
+
944
+ this.exports = exports;
945
+
946
+ if (this.map.isDefine && !this.ignore) {
947
+ defined[id] = exports;
948
+
949
+ if (req.onResourceLoad) {
950
+ var resLoadMaps = [];
951
+ each(this.depMaps, function (depMap) {
952
+ resLoadMaps.push(depMap.normalizedMap || depMap);
953
+ });
954
+ req.onResourceLoad(context, this.map, resLoadMaps);
955
+ }
956
+ }
957
+
958
+ //Clean up
959
+ cleanRegistry(id);
960
+
961
+ this.defined = true;
962
+ }
963
+
964
+ //Finished the define stage. Allow calling check again
965
+ //to allow define notifications below in the case of a
966
+ //cycle.
967
+ this.defining = false;
968
+
969
+ if (this.defined && !this.defineEmitted) {
970
+ this.defineEmitted = true;
971
+ this.emit('defined', this.exports);
972
+ this.defineEmitComplete = true;
973
+ }
974
+
975
+ }
976
+ },
977
+
978
+ callPlugin: function () {
979
+ var map = this.map,
980
+ id = map.id,
981
+ //Map already normalized the prefix.
982
+ pluginMap = makeModuleMap(map.prefix);
983
+
984
+ //Mark this as a dependency for this plugin, so it
985
+ //can be traced for cycles.
986
+ this.depMaps.push(pluginMap);
987
+
988
+ on(pluginMap, 'defined', bind(this, function (plugin) {
989
+ var load, normalizedMap, normalizedMod,
990
+ bundleId = getOwn(bundlesMap, this.map.id),
991
+ name = this.map.name,
992
+ parentName = this.map.parentMap ? this.map.parentMap.name : null,
993
+ localRequire = context.makeRequire(map.parentMap, {
994
+ enableBuildCallback: true
995
+ });
996
+
997
+ //If current map is not normalized, wait for that
998
+ //normalized name to load instead of continuing.
999
+ if (this.map.unnormalized) {
1000
+ //Normalize the ID if the plugin allows it.
1001
+ if (plugin.normalize) {
1002
+ name = plugin.normalize(name, function (name) {
1003
+ return normalize(name, parentName, true);
1004
+ }) || '';
1005
+ }
1006
+
1007
+ //prefix and name should already be normalized, no need
1008
+ //for applying map config again either.
1009
+ normalizedMap = makeModuleMap(map.prefix + '!' + name,
1010
+ this.map.parentMap,
1011
+ true);
1012
+ on(normalizedMap,
1013
+ 'defined', bind(this, function (value) {
1014
+ this.map.normalizedMap = normalizedMap;
1015
+ this.init([], function () { return value; }, null, {
1016
+ enabled: true,
1017
+ ignore: true
1018
+ });
1019
+ }));
1020
+
1021
+ normalizedMod = getOwn(registry, normalizedMap.id);
1022
+ if (normalizedMod) {
1023
+ //Mark this as a dependency for this plugin, so it
1024
+ //can be traced for cycles.
1025
+ this.depMaps.push(normalizedMap);
1026
+
1027
+ if (this.events.error) {
1028
+ normalizedMod.on('error', bind(this, function (err) {
1029
+ this.emit('error', err);
1030
+ }));
1031
+ }
1032
+ normalizedMod.enable();
1033
+ }
1034
+
1035
+ return;
1036
+ }
1037
+
1038
+ //If a paths config, then just load that file instead to
1039
+ //resolve the plugin, as it is built into that paths layer.
1040
+ if (bundleId) {
1041
+ this.map.url = context.nameToUrl(bundleId);
1042
+ this.load();
1043
+ return;
1044
+ }
1045
+
1046
+ load = bind(this, function (value) {
1047
+ this.init([], function () { return value; }, null, {
1048
+ enabled: true
1049
+ });
1050
+ });
1051
+
1052
+ load.error = bind(this, function (err) {
1053
+ this.inited = true;
1054
+ this.error = err;
1055
+ err.requireModules = [id];
1056
+
1057
+ //Remove temp unnormalized modules for this module,
1058
+ //since they will never be resolved otherwise now.
1059
+ eachProp(registry, function (mod) {
1060
+ if (mod.map.id.indexOf(id + '_unnormalized') === 0) {
1061
+ cleanRegistry(mod.map.id);
1062
+ }
1063
+ });
1064
+
1065
+ onError(err);
1066
+ });
1067
+
1068
+ //Allow plugins to load other code without having to know the
1069
+ //context or how to 'complete' the load.
1070
+ load.fromText = bind(this, function (text, textAlt) {
1071
+ /*jslint evil: true */
1072
+ var moduleName = map.name,
1073
+ moduleMap = makeModuleMap(moduleName),
1074
+ hasInteractive = useInteractive;
1075
+
1076
+ //As of 2.1.0, support just passing the text, to reinforce
1077
+ //fromText only being called once per resource. Still
1078
+ //support old style of passing moduleName but discard
1079
+ //that moduleName in favor of the internal ref.
1080
+ if (textAlt) {
1081
+ text = textAlt;
1082
+ }
1083
+
1084
+ //Turn off interactive script matching for IE for any define
1085
+ //calls in the text, then turn it back on at the end.
1086
+ if (hasInteractive) {
1087
+ useInteractive = false;
1088
+ }
1089
+
1090
+ //Prime the system by creating a module instance for
1091
+ //it.
1092
+ getModule(moduleMap);
1093
+
1094
+ //Transfer any config to this other module.
1095
+ if (hasProp(config.config, id)) {
1096
+ config.config[moduleName] = config.config[id];
1097
+ }
1098
+
1099
+ try {
1100
+ req.exec(text);
1101
+ } catch (e) {
1102
+ return onError(makeError('fromtexteval',
1103
+ 'fromText eval for ' + id +
1104
+ ' failed: ' + e,
1105
+ e,
1106
+ [id]));
1107
+ }
1108
+
1109
+ if (hasInteractive) {
1110
+ useInteractive = true;
1111
+ }
1112
+
1113
+ //Mark this as a dependency for the plugin
1114
+ //resource
1115
+ this.depMaps.push(moduleMap);
1116
+
1117
+ //Support anonymous modules.
1118
+ context.completeLoad(moduleName);
1119
+
1120
+ //Bind the value of that module to the value for this
1121
+ //resource ID.
1122
+ localRequire([moduleName], load);
1123
+ });
1124
+
1125
+ //Use parentName here since the plugin's name is not reliable,
1126
+ //could be some weird string with no path that actually wants to
1127
+ //reference the parentName's path.
1128
+ plugin.load(map.name, localRequire, load, config);
1129
+ }));
1130
+
1131
+ context.enable(pluginMap, this);
1132
+ this.pluginMaps[pluginMap.id] = pluginMap;
1133
+ },
1134
+
1135
+ enable: function () {
1136
+ enabledRegistry[this.map.id] = this;
1137
+ this.enabled = true;
1138
+
1139
+ //Set flag mentioning that the module is enabling,
1140
+ //so that immediate calls to the defined callbacks
1141
+ //for dependencies do not trigger inadvertent load
1142
+ //with the depCount still being zero.
1143
+ this.enabling = true;
1144
+
1145
+ //Enable each dependency
1146
+ each(this.depMaps, bind(this, function (depMap, i) {
1147
+ var id, mod, handler;
1148
+
1149
+ if (typeof depMap === 'string') {
1150
+ //Dependency needs to be converted to a depMap
1151
+ //and wired up to this module.
1152
+ depMap = makeModuleMap(depMap,
1153
+ (this.map.isDefine ? this.map : this.map.parentMap),
1154
+ false,
1155
+ !this.skipMap);
1156
+ this.depMaps[i] = depMap;
1157
+
1158
+ handler = getOwn(handlers, depMap.id);
1159
+
1160
+ if (handler) {
1161
+ this.depExports[i] = handler(this);
1162
+ return;
1163
+ }
1164
+
1165
+ this.depCount += 1;
1166
+
1167
+ on(depMap, 'defined', bind(this, function (depExports) {
1168
+ if (this.undefed) {
1169
+ return;
1170
+ }
1171
+ this.defineDep(i, depExports);
1172
+ this.check();
1173
+ }));
1174
+
1175
+ if (this.errback) {
1176
+ on(depMap, 'error', bind(this, this.errback));
1177
+ } else if (this.events.error) {
1178
+ // No direct errback on this module, but something
1179
+ // else is listening for errors, so be sure to
1180
+ // propagate the error correctly.
1181
+ on(depMap, 'error', bind(this, function(err) {
1182
+ this.emit('error', err);
1183
+ }));
1184
+ }
1185
+ }
1186
+
1187
+ id = depMap.id;
1188
+ mod = registry[id];
1189
+
1190
+ //Skip special modules like 'require', 'exports', 'module'
1191
+ //Also, don't call enable if it is already enabled,
1192
+ //important in circular dependency cases.
1193
+ if (!hasProp(handlers, id) && mod && !mod.enabled) {
1194
+ context.enable(depMap, this);
1195
+ }
1196
+ }));
1197
+
1198
+ //Enable each plugin that is used in
1199
+ //a dependency
1200
+ eachProp(this.pluginMaps, bind(this, function (pluginMap) {
1201
+ var mod = getOwn(registry, pluginMap.id);
1202
+ if (mod && !mod.enabled) {
1203
+ context.enable(pluginMap, this);
1204
+ }
1205
+ }));
1206
+
1207
+ this.enabling = false;
1208
+
1209
+ this.check();
1210
+ },
1211
+
1212
+ on: function (name, cb) {
1213
+ var cbs = this.events[name];
1214
+ if (!cbs) {
1215
+ cbs = this.events[name] = [];
1216
+ }
1217
+ cbs.push(cb);
1218
+ },
1219
+
1220
+ emit: function (name, evt) {
1221
+ each(this.events[name], function (cb) {
1222
+ cb(evt);
1223
+ });
1224
+ if (name === 'error') {
1225
+ //Now that the error handler was triggered, remove
1226
+ //the listeners, since this broken Module instance
1227
+ //can stay around for a while in the registry.
1228
+ delete this.events[name];
1229
+ }
1230
+ }
1231
+ };
1232
+
1233
+ function callGetModule(args) {
1234
+ //Skip modules already defined.
1235
+ if (!hasProp(defined, args[0])) {
1236
+ getModule(makeModuleMap(args[0], null, true)).init(args[1], args[2]);
1237
+ }
1238
+ }
1239
+
1240
+ function removeListener(node, func, name, ieName) {
1241
+ //Favor detachEvent because of IE9
1242
+ //issue, see attachEvent/addEventListener comment elsewhere
1243
+ //in this file.
1244
+ if (node.detachEvent && !isOpera) {
1245
+ //Probably IE. If not it will throw an error, which will be
1246
+ //useful to know.
1247
+ if (ieName) {
1248
+ node.detachEvent(ieName, func);
1249
+ }
1250
+ } else {
1251
+ node.removeEventListener(name, func, false);
1252
+ }
1253
+ }
1254
+
1255
+ /**
1256
+ * Given an event from a script node, get the requirejs info from it,
1257
+ * and then removes the event listeners on the node.
1258
+ * @param {Event} evt
1259
+ * @returns {Object}
1260
+ */
1261
+ function getScriptData(evt) {
1262
+ //Using currentTarget instead of target for Firefox 2.0's sake. Not
1263
+ //all old browsers will be supported, but this one was easy enough
1264
+ //to support and still makes sense.
1265
+ var node = evt.currentTarget || evt.srcElement;
1266
+
1267
+ //Remove the listeners once here.
1268
+ removeListener(node, context.onScriptLoad, 'load', 'onreadystatechange');
1269
+ removeListener(node, context.onScriptError, 'error');
1270
+
1271
+ return {
1272
+ node: node,
1273
+ id: node && node.getAttribute('data-requiremodule')
1274
+ };
1275
+ }
1276
+
1277
+ function intakeDefines() {
1278
+ var args;
1279
+
1280
+ //Any defined modules in the global queue, intake them now.
1281
+ takeGlobalQueue();
1282
+
1283
+ //Make sure any remaining defQueue items get properly processed.
1284
+ while (defQueue.length) {
1285
+ args = defQueue.shift();
1286
+ if (args[0] === null) {
1287
+ return onError(makeError('mismatch', 'Mismatched anonymous define() module: ' +
1288
+ args[args.length - 1]));
1289
+ } else {
1290
+ //args are id, deps, factory. Should be normalized by the
1291
+ //define() function.
1292
+ callGetModule(args);
1293
+ }
1294
+ }
1295
+ context.defQueueMap = {};
1296
+ }
1297
+
1298
+ context = {
1299
+ config: config,
1300
+ contextName: contextName,
1301
+ registry: registry,
1302
+ defined: defined,
1303
+ urlFetched: urlFetched,
1304
+ defQueue: defQueue,
1305
+ defQueueMap: {},
1306
+ Module: Module,
1307
+ makeModuleMap: makeModuleMap,
1308
+ nextTick: req.nextTick,
1309
+ onError: onError,
1310
+
1311
+ /**
1312
+ * Set a configuration for the context.
1313
+ * @param {Object} cfg config object to integrate.
1314
+ */
1315
+ configure: function (cfg) {
1316
+ //Make sure the baseUrl ends in a slash.
1317
+ if (cfg.baseUrl) {
1318
+ if (cfg.baseUrl.charAt(cfg.baseUrl.length - 1) !== '/') {
1319
+ cfg.baseUrl += '/';
1320
+ }
1321
+ }
1322
+
1323
+ // Convert old style urlArgs string to a function.
1324
+ if (typeof cfg.urlArgs === 'string') {
1325
+ var urlArgs = cfg.urlArgs;
1326
+ cfg.urlArgs = function(id, url) {
1327
+ return (url.indexOf('?') === -1 ? '?' : '&') + urlArgs;
1328
+ };
1329
+ }
1330
+
1331
+ //Save off the paths since they require special processing,
1332
+ //they are additive.
1333
+ var shim = config.shim,
1334
+ objs = {
1335
+ paths: true,
1336
+ bundles: true,
1337
+ config: true,
1338
+ map: true
1339
+ };
1340
+
1341
+ eachProp(cfg, function (value, prop) {
1342
+ if (objs[prop]) {
1343
+ if (!config[prop]) {
1344
+ config[prop] = {};
1345
+ }
1346
+ mixin(config[prop], value, true, true);
1347
+ } else {
1348
+ config[prop] = value;
1349
+ }
1350
+ });
1351
+
1352
+ //Reverse map the bundles
1353
+ if (cfg.bundles) {
1354
+ eachProp(cfg.bundles, function (value, prop) {
1355
+ each(value, function (v) {
1356
+ if (v !== prop) {
1357
+ bundlesMap[v] = prop;
1358
+ }
1359
+ });
1360
+ });
1361
+ }
1362
+
1363
+ //Merge shim
1364
+ if (cfg.shim) {
1365
+ eachProp(cfg.shim, function (value, id) {
1366
+ //Normalize the structure
1367
+ if (isArray(value)) {
1368
+ value = {
1369
+ deps: value
1370
+ };
1371
+ }
1372
+ if ((value.exports || value.init) && !value.exportsFn) {
1373
+ value.exportsFn = context.makeShimExports(value);
1374
+ }
1375
+ shim[id] = value;
1376
+ });
1377
+ config.shim = shim;
1378
+ }
1379
+
1380
+ //Adjust packages if necessary.
1381
+ if (cfg.packages) {
1382
+ each(cfg.packages, function (pkgObj) {
1383
+ var location, name;
1384
+
1385
+ pkgObj = typeof pkgObj === 'string' ? {name: pkgObj} : pkgObj;
1386
+
1387
+ name = pkgObj.name;
1388
+ location = pkgObj.location;
1389
+ if (location) {
1390
+ config.paths[name] = pkgObj.location;
1391
+ }
1392
+
1393
+ //Save pointer to main module ID for pkg name.
1394
+ //Remove leading dot in main, so main paths are normalized,
1395
+ //and remove any trailing .js, since different package
1396
+ //envs have different conventions: some use a module name,
1397
+ //some use a file name.
1398
+ config.pkgs[name] = pkgObj.name + '/' + (pkgObj.main || 'main')
1399
+ .replace(currDirRegExp, '')
1400
+ .replace(jsSuffixRegExp, '');
1401
+ });
1402
+ }
1403
+
1404
+ //If there are any "waiting to execute" modules in the registry,
1405
+ //update the maps for them, since their info, like URLs to load,
1406
+ //may have changed.
1407
+ eachProp(registry, function (mod, id) {
1408
+ //If module already has init called, since it is too
1409
+ //late to modify them, and ignore unnormalized ones
1410
+ //since they are transient.
1411
+ if (!mod.inited && !mod.map.unnormalized) {
1412
+ mod.map = makeModuleMap(id, null, true);
1413
+ }
1414
+ });
1415
+
1416
+ //If a deps array or a config callback is specified, then call
1417
+ //require with those args. This is useful when require is defined as a
1418
+ //config object before require.js is loaded.
1419
+ if (cfg.deps || cfg.callback) {
1420
+ context.require(cfg.deps || [], cfg.callback);
1421
+ }
1422
+ },
1423
+
1424
+ makeShimExports: function (value) {
1425
+ function fn() {
1426
+ var ret;
1427
+ if (value.init) {
1428
+ ret = value.init.apply(global, arguments);
1429
+ }
1430
+ return ret || (value.exports && getGlobal(value.exports));
1431
+ }
1432
+ return fn;
1433
+ },
1434
+
1435
+ makeRequire: function (relMap, options) {
1436
+ options = options || {};
1437
+
1438
+ function localRequire(deps, callback, errback) {
1439
+ var id, map, requireMod;
1440
+
1441
+ if (options.enableBuildCallback && callback && isFunction(callback)) {
1442
+ callback.__requireJsBuild = true;
1443
+ }
1444
+
1445
+ if (typeof deps === 'string') {
1446
+ if (isFunction(callback)) {
1447
+ //Invalid call
1448
+ return onError(makeError('requireargs', 'Invalid require call'), errback);
1449
+ }
1450
+
1451
+ //If require|exports|module are requested, get the
1452
+ //value for them from the special handlers. Caveat:
1453
+ //this only works while module is being defined.
1454
+ if (relMap && hasProp(handlers, deps)) {
1455
+ return handlers[deps](registry[relMap.id]);
1456
+ }
1457
+
1458
+ //Synchronous access to one module. If require.get is
1459
+ //available (as in the Node adapter), prefer that.
1460
+ if (req.get) {
1461
+ return req.get(context, deps, relMap, localRequire);
1462
+ }
1463
+
1464
+ //Normalize module name, if it contains . or ..
1465
+ map = makeModuleMap(deps, relMap, false, true);
1466
+ id = map.id;
1467
+
1468
+ if (!hasProp(defined, id)) {
1469
+ return onError(makeError('notloaded', 'Module name "' +
1470
+ id +
1471
+ '" has not been loaded yet for context: ' +
1472
+ contextName +
1473
+ (relMap ? '' : '. Use require([])')));
1474
+ }
1475
+ return defined[id];
1476
+ }
1477
+
1478
+ //Grab defines waiting in the global queue.
1479
+ intakeDefines();
1480
+
1481
+ //Mark all the dependencies as needing to be loaded.
1482
+ context.nextTick(function () {
1483
+ //Some defines could have been added since the
1484
+ //require call, collect them.
1485
+ intakeDefines();
1486
+
1487
+ requireMod = getModule(makeModuleMap(null, relMap));
1488
+
1489
+ //Store if map config should be applied to this require
1490
+ //call for dependencies.
1491
+ requireMod.skipMap = options.skipMap;
1492
+
1493
+ requireMod.init(deps, callback, errback, {
1494
+ enabled: true
1495
+ });
1496
+
1497
+ checkLoaded();
1498
+ });
1499
+
1500
+ return localRequire;
1501
+ }
1502
+
1503
+ mixin(localRequire, {
1504
+ isBrowser: isBrowser,
1505
+
1506
+ /**
1507
+ * Converts a module name + .extension into an URL path.
1508
+ * *Requires* the use of a module name. It does not support using
1509
+ * plain URLs like nameToUrl.
1510
+ */
1511
+ toUrl: function (moduleNamePlusExt) {
1512
+ var ext,
1513
+ index = moduleNamePlusExt.lastIndexOf('.'),
1514
+ segment = moduleNamePlusExt.split('/')[0],
1515
+ isRelative = segment === '.' || segment === '..';
1516
+
1517
+ //Have a file extension alias, and it is not the
1518
+ //dots from a relative path.
1519
+ if (index !== -1 && (!isRelative || index > 1)) {
1520
+ ext = moduleNamePlusExt.substring(index, moduleNamePlusExt.length);
1521
+ moduleNamePlusExt = moduleNamePlusExt.substring(0, index);
1522
+ }
1523
+
1524
+ return context.nameToUrl(normalize(moduleNamePlusExt,
1525
+ relMap && relMap.id, true), ext, true);
1526
+ },
1527
+
1528
+ defined: function (id) {
1529
+ return hasProp(defined, makeModuleMap(id, relMap, false, true).id);
1530
+ },
1531
+
1532
+ specified: function (id) {
1533
+ id = makeModuleMap(id, relMap, false, true).id;
1534
+ return hasProp(defined, id) || hasProp(registry, id);
1535
+ }
1536
+ });
1537
+
1538
+ //Only allow undef on top level require calls
1539
+ if (!relMap) {
1540
+ localRequire.undef = function (id) {
1541
+ //Bind any waiting define() calls to this context,
1542
+ //fix for #408
1543
+ takeGlobalQueue();
1544
+
1545
+ var map = makeModuleMap(id, relMap, true),
1546
+ mod = getOwn(registry, id);
1547
+
1548
+ mod.undefed = true;
1549
+ removeScript(id);
1550
+
1551
+ delete defined[id];
1552
+ delete urlFetched[map.url];
1553
+ delete undefEvents[id];
1554
+
1555
+ //Clean queued defines too. Go backwards
1556
+ //in array so that the splices do not
1557
+ //mess up the iteration.
1558
+ eachReverse(defQueue, function(args, i) {
1559
+ if (args[0] === id) {
1560
+ defQueue.splice(i, 1);
1561
+ }
1562
+ });
1563
+ delete context.defQueueMap[id];
1564
+
1565
+ if (mod) {
1566
+ //Hold on to listeners in case the
1567
+ //module will be attempted to be reloaded
1568
+ //using a different config.
1569
+ if (mod.events.defined) {
1570
+ undefEvents[id] = mod.events;
1571
+ }
1572
+
1573
+ cleanRegistry(id);
1574
+ }
1575
+ };
1576
+ }
1577
+
1578
+ return localRequire;
1579
+ },
1580
+
1581
+ /**
1582
+ * Called to enable a module if it is still in the registry
1583
+ * awaiting enablement. A second arg, parent, the parent module,
1584
+ * is passed in for context, when this method is overridden by
1585
+ * the optimizer. Not shown here to keep code compact.
1586
+ */
1587
+ enable: function (depMap) {
1588
+ var mod = getOwn(registry, depMap.id);
1589
+ if (mod) {
1590
+ getModule(depMap).enable();
1591
+ }
1592
+ },
1593
+
1594
+ /**
1595
+ * Internal method used by environment adapters to complete a load event.
1596
+ * A load event could be a script load or just a load pass from a synchronous
1597
+ * load call.
1598
+ * @param {String} moduleName the name of the module to potentially complete.
1599
+ */
1600
+ completeLoad: function (moduleName) {
1601
+ var found, args, mod,
1602
+ shim = getOwn(config.shim, moduleName) || {},
1603
+ shExports = shim.exports;
1604
+
1605
+ takeGlobalQueue();
1606
+
1607
+ while (defQueue.length) {
1608
+ args = defQueue.shift();
1609
+ if (args[0] === null) {
1610
+ args[0] = moduleName;
1611
+ //If already found an anonymous module and bound it
1612
+ //to this name, then this is some other anon module
1613
+ //waiting for its completeLoad to fire.
1614
+ if (found) {
1615
+ break;
1616
+ }
1617
+ found = true;
1618
+ } else if (args[0] === moduleName) {
1619
+ //Found matching define call for this script!
1620
+ found = true;
1621
+ }
1622
+
1623
+ callGetModule(args);
1624
+ }
1625
+ context.defQueueMap = {};
1626
+
1627
+ //Do this after the cycle of callGetModule in case the result
1628
+ //of those calls/init calls changes the registry.
1629
+ mod = getOwn(registry, moduleName);
1630
+
1631
+ if (!found && !hasProp(defined, moduleName) && mod && !mod.inited) {
1632
+ if (config.enforceDefine && (!shExports || !getGlobal(shExports))) {
1633
+ if (hasPathFallback(moduleName)) {
1634
+ return;
1635
+ } else {
1636
+ return onError(makeError('nodefine',
1637
+ 'No define call for ' + moduleName,
1638
+ null,
1639
+ [moduleName]));
1640
+ }
1641
+ } else {
1642
+ //A script that does not call define(), so just simulate
1643
+ //the call for it.
1644
+ callGetModule([moduleName, (shim.deps || []), shim.exportsFn]);
1645
+ }
1646
+ }
1647
+
1648
+ checkLoaded();
1649
+ },
1650
+
1651
+ /**
1652
+ * Converts a module name to a file path. Supports cases where
1653
+ * moduleName may actually be just an URL.
1654
+ * Note that it **does not** call normalize on the moduleName,
1655
+ * it is assumed to have already been normalized. This is an
1656
+ * internal API, not a public one. Use toUrl for the public API.
1657
+ */
1658
+ nameToUrl: function (moduleName, ext, skipExt) {
1659
+ var paths, syms, i, parentModule, url,
1660
+ parentPath, bundleId,
1661
+ pkgMain = getOwn(config.pkgs, moduleName);
1662
+
1663
+ if (pkgMain) {
1664
+ moduleName = pkgMain;
1665
+ }
1666
+
1667
+ bundleId = getOwn(bundlesMap, moduleName);
1668
+
1669
+ if (bundleId) {
1670
+ return context.nameToUrl(bundleId, ext, skipExt);
1671
+ }
1672
+
1673
+ //If a colon is in the URL, it indicates a protocol is used and it is just
1674
+ //an URL to a file, or if it starts with a slash, contains a query arg (i.e. ?)
1675
+ //or ends with .js, then assume the user meant to use an url and not a module id.
1676
+ //The slash is important for protocol-less URLs as well as full paths.
1677
+ if (req.jsExtRegExp.test(moduleName)) {
1678
+ //Just a plain path, not module name lookup, so just return it.
1679
+ //Add extension if it is included. This is a bit wonky, only non-.js things pass
1680
+ //an extension, this method probably needs to be reworked.
1681
+ url = moduleName + (ext || '');
1682
+ } else {
1683
+ //A module that needs to be converted to a path.
1684
+ paths = config.paths;
1685
+
1686
+ syms = moduleName.split('/');
1687
+ //For each module name segment, see if there is a path
1688
+ //registered for it. Start with most specific name
1689
+ //and work up from it.
1690
+ for (i = syms.length; i > 0; i -= 1) {
1691
+ parentModule = syms.slice(0, i).join('/');
1692
+
1693
+ parentPath = getOwn(paths, parentModule);
1694
+ if (parentPath) {
1695
+ //If an array, it means there are a few choices,
1696
+ //Choose the one that is desired
1697
+ if (isArray(parentPath)) {
1698
+ parentPath = parentPath[0];
1699
+ }
1700
+ syms.splice(0, i, parentPath);
1701
+ break;
1702
+ }
1703
+ }
1704
+
1705
+ //Join the path parts together, then figure out if baseUrl is needed.
1706
+ url = syms.join('/');
1707
+ url += (ext || (/^data\:|^blob\:|\?/.test(url) || skipExt ? '' : '.js'));
1708
+ url = (url.charAt(0) === '/' || url.match(/^[\w\+\.\-]+:/) ? '' : config.baseUrl) + url;
1709
+ }
1710
+
1711
+ return config.urlArgs && !/^blob\:/.test(url) ?
1712
+ url + config.urlArgs(moduleName, url) : url;
1713
+ },
1714
+
1715
+ //Delegates to req.load. Broken out as a separate function to
1716
+ //allow overriding in the optimizer.
1717
+ load: function (id, url) {
1718
+ req.load(context, id, url);
1719
+ },
1720
+
1721
+ /**
1722
+ * Executes a module callback function. Broken out as a separate function
1723
+ * solely to allow the build system to sequence the files in the built
1724
+ * layer in the right sequence.
1725
+ *
1726
+ * @private
1727
+ */
1728
+ execCb: function (name, callback, args, exports) {
1729
+ return callback.apply(exports, args);
1730
+ },
1731
+
1732
+ /**
1733
+ * callback for script loads, used to check status of loading.
1734
+ *
1735
+ * @param {Event} evt the event from the browser for the script
1736
+ * that was loaded.
1737
+ */
1738
+ onScriptLoad: function (evt) {
1739
+ //Using currentTarget instead of target for Firefox 2.0's sake. Not
1740
+ //all old browsers will be supported, but this one was easy enough
1741
+ //to support and still makes sense.
1742
+ if (evt.type === 'load' ||
1743
+ (readyRegExp.test((evt.currentTarget || evt.srcElement).readyState))) {
1744
+ //Reset interactive script so a script node is not held onto for
1745
+ //to long.
1746
+ interactiveScript = null;
1747
+
1748
+ //Pull out the name of the module and the context.
1749
+ var data = getScriptData(evt);
1750
+ context.completeLoad(data.id);
1751
+ }
1752
+ },
1753
+
1754
+ /**
1755
+ * Callback for script errors.
1756
+ */
1757
+ onScriptError: function (evt) {
1758
+ var data = getScriptData(evt);
1759
+ if (!hasPathFallback(data.id)) {
1760
+ var parents = [];
1761
+ eachProp(registry, function(value, key) {
1762
+ if (key.indexOf('_@r') !== 0) {
1763
+ each(value.depMaps, function(depMap) {
1764
+ if (depMap.id === data.id) {
1765
+ parents.push(key);
1766
+ return true;
1767
+ }
1768
+ });
1769
+ }
1770
+ });
1771
+ return onError(makeError('scripterror', 'Script error for "' + data.id +
1772
+ (parents.length ?
1773
+ '", needed by: ' + parents.join(', ') :
1774
+ '"'), evt, [data.id]));
1775
+ }
1776
+ }
1777
+ };
1778
+
1779
+ context.require = context.makeRequire();
1780
+ return context;
1781
+ }
1782
+
1783
+ /**
1784
+ * Main entry point.
1785
+ *
1786
+ * If the only argument to require is a string, then the module that
1787
+ * is represented by that string is fetched for the appropriate context.
1788
+ *
1789
+ * If the first argument is an array, then it will be treated as an array
1790
+ * of dependency string names to fetch. An optional function callback can
1791
+ * be specified to execute when all of those dependencies are available.
1792
+ *
1793
+ * Make a local req variable to help Caja compliance (it assumes things
1794
+ * on a require that are not standardized), and to give a short
1795
+ * name for minification/local scope use.
1796
+ */
1797
+ req = requirejs = function (deps, callback, errback, optional) {
1798
+
1799
+ //Find the right context, use default
1800
+ var context, config,
1801
+ contextName = defContextName;
1802
+
1803
+ // Determine if have config object in the call.
1804
+ if (!isArray(deps) && typeof deps !== 'string') {
1805
+ // deps is a config object
1806
+ config = deps;
1807
+ if (isArray(callback)) {
1808
+ // Adjust args if there are dependencies
1809
+ deps = callback;
1810
+ callback = errback;
1811
+ errback = optional;
1812
+ } else {
1813
+ deps = [];
1814
+ }
1815
+ }
1816
+
1817
+ if (config && config.context) {
1818
+ contextName = config.context;
1819
+ }
1820
+
1821
+ context = getOwn(contexts, contextName);
1822
+ if (!context) {
1823
+ context = contexts[contextName] = req.s.newContext(contextName);
1824
+ }
1825
+
1826
+ if (config) {
1827
+ context.configure(config);
1828
+ }
1829
+
1830
+ return context.require(deps, callback, errback);
1831
+ };
1832
+
1833
+ /**
1834
+ * Support require.config() to make it easier to cooperate with other
1835
+ * AMD loaders on globally agreed names.
1836
+ */
1837
+ req.config = function (config) {
1838
+ return req(config);
1839
+ };
1840
+
1841
+ /**
1842
+ * Execute something after the current tick
1843
+ * of the event loop. Override for other envs
1844
+ * that have a better solution than setTimeout.
1845
+ * @param {Function} fn function to execute later.
1846
+ */
1847
+ req.nextTick = typeof setTimeout !== 'undefined' ? function (fn) {
1848
+ setTimeout(fn, 4);
1849
+ } : function (fn) { fn(); };
1850
+
1851
+ /**
1852
+ * Export require as a global, but only if it does not already exist.
1853
+ */
1854
+ if (!require) {
1855
+ require = req;
1856
+ }
1857
+
1858
+ req.version = version;
1859
+
1860
+ //Used to filter out dependencies that are already paths.
1861
+ req.jsExtRegExp = /^\/|:|\?|\.js$/;
1862
+ req.isBrowser = isBrowser;
1863
+ s = req.s = {
1864
+ contexts: contexts,
1865
+ newContext: newContext
1866
+ };
1867
+
1868
+ //Create default context.
1869
+ req({});
1870
+
1871
+ //Exports some context-sensitive methods on global require.
1872
+ each([
1873
+ 'toUrl',
1874
+ 'undef',
1875
+ 'defined',
1876
+ 'specified'
1877
+ ], function (prop) {
1878
+ //Reference from contexts instead of early binding to default context,
1879
+ //so that during builds, the latest instance of the default context
1880
+ //with its config gets used.
1881
+ req[prop] = function () {
1882
+ var ctx = contexts[defContextName];
1883
+ return ctx.require[prop].apply(ctx, arguments);
1884
+ };
1885
+ });
1886
+
1887
+ if (isBrowser) {
1888
+ head = s.head = document.getElementsByTagName('head')[0];
1889
+ //If BASE tag is in play, using appendChild is a problem for IE6.
1890
+ //When that browser dies, this can be removed. Details in this jQuery bug:
1891
+ //http://dev.jquery.com/ticket/2709
1892
+ baseElement = document.getElementsByTagName('base')[0];
1893
+ if (baseElement) {
1894
+ head = s.head = baseElement.parentNode;
1895
+ }
1896
+ }
1897
+
1898
+ /**
1899
+ * Any errors that require explicitly generates will be passed to this
1900
+ * function. Intercept/override it if you want custom error handling.
1901
+ * @param {Error} err the error object.
1902
+ */
1903
+ req.onError = defaultOnError;
1904
+
1905
+ /**
1906
+ * Creates the node for the load command. Only used in browser envs.
1907
+ */
1908
+ req.createNode = function (config, moduleName, url) {
1909
+ var node = config.xhtml ?
1910
+ document.createElementNS('http://www.w3.org/1999/xhtml', 'html:script') :
1911
+ document.createElement('script');
1912
+ node.type = config.scriptType || 'text/javascript';
1913
+ node.charset = 'utf-8';
1914
+ node.async = true;
1915
+ return node;
1916
+ };
1917
+
1918
+ /**
1919
+ * Does the request to load a module for the browser case.
1920
+ * Make this a separate function to allow other environments
1921
+ * to override it.
1922
+ *
1923
+ * @param {Object} context the require context to find state.
1924
+ * @param {String} moduleName the name of the module.
1925
+ * @param {Object} url the URL to the module.
1926
+ */
1927
+ req.load = function (context, moduleName, url) {
1928
+ var config = (context && context.config) || {},
1929
+ node;
1930
+ if (isBrowser) {
1931
+ //In the browser so use a script tag
1932
+ node = req.createNode(config, moduleName, url);
1933
+
1934
+ node.setAttribute('data-requirecontext', context.contextName);
1935
+ node.setAttribute('data-requiremodule', moduleName);
1936
+
1937
+ //Set up load listener. Test attachEvent first because IE9 has
1938
+ //a subtle issue in its addEventListener and script onload firings
1939
+ //that do not match the behavior of all other browsers with
1940
+ //addEventListener support, which fire the onload event for a
1941
+ //script right after the script execution. See:
1942
+ //https://connect.microsoft.com/IE/feedback/details/648057/script-onload-event-is-not-fired-immediately-after-script-execution
1943
+ //UNFORTUNATELY Opera implements attachEvent but does not follow the script
1944
+ //script execution mode.
1945
+ if (node.attachEvent &&
1946
+ //Check if node.attachEvent is artificially added by custom script or
1947
+ //natively supported by browser
1948
+ //read https://github.com/requirejs/requirejs/issues/187
1949
+ //if we can NOT find [native code] then it must NOT natively supported.
1950
+ //in IE8, node.attachEvent does not have toString()
1951
+ //Note the test for "[native code" with no closing brace, see:
1952
+ //https://github.com/requirejs/requirejs/issues/273
1953
+ !(node.attachEvent.toString && node.attachEvent.toString().indexOf('[native code') < 0) &&
1954
+ !isOpera) {
1955
+ //Probably IE. IE (at least 6-8) do not fire
1956
+ //script onload right after executing the script, so
1957
+ //we cannot tie the anonymous define call to a name.
1958
+ //However, IE reports the script as being in 'interactive'
1959
+ //readyState at the time of the define call.
1960
+ useInteractive = true;
1961
+
1962
+ node.attachEvent('onreadystatechange', context.onScriptLoad);
1963
+ //It would be great to add an error handler here to catch
1964
+ //404s in IE9+. However, onreadystatechange will fire before
1965
+ //the error handler, so that does not help. If addEventListener
1966
+ //is used, then IE will fire error before load, but we cannot
1967
+ //use that pathway given the connect.microsoft.com issue
1968
+ //mentioned above about not doing the 'script execute,
1969
+ //then fire the script load event listener before execute
1970
+ //next script' that other browsers do.
1971
+ //Best hope: IE10 fixes the issues,
1972
+ //and then destroys all installs of IE 6-9.
1973
+ //node.attachEvent('onerror', context.onScriptError);
1974
+ } else {
1975
+ node.addEventListener('load', context.onScriptLoad, false);
1976
+ node.addEventListener('error', context.onScriptError, false);
1977
+ }
1978
+ node.src = url;
1979
+
1980
+ //Calling onNodeCreated after all properties on the node have been
1981
+ //set, but before it is placed in the DOM.
1982
+ if (config.onNodeCreated) {
1983
+ config.onNodeCreated(node, config, moduleName, url);
1984
+ }
1985
+
1986
+ //For some cache cases in IE 6-8, the script executes before the end
1987
+ //of the appendChild execution, so to tie an anonymous define
1988
+ //call to the module name (which is stored on the node), hold on
1989
+ //to a reference to this node, but clear after the DOM insertion.
1990
+ currentlyAddingScript = node;
1991
+ if (baseElement) {
1992
+ head.insertBefore(node, baseElement);
1993
+ } else {
1994
+ head.appendChild(node);
1995
+ }
1996
+ currentlyAddingScript = null;
1997
+
1998
+ return node;
1999
+ } else if (isWebWorker) {
2000
+ try {
2001
+ //In a web worker, use importScripts. This is not a very
2002
+ //efficient use of importScripts, importScripts will block until
2003
+ //its script is downloaded and evaluated. However, if web workers
2004
+ //are in play, the expectation is that a build has been done so
2005
+ //that only one script needs to be loaded anyway. This may need
2006
+ //to be reevaluated if other use cases become common.
2007
+
2008
+ // Post a task to the event loop to work around a bug in WebKit
2009
+ // where the worker gets garbage-collected after calling
2010
+ // importScripts(): https://webkit.org/b/153317
2011
+ setTimeout(function() {}, 0);
2012
+ importScripts(url);
2013
+
2014
+ //Account for anonymous modules
2015
+ context.completeLoad(moduleName);
2016
+ } catch (e) {
2017
+ context.onError(makeError('importscripts',
2018
+ 'importScripts failed for ' +
2019
+ moduleName + ' at ' + url,
2020
+ e,
2021
+ [moduleName]));
2022
+ }
2023
+ }
2024
+ };
2025
+
2026
+ function getInteractiveScript() {
2027
+ if (interactiveScript && interactiveScript.readyState === 'interactive') {
2028
+ return interactiveScript;
2029
+ }
2030
+
2031
+ eachReverse(scripts(), function (script) {
2032
+ if (script.readyState === 'interactive') {
2033
+ return (interactiveScript = script);
2034
+ }
2035
+ });
2036
+ return interactiveScript;
2037
+ }
2038
+
2039
+ //Look for a data-main script attribute, which could also adjust the baseUrl.
2040
+ if (isBrowser && !cfg.skipDataMain) {
2041
+ //Figure out baseUrl. Get it from the script tag with require.js in it.
2042
+ eachReverse(scripts(), function (script) {
2043
+ //Set the 'head' where we can append children by
2044
+ //using the script's parent.
2045
+ if (!head) {
2046
+ head = script.parentNode;
2047
+ }
2048
+
2049
+ //Look for a data-main attribute to set main script for the page
2050
+ //to load. If it is there, the path to data main becomes the
2051
+ //baseUrl, if it is not already set.
2052
+ dataMain = script.getAttribute('data-main');
2053
+ if (dataMain) {
2054
+ //Preserve dataMain in case it is a path (i.e. contains '?')
2055
+ mainScript = dataMain;
2056
+
2057
+ //Set final baseUrl if there is not already an explicit one,
2058
+ //but only do so if the data-main value is not a loader plugin
2059
+ //module ID.
2060
+ if (!cfg.baseUrl && mainScript.indexOf('!') === -1) {
2061
+ //Pull off the directory of data-main for use as the
2062
+ //baseUrl.
2063
+ src = mainScript.split('/');
2064
+ mainScript = src.pop();
2065
+ subPath = src.length ? src.join('/') + '/' : './';
2066
+
2067
+ cfg.baseUrl = subPath;
2068
+ }
2069
+
2070
+ //Strip off any trailing .js since mainScript is now
2071
+ //like a module name.
2072
+ mainScript = mainScript.replace(jsSuffixRegExp, '');
2073
+
2074
+ //If mainScript is still a path, fall back to dataMain
2075
+ if (req.jsExtRegExp.test(mainScript)) {
2076
+ mainScript = dataMain;
2077
+ }
2078
+
2079
+ //Put the data-main script in the files to load.
2080
+ cfg.deps = cfg.deps ? cfg.deps.concat(mainScript) : [mainScript];
2081
+
2082
+ return true;
2083
+ }
2084
+ });
2085
+ }
2086
+
2087
+ /**
2088
+ * The function that handles definitions of modules. Differs from
2089
+ * require() in that a string for the module should be the first argument,
2090
+ * and the function to execute after dependencies are loaded should
2091
+ * return a value to define the module corresponding to the first argument's
2092
+ * name.
2093
+ */
2094
+ define = function (name, deps, callback) {
2095
+ var node, context;
2096
+
2097
+ //Allow for anonymous modules
2098
+ if (typeof name !== 'string') {
2099
+ //Adjust args appropriately
2100
+ callback = deps;
2101
+ deps = name;
2102
+ name = null;
2103
+ }
2104
+
2105
+ //This module may not have dependencies
2106
+ if (!isArray(deps)) {
2107
+ callback = deps;
2108
+ deps = null;
2109
+ }
2110
+
2111
+ //If no name, and callback is a function, then figure out if it a
2112
+ //CommonJS thing with dependencies.
2113
+ if (!deps && isFunction(callback)) {
2114
+ deps = [];
2115
+ //Remove comments from the callback string,
2116
+ //look for require calls, and pull them into the dependencies,
2117
+ //but only if there are function args.
2118
+ if (callback.length) {
2119
+ callback
2120
+ .toString()
2121
+ .replace(commentRegExp, commentReplace)
2122
+ .replace(cjsRequireRegExp, function (match, dep) {
2123
+ deps.push(dep);
2124
+ });
2125
+
2126
+ //May be a CommonJS thing even without require calls, but still
2127
+ //could use exports, and module. Avoid doing exports and module
2128
+ //work though if it just needs require.
2129
+ //REQUIRES the function to expect the CommonJS variables in the
2130
+ //order listed below.
2131
+ deps = (callback.length === 1 ? ['require'] : ['require', 'exports', 'module']).concat(deps);
2132
+ }
2133
+ }
2134
+
2135
+ //If in IE 6-8 and hit an anonymous define() call, do the interactive
2136
+ //work.
2137
+ if (useInteractive) {
2138
+ node = currentlyAddingScript || getInteractiveScript();
2139
+ if (node) {
2140
+ if (!name) {
2141
+ name = node.getAttribute('data-requiremodule');
2142
+ }
2143
+ context = contexts[node.getAttribute('data-requirecontext')];
2144
+ }
2145
+ }
2146
+
2147
+ //Always save off evaluating the def call until the script onload handler.
2148
+ //This allows multiple modules to be in a file without prematurely
2149
+ //tracing dependencies, and allows for anonymous module support,
2150
+ //where the module name is not known until the script onload event
2151
+ //occurs. If no context, use the global queue, and get it processed
2152
+ //in the onscript load callback.
2153
+ if (context) {
2154
+ context.defQueue.push([name, deps, callback]);
2155
+ context.defQueueMap[name] = true;
2156
+ } else {
2157
+ globalDefQueue.push([name, deps, callback]);
2158
+ }
2159
+ };
2160
+
2161
+ define.amd = {
2162
+ jQuery: true
2163
+ };
2164
+
2165
+ /**
2166
+ * Executes the text. Normally just uses eval, but can be modified
2167
+ * to use a better, environment-specific call. Only used for transpiling
2168
+ * loader plugins, not for plain JS modules.
2169
+ * @param {String} text the text to execute/evaluate.
2170
+ */
2171
+ req.exec = function (text) {
2172
+ /*jslint evil: true */
2173
+ return eval(text);
2174
+ };
2175
+
2176
+ //Set up with config info.
2177
+ req(cfg);
2178
+
2179
+ global.requirejs = global.require = req;
2180
+ global.define = define;
2181
+ }(window, (typeof setTimeout === 'undefined' ? undefined : setTimeout)));
2182
+
2183
+
2184
+ /***/ }),
2185
+
2186
+ /***/ "./node_modules/nycticorax/dist/index.js":
2187
+ /*!***********************************************!*\
2188
+ !*** ./node_modules/nycticorax/dist/index.js ***!
2189
+ \***********************************************/
2190
+ /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
2191
+
2192
+ !function(t,e){ true?module.exports=e(__webpack_require__(/*! react */ "react")):0}(self,(t=>(()=>{"use strict";var e={294:(t,e,r)=>{r.d(e,{default:()=>c});var s=r(942),o=r(63),n=r.n(o);function i(t,e=new WeakMap){if("object"!=typeof t||null===t)return t;if(e.has(t))return e.get(t);const r=Array.isArray(t)?[]:{};e.set(t,r);const s=Reflect.ownKeys(t);for(const o of s)r[o]=i(t[o],e);return r}class c{constructor(){var t;(0,s.Z)(this,"state",void 0),(0,s.Z)(this,"listeners",void 0),(0,s.Z)(this,"emits",void 0),(0,s.Z)(this,"timer",void 0),(0,s.Z)(this,"onStateChange",void 0),(0,s.Z)(this,"getStore",void 0),(0,s.Z)(this,"createStore",(t=>{this.listeners=Reflect.ownKeys(t).reduce(((e,r)=>{const s=r;return this.state[s]=t[s],{...e,[r]:[]}}),{})})),(0,s.Z)(this,"subscribe",(t=>{const e={};return Reflect.ownKeys(t).forEach((r=>{const s=r;this.listeners[s]||(this.listeners[s]=[]),this.listeners[s].push(t[s]),e[s]=t[s]})),()=>{Reflect.ownKeys(e).forEach((t=>{const r=t;this.listeners[r]=this.listeners[r].filter((t=>t!==e[r]))}))}})),(0,s.Z)(this,"emit",((t,e)=>{this.emits={...this.emits,...t},e?this.trigger():(clearTimeout(this.timer),this.timer=setTimeout(this.trigger))})),(0,s.Z)(this,"dispatch",((t,...e)=>t({getStore:this.getStore,emit:t=>this.emit(t,!0)},...e))),(0,s.Z)(this,"trigger",(()=>{const t=this.emits,e=[],r=Reflect.ownKeys(t);for(let s=0;s<r.length;s+=1){const o=r[s];if(n()(this.state[o],t[o]))continue;const c=t[o],u=this.state[o];this.state[o]=i(t[o]),e.push({key:o,newValue:c,oldValue:u})}const s={};e.forEach((t=>{s[t.key]=[t.newValue,t.oldValue],this.listeners[t.key]&&this.listeners[t.key].forEach((e=>e(t.newValue,t.oldValue)))})),e.length&&this.onStateChange(s),this.emits={},this.timer=void 0})),this.state={},this.listeners={},this.emits={},this.timer=void 0,this.onStateChange=()=>null,this.getStore=(t=this.state,function(e){return e?i(t[e]):t})}set onChange(t){this.onStateChange=t}}},63:t=>{t.exports=function t(e,r){if(e===r)return!0;if(e&&r&&"object"==typeof e&&"object"==typeof r){if(e.constructor!==r.constructor)return!1;var s,o,n;if(Array.isArray(e)){if((s=e.length)!=r.length)return!1;for(o=s;0!=o--;)if(!t(e[o],r[o]))return!1;return!0}if(e.constructor===RegExp)return e.source===r.source&&e.flags===r.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===r.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===r.toString();if((s=(n=Object.keys(e)).length)!==Object.keys(r).length)return!1;for(o=s;0!=o--;)if(!Object.prototype.hasOwnProperty.call(r,n[o]))return!1;for(o=s;0!=o--;){var i=n[o];if(!t(e[i],r[i]))return!1}return!0}return e!=e&&r!=r}},250:e=>{e.exports=t},942:(t,e,r)=>{function s(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}r.d(e,{Z:()=>s})}},r={};function s(t){var o=r[t];if(void 0!==o)return o.exports;var n=r[t]={exports:{}};return e[t](n,n.exports,s),n.exports}s.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return s.d(e,{a:e}),e},s.d=(t,e)=>{for(var r in e)s.o(e,r)&&!s.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},s.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var o={};return(()=>{s.d(o,{default:()=>u});var t=s(942),e=s(294),r=s(250),n=s.n(r);const i=["name","prototype","length","propTypes","defaultProps","getDerivedStateFromProps","contextTypes","displayName"];class c extends e.default{constructor(...e){super(...e),(0,t.Z)(this,"connect",function(e){const{getStore:s,subscribe:o}=e;return function(...e){return function(c){class u extends r.Component{constructor(r){super(r),(0,t.Z)(this,"unsubscribe",void 0),(0,t.Z)(this,"state",{props:s()}),this.unsubscribe=o(e.reduce(((t,e)=>({...t,[e]:()=>{this.setState({props:s()})}})),{}))}componentWillUnmount(){this.unsubscribe()}render(){const{props:t}=this.state,e={...t,...this.props};return n().createElement(c,e)}}return Object.getOwnPropertyNames(c).forEach((t=>{const e=t;i.includes(t)||(u[e]=c[e])})),u}}}(this)),(0,t.Z)(this,"useStore",function(t){const{getStore:e,subscribe:s}=t;return function(...t){const[o,n]=(0,r.useState)(e());return(0,r.useLayoutEffect)((()=>s(t.reduce(((t,r)=>({...t,[r]:()=>{n((t=>({...t,[r]:e()[r]})))}})),{})))),o}}(this))}}const u=c})(),o.default})()));
2193
+ //# sourceMappingURL=index.js.map
2194
+
2195
+ /***/ }),
2196
+
2197
+ /***/ "./src/core/config.ts":
2198
+ /*!****************************!*\
2199
+ !*** ./src/core/config.ts ***!
2200
+ \****************************/
2201
+ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
2202
+
2203
+ "use strict";
2204
+ __webpack_require__.r(__webpack_exports__);
2205
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2206
+ /* harmony export */ BASE_DEPENDENCIES: function() { return /* binding */ BASE_DEPENDENCIES; },
2207
+ /* harmony export */ CONFIG_KEY: function() { return /* binding */ CONFIG_KEY; },
2208
+ /* harmony export */ DEPENDENCIES_KEY: function() { return /* binding */ DEPENDENCIES_KEY; },
2209
+ /* harmony export */ MESSAGE_KEY: function() { return /* binding */ MESSAGE_KEY; },
2210
+ /* harmony export */ MOUNTED_COMPONENTS_KEY: function() { return /* binding */ MOUNTED_COMPONENTS_KEY; },
2211
+ /* harmony export */ VUE_FUNCTION_OPTIONS: function() { return /* binding */ VUE_FUNCTION_OPTIONS; },
2212
+ /* harmony export */ VUE_VERSION: function() { return /* binding */ VUE_VERSION; }
2213
+ /* harmony export */ });
2214
+ const MOUNTED_COMPONENTS_KEY = Symbol('MOUNTED_COMPONENTS');
2215
+ const MESSAGE_KEY = Symbol('MESSAGE');
2216
+ const CONFIG_KEY = Symbol('CONFIG');
2217
+ const DEPENDENCIES_KEY = Symbol('DEPENDENCIES');
2218
+ const VUE_FUNCTION_OPTIONS = ['beforeCreate', 'created', 'beforeMount', 'mounted', 'beforeUpdate', 'updated', 'beforeUnmount', 'unmounted', 'errorCaptured', 'renderTracked', 'renderTriggered', 'activated', 'deactivated', 'setup', 'data', 'render'];
2219
+ const VUE_VERSION = 3;
2220
+ const BASE_DEPENDENCIES = ['react', 'react-dom', '@variousjs/various', 'app'];
2221
+
2222
+ /***/ }),
2223
+
2224
+ /***/ "./src/core/connector.ts":
2225
+ /*!*******************************!*\
2226
+ !*** ./src/core/connector.ts ***!
2227
+ \*******************************/
2228
+ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
2229
+
2230
+ "use strict";
2231
+ __webpack_require__.r(__webpack_exports__);
2232
+ /* harmony import */ var _default_component__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./default-component */ "./src/core/default-component.tsx");
2233
+ /* harmony import */ var _helper__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./helper */ "./src/core/helper.ts");
2234
+
2235
+
2236
+ class Connector {
2237
+ constructor() {
2238
+ this.fallbackComponent = _default_component__WEBPACK_IMPORTED_MODULE_0__.Fallback;
2239
+ this.errorFallbackComponent = _default_component__WEBPACK_IMPORTED_MODULE_0__.ErrorFallback;
2240
+ this.storeActions = {};
2241
+ this.componentActions = {};
2242
+ this.i18nConfigs = {};
2243
+ this.middlewares = {};
2244
+ }
2245
+ setMiddlewares(m) {
2246
+ this.middlewares = m;
2247
+ }
2248
+ getMiddlewares() {
2249
+ return this.middlewares;
2250
+ }
2251
+ setI18nConfig(moduleDefined, config) {
2252
+ const name = (0,_helper__WEBPACK_IMPORTED_MODULE_1__.getNameWithModule)(moduleDefined);
2253
+ this.i18nConfigs[name] = {
2254
+ ...this.i18nConfigs[name],
2255
+ ...config
2256
+ };
2257
+ }
2258
+ getI18nConfig(moduleDefined) {
2259
+ const name = (0,_helper__WEBPACK_IMPORTED_MODULE_1__.getNameWithModule)(moduleDefined);
2260
+ return this.i18nConfigs[name];
2261
+ }
2262
+ setGlobalI18nConfig(config) {
2263
+ this.globalI18nConfig = {
2264
+ ...this.globalI18nConfig,
2265
+ ...config
2266
+ };
2267
+ }
2268
+ getGlobalI18nConfig() {
2269
+ return this.globalI18nConfig;
2270
+ }
2271
+ setComponentActions(moduleDefined, actions) {
2272
+ const name = (0,_helper__WEBPACK_IMPORTED_MODULE_1__.getNameWithModule)(moduleDefined);
2273
+ this.componentActions[name] = actions;
2274
+ }
2275
+ deleteComponentActions(moduleDefined) {
2276
+ const name = (0,_helper__WEBPACK_IMPORTED_MODULE_1__.getNameWithModule)(moduleDefined);
2277
+ delete this.componentActions[name];
2278
+ }
2279
+ getComponentActions(moduleDefined) {
2280
+ const name = (0,_helper__WEBPACK_IMPORTED_MODULE_1__.getNameWithModule)(moduleDefined);
2281
+ return this.componentActions[name];
2282
+ }
2283
+ setStoreActions(actions) {
2284
+ this.storeActions = actions;
2285
+ }
2286
+ getStoreActions() {
2287
+ return this.storeActions;
2288
+ }
2289
+ setFallbackComponent(fallbackComponent) {
2290
+ this.fallbackComponent = fallbackComponent;
2291
+ }
2292
+ getFallbackComponent() {
2293
+ return this.fallbackComponent;
2294
+ }
2295
+ setErrorFallbackComponent(errorFallbackComponent) {
2296
+ this.errorFallbackComponent = errorFallbackComponent;
2297
+ }
2298
+ getErrorFallbackComponent() {
2299
+ return this.errorFallbackComponent;
2300
+ }
2301
+ }
2302
+ /* harmony default export */ __webpack_exports__["default"] = (new Connector());
2303
+
2304
+ /***/ }),
2305
+
2306
+ /***/ "./src/core/create-component.tsx":
2307
+ /*!***************************************!*\
2308
+ !*** ./src/core/create-component.tsx ***!
2309
+ \***************************************/
2310
+ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
2311
+
2312
+ "use strict";
2313
+ __webpack_require__.r(__webpack_exports__);
2314
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
2315
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
2316
+ /* harmony import */ var _react_component__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./react-component */ "./src/core/react-component.tsx");
2317
+ /* harmony import */ var _vue_component__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./vue-component */ "./src/core/vue-component.tsx");
2318
+ /* harmony import */ var _error_boundary__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./error-boundary */ "./src/core/error-boundary.tsx");
2319
+
2320
+
2321
+
2322
+
2323
+ const createComponent = (config, storeKeys) => {
2324
+ const {
2325
+ name,
2326
+ module,
2327
+ url,
2328
+ type = 'react'
2329
+ } = config;
2330
+ const C = (type === 'vue3' ? _vue_component__WEBPACK_IMPORTED_MODULE_2__["default"] : _react_component__WEBPACK_IMPORTED_MODULE_1__["default"])({
2331
+ name,
2332
+ module,
2333
+ url,
2334
+ watchKeys: storeKeys
2335
+ });
2336
+ const component = props => {
2337
+ const {
2338
+ $silent,
2339
+ $ref,
2340
+ ...rest
2341
+ } = props || {};
2342
+ const nextProps = {
2343
+ $componentProps: rest,
2344
+ $silent,
2345
+ $ref
2346
+ };
2347
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_error_boundary__WEBPACK_IMPORTED_MODULE_3__["default"], {
2348
+ name: name,
2349
+ module: module,
2350
+ url: url
2351
+ }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(C, nextProps));
2352
+ };
2353
+ component.displayName = 'various-creator';
2354
+ return component;
2355
+ };
2356
+ /* harmony default export */ __webpack_exports__["default"] = (createComponent);
2357
+
2358
+ /***/ }),
2359
+
2360
+ /***/ "./src/core/create-module.ts":
2361
+ /*!***********************************!*\
2362
+ !*** ./src/core/create-module.ts ***!
2363
+ \***********************************/
2364
+ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
2365
+
2366
+ "use strict";
2367
+ __webpack_require__.r(__webpack_exports__);
2368
+ /* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./config */ "./src/core/config.ts");
2369
+ /* harmony import */ var _store__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./store */ "./src/core/store.ts");
2370
+ /* harmony import */ var _connector__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./connector */ "./src/core/connector.ts");
2371
+ /* harmony import */ var _helper__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./helper */ "./src/core/helper.ts");
2372
+
2373
+
2374
+
2375
+
2376
+ const createModule = (config, logError = true) => {
2377
+ const dependencies = (0,_store__WEBPACK_IMPORTED_MODULE_1__.getStore)(_config__WEBPACK_IMPORTED_MODULE_0__.DEPENDENCIES_KEY);
2378
+ const middlewares = _connector__WEBPACK_IMPORTED_MODULE_2__["default"].getMiddlewares();
2379
+ const {
2380
+ name,
2381
+ module,
2382
+ url
2383
+ } = config;
2384
+ const loadStart = +new Date();
2385
+ const logOnError = e => {
2386
+ if (logError) {
2387
+ (0,_helper__WEBPACK_IMPORTED_MODULE_3__.onError)(e);
2388
+ }
2389
+ };
2390
+ if (url) {
2391
+ (0,_helper__WEBPACK_IMPORTED_MODULE_3__.resetDependencyConfig)(name, url);
2392
+ }
2393
+ return new Promise((resolve, reject) => {
2394
+ if (!url && !dependencies[name] && !(0,_helper__WEBPACK_IMPORTED_MODULE_3__.isModuleSpecified)(name)) {
2395
+ const error = new _helper__WEBPACK_IMPORTED_MODULE_3__.VariousError({
2396
+ name,
2397
+ module,
2398
+ type: 'NOT_DEFINED',
2399
+ originalError: new Error(`module "${name}" not defined`)
2400
+ });
2401
+ logOnError(error);
2402
+ reject(error);
2403
+ return;
2404
+ }
2405
+ window.requirejs([name], C => {
2406
+ const loadEnd = +new Date();
2407
+ middlewares?.onLoad?.({
2408
+ name,
2409
+ module,
2410
+ loadStart,
2411
+ loadEnd,
2412
+ beenLoaded: (0,_helper__WEBPACK_IMPORTED_MODULE_3__.isModuleLoaded)(name)
2413
+ });
2414
+ if (!C) {
2415
+ const error = new _helper__WEBPACK_IMPORTED_MODULE_3__.VariousError({
2416
+ name,
2417
+ module,
2418
+ type: 'INVALID_MODULE',
2419
+ originalError: new Error(`module "${name}" invalid`)
2420
+ });
2421
+ (0,_helper__WEBPACK_IMPORTED_MODULE_3__.resetDependencyConfig)(name);
2422
+ logOnError(error);
2423
+ reject(error);
2424
+ return;
2425
+ }
2426
+ const defaultModule = 'default' in C ? C.default : C;
2427
+ const actualModule = !module ? defaultModule : C[module];
2428
+ if (actualModule === undefined && module) {
2429
+ const error = new _helper__WEBPACK_IMPORTED_MODULE_3__.VariousError({
2430
+ name,
2431
+ module,
2432
+ type: 'SUBMODULE_NOT_DEFINED',
2433
+ originalError: new Error(`submodule "${module}" not defined`)
2434
+ });
2435
+ (0,_helper__WEBPACK_IMPORTED_MODULE_3__.resetDependencyConfig)(name);
2436
+ logOnError(error);
2437
+ reject(error);
2438
+ return;
2439
+ }
2440
+ resolve(actualModule);
2441
+ }, e => {
2442
+ const [requireModule] = e.requireModules;
2443
+ (0,_helper__WEBPACK_IMPORTED_MODULE_3__.resetDependencyConfig)(name, url);
2444
+ (0,_helper__WEBPACK_IMPORTED_MODULE_3__.resetDependencyConfig)(requireModule);
2445
+ let errorType = 'LOADING_ERROR';
2446
+ if (requireModule !== name) {
2447
+ errorType = 'SUBMODULE_LOADING_ERROR';
2448
+ }
2449
+ if (!e.message.includes('https://requirejs.org/docs/errors.html')) {
2450
+ errorType = requireModule === name ? 'SCRIPT_ERROR' : 'SUBMODULE_SCRIPT_ERROR';
2451
+ }
2452
+ const error = new _helper__WEBPACK_IMPORTED_MODULE_3__.VariousError({
2453
+ name,
2454
+ module: requireModule === name ? undefined : requireModule,
2455
+ type: errorType,
2456
+ originalError: e
2457
+ });
2458
+ logOnError(error);
2459
+ reject(error);
2460
+ });
2461
+ });
2462
+ };
2463
+ /* harmony default export */ __webpack_exports__["default"] = (createModule);
2464
+
2465
+ /***/ }),
2466
+
2467
+ /***/ "./src/core/default-component.tsx":
2468
+ /*!****************************************!*\
2469
+ !*** ./src/core/default-component.tsx ***!
2470
+ \****************************************/
2471
+ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
2472
+
2473
+ "use strict";
2474
+ __webpack_require__.r(__webpack_exports__);
2475
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2476
+ /* harmony export */ ErrorFallback: function() { return /* binding */ ErrorFallback; },
2477
+ /* harmony export */ Fallback: function() { return /* binding */ Fallback; },
2478
+ /* harmony export */ Root: function() { return /* binding */ Root; }
2479
+ /* harmony export */ });
2480
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
2481
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
2482
+ /* harmony import */ var _helper__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./helper */ "./src/core/helper.ts");
2483
+
2484
+
2485
+ const Fallback = props => {
2486
+ const className = (0,_helper__WEBPACK_IMPORTED_MODULE_1__.getClassNameWithModule)(props.$self, 'various-component-fallback');
2487
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
2488
+ className: className
2489
+ }, "Loading");
2490
+ };
2491
+ const ErrorFallback = ({
2492
+ $error,
2493
+ $reload,
2494
+ $self
2495
+ }) => {
2496
+ const className = (0,_helper__WEBPACK_IMPORTED_MODULE_1__.getClassNameWithModule)($self, 'various-component-error_fallback');
2497
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
2498
+ className: className
2499
+ }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("h3", null, $error.type), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("p", null, $error.message), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("button", {
2500
+ type: "button",
2501
+ onClick: $reload
2502
+ }, "Reload"));
2503
+ };
2504
+ const Root = () => /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", null, "App Container is not defined");
2505
+
2506
+ /***/ }),
2507
+
2508
+ /***/ "./src/core/dispatch.ts":
2509
+ /*!******************************!*\
2510
+ !*** ./src/core/dispatch.ts ***!
2511
+ \******************************/
2512
+ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
2513
+
2514
+ "use strict";
2515
+ __webpack_require__.r(__webpack_exports__);
2516
+ /* harmony import */ var _connector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./connector */ "./src/core/connector.ts");
2517
+ /* harmony import */ var _store__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./store */ "./src/core/store.ts");
2518
+ /* harmony import */ var _helper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./helper */ "./src/core/helper.ts");
2519
+ /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./logger */ "./src/core/logger.ts");
2520
+
2521
+
2522
+
2523
+
2524
+ const createDispatch = moduleDefined => async function (params) {
2525
+ const middlewares = _connector__WEBPACK_IMPORTED_MODULE_0__["default"].getMiddlewares();
2526
+ const logger = (0,_logger__WEBPACK_IMPORTED_MODULE_3__["default"])(moduleDefined);
2527
+ let {
2528
+ name,
2529
+ module,
2530
+ action,
2531
+ value
2532
+ } = params;
2533
+ if (middlewares?.onDispatch) {
2534
+ const check = await middlewares.onDispatch({
2535
+ target: {
2536
+ name,
2537
+ module
2538
+ },
2539
+ action,
2540
+ value,
2541
+ trigger: moduleDefined
2542
+ });
2543
+ if (check === false) {
2544
+ logger.warn('blocked by middleware', 'DISPATCH');
2545
+ return Promise.resolve();
2546
+ }
2547
+ if (check !== true) {
2548
+ name = check.target.name;
2549
+ module = check.target.module;
2550
+ action = check.action;
2551
+ value = check.value;
2552
+ }
2553
+ }
2554
+ if (name === 'app') {
2555
+ const storeActions = _connector__WEBPACK_IMPORTED_MODULE_0__["default"].getStoreActions();
2556
+ const storeAction = storeActions[action];
2557
+ if (!storeAction) {
2558
+ const errorMessage = `action "${action}" is not present`;
2559
+ const error = new _helper__WEBPACK_IMPORTED_MODULE_2__.VariousError({
2560
+ ...moduleDefined,
2561
+ type: 'DISPATCH',
2562
+ originalError: new Error(errorMessage)
2563
+ });
2564
+ (0,_helper__WEBPACK_IMPORTED_MODULE_2__.onError)(error);
2565
+ throw error;
2566
+ }
2567
+ return (0,_store__WEBPACK_IMPORTED_MODULE_1__.dispatch)(storeAction, value, moduleDefined);
2568
+ }
2569
+ const componentActions = _connector__WEBPACK_IMPORTED_MODULE_0__["default"].getComponentActions({
2570
+ name,
2571
+ module
2572
+ });
2573
+ if (!componentActions) {
2574
+ const errorMessage = 'component is not ready';
2575
+ const error = new _helper__WEBPACK_IMPORTED_MODULE_2__.VariousError({
2576
+ ...moduleDefined,
2577
+ type: 'DISPATCH',
2578
+ originalError: new Error(errorMessage)
2579
+ });
2580
+ (0,_helper__WEBPACK_IMPORTED_MODULE_2__.onError)(error);
2581
+ throw error;
2582
+ }
2583
+ const componentAction = componentActions[action];
2584
+ if (!componentAction) {
2585
+ const errorMessage = `action "${action}" is not present`;
2586
+ const error = new _helper__WEBPACK_IMPORTED_MODULE_2__.VariousError({
2587
+ ...moduleDefined,
2588
+ type: 'DISPATCH',
2589
+ originalError: new Error(errorMessage)
2590
+ });
2591
+ (0,_helper__WEBPACK_IMPORTED_MODULE_2__.onError)(error);
2592
+ throw error;
2593
+ }
2594
+ return Promise.resolve(componentAction(value, moduleDefined));
2595
+ };
2596
+ /* harmony default export */ __webpack_exports__["default"] = (createDispatch);
2597
+
2598
+ /***/ }),
2599
+
2600
+ /***/ "./src/core/error-boundary.tsx":
2601
+ /*!*************************************!*\
2602
+ !*** ./src/core/error-boundary.tsx ***!
2603
+ \*************************************/
2604
+ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
2605
+
2606
+ "use strict";
2607
+ __webpack_require__.r(__webpack_exports__);
2608
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
2609
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
2610
+ /* harmony import */ var _helper__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./helper */ "./src/core/helper.ts");
2611
+ /* harmony import */ var _connector__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./connector */ "./src/core/connector.ts");
2612
+ /* harmony import */ var _store__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./store */ "./src/core/store.ts");
2613
+
2614
+
2615
+
2616
+
2617
+ class ErrorBoundary extends react__WEBPACK_IMPORTED_MODULE_0__.Component {
2618
+ static displayName = 'various-error-boundary';
2619
+ state = {
2620
+ hasError: false
2621
+ };
2622
+ componentDidCatch(e) {
2623
+ const {
2624
+ name,
2625
+ module
2626
+ } = this.props;
2627
+ const error = e instanceof _helper__WEBPACK_IMPORTED_MODULE_1__.VariousError ? e : new _helper__WEBPACK_IMPORTED_MODULE_1__.VariousError({
2628
+ name,
2629
+ module,
2630
+ type: name === 'app' ? 'APP_ERROR' : 'SCRIPT_ERROR',
2631
+ originalError: e
2632
+ });
2633
+ this.setState({
2634
+ hasError: true
2635
+ });
2636
+ this.error = error;
2637
+ (0,_helper__WEBPACK_IMPORTED_MODULE_1__.onError)(error);
2638
+ (0,_helper__WEBPACK_IMPORTED_MODULE_1__.resetDependencyConfig)(this.props.name);
2639
+ (0,_helper__WEBPACK_IMPORTED_MODULE_1__.updateUnMountComponent)({
2640
+ name,
2641
+ module
2642
+ });
2643
+ }
2644
+ $self = (0,_helper__WEBPACK_IMPORTED_MODULE_1__.getSelfInfo)(this.props);
2645
+ reload = () => {
2646
+ this.error = undefined;
2647
+ this.setState({
2648
+ hasError: false
2649
+ });
2650
+ };
2651
+ render() {
2652
+ const ErrorFallbackNode = _connector__WEBPACK_IMPORTED_MODULE_2__["default"].getErrorFallbackComponent();
2653
+ const store = (0,_store__WEBPACK_IMPORTED_MODULE_3__.getUserStore)();
2654
+ if (this.state.hasError) {
2655
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(ErrorFallbackNode, {
2656
+ $self: this.$self,
2657
+ $reload: this.reload,
2658
+ $store: store,
2659
+ $error: this.error
2660
+ });
2661
+ }
2662
+ return this.props.children;
2663
+ }
2664
+ }
2665
+ /* harmony default export */ __webpack_exports__["default"] = (ErrorBoundary);
2666
+
2667
+ /***/ }),
2668
+
2669
+ /***/ "./src/core/helper.ts":
2670
+ /*!****************************!*\
2671
+ !*** ./src/core/helper.ts ***!
2672
+ \****************************/
2673
+ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
2674
+
2675
+ "use strict";
2676
+ __webpack_require__.r(__webpack_exports__);
2677
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2678
+ /* harmony export */ VariousError: function() { return /* binding */ VariousError; },
2679
+ /* harmony export */ checkReactComponent: function() { return /* binding */ checkReactComponent; },
2680
+ /* harmony export */ checkVueComponent: function() { return /* binding */ checkVueComponent; },
2681
+ /* harmony export */ defineDependencies: function() { return /* binding */ defineDependencies; },
2682
+ /* harmony export */ getClassNameWithModule: function() { return /* binding */ getClassNameWithModule; },
2683
+ /* harmony export */ getConfig: function() { return /* binding */ getConfig; },
2684
+ /* harmony export */ getMountedComponents: function() { return /* binding */ getMountedComponents; },
2685
+ /* harmony export */ getNameWithModule: function() { return /* binding */ getNameWithModule; },
2686
+ /* harmony export */ getSelfInfo: function() { return /* binding */ getSelfInfo; },
2687
+ /* harmony export */ isModuleLoaded: function() { return /* binding */ isModuleLoaded; },
2688
+ /* harmony export */ isModuleSpecified: function() { return /* binding */ isModuleSpecified; },
2689
+ /* harmony export */ isPromiseLike: function() { return /* binding */ isPromiseLike; },
2690
+ /* harmony export */ onComponentMounted: function() { return /* binding */ onComponentMounted; },
2691
+ /* harmony export */ onError: function() { return /* binding */ onError; },
2692
+ /* harmony export */ parseComponentActions: function() { return /* binding */ parseComponentActions; },
2693
+ /* harmony export */ preloadModules: function() { return /* binding */ preloadModules; },
2694
+ /* harmony export */ removeLoadedModules: function() { return /* binding */ removeLoadedModules; },
2695
+ /* harmony export */ resetDependencyConfig: function() { return /* binding */ resetDependencyConfig; },
2696
+ /* harmony export */ updateMountedComponent: function() { return /* binding */ updateMountedComponent; },
2697
+ /* harmony export */ updateUnMountComponent: function() { return /* binding */ updateUnMountComponent; }
2698
+ /* harmony export */ });
2699
+ /* harmony import */ var _store__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./store */ "./src/core/store.ts");
2700
+ /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./logger */ "./src/core/logger.ts");
2701
+ /* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./config */ "./src/core/config.ts");
2702
+ /* harmony import */ var _connector__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./connector */ "./src/core/connector.ts");
2703
+ /* harmony import */ var _message__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./message */ "./src/core/message.ts");
2704
+ /* harmony import */ var _i18n__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./i18n */ "./src/core/i18n.ts");
2705
+
2706
+
2707
+
2708
+
2709
+
2710
+
2711
+ const getUrlHash = url => `${url}?${+new Date()}`;
2712
+ const hasModule = (modules, module) => modules.some(c => c.name === module.name && c.module === module.module);
2713
+ const preloadModules = names => new Promise((resolve, reject) => {
2714
+ window.requirejs(names, resolve, reject);
2715
+ });
2716
+ const removeLoadedModules = names => {
2717
+ names.forEach(name => {
2718
+ if (!_config__WEBPACK_IMPORTED_MODULE_2__.BASE_DEPENDENCIES.includes(name)) {
2719
+ window.requirejs.undef(name);
2720
+ }
2721
+ });
2722
+ };
2723
+ const defineDependencies = deps => {
2724
+ const dependencies = (0,_store__WEBPACK_IMPORTED_MODULE_0__.getStore)(_config__WEBPACK_IMPORTED_MODULE_2__.DEPENDENCIES_KEY);
2725
+ const next = {};
2726
+ Object.keys(deps).forEach(name => {
2727
+ if (!_config__WEBPACK_IMPORTED_MODULE_2__.BASE_DEPENDENCIES.includes(name)) {
2728
+ next[name] = `${deps[name]}#${name}`;
2729
+ window.requirejs.undef(name);
2730
+ }
2731
+ });
2732
+ window.requirejs.config({
2733
+ paths: next
2734
+ });
2735
+ (0,_store__WEBPACK_IMPORTED_MODULE_0__.emit)({
2736
+ [_config__WEBPACK_IMPORTED_MODULE_2__.DEPENDENCIES_KEY]: {
2737
+ ...dependencies,
2738
+ ...next
2739
+ }
2740
+ }, true);
2741
+ };
2742
+ const isModuleLoaded = name => window.requirejs.defined(name);
2743
+ const isModuleSpecified = name => window.requirejs.specified(name);
2744
+ const getMountedComponents = () => (0,_store__WEBPACK_IMPORTED_MODULE_0__.getStore)(_config__WEBPACK_IMPORTED_MODULE_2__.MOUNTED_COMPONENTS_KEY);
2745
+ const onComponentMounted = (module, callback) => {
2746
+ const modules = Array.isArray(module) ? module : [module];
2747
+ if (modules.every(m => hasModule(getMountedComponents(), m))) {
2748
+ callback();
2749
+ }
2750
+ const unSubscribe = (0,_store__WEBPACK_IMPORTED_MODULE_0__.subscribe)({
2751
+ [_config__WEBPACK_IMPORTED_MODULE_2__.MOUNTED_COMPONENTS_KEY](value) {
2752
+ const mountedModules = value;
2753
+ if (modules.every(n => hasModule(mountedModules, n))) {
2754
+ unSubscribe();
2755
+ callback();
2756
+ }
2757
+ }
2758
+ });
2759
+ return unSubscribe;
2760
+ };
2761
+ const resetDependencyConfig = (name, url) => {
2762
+ const dependencies = (0,_store__WEBPACK_IMPORTED_MODULE_0__.getStore)(_config__WEBPACK_IMPORTED_MODULE_2__.DEPENDENCIES_KEY);
2763
+
2764
+ // ignore multiple custom module url
2765
+ if (url && window.requirejs.defined(name)) {
2766
+ return;
2767
+ }
2768
+ let path = getUrlHash(dependencies[name]);
2769
+
2770
+ // custom module url, but module loaded error
2771
+ if (url) {
2772
+ path = `${url}#${name}`;
2773
+ try {
2774
+ const {
2775
+ registry
2776
+ } = window.requirejs.s.contexts._;
2777
+ if (registry?.[name].error) {
2778
+ path = getUrlHash(url);
2779
+ }
2780
+ } catch (e) {
2781
+ // ignore
2782
+ }
2783
+ }
2784
+ window.requirejs.undef(name);
2785
+ window.requirejs.config({
2786
+ paths: {
2787
+ [name]: path
2788
+ }
2789
+ });
2790
+ };
2791
+ const getNameWithModule = moduleDefined => {
2792
+ const {
2793
+ name,
2794
+ module
2795
+ } = moduleDefined;
2796
+ return module ? `${name}.${module}` : name;
2797
+ };
2798
+ function getConfig() {
2799
+ return (0,_store__WEBPACK_IMPORTED_MODULE_0__.getStore)(_config__WEBPACK_IMPORTED_MODULE_2__.CONFIG_KEY);
2800
+ }
2801
+ const onError = e => {
2802
+ const {
2803
+ name,
2804
+ module,
2805
+ type
2806
+ } = e;
2807
+ const logger = (0,_logger__WEBPACK_IMPORTED_MODULE_1__["default"])({
2808
+ name,
2809
+ module
2810
+ });
2811
+ logger.error(e, type);
2812
+ };
2813
+ class VariousError extends Error {
2814
+ constructor(data) {
2815
+ super(data.originalError.message);
2816
+ this.type = data.type;
2817
+ this.originalError = data.originalError;
2818
+ this.module = data.module;
2819
+ this.name = data.name;
2820
+ }
2821
+ }
2822
+ function checkReactComponent(component, moduleDefined) {
2823
+ return new Promise((reslove, reject) => {
2824
+ if (component.$$typeof || component.prototype?.isReactComponent || typeof component === 'function') {
2825
+ reslove();
2826
+ return;
2827
+ }
2828
+ reject(new VariousError({
2829
+ ...moduleDefined,
2830
+ originalError: new Error('not a valid React component'),
2831
+ type: 'INVALID_COMPONENT'
2832
+ }));
2833
+ });
2834
+ }
2835
+ function isPromiseLike(value) {
2836
+ return value != null && typeof value.then === 'function';
2837
+ }
2838
+ function checkVueComponent(component, moduleDefined) {
2839
+ const versionRegex = new RegExp(`^${_config__WEBPACK_IMPORTED_MODULE_2__.VUE_VERSION}\\.`);
2840
+ return new Promise((resolve, reject) => {
2841
+ window.requirejs(['vue'], Vue => {
2842
+ if (!versionRegex.test(Vue.version)) {
2843
+ reject(new Error(`Vue ${_config__WEBPACK_IMPORTED_MODULE_2__.VUE_VERSION}+ required, detected an incompatible version`));
2844
+ }
2845
+ if (typeof component?.render === 'function' || typeof component?.setup === 'function') {
2846
+ resolve();
2847
+ return;
2848
+ }
2849
+ reject(new VariousError({
2850
+ ...moduleDefined,
2851
+ originalError: new Error('not a valid Vue component'),
2852
+ type: 'INVALID_COMPONENT'
2853
+ }));
2854
+ });
2855
+ });
2856
+ }
2857
+ function parseComponentActions(params) {
2858
+ const {
2859
+ componentNode,
2860
+ name,
2861
+ module,
2862
+ type,
2863
+ i18nUpdate
2864
+ } = params;
2865
+ const actions = {};
2866
+ let onMessageAction;
2867
+ let i18nAction;
2868
+ Object.getOwnPropertyNames(componentNode).forEach(method => {
2869
+ if (typeof componentNode[method] !== 'function') {
2870
+ return;
2871
+ }
2872
+ if (method === '$onMessage') {
2873
+ onMessageAction = componentNode[method];
2874
+ return;
2875
+ }
2876
+ if (method === '$i18n') {
2877
+ i18nAction = componentNode[method];
2878
+ return;
2879
+ }
2880
+ if (type === 'vue3' && _config__WEBPACK_IMPORTED_MODULE_2__.VUE_FUNCTION_OPTIONS.includes(method)) {
2881
+ return;
2882
+ }
2883
+ actions[method] = componentNode[method];
2884
+ });
2885
+ if (i18nAction) {
2886
+ (0,_i18n__WEBPACK_IMPORTED_MODULE_5__.createI18nConfig)(i18nAction, {
2887
+ name,
2888
+ module
2889
+ }, i18nUpdate);
2890
+ }
2891
+ _connector__WEBPACK_IMPORTED_MODULE_3__["default"].setComponentActions({
2892
+ name,
2893
+ module
2894
+ }, actions);
2895
+ if (onMessageAction) {
2896
+ return (0,_message__WEBPACK_IMPORTED_MODULE_4__.createOnMessage)({
2897
+ name,
2898
+ module
2899
+ }, onMessageAction);
2900
+ }
2901
+ return () => null;
2902
+ }
2903
+ function updateMountedComponent(moduleDefined) {
2904
+ const mountedComponents = getMountedComponents();
2905
+ if (!hasModule(mountedComponents, moduleDefined)) {
2906
+ mountedComponents.push(moduleDefined);
2907
+ }
2908
+ (0,_store__WEBPACK_IMPORTED_MODULE_0__.emit)({
2909
+ [_config__WEBPACK_IMPORTED_MODULE_2__.MOUNTED_COMPONENTS_KEY]: mountedComponents
2910
+ }, true);
2911
+ }
2912
+ function updateUnMountComponent(moduleDefined) {
2913
+ const {
2914
+ name,
2915
+ module
2916
+ } = moduleDefined;
2917
+ let mountedComponents = getMountedComponents();
2918
+ mountedComponents = mountedComponents.filter(item => item.name !== name || item.module !== module);
2919
+ (0,_store__WEBPACK_IMPORTED_MODULE_0__.emit)({
2920
+ [_config__WEBPACK_IMPORTED_MODULE_2__.MOUNTED_COMPONENTS_KEY]: mountedComponents
2921
+ }, true);
2922
+ _connector__WEBPACK_IMPORTED_MODULE_3__["default"].deleteComponentActions({
2923
+ name,
2924
+ module
2925
+ });
2926
+ }
2927
+ function getSelfInfo(params) {
2928
+ const {
2929
+ name,
2930
+ module,
2931
+ url
2932
+ } = params;
2933
+ const dependencies = (0,_store__WEBPACK_IMPORTED_MODULE_0__.getStore)(_config__WEBPACK_IMPORTED_MODULE_2__.DEPENDENCIES_KEY);
2934
+ return {
2935
+ name,
2936
+ module,
2937
+ url: url || dependencies[name]
2938
+ };
2939
+ }
2940
+ function getClassNameWithModule(self, prefix) {
2941
+ const {
2942
+ name,
2943
+ module
2944
+ } = self;
2945
+ return `${prefix} ${[name, module].filter(Boolean).join('-')}`;
2946
+ }
2947
+
2948
+ /***/ }),
2949
+
2950
+ /***/ "./src/core/i18n.ts":
2951
+ /*!**************************!*\
2952
+ !*** ./src/core/i18n.ts ***!
2953
+ \**************************/
2954
+ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
2955
+
2956
+ "use strict";
2957
+ __webpack_require__.r(__webpack_exports__);
2958
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2959
+ /* harmony export */ createI18n: function() { return /* binding */ createI18n; },
2960
+ /* harmony export */ createI18nConfig: function() { return /* binding */ createI18nConfig; }
2961
+ /* harmony export */ });
2962
+ /* harmony import */ var _connector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./connector */ "./src/core/connector.ts");
2963
+ /* harmony import */ var _helper__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./helper */ "./src/core/helper.ts");
2964
+ /* harmony import */ var _store__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./store */ "./src/core/store.ts");
2965
+
2966
+
2967
+
2968
+ function createI18nConfig(method, moduleDefined, callback) {
2969
+ if (!method) {
2970
+ return;
2971
+ }
2972
+ const i18nConfig = method();
2973
+ if (!(0,_helper__WEBPACK_IMPORTED_MODULE_1__.isPromiseLike)(i18nConfig)) {
2974
+ if (moduleDefined) {
2975
+ _connector__WEBPACK_IMPORTED_MODULE_0__["default"].setI18nConfig(moduleDefined, i18nConfig);
2976
+ } else {
2977
+ _connector__WEBPACK_IMPORTED_MODULE_0__["default"].setGlobalI18nConfig(i18nConfig);
2978
+ }
2979
+ return;
2980
+ }
2981
+ if (moduleDefined) {
2982
+ _connector__WEBPACK_IMPORTED_MODULE_0__["default"].setI18nConfig(moduleDefined, {
2983
+ loading: true,
2984
+ lngStoreKey: '',
2985
+ resources: {}
2986
+ });
2987
+ } else {
2988
+ _connector__WEBPACK_IMPORTED_MODULE_0__["default"].setGlobalI18nConfig({
2989
+ loading: true,
2990
+ lngStoreKey: '',
2991
+ resources: {}
2992
+ });
2993
+ }
2994
+ i18nConfig.then(res => {
2995
+ if (moduleDefined) {
2996
+ _connector__WEBPACK_IMPORTED_MODULE_0__["default"].setI18nConfig(moduleDefined, {
2997
+ ...res,
2998
+ loading: false
2999
+ });
3000
+ callback?.();
3001
+ return;
3002
+ }
3003
+ const locale = (0,_store__WEBPACK_IMPORTED_MODULE_2__.getStore)(res.lngStoreKey);
3004
+ (0,_store__WEBPACK_IMPORTED_MODULE_2__.emit)({
3005
+ [res.lngStoreKey]: undefined
3006
+ }, true);
3007
+ (0,_store__WEBPACK_IMPORTED_MODULE_2__.emit)({
3008
+ [res.lngStoreKey]: locale
3009
+ }, true);
3010
+ _connector__WEBPACK_IMPORTED_MODULE_0__["default"].setGlobalI18nConfig({
3011
+ ...res,
3012
+ loading: false
3013
+ });
3014
+ }).catch(e => {
3015
+ (0,_helper__WEBPACK_IMPORTED_MODULE_1__.onError)(new _helper__WEBPACK_IMPORTED_MODULE_1__.VariousError({
3016
+ name: moduleDefined?.name || 'app',
3017
+ module: moduleDefined?.module,
3018
+ type: 'I18N',
3019
+ originalError: e
3020
+ }));
3021
+ });
3022
+ }
3023
+ function createI18n(moduleDefined, updater) {
3024
+ const ctx = (key, params, defaultString) => {
3025
+ const i18nConfig = _connector__WEBPACK_IMPORTED_MODULE_0__["default"].getI18nConfig(moduleDefined) || _connector__WEBPACK_IMPORTED_MODULE_0__["default"].getGlobalI18nConfig();
3026
+ let defaultText = defaultString;
3027
+ if (defaultText === undefined) {
3028
+ defaultText = typeof params === 'string' ? params : key;
3029
+ }
3030
+ if (!i18nConfig) {
3031
+ (0,_helper__WEBPACK_IMPORTED_MODULE_1__.onError)(new _helper__WEBPACK_IMPORTED_MODULE_1__.VariousError({
3032
+ ...moduleDefined,
3033
+ type: 'I18N',
3034
+ originalError: new Error('config not exist')
3035
+ }));
3036
+ return defaultText;
3037
+ }
3038
+ if (i18nConfig.loading) {
3039
+ return defaultText;
3040
+ }
3041
+ const {
3042
+ lngStoreKey,
3043
+ resources
3044
+ } = i18nConfig;
3045
+ const locale = (0,_store__WEBPACK_IMPORTED_MODULE_2__.getStore)(lngStoreKey);
3046
+ if (lngStoreKey === undefined || locale === undefined) {
3047
+ (0,_helper__WEBPACK_IMPORTED_MODULE_1__.onError)(new _helper__WEBPACK_IMPORTED_MODULE_1__.VariousError({
3048
+ ...moduleDefined,
3049
+ type: 'I18N',
3050
+ originalError: new Error('locale key not defined')
3051
+ }));
3052
+ return defaultText;
3053
+ }
3054
+ const resource = resources?.[locale];
3055
+ if (!resource) {
3056
+ (0,_helper__WEBPACK_IMPORTED_MODULE_1__.onError)(new _helper__WEBPACK_IMPORTED_MODULE_1__.VariousError({
3057
+ ...moduleDefined,
3058
+ type: 'I18N',
3059
+ originalError: new Error(`locale resource \`${locale}\` not exist`)
3060
+ }));
3061
+ return defaultText;
3062
+ }
3063
+ if (!resource[key]) {
3064
+ (0,_helper__WEBPACK_IMPORTED_MODULE_1__.onError)(new _helper__WEBPACK_IMPORTED_MODULE_1__.VariousError({
3065
+ ...moduleDefined,
3066
+ type: 'I18N',
3067
+ originalError: new Error(`locale key \`${key}\` not exist`)
3068
+ }));
3069
+ return defaultText;
3070
+ }
3071
+ const text = resource[key];
3072
+ if (!params || typeof params === 'string' || Object.prototype.toString.call(params) !== '[object Object]') {
3073
+ return text;
3074
+ }
3075
+ const args = Object.keys(params);
3076
+ if (!args.length) {
3077
+ return text;
3078
+ }
3079
+ return args.reduce((next, arg) => {
3080
+ const regex = new RegExp(`{\\s*${arg}\\s*}`, 'g');
3081
+ return next.replace(regex, params[arg].toString());
3082
+ }, text);
3083
+ };
3084
+ ctx.update = (config, type) => {
3085
+ const i18nConfig = type === 'app' ? _connector__WEBPACK_IMPORTED_MODULE_0__["default"].getGlobalI18nConfig() : _connector__WEBPACK_IMPORTED_MODULE_0__["default"].getI18nConfig(moduleDefined);
3086
+ const next = {
3087
+ ...i18nConfig,
3088
+ ...config
3089
+ };
3090
+ if (type === 'app') {
3091
+ _connector__WEBPACK_IMPORTED_MODULE_0__["default"].setGlobalI18nConfig(next);
3092
+ } else {
3093
+ _connector__WEBPACK_IMPORTED_MODULE_0__["default"].setI18nConfig(moduleDefined, next);
3094
+ }
3095
+ updater();
3096
+ };
3097
+ return ctx;
3098
+ }
3099
+
3100
+ /***/ }),
3101
+
3102
+ /***/ "./src/core/logger.ts":
3103
+ /*!****************************!*\
3104
+ !*** ./src/core/logger.ts ***!
3105
+ \****************************/
3106
+ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
3107
+
3108
+ "use strict";
3109
+ __webpack_require__.r(__webpack_exports__);
3110
+ /* harmony import */ var _connector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./connector */ "./src/core/connector.ts");
3111
+ /* harmony import */ var _helper__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./helper */ "./src/core/helper.ts");
3112
+
3113
+
3114
+ const logger = args => {
3115
+ const middlewares = _connector__WEBPACK_IMPORTED_MODULE_0__["default"].getMiddlewares();
3116
+ const canLog = middlewares?.onLog?.(args);
3117
+ if (canLog === false) {
3118
+ return;
3119
+ }
3120
+ const colorMap = {
3121
+ info: 'blue',
3122
+ warn: 'orange',
3123
+ error: 'red'
3124
+ };
3125
+ const color = colorMap[args.level];
3126
+ const params = [`%c ${(0,_helper__WEBPACK_IMPORTED_MODULE_1__.getNameWithModule)(args)} `, `background:${color};border:1px solid ${color};padding:1px;border-radius:2px 0 0 2px;color: #fff;`];
3127
+ if (args.type) {
3128
+ params[0] = `${params[0]}%c ${args.type} %c`;
3129
+ params.push(`border:1px solid ${color};padding:1px;border-radius:0 2px 2px 0;color:${color};`, 'background:transparent');
3130
+ }
3131
+ if (args.level !== 'info') {
3132
+ params[0] = ` ${params[0]}`;
3133
+ }
3134
+ window.console[args.level](...params, args.message);
3135
+ };
3136
+ const createLogger = moduleDefined => ({
3137
+ info(message, type) {
3138
+ logger({
3139
+ ...moduleDefined,
3140
+ level: 'info',
3141
+ type,
3142
+ message
3143
+ });
3144
+ },
3145
+ warn(message, type) {
3146
+ logger({
3147
+ ...moduleDefined,
3148
+ level: 'warn',
3149
+ type,
3150
+ message
3151
+ });
3152
+ },
3153
+ error(message, type) {
3154
+ const middlewares = _connector__WEBPACK_IMPORTED_MODULE_0__["default"].getMiddlewares();
3155
+ const error = message instanceof _helper__WEBPACK_IMPORTED_MODULE_1__.VariousError ? message : new _helper__WEBPACK_IMPORTED_MODULE_1__.VariousError({
3156
+ ...moduleDefined,
3157
+ type: type || 'unknow',
3158
+ originalError: message instanceof Error ? message : new Error(message)
3159
+ });
3160
+ middlewares?.onError?.(error);
3161
+ logger({
3162
+ ...moduleDefined,
3163
+ level: 'error',
3164
+ type,
3165
+ message
3166
+ });
3167
+ }
3168
+ });
3169
+ /* harmony default export */ __webpack_exports__["default"] = (createLogger);
3170
+
3171
+ /***/ }),
3172
+
3173
+ /***/ "./src/core/message.ts":
3174
+ /*!*****************************!*\
3175
+ !*** ./src/core/message.ts ***!
3176
+ \*****************************/
3177
+ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
3178
+
3179
+ "use strict";
3180
+ __webpack_require__.r(__webpack_exports__);
3181
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3182
+ /* harmony export */ createOnMessage: function() { return /* binding */ createOnMessage; },
3183
+ /* harmony export */ createPostMessage: function() { return /* binding */ createPostMessage; }
3184
+ /* harmony export */ });
3185
+ /* harmony import */ var _connector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./connector */ "./src/core/connector.ts");
3186
+ /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./logger */ "./src/core/logger.ts");
3187
+ /* harmony import */ var _store__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./store */ "./src/core/store.ts");
3188
+ /* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./config */ "./src/core/config.ts");
3189
+
3190
+
3191
+
3192
+
3193
+ const createPostMessage = moduleDefined => async (event, value) => {
3194
+ const middlewares = _connector__WEBPACK_IMPORTED_MODULE_0__["default"].getMiddlewares();
3195
+ const logger = (0,_logger__WEBPACK_IMPORTED_MODULE_1__["default"])(moduleDefined);
3196
+ let next = {
3197
+ trigger: moduleDefined,
3198
+ event,
3199
+ value
3200
+ };
3201
+ if (middlewares?.onMessage) {
3202
+ const check = await middlewares.onMessage(next);
3203
+ if (check === false) {
3204
+ logger.warn('blocked by middleware', 'POST_MESSAGE');
3205
+ return;
3206
+ }
3207
+ if (check !== true) {
3208
+ next = {
3209
+ ...next,
3210
+ ...check
3211
+ };
3212
+ }
3213
+ }
3214
+ (0,_store__WEBPACK_IMPORTED_MODULE_2__.emit)({
3215
+ [_config__WEBPACK_IMPORTED_MODULE_3__.MESSAGE_KEY]: {
3216
+ timestamp: +new Date(),
3217
+ event: next.event,
3218
+ trigger: moduleDefined,
3219
+ value: next.value
3220
+ }
3221
+ });
3222
+ };
3223
+ const createOnMessage = (moduleDefined, onMessage) => (0,_store__WEBPACK_IMPORTED_MODULE_2__.subscribe)({
3224
+ [_config__WEBPACK_IMPORTED_MODULE_3__.MESSAGE_KEY](v) {
3225
+ const {
3226
+ trigger,
3227
+ value,
3228
+ event
3229
+ } = v;
3230
+ if (moduleDefined.name !== trigger.name || moduleDefined.module !== trigger.module) {
3231
+ onMessage({
3232
+ event,
3233
+ value,
3234
+ trigger
3235
+ });
3236
+ }
3237
+ }
3238
+ });
3239
+
3240
+ /***/ }),
3241
+
3242
+ /***/ "./src/core/react-component.tsx":
3243
+ /*!**************************************!*\
3244
+ !*** ./src/core/react-component.tsx ***!
3245
+ \**************************************/
3246
+ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
3247
+
3248
+ "use strict";
3249
+ __webpack_require__.r(__webpack_exports__);
3250
+ /* harmony import */ var _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/extends */ "./node_modules/@babel/runtime/helpers/esm/extends.js");
3251
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ "react");
3252
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
3253
+ /* harmony import */ var _helper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./helper */ "./src/core/helper.ts");
3254
+ /* harmony import */ var _store__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./store */ "./src/core/store.ts");
3255
+ /* harmony import */ var _connector__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./connector */ "./src/core/connector.ts");
3256
+ /* harmony import */ var _message__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./message */ "./src/core/message.ts");
3257
+ /* harmony import */ var _dispatch__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./dispatch */ "./src/core/dispatch.ts");
3258
+ /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./logger */ "./src/core/logger.ts");
3259
+ /* harmony import */ var _i18n__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./i18n */ "./src/core/i18n.ts");
3260
+ /* harmony import */ var _create_module__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./create-module */ "./src/core/create-module.ts");
3261
+
3262
+
3263
+
3264
+
3265
+
3266
+
3267
+
3268
+
3269
+
3270
+
3271
+ function reactComponent(config) {
3272
+ const {
3273
+ name,
3274
+ module,
3275
+ url,
3276
+ watchKeys,
3277
+ onMounted
3278
+ } = config;
3279
+ const storeKeys = watchKeys || Object.keys((0,_store__WEBPACK_IMPORTED_MODULE_3__.getStore)());
3280
+ class R extends react__WEBPACK_IMPORTED_MODULE_1__.Component {
3281
+ static displayName = 'various-react-component';
3282
+ state = {
3283
+ componentReady: false,
3284
+ isError: false
3285
+ };
3286
+ unSubscribeMessage = () => null;
3287
+ componentDidMount() {
3288
+ this.isUnMounted = false; // fix StrictMode
3289
+ this.mountComponent();
3290
+ }
3291
+ componentWillUnmount() {
3292
+ this.error = undefined;
3293
+ this.ComponentNode = null;
3294
+ this.isUnMounted = true;
3295
+ this.unSubscribeMessage();
3296
+ (0,_helper__WEBPACK_IMPORTED_MODULE_2__.updateUnMountComponent)({
3297
+ name,
3298
+ module
3299
+ });
3300
+ }
3301
+ mountComponent = async () => {
3302
+ try {
3303
+ const componentNode = await (0,_create_module__WEBPACK_IMPORTED_MODULE_9__["default"])({
3304
+ name,
3305
+ module,
3306
+ url
3307
+ }, false);
3308
+ if (this.isUnMounted) {
3309
+ return;
3310
+ }
3311
+ await (0,_helper__WEBPACK_IMPORTED_MODULE_2__.checkReactComponent)(componentNode, {
3312
+ name,
3313
+ module
3314
+ });
3315
+ componentNode.displayName = (0,_helper__WEBPACK_IMPORTED_MODULE_2__.getNameWithModule)({
3316
+ name,
3317
+ module
3318
+ });
3319
+ (0,_helper__WEBPACK_IMPORTED_MODULE_2__.updateMountedComponent)({
3320
+ name,
3321
+ module
3322
+ });
3323
+ this.unSubscribeMessage = (0,_helper__WEBPACK_IMPORTED_MODULE_2__.parseComponentActions)({
3324
+ componentNode,
3325
+ name,
3326
+ module,
3327
+ i18nUpdate: () => this.forceUpdate()
3328
+ });
3329
+ this.ComponentNode = componentNode;
3330
+ this.setState({
3331
+ componentReady: true
3332
+ });
3333
+ onMounted?.();
3334
+ } catch (e) {
3335
+ if (this.isUnMounted) {
3336
+ return;
3337
+ }
3338
+ this.error = e;
3339
+ this.setState({
3340
+ componentReady: true,
3341
+ isError: true
3342
+ });
3343
+ }
3344
+ };
3345
+ $postMessage = (0,_message__WEBPACK_IMPORTED_MODULE_5__.createPostMessage)({
3346
+ name,
3347
+ module
3348
+ });
3349
+ $dispatch = (0,_dispatch__WEBPACK_IMPORTED_MODULE_6__["default"])({
3350
+ name,
3351
+ module
3352
+ });
3353
+ $t = (0,_i18n__WEBPACK_IMPORTED_MODULE_8__.createI18n)({
3354
+ name,
3355
+ module
3356
+ }, () => this.forceUpdate());
3357
+ $logger = (0,_logger__WEBPACK_IMPORTED_MODULE_7__["default"])({
3358
+ name,
3359
+ module
3360
+ });
3361
+ $self = (0,_helper__WEBPACK_IMPORTED_MODULE_2__.getSelfInfo)({
3362
+ name,
3363
+ module,
3364
+ url
3365
+ });
3366
+ render() {
3367
+ const Fallback = _connector__WEBPACK_IMPORTED_MODULE_4__["default"].getFallbackComponent();
3368
+ const {
3369
+ $silent,
3370
+ $componentProps,
3371
+ $ref
3372
+ } = this.props;
3373
+ const {
3374
+ componentReady,
3375
+ isError
3376
+ } = this.state;
3377
+ const store = (0,_store__WEBPACK_IMPORTED_MODULE_3__.getUserStore)();
3378
+ const ComponentNode = this.ComponentNode;
3379
+ if (isError) {
3380
+ throw this.error;
3381
+ }
3382
+ if (!componentReady) {
3383
+ if ($silent || (0,_helper__WEBPACK_IMPORTED_MODULE_2__.isModuleLoaded)(name)) {
3384
+ return null;
3385
+ }
3386
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(Fallback, {
3387
+ $self: this.$self,
3388
+ $store: store
3389
+ });
3390
+ }
3391
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(ComponentNode, (0,_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__["default"])({}, $componentProps, {
3392
+ $self: this.$self,
3393
+ $dispatch: this.$dispatch,
3394
+ $store: store,
3395
+ $postMessage: this.$postMessage,
3396
+ $t: this.$t,
3397
+ $logger: this.$logger,
3398
+ ref: $ref
3399
+ }));
3400
+ }
3401
+ }
3402
+ const Connected = (0,_store__WEBPACK_IMPORTED_MODULE_3__.connect)(...storeKeys)(R);
3403
+ Connected.displayName = 'various-connector';
3404
+ return Connected;
3405
+ }
3406
+ /* harmony default export */ __webpack_exports__["default"] = (reactComponent);
3407
+
3408
+ /***/ }),
3409
+
3410
+ /***/ "./src/core/store.ts":
3411
+ /*!***************************!*\
3412
+ !*** ./src/core/store.ts ***!
3413
+ \***************************/
3414
+ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
3415
+
3416
+ "use strict";
3417
+ __webpack_require__.r(__webpack_exports__);
3418
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3419
+ /* harmony export */ connect: function() { return /* binding */ connect; },
3420
+ /* harmony export */ createStore: function() { return /* binding */ createStore; },
3421
+ /* harmony export */ dispatch: function() { return /* binding */ dispatch; },
3422
+ /* harmony export */ emit: function() { return /* binding */ emit; },
3423
+ /* harmony export */ getStore: function() { return /* binding */ getStore; },
3424
+ /* harmony export */ getUserStore: function() { return /* binding */ getUserStore; },
3425
+ /* harmony export */ subscribe: function() { return /* binding */ subscribe; },
3426
+ /* harmony export */ useStore: function() { return /* binding */ useStore; }
3427
+ /* harmony export */ });
3428
+ /* harmony import */ var nycticorax__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! nycticorax */ "./node_modules/nycticorax/dist/index.js");
3429
+ /* harmony import */ var nycticorax__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(nycticorax__WEBPACK_IMPORTED_MODULE_0__);
3430
+
3431
+ const {
3432
+ createStore,
3433
+ getStore,
3434
+ connect,
3435
+ emit,
3436
+ subscribe,
3437
+ dispatch,
3438
+ useStore
3439
+ } = new (nycticorax__WEBPACK_IMPORTED_MODULE_0___default())();
3440
+ function getUserStore() {
3441
+ const globalStore = getStore();
3442
+ const keys = Object.keys(globalStore);
3443
+ const store = {};
3444
+ keys.forEach(key => {
3445
+ store[key] = globalStore[key];
3446
+ });
3447
+ return store;
3448
+ }
3449
+
3450
+ /***/ }),
3451
+
3452
+ /***/ "./src/core/vue-component.tsx":
3453
+ /*!************************************!*\
3454
+ !*** ./src/core/vue-component.tsx ***!
3455
+ \************************************/
3456
+ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
3457
+
3458
+ "use strict";
3459
+ __webpack_require__.r(__webpack_exports__);
3460
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
3461
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
3462
+ /* harmony import */ var _connector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./connector */ "./src/core/connector.ts");
3463
+ /* harmony import */ var _create_module__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./create-module */ "./src/core/create-module.ts");
3464
+ /* harmony import */ var _store__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./store */ "./src/core/store.ts");
3465
+ /* harmony import */ var _helper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./helper */ "./src/core/helper.ts");
3466
+ /* harmony import */ var _dispatch__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./dispatch */ "./src/core/dispatch.ts");
3467
+ /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./logger */ "./src/core/logger.ts");
3468
+ /* harmony import */ var _message__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./message */ "./src/core/message.ts");
3469
+ /* harmony import */ var _i18n__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./i18n */ "./src/core/i18n.ts");
3470
+
3471
+
3472
+
3473
+
3474
+
3475
+
3476
+
3477
+
3478
+
3479
+ function vueComponent(config) {
3480
+ const {
3481
+ name,
3482
+ module,
3483
+ url,
3484
+ watchKeys,
3485
+ onMounted
3486
+ } = config;
3487
+ const storeKeys = watchKeys || Object.keys((0,_store__WEBPACK_IMPORTED_MODULE_3__.getStore)());
3488
+ const V = props => {
3489
+ const store = (0,_store__WEBPACK_IMPORTED_MODULE_3__.useStore)(...storeKeys);
3490
+ const vueRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)();
3491
+ const vmRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)();
3492
+ const isVueMounted = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(false);
3493
+ const errorRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)();
3494
+ const isUnMountedRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(false);
3495
+ const ComponentNodeRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)();
3496
+ const selfRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)((0,_helper__WEBPACK_IMPORTED_MODULE_4__.getSelfInfo)({
3497
+ name,
3498
+ module,
3499
+ url
3500
+ }));
3501
+ const containerDivRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null);
3502
+ const propsReactiveRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)();
3503
+ const storeReactiveRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)();
3504
+ const unMountVue = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)();
3505
+ const unSubscribeMessageRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)();
3506
+ const updateVueComponentRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)();
3507
+ const [componentReady, setComponentReady] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false);
3508
+ const [isError, setIsError] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false);
3509
+ const Fallback = _connector__WEBPACK_IMPORTED_MODULE_1__["default"].getFallbackComponent();
3510
+ const {
3511
+ $silent,
3512
+ $componentProps
3513
+ } = props;
3514
+ const mountVue = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(() => {
3515
+ const $logger = (0,_logger__WEBPACK_IMPORTED_MODULE_6__["default"])({
3516
+ name,
3517
+ module
3518
+ });
3519
+ const $dispatch = (0,_dispatch__WEBPACK_IMPORTED_MODULE_5__["default"])({
3520
+ name,
3521
+ module
3522
+ });
3523
+ const $postMessage = (0,_message__WEBPACK_IMPORTED_MODULE_7__.createPostMessage)({
3524
+ name,
3525
+ module
3526
+ });
3527
+ const $t = (0,_i18n__WEBPACK_IMPORTED_MODULE_8__.createI18n)({
3528
+ name,
3529
+ module
3530
+ }, () => {
3531
+ updateVueComponentRef.current?.();
3532
+ });
3533
+ propsReactiveRef.current = vueRef.current.ref({
3534
+ ...$componentProps
3535
+ });
3536
+ storeReactiveRef.current = vueRef.current.ref({
3537
+ ...store
3538
+ });
3539
+ const vueApp = vueRef.current.createApp({
3540
+ setup() {
3541
+ const renderKey = vueRef.current.ref(0);
3542
+ updateVueComponentRef.current = () => {
3543
+ renderKey.value += 1;
3544
+ };
3545
+ return {
3546
+ key: renderKey
3547
+ };
3548
+ },
3549
+ errorCaptured(e) {
3550
+ const error = e;
3551
+ errorRef.current = error.message?.includes('https://react') ? new _helper__WEBPACK_IMPORTED_MODULE_4__.VariousError({
3552
+ originalError: new Error('not a valid Vue component'),
3553
+ name,
3554
+ module,
3555
+ type: 'INVALID_COMPONENT'
3556
+ }) : error;
3557
+ setIsError(true);
3558
+ },
3559
+ render() {
3560
+ return vueRef.current.h(ComponentNodeRef.current, {
3561
+ ...propsReactiveRef.current.value,
3562
+ various: {
3563
+ $dispatch,
3564
+ $logger,
3565
+ $postMessage,
3566
+ $t,
3567
+ $store: storeReactiveRef.current.value,
3568
+ $self: selfRef.current
3569
+ },
3570
+ // eslint-disable-next-line react/no-this-in-sfc
3571
+ key: this.key
3572
+ });
3573
+ }
3574
+ });
3575
+
3576
+ // fix StrictMode
3577
+ if (!vmRef.current) {
3578
+ vmRef.current = vueApp.mount(containerDivRef.current);
3579
+ }
3580
+ isVueMounted.current = true;
3581
+ unMountVue.current = () => vueApp.unmount();
3582
+ }, [$componentProps, store]);
3583
+ const mountComponent = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(async () => {
3584
+ try {
3585
+ const vue = await (0,_create_module__WEBPACK_IMPORTED_MODULE_2__["default"])({
3586
+ name: 'vue'
3587
+ });
3588
+ vueRef.current = vue;
3589
+ const componentNode = await (0,_create_module__WEBPACK_IMPORTED_MODULE_2__["default"])({
3590
+ name,
3591
+ module,
3592
+ url
3593
+ }, false);
3594
+ if (isUnMountedRef.current) {
3595
+ return;
3596
+ }
3597
+ await (0,_helper__WEBPACK_IMPORTED_MODULE_4__.checkVueComponent)(componentNode, {
3598
+ name,
3599
+ module
3600
+ });
3601
+ (0,_helper__WEBPACK_IMPORTED_MODULE_4__.updateMountedComponent)({
3602
+ name,
3603
+ module
3604
+ });
3605
+ unSubscribeMessageRef.current = (0,_helper__WEBPACK_IMPORTED_MODULE_4__.parseComponentActions)({
3606
+ componentNode,
3607
+ name,
3608
+ module,
3609
+ type: 'vue3',
3610
+ i18nUpdate() {
3611
+ updateVueComponentRef.current?.();
3612
+ }
3613
+ });
3614
+ ComponentNodeRef.current = componentNode;
3615
+ setTimeout(mountVue);
3616
+ setComponentReady(true);
3617
+ onMounted?.();
3618
+ } catch (e) {
3619
+ if (isUnMountedRef.current) {
3620
+ return;
3621
+ }
3622
+ errorRef.current = e;
3623
+ setComponentReady(true);
3624
+ setIsError(true);
3625
+ }
3626
+ }, [mountVue]);
3627
+ (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
3628
+ // fix StrictMode
3629
+ isUnMountedRef.current = false;
3630
+ return () => {
3631
+ errorRef.current = undefined;
3632
+ ComponentNodeRef.current = undefined;
3633
+ isUnMountedRef.current = true;
3634
+ (0,_helper__WEBPACK_IMPORTED_MODULE_4__.updateUnMountComponent)({
3635
+ name,
3636
+ module
3637
+ });
3638
+ unMountVue.current?.();
3639
+ unSubscribeMessageRef.current?.();
3640
+ isVueMounted.current = false;
3641
+ };
3642
+ }, []);
3643
+ (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
3644
+ if (isVueMounted.current) {
3645
+ return;
3646
+ }
3647
+ mountComponent();
3648
+ }, [mountComponent]);
3649
+ (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
3650
+ if (propsReactiveRef.current) {
3651
+ propsReactiveRef.current.value = {
3652
+ ...$componentProps
3653
+ };
3654
+ }
3655
+ }, [$componentProps]);
3656
+ (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
3657
+ if (storeReactiveRef.current) {
3658
+ storeReactiveRef.current.value = {
3659
+ ...store
3660
+ };
3661
+ }
3662
+ }, [store]);
3663
+ if (isError) {
3664
+ throw errorRef.current;
3665
+ }
3666
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, !componentReady && !$silent && !(0,_helper__WEBPACK_IMPORTED_MODULE_4__.isModuleLoaded)(name) ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Fallback, {
3667
+ $self: selfRef.current,
3668
+ $store: store
3669
+ }) : null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
3670
+ className: (0,_helper__WEBPACK_IMPORTED_MODULE_4__.getClassNameWithModule)({
3671
+ name,
3672
+ module
3673
+ }, 'various-vue-component'),
3674
+ ref: containerDivRef
3675
+ }));
3676
+ };
3677
+ V.displayName = (0,_helper__WEBPACK_IMPORTED_MODULE_4__.getNameWithModule)({
3678
+ name,
3679
+ module
3680
+ });
3681
+ const VueComponent = props => /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(V, props);
3682
+ VueComponent.displayName = 'various-vue-component';
3683
+ return VueComponent;
3684
+ }
3685
+ /* harmony default export */ __webpack_exports__["default"] = (vueComponent);
3686
+
3687
+ /***/ }),
3688
+
3689
+ /***/ "./src/standalone/helper.ts":
3690
+ /*!**********************************!*\
3691
+ !*** ./src/standalone/helper.ts ***!
3692
+ \**********************************/
3693
+ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
3694
+
3695
+ "use strict";
3696
+ __webpack_require__.r(__webpack_exports__);
3697
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3698
+ /* harmony export */ defineModules: function() { return /* binding */ defineModules; }
3699
+ /* harmony export */ });
3700
+ /* harmony import */ var _core_helper__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../core/helper */ "./src/core/helper.ts");
3701
+
3702
+ const defineAsync = (name, dep) => new Promise(resolve => {
3703
+ window.define(name, [], () => dep);
3704
+ const check = () => {
3705
+ if (window.requirejs.specified(name)) {
3706
+ resolve();
3707
+ return;
3708
+ }
3709
+ setTimeout(check, 100);
3710
+ };
3711
+ check();
3712
+ });
3713
+ function defineModules(deps) {
3714
+ const defines = [];
3715
+ Object.entries(deps).forEach(([key, value]) => {
3716
+ if ((0,_core_helper__WEBPACK_IMPORTED_MODULE_0__.isModuleSpecified)(key) || value === undefined) {
3717
+ return;
3718
+ }
3719
+ if (typeof value === 'string') {
3720
+ window.requirejs.config({
3721
+ paths: {
3722
+ [key]: `${value}#${key}`
3723
+ }
3724
+ });
3725
+ return;
3726
+ }
3727
+ defines.push({
3728
+ key,
3729
+ value
3730
+ });
3731
+ });
3732
+ return Promise.all(defines.map(item => defineAsync(item.key, item.value)));
3733
+ }
3734
+
3735
+ /***/ }),
3736
+
3737
+ /***/ "react":
3738
+ /*!************************!*\
3739
+ !*** external "react" ***!
3740
+ \************************/
3741
+ /***/ (function(module) {
3742
+
3743
+ "use strict";
3744
+ module.exports = require("react");
3745
+
3746
+ /***/ })
3747
+
3748
+ /******/ });
3749
+ /************************************************************************/
3750
+ /******/ // The module cache
3751
+ /******/ var __webpack_module_cache__ = {};
3752
+ /******/
3753
+ /******/ // The require function
3754
+ /******/ function __webpack_require__(moduleId) {
3755
+ /******/ // Check if module is in cache
3756
+ /******/ var cachedModule = __webpack_module_cache__[moduleId];
3757
+ /******/ if (cachedModule !== undefined) {
3758
+ /******/ return cachedModule.exports;
3759
+ /******/ }
3760
+ /******/ // Create a new module (and put it into the cache)
3761
+ /******/ var module = __webpack_module_cache__[moduleId] = {
3762
+ /******/ // no module.id needed
3763
+ /******/ // no module.loaded needed
3764
+ /******/ exports: {}
3765
+ /******/ };
3766
+ /******/
3767
+ /******/ // Execute the module function
3768
+ /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
3769
+ /******/
3770
+ /******/ // Return the exports of the module
3771
+ /******/ return module.exports;
3772
+ /******/ }
3773
+ /******/
3774
+ /************************************************************************/
3775
+ /******/ /* webpack/runtime/compat get default export */
3776
+ /******/ !function() {
3777
+ /******/ // getDefaultExport function for compatibility with non-harmony modules
3778
+ /******/ __webpack_require__.n = function(module) {
3779
+ /******/ var getter = module && module.__esModule ?
3780
+ /******/ function() { return module['default']; } :
3781
+ /******/ function() { return module; };
3782
+ /******/ __webpack_require__.d(getter, { a: getter });
3783
+ /******/ return getter;
3784
+ /******/ };
3785
+ /******/ }();
3786
+ /******/
3787
+ /******/ /* webpack/runtime/define property getters */
3788
+ /******/ !function() {
3789
+ /******/ // define getter functions for harmony exports
3790
+ /******/ __webpack_require__.d = function(exports, definition) {
3791
+ /******/ for(var key in definition) {
3792
+ /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
3793
+ /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
3794
+ /******/ }
3795
+ /******/ }
3796
+ /******/ };
3797
+ /******/ }();
3798
+ /******/
3799
+ /******/ /* webpack/runtime/hasOwnProperty shorthand */
3800
+ /******/ !function() {
3801
+ /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
3802
+ /******/ }();
3803
+ /******/
3804
+ /******/ /* webpack/runtime/make namespace object */
3805
+ /******/ !function() {
3806
+ /******/ // define __esModule on exports
3807
+ /******/ __webpack_require__.r = function(exports) {
3808
+ /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
3809
+ /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
3810
+ /******/ }
3811
+ /******/ Object.defineProperty(exports, '__esModule', { value: true });
3812
+ /******/ };
3813
+ /******/ }();
3814
+ /******/
3815
+ /************************************************************************/
3816
+ var __webpack_exports__ = {};
3817
+ // This entry needs to be wrapped in an IIFE because it needs to be in strict mode.
3818
+ !function() {
3819
+ "use strict";
3820
+ /*!**********************************!*\
3821
+ !*** ./src/standalone/index.tsx ***!
3822
+ \**********************************/
3823
+ __webpack_require__.r(__webpack_exports__);
3824
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3825
+ /* harmony export */ createComponent: function() { return /* binding */ createComponent; },
3826
+ /* harmony export */ createConfig: function() { return /* binding */ createConfig; }
3827
+ /* harmony export */ });
3828
+ /* harmony import */ var _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/extends */ "./node_modules/@babel/runtime/helpers/esm/extends.js");
3829
+ /* harmony import */ var _variousjs_requirejs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @variousjs/requirejs */ "./node_modules/@variousjs/requirejs/require.js");
3830
+ /* harmony import */ var _variousjs_requirejs__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_variousjs_requirejs__WEBPACK_IMPORTED_MODULE_1__);
3831
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react */ "react");
3832
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_2__);
3833
+ /* harmony import */ var _core_create_component__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../core/create-component */ "./src/core/create-component.tsx");
3834
+ /* harmony import */ var _core_error_boundary__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../core/error-boundary */ "./src/core/error-boundary.tsx");
3835
+ /* harmony import */ var _core_connector__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../core/connector */ "./src/core/connector.ts");
3836
+ /* harmony import */ var _helper__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./helper */ "./src/standalone/helper.ts");
3837
+ /* harmony import */ var _core_store__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../core/store */ "./src/core/store.ts");
3838
+ /* harmony import */ var _core_config__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../core/config */ "./src/core/config.ts");
3839
+
3840
+
3841
+
3842
+
3843
+
3844
+
3845
+
3846
+
3847
+
3848
+ (0,_core_store__WEBPACK_IMPORTED_MODULE_7__.createStore)({
3849
+ [_core_config__WEBPACK_IMPORTED_MODULE_8__.MOUNTED_COMPONENTS_KEY]: [],
3850
+ [_core_config__WEBPACK_IMPORTED_MODULE_8__.MESSAGE_KEY]: null,
3851
+ [_core_config__WEBPACK_IMPORTED_MODULE_8__.CONFIG_KEY]: {},
3852
+ [_core_config__WEBPACK_IMPORTED_MODULE_8__.DEPENDENCIES_KEY]: {},
3853
+ configReady: undefined
3854
+ });
3855
+ window.define('react', [], () => (react__WEBPACK_IMPORTED_MODULE_2___default()));
3856
+ const Standalone = props => {
3857
+ const {
3858
+ dependencies,
3859
+ url,
3860
+ name,
3861
+ module,
3862
+ type,
3863
+ $componentProps,
3864
+ $ref,
3865
+ storeKeys
3866
+ } = props;
3867
+ const {
3868
+ configReady
3869
+ } = (0,_core_store__WEBPACK_IMPORTED_MODULE_7__.useStore)('configReady');
3870
+ const [componentReady, setComponentReady] = (0,react__WEBPACK_IMPORTED_MODULE_2__.useState)(false);
3871
+ const componentNode = (0,react__WEBPACK_IMPORTED_MODULE_2__.useRef)();
3872
+ (0,react__WEBPACK_IMPORTED_MODULE_2__.useEffect)(() => {
3873
+ (0,_helper__WEBPACK_IMPORTED_MODULE_6__.defineModules)(dependencies || {}).then(() => {
3874
+ componentNode.current = (0,_core_create_component__WEBPACK_IMPORTED_MODULE_3__["default"])({
3875
+ name,
3876
+ module,
3877
+ url,
3878
+ type
3879
+ }, storeKeys);
3880
+ setComponentReady(true);
3881
+ });
3882
+ }, [name, url, module, dependencies, type, storeKeys]);
3883
+ if (!componentReady || configReady === false) {
3884
+ const FallBack = _core_connector__WEBPACK_IMPORTED_MODULE_5__["default"].getFallbackComponent();
3885
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(FallBack, {
3886
+ $self: {
3887
+ name,
3888
+ module,
3889
+ url
3890
+ },
3891
+ $store: (0,_core_store__WEBPACK_IMPORTED_MODULE_7__.getUserStore)()
3892
+ });
3893
+ }
3894
+ const C = componentNode.current;
3895
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(C, (0,_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__["default"])({}, $componentProps, {
3896
+ ref: $ref
3897
+ }));
3898
+ };
3899
+ Standalone.displayName = 'various-standalone';
3900
+ const createComponent = args => {
3901
+ const component = props => /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_core_error_boundary__WEBPACK_IMPORTED_MODULE_4__["default"], {
3902
+ name: "standalone",
3903
+ url: args.url,
3904
+ module: args.module
3905
+ }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(Standalone, (0,_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__["default"])({
3906
+ $componentProps: props
3907
+ }, args)));
3908
+ const dispatch = next => {
3909
+ (0,_core_store__WEBPACK_IMPORTED_MODULE_7__.emit)(next, true);
3910
+ };
3911
+ component.displayName = 'various-standalone-creator';
3912
+ return Object.assign(component, {
3913
+ dispatch
3914
+ });
3915
+ };
3916
+ const createConfig = config => {
3917
+ const {
3918
+ baseDependencies,
3919
+ errorFallback,
3920
+ fallback,
3921
+ store
3922
+ } = config;
3923
+ (0,_core_store__WEBPACK_IMPORTED_MODULE_7__.emit)({
3924
+ configReady: false
3925
+ }, true);
3926
+ if (errorFallback) {
3927
+ _core_connector__WEBPACK_IMPORTED_MODULE_5__["default"].setErrorFallbackComponent(errorFallback);
3928
+ }
3929
+ if (fallback) {
3930
+ _core_connector__WEBPACK_IMPORTED_MODULE_5__["default"].setFallbackComponent(fallback);
3931
+ }
3932
+ if (store) {
3933
+ (0,_core_store__WEBPACK_IMPORTED_MODULE_7__.emit)(store);
3934
+ }
3935
+ (0,_helper__WEBPACK_IMPORTED_MODULE_6__.defineModules)(baseDependencies).then(() => {
3936
+ (0,_core_store__WEBPACK_IMPORTED_MODULE_7__.emit)({
3937
+ configReady: true
3938
+ });
3939
+ });
3940
+ };
3941
+ }();
3942
+ module.exports = __webpack_exports__;
3943
+ /******/ })()
3944
+ ;
2
3945
  //# sourceMappingURL=standalone.js.map