@variousjs/various 5.2.1 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.dev.js CHANGED
@@ -1,1715 +1,1398 @@
1
- define(["react"], function(__WEBPACK_EXTERNAL_MODULE_react__) { return /******/ (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);
1
+ import e, { Component, useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";
2
+ //#region \0@oxc-project+runtime@0.142.0/helpers/esm/typeof.js
3
+ function _typeof(o) {
4
+ "@babel/helpers - typeof";
5
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
6
+ return typeof o;
7
+ } : function(o) {
8
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
9
+ }, _typeof(o);
23
10
  }
24
-
25
-
26
- /***/ }),
27
-
28
- /***/ "./node_modules/nycticorax/dist/index.js":
29
- /*!***********************************************!*\
30
- !*** ./node_modules/nycticorax/dist/index.js ***!
31
- \***********************************************/
32
- /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
33
-
34
- !function(t,e){ true?module.exports=e(__webpack_require__(/*! react */ "react")):0}(self,t=>(()=>{"use strict";var e={17(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 o,s,n;if(Array.isArray(e)){if((o=e.length)!=r.length)return!1;for(s=o;0!==s--;)if(!t(e[s],r[s]))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((o=(n=Object.keys(e)).length)!==Object.keys(r).length)return!1;for(s=o;0!==s--;)if(!Object.prototype.hasOwnProperty.call(r,n[s]))return!1;for(s=o;0!==s--;){var i=n[s];if(!t(e[i],r[i]))return!1}return!0}return e!=e&&r!=r}},232(t,e,r){r.d(e,{default:()=>u});var o=r(705),s=r(17),n=r.n(s);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 o=Reflect.ownKeys(t);for(const s of o)r[s]=i(t[s],e);return r}class u{constructor(){var t;(0,o.A)(this,"state",void 0),(0,o.A)(this,"listeners",void 0),(0,o.A)(this,"emits",void 0),(0,o.A)(this,"timer",void 0),(0,o.A)(this,"onStateChange",void 0),(0,o.A)(this,"getStore",void 0),(0,o.A)(this,"createStore",t=>{this.listeners=Reflect.ownKeys(t).reduce((e,r)=>{const o=r;return this.state[o]=t[o],{...e,[r]:[]}},{})}),(0,o.A)(this,"subscribe",t=>{const e={};return Reflect.ownKeys(t).forEach(r=>{const o=r;this.listeners[o]||(this.listeners[o]=[]),this.listeners[o].push(t[o]),e[o]=t[o]}),()=>{Reflect.ownKeys(e).forEach(t=>{const r=t;this.listeners[r]=this.listeners[r].filter(t=>t!==e[r])})}}),(0,o.A)(this,"emit",(t,e)=>{this.emits={...this.emits,...t},e?this.trigger():(clearTimeout(this.timer),this.timer=setTimeout(this.trigger))}),(0,o.A)(this,"dispatch",(t,...e)=>t({getStore:this.getStore,emit:t=>this.emit(t,!0)},...e)),(0,o.A)(this,"trigger",()=>{const t=this.emits,e=[],r=Reflect.ownKeys(t);for(let o=0;o<r.length;o+=1){const s=r[o];if(n()(this.state[s],t[s]))continue;const u=t[s],c=this.state[s];this.state[s]=i(t[s]),e.push({key:s,newValue:u,oldValue:c})}const o={};e.forEach(t=>{o[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(o),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}}},438(e){e.exports=t},705(t,e,r){function o(t){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o(t)}function s(t,e,r){return(e=function(t){var e=function(t){if("object"!=o(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=o(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==o(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}r.d(e,{A:()=>s})}},r={};function o(t){var s=r[t];if(void 0!==s)return s.exports;var n=r[t]={exports:{}};return e[t](n,n.exports,o),n.exports}o.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return o.d(e,{a:e}),e},o.d=(t,e)=>{for(var r in e)o.o(e,r)&&!o.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var s={};o.d(s,{default:()=>l});var n=o(705),i=o(232),u=o(438),c=o.n(u);const a=["name","prototype","length","getDerivedStateFromProps","getDerivedStateFromError"];class f extends i.default{constructor(...t){super(...t),(0,n.A)(this,"connect",function(t){const{getStore:e,subscribe:r}=t;return function(...t){return function(o){class s extends u.Component{constructor(o){super(o),(0,n.A)(this,"unsubscribe",void 0),(0,n.A)(this,"state",{props:e()}),this.unsubscribe=r(t.reduce((t,r)=>({...t,[r]:()=>{this.setState({props:e()})}}),{}))}componentWillUnmount(){this.unsubscribe()}render(){const{props:t}=this.state,e={...t,...this.props};return c().createElement(o,e)}}return Reflect.ownKeys(o).forEach(t=>{const e=String(t);if(!a.includes(e)){const e=Object.getOwnPropertyDescriptor(o,t);e&&Object.defineProperty(s,t,e)}}),s}}}(this)),(0,n.A)(this,"useStore",function(t){const{getStore:e,subscribe:r}=t;return function(...t){const[o,s]=(0,u.useState)(e());return(0,u.useLayoutEffect)(()=>r(t.reduce((t,r)=>({...t,[r]:()=>{s(t=>({...t,[r]:e()[r]}))}}),{}))),o}}(this))}}const l=f;return s.default})());
35
- //# sourceMappingURL=index.js.map
36
-
37
- /***/ }),
38
-
39
- /***/ "./src/core/config.ts":
40
- /*!****************************!*\
41
- !*** ./src/core/config.ts ***!
42
- \****************************/
43
- /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
44
-
45
- "use strict";
46
- __webpack_require__.r(__webpack_exports__);
47
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
48
- /* harmony export */ BASE_DEPENDENCIES: function() { return /* binding */ BASE_DEPENDENCIES; },
49
- /* harmony export */ CONFIG_KEY: function() { return /* binding */ CONFIG_KEY; },
50
- /* harmony export */ DEPENDENCIES_KEY: function() { return /* binding */ DEPENDENCIES_KEY; },
51
- /* harmony export */ MESSAGE_KEY: function() { return /* binding */ MESSAGE_KEY; },
52
- /* harmony export */ MOUNTED_COMPONENTS_KEY: function() { return /* binding */ MOUNTED_COMPONENTS_KEY; },
53
- /* harmony export */ STANDALONE_CONFIG_READY: function() { return /* binding */ STANDALONE_CONFIG_READY; },
54
- /* harmony export */ VUE_FUNCTION_OPTIONS: function() { return /* binding */ VUE_FUNCTION_OPTIONS; },
55
- /* harmony export */ VUE_VERSION: function() { return /* binding */ VUE_VERSION; }
56
- /* harmony export */ });
57
- const MOUNTED_COMPONENTS_KEY = Symbol('MOUNTED_COMPONENTS');
58
- const MESSAGE_KEY = Symbol('MESSAGE');
59
- const CONFIG_KEY = Symbol('CONFIG');
60
- const DEPENDENCIES_KEY = Symbol('DEPENDENCIES');
61
- const STANDALONE_CONFIG_READY = Symbol('STANDALONE_CONFIG_READY');
62
- const VUE_FUNCTION_OPTIONS = ['beforeCreate', 'created', 'beforeMount', 'mounted', 'beforeUpdate', 'updated', 'beforeUnmount', 'unmounted', 'errorCaptured', 'renderTracked', 'renderTriggered', 'activated', 'deactivated', 'setup', 'data', 'render'];
63
- const VUE_VERSION = 3;
64
- const BASE_DEPENDENCIES = ['react', 'react-dom', '@variousjs/various', 'app'];
65
-
66
- /***/ }),
67
-
68
- /***/ "./src/core/connector.ts":
69
- /*!*******************************!*\
70
- !*** ./src/core/connector.ts ***!
71
- \*******************************/
72
- /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
73
-
74
- "use strict";
75
- __webpack_require__.r(__webpack_exports__);
76
- /* harmony import */ var _default_component__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./default-component */ "./src/core/default-component.tsx");
77
-
78
- class Connector {
79
- constructor() {
80
- this.fallbackComponent = _default_component__WEBPACK_IMPORTED_MODULE_0__.Fallback;
81
- this.errorFallbackComponent = _default_component__WEBPACK_IMPORTED_MODULE_0__.ErrorFallback;
82
- this.storeActions = {};
83
- this.componentActions = {};
84
- this.i18nConfigs = {};
85
- this.middlewares = {};
86
- }
87
- setMiddlewares(m) {
88
- this.middlewares = m;
89
- }
90
- getMiddlewares() {
91
- return this.middlewares;
92
- }
93
- setI18nConfig(module, config) {
94
- this.i18nConfigs[module] = {
95
- ...this.i18nConfigs[module],
96
- ...config
97
- };
98
- }
99
- getI18nConfig(module) {
100
- return this.i18nConfigs[module];
101
- }
102
- setGlobalI18nConfig(config) {
103
- this.globalI18nConfig = {
104
- ...this.globalI18nConfig,
105
- ...config
106
- };
107
- }
108
- getGlobalI18nConfig() {
109
- return this.globalI18nConfig;
110
- }
111
- setComponentActions(module, actions) {
112
- this.componentActions[module] = actions;
113
- }
114
- deleteComponentActions(module) {
115
- delete this.componentActions[module];
116
- }
117
- getComponentActions(module) {
118
- return this.componentActions[module];
119
- }
120
- setStoreActions(actions) {
121
- this.storeActions = actions;
122
- }
123
- getStoreActions() {
124
- return this.storeActions;
125
- }
126
- setFallbackComponent(fallbackComponent) {
127
- this.fallbackComponent = fallbackComponent;
128
- }
129
- getFallbackComponent() {
130
- return this.fallbackComponent;
131
- }
132
- setErrorFallbackComponent(errorFallbackComponent) {
133
- this.errorFallbackComponent = errorFallbackComponent;
134
- }
135
- getErrorFallbackComponent() {
136
- return this.errorFallbackComponent;
137
- }
11
+ //#endregion
12
+ //#region \0@oxc-project+runtime@0.142.0/helpers/esm/toPrimitive.js
13
+ function toPrimitive(t, r) {
14
+ if ("object" != _typeof(t) || !t) return t;
15
+ var e = t[Symbol.toPrimitive];
16
+ if (void 0 !== e) {
17
+ var i = e.call(t, r || "default");
18
+ if ("object" != _typeof(i)) return i;
19
+ throw new TypeError("@@toPrimitive must return a primitive value.");
20
+ }
21
+ return ("string" === r ? String : Number)(t);
138
22
  }
139
- /* harmony default export */ __webpack_exports__["default"] = (new Connector());
140
-
141
- /***/ }),
142
-
143
- /***/ "./src/core/create-component.tsx":
144
- /*!***************************************!*\
145
- !*** ./src/core/create-component.tsx ***!
146
- \***************************************/
147
- /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
148
-
149
- "use strict";
150
- __webpack_require__.r(__webpack_exports__);
151
- /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
152
- /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
153
- /* harmony import */ var _react_component__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./react-component */ "./src/core/react-component.tsx");
154
- /* harmony import */ var _vue_component__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./vue-component */ "./src/core/vue-component.tsx");
155
- /* harmony import */ var _error_boundary__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./error-boundary */ "./src/core/error-boundary.tsx");
156
-
157
-
158
-
159
-
160
- const createComponent = (config, storeKeys) => {
161
- const {
162
- module,
163
- url,
164
- type = 'react'
165
- } = config;
166
- const C = (type === 'vue3' ? _vue_component__WEBPACK_IMPORTED_MODULE_2__["default"] : _react_component__WEBPACK_IMPORTED_MODULE_1__["default"])({
167
- module,
168
- url,
169
- watchKeys: storeKeys
170
- });
171
- const component = props => {
172
- const {
173
- $silent,
174
- $ref,
175
- ...rest
176
- } = props || {};
177
- const nextProps = {
178
- $componentProps: rest,
179
- $silent,
180
- $ref
181
- };
182
- return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_error_boundary__WEBPACK_IMPORTED_MODULE_3__["default"], {
183
- module: module,
184
- url: url
185
- }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(C, nextProps));
186
- };
187
- component.displayName = 'various-creator';
188
- return component;
23
+ //#endregion
24
+ //#region \0@oxc-project+runtime@0.142.0/helpers/esm/toPropertyKey.js
25
+ function toPropertyKey(t) {
26
+ var i = toPrimitive(t, "string");
27
+ return "symbol" == _typeof(i) ? i : i + "";
28
+ }
29
+ //#endregion
30
+ //#region \0@oxc-project+runtime@0.142.0/helpers/esm/defineProperty.js
31
+ function _defineProperty(e, r, t) {
32
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
33
+ value: t,
34
+ enumerable: !0,
35
+ configurable: !0,
36
+ writable: !0
37
+ }) : e[r] = t, e;
38
+ }
39
+ //#endregion
40
+ //#region \0@oxc-project+runtime@0.142.0/helpers/esm/objectSpread2.js
41
+ function ownKeys(e, r) {
42
+ var t = Object.keys(e);
43
+ if (Object.getOwnPropertySymbols) {
44
+ var o = Object.getOwnPropertySymbols(e);
45
+ r && (o = o.filter(function(r) {
46
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
47
+ })), t.push.apply(t, o);
48
+ }
49
+ return t;
50
+ }
51
+ function _objectSpread2(e) {
52
+ for (var r = 1; r < arguments.length; r++) {
53
+ var t = null != arguments[r] ? arguments[r] : {};
54
+ r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
55
+ _defineProperty(e, r, t[r]);
56
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
57
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
58
+ });
59
+ }
60
+ return e;
61
+ }
62
+ //#endregion
63
+ //#region node_modules/nycticorax/dist/esm/index.js
64
+ var o = {
65
+ 17(t) {
66
+ t.exports = function t(e, r) {
67
+ if (e === r) return !0;
68
+ if (e && r && "object" == typeof e && "object" == typeof r) {
69
+ if (e.constructor !== r.constructor) return !1;
70
+ var s, o, n;
71
+ if (Array.isArray(e)) {
72
+ if ((s = e.length) != r.length) return !1;
73
+ for (o = s; 0 !== o--;) if (!t(e[o], r[o])) return !1;
74
+ return !0;
75
+ }
76
+ if (e.constructor === RegExp) return e.source === r.source && e.flags === r.flags;
77
+ if (e.valueOf !== Object.prototype.valueOf) return e.valueOf() === r.valueOf();
78
+ if (e.toString !== Object.prototype.toString) return e.toString() === r.toString();
79
+ if ((s = (n = Object.keys(e)).length) !== Object.keys(r).length) return !1;
80
+ for (o = s; 0 !== o--;) if (!Object.prototype.hasOwnProperty.call(r, n[o])) return !1;
81
+ for (o = s; 0 !== o--;) {
82
+ var i = n[o];
83
+ if (!t(e[i], r[i])) return !1;
84
+ }
85
+ return !0;
86
+ }
87
+ return e != e && r != r;
88
+ };
89
+ },
90
+ 232(t, e, r) {
91
+ r.d(e, { A: () => u });
92
+ var s = r(705), o = r(17), n = r.n(o);
93
+ function i(t, e = /* @__PURE__ */ new WeakMap()) {
94
+ if ("object" != typeof t || null === t) return t;
95
+ if (e.has(t)) return e.get(t);
96
+ const r = Array.isArray(t) ? [] : {};
97
+ e.set(t, r);
98
+ const s = Reflect.ownKeys(t);
99
+ for (const o of s) r[o] = i(t[o], e);
100
+ return r;
101
+ }
102
+ class u {
103
+ constructor() {
104
+ var t;
105
+ (0, s.A)(this, "state", void 0), (0, s.A)(this, "listeners", void 0), (0, s.A)(this, "emits", void 0), (0, s.A)(this, "timer", void 0), (0, s.A)(this, "onStateChange", void 0), (0, s.A)(this, "getStore", void 0), (0, s.A)(this, "createStore", (t) => {
106
+ this.listeners = Reflect.ownKeys(t).reduce((e, r) => {
107
+ const s = r;
108
+ return this.state[s] = t[s], _objectSpread2(_objectSpread2({}, e), {}, { [r]: [] });
109
+ }, {});
110
+ }), (0, s.A)(this, "subscribe", (t) => {
111
+ const e = {};
112
+ return Reflect.ownKeys(t).forEach((r) => {
113
+ const s = r;
114
+ this.listeners[s] || (this.listeners[s] = []), this.listeners[s].push(t[s]), e[s] = t[s];
115
+ }), () => {
116
+ Reflect.ownKeys(e).forEach((t) => {
117
+ const r = t;
118
+ this.listeners[r] = this.listeners[r].filter((t) => t !== e[r]);
119
+ });
120
+ };
121
+ }), (0, s.A)(this, "emit", (t, e) => {
122
+ this.emits = _objectSpread2(_objectSpread2({}, this.emits), t), e ? this.trigger() : (clearTimeout(this.timer), this.timer = setTimeout(this.trigger));
123
+ }), (0, s.A)(this, "dispatch", (t, ...e) => t({
124
+ getStore: this.getStore,
125
+ emit: (t) => this.emit(t, !0)
126
+ }, ...e)), (0, s.A)(this, "trigger", () => {
127
+ const t = this.emits, e = [], r = Reflect.ownKeys(t);
128
+ for (let s = 0; s < r.length; s += 1) {
129
+ const o = r[s];
130
+ if (n()(this.state[o], t[o])) continue;
131
+ const u = t[o], c = this.state[o];
132
+ this.state[o] = i(t[o]), e.push({
133
+ key: o,
134
+ newValue: u,
135
+ oldValue: c
136
+ });
137
+ }
138
+ const s = {};
139
+ e.forEach((t) => {
140
+ s[t.key] = [t.newValue, t.oldValue], this.listeners[t.key] && this.listeners[t.key].forEach((e) => e(t.newValue, t.oldValue));
141
+ }), e.length && this.onStateChange(s), this.emits = {}, this.timer = void 0;
142
+ }), this.state = {}, this.listeners = {}, this.emits = {}, this.timer = void 0, this.onStateChange = () => null, this.getStore = (t = this.state, function(e) {
143
+ return e ? i(t[e]) : t;
144
+ });
145
+ }
146
+ set onChange(t) {
147
+ this.onStateChange = t;
148
+ }
149
+ }
150
+ },
151
+ 705(t, e, r) {
152
+ function s(t) {
153
+ return s = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(t) {
154
+ return typeof t;
155
+ } : function(t) {
156
+ return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t;
157
+ }, s(t);
158
+ }
159
+ function o(t, e, r) {
160
+ return (e = function(t) {
161
+ var e = function(t) {
162
+ if ("object" != s(t) || !t) return t;
163
+ var e = t[Symbol.toPrimitive];
164
+ if (void 0 !== e) {
165
+ var r = e.call(t, "string");
166
+ if ("object" != s(r)) return r;
167
+ throw new TypeError("@@toPrimitive must return a primitive value.");
168
+ }
169
+ return String(t);
170
+ }(t);
171
+ return "symbol" == s(e) ? e : e + "";
172
+ }(e)) in t ? Object.defineProperty(t, e, {
173
+ value: r,
174
+ enumerable: !0,
175
+ configurable: !0,
176
+ writable: !0
177
+ }) : t[e] = r, t;
178
+ }
179
+ r.d(e, { A: () => o });
180
+ }
189
181
  };
