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

maishu-chitu

Package Overview
Dependencies
Maintainers
1
Versions
104
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

maishu-chitu - npm Package Compare versions

Comparing version 2.9.12 to 2.9.14

63

dist/index.es5.js
/*!
*
* maishu-chitu v2.9.12
* maishu-chitu v2.9.14
* https://github.com/ansiboy/services-sdk

@@ -93,3 +93,3 @@ *

/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = "./out/index.js");
/******/ return __webpack_require__(__webpack_require__.s = "./out-es5/index.js");
/******/ })

@@ -110,61 +110,50 @@ /************************************************************************/

/***/ "./out/Application.js":
/*!****************************!*\
!*** ./out/Application.js ***!
\****************************/
/***/ "./out-es5/Application.js":
/*!********************************!*\
!*** ./out-es5/Application.js ***!
\********************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
eval("var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__, exports, __webpack_require__(/*! maishu-chitu-service */ \"./node_modules/maishu-chitu-service/dist/index.js\"), __webpack_require__(/*! ./PageMaster */ \"./out/PageMaster.js\"), __webpack_require__(/*! ./Errors */ \"./out/Errors.js\")], __WEBPACK_AMD_DEFINE_RESULT__ = (function (require, exports, maishu_chitu_service_1, PageMaster_1, Errors_1) {\r\n \"use strict\";\r\n Object.defineProperty(exports, \"__esModule\", { value: true });\r\n const EmtpyStateData = \"\";\r\n const DefaultPageName = \"index\";\r\n function parseUrl(app, url) {\r\n if (!app)\r\n throw Errors_1.Errors.argumentNull('app');\r\n if (!url)\r\n throw Errors_1.Errors.argumentNull('url');\r\n let sharpIndex = url.indexOf('#');\r\n let routeString;\r\n if (sharpIndex >= 0)\r\n routeString = url.substr(sharpIndex + 1);\r\n else\r\n routeString = url;\r\n if (!routeString)\r\n throw Errors_1.Errors.canntParseRouteString(url);\r\n if (routeString.startsWith('!')) {\r\n throw Errors_1.Errors.canntParseRouteString(routeString);\r\n }\r\n let routePath;\r\n let search = null;\r\n let param_spliter_index = routeString.indexOf('?');\r\n if (param_spliter_index >= 0) {\r\n search = routeString.substr(param_spliter_index + 1);\r\n routePath = routeString.substring(0, param_spliter_index);\r\n }\r\n else {\r\n routePath = routeString;\r\n }\r\n if (!routePath)\r\n routePath = DefaultPageName;\r\n let values = {};\r\n if (search) {\r\n values = pareeUrlQuery(search);\r\n }\r\n let pageName = routePath;\r\n return { pageName, values };\r\n }\r\n function pareeUrlQuery(query) {\r\n let match, pl = /\\+/g, search = /([^&=]+)=?([^&]*)/g, decode = function (s) { return decodeURIComponent(s.replace(pl, \" \")); };\r\n let urlParams = {};\r\n while (match = search.exec(query))\r\n urlParams[decode(match[1])] = decode(match[2]);\r\n return urlParams;\r\n }\r\n function createUrl(pageName, params) {\r\n let path_parts = pageName.split('.');\r\n let path = path_parts.join('/');\r\n if (!params)\r\n return `#${path}`;\r\n let paramsText = '';\r\n for (let key in params) {\r\n let value = params[key];\r\n let type = typeof params[key];\r\n if (type != 'string' || value == null) {\r\n continue;\r\n }\r\n paramsText = paramsText == '' ? `?${key}=${params[key]}` : paramsText + `&${key}=${params[key]}`;\r\n }\r\n return `#${path}${paramsText}`;\r\n }\r\n class Application extends PageMaster_1.PageMaster {\r\n constructor(args) {\r\n super((args || {}).container || document.body, (args || {}).parser);\r\n this._runned = false;\r\n this.closeCurrentOnBack = null;\r\n this.tempPageData = undefined;\r\n }\r\n parseUrl(url) {\r\n if (!url)\r\n throw Errors_1.Errors.argumentNull('url');\r\n let routeData = parseUrl(this, url);\r\n return routeData;\r\n }\r\n createUrl(pageName, values) {\r\n return createUrl(pageName, values);\r\n }\r\n run() {\r\n if (this._runned)\r\n return;\r\n let showPage = () => {\r\n let url = location.href;\r\n let sharpIndex = url.indexOf('#');\r\n let routeString = url.substr(sharpIndex + 1);\r\n if (routeString.startsWith('!')) {\r\n return;\r\n }\r\n if (sharpIndex < 0) {\r\n url = '#' + DefaultPageName;\r\n }\r\n this.showPageByUrl(url, true);\r\n };\r\n showPage();\r\n window.addEventListener('popstate', () => {\r\n showPage();\r\n });\r\n this._runned = true;\r\n }\r\n showPageByUrl(url, fromCache) {\r\n if (!url)\r\n throw Errors_1.Errors.argumentNull('url');\r\n var routeData = this.parseUrl(url);\r\n if (routeData == null) {\r\n throw Errors_1.Errors.noneRouteMatched(url);\r\n }\r\n let tempPageData = this.fetchTemplatePageData();\r\n let result = null;\r\n if (this.closeCurrentOnBack == true) {\r\n this.closeCurrentOnBack = null;\r\n if (tempPageData == null)\r\n this.closeCurrentPage();\r\n else\r\n this.closeCurrentPage(tempPageData);\r\n result = this.currentPage;\r\n }\r\n else if (this.closeCurrentOnBack == false) {\r\n this.closeCurrentOnBack = null;\r\n var page = this.pageStack.pop();\r\n if (page == null)\r\n throw new Error('page is null');\r\n page.hide(this.currentPage);\r\n result = this.currentPage;\r\n }\r\n if (result == null || result.name != routeData.pageName) {\r\n let args = routeData.values || {};\r\n if (tempPageData) {\r\n args = Object.assign(args, tempPageData);\r\n }\r\n result = this.showPage(routeData.pageName, args);\r\n }\r\n return result;\r\n }\r\n fetchTemplatePageData() {\r\n if (this.tempPageData == null) {\r\n return null;\r\n }\r\n let data = this.tempPageData;\r\n this.tempPageData = undefined;\r\n return data;\r\n }\r\n setLocationHash(url) {\r\n history.pushState(EmtpyStateData, \"\", url);\r\n }\r\n redirect(pageNameOrUrl, args) {\r\n if (!pageNameOrUrl)\r\n throw Errors_1.Errors.argumentNull('pageNameOrUrl');\r\n let page = this.showPageByNameOrUrl(pageNameOrUrl, args);\r\n let url = this.createUrl(page.name, page.data);\r\n this.setLocationHash(url);\r\n return page;\r\n }\r\n forward(pageNameOrUrl, args, setUrl) {\r\n if (!pageNameOrUrl)\r\n throw Errors_1.Errors.argumentNull('pageNameOrUrl');\r\n if (setUrl == null)\r\n setUrl = true;\r\n let page = this.showPageByNameOrUrl(pageNameOrUrl, args, true);\r\n if (setUrl) {\r\n let url = this.createUrl(page.name, page.data);\r\n this.setLocationHash(url);\r\n }\r\n else {\r\n history.pushState(pageNameOrUrl, \"\", \"\");\r\n }\r\n return page;\r\n }\r\n showPageByNameOrUrl(pageNameOrUrl, args, rerender) {\r\n let pageName;\r\n if (pageNameOrUrl.indexOf('?') < 0) {\r\n pageName = pageNameOrUrl;\r\n }\r\n else {\r\n let obj = this.parseUrl(pageNameOrUrl);\r\n pageName = obj.pageName;\r\n args = Object.assign(obj.values, args || {});\r\n }\r\n return this.showPage(pageName, args, rerender);\r\n }\r\n reload(pageName, args) {\r\n let result = this.showPage(pageName, args, true);\r\n return result;\r\n }\r\n back(closeCurrentPage, data) {\r\n const closeCurrentPageDefault = true;\r\n if (typeof closeCurrentPage == 'object') {\r\n data = closeCurrentPage;\r\n closeCurrentPage = null;\r\n }\r\n this.closeCurrentOnBack = closeCurrentPage == null ? closeCurrentPageDefault : closeCurrentPage;\r\n this.tempPageData = data;\r\n history.back();\r\n }\r\n createService(type) {\r\n type = type || maishu_chitu_service_1.Service;\r\n let service = new type();\r\n service.error.add((sender, error) => {\r\n this.error.fire(this, error, null);\r\n });\r\n return service;\r\n }\r\n }\r\n exports.Application = Application;\r\n}).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),\n\t\t\t\t__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));\r\n\n\n//# sourceURL=webpack:///./out/Application.js?");
"use strict";
eval("var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _typeof(obj) { 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); }\n\n!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__, exports, __webpack_require__(/*! maishu-chitu-service */ \"./node_modules/maishu-chitu-service/dist/index.js\"), __webpack_require__(/*! ./PageMaster */ \"./out-es5/PageMaster.js\"), __webpack_require__(/*! ./Errors */ \"./out-es5/Errors.js\")], __WEBPACK_AMD_DEFINE_RESULT__ = (function (require, exports, maishu_chitu_service_1, PageMaster_1, Errors_1) {\n \"use strict\";\n\n Object.defineProperty(exports, \"__esModule\", {\n value: true\n });\n var EmtpyStateData = \"\";\n var DefaultPageName = \"index\";\n\n function _parseUrl(app, url) {\n if (!app) throw Errors_1.Errors.argumentNull('app');\n if (!url) throw Errors_1.Errors.argumentNull('url');\n var sharpIndex = url.indexOf('#');\n var routeString;\n if (sharpIndex >= 0) routeString = url.substr(sharpIndex + 1);else routeString = url;\n if (!routeString) throw Errors_1.Errors.canntParseRouteString(url);\n\n if (routeString.startsWith('!')) {\n throw Errors_1.Errors.canntParseRouteString(routeString);\n }\n\n var routePath;\n var search = null;\n var param_spliter_index = routeString.indexOf('?');\n\n if (param_spliter_index >= 0) {\n search = routeString.substr(param_spliter_index + 1);\n routePath = routeString.substring(0, param_spliter_index);\n } else {\n routePath = routeString;\n }\n\n if (!routePath) routePath = DefaultPageName;\n var values = {};\n\n if (search) {\n values = pareeUrlQuery(search);\n }\n\n var pageName = routePath;\n return {\n pageName: pageName,\n values: values\n };\n }\n\n function pareeUrlQuery(query) {\n var match,\n pl = /\\+/g,\n search = /([^&=]+)=?([^&]*)/g,\n decode = function decode(s) {\n return decodeURIComponent(s.replace(pl, \" \"));\n };\n\n var urlParams = {};\n\n while (match = search.exec(query)) {\n urlParams[decode(match[1])] = decode(match[2]);\n }\n\n return urlParams;\n }\n\n function _createUrl(pageName, params) {\n var path_parts = pageName.split('.');\n var path = path_parts.join('/');\n if (!params) return \"#\".concat(path);\n var paramsText = '';\n\n for (var key in params) {\n var value = params[key];\n\n var type = _typeof(params[key]);\n\n if (type != 'string' || value == null) {\n continue;\n }\n\n paramsText = paramsText == '' ? \"?\".concat(key, \"=\").concat(params[key]) : paramsText + \"&\".concat(key, \"=\").concat(params[key]);\n }\n\n return \"#\".concat(path).concat(paramsText);\n }\n\n var Application =\n /*#__PURE__*/\n function (_PageMaster_1$PageMas) {\n _inherits(Application, _PageMaster_1$PageMas);\n\n function Application(args) {\n var _this;\n\n _classCallCheck(this, Application);\n\n _this = _possibleConstructorReturn(this, _getPrototypeOf(Application).call(this, (args || {}).container || document.body, (args || {}).parser));\n _this._runned = false;\n _this.closeCurrentOnBack = null;\n _this.tempPageData = undefined;\n return _this;\n }\n\n _createClass(Application, [{\n key: \"parseUrl\",\n value: function parseUrl(url) {\n if (!url) throw Errors_1.Errors.argumentNull('url');\n\n var routeData = _parseUrl(this, url);\n\n return routeData;\n }\n }, {\n key: \"createUrl\",\n value: function createUrl(pageName, values) {\n return _createUrl(pageName, values);\n }\n }, {\n key: \"run\",\n value: function run() {\n var _this2 = this;\n\n if (this._runned) return;\n\n var showPage = function showPage() {\n var url = location.href;\n var sharpIndex = url.indexOf('#');\n var routeString = url.substr(sharpIndex + 1);\n\n if (routeString.startsWith('!')) {\n return;\n }\n\n if (sharpIndex < 0) {\n url = '#' + DefaultPageName;\n }\n\n _this2.showPageByUrl(url, true);\n };\n\n showPage();\n window.addEventListener('popstate', function () {\n showPage();\n });\n this._runned = true;\n }\n }, {\n key: \"showPageByUrl\",\n value: function showPageByUrl(url, fromCache) {\n if (!url) throw Errors_1.Errors.argumentNull('url');\n var routeData = this.parseUrl(url);\n\n if (routeData == null) {\n throw Errors_1.Errors.noneRouteMatched(url);\n }\n\n var tempPageData = this.fetchTemplatePageData();\n var result = null;\n\n if (this.closeCurrentOnBack == true) {\n this.closeCurrentOnBack = null;\n if (tempPageData == null) this.closeCurrentPage();else this.closeCurrentPage(tempPageData);\n result = this.currentPage;\n } else if (this.closeCurrentOnBack == false) {\n this.closeCurrentOnBack = null;\n var page = this.pageStack.pop();\n if (page == null) throw new Error('page is null');\n page.hide(this.currentPage);\n result = this.currentPage;\n }\n\n if (result == null || result.name != routeData.pageName) {\n var args = routeData.values || {};\n\n if (tempPageData) {\n args = Object.assign(args, tempPageData);\n }\n\n result = this.showPage(routeData.pageName, args);\n }\n\n return result;\n }\n }, {\n key: \"fetchTemplatePageData\",\n value: function fetchTemplatePageData() {\n if (this.tempPageData == null) {\n return null;\n }\n\n var data = this.tempPageData;\n this.tempPageData = undefined;\n return data;\n }\n }, {\n key: \"setLocationHash\",\n value: function setLocationHash(url) {\n history.pushState(EmtpyStateData, \"\", url);\n }\n }, {\n key: \"redirect\",\n value: function redirect(pageNameOrUrl, args) {\n if (!pageNameOrUrl) throw Errors_1.Errors.argumentNull('pageNameOrUrl');\n var page = this.showPageByNameOrUrl(pageNameOrUrl, args);\n var url = this.createUrl(page.name, page.data);\n this.setLocationHash(url);\n return page;\n }\n }, {\n key: \"forward\",\n value: function forward(pageNameOrUrl, args, setUrl) {\n if (!pageNameOrUrl) throw Errors_1.Errors.argumentNull('pageNameOrUrl');\n if (setUrl == null) setUrl = true;\n var page = this.showPageByNameOrUrl(pageNameOrUrl, args, true);\n\n if (setUrl) {\n var url = this.createUrl(page.name, page.data);\n this.setLocationHash(url);\n } else {\n history.pushState(pageNameOrUrl, \"\", \"\");\n }\n\n return page;\n }\n }, {\n key: \"showPageByNameOrUrl\",\n value: function showPageByNameOrUrl(pageNameOrUrl, args, rerender) {\n var pageName;\n\n if (pageNameOrUrl.indexOf('?') < 0) {\n pageName = pageNameOrUrl;\n } else {\n var obj = this.parseUrl(pageNameOrUrl);\n pageName = obj.pageName;\n args = Object.assign(obj.values, args || {});\n }\n\n return this.showPage(pageName, args, rerender);\n }\n }, {\n key: \"reload\",\n value: function reload(pageName, args) {\n var result = this.showPage(pageName, args, true);\n return result;\n }\n }, {\n key: \"back\",\n value: function back(closeCurrentPage, data) {\n var closeCurrentPageDefault = true;\n\n if (_typeof(closeCurrentPage) == 'object') {\n data = closeCurrentPage;\n closeCurrentPage = null;\n }\n\n this.closeCurrentOnBack = closeCurrentPage == null ? closeCurrentPageDefault : closeCurrentPage;\n this.tempPageData = data;\n history.back();\n }\n }, {\n key: \"createService\",\n value: function createService(type) {\n var _this3 = this;\n\n type = type || maishu_chitu_service_1.Service;\n var service = new type();\n service.error.add(function (sender, error) {\n _this3.error.fire(_this3, error, null);\n });\n return service;\n }\n }]);\n\n return Application;\n }(PageMaster_1.PageMaster);\n\n exports.Application = Application;\n}).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),\n\t\t\t\t__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));\n//# sourceMappingURL=Application.js.map\n\n\n//# sourceURL=webpack:///./out-es5/Application.js?");
/***/ }),
/***/ "./out/Errors.js":
/*!***********************!*\
!*** ./out/Errors.js ***!
\***********************/
/***/ "./out-es5/Errors.js":
/*!***************************!*\
!*** ./out-es5/Errors.js ***!
\***************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
eval("var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__, exports], __WEBPACK_AMD_DEFINE_RESULT__ = (function (require, exports) {\r\n \"use strict\";\r\n Object.defineProperty(exports, \"__esModule\", { value: true });\r\n class Errors {\r\n static pageNodeNotExists(pageName) {\r\n let msg = `Page node named ${pageName} is not exists.`;\r\n return new Error(msg);\r\n }\r\n static actionCanntNull(pageName) {\r\n let msg = `Action of '${pageName}' can not be null.`;\r\n return new Error(msg);\r\n }\r\n static argumentNull(paramName) {\r\n var msg = `The argument \"${paramName}\" cannt be null.`;\r\n return new Error(msg);\r\n }\r\n static modelFileExpecteFunction(script) {\r\n var msg = `The eval result of script file \"${script}\" is expected a function.`;\r\n return new Error(msg);\r\n }\r\n static paramTypeError(paramName, expectedType) {\r\n var msg = `The param \"${paramName}\" is expected \"${expectedType}\" type.`;\r\n return new Error(msg);\r\n }\r\n static paramError(msg) {\r\n return new Error(msg);\r\n }\r\n static pathPairRequireView(index) {\r\n var msg = `The view value is required for path pair, but the item with index \"${index}\" is miss it.`;\r\n return new Error(msg);\r\n }\r\n static notImplemented(name) {\r\n var msg = `'The method \"${name}\" is not implemented.'`;\r\n return new Error(msg);\r\n }\r\n static routeExists(name) {\r\n var msg = `Route named \"${name}\" is exists.`;\r\n return new Error(msg);\r\n }\r\n static noneRouteMatched(url) {\r\n var msg = `None route matched with url \"${url}\".`;\r\n var error = new Error(msg);\r\n return error;\r\n }\r\n static emptyStack() {\r\n return new Error('The stack is empty.');\r\n }\r\n static canntParseUrl(url) {\r\n var msg = `Can not parse the url \"${url}\" to route data.`;\r\n return new Error(msg);\r\n }\r\n static canntParseRouteString(routeString) {\r\n var msg = `Can not parse the route string \"${routeString}\" to route data.;`;\r\n return new Error(msg);\r\n }\r\n static routeDataRequireController() {\r\n var msg = 'The route data does not contains a \"controller\" file.';\r\n return new Error(msg);\r\n }\r\n static routeDataRequireAction() {\r\n var msg = 'The route data does not contains a \"action\" file.';\r\n return new Error(msg);\r\n }\r\n static viewCanntNull() {\r\n var msg = 'The view or viewDeferred of the page cannt null.';\r\n return new Error(msg);\r\n }\r\n static createPageFail(pageName) {\r\n var msg = `Create page \"${pageName}\" fail.`;\r\n return new Error(msg);\r\n }\r\n static actionTypeError(pageName) {\r\n let msg = `The action in page '${pageName}' is expect as function.`;\r\n return new Error(msg);\r\n }\r\n static canntFindAction(pageName) {\r\n let msg = `Cannt find action in page '${pageName}', is the exports has default field?`;\r\n return new Error(msg);\r\n }\r\n static exportsCanntNull(pageName) {\r\n let msg = `Exports of page '${pageName}' is null.`;\r\n return new Error(msg);\r\n }\r\n static scrollerElementNotExists() {\r\n let msg = \"Scroller element is not exists.\";\r\n return new Error(msg);\r\n }\r\n static resourceExists(resourceName, pageName) {\r\n let msg = `Rosource '${resourceName}' is exists in the resources of page '${pageName}'.`;\r\n return new Error(msg);\r\n }\r\n static siteMapRootCanntNull() {\r\n let msg = `The site map root node can not be null.`;\r\n return new Error(msg);\r\n }\r\n static duplicateSiteMapNode(name) {\r\n let msg = `The site map node ${name} is exists.`;\r\n return new Error(name);\r\n }\r\n }\r\n exports.Errors = Errors;\r\n}).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),\n\t\t\t\t__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));\r\n\n\n//# sourceURL=webpack:///./out/Errors.js?");
"use strict";
eval("var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__, exports], __WEBPACK_AMD_DEFINE_RESULT__ = (function (require, exports) {\n \"use strict\";\n\n Object.defineProperty(exports, \"__esModule\", {\n value: true\n });\n\n var Errors =\n /*#__PURE__*/\n function () {\n function Errors() {\n _classCallCheck(this, Errors);\n }\n\n _createClass(Errors, null, [{\n key: \"pageNodeNotExists\",\n value: function pageNodeNotExists(pageName) {\n var msg = \"Page node named \".concat(pageName, \" is not exists.\");\n return new Error(msg);\n }\n }, {\n key: \"actionCanntNull\",\n value: function actionCanntNull(pageName) {\n var msg = \"Action of '\".concat(pageName, \"' can not be null.\");\n return new Error(msg);\n }\n }, {\n key: \"argumentNull\",\n value: function argumentNull(paramName) {\n var msg = \"The argument \\\"\".concat(paramName, \"\\\" cannt be null.\");\n return new Error(msg);\n }\n }, {\n key: \"modelFileExpecteFunction\",\n value: function modelFileExpecteFunction(script) {\n var msg = \"The eval result of script file \\\"\".concat(script, \"\\\" is expected a function.\");\n return new Error(msg);\n }\n }, {\n key: \"paramTypeError\",\n value: function paramTypeError(paramName, expectedType) {\n var msg = \"The param \\\"\".concat(paramName, \"\\\" is expected \\\"\").concat(expectedType, \"\\\" type.\");\n return new Error(msg);\n }\n }, {\n key: \"paramError\",\n value: function paramError(msg) {\n return new Error(msg);\n }\n }, {\n key: \"pathPairRequireView\",\n value: function pathPairRequireView(index) {\n var msg = \"The view value is required for path pair, but the item with index \\\"\".concat(index, \"\\\" is miss it.\");\n return new Error(msg);\n }\n }, {\n key: \"notImplemented\",\n value: function notImplemented(name) {\n var msg = \"'The method \\\"\".concat(name, \"\\\" is not implemented.'\");\n return new Error(msg);\n }\n }, {\n key: \"routeExists\",\n value: function routeExists(name) {\n var msg = \"Route named \\\"\".concat(name, \"\\\" is exists.\");\n return new Error(msg);\n }\n }, {\n key: \"noneRouteMatched\",\n value: function noneRouteMatched(url) {\n var msg = \"None route matched with url \\\"\".concat(url, \"\\\".\");\n var error = new Error(msg);\n return error;\n }\n }, {\n key: \"emptyStack\",\n value: function emptyStack() {\n return new Error('The stack is empty.');\n }\n }, {\n key: \"canntParseUrl\",\n value: function canntParseUrl(url) {\n var msg = \"Can not parse the url \\\"\".concat(url, \"\\\" to route data.\");\n return new Error(msg);\n }\n }, {\n key: \"canntParseRouteString\",\n value: function canntParseRouteString(routeString) {\n var msg = \"Can not parse the route string \\\"\".concat(routeString, \"\\\" to route data.;\");\n return new Error(msg);\n }\n }, {\n key: \"routeDataRequireController\",\n value: function routeDataRequireController() {\n var msg = 'The route data does not contains a \"controller\" file.';\n return new Error(msg);\n }\n }, {\n key: \"routeDataRequireAction\",\n value: function routeDataRequireAction() {\n var msg = 'The route data does not contains a \"action\" file.';\n return new Error(msg);\n }\n }, {\n key: \"viewCanntNull\",\n value: function viewCanntNull() {\n var msg = 'The view or viewDeferred of the page cannt null.';\n return new Error(msg);\n }\n }, {\n key: \"createPageFail\",\n value: function createPageFail(pageName) {\n var msg = \"Create page \\\"\".concat(pageName, \"\\\" fail.\");\n return new Error(msg);\n }\n }, {\n key: \"actionTypeError\",\n value: function actionTypeError(pageName) {\n var msg = \"The action in page '\".concat(pageName, \"' is expect as function.\");\n return new Error(msg);\n }\n }, {\n key: \"canntFindAction\",\n value: function canntFindAction(pageName) {\n var msg = \"Cannt find action in page '\".concat(pageName, \"', is the exports has default field?\");\n return new Error(msg);\n }\n }, {\n key: \"exportsCanntNull\",\n value: function exportsCanntNull(pageName) {\n var msg = \"Exports of page '\".concat(pageName, \"' is null.\");\n return new Error(msg);\n }\n }, {\n key: \"scrollerElementNotExists\",\n value: function scrollerElementNotExists() {\n var msg = \"Scroller element is not exists.\";\n return new Error(msg);\n }\n }, {\n key: \"resourceExists\",\n value: function resourceExists(resourceName, pageName) {\n var msg = \"Rosource '\".concat(resourceName, \"' is exists in the resources of page '\").concat(pageName, \"'.\");\n return new Error(msg);\n }\n }, {\n key: \"siteMapRootCanntNull\",\n value: function siteMapRootCanntNull() {\n var msg = \"The site map root node can not be null.\";\n return new Error(msg);\n }\n }, {\n key: \"duplicateSiteMapNode\",\n value: function duplicateSiteMapNode(name) {\n var msg = \"The site map node \".concat(name, \" is exists.\");\n return new Error(name);\n }\n }]);\n\n return Errors;\n }();\n\n exports.Errors = Errors;\n}).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),\n\t\t\t\t__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));\n//# sourceMappingURL=Errors.js.map\n\n\n//# sourceURL=webpack:///./out-es5/Errors.js?");
/***/ }),
/***/ "./out/Page.js":
/*!*********************!*\
!*** ./out/Page.js ***!
\*********************/
/***/ "./out-es5/Page.js":
/*!*************************!*\
!*** ./out-es5/Page.js ***!
\*************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
eval("var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__, exports, __webpack_require__(/*! maishu-chitu-service */ \"./node_modules/maishu-chitu-service/dist/index.js\")], __WEBPACK_AMD_DEFINE_RESULT__ = (function (require, exports, maishu_chitu_service_1) {\r\n \"use strict\";\r\n Object.defineProperty(exports, \"__esModule\", { value: true });\r\n class Page {\r\n constructor(params) {\r\n this.data = {};\r\n this.showing = maishu_chitu_service_1.Callbacks();\r\n this.shown = maishu_chitu_service_1.Callbacks();\r\n this.hiding = maishu_chitu_service_1.Callbacks();\r\n this.hidden = maishu_chitu_service_1.Callbacks();\r\n this.closing = maishu_chitu_service_1.Callbacks();\r\n this.closed = maishu_chitu_service_1.Callbacks();\r\n this._element = params.element;\r\n this._app = params.app;\r\n this._displayer = params.displayer;\r\n this.data = params.data;\r\n this._name = params.name;\r\n }\r\n on_showing() {\r\n return this.showing.fire(this, this.data);\r\n }\r\n on_shown() {\r\n return this.shown.fire(this, this.data);\r\n }\r\n on_hiding() {\r\n return this.hiding.fire(this, this.data);\r\n }\r\n on_hidden() {\r\n return this.hidden.fire(this, this.data);\r\n }\r\n on_closing() {\r\n return this.closing.fire(this, this.data);\r\n }\r\n on_closed() {\r\n return this.closed.fire(this, this.data);\r\n }\r\n show() {\r\n this.on_showing();\r\n let currentPage = this._app.currentPage;\r\n if (this == currentPage) {\r\n currentPage = null;\r\n }\r\n return this._displayer.show(this, currentPage).then(o => {\r\n this.on_shown();\r\n });\r\n }\r\n hide(currentPage) {\r\n this.on_hiding();\r\n return this._displayer.hide(this, currentPage).then(o => {\r\n this.on_hidden();\r\n });\r\n }\r\n close() {\r\n this.on_closing();\r\n this._element.remove();\r\n this.on_closed();\r\n return Promise.resolve();\r\n }\r\n createService(type) {\r\n type = type || maishu_chitu_service_1.Service;\r\n let service = new type();\r\n service.error.add((sender, error) => {\r\n this._app.error.fire(this._app, error, this);\r\n });\r\n return service;\r\n }\r\n get element() {\r\n return this._element;\r\n }\r\n get name() {\r\n return this._name;\r\n }\r\n get app() {\r\n return this._app;\r\n }\r\n }\r\n Page.tagName = 'div';\r\n exports.Page = Page;\r\n class PageDisplayerImplement {\r\n show(page, previous) {\r\n page.element.style.display = 'block';\r\n if (previous != null) {\r\n previous.element.style.display = 'none';\r\n }\r\n return Promise.resolve();\r\n }\r\n hide(page, previous) {\r\n page.element.style.display = 'none';\r\n if (previous != null) {\r\n previous.element.style.display = 'block';\r\n }\r\n return Promise.resolve();\r\n }\r\n }\r\n exports.PageDisplayerImplement = PageDisplayerImplement;\r\n}).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),\n\t\t\t\t__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));\r\n\n\n//# sourceURL=webpack:///./out/Page.js?");
"use strict";
eval("var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__, exports, __webpack_require__(/*! maishu-chitu-service */ \"./node_modules/maishu-chitu-service/dist/index.js\")], __WEBPACK_AMD_DEFINE_RESULT__ = (function (require, exports, maishu_chitu_service_1) {\n \"use strict\";\n\n Object.defineProperty(exports, \"__esModule\", {\n value: true\n });\n\n var Page =\n /*#__PURE__*/\n function () {\n function Page(params) {\n _classCallCheck(this, Page);\n\n this.data = {};\n this.showing = maishu_chitu_service_1.Callbacks();\n this.shown = maishu_chitu_service_1.Callbacks();\n this.hiding = maishu_chitu_service_1.Callbacks();\n this.hidden = maishu_chitu_service_1.Callbacks();\n this.closing = maishu_chitu_service_1.Callbacks();\n this.closed = maishu_chitu_service_1.Callbacks();\n this._element = params.element;\n this._app = params.app;\n this._displayer = params.displayer;\n this.data = params.data;\n this._name = params.name;\n }\n\n _createClass(Page, [{\n key: \"on_showing\",\n value: function on_showing() {\n return this.showing.fire(this, this.data);\n }\n }, {\n key: \"on_shown\",\n value: function on_shown() {\n return this.shown.fire(this, this.data);\n }\n }, {\n key: \"on_hiding\",\n value: function on_hiding() {\n return this.hiding.fire(this, this.data);\n }\n }, {\n key: \"on_hidden\",\n value: function on_hidden() {\n return this.hidden.fire(this, this.data);\n }\n }, {\n key: \"on_closing\",\n value: function on_closing() {\n return this.closing.fire(this, this.data);\n }\n }, {\n key: \"on_closed\",\n value: function on_closed() {\n return this.closed.fire(this, this.data);\n }\n }, {\n key: \"show\",\n value: function show() {\n var _this = this;\n\n this.on_showing();\n var currentPage = this._app.currentPage;\n\n if (this == currentPage) {\n currentPage = null;\n }\n\n return this._displayer.show(this, currentPage).then(function (o) {\n _this.on_shown();\n });\n }\n }, {\n key: \"hide\",\n value: function hide(currentPage) {\n var _this2 = this;\n\n this.on_hiding();\n return this._displayer.hide(this, currentPage).then(function (o) {\n _this2.on_hidden();\n });\n }\n }, {\n key: \"close\",\n value: function close() {\n this.on_closing();\n\n this._element.remove();\n\n this.on_closed();\n return Promise.resolve();\n }\n }, {\n key: \"createService\",\n value: function createService(type) {\n var _this3 = this;\n\n type = type || maishu_chitu_service_1.Service;\n var service = new type();\n service.error.add(function (sender, error) {\n _this3._app.error.fire(_this3._app, error, _this3);\n });\n return service;\n }\n }, {\n key: \"element\",\n get: function get() {\n return this._element;\n }\n }, {\n key: \"name\",\n get: function get() {\n return this._name;\n }\n }, {\n key: \"app\",\n get: function get() {\n return this._app;\n }\n }]);\n\n return Page;\n }();\n\n Page.tagName = 'div';\n exports.Page = Page;\n\n var PageDisplayerImplement =\n /*#__PURE__*/\n function () {\n function PageDisplayerImplement() {\n _classCallCheck(this, PageDisplayerImplement);\n }\n\n _createClass(PageDisplayerImplement, [{\n key: \"show\",\n value: function show(page, previous) {\n page.element.style.display = 'block';\n\n if (previous != null) {\n previous.element.style.display = 'none';\n }\n\n return Promise.resolve();\n }\n }, {\n key: \"hide\",\n value: function hide(page, previous) {\n page.element.style.display = 'none';\n\n if (previous != null) {\n previous.element.style.display = 'block';\n }\n\n return Promise.resolve();\n }\n }]);\n\n return PageDisplayerImplement;\n }();\n\n exports.PageDisplayerImplement = PageDisplayerImplement;\n}).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),\n\t\t\t\t__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));\n//# sourceMappingURL=Page.js.map\n\n\n//# sourceURL=webpack:///./out-es5/Page.js?");
/***/ }),
/***/ "./out/PageMaster.js":
/*!***************************!*\
!*** ./out/PageMaster.js ***!
\***************************/
/***/ "./out-es5/PageMaster.js":
/*!*******************************!*\
!*** ./out-es5/PageMaster.js ***!
\*******************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
eval("var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n};\r\n!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__, exports, __webpack_require__(/*! maishu-chitu-service */ \"./node_modules/maishu-chitu-service/dist/index.js\"), __webpack_require__(/*! ./Page */ \"./out/Page.js\"), __webpack_require__(/*! ./Errors */ \"./out/Errors.js\")], __WEBPACK_AMD_DEFINE_RESULT__ = (function (require, exports, maishu_chitu_service_1, Page_1, Errors_1) {\r\n \"use strict\";\r\n Object.defineProperty(exports, \"__esModule\", { value: true });\r\n class PageMaster {\r\n constructor(container, parser) {\r\n this.pageCreated = maishu_chitu_service_1.Callbacks();\r\n this.pageShowing = maishu_chitu_service_1.Callbacks();\r\n this.pageShown = maishu_chitu_service_1.Callbacks();\r\n this.pageType = Page_1.Page;\r\n this.pageDisplayType = Page_1.PageDisplayerImplement;\r\n this.cachePages = {};\r\n this.page_stack = new Array();\r\n this.nodes = {};\r\n this.error = maishu_chitu_service_1.Callbacks();\r\n this.parser = parser || this.defaultPageNodeParser();\r\n if (!container)\r\n throw Errors_1.Errors.argumentNull(\"container\");\r\n this.parser.actions = this.parser.actions || {};\r\n this.container = container;\r\n }\r\n defaultPageNodeParser() {\r\n let nodes = {};\r\n let p = {\r\n actions: {},\r\n parse: (pageName) => {\r\n let node = nodes[pageName];\r\n if (node == null) {\r\n let path = `modules_${pageName}`.split('_').join('/');\r\n node = { action: this.createDefaultAction(path, this.loadjs), name: pageName };\r\n nodes[pageName] = node;\r\n }\r\n return node;\r\n }\r\n };\r\n return p;\r\n }\r\n createDefaultAction(url, loadjs) {\r\n return (page) => __awaiter(this, void 0, void 0, function* () {\r\n let actionExports = yield loadjs(url);\r\n if (!actionExports)\r\n throw Errors_1.Errors.exportsCanntNull(url);\r\n let _action = actionExports.default;\r\n if (_action == null) {\r\n throw Errors_1.Errors.canntFindAction(page.name);\r\n }\r\n let result;\r\n if (PageMaster.isClass(_action)) {\r\n let action = _action;\r\n result = new action(page, this);\r\n }\r\n else {\r\n let action = _action;\r\n result = action(page, this);\r\n }\r\n return result;\r\n });\r\n }\r\n loadjs(path) {\r\n return new Promise((reslove, reject) => {\r\n requirejs([path], function (result) {\r\n reslove(result);\r\n }, function (err) {\r\n reject(err);\r\n });\r\n });\r\n }\r\n on_pageCreated(page) {\r\n return this.pageCreated.fire(this, page);\r\n }\r\n get currentPage() {\r\n if (this.page_stack.length > 0)\r\n return this.page_stack[this.page_stack.length - 1];\r\n return null;\r\n }\r\n getPage(node, values) {\r\n console.assert(node != null);\r\n values = values || {};\r\n let pageName = node.name;\r\n let cachePage = this.cachePages[pageName];\r\n if (cachePage != null) {\r\n cachePage.data = values || {};\r\n return { page: cachePage, isNew: false };\r\n }\r\n let page = this.createPage(pageName, values);\r\n this.cachePages[pageName] = page;\r\n this.on_pageCreated(page);\r\n return { page, isNew: true };\r\n }\r\n createPage(pageName, values) {\r\n if (!pageName)\r\n throw Errors_1.Errors.argumentNull('pageName');\r\n values = values || {};\r\n let element = this.createPageElement(pageName);\r\n let displayer = new this.pageDisplayType(this);\r\n console.assert(this.pageType != null);\r\n let page = new this.pageType({\r\n app: this,\r\n name: pageName,\r\n data: values,\r\n displayer,\r\n element,\r\n });\r\n let showing = (sender) => {\r\n this.pageShowing.fire(this, sender);\r\n };\r\n let shown = (sender) => {\r\n this.pageShown.fire(this, sender);\r\n };\r\n page.showing.add(showing);\r\n page.shown.add(shown);\r\n page.closed.add(() => {\r\n page.showing.remove(showing);\r\n page.shown.remove(shown);\r\n });\r\n return page;\r\n }\r\n createPageElement(pageName) {\r\n let element = document.createElement(Page_1.Page.tagName);\r\n this.container.appendChild(element);\r\n return element;\r\n }\r\n showPage(pageName, args, forceRender) {\r\n args = args || {};\r\n forceRender = forceRender == null ? false : true;\r\n if (!pageName)\r\n throw Errors_1.Errors.argumentNull('pageName');\r\n let node = this.findSiteMapNode(pageName);\r\n if (node == null)\r\n throw Errors_1.Errors.pageNodeNotExists(pageName);\r\n if (this.currentPage != null && this.currentPage.name == pageName)\r\n return this.currentPage;\r\n let { page, isNew } = this.getPage(node, args);\r\n if (isNew || forceRender) {\r\n let siteMapNode = this.findSiteMapNode(pageName);\r\n if (siteMapNode == null)\r\n throw Errors_1.Errors.pageNodeNotExists(pageName);\r\n let action = siteMapNode.action;\r\n if (action == null)\r\n throw Errors_1.Errors.actionCanntNull(pageName);\r\n action(page, this);\r\n }\r\n page.show();\r\n this.pushPage(page);\r\n console.assert(page == this.currentPage, \"page is not current page\");\r\n return page;\r\n }\r\n closePage(page) {\r\n if (page == null)\r\n throw Errors_1.Errors.argumentNull('page');\r\n page.close();\r\n delete this.cachePages[page.name];\r\n this.page_stack = this.page_stack.filter(o => o != page);\r\n }\r\n pushPage(page) {\r\n this.page_stack.push(page);\r\n }\r\n findSiteMapNode(pageName) {\r\n if (this.nodes[pageName])\r\n return this.nodes[pageName];\r\n let node = null;\r\n let action = this.parser.actions ? this.parser.actions[pageName] : null;\r\n if (action != null) {\r\n node = { action, name: pageName };\r\n }\r\n if (node == null && this.parser.parse != null) {\r\n node = this.parser.parse(pageName);\r\n console.assert(node.action != null);\r\n }\r\n if (node != null)\r\n this.nodes[pageName] = node;\r\n return node;\r\n }\r\n closeCurrentPage(passData) {\r\n var page = this.page_stack.pop();\r\n if (page == null)\r\n return;\r\n this.closePage(page);\r\n if (this.currentPage) {\r\n if (passData) {\r\n console.assert(this.currentPage.data != null);\r\n this.currentPage.data = Object.assign(this.currentPage.data, passData);\r\n }\r\n this.currentPage.show();\r\n }\r\n }\r\n get pageStack() {\r\n return this.page_stack;\r\n }\r\n }\r\n PageMaster.isClass = (function () {\r\n var toString = Function.prototype.toString;\r\n function fnBody(fn) {\r\n return toString.call(fn).replace(/^[^{]*{\\s*/, '').replace(/\\s*}[^}]*$/, '');\r\n }\r\n function isClass(fn) {\r\n return (typeof fn === 'function' &&\r\n (/^class(\\s|\\{\\}$)/.test(toString.call(fn)) ||\r\n (/^.*classCallCheck\\(/.test(fnBody(fn)))));\r\n }\r\n return isClass;\r\n })();\r\n exports.PageMaster = PageMaster;\r\n}).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),\n\t\t\t\t__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));\r\n\n\n//# sourceURL=webpack:///./out/PageMaster.js?");
"use strict";
eval("var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nvar __awaiter = void 0 && (void 0).__awaiter || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n\n function step(result) {\n result.done ? resolve(result.value) : new P(function (resolve) {\n resolve(result.value);\n }).then(fulfilled, rejected);\n }\n\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__, exports, __webpack_require__(/*! maishu-chitu-service */ \"./node_modules/maishu-chitu-service/dist/index.js\"), __webpack_require__(/*! ./Page */ \"./out-es5/Page.js\"), __webpack_require__(/*! ./Errors */ \"./out-es5/Errors.js\")], __WEBPACK_AMD_DEFINE_RESULT__ = (function (require, exports, maishu_chitu_service_1, Page_1, Errors_1) {\n \"use strict\";\n\n Object.defineProperty(exports, \"__esModule\", {\n value: true\n });\n\n var PageMaster =\n /*#__PURE__*/\n function () {\n function PageMaster(container, parser) {\n _classCallCheck(this, PageMaster);\n\n this.pageCreated = maishu_chitu_service_1.Callbacks();\n this.pageShowing = maishu_chitu_service_1.Callbacks();\n this.pageShown = maishu_chitu_service_1.Callbacks();\n this.pageType = Page_1.Page;\n this.pageDisplayType = Page_1.PageDisplayerImplement;\n this.cachePages = {};\n this.page_stack = new Array();\n this.nodes = {};\n this.error = maishu_chitu_service_1.Callbacks();\n this.parser = parser || this.defaultPageNodeParser();\n if (!container) throw Errors_1.Errors.argumentNull(\"container\");\n this.parser.actions = this.parser.actions || {};\n this.container = container;\n }\n\n _createClass(PageMaster, [{\n key: \"defaultPageNodeParser\",\n value: function defaultPageNodeParser() {\n var _this = this;\n\n var nodes = {};\n var p = {\n actions: {},\n parse: function parse(pageName) {\n var node = nodes[pageName];\n\n if (node == null) {\n var path = \"modules_\".concat(pageName).split('_').join('/');\n node = {\n action: _this.createDefaultAction(path, _this.loadjs),\n name: pageName\n };\n nodes[pageName] = node;\n }\n\n return node;\n }\n };\n return p;\n }\n }, {\n key: \"createDefaultAction\",\n value: function createDefaultAction(url, loadjs) {\n var _this2 = this;\n\n return function (page) {\n return __awaiter(_this2, void 0, void 0,\n /*#__PURE__*/\n regeneratorRuntime.mark(function _callee() {\n var actionExports, _action, result, action, _action2;\n\n return regeneratorRuntime.wrap(function _callee$(_context) {\n while (1) {\n switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return loadjs(url);\n\n case 2:\n actionExports = _context.sent;\n\n if (actionExports) {\n _context.next = 5;\n break;\n }\n\n throw Errors_1.Errors.exportsCanntNull(url);\n\n case 5:\n _action = actionExports[\"default\"];\n\n if (!(_action == null)) {\n _context.next = 8;\n break;\n }\n\n throw Errors_1.Errors.canntFindAction(page.name);\n\n case 8:\n if (PageMaster.isClass(_action)) {\n action = _action;\n result = new action(page, this);\n } else {\n _action2 = _action;\n result = _action2(page, this);\n }\n\n return _context.abrupt(\"return\", result);\n\n case 10:\n case \"end\":\n return _context.stop();\n }\n }\n }, _callee, this);\n }));\n };\n }\n }, {\n key: \"loadjs\",\n value: function loadjs(path) {\n return new Promise(function (reslove, reject) {\n requirejs([path], function (result) {\n reslove(result);\n }, function (err) {\n reject(err);\n });\n });\n }\n }, {\n key: \"on_pageCreated\",\n value: function on_pageCreated(page) {\n return this.pageCreated.fire(this, page);\n }\n }, {\n key: \"getPage\",\n value: function getPage(node, values) {\n console.assert(node != null);\n values = values || {};\n var pageName = node.name;\n var cachePage = this.cachePages[pageName];\n\n if (cachePage != null) {\n cachePage.data = values || {};\n return {\n page: cachePage,\n isNew: false\n };\n }\n\n var page = this.createPage(pageName, values);\n this.cachePages[pageName] = page;\n this.on_pageCreated(page);\n return {\n page: page,\n isNew: true\n };\n }\n }, {\n key: \"createPage\",\n value: function createPage(pageName, values) {\n var _this3 = this;\n\n if (!pageName) throw Errors_1.Errors.argumentNull('pageName');\n values = values || {};\n var element = this.createPageElement(pageName);\n var displayer = new this.pageDisplayType(this);\n console.assert(this.pageType != null);\n var page = new this.pageType({\n app: this,\n name: pageName,\n data: values,\n displayer: displayer,\n element: element\n });\n\n var showing = function showing(sender) {\n _this3.pageShowing.fire(_this3, sender);\n };\n\n var shown = function shown(sender) {\n _this3.pageShown.fire(_this3, sender);\n };\n\n page.showing.add(showing);\n page.shown.add(shown);\n page.closed.add(function () {\n page.showing.remove(showing);\n page.shown.remove(shown);\n });\n return page;\n }\n }, {\n key: \"createPageElement\",\n value: function createPageElement(pageName) {\n var element = document.createElement(Page_1.Page.tagName);\n this.container.appendChild(element);\n return element;\n }\n }, {\n key: \"showPage\",\n value: function showPage(pageName, args, forceRender) {\n args = args || {};\n forceRender = forceRender == null ? false : true;\n if (!pageName) throw Errors_1.Errors.argumentNull('pageName');\n var node = this.findSiteMapNode(pageName);\n if (node == null) throw Errors_1.Errors.pageNodeNotExists(pageName);\n if (this.currentPage != null && this.currentPage.name == pageName) return this.currentPage;\n\n var _this$getPage = this.getPage(node, args),\n page = _this$getPage.page,\n isNew = _this$getPage.isNew;\n\n if (isNew || forceRender) {\n var siteMapNode = this.findSiteMapNode(pageName);\n if (siteMapNode == null) throw Errors_1.Errors.pageNodeNotExists(pageName);\n var action = siteMapNode.action;\n if (action == null) throw Errors_1.Errors.actionCanntNull(pageName);\n action(page, this);\n }\n\n page.show();\n this.pushPage(page);\n console.assert(page == this.currentPage, \"page is not current page\");\n return page;\n }\n }, {\n key: \"closePage\",\n value: function closePage(page) {\n if (page == null) throw Errors_1.Errors.argumentNull('page');\n page.close();\n delete this.cachePages[page.name];\n this.page_stack = this.page_stack.filter(function (o) {\n return o != page;\n });\n }\n }, {\n key: \"pushPage\",\n value: function pushPage(page) {\n this.page_stack.push(page);\n }\n }, {\n key: \"findSiteMapNode\",\n value: function findSiteMapNode(pageName) {\n if (this.nodes[pageName]) return this.nodes[pageName];\n var node = null;\n var action = this.parser.actions ? this.parser.actions[pageName] : null;\n\n if (action != null) {\n node = {\n action: action,\n name: pageName\n };\n }\n\n if (node == null && this.parser.parse != null) {\n node = this.parser.parse(pageName);\n console.assert(node.action != null);\n }\n\n if (node != null) this.nodes[pageName] = node;\n return node;\n }\n }, {\n key: \"closeCurrentPage\",\n value: function closeCurrentPage(passData) {\n var page = this.page_stack.pop();\n if (page == null) return;\n this.closePage(page);\n\n if (this.currentPage) {\n if (passData) {\n console.assert(this.currentPage.data != null);\n this.currentPage.data = Object.assign(this.currentPage.data, passData);\n }\n\n this.currentPage.show();\n }\n }\n }, {\n key: \"currentPage\",\n get: function get() {\n if (this.page_stack.length > 0) return this.page_stack[this.page_stack.length - 1];\n return null;\n }\n }, {\n key: \"pageStack\",\n get: function get() {\n return this.page_stack;\n }\n }]);\n\n return PageMaster;\n }();\n\n PageMaster.isClass = function () {\n var toString = Function.prototype.toString;\n\n function fnBody(fn) {\n return toString.call(fn).replace(/^[^{]*{\\s*/, '').replace(/\\s*}[^}]*$/, '');\n }\n\n function isClass(fn) {\n return typeof fn === 'function' && (/^class(\\s|\\{\\}$)/.test(toString.call(fn)) || /^.*classCallCheck\\(/.test(fnBody(fn)));\n }\n\n return isClass;\n }();\n\n exports.PageMaster = PageMaster;\n}).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),\n\t\t\t\t__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));\n//# sourceMappingURL=PageMaster.js.map\n\n\n//# sourceURL=webpack:///./out-es5/PageMaster.js?");
/***/ }),
/***/ "./out/index.js":
/*!**********************!*\
!*** ./out/index.js ***!
\**********************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
eval("var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__, exports, __webpack_require__(/*! ./Application */ \"./out/Application.js\"), __webpack_require__(/*! ./PageMaster */ \"./out/PageMaster.js\"), __webpack_require__(/*! ./Page */ \"./out/Page.js\"), __webpack_require__(/*! maishu-chitu-service */ \"./node_modules/maishu-chitu-service/dist/index.js\")], __WEBPACK_AMD_DEFINE_RESULT__ = (function (require, exports, Application_1, PageMaster_1, Page_1, maishu_chitu_service_1) {\r\n \"use strict\";\r\n Object.defineProperty(exports, \"__esModule\", { value: true });\r\n exports.Application = Application_1.Application;\r\n exports.PageMaster = PageMaster_1.PageMaster;\r\n exports.Page = Page_1.Page;\r\n exports.Callback = maishu_chitu_service_1.Callback;\r\n exports.Callbacks = maishu_chitu_service_1.Callbacks;\r\n exports.ValueStore = maishu_chitu_service_1.ValueStore;\r\n exports.Service = maishu_chitu_service_1.Service;\r\n}).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),\n\t\t\t\t__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));\r\n\n\n//# sourceURL=webpack:///./out/index.js?");
/***/ })
/******/ })});; reslove(result);\n }, function (err) {\n reject(err);\n });\n });\n }\n }, {\n key: \"on_pageCreated\",\n value: function on_pageCreated(page) {\n return this.pageCreated.fire(this, page);\n }\n }, {\n key: \"getPage\",\n value: function getPage(node, values) {\n console.assert(node != null);\n values = values || {};\n var pageName = node.name;\n var cachePage = this.cachePages[pageName];\n\n if (cachePage != null) {\n cachePage.data = values || {};\n return {\n page: cachePage,\n isNew: false\n };\n }\n\n var page = this.createPage(pageName, values);\n this.cachePages[pageName] = page;\n this.on_pageCreated(page);\n return {\n page: page,\n isNew: true\n };\n }\n }, {\n key: \"createPage\",\n value: function createPage(pageName, values) {\n var _this3 = this;\n\n if (!pageName) throw Errors_1.Errors.argumentNull('pageName');\n values = values || {};\n var element = this.createPageElement(pageName);\n var displayer = new this.pageDisplayType(this);\n console.assert(this.pageType != null);\n var page = new this.pageType({\n app: this,\n name: pageName,\n data: values,\n displayer: displayer,\n element: element\n });\n\n var showing = function showing(sender) {\n _this3.pageShowing.fire(_this3, sender);\n };\n\n var shown = function shown(sender) {\n _this3.pageShown.fire(_this3, sender);\n };\n\n page.showing.add(showing);\n page.shown.add(shown);\n page.closed.add(function () {\n page.showing.remove(showing);\n page.shown.remove(shown);\n });\n return page;\n }\n }, {\n key: \"createPageElement\",\n value: function createPageElement(pageName) {\n var element = document.createElement(Page_1.Page.tagName);\n this.container.appendChild(element);\n return element;\n }\n }, {\n key: \"showPage\",\n value: function showPage(pageName, args, forceRender) {\n args = args || {};\n forceRender = forceRender == null ? false : true;\n if (!pageName) throw Errors_1.Errors.argumentNull('pageName');\n var node = this.findSiteMapNode(pageName);\n if (node == null) throw Errors_1.Errors.pageNodeNotExists(pageName);\n if (this.currentPage != null && this.currentPage.name == pageName) return this.currentPage;\n\n var _this$getPage = this.getPage(node, args),\n page = _this$getPage.page,\n isNew = _this$getPage.isNew;\n\n if (isNew || forceRender) {\n var siteMapNode = this.findSiteMapNode(pageName);\n if (siteMapNode == null) throw Errors_1.Errors.pageNodeNotExists(pageName);\n var action = siteMapNode.action;\n if (action == null) throw Errors_1.Errors.actionCanntNull(pageName);\n action(page, this);\n }\n\n page.show();\n this.pushPage(page);\n console.assert(page == this.currentPage, \"page is not current page\");\n return page;\n }\n }, {\n key: \"closePage\",\n value: function closePage(page) {\n if (page == null) throw Errors_1.Errors.argumentNull('page');\n page.close();\n delete this.cachePages[page.name];\n this.page_stack = this.page_stack.filter(function (o) {\n return o != page;\n });\n }\n }, {\n key: \"pushPage\",\n value: function pushPage(page) {\n this.page_stack.push(page);\n }\n }, {\n key: \"findSiteMapNode\",\n value: function findSiteMapNode(pageName) {\n if (this.nodes[pageName]) return this.nodes[pageName];\n var node = null;\n var action = this.parser.actions ? this.parser.actions[pageName] : null;\n\n if (action != null) {\n node = {\n action: action,\n name: pageName\n };\n }\n\n if (node == null && this.parser.parse != null) {\n node = this.parser.parse(pageName);\n console.assert(node.action != null);\n }\n\n if (node != null) this.nodes[pageName] = node;\n return node;\n }\n }, {\n key: \"closeCurrentPage\",\n value: function closeCurrentPage(passData) {\n var page = this.page_stack.pop();\n if (page == null) return;\n this.closePage(page);\n\n if (this.currentPage) {\n if (passData) {\n console.assert(this.currentPage.data != null);\n this.currentPage.data = Object.assign(this.currentPage.data, passData);\n }\n\n this.currentPage.show();\n }\n }\n }, {\n key: \"currentPage\",\n get: function get() {\n if (this.page_stack.length > 0) return this.page_stack[this.page_stack.length - 1];\n return null;\n }\n }, {\n key: \"pageStack\",\n get: function get() {\n return this.page_stack;\n }\n }]);\n\n return PageMaster;\n }();\n\n PageMaster.isClass = function () {\n var toString = Function.prototype.toString;\n\n function fnBody(fn) {\n return toString.call(fn).replace(/^[^{]*{\\s*/, '').replace(/\\s*}[^}]*$/, '');\n }\n\n function isClass(fn) {\n return typeof fn === 'function' && (/^class(\\s|\\{\\}$)/.test(toString.call(fn)) || /^.*classCallCheck\\(/.test(fnBody(fn)));\n }\n\n return isClass;\n }();\n\n exports.PageMaster = PageMaster;\n}).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),\n\t\t\t\t__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));\n//# sourceMappingURL=PageMaster.js.map\n\n\n//# sourceURL=webpack:///./out-es5/PageMaster.js?");
/***/ }),
/***/ "./out-es5/index.js":

