/
lom.min.js
1 lines (1 loc) · 8.01 KB
/
lom.min.js
1
!function t(e,n,r){function s(i,u){if(!n[i]){if(!e[i]){var a="function"==typeof require&&require;if(!u&&a)return a(i,!0);if(o)return o(i,!0);throw new Error("Cannot find module '"+i+"'")}var c=n[i]={exports:{}};e[i][0].call(c.exports,function(t){var n=e[i][1][t];return s(n?n:t)},c,c.exports,t,e,n,r)}return n[i].exports}for(var o="function"==typeof require&&require,i=0;i<r.length;i++)s(r[i]);return s}({1:[function(t,e){e.exports=t("./async/index")},{"./async/index":2}],2:[function(t,e){e.exports={Schema:t("./schema"),Model:t("./model"),types:t("./types")}},{"./model":3,"./schema":4,"./types":5}],3:[function(t,e){{var n,r,s,o=t("extends__");({}).hasOwnProperty}r=t("../core/model"),s=t("./schema"),e.exports=n=function(t){function e(t){return this instanceof e?(t&&t instanceof s||(t=new s),void e.__super__.constructor.call(this,t)):new e(t)}return o(e,t),e.prototype.apply=function(t,n){var r,s;return r=t._state,t._state="lock",s=e.__super__.apply.call(this,t,n),t._state=r,s},e.prototype.sync=function(){return this},e.prototype.set=function(t,n,r){var s;return s=e.__super__.set.call(this,t,n,r),"lock"!==t._state&&"_state"!==n&&"_status"!==n&&"_notify"!==n&&this.set(t,"_state",t._state?"dirty":"new"),s},e.prototype.set_state=function(t,e){return t._state=e,"function"==typeof t._notify&&t._notify(e,t._status),("init"===e||"new"===e||"dirty"===e||"old"===e)&&this.sync(t),e},e}(r)},{"../core/model":8,"./schema":4,extends__:19}],4:[function(t,e){{var n,r,s,o=t("extends__");({}).hasOwnProperty}r=t("../core/schema"),s=t("./types"),e.exports=n=function(t){function e(t){return null==t&&(t={}),this instanceof e?(t._state=s.state,t._status=s.status,t._notify=s.callback,void e.__super__.constructor.call(this,t)):new e(t)}return o(e,t),e}(r)},{"../core/schema":10,"./types":5,extends__:19}],5:[function(t,e){var n,r,s,o,i,u=[].indexOf||function(t){for(var e=0,n=this.length;n>e;e++)if(e in this&&this[e]===t)return e;return-1};s=t("../core/index"),n=s.NIL,r=s.Type,i=s.types,o=["init","new","dirty","sync","busy","lock","old","error"],e.exports={state:new r({enumerable:!1},function(t){return u.call(o,t)>=0?t:n}),status:new r({enumerable:!1},function(t){return i.string.apply(t)}),callback:new r({enumerable:!1},function(t){return i["function"].apply(t)})}},{"../core/index":7}],6:[function(t,e){e.exports=t("./core/index")},{"./core/index":7}],7:[function(t,e){e.exports={NIL:t("./nil"),Type:t("./type"),Schema:t("./schema"),Model:t("./model"),types:t("./types")}},{"./model":8,"./nil":9,"./schema":10,"./type":11,"./types":12}],8:[function(t,e){var n,r,s,o,i,u={}.hasOwnProperty;r=t("./nil"),o=t("./type"),s=t("./schema"),i=function(t){return"string"==typeof t?t.substr(0,1).toUpperCase()+t.substr(1).toLowerCase():void 0},e.exports=n=function(){function t(e){return this instanceof t?(e&&e instanceof s||(e=new s),void Object.defineProperty(this,"_schema",{configurable:!1,writable:!1,enumerable:!1,value:e})):new t(e)}return t.prototype.apply=function(t,e){var n,s,o,i;s=this._schema;for(n in s)u.call(s,n)&&(o=s[n],o.enumerable&&e.hasOwnProperty(n)&&r!==(i=o.apply(e[n]))&&this.set(t,n,i));return t},t.prototype.get=function(t,e){var n;return(n=this["get"+i(e)])?n.call(this,t):t[e]},t.prototype.set=function(t,e,n){var r;return(r=this["set"+i(e)])?r.call(this,t,n):t[e]=n},t.prototype.create=function(t){var e,n,s,i,a;null==t&&(t={}),t=this.apply({},t),i={},s=this._schema,e=function(e){return function(n,s){return n&&s instanceof o?Object.defineProperty(i,n,{configurable:s.configurable?!0:!1,enumerable:s.enumerable?!0:!1,get:function(){var o;return o=e.get(t,n),r!==(o=s.apply(o))?o:void 0},set:function(o){return r!==(o=s.apply(o))?e.set(t,n,o):void 0}}):void 0}}(this);for(n in s)u.call(s,n)&&(a=s[n],e(n,a));return i},t.prototype.destroy=function(t){return t},t}()},{"./nil":9,"./schema":10,"./type":11}],9:[function(t,e){var n;e.exports=n=function(){return n}},{}],10:[function(t,e){var n;e.exports=n=function(){function t(e){var n,r;if(null==e&&(e={}),!(this instanceof t))return new t(e);for(n in e)r=e[n],this[n]=r;Object.freeze(this)}return t}()},{}],11:[function(t,e){var n,r,s=[].slice;n=t("./nil"),e.exports=r=function(){function t(){var e,r,o;return r=2<=arguments.length?s.call(arguments,0,e=arguments.length-1):(e=0,[]),o=arguments[e++],this instanceof t?(r=r[0]||{},this.apply="function"==typeof o?o:function(){return n},this.configurable="boolean"==typeof r.configurable?r.configurable:!1,this.enumerable="boolean"==typeof r.enumerable?r.enumerable:!0,void Object.freeze(this)):new t(o)}return t}()},{"./nil":9}],12:[function(t,e){var n,r,s;n=t("./nil"),r=t("./type"),e.exports=s={number:new r(function(t){return"number"!=typeof t&&isNaN(t=parseFloat(t))?n:t}),integer:new r(function(t){return n!==(t=s.number.apply(t))?Math.floor(t):n}),regexp:new r(function(t){return t instanceof RegExp?t:n}),"boolean":new r(function(t){return"boolean"==typeof t?t:n}),string:new r(function(t){return"string"==typeof t?t.toString():n}),object:new r(function(t){return"object"==typeof t?t:n}),array:new r(function(t){return Array.isArray(t)?t:n}),hash:new r(function(t){return n!==s.object.apply(t)&&n===s.array.apply(t)?t:n}),"function":new r(function(t){return"function"==typeof t?t:n})}},{"./nil":9,"./type":11}],13:[function(t,e){e.exports=t("./crud/index")},{"./crud/index":14}],14:[function(t,e,n){arguments[4][2][0].apply(n,arguments)},{"./model":15,"./schema":16,"./types":17}],15:[function(t,e){{var n,r,s,o=t("extends__");({}).hasOwnProperty}r=t("../async/model"),s=t("./schema"),e.exports=n=function(t){function e(t,n){return this instanceof e?(t&&t instanceof s||(t=new s),Object.defineProperty(this,"_adapter",{enumerable:!1,value:n}),void e.__super__.constructor.call(this,t)):new e(t,n)}return o(e,t),e.prototype.create=function(t){var n;return null==t&&(t={}),n=e.__super__.create.apply(this,arguments),n.id=t.id,n},e.prototype.sync=function(t){var e,n,r,s;if(null!=this._adapter)switch(t._state){case"new":this.set(t,"_status","create in progress"),this.set(t,"_state","busy"),"function"==typeof(e=this._adapter).create&&e.create(t,function(e){return function(n,r){return n?(e.set(t,"_status",n),e.set(t,"_state","error")):(e.apply(t,r),e.set(t,"_status","sync"),e.set(t,"_state","sync"))}}(this));break;case"dirty":this.set(t,"_status","update in progress"),this.set(t,"_state","busy"),"function"==typeof(n=this._adapter).update&&n.update(t,function(e){return function(n,r){return n?(e.set(t,"_state","error"),e.set(t,"_status",n)):(e.apply(t,r),e.set(t,"_state","sync"),e.set(t,"_status","sync"))}}(this));break;case"old":this.set(t,"_status","read in progress"),this.set(t,"_state","busy"),"function"==typeof(r=this._adapter).read&&r.read(t,function(e){return function(n,r){return n?(e.set(t,"_state","error"),e.set(t,"_status",n)):(e.apply(t,r),e.set(t,"_state","sync"),e.set(t,"_status","sync"))}}(this));break;case"init":this.set(t,"_status","init in progress"),"function"==typeof(s=this._adapter).read&&s.read(t,function(e){return function(n,r){return n?(e.set(t,"_state","error"),e.set(t,"_status",n)):(e.apply(t,r),e.set(t,"_state","sync"),e.set(t,"_status","sync"))}}(this))}return this},e.prototype.set=function(t,n,r){return"id"===n?(t._state&&"init"!==t._state||(t.id=r,this.set(t,"_state","old")),t.id):e.__super__.set.call(this,t,n,r)},e}(r)},{"../async/model":3,"./schema":16,extends__:19}],16:[function(t,e){{var n,r,s,o=t("extends__");({}).hasOwnProperty}r=t("../async/schema"),s=t("./types"),e.exports=n=function(t){function e(t){return null==t&&(t={}),this instanceof r?(t.id||(t.id=s.id),void e.__super__.constructor.call(this,t)):new r(t)}return o(e,t),e}(r)},{"../async/schema":4,"./types":17,extends__:19}],17:[function(t,e){var n,r,s;r=t("../core/index"),n=r.Type,s=r.types,e.exports={id:new n(function(t){return s.integer.apply(t)})}},{"../core/index":7}],18:[function(t){window.LOM={core:t("./core"),async:t("./async"),crud:t("./crud")}},{"./async":1,"./core":6,"./crud":13}],19:[function(t,e){var n=function(t,e){function n(){this.constructor=t}for(var s in e)r.call(e,s)&&(t[s]=e[s]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t},r={}.hasOwnProperty;e.exports=function(t,e){return n(t,e)}},{}]},{},[18]);