You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

1 lines
25 KiB

{"version":3,"file":"index.js","sources":["../src/task-proxy.js","../src/index.js"],"sourcesContent":["import EventEmitter from 'events';\nimport crypto from 'crypto';\nimport File from 'vinyl';\nimport pick from 'object.pick';\n\nconst whitespaces = 2,\n\teventListenersCount = 3;\n\nfunction makeHash(key) {\n\treturn crypto.createHash('md5').update(key).digest('hex');\n}\n\nexport default class TaskProxy {\n\n\tconstructor(task, inputOptions) {\n\n\t\tthis.task = task;\n\t\tthis.options = inputOptions;\n\t\tthis._cacheQueue = new Map();\n\t\tthis._removeListeners = [];\n\n\t\tif (task) {\n\t\t\tthis.patchTask();\n\t\t}\n\t}\n\n\tpatchTask() {\n\n\t\tconst { task } = this,\n\t\t\t{ _transform } = task;\n\n\t\ttask._transform = (chunk, encoding, next) => {\n\n\t\t\tReflect.apply(_transform, task, [chunk, encoding, (...args) => {\n\t\t\t\tnext(...args); // eslint-disable-line\n\t\t\t\ttask.emit('gulp-cache:transformed');\n\t\t\t}]);\n\t\t};\n\t}\n\n\tprocessFile(inputFile, signals = new EventEmitter()) {\n\n\t\tprocess.nextTick(() => {\n\t\t\tthis._processFileAsync(inputFile, signals);\n\t\t});\n\n\t\treturn signals;\n\t}\n\n\tasync _processFileAsync(inputFile, signals = new EventEmitter()) {\n\n\t\tconst cached = await this._checkForCachedValue(inputFile);\n\n\t\t// If we found a cached value\n\t\t// The path of the cache key should also be identical to the original one when the file path changed inside the task\n\t\tconst cachedValue = cached.value,\n\t\t\tcachedValueIsEmpty = !Array.isArray(cachedValue) || !cachedValue.length;\n\n\t\tconst cachedValuesWithNormalPaths = cachedValueIsEmpty ? [] : cachedValue.filter(\n\t\t\tfile =>\n\t\t\t\t(!file.gulpCache$filePathChangedInsideTask || file.gulpCache$originalPath === inputFile.path)\n\t\t\t\t&& (!file.gulpCache$fileBaseChangedInsideTask || file.gulpCache$originalBase === inputFile.base)\n\t\t);\n\n\t\tif (cachedValuesWithNormalPaths.length) {\n\n\t\t\tcachedValuesWithNormalPaths.forEach((cachedFile) => {\n\t\t\t\t// Extend the cached value onto the file, but don't overwrite original path info\n\t\t\t\tconst file = new File({\n\t\t\t\t\t// custom properties\n\t\t\t\t\t...cachedFile,\n\t\t\t\t\t// file info\n\t\t\t\t\t...pick(inputFile, ['cwd', 'base', 'stat', 'history', 'path']),\n\t\t\t\t\t// file contents\n\t\t\t\t\tcontents: cachedFile.contents\n\t\t\t\t});\n\n\t\t\t\t// Restore the file path if it was set\n\t\t\t\tif (cachedFile.path && cachedFile.gulpCache$filePathChangedInsideTask) {\n\t\t\t\t\tfile.path = cachedFile.path;\n\t\t\t\t}\n\t\t\t\t// Restore the file base if it was set\n\t\t\t\tif (cachedFile.base && cachedFile.gulpCache$fileBaseChangedInsideTask) {\n\t\t\t\t\tfile.base = cachedFile.base;\n\t\t\t\t}\n\n\t\t\t\tReflect.deleteProperty(file, 'gulpCache$filePathChangedInsideTask');\n\t\t\t\tReflect.deleteProperty(file, 'gulpCache$fileBaseChangedInsideTask');\n\t\t\t\tReflect.deleteProperty(file, 'gulpCache$originalPath');\n\t\t\t\tReflect.deleteProperty(file, 'gulpCache$originalBase');\n\n\t\t\t\tsignals.emit('file', file);\n\t\t\t});\n\n\t\t\tsignals.emit('done');\n\n\t\t\tthis._removeListeners.push(() => {\n\t\t\t\t// Remove all listeners from `signals`\n\t\t\t\tsignals.removeAllListeners();\n\t\t\t});\n\n\t\t\treturn;\n\t\t}\n\n\t\tthis._runProxiedTaskAndQueueCache(inputFile, cached.key, signals);\n\t}\n\n\tasync flush(next) {\n\n\t\tconst { task } = this;\n\n\t\ttry {\n\n\t\t\tif (typeof task._flush == 'function') {\n\t\t\t\ttask._flush(async (...args) => {\n\t\t\t\t\tawait this._flush();\n\t\t\t\t\tnext(...args);\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tawait this._flush();\n\t\t\t\tnext();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t} catch (err) {\n\t\t\tnext(err);\n\t\t\treturn;\n\t\t}\n\t}\n\n\tasync _flush() {\n\n\t\tthis._removeListeners.forEach((remove) => {\n\t\t\tremove();\n\t\t});\n\n\t\tthis._removeListeners = [];\n\n\t\tawait Promise.all(\n\t\t\tArray.from(this._cacheQueue).map(\n\t\t\t\tasync ([cachedKey, files]) =>\n\t\t\t\t\tthis._storeCachedResult(cachedKey, files)\n\t\t\t)\n\t\t);\n\n\t\tthis._cacheQueue = new Map();\n\t}\n\n\tasync removeCachedResult(file) {\n\n\t\tconst cachedKey = await this._getFileKey(file);\n\n\t\treturn this._removeCached(\n\t\t\tthis.options.name,\n\t\t\tcachedKey\n\t\t);\n\t}\n\n\tasync _getFileKey(file) {\n\n\t\tconst { key: getKey } = this.options,\n\t\t\tkey = await getKey(file);\n\n\t\treturn key ? makeHash(key) : key;\n\t}\n\n\tasync _checkForCachedValue(file) {\n\n\t\tconst key = await this._getFileKey(file);\n\n\t\t// If no key returned, bug out early\n\t\tif (!key) {\n\t\t\treturn {\n\t\t\t\tvalue: null,\n\t\t\t\tkey\n\t\t\t};\n\t\t}\n\n\t\tconst { name: cacheName, restore } = this.options;\n\n\t\tconst cached = await this._getCached(cacheName, key);\n\n\t\tif (!cached) {\n\t\t\treturn {\n\t\t\t\tvalue: null,\n\t\t\t\tkey\n\t\t\t};\n\t\t}\n\n\t\tlet parsedContents = null;\n\n\t\ttry {\n\t\t\tparsedContents = JSON.parse(cached.contents);\n\t\t} catch (err) {\n\t\t\tparsedContents = [{ cached: cached.contents }];\n\t\t}\n\n\t\tif (restore) {\n\t\t\tparsedContents = parsedContents.map(\n\t\t\t\t(parsedFile) => {\n\n\t\t\t\t\tconst restoredFile = restore(parsedFile);\n\n\t\t\t\t\t// Force restore service properties\n\t\t\t\t\trestoredFile.gulpCache$filePathChangedInsideTask = parsedFile.gulpCache$filePathChangedInsideTask;\n\t\t\t\t\trestoredFile.gulpCache$fileBaseChangedInsideTask = parsedFile.gulpCache$fileBaseChangedInsideTask;\n\t\t\t\t\trestoredFile.gulpCache$originalPath = parsedFile.gulpCache$originalPath;\n\t\t\t\t\trestoredFile.gulpCache$originalBase = parsedFile.gulpCache$originalBase;\n\n\t\t\t\t\treturn restoredFile;\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\treturn {\n\t\t\tvalue: parsedContents,\n\t\t\tkey\n\t\t};\n\t}\n\n\tasync _getValueFromResult(result) {\n\n\t\tconst { value: getValue } = this.options;\n\n\t\tif (typeof getValue !== 'function') {\n\n\t\t\tif (typeof getValue === 'string') {\n\t\t\t\treturn {\n\t\t\t\t\t[getValue]: result[getValue]\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn getValue;\n\t\t}\n\n\t\treturn getValue(result);\n\t}\n\n\tasync _storeCachedResult(key, result) {\n\n\t\t// If we didn't have a cachedKey, skip caching result\n\t\tif (!key) {\n\t\t\treturn result;\n\t\t}\n\n\t\tconst { options } = this;\n\n\t\tconst files = (await Promise.all(result.map(\n\t\t\tasync ({ file, meta }) => {\n\n\t\t\t\tif (options.success !== true && !(await options.success(file))) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\treturn Object.assign(\n\t\t\t\t\tawait this._getValueFromResult(file),\n\t\t\t\t\tmeta\n\t\t\t\t);\n\t\t\t}\n\t\t))).filter(Boolean);\n\n\t\treturn this._addCached(\n\t\t\tthis.options.name,\n\t\t\tkey,\n\t\t\tJSON.stringify(files, null, whitespaces)\n\t\t);\n\t}\n\n\tasync _queueCache(file, cachedKey, originalBase, originalPath) {\n\n\t\tconst { _cacheQueue } = this;\n\n\t\tconst item = {\n\t\t\tfile: file.clone({ contents: false }),\n\t\t\tmeta: {\n\t\t\t\t// Check if the task changed the file path\n\t\t\t\tgulpCache$filePathChangedInsideTask: file.path !== originalPath,\n\t\t\t\t// Check if the task changed the base path\n\t\t\t\tgulpCache$fileBaseChangedInsideTask: file.base !== originalBase,\n\t\t\t\t// Keep track of the original path\n\t\t\t\tgulpCache$originalPath: originalPath,\n\t\t\t\t// Keep track of the original base\n\t\t\t\tgulpCache$originalBase: originalBase\n\t\t\t}\n\t\t};\n\n\t\tif (_cacheQueue.has(cachedKey)) {\n\t\t\t_cacheQueue.get(cachedKey).push(item);\n\t\t} else {\n\t\t\t_cacheQueue.set(cachedKey, [item]);\n\t\t}\n\t}\n\n\t_runProxiedTaskAndQueueCache(file, cachedKey, signals = new EventEmitter()) {\n\n\t\tconst originalBase = file.base,\n\t\t\toriginalPath = file.path;\n\n\t\tsignals.on('cache', (file) => {\n\t\t\tthis._queueCache(file, cachedKey, originalBase, originalPath);\n\t\t\tsignals.emit('file', file);\n\t\t});\n\n\t\treturn this._runProxiedTask(file, cachedKey, signals);\n\t}\n\n\t_runProxiedTask(file, cachedKey, signals = new EventEmitter()) {\n\n\t\tconst { task } = this,\n\t\t\thasCacheListener = Boolean(signals.listenerCount('cache'));\n\n\t\tfunction onError(err) {\n\t\t\tsignals.emit('error', err);\n\t\t}\n\n\t\tfunction onData(datum) {\n\n\t\t\tif (datum._cachedKey !== cachedKey) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tReflect.deleteProperty(datum, '_cachedKey');\n\n\t\t\tif (hasCacheListener) {\n\t\t\t\tsignals.emit('cache', datum);\n\t\t\t} else {\n\t\t\t\tsignals.emit('file', datum);\n\t\t\t}\n\t\t}\n\n\t\tfunction onTransformed() {\n\t\t\tsignals.emit('done');\n\t\t}\n\n\t\tthis._removeListeners.push(() => {\n\t\t\t// Be good citizens and remove our listeners\n\t\t\ttask.removeListener('error', onError);\n\t\t\ttask.removeListener('gulp-cache:transformed', onTransformed);\n\t\t\ttask.removeListener('data', onData);\n\n\t\t\t// Reduce the maxListeners back down\n\t\t\ttask.setMaxListeners(task._maxListeners - eventListenersCount);\n\n\t\t\t// Remove all listeners from `signals`\n\t\t\tsignals.removeAllListeners();\n\t\t});\n\n\t\t// Bump up max listeners to prevent memory leak warnings\n\t\tconst currMaxListeners = task._maxListeners || 0;\n\n\t\ttask.setMaxListeners(currMaxListeners + eventListenersCount);\n\n\t\ttask.on('data', onData);\n\t\ttask.once('gulp-cache:transformed', onTransformed);\n\t\ttask.once('error', onError);\n\n\t\tfile._cachedKey = cachedKey;\n\n\t\t// Run through the other task and grab output (or error)\n\t\ttask.write(file);\n\n\t\treturn signals;\n\t}\n\n\t/**\n\t * Cache promise wrappers.\n\t */\n\n\t_addCached(...args) {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tthis.options.fileCache.addCached(...args, (err, res) => {\n\n\t\t\t\tif (err) {\n\t\t\t\t\treject(err);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tresolve(res);\n\t\t\t});\n\t\t});\n\t}\n\n\t_getCached(...args) {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tthis.options.fileCache.getCached(...args, (err, res) => {\n\n\t\t\t\tif (err) {\n\t\t\t\t\treject(err);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tresolve(res);\n\t\t\t});\n\t\t});\n\t}\n\n\t_removeCached(...args) {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tthis.options.fileCache.removeCached(...args, (err) => {\n\n\t\t\t\tif (err) {\n\t\t\t\t\treject(err);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tresolve();\n\t\t\t});\n\t\t});\n\t}\n}\n","import PluginError from 'plugin-error';\nimport through from 'through2';\nimport Cache from 'cache-swap';\nimport File from 'vinyl';\nimport pick from 'object.pick';\nimport { version as VERSION } from '../package.json';\nimport TaskProxy from './task-proxy';\n\nconst fileCache = new Cache({ cacheDirName: 'gulp-cache' });\n\nfunction defaultKey(file) {\n\treturn `${VERSION}${file.contents.toString('base64')}`;\n}\n\nfunction defaultRestore(restored) {\n\n\tif (restored.contents) {\n\t\t// Handle node 0.11 buffer to JSON as object with { type: 'buffer', data: [...] }\n\t\tif (restored && restored.contents && Array.isArray(restored.contents.data)) {\n\t\t\trestored.contents = new Buffer(restored.contents.data);\n\t\t} else\n\t\tif (Array.isArray(restored.contents)) {\n\t\t\trestored.contents = new Buffer(restored.contents);\n\t\t} else\n\t\tif (typeof restored.contents === 'string') {\n\t\t\trestored.contents = new Buffer(restored.contents, 'base64');\n\t\t}\n\t}\n\n\tconst restoredFile = new File(restored);\n\n\t// Restore any properties that the original task put on the file;\n\t// but omit the normal properties of the file\n\tObject.keys(restored).forEach((key) => {\n\n\t\tif (File.isCustomProp(key)) {\n\t\t\trestoredFile[key] = restored[key];\n\t\t}\n\t});\n\n\treturn restoredFile;\n}\n\nfunction defaultValue(file) {\n\n\tconst vinylProps = ['cwd', 'base', 'contents', 'stat', 'history', 'path'],\n\t\tcustomProps = Object.keys(file).filter(File.isCustomProp);\n\n\t// Convert from a File object (from vinyl) into a plain object\n\treturn pick(file, [\n\t\t...vinylProps,\n\t\t...customProps\n\t]);\n}\n\nconst defaultOptions = {\n\tfileCache,\n\tname: 'default',\n\tsuccess: true,\n\tkey: defaultKey,\n\trestore: defaultRestore,\n\tvalue: defaultValue\n};\n\nplugin.Cache = Cache;\nplugin.fileCache = fileCache;\nplugin.defaultOptions = defaultOptions;\n\nexport default function plugin(task, inputOptions) {\n\t// Check for required task option\n\tif (!task) {\n\t\tthrow new PluginError('gulp-cache', 'Must pass a task to cache()');\n\t}\n\n\tconst options = {\n\t\t...plugin.defaultOptions,\n\t\t...task.cacheable,\n\t\t...inputOptions\n\t};\n\n\tconst taskProxy = new TaskProxy(task, options);\n\n\tfunction each(file, enc, next) {\n\n\t\tif (file.isNull()) {\n\t\t\tnext(null, file);\n\t\t\treturn;\n\t\t}\n\n\t\tif (file.isStream()) {\n\t\t\tnext(new PluginError('gulp-cache', 'Cannot operate on stream sources'));\n\t\t\treturn;\n\t\t}\n\n\t\tconst signals = taskProxy.processFile(file);\n\n\t\tsignals.on('error', (err) => {\n\t\t\tnext(new PluginError('gulp-cache', err));\n\t\t});\n\n\t\tsignals.on('file', (file) => {\n\t\t\tthis.push(file);\n\t\t});\n\n\t\tsignals.on('done', () => {\n\t\t\tnext(null);\n\t\t});\n\t}\n\n\tfunction flush(next) {\n\t\ttaskProxy.flush(next);\n\t}\n\n\treturn through.obj(each, flush);\n}\n\nplugin.clear =\nfunction clear(inputOptions) {\n\n\tconst options = {\n\t\t...plugin.defaultOptions,\n\t\t...inputOptions\n\t};\n\n\tconst taskProxy = new TaskProxy(null, options);\n\n\tasync function each(file, enc, next) {\n\n\t\tif (file.isNull()) {\n\t\t\tnext(null, file);\n\t\t\treturn;\n\t\t}\n\n\t\tif (file.isStream()) {\n\t\t\tnext(new PluginError('gulp-cache', 'Cannot operate on stream sources'));\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tawait taskProxy.removeCachedResult(file);\n\t\t\tnext(null, file);\n\t\t\treturn;\n\t\t} catch (err) {\n\t\t\tnext(new PluginError('gulp-cache', err));\n\t\t\treturn;\n\t\t}\n\t}\n\n\treturn through.obj(each);\n};\n\nplugin.clearAll =\nfunction clearAll() {\n\treturn new Promise((resolve, reject) => {\n\t\tfileCache.clear(null, (err) => {\n\n\t\t\tif (err) {\n\t\t\t\treject(new PluginError(\n\t\t\t\t\t'gulp-cache',\n\t\t\t\t\t`Problem clearing the cache: ${err.message}`\n\t\t\t\t));\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tresolve();\n\t\t});\n\t});\n};\n"],"names":["whitespaces","eventListenersCount","makeHash","key","crypto","createHash","update","digest","TaskProxy","task","inputOptions","options","_cacheQueue","_removeListeners","patchTask","_transform","chunk","encoding","next","args","emit","inputFile","signals","EventEmitter","nextTick","_processFileAsync","cached","_checkForCachedValue","cachedValue","value","cachedValueIsEmpty","Array","isArray","length","cachedValuesWithNormalPaths","filter","file","gulpCache$filePathChangedInsideTask","gulpCache$originalPath","path","gulpCache$fileBaseChangedInsideTask","gulpCache$originalBase","base","forEach","cachedFile","File","pick","contents","push","removeAllListeners","_runProxiedTaskAndQueueCache","_flush","err","remove","all","map","cachedKey","files","_storeCachedResult","_getFileKey","_removeCached","name","getKey","cacheName","restore","_getCached","parsedContents","JSON","parse","parsedFile","restoredFile","result","getValue","meta","success","_getValueFromResult","Boolean","_addCached","originalBase","originalPath","item","clone","has","get","set","on","_queueCache","_runProxiedTask","hasCacheListener","listenerCount","onError","onData","datum","_cachedKey","onTransformed","removeListener","setMaxListeners","_maxListeners","currMaxListeners","once","write","resolve","reject","fileCache","addCached","res","getCached","removeCached","Cache","cacheDirName","defaultKey","VERSION","toString","defaultRestore","restored","data","Buffer","isCustomProp","defaultValue","vinylProps","customProps","defaultOptions","plugin","PluginError","cacheable","taskProxy","each","enc","isNull","isStream","processFile","flush","through","obj","clear","removeCachedResult","clearAll","message"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAKA,MAAMA,cAAc,CAApB;MACCC,sBAAsB,CADvB;;AAGA,SAASC,QAAT,CAAkBC,GAAlB,EAAuB;QACfC,OAAOC,UAAP,CAAkB,KAAlB,EAAyBC,MAAzB,CAAgCH,GAAhC,EAAqCI,MAArC,CAA4C,KAA5C,CAAP;;;AAGD,AAAe,MAAMC,SAAN,CAAgB;;aAElBC,IAAZ,EAAkBC,YAAlB,EAAgC;;OAE1BD,IAAL,GAAYA,IAAZ;OACKE,OAAL,GAAeD,YAAf;OACKE,WAAL,GAAmB,UAAnB;OACKC,gBAAL,GAAwB,EAAxB;;MAEIJ,IAAJ,EAAU;QACJK,SAAL;;;;aAIU;QAEHL,IAAF,GAAW,IAAX,CAAEA,IAAF;QACHM,UADG,GACYN,IADZ,CACHM,UADG;;;OAGDA,UAAL,GAAkB,CAACC,KAAD,EAAQC,QAAR,EAAkBC,IAAlB,KAA2B;;kBAE9BH,UAAd,EAA0BN,IAA1B,EAAgC,CAACO,KAAD,EAAQC,QAAR,EAAkB,CAAC,GAAGE,IAAJ,KAAa;SACzD,GAAGA,IAAR,EAD8D;SAEzDC,IAAL,CAAU,wBAAV;IAF+B,CAAhC;GAFD;;;aASWC,SAAZ,EAAuBC,U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