Automated build for v0.01
This commit is contained in:
8
lib/dojo/store/Cache.js
Normal file
8
lib/dojo/store/Cache.js
Normal file
@ -0,0 +1,8 @@
|
||||
/*
|
||||
Copyright (c) 2004-2016, The JS Foundation All Rights Reserved.
|
||||
Available via Academic Free License >= 2.1 OR the modified BSD license.
|
||||
see: http://dojotoolkit.org/license for details
|
||||
*/
|
||||
|
||||
//>>built
|
||||
define("dojo/store/Cache",["../_base/lang","../when"],function(_1,_2){var _3=function(_4,_5,_6){_6=_6||{};return _1.delegate(_4,{query:function(_7,_8){var _9=_4.query(_7,_8);_9.forEach(function(_a){if(!_6.isLoaded||_6.isLoaded(_a)){_5.put(_a);}});return _9;},queryEngine:_4.queryEngine||_5.queryEngine,get:function(id,_b){return _2(_5.get(id),function(_c){return _c||_2(_4.get(id,_b),function(_d){if(_d){_5.put(_d,{id:id});}return _d;});});},add:function(_e,_f){return _2(_4.add(_e,_f),function(_10){_5.add(_10&&typeof _10=="object"?_10:_e,_f);return _10;});},put:function(_11,_12){_5.remove((_12&&_12.id)||this.getIdentity(_11));return _2(_4.put(_11,_12),function(_13){_5.put(_13&&typeof _13=="object"?_13:_11,_12);return _13;});},remove:function(id,_14){return _2(_4.remove(id,_14),function(_15){return _5.remove(id,_14);});},evict:function(id){return _5.remove(id);}});};_1.setObject("dojo.store.Cache",_3);return _3;});
|
8
lib/dojo/store/DataStore.js
Normal file
8
lib/dojo/store/DataStore.js
Normal file
@ -0,0 +1,8 @@
|
||||
/*
|
||||
Copyright (c) 2004-2016, The JS Foundation All Rights Reserved.
|
||||
Available via Academic Free License >= 2.1 OR the modified BSD license.
|
||||
see: http://dojotoolkit.org/license for details
|
||||
*/
|
||||
|
||||
//>>built
|
||||
define("dojo/store/DataStore",["../_base/lang","../_base/declare","../Deferred","../_base/array","./util/QueryResults","./util/SimpleQueryEngine"],function(_1,_2,_3,_4,_5,_6){var _7=null;return _2("dojo.store.DataStore",_7,{target:"",constructor:function(_8){_1.mixin(this,_8);if(!("idProperty" in _8)){var _9;try{_9=this.store.getIdentityAttributes();}catch(e){}this.idProperty=(_1.isArray(_9)?_9[0]:_9)||this.idProperty;}var _a=this.store.getFeatures();if(!_a["dojo.data.api.Read"]){this.get=null;}if(!_a["dojo.data.api.Identity"]){this.getIdentity=null;}if(!_a["dojo.data.api.Write"]){this.put=this.add=null;}},idProperty:"id",store:null,queryEngine:_6,_objectConverter:function(_b){var _c=this.store;var _d=this.idProperty;function _e(_f){var _10={};var _11=_c.getAttributes(_f);for(var i=0;i<_11.length;i++){var _12=_11[i];var _13=_c.getValues(_f,_12);if(_13.length>1){for(var j=0;j<_13.length;j++){var _14=_13[j];if(typeof _14=="object"&&_c.isItem(_14)){_13[j]=_e(_14);}}_14=_13;}else{var _14=_c.getValue(_f,_12);if(typeof _14=="object"&&_c.isItem(_14)){_14=_e(_14);}}_10[_11[i]]=_14;}if(!(_d in _10)&&_c.getIdentity){_10[_d]=_c.getIdentity(_f);}return _10;};return function(_15){return _b(_15&&_e(_15));};},get:function(id,_16){var _17,_18;var _19=new _3();this.store.fetchItemByIdentity({identity:id,onItem:this._objectConverter(function(_1a){_19.resolve(_17=_1a);}),onError:function(_1b){_19.reject(_18=_1b);}});if(_17!==undefined){return _17==null?undefined:_17;}if(_18){throw _18;}return _19.promise;},put:function(_1c,_1d){_1d=_1d||{};var id=typeof _1d.id!="undefined"?_1d.id:this.getIdentity(_1c);var _1e=this.store;var _1f=this.idProperty;var _20=new _3();if(typeof id=="undefined"){var _21=_1e.newItem(_1c);_1e.save({onComplete:function(){_20.resolve(_21);},onError:function(_22){_20.reject(_22);}});}else{_1e.fetchItemByIdentity({identity:id,onItem:function(_23){if(_23){if(_1d.overwrite===false){return _20.reject(new Error("Overwriting existing object not allowed"));}for(var i in _1c){if(i!=_1f&&_1c.hasOwnProperty(i)&&_1e.getValue(_23,i)!=_1c[i]){_1e.setValue(_23,i,_1c[i]);}}}else{if(_1d.overwrite===true){return _20.reject(new Error("Creating new object not allowed"));}var _23=_1e.newItem(_1c);}_1e.save({onComplete:function(){_20.resolve(_23);},onError:function(_24){_20.reject(_24);}});},onError:function(_25){_20.reject(_25);}});}return _20.promise;},add:function(_26,_27){(_27=_27||{}).overwrite=false;return this.put(_26,_27);},remove:function(id){var _28=this.store;var _29=new _3();this.store.fetchItemByIdentity({identity:id,onItem:function(_2a){try{if(_2a==null){_29.resolve(false);}else{_28.deleteItem(_2a);_28.save();_29.resolve(true);}}catch(error){_29.reject(error);}},onError:function(_2b){_29.reject(_2b);}});return _29.promise;},query:function(_2c,_2d){var _2e;var _2f=new _3(function(){_2e.abort&&_2e.abort();});_2f.total=new _3();var _30=this._objectConverter(function(_31){return _31;});_2e=this.store.fetch(_1.mixin({query:_2c,onBegin:function(_32){_2f.total.resolve(_32);},onComplete:function(_33){_2f.resolve(_4.map(_33,_30));},onError:function(_34){_2f.reject(_34);}},_2d));return _5(_2f);},getIdentity:function(_35){return _35[this.idProperty];}});});
|
8
lib/dojo/store/JsonRest.js
Normal file
8
lib/dojo/store/JsonRest.js
Normal file
@ -0,0 +1,8 @@
|
||||
/*
|
||||
Copyright (c) 2004-2016, The JS Foundation All Rights Reserved.
|
||||
Available via Academic Free License >= 2.1 OR the modified BSD license.
|
||||
see: http://dojotoolkit.org/license for details
|
||||
*/
|
||||
|
||||
//>>built
|
||||
define("dojo/store/JsonRest",["../_base/xhr","../_base/lang","../json","../_base/declare","./util/QueryResults"],function(_1,_2,_3,_4,_5){var _6=null;return _4("dojo.store.JsonRest",_6,{constructor:function(_7){this.headers={};_4.safeMixin(this,_7);},headers:{},target:"",idProperty:"id",ascendingPrefix:"+",descendingPrefix:"-",_getTarget:function(id){var _8=this.target;if(typeof id!="undefined"){if((_8.charAt(_8.length-1)=="/")||(_8.charAt(_8.length-1)=="=")){_8+=id;}else{_8+="/"+id;}}return _8;},get:function(id,_9){_9=_9||{};var _a=_2.mixin({Accept:this.accepts},this.headers,_9.headers||_9);return _1("GET",{url:this._getTarget(id),handleAs:"json",headers:_a,timeout:_9&&_9.timeout});},accepts:"application/javascript, application/json",getIdentity:function(_b){return _b[this.idProperty];},put:function(_c,_d){_d=_d||{};var id=("id" in _d)?_d.id:this.getIdentity(_c);var _e=typeof id!="undefined";return _1(_e&&!_d.incremental?"PUT":"POST",{url:this._getTarget(id),postData:_3.stringify(_c),handleAs:"json",headers:_2.mixin({"Content-Type":"application/json",Accept:this.accepts,"If-Match":_d.overwrite===true?"*":null,"If-None-Match":_d.overwrite===false?"*":null},this.headers,_d.headers),timeout:_d&&_d.timeout});},add:function(_f,_10){_10=_10||{};_10.overwrite=false;return this.put(_f,_10);},remove:function(id,_11){_11=_11||{};return _1("DELETE",{url:this._getTarget(id),headers:_2.mixin({},this.headers,_11.headers),timeout:_11&&_11.timeout});},query:function(_12,_13){_13=_13||{};var _14=_2.mixin({Accept:this.accepts},this.headers,_13.headers);var _15=this.target.indexOf("?")>-1;_12=_12||"";if(_12&&typeof _12=="object"){_12=_1.objectToQuery(_12);_12=_12?(_15?"&":"?")+_12:"";}if(_13.start>=0||_13.count>=0){_14["X-Range"]="items="+(_13.start||"0")+"-"+(("count" in _13&&_13.count!=Infinity)?(_13.count+(_13.start||0)-1):"");if(this.rangeParam){_12+=(_12||_15?"&":"?")+this.rangeParam+"="+_14["X-Range"];_15=true;}else{_14.Range=_14["X-Range"];}}if(_13&&_13.sort){var _16=this.sortParam;_12+=(_12||_15?"&":"?")+(_16?_16+"=":"sort(");for(var i=0;i<_13.sort.length;i++){var _17=_13.sort[i];_12+=(i>0?",":"")+(_17.descending?this.descendingPrefix:this.ascendingPrefix)+encodeURIComponent(_17.attribute);}if(!_16){_12+=")";}}var _18=_1("GET",{url:this.target+(_12||""),handleAs:"json",headers:_14,timeout:_13&&_13.timeout});_18.total=_18.then(function(){var _19=_18.ioArgs.xhr.getResponseHeader("Content-Range");if(!_19){_19=_18.ioArgs.xhr.getResponseHeader("X-Content-Range");}return _19&&(_19=_19.match(/\/(.*)/))&&+_19[1];});return _5(_18);}});});
|
8
lib/dojo/store/Memory.js
Normal file
8
lib/dojo/store/Memory.js
Normal file
@ -0,0 +1,8 @@
|
||||
/*
|
||||
Copyright (c) 2004-2016, The JS Foundation All Rights Reserved.
|
||||
Available via Academic Free License >= 2.1 OR the modified BSD license.
|
||||
see: http://dojotoolkit.org/license for details
|
||||
*/
|
||||
|
||||
//>>built
|
||||
define("dojo/store/Memory",["../_base/declare","./util/QueryResults","./util/SimpleQueryEngine"],function(_1,_2,_3){var _4=null;return _1("dojo.store.Memory",_4,{constructor:function(_5){for(var i in _5){this[i]=_5[i];}this.setData(this.data||[]);},data:null,idProperty:"id",index:null,queryEngine:_3,get:function(id){return this.data[this.index[id]];},getIdentity:function(_6){return _6[this.idProperty];},put:function(_7,_8){var _9=this.data,_a=this.index,_b=this.idProperty;var id=_7[_b]=(_8&&"id" in _8)?_8.id:_b in _7?_7[_b]:Math.random();if(id in _a){if(_8&&_8.overwrite===false){throw new Error("Object already exists");}_9[_a[id]]=_7;}else{_a[id]=_9.push(_7)-1;}return id;},add:function(_c,_d){(_d=_d||{}).overwrite=false;return this.put(_c,_d);},remove:function(id){var _e=this.index;var _f=this.data;if(id in _e){_f.splice(_e[id],1);this.setData(_f);return true;}},query:function(_10,_11){return _2(this.queryEngine(_10,_11)(this.data));},setData:function(_12){if(_12.items){this.idProperty=_12.identifier||this.idProperty;_12=this.data=_12.items;}else{this.data=_12;}this.index={};for(var i=0,l=_12.length;i<l;i++){this.index[_12[i][this.idProperty]]=i;}}});});
|
8
lib/dojo/store/Observable.js
Normal file
8
lib/dojo/store/Observable.js
Normal file
@ -0,0 +1,8 @@
|
||||
/*
|
||||
Copyright (c) 2004-2016, The JS Foundation All Rights Reserved.
|
||||
Available via Academic Free License >= 2.1 OR the modified BSD license.
|
||||
see: http://dojotoolkit.org/license for details
|
||||
*/
|
||||
|
||||
//>>built
|
||||
define("dojo/store/Observable",["../_base/kernel","../_base/lang","../when","../_base/array"],function(_1,_2,_3,_4){var _5=function(_6){var _7,_8=[],_9=0;_6=_2.delegate(_6);_6.notify=function(_a,_b){_9++;var _c=_8.slice();for(var i=0,l=_c.length;i<l;i++){_c[i](_a,_b);}};var _d=_6.query;_6.query=function(_e,_f){_f=_f||{};var _10=_d.apply(this,arguments);if(_10&&_10.forEach){var _11=_2.mixin({},_f);delete _11.start;delete _11.count;var _12=_6.queryEngine&&_6.queryEngine(_e,_11);var _13=_9;var _14=[],_15;_10.observe=function(_16,_17){if(_14.push(_16)==1){_8.push(_15=function(_18,_19){_3(_10,function(_1a){var _1b=_1a.length!=_f.count;var i,l,_16;if(++_13!=_9){throw new Error("Query is out of date, you must observe() the query prior to any data modifications");}var _1c,_1d=-1,_1e=-1;if(_19!==_7){var _1f=[].concat(_1a);if(_12&&!_18){_1f=_12(_1a);}for(i=0,l=_1a.length;i<l;i++){var _20=_1a[i];if(_6.getIdentity(_20)==_19){if(_1f.indexOf(_20)<0){continue;}_1c=_20;_1d=i;if(_12||!_18){_1a.splice(i,1);}break;}}}if(_12){if(_18&&(_12.matches?_12.matches(_18):_12([_18]).length)){var _21=_1d>-1?_1d:_1a.length;_1a.splice(_21,0,_18);_1e=_4.indexOf(_12(_1a),_18);_1a.splice(_21,1);if((_f.start&&_1e==0)||(!_1b&&_1e==_1a.length)){_1e=-1;}else{_1a.splice(_1e,0,_18);}}}else{if(_18){if(_19!==_7){_1e=_1d;}else{if(!_f.start){_1e=_6.defaultIndex||0;_1a.splice(_1e,0,_18);}}}}if((_1d>-1||_1e>-1)&&(_17||!_12||(_1d!=_1e))){var _22=_14.slice();for(i=0;_16=_22[i];i++){_16(_18||_1c,_1d,_1e);}}});});}var _23={};_23.remove=_23.cancel=function(){var _24=_4.indexOf(_14,_16);if(_24>-1){_14.splice(_24,1);if(!_14.length){_8.splice(_4.indexOf(_8,_15),1);}}};return _23;};}return _10;};var _25;function _26(_27,_28){var _29=_6[_27];if(_29){_6[_27]=function(_2a){var _2b;if(_27==="put"){_2b=_6.getIdentity(_2a);}if(_25){return _29.apply(this,arguments);}_25=true;try{var _2c=_29.apply(this,arguments);_3(_2c,function(_2d){_28((typeof _2d=="object"&&_2d)||_2a,_2b);});return _2c;}finally{_25=false;}};}};_26("put",function(_2e,_2f){_6.notify(_2e,_2f);});_26("add",function(_30){_6.notify(_30);});_26("remove",function(id){_6.notify(undefined,id);});return _6;};_2.setObject("dojo.store.Observable",_5);return _5;});
|
6
lib/dojo/store/README
Normal file
6
lib/dojo/store/README
Normal file
@ -0,0 +1,6 @@
|
||||
This folder contains the stores and utilities implementing the Dojo Object Store API,
|
||||
a successor and unifier to Dojo Data, Dojo Storage, and potentially Dojo Model. These
|
||||
stores are designed to provide simple lightweight implementations
|
||||
providing core functionality for typical applications.
|
||||
|
||||
See http://dojotoolkit.org/features/1.6/object-store for more information
|
8
lib/dojo/store/api/Store.js
Normal file
8
lib/dojo/store/api/Store.js
Normal file
@ -0,0 +1,8 @@
|
||||
/*
|
||||
Copyright (c) 2004-2016, The JS Foundation All Rights Reserved.
|
||||
Available via Academic Free License >= 2.1 OR the modified BSD license.
|
||||
see: http://dojotoolkit.org/license for details
|
||||
*/
|
||||
|
||||
//>>built
|
||||
define("dojo/store/api/Store",["../../_base/declare"],function(_1){var _2=_1(null,{idProperty:"id",queryEngine:null,get:function(id){},getIdentity:function(_3){},put:function(_4,_5){},add:function(_6,_7){},remove:function(id){delete this.index[id];var _8=this.data,_9=this.idProperty;for(var i=0,l=_8.length;i<l;i++){if(_8[i][_9]==id){_8.splice(i,1);return;}}},query:function(_a,_b){},transaction:function(){},getChildren:function(_c,_d){},getMetadata:function(_e){}});_2.PutDirectives=_1(null,{});_2.SortInformation=_1(null,{});_2.QueryOptions=_1(null,{});_2.QueryResults=_1(null,{forEach:function(_f,_10){},filter:function(_11,_12){},map:function(_13,_14){},then:function(_15,_16){},observe:function(_17,_18){},total:0});_2.Transaction=_1(null,{commit:function(){},abort:function(_19,_1a){}});return _2;});
|
8
lib/dojo/store/util/QueryResults.js
Normal file
8
lib/dojo/store/util/QueryResults.js
Normal file
@ -0,0 +1,8 @@
|
||||
/*
|
||||
Copyright (c) 2004-2016, The JS Foundation All Rights Reserved.
|
||||
Available via Academic Free License >= 2.1 OR the modified BSD license.
|
||||
see: http://dojotoolkit.org/license for details
|
||||
*/
|
||||
|
||||
//>>built
|
||||
define("dojo/store/util/QueryResults",["../../_base/array","../../_base/lang","../../when"],function(_1,_2,_3){var _4=function(_5){if(!_5){return _5;}var _6=!!_5.then;if(_6){_5=_2.delegate(_5);}function _7(_8){_5[_8]=function(){var _9=arguments;var _a=_3(_5,function(_b){Array.prototype.unshift.call(_9,_b);return _4(_1[_8].apply(_1,_9));});if(_8!=="forEach"||_6){return _a;}};};_7("forEach");_7("filter");_7("map");if(_5.total==null){_5.total=_3(_5,function(_c){return _c.length;});}return _5;};_2.setObject("dojo.store.util.QueryResults",_4);return _4;});
|
8
lib/dojo/store/util/SimpleQueryEngine.js
Normal file
8
lib/dojo/store/util/SimpleQueryEngine.js
Normal file
@ -0,0 +1,8 @@
|
||||
/*
|
||||
Copyright (c) 2004-2016, The JS Foundation All Rights Reserved.
|
||||
Available via Academic Free License >= 2.1 OR the modified BSD license.
|
||||
see: http://dojotoolkit.org/license for details
|
||||
*/
|
||||
|
||||
//>>built
|
||||
define("dojo/store/util/SimpleQueryEngine",["../../_base/array"],function(_1){return function(_2,_3){switch(typeof _2){default:throw new Error("Can not query with a "+typeof _2);case "object":case "undefined":var _4=_2;_2=function(_5){for(var _6 in _4){var _7=_4[_6];if(_7&&_7.test){if(!_7.test(_5[_6],_5)){return false;}}else{if(_7!=_5[_6]){return false;}}}return true;};break;case "string":if(!this[_2]){throw new Error("No filter function "+_2+" was found in store");}_2=this[_2];case "function":}function _8(_9){var _a=_1.filter(_9,_2);var _b=_3&&_3.sort;if(_b){_a.sort(typeof _b=="function"?_b:function(a,b){for(var _c,i=0;_c=_b[i];i++){var _d=a[_c.attribute];var _e=b[_c.attribute];_d=_d!=null?_d.valueOf():_d;_e=_e!=null?_e.valueOf():_e;if(_d!=_e){return !!_c.descending==(_d==null||_d>_e)?-1:1;}}return 0;});}if(_3&&(_3.start||_3.count)){var _f=_a.length;_a=_a.slice(_3.start||0,(_3.start||0)+(_3.count||Infinity));_a.total=_f;}return _a;};_8.matches=_2;return _8;};});
|
Reference in New Issue
Block a user