index.js 4.8 KB

1
  1. var _=(r,i)=>()=>(i||r((i={exports:{}}).exports,i),i.exports);var y=_(d=>{"use strict";Object.defineProperty(d,"__esModule",{value:!0}),d.createActions=d.createDataFieldsReactions=void 0;var A,x,m=require("mobx-miniprogram");function O(r){if(Array.isArray(r)){for(var i=0,e=new Array(r.length);i<r.length;i++)e[i]=r[i];return e}}function S(r,i,e){return i in r?Object.defineProperty(r,i,{value:e,enumerable:!0,configurable:!0,writable:!0}):r[i]=e,r}function j(r){if(Symbol.iterator in Object(r)||Object.prototype.toString.call(r)==="[object Arguments]")return Array.from(r)}function D(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function F(r){for(var i=1;i<arguments.length;i++){var e=arguments[i]!=null?arguments[i]:{},n=Object.keys(e);typeof Object.getOwnPropertySymbols=="function"&&(n=n.concat(Object.getOwnPropertySymbols(e).filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.forEach(function(t){S(r,t,e[t])})}return r}function w(r){return O(r)||j(r)||D()}var q=function(r,i){var e=i.store,n=i.actions;if(n){if(e===void 0)throw new Error("[mobx-miniprogram] no store specified");Array.isArray(n)?n.forEach(function(t){if(r[t])throw new Error("[mobx-miniprogram] multiple action definition");r[t]=function(){for(var a=arguments.length,u=new Array(a),c=0;c<a;c++)u[c]=arguments[c];return(A=e)[t].apply(A,w(u))}}):typeof n=="object"&&Object.keys(n).forEach(function(t){var a=n[t];if(typeof t!="string"&&typeof t!="number")throw new Error("[mobx-miniprogram] unrecognized field definition");r[t]=function(){for(var u=arguments.length,c=new Array(u),s=0;s<u;s++)c[s]=arguments[s];return(x=e)[a].apply(x,w(c))}})}};d.createActions=q;var C=function(r,i){var e=i.store,n=i.fields,t=i.structuralComparison,a=i.namespace||"";if(a&&typeof a!="string")throw new Error("[mobx-miniprogram] namespace only expect string");a=a.replace(/ /gm,"");var u=Object.assign({},r[a]),c=t?m.comparer.structural:void 0,s=null,B=function(){if(s!==null){var o=s;s=null,r.setData(o)}},h=function(o,f){s||(s={},wx.nextTick(B)),a!==""?(u=F({},u,S({},o,m.toJS(f))),s[a]=u):s[o]=m.toJS(f)},l=[];if(Array.isArray(n)){if(e===void 0)throw new Error("[mobx-miniprogram] no store specified");l=n.map(function(o){return m.reaction(function(){return e[o]},function(f){h(o,f)},{equals:c,fireImmediately:!0})})}else typeof n=="object"&&n&&(l=Object.keys(n).map(function(o){var f=n[o];if(typeof f=="function")return m.reaction(function(){return f.call(r,e)},function(b){h(o,b)},{equals:c,fireImmediately:!0});if(typeof o!="string"&&typeof o!="number")throw new Error("[mobx-miniprogram] unrecognized field definition");if(e===void 0)throw new Error("[mobx-miniprogram] no store specified");return m.reaction(function(){return e[f]},function(b){h(String(o),b)},{equals:c,fireImmediately:!0})}));return{updateStoreBindings:B,destroyStoreBindings:function(){l.forEach(function(o){return o()})}}};d.createDataFieldsReactions=C});var M=_(p=>{"use strict";Object.defineProperty(p,"__esModule",{value:!0}),p.behavior=void 0;var g=y(),R=Behavior({definitionFilter:function(r){r.methods=r.methods||{};var i=r.storeBindings;r.methods._mobxMiniprogramBindings=function(){return i},i&&(Array.isArray(i)?i.forEach(function(e){g.createActions(r.methods,e)}):g.createActions(r.methods,i))},lifetimes:{attached:function(){if(typeof this._mobxMiniprogramBindings=="function"){var r=this._mobxMiniprogramBindings();if(!r)return void(this._mobxMiniprogramBindings=null);if(Array.isArray(r)){var i=this;this._mobxMiniprogramBindings=r.map(function(e){var n=g.createDataFieldsReactions(i,e);return n.updateStoreBindings(),n})}else this._mobxMiniprogramBindings=g.createDataFieldsReactions(this,r),this._mobxMiniprogramBindings.updateStoreBindings()}},detached:function(){this._mobxMiniprogramBindings&&(Array.isArray(this._mobxMiniprogramBindings)?this._mobxMiniprogramBindings.forEach(function(r){r.destroyStoreBindings()}):this._mobxMiniprogramBindings.destroyStoreBindings())}},methods:{updateStoreBindings:function(){this._mobxMiniprogramBindings&&typeof this._mobxMiniprogramBindings!="function"&&(Array.isArray(this._mobxMiniprogramBindings)?this._mobxMiniprogramBindings.forEach(function(r){r.updateStoreBindings()}):this._mobxMiniprogramBindings.updateStoreBindings())}}});p.behavior=R});"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ComponentWithStore=I,exports.BehaviorWithStore=W,exports.createStoreBindings=exports.storeBindingsBehavior=void 0;var v=M(),E=y();function I(r){return Array.isArray(r.behaviors)||(r.behaviors=[]),r.behaviors.unshift(v.behavior),Component(r)}function W(r){return Array.isArray(r.behaviors)||(r.behaviors=[]),r.behaviors.unshift(v.behavior),Behavior(r)}var k=function(r,i){return E.createActions(r,i),E.createDataFieldsReactions(r,i)};exports.createStoreBindings=k;var P=v.behavior;exports.storeBindingsBehavior=P;