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