190
- /* harmony default export */ __webpack_exports__["default"] = (createComponent);
191
-
192
- /***/ }),
193
-
194
- /***/ "./src/core/create-module.ts":
195
- /*!***********************************!*\
196
- !*** ./src/core/create-module.ts ***!
197
- \***********************************/
198
- /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
199
-
200
- "use strict";
201
- __webpack_require__.r(__webpack_exports__);
202
- /* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./config */ "./src/core/config.ts");
203
- /* harmony import */ var _store__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./store */ "./src/core/store.ts");
204
- /* harmony import */ var _connector__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./connector */ "./src/core/connector.ts");
205
- /* harmony import */ var _helper__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./helper */ "./src/core/helper.ts");
206
-
207
-
208
-
209
-
210
- const createModule = (config, logError = true) => {
211
- const dependencies = (0,_store__WEBPACK_IMPORTED_MODULE_1__.getStore)(_config__WEBPACK_IMPORTED_MODULE_0__.DEPENDENCIES_KEY);
212
- const middlewares = _connector__WEBPACK_IMPORTED_MODULE_2__["default"].getMiddlewares();
213
- const {
214
- url,
215
- module
216
- } = config;
217
- const {
218
- name,
219
- entry
220
- } = (0,_helper__WEBPACK_IMPORTED_MODULE_3__.getModuleInfo)(module);
221
- const loadStart = +new Date();
222
- const logOnError = e => {
223
- if (logError) {
224
- (0,_helper__WEBPACK_IMPORTED_MODULE_3__.onError)(e);
225
- }
226
- };
227
- if (url) {
228
- (0,_helper__WEBPACK_IMPORTED_MODULE_3__.resetDependencyConfig)(module, url);
229
- }
230
- return new Promise((resolve, reject) => {
231
- if (!url && !dependencies[name] && !(0,_helper__WEBPACK_IMPORTED_MODULE_3__.isModuleSpecified)(module)) {
232
- const error = new _helper__WEBPACK_IMPORTED_MODULE_3__.VariousError({
233
- module,
234
- type: 'NOT_DEFINED',
235
- originalError: new Error(`module "${name}" not defined`)
236
- });
237
- logOnError(error);
238
- reject(error);
239
- return;
240
- }
241
- window.requirejs([name], C => {
242
- const loadEnd = +new Date();
243
- middlewares?.onLoad?.({
244
- module,
245
- loadStart,
246
- loadEnd,
247
- beenLoaded: (0,_helper__WEBPACK_IMPORTED_MODULE_3__.isModuleLoaded)(module)
248
- });
249
- if (!C) {
250
- const error = new _helper__WEBPACK_IMPORTED_MODULE_3__.VariousError({
251
- module,
252
- type: 'INVALID_MODULE',
253
- originalError: new Error(`module "${name}" invalid`)
254
- });
255
- (0,_helper__WEBPACK_IMPORTED_MODULE_3__.resetDependencyConfig)(module);
256
- logOnError(error);
257
- reject(error);
258
- return;
259
- }
260
- const defaultModule = 'default' in C ? C.default : C;
261
- const actualModule = !entry ? defaultModule : C[entry];
262
- if (actualModule === undefined && entry) {
263
- const error = new _helper__WEBPACK_IMPORTED_MODULE_3__.VariousError({
264
- module,
265
- type: 'SUBMODULE_NOT_DEFINED',
266
- originalError: new Error(`submodule "${entry}" not defined`)
267
- });
268
- (0,_helper__WEBPACK_IMPORTED_MODULE_3__.resetDependencyConfig)(module);
269
- logOnError(error);
270
- reject(error);
271
- return;
272
- }
273
- resolve(actualModule);
274
- }, e => {
275
- const [requireModule] = e.requireModules;
276
- (0,_helper__WEBPACK_IMPORTED_MODULE_3__.resetDependencyConfig)(module, url);
277
- (0,_helper__WEBPACK_IMPORTED_MODULE_3__.resetDependencyConfig)(requireModule);
278
- let errorType = 'LOADING_ERROR';
279
- if (requireModule !== name) {
280
- errorType = 'SUBMODULE_LOADING_ERROR';
281
- }
282
- if (!e.message.includes('https://requirejs.org/docs/errors.html')) {
283
- errorType = requireModule === name ? 'SCRIPT_ERROR' : 'SUBMODULE_SCRIPT_ERROR';
284
- }
285
- const error = new _helper__WEBPACK_IMPORTED_MODULE_3__.VariousError({
286
- module: requireModule,
287
- type: errorType,
288
- originalError: e
289
- });
290
- logOnError(error);
291
- reject(error);
292
- });
293
- });
182
+ var n = {};
183
+ function i(t) {
184
+ var e = n[t];
185
+ if (void 0 !== e) return e.exports;
186
+ var r = n[t] = { exports: {} };
187
+ return o[t](r, r.exports, i), r.exports;
188
+ }
189
+ i.n = (t) => {
190
+ var e = t && t.__esModule ? () => t.default : () => t;
191
+ return i.d(e, { a: e }), e;
192
+ }, i.d = (t, e) => {
193
+ for (var r in e) i.o(e, r) && !i.o(t, r) && Object.defineProperty(t, r, {
194
+ enumerable: !0,
195
+ get: e[r]
196
+ });
197
+ }, i.o = (t, e) => Object.prototype.hasOwnProperty.call(t, e);
198
+ var u = i(705);
199
+ var c = i(232);
200
+ var a = [
201
+ "name",
202
+ "prototype",
203
+ "length",
204
+ "getDerivedStateFromProps",
205
+ "getDerivedStateFromError"
206
+ ];
207
+ var f = class extends c.A {
208
+ constructor(...o) {
209
+ super(...o), (0, u.A)(this, "connect", function(r) {
210
+ const { getStore: s, subscribe: o } = r;
211
+ return function(...r) {
212
+ return function(n) {
213
+ class i extends Component {
214
+ constructor(t) {
215
+ super(t), (0, u.A)(this, "unsubscribe", void 0), (0, u.A)(this, "state", { props: s() }), this.unsubscribe = o(r.reduce((t, e) => _objectSpread2(_objectSpread2({}, t), {}, { [e]: () => {
216
+ this.setState({ props: s() });
217
+ } }), {}));
218
+ }
219
+ componentWillUnmount() {
220
+ this.unsubscribe();
221
+ }
222
+ render() {
223
+ const { props: t } = this.state, r = _objectSpread2(_objectSpread2({}, t), this.props);
224
+ return e.createElement(n, r);
225
+ }
226
+ }
227
+ return Reflect.ownKeys(n).forEach((t) => {
228
+ const e = String(t);
229
+ if (!a.includes(e)) {
230
+ const e = Object.getOwnPropertyDescriptor(n, t);
231
+ e && Object.defineProperty(i, t, e);
232
+ }
233
+ }), i;
234
+ };
235
+ };
236
+ }(this)), (0, u.A)(this, "useStore", function(t) {
237
+ const { getStore: e, subscribe: o } = t;
238
+ return function(...t) {
239
+ const [n, i] = useState(e());
240
+ return useLayoutEffect(() => o(t.reduce((t, r) => _objectSpread2(_objectSpread2({}, t), {}, { [r]: () => {
241
+ i((t) => _objectSpread2(_objectSpread2({}, t), {}, { [r]: e()[r] }));
242
+ } }), {}))), n;
243
+ };
244
+ }(this));
245
+ }
294
246
  };
295
- /* harmony default export */ __webpack_exports__["default"] = (createModule);
296
-
297
- /***/ }),
298
-
299
- /***/ "./src/core/default-component.tsx":
300
- /*!****************************************!*\
301
- !*** ./src/core/default-component.tsx ***!
302
- \****************************************/
303
- /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
304
-
305
- "use strict";
306
- __webpack_require__.r(__webpack_exports__);
307
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
308
- /* harmony export */ ErrorFallback: function() { return /* binding */ ErrorFallback; },
309
- /* harmony export */ Fallback: function() { return /* binding */ Fallback; },
310
- /* harmony export */ Root: function() { return /* binding */ Root; }
311
- /* harmony export */ });
312
- /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
313
- /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
314
- /* harmony import */ var _helper__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./helper */ "./src/core/helper.ts");
315
-
316
-
317
- const Fallback = props => {
318
- const className = (0,_helper__WEBPACK_IMPORTED_MODULE_1__.getClassNameWithModule)(props.$self.module, 'various-component-fallback');
319
- return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
320
- className: className
321
- }, "Loading");
247
+ var h = f;
248
+ //#endregion
249
+ //#region src/core/store.ts
250
+ var { createStore, getStore, connect, emit, subscribe, dispatch, useStore } = new h();
251
+ function getUserStore() {
252
+ const globalStore = getStore();
253
+ const keys = Object.keys(globalStore);
254
+ const store = {};
255
+ keys.forEach((key) => {
256
+ store[key] = globalStore[key];
257
+ });
258
+ return store;
259
+ }
260
+ //#endregion
261
+ //#region src/core/config.ts
262
+ var MOUNTED_COMPONENTS_KEY = Symbol("MOUNTED_COMPONENTS");
263
+ var MESSAGE_KEY = Symbol("MESSAGE");
264
+ var CONFIG_KEY = Symbol("CONFIG");
265
+ var DEPENDENCIES_KEY = Symbol("DEPENDENCIES");
266
+ var LOCALE_KEY = Symbol("LOCALE");
267
+ var I18NActions = /* @__PURE__ */ function(I18NActions) {
268
+ I18NActions["SetLocale"] = "setLocale";
269
+ I18NActions["GetLocale"] = "getLocale";
270
+ I18NActions["UpdateI18nConfig"] = "updateI18nConfig";
271
+ return I18NActions;
272
+ }({});
273
+ var VUE_FUNCTION_OPTIONS = [
274
+ "beforeCreate",
275
+ "created",
276
+ "beforeMount",
277
+ "mounted",
278
+ "beforeUpdate",
279
+ "updated",
280
+ "beforeUnmount",
281
+ "unmounted",
282
+ "errorCaptured",
283
+ "renderTracked",
284
+ "renderTriggered",
285
+ "activated",
286
+ "deactivated",
287
+ "setup",
288
+ "data",
289
+ "render"
290
+ ];
291
+ var BASE_DEPENDENCIES = [
292
+ "react",
293
+ "react-dom",
294
+ "@variousjs/various",
295
+ "app"
296
+ ];
297
+ //#endregion
298
+ //#region src/core/logger.ts
299
+ var logger = (args) => {
300
+ var _middlewares$onLog;
301
+ const middlewares = connector_default.getMiddlewares();
302
+ if ((middlewares === null || middlewares === void 0 || (_middlewares$onLog = middlewares.onLog) === null || _middlewares$onLog === void 0 ? void 0 : _middlewares$onLog.call(middlewares, args)) === false) return;
303
+ const color = {
304
+ info: "blue",
305
+ warn: "orange",
306
+ error: "red"
307
+ }[args.level];
308
+ const params = [`%c ${args.module} `, `background:${color};border:1px solid ${color};padding:1px;border-radius:2px 0 0 2px;color: #fff;`];
309
+ if (args.type) {
310
+ params[0] = `${params[0]}%c ${args.type} %c`;
311
+ params.push(`border:1px solid ${color};padding:1px;border-radius:0 2px 2px 0;color:${color};`, "background:transparent");
312
+ }
313
+ if (args.level !== "info") params[0] = ` ${params[0]}`;
314
+ window.console[args.level](...params, args.message);
322
315
  };
323
- const ErrorFallback = ({
324
- $error,
325
- $reload,
326
- $self
327
- }) => {
328
- const className = (0,_helper__WEBPACK_IMPORTED_MODULE_1__.getClassNameWithModule)($self.module, 'various-component-error_fallback');
329
- return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
330
- className: className
331
- }, /*#__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", {
332
- type: "button",
333
- onClick: $reload
334
- }, "Reload"));
316
+ var createLogger = (module) => ({
317
+ info(message, type) {
318
+ logger({
319
+ module,
320
+ level: "info",
321
+ type,
322
+ message
323
+ });
324
+ },
325
+ warn(message, type) {
326
+ logger({
327
+ module,
328
+ level: "warn",
329
+ type,
330
+ message
331
+ });
332
+ },
333
+ error(message, type) {
334
+ var _middlewares$onError;
335
+ const middlewares = connector_default.getMiddlewares();
336
+ const error = message instanceof VariousError ? message : new VariousError({
337
+ module,
338
+ type: type || "unknow",
339
+ originalError: message instanceof Error ? message : new Error(message)
340
+ });
341
+ middlewares === null || middlewares === void 0 || (_middlewares$onError = middlewares.onError) === null || _middlewares$onError === void 0 || _middlewares$onError.call(middlewares, error);
342
+ logger({
343
+ module,
344
+ level: "error",
345
+ type,
346
+ message
347
+ });
348
+ }
349
+ });
350
+ //#endregion
351
+ //#region src/core/message.ts
352
+ var createPostMessage = (module) => async ({ event, payload }) => {
353
+ const middlewares = connector_default.getMiddlewares();
354
+ const logger = createLogger(module);
355
+ let next = {
356
+ trigger: module,
357
+ event,
358
+ payload
359
+ };
360
+ if (middlewares === null || middlewares === void 0 ? void 0 : middlewares.onMessage) {
361
+ const check = await middlewares.onMessage(next);
362
+ if (check === false) {
363
+ logger.warn("blocked by middleware", "POST_MESSAGE");
364
+ return;
365
+ }
366
+ if (check !== true) next = _objectSpread2(_objectSpread2({}, next), check);
367
+ }
368
+ emit({ [MESSAGE_KEY]: {
369
+ timestamp: +/* @__PURE__ */ new Date(),
370
+ event: next.event,
371
+ trigger: module,
372
+ payload: next.payload
373
+ } });
335
374
  };
