zmp-react
Advanced tools
Comparing version 2.4.0 to 2.5.0-0
@@ -19,20 +19,10 @@ "use strict"; | ||
var window = (0, _ssrWindow.getWindow)(); | ||
var importPages; | ||
var _default = function _default() { | ||
var routes; | ||
try { | ||
importPages = ZMP_IMPORT_PAGES; | ||
} catch (err) {} | ||
if (window.APP_CONFIG) { | ||
routes = window.APP_CONFIG.pages; | ||
} | ||
var initRoutesForOldVersion = function initRoutesForOldVersion(routes, isOldConfig) { | ||
if (routes) { | ||
var isOldConfig = false; | ||
if (routes.length && routes[0] && _regExp.oldRouteConfig.test(routes[0])) { | ||
isOldConfig = true; | ||
} | ||
routes = routes.map(function (route) { | ||
return (0, _utils.standardizePageDir)(route); | ||
}); | ||
routes = routes.map(function (path, index) { | ||
@@ -118,3 +108,5 @@ var _resolvePath = (0, _utils.resolvePath)(path), | ||
var routePath = (0, _utils.toRoutePath)(path); | ||
var _toRoutePath = (0, _utils.toRoutePath)(path), | ||
routePath = _toRoutePath.path; | ||
var alias; | ||
@@ -226,2 +218,115 @@ | ||
var initRoutes = function initRoutes(routes, isOldConfig) { | ||
var appRoutes; | ||
if (routes && importPages) { | ||
appRoutes = routes.map(function (path, index) { | ||
var _toRoutePath2 = (0, _utils.toRoutePath)(path), | ||
routePath = _toRoutePath2.path, | ||
fileDir = _toRoutePath2.fileDir; | ||
if (isOldConfig && index === 0) { | ||
return { | ||
path: '/', | ||
name: 'home', | ||
async: function async(_ref4) { | ||
var app = _ref4.app, | ||
to = _ref4.to, | ||
resolve = _ref4.resolve, | ||
reject = _ref4.reject; | ||
if (!importPages[fileDir]) { | ||
throw Error("Cannot find /" + fileDir); | ||
} | ||
importPages[fileDir]().then(function (res) { | ||
resolve({ | ||
component: res.default | ||
}); | ||
}); | ||
} | ||
}; | ||
} | ||
var alias; | ||
if (routePath) { | ||
alias = routePath.substring(0, routePath.length - 1); | ||
} | ||
var routeObj = { | ||
path: routePath, | ||
async: function async(_ref5) { | ||
var app = _ref5.app, | ||
to = _ref5.to, | ||
resolve = _ref5.resolve; | ||
if (!importPages[fileDir]) { | ||
throw Error("Cannot find /" + fileDir); | ||
} | ||
importPages[fileDir]().then(function (res) { | ||
resolve({ | ||
component: res.default | ||
}); | ||
}); | ||
} | ||
}; | ||
if (alias) { | ||
routeObj.alias = alias; | ||
} | ||
return routeObj; | ||
}); | ||
if (!isOldConfig) { | ||
appRoutes = [{ | ||
path: '/', | ||
name: 'home', | ||
async: function async(_ref6) { | ||
var app = _ref6.app, | ||
to = _ref6.to, | ||
resolve = _ref6.resolve; | ||
if (!importPages['index']) { | ||
throw Error('Can not find Index Page'); | ||
} | ||
importPages['index']().then(function (res) { | ||
resolve({ | ||
component: res.default | ||
}); | ||
}); | ||
} | ||
}].concat(appRoutes); | ||
} | ||
} | ||
return appRoutes; | ||
}; | ||
var _default = function _default() { | ||
var routes; | ||
if (window.APP_CONFIG) { | ||
routes = window.APP_CONFIG.pages; | ||
} | ||
if (routes) { | ||
var isOldConfig = false; | ||
if (routes.length && routes[0] && _regExp.oldRouteConfig.test(routes[0])) { | ||
isOldConfig = true; | ||
} | ||
routes = routes.map(function (route) { | ||
return (0, _utils.standardizePageDir)(route); | ||
}); | ||
routes = importPages ? initRoutes(routes, isOldConfig) : initRoutesForOldVersion(routes, isOldConfig); | ||
} | ||
return routes; | ||
}; | ||
exports.default = _default; |
@@ -76,2 +76,3 @@ "use strict"; | ||
info? : string | ||
label?: string | ||
outline? : boolean | ||
@@ -78,0 +79,0 @@ wrap? : boolean |
/** | ||
* ZMP React 2.4.0 | ||
* ZMP React 2.5.0-0 | ||
* Build full featured iOS & Android apps using ZMP & React | ||
@@ -10,3 +10,3 @@ * https://h5.zalo.me/react/ | ||
* | ||
* Released on: October 18, 2021 | ||
* Released on: October 26, 2021 | ||
*/ | ||
@@ -13,0 +13,0 @@ "use strict"; |
@@ -165,3 +165,4 @@ /* eslint-disable eqeqeq */ | ||
/** | ||
* @param {dir} string page dir | ||
* @param {string} Page Directory | ||
* @returns {object} {path: route path, fileDir: file name directory} | ||
*/ | ||
@@ -181,3 +182,3 @@ export const toRoutePath = (dir) => { | ||
} | ||
return `/${paths.join('/')}/`; | ||
return { path: `/${paths.join('/')}/`, fileDir: paths.join('/') }; | ||
}; | ||
@@ -184,0 +185,0 @@ |
@@ -52,2 +52,3 @@ | ||
info ?: string; | ||
label?: string; | ||
outline ?: boolean; | ||
@@ -54,0 +55,0 @@ wrap ?: boolean; |
@@ -6,19 +6,10 @@ import { getWindow } from 'ssr-window'; | ||
var window = getWindow(); | ||
export default (function () { | ||
var routes; | ||
var importPages; | ||
if (window.APP_CONFIG) { | ||
routes = window.APP_CONFIG.pages; | ||
} | ||
try { | ||
importPages = ZMP_IMPORT_PAGES; | ||
} catch (err) {} | ||
var initRoutesForOldVersion = function initRoutesForOldVersion(routes, isOldConfig) { | ||
if (routes) { | ||
var isOldConfig = false; | ||
if (routes.length && routes[0] && oldRouteConfig.test(routes[0])) { | ||
isOldConfig = true; | ||
} | ||
routes = routes.map(function (route) { | ||
return standardizePageDir(route); | ||
}); | ||
routes = routes.map(function (path, index) { | ||
@@ -104,3 +95,5 @@ var _resolvePath = resolvePath(path), | ||
var routePath = toRoutePath(path); | ||
var _toRoutePath = toRoutePath(path), | ||
routePath = _toRoutePath.path; | ||
var alias; | ||
@@ -210,2 +203,115 @@ | ||
return routes; | ||
}; | ||
var initRoutes = function initRoutes(routes, isOldConfig) { | ||
var appRoutes; | ||
if (routes && importPages) { | ||
appRoutes = routes.map(function (path, index) { | ||
var _toRoutePath2 = toRoutePath(path), | ||
routePath = _toRoutePath2.path, | ||
fileDir = _toRoutePath2.fileDir; | ||
if (isOldConfig && index === 0) { | ||
return { | ||
path: '/', | ||
name: 'home', | ||
async: function async(_ref4) { | ||
var app = _ref4.app, | ||
to = _ref4.to, | ||
resolve = _ref4.resolve, | ||
reject = _ref4.reject; | ||
if (!importPages[fileDir]) { | ||
throw Error("Cannot find /" + fileDir); | ||
} | ||
importPages[fileDir]().then(function (res) { | ||
resolve({ | ||
component: res.default | ||
}); | ||
}); | ||
} | ||
}; | ||
} | ||
var alias; | ||
if (routePath) { | ||
alias = routePath.substring(0, routePath.length - 1); | ||
} | ||
var routeObj = { | ||
path: routePath, | ||
async: function async(_ref5) { | ||
var app = _ref5.app, | ||
to = _ref5.to, | ||
resolve = _ref5.resolve; | ||
if (!importPages[fileDir]) { | ||
throw Error("Cannot find /" + fileDir); | ||
} | ||
importPages[fileDir]().then(function (res) { | ||
resolve({ | ||
component: res.default | ||
}); | ||
}); | ||
} | ||
}; | ||
if (alias) { | ||
routeObj.alias = alias; | ||
} | ||
return routeObj; | ||
}); | ||
if (!isOldConfig) { | ||
appRoutes = [{ | ||
path: '/', | ||
name: 'home', | ||
async: function async(_ref6) { | ||
var app = _ref6.app, | ||
to = _ref6.to, | ||
resolve = _ref6.resolve; | ||
if (!importPages['index']) { | ||
throw Error('Can not find Index Page'); | ||
} | ||
importPages['index']().then(function (res) { | ||
resolve({ | ||
component: res.default | ||
}); | ||
}); | ||
} | ||
}].concat(appRoutes); | ||
} | ||
} | ||
return appRoutes; | ||
}; | ||
export default (function () { | ||
var routes; | ||
if (window.APP_CONFIG) { | ||
routes = window.APP_CONFIG.pages; | ||
} | ||
if (routes) { | ||
var isOldConfig = false; | ||
if (routes.length && routes[0] && oldRouteConfig.test(routes[0])) { | ||
isOldConfig = true; | ||
} | ||
routes = routes.map(function (route) { | ||
return standardizePageDir(route); | ||
}); | ||
routes = importPages ? initRoutes(routes, isOldConfig) : initRoutesForOldVersion(routes, isOldConfig); | ||
} | ||
return routes; | ||
}); |
@@ -57,2 +57,3 @@ import _extends from "@babel/runtime/helpers/extends"; | ||
info? : string | ||
label?: string | ||
outline? : boolean | ||
@@ -59,0 +60,0 @@ wrap? : boolean |
/** | ||
* ZMP React 2.4.0 | ||
* ZMP React 2.5.0-0 | ||
* Build full featured iOS & Android apps using ZMP & React | ||
@@ -10,3 +10,3 @@ * https://h5.zalo.me/react/ | ||
* | ||
* Released on: October 18, 2021 | ||
* Released on: October 26, 2021 | ||
*/ | ||
@@ -13,0 +13,0 @@ /* eslint-disable no-proto */ |
{ | ||
"name": "zmp-react", | ||
"version": "2.4.0", | ||
"version": "2.5.0-0", | ||
"description": "Build full featured iOS & Android apps using ZMP & React", | ||
@@ -5,0 +5,0 @@ "main": "cjs/zmp-react.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1789175
40424
2