Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

seer-dynamic-component

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

seer-dynamic-component - npm Package Compare versions

Comparing version 1.0.5 to 1.0.6

0

CHANGELOG.md

@@ -0,0 +0,0 @@ # Changelog

122

lib/index.js

@@ -65,16 +65,19 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

value: function () {
var _loadComponent = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(id) {
var targetComp, targetComponent;
return regeneratorRuntime.wrap(function _callee$(_context) {
var _loadComponent = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(id) {
var _this2 = this;
var targetComp, injectReducer;
return regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) {
switch (_context.prev = _context.next) {
switch (_context2.prev = _context2.next) {
case 0:
_context.next = 2;
_context2.next = 2;
return getCompInfo(id);
case 2:
targetComp = _context.sent;
targetComp = _context2.sent;
injectReducer = this.props.injectReducer;
if (targetComp) {
_context.next = 7;
_context2.next = 8;
break;

@@ -86,21 +89,63 @@ }

});
_context.next = 11;
_context2.next = 9;
break;
case 7:
_context.next = 9;
return loadRealComponent(targetComp, targetComp.id, "components_");
case 8:
return _context2.delegateYield( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
var id, reducers, targetComponent, injectReducers, _loop, i;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
id = targetComp.id, reducers = targetComp.reducers;
_context.next = 3;
return loadRealComponent(targetComp, id, "components_");
case 3:
targetComponent = _context.sent;
if (!(injectReducer && Array.isArray(reducers) && reducers.length > 0)) {
_context.next = 10;
break;
}
injectReducers = [];
_loop = function _loop(i) {
var routers = window.seerConfig.routers || [];
var targetRoute = routers.find(function (router) {
return Array.isArray(router.reducer) ? router.reducer.findIndex(function (reducer) {
return reducer === reducers[i];
}) > -1 : router.reducer === reducers[i];
});
targetRoute && injectReducers.push(_this2.injectReducer(targetRoute, reducers[i], injectReducer));
};
for (i = 0; i < reducers.length; i++) {
_loop(i);
}
_context.next = 10;
return Promise.all(injectReducers);
case 10:
_this2.setState({
ModuleComponent: targetComponent
});
case 11:
case "end":
return _context.stop();
}
}
}, _callee);
})(), "t0", 9);
case 9:
targetComponent = _context.sent;
this.setState({
ModuleComponent: targetComponent
});
case 11:
case "end":
return _context.stop();
return _context2.stop();
}
}
}, _callee, this);
}, _callee2, this);
}));

@@ -114,3 +159,42 @@

}()
/**
* 注册reducer
* @param {*} reducerId
* @param injectReducer
*/
}, {
key: "injectReducer",
value: function () {
var _injectReducer2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(targetRoute, reducerId, _injectReducer) {
var reducerComp;
return regeneratorRuntime.wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
_context3.next = 2;
return loadRealComponent(targetRoute, reducerId, "reducer_", "moduleIns");
case 2:
reducerComp = _context3.sent;
if (reducerComp) {
_injectReducer(reducerId, reducerComp);
}
case 4:
case "end":
return _context3.stop();
}
}
}, _callee3);
}));
function injectReducer(_x2, _x3, _x4) {
return _injectReducer2.apply(this, arguments);
}
return injectReducer;
}()
}, {
key: "componentDidMount",

@@ -117,0 +201,0 @@ value: function componentDidMount() {

14

lib/utils.js

@@ -9,3 +9,3 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

* 获取组件配置信息
* @param {*} id
* @param {*} id
*/

@@ -65,5 +65,7 @@ export var getCompInfo = function getCompInfo(id) {

* @param {*} fp 前缀 router_ reducer_
* @param {*} key 当前查询的key值 componentsIn moduleIns
*/
export var loadRealComponent = function loadRealComponent(targetComp, compId, fp) {
var key = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "componentsIn";
return new Promise(function (resolve, reject) {

@@ -77,6 +79,6 @@ var tranCompId = fp + compId.replace(/\./g, "_");

var jsName = "".concat(packageName).concat(packageHash ? "." + packageHash : "", ".js");
window.seerConfig.componentsIn = window.seerConfig.componentsIn || {};
window.seerConfig[key] = window.seerConfig[key] || {};
if (window.seerConfig.componentsIn[module]) {
var comp = window.seerConfig.componentsIn[module][tranCompId];
if (window.seerConfig[key][module]) {
var comp = window.seerConfig[key][module][tranCompId];
resolve(comp);

@@ -86,4 +88,4 @@ } else {

delete window["default"];
window.seerConfig.componentsIn[module] = res["default"];
var comp = window.seerConfig.componentsIn[module][tranCompId];
window.seerConfig[key][module] = res["default"];
var comp = window.seerConfig[key][module][tranCompId];
resolve(comp);

@@ -90,0 +92,0 @@ })["catch"](function (e) {

{
"name": "seer-dynamic-component",
"version": "1.0.5",
"version": "1.0.6",
"description": "",

@@ -16,3 +16,11 @@ "main": "lib/index.js",

"author": "",
"license": "ISC"
}
"license": "ISC",
"devDependencies": {
"@babel/preset-env": "^7.9.5",
"standard-version": "^7.1.0",
"@babel/cli": "^7.8.4",
"@babel/core": "^7.9.0",
"@babel/plugin-proposal-class-properties": "^7.8.3",
"@babel/preset-react": "^7.9.4"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc