wechat-mini-program-extend
Advanced tools
Comparing version 1.1.1 to 1.1.2
@@ -1,1 +0,1 @@ | ||
"use strict";function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _OptionInstaller2=_interopRequireDefault(require("./OptionInstaller")),_Blend=require("../libs/Blend"),_Stream=require("../libs/Stream"),_Invocation=require("../libs/Invocation"),_Optional=require("../libs/Optional"),_common=require("../utils/common"),_lifecycle=_interopRequireDefault(require("../utils/lifecycle")),_options=_interopRequireDefault(require("../utils/options")),_excluded=["extends","mixins"];function _interopRequireDefault(t){return t&&t.__esModule?t:{default:t}}function _slicedToArray(t,e){return _arrayWithHoles(t)||_iterableToArrayLimit(t,e)||_unsupportedIterableToArray(t,e)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArrayLimit(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var o,n,i=[],a=!0,l=!1;try{for(r=r.call(t);!(a=(o=r.next()).done)&&(i.push(o.value),!e||i.length!==e);a=!0);}catch(t){l=!0,n=t}finally{try{a||null==r.return||r.return()}finally{if(l)throw n}}return i}}function _arrayWithHoles(t){if(Array.isArray(t))return t}function _objectWithoutProperties(t,e){if(null==t)return{};var r,o=_objectWithoutPropertiesLoose(t,e);if(Object.getOwnPropertySymbols)for(var n=Object.getOwnPropertySymbols(t),i=0;i<n.length;i++)r=n[i],0<=e.indexOf(r)||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r]);return o}function _objectWithoutPropertiesLoose(t,e){if(null==t)return{};for(var r,o={},n=Object.keys(t),i=0;i<n.length;i++)r=n[i],0<=e.indexOf(r)||(o[r]=t[r]);return o}function _toConsumableArray(t){return _arrayWithoutHoles(t)||_iterableToArray(t)||_unsupportedIterableToArray(t)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArray(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}function _arrayWithoutHoles(t){if(Array.isArray(t))return _arrayLikeToArray(t)}function _createForOfIteratorHelper(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=_unsupportedIterableToArray(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var o=0,e=function(){};return{s:e,n:function(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function(t){throw t},f:e}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var n,i=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return i=t.done,t},e:function(t){a=!0,n=t},f:function(){try{i||null==r.return||r.return()}finally{if(a)throw n}}}}function _unsupportedIterableToArray(t,e){if(t){if("string"==typeof t)return _arrayLikeToArray(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(r="Object"===r&&t.constructor?t.constructor.name:r)||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(t,e):void 0}}function _arrayLikeToArray(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,o=new Array(e);r<e;r++)o[r]=t[r];return o}function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function _defineProperties(t,e){for(var r=0;r<e.length;r++){var o=e[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}function _createClass(t,e,r){return e&&_defineProperties(t.prototype,e),r&&_defineProperties(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_setPrototypeOf(t,e)}function _setPrototypeOf(t,e){return(_setPrototypeOf=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function _createSuper(r){var o=_isNativeReflectConstruct();return function(){var t,e=_getPrototypeOf(r);return _possibleConstructorReturn(this,o?(t=_getPrototypeOf(this).constructor,Reflect.construct(e,arguments,t)):e.apply(this,arguments))}}function _possibleConstructorReturn(t,e){if(e&&("object"===_typeof(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(t)}function _assertThisInitialized(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}function _getPrototypeOf(t){return(_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var MixinInstaller=function(){_inherits(e,_OptionInstaller2["default"]);var t=_createSuper(e);function e(){return _classCallCheck(this,e),t.apply(this,arguments)}return _createClass(e,[{key:"collectOptions",value:function(){var e=this,r=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[],t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},o=2<arguments.length&&void 0!==arguments[2]?arguments[2]:new Map;Array.isArray(t.mixins)&&t.mixins.forEach(function(t){return e.collectOptions(r,t,o)});var n,i=_createForOfIteratorHelper(r);try{for(i.s();!(n=i.n()).done;){var a=n.value;Reflect.has(t,a)&&(o.has(a)||o.set(a,[]),o.get(a).push(t[a]))}}catch(t){i.e(t)}finally{i.f()}return o}},{key:"overrideOptions",value:function(t,e){return _Stream.Stream.of((Array.isArray(t)?t:_toConsumableArray(t)).filter(function(t){return e.has(t)&&0<e.get(t).length})).map(function(t){return[t,Object.assign.apply(void 0,[{}].concat(e.get(t)))]}).collect(_Stream.Collectors.toMap())}},{key:"overrideMembers",value:function(t,e){return _Stream.Stream.of((Array.isArray(t)?t:_toConsumableArray(t)).filter(function(t){return e.has(t)&&0<e.get(t).length})).map(function(t){return[t,Object.assign.apply(void 0,[{}].concat(e.get(t)))]}).collect(_Stream.Collectors.toMap())}},{key:"combineOptions",value:function(t,e){return _Stream.Stream.of((Array.isArray(t)?t:_toConsumableArray(t)).filter(function(t){return e.has(t)&&0<e.get(t).length})).map(function(t){return[t,(0,_Blend.Blend)({},e.get(t))]}).collect(_Stream.Collectors.toMap())}},{key:"seriesOptions",value:function(t,e){return _Stream.Stream.of((Array.isArray(t)?t:_toConsumableArray(t)).filter(function(t){return e.has(t)&&0<e.get(t).length})).map(function(t){return[t,(0,_Invocation.Invocation)(e.get(t))]}).collect(_Stream.Collectors.toMap())}},{key:"seriesMembers",value:function(t,o){var n=this;return _Stream.Stream.of((Array.isArray(t)?t:_toConsumableArray(t)).filter(function(t){return o.has(t)&&0<o.get(t).length})).map(function(t){var e=_Stream.Stream.of(_Stream.Stream.of(o.get(t)).map(function(t){return Object.keys(t)}).flat()).distinct().collect(_Stream.Collectors.toList()),r=o.get(t);return[t,n.seriesOptions(e,_Stream.Stream.of(e).map(function(e){return[e,r.map(function(t){return t[e]})]}).collect(_Stream.Collectors.toMap(!0)))]}).collect(_Stream.Collectors.toMap())}},{key:"concatOptions",value:function(t,e){return _Stream.Stream.of((Array.isArray(t)?t:_toConsumableArray(t)).filter(function(t){return e.has(t)&&0<e.get(t).length})).map(function(t){return[t,_toConsumableArray(new Set(_Stream.Stream.of(e.get(t)).flat()))]}).collect(_Stream.Collectors.toMap())}},{key:"reduceConfiguration",value:function(t){var e={};if(t.extends){var r=t.extends,o=t.mixins,n=_objectWithoutProperties(t,_excluded);return this.reduceConfiguration(Object.assign({mixins:[r].concat(o||[])},n))}Object.assign(e,this.concatOptions(["behaviors","externalClasses"],this.collectOptions(["behaviors","externalClasses"],t))),Object.assign(e,this.overrideOptions(["methods","properties","props","relations","options","inject"],this.collectOptions(["methods","properties","props","relations","options","inject"],t))),Object.assign(e,this.overrideMembers(["computed","observers"],this.collectOptions(["computed","observers"],t))),Object.assign(e,this.combineOptions(["data","provide"],this.collectOptions(["data","provide"],t))),Object.assign(e,this.seriesMembers(["lifetimes","pageLifetimes"],this.collectOptions(["lifetimes","pageLifetimes"],t))),Object.assign(e,this.seriesOptions(["definitionFilter"],this.collectOptions(["definitionFilter"],t))),Object.assign(e,this.seriesOptions(_lifecycle.default,this.collectOptions(_lifecycle.default,t))),_Optional.Optional.of(this.collectOptions(["watch"],t).get("watch")).ifPresent(function(r){var t=_Stream.Stream.of(_Stream.Stream.of(r).map(function(t){return Object.keys(t)}).flat()).distinct().collect(_Stream.Collectors.toList());Object.assign(e,{watch:_Stream.Stream.of(t).map(function(e){var t=r.map(function(t){return t[e]});return[e,1<t.length?(0,_Invocation.Invocation)(_Stream.Stream.of(t).flat()):t[0]]}).collect(_Stream.Collectors.toMap())})});var i,n=_Stream.Stream.of(Object.entries(t)).filter(function(t){return!_lifecycle.default.has(t[0])&&!_options.default.has(t[0])}).collect(_Stream.Collectors.groupingBy(function(t){return(0,_common.isFunction)(t[1])?"methods":"staticData"})),t=n.methods,n=n.staticData;return Array.isArray(t)&&(i=_Stream.Stream.of(t).collect(_Stream.Collectors.toMap()),_Optional.Optional.of(e.methods).ifPresentOrElse(function(t){Object.assign(t,i)},function(){Object.assign(e,{methods:i})})),Array.isArray(n)&&Object.assign(e,_Stream.Stream.of(n).collect(_Stream.Collectors.toMap())),e}},{key:"configuration",value:function(t,e,r){return this.reduceConfiguration(r)}},{key:"definitionFilter",value:function(t,e,r,o,n){o.behaviors&&(o.behaviors=(o.behaviors||[]).concat(r.behaviors||[]))}},{key:"build",value:function(t,e,r){var o=_Stream.Stream.of(Object.entries(r)).filter(function(t){var e=_slicedToArray(t,2),t=e[0],e=e[1];return!(0,_common.isFunction)(e)&&!_options.default.has(t)&&!_lifecycle.default.has(t)}).collect(_Stream.Collectors.toMap()),n=r.externalClasses,i=r.options,r=r.relations;return Object.assign({},o,(0,_common.removeEmpty)({externalClasses:n,options:i,relations:r}))}}]),e}();exports.default=MixinInstaller; | ||
"use strict";function _typeof(e){return(_typeof="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(exports,"__esModule",{value:!0}),exports.default=void 0;var _OptionInstaller2=_interopRequireDefault(require("./OptionInstaller")),_Blend=require("../libs/Blend"),_Stream=require("../libs/Stream"),_Invocation=require("../libs/Invocation"),_Optional=require("../libs/Optional"),_common=require("../utils/common"),_lifecycle=_interopRequireDefault(require("../utils/lifecycle")),_options=_interopRequireDefault(require("../utils/options")),_excluded=["extends","mixins"];function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_unsupportedIterableToArray(e,t)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArrayLimit(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o,n,i=[],a=!0,l=!1;try{for(r=r.call(e);!(a=(o=r.next()).done)&&(i.push(o.value),!t||i.length!==t);a=!0);}catch(e){l=!0,n=e}finally{try{a||null==r.return||r.return()}finally{if(l)throw n}}return i}}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _objectWithoutProperties(e,t){if(null==e)return{};var r,o=_objectWithoutPropertiesLoose(e,t);if(Object.getOwnPropertySymbols)for(var n=Object.getOwnPropertySymbols(e),i=0;i<n.length;i++)r=n[i],0<=t.indexOf(r)||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r]);return o}function _objectWithoutPropertiesLoose(e,t){if(null==e)return{};for(var r,o={},n=Object.keys(e),i=0;i<n.length;i++)r=n[i],0<=t.indexOf(r)||(o[r]=e[r]);return o}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _createForOfIteratorHelper(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=_unsupportedIterableToArray(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var o=0,t=function(){};return{s:t,n:function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:t}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var n,i=!0,a=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return i=e.done,e},e:function(e){a=!0,n=e},f:function(){try{i||null==r.return||r.return()}finally{if(a)throw n}}}}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Map"===(r="Object"===r&&e.constructor?e.constructor.name:r)||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,o=new Array(t);r<t;r++)o[r]=e[r];return o}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&_setPrototypeOf(e,t)}function _setPrototypeOf(e,t){return(_setPrototypeOf=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function _createSuper(r){var o=_isNativeReflectConstruct();return function(){var e,t=_getPrototypeOf(r);return _possibleConstructorReturn(this,o?(e=_getPrototypeOf(this).constructor,Reflect.construct(t,arguments,e)):t.apply(this,arguments))}}function _possibleConstructorReturn(e,t){if(t&&("object"===_typeof(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(e)}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function _getPrototypeOf(e){return(_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var MixinInstaller=function(){_inherits(o,_OptionInstaller2["default"]);var e=_createSuper(o);function o(){return _classCallCheck(this,o),e.apply(this,arguments)}return _createClass(o,[{key:"collectOptions",value:function(){var t=this,r=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[],e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},o=2<arguments.length&&void 0!==arguments[2]?arguments[2]:new Map;Array.isArray(e.mixins)&&e.mixins.forEach(function(e){return t.collectOptions(r,e,o)});var n,i=_createForOfIteratorHelper(r);try{for(i.s();!(n=i.n()).done;){var a=n.value;Reflect.has(e,a)&&(o.has(a)||o.set(a,[]),o.get(a).push(e[a]))}}catch(e){i.e(e)}finally{i.f()}return o}},{key:"overrideOptions",value:function(e,t){return _Stream.Stream.of((Array.isArray(e)?e:_toConsumableArray(e)).filter(function(e){return t.has(e)&&0<t.get(e).length})).map(function(e){return[e,Object.assign.apply(void 0,[{}].concat(t.get(e)))]}).collect(_Stream.Collectors.toMap())}},{key:"overrideMembers",value:function(e,t){return _Stream.Stream.of((Array.isArray(e)?e:_toConsumableArray(e)).filter(function(e){return t.has(e)&&0<t.get(e).length})).map(function(e){return[e,Object.assign.apply(void 0,[{}].concat(t.get(e)))]}).collect(_Stream.Collectors.toMap())}},{key:"combineOptions",value:function(e,t){return _Stream.Stream.of((Array.isArray(e)?e:_toConsumableArray(e)).filter(function(e){return t.has(e)&&0<t.get(e).length})).map(function(e){return[e,(0,_Blend.Blend)({},t.get(e))]}).collect(_Stream.Collectors.toMap())}},{key:"seriesOptions",value:function(e,t){return _Stream.Stream.of((Array.isArray(e)?e:_toConsumableArray(e)).filter(function(e){return t.has(e)&&0<t.get(e).length})).map(function(e){return[e,(0,_Invocation.Invocation)(t.get(e))]}).collect(_Stream.Collectors.toMap())}},{key:"seriesMembers",value:function(e,o){var n=this;return _Stream.Stream.of((Array.isArray(e)?e:_toConsumableArray(e)).filter(function(e){return o.has(e)&&0<o.get(e).length})).map(function(e){var t=_Stream.Stream.of(_Stream.Stream.of(o.get(e)).map(function(e){return Object.keys(e)}).flat()).distinct().collect(_Stream.Collectors.toList()),r=o.get(e);return[e,n.seriesOptions(t,_Stream.Stream.of(t).map(function(t){return[t,r.map(function(e){return e[t]})]}).collect(_Stream.Collectors.toMap(!0)))]}).collect(_Stream.Collectors.toMap())}},{key:"concatOptions",value:function(e,t){return _Stream.Stream.of((Array.isArray(e)?e:_toConsumableArray(e)).filter(function(e){return t.has(e)&&0<t.get(e).length})).map(function(e){return[e,_toConsumableArray(new Set(_Stream.Stream.of(t.get(e)).flat()))]}).collect(_Stream.Collectors.toMap())}},{key:"reduceConfiguration",value:function(e){var t={};if(e.extends){var r=e.extends,o=e.mixins,n=_objectWithoutProperties(e,_excluded);return this.reduceConfiguration(Object.assign({mixins:[r].concat(o||[])},n))}Object.assign(t,this.concatOptions(["behaviors","externalClasses"],this.collectOptions(["behaviors","externalClasses"],e))),Object.assign(t,this.overrideOptions(["methods","properties","props","relations","options","inject"],this.collectOptions(["methods","properties","props","relations","options","inject"],e))),Object.assign(t,this.overrideMembers(["computed","observers"],this.collectOptions(["computed","observers"],e))),Object.assign(t,this.combineOptions(["data","provide"],this.collectOptions(["data","provide"],e))),Object.assign(t,this.seriesMembers(["lifetimes","pageLifetimes"],this.collectOptions(["lifetimes","pageLifetimes"],e))),Object.assign(t,this.seriesOptions(["definitionFilter"],this.collectOptions(["definitionFilter"],e))),Object.assign(t,this.seriesOptions(_lifecycle.default,this.collectOptions(_lifecycle.default,e))),_Optional.Optional.of(this.collectOptions(["watch"],e).get("watch")).ifPresent(function(r){var e=_Stream.Stream.of(_Stream.Stream.of(r).map(function(e){return Object.keys(e)}).flat()).distinct().collect(_Stream.Collectors.toList());Object.assign(t,{watch:_Stream.Stream.of(e).map(function(t){var e=r.map(function(e){return e[t]});return[t,1<e.length?(0,_Invocation.Invocation)(_Stream.Stream.of(e).flat()):e[0]]}).collect(_Stream.Collectors.toMap())})});var i,n=_Stream.Stream.of(Object.entries(e)).filter(function(e){return!_lifecycle.default.has(e[0])&&!_options.default.has(e[0])}).collect(_Stream.Collectors.groupingBy(function(e){return(0,_common.isFunction)(e[1])?"methods":"staticData"})),e=n.methods,n=n.staticData;return Array.isArray(e)&&(i=_Stream.Stream.of(e).collect(_Stream.Collectors.toMap()),_Optional.Optional.of(t.methods).ifPresentOrElse(function(e){Object.assign(e,i)},function(){Object.assign(t,{methods:i})})),Array.isArray(n)&&Object.assign(t,_Stream.Stream.of(n).collect(_Stream.Collectors.toMap())),t}},{key:"configuration",value:function(e,t,r){return r&&o.globalMixins.length&&(r.mixins=o.globalMixins.concat(Array.isArray(r.mixins)?r.mixins:[])),this.reduceConfiguration(r)}},{key:"definitionFilter",value:function(e,t,r,o,n){o.behaviors&&(o.behaviors=(o.behaviors||[]).concat(r.behaviors||[]))}},{key:"build",value:function(e,t,r){var o=_Stream.Stream.of(Object.entries(r)).filter(function(e){var t=_slicedToArray(e,2),e=t[0],t=t[1];return!(0,_common.isFunction)(t)&&!_options.default.has(e)&&!_lifecycle.default.has(e)}).collect(_Stream.Collectors.toMap()),n=r.externalClasses,i=r.options,r=r.relations;return Object.assign({},o,(0,_common.removeEmpty)({externalClasses:n,options:i,relations:r}))}}],[{key:"addGlobalMixin",value:function(e){o.globalMixins.includes(e)||o.globalMixins.push(e)}},{key:"removeGlobalMixin",value:function(e){e=o.globalMixins.indexOf(e);0<=e&&o.globalMixins.splice(e,1)}},{key:"clearGlobalMixins",value:function(){o.globalMixins.splice(0)}}]),o}();_defineProperty(exports.default=MixinInstaller,"globalMixins",[]); |
@@ -175,7 +175,7 @@ declare namespace extend { | ||
$once: (event: string, listener: (event: string, data: EventArgs) => void) => void; | ||
$once: (event: string, listener: (event: string, data: RoutedEventArgs | EventArgs) => void) => void; | ||
$on: (event: string, listener: (event: string, data: EventArgs) => void) => void; | ||
$on: (event: string, listener: (event: string, data: RoutedEventArgs | EventArgs) => void) => void; | ||
$off: (event?: string, listener?: (event: string, data: EventArgs) => void) => void; | ||
$off: (event?: string, listener?: (event: string, data: RoutedEventArgs | EventArgs) => void) => void; | ||
} | ||
@@ -189,3 +189,5 @@ } | ||
export const Extension: { | ||
use: <T extends extend.OptionInstaller>(installer: T) => void; | ||
use: <T extends extend.OptionInstaller>(installer: T, priority?: number) => void; | ||
mixin: <T extends extend.Options>(mixin: T) => void; | ||
}; | ||
@@ -192,0 +194,0 @@ |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ComponentEx=ComponentEx,exports.OptionInstaller=exports.MPExtender=exports.Extension=void 0,exports.PageEx=PageEx;var _MPExtender2=_interopRequireDefault(require("./core/MPExtender")),_OptionInstaller2=_interopRequireDefault(require("./core/OptionInstaller"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _slicedToArray(e,r){return _arrayWithHoles(e)||_iterableToArrayLimit(e,r)||_unsupportedIterableToArray(e,r)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArrayLimit(e,r){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var n,o,a=[],l=!0,i=!1;try{for(t=t.call(e);!(l=(n=t.next()).done)&&(a.push(n.value),!r||a.length!==r);l=!0);}catch(e){i=!0,o=e}finally{try{l||null==t.return||t.return()}finally{if(i)throw o}}return a}}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _createForOfIteratorHelper(e,r){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=_unsupportedIterableToArray(e))||r&&e&&"number"==typeof e.length){t&&(e=t);var n=0,r=function(){};return{s:r,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,l=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return a=e.done,e},e:function(e){l=!0,o=e},f:function(){try{a||null==t.return||t.return()}finally{if(l)throw o}}}}function _unsupportedIterableToArray(e,r){if(e){if("string"==typeof e)return _arrayLikeToArray(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Map"===(t="Object"===t&&e.constructor?e.constructor.name:t)||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(e,r):void 0}}function _arrayLikeToArray(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var Extension={_installerClasses:new Map,use:function(e){this._installerClasses.set(e,1<arguments.length&&void 0!==arguments[1]?arguments[1]:100)}};function PageEx(e){var r=new _MPExtender2.default;if(Extension._installerClasses.size){var t,n=_createForOfIteratorHelper(Extension._installerClasses);try{for(n.s();!(t=n.n()).done;){var o=_slicedToArray(t.value,2),a=o[0],l=o[1];r.use(new a,l)}}catch(e){n.e(e)}finally{n.f()}}Page(r.extends(e))}function ComponentEx(e){var r=new _MPExtender2.default;if(Extension._installerClasses.size){var t,n=_createForOfIteratorHelper(Extension._installerClasses);try{for(n.s();!(t=n.n()).done;){var o=_slicedToArray(t.value,2),a=o[0],l=o[1];r.use(new a,l)}}catch(e){n.e(e)}finally{n.f()}}Component(r.extends(e))}exports.Extension=Extension;var MPExtender=_MPExtender2.default;exports.MPExtender=MPExtender;var OptionInstaller=_OptionInstaller2.default;exports.OptionInstaller=OptionInstaller; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ComponentEx=ComponentEx,exports.OptionInstaller=exports.MPExtender=exports.Extension=void 0,exports.PageEx=PageEx;var _MPExtender2=_interopRequireDefault(require("./core/MPExtender")),_OptionInstaller2=_interopRequireDefault(require("./core/OptionInstaller")),_MixinInstaller=_interopRequireDefault(require("./core/MixinInstaller"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _slicedToArray(e,r){return _arrayWithHoles(e)||_iterableToArrayLimit(e,r)||_unsupportedIterableToArray(e,r)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArrayLimit(e,r){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var n,o,a=[],i=!0,l=!1;try{for(t=t.call(e);!(i=(n=t.next()).done)&&(a.push(n.value),!r||a.length!==r);i=!0);}catch(e){l=!0,o=e}finally{try{i||null==t.return||t.return()}finally{if(l)throw o}}return a}}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _createForOfIteratorHelper(e,r){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=_unsupportedIterableToArray(e))||r&&e&&"number"==typeof e.length){t&&(e=t);var n=0,r=function(){};return{s:r,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,i=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return a=e.done,e},e:function(e){i=!0,o=e},f:function(){try{a||null==t.return||t.return()}finally{if(i)throw o}}}}function _unsupportedIterableToArray(e,r){if(e){if("string"==typeof e)return _arrayLikeToArray(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Map"===(t="Object"===t&&e.constructor?e.constructor.name:t)||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(e,r):void 0}}function _arrayLikeToArray(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var Extension={_installerClasses:new Map,use:function(e){this._installerClasses.set(e,1<arguments.length&&void 0!==arguments[1]?arguments[1]:100)},mixin:function(e){_MixinInstaller.default.addGlobalMixin(e)}};function PageEx(e){var r=new _MPExtender2.default;if(Extension._installerClasses.size){var t,n=_createForOfIteratorHelper(Extension._installerClasses);try{for(n.s();!(t=n.n()).done;){var o=_slicedToArray(t.value,2),a=o[0],i=o[1];r.use(new a,i)}}catch(e){n.e(e)}finally{n.f()}}Page(r.extends(e))}function ComponentEx(e){var r=new _MPExtender2.default;if(Extension._installerClasses.size){var t,n=_createForOfIteratorHelper(Extension._installerClasses);try{for(n.s();!(t=n.n()).done;){var o=_slicedToArray(t.value,2),a=o[0],i=o[1];r.use(new a,i)}}catch(e){n.e(e)}finally{n.f()}}Component(r.extends(e))}exports.Extension=Extension;var MPExtender=_MPExtender2.default;exports.MPExtender=MPExtender;var OptionInstaller=_OptionInstaller2.default;exports.OptionInstaller=OptionInstaller; |
@@ -175,7 +175,7 @@ declare namespace extend { | ||
$once: (event: string, listener: (event: string, data: EventArgs) => void) => void; | ||
$once: (event: string, listener: (event: string, data: RoutedEventArgs | EventArgs) => void) => void; | ||
$on: (event: string, listener: (event: string, data: EventArgs) => void) => void; | ||
$on: (event: string, listener: (event: string, data: RoutedEventArgs | EventArgs) => void) => void; | ||
$off: (event?: string, listener?: (event: string, data: EventArgs) => void) => void; | ||
$off: (event?: string, listener?: (event: string, data: RoutedEventArgs | EventArgs) => void) => void; | ||
} | ||
@@ -189,3 +189,5 @@ } | ||
export const Extension: { | ||
use: <T extends extend.OptionInstaller>(installer: T) => void; | ||
use: <T extends extend.OptionInstaller>(installer: T, priority?: number) => void; | ||
mixin: <T extends extend.Options>(mixin: T) => void; | ||
}; | ||
@@ -192,0 +194,0 @@ |
{ | ||
"name": "wechat-mini-program-extend", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"repository": "git@github.com:sitorhy/wechat-mini-program-extend.git", | ||
@@ -5,0 +5,0 @@ "author": "sitorhy <sitorhy>", |
@@ -230,3 +230,3 @@ # wechat-mini-program-extend | ||
const styles = [`color:${this.color}`]; | ||
return styles.join(""); | ||
return styles.join(";"); | ||
}, | ||
@@ -468,3 +468,4 @@ classes() { | ||
通常用不上,`$parent`,`$children`不完整,避免在回调中使用。 | ||
🔴 该配置通常用不上,`$parent`,`$children`不完整,应避免在回调中使用。 | ||
```javascript | ||
@@ -510,2 +511,70 @@ // behaviors.js 导出 | ||
* **mixins** | ||
🔴 主要用于混入生命周期或数据,方法每一次重定义都会覆盖上一次定义。 | ||
```javascript | ||
const Mixin = { | ||
data: { | ||
b: 200 | ||
}, | ||
methods: { | ||
test() { | ||
console.log('test'); | ||
} | ||
}, | ||
mounted() { | ||
console.log('mounted 1'); | ||
} | ||
}; | ||
PageEx({ | ||
mixins: [Mixin], | ||
data: { | ||
a: 100 | ||
}, | ||
methods: { | ||
test() { | ||
console.log(this.a + this.b); | ||
} | ||
}, | ||
mounted() { | ||
this.test(); | ||
} | ||
}); | ||
``` | ||
输出 | ||
``` | ||
mounted 1 | ||
300 | ||
``` | ||
* **全局混入** | ||
在`app.js`注入。 | ||
```javascript | ||
import {Extension} from "wechat-mini-program-extend"; | ||
Extension.mixin({ | ||
methods: { | ||
getUserInfo() { | ||
console.log('114514') | ||
} | ||
} | ||
}); | ||
App({ | ||
onLaunch(options) { | ||
// ... | ||
} | ||
}); | ||
``` | ||
### 实例方法 / 数据 | ||
@@ -635,3 +704,3 @@ | ||
🔴 以祖先组件为起点,自身为终点的方向(捕获顺序)触发一个总线事件,捕获事件可被拦截。页面可使用`PageEx`构建。 | ||
🔴 以祖先组件为起点,自身为终点的方向(捕获顺序)触发一个总线事件,捕获事件可被拦截。页面使用`PageEx`构建,使事件可以从页面往下传递。 | ||
@@ -652,2 +721,3 @@ ```javascript | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
177823
315
719
0