336
- const Root = () => /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", null, "App Container is not defined");
337
-
338
- /***/ }),
339
-
340
- /***/ "./src/core/dispatch.ts":
341
- /*!******************************!*\
342
- !*** ./src/core/dispatch.ts ***!
343
- \******************************/
344
- /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
345
-
346
- "use strict";
347
- __webpack_require__.r(__webpack_exports__);
348
- /* harmony import */ var _connector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./connector */ "./src/core/connector.ts");
349
- /* harmony import */ var _store__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./store */ "./src/core/store.ts");
350
- /* harmony import */ var _helper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./helper */ "./src/core/helper.ts");
351
- /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./logger */ "./src/core/logger.ts");
352
-
353
-
354
-
355
-
356
- const createDispatch = module => async function (params) {
357
- const middlewares = _connector__WEBPACK_IMPORTED_MODULE_0__["default"].getMiddlewares();
358
- const logger = (0,_logger__WEBPACK_IMPORTED_MODULE_3__["default"])(module);
359
- let {
360
- action,
361
- payload,
362
- target
363
- } = params;
364
- if (middlewares?.onDispatch) {
365
- const check = await middlewares.onDispatch({
366
- target,
367
- action,
368
- payload,
369
- trigger: module
370
- });
371
- if (check === false) {
372
- logger.warn('blocked by middleware', 'DISPATCH');
373
- return Promise.resolve();
374
- }
375
- if (check !== true) {
376
- target = check.target;
377
- action = check.action;
378
- payload = check.payload;
379
- }
380
- }
381
- if (target === 'app') {
382
- const storeActions = _connector__WEBPACK_IMPORTED_MODULE_0__["default"].getStoreActions();
383
- const storeAction = storeActions[action];
384
- if (!storeAction) {
385
- const errorMessage = `action "${action}" is not present`;
386
- const error = new _helper__WEBPACK_IMPORTED_MODULE_2__.VariousError({
387
- module,
388
- type: 'DISPATCH',
389
- originalError: new Error(errorMessage)
390
- });
391
- (0,_helper__WEBPACK_IMPORTED_MODULE_2__.onError)(error);
392
- throw error;
393
- }
394
- return (0,_store__WEBPACK_IMPORTED_MODULE_1__.dispatch)(storeAction, payload, module);
395
- }
396
- const componentActions = _connector__WEBPACK_IMPORTED_MODULE_0__["default"].getComponentActions(target);
397
- if (!componentActions) {
398
- const errorMessage = 'component is not ready';
399
- const error = new _helper__WEBPACK_IMPORTED_MODULE_2__.VariousError({
400
- module,
401
- type: 'DISPATCH',
402
- originalError: new Error(errorMessage)
403
- });
404
- (0,_helper__WEBPACK_IMPORTED_MODULE_2__.onError)(error);
405
- throw error;
406
- }
407
- const componentAction = componentActions[action];
408
- if (!componentAction) {
409
- const errorMessage = `action "${action}" is not present`;
410
- const error = new _helper__WEBPACK_IMPORTED_MODULE_2__.VariousError({
411
- module,
412
- type: 'DISPATCH',
413
- originalError: new Error(errorMessage)
414
- });
415
- (0,_helper__WEBPACK_IMPORTED_MODULE_2__.onError)(error);
416
- throw error;
417
- }
418
- return Promise.resolve(componentAction({
419
- payload,
420
- trigger: module
421
- }));
375
+ var createOnMessage = (module, onMessage) => subscribe({ [MESSAGE_KEY](v) {
376
+ const { trigger, payload, event } = v;
377
+ if (module !== trigger) onMessage({
378
+ event,
379
+ payload,
380
+ trigger
381
+ });
382
+ } });
383
+ //#endregion
384
+ //#region src/core/i18n.ts
385
+ function createI18nConfig(method, module, callback) {
386
+ if (!method) return;
387
+ const i18nConfig = method();
388
+ if (!isPromiseLike(i18nConfig)) {
389
+ if (module) connector_default.setI18nConfig(module, i18nConfig);
390
+ else connector_default.setGlobalI18nConfig(i18nConfig);
391
+ return;
392
+ }
393
+ if (module) connector_default.setI18nConfig(module, {
394
+ loading: true,
395
+ resources: {}
396
+ });
397
+ else connector_default.setGlobalI18nConfig({
398
+ loading: true,
399
+ resources: {}
400
+ });
401
+ i18nConfig.then((res) => {
402
+ if (module) {
403
+ connector_default.setI18nConfig(module, _objectSpread2(_objectSpread2({}, res), {}, { loading: false }));
404
+ callback === null || callback === void 0 || callback();
405
+ return;
406
+ }
407
+ const locale = getStore(LOCALE_KEY);
408
+ emit({ [LOCALE_KEY]: void 0 }, true);
409
+ emit({ [LOCALE_KEY]: locale }, true);
410
+ connector_default.setGlobalI18nConfig(_objectSpread2(_objectSpread2({}, res), {}, { loading: false }));
411
+ }).catch((e) => {
412
+ onError(new VariousError({
413
+ module: module || "app",
414
+ type: "I18N",
415
+ originalError: e
416
+ }));
417
+ });
418
+ }
419
+ function createI18n(module, updater) {
420
+ const ctx = (key, params, defaultString) => {
421
+ const i18nConfig = connector_default.getI18nConfig(module) || connector_default.getGlobalI18nConfig();
422
+ let defaultText = defaultString;
423
+ if (defaultText === void 0) defaultText = typeof params === "string" ? params : key;
424
+ if (!i18nConfig) {
425
+ onError(new VariousError({
426
+ module,
427
+ type: "I18N",
428
+ originalError: /* @__PURE__ */ new Error("config not exist")
429
+ }));
430
+ return defaultText;
431
+ }
432
+ if (i18nConfig.loading) return defaultText;
433
+ const { resources } = i18nConfig;
434
+ const locale = getStore(LOCALE_KEY);
435
+ const resource = resources === null || resources === void 0 ? void 0 : resources[locale];
436
+ if (!resource) {
437
+ onError(new VariousError({
438
+ module,
439
+ type: "I18N",
440
+ originalError: /* @__PURE__ */ new Error(`locale resource \`${locale}\` not exist`)
441
+ }));
442
+ return defaultText;
443
+ }
444
+ if (!resource[key]) {
445
+ onError(new VariousError({
446
+ module,
447
+ type: "I18N",
448
+ originalError: /* @__PURE__ */ new Error(`locale key \`${key}\` not exist`)
449
+ }));
450
+ return defaultText;
451
+ }
452
+ const text = resource[key];
453
+ if (!params || typeof params === "string" || Object.prototype.toString.call(params) !== "[object Object]") return text;
454
+ const args = Object.keys(params);
455
+ if (!args.length) return text;
456
+ return args.reduce((next, arg) => {
457
+ const regex = new RegExp(`{\\s*${arg}\\s*}`, "g");
458
+ return next.replace(regex, params[arg].toString());
459
+ }, text);
460
+ };
461
+ ctx.update = (config) => {
462
+ const next = _objectSpread2(_objectSpread2({}, connector_default.getI18nConfig(module)), config);
463
+ connector_default.setI18nConfig(module, next);
464
+ updater();
465
+ };
466
+ return ctx;
467
+ }
468
+ //#endregion
469
+ //#region \0vite/preload-helper.js
470
+ var scriptRel = "modulepreload";
471
+ var assetsURL = function(dep) {
472
+ return "/" + dep;
422
473
  };
423
- /* harmony default export */ __webpack_exports__["default"] = (createDispatch);
424
-
425
- /***/ }),
426
-
427
- /***/ "./src/core/error-boundary.tsx":
428
- /*!*************************************!*\
429
- !*** ./src/core/error-boundary.tsx ***!
430
- \*************************************/
431
- /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
432
-
433
- "use strict";
434
- __webpack_require__.r(__webpack_exports__);
435
- /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
436
- /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
437
- /* harmony import */ var _helper__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./helper */ "./src/core/helper.ts");
438
- /* harmony import */ var _connector__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./connector */ "./src/core/connector.ts");
439
- /* harmony import */ var _store__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./store */ "./src/core/store.ts");
440
-
441
-
442
-
443
-
444
- class ErrorBoundary extends react__WEBPACK_IMPORTED_MODULE_0__.Component {
445
- static displayName = 'various-error-boundary';
446
- state = {
447
- hasError: false
448
- };
449
- componentDidCatch(e) {
450
- const {
451
- module
452
- } = this.props;
453
- const error = e instanceof _helper__WEBPACK_IMPORTED_MODULE_1__.VariousError ? e : new _helper__WEBPACK_IMPORTED_MODULE_1__.VariousError({
454
- module,
455
- type: module === 'app' ? 'APP_ERROR' : 'SCRIPT_ERROR',
456
- originalError: e
457
- });
458
- this.setState({
459
- hasError: true
460
- });
461
- this.error = error;
462
- (0,_helper__WEBPACK_IMPORTED_MODULE_1__.onError)(error);
463
- (0,_helper__WEBPACK_IMPORTED_MODULE_1__.resetDependencyConfig)(module);
464
- (0,_helper__WEBPACK_IMPORTED_MODULE_1__.updateUnMountComponent)(module);
465
- }
466
- $self = (0,_helper__WEBPACK_IMPORTED_MODULE_1__.getSelfInfo)(this.props);
467
- reload = () => {
468
- this.error = undefined;
469
- this.setState({
470
- hasError: false
471
- });
472
- };
473
- render() {
474
- const ErrorFallbackNode = _connector__WEBPACK_IMPORTED_MODULE_2__["default"].getErrorFallbackComponent();
475
- const store = (0,_store__WEBPACK_IMPORTED_MODULE_3__.getUserStore)();
476
- if (this.state.hasError) {
477
- return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(ErrorFallbackNode, {
478
- $self: this.$self,
479
- $reload: this.reload,
480
- $store: store,
481
- $error: this.error
482
- });
483
- }
484
- return this.props.children;
485
- }
474
+ var seen = {};
475
+ var __vitePreload = function preload(baseModule, deps, importerUrl) {
476
+ let promise = Promise.resolve();
477
+ if (deps && deps.length > 0) {
478
+ const links = document.getElementsByTagName("link");
479
+ const cspNonceMeta = document.querySelector("meta[property=csp-nonce]");
480
+ const cspNonce = (cspNonceMeta === null || cspNonceMeta === void 0 ? void 0 : cspNonceMeta.nonce) || (cspNonceMeta === null || cspNonceMeta === void 0 ? void 0 : cspNonceMeta.getAttribute("nonce"));
481
+ function allSettled(promises) {
482
+ return Promise.all(promises.map((p) => Promise.resolve(p).then((value) => ({
483
+ status: "fulfilled",
484
+ value
485
+ }), (reason) => ({
486
+ status: "rejected",
487
+ reason
488
+ }))));
489
+ }
490
+ function importMetaResolve(specifier) {
491
+ if (import.meta.resolve) return import.meta.resolve(specifier);
492
+ return new URL(
493
+ specifier,
494
+ /** #__KEEP__ */
495
+ import.meta.url
496
+ ).href;
497
+ }
498
+ promise = allSettled(deps.map((dep) => {
499
+ dep = assetsURL(dep, importerUrl);
500
+ dep = importMetaResolve(dep);
501
+ if (dep in seen) return;
502
+ seen[dep] = true;
503
+ const isCss = dep.endsWith(".css");
504
+ for (let i = links.length - 1; i >= 0; i--) {
505
+ const link = links[i];
506
+ if (link.href === dep && (!isCss || link.rel === "stylesheet")) return;
507
+ }
508
+ const link = document.createElement("link");
509
+ link.rel = isCss ? "stylesheet" : scriptRel;
510
+ if (!isCss) link.as = "script";
511
+ link.crossOrigin = "";
512
+ link.href = dep;
513
+ if (cspNonce) link.setAttribute("nonce", cspNonce);
514
+ document.head.appendChild(link);
515
+ if (isCss) return new Promise((res, rej) => {
516
+ link.addEventListener("load", res);
517
+ link.addEventListener("error", () => rej(/* @__PURE__ */ new Error(`Unable to preload CSS for ${dep}`)));
518
+ });
519
+ }));
520
+ }
521
+ function handlePreloadError(err) {
522
+ const e = new Event("vite:preloadError", { cancelable: true });
523
+ e.payload = err;
524
+ window.dispatchEvent(e);
525
+ if (!e.defaultPrevented) throw err;
526
+ }
527
+ return promise.then((res) => {
528
+ for (const item of res || []) {
529
+ if (item.status !== "rejected") continue;
530
+ handlePreloadError(item.reason);
531
+ }
532
+ return baseModule().catch(handlePreloadError);
533
+ });
534
+ };
535
+ //#endregion
536
+ //#region src/core/system.ts
537
+ function getRegistry() {
538
+ if (!window.__various) window.__various = {
539
+ modules: /* @__PURE__ */ new Map(),
540
+ urls: /* @__PURE__ */ new Map(),
541
+ loaded: /* @__PURE__ */ new Map()
542
+ };
543
+ return window.__various;
486
544
  }
487
- /* harmony default export */ __webpack_exports__["default"] = (ErrorBoundary);
488
-
489
- /***/ }),
490
-
491
- /***/ "./src/core/helper.ts":
492
- /*!****************************!*\
493
- !*** ./src/core/helper.ts ***!
494
- \****************************/
495
- /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
496
-
497
- "use strict";
498
- __webpack_require__.r(__webpack_exports__);
499
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
500
- /* harmony export */ VariousError: function() { return /* binding */ VariousError; },
501
- /* harmony export */ checkReactComponent: function() { return /* binding */ checkReactComponent; },
502
- /* harmony export */ checkVueComponent: function() { return /* binding */ checkVueComponent; },
503
- /* harmony export */ defineDependencies: function() { return /* binding */ defineDependencies; },
504
- /* harmony export */ getClassNameWithModule: function() { return /* binding */ getClassNameWithModule; },
505
- /* harmony export */ getConfig: function() { return /* binding */ getConfig; },
506
- /* harmony export */ getModuleInfo: function() { return /* binding */ getModuleInfo; },
507
- /* harmony export */ getMountedComponents: function() { return /* binding */ getMountedComponents; },
508
- /* harmony export */ getSelfInfo: function() { return /* binding */ getSelfInfo; },
509
- /* harmony export */ isModuleLoaded: function() { return /* binding */ isModuleLoaded; },
510
- /* harmony export */ isModuleSpecified: function() { return /* binding */ isModuleSpecified; },
511
- /* harmony export */ isPromiseLike: function() { return /* binding */ isPromiseLike; },
512
- /* harmony export */ onComponentMounted: function() { return /* binding */ onComponentMounted; },
513
- /* harmony export */ onError: function() { return /* binding */ onError; },
514
- /* harmony export */ parseComponentActions: function() { return /* binding */ parseComponentActions; },
515
- /* harmony export */ preloadModules: function() { return /* binding */ preloadModules; },
516
- /* harmony export */ removeLoadedModules: function() { return /* binding */ removeLoadedModules; },
517
- /* harmony export */ resetDependencyConfig: function() { return /* binding */ resetDependencyConfig; },
518
- /* harmony export */ updateMountedComponent: function() { return /* binding */ updateMountedComponent; },
519
- /* harmony export */ updateUnMountComponent: function() { return /* binding */ updateUnMountComponent; }
520
- /* harmony export */ });
521
- /* harmony import */ var _store__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./store */ "./src/core/store.ts");
522
- /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./logger */ "./src/core/logger.ts");
523
- /* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./config */ "./src/core/config.ts");
524
- /* harmony import */ var _connector__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./connector */ "./src/core/connector.ts");
525
- /* harmony import */ var _message__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./message */ "./src/core/message.ts");
526
- /* harmony import */ var _i18n__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./i18n */ "./src/core/i18n.ts");
527
-
528
-
529
-
530
-
531
-
532
-
533
- const getUrlHash = url => `${url}?${+new Date()}`;
534
- const getModuleInfo = module => {
535
- const [name, entry] = module.split('.');
536
- return {
537
- name,
538
- entry
539
- };
545
+ var { modules: moduleRegistry, urls: moduleUrls, loaded: loadedModules } = getRegistry();
546
+ function resolveUrl(url) {
547
+ if (url.startsWith("http") || url.startsWith("/") || url.startsWith("blob:")) return url;
548
+ return new URL(url, document.baseURI).href;
549
+ }
550
+ function setModuleUrl(name, url) {
551
+ moduleUrls.set(name, url);
552
+ }
553
+ function getModuleUrl(name) {
554
+ return moduleUrls.get(name);
555
+ }
556
+ async function importModule(name) {
557
+ const url = moduleUrls.get(name);
558
+ if (url) {
559
+ const absoluteUrl = resolveUrl(url);
560
+ if (loadedModules.has(absoluteUrl)) return loadedModules.get(absoluteUrl);
561
+ const mod = await __vitePreload(() => import(
562
+ /* @vite-ignore */
563
+ absoluteUrl
564
+ ), []);
565
+ loadedModules.set(absoluteUrl, mod);
566
+ return mod;
567
+ }
568
+ if (moduleRegistry.has(name)) return moduleRegistry.get(name);
569
+ throw new Error(`module "${name}" not defined`);
570
+ }
571
+ function isModuleDefined(name) {
572
+ if (moduleRegistry.has(name)) return true;
573
+ const url = moduleUrls.get(name);
574
+ if (url && loadedModules.has(resolveUrl(url))) return true;
575
+ return false;
576
+ }
577
+ function isModuleSpecified$1(name) {
578
+ return moduleUrls.has(name) || isModuleDefined(name);
579
+ }
580
+ function deleteModule(name) {
581
+ moduleRegistry.delete(name);
582
+ const url = moduleUrls.get(name);
583
+ if (url) loadedModules.delete(resolveUrl(url));
584
+ }
585
+ //#endregion
586
+ //#region src/core/helper.ts
587
+ var getUrlHash = (url) => `${url}?${+/* @__PURE__ */ new Date()}`;
588
+ var getModuleInfo = (module) => {
589
+ const [name, entry] = module.split(".");
590
+ return {
591
+ name,
592
+ entry
593
+ };
540
594
  };
541
- const preloadModules = modules => new Promise((resolve, reject) => {
542
- const names = modules.map(m => getModuleInfo(m).name);
543
- window.requirejs(names, resolve, reject);
544
- });
545
- const removeLoadedModules = modules => {
546
- modules.forEach(module => {
547
- const {
548
- name
549
- } = getModuleInfo(module);
550
- if (!_config__WEBPACK_IMPORTED_MODULE_2__.BASE_DEPENDENCIES.includes(name)) {
551
- window.requirejs.undef(name);
552
- }
553
- });
595
+ var preloadModules = (modules) => {
596
+ const names = modules.map((m) => getModuleInfo(m).name);
597
+ return Promise.all(names.map((n) => importModule(n))).then(() => void 0);
554
598
  };
555
- const defineDependencies = deps => {
556
- const dependencies = (0,_store__WEBPACK_IMPORTED_MODULE_0__.getStore)(_config__WEBPACK_IMPORTED_MODULE_2__.DEPENDENCIES_KEY);
557
- const next = {};
558
- Object.keys(deps).forEach(name => {
559
- if (!_config__WEBPACK_IMPORTED_MODULE_2__.BASE_DEPENDENCIES.includes(name)) {
560
- next[name] = `${deps[name]}#${name}`;
561
- window.requirejs.undef(name);
562
- }
563
- });
564
- window.requirejs.config({
565
- paths: next
566
- });
567
- (0,_store__WEBPACK_IMPORTED_MODULE_0__.emit)({
568
- [_config__WEBPACK_IMPORTED_MODULE_2__.DEPENDENCIES_KEY]: {
569
- ...dependencies,
570
- ...next
571
- }
572
- }, true);
599
+ var removeLoadedModules = (modules) => {
600
+ modules.forEach((module) => {
601
+ const { name } = getModuleInfo(module);
602
+ if (!BASE_DEPENDENCIES.includes(name)) deleteModule(name);
603
+ });
573
604
  };
574
- const isModuleLoaded = module => {
575
- const {
576
- name
577
- } = getModuleInfo(module);
578
- return window.requirejs.defined(name);
605
+ var defineDependencies = (deps) => {
606
+ const dependencies = getStore(DEPENDENCIES_KEY);
607
+ const next = {};
608
+ Object.keys(deps).forEach((name) => {
609
+ if (!BASE_DEPENDENCIES.includes(name)) {
610
+ next[name] = deps[name];
611
+ if (getModuleUrl(name) !== deps[name]) deleteModule(name);
612
+ setModuleUrl(name, deps[name]);
613
+ }
614
+ });
615
+ emit({ [DEPENDENCIES_KEY]: _objectSpread2(_objectSpread2({}, dependencies), next) }, true);
579
616
  };
580
- const isModuleSpecified = module => {
581
- const {
582
- name
583
- } = getModuleInfo(module);
584
- return window.requirejs.specified(name);
617
+ var isModuleLoaded = (module) => {
618
+ const { name } = getModuleInfo(module);
619
+ return isModuleDefined(name);
585
620
  };
586
- const getMountedComponents = () => (0,_store__WEBPACK_IMPORTED_MODULE_0__.getStore)(_config__WEBPACK_IMPORTED_MODULE_2__.MOUNTED_COMPONENTS_KEY);
587
- const onComponentMounted = (module, callback) => {
588
- const modules = Array.isArray(module) ? module : [module];
589
- if (modules.every(m => getMountedComponents().includes(m))) {
590
- callback();
591
- }
592
- const unSubscribe = (0,_store__WEBPACK_IMPORTED_MODULE_0__.subscribe)({
593
- [_config__WEBPACK_IMPORTED_MODULE_2__.MOUNTED_COMPONENTS_KEY](value) {
594
- if (modules.every(n => value.includes(n))) {
595
- unSubscribe();
596
- callback();
597
- }
598
- }
599
- });
600
- return unSubscribe;
621
+ var isModuleSpecified = (module) => {
622
+ const { name } = getModuleInfo(module);
623
+ return isModuleSpecified$1(name);
601
624
  };
602
- const resetDependencyConfig = (module, url) => {
603
- const {
604
- name
605
- } = getModuleInfo(module);
606
- const dependencies = (0,_store__WEBPACK_IMPORTED_MODULE_0__.getStore)(_config__WEBPACK_IMPORTED_MODULE_2__.DEPENDENCIES_KEY);
607
-
608
- // ignore multiple custom module url
609
- if (url && isModuleLoaded(name)) {
610
- return;
611
- }
612
- if (!dependencies[name] && url) {
613
- window.requirejs.config({
614
- paths: {
615
- [name]: `${url}#${name}`
616
- }
617
- });
618
- return;
619
- }
620
- let path = getUrlHash(dependencies[name]);
621
- if (url) {
622
- path = getUrlHash(`${url}#${name}`);
623
- }
624
- window.requirejs.undef(name);
625
- window.requirejs.config({
626
- paths: {
627
- [name]: path
628
- }
629
- });
625
+ var getMountedComponents = () => getStore(MOUNTED_COMPONENTS_KEY);
626
+ var onComponentMounted = (module, callback) => {
627
+ const modules = Array.isArray(module) ? module : [module];
628
+ if (modules.every((m) => getMountedComponents().includes(m))) callback();
629
+ const unSubscribe = subscribe({ [MOUNTED_COMPONENTS_KEY](value) {
630
+ if (modules.every((n) => value.includes(n))) {
631
+ unSubscribe();
632
+ callback();
633
+ }
634
+ } });
635
+ return unSubscribe;
636
+ };
637
+ var resetDependencyConfig = (module, url) => {
638
+ const { name } = getModuleInfo(module);
639
+ const dependencies = getStore(DEPENDENCIES_KEY);
640
+ if (url && isModuleDefined(name)) return;
641
+ if (!dependencies[name] && url) {
642
+ setModuleUrl(name, url);
643
+ return;
644
+ }
645
+ let moduleUrl = getUrlHash(dependencies[name]);
646
+ if (url) moduleUrl = getUrlHash(url);
647
+ deleteModule(name);
648
+ setModuleUrl(name, moduleUrl);
630
649
  };
631
650
  function getConfig() {
632
- return (0,_store__WEBPACK_IMPORTED_MODULE_0__.getStore)(_config__WEBPACK_IMPORTED_MODULE_2__.CONFIG_KEY);
651
+ return getStore(CONFIG_KEY);
633
652
  }
634
- const onError = e => {
635
- const {
636
- module,
637
- type
638
- } = e;
639
- const logger = (0,_logger__WEBPACK_IMPORTED_MODULE_1__["default"])(module);
640
- logger.error(e, type);
653
+ var onError = (e) => {
654
+ const { module, type } = e;
655
+ createLogger(module).error(e, type);
656
+ };
657
+ var VariousError = class extends Error {
658
+ constructor(data) {
659
+ super(data.originalError.message);
660
+ _defineProperty(this, "type", void 0);
661
+ _defineProperty(this, "originalError", void 0);
662
+ _defineProperty(this, "module", void 0);
663
+ this.type = data.type;
664
+ this.originalError = data.originalError;
665
+ this.module = data.module;
666
+ }
641
667
  };
642
- class VariousError extends Error {
643
- constructor(data) {
644
- super(data.originalError.message);
645
- this.type = data.type;
646
- this.originalError = data.originalError;
647
- this.module = data.module;
648
- }
649
- }
650
668
  function checkReactComponent(component, module) {
651
- return new Promise((reslove, reject) => {
652
- if (component.$$typeof || component.prototype?.isReactComponent || typeof component === 'function') {
653
- reslove();
654
- return;
655
- }
656
- reject(new VariousError({
657
- module,
658
- originalError: new Error('not a valid React component'),
659
- type: 'INVALID_COMPONENT'
660
- }));
661
- });
669
+ return new Promise((reslove, reject) => {
670
+ var _component$prototype;
671
+ if (component.$$typeof || ((_component$prototype = component.prototype) === null || _component$prototype === void 0 ? void 0 : _component$prototype.isReactComponent) || typeof component === "function") {
672
+ reslove();
673
+ return;
674
+ }
675
+ reject(new VariousError({
676
+ module,
677
+ originalError: /* @__PURE__ */ new Error("not a valid React component"),
678
+ type: "INVALID_COMPONENT"
679
+ }));
680
+ });
662
681
  }
663
682
  function isPromiseLike(value) {
664
- return value != null && typeof value.then === 'function';
683
+ return value != null && typeof value.then === "function";
665
684
  }
666
685
  function checkVueComponent(component, module) {
667
- const versionRegex = new RegExp(`^${_config__WEBPACK_IMPORTED_MODULE_2__.VUE_VERSION}\\.`);
668
- return new Promise((resolve, reject) => {
669
- window.requirejs(['vue'], Vue => {
670
- if (!versionRegex.test(Vue.version)) {
671
- reject(new Error(`Vue ${_config__WEBPACK_IMPORTED_MODULE_2__.VUE_VERSION}+ required, detected an incompatible version`));
672
- }
673
- if (typeof component?.render === 'function' || typeof component?.setup === 'function') {
674
- resolve();
675
- return;
676
- }
677
- reject(new VariousError({
678
- module,
679
- originalError: new Error('not a valid Vue component'),
680
- type: 'INVALID_COMPONENT'
681
- }));
682
- });
683
- });
686
+ const versionRegex = new RegExp(`^3\\.`);
687
+ return new Promise((resolve, reject) => {
688
+ importModule("vue").then((Vue) => {
689
+ const vueObj = Vue.default || Vue;
690
+ if (!versionRegex.test(vueObj.version)) {
691
+ reject(/* @__PURE__ */ new Error(`Vue 3+ required, detected an incompatible version`));
692
+ return;
693
+ }
694
+ if (typeof (component === null || component === void 0 ? void 0 : component.render) === "function" || typeof (component === null || component === void 0 ? void 0 : component.setup) === "function") {
695
+ resolve();
696
+ return;
697
+ }
698
+ reject(new VariousError({
699
+ module,
700
+ originalError: /* @__PURE__ */ new Error("not a valid Vue component"),
701
+ type: "INVALID_COMPONENT"
702
+ }));
703
+ }).catch(reject);
704
+ });
684
705
  }
685
706
  function parseComponentActions(params) {
686
- const {
687
- componentNode,
688
- module,
689
- type,
690
- i18nUpdate
691
- } = params;
692
- const actions = {};
693
- let onMessageAction;
694
- let i18nAction;
695
- Object.getOwnPropertyNames(componentNode).forEach(method => {
696
- if (typeof componentNode[method] !== 'function') {
697
- return;
698
- }
699
- if (method === '$onMessage') {
700
- onMessageAction = componentNode[method];
701
- return;
702
- }
703
- if (method === '$i18n') {
704
- i18nAction = componentNode[method];
705
- return;
706
- }
707
- if (type === 'vue3' && _config__WEBPACK_IMPORTED_MODULE_2__.VUE_FUNCTION_OPTIONS.includes(method)) {
708
- return;
709
- }
710
- actions[method] = componentNode[method];
711
- });
712
- if (i18nAction) {
713
- (0,_i18n__WEBPACK_IMPORTED_MODULE_5__.createI18nConfig)(i18nAction, module, i18nUpdate);
714
- }
715
- _connector__WEBPACK_IMPORTED_MODULE_3__["default"].setComponentActions(module, actions);
716
- if (onMessageAction) {
717
- return (0,_message__WEBPACK_IMPORTED_MODULE_4__.createOnMessage)(module, onMessageAction);
718
- }
719
- return () => null;
707
+ const { componentNode, module, type, i18nUpdate } = params;
708
+ const actions = {};
709
+ let onMessageAction;
710
+ let i18nAction;
711
+ Object.getOwnPropertyNames(componentNode).forEach((method) => {
712
+ if (typeof componentNode[method] !== "function") return;
713
+ if (method === "$onMessage") {
714
+ onMessageAction = componentNode[method];
715
+ return;
716
+ }
717
+ if (method === "$i18n") {
718
+ i18nAction = componentNode[method];
719
+ return;
720
+ }
721
+ if (type === "vue3" && VUE_FUNCTION_OPTIONS.includes(method)) return;
722
+ actions[method] = componentNode[method];
723
+ });
724
+ if (i18nAction) createI18nConfig(i18nAction, module, i18nUpdate);
725
+ connector_default.setComponentActions(module, actions);
726
+ if (onMessageAction) return createOnMessage(module, onMessageAction);
727
+ return () => null;
720
728
  }
721
729
  function updateMountedComponent(module) {
722
- const mountedComponents = getMountedComponents();
723
- if (!mountedComponents.includes(module)) {
724
- mountedComponents.push(module);
725
- }
726
- (0,_store__WEBPACK_IMPORTED_MODULE_0__.emit)({
727
- [_config__WEBPACK_IMPORTED_MODULE_2__.MOUNTED_COMPONENTS_KEY]: mountedComponents
728
- }, true);
730
+ const mountedComponents = getMountedComponents();
731
+ if (!mountedComponents.includes(module)) mountedComponents.push(module);
732
+ emit({ [MOUNTED_COMPONENTS_KEY]: mountedComponents }, true);
729
733
  }
730
734
  function updateUnMountComponent(module) {
731
- let mountedComponents = getMountedComponents();
732
- mountedComponents = mountedComponents.filter(item => item !== module);
733
- (0,_store__WEBPACK_IMPORTED_MODULE_0__.emit)({
734
- [_config__WEBPACK_IMPORTED_MODULE_2__.MOUNTED_COMPONENTS_KEY]: mountedComponents
735
- }, true);
736
- _connector__WEBPACK_IMPORTED_MODULE_3__["default"].deleteComponentActions(module);
735
+ let mountedComponents = getMountedComponents();
736
+ mountedComponents = mountedComponents.filter((item) => item !== module);
737
+ emit({ [MOUNTED_COMPONENTS_KEY]: mountedComponents }, true);
738
+ connector_default.deleteComponentActions(module);
737
739
  }
738
740
  function getSelfInfo(params) {
739
- const {
740
- module,
741
- url
742
- } = params;
743
- const dependencies = (0,_store__WEBPACK_IMPORTED_MODULE_0__.getStore)(_config__WEBPACK_IMPORTED_MODULE_2__.DEPENDENCIES_KEY);
744
- const {
745
- name
746
- } = getModuleInfo(module);
747
- return {
748
- module,
749
- url: url || dependencies[name]
750
- };
741
+ const { module, url } = params;
742
+ const dependencies = getStore(DEPENDENCIES_KEY);
743
+ const { name } = getModuleInfo(module);
744
+ return {
745
+ module,
746
+ url: url || dependencies[name] || getModuleUrl(name) || ""
747
+ };
751
748
  }
752
749
  function getClassNameWithModule(module, prefix) {
753
- const {
754
- name,
755
- entry
756
- } = getModuleInfo(module);
757
- return `${prefix} ${[name, entry].filter(Boolean).join('-')}`;
750
+ const { name, entry } = getModuleInfo(module);
751
+ return `${prefix} ${[name, entry].filter(Boolean).join("-")}`;
758
752
  }
759
-
760
- /***/ }),
761
-
762
- /***/ "./src/core/i18n.ts":
763
- /*!**************************!*\
764
- !*** ./src/core/i18n.ts ***!
765
- \**************************/
766
- /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
767
-
768
- "use strict";
769
- __webpack_require__.r(__webpack_exports__);
770
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
771
- /* harmony export */ createI18n: function() { return /* binding */ createI18n; },
772
- /* harmony export */ createI18nConfig: function() { return /* binding */ createI18nConfig; }
773
- /* harmony export */ });
774
- /* harmony import */ var _connector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./connector */ "./src/core/connector.ts");
775
- /* harmony import */ var _helper__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./helper */ "./src/core/helper.ts");
776
- /* harmony import */ var _store__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./store */ "./src/core/store.ts");
777
-
778
-
779
-
780
- function createI18nConfig(method, module, callback) {
781
- if (!method) {
782
- return;
783
- }
784
- const i18nConfig = method();
785
- if (!(0,_helper__WEBPACK_IMPORTED_MODULE_1__.isPromiseLike)(i18nConfig)) {
786
- if (module) {
787
- _connector__WEBPACK_IMPORTED_MODULE_0__["default"].setI18nConfig(module, i18nConfig);
788
- } else {
789
- _connector__WEBPACK_IMPORTED_MODULE_0__["default"].setGlobalI18nConfig(i18nConfig);
790
- }
791
- return;
792
- }
793
- if (module) {
794
- _connector__WEBPACK_IMPORTED_MODULE_0__["default"].setI18nConfig(module, {
795
- loading: true,
796
- lngStoreKey: '',
797
- resources: {}
798
- });
799
- } else {
800
- _connector__WEBPACK_IMPORTED_MODULE_0__["default"].setGlobalI18nConfig({
801
- loading: true,
802
- lngStoreKey: '',
803
- resources: {}
804
- });
805
- }
806
- i18nConfig.then(res => {
807
- if (module) {
808
- _connector__WEBPACK_IMPORTED_MODULE_0__["default"].setI18nConfig(module, {
809
- ...res,
810
- loading: false
811
- });
812
- callback?.();
813
- return;
814
- }
815
- const locale = (0,_store__WEBPACK_IMPORTED_MODULE_2__.getStore)(res.lngStoreKey);
816
- (0,_store__WEBPACK_IMPORTED_MODULE_2__.emit)({
817
- [res.lngStoreKey]: undefined
818
- }, true);
819
- (0,_store__WEBPACK_IMPORTED_MODULE_2__.emit)({
820
- [res.lngStoreKey]: locale
821
- }, true);
822
- _connector__WEBPACK_IMPORTED_MODULE_0__["default"].setGlobalI18nConfig({
823
- ...res,
824
- loading: false
825
- });
826
- }).catch(e => {
827
- (0,_helper__WEBPACK_IMPORTED_MODULE_1__.onError)(new _helper__WEBPACK_IMPORTED_MODULE_1__.VariousError({
828
- module: module || 'app',
829
- type: 'I18N',
830
- originalError: e
831
- }));
832
- });
753
+ //#endregion
754
+ //#region src/core/default-component.tsx
755
+ var Fallback = (props) => {
756
+ const className = getClassNameWithModule(props.$self.module, "various-component-fallback");
757
+ return /* @__PURE__ */ e.createElement("div", { className }, "Loading");
758
+ };
759
+ var ErrorFallback = ({ $error, $reload, $self }) => {
760
+ const className = getClassNameWithModule($self.module, "various-component-error_fallback");
761
+ return /* @__PURE__ */ e.createElement("div", { className }, /* @__PURE__ */ e.createElement("h3", null, $error.type), /* @__PURE__ */ e.createElement("p", null, $error.message), /* @__PURE__ */ e.createElement("button", {
762
+ type: "button",
763
+ onClick: $reload
764
+ }, "Reload"));
765
+ };
766
+ var Root = () => /* @__PURE__ */ e.createElement("div", null, "App Container is not defined");
767
+ //#endregion
768
+ //#region src/core/connector.ts
769
+ var Connector = class {
770
+ constructor() {
771
+ _defineProperty(this, "fallbackComponent", void 0);
772
+ _defineProperty(this, "errorFallbackComponent", void 0);
773
+ _defineProperty(this, "storeActions", void 0);
774
+ _defineProperty(this, "componentActions", void 0);
775
+ _defineProperty(this, "i18nConfigs", void 0);
776
+ _defineProperty(this, "globalI18nConfig", void 0);
777
+ _defineProperty(this, "middlewares", void 0);
778
+ this.fallbackComponent = Fallback;
779
+ this.errorFallbackComponent = ErrorFallback;
780
+ this.storeActions = {};
781
+ this.componentActions = {};
782
+ this.i18nConfigs = {};
783
+ this.middlewares = {};
784
+ }
785
+ setMiddlewares(m) {
786
+ this.middlewares = m;
787
+ }
788
+ getMiddlewares() {
789
+ return this.middlewares;
790
+ }
791
+ setI18nConfig(module, config) {
792
+ this.i18nConfigs[module] = _objectSpread2(_objectSpread2({}, this.i18nConfigs[module]), config);
793
+ }
794
+ getI18nConfig(module) {
795
+ return this.i18nConfigs[module];
796
+ }
797
+ setGlobalI18nConfig(config) {
798
+ this.globalI18nConfig = _objectSpread2(_objectSpread2({}, this.globalI18nConfig), config);
799
+ }
800
+ getGlobalI18nConfig() {
801
+ return this.globalI18nConfig;
802
+ }
803
+ setComponentActions(module, actions) {
804
+ this.componentActions[module] = actions;
805
+ }
806
+ deleteComponentActions(module) {
807
+ delete this.componentActions[module];
808
+ }
809
+ getComponentActions(module) {
810
+ return this.componentActions[module];
811
+ }
812
+ setStoreActions(actions) {
813
+ this.storeActions = actions;
814
+ }
815
+ getStoreActions() {
816
+ return this.storeActions;
817
+ }
818
+ setFallbackComponent(fallbackComponent) {
819
+ this.fallbackComponent = fallbackComponent;
820
+ }
821
+ getFallbackComponent() {
822
+ return this.fallbackComponent;
823
+ }
824
+ setErrorFallbackComponent(errorFallbackComponent) {
825
+ this.errorFallbackComponent = errorFallbackComponent;
826
+ }
827
+ getErrorFallbackComponent() {
828
+ return this.errorFallbackComponent;
829
+ }
830
+ };
831
+ var connector_default = new Connector();
832
+ //#endregion
833
+ //#region src/core/error-boundary.tsx
834
+ var ErrorBoundary = class extends Component {
835
+ constructor(..._args) {
836
+ super(..._args);
837
+ _defineProperty(this, "state", { hasError: false });
838
+ _defineProperty(this, "error", void 0);
839
+ _defineProperty(this, "$self", getSelfInfo(this.props));
840
+ _defineProperty(this, "reload", () => {
841
+ this.error = void 0;
842
+ this.setState({ hasError: false });
843
+ });
844
+ }
845
+ componentDidCatch(e) {
846
+ const { module } = this.props;
847
+ const error = e instanceof VariousError ? e : new VariousError({
848
+ module,
849
+ type: module === "app" ? "APP_ERROR" : "SCRIPT_ERROR",
850
+ originalError: e
851
+ });
852
+ this.setState({ hasError: true });
853
+ this.error = error;
854
+ onError(error);
855
+ resetDependencyConfig(module);
856
+ updateUnMountComponent(module);
857
+ }
858
+ render() {
859
+ const ErrorFallbackNode = connector_default.getErrorFallbackComponent();
860
+ const store = getUserStore();
861
+ const locale = getStore(LOCALE_KEY);
862
+ if (this.state.hasError) return /* @__PURE__ */ e.createElement(ErrorFallbackNode, {
863
+ $self: this.$self,
864
+ $reload: this.reload,
865
+ $store: store,
866
+ $error: this.error,
867
+ $locale: locale
868
+ });
869
+ return this.props.children;
870
+ }
871
+ };
872
+ _defineProperty(ErrorBoundary, "displayName", "various-error-boundary");
873
+ //#endregion
874
+ //#region \0@oxc-project+runtime@0.142.0/helpers/esm/objectWithoutPropertiesLoose.js
875
+ function _objectWithoutPropertiesLoose(r, e) {
876
+ if (null == r) return {};
877
+ var t = {};
878
+ for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
879
+ if (e.includes(n)) continue;
880
+ t[n] = r[n];
881
+ }
882
+ return t;
833
883
  }
834
- function createI18n(module, updater) {
835
- const ctx = (key, params, defaultString) => {
836
- const i18nConfig = _connector__WEBPACK_IMPORTED_MODULE_0__["default"].getI18nConfig(module) || _connector__WEBPACK_IMPORTED_MODULE_0__["default"].getGlobalI18nConfig();
837
- let defaultText = defaultString;
838
- if (defaultText === undefined) {
839
- defaultText = typeof params === 'string' ? params : key;
840
- }
841
- if (!i18nConfig) {
842
- (0,_helper__WEBPACK_IMPORTED_MODULE_1__.onError)(new _helper__WEBPACK_IMPORTED_MODULE_1__.VariousError({
843
- module,
844
- type: 'I18N',
845
- originalError: new Error('config not exist')
846
- }));
847
- return defaultText;
848
- }
849
- if (i18nConfig.loading) {
850
- return defaultText;
851
- }
852
- const {
853
- lngStoreKey,
854
- resources
855
- } = i18nConfig;
856
- const locale = (0,_store__WEBPACK_IMPORTED_MODULE_2__.getStore)(lngStoreKey);
857
- if (lngStoreKey === undefined || locale === undefined) {
858
- (0,_helper__WEBPACK_IMPORTED_MODULE_1__.onError)(new _helper__WEBPACK_IMPORTED_MODULE_1__.VariousError({
859
- module,
860
- type: 'I18N',
861
- originalError: new Error('locale key not defined')
862
- }));
863
- return defaultText;
864
- }
865
- const resource = resources?.[locale];
866
- if (!resource) {
867
- (0,_helper__WEBPACK_IMPORTED_MODULE_1__.onError)(new _helper__WEBPACK_IMPORTED_MODULE_1__.VariousError({
868
- module,
869
- type: 'I18N',
870
- originalError: new Error(`locale resource \`${locale}\` not exist`)
871
- }));
872
- return defaultText;
873
- }
874
- if (!resource[key]) {
875
- (0,_helper__WEBPACK_IMPORTED_MODULE_1__.onError)(new _helper__WEBPACK_IMPORTED_MODULE_1__.VariousError({
876
- module,
877
- type: 'I18N',
878
- originalError: new Error(`locale key \`${key}\` not exist`)
879
- }));
880
- return defaultText;
881
- }
882
- const text = resource[key];
883
- if (!params || typeof params === 'string' || Object.prototype.toString.call(params) !== '[object Object]') {
884
- return text;
885
- }
886
- const args = Object.keys(params);
887
- if (!args.length) {
888
- return text;
889
- }
890
- return args.reduce((next, arg) => {
891
- const regex = new RegExp(`{\\s*${arg}\\s*}`, 'g');
892
- return next.replace(regex, params[arg].toString());
893
- }, text);
894
- };
895
- ctx.update = (config, type) => {
896
- const i18nConfig = type === 'app' ? _connector__WEBPACK_IMPORTED_MODULE_0__["default"].getGlobalI18nConfig() : _connector__WEBPACK_IMPORTED_MODULE_0__["default"].getI18nConfig(module);
897
- const next = {
898
- ...i18nConfig,
899
- ...config
900
- };
901
- if (type === 'app') {
902
- _connector__WEBPACK_IMPORTED_MODULE_0__["default"].setGlobalI18nConfig(next);
903
- } else {
904
- _connector__WEBPACK_IMPORTED_MODULE_0__["default"].setI18nConfig(module, next);
905
- }
906
- updater();
907
- };
908
- return ctx;
884
+ //#endregion
885
+ //#region \0@oxc-project+runtime@0.142.0/helpers/esm/objectWithoutProperties.js
886
+ function _objectWithoutProperties(e, t) {
887
+ if (null == e) return {};
888
+ var o, r, i = _objectWithoutPropertiesLoose(e, t);
889
+ if (Object.getOwnPropertySymbols) {
890
+ var s = Object.getOwnPropertySymbols(e);
891
+ for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
892
+ }
893
+ return i;
909
894
  }
910
-
911
- /***/ }),
912
-
913
- /***/ "./src/core/logger.ts":
914
- /*!****************************!*\
915
- !*** ./src/core/logger.ts ***!
916
- \****************************/
917
- /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
918
-
919
- "use strict";
920
- __webpack_require__.r(__webpack_exports__);
921
- /* harmony import */ var _connector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./connector */ "./src/core/connector.ts");
922
- /* harmony import */ var _helper__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./helper */ "./src/core/helper.ts");
923
-
924
-
925
- const logger = args => {
926
- const middlewares = _connector__WEBPACK_IMPORTED_MODULE_0__["default"].getMiddlewares();
927
- const canLog = middlewares?.onLog?.(args);
928
- if (canLog === false) {
929
- return;
930
- }
931
- const colorMap = {
932
- info: 'blue',
933
- warn: 'orange',
934
- error: 'red'
935
- };
936
- const color = colorMap[args.level];
937
- const params = [`%c ${args.module} `, `background:${color};border:1px solid ${color};padding:1px;border-radius:2px 0 0 2px;color: #fff;`];
938
- if (args.type) {
939
- params[0] = `${params[0]}%c ${args.type} %c`;
940
- params.push(`border:1px solid ${color};padding:1px;border-radius:0 2px 2px 0;color:${color};`, 'background:transparent');
941
- }
942
- if (args.level !== 'info') {
943
- params[0] = ` ${params[0]}`;
944
- }
945
- window.console[args.level](...params, args.message);
895
+ //#endregion
896
+ //#region src/core/dispatch.ts
897
+ var createDispatch = (module) => async function(params) {
898
+ const middlewares = connector_default.getMiddlewares();
899
+ const logger = createLogger(module);
900
+ let { action, payload, target } = params;
901
+ if (middlewares === null || middlewares === void 0 ? void 0 : middlewares.onDispatch) {
902
+ const check = await middlewares.onDispatch({
903
+ target,
904
+ action,
905
+ payload,
906
+ trigger: module
907
+ });
908
+ if (check === false) {
909
+ logger.warn("blocked by middleware", "DISPATCH");
910
+ return Promise.resolve();
911
+ }
912
+ if (check !== true) {
913
+ target = check.target;
914
+ action = check.action;
915
+ payload = check.payload;
916
+ }
917
+ }
918
+ if (target === "app") {
919
+ const storeAction = connector_default.getStoreActions()[action];
920
+ if (action === I18NActions.SetLocale) {
921
+ emit({ [LOCALE_KEY]: payload }, true);
922
+ return payload;
923
+ }
924
+ if (action === I18NActions.GetLocale) return getStore(LOCALE_KEY);
925
+ if (action === I18NActions.UpdateI18nConfig) {
926
+ const locale = getStore(LOCALE_KEY);
927
+ connector_default.setGlobalI18nConfig(payload);
928
+ emit({ [LOCALE_KEY]: void 0 }, true);
929
+ emit({ [LOCALE_KEY]: locale }, true);
930
+ return locale;
931
+ }
932
+ if (!storeAction) {
933
+ const errorMessage = `action "${action}" is not present`;
934
+ const error = new VariousError({
935
+ module,
936
+ type: "DISPATCH",
937
+ originalError: new Error(errorMessage)
938
+ });
939
+ onError(error);
940
+ throw error;
941
+ }
942
+ return dispatch(storeAction, payload, module);
943
+ }
944
+ const componentActions = connector_default.getComponentActions(target);
945
+ if (!componentActions) {
946
+ const error = new VariousError({
947
+ module,
948
+ type: "DISPATCH",
949
+ originalError: /* @__PURE__ */ new Error("component is not ready")
950
+ });
951
+ onError(error);
952
+ throw error;
953
+ }
954
+ const componentAction = componentActions[action];
955
+ if (!componentAction) {
956
+ const errorMessage = `action "${action}" is not present`;
957
+ const error = new VariousError({
958
+ module,
959
+ type: "DISPATCH",
960
+ originalError: new Error(errorMessage)
961
+ });
962
+ onError(error);
963
+ throw error;
964
+ }
965
+ return Promise.resolve(componentAction({
966
+ payload,
967
+ trigger: module
968
+ }));
946
969
  };
947
- const createLogger = module => ({
948
- info(message, type) {
949
- logger({
950
- module,
951
- level: 'info',
952
- type,
953
- message
954
- });
955
- },
956
- warn(message, type) {
957
- logger({
958
- module,
959
- level: 'warn',
960
- type,
961
- message
962
- });
963
- },
964
- error(message, type) {
965
- const middlewares = _connector__WEBPACK_IMPORTED_MODULE_0__["default"].getMiddlewares();
966
- const error = message instanceof _helper__WEBPACK_IMPORTED_MODULE_1__.VariousError ? message : new _helper__WEBPACK_IMPORTED_MODULE_1__.VariousError({
967
- module,
968
- type: type || 'unknow',
969
- originalError: message instanceof Error ? message : new Error(message)
970
- });
971
- middlewares?.onError?.(error);
972
- logger({
973
- module,
974
- level: 'error',
975
- type,
976
- message
977
- });
978
- }
979
- });
980
- /* harmony default export */ __webpack_exports__["default"] = (createLogger);
981
-
982
- /***/ }),
983
-
984
- /***/ "./src/core/message.ts":
985
- /*!*****************************!*\
986
- !*** ./src/core/message.ts ***!
987
- \*****************************/
988
- /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
989
-
990
- "use strict";
991
- __webpack_require__.r(__webpack_exports__);
992
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
993
- /* harmony export */ createOnMessage: function() { return /* binding */ createOnMessage; },
994
- /* harmony export */ createPostMessage: function() { return /* binding */ createPostMessage; }
995
- /* harmony export */ });
996
- /* harmony import */ var _connector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./connector */ "./src/core/connector.ts");
997
- /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./logger */ "./src/core/logger.ts");
998
- /* harmony import */ var _store__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./store */ "./src/core/store.ts");
999
- /* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./config */ "./src/core/config.ts");
1000
-
1001
-
1002
-
1003
-
1004
- const createPostMessage = module => async ({
1005
- event,
1006
- payload
1007
- }) => {
1008
- const middlewares = _connector__WEBPACK_IMPORTED_MODULE_0__["default"].getMiddlewares();
1009
- const logger = (0,_logger__WEBPACK_IMPORTED_MODULE_1__["default"])(module);
1010
- let next = {
1011
- trigger: module,
1012
- event,
1013
- payload
1014
- };
1015
- if (middlewares?.onMessage) {
1016
- const check = await middlewares.onMessage(next);
1017
- if (check === false) {
1018
- logger.warn('blocked by middleware', 'POST_MESSAGE');
1019
- return;
1020
- }
1021
- if (check !== true) {
1022
- next = {
1023
- ...next,
1024
- ...check
1025
- };
1026
- }
1027
- }
1028
- (0,_store__WEBPACK_IMPORTED_MODULE_2__.emit)({
1029
- [_config__WEBPACK_IMPORTED_MODULE_3__.MESSAGE_KEY]: {
1030
- timestamp: +new Date(),
1031
- event: next.event,
1032
- trigger: module,
1033
- payload: next.payload
1034
- }
1035
- });
970
+ //#endregion
971
+ //#region src/core/create-module.ts
972
+ var createModule = (config, logError = true) => {
973
+ const dependencies = getStore(DEPENDENCIES_KEY);
974
+ const middlewares = connector_default.getMiddlewares();
975
+ const { url, module } = config;
976
+ const { name, entry } = getModuleInfo(module);
977
+ const loadStart = +/* @__PURE__ */ new Date();
978
+ const logOnError = (e) => {
979
+ if (logError) onError(e);
980
+ };
981
+ if (url) resetDependencyConfig(module, url);
982
+ return new Promise((resolve, reject) => {
983
+ if (!url && !dependencies[name] && !isModuleSpecified(module)) {
984
+ const error = new VariousError({
985
+ module,
986
+ type: "NOT_DEFINED",
987
+ originalError: /* @__PURE__ */ new Error(`module "${name}" not defined`)
988
+ });
989
+ logOnError(error);
990
+ reject(error);
991
+ return;
992
+ }
993
+ importModule(name).then((C) => {
994
+ var _middlewares$onLoad;
995
+ const loadEnd = +/* @__PURE__ */ new Date();
996
+ middlewares === null || middlewares === void 0 || (_middlewares$onLoad = middlewares.onLoad) === null || _middlewares$onLoad === void 0 || _middlewares$onLoad.call(middlewares, {
997
+ module,
998
+ loadStart,
999
+ loadEnd,
1000
+ beenLoaded: isModuleLoaded(module)
1001
+ });
1002
+ if (!C || typeof C === "object" && Object.keys(C).length === 0) {
1003
+ const error = new VariousError({
1004
+ module,
1005
+ type: "INVALID_MODULE",
1006
+ originalError: /* @__PURE__ */ new Error(`module "${name}" invalid`)
1007
+ });
1008
+ resetDependencyConfig(module);
1009
+ logOnError(error);
1010
+ reject(error);
1011
+ return;
1012
+ }
1013
+ const defaultModule = "default" in C ? C.default : C;
1014
+ const actualModule = !entry ? defaultModule : C[entry];
1015
+ if (actualModule === void 0 && entry) {
1016
+ const error = new VariousError({
1017
+ module,
1018
+ type: "SUBMODULE_NOT_DEFINED",
1019
+ originalError: /* @__PURE__ */ new Error(`submodule "${entry}" not defined`)
1020
+ });
1021
+ resetDependencyConfig(module);
1022
+ logOnError(error);
1023
+ reject(error);
1024
+ return;
1025
+ }
1026
+ resolve(actualModule);
1027
+ }).catch((e) => {
1028
+ resetDependencyConfig(module, url);
1029
+ let errorType = "LOADING_ERROR";
1030
+ if (!url && e.message && !e.message.includes(name)) errorType = "SUBMODULE_LOADING_ERROR";
1031
+ const error = new VariousError({
1032
+ module: name,
1033
+ type: errorType,
1034
+ originalError: e
1035
+ });
1036
+ logOnError(error);
1037
+ reject(error);
1038
+ });
1039
+ });
1036
1040
  };
1037
- const createOnMessage = (module, onMessage) => (0,_store__WEBPACK_IMPORTED_MODULE_2__.subscribe)({
1038
- [_config__WEBPACK_IMPORTED_MODULE_3__.MESSAGE_KEY](v) {
1039
- const {
1040
- trigger,
1041
- payload,
1042
- event
1043
- } = v;
1044
- if (module !== trigger) {
1045
- onMessage({
1046
- event,
1047
- payload,
1048
- trigger
1049
- });
1050
- }
1051
- }
1052
- });
1053
-
1054
- /***/ }),
1055
-
1056
- /***/ "./src/core/react-component.tsx":
1057
- /*!**************************************!*\
1058
- !*** ./src/core/react-component.tsx ***!
1059
- \**************************************/
1060
- /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
1061
-
1062
- "use strict";
1063
- __webpack_require__.r(__webpack_exports__);
1064
- /* 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");
1065
- /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ "react");
1066
- /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
1067
- /* harmony import */ var _helper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./helper */ "./src/core/helper.ts");
1068
- /* harmony import */ var _store__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./store */ "./src/core/store.ts");
1069
- /* harmony import */ var _connector__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./connector */ "./src/core/connector.ts");
1070
- /* harmony import */ var _message__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./message */ "./src/core/message.ts");
1071
- /* harmony import */ var _dispatch__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./dispatch */ "./src/core/dispatch.ts");
1072
- /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./logger */ "./src/core/logger.ts");
1073
- /* harmony import */ var _i18n__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./i18n */ "./src/core/i18n.ts");
1074
- /* harmony import */ var _create_module__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./create-module */ "./src/core/create-module.ts");
1075
-
1076
-
1077
-
1078
-
1079
-
1080
-
1081
-
1082
-
1083
-
1084
-
1041
+ //#endregion
1042
+ //#region src/core/react-component.tsx
1085
1043
  function reactComponent(config) {
1086
- const {
1087
- module,
1088
- url,
1089
- watchKeys,
1090
- onMounted
1091
- } = config;
1092
- const storeKeys = watchKeys || Object.keys((0,_store__WEBPACK_IMPORTED_MODULE_3__.getStore)());
1093
- class R extends react__WEBPACK_IMPORTED_MODULE_1__.Component {
1094
- static displayName = 'various-react-component';
1095
- state = {
1096
- componentReady: false,
1097
- isError: false
1098
- };
1099
- unSubscribeMessage = () => null;
1100
- componentDidMount() {
1101
- this.isUnMounted = false; // fix StrictMode
1102
- this.mountComponent();
1103
- }
1104
- componentWillUnmount() {
1105
- this.error = undefined;
1106
- this.ComponentNode = null;
1107
- this.isUnMounted = true;
1108
- this.unSubscribeMessage();
1109
- (0,_helper__WEBPACK_IMPORTED_MODULE_2__.updateUnMountComponent)(module);
1110
- }
1111
- mountComponent = async () => {
1112
- try {
1113
- const componentNode = await (0,_create_module__WEBPACK_IMPORTED_MODULE_9__["default"])({
1114
- module,
1115
- url
1116
- }, false);
1117
- if (this.isUnMounted) {
1118
- return;
1119
- }
1120
- await (0,_helper__WEBPACK_IMPORTED_MODULE_2__.checkReactComponent)(componentNode, module);
1121
- componentNode.displayName = module;
1122
- (0,_helper__WEBPACK_IMPORTED_MODULE_2__.updateMountedComponent)(module);
1123
- this.unSubscribeMessage = (0,_helper__WEBPACK_IMPORTED_MODULE_2__.parseComponentActions)({
1124
- componentNode,
1125
- module,
1126
- i18nUpdate: () => this.forceUpdate()
1127
- });
1128
- this.ComponentNode = componentNode;
1129
- this.setState({
1130
- componentReady: true
1131
- });
1132
- onMounted?.();
1133
- } catch (e) {
1134
- if (this.isUnMounted) {
1135
- return;
1136
- }
1137
- this.error = e;
1138
- this.setState({
1139
- componentReady: true,
1140
- isError: true
1141
- });
1142
- }
1143
- };
1144
- $postMessage = (0,_message__WEBPACK_IMPORTED_MODULE_5__.createPostMessage)(module);
1145
- $dispatch = (0,_dispatch__WEBPACK_IMPORTED_MODULE_6__["default"])(module);
1146
- $t = (0,_i18n__WEBPACK_IMPORTED_MODULE_8__.createI18n)(module, () => this.forceUpdate());
1147
- $logger = (0,_logger__WEBPACK_IMPORTED_MODULE_7__["default"])(module);
1148
- $self = (0,_helper__WEBPACK_IMPORTED_MODULE_2__.getSelfInfo)({
1149
- module,
1150
- url
1151
- });
1152
- render() {
1153
- const Fallback = _connector__WEBPACK_IMPORTED_MODULE_4__["default"].getFallbackComponent();
1154
- const {
1155
- $silent,
1156
- $componentProps,
1157
- $ref
1158
- } = this.props;
1159
- const {
1160
- componentReady,
1161
- isError
1162
- } = this.state;
1163
- const store = (0,_store__WEBPACK_IMPORTED_MODULE_3__.getUserStore)();
1164
- const ComponentNode = this.ComponentNode;
1165
- if (isError) {
1166
- throw this.error;
1167
- }
1168
- if (!componentReady) {
1169
- if ($silent || (0,_helper__WEBPACK_IMPORTED_MODULE_2__.isModuleLoaded)(module)) {
1170
- return null;
1171
- }
1172
- return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(Fallback, {
1173
- $self: this.$self,
1174
- $store: store
1175
- });
1176
- }
1177
- return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(ComponentNode, (0,_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__["default"])({}, $componentProps, {
1178
- $self: this.$self,
1179
- $dispatch: this.$dispatch,
1180
- $store: store,
1181
- $postMessage: this.$postMessage,
1182
- $t: this.$t,
1183
- $logger: this.$logger,
1184
- ref: $ref
1185
- }));
1186
- }
1187
- }
1188
- const Connected = (0,_store__WEBPACK_IMPORTED_MODULE_3__.connect)(...storeKeys)(R);
1189
- Connected.displayName = 'various-connector';
1190
- return Connected;
1191
- }
1192
- /* harmony default export */ __webpack_exports__["default"] = (reactComponent);
1193
-
1194
- /***/ }),
1195
-
1196
- /***/ "./src/core/render-component.tsx":
1197
- /*!***************************************!*\
1198
- !*** ./src/core/render-component.tsx ***!
1199
- \***************************************/
1200
- /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
1201
-
1202
- "use strict";
1203
- __webpack_require__.r(__webpack_exports__);
1204
- /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
1205
- /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
1206
- /* harmony import */ var _react_component__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./react-component */ "./src/core/react-component.tsx");
1207
- /* harmony import */ var _vue_component__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./vue-component */ "./src/core/vue-component.tsx");
1208
- /* harmony import */ var _helper__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./helper */ "./src/core/helper.ts");
1209
- /* harmony import */ var _error_boundary__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./error-boundary */ "./src/core/error-boundary.tsx");
1210
- /* harmony import */ var _create_module__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./create-module */ "./src/core/create-module.ts");
1211
-
1212
-
1213
-
1214
-
1215
-
1216
-
1217
- const renderComponent = async ({
1218
- module,
1219
- url,
1220
- target,
1221
- props,
1222
- type = 'react',
1223
- renderNode,
1224
- onMounted
1225
- }) => {
1226
- try {
1227
- const ReactDOM = await (0,_create_module__WEBPACK_IMPORTED_MODULE_5__["default"])({
1228
- module: 'react-dom'
1229
- });
1230
- const C = (type === 'vue3' ? _vue_component__WEBPACK_IMPORTED_MODULE_2__["default"] : _react_component__WEBPACK_IMPORTED_MODULE_1__["default"])({
1231
- module,
1232
- url,
1233
- onMounted
1234
- });
1235
- const root = ReactDOM.createRoot(target);
1236
- const {
1237
- $silent,
1238
- $ref,
1239
- ...rest
1240
- } = props || {};
1241
- const nextProps = {
1242
- $componentProps: rest,
1243
- $silent,
1244
- $ref
1245
- };
1246
- const node = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_error_boundary__WEBPACK_IMPORTED_MODULE_4__["default"], {
1247
- module: module,
1248
- url: url
1249
- }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(C, nextProps));
1250
- root.render(renderNode ? renderNode(node) : node);
1251
- return () => new Promise(resolve => {
1252
- setTimeout(() => {
1253
- root.unmount();
1254
- resolve();
1255
- });
1256
- });
1257
- } catch (e) {
1258
- const error = new _helper__WEBPACK_IMPORTED_MODULE_3__.VariousError({
1259
- module,
1260
- type: 'SCRIPT_ERROR',
1261
- originalError: e
1262
- });
1263
- (0,_helper__WEBPACK_IMPORTED_MODULE_3__.onError)(error);
1264
- return () => Promise.resolve();
1265
- }
1266
- };
1267
- /* harmony default export */ __webpack_exports__["default"] = (renderComponent);
1268
-
1269
- /***/ }),
1270
-
1271
- /***/ "./src/core/store.ts":
1272
- /*!***************************!*\
1273
- !*** ./src/core/store.ts ***!
1274
- \***************************/
1275
- /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
1276
-
1277
- "use strict";
1278
- __webpack_require__.r(__webpack_exports__);
1279
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1280
- /* harmony export */ connect: function() { return /* binding */ connect; },
1281
- /* harmony export */ createStore: function() { return /* binding */ createStore; },
1282
- /* harmony export */ dispatch: function() { return /* binding */ dispatch; },
1283
- /* harmony export */ emit: function() { return /* binding */ emit; },
1284
- /* harmony export */ getStore: function() { return /* binding */ getStore; },
1285
- /* harmony export */ getUserStore: function() { return /* binding */ getUserStore; },
1286
- /* harmony export */ subscribe: function() { return /* binding */ subscribe; },
1287
- /* harmony export */ useStore: function() { return /* binding */ useStore; }
1288
- /* harmony export */ });
1289
- /* harmony import */ var nycticorax__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! nycticorax */ "./node_modules/nycticorax/dist/index.js");
1290
- /* harmony import */ var nycticorax__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(nycticorax__WEBPACK_IMPORTED_MODULE_0__);
1291
-
1292
- const {
1293
- createStore,
1294
- getStore,
1295
- connect,
1296
- emit,
1297
- subscribe,
1298
- dispatch,
1299
- useStore
1300
- } = new (nycticorax__WEBPACK_IMPORTED_MODULE_0___default())();
1301
- function getUserStore() {
1302
- const globalStore = getStore();
1303
- const keys = Object.keys(globalStore);
1304
- const store = {};
1305
- keys.forEach(key => {
1306
- store[key] = globalStore[key];
1307
- });
1308
- return store;
1044
+ const { module, url, watchKeys, onMounted } = config;
1045
+ const storeKeys = watchKeys || Object.keys(getStore());
1046
+ class R extends Component {
1047
+ constructor(..._args) {
1048
+ var _this;
1049
+ super(..._args);
1050
+ _this = this;
1051
+ _defineProperty(this, "state", {
1052
+ componentReady: false,
1053
+ isError: false
1054
+ });
1055
+ _defineProperty(this, "error", void 0);
1056
+ _defineProperty(this, "ComponentNode", void 0);
1057
+ _defineProperty(this, "isUnMounted", void 0);
1058
+ _defineProperty(this, "unSubscribeMessage", () => null);
1059
+ _defineProperty(this, "mountComponent", async () => {
1060
+ try {
1061
+ const componentNode = await createModule({
1062
+ module,
1063
+ url
1064
+ }, false);
1065
+ if (_this.isUnMounted) return;
1066
+ await checkReactComponent(componentNode, module);
1067
+ componentNode.displayName = module;
1068
+ updateMountedComponent(module);
1069
+ _this.unSubscribeMessage = parseComponentActions({
1070
+ componentNode,
1071
+ module,
1072
+ i18nUpdate: () => _this.forceUpdate()
1073
+ });
1074
+ _this.ComponentNode = componentNode;
1075
+ _this.setState({ componentReady: true });
1076
+ onMounted === null || onMounted === void 0 || onMounted();
1077
+ } catch (e) {
1078
+ if (_this.isUnMounted) return;
1079
+ _this.error = e;
1080
+ _this.setState({
1081
+ componentReady: true,
1082
+ isError: true
1083
+ });
1084
+ }
1085
+ });
1086
+ _defineProperty(this, "$postMessage", createPostMessage(module));
1087
+ _defineProperty(this, "$dispatch", createDispatch(module));
1088
+ _defineProperty(this, "$t", createI18n(module, () => this.forceUpdate()));
1089
+ _defineProperty(this, "$logger", createLogger(module));
1090
+ _defineProperty(this, "$self", getSelfInfo({
1091
+ module,
1092
+ url
1093
+ }));
1094
+ }
1095
+ componentDidMount() {
1096
+ this.isUnMounted = false;
1097
+ this.mountComponent();
1098
+ }
1099
+ componentWillUnmount() {
1100
+ this.error = void 0;
1101
+ this.ComponentNode = null;
1102
+ this.isUnMounted = true;
1103
+ this.unSubscribeMessage();
1104
+ updateUnMountComponent(module);
1105
+ }
1106
+ render() {
1107
+ const Fallback = connector_default.getFallbackComponent();
1108
+ const { $silent, $componentProps, $ref } = this.props;
1109
+ const { componentReady, isError } = this.state;
1110
+ const store = getUserStore();
1111
+ const locale = getStore(LOCALE_KEY);
1112
+ const ComponentNode = this.ComponentNode;
1113
+ if (isError) throw this.error;
1114
+ if (!componentReady) {
1115
+ if ($silent || isModuleLoaded(module)) return null;
1116
+ return /* @__PURE__ */ e.createElement(Fallback, {
1117
+ $self: this.$self,
1118
+ $store: store,
1119
+ $locale: locale
1120
+ });
1121
+ }
1122
+ return /* @__PURE__ */ e.createElement(ComponentNode, _objectSpread2(_objectSpread2({}, $componentProps), {}, {
1123
+ $self: this.$self,
1124
+ $dispatch: this.$dispatch,
1125
+ $store: store,
1126
+ $postMessage: this.$postMessage,
1127
+ $t: this.$t,
1128
+ $logger: this.$logger,
1129
+ ref: $ref,
1130
+ $locale: locale
1131
+ }));
1132
+ }
1133
+ }
1134
+ _defineProperty(R, "displayName", "various-react-component");
1135
+ const Connected = connect(...storeKeys, LOCALE_KEY)(R);
1136
+ Connected.displayName = "various-connector";
1137
+ return Connected;
1309
1138
  }
