maishu-toolkit
Advanced tools
Comparing version 1.8.0 to 1.8.2
/*! | ||
* ~ | ||
* maishu-toolkit v1.7.3 | ||
* maishu-toolkit v1.8.1 | ||
* https://github.com/ansiboy/toolkit | ||
@@ -937,3 +937,3 @@ * | ||
}); | ||
exports.ValueStore = exports.HTML = exports.formatString = exports.formatDate = exports.objectAssignDeep = exports.deepEqual = exports.parseUrl = exports.DataSourceSelectArguments = exports.DataSource = exports.Callback = exports.errors = exports.Errors = exports.pathConcat = exports.guid = void 0; | ||
exports.SingleInvoke = exports.ValueStore = exports.HTML = exports.formatString = exports.formatDate = exports.objectAssignDeep = exports.deepEqual = exports.parseUrl = exports.DataSourceSelectArguments = exports.DataSource = exports.Callback = exports.errors = exports.Errors = exports.pathConcat = exports.guid = void 0; | ||
@@ -1056,2 +1056,11 @@ var guid_1 = __webpack_require__(/*! ./guid */ "./out-es5/guid.js"); | ||
}); | ||
var single_inoke_1 = __webpack_require__(/*! ./single-inoke */ "./out-es5/single-inoke.js"); | ||
Object.defineProperty(exports, "SingleInvoke", { | ||
enumerable: true, | ||
get: function get() { | ||
return single_inoke_1.SingleInvoke; | ||
} | ||
}); | ||
//# sourceMappingURL=index.js.map | ||
@@ -1072,2 +1081,10 @@ | ||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } | ||
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } | ||
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } | ||
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -1102,14 +1119,26 @@ value: true | ||
path2 = path2.replace(/(\/+\\*|\\+\/*)/g, '/'); | ||
var arr1 = path1.split('/'); | ||
var arr2 = path2.split('/'); | ||
var arr1 = path1.split('/').filter(function (o) { | ||
return o; | ||
}); | ||
var arr2 = path2.split('/').filter(function (o) { | ||
return o; | ||
}); | ||
if (path1[0] == "/") { | ||
arr1.unshift(""); | ||
} | ||
while (arr2[0] == "." || arr2[0] == "..") { | ||
if (arr2[0] == "..") arr1.pop(); | ||
if (arr2[0] == ".." && arr1.length > 0 && arr1[arr1.length - 1] != "") { | ||
arr1.pop(); | ||
} | ||
arr2.shift(); | ||
} | ||
path1 = arr1.join('/'); | ||
path2 = arr2.join('/'); | ||
if (!path1) return path2; | ||
var path = path1.endsWith("/") ? path1 + path2 : path1 + '/' + path2; | ||
if (arr1.length == 1 && arr1[0] == "" && arr2.length == 0) { | ||
return "/"; | ||
} | ||
var path = [].concat(_toConsumableArray(arr1), _toConsumableArray(arr2)).join("/"); | ||
return path; | ||
@@ -1124,2 +1153,88 @@ } | ||
/***/ "./out-es5/single-inoke.js": | ||
/*!*********************************!*\ | ||
!*** ./out-es5/single-inoke.js ***! | ||
\*********************************/ | ||
/*! no static exports found */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _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); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.SingleInvoke = void 0; | ||
var value_store_1 = __webpack_require__(/*! ./value-store */ "./out-es5/value-store.js"); | ||
var SingleInvoke = | ||
/*#__PURE__*/ | ||
function () { | ||
function SingleInvoke(func) { | ||
_classCallCheck(this, SingleInvoke); | ||
this.result = new value_store_1.ValueStore(undefined); | ||
this.error = new value_store_1.ValueStore(undefined); | ||
this.executing = false; | ||
this.func = func; | ||
} | ||
_createClass(SingleInvoke, [{ | ||
key: "clear", | ||
value: function clear() { | ||
this.result = new value_store_1.ValueStore(undefined); | ||
this.error = new value_store_1.ValueStore(undefined); | ||
} | ||
}, { | ||
key: "execute", | ||
value: function execute() { | ||
var _this = this; | ||
if (this.result.value !== undefined) { | ||
return Promise.resolve(this.result.value); | ||
} | ||
if (this.executing) { | ||
return new Promise(function (resolve, reject) { | ||
_this.result.add(function (value) { | ||
resolve(value); | ||
}); | ||
_this.error.add(function (err) { | ||
reject(err); | ||
}); | ||
}); | ||
} | ||
this.executing = true; | ||
return new Promise(function (resolve, reject) { | ||
_this.func().then(function (r) { | ||
_this.result.value = r || null; | ||
_this.executing = false; | ||
resolve(r); | ||
}).catch(function (err) { | ||
_this.error = err; | ||
_this.executing = false; | ||
reject(err); | ||
}); | ||
}); | ||
} | ||
}]); | ||
return SingleInvoke; | ||
}(); | ||
exports.SingleInvoke = SingleInvoke; | ||
//# sourceMappingURL=single-inoke.js.map | ||
/***/ }), | ||
/***/ "./out-es5/url.js": | ||
@@ -1240,3 +1355,2 @@ /*!************************!*\ | ||
get: function get() { | ||
if (this._value === undefined) return null; | ||
return this._value; | ||
@@ -1243,0 +1357,0 @@ }, |
/*! | ||
* ~ | ||
* maishu-toolkit v1.7.3 | ||
* maishu-toolkit v1.8.1 | ||
* https://github.com/ansiboy/toolkit | ||
@@ -10,3 +10,3 @@ * | ||
*/ | ||
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}("undefined"==typeof window?global:window,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var a=t[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,r),a.l=!0,a.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)r.d(n,a,function(t){return e[t]}.bind(null,a));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=2)}([function(e,t,r){"use strict";function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}Object.defineProperty(t,"__esModule",{value:!0}),t.errors=t.Errors=void 0;var a=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}var t,r,a;return t=e,(r=[{key:"argumentNull",value:function(e){var t=new Error("Argument ".concat(e," cannt be null or emtpy."));return t.name="argumentNull",t}},{key:"routeDataFieldNull",value:function(e){var t="The ".concat(e," field of route data cannt be null."),r=new Error(t);return r.name="routeDataFieldNull",r}},{key:"argumentFieldNull",value:function(e,t){var r="The ".concat(e," field of ").concat(t," cannt be null."),n=new Error(r);return n.name="argumentFieldNull",n}},{key:"argumentTypeIncorrect",value:function(e,t){var r="Argument ".concat(e," type error, expected type is ").concat(t,"."),n=new Error(r);return n.name="argumentTypeIncorrect",n}},{key:"pathStartsHttp",value:function(e){var t="Path ".concat(e," start with http or https."),r=new Error(t);return r.name="pathStartsHttp",r}}])&&n(t.prototype,r),a&&n(t,a),e}();t.Errors=a,t.errors=new a},function(e,t,r){"use strict";function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}Object.defineProperty(t,"__esModule",{value:!0}),t.Callback=void 0;var a=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.funcs=new Array}var t,r,a;return t=e,a=[{key:"create",value:function(){return new e}}],(r=[{key:"add",value:function(e){this.funcs.push(e)}},{key:"remove",value:function(e){this.funcs=this.funcs.filter((function(t){return t!=e}))}},{key:"fire",value:function(e){this.funcs.forEach((function(t){return t(e)}))}}])&&n(t.prototype,r),a&&n(t,a),e}();t.Callback=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ValueStore=t.HTML=t.formatString=t.formatDate=t.objectAssignDeep=t.deepEqual=t.parseUrl=t.DataSourceSelectArguments=t.DataSource=t.Callback=t.errors=t.Errors=t.pathConcat=t.guid=void 0;var n=r(3);Object.defineProperty(t,"guid",{enumerable:!0,get:function(){return n.guid}});var a=r(4);Object.defineProperty(t,"pathConcat",{enumerable:!0,get:function(){return a.pathConcat}});var o=r(0);Object.defineProperty(t,"Errors",{enumerable:!0,get:function(){return o.Errors}}),Object.defineProperty(t,"errors",{enumerable:!0,get:function(){return o.errors}});var u=r(1);Object.defineProperty(t,"Callback",{enumerable:!0,get:function(){return u.Callback}});var i=r(5);Object.defineProperty(t,"DataSource",{enumerable:!0,get:function(){return i.DataSource}}),Object.defineProperty(t,"DataSourceSelectArguments",{enumerable:!0,get:function(){return i.DataSourceSelectArguments}});var c=r(6);Object.defineProperty(t,"parseUrl",{enumerable:!0,get:function(){return c.parseUrl}});var l=r(7);Object.defineProperty(t,"deepEqual",{enumerable:!0,get:function(){return l.deepEqual}});var s=r(8);Object.defineProperty(t,"objectAssignDeep",{enumerable:!0,get:function(){return s.objectAssignDeep}});var f=r(9);Object.defineProperty(t,"formatDate",{enumerable:!0,get:function(){return f.formatDate}}),Object.defineProperty(t,"formatString",{enumerable:!0,get:function(){return f.formatString}});var d=r(10);Object.defineProperty(t,"HTML",{enumerable:!0,get:function(){return d.HTML}});var y=r(11);Object.defineProperty(t,"ValueStore",{enumerable:!0,get:function(){return y.ValueStore}})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.guid=void 0,t.guid=function(){function e(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}return e()+e()+"-"+e()+"-"+e()+"-"+e()+"-"+e()+e()+e()}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.partConcat2=t.pathConcat=void 0;var n=r(0);function a(e,t){if(e.startsWith("http://")||e.startsWith("https://"))throw n.errors.pathStartsHttp(e);if(t.startsWith("http://")||t.startsWith("https://"))throw n.errors.pathStartsHttp(t);e=e.replace(/(\/+\\*|\\+\/*)/g,"/"),t=t.replace(/(\/+\\*|\\+\/*)/g,"/");for(var r=e.split("/"),a=t.split("/");"."==a[0]||".."==a[0];)".."==a[0]&&r.pop(),a.shift();return e=r.join("/"),t=a.join("/"),e?e.endsWith("/")?e+t:e+"/"+t:t}t.pathConcat=function(e){var t="";e.startsWith("http://")?t="http://":e.startsWith("https://")&&(t="https://"),e=e.substring(t.length);for(var r=0;r<(arguments.length<=1?0:arguments.length-1);r++)e=a(e,r+1<1||arguments.length<=r+1?void 0:arguments[r+1]);return e=t+e},t.partConcat2=a},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}Object.defineProperty(t,"__esModule",{value:!0}),t.DataSourceSelectArguments=t.DataSource=void 0;var o=r(0),u=r(1),i=Object.assign(o.errors,{dataSourceCanntInsert:function(){return new Error("DataSource can not insert.")},dataSourceCanntDelete:function(){return new Error("DataSource can not delete.")},dataSourceCanntUpdate:function(){return new Error("DataSource can not update.")},primaryKeyNull:function(e){var t="Primary key named '".concat(e,"' value is null.");return new Error(t)},queryResultTypeError:function(){return new Error("Query result type error.")}}),c=function(){function e(t){n(this,e),this.inserting=new u.Callback,this.inserted=new u.Callback,this.deleting=new u.Callback,this.deleted=new u.Callback,this.updating=new u.Callback,this.updated=new u.Callback,this.selecting=new u.Callback,this.selected=new u.Callback,this.error=new u.Callback,this.args=t,this.primaryKeys=t.primaryKeys||[]}var t,r,o;return t=e,(r=[{key:"executeInsert",value:function(e,t){return this.args.insert(e,t)}},{key:"executeDelete",value:function(e,t){return this.args.delete(e,t)}},{key:"executeUpdate",value:function(e,t){return this.args.update(e,t)}},{key:"executeSelect",value:function(e){return e=e||{},this.args.select(e)}},{key:"insert",value:function(e,t,r){var n=this;if(!this.canInsert)throw i.dataSourceCanntInsert();if(!e)throw i.argumentNull("item");return"number"==typeof t&&(r=t,t=null),this.inserting.fire({sender:this,dataItem:e,index:r}),this.executeInsert(e,t).then((function(t){return Object.assign(e,t),n.inserted.fire({sender:n,dataItem:e,index:r}),t})).catch((function(e){throw n.processError(e,"insert"),e}))}},{key:"delete",value:function(e,t){var r=this;if(!this.canDelete)throw i.dataSourceCanntDelete();if(!e)throw i.argumentNull("item");return this.checkPrimaryKeys(e),this.deleting.fire({sender:this,dataItem:e}),this.executeDelete(e,t).then((function(t){return r.deleted.fire({sender:r,dataItem:e}),t})).catch((function(e){throw r.processError(e,"delete"),e}))}},{key:"update",value:function(e,t){var r=this;if(!this.canUpdate)throw i.dataSourceCanntUpdate();if(!e)throw i.argumentNull("item");return this.checkPrimaryKeys(e),this.updating.fire({sender:this,dataItem:e}),this.executeUpdate(e,t).then((function(t){return Object.assign(e,t),r.updated.fire({sender:r,dataItem:e}),t})).catch((function(e){throw r.processError(e,"update"),e}))}},{key:"isSameItem",value:function(e,t){if(null==e)throw i.argumentNull("theItem");if(null==t)throw i.argumentNull("otherItem");if(0==this.primaryKeys.length)return e==t;this.checkPrimaryKeys(e),this.checkPrimaryKeys(t);var r=!0,n=!1,a=void 0;try{for(var o,u=this.primaryKeys[Symbol.iterator]();!(r=(o=u.next()).done);r=!0){var c=o.value;if(e[c]!=t[c])return!1}}catch(e){n=!0,a=e}finally{try{r||null==u.return||u.return()}finally{if(n)throw a}}return!0}},{key:"checkPrimaryKeys",value:function(e){for(var t in e)if(null==e[t]&&this.primaryKeys.indexOf(t)>=0)throw i.primaryKeyNull(t)}},{key:"select",value:function(e){var t=this;return e=e||{},this.selecting.fire({sender:this,selectArguments:e}),this.executeSelect(e).then((function(r){var n,a;if(Array.isArray(r))n=r,a=r.length;else{if(void 0===r.dataItems||void 0===r.totalRowCount)throw i.queryResultTypeError();n=r.dataItems,a=r.totalRowCount}return t.selected.fire({sender:t,selectResult:{totalRowCount:a,dataItems:n},selectArguments:e}),{totalRowCount:a,dataItems:n}})).catch((function(e){throw t.processError(e,"select"),e}))}},{key:"processError",value:function(e,t){if(e.method=t,this.error.fire({sender:this,error:e}),!e.handled)throw e}},{key:"canDelete",get:function(){return null!=this.args.delete&&this.primaryKeys.length>0}},{key:"canInsert",get:function(){return null!=this.args.insert&&this.primaryKeys.length>0}},{key:"canUpdate",get:function(){return null!=this.args.update&&this.primaryKeys.length>0}}])&&a(t.prototype,r),o&&a(t,o),e}();t.DataSource=c;t.DataSourceSelectArguments=function e(){n(this,e),this.startRowIndex=0,this.maximumRows=2147483647}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseUrl=void 0,t.parseUrl=function(e){var t=e.indexOf("?");return t<0?{}:function(e){var t,r=/\+/g,n=/([^&=]+)=?([^&]*)/g,a=function(e){return decodeURIComponent(e.replace(r," "))},o={};for(;t=n.exec(e);)o[a(t[1])]=a(t[2]);return o}(e.substr(t+1))}},function(e,t,r){"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.deepEqual=void 0,t.deepEqual=function e(t,r){if(t===r)return!0;if("object"==n(t)&&null!=t&&"object"==n(r)&&null!=r){if(Object.keys(t).length!=Object.keys(r).length)return!1;for(var a in t){if(!r.hasOwnProperty(a))return!1;if(!e(t[a],r[a]))return!1}return!0}return!1}},function(e,t,r){"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function a(e){return null===e?"null":void 0===e?"undefined":"object"===n(e)?Array.isArray(e)?"array":"object":n(e)}function o(e){return"object"===a(e)?i(e):"array"===a(e)?u(e):e}function u(e){return e.map(o)}function i(e){var t={};for(var r in e)e.hasOwnProperty(r)&&(t[r]=o(e[r]));return t}function c(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r={arrayBehaviour:(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).arrayBehaviour||"replace"},n=t.map((function(e){return e||{}})),o=e||{},l=0;l<n.length;l++)for(var s=n[l],f=Object.keys(s),d=0;d<f.length;d++){var y=f[d],p=s[y],h=a(p),v=a(o[y]);if("object"===h)if("undefined"!==v){var m="object"===v?o[y]:{};o[y]=c({},[m,i(p)],r)}else o[y]=i(p);else if("array"===h)if("array"===v){var b=u(p);o[y]="merge"===r.arrayBehaviour?o[y].concat(b):b}else o[y]=u(p);else o[y]=p}return o}Object.defineProperty(t,"__esModule",{value:!0}),t.withOptions=t.objectAssignDeepInto=t.objectAssignDeep=void 0,t.objectAssignDeep=function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];return c(e,r)},t.objectAssignDeepInto=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return c({},t)};t.withOptions=function(e,t,r){return c(e,t,r)}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.formatString=t.formatDate=void 0,t.formatDate=function(e,t){if("string"==typeof e)return e;var r=e;return t?"".concat(r.getFullYear(),"-").concat(r.getMonth(),"-").concat(r.getDate()," ").concat(r.getHours()+1,":").concat(r.getMinutes()):"".concat(r.getFullYear(),"-").concat(r.getMonth(),"-").concat(r.getDate())},t.formatString=function(e){for(var t=e,r=arguments.length,n=new Array(r>1?r-1:0),a=1;a<r;a++)n[a-1]=arguments[a];for(var o in n)t=t.replace("{"+o+"}",n[o]);return t}},function(e,t,r){"use strict";function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}Object.defineProperty(t,"__esModule",{value:!0}),t.HTML=void 0;var a=r(0),o=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}var t,r,o;return t=e,o=[{key:"addClassName",value:function(e,t){if(null==e)throw a.errors.argumentNull("element");if(!t)throw a.errors.argumentNull("addonClassName");var r;if(r=(r="string"==typeof e?e:e.className)||"",console.assert(null!=t),r.indexOf(t)>=0)return r;var n="".concat(r," ").concat(t);return"string"!=typeof e&&(e.className=n),n}},{key:"removeClassName",value:function(e,t){var r;return(r="string"==typeof e?e:e.className||"").indexOf(t)<0?r:(r=(r=(r=r||"").replace(new RegExp(t,"g"),"")).trim(),"string"!=typeof e&&(e.className=r),r)}}],(r=null)&&n(t.prototype,r),o&&n(t,o),e}();t.HTML=o},function(e,t,r){"use strict";function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}Object.defineProperty(t,"__esModule",{value:!0}),t.ValueStore=void 0;var a=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.items=new Array,this._value=t}var t,r,a;return t=e,(r=[{key:"attach",value:function(e,t){return void 0!==this.value&&e(this.value,t),this.add(e,t)}},{key:"add",value:function(e,t){return this.items.push({func:e,sender:t}),e}},{key:"remove",value:function(e){this.items=this.items.filter((function(t){return t.func!=e}))}},{key:"fire",value:function(e){this.items.forEach((function(t){return t.func(e,t.sender)}))}},{key:"value",get:function(){return void 0===this._value?null:this._value},set:function(e){this._value=e,this.fire(e)}}])&&n(t.prototype,r),a&&n(t,a),e}();t.ValueStore=a}])})); | ||
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}("undefined"==typeof window?global:window,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=3)}([function(e,t,r){"use strict";function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}Object.defineProperty(t,"__esModule",{value:!0}),t.errors=t.Errors=void 0;var o=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}var t,r,o;return t=e,(r=[{key:"argumentNull",value:function(e){var t=new Error("Argument ".concat(e," cannt be null or emtpy."));return t.name="argumentNull",t}},{key:"routeDataFieldNull",value:function(e){var t="The ".concat(e," field of route data cannt be null."),r=new Error(t);return r.name="routeDataFieldNull",r}},{key:"argumentFieldNull",value:function(e,t){var r="The ".concat(e," field of ").concat(t," cannt be null."),n=new Error(r);return n.name="argumentFieldNull",n}},{key:"argumentTypeIncorrect",value:function(e,t){var r="Argument ".concat(e," type error, expected type is ").concat(t,"."),n=new Error(r);return n.name="argumentTypeIncorrect",n}},{key:"pathStartsHttp",value:function(e){var t="Path ".concat(e," start with http or https."),r=new Error(t);return r.name="pathStartsHttp",r}}])&&n(t.prototype,r),o&&n(t,o),e}();t.Errors=o,t.errors=new o},function(e,t,r){"use strict";function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}Object.defineProperty(t,"__esModule",{value:!0}),t.Callback=void 0;var o=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.funcs=new Array}var t,r,o;return t=e,o=[{key:"create",value:function(){return new e}}],(r=[{key:"add",value:function(e){this.funcs.push(e)}},{key:"remove",value:function(e){this.funcs=this.funcs.filter((function(t){return t!=e}))}},{key:"fire",value:function(e){this.funcs.forEach((function(t){return t(e)}))}}])&&n(t.prototype,r),o&&n(t,o),e}();t.Callback=o},function(e,t,r){"use strict";function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}Object.defineProperty(t,"__esModule",{value:!0}),t.ValueStore=void 0;var o=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.items=new Array,this._value=t}var t,r,o;return t=e,(r=[{key:"attach",value:function(e,t){return void 0!==this.value&&e(this.value,t),this.add(e,t)}},{key:"add",value:function(e,t){return this.items.push({func:e,sender:t}),e}},{key:"remove",value:function(e){this.items=this.items.filter((function(t){return t.func!=e}))}},{key:"fire",value:function(e){this.items.forEach((function(t){return t.func(e,t.sender)}))}},{key:"value",get:function(){return this._value},set:function(e){this._value=e,this.fire(e)}}])&&n(t.prototype,r),o&&n(t,o),e}();t.ValueStore=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SingleInvoke=t.ValueStore=t.HTML=t.formatString=t.formatDate=t.objectAssignDeep=t.deepEqual=t.parseUrl=t.DataSourceSelectArguments=t.DataSource=t.Callback=t.errors=t.Errors=t.pathConcat=t.guid=void 0;var n=r(4);Object.defineProperty(t,"guid",{enumerable:!0,get:function(){return n.guid}});var o=r(5);Object.defineProperty(t,"pathConcat",{enumerable:!0,get:function(){return o.pathConcat}});var a=r(0);Object.defineProperty(t,"Errors",{enumerable:!0,get:function(){return a.Errors}}),Object.defineProperty(t,"errors",{enumerable:!0,get:function(){return a.errors}});var u=r(1);Object.defineProperty(t,"Callback",{enumerable:!0,get:function(){return u.Callback}});var i=r(6);Object.defineProperty(t,"DataSource",{enumerable:!0,get:function(){return i.DataSource}}),Object.defineProperty(t,"DataSourceSelectArguments",{enumerable:!0,get:function(){return i.DataSourceSelectArguments}});var c=r(7);Object.defineProperty(t,"parseUrl",{enumerable:!0,get:function(){return c.parseUrl}});var l=r(8);Object.defineProperty(t,"deepEqual",{enumerable:!0,get:function(){return l.deepEqual}});var s=r(9);Object.defineProperty(t,"objectAssignDeep",{enumerable:!0,get:function(){return s.objectAssignDeep}});var f=r(10);Object.defineProperty(t,"formatDate",{enumerable:!0,get:function(){return f.formatDate}}),Object.defineProperty(t,"formatString",{enumerable:!0,get:function(){return f.formatString}});var d=r(11);Object.defineProperty(t,"HTML",{enumerable:!0,get:function(){return d.HTML}});var h=r(2);Object.defineProperty(t,"ValueStore",{enumerable:!0,get:function(){return h.ValueStore}});var y=r(12);Object.defineProperty(t,"SingleInvoke",{enumerable:!0,get:function(){return y.SingleInvoke}})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.guid=void 0,t.guid=function(){function e(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}return e()+e()+"-"+e()+"-"+e()+"-"+e()+"-"+e()+e()+e()}},function(e,t,r){"use strict";function n(e){return function(e){if(Array.isArray(e)){for(var t=0,r=new Array(e.length);t<e.length;t++)r[t]=e[t];return r}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}Object.defineProperty(t,"__esModule",{value:!0}),t.partConcat2=t.pathConcat=void 0;var o=r(0);function a(e,t){if(e.startsWith("http://")||e.startsWith("https://"))throw o.errors.pathStartsHttp(e);if(t.startsWith("http://")||t.startsWith("https://"))throw o.errors.pathStartsHttp(t);e=e.replace(/(\/+\\*|\\+\/*)/g,"/"),t=t.replace(/(\/+\\*|\\+\/*)/g,"/");var r=e.split("/").filter((function(e){return e})),a=t.split("/").filter((function(e){return e}));for("/"==e[0]&&r.unshift("");"."==a[0]||".."==a[0];)".."==a[0]&&r.length>0&&""!=r[r.length-1]&&r.pop(),a.shift();return 1==r.length&&""==r[0]&&0==a.length?"/":[].concat(n(r),n(a)).join("/")}t.pathConcat=function(e){var t="";e.startsWith("http://")?t="http://":e.startsWith("https://")&&(t="https://"),e=e.substring(t.length);for(var r=0;r<(arguments.length<=1?0:arguments.length-1);r++)e=a(e,r+1<1||arguments.length<=r+1?void 0:arguments[r+1]);return e=t+e},t.partConcat2=a},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}Object.defineProperty(t,"__esModule",{value:!0}),t.DataSourceSelectArguments=t.DataSource=void 0;var a=r(0),u=r(1),i=Object.assign(a.errors,{dataSourceCanntInsert:function(){return new Error("DataSource can not insert.")},dataSourceCanntDelete:function(){return new Error("DataSource can not delete.")},dataSourceCanntUpdate:function(){return new Error("DataSource can not update.")},primaryKeyNull:function(e){var t="Primary key named '".concat(e,"' value is null.");return new Error(t)},queryResultTypeError:function(){return new Error("Query result type error.")}}),c=function(){function e(t){n(this,e),this.inserting=new u.Callback,this.inserted=new u.Callback,this.deleting=new u.Callback,this.deleted=new u.Callback,this.updating=new u.Callback,this.updated=new u.Callback,this.selecting=new u.Callback,this.selected=new u.Callback,this.error=new u.Callback,this.args=t,this.primaryKeys=t.primaryKeys||[]}var t,r,a;return t=e,(r=[{key:"executeInsert",value:function(e,t){return this.args.insert(e,t)}},{key:"executeDelete",value:function(e,t){return this.args.delete(e,t)}},{key:"executeUpdate",value:function(e,t){return this.args.update(e,t)}},{key:"executeSelect",value:function(e){return e=e||{},this.args.select(e)}},{key:"insert",value:function(e,t,r){var n=this;if(!this.canInsert)throw i.dataSourceCanntInsert();if(!e)throw i.argumentNull("item");return"number"==typeof t&&(r=t,t=null),this.inserting.fire({sender:this,dataItem:e,index:r}),this.executeInsert(e,t).then((function(t){return Object.assign(e,t),n.inserted.fire({sender:n,dataItem:e,index:r}),t})).catch((function(e){throw n.processError(e,"insert"),e}))}},{key:"delete",value:function(e,t){var r=this;if(!this.canDelete)throw i.dataSourceCanntDelete();if(!e)throw i.argumentNull("item");return this.checkPrimaryKeys(e),this.deleting.fire({sender:this,dataItem:e}),this.executeDelete(e,t).then((function(t){return r.deleted.fire({sender:r,dataItem:e}),t})).catch((function(e){throw r.processError(e,"delete"),e}))}},{key:"update",value:function(e,t){var r=this;if(!this.canUpdate)throw i.dataSourceCanntUpdate();if(!e)throw i.argumentNull("item");return this.checkPrimaryKeys(e),this.updating.fire({sender:this,dataItem:e}),this.executeUpdate(e,t).then((function(t){return Object.assign(e,t),r.updated.fire({sender:r,dataItem:e}),t})).catch((function(e){throw r.processError(e,"update"),e}))}},{key:"isSameItem",value:function(e,t){if(null==e)throw i.argumentNull("theItem");if(null==t)throw i.argumentNull("otherItem");if(0==this.primaryKeys.length)return e==t;this.checkPrimaryKeys(e),this.checkPrimaryKeys(t);var r=!0,n=!1,o=void 0;try{for(var a,u=this.primaryKeys[Symbol.iterator]();!(r=(a=u.next()).done);r=!0){var c=a.value;if(e[c]!=t[c])return!1}}catch(e){n=!0,o=e}finally{try{r||null==u.return||u.return()}finally{if(n)throw o}}return!0}},{key:"checkPrimaryKeys",value:function(e){for(var t in e)if(null==e[t]&&this.primaryKeys.indexOf(t)>=0)throw i.primaryKeyNull(t)}},{key:"select",value:function(e){var t=this;return e=e||{},this.selecting.fire({sender:this,selectArguments:e}),this.executeSelect(e).then((function(r){var n,o;if(Array.isArray(r))n=r,o=r.length;else{if(void 0===r.dataItems||void 0===r.totalRowCount)throw i.queryResultTypeError();n=r.dataItems,o=r.totalRowCount}return t.selected.fire({sender:t,selectResult:{totalRowCount:o,dataItems:n},selectArguments:e}),{totalRowCount:o,dataItems:n}})).catch((function(e){throw t.processError(e,"select"),e}))}},{key:"processError",value:function(e,t){if(e.method=t,this.error.fire({sender:this,error:e}),!e.handled)throw e}},{key:"canDelete",get:function(){return null!=this.args.delete&&this.primaryKeys.length>0}},{key:"canInsert",get:function(){return null!=this.args.insert&&this.primaryKeys.length>0}},{key:"canUpdate",get:function(){return null!=this.args.update&&this.primaryKeys.length>0}}])&&o(t.prototype,r),a&&o(t,a),e}();t.DataSource=c;t.DataSourceSelectArguments=function e(){n(this,e),this.startRowIndex=0,this.maximumRows=2147483647}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseUrl=void 0,t.parseUrl=function(e){var t=e.indexOf("?");return t<0?{}:function(e){var t,r=/\+/g,n=/([^&=]+)=?([^&]*)/g,o=function(e){return decodeURIComponent(e.replace(r," "))},a={};for(;t=n.exec(e);)a[o(t[1])]=o(t[2]);return a}(e.substr(t+1))}},function(e,t,r){"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.deepEqual=void 0,t.deepEqual=function e(t,r){if(t===r)return!0;if("object"==n(t)&&null!=t&&"object"==n(r)&&null!=r){if(Object.keys(t).length!=Object.keys(r).length)return!1;for(var o in t){if(!r.hasOwnProperty(o))return!1;if(!e(t[o],r[o]))return!1}return!0}return!1}},function(e,t,r){"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e){return null===e?"null":void 0===e?"undefined":"object"===n(e)?Array.isArray(e)?"array":"object":n(e)}function a(e){return"object"===o(e)?i(e):"array"===o(e)?u(e):e}function u(e){return e.map(a)}function i(e){var t={};for(var r in e)e.hasOwnProperty(r)&&(t[r]=a(e[r]));return t}function c(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r={arrayBehaviour:(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).arrayBehaviour||"replace"},n=t.map((function(e){return e||{}})),a=e||{},l=0;l<n.length;l++)for(var s=n[l],f=Object.keys(s),d=0;d<f.length;d++){var h=f[d],y=s[h],p=o(y),v=o(a[h]);if("object"===p)if("undefined"!==v){var m="object"===v?a[h]:{};a[h]=c({},[m,i(y)],r)}else a[h]=i(y);else if("array"===p)if("array"===v){var g=u(y);a[h]="merge"===r.arrayBehaviour?a[h].concat(g):g}else a[h]=u(y);else a[h]=y}return a}Object.defineProperty(t,"__esModule",{value:!0}),t.withOptions=t.objectAssignDeepInto=t.objectAssignDeep=void 0,t.objectAssignDeep=function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];return c(e,r)},t.objectAssignDeepInto=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return c({},t)};t.withOptions=function(e,t,r){return c(e,t,r)}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.formatString=t.formatDate=void 0,t.formatDate=function(e,t){if("string"==typeof e)return e;var r=e;return t?"".concat(r.getFullYear(),"-").concat(r.getMonth(),"-").concat(r.getDate()," ").concat(r.getHours()+1,":").concat(r.getMinutes()):"".concat(r.getFullYear(),"-").concat(r.getMonth(),"-").concat(r.getDate())},t.formatString=function(e){for(var t=e,r=arguments.length,n=new Array(r>1?r-1:0),o=1;o<r;o++)n[o-1]=arguments[o];for(var a in n)t=t.replace("{"+a+"}",n[a]);return t}},function(e,t,r){"use strict";function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}Object.defineProperty(t,"__esModule",{value:!0}),t.HTML=void 0;var o=r(0),a=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}var t,r,a;return t=e,a=[{key:"addClassName",value:function(e,t){if(null==e)throw o.errors.argumentNull("element");if(!t)throw o.errors.argumentNull("addonClassName");var r;if(r=(r="string"==typeof e?e:e.className)||"",console.assert(null!=t),r.indexOf(t)>=0)return r;var n="".concat(r," ").concat(t);return"string"!=typeof e&&(e.className=n),n}},{key:"removeClassName",value:function(e,t){var r;return(r="string"==typeof e?e:e.className||"").indexOf(t)<0?r:(r=(r=(r=r||"").replace(new RegExp(t,"g"),"")).trim(),"string"!=typeof e&&(e.className=r),r)}}],(r=null)&&n(t.prototype,r),a&&n(t,a),e}();t.HTML=a},function(e,t,r){"use strict";function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}Object.defineProperty(t,"__esModule",{value:!0}),t.SingleInvoke=void 0;var o=r(2),a=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.result=new o.ValueStore(void 0),this.error=new o.ValueStore(void 0),this.executing=!1,this.func=t}var t,r,a;return t=e,(r=[{key:"clear",value:function(){this.result=new o.ValueStore(void 0),this.error=new o.ValueStore(void 0)}},{key:"execute",value:function(){var e=this;return void 0!==this.result.value?Promise.resolve(this.result.value):this.executing?new Promise((function(t,r){e.result.add((function(e){t(e)})),e.error.add((function(e){r(e)}))})):(this.executing=!0,new Promise((function(t,r){e.func().then((function(r){e.result.value=r||null,e.executing=!1,t(r)})).catch((function(t){e.error=t,e.executing=!1,r(t)}))})))}}])&&n(t.prototype,r),a&&n(t,a),e}();t.SingleInvoke=a}])})); | ||
//# sourceMappingURL=index.es5.min.js.map |
/*! | ||
* ~ | ||
* maishu-toolkit v1.7.3 | ||
* maishu-toolkit v1.8.1 | ||
* https://github.com/ansiboy/toolkit | ||
@@ -671,3 +671,3 @@ * | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ValueStore = exports.HTML = exports.formatString = exports.formatDate = exports.objectAssignDeep = exports.deepEqual = exports.parseUrl = exports.DataSourceSelectArguments = exports.DataSource = exports.Callback = exports.errors = exports.Errors = exports.pathConcat = exports.guid = void 0; | ||
exports.SingleInvoke = exports.ValueStore = exports.HTML = exports.formatString = exports.formatDate = exports.objectAssignDeep = exports.deepEqual = exports.parseUrl = exports.DataSourceSelectArguments = exports.DataSource = exports.Callback = exports.errors = exports.Errors = exports.pathConcat = exports.guid = void 0; | ||
var guid_1 = __webpack_require__(/*! ./guid */ "./out/guid.js"); | ||
@@ -698,2 +698,4 @@ Object.defineProperty(exports, "guid", { enumerable: true, get: function () { return guid_1.guid; } }); | ||
Object.defineProperty(exports, "ValueStore", { enumerable: true, get: function () { return value_store_1.ValueStore; } }); | ||
var single_inoke_1 = __webpack_require__(/*! ./single-inoke */ "./out/single-inoke.js"); | ||
Object.defineProperty(exports, "SingleInvoke", { enumerable: true, get: function () { return single_inoke_1.SingleInvoke; } }); | ||
@@ -737,14 +739,17 @@ | ||
path2 = path2.replace(/(\/+\\*|\\+\/*)/g, '/'); | ||
let arr1 = path1.split('/'); | ||
let arr2 = path2.split('/'); | ||
let arr1 = path1.split('/').filter(o => o); | ||
let arr2 = path2.split('/').filter(o => o); | ||
if (path1[0] == "/") { | ||
arr1.unshift(""); | ||
} | ||
while (arr2[0] == "." || arr2[0] == "..") { | ||
if (arr2[0] == "..") | ||
if (arr2[0] == ".." && arr1.length > 0 && arr1[arr1.length - 1] != "") { | ||
arr1.pop(); | ||
} | ||
arr2.shift(); | ||
} | ||
path1 = arr1.join('/'); | ||
path2 = arr2.join('/'); | ||
if (!path1) | ||
return path2; | ||
let path = path1.endsWith("/") ? path1 + path2 : path1 + '/' + path2; | ||
if (arr1.length == 1 && arr1[0] == "" && arr2.length == 0) { | ||
return "/"; | ||
} | ||
let path = [...arr1, ...arr2].join("/"); | ||
return path; | ||
@@ -757,2 +762,58 @@ } | ||
/***/ "./out/single-inoke.js": | ||
/*!*****************************!*\ | ||
!*** ./out/single-inoke.js ***! | ||
\*****************************/ | ||
/*! no static exports found */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SingleInvoke = void 0; | ||
const value_store_1 = __webpack_require__(/*! ./value-store */ "./out/value-store.js"); | ||
class SingleInvoke { | ||
constructor(func) { | ||
this.result = new value_store_1.ValueStore(undefined); | ||
this.error = new value_store_1.ValueStore(undefined); | ||
this.executing = false; | ||
this.func = func; | ||
} | ||
clear() { | ||
this.result = new value_store_1.ValueStore(undefined); | ||
this.error = new value_store_1.ValueStore(undefined); | ||
} | ||
execute() { | ||
if (this.result.value !== undefined) { | ||
return Promise.resolve(this.result.value); | ||
} | ||
if (this.executing) { | ||
return new Promise((resolve, reject) => { | ||
this.result.add(value => { | ||
resolve(value); | ||
}); | ||
this.error.add(err => { | ||
reject(err); | ||
}); | ||
}); | ||
} | ||
this.executing = true; | ||
return new Promise((resolve, reject) => { | ||
this.func().then(r => { | ||
this.result.value = r || null; | ||
this.executing = false; | ||
resolve(r); | ||
}).catch(err => { | ||
this.error = err; | ||
this.executing = false; | ||
reject(err); | ||
}); | ||
}); | ||
} | ||
} | ||
exports.SingleInvoke = SingleInvoke; | ||
/***/ }), | ||
/***/ "./out/url.js": | ||
@@ -827,4 +888,2 @@ /*!********************!*\ | ||
get value() { | ||
if (this._value === undefined) | ||
return null; | ||
return this._value; | ||
@@ -831,0 +890,0 @@ } |
/*! | ||
* ~ | ||
* maishu-toolkit v1.7.3 | ||
* maishu-toolkit v1.8.1 | ||
* https://github.com/ansiboy/toolkit | ||
@@ -10,3 +10,3 @@ * | ||
*/ | ||
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}("undefined"==typeof window?global:window,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var a=t[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,r),a.l=!0,a.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)r.d(n,a,function(t){return e[t]}.bind(null,a));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=2)}([function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.errors=t.Errors=void 0;class n{argumentNull(e){let t=new Error(`Argument ${e} cannt be null or emtpy.`);return t.name="argumentNull",t}routeDataFieldNull(e){let t=new Error(`The ${e} field of route data cannt be null.`);return t.name="routeDataFieldNull",t}argumentFieldNull(e,t){let r=new Error(`The ${e} field of ${t} cannt be null.`);return r.name="argumentFieldNull",r}argumentTypeIncorrect(e,t){let r=new Error(`Argument ${e} type error, expected type is ${t}.`);return r.name="argumentTypeIncorrect",r}pathStartsHttp(e){let t=new Error(`Path ${e} start with http or https.`);return t.name="pathStartsHttp",t}}t.Errors=n,t.errors=new n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Callback=void 0;class n{constructor(){this.funcs=new Array}add(e){this.funcs.push(e)}remove(e){this.funcs=this.funcs.filter(t=>t!=e)}fire(e){this.funcs.forEach(t=>t(e))}static create(){return new n}}t.Callback=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ValueStore=t.HTML=t.formatString=t.formatDate=t.objectAssignDeep=t.deepEqual=t.parseUrl=t.DataSourceSelectArguments=t.DataSource=t.Callback=t.errors=t.Errors=t.pathConcat=t.guid=void 0;var n=r(3);Object.defineProperty(t,"guid",{enumerable:!0,get:function(){return n.guid}});var a=r(4);Object.defineProperty(t,"pathConcat",{enumerable:!0,get:function(){return a.pathConcat}});var i=r(0);Object.defineProperty(t,"Errors",{enumerable:!0,get:function(){return i.Errors}}),Object.defineProperty(t,"errors",{enumerable:!0,get:function(){return i.errors}});var o=r(1);Object.defineProperty(t,"Callback",{enumerable:!0,get:function(){return o.Callback}});var s=r(5);Object.defineProperty(t,"DataSource",{enumerable:!0,get:function(){return s.DataSource}}),Object.defineProperty(t,"DataSourceSelectArguments",{enumerable:!0,get:function(){return s.DataSourceSelectArguments}});var u=r(6);Object.defineProperty(t,"parseUrl",{enumerable:!0,get:function(){return u.parseUrl}});var l=r(7);Object.defineProperty(t,"deepEqual",{enumerable:!0,get:function(){return l.deepEqual}});var c=r(8);Object.defineProperty(t,"objectAssignDeep",{enumerable:!0,get:function(){return c.objectAssignDeep}});var f=r(9);Object.defineProperty(t,"formatDate",{enumerable:!0,get:function(){return f.formatDate}}),Object.defineProperty(t,"formatString",{enumerable:!0,get:function(){return f.formatString}});var d=r(10);Object.defineProperty(t,"HTML",{enumerable:!0,get:function(){return d.HTML}});var h=r(11);Object.defineProperty(t,"ValueStore",{enumerable:!0,get:function(){return h.ValueStore}})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.guid=void 0,t.guid=function(){function e(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}return e()+e()+"-"+e()+"-"+e()+"-"+e()+"-"+e()+e()+e()}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.partConcat2=t.pathConcat=void 0;const n=r(0);function a(e,t){if(e.startsWith("http://")||e.startsWith("https://"))throw n.errors.pathStartsHttp(e);if(t.startsWith("http://")||t.startsWith("https://"))throw n.errors.pathStartsHttp(t);e=e.replace(/(\/+\\*|\\+\/*)/g,"/"),t=t.replace(/(\/+\\*|\\+\/*)/g,"/");let r=e.split("/"),a=t.split("/");for(;"."==a[0]||".."==a[0];)".."==a[0]&&r.pop(),a.shift();return e=r.join("/"),t=a.join("/"),e?e.endsWith("/")?e+t:e+"/"+t:t}t.pathConcat=function(e,...t){let r="";e.startsWith("http://")?r="http://":e.startsWith("https://")&&(r="https://"),e=e.substring(r.length);for(let r=0;r<t.length;r++)e=a(e,t[r]);return e=r+e},t.partConcat2=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DataSourceSelectArguments=t.DataSource=void 0;const n=r(0),a=r(1);let i=Object.assign(n.errors,{dataSourceCanntInsert:()=>new Error("DataSource can not insert."),dataSourceCanntDelete:()=>new Error("DataSource can not delete."),dataSourceCanntUpdate:()=>new Error("DataSource can not update."),primaryKeyNull:e=>new Error(`Primary key named '${e}' value is null.`),queryResultTypeError:()=>new Error("Query result type error.")});t.DataSource=class{constructor(e){this.inserting=new a.Callback,this.inserted=new a.Callback,this.deleting=new a.Callback,this.deleted=new a.Callback,this.updating=new a.Callback,this.updated=new a.Callback,this.selecting=new a.Callback,this.selected=new a.Callback,this.error=new a.Callback,this.args=e,this.primaryKeys=e.primaryKeys||[]}get canDelete(){return null!=this.args.delete&&this.primaryKeys.length>0}get canInsert(){return null!=this.args.insert&&this.primaryKeys.length>0}get canUpdate(){return null!=this.args.update&&this.primaryKeys.length>0}executeInsert(e,t){return this.args.insert(e,t)}executeDelete(e,t){return this.args.delete(e,t)}executeUpdate(e,t){return this.args.update(e,t)}executeSelect(e){return e=e||{},this.args.select(e)}insert(e,t,r){if(!this.canInsert)throw i.dataSourceCanntInsert();if(!e)throw i.argumentNull("item");return"number"==typeof t&&(r=t,t=null),this.inserting.fire({sender:this,dataItem:e,index:r}),this.executeInsert(e,t).then(t=>(Object.assign(e,t),this.inserted.fire({sender:this,dataItem:e,index:r}),t)).catch(e=>{throw this.processError(e,"insert"),e})}delete(e,t){if(!this.canDelete)throw i.dataSourceCanntDelete();if(!e)throw i.argumentNull("item");return this.checkPrimaryKeys(e),this.deleting.fire({sender:this,dataItem:e}),this.executeDelete(e,t).then(t=>(this.deleted.fire({sender:this,dataItem:e}),t)).catch(e=>{throw this.processError(e,"delete"),e})}update(e,t){if(!this.canUpdate)throw i.dataSourceCanntUpdate();if(!e)throw i.argumentNull("item");return this.checkPrimaryKeys(e),this.updating.fire({sender:this,dataItem:e}),this.executeUpdate(e,t).then(t=>(Object.assign(e,t),this.updated.fire({sender:this,dataItem:e}),t)).catch(e=>{throw this.processError(e,"update"),e})}isSameItem(e,t){if(null==e)throw i.argumentNull("theItem");if(null==t)throw i.argumentNull("otherItem");if(0==this.primaryKeys.length)return e==t;this.checkPrimaryKeys(e),this.checkPrimaryKeys(t);for(let r of this.primaryKeys)if(e[r]!=t[r])return!1;return!0}checkPrimaryKeys(e){for(let t in e)if(null==e[t]&&this.primaryKeys.indexOf(t)>=0)throw i.primaryKeyNull(t)}select(e){return e=e||{},this.selecting.fire({sender:this,selectArguments:e}),this.executeSelect(e).then(t=>{let r,n;if(Array.isArray(t))r=t,n=t.length;else{if(void 0===t.dataItems||void 0===t.totalRowCount)throw i.queryResultTypeError();r=t.dataItems,n=t.totalRowCount}return this.selected.fire({sender:this,selectResult:{totalRowCount:n,dataItems:r},selectArguments:e}),{totalRowCount:n,dataItems:r}}).catch(e=>{throw this.processError(e,"select"),e})}processError(e,t){if(e.method=t,this.error.fire({sender:this,error:e}),!e.handled)throw e}};t.DataSourceSelectArguments=class{constructor(){this.startRowIndex=0,this.maximumRows=2147483647}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseUrl=void 0,t.parseUrl=function(e){let t=e.indexOf("?");return t<0?{}:function(e){let t,r=/\+/g,n=/([^&=]+)=?([^&]*)/g,a=function(e){return decodeURIComponent(e.replace(r," "))},i={};for(;t=n.exec(e);)i[a(t[1])]=a(t[2]);return i}(e.substr(t+1))}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.deepEqual=void 0,t.deepEqual=function e(t,r){if(t===r)return!0;if("object"==typeof t&&null!=t&&"object"==typeof r&&null!=r){if(Object.keys(t).length!=Object.keys(r).length)return!1;for(var n in t){if(!r.hasOwnProperty(n))return!1;if(!e(t[n],r[n]))return!1}return!0}return!1}},function(e,t,r){"use strict";function n(e){return null===e?"null":void 0===e?"undefined":"object"==typeof e?Array.isArray(e)?"array":"object":typeof e}function a(e){return"object"===n(e)?o(e):"array"===n(e)?i(e):e}function i(e){return e.map(a)}function o(e){const t={};for(const r in e)e.hasOwnProperty(r)&&(t[r]=a(e[r]));return t}function s(e,t=[],r={}){const a={arrayBehaviour:r.arrayBehaviour||"replace"},u=t.map(e=>e||{}),l=e||{};for(let e=0;e<u.length;e++){const t=u[e],r=Object.keys(t);for(let e=0;e<r.length;e++){const u=r[e],c=t[u],f=n(c),d=n(l[u]);if("object"===f)if("undefined"!==d){const e="object"===d?l[u]:{};l[u]=s({},[e,o(c)],a)}else l[u]=o(c);else if("array"===f)if("array"===d){const e=i(c);l[u]="merge"===a.arrayBehaviour?l[u].concat(e):e}else l[u]=i(c);else l[u]=c}}return l}Object.defineProperty(t,"__esModule",{value:!0}),t.withOptions=t.objectAssignDeepInto=t.objectAssignDeep=void 0,t.objectAssignDeep=function(e,...t){return s(e,t)},t.objectAssignDeepInto=function(...e){return s({},e)};t.withOptions=function(e,t,r){return s(e,t,r)}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.formatString=t.formatDate=void 0,t.formatDate=function(e,t){if("string"==typeof e)return e;let r=e;return t?`${r.getFullYear()}-${r.getMonth()}-${r.getDate()} ${r.getHours()+1}:${r.getMinutes()}`:`${r.getFullYear()}-${r.getMonth()}-${r.getDate()}`},t.formatString=function(e,...t){let r=e;for(let e in t)r=r.replace("{"+e+"}",t[e]);return r}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HTML=void 0;const n=r(0);t.HTML=class{static addClassName(e,t){if(null==e)throw n.errors.argumentNull("element");if(!t)throw n.errors.argumentNull("addonClassName");let r;if(r="string"==typeof e?e:e.className,r=r||"",console.assert(null!=t),r.indexOf(t)>=0)return r;let a=`${r} ${t}`;return"string"!=typeof e&&(e.className=a),a}static removeClassName(e,t){let r;return r="string"==typeof e?e:e.className||"",r.indexOf(t)<0?r:(r=r||"",r=r.replace(new RegExp(t,"g"),""),r=r.trim(),"string"!=typeof e&&(e.className=r),r)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ValueStore=void 0;t.ValueStore=class{constructor(e){this.items=new Array,this._value=e}attach(e,t){return void 0!==this.value&&e(this.value,t),this.add(e,t)}add(e,t){return this.items.push({func:e,sender:t}),e}remove(e){this.items=this.items.filter(t=>t.func!=e)}fire(e){this.items.forEach(t=>t.func(e,t.sender))}get value(){return void 0===this._value?null:this._value}set value(e){this._value=e,this.fire(e)}}}])})); | ||
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}("undefined"==typeof window?global:window,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=3)}([function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.errors=t.Errors=void 0;class n{argumentNull(e){let t=new Error(`Argument ${e} cannt be null or emtpy.`);return t.name="argumentNull",t}routeDataFieldNull(e){let t=new Error(`The ${e} field of route data cannt be null.`);return t.name="routeDataFieldNull",t}argumentFieldNull(e,t){let r=new Error(`The ${e} field of ${t} cannt be null.`);return r.name="argumentFieldNull",r}argumentTypeIncorrect(e,t){let r=new Error(`Argument ${e} type error, expected type is ${t}.`);return r.name="argumentTypeIncorrect",r}pathStartsHttp(e){let t=new Error(`Path ${e} start with http or https.`);return t.name="pathStartsHttp",t}}t.Errors=n,t.errors=new n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Callback=void 0;class n{constructor(){this.funcs=new Array}add(e){this.funcs.push(e)}remove(e){this.funcs=this.funcs.filter(t=>t!=e)}fire(e){this.funcs.forEach(t=>t(e))}static create(){return new n}}t.Callback=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ValueStore=void 0;t.ValueStore=class{constructor(e){this.items=new Array,this._value=e}attach(e,t){return void 0!==this.value&&e(this.value,t),this.add(e,t)}add(e,t){return this.items.push({func:e,sender:t}),e}remove(e){this.items=this.items.filter(t=>t.func!=e)}fire(e){this.items.forEach(t=>t.func(e,t.sender))}get value(){return this._value}set value(e){this._value=e,this.fire(e)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SingleInvoke=t.ValueStore=t.HTML=t.formatString=t.formatDate=t.objectAssignDeep=t.deepEqual=t.parseUrl=t.DataSourceSelectArguments=t.DataSource=t.Callback=t.errors=t.Errors=t.pathConcat=t.guid=void 0;var n=r(4);Object.defineProperty(t,"guid",{enumerable:!0,get:function(){return n.guid}});var i=r(5);Object.defineProperty(t,"pathConcat",{enumerable:!0,get:function(){return i.pathConcat}});var a=r(0);Object.defineProperty(t,"Errors",{enumerable:!0,get:function(){return a.Errors}}),Object.defineProperty(t,"errors",{enumerable:!0,get:function(){return a.errors}});var s=r(1);Object.defineProperty(t,"Callback",{enumerable:!0,get:function(){return s.Callback}});var o=r(6);Object.defineProperty(t,"DataSource",{enumerable:!0,get:function(){return o.DataSource}}),Object.defineProperty(t,"DataSourceSelectArguments",{enumerable:!0,get:function(){return o.DataSourceSelectArguments}});var u=r(7);Object.defineProperty(t,"parseUrl",{enumerable:!0,get:function(){return u.parseUrl}});var l=r(8);Object.defineProperty(t,"deepEqual",{enumerable:!0,get:function(){return l.deepEqual}});var c=r(9);Object.defineProperty(t,"objectAssignDeep",{enumerable:!0,get:function(){return c.objectAssignDeep}});var f=r(10);Object.defineProperty(t,"formatDate",{enumerable:!0,get:function(){return f.formatDate}}),Object.defineProperty(t,"formatString",{enumerable:!0,get:function(){return f.formatString}});var d=r(11);Object.defineProperty(t,"HTML",{enumerable:!0,get:function(){return d.HTML}});var h=r(2);Object.defineProperty(t,"ValueStore",{enumerable:!0,get:function(){return h.ValueStore}});var p=r(12);Object.defineProperty(t,"SingleInvoke",{enumerable:!0,get:function(){return p.SingleInvoke}})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.guid=void 0,t.guid=function(){function e(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}return e()+e()+"-"+e()+"-"+e()+"-"+e()+"-"+e()+e()+e()}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.partConcat2=t.pathConcat=void 0;const n=r(0);function i(e,t){if(e.startsWith("http://")||e.startsWith("https://"))throw n.errors.pathStartsHttp(e);if(t.startsWith("http://")||t.startsWith("https://"))throw n.errors.pathStartsHttp(t);e=e.replace(/(\/+\\*|\\+\/*)/g,"/"),t=t.replace(/(\/+\\*|\\+\/*)/g,"/");let r=e.split("/").filter(e=>e),i=t.split("/").filter(e=>e);for("/"==e[0]&&r.unshift("");"."==i[0]||".."==i[0];)".."==i[0]&&r.length>0&&""!=r[r.length-1]&&r.pop(),i.shift();return 1==r.length&&""==r[0]&&0==i.length?"/":[...r,...i].join("/")}t.pathConcat=function(e,...t){let r="";e.startsWith("http://")?r="http://":e.startsWith("https://")&&(r="https://"),e=e.substring(r.length);for(let r=0;r<t.length;r++)e=i(e,t[r]);return e=r+e},t.partConcat2=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DataSourceSelectArguments=t.DataSource=void 0;const n=r(0),i=r(1);let a=Object.assign(n.errors,{dataSourceCanntInsert:()=>new Error("DataSource can not insert."),dataSourceCanntDelete:()=>new Error("DataSource can not delete."),dataSourceCanntUpdate:()=>new Error("DataSource can not update."),primaryKeyNull:e=>new Error(`Primary key named '${e}' value is null.`),queryResultTypeError:()=>new Error("Query result type error.")});t.DataSource=class{constructor(e){this.inserting=new i.Callback,this.inserted=new i.Callback,this.deleting=new i.Callback,this.deleted=new i.Callback,this.updating=new i.Callback,this.updated=new i.Callback,this.selecting=new i.Callback,this.selected=new i.Callback,this.error=new i.Callback,this.args=e,this.primaryKeys=e.primaryKeys||[]}get canDelete(){return null!=this.args.delete&&this.primaryKeys.length>0}get canInsert(){return null!=this.args.insert&&this.primaryKeys.length>0}get canUpdate(){return null!=this.args.update&&this.primaryKeys.length>0}executeInsert(e,t){return this.args.insert(e,t)}executeDelete(e,t){return this.args.delete(e,t)}executeUpdate(e,t){return this.args.update(e,t)}executeSelect(e){return e=e||{},this.args.select(e)}insert(e,t,r){if(!this.canInsert)throw a.dataSourceCanntInsert();if(!e)throw a.argumentNull("item");return"number"==typeof t&&(r=t,t=null),this.inserting.fire({sender:this,dataItem:e,index:r}),this.executeInsert(e,t).then(t=>(Object.assign(e,t),this.inserted.fire({sender:this,dataItem:e,index:r}),t)).catch(e=>{throw this.processError(e,"insert"),e})}delete(e,t){if(!this.canDelete)throw a.dataSourceCanntDelete();if(!e)throw a.argumentNull("item");return this.checkPrimaryKeys(e),this.deleting.fire({sender:this,dataItem:e}),this.executeDelete(e,t).then(t=>(this.deleted.fire({sender:this,dataItem:e}),t)).catch(e=>{throw this.processError(e,"delete"),e})}update(e,t){if(!this.canUpdate)throw a.dataSourceCanntUpdate();if(!e)throw a.argumentNull("item");return this.checkPrimaryKeys(e),this.updating.fire({sender:this,dataItem:e}),this.executeUpdate(e,t).then(t=>(Object.assign(e,t),this.updated.fire({sender:this,dataItem:e}),t)).catch(e=>{throw this.processError(e,"update"),e})}isSameItem(e,t){if(null==e)throw a.argumentNull("theItem");if(null==t)throw a.argumentNull("otherItem");if(0==this.primaryKeys.length)return e==t;this.checkPrimaryKeys(e),this.checkPrimaryKeys(t);for(let r of this.primaryKeys)if(e[r]!=t[r])return!1;return!0}checkPrimaryKeys(e){for(let t in e)if(null==e[t]&&this.primaryKeys.indexOf(t)>=0)throw a.primaryKeyNull(t)}select(e){return e=e||{},this.selecting.fire({sender:this,selectArguments:e}),this.executeSelect(e).then(t=>{let r,n;if(Array.isArray(t))r=t,n=t.length;else{if(void 0===t.dataItems||void 0===t.totalRowCount)throw a.queryResultTypeError();r=t.dataItems,n=t.totalRowCount}return this.selected.fire({sender:this,selectResult:{totalRowCount:n,dataItems:r},selectArguments:e}),{totalRowCount:n,dataItems:r}}).catch(e=>{throw this.processError(e,"select"),e})}processError(e,t){if(e.method=t,this.error.fire({sender:this,error:e}),!e.handled)throw e}};t.DataSourceSelectArguments=class{constructor(){this.startRowIndex=0,this.maximumRows=2147483647}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseUrl=void 0,t.parseUrl=function(e){let t=e.indexOf("?");return t<0?{}:function(e){let t,r=/\+/g,n=/([^&=]+)=?([^&]*)/g,i=function(e){return decodeURIComponent(e.replace(r," "))},a={};for(;t=n.exec(e);)a[i(t[1])]=i(t[2]);return a}(e.substr(t+1))}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.deepEqual=void 0,t.deepEqual=function e(t,r){if(t===r)return!0;if("object"==typeof t&&null!=t&&"object"==typeof r&&null!=r){if(Object.keys(t).length!=Object.keys(r).length)return!1;for(var n in t){if(!r.hasOwnProperty(n))return!1;if(!e(t[n],r[n]))return!1}return!0}return!1}},function(e,t,r){"use strict";function n(e){return null===e?"null":void 0===e?"undefined":"object"==typeof e?Array.isArray(e)?"array":"object":typeof e}function i(e){return"object"===n(e)?s(e):"array"===n(e)?a(e):e}function a(e){return e.map(i)}function s(e){const t={};for(const r in e)e.hasOwnProperty(r)&&(t[r]=i(e[r]));return t}function o(e,t=[],r={}){const i={arrayBehaviour:r.arrayBehaviour||"replace"},u=t.map(e=>e||{}),l=e||{};for(let e=0;e<u.length;e++){const t=u[e],r=Object.keys(t);for(let e=0;e<r.length;e++){const u=r[e],c=t[u],f=n(c),d=n(l[u]);if("object"===f)if("undefined"!==d){const e="object"===d?l[u]:{};l[u]=o({},[e,s(c)],i)}else l[u]=s(c);else if("array"===f)if("array"===d){const e=a(c);l[u]="merge"===i.arrayBehaviour?l[u].concat(e):e}else l[u]=a(c);else l[u]=c}}return l}Object.defineProperty(t,"__esModule",{value:!0}),t.withOptions=t.objectAssignDeepInto=t.objectAssignDeep=void 0,t.objectAssignDeep=function(e,...t){return o(e,t)},t.objectAssignDeepInto=function(...e){return o({},e)};t.withOptions=function(e,t,r){return o(e,t,r)}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.formatString=t.formatDate=void 0,t.formatDate=function(e,t){if("string"==typeof e)return e;let r=e;return t?`${r.getFullYear()}-${r.getMonth()}-${r.getDate()} ${r.getHours()+1}:${r.getMinutes()}`:`${r.getFullYear()}-${r.getMonth()}-${r.getDate()}`},t.formatString=function(e,...t){let r=e;for(let e in t)r=r.replace("{"+e+"}",t[e]);return r}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HTML=void 0;const n=r(0);t.HTML=class{static addClassName(e,t){if(null==e)throw n.errors.argumentNull("element");if(!t)throw n.errors.argumentNull("addonClassName");let r;if(r="string"==typeof e?e:e.className,r=r||"",console.assert(null!=t),r.indexOf(t)>=0)return r;let i=`${r} ${t}`;return"string"!=typeof e&&(e.className=i),i}static removeClassName(e,t){let r;return r="string"==typeof e?e:e.className||"",r.indexOf(t)<0?r:(r=r||"",r=r.replace(new RegExp(t,"g"),""),r=r.trim(),"string"!=typeof e&&(e.className=r),r)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SingleInvoke=void 0;const n=r(2);t.SingleInvoke=class{constructor(e){this.result=new n.ValueStore(void 0),this.error=new n.ValueStore(void 0),this.executing=!1,this.func=e}clear(){this.result=new n.ValueStore(void 0),this.error=new n.ValueStore(void 0)}execute(){return void 0!==this.result.value?Promise.resolve(this.result.value):this.executing?new Promise((e,t)=>{this.result.add(t=>{e(t)}),this.error.add(e=>{t(e)})}):(this.executing=!0,new Promise((e,t)=>{this.func().then(t=>{this.result.value=t||null,this.executing=!1,e(t)}).catch(e=>{this.error=e,this.executing=!1,t(e)})}))}}}])})); | ||
//# sourceMappingURL=index.min.js.map |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.ValueStore = exports.HTML = exports.formatString = exports.formatDate = exports.objectAssignDeep = exports.deepEqual = exports.parseUrl = exports.DataSourceSelectArguments = exports.DataSource = exports.Callback = exports.errors = exports.Errors = exports.pathConcat = exports.guid = void 0; | ||
exports.SingleInvoke = exports.ValueStore = exports.HTML = exports.formatString = exports.formatDate = exports.objectAssignDeep = exports.deepEqual = exports.parseUrl = exports.DataSourceSelectArguments = exports.DataSource = exports.Callback = exports.errors = exports.Errors = exports.pathConcat = exports.guid = void 0; | ||
@@ -125,2 +125,11 @@ var guid_1 = require("./guid"); | ||
}); | ||
var single_inoke_1 = require("./single-inoke"); | ||
Object.defineProperty(exports, "SingleInvoke", { | ||
enumerable: true, | ||
get: function get() { | ||
return single_inoke_1.SingleInvoke; | ||
} | ||
}); | ||
//# sourceMappingURL=index.js.map |
"use strict"; | ||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } | ||
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } | ||
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } | ||
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -32,14 +40,26 @@ value: true | ||
path2 = path2.replace(/(\/+\\*|\\+\/*)/g, '/'); | ||
var arr1 = path1.split('/'); | ||
var arr2 = path2.split('/'); | ||
var arr1 = path1.split('/').filter(function (o) { | ||
return o; | ||
}); | ||
var arr2 = path2.split('/').filter(function (o) { | ||
return o; | ||
}); | ||
if (path1[0] == "/") { | ||
arr1.unshift(""); | ||
} | ||
while (arr2[0] == "." || arr2[0] == "..") { | ||
if (arr2[0] == "..") arr1.pop(); | ||
if (arr2[0] == ".." && arr1.length > 0 && arr1[arr1.length - 1] != "") { | ||
arr1.pop(); | ||
} | ||
arr2.shift(); | ||
} | ||
path1 = arr1.join('/'); | ||
path2 = arr2.join('/'); | ||
if (!path1) return path2; | ||
var path = path1.endsWith("/") ? path1 + path2 : path1 + '/' + path2; | ||
if (arr1.length == 1 && arr1[0] == "" && arr2.length == 0) { | ||
return "/"; | ||
} | ||
var path = [].concat(_toConsumableArray(arr1), _toConsumableArray(arr2)).join("/"); | ||
return path; | ||
@@ -46,0 +66,0 @@ } |
@@ -62,3 +62,2 @@ "use strict"; | ||
get: function get() { | ||
if (this._value === undefined) return null; | ||
return this._value; | ||
@@ -65,0 +64,0 @@ }, |
@@ -8,3 +8,3 @@ export declare class SingleInvoke<T> { | ||
clear(): void; | ||
execute(): Promise<unknown>; | ||
execute(): Promise<T>; | ||
} |
@@ -20,3 +20,2 @@ "use strict"; | ||
} | ||
this.executing = true; | ||
if (this.executing) { | ||
@@ -32,8 +31,13 @@ return new Promise((resolve, reject) => { | ||
} | ||
this.func().then(r => { | ||
this.result = r || null; | ||
this.executing = false; | ||
}).catch(err => { | ||
this.error = err; | ||
this.executing = false; | ||
this.executing = true; | ||
return new Promise((resolve, reject) => { | ||
this.func().then(r => { | ||
this.result.value = r || null; | ||
this.executing = false; | ||
resolve(r); | ||
}).catch(err => { | ||
this.error = err; | ||
this.executing = false; | ||
reject(err); | ||
}); | ||
}); | ||
@@ -40,0 +44,0 @@ } |
@@ -29,4 +29,2 @@ "use strict"; | ||
get value() { | ||
if (this._value === undefined) | ||
return null; | ||
return this._value; | ||
@@ -33,0 +31,0 @@ } |
{ | ||
"name": "maishu-toolkit", | ||
"version": "1.8.0", | ||
"version": "1.8.2", | ||
"main": "./dist/index.js", | ||
@@ -5,0 +5,0 @@ "types": "./out/index.d.ts", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
403648
69
3831