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