1310
-
1311
- /***/ }),
1312
-
1313
- /***/ "./src/core/vue-component.tsx":
1314
- /*!************************************!*\
1315
- !*** ./src/core/vue-component.tsx ***!
1316
- \************************************/
1317
- /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
1318
-
1319
- "use strict";
1320
- __webpack_require__.r(__webpack_exports__);
1321
- /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
1322
- /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
1323
- /* harmony import */ var _connector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./connector */ "./src/core/connector.ts");
1324
- /* harmony import */ var _create_module__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./create-module */ "./src/core/create-module.ts");
1325
- /* harmony import */ var _store__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./store */ "./src/core/store.ts");
1326
- /* harmony import */ var _helper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./helper */ "./src/core/helper.ts");
1327
- /* harmony import */ var _dispatch__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./dispatch */ "./src/core/dispatch.ts");
1328
- /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./logger */ "./src/core/logger.ts");
1329
- /* harmony import */ var _message__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./message */ "./src/core/message.ts");
1330
- /* harmony import */ var _i18n__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./i18n */ "./src/core/i18n.ts");
1331
-
1332
-
1333
-
1334
-
1335
-
1336
-
1337
-
1338
-
1339
-
1139
+ //#endregion
1140
+ //#region src/core/vue-component.tsx
1340
1141
  function vueComponent(config) {
1341
- const {
1342
- module,
1343
- url,
1344
- watchKeys,
1345
- onMounted
1346
- } = config;
1347
- const storeKeys = watchKeys || Object.keys((0,_store__WEBPACK_IMPORTED_MODULE_3__.getStore)());
1348
- const V = props => {
1349
- const store = (0,_store__WEBPACK_IMPORTED_MODULE_3__.useStore)(...storeKeys);
1350
- const vueRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)();
1351
- const vmRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)();
1352
- const isVueMounted = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(false);
1353
- const errorRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)();
1354
- const isUnMountedRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(false);
1355
- const ComponentNodeRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)();
1356
- const selfRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)((0,_helper__WEBPACK_IMPORTED_MODULE_4__.getSelfInfo)({
1357
- module,
1358
- url
1359
- }));
1360
- const containerDivRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null);
1361
- const propsReactiveRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)();
1362
- const storeReactiveRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)();
1363
- const unMountVue = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)();
1364
- const unSubscribeMessageRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)();
1365
- const updateVueComponentRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)();
1366
- const [componentReady, setComponentReady] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false);
1367
- const [isError, setIsError] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false);
1368
- const Fallback = _connector__WEBPACK_IMPORTED_MODULE_1__["default"].getFallbackComponent();
1369
- const {
1370
- $silent,
1371
- $componentProps
1372
- } = props;
1373
- const mountVue = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(() => {
1374
- const $logger = (0,_logger__WEBPACK_IMPORTED_MODULE_6__["default"])(module);
1375
- const $dispatch = (0,_dispatch__WEBPACK_IMPORTED_MODULE_5__["default"])(module);
1376
- const $postMessage = (0,_message__WEBPACK_IMPORTED_MODULE_7__.createPostMessage)(module);
1377
- const $t = (0,_i18n__WEBPACK_IMPORTED_MODULE_8__.createI18n)(module, () => {
1378
- updateVueComponentRef.current?.();
1379
- });
1380
- propsReactiveRef.current = vueRef.current.ref({
1381
- ...$componentProps
1382
- });
1383
- storeReactiveRef.current = vueRef.current.ref({
1384
- ...store
1385
- });
1386
- const vueApp = vueRef.current.createApp({
1387
- setup() {
1388
- const renderKey = vueRef.current.ref(0);
1389
- updateVueComponentRef.current = () => {
1390
- renderKey.value += 1;
1391
- };
1392
- return {
1393
- key: renderKey
1394
- };
1395
- },
1396
- errorCaptured(e) {
1397
- const error = e;
1398
- errorRef.current = error.message?.includes('https://react') ? new _helper__WEBPACK_IMPORTED_MODULE_4__.VariousError({
1399
- originalError: new Error('not a valid Vue component'),
1400
- module,
1401
- type: 'INVALID_COMPONENT'
1402
- }) : error;
1403
- setIsError(true);
1404
- },
1405
- render() {
1406
- return vueRef.current.h(ComponentNodeRef.current, {
1407
- ...propsReactiveRef.current.value,
1408
- various: {
1409
- $dispatch,
1410
- $logger,
1411
- $postMessage,
1412
- $t,
1413
- $store: storeReactiveRef.current.value,
1414
- $self: selfRef.current
1415
- },
1416
- // eslint-disable-next-line react/no-this-in-sfc
1417
- key: this.key
1418
- });
1419
- }
1420
- });
1421
-
1422
- // fix StrictMode
1423
- if (!vmRef.current) {
1424
- vmRef.current = vueApp.mount(containerDivRef.current);
1425
- }
1426
- isVueMounted.current = true;
1427
- unMountVue.current = () => vueApp.unmount();
1428
- }, [$componentProps, store]);
1429
- const mountComponent = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(async () => {
1430
- try {
1431
- const vue = await (0,_create_module__WEBPACK_IMPORTED_MODULE_2__["default"])({
1432
- module: 'vue'
1433
- });
1434
- vueRef.current = vue;
1435
- const componentNode = await (0,_create_module__WEBPACK_IMPORTED_MODULE_2__["default"])({
1436
- module,
1437
- url
1438
- }, false);
1439
- if (isUnMountedRef.current) {
1440
- return;
1441
- }
1442
- await (0,_helper__WEBPACK_IMPORTED_MODULE_4__.checkVueComponent)(componentNode, module);
1443
- (0,_helper__WEBPACK_IMPORTED_MODULE_4__.updateMountedComponent)(module);
1444
- unSubscribeMessageRef.current = (0,_helper__WEBPACK_IMPORTED_MODULE_4__.parseComponentActions)({
1445
- componentNode,
1446
- module,
1447
- type: 'vue3',
1448
- i18nUpdate() {
1449
- updateVueComponentRef.current?.();
1450
- }
1451
- });
1452
- ComponentNodeRef.current = componentNode;
1453
- setTimeout(mountVue);
1454
- setComponentReady(true);
1455
- onMounted?.();
1456
- } catch (e) {
1457
- if (isUnMountedRef.current) {
1458
- return;
1459
- }
1460
- errorRef.current = e;
1461
- setComponentReady(true);
1462
- setIsError(true);
1463
- }
1464
- }, [mountVue]);
1465
- (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
1466
- // fix StrictMode
1467
- isUnMountedRef.current = false;
1468
- return () => {
1469
- errorRef.current = undefined;
1470
- ComponentNodeRef.current = undefined;
1471
- isUnMountedRef.current = true;
1472
- (0,_helper__WEBPACK_IMPORTED_MODULE_4__.updateUnMountComponent)(module);
1473
- unMountVue.current?.();
1474
- unSubscribeMessageRef.current?.();
1475
- isVueMounted.current = false;
1476
- };
1477
- }, []);
1478
- (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
1479
- if (isVueMounted.current) {
1480
- return;
1481
- }
1482
- mountComponent();
1483
- }, [mountComponent]);
1484
- (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
1485
- if (propsReactiveRef.current) {
1486
- propsReactiveRef.current.value = {
1487
- ...$componentProps
1488
- };
1489
- }
1490
- }, [$componentProps]);
1491
- (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
1492
- if (storeReactiveRef.current) {
1493
- storeReactiveRef.current.value = {
1494
- ...store
1495
- };
1496
- }
1497
- }, [store]);
1498
- if (isError) {
1499
- throw errorRef.current;
1500
- }
1501
- 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)(module) ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Fallback, {
1502
- $self: selfRef.current,
1503
- $store: store
1504
- }) : null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
1505
- className: (0,_helper__WEBPACK_IMPORTED_MODULE_4__.getClassNameWithModule)(module, 'various-vue-component'),
1506
- ref: containerDivRef
1507
- }));
1508
- };
1509
- V.displayName = module;
1510
- const VueComponent = props => /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(V, props);
1511
- VueComponent.displayName = 'various-vue-component';
1512
- return VueComponent;
1142
+ const { module, url, watchKeys, onMounted } = config;
1143
+ const storeKeys = watchKeys || Object.keys(getStore());
1144
+ const V = (props) => {
1145
+ const store = useStore(...storeKeys, LOCALE_KEY);
1146
+ const locale = store[LOCALE_KEY];
1147
+ const vueRef = useRef();
1148
+ const vmRef = useRef();
1149
+ const isVueMounted = useRef(false);
1150
+ const errorRef = useRef();
1151
+ const isUnMountedRef = useRef(false);
1152
+ const ComponentNodeRef = useRef();
1153
+ const selfRef = useRef(getSelfInfo({
1154
+ module,
1155
+ url
1156
+ }));
1157
+ const containerDivRef = useRef(null);
1158
+ const propsReactiveRef = useRef();
1159
+ const storeReactiveRef = useRef();
1160
+ const localeReactiveRef = useRef();
1161
+ const unMountVue = useRef();
1162
+ const unSubscribeMessageRef = useRef();
1163
+ const updateVueComponentRef = useRef();
1164
+ const [componentReady, setComponentReady] = useState(false);
1165
+ const [isError, setIsError] = useState(false);
1166
+ const Fallback = connector_default.getFallbackComponent();
1167
+ const { $silent, $componentProps } = props;
1168
+ const mountVue = useCallback(() => {
1169
+ const $logger = createLogger(module);
1170
+ const $dispatch = createDispatch(module);
1171
+ const $postMessage = createPostMessage(module);
1172
+ const $t = createI18n(module, () => {
1173
+ var _updateVueComponentRe;
1174
+ (_updateVueComponentRe = updateVueComponentRef.current) === null || _updateVueComponentRe === void 0 || _updateVueComponentRe.call(updateVueComponentRef);
1175
+ });
1176
+ propsReactiveRef.current = vueRef.current.ref(_objectSpread2({}, $componentProps));
1177
+ storeReactiveRef.current = vueRef.current.ref(_objectSpread2({}, store));
1178
+ localeReactiveRef.current = vueRef.current.ref(locale);
1179
+ const vueApp = vueRef.current.createApp({
1180
+ setup() {
1181
+ const renderKey = vueRef.current.ref(0);
1182
+ updateVueComponentRef.current = () => {
1183
+ renderKey.value += 1;
1184
+ };
1185
+ return { key: renderKey };
1186
+ },
1187
+ errorCaptured(e) {
1188
+ var _error$message;
1189
+ const error = e;
1190
+ errorRef.current = ((_error$message = error.message) === null || _error$message === void 0 ? void 0 : _error$message.includes("https://react")) ? new VariousError({
1191
+ originalError: /* @__PURE__ */ new Error("not a valid Vue component"),
1192
+ module,
1193
+ type: "INVALID_COMPONENT"
1194
+ }) : error;
1195
+ setIsError(true);
1196
+ },
1197
+ render() {
1198
+ return vueRef.current.h(ComponentNodeRef.current, _objectSpread2(_objectSpread2({}, propsReactiveRef.current.value), {}, {
1199
+ various: {
1200
+ $dispatch,
1201
+ $logger,
1202
+ $postMessage,
1203
+ $t,
1204
+ $store: storeReactiveRef.current.value,
1205
+ $self: selfRef.current,
1206
+ $locale: localeReactiveRef.current.value
1207
+ },
1208
+ key: this.key
1209
+ }));
1210
+ }
1211
+ });
1212
+ if (!vmRef.current) vmRef.current = vueApp.mount(containerDivRef.current);
1213
+ isVueMounted.current = true;
1214
+ unMountVue.current = () => vueApp.unmount();
1215
+ }, [
1216
+ $componentProps,
1217
+ store,
1218
+ locale
1219
+ ]);
1220
+ const mountComponent = useCallback(async () => {
1221
+ try {
1222
+ const vue = await createModule({ module: "vue" });
1223
+ vueRef.current = vue;
1224
+ const componentNode = await createModule({
1225
+ module,
1226
+ url
1227
+ }, false);
1228
+ if (isUnMountedRef.current) return;
1229
+ await checkVueComponent(componentNode, module);
1230
+ updateMountedComponent(module);
1231
+ unSubscribeMessageRef.current = parseComponentActions({
1232
+ componentNode,
1233
+ module,
1234
+ type: "vue3",
1235
+ i18nUpdate() {
1236
+ var _updateVueComponentRe2;
1237
+ (_updateVueComponentRe2 = updateVueComponentRef.current) === null || _updateVueComponentRe2 === void 0 || _updateVueComponentRe2.call(updateVueComponentRef);
1238
+ }
1239
+ });
1240
+ ComponentNodeRef.current = componentNode;
1241
+ setTimeout(mountVue);
1242
+ setComponentReady(true);
1243
+ onMounted === null || onMounted === void 0 || onMounted();
1244
+ } catch (e) {
1245
+ if (isUnMountedRef.current) return;
1246
+ errorRef.current = e;
1247
+ setComponentReady(true);
1248
+ setIsError(true);
1249
+ }
1250
+ }, [mountVue]);
1251
+ useEffect(() => {
1252
+ isUnMountedRef.current = false;
1253
+ return () => {
1254
+ var _unMountVue$current, _unSubscribeMessageRe;
1255
+ errorRef.current = void 0;
1256
+ ComponentNodeRef.current = void 0;
1257
+ isUnMountedRef.current = true;
1258
+ updateUnMountComponent(module);
1259
+ (_unMountVue$current = unMountVue.current) === null || _unMountVue$current === void 0 || _unMountVue$current.call(unMountVue);
1260
+ (_unSubscribeMessageRe = unSubscribeMessageRef.current) === null || _unSubscribeMessageRe === void 0 || _unSubscribeMessageRe.call(unSubscribeMessageRef);
1261
+ isVueMounted.current = false;
1262
+ };
1263
+ }, []);
1264
+ useEffect(() => {
1265
+ if (isVueMounted.current) return;
1266
+ mountComponent();
1267
+ }, [mountComponent]);
1268
+ useEffect(() => {
1269
+ if (propsReactiveRef.current) propsReactiveRef.current.value = _objectSpread2({}, $componentProps);
1270
+ }, [$componentProps]);
1271
+ useEffect(() => {
1272
+ if (storeReactiveRef.current) storeReactiveRef.current.value = _objectSpread2({}, store);
1273
+ }, [store]);
1274
+ useEffect(() => {
1275
+ if (localeReactiveRef.current) localeReactiveRef.current.value = locale;
1276
+ }, [locale]);
1277
+ if (isError) throw errorRef.current;
1278
+ return /* @__PURE__ */ e.createElement(e.Fragment, null, !componentReady && !$silent && !isModuleLoaded(module) ? /* @__PURE__ */ e.createElement(Fallback, {
1279
+ $self: selfRef.current,
1280
+ $store: store,
1281
+ $locale: locale
1282
+ }) : null, /* @__PURE__ */ e.createElement("div", {
1283
+ className: getClassNameWithModule(module, "various-vue-component"),
1284
+ ref: containerDivRef
1285
+ }));
1286
+ };
1287
+ V.displayName = module;
1288
+ const VueComponent = (props) => /* @__PURE__ */ e.createElement(V, props);
1289
+ VueComponent.displayName = "various-vue-component";
1290
+ return VueComponent;
1513
1291
  }
