angular.js-server-ng-cache
Version:
A REST API and template caching for server side rendering with angular.js-server
1 lines • 24.7 kB
Source Map (JSON)
{"version":3,"sources":["webpack:///webpack/universalModuleDefinition?5ca6","webpack:///angular.js-server-ng-cache.min.js","webpack:///webpack/bootstrap 55219ab2712318fbcda6?7e49","webpack:///./src/index.js?9552","webpack:///./src/provider/ngCacheFactory.js?50d3"],"names":["root","factory","exports","module","define","amd","this","modules","__webpack_require__","moduleId","installedModules","id","loaded","call","m","c","p","_ngCacheFactory","angular","provider","$CacheFactoryProvider","$TemplateCacheProvider","constant","defaultCache","config","$windowProvider","$httpProvider","$cacheFactoryProvider","serverCacheConfig","defaults","cache","$window","$get","onServer","$angularServerCache","importAll","addEventListener","remove","caches","getCaches","cacheId","Error","exportAll","_caches","i","removeAll","cacheData","cacheFactory","info","infoAll","options","refresh","entry","freshEnd","staleEnd","n","link","nextEntry","prevEntry","size","stats","Object","assign","data","create","capacity","Number","MAX_VALUE","lruHash","put","key","value","lruEntry","export","import","get","destroy","keys","getOwnPropertyNames","$cacheFactory","defineProperty"],"mappings":";;;;;CAAA,SAAAA,EAAAC,GACA,gBAAAC,UAAA,gBAAAC,QACAA,OAAAD,QAAAD,IACA,kBAAAG,gBAAAC,IACAD,UAAAH,GACA,gBAAAC,SACAA,QAAA,8BAAAD,IAEAD,EAAA,8BAAAC,KACCK,KAAA,WACD,MCAgB,UAAUC,GCN1B,QAAAC,GAAAC,GAGA,GAAAC,EAAAD,GACA,MAAAC,GAAAD,GAAAP,OAGA,IAAAC,GAAAO,EAAAD,IACAP,WACAS,GAAAF,EACAG,QAAA,EAUA,OANAL,GAAAE,GAAAI,KAAAV,EAAAD,QAAAC,IAAAD,QAAAM,GAGAL,EAAAS,QAAA,EAGAT,EAAAD,QAvBA,GAAAQ,KAqCA,OATAF,GAAAM,EAAAP,EAGAC,EAAAO,EAAAL,EAGAF,EAAAQ,EAAA,GAGAR,EAAA,KDgBM,SAASL,EAAQD,EAASM,GAE/B,YExDD,IAAAS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mB,EAAKnB,KAIzB+B,IAAK,SAASL,GACV,GAAIL,EAAWC,OAAOC,UAAW,CAC7B,GAAIK,GAAWJ,EAAQE,EAEvB,KAAKE,EAAU,MAEfrB,GAAQqB,GAGZ,MAAOT,GAAKO,IAGhBjC,OAAQ,SAASiC,GACb,GAAIL,EAAWC,OAAOC,UAAW,CAC7B,GAAIK,GAAWJ,EAAQE,EAEvB,KAAKE,EAAU,MAEXA,KAAanB,IAAUA,EAAWmB,EAASxD,GAC3CwD,IAAalB,IAAUA,EAAWkB,EAASjB,GAC/CC,EAAKgB,EAASjB,EAAEiB,EAASxD,SAElBoD,GAAQE,GAGbA,IAAOP,WAENA,GAAKO,GACZX,MAGJd,UAAW,WACPkB,EAAOF,OAAOG,OAAO,MACrBL,EAAO,EACPS,EAAUP,OAAOG,OAAO,MACxBX,EAAWC,EAAW,MAG1BsB,QAAS,WACLb,EAAO,KACPH,EAAQ,KACRQ,EAAU,WACH9B,GAAOE,IAGlBQ,KAAM,WACF,MAAOa,QAAOC,UAAWF,GAAQD,KAAMA,KAG3CkB,KAAM,WACF,MAAOhB,QAAOiB,oBAAoBf,KAyC9C,MARAhB,GAAaC,KAAO,WAChB,GAAIA,KACJ,KAAK,GAAIR,KAAYF,GACjBU,EAAKR,GAAWF,EAAOE,GAASQ,MAEpC,OAAOA,IAGJD,GAIR,QAAS1B,KACZf,KAAK0B,MAAQ,gBAAiB,SAAS+C,GACnC,MAAOA,GAAc,eHjI5BlB,OAAOmB,eAAe9E,EAAS,cAC3BqE,OAAO,IAEXrE,EG1FekB,wBH2FflB,EG2HemB","file":"angular.js-server-ng-cache.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"angular.js-server-ng-cache\"] = factory();\n\telse\n\t\troot[\"angular.js-server-ng-cache\"] = factory();\n})(this, function() {\nreturn \n\n\n/** WEBPACK FOOTER **\n ** webpack/universalModuleDefinition\n **/","(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"angular.js-server-ng-cache\"] = factory();\n\telse\n\t\troot[\"angular.js-server-ng-cache\"] = factory();\n})(this, function() {\nreturn /******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId])\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\texports: {},\n/******/ \t\t\tid: moduleId,\n/******/ \t\t\tloaded: false\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.loaded = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(0);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar _ngCacheFactory = __webpack_require__(1);\n\t\n\tangular.module('server-cache', []).provider('$cacheFactory', _ngCacheFactory.$CacheFactoryProvider).provider('$templateCache', _ngCacheFactory.$TemplateCacheProvider).constant('serverCacheConfig', { defaultCache: true }).config(function ($windowProvider, $httpProvider, $cacheFactoryProvider, serverCacheConfig) {\n\t\n\t $httpProvider.defaults.cache = true;\n\t\n\t var $window = $windowProvider.$get();\n\t\n\t if ($window.onServer && $window.onServer === true) {\n\t $window.$cacheFactoryProvider = $cacheFactoryProvider;\n\t }\n\t\n\t if (typeof $window.onServer === 'undefined' && typeof $window.$angularServerCache !== 'undefined') {\n\t\n\t $cacheFactoryProvider.importAll($window.$angularServerCache);\n\t\n\t $window.addEventListener('StackQueueEmpty', function () {\n\t $cacheFactoryProvider.remove('$http');\n\t $httpProvider.defaults.cache = serverCacheConfig.defaultCache;\n\t });\n\t }\n\t});\n\n/***/ },\n/* 1 */\n/***/ function(module, exports) {\n\n\t'use strict';\n\t\n\tObject.defineProperty(exports, \"__esModule\", {\n\t value: true\n\t});\n\texports.$CacheFactoryProvider = $CacheFactoryProvider;\n\texports.$TemplateCacheProvider = $TemplateCacheProvider;\n\tfunction $CacheFactoryProvider() {\n\t\n\t var caches = {};\n\t\n\t this.getCaches = function () {\n\t return caches;\n\t };\n\t\n\t this.export = function (cacheId) {\n\t if (typeof cache[cacheId] === 'undefined') {\n\t throw new Error('$cacheFactory - iid - CacheId ' + cacheId + ' is not defined!');\n\t }\n\t return caches[cacheId].export();\n\t };\n\t\n\t this.exportAll = function () {\n\t var _caches = {};\n\t for (var i in caches) {\n\t _caches[i] = caches[i].export();\n\t }\n\t return _caches;\n\t };\n\t\n\t this.remove = function (cacheId) {\n\t if (typeof caches[cacheId] !== 'undefined') {\n\t delete caches[cacheId];\n\t }\n\t };\n\t\n\t this.removeAll = function () {\n\t caches = {};\n\t };\n\t\n\t this.importAll = function (cacheData) {\n\t\n\t var cacheFactory = this.$get();\n\t for (var i in cacheData) {\n\t if (typeof caches[i] === 'undefined') {\n\t caches[i] = cacheFactory(i);\n\t }\n\t caches[i].import(cacheData[i]);\n\t }\n\t };\n\t\n\t this.import = function (cacheId, cacheData) {\n\t\n\t var cacheFactory = this.$get();\n\t if (typeof caches[cacheId] === 'undefined') {\n\t caches[cacheId] = cacheFactory(i);\n\t }\n\t\n\t caches[cacheId].import(cacheData);\n\t };\n\t\n\t this.info = function (cacheId) {\n\t if (typeof caches[cacheId] === 'undefined') {\n\t throw new Error('$cacheFactory - iid - CacheId ' + cacheId + ' is not defined!');\n\t }\n\t return caches[cacheId].info();\n\t };\n\t\n\t this.infoAll = function () {\n\t var info = {};\n\t for (var cacheId in caches) {\n\t info[cacheId] = caches[cacheId].info();\n\t }\n\t return info;\n\t };\n\t\n\t this.$get = function () {\n\t\n\t function cacheFactory(cacheId, options) {\n\t if (cacheId in caches) {\n\t return caches[cacheId];\n\t throw new Error('$cacheFactory - iid - CacheId ' + cacheId + ' is already taken!');\n\t }\n\t\n\t var size = 0,\n\t stats = Object.assign({}, options, { id: cacheId }),\n\t data = Object.create(null),\n\t capacity = options && options.capacity || Number.MAX_VALUE,\n\t lruHash = Object.create(null),\n\t freshEnd = null,\n\t staleEnd = null;\n\t\n\t return caches[cacheId] = {\n\t\n\t put: function put(key, value) {\n\t if (typeof value === 'undefined') return;\n\t if (capacity < Number.MAX_VALUE) {\n\t var lruEntry = lruHash[key] || (lruHash[key] = { key: key });\n\t refresh(lruEntry);\n\t }\n\t\n\t if (!(key in data)) size++;\n\t data[key] = value;\n\t\n\t if (size > capacity) {\n\t this.remove(staleEnd.key);\n\t }\n\t\n\t return value;\n\t },\n\t\n\t export: function _export() {\n\t return data;\n\t },\n\t\n\t import: function _import(data) {\n\t size = 0;\n\t lruHash = Object.create(null);\n\t freshEnd = null;\n\t staleEnd = null;\n\t for (var i in data) {\n\t this.put(i, data[i]);\n\t }\n\t },\n\t\n\t get: function get(key) {\n\t if (capacity < Number.MAX_VALUE) {\n\t var lruEntry = lruHash[key];\n\t\n\t if (!lruEntry) return;\n\t\n\t refresh(lruEntry);\n\t }\n\t\n\t return data[key];\n\t },\n\t\n\t remove: function remove(key) {\n\t if (capacity < Number.MAX_VALUE) {\n\t var lruEntry = lruHash[key];\n\t\n\t if (!lruEntry) return;\n\t\n\t if (lruEntry === freshEnd) freshEnd = lruEntry.p;\n\t if (lruEntry === staleEnd) staleEnd = lruEntry.n;\n\t link(lruEntry.n, lruEntry.p);\n\t\n\t delete lruHash[key];\n\t }\n\t\n\t if (!(key in data)) return;\n\t\n\t delete data[key];\n\t size--;\n\t },\n\t\n\t removeAll: function removeAll() {\n\t data = Object.create(null);\n\t size = 0;\n\t lruHash = Object.create(null);\n\t freshEnd = staleEnd = null;\n\t },\n\t\n\t destroy: function destroy() {\n\t data = null;\n\t stats = null;\n\t lruHash = null;\n\t delete caches[cacheId];\n\t },\n\t\n\t info: function info() {\n\t return Object.assign({}, stats, { size: size });\n\t },\n\t\n\t keys: function keys() {\n\t return Object.getOwnPropertyNames(data);\n\t }\n\t };\n\t\n\t /**\n\t * makes the `entry` the freshEnd of the LRU linked list\n\t */\n\t function refresh(entry) {\n\t if (entry !== freshEnd) {\n\t if (!staleEnd) {\n\t staleEnd = entry;\n\t } else if (staleEnd === entry) {\n\t staleEnd = entry.n;\n\t }\n\t\n\t link(entry.n, entry.p);\n\t link(entry, freshEnd);\n\t freshEnd = entry;\n\t freshEnd.n = null;\n\t }\n\t }\n\t\n\t /**\n\t * bidirectionally links two entries of the LRU linked list\n\t */\n\t function link(nextEntry, prevEntry) {\n\t if (nextEntry !== prevEntry) {\n\t if (nextEntry) nextEntry.p = prevEntry; //p stands for previous, 'prev' didn't minify\n\t if (prevEntry) prevEntry.n = nextEntry; //n stands for next, 'next' didn't minify\n\t }\n\t }\n\t }\n\t\n\t cacheFactory.info = function () {\n\t var info = {};\n\t for (var cacheId in caches) {\n\t info[cacheId] = caches[cacheId].info();\n\t }\n\t return info;\n\t };\n\t\n\t return cacheFactory;\n\t };\n\t}\n\t\n\tfunction $TemplateCacheProvider() {\n\t this.$get = ['$cacheFactory', function ($cacheFactory) {\n\t return $cacheFactory('templates');\n\t }];\n\t}\n\n/***/ }\n/******/ ])\n});\n;\n\n\n/** WEBPACK FOOTER **\n ** angular.js-server-ng-cache.min.js\n **/"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n/** WEBPACK FOOTER **\n ** webpack/bootstrap 55219ab2712318fbcda6\n **/","import { $CacheFactoryProvider, $TemplateCacheProvider } from './provider/ngCacheFactory';\n\n\nangular.module('server-cache', [])\n .provider('$cacheFactory', $CacheFactoryProvider)\n .provider('$templateCache', $TemplateCacheProvider)\n .constant('serverCacheConfig', {defaultCache: true})\n .config(function($windowProvider, $httpProvider, $cacheFactoryProvider, serverCacheConfig) {\n\n $httpProvider.defaults.cache = true;\n\n var $window = $windowProvider.$get();\n\n if ($window.onServer && $window.onServer === true) {\n $window.$cacheFactoryProvider = $cacheFactoryProvider;\n }\n\n if (typeof $window.onServer === 'undefined' && typeof $window.$angularServerCache !== 'undefined') {\n\n $cacheFactoryProvider.importAll($window.$angularServerCache);\n\n $window.addEventListener('StackQueueEmpty', function() {\n $cacheFactoryProvider.remove('$http');\n $httpProvider.defaults.cache = serverCacheConfig.defaultCache;\n });\n }\n });\n\n\n/** WEBPACK FOOTER **\n ** ./src/index.js\n **/","export function $CacheFactoryProvider() {\n\n var caches = {};\n\n this.getCaches = function() {\n return caches;\n };\n\n this.export = function(cacheId) {\n if (typeof cache[cacheId] === 'undefined') {\n throw new Error('$cacheFactory - iid - CacheId '+cacheId+' is not defined!');\n }\n return caches[cacheId].export();\n };\n\n this.exportAll = function() {\n var _caches = {};\n for(var i in caches) {\n _caches[i] = caches[i].export();\n }\n return _caches;\n };\n\n this.remove = function(cacheId) {\n if (typeof caches[cacheId] !== 'undefined') {\n delete caches[cacheId];\n }\n };\n\n this.removeAll = function() {\n caches = {};\n };\n\n this.importAll = function(cacheData) {\n\n var cacheFactory = this.$get();\n for(var i in cacheData) {\n if(typeof caches[i] === 'undefined') {\n caches[i] = cacheFactory(i);\n }\n caches[i].import(cacheData[i]);\n }\n };\n\n this.import = function(cacheId, cacheData) {\n\n var cacheFactory = this.$get();\n if(typeof caches[cacheId] === 'undefined') {\n caches[cacheId] = cacheFactory(i);\n }\n\n caches[cacheId].import(cacheData);\n };\n\n this.info = function(cacheId) {\n if(typeof caches[cacheId] === 'undefined') {\n throw new Error('$cacheFactory - iid - CacheId '+cacheId+' is not defined!');\n }\n return caches[cacheId].info();\n };\n\n this.infoAll = function() {\n var info = {};\n for (var cacheId in caches) {\n info[cacheId] = caches[cacheId].info();\n }\n return info;\n };\n\n this.$get = function() {\n \n function cacheFactory(cacheId, options) {\n if (cacheId in caches) {\n return caches[cacheId];\n throw new Error('$cacheFactory - iid - CacheId '+cacheId+' is already taken!');\n }\n\n var size = 0,\n stats = Object.assign({}, options, {id: cacheId}),\n data = Object.create(null),\n capacity = (options && options.capacity) || Number.MAX_VALUE,\n lruHash = Object.create(null),\n freshEnd = null,\n staleEnd = null;\n\n\n return caches[cacheId] = {\n\n put: function(key, value) {\n if ( typeof value === 'undefined') return;\n if (capacity < Number.MAX_VALUE) {\n var lruEntry = lruHash[key] || (lruHash[key] = {key: key});\n refresh(lruEntry);\n }\n\n if (!(key in data)) size++;\n data[key] = value;\n\n if (size > capacity) {\n this.remove(staleEnd.key);\n }\n\n return value;\n },\n\n export: function() {\n return data;\n },\n\n import: function(data) {\n size = 0;\n lruHash = Object.create(null);\n freshEnd = null;\n staleEnd = null;\n for(var i in data) {\n this.put(i, data[i]);\n }\n },\n\n get: function(key) {\n if (capacity < Number.MAX_VALUE) {\n var lruEntry = lruHash[key];\n\n if (!lruEntry) return;\n\n refresh(lruEntry);\n }\n\n return data[key];\n },\n\n remove: function(key) {\n if (capacity < Number.MAX_VALUE) {\n var lruEntry = lruHash[key];\n\n if (!lruEntry) return;\n\n if (lruEntry === freshEnd) freshEnd = lruEntry.p;\n if (lruEntry === staleEnd) staleEnd = lruEntry.n;\n link(lruEntry.n,lruEntry.p);\n\n delete lruHash[key];\n }\n\n if (!(key in data)) return;\n\n delete data[key];\n size--;\n },\n\n removeAll: function() {\n data = Object.create(null);\n size = 0;\n lruHash = Object.create(null);\n freshEnd = staleEnd = null;\n },\n\n destroy: function() {\n data = null;\n stats = null;\n lruHash = null;\n delete caches[cacheId];\n },\n\n info: function() {\n return Object.assign({}, stats, {size: size});\n },\n\n keys: function() {\n return Object.getOwnPropertyNames(data);\n }\n };\n\n /**\n * makes the `entry` the freshEnd of the LRU linked list\n */\n function refresh(entry) {\n if (entry !== freshEnd) {\n if (!staleEnd) {\n staleEnd = entry;\n } else if (staleEnd === entry) {\n staleEnd = entry.n;\n }\n\n link(entry.n, entry.p);\n link(entry, freshEnd);\n freshEnd = entry;\n freshEnd.n = null;\n }\n }\n\n /**\n * bidirectionally links two entries of the LRU linked list\n */\n function link(nextEntry, prevEntry) {\n if (nextEntry !== prevEntry) {\n if (nextEntry) nextEntry.p = prevEntry; //p stands for previous, 'prev' didn't minify\n if (prevEntry) prevEntry.n = nextEntry; //n stands for next, 'next' didn't minify\n }\n }\n }\n\n cacheFactory.info = function() {\n var info = {};\n for (var cacheId in caches) {\n info[cacheId] = caches[cacheId].info();\n }\n return info;\n };\n\n return cacheFactory;\n };\n}\n\nexport function $TemplateCacheProvider(){\n this.$get = ['$cacheFactory', function($cacheFactory) {\n return $cacheFactory('templates');\n }];\n}\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/provider/ngCacheFactory.js\n **/"],"sourceRoot":""}