@variousjs/various 5.1.4 → 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.dev.js +172 -267
- 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 +11 -5
- 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 +398 -297
- package/dist/standalone.js.map +1 -1
- package/index.d.ts +166 -77
- package/package.json +38 -33
- package/standalone.d.ts +30 -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
|
|
@@ -618,20 +618,8 @@ const resetDependencyConfig = (name, url) => {
|
|
|
618
618
|
return;
|
|
619
619
|
}
|
|
620
620
|
let path = getUrlHash(dependencies[name]);
|
|
621
|
-
|
|
622
|
-
// custom module url, but module loaded error
|
|
623
621
|
if (url) {
|
|
624
|
-
path = `${url}#${name}
|
|
625
|
-
try {
|
|
626
|
-
const {
|
|
627
|
-
registry
|
|
628
|
-
} = window.requirejs.s.contexts._;
|
|
629
|
-
if (registry?.[name].error) {
|
|
630
|
-
path = getUrlHash(url);
|
|
631
|
-
}
|
|
632
|
-
} catch (e) {
|
|
633
|
-
// ignore
|
|
634
|
-
}
|
|
622
|
+
path = getUrlHash(`${url}#${name}`);
|
|
635
623
|
}
|
|
636
624
|
window.requirejs.undef(name);
|
|
637
625
|
window.requirejs.config({
|
|
@@ -640,26 +628,15 @@ const resetDependencyConfig = (name, url) => {
|
|
|
640
628
|
}
|
|
641
629
|
});
|
|
642
630
|
};
|
|
643
|
-
const getNameWithModule = moduleDefined => {
|
|
644
|
-
const {
|
|
645
|
-
name,
|
|
646
|
-
module
|
|
647
|
-
} = moduleDefined;
|
|
648
|
-
return module ? `${name}.${module}` : name;
|
|
649
|
-
};
|
|
650
631
|
function getConfig() {
|
|
651
632
|
return (0,_store__WEBPACK_IMPORTED_MODULE_0__.getStore)(_config__WEBPACK_IMPORTED_MODULE_2__.CONFIG_KEY);
|
|
652
633
|
}
|
|
653
634
|
const onError = e => {
|
|
654
635
|
const {
|
|
655
|
-
name,
|
|
656
636
|
module,
|
|
657
637
|
type
|
|
658
638
|
} = e;
|
|
659
|
-
const logger = (0,_logger__WEBPACK_IMPORTED_MODULE_1__["default"])(
|
|
660
|
-
name,
|
|
661
|
-
module
|
|
662
|
-
});
|
|
639
|
+
const logger = (0,_logger__WEBPACK_IMPORTED_MODULE_1__["default"])(module);
|
|
663
640
|
logger.error(e, type);
|
|
664
641
|
};
|
|
665
642
|
class VariousError extends Error {
|
|
@@ -668,17 +645,16 @@ class VariousError extends Error {
|
|
|
668
645
|
this.type = data.type;
|
|
669
646
|
this.originalError = data.originalError;
|
|
670
647
|
this.module = data.module;
|
|
671
|
-
this.name = data.name;
|
|
672
648
|
}
|
|
673
649
|
}
|
|
674
|
-
function checkReactComponent(component,
|
|
650
|
+
function checkReactComponent(component, module) {
|
|
675
651
|
return new Promise((reslove, reject) => {
|
|
676
652
|
if (component.$$typeof || component.prototype?.isReactComponent || typeof component === 'function') {
|
|
677
653
|
reslove();
|
|
678
654
|
return;
|
|
679
655
|
}
|
|
680
656
|
reject(new VariousError({
|
|
681
|
-
|
|
657
|
+
module,
|
|
682
658
|
originalError: new Error('not a valid React component'),
|
|
683
659
|
type: 'INVALID_COMPONENT'
|
|
684
660
|
}));
|
|
@@ -687,7 +663,7 @@ function checkReactComponent(component, moduleDefined) {
|
|
|
687
663
|
function isPromiseLike(value) {
|
|
688
664
|
return value != null && typeof value.then === 'function';
|
|
689
665
|
}
|
|
690
|
-
function checkVueComponent(component,
|
|
666
|
+
function checkVueComponent(component, module) {
|
|
691
667
|
const versionRegex = new RegExp(`^${_config__WEBPACK_IMPORTED_MODULE_2__.VUE_VERSION}\\.`);
|
|
692
668
|
return new Promise((resolve, reject) => {
|
|
693
669
|
window.requirejs(['vue'], Vue => {
|
|
@@ -699,7 +675,7 @@ function checkVueComponent(component, moduleDefined) {
|
|
|
699
675
|
return;
|
|
700
676
|
}
|
|
701
677
|
reject(new VariousError({
|
|
702
|
-
|
|
678
|
+
module,
|
|
703
679
|
originalError: new Error('not a valid Vue component'),
|
|
704
680
|
type: 'INVALID_COMPONENT'
|
|
705
681
|
}));
|
|
@@ -709,7 +685,6 @@ function checkVueComponent(component, moduleDefined) {
|
|
|
709
685
|
function parseComponentActions(params) {
|
|
710
686
|
const {
|
|
711
687
|
componentNode,
|
|
712
|
-
name,
|
|
713
688
|
module,
|
|
714
689
|
type,
|
|
715
690
|
i18nUpdate
|
|
@@ -735,66 +710,51 @@ function parseComponentActions(params) {
|
|
|
735
710
|
actions[method] = componentNode[method];
|
|
736
711
|
});
|
|
737
712
|
if (i18nAction) {
|
|
738
|
-
(0,_i18n__WEBPACK_IMPORTED_MODULE_5__.createI18nConfig)(i18nAction,
|
|
739
|
-
name,
|
|
740
|
-
module
|
|
741
|
-
}, i18nUpdate);
|
|
713
|
+
(0,_i18n__WEBPACK_IMPORTED_MODULE_5__.createI18nConfig)(i18nAction, module, i18nUpdate);
|
|
742
714
|
}
|
|
743
|
-
_connector__WEBPACK_IMPORTED_MODULE_3__["default"].setComponentActions(
|
|
744
|
-
name,
|
|
745
|
-
module
|
|
746
|
-
}, actions);
|
|
715
|
+
_connector__WEBPACK_IMPORTED_MODULE_3__["default"].setComponentActions(module, actions);
|
|
747
716
|
if (onMessageAction) {
|
|
748
|
-
return (0,_message__WEBPACK_IMPORTED_MODULE_4__.createOnMessage)(
|
|
749
|
-
name,
|
|
750
|
-
module
|
|
751
|
-
}, onMessageAction);
|
|
717
|
+
return (0,_message__WEBPACK_IMPORTED_MODULE_4__.createOnMessage)(module, onMessageAction);
|
|
752
718
|
}
|
|
753
719
|
return () => null;
|
|
754
720
|
}
|
|
755
|
-
function updateMountedComponent(
|
|
721
|
+
function updateMountedComponent(module) {
|
|
756
722
|
const mountedComponents = getMountedComponents();
|
|
757
|
-
if (!
|
|
758
|
-
mountedComponents.push(
|
|
723
|
+
if (!mountedComponents.includes(module)) {
|
|
724
|
+
mountedComponents.push(module);
|
|
759
725
|
}
|
|
760
726
|
(0,_store__WEBPACK_IMPORTED_MODULE_0__.emit)({
|
|
761
727
|
[_config__WEBPACK_IMPORTED_MODULE_2__.MOUNTED_COMPONENTS_KEY]: mountedComponents
|
|
762
728
|
}, true);
|
|
763
729
|
}
|
|
764
|
-
function updateUnMountComponent(
|
|
765
|
-
const {
|
|
766
|
-
name,
|
|
767
|
-
module
|
|
768
|
-
} = moduleDefined;
|
|
730
|
+
function updateUnMountComponent(module) {
|
|
769
731
|
let mountedComponents = getMountedComponents();
|
|
770
|
-
mountedComponents = mountedComponents.filter(item => item
|
|
732
|
+
mountedComponents = mountedComponents.filter(item => item !== module);
|
|
771
733
|
(0,_store__WEBPACK_IMPORTED_MODULE_0__.emit)({
|
|
772
734
|
[_config__WEBPACK_IMPORTED_MODULE_2__.MOUNTED_COMPONENTS_KEY]: mountedComponents
|
|
773
735
|
}, true);
|
|
774
|
-
_connector__WEBPACK_IMPORTED_MODULE_3__["default"].deleteComponentActions(
|
|
775
|
-
name,
|
|
776
|
-
module
|
|
777
|
-
});
|
|
736
|
+
_connector__WEBPACK_IMPORTED_MODULE_3__["default"].deleteComponentActions(module);
|
|
778
737
|
}
|
|
779
738
|
function getSelfInfo(params) {
|
|
780
739
|
const {
|
|
781
|
-
name,
|
|
782
740
|
module,
|
|
783
741
|
url
|
|
784
742
|
} = params;
|
|
785
743
|
const dependencies = (0,_store__WEBPACK_IMPORTED_MODULE_0__.getStore)(_config__WEBPACK_IMPORTED_MODULE_2__.DEPENDENCIES_KEY);
|
|
744
|
+
const {
|
|
745
|
+
name
|
|
746
|
+
} = getModuleInfo(module);
|
|
786
747
|
return {
|
|
787
|
-
name,
|
|
788
748
|
module,
|
|
789
749
|
url: url || dependencies[name]
|
|
790
750
|
};
|
|
791
751
|
}
|
|
792
|
-
function getClassNameWithModule(
|
|
752
|
+
function getClassNameWithModule(module, prefix) {
|
|
793
753
|
const {
|
|
794
754
|
name,
|
|
795
|
-
|
|
796
|
-
} =
|
|
797
|
-
return `${prefix} ${[name,
|
|
755
|
+
entry
|
|
756
|
+
} = getModuleInfo(module);
|
|
757
|
+
return `${prefix} ${[name, entry].filter(Boolean).join('-')}`;
|
|
798
758
|
}
|
|
799
759
|
|
|
800
760
|
/***/ }),
|
|
@@ -817,21 +777,21 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
817
777
|
|
|
818
778
|
|
|
819
779
|
|
|
820
|
-
function createI18nConfig(method,
|
|
780
|
+
function createI18nConfig(method, module, callback) {
|
|
821
781
|
if (!method) {
|
|
822
782
|
return;
|
|
823
783
|
}
|
|
824
784
|
const i18nConfig = method();
|
|
825
785
|
if (!(0,_helper__WEBPACK_IMPORTED_MODULE_1__.isPromiseLike)(i18nConfig)) {
|
|
826
|
-
if (
|
|
827
|
-
_connector__WEBPACK_IMPORTED_MODULE_0__["default"].setI18nConfig(
|
|
786
|
+
if (module) {
|
|
787
|
+
_connector__WEBPACK_IMPORTED_MODULE_0__["default"].setI18nConfig(module, i18nConfig);
|
|
828
788
|
} else {
|
|
829
789
|
_connector__WEBPACK_IMPORTED_MODULE_0__["default"].setGlobalI18nConfig(i18nConfig);
|
|
830
790
|
}
|
|
831
791
|
return;
|
|
832
792
|
}
|
|
833
|
-
if (
|
|
834
|
-
_connector__WEBPACK_IMPORTED_MODULE_0__["default"].setI18nConfig(
|
|
793
|
+
if (module) {
|
|
794
|
+
_connector__WEBPACK_IMPORTED_MODULE_0__["default"].setI18nConfig(module, {
|
|
835
795
|
loading: true,
|
|
836
796
|
lngStoreKey: '',
|
|
837
797
|
resources: {}
|
|
@@ -844,8 +804,8 @@ function createI18nConfig(method, moduleDefined, callback) {
|
|
|
844
804
|
});
|
|
845
805
|
}
|
|
846
806
|
i18nConfig.then(res => {
|
|
847
|
-
if (
|
|
848
|
-
_connector__WEBPACK_IMPORTED_MODULE_0__["default"].setI18nConfig(
|
|
807
|
+
if (module) {
|
|
808
|
+
_connector__WEBPACK_IMPORTED_MODULE_0__["default"].setI18nConfig(module, {
|
|
849
809
|
...res,
|
|
850
810
|
loading: false
|
|
851
811
|
});
|
|
@@ -865,23 +825,22 @@ function createI18nConfig(method, moduleDefined, callback) {
|
|
|
865
825
|
});
|
|
866
826
|
}).catch(e => {
|
|
867
827
|
(0,_helper__WEBPACK_IMPORTED_MODULE_1__.onError)(new _helper__WEBPACK_IMPORTED_MODULE_1__.VariousError({
|
|
868
|
-
|
|
869
|
-
module: moduleDefined?.module,
|
|
828
|
+
module: module || 'app',
|
|
870
829
|
type: 'I18N',
|
|
871
830
|
originalError: e
|
|
872
831
|
}));
|
|
873
832
|
});
|
|
874
833
|
}
|
|
875
|
-
function createI18n(
|
|
834
|
+
function createI18n(module, updater) {
|
|
876
835
|
const ctx = (key, params, defaultString) => {
|
|
877
|
-
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();
|
|
878
837
|
let defaultText = defaultString;
|
|
879
838
|
if (defaultText === undefined) {
|
|
880
839
|
defaultText = typeof params === 'string' ? params : key;
|
|
881
840
|
}
|
|
882
841
|
if (!i18nConfig) {
|
|
883
842
|
(0,_helper__WEBPACK_IMPORTED_MODULE_1__.onError)(new _helper__WEBPACK_IMPORTED_MODULE_1__.VariousError({
|
|
884
|
-
|
|
843
|
+
module,
|
|
885
844
|
type: 'I18N',
|
|
886
845
|
originalError: new Error('config not exist')
|
|
887
846
|
}));
|
|
@@ -897,7 +856,7 @@ function createI18n(moduleDefined, updater) {
|
|
|
897
856
|
const locale = (0,_store__WEBPACK_IMPORTED_MODULE_2__.getStore)(lngStoreKey);
|
|
898
857
|
if (lngStoreKey === undefined || locale === undefined) {
|
|
899
858
|
(0,_helper__WEBPACK_IMPORTED_MODULE_1__.onError)(new _helper__WEBPACK_IMPORTED_MODULE_1__.VariousError({
|
|
900
|
-
|
|
859
|
+
module,
|
|
901
860
|
type: 'I18N',
|
|
902
861
|
originalError: new Error('locale key not defined')
|
|
903
862
|
}));
|
|
@@ -906,7 +865,7 @@ function createI18n(moduleDefined, updater) {
|
|
|
906
865
|
const resource = resources?.[locale];
|
|
907
866
|
if (!resource) {
|
|
908
867
|
(0,_helper__WEBPACK_IMPORTED_MODULE_1__.onError)(new _helper__WEBPACK_IMPORTED_MODULE_1__.VariousError({
|
|
909
|
-
|
|
868
|
+
module,
|
|
910
869
|
type: 'I18N',
|
|
911
870
|
originalError: new Error(`locale resource \`${locale}\` not exist`)
|
|
912
871
|
}));
|
|
@@ -914,7 +873,7 @@ function createI18n(moduleDefined, updater) {
|
|
|
914
873
|
}
|
|
915
874
|
if (!resource[key]) {
|
|
916
875
|
(0,_helper__WEBPACK_IMPORTED_MODULE_1__.onError)(new _helper__WEBPACK_IMPORTED_MODULE_1__.VariousError({
|
|
917
|
-
|
|
876
|
+
module,
|
|
918
877
|
type: 'I18N',
|
|
919
878
|
originalError: new Error(`locale key \`${key}\` not exist`)
|
|
920
879
|
}));
|
|
@@ -934,7 +893,7 @@ function createI18n(moduleDefined, updater) {
|
|
|
934
893
|
}, text);
|
|
935
894
|
};
|
|
936
895
|
ctx.update = (config, type) => {
|
|
937
|
-
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);
|
|
938
897
|
const next = {
|
|
939
898
|
...i18nConfig,
|
|
940
899
|
...config
|
|
@@ -942,7 +901,7 @@ function createI18n(moduleDefined, updater) {
|
|
|
942
901
|
if (type === 'app') {
|
|
943
902
|
_connector__WEBPACK_IMPORTED_MODULE_0__["default"].setGlobalI18nConfig(next);
|
|
944
903
|
} else {
|
|
945
|
-
_connector__WEBPACK_IMPORTED_MODULE_0__["default"].setI18nConfig(
|
|
904
|
+
_connector__WEBPACK_IMPORTED_MODULE_0__["default"].setI18nConfig(module, next);
|
|
946
905
|
}
|
|
947
906
|
updater();
|
|
948
907
|
};
|
|
@@ -975,7 +934,7 @@ const logger = args => {
|
|
|
975
934
|
error: 'red'
|
|
976
935
|
};
|
|
977
936
|
const color = colorMap[args.level];
|
|
978
|
-
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;`];
|
|
979
938
|
if (args.type) {
|
|
980
939
|
params[0] = `${params[0]}%c ${args.type} %c`;
|
|
981
940
|
params.push(`border:1px solid ${color};padding:1px;border-radius:0 2px 2px 0;color:${color};`, 'background:transparent');
|
|
@@ -985,10 +944,10 @@ const logger = args => {
|
|
|
985
944
|
}
|
|
986
945
|
window.console[args.level](...params, args.message);
|
|
987
946
|
};
|
|
988
|
-
const createLogger =
|
|
947
|
+
const createLogger = module => ({
|
|
989
948
|
info(message, type) {
|
|
990
949
|
logger({
|
|
991
|
-
|
|
950
|
+
module,
|
|
992
951
|
level: 'info',
|
|
993
952
|
type,
|
|
994
953
|
message
|
|
@@ -996,7 +955,7 @@ const createLogger = moduleDefined => ({
|
|
|
996
955
|
},
|
|
997
956
|
warn(message, type) {
|
|
998
957
|
logger({
|
|
999
|
-
|
|
958
|
+
module,
|
|
1000
959
|
level: 'warn',
|
|
1001
960
|
type,
|
|
1002
961
|
message
|
|
@@ -1005,13 +964,13 @@ const createLogger = moduleDefined => ({
|
|
|
1005
964
|
error(message, type) {
|
|
1006
965
|
const middlewares = _connector__WEBPACK_IMPORTED_MODULE_0__["default"].getMiddlewares();
|
|
1007
966
|
const error = message instanceof _helper__WEBPACK_IMPORTED_MODULE_1__.VariousError ? message : new _helper__WEBPACK_IMPORTED_MODULE_1__.VariousError({
|
|
1008
|
-
|
|
967
|
+
module,
|
|
1009
968
|
type: type || 'unknow',
|
|
1010
969
|
originalError: message instanceof Error ? message : new Error(message)
|
|
1011
970
|
});
|
|
1012
971
|
middlewares?.onError?.(error);
|
|
1013
972
|
logger({
|
|
1014
|
-
|
|
973
|
+
module,
|
|
1015
974
|
level: 'error',
|
|
1016
975
|
type,
|
|
1017
976
|
message
|
|
@@ -1042,13 +1001,16 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1042
1001
|
|
|
1043
1002
|
|
|
1044
1003
|
|
|
1045
|
-
const createPostMessage =
|
|
1004
|
+
const createPostMessage = module => async ({
|
|
1005
|
+
event,
|
|
1006
|
+
payload
|
|
1007
|
+
}) => {
|
|
1046
1008
|
const middlewares = _connector__WEBPACK_IMPORTED_MODULE_0__["default"].getMiddlewares();
|
|
1047
|
-
const logger = (0,_logger__WEBPACK_IMPORTED_MODULE_1__["default"])(
|
|
1009
|
+
const logger = (0,_logger__WEBPACK_IMPORTED_MODULE_1__["default"])(module);
|
|
1048
1010
|
let next = {
|
|
1049
|
-
trigger:
|
|
1011
|
+
trigger: module,
|
|
1050
1012
|
event,
|
|
1051
|
-
|
|
1013
|
+
payload
|
|
1052
1014
|
};
|
|
1053
1015
|
if (middlewares?.onMessage) {
|
|
1054
1016
|
const check = await middlewares.onMessage(next);
|
|
@@ -1067,22 +1029,22 @@ const createPostMessage = moduleDefined => async (event, value) => {
|
|
|
1067
1029
|
[_config__WEBPACK_IMPORTED_MODULE_3__.MESSAGE_KEY]: {
|
|
1068
1030
|
timestamp: +new Date(),
|
|
1069
1031
|
event: next.event,
|
|
1070
|
-
trigger:
|
|
1071
|
-
|
|
1032
|
+
trigger: module,
|
|
1033
|
+
payload: next.payload
|
|
1072
1034
|
}
|
|
1073
1035
|
});
|
|
1074
1036
|
};
|
|
1075
|
-
const createOnMessage = (
|
|
1037
|
+
const createOnMessage = (module, onMessage) => (0,_store__WEBPACK_IMPORTED_MODULE_2__.subscribe)({
|
|
1076
1038
|
[_config__WEBPACK_IMPORTED_MODULE_3__.MESSAGE_KEY](v) {
|
|
1077
1039
|
const {
|
|
1078
1040
|
trigger,
|
|
1079
|
-
|
|
1041
|
+
payload,
|
|
1080
1042
|
event
|
|
1081
1043
|
} = v;
|
|
1082
|
-
if (
|
|
1044
|
+
if (module !== trigger) {
|
|
1083
1045
|
onMessage({
|
|
1084
1046
|
event,
|
|
1085
|
-
|
|
1047
|
+
payload,
|
|
1086
1048
|
trigger
|
|
1087
1049
|
});
|
|
1088
1050
|
}
|
|
@@ -1122,7 +1084,6 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1122
1084
|
|
|
1123
1085
|
function reactComponent(config) {
|
|
1124
1086
|
const {
|
|
1125
|
-
name,
|
|
1126
1087
|
module,
|
|
1127
1088
|
url,
|
|
1128
1089
|
watchKeys,
|
|
@@ -1145,36 +1106,22 @@ function reactComponent(config) {
|
|
|
1145
1106
|
this.ComponentNode = null;
|
|
1146
1107
|
this.isUnMounted = true;
|
|
1147
1108
|
this.unSubscribeMessage();
|
|
1148
|
-
(0,_helper__WEBPACK_IMPORTED_MODULE_2__.updateUnMountComponent)(
|
|
1149
|
-
name,
|
|
1150
|
-
module
|
|
1151
|
-
});
|
|
1109
|
+
(0,_helper__WEBPACK_IMPORTED_MODULE_2__.updateUnMountComponent)(module);
|
|
1152
1110
|
}
|
|
1153
1111
|
mountComponent = async () => {
|
|
1154
1112
|
try {
|
|
1155
1113
|
const componentNode = await (0,_create_module__WEBPACK_IMPORTED_MODULE_9__["default"])({
|
|
1156
|
-
name,
|
|
1157
1114
|
module,
|
|
1158
1115
|
url
|
|
1159
1116
|
}, false);
|
|
1160
1117
|
if (this.isUnMounted) {
|
|
1161
1118
|
return;
|
|
1162
1119
|
}
|
|
1163
|
-
await (0,_helper__WEBPACK_IMPORTED_MODULE_2__.checkReactComponent)(componentNode,
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
});
|
|
1167
|
-
componentNode.displayName = (0,_helper__WEBPACK_IMPORTED_MODULE_2__.getNameWithModule)({
|
|
1168
|
-
name,
|
|
1169
|
-
module
|
|
1170
|
-
});
|
|
1171
|
-
(0,_helper__WEBPACK_IMPORTED_MODULE_2__.updateMountedComponent)({
|
|
1172
|
-
name,
|
|
1173
|
-
module
|
|
1174
|
-
});
|
|
1120
|
+
await (0,_helper__WEBPACK_IMPORTED_MODULE_2__.checkReactComponent)(componentNode, module);
|
|
1121
|
+
componentNode.displayName = module;
|
|
1122
|
+
(0,_helper__WEBPACK_IMPORTED_MODULE_2__.updateMountedComponent)(module);
|
|
1175
1123
|
this.unSubscribeMessage = (0,_helper__WEBPACK_IMPORTED_MODULE_2__.parseComponentActions)({
|
|
1176
1124
|
componentNode,
|
|
1177
|
-
name,
|
|
1178
1125
|
module,
|
|
1179
1126
|
i18nUpdate: () => this.forceUpdate()
|
|
1180
1127
|
});
|
|
@@ -1194,24 +1141,11 @@ function reactComponent(config) {
|
|
|
1194
1141
|
});
|
|
1195
1142
|
}
|
|
1196
1143
|
};
|
|
1197
|
-
$postMessage = (0,_message__WEBPACK_IMPORTED_MODULE_5__.createPostMessage)(
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
$dispatch = (0,_dispatch__WEBPACK_IMPORTED_MODULE_6__["default"])({
|
|
1202
|
-
name,
|
|
1203
|
-
module
|
|
1204
|
-
});
|
|
1205
|
-
$t = (0,_i18n__WEBPACK_IMPORTED_MODULE_8__.createI18n)({
|
|
1206
|
-
name,
|
|
1207
|
-
module
|
|
1208
|
-
}, () => this.forceUpdate());
|
|
1209
|
-
$logger = (0,_logger__WEBPACK_IMPORTED_MODULE_7__["default"])({
|
|
1210
|
-
name,
|
|
1211
|
-
module
|
|
1212
|
-
});
|
|
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);
|
|
1213
1148
|
$self = (0,_helper__WEBPACK_IMPORTED_MODULE_2__.getSelfInfo)({
|
|
1214
|
-
name,
|
|
1215
1149
|
module,
|
|
1216
1150
|
url
|
|
1217
1151
|
});
|
|
@@ -1232,7 +1166,7 @@ function reactComponent(config) {
|
|
|
1232
1166
|
throw this.error;
|
|
1233
1167
|
}
|
|
1234
1168
|
if (!componentReady) {
|
|
1235
|
-
if ($silent || (0,_helper__WEBPACK_IMPORTED_MODULE_2__.isModuleLoaded)(
|
|
1169
|
+
if ($silent || (0,_helper__WEBPACK_IMPORTED_MODULE_2__.isModuleLoaded)(module)) {
|
|
1236
1170
|
return null;
|
|
1237
1171
|
}
|
|
1238
1172
|
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(Fallback, {
|
|
@@ -1281,7 +1215,6 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1281
1215
|
|
|
1282
1216
|
|
|
1283
1217
|
const renderComponent = async ({
|
|
1284
|
-
name,
|
|
1285
1218
|
module,
|
|
1286
1219
|
url,
|
|
1287
1220
|
target,
|
|
@@ -1292,10 +1225,9 @@ const renderComponent = async ({
|
|
|
1292
1225
|
}) => {
|
|
1293
1226
|
try {
|
|
1294
1227
|
const ReactDOM = await (0,_create_module__WEBPACK_IMPORTED_MODULE_5__["default"])({
|
|
1295
|
-
|
|
1228
|
+
module: 'react-dom'
|
|
1296
1229
|
});
|
|
1297
1230
|
const C = (type === 'vue3' ? _vue_component__WEBPACK_IMPORTED_MODULE_2__["default"] : _react_component__WEBPACK_IMPORTED_MODULE_1__["default"])({
|
|
1298
|
-
name,
|
|
1299
1231
|
module,
|
|
1300
1232
|
url,
|
|
1301
1233
|
onMounted
|
|
@@ -1312,7 +1244,6 @@ const renderComponent = async ({
|
|
|
1312
1244
|
$ref
|
|
1313
1245
|
};
|
|
1314
1246
|
const node = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_error_boundary__WEBPACK_IMPORTED_MODULE_4__["default"], {
|
|
1315
|
-
name: name,
|
|
1316
1247
|
module: module,
|
|
1317
1248
|
url: url
|
|
1318
1249
|
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(C, nextProps));
|
|
@@ -1325,7 +1256,6 @@ const renderComponent = async ({
|
|
|
1325
1256
|
});
|
|
1326
1257
|
} catch (e) {
|
|
1327
1258
|
const error = new _helper__WEBPACK_IMPORTED_MODULE_3__.VariousError({
|
|
1328
|
-
name,
|
|
1329
1259
|
module,
|
|
1330
1260
|
type: 'SCRIPT_ERROR',
|
|
1331
1261
|
originalError: e
|
|
@@ -1409,7 +1339,6 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1409
1339
|
|
|
1410
1340
|
function vueComponent(config) {
|
|
1411
1341
|
const {
|
|
1412
|
-
name,
|
|
1413
1342
|
module,
|
|
1414
1343
|
url,
|
|
1415
1344
|
watchKeys,
|
|
@@ -1425,7 +1354,6 @@ function vueComponent(config) {
|
|
|
1425
1354
|
const isUnMountedRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(false);
|
|
1426
1355
|
const ComponentNodeRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)();
|
|
1427
1356
|
const selfRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)((0,_helper__WEBPACK_IMPORTED_MODULE_4__.getSelfInfo)({
|
|
1428
|
-
name,
|
|
1429
1357
|
module,
|
|
1430
1358
|
url
|
|
1431
1359
|
}));
|
|
@@ -1443,22 +1371,10 @@ function vueComponent(config) {
|
|
|
1443
1371
|
$componentProps
|
|
1444
1372
|
} = props;
|
|
1445
1373
|
const mountVue = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(() => {
|
|
1446
|
-
const $logger = (0,_logger__WEBPACK_IMPORTED_MODULE_6__["default"])(
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
const $dispatch = (0,_dispatch__WEBPACK_IMPORTED_MODULE_5__["default"])({
|
|
1451
|
-
name,
|
|
1452
|
-
module
|
|
1453
|
-
});
|
|
1454
|
-
const $postMessage = (0,_message__WEBPACK_IMPORTED_MODULE_7__.createPostMessage)({
|
|
1455
|
-
name,
|
|
1456
|
-
module
|
|
1457
|
-
});
|
|
1458
|
-
const $t = (0,_i18n__WEBPACK_IMPORTED_MODULE_8__.createI18n)({
|
|
1459
|
-
name,
|
|
1460
|
-
module
|
|
1461
|
-
}, () => {
|
|
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, () => {
|
|
1462
1378
|
updateVueComponentRef.current?.();
|
|
1463
1379
|
});
|
|
1464
1380
|
propsReactiveRef.current = vueRef.current.ref({
|
|
@@ -1481,7 +1397,6 @@ function vueComponent(config) {
|
|
|
1481
1397
|
const error = e;
|
|
1482
1398
|
errorRef.current = error.message?.includes('https://react') ? new _helper__WEBPACK_IMPORTED_MODULE_4__.VariousError({
|
|
1483
1399
|
originalError: new Error('not a valid Vue component'),
|
|
1484
|
-
name,
|
|
1485
1400
|
module,
|
|
1486
1401
|
type: 'INVALID_COMPONENT'
|
|
1487
1402
|
}) : error;
|
|
@@ -1514,28 +1429,20 @@ function vueComponent(config) {
|
|
|
1514
1429
|
const mountComponent = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(async () => {
|
|
1515
1430
|
try {
|
|
1516
1431
|
const vue = await (0,_create_module__WEBPACK_IMPORTED_MODULE_2__["default"])({
|
|
1517
|
-
|
|
1432
|
+
module: 'vue'
|
|
1518
1433
|
});
|
|
1519
1434
|
vueRef.current = vue;
|
|
1520
1435
|
const componentNode = await (0,_create_module__WEBPACK_IMPORTED_MODULE_2__["default"])({
|
|
1521
|
-
name,
|
|
1522
1436
|
module,
|
|
1523
1437
|
url
|
|
1524
1438
|
}, false);
|
|
1525
1439
|
if (isUnMountedRef.current) {
|
|
1526
1440
|
return;
|
|
1527
1441
|
}
|
|
1528
|
-
await (0,_helper__WEBPACK_IMPORTED_MODULE_4__.checkVueComponent)(componentNode,
|
|
1529
|
-
|
|
1530
|
-
module
|
|
1531
|
-
});
|
|
1532
|
-
(0,_helper__WEBPACK_IMPORTED_MODULE_4__.updateMountedComponent)({
|
|
1533
|
-
name,
|
|
1534
|
-
module
|
|
1535
|
-
});
|
|
1442
|
+
await (0,_helper__WEBPACK_IMPORTED_MODULE_4__.checkVueComponent)(componentNode, module);
|
|
1443
|
+
(0,_helper__WEBPACK_IMPORTED_MODULE_4__.updateMountedComponent)(module);
|
|
1536
1444
|
unSubscribeMessageRef.current = (0,_helper__WEBPACK_IMPORTED_MODULE_4__.parseComponentActions)({
|
|
1537
1445
|
componentNode,
|
|
1538
|
-
name,
|
|
1539
1446
|
module,
|
|
1540
1447
|
type: 'vue3',
|
|
1541
1448
|
i18nUpdate() {
|
|
@@ -1562,10 +1469,7 @@ function vueComponent(config) {
|
|
|
1562
1469
|
errorRef.current = undefined;
|
|
1563
1470
|
ComponentNodeRef.current = undefined;
|
|
1564
1471
|
isUnMountedRef.current = true;
|
|
1565
|
-
(0,_helper__WEBPACK_IMPORTED_MODULE_4__.updateUnMountComponent)(
|
|
1566
|
-
name,
|
|
1567
|
-
module
|
|
1568
|
-
});
|
|
1472
|
+
(0,_helper__WEBPACK_IMPORTED_MODULE_4__.updateUnMountComponent)(module);
|
|
1569
1473
|
unMountVue.current?.();
|
|
1570
1474
|
unSubscribeMessageRef.current?.();
|
|
1571
1475
|
isVueMounted.current = false;
|
|
@@ -1594,21 +1498,15 @@ function vueComponent(config) {
|
|
|
1594
1498
|
if (isError) {
|
|
1595
1499
|
throw errorRef.current;
|
|
1596
1500
|
}
|
|
1597
|
-
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, {
|
|
1598
1502
|
$self: selfRef.current,
|
|
1599
1503
|
$store: store
|
|
1600
1504
|
}) : null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
1601
|
-
className: (0,_helper__WEBPACK_IMPORTED_MODULE_4__.getClassNameWithModule)(
|
|
1602
|
-
name,
|
|
1603
|
-
module
|
|
1604
|
-
}, 'various-vue-component'),
|
|
1505
|
+
className: (0,_helper__WEBPACK_IMPORTED_MODULE_4__.getClassNameWithModule)(module, 'various-vue-component'),
|
|
1605
1506
|
ref: containerDivRef
|
|
1606
1507
|
}));
|
|
1607
1508
|
};
|
|
1608
|
-
V.displayName =
|
|
1609
|
-
name,
|
|
1610
|
-
module
|
|
1611
|
-
});
|
|
1509
|
+
V.displayName = module;
|
|
1612
1510
|
const VueComponent = props => /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(V, props);
|
|
1613
1511
|
VueComponent.displayName = 'various-vue-component';
|
|
1614
1512
|
return VueComponent;
|
|
@@ -1640,6 +1538,12 @@ module.exports = __WEBPACK_EXTERNAL_MODULE_react__;
|
|
|
1640
1538
|
/******/ if (cachedModule !== undefined) {
|
|
1641
1539
|
/******/ return cachedModule.exports;
|
|
1642
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
|
+
/******/ }
|
|
1643
1547
|
/******/ // Create a new module (and put it into the cache)
|
|
1644
1548
|
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
1645
1549
|
/******/ // no module.id needed
|
|
@@ -1714,6 +1618,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1714
1618
|
/* harmony export */ defineDependencies: function() { return /* reexport safe */ _helper__WEBPACK_IMPORTED_MODULE_11__.defineDependencies; },
|
|
1715
1619
|
/* harmony export */ getApp: function() { return /* binding */ getApp; },
|
|
1716
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; },
|
|
1717
1622
|
/* harmony export */ getMountedComponents: function() { return /* reexport safe */ _helper__WEBPACK_IMPORTED_MODULE_11__.getMountedComponents; },
|
|
1718
1623
|
/* harmony export */ getStore: function() { return /* reexport safe */ _store__WEBPACK_IMPORTED_MODULE_1__.getUserStore; },
|
|
1719
1624
|
/* harmony export */ isModuleLoaded: function() { return /* reexport safe */ _helper__WEBPACK_IMPORTED_MODULE_11__.isModuleLoaded; },
|
|
@@ -1758,7 +1663,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1758
1663
|
|
|
1759
1664
|
|
|
1760
1665
|
// eslint-disable-next-line no-undef
|
|
1761
|
-
const version = "5.
|
|
1666
|
+
const version = "5.2.0";
|
|
1762
1667
|
const getApp = config => {
|
|
1763
1668
|
const {
|
|
1764
1669
|
dependencies,
|
|
@@ -1796,7 +1701,7 @@ const getApp = config => {
|
|
|
1796
1701
|
}
|
|
1797
1702
|
render() {
|
|
1798
1703
|
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_error_boundary__WEBPACK_IMPORTED_MODULE_6__["default"], {
|
|
1799
|
-
|
|
1704
|
+
module: "app",
|
|
1800
1705
|
url: dependencies.app
|
|
1801
1706
|
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Root, null));
|
|
1802
1707
|
}
|