@mobilabs/spine
Advanced tools
Comparing version 0.9.5 to 1.0.0
/*! **************************************************************************** | ||
* Spine v0.9.5 | ||
* Spine v1.0.0 | ||
* | ||
@@ -9,5 +9,5 @@ * A tiny MVC framework inspired from Backbone.js. | ||
* at: http://www.opensource.org/licenses/mit-license.php). | ||
* Built from ES6Kadoo v1.0.10. | ||
* Built from ES6Kadoo v1.1.1. | ||
* ************************************************************************** */ | ||
/*! Generated by Kadoo v1.0.6 */ | ||
!function(t,e){"use strict";"function"==typeof define&&define.amd?define([""],e):"object"==typeof exports?module.exports=e(t):t.Spine=e(t)}(this,(t=>{"use strict";let e={src:{spine:{},components:{model:{main:{},private:{fetch:{},util:{}}},collection:{main:{},private:{util1:{},util2:{},util3:{}}},view:{main:{}},router:{main:{},util:{}},history:{main:{}},radio:{main:{}},generic:{main:{}}},sync:{main:{},fetch:{}},utils:{util1:{}},libs:{_:{}}},libin:{}};return e.extend=function(t,e){for(var n=Object.keys(e),i=0;i<n.length;i++)t[n[i]]=e[n[i]]},function(t,e){"function"==typeof define&&define.amd?define([""],e):"object"==typeof exports?(module.exports=e(t),t.Messenger=e(t)):t.Messenger=e(t)}(e.libin,(t=>{let e,n;return function(){const i=t.Messenger;let s;e=function(){const t=Object.create(s);return t._library={name:"Messenger",version:"1.0.3"},t._db={},t},e.NAME="Messenger",e.VERSION="1.0.3",e._setTestMode=function(){return[]},e.noConflict=function(){return t.Messenger=i,this},s={whoami(){return this._library},subscribe(t,e){return n.subscribe(this._db,t,e),this},subscribeOnce(t,e){return n.subscribeOnce(this._db,t,e),this},unsubscribe(t,e){return n.unsubscribe(this._db,t,e),this},publish(t,e){return n.publish(this._db,t,e),this}}}(),function(){function t(t,e){"string"==typeof e&&function(t,e){Object.prototype.hasOwnProperty.call(t,e)||(t[e]={listeners:[],listenersOnce:[]})}(t,e)}n={subscribe(e,n,i){!function(e,n,i){t(e,n),"string"==typeof n&&"function"==typeof i&&Object.prototype.hasOwnProperty.call(e,n)&&e[n].listeners.push(i)}(e,n,i)},subscribeOnce(e,n,i){!function(e,n,i){t(e,n),"string"==typeof n&&"function"==typeof i&&Object.prototype.hasOwnProperty.call(e,n)&&e[n].listenersOnce.push(i)}(e,n,i)},unsubscribe(t,e,n){!function(t,e,n){let i;"string"==typeof e&&"function"==typeof n&&Object.prototype.hasOwnProperty.call(t,e)&&(i=t[e].listeners.indexOf(n),i>=0&&t[e].listeners.splice(i,1),i=t[e].listenersOnce.indexOf(n),i>=0&&t[e].listenersOnce.splice(i,1))}(t,e,n)},publish(t,e,n){!function(t,e,n){if("string"==typeof e&&Object.prototype.hasOwnProperty.call(t,e)){for(let i=0;i<t[e].listeners.length;i++)t[e].listeners[i](n);for(let i=0;i<t[e].listenersOnce.length;i++)t[e].listenersOnce[i](n);t[e].listenersOnce.splice(0,t[e].listenersOnce.length)}}(t,e,n)}}}(),e})),function(t,e){"function"==typeof define&&define.amd?define([""],e):"object"==typeof exports?(module.exports=e(t),t.Overslash=e(t)):t.Overslash=e(t)}(e.libin,(t=>{let e,n;return n=function(t,e){const n=Object.keys(e);for(let i=0;i<n.length;i++)t[n[i]]=e[n[i]]},function(){const n=t.Overslash;e={_library:{name:"Overslash",version:"1.0.7"},_setTestMode:()=>[],noConflict(){return t.Overslash=n,this},whoami(){return this._library}},e.NAME="Overslash",e.VERSION="1.0.7"}(),n(e,{isUndefined:t=>void 0===t,isNull:t=>null===t,isBoolean:t=>!0===t||!1===t||"[object Boolean]"===Object.prototype.toString.call(t),isString:t=>"[object String]"===Object.prototype.toString.call(t),isNumber:t=>"[object Number]"===Object.prototype.toString.call(t),isNaN(t){return this.isNumber(t)&&t!==+t},isOdd(t){const e=t%2;return t===parseFloat(t)?!!e:void 0}}),n(e,{isObject(t){const e=typeof t;return("function"===e||"object"===e)&&!!t},isLiteralObject:t=>"[object Object]"===Object.prototype.toString.call(t),isFunction:t=>"[object Function]"===Object.prototype.toString.call(t),isArray:t=>"[object Array]"===Object.prototype.toString.call(t),isMath:t=>"[object Math]"===Object.prototype.toString.call(t),isDate:t=>"[object Date]"===Object.prototype.toString.call(t),isEmpty(t){let e;if(null===t)return!0;if(this.isArray(t)||this.isString(t))return 0===t.length;for(e in t)if(t.hasOwnProperty(e))return!1;return!0}}),n(e,{clone(t){const e=this.isArray(t)?[]:{};let n;if(this.isObject(t)){for(n in t)this.isArray(t[n])?e[n]=this.clone(t[n]):this.isObject(t[n])?e[n]=this.extend(t[n]):e[n]=t[n];return e}},extend(t){let e,n;if(!this.isObject(t))return t;for(let i=1;i<arguments.length;i++)for(n in e=arguments[i],e)this.isLiteralObject(arguments[i][n])?(t[n]=void 0!==t[n]?t[n]:{},this.extend(t[n],arguments[i][n])):hasOwnProperty.call(e,n)&&(t[n]=this.isArray(e[n])?this.clone(e[n]):e[n]);return t},keys:t=>Object.keys(t),forPropIn(t,e){this.keys(t).forEach((n=>{({}).hasOwnProperty.call(t,n)&&e(n)}))},assign(){const t=arguments[0];let e,n,i;for(i=1;i<arguments.length;i++)e=arguments[i],n=Object.keys(e).reduce(((t,n)=>(t[n]=Object.getOwnPropertyDescriptor(e,n),t)),{});return Object.defineProperties(t,n),t}}),n(e,{contains:(t,e)=>-1!==t.indexOf(e),flatten(t,e){let n,i=[],s=0;if(this.isArray(t)){if(e)return[].concat.apply([],t);for(n=0;n<t.length;n++)this.isArray(t[n])?(i=i.concat(this.flatten(t[n])),s=i.length):i[s++]=t[n];return i}},max(t){let e,n=null;if(!this.isArray(t))return;const i=this.flatten(t);for(e=0;e<i.length;e++)(null===n||n<i[e])&&(n="number"==typeof i[e]?i[e]:n);return null!==n?n:void 0},min(t){let e,n=null;if(!this.isArray(t))return;const i=this.flatten(t);for(e=0;e<i.length;e++)(null===n||n>i[e])&&(n="number"==typeof i[e]?i[e]:n);return null!==n?n:void 0},share(t){const e=[];let n,i,s;for(i=0;i<t.length;i++)if(n=t[i],!this.contains(e,n)){for(s=1;s<arguments.length&&this.contains(arguments[s],n);s++);s===arguments.length&&e.push(n)}return e},pull(t,...e){const n=Array.isArray(e[0])?e[0]:e,i=[];let s;return n.forEach((e=>{s=t.indexOf(e),s>-1&&i.push(t.splice(s,1)[0])})),i},include:(t,...e)=>(Array.isArray(e[0])?e[0]:e).filter((e=>t.indexOf(e)>-1)),partition:(t,e)=>[t.filter((t=>e(t))),t.filter((t=>!e(t)))]}),n(e,{}),e})),function(){const n=e.src.components.model.main,i=e.src.components.collection.main,s=e.src.components.view.main,r=e.src.components.router.main,l=e.src.components.history.main,o=e.src.components.radio.main,c=e.src.sync.main,u=e.src.utils.util1,a=t.Spine,h={_library:{name:"Spine",version:"0.9.5"},_setTestMode:()=>[],noConflict(){return t.Spine=a,this},whoami(){return this._library},Model:t=>n.Model(t),Collection:t=>i.Collection(t),View:t=>s.View(t),Router:t=>r.Router(t),fetch(...t){return c.fetch(...t),this},urify:(...t)=>u.urify(...t),History:l,Radio:o,NAME:"Spine",VERSION:"0.9.5"};e.src.spine=h}(),function(){const{_:t}=e.src.libs,n=e.src.components.generic.main,i=e.src.utils.util1,s=e.src.components.model.private.fetch,r=e.src.components.model.private.util;let l;l={_init(...t){this.url=this.url||null,this.defaults=this.defaults||{};const[e,n]=t;return this._attributes=this._parse(e,n),this},_parse(t,e){let n=t||{};n=e&&e.parse?this.parse(n):n;for(const t in this.defaults)n[t]||(n[t]=this.defaults[t]);return n},initialize(){return this},listen(){return this},parse:t=>t,get(t){return"string"==typeof t?this._attributes[t]:null},getAll(){return{...this._attributes}},set(...t){return r.set(this,...t)},remove(...t){return r.remove(this,...t)},has(t){return"string"==typeof t&&t in this._attributes},fetch(...t){return s.fetch(this,this.url,...t),this},save(...t){return s.save(this,this.url,...t),this},delete(...t){return s.delete(this,this.url,...t),this},urify:(...t)=>i.urify(...t)},e.extend(e.src.components.model.main,{Model:function(e){let i;const s=function(){return this instanceof s?(n.Construct.apply(this,i),this.initialize.apply(this,i),this.listen.apply(this),this):(i=arguments,new s)},r=t.assign({},n.methods),o=t.assign(r,l);return s.prototype=t.assign(o,e||{}),s.prototype.constructor=s,s}})}(),function(){const{_:t}=e.src.libs,n=e.src.components.generic.main,i=e.src.components.model.main,s=e.src.utils.util1,r=e.src.components.collection.private.util1,l=e.src.components.collection.private.util2,o=e.src.components.collection.private.util3;let c;c={_init(...t){return this._ids=[],this._cids=[],this._models=[],this.url=this.url||null,this.model=this.model||i.Model(),this.add(t[0]),this},initialize(){return this},listen(){return this},get(t){return l.get(this,t)},each(t){for(let e=0;e<this._models.length;e++)t(this._models[e],e);return this},next(t){return l.next(this,t)},previous(t){return l.previous(this,t)},length(){return this._models.length},empty(){return this._ids=[],this._cids=[],this._models=[],this},add(t,e){return r.add(this,t,e)},remove(t,e){return r.remove(this,t,e)},fetch(...t){return r.fetch(this,...t),this},save(...t){return o.save(this,this.url,...t),this},delete(...t){return l.delete(this,...t),this},urify:(...t)=>s.urify(...t)},e.extend(e.src.components.collection.main,{Collection:function(e){let i;const s=function(){return this instanceof s?(n.Construct.apply(this,i),this.initialize.apply(this,i),this.listen.apply(this),this):(i=arguments,new s)},r=t.assign({},n.methods),l=t.assign(r,c);return s.prototype=t.assign(l,e||{}),s.prototype.constructor=s,s}})}(),function(){const{_:t}=e.src.libs,n=e.src.components.generic.main;let i;i={_init(){return this},initialize(){return this},listen(){return this},render(){return this}},e.extend(e.src.components.view.main,{View:function(e){let s;const r=function(){return this instanceof r?(n.Construct.apply(this,s),this.initialize.apply(this,s),this.listen.apply(this),this):(s=arguments,new r)},l=t.assign({},n.methods),o=t.assign(l,i);return r.prototype=t.assign(o,e||{}),r.prototype.constructor=r,r}})}(),function(){const{_:t}=e.src.libs,n=e.src.components.generic.main,i=e.src.components.history.main,s=e.src.components.router.util;let r;r={_init(){return this._trigger=!0,this._replace=!1,this.routes=this.routes||{},s.startListeningHashChange(this),this},initialize(){return this},listen(){return this},execute(t,...e){return t&&t.apply(this,e),this},navigate(t,e){return this._trigger=e&&e.trigger,this._replace=e&&e.replace,location.hash=`#${t}`,this},getLastRoute:()=>i.get(),stop(){return s.stopListeningHashChange(),this}},e.extend(e.src.components.router.main,{Router:function(e){let i;const s=function(){return this instanceof s?(n.Construct.apply(this,i),this.initialize.apply(this,i),this.listen.apply(this),this):(i=arguments,new s)},l=t.assign({},n.methods),o=t.assign(l,r);return s.prototype=t.assign(o,e||{}),s.prototype.constructor=s,s}})}(),function(){const t={_history:null,start(){if(!this._history)return this._history=[],this;throw new Error("Spine.history is already running!")},stop(){return this._history=null,this},isHistoryRunning(){return!!this._history},get(t){if(this._history){let e=-1;return t&&"number"==typeof t&&t<0&&(e=this._history.length+t>=0?t:-this._history.length),this._history[this._history.length+e]}throw new Error("Spine.history is NOT running!")},push(t){if(this._history)return t&&"string"==typeof t&&(this._history.push(t),this._history.length>25&&this._history.shift()),this;throw new Error("Spine.history is NOT running!")},pop(){if(this._history)return this._history.pop();throw new Error("Spine.history is NOT running!")}};e.extend(e.src.components.history.main,t)}(),function(){const{Messenger:t}=e.libin,n={_mess:t(),on(t,e){return this._mess.subscribe(t,e),this},one(t,e){return this._mess.subscribeOnce(t,e),this},off(t,e){return this._mess.unsubscribe(t,e),this},fire(t,e){return this._mess.publish(t,e),this},trigger(t,e){return this.fire(t,e),this}};e.extend(e.src.components.radio.main,n)}(),function(){const t=e.src.sync.fetch,n={fetch(...e){return t.fetch(...e),this}};e.extend(e.src.sync.main,n)}(),function(){const{_:t}=e.src.libs;function n(e,n){return n&&(n.params||n.query)?n.params?`${e}${function(e){if(!t.isLiteralObject(e))return"";let n=e._params;for(const t in e)"_params"!==t&&(n=n.replace(`:${t}`,e[t]));return encodeURI(n)}(n.params)}`:`${e}${function(e){if(!t.isLiteralObject(e))return"";let n="?";for(const t in e)({}).hasOwnProperty.call(e,t)&&e[t]&&(n+=`${t}=${e[t]}&`);return n=encodeURI(n.slice(0,-1)),n}(n.query)}`:e}function i(...e){const[i,s]=function(...e){const[n,i]=e;switch(e.length){case 0:return[null,{}];case 1:return t.isString(n)?[n,{}]:[null,{}];default:return t.isString(n)&&t.isLiteralObject(i)?[n,i]:t.isString(n)?[n,{}]:[null,{}]}}(...e);return i?n(i,{query:s}):null}const s={getUrl:(t,e)=>n(t,e),urify:(...t)=>i(...t)};e.extend(e.src.utils.util1,s)}(),function(){const t=e.libin.Overslash;e.extend(e.src.libs._,t)}(),function(){const{Messenger:t}=e.libin;const n={_ginit(){return this._mess=t(),this},_init(){return this},on(t,e){return this._mess.subscribe(t,e),this},one(t,e){return this._mess.subscribeOnce(t,e),this},off(t,e){return this._mess.unsubscribe(t,e),this},fire(t,e){return this._mess.publish(t,e),this},trigger(t,e){return this.fire(t,e),this}};e.extend(e.src.components.generic.main,{Construct:function(...t){this._ginit(...t),this._init(...t)},methods:n})}(),function(){const{_:t}=e.src.libs,n=e.src.sync.main,i=e.src.utils.util1;function s(...e){const[n,i]=e;switch(e.length){case 0:return[{},null];case 1:return t.isLiteralObject(n)?[n,null]:t.isFunction(n)?[{},n]:[{},null];default:return t.isLiteralObject(n)&&t.isFunction(i)?[n,i]:t.isLiteralObject(n)?[n,null]:t.isFunction(n)?[{},n]:[{},null]}}function r(e,i,...s){const[r,l,o]=function(...e){const[n,i,s]=e;switch(e.length){case 0:return[null,null,null];case 1:return t.isLiteralObject(n)?[n,{},null]:[null,null,null];case 2:return t.isLiteralObject(n)&&t.isLiteralObject(i)?[n,i,null]:t.isLiteralObject(n)&&t.isFunction(i)?[n,{},i]:t.isLiteralObject(n)?[n,{},null]:[null,null,null];default:return t.isLiteralObject(n)&&t.isLiteralObject(i)&&t.isFunction(s)?[n,i,s]:t.isLiteralObject(n)&&t.isLiteralObject(i)?[n,i,null]:t.isLiteralObject(n)&&t.isFunction(i)?[n,{},i]:t.isLiteralObject(n)?[n,{},null]:[null,null,null]}}(...s);if(!r)return;const c={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(r)},u="text"===l.type?"text":"json";n.fetch(i,c,u,((t,n)=>{t?o&&o(t):(l.silent||e.fire("save",n),o&&o(t,n))}))}const l={fetch(t,e,...r){return function(t,e,...r){const[l,o]=s(...r);let c;c=l.params||l.query?i.getUrl(e,l):t._attributes.id?`${e}/${t._attributes.id}`:`${e}/1`;const u="text"===l.type?"text":"json";n.fetch(c,{method:"GET",headers:{Accept:"application/json","Content-Type":"application/json"}},u,((e,n)=>{e?o&&o(e):(t._attributes=t._parse(n,l),l.silent||t.fire("load",t._attributes),o&&o(null,t._attributes))}))}(t,e,...r),this},save(t,e,...n){return r(t,e,...n),this},delete(t,e,...i){return function(t,e,...i){const[r,l]=s(...i),o=t.get("id");if(!o)return void(l&&l(null,"This model has no id. Thus, it does not exist on the server!"));if(!e)return void(l&&l(null,"This model has no url!"));const c="text"===r.type?"text":"json";n.fetch(`${e}/${o}`,{method:"DELETE",headers:{Accept:"application/json","Content-Type":"application/json"}},c,((e,n)=>{e?l&&l(e):(r.silent||t.fire("delete",n),l&&l(e,n))}))}(t,e,...i),this}};e.extend(e.src.components.model.private.fetch,l)}(),function(){const{_:t}=e.src.libs;function n(e,...n){const[i,s]=function(...e){const[n,i]=e;switch(e.length){case 0:return[[],{}];case 1:return t.isString(n)?[[n],{}]:t.isArray(n)?[n,{}]:t.isLiteralObject(n)?[[],n]:[[],{}];default:return t.isString(n)&&t.isLiteralObject(i)?[[n],i]:t.isArray(n)&&t.isLiteralObject(i)?[n,i]:t.isString(n)?[[n],{}]:t.isArray(n)?[n,{}]:t.isLiteralObject(n)?[[],n]:t.isLiteralObject(i)?[[],i]:[[],{}]}}(...n),r=Object.keys(e._attributes),l={};let o;return i.forEach((t=>{r.indexOf(t)>-1&&(o={},o[t]=e._attributes[t],l[t]=o[t],delete e._attributes[t],s.silent||e.fire("remove:prop",o))})),s.silent||e.fire("remove",l),l}function i(e,...n){const[i,s]=function(...e){const[n,i,s]=e,r={};switch(e.length){case 0:return[{},{}];case 1:return t.isLiteralObject(n)?[n,{}]:[{},{}];case 2:return t.isLiteralObject(n)&&t.isLiteralObject(i)?[n,i]:t.isString(n)?(r[n]=i,[r,{}]):[{},{}];default:return t.isString(n)&&t.isLiteralObject(s)?(r[n]=i,[r,s]):t.isString(n)?(r[n]=i,[r,{}]):[{},{}]}}(...n),r={};let l;for(const t in i)({}).hasOwnProperty.call(i,t)&&e._attributes[t]!==i[t]&&(e._attributes[t]=i[t],r[t]=i[t],s.silent||e.fire(`change:${t}`,i[t]),l=!0);return e._attributes.id&&(r.id=e._attributes.id),!s.silent&&l&&e.fire("change",r),e._attributes}const s={set:(t,...e)=>i(t,...e),remove:(t,...e)=>n(t,...e)};e.extend(e.src.components.model.private.util,s)}(),function(){const{_:t}=e.src.libs,n=e.src.sync.main,i=e.src.utils.util1;function s(t,e,n,i){if(-1===n.indexOf(e)&&-1===i.indexOf(e))return null;for(let s=0;s<t.length;s++)if(t[s].cid===e||t[s].get("id")===e){let r=n.indexOf(t[s].cid);return r>-1&&n.splice(r,1),r=i.indexOf(e),r>-1&&i.splice(r,1),t.splice(s,1)[0]}return null}function r(e,...s){const[r,l]=function(...e){const[n,i]=e;switch(e.length){case 0:return[{},null];case 1:return t.isLiteralObject(n)?[n,null]:t.isFunction(n)?[{},n]:[{},null];default:return t.isLiteralObject(n)&&t.isFunction(i)?[n,i]:t.isLiteralObject(n)?[n,null]:t.isFunction(n)?[{},n]:[{},null]}}(...s),o=i.getUrl(e.url,r),c="text"===r.type?"text":"json";n.fetch(o,{method:"GET",headers:{Accept:"application/json","Content-Type":"application/json"}},c,((t,n)=>{if(t)return void(l&&l(t));const i=e.add(n,{silent:!0,parse:r.parse});r.silent||e.fire("load",i),l&&l(null,i)}))}const l={add:(e,n,i)=>function(e,n,i){const s=e._ids,r=e._cids,l=e.model,o=[];let c,u,a,h,f,p,d;c=t.isLiteralObject(n)?[n]:t.isArray(n)?n:[];for(let n=0;n<c.length;n++)if(t.isLiteralObject(c[n]))if(u=l(c[n],{parse:i&&i.parse}),h=u.get("id"),s.includes(h)){d=Object.keys(u.getAll()),f=e.get(u.get("id"));for(let t=0;t<d.length;t++)f._attributes[d[t]]=u._attributes[d[t]];p=t.clone(f),o.push(p),i&&i.silent||e.fire("add",p)}else h&&s.push(h),u.cid=`c${r.length+1}`,r.push(u.cid),e._models.push(u),a=t.clone(u),o.push(a),i&&i.silent||e.fire("add",a);return i&&i.silent||e.fire("addcomplete",o),o}(e,n,i),remove:(e,n,i)=>function(e,n,i){let r;r=t.isLiteralObject(n)||t.isString(n)||t.isNumber(n)?[n]:t.isArray(n)?n:[];const l=[];for(let n=0;n<r.length;n++){let o;t.isLiteralObject(r[n])?o=s(e._models,r[n].cid,e._cids,e._ids):(t.isString(r[n])||t.isNumber(r[n]))&&(o=s(e._models,r[n],e._cids,e._ids)),o&&(l.push(o),i&&i.silent||e.fire("remove",o))}return i&&i.silent||e.fire("removecomplete",l),l}(e,n,i),fetch(t,...e){return r(t,...e),this}};e.extend(e.src.components.collection.private.util1,l)}(),function(){const{_:t}=e.src.libs,n=e.src.sync.main;function i(t,e,n){for(let i=0;i<t._models.length;i++)if(t._models[i].cid===e||t._models[i]._attributes.id===e)return n?i+1>=t._models.length?t._models[0]:t._models[i+1]:i-1<0?t._models[t._models.length-1]:t._models[i-1];return null}function s(e,...i){const[s,r,l]=function(...e){const[n,i,s]=e;switch(e.length){case 0:return[[],{},null];case 1:return t.isArray(n)?[n,{},null]:t.isFunction(n)?[[],{},n]:[[],{},null];case 2:return t.isArray(n)&&t.isLiteralObject(i)?[n,i,null]:t.isArray(n)&&t.isFunction(i)?[n,{},i]:t.isArray(n)?[n,{},null]:[[],{},null];default:return t.isArray(n)&&t.isLiteralObject(i)&&t.isFunction(s)?[n,i,s]:t.isArray(n)&&t.isLiteralObject(i)?[n,i,null]:t.isArray(n)&&t.isFunction(i)?[n,{},i]:t.isArray(n)&&t.isFunction(s)?[n,{},s]:[[],{},null]}}(...i),{url:o}=e;if(0===s.length)return r.silent||e.fire("delete",[]),void(l&&l(null,[]));let c="?ids=";for(let t=0;t<s.length;t++)c+=t<s.length-1?`${s[t]},`:`${s[t]}`;const u="text"===r.type?"text":"json";n.fetch(`${o}${c}`,{method:"DELETE",headers:{Accept:"application/json","Content-Type":"application/json"}},u,((n,i)=>{if(n)return void(l&&l(n));const s=[];t.isLiteralObject(i)&&t.isArray(i.deleted)&&i.deleted.forEach((t=>{s.push(t.id)}));const o=e.remove(s,{silent:!0});r.silent||e.fire("delete",o),l&&l(null,o)}))}const r={get:(t,e,n)=>function(t,e){if(!e)return null;for(let n=0;n<t._models.length;n++)if(t._models[n].cid===e||t._models[n]._attributes.id===e)return t._models[n];return null}(t,e),delete(t,...e){return s(t,...e),this},next:(t,e)=>i(t,e,!0),previous:(t,e)=>i(t,e)};e.extend(e.src.components.collection.private.util2,r)}(),function(){const{_:t}=e.src.libs,n=e.src.sync.main;function i(e,i,...s){const[r,l,o,c]=function(...e){const[n,i,s,r]=e;switch(e.length){case 0:case 1:return[null,null,{},null];case 2:return t.isString(n)&&t.isLiteralObject(i)?[n,i,{},null]:[null,null,{},null];case 3:return t.isString(n)&&t.isLiteralObject(i)&&t.isLiteralObject(s)?[n,i,s,null]:t.isString(n)&&t.isLiteralObject(i)&&t.isFunction(s)?[n,i,{},s]:[n,i,{},null];default:return t.isString(n)&&t.isLiteralObject(i)&&t.isLiteralObject(s)&&t.isFunction(r)?[n,i,s,r]:t.isString(n)&&t.isLiteralObject(i)?[n,i,{},null]:[null,null,{},null]}}(...s),u={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify({where:r,params:l})},a="text"===o.type?"text":"json";n.fetch(i,u,a,((n,i)=>{if(n)c&&c(n);else{if(t.isArray(i)){let t,n;for(let s=0;s<i.length;s++)if(i[s].id&&(t=e.get(i[s].id),t)){n=Object.keys(i[s]);for(let e=0;e<n.length;e++)"id"!==n[e]&&t.set(n[e],i[s][n[e]])}return o.silent||e.fire("save",i),void(c&&c(null,i))}o.silent||e.fire("save",[]),c&&c(null,[])}}))}const s={save(t,e,...n){return i(t,e,...n),this}};e.extend(e.src.components.collection.private.util3,s)}(),function(){const t=e.src.components.history.main;function n(){const e=location.hash.slice(1);let n,i;this.routes[e]?n=e:[n,i]=e.includes("?")?function(t,e){let n=e.slice(0,e.indexOf("?"));if(n="/"===n.slice(-1)?n.slice(0,-1):n,t[n]){const t={};return e.slice(e.indexOf("?")+1).split("&").forEach((e=>{const n=e.split("=");if(2===n.length&&n[0].length>0){let e=n[1];/^\d+$/.test(e)&&(e=parseInt(e,10)),t[n[0]]=e}})),[n,t]}return[null,null]}(this.routes,e):function(t,e){let n,i,s=!1;const r=Object.keys(t);for(let t=0;t<r.length;t++)if(r[t].includes("/:")&&(i=r[t].split("/:"),e.startsWith(`${i[0]}/`))){n=r[t],s=!0;break}if(s){const[t]=i,s={},r=e.slice(t.length+1).split("/");for(let t=1;t<i.length;t++){let e=r[t-1];/^\d+$/.test(e)&&(e=parseInt(e,10)),s[i[t]]=e}return[n,s]}return[null,null]}(this.routes,e),n="string"==typeof n?n:"";const s=this[this.routes[n]];if("function"!=typeof s)throw new Error(`Spine.Router: this direction "${s}" does not match a function!`);t.isHistoryRunning()&&!this._replace&&t.push(e),this._replace=!1,this._trigger?this.execute(s,i,n,e):this._trigger=!0}const i={startListeningHashChange(t){return this._route=n.bind(t),window.addEventListener("hashchange",this._route),window.addEventListener("load",this._route),this},stopListeningHashChange(){return window.removeEventListener("hashchange",this._route),window.removeEventListener("load",this._route),this}};e.extend(e.src.components.router.util,i)}(),function(){function t(t,e,n,i){!function(t,e,n){let i;fetch(t,e).then((t=>t.ok?t.text():(i=t.status,Promise.reject(t)))).then((t=>{n(null,t)})).catch((t=>{t.text().then((t=>{n(t||{status:i,message:"none!",statusText:"none!"})}))}))}(t,e,((t,e)=>{if(t&&"json"===n){let e;try{e=JSON.parse(t),e.statusText=e.message}catch(n){e={status:"40x",message:t,statusText:t}}i(e)}else if(t)i(t);else if("json"!==n)i(null,e);else{let t;try{t=JSON.parse(e)}catch(n){t=e}i(null,t)}}))}const n={fetch(...e){const[n,i,s,r]=function(...t){const[e,n,i,s]=t;switch(t.length){case 0:return[null,null,null,null];case 1:return"string"==typeof e?[e,{},null,null]:[null,null,null,null];case 2:return"string"==typeof e?"object"==typeof n&&n.method?[e,n,null,null]:"string"==typeof n?[e,{},n,null]:"function"==typeof n?[e,{},null,n]:[e,{},null,null]:[null,null,null,null];case 3:return"string"==typeof e?"object"==typeof n&&n.method?"string"==typeof i?[e,n,i,null]:"function"==typeof i?[e,n,null,i]:[e,n,null,null]:"string"==typeof n?"function"==typeof i?[e,{},n,i]:[e,{},n,null]:"function"==typeof i?[e,{},null,i]:[e,{},null,null]:[null,null,null,null];case 4:return"string"==typeof e&&"object"==typeof n&&n.method&&"string"==typeof i&&"function"==typeof s?[e,n,i,s]:"string"==typeof e&&"object"==typeof n&&n.method&&"string"==typeof i?[e,n,i,null]:[null,null,null,null];default:return"string"==typeof e&&"object"==typeof n&&n.method&&"string"==typeof i&&"function"==typeof s?[e,n,i,s]:[null,null,null,null]}}(...e);return t(n,i,s||"json",((t,e)=>{r&&r(t,e)})),this}};e.extend(e.src.sync.fetch,n)}(),e.src.spine})); | ||
/*! Generated by Kadoo v1.0.7 */ | ||
!function(t,e){"use strict";"function"==typeof define&&define.amd?define([""],e):"object"==typeof exports?module.exports=e(t):t.Spine=e(t)}(this,(t=>{"use strict";let e={src:{spine:{},components:{model:{main:{},private:{fetch:{},util:{}}},collection:{main:{},private:{util1:{},util2:{},util3:{}}},view:{main:{}},router:{main:{},util:{}},history:{main:{}},radio:{main:{}},generic:{main:{}}},sync:{main:{},fetch:{}},utils:{util1:{}},libs:{_:{}}},libin:{}};return e.extend=function(t,e){for(var n=Object.keys(e),i=0;i<n.length;i++)t[n[i]]=e[n[i]]},function(t,e){"function"==typeof define&&define.amd?define([""],e):"object"==typeof exports?(module.exports=e(t),t.Messenger=e(t)):t.Messenger=e(t)}(e.libin,(t=>{let e,n;return function(){const i=t.Messenger;let s;e=function(){const t=Object.create(s);return t._library={name:"Messenger",version:"1.0.3"},t._db={},t},e.NAME="Messenger",e.VERSION="1.0.3",e._setTestMode=function(){return[]},e.noConflict=function(){return t.Messenger=i,this},s={whoami(){return this._library},subscribe(t,e){return n.subscribe(this._db,t,e),this},subscribeOnce(t,e){return n.subscribeOnce(this._db,t,e),this},unsubscribe(t,e){return n.unsubscribe(this._db,t,e),this},publish(t,e){return n.publish(this._db,t,e),this}}}(),function(){function t(t,e){"string"==typeof e&&function(t,e){Object.prototype.hasOwnProperty.call(t,e)||(t[e]={listeners:[],listenersOnce:[]})}(t,e)}n={subscribe(e,n,i){!function(e,n,i){t(e,n),"string"==typeof n&&"function"==typeof i&&Object.prototype.hasOwnProperty.call(e,n)&&e[n].listeners.push(i)}(e,n,i)},subscribeOnce(e,n,i){!function(e,n,i){t(e,n),"string"==typeof n&&"function"==typeof i&&Object.prototype.hasOwnProperty.call(e,n)&&e[n].listenersOnce.push(i)}(e,n,i)},unsubscribe(t,e,n){!function(t,e,n){let i;"string"==typeof e&&"function"==typeof n&&Object.prototype.hasOwnProperty.call(t,e)&&(i=t[e].listeners.indexOf(n),i>=0&&t[e].listeners.splice(i,1),i=t[e].listenersOnce.indexOf(n),i>=0&&t[e].listenersOnce.splice(i,1))}(t,e,n)},publish(t,e,n){!function(t,e,n){if("string"==typeof e&&Object.prototype.hasOwnProperty.call(t,e)){for(let i=0;i<t[e].listeners.length;i++)t[e].listeners[i](n);for(let i=0;i<t[e].listenersOnce.length;i++)t[e].listenersOnce[i](n);t[e].listenersOnce.splice(0,t[e].listenersOnce.length)}}(t,e,n)}}}(),e})),function(t,e){"function"==typeof define&&define.amd?define([""],e):"object"==typeof exports?(module.exports=e(t),t.Overslash=e(t)):t.Overslash=e(t)}(e.libin,(t=>{let e,n;return n=function(t,e){const n=Object.keys(e);for(let i=0;i<n.length;i++)t[n[i]]=e[n[i]]},function(){const n=t.Overslash;e={_library:{name:"Overslash",version:"1.0.7"},_setTestMode:()=>[],noConflict(){return t.Overslash=n,this},whoami(){return this._library}},e.NAME="Overslash",e.VERSION="1.0.7"}(),n(e,{isUndefined:t=>void 0===t,isNull:t=>null===t,isBoolean:t=>!0===t||!1===t||"[object Boolean]"===Object.prototype.toString.call(t),isString:t=>"[object String]"===Object.prototype.toString.call(t),isNumber:t=>"[object Number]"===Object.prototype.toString.call(t),isNaN(t){return this.isNumber(t)&&t!==+t},isOdd(t){const e=t%2;return t===parseFloat(t)?!!e:void 0}}),n(e,{isObject(t){const e=typeof t;return("function"===e||"object"===e)&&!!t},isLiteralObject:t=>"[object Object]"===Object.prototype.toString.call(t),isFunction:t=>"[object Function]"===Object.prototype.toString.call(t),isArray:t=>"[object Array]"===Object.prototype.toString.call(t),isMath:t=>"[object Math]"===Object.prototype.toString.call(t),isDate:t=>"[object Date]"===Object.prototype.toString.call(t),isEmpty(t){let e;if(null===t)return!0;if(this.isArray(t)||this.isString(t))return 0===t.length;for(e in t)if(t.hasOwnProperty(e))return!1;return!0}}),n(e,{clone(t){const e=this.isArray(t)?[]:{};let n;if(this.isObject(t)){for(n in t)this.isArray(t[n])?e[n]=this.clone(t[n]):this.isObject(t[n])?e[n]=this.extend(t[n]):e[n]=t[n];return e}},extend(t){let e,n;if(!this.isObject(t))return t;for(let i=1;i<arguments.length;i++)for(n in e=arguments[i],e)this.isLiteralObject(arguments[i][n])?(t[n]=void 0!==t[n]?t[n]:{},this.extend(t[n],arguments[i][n])):hasOwnProperty.call(e,n)&&(t[n]=this.isArray(e[n])?this.clone(e[n]):e[n]);return t},keys:t=>Object.keys(t),forPropIn(t,e){this.keys(t).forEach((n=>{({}).hasOwnProperty.call(t,n)&&e(n)}))},assign(){const t=arguments[0];let e,n,i;for(i=1;i<arguments.length;i++)e=arguments[i],n=Object.keys(e).reduce(((t,n)=>(t[n]=Object.getOwnPropertyDescriptor(e,n),t)),{});return Object.defineProperties(t,n),t}}),n(e,{contains:(t,e)=>-1!==t.indexOf(e),flatten(t,e){let n,i=[],s=0;if(this.isArray(t)){if(e)return[].concat.apply([],t);for(n=0;n<t.length;n++)this.isArray(t[n])?(i=i.concat(this.flatten(t[n])),s=i.length):i[s++]=t[n];return i}},max(t){let e,n=null;if(!this.isArray(t))return;const i=this.flatten(t);for(e=0;e<i.length;e++)(null===n||n<i[e])&&(n="number"==typeof i[e]?i[e]:n);return null!==n?n:void 0},min(t){let e,n=null;if(!this.isArray(t))return;const i=this.flatten(t);for(e=0;e<i.length;e++)(null===n||n>i[e])&&(n="number"==typeof i[e]?i[e]:n);return null!==n?n:void 0},share(t){const e=[];let n,i,s;for(i=0;i<t.length;i++)if(n=t[i],!this.contains(e,n)){for(s=1;s<arguments.length&&this.contains(arguments[s],n);s++);s===arguments.length&&e.push(n)}return e},pull(t,...e){const n=Array.isArray(e[0])?e[0]:e,i=[];let s;return n.forEach((e=>{s=t.indexOf(e),s>-1&&i.push(t.splice(s,1)[0])})),i},include:(t,...e)=>(Array.isArray(e[0])?e[0]:e).filter((e=>t.indexOf(e)>-1)),partition:(t,e)=>[t.filter((t=>e(t))),t.filter((t=>!e(t)))]}),n(e,{}),e})),function(){const n=e.src.components.model.main,i=e.src.components.collection.main,s=e.src.components.view.main,r=e.src.components.router.main,l=e.src.components.history.main,o=e.src.components.radio.main,c=e.src.sync.main,u=e.src.utils.util1,a=t.Spine,h={_library:{name:"Spine",version:"1.0.0"},_setTestMode:()=>[],noConflict(){return t.Spine=a,this},whoami(){return this._library},Model:t=>n.Model(t),Collection:t=>i.Collection(t),View:t=>s.View(t),Router:t=>r.Router(t),fetch(...t){return c.fetch(...t),this},urify:(...t)=>u.urify(...t),History:l,Radio:o,NAME:"Spine",VERSION:"1.0.0"};e.src.spine=h}(),function(){const{_:t}=e.src.libs,n=e.src.components.generic.main,i=e.src.utils.util1,s=e.src.components.model.private.fetch,r=e.src.components.model.private.util;let l;l={_init(...t){this.url=this.url||null,this.defaults=this.defaults||{};const[e,n]=t;return this._attributes=this._parse(e,n),this},_parse(t,e){let n=t||{};n=e&&e.parse?this.parse(n):n;for(const t in this.defaults)n[t]||(n[t]=this.defaults[t]);return n},initialize(){return this},listen(){return this},parse:t=>t,get(t){return"string"==typeof t?this._attributes[t]:null},getAll(){return{...this._attributes}},set(...t){return r.set(this,...t)},remove(...t){return r.remove(this,...t)},has(t){return"string"==typeof t&&t in this._attributes},fetch(...t){return s.fetch(this,this.url,...t),this},save(...t){return s.save(this,this.url,...t),this},delete(...t){return s.delete(this,this.url,...t),this},urify:(...t)=>i.urify(...t)},e.extend(e.src.components.model.main,{Model:function(e){let i;const s=function(){return this instanceof s?(n.Construct.apply(this,i),this.initialize.apply(this,i),this.listen.apply(this),this):(i=arguments,new s)},r=t.assign({},n.methods),o=t.assign(r,l);return s.prototype=t.assign(o,e||{}),s.prototype.constructor=s,s}})}(),function(){const{_:t}=e.src.libs,n=e.src.components.generic.main,i=e.src.components.model.main,s=e.src.utils.util1,r=e.src.components.collection.private.util1,l=e.src.components.collection.private.util2,o=e.src.components.collection.private.util3;let c;c={_init(...t){return this._ids=[],this._cids=[],this._models=[],this.url=this.url||null,this.model=this.model||i.Model(),this.add(t[0]),this},initialize(){return this},listen(){return this},get(t){return l.get(this,t)},each(t){for(let e=0;e<this._models.length;e++)t(this._models[e],e);return this},next(t){return l.next(this,t)},previous(t){return l.previous(this,t)},length(){return this._models.length},empty(){return this._ids=[],this._cids=[],this._models=[],this},add(t,e){return r.add(this,t,e)},remove(t,e){return r.remove(this,t,e)},fetch(...t){return r.fetch(this,...t),this},save(...t){return o.save(this,this.url,...t),this},delete(...t){return l.delete(this,...t),this},urify:(...t)=>s.urify(...t)},e.extend(e.src.components.collection.main,{Collection:function(e){let i;const s=function(){return this instanceof s?(n.Construct.apply(this,i),this.initialize.apply(this,i),this.listen.apply(this),this):(i=arguments,new s)},r=t.assign({},n.methods),l=t.assign(r,c);return s.prototype=t.assign(l,e||{}),s.prototype.constructor=s,s}})}(),function(){const{_:t}=e.src.libs,n=e.src.components.generic.main;let i;i={_init(){return this},initialize(){return this},listen(){return this},render(){return this}},e.extend(e.src.components.view.main,{View:function(e){let s;const r=function(){return this instanceof r?(n.Construct.apply(this,s),this.initialize.apply(this,s),this.listen.apply(this),this):(s=arguments,new r)},l=t.assign({},n.methods),o=t.assign(l,i);return r.prototype=t.assign(o,e||{}),r.prototype.constructor=r,r}})}(),function(){const{_:t}=e.src.libs,n=e.src.components.generic.main,i=e.src.components.history.main,s=e.src.components.router.util;let r;r={_init(){return this._trigger=!0,this._replace=!1,this.routes=this.routes||{},s.startListeningHashChange(this),this},initialize(){return this},listen(){return this},execute(t,...e){return t&&t.apply(this,e),this},navigate(t,e){return this._trigger=e&&e.trigger,this._replace=e&&e.replace,location.hash=`#${t}`,this},getLastRoute:()=>i.get(),stop(){return s.stopListeningHashChange(),this}},e.extend(e.src.components.router.main,{Router:function(e){let i;const s=function(){return this instanceof s?(n.Construct.apply(this,i),this.initialize.apply(this,i),this.listen.apply(this),this):(i=arguments,new s)},l=t.assign({},n.methods),o=t.assign(l,r);return s.prototype=t.assign(o,e||{}),s.prototype.constructor=s,s}})}(),function(){const t={_history:null,start(){if(!this._history)return this._history=[],this;throw new Error("Spine.history is already running!")},stop(){return this._history=null,this},isHistoryRunning(){return!!this._history},get(t){if(this._history){let e=-1;return t&&"number"==typeof t&&t<0&&(e=this._history.length+t>=0?t:-this._history.length),this._history[this._history.length+e]}throw new Error("Spine.history is NOT running!")},push(t){if(this._history)return t&&"string"==typeof t&&(this._history.push(t),this._history.length>25&&this._history.shift()),this;throw new Error("Spine.history is NOT running!")},pop(){if(this._history)return this._history.pop();throw new Error("Spine.history is NOT running!")}};e.extend(e.src.components.history.main,t)}(),function(){const{Messenger:t}=e.libin,n={_mess:t(),on(t,e){return this._mess.subscribe(t,e),this},one(t,e){return this._mess.subscribeOnce(t,e),this},off(t,e){return this._mess.unsubscribe(t,e),this},fire(t,e){return this._mess.publish(t,e),this},trigger(t,e){return this.fire(t,e),this}};e.extend(e.src.components.radio.main,n)}(),function(){const t=e.src.sync.fetch,n={fetch(...e){return t.fetch(...e),this}};e.extend(e.src.sync.main,n)}(),function(){const{_:t}=e.src.libs;function n(e,n){return n&&(n.params||n.query)?n.params?`${e}${function(e){if(!t.isLiteralObject(e))return"";let n=e._params;for(const t in e)"_params"!==t&&(n=n.replace(`:${t}`,e[t]));return encodeURI(n)}(n.params)}`:`${e}${function(e){if(!t.isLiteralObject(e))return"";let n="?";for(const t in e)({}).hasOwnProperty.call(e,t)&&e[t]&&(n+=`${t}=${e[t]}&`);return n=encodeURI(n.slice(0,-1)),n}(n.query)}`:e}function i(...e){const[i,s]=function(...e){const[n,i]=e;switch(e.length){case 0:return[null,{}];case 1:return t.isString(n)?[n,{}]:[null,{}];default:return t.isString(n)&&t.isLiteralObject(i)?[n,i]:t.isString(n)?[n,{}]:[null,{}]}}(...e);return i?n(i,{query:s}):null}const s={getUrl:(t,e)=>n(t,e),urify:(...t)=>i(...t)};e.extend(e.src.utils.util1,s)}(),function(){const t=e.libin.Overslash;e.extend(e.src.libs._,t)}(),function(){const{Messenger:t}=e.libin;const n={_ginit(){return this._mess=t(),this},_init(){return this},on(t,e){return this._mess.subscribe(t,e),this},one(t,e){return this._mess.subscribeOnce(t,e),this},off(t,e){return this._mess.unsubscribe(t,e),this},fire(t,e){return this._mess.publish(t,e),this},trigger(t,e){return this.fire(t,e),this}};e.extend(e.src.components.generic.main,{Construct:function(...t){this._ginit(...t),this._init(...t)},methods:n})}(),function(){const{_:t}=e.src.libs,n=e.src.sync.main,i=e.src.utils.util1;function s(...e){const[n,i]=e;switch(e.length){case 0:return[{},null];case 1:return t.isLiteralObject(n)?[n,null]:t.isFunction(n)?[{},n]:[{},null];default:return t.isLiteralObject(n)&&t.isFunction(i)?[n,i]:t.isLiteralObject(n)?[n,null]:t.isFunction(n)?[{},n]:[{},null]}}function r(e,i,...s){const[r,l,o]=function(...e){const[n,i,s]=e;switch(e.length){case 0:return[null,null,null];case 1:return t.isLiteralObject(n)?[n,{},null]:[null,null,null];case 2:return t.isLiteralObject(n)&&t.isLiteralObject(i)?[n,i,null]:t.isLiteralObject(n)&&t.isFunction(i)?[n,{},i]:t.isLiteralObject(n)?[n,{},null]:[null,null,null];default:return t.isLiteralObject(n)&&t.isLiteralObject(i)&&t.isFunction(s)?[n,i,s]:t.isLiteralObject(n)&&t.isLiteralObject(i)?[n,i,null]:t.isLiteralObject(n)&&t.isFunction(i)?[n,{},i]:t.isLiteralObject(n)?[n,{},null]:[null,null,null]}}(...s);if(!r)return;const c={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(r)},u="text"===l.type?"text":"json";n.fetch(i,c,u,((t,n)=>{t?o&&o(t):(l.silent||e.fire("save",n),o&&o(t,n))}))}const l={fetch(t,e,...r){return function(t,e,...r){const[l,o]=s(...r);let c;c=l.params||l.query?i.getUrl(e,l):t._attributes.id?`${e}/${t._attributes.id}`:`${e}/1`;const u="text"===l.type?"text":"json";n.fetch(c,{method:"GET",headers:{Accept:"application/json","Content-Type":"application/json"}},u,((e,n)=>{e?o&&o(e):(t._attributes=t._parse(n,l),l.silent||t.fire("load",t._attributes),o&&o(null,t._attributes))}))}(t,e,...r),this},save(t,e,...n){return r(t,e,...n),this},delete(t,e,...i){return function(t,e,...i){const[r,l]=s(...i),o=t.get("id");if(!o)return void(l&&l(null,"This model has no id. Thus, it does not exist on the server!"));if(!e)return void(l&&l(null,"This model has no url!"));const c="text"===r.type?"text":"json";n.fetch(`${e}/${o}`,{method:"DELETE",headers:{Accept:"application/json","Content-Type":"application/json"}},c,((e,n)=>{e?l&&l(e):(r.silent||t.fire("delete",n),l&&l(e,n))}))}(t,e,...i),this}};e.extend(e.src.components.model.private.fetch,l)}(),function(){const{_:t}=e.src.libs;function n(e,...n){const[i,s]=function(...e){const[n,i]=e;switch(e.length){case 0:return[[],{}];case 1:return t.isString(n)?[[n],{}]:t.isArray(n)?[n,{}]:t.isLiteralObject(n)?[[],n]:[[],{}];default:return t.isString(n)&&t.isLiteralObject(i)?[[n],i]:t.isArray(n)&&t.isLiteralObject(i)?[n,i]:t.isString(n)?[[n],{}]:t.isArray(n)?[n,{}]:t.isLiteralObject(n)?[[],n]:t.isLiteralObject(i)?[[],i]:[[],{}]}}(...n),r=Object.keys(e._attributes),l={};let o;return i.forEach((t=>{r.indexOf(t)>-1&&(o={},o[t]=e._attributes[t],l[t]=o[t],delete e._attributes[t],s.silent||e.fire("remove:prop",o))})),s.silent||e.fire("remove",l),l}function i(e,...n){const[i,s]=function(...e){const[n,i,s]=e,r={};switch(e.length){case 0:return[{},{}];case 1:return t.isLiteralObject(n)?[n,{}]:[{},{}];case 2:return t.isLiteralObject(n)&&t.isLiteralObject(i)?[n,i]:t.isString(n)?(r[n]=i,[r,{}]):[{},{}];default:return t.isString(n)&&t.isLiteralObject(s)?(r[n]=i,[r,s]):t.isString(n)?(r[n]=i,[r,{}]):[{},{}]}}(...n),r={};let l;for(const t in i)({}).hasOwnProperty.call(i,t)&&e._attributes[t]!==i[t]&&(e._attributes[t]=i[t],r[t]=i[t],s.silent||e.fire(`change:${t}`,i[t]),l=!0);return e._attributes.id&&(r.id=e._attributes.id),!s.silent&&l&&e.fire("change",r),e._attributes}const s={set:(t,...e)=>i(t,...e),remove:(t,...e)=>n(t,...e)};e.extend(e.src.components.model.private.util,s)}(),function(){const{_:t}=e.src.libs,n=e.src.sync.main,i=e.src.utils.util1;function s(t,e,n,i){if(-1===n.indexOf(e)&&-1===i.indexOf(e))return null;for(let s=0;s<t.length;s++)if(t[s].cid===e||t[s].get("id")===e){let r=n.indexOf(t[s].cid);return r>-1&&n.splice(r,1),r=i.indexOf(e),r>-1&&i.splice(r,1),t.splice(s,1)[0]}return null}function r(e,...s){const[r,l]=function(...e){const[n,i]=e;switch(e.length){case 0:return[{},null];case 1:return t.isLiteralObject(n)?[n,null]:t.isFunction(n)?[{},n]:[{},null];default:return t.isLiteralObject(n)&&t.isFunction(i)?[n,i]:t.isLiteralObject(n)?[n,null]:t.isFunction(n)?[{},n]:[{},null]}}(...s),o=i.getUrl(e.url,r),c="text"===r.type?"text":"json";n.fetch(o,{method:"GET",headers:{Accept:"application/json","Content-Type":"application/json"}},c,((t,n)=>{if(t)return void(l&&l(t));const i=e.add(n,{silent:!0,parse:r.parse});r.silent||e.fire("load",i),l&&l(null,i)}))}const l={add:(e,n,i)=>function(e,n,i){const s=e._ids,r=e._cids,l=e.model,o=[];let c,u,a,h,f,p,d;c=t.isLiteralObject(n)?[n]:t.isArray(n)?n:[];for(let n=0;n<c.length;n++)if(t.isLiteralObject(c[n]))if(u=l(c[n],{parse:i&&i.parse}),h=u.get("id"),s.includes(h)){d=Object.keys(u.getAll()),f=e.get(u.get("id"));for(let t=0;t<d.length;t++)f._attributes[d[t]]=u._attributes[d[t]];p=t.clone(f),o.push(p),i&&i.silent||e.fire("add",p)}else h&&s.push(h),u.cid=`c${r.length+1}`,r.push(u.cid),e._models.push(u),a=t.clone(u),o.push(a),i&&i.silent||e.fire("add",a);return i&&i.silent||e.fire("addcomplete",o),o}(e,n,i),remove:(e,n,i)=>function(e,n,i){let r;r=t.isLiteralObject(n)||t.isString(n)||t.isNumber(n)?[n]:t.isArray(n)?n:[];const l=[];for(let n=0;n<r.length;n++){let o;t.isLiteralObject(r[n])?o=s(e._models,r[n].cid,e._cids,e._ids):(t.isString(r[n])||t.isNumber(r[n]))&&(o=s(e._models,r[n],e._cids,e._ids)),o&&(l.push(o),i&&i.silent||e.fire("remove",o))}return i&&i.silent||e.fire("removecomplete",l),l}(e,n,i),fetch(t,...e){return r(t,...e),this}};e.extend(e.src.components.collection.private.util1,l)}(),function(){const{_:t}=e.src.libs,n=e.src.sync.main;function i(t,e,n){for(let i=0;i<t._models.length;i++)if(t._models[i].cid===e||t._models[i]._attributes.id===e)return n?i+1>=t._models.length?t._models[0]:t._models[i+1]:i-1<0?t._models[t._models.length-1]:t._models[i-1];return null}function s(e,...i){const[s,r,l]=function(...e){const[n,i,s]=e;switch(e.length){case 0:return[[],{},null];case 1:return t.isArray(n)?[n,{},null]:t.isFunction(n)?[[],{},n]:[[],{},null];case 2:return t.isArray(n)&&t.isLiteralObject(i)?[n,i,null]:t.isArray(n)&&t.isFunction(i)?[n,{},i]:t.isArray(n)?[n,{},null]:[[],{},null];default:return t.isArray(n)&&t.isLiteralObject(i)&&t.isFunction(s)?[n,i,s]:t.isArray(n)&&t.isLiteralObject(i)?[n,i,null]:t.isArray(n)&&t.isFunction(i)?[n,{},i]:t.isArray(n)&&t.isFunction(s)?[n,{},s]:[[],{},null]}}(...i),{url:o}=e;if(0===s.length)return r.silent||e.fire("delete",[]),void(l&&l(null,[]));let c="?ids=";for(let t=0;t<s.length;t++)c+=t<s.length-1?`${s[t]},`:`${s[t]}`;const u="text"===r.type?"text":"json";n.fetch(`${o}${c}`,{method:"DELETE",headers:{Accept:"application/json","Content-Type":"application/json"}},u,((n,i)=>{if(n)return void(l&&l(n));const s=[];t.isLiteralObject(i)&&t.isArray(i.deleted)&&i.deleted.forEach((t=>{s.push(t.id)}));const o=e.remove(s,{silent:!0});r.silent||e.fire("delete",o),l&&l(null,o)}))}const r={get:(t,e,n)=>function(t,e){if(!e)return null;for(let n=0;n<t._models.length;n++)if(t._models[n].cid===e||t._models[n]._attributes.id===e)return t._models[n];return null}(t,e),delete(t,...e){return s(t,...e),this},next:(t,e)=>i(t,e,!0),previous:(t,e)=>i(t,e)};e.extend(e.src.components.collection.private.util2,r)}(),function(){const{_:t}=e.src.libs,n=e.src.sync.main;function i(e,i,...s){const[r,l,o,c]=function(...e){const[n,i,s,r]=e;switch(e.length){case 0:case 1:return[null,null,{},null];case 2:return t.isString(n)&&t.isLiteralObject(i)?[n,i,{},null]:[null,null,{},null];case 3:return t.isString(n)&&t.isLiteralObject(i)&&t.isLiteralObject(s)?[n,i,s,null]:t.isString(n)&&t.isLiteralObject(i)&&t.isFunction(s)?[n,i,{},s]:[n,i,{},null];default:return t.isString(n)&&t.isLiteralObject(i)&&t.isLiteralObject(s)&&t.isFunction(r)?[n,i,s,r]:t.isString(n)&&t.isLiteralObject(i)?[n,i,{},null]:[null,null,{},null]}}(...s),u={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify({where:r,params:l})},a="text"===o.type?"text":"json";n.fetch(i,u,a,((n,i)=>{if(n)c&&c(n);else{if(t.isArray(i)){let t,n;for(let s=0;s<i.length;s++)if(i[s].id&&(t=e.get(i[s].id),t)){n=Object.keys(i[s]);for(let e=0;e<n.length;e++)"id"!==n[e]&&t.set(n[e],i[s][n[e]])}return o.silent||e.fire("save",i),void(c&&c(null,i))}o.silent||e.fire("save",[]),c&&c(null,[])}}))}const s={save(t,e,...n){return i(t,e,...n),this}};e.extend(e.src.components.collection.private.util3,s)}(),function(){const t=e.src.components.history.main;function n(){const e=location.hash.slice(1);let n,i;this.routes[e]?n=e:[n,i]=e.includes("?")?function(t,e){let n=e.slice(0,e.indexOf("?"));if(n="/"===n.slice(-1)?n.slice(0,-1):n,t[n]){const t={};return e.slice(e.indexOf("?")+1).split("&").forEach((e=>{const n=e.split("=");if(2===n.length&&n[0].length>0){let e=n[1];/^\d+$/.test(e)&&(e=parseInt(e,10)),t[n[0]]=e}})),[n,t]}return[null,null]}(this.routes,e):function(t,e){let n,i,s=!1;const r=Object.keys(t);for(let t=0;t<r.length;t++)if(r[t].includes("/:")&&(i=r[t].split("/:"),e.startsWith(`${i[0]}/`))){n=r[t],s=!0;break}if(s){const[t]=i,s={},r=e.slice(t.length+1).split("/");for(let t=1;t<i.length;t++){let e=r[t-1];/^\d+$/.test(e)&&(e=parseInt(e,10)),s[i[t]]=e}return[n,s]}return[null,null]}(this.routes,e),n="string"==typeof n?n:"";const s=this[this.routes[n]];if("function"!=typeof s)throw new Error(`Spine.Router: this direction "${s}" does not match a function!`);t.isHistoryRunning()&&!this._replace&&t.push(e),this._replace=!1,this._trigger?this.execute(s,i,n,e):this._trigger=!0}const i={startListeningHashChange(t){return this._route=n.bind(t),window.addEventListener("hashchange",this._route),window.addEventListener("load",this._route),this},stopListeningHashChange(){return window.removeEventListener("hashchange",this._route),window.removeEventListener("load",this._route),this}};e.extend(e.src.components.router.util,i)}(),function(){function t(t,e,n,i){!function(t,e,n){let i;fetch(t,e).then((t=>t.ok?t.text():(i=t.status,Promise.reject(t)))).then((t=>{n(null,t)})).catch((t=>{t.text().then((t=>{n(t||{status:i,message:"none!",statusText:"none!"})}))}))}(t,e,((t,e)=>{if(t&&"json"===n){let e;try{e=JSON.parse(t),e.statusText=e.message}catch(n){e={status:"40x",message:t,statusText:t}}i(e)}else if(t)i(t);else if("json"!==n)i(null,e);else{let t;try{t=JSON.parse(e)}catch(n){t=e}i(null,t)}}))}const n={fetch(...e){const[n,i,s,r]=function(...t){const[e,n,i,s]=t;switch(t.length){case 0:return[null,null,null,null];case 1:return"string"==typeof e?[e,{},null,null]:[null,null,null,null];case 2:return"string"==typeof e?"object"==typeof n&&n.method?[e,n,null,null]:"string"==typeof n?[e,{},n,null]:"function"==typeof n?[e,{},null,n]:[e,{},null,null]:[null,null,null,null];case 3:return"string"==typeof e?"object"==typeof n&&n.method?"string"==typeof i?[e,n,i,null]:"function"==typeof i?[e,n,null,i]:[e,n,null,null]:"string"==typeof n?"function"==typeof i?[e,{},n,i]:[e,{},n,null]:"function"==typeof i?[e,{},null,i]:[e,{},null,null]:[null,null,null,null];case 4:return"string"==typeof e&&"object"==typeof n&&n.method&&"string"==typeof i&&"function"==typeof s?[e,n,i,s]:"string"==typeof e&&"object"==typeof n&&n.method&&"string"==typeof i?[e,n,i,null]:[null,null,null,null];default:return"string"==typeof e&&"object"==typeof n&&n.method&&"string"==typeof i&&"function"==typeof s?[e,n,i,s]:[null,null,null,null]}}(...e);return t(n,i,s||"json",((t,e)=>{r&&r(t,e)})),this}};e.extend(e.src.sync.fetch,n)}(),e.src.spine})); |
{ | ||
"name": "@mobilabs/spine", | ||
"version": "0.9.5", | ||
"version": "1.0.0", | ||
"description": "A tiny MVC framework inspired from Backbone.js", | ||
@@ -11,15 +11,47 @@ "main": "_dist/lib/spine.js", | ||
"scripts": { | ||
"build": "gulp build", | ||
"watch": "gulp watch", | ||
"dev": "gulp rundev", | ||
"apiserver": "node test/scripts/apiserver.js", | ||
"general": " --- GENERAL ---", | ||
"build:js": " --- JAVASCRIPT --- ", | ||
"build:js:dev": "node tasks/build.js.dev.js $1", | ||
"build:js:prod": "node tasks/build.js.prod.js $1", | ||
"build:css": " --- CSS --- ", | ||
"build:generic": " --- BUILD (GENERIC) --- ", | ||
"build:development": " --- BUILD (DEVELOPMENT) --- ", | ||
"build:dev": "npm run build:js:dev", | ||
"build:production": " --- BUILD (PRODUCTION) --- ", | ||
"build:skeleton:prod": "node tasks/build.skeleton.prod.js $1", | ||
"prebuild:prod": "npm run build:dev && npm run build:skeleton:prod", | ||
"build:prod": "npm run build:js:prod", | ||
"testing": " --- TESTING --- ", | ||
"test": "cross-env NODE_ENV=test nyc --reporter=lcov mocha --require esm ./test/main.js", | ||
"display-coverage": "opener ./coverage/lcov-report/index.html", | ||
"check-coverage": "nyc check-coverage --statements 70 --branches 60 --functions 80 --lines 70", | ||
"report-coverage": "nyc report --reporter=text-lcov | coveralls", | ||
"display:coverage": "open -a safari ./coverage/lcov-report/index.html", | ||
"check:coverage": "nyc check-coverage --statements 70 --branches 60 --functions 80 --lines 70", | ||
"report:coverage": "nyc report --reporter=text-lcov | coveralls", | ||
"report": "nyc report", | ||
"makedist": "gulp makedist", | ||
"app": "gulp runapp", | ||
"prepare": "husky install", | ||
"doc": "" | ||
"serving": " --- SERVING --- ", | ||
"server:api": "node test/scripts/apiserver.js", | ||
"server:dev": "http-server --port 8080", | ||
"server:prod": "http-server --port 8090", | ||
"watch:js:css": " --- WATCHING --- ", | ||
"watch:js": "nodemon --watch './src/**/*.js' --exec npm run build:dev", | ||
"watch": "npm run watch:js", | ||
"deployment": " --- DEPLOYMENT --- ", | ||
"dep:prod": "rm -rf _dist-$npm_package_version && npm run build:prod && cp -r _dist _dist-$npm_package_version", | ||
"doc:kasar": " --- DOC ---", | ||
"doc:create": "", | ||
"doc:build": "kasar build", | ||
"doc:watch": "kasar watch", | ||
"doc:run": "kasar serve --port $1", | ||
"others": " --- OTHERS ---", | ||
"prepare": "husky install" | ||
}, | ||
@@ -48,29 +80,23 @@ "repository": { | ||
"devDependencies": { | ||
"body-parser": "^1.20.0", | ||
"chai": "^4.3.6", | ||
"@mobilabs/kasar": "^2.3.1", | ||
"chai": "^4.3.7", | ||
"cookie-parser": "^1.4.6", | ||
"coveralls": "^3.1.1", | ||
"cross-env": "^7.0.3", | ||
"del": "^6.1.1", | ||
"eslint": "^7.32.0", | ||
"eslint": "^8.41.0", | ||
"eslint-config-airbnb-base": "^15.0.0", | ||
"eslint-plugin-import": "^2.26.0", | ||
"eslint-plugin-import": "^2.27.5", | ||
"esm": "^3.2.25", | ||
"express": "^4.18.1", | ||
"express": "^4.18.2", | ||
"express-session": "^1.17.3", | ||
"gulp": "^4.0.2", | ||
"gulp-concat": "^2.6.1", | ||
"gulp-connect": "^5.7.0", | ||
"gulp-header": "^2.0.9", | ||
"gulp-replace": "^1.1.3", | ||
"gulp-uglify-es": "^3.0.0", | ||
"husky": "^8.0.1", | ||
"jsdom": "^20.0.0", | ||
"kadoo": "^1.0.6", | ||
"http-server": "^14.1.1", | ||
"husky": "^8.0.3", | ||
"jsdom": "^22.1.0", | ||
"kadoo": "^1.0.7", | ||
"mocha": "^8.4.0", | ||
"node-fetch": "^2.6.7", | ||
"node-fetch": "^2.7.0", | ||
"nodemon": "^2.0.22", | ||
"nyc": "^15.1.0", | ||
"open": "^8.4.0", | ||
"opener": "^1.5.2", | ||
"@mobilabs/es6kadoo": "1.0.10" | ||
"terser": "^5.17.4", | ||
"@mobilabs/es6kadoo": "1.1.1" | ||
}, | ||
@@ -77,0 +103,0 @@ "publishConfig": { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
438531
21
0