@variousjs/various 5.1.5 → 5.2.1
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 +171 -254
- package/dist/index.dev.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/loader-dev.js +8 -2
- package/dist/loader-dev.js.map +1 -1
- package/dist/loader.js +1 -1
- package/dist/loader.js.map +1 -1
- package/dist/standalone.js +178 -265
- package/dist/standalone.js.map +1 -1
- package/index.d.ts +170 -78
- package/package.json +38 -33
- package/standalone.d.ts +27 -20
package/dist/index.dev.js
CHANGED
|
@@ -31,7 +31,7 @@ function _extends() {
|
|
|
31
31
|
\***********************************************/
|
|
32
32
|
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
|
|
33
33
|
|
|
34
|
-
!function(t,e){ true?module.exports=e(__webpack_require__(/*! react */ "react")):0}(self,
|
|
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
35
|
//# sourceMappingURL=index.js.map
|
|
36
36
|
|
|
37
37
|
/***/ }),
|
|
@@ -74,8 +74,6 @@ const BASE_DEPENDENCIES = ['react', 'react-dom', '@variousjs/various', 'app'];
|
|
|
74
74
|
"use strict";
|
|
75
75
|
__webpack_require__.r(__webpack_exports__);
|
|
76
76
|
/* harmony import */ var _default_component__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./default-component */ "./src/core/default-component.tsx");
|
|
77
|
-
/* harmony import */ var _helper__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./helper */ "./src/core/helper.ts");
|
|
78
|
-
|
|
79
77
|
|
|
80
78
|
class Connector {
|
|
81
79
|
constructor() {
|
|
@@ -92,16 +90,14 @@ class Connector {
|
|
|
92
90
|
getMiddlewares() {
|
|
93
91
|
return this.middlewares;
|
|
94
92
|
}
|
|
95
|
-
setI18nConfig(
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
...this.i18nConfigs[name],
|
|
93
|
+
setI18nConfig(module, config) {
|
|
94
|
+
this.i18nConfigs[module] = {
|
|
95
|
+
...this.i18nConfigs[module],
|
|
99
96
|
...config
|
|
100
97
|
};
|
|
101
98
|
}
|
|
102
|
-
getI18nConfig(
|
|
103
|
-
|
|
104
|
-
return this.i18nConfigs[name];
|
|
99
|
+
getI18nConfig(module) {
|
|
100
|
+
return this.i18nConfigs[module];
|
|
105
101
|
}
|
|
106
102
|
setGlobalI18nConfig(config) {
|
|
107
103
|
this.globalI18nConfig = {
|
|
@@ -112,17 +108,14 @@ class Connector {
|
|
|
112
108
|
getGlobalI18nConfig() {
|
|
113
109
|
return this.globalI18nConfig;
|
|
114
110
|
}
|
|
115
|
-
setComponentActions(
|
|
116
|
-
|
|
117
|
-
this.componentActions[name] = actions;
|
|
111
|
+
setComponentActions(module, actions) {
|
|
112
|
+
this.componentActions[module] = actions;
|
|
118
113
|
}
|
|
119
|
-
deleteComponentActions(
|
|
120
|
-
|
|
121
|
-
delete this.componentActions[name];
|
|
114
|
+
deleteComponentActions(module) {
|
|
115
|
+
delete this.componentActions[module];
|
|
122
116
|
}
|
|
123
|
-
getComponentActions(
|
|
124
|
-
|
|
125
|
-
return this.componentActions[name];
|
|
117
|
+
getComponentActions(module) {
|
|
118
|
+
return this.componentActions[module];
|
|
126
119
|
}
|
|
127
120
|
setStoreActions(actions) {
|
|
128
121
|
this.storeActions = actions;
|
|
@@ -166,13 +159,11 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
166
159
|
|
|
167
160
|
const createComponent = (config, storeKeys) => {
|
|
168
161
|
const {
|
|
169
|
-
name,
|
|
170
162
|
module,
|
|
171
163
|
url,
|
|
172
164
|
type = 'react'
|
|
173
165
|
} = config;
|
|
174
166
|
const C = (type === 'vue3' ? _vue_component__WEBPACK_IMPORTED_MODULE_2__["default"] : _react_component__WEBPACK_IMPORTED_MODULE_1__["default"])({
|
|
175
|
-
name,
|
|
176
167
|
module,
|
|
177
168
|
url,
|
|
178
169
|
watchKeys: storeKeys
|
|
@@ -189,7 +180,6 @@ const createComponent = (config, storeKeys) => {
|
|
|
189
180
|
$ref
|
|
190
181
|
};
|
|
191
182
|
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_error_boundary__WEBPACK_IMPORTED_MODULE_3__["default"], {
|
|
192
|
-
name: name,
|
|
193
183
|
module: module,
|
|
194
184
|
url: url
|
|
195
185
|
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(C, nextProps));
|
|
@@ -221,10 +211,13 @@ const createModule = (config, logError = true) => {
|
|
|
221
211
|
const dependencies = (0,_store__WEBPACK_IMPORTED_MODULE_1__.getStore)(_config__WEBPACK_IMPORTED_MODULE_0__.DEPENDENCIES_KEY);
|
|
222
212
|
const middlewares = _connector__WEBPACK_IMPORTED_MODULE_2__["default"].getMiddlewares();
|
|
223
213
|
const {
|
|
224
|
-
|
|
225
|
-
module
|
|
226
|
-
url
|
|
214
|
+
url,
|
|
215
|
+
module
|
|
227
216
|
} = config;
|
|
217
|
+
const {
|
|
218
|
+
name,
|
|
219
|
+
entry
|
|
220
|
+
} = (0,_helper__WEBPACK_IMPORTED_MODULE_3__.getModuleInfo)(module);
|
|
228
221
|
const loadStart = +new Date();
|
|
229
222
|
const logOnError = e => {
|
|
230
223
|
if (logError) {
|
|
@@ -232,12 +225,11 @@ const createModule = (config, logError = true) => {
|
|
|
232
225
|
}
|
|
233
226
|
};
|
|
234
227
|
if (url) {
|
|
235
|
-
(0,_helper__WEBPACK_IMPORTED_MODULE_3__.resetDependencyConfig)(
|
|
228
|
+
(0,_helper__WEBPACK_IMPORTED_MODULE_3__.resetDependencyConfig)(module, url);
|
|
236
229
|
}
|
|
237
230
|
return new Promise((resolve, reject) => {
|
|
238
|
-
if (!url && !dependencies[name] && !(0,_helper__WEBPACK_IMPORTED_MODULE_3__.isModuleSpecified)(
|
|
231
|
+
if (!url && !dependencies[name] && !(0,_helper__WEBPACK_IMPORTED_MODULE_3__.isModuleSpecified)(module)) {
|
|
239
232
|
const error = new _helper__WEBPACK_IMPORTED_MODULE_3__.VariousError({
|
|
240
|
-
name,
|
|
241
233
|
module,
|
|
242
234
|
type: 'NOT_DEFINED',
|
|
243
235
|
originalError: new Error(`module "${name}" not defined`)
|
|
@@ -249,34 +241,31 @@ const createModule = (config, logError = true) => {
|
|
|
249
241
|
window.requirejs([name], C => {
|
|
250
242
|
const loadEnd = +new Date();
|
|
251
243
|
middlewares?.onLoad?.({
|
|
252
|
-
name,
|
|
253
244
|
module,
|
|
254
245
|
loadStart,
|
|
255
246
|
loadEnd,
|
|
256
|
-
beenLoaded: (0,_helper__WEBPACK_IMPORTED_MODULE_3__.isModuleLoaded)(
|
|
247
|
+
beenLoaded: (0,_helper__WEBPACK_IMPORTED_MODULE_3__.isModuleLoaded)(module)
|
|
257
248
|
});
|
|
258
249
|
if (!C) {
|
|
259
250
|
const error = new _helper__WEBPACK_IMPORTED_MODULE_3__.VariousError({
|
|
260
|
-
name,
|
|
261
251
|
module,
|
|
262
252
|
type: 'INVALID_MODULE',
|
|
263
253
|
originalError: new Error(`module "${name}" invalid`)
|
|
264
254
|
});
|
|
265
|
-
(0,_helper__WEBPACK_IMPORTED_MODULE_3__.resetDependencyConfig)(
|
|
255
|
+
(0,_helper__WEBPACK_IMPORTED_MODULE_3__.resetDependencyConfig)(module);
|
|
266
256
|
logOnError(error);
|
|
267
257
|
reject(error);
|
|
268
258
|
return;
|
|
269
259
|
}
|
|
270
260
|
const defaultModule = 'default' in C ? C.default : C;
|
|
271
|
-
const actualModule = !
|
|
272
|
-
if (actualModule === undefined &&
|
|
261
|
+
const actualModule = !entry ? defaultModule : C[entry];
|
|
262
|
+
if (actualModule === undefined && entry) {
|
|
273
263
|
const error = new _helper__WEBPACK_IMPORTED_MODULE_3__.VariousError({
|
|
274
|
-
name,
|
|
275
264
|
module,
|
|
276
265
|
type: 'SUBMODULE_NOT_DEFINED',
|
|
277
|
-
originalError: new Error(`submodule "${
|
|
266
|
+
originalError: new Error(`submodule "${entry}" not defined`)
|
|
278
267
|
});
|
|
279
|
-
(0,_helper__WEBPACK_IMPORTED_MODULE_3__.resetDependencyConfig)(
|
|
268
|
+
(0,_helper__WEBPACK_IMPORTED_MODULE_3__.resetDependencyConfig)(module);
|
|
280
269
|
logOnError(error);
|
|
281
270
|
reject(error);
|
|
282
271
|
return;
|
|
@@ -284,7 +273,7 @@ const createModule = (config, logError = true) => {
|
|
|
284
273
|
resolve(actualModule);
|
|
285
274
|
}, e => {
|
|
286
275
|
const [requireModule] = e.requireModules;
|
|
287
|
-
(0,_helper__WEBPACK_IMPORTED_MODULE_3__.resetDependencyConfig)(
|
|
276
|
+
(0,_helper__WEBPACK_IMPORTED_MODULE_3__.resetDependencyConfig)(module, url);
|
|
288
277
|
(0,_helper__WEBPACK_IMPORTED_MODULE_3__.resetDependencyConfig)(requireModule);
|
|
289
278
|
let errorType = 'LOADING_ERROR';
|
|
290
279
|
if (requireModule !== name) {
|
|
@@ -294,8 +283,7 @@ const createModule = (config, logError = true) => {
|
|
|
294
283
|
errorType = requireModule === name ? 'SCRIPT_ERROR' : 'SUBMODULE_SCRIPT_ERROR';
|
|
295
284
|
}
|
|
296
285
|
const error = new _helper__WEBPACK_IMPORTED_MODULE_3__.VariousError({
|
|
297
|
-
|
|
298
|
-
module: requireModule === name ? undefined : requireModule,
|
|
286
|
+
module: requireModule,
|
|
299
287
|
type: errorType,
|
|
300
288
|
originalError: e
|
|
301
289
|
});
|
|
@@ -327,7 +315,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
327
315
|
|
|
328
316
|
|
|
329
317
|
const Fallback = props => {
|
|
330
|
-
const className = (0,_helper__WEBPACK_IMPORTED_MODULE_1__.getClassNameWithModule)(props.$self, 'various-component-fallback');
|
|
318
|
+
const className = (0,_helper__WEBPACK_IMPORTED_MODULE_1__.getClassNameWithModule)(props.$self.module, 'various-component-fallback');
|
|
331
319
|
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
332
320
|
className: className
|
|
333
321
|
}, "Loading");
|
|
@@ -337,7 +325,7 @@ const ErrorFallback = ({
|
|
|
337
325
|
$reload,
|
|
338
326
|
$self
|
|
339
327
|
}) => {
|
|
340
|
-
const className = (0,_helper__WEBPACK_IMPORTED_MODULE_1__.getClassNameWithModule)($self, 'various-component-error_fallback');
|
|
328
|
+
const className = (0,_helper__WEBPACK_IMPORTED_MODULE_1__.getClassNameWithModule)($self.module, 'various-component-error_fallback');
|
|
341
329
|
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
342
330
|
className: className
|
|
343
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", {
|
|
@@ -365,59 +353,51 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
365
353
|
|
|
366
354
|
|
|
367
355
|
|
|
368
|
-
const createDispatch =
|
|
356
|
+
const createDispatch = module => async function (params) {
|
|
369
357
|
const middlewares = _connector__WEBPACK_IMPORTED_MODULE_0__["default"].getMiddlewares();
|
|
370
|
-
const logger = (0,_logger__WEBPACK_IMPORTED_MODULE_3__["default"])(
|
|
358
|
+
const logger = (0,_logger__WEBPACK_IMPORTED_MODULE_3__["default"])(module);
|
|
371
359
|
let {
|
|
372
|
-
name,
|
|
373
|
-
module,
|
|
374
360
|
action,
|
|
375
|
-
|
|
361
|
+
payload,
|
|
362
|
+
target
|
|
376
363
|
} = params;
|
|
377
364
|
if (middlewares?.onDispatch) {
|
|
378
365
|
const check = await middlewares.onDispatch({
|
|
379
|
-
target
|
|
380
|
-
name,
|
|
381
|
-
module
|
|
382
|
-
},
|
|
366
|
+
target,
|
|
383
367
|
action,
|
|
384
|
-
|
|
385
|
-
trigger:
|
|
368
|
+
payload,
|
|
369
|
+
trigger: module
|
|
386
370
|
});
|
|
387
371
|
if (check === false) {
|
|
388
372
|
logger.warn('blocked by middleware', 'DISPATCH');
|
|
389
373
|
return Promise.resolve();
|
|
390
374
|
}
|
|
391
375
|
if (check !== true) {
|
|
392
|
-
|
|
393
|
-
module = check.target.module;
|
|
376
|
+
target = check.target;
|
|
394
377
|
action = check.action;
|
|
395
|
-
|
|
378
|
+
payload = check.payload;
|
|
396
379
|
}
|
|
397
380
|
}
|
|
398
|
-
if (
|
|
381
|
+
if (target === 'app') {
|
|
399
382
|
const storeActions = _connector__WEBPACK_IMPORTED_MODULE_0__["default"].getStoreActions();
|
|
400
383
|
const storeAction = storeActions[action];
|
|
401
384
|
if (!storeAction) {
|
|
402
385
|
const errorMessage = `action "${action}" is not present`;
|
|
403
386
|
const error = new _helper__WEBPACK_IMPORTED_MODULE_2__.VariousError({
|
|
404
|
-
|
|
387
|
+
module,
|
|
405
388
|
type: 'DISPATCH',
|
|
406
389
|
originalError: new Error(errorMessage)
|
|
407
390
|
});
|
|
408
391
|
(0,_helper__WEBPACK_IMPORTED_MODULE_2__.onError)(error);
|
|
409
392
|
throw error;
|
|
410
393
|
}
|
|
411
|
-
return (0,_store__WEBPACK_IMPORTED_MODULE_1__.dispatch)(storeAction,
|
|
394
|
+
return (0,_store__WEBPACK_IMPORTED_MODULE_1__.dispatch)(storeAction, payload, module);
|
|
412
395
|
}
|
|
413
|
-
const componentActions = _connector__WEBPACK_IMPORTED_MODULE_0__["default"].getComponentActions(
|
|
414
|
-
name,
|
|
415
|
-
module
|
|
416
|
-
});
|
|
396
|
+
const componentActions = _connector__WEBPACK_IMPORTED_MODULE_0__["default"].getComponentActions(target);
|
|
417
397
|
if (!componentActions) {
|
|
418
398
|
const errorMessage = 'component is not ready';
|
|
419
399
|
const error = new _helper__WEBPACK_IMPORTED_MODULE_2__.VariousError({
|
|
420
|
-
|
|
400
|
+
module,
|
|
421
401
|
type: 'DISPATCH',
|
|
422
402
|
originalError: new Error(errorMessage)
|
|
423
403
|
});
|
|
@@ -428,14 +408,17 @@ const createDispatch = moduleDefined => async function (params) {
|
|
|
428
408
|
if (!componentAction) {
|
|
429
409
|
const errorMessage = `action "${action}" is not present`;
|
|
430
410
|
const error = new _helper__WEBPACK_IMPORTED_MODULE_2__.VariousError({
|
|
431
|
-
|
|
411
|
+
module,
|
|
432
412
|
type: 'DISPATCH',
|
|
433
413
|
originalError: new Error(errorMessage)
|
|
434
414
|
});
|
|
435
415
|
(0,_helper__WEBPACK_IMPORTED_MODULE_2__.onError)(error);
|
|
436
416
|
throw error;
|
|
437
417
|
}
|
|
438
|
-
return Promise.resolve(componentAction(
|
|
418
|
+
return Promise.resolve(componentAction({
|
|
419
|
+
payload,
|
|
420
|
+
trigger: module
|
|
421
|
+
}));
|
|
439
422
|
};
|
|
440
423
|
/* harmony default export */ __webpack_exports__["default"] = (createDispatch);
|
|
441
424
|
|
|
@@ -465,13 +448,11 @@ class ErrorBoundary extends react__WEBPACK_IMPORTED_MODULE_0__.Component {
|
|
|
465
448
|
};
|
|
466
449
|
componentDidCatch(e) {
|
|
467
450
|
const {
|
|
468
|
-
name,
|
|
469
451
|
module
|
|
470
452
|
} = this.props;
|
|
471
453
|
const error = e instanceof _helper__WEBPACK_IMPORTED_MODULE_1__.VariousError ? e : new _helper__WEBPACK_IMPORTED_MODULE_1__.VariousError({
|
|
472
|
-
name,
|
|
473
454
|
module,
|
|
474
|
-
type:
|
|
455
|
+
type: module === 'app' ? 'APP_ERROR' : 'SCRIPT_ERROR',
|
|
475
456
|
originalError: e
|
|
476
457
|
});
|
|
477
458
|
this.setState({
|
|
@@ -479,11 +460,8 @@ class ErrorBoundary extends react__WEBPACK_IMPORTED_MODULE_0__.Component {
|
|
|
479
460
|
});
|
|
480
461
|
this.error = error;
|
|
481
462
|
(0,_helper__WEBPACK_IMPORTED_MODULE_1__.onError)(error);
|
|
482
|
-
(0,_helper__WEBPACK_IMPORTED_MODULE_1__.resetDependencyConfig)(
|
|
483
|
-
(0,_helper__WEBPACK_IMPORTED_MODULE_1__.updateUnMountComponent)(
|
|
484
|
-
name,
|
|
485
|
-
module
|
|
486
|
-
});
|
|
463
|
+
(0,_helper__WEBPACK_IMPORTED_MODULE_1__.resetDependencyConfig)(module);
|
|
464
|
+
(0,_helper__WEBPACK_IMPORTED_MODULE_1__.updateUnMountComponent)(module);
|
|
487
465
|
}
|
|
488
466
|
$self = (0,_helper__WEBPACK_IMPORTED_MODULE_1__.getSelfInfo)(this.props);
|
|
489
467
|
reload = () => {
|
|
@@ -525,8 +503,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
525
503
|
/* harmony export */ defineDependencies: function() { return /* binding */ defineDependencies; },
|
|
526
504
|
/* harmony export */ getClassNameWithModule: function() { return /* binding */ getClassNameWithModule; },
|
|
527
505
|
/* harmony export */ getConfig: function() { return /* binding */ getConfig; },
|
|
506
|
+
/* harmony export */ getModuleInfo: function() { return /* binding */ getModuleInfo; },
|
|
528
507
|
/* harmony export */ getMountedComponents: function() { return /* binding */ getMountedComponents; },
|
|
529
|
-
/* harmony export */ getNameWithModule: function() { return /* binding */ getNameWithModule; },
|
|
530
508
|
/* harmony export */ getSelfInfo: function() { return /* binding */ getSelfInfo; },
|
|
531
509
|
/* harmony export */ isModuleLoaded: function() { return /* binding */ isModuleLoaded; },
|
|
532
510
|
/* harmony export */ isModuleSpecified: function() { return /* binding */ isModuleSpecified; },
|
|
@@ -553,12 +531,22 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
553
531
|
|
|
554
532
|
|
|
555
533
|
const getUrlHash = url => `${url}?${+new Date()}`;
|
|
556
|
-
const
|
|
557
|
-
const
|
|
534
|
+
const getModuleInfo = module => {
|
|
535
|
+
const [name, entry] = module.split('.');
|
|
536
|
+
return {
|
|
537
|
+
name,
|
|
538
|
+
entry
|
|
539
|
+
};
|
|
540
|
+
};
|
|
541
|
+
const preloadModules = modules => new Promise((resolve, reject) => {
|
|
542
|
+
const names = modules.map(m => getModuleInfo(m).name);
|
|
558
543
|
window.requirejs(names, resolve, reject);
|
|
559
544
|
});
|
|
560
|
-
const removeLoadedModules =
|
|
561
|
-
|
|
545
|
+
const removeLoadedModules = modules => {
|
|
546
|
+
modules.forEach(module => {
|
|
547
|
+
const {
|
|
548
|
+
name
|
|
549
|
+
} = getModuleInfo(module);
|
|
562
550
|
if (!_config__WEBPACK_IMPORTED_MODULE_2__.BASE_DEPENDENCIES.includes(name)) {
|
|
563
551
|
window.requirejs.undef(name);
|
|
564
552
|
}
|
|
@@ -583,18 +571,27 @@ const defineDependencies = deps => {
|
|
|
583
571
|
}
|
|
584
572
|
}, true);
|
|
585
573
|
};
|
|
586
|
-
const isModuleLoaded =
|
|
587
|
-
const
|
|
574
|
+
const isModuleLoaded = module => {
|
|
575
|
+
const {
|
|
576
|
+
name
|
|
577
|
+
} = getModuleInfo(module);
|
|
578
|
+
return window.requirejs.defined(name);
|
|
579
|
+
};
|
|
580
|
+
const isModuleSpecified = module => {
|
|
581
|
+
const {
|
|
582
|
+
name
|
|
583
|
+
} = getModuleInfo(module);
|
|
584
|
+
return window.requirejs.specified(name);
|
|
585
|
+
};
|
|
588
586
|
const getMountedComponents = () => (0,_store__WEBPACK_IMPORTED_MODULE_0__.getStore)(_config__WEBPACK_IMPORTED_MODULE_2__.MOUNTED_COMPONENTS_KEY);
|
|
589
587
|
const onComponentMounted = (module, callback) => {
|
|
590
588
|
const modules = Array.isArray(module) ? module : [module];
|
|
591
|
-
if (modules.every(m =>
|
|
589
|
+
if (modules.every(m => getMountedComponents().includes(m))) {
|
|
592
590
|
callback();
|
|
593
591
|
}
|
|
594
592
|
const unSubscribe = (0,_store__WEBPACK_IMPORTED_MODULE_0__.subscribe)({
|
|
595
593
|
[_config__WEBPACK_IMPORTED_MODULE_2__.MOUNTED_COMPONENTS_KEY](value) {
|
|
596
|
-
|
|
597
|
-
if (modules.every(n => hasModule(mountedModules, n))) {
|
|
594
|
+
if (modules.every(n => value.includes(n))) {
|
|
598
595
|
unSubscribe();
|
|
599
596
|
callback();
|
|
600
597
|
}
|
|
@@ -602,7 +599,10 @@ const onComponentMounted = (module, callback) => {
|
|
|
602
599
|
});
|
|
603
600
|
return unSubscribe;
|
|
604
601
|
};
|
|
605
|
-
const resetDependencyConfig = (
|
|
602
|
+
const resetDependencyConfig = (module, url) => {
|
|
603
|
+
const {
|
|
604
|
+
name
|
|
605
|
+
} = getModuleInfo(module);
|
|
606
606
|
const dependencies = (0,_store__WEBPACK_IMPORTED_MODULE_0__.getStore)(_config__WEBPACK_IMPORTED_MODULE_2__.DEPENDENCIES_KEY);
|
|
607
607
|
|
|
608
608
|
// ignore multiple custom module url
|
|
@@ -628,26 +628,15 @@ const resetDependencyConfig = (name, url) => {
|
|
|
628
628
|
}
|
|
629
629
|
});
|
|
630
630
|
};
|
|
631
|
-
const getNameWithModule = moduleDefined => {
|
|
632
|
-
const {
|
|
633
|
-
name,
|
|
634
|
-
module
|
|
635
|
-
} = moduleDefined;
|
|
636
|
-
return module ? `${name}.${module}` : name;
|
|
637
|
-
};
|
|
638
631
|
function getConfig() {
|
|
639
632
|
return (0,_store__WEBPACK_IMPORTED_MODULE_0__.getStore)(_config__WEBPACK_IMPORTED_MODULE_2__.CONFIG_KEY);
|
|
640
633
|
}
|
|
641
634
|
const onError = e => {
|
|
642
635
|
const {
|
|
643
|
-
name,
|
|
644
636
|
module,
|
|
645
637
|
type
|
|
646
638
|
} = e;
|
|
647
|
-
const logger = (0,_logger__WEBPACK_IMPORTED_MODULE_1__["default"])(
|
|
648
|
-
name,
|
|
649
|
-
module
|
|
650
|
-
});
|
|
639
|
+
const logger = (0,_logger__WEBPACK_IMPORTED_MODULE_1__["default"])(module);
|
|
651
640
|
logger.error(e, type);
|
|
652
641
|
};
|
|
653
642
|
class VariousError extends Error {
|
|
@@ -656,17 +645,16 @@ class VariousError extends Error {
|
|
|
656
645
|
this.type = data.type;
|
|
657
646
|
this.originalError = data.originalError;
|
|
658
647
|
this.module = data.module;
|
|
659
|
-
this.name = data.name;
|
|
660
648
|
}
|
|
661
649
|
}
|
|
662
|
-
function checkReactComponent(component,
|
|
650
|
+
function checkReactComponent(component, module) {
|
|
663
651
|
return new Promise((reslove, reject) => {
|
|
664
652
|
if (component.$$typeof || component.prototype?.isReactComponent || typeof component === 'function') {
|
|
665
653
|
reslove();
|
|
666
654
|
return;
|
|
667
655
|
}
|
|
668
656
|
reject(new VariousError({
|
|
669
|
-
|
|
657
|
+
module,
|
|
670
658
|
originalError: new Error('not a valid React component'),
|
|
671
659
|
type: 'INVALID_COMPONENT'
|
|
672
660
|
}));
|
|
@@ -675,7 +663,7 @@ function checkReactComponent(component, moduleDefined) {
|
|
|
675
663
|
function isPromiseLike(value) {
|
|
676
664
|
return value != null && typeof value.then === 'function';
|
|
677
665
|
}
|
|
678
|
-
function checkVueComponent(component,
|
|
666
|
+
function checkVueComponent(component, module) {
|
|
679
667
|
const versionRegex = new RegExp(`^${_config__WEBPACK_IMPORTED_MODULE_2__.VUE_VERSION}\\.`);
|
|
680
668
|
return new Promise((resolve, reject) => {
|
|
681
669
|
window.requirejs(['vue'], Vue => {
|
|
@@ -687,7 +675,7 @@ function checkVueComponent(component, moduleDefined) {
|
|
|
687
675
|
return;
|
|
688
676
|
}
|
|
689
677
|
reject(new VariousError({
|
|
690
|
-
|
|
678
|
+
module,
|
|
691
679
|
originalError: new Error('not a valid Vue component'),
|
|
692
680
|
type: 'INVALID_COMPONENT'
|
|
693
681
|
}));
|
|
@@ -697,7 +685,6 @@ function checkVueComponent(component, moduleDefined) {
|
|
|
697
685
|
function parseComponentActions(params) {
|
|
698
686
|
const {
|
|
699
687
|
componentNode,
|
|
700
|
-
name,
|
|
701
688
|
module,
|
|
702
689
|
type,
|
|
703
690
|
i18nUpdate
|
|
@@ -723,66 +710,51 @@ function parseComponentActions(params) {
|
|
|
723
710
|
actions[method] = componentNode[method];
|
|
724
711
|
});
|
|
725
712
|
if (i18nAction) {
|
|
726
|
-
(0,_i18n__WEBPACK_IMPORTED_MODULE_5__.createI18nConfig)(i18nAction,
|
|
727
|
-
name,
|
|
728
|
-
module
|
|
729
|
-
}, i18nUpdate);
|
|
713
|
+
(0,_i18n__WEBPACK_IMPORTED_MODULE_5__.createI18nConfig)(i18nAction, module, i18nUpdate);
|
|
730
714
|
}
|
|
731
|
-
_connector__WEBPACK_IMPORTED_MODULE_3__["default"].setComponentActions(
|
|
732
|
-
name,
|
|
733
|
-
module
|
|
734
|
-
}, actions);
|
|
715
|
+
_connector__WEBPACK_IMPORTED_MODULE_3__["default"].setComponentActions(module, actions);
|
|
735
716
|
if (onMessageAction) {
|
|
736
|
-
return (0,_message__WEBPACK_IMPORTED_MODULE_4__.createOnMessage)(
|
|
737
|
-
name,
|
|
738
|
-
module
|
|
739
|
-
}, onMessageAction);
|
|
717
|
+
return (0,_message__WEBPACK_IMPORTED_MODULE_4__.createOnMessage)(module, onMessageAction);
|
|
740
718
|
}
|
|
741
719
|
return () => null;
|
|
742
720
|
}
|
|
743
|
-
function updateMountedComponent(
|
|
721
|
+
function updateMountedComponent(module) {
|
|
744
722
|
const mountedComponents = getMountedComponents();
|
|
745
|
-
if (!
|
|
746
|
-
mountedComponents.push(
|
|
723
|
+
if (!mountedComponents.includes(module)) {
|
|
724
|
+
mountedComponents.push(module);
|
|
747
725
|
}
|
|
748
726
|
(0,_store__WEBPACK_IMPORTED_MODULE_0__.emit)({
|
|
749
727
|
[_config__WEBPACK_IMPORTED_MODULE_2__.MOUNTED_COMPONENTS_KEY]: mountedComponents
|
|
750
728
|
}, true);
|
|
751
729
|
}
|
|
752
|
-
function updateUnMountComponent(
|
|
753
|
-
const {
|
|
754
|
-
name,
|
|
755
|
-
module
|
|
756
|
-
} = moduleDefined;
|
|
730
|
+
function updateUnMountComponent(module) {
|
|
757
731
|
let mountedComponents = getMountedComponents();
|
|
758
|
-
mountedComponents = mountedComponents.filter(item => item
|
|
732
|
+
mountedComponents = mountedComponents.filter(item => item !== module);
|
|
759
733
|
(0,_store__WEBPACK_IMPORTED_MODULE_0__.emit)({
|
|
760
734
|
[_config__WEBPACK_IMPORTED_MODULE_2__.MOUNTED_COMPONENTS_KEY]: mountedComponents
|
|
761
735
|
}, true);
|
|
762
|
-
_connector__WEBPACK_IMPORTED_MODULE_3__["default"].deleteComponentActions(
|
|
763
|
-
name,
|
|
764
|
-
module
|
|
765
|
-
});
|
|
736
|
+
_connector__WEBPACK_IMPORTED_MODULE_3__["default"].deleteComponentActions(module);
|
|
766
737
|
}
|
|
767
738
|
function getSelfInfo(params) {
|
|
768
739
|
const {
|
|
769
|
-
name,
|
|
770
740
|
module,
|
|
771
741
|
url
|
|
772
742
|
} = params;
|
|
773
743
|
const dependencies = (0,_store__WEBPACK_IMPORTED_MODULE_0__.getStore)(_config__WEBPACK_IMPORTED_MODULE_2__.DEPENDENCIES_KEY);
|
|
744
|
+
const {
|
|
745
|
+
name
|
|
746
|
+
} = getModuleInfo(module);
|
|
774
747
|
return {
|
|
775
|
-
name,
|
|
776
748
|
module,
|
|
777
749
|
url: url || dependencies[name]
|
|
778
750
|
};
|
|
779
751
|
}
|
|
780
|
-
function getClassNameWithModule(
|
|
752
|
+
function getClassNameWithModule(module, prefix) {
|
|
781
753
|
const {
|
|
782
754
|
name,
|
|
783
|
-
|
|
784
|
-
} =
|
|
785
|
-
return `${prefix} ${[name,
|
|
755
|
+
entry
|
|
756
|
+
} = getModuleInfo(module);
|
|
757
|
+
return `${prefix} ${[name, entry].filter(Boolean).join('-')}`;
|
|
786
758
|
}
|
|
787
759
|
|
|
788
760
|
/***/ }),
|
|
@@ -805,21 +777,21 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
805
777
|
|
|
806
778
|
|
|
807
779
|
|
|
808
|
-
function createI18nConfig(method,
|
|
780
|
+
function createI18nConfig(method, module, callback) {
|
|
809
781
|
if (!method) {
|
|
810
782
|
return;
|
|
811
783
|
}
|
|
812
784
|
const i18nConfig = method();
|
|
813
785
|
if (!(0,_helper__WEBPACK_IMPORTED_MODULE_1__.isPromiseLike)(i18nConfig)) {
|
|
814
|
-
if (
|
|
815
|
-
_connector__WEBPACK_IMPORTED_MODULE_0__["default"].setI18nConfig(
|
|
786
|
+
if (module) {
|
|
787
|
+
_connector__WEBPACK_IMPORTED_MODULE_0__["default"].setI18nConfig(module, i18nConfig);
|
|
816
788
|
} else {
|
|
817
789
|
_connector__WEBPACK_IMPORTED_MODULE_0__["default"].setGlobalI18nConfig(i18nConfig);
|
|
818
790
|
}
|
|
819
791
|
return;
|
|
820
792
|
}
|
|
821
|
-
if (
|
|
822
|
-
_connector__WEBPACK_IMPORTED_MODULE_0__["default"].setI18nConfig(
|
|
793
|
+
if (module) {
|
|
794
|
+
_connector__WEBPACK_IMPORTED_MODULE_0__["default"].setI18nConfig(module, {
|
|
823
795
|
loading: true,
|
|
824
796
|
lngStoreKey: '',
|
|
825
797
|
resources: {}
|
|
@@ -832,8 +804,8 @@ function createI18nConfig(method, moduleDefined, callback) {
|
|
|
832
804
|
});
|
|
833
805
|
}
|
|
834
806
|
i18nConfig.then(res => {
|
|
835
|
-
if (
|
|
836
|
-
_connector__WEBPACK_IMPORTED_MODULE_0__["default"].setI18nConfig(
|
|
807
|
+
if (module) {
|
|
808
|
+
_connector__WEBPACK_IMPORTED_MODULE_0__["default"].setI18nConfig(module, {
|
|
837
809
|
...res,
|
|
838
810
|
loading: false
|
|
839
811
|
});
|
|
@@ -853,23 +825,22 @@ function createI18nConfig(method, moduleDefined, callback) {
|
|
|
853
825
|
});
|
|
854
826
|
}).catch(e => {
|
|
855
827
|
(0,_helper__WEBPACK_IMPORTED_MODULE_1__.onError)(new _helper__WEBPACK_IMPORTED_MODULE_1__.VariousError({
|
|
856
|
-
|
|
857
|
-
module: moduleDefined?.module,
|
|
828
|
+
module: module || 'app',
|
|
858
829
|
type: 'I18N',
|
|
859
830
|
originalError: e
|
|
860
831
|
}));
|
|
861
832
|
});
|
|
862
833
|
}
|
|
863
|
-
function createI18n(
|
|
834
|
+
function createI18n(module, updater) {
|
|
864
835
|
const ctx = (key, params, defaultString) => {
|
|
865
|
-
const i18nConfig = _connector__WEBPACK_IMPORTED_MODULE_0__["default"].getI18nConfig(
|
|
836
|
+
const i18nConfig = _connector__WEBPACK_IMPORTED_MODULE_0__["default"].getI18nConfig(module) || _connector__WEBPACK_IMPORTED_MODULE_0__["default"].getGlobalI18nConfig();
|
|
866
837
|
let defaultText = defaultString;
|
|
867
838
|
if (defaultText === undefined) {
|
|
868
839
|
defaultText = typeof params === 'string' ? params : key;
|
|
869
840
|
}
|
|
870
841
|
if (!i18nConfig) {
|
|
871
842
|
(0,_helper__WEBPACK_IMPORTED_MODULE_1__.onError)(new _helper__WEBPACK_IMPORTED_MODULE_1__.VariousError({
|
|
872
|
-
|
|
843
|
+
module,
|
|
873
844
|
type: 'I18N',
|
|
874
845
|
originalError: new Error('config not exist')
|
|
875
846
|
}));
|
|
@@ -885,7 +856,7 @@ function createI18n(moduleDefined, updater) {
|
|
|
885
856
|
const locale = (0,_store__WEBPACK_IMPORTED_MODULE_2__.getStore)(lngStoreKey);
|
|
886
857
|
if (lngStoreKey === undefined || locale === undefined) {
|
|
887
858
|
(0,_helper__WEBPACK_IMPORTED_MODULE_1__.onError)(new _helper__WEBPACK_IMPORTED_MODULE_1__.VariousError({
|
|
888
|
-
|
|
859
|
+
module,
|
|
889
860
|
type: 'I18N',
|
|
890
861
|
originalError: new Error('locale key not defined')
|
|
891
862
|
}));
|
|
@@ -894,7 +865,7 @@ function createI18n(moduleDefined, updater) {
|
|
|
894
865
|
const resource = resources?.[locale];
|
|
895
866
|
if (!resource) {
|
|
896
867
|
(0,_helper__WEBPACK_IMPORTED_MODULE_1__.onError)(new _helper__WEBPACK_IMPORTED_MODULE_1__.VariousError({
|
|
897
|
-
|
|
868
|
+
module,
|
|
898
869
|
type: 'I18N',
|
|
899
870
|
originalError: new Error(`locale resource \`${locale}\` not exist`)
|
|
900
871
|
}));
|
|
@@ -902,7 +873,7 @@ function createI18n(moduleDefined, updater) {
|
|
|
902
873
|
}
|
|
903
874
|
if (!resource[key]) {
|
|
904
875
|
(0,_helper__WEBPACK_IMPORTED_MODULE_1__.onError)(new _helper__WEBPACK_IMPORTED_MODULE_1__.VariousError({
|
|
905
|
-
|
|
876
|
+
module,
|
|
906
877
|
type: 'I18N',
|
|
907
878
|
originalError: new Error(`locale key \`${key}\` not exist`)
|
|
908
879
|
}));
|
|
@@ -922,7 +893,7 @@ function createI18n(moduleDefined, updater) {
|
|
|
922
893
|
}, text);
|
|
923
894
|
};
|
|
924
895
|
ctx.update = (config, type) => {
|
|
925
|
-
const i18nConfig = type === 'app' ? _connector__WEBPACK_IMPORTED_MODULE_0__["default"].getGlobalI18nConfig() : _connector__WEBPACK_IMPORTED_MODULE_0__["default"].getI18nConfig(
|
|
896
|
+
const i18nConfig = type === 'app' ? _connector__WEBPACK_IMPORTED_MODULE_0__["default"].getGlobalI18nConfig() : _connector__WEBPACK_IMPORTED_MODULE_0__["default"].getI18nConfig(module);
|
|
926
897
|
const next = {
|
|
927
898
|
...i18nConfig,
|
|
928
899
|
...config
|
|
@@ -930,7 +901,7 @@ function createI18n(moduleDefined, updater) {
|
|
|
930
901
|
if (type === 'app') {
|
|
931
902
|
_connector__WEBPACK_IMPORTED_MODULE_0__["default"].setGlobalI18nConfig(next);
|
|
932
903
|
} else {
|
|
933
|
-
_connector__WEBPACK_IMPORTED_MODULE_0__["default"].setI18nConfig(
|
|
904
|
+
_connector__WEBPACK_IMPORTED_MODULE_0__["default"].setI18nConfig(module, next);
|
|
934
905
|
}
|
|
935
906
|
updater();
|
|
936
907
|
};
|
|
@@ -963,7 +934,7 @@ const logger = args => {
|
|
|
963
934
|
error: 'red'
|
|
964
935
|
};
|
|
965
936
|
const color = colorMap[args.level];
|
|
966
|
-
const params = [`%c ${
|
|
937
|
+
const params = [`%c ${args.module} `, `background:${color};border:1px solid ${color};padding:1px;border-radius:2px 0 0 2px;color: #fff;`];
|
|
967
938
|
if (args.type) {
|
|
968
939
|
params[0] = `${params[0]}%c ${args.type} %c`;
|
|
969
940
|
params.push(`border:1px solid ${color};padding:1px;border-radius:0 2px 2px 0;color:${color};`, 'background:transparent');
|
|
@@ -973,10 +944,10 @@ const logger = args => {
|
|
|
973
944
|
}
|
|
974
945
|
window.console[args.level](...params, args.message);
|
|
975
946
|
};
|
|
976
|
-
const createLogger =
|
|
947
|
+
const createLogger = module => ({
|
|
977
948
|
info(message, type) {
|
|
978
949
|
logger({
|
|
979
|
-
|
|
950
|
+
module,
|
|
980
951
|
level: 'info',
|
|
981
952
|
type,
|
|
982
953
|
message
|
|
@@ -984,7 +955,7 @@ const createLogger = moduleDefined => ({
|
|
|
984
955
|
},
|
|
985
956
|
warn(message, type) {
|
|
986
957
|
logger({
|
|
987
|
-
|
|
958
|
+
module,
|
|
988
959
|
level: 'warn',
|
|
989
960
|
type,
|
|
990
961
|
message
|
|
@@ -993,13 +964,13 @@ const createLogger = moduleDefined => ({
|
|
|
993
964
|
error(message, type) {
|
|
994
965
|
const middlewares = _connector__WEBPACK_IMPORTED_MODULE_0__["default"].getMiddlewares();
|
|
995
966
|
const error = message instanceof _helper__WEBPACK_IMPORTED_MODULE_1__.VariousError ? message : new _helper__WEBPACK_IMPORTED_MODULE_1__.VariousError({
|
|
996
|
-
|
|
967
|
+
module,
|
|
997
968
|
type: type || 'unknow',
|
|
998
969
|
originalError: message instanceof Error ? message : new Error(message)
|
|
999
970
|
});
|
|
1000
971
|
middlewares?.onError?.(error);
|
|
1001
972
|
logger({
|
|
1002
|
-
|
|
973
|
+
module,
|
|
1003
974
|
level: 'error',
|
|
1004
975
|
type,
|
|
1005
976
|
message
|
|
@@ -1030,13 +1001,16 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1030
1001
|
|
|
1031
1002
|
|
|
1032
1003
|
|
|
1033
|
-
const createPostMessage =
|
|
1004
|
+
const createPostMessage = module => async ({
|
|
1005
|
+
event,
|
|
1006
|
+
payload
|
|
1007
|
+
}) => {
|
|
1034
1008
|
const middlewares = _connector__WEBPACK_IMPORTED_MODULE_0__["default"].getMiddlewares();
|
|
1035
|
-
const logger = (0,_logger__WEBPACK_IMPORTED_MODULE_1__["default"])(
|
|
1009
|
+
const logger = (0,_logger__WEBPACK_IMPORTED_MODULE_1__["default"])(module);
|
|
1036
1010
|
let next = {
|
|
1037
|
-
trigger:
|
|
1011
|
+
trigger: module,
|
|
1038
1012
|
event,
|
|
1039
|
-
|
|
1013
|
+
payload
|
|
1040
1014
|
};
|
|
1041
1015
|
if (middlewares?.onMessage) {
|
|
1042
1016
|
const check = await middlewares.onMessage(next);
|
|
@@ -1055,22 +1029,22 @@ const createPostMessage = moduleDefined => async (event, value) => {
|
|
|
1055
1029
|
[_config__WEBPACK_IMPORTED_MODULE_3__.MESSAGE_KEY]: {
|
|
1056
1030
|
timestamp: +new Date(),
|
|
1057
1031
|
event: next.event,
|
|
1058
|
-
trigger:
|
|
1059
|
-
|
|
1032
|
+
trigger: module,
|
|
1033
|
+
payload: next.payload
|
|
1060
1034
|
}
|
|
1061
1035
|
});
|
|
1062
1036
|
};
|
|
1063
|
-
const createOnMessage = (
|
|
1037
|
+
const createOnMessage = (module, onMessage) => (0,_store__WEBPACK_IMPORTED_MODULE_2__.subscribe)({
|
|
1064
1038
|
[_config__WEBPACK_IMPORTED_MODULE_3__.MESSAGE_KEY](v) {
|
|
1065
1039
|
const {
|
|
1066
1040
|
trigger,
|
|
1067
|
-
|
|
1041
|
+
payload,
|
|
1068
1042
|
event
|
|
1069
1043
|
} = v;
|
|
1070
|
-
if (
|
|
1044
|
+
if (module !== trigger) {
|
|
1071
1045
|
onMessage({
|
|
1072
1046
|
event,
|
|
1073
|
-
|
|
1047
|
+
payload,
|
|
1074
1048
|
trigger
|
|
1075
1049
|
});
|
|
1076
1050
|
}
|
|
@@ -1110,7 +1084,6 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1110
1084
|
|
|
1111
1085
|
function reactComponent(config) {
|
|
1112
1086
|
const {
|
|
1113
|
-
name,
|
|
1114
1087
|
module,
|
|
1115
1088
|
url,
|
|
1116
1089
|
watchKeys,
|
|
@@ -1133,36 +1106,22 @@ function reactComponent(config) {
|
|
|
1133
1106
|
this.ComponentNode = null;
|
|
1134
1107
|
this.isUnMounted = true;
|
|
1135
1108
|
this.unSubscribeMessage();
|
|
1136
|
-
(0,_helper__WEBPACK_IMPORTED_MODULE_2__.updateUnMountComponent)(
|
|
1137
|
-
name,
|
|
1138
|
-
module
|
|
1139
|
-
});
|
|
1109
|
+
(0,_helper__WEBPACK_IMPORTED_MODULE_2__.updateUnMountComponent)(module);
|
|
1140
1110
|
}
|
|
1141
1111
|
mountComponent = async () => {
|
|
1142
1112
|
try {
|
|
1143
1113
|
const componentNode = await (0,_create_module__WEBPACK_IMPORTED_MODULE_9__["default"])({
|
|
1144
|
-
name,
|
|
1145
1114
|
module,
|
|
1146
1115
|
url
|
|
1147
1116
|
}, false);
|
|
1148
1117
|
if (this.isUnMounted) {
|
|
1149
1118
|
return;
|
|
1150
1119
|
}
|
|
1151
|
-
await (0,_helper__WEBPACK_IMPORTED_MODULE_2__.checkReactComponent)(componentNode,
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
});
|
|
1155
|
-
componentNode.displayName = (0,_helper__WEBPACK_IMPORTED_MODULE_2__.getNameWithModule)({
|
|
1156
|
-
name,
|
|
1157
|
-
module
|
|
1158
|
-
});
|
|
1159
|
-
(0,_helper__WEBPACK_IMPORTED_MODULE_2__.updateMountedComponent)({
|
|
1160
|
-
name,
|
|
1161
|
-
module
|
|
1162
|
-
});
|
|
1120
|
+
await (0,_helper__WEBPACK_IMPORTED_MODULE_2__.checkReactComponent)(componentNode, module);
|
|
1121
|
+
componentNode.displayName = module;
|
|
1122
|
+
(0,_helper__WEBPACK_IMPORTED_MODULE_2__.updateMountedComponent)(module);
|
|
1163
1123
|
this.unSubscribeMessage = (0,_helper__WEBPACK_IMPORTED_MODULE_2__.parseComponentActions)({
|
|
1164
1124
|
componentNode,
|
|
1165
|
-
name,
|
|
1166
1125
|
module,
|
|
1167
1126
|
i18nUpdate: () => this.forceUpdate()
|
|
1168
1127
|
});
|
|
@@ -1182,24 +1141,11 @@ function reactComponent(config) {
|
|
|
1182
1141
|
});
|
|
1183
1142
|
}
|
|
1184
1143
|
};
|
|
1185
|
-
$postMessage = (0,_message__WEBPACK_IMPORTED_MODULE_5__.createPostMessage)(
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
$dispatch = (0,_dispatch__WEBPACK_IMPORTED_MODULE_6__["default"])({
|
|
1190
|
-
name,
|
|
1191
|
-
module
|
|
1192
|
-
});
|
|
1193
|
-
$t = (0,_i18n__WEBPACK_IMPORTED_MODULE_8__.createI18n)({
|
|
1194
|
-
name,
|
|
1195
|
-
module
|
|
1196
|
-
}, () => this.forceUpdate());
|
|
1197
|
-
$logger = (0,_logger__WEBPACK_IMPORTED_MODULE_7__["default"])({
|
|
1198
|
-
name,
|
|
1199
|
-
module
|
|
1200
|
-
});
|
|
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);
|
|
1201
1148
|
$self = (0,_helper__WEBPACK_IMPORTED_MODULE_2__.getSelfInfo)({
|
|
1202
|
-
name,
|
|
1203
1149
|
module,
|
|
1204
1150
|
url
|
|
1205
1151
|
});
|
|
@@ -1220,7 +1166,7 @@ function reactComponent(config) {
|
|
|
1220
1166
|
throw this.error;
|
|
1221
1167
|
}
|
|
1222
1168
|
if (!componentReady) {
|
|
1223
|
-
if ($silent || (0,_helper__WEBPACK_IMPORTED_MODULE_2__.isModuleLoaded)(
|
|
1169
|
+
if ($silent || (0,_helper__WEBPACK_IMPORTED_MODULE_2__.isModuleLoaded)(module)) {
|
|
1224
1170
|
return null;
|
|
1225
1171
|
}
|
|
1226
1172
|
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(Fallback, {
|
|
@@ -1269,7 +1215,6 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1269
1215
|
|
|
1270
1216
|
|
|
1271
1217
|
const renderComponent = async ({
|
|
1272
|
-
name,
|
|
1273
1218
|
module,
|
|
1274
1219
|
url,
|
|
1275
1220
|
target,
|
|
@@ -1280,10 +1225,9 @@ const renderComponent = async ({
|
|
|
1280
1225
|
}) => {
|
|
1281
1226
|
try {
|
|
1282
1227
|
const ReactDOM = await (0,_create_module__WEBPACK_IMPORTED_MODULE_5__["default"])({
|
|
1283
|
-
|
|
1228
|
+
module: 'react-dom'
|
|
1284
1229
|
});
|
|
1285
1230
|
const C = (type === 'vue3' ? _vue_component__WEBPACK_IMPORTED_MODULE_2__["default"] : _react_component__WEBPACK_IMPORTED_MODULE_1__["default"])({
|
|
1286
|
-
name,
|
|
1287
1231
|
module,
|
|
1288
1232
|
url,
|
|
1289
1233
|
onMounted
|
|
@@ -1300,7 +1244,6 @@ const renderComponent = async ({
|
|
|
1300
1244
|
$ref
|
|
1301
1245
|
};
|
|
1302
1246
|
const node = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_error_boundary__WEBPACK_IMPORTED_MODULE_4__["default"], {
|
|
1303
|
-
name: name,
|
|
1304
1247
|
module: module,
|
|
1305
1248
|
url: url
|
|
1306
1249
|
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(C, nextProps));
|
|
@@ -1313,7 +1256,6 @@ const renderComponent = async ({
|
|
|
1313
1256
|
});
|
|
1314
1257
|
} catch (e) {
|
|
1315
1258
|
const error = new _helper__WEBPACK_IMPORTED_MODULE_3__.VariousError({
|
|
1316
|
-
name,
|
|
1317
1259
|
module,
|
|
1318
1260
|
type: 'SCRIPT_ERROR',
|
|
1319
1261
|
originalError: e
|
|
@@ -1397,7 +1339,6 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1397
1339
|
|
|
1398
1340
|
function vueComponent(config) {
|
|
1399
1341
|
const {
|
|
1400
|
-
name,
|
|
1401
1342
|
module,
|
|
1402
1343
|
url,
|
|
1403
1344
|
watchKeys,
|
|
@@ -1413,7 +1354,6 @@ function vueComponent(config) {
|
|
|
1413
1354
|
const isUnMountedRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(false);
|
|
1414
1355
|
const ComponentNodeRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)();
|
|
1415
1356
|
const selfRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)((0,_helper__WEBPACK_IMPORTED_MODULE_4__.getSelfInfo)({
|
|
1416
|
-
name,
|
|
1417
1357
|
module,
|
|
1418
1358
|
url
|
|
1419
1359
|
}));
|
|
@@ -1431,22 +1371,10 @@ function vueComponent(config) {
|
|
|
1431
1371
|
$componentProps
|
|
1432
1372
|
} = props;
|
|
1433
1373
|
const mountVue = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(() => {
|
|
1434
|
-
const $logger = (0,_logger__WEBPACK_IMPORTED_MODULE_6__["default"])(
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
const $dispatch = (0,_dispatch__WEBPACK_IMPORTED_MODULE_5__["default"])({
|
|
1439
|
-
name,
|
|
1440
|
-
module
|
|
1441
|
-
});
|
|
1442
|
-
const $postMessage = (0,_message__WEBPACK_IMPORTED_MODULE_7__.createPostMessage)({
|
|
1443
|
-
name,
|
|
1444
|
-
module
|
|
1445
|
-
});
|
|
1446
|
-
const $t = (0,_i18n__WEBPACK_IMPORTED_MODULE_8__.createI18n)({
|
|
1447
|
-
name,
|
|
1448
|
-
module
|
|
1449
|
-
}, () => {
|
|
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, () => {
|
|
1450
1378
|
updateVueComponentRef.current?.();
|
|
1451
1379
|
});
|
|
1452
1380
|
propsReactiveRef.current = vueRef.current.ref({
|
|
@@ -1469,7 +1397,6 @@ function vueComponent(config) {
|
|
|
1469
1397
|
const error = e;
|
|
1470
1398
|
errorRef.current = error.message?.includes('https://react') ? new _helper__WEBPACK_IMPORTED_MODULE_4__.VariousError({
|
|
1471
1399
|
originalError: new Error('not a valid Vue component'),
|
|
1472
|
-
name,
|
|
1473
1400
|
module,
|
|
1474
1401
|
type: 'INVALID_COMPONENT'
|
|
1475
1402
|
}) : error;
|
|
@@ -1502,28 +1429,20 @@ function vueComponent(config) {
|
|
|
1502
1429
|
const mountComponent = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(async () => {
|
|
1503
1430
|
try {
|
|
1504
1431
|
const vue = await (0,_create_module__WEBPACK_IMPORTED_MODULE_2__["default"])({
|
|
1505
|
-
|
|
1432
|
+
module: 'vue'
|
|
1506
1433
|
});
|
|
1507
1434
|
vueRef.current = vue;
|
|
1508
1435
|
const componentNode = await (0,_create_module__WEBPACK_IMPORTED_MODULE_2__["default"])({
|
|
1509
|
-
name,
|
|
1510
1436
|
module,
|
|
1511
1437
|
url
|
|
1512
1438
|
}, false);
|
|
1513
1439
|
if (isUnMountedRef.current) {
|
|
1514
1440
|
return;
|
|
1515
1441
|
}
|
|
1516
|
-
await (0,_helper__WEBPACK_IMPORTED_MODULE_4__.checkVueComponent)(componentNode,
|
|
1517
|
-
|
|
1518
|
-
module
|
|
1519
|
-
});
|
|
1520
|
-
(0,_helper__WEBPACK_IMPORTED_MODULE_4__.updateMountedComponent)({
|
|
1521
|
-
name,
|
|
1522
|
-
module
|
|
1523
|
-
});
|
|
1442
|
+
await (0,_helper__WEBPACK_IMPORTED_MODULE_4__.checkVueComponent)(componentNode, module);
|
|
1443
|
+
(0,_helper__WEBPACK_IMPORTED_MODULE_4__.updateMountedComponent)(module);
|
|
1524
1444
|
unSubscribeMessageRef.current = (0,_helper__WEBPACK_IMPORTED_MODULE_4__.parseComponentActions)({
|
|
1525
1445
|
componentNode,
|
|
1526
|
-
name,
|
|
1527
1446
|
module,
|
|
1528
1447
|
type: 'vue3',
|
|
1529
1448
|
i18nUpdate() {
|
|
@@ -1550,10 +1469,7 @@ function vueComponent(config) {
|
|
|
1550
1469
|
errorRef.current = undefined;
|
|
1551
1470
|
ComponentNodeRef.current = undefined;
|
|
1552
1471
|
isUnMountedRef.current = true;
|
|
1553
|
-
(0,_helper__WEBPACK_IMPORTED_MODULE_4__.updateUnMountComponent)(
|
|
1554
|
-
name,
|
|
1555
|
-
module
|
|
1556
|
-
});
|
|
1472
|
+
(0,_helper__WEBPACK_IMPORTED_MODULE_4__.updateUnMountComponent)(module);
|
|
1557
1473
|
unMountVue.current?.();
|
|
1558
1474
|
unSubscribeMessageRef.current?.();
|
|
1559
1475
|
isVueMounted.current = false;
|
|
@@ -1582,21 +1498,15 @@ function vueComponent(config) {
|
|
|
1582
1498
|
if (isError) {
|
|
1583
1499
|
throw errorRef.current;
|
|
1584
1500
|
}
|
|
1585
|
-
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)(
|
|
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, {
|
|
1586
1502
|
$self: selfRef.current,
|
|
1587
1503
|
$store: store
|
|
1588
1504
|
}) : null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
1589
|
-
className: (0,_helper__WEBPACK_IMPORTED_MODULE_4__.getClassNameWithModule)(
|
|
1590
|
-
name,
|
|
1591
|
-
module
|
|
1592
|
-
}, 'various-vue-component'),
|
|
1505
|
+
className: (0,_helper__WEBPACK_IMPORTED_MODULE_4__.getClassNameWithModule)(module, 'various-vue-component'),
|
|
1593
1506
|
ref: containerDivRef
|
|
1594
1507
|
}));
|
|
1595
1508
|
};
|
|
1596
|
-
V.displayName =
|
|
1597
|
-
name,
|
|
1598
|
-
module
|
|
1599
|
-
});
|
|
1509
|
+
V.displayName = module;
|
|
1600
1510
|
const VueComponent = props => /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(V, props);
|
|
1601
1511
|
VueComponent.displayName = 'various-vue-component';
|
|
1602
1512
|
return VueComponent;
|
|
@@ -1628,6 +1538,12 @@ module.exports = __WEBPACK_EXTERNAL_MODULE_react__;
|
|
|
1628
1538
|
/******/ if (cachedModule !== undefined) {
|
|
1629
1539
|
/******/ return cachedModule.exports;
|
|
1630
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
|
+
/******/ }
|
|
1631
1547
|
/******/ // Create a new module (and put it into the cache)
|
|
1632
1548
|
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
1633
1549
|
/******/ // no module.id needed
|
|
@@ -1702,6 +1618,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1702
1618
|
/* harmony export */ defineDependencies: function() { return /* reexport safe */ _helper__WEBPACK_IMPORTED_MODULE_11__.defineDependencies; },
|
|
1703
1619
|
/* harmony export */ getApp: function() { return /* binding */ getApp; },
|
|
1704
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; },
|
|
1705
1622
|
/* harmony export */ getMountedComponents: function() { return /* reexport safe */ _helper__WEBPACK_IMPORTED_MODULE_11__.getMountedComponents; },
|
|
1706
1623
|
/* harmony export */ getStore: function() { return /* reexport safe */ _store__WEBPACK_IMPORTED_MODULE_1__.getUserStore; },
|
|
1707
1624
|
/* harmony export */ isModuleLoaded: function() { return /* reexport safe */ _helper__WEBPACK_IMPORTED_MODULE_11__.isModuleLoaded; },
|
|
@@ -1746,7 +1663,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1746
1663
|
|
|
1747
1664
|
|
|
1748
1665
|
// eslint-disable-next-line no-undef
|
|
1749
|
-
const version = "5.1
|
|
1666
|
+
const version = "5.2.1";
|
|
1750
1667
|
const getApp = config => {
|
|
1751
1668
|
const {
|
|
1752
1669
|
dependencies,
|
|
@@ -1784,7 +1701,7 @@ const getApp = config => {
|
|
|
1784
1701
|
}
|
|
1785
1702
|
render() {
|
|
1786
1703
|
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_error_boundary__WEBPACK_IMPORTED_MODULE_6__["default"], {
|
|
1787
|
-
|
|
1704
|
+
module: "app",
|
|
1788
1705
|
url: dependencies.app
|
|
1789
1706
|
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Root, null));
|
|
1790
1707
|
}
|