1514
- /* harmony default export */ __webpack_exports__["default"] = (vueComponent);
1515
-
1516
- /***/ }),
1517
-
1518
- /***/ "react":
1519
- /*!************************!*\
1520
- !*** external "react" ***!
1521
- \************************/
1522
- /***/ (function(module) {
1523
-
1524
- "use strict";
1525
- module.exports = __WEBPACK_EXTERNAL_MODULE_react__;
1526
-
1527
- /***/ })
1528
-
1529
- /******/ });
1530
- /************************************************************************/
1531
- /******/ // The module cache
1532
- /******/ var __webpack_module_cache__ = {};
1533
- /******/
1534
- /******/ // The require function
1535
- /******/ function __webpack_require__(moduleId) {
1536
- /******/ // Check if module is in cache
1537
- /******/ var cachedModule = __webpack_module_cache__[moduleId];
1538
- /******/ if (cachedModule !== undefined) {
1539
- /******/ return cachedModule.exports;
1540
- /******/ }
1541
- /******/ // Check if module exists (development only)
1542
- /******/ if (__webpack_modules__[moduleId] === undefined) {
1543
- /******/ var e = new Error("Cannot find module '" + moduleId + "'");
1544
- /******/ e.code = 'MODULE_NOT_FOUND';
1545
- /******/ throw e;
1546
- /******/ }
1547
- /******/ // Create a new module (and put it into the cache)
1548
- /******/ var module = __webpack_module_cache__[moduleId] = {
1549
- /******/ // no module.id needed
1550
- /******/ // no module.loaded needed
1551
- /******/ exports: {}
1552
- /******/ };
1553
- /******/
1554
- /******/ // Execute the module function
1555
- /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
1556
- /******/
1557
- /******/ // Return the exports of the module
1558
- /******/ return module.exports;
1559
- /******/ }
1560
- /******/
1561
- /************************************************************************/
1562
- /******/ /* webpack/runtime/compat get default export */
1563
- /******/ !function() {
1564
- /******/ // getDefaultExport function for compatibility with non-harmony modules
1565
- /******/ __webpack_require__.n = function(module) {
1566
- /******/ var getter = module && module.__esModule ?
1567
- /******/ function() { return module['default']; } :
1568
- /******/ function() { return module; };
1569
- /******/ __webpack_require__.d(getter, { a: getter });
1570
- /******/ return getter;
1571
- /******/ };
1572
- /******/ }();
1573
- /******/
1574
- /******/ /* webpack/runtime/define property getters */
1575
- /******/ !function() {
1576
- /******/ // define getter functions for harmony exports
1577
- /******/ __webpack_require__.d = function(exports, definition) {
1578
- /******/ for(var key in definition) {
1579
- /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
1580
- /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
1581
- /******/ }
1582
- /******/ }
1583
- /******/ };
1584
- /******/ }();
1585
- /******/
1586
- /******/ /* webpack/runtime/hasOwnProperty shorthand */
1587
- /******/ !function() {
1588
- /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
1589
- /******/ }();
1590
- /******/
1591
- /******/ /* webpack/runtime/make namespace object */
1592
- /******/ !function() {
1593
- /******/ // define __esModule on exports
1594
- /******/ __webpack_require__.r = function(exports) {
1595
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
1596
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1597
- /******/ }
1598
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
1599
- /******/ };
1600
- /******/ }();
1601
- /******/
1602
- /************************************************************************/
1603
- var __webpack_exports__ = {};
1604
- // This entry needs to be wrapped in an IIFE because it needs to be in strict mode.
1605
- !function() {
1606
- "use strict";
1607
- /*!****************************!*\
1608
- !*** ./src/core/index.tsx ***!
1609
- \****************************/
1610
- __webpack_require__.r(__webpack_exports__);
1611
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1612
- /* harmony export */ Nycticorax: function() { return /* reexport default from dynamic */ nycticorax__WEBPACK_IMPORTED_MODULE_7___default.a; },
1613
- /* harmony export */ createComponent: function() { return /* reexport safe */ _create_component__WEBPACK_IMPORTED_MODULE_13__["default"]; },
1614
- /* harmony export */ createDispatch: function() { return /* reexport safe */ _dispatch__WEBPACK_IMPORTED_MODULE_8__["default"]; },
1615
- /* harmony export */ createLogger: function() { return /* reexport safe */ _logger__WEBPACK_IMPORTED_MODULE_10__["default"]; },
1616
- /* harmony export */ createModule: function() { return /* reexport safe */ _create_module__WEBPACK_IMPORTED_MODULE_12__["default"]; },
1617
- /* harmony export */ createPostMessage: function() { return /* reexport safe */ _message__WEBPACK_IMPORTED_MODULE_9__.createPostMessage; },
1618
- /* harmony export */ defineDependencies: function() { return /* reexport safe */ _helper__WEBPACK_IMPORTED_MODULE_11__.defineDependencies; },
1619
- /* harmony export */ getApp: function() { return /* binding */ getApp; },
1620
- /* harmony export */ getConfig: function() { return /* reexport safe */ _helper__WEBPACK_IMPORTED_MODULE_11__.getConfig; },
1621
- /* harmony export */ getModuleInfo: function() { return /* reexport safe */ _helper__WEBPACK_IMPORTED_MODULE_11__.getModuleInfo; },
1622
- /* harmony export */ getMountedComponents: function() { return /* reexport safe */ _helper__WEBPACK_IMPORTED_MODULE_11__.getMountedComponents; },
1623
- /* harmony export */ getStore: function() { return /* reexport safe */ _store__WEBPACK_IMPORTED_MODULE_1__.getUserStore; },
1624
- /* harmony export */ isModuleLoaded: function() { return /* reexport safe */ _helper__WEBPACK_IMPORTED_MODULE_11__.isModuleLoaded; },
1625
- /* harmony export */ onComponentMounted: function() { return /* reexport safe */ _helper__WEBPACK_IMPORTED_MODULE_11__.onComponentMounted; },
1626
- /* harmony export */ preloadModules: function() { return /* reexport safe */ _helper__WEBPACK_IMPORTED_MODULE_11__.preloadModules; },
1627
- /* harmony export */ removeLoadedModules: function() { return /* reexport safe */ _helper__WEBPACK_IMPORTED_MODULE_11__.removeLoadedModules; },
1628
- /* harmony export */ renderComponent: function() { return /* reexport safe */ _render_component__WEBPACK_IMPORTED_MODULE_14__["default"]; },
1629
- /* harmony export */ version: function() { return /* binding */ version; }
1630
- /* harmony export */ });
1631
- /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
1632
- /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
1633
- /* harmony import */ var _store__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./store */ "./src/core/store.ts");
1634
- /* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./config */ "./src/core/config.ts");
1635
- /* harmony import */ var _connector__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./connector */ "./src/core/connector.ts");
1636
- /* harmony import */ var _i18n__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./i18n */ "./src/core/i18n.ts");
1637
- /* harmony import */ var _default_component__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./default-component */ "./src/core/default-component.tsx");
1638
- /* harmony import */ var _error_boundary__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./error-boundary */ "./src/core/error-boundary.tsx");
1639
- /* harmony import */ var nycticorax__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! nycticorax */ "./node_modules/nycticorax/dist/index.js");
1640
- /* harmony import */ var nycticorax__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(nycticorax__WEBPACK_IMPORTED_MODULE_7__);
1641
- /* harmony import */ var _dispatch__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./dispatch */ "./src/core/dispatch.ts");
1642
- /* harmony import */ var _message__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./message */ "./src/core/message.ts");
1643
- /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./logger */ "./src/core/logger.ts");
1644
- /* harmony import */ var _helper__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./helper */ "./src/core/helper.ts");
1645
- /* harmony import */ var _create_module__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./create-module */ "./src/core/create-module.ts");
1646
- /* harmony import */ var _create_component__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./create-component */ "./src/core/create-component.tsx");
1647
- /* harmony import */ var _render_component__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./render-component */ "./src/core/render-component.tsx");
1648
-
1649
-
1650
-
1651
-
1652
-
1653
-
1654
-
1655
-
1656
-
1657
-
1658
-
1659
-
1660
-
1661
-
1662
-
1663
-
1664
-
1665
- // eslint-disable-next-line no-undef
1666
- const version = "5.2.1";
1667
- const getApp = config => {
1668
- const {
1669
- dependencies,
1670
- store = {},
1671
- actions = {},
1672
- Fallback,
1673
- ErrorFallback,
1674
- Root = _default_component__WEBPACK_IMPORTED_MODULE_5__.Root,
1675
- middlewares,
1676
- i18n,
1677
- ...rest
1678
- } = config;
1679
- if (middlewares) {
1680
- _connector__WEBPACK_IMPORTED_MODULE_3__["default"].setMiddlewares(middlewares);
1681
- }
1682
- _connector__WEBPACK_IMPORTED_MODULE_3__["default"].setStoreActions(actions);
1683
- if (Fallback) {
1684
- _connector__WEBPACK_IMPORTED_MODULE_3__["default"].setFallbackComponent(Fallback);
1685
- }
1686
- if (ErrorFallback) {
1687
- _connector__WEBPACK_IMPORTED_MODULE_3__["default"].setErrorFallbackComponent(ErrorFallback);
1688
- }
1689
- (0,_store__WEBPACK_IMPORTED_MODULE_1__.createStore)({
1690
- ...store,
1691
- [_config__WEBPACK_IMPORTED_MODULE_2__.MOUNTED_COMPONENTS_KEY]: [],
1692
- [_config__WEBPACK_IMPORTED_MODULE_2__.CONFIG_KEY]: rest,
1693
- [_config__WEBPACK_IMPORTED_MODULE_2__.DEPENDENCIES_KEY]: dependencies,
1694
- [_config__WEBPACK_IMPORTED_MODULE_2__.MESSAGE_KEY]: null
1695
- });
1696
- Root.displayName = 'various-app-root';
1697
- return class extends react__WEBPACK_IMPORTED_MODULE_0__.Component {
1698
- static displayName = 'various-app';
1699
- componentDidMount() {
1700
- (0,_i18n__WEBPACK_IMPORTED_MODULE_4__.createI18nConfig)(i18n);
1701
- }
1702
- render() {
1703
- return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_error_boundary__WEBPACK_IMPORTED_MODULE_6__["default"], {
1704
- module: "app",
1705
- url: dependencies.app
1706
- }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Root, null));
1707
- }
1708
- };
1292
+ //#endregion
1293
+ //#region src/core/create-component.tsx
1294
+ var _excluded$2 = ["$silent", "$ref"];
1295
+ var createComponent = (config, storeKeys) => {
1296
+ const { module, url, type = "react" } = config;
1297
+ const C = (type === "vue3" ? vueComponent : reactComponent)({
1298
+ module,
1299
+ url,
1300
+ watchKeys: storeKeys
1301
+ });
1302
+ const component = (props) => {
1303
+ const _ref = props || {}, { $silent, $ref } = _ref;
1304
+ const nextProps = {
1305
+ $componentProps: _objectWithoutProperties(_ref, _excluded$2),
1306
+ $silent,
1307
+ $ref
1308
+ };
1309
+ return /* @__PURE__ */ e.createElement(ErrorBoundary, {
1310
+ module,
1311
+ url
1312
+ }, /* @__PURE__ */ e.createElement(C, nextProps));
1313
+ };
1314
+ component.displayName = "various-creator";
1315
+ return component;
1316
+ };
1317
+ //#endregion
1318
+ //#region src/core/render-component.tsx
1319
+ var _excluded$1 = ["$silent", "$ref"];
1320
+ var renderComponent = async ({ module, url, target, props, type = "react", renderNode, onMounted }) => {
1321
+ try {
1322
+ const ReactDOM = await createModule({ module: "react-dom/client" });
1323
+ const C = (type === "vue3" ? vueComponent : reactComponent)({
1324
+ module,
1325
+ url,
1326
+ onMounted
1327
+ });
1328
+ const root = ReactDOM.createRoot(target);
1329
+ const _ref = props || {}, { $silent, $ref } = _ref;
1330
+ const nextProps = {
1331
+ $componentProps: _objectWithoutProperties(_ref, _excluded$1),
1332
+ $silent,
1333
+ $ref
1334
+ };
1335
+ const node = /* @__PURE__ */ e.createElement(ErrorBoundary, {
1336
+ module,
1337
+ url
1338
+ }, /* @__PURE__ */ e.createElement(C, nextProps));
1339
+ root.render(renderNode ? renderNode(node) : node);
1340
+ return () => new Promise((resolve) => {
1341
+ setTimeout(() => {
1342
+ root.unmount();
1343
+ resolve();
1344
+ });
1345
+ });
1346
+ } catch (e) {
1347
+ onError(new VariousError({
1348
+ module,
1349
+ type: "SCRIPT_ERROR",
1350
+ originalError: e
1351
+ }));
1352
+ return () => Promise.resolve();
1353
+ }
1709
1354
  };
