From 3f09cbb1a5d2d2a19c58ef11b63f99f67e5e65bf Mon Sep 17 00:00:00 2001 From: Marshall Thompson Date: Tue, 20 Dec 2016 17:07:25 -0700 Subject: [PATCH] 1.0.21 --- dist/amd/all.js | 22 + dist/amd/all.js.map | 1 + dist/amd/base/base.js | 31 + dist/amd/base/base.js.map | 1 + dist/amd/cache-requests/cache-requests.js | 84 + dist/amd/cache-requests/cache-requests.js.map | 1 + dist/amd/can-connect.js | 9 + dist/amd/can-connect.js.map | 1 + dist/amd/can/base-map/base-map.js | 34 + dist/amd/can/base-map/base-map.js.map | 1 + dist/amd/can/map/map.js | 301 ++ dist/amd/can/map/map.js.map | 1 + dist/amd/can/ref/ref.js | 131 + dist/amd/can/ref/ref.js.map | 1 + dist/amd/can/super-map/super-map.js | 48 + dist/amd/can/super-map/super-map.js.map | 1 + dist/amd/can/tag/tag.js | 84 + dist/amd/can/tag/tag.js.map | 1 + dist/amd/connect.js | 83 + dist/amd/connect.js.map | 1 + .../callbacks-once/callbacks-once.js | 27 + .../callbacks-once/callbacks-once.js.map | 1 + dist/amd/constructor/constructor.js | 131 + dist/amd/constructor/constructor.js.map | 1 + dist/amd/constructor/store/store.js | 182 ++ dist/amd/constructor/store/store.js.map | 1 + .../data/callbacks-cache/callbacks-cache.js | 22 + .../callbacks-cache/callbacks-cache.js.map | 1 + dist/amd/data/callbacks/callbacks.js | 28 + dist/amd/data/callbacks/callbacks.js.map | 1 + .../data/combine-requests/combine-requests.js | 105 + .../combine-requests/combine-requests.js.map | 1 + .../localstorage-cache/localstorage-cache.js | 260 ++ .../localstorage-cache.js.map | 1 + dist/amd/data/memory-cache/memory-cache.js | 217 ++ .../amd/data/memory-cache/memory-cache.js.map | 1 + dist/amd/data/parse/parse.js | 59 + dist/amd/data/parse/parse.js.map | 1 + dist/amd/data/url/url.js | 101 + dist/amd/data/url/url.js.map | 1 + .../fall-through-cache/fall-through-cache.js | 98 + .../fall-through-cache.js.map | 1 + dist/amd/helpers/clone-data.js | 9 + dist/amd/helpers/clone-data.js.map | 1 + dist/amd/helpers/deferred.js | 12 + dist/amd/helpers/deferred.js.map | 1 + dist/amd/helpers/get-id-props.js | 19 + dist/amd/helpers/get-id-props.js.map | 1 + dist/amd/helpers/get-index-by-id.js | 14 + dist/amd/helpers/get-index-by-id.js.map | 1 + dist/amd/helpers/get-items.js | 12 + dist/amd/helpers/get-items.js.map | 1 + dist/amd/helpers/id-merge.js | 41 + dist/amd/helpers/id-merge.js.map | 1 + dist/amd/helpers/overwrite.js | 15 + dist/amd/helpers/overwrite.js.map | 1 + dist/amd/helpers/set-add.js | 14 + dist/amd/helpers/set-add.js.map | 1 + dist/amd/helpers/sorted-set-json.js | 17 + dist/amd/helpers/sorted-set-json.js.map | 1 + dist/amd/helpers/weak-reference-map.js | 45 + dist/amd/helpers/weak-reference-map.js.map | 1 + dist/amd/real-time/real-time.js | 143 + dist/amd/real-time/real-time.js.map | 1 + dist/cjs/all.js | 20 + dist/cjs/all.js.map | 1 + dist/cjs/base/base.js | 29 + dist/cjs/base/base.js.map | 1 + dist/cjs/cache-requests/cache-requests.js | 82 + dist/cjs/cache-requests/cache-requests.js.map | 1 + dist/cjs/can-connect.js | 7 + dist/cjs/can-connect.js.map | 1 + dist/cjs/can/base-map/base-map.js | 32 + dist/cjs/can/base-map/base-map.js.map | 1 + dist/cjs/can/map/map.js | 299 ++ dist/cjs/can/map/map.js.map | 1 + dist/cjs/can/ref/ref.js | 129 + dist/cjs/can/ref/ref.js.map | 1 + dist/cjs/can/super-map/super-map.js | 46 + dist/cjs/can/super-map/super-map.js.map | 1 + dist/cjs/can/tag/tag.js | 82 + dist/cjs/can/tag/tag.js.map | 1 + dist/cjs/connect.js | 81 + dist/cjs/connect.js.map | 1 + .../callbacks-once/callbacks-once.js | 25 + .../callbacks-once/callbacks-once.js.map | 1 + dist/cjs/constructor/constructor.js | 129 + dist/cjs/constructor/constructor.js.map | 1 + dist/cjs/constructor/store/store.js | 180 ++ dist/cjs/constructor/store/store.js.map | 1 + .../data/callbacks-cache/callbacks-cache.js | 20 + .../callbacks-cache/callbacks-cache.js.map | 1 + dist/cjs/data/callbacks/callbacks.js | 26 + dist/cjs/data/callbacks/callbacks.js.map | 1 + .../data/combine-requests/combine-requests.js | 103 + .../combine-requests/combine-requests.js.map | 1 + .../localstorage-cache/localstorage-cache.js | 258 ++ .../localstorage-cache.js.map | 1 + dist/cjs/data/memory-cache/memory-cache.js | 215 ++ .../cjs/data/memory-cache/memory-cache.js.map | 1 + dist/cjs/data/parse/parse.js | 57 + dist/cjs/data/parse/parse.js.map | 1 + dist/cjs/data/url/url.js | 99 + dist/cjs/data/url/url.js.map | 1 + .../fall-through-cache/fall-through-cache.js | 96 + .../fall-through-cache.js.map | 1 + dist/cjs/helpers/clone-data.js | 7 + dist/cjs/helpers/clone-data.js.map | 1 + dist/cjs/helpers/deferred.js | 10 + dist/cjs/helpers/deferred.js.map | 1 + dist/cjs/helpers/get-id-props.js | 17 + dist/cjs/helpers/get-id-props.js.map | 1 + dist/cjs/helpers/get-index-by-id.js | 12 + dist/cjs/helpers/get-index-by-id.js.map | 1 + dist/cjs/helpers/get-items.js | 10 + dist/cjs/helpers/get-items.js.map | 1 + dist/cjs/helpers/id-merge.js | 39 + dist/cjs/helpers/id-merge.js.map | 1 + dist/cjs/helpers/overwrite.js | 13 + dist/cjs/helpers/overwrite.js.map | 1 + dist/cjs/helpers/set-add.js | 12 + dist/cjs/helpers/set-add.js.map | 1 + dist/cjs/helpers/sorted-set-json.js | 15 + dist/cjs/helpers/sorted-set-json.js.map | 1 + dist/cjs/helpers/weak-reference-map.js | 43 + dist/cjs/helpers/weak-reference-map.js.map | 1 + dist/cjs/real-time/real-time.js | 141 + dist/cjs/real-time/real-time.js.map | 1 + dist/global/can-connect.js | 2482 +++++++++++++++++ dist/global/can-connect.js.map | 1 + 130 files changed, 7279 insertions(+) create mode 100644 dist/amd/all.js create mode 100644 dist/amd/all.js.map create mode 100644 dist/amd/base/base.js create mode 100644 dist/amd/base/base.js.map create mode 100644 dist/amd/cache-requests/cache-requests.js create mode 100644 dist/amd/cache-requests/cache-requests.js.map create mode 100644 dist/amd/can-connect.js create mode 100644 dist/amd/can-connect.js.map create mode 100644 dist/amd/can/base-map/base-map.js create mode 100644 dist/amd/can/base-map/base-map.js.map create mode 100644 dist/amd/can/map/map.js create mode 100644 dist/amd/can/map/map.js.map create mode 100644 dist/amd/can/ref/ref.js create mode 100644 dist/amd/can/ref/ref.js.map create mode 100644 dist/amd/can/super-map/super-map.js create mode 100644 dist/amd/can/super-map/super-map.js.map create mode 100644 dist/amd/can/tag/tag.js create mode 100644 dist/amd/can/tag/tag.js.map create mode 100644 dist/amd/connect.js create mode 100644 dist/amd/connect.js.map create mode 100644 dist/amd/constructor/callbacks-once/callbacks-once.js create mode 100644 dist/amd/constructor/callbacks-once/callbacks-once.js.map create mode 100644 dist/amd/constructor/constructor.js create mode 100644 dist/amd/constructor/constructor.js.map create mode 100644 dist/amd/constructor/store/store.js create mode 100644 dist/amd/constructor/store/store.js.map create mode 100644 dist/amd/data/callbacks-cache/callbacks-cache.js create mode 100644 dist/amd/data/callbacks-cache/callbacks-cache.js.map create mode 100644 dist/amd/data/callbacks/callbacks.js create mode 100644 dist/amd/data/callbacks/callbacks.js.map create mode 100644 dist/amd/data/combine-requests/combine-requests.js create mode 100644 dist/amd/data/combine-requests/combine-requests.js.map create mode 100644 dist/amd/data/localstorage-cache/localstorage-cache.js create mode 100644 dist/amd/data/localstorage-cache/localstorage-cache.js.map create mode 100644 dist/amd/data/memory-cache/memory-cache.js create mode 100644 dist/amd/data/memory-cache/memory-cache.js.map create mode 100644 dist/amd/data/parse/parse.js create mode 100644 dist/amd/data/parse/parse.js.map create mode 100644 dist/amd/data/url/url.js create mode 100644 dist/amd/data/url/url.js.map create mode 100644 dist/amd/fall-through-cache/fall-through-cache.js create mode 100644 dist/amd/fall-through-cache/fall-through-cache.js.map create mode 100644 dist/amd/helpers/clone-data.js create mode 100644 dist/amd/helpers/clone-data.js.map create mode 100644 dist/amd/helpers/deferred.js create mode 100644 dist/amd/helpers/deferred.js.map create mode 100644 dist/amd/helpers/get-id-props.js create mode 100644 dist/amd/helpers/get-id-props.js.map create mode 100644 dist/amd/helpers/get-index-by-id.js create mode 100644 dist/amd/helpers/get-index-by-id.js.map create mode 100644 dist/amd/helpers/get-items.js create mode 100644 dist/amd/helpers/get-items.js.map create mode 100644 dist/amd/helpers/id-merge.js create mode 100644 dist/amd/helpers/id-merge.js.map create mode 100644 dist/amd/helpers/overwrite.js create mode 100644 dist/amd/helpers/overwrite.js.map create mode 100644 dist/amd/helpers/set-add.js create mode 100644 dist/amd/helpers/set-add.js.map create mode 100644 dist/amd/helpers/sorted-set-json.js create mode 100644 dist/amd/helpers/sorted-set-json.js.map create mode 100644 dist/amd/helpers/weak-reference-map.js create mode 100644 dist/amd/helpers/weak-reference-map.js.map create mode 100644 dist/amd/real-time/real-time.js create mode 100644 dist/amd/real-time/real-time.js.map create mode 100644 dist/cjs/all.js create mode 100644 dist/cjs/all.js.map create mode 100644 dist/cjs/base/base.js create mode 100644 dist/cjs/base/base.js.map create mode 100644 dist/cjs/cache-requests/cache-requests.js create mode 100644 dist/cjs/cache-requests/cache-requests.js.map create mode 100644 dist/cjs/can-connect.js create mode 100644 dist/cjs/can-connect.js.map create mode 100644 dist/cjs/can/base-map/base-map.js create mode 100644 dist/cjs/can/base-map/base-map.js.map create mode 100644 dist/cjs/can/map/map.js create mode 100644 dist/cjs/can/map/map.js.map create mode 100644 dist/cjs/can/ref/ref.js create mode 100644 dist/cjs/can/ref/ref.js.map create mode 100644 dist/cjs/can/super-map/super-map.js create mode 100644 dist/cjs/can/super-map/super-map.js.map create mode 100644 dist/cjs/can/tag/tag.js create mode 100644 dist/cjs/can/tag/tag.js.map create mode 100644 dist/cjs/connect.js create mode 100644 dist/cjs/connect.js.map create mode 100644 dist/cjs/constructor/callbacks-once/callbacks-once.js create mode 100644 dist/cjs/constructor/callbacks-once/callbacks-once.js.map create mode 100644 dist/cjs/constructor/constructor.js create mode 100644 dist/cjs/constructor/constructor.js.map create mode 100644 dist/cjs/constructor/store/store.js create mode 100644 dist/cjs/constructor/store/store.js.map create mode 100644 dist/cjs/data/callbacks-cache/callbacks-cache.js create mode 100644 dist/cjs/data/callbacks-cache/callbacks-cache.js.map create mode 100644 dist/cjs/data/callbacks/callbacks.js create mode 100644 dist/cjs/data/callbacks/callbacks.js.map create mode 100644 dist/cjs/data/combine-requests/combine-requests.js create mode 100644 dist/cjs/data/combine-requests/combine-requests.js.map create mode 100644 dist/cjs/data/localstorage-cache/localstorage-cache.js create mode 100644 dist/cjs/data/localstorage-cache/localstorage-cache.js.map create mode 100644 dist/cjs/data/memory-cache/memory-cache.js create mode 100644 dist/cjs/data/memory-cache/memory-cache.js.map create mode 100644 dist/cjs/data/parse/parse.js create mode 100644 dist/cjs/data/parse/parse.js.map create mode 100644 dist/cjs/data/url/url.js create mode 100644 dist/cjs/data/url/url.js.map create mode 100644 dist/cjs/fall-through-cache/fall-through-cache.js create mode 100644 dist/cjs/fall-through-cache/fall-through-cache.js.map create mode 100644 dist/cjs/helpers/clone-data.js create mode 100644 dist/cjs/helpers/clone-data.js.map create mode 100644 dist/cjs/helpers/deferred.js create mode 100644 dist/cjs/helpers/deferred.js.map create mode 100644 dist/cjs/helpers/get-id-props.js create mode 100644 dist/cjs/helpers/get-id-props.js.map create mode 100644 dist/cjs/helpers/get-index-by-id.js create mode 100644 dist/cjs/helpers/get-index-by-id.js.map create mode 100644 dist/cjs/helpers/get-items.js create mode 100644 dist/cjs/helpers/get-items.js.map create mode 100644 dist/cjs/helpers/id-merge.js create mode 100644 dist/cjs/helpers/id-merge.js.map create mode 100644 dist/cjs/helpers/overwrite.js create mode 100644 dist/cjs/helpers/overwrite.js.map create mode 100644 dist/cjs/helpers/set-add.js create mode 100644 dist/cjs/helpers/set-add.js.map create mode 100644 dist/cjs/helpers/sorted-set-json.js create mode 100644 dist/cjs/helpers/sorted-set-json.js.map create mode 100644 dist/cjs/helpers/weak-reference-map.js create mode 100644 dist/cjs/helpers/weak-reference-map.js.map create mode 100644 dist/cjs/real-time/real-time.js create mode 100644 dist/cjs/real-time/real-time.js.map create mode 100644 dist/global/can-connect.js create mode 100644 dist/global/can-connect.js.map diff --git a/dist/amd/all.js b/dist/amd/all.js new file mode 100644 index 00000000..56bea26e --- /dev/null +++ b/dist/amd/all.js @@ -0,0 +1,22 @@ +/*can-connect@1.0.20#all*/ +define(function (require, exports, module) { + var connect = require('./can-connect'); + connect.cacheRequests = require('./cache-requests/cache-requests'); + connect.constructor = require('./constructor/constructor'); + connect.constructorCallbacksOnce = require('./constructor/callbacks-once/callbacks-once'); + connect.constructorStore = require('./constructor/store/store'); + connect.dataCallbacks = require('./data/callbacks/callbacks'); + connect.dataCallbacksCache = require('./data/callbacks-cache/callbacks-cache'); + connect.dataCombineRequests = require('./data/combine-requests/combine-requests'); + connect.dataLocalStorageCache = require('./data/localstorage-cache/localstorage-cache'); + connect.dataMemoryCache = require('./data/memory-cache/memory-cache'); + connect.dataParse = require('./data/parse/parse'); + connect.dataUrl = require('./data/url/url'); + connect.fallThroughCache = require('./fall-through-cache/fall-through-cache'); + connect.realTime = require('./real-time/real-time'); + connect.superMap = require('./can/super-map/super-map'); + connect.tag = require('./can/tag/tag'); + connect.baseMap = require('./can/base-map/base-map'); + module.exports = connect; +}); +//# sourceMappingURL=all.js.map \ No newline at end of file diff --git a/dist/amd/all.js.map b/dist/amd/all.js.map new file mode 100644 index 00000000..42ba12e0 --- /dev/null +++ b/dist/amd/all.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../all.js"],"names":["connect","require","cacheRequests","constructor","constructorCallbacksOnce","constructorStore","dataCallbacks","dataCallbacksCache","dataCombineRequests","dataLocalStorageCache","dataMemoryCache","dataParse","dataUrl","fallThroughCache","realTime","superMap","tag","baseMap","module","exports"],"mappings":";;IAAA,IAAIA,OAAA,GAAUC,OAAA,CAAQ,eAAR,CAAd,C;IAEAD,OAAA,CAAQE,aAAR,GAAwBD,OAAA,CAAQ,iCAAR,CAAxB,C;IAEAD,OAAA,CAAQG,WAAR,GAAsBF,OAAA,CAAQ,2BAAR,CAAtB,C;IACAD,OAAA,CAAQI,wBAAR,GAAmCH,OAAA,CAAQ,6CAAR,CAAnC,C;IACAD,OAAA,CAAQK,gBAAR,GAA2BJ,OAAA,CAAQ,2BAAR,CAA3B,C;IACAD,OAAA,CAAQM,aAAR,GAAwBL,OAAA,CAAQ,4BAAR,CAAxB,C;IACAD,OAAA,CAAQO,kBAAR,GAA6BN,OAAA,CAAQ,wCAAR,CAA7B,C;IACAD,OAAA,CAAQQ,mBAAR,GAA8BP,OAAA,CAAQ,0CAAR,CAA9B,C;IACAD,OAAA,CAAQS,qBAAR,GAAgCR,OAAA,CAAQ,8CAAR,CAAhC,C;IACAD,OAAA,CAAQU,eAAR,GAA0BT,OAAA,CAAQ,kCAAR,CAA1B,C;IACAD,OAAA,CAAQW,SAAR,GAAoBV,OAAA,CAAQ,oBAAR,CAApB,C;IACAD,OAAA,CAAQY,OAAR,GAAkBX,OAAA,CAAQ,gBAAR,CAAlB,C;IACAD,OAAA,CAAQa,gBAAR,GAA2BZ,OAAA,CAAQ,yCAAR,CAA3B,C;IACAD,OAAA,CAAQc,QAAR,GAAmBb,OAAA,CAAQ,uBAAR,CAAnB,C;IAEAD,OAAA,CAAQe,QAAR,GAAmBd,OAAA,CAAQ,2BAAR,CAAnB,C;IACAD,OAAA,CAAQgB,GAAR,GAAcf,OAAA,CAAQ,eAAR,CAAd,C;IACAD,OAAA,CAAQiB,OAAR,GAAkBhB,OAAA,CAAQ,yBAAR,CAAlB,C;IAEAiB,MAAA,CAAOC,OAAP,GAAiBnB,OAAjB,C","file":"all.js"} \ No newline at end of file diff --git a/dist/amd/base/base.js b/dist/amd/base/base.js new file mode 100644 index 00000000..902d4b08 --- /dev/null +++ b/dist/amd/base/base.js @@ -0,0 +1,31 @@ +/*can-connect@1.0.20#base/base*/ +define(function (require, exports, module) { + var connect = require('../connect'); + module.exports = connect.behavior('base', function (baseConnection) { + return { + id: function (instance) { + var ids = [], algebra = this.algebra; + if (algebra && algebra.clauses && algebra.clauses.id) { + for (var prop in algebra.clauses.id) { + ids.push(instance[prop]); + } + } + if (this.idProp && !ids.length) { + ids.push(instance[this.idProp]); + } + if (!ids.length) { + ids.push(instance.id); + } + return ids.length > 1 ? ids.join('@|@') : ids[0]; + }, + idProp: baseConnection.idProp || 'id', + listSet: function (list) { + return list[this.listSetProp]; + }, + listSetProp: '__listSet', + init: function () { + } + }; + }); +}); +//# sourceMappingURL=base.js.map \ No newline at end of file diff --git a/dist/amd/base/base.js.map b/dist/amd/base/base.js.map new file mode 100644 index 00000000..d3d789f0 --- /dev/null +++ b/dist/amd/base/base.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../base/base.js"],"names":["connect","require","module","exports","behavior","baseConnection","id","instance","ids","algebra","clauses","prop","push","idProp","length","join","listSet","list","listSetProp","init"],"mappings":";;IAAA,IAAIA,OAAA,GAAUC,OAAA,CAAQ,YAAR,CAAd,C;IAyBAC,MAAA,CAAOC,OAAP,GAAiBH,OAAA,CAAQI,QAAR,CAAiB,MAAjB,EAAwB,UAASC,cAAT,EAAwB;AAAA,QAChE,OAAO;AAAA,YAwDNC,EAAA,EAAI,UAASC,QAAT,EAAkB;AAAA,gBACrB,IAAIC,GAAA,GAAM,EAAV,EACCC,OAAA,GAAU,KAAKA,OADhB,CADqB;AAAA,gBAIrB,IAAGA,OAAA,IAAWA,OAAA,CAAQC,OAAnB,IAA8BD,OAAA,CAAQC,OAAR,CAAgBJ,EAAjD,EAAqD;AAAA,oBACpD,SAAQK,IAAR,IAAgBF,OAAA,CAAQC,OAAR,CAAgBJ,EAAhC,EAAoC;AAAA,wBACnCE,GAAA,CAAII,IAAJ,CAASL,QAAA,CAASI,IAAT,CAAT,EADmC;AAAA,qBADgB;AAAA,iBAJhC;AAAA,gBAUrB,IAAG,KAAKE,MAAL,IAAe,CAACL,GAAA,CAAIM,MAAvB,EAA+B;AAAA,oBAC9BN,GAAA,CAAII,IAAJ,CAASL,QAAA,CAAS,KAAKM,MAAd,CAAT,EAD8B;AAAA,iBAVV;AAAA,gBAarB,IAAG,CAACL,GAAA,CAAIM,MAAR,EAAgB;AAAA,oBACfN,GAAA,CAAII,IAAJ,CAASL,QAAA,CAASD,EAAlB,EADe;AAAA,iBAbK;AAAA,gBAmBrB,OAAOE,GAAA,CAAIM,MAAJ,GAAa,CAAb,GAAiBN,GAAA,CAAIO,IAAJ,CAAS,KAAT,CAAjB,GAAkCP,GAAA,CAAI,CAAJ,CAAzC,CAnBqB;AAAA,aAxDhB;AAAA,YAsGNK,MAAA,EAAQR,cAAA,CAAeQ,MAAf,IAAyB,IAtG3B;AAAA,YA0ING,OAAA,EAAS,UAASC,IAAT,EAAc;AAAA,gBACtB,OAAOA,IAAA,CAAK,KAAKC,WAAV,CAAP,CADsB;AAAA,aA1IjB;AAAA,YAwKNA,WAAA,EAAa,WAxKP;AAAA,YAyKNC,IAAA,EAAM,YAAU;AAAA,aAzKV;AAAA,SAAP,CADgE;AAAA,KAAhD,CAAjB,C","file":"base.js"} \ No newline at end of file diff --git a/dist/amd/cache-requests/cache-requests.js b/dist/amd/cache-requests/cache-requests.js new file mode 100644 index 00000000..dbb0df41 --- /dev/null +++ b/dist/amd/cache-requests/cache-requests.js @@ -0,0 +1,84 @@ +/*can-connect@1.0.20#cache-requests/cache-requests*/ +define(function (require, exports, module) { + var connect = require('../can-connect'); + var getItems = require('../helpers/get-items'); + var canSet = require('can-set'); + var forEach = [].forEach; + module.exports = connect.behavior('cache-requests', function (baseConnection) { + return { + getDiff: function (params, availableSets) { + var minSets, self = this; + forEach.call(availableSets, function (set) { + var curSets; + var difference = canSet.difference(params, set, self.algebra); + if (typeof difference === 'object') { + curSets = { + needed: difference, + cached: canSet.intersection(params, set, self.algebra), + count: canSet.count(difference, self.algebra) + }; + } else if (canSet.subset(params, set, self.algebra)) { + curSets = { + cached: params, + count: 0 + }; + } + if (curSets) { + if (!minSets || curSets.count < minSets.count) { + minSets = curSets; + } + } + }); + if (!minSets) { + return { needed: params }; + } else { + return { + needed: minSets.needed, + cached: minSets.cached + }; + } + }, + getUnion: function (params, diff, neededItems, cachedItems) { + return { data: canSet.getUnion(diff.needed, diff.cached, getItems(neededItems), getItems(cachedItems), this.algebra) }; + }, + getListData: function (set) { + set = set || {}; + var self = this; + return this.cacheConnection.getSets(set).then(function (sets) { + var diff = self.getDiff(set, sets); + if (!diff.needed) { + return self.cacheConnection.getListData(diff.cached); + } else if (!diff.cached) { + return baseConnection.getListData(diff.needed).then(function (data) { + return self.cacheConnection.updateListData(getItems(data), diff.needed).then(function () { + return data; + }); + }); + } else { + var cachedPromise = self.cacheConnection.getListData(diff.cached); + var needsPromise = baseConnection.getListData(diff.needed); + var savedPromise = needsPromise.then(function (data) { + return self.cacheConnection.updateListData(getItems(data), diff.needed).then(function () { + return data; + }); + }); + var combinedPromise = Promise.all([ + cachedPromise, + needsPromise + ]).then(function (result) { + var cached = result[0], needed = result[1]; + return self.getUnion(set, diff, needed, cached); + }); + return Promise.all([ + combinedPromise, + savedPromise + ]).then(function (data) { + return data[0]; + }); + } + }); + } + }; + }); +}); +//# sourceMappingURL=cache-requests.js.map \ No newline at end of file diff --git a/dist/amd/cache-requests/cache-requests.js.map b/dist/amd/cache-requests/cache-requests.js.map new file mode 100644 index 00000000..4eac5efe --- /dev/null +++ b/dist/amd/cache-requests/cache-requests.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../cache-requests/cache-requests.js"],"names":["connect","require","getItems","canSet","forEach","module","exports","behavior","baseConnection","getDiff","params","availableSets","minSets","self","call","set","curSets","difference","algebra","needed","cached","intersection","count","subset","getUnion","diff","neededItems","cachedItems","data","getListData","cacheConnection","getSets","then","sets","updateListData","cachedPromise","needsPromise","savedPromise","combinedPromise","Promise","all","result"],"mappings":";;IACA,IAAIA,OAAA,GAAUC,OAAA,CAAQ,gBAAR,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CAAO,CAAP,CAAb,EACCtB,MAAA,GAASsB,MAAA,CAAO,CAAP,CADV,CADuB;AAAA,4BAGvB,OAAO5B,IAAA,CAAKW,QAAL,CAAeT,GAAf,EAAoBU,IAApB,EAA0BN,MAA1B,EAAkCC,MAAlC,CAAP,CAHuB;AAAA,yBAHF,CAAtB,CAVM;AAAA,wBAmBN,OAAOmB,OAAA,CAAQC,GAAR,CAAY;AAAA,4BAACF,eAAD;AAAA,4BAAkBD,YAAlB;AAAA,yBAAZ,EAA6CL,IAA7C,CAAkD,UAASJ,IAAT,EAAc;AAAA,4BACtE,OAAOA,IAAA,CAAK,CAAL,CAAP,CADsE;AAAA,yBAAhE,CAAP,CAnBM;AAAA,qBAdoD;AAAA,iBAArD,CAAP,CAJyB;AAAA,aAxHpB;AAAA,SAAP,CAF0E;AAAA,KAA1D,CAAjB,C","file":"cache-requests.js"} \ No newline at end of file diff --git a/dist/amd/can-connect.js b/dist/amd/can-connect.js new file mode 100644 index 00000000..fdc4bae4 --- /dev/null +++ b/dist/amd/can-connect.js @@ -0,0 +1,9 @@ +/*can-connect@1.0.20#can-connect*/ +define(function (require, exports, module) { + var connect = require('./connect'); + var base = require('./base/base'); + var ns = require('can-namespace'); + connect.base = base; + module.exports = ns.connect = connect; +}); +//# sourceMappingURL=can-connect.js.map \ No newline at end of file diff --git a/dist/amd/can-connect.js.map b/dist/amd/can-connect.js.map new file mode 100644 index 00000000..63ff6d4d --- /dev/null +++ b/dist/amd/can-connect.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../can-connect.js"],"names":["connect","require","base","ns","module","exports"],"mappings":";;IAAA,IAAIA,OAAA,GAAUC,OAAA,CAAQ,WAAR,CAAd,C;IACA,IAAIC,IAAA,GAAOD,OAAA,CAAQ,aAAR,CAAX,C;IACA,IAAIE,EAAA,GAAKF,OAAA,CAAQ,eAAR,CAAT,C;IAEAD,OAAA,CAAQE,IAAR,GAAeA,IAAf,C;IAEAE,MAAA,CAAOC,OAAP,GAAiBF,EAAA,CAAGH,OAAH,GAAaA,OAA9B,C","file":"can-connect.js"} \ No newline at end of file diff --git a/dist/amd/can/base-map/base-map.js b/dist/amd/can/base-map/base-map.js new file mode 100644 index 00000000..d1154a3f --- /dev/null +++ b/dist/amd/can/base-map/base-map.js @@ -0,0 +1,34 @@ +/*can-connect@1.0.20#can/base-map/base-map*/ +define(function (require, exports, module) { + var connect = require('../../can-connect'); + var constructor = require('../../constructor/constructor'); + var canMap = require('../map/map'); + var canRef = require('../ref/ref'); + var constructorStore = require('../../constructor/store/store'); + var dataCallbacks = require('../../data/callbacks/callbacks'); + var callbacksCache = require('../../data/callbacks-cache/callbacks-cache'); + var dataParse = require('../../data/parse/parse'); + var dataUrl = require('../../data/url/url'); + var realTime = require('../../real-time/real-time'); + var callbacksOnce = require('../../constructor/callbacks-once/callbacks-once'); + var $ = require('jquery'); + connect.baseMap = function (options) { + var behaviors = [ + constructor, + canMap, + canRef, + constructorStore, + dataCallbacks, + dataParse, + dataUrl, + realTime, + callbacksOnce + ]; + if ($ && $.ajax) { + options.ajax = $.ajax; + } + return connect(behaviors, options); + }; + module.exports = connect.baseMap; +}); +//# sourceMappingURL=base-map.js.map \ No newline at end of file diff --git a/dist/amd/can/base-map/base-map.js.map b/dist/amd/can/base-map/base-map.js.map new file mode 100644 index 00000000..ad717e7a --- /dev/null +++ b/dist/amd/can/base-map/base-map.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../../can/base-map/base-map.js"],"names":["connect","require","constructor","canMap","canRef","constructorStore","dataCallbacks","callbacksCache","dataParse","dataUrl","realTime","callbacksOnce","$","baseMap","options","behaviors","ajax","module","exports"],"mappings":";;IAAA,IAAIA,OAAA,GAAUC,OAAA,CAAQ,mBAAR,CAAd,C;IAEA,IAAIC,WAAA,GAAcD,OAAA,CAAQ,+BAAR,CAAlB,C;IACA,IAAIE,MAAA,GAASF,OAAA,CAAQ,YAAR,CAAb,C;IACA,IAAIG,MAAA,GAASH,OAAA,CAAQ,YAAR,CAAb,C;IACA,IAAII,gBAAA,GAAmBJ,OAAA,CAAQ,+BAAR,CAAvB,C;IACA,IAAIK,aAAA,GAAgBL,OAAA,CAAQ,gCAAR,CAApB,C;IACA,IAAIM,cAAA,GAAiBN,OAAA,CAAQ,4CAAR,CAArB,C;IACA,IAAIO,SAAA,GAAYP,OAAA,CAAQ,wBAAR,CAAhB,C;IACA,IAAIQ,OAAA,GAAUR,OAAA,CAAQ,oBAAR,CAAd,C;IACA,IAAIS,QAAA,GAAWT,OAAA,CAAQ,2BAAR,CAAf,C;IACA,IAAIU,aAAA,GAAgBV,OAAA,CAAQ,iDAAR,CAApB,C;IAGA,IAAIW,CAAA,GAAIX,OAAA,CAAQ,QAAR,CAAR,C;IAEAD,OAAA,CAAQa,OAAR,GAAkB,UAASC,OAAT,EAAiB;AAAA,QAElC,IAAIC,SAAA,GAAY;AAAA,YACfb,WADe;AAAA,YAEfC,MAFe;AAAA,YAGfC,MAHe;AAAA,YAIfC,gBAJe;AAAA,YAKfC,aALe;AAAA,YAMfE,SANe;AAAA,YAOfC,OAPe;AAAA,YAQfC,QARe;AAAA,YASfC,aATe;AAAA,SAAhB,CAFkC;AAAA,QAelC,IAAGC,CAAA,IAAKA,CAAA,CAAEI,IAAV,EAAgB;AAAA,YACfF,OAAA,CAAQE,IAAR,GAAeJ,CAAA,CAAEI,IAAjB,CADe;AAAA,SAfkB;AAAA,QAmBlC,OAAOhB,OAAA,CAAQe,SAAR,EAAkBD,OAAlB,CAAP,CAnBkC;AAAA,KAAnC,C;IAsBAG,MAAA,CAAOC,OAAP,GAAiBlB,OAAA,CAAQa,OAAzB,C","file":"base-map.js"} \ No newline at end of file diff --git a/dist/amd/can/map/map.js b/dist/amd/can/map/map.js new file mode 100644 index 00000000..dd2ecfbb --- /dev/null +++ b/dist/amd/can/map/map.js @@ -0,0 +1,301 @@ +/*can-connect@1.0.20#can/map/map*/ +define(function (require, exports, module) { + 'use strict'; + var each = require('can-util/js/each'); + var connect = require('../../can-connect'); + var canBatch = require('can-event/batch'); + var canEvent = require('can-event'); + var Observation = require('can-observation'); + var isPlainObject = require('can-util/js/is-plain-object'); + var isArray = require('can-util/js/is-array'); + var types = require('can-types'); + var each = require('can-util/js/each'); + var isFunction = require('can-util/js/is-function'); + var dev = require('can-util/js/dev'); + var setExpando = function (map, prop, value) { + if ('attr' in map) { + map[prop] = value; + } else { + map._data[prop] = value; + } + }; + var getExpando = function (map, prop) { + if ('attr' in map) { + return map[prop]; + } else { + return map._data[prop]; + } + }; + module.exports = connect.behavior('can/map', function (baseConnection) { + var behavior = { + init: function () { + this.Map = this.Map || types.DefaultMap.extend({}); + this.List = this.List || types.DefaultList.extend({}); + overwrite(this, this.Map, mapOverwrites, mapStaticOverwrites); + overwrite(this, this.List, listPrototypeOverwrites, listStaticOverwrites); + baseConnection.init.apply(this, arguments); + }, + id: function (instance) { + if (!isPlainObject(instance)) { + var ids = [], algebra = this.algebra; + if (algebra && algebra.clauses && algebra.clauses.id) { + for (var prop in algebra.clauses.id) { + ids.push(readObservabe(instance, prop)); + } + } + if (this.idProp && !ids.length) { + ids.push(readObservabe(instance, this.idProp)); + } + if (!ids.length) { + ids.push(readObservabe(instance, 'id')); + } + return ids.length > 1 ? ids.join('@|@') : ids[0]; + } else { + return baseConnection.id(instance); + } + }, + serializeInstance: function (instance) { + return instance.serialize(); + }, + serializeList: function (list) { + return list.serialize(); + }, + instance: function (props) { + var _Map = this.Map || types.DefaultMap; + return new _Map(props); + }, + list: function (listData, set) { + var _List = this.List || this.Map && this.Map.List || types.DefaultList; + var list = new _List(listData.data); + each(listData, function (val, prop) { + if (prop !== 'data') { + list[list.set ? 'set' : 'attr'](prop, val); + } + }); + list.__listSet = set; + return list; + }, + updatedList: function () { + canBatch.start(); + var res = baseConnection.updatedList.apply(this, arguments); + canBatch.stop(); + return res; + }, + save: function (instance) { + setExpando(instance, '_saving', true); + canEvent.dispatch.call(instance, '_saving', [ + true, + false + ]); + var done = function () { + setExpando(instance, '_saving', false); + canEvent.dispatch.call(instance, '_saving', [ + false, + true + ]); + }; + var base = baseConnection.save.apply(this, arguments); + base.then(done, done); + return base; + }, + destroy: function (instance) { + setExpando(instance, '_destroying', true); + canEvent.dispatch.call(instance, '_destroying', [ + true, + false + ]); + var done = function () { + setExpando(instance, '_destroying', false); + canEvent.dispatch.call(instance, '_destroying', [ + false, + true + ]); + }; + var base = baseConnection.destroy.apply(this, arguments); + base.then(done, done); + return base; + } + }; + each([ + 'created', + 'updated', + 'destroyed' + ], function (funcName) { + behavior[funcName + 'Instance'] = function (instance, props) { + var constructor = instance.constructor; + if (props && typeof props === 'object') { + if ('set' in instance) { + instance.set(isFunction(props.get) ? props.get() : props, this.constructor.removeAttr || false); + } else if ('attr' in instance) { + instance.attr(isFunction(props.attr) ? props.attr() : props, this.constructor.removeAttr || false); + } else { + canBatch.start(); + each(props, function (value, prop) { + instance[prop] = value; + }); + canBatch.stop(); + } + } + canEvent.dispatch.call(instance, { + type: funcName, + target: instance + }); + canEvent.dispatch.call(constructor, funcName, [instance]); + }; + }); + return behavior; + }); + var callCanReadingOnIdRead = true; + var mapStaticOverwrites = { + getList: function (base, connection) { + return function (set) { + return connection.getList(set); + }; + }, + findAll: function (base, connection) { + return function (set) { + return connection.getList(set); + }; + }, + get: function (base, connection) { + return function (params) { + return connection.get(params); + }; + }, + findOne: function (base, connection) { + return function (params) { + return connection.get(params); + }; + } + }; + var mapOverwrites = { + _eventSetup: function (base, connection) { + return function () { + callCanReadingOnIdRead = false; + connection.addInstanceReference(this); + callCanReadingOnIdRead = true; + return base.apply(this, arguments); + }; + }, + _eventTeardown: function (base, connection) { + return function () { + callCanReadingOnIdRead = false; + connection.deleteInstanceReference(this); + callCanReadingOnIdRead = true; + return base.apply(this, arguments); + }; + }, + ___set: function (base, connection) { + return function (prop, val) { + base.apply(this, arguments); + if (prop === connection.idProp && this._bindings) { + connection.addInstanceReference(this); + } + }; + }, + isNew: function (base, connection) { + return function () { + var id = connection.id(this); + return !(id || id === 0); + }; + }, + isSaving: function (base, connection) { + return function () { + Observation.add(this, '_saving'); + return !!getExpando(this, '_saving'); + }; + }, + isDestroying: function (base, connection) { + return function () { + Observation.add(this, '_destroying'); + return !!getExpando(this, '_destroying'); + }; + }, + save: function (base, connection) { + return function (success, error) { + var promise = connection.save(this); + promise.then(success, error); + return promise; + }; + }, + destroy: function (base, connection) { + return function (success, error) { + var promise; + if (this.isNew()) { + promise = Promise.resolve(this); + connection.destroyedInstance(this, {}); + } else { + promise = connection.destroy(this); + } + promise.then(success, error); + return promise; + }; + } + }; + var listPrototypeOverwrites = { + setup: function (base, connection) { + return function (params) { + if (isPlainObject(params) && !isArray(params)) { + this.__listSet = params; + base.apply(this); + this.replace(types.isPromise(params) ? params : connection.getList(params)); + } else { + base.apply(this, arguments); + } + }; + }, + _eventSetup: function (base, connection) { + return function () { + connection.addListReference(this); + if (base) { + return base.apply(this, arguments); + } + }; + }, + _eventTeardown: function (base, connection) { + return function () { + connection.deleteListReference(this); + if (base) { + return base.apply(this, arguments); + } + }; + } + }; + var listStaticOverwrites = { + _bubbleRule: function (base, connection) { + return function (eventName, list) { + var bubbleRules = base(eventName, list); + bubbleRules.push('destroyed'); + return bubbleRules; + }; + } + }; + var readObservabe = function (instance, prop) { + if ('__get' in instance) { + if (callCanReadingOnIdRead) { + Observation.add(instance, prop); + } + return instance.__get(prop); + } else { + if (callCanReadingOnIdRead) { + return instance[prop]; + } else { + return Observation.ignore(function () { + return instance[prop]; + })(); + } + } + }; + var overwrite = function (connection, Constructor, prototype, statics) { + var prop; + for (prop in prototype) { + Constructor.prototype[prop] = prototype[prop](Constructor.prototype[prop], connection); + } + if (statics) { + for (prop in statics) { + Constructor[prop] = statics[prop](Constructor[prop], connection); + } + } + }; +}); +//# sourceMappingURL=map.js.map \ No newline at end of file diff --git a/dist/amd/can/map/map.js.map b/dist/amd/can/map/map.js.map new file mode 100644 index 00000000..ff8e1f6f --- /dev/null +++ b/dist/amd/can/map/map.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../../can/map/map.js"],"names":["each","require","connect","canBatch","canEvent","Observation","isPlainObject","isArray","types","isFunction","dev","setExpando","map","prop","value","_data","getExpando","module","exports","behavior","baseConnection","init","Map","DefaultMap","extend","List","DefaultList","overwrite","mapOverwrites","mapStaticOverwrites","listPrototypeOverwrites","listStaticOverwrites","apply","arguments","id","instance","ids","algebra","clauses","push","readObservabe","idProp","length","join","serializeInstance","serialize","serializeList","list","props","_Map","listData","set","_List","data","val","__listSet","updatedList","start","res","stop","save","dispatch","call","done","base","then","destroy","funcName","constructor","get","removeAttr","attr","type","target","callCanReadingOnIdRead","getList","connection","findAll","params","findOne","_eventSetup","addInstanceReference","_eventTeardown","deleteInstanceReference","___set","_bindings","isNew","isSaving","add","isDestroying","success","error","promise","Promise","resolve","destroyedInstance","setup","replace","isPromise","addListReference","deleteListReference","_bubbleRule","eventName","bubbleRules","__get","ignore","Constructor","prototype","statics"],"mappings":";;IAAA,a;IACA,IAAIA,IAAA,GAAOC,OAAA,CAAQ,kBAAR,CAAX,C;IAEA,IAAIC,OAAA,GAAUD,OAAA,CAAQ,mBAAR,CAAd,C;IACA,IAAIE,QAAA,GAAWF,OAAA,CAAQ,iBAAR,CAAf,C;IACA,IAAIG,QAAA,GAAWH,OAAA,CAAQ,WAAR,CAAf,C;IACA,IAAII,WAAA,GAAcJ,OAAA,CAAQ,iBAAR,CAAlB,C;IAEA,IAAIK,aAAA,GAAgBL,OAAA,CAAQ,6BAAR,CAApB,C;IACA,IAAIM,OAAA,GAAUN,OAAA,CAAQ,sBAAR,CAAd,C;IACA,IAAIO,KAAA,GAAQP,OAAA,CAAQ,WAAR,CAAZ,C;IACA,IAAID,IAAA,GAAOC,OAAA,CAAQ,kBAAR,CAAX,C;IACA,IAAIQ,UAAA,GAAaR,OAAA,CAAQ,yBAAR,CAAjB,C;IACA,IAAIS,GAAA,GAAMT,OAAA,CAAQ,iBAAR,CAAV,C;IAEA,IAAIU,UAAA,GAAa,UAAS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F,GAAZ,CAAgBrD,QAAhB,EAA0BtB,IAA1B,EAD0B;AAAA,aADJ;AAAA,YAIvB,OAAOsB,QAAA,CAASqE,KAAT,CAAe3F,IAAf,CAAP,CAJuB;AAAA,SAAxB,MAKO;AAAA,YACN,IAAG6D,sBAAH,EAA2B;AAAA,gBAC1B,OAAOvC,QAAA,CAAStB,IAAT,CAAP,CAD0B;AAAA,aAA3B,MAEO;AAAA,gBACN,OAAOR,WAAA,CAAYoG,MAAZ,CAAmB,YAAU;AAAA,oBACnC,OAAOtE,QAAA,CAAStB,IAAT,CAAP,CADmC;AAAA,iBAA7B,GAAP,CADM;AAAA,aAHD;AAAA,SANoC;AAAA,KAA5C,C;IAkBA,IAAIc,SAAA,GAAY,UAAUiD,UAAV,EAAsB8B,WAAtB,EAAmCC,SAAnC,EAA8CC,OAA9C,EAAuD;AAAA,QACtE,IAAI/F,IAAJ,CADsE;AAAA,QAGtE,KAAIA,IAAJ,IAAY8F,SAAZ,EAAuB;AAAA,YACtBD,WAAA,CAAYC,SAAZ,CAAsB9F,IAAtB,IAA8B8F,SAAA,CAAU9F,IAAV,EAAgB6F,WAAA,CAAYC,SAAZ,CAAsB9F,IAAtB,CAAhB,EAA6C+D,UAA7C,CAA9B,CADsB;AAAA,SAH+C;AAAA,QAMtE,IAAGgC,OAAH,EAAY;AAAA,YACX,KAAI/F,IAAJ,IAAY+F,OAAZ,EAAqB;AAAA,gBACpBF,WAAA,CAAY7F,IAAZ,IAAoB+F,OAAA,CAAQ/F,IAAR,EAAc6F,WAAA,CAAY7F,IAAZ,CAAd,EAAiC+D,UAAjC,CAApB,CADoB;AAAA,aADV;AAAA,SAN0D;AAAA,KAAvE,C","file":"map.js"} \ No newline at end of file diff --git a/dist/amd/can/ref/ref.js b/dist/amd/can/ref/ref.js new file mode 100644 index 00000000..f5231095 --- /dev/null +++ b/dist/amd/can/ref/ref.js @@ -0,0 +1,131 @@ +/*can-connect@1.0.20#can/ref/ref*/ +define(function (require, exports, module) { + var connect = require('../../can-connect'); + var getIdProps = require('../../helpers/get-id-props'); + var WeakReferenceMap = require('../../helpers/weak-reference-map'); + var Observation = require('can-observation'); + var constructorStore = require('../../constructor/store/store'); + var define = require('can-define'); + var makeRef = function (connection) { + var idProp = getIdProps(connection)[0]; + var Ref = function (id, value) { + if (Ref.store.has(id)) { + return Ref.store.get(id); + } + this[idProp] = id; + if (value) { + this._value = connection.hydrateInstance(value); + } + if (constructorStore.requests.count() > 0) { + if (!Ref._requestInstances[id]) { + Ref.store.addReference(id, this); + Ref._requestInstances[id] = this; + } + } + }; + Ref.store = new WeakReferenceMap(); + Ref._requestInstances = {}; + Ref.type = function (ref) { + if (ref && typeof ref !== 'object') { + return new Ref(ref); + } else { + return new Ref(ref[idProp], ref); + } + }; + var defs = { + promise: { + get: function () { + if (this._value) { + return Promise.resolve(this._value); + } else { + var props = {}; + props[idProp] = this[idProp]; + return connection.Map.get(props); + } + } + }, + _state: { + get: function (lastSet, resolve) { + if (resolve) { + this.promise.then(function () { + resolve('resolved'); + }, function () { + resolve('rejected'); + }); + } + return 'pending'; + } + }, + value: { + get: function (lastSet, resolve) { + if (this._value) { + return this._value; + } else if (resolve) { + this.promise.then(function (value) { + resolve(value); + }); + } + } + }, + reason: { + get: function (lastSet, resolve) { + if (this._value) { + return undefined; + } else { + this.promise.catch(function (value) { + resolve(value); + }); + } + } + } + }; + defs[idProp] = { + type: '*', + set: function () { + this._value = undefined; + } + }; + define(Ref.prototype, defs); + Ref.prototype.unobservedId = Observation.ignore(function () { + return this[idProp]; + }); + Ref.prototype.isResolved = function () { + return !!this._value || this._state === 'resolved'; + }; + Ref.prototype.isRejected = function () { + return this._state === 'rejected'; + }; + Ref.prototype.isPending = function () { + return !this._value && (this._state !== 'resolved' || this._state !== 'rejected'); + }; + Ref.prototype.serialize = function () { + return this[idProp]; + }; + var baseEventSetup = Ref.prototype._eventSetup; + Ref.prototype._eventSetup = function () { + Ref.store.addReference(this.unobservedId(), this); + return baseEventSetup.apply(this, arguments); + }; + var baseTeardown = Ref.prototype._eventTeardown; + Ref.prototype._eventTeardown = function () { + Ref.store.deleteReference(this.unobservedId(), this); + return baseTeardown.apply(this, arguments); + }; + constructorStore.requests.on('end', function () { + for (var id in Ref._requestInstances) { + Ref.store.deleteReference(id); + } + Ref._requestInstances = {}; + }); + return Ref; + }; + module.exports = connect.behavior('can/ref', function (baseConnection) { + return { + init: function () { + baseConnection.init.apply(this, arguments); + this.Map.Ref = makeRef(this); + } + }; + }); +}); +//# sourceMappingURL=ref.js.map \ No newline at end of file diff --git a/dist/amd/can/ref/ref.js.map b/dist/amd/can/ref/ref.js.map new file mode 100644 index 00000000..591fff4e --- /dev/null +++ b/dist/amd/can/ref/ref.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../../can/ref/ref.js"],"names":["connect","require","getIdProps","WeakReferenceMap","Observation","constructorStore","define","makeRef","connection","idProp","Ref","id","value","store","has","get","_value","hydrateInstance","requests","count","_requestInstances","addReference","type","ref","defs","promise","Promise","resolve","props","Map","_state","lastSet","then","reason","undefined","catch","set","prototype","unobservedId","ignore","isResolved","isRejected","isPending","serialize","baseEventSetup","_eventSetup","apply","arguments","baseTeardown","_eventTeardown","deleteReference","on","module","exports","behavior","baseConnection","init"],"mappings":";;IAiJA,IAAIA,OAAA,GAAUC,OAAA,CAAQ,mBAAR,CAAd,C;IACA,IAAIC,UAAA,GAAaD,OAAA,CAAQ,4BAAR,CAAjB,C;IACA,IAAIE,gBAAA,GAAmBF,OAAA,CAAQ,kCAAR,CAAvB,C;IACA,IAAIG,WAAA,GAAcH,OAAA,CAAQ,iBAAR,CAAlB,C;IACA,IAAII,gBAAA,GAAmBJ,OAAA,CAAQ,+BAAR,CAAvB,C;IACA,IAAIK,MAAA,GAASL,OAAA,CAAQ,YAAR,CAAb,C;IAEA,IAAIM,OAAA,GAAU,UAASC,UAAT,EAAoB;AAAA,QACjC,IAAIC,MAAA,GAASP,UAAA,CAAWM,UAAX,EAAuB,CAAvB,CAA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+MA0C,MAAA,CAAOC,OAAP,GAAiBrD,OAAA,CAAQsD,QAAR,CAAiB,SAAjB,EAA2B,UAASC,cAAT,EAAwB;AAAA,QACnE,OAAO;AAAA,YAONC,IAAA,EAAM,YAAU;AAAA,gBACfD,cAAA,CAAeC,IAAf,CAAoBV,KAApB,CAA0B,IAA1B,EAAgCC,SAAhC,EADe;AAAA,gBAEf,KAAKlB,GAAL,CAASnB,GAAT,GAAeH,OAAA,CAAQ,IAAR,CAAf,CAFe;AAAA,aAPV;AAAA,SAAP,CADmE;AAAA,KAAnD,CAAjB,C","file":"ref.js"} \ No newline at end of file diff --git a/dist/amd/can/super-map/super-map.js b/dist/amd/can/super-map/super-map.js new file mode 100644 index 00000000..a76f7aae --- /dev/null +++ b/dist/amd/can/super-map/super-map.js @@ -0,0 +1,48 @@ +/*can-connect@1.0.20#can/super-map/super-map*/ +define(function (require, exports, module) { + var connect = require('../../can-connect'); + var constructor = require('../../constructor/constructor'); + var canMap = require('../map/map'); + var canRef = require('../ref/ref'); + var constructorStore = require('../../constructor/store/store'); + var dataCallbacks = require('../../data/callbacks/callbacks'); + var callbacksCache = require('../../data/callbacks-cache/callbacks-cache'); + var combineRequests = require('../../data/combine-requests/combine-requests'); + var localCache = require('../../data/localstorage-cache/localstorage-cache'); + var dataParse = require('../../data/parse/parse'); + var dataUrl = require('../../data/url/url'); + var fallThroughCache = require('../../fall-through-cache/fall-through-cache'); + var realTime = require('../../real-time/real-time'); + var callbacksOnce = require('../../constructor/callbacks-once/callbacks-once'); + var $ = require('jquery'); + connect.superMap = function (options) { + var behaviors = [ + constructor, + canMap, + canRef, + constructorStore, + dataCallbacks, + combineRequests, + dataParse, + dataUrl, + realTime, + callbacksOnce + ]; + if (typeof localStorage !== 'undefined') { + if (!options.cacheConnection) { + options.cacheConnection = connect([localCache], { + name: options.name + 'Cache', + idProp: options.idProp, + algebra: options.algebra + }); + } + behaviors.push(callbacksCache, fallThroughCache); + } + if ($ && $.ajax) { + options.ajax = $.ajax; + } + return connect(behaviors, options); + }; + module.exports = connect.superMap; +}); +//# sourceMappingURL=super-map.js.map \ No newline at end of file diff --git a/dist/amd/can/super-map/super-map.js.map b/dist/amd/can/super-map/super-map.js.map new file mode 100644 index 00000000..da466667 --- /dev/null +++ b/dist/amd/can/super-map/super-map.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../../can/super-map/super-map.js"],"names":["connect","require","constructor","canMap","canRef","constructorStore","dataCallbacks","callbacksCache","combineRequests","localCache","dataParse","dataUrl","fallThroughCache","realTime","callbacksOnce","$","superMap","options","behaviors","localStorage","cacheConnection","name","idProp","algebra","push","ajax","module","exports"],"mappings":";;IAAA,IAAIA,OAAA,GAAUC,OAAA,CAAQ,mBAAR,CAAd,C;IAEA,IAAIC,WAAA,GAAcD,OAAA,CAAQ,+BAAR,CAAlB,C;IACA,IAAIE,MAAA,GAASF,OAAA,CAAQ,YAAR,CAAb,C;IACA,IAAIG,MAAA,GAASH,OAAA,CAAQ,YAAR,CAAb,C;IACA,IAAII,gBAAA,GAAmBJ,OAAA,CAAQ,+BAAR,CAAvB,C;IACA,IAAIK,aAAA,GAAgBL,OAAA,CAAQ,gCAAR,CAApB,C;IACA,IAAIM,cAAA,GAAiBN,OAAA,CAAQ,4CAAR,CAArB,C;IACA,IAAIO,eAAA,GAAkBP,OAAA,CAAQ,8CAAR,CAAtB,C;IACA,IAAIQ,UAAA,GAAaR,OAAA,CAAQ,kDAAR,CAAjB,C;IACA,IAAIS,SAAA,GAAYT,OAAA,CAAQ,wBAAR,CAAhB,C;IACA,IAAIU,OAAA,GAAUV,OAAA,CAAQ,oBAAR,CAAd,C;IACA,IAAIW,gBAAA,GAAmBX,OAAA,CAAQ,6CAAR,CAAvB,C;IACA,IAAIY,QAAA,GAAWZ,OAAA,CAAQ,2BAAR,CAAf,C;IACA,IAAIa,aAAA,GAAgBb,OAAA,CAAQ,iDAAR,CAApB,C;IAGA,IAAIc,CAAA,GAAId,OAAA,CAAQ,QAAR,CAAR,C;IAEAD,OAAA,CAAQgB,QAAR,GAAmB,UAASC,OAAT,EAAiB;AAAA,QAEnC,IAAIC,SAAA,GAAY;AAAA,YACfhB,WADe;AAAA,YAEfC,MAFe;AAAA,YAGfC,MAHe;AAAA,YAIfC,gBAJe;AAAA,YAKfC,aALe;AAAA,YAMfE,eANe;AAAA,YAOfE,SAPe;AAAA,YAQfC,OARe;AAAA,YASfE,QATe;AAAA,YAUfC,aAVe;AAAA,SAAhB,CAFmC;AAAA,QAcnC,IAAG,OAAOK,YAAP,KAAwB,WAA3B,EAAwC;AAAA,YACvC,IAAG,CAACF,OAAA,CAAQG,eAAZ,EAA6B;AAAA,gBAC5BH,OAAA,CAAQG,eAAR,GAA0BpB,OAAA,CAAQ,CAACS,UAAD,CAAR,EAAqB;AAAA,oBAC9CY,IAAA,EAAMJ,OAAA,CAAQI,IAAR,GAAa,OAD2B;AAAA,oBAE9CC,MAAA,EAAQL,OAAA,CAAQK,MAF8B;AAAA,oBAG9CC,OAAA,EAASN,OAAA,CAAQM,OAH6B;AAAA,iBAArB,CAA1B,CAD4B;AAAA,aADU;AAAA,YAQvCL,SAAA,CAAUM,IAAV,CAAejB,cAAf,EAA8BK,gBAA9B,EARuC;AAAA,SAdL;AAAA,QAyBnC,IAAGG,CAAA,IAAKA,CAAA,CAAEU,IAAV,EAAgB;AAAA,YACfR,OAAA,CAAQQ,IAAR,GAAeV,CAAA,CAAEU,IAAjB,CADe;AAAA,SAzBmB;AAAA,QA4BnC,OAAOzB,OAAA,CAAQkB,SAAR,EAAkBD,OAAlB,CAAP,CA5BmC;AAAA,KAApC,C;IA+BAS,MAAA,CAAOC,OAAP,GAAiB3B,OAAA,CAAQgB,QAAzB,C","file":"super-map.js"} \ No newline at end of file diff --git a/dist/amd/can/tag/tag.js b/dist/amd/can/tag/tag.js new file mode 100644 index 00000000..bafeefd8 --- /dev/null +++ b/dist/amd/can/tag/tag.js @@ -0,0 +1,84 @@ +/*can-connect@1.0.20#can/tag/tag*/ +define(function (require, exports, module) { + require('can-stache-bindings'); + var connect = require('../../can-connect'); + var compute = require('can-compute'); + var expression = require('can-stache/src/expression'); + var viewCallbacks = require('can-view-callbacks'); + var Observation = require('can-observation'); + var nodeLists = require('can-view-nodelist'); + var canEvent = require('can-event'); + var each = require('can-util/js/each'); + var domMutate = require('can-util/dom/mutate'); + var domData = require('can-util/dom/data'); + require('can-util/dom/events/removed'); + var convertToValue = function (arg) { + if (typeof arg === 'function') { + return convertToValue(arg()); + } else { + return arg; + } + }; + connect.tag = function (tagName, connection) { + var removeBrackets = function (value, open, close) { + open = open || '{'; + close = close || '}'; + if (value[0] === open && value[value.length - 1] === close) { + return value.substr(1, value.length - 2); + } + return value; + }; + viewCallbacks.tag(tagName, function (el, tagData) { + var getList = el.getAttribute('getList') || el.getAttribute('get-list'); + var getInstance = el.getAttribute('get'); + var attrValue = getList || getInstance; + var method = getList ? 'getList' : 'get'; + var attrInfo = expression.parse('tmp(' + removeBrackets(attrValue) + ')', { baseMethodType: 'Call' }); + var addedToPageData = false; + var addToPageData = Observation.ignore(function (set, promise) { + if (!addedToPageData) { + var root = tagData.scope.peek('%root') || tagData.scope.peek('@root'); + if (root && root.pageData) { + if (method === 'get') { + set = connection.id(set); + } + root.pageData(connection.name, set, promise); + } + } + addedToPageData = true; + }); + var request = compute(function () { + var hash = {}; + if (typeof attrInfo.hash === 'object') { + each(attrInfo.hash, function (val, key) { + if (val && val.hasOwnProperty('get')) { + hash[key] = tagData.scope.read(val.get, {}).value; + } else { + hash[key] = val; + } + }); + } else if (typeof attrInfo.hash === 'function') { + var getHash = attrInfo.hash(tagData.scope, tagData.options, {}); + each(getHash(), function (val, key) { + hash[key] = convertToValue(val); + }); + } else { + hash = attrInfo.argExprs.length ? attrInfo.argExprs[0].value(tagData.scope, tagData.options)() : {}; + } + var promise = connection[method](hash); + addToPageData(hash, promise); + return promise; + }); + domData.set.call(el, 'viewModel', request); + var nodeList = nodeLists.register([], undefined, tagData.parentNodeList || true); + var frag = tagData.subtemplate ? tagData.subtemplate(tagData.scope.add(request), tagData.options, nodeList) : document.createDocumentFragment(); + domMutate.appendChild.call(el, frag); + nodeLists.update(nodeList, el.childNodes); + canEvent.one.call(el, 'removed', function () { + nodeLists.unregister(nodeList); + }); + }); + }; + module.exports = connect.tag; +}); +//# sourceMappingURL=tag.js.map \ No newline at end of file diff --git a/dist/amd/can/tag/tag.js.map b/dist/amd/can/tag/tag.js.map new file mode 100644 index 00000000..96c921b9 --- /dev/null +++ b/dist/amd/can/tag/tag.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../../can/tag/tag.js"],"names":["require","connect","compute","expression","viewCallbacks","Observation","nodeLists","canEvent","each","domMutate","domData","convertToValue","arg","tag","tagName","connection","removeBrackets","value","open","close","length","substr","el","tagData","getList","getAttribute","getInstance","attrValue","method","attrInfo","parse","baseMethodType","addedToPageData","addToPageData","ignore","set","promise","root","scope","peek","pageData","id","name","request","hash","val","key","hasOwnProperty","read","get","getHash","options","argExprs","call","nodeList","register","undefined","parentNodeList","frag","subtemplate","add","document","createDocumentFragment","appendChild","update","childNodes","one","unregister","module","exports"],"mappings":";;IAgCAA,OAAA,CAAQ,qBAAR,E;IAEA,IAAIC,OAAA,GAAUD,OAAA,CAAQ,mBAAR,CAAd,C;IAEA,IAAIE,OAAA,GAAUF,OAAA,CAAQ,aAAR,CAAd,C;IACA,IAAIG,UAAA,GAAaH,OAAA,CAAQ,2BAAR,CAAjB,C;IACA,IAAII,aAAA,GAAgBJ,OAAA,CAAQ,oBAAR,CAApB,C;IACA,IAAIK,WAAA,GAAcL,OAAA,CAAQ,iBAAR,CAAlB,C;IACA,IAAIM,SAAA,GAAYN,OAAA,CAAQ,mBAAR,CAAhB,C;IACA,IAAIO,QAAA,GAAWP,OAAA,CAAQ,WAAR,CAAf,C;IAEA,IAAIQ,IAAA,GAAOR,OAAA,CAAQ,kBAAR,CAAX,C;IAEA,IAAIS,SAAA,GAAYT,OAAA,CAAQ,qBAAR,CAAh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AAZ,CAAiB/B,EAAjB,EAAqB,WAArB,EAAkCqB,OAAlC,EApD+C;AAAA,YAsD/C,IAAIW,QAAA,GAAWhD,SAAA,CAAUiD,QAAV,CAAmB,EAAnB,EAAuBC,SAAvB,EAAkCjC,OAAA,CAAQkC,cAAR,IAA0B,IAA5D,CAAf,CAtD+C;AAAA,YAwD/C,IAAIC,IAAA,GAAOnC,OAAA,CAAQoC,WAAR,GACRpC,OAAA,CAAQoC,WAAR,CAAqBpC,OAAA,CAAQe,KAAR,CAAcsB,GAAd,CAAkBjB,OAAlB,CAArB,EAAiDpB,OAAA,CAAQ4B,OAAzD,EAAkEG,QAAlE,CADQ,GAERO,QAAA,CAASC,sBAAT,EAFH,CAxD+C;AAAA,YA6D/CrD,SAAA,CAAUsD,WAAV,CAAsBV,IAAtB,CAA2B/B,EAA3B,EAA+BoC,IAA/B,EA7D+C;AAAA,YAgE/CpD,SAAA,CAAU0D,MAAV,CAAiBV,QAAjB,EAA2BhC,EAAA,CAAG2C,UAA9B,EAhE+C;AAAA,YAoE/C1D,QAAA,CAAS2D,GAAT,CAAab,IAAb,CAAkB/B,EAAlB,EAAsB,SAAtB,EAAiC,YAAW;AAAA,gBAC3ChB,SAAA,CAAU6D,UAAV,CAAqBb,QAArB,EAD2C;AAAA,aAA5C,EApE+C;AAAA,SAAhD,EAb0C;AAAA,KAA3C,C;IAuFAc,MAAA,CAAOC,OAAP,GAAiBpE,OAAA,CAAQY,GAAzB,C","file":"tag.js"} \ No newline at end of file diff --git a/dist/amd/connect.js b/dist/amd/connect.js new file mode 100644 index 00000000..42f6467a --- /dev/null +++ b/dist/amd/connect.js @@ -0,0 +1,83 @@ +/*can-connect@1.0.20#connect*/ +define(function (require, exports, module) { + var assign = require('can-util/js/assign'); + var connect = function (behaviors, options) { + behaviors = behaviors.map(function (behavior, index) { + var sortedIndex = -1; + if (typeof behavior === 'string') { + sortedIndex = connect.order.indexOf(behavior); + behavior = behaviorsMap[behavior]; + } else if (behavior.isBehavior) { + sortedIndex = connect.order.indexOf(behavior.behaviorName); + } else { + behavior = connect.behavior(behavior); + } + return { + originalIndex: index, + sortedIndex: sortedIndex, + behavior: behavior + }; + }).sort(function (b1, b2) { + if (~b1.sortedIndex && ~b2.sortedIndex) { + return b1.sortedIndex - b2.sortedIndex; + } + return b1.originalIndex - b2.originalIndex; + }); + behaviors = behaviors.map(function (b) { + return b.behavior; + }); + var behavior = connect.base(connect.behavior('options', function () { + return options; + })()); + behaviors.forEach(function (behave) { + behavior = behave(behavior); + }); + if (behavior.init) { + behavior.init(); + } + return behavior; + }; + connect.order = [ + 'data/localstorage-cache', + 'data/url', + 'data/parse', + 'cache-requests', + 'data/combine-requests', + 'constructor', + 'constructor/store', + 'can/map', + 'can/ref', + 'fall-through-cache', + 'data/worker', + 'real-time', + 'data/callbacks-cache', + 'data/callbacks', + 'constructor/callbacks-once' + ]; + connect.behavior = function (name, behavior) { + if (typeof name !== 'string') { + behavior = name; + name = undefined; + } + var behaviorMixin = function (base) { + var Behavior = function () { + }; + Behavior.name = name; + Behavior.prototype = base; + var newBehavior = new Behavior(); + var res = typeof behavior === 'function' ? behavior.apply(newBehavior, arguments) : behavior; + assign(newBehavior, res); + newBehavior.__behaviorName = name; + return newBehavior; + }; + if (name) { + behaviorMixin.behaviorName = name; + behaviorsMap[name] = behaviorMixin; + } + behaviorMixin.isBehavior = true; + return behaviorMixin; + }; + var behaviorsMap = {}; + module.exports = connect; +}); +//# sourceMappingURL=connect.js.map \ No newline at end of file diff --git a/dist/amd/connect.js.map b/dist/amd/connect.js.map new file mode 100644 index 00000000..dd9e3425 --- /dev/null +++ b/dist/amd/connect.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../connect.js"],"names":["assign","require","connect","behaviors","options","map","behavior","index","sortedIndex","order","indexOf","behaviorsMap","isBehavior","behaviorName","originalIndex","sort","b1","b2","b","base","forEach","behave","init","name","undefined","behaviorMixin","Behavior","prototype","newBehavior","res","apply","arguments","__behaviorName","module","exports"],"m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QAAA,GAAW,YAAU;AAAA,aAAzB,CAFiC;AAAA,YAGjCA,QAAA,CAASH,IAAT,GAAgBA,IAAhB,CAHiC;AAAA,YAIjCG,QAAA,CAASC,SAAT,GAAqBR,IAArB,CAJiC;AAAA,YAKjC,IAAIS,WAAA,GAAc,IAAIF,QAAJ,EAAlB,CALiC;AAAA,YAOjC,IAAIG,GAAA,GAAM,OAAOvB,QAAP,KAAoB,UAApB,GAAiCA,QAAA,CAASwB,KAAT,CAAeF,WAAf,EAA4BG,SAA5B,CAAjC,GAA0EzB,QAApF,CAPiC;AAAA,YAQjCN,MAAA,CAAO4B,WAAP,EAAoBC,GAApB,EARiC;AAAA,YASjCD,WAAA,CAAYI,cAAZ,GAA6BT,IAA7B,CATiC;AAAA,YAUjC,OAAOK,WAAP,CAViC;AAAA,SAAlC,CAL0C;AAAA,QAiB1C,IAAGL,IAAH,EAAS;AAAA,YACRE,aAAA,CAAcZ,YAAd,GAA6BU,IAA7B,CADQ;AAAA,YAERZ,YAAA,CAAaY,IAAb,IAAqBE,aAArB,CAFQ;AAAA,SAjBiC;AAAA,QAqB1CA,aAAA,CAAcb,UAAd,GAA2B,IAA3B,CArB0C;AAAA,QAsB1C,OAAOa,aAAP,CAtB0C;AAAA,KAA3C,C;IAyBA,IAAId,YAAA,GAAe,EAAnB,C;IAEAsB,MAAA,CAAOC,OAAP,GAAgBhC,OAAhB,C","file":"connect.js"} \ No newline at end of file diff --git a/dist/amd/constructor/callbacks-once/callbacks-once.js b/dist/amd/constructor/callbacks-once/callbacks-once.js new file mode 100644 index 00000000..acd373d2 --- /dev/null +++ b/dist/amd/constructor/callbacks-once/callbacks-once.js @@ -0,0 +1,27 @@ +/*can-connect@1.0.20#constructor/callbacks-once/callbacks-once*/ +define(function (require, exports, module) { + var connect = require('../../can-connect'); + var sortedSetJSON = require('../../helpers/sorted-set-json'); + var forEach = [].forEach; + var callbacks = [ + 'createdInstance', + 'updatedInstance', + 'destroyedInstance' + ]; + module.exports = connect.behavior('constructor/callbacks-once', function (baseConnection) { + var behavior = {}; + forEach.call(callbacks, function (name) { + behavior[name] = function (instance, data) { + var lastSerialized = this.getInstanceMetaData(instance, 'last-data'); + var serialize = sortedSetJSON(data), serialized = sortedSetJSON(this.serializeInstance(instance)); + if (lastSerialized !== serialize) { + var result = baseConnection[name].apply(this, arguments); + this.addInstanceMetaData(instance, 'last-data', serialize); + return result; + } + }; + }); + return behavior; + }); +}); +//# sourceMappingURL=callbacks-once.js.map \ No newline at end of file diff --git a/dist/amd/constructor/callbacks-once/callbacks-once.js.map b/dist/amd/constructor/callbacks-once/callbacks-once.js.map new file mode 100644 index 00000000..9e44fa1b --- /dev/null +++ b/dist/amd/constructor/callbacks-once/callbacks-once.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../../constructor/callbacks-once/callbacks-once.js"],"names":["connect","require","sortedSetJSON","forEach","callbacks","module","exports","behavior","baseConnection","call","name","instance","data","lastSerialized","getInstanceMetaData","serialize","serialized","serializeInstance","result","apply","arguments","addInstanceMetaData"],"mappings":";;IAcA,IAAIA,OAAA,GAAUC,OAAA,CAAQ,mBAAR,CAAd,C;IACA,IAAIC,aAAA,GAAgBD,OAAA,CAAQ,+BAAR,CAApB,C;IACA,IAAIE,OAAA,GAAU,GAAGA,OAAjB,C;IAGA,IAAIC,SAAA,GAAY;AAAA,QASf,iBATe;AAAA,QAkBf,iBAlBe;AAAA,QA2Bf,mBA3Be;AAAA,KAAhB,C;IAgCAC,MAAA,CAAOC,OAAP,GAAiBN,OAAA,CAAQO,QAAR,CAAiB,4BAAjB,EAA8C,UAASC,cAAT,EAAwB;AAAA,QAEtF,IAAID,QAAA,GAAW,EAAf,CAFsF;AAAA,QAMtFJ,OAAA,CAAQM,IAAR,CAAaL,SAAb,EAAwB,UAASM,IAAT,EAAc;AAAA,YACrCH,QAAA,CAASG,IAAT,IAAiB,UAASC,QAAT,EAAmBC,IAAnB,EAAyB;AAAA,gBAEzC,IAAIC,cAAA,GAAiB,KAAKC,mBAAL,CAAyBH,QAAzB,EAAmC,WAAnC,CAArB,CAFyC;AAAA,gBAIzC,IAAII,SAAA,GAAYb,aAAA,CAAcU,IAAd,CAAhB,EACCI,UAAA,GAAad,aAAA,CAAe,KAAKe,iBAAL,CAAwBN,QAAxB,CAAf,CADd,CAJyC;AAAA,gBAMzC,IAAGE,cAAA,KAAmBE,SAAtB,EAAiC;AAAA,oBAChC,IAAIG,MAAA,GAAUV,cAAA,CAAeE,IAAf,EAAqBS,KAArB,CAA2B,IAA3B,EAAiCC,SAAjC,CAAd,CADgC;AAAA,oBAEhC,KAAKC,mBAAL,CAAyBV,QAAzB,EAAmC,WAAnC,EAAgDI,SAAhD,EAFgC;AAAA,oBAGhC,OAAOG,MAAP,CAHgC;AAAA,iBANQ;AAAA,aAA1C,CADqC;AAAA,SAAtC,EANsF;AAAA,QAsBtF,OAAOX,QAAP,CAtBsF;AAAA,KAAtE,CAAjB,C","file":"callbacks-once.js"} \ No newline at end of file diff --git a/dist/amd/constructor/constructor.js b/dist/amd/constructor/constructor.js new file mode 100644 index 00000000..d9299629 --- /dev/null +++ b/dist/amd/constructor/constructor.js @@ -0,0 +1,131 @@ +/*can-connect@1.0.20#constructor/constructor*/ +define(function (require, exports, module) { + var isArray = require('can-util/js/is-array'); + var makeArray = require('can-util/js/make-array'); + var assign = require('can-util/js/assign'); + var connect = require('../can-connect'); + var WeakReferenceMap = require('../helpers/weak-reference-map'); + var overwrite = require('../helpers/overwrite'); + var idMerge = require('../helpers/id-merge'); + module.exports = connect.behavior('constructor', function (baseConnection) { + var behavior = { + cidStore: new WeakReferenceMap(), + _cid: 0, + get: function (params) { + var self = this; + return this.getData(params).then(function (data) { + return self.hydrateInstance(data); + }); + }, + getList: function (set) { + set = set || {}; + var self = this; + return this.getListData(set).then(function (data) { + return self.hydrateList(data, set); + }); + }, + hydrateList: function (listData, set) { + if (isArray(listData)) { + listData = { data: listData }; + } + var arr = []; + for (var i = 0; i < listData.data.length; i++) { + arr.push(this.hydrateInstance(listData.data[i])); + } + listData.data = arr; + if (this.list) { + return this.list(listData, set); + } else { + var list = listData.data.slice(0); + list[this.listSetProp || '__listSet'] = set; + copyMetadata(listData, list); + return list; + } + }, + hydrateInstance: function (props) { + if (this.instance) { + return this.instance(props); + } else { + return assign({}, props); + } + }, + save: function (instance) { + var serialized = this.serializeInstance(instance); + var id = this.id(instance); + var self = this; + if (id === undefined) { + var cid = this._cid++; + this.cidStore.addReference(cid, instance); + return this.createData(serialized, cid).then(function (data) { + if (data !== undefined) { + self.createdInstance(instance, data); + } + self.cidStore.deleteReference(cid, instance); + return instance; + }); + } else { + return this.updateData(serialized).then(function (data) { + if (data !== undefined) { + self.updatedInstance(instance, data); + } + return instance; + }); + } + }, + destroy: function (instance) { + var serialized = this.serializeInstance(instance), self = this; + return this.destroyData(serialized).then(function (data) { + if (data !== undefined) { + self.destroyedInstance(instance, data); + } + return instance; + }); + }, + createdInstance: function (instance, props) { + assign(instance, props); + }, + updatedInstance: function (instance, data) { + overwrite(instance, data, this.idProp); + }, + updatedList: function (list, listData, set) { + var instanceList = []; + for (var i = 0; i < listData.data.length; i++) { + instanceList.push(this.hydrateInstance(listData.data[i])); + } + idMerge(list, instanceList, this.id.bind(this), this.hydrateInstance.bind(this)); + copyMetadata(listData, list); + }, + destroyedInstance: function (instance, data) { + overwrite(instance, data, this.idProp); + }, + serializeInstance: function (instance) { + return assign({}, instance); + }, + serializeList: function (list) { + var self = this; + return makeArray(list).map(function (instance) { + return self.serializeInstance(instance); + }); + }, + isNew: function (instance) { + var id = this.id(instance); + return !(id || id === 0); + } + }; + return behavior; + }); + function copyMetadata(listData, list) { + for (var prop in listData) { + if (prop !== 'data') { + if (typeof list.set === 'function') { + list.set(prop, listData[prop]); + } else if (typeof list.attr === 'function') { + list.attr(prop, listData[prop]); + } else { + list[prop] = listData[prop]; + } + } + } + } +}); +//# sourceMappingURL=constructor.js.map \ No newline at end of file diff --git a/dist/amd/constructor/constructor.js.map b/dist/amd/constructor/constructor.js.map new file mode 100644 index 00000000..2e96ff70 --- /dev/null +++ b/dist/amd/constructor/constructor.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../constructor/constructor.js"],"names":["isArray","require","makeArray","assign","connect","WeakReferenceMap","overwrite","idMerge","module","exports","behavior","baseConnection","cidStore","_cid","get","params","self","getData","then","data","hydrateInstance","getList","set","getListData","hydrateList","listData","arr","i","length","push","list","slice","listSetProp","copyMetadata","props","instance","save","serialized","serializeInstance","id","undefined","cid","addReference","createData","createdInstance","deleteReference","updateData","updatedInstance","destroy","destroyData","destroyedInstance","idProp","updatedList","instanceList","bind","serializeList","map","isNew","prop","attr"],"mappings":";;IA8FA,IAAIA,OAAA,GAAUC,OAAA,CAAQ,sBAAR,CAAd,C;IACA,IAAIC,SAAA,GAAYD,OAAA,CAAQ,wBAAR,CAAhB,C;IACA,IAAIE,MAAA,GAASF,OAAA,CAAQ,oBAAR,CAAb,C;IACA,IAAIG,OAAA,GAAUH,OAAA,CAAQ,gBAAR,CAAd,C;IACA,IAAII,gBAAA,GAAmBJ,OAAA,CAAQ,+BAAR,CAAvB,C;IACA,IAAIK,SAAA,GAAYL,OAAA,CAAQ,sBAAR,CAAhB,C;IACA,IAAIM,OAAA,GAAUN,OAAA,CAAQ,qBAAR,CAAd,C;IAEAO,MAAA,CAAOC,OAAP,GAAiBL,OAAA,CAAQM,QAAR,CAAiB,aAAjB,EAA+B,UAASC,cAAT,EAAwB;AAAA,QAEvE,IAAID,QAAA,GAAW;AAAA,YAcdE,QAAA,EAAU,IAAIP,gBAAJ,EAdI;AAAA,YAedQ,IAAA,EAAM,CAfQ;AAAA,YA8CdC,GAAA,EAAK,UAASC,MAAT,EAAiB;AAAA,gBACrB,IAAIC,IAAA,GAAO,IAAX,CADqB;AAAA,gBAErB,OAAO,KAAKC,OAAL,CAAaF,MAAb,EAAqBG,IAArB,CAA0B,UAASC,IAAT,EAAc;AAAA,oBAC9C,OAAOH,IAAA,CAAKI,eAAL,CAAqBD,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I,EAAA,IAAMA,EAAA,KAAO,CAAb,CAAT,CAFwB;AAAA,aAldX;AAAA,SAAf,CAFuE;AAAA,QAykBvE,OAAO7B,QAAP,CAzkBuE;AAAA,KAAvD,CAAjB,C;IA6kBA,SAASuB,YAAT,CAAsBR,QAAtB,EAAgCK,IAAhC,EAAqC;AAAA,QACpC,SAAQ4B,IAAR,IAAgBjC,QAAhB,EAA0B;AAAA,YACzB,IAAGiC,IAAA,KAAS,MAAZ,EAAoB;AAAA,gBAEnB,IAAG,OAAO5B,IAAA,CAAKR,GAAZ,KAAoB,UAAvB,EAAmC;AAAA,oBAClCQ,IAAA,CAAKR,GAAL,CAASoC,IAAT,EAAejC,QAAA,CAASiC,IAAT,CAAf,EADkC;AAAA,iBAAnC,MAEO,IAAG,OAAO5B,IAAA,CAAK6B,IAAZ,KAAqB,UAAxB,EAAoC;AAAA,oBAC1C7B,IAAA,CAAK6B,IAAL,CAAUD,IAAV,EAAgBjC,QAAA,CAASiC,IAAT,CAAhB,EAD0C;AAAA,iBAApC,MAEA;AAAA,oBACN5B,IAAA,CAAK4B,IAAL,IAAajC,QAAA,CAASiC,IAAT,CAAb,CADM;AAAA,iBANY;AAAA,aADK;AAAA,SADU;AAAA,K","file":"constructor.js"} \ No newline at end of file diff --git a/dist/amd/constructor/store/store.js b/dist/amd/constructor/store/store.js new file mode 100644 index 00000000..e8c20629 --- /dev/null +++ b/dist/amd/constructor/store/store.js @@ -0,0 +1,182 @@ +/*can-connect@1.0.20#constructor/store/store*/ +define(function (require, exports, module) { + var connect = require('../../can-connect'); + var WeakReferenceMap = require('../../helpers/weak-reference-map'); + var sortedSetJSON = require('../../helpers/sorted-set-json'); + var canEvent = require('can-event'); + var assign = require('can-util/js/assign'); + var pendingRequests = 0; + var noRequestsTimer = null; + var requests = { + increment: function (connection) { + pendingRequests++; + clearTimeout(noRequestsTimer); + }, + decrement: function (connection) { + pendingRequests--; + if (pendingRequests === 0) { + noRequestsTimer = setTimeout(function () { + requests.dispatch('end'); + }, 10); + } + }, + count: function () { + return pendingRequests; + } + }; + assign(requests, canEvent); + var constructorStore = connect.behavior('constructor/store', function (baseConnection) { + var behavior = { + instanceStore: new WeakReferenceMap(), + listStore: new WeakReferenceMap(), + _requestInstances: {}, + _requestLists: {}, + _finishedRequest: function () { + var id; + requests.decrement(this); + if (requests.count() === 0) { + for (id in this._requestInstances) { + this.instanceStore.deleteReference(id); + } + this._requestInstances = {}; + for (id in this._requestLists) { + this.listStore.deleteReference(id); + } + this._requestLists = {}; + } + }, + addInstanceReference: function (instance, id) { + this.instanceStore.addReference(id || this.id(instance), instance); + }, + addInstanceMetaData: function (instance, name, value) { + var data = this.instanceStore.set[this.id(instance)]; + if (data) { + data[name] = value; + } + }, + getInstanceMetaData: function (instance, name) { + var data = this.instanceStore.set[this.id(instance)]; + if (data) { + return data[name]; + } + }, + deleteInstanceMetaData: function (instance, name) { + var data = this.instanceStore.set[this.id(instance)]; + delete data[name]; + }, + deleteInstanceReference: function (instance) { + this.instanceStore.deleteReference(this.id(instance), instance); + }, + addListReference: function (list, set) { + var id = sortedSetJSON(set || this.listSet(list)); + if (id) { + this.listStore.addReference(id, list); + } + }, + deleteListReference: function (list, set) { + var id = sortedSetJSON(set || this.listSet(list)); + if (id) { + this.listStore.deleteReference(id, list); + } + }, + hydratedInstance: function (instance) { + if (requests.count() > 0) { + var id = this.id(instance); + if (!this._requestInstances[id]) { + this.addInstanceReference(instance); + this._requestInstances[id] = instance; + } + } + }, + hydrateInstance: function (props) { + var id = this.id(props); + if ((id || id === 0) && this.instanceStore.has(id)) { + var storeInstance = this.instanceStore.get(id); + this.updatedInstance(storeInstance, props); + return storeInstance; + } + var instance = baseConnection.hydrateInstance.call(this, props); + this.hydratedInstance(instance); + return instance; + }, + hydratedList: function (list, set) { + if (requests.count() > 0) { + var id = sortedSetJSON(set || this.listSet(list)); + if (id) { + if (!this._requestLists[id]) { + this.addListReference(list, set); + this._requestLists[id] = list; + } + } + } + }, + hydrateList: function (listData, set) { + set = set || this.listSet(listData); + var id = sortedSetJSON(set); + if (id && this.listStore.has(id)) { + var storeList = this.listStore.get(id); + this.updatedList(storeList, listData, set); + return storeList; + } + var list = baseConnection.hydrateList.call(this, listData, set); + this.hydratedList(list, set); + return list; + }, + getList: function (params) { + var self = this; + requests.increment(this); + var promise = baseConnection.getList.call(this, params); + promise.then(function (instances) { + self._finishedRequest(); + }, function () { + self._finishedRequest(); + }); + return promise; + }, + get: function (params) { + var self = this; + requests.increment(this); + var promise = baseConnection.get.call(this, params); + promise.then(function (instance) { + self._finishedRequest(); + }, function () { + self._finishedRequest(); + }); + return promise; + }, + save: function (instance) { + var self = this; + requests.increment(this); + var updating = !this.isNew(instance); + if (updating) { + this.addInstanceReference(instance); + } + var promise = baseConnection.save.call(this, instance); + promise.then(function (instances) { + if (updating) { + self.deleteInstanceReference(instance); + } + self._finishedRequest(); + }, function () { + self._finishedRequest(); + }); + return promise; + }, + destroy: function (instance) { + var self = this; + requests.increment(this); + var promise = baseConnection.destroy.call(this, instance); + promise.then(function (instance) { + self._finishedRequest(); + }, function () { + self._finishedRequest(); + }); + return promise; + } + }; + return behavior; + }); + constructorStore.requests = requests; + module.exports = constructorStore; +}); +//# sourceMappingURL=store.js.map \ No newline at end of file diff --git a/dist/amd/constructor/store/store.js.map b/dist/amd/constructor/store/store.js.map new file mode 100644 index 00000000..b10cb938 --- /dev/null +++ b/dist/amd/constructor/store/store.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../../constructor/store/store.js"],"names":["connect","require","WeakReferenceMap","sortedSetJSON","canEvent","assign","pendingRequests","noRequestsTimer","requests","increment","connection","clearTimeout","decrement","setTimeout","dispatch","count","constructorStore","behavior","baseConnection","instanceStore","listStore","_requestInstances","_requestLists","_finishedRequest","id","deleteReference","addInstanceReference","instance","addReference","addInstanceMetaData","name","value","data","set","getInstanceMetaData","deleteInstanceMetaData","deleteInstanceReference","addListReference","list","listSet","deleteListReference","hydratedInstance","hydrateInstance","props","has","storeInstance","get","updatedInstance","call","hydratedList","hydrateList","listData","storeList","updatedList","getList","params","self","promise","then","instances","save","updating","isNew","destroy","module","exports"],"mappings":";;IAgFA,IAAIA,OAAA,GAAUC,OAAA,CAAQ,mBAAR,CAAd,C;IACA,IAAIC,gBAAA,GAAmBD,OAAA,CAAQ,kCAAR,CAAvB,C;IACA,IAAIE,aAAA,GAAgBF,OAAA,CAAQ,+BAAR,CAApB,C;IACA,IAAIG,QAAA,GAAWH,OAAA,CAAQ,WAAR,CAAf,C;IACA,IAAII,MAAA,GAASJ,OAAA,CAAQ,oBAAR,CAAb,C;IAGA,IAAIK,eAAA,GAAkB,CAAtB,C;IACA,IAAIC,eAAA,GAAkB,IAAtB,C;IACA,IAAIC,QAAA,GAAW;AAAA,QACdC,SAAA,EAAW,UAASC,UAAT,EAAoB;AAAA,YAC9BJ,eAAA,GAD8B;AAAA,YAE9BK,YAAA,CAAaJ,eAAb,EAF8B;AAAA,SADjB;AAAA,QAKdK,SAAA,EAAW,UAASF,UAAT,EAAoB;AAAA,YAC9BJ,eAAA,GAD8B;AAAA,YAE9B,IAAGA,eAAA,KAAoB,CAAvB,EAA0B;AAAA,gBACzBC,eAAA,GAAkBM,UAAA,CAAW,YAAU;AAAA,oBACtCL,QAAA,CAASM,QAAT,CAAkB,KAAlB,EADsC;AAAA,iBAArB,EAEhB,EAFgB,CAAlB,CADyB;AAAA,aAFI;AAAA,SALjB;AAAA,QAadC,KAAA,EAAO,YAAU;AAAA,YAChB,OAAOT,eAAP,CADgB;AAAA,SAbH;AAAA,KAAf,C;IAiBAD,MAAA,CAAOG,QAAP,EAAiBJ,QAAjB,E;IAGA,IAAIY,gBAAA,GAAmBhB,OAAA,CAAQiB,QAAR,CAAiB,mBAAjB,EAAqC,UAASC,cAAT,EAAwB;AAAA,QAEnF,IAAID,QAAA,GAAW;AAAA,YAkBdE,aAAA,EAAe,IAAIjB,gBAAJ,EAlBD;AAAA,YAmCdkB,SAAA,EAAW,IAAIlB,gBAAJ,E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ks-cache/callbacks-cache.js b/dist/amd/data/callbacks-cache/callbacks-cache.js new file mode 100644 index 00000000..2a36b455 --- /dev/null +++ b/dist/amd/data/callbacks-cache/callbacks-cache.js @@ -0,0 +1,22 @@ +/*can-connect@1.0.20#data/callbacks-cache/callbacks-cache*/ +define(function (require, exports, module) { + var connect = require('../../can-connect'); + var assign = require('can-util/js/assign'); + var each = require('can-util/js/each'); + var pairs = { + createdData: 'createData', + updatedData: 'updateData', + destroyedData: 'destroyData' + }; + module.exports = connect.behavior('data/callbacks-cache', function (baseConnection) { + var behavior = {}; + each(pairs, function (cacheCallback, dataCallbackName) { + behavior[dataCallbackName] = function (data, set, cid) { + this.cacheConnection[cacheCallback](assign(assign({}, set), data)); + return baseConnection[dataCallbackName].call(this, data, set, cid); + }; + }); + return behavior; + }); +}); +//# sourceMappingURL=callbacks-cache.js.map \ No newline at end of file diff --git a/dist/amd/data/callbacks-cache/callbacks-cache.js.map b/dist/amd/data/callbacks-cache/callbacks-cache.js.map new file mode 100644 index 00000000..f73c1516 --- /dev/null +++ b/dist/amd/data/callbacks-cache/callbacks-cache.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../../data/callbacks-cache/callbacks-cache.js"],"names":["connect","require","assign","each","pairs","createdData","updatedData","destroyedData","module","exports","behavior","baseConnection","cacheCallback","dataCallbackName","data","set","cid","cacheConnection","call"],"mappings":";;IAaA,IAAIA,OAAA,GAAUC,OAAA,CAAQ,mBAAR,CAAd,C;IACA,IAAIC,MAAA,GAASD,OAAA,CAAQ,oBAAR,CAAb,C;IACA,IAAIE,IAAA,GAAOF,OAAA,CAAQ,kBAAR,CAAX,C;IAGA,IAAIG,KAAA,GAAQ;AAAA,QAQXC,WAAA,EAAa,YARF;AAAA,QAgBXC,WAAA,EAAa,YAhBF;AAAA,QAwBXC,aAAA,EAAe,aAxBJ;AAAA,KAAZ,C;IA8BAC,MAAA,CAAOC,OAAP,GAAiBT,OAAA,CAAQU,QAAR,CAAiB,sBAAjB,EAAwC,UAASC,cAAT,EAAwB;AAAA,QAEhF,IAAID,QAAA,GAAW,EAAf,CAFgF;AAAA,QAIhFP,IAAA,CAAKC,KAAL,EAAY,UAASQ,aAAT,EAAwBC,gBAAxB,EAAyC;AAAA,YACpDH,QAAA,CAASG,gBAAT,IAA6B,UAASC,IAAT,EAAeC,GAAf,EAAoBC,GAApB,EAAwB;AAAA,gBAGpD,KAAKC,eAAL,CAAqBL,aAArB,EAAqCV,MAAA,CAAOA,MAAA,CAAO,EAAP,EAAWa,GAAX,CAAP,EAAwBD,IAAxB,CAArC,EAHoD;AAAA,gBAKpD,OAAOH,cAAA,CAAeE,gBAAf,EAAiCK,IAAjC,CAAsC,IAAtC,EAA6CJ,IAA7C,EAAmDC,GAAnD,EAAwDC,GAAxD,CAAP,CALoD;AAAA,aAArD,CADoD;AAAA,SAArD,EAJgF;AAAA,QAahF,OAAON,QAAP,CAbgF;AAAA,KAAhE,CAAjB,C","file":"callbacks-cache.js"} \ No newline at end of file diff --git a/dist/amd/data/callbacks/callbacks.js b/dist/amd/data/callbacks/callbacks.js new file mode 100644 index 00000000..1b617377 --- /dev/null +++ b/dist/amd/data/callbacks/callbacks.js @@ -0,0 +1,28 @@ +/*can-connect@1.0.20#data/callbacks/callbacks*/ +define(function (require, exports, module) { + var connect = require('../../can-connect'); + var each = require('can-util/js/each'); + var pairs = { + getListData: 'gotListData', + createData: 'createdData', + updateData: 'updatedData', + destroyData: 'destroyedData' + }; + module.exports = connect.behavior('data/callbacks', function (baseConnection) { + var behavior = {}; + each(pairs, function (callbackName, name) { + behavior[name] = function (params, cid) { + var self = this; + return baseConnection[name].call(this, params).then(function (data) { + if (self[callbackName]) { + return self[callbackName].call(self, data, params, cid); + } else { + return data; + } + }); + }; + }); + return behavior; + }); +}); +//# sourceMappingURL=callbacks.js.map \ No newline at end of file diff --git a/dist/amd/data/callbacks/callbacks.js.map b/dist/amd/data/callbacks/callbacks.js.map new file mode 100644 index 00000000..2765166b --- /dev/null +++ b/dist/amd/data/callbacks/callbacks.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../../data/callbacks/callbacks.js"],"names":["connect","require","each","pairs","getListData","createData","updateData","destroyData","module","exports","behavior","baseConnection","callbackName","name","params","cid","self","call","then","data"],"mappings":";;IAUA,IAAIA,OAAA,GAAUC,OAAA,CAAQ,mBAAR,CAAd,C;IACA,IAAIC,IAAA,GAAOD,OAAA,CAAQ,kBAAR,CAAX,C;IAGA,IAAIE,KAAA,GAAQ;AAAA,QAiBXC,WAAA,EAAa,aAjBF;AAAA,QAmCXC,UAAA,EAAY,aAnCD;AAAA,QAoDXC,UAAA,EAAY,aApDD;AAAA,QAqEXC,WAAA,EAAa,eArEF;AAAA,KAAZ,C;IAwEAC,MAAA,CAAOC,OAAP,GAAiBT,OAAA,CAAQU,QAAR,CAAiB,gBAAjB,EAAkC,UAASC,cAAT,EAAwB;AAAA,QAE1E,IAAID,QAAA,GAAW,EAAf,CAF0E;AAAA,QAM1ER,IAAA,CAAKC,KAAL,EAAY,UAASS,YAAT,EAAuBC,IAAvB,EAA4B;AAAA,YAEvCH,QAAA,CAASG,IAAT,IAAiB,UAASC,MAAT,EAAiBC,GAAjB,EAAqB;AAAA,gBACrC,IAAIC,IAAA,GAAO,IAAX,CADqC;AAAA,gBAGrC,OAAOL,cAAA,CAAeE,IAAf,EAAqBI,IAArB,CAA0B,IAA1B,EAAgCH,MAAhC,EAAwCI,IAAxC,CAA6C,UAASC,IAAT,EAAc;AAAA,oBACjE,IAAGH,IAAA,CAAKJ,YAAL,CAAH,EAAuB;AAAA,wBACtB,OAAOI,IAAA,CAAKJ,YAAL,EAAmBK,IAAnB,CAAwBD,IAAxB,EAA6BG,IAA7B,EAAmCL,MAAnC,EAA2CC,GAA3C,CAAP,CADsB;AAAA,qBAAvB,MAEO;AAAA,wBACN,OAAOI,IAAP,CADM;AAAA,qBAH0D;AAAA,iBAA3D,CAAP,CAHqC;AAAA,aAAtC,CAFuC;AAAA,SAAxC,EAN0E;AAAA,QAqB1E,OAAOT,QAAP,CArB0E;AAAA,KAA1D,CAAjB,C","file":"callbacks.js"} \ No newline at end of file diff --git a/dist/amd/data/combine-requests/combine-requests.js b/dist/amd/data/combine-requests/combine-requests.js new file mode 100644 index 00000000..27426893 --- /dev/null +++ b/dist/amd/data/combine-requests/combine-requests.js @@ -0,0 +1,105 @@ +/*can-connect@1.0.20#data/combine-requests/combine-requests*/ +define(function (require, exports, module) { + var connect = require('../../can-connect'); + var canSet = require('can-set'); + var getItems = require('../../helpers/get-items'); + var deepAssign = require('can-util/js/deep-assign'); + var makeDeferred = require('../../helpers/deferred'); + var forEach = [].forEach; + module.exports = connect.behavior('data/combine-requests', function (baseConnection) { + var pendingRequests; + return { + unionPendingRequests: function (pendingRequests) { + var self = this; + pendingRequests.sort(function (pReq1, pReq2) { + if (canSet.subset(pReq1.set, pReq2.set, self.algebra)) { + return 1; + } else if (canSet.subset(pReq2.set, pReq1.set, self.algebra)) { + return -1; + } else { + return 0; + } + }); + var combineData = []; + var current; + doubleLoop(pendingRequests, { + start: function (pendingRequest) { + current = { + set: pendingRequest.set, + pendingRequests: [pendingRequest] + }; + combineData.push(current); + }, + iterate: function (pendingRequest) { + var combined = canSet.union(current.set, pendingRequest.set, self.algebra); + if (combined) { + current.set = combined; + current.pendingRequests.push(pendingRequest); + return true; + } + } + }); + return Promise.resolve(combineData); + }, + getSubset: function (set, unionSet, data) { + return canSet.getSubset(set, unionSet, data, this.algebra); + }, + time: 1, + getListData: function (set) { + set = set || {}; + var self = this; + if (!pendingRequests) { + pendingRequests = []; + setTimeout(function () { + var combineDataPromise = self.unionPendingRequests(pendingRequests); + pendingRequests = null; + combineDataPromise.then(function (combinedData) { + forEach.call(combinedData, function (combined) { + var combinedSet = deepAssign({}, combined.set); + baseConnection.getListData(combinedSet).then(function (data) { + if (combined.pendingRequests.length === 1) { + combined.pendingRequests[0].deferred.resolve(data); + } else { + forEach.call(combined.pendingRequests, function (pending) { + pending.deferred.resolve({ data: self.getSubset(pending.set, combined.set, getItems(data)) }); + }); + } + }, function (err) { + if (combined.pendingRequests.length === 1) { + combined.pendingRequests[0].deferred.reject(err); + } else { + forEach.call(combined.pendingRequests, function (pending) { + pending.deferred.reject(err); + }); + } + }); + }); + }); + }, this.time || 1); + } + var deferred = makeDeferred(); + pendingRequests.push({ + deferred: deferred, + set: set + }); + return deferred.promise; + } + }; + }); + var doubleLoop = function (arr, callbacks) { + var i = 0; + while (i < arr.length) { + callbacks.start(arr[i]); + var j = i + 1; + while (j < arr.length) { + if (callbacks.iterate(arr[j]) === true) { + arr.splice(j, 1); + } else { + j++; + } + } + i++; + } + }; +}); +//# sourceMappingURL=combine-requests.js.map \ No newline at end of file diff --git a/dist/amd/data/combine-requests/combine-requests.js.map b/dist/amd/data/combine-requests/combine-requests.js.map new file mode 100644 index 00000000..f4cebdd5 --- /dev/null +++ b/dist/amd/data/combine-requests/combine-requests.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../../data/combine-requests/combine-requests.js"],"names":["connect","require","canSet","getItems","deepAssign","makeDeferred","forEach","module","exports","behavior","baseConnection","pendingRequests","unionPendingRequests","self","sort","pReq1","pReq2","subset","set","algebra","combineData","current","doubleLoop","start","pendingRequest","push","iterate","combined","union","Promise","resolve","getSubset","unionSet","data","time","getListData","setTimeout","combineDataPromise","then","combinedData","call","combinedSet","length","deferred","pending","err","reject","promise","arr","callbacks","i","j","splice"],"mappings":";;IACA,IAAIA,OAAA,GAAUC,OAAA,CAAQ,mBAAR,CAAd,C;IACA,IAAIC,MAAA,GAASD,OAAA,CAAQ,SAAR,CAAb,C;IACA,IAAIE,QAAA,GAAWF,OAAA,CAAQ,yBAAR,CAAf,C;IACA,IAAIG,UAAA,GAAaH,OAAA,CAAQ,yBAAR,CAAjB,C;IAEA,IAAII,YAAA,GAAeJ,OAAA,CAAQ,wBAAR,CAAnB,C;IACA,IAAIK,OAAA,GAAU,GAAGA,OAAjB,C;IAqEAC,MAAA,CAAOC,OAAP,GA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ChB,EAJoB;AAAA,iBAJI;AAAA,gBA8CzB,IAAIS,QAAA,GAAWtC,YAAA,EAAf,CA9CyB;AAAA,gBAgDzBM,eAAA,CAAgBc,IAAhB,CAAqB;AAAA,oBAACkB,QAAA,EAAUA,QAAX;AAAA,oBAAqBzB,GAAA,EAAKA,GAA1B;AAAA,iBAArB,EAhDyB;AAAA,gBAkDzB,OAAOyB,QAAA,CAASI,OAAhB,CAlDyB;AAAA,aA1JpB;AAAA,SAAP,CAHiF;AAAA,KAAjE,CAAjB,C;IA4NA,IAAIzB,UAAA,GAAa,UAAS0B,GAAT,EAAcC,SAAd,EAAwB;AAAA,QACxC,IAAIC,CAAA,GAAI,CAAR,CADwC;AAAA,QAExC,OAAMA,CAAA,GAAIF,GAAA,CAAIN,MAAd,EAAsB;AAAA,YACrBO,SAAA,CAAU1B,KAAV,CAAgByB,GAAA,CAAIE,CAAJ,CAAhB,EADqB;AAAA,YAErB,IAAIC,CAAA,GAAID,CAAA,GAAE,CAAV,CAFqB;AAAA,YAGrB,OAAOC,CAAA,GAAIH,GAAA,CAAIN,MAAf,EAAwB;AAAA,gBACvB,IAAGO,SAAA,CAAUvB,OAAV,CAAkBsB,GAAA,CAAIG,CAAJ,CAAlB,MAA8B,IAAjC,EAAuC;AAAA,oBACtCH,GAAA,CAAII,MAAJ,CAAWD,CAAX,EAAc,CAAd,EADsC;AAAA,iBAAvC,MAEO;AAAA,oBACNA,CAAA,GADM;AAAA,iBAHgB;AAAA,aAHH;AAAA,YAUrBD,CAAA,GAVqB;AAAA,SAFkB;AAAA,KAAzC,C","file":"combine-requests.js"} \ No newline at end of file diff --git a/dist/amd/data/localstorage-cache/localstorage-cache.js b/dist/amd/data/localstorage-cache/localstorage-cache.js new file mode 100644 index 00000000..53875607 --- /dev/null +++ b/dist/amd/data/localstorage-cache/localstorage-cache.js @@ -0,0 +1,260 @@ +/*can-connect@1.0.20#data/localstorage-cache/localstorage-cache*/ +define(function (require, exports, module) { + var getItems = require('../../helpers/get-items'); + var connect = require('../../can-connect'); + var sortedSetJSON = require('../../helpers/sorted-set-json'); + var canSet = require('can-set'); + var forEach = [].forEach; + var map = [].map; + var setAdd = require('../../helpers/set-add'); + var indexOf = require('../../helpers/get-index-by-id'); + var assign = require('can-util/js/assign'); + var overwrite = require('../../helpers/overwrite'); + module.exports = connect.behavior('data/localstorage-cache', function (baseConnection) { + var behavior = { + _instances: {}, + getSetData: function () { + var sets = {}; + var self = this; + forEach.call(JSON.parse(localStorage.getItem(this.name + '-sets')) || [], function (set) { + var setKey = sortedSetJSON(set); + if (localStorage.getItem(self.name + '/set/' + setKey)) { + sets[setKey] = { + set: set, + setKey: setKey + }; + } + }); + return sets; + }, + _getSets: function (setData) { + var sets = []; + setData = setData || this.getSetData(); + for (var setKey in setData) { + sets.push(JSON.parse(setKey)); + } + return sets; + }, + getInstance: function (id) { + var res = localStorage.getItem(this.name + '/instance/' + id); + if (res) { + return JSON.parse(res); + } + }, + updateInstance: function (props) { + var id = this.id(props); + var instance = this.getInstance(id); + if (!instance) { + instance = props; + } else { + overwrite(instance, props, this.idProp); + } + localStorage.setItem(this.name + '/instance/' + id, JSON.stringify(instance)); + return instance; + }, + getInstances: function (ids) { + var self = this; + return map.call(ids, function (id) { + return self.getInstance(id); + }); + }, + removeSet: function (setKey) { + var sets = this.getSetData(); + localStorage.removeItem(this.name + '/set/' + setKey); + delete sets[setKey]; + }, + updateSets: function (sets) { + var setData = this._getSets(sets); + localStorage.setItem(this.name + '-sets', JSON.stringify(setData)); + }, + updateSet: function (setDatum, items, newSet) { + var newSetKey = newSet ? sortedSetJSON(newSet) : setDatum.setKey; + if (newSet) { + if (newSetKey !== setDatum.setKey) { + var sets = this.getSetData(); + localStorage.removeItem(this.name + '/set/' + setDatum.setKey); + delete sets[setDatum.setKey]; + sets[newSetKey] = { + setKey: newSetKey, + set: newSet + }; + this.updateSets(sets); + } + } + setDatum.items = items; + var self = this; + var ids = map.call(items, function (item) { + var id = self.id(item); + localStorage.setItem(self.name + '/instance/' + id, JSON.stringify(item)); + return id; + }); + localStorage.setItem(this.name + '/set/' + newSetKey, JSON.stringify(ids)); + }, + addSet: function (set, data) { + var items = getItems(data); + var sets = this.getSetData(); + var setKey = sortedSetJSON(set); + sets[setKey] = { + setKey: setKey, + items: items, + set: set + }; + var self = this; + var ids = map.call(items, function (item) { + var id = self.id(item); + localStorage.setItem(self.name + '/instance/' + id, JSON.stringify(item)); + return id; + }); + localStorage.setItem(this.name + '/set/' + setKey, JSON.stringify(ids)); + this.updateSets(sets); + }, + _eachSet: function (cb) { + var sets = this.getSetData(); + var self = this; + var loop = function (setDatum, setKey) { + return cb.call(self, setDatum, setKey, function () { + if (!('items' in setDatum)) { + var ids = JSON.parse(localStorage.getItem(self.name + '/set/' + setKey)); + setDatum.items = self.getInstances(ids); + } + return setDatum.items; + }); + }; + for (var setKey in sets) { + var setDatum = sets[setKey]; + var result = loop(setDatum, setKey); + if (result !== undefined) { + return result; + } + } + }, + clear: function () { + var sets = this.getSetData(); + for (var setKey in sets) { + localStorage.removeItem(this.name + '/set/' + setKey); + } + localStorage.removeItem(this.name + '-sets'); + var keys = []; + for (var i = 0, len = localStorage.length; i < len; ++i) { + if (localStorage.key(i).indexOf(this.name + '/instance/') === 0) { + keys.push(localStorage.key(i)); + } + } + forEach.call(keys, function (key) { + localStorage.removeItem(key); + }); + this._instances = {}; + }, + getSets: function () { + return Promise.resolve(this._getSets()); + }, + getListData: function (set) { + set = set || {}; + var listData = this.getListDataSync(set); + if (listData) { + return Promise.resolve(listData); + } + return Promise.reject({ + message: 'no data', + error: 404 + }); + }, + getListDataSync: function (set) { + var sets = this._getSets(); + for (var i = 0; i < sets.length; i++) { + var checkSet = sets[i]; + if (canSet.subset(set, checkSet, this.algebra)) { + var items = canSet.getSubset(set, checkSet, this.__getListData(checkSet), this.algebra); + return { data: items }; + } + } + }, + __getListData: function (set) { + var setKey = sortedSetJSON(set); + var setDatum = this.getSetData()[setKey]; + if (setDatum) { + var localData = localStorage.getItem(this.name + '/set/' + setKey); + if (localData) { + return this.getInstances(JSON.parse(localData)); + } + } + }, + getData: function (params) { + var id = this.id(params); + var res = localStorage.getItem(this.name + '/instance/' + id); + if (res) { + return Promise.resolve(JSON.parse(res)); + } else { + return Promise.reject({ + message: 'no data', + error: 404 + }); + } + }, + updateListData: function (data, set) { + set = set || {}; + var items = getItems(data); + var sets = this.getSetData(); + var self = this; + for (var setKey in sets) { + var setDatum = sets[setKey]; + var union = canSet.union(setDatum.set, set, this.algebra); + if (union) { + return this.getListData(setDatum.set).then(function (setData) { + self.updateSet(setDatum, canSet.getUnion(setDatum.set, set, getItems(setData), items, this.algebra), union); + }); + } + } + this.addSet(set, data); + return Promise.resolve(); + }, + createData: function (props) { + var self = this; + var instance = this.updateInstance(props); + this._eachSet(function (setDatum, setKey, getItems) { + if (canSet.has(setDatum.set, instance, this.algebra)) { + self.updateSet(setDatum, setAdd(self, setDatum.set, getItems(), instance, self.algebra), setDatum.set); + } + }); + return Promise.resolve(assign({}, instance)); + }, + updateData: function (props) { + var self = this; + var instance = this.updateInstance(props); + this._eachSet(function (setDatum, setKey, getItems) { + var items = getItems(); + var index = indexOf(self, instance, items); + if (canSet.has(setDatum.set, instance, this.algebra)) { + if (index === -1) { + self.updateSet(setDatum, setAdd(self, setDatum.set, getItems(), instance, self.algebra)); + } else { + items.splice(index, 1, instance); + self.updateSet(setDatum, items); + } + } else if (index !== -1) { + items.splice(index, 1); + self.updateSet(setDatum, items); + } + }); + return Promise.resolve(assign({}, instance)); + }, + destroyData: function (props) { + var self = this; + var instance = this.updateInstance(props); + this._eachSet(function (setDatum, setKey, getItems) { + var items = getItems(); + var index = indexOf(self, instance, items); + if (index !== -1) { + items.splice(index, 1); + self.updateSet(setDatum, items); + } + }); + var id = this.id(instance); + localStorage.removeItem(this.name + '/instance/' + id); + return Promise.resolve(assign({}, instance)); + } + }; + return behavior; + }); +}); +//# sourceMappingURL=localstorage-cache.js.map \ No newline at end of file diff --git a/dist/amd/data/localstorage-cache/localstorage-cache.js.map b/dist/amd/data/localstorage-cache/localstorage-cache.js.map new file mode 100644 index 00000000..a7d69834 --- /dev/null +++ b/dist/amd/data/localstorage-cache/localstorage-cache.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../../data/localstorage-cache/localstorage-cache.js"],"names":["getItems","require","connect","sortedSetJSON","canSet","forEach","map","setAdd","indexOf","assign","overwrite","module","exports","behavior","baseConnection","_instances","getSetData","sets","self","call","JSON","parse","localStorage","getItem","name","set","setKey","_getSets","setData","push","getInstance","id","res","updateInstance","props","instance","idProp","setItem","stringify","getInstances","ids","removeSet","removeItem","updateSets","updateSet","setDatum","items","newSet","newSetKey","item","addSet","data","_eachSet","cb","loop","result","undefined","clear","keys","i","len","length","key","getSets","Promise","resolve","getListData","listData","getListDataSync","reject","message","error","checkSet","subset","algebra","getSubset","__getListData","localData","getData","params","updateListData","union","then","getUnion","createData","has","updateData","index","splice","destroyData"],"mappings":";;IA+CA,IAAIA,QAAA,GAAWC,OAAA,CAAQ,yBAAR,CAAf,C;IACA,IAAIC,OAAA,GAAUD,OAAA,CAAQ,mBAAR,CAAd,C;IACA,IAAIE,aAAA,GAAgBF,OAAA,CAAQ,+BAAR,CAApB,C;IACA,IAAIG,MAAA,GAASH,OAAA,CAAQ,SAAR,CAAb,C;IACA,IAAII,OAAA,GAAU,GAAGA,OAAjB,C;IACA,IAAIC,GAAA,GAAM,GAAGA,GAAb,C;IACA,IAAIC,MAAA,GAASN,OAAA,CAAQ,uBAAR,CAAb,C;IACA,IAAIO,OAAA,GAAUP,OAAA,CAAQ,+BAAR,CAAd,C;IACA,IAAIQ,MAAA,GAASR,OAAA,CAAQ,oBAAR,CAAb,C;IACA,IAAIS,SAAA,GAAYT,OAAA,CAAQ,yBAAR,CAAhB,C;IAEAU,MAAA,CAAOC,OAAP,GAAiBV,OAAA,CAAQW,QAAR,CAAiB,yBAAjB,EAA2C,UAASC,cAAT,EAAwB;AAAA,QAEnF,IAAID,QAAA,GA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,CAAwB,KAAKlB,IAAL,GAAU,YAAV,GAAuBO,EAA/C,EAhB2B;AAAA,gBAiB3B,OAAOiC,OAAA,CAAQC,OAAR,CAAgBxD,MAAA,CAAO,EAAP,EAAU0B,QAAV,CAAhB,CAAP,CAjB2B;AAAA,aA7ad;AAAA,SAAf,CAFmF;AAAA,QAocnF,OAAOtB,QAAP,CApcmF;AAAA,KAAnE,CAAjB,C","file":"localstorage-cache.js"} \ No newline at end of file diff --git a/dist/amd/data/memory-cache/memory-cache.js b/dist/amd/data/memory-cache/memory-cache.js new file mode 100644 index 00000000..091e9848 --- /dev/null +++ b/dist/amd/data/memory-cache/memory-cache.js @@ -0,0 +1,217 @@ +/*can-connect@1.0.20#data/memory-cache/memory-cache*/ +define(function (require, exports, module) { + var getItems = require('../../helpers/get-items'); + var connect = require('../../can-connect'); + var sortedSetJSON = require('../../helpers/sorted-set-json'); + var canSet = require('can-set'); + var overwrite = require('../../helpers/overwrite'); + var setAdd = require('../../helpers/set-add'); + var indexOf = require('../../helpers/get-index-by-id'); + var assign = require('can-util/js/assign'); + var cloneData = require('../../helpers/clone-data'); + module.exports = connect.behavior('data/memory-cache', function (baseConnection) { + var behavior = { + _sets: {}, + getSetData: function () { + return this._sets; + }, + __getListData: function (set) { + var setsData = this.getSetData(); + var setData = setsData[sortedSetJSON(set)]; + if (setData) { + return setData.items; + } + }, + _instances: {}, + getInstance: function (id) { + return this._instances[id]; + }, + removeSet: function (setKey, noUpdate) { + var sets = this.getSetData(); + delete sets[setKey]; + if (noUpdate !== true) { + this.updateSets(); + } + }, + updateSets: function () { + }, + updateInstance: function (props) { + var id = this.id(props); + if (!(id in this._instances)) { + this._instances[id] = props; + } else { + overwrite(this._instances[id], props, this.idProp); + } + return this._instances[id]; + }, + updateSet: function (setDatum, items, newSet) { + var newSetKey = newSet ? sortedSetJSON(newSet) : setDatum.setKey; + if (newSet) { + if (newSetKey !== setDatum.setKey) { + var sets = this.getSetData(); + var oldSetKey = setDatum.setKey; + sets[newSetKey] = setDatum; + setDatum.setKey = newSetKey; + setDatum.set = assign({}, newSet); + this.removeSet(oldSetKey); + } + } + setDatum.items = items; + var self = this; + items.forEach(function (item) { + self.updateInstance(item); + }); + }, + addSet: function (set, data) { + var items = getItems(data); + var sets = this.getSetData(); + var setKey = sortedSetJSON(set); + sets[setKey] = { + setKey: setKey, + items: items, + set: assign({}, set) + }; + var self = this; + items.forEach(function (item) { + self.updateInstance(item); + }); + this.updateSets(); + }, + _eachSet: function (cb) { + var sets = this.getSetData(); + var self = this; + var loop = function (setDatum, setKey) { + return cb.call(self, setDatum, setKey, function () { + return setDatum.items; + }); + }; + for (var setKey in sets) { + var setDatum = sets[setKey]; + var result = loop(setDatum, setKey); + if (result !== undefined) { + return result; + } + } + }, + _getSets: function () { + var sets = [], setsData = this.getSetData(); + for (var prop in setsData) { + sets.push(setsData[prop].set); + } + return sets; + }, + getSets: function () { + return Promise.resolve(this._getSets()); + }, + clear: function () { + this._instances = {}; + this._sets = {}; + }, + getListData: function (set) { + set = set || {}; + var listData = this.getListDataSync(set); + if (listData) { + return Promise.resolve(listData); + } + return Promise.reject({ + message: 'no data', + error: 404 + }); + }, + getListDataSync: function (set) { + var sets = this._getSets(); + for (var i = 0; i < sets.length; i++) { + var checkSet = sets[i]; + if (canSet.subset(set, checkSet, this.algebra)) { + var source = this.__getListData(checkSet); + var items = canSet.getSubset(set, checkSet, source, this.algebra); + return { + data: items, + count: source.length + }; + } + } + }, + _getListData: function (set) { + return this.getListDataSync(set); + }, + updateListData: function (data, set) { + set = set || {}; + var clonedData = cloneData(data); + var items = getItems(clonedData); + var sets = this.getSetData(); + var self = this; + for (var setKey in sets) { + var setDatum = sets[setKey]; + var union = canSet.union(setDatum.set, set, this.algebra); + if (union) { + var getSet = assign({}, setDatum.set); + return this.getListData(getSet).then(function (setData) { + self.updateSet(setDatum, canSet.getUnion(getSet, set, getItems(setData), items, self.algebra), union); + }); + } + } + this.addSet(set, clonedData); + return Promise.resolve(); + }, + getData: function (params) { + var id = this.id(params); + var res = this.getInstance(id); + if (res) { + return Promise.resolve(res); + } else { + return Promise.reject({ + message: 'no data', + error: 404 + }); + } + }, + createData: function (props) { + var self = this; + var instance = this.updateInstance(props); + this._eachSet(function (setDatum, setKey, getItems) { + if (canSet.has(setDatum.set, instance, this.algebra)) { + self.updateSet(setDatum, setAdd(self, setDatum.set, getItems(), instance, self.algebra), setDatum.set); + } + }); + return Promise.resolve(assign({}, instance)); + }, + updateData: function (props) { + var self = this; + var instance = this.updateInstance(props); + this._eachSet(function (setDatum, setKey, getItems) { + var items = getItems(); + var index = indexOf(self, instance, items); + if (canSet.subset(instance, setDatum.set, this.algebra)) { + if (index === -1) { + self.updateSet(setDatum, setAdd(self, setDatum.set, getItems(), instance, self.algebra)); + } else { + items.splice(index, 1, instance); + self.updateSet(setDatum, items); + } + } else if (index !== -1) { + items.splice(index, 1); + self.updateSet(setDatum, items); + } + }); + return Promise.resolve(assign({}, instance)); + }, + destroyData: function (props) { + var self = this; + this._eachSet(function (setDatum, setKey, getItems) { + var items = getItems(); + var index = indexOf(self, props, items); + if (index !== -1) { + items.splice(index, 1); + self.updateSet(setDatum, items); + } + }); + var id = this.id(props); + delete this._instances[id]; + return Promise.resolve(assign({}, props)); + } + }; + return behavior; + }); +}); +//# sourceMappingURL=memory-cache.js.map \ No newline at end of file diff --git a/dist/amd/data/memory-cache/memory-cache.js.map b/dist/amd/data/memory-cache/memory-cache.js.map new file mode 100644 index 00000000..974cab51 --- /dev/null +++ b/dist/amd/data/memory-cache/memory-cache.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../../data/memory-cache/memory-cache.js"],"names":["getItems","require","connect","sortedSetJSON","canSet","overwrite","setAdd","indexOf","assign","cloneData","module","exports","behavior","baseConnection","_sets","getSetData","__getListData","set","setsData","setData","items","_instances","getInstance","id","removeSet","setKey","noUpdate","sets","updateSets","updateInstance","props","idProp","updateSet","setDatum","newSet","newSetKey","oldSetKey","self","forEach","item","addSet","data","_eachSet","cb","loop","call","result","undefined","_getSets","prop","push","getSets","Promise","resolve","clear","getListData","listData","getListDataSync","reject","message","error","i","length","checkSet","subset","algebra","source","getSubset","count","_getListData","updateListData","clonedData","union","getSet","then","getUnion","getData","params","res","createData","instance","has","updateData","index","splice","destroyData"],"mappings":";;IA2CA,IAAIA,QAAA,GAAWC,OAAA,CAAQ,yBAAR,CAAf,C;IACA,IAAIC,OAAA,GAAUD,OAAA,CAAQ,mBAAR,CAAd,C;IACA,IAAIE,aAAA,GAAgBF,OAAA,CAAQ,+BAAR,CAApB,C;IACA,IAAIG,MAAA,GAASH,OAAA,CAAQ,SAAR,CAAb,C;IACA,IAAII,SAAA,GAAYJ,OAAA,CAAQ,yBAAR,CAAhB,C;IACA,IAAIK,MAAA,GAASL,OAAA,CAAQ,uBAAR,CAAb,C;IACA,IAAIM,OAAA,GAAUN,OAAA,CAAQ,+BAAR,CAAd,C;IACA,IAAIO,MAAA,GAASP,OAAA,CAAQ,oBAAR,CAAb,C;IACA,IAAIQ,SAAA,GAAYR,OAAA,CAAQ,0BAAR,CAAhB,C;IAEAS,MAAA,CAAOC,OAAP,GAAiBT,OAAA,CAAQU,QAAR,CAAiB,mBAAjB,EAAqC,UAASC,cAAT,EAAwB;AAAA,QAE7E,IAAID,QAAA,GAAW;AAAA,YACdE,KAAA,EAAO,EADO;AAAA,YAEdC,UAAA,EAAY,YAAU;AAAA,gBACrB,OAAO,KAAKD,KAAZ,CADqB;AAAA,aAFR;AAAA,YAMdE,aAAA,EAAe,UAASC,GAAT,EAAa;AAAA,gBAC3B,IAAIC,QAAA,GAAW,KAAKH,UAAL,EAAf,CAD2B;AAAA,gBAE3B,IAAII,OAAA,GAAUD,QAAA,CAASf,aAAA,CAAcc,GAAd,CAAT,CAAd,CAF2B;AAAA,gBAG3B,IAAGE,OAAH,EAAY;AAAA,oBACX,OAAOA,OAAA,CAAQC,KAAf,CADW;AAAA,iBAHe;AAAA,aANd;AAAA,YAadC,UAAA,EAAY,EAbE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CAAP,CAhB2B;AAAA,aA3Wd;AAAA,SAAf,CAF6E;AAAA,QAiY7E,OAAOlB,QAAP,CAjY6E;AAAA,KAA7D,CAAjB,C","file":"memory-cache.js"} \ No newline at end of file diff --git a/dist/amd/data/parse/parse.js b/dist/amd/data/parse/parse.js new file mode 100644 index 00000000..bbb1454d --- /dev/null +++ b/dist/amd/data/parse/parse.js @@ -0,0 +1,59 @@ +/*can-connect@1.0.20#data/parse/parse*/ +define(function (require, exports, module) { + var connect = require('../../can-connect'); + var each = require('can-util/js/each'); + var isArray = require('can-util/js/is-array'); + var getObject = require('can-util/js/get'); + module.exports = connect.behavior('data/parse', function (baseConnection) { + var behavior = { + parseListData: function (responseData) { + if (baseConnection.parseListData) { + responseData = baseConnection.parseListData.apply(this, arguments); + } + var result; + if (isArray(responseData)) { + result = { data: responseData }; + } else { + var prop = this.parseListProp || 'data'; + responseData.data = getObject(responseData, prop); + result = responseData; + if (prop !== 'data') { + delete responseData[prop]; + } + if (!isArray(result.data)) { + throw new Error('Could not get any raw data while converting using .parseListData'); + } + } + var arr = []; + for (var i = 0; i < result.data.length; i++) { + arr.push(this.parseInstanceData(result.data[i])); + } + result.data = arr; + return result; + }, + parseInstanceData: function (props) { + if (baseConnection.parseInstanceData) { + props = baseConnection.parseInstanceData.apply(this, arguments) || props; + } + return this.parseInstanceProp ? getObject(props, this.parseInstanceProp) || props : props; + } + }; + each(pairs, function (parseFunction, name) { + behavior[name] = function (params) { + var self = this; + return baseConnection[name].call(this, params).then(function () { + return self[parseFunction].apply(self, arguments); + }); + }; + }); + return behavior; + }); + var pairs = { + getListData: 'parseListData', + getData: 'parseInstanceData', + createData: 'parseInstanceData', + updateData: 'parseInstanceData', + destroyData: 'parseInstanceData' + }; +}); +//# sourceMappingURL=parse.js.map \ No newline at end of file diff --git a/dist/amd/data/parse/parse.js.map b/dist/amd/data/parse/parse.js.map new file mode 100644 index 00000000..b8527a5e --- /dev/null +++ b/dist/amd/data/parse/parse.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../../data/parse/parse.js"],"names":["connect","require","each","isArray","getObject","module","exports","behavior","baseConnection","parseListData","responseData","apply","arguments","result","data","prop","parseListProp","Error","arr","i","length","push","parseInstanceData","props","parseInstanceProp","pairs","parseFunction","name","params","self","call","then","getListData","getData","createData","updateData","destroyData"],"mappings":";;IAuDC,IAAIA,OAAA,GAAUC,OAAA,CAAQ,mBAAR,CAAd,C;IACA,IAAIC,IAAA,GAAOD,OAAA,CAAQ,kBAAR,CAAX,C;IACA,IAAIE,OAAA,GAAUF,OAAA,CAAQ,sBAAR,CAAd,C;IACA,IAAIG,SAAA,GAAYH,OAAA,CAAQ,iBAAR,CAAhB,C;IAGDI,MAAA,CAAOC,OAAP,GAAiBN,OAAA,CAAQO,QAAR,CAAiB,YAAjB,EAA8B,UAASC,cAAT,EAAwB;AAAA,QAEtE,IAAID,QAAA,GAAW;AAAA,YAoEdE,aAAA,EAAe,UAAUC,YAAV,EAAyB;AAAA,gBAGvC,IAAGF,cAAA,CAAeC,aAAlB,EAAiC;AAAA,oBAC9BC,YAAA,GAAeF,cAAA,CAAeC,aAAf,CAA6BE,KAA7B,CAAmC,IAAnC,EAAyCC,SAAzC,CAAf,CAD8B;AAAA,iBAHM;AAAA,gBAOvC,IAAIC,MAAJ,CAPuC;AAAA,gBAQvC,IAAIV,OAAA,CAAQO,YAAR,CAAJ,EAA4B;AAAA,oBAC3BG,MAAA,GAAS,EAACC,IAAA,EAAMJ,YAAP,EAAT,CAD2B;AAAA,iBAA5B,MAEO;AAAA,oBACN,IAAIK,IAAA,GAAO,KAAKC,aAAL,IAAsB,MAAjC,CADM;AAAA,oBAGNN,YAAA,CAAaI,IAAb,GAAoBV,SAAA,CAAUM,YAAV,EAAwBK,IAAxB,CAApB,CAHM;AAAA,oBAINF,MAAA,GAASH,YAAT,CAJM;AAAA,oBAKN,IAAGK,IAAA,KAAS,MAAZ,EAAoB;AAAA,wBACnB,OAAOL,YAAA,CAAaK,IAAb,C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ArB,CAA0B,IAA1B,EAAgCF,MAAhC,EAAwCG,IAAxC,CAA6C,YAAU;AAAA,oBAC7D,OAAOF,IAAA,CAAKH,aAAL,EAAoBf,KAApB,CAA0BkB,IAA1B,EAAgCjB,SAAhC,CAAP,CAD6D;AAAA,iBAAvD,CAAP,CAFgC;AAAA,aAAjC,CADwC;AAAA,SAAzC,EAjQsE;AAAA,QA0QtE,OAAOL,QAAP,CA1QsE;AAAA,KAAtD,CAAjB,C;IA8QA,IAAIkB,KAAA,GAAQ;AAAA,QACXO,WAAA,EAAa,eADF;AAAA,QAEXC,OAAA,EAAS,mBAFE;AAAA,QAGXC,UAAA,EAAY,mBAHD;AAAA,QAIXC,UAAA,EAAY,mBAJD;AAAA,QAKXC,WAAA,EAAa,mBALF;AAAA,KAAZ,C","file":"parse.js"} \ No newline at end of file diff --git a/dist/amd/data/url/url.js b/dist/amd/data/url/url.js new file mode 100644 index 00000000..4593fc08 --- /dev/null +++ b/dist/amd/data/url/url.js @@ -0,0 +1,101 @@ +/*can-connect@1.0.20#data/url/url*/ +define(function (require, exports, module) { + var isArray = require('can-util/js/is-array'); + var assign = require('can-util/js/assign'); + var each = require('can-util/js/each'); + var ajax = require('can-util/dom/ajax'); + var string = require('can-util/js/string'); + var getIdProps = require('../../helpers/get-id-props'); + var dev = require('can-util/js/dev'); + var connect = require('../../can-connect'); + var makePromise = require('can-util/js/make-promise'); + module.exports = connect.behavior('data/url', function (baseConnection) { + var behavior = {}; + each(pairs, function (reqOptions, name) { + behavior[name] = function (params) { + if (typeof this.url === 'object') { + if (typeof this.url[reqOptions.prop] === 'function') { + return makePromise(this.url[reqOptions.prop](params)); + } else if (this.url[reqOptions.prop]) { + return makePromise(makeAjax(this.url[reqOptions.prop], params, reqOptions.type, this.ajax || ajax, findContentType(this.url), reqOptions)); + } + } + var resource = typeof this.url === 'string' ? this.url : this.url.resource; + if (resource) { + var idProps = getIdProps(this); + return makePromise(makeAjax(createURLFromResource(resource, idProps[0], reqOptions.prop), params, reqOptions.type, this.ajax || ajax, findContentType(this.url), reqOptions)); + } + return baseConnection[name].call(this, params); + }; + }); + return behavior; + }); + var pairs = { + getListData: { + prop: 'getListData', + type: 'GET' + }, + getData: { + prop: 'getData', + type: 'GET' + }, + createData: { + prop: 'createData', + type: 'POST' + }, + updateData: { + prop: 'updateData', + type: 'PUT' + }, + destroyData: { + prop: 'destroyData', + type: 'DELETE', + includeData: false + } + }; + var findContentType = function (url) { + if (typeof url === 'object' && url.contentType) { + var acceptableType = url.contentType === 'application/x-www-form-urlencoded' || url.contentType === 'application/json'; + if (acceptableType) { + return url.contentType; + } else { + } + } + return 'application/json'; + }; + var makeAjax = function (ajaxOb, data, type, ajax, contentType, reqOptions) { + var params = {}; + if (typeof ajaxOb === 'string') { + var parts = ajaxOb.split(/\s+/); + params.url = parts.pop(); + if (parts.length) { + params.type = parts.pop(); + } + } else { + assign(params, ajaxOb); + } + params.data = typeof data === 'object' && !isArray(data) ? assign(params.data || {}, data) : data; + params.url = string.sub(params.url, params.data, true); + var encodeJSON = contentType !== 'application/x-www-form-urlencoded' && (type && (type === 'POST' || type === 'PUT')); + if (encodeJSON) { + params.data = JSON.stringify(params.data); + params.contentType = contentType; + } + if (reqOptions.includeData === false) { + delete params.data; + } + return ajax(assign({ + type: type || 'post', + dataType: 'json' + }, params)); + }; + var createURLFromResource = function (resource, idProp, name) { + var url = resource.replace(/\/+$/, ''); + if (name === 'getListData' || name === 'createData') { + return url; + } else { + return url + '/{' + idProp + '}'; + } + }; +}); +//# sourceMappingURL=url.js.map \ No newline at end of file diff --git a/dist/amd/data/url/url.js.map b/dist/amd/data/url/url.js.map new file mode 100644 index 00000000..2b105a0a --- /dev/null +++ b/dist/amd/data/url/url.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../../data/url/url.js"],"names":["isArray","require","assign","each","ajax","string","getIdProps","dev","connect","makePromise","module","exports","behavior","baseConnection","pairs","reqOptions","name","params","url","prop","makeAjax","type","findContentType","resource","idProps","createURLFromResource","call","getListData","getData","createData","updateData","destroyData","includeData","contentType","acceptableType","ajaxOb","data","parts","split","pop","length","sub","encodeJSON","JSON","stringify","dataType","idProp","replace"],"mappings":";;IAgGA,IAAIA,OAAA,GAAUC,OAAA,CAAQ,sBAAR,CAAd,C;IACA,IAAIC,MAAA,GAASD,OAAA,CAAQ,oBAAR,CAAb,C;IACA,IAAIE,IAAA,GAAOF,OAAA,CAAQ,kBAAR,CAAX,C;IACA,IAAIG,IAAA,GAAOH,OAAA,CAAQ,mBAAR,CAAX,C;IACA,IAAII,MAAA,GAASJ,OAAA,CAAQ,oBAAR,CAAb,C;IACA,IAAIK,UAAA,GAAaL,OAAA,CAAQ,4BAAR,CAAjB,C;IACA,IAAIM,GAAA,GAAMN,OAAA,CAAQ,iBAAR,CAAV,C;IACA,IAAIO,OAAA,GAAUP,OAAA,CAAQ,mBAAR,CAAd,C;IAEA,IAAIQ,WAAA,GAAcR,OAAA,CAAQ,0BAAR,CAAlB,C;IAKAS,MAAA,CAAOC,OAAP,GAAiBH,OAAA,CAAQI,QAAR,CAAiB,UAAjB,EAA6B,UAASC,cAAT,EAAyB;AAAA,QAGtE,IAAID,QAAA,GAAW,EAAf,CAHsE;AAAA,QAItET,IAAA,CAAKW,KAAL,EAAY,UAASC,UAAT,EAAqBC,IAArB,EAA2B;AAAA,YACtCJ,QAAA,CAASI,IAAT,IAAiB,UAASC,MAAT,EAAiB;AAAA,gBAEjC,IAAG,OAAO,KAAKC,GAAZ,KAAoB,QAAvB,EAAiC;AAAA,oBAChC,IAAG,OAAO,KAAKA,GAAL,CAASH,UAAA,CAAWI,IAApB,CAAP,KAAqC,UAAxC,EAAoD;AAAA,wBAEnD,OAAOV,WAAA,CAAY,KAAKS,GAAL,CAASH,UAAA,CAAWI,IAApB,EAA0BF,MAA1B,CAAZ,CAAP,CAFmD;AAAA,qBAApD,MAIK,IAAG,KAAKC,GAAL,CAASH,UAAA,CAAWI,IAApB,CAAH,EAA8B;AAAA,wBAClC,O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AA2B9B,IAA3B,EAAiC;AAAA,QAE5D,IAAIE,GAAA,GAAMK,QAAA,CAASwB,OAAT,CAAiB,MAAjB,EAAyB,EAAzB,CAAV,CAF4D;AAAA,QAG5D,IAAI/B,IAAA,KAAS,aAAT,IAA0BA,IAAA,KAAS,YAAvC,EAAqD;AAAA,YACpD,OAAOE,GAAP,CADoD;AAAA,SAArD,MAEO;AAAA,YACN,OAAOA,GAAA,GAAM,IAAN,GAAa4B,MAAb,GAAsB,GAA7B,CADM;AAAA,SALqD;AAAA,KAA7D,C","file":"url.js"} \ No newline at end of file diff --git a/dist/amd/fall-through-cache/fall-through-cache.js b/dist/amd/fall-through-cache/fall-through-cache.js new file mode 100644 index 00000000..547f1e99 --- /dev/null +++ b/dist/amd/fall-through-cache/fall-through-cache.js @@ -0,0 +1,98 @@ +/*can-connect@1.0.20#fall-through-cache/fall-through-cache*/ +define(function (require, exports, module) { + var connect = require('../can-connect'); + var sortedSetJSON = require('../helpers/sorted-set-json'); + module.exports = connect.behavior('fall-through-cache', function (baseConnection) { + var behavior = { + hydrateList: function (listData, set) { + set = set || this.listSet(listData); + var id = sortedSetJSON(set); + var list = baseConnection.hydrateList.call(this, listData, set); + if (this._getHydrateListCallbacks[id]) { + this._getHydrateListCallbacks[id].shift()(list); + if (!this._getHydrateListCallbacks[id].length) { + delete this._getHydrateListCallbacks[id]; + } + } + return list; + }, + _getHydrateListCallbacks: {}, + _getHydrateList: function (set, callback) { + var id = sortedSetJSON(set); + if (!this._getHydrateListCallbacks[id]) { + this._getHydrateListCallbacks[id] = []; + } + this._getHydrateListCallbacks[id].push(callback); + }, + getListData: function (set) { + set = set || {}; + var self = this; + return this.cacheConnection.getListData(set).then(function (data) { + self._getHydrateList(set, function (list) { + self.addListReference(list, set); + setTimeout(function () { + baseConnection.getListData.call(self, set).then(function (listData) { + self.cacheConnection.updateListData(listData, set); + self.updatedList(list, listData, set); + self.deleteListReference(list, set); + }, function (e) { + console.log('REJECTED', e); + }); + }, 1); + }); + return data; + }, function () { + var listData = baseConnection.getListData.call(self, set); + listData.then(function (listData) { + self.cacheConnection.updateListData(listData, set); + }); + return listData; + }); + }, + hydrateInstance: function (props) { + var id = this.id(props); + var instance = baseConnection.hydrateInstance.apply(this, arguments); + if (this._getMakeInstanceCallbacks[id]) { + this._getMakeInstanceCallbacks[id].shift()(instance); + if (!this._getMakeInstanceCallbacks[id].length) { + delete this._getMakeInstanceCallbacks[id]; + } + } + return instance; + }, + _getMakeInstanceCallbacks: {}, + _getMakeInstance: function (id, callback) { + if (!this._getMakeInstanceCallbacks[id]) { + this._getMakeInstanceCallbacks[id] = []; + } + this._getMakeInstanceCallbacks[id].push(callback); + }, + getData: function (params) { + var self = this; + return this.cacheConnection.getData(params).then(function (instanceData) { + self._getMakeInstance(self.id(instanceData) || self.id(params), function (instance) { + self.addInstanceReference(instance); + setTimeout(function () { + baseConnection.getData.call(self, params).then(function (instanceData2) { + self.cacheConnection.updateData(instanceData2); + self.updatedInstance(instance, instanceData2); + self.deleteInstanceReference(instance); + }, function (e) { + console.log('REJECTED', e); + }); + }, 1); + }); + return instanceData; + }, function () { + var listData = baseConnection.getData.call(self, params); + listData.then(function (instanceData) { + self.cacheConnection.updateData(instanceData); + }); + return listData; + }); + } + }; + return behavior; + }); +}); +//# sourceMappingURL=fall-through-cache.js.map \ No newline at end of file diff --git a/dist/amd/fall-through-cache/fall-through-cache.js.map b/dist/amd/fall-through-cache/fall-through-cache.js.map new file mode 100644 index 00000000..7f5ef1d5 --- /dev/null +++ b/dist/amd/fall-through-cache/fall-through-cache.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../fall-through-cache/fall-through-cache.js"],"names":["connect","require","sortedSetJSON","module","exports","behavior","baseConnection","hydrateList","listData","set","listSet","id","list","call","_getHydrateListCallbacks","shift","length","_getHydrateList","callback","push","getListData","self","cacheConnection","then","data","addListReference","setTimeout","updateListData","updatedList","deleteListReference","e","console","log","hydrateInstance","props","instance","apply","arguments","_getMakeInstanceCallbacks","_getMakeInstance","getData","params","instanceData","addInstanceReference","instanceData2","updateData","updatedInstance","deleteInstanceReference"],"mappings":";;IAuEA,IAAIA,OAAA,GAAUC,OAAA,CAAQ,gBAAR,CAAd,C;IACA,IAAIC,aAAA,GAAgBD,OAAA,CAAQ,4BAAR,CAApB,C;IAEAE,MAAA,CAAOC,OAAP,GAAiBJ,OAAA,CAAQK,QAAR,CAAiB,oBAAjB,EAAsC,UAASC,cAAT,EAAwB;AAAA,QAE9E,IAAID,QAAA,GAAW;AAAA,YAkBdE,WAAA,EAAa,UAASC,QAAT,EAAmBC,GAAnB,EAAuB;AAAA,gBACnCA,GAAA,GAAMA,GAAA,IAAO,KAAKC,OAAL,CAAaF,QAAb,CAAb,CADmC;AAAA,gBAEnC,IAAIG,EAAA,GAAKT,aAAA,CAAeO,GAAf,CAAT,CAFmC;AAAA,gBAGnC,IAAIG,IAAA,GAAON,cAAA,CAAeC,WAAf,CAA2BM,IAA3B,CAAgC,IAAhC,EAAsCL,QAAtC,EAAgDC,GAAhD,CAAX,CAHmC;AAAA,gBAKnC,IAAG,KAAKK,wBAAL,CAA8BH,EAA9B,CAAH,EAAsC;AAAA,oBACrC,KAAKG,wBAAL,CAA8BH,EAA9B,EAAkCI,KAAlC,GAA0CH,IAA1C,EADqC;AAAA,oBAErC,IAAG,CAAC,KAAKE,wBAAL,CAA8BH,EAA9B,EAAkCK,MAAtC,EAA6C;AAAA,wBAC5C,OAAO,KAAKF,wBAAL,CAA8BH,EAA9B,CAAP,CAD4C;AAAA,qBAFR;AAAA,iBALH;AAAA,gBAWnC,OAAOC,IAAP,CAXmC;AAAA,aAlBtB;AAAA,YA+BdE,wBAAA,EAA0B,EA/BZ;AAAA,YAgCdG,eAAA,EAAiB,UAASR,GAAT,EAAcS,QAAd,EAAuB;AAAA,gBACvC,IAAIP,EAAA,GAAKT,aAAA,CAAeO,GAAf,CAAT,CADuC;AAAA,gBAEvC,IAAG,CAAC,KAAKK,wBAAL,CAA8BH,EAA9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B,MAAlC,CAAf,CADY;AAAA,oBAEZjC,QAAA,CAASe,IAAT,CAAc,UAASmB,YAAT,EAAsB;AAAA,wBACnCrB,IAAA,CAAKC,eAAL,CAAqBuB,UAArB,CAAgCH,YAAhC,EADmC;AAAA,qBAApC,EAFY;AAAA,oBAMZ,OAAOlC,QAAP,CANY;AAAA,iBAtBN,CAAP,CAHwB;AAAA,aA1KX;AAAA,SAAf,CAF8E;AAAA,QAiN9E,OAAOH,QAAP,CAjN8E;AAAA,KAA9D,CAAjB,C","file":"fall-through-cache.js"} \ No newline at end of file diff --git a/dist/amd/helpers/clone-data.js b/dist/amd/helpers/clone-data.js new file mode 100644 index 00000000..35e56d83 --- /dev/null +++ b/dist/amd/helpers/clone-data.js @@ -0,0 +1,9 @@ +/*can-connect@1.0.20#helpers/clone-data*/ +define(function (require, exports, module) { + var isArray = require('can-util/js/is-array'); + var deepAssign = require('can-util/js/deep-assign'); + module.exports = function (data) { + return isArray(data) ? data.slice(0) : deepAssign({}, data); + }; +}); +//# sourceMappingURL=clone-data.js.map \ No newline at end of file diff --git a/dist/amd/helpers/clone-data.js.map b/dist/amd/helpers/clone-data.js.map new file mode 100644 index 00000000..b63c9d11 --- /dev/null +++ b/dist/amd/helpers/clone-data.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../helpers/clone-data.js"],"names":["isArray","require","deepAssign","module","exports","data","slice"],"mappings":";;IAAA,IAAIA,OAAA,GAAUC,OAAA,CAAQ,sBAAR,CAAd,C;IACA,IAAIC,UAAA,GAAaD,OAAA,CAAQ,yBAAR,CAAjB,C;IAEAE,MAAA,CAAOC,OAAP,GAAiB,UAASC,IAAT,EAAe;AAAA,QAC/B,OAAOL,OAAA,CAAQK,IAAR,IAAgBA,IAAA,CAAKC,KAAL,CAAW,CAAX,CAAhB,GAAgCJ,UAAA,CAAW,EAAX,EAAeG,IAAf,CAAvC,CAD+B;AAAA,KAAhC,C","file":"clone-data.js"} \ No newline at end of file diff --git a/dist/amd/helpers/deferred.js b/dist/amd/helpers/deferred.js new file mode 100644 index 00000000..fc20b24c --- /dev/null +++ b/dist/amd/helpers/deferred.js @@ -0,0 +1,12 @@ +/*can-connect@1.0.20#helpers/deferred*/ +define(function (require, exports, module) { + module.exports = function () { + var def = {}; + def.promise = new Promise(function (resolve, reject) { + def.resolve = resolve; + def.reject = reject; + }); + return def; + }; +}); +//# sourceMappingURL=deferred.js.map \ No newline at end of file diff --git a/dist/amd/helpers/deferred.js.map b/dist/amd/helpers/deferred.js.map new file mode 100644 index 00000000..47ab40ea --- /dev/null +++ b/dist/amd/helpers/deferred.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../helpers/deferred.js"],"names":["module","exports","def","promise","Promise","resolve","reject"],"mappings":";;IACAA,MAAA,CAAOC,OAAP,GAAiB,YAAU;AAAA,QAC1B,IAAIC,GAAA,GAAM,EAAV,CAD0B;AAAA,QAE1BA,GAAA,CAAIC,OAAJ,GAAc,IAAIC,OAAJ,CAAY,UAASC,OAAT,EAAkBC,MAAlB,EAAyB;AAAA,YAClDJ,GAAA,CAAIG,OAAJ,GAAcA,OAAd,CADkD;AAAA,YAElDH,GAAA,CAAII,MAAJ,GAAaA,MAAb,CAFkD;AAAA,SAArC,CAAd,CAF0B;AAAA,QAM1B,OAAOJ,GAAP,CAN0B;AAAA,KAA3B,C","file":"deferred.js"} \ No newline at end of file diff --git a/dist/amd/helpers/get-id-props.js b/dist/amd/helpers/get-id-props.js new file mode 100644 index 00000000..bc6ba0d7 --- /dev/null +++ b/dist/amd/helpers/get-id-props.js @@ -0,0 +1,19 @@ +/*can-connect@1.0.20#helpers/get-id-props*/ +define(function (require, exports, module) { + module.exports = function (connection) { + var ids = [], algebra = this.algebra; + if (algebra && algebra.clauses && algebra.clauses.id) { + for (var prop in algebra.clauses.id) { + ids.push(prop); + } + } + if (connection.idProp && !ids.length) { + ids.push(connection.idProp); + } + if (!ids.length) { + ids.push('id'); + } + return ids; + }; +}); +//# sourceMappingURL=get-id-props.js.map \ No newline at end of file diff --git a/dist/amd/helpers/get-id-props.js.map b/dist/amd/helpers/get-id-props.js.map new file mode 100644 index 00000000..b4076e42 --- /dev/null +++ b/dist/amd/helpers/get-id-props.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../helpers/get-id-props.js"],"names":["module","exports","connection","ids","algebra","clauses","id","prop","push","idProp","length"],"mappings":";;IAAAA,MAAA,CAAOC,OAAP,GAAiB,UAASC,UAAT,EAAqB;AAAA,QACrC,IAAIC,GAAA,GAAM,EAAV,EACCC,OAAA,GAAU,KAAKA,OADhB,CADqC;AAAA,QAIrC,IAAGA,OAAA,IAAWA,OAAA,CAAQC,OAAnB,IAA8BD,OAAA,CAAQC,OAAR,CAAgBC,EAAjD,EAAqD;AAAA,YACpD,SAAQC,IAAR,IAAgBH,OAAA,CAAQC,OAAR,CAAgBC,EAAhC,EAAoC;AAAA,gBACnCH,GAAA,CAAIK,IAAJ,CAASD,IAAT,EADmC;AAAA,aADgB;AAAA,SAJhB;AAAA,QAUrC,IAAGL,UAAA,CAAWO,MAAX,IAAqB,CAACN,GAAA,CAAIO,MAA7B,EAAqC;AAAA,YACpCP,GAAA,CAAIK,IAAJ,CAASN,UAAA,CAAWO,MAApB,EADoC;AAAA,SAVA;AAAA,QAarC,IAAG,CAACN,GAAA,CAAIO,MAAR,EAAgB;AAAA,YACfP,GAAA,CAAIK,IAAJ,CAAS,IAAT,EADe;AAAA,SAbqB;AAAA,QAgBrC,OAAOL,GAAP,CAhBqC;AAAA,KAAtC,C","file":"get-id-props.js"} \ No newline at end of file diff --git a/dist/amd/helpers/get-index-by-id.js b/dist/amd/helpers/get-index-by-id.js new file mode 100644 index 00000000..34711b73 --- /dev/null +++ b/dist/amd/helpers/get-index-by-id.js @@ -0,0 +1,14 @@ +/*can-connect@1.0.20#helpers/get-index-by-id*/ +define(function (require, exports, module) { + module.exports = function (connection, props, items) { + var id = connection.id(props); + for (var i = 0; i < items.length; i++) { + var connId = connection.id(items[i]); + if (id == connId) { + return i; + } + } + return -1; + }; +}); +//# sourceMappingURL=get-index-by-id.js.map \ No newline at end of file diff --git a/dist/amd/helpers/get-index-by-id.js.map b/dist/amd/helpers/get-index-by-id.js.map new file mode 100644 index 00000000..50993824 --- /dev/null +++ b/dist/amd/helpers/get-index-by-id.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../helpers/get-index-by-id.js"],"names":["module","exports","connection","props","items","id","i","length","connId"],"mappings":";;IACAA,MAAA,CAAOC,OAAP,GAAiB,UAASC,UAAT,EAAqBC,KAArB,EAA4BC,KAA5B,EAAkC;AAAA,QAClD,IAAIC,EAAA,GAAKH,UAAA,CAAWG,EAAX,CAAcF,KAAd,CAAT,CADkD;AAAA,QAGlD,KAAI,IAAIG,CAAA,GAAI,CAAR,CAAJ,CAAeA,CAAA,GAAIF,KAAA,CAAMG,MAAzB,EAAiCD,CAAA,EAAjC,EAAsC;AAAA,YACrC,IAAIE,MAAA,GAASN,UAAA,CAAWG,EAAX,CAAcD,KAAA,CAAME,CAAN,CAAd,CAAb,CADqC;AAAA,YAErC,IAAID,EAAA,IAAMG,MAAV,EAAkB;AAAA,gBACjB,OAAOF,CAAP,CADiB;AAAA,aAFmB;AAAA,SAHY;AAAA,QASlD,OAAO,CAAC,CAAR,CATkD;AAAA,KAAnD,C","file":"get-index-by-id.js"} \ No newline at end of file diff --git a/dist/amd/helpers/get-items.js b/dist/amd/helpers/get-items.js new file mode 100644 index 00000000..efbbb816 --- /dev/null +++ b/dist/amd/helpers/get-items.js @@ -0,0 +1,12 @@ +/*can-connect@1.0.20#helpers/get-items*/ +define(function (require, exports, module) { + var isArray = require('can-util/js/is-array'); + module.exports = function (data) { + if (isArray(data)) { + return data; + } else { + return data.data; + } + }; +}); +//# sourceMappingURL=get-items.js.map \ No newline at end of file diff --git a/dist/amd/helpers/get-items.js.map b/dist/amd/helpers/get-items.js.map new file mode 100644 index 00000000..b2af66c1 --- /dev/null +++ b/dist/amd/helpers/get-items.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../helpers/get-items.js"],"names":["isArray","require","module","exports","data"],"mappings":";;IAAA,IAAIA,OAAA,GAAUC,OAAA,CAAQ,sBAAR,CAAd,C;IAEAC,MAAA,CAAOC,OAAP,GAAiB,UAASC,IAAT,EAAc;AAAA,QAC9B,IAAGJ,OAAA,CAAQI,IAAR,CAAH,EAAkB;AAAA,YACjB,OAAOA,IAAP,CADiB;AAAA,SAAlB,MAEO;AAAA,YACN,OAAOA,IAAA,CAAKA,IAAZ,CADM;AAAA,SAHuB;AAAA,KAA/B,C","file":"get-items.js"} \ No newline at end of file diff --git a/dist/amd/helpers/id-merge.js b/dist/amd/helpers/id-merge.js new file mode 100644 index 00000000..6b33967a --- /dev/null +++ b/dist/amd/helpers/id-merge.js @@ -0,0 +1,41 @@ +/*can-connect@1.0.20#helpers/id-merge*/ +define(function (require, exports, module) { + var map = [].map; + module.exports = function (list, update, id, make) { + var listIndex = 0, updateIndex = 0; + while (listIndex < list.length && updateIndex < update.length) { + var listItem = list[listIndex], updateItem = update[updateIndex], lID = id(listItem), uID = id(updateItem); + if (id(listItem) === id(updateItem)) { + listIndex++; + updateIndex++; + continue; + } + if (updateIndex + 1 < update.length && id(update[updateIndex + 1]) === lID) { + list.splice(listIndex, 0, make(update[updateIndex])); + listIndex++; + updateIndex++; + continue; + } else if (listIndex + 1 < list.length && id(list[listIndex + 1]) === uID) { + list.splice(listIndex, 1); + listIndex++; + updateIndex++; + continue; + } else { + list.splice.apply(list, [ + listIndex, + list.length - listIndex + ].concat(map.call(update.slice(updateIndex), make))); + return list; + } + } + if (updateIndex === update.length && listIndex === list.length) { + return; + } + list.splice.apply(list, [ + listIndex, + list.length - listIndex + ].concat(map.call(update.slice(updateIndex), make))); + return; + }; +}); +//# sourceMappingURL=id-merge.js.map \ No newline at end of file diff --git a/dist/amd/helpers/id-merge.js.map b/dist/amd/helpers/id-merge.js.map new file mode 100644 index 00000000..a8da2d94 --- /dev/null +++ b/dist/amd/helpers/id-merge.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../helpers/id-merge.js"],"names":["map","module","exports","list","update","id","make","listIndex","updateIndex","length","listItem","updateItem","lID","uID","splice","apply","concat","call","slice"],"mappings":";;IAAA,IAAIA,GAAA,GAAM,GAAGA,GAAb,C;IAEAC,MAAA,CAAOC,OAAP,GAAiB,UAASC,IAAT,EAAeC,MAAf,EAAuBC,EAAvB,EAA2BC,IAA3B,EAAgC;AAAA,QAChD,IAAIC,SAAA,GAAY,CAAhB,EACCC,WAAA,GAAe,CADhB,CADgD;AAAA,QAIhD,OAAMD,SAAA,GAAYJ,IAAA,CAAKM,MAAjB,IAA2BD,WAAA,GAAcJ,MAAA,CAAOK,MAAtD,EAA8D;AAAA,YAC7D,IAAIC,QAAA,GAAWP,IAAA,CAAKI,SAAL,CAAf,EACCI,UAAA,GAAaP,MAAA,CAAOI,WAAP,CADd,EAECI,GAAA,GAAMP,EAAA,CAAGK,QAAH,CAFP,EAGCG,GAAA,GAAMR,EAAA,CAAGM,UAAH,CAHP,CAD6D;AAAA,YAK7D,IAAIN,EAAA,CAAGK,QAAH,MAAiBL,EAAA,CAAGM,UAAH,CAArB,EAAsC;AAAA,gBACrCJ,SAAA,GADqC;AAAA,gBAErCC,WAAA,GAFqC;AAAA,gBAGrC,SAHqC;AAAA,aALuB;AAAA,YAa7D,IAAKA,WAAA,GAAY,CAAZ,GAAgBJ,MAAA,CAAOK,MAAvB,IAAiCJ,EAAA,CAAGD,MAAA,CAAOI,WAAA,GAAY,CAAnB,CAAH,MAA8BI,GAApE,EAAyE;AAAA,gBACxET,IAAA,CAAKW,MAAL,CAAYP,SAAZ,EAAuB,CAAvB,EAA0BD,IAAA,CAAKF,MAAA,CAAOI,WAAP,CAAL,CAA1B,EADwE;AAAA,gBAExED,SAAA,GAFwE;AAAA,gBAGxEC,WAAA,GAHwE;AAAA,gBAIxE,SAJwE;AAAA,aAAzE,MAOK,IAAID,SAAA,GAAU,CAAV,GAAcJ,IAAA,CAAKM,MAAnB,IAA8BJ,EAAA,CAAGF,IAAA,CAAKI,SAAA,GAAU,CAAf,CAAH,MAA0BM,GAA5D,EAAkE;AAAA,gBACtEV,IAAA,CAAKW,MAAL,CAAYP,SAAZ,EAAuB,CAAvB,EADsE;AAAA,gBAEtEA,SAAA,GAFsE;AAAA,gBAGtEC,WAAA,GAHsE;AAAA,gBAItE,SAJsE;AAAA,aAAlE,MAOA;AAAA,gBACJL,IAAA,CAAKW,MAAL,CAAYC,KAAZ,CAAmBZ,IAAnB,EAAyB;AAAA,oBAACI,SAAD;AAAA,oBAAYJ,IAAA,CAAKM,MAAL,GAAYF,SAAxB;AAAA,kBAAmCS,MAAnC,CAA2ChB,GAAA,CAAIiB,IAAJ,CAASb,MAAA,CAAOc,KAAP,CAAaV,WAAb,CAAT,EAAoCF,IAApC,CAA3C,CAAzB,EADI;AAAA,gBAEJ,OAAOH,IAAP,CAFI;AAAA,aA3BwD;AAAA,SAJd;AAAA,QAoChD,IAAKK,WAAA,KAAgBJ,MAAA,CAAOK,MAAxB,IAAoCF,SAAA,KAAcJ,IAAA,CAAKM,MAA3D,EAAqE;AAAA,YACpE,OADoE;AAAA,SApCrB;AAAA,QAuChDN,IAAA,CAAKW,MAAL,CAAYC,KAAZ,CAAmBZ,IAAnB,EAAyB;AAAA,YAACI,SAAD;AAAA,YAAYJ,IAAA,CAAKM,MAAL,GAAYF,SAAxB;AAAA,UAAmCS,MAAnC,CAA2ChB,GAAA,CAAIiB,IAAJ,CAASb,MAAA,CAAOc,KAAP,CAAaV,WAAb,CAAT,EAAoCF,IAApC,CAA3C,CAAzB,EAvCgD;AAAA,QAwChD,OAxCgD;AAAA,KAAjD,C","file":"id-merge.js"} \ No newline at end of file diff --git a/dist/amd/helpers/overwrite.js b/dist/amd/helpers/overwrite.js new file mode 100644 index 00000000..3d016a7a --- /dev/null +++ b/dist/amd/helpers/overwrite.js @@ -0,0 +1,15 @@ +/*can-connect@1.0.20#helpers/overwrite*/ +define(function (require, exports, module) { + module.exports = function (d, s, id) { + for (var prop in d) { + if (prop !== id && !(prop in s)) { + delete d[prop]; + } + } + for (prop in s) { + d[prop] = s[prop]; + } + return d; + }; +}); +//# sourceMappingURL=overwrite.js.map \ No newline at end of file diff --git a/dist/amd/helpers/overwrite.js.map b/dist/amd/helpers/overwrite.js.map new file mode 100644 index 00000000..cf7385bc --- /dev/null +++ b/dist/amd/helpers/overwrite.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../helpers/overwrite.js"],"names":["module","exports","d","s","id","prop"],"mappings":";;IAAAA,MAAA,CAAOC,OAAP,GAAiB,UAASC,CAAT,EAAYC,CAAZ,EAAeC,EAAf,EAAkB;AAAA,QAClC,SAAQC,IAAR,IAAgBH,CAAhB,EAAmB;AAAA,YAClB,IAAIG,IAAA,KAASD,EAAT,IAAe,CAAE,CAAAC,IAAA,IAAQF,CAAR,CAArB,EAAiC;AAAA,gBAChC,OAAOD,CAAA,CAAEG,IAAF,CAAP,CADgC;AAAA,aADf;AAAA,SADe;AAAA,QAMlC,KAAIA,IAAJ,IAAYF,CAAZ,EAAe;AAAA,YACdD,CAAA,CAAEG,IAAF,IAAUF,CAAA,CAAEE,IAAF,CAAV,CADc;AAAA,SANmB;AAAA,QASlC,OAAOH,CAAP,CATkC;AAAA,KAAnC,C","file":"overwrite.js"} \ No newline at end of file diff --git a/dist/amd/helpers/set-add.js b/dist/amd/helpers/set-add.js new file mode 100644 index 00000000..337d6545 --- /dev/null +++ b/dist/amd/helpers/set-add.js @@ -0,0 +1,14 @@ +/*can-connect@1.0.20#helpers/set-add*/ +define(function (require, exports, module) { + var canSet = require('can-set'); + module.exports = function (connection, setItems, items, item, algebra) { + var index = canSet.index(setItems, items, item, algebra); + if (index === undefined) { + index = items.length; + } + var copy = items.slice(0); + copy.splice(index, 0, item); + return copy; + }; +}); +//# sourceMappingURL=set-add.js.map \ No newline at end of file diff --git a/dist/amd/helpers/set-add.js.map b/dist/amd/helpers/set-add.js.map new file mode 100644 index 00000000..e0be627c --- /dev/null +++ b/dist/amd/helpers/set-add.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../helpers/set-add.js"],"names":["canSet","require","module","exports","connection","setItems","items","item","algebra","index","undefined","length","copy","slice","splice"],"mappings":";;IAAA,IAAIA,MAAA,GAASC,OAAA,CAAQ,SAAR,CAAb,C;IAGAC,MAAA,CAAOC,OAAP,GAAiB,UAASC,UAAT,EAAqBC,QAArB,EAA+BC,KAA/B,EAAsCC,IAAtC,EAA4CC,OAA5C,EAAoD;AAAA,QACpE,IAAIC,KAAA,GAAQT,MAAA,CAAOS,KAAP,CAAaJ,QAAb,EAAuBC,KAAvB,EAA8BC,IAA9B,EAAoCC,OAApC,CAAZ,CADoE;AAAA,QAEpE,IAAGC,KAAA,KAAUC,SAAb,EAAwB;AAAA,YACvBD,KAAA,GAAQH,KAAA,CAAMK,MAAd,CADuB;AAAA,SAF4C;AAAA,QAMpE,IAAIC,IAAA,GAAON,KAAA,CAAMO,KAAN,CAAY,CAAZ,CAAX,CANoE;AAAA,QAOpED,IAAA,CAAKE,MAAL,CAAYL,KAAZ,EAAmB,CAAnB,EAAsBF,IAAtB,EAPoE;AAAA,QASpE,OAAOK,IAAP,CAToE;AAAA,KAArE,C","file":"set-add.js"} \ No newline at end of file diff --git a/dist/amd/helpers/sorted-set-json.js b/dist/amd/helpers/sorted-set-json.js new file mode 100644 index 00000000..2f7646f2 --- /dev/null +++ b/dist/amd/helpers/sorted-set-json.js @@ -0,0 +1,17 @@ +/*can-connect@1.0.20#helpers/sorted-set-json*/ +define(function (require, exports, module) { + var forEach = [].forEach; + var keys = Object.keys; + module.exports = function (set) { + if (set == null) { + return set; + } else { + var sorted = {}; + forEach.call(keys(set).sort(), function (prop) { + sorted[prop] = set[prop]; + }); + return JSON.stringify(sorted); + } + }; +}); +//# sourceMappingURL=sorted-set-json.js.map \ No newline at end of file diff --git a/dist/amd/helpers/sorted-set-json.js.map b/dist/amd/helpers/sorted-set-json.js.map new file mode 100644 index 00000000..a77bda87 --- /dev/null +++ b/dist/amd/helpers/sorted-set-json.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../helpers/sorted-set-json.js"],"names":["forEach","keys","Object","module","exports","set","sorted","call","sort","prop","JSON","stringify"],"mappings":";;IAAA,IAAIA,OAAA,GAAU,GAAGA,OAAjB,C;IACA,IAAIC,IAAA,GAAOC,MAAA,CAAOD,IAAlB,C;IAEAE,MAAA,CAAOC,OAAP,GAAiB,UAASC,GAAT,EAAa;AAAA,QAC7B,IAAGA,GAAA,IAAO,IAAV,EAAgB;AAAA,YACf,OAAOA,GAAP,CADe;AAAA,SAAhB,MAEO;AAAA,YACN,IAAIC,MAAA,GAAS,EAAb,CADM;AAAA,YAENN,OAAA,CAAQO,IAAR,CAAaN,IAAA,CAAKI,GAAL,EAAUG,IAAV,EAAb,EAA+B,UAASC,IAAT,EAAc;AAAA,gBAC5CH,MAAA,CAAOG,IAAP,IAAeJ,GAAA,CAAII,IAAJ,CAAf,CAD4C;AAAA,aAA7C,EAFM;AAAA,YAKN,OAAOC,IAAA,CAAKC,SAAL,CAAeL,MAAf,CAAP,CALM;AAAA,SAHsB;AAAA,KAA9B,C","file":"sorted-set-json.js"} \ No newline at end of file diff --git a/dist/amd/helpers/weak-reference-map.js b/dist/amd/helpers/weak-reference-map.js new file mode 100644 index 00000000..70ab4041 --- /dev/null +++ b/dist/amd/helpers/weak-reference-map.js @@ -0,0 +1,45 @@ +/*can-connect@1.0.20#helpers/weak-reference-map*/ +define(function (require, exports, module) { + var assign = require('can-util/js/assign'); + var WeakReferenceMap = function () { + this.set = {}; + }; + assign(WeakReferenceMap.prototype, { + has: function (key) { + return !!this.set[key]; + }, + addReference: function (key, item) { + var data = this.set[key]; + if (!data) { + data = this.set[key] = { + item: item, + referenceCount: 0, + key: key + }; + } + data.referenceCount++; + }, + deleteReference: function (key) { + var data = this.set[key]; + if (data) { + data.referenceCount--; + if (data.referenceCount === 0) { + delete this.set[key]; + } + } + }, + get: function (key) { + var data = this.set[key]; + if (data) { + return data.item; + } + }, + forEach: function (cb) { + for (var id in this.set) { + cb(this.set[id].item, id); + } + } + }); + module.exports = WeakReferenceMap; +}); +//# sourceMappingURL=weak-reference-map.js.map \ No newline at end of file diff --git a/dist/amd/helpers/weak-reference-map.js.map b/dist/amd/helpers/weak-reference-map.js.map new file mode 100644 index 00000000..3b57631b --- /dev/null +++ b/dist/amd/helpers/weak-reference-map.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../helpers/weak-reference-map.js"],"names":["assign","require","WeakReferenceMap","set","prototype","has","key","addReference","item","data","referenceCount","deleteReference","get","forEach","cb","id","module","exports"],"mappings":";;IAAA,IAAIA,MAAA,GAASC,OAAA,CAAQ,oBAAR,CAAb,C;IAgCA,IAAIC,gBAAA,GAAmB,YAAU;AAAA,QAChC,KAAKC,GAAL,GAAW,EAAX,CADgC;AAAA,KAAjC,C;IAOAH,MAAA,CAAOE,gBAAA,CAAiBE,SAAxB,EAIC;AAAA,QAUAC,GAAA,EAAK,UAASC,GAAT,EAAa;AAAA,YACjB,OAAO,CAAC,CAAC,KAAKH,GAAL,CAASG,GAAT,CAAT,CADiB;AAAA,SAVlB;AAAA,QAsBAC,YAAA,EAAc,UAASD,GAAT,EAAcE,IAAd,EAAmB;AAAA,YAChC,IAAIC,IAAA,GAAO,KAAKN,GAAL,CAASG,GAAT,CAAX,CADgC;AAAA,YAEhC,IAAG,CAACG,IAAJ,EAAU;AAAA,gBACTA,IAAA,GAAO,KAAKN,GAAL,CAASG,GAAT,IAAgB;AAAA,oBACtBE,IAAA,EAAMA,IADgB;AAAA,oBAEtBE,cAAA,EAAgB,CAFM;AAAA,oBAGtBJ,GAAA,EAAKA,GAHiB;AAAA,iBAAvB,CADS;AAAA,aAFsB;AAAA,YAShCG,IAAA,CAAKC,cAAL,GATgC;AAAA,SAtBjC;AAAA,QA0CAC,eAAA,EAAiB,UAASL,GAAT,EAAa;AAAA,YAC7B,IAAIG,IAAA,GAAO,KAAKN,GAAL,CAASG,GAAT,CAAX,CAD6B;AAAA,YAE7B,IAAGG,IAAH,EAAQ;AAAA,gBACPA,IAAA,CAAKC,cAAL,GADO;AAAA,gBAEP,IAAID,IAAA,CAAKC,cAAL,KAAwB,CAA5B,EAAgC;AAAA,oBAC/B,OAAO,KAAKP,GAAL,CAASG,GAAT,CAAP,CAD+B;AAAA,iBAFzB;AAAA,aAFqB;AAAA,SA1C9B;AAAA,QA4DAM,GAAA,EAAK,UAASN,GAAT,EAAa;AAAA,YACjB,IAAIG,IAAA,GAAO,KAAKN,GAAL,CAASG,GAAT,CAAX,CADiB;AAAA,YAEjB,IAAGG,IAAH,EAAS;AAAA,gBACR,OAAOA,IAAA,CAAKD,IAAZ,CADQ;AAAA,aAFQ;AAAA,SA5DlB;AAAA,QA0EAK,OAAA,EAAS,UAASC,EAAT,EAAY;AAAA,YACpB,SAAQC,EAAR,IAAc,KAAKZ,GAAnB,EAAwB;AAAA,gBACvBW,EAAA,CAAG,KAAKX,GAAL,CAASY,EAAT,EAAaP,IAAhB,EAAsBO,EAAtB,EADuB;AAAA,aADJ;AAAA,SA1ErB;AAAA,KAJD,E;IAqFAC,MAAA,CAAOC,OAAP,GAAiBf,gBAAjB,C","file":"weak-reference-map.js"} \ No newline at end of file diff --git a/dist/amd/real-time/real-time.js b/dist/amd/real-time/real-time.js new file mode 100644 index 00000000..5477f8d5 --- /dev/null +++ b/dist/amd/real-time/real-time.js @@ -0,0 +1,143 @@ +/*can-connect@1.0.20#real-time/real-time*/ +define(function (require, exports, module) { + var connect = require('../can-connect'); + var canSet = require('can-set'); + var setAdd = require('../helpers/set-add'); + var indexOf = require('../helpers/get-index-by-id'); + var canDev = require('can-util/js/dev'); + module.exports = connect.behavior('real-time', function (baseConnection) { + return { + createInstance: function (props) { + var id = this.id(props); + var instance = this.instanceStore.get(id); + var serialized; + if (instance) { + return this.updateInstance(props); + } else { + instance = this.hydrateInstance(props); + serialized = this.serializeInstance(instance); + var self = this; + this.addInstanceReference(instance); + return Promise.resolve(this.createdData(props, serialized)).then(function () { + self.deleteInstanceReference(instance); + return instance; + }); + } + }, + createdData: function (props, params, cid) { + var instance; + if (cid !== undefined) { + instance = this.cidStore.get(cid); + } else { + instance = this.instanceStore.get(this.id(props)); + } + this.addInstanceReference(instance, this.id(props)); + this.createdInstance(instance, props); + create.call(this, this.serializeInstance(instance)); + this.deleteInstanceReference(instance); + return undefined; + }, + updatedData: function (props, params) { + var instance = this.instanceStore.get(this.id(params)); + this.updatedInstance(instance, props); + update.call(this, this.serializeInstance(instance)); + return undefined; + }, + updateInstance: function (props) { + var id = this.id(props); + var instance = this.instanceStore.get(id); + if (!instance) { + instance = this.hydrateInstance(props); + } + this.addInstanceReference(instance); + var serialized = this.serializeInstance(instance), self = this; + return Promise.resolve(this.updatedData(props, serialized)).then(function () { + self.deleteInstanceReference(instance); + return instance; + }); + }, + destroyedData: function (props, params) { + var id = this.id(params || props); + var instance = this.instanceStore.get(id); + if (!instance) { + instance = this.hydrateInstance(props); + } + var serialized = this.serializeInstance(instance); + this.destroyedInstance(instance, props); + destroy.call(this, serialized); + return undefined; + }, + destroyInstance: function (props) { + var id = this.id(props); + var instance = this.instanceStore.get(id); + if (!instance) { + instance = this.hydrateInstance(props); + } + this.addInstanceReference(instance); + var serialized = this.serializeInstance(instance), self = this; + return Promise.resolve(this.destroyedData(props, serialized)).then(function () { + self.deleteInstanceReference(instance); + return instance; + }); + } + }; + }); + var create = function (props) { + var self = this; + this.listStore.forEach(function (list, id) { + var set = JSON.parse(id); + var index = indexOf(self, props, list); + if (canSet.has(set, props, self.algebra)) { + if (index === -1) { + var items = self.serializeList(list); + self.updatedList(list, { data: setAdd(self, set, items, props, self.algebra) }, set); + } else { + } + } + }); + }; + var update = function (props) { + var self = this; + this.listStore.forEach(function (list, id) { + var items; + var set = JSON.parse(id); + var index = indexOf(self, props, list); + if (canSet.has(set, props, self.algebra)) { + items = self.serializeList(list); + if (index === -1) { + self.updatedList(list, { data: setAdd(self, set, items, props, self.algebra) }, set); + } else { + var sortedIndex = canSet.index(set, items, props, self.algebra); + if (sortedIndex !== undefined && sortedIndex !== index) { + var copy = items.slice(0); + if (index < sortedIndex) { + copy.splice(sortedIndex, 0, props); + copy.splice(index, 1); + } else { + copy.splice(index, 1); + copy.splice(sortedIndex, 0, props); + } + self.updatedList(list, { data: copy }, set); + } + } + } else if (index !== -1) { + items = self.serializeList(list); + items.splice(index, 1); + self.updatedList(list, { data: items }, set); + } + }); + }; + var destroy = function (props) { + var self = this; + this.listStore.forEach(function (list, id) { + var set = JSON.parse(id); + var index = indexOf(self, props, list); + if (index !== -1) { + var items = self.serializeList(list); + items.splice(index, 1); + self.updatedList(list, { data: items }, set); + } + }); + }; +}); +//# sourceMappingURL=real-time.js.map \ No newline at end of file diff --git a/dist/amd/real-time/real-time.js.map b/dist/amd/real-time/real-time.js.map new file mode 100644 index 00000000..ebe525cb --- /dev/null +++ b/dist/amd/real-time/real-time.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../real-time/real-time.js"],"names":["connect","require","canSet","setAdd","indexOf","canDev","module","exports","behavior","baseConnection","createInstance","props","id","instance","instanceStore","get","serialized","updateInstance","hydrateInstance","serializeInstance","self","addInstanceReference","Promise","resolve","createdData","then","deleteInstanceReference","params","cid","undefined","cidStore","createdInstance","create","call","updatedData","updatedInstance","update","destroyedData","destroyedInstance","destroy","destroyInstance","listStore","forEach","list","set","JSON","parse","index","has","algebra","items","serializeList","updatedList","data","sortedIndex","copy","slice","splice"],"mappings":";;IA+HA,IAAIA,OAAA,GAAUC,OAAA,CAAQ,gBAAR,CAAd,C;IACA,IAAIC,MAAA,GAASD,OAAA,CAAQ,SAAR,CAAb,C;IACA,IAAIE,MAAA,GAASF,OAAA,CAAQ,oBAAR,CAAb,C;IACA,IAAIG,OAAA,GAAUH,OAAA,CAAQ,4BAAR,CAAd,C;IACA,IAAII,MAAA,GAASJ,OAAA,CAAQ,iBAAR,CAAb,C;IAEAK,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f,CAAuB,UAASC,IAAT,EAAe/B,EAAf,EAAkB;AAAA,YACxC,IAAIgC,GAAA,GAAMC,IAAA,CAAKC,KAAL,CAAWlC,EAAX,CAAV,CADwC;AAAA,YAIxC,IAAImC,KAAA,GAAQ3C,OAAA,CAAQgB,IAAR,EAAcT,KAAd,EAAqBgC,IAArB,CAAZ,CAJwC;AAAA,YAMxC,IAAGI,KAAA,KAAU,CAAC,CAAd,EAAgB;AAAA,gBAEf,IAAIG,KAAA,GAAQ9B,IAAA,CAAK+B,aAAL,CAAmBR,IAAnB,CAAZ,CAFe;AAAA,gBAGfO,KAAA,CAAMO,MAAN,CAAaV,KAAb,EAAmB,CAAnB,EAHe;AAAA,gBAIf3B,IAAA,CAAKgC,WAAL,CAAiBT,IAAjB,EAAwB,EAAEU,IAAA,EAAMH,KAAR,EAAxB,EAAyCN,GAAzC,EAJe;AAAA,aANwB;AAAA,SAAzC,EAF6B;AAAA,KAA9B,C","file":"real-time.js"} \ No newline at end of file diff --git a/dist/cjs/all.js b/dist/cjs/all.js new file mode 100644 index 00000000..7c3d4ecb --- /dev/null +++ b/dist/cjs/all.js @@ -0,0 +1,20 @@ +/*can-connect@1.0.20#all*/ +var connect = require('./can-connect.js'); +connect.cacheRequests = require('./cache-requests/cache-requests.js'); +connect.constructor = require('./constructor/constructor.js'); +connect.constructorCallbacksOnce = require('./constructor/callbacks-once/callbacks-once.js'); +connect.constructorStore = require('./constructor/store/store.js'); +connect.dataCallbacks = require('./data/callbacks/callbacks.js'); +connect.dataCallbacksCache = require('./data/callbacks-cache/callbacks-cache.js'); +connect.dataCombineRequests = require('./data/combine-requests/combine-requests.js'); +connect.dataLocalStorageCache = require('./data/localstorage-cache/localstorage-cache.js'); +connect.dataMemoryCache = require('./data/memory-cache/memory-cache.js'); +connect.dataParse = require('./data/parse/parse.js'); +connect.dataUrl = require('./data/url/url.js'); +connect.fallThroughCache = require('./fall-through-cache/fall-through-cache.js'); +connect.realTime = require('./real-time/real-time.js'); +connect.superMap = require('./can/super-map/super-map.js'); +connect.tag = require('./can/tag/tag.js'); +connect.baseMap = require('./can/base-map/base-map.js'); +module.exports = connect; +//# sourceMappingURL=all.js.map \ No newline at end of file diff --git a/dist/cjs/all.js.map b/dist/cjs/all.js.map new file mode 100644 index 00000000..76bc1a37 --- /dev/null +++ b/dist/cjs/all.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../all.js"],"names":["connect","require","cacheRequests","constructor","constructorCallbacksOnce","constructorStore","dataCallbacks","dataCallbacksCache","dataCombineRequests","dataLocalStorageCache","dataMemoryCache","dataParse","dataUrl","fallThroughCache","realTime","superMap","tag","baseMap","module","exports"],"mappings":";AAAA,IAAIA,OAAA,GAAUC,OAAA,CAAQ,kBAAR,CAAd;AAEAD,OAAA,CAAQE,aAAR,GAAwBD,OAAA,CAAQ,oCAAR,CAAxB,CAFA;AAIAD,OAAA,CAAQG,WAAR,GAAsBF,OAAA,CAAQ,8BAAR,CAAtB,CAJA;AAKAD,OAAA,CAAQI,wBAAR,GAAmCH,OAAA,CAAQ,gDAAR,CAAnC,CALA;AAMAD,OAAA,CAAQK,gBAAR,GAA2BJ,OAAA,CAAQ,8BAAR,CAA3B,CANA;AAOAD,OAAA,CAAQM,aAAR,GAAwBL,OAAA,CAAQ,+BAAR,CAAxB,CAPA;AAQAD,OAAA,CAAQO,kBAAR,GAA6BN,OAAA,CAAQ,2CAAR,CAA7B,CARA;AASAD,OAAA,CAAQQ,mBAAR,GAA8BP,OAAA,CAAQ,6CAAR,CAA9B,CATA;AAUAD,OAAA,CAAQS,qBAAR,GAAgCR,OAAA,CAAQ,iDAAR,CAAhC,CAVA;AAWAD,OAAA,CAAQU,eAAR,GAA0BT,OAAA,CAAQ,qCAAR,CAA1B,CAXA;AAYAD,OAAA,CAAQW,SAAR,GAAoBV,OAAA,CAAQ,uBAAR,CAApB,CAZA;AAaAD,OAAA,CAAQY,OAAR,GAAkBX,OAAA,CAAQ,mBAAR,CAAlB,CAbA;AAcAD,OAAA,CAAQa,gBAAR,GAA2BZ,OAAA,CAAQ,4CAAR,CAA3B,CAdA;AAeAD,OAAA,CAAQc,QAAR,GAAmBb,OAAA,CAAQ,0BAAR,CAAnB,CAfA;AAiBAD,OAAA,CAAQe,QAAR,GAAmBd,OAAA,CAAQ,8BAAR,CAAnB,CAjBA;AAkBAD,OAAA,CAAQgB,GAAR,GAAcf,OAAA,CAAQ,kBAAR,CAAd,CAlBA;AAmBAD,OAAA,CAAQiB,OAAR,GAAkBhB,OAAA,CAAQ,4BAAR,CAAlB,CAnBA;AAqBAiB,MAAA,CAAOC,OAAP,GAAiBnB,OAAjB","file":"all.js"} \ No newline at end of file diff --git a/dist/cjs/base/base.js b/dist/cjs/base/base.js new file mode 100644 index 00000000..bc94435c --- /dev/null +++ b/dist/cjs/base/base.js @@ -0,0 +1,29 @@ +/*can-connect@1.0.20#base/base*/ +var connect = require('../connect.js'); +module.exports = connect.behavior('base', function (baseConnection) { + return { + id: function (instance) { + var ids = [], algebra = this.algebra; + if (algebra && algebra.clauses && algebra.clauses.id) { + for (var prop in algebra.clauses.id) { + ids.push(instance[prop]); + } + } + if (this.idProp && !ids.length) { + ids.push(instance[this.idProp]); + } + if (!ids.length) { + ids.push(instance.id); + } + return ids.length > 1 ? ids.join('@|@') : ids[0]; + }, + idProp: baseConnection.idProp || 'id', + listSet: function (list) { + return list[this.listSetProp]; + }, + listSetProp: '__listSet', + init: function () { + } + }; +}); +//# sourceMappingURL=base.js.map \ No newline at end of file diff --git a/dist/cjs/base/base.js.map b/dist/cjs/base/base.js.map new file mode 100644 index 00000000..6356399f --- /dev/null +++ b/dist/cjs/base/base.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../base/base.js"],"names":["connect","require","module","exports","behavior","baseConnection","id","instance","ids","algebra","clauses","prop","push","idProp","length","join","listSet","list","listSetProp","init"],"mappings":";AAAA,IAAIA,OAAA,GAAUC,OAAA,CAAQ,eAAR,CAAd;AAyBAC,MAAA,CAAOC,OAAP,G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":"base.js"} \ No newline at end of file diff --git a/dist/cjs/cache-requests/cache-requests.js b/dist/cjs/cache-requests/cache-requests.js new file mode 100644 index 00000000..71e553c7 --- /dev/null +++ b/dist/cjs/cache-requests/cache-requests.js @@ -0,0 +1,82 @@ +/*can-connect@1.0.20#cache-requests/cache-requests*/ +var connect = require('../can-connect.js'); +var getItems = require('../helpers/get-items.js'); +var canSet = require('can-set'); +var forEach = [].forEach; +module.exports = connect.behavior('cache-requests', function (baseConnection) { + return { + getDiff: function (params, availableSets) { + var minSets, self = this; + forEach.call(availableSets, function (set) { + var curSets; + var difference = canSet.difference(params, set, self.algebra); + if (typeof difference === 'object') { + curSets = { + needed: difference, + cached: canSet.intersection(params, set, self.algebra), + count: canSet.count(difference, self.algebra) + }; + } else if (canSet.subset(params, set, self.algebra)) { + curSets = { + cached: params, + count: 0 + }; + } + if (curSets) { + if (!minSets || curSets.count < minSets.count) { + minSets = curSets; + } + } + }); + if (!minSets) { + return { needed: params }; + } else { + return { + needed: minSets.needed, + cached: minSets.cached + }; + } + }, + getUnion: function (params, diff, neededItems, cachedItems) { + return { data: canSet.getUnion(diff.needed, diff.cached, getItems(neededItems), getItems(cachedItems), this.algebra) }; + }, + getListData: function (set) { + set = set || {}; + var self = this; + return this.cacheConnection.getSets(set).then(function (sets) { + var diff = self.getDiff(set, sets); + if (!diff.needed) { + return self.cacheConnection.getListData(diff.cached); + } else if (!diff.cached) { + return baseConnection.getListData(diff.needed).then(function (data) { + return self.cacheConnection.updateListData(getItems(data), diff.needed).then(function () { + return data; + }); + }); + } else { + var cachedPromise = self.cacheConnection.getListData(diff.cached); + var needsPromise = baseConnection.getListData(diff.needed); + var savedPromise = needsPromise.then(function (data) { + return self.cacheConnection.updateListData(getItems(data), diff.needed).then(function () { + return data; + }); + }); + var combinedPromise = Promise.all([ + cachedPromise, + needsPromise + ]).then(function (result) { + var cached = result[0], needed = result[1]; + return self.getUnion(set, diff, needed, cached); + }); + return Promise.all([ + combinedPromise, + savedPromise + ]).then(function (data) { + return data[0]; + }); + } + }); + } + }; +}); +//# sourceMappingURL=cache-requests.js.map \ No newline at end of file diff --git a/dist/cjs/cache-requests/cache-requests.js.map b/dist/cjs/cache-requests/cache-requests.js.map new file mode 100644 index 00000000..574e2983 --- /dev/null +++ b/dist/cjs/cache-requests/cache-requests.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../cache-requests/cache-requests.js"],"names":["connect","require","getItems","canSet","forEach","module","exports","behavior","baseConnection","getDiff","params","availableSets","minSets","self","call","set","curSets","difference","algebra","needed","cached","intersection","count","subset","getUnion","diff","neededItems","cachedItems","data","getListData","cacheConnection","getSets","then","sets","updateListData","cachedPromise","needsPromise","savedPromise","combinedPromise","Promise","all","result"],"mappings":";AACA,IAAIA,OAAA,GAAUC,OAAA,CAAQ,mBAAR,CAAd;AACA,IAAIC,QAAA,GAAWD,OAAA,CAAQ,yBAAR,CAAf,CADA;AAEA,IAAIE,MAAA,GAASF,OAAA,CAAQ,SAAR,CAAb,CAFA;AAGA,IAAIG,OAAA,GAAU,GAAGA,OAAjB,CAHA;AAiGAC,MAAA,CAAOC,OAAP,GAAiBN,OAAA,CAAQO,QAAR,CAAiB,gBAAjB,EAAkC,UAASC,cAAT,EAAwB;AAAA,IAE1E,OAAO;AAAA,QA2CNC,OAAA,EAAS,UAAUC,MAAV,EAAkBC,aAAlB,EAAiC;AAAA,YAEzC,IAAIC,OAAJ,EACCC,IAAA,GAAO,IADR,CAFyC;AAAA,YAKzCT,OAAA,CAAQU,IAAR,CAAaH,aAAb,EAA4B,UAASI,GAAT,EAAa;AAAA,gBACxC,IAAIC,OAAJ,CADwC;AAAA,gBAExC,IAAIC,UAAA,GAAad,MAAA,CAAOc,UAAP,CAAkBP,MAAlB,EAA0BK,GAA1B,EAA+BF,IAAA,CAAKK,OAApC,CAAjB,CAFwC;AAAA,gBAGxC,IAAG,OAAOD,UAAP,KAAsB,QAAzB,EAAmC;AAAA,oBAClCD,OAAA,GAAU;AAAA,wBAC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IAAIkB,YAAA,GAAeD,YAAA,CAAaJ,IAAb,CAAkB,UAASJ,IAAT,EAAc;AAAA,wBAClD,OAAOf,IAAA,CAAKiB,eAAL,CAAqBI,cAArB,CAAsChC,QAAA,CAAS0B,IAAT,CAAtC,EAAsDH,IAAA,CAAKN,MAA3D,EAAoEa,IAApE,CAAyE,YAAU;AAAA,4BACzF,OAAOJ,IAAP,CADyF;AAAA,yBAAnF,CAAP,CADkD;AAAA,qBAAhC,CAAnB,CAJM;AAAA,oBAUN,IAAIU,eAAA,GAAkBC,OAAA,CAAQC,GAAR,CAAY;AAAA,wBACjCL,aADiC;AAAA,wBAEjCC,YAFiC;AAAA,qBAAZ,EAGnBJ,IAHmB,CAGd,UAASS,MAAT,EAAgB;AAAA,wBACvB,IAAIrB,MAAA,GAASqB,MAAA,CAAO,CAAP,CAAb,EACCtB,MAAA,GAASsB,MAAA,CAAO,CAAP,CADV,CADuB;AAAA,wBAGvB,OAAO5B,IAAA,CAAKW,QAAL,CAAeT,GAAf,EAAoBU,IAApB,EAA0BN,MAA1B,EAAkCC,MAAlC,CAAP,CAHuB;AAAA,qBAHF,CAAtB,CAVM;AAAA,oBAmBN,OAAOmB,OAAA,CAAQC,GAAR,CAAY;AAAA,wBAACF,eAAD;AAAA,wBAAkBD,YAAlB;AAAA,qBAAZ,EAA6CL,IAA7C,CAAkD,UAASJ,IAAT,EAAc;AAAA,wBACtE,OAAOA,IAAA,CAAK,CAAL,CAAP,CADsE;AAAA,qBAAhE,CAAP,CAnBM;AAAA,iBAdoD;AAAA,aAArD,CAAP,CAJyB;AAAA,SAxHpB;AAAA,KAAP,CAF0E;AAAA,CAA1D,CAAjB","file":"cache-requests.js"} \ No newline at end of file diff --git a/dist/cjs/can-connect.js b/dist/cjs/can-connect.js new file mode 100644 index 00000000..b6b82d84 --- /dev/null +++ b/dist/cjs/can-connect.js @@ -0,0 +1,7 @@ +/*can-connect@1.0.20#can-connect*/ +var connect = require('./connect.js'); +var base = require('./base/base.js'); +var ns = require('can-namespace'); +connect.base = base; +module.exports = ns.connect = connect; +//# sourceMappingURL=can-connect.js.map \ No newline at end of file diff --git a/dist/cjs/can-connect.js.map b/dist/cjs/can-connect.js.map new file mode 100644 index 00000000..de1ddacc --- /dev/null +++ b/dist/cjs/can-connect.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../can-connect.js"],"names":["connect","require","base","ns","module","exports"],"mappings":";AAAA,IAAIA,OAAA,GAAUC,OAAA,CAAQ,cAAR,CAAd;AACA,IAAIC,IAAA,GAAOD,OAAA,CAAQ,gBAAR,CAAX,CADA;AAEA,IAAIE,EAAA,GAAKF,OAAA,CAAQ,eAAR,CAAT,CAFA;AAIAD,OAAA,CAAQE,IAAR,GAAeA,IAAf,CAJA;AAMAE,MAAA,CAAOC,OAAP,GAAiBF,EAAA,CAAGH,OAAH,GAAaA,OAA9B","file":"can-connect.js"} \ No newline at end of file diff --git a/dist/cjs/can/base-map/base-map.js b/dist/cjs/can/base-map/base-map.js new file mode 100644 index 00000000..79d96ce1 --- /dev/null +++ b/dist/cjs/can/base-map/base-map.js @@ -0,0 +1,32 @@ +/*can-connect@1.0.20#can/base-map/base-map*/ +var connect = require('../../can-connect.js'); +var constructor = require('../../constructor/constructor.js'); +var canMap = require('../map/map.js'); +var canRef = require('../ref/ref.js'); +var constructorStore = require('../../constructor/store/store.js'); +var dataCallbacks = require('../../data/callbacks/callbacks.js'); +var callbacksCache = require('../../data/callbacks-cache/callbacks-cache.js'); +var dataParse = require('../../data/parse/parse.js'); +var dataUrl = require('../../data/url/url.js'); +var realTime = require('../../real-time/real-time.js'); +var callbacksOnce = require('../../constructor/callbacks-once/callbacks-once.js'); +var $ = require('jquery'); +connect.baseMap = function (options) { + var behaviors = [ + constructor, + canMap, + canRef, + constructorStore, + dataCallbacks, + dataParse, + dataUrl, + realTime, + callbacksOnce + ]; + if ($ && $.ajax) { + options.ajax = $.ajax; + } + return connect(behaviors, options); +}; +module.exports = connect.baseMap; +//# sourceMappingURL=base-map.js.map \ No newline at end of file diff --git a/dist/cjs/can/base-map/base-map.js.map b/dist/cjs/can/base-map/base-map.js.map new file mode 100644 index 00000000..85481fc4 --- /dev/null +++ b/dist/cjs/can/base-map/base-map.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../../can/base-map/base-map.js"],"names":["connect","require","constructor","canMap","canRef","constructorStore","dataCallbacks","callbacksCache","dataParse","dataUrl","realTime","callbacksOnce","$","baseMap","options","behaviors","ajax","module","exports"],"mappings":";AAAA,IAAIA,OAAA,GAAUC,OAAA,CAAQ,sBAAR,CAAd;AAEA,IAAIC,WAAA,GAAcD,OAAA,CAAQ,kCAAR,CAAlB,CAFA;AAGA,IAAIE,MAAA,GAASF,OAAA,CAAQ,eAAR,CAAb,CAHA;AAIA,IAAIG,MAAA,GAASH,OAAA,CAAQ,eAAR,CAAb,CAJA;AAKA,IAAII,gBAAA,GAAmBJ,OAAA,CAAQ,kCAAR,CAAvB,CALA;AAMA,IAAIK,aAAA,GAAgBL,OAAA,CAAQ,mCAAR,CAApB,CANA;AAOA,IAAIM,cAAA,GAAiBN,OAAA,CAAQ,+CAAR,CAArB,CAPA;AAQA,IAAIO,SAAA,GAAYP,OAAA,CAAQ,2BAAR,CAAhB,CARA;AASA,IAAIQ,OAAA,GAAUR,OAAA,CAAQ,uBAAR,CAAd,CATA;AAUA,IAAIS,QAAA,GAAWT,OAAA,CAAQ,8BAAR,CAAf,CAVA;AAWA,IAAIU,aAAA,GAAgBV,OAAA,CAAQ,oDAAR,CAApB,CAXA;AAcA,IAAIW,CAAA,GAAIX,OAAA,CAAQ,QAAR,CAAR,CAdA;AAgBAD,OAAA,CAAQa,OAAR,GAAkB,UAASC,OAAT,EAAiB;AAAA,IAElC,IAAIC,SAAA,GAAY;AAAA,QACfb,WADe;AAAA,QAEfC,MAFe;AAAA,QAGfC,MAHe;AAAA,QAIfC,gBAJe;AAAA,QAKfC,aALe;AAAA,QAMfE,SANe;AAAA,QAOfC,OAPe;AAAA,QAQfC,QARe;AAAA,QASfC,aATe;AAAA,KAAhB,CAFkC;AAAA,IAelC,IAAGC,CAAA,IAAKA,CAAA,CAAEI,IAAV,EAAgB;AAAA,QACfF,OAAA,CAAQE,IAAR,GAAeJ,CAAA,CAAEI,IAAjB,CADe;AAAA,KAfkB;AAAA,IAmBlC,OAAOhB,OAAA,CAAQe,SAAR,EAAkBD,OAAlB,CAAP,CAnBkC;AAAA,CAAnC,CAhBA;AAsCAG,MAAA,CAAOC,OAAP,GAAiBlB,OAAA,CAAQa,OAAzB","file":"base-map.js"} \ No newline at end of file diff --git a/dist/cjs/can/map/map.js b/dist/cjs/can/map/map.js new file mode 100644 index 00000000..64479715 --- /dev/null +++ b/dist/cjs/can/map/map.js @@ -0,0 +1,299 @@ +/*can-connect@1.0.20#can/map/map*/ +'use strict'; +var each = require('can-util/js/each/each'); +var connect = require('../../can-connect.js'); +var canBatch = require('can-event/batch/batch'); +var canEvent = require('can-event'); +var Observation = require('can-observation'); +var isPlainObject = require('can-util/js/is-plain-object/is-plain-object'); +var isArray = require('can-util/js/is-array/is-array'); +var types = require('can-types'); +var each = require('can-util/js/each/each'); +var isFunction = require('can-util/js/is-function/is-function'); +var dev = require('can-util/js/dev/dev'); +var setExpando = function (map, prop, value) { + if ('attr' in map) { + map[prop] = value; + } else { + map._data[prop] = value; + } +}; +var getExpando = function (map, prop) { + if ('attr' in map) { + return map[prop]; + } else { + return map._data[prop]; + } +}; +module.exports = connect.behavior('can/map', function (baseConnection) { + var behavior = { + init: function () { + this.Map = this.Map || types.DefaultMap.extend({}); + this.List = this.List || types.DefaultList.extend({}); + overwrite(this, this.Map, mapOverwrites, mapStaticOverwrites); + overwrite(this, this.List, listPrototypeOverwrites, listStaticOverwrites); + baseConnection.init.apply(this, arguments); + }, + id: function (instance) { + if (!isPlainObject(instance)) { + var ids = [], algebra = this.algebra; + if (algebra && algebra.clauses && algebra.clauses.id) { + for (var prop in algebra.clauses.id) { + ids.push(readObservabe(instance, prop)); + } + } + if (this.idProp && !ids.length) { + ids.push(readObservabe(instance, this.idProp)); + } + if (!ids.length) { + ids.push(readObservabe(instance, 'id')); + } + return ids.length > 1 ? ids.join('@|@') : ids[0]; + } else { + return baseConnection.id(instance); + } + }, + serializeInstance: function (instance) { + return instance.serialize(); + }, + serializeList: function (list) { + return list.serialize(); + }, + instance: function (props) { + var _Map = this.Map || types.DefaultMap; + return new _Map(props); + }, + list: function (listData, set) { + var _List = this.List || this.Map && this.Map.List || types.DefaultList; + var list = new _List(listData.data); + each(listData, function (val, prop) { + if (prop !== 'data') { + list[list.set ? 'set' : 'attr'](prop, val); + } + }); + list.__listSet = set; + return list; + }, + updatedList: function () { + canBatch.start(); + var res = baseConnection.updatedList.apply(this, arguments); + canBatch.stop(); + return res; + }, + save: function (instance) { + setExpando(instance, '_saving', true); + canEvent.dispatch.call(instance, '_saving', [ + true, + false + ]); + var done = function () { + setExpando(instance, '_saving', false); + canEvent.dispatch.call(instance, '_saving', [ + false, + true + ]); + }; + var base = baseConnection.save.apply(this, arguments); + base.then(done, done); + return base; + }, + destroy: function (instance) { + setExpando(instance, '_destroying', true); + canEvent.dispatch.call(instance, '_destroying', [ + true, + false + ]); + var done = function () { + setExpando(instance, '_destroying', false); + canEvent.dispatch.call(instance, '_destroying', [ + false, + true + ]); + }; + var base = baseConnection.destroy.apply(this, arguments); + base.then(done, done); + return base; + } + }; + each([ + 'created', + 'updated', + 'destroyed' + ], function (funcName) { + behavior[funcName + 'Instance'] = function (instance, props) { + var constructor = instance.constructor; + if (props && typeof props === 'object') { + if ('set' in instance) { + instance.set(isFunction(props.get) ? props.get() : props, this.constructor.removeAttr || false); + } else if ('attr' in instance) { + instance.attr(isFunction(props.attr) ? props.attr() : props, this.constructor.removeAttr || false); + } else { + canBatch.start(); + each(props, function (value, prop) { + instance[prop] = value; + }); + canBatch.stop(); + } + } + canEvent.dispatch.call(instance, { + type: funcName, + target: instance + }); + canEvent.dispatch.call(constructor, funcName, [instance]); + }; + }); + return behavior; +}); +var callCanReadingOnIdRead = true; +var mapStaticOverwrites = { + getList: function (base, connection) { + return function (set) { + return connection.getList(set); + }; + }, + findAll: function (base, connection) { + return function (set) { + return connection.getList(set); + }; + }, + get: function (base, connection) { + return function (params) { + return connection.get(params); + }; + }, + findOne: function (base, connection) { + return function (params) { + return connection.get(params); + }; + } +}; +var mapOverwrites = { + _eventSetup: function (base, connection) { + return function () { + callCanReadingOnIdRead = false; + connection.addInstanceReference(this); + callCanReadingOnIdRead = true; + return base.apply(this, arguments); + }; + }, + _eventTeardown: function (base, connection) { + return function () { + callCanReadingOnIdRead = false; + connection.deleteInstanceReference(this); + callCanReadingOnIdRead = true; + return base.apply(this, arguments); + }; + }, + ___set: function (base, connection) { + return function (prop, val) { + base.apply(this, arguments); + if (prop === connection.idProp && this._bindings) { + connection.addInstanceReference(this); + } + }; + }, + isNew: function (base, connection) { + return function () { + var id = connection.id(this); + return !(id || id === 0); + }; + }, + isSaving: function (base, connection) { + return function () { + Observation.add(this, '_saving'); + return !!getExpando(this, '_saving'); + }; + }, + isDestroying: function (base, connection) { + return function () { + Observation.add(this, '_destroying'); + return !!getExpando(this, '_destroying'); + }; + }, + save: function (base, connection) { + return function (success, error) { + var promise = connection.save(this); + promise.then(success, error); + return promise; + }; + }, + destroy: function (base, connection) { + return function (success, error) { + var promise; + if (this.isNew()) { + promise = Promise.resolve(this); + connection.destroyedInstance(this, {}); + } else { + promise = connection.destroy(this); + } + promise.then(success, error); + return promise; + }; + } +}; +var listPrototypeOverwrites = { + setup: function (base, connection) { + return function (params) { + if (isPlainObject(params) && !isArray(params)) { + this.__listSet = params; + base.apply(this); + this.replace(types.isPromise(params) ? params : connection.getList(params)); + } else { + base.apply(this, arguments); + } + }; + }, + _eventSetup: function (base, connection) { + return function () { + connection.addListReference(this); + if (base) { + return base.apply(this, arguments); + } + }; + }, + _eventTeardown: function (base, connection) { + return function () { + connection.deleteListReference(this); + if (base) { + return base.apply(this, arguments); + } + }; + } +}; +var listStaticOverwrites = { + _bubbleRule: function (base, connection) { + return function (eventName, list) { + var bubbleRules = base(eventName, list); + bubbleRules.push('destroyed'); + return bubbleRules; + }; + } +}; +var readObservabe = function (instance, prop) { + if ('__get' in instance) { + if (callCanReadingOnIdRead) { + Observation.add(instance, prop); + } + return instance.__get(prop); + } else { + if (callCanReadingOnIdRead) { + return instance[prop]; + } else { + return Observation.ignore(function () { + return instance[prop]; + })(); + } + } +}; +var overwrite = function (connection, Constructor, prototype, statics) { + var prop; + for (prop in prototype) { + Constructor.prototype[prop] = prototype[prop](Constructor.prototype[prop], connection); + } + if (statics) { + for (prop in statics) { + Constructor[prop] = statics[prop](Constructor[prop], connection); + } + } +}; +//# sourceMappingURL=map.js.map \ No newline at end of file diff --git a/dist/cjs/can/map/map.js.map b/dist/cjs/can/map/map.js.map new file mode 100644 index 00000000..3a90ffaf --- /dev/null +++ b/dist/cjs/can/map/map.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../../can/map/map.js"],"names":["each","require","connect","canBatch","canEvent","Observation","isPlainObject","isArray","types","isFunction","dev","setExpando","map","prop","value","_data","getExpando","module","exports","behavior","baseConnection","init","Map","DefaultMap","extend","List","DefaultList","overwrite","mapOverwrites","mapStaticOverwrites","listPrototypeOverwrites","listStaticOverwrites","apply","arguments","id","instance","ids","algebra","clauses","push","readObservabe","idProp","length","join","serializeInstance","serialize","serializeList","list","props","_Map","listData","set","_List","data","val","__listSet","updatedList","start","res","stop","save","dispatch","call","done","base","then","destroy","funcName","constructor","get","removeAttr","attr","type","target","callCanReadingOnIdRead","getList","connection","findAll","params","findOne","_eventSetup","addInstanceReference","_eventTeardown","deleteInstanceReference","___set","_bindings","isNew","isSaving","add","isDestroying","success","error","promise","Promise","resolve","destroyedInstance","setup","replace","isPromise","addListReference","deleteListReference","_bubbleRule","eventName","bubbleRules","__get","ignore","Constructor","prototype","statics"],"mappings":";AAAA;AACA,IAAIA,IAAA,GAAOC,OAAA,CAAQ,uBAAR,CAAX,CADA;AAGA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,CAAU9F,IAAV,EAAgB6F,WAAA,CAAYC,SAAZ,CAAsB9F,IAAtB,CAAhB,EAA6C+D,UAA7C,CAA9B,CADsB;AAAA,KAH+C;AAAA,IAMtE,IAAGgC,OAAH,EAAY;AAAA,QACX,KAAI/F,IAAJ,IAAY+F,OAAZ,EAAqB;AAAA,YACpBF,WAAA,CAAY7F,IAAZ,IAAoB+F,OAAA,CAAQ/F,IAAR,EAAc6F,WAAA,CAAY7F,IAAZ,CAAd,EAAiC+D,UAAjC,CAApB,CADoB;AAAA,SADV;AAAA,KAN0D;AAAA,CAAvE","file":"map.js"} \ No newline at end of file diff --git a/dist/cjs/can/ref/ref.js b/dist/cjs/can/ref/ref.js new file mode 100644 index 00000000..b364d748 --- /dev/null +++ b/dist/cjs/can/ref/ref.js @@ -0,0 +1,129 @@ +/*can-connect@1.0.20#can/ref/ref*/ +var connect = require('../../can-connect.js'); +var getIdProps = require('../../helpers/get-id-props.js'); +var WeakReferenceMap = require('../../helpers/weak-reference-map.js'); +var Observation = require('can-observation'); +var constructorStore = require('../../constructor/store/store.js'); +var define = require('can-define'); +var makeRef = function (connection) { + var idProp = getIdProps(connection)[0]; + var Ref = function (id, value) { + if (Ref.store.has(id)) { + return Ref.store.get(id); + } + this[idProp] = id; + if (value) { + this._value = connection.hydrateInstance(value); + } + if (constructorStore.requests.count() > 0) { + if (!Ref._requestInstances[id]) { + Ref.store.addReference(id, this); + Ref._requestInstances[id] = this; + } + } + }; + Ref.store = new WeakReferenceMap(); + Ref._requestInstances = {}; + Ref.type = function (ref) { + if (ref && typeof ref !== 'object') { + return new Ref(ref); + } else { + return new Ref(ref[idProp], ref); + } + }; + var defs = { + promise: { + get: function () { + if (this._value) { + return Promise.resolve(this._value); + } else { + var props = {}; + props[idProp] = this[idProp]; + return connection.Map.get(props); + } + } + }, + _state: { + get: function (lastSet, resolve) { + if (resolve) { + this.promise.then(function () { + resolve('resolved'); + }, function () { + resolve('rejected'); + }); + } + return 'pending'; + } + }, + value: { + get: function (lastSet, resolve) { + if (this._value) { + return this._value; + } else if (resolve) { + this.promise.then(function (value) { + resolve(value); + }); + } + } + }, + reason: { + get: function (lastSet, resolve) { + if (this._value) { + return undefined; + } else { + this.promise.catch(function (value) { + resolve(value); + }); + } + } + } + }; + defs[idProp] = { + type: '*', + set: function () { + this._value = undefined; + } + }; + define(Ref.prototype, defs); + Ref.prototype.unobservedId = Observation.ignore(function () { + return this[idProp]; + }); + Ref.prototype.isResolved = function () { + return !!this._value || this._state === 'resolved'; + }; + Ref.prototype.isRejected = function () { + return this._state === 'rejected'; + }; + Ref.prototype.isPending = function () { + return !this._value && (this._state !== 'resolved' || this._state !== 'rejected'); + }; + Ref.prototype.serialize = function () { + return this[idProp]; + }; + var baseEventSetup = Ref.prototype._eventSetup; + Ref.prototype._eventSetup = function () { + Ref.store.addReference(this.unobservedId(), this); + return baseEventSetup.apply(this, arguments); + }; + var baseTeardown = Ref.prototype._eventTeardown; + Ref.prototype._eventTeardown = function () { + Ref.store.deleteReference(this.unobservedId(), this); + return baseTeardown.apply(this, arguments); + }; + constructorStore.requests.on('end', function () { + for (var id in Ref._requestInstances) { + Ref.store.deleteReference(id); + } + Ref._requestInstances = {}; + }); + return Ref; +}; +module.exports = connect.behavior('can/ref', function (baseConnection) { + return { + init: function () { + baseConnection.init.apply(this, arguments); + this.Map.Ref = makeRef(this); + } + }; +}); +//# sourceMappingURL=ref.js.map \ No newline at end of file diff --git a/dist/cjs/can/ref/ref.js.map b/dist/cjs/can/ref/ref.js.map new file mode 100644 index 00000000..143baa5a --- /dev/null +++ b/dist/cjs/can/ref/ref.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../../can/ref/ref.js"],"names":["connect","require","getIdProps","WeakReferenceMap","Observation","constructorStore","define","makeRef","connection","idProp","Ref","id","value","store","has","get","_value","hydrateInstance","requests","count","_requestInstances","addReference","type","ref","defs","promise","Promise","resolve","props","Map","_state","lastSet","then","reason","undefined","catch","set","prototype","unobservedId","ignore","isResolved","isRejected","isPending","serialize","baseEventSetup","_eventSetup","apply","arguments","baseTeardown","_eventTeardown","deleteReference","on","module","exports","behavior","baseConnection","init"],"mappings":";AAiJA,IAAIA,OAAA,GAAUC,OAAA,CAAQ,sBAAR,CAAd;AACA,IAAIC,UAAA,GAAaD,OAAA,CAAQ,+BAAR,CAAjB,CADA;AAEA,IAAIE,gBAAA,GAAmBF,OAAA,CAAQ,qCAAR,CAAvB,CAFA;AAGA,IAAIG,WAAA,GAAcH,OAAA,CAAQ,iBAAR,CAAlB,CAHA;AAIA,IAAII,gBAAA,GAAmBJ,OAAA,CAAQ,kCAAR,CAAvB,CAJA;AAKA,IAAIK,MAAA,GAASL,OAAA,CAAQ,YAAR,CAAb,CALA;AAOA,IAAIM,OAAA,GAAU,UAASC,UAAT,EAAoB;AAAA,IACjC,IAAIC,MAAA,GAASP,UAAA,CAAWM,UAAX,EAAuB,CAAvB,CAAb,CADiC;AAAA,IAWjC,IAAIE,GAAA,GAAM,UAASC,EAAT,EAAaC,KAAb,EAAmB;AAAA,QAE5B,IAAGF,GAAA,CAAIG,KAAJ,CAAUC,GAAV,CAAcH,EAAd,CAAH,EAAsB;AAAA,YACrB,OAAOD,GAAA,CAAIG,KAAJ,CAAUE,GAAV,CAAcJ,EAAd,CAAP,CADqB;AAAA,SAFM;AAAA,QAM5B,KAAKF,MAAL,IAAeE,EAAf,CAN4B;AAAA,QAO5B,IAAGC,KAAH,EAAU;AAAA,YACT,KAAKI,MAAL,GAAcR,UAAA,CAAWS,eAAX,CAA2BL,KAA3B,CAAd,CADS;AAAA,SAPkB;AAAA,QAc5B,IAAIP,gBAAA,CAAiBa,QAAjB,CAA0BC,KAA1B,KAAoC,CAAxC,EAA4C;AAAA,YAC3C,IAAG,CAAET,GAAA,CAAIU,iBAAJ,CAAsBT,EAAtB,CAAL,EAAiC;AAAA,gBAChCD,GAAA,CAAIG,KAAJ,CAAUQ,YAAV,CAAuBV,EAAvB,EAA2B,IAA3B,EADgC;AAAA,gB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,CAAIG,KAAJ,CAAUqC,eAAV,CAA0B,KAAKZ,YAAL,EAA1B,EAA8C,IAA9C,EADwC;AAAA,QAExC,OAAOU,YAAA,CAAaF,KAAb,CAAmB,IAAnB,EAAyBC,SAAzB,CAAP,CAFwC;AAAA,KAAzC,CA9LiC;AAAA,IAoMjC1C,gBAAA,CAAiBa,QAAjB,CAA0BiC,EAA1B,CAA6B,KAA7B,EAAoC,YAAU;AAAA,QAC7C,SAAQxC,EAAR,IAAcD,GAAA,CAAIU,iBAAlB,EAAqC;AAAA,YACpCV,GAAA,CAAIG,KAAJ,CAAUqC,eAAV,CAA0BvC,EAA1B,EADoC;AAAA,SADQ;AAAA,QAI7CD,GAAA,CAAIU,iBAAJ,GAAwB,EAAxB,CAJ6C;AAAA,KAA9C,EApMiC;AAAA,IA2MjC,OAAOV,GAAP,CA3MiC;AAAA,CAAlC,CAPA;AAsNA0C,MAAA,CAAOC,OAAP,GAAiBrD,OAAA,CAAQsD,QAAR,CAAiB,SAAjB,EAA2B,UAASC,cAAT,EAAwB;AAAA,IACnE,OAAO;AAAA,QAONC,IAAA,EAAM,YAAU;AAAA,YACfD,cAAA,CAAeC,IAAf,CAAoBV,KAApB,CAA0B,IAA1B,EAAgCC,SAAhC,EADe;AAAA,YAEf,KAAKlB,GAAL,CAASnB,GAAT,GAAeH,OAAA,CAAQ,IAAR,CAAf,CAFe;AAAA,SAPV;AAAA,KAAP,CADmE;AAAA,CAAnD,CAAjB","file":"ref.js"} \ No newline at end of file diff --git a/dist/cjs/can/super-map/super-map.js b/dist/cjs/can/super-map/super-map.js new file mode 100644 index 00000000..10d0ec36 --- /dev/null +++ b/dist/cjs/can/super-map/super-map.js @@ -0,0 +1,46 @@ +/*can-connect@1.0.20#can/super-map/super-map*/ +var connect = require('../../can-connect.js'); +var constructor = require('../../constructor/constructor.js'); +var canMap = require('../map/map.js'); +var canRef = require('../ref/ref.js'); +var constructorStore = require('../../constructor/store/store.js'); +var dataCallbacks = require('../../data/callbacks/callbacks.js'); +var callbacksCache = require('../../data/callbacks-cache/callbacks-cache.js'); +var combineRequests = require('../../data/combine-requests/combine-requests.js'); +var localCache = require('../../data/localstorage-cache/localstorage-cache.js'); +var dataParse = require('../../data/parse/parse.js'); +var dataUrl = require('../../data/url/url.js'); +var fallThroughCache = require('../../fall-through-cache/fall-through-cache.js'); +var realTime = require('../../real-time/real-time.js'); +var callbacksOnce = require('../../constructor/callbacks-once/callbacks-once.js'); +var $ = require('jquery'); +connect.superMap = function (options) { + var behaviors = [ + constructor, + canMap, + canRef, + constructorStore, + dataCallbacks, + combineRequests, + dataParse, + dataUrl, + realTime, + callbacksOnce + ]; + if (typeof localStorage !== 'undefined') { + if (!options.cacheConnection) { + options.cacheConnection = connect([localCache], { + name: options.name + 'Cache', + idProp: options.idProp, + algebra: options.algebra + }); + } + behaviors.push(callbacksCache, fallThroughCache); + } + if ($ && $.ajax) { + options.ajax = $.ajax; + } + return connect(behaviors, options); +}; +module.exports = connect.superMap; +//# sourceMappingURL=super-map.js.map \ No newline at end of file diff --git a/dist/cjs/can/super-map/super-map.js.map b/dist/cjs/can/super-map/super-map.js.map new file mode 100644 index 00000000..09ba7170 --- /dev/null +++ b/dist/cjs/can/super-map/super-map.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../../can/super-map/super-map.js"],"names":["connect","require","constructor","canMap","canRef","constructorStore","dataCallbacks","callbacksCache","combineRequests","localCache","dataParse","dataUrl","fallThroughCache","realTime","callbacksOnce","$","superMap","options","behaviors","localStorage","cacheConnection","name","idProp","algebra","push","ajax","module","exports"],"mappings":";AAAA,IAAIA,OAAA,GAAUC,OAAA,CAAQ,sBAAR,CAAd;AAEA,IAAIC,WAAA,GAAcD,OAAA,CAAQ,kCAAR,CAAlB,CAFA;AAGA,IAAIE,MAAA,GAASF,OAAA,CAAQ,eAAR,CAAb,CAHA;AAIA,IAAIG,MAAA,GAASH,OAAA,CAAQ,eAAR,CAAb,CAJA;AAKA,IAAII,gBAAA,GAAmB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AA,gBAG9CC,OAAA,EAASN,OAAA,CAAQM,OAH6B;AAAA,aAArB,CAA1B,CAD4B;AAAA,SADU;AAAA,QAQvCL,SAAA,CAAUM,IAAV,CAAejB,cAAf,EAA8BK,gBAA9B,EARuC;AAAA,KAdL;AAAA,IAyBnC,IAAGG,CAAA,IAAKA,CAAA,CAAEU,IAAV,EAAgB;AAAA,QACfR,OAAA,CAAQQ,IAAR,GAAeV,CAAA,CAAEU,IAAjB,CADe;AAAA,KAzBmB;AAAA,IA4BnC,OAAOzB,OAAA,CAAQkB,SAAR,EAAkBD,OAAlB,CAAP,CA5BmC;AAAA,CAApC,CAnBA;AAkDAS,MAAA,CAAOC,OAAP,GAAiB3B,OAAA,CAAQgB,QAAzB","file":"super-map.js"} \ No newline at end of file diff --git a/dist/cjs/can/tag/tag.js b/dist/cjs/can/tag/tag.js new file mode 100644 index 00000000..063926df --- /dev/null +++ b/dist/cjs/can/tag/tag.js @@ -0,0 +1,82 @@ +/*can-connect@1.0.20#can/tag/tag*/ +require('can-stache-bindings'); +var connect = require('../../can-connect.js'); +var compute = require('can-compute'); +var expression = require('can-stache/src/expression'); +var viewCallbacks = require('can-view-callbacks'); +var Observation = require('can-observation'); +var nodeLists = require('can-view-nodelist'); +var canEvent = require('can-event'); +var each = require('can-util/js/each/each'); +var domMutate = require('can-util/dom/mutate/mutate'); +var domData = require('can-util/dom/data/data'); +require('can-util/dom/events/removed/removed'); +var convertToValue = function (arg) { + if (typeof arg === 'function') { + return convertToValue(arg()); + } else { + return arg; + } +}; +connect.tag = function (tagName, connection) { + var removeBrackets = function (value, open, close) { + open = open || '{'; + close = close || '}'; + if (value[0] === open && value[value.length - 1] === close) { + return value.substr(1, value.length - 2); + } + return value; + }; + viewCallbacks.tag(tagName, function (el, tagData) { + var getList = el.getAttribute('getList') || el.getAttribute('get-list'); + var getInstance = el.getAttribute('get'); + var attrValue = getList || getInstance; + var method = getList ? 'getList' : 'get'; + var attrInfo = expression.parse('tmp(' + removeBrackets(attrValue) + ')', { baseMethodType: 'Call' }); + var addedToPageData = false; + var addToPageData = Observation.ignore(function (set, promise) { + if (!addedToPageData) { + var root = tagData.scope.peek('%root') || tagData.scope.peek('@root'); + if (root && root.pageData) { + if (method === 'get') { + set = connection.id(set); + } + root.pageData(connection.name, set, promise); + } + } + addedToPageData = true; + }); + var request = compute(function () { + var hash = {}; + if (typeof attrInfo.hash === 'object') { + each(attrInfo.hash, function (val, key) { + if (val && val.hasOwnProperty('get')) { + hash[key] = tagData.scope.read(val.get, {}).value; + } else { + hash[key] = val; + } + }); + } else if (typeof attrInfo.hash === 'function') { + var getHash = attrInfo.hash(tagData.scope, tagData.options, {}); + each(getHash(), function (val, key) { + hash[key] = convertToValue(val); + }); + } else { + hash = attrInfo.argExprs.length ? attrInfo.argExprs[0].value(tagData.scope, tagData.options)() : {}; + } + var promise = connection[method](hash); + addToPageData(hash, promise); + return promise; + }); + domData.set.call(el, 'viewModel', request); + var nodeList = nodeLists.register([], undefined, tagData.parentNodeList || true); + var frag = tagData.subtemplate ? tagData.subtemplate(tagData.scope.add(request), tagData.options, nodeList) : document.createDocumentFragment(); + domMutate.appendChild.call(el, frag); + nodeLists.update(nodeList, el.childNodes); + canEvent.one.call(el, 'removed', function () { + nodeLists.unregister(nodeList); + }); + }); +}; +module.exports = connect.tag; +//# sourceMappingURL=tag.js.map \ No newline at end of file diff --git a/dist/cjs/can/tag/tag.js.map b/dist/cjs/can/tag/tag.js.map new file mode 100644 index 00000000..1e8c0c1f --- /dev/null +++ b/dist/cjs/can/tag/tag.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../../can/tag/tag.js"],"names":["require","connect","compute","expression","viewCallbacks","Observation","nodeLists","canEvent","each","domMutate","domData","convertToValue","arg","tag","tagName","connection","removeBrackets","value","open","close","length","substr","el","tagData","getList","getAttribute","getInstance","attrValue","method","attrInfo","parse","baseMethodType","addedToPageData","addToPageData","ignore","set","promise","root","scope","peek","pageData","id","name","request","hash","val","key","hasOwnProperty","read","get","getHash","options","argExprs","call","nodeList","register","undefined","parentNodeList","frag","subtemplate","add","document","createDocumentFragment","appendChild","update","childNodes","one","unregister","module","exports"],"mappings":";AAgCAA,OAAA,CAAQ,qBAAR;AAEA,IAAIC,OAAA,GAAUD,OAAA,CAAQ,sBAAR,CAAd,CAFA;AAIA,IAAIE,OAAA,GAAUF,OAAA,CAAQ,aAAR,CAAd,CAJA;AAKA,IAAIG,UAAA,GAAaH,OAAA,CAAQ,2BAAR,CAAjB,CALA;AAMA,IAAII,aAAA,GAAgBJ,OAAA,CAAQ,oBAAR,CAApB,CANA;AAOA,IAAIK,WAAA,GAAcL,OAAA,CAAQ,iBAAR,CAAlB,CAPA;AAQA,IAAIM,SAAA,GAAYN,OAAA,CAAQ,mBAAR,CAAhB,CARA;AASA,IAAIO,QAAA,GAAWP,OAAA,CAAQ,WAAR,CAAf,CATA;AAWA,IAAIQ,IAAA,GAAOR,OAAA,CAAQ,uBAAR,CAAX,CAXA;AAaA,IAAIS,SAAA,GAAYT,OAAA,CAAQ,4BAAR,CAAhB,CAbA;AAcA,IAAIU,OAAA,GAAUV,OAAA,CAAQ,wBAAR,CAAd,CAdA;AAiBAA,OAAA,CAAQ,qCAAR,EAjBA;AAmBA,IAAIW,cAAA,GAAiB,UAASC,GAAT,EAAa;AAAA,IACjC,IAAG,OAAOA,GAAP,KAAe,UAAlB,EAA8B;AAAA,QAC7B,OAAOD,cAAA,CAAgBC,GAAA,EAAhB,CAAP,CAD6B;AAAA,KAA9B,MAEO;AAAA,QACN,OAAOA,GAAP,CADM;AAAA,KAH0B;AAAA,CAAlC,CAnBA;AA2BAX,OAAA,CAAQY,GAAR,GAAc,UAASC,OAAT,EAAkBC,UAAlB,EAA6B;AAAA,IAE1C,IAAIC,cAAA,GAAiB,UAASC,KAAT,EAAgBC,IAAhB,EAAsBC,KAAtB,EAA4B;AAAA,QAChDD,IAAA,GAAOA,IAAA,IAAQ,GAAf,CADgD;AAAA,QAEhDC,KAAA,GAAQA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CAAU0D,MAAV,CAAiBV,QAAjB,EAA2BhC,EAAA,CAAG2C,UAA9B,EAhE+C;AAAA,QAoE/C1D,QAAA,CAAS2D,GAAT,CAAab,IAAb,CAAkB/B,EAAlB,EAAsB,SAAtB,EAAiC,YAAW;AAAA,YAC3ChB,SAAA,CAAU6D,UAAV,CAAqBb,QAArB,EAD2C;AAAA,SAA5C,EApE+C;AAAA,KAAhD,EAb0C;AAAA,CAA3C,CA3BA;AAkHAc,MAAA,CAAOC,OAAP,GAAiBpE,OAAA,CAAQY,GAAzB","file":"tag.js"} \ No newline at end of file diff --git a/dist/cjs/connect.js b/dist/cjs/connect.js new file mode 100644 index 00000000..b57c127e --- /dev/null +++ b/dist/cjs/connect.js @@ -0,0 +1,81 @@ +/*can-connect@1.0.20#connect*/ +var assign = require('can-util/js/assign/assign'); +var connect = function (behaviors, options) { + behaviors = behaviors.map(function (behavior, index) { + var sortedIndex = -1; + if (typeof behavior === 'string') { + sortedIndex = connect.order.indexOf(behavior); + behavior = behaviorsMap[behavior]; + } else if (behavior.isBehavior) { + sortedIndex = connect.order.indexOf(behavior.behaviorName); + } else { + behavior = connect.behavior(behavior); + } + return { + originalIndex: index, + sortedIndex: sortedIndex, + behavior: behavior + }; + }).sort(function (b1, b2) { + if (~b1.sortedIndex && ~b2.sortedIndex) { + return b1.sortedIndex - b2.sortedIndex; + } + return b1.originalIndex - b2.originalIndex; + }); + behaviors = behaviors.map(function (b) { + return b.behavior; + }); + var behavior = connect.base(connect.behavior('options', function () { + return options; + })()); + behaviors.forEach(function (behave) { + behavior = behave(behavior); + }); + if (behavior.init) { + behavior.init(); + } + return behavior; +}; +connect.order = [ + 'data/localstorage-cache', + 'data/url', + 'data/parse', + 'cache-requests', + 'data/combine-requests', + 'constructor', + 'constructor/store', + 'can/map', + 'can/ref', + 'fall-through-cache', + 'data/worker', + 'real-time', + 'data/callbacks-cache', + 'data/callbacks', + 'constructor/callbacks-once' +]; +connect.behavior = function (name, behavior) { + if (typeof name !== 'string') { + behavior = name; + name = undefined; + } + var behaviorMixin = function (base) { + var Behavior = function () { + }; + Behavior.name = name; + Behavior.prototype = base; + var newBehavior = new Behavior(); + var res = typeof behavior === 'function' ? behavior.apply(newBehavior, arguments) : behavior; + assign(newBehavior, res); + newBehavior.__behaviorName = name; + return newBehavior; + }; + if (name) { + behaviorMixin.behaviorName = name; + behaviorsMap[name] = behaviorMixin; + } + behaviorMixin.isBehavior = true; + return behaviorMixin; +}; +var behaviorsMap = {}; +module.exports = connect; +//# sourceMappingURL=connect.js.map \ No newline at end of file diff --git a/dist/cjs/connect.js.map b/dist/cjs/connect.js.map new file mode 100644 index 00000000..e013de4f --- /dev/null +++ b/dist/cjs/connect.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../connect.js"],"names":["assign","require","connect","behaviors","options","map","behavior","index","sortedIndex","order","indexOf","behaviorsMap","isBehavior","behaviorName","originalIndex","sort","b1","b2","b","base","forEach","behave","init","name","undefined","behaviorMixin","Behavior","prototype","newBehavior","res","apply","arguments","__behaviorName","module","exports"],"mappings":";AAAA,IAAIA,MAAA,GAASC,OAAA,CAAQ,2BAAR,CAAb;AAOA,IAAIC,OAAA,GAAU,UAASC,SAAT,EAAoBC,OAApB,EAA4B;AAAA,IAEzCD,SAAA,GAAYA,SAAA,CAAUE,GAAV,CAAc,UAASC,QAAT,EAAmBC,KAAnB,EAAyB;AAAA,QAClD,IAAIC,WAAA,GAAc,CAAC,CAAnB,CADkD;AAAA,QAElD,IAAG,OAAOF,QAAP,KAAoB,QAAvB,EAAiC;AAAA,YAChCE,WAAA,GAAcN,OAAA,CAAQO,KAAR,CAAcC,OAAd,CAAsBJ,QAAtB,CAAd,CADgC;AAAA,YAEhCA,QAAA,GAAWK,YAAA,CAAaL,QAAb,CAAX,CAFgC;AAAA,SAAjC,MAGO,IAAGA,QAAA,CAASM,UAAZ,EAAwB;AAAA,YAC9BJ,WAAA,GAAcN,OAAA,CAAQO,KAAR,CAAcC,OAAd,CAAsBJ,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d,GAA6BU,IAA7B,CADQ;AAAA,QAERZ,YAAA,CAAaY,IAAb,IAAqBE,aAArB,CAFQ;AAAA,KAjBiC;AAAA,IAqB1CA,aAAA,CAAcb,UAAd,GAA2B,IAA3B,CArB0C;AAAA,IAsB1C,OAAOa,aAAP,CAtB0C;AAAA,CAA3C,CA7DA;AAsFA,IAAId,YAAA,GAAe,EAAnB,CAtFA;AAwFAsB,MAAA,CAAOC,OAAP,GAAgBhC,OAAhB","file":"connect.js"} \ No newline at end of file diff --git a/dist/cjs/constructor/callbacks-once/callbacks-once.js b/dist/cjs/constructor/callbacks-once/callbacks-once.js new file mode 100644 index 00000000..d8b42bc9 --- /dev/null +++ b/dist/cjs/constructor/callbacks-once/callbacks-once.js @@ -0,0 +1,25 @@ +/*can-connect@1.0.20#constructor/callbacks-once/callbacks-once*/ +var connect = require('../../can-connect.js'); +var sortedSetJSON = require('../../helpers/sorted-set-json.js'); +var forEach = [].forEach; +var callbacks = [ + 'createdInstance', + 'updatedInstance', + 'destroyedInstance' +]; +module.exports = connect.behavior('constructor/callbacks-once', function (baseConnection) { + var behavior = {}; + forEach.call(callbacks, function (name) { + behavior[name] = function (instance, data) { + var lastSerialized = this.getInstanceMetaData(instance, 'last-data'); + var serialize = sortedSetJSON(data), serialized = sortedSetJSON(this.serializeInstance(instance)); + if (lastSerialized !== serialize) { + var result = baseConnection[name].apply(this, arguments); + this.addInstanceMetaData(instance, 'last-data', serialize); + return result; + } + }; + }); + return behavior; +}); +//# sourceMappingURL=callbacks-once.js.map \ No newline at end of file diff --git a/dist/cjs/constructor/callbacks-once/callbacks-once.js.map b/dist/cjs/constructor/callbacks-once/callbacks-once.js.map new file mode 100644 index 00000000..ae5a0f6e --- /dev/null +++ b/dist/cjs/constructor/callbacks-once/callbacks-once.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../../constructor/callbacks-once/callbacks-once.js"],"names":["connect","require","sortedSetJSON","forEach","callbacks","module","exports","behavior","baseConnection","call","name","instance","data","lastSerialized","getInstanceMetaData","serialize","serialized","serializeInstance","result","apply","arguments","addInstanceMetaData"],"mappings":";AAcA,IAAIA,OAAA,GAAUC,OAAA,CAAQ,sBAAR,CAAd;AACA,IAAIC,aAAA,GAAgBD,OAAA,CAAQ,kCAAR,CAApB,CADA;AAEA,IAAIE,OAAA,GAAU,GAAGA,OAAjB,CAFA;AAKA,IAAIC,SAAA,GAAY;AAAA,IASf,iBATe;AAAA,IAkBf,iBAlBe;AAAA,IA2Bf,mBA3Be;AAAA,CAAhB,CALA;AAqCAC,MAAA,CAAOC,OAAP,GAAiBN,OAAA,CAAQO,QAAR,CAAiB,4BAAjB,EAA8C,UAASC,cAAT,EAAwB;AAAA,IAEtF,IAAID,QAAA,GAAW,EAAf,CAFsF;AAAA,IAMtFJ,OAAA,CAAQM,IAAR,CAAaL,SAAb,EAAwB,UAASM,IAAT,EAAc;AAAA,QACrCH,QAAA,CAASG,IAAT,IAAiB,UAASC,QAAT,EAAmBC,IAAnB,EAAyB;AAAA,YAEzC,IAAIC,cAAA,GAAiB,KAAKC,mBAAL,CAAyBH,QAAzB,EAAmC,WAAnC,CAArB,CAFyC;AAAA,YAIzC,IAAII,SAAA,GAAYb,aAAA,CAAcU,IAAd,CAAhB,EACCI,UAAA,GAAad,aAAA,CAAe,KAAKe,iBAAL,CAAwBN,QAAxB,CAAf,CADd,CAJyC;AAAA,YAMzC,IAAGE,cAAA,KAAmBE,SAAtB,EAAiC;AAAA,gBAChC,IAAIG,MAAA,GAAUV,cAAA,CAAeE,IAAf,EAAqBS,KAArB,CAA2B,IAA3B,EAAiCC,SAAjC,CAAd,CADgC;AAAA,gBAEhC,KAAKC,mBAAL,CAAyBV,QAAzB,EAAmC,WAAnC,EAAgDI,SAAhD,EAFgC;AAAA,gBAGhC,OAAOG,MAAP,CAHgC;AAAA,aANQ;AAAA,SAA1C,CADqC;AAAA,KAAtC,EANsF;AAAA,IAsBtF,OAAOX,QAAP,CAtBsF;AAAA,CAAtE,CAAjB","file":"callbacks-once.js"} \ No newline at end of file diff --git a/dist/cjs/constructor/constructor.js b/dist/cjs/constructor/constructor.js new file mode 100644 index 00000000..b92638f5 --- /dev/null +++ b/dist/cjs/constructor/constructor.js @@ -0,0 +1,129 @@ +/*can-connect@1.0.20#constructor/constructor*/ +var isArray = require('can-util/js/is-array/is-array'); +var makeArray = require('can-util/js/make-array/make-array'); +var assign = require('can-util/js/assign/assign'); +var connect = require('../can-connect.js'); +var WeakReferenceMap = require('../helpers/weak-reference-map.js'); +var overwrite = require('../helpers/overwrite.js'); +var idMerge = require('../helpers/id-merge.js'); +module.exports = connect.behavior('constructor', function (baseConnection) { + var behavior = { + cidStore: new WeakReferenceMap(), + _cid: 0, + get: function (params) { + var self = this; + return this.getData(params).then(function (data) { + return self.hydrateInstance(data); + }); + }, + getList: function (set) { + set = set || {}; + var self = this; + return this.getListData(set).then(function (data) { + return self.hydrateList(data, set); + }); + }, + hydrateList: function (listData, set) { + if (isArray(listData)) { + listData = { data: listData }; + } + var arr = []; + for (var i = 0; i < listData.data.length; i++) { + arr.push(this.hydrateInstance(listData.data[i])); + } + listData.data = arr; + if (this.list) { + return this.list(listData, set); + } else { + var list = listData.data.slice(0); + list[this.listSetProp || '__listSet'] = set; + copyMetadata(listData, list); + return list; + } + }, + hydrateInstance: function (props) { + if (this.instance) { + return this.instance(props); + } else { + return assign({}, props); + } + }, + save: function (instance) { + var serialized = this.serializeInstance(instance); + var id = this.id(instance); + var self = this; + if (id === undefined) { + var cid = this._cid++; + this.cidStore.addReference(cid, instance); + return this.createData(serialized, cid).then(function (data) { + if (data !== undefined) { + self.createdInstance(instance, data); + } + self.cidStore.deleteReference(cid, instance); + return instance; + }); + } else { + return this.updateData(serialized).then(function (data) { + if (data !== undefined) { + self.updatedInstance(instance, data); + } + return instance; + }); + } + }, + destroy: function (instance) { + var serialized = this.serializeInstance(instance), self = this; + return this.destroyData(serialized).then(function (data) { + if (data !== undefined) { + self.destroyedInstance(instance, data); + } + return instance; + }); + }, + createdInstance: function (instance, props) { + assign(instance, props); + }, + updatedInstance: function (instance, data) { + overwrite(instance, data, this.idProp); + }, + updatedList: function (list, listData, set) { + var instanceList = []; + for (var i = 0; i < listData.data.length; i++) { + instanceList.push(this.hydrateInstance(listData.data[i])); + } + idMerge(list, instanceList, this.id.bind(this), this.hydrateInstance.bind(this)); + copyMetadata(listData, list); + }, + destroyedInstance: function (instance, data) { + overwrite(instance, data, this.idProp); + }, + serializeInstance: function (instance) { + return assign({}, instance); + }, + serializeList: function (list) { + var self = this; + return makeArray(list).map(function (instance) { + return self.serializeInstance(instance); + }); + }, + isNew: function (instance) { + var id = this.id(instance); + return !(id || id === 0); + } + }; + return behavior; +}); +function copyMetadata(listData, list) { + for (var prop in listData) { + if (prop !== 'data') { + if (typeof list.set === 'function') { + list.set(prop, listData[prop]); + } else if (typeof list.attr === 'function') { + list.attr(prop, listData[prop]); + } else { + list[prop] = listData[prop]; + } + } + } +} +//# sourceMappingURL=constructor.js.map \ No newline at end of file diff --git a/dist/cjs/constructor/constructor.js.map b/dist/cjs/constructor/constructor.js.map new file mode 100644 index 00000000..0385d62d --- /dev/null +++ b/dist/cjs/constructor/constructor.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../constructor/constructor.js"],"names":["isArray","require","makeArray","assign","connect","WeakReferenceMap","overwrite","idMerge","module","exports","behavior","baseConnection","cidStore","_cid","get","params","self","getData","then","data","hydrateInstance","getList","set","getListData","hydrateList","listData","arr","i","length","push","list","slice","listSetProp","copyMetadata","props","instance","save","serialized","serializeInstance","id","undefined","cid","addReference","createData","createdInstance","deleteReference","updateData","updatedInstance","destroy","destroyData","destroyedInstance","idProp","updatedList","instanceList","bind","serializeList","map","isNew","prop","attr"],"mappings":";AA8FA,IAAIA,OAAA,GAAUC,OAAA,CAAQ,+BAAR,CAAd;AACA,IAAIC,SAAA,GAAYD,OAAA,CAAQ,mCAAR,CAAhB,CADA;AAEA,IAAIE,MAAA,GAASF,OAAA,CAAQ,2BAAR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CAASiC,IAAT,CAAhB,EAD0C;AAAA,aAApC,MAEA;AAAA,gBACN5B,IAAA,CAAK4B,IAAL,IAAajC,QAAA,CAASiC,IAAT,CAAb,CADM;AAAA,aANY;AAAA,SADK;AAAA,KADU;AAAA","file":"constructor.js"} \ No newline at end of file diff --git a/dist/cjs/constructor/store/store.js b/dist/cjs/constructor/store/store.js new file mode 100644 index 00000000..6f00a74e --- /dev/null +++ b/dist/cjs/constructor/store/store.js @@ -0,0 +1,180 @@ +/*can-connect@1.0.20#constructor/store/store*/ +var connect = require('../../can-connect.js'); +var WeakReferenceMap = require('../../helpers/weak-reference-map.js'); +var sortedSetJSON = require('../../helpers/sorted-set-json.js'); +var canEvent = require('can-event'); +var assign = require('can-util/js/assign/assign'); +var pendingRequests = 0; +var noRequestsTimer = null; +var requests = { + increment: function (connection) { + pendingRequests++; + clearTimeout(noRequestsTimer); + }, + decrement: function (connection) { + pendingRequests--; + if (pendingRequests === 0) { + noRequestsTimer = setTimeout(function () { + requests.dispatch('end'); + }, 10); + } + }, + count: function () { + return pendingRequests; + } +}; +assign(requests, canEvent); +var constructorStore = connect.behavior('constructor/store', function (baseConnection) { + var behavior = { + instanceStore: new WeakReferenceMap(), + listStore: new WeakReferenceMap(), + _requestInstances: {}, + _requestLists: {}, + _finishedRequest: function () { + var id; + requests.decrement(this); + if (requests.count() === 0) { + for (id in this._requestInstances) { + this.instanceStore.deleteReference(id); + } + this._requestInstances = {}; + for (id in this._requestLists) { + this.listStore.deleteReference(id); + } + this._requestLists = {}; + } + }, + addInstanceReference: function (instance, id) { + this.instanceStore.addReference(id || this.id(instance), instance); + }, + addInstanceMetaData: function (instance, name, value) { + var data = this.instanceStore.set[this.id(instance)]; + if (data) { + data[name] = value; + } + }, + getInstanceMetaData: function (instance, name) { + var data = this.instanceStore.set[this.id(instance)]; + if (data) { + return data[name]; + } + }, + deleteInstanceMetaData: function (instance, name) { + var data = this.instanceStore.set[this.id(instance)]; + delete data[name]; + }, + deleteInstanceReference: function (instance) { + this.instanceStore.deleteReference(this.id(instance), instance); + }, + addListReference: function (list, set) { + var id = sortedSetJSON(set || this.listSet(list)); + if (id) { + this.listStore.addReference(id, list); + } + }, + deleteListReference: function (list, set) { + var id = sortedSetJSON(set || this.listSet(list)); + if (id) { + this.listStore.deleteReference(id, list); + } + }, + hydratedInstance: function (instance) { + if (requests.count() > 0) { + var id = this.id(instance); + if (!this._requestInstances[id]) { + this.addInstanceReference(instance); + this._requestInstances[id] = instance; + } + } + }, + hydrateInstance: function (props) { + var id = this.id(props); + if ((id || id === 0) && this.instanceStore.has(id)) { + var storeInstance = this.instanceStore.get(id); + this.updatedInstance(storeInstance, props); + return storeInstance; + } + var instance = baseConnection.hydrateInstance.call(this, props); + this.hydratedInstance(instance); + return instance; + }, + hydratedList: function (list, set) { + if (requests.count() > 0) { + var id = sortedSetJSON(set || this.listSet(list)); + if (id) { + if (!this._requestLists[id]) { + this.addListReference(list, set); + this._requestLists[id] = list; + } + } + } + }, + hydrateList: function (listData, set) { + set = set || this.listSet(listData); + var id = sortedSetJSON(set); + if (id && this.listStore.has(id)) { + var storeList = this.listStore.get(id); + this.updatedList(storeList, listData, set); + return storeList; + } + var list = baseConnection.hydrateList.call(this, listData, set); + this.hydratedList(list, set); + return list; + }, + getList: function (params) { + var self = this; + requests.increment(this); + var promise = baseConnection.getList.call(this, params); + promise.then(function (instances) { + self._finishedRequest(); + }, function () { + self._finishedRequest(); + }); + return promise; + }, + get: function (params) { + var self = this; + requests.increment(this); + var promise = baseConnection.get.call(this, params); + promise.then(function (instance) { + self._finishedRequest(); + }, function () { + self._finishedRequest(); + }); + return promise; + }, + save: function (instance) { + var self = this; + requests.increment(this); + var updating = !this.isNew(instance); + if (updating) { + this.addInstanceReference(instance); + } + var promise = baseConnection.save.call(this, instance); + promise.then(function (instances) { + if (updating) { + self.deleteInstanceReference(instance); + } + self._finishedRequest(); + }, function () { + self._finishedRequest(); + }); + return promise; + }, + destroy: function (instance) { + var self = this; + requests.increment(this); + var promise = baseConnection.destroy.call(this, instance); + promise.then(function (instance) { + self._finishedRequest(); + }, function () { + self._finishedRequest(); + }); + return promise; + } + }; + return behavior; +}); +constructorStore.requests = requests; +module.exports = constructorStore; +//# sourceMappingURL=store.js.map \ No newline at end of file diff --git a/dist/cjs/constructor/store/store.js.map b/dist/cjs/constructor/store/store.js.map new file mode 100644 index 00000000..924a9943 --- /dev/null +++ b/dist/cjs/constructor/store/store.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../../constructor/store/store.js"],"names":["connect","require","WeakReferenceMap","sortedSetJSON","canEvent","assign","pendingRequests","noRequestsTimer","requests","increment","connection","clearTimeout","decrement","setTimeout","dispatch","count","constructorStore","behavior","baseConnection","instanceStore","listStore","_requestInstances","_requestLists","_finishedRequest","id","deleteReference","addInstanceReference","instance","addReference","addInstanceMetaData","name","value","data","set","getInstanceMetaData","deleteInstanceMetaData","deleteInstanceReference","addListReference","list","listSet","deleteListReference","hydratedInstance","hydrateInstance","props","has","storeInstance","get","updatedInstance","call","hydratedList","hydrateList","listData","storeList","updatedList","getList","params","self","promise","then","instances","save","updating","isNew","destroy","module","exports"],"mappings":";AAgFA,IAAIA,OAAA,GAAUC,OAAA,CAAQ,sBAAR,CAAd;AACA,IAAIC,gBAAA,GAAmBD,OAAA,CAAQ,qCAAR,CAAvB,CADA;AAEA,IAAIE,aAAA,GAAgBF,OAAA,CAAQ,kCAAR,CAApB,CAFA;AAGA,IAAIG,QAAA,GAAWH,OAAA,CAAQ,WAAR,CAAf,CAHA;AAIA,IAAII,MAAA,GAASJ,OAAA,CAAQ,2BAAR,CAAb,CAJA;AAOA,IAAIK,eAAA,GAAkB,CAAtB,CAPA;AAQA,IAAIC,eAAA,GAAkB,IAAtB,CARA;AASA,IAAIC,QAAA,GAAW;AAAA,IACdC,SAAA,EAAW,UAASC,UAAT,EAAoB;AAAA,QAC9BJ,eAAA,GAD8B;AAAA,QAE9BK,YAAA,CAAaJ,eAAb,EAF8B;AAAA,KAD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3B,IAAIgD,OAAA,GAAUvC,cAAA,CAAe6C,OAAf,CAAuBf,IAAvB,CAA4B,IAA5B,EAAkCrB,QAAlC,CAAd,CAH2B;AAAA,YAK3B8B,OAAA,CAAQC,IAAR,CAAa,UAAS/B,QAAT,EAAkB;AAAA,gBAC9B6B,IAAA,CAAKjC,gBAAL,GAD8B;AAAA,aAA/B,EAEG,YAAU;AAAA,gBACZiC,IAAA,CAAKjC,gBAAL,GADY;AAAA,aAFb,EAL2B;AAAA,YAU3B,OAAOkC,OAAP,CAV2B;AAAA,SApgBd;AAAA,KAAf,CAFmF;AAAA,IAqhBnF,OAAOxC,QAAP,CArhBmF;AAAA,CAA7D,CAAvB,CA7BA;AAqjBAD,gBAAA,CAAiBR,QAAjB,GAA4BA,QAA5B,CArjBA;AAujBAwD,MAAA,CAAOC,OAAP,GAAiBjD,gBAAjB","file":"store.js"} \ No newline at end of file diff --git a/dist/cjs/data/callbacks-cache/callbacks-cache.js b/dist/cjs/data/callbacks-cache/callbacks-cache.js new file mode 100644 index 00000000..06c8c5c6 --- /dev/null +++ b/dist/cjs/data/callbacks-cache/callbacks-cache.js @@ -0,0 +1,20 @@ +/*can-connect@1.0.20#data/callbacks-cache/callbacks-cache*/ +var connect = require('../../can-connect.js'); +var assign = require('can-util/js/assign/assign'); +var each = require('can-util/js/each/each'); +var pairs = { + createdData: 'createData', + updatedData: 'updateData', + destroyedData: 'destroyData' +}; +module.exports = connect.behavior('data/callbacks-cache', function (baseConnection) { + var behavior = {}; + each(pairs, function (cacheCallback, dataCallbackName) { + behavior[dataCallbackName] = function (data, set, cid) { + this.cacheConnection[cacheCallback](assign(assign({}, set), data)); + return baseConnection[dataCallbackName].call(this, data, set, cid); + }; + }); + return behavior; +}); +//# sourceMappingURL=callbacks-cache.js.map \ No newline at end of file diff --git a/dist/cjs/data/callbacks-cache/callbacks-cache.js.map b/dist/cjs/data/callbacks-cache/callbacks-cache.js.map new file mode 100644 index 00000000..fc1877ef --- /dev/null +++ b/dist/cjs/data/callbacks-cache/callbacks-cache.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../../data/callbacks-cache/callbacks-cache.js"],"names":["connect","require","assign","each","pairs","createdData","updatedData","destroyedData","module","exports","behavior","baseConnection","cacheCallback","dataCallbackName","data","set","cid","cacheConnection","call"],"mappings":";AAaA,IAAIA,OAAA,GAAUC,OAAA,CAAQ,sBAAR,CAAd;AACA,IAAIC,MAAA,GAASD,OAAA,CAAQ,2BAAR,CAAb,CADA;AAEA,IAAIE,IAAA,GAAOF,OAAA,CAAQ,uBAAR,CAAX,CAFA;AAKA,IAAIG,KAAA,GAAQ;AAAA,IAQXC,WAAA,EAAa,YARF;AAAA,IAgBXC,WAAA,EAAa,YAhBF;AAAA,IAwBXC,aAAA,EAAe,aAxBJ;AAAA,CAAZ,CALA;AAmCAC,MAAA,CAAOC,OAAP,GAAiBT,OAAA,CAAQU,QAAR,CAAiB,sBAAjB,EAAwC,UAASC,cAAT,EAAwB;AAAA,IAEhF,IAAID,QAAA,GAAW,EAAf,CAFgF;AAAA,IAIhFP,IAAA,CAAKC,KAAL,EAAY,UAASQ,aAAT,EAAwBC,gBAAxB,EAAyC;AAAA,QACpDH,QAAA,CAASG,gBAAT,IAA6B,UAASC,IAAT,EAAeC,GAAf,EAAoBC,GAApB,EAAwB;AAAA,YAGpD,KAAKC,eAAL,CAAqBL,aAArB,EAAqCV,MAAA,CAAOA,MAAA,CAAO,EAAP,EAAWa,GAAX,CAAP,EAAwBD,IAAxB,CAArC,EAHoD;AAAA,YAKpD,OAAOH,cAAA,CAAeE,gBAAf,EAAiCK,IAAjC,CAAsC,IAAtC,EAA6CJ,IAA7C,EAAmDC,GAAnD,EAAwDC,GAAxD,CAAP,CALoD;AAAA,SAArD,CADoD;AAAA,KAArD,EAJgF;AAAA,IAahF,OAAON,QAAP,CAbgF;AAAA,CAAhE,CAAjB","file":"callbacks-cache.js"} \ No newline at end of file diff --git a/dist/cjs/data/callbacks/callbacks.js b/dist/cjs/data/callbacks/callbacks.js new file mode 100644 index 00000000..22c9ee2f --- /dev/null +++ b/dist/cjs/data/callbacks/callbacks.js @@ -0,0 +1,26 @@ +/*can-connect@1.0.20#data/callbacks/callbacks*/ +var connect = require('../../can-connect.js'); +var each = require('can-util/js/each/each'); +var pairs = { + getListData: 'gotListData', + createData: 'createdData', + updateData: 'updatedData', + destroyData: 'destroyedData' +}; +module.exports = connect.behavior('data/callbacks', function (baseConnection) { + var behavior = {}; + each(pairs, function (callbackName, name) { + behavior[name] = function (params, cid) { + var self = this; + return baseConnection[name].call(this, params).then(function (data) { + if (self[callbackName]) { + return self[callbackName].call(self, data, params, cid); + } else { + return data; + } + }); + }; + }); + return behavior; +}); +//# sourceMappingURL=callbacks.js.map \ No newline at end of file diff --git a/dist/cjs/data/callbacks/callbacks.js.map b/dist/cjs/data/callbacks/callbacks.js.map new file mode 100644 index 00000000..5aba2ed8 --- /dev/null +++ b/dist/cjs/data/callbacks/callbacks.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../../data/callbacks/callbacks.js"],"names":["connect","require","each","pairs","getListData","createData","updateData","destroyData","module","exports","behavior","baseConnection","callbackName","name","params","cid","self","call","then","data"],"mappings":";AAUA,IAAIA,OAAA,GAAUC,OAAA,CAAQ,sBAAR,CAAd;AACA,IAAIC,IAAA,GAAOD,OAAA,CAAQ,uBAAR,CAAX,CADA;AAIA,IAAIE,KAAA,GAAQ;AAAA,IAiBXC,WAAA,EAAa,aAjBF;AAAA,IAmCXC,UAAA,EAAY,aAnCD;AAAA,IAoDXC,UAAA,EAAY,aApDD;AAAA,IAqEXC,WAAA,EAAa,eArEF;AAAA,CAAZ,CAJA;AA4EAC,MAAA,CAAOC,OAAP,GAAiBT,OAAA,CAAQU,QAAR,CAAiB,gBAAjB,EAAkC,UAASC,cAAT,EAAwB;AAAA,IAE1E,IAAID,QAAA,GAAW,EAAf,CAF0E;AAAA,IAM1ER,IAAA,CAAKC,KAAL,EAAY,UAASS,YAAT,EAAuBC,IAAvB,EAA4B;AAAA,QAEvCH,QAAA,CAASG,IAAT,IAAiB,UAASC,MAAT,EAAiBC,GAAjB,EAAqB;AAAA,YACrC,IAAIC,IAAA,GAAO,IAAX,CADqC;AAAA,YAGrC,OAAOL,cAAA,CAAeE,IAAf,EAAqBI,IAArB,CAA0B,IAA1B,EAAgCH,MAAhC,EAAwCI,IAAxC,CAA6C,UAASC,IAAT,EAAc;AAAA,gBACjE,IAAGH,IAAA,CAAKJ,YAAL,CAAH,EAAuB;AAAA,oBACtB,OAAOI,IAAA,CAAKJ,YAAL,EAAmBK,IAAnB,CAAwBD,IAAxB,EAA6BG,IAA7B,EAAmCL,MAAnC,EAA2CC,GAA3C,CAAP,CADsB;AAAA,iBAAvB,MAEO;AAAA,oBACN,OAAOI,IAAP,CADM;AAAA,iBAH0D;AAAA,aAA3D,CAAP,CAHqC;AAAA,SAAtC,CAFuC;AAAA,KAAxC,EAN0E;AAAA,IAqB1E,OAAOT,QAAP,CArB0E;AAAA,CAA1D,CAAjB","file":"callbacks.js"} \ No newline at end of file diff --git a/dist/cjs/data/combine-requests/combine-requests.js b/dist/cjs/data/combine-requests/combine-requests.js new file mode 100644 index 00000000..4b903b3d --- /dev/null +++ b/dist/cjs/data/combine-requests/combine-requests.js @@ -0,0 +1,103 @@ +/*can-connect@1.0.20#data/combine-requests/combine-requests*/ +var connect = require('../../can-connect.js'); +var canSet = require('can-set'); +var getItems = require('../../helpers/get-items.js'); +var deepAssign = require('can-util/js/deep-assign/deep-assign'); +var makeDeferred = require('../../helpers/deferred.js'); +var forEach = [].forEach; +module.exports = connect.behavior('data/combine-requests', function (baseConnection) { + var pendingRequests; + return { + unionPendingRequests: function (pendingRequests) { + var self = this; + pendingRequests.sort(function (pReq1, pReq2) { + if (canSet.subset(pReq1.set, pReq2.set, self.algebra)) { + return 1; + } else if (canSet.subset(pReq2.set, pReq1.set, self.algebra)) { + return -1; + } else { + return 0; + } + }); + var combineData = []; + var current; + doubleLoop(pendingRequests, { + start: function (pendingRequest) { + current = { + set: pendingRequest.set, + pendingRequests: [pendingRequest] + }; + combineData.push(current); + }, + iterate: function (pendingRequest) { + var combined = canSet.union(current.set, pendingRequest.set, self.algebra); + if (combined) { + current.set = combined; + current.pendingRequests.push(pendingRequest); + return true; + } + } + }); + return Promise.resolve(combineData); + }, + getSubset: function (set, unionSet, data) { + return canSet.getSubset(set, unionSet, data, this.algebra); + }, + time: 1, + getListData: function (set) { + set = set || {}; + var self = this; + if (!pendingRequests) { + pendingRequests = []; + setTimeout(function () { + var combineDataPromise = self.unionPendingRequests(pendingRequests); + pendingRequests = null; + combineDataPromise.then(function (combinedData) { + forEach.call(combinedData, function (combined) { + var combinedSet = deepAssign({}, combined.set); + baseConnection.getListData(combinedSet).then(function (data) { + if (combined.pendingRequests.length === 1) { + combined.pendingRequests[0].deferred.resolve(data); + } else { + forEach.call(combined.pendingRequests, function (pending) { + pending.deferred.resolve({ data: self.getSubset(pending.set, combined.set, getItems(data)) }); + }); + } + }, function (err) { + if (combined.pendingRequests.length === 1) { + combined.pendingRequests[0].deferred.reject(err); + } else { + forEach.call(combined.pendingRequests, function (pending) { + pending.deferred.reject(err); + }); + } + }); + }); + }); + }, this.time || 1); + } + var deferred = makeDeferred(); + pendingRequests.push({ + deferred: deferred, + set: set + }); + return deferred.promise; + } + }; +}); +var doubleLoop = function (arr, callbacks) { + var i = 0; + while (i < arr.length) { + callbacks.start(arr[i]); + var j = i + 1; + while (j < arr.length) { + if (callbacks.iterate(arr[j]) === true) { + arr.splice(j, 1); + } else { + j++; + } + } + i++; + } +}; +//# sourceMappingURL=combine-requests.js.map \ No newline at end of file diff --git a/dist/cjs/data/combine-requests/combine-requests.js.map b/dist/cjs/data/combine-requests/combine-requests.js.map new file mode 100644 index 00000000..c758db46 --- /dev/null +++ b/dist/cjs/data/combine-requests/combine-requests.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../../data/combine-requests/combine-requests.js"],"names":["connect","require","canSet","getItems","deepAssign","makeDeferred","forEach","module","exports","behavior","baseConnection","pendingRequests","unionPendingRequests","self","sort","pReq1","pReq2","subset","set","algebra","combineData","current","doubleLoop","start","pendingRequest","push","iterate","combined","union","Promise","resolve","getSubset","unionSet","data","time","getListData","setTimeout","combineDataPromise","then","combinedData","call","combinedSet","length","deferred","pending","err","reject","promise","arr","callbacks","i","j","splice"],"mappings":";AACA,IAAIA,OAAA,GAAUC,OAAA,CAAQ,sBAAR,CAAd;AACA,IAAIC,MAAA,GAASD,OAAA,CAAQ,SAAR,CAAb,CADA;AAEA,IAAIE,QAAA,GAAWF,OAAA,CAAQ,4BAAR,CAAf,CAFA;AAGA,IAAIG,UAAA,GAAaH,OAAA,CAAQ,qCAAR,CAAjB,CAHA;AAKA,IAAII,YAAA,GAAeJ,OAAA,CAAQ,2BAAR,CAAnB,CALA;AAMA,IAAIK,OAAA,GAAU,GAAGA,OAAjB,CANA;AA2EAC,MAAA,CAAOC,OAAP,GAAiBR,OAAA,CAAQS,QAAR,CAAiB,uBAAjB,EAAyC,UAASC,cAAT,EAAwB;AAAA,IACjF,IAAIC,eAAJ,CADiF;AAAA,IAGjF,OAAO;AAAA,QAiDNC,oBAAA,EAAsB,UAASD,eAAT,EAAyB;AAAA,YAQ9C,IAAIE,IAAA,GAAO,IAAX,CAR8C;AAAA,YAU9CF,eAAA,CAAgBG,IAAhB,CAAqB,UAASC,KAAT,EAAgBC,KAAhB,EAAsB;AAAA,gBAE1C,IAAGd,MAAA,CAAOe,MAAP,CAAcF,KAAA,CAAMG,GAApB,EAAyBF,KAAA,CAAME,GAA/B,EAAoCL,IAAA,CAAKM,OAAzC,CAAH,EAAsD;AAAA,oBACrD,OAAO,CAAP,CADqD;AAAA,iBAAtD,MAEO,IAAIjB,MAAA,CAAOe,MAAP,CAAcD,KAAA,CAAME,GAApB,EAAyBH,KAAA,CAAMG,GAA/B,EAAoCL,IAAA,CAAKM,OAAzC,CAAJ,EAAwD;AAAA,oBAC9D,OAAO,CAAC,CAAR,CAD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,GAAA,CAAIN,MAAf,EAAwB;AAAA,YACvB,IAAGO,SAAA,CAAUvB,OAAV,CAAkBsB,GAAA,CAAIG,CAAJ,CAAlB,MAA8B,IAAjC,EAAuC;AAAA,gBACtCH,GAAA,CAAII,MAAJ,CAAWD,CAAX,EAAc,CAAd,EADsC;AAAA,aAAvC,MAEO;AAAA,gBACNA,CAAA,GADM;AAAA,aAHgB;AAAA,SAHH;AAAA,QAUrBD,CAAA,GAVqB;AAAA,KAFkB;AAAA,CAAzC","file":"combine-requests.js"} \ No newline at end of file diff --git a/dist/cjs/data/localstorage-cache/localstorage-cache.js b/dist/cjs/data/localstorage-cache/localstorage-cache.js new file mode 100644 index 00000000..4ba89c2a --- /dev/null +++ b/dist/cjs/data/localstorage-cache/localstorage-cache.js @@ -0,0 +1,258 @@ +/*can-connect@1.0.20#data/localstorage-cache/localstorage-cache*/ +var getItems = require('../../helpers/get-items.js'); +var connect = require('../../can-connect.js'); +var sortedSetJSON = require('../../helpers/sorted-set-json.js'); +var canSet = require('can-set'); +var forEach = [].forEach; +var map = [].map; +var setAdd = require('../../helpers/set-add.js'); +var indexOf = require('../../helpers/get-index-by-id.js'); +var assign = require('can-util/js/assign/assign'); +var overwrite = require('../../helpers/overwrite.js'); +module.exports = connect.behavior('data/localstorage-cache', function (baseConnection) { + var behavior = { + _instances: {}, + getSetData: function () { + var sets = {}; + var self = this; + forEach.call(JSON.parse(localStorage.getItem(this.name + '-sets')) || [], function (set) { + var setKey = sortedSetJSON(set); + if (localStorage.getItem(self.name + '/set/' + setKey)) { + sets[setKey] = { + set: set, + setKey: setKey + }; + } + }); + return sets; + }, + _getSets: function (setData) { + var sets = []; + setData = setData || this.getSetData(); + for (var setKey in setData) { + sets.push(JSON.parse(setKey)); + } + return sets; + }, + getInstance: function (id) { + var res = localStorage.getItem(this.name + '/instance/' + id); + if (res) { + return JSON.parse(res); + } + }, + updateInstance: function (props) { + var id = this.id(props); + var instance = this.getInstance(id); + if (!instance) { + instance = props; + } else { + overwrite(instance, props, this.idProp); + } + localStorage.setItem(this.name + '/instance/' + id, JSON.stringify(instance)); + return instance; + }, + getInstances: function (ids) { + var self = this; + return map.call(ids, function (id) { + return self.getInstance(id); + }); + }, + removeSet: function (setKey) { + var sets = this.getSetData(); + localStorage.removeItem(this.name + '/set/' + setKey); + delete sets[setKey]; + }, + updateSets: function (sets) { + var setData = this._getSets(sets); + localStorage.setItem(this.name + '-sets', JSON.stringify(setData)); + }, + updateSet: function (setDatum, items, newSet) { + var newSetKey = newSet ? sortedSetJSON(newSet) : setDatum.setKey; + if (newSet) { + if (newSetKey !== setDatum.setKey) { + var sets = this.getSetData(); + localStorage.removeItem(this.name + '/set/' + setDatum.setKey); + delete sets[setDatum.setKey]; + sets[newSetKey] = { + setKey: newSetKey, + set: newSet + }; + this.updateSets(sets); + } + } + setDatum.items = items; + var self = this; + var ids = map.call(items, function (item) { + var id = self.id(item); + localStorage.setItem(self.name + '/instance/' + id, JSON.stringify(item)); + return id; + }); + localStorage.setItem(this.name + '/set/' + newSetKey, JSON.stringify(ids)); + }, + addSet: function (set, data) { + var items = getItems(data); + var sets = this.getSetData(); + var setKey = sortedSetJSON(set); + sets[setKey] = { + setKey: setKey, + items: items, + set: set + }; + var self = this; + var ids = map.call(items, function (item) { + var id = self.id(item); + localStorage.setItem(self.name + '/instance/' + id, JSON.stringify(item)); + return id; + }); + localStorage.setItem(this.name + '/set/' + setKey, JSON.stringify(ids)); + this.updateSets(sets); + }, + _eachSet: function (cb) { + var sets = this.getSetData(); + var self = this; + var loop = function (setDatum, setKey) { + return cb.call(self, setDatum, setKey, function () { + if (!('items' in setDatum)) { + var ids = JSON.parse(localStorage.getItem(self.name + '/set/' + setKey)); + setDatum.items = self.getInstances(ids); + } + return setDatum.items; + }); + }; + for (var setKey in sets) { + var setDatum = sets[setKey]; + var result = loop(setDatum, setKey); + if (result !== undefined) { + return result; + } + } + }, + clear: function () { + var sets = this.getSetData(); + for (var setKey in sets) { + localStorage.removeItem(this.name + '/set/' + setKey); + } + localStorage.removeItem(this.name + '-sets'); + var keys = []; + for (var i = 0, len = localStorage.length; i < len; ++i) { + if (localStorage.key(i).indexOf(this.name + '/instance/') === 0) { + keys.push(localStorage.key(i)); + } + } + forEach.call(keys, function (key) { + localStorage.removeItem(key); + }); + this._instances = {}; + }, + getSets: function () { + return Promise.resolve(this._getSets()); + }, + getListData: function (set) { + set = set || {}; + var listData = this.getListDataSync(set); + if (listData) { + return Promise.resolve(listData); + } + return Promise.reject({ + message: 'no data', + error: 404 + }); + }, + getListDataSync: function (set) { + var sets = this._getSets(); + for (var i = 0; i < sets.length; i++) { + var checkSet = sets[i]; + if (canSet.subset(set, checkSet, this.algebra)) { + var items = canSet.getSubset(set, checkSet, this.__getListData(checkSet), this.algebra); + return { data: items }; + } + } + }, + __getListData: function (set) { + var setKey = sortedSetJSON(set); + var setDatum = this.getSetData()[setKey]; + if (setDatum) { + var localData = localStorage.getItem(this.name + '/set/' + setKey); + if (localData) { + return this.getInstances(JSON.parse(localData)); + } + } + }, + getData: function (params) { + var id = this.id(params); + var res = localStorage.getItem(this.name + '/instance/' + id); + if (res) { + return Promise.resolve(JSON.parse(res)); + } else { + return Promise.reject({ + message: 'no data', + error: 404 + }); + } + }, + updateListData: function (data, set) { + set = set || {}; + var items = getItems(data); + var sets = this.getSetData(); + var self = this; + for (var setKey in sets) { + var setDatum = sets[setKey]; + var union = canSet.union(setDatum.set, set, this.algebra); + if (union) { + return this.getListData(setDatum.set).then(function (setData) { + self.updateSet(setDatum, canSet.getUnion(setDatum.set, set, getItems(setData), items, this.algebra), union); + }); + } + } + this.addSet(set, data); + return Promise.resolve(); + }, + createData: function (props) { + var self = this; + var instance = this.updateInstance(props); + this._eachSet(function (setDatum, setKey, getItems) { + if (canSet.has(setDatum.set, instance, this.algebra)) { + self.updateSet(setDatum, setAdd(self, setDatum.set, getItems(), instance, self.algebra), setDatum.set); + } + }); + return Promise.resolve(assign({}, instance)); + }, + updateData: function (props) { + var self = this; + var instance = this.updateInstance(props); + this._eachSet(function (setDatum, setKey, getItems) { + var items = getItems(); + var index = indexOf(self, instance, items); + if (canSet.has(setDatum.set, instance, this.algebra)) { + if (index === -1) { + self.updateSet(setDatum, setAdd(self, setDatum.set, getItems(), instance, self.algebra)); + } else { + items.splice(index, 1, instance); + self.updateSet(setDatum, items); + } + } else if (index !== -1) { + items.splice(index, 1); + self.updateSet(setDatum, items); + } + }); + return Promise.resolve(assign({}, instance)); + }, + destroyData: function (props) { + var self = this; + var instance = this.updateInstance(props); + this._eachSet(function (setDatum, setKey, getItems) { + var items = getItems(); + var index = indexOf(self, instance, items); + if (index !== -1) { + items.splice(index, 1); + self.updateSet(setDatum, items); + } + }); + var id = this.id(instance); + localStorage.removeItem(this.name + '/instance/' + id); + return Promise.resolve(assign({}, instance)); + } + }; + return behavior; +}); +//# sourceMappingURL=localstorage-cache.js.map \ No newline at end of file diff --git a/dist/cjs/data/localstorage-cache/localstorage-cache.js.map b/dist/cjs/data/localstorage-cache/localstorage-cache.js.map new file mode 100644 index 00000000..529e9e37 --- /dev/null +++ b/dist/cjs/data/localstorage-cache/localstorage-cache.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../../data/localstorage-cache/localstorage-cache.js"],"names":["getItems","require","connect","sortedSetJSON","canSet","forEach","map","setAdd","indexOf","assign","overwrite","module","exports","behavior","baseConnection","_instances","getSetData","sets","self","call","JSON","parse","localStorage","getItem","name","set","setKey","_getSets","setData","push","getInstance","id","res","updateInstance","props","instance","idProp","setItem","stringify","getInstances","ids","removeSet","removeItem","updateSets","updateSet","setDatum","items","newSet","newSetKey","item","addSet","data","_eachSet","cb","loop","result","undefined","clear","keys","i","len","length","key","getSets","Promise","resolve","getListData","listData","getListDataSync","reject","message","error","checkSet","subset","algebra","getSubset","__getListData","localData","getData","params","updateListData","union","then","getUnion","createData","has","updateData","index","splice","destroyData"],"mappings":";AA+CA,IAAIA,QAAA,GAAWC,OAAA,CAAQ,4BAAR,CAAf;AACA,IA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AAI8C,KAAA,GAAQ9C,QAAA,EAAZ,CAFiD;AAAA,gBAGjD,IAAIuF,KAAA,GAAQ/E,OAAA,CAAQU,IAAR,EAAciB,QAAd,EAAwBW,KAAxB,CAAZ,CAHiD;AAAA,gBAKjD,IAAGyC,KAAA,KAAU,CAAC,CAAd,EAAgB;AAAA,oBAEfzC,KAAA,CAAM0C,MAAN,CAAaD,KAAb,EAAmB,CAAnB,EAFe;AAAA,oBAGfrE,IAAA,CAAK0B,SAAL,CAAeC,QAAf,EAAyBC,KAAzB,EAHe;AAAA,iBALiC;AAAA,aAAlD,EAJ2B;AAAA,YAe3B,IAAIf,EAAA,GAAK,KAAKA,EAAL,CAAQI,QAAR,CAAT,CAf2B;AAAA,YAgB3Bb,YAAA,CAAaoB,UAAb,CAAwB,KAAKlB,IAAL,GAAU,YAAV,GAAuBO,EAA/C,EAhB2B;AAAA,YAiB3B,OAAOiC,OAAA,CAAQC,OAAR,CAAgBxD,MAAA,CAAO,EAAP,EAAU0B,QAAV,CAAhB,CAAP,CAjB2B;AAAA,SA7ad;AAAA,KAAf,CAFmF;AAAA,IAocnF,OAAOtB,QAAP,CApcmF;AAAA,CAAnE,CAAjB","file":"localstorage-cache.js"} \ No newline at end of file diff --git a/dist/cjs/data/memory-cache/memory-cache.js b/dist/cjs/data/memory-cache/memory-cache.js new file mode 100644 index 00000000..262ede7c --- /dev/null +++ b/dist/cjs/data/memory-cache/memory-cache.js @@ -0,0 +1,215 @@ +/*can-connect@1.0.20#data/memory-cache/memory-cache*/ +var getItems = require('../../helpers/get-items.js'); +var connect = require('../../can-connect.js'); +var sortedSetJSON = require('../../helpers/sorted-set-json.js'); +var canSet = require('can-set'); +var overwrite = require('../../helpers/overwrite.js'); +var setAdd = require('../../helpers/set-add.js'); +var indexOf = require('../../helpers/get-index-by-id.js'); +var assign = require('can-util/js/assign/assign'); +var cloneData = require('../../helpers/clone-data.js'); +module.exports = connect.behavior('data/memory-cache', function (baseConnection) { + var behavior = { + _sets: {}, + getSetData: function () { + return this._sets; + }, + __getListData: function (set) { + var setsData = this.getSetData(); + var setData = setsData[sortedSetJSON(set)]; + if (setData) { + return setData.items; + } + }, + _instances: {}, + getInstance: function (id) { + return this._instances[id]; + }, + removeSet: function (setKey, noUpdate) { + var sets = this.getSetData(); + delete sets[setKey]; + if (noUpdate !== true) { + this.updateSets(); + } + }, + updateSets: function () { + }, + updateInstance: function (props) { + var id = this.id(props); + if (!(id in this._instances)) { + this._instances[id] = props; + } else { + overwrite(this._instances[id], props, this.idProp); + } + return this._instances[id]; + }, + updateSet: function (setDatum, items, newSet) { + var newSetKey = newSet ? sortedSetJSON(newSet) : setDatum.setKey; + if (newSet) { + if (newSetKey !== setDatum.setKey) { + var sets = this.getSetData(); + var oldSetKey = setDatum.setKey; + sets[newSetKey] = setDatum; + setDatum.setKey = newSetKey; + setDatum.set = assign({}, newSet); + this.removeSet(oldSetKey); + } + } + setDatum.items = items; + var self = this; + items.forEach(function (item) { + self.updateInstance(item); + }); + }, + addSet: function (set, data) { + var items = getItems(data); + var sets = this.getSetData(); + var setKey = sortedSetJSON(set); + sets[setKey] = { + setKey: setKey, + items: items, + set: assign({}, set) + }; + var self = this; + items.forEach(function (item) { + self.updateInstance(item); + }); + this.updateSets(); + }, + _eachSet: function (cb) { + var sets = this.getSetData(); + var self = this; + var loop = function (setDatum, setKey) { + return cb.call(self, setDatum, setKey, function () { + return setDatum.items; + }); + }; + for (var setKey in sets) { + var setDatum = sets[setKey]; + var result = loop(setDatum, setKey); + if (result !== undefined) { + return result; + } + } + }, + _getSets: function () { + var sets = [], setsData = this.getSetData(); + for (var prop in setsData) { + sets.push(setsData[prop].set); + } + return sets; + }, + getSets: function () { + return Promise.resolve(this._getSets()); + }, + clear: function () { + this._instances = {}; + this._sets = {}; + }, + getListData: function (set) { + set = set || {}; + var listData = this.getListDataSync(set); + if (listData) { + return Promise.resolve(listData); + } + return Promise.reject({ + message: 'no data', + error: 404 + }); + }, + getListDataSync: function (set) { + var sets = this._getSets(); + for (var i = 0; i < sets.length; i++) { + var checkSet = sets[i]; + if (canSet.subset(set, checkSet, this.algebra)) { + var source = this.__getListData(checkSet); + var items = canSet.getSubset(set, checkSet, source, this.algebra); + return { + data: items, + count: source.length + }; + } + } + }, + _getListData: function (set) { + return this.getListDataSync(set); + }, + updateListData: function (data, set) { + set = set || {}; + var clonedData = cloneData(data); + var items = getItems(clonedData); + var sets = this.getSetData(); + var self = this; + for (var setKey in sets) { + var setDatum = sets[setKey]; + var union = canSet.union(setDatum.set, set, this.algebra); + if (union) { + var getSet = assign({}, setDatum.set); + return this.getListData(getSet).then(function (setData) { + self.updateSet(setDatum, canSet.getUnion(getSet, set, getItems(setData), items, self.algebra), union); + }); + } + } + this.addSet(set, clonedData); + return Promise.resolve(); + }, + getData: function (params) { + var id = this.id(params); + var res = this.getInstance(id); + if (res) { + return Promise.resolve(res); + } else { + return Promise.reject({ + message: 'no data', + error: 404 + }); + } + }, + createData: function (props) { + var self = this; + var instance = this.updateInstance(props); + this._eachSet(function (setDatum, setKey, getItems) { + if (canSet.has(setDatum.set, instance, this.algebra)) { + self.updateSet(setDatum, setAdd(self, setDatum.set, getItems(), instance, self.algebra), setDatum.set); + } + }); + return Promise.resolve(assign({}, instance)); + }, + updateData: function (props) { + var self = this; + var instance = this.updateInstance(props); + this._eachSet(function (setDatum, setKey, getItems) { + var items = getItems(); + var index = indexOf(self, instance, items); + if (canSet.subset(instance, setDatum.set, this.algebra)) { + if (index === -1) { + self.updateSet(setDatum, setAdd(self, setDatum.set, getItems(), instance, self.algebra)); + } else { + items.splice(index, 1, instance); + self.updateSet(setDatum, items); + } + } else if (index !== -1) { + items.splice(index, 1); + self.updateSet(setDatum, items); + } + }); + return Promise.resolve(assign({}, instance)); + }, + destroyData: function (props) { + var self = this; + this._eachSet(function (setDatum, setKey, getItems) { + var items = getItems(); + var index = indexOf(self, props, items); + if (index !== -1) { + items.splice(index, 1); + self.updateSet(setDatum, items); + } + }); + var id = this.id(props); + delete this._instances[id]; + return Promise.resolve(assign({}, props)); + } + }; + return behavior; +}); +//# sourceMappingURL=memory-cache.js.map \ No newline at end of file diff --git a/dist/cjs/data/memory-cache/memory-cache.js.map b/dist/cjs/data/memory-cache/memory-cache.js.map new file mode 100644 index 00000000..1f5ea125 --- /dev/null +++ b/dist/cjs/data/memory-cache/memory-cache.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../../data/memory-cache/memory-cache.js"],"names":["getItems","require","connect","sortedSetJSON","canSet","overwrite","setAdd","indexOf","assign","cloneData","module","exports","behavior","baseConnection","_sets","getSetData","__getListData","set","setsData","setData","items","_instances","getInstance","id","removeSet","setKey","noUpdate","sets","updateSets","updateInstance","props","idProp","updateSet","setDatum","newSet","newSetKey","oldSetKey","self","forEach","item","addSet","data","_eachSet","cb","loop","call","result","undefined","_getSets","prop","push","getSets","Promise","resolve","clear","getListData","listData","getListDataSync","reject","message","error","i","length","checkSet","subset","algebra","source","getSubset","count","_getListData","updateListData","clonedData","union","getSet","then","getUnion","getData","params","res","createData","instance","has","updateData","index","splice","destroyData"],"mappings":";AA2CA,IAAIA,QAAA,GAAWC,OAAA,CAAQ,4BAAR,CAAf;AACA,IAAIC,OAAA,GAAUD,OAAA,CAAQ,sBAAR,CAAd,CADA;AAEA,IAAIE,aAAA,GAAgBF,OAAA,CAAQ,kCAAR,CAApB,CAFA;AAGA,IAAIG,MAAA,GAASH,OAAA,CAAQ,SAAR,CAAb,CAHA;AAIA,IAAII,SAAA,GAAYJ,OAAA,CAAQ,4BAAR,CAAhB,CAJA;AAKA,IAAIK,MAAA,GAASL,OAAA,CAAQ,0BAAR,CAAb,CALA;AAMA,IAAIM,OAAA,GAAUN,OAAA,CAAQ,kCAAR,CAAd,CANA;AAOA,IAAIO,MAAA,GAASP,OAAA,CAAQ,2BAAR,CAAb,CAPA;AAQA,IAAIQ,SAAA,GAAYR,OAAA,CAAQ,6BAAR,CAAhB,CARA;AAUAS,MAAA,CAAOC,OAAP,GAAiBT,OAA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CAAC,CAAd,EAAgB;AAAA,oBAEf/D,KAAA,CAAMgE,MAAN,CAAaD,KAAb,EAAmB,CAAnB,EAFe;AAAA,oBAGf9C,IAAA,CAAKL,SAAL,CAAeC,QAAf,EAAyBb,KAAzB,EAHe;AAAA,iBALiC;AAAA,aAAlD,EAH2B;AAAA,YAc3B,IAAIG,EAAA,GAAK,KAAKA,EAAL,CAAQO,KAAR,CAAT,CAd2B;AAAA,YAe3B,OAAO,KAAKT,UAAL,CAAgBE,EAAhB,CAAP,CAf2B;AAAA,YAgB3B,OAAO6B,OAAA,CAAQC,OAAR,CAAgB7C,MAAA,CAAO,EAAP,EAAUsB,KAAV,CAAhB,CAAP,CAhB2B;AAAA,SA3Wd;AAAA,KAAf,CAF6E;AAAA,IAiY7E,OAAOlB,QAAP,CAjY6E;AAAA,CAA7D,CAAjB","file":"memory-cache.js"} \ No newline at end of file diff --git a/dist/cjs/data/parse/parse.js b/dist/cjs/data/parse/parse.js new file mode 100644 index 00000000..326006db --- /dev/null +++ b/dist/cjs/data/parse/parse.js @@ -0,0 +1,57 @@ +/*can-connect@1.0.20#data/parse/parse*/ +var connect = require('../../can-connect.js'); +var each = require('can-util/js/each/each'); +var isArray = require('can-util/js/is-array/is-array'); +var getObject = require('can-util/js/get/get'); +module.exports = connect.behavior('data/parse', function (baseConnection) { + var behavior = { + parseListData: function (responseData) { + if (baseConnection.parseListData) { + responseData = baseConnection.parseListData.apply(this, arguments); + } + var result; + if (isArray(responseData)) { + result = { data: responseData }; + } else { + var prop = this.parseListProp || 'data'; + responseData.data = getObject(responseData, prop); + result = responseData; + if (prop !== 'data') { + delete responseData[prop]; + } + if (!isArray(result.data)) { + throw new Error('Could not get any raw data while converting using .parseListData'); + } + } + var arr = []; + for (var i = 0; i < result.data.length; i++) { + arr.push(this.parseInstanceData(result.data[i])); + } + result.data = arr; + return result; + }, + parseInstanceData: function (props) { + if (baseConnection.parseInstanceData) { + props = baseConnection.parseInstanceData.apply(this, arguments) || props; + } + return this.parseInstanceProp ? getObject(props, this.parseInstanceProp) || props : props; + } + }; + each(pairs, function (parseFunction, name) { + behavior[name] = function (params) { + var self = this; + return baseConnection[name].call(this, params).then(function () { + return self[parseFunction].apply(self, arguments); + }); + }; + }); + return behavior; +}); +var pairs = { + getListData: 'parseListData', + getData: 'parseInstanceData', + createData: 'parseInstanceData', + updateData: 'parseInstanceData', + destroyData: 'parseInstanceData' +}; +//# sourceMappingURL=parse.js.map \ No newline at end of file diff --git a/dist/cjs/data/parse/parse.js.map b/dist/cjs/data/parse/parse.js.map new file mode 100644 index 00000000..1b51025b --- /dev/null +++ b/dist/cjs/data/parse/parse.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../../data/parse/parse.js"],"names":["connect","require","each","isArray","getObject","module","exports","behavior","baseConnection","parseListData","responseData","apply","arguments","result","data","prop","parseListProp","Error","arr","i","length","push","parseInstanceData","props","parseInstanceProp","pairs","parseFunction","name","params","self","call","then","getListData","getData","createData","updateData","destroyData"],"mappings":";AAuDC,IAAIA,OAAA,GAAUC,OAAA,CAAQ,sBAAR,CAAd;AACA,IAAIC,IAAA,GAAOD,OAAA,CAAQ,uBAAR,CAAX,CADA;AAEA,IAAIE,OAAA,GAAUF,OAAA,CAAQ,+BAAR,CAAd,CAFA;AAGA,IAAIG,SAAA,GAAYH,OAAA,CAAQ,qBAAR,CAAhB,CAHA;AAMDI,MAAA,CAAOC,OAAP,GAAiBN,OAAA,CAAQO,QAAR,CAAiB,YAAjB,EAA8B,UAASC,cAAT,EAAwB;AAAA,IAEtE,IAAID,QAAA,GAAW;AAAA,QAoEdE,aAAA,EAAe,UAAUC,YAAV,EAAyB;AAAA,YAGvC,IAAGF,cAAA,CAAeC,aAAlB,EAAiC;AAAA,gBAC9BC,YAAA,GAAeF,cAAA,CAAeC,aAAf,CAA6BE,KAA7B,CAAmC,IAAnC,EAAyCC,SAAzC,CAAf,CAD8B;AAAA,aAHM;AAAA,YAOvC,IAAIC,MAAJ,CAPuC;AAAA,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AAA,aAFD;AAAA,YAOpC,OAAO,KAAKC,iBAAL,GAAyBpB,SAAA,CAAUmB,KAAV,EAAiB,KAAKC,iBAAtB,KAA4CD,KAArE,GAA6EA,KAApF,CAPoC;AAAA,SAxKvB;AAAA,KAAf,CAFsE;AAAA,IAiQtErB,IAAA,CAAKuB,KAAL,EAAY,UAASC,aAAT,EAAwBC,IAAxB,EAA6B;AAAA,QACxCpB,QAAA,CAASoB,IAAT,IAAiB,UAASC,MAAT,EAAgB;AAAA,YAChC,IAAIC,IAAA,GAAO,IAAX,CADgC;AAAA,YAEhC,OAAOrB,cAAA,CAAemB,IAAf,EAAqBG,IAArB,CAA0B,IAA1B,EAAgCF,MAAhC,EAAwCG,IAAxC,CAA6C,YAAU;AAAA,gBAC7D,OAAOF,IAAA,CAAKH,aAAL,EAAoBf,KAApB,CAA0BkB,IAA1B,EAAgCjB,SAAhC,CAAP,CAD6D;AAAA,aAAvD,CAAP,CAFgC;AAAA,SAAjC,CADwC;AAAA,KAAzC,EAjQsE;AAAA,IA0QtE,OAAOL,QAAP,CA1QsE;AAAA,CAAtD,CAAjB,CANC;AAoRD,IAAIkB,KAAA,GAAQ;AAAA,IACXO,WAAA,EAAa,eADF;AAAA,IAEXC,OAAA,EAAS,mBAFE;AAAA,IAGXC,UAAA,EAAY,mBAHD;AAAA,IAIXC,UAAA,EAAY,mBAJD;AAAA,IAKXC,WAAA,EAAa,mBALF;AAAA,CAAZ","file":"parse.js"} \ No newline at end of file diff --git a/dist/cjs/data/url/url.js b/dist/cjs/data/url/url.js new file mode 100644 index 00000000..274971f8 --- /dev/null +++ b/dist/cjs/data/url/url.js @@ -0,0 +1,99 @@ +/*can-connect@1.0.20#data/url/url*/ +var isArray = require('can-util/js/is-array/is-array'); +var assign = require('can-util/js/assign/assign'); +var each = require('can-util/js/each/each'); +var ajax = require('can-util/dom/ajax/ajax'); +var string = require('can-util/js/string/string'); +var getIdProps = require('../../helpers/get-id-props.js'); +var dev = require('can-util/js/dev/dev'); +var connect = require('../../can-connect.js'); +var makePromise = require('can-util/js/make-promise/make-promise'); +module.exports = connect.behavior('data/url', function (baseConnection) { + var behavior = {}; + each(pairs, function (reqOptions, name) { + behavior[name] = function (params) { + if (typeof this.url === 'object') { + if (typeof this.url[reqOptions.prop] === 'function') { + return makePromise(this.url[reqOptions.prop](params)); + } else if (this.url[reqOptions.prop]) { + return makePromise(makeAjax(this.url[reqOptions.prop], params, reqOptions.type, this.ajax || ajax, findContentType(this.url), reqOptions)); + } + } + var resource = typeof this.url === 'string' ? this.url : this.url.resource; + if (resource) { + var idProps = getIdProps(this); + return makePromise(makeAjax(createURLFromResource(resource, idProps[0], reqOptions.prop), params, reqOptions.type, this.ajax || ajax, findContentType(this.url), reqOptions)); + } + return baseConnection[name].call(this, params); + }; + }); + return behavior; +}); +var pairs = { + getListData: { + prop: 'getListData', + type: 'GET' + }, + getData: { + prop: 'getData', + type: 'GET' + }, + createData: { + prop: 'createData', + type: 'POST' + }, + updateData: { + prop: 'updateData', + type: 'PUT' + }, + destroyData: { + prop: 'destroyData', + type: 'DELETE', + includeData: false + } +}; +var findContentType = function (url) { + if (typeof url === 'object' && url.contentType) { + var acceptableType = url.contentType === 'application/x-www-form-urlencoded' || url.contentType === 'application/json'; + if (acceptableType) { + return url.contentType; + } else { + } + } + return 'application/json'; +}; +var makeAjax = function (ajaxOb, data, type, ajax, contentType, reqOptions) { + var params = {}; + if (typeof ajaxOb === 'string') { + var parts = ajaxOb.split(/\s+/); + params.url = parts.pop(); + if (parts.length) { + params.type = parts.pop(); + } + } else { + assign(params, ajaxOb); + } + params.data = typeof data === 'object' && !isArray(data) ? assign(params.data || {}, data) : data; + params.url = string.sub(params.url, params.data, true); + var encodeJSON = contentType !== 'application/x-www-form-urlencoded' && (type && (type === 'POST' || type === 'PUT')); + if (encodeJSON) { + params.data = JSON.stringify(params.data); + params.contentType = contentType; + } + if (reqOptions.includeData === false) { + delete params.data; + } + return ajax(assign({ + type: type || 'post', + dataType: 'json' + }, params)); +}; +var createURLFromResource = function (resource, idProp, name) { + var url = resource.replace(/\/+$/, ''); + if (name === 'getListData' || name === 'createData') { + return url; + } else { + return url + '/{' + idProp + '}'; + } +}; +//# sourceMappingURL=url.js.map \ No newline at end of file diff --git a/dist/cjs/data/url/url.js.map b/dist/cjs/data/url/url.js.map new file mode 100644 index 00000000..b07a428a --- /dev/null +++ b/dist/cjs/data/url/url.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../../data/url/url.js"],"names":["isArray","require","assign","each","ajax","string","getIdProps","dev","connect","makePromise","module","exports","behavior","baseConnection","pairs","reqOptions","name","params","url","prop","makeAjax","type","findContentType","resource","idProps","createURLFromResource","call","getListData","getData","createData","updateData","destroyData","includeData","contentType","acceptableType","ajaxOb","data","parts","split","pop","length","sub","encodeJSON","JSON","stringify","dataType","idProp","replace"],"mappings":";AAgGA,IAAIA,OAAA,GAAUC,OAAA,CAAQ,+BAAR,CAAd;AACA,IAAIC,MAAA,GAASD,OAAA,CAAQ,2BAAR,CAAb,CADA;AAEA,IAAIE,IAAA,GAAOF,OAAA,CAAQ,uBAAR,CAAX,CAFA;AAGA,IAAIG,IAAA,GAAOH,OAAA,CAAQ,wBAAR,CAAX,CAHA;AAIA,IAAII,MAAA,GAASJ,OAAA,CAAQ,2BAAR,CAAb,CAJA;AAKA,IAAIK,UAAA,GAAaL,OAAA,CAAQ,+BAAR,CAAjB,CALA;AAMA,IAAIM,GAAA,GAAMN,OAAA,CAAQ,qBAAR,CAAV,CANA;AAOA,IAAIO,OAAA,GAAUP,OAAA,CAAQ,sBAAR,CAAd,CAPA;AASA,IAAIQ,WAAA,GAAcR,OAAA,CAAQ,uCAAR,CAAlB,CATA;AAcAS,MAAA,CAAOC,OAAP,GAAiBH,OAAA,CAAQI,QAAR,CAAiB,UAAjB,EAA6B,UAASC,cAAT,EAAyB;AAAA,IAGtE,IAAID,QAAA,GAAW,EAAf,CAHsE;AAAA,IAItET,IAAA,CAAKW,KAAL,EAAY,UAAS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ADe;AAAA,QAEfnB,MAAA,CAAOgB,WAAP,GAAqBA,WAArB,CAFe;AAAA,KA3B6D;AAAA,IAgC7E,IAAGlB,UAAA,CAAWiB,WAAX,KAA2B,KAA9B,EAAqC;AAAA,QACpC,OAAOf,MAAA,CAAOmB,IAAd,CADoC;AAAA,KAhCwC;AAAA,IAoC7E,OAAOhC,IAAA,CAAKF,MAAA,CAAO;AAAA,QAClBmB,IAAA,EAAMA,IAAA,IAAQ,MADI;AAAA,QAElBwB,QAAA,EAAU,MAFQ;AAAA,KAAP,EAGT5B,MAHS,CAAL,CAAP,CApC6E;AAAA,CAA9E,CAtOA;AAgRA,IAAIQ,qBAAA,GAAwB,UAASF,QAAT,EAAmBuB,MAAnB,EAA2B9B,IAA3B,EAAiC;AAAA,IAE5D,IAAIE,GAAA,GAAMK,QAAA,CAASwB,OAAT,CAAiB,MAAjB,EAAyB,EAAzB,CAAV,CAF4D;AAAA,IAG5D,IAAI/B,IAAA,KAAS,aAAT,IAA0BA,IAAA,KAAS,YAAvC,EAAqD;AAAA,QACpD,OAAOE,GAAP,CADoD;AAAA,KAArD,MAEO;AAAA,QACN,OAAOA,GAAA,GAAM,IAAN,GAAa4B,MAAb,GAAsB,GAA7B,CADM;AAAA,KALqD;AAAA,CAA7D","file":"url.js"} \ No newline at end of file diff --git a/dist/cjs/fall-through-cache/fall-through-cache.js b/dist/cjs/fall-through-cache/fall-through-cache.js new file mode 100644 index 00000000..9bb2e8db --- /dev/null +++ b/dist/cjs/fall-through-cache/fall-through-cache.js @@ -0,0 +1,96 @@ +/*can-connect@1.0.20#fall-through-cache/fall-through-cache*/ +var connect = require('../can-connect.js'); +var sortedSetJSON = require('../helpers/sorted-set-json.js'); +module.exports = connect.behavior('fall-through-cache', function (baseConnection) { + var behavior = { + hydrateList: function (listData, set) { + set = set || this.listSet(listData); + var id = sortedSetJSON(set); + var list = baseConnection.hydrateList.call(this, listData, set); + if (this._getHydrateListCallbacks[id]) { + this._getHydrateListCallbacks[id].shift()(list); + if (!this._getHydrateListCallbacks[id].length) { + delete this._getHydrateListCallbacks[id]; + } + } + return list; + }, + _getHydrateListCallbacks: {}, + _getHydrateList: function (set, callback) { + var id = sortedSetJSON(set); + if (!this._getHydrateListCallbacks[id]) { + this._getHydrateListCallbacks[id] = []; + } + this._getHydrateListCallbacks[id].push(callback); + }, + getListData: function (set) { + set = set || {}; + var self = this; + return this.cacheConnection.getListData(set).then(function (data) { + self._getHydrateList(set, function (list) { + self.addListReference(list, set); + setTimeout(function () { + baseConnection.getListData.call(self, set).then(function (listData) { + self.cacheConnection.updateListData(listData, set); + self.updatedList(list, listData, set); + self.deleteListReference(list, set); + }, function (e) { + console.log('REJECTED', e); + }); + }, 1); + }); + return data; + }, function () { + var listData = baseConnection.getListData.call(self, set); + listData.then(function (listData) { + self.cacheConnection.updateListData(listData, set); + }); + return listData; + }); + }, + hydrateInstance: function (props) { + var id = this.id(props); + var instance = baseConnection.hydrateInstance.apply(this, arguments); + if (this._getMakeInstanceCallbacks[id]) { + this._getMakeInstanceCallbacks[id].shift()(instance); + if (!this._getMakeInstanceCallbacks[id].length) { + delete this._getMakeInstanceCallbacks[id]; + } + } + return instance; + }, + _getMakeInstanceCallbacks: {}, + _getMakeInstance: function (id, callback) { + if (!this._getMakeInstanceCallbacks[id]) { + this._getMakeInstanceCallbacks[id] = []; + } + this._getMakeInstanceCallbacks[id].push(callback); + }, + getData: function (params) { + var self = this; + return this.cacheConnection.getData(params).then(function (instanceData) { + self._getMakeInstance(self.id(instanceData) || self.id(params), function (instance) { + self.addInstanceReference(instance); + setTimeout(function () { + baseConnection.getData.call(self, params).then(function (instanceData2) { + self.cacheConnection.updateData(instanceData2); + self.updatedInstance(instance, instanceData2); + self.deleteInstanceReference(instance); + }, function (e) { + console.log('REJECTED', e); + }); + }, 1); + }); + return instanceData; + }, function () { + var listData = baseConnection.getData.call(self, params); + listData.then(function (instanceData) { + self.cacheConnection.updateData(instanceData); + }); + return listData; + }); + } + }; + return behavior; +}); +//# sourceMappingURL=fall-through-cache.js.map \ No newline at end of file diff --git a/dist/cjs/fall-through-cache/fall-through-cache.js.map b/dist/cjs/fall-through-cache/fall-through-cache.js.map new file mode 100644 index 00000000..b805e3f5 --- /dev/null +++ b/dist/cjs/fall-through-cache/fall-through-cache.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../fall-through-cache/fall-through-cache.js"],"names":["connect","require","sortedSetJSON","module","exports","behavior","baseConnection","hydrateList","listData","set","listSet","id","list","call","_getHydrateListCallbacks","shift","length","_getHydrateList","callback","push","getListData","self","cacheConnection","then","data","addListReference","setTimeout","updateListData","updatedList","deleteListReference","e","console","log","hydrateInstance","props","instance","apply","arguments","_getMakeInstanceCallbacks","_getMakeInstance","getData","params","instanceData","addInstanceReference","instanceData2","updateData","updatedInstance","deleteInstanceReference"],"mappings":";AAuEA,IAAIA,OAAA,GAAUC,OAAA,CAAQ,mBAAR,CAAd;AACA,IAAIC,aAAA,GAAgBD,OAAA,CAAQ,+BAAR,CAApB,CADA;AAGAE,MAAA,CAAOC,OAAP,GAAiBJ,OAAA,CAAQK,QAAR,CAAiB,oBAAjB,EAAsC,UAASC,cAAT,EAAwB;AAAA,IAE9E,IAAID,QAAA,GAAW;AAAA,QAkBdE,WAAA,EAAa,UAASC,QAAT,EAAmBC,GAAnB,EAAuB;AAAA,YACnCA,GAAA,GAAMA,GAAA,IAAO,KAAKC,OAAL,CAAaF,QAAb,CAAb,CADmC;AAAA,YAEnC,IAAIG,EAAA,GAAKT,aAAA,CAAeO,GAAf,CAAT,CAFmC;AAAA,YAGnC,IAAIG,IAAA,GAAON,cAAA,CAAeC,WAAf,CAA2BM,IAA3B,CAAgC,IAAhC,EAAsCL,QAAtC,EAAgDC,GAAhD,CAAX,CAHmC;AAAA,YAKnC,IAAG,KAAKK,wBAAL,CAA8BH,EAA9B,CAAH,EAAsC;AAAA,gBACrC,KAAKG,wBAAL,CAA8BH,EAA9B,EAAkCI,KAAlC,GAA0CH,IAA1C,EADq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,EAHqE;AAAA,4BAIrEvB,IAAA,CAAK0B,uBAAL,CAA6BZ,QAA7B,EAJqE;AAAA,yBAAtE,EAMG,UAASL,CAAT,EAAW;AAAA,4BAEbC,OAAA,CAAQC,GAAR,CAAY,UAAZ,EAAwBF,CAAxB,EAFa;AAAA,yBANd,EADoB;AAAA,qBAArB,EAWE,CAXF,EAHiF;AAAA,iBAAlF,EAJsE;AAAA,gBAqBtE,OAAOY,YAAP,CArBsE;AAAA,aAAhE,EAsBJ,YAAU;AAAA,gBACZ,IAAIlC,QAAA,GAAWF,cAAA,CAAekC,OAAf,CAAuB3B,IAAvB,CAA4BQ,IAA5B,EAAkCoB,MAAlC,CAAf,CADY;AAAA,gBAEZjC,QAAA,CAASe,IAAT,CAAc,UAASmB,YAAT,EAAsB;AAAA,oBACnCrB,IAAA,CAAKC,eAAL,CAAqBuB,UAArB,CAAgCH,YAAhC,EADmC;AAAA,iBAApC,EAFY;AAAA,gBAMZ,OAAOlC,QAAP,CANY;AAAA,aAtBN,CAAP,CAHwB;AAAA,SA1KX;AAAA,KAAf,CAF8E;AAAA,IAiN9E,OAAOH,QAAP,CAjN8E;AAAA,CAA9D,CAAjB","file":"fall-through-cache.js"} \ No newline at end of file diff --git a/dist/cjs/helpers/clone-data.js b/dist/cjs/helpers/clone-data.js new file mode 100644 index 00000000..b794b230 --- /dev/null +++ b/dist/cjs/helpers/clone-data.js @@ -0,0 +1,7 @@ +/*can-connect@1.0.20#helpers/clone-data*/ +var isArray = require('can-util/js/is-array/is-array'); +var deepAssign = require('can-util/js/deep-assign/deep-assign'); +module.exports = function (data) { + return isArray(data) ? data.slice(0) : deepAssign({}, data); +}; +//# sourceMappingURL=clone-data.js.map \ No newline at end of file diff --git a/dist/cjs/helpers/clone-data.js.map b/dist/cjs/helpers/clone-data.js.map new file mode 100644 index 00000000..cf08bd41 --- /dev/null +++ b/dist/cjs/helpers/clone-data.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../helpers/clone-data.js"],"names":["isArray","require","deepAssign","module","exports","data","slice"],"mappings":";AAAA,IAAIA,OAAA,GAAUC,OAAA,CAAQ,+BAAR,CAAd;AACA,IAAIC,UAAA,GAAaD,OAAA,CAAQ,qCAAR,CAAjB,CADA;AAGAE,MAAA,CAAOC,OAAP,GAAiB,UAASC,IAAT,EAAe;AAAA,IAC/B,OAAOL,OAAA,CAAQK,IAAR,IAAgBA,IAAA,CAAKC,KAAL,CAAW,CAAX,CAAhB,GAAgCJ,UAAA,CAAW,EAAX,EAAeG,IAAf,CAAvC,CAD+B;AAAA,CAAhC","file":"clone-data.js"} \ No newline at end of file diff --git a/dist/cjs/helpers/deferred.js b/dist/cjs/helpers/deferred.js new file mode 100644 index 00000000..9beae023 --- /dev/null +++ b/dist/cjs/helpers/deferred.js @@ -0,0 +1,10 @@ +/*can-connect@1.0.20#helpers/deferred*/ +module.exports = function () { + var def = {}; + def.promise = new Promise(function (resolve, reject) { + def.resolve = resolve; + def.reject = reject; + }); + return def; +}; +//# sourceMappingURL=deferred.js.map \ No newline at end of file diff --git a/dist/cjs/helpers/deferred.js.map b/dist/cjs/helpers/deferred.js.map new file mode 100644 index 00000000..fb74d64c --- /dev/null +++ b/dist/cjs/helpers/deferred.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../helpers/deferred.js"],"names":["module","exports","def","promise","Promise","resolve","reject"],"mappings":";AACAA,MAAA,CAAOC,OAAP,GAAiB,YAAU;AAAA,IAC1B,IAAIC,GAAA,GAAM,EAAV,CAD0B;AAAA,IAE1BA,GAAA,CAAIC,OAAJ,GAAc,IAAIC,OAAJ,CAAY,UAASC,OAAT,EAAkBC,MAAlB,EAAyB;AAAA,QAClDJ,GAAA,CAAIG,OAAJ,GAAcA,OAAd,CADkD;AAAA,QAElDH,GAAA,CAAII,MAAJ,GAAaA,MAAb,CAFkD;AAAA,KAArC,CAAd,CAF0B;AAAA,IAM1B,OAAOJ,GAAP,CAN0B;AAAA,CAA3B","file":"deferred.js"} \ No newline at end of file diff --git a/dist/cjs/helpers/get-id-props.js b/dist/cjs/helpers/get-id-props.js new file mode 100644 index 00000000..e684238c --- /dev/null +++ b/dist/cjs/helpers/get-id-props.js @@ -0,0 +1,17 @@ +/*can-connect@1.0.20#helpers/get-id-props*/ +module.exports = function (connection) { + var ids = [], algebra = this.algebra; + if (algebra && algebra.clauses && algebra.clauses.id) { + for (var prop in algebra.clauses.id) { + ids.push(prop); + } + } + if (connection.idProp && !ids.length) { + ids.push(connection.idProp); + } + if (!ids.length) { + ids.push('id'); + } + return ids; +}; +//# sourceMappingURL=get-id-props.js.map \ No newline at end of file diff --git a/dist/cjs/helpers/get-id-props.js.map b/dist/cjs/helpers/get-id-props.js.map new file mode 100644 index 00000000..fa673e53 --- /dev/null +++ b/dist/cjs/helpers/get-id-props.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../helpers/get-id-props.js"],"names":["module","exports","connection","ids","algebra","clauses","id","prop","push","idProp","length"],"mappings":";AAAAA,MAAA,CAAOC,OAAP,GAAiB,UAASC,UAAT,EAAqB;AAAA,IACrC,IAAIC,GAAA,GAAM,EAAV,EACCC,OAAA,GAAU,KAAKA,OADhB,CADqC;AAAA,IAIrC,IAAGA,OAAA,IAAWA,OAAA,CAAQC,OAAnB,IAA8BD,OAAA,CAAQC,OAAR,CAAgBC,EAAjD,EAAqD;AAAA,QACpD,SAAQC,IAAR,IAAgBH,OAAA,CAAQC,OAAR,CAAgBC,EAAhC,EAAoC;AAAA,YACnCH,GAAA,CAAIK,IAAJ,CAASD,IAAT,EADmC;AAAA,SADgB;AAAA,KAJhB;AAAA,IAUrC,IAAGL,UAAA,CAAWO,MAAX,IAAqB,CAACN,GAAA,CAAIO,MAA7B,EAAqC;AAAA,QACpCP,GAAA,CAAIK,IAAJ,CAASN,UAAA,CAAWO,MAApB,EADoC;AAAA,KAVA;AAAA,IAarC,IAAG,CAACN,GAAA,CAAIO,MAAR,EAAgB;AAAA,QACfP,GAAA,CAAIK,IAAJ,CAAS,IAAT,EADe;AAAA,KAbqB;AAAA,IAgBrC,OAAOL,GAAP,CAhBqC;AAAA,CAAtC","file":"get-id-props.js"} \ No newline at end of file diff --git a/dist/cjs/helpers/get-index-by-id.js b/dist/cjs/helpers/get-index-by-id.js new file mode 100644 index 00000000..70103742 --- /dev/null +++ b/dist/cjs/helpers/get-index-by-id.js @@ -0,0 +1,12 @@ +/*can-connect@1.0.20#helpers/get-index-by-id*/ +module.exports = function (connection, props, items) { + var id = connection.id(props); + for (var i = 0; i < items.length; i++) { + var connId = connection.id(items[i]); + if (id == connId) { + return i; + } + } + return -1; +}; +//# sourceMappingURL=get-index-by-id.js.map \ No newline at end of file diff --git a/dist/cjs/helpers/get-index-by-id.js.map b/dist/cjs/helpers/get-index-by-id.js.map new file mode 100644 index 00000000..757d5ff3 --- /dev/null +++ b/dist/cjs/helpers/get-index-by-id.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../helpers/get-index-by-id.js"],"names":["module","exports","connection","props","items","id","i","length","connId"],"mappings":";AACAA,MAAA,CAAOC,OAAP,GAAiB,UAASC,UAAT,EAAqBC,KAArB,EAA4BC,KAA5B,EAAkC;AAAA,IAClD,IAAIC,EAAA,GAAKH,UAAA,CAAWG,EAAX,CAAcF,KAAd,CAAT,CADkD;AAAA,IAGlD,KAAI,IAAIG,CAAA,GAAI,CAAR,CAAJ,CAAeA,CAAA,GAAIF,KAAA,CAAMG,MAAzB,EAAiCD,CAAA,EAAjC,EAAsC;AAAA,QACrC,IAAIE,MAAA,GAASN,UAAA,CAAWG,EAAX,CAAcD,KAAA,CAAME,CAAN,CAAd,CAAb,CADqC;AAAA,QAErC,IAAID,EAAA,IAAMG,MAAV,EAAkB;AAAA,YACjB,OAAOF,CAAP,CADiB;AAAA,SAFmB;AAAA,KAHY;AAAA,IASlD,OAAO,CAAC,CAAR,CATkD;AAAA,CAAnD","file":"get-index-by-id.js"} \ No newline at end of file diff --git a/dist/cjs/helpers/get-items.js b/dist/cjs/helpers/get-items.js new file mode 100644 index 00000000..655991ea --- /dev/null +++ b/dist/cjs/helpers/get-items.js @@ -0,0 +1,10 @@ +/*can-connect@1.0.20#helpers/get-items*/ +var isArray = require('can-util/js/is-array/is-array'); +module.exports = function (data) { + if (isArray(data)) { + return data; + } else { + return data.data; + } +}; +//# sourceMappingURL=get-items.js.map \ No newline at end of file diff --git a/dist/cjs/helpers/get-items.js.map b/dist/cjs/helpers/get-items.js.map new file mode 100644 index 00000000..89df9807 --- /dev/null +++ b/dist/cjs/helpers/get-items.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../helpers/get-items.js"],"names":["isArray","require","module","exports","data"],"mappings":";AAAA,IAAIA,OAAA,GAAUC,OAAA,CAAQ,+BAAR,CAAd;AAEAC,MAAA,CAAOC,OAAP,GAAiB,UAASC,IAAT,EAAc;AAAA,IAC9B,IAAGJ,OAAA,CAAQI,IAAR,CAAH,EAAkB;AAAA,QACjB,OAAOA,IAAP,CADiB;AAAA,KAAlB,MAEO;AAAA,QACN,OAAOA,IAAA,CAAKA,IAAZ,CADM;AAAA,KAHuB;AAAA,CAA/B","file":"get-items.js"} \ No newline at end of file diff --git a/dist/cjs/helpers/id-merge.js b/dist/cjs/helpers/id-merge.js new file mode 100644 index 00000000..60f92c4b --- /dev/null +++ b/dist/cjs/helpers/id-merge.js @@ -0,0 +1,39 @@ +/*can-connect@1.0.20#helpers/id-merge*/ +var map = [].map; +module.exports = function (list, update, id, make) { + var listIndex = 0, updateIndex = 0; + while (listIndex < list.length && updateIndex < update.length) { + var listItem = list[listIndex], updateItem = update[updateIndex], lID = id(listItem), uID = id(updateItem); + if (id(listItem) === id(updateItem)) { + listIndex++; + updateIndex++; + continue; + } + if (updateIndex + 1 < update.length && id(update[updateIndex + 1]) === lID) { + list.splice(listIndex, 0, make(update[updateIndex])); + listIndex++; + updateIndex++; + continue; + } else if (listIndex + 1 < list.length && id(list[listIndex + 1]) === uID) { + list.splice(listIndex, 1); + listIndex++; + updateIndex++; + continue; + } else { + list.splice.apply(list, [ + listIndex, + list.length - listIndex + ].concat(map.call(update.slice(updateIndex), make))); + return list; + } + } + if (updateIndex === update.length && listIndex === list.length) { + return; + } + list.splice.apply(list, [ + listIndex, + list.length - listIndex + ].concat(map.call(update.slice(updateIndex), make))); + return; +}; +//# sourceMappingURL=id-merge.js.map \ No newline at end of file diff --git a/dist/cjs/helpers/id-merge.js.map b/dist/cjs/helpers/id-merge.js.map new file mode 100644 index 00000000..00b79451 --- /dev/null +++ b/dist/cjs/helpers/id-merge.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../helpers/id-merge.js"],"names":["map","module","exports","list","update","id","make","listIndex","updateIndex","length","listItem","updateItem","lID","uID","splice","apply","concat","call","slice"],"mappings":";AAAA,IAAIA,GAAA,GAAM,GAAGA,GAAb;AAEAC,MAAA,CAAOC,OAAP,GAAiB,UAASC,IAAT,EAAeC,MAAf,EAAuBC,EAAvB,EAA2BC,IAA3B,EAAgC;AAAA,IAChD,IAAIC,SAAA,GAAY,CAAhB,EACCC,WAAA,GAAe,CADhB,CADgD;AAAA,IAIhD,OAAMD,SAAA,GAAYJ,IAAA,CAAKM,MAAjB,IAA2BD,WAAA,GAAcJ,MAAA,CAAOK,MAAtD,EAA8D;AAAA,QAC7D,IAAIC,QAAA,GAAWP,IAAA,CAAKI,SAAL,CAAf,EACCI,UAAA,GAAaP,MAAA,CAAOI,WAAP,CADd,EAECI,GAAA,GAAMP,EAAA,CAAGK,QAAH,CAFP,EAGCG,GAAA,GAAMR,EAAA,CAAGM,UAAH,CAHP,CAD6D;AAAA,QAK7D,IAAIN,EAAA,CAAGK,QAAH,MAAiBL,EAAA,CAAGM,UAAH,CAArB,EAAsC;AAAA,YACrCJ,SAAA,GADqC;AAAA,YAErCC,WAAA,GAFqC;AAAA,YAGrC,SAHqC;AAAA,SALuB;AAAA,QAa7D,IAAKA,WAAA,GAAY,CAAZ,GAAgBJ,MAAA,CAAOK,MAAvB,IAAiCJ,EAAA,CAAGD,MAAA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AA,CAAOc,KAAP,CAAaV,WAAb,CAAT,EAAoCF,IAApC,CAA3C,CAAzB,EAvCgD;AAAA,IAwChD,OAxCgD;AAAA,CAAjD","file":"id-merge.js"} \ No newline at end of file diff --git a/dist/cjs/helpers/overwrite.js b/dist/cjs/helpers/overwrite.js new file mode 100644 index 00000000..b1412d72 --- /dev/null +++ b/dist/cjs/helpers/overwrite.js @@ -0,0 +1,13 @@ +/*can-connect@1.0.20#helpers/overwrite*/ +module.exports = function (d, s, id) { + for (var prop in d) { + if (prop !== id && !(prop in s)) { + delete d[prop]; + } + } + for (prop in s) { + d[prop] = s[prop]; + } + return d; +}; +//# sourceMappingURL=overwrite.js.map \ No newline at end of file diff --git a/dist/cjs/helpers/overwrite.js.map b/dist/cjs/helpers/overwrite.js.map new file mode 100644 index 00000000..ccdd058d --- /dev/null +++ b/dist/cjs/helpers/overwrite.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../helpers/overwrite.js"],"names":["module","exports","d","s","id","prop"],"mappings":";AAAAA,MAAA,CAAOC,OAAP,GAAiB,UAASC,CAAT,EAAYC,CAAZ,EAAeC,EAAf,EAAkB;AAAA,IAClC,SAAQC,IAAR,IAAgBH,CAAhB,EAAmB;AAAA,QAClB,IAAIG,IAAA,KAASD,EAAT,IAAe,CAAE,CAAAC,IAAA,IAAQF,CAAR,CAArB,EAAiC;AAAA,YAChC,OAAOD,CAAA,CAAEG,IAAF,CAAP,CADgC;AAAA,SADf;AAAA,KADe;AAAA,IAMlC,KAAIA,IAAJ,IAAYF,CAAZ,EAAe;AAAA,QACdD,CAAA,CAAEG,IAAF,IAAUF,CAAA,CAAEE,IAAF,CAAV,CADc;AAAA,KANmB;AAAA,IASlC,OAAOH,CAAP,CATkC;AAAA,CAAnC","file":"overwrite.js"} \ No newline at end of file diff --git a/dist/cjs/helpers/set-add.js b/dist/cjs/helpers/set-add.js new file mode 100644 index 00000000..74dbbf22 --- /dev/null +++ b/dist/cjs/helpers/set-add.js @@ -0,0 +1,12 @@ +/*can-connect@1.0.20#helpers/set-add*/ +var canSet = require('can-set'); +module.exports = function (connection, setItems, items, item, algebra) { + var index = canSet.index(setItems, items, item, algebra); + if (index === undefined) { + index = items.length; + } + var copy = items.slice(0); + copy.splice(index, 0, item); + return copy; +}; +//# sourceMappingURL=set-add.js.map \ No newline at end of file diff --git a/dist/cjs/helpers/set-add.js.map b/dist/cjs/helpers/set-add.js.map new file mode 100644 index 00000000..5222f57d --- /dev/null +++ b/dist/cjs/helpers/set-add.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../helpers/set-add.js"],"names":["canSet","require","module","exports","connection","setItems","items","item","algebra","index","undefined","length","copy","slice","splice"],"mappings":";AAAA,IAAIA,MAAA,GAASC,OAAA,CAAQ,SAAR,CAAb;AAGAC,MAAA,CAAOC,OAAP,GAAiB,UAASC,UAAT,EAAqBC,QAArB,EAA+BC,KAA/B,EAAsCC,IAAtC,EAA4CC,OAA5C,EAAoD;AAAA,IACpE,IAAIC,KAAA,GAAQT,MAAA,CAAOS,KAAP,CAAaJ,QAAb,EAAuBC,KAAvB,EAA8BC,IAA9B,EAAoCC,OAApC,CAAZ,CADoE;AAAA,IAEpE,IAAGC,KAAA,KAAUC,SAAb,EAAwB;AAAA,QACvBD,KAAA,GAAQH,KAAA,CAAMK,MAAd,CADuB;AAAA,KAF4C;AAAA,IAMpE,IAAIC,IAAA,GAAON,KAAA,CAAMO,KAAN,CAAY,CAAZ,CAAX,CANoE;AAAA,IAOpED,IAAA,CAAKE,MAAL,CAAYL,KAAZ,EAAmB,CAAnB,EAAsBF,IAAtB,EAPoE;AAAA,IASpE,OAAOK,IAAP,CAToE;AAAA,CAArE","file":"set-add.js"} \ No newline at end of file diff --git a/dist/cjs/helpers/sorted-set-json.js b/dist/cjs/helpers/sorted-set-json.js new file mode 100644 index 00000000..5d7f6409 --- /dev/null +++ b/dist/cjs/helpers/sorted-set-json.js @@ -0,0 +1,15 @@ +/*can-connect@1.0.20#helpers/sorted-set-json*/ +var forEach = [].forEach; +var keys = Object.keys; +module.exports = function (set) { + if (set == null) { + return set; + } else { + var sorted = {}; + forEach.call(keys(set).sort(), function (prop) { + sorted[prop] = set[prop]; + }); + return JSON.stringify(sorted); + } +}; +//# sourceMappingURL=sorted-set-json.js.map \ No newline at end of file diff --git a/dist/cjs/helpers/sorted-set-json.js.map b/dist/cjs/helpers/sorted-set-json.js.map new file mode 100644 index 00000000..0d240b0a --- /dev/null +++ b/dist/cjs/helpers/sorted-set-json.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../helpers/sorted-set-json.js"],"names":["forEach","keys","Object","module","exports","set","sorted","call","sort","prop","JSON","stringify"],"mappings":";AAAA,IAAIA,OAAA,GAAU,GAAGA,OAAjB;AACA,IAAIC,IAAA,GAAOC,MAAA,CAAOD,IAAlB,CADA;AAGAE,MAAA,CAAOC,OAAP,GAAiB,UAASC,GAAT,EAAa;AAAA,IAC7B,IAAGA,GAAA,IAAO,IAAV,EAAgB;AAAA,QACf,OAAOA,GAAP,CADe;AAAA,KAAhB,MAEO;AAAA,QACN,IAAIC,MAAA,GAAS,EAAb,CADM;AAAA,QAENN,OAAA,CAAQO,IAAR,CAAaN,IAAA,CAAKI,GAAL,EAAUG,IAAV,EAAb,EAA+B,UAASC,IAAT,EAAc;AAAA,YAC5CH,MAAA,CAAOG,IAAP,IAAeJ,GAAA,CAAII,IAAJ,CAAf,CAD4C;AAAA,SAA7C,EAFM;AAAA,QAKN,OAAOC,IAAA,CAAKC,SAAL,CAAeL,MAAf,CAAP,CALM;AAAA,KAHsB;AAAA,CAA9B","file":"sorted-set-json.js"} \ No newline at end of file diff --git a/dist/cjs/helpers/weak-reference-map.js b/dist/cjs/helpers/weak-reference-map.js new file mode 100644 index 00000000..f5e71ea5 --- /dev/null +++ b/dist/cjs/helpers/weak-reference-map.js @@ -0,0 +1,43 @@ +/*can-connect@1.0.20#helpers/weak-reference-map*/ +var assign = require('can-util/js/assign/assign'); +var WeakReferenceMap = function () { + this.set = {}; +}; +assign(WeakReferenceMap.prototype, { + has: function (key) { + return !!this.set[key]; + }, + addReference: function (key, item) { + var data = this.set[key]; + if (!data) { + data = this.set[key] = { + item: item, + referenceCount: 0, + key: key + }; + } + data.referenceCount++; + }, + deleteReference: function (key) { + var data = this.set[key]; + if (data) { + data.referenceCount--; + if (data.referenceCount === 0) { + delete this.set[key]; + } + } + }, + get: function (key) { + var data = this.set[key]; + if (data) { + return data.item; + } + }, + forEach: function (cb) { + for (var id in this.set) { + cb(this.set[id].item, id); + } + } +}); +module.exports = WeakReferenceMap; +//# sourceMappingURL=weak-reference-map.js.map \ No newline at end of file diff --git a/dist/cjs/helpers/weak-reference-map.js.map b/dist/cjs/helpers/weak-reference-map.js.map new file mode 100644 index 00000000..e31b2285 --- /dev/null +++ b/dist/cjs/helpers/weak-reference-map.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../helpers/weak-reference-map.js"],"names":["assign","require","WeakReferenceMap","set","prototype","has","key","addReference","item","data","referenceCount","deleteReference","get","forEach","cb","id","module","exports"],"mappings":";AAAA,IAAIA,MAAA,GAASC,OAAA,CAAQ,2BAAR,CAAb;AAgCA,IAAIC,gBAAA,GAAmB,YAAU;AAAA,IAChC,KAAKC,GAAL,GAAW,EAAX,CADgC;AAAA,CAAjC,CAhCA;AAuCAH,MAAA,CAAOE,gBAAA,CAAiBE,SAAxB,EAIC;AAAA,IAUAC,GAAA,EAAK,UAASC,GAAT,EAAa;AAAA,QACjB,OAAO,CAAC,CAAC,KAAKH,GAAL,CAASG,GAAT,CAAT,CADiB;AAAA,KAVlB;AAAA,IAsBAC,YAAA,EAAc,UAASD,GAAT,EAAcE,IAAd,EAAmB;AAAA,QAChC,IAAIC,IAAA,GAAO,KAAKN,GAAL,CAASG,GAAT,CAAX,CADgC;AAAA,QAEhC,IAAG,CAACG,IAAJ,EAAU;AAAA,YACTA,IAAA,GAAO,KAAKN,GAAL,CAASG,GAAT,IAAgB;AAAA,gBACtBE,IAAA,EAAMA,IADgB;AAAA,gBAEtBE,cAAA,EAAgB,CAFM;AAAA,gBAGtBJ,GAAA,EAAKA,GAHiB;AAAA,aAAvB,CADS;AAAA,SAFsB;AAAA,QAShCG,IAAA,CAAKC,cAAL,GATgC;AAAA,KAtBjC;AAAA,IA0CAC,eAAA,EAAiB,UAASL,GAAT,EAAa;AAAA,QAC7B,IAAIG,IAAA,GAAO,KAAKN,GAAL,CAASG,GAAT,CAAX,CAD6B;AAAA,QAE7B,IAAGG,IAAH,EAAQ;AAAA,YACPA,IAAA,CAAKC,cAAL,GADO;AAAA,YAEP,IAAID,IAAA,CAAKC,cAAL,KAAwB,CAA5B,EAAgC;AAAA,gBAC/B,OAAO,KAAKP,GAAL,CAASG,GAAT,CAAP,CAD+B;AAAA,aAFzB;AAAA,SAFqB;AAAA,KA1C9B;AAAA,IA4DAM,GAAA,EAAK,UAASN,GAAT,EAAa;AAAA,QACjB,IAAIG,IAAA,GAAO,KAAKN,GAAL,CAASG,GAAT,CAAX,CADiB;AAAA,QAEjB,IAAGG,IAAH,EAAS;AAAA,YACR,OAAOA,IAAA,CAAKD,IAAZ,CADQ;AAAA,SAFQ;AAAA,KA5DlB;AAAA,IA0EAK,OAAA,EAAS,UAASC,EAAT,EAAY;AAAA,QACpB,SAAQC,EAAR,IAAc,KAAKZ,GAAnB,EAAwB;AAAA,YACvBW,EAAA,CAAG,KAAKX,GAAL,CAASY,EAAT,EAAaP,IAAhB,EAAsBO,EAAtB,EADuB;AAAA,SADJ;AAAA,KA1ErB;AAAA,CAJD,EAvCA;AA4HAC,MAAA,CAAOC,OAAP,GAAiBf,gBAAjB","file":"weak-reference-map.js"} \ No newline at end of file diff --git a/dist/cjs/real-time/real-time.js b/dist/cjs/real-time/real-time.js new file mode 100644 index 00000000..224b4df8 --- /dev/null +++ b/dist/cjs/real-time/real-time.js @@ -0,0 +1,141 @@ +/*can-connect@1.0.20#real-time/real-time*/ +var connect = require('../can-connect.js'); +var canSet = require('can-set'); +var setAdd = require('../helpers/set-add.js'); +var indexOf = require('../helpers/get-index-by-id.js'); +var canDev = require('can-util/js/dev/dev'); +module.exports = connect.behavior('real-time', function (baseConnection) { + return { + createInstance: function (props) { + var id = this.id(props); + var instance = this.instanceStore.get(id); + var serialized; + if (instance) { + return this.updateInstance(props); + } else { + instance = this.hydrateInstance(props); + serialized = this.serializeInstance(instance); + var self = this; + this.addInstanceReference(instance); + return Promise.resolve(this.createdData(props, serialized)).then(function () { + self.deleteInstanceReference(instance); + return instance; + }); + } + }, + createdData: function (props, params, cid) { + var instance; + if (cid !== undefined) { + instance = this.cidStore.get(cid); + } else { + instance = this.instanceStore.get(this.id(props)); + } + this.addInstanceReference(instance, this.id(props)); + this.createdInstance(instance, props); + create.call(this, this.serializeInstance(instance)); + this.deleteInstanceReference(instance); + return undefined; + }, + updatedData: function (props, params) { + var instance = this.instanceStore.get(this.id(params)); + this.updatedInstance(instance, props); + update.call(this, this.serializeInstance(instance)); + return undefined; + }, + updateInstance: function (props) { + var id = this.id(props); + var instance = this.instanceStore.get(id); + if (!instance) { + instance = this.hydrateInstance(props); + } + this.addInstanceReference(instance); + var serialized = this.serializeInstance(instance), self = this; + return Promise.resolve(this.updatedData(props, serialized)).then(function () { + self.deleteInstanceReference(instance); + return instance; + }); + }, + destroyedData: function (props, params) { + var id = this.id(params || props); + var instance = this.instanceStore.get(id); + if (!instance) { + instance = this.hydrateInstance(props); + } + var serialized = this.serializeInstance(instance); + this.destroyedInstance(instance, props); + destroy.call(this, serialized); + return undefined; + }, + destroyInstance: function (props) { + var id = this.id(props); + var instance = this.instanceStore.get(id); + if (!instance) { + instance = this.hydrateInstance(props); + } + this.addInstanceReference(instance); + var serialized = this.serializeInstance(instance), self = this; + return Promise.resolve(this.destroyedData(props, serialized)).then(function () { + self.deleteInstanceReference(instance); + return instance; + }); + } + }; +}); +var create = function (props) { + var self = this; + this.listStore.forEach(function (list, id) { + var set = JSON.parse(id); + var index = indexOf(self, props, list); + if (canSet.has(set, props, self.algebra)) { + if (index === -1) { + var items = self.serializeList(list); + self.updatedList(list, { data: setAdd(self, set, items, props, self.algebra) }, set); + } else { + } + } + }); +}; +var update = function (props) { + var self = this; + this.listStore.forEach(function (list, id) { + var items; + var set = JSON.parse(id); + var index = indexOf(self, props, list); + if (canSet.has(set, props, self.algebra)) { + items = self.serializeList(list); + if (index === -1) { + self.updatedList(list, { data: setAdd(self, set, items, props, self.algebra) }, set); + } else { + var sortedIndex = canSet.index(set, items, props, self.algebra); + if (sortedIndex !== undefined && sortedIndex !== index) { + var copy = items.slice(0); + if (index < sortedIndex) { + copy.splice(sortedIndex, 0, props); + copy.splice(index, 1); + } else { + copy.splice(index, 1); + copy.splice(sortedIndex, 0, props); + } + self.updatedList(list, { data: copy }, set); + } + } + } else if (index !== -1) { + items = self.serializeList(list); + items.splice(index, 1); + self.updatedList(list, { data: items }, set); + } + }); +}; +var destroy = function (props) { + var self = this; + this.listStore.forEach(function (list, id) { + var set = JSON.parse(id); + var index = indexOf(self, props, list); + if (index !== -1) { + var items = self.serializeList(list); + items.splice(index, 1); + self.updatedList(list, { data: items }, set); + } + }); +}; +//# sourceMappingURL=real-time.js.map \ No newline at end of file diff --git a/dist/cjs/real-time/real-time.js.map b/dist/cjs/real-time/real-time.js.map new file mode 100644 index 00000000..1fa5a493 --- /dev/null +++ b/dist/cjs/real-time/real-time.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../real-time/real-time.js"],"names":["connect","require","canSet","setAdd","indexOf","canDev","module","exports","behavior","baseConnection","createInstance","props","id","instance","instanceStore","get","serialized","updateInstance","hydrateInstance","serializeInstance","self","addInstanceReference","Promise","resolve","createdData","then","deleteInstanceReference","params","cid","undefined","cidStore","createdInstance","create","call","updatedData","updatedInstance","update","destroyedData","destroyedInstance","destroy","destroyInstance","listStore","forEach","list","set","JSON","parse","index","has","algebra","items","serializeList","updatedList","data","sortedIndex","copy","slice","splice"],"mappings":";AA+HA,IAAIA,OAAA,GAAUC,OAAA,CAAQ,mB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EAJuB;AAAA,SA/BgB;AAAA,KAAzC,EAH4B;AAAA,CAA7B,CA3PA;AAwSA,IAAIL,OAAA,GAAU,UAAS5B,KAAT,EAAgB;AAAA,IAC7B,IAAIS,IAAA,GAAO,IAAX,CAD6B;AAAA,IAE7B,KAAKqB,SAAL,CAAeC,OAAf,CAAuB,UAASC,IAAT,EAAe/B,EAAf,EAAkB;AAAA,QACxC,IAAIgC,GAAA,GAAMC,IAAA,CAAKC,KAAL,CAAWlC,EAAX,CAAV,CADwC;AAAA,QAIxC,IAAImC,KAAA,GAAQ3C,OAAA,CAAQgB,IAAR,EAAcT,KAAd,EAAqBgC,IAArB,CAAZ,CAJwC;AAAA,QAMxC,IAAGI,KAAA,KAAU,CAAC,CAAd,EAAgB;AAAA,YAEf,IAAIG,KAAA,GAAQ9B,IAAA,CAAK+B,aAAL,CAAmBR,IAAnB,CAAZ,CAFe;AAAA,YAGfO,KAAA,CAAMO,MAAN,CAAaV,KAAb,EAAmB,CAAnB,EAHe;AAAA,YAIf3B,IAAA,CAAKgC,WAAL,CAAiBT,IAAjB,EAAwB,EAAEU,IAAA,EAAMH,KAAR,EAAxB,EAAyCN,GAAzC,EAJe;AAAA,SANwB;AAAA,KAAzC,EAF6B;AAAA,CAA9B","file":"real-time.js"} \ No newline at end of file diff --git a/dist/global/can-connect.js b/dist/global/can-connect.js new file mode 100644 index 00000000..539e6217 --- /dev/null +++ b/dist/global/can-connect.js @@ -0,0 +1,2482 @@ +/*[global-shim-start]*/ +(function(exports, global, doEval){ // jshint ignore:line + var origDefine = global.define; + + var get = function(name){ + var parts = name.split("."), + cur = global, + i; + for(i = 0 ; i < parts.length; i++){ + if(!cur) { + break; + } + cur = cur[parts[i]]; + } + return cur; + }; + var set = function(name, val){ + var parts = name.split("."), + cur = global, + i, part, next; + for(i = 0; i < parts.length - 1; i++) { + part = parts[i]; + next = cur[part]; + if(!next) { + next = cur[part] = {}; + } + cur = next; + } + part = parts[parts.length - 1]; + cur[part] = val; + }; + var useDefault = function(mod){ + if(!mod || !mod.__esModule) return false; + var esProps = { __esModule: true, "default": true }; + for(var p in mod) { + if(!esProps[p]) return false; + } + return true; + }; + var modules = (global.define && global.define.modules) || + (global._define && global._define.modules) || {}; + var ourDefine = global.define = function(moduleName, deps, callback){ + var module; + if(typeof deps === "function") { + callback = deps; + deps = []; + } + var args = [], + i; + for(i =0; i < deps.length; i++) { + args.push( exports[deps[i]] ? get(exports[deps[i]]) : ( modules[deps[i]] || get(deps[i]) ) ); + } + // CJS has no dependencies but 3 callback arguments + if(!deps.length && callback.length) { + module = { exports: {} }; + var require = function(name) { + return exports[name] ? get(exports[name]) : modules[name]; + }; + args.push(require, module.exports, module); + } + // Babel uses the exports and module object. + else if(!args[0] && deps[0] === "exports") { + module = { exports: {} }; + args[0] = module.exports; + if(deps[1] === "module") { + args[1] = module; + } + } else if(!args[0] && deps[0] === "module") { + args[0] = { id: moduleName }; + } + + global.define = origDefine; + var result = callback ? callback.apply(null, args) : undefined; + global.define = ourDefine; + + // Favor CJS module.exports over the return value + result = module && module.exports ? module.exports : result; + modules[moduleName] = result; + + // Set global exports + var globalExport = exports[moduleName]; + if(globalExport && !get(globalExport)) { + if(useDefault(result)) { + result = result["default"]; + } + set(globalExport, result); + } + }; + global.define.orig = origDefine; + global.define.modules = modules; + global.define.amd = true; + ourDefine("@loader", [], function(){ + // shim for @@global-helpers + var noop = function(){}; + return { + get: function(){ + return { prepareGlobal: noop, retrieveGlobal: noop }; + }, + global: global, + __exec: function(__load){ + doEval(__load.source, global); + } + }; + }); +} +)({"jquery":"jQuery"},window,function(__$source__, __$global__) { // jshint ignore:line + eval("(function() { " + __$source__ + " \n }).call(__$global__);"); +} +) +/*can-connect@1.0.20#connect*/ +define('can-connect/connect', function (require, exports, module) { + var assign = require('can-util/js/assign/assign'); + var connect = function (behaviors, options) { + behaviors = behaviors.map(function (behavior, index) { + var sortedIndex = -1; + if (typeof behavior === 'string') { + sortedIndex = connect.order.indexOf(behavior); + behavior = behaviorsMap[behavior]; + } else if (behavior.isBehavior) { + sortedIndex = connect.order.indexOf(behavior.behaviorName); + } else { + behavior = connect.behavior(behavior); + } + return { + originalIndex: index, + sortedIndex: sortedIndex, + behavior: behavior + }; + }).sort(function (b1, b2) { + if (~b1.sortedIndex && ~b2.sortedIndex) { + return b1.sortedIndex - b2.sortedIndex; + } + return b1.originalIndex - b2.originalIndex; + }); + behaviors = behaviors.map(function (b) { + return b.behavior; + }); + var behavior = connect.base(connect.behavior('options', function () { + return options; + })()); + behaviors.forEach(function (behave) { + behavior = behave(behavior); + }); + if (behavior.init) { + behavior.init(); + } + return behavior; + }; + connect.order = [ + 'data/localstorage-cache', + 'data/url', + 'data/parse', + 'cache-requests', + 'data/combine-requests', + 'constructor', + 'constructor/store', + 'can/map', + 'can/ref', + 'fall-through-cache', + 'data/worker', + 'real-time', + 'data/callbacks-cache', + 'data/callbacks', + 'constructor/callbacks-once' + ]; + connect.behavior = function (name, behavior) { + if (typeof name !== 'string') { + behavior = name; + name = undefined; + } + var behaviorMixin = function (base) { + var Behavior = function () { + }; + Behavior.name = name; + Behavior.prototype = base; + var newBehavior = new Behavior(); + var res = typeof behavior === 'function' ? behavior.apply(newBehavior, arguments) : behavior; + assign(newBehavior, res); + newBehavior.__behaviorName = name; + return newBehavior; + }; + if (name) { + behaviorMixin.behaviorName = name; + behaviorsMap[name] = behaviorMixin; + } + behaviorMixin.isBehavior = true; + return behaviorMixin; + }; + var behaviorsMap = {}; + module.exports = connect; +}); +/*can-connect@1.0.20#base/base*/ +define('can-connect/base/base', function (require, exports, module) { + var connect = require('can-connect/connect'); + module.exports = connect.behavior('base', function (baseConnection) { + return { + id: function (instance) { + var ids = [], algebra = this.algebra; + if (algebra && algebra.clauses && algebra.clauses.id) { + for (var prop in algebra.clauses.id) { + ids.push(instance[prop]); + } + } + if (this.idProp && !ids.length) { + ids.push(instance[this.idProp]); + } + if (!ids.length) { + ids.push(instance.id); + } + return ids.length > 1 ? ids.join('@|@') : ids[0]; + }, + idProp: baseConnection.idProp || 'id', + listSet: function (list) { + return list[this.listSetProp]; + }, + listSetProp: '__listSet', + init: function () { + } + }; + }); +}); +/*can-connect@1.0.20#can-connect*/ +define('can-connect', function (require, exports, module) { + var connect = require('can-connect/connect'); + var base = require('can-connect/base/base'); + var ns = require('can-namespace'); + connect.base = base; + module.exports = ns.connect = connect; +}); +/*can-connect@1.0.20#helpers/get-items*/ +define('can-connect/helpers/get-items', function (require, exports, module) { + var isArray = require('can-util/js/is-array/is-array'); + module.exports = function (data) { + if (isArray(data)) { + return data; + } else { + return data.data; + } + }; +}); +/*can-connect@1.0.20#cache-requests/cache-requests*/ +define('can-connect/cache-requests/cache-requests', function (require, exports, module) { + var connect = require('can-connect'); + var getItems = require('can-connect/helpers/get-items'); + var canSet = require('can-set'); + var forEach = [].forEach; + module.exports = connect.behavior('cache-requests', function (baseConnection) { + return { + getDiff: function (params, availableSets) { + var minSets, self = this; + forEach.call(availableSets, function (set) { + var curSets; + var difference = canSet.difference(params, set, self.algebra); + if (typeof difference === 'object') { + curSets = { + needed: difference, + cached: canSet.intersection(params, set, self.algebra), + count: canSet.count(difference, self.algebra) + }; + } else if (canSet.subset(params, set, self.algebra)) { + curSets = { + cached: params, + count: 0 + }; + } + if (curSets) { + if (!minSets || curSets.count < minSets.count) { + minSets = curSets; + } + } + }); + if (!minSets) { + return { needed: params }; + } else { + return { + needed: minSets.needed, + cached: minSets.cached + }; + } + }, + getUnion: function (params, diff, neededItems, cachedItems) { + return { data: canSet.getUnion(diff.needed, diff.cached, getItems(neededItems), getItems(cachedItems), this.algebra) }; + }, + getListData: function (set) { + set = set || {}; + var self = this; + return this.cacheConnection.getSets(set).then(function (sets) { + var diff = self.getDiff(set, sets); + if (!diff.needed) { + return self.cacheConnection.getListData(diff.cached); + } else if (!diff.cached) { + return baseConnection.getListData(diff.needed).then(function (data) { + return self.cacheConnection.updateListData(getItems(data), diff.needed).then(function () { + return data; + }); + }); + } else { + var cachedPromise = self.cacheConnection.getListData(diff.cached); + var needsPromise = baseConnection.getListData(diff.needed); + var savedPromise = needsPromise.then(function (data) { + return self.cacheConnection.updateListData(getItems(data), diff.needed).then(function () { + return data; + }); + }); + var combinedPromise = Promise.all([ + cachedPromise, + needsPromise + ]).then(function (result) { + var cached = result[0], needed = result[1]; + return self.getUnion(set, diff, needed, cached); + }); + return Promise.all([ + combinedPromise, + savedPromise + ]).then(function (data) { + return data[0]; + }); + } + }); + } + }; + }); +}); +/*can-connect@1.0.20#helpers/weak-reference-map*/ +define('can-connect/helpers/weak-reference-map', function (require, exports, module) { + var assign = require('can-util/js/assign/assign'); + var WeakReferenceMap = function () { + this.set = {}; + }; + assign(WeakReferenceMap.prototype, { + has: function (key) { + return !!this.set[key]; + }, + addReference: function (key, item) { + var data = this.set[key]; + if (!data) { + data = this.set[key] = { + item: item, + referenceCount: 0, + key: key + }; + } + data.referenceCount++; + }, + deleteReference: function (key) { + var data = this.set[key]; + if (data) { + data.referenceCount--; + if (data.referenceCount === 0) { + delete this.set[key]; + } + } + }, + get: function (key) { + var data = this.set[key]; + if (data) { + return data.item; + } + }, + forEach: function (cb) { + for (var id in this.set) { + cb(this.set[id].item, id); + } + } + }); + module.exports = WeakReferenceMap; +}); +/*can-connect@1.0.20#helpers/overwrite*/ +define('can-connect/helpers/overwrite', function (require, exports, module) { + module.exports = function (d, s, id) { + for (var prop in d) { + if (prop !== id && !(prop in s)) { + delete d[prop]; + } + } + for (prop in s) { + d[prop] = s[prop]; + } + return d; + }; +}); +/*can-connect@1.0.20#helpers/id-merge*/ +define('can-connect/helpers/id-merge', function (require, exports, module) { + var map = [].map; + module.exports = function (list, update, id, make) { + var listIndex = 0, updateIndex = 0; + while (listIndex < list.length && updateIndex < update.length) { + var listItem = list[listIndex], updateItem = update[updateIndex], lID = id(listItem), uID = id(updateItem); + if (id(listItem) === id(updateItem)) { + listIndex++; + updateIndex++; + continue; + } + if (updateIndex + 1 < update.length && id(update[updateIndex + 1]) === lID) { + list.splice(listIndex, 0, make(update[updateIndex])); + listIndex++; + updateIndex++; + continue; + } else if (listIndex + 1 < list.length && id(list[listIndex + 1]) === uID) { + list.splice(listIndex, 1); + listIndex++; + updateIndex++; + continue; + } else { + list.splice.apply(list, [ + listIndex, + list.length - listIndex + ].concat(map.call(update.slice(updateIndex), make))); + return list; + } + } + if (updateIndex === update.length && listIndex === list.length) { + return; + } + list.splice.apply(list, [ + listIndex, + list.length - listIndex + ].concat(map.call(update.slice(updateIndex), make))); + return; + }; +}); +/*can-connect@1.0.20#constructor/constructor*/ +define('can-connect/constructor/constructor', function (require, exports, module) { + var isArray = require('can-util/js/is-array/is-array'); + var makeArray = require('can-util/js/make-array/make-array'); + var assign = require('can-util/js/assign/assign'); + var connect = require('can-connect'); + var WeakReferenceMap = require('can-connect/helpers/weak-reference-map'); + var overwrite = require('can-connect/helpers/overwrite'); + var idMerge = require('can-connect/helpers/id-merge'); + module.exports = connect.behavior('constructor', function (baseConnection) { + var behavior = { + cidStore: new WeakReferenceMap(), + _cid: 0, + get: function (params) { + var self = this; + return this.getData(params).then(function (data) { + return self.hydrateInstance(data); + }); + }, + getList: function (set) { + set = set || {}; + var self = this; + return this.getListData(set).then(function (data) { + return self.hydrateList(data, set); + }); + }, + hydrateList: function (listData, set) { + if (isArray(listData)) { + listData = { data: listData }; + } + var arr = []; + for (var i = 0; i < listData.data.length; i++) { + arr.push(this.hydrateInstance(listData.data[i])); + } + listData.data = arr; + if (this.list) { + return this.list(listData, set); + } else { + var list = listData.data.slice(0); + list[this.listSetProp || '__listSet'] = set; + copyMetadata(listData, list); + return list; + } + }, + hydrateInstance: function (props) { + if (this.instance) { + return this.instance(props); + } else { + return assign({}, props); + } + }, + save: function (instance) { + var serialized = this.serializeInstance(instance); + var id = this.id(instance); + var self = this; + if (id === undefined) { + var cid = this._cid++; + this.cidStore.addReference(cid, instance); + return this.createData(serialized, cid).then(function (data) { + if (data !== undefined) { + self.createdInstance(instance, data); + } + self.cidStore.deleteReference(cid, instance); + return instance; + }); + } else { + return this.updateData(serialized).then(function (data) { + if (data !== undefined) { + self.updatedInstance(instance, data); + } + return instance; + }); + } + }, + destroy: function (instance) { + var serialized = this.serializeInstance(instance), self = this; + return this.destroyData(serialized).then(function (data) { + if (data !== undefined) { + self.destroyedInstance(instance, data); + } + return instance; + }); + }, + createdInstance: function (instance, props) { + assign(instance, props); + }, + updatedInstance: function (instance, data) { + overwrite(instance, data, this.idProp); + }, + updatedList: function (list, listData, set) { + var instanceList = []; + for (var i = 0; i < listData.data.length; i++) { + instanceList.push(this.hydrateInstance(listData.data[i])); + } + idMerge(list, instanceList, this.id.bind(this), this.hydrateInstance.bind(this)); + copyMetadata(listData, list); + }, + destroyedInstance: function (instance, data) { + overwrite(instance, data, this.idProp); + }, + serializeInstance: function (instance) { + return assign({}, instance); + }, + serializeList: function (list) { + var self = this; + return makeArray(list).map(function (instance) { + return self.serializeInstance(instance); + }); + }, + isNew: function (instance) { + var id = this.id(instance); + return !(id || id === 0); + } + }; + return behavior; + }); + function copyMetadata(listData, list) { + for (var prop in listData) { + if (prop !== 'data') { + if (typeof list.set === 'function') { + list.set(prop, listData[prop]); + } else if (typeof list.attr === 'function') { + list.attr(prop, listData[prop]); + } else { + list[prop] = listData[prop]; + } + } + } + } +}); +/*can-connect@1.0.20#helpers/sorted-set-json*/ +define('can-connect/helpers/sorted-set-json', function (require, exports, module) { + var forEach = [].forEach; + var keys = Object.keys; + module.exports = function (set) { + if (set == null) { + return set; + } else { + var sorted = {}; + forEach.call(keys(set).sort(), function (prop) { + sorted[prop] = set[prop]; + }); + return JSON.stringify(sorted); + } + }; +}); +/*can-connect@1.0.20#constructor/callbacks-once/callbacks-once*/ +define('can-connect/constructor/callbacks-once/callbacks-once', function (require, exports, module) { + var connect = require('can-connect'); + var sortedSetJSON = require('can-connect/helpers/sorted-set-json'); + var forEach = [].forEach; + var callbacks = [ + 'createdInstance', + 'updatedInstance', + 'destroyedInstance' + ]; + module.exports = connect.behavior('constructor/callbacks-once', function (baseConnection) { + var behavior = {}; + forEach.call(callbacks, function (name) { + behavior[name] = function (instance, data) { + var lastSerialized = this.getInstanceMetaData(instance, 'last-data'); + var serialize = sortedSetJSON(data), serialized = sortedSetJSON(this.serializeInstance(instance)); + if (lastSerialized !== serialize) { + var result = baseConnection[name].apply(this, arguments); + this.addInstanceMetaData(instance, 'last-data', serialize); + return result; + } + }; + }); + return behavior; + }); +}); +/*can-connect@1.0.20#constructor/store/store*/ +define('can-connect/constructor/store/store', function (require, exports, module) { + var connect = require('can-connect'); + var WeakReferenceMap = require('can-connect/helpers/weak-reference-map'); + var sortedSetJSON = require('can-connect/helpers/sorted-set-json'); + var canEvent = require('can-event'); + var assign = require('can-util/js/assign/assign'); + var pendingRequests = 0; + var noRequestsTimer = null; + var requests = { + increment: function (connection) { + pendingRequests++; + clearTimeout(noRequestsTimer); + }, + decrement: function (connection) { + pendingRequests--; + if (pendingRequests === 0) { + noRequestsTimer = setTimeout(function () { + requests.dispatch('end'); + }, 10); + } + }, + count: function () { + return pendingRequests; + } + }; + assign(requests, canEvent); + var constructorStore = connect.behavior('constructor/store', function (baseConnection) { + var behavior = { + instanceStore: new WeakReferenceMap(), + listStore: new WeakReferenceMap(), + _requestInstances: {}, + _requestLists: {}, + _finishedRequest: function () { + var id; + requests.decrement(this); + if (requests.count() === 0) { + for (id in this._requestInstances) { + this.instanceStore.deleteReference(id); + } + this._requestInstances = {}; + for (id in this._requestLists) { + this.listStore.deleteReference(id); + } + this._requestLists = {}; + } + }, + addInstanceReference: function (instance, id) { + this.instanceStore.addReference(id || this.id(instance), instance); + }, + addInstanceMetaData: function (instance, name, value) { + var data = this.instanceStore.set[this.id(instance)]; + if (data) { + data[name] = value; + } + }, + getInstanceMetaData: function (instance, name) { + var data = this.instanceStore.set[this.id(instance)]; + if (data) { + return data[name]; + } + }, + deleteInstanceMetaData: function (instance, name) { + var data = this.instanceStore.set[this.id(instance)]; + delete data[name]; + }, + deleteInstanceReference: function (instance) { + this.instanceStore.deleteReference(this.id(instance), instance); + }, + addListReference: function (list, set) { + var id = sortedSetJSON(set || this.listSet(list)); + if (id) { + this.listStore.addReference(id, list); + } + }, + deleteListReference: function (list, set) { + var id = sortedSetJSON(set || this.listSet(list)); + if (id) { + this.listStore.deleteReference(id, list); + } + }, + hydratedInstance: function (instance) { + if (requests.count() > 0) { + var id = this.id(instance); + if (!this._requestInstances[id]) { + this.addInstanceReference(instance); + this._requestInstances[id] = instance; + } + } + }, + hydrateInstance: function (props) { + var id = this.id(props); + if ((id || id === 0) && this.instanceStore.has(id)) { + var storeInstance = this.instanceStore.get(id); + this.updatedInstance(storeInstance, props); + return storeInstance; + } + var instance = baseConnection.hydrateInstance.call(this, props); + this.hydratedInstance(instance); + return instance; + }, + hydratedList: function (list, set) { + if (requests.count() > 0) { + var id = sortedSetJSON(set || this.listSet(list)); + if (id) { + if (!this._requestLists[id]) { + this.addListReference(list, set); + this._requestLists[id] = list; + } + } + } + }, + hydrateList: function (listData, set) { + set = set || this.listSet(listData); + var id = sortedSetJSON(set); + if (id && this.listStore.has(id)) { + var storeList = this.listStore.get(id); + this.updatedList(storeList, listData, set); + return storeList; + } + var list = baseConnection.hydrateList.call(this, listData, set); + this.hydratedList(list, set); + return list; + }, + getList: function (params) { + var self = this; + requests.increment(this); + var promise = baseConnection.getList.call(this, params); + promise.then(function (instances) { + self._finishedRequest(); + }, function () { + self._finishedRequest(); + }); + return promise; + }, + get: function (params) { + var self = this; + requests.increment(this); + var promise = baseConnection.get.call(this, params); + promise.then(function (instance) { + self._finishedRequest(); + }, function () { + self._finishedRequest(); + }); + return promise; + }, + save: function (instance) { + var self = this; + requests.increment(this); + var updating = !this.isNew(instance); + if (updating) { + this.addInstanceReference(instance); + } + var promise = baseConnection.save.call(this, instance); + promise.then(function (instances) { + if (updating) { + self.deleteInstanceReference(instance); + } + self._finishedRequest(); + }, function () { + self._finishedRequest(); + }); + return promise; + }, + destroy: function (instance) { + var self = this; + requests.increment(this); + var promise = baseConnection.destroy.call(this, instance); + promise.then(function (instance) { + self._finishedRequest(); + }, function () { + self._finishedRequest(); + }); + return promise; + } + }; + return behavior; + }); + constructorStore.requests = requests; + module.exports = constructorStore; +}); +/*can-connect@1.0.20#data/callbacks/callbacks*/ +define('can-connect/data/callbacks/callbacks', function (require, exports, module) { + var connect = require('can-connect'); + var each = require('can-util/js/each/each'); + var pairs = { + getListData: 'gotListData', + createData: 'createdData', + updateData: 'updatedData', + destroyData: 'destroyedData' + }; + module.exports = connect.behavior('data/callbacks', function (baseConnection) { + var behavior = {}; + each(pairs, function (callbackName, name) { + behavior[name] = function (params, cid) { + var self = this; + return baseConnection[name].call(this, params).then(function (data) { + if (self[callbackName]) { + return self[callbackName].call(self, data, params, cid); + } else { + return data; + } + }); + }; + }); + return behavior; + }); +}); +/*can-connect@1.0.20#data/callbacks-cache/callbacks-cache*/ +define('can-connect/data/callbacks-cache/callbacks-cache', function (require, exports, module) { + var connect = require('can-connect'); + var assign = require('can-util/js/assign/assign'); + var each = require('can-util/js/each/each'); + var pairs = { + createdData: 'createData', + updatedData: 'updateData', + destroyedData: 'destroyData' + }; + module.exports = connect.behavior('data/callbacks-cache', function (baseConnection) { + var behavior = {}; + each(pairs, function (cacheCallback, dataCallbackName) { + behavior[dataCallbackName] = function (data, set, cid) { + this.cacheConnection[cacheCallback](assign(assign({}, set), data)); + return baseConnection[dataCallbackName].call(this, data, set, cid); + }; + }); + return behavior; + }); +}); +/*can-connect@1.0.20#helpers/deferred*/ +define('can-connect/helpers/deferred', function (require, exports, module) { + module.exports = function () { + var def = {}; + def.promise = new Promise(function (resolve, reject) { + def.resolve = resolve; + def.reject = reject; + }); + return def; + }; +}); +/*can-connect@1.0.20#data/combine-requests/combine-requests*/ +define('can-connect/data/combine-requests/combine-requests', function (require, exports, module) { + var connect = require('can-connect'); + var canSet = require('can-set'); + var getItems = require('can-connect/helpers/get-items'); + var deepAssign = require('can-util/js/deep-assign/deep-assign'); + var makeDeferred = require('can-connect/helpers/deferred'); + var forEach = [].forEach; + module.exports = connect.behavior('data/combine-requests', function (baseConnection) { + var pendingRequests; + return { + unionPendingRequests: function (pendingRequests) { + var self = this; + pendingRequests.sort(function (pReq1, pReq2) { + if (canSet.subset(pReq1.set, pReq2.set, self.algebra)) { + return 1; + } else if (canSet.subset(pReq2.set, pReq1.set, self.algebra)) { + return -1; + } else { + return 0; + } + }); + var combineData = []; + var current; + doubleLoop(pendingRequests, { + start: function (pendingRequest) { + current = { + set: pendingRequest.set, + pendingRequests: [pendingRequest] + }; + combineData.push(current); + }, + iterate: function (pendingRequest) { + var combined = canSet.union(current.set, pendingRequest.set, self.algebra); + if (combined) { + current.set = combined; + current.pendingRequests.push(pendingRequest); + return true; + } + } + }); + return Promise.resolve(combineData); + }, + getSubset: function (set, unionSet, data) { + return canSet.getSubset(set, unionSet, data, this.algebra); + }, + time: 1, + getListData: function (set) { + set = set || {}; + var self = this; + if (!pendingRequests) { + pendingRequests = []; + setTimeout(function () { + var combineDataPromise = self.unionPendingRequests(pendingRequests); + pendingRequests = null; + combineDataPromise.then(function (combinedData) { + forEach.call(combinedData, function (combined) { + var combinedSet = deepAssign({}, combined.set); + baseConnection.getListData(combinedSet).then(function (data) { + if (combined.pendingRequests.length === 1) { + combined.pendingRequests[0].deferred.resolve(data); + } else { + forEach.call(combined.pendingRequests, function (pending) { + pending.deferred.resolve({ data: self.getSubset(pending.set, combined.set, getItems(data)) }); + }); + } + }, function (err) { + if (combined.pendingRequests.length === 1) { + combined.pendingRequests[0].deferred.reject(err); + } else { + forEach.call(combined.pendingRequests, function (pending) { + pending.deferred.reject(err); + }); + } + }); + }); + }); + }, this.time || 1); + } + var deferred = makeDeferred(); + pendingRequests.push({ + deferred: deferred, + set: set + }); + return deferred.promise; + } + }; + }); + var doubleLoop = function (arr, callbacks) { + var i = 0; + while (i < arr.length) { + callbacks.start(arr[i]); + var j = i + 1; + while (j < arr.length) { + if (callbacks.iterate(arr[j]) === true) { + arr.splice(j, 1); + } else { + j++; + } + } + i++; + } + }; +}); +/*can-connect@1.0.20#helpers/set-add*/ +define('can-connect/helpers/set-add', function (require, exports, module) { + var canSet = require('can-set'); + module.exports = function (connection, setItems, items, item, algebra) { + var index = canSet.index(setItems, items, item, algebra); + if (index === undefined) { + index = items.length; + } + var copy = items.slice(0); + copy.splice(index, 0, item); + return copy; + }; +}); +/*can-connect@1.0.20#helpers/get-index-by-id*/ +define('can-connect/helpers/get-index-by-id', function (require, exports, module) { + module.exports = function (connection, props, items) { + var id = connection.id(props); + for (var i = 0; i < items.length; i++) { + var connId = connection.id(items[i]); + if (id == connId) { + return i; + } + } + return -1; + }; +}); +/*can-connect@1.0.20#data/localstorage-cache/localstorage-cache*/ +define('can-connect/data/localstorage-cache/localstorage-cache', function (require, exports, module) { + var getItems = require('can-connect/helpers/get-items'); + var connect = require('can-connect'); + var sortedSetJSON = require('can-connect/helpers/sorted-set-json'); + var canSet = require('can-set'); + var forEach = [].forEach; + var map = [].map; + var setAdd = require('can-connect/helpers/set-add'); + var indexOf = require('can-connect/helpers/get-index-by-id'); + var assign = require('can-util/js/assign/assign'); + var overwrite = require('can-connect/helpers/overwrite'); + module.exports = connect.behavior('data/localstorage-cache', function (baseConnection) { + var behavior = { + _instances: {}, + getSetData: function () { + var sets = {}; + var self = this; + forEach.call(JSON.parse(localStorage.getItem(this.name + '-sets')) || [], function (set) { + var setKey = sortedSetJSON(set); + if (localStorage.getItem(self.name + '/set/' + setKey)) { + sets[setKey] = { + set: set, + setKey: setKey + }; + } + }); + return sets; + }, + _getSets: function (setData) { + var sets = []; + setData = setData || this.getSetData(); + for (var setKey in setData) { + sets.push(JSON.parse(setKey)); + } + return sets; + }, + getInstance: function (id) { + var res = localStorage.getItem(this.name + '/instance/' + id); + if (res) { + return JSON.parse(res); + } + }, + updateInstance: function (props) { + var id = this.id(props); + var instance = this.getInstance(id); + if (!instance) { + instance = props; + } else { + overwrite(instance, props, this.idProp); + } + localStorage.setItem(this.name + '/instance/' + id, JSON.stringify(instance)); + return instance; + }, + getInstances: function (ids) { + var self = this; + return map.call(ids, function (id) { + return self.getInstance(id); + }); + }, + removeSet: function (setKey) { + var sets = this.getSetData(); + localStorage.removeItem(this.name + '/set/' + setKey); + delete sets[setKey]; + }, + updateSets: function (sets) { + var setData = this._getSets(sets); + localStorage.setItem(this.name + '-sets', JSON.stringify(setData)); + }, + updateSet: function (setDatum, items, newSet) { + var newSetKey = newSet ? sortedSetJSON(newSet) : setDatum.setKey; + if (newSet) { + if (newSetKey !== setDatum.setKey) { + var sets = this.getSetData(); + localStorage.removeItem(this.name + '/set/' + setDatum.setKey); + delete sets[setDatum.setKey]; + sets[newSetKey] = { + setKey: newSetKey, + set: newSet + }; + this.updateSets(sets); + } + } + setDatum.items = items; + var self = this; + var ids = map.call(items, function (item) { + var id = self.id(item); + localStorage.setItem(self.name + '/instance/' + id, JSON.stringify(item)); + return id; + }); + localStorage.setItem(this.name + '/set/' + newSetKey, JSON.stringify(ids)); + }, + addSet: function (set, data) { + var items = getItems(data); + var sets = this.getSetData(); + var setKey = sortedSetJSON(set); + sets[setKey] = { + setKey: setKey, + items: items, + set: set + }; + var self = this; + var ids = map.call(items, function (item) { + var id = self.id(item); + localStorage.setItem(self.name + '/instance/' + id, JSON.stringify(item)); + return id; + }); + localStorage.setItem(this.name + '/set/' + setKey, JSON.stringify(ids)); + this.updateSets(sets); + }, + _eachSet: function (cb) { + var sets = this.getSetData(); + var self = this; + var loop = function (setDatum, setKey) { + return cb.call(self, setDatum, setKey, function () { + if (!('items' in setDatum)) { + var ids = JSON.parse(localStorage.getItem(self.name + '/set/' + setKey)); + setDatum.items = self.getInstances(ids); + } + return setDatum.items; + }); + }; + for (var setKey in sets) { + var setDatum = sets[setKey]; + var result = loop(setDatum, setKey); + if (result !== undefined) { + return result; + } + } + }, + clear: function () { + var sets = this.getSetData(); + for (var setKey in sets) { + localStorage.removeItem(this.name + '/set/' + setKey); + } + localStorage.removeItem(this.name + '-sets'); + var keys = []; + for (var i = 0, len = localStorage.length; i < len; ++i) { + if (localStorage.key(i).indexOf(this.name + '/instance/') === 0) { + keys.push(localStorage.key(i)); + } + } + forEach.call(keys, function (key) { + localStorage.removeItem(key); + }); + this._instances = {}; + }, + getSets: function () { + return Promise.resolve(this._getSets()); + }, + getListData: function (set) { + set = set || {}; + var listData = this.getListDataSync(set); + if (listData) { + return Promise.resolve(listData); + } + return Promise.reject({ + message: 'no data', + error: 404 + }); + }, + getListDataSync: function (set) { + var sets = this._getSets(); + for (var i = 0; i < sets.length; i++) { + var checkSet = sets[i]; + if (canSet.subset(set, checkSet, this.algebra)) { + var items = canSet.getSubset(set, checkSet, this.__getListData(checkSet), this.algebra); + return { data: items }; + } + } + }, + __getListData: function (set) { + var setKey = sortedSetJSON(set); + var setDatum = this.getSetData()[setKey]; + if (setDatum) { + var localData = localStorage.getItem(this.name + '/set/' + setKey); + if (localData) { + return this.getInstances(JSON.parse(localData)); + } + } + }, + getData: function (params) { + var id = this.id(params); + var res = localStorage.getItem(this.name + '/instance/' + id); + if (res) { + return Promise.resolve(JSON.parse(res)); + } else { + return Promise.reject({ + message: 'no data', + error: 404 + }); + } + }, + updateListData: function (data, set) { + set = set || {}; + var items = getItems(data); + var sets = this.getSetData(); + var self = this; + for (var setKey in sets) { + var setDatum = sets[setKey]; + var union = canSet.union(setDatum.set, set, this.algebra); + if (union) { + return this.getListData(setDatum.set).then(function (setData) { + self.updateSet(setDatum, canSet.getUnion(setDatum.set, set, getItems(setData), items, this.algebra), union); + }); + } + } + this.addSet(set, data); + return Promise.resolve(); + }, + createData: function (props) { + var self = this; + var instance = this.updateInstance(props); + this._eachSet(function (setDatum, setKey, getItems) { + if (canSet.has(setDatum.set, instance, this.algebra)) { + self.updateSet(setDatum, setAdd(self, setDatum.set, getItems(), instance, self.algebra), setDatum.set); + } + }); + return Promise.resolve(assign({}, instance)); + }, + updateData: function (props) { + var self = this; + var instance = this.updateInstance(props); + this._eachSet(function (setDatum, setKey, getItems) { + var items = getItems(); + var index = indexOf(self, instance, items); + if (canSet.has(setDatum.set, instance, this.algebra)) { + if (index === -1) { + self.updateSet(setDatum, setAdd(self, setDatum.set, getItems(), instance, self.algebra)); + } else { + items.splice(index, 1, instance); + self.updateSet(setDatum, items); + } + } else if (index !== -1) { + items.splice(index, 1); + self.updateSet(setDatum, items); + } + }); + return Promise.resolve(assign({}, instance)); + }, + destroyData: function (props) { + var self = this; + var instance = this.updateInstance(props); + this._eachSet(function (setDatum, setKey, getItems) { + var items = getItems(); + var index = indexOf(self, instance, items); + if (index !== -1) { + items.splice(index, 1); + self.updateSet(setDatum, items); + } + }); + var id = this.id(instance); + localStorage.removeItem(this.name + '/instance/' + id); + return Promise.resolve(assign({}, instance)); + } + }; + return behavior; + }); +}); +/*can-connect@1.0.20#helpers/clone-data*/ +define('can-connect/helpers/clone-data', function (require, exports, module) { + var isArray = require('can-util/js/is-array/is-array'); + var deepAssign = require('can-util/js/deep-assign/deep-assign'); + module.exports = function (data) { + return isArray(data) ? data.slice(0) : deepAssign({}, data); + }; +}); +/*can-connect@1.0.20#data/memory-cache/memory-cache*/ +define('can-connect/data/memory-cache/memory-cache', function (require, exports, module) { + var getItems = require('can-connect/helpers/get-items'); + var connect = require('can-connect'); + var sortedSetJSON = require('can-connect/helpers/sorted-set-json'); + var canSet = require('can-set'); + var overwrite = require('can-connect/helpers/overwrite'); + var setAdd = require('can-connect/helpers/set-add'); + var indexOf = require('can-connect/helpers/get-index-by-id'); + var assign = require('can-util/js/assign/assign'); + var cloneData = require('can-connect/helpers/clone-data'); + module.exports = connect.behavior('data/memory-cache', function (baseConnection) { + var behavior = { + _sets: {}, + getSetData: function () { + return this._sets; + }, + __getListData: function (set) { + var setsData = this.getSetData(); + var setData = setsData[sortedSetJSON(set)]; + if (setData) { + return setData.items; + } + }, + _instances: {}, + getInstance: function (id) { + return this._instances[id]; + }, + removeSet: function (setKey, noUpdate) { + var sets = this.getSetData(); + delete sets[setKey]; + if (noUpdate !== true) { + this.updateSets(); + } + }, + updateSets: function () { + }, + updateInstance: function (props) { + var id = this.id(props); + if (!(id in this._instances)) { + this._instances[id] = props; + } else { + overwrite(this._instances[id], props, this.idProp); + } + return this._instances[id]; + }, + updateSet: function (setDatum, items, newSet) { + var newSetKey = newSet ? sortedSetJSON(newSet) : setDatum.setKey; + if (newSet) { + if (newSetKey !== setDatum.setKey) { + var sets = this.getSetData(); + var oldSetKey = setDatum.setKey; + sets[newSetKey] = setDatum; + setDatum.setKey = newSetKey; + setDatum.set = assign({}, newSet); + this.removeSet(oldSetKey); + } + } + setDatum.items = items; + var self = this; + items.forEach(function (item) { + self.updateInstance(item); + }); + }, + addSet: function (set, data) { + var items = getItems(data); + var sets = this.getSetData(); + var setKey = sortedSetJSON(set); + sets[setKey] = { + setKey: setKey, + items: items, + set: assign({}, set) + }; + var self = this; + items.forEach(function (item) { + self.updateInstance(item); + }); + this.updateSets(); + }, + _eachSet: function (cb) { + var sets = this.getSetData(); + var self = this; + var loop = function (setDatum, setKey) { + return cb.call(self, setDatum, setKey, function () { + return setDatum.items; + }); + }; + for (var setKey in sets) { + var setDatum = sets[setKey]; + var result = loop(setDatum, setKey); + if (result !== undefined) { + return result; + } + } + }, + _getSets: function () { + var sets = [], setsData = this.getSetData(); + for (var prop in setsData) { + sets.push(setsData[prop].set); + } + return sets; + }, + getSets: function () { + return Promise.resolve(this._getSets()); + }, + clear: function () { + this._instances = {}; + this._sets = {}; + }, + getListData: function (set) { + set = set || {}; + var listData = this.getListDataSync(set); + if (listData) { + return Promise.resolve(listData); + } + return Promise.reject({ + message: 'no data', + error: 404 + }); + }, + getListDataSync: function (set) { + var sets = this._getSets(); + for (var i = 0; i < sets.length; i++) { + var checkSet = sets[i]; + if (canSet.subset(set, checkSet, this.algebra)) { + var source = this.__getListData(checkSet); + var items = canSet.getSubset(set, checkSet, source, this.algebra); + return { + data: items, + count: source.length + }; + } + } + }, + _getListData: function (set) { + return this.getListDataSync(set); + }, + updateListData: function (data, set) { + set = set || {}; + var clonedData = cloneData(data); + var items = getItems(clonedData); + var sets = this.getSetData(); + var self = this; + for (var setKey in sets) { + var setDatum = sets[setKey]; + var union = canSet.union(setDatum.set, set, this.algebra); + if (union) { + var getSet = assign({}, setDatum.set); + return this.getListData(getSet).then(function (setData) { + self.updateSet(setDatum, canSet.getUnion(getSet, set, getItems(setData), items, self.algebra), union); + }); + } + } + this.addSet(set, clonedData); + return Promise.resolve(); + }, + getData: function (params) { + var id = this.id(params); + var res = this.getInstance(id); + if (res) { + return Promise.resolve(res); + } else { + return Promise.reject({ + message: 'no data', + error: 404 + }); + } + }, + createData: function (props) { + var self = this; + var instance = this.updateInstance(props); + this._eachSet(function (setDatum, setKey, getItems) { + if (canSet.has(setDatum.set, instance, this.algebra)) { + self.updateSet(setDatum, setAdd(self, setDatum.set, getItems(), instance, self.algebra), setDatum.set); + } + }); + return Promise.resolve(assign({}, instance)); + }, + updateData: function (props) { + var self = this; + var instance = this.updateInstance(props); + this._eachSet(function (setDatum, setKey, getItems) { + var items = getItems(); + var index = indexOf(self, instance, items); + if (canSet.subset(instance, setDatum.set, this.algebra)) { + if (index === -1) { + self.updateSet(setDatum, setAdd(self, setDatum.set, getItems(), instance, self.algebra)); + } else { + items.splice(index, 1, instance); + self.updateSet(setDatum, items); + } + } else if (index !== -1) { + items.splice(index, 1); + self.updateSet(setDatum, items); + } + }); + return Promise.resolve(assign({}, instance)); + }, + destroyData: function (props) { + var self = this; + this._eachSet(function (setDatum, setKey, getItems) { + var items = getItems(); + var index = indexOf(self, props, items); + if (index !== -1) { + items.splice(index, 1); + self.updateSet(setDatum, items); + } + }); + var id = this.id(props); + delete this._instances[id]; + return Promise.resolve(assign({}, props)); + } + }; + return behavior; + }); +}); +/*can-connect@1.0.20#data/parse/parse*/ +define('can-connect/data/parse/parse', function (require, exports, module) { + var connect = require('can-connect'); + var each = require('can-util/js/each/each'); + var isArray = require('can-util/js/is-array/is-array'); + var getObject = require('can-util/js/get/get'); + module.exports = connect.behavior('data/parse', function (baseConnection) { + var behavior = { + parseListData: function (responseData) { + if (baseConnection.parseListData) { + responseData = baseConnection.parseListData.apply(this, arguments); + } + var result; + if (isArray(responseData)) { + result = { data: responseData }; + } else { + var prop = this.parseListProp || 'data'; + responseData.data = getObject(responseData, prop); + result = responseData; + if (prop !== 'data') { + delete responseData[prop]; + } + if (!isArray(result.data)) { + throw new Error('Could not get any raw data while converting using .parseListData'); + } + } + var arr = []; + for (var i = 0; i < result.data.length; i++) { + arr.push(this.parseInstanceData(result.data[i])); + } + result.data = arr; + return result; + }, + parseInstanceData: function (props) { + if (baseConnection.parseInstanceData) { + props = baseConnection.parseInstanceData.apply(this, arguments) || props; + } + return this.parseInstanceProp ? getObject(props, this.parseInstanceProp) || props : props; + } + }; + each(pairs, function (parseFunction, name) { + behavior[name] = function (params) { + var self = this; + return baseConnection[name].call(this, params).then(function () { + return self[parseFunction].apply(self, arguments); + }); + }; + }); + return behavior; + }); + var pairs = { + getListData: 'parseListData', + getData: 'parseInstanceData', + createData: 'parseInstanceData', + updateData: 'parseInstanceData', + destroyData: 'parseInstanceData' + }; +}); +/*can-connect@1.0.20#helpers/get-id-props*/ +define('can-connect/helpers/get-id-props', function (require, exports, module) { + module.exports = function (connection) { + var ids = [], algebra = this.algebra; + if (algebra && algebra.clauses && algebra.clauses.id) { + for (var prop in algebra.clauses.id) { + ids.push(prop); + } + } + if (connection.idProp && !ids.length) { + ids.push(connection.idProp); + } + if (!ids.length) { + ids.push('id'); + } + return ids; + }; +}); +/*can-connect@1.0.20#data/url/url*/ +define('can-connect/data/url/url', function (require, exports, module) { + var isArray = require('can-util/js/is-array/is-array'); + var assign = require('can-util/js/assign/assign'); + var each = require('can-util/js/each/each'); + var ajax = require('can-util/dom/ajax/ajax'); + var string = require('can-util/js/string/string'); + var getIdProps = require('can-connect/helpers/get-id-props'); + var dev = require('can-util/js/dev/dev'); + var connect = require('can-connect'); + var makePromise = require('can-util/js/make-promise/make-promise'); + module.exports = connect.behavior('data/url', function (baseConnection) { + var behavior = {}; + each(pairs, function (reqOptions, name) { + behavior[name] = function (params) { + if (typeof this.url === 'object') { + if (typeof this.url[reqOptions.prop] === 'function') { + return makePromise(this.url[reqOptions.prop](params)); + } else if (this.url[reqOptions.prop]) { + return makePromise(makeAjax(this.url[reqOptions.prop], params, reqOptions.type, this.ajax || ajax, findContentType(this.url), reqOptions)); + } + } + var resource = typeof this.url === 'string' ? this.url : this.url.resource; + if (resource) { + var idProps = getIdProps(this); + return makePromise(makeAjax(createURLFromResource(resource, idProps[0], reqOptions.prop), params, reqOptions.type, this.ajax || ajax, findContentType(this.url), reqOptions)); + } + return baseConnection[name].call(this, params); + }; + }); + return behavior; + }); + var pairs = { + getListData: { + prop: 'getListData', + type: 'GET' + }, + getData: { + prop: 'getData', + type: 'GET' + }, + createData: { + prop: 'createData', + type: 'POST' + }, + updateData: { + prop: 'updateData', + type: 'PUT' + }, + destroyData: { + prop: 'destroyData', + type: 'DELETE', + includeData: false + } + }; + var findContentType = function (url) { + if (typeof url === 'object' && url.contentType) { + var acceptableType = url.contentType === 'application/x-www-form-urlencoded' || url.contentType === 'application/json'; + if (acceptableType) { + return url.contentType; + } else { + } + } + return 'application/json'; + }; + var makeAjax = function (ajaxOb, data, type, ajax, contentType, reqOptions) { + var params = {}; + if (typeof ajaxOb === 'string') { + var parts = ajaxOb.split(/\s+/); + params.url = parts.pop(); + if (parts.length) { + params.type = parts.pop(); + } + } else { + assign(params, ajaxOb); + } + params.data = typeof data === 'object' && !isArray(data) ? assign(params.data || {}, data) : data; + params.url = string.sub(params.url, params.data, true); + var encodeJSON = contentType !== 'application/x-www-form-urlencoded' && (type && (type === 'POST' || type === 'PUT')); + if (encodeJSON) { + params.data = JSON.stringify(params.data); + params.contentType = contentType; + } + if (reqOptions.includeData === false) { + delete params.data; + } + return ajax(assign({ + type: type || 'post', + dataType: 'json' + }, params)); + }; + var createURLFromResource = function (resource, idProp, name) { + var url = resource.replace(/\/+$/, ''); + if (name === 'getListData' || name === 'createData') { + return url; + } else { + return url + '/{' + idProp + '}'; + } + }; +}); +/*can-connect@1.0.20#fall-through-cache/fall-through-cache*/ +define('can-connect/fall-through-cache/fall-through-cache', function (require, exports, module) { + var connect = require('can-connect'); + var sortedSetJSON = require('can-connect/helpers/sorted-set-json'); + module.exports = connect.behavior('fall-through-cache', function (baseConnection) { + var behavior = { + hydrateList: function (listData, set) { + set = set || this.listSet(listData); + var id = sortedSetJSON(set); + var list = baseConnection.hydrateList.call(this, listData, set); + if (this._getHydrateListCallbacks[id]) { + this._getHydrateListCallbacks[id].shift()(list); + if (!this._getHydrateListCallbacks[id].length) { + delete this._getHydrateListCallbacks[id]; + } + } + return list; + }, + _getHydrateListCallbacks: {}, + _getHydrateList: function (set, callback) { + var id = sortedSetJSON(set); + if (!this._getHydrateListCallbacks[id]) { + this._getHydrateListCallbacks[id] = []; + } + this._getHydrateListCallbacks[id].push(callback); + }, + getListData: function (set) { + set = set || {}; + var self = this; + return this.cacheConnection.getListData(set).then(function (data) { + self._getHydrateList(set, function (list) { + self.addListReference(list, set); + setTimeout(function () { + baseConnection.getListData.call(self, set).then(function (listData) { + self.cacheConnection.updateListData(listData, set); + self.updatedList(list, listData, set); + self.deleteListReference(list, set); + }, function (e) { + console.log('REJECTED', e); + }); + }, 1); + }); + return data; + }, function () { + var listData = baseConnection.getListData.call(self, set); + listData.then(function (listData) { + self.cacheConnection.updateListData(listData, set); + }); + return listData; + }); + }, + hydrateInstance: function (props) { + var id = this.id(props); + var instance = baseConnection.hydrateInstance.apply(this, arguments); + if (this._getMakeInstanceCallbacks[id]) { + this._getMakeInstanceCallbacks[id].shift()(instance); + if (!this._getMakeInstanceCallbacks[id].length) { + delete this._getMakeInstanceCallbacks[id]; + } + } + return instance; + }, + _getMakeInstanceCallbacks: {}, + _getMakeInstance: function (id, callback) { + if (!this._getMakeInstanceCallbacks[id]) { + this._getMakeInstanceCallbacks[id] = []; + } + this._getMakeInstanceCallbacks[id].push(callback); + }, + getData: function (params) { + var self = this; + return this.cacheConnection.getData(params).then(function (instanceData) { + self._getMakeInstance(self.id(instanceData) || self.id(params), function (instance) { + self.addInstanceReference(instance); + setTimeout(function () { + baseConnection.getData.call(self, params).then(function (instanceData2) { + self.cacheConnection.updateData(instanceData2); + self.updatedInstance(instance, instanceData2); + self.deleteInstanceReference(instance); + }, function (e) { + console.log('REJECTED', e); + }); + }, 1); + }); + return instanceData; + }, function () { + var listData = baseConnection.getData.call(self, params); + listData.then(function (instanceData) { + self.cacheConnection.updateData(instanceData); + }); + return listData; + }); + } + }; + return behavior; + }); +}); +/*can-connect@1.0.20#real-time/real-time*/ +define('can-connect/real-time/real-time', function (require, exports, module) { + var connect = require('can-connect'); + var canSet = require('can-set'); + var setAdd = require('can-connect/helpers/set-add'); + var indexOf = require('can-connect/helpers/get-index-by-id'); + var canDev = require('can-util/js/dev/dev'); + module.exports = connect.behavior('real-time', function (baseConnection) { + return { + createInstance: function (props) { + var id = this.id(props); + var instance = this.instanceStore.get(id); + var serialized; + if (instance) { + return this.updateInstance(props); + } else { + instance = this.hydrateInstance(props); + serialized = this.serializeInstance(instance); + var self = this; + this.addInstanceReference(instance); + return Promise.resolve(this.createdData(props, serialized)).then(function () { + self.deleteInstanceReference(instance); + return instance; + }); + } + }, + createdData: function (props, params, cid) { + var instance; + if (cid !== undefined) { + instance = this.cidStore.get(cid); + } else { + instance = this.instanceStore.get(this.id(props)); + } + this.addInstanceReference(instance, this.id(props)); + this.createdInstance(instance, props); + create.call(this, this.serializeInstance(instance)); + this.deleteInstanceReference(instance); + return undefined; + }, + updatedData: function (props, params) { + var instance = this.instanceStore.get(this.id(params)); + this.updatedInstance(instance, props); + update.call(this, this.serializeInstance(instance)); + return undefined; + }, + updateInstance: function (props) { + var id = this.id(props); + var instance = this.instanceStore.get(id); + if (!instance) { + instance = this.hydrateInstance(props); + } + this.addInstanceReference(instance); + var serialized = this.serializeInstance(instance), self = this; + return Promise.resolve(this.updatedData(props, serialized)).then(function () { + self.deleteInstanceReference(instance); + return instance; + }); + }, + destroyedData: function (props, params) { + var id = this.id(params || props); + var instance = this.instanceStore.get(id); + if (!instance) { + instance = this.hydrateInstance(props); + } + var serialized = this.serializeInstance(instance); + this.destroyedInstance(instance, props); + destroy.call(this, serialized); + return undefined; + }, + destroyInstance: function (props) { + var id = this.id(props); + var instance = this.instanceStore.get(id); + if (!instance) { + instance = this.hydrateInstance(props); + } + this.addInstanceReference(instance); + var serialized = this.serializeInstance(instance), self = this; + return Promise.resolve(this.destroyedData(props, serialized)).then(function () { + self.deleteInstanceReference(instance); + return instance; + }); + } + }; + }); + var create = function (props) { + var self = this; + this.listStore.forEach(function (list, id) { + var set = JSON.parse(id); + var index = indexOf(self, props, list); + if (canSet.has(set, props, self.algebra)) { + if (index === -1) { + var items = self.serializeList(list); + self.updatedList(list, { data: setAdd(self, set, items, props, self.algebra) }, set); + } else { + } + } + }); + }; + var update = function (props) { + var self = this; + this.listStore.forEach(function (list, id) { + var items; + var set = JSON.parse(id); + var index = indexOf(self, props, list); + if (canSet.has(set, props, self.algebra)) { + items = self.serializeList(list); + if (index === -1) { + self.updatedList(list, { data: setAdd(self, set, items, props, self.algebra) }, set); + } else { + var sortedIndex = canSet.index(set, items, props, self.algebra); + if (sortedIndex !== undefined && sortedIndex !== index) { + var copy = items.slice(0); + if (index < sortedIndex) { + copy.splice(sortedIndex, 0, props); + copy.splice(index, 1); + } else { + copy.splice(index, 1); + copy.splice(sortedIndex, 0, props); + } + self.updatedList(list, { data: copy }, set); + } + } + } else if (index !== -1) { + items = self.serializeList(list); + items.splice(index, 1); + self.updatedList(list, { data: items }, set); + } + }); + }; + var destroy = function (props) { + var self = this; + this.listStore.forEach(function (list, id) { + var set = JSON.parse(id); + var index = indexOf(self, props, list); + if (index !== -1) { + var items = self.serializeList(list); + items.splice(index, 1); + self.updatedList(list, { data: items }, set); + } + }); + }; +}); +/*can-connect@1.0.20#can/map/map*/ +define('can-connect/can/map/map', function (require, exports, module) { + 'use strict'; + var each = require('can-util/js/each/each'); + var connect = require('can-connect'); + var canBatch = require('can-event/batch/batch'); + var canEvent = require('can-event'); + var Observation = require('can-observation'); + var isPlainObject = require('can-util/js/is-plain-object/is-plain-object'); + var isArray = require('can-util/js/is-array/is-array'); + var types = require('can-types'); + var each = require('can-util/js/each/each'); + var isFunction = require('can-util/js/is-function/is-function'); + var dev = require('can-util/js/dev/dev'); + var setExpando = function (map, prop, value) { + if ('attr' in map) { + map[prop] = value; + } else { + map._data[prop] = value; + } + }; + var getExpando = function (map, prop) { + if ('attr' in map) { + return map[prop]; + } else { + return map._data[prop]; + } + }; + module.exports = connect.behavior('can/map', function (baseConnection) { + var behavior = { + init: function () { + this.Map = this.Map || types.DefaultMap.extend({}); + this.List = this.List || types.DefaultList.extend({}); + overwrite(this, this.Map, mapOverwrites, mapStaticOverwrites); + overwrite(this, this.List, listPrototypeOverwrites, listStaticOverwrites); + baseConnection.init.apply(this, arguments); + }, + id: function (instance) { + if (!isPlainObject(instance)) { + var ids = [], algebra = this.algebra; + if (algebra && algebra.clauses && algebra.clauses.id) { + for (var prop in algebra.clauses.id) { + ids.push(readObservabe(instance, prop)); + } + } + if (this.idProp && !ids.length) { + ids.push(readObservabe(instance, this.idProp)); + } + if (!ids.length) { + ids.push(readObservabe(instance, 'id')); + } + return ids.length > 1 ? ids.join('@|@') : ids[0]; + } else { + return baseConnection.id(instance); + } + }, + serializeInstance: function (instance) { + return instance.serialize(); + }, + serializeList: function (list) { + return list.serialize(); + }, + instance: function (props) { + var _Map = this.Map || types.DefaultMap; + return new _Map(props); + }, + list: function (listData, set) { + var _List = this.List || this.Map && this.Map.List || types.DefaultList; + var list = new _List(listData.data); + each(listData, function (val, prop) { + if (prop !== 'data') { + list[list.set ? 'set' : 'attr'](prop, val); + } + }); + list.__listSet = set; + return list; + }, + updatedList: function () { + canBatch.start(); + var res = baseConnection.updatedList.apply(this, arguments); + canBatch.stop(); + return res; + }, + save: function (instance) { + setExpando(instance, '_saving', true); + canEvent.dispatch.call(instance, '_saving', [ + true, + false + ]); + var done = function () { + setExpando(instance, '_saving', false); + canEvent.dispatch.call(instance, '_saving', [ + false, + true + ]); + }; + var base = baseConnection.save.apply(this, arguments); + base.then(done, done); + return base; + }, + destroy: function (instance) { + setExpando(instance, '_destroying', true); + canEvent.dispatch.call(instance, '_destroying', [ + true, + false + ]); + var done = function () { + setExpando(instance, '_destroying', false); + canEvent.dispatch.call(instance, '_destroying', [ + false, + true + ]); + }; + var base = baseConnection.destroy.apply(this, arguments); + base.then(done, done); + return base; + } + }; + each([ + 'created', + 'updated', + 'destroyed' + ], function (funcName) { + behavior[funcName + 'Instance'] = function (instance, props) { + var constructor = instance.constructor; + if (props && typeof props === 'object') { + if ('set' in instance) { + instance.set(isFunction(props.get) ? props.get() : props, this.constructor.removeAttr || false); + } else if ('attr' in instance) { + instance.attr(isFunction(props.attr) ? props.attr() : props, this.constructor.removeAttr || false); + } else { + canBatch.start(); + each(props, function (value, prop) { + instance[prop] = value; + }); + canBatch.stop(); + } + } + canEvent.dispatch.call(instance, { + type: funcName, + target: instance + }); + canEvent.dispatch.call(constructor, funcName, [instance]); + }; + }); + return behavior; + }); + var callCanReadingOnIdRead = true; + var mapStaticOverwrites = { + getList: function (base, connection) { + return function (set) { + return connection.getList(set); + }; + }, + findAll: function (base, connection) { + return function (set) { + return connection.getList(set); + }; + }, + get: function (base, connection) { + return function (params) { + return connection.get(params); + }; + }, + findOne: function (base, connection) { + return function (params) { + return connection.get(params); + }; + } + }; + var mapOverwrites = { + _eventSetup: function (base, connection) { + return function () { + callCanReadingOnIdRead = false; + connection.addInstanceReference(this); + callCanReadingOnIdRead = true; + return base.apply(this, arguments); + }; + }, + _eventTeardown: function (base, connection) { + return function () { + callCanReadingOnIdRead = false; + connection.deleteInstanceReference(this); + callCanReadingOnIdRead = true; + return base.apply(this, arguments); + }; + }, + ___set: function (base, connection) { + return function (prop, val) { + base.apply(this, arguments); + if (prop === connection.idProp && this._bindings) { + connection.addInstanceReference(this); + } + }; + }, + isNew: function (base, connection) { + return function () { + var id = connection.id(this); + return !(id || id === 0); + }; + }, + isSaving: function (base, connection) { + return function () { + Observation.add(this, '_saving'); + return !!getExpando(this, '_saving'); + }; + }, + isDestroying: function (base, connection) { + return function () { + Observation.add(this, '_destroying'); + return !!getExpando(this, '_destroying'); + }; + }, + save: function (base, connection) { + return function (success, error) { + var promise = connection.save(this); + promise.then(success, error); + return promise; + }; + }, + destroy: function (base, connection) { + return function (success, error) { + var promise; + if (this.isNew()) { + promise = Promise.resolve(this); + connection.destroyedInstance(this, {}); + } else { + promise = connection.destroy(this); + } + promise.then(success, error); + return promise; + }; + } + }; + var listPrototypeOverwrites = { + setup: function (base, connection) { + return function (params) { + if (isPlainObject(params) && !isArray(params)) { + this.__listSet = params; + base.apply(this); + this.replace(types.isPromise(params) ? params : connection.getList(params)); + } else { + base.apply(this, arguments); + } + }; + }, + _eventSetup: function (base, connection) { + return function () { + connection.addListReference(this); + if (base) { + return base.apply(this, arguments); + } + }; + }, + _eventTeardown: function (base, connection) { + return function () { + connection.deleteListReference(this); + if (base) { + return base.apply(this, arguments); + } + }; + } + }; + var listStaticOverwrites = { + _bubbleRule: function (base, connection) { + return function (eventName, list) { + var bubbleRules = base(eventName, list); + bubbleRules.push('destroyed'); + return bubbleRules; + }; + } + }; + var readObservabe = function (instance, prop) { + if ('__get' in instance) { + if (callCanReadingOnIdRead) { + Observation.add(instance, prop); + } + return instance.__get(prop); + } else { + if (callCanReadingOnIdRead) { + return instance[prop]; + } else { + return Observation.ignore(function () { + return instance[prop]; + })(); + } + } + }; + var overwrite = function (connection, Constructor, prototype, statics) { + var prop; + for (prop in prototype) { + Constructor.prototype[prop] = prototype[prop](Constructor.prototype[prop], connection); + } + if (statics) { + for (prop in statics) { + Constructor[prop] = statics[prop](Constructor[prop], connection); + } + } + }; +}); +/*can-connect@1.0.20#can/ref/ref*/ +define('can-connect/can/ref/ref', function (require, exports, module) { + var connect = require('can-connect'); + var getIdProps = require('can-connect/helpers/get-id-props'); + var WeakReferenceMap = require('can-connect/helpers/weak-reference-map'); + var Observation = require('can-observation'); + var constructorStore = require('can-connect/constructor/store/store'); + var define = require('can-define'); + var makeRef = function (connection) { + var idProp = getIdProps(connection)[0]; + var Ref = function (id, value) { + if (Ref.store.has(id)) { + return Ref.store.get(id); + } + this[idProp] = id; + if (value) { + this._value = connection.hydrateInstance(value); + } + if (constructorStore.requests.count() > 0) { + if (!Ref._requestInstances[id]) { + Ref.store.addReference(id, this); + Ref._requestInstances[id] = this; + } + } + }; + Ref.store = new WeakReferenceMap(); + Ref._requestInstances = {}; + Ref.type = function (ref) { + if (ref && typeof ref !== 'object') { + return new Ref(ref); + } else { + return new Ref(ref[idProp], ref); + } + }; + var defs = { + promise: { + get: function () { + if (this._value) { + return Promise.resolve(this._value); + } else { + var props = {}; + props[idProp] = this[idProp]; + return connection.Map.get(props); + } + } + }, + _state: { + get: function (lastSet, resolve) { + if (resolve) { + this.promise.then(function () { + resolve('resolved'); + }, function () { + resolve('rejected'); + }); + } + return 'pending'; + } + }, + value: { + get: function (lastSet, resolve) { + if (this._value) { + return this._value; + } else if (resolve) { + this.promise.then(function (value) { + resolve(value); + }); + } + } + }, + reason: { + get: function (lastSet, resolve) { + if (this._value) { + return undefined; + } else { + this.promise.catch(function (value) { + resolve(value); + }); + } + } + } + }; + defs[idProp] = { + type: '*', + set: function () { + this._value = undefined; + } + }; + define(Ref.prototype, defs); + Ref.prototype.unobservedId = Observation.ignore(function () { + return this[idProp]; + }); + Ref.prototype.isResolved = function () { + return !!this._value || this._state === 'resolved'; + }; + Ref.prototype.isRejected = function () { + return this._state === 'rejected'; + }; + Ref.prototype.isPending = function () { + return !this._value && (this._state !== 'resolved' || this._state !== 'rejected'); + }; + Ref.prototype.serialize = function () { + return this[idProp]; + }; + var baseEventSetup = Ref.prototype._eventSetup; + Ref.prototype._eventSetup = function () { + Ref.store.addReference(this.unobservedId(), this); + return baseEventSetup.apply(this, arguments); + }; + var baseTeardown = Ref.prototype._eventTeardown; + Ref.prototype._eventTeardown = function () { + Ref.store.deleteReference(this.unobservedId(), this); + return baseTeardown.apply(this, arguments); + }; + constructorStore.requests.on('end', function () { + for (var id in Ref._requestInstances) { + Ref.store.deleteReference(id); + } + Ref._requestInstances = {}; + }); + return Ref; + }; + module.exports = connect.behavior('can/ref', function (baseConnection) { + return { + init: function () { + baseConnection.init.apply(this, arguments); + this.Map.Ref = makeRef(this); + } + }; + }); +}); +/*can-connect@1.0.20#can/super-map/super-map*/ +define('can-connect/can/super-map/super-map', function (require, exports, module) { + var connect = require('can-connect'); + var constructor = require('can-connect/constructor/constructor'); + var canMap = require('can-connect/can/map/map'); + var canRef = require('can-connect/can/ref/ref'); + var constructorStore = require('can-connect/constructor/store/store'); + var dataCallbacks = require('can-connect/data/callbacks/callbacks'); + var callbacksCache = require('can-connect/data/callbacks-cache/callbacks-cache'); + var combineRequests = require('can-connect/data/combine-requests/combine-requests'); + var localCache = require('can-connect/data/localstorage-cache/localstorage-cache'); + var dataParse = require('can-connect/data/parse/parse'); + var dataUrl = require('can-connect/data/url/url'); + var fallThroughCache = require('can-connect/fall-through-cache/fall-through-cache'); + var realTime = require('can-connect/real-time/real-time'); + var callbacksOnce = require('can-connect/constructor/callbacks-once/callbacks-once'); + var $ = require('jquery'); + connect.superMap = function (options) { + var behaviors = [ + constructor, + canMap, + canRef, + constructorStore, + dataCallbacks, + combineRequests, + dataParse, + dataUrl, + realTime, + callbacksOnce + ]; + if (typeof localStorage !== 'undefined') { + if (!options.cacheConnection) { + options.cacheConnection = connect([localCache], { + name: options.name + 'Cache', + idProp: options.idProp, + algebra: options.algebra + }); + } + behaviors.push(callbacksCache, fallThroughCache); + } + if ($ && $.ajax) { + options.ajax = $.ajax; + } + return connect(behaviors, options); + }; + module.exports = connect.superMap; +}); +/*can-connect@1.0.20#can/tag/tag*/ +define('can-connect/can/tag/tag', function (require, exports, module) { + require('can-stache-bindings'); + var connect = require('can-connect'); + var compute = require('can-compute'); + var expression = require('can-stache/src/expression'); + var viewCallbacks = require('can-view-callbacks'); + var Observation = require('can-observation'); + var nodeLists = require('can-view-nodelist'); + var canEvent = require('can-event'); + var each = require('can-util/js/each/each'); + var domMutate = require('can-util/dom/mutate/mutate'); + var domData = require('can-util/dom/data/data'); + require('can-util/dom/events/removed/removed'); + var convertToValue = function (arg) { + if (typeof arg === 'function') { + return convertToValue(arg()); + } else { + return arg; + } + }; + connect.tag = function (tagName, connection) { + var removeBrackets = function (value, open, close) { + open = open || '{'; + close = close || '}'; + if (value[0] === open && value[value.length - 1] === close) { + return value.substr(1, value.length - 2); + } + return value; + }; + viewCallbacks.tag(tagName, function (el, tagData) { + var getList = el.getAttribute('getList') || el.getAttribute('get-list'); + var getInstance = el.getAttribute('get'); + var attrValue = getList || getInstance; + var method = getList ? 'getList' : 'get'; + var attrInfo = expression.parse('tmp(' + removeBrackets(attrValue) + ')', { baseMethodType: 'Call' }); + var addedToPageData = false; + var addToPageData = Observation.ignore(function (set, promise) { + if (!addedToPageData) { + var root = tagData.scope.peek('%root') || tagData.scope.peek('@root'); + if (root && root.pageData) { + if (method === 'get') { + set = connection.id(set); + } + root.pageData(connection.name, set, promise); + } + } + addedToPageData = true; + }); + var request = compute(function () { + var hash = {}; + if (typeof attrInfo.hash === 'object') { + each(attrInfo.hash, function (val, key) { + if (val && val.hasOwnProperty('get')) { + hash[key] = tagData.scope.read(val.get, {}).value; + } else { + hash[key] = val; + } + }); + } else if (typeof attrInfo.hash === 'function') { + var getHash = attrInfo.hash(tagData.scope, tagData.options, {}); + each(getHash(), function (val, key) { + hash[key] = convertToValue(val); + }); + } else { + hash = attrInfo.argExprs.length ? attrInfo.argExprs[0].value(tagData.scope, tagData.options)() : {}; + } + var promise = connection[method](hash); + addToPageData(hash, promise); + return promise; + }); + domData.set.call(el, 'viewModel', request); + var nodeList = nodeLists.register([], undefined, tagData.parentNodeList || true); + var frag = tagData.subtemplate ? tagData.subtemplate(tagData.scope.add(request), tagData.options, nodeList) : document.createDocumentFragment(); + domMutate.appendChild.call(el, frag); + nodeLists.update(nodeList, el.childNodes); + canEvent.one.call(el, 'removed', function () { + nodeLists.unregister(nodeList); + }); + }); + }; + module.exports = connect.tag; +}); +/*can-connect@1.0.20#can/base-map/base-map*/ +define('can-connect/can/base-map/base-map', function (require, exports, module) { + var connect = require('can-connect'); + var constructor = require('can-connect/constructor/constructor'); + var canMap = require('can-connect/can/map/map'); + var canRef = require('can-connect/can/ref/ref'); + var constructorStore = require('can-connect/constructor/store/store'); + var dataCallbacks = require('can-connect/data/callbacks/callbacks'); + var callbacksCache = require('can-connect/data/callbacks-cache/callbacks-cache'); + var dataParse = require('can-connect/data/parse/parse'); + var dataUrl = require('can-connect/data/url/url'); + var realTime = require('can-connect/real-time/real-time'); + var callbacksOnce = require('can-connect/constructor/callbacks-once/callbacks-once'); + var $ = require('jquery'); + connect.baseMap = function (options) { + var behaviors = [ + constructor, + canMap, + canRef, + constructorStore, + dataCallbacks, + dataParse, + dataUrl, + realTime, + callbacksOnce + ]; + if ($ && $.ajax) { + options.ajax = $.ajax; + } + return connect(behaviors, options); + }; + module.exports = connect.baseMap; +}); +/*can-connect@1.0.20#all*/ +define('can-connect/all', function (require, exports, module) { + var connect = require('can-connect'); + connect.cacheRequests = require('can-connect/cache-requests/cache-requests'); + connect.constructor = require('can-connect/constructor/constructor'); + connect.constructorCallbacksOnce = require('can-connect/constructor/callbacks-once/callbacks-once'); + connect.constructorStore = require('can-connect/constructor/store/store'); + connect.dataCallbacks = require('can-connect/data/callbacks/callbacks'); + connect.dataCallbacksCache = require('can-connect/data/callbacks-cache/callbacks-cache'); + connect.dataCombineRequests = require('can-connect/data/combine-requests/combine-requests'); + connect.dataLocalStorageCache = require('can-connect/data/localstorage-cache/localstorage-cache'); + connect.dataMemoryCache = require('can-connect/data/memory-cache/memory-cache'); + connect.dataParse = require('can-connect/data/parse/parse'); + connect.dataUrl = require('can-connect/data/url/url'); + connect.fallThroughCache = require('can-connect/fall-through-cache/fall-through-cache'); + connect.realTime = require('can-connect/real-time/real-time'); + connect.superMap = require('can-connect/can/super-map/super-map'); + connect.tag = require('can-connect/can/tag/tag'); + connect.baseMap = require('can-connect/can/base-map/base-map'); + module.exports = connect; +}); +/*[global-shim-end]*/ +(function(){ // jshint ignore:line + window._define = window.define; + window.define = window.define.orig; +} +)(); +//# sourceMappingURL=all.js.map \ No newline at end of file diff --git a/dist/global/can-connect.js.map b/dist/global/can-connect.js.map new file mode 100644 index 00000000..37ccccbc --- /dev/null +++ b/dist/global/can-connect.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../connect.js","../../../base/base.js","../../../can-connect.js","../../../helpers/get-items.js","../../../cache-requests/cache-requests.js","../../../helpers/weak-reference-map.js","../../../helpers/overwrite.js","../../../helpers/id-merge.js","../../../constructor/constructor.js","../../../helpers/sorted-set-json.js","../../../constructor/callbacks-once/callbacks-once.js","../../../constructor/store/store.js","../../../data/callbacks/callbacks.js","../../../data/callbacks-cache/callbacks-cache.js","../../../helpers/deferred.js","../../../data/combine-requests/combine-requests.js","../../../helpers/set-add.js","../../../helpers/get-index-by-id.js","../../../data/localstorage-cache/localstorage-cache.js","../../../helpers/clone-data.js","../../../data/memory-cache/memory-cache.js","../../../data/parse/parse.js","../../../helpers/get-id-props.js","../../../data/url/url.js","../../../fall-through-cache/fall-through-cache.js","../../../real-time/real-time.js","../../../can/map/map.js","../../../can/ref/ref.js","../../../can/super-map/super-map.js","../../../can/tag/tag.js","../../../can/base-map/base-map.js","../../../all.js"],"names":["assign","require","connect","behaviors","options","map","behavior","index","sortedIndex","order","indexOf","behaviorsMap","isBehavior","behaviorName","originalIndex","sort","b1","b2","b","base","forEach","behave","init","name","undefined","behaviorMixin","Behavior","prototype","newBehavior","res","apply","arguments","__behaviorName","module","exports","baseConnection","id","instance","ids","algebra","clauses","prop","push","idProp","length","join","listSet","list","listSetProp","ns","isArray","data","getItems","canSet","getDiff","params","availableSets","minSets","self","call","set","curSets","difference","needed","cached","intersection","count","subset","getUnion","diff","neededItems","cachedItems","getListData","cacheConnection","getSets","then","sets","updateListData","cachedPromise","needsPromise","savedPromise","combinedPromise","Promise","all","result","WeakReferenceMap","has","key","addReference","item","referenceCount","deleteReference","get","cb","d","s","update","make","listIndex","updateIndex","listItem","updateItem","lID","uID","splice","concat","slice","makeArray","overwrite","idMerge","cidStore","_cid","getData","hydrateInstance","getList","hydrateList","listData","arr","i","copyMetadata","props","save","serialized","serializeInstance","cid","createData","createdInstance","updateData","updatedInstance","destroy","destroyData","destroyedInstance","updatedList","instanceList","bind","serializeList","isNew","attr","keys","Object","sorted","JSON","stringify","sortedSetJSON","callbacks","lastSerialized","getInstanceMetaData","serialize","addInstanceMetaData","canEvent","pendingRequests","noRequestsTimer","requests","increment","connection","clearTimeout","decrement","setTimeout","dispatch","constructorStore","instanceStore","listStore","_requestInstances","_requestLists","_finishedRequest","addInstanceReference","value","deleteInstanceMetaData","deleteInstanceReference","addListReference","deleteListReference","hydratedInstance","storeInstance","hydratedList","storeList","promise","instances","updating","each","pairs","callbackName","createdData","updatedData","destroyedData","cacheCallback","dataCallbackName","def","resolve","reject","deepAssign","makeDeferred","unionPendingRequests","pReq1","pReq2","combineData","current","doubleLoop","start","pendingRequest","iterate","combined","union","getSubset","unionSet","time","combineDataPromise","combinedData","combinedSet","deferred","pending","err","j","setItems","items","copy","connId","setAdd","_instances","getSetData","parse","localStorage","getItem","setKey","_getSets","setData","getInstance","updateInstance","setItem","getInstances","removeSet","removeItem","updateSets","updateSet","setDatum","newSet","newSetKey","addSet","_eachSet","loop","clear","len","getListDataSync","message","error","checkSet","__getListData","localData","cloneData","_sets","setsData","noUpdate","oldSetKey","source","_getListData","clonedData","getSet","getObject","parseListData","responseData","parseListProp","Error","parseInstanceData","parseInstanceProp","parseFunction","ajax","string","getIdProps","dev","makePromise","reqOptions","url","makeAjax","type","findContentType","resource","idProps","createURLFromResource","includeData","contentType","acceptableType","ajaxOb","parts","split","pop","sub","encodeJSON","dataType","replace","_getHydrateListCallbacks","shift","_getHydrateList","callback","e","console","log","_getMakeInstanceCallbacks","_getMakeInstance","instanceData","instanceData2","canDev","createInstance","create","destroyInstance","canBatch","Observation","isPlainObject","types","isFunction","setExpando","_data","getExpando","Map","DefaultMap","extend","List","DefaultList","mapOverwrites","mapStaticOverwrites","listPrototypeOverwrites","listStaticOverwrites","readObservabe","_Map","_List","val","__listSet","stop","done","funcName","constructor","removeAttr","target","callCanReadingOnIdRead","findAll","findOne","_eventSetup","_eventTeardown","___set","_bindings","isSaving","add","isDestroying","success","setup","isPromise","_bubbleRule","eventName","bubbleRules","__get","ignore","Constructor","statics","define","makeRef","Ref","store","_value","ref","defs","_state","lastSet","reason","catch","unobservedId","isResolved","isRejected","isPending","baseEventSetup","baseTeardown","on","canMap","canRef","dataCallbacks","callbacksCache","combineRequests","localCache","dataParse","dataUrl","fallThroughCache","realTime","callbacksOnce","$","superMap","compute","expression","viewCallbacks","nodeLists","domMutate","domData","convertToValue","arg","tag","tagName","removeBrackets","open","close","substr","el","tagData","getAttribute","attrValue","method","attrInfo","baseMethodType","addedToPageData","addToPageData","root","scope","peek","pageData","request","hash","hasOwnProperty","read","getHash","argExprs","nodeList","register","parentNodeList","frag","subtemplate","document","createDocumentFragment","appendChild","childNodes","one","unregister","baseMap","cacheRequests","constructorCallbacksOnce","dataCallbacksCache","dataCombineRequests","dataLocalStorageCache","dataMemoryCache"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAAA,IAAIA,MAAA,GAASC,OAAA,CAAQ,2BAAR,CAAb,C;IAOA,IAAIC,OAAA,GAAU,UAASC,SAAT,EAAoBC,OAApB,EAA4B;AAAA,QAEzCD,SAAA,GAAYA,SAAA,CAAUE,GAAV,CAAc,UAASC,QAAT,EAAmBC,KAAnB,EAAyB;AAAA,YAClD,IAAIC,WAAA,GAAc,CAAC,CAAnB,CADkD;AAAA,YAEl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