@@ -171,0 +160,0 @@ /*!**************************!*\

@@ -0,7 +1,8 @@

import { Callback1, Callback2 } from "maishu-chitu-service";
import { Page, PageConstructor, PageDisplayConstructor } from "./Page";
import { PageNodeParser, PageNode, StringPropertyNames, Action } from "./Application";
export declare class PageMaster {
pageCreated: import("../node_modules/maishu-chitu-service/out/callback").Callback1<this, Page>;
pageShowing: import("../node_modules/maishu-chitu-service/out/callback").Callback1<this, Page>;
pageShown: import("../node_modules/maishu-chitu-service/out/callback").Callback1<this, Page>;
pageCreated: Callback1<this, Page>;
pageShowing: Callback1<this, Page>;
pageShown: Callback1<this, Page>;
protected pageType: PageConstructor;

@@ -13,3 +14,3 @@ protected pageDisplayType: PageDisplayConstructor;

private nodes;
error: import("../node_modules/maishu-chitu-service/out/callback").Callback2<this, Error, Page | null>;
error: Callback2<this, Error, Page | null>;
parser: PageNodeParser;

@@ -16,0 +17,0 @@ constructor(container: HTMLElement, parser?: PageNodeParser);

@@ -36,3 +36,3 @@ {

},
"version": "2.9.12"
"version": "2.9.14"
}

@@ -1,2 +0,2 @@

import { Callbacks } from "maishu-chitu-service";
import { Callbacks, Callback1, Callback2 } from "maishu-chitu-service";
import { Page, PageConstructor, PageDisplayConstructor, PageDisplayerImplement } from "./Page";

@@ -14,9 +14,9 @@ import { PageNodeParser, PageNode, StringPropertyNames, Action } from "./Application";

*/
pageCreated = Callbacks<this, Page>();
pageCreated: Callback1<this, Page> = Callbacks<this, Page>();
/** 页面显示时引发 */
pageShowing = Callbacks<this, Page>();
pageShowing: Callback1<this, Page> = Callbacks<this, Page>();
/** 页面显示时完成后引发 */
pageShown = Callbacks<this, Page>();
pageShown: Callback1<this, Page> = Callbacks<this, Page>();

@@ -34,3 +34,3 @@ protected pageType: PageConstructor = Page;

*/
error = Callbacks<this, Error, Page | null>();
error: Callback2<this, Error, Page | null> = Callbacks<this, Error, Page | null>();
parser: PageNodeParser;

@@ -37,0 +37,0 @@

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