@variousjs/various 5.0.0 → 5.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.dev.js CHANGED
@@ -45,6 +45,7 @@ function _extends() {
45
45
  "use strict";
46
46
  __webpack_require__.r(__webpack_exports__);
47
47
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
48
+ /* harmony export */ BASE_DEPENDENCIES: function() { return /* binding */ BASE_DEPENDENCIES; },
48
49
  /* harmony export */ CONFIG_KEY: function() { return /* binding */ CONFIG_KEY; },
49
50
  /* harmony export */ DEPENDENCIES_KEY: function() { return /* binding */ DEPENDENCIES_KEY; },
50
51
  /* harmony export */ MESSAGE_KEY: function() { return /* binding */ MESSAGE_KEY; },
@@ -60,6 +61,7 @@ const DEPENDENCIES_KEY = Symbol('DEPENDENCIES');
60
61
  const ROOT = '#root';
61
62
  const VUE_FUNCTION_OPTIONS = ['beforeCreate', 'created', 'beforeMount', 'mounted', 'beforeUpdate', 'updated', 'beforeUnmount', 'unmounted', 'errorCaptured', 'renderTracked', 'renderTriggered', 'activated', 'deactivated', 'setup', 'data', 'render'];
62
63
  const VUE_VERSION = 3;
64
+ const BASE_DEPENDENCIES = ['react', 'react-dom', '@variousjs/various', 'app'];
63
65
 
64
66
  /***/ }),
65
67
 
@@ -188,7 +190,8 @@ const createComponent = (config, storeKeys) => {
188
190
  };
189
191
  return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_error_boundary__WEBPACK_IMPORTED_MODULE_3__["default"], {
190
192
  name: name,
191
- module: module
193
+ module: module,
194
+ url: url
192
195
  }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(C, nextProps));
193
196
  };
194
197
  component.displayName = 'various-creator';
@@ -469,6 +472,7 @@ class ErrorBoundary extends react__WEBPACK_IMPORTED_MODULE_0__.Component {
469
472
  module
470
473
  });
471
474
  }