1710
- }();
1711
- /******/ return __webpack_exports__;
1712
- /******/ })()
1713
- ;
1714
- });;
1355
+ //#endregion
1356
+ //#region src/core/index.tsx
1357
+ var _excluded = [
1358
+ "dependencies",
1359
+ "store",
1360
+ "actions",
1361
+ "Fallback",
1362
+ "ErrorFallback",
1363
+ "Root",
1364
+ "middlewares",
1365
+ "i18n"
1366
+ ];
1367
+ var version = "6.0.0";
1368
+ var getApp = (config) => {
1369
+ var _Class;
1370
+ const { dependencies, store = {}, actions = {}, Fallback, ErrorFallback, Root: Root$1 = Root, middlewares, i18n } = config, rest = _objectWithoutProperties(config, _excluded);
1371
+ if (middlewares) connector_default.setMiddlewares(middlewares);
1372
+ connector_default.setStoreActions(actions);
1373
+ if (Fallback) connector_default.setFallbackComponent(Fallback);
1374
+ if (ErrorFallback) connector_default.setErrorFallbackComponent(ErrorFallback);
1375
+ createStore(_objectSpread2(_objectSpread2({}, store), {}, {
1376
+ [MOUNTED_COMPONENTS_KEY]: [],
1377
+ [CONFIG_KEY]: rest,
1378
+ [DEPENDENCIES_KEY]: dependencies,
1379
+ [MESSAGE_KEY]: null,
1380
+ [LOCALE_KEY]: (i18n === null || i18n === void 0 ? void 0 : i18n.defaultLocale) || "en"
1381
+ }));
1382
+ Root$1.displayName = "various-app-root";
1383
+ return _Class = class extends Component {
1384
+ componentDidMount() {
1385
+ createI18nConfig(i18n === null || i18n === void 0 ? void 0 : i18n.getResources);
1386
+ }
1387
+ render() {
1388
+ return /* @__PURE__ */ e.createElement(ErrorBoundary, {
1389
+ module: "app",
1390
+ url: dependencies.app
1391
+ }, /* @__PURE__ */ e.createElement(Root$1, null));
1392
+ }
1393
+ }, _defineProperty(_Class, "displayName", "various-app"), _Class;
1394
+ };
1395
+ //#endregion
1396
+ export { h as Nycticorax, createComponent, createDispatch, createLogger, createModule, createPostMessage, defineDependencies, getApp, getConfig, getModuleInfo, getMountedComponents, getUserStore as getStore, isModuleLoaded, onComponentMounted, preloadModules, removeLoadedModules, renderComponent, version };
1397
+
1715
1398
  //# sourceMappingURL=index.dev.js.map