475
+ $self = (0,_helper__WEBPACK_IMPORTED_MODULE_1__.getSelfInfo)(this.props);
472
476
  reload = () => {
473
477
  this.error = undefined;
474
478
  this.setState({
@@ -476,16 +480,11 @@ class ErrorBoundary extends react__WEBPACK_IMPORTED_MODULE_0__.Component {
476
480
  });
477
481
  };
478
482
  render() {
479
- const {
480
- name,
481
- module
482
- } = this.props;
483
483
  const ErrorNode = _connector__WEBPACK_IMPORTED_MODULE_2__["default"].getErrorComponent();
484
484
  const store = (0,_store__WEBPACK_IMPORTED_MODULE_3__.getUserStore)();
485
485
  if (this.state.hasError) {
486
486
  return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(ErrorNode, {
487
- $name: name,
488
- $module: module,
487
+ $self: this.$self,
489
488
  $reload: this.reload,
490
489
  $store: store,
491
490
  $error: this.error
@@ -514,12 +513,14 @@ __webpack_require__.r(__webpack_exports__);
514
513
  /* harmony export */ getConfig: function() { return /* binding */ getConfig; },
515
514
  /* harmony export */ getMountedComponents: function() { return /* binding */ getMountedComponents; },
516
515
  /* harmony export */ getNameWithModule: function() { return /* binding */ getNameWithModule; },
516
+ /* harmony export */ getSelfInfo: function() { return /* binding */ getSelfInfo; },
517
517
  /* harmony export */ isModuleLoaded: function() { return /* binding */ isModuleLoaded; },
518
518
  /* harmony export */ isPromiseLike: function() { return /* binding */ isPromiseLike; },
519
519
  /* harmony export */ onComponentMounted: function() { return /* binding */ onComponentMounted; },
520
520
  /* harmony export */ onError: function() { return /* binding */ onError; },
521
521
  /* harmony export */ parseComponentActions: function() { return /* binding */ parseComponentActions; },
522
522
  /* harmony export */ preloadModules: function() { return /* binding */ preloadModules; },
523
+ /* harmony export */ removeLoadedModules: function() { return /* binding */ removeLoadedModules; },
523
524
  /* harmony export */ resetDependencyConfig: function() { return /* binding */ resetDependencyConfig; },
524
525
  /* harmony export */ updateMountedComponent: function() { return /* binding */ updateMountedComponent; },
525
526
  /* harmony export */ updateUnMountComponent: function() { return /* binding */ updateUnMountComponent; }
@@ -538,16 +539,24 @@ __webpack_require__.r(__webpack_exports__);
538
539
 
539
540
  const getUrlHash = url => `${url}?${+new Date()}`;
540
541
  const hasModule = (modules, module) => modules.some(c => c.name === module.name && c.module === module.module);
541
- const preloadModules = name => new Promise((resolve, reject) => {
542
- const names = typeof name === 'string' ? [name] : name;
542
+ const preloadModules = names => new Promise((resolve, reject) => {
543
543
  window.requirejs(names, resolve, reject);
544
544
  });
545
+ const removeLoadedModules = names => {
546
+ names.forEach(name => {
547
+ if (!_config__WEBPACK_IMPORTED_MODULE_2__.BASE_DEPENDENCIES.includes(name)) {
548
+ window.requirejs.undef(name);
549
+ }
550
+ });
551
+ };
545
552
  const defineDependencies = deps => {
546
553
  const dependencies = (0,_store__WEBPACK_IMPORTED_MODULE_0__.getStore)(_config__WEBPACK_IMPORTED_MODULE_2__.DEPENDENCIES_KEY);
547
554
  const next = {};
548
555
  Object.keys(deps).forEach(name => {
549
- next[name] = `${deps[name]}#${name}`;
550
- window.requirejs.undef(name);
556
+ if (!_config__WEBPACK_IMPORTED_MODULE_2__.BASE_DEPENDENCIES.includes(name)) {
557
+ next[name] = `${deps[name]}#${name}`;
558
+ window.requirejs.undef(name);
559
+ }
551
560
  });
552
561
  window.requirejs.config({
553
562
  paths: next
@@ -743,6 +752,19 @@ function updateUnMountComponent(moduleDefined) {
743
752
  module
744
753
  });
745
754
  }
755
+ function getSelfInfo(params) {
756
+ const {
757
+ name,
758
+ module,
759
+ url
760
+ } = params;
761
+ const dependencies = (0,_store__WEBPACK_IMPORTED_MODULE_0__.getStore)(_config__WEBPACK_IMPORTED_MODULE_2__.DEPENDENCIES_KEY);
762
+ return {
763
+ name,
764
+ module,
765
+ url: url || dependencies[name]
766
+ };
767
+ }
746
768
 
747
769
  /***/ }),
748
770
 
@@ -1156,6 +1178,11 @@ function reactComponent(config) {
1156
1178
  name,
1157
1179
  module
1158
1180
  });
1181
+ $self = (0,_helper__WEBPACK_IMPORTED_MODULE_2__.getSelfInfo)({
1182
+ name,
1183
+ module,
1184
+ url
1185
+ });
1159
1186
  render() {
1160
1187
  const LoaderNode = _connector__WEBPACK_IMPORTED_MODULE_4__["default"].getLoaderComponent();
1161
1188
  const {
@@ -1177,12 +1204,12 @@ function reactComponent(config) {
1177
1204
  return null;
1178
1205
  }
1179
1206
  return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(LoaderNode, {
1180
- $name: name,
1181
- $module: module,
1207
+ $self: this.$self,
1182
1208
  $store: store
1183
1209
  });
1184
1210
  }
1185
1211
  return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(ComponentNode, (0,_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__["default"])({}, $componentProps, {
1212
+ $self: this.$self,
1186
1213
  $dispatch: this.$dispatch,
1187
1214
  $store: store,
1188
1215
  $postMessage: this.$postMessage,
@@ -1215,6 +1242,8 @@ __webpack_require__.r(__webpack_exports__);
1215
1242
  /* harmony import */ var _react_component__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./react-component */ "./src/core/react-component.tsx");
1216
1243
  /* harmony import */ var _vue_component__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vue-component */ "./src/core/vue-component.tsx");
1217
1244
  /* harmony import */ var _helper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./helper */ "./src/core/helper.ts");
1245
+ /* harmony import */ var _error_boundary__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./error-boundary */ "./src/core/error-boundary.tsx");
1246
+
1218
1247
 
1219
1248
 
1220
1249
 
@@ -1248,7 +1277,11 @@ const renderComponent = ({
1248
1277
  $silent,
1249
1278
  $ref
1250
1279
  };
1251
- const node = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(C, nextProps);
1280
+ const node = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_error_boundary__WEBPACK_IMPORTED_MODULE_5__["default"], {
1281
+ name: name,
1282
+ module: module,
1283
+ url: url
1284
+ }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(C, nextProps));
1252
1285
  root.render(renderNode ? renderNode(node) : node);
1253
1286
  return () => new Promise(resolve => {
1254
1287
  setTimeout(() => {
@@ -1355,6 +1388,11 @@ function vueComponent(config) {
1355
1388
  const errorRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)();
1356
1389
  const isUnMountedRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(false);
1357
1390
  const ComponentNodeRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)();
1391
+ const selfRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)((0,_helper__WEBPACK_IMPORTED_MODULE_4__.getSelfInfo)({
1392
+ name,
1393
+ module,
1394
+ url
1395
+ }));
1358
1396
  const containerDivRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null);
1359
1397
  const propsReactiveRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)();
1360
1398
  const storeReactiveRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)();
@@ -1421,7 +1459,8 @@ function vueComponent(config) {
1421
1459
  $logger,
1422
1460
  $postMessage,
1423
1461
  $t,
1424
- $store: storeReactiveRef.current.value
1462
+ $store: storeReactiveRef.current.value,
1463
+ $self: selfRef.current
1425
1464
  },
1426
1465
  // eslint-disable-next-line react/no-this-in-sfc
1427
1466
  key: this.key
@@ -1512,8 +1551,7 @@ function vueComponent(config) {
1512
1551
  throw errorRef.current;
1513
1552
  }
1514
1553
  return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, !componentReady && !$silent && !(0,_helper__WEBPACK_IMPORTED_MODULE_4__.isModuleLoaded)(name) ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(LoaderNode, {
1515
- $name: name,
1516
- $module: module,
1554
+ $self: selfRef.current,
1517
1555
  $store: store
1518
1556
  }) : null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
1519
1557
  className: `various-component-${(0,_helper__WEBPACK_IMPORTED_MODULE_4__.getNameWithModule)({
@@ -1647,6 +1685,7 @@ __webpack_require__.r(__webpack_exports__);
1647
1685
  /* harmony export */ isModuleLoaded: function() { return /* reexport safe */ _helper__WEBPACK_IMPORTED_MODULE_12__.isModuleLoaded; },
1648
1686
  /* harmony export */ onComponentMounted: function() { return /* reexport safe */ _helper__WEBPACK_IMPORTED_MODULE_12__.onComponentMounted; },
1649
1687
  /* harmony export */ preloadModules: function() { return /* reexport safe */ _helper__WEBPACK_IMPORTED_MODULE_12__.preloadModules; },
1688
+ /* harmony export */ removeLoadedModules: function() { return /* reexport safe */ _helper__WEBPACK_IMPORTED_MODULE_12__.removeLoadedModules; },
1650
1689
  /* harmony export */ renderComponent: function() { return /* reexport safe */ _render_component__WEBPACK_IMPORTED_MODULE_15__["default"]; },
1651
1690
  /* harmony export */ version: function() { return /* binding */ version; }
1652
1691
  /* harmony export */ });
@@ -1688,7 +1727,7 @@ __webpack_require__.r(__webpack_exports__);
1688
1727
 
1689
1728
 
1690
1729
  // eslint-disable-next-line no-undef
1691
- const version = "5.0.0";
1730
+ const version = "5.0.2";
1692
1731
  /* harmony default export */ __webpack_exports__["default"] = (config => {
1693
1732
  const {
1694
1733
  dependencies,
@@ -1727,7 +1766,8 @@ const version = "5.0.0";
1727
1766
  }
1728
1767
  render() {
1729
1768
  return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_error_boundary__WEBPACK_IMPORTED_MODULE_7__["default"], {
1730
- name: "app"
1769
+ name: "app",
1770
+ url: dependencies.app
1731
1771
  }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(ContainerComponent, null));
1732
1772
  }
1733
1773
  }