vbapm 0.6.3-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +246 -0
  3. package/lib/_commonjsHelpers-553b27b3.js +2 -0
  4. package/lib/_commonjsHelpers-553b27b3.js.map +1 -0
  5. package/lib/build-project-55e5df48.js +4 -0
  6. package/lib/build-project-55e5df48.js.map +1 -0
  7. package/lib/build-target-283e1e7d.js +10 -0
  8. package/lib/build-target-283e1e7d.js.map +1 -0
  9. package/lib/create-project-905598ca.js +11 -0
  10. package/lib/create-project-905598ca.js.map +1 -0
  11. package/lib/debug.js +2 -0
  12. package/lib/debug.js.map +1 -0
  13. package/lib/export-project-55168787.js +5 -0
  14. package/lib/export-project-55168787.js.map +1 -0
  15. package/lib/export-target-c9ddd2fa.js +5 -0
  16. package/lib/export-target-c9ddd2fa.js.map +1 -0
  17. package/lib/get-target-23b8cc04.js +12 -0
  18. package/lib/get-target-23b8cc04.js.map +1 -0
  19. package/lib/index-35cff1d5.js +38 -0
  20. package/lib/index-35cff1d5.js.map +1 -0
  21. package/lib/index-87f55e79.js +4 -0
  22. package/lib/index-87f55e79.js.map +1 -0
  23. package/lib/index-b49bd5b2.js +2 -0
  24. package/lib/index-b49bd5b2.js.map +1 -0
  25. package/lib/index-c97017db.js +2 -0
  26. package/lib/index-c97017db.js.map +1 -0
  27. package/lib/index-d9ba3ba0.js +6 -0
  28. package/lib/index-d9ba3ba0.js.map +1 -0
  29. package/lib/index-ffbba08f.js +3 -0
  30. package/lib/index-ffbba08f.js.map +1 -0
  31. package/lib/index.js +2 -0
  32. package/lib/index.js.map +1 -0
  33. package/lib/inherits-713f4554.js +2 -0
  34. package/lib/inherits-713f4554.js.map +1 -0
  35. package/lib/init-project-a62cb644.js +16 -0
  36. package/lib/init-project-a62cb644.js.map +1 -0
  37. package/lib/load-from-project-e6530a69.js +6 -0
  38. package/lib/load-from-project-e6530a69.js.map +1 -0
  39. package/lib/minimatch-3a1d1fa9.js +2 -0
  40. package/lib/minimatch-3a1d1fa9.js.map +1 -0
  41. package/lib/once-9eb67b4f.js +2 -0
  42. package/lib/once-9eb67b4f.js.map +1 -0
  43. package/lib/project-d43b4e0c.js +30 -0
  44. package/lib/project-d43b4e0c.js.map +1 -0
  45. package/lib/run-macro-f4aa7c14.js +2 -0
  46. package/lib/run-macro-f4aa7c14.js.map +1 -0
  47. package/lib/sat-solver-01d6409e.js +2 -0
  48. package/lib/sat-solver-01d6409e.js.map +1 -0
  49. package/lib/src/actions/build-project.d.ts +2 -0
  50. package/lib/src/actions/create-project.d.ts +8 -0
  51. package/lib/src/actions/export-project.d.ts +6 -0
  52. package/lib/src/actions/increment-version.d.ts +5 -0
  53. package/lib/src/actions/init-project.d.ts +9 -0
  54. package/lib/src/actions/run-macro.d.ts +8 -0
  55. package/lib/src/actions/test-project.d.ts +5 -0
  56. package/lib/src/addin.d.ts +36 -0
  57. package/lib/src/bin/vba-blocks-build.d.ts +2 -0
  58. package/lib/src/bin/vba-blocks-export.d.ts +2 -0
  59. package/lib/src/bin/vba-blocks-init.d.ts +2 -0
  60. package/lib/src/bin/vba-blocks-new.d.ts +2 -0
  61. package/lib/src/bin/vba-blocks-run.d.ts +2 -0
  62. package/lib/src/bin/vba-blocks-test.d.ts +2 -0
  63. package/lib/src/bin/vba-blocks-version.d.ts +2 -0
  64. package/lib/src/bin/vba-blocks.d.ts +2 -0
  65. package/lib/src/build/apply-changeset.d.ts +3 -0
  66. package/lib/src/build/build-graph.d.ts +18 -0
  67. package/lib/src/build/changeset.d.ts +14 -0
  68. package/lib/src/build/compare-build-graphs.d.ts +3 -0
  69. package/lib/src/build/component.d.ts +25 -0
  70. package/lib/src/build/index.d.ts +7 -0
  71. package/lib/src/build/load-from-export.d.ts +2 -0
  72. package/lib/src/build/load-from-project.d.ts +5 -0
  73. package/lib/src/build/stage-build-graph.d.ts +2 -0
  74. package/lib/src/build/transform-build-graph.d.ts +3 -0
  75. package/lib/src/build/transforms/editor-config.d.ts +3 -0
  76. package/lib/src/cache.d.ts +9 -0
  77. package/lib/src/config.d.ts +29 -0
  78. package/lib/src/debug.d.ts +2 -0
  79. package/lib/src/env.d.ts +21 -0
  80. package/lib/src/errors.d.ts +56 -0
  81. package/lib/src/index.d.ts +16 -0
  82. package/lib/src/installer.d.ts +3 -0
  83. package/lib/src/lockfile/index.d.ts +23 -0
  84. package/lib/src/lockfile/is-lockfile-valid.d.ts +10 -0
  85. package/lib/src/lockfile/lockfile.d.ts +26 -0
  86. package/lib/src/manifest/dependency.d.ts +25 -0
  87. package/lib/src/manifest/index.d.ts +34 -0
  88. package/lib/src/manifest/reference.d.ts +12 -0
  89. package/lib/src/manifest/source.d.ts +8 -0
  90. package/lib/src/manifest/target.d.ts +10 -0
  91. package/lib/src/manifest/version.d.ts +3 -0
  92. package/lib/src/messages.d.ts +22 -0
  93. package/lib/src/professional/sources/git-source.d.ts +7 -0
  94. package/lib/src/professional/workspace.d.ts +10 -0
  95. package/lib/src/project.d.ts +48 -0
  96. package/lib/src/reporter.d.ts +12 -0
  97. package/lib/src/resolve/dependency-graph.d.ts +4 -0
  98. package/lib/src/resolve/index.d.ts +6 -0
  99. package/lib/src/resolve/latest-solver.d.ts +8 -0
  100. package/lib/src/resolve/resolver.d.ts +23 -0
  101. package/lib/src/resolve/sat-solver.d.ts +7 -0
  102. package/lib/src/sources/index.d.ts +16 -0
  103. package/lib/src/sources/path-source.d.ts +7 -0
  104. package/lib/src/sources/registration.d.ts +17 -0
  105. package/lib/src/sources/registry-source.d.ts +32 -0
  106. package/lib/src/sources/source.d.ts +6 -0
  107. package/lib/src/targets/add-target.d.ts +8 -0
  108. package/lib/src/targets/build-target.d.ts +41 -0
  109. package/lib/src/targets/export-target.d.ts +15 -0
  110. package/lib/src/targets/get-target.d.ts +7 -0
  111. package/lib/src/targets/index.d.ts +3 -0
  112. package/lib/src/targets/project-info.d.ts +7 -0
  113. package/lib/src/targets/transform-target.d.ts +3 -0
  114. package/lib/src/targets/transforms/core-xml.d.ts +2 -0
  115. package/lib/src/targets/transforms/workbook-xml.d.ts +2 -0
  116. package/lib/src/utils/async-map.d.ts +4 -0
  117. package/lib/src/utils/download.d.ts +1 -0
  118. package/lib/src/utils/fs.d.ts +23 -0
  119. package/lib/src/utils/get-staging.d.ts +1 -0
  120. package/lib/src/utils/git.d.ts +4 -0
  121. package/lib/src/utils/github.d.ts +9 -0
  122. package/lib/src/utils/has.d.ts +1 -0
  123. package/lib/src/utils/hash.d.ts +8 -0
  124. package/lib/src/utils/interop.d.ts +1 -0
  125. package/lib/src/utils/is.d.ts +5 -0
  126. package/lib/src/utils/noop.d.ts +1 -0
  127. package/lib/src/utils/observable.d.ts +15 -0
  128. package/lib/src/utils/parallel.d.ts +6 -0
  129. package/lib/src/utils/path.d.ts +7 -0
  130. package/lib/src/utils/pipe.d.ts +5 -0
  131. package/lib/src/utils/run.d.ts +17 -0
  132. package/lib/src/utils/stdout-file.d.ts +3 -0
  133. package/lib/src/utils/text.d.ts +4 -0
  134. package/lib/src/utils/toml.d.ts +4 -0
  135. package/lib/src/utils/unique.d.ts +1 -0
  136. package/lib/src/utils/without.d.ts +1 -0
  137. package/lib/src/utils/xml.d.ts +10 -0
  138. package/lib/src/utils/zip.d.ts +17 -0
  139. package/lib/test-project-d4f237d1.js +2 -0
  140. package/lib/test-project-d4f237d1.js.map +1 -0
  141. package/lib/text-ba532b40.js +10 -0
  142. package/lib/text-ba532b40.js.map +1 -0
  143. package/lib/tmp-bc08ebcf.js +10 -0
  144. package/lib/tmp-bc08ebcf.js.map +1 -0
  145. package/lib/toml-patch.es-6bd2145d.js +4 -0
  146. package/lib/toml-patch.es-6bd2145d.js.map +1 -0
  147. package/lib/vba-blocks-build-a717fcdb.js +10 -0
  148. package/lib/vba-blocks-build-a717fcdb.js.map +1 -0
  149. package/lib/vba-blocks-export-7e2c75cc.js +8 -0
  150. package/lib/vba-blocks-export-7e2c75cc.js.map +1 -0
  151. package/lib/vba-blocks-init-54531020.js +17 -0
  152. package/lib/vba-blocks-init-54531020.js.map +1 -0
  153. package/lib/vba-blocks-new-3210d92c.js +18 -0
  154. package/lib/vba-blocks-new-3210d92c.js.map +1 -0
  155. package/lib/vba-blocks-run-ab9d4ad4.js +11 -0
  156. package/lib/vba-blocks-run-ab9d4ad4.js.map +1 -0
  157. package/lib/vba-blocks-test-da5dba90.js +16 -0
  158. package/lib/vba-blocks-test-da5dba90.js.map +1 -0
  159. package/lib/vba-blocks-version-e1b3c35a.js +9 -0
  160. package/lib/vba-blocks-version-e1b3c35a.js.map +1 -0
  161. package/lib/vba-blocks.js +43 -0
  162. package/lib/vba-blocks.js.map +1 -0
  163. package/lib/workbook-xml-69fff4ae.js +3 -0
  164. package/lib/workbook-xml-69fff4ae.js.map +1 -0
  165. package/package.json +116 -0
  166. package/run-scripts/run.applescript +78 -0
  167. package/run-scripts/run.ps1 +211 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-c97017db.js","sources":["../node_modules/async-lock/lib/index.js","../node_modules/async-lock/index.js","../node_modules/sha.js/hash.js","../node_modules/sha.js/sha1.js","../node_modules/path-browserify/index.js","../node_modules/crc-32/crc32.js","../node_modules/pako/lib/utils/common.js","../node_modules/pako/lib/zlib/trees.js","../node_modules/pako/lib/zlib/adler32.js","../node_modules/pako/lib/zlib/crc32.js","../node_modules/pako/lib/zlib/deflate.js","../node_modules/pako/lib/zlib/messages.js","../node_modules/pako/lib/utils/strings.js","../node_modules/pako/lib/zlib/zstream.js","../node_modules/pako/lib/deflate.js","../node_modules/pako/lib/zlib/inffast.js","../node_modules/pako/lib/zlib/inftrees.js","../node_modules/pako/lib/zlib/inflate.js","../node_modules/pako/lib/zlib/constants.js","../node_modules/pako/lib/zlib/gzheader.js","../node_modules/pako/lib/inflate.js","../node_modules/pako/index.js","../node_modules/isomorphic-git/node_modules/pify/index.js","../node_modules/ignore/index.js","../node_modules/clean-git-ref/lib/index.js","../node_modules/diff3/onp.js","../node_modules/diff3/diff3.js","../node_modules/isomorphic-git/index.js"],"sourcesContent":["'use strict';\n\nvar AsyncLock = function (opts) {\n\topts = opts || {};\n\n\tthis.Promise = opts.Promise || Promise;\n\n\t// format: {key : [fn, fn]}\n\t// queues[key] = null indicates no job running for key\n\tthis.queues = Object.create(null);\n\n\t// lock is reentrant for same domain\n\tthis.domainReentrant = opts.domainReentrant || false;\n\tif (this.domainReentrant) {\n\t\tif (typeof process === 'undefined' || typeof process.domain === 'undefined') {\n\t\t\tthrow new Error(\n\t\t\t\t'Domain-reentrant locks require `process.domain` to exist. Please flip `opts.domainReentrant = false`, ' +\n\t\t\t\t'use a NodeJS version that still implements Domain, or install a browser polyfill.');\n\t\t}\n\t\t// domain of current running func {key : fn}\n\t\tthis.domains = Object.create(null);\n\t}\n\n\tthis.timeout = opts.timeout || AsyncLock.DEFAULT_TIMEOUT;\n\tthis.maxOccupationTime = opts.maxOccupationTime || AsyncLock.DEFAULT_MAX_OCCUPATION_TIME;\n\tthis.maxExecutionTime = opts.maxExecutionTime || AsyncLock.DEFAULT_MAX_EXECUTION_TIME;\n\tif (opts.maxPending === Infinity || (Number.isInteger(opts.maxPending) && opts.maxPending >= 0)) {\n\t\tthis.maxPending = opts.maxPending;\n\t} else {\n\t\tthis.maxPending = AsyncLock.DEFAULT_MAX_PENDING;\n\t}\n};\n\nAsyncLock.DEFAULT_TIMEOUT = 0; //Never\nAsyncLock.DEFAULT_MAX_OCCUPATION_TIME = 0; //Never\nAsyncLock.DEFAULT_MAX_EXECUTION_TIME = 0; //Never\nAsyncLock.DEFAULT_MAX_PENDING = 1000;\n\n/**\n * Acquire Locks\n *\n * @param {String|Array} key \tresource key or keys to lock\n * @param {function} fn \tasync function\n * @param {function} cb \tcallback function, otherwise will return a promise\n * @param {Object} opts \toptions\n */\nAsyncLock.prototype.acquire = function (key, fn, cb, opts) {\n\tif (Array.isArray(key)) {\n\t\treturn this._acquireBatch(key, fn, cb, opts);\n\t}\n\n\tif (typeof (fn) !== 'function') {\n\t\tthrow new Error('You must pass a function to execute');\n\t}\n\n\t// faux-deferred promise using new Promise() (as Promise.defer is deprecated)\n\tvar deferredResolve = null;\n\tvar deferredReject = null;\n\tvar deferred = null;\n\n\tif (typeof (cb) !== 'function') {\n\t\topts = cb;\n\t\tcb = null;\n\n\t\t// will return a promise\n\t\tdeferred = new this.Promise(function(resolve, reject) {\n\t\t\tdeferredResolve = resolve;\n\t\t\tdeferredReject = reject;\n\t\t});\n\t}\n\n\topts = opts || {};\n\n\tvar resolved = false;\n\tvar timer = null;\n\tvar occupationTimer = null;\n\tvar executionTimer = null;\n\tvar self = this;\n\n\tvar done = function (locked, err, ret) {\n\n\t\tif (occupationTimer) {\n\t\t\tclearTimeout(occupationTimer);\n\t\t\toccupationTimer = null;\n\t\t}\n\n\t\tif (executionTimer) {\n\t\t\tclearTimeout(executionTimer);\n\t\t\texecutionTimer = null;\n\t\t}\n\n\t\tif (locked) {\n\t\t\tif (!!self.queues[key] && self.queues[key].length === 0) {\n\t\t\t\tdelete self.queues[key];\n\t\t\t}\n\t\t\tif (self.domainReentrant) {\n\t\t\t\tdelete self.domains[key];\n\t\t\t}\n\t\t}\n\n\t\tif (!resolved) {\n\t\t\tif (!deferred) {\n\t\t\t\tif (typeof (cb) === 'function') {\n\t\t\t\t\tcb(err, ret);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\t//promise mode\n\t\t\t\tif (err) {\n\t\t\t\t\tdeferredReject(err);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tdeferredResolve(ret);\n\t\t\t\t}\n\t\t\t}\n\t\t\tresolved = true;\n\t\t}\n\n\t\tif (locked) {\n\t\t\t//run next func\n\t\t\tif (!!self.queues[key] && self.queues[key].length > 0) {\n\t\t\t\tself.queues[key].shift()();\n\t\t\t}\n\t\t}\n\t};\n\n\tvar exec = function (locked) {\n\t\tif (resolved) { // may due to timed out\n\t\t\treturn done(locked);\n\t\t}\n\n\t\tif (timer) {\n\t\t\tclearTimeout(timer);\n\t\t\ttimer = null;\n\t\t}\n\n\t\tif (self.domainReentrant && locked) {\n\t\t\tself.domains[key] = process.domain;\n\t\t}\n\n\t\tvar maxExecutionTime = opts.maxExecutionTime || self.maxExecutionTime;\n\t\tif (maxExecutionTime) {\n\t\t\texecutionTimer = setTimeout(function () {\n\t\t\t\tif (!!self.queues[key]) {\n\t\t\t\t\tdone(locked, new Error('Maximum execution time is exceeded ' + key));\n\t\t\t\t}\n\t\t\t}, maxExecutionTime);\n\t\t}\n\n\t\t// Callback mode\n\t\tif (fn.length === 1) {\n\t\t\tvar called = false;\n\t\t\ttry {\n\t\t\t\tfn(function (err, ret) {\n\t\t\t\t\tif (!called) {\n\t\t\t\t\t\tcalled = true;\n\t\t\t\t\t\tdone(locked, err, ret);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t} catch (err) {\n\t\t\t\t// catching error thrown in user function fn\n\t\t\t\tif (!called) {\n\t\t\t\t\tcalled = true;\n\t\t\t\t\tdone(locked, err);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\t// Promise mode\n\t\t\tself._promiseTry(function () {\n\t\t\t\treturn fn();\n\t\t\t})\n\t\t\t.then(function(ret){\n\t\t\t\tdone(locked, undefined, ret);\n\t\t\t}, function(error){\n\t\t\t\tdone(locked, error);\n\t\t\t});\n\t\t}\n\t};\n\n\tif (self.domainReentrant && !!process.domain) {\n\t\texec = process.domain.bind(exec);\n\t}\n\n\tvar maxPending = opts.maxPending || self.maxPending;\n\n\tif (!self.queues[key]) {\n\t\tself.queues[key] = [];\n\t\texec(true);\n\t}\n\telse if (self.domainReentrant && !!process.domain && process.domain === self.domains[key]) {\n\t\t// If code is in the same domain of current running task, run it directly\n\t\t// Since lock is re-enterable\n\t\texec(false);\n\t}\n\telse if (self.queues[key].length >= maxPending) {\n\t\tdone(false, new Error('Too many pending tasks in queue ' + key));\n\t}\n\telse {\n\t\tvar taskFn = function () {\n\t\t\texec(true);\n\t\t};\n\t\tif (opts.skipQueue) {\n\t\t\tself.queues[key].unshift(taskFn);\n\t\t} else {\n\t\t\tself.queues[key].push(taskFn);\n\t\t}\n\n\t\tvar timeout = opts.timeout || self.timeout;\n\t\tif (timeout) {\n\t\t\ttimer = setTimeout(function () {\n\t\t\t\ttimer = null;\n\t\t\t\tdone(false, new Error('async-lock timed out in queue ' + key));\n\t\t\t}, timeout);\n\t\t}\n\t}\n\n\tvar maxOccupationTime = opts.maxOccupationTime || self.maxOccupationTime;\n\t\tif (maxOccupationTime) {\n\t\t\toccupationTimer = setTimeout(function () {\n\t\t\t\tif (!!self.queues[key]) {\n\t\t\t\t\tdone(false, new Error('Maximum occupation time is exceeded in queue ' + key));\n\t\t\t\t}\n\t\t\t}, maxOccupationTime);\n\t\t}\n\n\tif (deferred) {\n\t\treturn deferred;\n\t}\n};\n\n/*\n * Below is how this function works:\n *\n * Equivalent code:\n * self.acquire(key1, function(cb){\n * self.acquire(key2, function(cb){\n * self.acquire(key3, fn, cb);\n * }, cb);\n * }, cb);\n *\n * Equivalent code:\n * var fn3 = getFn(key3, fn);\n * var fn2 = getFn(key2, fn3);\n * var fn1 = getFn(key1, fn2);\n * fn1(cb);\n */\nAsyncLock.prototype._acquireBatch = function (keys, fn, cb, opts) {\n\tif (typeof (cb) !== 'function') {\n\t\topts = cb;\n\t\tcb = null;\n\t}\n\n\tvar self = this;\n\tvar getFn = function (key, fn) {\n\t\treturn function (cb) {\n\t\t\tself.acquire(key, fn, cb, opts);\n\t\t};\n\t};\n\n\tvar fnx = keys.reduceRight(function (prev, key) {\n\t\treturn getFn(key, prev);\n\t}, fn);\n\n\tif (typeof (cb) === 'function') {\n\t\tfnx(cb);\n\t}\n\telse {\n\t\treturn new this.Promise(function (resolve, reject) {\n\t\t\t// check for promise mode in case keys is empty array\n\t\t\tif (fnx.length === 1) {\n\t\t\t\tfnx(function (err, ret) {\n\t\t\t\t\tif (err) {\n\t\t\t\t\t\treject(err);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tresolve(ret);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tresolve(fnx());\n\t\t\t}\n\t\t});\n\t}\n};\n\n/*\n *\tWhether there is any running or pending asyncFunc\n *\n *\t@param {String} key\n */\nAsyncLock.prototype.isBusy = function (key) {\n\tif (!key) {\n\t\treturn Object.keys(this.queues).length > 0;\n\t}\n\telse {\n\t\treturn !!this.queues[key];\n\t}\n};\n\n/**\n * Promise.try() implementation to become independent of Q-specific methods\n */\nAsyncLock.prototype._promiseTry = function(fn) {\n\ttry {\n\t\treturn this.Promise.resolve(fn());\n\t} catch (e) {\n\t\treturn this.Promise.reject(e);\n\t}\n};\n\nmodule.exports = AsyncLock;\n","'use strict';\nmodule.exports = require('./lib');\n","var Buffer = require('safe-buffer').Buffer\n\n// prototype class for hash functions\nfunction Hash (blockSize, finalSize) {\n this._block = Buffer.alloc(blockSize)\n this._finalSize = finalSize\n this._blockSize = blockSize\n this._len = 0\n}\n\nHash.prototype.update = function (data, enc) {\n if (typeof data === 'string') {\n enc = enc || 'utf8'\n data = Buffer.from(data, enc)\n }\n\n var block = this._block\n var blockSize = this._blockSize\n var length = data.length\n var accum = this._len\n\n for (var offset = 0; offset < length;) {\n var assigned = accum % blockSize\n var remainder = Math.min(length - offset, blockSize - assigned)\n\n for (var i = 0; i < remainder; i++) {\n block[assigned + i] = data[offset + i]\n }\n\n accum += remainder\n offset += remainder\n\n if ((accum % blockSize) === 0) {\n this._update(block)\n }\n }\n\n this._len += length\n return this\n}\n\nHash.prototype.digest = function (enc) {\n var rem = this._len % this._blockSize\n\n this._block[rem] = 0x80\n\n // zero (rem + 1) trailing bits, where (rem + 1) is the smallest\n // non-negative solution to the equation (length + 1 + (rem + 1)) === finalSize mod blockSize\n this._block.fill(0, rem + 1)\n\n if (rem >= this._finalSize) {\n this._update(this._block)\n this._block.fill(0)\n }\n\n var bits = this._len * 8\n\n // uint32\n if (bits <= 0xffffffff) {\n this._block.writeUInt32BE(bits, this._blockSize - 4)\n\n // uint64\n } else {\n var lowBits = (bits & 0xffffffff) >>> 0\n var highBits = (bits - lowBits) / 0x100000000\n\n this._block.writeUInt32BE(highBits, this._blockSize - 8)\n this._block.writeUInt32BE(lowBits, this._blockSize - 4)\n }\n\n this._update(this._block)\n var hash = this._hash()\n\n return enc ? hash.toString(enc) : hash\n}\n\nHash.prototype._update = function () {\n throw new Error('_update must be implemented by subclass')\n}\n\nmodule.exports = Hash\n","/*\n * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined\n * in FIPS PUB 180-1\n * Version 2.1a Copyright Paul Johnston 2000 - 2002.\n * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet\n * Distributed under the BSD License\n * See http://pajhome.org.uk/crypt/md5 for details.\n */\n\nvar inherits = require('inherits')\nvar Hash = require('./hash')\nvar Buffer = require('safe-buffer').Buffer\n\nvar K = [\n 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 0\n]\n\nvar W = new Array(80)\n\nfunction Sha1 () {\n this.init()\n this._w = W\n\n Hash.call(this, 64, 56)\n}\n\ninherits(Sha1, Hash)\n\nSha1.prototype.init = function () {\n this._a = 0x67452301\n this._b = 0xefcdab89\n this._c = 0x98badcfe\n this._d = 0x10325476\n this._e = 0xc3d2e1f0\n\n return this\n}\n\nfunction rotl1 (num) {\n return (num << 1) | (num >>> 31)\n}\n\nfunction rotl5 (num) {\n return (num << 5) | (num >>> 27)\n}\n\nfunction rotl30 (num) {\n return (num << 30) | (num >>> 2)\n}\n\nfunction ft (s, b, c, d) {\n if (s === 0) return (b & c) | ((~b) & d)\n if (s === 2) return (b & c) | (b & d) | (c & d)\n return b ^ c ^ d\n}\n\nSha1.prototype._update = function (M) {\n var W = this._w\n\n var a = this._a | 0\n var b = this._b | 0\n var c = this._c | 0\n var d = this._d | 0\n var e = this._e | 0\n\n for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4)\n for (; i < 80; ++i) W[i] = rotl1(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16])\n\n for (var j = 0; j < 80; ++j) {\n var s = ~~(j / 20)\n var t = (rotl5(a) + ft(s, b, c, d) + e + W[j] + K[s]) | 0\n\n e = d\n d = c\n c = rotl30(b)\n b = a\n a = t\n }\n\n this._a = (a + this._a) | 0\n this._b = (b + this._b) | 0\n this._c = (c + this._c) | 0\n this._d = (d + this._d) | 0\n this._e = (e + this._e) | 0\n}\n\nSha1.prototype._hash = function () {\n var H = Buffer.allocUnsafe(20)\n\n H.writeInt32BE(this._a | 0, 0)\n H.writeInt32BE(this._b | 0, 4)\n H.writeInt32BE(this._c | 0, 8)\n H.writeInt32BE(this._d | 0, 12)\n H.writeInt32BE(this._e | 0, 16)\n\n return H\n}\n\nmodule.exports = Sha1\n","// 'path' module extracted from Node.js v8.11.1 (only the posix part)\n// transplited with Babel\n\n// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n'use strict';\n\nfunction assertPath(path) {\n if (typeof path !== 'string') {\n throw new TypeError('Path must be a string. Received ' + JSON.stringify(path));\n }\n}\n\n// Resolves . and .. elements in a path with directory names\nfunction normalizeStringPosix(path, allowAboveRoot) {\n var res = '';\n var lastSegmentLength = 0;\n var lastSlash = -1;\n var dots = 0;\n var code;\n for (var i = 0; i <= path.length; ++i) {\n if (i < path.length)\n code = path.charCodeAt(i);\n else if (code === 47 /*/*/)\n break;\n else\n code = 47 /*/*/;\n if (code === 47 /*/*/) {\n if (lastSlash === i - 1 || dots === 1) {\n // NOOP\n } else if (lastSlash !== i - 1 && dots === 2) {\n if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== 46 /*.*/ || res.charCodeAt(res.length - 2) !== 46 /*.*/) {\n if (res.length > 2) {\n var lastSlashIndex = res.lastIndexOf('/');\n if (lastSlashIndex !== res.length - 1) {\n if (lastSlashIndex === -1) {\n res = '';\n lastSegmentLength = 0;\n } else {\n res = res.slice(0, lastSlashIndex);\n lastSegmentLength = res.length - 1 - res.lastIndexOf('/');\n }\n lastSlash = i;\n dots = 0;\n continue;\n }\n } else if (res.length === 2 || res.length === 1) {\n res = '';\n lastSegmentLength = 0;\n lastSlash = i;\n dots = 0;\n continue;\n }\n }\n if (allowAboveRoot) {\n if (res.length > 0)\n res += '/..';\n else\n res = '..';\n lastSegmentLength = 2;\n }\n } else {\n if (res.length > 0)\n res += '/' + path.slice(lastSlash + 1, i);\n else\n res = path.slice(lastSlash + 1, i);\n lastSegmentLength = i - lastSlash - 1;\n }\n lastSlash = i;\n dots = 0;\n } else if (code === 46 /*.*/ && dots !== -1) {\n ++dots;\n } else {\n dots = -1;\n }\n }\n return res;\n}\n\nfunction _format(sep, pathObject) {\n var dir = pathObject.dir || pathObject.root;\n var base = pathObject.base || (pathObject.name || '') + (pathObject.ext || '');\n if (!dir) {\n return base;\n }\n if (dir === pathObject.root) {\n return dir + base;\n }\n return dir + sep + base;\n}\n\nvar posix = {\n // path.resolve([from ...], to)\n resolve: function resolve() {\n var resolvedPath = '';\n var resolvedAbsolute = false;\n var cwd;\n\n for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {\n var path;\n if (i >= 0)\n path = arguments[i];\n else {\n if (cwd === undefined)\n cwd = process.cwd();\n path = cwd;\n }\n\n assertPath(path);\n\n // Skip empty entries\n if (path.length === 0) {\n continue;\n }\n\n resolvedPath = path + '/' + resolvedPath;\n resolvedAbsolute = path.charCodeAt(0) === 47 /*/*/;\n }\n\n // At this point the path should be resolved to a full absolute path, but\n // handle relative paths to be safe (might happen when process.cwd() fails)\n\n // Normalize the path\n resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute);\n\n if (resolvedAbsolute) {\n if (resolvedPath.length > 0)\n return '/' + resolvedPath;\n else\n return '/';\n } else if (resolvedPath.length > 0) {\n return resolvedPath;\n } else {\n return '.';\n }\n },\n\n normalize: function normalize(path) {\n assertPath(path);\n\n if (path.length === 0) return '.';\n\n var isAbsolute = path.charCodeAt(0) === 47 /*/*/;\n var trailingSeparator = path.charCodeAt(path.length - 1) === 47 /*/*/;\n\n // Normalize the path\n path = normalizeStringPosix(path, !isAbsolute);\n\n if (path.length === 0 && !isAbsolute) path = '.';\n if (path.length > 0 && trailingSeparator) path += '/';\n\n if (isAbsolute) return '/' + path;\n return path;\n },\n\n isAbsolute: function isAbsolute(path) {\n assertPath(path);\n return path.length > 0 && path.charCodeAt(0) === 47 /*/*/;\n },\n\n join: function join() {\n if (arguments.length === 0)\n return '.';\n var joined;\n for (var i = 0; i < arguments.length; ++i) {\n var arg = arguments[i];\n assertPath(arg);\n if (arg.length > 0) {\n if (joined === undefined)\n joined = arg;\n else\n joined += '/' + arg;\n }\n }\n if (joined === undefined)\n return '.';\n return posix.normalize(joined);\n },\n\n relative: function relative(from, to) {\n assertPath(from);\n assertPath(to);\n\n if (from === to) return '';\n\n from = posix.resolve(from);\n to = posix.resolve(to);\n\n if (from === to) return '';\n\n // Trim any leading backslashes\n var fromStart = 1;\n for (; fromStart < from.length; ++fromStart) {\n if (from.charCodeAt(fromStart) !== 47 /*/*/)\n break;\n }\n var fromEnd = from.length;\n var fromLen = fromEnd - fromStart;\n\n // Trim any leading backslashes\n var toStart = 1;\n for (; toStart < to.length; ++toStart) {\n if (to.charCodeAt(toStart) !== 47 /*/*/)\n break;\n }\n var toEnd = to.length;\n var toLen = toEnd - toStart;\n\n // Compare paths to find the longest common path from root\n var length = fromLen < toLen ? fromLen : toLen;\n var lastCommonSep = -1;\n var i = 0;\n for (; i <= length; ++i) {\n if (i === length) {\n if (toLen > length) {\n if (to.charCodeAt(toStart + i) === 47 /*/*/) {\n // We get here if `from` is the exact base path for `to`.\n // For example: from='/foo/bar'; to='/foo/bar/baz'\n return to.slice(toStart + i + 1);\n } else if (i === 0) {\n // We get here if `from` is the root\n // For example: from='/'; to='/foo'\n return to.slice(toStart + i);\n }\n } else if (fromLen > length) {\n if (from.charCodeAt(fromStart + i) === 47 /*/*/) {\n // We get here if `to` is the exact base path for `from`.\n // For example: from='/foo/bar/baz'; to='/foo/bar'\n lastCommonSep = i;\n } else if (i === 0) {\n // We get here if `to` is the root.\n // For example: from='/foo'; to='/'\n lastCommonSep = 0;\n }\n }\n break;\n }\n var fromCode = from.charCodeAt(fromStart + i);\n var toCode = to.charCodeAt(toStart + i);\n if (fromCode !== toCode)\n break;\n else if (fromCode === 47 /*/*/)\n lastCommonSep = i;\n }\n\n var out = '';\n // Generate the relative path based on the path difference between `to`\n // and `from`\n for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {\n if (i === fromEnd || from.charCodeAt(i) === 47 /*/*/) {\n if (out.length === 0)\n out += '..';\n else\n out += '/..';\n }\n }\n\n // Lastly, append the rest of the destination (`to`) path that comes after\n // the common path parts\n if (out.length > 0)\n return out + to.slice(toStart + lastCommonSep);\n else {\n toStart += lastCommonSep;\n if (to.charCodeAt(toStart) === 47 /*/*/)\n ++toStart;\n return to.slice(toStart);\n }\n },\n\n _makeLong: function _makeLong(path) {\n return path;\n },\n\n dirname: function dirname(path) {\n assertPath(path);\n if (path.length === 0) return '.';\n var code = path.charCodeAt(0);\n var hasRoot = code === 47 /*/*/;\n var end = -1;\n var matchedSlash = true;\n for (var i = path.length - 1; i >= 1; --i) {\n code = path.charCodeAt(i);\n if (code === 47 /*/*/) {\n if (!matchedSlash) {\n end = i;\n break;\n }\n } else {\n // We saw the first non-path separator\n matchedSlash = false;\n }\n }\n\n if (end === -1) return hasRoot ? '/' : '.';\n if (hasRoot && end === 1) return '//';\n return path.slice(0, end);\n },\n\n basename: function basename(path, ext) {\n if (ext !== undefined && typeof ext !== 'string') throw new TypeError('\"ext\" argument must be a string');\n assertPath(path);\n\n var start = 0;\n var end = -1;\n var matchedSlash = true;\n var i;\n\n if (ext !== undefined && ext.length > 0 && ext.length <= path.length) {\n if (ext.length === path.length && ext === path) return '';\n var extIdx = ext.length - 1;\n var firstNonSlashEnd = -1;\n for (i = path.length - 1; i >= 0; --i) {\n var code = path.charCodeAt(i);\n if (code === 47 /*/*/) {\n // If we reached a path separator that was not part of a set of path\n // separators at the end of the string, stop now\n if (!matchedSlash) {\n start = i + 1;\n break;\n }\n } else {\n if (firstNonSlashEnd === -1) {\n // We saw the first non-path separator, remember this index in case\n // we need it if the extension ends up not matching\n matchedSlash = false;\n firstNonSlashEnd = i + 1;\n }\n if (extIdx >= 0) {\n // Try to match the explicit extension\n if (code === ext.charCodeAt(extIdx)) {\n if (--extIdx === -1) {\n // We matched the extension, so mark this as the end of our path\n // component\n end = i;\n }\n } else {\n // Extension does not match, so our result is the entire path\n // component\n extIdx = -1;\n end = firstNonSlashEnd;\n }\n }\n }\n }\n\n if (start === end) end = firstNonSlashEnd;else if (end === -1) end = path.length;\n return path.slice(start, end);\n } else {\n for (i = path.length - 1; i >= 0; --i) {\n if (path.charCodeAt(i) === 47 /*/*/) {\n // If we reached a path separator that was not part of a set of path\n // separators at the end of the string, stop now\n if (!matchedSlash) {\n start = i + 1;\n break;\n }\n } else if (end === -1) {\n // We saw the first non-path separator, mark this as the end of our\n // path component\n matchedSlash = false;\n end = i + 1;\n }\n }\n\n if (end === -1) return '';\n return path.slice(start, end);\n }\n },\n\n extname: function extname(path) {\n assertPath(path);\n var startDot = -1;\n var startPart = 0;\n var end = -1;\n var matchedSlash = true;\n // Track the state of characters (if any) we see before our first dot and\n // after any path separator we find\n var preDotState = 0;\n for (var i = path.length - 1; i >= 0; --i) {\n var code = path.charCodeAt(i);\n if (code === 47 /*/*/) {\n // If we reached a path separator that was not part of a set of path\n // separators at the end of the string, stop now\n if (!matchedSlash) {\n startPart = i + 1;\n break;\n }\n continue;\n }\n if (end === -1) {\n // We saw the first non-path separator, mark this as the end of our\n // extension\n matchedSlash = false;\n end = i + 1;\n }\n if (code === 46 /*.*/) {\n // If this is our first dot, mark it as the start of our extension\n if (startDot === -1)\n startDot = i;\n else if (preDotState !== 1)\n preDotState = 1;\n } else if (startDot !== -1) {\n // We saw a non-dot and non-path separator before our dot, so we should\n // have a good chance at having a non-empty extension\n preDotState = -1;\n }\n }\n\n if (startDot === -1 || end === -1 ||\n // We saw a non-dot character immediately before the dot\n preDotState === 0 ||\n // The (right-most) trimmed path component is exactly '..'\n preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {\n return '';\n }\n return path.slice(startDot, end);\n },\n\n format: function format(pathObject) {\n if (pathObject === null || typeof pathObject !== 'object') {\n throw new TypeError('The \"pathObject\" argument must be of type Object. Received type ' + typeof pathObject);\n }\n return _format('/', pathObject);\n },\n\n parse: function parse(path) {\n assertPath(path);\n\n var ret = { root: '', dir: '', base: '', ext: '', name: '' };\n if (path.length === 0) return ret;\n var code = path.charCodeAt(0);\n var isAbsolute = code === 47 /*/*/;\n var start;\n if (isAbsolute) {\n ret.root = '/';\n start = 1;\n } else {\n start = 0;\n }\n var startDot = -1;\n var startPart = 0;\n var end = -1;\n var matchedSlash = true;\n var i = path.length - 1;\n\n // Track the state of characters (if any) we see before our first dot and\n // after any path separator we find\n var preDotState = 0;\n\n // Get non-dir info\n for (; i >= start; --i) {\n code = path.charCodeAt(i);\n if (code === 47 /*/*/) {\n // If we reached a path separator that was not part of a set of path\n // separators at the end of the string, stop now\n if (!matchedSlash) {\n startPart = i + 1;\n break;\n }\n continue;\n }\n if (end === -1) {\n // We saw the first non-path separator, mark this as the end of our\n // extension\n matchedSlash = false;\n end = i + 1;\n }\n if (code === 46 /*.*/) {\n // If this is our first dot, mark it as the start of our extension\n if (startDot === -1) startDot = i;else if (preDotState !== 1) preDotState = 1;\n } else if (startDot !== -1) {\n // We saw a non-dot and non-path separator before our dot, so we should\n // have a good chance at having a non-empty extension\n preDotState = -1;\n }\n }\n\n if (startDot === -1 || end === -1 ||\n // We saw a non-dot character immediately before the dot\n preDotState === 0 ||\n // The (right-most) trimmed path component is exactly '..'\n preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {\n if (end !== -1) {\n if (startPart === 0 && isAbsolute) ret.base = ret.name = path.slice(1, end);else ret.base = ret.name = path.slice(startPart, end);\n }\n } else {\n if (startPart === 0 && isAbsolute) {\n ret.name = path.slice(1, startDot);\n ret.base = path.slice(1, end);\n } else {\n ret.name = path.slice(startPart, startDot);\n ret.base = path.slice(startPart, end);\n }\n ret.ext = path.slice(startDot, end);\n }\n\n if (startPart > 0) ret.dir = path.slice(0, startPart - 1);else if (isAbsolute) ret.dir = '/';\n\n return ret;\n },\n\n sep: '/',\n delimiter: ':',\n win32: null,\n posix: null\n};\n\nposix.posix = posix;\n\nmodule.exports = posix;\n","/* crc32.js (C) 2014-present SheetJS -- http://sheetjs.com */\n/* vim: set ts=2: */\n/*exported CRC32 */\nvar CRC32;\n(function (factory) {\n\t/*jshint ignore:start */\n\t/*eslint-disable */\n\tif(typeof DO_NOT_EXPORT_CRC === 'undefined') {\n\t\tif('object' === typeof exports) {\n\t\t\tfactory(exports);\n\t\t} else if ('function' === typeof define && define.amd) {\n\t\t\tdefine(function () {\n\t\t\t\tvar module = {};\n\t\t\t\tfactory(module);\n\t\t\t\treturn module;\n\t\t\t});\n\t\t} else {\n\t\t\tfactory(CRC32 = {});\n\t\t}\n\t} else {\n\t\tfactory(CRC32 = {});\n\t}\n\t/*eslint-enable */\n\t/*jshint ignore:end */\n}(function(CRC32) {\nCRC32.version = '1.2.0';\n/* see perf/crc32table.js */\n/*global Int32Array */\nfunction signed_crc_table() {\n\tvar c = 0, table = new Array(256);\n\n\tfor(var n =0; n != 256; ++n){\n\t\tc = n;\n\t\tc = ((c&1) ? (-306674912 ^ (c >>> 1)) : (c >>> 1));\n\t\tc = ((c&1) ? (-306674912 ^ (c >>> 1)) : (c >>> 1));\n\t\tc = ((c&1) ? (-306674912 ^ (c >>> 1)) : (c >>> 1));\n\t\tc = ((c&1) ? (-306674912 ^ (c >>> 1)) : (c >>> 1));\n\t\tc = ((c&1) ? (-306674912 ^ (c >>> 1)) : (c >>> 1));\n\t\tc = ((c&1) ? (-306674912 ^ (c >>> 1)) : (c >>> 1));\n\t\tc = ((c&1) ? (-306674912 ^ (c >>> 1)) : (c >>> 1));\n\t\tc = ((c&1) ? (-306674912 ^ (c >>> 1)) : (c >>> 1));\n\t\ttable[n] = c;\n\t}\n\n\treturn typeof Int32Array !== 'undefined' ? new Int32Array(table) : table;\n}\n\nvar T = signed_crc_table();\nfunction crc32_bstr(bstr, seed) {\n\tvar C = seed ^ -1, L = bstr.length - 1;\n\tfor(var i = 0; i < L;) {\n\t\tC = (C>>>8) ^ T[(C^bstr.charCodeAt(i++))&0xFF];\n\t\tC = (C>>>8) ^ T[(C^bstr.charCodeAt(i++))&0xFF];\n\t}\n\tif(i === L) C = (C>>>8) ^ T[(C ^ bstr.charCodeAt(i))&0xFF];\n\treturn C ^ -1;\n}\n\nfunction crc32_buf(buf, seed) {\n\tif(buf.length > 10000) return crc32_buf_8(buf, seed);\n\tvar C = seed ^ -1, L = buf.length - 3;\n\tfor(var i = 0; i < L;) {\n\t\tC = (C>>>8) ^ T[(C^buf[i++])&0xFF];\n\t\tC = (C>>>8) ^ T[(C^buf[i++])&0xFF];\n\t\tC = (C>>>8) ^ T[(C^buf[i++])&0xFF];\n\t\tC = (C>>>8) ^ T[(C^buf[i++])&0xFF];\n\t}\n\twhile(i < L+3) C = (C>>>8) ^ T[(C^buf[i++])&0xFF];\n\treturn C ^ -1;\n}\n\nfunction crc32_buf_8(buf, seed) {\n\tvar C = seed ^ -1, L = buf.length - 7;\n\tfor(var i = 0; i < L;) {\n\t\tC = (C>>>8) ^ T[(C^buf[i++])&0xFF];\n\t\tC = (C>>>8) ^ T[(C^buf[i++])&0xFF];\n\t\tC = (C>>>8) ^ T[(C^buf[i++])&0xFF];\n\t\tC = (C>>>8) ^ T[(C^buf[i++])&0xFF];\n\t\tC = (C>>>8) ^ T[(C^buf[i++])&0xFF];\n\t\tC = (C>>>8) ^ T[(C^buf[i++])&0xFF];\n\t\tC = (C>>>8) ^ T[(C^buf[i++])&0xFF];\n\t\tC = (C>>>8) ^ T[(C^buf[i++])&0xFF];\n\t}\n\twhile(i < L+7) C = (C>>>8) ^ T[(C^buf[i++])&0xFF];\n\treturn C ^ -1;\n}\n\nfunction crc32_str(str, seed) {\n\tvar C = seed ^ -1;\n\tfor(var i = 0, L=str.length, c, d; i < L;) {\n\t\tc = str.charCodeAt(i++);\n\t\tif(c < 0x80) {\n\t\t\tC = (C>>>8) ^ T[(C ^ c)&0xFF];\n\t\t} else if(c < 0x800) {\n\t\t\tC = (C>>>8) ^ T[(C ^ (192|((c>>6)&31)))&0xFF];\n\t\t\tC = (C>>>8) ^ T[(C ^ (128|(c&63)))&0xFF];\n\t\t} else if(c >= 0xD800 && c < 0xE000) {\n\t\t\tc = (c&1023)+64; d = str.charCodeAt(i++)&1023;\n\t\t\tC = (C>>>8) ^ T[(C ^ (240|((c>>8)&7)))&0xFF];\n\t\t\tC = (C>>>8) ^ T[(C ^ (128|((c>>2)&63)))&0xFF];\n\t\t\tC = (C>>>8) ^ T[(C ^ (128|((d>>6)&15)|((c&3)<<4)))&0xFF];\n\t\t\tC = (C>>>8) ^ T[(C ^ (128|(d&63)))&0xFF];\n\t\t} else {\n\t\t\tC = (C>>>8) ^ T[(C ^ (224|((c>>12)&15)))&0xFF];\n\t\t\tC = (C>>>8) ^ T[(C ^ (128|((c>>6)&63)))&0xFF];\n\t\t\tC = (C>>>8) ^ T[(C ^ (128|(c&63)))&0xFF];\n\t\t}\n\t}\n\treturn C ^ -1;\n}\nCRC32.table = T;\n// $FlowIgnore\nCRC32.bstr = crc32_bstr;\n// $FlowIgnore\nCRC32.buf = crc32_buf;\n// $FlowIgnore\nCRC32.str = crc32_str;\n}));\n","'use strict';\n\n\nvar TYPED_OK = (typeof Uint8Array !== 'undefined') &&\n (typeof Uint16Array !== 'undefined') &&\n (typeof Int32Array !== 'undefined');\n\nfunction _has(obj, key) {\n return Object.prototype.hasOwnProperty.call(obj, key);\n}\n\nexports.assign = function (obj /*from1, from2, from3, ...*/) {\n var sources = Array.prototype.slice.call(arguments, 1);\n while (sources.length) {\n var source = sources.shift();\n if (!source) { continue; }\n\n if (typeof source !== 'object') {\n throw new TypeError(source + 'must be non-object');\n }\n\n for (var p in source) {\n if (_has(source, p)) {\n obj[p] = source[p];\n }\n }\n }\n\n return obj;\n};\n\n\n// reduce buffer size, avoiding mem copy\nexports.shrinkBuf = function (buf, size) {\n if (buf.length === size) { return buf; }\n if (buf.subarray) { return buf.subarray(0, size); }\n buf.length = size;\n return buf;\n};\n\n\nvar fnTyped = {\n arraySet: function (dest, src, src_offs, len, dest_offs) {\n if (src.subarray && dest.subarray) {\n dest.set(src.subarray(src_offs, src_offs + len), dest_offs);\n return;\n }\n // Fallback to ordinary array\n for (var i = 0; i < len; i++) {\n dest[dest_offs + i] = src[src_offs + i];\n }\n },\n // Join array of chunks to single array.\n flattenChunks: function (chunks) {\n var i, l, len, pos, chunk, result;\n\n // calculate data length\n len = 0;\n for (i = 0, l = chunks.length; i < l; i++) {\n len += chunks[i].length;\n }\n\n // join chunks\n result = new Uint8Array(len);\n pos = 0;\n for (i = 0, l = chunks.length; i < l; i++) {\n chunk = chunks[i];\n result.set(chunk, pos);\n pos += chunk.length;\n }\n\n return result;\n }\n};\n\nvar fnUntyped = {\n arraySet: function (dest, src, src_offs, len, dest_offs) {\n for (var i = 0; i < len; i++) {\n dest[dest_offs + i] = src[src_offs + i];\n }\n },\n // Join array of chunks to single array.\n flattenChunks: function (chunks) {\n return [].concat.apply([], chunks);\n }\n};\n\n\n// Enable/Disable typed arrays use, for testing\n//\nexports.setTyped = function (on) {\n if (on) {\n exports.Buf8 = Uint8Array;\n exports.Buf16 = Uint16Array;\n exports.Buf32 = Int32Array;\n exports.assign(exports, fnTyped);\n } else {\n exports.Buf8 = Array;\n exports.Buf16 = Array;\n exports.Buf32 = Array;\n exports.assign(exports, fnUntyped);\n }\n};\n\nexports.setTyped(TYPED_OK);\n","'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\n/* eslint-disable space-unary-ops */\n\nvar utils = require('../utils/common');\n\n/* Public constants ==========================================================*/\n/* ===========================================================================*/\n\n\n//var Z_FILTERED = 1;\n//var Z_HUFFMAN_ONLY = 2;\n//var Z_RLE = 3;\nvar Z_FIXED = 4;\n//var Z_DEFAULT_STRATEGY = 0;\n\n/* Possible values of the data_type field (though see inflate()) */\nvar Z_BINARY = 0;\nvar Z_TEXT = 1;\n//var Z_ASCII = 1; // = Z_TEXT\nvar Z_UNKNOWN = 2;\n\n/*============================================================================*/\n\n\nfunction zero(buf) { var len = buf.length; while (--len >= 0) { buf[len] = 0; } }\n\n// From zutil.h\n\nvar STORED_BLOCK = 0;\nvar STATIC_TREES = 1;\nvar DYN_TREES = 2;\n/* The three kinds of block type */\n\nvar MIN_MATCH = 3;\nvar MAX_MATCH = 258;\n/* The minimum and maximum match lengths */\n\n// From deflate.h\n/* ===========================================================================\n * Internal compression state.\n */\n\nvar LENGTH_CODES = 29;\n/* number of length codes, not counting the special END_BLOCK code */\n\nvar LITERALS = 256;\n/* number of literal bytes 0..255 */\n\nvar L_CODES = LITERALS + 1 + LENGTH_CODES;\n/* number of Literal or Length codes, including the END_BLOCK code */\n\nvar D_CODES = 30;\n/* number of distance codes */\n\nvar BL_CODES = 19;\n/* number of codes used to transfer the bit lengths */\n\nvar HEAP_SIZE = 2 * L_CODES + 1;\n/* maximum heap size */\n\nvar MAX_BITS = 15;\n/* All codes must not exceed MAX_BITS bits */\n\nvar Buf_size = 16;\n/* size of bit buffer in bi_buf */\n\n\n/* ===========================================================================\n * Constants\n */\n\nvar MAX_BL_BITS = 7;\n/* Bit length codes must not exceed MAX_BL_BITS bits */\n\nvar END_BLOCK = 256;\n/* end of block literal code */\n\nvar REP_3_6 = 16;\n/* repeat previous bit length 3-6 times (2 bits of repeat count) */\n\nvar REPZ_3_10 = 17;\n/* repeat a zero length 3-10 times (3 bits of repeat count) */\n\nvar REPZ_11_138 = 18;\n/* repeat a zero length 11-138 times (7 bits of repeat count) */\n\n/* eslint-disable comma-spacing,array-bracket-spacing */\nvar extra_lbits = /* extra bits for each length code */\n [0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0];\n\nvar extra_dbits = /* extra bits for each distance code */\n [0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13];\n\nvar extra_blbits = /* extra bits for each bit length code */\n [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7];\n\nvar bl_order =\n [16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];\n/* eslint-enable comma-spacing,array-bracket-spacing */\n\n/* The lengths of the bit length codes are sent in order of decreasing\n * probability, to avoid transmitting the lengths for unused bit length codes.\n */\n\n/* ===========================================================================\n * Local data. These are initialized only once.\n */\n\n// We pre-fill arrays with 0 to avoid uninitialized gaps\n\nvar DIST_CODE_LEN = 512; /* see definition of array dist_code below */\n\n// !!!! Use flat array instead of structure, Freq = i*2, Len = i*2+1\nvar static_ltree = new Array((L_CODES + 2) * 2);\nzero(static_ltree);\n/* The static literal tree. Since the bit lengths are imposed, there is no\n * need for the L_CODES extra codes used during heap construction. However\n * The codes 286 and 287 are needed to build a canonical tree (see _tr_init\n * below).\n */\n\nvar static_dtree = new Array(D_CODES * 2);\nzero(static_dtree);\n/* The static distance tree. (Actually a trivial tree since all codes use\n * 5 bits.)\n */\n\nvar _dist_code = new Array(DIST_CODE_LEN);\nzero(_dist_code);\n/* Distance codes. The first 256 values correspond to the distances\n * 3 .. 258, the last 256 values correspond to the top 8 bits of\n * the 15 bit distances.\n */\n\nvar _length_code = new Array(MAX_MATCH - MIN_MATCH + 1);\nzero(_length_code);\n/* length code for each normalized match length (0 == MIN_MATCH) */\n\nvar base_length = new Array(LENGTH_CODES);\nzero(base_length);\n/* First normalized length for each code (0 = MIN_MATCH) */\n\nvar base_dist = new Array(D_CODES);\nzero(base_dist);\n/* First normalized distance for each code (0 = distance of 1) */\n\n\nfunction StaticTreeDesc(static_tree, extra_bits, extra_base, elems, max_length) {\n\n this.static_tree = static_tree; /* static tree or NULL */\n this.extra_bits = extra_bits; /* extra bits for each code or NULL */\n this.extra_base = extra_base; /* base index for extra_bits */\n this.elems = elems; /* max number of elements in the tree */\n this.max_length = max_length; /* max bit length for the codes */\n\n // show if `static_tree` has data or dummy - needed for monomorphic objects\n this.has_stree = static_tree && static_tree.length;\n}\n\n\nvar static_l_desc;\nvar static_d_desc;\nvar static_bl_desc;\n\n\nfunction TreeDesc(dyn_tree, stat_desc) {\n this.dyn_tree = dyn_tree; /* the dynamic tree */\n this.max_code = 0; /* largest code with non zero frequency */\n this.stat_desc = stat_desc; /* the corresponding static tree */\n}\n\n\n\nfunction d_code(dist) {\n return dist < 256 ? _dist_code[dist] : _dist_code[256 + (dist >>> 7)];\n}\n\n\n/* ===========================================================================\n * Output a short LSB first on the stream.\n * IN assertion: there is enough room in pendingBuf.\n */\nfunction put_short(s, w) {\n// put_byte(s, (uch)((w) & 0xff));\n// put_byte(s, (uch)((ush)(w) >> 8));\n s.pending_buf[s.pending++] = (w) & 0xff;\n s.pending_buf[s.pending++] = (w >>> 8) & 0xff;\n}\n\n\n/* ===========================================================================\n * Send a value on a given number of bits.\n * IN assertion: length <= 16 and value fits in length bits.\n */\nfunction send_bits(s, value, length) {\n if (s.bi_valid > (Buf_size - length)) {\n s.bi_buf |= (value << s.bi_valid) & 0xffff;\n put_short(s, s.bi_buf);\n s.bi_buf = value >> (Buf_size - s.bi_valid);\n s.bi_valid += length - Buf_size;\n } else {\n s.bi_buf |= (value << s.bi_valid) & 0xffff;\n s.bi_valid += length;\n }\n}\n\n\nfunction send_code(s, c, tree) {\n send_bits(s, tree[c * 2]/*.Code*/, tree[c * 2 + 1]/*.Len*/);\n}\n\n\n/* ===========================================================================\n * Reverse the first len bits of a code, using straightforward code (a faster\n * method would use a table)\n * IN assertion: 1 <= len <= 15\n */\nfunction bi_reverse(code, len) {\n var res = 0;\n do {\n res |= code & 1;\n code >>>= 1;\n res <<= 1;\n } while (--len > 0);\n return res >>> 1;\n}\n\n\n/* ===========================================================================\n * Flush the bit buffer, keeping at most 7 bits in it.\n */\nfunction bi_flush(s) {\n if (s.bi_valid === 16) {\n put_short(s, s.bi_buf);\n s.bi_buf = 0;\n s.bi_valid = 0;\n\n } else if (s.bi_valid >= 8) {\n s.pending_buf[s.pending++] = s.bi_buf & 0xff;\n s.bi_buf >>= 8;\n s.bi_valid -= 8;\n }\n}\n\n\n/* ===========================================================================\n * Compute the optimal bit lengths for a tree and update the total bit length\n * for the current block.\n * IN assertion: the fields freq and dad are set, heap[heap_max] and\n * above are the tree nodes sorted by increasing frequency.\n * OUT assertions: the field len is set to the optimal bit length, the\n * array bl_count contains the frequencies for each bit length.\n * The length opt_len is updated; static_len is also updated if stree is\n * not null.\n */\nfunction gen_bitlen(s, desc)\n// deflate_state *s;\n// tree_desc *desc; /* the tree descriptor */\n{\n var tree = desc.dyn_tree;\n var max_code = desc.max_code;\n var stree = desc.stat_desc.static_tree;\n var has_stree = desc.stat_desc.has_stree;\n var extra = desc.stat_desc.extra_bits;\n var base = desc.stat_desc.extra_base;\n var max_length = desc.stat_desc.max_length;\n var h; /* heap index */\n var n, m; /* iterate over the tree elements */\n var bits; /* bit length */\n var xbits; /* extra bits */\n var f; /* frequency */\n var overflow = 0; /* number of elements with bit length too large */\n\n for (bits = 0; bits <= MAX_BITS; bits++) {\n s.bl_count[bits] = 0;\n }\n\n /* In a first pass, compute the optimal bit lengths (which may\n * overflow in the case of the bit length tree).\n */\n tree[s.heap[s.heap_max] * 2 + 1]/*.Len*/ = 0; /* root of the heap */\n\n for (h = s.heap_max + 1; h < HEAP_SIZE; h++) {\n n = s.heap[h];\n bits = tree[tree[n * 2 + 1]/*.Dad*/ * 2 + 1]/*.Len*/ + 1;\n if (bits > max_length) {\n bits = max_length;\n overflow++;\n }\n tree[n * 2 + 1]/*.Len*/ = bits;\n /* We overwrite tree[n].Dad which is no longer needed */\n\n if (n > max_code) { continue; } /* not a leaf node */\n\n s.bl_count[bits]++;\n xbits = 0;\n if (n >= base) {\n xbits = extra[n - base];\n }\n f = tree[n * 2]/*.Freq*/;\n s.opt_len += f * (bits + xbits);\n if (has_stree) {\n s.static_len += f * (stree[n * 2 + 1]/*.Len*/ + xbits);\n }\n }\n if (overflow === 0) { return; }\n\n // Trace((stderr,\"\\nbit length overflow\\n\"));\n /* This happens for example on obj2 and pic of the Calgary corpus */\n\n /* Find the first bit length which could increase: */\n do {\n bits = max_length - 1;\n while (s.bl_count[bits] === 0) { bits--; }\n s.bl_count[bits]--; /* move one leaf down the tree */\n s.bl_count[bits + 1] += 2; /* move one overflow item as its brother */\n s.bl_count[max_length]--;\n /* The brother of the overflow item also moves one step up,\n * but this does not affect bl_count[max_length]\n */\n overflow -= 2;\n } while (overflow > 0);\n\n /* Now recompute all bit lengths, scanning in increasing frequency.\n * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all\n * lengths instead of fixing only the wrong ones. This idea is taken\n * from 'ar' written by Haruhiko Okumura.)\n */\n for (bits = max_length; bits !== 0; bits--) {\n n = s.bl_count[bits];\n while (n !== 0) {\n m = s.heap[--h];\n if (m > max_code) { continue; }\n if (tree[m * 2 + 1]/*.Len*/ !== bits) {\n // Trace((stderr,\"code %d bits %d->%d\\n\", m, tree[m].Len, bits));\n s.opt_len += (bits - tree[m * 2 + 1]/*.Len*/) * tree[m * 2]/*.Freq*/;\n tree[m * 2 + 1]/*.Len*/ = bits;\n }\n n--;\n }\n }\n}\n\n\n/* ===========================================================================\n * Generate the codes for a given tree and bit counts (which need not be\n * optimal).\n * IN assertion: the array bl_count contains the bit length statistics for\n * the given tree and the field len is set for all tree elements.\n * OUT assertion: the field code is set for all tree elements of non\n * zero code length.\n */\nfunction gen_codes(tree, max_code, bl_count)\n// ct_data *tree; /* the tree to decorate */\n// int max_code; /* largest code with non zero frequency */\n// ushf *bl_count; /* number of codes at each bit length */\n{\n var next_code = new Array(MAX_BITS + 1); /* next code value for each bit length */\n var code = 0; /* running code value */\n var bits; /* bit index */\n var n; /* code index */\n\n /* The distribution counts are first used to generate the code values\n * without bit reversal.\n */\n for (bits = 1; bits <= MAX_BITS; bits++) {\n next_code[bits] = code = (code + bl_count[bits - 1]) << 1;\n }\n /* Check that the bit counts in bl_count are consistent. The last code\n * must be all ones.\n */\n //Assert (code + bl_count[MAX_BITS]-1 == (1<<MAX_BITS)-1,\n // \"inconsistent bit counts\");\n //Tracev((stderr,\"\\ngen_codes: max_code %d \", max_code));\n\n for (n = 0; n <= max_code; n++) {\n var len = tree[n * 2 + 1]/*.Len*/;\n if (len === 0) { continue; }\n /* Now reverse the bits */\n tree[n * 2]/*.Code*/ = bi_reverse(next_code[len]++, len);\n\n //Tracecv(tree != static_ltree, (stderr,\"\\nn %3d %c l %2d c %4x (%x) \",\n // n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len]-1));\n }\n}\n\n\n/* ===========================================================================\n * Initialize the various 'constant' tables.\n */\nfunction tr_static_init() {\n var n; /* iterates over tree elements */\n var bits; /* bit counter */\n var length; /* length value */\n var code; /* code value */\n var dist; /* distance index */\n var bl_count = new Array(MAX_BITS + 1);\n /* number of codes at each bit length for an optimal tree */\n\n // do check in _tr_init()\n //if (static_init_done) return;\n\n /* For some embedded targets, global variables are not initialized: */\n/*#ifdef NO_INIT_GLOBAL_POINTERS\n static_l_desc.static_tree = static_ltree;\n static_l_desc.extra_bits = extra_lbits;\n static_d_desc.static_tree = static_dtree;\n static_d_desc.extra_bits = extra_dbits;\n static_bl_desc.extra_bits = extra_blbits;\n#endif*/\n\n /* Initialize the mapping length (0..255) -> length code (0..28) */\n length = 0;\n for (code = 0; code < LENGTH_CODES - 1; code++) {\n base_length[code] = length;\n for (n = 0; n < (1 << extra_lbits[code]); n++) {\n _length_code[length++] = code;\n }\n }\n //Assert (length == 256, \"tr_static_init: length != 256\");\n /* Note that the length 255 (match length 258) can be represented\n * in two different ways: code 284 + 5 bits or code 285, so we\n * overwrite length_code[255] to use the best encoding:\n */\n _length_code[length - 1] = code;\n\n /* Initialize the mapping dist (0..32K) -> dist code (0..29) */\n dist = 0;\n for (code = 0; code < 16; code++) {\n base_dist[code] = dist;\n for (n = 0; n < (1 << extra_dbits[code]); n++) {\n _dist_code[dist++] = code;\n }\n }\n //Assert (dist == 256, \"tr_static_init: dist != 256\");\n dist >>= 7; /* from now on, all distances are divided by 128 */\n for (; code < D_CODES; code++) {\n base_dist[code] = dist << 7;\n for (n = 0; n < (1 << (extra_dbits[code] - 7)); n++) {\n _dist_code[256 + dist++] = code;\n }\n }\n //Assert (dist == 256, \"tr_static_init: 256+dist != 512\");\n\n /* Construct the codes of the static literal tree */\n for (bits = 0; bits <= MAX_BITS; bits++) {\n bl_count[bits] = 0;\n }\n\n n = 0;\n while (n <= 143) {\n static_ltree[n * 2 + 1]/*.Len*/ = 8;\n n++;\n bl_count[8]++;\n }\n while (n <= 255) {\n static_ltree[n * 2 + 1]/*.Len*/ = 9;\n n++;\n bl_count[9]++;\n }\n while (n <= 279) {\n static_ltree[n * 2 + 1]/*.Len*/ = 7;\n n++;\n bl_count[7]++;\n }\n while (n <= 287) {\n static_ltree[n * 2 + 1]/*.Len*/ = 8;\n n++;\n bl_count[8]++;\n }\n /* Codes 286 and 287 do not exist, but we must include them in the\n * tree construction to get a canonical Huffman tree (longest code\n * all ones)\n */\n gen_codes(static_ltree, L_CODES + 1, bl_count);\n\n /* The static distance tree is trivial: */\n for (n = 0; n < D_CODES; n++) {\n static_dtree[n * 2 + 1]/*.Len*/ = 5;\n static_dtree[n * 2]/*.Code*/ = bi_reverse(n, 5);\n }\n\n // Now data ready and we can init static trees\n static_l_desc = new StaticTreeDesc(static_ltree, extra_lbits, LITERALS + 1, L_CODES, MAX_BITS);\n static_d_desc = new StaticTreeDesc(static_dtree, extra_dbits, 0, D_CODES, MAX_BITS);\n static_bl_desc = new StaticTreeDesc(new Array(0), extra_blbits, 0, BL_CODES, MAX_BL_BITS);\n\n //static_init_done = true;\n}\n\n\n/* ===========================================================================\n * Initialize a new block.\n */\nfunction init_block(s) {\n var n; /* iterates over tree elements */\n\n /* Initialize the trees. */\n for (n = 0; n < L_CODES; n++) { s.dyn_ltree[n * 2]/*.Freq*/ = 0; }\n for (n = 0; n < D_CODES; n++) { s.dyn_dtree[n * 2]/*.Freq*/ = 0; }\n for (n = 0; n < BL_CODES; n++) { s.bl_tree[n * 2]/*.Freq*/ = 0; }\n\n s.dyn_ltree[END_BLOCK * 2]/*.Freq*/ = 1;\n s.opt_len = s.static_len = 0;\n s.last_lit = s.matches = 0;\n}\n\n\n/* ===========================================================================\n * Flush the bit buffer and align the output on a byte boundary\n */\nfunction bi_windup(s)\n{\n if (s.bi_valid > 8) {\n put_short(s, s.bi_buf);\n } else if (s.bi_valid > 0) {\n //put_byte(s, (Byte)s->bi_buf);\n s.pending_buf[s.pending++] = s.bi_buf;\n }\n s.bi_buf = 0;\n s.bi_valid = 0;\n}\n\n/* ===========================================================================\n * Copy a stored block, storing first the length and its\n * one's complement if requested.\n */\nfunction copy_block(s, buf, len, header)\n//DeflateState *s;\n//charf *buf; /* the input data */\n//unsigned len; /* its length */\n//int header; /* true if block header must be written */\n{\n bi_windup(s); /* align on byte boundary */\n\n if (header) {\n put_short(s, len);\n put_short(s, ~len);\n }\n// while (len--) {\n// put_byte(s, *buf++);\n// }\n utils.arraySet(s.pending_buf, s.window, buf, len, s.pending);\n s.pending += len;\n}\n\n/* ===========================================================================\n * Compares to subtrees, using the tree depth as tie breaker when\n * the subtrees have equal frequency. This minimizes the worst case length.\n */\nfunction smaller(tree, n, m, depth) {\n var _n2 = n * 2;\n var _m2 = m * 2;\n return (tree[_n2]/*.Freq*/ < tree[_m2]/*.Freq*/ ||\n (tree[_n2]/*.Freq*/ === tree[_m2]/*.Freq*/ && depth[n] <= depth[m]));\n}\n\n/* ===========================================================================\n * Restore the heap property by moving down the tree starting at node k,\n * exchanging a node with the smallest of its two sons if necessary, stopping\n * when the heap property is re-established (each father smaller than its\n * two sons).\n */\nfunction pqdownheap(s, tree, k)\n// deflate_state *s;\n// ct_data *tree; /* the tree to restore */\n// int k; /* node to move down */\n{\n var v = s.heap[k];\n var j = k << 1; /* left son of k */\n while (j <= s.heap_len) {\n /* Set j to the smallest of the two sons: */\n if (j < s.heap_len &&\n smaller(tree, s.heap[j + 1], s.heap[j], s.depth)) {\n j++;\n }\n /* Exit if v is smaller than both sons */\n if (smaller(tree, v, s.heap[j], s.depth)) { break; }\n\n /* Exchange v with the smallest son */\n s.heap[k] = s.heap[j];\n k = j;\n\n /* And continue down the tree, setting j to the left son of k */\n j <<= 1;\n }\n s.heap[k] = v;\n}\n\n\n// inlined manually\n// var SMALLEST = 1;\n\n/* ===========================================================================\n * Send the block data compressed using the given Huffman trees\n */\nfunction compress_block(s, ltree, dtree)\n// deflate_state *s;\n// const ct_data *ltree; /* literal tree */\n// const ct_data *dtree; /* distance tree */\n{\n var dist; /* distance of matched string */\n var lc; /* match length or unmatched char (if dist == 0) */\n var lx = 0; /* running index in l_buf */\n var code; /* the code to send */\n var extra; /* number of extra bits to send */\n\n if (s.last_lit !== 0) {\n do {\n dist = (s.pending_buf[s.d_buf + lx * 2] << 8) | (s.pending_buf[s.d_buf + lx * 2 + 1]);\n lc = s.pending_buf[s.l_buf + lx];\n lx++;\n\n if (dist === 0) {\n send_code(s, lc, ltree); /* send a literal byte */\n //Tracecv(isgraph(lc), (stderr,\" '%c' \", lc));\n } else {\n /* Here, lc is the match length - MIN_MATCH */\n code = _length_code[lc];\n send_code(s, code + LITERALS + 1, ltree); /* send the length code */\n extra = extra_lbits[code];\n if (extra !== 0) {\n lc -= base_length[code];\n send_bits(s, lc, extra); /* send the extra length bits */\n }\n dist--; /* dist is now the match distance - 1 */\n code = d_code(dist);\n //Assert (code < D_CODES, \"bad d_code\");\n\n send_code(s, code, dtree); /* send the distance code */\n extra = extra_dbits[code];\n if (extra !== 0) {\n dist -= base_dist[code];\n send_bits(s, dist, extra); /* send the extra distance bits */\n }\n } /* literal or match pair ? */\n\n /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */\n //Assert((uInt)(s->pending) < s->lit_bufsize + 2*lx,\n // \"pendingBuf overflow\");\n\n } while (lx < s.last_lit);\n }\n\n send_code(s, END_BLOCK, ltree);\n}\n\n\n/* ===========================================================================\n * Construct one Huffman tree and assigns the code bit strings and lengths.\n * Update the total bit length for the current block.\n * IN assertion: the field freq is set for all tree elements.\n * OUT assertions: the fields len and code are set to the optimal bit length\n * and corresponding code. The length opt_len is updated; static_len is\n * also updated if stree is not null. The field max_code is set.\n */\nfunction build_tree(s, desc)\n// deflate_state *s;\n// tree_desc *desc; /* the tree descriptor */\n{\n var tree = desc.dyn_tree;\n var stree = desc.stat_desc.static_tree;\n var has_stree = desc.stat_desc.has_stree;\n var elems = desc.stat_desc.elems;\n var n, m; /* iterate over heap elements */\n var max_code = -1; /* largest code with non zero frequency */\n var node; /* new node being created */\n\n /* Construct the initial heap, with least frequent element in\n * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1].\n * heap[0] is not used.\n */\n s.heap_len = 0;\n s.heap_max = HEAP_SIZE;\n\n for (n = 0; n < elems; n++) {\n if (tree[n * 2]/*.Freq*/ !== 0) {\n s.heap[++s.heap_len] = max_code = n;\n s.depth[n] = 0;\n\n } else {\n tree[n * 2 + 1]/*.Len*/ = 0;\n }\n }\n\n /* The pkzip format requires that at least one distance code exists,\n * and that at least one bit should be sent even if there is only one\n * possible code. So to avoid special checks later on we force at least\n * two codes of non zero frequency.\n */\n while (s.heap_len < 2) {\n node = s.heap[++s.heap_len] = (max_code < 2 ? ++max_code : 0);\n tree[node * 2]/*.Freq*/ = 1;\n s.depth[node] = 0;\n s.opt_len--;\n\n if (has_stree) {\n s.static_len -= stree[node * 2 + 1]/*.Len*/;\n }\n /* node is 0 or 1 so it does not have extra bits */\n }\n desc.max_code = max_code;\n\n /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree,\n * establish sub-heaps of increasing lengths:\n */\n for (n = (s.heap_len >> 1/*int /2*/); n >= 1; n--) { pqdownheap(s, tree, n); }\n\n /* Construct the Huffman tree by repeatedly combining the least two\n * frequent nodes.\n */\n node = elems; /* next internal node of the tree */\n do {\n //pqremove(s, tree, n); /* n = node of least frequency */\n /*** pqremove ***/\n n = s.heap[1/*SMALLEST*/];\n s.heap[1/*SMALLEST*/] = s.heap[s.heap_len--];\n pqdownheap(s, tree, 1/*SMALLEST*/);\n /***/\n\n m = s.heap[1/*SMALLEST*/]; /* m = node of next least frequency */\n\n s.heap[--s.heap_max] = n; /* keep the nodes sorted by frequency */\n s.heap[--s.heap_max] = m;\n\n /* Create a new node father of n and m */\n tree[node * 2]/*.Freq*/ = tree[n * 2]/*.Freq*/ + tree[m * 2]/*.Freq*/;\n s.depth[node] = (s.depth[n] >= s.depth[m] ? s.depth[n] : s.depth[m]) + 1;\n tree[n * 2 + 1]/*.Dad*/ = tree[m * 2 + 1]/*.Dad*/ = node;\n\n /* and insert the new node in the heap */\n s.heap[1/*SMALLEST*/] = node++;\n pqdownheap(s, tree, 1/*SMALLEST*/);\n\n } while (s.heap_len >= 2);\n\n s.heap[--s.heap_max] = s.heap[1/*SMALLEST*/];\n\n /* At this point, the fields freq and dad are set. We can now\n * generate the bit lengths.\n */\n gen_bitlen(s, desc);\n\n /* The field len is now set, we can generate the bit codes */\n gen_codes(tree, max_code, s.bl_count);\n}\n\n\n/* ===========================================================================\n * Scan a literal or distance tree to determine the frequencies of the codes\n * in the bit length tree.\n */\nfunction scan_tree(s, tree, max_code)\n// deflate_state *s;\n// ct_data *tree; /* the tree to be scanned */\n// int max_code; /* and its largest code of non zero frequency */\n{\n var n; /* iterates over all tree elements */\n var prevlen = -1; /* last emitted length */\n var curlen; /* length of current code */\n\n var nextlen = tree[0 * 2 + 1]/*.Len*/; /* length of next code */\n\n var count = 0; /* repeat count of the current code */\n var max_count = 7; /* max repeat count */\n var min_count = 4; /* min repeat count */\n\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n }\n tree[(max_code + 1) * 2 + 1]/*.Len*/ = 0xffff; /* guard */\n\n for (n = 0; n <= max_code; n++) {\n curlen = nextlen;\n nextlen = tree[(n + 1) * 2 + 1]/*.Len*/;\n\n if (++count < max_count && curlen === nextlen) {\n continue;\n\n } else if (count < min_count) {\n s.bl_tree[curlen * 2]/*.Freq*/ += count;\n\n } else if (curlen !== 0) {\n\n if (curlen !== prevlen) { s.bl_tree[curlen * 2]/*.Freq*/++; }\n s.bl_tree[REP_3_6 * 2]/*.Freq*/++;\n\n } else if (count <= 10) {\n s.bl_tree[REPZ_3_10 * 2]/*.Freq*/++;\n\n } else {\n s.bl_tree[REPZ_11_138 * 2]/*.Freq*/++;\n }\n\n count = 0;\n prevlen = curlen;\n\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n\n } else if (curlen === nextlen) {\n max_count = 6;\n min_count = 3;\n\n } else {\n max_count = 7;\n min_count = 4;\n }\n }\n}\n\n\n/* ===========================================================================\n * Send a literal or distance tree in compressed form, using the codes in\n * bl_tree.\n */\nfunction send_tree(s, tree, max_code)\n// deflate_state *s;\n// ct_data *tree; /* the tree to be scanned */\n// int max_code; /* and its largest code of non zero frequency */\n{\n var n; /* iterates over all tree elements */\n var prevlen = -1; /* last emitted length */\n var curlen; /* length of current code */\n\n var nextlen = tree[0 * 2 + 1]/*.Len*/; /* length of next code */\n\n var count = 0; /* repeat count of the current code */\n var max_count = 7; /* max repeat count */\n var min_count = 4; /* min repeat count */\n\n /* tree[max_code+1].Len = -1; */ /* guard already set */\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n }\n\n for (n = 0; n <= max_code; n++) {\n curlen = nextlen;\n nextlen = tree[(n + 1) * 2 + 1]/*.Len*/;\n\n if (++count < max_count && curlen === nextlen) {\n continue;\n\n } else if (count < min_count) {\n do { send_code(s, curlen, s.bl_tree); } while (--count !== 0);\n\n } else if (curlen !== 0) {\n if (curlen !== prevlen) {\n send_code(s, curlen, s.bl_tree);\n count--;\n }\n //Assert(count >= 3 && count <= 6, \" 3_6?\");\n send_code(s, REP_3_6, s.bl_tree);\n send_bits(s, count - 3, 2);\n\n } else if (count <= 10) {\n send_code(s, REPZ_3_10, s.bl_tree);\n send_bits(s, count - 3, 3);\n\n } else {\n send_code(s, REPZ_11_138, s.bl_tree);\n send_bits(s, count - 11, 7);\n }\n\n count = 0;\n prevlen = curlen;\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n\n } else if (curlen === nextlen) {\n max_count = 6;\n min_count = 3;\n\n } else {\n max_count = 7;\n min_count = 4;\n }\n }\n}\n\n\n/* ===========================================================================\n * Construct the Huffman tree for the bit lengths and return the index in\n * bl_order of the last bit length code to send.\n */\nfunction build_bl_tree(s) {\n var max_blindex; /* index of last bit length code of non zero freq */\n\n /* Determine the bit length frequencies for literal and distance trees */\n scan_tree(s, s.dyn_ltree, s.l_desc.max_code);\n scan_tree(s, s.dyn_dtree, s.d_desc.max_code);\n\n /* Build the bit length tree: */\n build_tree(s, s.bl_desc);\n /* opt_len now includes the length of the tree representations, except\n * the lengths of the bit lengths codes and the 5+5+4 bits for the counts.\n */\n\n /* Determine the number of bit length codes to send. The pkzip format\n * requires that at least 4 bit length codes be sent. (appnote.txt says\n * 3 but the actual value used is 4.)\n */\n for (max_blindex = BL_CODES - 1; max_blindex >= 3; max_blindex--) {\n if (s.bl_tree[bl_order[max_blindex] * 2 + 1]/*.Len*/ !== 0) {\n break;\n }\n }\n /* Update opt_len to include the bit length tree and counts */\n s.opt_len += 3 * (max_blindex + 1) + 5 + 5 + 4;\n //Tracev((stderr, \"\\ndyn trees: dyn %ld, stat %ld\",\n // s->opt_len, s->static_len));\n\n return max_blindex;\n}\n\n\n/* ===========================================================================\n * Send the header for a block using dynamic Huffman trees: the counts, the\n * lengths of the bit length codes, the literal tree and the distance tree.\n * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4.\n */\nfunction send_all_trees(s, lcodes, dcodes, blcodes)\n// deflate_state *s;\n// int lcodes, dcodes, blcodes; /* number of codes for each tree */\n{\n var rank; /* index in bl_order */\n\n //Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, \"not enough codes\");\n //Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES,\n // \"too many codes\");\n //Tracev((stderr, \"\\nbl counts: \"));\n send_bits(s, lcodes - 257, 5); /* not +255 as stated in appnote.txt */\n send_bits(s, dcodes - 1, 5);\n send_bits(s, blcodes - 4, 4); /* not -3 as stated in appnote.txt */\n for (rank = 0; rank < blcodes; rank++) {\n //Tracev((stderr, \"\\nbl code %2d \", bl_order[rank]));\n send_bits(s, s.bl_tree[bl_order[rank] * 2 + 1]/*.Len*/, 3);\n }\n //Tracev((stderr, \"\\nbl tree: sent %ld\", s->bits_sent));\n\n send_tree(s, s.dyn_ltree, lcodes - 1); /* literal tree */\n //Tracev((stderr, \"\\nlit tree: sent %ld\", s->bits_sent));\n\n send_tree(s, s.dyn_dtree, dcodes - 1); /* distance tree */\n //Tracev((stderr, \"\\ndist tree: sent %ld\", s->bits_sent));\n}\n\n\n/* ===========================================================================\n * Check if the data type is TEXT or BINARY, using the following algorithm:\n * - TEXT if the two conditions below are satisfied:\n * a) There are no non-portable control characters belonging to the\n * \"black list\" (0..6, 14..25, 28..31).\n * b) There is at least one printable character belonging to the\n * \"white list\" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255).\n * - BINARY otherwise.\n * - The following partially-portable control characters form a\n * \"gray list\" that is ignored in this detection algorithm:\n * (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}).\n * IN assertion: the fields Freq of dyn_ltree are set.\n */\nfunction detect_data_type(s) {\n /* black_mask is the bit mask of black-listed bytes\n * set bits 0..6, 14..25, and 28..31\n * 0xf3ffc07f = binary 11110011111111111100000001111111\n */\n var black_mask = 0xf3ffc07f;\n var n;\n\n /* Check for non-textual (\"black-listed\") bytes. */\n for (n = 0; n <= 31; n++, black_mask >>>= 1) {\n if ((black_mask & 1) && (s.dyn_ltree[n * 2]/*.Freq*/ !== 0)) {\n return Z_BINARY;\n }\n }\n\n /* Check for textual (\"white-listed\") bytes. */\n if (s.dyn_ltree[9 * 2]/*.Freq*/ !== 0 || s.dyn_ltree[10 * 2]/*.Freq*/ !== 0 ||\n s.dyn_ltree[13 * 2]/*.Freq*/ !== 0) {\n return Z_TEXT;\n }\n for (n = 32; n < LITERALS; n++) {\n if (s.dyn_ltree[n * 2]/*.Freq*/ !== 0) {\n return Z_TEXT;\n }\n }\n\n /* There are no \"black-listed\" or \"white-listed\" bytes:\n * this stream either is empty or has tolerated (\"gray-listed\") bytes only.\n */\n return Z_BINARY;\n}\n\n\nvar static_init_done = false;\n\n/* ===========================================================================\n * Initialize the tree data structures for a new zlib stream.\n */\nfunction _tr_init(s)\n{\n\n if (!static_init_done) {\n tr_static_init();\n static_init_done = true;\n }\n\n s.l_desc = new TreeDesc(s.dyn_ltree, static_l_desc);\n s.d_desc = new TreeDesc(s.dyn_dtree, static_d_desc);\n s.bl_desc = new TreeDesc(s.bl_tree, static_bl_desc);\n\n s.bi_buf = 0;\n s.bi_valid = 0;\n\n /* Initialize the first block of the first file: */\n init_block(s);\n}\n\n\n/* ===========================================================================\n * Send a stored block\n */\nfunction _tr_stored_block(s, buf, stored_len, last)\n//DeflateState *s;\n//charf *buf; /* input block */\n//ulg stored_len; /* length of input block */\n//int last; /* one if this is the last block for a file */\n{\n send_bits(s, (STORED_BLOCK << 1) + (last ? 1 : 0), 3); /* send block type */\n copy_block(s, buf, stored_len, true); /* with header */\n}\n\n\n/* ===========================================================================\n * Send one empty static block to give enough lookahead for inflate.\n * This takes 10 bits, of which 7 may remain in the bit buffer.\n */\nfunction _tr_align(s) {\n send_bits(s, STATIC_TREES << 1, 3);\n send_code(s, END_BLOCK, static_ltree);\n bi_flush(s);\n}\n\n\n/* ===========================================================================\n * Determine the best encoding for the current block: dynamic trees, static\n * trees or store, and output the encoded block to the zip file.\n */\nfunction _tr_flush_block(s, buf, stored_len, last)\n//DeflateState *s;\n//charf *buf; /* input block, or NULL if too old */\n//ulg stored_len; /* length of input block */\n//int last; /* one if this is the last block for a file */\n{\n var opt_lenb, static_lenb; /* opt_len and static_len in bytes */\n var max_blindex = 0; /* index of last bit length code of non zero freq */\n\n /* Build the Huffman trees unless a stored block is forced */\n if (s.level > 0) {\n\n /* Check if the file is binary or text */\n if (s.strm.data_type === Z_UNKNOWN) {\n s.strm.data_type = detect_data_type(s);\n }\n\n /* Construct the literal and distance trees */\n build_tree(s, s.l_desc);\n // Tracev((stderr, \"\\nlit data: dyn %ld, stat %ld\", s->opt_len,\n // s->static_len));\n\n build_tree(s, s.d_desc);\n // Tracev((stderr, \"\\ndist data: dyn %ld, stat %ld\", s->opt_len,\n // s->static_len));\n /* At this point, opt_len and static_len are the total bit lengths of\n * the compressed block data, excluding the tree representations.\n */\n\n /* Build the bit length tree for the above two trees, and get the index\n * in bl_order of the last bit length code to send.\n */\n max_blindex = build_bl_tree(s);\n\n /* Determine the best encoding. Compute the block lengths in bytes. */\n opt_lenb = (s.opt_len + 3 + 7) >>> 3;\n static_lenb = (s.static_len + 3 + 7) >>> 3;\n\n // Tracev((stderr, \"\\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u \",\n // opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len,\n // s->last_lit));\n\n if (static_lenb <= opt_lenb) { opt_lenb = static_lenb; }\n\n } else {\n // Assert(buf != (char*)0, \"lost buf\");\n opt_lenb = static_lenb = stored_len + 5; /* force a stored block */\n }\n\n if ((stored_len + 4 <= opt_lenb) && (buf !== -1)) {\n /* 4: two words for the lengths */\n\n /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE.\n * Otherwise we can't have processed more than WSIZE input bytes since\n * the last block flush, because compression would have been\n * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to\n * transform a block into a stored block.\n */\n _tr_stored_block(s, buf, stored_len, last);\n\n } else if (s.strategy === Z_FIXED || static_lenb === opt_lenb) {\n\n send_bits(s, (STATIC_TREES << 1) + (last ? 1 : 0), 3);\n compress_block(s, static_ltree, static_dtree);\n\n } else {\n send_bits(s, (DYN_TREES << 1) + (last ? 1 : 0), 3);\n send_all_trees(s, s.l_desc.max_code + 1, s.d_desc.max_code + 1, max_blindex + 1);\n compress_block(s, s.dyn_ltree, s.dyn_dtree);\n }\n // Assert (s->compressed_len == s->bits_sent, \"bad compressed size\");\n /* The above check is made mod 2^32, for files larger than 512 MB\n * and uLong implemented on 32 bits.\n */\n init_block(s);\n\n if (last) {\n bi_windup(s);\n }\n // Tracev((stderr,\"\\ncomprlen %lu(%lu) \", s->compressed_len>>3,\n // s->compressed_len-7*last));\n}\n\n/* ===========================================================================\n * Save the match info and tally the frequency counts. Return true if\n * the current block must be flushed.\n */\nfunction _tr_tally(s, dist, lc)\n// deflate_state *s;\n// unsigned dist; /* distance of matched string */\n// unsigned lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */\n{\n //var out_length, in_length, dcode;\n\n s.pending_buf[s.d_buf + s.last_lit * 2] = (dist >>> 8) & 0xff;\n s.pending_buf[s.d_buf + s.last_lit * 2 + 1] = dist & 0xff;\n\n s.pending_buf[s.l_buf + s.last_lit] = lc & 0xff;\n s.last_lit++;\n\n if (dist === 0) {\n /* lc is the unmatched char */\n s.dyn_ltree[lc * 2]/*.Freq*/++;\n } else {\n s.matches++;\n /* Here, lc is the match length - MIN_MATCH */\n dist--; /* dist = match distance - 1 */\n //Assert((ush)dist < (ush)MAX_DIST(s) &&\n // (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) &&\n // (ush)d_code(dist) < (ush)D_CODES, \"_tr_tally: bad match\");\n\n s.dyn_ltree[(_length_code[lc] + LITERALS + 1) * 2]/*.Freq*/++;\n s.dyn_dtree[d_code(dist) * 2]/*.Freq*/++;\n }\n\n// (!) This block is disabled in zlib defaults,\n// don't enable it for binary compatibility\n\n//#ifdef TRUNCATE_BLOCK\n// /* Try to guess if it is profitable to stop the current block here */\n// if ((s.last_lit & 0x1fff) === 0 && s.level > 2) {\n// /* Compute an upper bound for the compressed length */\n// out_length = s.last_lit*8;\n// in_length = s.strstart - s.block_start;\n//\n// for (dcode = 0; dcode < D_CODES; dcode++) {\n// out_length += s.dyn_dtree[dcode*2]/*.Freq*/ * (5 + extra_dbits[dcode]);\n// }\n// out_length >>>= 3;\n// //Tracev((stderr,\"\\nlast_lit %u, in %ld, out ~%ld(%ld%%) \",\n// // s->last_lit, in_length, out_length,\n// // 100L - out_length*100L/in_length));\n// if (s.matches < (s.last_lit>>1)/*int /2*/ && out_length < (in_length>>1)/*int /2*/) {\n// return true;\n// }\n// }\n//#endif\n\n return (s.last_lit === s.lit_bufsize - 1);\n /* We avoid equality with lit_bufsize because of wraparound at 64K\n * on 16 bit machines and because stored blocks are restricted to\n * 64K-1 bytes.\n */\n}\n\nexports._tr_init = _tr_init;\nexports._tr_stored_block = _tr_stored_block;\nexports._tr_flush_block = _tr_flush_block;\nexports._tr_tally = _tr_tally;\nexports._tr_align = _tr_align;\n","'use strict';\n\n// Note: adler32 takes 12% for level 0 and 2% for level 6.\n// It isn't worth it to make additional optimizations as in original.\n// Small size is preferable.\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nfunction adler32(adler, buf, len, pos) {\n var s1 = (adler & 0xffff) |0,\n s2 = ((adler >>> 16) & 0xffff) |0,\n n = 0;\n\n while (len !== 0) {\n // Set limit ~ twice less than 5552, to keep\n // s2 in 31-bits, because we force signed ints.\n // in other case %= will fail.\n n = len > 2000 ? 2000 : len;\n len -= n;\n\n do {\n s1 = (s1 + buf[pos++]) |0;\n s2 = (s2 + s1) |0;\n } while (--n);\n\n s1 %= 65521;\n s2 %= 65521;\n }\n\n return (s1 | (s2 << 16)) |0;\n}\n\n\nmodule.exports = adler32;\n","'use strict';\n\n// Note: we can't get significant speed boost here.\n// So write code to minimize size - no pregenerated tables\n// and array tools dependencies.\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\n// Use ordinary array, since untyped makes no boost here\nfunction makeTable() {\n var c, table = [];\n\n for (var n = 0; n < 256; n++) {\n c = n;\n for (var k = 0; k < 8; k++) {\n c = ((c & 1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));\n }\n table[n] = c;\n }\n\n return table;\n}\n\n// Create table on load. Just 255 signed longs. Not a problem.\nvar crcTable = makeTable();\n\n\nfunction crc32(crc, buf, len, pos) {\n var t = crcTable,\n end = pos + len;\n\n crc ^= -1;\n\n for (var i = pos; i < end; i++) {\n crc = (crc >>> 8) ^ t[(crc ^ buf[i]) & 0xFF];\n }\n\n return (crc ^ (-1)); // >>> 0;\n}\n\n\nmodule.exports = crc32;\n","'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nvar utils = require('../utils/common');\nvar trees = require('./trees');\nvar adler32 = require('./adler32');\nvar crc32 = require('./crc32');\nvar msg = require('./messages');\n\n/* Public constants ==========================================================*/\n/* ===========================================================================*/\n\n\n/* Allowed flush values; see deflate() and inflate() below for details */\nvar Z_NO_FLUSH = 0;\nvar Z_PARTIAL_FLUSH = 1;\n//var Z_SYNC_FLUSH = 2;\nvar Z_FULL_FLUSH = 3;\nvar Z_FINISH = 4;\nvar Z_BLOCK = 5;\n//var Z_TREES = 6;\n\n\n/* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\nvar Z_OK = 0;\nvar Z_STREAM_END = 1;\n//var Z_NEED_DICT = 2;\n//var Z_ERRNO = -1;\nvar Z_STREAM_ERROR = -2;\nvar Z_DATA_ERROR = -3;\n//var Z_MEM_ERROR = -4;\nvar Z_BUF_ERROR = -5;\n//var Z_VERSION_ERROR = -6;\n\n\n/* compression levels */\n//var Z_NO_COMPRESSION = 0;\n//var Z_BEST_SPEED = 1;\n//var Z_BEST_COMPRESSION = 9;\nvar Z_DEFAULT_COMPRESSION = -1;\n\n\nvar Z_FILTERED = 1;\nvar Z_HUFFMAN_ONLY = 2;\nvar Z_RLE = 3;\nvar Z_FIXED = 4;\nvar Z_DEFAULT_STRATEGY = 0;\n\n/* Possible values of the data_type field (though see inflate()) */\n//var Z_BINARY = 0;\n//var Z_TEXT = 1;\n//var Z_ASCII = 1; // = Z_TEXT\nvar Z_UNKNOWN = 2;\n\n\n/* The deflate compression method */\nvar Z_DEFLATED = 8;\n\n/*============================================================================*/\n\n\nvar MAX_MEM_LEVEL = 9;\n/* Maximum value for memLevel in deflateInit2 */\nvar MAX_WBITS = 15;\n/* 32K LZ77 window */\nvar DEF_MEM_LEVEL = 8;\n\n\nvar LENGTH_CODES = 29;\n/* number of length codes, not counting the special END_BLOCK code */\nvar LITERALS = 256;\n/* number of literal bytes 0..255 */\nvar L_CODES = LITERALS + 1 + LENGTH_CODES;\n/* number of Literal or Length codes, including the END_BLOCK code */\nvar D_CODES = 30;\n/* number of distance codes */\nvar BL_CODES = 19;\n/* number of codes used to transfer the bit lengths */\nvar HEAP_SIZE = 2 * L_CODES + 1;\n/* maximum heap size */\nvar MAX_BITS = 15;\n/* All codes must not exceed MAX_BITS bits */\n\nvar MIN_MATCH = 3;\nvar MAX_MATCH = 258;\nvar MIN_LOOKAHEAD = (MAX_MATCH + MIN_MATCH + 1);\n\nvar PRESET_DICT = 0x20;\n\nvar INIT_STATE = 42;\nvar EXTRA_STATE = 69;\nvar NAME_STATE = 73;\nvar COMMENT_STATE = 91;\nvar HCRC_STATE = 103;\nvar BUSY_STATE = 113;\nvar FINISH_STATE = 666;\n\nvar BS_NEED_MORE = 1; /* block not completed, need more input or more output */\nvar BS_BLOCK_DONE = 2; /* block flush performed */\nvar BS_FINISH_STARTED = 3; /* finish started, need only more output at next deflate */\nvar BS_FINISH_DONE = 4; /* finish done, accept no more input or output */\n\nvar OS_CODE = 0x03; // Unix :) . Don't detect, use this default.\n\nfunction err(strm, errorCode) {\n strm.msg = msg[errorCode];\n return errorCode;\n}\n\nfunction rank(f) {\n return ((f) << 1) - ((f) > 4 ? 9 : 0);\n}\n\nfunction zero(buf) { var len = buf.length; while (--len >= 0) { buf[len] = 0; } }\n\n\n/* =========================================================================\n * Flush as much pending output as possible. All deflate() output goes\n * through this function so some applications may wish to modify it\n * to avoid allocating a large strm->output buffer and copying into it.\n * (See also read_buf()).\n */\nfunction flush_pending(strm) {\n var s = strm.state;\n\n //_tr_flush_bits(s);\n var len = s.pending;\n if (len > strm.avail_out) {\n len = strm.avail_out;\n }\n if (len === 0) { return; }\n\n utils.arraySet(strm.output, s.pending_buf, s.pending_out, len, strm.next_out);\n strm.next_out += len;\n s.pending_out += len;\n strm.total_out += len;\n strm.avail_out -= len;\n s.pending -= len;\n if (s.pending === 0) {\n s.pending_out = 0;\n }\n}\n\n\nfunction flush_block_only(s, last) {\n trees._tr_flush_block(s, (s.block_start >= 0 ? s.block_start : -1), s.strstart - s.block_start, last);\n s.block_start = s.strstart;\n flush_pending(s.strm);\n}\n\n\nfunction put_byte(s, b) {\n s.pending_buf[s.pending++] = b;\n}\n\n\n/* =========================================================================\n * Put a short in the pending buffer. The 16-bit value is put in MSB order.\n * IN assertion: the stream state is correct and there is enough room in\n * pending_buf.\n */\nfunction putShortMSB(s, b) {\n// put_byte(s, (Byte)(b >> 8));\n// put_byte(s, (Byte)(b & 0xff));\n s.pending_buf[s.pending++] = (b >>> 8) & 0xff;\n s.pending_buf[s.pending++] = b & 0xff;\n}\n\n\n/* ===========================================================================\n * Read a new buffer from the current input stream, update the adler32\n * and total number of bytes read. All deflate() input goes through\n * this function so some applications may wish to modify it to avoid\n * allocating a large strm->input buffer and copying from it.\n * (See also flush_pending()).\n */\nfunction read_buf(strm, buf, start, size) {\n var len = strm.avail_in;\n\n if (len > size) { len = size; }\n if (len === 0) { return 0; }\n\n strm.avail_in -= len;\n\n // zmemcpy(buf, strm->next_in, len);\n utils.arraySet(buf, strm.input, strm.next_in, len, start);\n if (strm.state.wrap === 1) {\n strm.adler = adler32(strm.adler, buf, len, start);\n }\n\n else if (strm.state.wrap === 2) {\n strm.adler = crc32(strm.adler, buf, len, start);\n }\n\n strm.next_in += len;\n strm.total_in += len;\n\n return len;\n}\n\n\n/* ===========================================================================\n * Set match_start to the longest match starting at the given string and\n * return its length. Matches shorter or equal to prev_length are discarded,\n * in which case the result is equal to prev_length and match_start is\n * garbage.\n * IN assertions: cur_match is the head of the hash chain for the current\n * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1\n * OUT assertion: the match length is not greater than s->lookahead.\n */\nfunction longest_match(s, cur_match) {\n var chain_length = s.max_chain_length; /* max hash chain length */\n var scan = s.strstart; /* current string */\n var match; /* matched string */\n var len; /* length of current match */\n var best_len = s.prev_length; /* best match length so far */\n var nice_match = s.nice_match; /* stop if match long enough */\n var limit = (s.strstart > (s.w_size - MIN_LOOKAHEAD)) ?\n s.strstart - (s.w_size - MIN_LOOKAHEAD) : 0/*NIL*/;\n\n var _win = s.window; // shortcut\n\n var wmask = s.w_mask;\n var prev = s.prev;\n\n /* Stop when cur_match becomes <= limit. To simplify the code,\n * we prevent matches with the string of window index 0.\n */\n\n var strend = s.strstart + MAX_MATCH;\n var scan_end1 = _win[scan + best_len - 1];\n var scan_end = _win[scan + best_len];\n\n /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.\n * It is easy to get rid of this optimization if necessary.\n */\n // Assert(s->hash_bits >= 8 && MAX_MATCH == 258, \"Code too clever\");\n\n /* Do not waste too much time if we already have a good match: */\n if (s.prev_length >= s.good_match) {\n chain_length >>= 2;\n }\n /* Do not look for matches beyond the end of the input. This is necessary\n * to make deflate deterministic.\n */\n if (nice_match > s.lookahead) { nice_match = s.lookahead; }\n\n // Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, \"need lookahead\");\n\n do {\n // Assert(cur_match < s->strstart, \"no future\");\n match = cur_match;\n\n /* Skip to next match if the match length cannot increase\n * or if the match length is less than 2. Note that the checks below\n * for insufficient lookahead only occur occasionally for performance\n * reasons. Therefore uninitialized memory will be accessed, and\n * conditional jumps will be made that depend on those values.\n * However the length of the match is limited to the lookahead, so\n * the output of deflate is not affected by the uninitialized values.\n */\n\n if (_win[match + best_len] !== scan_end ||\n _win[match + best_len - 1] !== scan_end1 ||\n _win[match] !== _win[scan] ||\n _win[++match] !== _win[scan + 1]) {\n continue;\n }\n\n /* The check at best_len-1 can be removed because it will be made\n * again later. (This heuristic is not always a win.)\n * It is not necessary to compare scan[2] and match[2] since they\n * are always equal when the other bytes match, given that\n * the hash keys are equal and that HASH_BITS >= 8.\n */\n scan += 2;\n match++;\n // Assert(*scan == *match, \"match[2]?\");\n\n /* We check for insufficient lookahead only every 8th comparison;\n * the 256th check will be made at strstart+258.\n */\n do {\n /*jshint noempty:false*/\n } while (_win[++scan] === _win[++match] && _win[++scan] === _win[++match] &&\n _win[++scan] === _win[++match] && _win[++scan] === _win[++match] &&\n _win[++scan] === _win[++match] && _win[++scan] === _win[++match] &&\n _win[++scan] === _win[++match] && _win[++scan] === _win[++match] &&\n scan < strend);\n\n // Assert(scan <= s->window+(unsigned)(s->window_size-1), \"wild scan\");\n\n len = MAX_MATCH - (strend - scan);\n scan = strend - MAX_MATCH;\n\n if (len > best_len) {\n s.match_start = cur_match;\n best_len = len;\n if (len >= nice_match) {\n break;\n }\n scan_end1 = _win[scan + best_len - 1];\n scan_end = _win[scan + best_len];\n }\n } while ((cur_match = prev[cur_match & wmask]) > limit && --chain_length !== 0);\n\n if (best_len <= s.lookahead) {\n return best_len;\n }\n return s.lookahead;\n}\n\n\n/* ===========================================================================\n * Fill the window when the lookahead becomes insufficient.\n * Updates strstart and lookahead.\n *\n * IN assertion: lookahead < MIN_LOOKAHEAD\n * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD\n * At least one byte has been read, or avail_in == 0; reads are\n * performed for at least two bytes (required for the zip translate_eol\n * option -- not supported here).\n */\nfunction fill_window(s) {\n var _w_size = s.w_size;\n var p, n, m, more, str;\n\n //Assert(s->lookahead < MIN_LOOKAHEAD, \"already enough lookahead\");\n\n do {\n more = s.window_size - s.lookahead - s.strstart;\n\n // JS ints have 32 bit, block below not needed\n /* Deal with !@#$% 64K limit: */\n //if (sizeof(int) <= 2) {\n // if (more == 0 && s->strstart == 0 && s->lookahead == 0) {\n // more = wsize;\n //\n // } else if (more == (unsigned)(-1)) {\n // /* Very unlikely, but possible on 16 bit machine if\n // * strstart == 0 && lookahead == 1 (input done a byte at time)\n // */\n // more--;\n // }\n //}\n\n\n /* If the window is almost full and there is insufficient lookahead,\n * move the upper half to the lower one to make room in the upper half.\n */\n if (s.strstart >= _w_size + (_w_size - MIN_LOOKAHEAD)) {\n\n utils.arraySet(s.window, s.window, _w_size, _w_size, 0);\n s.match_start -= _w_size;\n s.strstart -= _w_size;\n /* we now have strstart >= MAX_DIST */\n s.block_start -= _w_size;\n\n /* Slide the hash table (could be avoided with 32 bit values\n at the expense of memory usage). We slide even when level == 0\n to keep the hash table consistent if we switch back to level > 0\n later. (Using level 0 permanently is not an optimal usage of\n zlib, so we don't care about this pathological case.)\n */\n\n n = s.hash_size;\n p = n;\n do {\n m = s.head[--p];\n s.head[p] = (m >= _w_size ? m - _w_size : 0);\n } while (--n);\n\n n = _w_size;\n p = n;\n do {\n m = s.prev[--p];\n s.prev[p] = (m >= _w_size ? m - _w_size : 0);\n /* If n is not on any hash chain, prev[n] is garbage but\n * its value will never be used.\n */\n } while (--n);\n\n more += _w_size;\n }\n if (s.strm.avail_in === 0) {\n break;\n }\n\n /* If there was no sliding:\n * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 &&\n * more == window_size - lookahead - strstart\n * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1)\n * => more >= window_size - 2*WSIZE + 2\n * In the BIG_MEM or MMAP case (not yet supported),\n * window_size == input_size + MIN_LOOKAHEAD &&\n * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD.\n * Otherwise, window_size == 2*WSIZE so more >= 2.\n * If there was sliding, more >= WSIZE. So in all cases, more >= 2.\n */\n //Assert(more >= 2, \"more < 2\");\n n = read_buf(s.strm, s.window, s.strstart + s.lookahead, more);\n s.lookahead += n;\n\n /* Initialize the hash value now that we have some input: */\n if (s.lookahead + s.insert >= MIN_MATCH) {\n str = s.strstart - s.insert;\n s.ins_h = s.window[str];\n\n /* UPDATE_HASH(s, s->ins_h, s->window[str + 1]); */\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[str + 1]) & s.hash_mask;\n//#if MIN_MATCH != 3\n// Call update_hash() MIN_MATCH-3 more times\n//#endif\n while (s.insert) {\n /* UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); */\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[str + MIN_MATCH - 1]) & s.hash_mask;\n\n s.prev[str & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = str;\n str++;\n s.insert--;\n if (s.lookahead + s.insert < MIN_MATCH) {\n break;\n }\n }\n }\n /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage,\n * but this is not important since only literal bytes will be emitted.\n */\n\n } while (s.lookahead < MIN_LOOKAHEAD && s.strm.avail_in !== 0);\n\n /* If the WIN_INIT bytes after the end of the current data have never been\n * written, then zero those bytes in order to avoid memory check reports of\n * the use of uninitialized (or uninitialised as Julian writes) bytes by\n * the longest match routines. Update the high water mark for the next\n * time through here. WIN_INIT is set to MAX_MATCH since the longest match\n * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead.\n */\n// if (s.high_water < s.window_size) {\n// var curr = s.strstart + s.lookahead;\n// var init = 0;\n//\n// if (s.high_water < curr) {\n// /* Previous high water mark below current data -- zero WIN_INIT\n// * bytes or up to end of window, whichever is less.\n// */\n// init = s.window_size - curr;\n// if (init > WIN_INIT)\n// init = WIN_INIT;\n// zmemzero(s->window + curr, (unsigned)init);\n// s->high_water = curr + init;\n// }\n// else if (s->high_water < (ulg)curr + WIN_INIT) {\n// /* High water mark at or above current data, but below current data\n// * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up\n// * to end of window, whichever is less.\n// */\n// init = (ulg)curr + WIN_INIT - s->high_water;\n// if (init > s->window_size - s->high_water)\n// init = s->window_size - s->high_water;\n// zmemzero(s->window + s->high_water, (unsigned)init);\n// s->high_water += init;\n// }\n// }\n//\n// Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD,\n// \"not enough room for search\");\n}\n\n/* ===========================================================================\n * Copy without compression as much as possible from the input stream, return\n * the current block state.\n * This function does not insert new strings in the dictionary since\n * uncompressible data is probably not useful. This function is used\n * only for the level=0 compression option.\n * NOTE: this function should be optimized to avoid extra copying from\n * window to pending_buf.\n */\nfunction deflate_stored(s, flush) {\n /* Stored blocks are limited to 0xffff bytes, pending_buf is limited\n * to pending_buf_size, and each stored block has a 5 byte header:\n */\n var max_block_size = 0xffff;\n\n if (max_block_size > s.pending_buf_size - 5) {\n max_block_size = s.pending_buf_size - 5;\n }\n\n /* Copy as much as possible from input to output: */\n for (;;) {\n /* Fill the window as much as possible: */\n if (s.lookahead <= 1) {\n\n //Assert(s->strstart < s->w_size+MAX_DIST(s) ||\n // s->block_start >= (long)s->w_size, \"slide too late\");\n// if (!(s.strstart < s.w_size + (s.w_size - MIN_LOOKAHEAD) ||\n// s.block_start >= s.w_size)) {\n// throw new Error(\"slide too late\");\n// }\n\n fill_window(s);\n if (s.lookahead === 0 && flush === Z_NO_FLUSH) {\n return BS_NEED_MORE;\n }\n\n if (s.lookahead === 0) {\n break;\n }\n /* flush the current block */\n }\n //Assert(s->block_start >= 0L, \"block gone\");\n// if (s.block_start < 0) throw new Error(\"block gone\");\n\n s.strstart += s.lookahead;\n s.lookahead = 0;\n\n /* Emit a stored block if pending_buf will be full: */\n var max_start = s.block_start + max_block_size;\n\n if (s.strstart === 0 || s.strstart >= max_start) {\n /* strstart == 0 is possible when wraparound on 16-bit machine */\n s.lookahead = s.strstart - max_start;\n s.strstart = max_start;\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n\n\n }\n /* Flush if we may have to slide, otherwise block_start may become\n * negative and the data will be gone:\n */\n if (s.strstart - s.block_start >= (s.w_size - MIN_LOOKAHEAD)) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n }\n\n s.insert = 0;\n\n if (flush === Z_FINISH) {\n /*** FLUSH_BLOCK(s, 1); ***/\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n /***/\n return BS_FINISH_DONE;\n }\n\n if (s.strstart > s.block_start) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n\n return BS_NEED_MORE;\n}\n\n/* ===========================================================================\n * Compress as much as possible from the input stream, return the current\n * block state.\n * This function does not perform lazy evaluation of matches and inserts\n * new strings in the dictionary only for unmatched strings or for short\n * matches. It is used only for the fast compression options.\n */\nfunction deflate_fast(s, flush) {\n var hash_head; /* head of the hash chain */\n var bflush; /* set if current block must be flushed */\n\n for (;;) {\n /* Make sure that we always have enough lookahead, except\n * at the end of the input file. We need MAX_MATCH bytes\n * for the next match, plus MIN_MATCH bytes to insert the\n * string following the next match.\n */\n if (s.lookahead < MIN_LOOKAHEAD) {\n fill_window(s);\n if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH) {\n return BS_NEED_MORE;\n }\n if (s.lookahead === 0) {\n break; /* flush the current block */\n }\n }\n\n /* Insert the string window[strstart .. strstart+2] in the\n * dictionary, and set hash_head to the head of the hash chain:\n */\n hash_head = 0/*NIL*/;\n if (s.lookahead >= MIN_MATCH) {\n /*** INSERT_STRING(s, s.strstart, hash_head); ***/\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n /***/\n }\n\n /* Find the longest match, discarding those <= prev_length.\n * At this point we have always match_length < MIN_MATCH\n */\n if (hash_head !== 0/*NIL*/ && ((s.strstart - hash_head) <= (s.w_size - MIN_LOOKAHEAD))) {\n /* To simplify the code, we prevent matches with the string\n * of window index 0 (in particular we have to avoid a match\n * of the string with itself at the start of the input file).\n */\n s.match_length = longest_match(s, hash_head);\n /* longest_match() sets match_start */\n }\n if (s.match_length >= MIN_MATCH) {\n // check_match(s, s.strstart, s.match_start, s.match_length); // for debug only\n\n /*** _tr_tally_dist(s, s.strstart - s.match_start,\n s.match_length - MIN_MATCH, bflush); ***/\n bflush = trees._tr_tally(s, s.strstart - s.match_start, s.match_length - MIN_MATCH);\n\n s.lookahead -= s.match_length;\n\n /* Insert new strings in the hash table only if the match length\n * is not too large. This saves time but degrades compression.\n */\n if (s.match_length <= s.max_lazy_match/*max_insert_length*/ && s.lookahead >= MIN_MATCH) {\n s.match_length--; /* string at strstart already in table */\n do {\n s.strstart++;\n /*** INSERT_STRING(s, s.strstart, hash_head); ***/\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n /***/\n /* strstart never exceeds WSIZE-MAX_MATCH, so there are\n * always MIN_MATCH bytes ahead.\n */\n } while (--s.match_length !== 0);\n s.strstart++;\n } else\n {\n s.strstart += s.match_length;\n s.match_length = 0;\n s.ins_h = s.window[s.strstart];\n /* UPDATE_HASH(s, s.ins_h, s.window[s.strstart+1]); */\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + 1]) & s.hash_mask;\n\n//#if MIN_MATCH != 3\n// Call UPDATE_HASH() MIN_MATCH-3 more times\n//#endif\n /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not\n * matter since it will be recomputed at next deflate call.\n */\n }\n } else {\n /* No match, output a literal byte */\n //Tracevv((stderr,\"%c\", s.window[s.strstart]));\n /*** _tr_tally_lit(s, s.window[s.strstart], bflush); ***/\n bflush = trees._tr_tally(s, 0, s.window[s.strstart]);\n\n s.lookahead--;\n s.strstart++;\n }\n if (bflush) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n }\n s.insert = ((s.strstart < (MIN_MATCH - 1)) ? s.strstart : MIN_MATCH - 1);\n if (flush === Z_FINISH) {\n /*** FLUSH_BLOCK(s, 1); ***/\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n /***/\n return BS_FINISH_DONE;\n }\n if (s.last_lit) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n return BS_BLOCK_DONE;\n}\n\n/* ===========================================================================\n * Same as above, but achieves better compression. We use a lazy\n * evaluation for matches: a match is finally adopted only if there is\n * no better match at the next window position.\n */\nfunction deflate_slow(s, flush) {\n var hash_head; /* head of hash chain */\n var bflush; /* set if current block must be flushed */\n\n var max_insert;\n\n /* Process the input block. */\n for (;;) {\n /* Make sure that we always have enough lookahead, except\n * at the end of the input file. We need MAX_MATCH bytes\n * for the next match, plus MIN_MATCH bytes to insert the\n * string following the next match.\n */\n if (s.lookahead < MIN_LOOKAHEAD) {\n fill_window(s);\n if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH) {\n return BS_NEED_MORE;\n }\n if (s.lookahead === 0) { break; } /* flush the current block */\n }\n\n /* Insert the string window[strstart .. strstart+2] in the\n * dictionary, and set hash_head to the head of the hash chain:\n */\n hash_head = 0/*NIL*/;\n if (s.lookahead >= MIN_MATCH) {\n /*** INSERT_STRING(s, s.strstart, hash_head); ***/\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n /***/\n }\n\n /* Find the longest match, discarding those <= prev_length.\n */\n s.prev_length = s.match_length;\n s.prev_match = s.match_start;\n s.match_length = MIN_MATCH - 1;\n\n if (hash_head !== 0/*NIL*/ && s.prev_length < s.max_lazy_match &&\n s.strstart - hash_head <= (s.w_size - MIN_LOOKAHEAD)/*MAX_DIST(s)*/) {\n /* To simplify the code, we prevent matches with the string\n * of window index 0 (in particular we have to avoid a match\n * of the string with itself at the start of the input file).\n */\n s.match_length = longest_match(s, hash_head);\n /* longest_match() sets match_start */\n\n if (s.match_length <= 5 &&\n (s.strategy === Z_FILTERED || (s.match_length === MIN_MATCH && s.strstart - s.match_start > 4096/*TOO_FAR*/))) {\n\n /* If prev_match is also MIN_MATCH, match_start is garbage\n * but we will ignore the current match anyway.\n */\n s.match_length = MIN_MATCH - 1;\n }\n }\n /* If there was a match at the previous step and the current\n * match is not better, output the previous match:\n */\n if (s.prev_length >= MIN_MATCH && s.match_length <= s.prev_length) {\n max_insert = s.strstart + s.lookahead - MIN_MATCH;\n /* Do not insert strings in hash table beyond this. */\n\n //check_match(s, s.strstart-1, s.prev_match, s.prev_length);\n\n /***_tr_tally_dist(s, s.strstart - 1 - s.prev_match,\n s.prev_length - MIN_MATCH, bflush);***/\n bflush = trees._tr_tally(s, s.strstart - 1 - s.prev_match, s.prev_length - MIN_MATCH);\n /* Insert in hash table all strings up to the end of the match.\n * strstart-1 and strstart are already inserted. If there is not\n * enough lookahead, the last two strings are not inserted in\n * the hash table.\n */\n s.lookahead -= s.prev_length - 1;\n s.prev_length -= 2;\n do {\n if (++s.strstart <= max_insert) {\n /*** INSERT_STRING(s, s.strstart, hash_head); ***/\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n /***/\n }\n } while (--s.prev_length !== 0);\n s.match_available = 0;\n s.match_length = MIN_MATCH - 1;\n s.strstart++;\n\n if (bflush) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n\n } else if (s.match_available) {\n /* If there was no match at the previous position, output a\n * single literal. If there was a match but the current match\n * is longer, truncate the previous match to a single literal.\n */\n //Tracevv((stderr,\"%c\", s->window[s->strstart-1]));\n /*** _tr_tally_lit(s, s.window[s.strstart-1], bflush); ***/\n bflush = trees._tr_tally(s, 0, s.window[s.strstart - 1]);\n\n if (bflush) {\n /*** FLUSH_BLOCK_ONLY(s, 0) ***/\n flush_block_only(s, false);\n /***/\n }\n s.strstart++;\n s.lookahead--;\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n } else {\n /* There is no previous match to compare with, wait for\n * the next step to decide.\n */\n s.match_available = 1;\n s.strstart++;\n s.lookahead--;\n }\n }\n //Assert (flush != Z_NO_FLUSH, \"no flush?\");\n if (s.match_available) {\n //Tracevv((stderr,\"%c\", s->window[s->strstart-1]));\n /*** _tr_tally_lit(s, s.window[s.strstart-1], bflush); ***/\n bflush = trees._tr_tally(s, 0, s.window[s.strstart - 1]);\n\n s.match_available = 0;\n }\n s.insert = s.strstart < MIN_MATCH - 1 ? s.strstart : MIN_MATCH - 1;\n if (flush === Z_FINISH) {\n /*** FLUSH_BLOCK(s, 1); ***/\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n /***/\n return BS_FINISH_DONE;\n }\n if (s.last_lit) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n\n return BS_BLOCK_DONE;\n}\n\n\n/* ===========================================================================\n * For Z_RLE, simply look for runs of bytes, generate matches only of distance\n * one. Do not maintain a hash table. (It will be regenerated if this run of\n * deflate switches away from Z_RLE.)\n */\nfunction deflate_rle(s, flush) {\n var bflush; /* set if current block must be flushed */\n var prev; /* byte at distance one to match */\n var scan, strend; /* scan goes up to strend for length of run */\n\n var _win = s.window;\n\n for (;;) {\n /* Make sure that we always have enough lookahead, except\n * at the end of the input file. We need MAX_MATCH bytes\n * for the longest run, plus one for the unrolled loop.\n */\n if (s.lookahead <= MAX_MATCH) {\n fill_window(s);\n if (s.lookahead <= MAX_MATCH && flush === Z_NO_FLUSH) {\n return BS_NEED_MORE;\n }\n if (s.lookahead === 0) { break; } /* flush the current block */\n }\n\n /* See how many times the previous byte repeats */\n s.match_length = 0;\n if (s.lookahead >= MIN_MATCH && s.strstart > 0) {\n scan = s.strstart - 1;\n prev = _win[scan];\n if (prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan]) {\n strend = s.strstart + MAX_MATCH;\n do {\n /*jshint noempty:false*/\n } while (prev === _win[++scan] && prev === _win[++scan] &&\n prev === _win[++scan] && prev === _win[++scan] &&\n prev === _win[++scan] && prev === _win[++scan] &&\n prev === _win[++scan] && prev === _win[++scan] &&\n scan < strend);\n s.match_length = MAX_MATCH - (strend - scan);\n if (s.match_length > s.lookahead) {\n s.match_length = s.lookahead;\n }\n }\n //Assert(scan <= s->window+(uInt)(s->window_size-1), \"wild scan\");\n }\n\n /* Emit match if have run of MIN_MATCH or longer, else emit literal */\n if (s.match_length >= MIN_MATCH) {\n //check_match(s, s.strstart, s.strstart - 1, s.match_length);\n\n /*** _tr_tally_dist(s, 1, s.match_length - MIN_MATCH, bflush); ***/\n bflush = trees._tr_tally(s, 1, s.match_length - MIN_MATCH);\n\n s.lookahead -= s.match_length;\n s.strstart += s.match_length;\n s.match_length = 0;\n } else {\n /* No match, output a literal byte */\n //Tracevv((stderr,\"%c\", s->window[s->strstart]));\n /*** _tr_tally_lit(s, s.window[s.strstart], bflush); ***/\n bflush = trees._tr_tally(s, 0, s.window[s.strstart]);\n\n s.lookahead--;\n s.strstart++;\n }\n if (bflush) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n }\n s.insert = 0;\n if (flush === Z_FINISH) {\n /*** FLUSH_BLOCK(s, 1); ***/\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n /***/\n return BS_FINISH_DONE;\n }\n if (s.last_lit) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n return BS_BLOCK_DONE;\n}\n\n/* ===========================================================================\n * For Z_HUFFMAN_ONLY, do not look for matches. Do not maintain a hash table.\n * (It will be regenerated if this run of deflate switches away from Huffman.)\n */\nfunction deflate_huff(s, flush) {\n var bflush; /* set if current block must be flushed */\n\n for (;;) {\n /* Make sure that we have a literal to write. */\n if (s.lookahead === 0) {\n fill_window(s);\n if (s.lookahead === 0) {\n if (flush === Z_NO_FLUSH) {\n return BS_NEED_MORE;\n }\n break; /* flush the current block */\n }\n }\n\n /* Output a literal byte */\n s.match_length = 0;\n //Tracevv((stderr,\"%c\", s->window[s->strstart]));\n /*** _tr_tally_lit(s, s.window[s.strstart], bflush); ***/\n bflush = trees._tr_tally(s, 0, s.window[s.strstart]);\n s.lookahead--;\n s.strstart++;\n if (bflush) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n }\n s.insert = 0;\n if (flush === Z_FINISH) {\n /*** FLUSH_BLOCK(s, 1); ***/\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n /***/\n return BS_FINISH_DONE;\n }\n if (s.last_lit) {\n /*** FLUSH_BLOCK(s, 0); ***/\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n /***/\n }\n return BS_BLOCK_DONE;\n}\n\n/* Values for max_lazy_match, good_match and max_chain_length, depending on\n * the desired pack level (0..9). The values given below have been tuned to\n * exclude worst case performance for pathological files. Better values may be\n * found for specific files.\n */\nfunction Config(good_length, max_lazy, nice_length, max_chain, func) {\n this.good_length = good_length;\n this.max_lazy = max_lazy;\n this.nice_length = nice_length;\n this.max_chain = max_chain;\n this.func = func;\n}\n\nvar configuration_table;\n\nconfiguration_table = [\n /* good lazy nice chain */\n new Config(0, 0, 0, 0, deflate_stored), /* 0 store only */\n new Config(4, 4, 8, 4, deflate_fast), /* 1 max speed, no lazy matches */\n new Config(4, 5, 16, 8, deflate_fast), /* 2 */\n new Config(4, 6, 32, 32, deflate_fast), /* 3 */\n\n new Config(4, 4, 16, 16, deflate_slow), /* 4 lazy matches */\n new Config(8, 16, 32, 32, deflate_slow), /* 5 */\n new Config(8, 16, 128, 128, deflate_slow), /* 6 */\n new Config(8, 32, 128, 256, deflate_slow), /* 7 */\n new Config(32, 128, 258, 1024, deflate_slow), /* 8 */\n new Config(32, 258, 258, 4096, deflate_slow) /* 9 max compression */\n];\n\n\n/* ===========================================================================\n * Initialize the \"longest match\" routines for a new zlib stream\n */\nfunction lm_init(s) {\n s.window_size = 2 * s.w_size;\n\n /*** CLEAR_HASH(s); ***/\n zero(s.head); // Fill with NIL (= 0);\n\n /* Set the default configuration parameters:\n */\n s.max_lazy_match = configuration_table[s.level].max_lazy;\n s.good_match = configuration_table[s.level].good_length;\n s.nice_match = configuration_table[s.level].nice_length;\n s.max_chain_length = configuration_table[s.level].max_chain;\n\n s.strstart = 0;\n s.block_start = 0;\n s.lookahead = 0;\n s.insert = 0;\n s.match_length = s.prev_length = MIN_MATCH - 1;\n s.match_available = 0;\n s.ins_h = 0;\n}\n\n\nfunction DeflateState() {\n this.strm = null; /* pointer back to this zlib stream */\n this.status = 0; /* as the name implies */\n this.pending_buf = null; /* output still pending */\n this.pending_buf_size = 0; /* size of pending_buf */\n this.pending_out = 0; /* next pending byte to output to the stream */\n this.pending = 0; /* nb of bytes in the pending buffer */\n this.wrap = 0; /* bit 0 true for zlib, bit 1 true for gzip */\n this.gzhead = null; /* gzip header information to write */\n this.gzindex = 0; /* where in extra, name, or comment */\n this.method = Z_DEFLATED; /* can only be DEFLATED */\n this.last_flush = -1; /* value of flush param for previous deflate call */\n\n this.w_size = 0; /* LZ77 window size (32K by default) */\n this.w_bits = 0; /* log2(w_size) (8..16) */\n this.w_mask = 0; /* w_size - 1 */\n\n this.window = null;\n /* Sliding window. Input bytes are read into the second half of the window,\n * and move to the first half later to keep a dictionary of at least wSize\n * bytes. With this organization, matches are limited to a distance of\n * wSize-MAX_MATCH bytes, but this ensures that IO is always\n * performed with a length multiple of the block size.\n */\n\n this.window_size = 0;\n /* Actual size of window: 2*wSize, except when the user input buffer\n * is directly used as sliding window.\n */\n\n this.prev = null;\n /* Link to older string with same hash index. To limit the size of this\n * array to 64K, this link is maintained only for the last 32K strings.\n * An index in this array is thus a window index modulo 32K.\n */\n\n this.head = null; /* Heads of the hash chains or NIL. */\n\n this.ins_h = 0; /* hash index of string to be inserted */\n this.hash_size = 0; /* number of elements in hash table */\n this.hash_bits = 0; /* log2(hash_size) */\n this.hash_mask = 0; /* hash_size-1 */\n\n this.hash_shift = 0;\n /* Number of bits by which ins_h must be shifted at each input\n * step. It must be such that after MIN_MATCH steps, the oldest\n * byte no longer takes part in the hash key, that is:\n * hash_shift * MIN_MATCH >= hash_bits\n */\n\n this.block_start = 0;\n /* Window position at the beginning of the current output block. Gets\n * negative when the window is moved backwards.\n */\n\n this.match_length = 0; /* length of best match */\n this.prev_match = 0; /* previous match */\n this.match_available = 0; /* set if previous match exists */\n this.strstart = 0; /* start of string to insert */\n this.match_start = 0; /* start of matching string */\n this.lookahead = 0; /* number of valid bytes ahead in window */\n\n this.prev_length = 0;\n /* Length of the best match at previous step. Matches not greater than this\n * are discarded. This is used in the lazy match evaluation.\n */\n\n this.max_chain_length = 0;\n /* To speed up deflation, hash chains are never searched beyond this\n * length. A higher limit improves compression ratio but degrades the\n * speed.\n */\n\n this.max_lazy_match = 0;\n /* Attempt to find a better match only when the current match is strictly\n * smaller than this value. This mechanism is used only for compression\n * levels >= 4.\n */\n // That's alias to max_lazy_match, don't use directly\n //this.max_insert_length = 0;\n /* Insert new strings in the hash table only if the match length is not\n * greater than this length. This saves time but degrades compression.\n * max_insert_length is used only for compression levels <= 3.\n */\n\n this.level = 0; /* compression level (1..9) */\n this.strategy = 0; /* favor or force Huffman coding*/\n\n this.good_match = 0;\n /* Use a faster search when the previous match is longer than this */\n\n this.nice_match = 0; /* Stop searching when current match exceeds this */\n\n /* used by trees.c: */\n\n /* Didn't use ct_data typedef below to suppress compiler warning */\n\n // struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */\n // struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */\n // struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */\n\n // Use flat array of DOUBLE size, with interleaved fata,\n // because JS does not support effective\n this.dyn_ltree = new utils.Buf16(HEAP_SIZE * 2);\n this.dyn_dtree = new utils.Buf16((2 * D_CODES + 1) * 2);\n this.bl_tree = new utils.Buf16((2 * BL_CODES + 1) * 2);\n zero(this.dyn_ltree);\n zero(this.dyn_dtree);\n zero(this.bl_tree);\n\n this.l_desc = null; /* desc. for literal tree */\n this.d_desc = null; /* desc. for distance tree */\n this.bl_desc = null; /* desc. for bit length tree */\n\n //ush bl_count[MAX_BITS+1];\n this.bl_count = new utils.Buf16(MAX_BITS + 1);\n /* number of codes at each bit length for an optimal tree */\n\n //int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */\n this.heap = new utils.Buf16(2 * L_CODES + 1); /* heap used to build the Huffman trees */\n zero(this.heap);\n\n this.heap_len = 0; /* number of elements in the heap */\n this.heap_max = 0; /* element of largest frequency */\n /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used.\n * The same heap array is used to build all trees.\n */\n\n this.depth = new utils.Buf16(2 * L_CODES + 1); //uch depth[2*L_CODES+1];\n zero(this.depth);\n /* Depth of each subtree used as tie breaker for trees of equal frequency\n */\n\n this.l_buf = 0; /* buffer index for literals or lengths */\n\n this.lit_bufsize = 0;\n /* Size of match buffer for literals/lengths. There are 4 reasons for\n * limiting lit_bufsize to 64K:\n * - frequencies can be kept in 16 bit counters\n * - if compression is not successful for the first block, all input\n * data is still in the window so we can still emit a stored block even\n * when input comes from standard input. (This can also be done for\n * all blocks if lit_bufsize is not greater than 32K.)\n * - if compression is not successful for a file smaller than 64K, we can\n * even emit a stored file instead of a stored block (saving 5 bytes).\n * This is applicable only for zip (not gzip or zlib).\n * - creating new Huffman trees less frequently may not provide fast\n * adaptation to changes in the input data statistics. (Take for\n * example a binary file with poorly compressible code followed by\n * a highly compressible string table.) Smaller buffer sizes give\n * fast adaptation but have of course the overhead of transmitting\n * trees more frequently.\n * - I can't count above 4\n */\n\n this.last_lit = 0; /* running index in l_buf */\n\n this.d_buf = 0;\n /* Buffer index for distances. To simplify the code, d_buf and l_buf have\n * the same number of elements. To use different lengths, an extra flag\n * array would be necessary.\n */\n\n this.opt_len = 0; /* bit length of current block with optimal trees */\n this.static_len = 0; /* bit length of current block with static trees */\n this.matches = 0; /* number of string matches in current block */\n this.insert = 0; /* bytes at end of window left to insert */\n\n\n this.bi_buf = 0;\n /* Output buffer. bits are inserted starting at the bottom (least\n * significant bits).\n */\n this.bi_valid = 0;\n /* Number of valid bits in bi_buf. All bits above the last valid bit\n * are always zero.\n */\n\n // Used for window memory init. We safely ignore it for JS. That makes\n // sense only for pointers and memory check tools.\n //this.high_water = 0;\n /* High water mark offset in window for initialized bytes -- bytes above\n * this are set to zero in order to avoid memory check warnings when\n * longest match routines access bytes past the input. This is then\n * updated to the new high water mark.\n */\n}\n\n\nfunction deflateResetKeep(strm) {\n var s;\n\n if (!strm || !strm.state) {\n return err(strm, Z_STREAM_ERROR);\n }\n\n strm.total_in = strm.total_out = 0;\n strm.data_type = Z_UNKNOWN;\n\n s = strm.state;\n s.pending = 0;\n s.pending_out = 0;\n\n if (s.wrap < 0) {\n s.wrap = -s.wrap;\n /* was made negative by deflate(..., Z_FINISH); */\n }\n s.status = (s.wrap ? INIT_STATE : BUSY_STATE);\n strm.adler = (s.wrap === 2) ?\n 0 // crc32(0, Z_NULL, 0)\n :\n 1; // adler32(0, Z_NULL, 0)\n s.last_flush = Z_NO_FLUSH;\n trees._tr_init(s);\n return Z_OK;\n}\n\n\nfunction deflateReset(strm) {\n var ret = deflateResetKeep(strm);\n if (ret === Z_OK) {\n lm_init(strm.state);\n }\n return ret;\n}\n\n\nfunction deflateSetHeader(strm, head) {\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n if (strm.state.wrap !== 2) { return Z_STREAM_ERROR; }\n strm.state.gzhead = head;\n return Z_OK;\n}\n\n\nfunction deflateInit2(strm, level, method, windowBits, memLevel, strategy) {\n if (!strm) { // === Z_NULL\n return Z_STREAM_ERROR;\n }\n var wrap = 1;\n\n if (level === Z_DEFAULT_COMPRESSION) {\n level = 6;\n }\n\n if (windowBits < 0) { /* suppress zlib wrapper */\n wrap = 0;\n windowBits = -windowBits;\n }\n\n else if (windowBits > 15) {\n wrap = 2; /* write gzip wrapper instead */\n windowBits -= 16;\n }\n\n\n if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method !== Z_DEFLATED ||\n windowBits < 8 || windowBits > 15 || level < 0 || level > 9 ||\n strategy < 0 || strategy > Z_FIXED) {\n return err(strm, Z_STREAM_ERROR);\n }\n\n\n if (windowBits === 8) {\n windowBits = 9;\n }\n /* until 256-byte window bug fixed */\n\n var s = new DeflateState();\n\n strm.state = s;\n s.strm = strm;\n\n s.wrap = wrap;\n s.gzhead = null;\n s.w_bits = windowBits;\n s.w_size = 1 << s.w_bits;\n s.w_mask = s.w_size - 1;\n\n s.hash_bits = memLevel + 7;\n s.hash_size = 1 << s.hash_bits;\n s.hash_mask = s.hash_size - 1;\n s.hash_shift = ~~((s.hash_bits + MIN_MATCH - 1) / MIN_MATCH);\n\n s.window = new utils.Buf8(s.w_size * 2);\n s.head = new utils.Buf16(s.hash_size);\n s.prev = new utils.Buf16(s.w_size);\n\n // Don't need mem init magic for JS.\n //s.high_water = 0; /* nothing written to s->window yet */\n\n s.lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */\n\n s.pending_buf_size = s.lit_bufsize * 4;\n\n //overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2);\n //s->pending_buf = (uchf *) overlay;\n s.pending_buf = new utils.Buf8(s.pending_buf_size);\n\n // It is offset from `s.pending_buf` (size is `s.lit_bufsize * 2`)\n //s->d_buf = overlay + s->lit_bufsize/sizeof(ush);\n s.d_buf = 1 * s.lit_bufsize;\n\n //s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize;\n s.l_buf = (1 + 2) * s.lit_bufsize;\n\n s.level = level;\n s.strategy = strategy;\n s.method = method;\n\n return deflateReset(strm);\n}\n\nfunction deflateInit(strm, level) {\n return deflateInit2(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY);\n}\n\n\nfunction deflate(strm, flush) {\n var old_flush, s;\n var beg, val; // for gzip header write only\n\n if (!strm || !strm.state ||\n flush > Z_BLOCK || flush < 0) {\n return strm ? err(strm, Z_STREAM_ERROR) : Z_STREAM_ERROR;\n }\n\n s = strm.state;\n\n if (!strm.output ||\n (!strm.input && strm.avail_in !== 0) ||\n (s.status === FINISH_STATE && flush !== Z_FINISH)) {\n return err(strm, (strm.avail_out === 0) ? Z_BUF_ERROR : Z_STREAM_ERROR);\n }\n\n s.strm = strm; /* just in case */\n old_flush = s.last_flush;\n s.last_flush = flush;\n\n /* Write the header */\n if (s.status === INIT_STATE) {\n\n if (s.wrap === 2) { // GZIP header\n strm.adler = 0; //crc32(0L, Z_NULL, 0);\n put_byte(s, 31);\n put_byte(s, 139);\n put_byte(s, 8);\n if (!s.gzhead) { // s->gzhead == Z_NULL\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, s.level === 9 ? 2 :\n (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ?\n 4 : 0));\n put_byte(s, OS_CODE);\n s.status = BUSY_STATE;\n }\n else {\n put_byte(s, (s.gzhead.text ? 1 : 0) +\n (s.gzhead.hcrc ? 2 : 0) +\n (!s.gzhead.extra ? 0 : 4) +\n (!s.gzhead.name ? 0 : 8) +\n (!s.gzhead.comment ? 0 : 16)\n );\n put_byte(s, s.gzhead.time & 0xff);\n put_byte(s, (s.gzhead.time >> 8) & 0xff);\n put_byte(s, (s.gzhead.time >> 16) & 0xff);\n put_byte(s, (s.gzhead.time >> 24) & 0xff);\n put_byte(s, s.level === 9 ? 2 :\n (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ?\n 4 : 0));\n put_byte(s, s.gzhead.os & 0xff);\n if (s.gzhead.extra && s.gzhead.extra.length) {\n put_byte(s, s.gzhead.extra.length & 0xff);\n put_byte(s, (s.gzhead.extra.length >> 8) & 0xff);\n }\n if (s.gzhead.hcrc) {\n strm.adler = crc32(strm.adler, s.pending_buf, s.pending, 0);\n }\n s.gzindex = 0;\n s.status = EXTRA_STATE;\n }\n }\n else // DEFLATE header\n {\n var header = (Z_DEFLATED + ((s.w_bits - 8) << 4)) << 8;\n var level_flags = -1;\n\n if (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2) {\n level_flags = 0;\n } else if (s.level < 6) {\n level_flags = 1;\n } else if (s.level === 6) {\n level_flags = 2;\n } else {\n level_flags = 3;\n }\n header |= (level_flags << 6);\n if (s.strstart !== 0) { header |= PRESET_DICT; }\n header += 31 - (header % 31);\n\n s.status = BUSY_STATE;\n putShortMSB(s, header);\n\n /* Save the adler32 of the preset dictionary: */\n if (s.strstart !== 0) {\n putShortMSB(s, strm.adler >>> 16);\n putShortMSB(s, strm.adler & 0xffff);\n }\n strm.adler = 1; // adler32(0L, Z_NULL, 0);\n }\n }\n\n//#ifdef GZIP\n if (s.status === EXTRA_STATE) {\n if (s.gzhead.extra/* != Z_NULL*/) {\n beg = s.pending; /* start of bytes to update crc */\n\n while (s.gzindex < (s.gzhead.extra.length & 0xffff)) {\n if (s.pending === s.pending_buf_size) {\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n flush_pending(strm);\n beg = s.pending;\n if (s.pending === s.pending_buf_size) {\n break;\n }\n }\n put_byte(s, s.gzhead.extra[s.gzindex] & 0xff);\n s.gzindex++;\n }\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n if (s.gzindex === s.gzhead.extra.length) {\n s.gzindex = 0;\n s.status = NAME_STATE;\n }\n }\n else {\n s.status = NAME_STATE;\n }\n }\n if (s.status === NAME_STATE) {\n if (s.gzhead.name/* != Z_NULL*/) {\n beg = s.pending; /* start of bytes to update crc */\n //int val;\n\n do {\n if (s.pending === s.pending_buf_size) {\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n flush_pending(strm);\n beg = s.pending;\n if (s.pending === s.pending_buf_size) {\n val = 1;\n break;\n }\n }\n // JS specific: little magic to add zero terminator to end of string\n if (s.gzindex < s.gzhead.name.length) {\n val = s.gzhead.name.charCodeAt(s.gzindex++) & 0xff;\n } else {\n val = 0;\n }\n put_byte(s, val);\n } while (val !== 0);\n\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n if (val === 0) {\n s.gzindex = 0;\n s.status = COMMENT_STATE;\n }\n }\n else {\n s.status = COMMENT_STATE;\n }\n }\n if (s.status === COMMENT_STATE) {\n if (s.gzhead.comment/* != Z_NULL*/) {\n beg = s.pending; /* start of bytes to update crc */\n //int val;\n\n do {\n if (s.pending === s.pending_buf_size) {\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n flush_pending(strm);\n beg = s.pending;\n if (s.pending === s.pending_buf_size) {\n val = 1;\n break;\n }\n }\n // JS specific: little magic to add zero terminator to end of string\n if (s.gzindex < s.gzhead.comment.length) {\n val = s.gzhead.comment.charCodeAt(s.gzindex++) & 0xff;\n } else {\n val = 0;\n }\n put_byte(s, val);\n } while (val !== 0);\n\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n if (val === 0) {\n s.status = HCRC_STATE;\n }\n }\n else {\n s.status = HCRC_STATE;\n }\n }\n if (s.status === HCRC_STATE) {\n if (s.gzhead.hcrc) {\n if (s.pending + 2 > s.pending_buf_size) {\n flush_pending(strm);\n }\n if (s.pending + 2 <= s.pending_buf_size) {\n put_byte(s, strm.adler & 0xff);\n put_byte(s, (strm.adler >> 8) & 0xff);\n strm.adler = 0; //crc32(0L, Z_NULL, 0);\n s.status = BUSY_STATE;\n }\n }\n else {\n s.status = BUSY_STATE;\n }\n }\n//#endif\n\n /* Flush as much pending output as possible */\n if (s.pending !== 0) {\n flush_pending(strm);\n if (strm.avail_out === 0) {\n /* Since avail_out is 0, deflate will be called again with\n * more output space, but possibly with both pending and\n * avail_in equal to zero. There won't be anything to do,\n * but this is not an error situation so make sure we\n * return OK instead of BUF_ERROR at next call of deflate:\n */\n s.last_flush = -1;\n return Z_OK;\n }\n\n /* Make sure there is something to do and avoid duplicate consecutive\n * flushes. For repeated and useless calls with Z_FINISH, we keep\n * returning Z_STREAM_END instead of Z_BUF_ERROR.\n */\n } else if (strm.avail_in === 0 && rank(flush) <= rank(old_flush) &&\n flush !== Z_FINISH) {\n return err(strm, Z_BUF_ERROR);\n }\n\n /* User must not provide more input after the first FINISH: */\n if (s.status === FINISH_STATE && strm.avail_in !== 0) {\n return err(strm, Z_BUF_ERROR);\n }\n\n /* Start a new block or continue the current one.\n */\n if (strm.avail_in !== 0 || s.lookahead !== 0 ||\n (flush !== Z_NO_FLUSH && s.status !== FINISH_STATE)) {\n var bstate = (s.strategy === Z_HUFFMAN_ONLY) ? deflate_huff(s, flush) :\n (s.strategy === Z_RLE ? deflate_rle(s, flush) :\n configuration_table[s.level].func(s, flush));\n\n if (bstate === BS_FINISH_STARTED || bstate === BS_FINISH_DONE) {\n s.status = FINISH_STATE;\n }\n if (bstate === BS_NEED_MORE || bstate === BS_FINISH_STARTED) {\n if (strm.avail_out === 0) {\n s.last_flush = -1;\n /* avoid BUF_ERROR next call, see above */\n }\n return Z_OK;\n /* If flush != Z_NO_FLUSH && avail_out == 0, the next call\n * of deflate should use the same flush parameter to make sure\n * that the flush is complete. So we don't have to output an\n * empty block here, this will be done at next call. This also\n * ensures that for a very small output buffer, we emit at most\n * one empty block.\n */\n }\n if (bstate === BS_BLOCK_DONE) {\n if (flush === Z_PARTIAL_FLUSH) {\n trees._tr_align(s);\n }\n else if (flush !== Z_BLOCK) { /* FULL_FLUSH or SYNC_FLUSH */\n\n trees._tr_stored_block(s, 0, 0, false);\n /* For a full flush, this empty block will be recognized\n * as a special marker by inflate_sync().\n */\n if (flush === Z_FULL_FLUSH) {\n /*** CLEAR_HASH(s); ***/ /* forget history */\n zero(s.head); // Fill with NIL (= 0);\n\n if (s.lookahead === 0) {\n s.strstart = 0;\n s.block_start = 0;\n s.insert = 0;\n }\n }\n }\n flush_pending(strm);\n if (strm.avail_out === 0) {\n s.last_flush = -1; /* avoid BUF_ERROR at next call, see above */\n return Z_OK;\n }\n }\n }\n //Assert(strm->avail_out > 0, \"bug2\");\n //if (strm.avail_out <= 0) { throw new Error(\"bug2\");}\n\n if (flush !== Z_FINISH) { return Z_OK; }\n if (s.wrap <= 0) { return Z_STREAM_END; }\n\n /* Write the trailer */\n if (s.wrap === 2) {\n put_byte(s, strm.adler & 0xff);\n put_byte(s, (strm.adler >> 8) & 0xff);\n put_byte(s, (strm.adler >> 16) & 0xff);\n put_byte(s, (strm.adler >> 24) & 0xff);\n put_byte(s, strm.total_in & 0xff);\n put_byte(s, (strm.total_in >> 8) & 0xff);\n put_byte(s, (strm.total_in >> 16) & 0xff);\n put_byte(s, (strm.total_in >> 24) & 0xff);\n }\n else\n {\n putShortMSB(s, strm.adler >>> 16);\n putShortMSB(s, strm.adler & 0xffff);\n }\n\n flush_pending(strm);\n /* If avail_out is zero, the application will call deflate again\n * to flush the rest.\n */\n if (s.wrap > 0) { s.wrap = -s.wrap; }\n /* write the trailer only once! */\n return s.pending !== 0 ? Z_OK : Z_STREAM_END;\n}\n\nfunction deflateEnd(strm) {\n var status;\n\n if (!strm/*== Z_NULL*/ || !strm.state/*== Z_NULL*/) {\n return Z_STREAM_ERROR;\n }\n\n status = strm.state.status;\n if (status !== INIT_STATE &&\n status !== EXTRA_STATE &&\n status !== NAME_STATE &&\n status !== COMMENT_STATE &&\n status !== HCRC_STATE &&\n status !== BUSY_STATE &&\n status !== FINISH_STATE\n ) {\n return err(strm, Z_STREAM_ERROR);\n }\n\n strm.state = null;\n\n return status === BUSY_STATE ? err(strm, Z_DATA_ERROR) : Z_OK;\n}\n\n\n/* =========================================================================\n * Initializes the compression dictionary from the given byte\n * sequence without producing any compressed output.\n */\nfunction deflateSetDictionary(strm, dictionary) {\n var dictLength = dictionary.length;\n\n var s;\n var str, n;\n var wrap;\n var avail;\n var next;\n var input;\n var tmpDict;\n\n if (!strm/*== Z_NULL*/ || !strm.state/*== Z_NULL*/) {\n return Z_STREAM_ERROR;\n }\n\n s = strm.state;\n wrap = s.wrap;\n\n if (wrap === 2 || (wrap === 1 && s.status !== INIT_STATE) || s.lookahead) {\n return Z_STREAM_ERROR;\n }\n\n /* when using zlib wrappers, compute Adler-32 for provided dictionary */\n if (wrap === 1) {\n /* adler32(strm->adler, dictionary, dictLength); */\n strm.adler = adler32(strm.adler, dictionary, dictLength, 0);\n }\n\n s.wrap = 0; /* avoid computing Adler-32 in read_buf */\n\n /* if dictionary would fill window, just replace the history */\n if (dictLength >= s.w_size) {\n if (wrap === 0) { /* already empty otherwise */\n /*** CLEAR_HASH(s); ***/\n zero(s.head); // Fill with NIL (= 0);\n s.strstart = 0;\n s.block_start = 0;\n s.insert = 0;\n }\n /* use the tail */\n // dictionary = dictionary.slice(dictLength - s.w_size);\n tmpDict = new utils.Buf8(s.w_size);\n utils.arraySet(tmpDict, dictionary, dictLength - s.w_size, s.w_size, 0);\n dictionary = tmpDict;\n dictLength = s.w_size;\n }\n /* insert dictionary into window and hash */\n avail = strm.avail_in;\n next = strm.next_in;\n input = strm.input;\n strm.avail_in = dictLength;\n strm.next_in = 0;\n strm.input = dictionary;\n fill_window(s);\n while (s.lookahead >= MIN_MATCH) {\n str = s.strstart;\n n = s.lookahead - (MIN_MATCH - 1);\n do {\n /* UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); */\n s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[str + MIN_MATCH - 1]) & s.hash_mask;\n\n s.prev[str & s.w_mask] = s.head[s.ins_h];\n\n s.head[s.ins_h] = str;\n str++;\n } while (--n);\n s.strstart = str;\n s.lookahead = MIN_MATCH - 1;\n fill_window(s);\n }\n s.strstart += s.lookahead;\n s.block_start = s.strstart;\n s.insert = s.lookahead;\n s.lookahead = 0;\n s.match_length = s.prev_length = MIN_MATCH - 1;\n s.match_available = 0;\n strm.next_in = next;\n strm.input = input;\n strm.avail_in = avail;\n s.wrap = wrap;\n return Z_OK;\n}\n\n\nexports.deflateInit = deflateInit;\nexports.deflateInit2 = deflateInit2;\nexports.deflateReset = deflateReset;\nexports.deflateResetKeep = deflateResetKeep;\nexports.deflateSetHeader = deflateSetHeader;\nexports.deflate = deflate;\nexports.deflateEnd = deflateEnd;\nexports.deflateSetDictionary = deflateSetDictionary;\nexports.deflateInfo = 'pako deflate (from Nodeca project)';\n\n/* Not implemented\nexports.deflateBound = deflateBound;\nexports.deflateCopy = deflateCopy;\nexports.deflateParams = deflateParams;\nexports.deflatePending = deflatePending;\nexports.deflatePrime = deflatePrime;\nexports.deflateTune = deflateTune;\n*/\n","'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nmodule.exports = {\n 2: 'need dictionary', /* Z_NEED_DICT 2 */\n 1: 'stream end', /* Z_STREAM_END 1 */\n 0: '', /* Z_OK 0 */\n '-1': 'file error', /* Z_ERRNO (-1) */\n '-2': 'stream error', /* Z_STREAM_ERROR (-2) */\n '-3': 'data error', /* Z_DATA_ERROR (-3) */\n '-4': 'insufficient memory', /* Z_MEM_ERROR (-4) */\n '-5': 'buffer error', /* Z_BUF_ERROR (-5) */\n '-6': 'incompatible version' /* Z_VERSION_ERROR (-6) */\n};\n","// String encode/decode helpers\n'use strict';\n\n\nvar utils = require('./common');\n\n\n// Quick check if we can use fast array to bin string conversion\n//\n// - apply(Array) can fail on Android 2.2\n// - apply(Uint8Array) can fail on iOS 5.1 Safari\n//\nvar STR_APPLY_OK = true;\nvar STR_APPLY_UIA_OK = true;\n\ntry { String.fromCharCode.apply(null, [ 0 ]); } catch (__) { STR_APPLY_OK = false; }\ntry { String.fromCharCode.apply(null, new Uint8Array(1)); } catch (__) { STR_APPLY_UIA_OK = false; }\n\n\n// Table with utf8 lengths (calculated by first byte of sequence)\n// Note, that 5 & 6-byte values and some 4-byte values can not be represented in JS,\n// because max possible codepoint is 0x10ffff\nvar _utf8len = new utils.Buf8(256);\nfor (var q = 0; q < 256; q++) {\n _utf8len[q] = (q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1);\n}\n_utf8len[254] = _utf8len[254] = 1; // Invalid sequence start\n\n\n// convert string to array (typed, when possible)\nexports.string2buf = function (str) {\n var buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0;\n\n // count binary size\n for (m_pos = 0; m_pos < str_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 0xfc00) === 0xdc00) {\n c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n m_pos++;\n }\n }\n buf_len += c < 0x80 ? 1 : c < 0x800 ? 2 : c < 0x10000 ? 3 : 4;\n }\n\n // allocate buffer\n buf = new utils.Buf8(buf_len);\n\n // convert\n for (i = 0, m_pos = 0; i < buf_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 0xfc00) === 0xdc00) {\n c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n m_pos++;\n }\n }\n if (c < 0x80) {\n /* one byte */\n buf[i++] = c;\n } else if (c < 0x800) {\n /* two bytes */\n buf[i++] = 0xC0 | (c >>> 6);\n buf[i++] = 0x80 | (c & 0x3f);\n } else if (c < 0x10000) {\n /* three bytes */\n buf[i++] = 0xE0 | (c >>> 12);\n buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n buf[i++] = 0x80 | (c & 0x3f);\n } else {\n /* four bytes */\n buf[i++] = 0xf0 | (c >>> 18);\n buf[i++] = 0x80 | (c >>> 12 & 0x3f);\n buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n buf[i++] = 0x80 | (c & 0x3f);\n }\n }\n\n return buf;\n};\n\n// Helper (used in 2 places)\nfunction buf2binstring(buf, len) {\n // On Chrome, the arguments in a function call that are allowed is `65534`.\n // If the length of the buffer is smaller than that, we can use this optimization,\n // otherwise we will take a slower path.\n if (len < 65534) {\n if ((buf.subarray && STR_APPLY_UIA_OK) || (!buf.subarray && STR_APPLY_OK)) {\n return String.fromCharCode.apply(null, utils.shrinkBuf(buf, len));\n }\n }\n\n var result = '';\n for (var i = 0; i < len; i++) {\n result += String.fromCharCode(buf[i]);\n }\n return result;\n}\n\n\n// Convert byte array to binary string\nexports.buf2binstring = function (buf) {\n return buf2binstring(buf, buf.length);\n};\n\n\n// Convert binary string (typed, when possible)\nexports.binstring2buf = function (str) {\n var buf = new utils.Buf8(str.length);\n for (var i = 0, len = buf.length; i < len; i++) {\n buf[i] = str.charCodeAt(i);\n }\n return buf;\n};\n\n\n// convert array to string\nexports.buf2string = function (buf, max) {\n var i, out, c, c_len;\n var len = max || buf.length;\n\n // Reserve max possible length (2 words per char)\n // NB: by unknown reasons, Array is significantly faster for\n // String.fromCharCode.apply than Uint16Array.\n var utf16buf = new Array(len * 2);\n\n for (out = 0, i = 0; i < len;) {\n c = buf[i++];\n // quick process ascii\n if (c < 0x80) { utf16buf[out++] = c; continue; }\n\n c_len = _utf8len[c];\n // skip 5 & 6 byte codes\n if (c_len > 4) { utf16buf[out++] = 0xfffd; i += c_len - 1; continue; }\n\n // apply mask on first byte\n c &= c_len === 2 ? 0x1f : c_len === 3 ? 0x0f : 0x07;\n // join the rest\n while (c_len > 1 && i < len) {\n c = (c << 6) | (buf[i++] & 0x3f);\n c_len--;\n }\n\n // terminated by end of string?\n if (c_len > 1) { utf16buf[out++] = 0xfffd; continue; }\n\n if (c < 0x10000) {\n utf16buf[out++] = c;\n } else {\n c -= 0x10000;\n utf16buf[out++] = 0xd800 | ((c >> 10) & 0x3ff);\n utf16buf[out++] = 0xdc00 | (c & 0x3ff);\n }\n }\n\n return buf2binstring(utf16buf, out);\n};\n\n\n// Calculate max possible position in utf8 buffer,\n// that will not break sequence. If that's not possible\n// - (very small limits) return max size as is.\n//\n// buf[] - utf8 bytes array\n// max - length limit (mandatory);\nexports.utf8border = function (buf, max) {\n var pos;\n\n max = max || buf.length;\n if (max > buf.length) { max = buf.length; }\n\n // go back from last position, until start of sequence found\n pos = max - 1;\n while (pos >= 0 && (buf[pos] & 0xC0) === 0x80) { pos--; }\n\n // Very small and broken sequence,\n // return max, because we should return something anyway.\n if (pos < 0) { return max; }\n\n // If we came to start of buffer - that means buffer is too small,\n // return max too.\n if (pos === 0) { return max; }\n\n return (pos + _utf8len[buf[pos]] > max) ? pos : max;\n};\n","'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nfunction ZStream() {\n /* next input byte */\n this.input = null; // JS specific, because we have no pointers\n this.next_in = 0;\n /* number of bytes available at input */\n this.avail_in = 0;\n /* total number of input bytes read so far */\n this.total_in = 0;\n /* next output byte should be put there */\n this.output = null; // JS specific, because we have no pointers\n this.next_out = 0;\n /* remaining free space at output */\n this.avail_out = 0;\n /* total number of bytes output so far */\n this.total_out = 0;\n /* last error message, NULL if no error */\n this.msg = ''/*Z_NULL*/;\n /* not visible by applications */\n this.state = null;\n /* best guess about the data type: binary or text */\n this.data_type = 2/*Z_UNKNOWN*/;\n /* adler32 value of the uncompressed data */\n this.adler = 0;\n}\n\nmodule.exports = ZStream;\n","'use strict';\n\n\nvar zlib_deflate = require('./zlib/deflate');\nvar utils = require('./utils/common');\nvar strings = require('./utils/strings');\nvar msg = require('./zlib/messages');\nvar ZStream = require('./zlib/zstream');\n\nvar toString = Object.prototype.toString;\n\n/* Public constants ==========================================================*/\n/* ===========================================================================*/\n\nvar Z_NO_FLUSH = 0;\nvar Z_FINISH = 4;\n\nvar Z_OK = 0;\nvar Z_STREAM_END = 1;\nvar Z_SYNC_FLUSH = 2;\n\nvar Z_DEFAULT_COMPRESSION = -1;\n\nvar Z_DEFAULT_STRATEGY = 0;\n\nvar Z_DEFLATED = 8;\n\n/* ===========================================================================*/\n\n\n/**\n * class Deflate\n *\n * Generic JS-style wrapper for zlib calls. If you don't need\n * streaming behaviour - use more simple functions: [[deflate]],\n * [[deflateRaw]] and [[gzip]].\n **/\n\n/* internal\n * Deflate.chunks -> Array\n *\n * Chunks of output data, if [[Deflate#onData]] not overridden.\n **/\n\n/**\n * Deflate.result -> Uint8Array|Array\n *\n * Compressed result, generated by default [[Deflate#onData]]\n * and [[Deflate#onEnd]] handlers. Filled after you push last chunk\n * (call [[Deflate#push]] with `Z_FINISH` / `true` param) or if you\n * push a chunk with explicit flush (call [[Deflate#push]] with\n * `Z_SYNC_FLUSH` param).\n **/\n\n/**\n * Deflate.err -> Number\n *\n * Error code after deflate finished. 0 (Z_OK) on success.\n * You will not need it in real life, because deflate errors\n * are possible only on wrong options or bad `onData` / `onEnd`\n * custom handlers.\n **/\n\n/**\n * Deflate.msg -> String\n *\n * Error message, if [[Deflate.err]] != 0\n **/\n\n\n/**\n * new Deflate(options)\n * - options (Object): zlib deflate options.\n *\n * Creates new deflator instance with specified params. Throws exception\n * on bad params. Supported options:\n *\n * - `level`\n * - `windowBits`\n * - `memLevel`\n * - `strategy`\n * - `dictionary`\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information on these.\n *\n * Additional options, for internal needs:\n *\n * - `chunkSize` - size of generated data chunks (16K by default)\n * - `raw` (Boolean) - do raw deflate\n * - `gzip` (Boolean) - create gzip wrapper\n * - `to` (String) - if equal to 'string', then result will be \"binary string\"\n * (each char code [0..255])\n * - `header` (Object) - custom header for gzip\n * - `text` (Boolean) - true if compressed data believed to be text\n * - `time` (Number) - modification time, unix timestamp\n * - `os` (Number) - operation system code\n * - `extra` (Array) - array of bytes with extra data (max 65536)\n * - `name` (String) - file name (binary string)\n * - `comment` (String) - comment (binary string)\n * - `hcrc` (Boolean) - true if header crc should be added\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n * , chunk1 = Uint8Array([1,2,3,4,5,6,7,8,9])\n * , chunk2 = Uint8Array([10,11,12,13,14,15,16,17,18,19]);\n *\n * var deflate = new pako.Deflate({ level: 3});\n *\n * deflate.push(chunk1, false);\n * deflate.push(chunk2, true); // true -> last chunk\n *\n * if (deflate.err) { throw new Error(deflate.err); }\n *\n * console.log(deflate.result);\n * ```\n **/\nfunction Deflate(options) {\n if (!(this instanceof Deflate)) return new Deflate(options);\n\n this.options = utils.assign({\n level: Z_DEFAULT_COMPRESSION,\n method: Z_DEFLATED,\n chunkSize: 16384,\n windowBits: 15,\n memLevel: 8,\n strategy: Z_DEFAULT_STRATEGY,\n to: ''\n }, options || {});\n\n var opt = this.options;\n\n if (opt.raw && (opt.windowBits > 0)) {\n opt.windowBits = -opt.windowBits;\n }\n\n else if (opt.gzip && (opt.windowBits > 0) && (opt.windowBits < 16)) {\n opt.windowBits += 16;\n }\n\n this.err = 0; // error code, if happens (0 = Z_OK)\n this.msg = ''; // error message\n this.ended = false; // used to avoid multiple onEnd() calls\n this.chunks = []; // chunks of compressed data\n\n this.strm = new ZStream();\n this.strm.avail_out = 0;\n\n var status = zlib_deflate.deflateInit2(\n this.strm,\n opt.level,\n opt.method,\n opt.windowBits,\n opt.memLevel,\n opt.strategy\n );\n\n if (status !== Z_OK) {\n throw new Error(msg[status]);\n }\n\n if (opt.header) {\n zlib_deflate.deflateSetHeader(this.strm, opt.header);\n }\n\n if (opt.dictionary) {\n var dict;\n // Convert data if needed\n if (typeof opt.dictionary === 'string') {\n // If we need to compress text, change encoding to utf8.\n dict = strings.string2buf(opt.dictionary);\n } else if (toString.call(opt.dictionary) === '[object ArrayBuffer]') {\n dict = new Uint8Array(opt.dictionary);\n } else {\n dict = opt.dictionary;\n }\n\n status = zlib_deflate.deflateSetDictionary(this.strm, dict);\n\n if (status !== Z_OK) {\n throw new Error(msg[status]);\n }\n\n this._dict_set = true;\n }\n}\n\n/**\n * Deflate#push(data[, mode]) -> Boolean\n * - data (Uint8Array|Array|ArrayBuffer|String): input data. Strings will be\n * converted to utf8 byte sequence.\n * - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes.\n * See constants. Skipped or `false` means Z_NO_FLUSH, `true` means Z_FINISH.\n *\n * Sends input data to deflate pipe, generating [[Deflate#onData]] calls with\n * new compressed chunks. Returns `true` on success. The last data block must have\n * mode Z_FINISH (or `true`). That will flush internal pending buffers and call\n * [[Deflate#onEnd]]. For interim explicit flushes (without ending the stream) you\n * can use mode Z_SYNC_FLUSH, keeping the compression context.\n *\n * On fail call [[Deflate#onEnd]] with error code and return false.\n *\n * We strongly recommend to use `Uint8Array` on input for best speed (output\n * array format is detected automatically). Also, don't skip last param and always\n * use the same type in your code (boolean or number). That will improve JS speed.\n *\n * For regular `Array`-s make sure all elements are [0..255].\n *\n * ##### Example\n *\n * ```javascript\n * push(chunk, false); // push one of data chunks\n * ...\n * push(chunk, true); // push last chunk\n * ```\n **/\nDeflate.prototype.push = function (data, mode) {\n var strm = this.strm;\n var chunkSize = this.options.chunkSize;\n var status, _mode;\n\n if (this.ended) { return false; }\n\n _mode = (mode === ~~mode) ? mode : ((mode === true) ? Z_FINISH : Z_NO_FLUSH);\n\n // Convert data if needed\n if (typeof data === 'string') {\n // If we need to compress text, change encoding to utf8.\n strm.input = strings.string2buf(data);\n } else if (toString.call(data) === '[object ArrayBuffer]') {\n strm.input = new Uint8Array(data);\n } else {\n strm.input = data;\n }\n\n strm.next_in = 0;\n strm.avail_in = strm.input.length;\n\n do {\n if (strm.avail_out === 0) {\n strm.output = new utils.Buf8(chunkSize);\n strm.next_out = 0;\n strm.avail_out = chunkSize;\n }\n status = zlib_deflate.deflate(strm, _mode); /* no bad return value */\n\n if (status !== Z_STREAM_END && status !== Z_OK) {\n this.onEnd(status);\n this.ended = true;\n return false;\n }\n if (strm.avail_out === 0 || (strm.avail_in === 0 && (_mode === Z_FINISH || _mode === Z_SYNC_FLUSH))) {\n if (this.options.to === 'string') {\n this.onData(strings.buf2binstring(utils.shrinkBuf(strm.output, strm.next_out)));\n } else {\n this.onData(utils.shrinkBuf(strm.output, strm.next_out));\n }\n }\n } while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== Z_STREAM_END);\n\n // Finalize on the last chunk.\n if (_mode === Z_FINISH) {\n status = zlib_deflate.deflateEnd(this.strm);\n this.onEnd(status);\n this.ended = true;\n return status === Z_OK;\n }\n\n // callback interim results if Z_SYNC_FLUSH.\n if (_mode === Z_SYNC_FLUSH) {\n this.onEnd(Z_OK);\n strm.avail_out = 0;\n return true;\n }\n\n return true;\n};\n\n\n/**\n * Deflate#onData(chunk) -> Void\n * - chunk (Uint8Array|Array|String): output data. Type of array depends\n * on js engine support. When string output requested, each chunk\n * will be string.\n *\n * By default, stores data blocks in `chunks[]` property and glue\n * those in `onEnd`. Override this handler, if you need another behaviour.\n **/\nDeflate.prototype.onData = function (chunk) {\n this.chunks.push(chunk);\n};\n\n\n/**\n * Deflate#onEnd(status) -> Void\n * - status (Number): deflate status. 0 (Z_OK) on success,\n * other if not.\n *\n * Called once after you tell deflate that the input stream is\n * complete (Z_FINISH) or should be flushed (Z_SYNC_FLUSH)\n * or if an error happened. By default - join collected chunks,\n * free memory and fill `results` / `err` properties.\n **/\nDeflate.prototype.onEnd = function (status) {\n // On success - join\n if (status === Z_OK) {\n if (this.options.to === 'string') {\n this.result = this.chunks.join('');\n } else {\n this.result = utils.flattenChunks(this.chunks);\n }\n }\n this.chunks = [];\n this.err = status;\n this.msg = this.strm.msg;\n};\n\n\n/**\n * deflate(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to compress.\n * - options (Object): zlib deflate options.\n *\n * Compress `data` with deflate algorithm and `options`.\n *\n * Supported options are:\n *\n * - level\n * - windowBits\n * - memLevel\n * - strategy\n * - dictionary\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information on these.\n *\n * Sugar (options):\n *\n * - `raw` (Boolean) - say that we work with raw stream, if you don't wish to specify\n * negative windowBits implicitly.\n * - `to` (String) - if equal to 'string', then result will be \"binary string\"\n * (each char code [0..255])\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n * , data = Uint8Array([1,2,3,4,5,6,7,8,9]);\n *\n * console.log(pako.deflate(data));\n * ```\n **/\nfunction deflate(input, options) {\n var deflator = new Deflate(options);\n\n deflator.push(input, true);\n\n // That will never happens, if you don't cheat with options :)\n if (deflator.err) { throw deflator.msg || msg[deflator.err]; }\n\n return deflator.result;\n}\n\n\n/**\n * deflateRaw(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to compress.\n * - options (Object): zlib deflate options.\n *\n * The same as [[deflate]], but creates raw data, without wrapper\n * (header and adler32 crc).\n **/\nfunction deflateRaw(input, options) {\n options = options || {};\n options.raw = true;\n return deflate(input, options);\n}\n\n\n/**\n * gzip(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to compress.\n * - options (Object): zlib deflate options.\n *\n * The same as [[deflate]], but create gzip wrapper instead of\n * deflate one.\n **/\nfunction gzip(input, options) {\n options = options || {};\n options.gzip = true;\n return deflate(input, options);\n}\n\n\nexports.Deflate = Deflate;\nexports.deflate = deflate;\nexports.deflateRaw = deflateRaw;\nexports.gzip = gzip;\n","'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\n// See state defs from inflate.js\nvar BAD = 30; /* got a data error -- remain here until reset */\nvar TYPE = 12; /* i: waiting for type bits, including last-flag bit */\n\n/*\n Decode literal, length, and distance codes and write out the resulting\n literal and match bytes until either not enough input or output is\n available, an end-of-block is encountered, or a data error is encountered.\n When large enough input and output buffers are supplied to inflate(), for\n example, a 16K input buffer and a 64K output buffer, more than 95% of the\n inflate execution time is spent in this routine.\n\n Entry assumptions:\n\n state.mode === LEN\n strm.avail_in >= 6\n strm.avail_out >= 258\n start >= strm.avail_out\n state.bits < 8\n\n On return, state.mode is one of:\n\n LEN -- ran out of enough output space or enough available input\n TYPE -- reached end of block code, inflate() to interpret next block\n BAD -- error in block data\n\n Notes:\n\n - The maximum input bits used by a length/distance pair is 15 bits for the\n length code, 5 bits for the length extra, 15 bits for the distance code,\n and 13 bits for the distance extra. This totals 48 bits, or six bytes.\n Therefore if strm.avail_in >= 6, then there is enough input to avoid\n checking for available input while decoding.\n\n - The maximum bytes that a single length/distance pair can output is 258\n bytes, which is the maximum length that can be coded. inflate_fast()\n requires strm.avail_out >= 258 for each loop to avoid checking for\n output space.\n */\nmodule.exports = function inflate_fast(strm, start) {\n var state;\n var _in; /* local strm.input */\n var last; /* have enough input while in < last */\n var _out; /* local strm.output */\n var beg; /* inflate()'s initial strm.output */\n var end; /* while out < end, enough space available */\n//#ifdef INFLATE_STRICT\n var dmax; /* maximum distance from zlib header */\n//#endif\n var wsize; /* window size or zero if not using window */\n var whave; /* valid bytes in the window */\n var wnext; /* window write index */\n // Use `s_window` instead `window`, avoid conflict with instrumentation tools\n var s_window; /* allocated sliding window, if wsize != 0 */\n var hold; /* local strm.hold */\n var bits; /* local strm.bits */\n var lcode; /* local strm.lencode */\n var dcode; /* local strm.distcode */\n var lmask; /* mask for first level of length codes */\n var dmask; /* mask for first level of distance codes */\n var here; /* retrieved table entry */\n var op; /* code bits, operation, extra bits, or */\n /* window position, window bytes to copy */\n var len; /* match length, unused bytes */\n var dist; /* match distance */\n var from; /* where to copy match from */\n var from_source;\n\n\n var input, output; // JS specific, because we have no pointers\n\n /* copy state to local variables */\n state = strm.state;\n //here = state.here;\n _in = strm.next_in;\n input = strm.input;\n last = _in + (strm.avail_in - 5);\n _out = strm.next_out;\n output = strm.output;\n beg = _out - (start - strm.avail_out);\n end = _out + (strm.avail_out - 257);\n//#ifdef INFLATE_STRICT\n dmax = state.dmax;\n//#endif\n wsize = state.wsize;\n whave = state.whave;\n wnext = state.wnext;\n s_window = state.window;\n hold = state.hold;\n bits = state.bits;\n lcode = state.lencode;\n dcode = state.distcode;\n lmask = (1 << state.lenbits) - 1;\n dmask = (1 << state.distbits) - 1;\n\n\n /* decode literals and length/distances until end-of-block or not enough\n input data or output space */\n\n top:\n do {\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n\n here = lcode[hold & lmask];\n\n dolen:\n for (;;) { // Goto emulation\n op = here >>> 24/*here.bits*/;\n hold >>>= op;\n bits -= op;\n op = (here >>> 16) & 0xff/*here.op*/;\n if (op === 0) { /* literal */\n //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n // \"inflate: literal '%c'\\n\" :\n // \"inflate: literal 0x%02x\\n\", here.val));\n output[_out++] = here & 0xffff/*here.val*/;\n }\n else if (op & 16) { /* length base */\n len = here & 0xffff/*here.val*/;\n op &= 15; /* number of extra bits */\n if (op) {\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n len += hold & ((1 << op) - 1);\n hold >>>= op;\n bits -= op;\n }\n //Tracevv((stderr, \"inflate: length %u\\n\", len));\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n here = dcode[hold & dmask];\n\n dodist:\n for (;;) { // goto emulation\n op = here >>> 24/*here.bits*/;\n hold >>>= op;\n bits -= op;\n op = (here >>> 16) & 0xff/*here.op*/;\n\n if (op & 16) { /* distance base */\n dist = here & 0xffff/*here.val*/;\n op &= 15; /* number of extra bits */\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n }\n dist += hold & ((1 << op) - 1);\n//#ifdef INFLATE_STRICT\n if (dist > dmax) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break top;\n }\n//#endif\n hold >>>= op;\n bits -= op;\n //Tracevv((stderr, \"inflate: distance %u\\n\", dist));\n op = _out - beg; /* max distance in output */\n if (dist > op) { /* see if copy from window */\n op = dist - op; /* distance back in window */\n if (op > whave) {\n if (state.sane) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break top;\n }\n\n// (!) This block is disabled in zlib defaults,\n// don't enable it for binary compatibility\n//#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n// if (len <= op - whave) {\n// do {\n// output[_out++] = 0;\n// } while (--len);\n// continue top;\n// }\n// len -= op - whave;\n// do {\n// output[_out++] = 0;\n// } while (--op > whave);\n// if (op === 0) {\n// from = _out - dist;\n// do {\n// output[_out++] = output[from++];\n// } while (--len);\n// continue top;\n// }\n//#endif\n }\n from = 0; // window index\n from_source = s_window;\n if (wnext === 0) { /* very common case */\n from += wsize - op;\n if (op < len) { /* some from window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n else if (wnext < op) { /* wrap around window */\n from += wsize + wnext - op;\n op -= wnext;\n if (op < len) { /* some from end of window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = 0;\n if (wnext < len) { /* some from start of window */\n op = wnext;\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n }\n else { /* contiguous in window */\n from += wnext - op;\n if (op < len) { /* some from window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n while (len > 2) {\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n len -= 3;\n }\n if (len) {\n output[_out++] = from_source[from++];\n if (len > 1) {\n output[_out++] = from_source[from++];\n }\n }\n }\n else {\n from = _out - dist; /* copy direct from output */\n do { /* minimum length is three */\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n len -= 3;\n } while (len > 2);\n if (len) {\n output[_out++] = output[from++];\n if (len > 1) {\n output[_out++] = output[from++];\n }\n }\n }\n }\n else if ((op & 64) === 0) { /* 2nd level distance code */\n here = dcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];\n continue dodist;\n }\n else {\n strm.msg = 'invalid distance code';\n state.mode = BAD;\n break top;\n }\n\n break; // need to emulate goto via \"continue\"\n }\n }\n else if ((op & 64) === 0) { /* 2nd level length code */\n here = lcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];\n continue dolen;\n }\n else if (op & 32) { /* end-of-block */\n //Tracevv((stderr, \"inflate: end of block\\n\"));\n state.mode = TYPE;\n break top;\n }\n else {\n strm.msg = 'invalid literal/length code';\n state.mode = BAD;\n break top;\n }\n\n break; // need to emulate goto via \"continue\"\n }\n } while (_in < last && _out < end);\n\n /* return unused bytes (on entry, bits < 8, so in won't go too far back) */\n len = bits >> 3;\n _in -= len;\n bits -= len << 3;\n hold &= (1 << bits) - 1;\n\n /* update state and return */\n strm.next_in = _in;\n strm.next_out = _out;\n strm.avail_in = (_in < last ? 5 + (last - _in) : 5 - (_in - last));\n strm.avail_out = (_out < end ? 257 + (end - _out) : 257 - (_out - end));\n state.hold = hold;\n state.bits = bits;\n return;\n};\n","'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nvar utils = require('../utils/common');\n\nvar MAXBITS = 15;\nvar ENOUGH_LENS = 852;\nvar ENOUGH_DISTS = 592;\n//var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);\n\nvar CODES = 0;\nvar LENS = 1;\nvar DISTS = 2;\n\nvar lbase = [ /* Length codes 257..285 base */\n 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,\n 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0\n];\n\nvar lext = [ /* Length codes 257..285 extra */\n 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,\n 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78\n];\n\nvar dbase = [ /* Distance codes 0..29 base */\n 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,\n 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,\n 8193, 12289, 16385, 24577, 0, 0\n];\n\nvar dext = [ /* Distance codes 0..29 extra */\n 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,\n 23, 23, 24, 24, 25, 25, 26, 26, 27, 27,\n 28, 28, 29, 29, 64, 64\n];\n\nmodule.exports = function inflate_table(type, lens, lens_index, codes, table, table_index, work, opts)\n{\n var bits = opts.bits;\n //here = opts.here; /* table entry for duplication */\n\n var len = 0; /* a code's length in bits */\n var sym = 0; /* index of code symbols */\n var min = 0, max = 0; /* minimum and maximum code lengths */\n var root = 0; /* number of index bits for root table */\n var curr = 0; /* number of index bits for current table */\n var drop = 0; /* code bits to drop for sub-table */\n var left = 0; /* number of prefix codes available */\n var used = 0; /* code entries in table used */\n var huff = 0; /* Huffman code */\n var incr; /* for incrementing code, index */\n var fill; /* index for replicating entries */\n var low; /* low bits for current root entry */\n var mask; /* mask for low root bits */\n var next; /* next available space in table */\n var base = null; /* base value table to use */\n var base_index = 0;\n// var shoextra; /* extra bits table to use */\n var end; /* use base and extra for symbol > end */\n var count = new utils.Buf16(MAXBITS + 1); //[MAXBITS+1]; /* number of codes of each length */\n var offs = new utils.Buf16(MAXBITS + 1); //[MAXBITS+1]; /* offsets in table for each length */\n var extra = null;\n var extra_index = 0;\n\n var here_bits, here_op, here_val;\n\n /*\n Process a set of code lengths to create a canonical Huffman code. The\n code lengths are lens[0..codes-1]. Each length corresponds to the\n symbols 0..codes-1. The Huffman code is generated by first sorting the\n symbols by length from short to long, and retaining the symbol order\n for codes with equal lengths. Then the code starts with all zero bits\n for the first code of the shortest length, and the codes are integer\n increments for the same length, and zeros are appended as the length\n increases. For the deflate format, these bits are stored backwards\n from their more natural integer increment ordering, and so when the\n decoding tables are built in the large loop below, the integer codes\n are incremented backwards.\n\n This routine assumes, but does not check, that all of the entries in\n lens[] are in the range 0..MAXBITS. The caller must assure this.\n 1..MAXBITS is interpreted as that code length. zero means that that\n symbol does not occur in this code.\n\n The codes are sorted by computing a count of codes for each length,\n creating from that a table of starting indices for each length in the\n sorted table, and then entering the symbols in order in the sorted\n table. The sorted table is work[], with that space being provided by\n the caller.\n\n The length counts are used for other purposes as well, i.e. finding\n the minimum and maximum length codes, determining if there are any\n codes at all, checking for a valid set of lengths, and looking ahead\n at length counts to determine sub-table sizes when building the\n decoding tables.\n */\n\n /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */\n for (len = 0; len <= MAXBITS; len++) {\n count[len] = 0;\n }\n for (sym = 0; sym < codes; sym++) {\n count[lens[lens_index + sym]]++;\n }\n\n /* bound code lengths, force root to be within code lengths */\n root = bits;\n for (max = MAXBITS; max >= 1; max--) {\n if (count[max] !== 0) { break; }\n }\n if (root > max) {\n root = max;\n }\n if (max === 0) { /* no symbols to code at all */\n //table.op[opts.table_index] = 64; //here.op = (var char)64; /* invalid code marker */\n //table.bits[opts.table_index] = 1; //here.bits = (var char)1;\n //table.val[opts.table_index++] = 0; //here.val = (var short)0;\n table[table_index++] = (1 << 24) | (64 << 16) | 0;\n\n\n //table.op[opts.table_index] = 64;\n //table.bits[opts.table_index] = 1;\n //table.val[opts.table_index++] = 0;\n table[table_index++] = (1 << 24) | (64 << 16) | 0;\n\n opts.bits = 1;\n return 0; /* no symbols, but wait for decoding to report error */\n }\n for (min = 1; min < max; min++) {\n if (count[min] !== 0) { break; }\n }\n if (root < min) {\n root = min;\n }\n\n /* check for an over-subscribed or incomplete set of lengths */\n left = 1;\n for (len = 1; len <= MAXBITS; len++) {\n left <<= 1;\n left -= count[len];\n if (left < 0) {\n return -1;\n } /* over-subscribed */\n }\n if (left > 0 && (type === CODES || max !== 1)) {\n return -1; /* incomplete set */\n }\n\n /* generate offsets into symbol table for each length for sorting */\n offs[1] = 0;\n for (len = 1; len < MAXBITS; len++) {\n offs[len + 1] = offs[len] + count[len];\n }\n\n /* sort symbols by length, by symbol order within each length */\n for (sym = 0; sym < codes; sym++) {\n if (lens[lens_index + sym] !== 0) {\n work[offs[lens[lens_index + sym]]++] = sym;\n }\n }\n\n /*\n Create and fill in decoding tables. In this loop, the table being\n filled is at next and has curr index bits. The code being used is huff\n with length len. That code is converted to an index by dropping drop\n bits off of the bottom. For codes where len is less than drop + curr,\n those top drop + curr - len bits are incremented through all values to\n fill the table with replicated entries.\n\n root is the number of index bits for the root table. When len exceeds\n root, sub-tables are created pointed to by the root entry with an index\n of the low root bits of huff. This is saved in low to check for when a\n new sub-table should be started. drop is zero when the root table is\n being filled, and drop is root when sub-tables are being filled.\n\n When a new sub-table is needed, it is necessary to look ahead in the\n code lengths to determine what size sub-table is needed. The length\n counts are used for this, and so count[] is decremented as codes are\n entered in the tables.\n\n used keeps track of how many table entries have been allocated from the\n provided *table space. It is checked for LENS and DIST tables against\n the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in\n the initial root table size constants. See the comments in inftrees.h\n for more information.\n\n sym increments through all symbols, and the loop terminates when\n all codes of length max, i.e. all codes, have been processed. This\n routine permits incomplete codes, so another loop after this one fills\n in the rest of the decoding tables with invalid code markers.\n */\n\n /* set up for code type */\n // poor man optimization - use if-else instead of switch,\n // to avoid deopts in old v8\n if (type === CODES) {\n base = extra = work; /* dummy value--not used */\n end = 19;\n\n } else if (type === LENS) {\n base = lbase;\n base_index -= 257;\n extra = lext;\n extra_index -= 257;\n end = 256;\n\n } else { /* DISTS */\n base = dbase;\n extra = dext;\n end = -1;\n }\n\n /* initialize opts for loop */\n huff = 0; /* starting code */\n sym = 0; /* starting code symbol */\n len = min; /* starting code length */\n next = table_index; /* current table to fill in */\n curr = root; /* current table index bits */\n drop = 0; /* current bits to drop from code for index */\n low = -1; /* trigger new sub-table when len > root */\n used = 1 << root; /* use root table entries */\n mask = used - 1; /* mask for comparing low */\n\n /* check available table space */\n if ((type === LENS && used > ENOUGH_LENS) ||\n (type === DISTS && used > ENOUGH_DISTS)) {\n return 1;\n }\n\n /* process all codes and make table entries */\n for (;;) {\n /* create table entry */\n here_bits = len - drop;\n if (work[sym] < end) {\n here_op = 0;\n here_val = work[sym];\n }\n else if (work[sym] > end) {\n here_op = extra[extra_index + work[sym]];\n here_val = base[base_index + work[sym]];\n }\n else {\n here_op = 32 + 64; /* end of block */\n here_val = 0;\n }\n\n /* replicate for those indices with low len bits equal to huff */\n incr = 1 << (len - drop);\n fill = 1 << curr;\n min = fill; /* save offset to next table */\n do {\n fill -= incr;\n table[next + (huff >> drop) + fill] = (here_bits << 24) | (here_op << 16) | here_val |0;\n } while (fill !== 0);\n\n /* backwards increment the len-bit code huff */\n incr = 1 << (len - 1);\n while (huff & incr) {\n incr >>= 1;\n }\n if (incr !== 0) {\n huff &= incr - 1;\n huff += incr;\n } else {\n huff = 0;\n }\n\n /* go to next symbol, update count, len */\n sym++;\n if (--count[len] === 0) {\n if (len === max) { break; }\n len = lens[lens_index + work[sym]];\n }\n\n /* create new sub-table if needed */\n if (len > root && (huff & mask) !== low) {\n /* if first time, transition to sub-tables */\n if (drop === 0) {\n drop = root;\n }\n\n /* increment past last table */\n next += min; /* here min is 1 << curr */\n\n /* determine length of next table */\n curr = len - drop;\n left = 1 << curr;\n while (curr + drop < max) {\n left -= count[curr + drop];\n if (left <= 0) { break; }\n curr++;\n left <<= 1;\n }\n\n /* check for enough space */\n used += 1 << curr;\n if ((type === LENS && used > ENOUGH_LENS) ||\n (type === DISTS && used > ENOUGH_DISTS)) {\n return 1;\n }\n\n /* point entry in root table to sub-table */\n low = huff & mask;\n /*table.op[low] = curr;\n table.bits[low] = root;\n table.val[low] = next - opts.table_index;*/\n table[low] = (root << 24) | (curr << 16) | (next - table_index) |0;\n }\n }\n\n /* fill in remaining table entry if code is incomplete (guaranteed to have\n at most one remaining entry, since if the code is incomplete, the\n maximum code length that was allowed to get this far is one bit) */\n if (huff !== 0) {\n //table.op[next + huff] = 64; /* invalid code marker */\n //table.bits[next + huff] = len - drop;\n //table.val[next + huff] = 0;\n table[next + huff] = ((len - drop) << 24) | (64 << 16) |0;\n }\n\n /* set return parameters */\n //opts.table_index += used;\n opts.bits = root;\n return 0;\n};\n","'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nvar utils = require('../utils/common');\nvar adler32 = require('./adler32');\nvar crc32 = require('./crc32');\nvar inflate_fast = require('./inffast');\nvar inflate_table = require('./inftrees');\n\nvar CODES = 0;\nvar LENS = 1;\nvar DISTS = 2;\n\n/* Public constants ==========================================================*/\n/* ===========================================================================*/\n\n\n/* Allowed flush values; see deflate() and inflate() below for details */\n//var Z_NO_FLUSH = 0;\n//var Z_PARTIAL_FLUSH = 1;\n//var Z_SYNC_FLUSH = 2;\n//var Z_FULL_FLUSH = 3;\nvar Z_FINISH = 4;\nvar Z_BLOCK = 5;\nvar Z_TREES = 6;\n\n\n/* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\nvar Z_OK = 0;\nvar Z_STREAM_END = 1;\nvar Z_NEED_DICT = 2;\n//var Z_ERRNO = -1;\nvar Z_STREAM_ERROR = -2;\nvar Z_DATA_ERROR = -3;\nvar Z_MEM_ERROR = -4;\nvar Z_BUF_ERROR = -5;\n//var Z_VERSION_ERROR = -6;\n\n/* The deflate compression method */\nvar Z_DEFLATED = 8;\n\n\n/* STATES ====================================================================*/\n/* ===========================================================================*/\n\n\nvar HEAD = 1; /* i: waiting for magic header */\nvar FLAGS = 2; /* i: waiting for method and flags (gzip) */\nvar TIME = 3; /* i: waiting for modification time (gzip) */\nvar OS = 4; /* i: waiting for extra flags and operating system (gzip) */\nvar EXLEN = 5; /* i: waiting for extra length (gzip) */\nvar EXTRA = 6; /* i: waiting for extra bytes (gzip) */\nvar NAME = 7; /* i: waiting for end of file name (gzip) */\nvar COMMENT = 8; /* i: waiting for end of comment (gzip) */\nvar HCRC = 9; /* i: waiting for header crc (gzip) */\nvar DICTID = 10; /* i: waiting for dictionary check value */\nvar DICT = 11; /* waiting for inflateSetDictionary() call */\nvar TYPE = 12; /* i: waiting for type bits, including last-flag bit */\nvar TYPEDO = 13; /* i: same, but skip check to exit inflate on new block */\nvar STORED = 14; /* i: waiting for stored size (length and complement) */\nvar COPY_ = 15; /* i/o: same as COPY below, but only first time in */\nvar COPY = 16; /* i/o: waiting for input or output to copy stored block */\nvar TABLE = 17; /* i: waiting for dynamic block table lengths */\nvar LENLENS = 18; /* i: waiting for code length code lengths */\nvar CODELENS = 19; /* i: waiting for length/lit and distance code lengths */\nvar LEN_ = 20; /* i: same as LEN below, but only first time in */\nvar LEN = 21; /* i: waiting for length/lit/eob code */\nvar LENEXT = 22; /* i: waiting for length extra bits */\nvar DIST = 23; /* i: waiting for distance code */\nvar DISTEXT = 24; /* i: waiting for distance extra bits */\nvar MATCH = 25; /* o: waiting for output space to copy string */\nvar LIT = 26; /* o: waiting for output space to write literal */\nvar CHECK = 27; /* i: waiting for 32-bit check value */\nvar LENGTH = 28; /* i: waiting for 32-bit length (gzip) */\nvar DONE = 29; /* finished check, done -- remain here until reset */\nvar BAD = 30; /* got a data error -- remain here until reset */\nvar MEM = 31; /* got an inflate() memory error -- remain here until reset */\nvar SYNC = 32; /* looking for synchronization bytes to restart inflate() */\n\n/* ===========================================================================*/\n\n\n\nvar ENOUGH_LENS = 852;\nvar ENOUGH_DISTS = 592;\n//var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);\n\nvar MAX_WBITS = 15;\n/* 32K LZ77 window */\nvar DEF_WBITS = MAX_WBITS;\n\n\nfunction zswap32(q) {\n return (((q >>> 24) & 0xff) +\n ((q >>> 8) & 0xff00) +\n ((q & 0xff00) << 8) +\n ((q & 0xff) << 24));\n}\n\n\nfunction InflateState() {\n this.mode = 0; /* current inflate mode */\n this.last = false; /* true if processing last block */\n this.wrap = 0; /* bit 0 true for zlib, bit 1 true for gzip */\n this.havedict = false; /* true if dictionary provided */\n this.flags = 0; /* gzip header method and flags (0 if zlib) */\n this.dmax = 0; /* zlib header max distance (INFLATE_STRICT) */\n this.check = 0; /* protected copy of check value */\n this.total = 0; /* protected copy of output count */\n // TODO: may be {}\n this.head = null; /* where to save gzip header information */\n\n /* sliding window */\n this.wbits = 0; /* log base 2 of requested window size */\n this.wsize = 0; /* window size or zero if not using window */\n this.whave = 0; /* valid bytes in the window */\n this.wnext = 0; /* window write index */\n this.window = null; /* allocated sliding window, if needed */\n\n /* bit accumulator */\n this.hold = 0; /* input bit accumulator */\n this.bits = 0; /* number of bits in \"in\" */\n\n /* for string and stored block copying */\n this.length = 0; /* literal or length of data to copy */\n this.offset = 0; /* distance back to copy string from */\n\n /* for table and code decoding */\n this.extra = 0; /* extra bits needed */\n\n /* fixed and dynamic code tables */\n this.lencode = null; /* starting table for length/literal codes */\n this.distcode = null; /* starting table for distance codes */\n this.lenbits = 0; /* index bits for lencode */\n this.distbits = 0; /* index bits for distcode */\n\n /* dynamic table building */\n this.ncode = 0; /* number of code length code lengths */\n this.nlen = 0; /* number of length code lengths */\n this.ndist = 0; /* number of distance code lengths */\n this.have = 0; /* number of code lengths in lens[] */\n this.next = null; /* next available space in codes[] */\n\n this.lens = new utils.Buf16(320); /* temporary storage for code lengths */\n this.work = new utils.Buf16(288); /* work area for code table building */\n\n /*\n because we don't have pointers in js, we use lencode and distcode directly\n as buffers so we don't need codes\n */\n //this.codes = new utils.Buf32(ENOUGH); /* space for code tables */\n this.lendyn = null; /* dynamic table for length/literal codes (JS specific) */\n this.distdyn = null; /* dynamic table for distance codes (JS specific) */\n this.sane = 0; /* if false, allow invalid distance too far */\n this.back = 0; /* bits back of last unprocessed length/lit */\n this.was = 0; /* initial length of match */\n}\n\nfunction inflateResetKeep(strm) {\n var state;\n\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n strm.total_in = strm.total_out = state.total = 0;\n strm.msg = ''; /*Z_NULL*/\n if (state.wrap) { /* to support ill-conceived Java test suite */\n strm.adler = state.wrap & 1;\n }\n state.mode = HEAD;\n state.last = 0;\n state.havedict = 0;\n state.dmax = 32768;\n state.head = null/*Z_NULL*/;\n state.hold = 0;\n state.bits = 0;\n //state.lencode = state.distcode = state.next = state.codes;\n state.lencode = state.lendyn = new utils.Buf32(ENOUGH_LENS);\n state.distcode = state.distdyn = new utils.Buf32(ENOUGH_DISTS);\n\n state.sane = 1;\n state.back = -1;\n //Tracev((stderr, \"inflate: reset\\n\"));\n return Z_OK;\n}\n\nfunction inflateReset(strm) {\n var state;\n\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n state.wsize = 0;\n state.whave = 0;\n state.wnext = 0;\n return inflateResetKeep(strm);\n\n}\n\nfunction inflateReset2(strm, windowBits) {\n var wrap;\n var state;\n\n /* get the state */\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n\n /* extract wrap request from windowBits parameter */\n if (windowBits < 0) {\n wrap = 0;\n windowBits = -windowBits;\n }\n else {\n wrap = (windowBits >> 4) + 1;\n if (windowBits < 48) {\n windowBits &= 15;\n }\n }\n\n /* set number of window bits, free window if different */\n if (windowBits && (windowBits < 8 || windowBits > 15)) {\n return Z_STREAM_ERROR;\n }\n if (state.window !== null && state.wbits !== windowBits) {\n state.window = null;\n }\n\n /* update state and reset the rest of it */\n state.wrap = wrap;\n state.wbits = windowBits;\n return inflateReset(strm);\n}\n\nfunction inflateInit2(strm, windowBits) {\n var ret;\n var state;\n\n if (!strm) { return Z_STREAM_ERROR; }\n //strm.msg = Z_NULL; /* in case we return an error */\n\n state = new InflateState();\n\n //if (state === Z_NULL) return Z_MEM_ERROR;\n //Tracev((stderr, \"inflate: allocated\\n\"));\n strm.state = state;\n state.window = null/*Z_NULL*/;\n ret = inflateReset2(strm, windowBits);\n if (ret !== Z_OK) {\n strm.state = null/*Z_NULL*/;\n }\n return ret;\n}\n\nfunction inflateInit(strm) {\n return inflateInit2(strm, DEF_WBITS);\n}\n\n\n/*\n Return state with length and distance decoding tables and index sizes set to\n fixed code decoding. Normally this returns fixed tables from inffixed.h.\n If BUILDFIXED is defined, then instead this routine builds the tables the\n first time it's called, and returns those tables the first time and\n thereafter. This reduces the size of the code by about 2K bytes, in\n exchange for a little execution time. However, BUILDFIXED should not be\n used for threaded applications, since the rewriting of the tables and virgin\n may not be thread-safe.\n */\nvar virgin = true;\n\nvar lenfix, distfix; // We have no pointers in JS, so keep tables separate\n\nfunction fixedtables(state) {\n /* build fixed huffman tables if first call (may not be thread safe) */\n if (virgin) {\n var sym;\n\n lenfix = new utils.Buf32(512);\n distfix = new utils.Buf32(32);\n\n /* literal/length table */\n sym = 0;\n while (sym < 144) { state.lens[sym++] = 8; }\n while (sym < 256) { state.lens[sym++] = 9; }\n while (sym < 280) { state.lens[sym++] = 7; }\n while (sym < 288) { state.lens[sym++] = 8; }\n\n inflate_table(LENS, state.lens, 0, 288, lenfix, 0, state.work, { bits: 9 });\n\n /* distance table */\n sym = 0;\n while (sym < 32) { state.lens[sym++] = 5; }\n\n inflate_table(DISTS, state.lens, 0, 32, distfix, 0, state.work, { bits: 5 });\n\n /* do this just once */\n virgin = false;\n }\n\n state.lencode = lenfix;\n state.lenbits = 9;\n state.distcode = distfix;\n state.distbits = 5;\n}\n\n\n/*\n Update the window with the last wsize (normally 32K) bytes written before\n returning. If window does not exist yet, create it. This is only called\n when a window is already in use, or when output has been written during this\n inflate call, but the end of the deflate stream has not been reached yet.\n It is also called to create a window for dictionary data when a dictionary\n is loaded.\n\n Providing output buffers larger than 32K to inflate() should provide a speed\n advantage, since only the last 32K of output is copied to the sliding window\n upon return from inflate(), and since all distances after the first 32K of\n output will fall in the output data, making match copies simpler and faster.\n The advantage may be dependent on the size of the processor's data caches.\n */\nfunction updatewindow(strm, src, end, copy) {\n var dist;\n var state = strm.state;\n\n /* if it hasn't been done already, allocate space for the window */\n if (state.window === null) {\n state.wsize = 1 << state.wbits;\n state.wnext = 0;\n state.whave = 0;\n\n state.window = new utils.Buf8(state.wsize);\n }\n\n /* copy state->wsize or less output bytes into the circular window */\n if (copy >= state.wsize) {\n utils.arraySet(state.window, src, end - state.wsize, state.wsize, 0);\n state.wnext = 0;\n state.whave = state.wsize;\n }\n else {\n dist = state.wsize - state.wnext;\n if (dist > copy) {\n dist = copy;\n }\n //zmemcpy(state->window + state->wnext, end - copy, dist);\n utils.arraySet(state.window, src, end - copy, dist, state.wnext);\n copy -= dist;\n if (copy) {\n //zmemcpy(state->window, end - copy, copy);\n utils.arraySet(state.window, src, end - copy, copy, 0);\n state.wnext = copy;\n state.whave = state.wsize;\n }\n else {\n state.wnext += dist;\n if (state.wnext === state.wsize) { state.wnext = 0; }\n if (state.whave < state.wsize) { state.whave += dist; }\n }\n }\n return 0;\n}\n\nfunction inflate(strm, flush) {\n var state;\n var input, output; // input/output buffers\n var next; /* next input INDEX */\n var put; /* next output INDEX */\n var have, left; /* available input and output */\n var hold; /* bit buffer */\n var bits; /* bits in bit buffer */\n var _in, _out; /* save starting available input and output */\n var copy; /* number of stored or match bytes to copy */\n var from; /* where to copy match bytes from */\n var from_source;\n var here = 0; /* current decoding table entry */\n var here_bits, here_op, here_val; // paked \"here\" denormalized (JS specific)\n //var last; /* parent table entry */\n var last_bits, last_op, last_val; // paked \"last\" denormalized (JS specific)\n var len; /* length to copy for repeats, bits to drop */\n var ret; /* return code */\n var hbuf = new utils.Buf8(4); /* buffer for gzip header crc calculation */\n var opts;\n\n var n; // temporary var for NEED_BITS\n\n var order = /* permutation of code lengths */\n [ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ];\n\n\n if (!strm || !strm.state || !strm.output ||\n (!strm.input && strm.avail_in !== 0)) {\n return Z_STREAM_ERROR;\n }\n\n state = strm.state;\n if (state.mode === TYPE) { state.mode = TYPEDO; } /* skip check */\n\n\n //--- LOAD() ---\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n //---\n\n _in = have;\n _out = left;\n ret = Z_OK;\n\n inf_leave: // goto emulation\n for (;;) {\n switch (state.mode) {\n case HEAD:\n if (state.wrap === 0) {\n state.mode = TYPEDO;\n break;\n }\n //=== NEEDBITS(16);\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if ((state.wrap & 2) && hold === 0x8b1f) { /* gzip header */\n state.check = 0/*crc32(0L, Z_NULL, 0)*/;\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = FLAGS;\n break;\n }\n state.flags = 0; /* expect zlib header */\n if (state.head) {\n state.head.done = false;\n }\n if (!(state.wrap & 1) || /* check if zlib header allowed */\n (((hold & 0xff)/*BITS(8)*/ << 8) + (hold >> 8)) % 31) {\n strm.msg = 'incorrect header check';\n state.mode = BAD;\n break;\n }\n if ((hold & 0x0f)/*BITS(4)*/ !== Z_DEFLATED) {\n strm.msg = 'unknown compression method';\n state.mode = BAD;\n break;\n }\n //--- DROPBITS(4) ---//\n hold >>>= 4;\n bits -= 4;\n //---//\n len = (hold & 0x0f)/*BITS(4)*/ + 8;\n if (state.wbits === 0) {\n state.wbits = len;\n }\n else if (len > state.wbits) {\n strm.msg = 'invalid window size';\n state.mode = BAD;\n break;\n }\n state.dmax = 1 << len;\n //Tracev((stderr, \"inflate: zlib header ok\\n\"));\n strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;\n state.mode = hold & 0x200 ? DICTID : TYPE;\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n break;\n case FLAGS:\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.flags = hold;\n if ((state.flags & 0xff) !== Z_DEFLATED) {\n strm.msg = 'unknown compression method';\n state.mode = BAD;\n break;\n }\n if (state.flags & 0xe000) {\n strm.msg = 'unknown header flags set';\n state.mode = BAD;\n break;\n }\n if (state.head) {\n state.head.text = ((hold >> 8) & 1);\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = TIME;\n /* falls through */\n case TIME:\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (state.head) {\n state.head.time = hold;\n }\n if (state.flags & 0x0200) {\n //=== CRC4(state.check, hold)\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n hbuf[2] = (hold >>> 16) & 0xff;\n hbuf[3] = (hold >>> 24) & 0xff;\n state.check = crc32(state.check, hbuf, 4, 0);\n //===\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = OS;\n /* falls through */\n case OS:\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (state.head) {\n state.head.xflags = (hold & 0xff);\n state.head.os = (hold >> 8);\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = EXLEN;\n /* falls through */\n case EXLEN:\n if (state.flags & 0x0400) {\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.length = hold;\n if (state.head) {\n state.head.extra_len = hold;\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n }\n else if (state.head) {\n state.head.extra = null/*Z_NULL*/;\n }\n state.mode = EXTRA;\n /* falls through */\n case EXTRA:\n if (state.flags & 0x0400) {\n copy = state.length;\n if (copy > have) { copy = have; }\n if (copy) {\n if (state.head) {\n len = state.head.extra_len - state.length;\n if (!state.head.extra) {\n // Use untyped array for more convenient processing later\n state.head.extra = new Array(state.head.extra_len);\n }\n utils.arraySet(\n state.head.extra,\n input,\n next,\n // extra field is limited to 65536 bytes\n // - no need for additional size check\n copy,\n /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/\n len\n );\n //zmemcpy(state.head.extra + len, next,\n // len + copy > state.head.extra_max ?\n // state.head.extra_max - len : copy);\n }\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n state.length -= copy;\n }\n if (state.length) { break inf_leave; }\n }\n state.length = 0;\n state.mode = NAME;\n /* falls through */\n case NAME:\n if (state.flags & 0x0800) {\n if (have === 0) { break inf_leave; }\n copy = 0;\n do {\n // TODO: 2 or 1 bytes?\n len = input[next + copy++];\n /* use constant limit because in js we should not preallocate memory */\n if (state.head && len &&\n (state.length < 65536 /*state.head.name_max*/)) {\n state.head.name += String.fromCharCode(len);\n }\n } while (len && copy < have);\n\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) { break inf_leave; }\n }\n else if (state.head) {\n state.head.name = null;\n }\n state.length = 0;\n state.mode = COMMENT;\n /* falls through */\n case COMMENT:\n if (state.flags & 0x1000) {\n if (have === 0) { break inf_leave; }\n copy = 0;\n do {\n len = input[next + copy++];\n /* use constant limit because in js we should not preallocate memory */\n if (state.head && len &&\n (state.length < 65536 /*state.head.comm_max*/)) {\n state.head.comment += String.fromCharCode(len);\n }\n } while (len && copy < have);\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) { break inf_leave; }\n }\n else if (state.head) {\n state.head.comment = null;\n }\n state.mode = HCRC;\n /* falls through */\n case HCRC:\n if (state.flags & 0x0200) {\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (hold !== (state.check & 0xffff)) {\n strm.msg = 'header crc mismatch';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n }\n if (state.head) {\n state.head.hcrc = ((state.flags >> 9) & 1);\n state.head.done = true;\n }\n strm.adler = state.check = 0;\n state.mode = TYPE;\n break;\n case DICTID:\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n strm.adler = state.check = zswap32(hold);\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = DICT;\n /* falls through */\n case DICT:\n if (state.havedict === 0) {\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n return Z_NEED_DICT;\n }\n strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;\n state.mode = TYPE;\n /* falls through */\n case TYPE:\n if (flush === Z_BLOCK || flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case TYPEDO:\n if (state.last) {\n //--- BYTEBITS() ---//\n hold >>>= bits & 7;\n bits -= bits & 7;\n //---//\n state.mode = CHECK;\n break;\n }\n //=== NEEDBITS(3); */\n while (bits < 3) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.last = (hold & 0x01)/*BITS(1)*/;\n //--- DROPBITS(1) ---//\n hold >>>= 1;\n bits -= 1;\n //---//\n\n switch ((hold & 0x03)/*BITS(2)*/) {\n case 0: /* stored block */\n //Tracev((stderr, \"inflate: stored block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = STORED;\n break;\n case 1: /* fixed block */\n fixedtables(state);\n //Tracev((stderr, \"inflate: fixed codes block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = LEN_; /* decode codes */\n if (flush === Z_TREES) {\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n break inf_leave;\n }\n break;\n case 2: /* dynamic block */\n //Tracev((stderr, \"inflate: dynamic codes block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = TABLE;\n break;\n case 3:\n strm.msg = 'invalid block type';\n state.mode = BAD;\n }\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n break;\n case STORED:\n //--- BYTEBITS() ---// /* go to byte boundary */\n hold >>>= bits & 7;\n bits -= bits & 7;\n //---//\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if ((hold & 0xffff) !== ((hold >>> 16) ^ 0xffff)) {\n strm.msg = 'invalid stored block lengths';\n state.mode = BAD;\n break;\n }\n state.length = hold & 0xffff;\n //Tracev((stderr, \"inflate: stored length %u\\n\",\n // state.length));\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = COPY_;\n if (flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case COPY_:\n state.mode = COPY;\n /* falls through */\n case COPY:\n copy = state.length;\n if (copy) {\n if (copy > have) { copy = have; }\n if (copy > left) { copy = left; }\n if (copy === 0) { break inf_leave; }\n //--- zmemcpy(put, next, copy); ---\n utils.arraySet(output, input, next, copy, put);\n //---//\n have -= copy;\n next += copy;\n left -= copy;\n put += copy;\n state.length -= copy;\n break;\n }\n //Tracev((stderr, \"inflate: stored end\\n\"));\n state.mode = TYPE;\n break;\n case TABLE:\n //=== NEEDBITS(14); */\n while (bits < 14) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.nlen = (hold & 0x1f)/*BITS(5)*/ + 257;\n //--- DROPBITS(5) ---//\n hold >>>= 5;\n bits -= 5;\n //---//\n state.ndist = (hold & 0x1f)/*BITS(5)*/ + 1;\n //--- DROPBITS(5) ---//\n hold >>>= 5;\n bits -= 5;\n //---//\n state.ncode = (hold & 0x0f)/*BITS(4)*/ + 4;\n //--- DROPBITS(4) ---//\n hold >>>= 4;\n bits -= 4;\n //---//\n//#ifndef PKZIP_BUG_WORKAROUND\n if (state.nlen > 286 || state.ndist > 30) {\n strm.msg = 'too many length or distance symbols';\n state.mode = BAD;\n break;\n }\n//#endif\n //Tracev((stderr, \"inflate: table sizes ok\\n\"));\n state.have = 0;\n state.mode = LENLENS;\n /* falls through */\n case LENLENS:\n while (state.have < state.ncode) {\n //=== NEEDBITS(3);\n while (bits < 3) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.lens[order[state.have++]] = (hold & 0x07);//BITS(3);\n //--- DROPBITS(3) ---//\n hold >>>= 3;\n bits -= 3;\n //---//\n }\n while (state.have < 19) {\n state.lens[order[state.have++]] = 0;\n }\n // We have separate tables & no pointers. 2 commented lines below not needed.\n //state.next = state.codes;\n //state.lencode = state.next;\n // Switch to use dynamic table\n state.lencode = state.lendyn;\n state.lenbits = 7;\n\n opts = { bits: state.lenbits };\n ret = inflate_table(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts);\n state.lenbits = opts.bits;\n\n if (ret) {\n strm.msg = 'invalid code lengths set';\n state.mode = BAD;\n break;\n }\n //Tracev((stderr, \"inflate: code lengths ok\\n\"));\n state.have = 0;\n state.mode = CODELENS;\n /* falls through */\n case CODELENS:\n while (state.have < state.nlen + state.ndist) {\n for (;;) {\n here = state.lencode[hold & ((1 << state.lenbits) - 1)];/*BITS(state.lenbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if (here_val < 16) {\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.lens[state.have++] = here_val;\n }\n else {\n if (here_val === 16) {\n //=== NEEDBITS(here.bits + 2);\n n = here_bits + 2;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n if (state.have === 0) {\n strm.msg = 'invalid bit length repeat';\n state.mode = BAD;\n break;\n }\n len = state.lens[state.have - 1];\n copy = 3 + (hold & 0x03);//BITS(2);\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n }\n else if (here_val === 17) {\n //=== NEEDBITS(here.bits + 3);\n n = here_bits + 3;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n len = 0;\n copy = 3 + (hold & 0x07);//BITS(3);\n //--- DROPBITS(3) ---//\n hold >>>= 3;\n bits -= 3;\n //---//\n }\n else {\n //=== NEEDBITS(here.bits + 7);\n n = here_bits + 7;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n len = 0;\n copy = 11 + (hold & 0x7f);//BITS(7);\n //--- DROPBITS(7) ---//\n hold >>>= 7;\n bits -= 7;\n //---//\n }\n if (state.have + copy > state.nlen + state.ndist) {\n strm.msg = 'invalid bit length repeat';\n state.mode = BAD;\n break;\n }\n while (copy--) {\n state.lens[state.have++] = len;\n }\n }\n }\n\n /* handle error breaks in while */\n if (state.mode === BAD) { break; }\n\n /* check for end-of-block code (better have one) */\n if (state.lens[256] === 0) {\n strm.msg = 'invalid code -- missing end-of-block';\n state.mode = BAD;\n break;\n }\n\n /* build code tables -- note: do not change the lenbits or distbits\n values here (9 and 6) without reading the comments in inftrees.h\n concerning the ENOUGH constants, which depend on those values */\n state.lenbits = 9;\n\n opts = { bits: state.lenbits };\n ret = inflate_table(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts);\n // We have separate tables & no pointers. 2 commented lines below not needed.\n // state.next_index = opts.table_index;\n state.lenbits = opts.bits;\n // state.lencode = state.next;\n\n if (ret) {\n strm.msg = 'invalid literal/lengths set';\n state.mode = BAD;\n break;\n }\n\n state.distbits = 6;\n //state.distcode.copy(state.codes);\n // Switch to use dynamic table\n state.distcode = state.distdyn;\n opts = { bits: state.distbits };\n ret = inflate_table(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts);\n // We have separate tables & no pointers. 2 commented lines below not needed.\n // state.next_index = opts.table_index;\n state.distbits = opts.bits;\n // state.distcode = state.next;\n\n if (ret) {\n strm.msg = 'invalid distances set';\n state.mode = BAD;\n break;\n }\n //Tracev((stderr, 'inflate: codes ok\\n'));\n state.mode = LEN_;\n if (flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case LEN_:\n state.mode = LEN;\n /* falls through */\n case LEN:\n if (have >= 6 && left >= 258) {\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n inflate_fast(strm, _out);\n //--- LOAD() ---\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n //---\n\n if (state.mode === TYPE) {\n state.back = -1;\n }\n break;\n }\n state.back = 0;\n for (;;) {\n here = state.lencode[hold & ((1 << state.lenbits) - 1)]; /*BITS(state.lenbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if (here_bits <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if (here_op && (here_op & 0xf0) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (;;) {\n here = state.lencode[last_val +\n ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((last_bits + here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n //--- DROPBITS(last.bits) ---//\n hold >>>= last_bits;\n bits -= last_bits;\n //---//\n state.back += last_bits;\n }\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.back += here_bits;\n state.length = here_val;\n if (here_op === 0) {\n //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n // \"inflate: literal '%c'\\n\" :\n // \"inflate: literal 0x%02x\\n\", here.val));\n state.mode = LIT;\n break;\n }\n if (here_op & 32) {\n //Tracevv((stderr, \"inflate: end of block\\n\"));\n state.back = -1;\n state.mode = TYPE;\n break;\n }\n if (here_op & 64) {\n strm.msg = 'invalid literal/length code';\n state.mode = BAD;\n break;\n }\n state.extra = here_op & 15;\n state.mode = LENEXT;\n /* falls through */\n case LENEXT:\n if (state.extra) {\n //=== NEEDBITS(state.extra);\n n = state.extra;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.length += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;\n //--- DROPBITS(state.extra) ---//\n hold >>>= state.extra;\n bits -= state.extra;\n //---//\n state.back += state.extra;\n }\n //Tracevv((stderr, \"inflate: length %u\\n\", state.length));\n state.was = state.length;\n state.mode = DIST;\n /* falls through */\n case DIST:\n for (;;) {\n here = state.distcode[hold & ((1 << state.distbits) - 1)];/*BITS(state.distbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if ((here_op & 0xf0) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (;;) {\n here = state.distcode[last_val +\n ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((last_bits + here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n //--- DROPBITS(last.bits) ---//\n hold >>>= last_bits;\n bits -= last_bits;\n //---//\n state.back += last_bits;\n }\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.back += here_bits;\n if (here_op & 64) {\n strm.msg = 'invalid distance code';\n state.mode = BAD;\n break;\n }\n state.offset = here_val;\n state.extra = (here_op) & 15;\n state.mode = DISTEXT;\n /* falls through */\n case DISTEXT:\n if (state.extra) {\n //=== NEEDBITS(state.extra);\n n = state.extra;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.offset += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;\n //--- DROPBITS(state.extra) ---//\n hold >>>= state.extra;\n bits -= state.extra;\n //---//\n state.back += state.extra;\n }\n//#ifdef INFLATE_STRICT\n if (state.offset > state.dmax) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break;\n }\n//#endif\n //Tracevv((stderr, \"inflate: distance %u\\n\", state.offset));\n state.mode = MATCH;\n /* falls through */\n case MATCH:\n if (left === 0) { break inf_leave; }\n copy = _out - left;\n if (state.offset > copy) { /* copy from window */\n copy = state.offset - copy;\n if (copy > state.whave) {\n if (state.sane) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break;\n }\n// (!) This block is disabled in zlib defaults,\n// don't enable it for binary compatibility\n//#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n// Trace((stderr, \"inflate.c too far\\n\"));\n// copy -= state.whave;\n// if (copy > state.length) { copy = state.length; }\n// if (copy > left) { copy = left; }\n// left -= copy;\n// state.length -= copy;\n// do {\n// output[put++] = 0;\n// } while (--copy);\n// if (state.length === 0) { state.mode = LEN; }\n// break;\n//#endif\n }\n if (copy > state.wnext) {\n copy -= state.wnext;\n from = state.wsize - copy;\n }\n else {\n from = state.wnext - copy;\n }\n if (copy > state.length) { copy = state.length; }\n from_source = state.window;\n }\n else { /* copy from output */\n from_source = output;\n from = put - state.offset;\n copy = state.length;\n }\n if (copy > left) { copy = left; }\n left -= copy;\n state.length -= copy;\n do {\n output[put++] = from_source[from++];\n } while (--copy);\n if (state.length === 0) { state.mode = LEN; }\n break;\n case LIT:\n if (left === 0) { break inf_leave; }\n output[put++] = state.length;\n left--;\n state.mode = LEN;\n break;\n case CHECK:\n if (state.wrap) {\n //=== NEEDBITS(32);\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n // Use '|' instead of '+' to make sure that result is signed\n hold |= input[next++] << bits;\n bits += 8;\n }\n //===//\n _out -= left;\n strm.total_out += _out;\n state.total += _out;\n if (_out) {\n strm.adler = state.check =\n /*UPDATE(state.check, put - _out, _out);*/\n (state.flags ? crc32(state.check, output, _out, put - _out) : adler32(state.check, output, _out, put - _out));\n\n }\n _out = left;\n // NB: crc32 stored as signed 32-bit int, zswap32 returns signed too\n if ((state.flags ? hold : zswap32(hold)) !== state.check) {\n strm.msg = 'incorrect data check';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n //Tracev((stderr, \"inflate: check matches trailer\\n\"));\n }\n state.mode = LENGTH;\n /* falls through */\n case LENGTH:\n if (state.wrap && state.flags) {\n //=== NEEDBITS(32);\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (hold !== (state.total & 0xffffffff)) {\n strm.msg = 'incorrect length check';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n //Tracev((stderr, \"inflate: length matches trailer\\n\"));\n }\n state.mode = DONE;\n /* falls through */\n case DONE:\n ret = Z_STREAM_END;\n break inf_leave;\n case BAD:\n ret = Z_DATA_ERROR;\n break inf_leave;\n case MEM:\n return Z_MEM_ERROR;\n case SYNC:\n /* falls through */\n default:\n return Z_STREAM_ERROR;\n }\n }\n\n // inf_leave <- here is real place for \"goto inf_leave\", emulated via \"break inf_leave\"\n\n /*\n Return from inflate(), updating the total counts and the check value.\n If there was no progress during the inflate() call, return a buffer\n error. Call updatewindow() to create and/or update the window state.\n Note: a memory error from inflate() is non-recoverable.\n */\n\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n\n if (state.wsize || (_out !== strm.avail_out && state.mode < BAD &&\n (state.mode < CHECK || flush !== Z_FINISH))) {\n if (updatewindow(strm, strm.output, strm.next_out, _out - strm.avail_out)) {\n state.mode = MEM;\n return Z_MEM_ERROR;\n }\n }\n _in -= strm.avail_in;\n _out -= strm.avail_out;\n strm.total_in += _in;\n strm.total_out += _out;\n state.total += _out;\n if (state.wrap && _out) {\n strm.adler = state.check = /*UPDATE(state.check, strm.next_out - _out, _out);*/\n (state.flags ? crc32(state.check, output, _out, strm.next_out - _out) : adler32(state.check, output, _out, strm.next_out - _out));\n }\n strm.data_type = state.bits + (state.last ? 64 : 0) +\n (state.mode === TYPE ? 128 : 0) +\n (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0);\n if (((_in === 0 && _out === 0) || flush === Z_FINISH) && ret === Z_OK) {\n ret = Z_BUF_ERROR;\n }\n return ret;\n}\n\nfunction inflateEnd(strm) {\n\n if (!strm || !strm.state /*|| strm->zfree == (free_func)0*/) {\n return Z_STREAM_ERROR;\n }\n\n var state = strm.state;\n if (state.window) {\n state.window = null;\n }\n strm.state = null;\n return Z_OK;\n}\n\nfunction inflateGetHeader(strm, head) {\n var state;\n\n /* check state */\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n if ((state.wrap & 2) === 0) { return Z_STREAM_ERROR; }\n\n /* save header structure */\n state.head = head;\n head.done = false;\n return Z_OK;\n}\n\nfunction inflateSetDictionary(strm, dictionary) {\n var dictLength = dictionary.length;\n\n var state;\n var dictid;\n var ret;\n\n /* check state */\n if (!strm /* == Z_NULL */ || !strm.state /* == Z_NULL */) { return Z_STREAM_ERROR; }\n state = strm.state;\n\n if (state.wrap !== 0 && state.mode !== DICT) {\n return Z_STREAM_ERROR;\n }\n\n /* check for correct dictionary identifier */\n if (state.mode === DICT) {\n dictid = 1; /* adler32(0, null, 0)*/\n /* dictid = adler32(dictid, dictionary, dictLength); */\n dictid = adler32(dictid, dictionary, dictLength, 0);\n if (dictid !== state.check) {\n return Z_DATA_ERROR;\n }\n }\n /* copy dictionary to window using updatewindow(), which will amend the\n existing dictionary if appropriate */\n ret = updatewindow(strm, dictionary, dictLength, dictLength);\n if (ret) {\n state.mode = MEM;\n return Z_MEM_ERROR;\n }\n state.havedict = 1;\n // Tracev((stderr, \"inflate: dictionary set\\n\"));\n return Z_OK;\n}\n\nexports.inflateReset = inflateReset;\nexports.inflateReset2 = inflateReset2;\nexports.inflateResetKeep = inflateResetKeep;\nexports.inflateInit = inflateInit;\nexports.inflateInit2 = inflateInit2;\nexports.inflate = inflate;\nexports.inflateEnd = inflateEnd;\nexports.inflateGetHeader = inflateGetHeader;\nexports.inflateSetDictionary = inflateSetDictionary;\nexports.inflateInfo = 'pako inflate (from Nodeca project)';\n\n/* Not implemented\nexports.inflateCopy = inflateCopy;\nexports.inflateGetDictionary = inflateGetDictionary;\nexports.inflateMark = inflateMark;\nexports.inflatePrime = inflatePrime;\nexports.inflateSync = inflateSync;\nexports.inflateSyncPoint = inflateSyncPoint;\nexports.inflateUndermine = inflateUndermine;\n*/\n","'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nmodule.exports = {\n\n /* Allowed flush values; see deflate() and inflate() below for details */\n Z_NO_FLUSH: 0,\n Z_PARTIAL_FLUSH: 1,\n Z_SYNC_FLUSH: 2,\n Z_FULL_FLUSH: 3,\n Z_FINISH: 4,\n Z_BLOCK: 5,\n Z_TREES: 6,\n\n /* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\n Z_OK: 0,\n Z_STREAM_END: 1,\n Z_NEED_DICT: 2,\n Z_ERRNO: -1,\n Z_STREAM_ERROR: -2,\n Z_DATA_ERROR: -3,\n //Z_MEM_ERROR: -4,\n Z_BUF_ERROR: -5,\n //Z_VERSION_ERROR: -6,\n\n /* compression levels */\n Z_NO_COMPRESSION: 0,\n Z_BEST_SPEED: 1,\n Z_BEST_COMPRESSION: 9,\n Z_DEFAULT_COMPRESSION: -1,\n\n\n Z_FILTERED: 1,\n Z_HUFFMAN_ONLY: 2,\n Z_RLE: 3,\n Z_FIXED: 4,\n Z_DEFAULT_STRATEGY: 0,\n\n /* Possible values of the data_type field (though see inflate()) */\n Z_BINARY: 0,\n Z_TEXT: 1,\n //Z_ASCII: 1, // = Z_TEXT (deprecated)\n Z_UNKNOWN: 2,\n\n /* The deflate compression method */\n Z_DEFLATED: 8\n //Z_NULL: null // Use -1 or null inline, depending on var type\n};\n","'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n// claim that you wrote the original software. If you use this software\n// in a product, an acknowledgment in the product documentation would be\n// appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n// misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nfunction GZheader() {\n /* true if compressed data believed to be text */\n this.text = 0;\n /* modification time */\n this.time = 0;\n /* extra flags (not used when writing a gzip file) */\n this.xflags = 0;\n /* operating system */\n this.os = 0;\n /* pointer to extra field or Z_NULL if none */\n this.extra = null;\n /* extra field length (valid if extra != Z_NULL) */\n this.extra_len = 0; // Actually, we don't need it in JS,\n // but leave for few code modifications\n\n //\n // Setup limits is not necessary because in js we should not preallocate memory\n // for inflate use constant limit in 65536 bytes\n //\n\n /* space at extra (only when reading header) */\n // this.extra_max = 0;\n /* pointer to zero-terminated file name or Z_NULL */\n this.name = '';\n /* space at name (only when reading header) */\n // this.name_max = 0;\n /* pointer to zero-terminated comment or Z_NULL */\n this.comment = '';\n /* space at comment (only when reading header) */\n // this.comm_max = 0;\n /* true if there was or will be a header crc */\n this.hcrc = 0;\n /* true when done reading gzip header (not used when writing a gzip file) */\n this.done = false;\n}\n\nmodule.exports = GZheader;\n","'use strict';\n\n\nvar zlib_inflate = require('./zlib/inflate');\nvar utils = require('./utils/common');\nvar strings = require('./utils/strings');\nvar c = require('./zlib/constants');\nvar msg = require('./zlib/messages');\nvar ZStream = require('./zlib/zstream');\nvar GZheader = require('./zlib/gzheader');\n\nvar toString = Object.prototype.toString;\n\n/**\n * class Inflate\n *\n * Generic JS-style wrapper for zlib calls. If you don't need\n * streaming behaviour - use more simple functions: [[inflate]]\n * and [[inflateRaw]].\n **/\n\n/* internal\n * inflate.chunks -> Array\n *\n * Chunks of output data, if [[Inflate#onData]] not overridden.\n **/\n\n/**\n * Inflate.result -> Uint8Array|Array|String\n *\n * Uncompressed result, generated by default [[Inflate#onData]]\n * and [[Inflate#onEnd]] handlers. Filled after you push last chunk\n * (call [[Inflate#push]] with `Z_FINISH` / `true` param) or if you\n * push a chunk with explicit flush (call [[Inflate#push]] with\n * `Z_SYNC_FLUSH` param).\n **/\n\n/**\n * Inflate.err -> Number\n *\n * Error code after inflate finished. 0 (Z_OK) on success.\n * Should be checked if broken data possible.\n **/\n\n/**\n * Inflate.msg -> String\n *\n * Error message, if [[Inflate.err]] != 0\n **/\n\n\n/**\n * new Inflate(options)\n * - options (Object): zlib inflate options.\n *\n * Creates new inflator instance with specified params. Throws exception\n * on bad params. Supported options:\n *\n * - `windowBits`\n * - `dictionary`\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information on these.\n *\n * Additional options, for internal needs:\n *\n * - `chunkSize` - size of generated data chunks (16K by default)\n * - `raw` (Boolean) - do raw inflate\n * - `to` (String) - if equal to 'string', then result will be converted\n * from utf8 to utf16 (javascript) string. When string output requested,\n * chunk length can differ from `chunkSize`, depending on content.\n *\n * By default, when no options set, autodetect deflate/gzip data format via\n * wrapper header.\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n * , chunk1 = Uint8Array([1,2,3,4,5,6,7,8,9])\n * , chunk2 = Uint8Array([10,11,12,13,14,15,16,17,18,19]);\n *\n * var inflate = new pako.Inflate({ level: 3});\n *\n * inflate.push(chunk1, false);\n * inflate.push(chunk2, true); // true -> last chunk\n *\n * if (inflate.err) { throw new Error(inflate.err); }\n *\n * console.log(inflate.result);\n * ```\n **/\nfunction Inflate(options) {\n if (!(this instanceof Inflate)) return new Inflate(options);\n\n this.options = utils.assign({\n chunkSize: 16384,\n windowBits: 0,\n to: ''\n }, options || {});\n\n var opt = this.options;\n\n // Force window size for `raw` data, if not set directly,\n // because we have no header for autodetect.\n if (opt.raw && (opt.windowBits >= 0) && (opt.windowBits < 16)) {\n opt.windowBits = -opt.windowBits;\n if (opt.windowBits === 0) { opt.windowBits = -15; }\n }\n\n // If `windowBits` not defined (and mode not raw) - set autodetect flag for gzip/deflate\n if ((opt.windowBits >= 0) && (opt.windowBits < 16) &&\n !(options && options.windowBits)) {\n opt.windowBits += 32;\n }\n\n // Gzip header has no info about windows size, we can do autodetect only\n // for deflate. So, if window size not set, force it to max when gzip possible\n if ((opt.windowBits > 15) && (opt.windowBits < 48)) {\n // bit 3 (16) -> gzipped data\n // bit 4 (32) -> autodetect gzip/deflate\n if ((opt.windowBits & 15) === 0) {\n opt.windowBits |= 15;\n }\n }\n\n this.err = 0; // error code, if happens (0 = Z_OK)\n this.msg = ''; // error message\n this.ended = false; // used to avoid multiple onEnd() calls\n this.chunks = []; // chunks of compressed data\n\n this.strm = new ZStream();\n this.strm.avail_out = 0;\n\n var status = zlib_inflate.inflateInit2(\n this.strm,\n opt.windowBits\n );\n\n if (status !== c.Z_OK) {\n throw new Error(msg[status]);\n }\n\n this.header = new GZheader();\n\n zlib_inflate.inflateGetHeader(this.strm, this.header);\n\n // Setup dictionary\n if (opt.dictionary) {\n // Convert data if needed\n if (typeof opt.dictionary === 'string') {\n opt.dictionary = strings.string2buf(opt.dictionary);\n } else if (toString.call(opt.dictionary) === '[object ArrayBuffer]') {\n opt.dictionary = new Uint8Array(opt.dictionary);\n }\n if (opt.raw) { //In raw mode we need to set the dictionary early\n status = zlib_inflate.inflateSetDictionary(this.strm, opt.dictionary);\n if (status !== c.Z_OK) {\n throw new Error(msg[status]);\n }\n }\n }\n}\n\n/**\n * Inflate#push(data[, mode]) -> Boolean\n * - data (Uint8Array|Array|ArrayBuffer|String): input data\n * - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes.\n * See constants. Skipped or `false` means Z_NO_FLUSH, `true` means Z_FINISH.\n *\n * Sends input data to inflate pipe, generating [[Inflate#onData]] calls with\n * new output chunks. Returns `true` on success. The last data block must have\n * mode Z_FINISH (or `true`). That will flush internal pending buffers and call\n * [[Inflate#onEnd]]. For interim explicit flushes (without ending the stream) you\n * can use mode Z_SYNC_FLUSH, keeping the decompression context.\n *\n * On fail call [[Inflate#onEnd]] with error code and return false.\n *\n * We strongly recommend to use `Uint8Array` on input for best speed (output\n * format is detected automatically). Also, don't skip last param and always\n * use the same type in your code (boolean or number). That will improve JS speed.\n *\n * For regular `Array`-s make sure all elements are [0..255].\n *\n * ##### Example\n *\n * ```javascript\n * push(chunk, false); // push one of data chunks\n * ...\n * push(chunk, true); // push last chunk\n * ```\n **/\nInflate.prototype.push = function (data, mode) {\n var strm = this.strm;\n var chunkSize = this.options.chunkSize;\n var dictionary = this.options.dictionary;\n var status, _mode;\n var next_out_utf8, tail, utf8str;\n\n // Flag to properly process Z_BUF_ERROR on testing inflate call\n // when we check that all output data was flushed.\n var allowBufError = false;\n\n if (this.ended) { return false; }\n _mode = (mode === ~~mode) ? mode : ((mode === true) ? c.Z_FINISH : c.Z_NO_FLUSH);\n\n // Convert data if needed\n if (typeof data === 'string') {\n // Only binary strings can be decompressed on practice\n strm.input = strings.binstring2buf(data);\n } else if (toString.call(data) === '[object ArrayBuffer]') {\n strm.input = new Uint8Array(data);\n } else {\n strm.input = data;\n }\n\n strm.next_in = 0;\n strm.avail_in = strm.input.length;\n\n do {\n if (strm.avail_out === 0) {\n strm.output = new utils.Buf8(chunkSize);\n strm.next_out = 0;\n strm.avail_out = chunkSize;\n }\n\n status = zlib_inflate.inflate(strm, c.Z_NO_FLUSH); /* no bad return value */\n\n if (status === c.Z_NEED_DICT && dictionary) {\n status = zlib_inflate.inflateSetDictionary(this.strm, dictionary);\n }\n\n if (status === c.Z_BUF_ERROR && allowBufError === true) {\n status = c.Z_OK;\n allowBufError = false;\n }\n\n if (status !== c.Z_STREAM_END && status !== c.Z_OK) {\n this.onEnd(status);\n this.ended = true;\n return false;\n }\n\n if (strm.next_out) {\n if (strm.avail_out === 0 || status === c.Z_STREAM_END || (strm.avail_in === 0 && (_mode === c.Z_FINISH || _mode === c.Z_SYNC_FLUSH))) {\n\n if (this.options.to === 'string') {\n\n next_out_utf8 = strings.utf8border(strm.output, strm.next_out);\n\n tail = strm.next_out - next_out_utf8;\n utf8str = strings.buf2string(strm.output, next_out_utf8);\n\n // move tail\n strm.next_out = tail;\n strm.avail_out = chunkSize - tail;\n if (tail) { utils.arraySet(strm.output, strm.output, next_out_utf8, tail, 0); }\n\n this.onData(utf8str);\n\n } else {\n this.onData(utils.shrinkBuf(strm.output, strm.next_out));\n }\n }\n }\n\n // When no more input data, we should check that internal inflate buffers\n // are flushed. The only way to do it when avail_out = 0 - run one more\n // inflate pass. But if output data not exists, inflate return Z_BUF_ERROR.\n // Here we set flag to process this error properly.\n //\n // NOTE. Deflate does not return error in this case and does not needs such\n // logic.\n if (strm.avail_in === 0 && strm.avail_out === 0) {\n allowBufError = true;\n }\n\n } while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== c.Z_STREAM_END);\n\n if (status === c.Z_STREAM_END) {\n _mode = c.Z_FINISH;\n }\n\n // Finalize on the last chunk.\n if (_mode === c.Z_FINISH) {\n status = zlib_inflate.inflateEnd(this.strm);\n this.onEnd(status);\n this.ended = true;\n return status === c.Z_OK;\n }\n\n // callback interim results if Z_SYNC_FLUSH.\n if (_mode === c.Z_SYNC_FLUSH) {\n this.onEnd(c.Z_OK);\n strm.avail_out = 0;\n return true;\n }\n\n return true;\n};\n\n\n/**\n * Inflate#onData(chunk) -> Void\n * - chunk (Uint8Array|Array|String): output data. Type of array depends\n * on js engine support. When string output requested, each chunk\n * will be string.\n *\n * By default, stores data blocks in `chunks[]` property and glue\n * those in `onEnd`. Override this handler, if you need another behaviour.\n **/\nInflate.prototype.onData = function (chunk) {\n this.chunks.push(chunk);\n};\n\n\n/**\n * Inflate#onEnd(status) -> Void\n * - status (Number): inflate status. 0 (Z_OK) on success,\n * other if not.\n *\n * Called either after you tell inflate that the input stream is\n * complete (Z_FINISH) or should be flushed (Z_SYNC_FLUSH)\n * or if an error happened. By default - join collected chunks,\n * free memory and fill `results` / `err` properties.\n **/\nInflate.prototype.onEnd = function (status) {\n // On success - join\n if (status === c.Z_OK) {\n if (this.options.to === 'string') {\n // Glue & convert here, until we teach pako to send\n // utf8 aligned strings to onData\n this.result = this.chunks.join('');\n } else {\n this.result = utils.flattenChunks(this.chunks);\n }\n }\n this.chunks = [];\n this.err = status;\n this.msg = this.strm.msg;\n};\n\n\n/**\n * inflate(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * Decompress `data` with inflate/ungzip and `options`. Autodetect\n * format via wrapper header by default. That's why we don't provide\n * separate `ungzip` method.\n *\n * Supported options are:\n *\n * - windowBits\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information.\n *\n * Sugar (options):\n *\n * - `raw` (Boolean) - say that we work with raw stream, if you don't wish to specify\n * negative windowBits implicitly.\n * - `to` (String) - if equal to 'string', then result will be converted\n * from utf8 to utf16 (javascript) string. When string output requested,\n * chunk length can differ from `chunkSize`, depending on content.\n *\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n * , input = pako.deflate([1,2,3,4,5,6,7,8,9])\n * , output;\n *\n * try {\n * output = pako.inflate(input);\n * } catch (err)\n * console.log(err);\n * }\n * ```\n **/\nfunction inflate(input, options) {\n var inflator = new Inflate(options);\n\n inflator.push(input, true);\n\n // That will never happens, if you don't cheat with options :)\n if (inflator.err) { throw inflator.msg || msg[inflator.err]; }\n\n return inflator.result;\n}\n\n\n/**\n * inflateRaw(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * The same as [[inflate]], but creates raw data, without wrapper\n * (header and adler32 crc).\n **/\nfunction inflateRaw(input, options) {\n options = options || {};\n options.raw = true;\n return inflate(input, options);\n}\n\n\n/**\n * ungzip(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * Just shortcut to [[inflate]], because it autodetects format\n * by header.content. Done for convenience.\n **/\n\n\nexports.Inflate = Inflate;\nexports.inflate = inflate;\nexports.inflateRaw = inflateRaw;\nexports.ungzip = inflate;\n","// Top level file is just a mixin of submodules & constants\n'use strict';\n\nvar assign = require('./lib/utils/common').assign;\n\nvar deflate = require('./lib/deflate');\nvar inflate = require('./lib/inflate');\nvar constants = require('./lib/zlib/constants');\n\nvar pako = {};\n\nassign(pako, deflate, inflate, constants);\n\nmodule.exports = pako;\n","'use strict';\n\nconst processFn = (fn, options) => function (...args) {\n\tconst P = options.promiseModule;\n\n\treturn new P((resolve, reject) => {\n\t\tif (options.multiArgs) {\n\t\t\targs.push((...result) => {\n\t\t\t\tif (options.errorFirst) {\n\t\t\t\t\tif (result[0]) {\n\t\t\t\t\t\treject(result);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tresult.shift();\n\t\t\t\t\t\tresolve(result);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tresolve(result);\n\t\t\t\t}\n\t\t\t});\n\t\t} else if (options.errorFirst) {\n\t\t\targs.push((error, result) => {\n\t\t\t\tif (error) {\n\t\t\t\t\treject(error);\n\t\t\t\t} else {\n\t\t\t\t\tresolve(result);\n\t\t\t\t}\n\t\t\t});\n\t\t} else {\n\t\t\targs.push(resolve);\n\t\t}\n\n\t\tfn.apply(this, args);\n\t});\n};\n\nmodule.exports = (input, options) => {\n\toptions = Object.assign({\n\t\texclude: [/.+(Sync|Stream)$/],\n\t\terrorFirst: true,\n\t\tpromiseModule: Promise\n\t}, options);\n\n\tconst objType = typeof input;\n\tif (!(input !== null && (objType === 'object' || objType === 'function'))) {\n\t\tthrow new TypeError(`Expected \\`input\\` to be a \\`Function\\` or \\`Object\\`, got \\`${input === null ? 'null' : objType}\\``);\n\t}\n\n\tconst filter = key => {\n\t\tconst match = pattern => typeof pattern === 'string' ? key === pattern : pattern.test(key);\n\t\treturn options.include ? options.include.some(match) : !options.exclude.some(match);\n\t};\n\n\tlet ret;\n\tif (objType === 'function') {\n\t\tret = function (...args) {\n\t\t\treturn options.excludeMain ? input(...args) : processFn(input, options).apply(this, args);\n\t\t};\n\t} else {\n\t\tret = Object.create(Object.getPrototypeOf(input));\n\t}\n\n\tfor (const key in input) { // eslint-disable-line guard-for-in\n\t\tconst property = input[key];\n\t\tret[key] = typeof property === 'function' && filter(key) ? processFn(property, options) : property;\n\t}\n\n\treturn ret;\n};\n","// A simple implementation of make-array\nfunction makeArray (subject) {\n return Array.isArray(subject)\n ? subject\n : [subject]\n}\n\nconst EMPTY = ''\nconst SPACE = ' '\nconst ESCAPE = '\\\\'\nconst REGEX_TEST_BLANK_LINE = /^\\s+$/\nconst REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\\\!/\nconst REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\\\#/\nconst REGEX_SPLITALL_CRLF = /\\r?\\n/g\n// /foo,\n// ./foo,\n// ../foo,\n// .\n// ..\nconst REGEX_TEST_INVALID_PATH = /^\\.*\\/|^\\.+$/\n\nconst SLASH = '/'\nconst KEY_IGNORE = typeof Symbol !== 'undefined'\n ? Symbol.for('node-ignore')\n /* istanbul ignore next */\n : 'node-ignore'\n\nconst define = (object, key, value) =>\n Object.defineProperty(object, key, {value})\n\nconst REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g\n\n// Sanitize the range of a regular expression\n// The cases are complicated, see test cases for details\nconst sanitizeRange = range => range.replace(\n REGEX_REGEXP_RANGE,\n (match, from, to) => from.charCodeAt(0) <= to.charCodeAt(0)\n ? match\n // Invalid range (out of order) which is ok for gitignore rules but\n // fatal for JavaScript regular expression, so eliminate it.\n : EMPTY\n)\n\n// See fixtures #59\nconst cleanRangeBackSlash = slashes => {\n const {length} = slashes\n return slashes.slice(0, length - length % 2)\n}\n\n// > If the pattern ends with a slash,\n// > it is removed for the purpose of the following description,\n// > but it would only find a match with a directory.\n// > In other words, foo/ will match a directory foo and paths underneath it,\n// > but will not match a regular file or a symbolic link foo\n// > (this is consistent with the way how pathspec works in general in Git).\n// '`foo/`' will not match regular file '`foo`' or symbolic link '`foo`'\n// -> ignore-rules will not deal with it, because it costs extra `fs.stat` call\n// you could use option `mark: true` with `glob`\n\n// '`foo/`' should not continue with the '`..`'\nconst REPLACERS = [\n\n // > Trailing spaces are ignored unless they are quoted with backslash (\"\\\")\n [\n // (a\\ ) -> (a )\n // (a ) -> (a)\n // (a \\ ) -> (a )\n /\\\\?\\s+$/,\n match => match.indexOf('\\\\') === 0\n ? SPACE\n : EMPTY\n ],\n\n // replace (\\ ) with ' '\n [\n /\\\\\\s/g,\n () => SPACE\n ],\n\n // Escape metacharacters\n // which is written down by users but means special for regular expressions.\n\n // > There are 12 characters with special meanings:\n // > - the backslash \\,\n // > - the caret ^,\n // > - the dollar sign $,\n // > - the period or dot .,\n // > - the vertical bar or pipe symbol |,\n // > - the question mark ?,\n // > - the asterisk or star *,\n // > - the plus sign +,\n // > - the opening parenthesis (,\n // > - the closing parenthesis ),\n // > - and the opening square bracket [,\n // > - the opening curly brace {,\n // > These special characters are often called \"metacharacters\".\n [\n /[\\\\$.|*+(){^]/g,\n match => `\\\\${match}`\n ],\n\n [\n // > a question mark (?) matches a single character\n /(?!\\\\)\\?/g,\n () => '[^/]'\n ],\n\n // leading slash\n [\n\n // > A leading slash matches the beginning of the pathname.\n // > For example, \"/*.c\" matches \"cat-file.c\" but not \"mozilla-sha1/sha1.c\".\n // A leading slash matches the beginning of the pathname\n /^\\//,\n () => '^'\n ],\n\n // replace special metacharacter slash after the leading slash\n [\n /\\//g,\n () => '\\\\/'\n ],\n\n [\n // > A leading \"**\" followed by a slash means match in all directories.\n // > For example, \"**/foo\" matches file or directory \"foo\" anywhere,\n // > the same as pattern \"foo\".\n // > \"**/foo/bar\" matches file or directory \"bar\" anywhere that is directly\n // > under directory \"foo\".\n // Notice that the '*'s have been replaced as '\\\\*'\n /^\\^*\\\\\\*\\\\\\*\\\\\\//,\n\n // '**/foo' <-> 'foo'\n () => '^(?:.*\\\\/)?'\n ],\n\n // starting\n [\n // there will be no leading '/'\n // (which has been replaced by section \"leading slash\")\n // If starts with '**', adding a '^' to the regular expression also works\n /^(?=[^^])/,\n function startingReplacer () {\n // If has a slash `/` at the beginning or middle\n return !/\\/(?!$)/.test(this)\n // > Prior to 2.22.1\n // > If the pattern does not contain a slash /,\n // > Git treats it as a shell glob pattern\n // Actually, if there is only a trailing slash,\n // git also treats it as a shell glob pattern\n\n // After 2.22.1 (compatible but clearer)\n // > If there is a separator at the beginning or middle (or both)\n // > of the pattern, then the pattern is relative to the directory\n // > level of the particular .gitignore file itself.\n // > Otherwise the pattern may also match at any level below\n // > the .gitignore level.\n ? '(?:^|\\\\/)'\n\n // > Otherwise, Git treats the pattern as a shell glob suitable for\n // > consumption by fnmatch(3)\n : '^'\n }\n ],\n\n // two globstars\n [\n // Use lookahead assertions so that we could match more than one `'/**'`\n /\\\\\\/\\\\\\*\\\\\\*(?=\\\\\\/|$)/g,\n\n // Zero, one or several directories\n // should not use '*', or it will be replaced by the next replacer\n\n // Check if it is not the last `'/**'`\n (_, index, str) => index + 6 < str.length\n\n // case: /**/\n // > A slash followed by two consecutive asterisks then a slash matches\n // > zero or more directories.\n // > For example, \"a/**/b\" matches \"a/b\", \"a/x/b\", \"a/x/y/b\" and so on.\n // '/**/'\n ? '(?:\\\\/[^\\\\/]+)*'\n\n // case: /**\n // > A trailing `\"/**\"` matches everything inside.\n\n // #21: everything inside but it should not include the current folder\n : '\\\\/.+'\n ],\n\n // intermediate wildcards\n [\n // Never replace escaped '*'\n // ignore rule '\\*' will match the path '*'\n\n // 'abc.*/' -> go\n // 'abc.*' -> skip this rule\n /(^|[^\\\\]+)\\\\\\*(?=.+)/g,\n\n // '*.js' matches '.js'\n // '*.js' doesn't match 'abc'\n (_, p1) => `${p1}[^\\\\/]*`\n ],\n\n [\n // unescape, revert step 3 except for back slash\n // For example, if a user escape a '\\\\*',\n // after step 3, the result will be '\\\\\\\\\\\\*'\n /\\\\\\\\\\\\(?=[$.|*+(){^])/g,\n () => ESCAPE\n ],\n\n [\n // '\\\\\\\\' -> '\\\\'\n /\\\\\\\\/g,\n () => ESCAPE\n ],\n\n [\n // > The range notation, e.g. [a-zA-Z],\n // > can be used to match one of the characters in a range.\n\n // `\\` is escaped by step 3\n /(\\\\)?\\[([^\\]/]*?)(\\\\*)($|\\])/g,\n (match, leadEscape, range, endEscape, close) => leadEscape === ESCAPE\n // '\\\\[bar]' -> '\\\\\\\\[bar\\\\]'\n ? `\\\\[${range}${cleanRangeBackSlash(endEscape)}${close}`\n : close === ']'\n ? endEscape.length % 2 === 0\n // A normal case, and it is a range notation\n // '[bar]'\n // '[bar\\\\\\\\]'\n ? `[${sanitizeRange(range)}${endEscape}]`\n // Invalid range notaton\n // '[bar\\\\]' -> '[bar\\\\\\\\]'\n : '[]'\n : '[]'\n ],\n\n // ending\n [\n // 'js' will not match 'js.'\n // 'ab' will not match 'abc'\n /(?:[^*])$/,\n\n // WTF!\n // https://git-scm.com/docs/gitignore\n // changes in [2.22.1](https://git-scm.com/docs/gitignore/2.22.1)\n // which re-fixes #24, #38\n\n // > If there is a separator at the end of the pattern then the pattern\n // > will only match directories, otherwise the pattern can match both\n // > files and directories.\n\n // 'js*' will not match 'a.js'\n // 'js/' will not match 'a.js'\n // 'js' will match 'a.js' and 'a.js/'\n match => /\\/$/.test(match)\n // foo/ will not match 'foo'\n ? `${match}$`\n // foo matches 'foo' and 'foo/'\n : `${match}(?=$|\\\\/$)`\n ],\n\n // trailing wildcard\n [\n /(\\^|\\\\\\/)?\\\\\\*$/,\n (_, p1) => {\n const prefix = p1\n // '\\^':\n // '/*' does not match EMPTY\n // '/*' does not match everything\n\n // '\\\\\\/':\n // 'abc/*' does not match 'abc/'\n ? `${p1}[^/]+`\n\n // 'a*' matches 'a'\n // 'a*' matches 'aa'\n : '[^/]*'\n\n return `${prefix}(?=$|\\\\/$)`\n }\n ],\n]\n\n// A simple cache, because an ignore rule only has only one certain meaning\nconst regexCache = Object.create(null)\n\n// @param {pattern}\nconst makeRegex = (pattern, negative, ignorecase) => {\n const r = regexCache[pattern]\n if (r) {\n return r\n }\n\n // const replacers = negative\n // ? NEGATIVE_REPLACERS\n // : POSITIVE_REPLACERS\n\n const source = REPLACERS.reduce(\n (prev, current) => prev.replace(current[0], current[1].bind(pattern)),\n pattern\n )\n\n return regexCache[pattern] = ignorecase\n ? new RegExp(source, 'i')\n : new RegExp(source)\n}\n\nconst isString = subject => typeof subject === 'string'\n\n// > A blank line matches no files, so it can serve as a separator for readability.\nconst checkPattern = pattern => pattern\n && isString(pattern)\n && !REGEX_TEST_BLANK_LINE.test(pattern)\n\n // > A line starting with # serves as a comment.\n && pattern.indexOf('#') !== 0\n\nconst splitPattern = pattern => pattern.split(REGEX_SPLITALL_CRLF)\n\nclass IgnoreRule {\n constructor (\n origin,\n pattern,\n negative,\n regex\n ) {\n this.origin = origin\n this.pattern = pattern\n this.negative = negative\n this.regex = regex\n }\n}\n\nconst createRule = (pattern, ignorecase) => {\n const origin = pattern\n let negative = false\n\n // > An optional prefix \"!\" which negates the pattern;\n if (pattern.indexOf('!') === 0) {\n negative = true\n pattern = pattern.substr(1)\n }\n\n pattern = pattern\n // > Put a backslash (\"\\\") in front of the first \"!\" for patterns that\n // > begin with a literal \"!\", for example, `\"\\!important!.txt\"`.\n .replace(REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION, '!')\n // > Put a backslash (\"\\\") in front of the first hash for patterns that\n // > begin with a hash.\n .replace(REGEX_REPLACE_LEADING_EXCAPED_HASH, '#')\n\n const regex = makeRegex(pattern, negative, ignorecase)\n\n return new IgnoreRule(\n origin,\n pattern,\n negative,\n regex\n )\n}\n\nconst throwError = (message, Ctor) => {\n throw new Ctor(message)\n}\n\nconst checkPath = (path, originalPath, doThrow) => {\n if (!isString(path)) {\n return doThrow(\n `path must be a string, but got \\`${originalPath}\\``,\n TypeError\n )\n }\n\n // We don't know if we should ignore EMPTY, so throw\n if (!path) {\n return doThrow(`path must not be empty`, TypeError)\n }\n\n // Check if it is a relative path\n if (checkPath.isNotRelative(path)) {\n const r = '`path.relative()`d'\n return doThrow(\n `path should be a ${r} string, but got \"${originalPath}\"`,\n RangeError\n )\n }\n\n return true\n}\n\nconst isNotRelative = path => REGEX_TEST_INVALID_PATH.test(path)\n\ncheckPath.isNotRelative = isNotRelative\ncheckPath.convert = p => p\n\nclass Ignore {\n constructor ({\n ignorecase = true\n } = {}) {\n this._rules = []\n this._ignorecase = ignorecase\n define(this, KEY_IGNORE, true)\n this._initCache()\n }\n\n _initCache () {\n this._ignoreCache = Object.create(null)\n this._testCache = Object.create(null)\n }\n\n _addPattern (pattern) {\n // #32\n if (pattern && pattern[KEY_IGNORE]) {\n this._rules = this._rules.concat(pattern._rules)\n this._added = true\n return\n }\n\n if (checkPattern(pattern)) {\n const rule = createRule(pattern, this._ignorecase)\n this._added = true\n this._rules.push(rule)\n }\n }\n\n // @param {Array<string> | string | Ignore} pattern\n add (pattern) {\n this._added = false\n\n makeArray(\n isString(pattern)\n ? splitPattern(pattern)\n : pattern\n ).forEach(this._addPattern, this)\n\n // Some rules have just added to the ignore,\n // making the behavior changed.\n if (this._added) {\n this._initCache()\n }\n\n return this\n }\n\n // legacy\n addPattern (pattern) {\n return this.add(pattern)\n }\n\n // | ignored : unignored\n // negative | 0:0 | 0:1 | 1:0 | 1:1\n // -------- | ------- | ------- | ------- | --------\n // 0 | TEST | TEST | SKIP | X\n // 1 | TESTIF | SKIP | TEST | X\n\n // - SKIP: always skip\n // - TEST: always test\n // - TESTIF: only test if checkUnignored\n // - X: that never happen\n\n // @param {boolean} whether should check if the path is unignored,\n // setting `checkUnignored` to `false` could reduce additional\n // path matching.\n\n // @returns {TestResult} true if a file is ignored\n _testOne (path, checkUnignored) {\n let ignored = false\n let unignored = false\n\n this._rules.forEach(rule => {\n const {negative} = rule\n if (\n unignored === negative && ignored !== unignored\n || negative && !ignored && !unignored && !checkUnignored\n ) {\n return\n }\n\n const matched = rule.regex.test(path)\n\n if (matched) {\n ignored = !negative\n unignored = negative\n }\n })\n\n return {\n ignored,\n unignored\n }\n }\n\n // @returns {TestResult}\n _test (originalPath, cache, checkUnignored, slices) {\n const path = originalPath\n // Supports nullable path\n && checkPath.convert(originalPath)\n\n checkPath(path, originalPath, throwError)\n\n return this._t(path, cache, checkUnignored, slices)\n }\n\n _t (path, cache, checkUnignored, slices) {\n if (path in cache) {\n return cache[path]\n }\n\n if (!slices) {\n // path/to/a.js\n // ['path', 'to', 'a.js']\n slices = path.split(SLASH)\n }\n\n slices.pop()\n\n // If the path has no parent directory, just test it\n if (!slices.length) {\n return cache[path] = this._testOne(path, checkUnignored)\n }\n\n const parent = this._t(\n slices.join(SLASH) + SLASH,\n cache,\n checkUnignored,\n slices\n )\n\n // If the path contains a parent directory, check the parent first\n return cache[path] = parent.ignored\n // > It is not possible to re-include a file if a parent directory of\n // > that file is excluded.\n ? parent\n : this._testOne(path, checkUnignored)\n }\n\n ignores (path) {\n return this._test(path, this._ignoreCache, false).ignored\n }\n\n createFilter () {\n return path => !this.ignores(path)\n }\n\n filter (paths) {\n return makeArray(paths).filter(this.createFilter())\n }\n\n // @returns {TestResult}\n test (path) {\n return this._test(path, this._testCache, true)\n }\n}\n\nconst factory = options => new Ignore(options)\n\nconst returnFalse = () => false\n\nconst isPathValid = path =>\n checkPath(path && checkPath.convert(path), path, returnFalse)\n\nfactory.isPathValid = isPathValid\n\n// Fixes typescript\nfactory.default = factory\n\nmodule.exports = factory\n\n// Windows\n// --------------------------------------------------------------\n/* istanbul ignore if */\nif (\n // Detect `process` so that it can run in browsers.\n typeof process !== 'undefined'\n && (\n process.env && process.env.IGNORE_TEST_WIN32\n || process.platform === 'win32'\n )\n) {\n /* eslint no-control-regex: \"off\" */\n const makePosix = str => /^\\\\\\\\\\?\\\\/.test(str)\n || /[\"<>|\\u0000-\\u001F]+/u.test(str)\n ? str\n : str.replace(/\\\\/g, '/')\n\n checkPath.convert = makePosix\n\n // 'C:\\\\foo' <- 'C:\\\\foo' has been converted to 'C:/'\n // 'd:\\\\foo'\n const REGIX_IS_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\\//i\n checkPath.isNotRelative = path =>\n REGIX_IS_WINDOWS_PATH_ABSOLUTE.test(path)\n || isNotRelative(path)\n}\n","'use strict';\n\nfunction escapeRegExp(string) {\n return string.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'); // $& means the whole matched string\n}\n\nfunction replaceAll(str, search, replacement) {\n search = search instanceof RegExp ? search : new RegExp(escapeRegExp(search), 'g');\n\n return str.replace(search, replacement);\n}\n\nvar CleanGitRef = {\n clean: function clean(value) {\n if (typeof value !== 'string') {\n throw new Error('Expected a string, received: ' + value);\n }\n\n value = replaceAll(value, './', '/');\n value = replaceAll(value, '..', '.');\n value = replaceAll(value, ' ', '-');\n value = replaceAll(value, /^[~^:?*\\\\\\-]/g, '');\n value = replaceAll(value, /[~^:?*\\\\]/g, '-');\n value = replaceAll(value, /[~^:?*\\\\\\-]$/g, '');\n value = replaceAll(value, '@{', '-');\n value = replaceAll(value, /\\.$/g, '');\n value = replaceAll(value, /\\/$/g, '');\n value = replaceAll(value, /\\.lock$/g, '');\n return value;\n }\n};\n\nmodule.exports = CleanGitRef;","/*\n * URL: https://github.com/cubicdaiya/onp\n *\n * Copyright (c) 2013 Tatsuhiko Kubo <cubicdaiya@gmail.com>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\n/**\n * The algorithm implemented here is based on \"An O(NP) Sequence Comparison Algorithm\"\n * by described by Sun Wu, Udi Manber and Gene Myers\n*/\nmodule.exports = function (a_, b_) {\n var a = a_,\n b = b_,\n m = a.length,\n n = b.length,\n reverse = false,\n ed = null,\n offset = m + 1,\n path = [],\n pathposi = [],\n ses = [],\n lcs = \"\",\n SES_DELETE = -1,\n SES_COMMON = 0,\n SES_ADD = 1;\n\n var tmp1,\n tmp2;\n\n var init = function () {\n if (m >= n) {\n tmp1 = a;\n tmp2 = m;\n a = b;\n b = tmp1;\n m = n;\n n = tmp2;\n reverse = true;\n offset = m + 1;\n }\n };\n\n var P = function (x, y, k) {\n return {\n 'x' : x,\n 'y' : y,\n 'k' : k,\n };\n };\n\n var seselem = function (elem, t) {\n return {\n 'elem' : elem,\n 't' : t,\n };\n };\n\n var snake = function (k, p, pp) {\n var r, x, y;\n if (p > pp) {\n r = path[k-1+offset];\n } else {\n r = path[k+1+offset];\n }\n\n y = Math.max(p, pp);\n x = y - k;\n while (x < m && y < n && a[x] === b[y]) {\n ++x;\n ++y;\n }\n\n path[k+offset] = pathposi.length;\n pathposi[pathposi.length] = new P(x, y, r);\n return y;\n };\n\n var recordseq = function (epc) {\n var x_idx, y_idx, px_idx, py_idx, i;\n x_idx = y_idx = 1;\n px_idx = py_idx = 0;\n for (i=epc.length-1;i>=0;--i) {\n while(px_idx < epc[i].x || py_idx < epc[i].y) {\n if (epc[i].y - epc[i].x > py_idx - px_idx) {\n if (reverse) {\n ses[ses.length] = new seselem(b[py_idx], SES_DELETE);\n } else {\n ses[ses.length] = new seselem(b[py_idx], SES_ADD);\n }\n ++y_idx;\n ++py_idx;\n } else if (epc[i].y - epc[i].x < py_idx - px_idx) {\n if (reverse) {\n ses[ses.length] = new seselem(a[px_idx], SES_ADD);\n } else {\n ses[ses.length] = new seselem(a[px_idx], SES_DELETE);\n }\n ++x_idx;\n ++px_idx;\n } else {\n ses[ses.length] = new seselem(a[px_idx], SES_COMMON);\n lcs += a[px_idx];\n ++x_idx;\n ++y_idx;\n ++px_idx;\n ++py_idx;\n }\n }\n }\n };\n\n init();\n\n return {\n SES_DELETE : -1,\n SES_COMMON : 0,\n SES_ADD : 1,\n editdistance : function () {\n return ed;\n },\n getlcs : function () {\n return lcs;\n },\n getses : function () {\n return ses;\n },\n compose : function () {\n var delta, size, fp, p, r, epc, i, k;\n delta = n - m;\n size = m + n + 3;\n fp = {};\n for (i=0;i<size;++i) {\n fp[i] = -1;\n path[i] = -1;\n }\n p = -1;\n do {\n ++p;\n for (k=-p;k<=delta-1;++k) {\n fp[k+offset] = snake(k, fp[k-1+offset]+1, fp[k+1+offset]);\n }\n for (k=delta+p;k>=delta+1;--k) {\n fp[k+offset] = snake(k, fp[k-1+offset]+1, fp[k+1+offset]);\n }\n fp[delta+offset] = snake(delta, fp[delta-1+offset]+1, fp[delta+1+offset]);\n } while (fp[delta+offset] !== n);\n\n ed = delta + 2 * p;\n\n r = path[delta+offset];\n\n epc = [];\n while (r !== -1) {\n epc[epc.length] = new P(pathposi[r].x, pathposi[r].y, null);\n r = pathposi[r].k;\n }\n recordseq(epc);\n }\n };\n};\n","// Copyright (c) 2006, 2008 Tony Garnock-Jones <tonyg@lshift.net>\n// Copyright (c) 2006, 2008 LShift Ltd. <query@lshift.net>\n//\n// Permission is hereby granted, free of charge, to any person\n// obtaining a copy of this software and associated documentation files\n// (the \"Software\"), to deal in the Software without restriction,\n// including without limitation the rights to use, copy, modify, merge,\n// publish, distribute, sublicense, and/or sell copies of the Software,\n// and to permit persons to whom the Software is furnished to do so,\n// subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be\n// included in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\n// BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\n// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\n// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\nvar onp = require('./onp');\n\nfunction longestCommonSubsequence(file1, file2) {\n var diff = new onp(file1, file2);\n diff.compose();\n var ses = diff.getses();\n\n var root;\n var prev;\n var file1RevIdx = file1.length - 1,\n file2RevIdx = file2.length - 1;\n for (var i = ses.length - 1; i >= 0; --i) {\n if (ses[i].t === diff.SES_COMMON) {\n if (prev) {\n prev.chain = {\n file1index: file1RevIdx,\n file2index: file2RevIdx,\n chain: null\n };\n prev = prev.chain;\n } else {\n root = {\n file1index: file1RevIdx,\n file2index: file2RevIdx,\n chain: null\n };\n prev = root;\n }\n file1RevIdx--;\n file2RevIdx--;\n } else if (ses[i].t === diff.SES_DELETE) {\n file1RevIdx--;\n } else if (ses[i].t === diff.SES_ADD) {\n file2RevIdx--;\n }\n }\n\n var tail = {\n file1index: -1,\n file2index: -1,\n chain: null\n };\n\n if (!prev) {\n return tail;\n }\n\n prev.chain = tail;\n\n return root;\n}\n\nfunction diffIndices(file1, file2) {\n // We apply the LCS to give a simple representation of the\n // offsets and lengths of mismatched chunks in the input\n // files. This is used by diff3_merge_indices below.\n\n var result = [];\n var tail1 = file1.length;\n var tail2 = file2.length;\n\n for (var candidate = longestCommonSubsequence(file1, file2); candidate !== null; candidate = candidate.chain) {\n var mismatchLength1 = tail1 - candidate.file1index - 1;\n var mismatchLength2 = tail2 - candidate.file2index - 1;\n tail1 = candidate.file1index;\n tail2 = candidate.file2index;\n\n if (mismatchLength1 || mismatchLength2) {\n result.push({\n file1: [tail1 + 1, mismatchLength1],\n file2: [tail2 + 1, mismatchLength2]\n });\n }\n }\n\n result.reverse();\n return result;\n}\n\nfunction diff3MergeIndices(a, o, b) {\n // Given three files, A, O, and B, where both A and B are\n // independently derived from O, returns a fairly complicated\n // internal representation of merge decisions it's taken. The\n // interested reader may wish to consult\n //\n // Sanjeev Khanna, Keshav Kunal, and Benjamin C. Pierce. \"A\n // Formal Investigation of Diff3.\" In Arvind and Prasad,\n // editors, Foundations of Software Technology and Theoretical\n // Computer Science (FSTTCS), December 2007.\n //\n // (http://www.cis.upenn.edu/~bcpierce/papers/diff3-short.pdf)\n var i;\n\n var m1 = diffIndices(o, a);\n var m2 = diffIndices(o, b);\n\n var hunks = [];\n\n function addHunk(h, side) {\n hunks.push([h.file1[0], side, h.file1[1], h.file2[0], h.file2[1]]);\n }\n for (i = 0; i < m1.length; i++) {\n addHunk(m1[i], 0);\n }\n for (i = 0; i < m2.length; i++) {\n addHunk(m2[i], 2);\n }\n hunks.sort(function(x, y) {\n return x[0] - y[0]\n });\n\n var result = [];\n var commonOffset = 0;\n\n function copyCommon(targetOffset) {\n if (targetOffset > commonOffset) {\n result.push([1, commonOffset, targetOffset - commonOffset]);\n commonOffset = targetOffset;\n }\n }\n\n for (var hunkIndex = 0; hunkIndex < hunks.length; hunkIndex++) {\n var firstHunkIndex = hunkIndex;\n var hunk = hunks[hunkIndex];\n var regionLhs = hunk[0];\n var regionRhs = regionLhs + hunk[2];\n while (hunkIndex < hunks.length - 1) {\n var maybeOverlapping = hunks[hunkIndex + 1];\n var maybeLhs = maybeOverlapping[0];\n if (maybeLhs > regionRhs) break;\n regionRhs = Math.max(regionRhs, maybeLhs + maybeOverlapping[2]);\n hunkIndex++;\n }\n\n copyCommon(regionLhs);\n if (firstHunkIndex == hunkIndex) {\n // The \"overlap\" was only one hunk long, meaning that\n // there's no conflict here. Either a and o were the\n // same, or b and o were the same.\n if (hunk[4] > 0) {\n result.push([hunk[1], hunk[3], hunk[4]]);\n }\n } else {\n // A proper conflict. Determine the extents of the\n // regions involved from a, o and b. Effectively merge\n // all the hunks on the left into one giant hunk, and\n // do the same for the right; then, correct for skew\n // in the regions of o that each side changed, and\n // report appropriate spans for the three sides.\n var regions = {\n 0: [a.length, -1, o.length, -1],\n 2: [b.length, -1, o.length, -1]\n };\n for (i = firstHunkIndex; i <= hunkIndex; i++) {\n hunk = hunks[i];\n var side = hunk[1];\n var r = regions[side];\n var oLhs = hunk[0];\n var oRhs = oLhs + hunk[2];\n var abLhs = hunk[3];\n var abRhs = abLhs + hunk[4];\n r[0] = Math.min(abLhs, r[0]);\n r[1] = Math.max(abRhs, r[1]);\n r[2] = Math.min(oLhs, r[2]);\n r[3] = Math.max(oRhs, r[3]);\n }\n var aLhs = regions[0][0] + (regionLhs - regions[0][2]);\n var aRhs = regions[0][1] + (regionRhs - regions[0][3]);\n var bLhs = regions[2][0] + (regionLhs - regions[2][2]);\n var bRhs = regions[2][1] + (regionRhs - regions[2][3]);\n result.push([-1,\n aLhs, aRhs - aLhs,\n regionLhs, regionRhs - regionLhs,\n bLhs, bRhs - bLhs\n ]);\n }\n commonOffset = regionRhs;\n }\n\n copyCommon(o.length);\n return result;\n}\n\nfunction diff3Merge(a, o, b) {\n // Applies the output of Diff.diff3_merge_indices to actually\n // construct the merged file; the returned result alternates\n // between \"ok\" and \"conflict\" blocks.\n\n var result = [];\n var files = [a, o, b];\n var indices = diff3MergeIndices(a, o, b);\n\n var okLines = [];\n\n function flushOk() {\n if (okLines.length) {\n result.push({\n ok: okLines\n });\n }\n okLines = [];\n }\n\n function pushOk(xs) {\n for (var j = 0; j < xs.length; j++) {\n okLines.push(xs[j]);\n }\n }\n\n function isTrueConflict(rec) {\n if (rec[2] != rec[6]) return true;\n var aoff = rec[1];\n var boff = rec[5];\n for (var j = 0; j < rec[2]; j++) {\n if (a[j + aoff] != b[j + boff]) return true;\n }\n return false;\n }\n\n for (var i = 0; i < indices.length; i++) {\n var x = indices[i];\n var side = x[0];\n if (side == -1) {\n if (!isTrueConflict(x)) {\n pushOk(files[0].slice(x[1], x[1] + x[2]));\n } else {\n flushOk();\n result.push({\n conflict: {\n a: a.slice(x[1], x[1] + x[2]),\n aIndex: x[1],\n o: o.slice(x[3], x[3] + x[4]),\n oIndex: x[3],\n b: b.slice(x[5], x[5] + x[6]),\n bIndex: x[5]\n }\n });\n }\n } else {\n pushOk(files[side].slice(x[1], x[1] + x[2]));\n }\n }\n\n flushOk();\n return result;\n}\n\nmodule.exports = diff3Merge;\n","import AsyncLock from 'async-lock';\nimport Hash from 'sha.js/sha1.js';\nimport { join } from 'path-browserify';\nimport crc32 from 'crc-32';\nimport pako from 'pako';\nimport pify from 'pify';\nimport ignore from 'ignore';\nimport cleanGitRef from 'clean-git-ref';\nimport diff3Merge from 'diff3';\n\n/**\n * @typedef {Object} GitProgressEvent\n * @property {string} phase\n * @property {number} loaded\n * @property {number} total\n */\n\n/**\n * @callback ProgressCallback\n * @param {GitProgressEvent} progress\n * @returns {void | Promise<void>}\n */\n\n/**\n * @typedef {Object} GitHttpRequest\n * @property {string} url - The URL to request\n * @property {string} [method='GET'] - The HTTP method to use\n * @property {Object<string, string>} [headers={}] - Headers to include in the HTTP request\n * @property {Object} [agent] - An HTTP or HTTPS agent that manages connections for the HTTP client (Node.js only)\n * @property {AsyncIterableIterator<Uint8Array>} [body] - An async iterator of Uint8Arrays that make up the body of POST requests\n * @property {ProgressCallback} [onProgress] - Reserved for future use (emitting `GitProgressEvent`s)\n * @property {object} [signal] - Reserved for future use (canceling a request)\n */\n\n/**\n * @typedef {Object} GitHttpResponse\n * @property {string} url - The final URL that was fetched after any redirects\n * @property {string} [method] - The HTTP method that was used\n * @property {Object<string, string>} [headers] - HTTP response headers\n * @property {AsyncIterableIterator<Uint8Array>} [body] - An async iterator of Uint8Arrays that make up the body of the response\n * @property {number} statusCode - The HTTP status code\n * @property {string} statusMessage - The HTTP status message\n */\n\n/**\n * @callback HttpFetch\n * @param {GitHttpRequest} request\n * @returns {Promise<GitHttpResponse>}\n */\n\n/**\n * @typedef {Object} HttpClient\n * @property {HttpFetch} request\n */\n\n/**\n * A git commit object.\n *\n * @typedef {Object} CommitObject\n * @property {string} message Commit message\n * @property {string} tree SHA-1 object id of corresponding file tree\n * @property {string[]} parent an array of zero or more SHA-1 object ids\n * @property {Object} author\n * @property {string} author.name The author's name\n * @property {string} author.email The author's email\n * @property {number} author.timestamp UTC Unix timestamp in seconds\n * @property {number} author.timezoneOffset Timezone difference from UTC in minutes\n * @property {Object} committer\n * @property {string} committer.name The committer's name\n * @property {string} committer.email The committer's email\n * @property {number} committer.timestamp UTC Unix timestamp in seconds\n * @property {number} committer.timezoneOffset Timezone difference from UTC in minutes\n * @property {string} [gpgsig] PGP signature (if present)\n */\n\n/**\n * An entry from a git tree object. Files are called 'blobs' and directories are called 'trees'.\n *\n * @typedef {Object} TreeEntry\n * @property {string} mode the 6 digit hexadecimal mode\n * @property {string} path the name of the file or directory\n * @property {string} oid the SHA-1 object id of the blob or tree\n * @property {'commit'|'blob'|'tree'} type the type of object\n */\n\n/**\n * A git tree object. Trees represent a directory snapshot.\n *\n * @typedef {TreeEntry[]} TreeObject\n */\n\n/**\n * A git annotated tag object.\n *\n * @typedef {Object} TagObject\n * @property {string} object SHA-1 object id of object being tagged\n * @property {'blob' | 'tree' | 'commit' | 'tag'} type the type of the object being tagged\n * @property {string} tag the tag name\n * @property {Object} tagger\n * @property {string} tagger.name the tagger's name\n * @property {string} tagger.email the tagger's email\n * @property {number} tagger.timestamp UTC Unix timestamp in seconds\n * @property {number} tagger.timezoneOffset timezone difference from UTC in minutes\n * @property {string} message tag message\n * @property {string} [gpgsig] PGP signature (if present)\n */\n\n/**\n * @typedef {Object} ReadCommitResult\n * @property {string} oid - SHA-1 object id of this commit\n * @property {CommitObject} commit - the parsed commit object\n * @property {string} payload - PGP signing payload\n */\n\n/**\n * @typedef {Object} ServerRef - This object has the following schema:\n * @property {string} ref - The name of the ref\n * @property {string} oid - The SHA-1 object id the ref points to\n * @property {string} [target] - The target ref pointed to by a symbolic ref\n * @property {string} [peeled] - If the oid is the SHA-1 object id of an annotated tag, this is the SHA-1 object id that the annotated tag points to\n */\n\n/**\n * @typedef Walker\n * @property {Symbol} Symbol('GitWalkerSymbol')\n */\n\n/**\n * Normalized subset of filesystem `stat` data:\n *\n * @typedef {Object} Stat\n * @property {number} ctimeSeconds\n * @property {number} ctimeNanoseconds\n * @property {number} mtimeSeconds\n * @property {number} mtimeNanoseconds\n * @property {number} dev\n * @property {number} ino\n * @property {number} mode\n * @property {number} uid\n * @property {number} gid\n * @property {number} size\n */\n\n/**\n * The `WalkerEntry` is an interface that abstracts computing many common tree / blob stats.\n *\n * @typedef {Object} WalkerEntry\n * @property {function(): Promise<'tree'|'blob'|'special'|'commit'>} type\n * @property {function(): Promise<number>} mode\n * @property {function(): Promise<string>} oid\n * @property {function(): Promise<Uint8Array|void>} content\n * @property {function(): Promise<Stat>} stat\n */\n\n/**\n * @typedef {Object} CallbackFsClient\n * @property {function} readFile - https://nodejs.org/api/fs.html#fs_fs_readfile_path_options_callback\n * @property {function} writeFile - https://nodejs.org/api/fs.html#fs_fs_writefile_file_data_options_callback\n * @property {function} unlink - https://nodejs.org/api/fs.html#fs_fs_unlink_path_callback\n * @property {function} readdir - https://nodejs.org/api/fs.html#fs_fs_readdir_path_options_callback\n * @property {function} mkdir - https://nodejs.org/api/fs.html#fs_fs_mkdir_path_mode_callback\n * @property {function} rmdir - https://nodejs.org/api/fs.html#fs_fs_rmdir_path_callback\n * @property {function} stat - https://nodejs.org/api/fs.html#fs_fs_stat_path_options_callback\n * @property {function} lstat - https://nodejs.org/api/fs.html#fs_fs_lstat_path_options_callback\n * @property {function} [readlink] - https://nodejs.org/api/fs.html#fs_fs_readlink_path_options_callback\n * @property {function} [symlink] - https://nodejs.org/api/fs.html#fs_fs_symlink_target_path_type_callback\n * @property {function} [chmod] - https://nodejs.org/api/fs.html#fs_fs_chmod_path_mode_callback\n */\n\n/**\n * @typedef {Object} PromiseFsClient\n * @property {Object} promises\n * @property {function} promises.readFile - https://nodejs.org/api/fs.html#fs_fspromises_readfile_path_options\n * @property {function} promises.writeFile - https://nodejs.org/api/fs.html#fs_fspromises_writefile_file_data_options\n * @property {function} promises.unlink - https://nodejs.org/api/fs.html#fs_fspromises_unlink_path\n * @property {function} promises.readdir - https://nodejs.org/api/fs.html#fs_fspromises_readdir_path_options\n * @property {function} promises.mkdir - https://nodejs.org/api/fs.html#fs_fspromises_mkdir_path_options\n * @property {function} promises.rmdir - https://nodejs.org/api/fs.html#fs_fspromises_rmdir_path\n * @property {function} promises.stat - https://nodejs.org/api/fs.html#fs_fspromises_stat_path_options\n * @property {function} promises.lstat - https://nodejs.org/api/fs.html#fs_fspromises_lstat_path_options\n * @property {function} [promises.readlink] - https://nodejs.org/api/fs.html#fs_fspromises_readlink_path_options\n * @property {function} [promises.symlink] - https://nodejs.org/api/fs.html#fs_fspromises_symlink_target_path_type\n * @property {function} [promises.chmod] - https://nodejs.org/api/fs.html#fs_fspromises_chmod_path_mode\n */\n\n/**\n * @typedef {CallbackFsClient | PromiseFsClient} FsClient\n */\n\n/**\n * @callback MessageCallback\n * @param {string} message\n * @returns {void | Promise<void>}\n */\n\n/**\n * @typedef {Object} GitAuth\n * @property {string} [username]\n * @property {string} [password]\n * @property {Object<string, string>} [headers]\n * @property {boolean} [cancel] Tells git to throw a `UserCanceledError` (instead of an `HttpError`).\n */\n\n/**\n * @callback AuthCallback\n * @param {string} url\n * @param {GitAuth} auth Might have some values if the URL itself originally contained a username or password.\n * @returns {GitAuth | void | Promise<GitAuth | void>}\n */\n\n/**\n * @callback AuthFailureCallback\n * @param {string} url\n * @param {GitAuth} auth The credentials that failed\n * @returns {GitAuth | void | Promise<GitAuth | void>}\n */\n\n/**\n * @callback AuthSuccessCallback\n * @param {string} url\n * @param {GitAuth} auth\n * @returns {void | Promise<void>}\n */\n\n/**\n * @typedef {Object} SignParams\n * @property {string} payload - a plaintext message\n * @property {string} secretKey - an 'ASCII armor' encoded PGP key (technically can actually contain _multiple_ keys)\n */\n\n/**\n * @callback SignCallback\n * @param {SignParams} args\n * @return {{signature: string} | Promise<{signature: string}>} - an 'ASCII armor' encoded \"detached\" signature\n */\n\n/**\n * @typedef {Object} MergeDriverParams\n * @property {Array<string>} branches\n * @property {Array<string>} contents\n * @property {string} path\n */\n\n/**\n * @callback MergeDriverCallback\n * @param {MergeDriverParams} args\n * @return {{cleanMerge: boolean, mergedText: string} | Promise<{cleanMerge: boolean, mergedText: string}>}\n */\n\n/**\n * @callback WalkerMap\n * @param {string} filename\n * @param {WalkerEntry[]} entries\n * @returns {Promise<any>}\n */\n\n/**\n * @callback WalkerReduce\n * @param {any} parent\n * @param {any[]} children\n * @returns {Promise<any>}\n */\n\n/**\n * @callback WalkerIterateCallback\n * @param {WalkerEntry[]} entries\n * @returns {Promise<any[]>}\n */\n\n/**\n * @callback WalkerIterate\n * @param {WalkerIterateCallback} walk\n * @param {IterableIterator<WalkerEntry[]>} children\n * @returns {Promise<any[]>}\n */\n\n/**\n * @typedef {Object} RefUpdateStatus\n * @property {boolean} ok\n * @property {string} error\n */\n\n/**\n * @typedef {Object} PushResult\n * @property {boolean} ok\n * @property {?string} error\n * @property {Object<string, RefUpdateStatus>} refs\n * @property {Object<string, string>} [headers]\n */\n\n/**\n * @typedef {0|1} HeadStatus\n */\n\n/**\n * @typedef {0|1|2} WorkdirStatus\n */\n\n/**\n * @typedef {0|1|2|3} StageStatus\n */\n\n/**\n * @typedef {[string, HeadStatus, WorkdirStatus, StageStatus]} StatusRow\n */\n\n/**\n * @typedef {'push' | 'pop' | 'apply' | 'drop' | 'list' | 'clear'} StashOp the type of stash ops\n */\n\n/**\n * @typedef {'equal' | 'modify' | 'add' | 'remove' | 'unknown'} StashChangeType - when compare WORDIR to HEAD, 'remove' could mean 'untracked'\n * @typedef {Object} ClientRef\n * @property {string} ref The name of the ref\n * @property {string} oid The SHA-1 object id the ref points to\n */\n\n/**\n * @typedef {Object} PrePushParams\n * @property {string} remote The expanded name of target remote\n * @property {string} url The URL address of target remote\n * @property {ClientRef} localRef The ref which the client wants to push to the remote\n * @property {ClientRef} remoteRef The ref which is known by the remote\n */\n\n/**\n * @callback PrePushCallback\n * @param {PrePushParams} args\n * @returns {boolean | Promise<boolean>} Returns false if push must be cancelled\n */\n\n/**\n * @typedef {Object} PostCheckoutParams\n * @property {string} previousHead The SHA-1 object id of HEAD before checkout\n * @property {string} newHead The SHA-1 object id of HEAD after checkout\n * @property {'branch' | 'file'} type flag determining whether a branch or a set of files was checked\n */\n\n/**\n * @callback PostCheckoutCallback\n * @param {PostCheckoutParams} args\n * @returns {void | Promise<void>}\n */\n\nclass BaseError extends Error {\n constructor(message) {\n super(message);\n // Setting this here allows TS to infer that all git errors have a `caller` property and\n // that its type is string.\n this.caller = '';\n }\n\n toJSON() {\n // Error objects aren't normally serializable. So we do something about that.\n return {\n code: this.code,\n data: this.data,\n caller: this.caller,\n message: this.message,\n stack: this.stack,\n }\n }\n\n fromJSON(json) {\n const e = new BaseError(json.message);\n e.code = json.code;\n e.data = json.data;\n e.caller = json.caller;\n e.stack = json.stack;\n return e\n }\n\n get isIsomorphicGitError() {\n return true\n }\n}\n\nclass UnmergedPathsError extends BaseError {\n /**\n * @param {Array<string>} filepaths\n */\n constructor(filepaths) {\n super(\n `Modifying the index is not possible because you have unmerged files: ${filepaths.toString}. Fix them up in the work tree, and then use 'git add/rm as appropriate to mark resolution and make a commit.`\n );\n this.code = this.name = UnmergedPathsError.code;\n this.data = { filepaths };\n }\n}\n/** @type {'UnmergedPathsError'} */\nUnmergedPathsError.code = 'UnmergedPathsError';\n\nclass InternalError extends BaseError {\n /**\n * @param {string} message\n */\n constructor(message) {\n super(\n `An internal error caused this command to fail. Please file a bug report at https://github.com/isomorphic-git/isomorphic-git/issues with this error message: ${message}`\n );\n this.code = this.name = InternalError.code;\n this.data = { message };\n }\n}\n/** @type {'InternalError'} */\nInternalError.code = 'InternalError';\n\nclass UnsafeFilepathError extends BaseError {\n /**\n * @param {string} filepath\n */\n constructor(filepath) {\n super(`The filepath \"${filepath}\" contains unsafe character sequences`);\n this.code = this.name = UnsafeFilepathError.code;\n this.data = { filepath };\n }\n}\n/** @type {'UnsafeFilepathError'} */\nUnsafeFilepathError.code = 'UnsafeFilepathError';\n\n// Modeled after https://github.com/tjfontaine/node-buffercursor\n// but with the goal of being much lighter weight.\nclass BufferCursor {\n constructor(buffer) {\n this.buffer = buffer;\n this._start = 0;\n }\n\n eof() {\n return this._start >= this.buffer.length\n }\n\n tell() {\n return this._start\n }\n\n seek(n) {\n this._start = n;\n }\n\n slice(n) {\n const r = this.buffer.slice(this._start, this._start + n);\n this._start += n;\n return r\n }\n\n toString(enc, length) {\n const r = this.buffer.toString(enc, this._start, this._start + length);\n this._start += length;\n return r\n }\n\n write(value, length, enc) {\n const r = this.buffer.write(value, this._start, length, enc);\n this._start += length;\n return r\n }\n\n copy(source, start, end) {\n const r = source.copy(this.buffer, this._start, start, end);\n this._start += r;\n return r\n }\n\n readUInt8() {\n const r = this.buffer.readUInt8(this._start);\n this._start += 1;\n return r\n }\n\n writeUInt8(value) {\n const r = this.buffer.writeUInt8(value, this._start);\n this._start += 1;\n return r\n }\n\n readUInt16BE() {\n const r = this.buffer.readUInt16BE(this._start);\n this._start += 2;\n return r\n }\n\n writeUInt16BE(value) {\n const r = this.buffer.writeUInt16BE(value, this._start);\n this._start += 2;\n return r\n }\n\n readUInt32BE() {\n const r = this.buffer.readUInt32BE(this._start);\n this._start += 4;\n return r\n }\n\n writeUInt32BE(value) {\n const r = this.buffer.writeUInt32BE(value, this._start);\n this._start += 4;\n return r\n }\n}\n\nfunction compareStrings(a, b) {\n // https://stackoverflow.com/a/40355107/2168416\n return -(a < b) || +(a > b)\n}\n\nfunction comparePath(a, b) {\n // https://stackoverflow.com/a/40355107/2168416\n return compareStrings(a.path, b.path)\n}\n\n/**\n * From https://github.com/git/git/blob/master/Documentation/technical/index-format.txt\n *\n * 32-bit mode, split into (high to low bits)\n *\n * 4-bit object type\n * valid values in binary are 1000 (regular file), 1010 (symbolic link)\n * and 1110 (gitlink)\n *\n * 3-bit unused\n *\n * 9-bit unix permission. Only 0755 and 0644 are valid for regular files.\n * Symbolic links and gitlinks have value 0 in this field.\n */\nfunction normalizeMode(mode) {\n // Note: BrowserFS will use -1 for \"unknown\"\n // I need to make it non-negative for these bitshifts to work.\n let type = mode > 0 ? mode >> 12 : 0;\n // If it isn't valid, assume it as a \"regular file\"\n // 0100 = directory\n // 1000 = regular file\n // 1010 = symlink\n // 1110 = gitlink\n if (\n type !== 0b0100 &&\n type !== 0b1000 &&\n type !== 0b1010 &&\n type !== 0b1110\n ) {\n type = 0b1000;\n }\n let permissions = mode & 0o777;\n // Is the file executable? then 755. Else 644.\n if (permissions & 0b001001001) {\n permissions = 0o755;\n } else {\n permissions = 0o644;\n }\n // If it's not a regular file, scrub all permissions\n if (type !== 0b1000) permissions = 0;\n return (type << 12) + permissions\n}\n\nconst MAX_UINT32 = 2 ** 32;\n\nfunction SecondsNanoseconds(\n givenSeconds,\n givenNanoseconds,\n milliseconds,\n date\n) {\n if (givenSeconds !== undefined && givenNanoseconds !== undefined) {\n return [givenSeconds, givenNanoseconds]\n }\n if (milliseconds === undefined) {\n milliseconds = date.valueOf();\n }\n const seconds = Math.floor(milliseconds / 1000);\n const nanoseconds = (milliseconds - seconds * 1000) * 1000000;\n return [seconds, nanoseconds]\n}\n\nfunction normalizeStats(e) {\n const [ctimeSeconds, ctimeNanoseconds] = SecondsNanoseconds(\n e.ctimeSeconds,\n e.ctimeNanoseconds,\n e.ctimeMs,\n e.ctime\n );\n const [mtimeSeconds, mtimeNanoseconds] = SecondsNanoseconds(\n e.mtimeSeconds,\n e.mtimeNanoseconds,\n e.mtimeMs,\n e.mtime\n );\n\n return {\n ctimeSeconds: ctimeSeconds % MAX_UINT32,\n ctimeNanoseconds: ctimeNanoseconds % MAX_UINT32,\n mtimeSeconds: mtimeSeconds % MAX_UINT32,\n mtimeNanoseconds: mtimeNanoseconds % MAX_UINT32,\n dev: e.dev % MAX_UINT32,\n ino: e.ino % MAX_UINT32,\n mode: normalizeMode(e.mode % MAX_UINT32),\n uid: e.uid % MAX_UINT32,\n gid: e.gid % MAX_UINT32,\n // size of -1 happens over a BrowserFS HTTP Backend that doesn't serve Content-Length headers\n // (like the Karma webserver) because BrowserFS HTTP Backend uses HTTP HEAD requests to do fs.stat\n size: e.size > -1 ? e.size % MAX_UINT32 : 0,\n }\n}\n\nfunction toHex(buffer) {\n let hex = '';\n for (const byte of new Uint8Array(buffer)) {\n if (byte < 16) hex += '0';\n hex += byte.toString(16);\n }\n return hex\n}\n\n/* eslint-env node, browser */\n\nlet supportsSubtleSHA1 = null;\n\nasync function shasum(buffer) {\n if (supportsSubtleSHA1 === null) {\n supportsSubtleSHA1 = await testSubtleSHA1();\n }\n return supportsSubtleSHA1 ? subtleSHA1(buffer) : shasumSync(buffer)\n}\n\n// This is modeled after @dominictarr's \"shasum\" module,\n// but without the 'json-stable-stringify' dependency and\n// extra type-casting features.\nfunction shasumSync(buffer) {\n return new Hash().update(buffer).digest('hex')\n}\n\nasync function subtleSHA1(buffer) {\n const hash = await crypto.subtle.digest('SHA-1', buffer);\n return toHex(hash)\n}\n\nasync function testSubtleSHA1() {\n // I'm using a rather crude method of progressive enhancement, because\n // some browsers that have crypto.subtle.digest don't actually implement SHA-1.\n try {\n const hash = await subtleSHA1(new Uint8Array([]));\n if (hash === 'da39a3ee5e6b4b0d3255bfef95601890afd80709') return true\n } catch (_) {\n // no bother\n }\n return false\n}\n\n// Extract 1-bit assume-valid, 1-bit extended flag, 2-bit merge state flag, 12-bit path length flag\nfunction parseCacheEntryFlags(bits) {\n return {\n assumeValid: Boolean(bits & 0b1000000000000000),\n extended: Boolean(bits & 0b0100000000000000),\n stage: (bits & 0b0011000000000000) >> 12,\n nameLength: bits & 0b0000111111111111,\n }\n}\n\nfunction renderCacheEntryFlags(entry) {\n const flags = entry.flags;\n // 1-bit extended flag (must be zero in version 2)\n flags.extended = false;\n // 12-bit name length if the length is less than 0xFFF; otherwise 0xFFF\n // is stored in this field.\n flags.nameLength = Math.min(Buffer.from(entry.path).length, 0xfff);\n return (\n (flags.assumeValid ? 0b1000000000000000 : 0) +\n (flags.extended ? 0b0100000000000000 : 0) +\n ((flags.stage & 0b11) << 12) +\n (flags.nameLength & 0b111111111111)\n )\n}\n\nclass GitIndex {\n /*::\n _entries: Map<string, CacheEntry>\n _dirty: boolean // Used to determine if index needs to be saved to filesystem\n */\n constructor(entries, unmergedPaths) {\n this._dirty = false;\n this._unmergedPaths = unmergedPaths || new Set();\n this._entries = entries || new Map();\n }\n\n _addEntry(entry) {\n if (entry.flags.stage === 0) {\n entry.stages = [entry];\n this._entries.set(entry.path, entry);\n this._unmergedPaths.delete(entry.path);\n } else {\n let existingEntry = this._entries.get(entry.path);\n if (!existingEntry) {\n this._entries.set(entry.path, entry);\n existingEntry = entry;\n }\n existingEntry.stages[entry.flags.stage] = entry;\n this._unmergedPaths.add(entry.path);\n }\n }\n\n static async from(buffer) {\n if (Buffer.isBuffer(buffer)) {\n return GitIndex.fromBuffer(buffer)\n } else if (buffer === null) {\n return new GitIndex(null)\n } else {\n throw new InternalError('invalid type passed to GitIndex.from')\n }\n }\n\n static async fromBuffer(buffer) {\n if (buffer.length === 0) {\n throw new InternalError('Index file is empty (.git/index)')\n }\n\n const index = new GitIndex();\n const reader = new BufferCursor(buffer);\n const magic = reader.toString('utf8', 4);\n if (magic !== 'DIRC') {\n throw new InternalError(`Invalid dircache magic file number: ${magic}`)\n }\n\n // Verify shasum after we ensured that the file has a magic number\n const shaComputed = await shasum(buffer.slice(0, -20));\n const shaClaimed = buffer.slice(-20).toString('hex');\n if (shaClaimed !== shaComputed) {\n throw new InternalError(\n `Invalid checksum in GitIndex buffer: expected ${shaClaimed} but saw ${shaComputed}`\n )\n }\n\n const version = reader.readUInt32BE();\n if (version !== 2) {\n throw new InternalError(`Unsupported dircache version: ${version}`)\n }\n const numEntries = reader.readUInt32BE();\n let i = 0;\n while (!reader.eof() && i < numEntries) {\n const entry = {};\n entry.ctimeSeconds = reader.readUInt32BE();\n entry.ctimeNanoseconds = reader.readUInt32BE();\n entry.mtimeSeconds = reader.readUInt32BE();\n entry.mtimeNanoseconds = reader.readUInt32BE();\n entry.dev = reader.readUInt32BE();\n entry.ino = reader.readUInt32BE();\n entry.mode = reader.readUInt32BE();\n entry.uid = reader.readUInt32BE();\n entry.gid = reader.readUInt32BE();\n entry.size = reader.readUInt32BE();\n entry.oid = reader.slice(20).toString('hex');\n const flags = reader.readUInt16BE();\n entry.flags = parseCacheEntryFlags(flags);\n // TODO: handle if (version === 3 && entry.flags.extended)\n const pathlength = buffer.indexOf(0, reader.tell() + 1) - reader.tell();\n if (pathlength < 1) {\n throw new InternalError(`Got a path length of: ${pathlength}`)\n }\n // TODO: handle pathnames larger than 12 bits\n entry.path = reader.toString('utf8', pathlength);\n\n // Prevent malicious paths like \"..\\foo\"\n if (entry.path.includes('..\\\\') || entry.path.includes('../')) {\n throw new UnsafeFilepathError(entry.path)\n }\n\n // The next bit is awkward. We expect 1 to 8 null characters\n // such that the total size of the entry is a multiple of 8 bits.\n // (Hence subtract 12 bytes for the header.)\n let padding = 8 - ((reader.tell() - 12) % 8);\n if (padding === 0) padding = 8;\n while (padding--) {\n const tmp = reader.readUInt8();\n if (tmp !== 0) {\n throw new InternalError(\n `Expected 1-8 null characters but got '${tmp}' after ${entry.path}`\n )\n } else if (reader.eof()) {\n throw new InternalError('Unexpected end of file')\n }\n }\n // end of awkward part\n entry.stages = [];\n\n index._addEntry(entry);\n\n i++;\n }\n return index\n }\n\n get unmergedPaths() {\n return [...this._unmergedPaths]\n }\n\n get entries() {\n return [...this._entries.values()].sort(comparePath)\n }\n\n get entriesMap() {\n return this._entries\n }\n\n get entriesFlat() {\n return [...this.entries].flatMap(entry => {\n return entry.stages.length > 1 ? entry.stages.filter(x => x) : entry\n })\n }\n\n *[Symbol.iterator]() {\n for (const entry of this.entries) {\n yield entry;\n }\n }\n\n insert({ filepath, stats, oid, stage = 0 }) {\n if (!stats) {\n stats = {\n ctimeSeconds: 0,\n ctimeNanoseconds: 0,\n mtimeSeconds: 0,\n mtimeNanoseconds: 0,\n dev: 0,\n ino: 0,\n mode: 0,\n uid: 0,\n gid: 0,\n size: 0,\n };\n }\n stats = normalizeStats(stats);\n const bfilepath = Buffer.from(filepath);\n const entry = {\n ctimeSeconds: stats.ctimeSeconds,\n ctimeNanoseconds: stats.ctimeNanoseconds,\n mtimeSeconds: stats.mtimeSeconds,\n mtimeNanoseconds: stats.mtimeNanoseconds,\n dev: stats.dev,\n ino: stats.ino,\n // We provide a fallback value for `mode` here because not all fs\n // implementations assign it, but we use it in GitTree.\n // '100644' is for a \"regular non-executable file\"\n mode: stats.mode || 0o100644,\n uid: stats.uid,\n gid: stats.gid,\n size: stats.size,\n path: filepath,\n oid: oid,\n flags: {\n assumeValid: false,\n extended: false,\n stage,\n nameLength: bfilepath.length < 0xfff ? bfilepath.length : 0xfff,\n },\n stages: [],\n };\n\n this._addEntry(entry);\n\n this._dirty = true;\n }\n\n delete({ filepath }) {\n if (this._entries.has(filepath)) {\n this._entries.delete(filepath);\n } else {\n for (const key of this._entries.keys()) {\n if (key.startsWith(filepath + '/')) {\n this._entries.delete(key);\n }\n }\n }\n\n if (this._unmergedPaths.has(filepath)) {\n this._unmergedPaths.delete(filepath);\n }\n this._dirty = true;\n }\n\n clear() {\n this._entries.clear();\n this._dirty = true;\n }\n\n has({ filepath }) {\n return this._entries.has(filepath)\n }\n\n render() {\n return this.entries\n .map(entry => `${entry.mode.toString(8)} ${entry.oid} ${entry.path}`)\n .join('\\n')\n }\n\n static async _entryToBuffer(entry) {\n const bpath = Buffer.from(entry.path);\n // the fixed length + the filename + at least one null char => align by 8\n const length = Math.ceil((62 + bpath.length + 1) / 8) * 8;\n const written = Buffer.alloc(length);\n const writer = new BufferCursor(written);\n const stat = normalizeStats(entry);\n writer.writeUInt32BE(stat.ctimeSeconds);\n writer.writeUInt32BE(stat.ctimeNanoseconds);\n writer.writeUInt32BE(stat.mtimeSeconds);\n writer.writeUInt32BE(stat.mtimeNanoseconds);\n writer.writeUInt32BE(stat.dev);\n writer.writeUInt32BE(stat.ino);\n writer.writeUInt32BE(stat.mode);\n writer.writeUInt32BE(stat.uid);\n writer.writeUInt32BE(stat.gid);\n writer.writeUInt32BE(stat.size);\n writer.write(entry.oid, 20, 'hex');\n writer.writeUInt16BE(renderCacheEntryFlags(entry));\n writer.write(entry.path, bpath.length, 'utf8');\n return written\n }\n\n async toObject() {\n const header = Buffer.alloc(12);\n const writer = new BufferCursor(header);\n writer.write('DIRC', 4, 'utf8');\n writer.writeUInt32BE(2);\n writer.writeUInt32BE(this.entriesFlat.length);\n\n let entryBuffers = [];\n for (const entry of this.entries) {\n entryBuffers.push(GitIndex._entryToBuffer(entry));\n if (entry.stages.length > 1) {\n for (const stage of entry.stages) {\n if (stage && stage !== entry) {\n entryBuffers.push(GitIndex._entryToBuffer(stage));\n }\n }\n }\n }\n entryBuffers = await Promise.all(entryBuffers);\n\n const body = Buffer.concat(entryBuffers);\n const main = Buffer.concat([header, body]);\n const sum = await shasum(main);\n return Buffer.concat([main, Buffer.from(sum, 'hex')])\n }\n}\n\nfunction compareStats(entry, stats, filemode = true, trustino = true) {\n // Comparison based on the description in Paragraph 4 of\n // https://www.kernel.org/pub/software/scm/git/docs/technical/racy-git.txt\n const e = normalizeStats(entry);\n const s = normalizeStats(stats);\n const staleness =\n (filemode && e.mode !== s.mode) ||\n e.mtimeSeconds !== s.mtimeSeconds ||\n e.ctimeSeconds !== s.ctimeSeconds ||\n e.uid !== s.uid ||\n e.gid !== s.gid ||\n (trustino && e.ino !== s.ino) ||\n e.size !== s.size;\n return staleness\n}\n\n// import LockManager from 'travix-lock-manager'\n\n// import Lock from '../utils.js'\n\n// const lm = new LockManager()\nlet lock = null;\n\nconst IndexCache = Symbol('IndexCache');\n\nfunction createCache() {\n return {\n map: new Map(),\n stats: new Map(),\n }\n}\n\nasync function updateCachedIndexFile(fs, filepath, cache) {\n const [stat, rawIndexFile] = await Promise.all([\n fs.lstat(filepath),\n fs.read(filepath),\n ]);\n\n const index = await GitIndex.from(rawIndexFile);\n // cache the GitIndex object so we don't need to re-read it every time.\n cache.map.set(filepath, index);\n // Save the stat data for the index so we know whether the cached file is stale (modified by an outside process).\n cache.stats.set(filepath, stat);\n}\n\n// Determine whether our copy of the index file is stale\nasync function isIndexStale(fs, filepath, cache) {\n const savedStats = cache.stats.get(filepath);\n if (savedStats === undefined) return true\n if (savedStats === null) return false\n\n const currStats = await fs.lstat(filepath);\n if (currStats === null) return false\n return compareStats(savedStats, currStats)\n}\n\nclass GitIndexManager {\n /**\n *\n * @param {object} opts\n * @param {import('../models/FileSystem.js').FileSystem} opts.fs\n * @param {string} opts.gitdir\n * @param {object} opts.cache\n * @param {bool} opts.allowUnmerged\n * @param {function(GitIndex): any} closure\n */\n static async acquire({ fs, gitdir, cache, allowUnmerged = true }, closure) {\n if (!cache[IndexCache]) {\n cache[IndexCache] = createCache();\n }\n\n const filepath = `${gitdir}/index`;\n if (lock === null) lock = new AsyncLock({ maxPending: Infinity });\n let result;\n let unmergedPaths = [];\n await lock.acquire(filepath, async () => {\n // Acquire a file lock while we're reading the index\n // to make sure other processes aren't writing to it\n // simultaneously, which could result in a corrupted index.\n // const fileLock = await Lock(filepath)\n const theIndexCache = cache[IndexCache];\n if (await isIndexStale(fs, filepath, theIndexCache)) {\n await updateCachedIndexFile(fs, filepath, theIndexCache);\n }\n const index = theIndexCache.map.get(filepath);\n unmergedPaths = index.unmergedPaths;\n\n if (unmergedPaths.length && !allowUnmerged)\n throw new UnmergedPathsError(unmergedPaths)\n\n result = await closure(index);\n if (index._dirty) {\n // Acquire a file lock while we're writing the index file\n // let fileLock = await Lock(filepath)\n const buffer = await index.toObject();\n await fs.write(filepath, buffer);\n // Update cached stat value\n theIndexCache.stats.set(filepath, await fs.lstat(filepath));\n index._dirty = false;\n }\n });\n\n return result\n }\n}\n\nfunction basename(path) {\n const last = Math.max(path.lastIndexOf('/'), path.lastIndexOf('\\\\'));\n if (last > -1) {\n path = path.slice(last + 1);\n }\n return path\n}\n\nfunction dirname(path) {\n const last = Math.max(path.lastIndexOf('/'), path.lastIndexOf('\\\\'));\n if (last === -1) return '.'\n if (last === 0) return '/'\n return path.slice(0, last)\n}\n\n/*::\ntype Node = {\n type: string,\n fullpath: string,\n basename: string,\n metadata: Object, // mode, oid\n parent?: Node,\n children: Array<Node>\n}\n*/\n\nfunction flatFileListToDirectoryStructure(files) {\n const inodes = new Map();\n const mkdir = function(name) {\n if (!inodes.has(name)) {\n const dir = {\n type: 'tree',\n fullpath: name,\n basename: basename(name),\n metadata: {},\n children: [],\n };\n inodes.set(name, dir);\n // This recursively generates any missing parent folders.\n // We do it after we've added the inode to the set so that\n // we don't recurse infinitely trying to create the root '.' dirname.\n dir.parent = mkdir(dirname(name));\n if (dir.parent && dir.parent !== dir) dir.parent.children.push(dir);\n }\n return inodes.get(name)\n };\n\n const mkfile = function(name, metadata) {\n if (!inodes.has(name)) {\n const file = {\n type: 'blob',\n fullpath: name,\n basename: basename(name),\n metadata: metadata,\n // This recursively generates any missing parent folders.\n parent: mkdir(dirname(name)),\n children: [],\n };\n if (file.parent) file.parent.children.push(file);\n inodes.set(name, file);\n }\n return inodes.get(name)\n };\n\n mkdir('.');\n for (const file of files) {\n mkfile(file.path, file);\n }\n return inodes\n}\n\n/**\n *\n * @param {number} mode\n */\nfunction mode2type(mode) {\n // prettier-ignore\n switch (mode) {\n case 0o040000: return 'tree'\n case 0o100644: return 'blob'\n case 0o100755: return 'blob'\n case 0o120000: return 'blob'\n case 0o160000: return 'commit'\n }\n throw new InternalError(`Unexpected GitTree entry mode: ${mode.toString(8)}`)\n}\n\nclass GitWalkerIndex {\n constructor({ fs, gitdir, cache }) {\n this.treePromise = GitIndexManager.acquire(\n { fs, gitdir, cache },\n async function(index) {\n return flatFileListToDirectoryStructure(index.entries)\n }\n );\n const walker = this;\n this.ConstructEntry = class StageEntry {\n constructor(fullpath) {\n this._fullpath = fullpath;\n this._type = false;\n this._mode = false;\n this._stat = false;\n this._oid = false;\n }\n\n async type() {\n return walker.type(this)\n }\n\n async mode() {\n return walker.mode(this)\n }\n\n async stat() {\n return walker.stat(this)\n }\n\n async content() {\n return walker.content(this)\n }\n\n async oid() {\n return walker.oid(this)\n }\n };\n }\n\n async readdir(entry) {\n const filepath = entry._fullpath;\n const tree = await this.treePromise;\n const inode = tree.get(filepath);\n if (!inode) return null\n if (inode.type === 'blob') return null\n if (inode.type !== 'tree') {\n throw new Error(`ENOTDIR: not a directory, scandir '${filepath}'`)\n }\n const names = inode.children.map(inode => inode.fullpath);\n names.sort(compareStrings);\n return names\n }\n\n async type(entry) {\n if (entry._type === false) {\n await entry.stat();\n }\n return entry._type\n }\n\n async mode(entry) {\n if (entry._mode === false) {\n await entry.stat();\n }\n return entry._mode\n }\n\n async stat(entry) {\n if (entry._stat === false) {\n const tree = await this.treePromise;\n const inode = tree.get(entry._fullpath);\n if (!inode) {\n throw new Error(\n `ENOENT: no such file or directory, lstat '${entry._fullpath}'`\n )\n }\n const stats = inode.type === 'tree' ? {} : normalizeStats(inode.metadata);\n entry._type = inode.type === 'tree' ? 'tree' : mode2type(stats.mode);\n entry._mode = stats.mode;\n if (inode.type === 'tree') {\n entry._stat = undefined;\n } else {\n entry._stat = stats;\n }\n }\n return entry._stat\n }\n\n async content(_entry) {\n // Cannot get content for an index entry\n }\n\n async oid(entry) {\n if (entry._oid === false) {\n const tree = await this.treePromise;\n const inode = tree.get(entry._fullpath);\n entry._oid = inode.metadata.oid;\n }\n return entry._oid\n }\n}\n\n// This is part of an elaborate system to facilitate code-splitting / tree-shaking.\n// commands/walk.js can depend on only this, and the actual Walker classes exported\n// can be opaque - only having a single property (this symbol) that is not enumerable,\n// and thus the constructor can be passed as an argument to walk while being \"unusable\"\n// outside of it.\nconst GitWalkSymbol = Symbol('GitWalkSymbol');\n\n// @ts-check\n\n/**\n * @returns {Walker}\n */\nfunction STAGE() {\n const o = Object.create(null);\n Object.defineProperty(o, GitWalkSymbol, {\n value: function({ fs, gitdir, cache }) {\n return new GitWalkerIndex({ fs, gitdir, cache })\n },\n });\n Object.freeze(o);\n return o\n}\n\n// @ts-check\n\nclass NotFoundError extends BaseError {\n /**\n * @param {string} what\n */\n constructor(what) {\n super(`Could not find ${what}.`);\n this.code = this.name = NotFoundError.code;\n this.data = { what };\n }\n}\n/** @type {'NotFoundError'} */\nNotFoundError.code = 'NotFoundError';\n\nclass ObjectTypeError extends BaseError {\n /**\n * @param {string} oid\n * @param {'blob'|'commit'|'tag'|'tree'} actual\n * @param {'blob'|'commit'|'tag'|'tree'} expected\n * @param {string} [filepath]\n */\n constructor(oid, actual, expected, filepath) {\n super(\n `Object ${oid} ${\n filepath ? `at ${filepath}` : ''\n }was anticipated to be a ${expected} but it is a ${actual}.`\n );\n this.code = this.name = ObjectTypeError.code;\n this.data = { oid, actual, expected, filepath };\n }\n}\n/** @type {'ObjectTypeError'} */\nObjectTypeError.code = 'ObjectTypeError';\n\nclass InvalidOidError extends BaseError {\n /**\n * @param {string} value\n */\n constructor(value) {\n super(`Expected a 40-char hex object id but saw \"${value}\".`);\n this.code = this.name = InvalidOidError.code;\n this.data = { value };\n }\n}\n/** @type {'InvalidOidError'} */\nInvalidOidError.code = 'InvalidOidError';\n\nclass NoRefspecError extends BaseError {\n /**\n * @param {string} remote\n */\n constructor(remote) {\n super(`Could not find a fetch refspec for remote \"${remote}\". Make sure the config file has an entry like the following:\n[remote \"${remote}\"]\n\\tfetch = +refs/heads/*:refs/remotes/origin/*\n`);\n this.code = this.name = NoRefspecError.code;\n this.data = { remote };\n }\n}\n/** @type {'NoRefspecError'} */\nNoRefspecError.code = 'NoRefspecError';\n\nclass GitPackedRefs {\n constructor(text) {\n this.refs = new Map();\n this.parsedConfig = [];\n if (text) {\n let key = null;\n this.parsedConfig = text\n .trim()\n .split('\\n')\n .map(line => {\n if (/^\\s*#/.test(line)) {\n return { line, comment: true }\n }\n const i = line.indexOf(' ');\n if (line.startsWith('^')) {\n // This is a oid for the commit associated with the annotated tag immediately preceding this line.\n // Trim off the '^'\n const value = line.slice(1);\n // The tagname^{} syntax is based on the output of `git show-ref --tags -d`\n this.refs.set(key + '^{}', value);\n return { line, ref: key, peeled: value }\n } else {\n // This is an oid followed by the ref name\n const value = line.slice(0, i);\n key = line.slice(i + 1);\n this.refs.set(key, value);\n return { line, ref: key, oid: value }\n }\n });\n }\n return this\n }\n\n static from(text) {\n return new GitPackedRefs(text)\n }\n\n delete(ref) {\n this.parsedConfig = this.parsedConfig.filter(entry => entry.ref !== ref);\n this.refs.delete(ref);\n }\n\n toString() {\n return this.parsedConfig.map(({ line }) => line).join('\\n') + '\\n'\n }\n}\n\nclass GitRefSpec {\n constructor({ remotePath, localPath, force, matchPrefix }) {\n Object.assign(this, {\n remotePath,\n localPath,\n force,\n matchPrefix,\n });\n }\n\n static from(refspec) {\n const [\n forceMatch,\n remotePath,\n remoteGlobMatch,\n localPath,\n localGlobMatch,\n ] = refspec.match(/^(\\+?)(.*?)(\\*?):(.*?)(\\*?)$/).slice(1);\n const force = forceMatch === '+';\n const remoteIsGlob = remoteGlobMatch === '*';\n const localIsGlob = localGlobMatch === '*';\n // validate\n // TODO: Make this check more nuanced, and depend on whether this is a fetch refspec or a push refspec\n if (remoteIsGlob !== localIsGlob) {\n throw new InternalError('Invalid refspec')\n }\n return new GitRefSpec({\n remotePath,\n localPath,\n force,\n matchPrefix: remoteIsGlob,\n })\n // TODO: We need to run resolveRef on both paths to expand them to their full name.\n }\n\n translate(remoteBranch) {\n if (this.matchPrefix) {\n if (remoteBranch.startsWith(this.remotePath)) {\n return this.localPath + remoteBranch.replace(this.remotePath, '')\n }\n } else {\n if (remoteBranch === this.remotePath) return this.localPath\n }\n return null\n }\n\n reverseTranslate(localBranch) {\n if (this.matchPrefix) {\n if (localBranch.startsWith(this.localPath)) {\n return this.remotePath + localBranch.replace(this.localPath, '')\n }\n } else {\n if (localBranch === this.localPath) return this.remotePath\n }\n return null\n }\n}\n\nclass GitRefSpecSet {\n constructor(rules = []) {\n this.rules = rules;\n }\n\n static from(refspecs) {\n const rules = [];\n for (const refspec of refspecs) {\n rules.push(GitRefSpec.from(refspec)); // might throw\n }\n return new GitRefSpecSet(rules)\n }\n\n add(refspec) {\n const rule = GitRefSpec.from(refspec); // might throw\n this.rules.push(rule);\n }\n\n translate(remoteRefs) {\n const result = [];\n for (const rule of this.rules) {\n for (const remoteRef of remoteRefs) {\n const localRef = rule.translate(remoteRef);\n if (localRef) {\n result.push([remoteRef, localRef]);\n }\n }\n }\n return result\n }\n\n translateOne(remoteRef) {\n let result = null;\n for (const rule of this.rules) {\n const localRef = rule.translate(remoteRef);\n if (localRef) {\n result = localRef;\n }\n }\n return result\n }\n\n localNamespaces() {\n return this.rules\n .filter(rule => rule.matchPrefix)\n .map(rule => rule.localPath.replace(/\\/$/, ''))\n }\n}\n\nfunction compareRefNames(a, b) {\n // https://stackoverflow.com/a/40355107/2168416\n const _a = a.replace(/\\^\\{\\}$/, '');\n const _b = b.replace(/\\^\\{\\}$/, '');\n const tmp = -(_a < _b) || +(_a > _b);\n if (tmp === 0) {\n return a.endsWith('^{}') ? 1 : -1\n }\n return tmp\n}\n\n// This is straight from parse_unit_factor in config.c of canonical git\nconst num = val => {\n if (typeof val === 'number') {\n return val\n }\n\n val = val.toLowerCase();\n let n = parseInt(val);\n if (val.endsWith('k')) n *= 1024;\n if (val.endsWith('m')) n *= 1024 * 1024;\n if (val.endsWith('g')) n *= 1024 * 1024 * 1024;\n return n\n};\n\n// This is straight from git_parse_maybe_bool_text in config.c of canonical git\nconst bool = val => {\n if (typeof val === 'boolean') {\n return val\n }\n\n val = val.trim().toLowerCase();\n if (val === 'true' || val === 'yes' || val === 'on') return true\n if (val === 'false' || val === 'no' || val === 'off') return false\n throw Error(\n `Expected 'true', 'false', 'yes', 'no', 'on', or 'off', but got ${val}`\n )\n};\n\nconst schema = {\n core: {\n filemode: bool,\n bare: bool,\n logallrefupdates: bool,\n symlinks: bool,\n ignorecase: bool,\n bigFileThreshold: num,\n },\n};\n\n// https://git-scm.com/docs/git-config#_syntax\n\n// section starts with [ and ends with ]\n// section is alphanumeric (ASCII) with - and .\n// section is case insensitive\n// subsection is optional\n// subsection is specified after section and one or more spaces\n// subsection is specified between double quotes\nconst SECTION_LINE_REGEX = /^\\[([A-Za-z0-9-.]+)(?: \"(.*)\")?\\]$/;\nconst SECTION_REGEX = /^[A-Za-z0-9-.]+$/;\n\n// variable lines contain a name, and equal sign and then a value\n// variable lines can also only contain a name (the implicit value is a boolean true)\n// variable name is alphanumeric (ASCII) with -\n// variable name starts with an alphabetic character\n// variable name is case insensitive\nconst VARIABLE_LINE_REGEX = /^([A-Za-z][A-Za-z-]*)(?: *= *(.*))?$/;\nconst VARIABLE_NAME_REGEX = /^[A-Za-z][A-Za-z-]*$/;\n\n// Comments start with either # or ; and extend to the end of line\nconst VARIABLE_VALUE_COMMENT_REGEX = /^(.*?)( *[#;].*)$/;\n\nconst extractSectionLine = line => {\n const matches = SECTION_LINE_REGEX.exec(line);\n if (matches != null) {\n const [section, subsection] = matches.slice(1);\n return [section, subsection]\n }\n return null\n};\n\nconst extractVariableLine = line => {\n const matches = VARIABLE_LINE_REGEX.exec(line);\n if (matches != null) {\n const [name, rawValue = 'true'] = matches.slice(1);\n const valueWithoutComments = removeComments(rawValue);\n const valueWithoutQuotes = removeQuotes(valueWithoutComments);\n return [name, valueWithoutQuotes]\n }\n return null\n};\n\nconst removeComments = rawValue => {\n const commentMatches = VARIABLE_VALUE_COMMENT_REGEX.exec(rawValue);\n if (commentMatches == null) {\n return rawValue\n }\n const [valueWithoutComment, comment] = commentMatches.slice(1);\n // if odd number of quotes before and after comment => comment is escaped\n if (\n hasOddNumberOfQuotes(valueWithoutComment) &&\n hasOddNumberOfQuotes(comment)\n ) {\n return `${valueWithoutComment}${comment}`\n }\n return valueWithoutComment\n};\n\nconst hasOddNumberOfQuotes = text => {\n const numberOfQuotes = (text.match(/(?:^|[^\\\\])\"/g) || []).length;\n return numberOfQuotes % 2 !== 0\n};\n\nconst removeQuotes = text => {\n return text.split('').reduce((newText, c, idx, text) => {\n const isQuote = c === '\"' && text[idx - 1] !== '\\\\';\n const isEscapeForQuote = c === '\\\\' && text[idx + 1] === '\"';\n if (isQuote || isEscapeForQuote) {\n return newText\n }\n return newText + c\n }, '')\n};\n\nconst lower = text => {\n return text != null ? text.toLowerCase() : null\n};\n\nconst getPath = (section, subsection, name) => {\n return [lower(section), subsection, lower(name)]\n .filter(a => a != null)\n .join('.')\n};\n\nconst normalizePath = path => {\n const pathSegments = path.split('.');\n const section = pathSegments.shift();\n const name = pathSegments.pop();\n const subsection = pathSegments.length ? pathSegments.join('.') : undefined;\n\n return {\n section,\n subsection,\n name,\n path: getPath(section, subsection, name),\n sectionPath: getPath(section, subsection, null),\n isSection: !!section,\n }\n};\n\nconst findLastIndex = (array, callback) => {\n return array.reduce((lastIndex, item, index) => {\n return callback(item) ? index : lastIndex\n }, -1)\n};\n\n// Note: there are a LOT of edge cases that aren't covered (e.g. keys in sections that also\n// have subsections, [include] directives, etc.\nclass GitConfig {\n constructor(text) {\n let section = null;\n let subsection = null;\n this.parsedConfig = text\n ? text.split('\\n').map(line => {\n let name = null;\n let value = null;\n\n const trimmedLine = line.trim();\n const extractedSection = extractSectionLine(trimmedLine);\n const isSection = extractedSection != null;\n if (isSection) {\n ;[section, subsection] = extractedSection;\n } else {\n const extractedVariable = extractVariableLine(trimmedLine);\n const isVariable = extractedVariable != null;\n if (isVariable) {\n ;[name, value] = extractedVariable;\n }\n }\n\n const path = getPath(section, subsection, name);\n return { line, isSection, section, subsection, name, value, path }\n })\n : [];\n }\n\n static from(text) {\n return new GitConfig(text)\n }\n\n async get(path, getall = false) {\n const normalizedPath = normalizePath(path).path;\n const allValues = this.parsedConfig\n .filter(config => config.path === normalizedPath)\n .map(({ section, name, value }) => {\n const fn = schema[section] && schema[section][name];\n return fn ? fn(value) : value\n });\n return getall ? allValues : allValues.pop()\n }\n\n async getall(path) {\n return this.get(path, true)\n }\n\n async getSubsections(section) {\n return this.parsedConfig\n .filter(config => config.isSection && config.section === section)\n .map(config => config.subsection)\n }\n\n async deleteSection(section, subsection) {\n this.parsedConfig = this.parsedConfig.filter(\n config =>\n !(config.section === section && config.subsection === subsection)\n );\n }\n\n async append(path, value) {\n return this.set(path, value, true)\n }\n\n async set(path, value, append = false) {\n const {\n section,\n subsection,\n name,\n path: normalizedPath,\n sectionPath,\n isSection,\n } = normalizePath(path);\n\n const configIndex = findLastIndex(\n this.parsedConfig,\n config => config.path === normalizedPath\n );\n if (value == null) {\n if (configIndex !== -1) {\n this.parsedConfig.splice(configIndex, 1);\n }\n } else {\n if (configIndex !== -1) {\n const config = this.parsedConfig[configIndex];\n // Name should be overwritten in case the casing changed\n const modifiedConfig = Object.assign({}, config, {\n name,\n value,\n modified: true,\n });\n if (append) {\n this.parsedConfig.splice(configIndex + 1, 0, modifiedConfig);\n } else {\n this.parsedConfig[configIndex] = modifiedConfig;\n }\n } else {\n const sectionIndex = this.parsedConfig.findIndex(\n config => config.path === sectionPath\n );\n const newConfig = {\n section,\n subsection,\n name,\n value,\n modified: true,\n path: normalizedPath,\n };\n if (SECTION_REGEX.test(section) && VARIABLE_NAME_REGEX.test(name)) {\n if (sectionIndex >= 0) {\n // Reuse existing section\n this.parsedConfig.splice(sectionIndex + 1, 0, newConfig);\n } else {\n // Add a new section\n const newSection = {\n isSection,\n section,\n subsection,\n modified: true,\n path: sectionPath,\n };\n this.parsedConfig.push(newSection, newConfig);\n }\n }\n }\n }\n }\n\n toString() {\n return this.parsedConfig\n .map(({ line, section, subsection, name, value, modified = false }) => {\n if (!modified) {\n return line\n }\n if (name != null && value != null) {\n if (typeof value === 'string' && /[#;]/.test(value)) {\n // A `#` or `;` symbol denotes a comment, so we have to wrap it in double quotes\n return `\\t${name} = \"${value}\"`\n }\n return `\\t${name} = ${value}`\n }\n if (subsection != null) {\n return `[${section} \"${subsection}\"]`\n }\n return `[${section}]`\n })\n .join('\\n')\n }\n}\n\nclass GitConfigManager {\n static async get({ fs, gitdir }) {\n // We can improve efficiency later if needed.\n // TODO: read from full list of git config files\n const text = await fs.read(`${gitdir}/config`, { encoding: 'utf8' });\n return GitConfig.from(text)\n }\n\n static async save({ fs, gitdir, config }) {\n // We can improve efficiency later if needed.\n // TODO: handle saving to the correct global/user/repo location\n await fs.write(`${gitdir}/config`, config.toString(), {\n encoding: 'utf8',\n });\n }\n}\n\n// This is a convenience wrapper for reading and writing files in the 'refs' directory.\n\n// @see https://git-scm.com/docs/git-rev-parse.html#_specifying_revisions\nconst refpaths = ref => [\n `${ref}`,\n `refs/${ref}`,\n `refs/tags/${ref}`,\n `refs/heads/${ref}`,\n `refs/remotes/${ref}`,\n `refs/remotes/${ref}/HEAD`,\n];\n\n// @see https://git-scm.com/docs/gitrepository-layout\nconst GIT_FILES = ['config', 'description', 'index', 'shallow', 'commondir'];\n\nlet lock$1;\n\nasync function acquireLock(ref, callback) {\n if (lock$1 === undefined) lock$1 = new AsyncLock();\n return lock$1.acquire(ref, callback)\n}\n\nclass GitRefManager {\n static async updateRemoteRefs({\n fs,\n gitdir,\n remote,\n refs,\n symrefs,\n tags,\n refspecs = undefined,\n prune = false,\n pruneTags = false,\n }) {\n // Validate input\n for (const value of refs.values()) {\n if (!value.match(/[0-9a-f]{40}/)) {\n throw new InvalidOidError(value)\n }\n }\n const config = await GitConfigManager.get({ fs, gitdir });\n if (!refspecs) {\n refspecs = await config.getall(`remote.${remote}.fetch`);\n if (refspecs.length === 0) {\n throw new NoRefspecError(remote)\n }\n // There's some interesting behavior with HEAD that doesn't follow the refspec.\n refspecs.unshift(`+HEAD:refs/remotes/${remote}/HEAD`);\n }\n const refspec = GitRefSpecSet.from(refspecs);\n const actualRefsToWrite = new Map();\n // Delete all current tags if the pruneTags argument is true.\n if (pruneTags) {\n const tags = await GitRefManager.listRefs({\n fs,\n gitdir,\n filepath: 'refs/tags',\n });\n await GitRefManager.deleteRefs({\n fs,\n gitdir,\n refs: tags.map(tag => `refs/tags/${tag}`),\n });\n }\n // Add all tags if the fetch tags argument is true.\n if (tags) {\n for (const serverRef of refs.keys()) {\n if (serverRef.startsWith('refs/tags') && !serverRef.endsWith('^{}')) {\n // Git's behavior is to only fetch tags that do not conflict with tags already present.\n if (!(await GitRefManager.exists({ fs, gitdir, ref: serverRef }))) {\n // Always use the object id of the tag itself, and not the peeled object id.\n const oid = refs.get(serverRef);\n actualRefsToWrite.set(serverRef, oid);\n }\n }\n }\n }\n // Combine refs and symrefs giving symrefs priority\n const refTranslations = refspec.translate([...refs.keys()]);\n for (const [serverRef, translatedRef] of refTranslations) {\n const value = refs.get(serverRef);\n actualRefsToWrite.set(translatedRef, value);\n }\n const symrefTranslations = refspec.translate([...symrefs.keys()]);\n for (const [serverRef, translatedRef] of symrefTranslations) {\n const value = symrefs.get(serverRef);\n const symtarget = refspec.translateOne(value);\n if (symtarget) {\n actualRefsToWrite.set(translatedRef, `ref: ${symtarget}`);\n }\n }\n // If `prune` argument is true, clear out the existing local refspec roots\n const pruned = [];\n if (prune) {\n for (const filepath of refspec.localNamespaces()) {\n const refs = (\n await GitRefManager.listRefs({\n fs,\n gitdir,\n filepath,\n })\n ).map(file => `${filepath}/${file}`);\n for (const ref of refs) {\n if (!actualRefsToWrite.has(ref)) {\n pruned.push(ref);\n }\n }\n }\n if (pruned.length > 0) {\n await GitRefManager.deleteRefs({ fs, gitdir, refs: pruned });\n }\n }\n // Update files\n // TODO: For large repos with a history of thousands of pull requests\n // (i.e. gitlab-ce) it would be vastly more efficient to write them\n // to .git/packed-refs.\n // The trick is to make sure we a) don't write a packed ref that is\n // already shadowed by a loose ref and b) don't loose any refs already\n // in packed-refs. Doing this efficiently may be difficult. A\n // solution that might work is\n // a) load the current packed-refs file\n // b) add actualRefsToWrite, overriding the existing values if present\n // c) enumerate all the loose refs currently in .git/refs/remotes/${remote}\n // d) overwrite their value with the new value.\n // Examples of refs we need to avoid writing in loose format for efficieny's sake\n // are .git/refs/remotes/origin/refs/remotes/remote_mirror_3059\n // and .git/refs/remotes/origin/refs/merge-requests\n for (const [key, value] of actualRefsToWrite) {\n await acquireLock(key, async () =>\n fs.write(join(gitdir, key), `${value.trim()}\\n`, 'utf8')\n );\n }\n return { pruned }\n }\n\n // TODO: make this less crude?\n static async writeRef({ fs, gitdir, ref, value }) {\n // Validate input\n if (!value.match(/[0-9a-f]{40}/)) {\n throw new InvalidOidError(value)\n }\n await acquireLock(ref, async () =>\n fs.write(join(gitdir, ref), `${value.trim()}\\n`, 'utf8')\n );\n }\n\n static async writeSymbolicRef({ fs, gitdir, ref, value }) {\n await acquireLock(ref, async () =>\n fs.write(join(gitdir, ref), 'ref: ' + `${value.trim()}\\n`, 'utf8')\n );\n }\n\n static async deleteRef({ fs, gitdir, ref }) {\n return GitRefManager.deleteRefs({ fs, gitdir, refs: [ref] })\n }\n\n static async deleteRefs({ fs, gitdir, refs }) {\n // Delete regular ref\n await Promise.all(refs.map(ref => fs.rm(join(gitdir, ref))));\n // Delete any packed ref\n let text = await acquireLock('packed-refs', async () =>\n fs.read(`${gitdir}/packed-refs`, { encoding: 'utf8' })\n );\n const packed = GitPackedRefs.from(text);\n const beforeSize = packed.refs.size;\n for (const ref of refs) {\n if (packed.refs.has(ref)) {\n packed.delete(ref);\n }\n }\n if (packed.refs.size < beforeSize) {\n text = packed.toString();\n await acquireLock('packed-refs', async () =>\n fs.write(`${gitdir}/packed-refs`, text, { encoding: 'utf8' })\n );\n }\n }\n\n /**\n * @param {object} args\n * @param {import('../models/FileSystem.js').FileSystem} args.fs\n * @param {string} args.gitdir\n * @param {string} args.ref\n * @param {number} [args.depth]\n * @returns {Promise<string>}\n */\n static async resolve({ fs, gitdir, ref, depth = undefined }) {\n if (depth !== undefined) {\n depth--;\n if (depth === -1) {\n return ref\n }\n }\n\n // Is it a ref pointer?\n if (ref.startsWith('ref: ')) {\n ref = ref.slice('ref: '.length);\n return GitRefManager.resolve({ fs, gitdir, ref, depth })\n }\n // Is it a complete and valid SHA?\n if (ref.length === 40 && /[0-9a-f]{40}/.test(ref)) {\n return ref\n }\n // We need to alternate between the file system and the packed-refs\n const packedMap = await GitRefManager.packedRefs({ fs, gitdir });\n // Look in all the proper paths, in this order\n const allpaths = refpaths(ref).filter(p => !GIT_FILES.includes(p)); // exclude git system files (#709)\n\n for (const ref of allpaths) {\n const sha = await acquireLock(\n ref,\n async () =>\n (await fs.read(`${gitdir}/${ref}`, { encoding: 'utf8' })) ||\n packedMap.get(ref)\n );\n if (sha) {\n return GitRefManager.resolve({ fs, gitdir, ref: sha.trim(), depth })\n }\n }\n // Do we give up?\n throw new NotFoundError(ref)\n }\n\n static async exists({ fs, gitdir, ref }) {\n try {\n await GitRefManager.expand({ fs, gitdir, ref });\n return true\n } catch (err) {\n return false\n }\n }\n\n static async expand({ fs, gitdir, ref }) {\n // Is it a complete and valid SHA?\n if (ref.length === 40 && /[0-9a-f]{40}/.test(ref)) {\n return ref\n }\n // We need to alternate between the file system and the packed-refs\n const packedMap = await GitRefManager.packedRefs({ fs, gitdir });\n // Look in all the proper paths, in this order\n const allpaths = refpaths(ref);\n for (const ref of allpaths) {\n const refExists = await acquireLock(ref, async () =>\n fs.exists(`${gitdir}/${ref}`)\n );\n if (refExists) return ref\n if (packedMap.has(ref)) return ref\n }\n // Do we give up?\n throw new NotFoundError(ref)\n }\n\n static async expandAgainstMap({ ref, map }) {\n // Look in all the proper paths, in this order\n const allpaths = refpaths(ref);\n for (const ref of allpaths) {\n if (await map.has(ref)) return ref\n }\n // Do we give up?\n throw new NotFoundError(ref)\n }\n\n static resolveAgainstMap({ ref, fullref = ref, depth = undefined, map }) {\n if (depth !== undefined) {\n depth--;\n if (depth === -1) {\n return { fullref, oid: ref }\n }\n }\n // Is it a ref pointer?\n if (ref.startsWith('ref: ')) {\n ref = ref.slice('ref: '.length);\n return GitRefManager.resolveAgainstMap({ ref, fullref, depth, map })\n }\n // Is it a complete and valid SHA?\n if (ref.length === 40 && /[0-9a-f]{40}/.test(ref)) {\n return { fullref, oid: ref }\n }\n // Look in all the proper paths, in this order\n const allpaths = refpaths(ref);\n for (const ref of allpaths) {\n const sha = map.get(ref);\n if (sha) {\n return GitRefManager.resolveAgainstMap({\n ref: sha.trim(),\n fullref: ref,\n depth,\n map,\n })\n }\n }\n // Do we give up?\n throw new NotFoundError(ref)\n }\n\n static async packedRefs({ fs, gitdir }) {\n const text = await acquireLock('packed-refs', async () =>\n fs.read(`${gitdir}/packed-refs`, { encoding: 'utf8' })\n );\n const packed = GitPackedRefs.from(text);\n return packed.refs\n }\n\n // List all the refs that match the `filepath` prefix\n static async listRefs({ fs, gitdir, filepath }) {\n const packedMap = GitRefManager.packedRefs({ fs, gitdir });\n let files = null;\n try {\n files = await fs.readdirDeep(`${gitdir}/${filepath}`);\n files = files.map(x => x.replace(`${gitdir}/${filepath}/`, ''));\n } catch (err) {\n files = [];\n }\n\n for (let key of (await packedMap).keys()) {\n // filter by prefix\n if (key.startsWith(filepath)) {\n // remove prefix\n key = key.replace(filepath + '/', '');\n // Don't include duplicates; the loose files have precedence anyway\n if (!files.includes(key)) {\n files.push(key);\n }\n }\n }\n // since we just appended things onto an array, we need to sort them now\n files.sort(compareRefNames);\n return files\n }\n\n static async listBranches({ fs, gitdir, remote }) {\n if (remote) {\n return GitRefManager.listRefs({\n fs,\n gitdir,\n filepath: `refs/remotes/${remote}`,\n })\n } else {\n return GitRefManager.listRefs({ fs, gitdir, filepath: `refs/heads` })\n }\n }\n\n static async listTags({ fs, gitdir }) {\n const tags = await GitRefManager.listRefs({\n fs,\n gitdir,\n filepath: `refs/tags`,\n });\n return tags.filter(x => !x.endsWith('^{}'))\n }\n}\n\nfunction compareTreeEntryPath(a, b) {\n // Git sorts tree entries as if there is a trailing slash on directory names.\n return compareStrings(appendSlashIfDir(a), appendSlashIfDir(b))\n}\n\nfunction appendSlashIfDir(entry) {\n return entry.mode === '040000' ? entry.path + '/' : entry.path\n}\n\n/**\n *\n * @typedef {Object} TreeEntry\n * @property {string} mode - the 6 digit hexadecimal mode\n * @property {string} path - the name of the file or directory\n * @property {string} oid - the SHA-1 object id of the blob or tree\n * @property {'commit'|'blob'|'tree'} type - the type of object\n */\n\nfunction mode2type$1(mode) {\n // prettier-ignore\n switch (mode) {\n case '040000': return 'tree'\n case '100644': return 'blob'\n case '100755': return 'blob'\n case '120000': return 'blob'\n case '160000': return 'commit'\n }\n throw new InternalError(`Unexpected GitTree entry mode: ${mode}`)\n}\n\nfunction parseBuffer(buffer) {\n const _entries = [];\n let cursor = 0;\n while (cursor < buffer.length) {\n const space = buffer.indexOf(32, cursor);\n if (space === -1) {\n throw new InternalError(\n `GitTree: Error parsing buffer at byte location ${cursor}: Could not find the next space character.`\n )\n }\n const nullchar = buffer.indexOf(0, cursor);\n if (nullchar === -1) {\n throw new InternalError(\n `GitTree: Error parsing buffer at byte location ${cursor}: Could not find the next null character.`\n )\n }\n let mode = buffer.slice(cursor, space).toString('utf8');\n if (mode === '40000') mode = '040000'; // makes it line up neater in printed output\n const type = mode2type$1(mode);\n const path = buffer.slice(space + 1, nullchar).toString('utf8');\n\n // Prevent malicious git repos from writing to \"..\\foo\" on clone etc\n if (path.includes('\\\\') || path.includes('/')) {\n throw new UnsafeFilepathError(path)\n }\n\n const oid = buffer.slice(nullchar + 1, nullchar + 21).toString('hex');\n cursor = nullchar + 21;\n _entries.push({ mode, path, oid, type });\n }\n return _entries\n}\n\nfunction limitModeToAllowed(mode) {\n if (typeof mode === 'number') {\n mode = mode.toString(8);\n }\n // tree\n if (mode.match(/^0?4.*/)) return '040000' // Directory\n if (mode.match(/^1006.*/)) return '100644' // Regular non-executable file\n if (mode.match(/^1007.*/)) return '100755' // Regular executable file\n if (mode.match(/^120.*/)) return '120000' // Symbolic link\n if (mode.match(/^160.*/)) return '160000' // Commit (git submodule reference)\n throw new InternalError(`Could not understand file mode: ${mode}`)\n}\n\nfunction nudgeIntoShape(entry) {\n if (!entry.oid && entry.sha) {\n entry.oid = entry.sha; // Github\n }\n entry.mode = limitModeToAllowed(entry.mode); // index\n if (!entry.type) {\n entry.type = mode2type$1(entry.mode); // index\n }\n return entry\n}\n\nclass GitTree {\n constructor(entries) {\n if (Buffer.isBuffer(entries)) {\n this._entries = parseBuffer(entries);\n } else if (Array.isArray(entries)) {\n this._entries = entries.map(nudgeIntoShape);\n } else {\n throw new InternalError('invalid type passed to GitTree constructor')\n }\n // Tree entries are not sorted alphabetically in the usual sense (see `compareTreeEntryPath`)\n // but it is important later on that these be sorted in the same order as they would be returned from readdir.\n this._entries.sort(comparePath);\n }\n\n static from(tree) {\n return new GitTree(tree)\n }\n\n render() {\n return this._entries\n .map(entry => `${entry.mode} ${entry.type} ${entry.oid} ${entry.path}`)\n .join('\\n')\n }\n\n toObject() {\n // Adjust the sort order to match git's\n const entries = [...this._entries];\n entries.sort(compareTreeEntryPath);\n return Buffer.concat(\n entries.map(entry => {\n const mode = Buffer.from(entry.mode.replace(/^0/, ''));\n const space = Buffer.from(' ');\n const path = Buffer.from(entry.path, 'utf8');\n const nullchar = Buffer.from([0]);\n const oid = Buffer.from(entry.oid, 'hex');\n return Buffer.concat([mode, space, path, nullchar, oid])\n })\n )\n }\n\n /**\n * @returns {TreeEntry[]}\n */\n entries() {\n return this._entries\n }\n\n *[Symbol.iterator]() {\n for (const entry of this._entries) {\n yield entry;\n }\n }\n}\n\nclass GitObject {\n static wrap({ type, object }) {\n return Buffer.concat([\n Buffer.from(`${type} ${object.byteLength.toString()}\\x00`),\n Buffer.from(object),\n ])\n }\n\n static unwrap(buffer) {\n const s = buffer.indexOf(32); // first space\n const i = buffer.indexOf(0); // first null value\n const type = buffer.slice(0, s).toString('utf8'); // get type of object\n const length = buffer.slice(s + 1, i).toString('utf8'); // get type of object\n const actualLength = buffer.length - (i + 1);\n // verify length\n if (parseInt(length) !== actualLength) {\n throw new InternalError(\n `Length mismatch: expected ${length} bytes but got ${actualLength} instead.`\n )\n }\n return {\n type,\n object: Buffer.from(buffer.slice(i + 1)),\n }\n }\n}\n\nasync function readObjectLoose({ fs, gitdir, oid }) {\n const source = `objects/${oid.slice(0, 2)}/${oid.slice(2)}`;\n const file = await fs.read(`${gitdir}/${source}`);\n if (!file) {\n return null\n }\n return { object: file, format: 'deflated', source }\n}\n\n/**\n * @param {Buffer} delta\n * @param {Buffer} source\n * @returns {Buffer}\n */\nfunction applyDelta(delta, source) {\n const reader = new BufferCursor(delta);\n const sourceSize = readVarIntLE(reader);\n\n if (sourceSize !== source.byteLength) {\n throw new InternalError(\n `applyDelta expected source buffer to be ${sourceSize} bytes but the provided buffer was ${source.length} bytes`\n )\n }\n const targetSize = readVarIntLE(reader);\n let target;\n\n const firstOp = readOp(reader, source);\n // Speed optimization - return raw buffer if it's just single simple copy\n if (firstOp.byteLength === targetSize) {\n target = firstOp;\n } else {\n // Otherwise, allocate a fresh buffer and slices\n target = Buffer.alloc(targetSize);\n const writer = new BufferCursor(target);\n writer.copy(firstOp);\n\n while (!reader.eof()) {\n writer.copy(readOp(reader, source));\n }\n\n const tell = writer.tell();\n if (targetSize !== tell) {\n throw new InternalError(\n `applyDelta expected target buffer to be ${targetSize} bytes but the resulting buffer was ${tell} bytes`\n )\n }\n }\n return target\n}\n\nfunction readVarIntLE(reader) {\n let result = 0;\n let shift = 0;\n let byte = null;\n do {\n byte = reader.readUInt8();\n result |= (byte & 0b01111111) << shift;\n shift += 7;\n } while (byte & 0b10000000)\n return result\n}\n\nfunction readCompactLE(reader, flags, size) {\n let result = 0;\n let shift = 0;\n while (size--) {\n if (flags & 0b00000001) {\n result |= reader.readUInt8() << shift;\n }\n flags >>= 1;\n shift += 8;\n }\n return result\n}\n\nfunction readOp(reader, source) {\n /** @type {number} */\n const byte = reader.readUInt8();\n const COPY = 0b10000000;\n const OFFS = 0b00001111;\n const SIZE = 0b01110000;\n if (byte & COPY) {\n // copy consists of 4 byte offset, 3 byte size (in LE order)\n const offset = readCompactLE(reader, byte & OFFS, 4);\n let size = readCompactLE(reader, (byte & SIZE) >> 4, 3);\n // Yup. They really did this optimization.\n if (size === 0) size = 0x10000;\n return source.slice(offset, offset + size)\n } else {\n // insert\n return reader.slice(byte)\n }\n}\n\n// Convert a value to an Async Iterator\n// This will be easier with async generator functions.\nfunction fromValue(value) {\n let queue = [value];\n return {\n next() {\n return Promise.resolve({ done: queue.length === 0, value: queue.pop() })\n },\n return() {\n queue = [];\n return {}\n },\n [Symbol.asyncIterator]() {\n return this\n },\n }\n}\n\nfunction getIterator(iterable) {\n if (iterable[Symbol.asyncIterator]) {\n return iterable[Symbol.asyncIterator]()\n }\n if (iterable[Symbol.iterator]) {\n return iterable[Symbol.iterator]()\n }\n if (iterable.next) {\n return iterable\n }\n return fromValue(iterable)\n}\n\n// inspired by 'gartal' but lighter-weight and more battle-tested.\nclass StreamReader {\n constructor(stream) {\n // TODO: fix usage in bundlers before Buffer dependency is removed #1855\n if (typeof Buffer === 'undefined') {\n throw new Error('Missing Buffer dependency')\n }\n this.stream = getIterator(stream);\n this.buffer = null;\n this.cursor = 0;\n this.undoCursor = 0;\n this.started = false;\n this._ended = false;\n this._discardedBytes = 0;\n }\n\n eof() {\n return this._ended && this.cursor === this.buffer.length\n }\n\n tell() {\n return this._discardedBytes + this.cursor\n }\n\n async byte() {\n if (this.eof()) return\n if (!this.started) await this._init();\n if (this.cursor === this.buffer.length) {\n await this._loadnext();\n if (this._ended) return\n }\n this._moveCursor(1);\n return this.buffer[this.undoCursor]\n }\n\n async chunk() {\n if (this.eof()) return\n if (!this.started) await this._init();\n if (this.cursor === this.buffer.length) {\n await this._loadnext();\n if (this._ended) return\n }\n this._moveCursor(this.buffer.length);\n return this.buffer.slice(this.undoCursor, this.cursor)\n }\n\n async read(n) {\n if (this.eof()) return\n if (!this.started) await this._init();\n if (this.cursor + n > this.buffer.length) {\n this._trim();\n await this._accumulate(n);\n }\n this._moveCursor(n);\n return this.buffer.slice(this.undoCursor, this.cursor)\n }\n\n async skip(n) {\n if (this.eof()) return\n if (!this.started) await this._init();\n if (this.cursor + n > this.buffer.length) {\n this._trim();\n await this._accumulate(n);\n }\n this._moveCursor(n);\n }\n\n async undo() {\n this.cursor = this.undoCursor;\n }\n\n async _next() {\n this.started = true;\n let { done, value } = await this.stream.next();\n if (done) {\n this._ended = true;\n if (!value) return Buffer.alloc(0)\n }\n if (value) {\n value = Buffer.from(value);\n }\n return value\n }\n\n _trim() {\n // Throw away parts of the buffer we don't need anymore\n // assert(this.cursor <= this.buffer.length)\n this.buffer = this.buffer.slice(this.undoCursor);\n this.cursor -= this.undoCursor;\n this._discardedBytes += this.undoCursor;\n this.undoCursor = 0;\n }\n\n _moveCursor(n) {\n this.undoCursor = this.cursor;\n this.cursor += n;\n if (this.cursor > this.buffer.length) {\n this.cursor = this.buffer.length;\n }\n }\n\n async _accumulate(n) {\n if (this._ended) return\n // Expand the buffer until we have N bytes of data\n // or we've reached the end of the stream\n const buffers = [this.buffer];\n while (this.cursor + n > lengthBuffers(buffers)) {\n const nextbuffer = await this._next();\n if (this._ended) break\n buffers.push(nextbuffer);\n }\n this.buffer = Buffer.concat(buffers);\n }\n\n async _loadnext() {\n this._discardedBytes += this.buffer.length;\n this.undoCursor = 0;\n this.cursor = 0;\n this.buffer = await this._next();\n }\n\n async _init() {\n this.buffer = await this._next();\n }\n}\n\n// This helper function helps us postpone concatenating buffers, which\n// would create intermediate buffer objects,\nfunction lengthBuffers(buffers) {\n return buffers.reduce((acc, buffer) => acc + buffer.length, 0)\n}\n\n// My version of git-list-pack - roughly 15x faster than the original\n\nasync function listpack(stream, onData) {\n const reader = new StreamReader(stream);\n let PACK = await reader.read(4);\n PACK = PACK.toString('utf8');\n if (PACK !== 'PACK') {\n throw new InternalError(`Invalid PACK header '${PACK}'`)\n }\n\n let version = await reader.read(4);\n version = version.readUInt32BE(0);\n if (version !== 2) {\n throw new InternalError(`Invalid packfile version: ${version}`)\n }\n\n let numObjects = await reader.read(4);\n numObjects = numObjects.readUInt32BE(0);\n // If (for some godforsaken reason) this is an empty packfile, abort now.\n if (numObjects < 1) return\n\n while (!reader.eof() && numObjects--) {\n const offset = reader.tell();\n const { type, length, ofs, reference } = await parseHeader(reader);\n const inflator = new pako.Inflate();\n while (!inflator.result) {\n const chunk = await reader.chunk();\n if (!chunk) break\n inflator.push(chunk, false);\n if (inflator.err) {\n throw new InternalError(`Pako error: ${inflator.msg}`)\n }\n if (inflator.result) {\n if (inflator.result.length !== length) {\n throw new InternalError(\n `Inflated object size is different from that stated in packfile.`\n )\n }\n\n // Backtrack parser to where deflated data ends\n await reader.undo();\n await reader.read(chunk.length - inflator.strm.avail_in);\n const end = reader.tell();\n await onData({\n data: inflator.result,\n type,\n num: numObjects,\n offset,\n end,\n reference,\n ofs,\n });\n }\n }\n }\n}\n\nasync function parseHeader(reader) {\n // Object type is encoded in bits 654\n let byte = await reader.byte();\n const type = (byte >> 4) & 0b111;\n // The length encoding get complicated.\n // Last four bits of length is encoded in bits 3210\n let length = byte & 0b1111;\n // Whether the next byte is part of the variable-length encoded number\n // is encoded in bit 7\n if (byte & 0b10000000) {\n let shift = 4;\n do {\n byte = await reader.byte();\n length |= (byte & 0b01111111) << shift;\n shift += 7;\n } while (byte & 0b10000000)\n }\n // Handle deltified objects\n let ofs;\n let reference;\n if (type === 6) {\n let shift = 0;\n ofs = 0;\n const bytes = [];\n do {\n byte = await reader.byte();\n ofs |= (byte & 0b01111111) << shift;\n shift += 7;\n bytes.push(byte);\n } while (byte & 0b10000000)\n reference = Buffer.from(bytes);\n }\n if (type === 7) {\n const buf = await reader.read(20);\n reference = buf;\n }\n return { type, length, ofs, reference }\n}\n\n/* eslint-env node, browser */\n\nlet supportsDecompressionStream = false;\n\nasync function inflate(buffer) {\n if (supportsDecompressionStream === null) {\n supportsDecompressionStream = testDecompressionStream();\n }\n return supportsDecompressionStream\n ? browserInflate(buffer)\n : pako.inflate(buffer)\n}\n\nasync function browserInflate(buffer) {\n const ds = new DecompressionStream('deflate');\n const d = new Blob([buffer]).stream().pipeThrough(ds);\n return new Uint8Array(await new Response(d).arrayBuffer())\n}\n\nfunction testDecompressionStream() {\n try {\n const ds = new DecompressionStream('deflate');\n if (ds) return true\n } catch (_) {\n // no bother\n }\n return false\n}\n\nfunction decodeVarInt(reader) {\n const bytes = [];\n let byte = 0;\n let multibyte = 0;\n do {\n byte = reader.readUInt8();\n // We keep bits 6543210\n const lastSeven = byte & 0b01111111;\n bytes.push(lastSeven);\n // Whether the next byte is part of the variable-length encoded number\n // is encoded in bit 7\n multibyte = byte & 0b10000000;\n } while (multibyte)\n // Now that all the bytes are in big-endian order,\n // alternate shifting the bits left by 7 and OR-ing the next byte.\n // And... do a weird increment-by-one thing that I don't quite understand.\n return bytes.reduce((a, b) => ((a + 1) << 7) | b, -1)\n}\n\n// I'm pretty much copying this one from the git C source code,\n// because it makes no sense.\nfunction otherVarIntDecode(reader, startWith) {\n let result = startWith;\n let shift = 4;\n let byte = null;\n do {\n byte = reader.readUInt8();\n result |= (byte & 0b01111111) << shift;\n shift += 7;\n } while (byte & 0b10000000)\n return result\n}\n\nclass GitPackIndex {\n constructor(stuff) {\n Object.assign(this, stuff);\n this.offsetCache = {};\n }\n\n static async fromIdx({ idx, getExternalRefDelta }) {\n const reader = new BufferCursor(idx);\n const magic = reader.slice(4).toString('hex');\n // Check for IDX v2 magic number\n if (magic !== 'ff744f63') {\n return // undefined\n }\n const version = reader.readUInt32BE();\n if (version !== 2) {\n throw new InternalError(\n `Unable to read version ${version} packfile IDX. (Only version 2 supported)`\n )\n }\n if (idx.byteLength > 2048 * 1024 * 1024) {\n throw new InternalError(\n `To keep implementation simple, I haven't implemented the layer 5 feature needed to support packfiles > 2GB in size.`\n )\n }\n // Skip over fanout table\n reader.seek(reader.tell() + 4 * 255);\n // Get hashes\n const size = reader.readUInt32BE();\n const hashes = [];\n for (let i = 0; i < size; i++) {\n const hash = reader.slice(20).toString('hex');\n hashes[i] = hash;\n }\n reader.seek(reader.tell() + 4 * size);\n // Skip over CRCs\n // Get offsets\n const offsets = new Map();\n for (let i = 0; i < size; i++) {\n offsets.set(hashes[i], reader.readUInt32BE());\n }\n const packfileSha = reader.slice(20).toString('hex');\n return new GitPackIndex({\n hashes,\n crcs: {},\n offsets,\n packfileSha,\n getExternalRefDelta,\n })\n }\n\n static async fromPack({ pack, getExternalRefDelta, onProgress }) {\n const listpackTypes = {\n 1: 'commit',\n 2: 'tree',\n 3: 'blob',\n 4: 'tag',\n 6: 'ofs-delta',\n 7: 'ref-delta',\n };\n const offsetToObject = {};\n\n // Older packfiles do NOT use the shasum of the pack itself,\n // so it is recommended to just use whatever bytes are in the trailer.\n // Source: https://github.com/git/git/commit/1190a1acf800acdcfd7569f87ac1560e2d077414\n const packfileSha = pack.slice(-20).toString('hex');\n\n const hashes = [];\n const crcs = {};\n const offsets = new Map();\n let totalObjectCount = null;\n let lastPercent = null;\n\n await listpack([pack], async ({ data, type, reference, offset, num }) => {\n if (totalObjectCount === null) totalObjectCount = num;\n const percent = Math.floor(\n ((totalObjectCount - num) * 100) / totalObjectCount\n );\n if (percent !== lastPercent) {\n if (onProgress) {\n await onProgress({\n phase: 'Receiving objects',\n loaded: totalObjectCount - num,\n total: totalObjectCount,\n });\n }\n }\n lastPercent = percent;\n // Change type from a number to a meaningful string\n type = listpackTypes[type];\n\n if (['commit', 'tree', 'blob', 'tag'].includes(type)) {\n offsetToObject[offset] = {\n type,\n offset,\n };\n } else if (type === 'ofs-delta') {\n offsetToObject[offset] = {\n type,\n offset,\n };\n } else if (type === 'ref-delta') {\n offsetToObject[offset] = {\n type,\n offset,\n };\n }\n });\n\n // We need to know the lengths of the slices to compute the CRCs.\n const offsetArray = Object.keys(offsetToObject).map(Number);\n for (const [i, start] of offsetArray.entries()) {\n const end =\n i + 1 === offsetArray.length ? pack.byteLength - 20 : offsetArray[i + 1];\n const o = offsetToObject[start];\n const crc = crc32.buf(pack.slice(start, end)) >>> 0;\n o.end = end;\n o.crc = crc;\n }\n\n // We don't have the hashes yet. But we can generate them using the .readSlice function!\n const p = new GitPackIndex({\n pack: Promise.resolve(pack),\n packfileSha,\n crcs,\n hashes,\n offsets,\n getExternalRefDelta,\n });\n\n // Resolve deltas and compute the oids\n lastPercent = null;\n let count = 0;\n const objectsByDepth = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];\n for (let offset in offsetToObject) {\n offset = Number(offset);\n const percent = Math.floor((count * 100) / totalObjectCount);\n if (percent !== lastPercent) {\n if (onProgress) {\n await onProgress({\n phase: 'Resolving deltas',\n loaded: count,\n total: totalObjectCount,\n });\n }\n }\n count++;\n lastPercent = percent;\n\n const o = offsetToObject[offset];\n if (o.oid) continue\n try {\n p.readDepth = 0;\n p.externalReadDepth = 0;\n const { type, object } = await p.readSlice({ start: offset });\n objectsByDepth[p.readDepth] += 1;\n const oid = await shasum(GitObject.wrap({ type, object }));\n o.oid = oid;\n hashes.push(oid);\n offsets.set(oid, offset);\n crcs[oid] = o.crc;\n } catch (err) {\n continue\n }\n }\n\n hashes.sort();\n return p\n }\n\n async toBuffer() {\n const buffers = [];\n const write = (str, encoding) => {\n buffers.push(Buffer.from(str, encoding));\n };\n // Write out IDX v2 magic number\n write('ff744f63', 'hex');\n // Write out version number 2\n write('00000002', 'hex');\n // Write fanout table\n const fanoutBuffer = new BufferCursor(Buffer.alloc(256 * 4));\n for (let i = 0; i < 256; i++) {\n let count = 0;\n for (const hash of this.hashes) {\n if (parseInt(hash.slice(0, 2), 16) <= i) count++;\n }\n fanoutBuffer.writeUInt32BE(count);\n }\n buffers.push(fanoutBuffer.buffer);\n // Write out hashes\n for (const hash of this.hashes) {\n write(hash, 'hex');\n }\n // Write out crcs\n const crcsBuffer = new BufferCursor(Buffer.alloc(this.hashes.length * 4));\n for (const hash of this.hashes) {\n crcsBuffer.writeUInt32BE(this.crcs[hash]);\n }\n buffers.push(crcsBuffer.buffer);\n // Write out offsets\n const offsetsBuffer = new BufferCursor(Buffer.alloc(this.hashes.length * 4));\n for (const hash of this.hashes) {\n offsetsBuffer.writeUInt32BE(this.offsets.get(hash));\n }\n buffers.push(offsetsBuffer.buffer);\n // Write out packfile checksum\n write(this.packfileSha, 'hex');\n // Write out shasum\n const totalBuffer = Buffer.concat(buffers);\n const sha = await shasum(totalBuffer);\n const shaBuffer = Buffer.alloc(20);\n shaBuffer.write(sha, 'hex');\n return Buffer.concat([totalBuffer, shaBuffer])\n }\n\n async load({ pack }) {\n this.pack = pack;\n }\n\n async unload() {\n this.pack = null;\n }\n\n async read({ oid }) {\n if (!this.offsets.get(oid)) {\n if (this.getExternalRefDelta) {\n this.externalReadDepth++;\n return this.getExternalRefDelta(oid)\n } else {\n throw new InternalError(`Could not read object ${oid} from packfile`)\n }\n }\n const start = this.offsets.get(oid);\n return this.readSlice({ start })\n }\n\n async readSlice({ start }) {\n if (this.offsetCache[start]) {\n return Object.assign({}, this.offsetCache[start])\n }\n this.readDepth++;\n const types = {\n 0b0010000: 'commit',\n 0b0100000: 'tree',\n 0b0110000: 'blob',\n 0b1000000: 'tag',\n 0b1100000: 'ofs_delta',\n 0b1110000: 'ref_delta',\n };\n if (!this.pack) {\n throw new InternalError(\n 'Tried to read from a GitPackIndex with no packfile loaded into memory'\n )\n }\n const raw = (await this.pack).slice(start);\n const reader = new BufferCursor(raw);\n const byte = reader.readUInt8();\n // Object type is encoded in bits 654\n const btype = byte & 0b1110000;\n let type = types[btype];\n if (type === undefined) {\n throw new InternalError('Unrecognized type: 0b' + btype.toString(2))\n }\n // The length encoding get complicated.\n // Last four bits of length is encoded in bits 3210\n const lastFour = byte & 0b1111;\n let length = lastFour;\n // Whether the next byte is part of the variable-length encoded number\n // is encoded in bit 7\n const multibyte = byte & 0b10000000;\n if (multibyte) {\n length = otherVarIntDecode(reader, lastFour);\n }\n let base = null;\n let object = null;\n // Handle deltified objects\n if (type === 'ofs_delta') {\n const offset = decodeVarInt(reader);\n const baseOffset = start - offset\n ;({ object: base, type } = await this.readSlice({ start: baseOffset }));\n }\n if (type === 'ref_delta') {\n const oid = reader.slice(20).toString('hex')\n ;({ object: base, type } = await this.read({ oid }));\n }\n // Handle undeltified objects\n const buffer = raw.slice(reader.tell());\n object = Buffer.from(await inflate(buffer));\n // Assert that the object length is as expected.\n if (object.byteLength !== length) {\n throw new InternalError(\n `Packfile told us object would have length ${length} but it had length ${object.byteLength}`\n )\n }\n if (base) {\n object = Buffer.from(applyDelta(object, base));\n }\n // Cache the result based on depth.\n if (this.readDepth > 3) {\n // hand tuned for speed / memory usage tradeoff\n this.offsetCache[start] = { type, object };\n }\n return { type, format: 'content', object }\n }\n}\n\nconst PackfileCache = Symbol('PackfileCache');\n\nasync function loadPackIndex({\n fs,\n filename,\n getExternalRefDelta,\n emitter,\n emitterPrefix,\n}) {\n const idx = await fs.read(filename);\n return GitPackIndex.fromIdx({ idx, getExternalRefDelta })\n}\n\nfunction readPackIndex({\n fs,\n cache,\n filename,\n getExternalRefDelta,\n emitter,\n emitterPrefix,\n}) {\n // Try to get the packfile index from the in-memory cache\n if (!cache[PackfileCache]) cache[PackfileCache] = new Map();\n let p = cache[PackfileCache].get(filename);\n if (!p) {\n p = loadPackIndex({\n fs,\n filename,\n getExternalRefDelta,\n emitter,\n emitterPrefix,\n });\n cache[PackfileCache].set(filename, p);\n }\n return p\n}\n\nasync function readObjectPacked({\n fs,\n cache,\n gitdir,\n oid,\n format = 'content',\n getExternalRefDelta,\n}) {\n // Check to see if it's in a packfile.\n // Iterate through all the .idx files\n let list = await fs.readdir(join(gitdir, 'objects/pack'));\n list = list.filter(x => x.endsWith('.idx'));\n for (const filename of list) {\n const indexFile = `${gitdir}/objects/pack/${filename}`;\n const p = await readPackIndex({\n fs,\n cache,\n filename: indexFile,\n getExternalRefDelta,\n });\n if (p.error) throw new InternalError(p.error)\n // If the packfile DOES have the oid we're looking for...\n if (p.offsets.has(oid)) {\n // Get the resolved git object from the packfile\n if (!p.pack) {\n const packFile = indexFile.replace(/idx$/, 'pack');\n p.pack = fs.read(packFile);\n }\n const result = await p.read({ oid, getExternalRefDelta });\n result.format = 'content';\n result.source = `objects/pack/${filename.replace(/idx$/, 'pack')}`;\n return result\n }\n }\n // Failed to find it\n return null\n}\n\n/**\n * @param {object} args\n * @param {import('../models/FileSystem.js').FileSystem} args.fs\n * @param {any} args.cache\n * @param {string} args.gitdir\n * @param {string} args.oid\n * @param {string} [args.format]\n */\nasync function _readObject({\n fs,\n cache,\n gitdir,\n oid,\n format = 'content',\n}) {\n // Curry the current read method so that the packfile un-deltification\n // process can acquire external ref-deltas.\n const getExternalRefDelta = oid => _readObject({ fs, cache, gitdir, oid });\n\n let result;\n // Empty tree - hard-coded so we can use it as a shorthand.\n // Note: I think the canonical git implementation must do this too because\n // `git cat-file -t 4b825dc642cb6eb9a060e54bf8d69288fbee4904` prints \"tree\" even in empty repos.\n if (oid === '4b825dc642cb6eb9a060e54bf8d69288fbee4904') {\n result = { format: 'wrapped', object: Buffer.from(`tree 0\\x00`) };\n }\n // Look for it in the loose object directory.\n if (!result) {\n result = await readObjectLoose({ fs, gitdir, oid });\n }\n // Check to see if it's in a packfile.\n if (!result) {\n result = await readObjectPacked({\n fs,\n cache,\n gitdir,\n oid,\n getExternalRefDelta,\n });\n\n if (!result) {\n throw new NotFoundError(oid)\n }\n\n // Directly return packed result, as specified: packed objects always return the 'content' format.\n return result\n }\n\n // Loose objects are always deflated, return early\n if (format === 'deflated') {\n return result\n }\n\n // All loose objects are deflated but the hard-coded empty tree is `wrapped` so we have to check if we need to inflate the object.\n if (result.format === 'deflated') {\n result.object = Buffer.from(await inflate(result.object));\n result.format = 'wrapped';\n }\n\n if (format === 'wrapped') {\n return result\n }\n\n const sha = await shasum(result.object);\n if (sha !== oid) {\n throw new InternalError(\n `SHA check failed! Expected ${oid}, computed ${sha}`\n )\n }\n const { object, type } = GitObject.unwrap(result.object);\n result.type = type;\n result.object = object;\n result.format = 'content';\n\n if (format === 'content') {\n return result\n }\n\n throw new InternalError(`invalid requested format \"${format}\"`)\n}\n\nclass AlreadyExistsError extends BaseError {\n /**\n * @param {'note'|'remote'|'tag'|'branch'} noun\n * @param {string} where\n * @param {boolean} canForce\n */\n constructor(noun, where, canForce = true) {\n super(\n `Failed to create ${noun} at ${where} because it already exists.${\n canForce\n ? ` (Hint: use 'force: true' parameter to overwrite existing ${noun}.)`\n : ''\n }`\n );\n this.code = this.name = AlreadyExistsError.code;\n this.data = { noun, where, canForce };\n }\n}\n/** @type {'AlreadyExistsError'} */\nAlreadyExistsError.code = 'AlreadyExistsError';\n\nclass AmbiguousError extends BaseError {\n /**\n * @param {'oids'|'refs'} nouns\n * @param {string} short\n * @param {string[]} matches\n */\n constructor(nouns, short, matches) {\n super(\n `Found multiple ${nouns} matching \"${short}\" (${matches.join(\n ', '\n )}). Use a longer abbreviation length to disambiguate them.`\n );\n this.code = this.name = AmbiguousError.code;\n this.data = { nouns, short, matches };\n }\n}\n/** @type {'AmbiguousError'} */\nAmbiguousError.code = 'AmbiguousError';\n\nclass CheckoutConflictError extends BaseError {\n /**\n * @param {string[]} filepaths\n */\n constructor(filepaths) {\n super(\n `Your local changes to the following files would be overwritten by checkout: ${filepaths.join(\n ', '\n )}`\n );\n this.code = this.name = CheckoutConflictError.code;\n this.data = { filepaths };\n }\n}\n/** @type {'CheckoutConflictError'} */\nCheckoutConflictError.code = 'CheckoutConflictError';\n\nclass CommitNotFetchedError extends BaseError {\n /**\n * @param {string} ref\n * @param {string} oid\n */\n constructor(ref, oid) {\n super(\n `Failed to checkout \"${ref}\" because commit ${oid} is not available locally. Do a git fetch to make the branch available locally.`\n );\n this.code = this.name = CommitNotFetchedError.code;\n this.data = { ref, oid };\n }\n}\n/** @type {'CommitNotFetchedError'} */\nCommitNotFetchedError.code = 'CommitNotFetchedError';\n\nclass EmptyServerResponseError extends BaseError {\n constructor() {\n super(`Empty response from git server.`);\n this.code = this.name = EmptyServerResponseError.code;\n this.data = {};\n }\n}\n/** @type {'EmptyServerResponseError'} */\nEmptyServerResponseError.code = 'EmptyServerResponseError';\n\nclass FastForwardError extends BaseError {\n constructor() {\n super(`A simple fast-forward merge was not possible.`);\n this.code = this.name = FastForwardError.code;\n this.data = {};\n }\n}\n/** @type {'FastForwardError'} */\nFastForwardError.code = 'FastForwardError';\n\nclass GitPushError extends BaseError {\n /**\n * @param {string} prettyDetails\n * @param {PushResult} result\n */\n constructor(prettyDetails, result) {\n super(`One or more branches were not updated: ${prettyDetails}`);\n this.code = this.name = GitPushError.code;\n this.data = { prettyDetails, result };\n }\n}\n/** @type {'GitPushError'} */\nGitPushError.code = 'GitPushError';\n\nclass HttpError extends BaseError {\n /**\n * @param {number} statusCode\n * @param {string} statusMessage\n * @param {string} response\n */\n constructor(statusCode, statusMessage, response) {\n super(`HTTP Error: ${statusCode} ${statusMessage}`);\n this.code = this.name = HttpError.code;\n this.data = { statusCode, statusMessage, response };\n }\n}\n/** @type {'HttpError'} */\nHttpError.code = 'HttpError';\n\nclass InvalidFilepathError extends BaseError {\n /**\n * @param {'leading-slash'|'trailing-slash'|'directory'} [reason]\n */\n constructor(reason) {\n let message = 'invalid filepath';\n if (reason === 'leading-slash' || reason === 'trailing-slash') {\n message = `\"filepath\" parameter should not include leading or trailing directory separators because these can cause problems on some platforms.`;\n } else if (reason === 'directory') {\n message = `\"filepath\" should not be a directory.`;\n }\n super(message);\n this.code = this.name = InvalidFilepathError.code;\n this.data = { reason };\n }\n}\n/** @type {'InvalidFilepathError'} */\nInvalidFilepathError.code = 'InvalidFilepathError';\n\nclass InvalidRefNameError extends BaseError {\n /**\n * @param {string} ref\n * @param {string} suggestion\n * @param {boolean} canForce\n */\n constructor(ref, suggestion) {\n super(\n `\"${ref}\" would be an invalid git reference. (Hint: a valid alternative would be \"${suggestion}\".)`\n );\n this.code = this.name = InvalidRefNameError.code;\n this.data = { ref, suggestion };\n }\n}\n/** @type {'InvalidRefNameError'} */\nInvalidRefNameError.code = 'InvalidRefNameError';\n\nclass MaxDepthError extends BaseError {\n /**\n * @param {number} depth\n */\n constructor(depth) {\n super(`Maximum search depth of ${depth} exceeded.`);\n this.code = this.name = MaxDepthError.code;\n this.data = { depth };\n }\n}\n/** @type {'MaxDepthError'} */\nMaxDepthError.code = 'MaxDepthError';\n\nclass MergeNotSupportedError extends BaseError {\n constructor() {\n super(`Merges with conflicts are not supported yet.`);\n this.code = this.name = MergeNotSupportedError.code;\n this.data = {};\n }\n}\n/** @type {'MergeNotSupportedError'} */\nMergeNotSupportedError.code = 'MergeNotSupportedError';\n\nclass MergeConflictError extends BaseError {\n /**\n * @param {Array<string>} filepaths\n * @param {Array<string>} bothModified\n * @param {Array<string>} deleteByUs\n * @param {Array<string>} deleteByTheirs\n */\n constructor(filepaths, bothModified, deleteByUs, deleteByTheirs) {\n super(\n `Automatic merge failed with one or more merge conflicts in the following files: ${filepaths.toString()}. Fix conflicts then commit the result.`\n );\n this.code = this.name = MergeConflictError.code;\n this.data = { filepaths, bothModified, deleteByUs, deleteByTheirs };\n }\n}\n/** @type {'MergeConflictError'} */\nMergeConflictError.code = 'MergeConflictError';\n\nclass MissingNameError extends BaseError {\n /**\n * @param {'author'|'committer'|'tagger'} role\n */\n constructor(role) {\n super(\n `No name was provided for ${role} in the argument or in the .git/config file.`\n );\n this.code = this.name = MissingNameError.code;\n this.data = { role };\n }\n}\n/** @type {'MissingNameError'} */\nMissingNameError.code = 'MissingNameError';\n\nclass MissingParameterError extends BaseError {\n /**\n * @param {string} parameter\n */\n constructor(parameter) {\n super(\n `The function requires a \"${parameter}\" parameter but none was provided.`\n );\n this.code = this.name = MissingParameterError.code;\n this.data = { parameter };\n }\n}\n/** @type {'MissingParameterError'} */\nMissingParameterError.code = 'MissingParameterError';\n\nclass MultipleGitError extends BaseError {\n /**\n * @param {Error[]} errors\n * @param {string} message\n */\n constructor(errors) {\n super(\n `There are multiple errors that were thrown by the method. Please refer to the \"errors\" property to see more`\n );\n this.code = this.name = MultipleGitError.code;\n this.data = { errors };\n this.errors = errors;\n }\n}\n/** @type {'MultipleGitError'} */\nMultipleGitError.code = 'MultipleGitError';\n\nclass ParseError extends BaseError {\n /**\n * @param {string} expected\n * @param {string} actual\n */\n constructor(expected, actual) {\n super(`Expected \"${expected}\" but received \"${actual}\".`);\n this.code = this.name = ParseError.code;\n this.data = { expected, actual };\n }\n}\n/** @type {'ParseError'} */\nParseError.code = 'ParseError';\n\nclass PushRejectedError extends BaseError {\n /**\n * @param {'not-fast-forward'|'tag-exists'} reason\n */\n constructor(reason) {\n let message = '';\n if (reason === 'not-fast-forward') {\n message = ' because it was not a simple fast-forward';\n } else if (reason === 'tag-exists') {\n message = ' because tag already exists';\n }\n super(`Push rejected${message}. Use \"force: true\" to override.`);\n this.code = this.name = PushRejectedError.code;\n this.data = { reason };\n }\n}\n/** @type {'PushRejectedError'} */\nPushRejectedError.code = 'PushRejectedError';\n\nclass RemoteCapabilityError extends BaseError {\n /**\n * @param {'shallow'|'deepen-since'|'deepen-not'|'deepen-relative'} capability\n * @param {'depth'|'since'|'exclude'|'relative'} parameter\n */\n constructor(capability, parameter) {\n super(\n `Remote does not support the \"${capability}\" so the \"${parameter}\" parameter cannot be used.`\n );\n this.code = this.name = RemoteCapabilityError.code;\n this.data = { capability, parameter };\n }\n}\n/** @type {'RemoteCapabilityError'} */\nRemoteCapabilityError.code = 'RemoteCapabilityError';\n\nclass SmartHttpError extends BaseError {\n /**\n * @param {string} preview\n * @param {string} response\n */\n constructor(preview, response) {\n super(\n `Remote did not reply using the \"smart\" HTTP protocol. Expected \"001e# service=git-upload-pack\" but received: ${preview}`\n );\n this.code = this.name = SmartHttpError.code;\n this.data = { preview, response };\n }\n}\n/** @type {'SmartHttpError'} */\nSmartHttpError.code = 'SmartHttpError';\n\nclass UnknownTransportError extends BaseError {\n /**\n * @param {string} url\n * @param {string} transport\n * @param {string} [suggestion]\n */\n constructor(url, transport, suggestion) {\n super(\n `Git remote \"${url}\" uses an unrecognized transport protocol: \"${transport}\"`\n );\n this.code = this.name = UnknownTransportError.code;\n this.data = { url, transport, suggestion };\n }\n}\n/** @type {'UnknownTransportError'} */\nUnknownTransportError.code = 'UnknownTransportError';\n\nclass UrlParseError extends BaseError {\n /**\n * @param {string} url\n */\n constructor(url) {\n super(`Cannot parse remote URL: \"${url}\"`);\n this.code = this.name = UrlParseError.code;\n this.data = { url };\n }\n}\n/** @type {'UrlParseError'} */\nUrlParseError.code = 'UrlParseError';\n\nclass UserCanceledError extends BaseError {\n constructor() {\n super(`The operation was canceled.`);\n this.code = this.name = UserCanceledError.code;\n this.data = {};\n }\n}\n/** @type {'UserCanceledError'} */\nUserCanceledError.code = 'UserCanceledError';\n\nclass IndexResetError extends BaseError {\n /**\n * @param {Array<string>} filepaths\n */\n constructor(filepath) {\n super(\n `Could not merge index: Entry for '${filepath}' is not up to date. Either reset the index entry to HEAD, or stage your unstaged changes.`\n );\n this.code = this.name = IndexResetError.code;\n this.data = { filepath };\n }\n}\n/** @type {'IndexResetError'} */\nIndexResetError.code = 'IndexResetError';\n\nclass NoCommitError extends BaseError {\n /**\n * @param {string} ref\n */\n constructor(ref) {\n super(\n `\"${ref}\" does not point to any commit. You're maybe working on a repository with no commits yet. `\n );\n this.code = this.name = NoCommitError.code;\n this.data = { ref };\n }\n}\n/** @type {'NoCommitError'} */\nNoCommitError.code = 'NoCommitError';\n\n\n\nvar Errors = /*#__PURE__*/Object.freeze({\n __proto__: null,\n AlreadyExistsError: AlreadyExistsError,\n AmbiguousError: AmbiguousError,\n CheckoutConflictError: CheckoutConflictError,\n CommitNotFetchedError: CommitNotFetchedError,\n EmptyServerResponseError: EmptyServerResponseError,\n FastForwardError: FastForwardError,\n GitPushError: GitPushError,\n HttpError: HttpError,\n InternalError: InternalError,\n InvalidFilepathError: InvalidFilepathError,\n InvalidOidError: InvalidOidError,\n InvalidRefNameError: InvalidRefNameError,\n MaxDepthError: MaxDepthError,\n MergeNotSupportedError: MergeNotSupportedError,\n MergeConflictError: MergeConflictError,\n MissingNameError: MissingNameError,\n MissingParameterError: MissingParameterError,\n MultipleGitError: MultipleGitError,\n NoRefspecError: NoRefspecError,\n NotFoundError: NotFoundError,\n ObjectTypeError: ObjectTypeError,\n ParseError: ParseError,\n PushRejectedError: PushRejectedError,\n RemoteCapabilityError: RemoteCapabilityError,\n SmartHttpError: SmartHttpError,\n UnknownTransportError: UnknownTransportError,\n UnsafeFilepathError: UnsafeFilepathError,\n UrlParseError: UrlParseError,\n UserCanceledError: UserCanceledError,\n UnmergedPathsError: UnmergedPathsError,\n IndexResetError: IndexResetError,\n NoCommitError: NoCommitError\n});\n\nfunction formatAuthor({ name, email, timestamp, timezoneOffset }) {\n timezoneOffset = formatTimezoneOffset(timezoneOffset);\n return `${name} <${email}> ${timestamp} ${timezoneOffset}`\n}\n\n// The amount of effort that went into crafting these cases to handle\n// -0 (just so we don't lose that information when parsing and reconstructing)\n// but can also default to +0 was extraordinary.\n\nfunction formatTimezoneOffset(minutes) {\n const sign = simpleSign(negateExceptForZero(minutes));\n minutes = Math.abs(minutes);\n const hours = Math.floor(minutes / 60);\n minutes -= hours * 60;\n let strHours = String(hours);\n let strMinutes = String(minutes);\n if (strHours.length < 2) strHours = '0' + strHours;\n if (strMinutes.length < 2) strMinutes = '0' + strMinutes;\n return (sign === -1 ? '-' : '+') + strHours + strMinutes\n}\n\nfunction simpleSign(n) {\n return Math.sign(n) || (Object.is(n, -0) ? -1 : 1)\n}\n\nfunction negateExceptForZero(n) {\n return n === 0 ? n : -n\n}\n\nfunction normalizeNewlines(str) {\n // remove all <CR>\n str = str.replace(/\\r/g, '');\n // no extra newlines up front\n str = str.replace(/^\\n+/, '');\n // and a single newline at the end\n str = str.replace(/\\n+$/, '') + '\\n';\n return str\n}\n\nfunction parseAuthor(author) {\n const [, name, email, timestamp, offset] = author.match(\n /^(.*) <(.*)> (.*) (.*)$/\n );\n return {\n name: name,\n email: email,\n timestamp: Number(timestamp),\n timezoneOffset: parseTimezoneOffset(offset),\n }\n}\n\n// The amount of effort that went into crafting these cases to handle\n// -0 (just so we don't lose that information when parsing and reconstructing)\n// but can also default to +0 was extraordinary.\n\nfunction parseTimezoneOffset(offset) {\n let [, sign, hours, minutes] = offset.match(/(\\+|-)(\\d\\d)(\\d\\d)/);\n minutes = (sign === '+' ? 1 : -1) * (Number(hours) * 60 + Number(minutes));\n return negateExceptForZero$1(minutes)\n}\n\nfunction negateExceptForZero$1(n) {\n return n === 0 ? n : -n\n}\n\nclass GitAnnotatedTag {\n constructor(tag) {\n if (typeof tag === 'string') {\n this._tag = tag;\n } else if (Buffer.isBuffer(tag)) {\n this._tag = tag.toString('utf8');\n } else if (typeof tag === 'object') {\n this._tag = GitAnnotatedTag.render(tag);\n } else {\n throw new InternalError(\n 'invalid type passed to GitAnnotatedTag constructor'\n )\n }\n }\n\n static from(tag) {\n return new GitAnnotatedTag(tag)\n }\n\n static render(obj) {\n return `object ${obj.object}\ntype ${obj.type}\ntag ${obj.tag}\ntagger ${formatAuthor(obj.tagger)}\n\n${obj.message}\n${obj.gpgsig ? obj.gpgsig : ''}`\n }\n\n justHeaders() {\n return this._tag.slice(0, this._tag.indexOf('\\n\\n'))\n }\n\n message() {\n const tag = this.withoutSignature();\n return tag.slice(tag.indexOf('\\n\\n') + 2)\n }\n\n parse() {\n return Object.assign(this.headers(), {\n message: this.message(),\n gpgsig: this.gpgsig(),\n })\n }\n\n render() {\n return this._tag\n }\n\n headers() {\n const headers = this.justHeaders().split('\\n');\n const hs = [];\n for (const h of headers) {\n if (h[0] === ' ') {\n // combine with previous header (without space indent)\n hs[hs.length - 1] += '\\n' + h.slice(1);\n } else {\n hs.push(h);\n }\n }\n const obj = {};\n for (const h of hs) {\n const key = h.slice(0, h.indexOf(' '));\n const value = h.slice(h.indexOf(' ') + 1);\n if (Array.isArray(obj[key])) {\n obj[key].push(value);\n } else {\n obj[key] = value;\n }\n }\n if (obj.tagger) {\n obj.tagger = parseAuthor(obj.tagger);\n }\n if (obj.committer) {\n obj.committer = parseAuthor(obj.committer);\n }\n return obj\n }\n\n withoutSignature() {\n const tag = normalizeNewlines(this._tag);\n if (tag.indexOf('\\n-----BEGIN PGP SIGNATURE-----') === -1) return tag\n return tag.slice(0, tag.lastIndexOf('\\n-----BEGIN PGP SIGNATURE-----'))\n }\n\n gpgsig() {\n if (this._tag.indexOf('\\n-----BEGIN PGP SIGNATURE-----') === -1) return\n const signature = this._tag.slice(\n this._tag.indexOf('-----BEGIN PGP SIGNATURE-----'),\n this._tag.indexOf('-----END PGP SIGNATURE-----') +\n '-----END PGP SIGNATURE-----'.length\n );\n return normalizeNewlines(signature)\n }\n\n payload() {\n return this.withoutSignature() + '\\n'\n }\n\n toObject() {\n return Buffer.from(this._tag, 'utf8')\n }\n\n static async sign(tag, sign, secretKey) {\n const payload = tag.payload();\n let { signature } = await sign({ payload, secretKey });\n // renormalize the line endings to the one true line-ending\n signature = normalizeNewlines(signature);\n const signedTag = payload + signature;\n // return a new tag object\n return GitAnnotatedTag.from(signedTag)\n }\n}\n\nfunction indent(str) {\n return (\n str\n .trim()\n .split('\\n')\n .map(x => ' ' + x)\n .join('\\n') + '\\n'\n )\n}\n\nfunction outdent(str) {\n return str\n .split('\\n')\n .map(x => x.replace(/^ /, ''))\n .join('\\n')\n}\n\nclass GitCommit {\n constructor(commit) {\n if (typeof commit === 'string') {\n this._commit = commit;\n } else if (Buffer.isBuffer(commit)) {\n this._commit = commit.toString('utf8');\n } else if (typeof commit === 'object') {\n this._commit = GitCommit.render(commit);\n } else {\n throw new InternalError('invalid type passed to GitCommit constructor')\n }\n }\n\n static fromPayloadSignature({ payload, signature }) {\n const headers = GitCommit.justHeaders(payload);\n const message = GitCommit.justMessage(payload);\n const commit = normalizeNewlines(\n headers + '\\ngpgsig' + indent(signature) + '\\n' + message\n );\n return new GitCommit(commit)\n }\n\n static from(commit) {\n return new GitCommit(commit)\n }\n\n toObject() {\n return Buffer.from(this._commit, 'utf8')\n }\n\n // Todo: allow setting the headers and message\n headers() {\n return this.parseHeaders()\n }\n\n // Todo: allow setting the headers and message\n message() {\n return GitCommit.justMessage(this._commit)\n }\n\n parse() {\n return Object.assign({ message: this.message() }, this.headers())\n }\n\n static justMessage(commit) {\n return normalizeNewlines(commit.slice(commit.indexOf('\\n\\n') + 2))\n }\n\n static justHeaders(commit) {\n return commit.slice(0, commit.indexOf('\\n\\n'))\n }\n\n parseHeaders() {\n const headers = GitCommit.justHeaders(this._commit).split('\\n');\n const hs = [];\n for (const h of headers) {\n if (h[0] === ' ') {\n // combine with previous header (without space indent)\n hs[hs.length - 1] += '\\n' + h.slice(1);\n } else {\n hs.push(h);\n }\n }\n const obj = {\n parent: [],\n };\n for (const h of hs) {\n const key = h.slice(0, h.indexOf(' '));\n const value = h.slice(h.indexOf(' ') + 1);\n if (Array.isArray(obj[key])) {\n obj[key].push(value);\n } else {\n obj[key] = value;\n }\n }\n if (obj.author) {\n obj.author = parseAuthor(obj.author);\n }\n if (obj.committer) {\n obj.committer = parseAuthor(obj.committer);\n }\n return obj\n }\n\n static renderHeaders(obj) {\n let headers = '';\n if (obj.tree) {\n headers += `tree ${obj.tree}\\n`;\n } else {\n headers += `tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904\\n`; // the null tree\n }\n if (obj.parent) {\n if (obj.parent.length === undefined) {\n throw new InternalError(`commit 'parent' property should be an array`)\n }\n for (const p of obj.parent) {\n headers += `parent ${p}\\n`;\n }\n }\n const author = obj.author;\n headers += `author ${formatAuthor(author)}\\n`;\n const committer = obj.committer || obj.author;\n headers += `committer ${formatAuthor(committer)}\\n`;\n if (obj.gpgsig) {\n headers += 'gpgsig' + indent(obj.gpgsig);\n }\n return headers\n }\n\n static render(obj) {\n return GitCommit.renderHeaders(obj) + '\\n' + normalizeNewlines(obj.message)\n }\n\n render() {\n return this._commit\n }\n\n withoutSignature() {\n const commit = normalizeNewlines(this._commit);\n if (commit.indexOf('\\ngpgsig') === -1) return commit\n const headers = commit.slice(0, commit.indexOf('\\ngpgsig'));\n const message = commit.slice(\n commit.indexOf('-----END PGP SIGNATURE-----\\n') +\n '-----END PGP SIGNATURE-----\\n'.length\n );\n return normalizeNewlines(headers + '\\n' + message)\n }\n\n isolateSignature() {\n const signature = this._commit.slice(\n this._commit.indexOf('-----BEGIN PGP SIGNATURE-----'),\n this._commit.indexOf('-----END PGP SIGNATURE-----') +\n '-----END PGP SIGNATURE-----'.length\n );\n return outdent(signature)\n }\n\n static async sign(commit, sign, secretKey) {\n const payload = commit.withoutSignature();\n const message = GitCommit.justMessage(commit._commit);\n let { signature } = await sign({ payload, secretKey });\n // renormalize the line endings to the one true line-ending\n signature = normalizeNewlines(signature);\n const headers = GitCommit.justHeaders(commit._commit);\n const signedCommit =\n headers + '\\n' + 'gpgsig' + indent(signature) + '\\n' + message;\n // return a new commit object\n return GitCommit.from(signedCommit)\n }\n}\n\nasync function resolveTree({ fs, cache, gitdir, oid }) {\n // Empty tree - bypass `readObject`\n if (oid === '4b825dc642cb6eb9a060e54bf8d69288fbee4904') {\n return { tree: GitTree.from([]), oid }\n }\n const { type, object } = await _readObject({ fs, cache, gitdir, oid });\n // Resolve annotated tag objects to whatever\n if (type === 'tag') {\n oid = GitAnnotatedTag.from(object).parse().object;\n return resolveTree({ fs, cache, gitdir, oid })\n }\n // Resolve commits to trees\n if (type === 'commit') {\n oid = GitCommit.from(object).parse().tree;\n return resolveTree({ fs, cache, gitdir, oid })\n }\n if (type !== 'tree') {\n throw new ObjectTypeError(oid, type, 'tree')\n }\n return { tree: GitTree.from(object), oid }\n}\n\nclass GitWalkerRepo {\n constructor({ fs, gitdir, ref, cache }) {\n this.fs = fs;\n this.cache = cache;\n this.gitdir = gitdir;\n this.mapPromise = (async () => {\n const map = new Map();\n let oid;\n try {\n oid = await GitRefManager.resolve({ fs, gitdir, ref });\n } catch (e) {\n if (e instanceof NotFoundError) {\n // Handle fresh branches with no commits\n oid = '4b825dc642cb6eb9a060e54bf8d69288fbee4904';\n }\n }\n const tree = await resolveTree({ fs, cache: this.cache, gitdir, oid });\n tree.type = 'tree';\n tree.mode = '40000';\n map.set('.', tree);\n return map\n })();\n const walker = this;\n this.ConstructEntry = class TreeEntry {\n constructor(fullpath) {\n this._fullpath = fullpath;\n this._type = false;\n this._mode = false;\n this._stat = false;\n this._content = false;\n this._oid = false;\n }\n\n async type() {\n return walker.type(this)\n }\n\n async mode() {\n return walker.mode(this)\n }\n\n async stat() {\n return walker.stat(this)\n }\n\n async content() {\n return walker.content(this)\n }\n\n async oid() {\n return walker.oid(this)\n }\n };\n }\n\n async readdir(entry) {\n const filepath = entry._fullpath;\n const { fs, cache, gitdir } = this;\n const map = await this.mapPromise;\n const obj = map.get(filepath);\n if (!obj) throw new Error(`No obj for ${filepath}`)\n const oid = obj.oid;\n if (!oid) throw new Error(`No oid for obj ${JSON.stringify(obj)}`)\n if (obj.type !== 'tree') {\n // TODO: support submodules (type === 'commit')\n return null\n }\n const { type, object } = await _readObject({ fs, cache, gitdir, oid });\n if (type !== obj.type) {\n throw new ObjectTypeError(oid, type, obj.type)\n }\n const tree = GitTree.from(object);\n // cache all entries\n for (const entry of tree) {\n map.set(join(filepath, entry.path), entry);\n }\n return tree.entries().map(entry => join(filepath, entry.path))\n }\n\n async type(entry) {\n if (entry._type === false) {\n const map = await this.mapPromise;\n const { type } = map.get(entry._fullpath);\n entry._type = type;\n }\n return entry._type\n }\n\n async mode(entry) {\n if (entry._mode === false) {\n const map = await this.mapPromise;\n const { mode } = map.get(entry._fullpath);\n entry._mode = normalizeMode(parseInt(mode, 8));\n }\n return entry._mode\n }\n\n async stat(_entry) {}\n\n async content(entry) {\n if (entry._content === false) {\n const map = await this.mapPromise;\n const { fs, cache, gitdir } = this;\n const obj = map.get(entry._fullpath);\n const oid = obj.oid;\n const { type, object } = await _readObject({ fs, cache, gitdir, oid });\n if (type !== 'blob') {\n entry._content = undefined;\n } else {\n entry._content = new Uint8Array(object);\n }\n }\n return entry._content\n }\n\n async oid(entry) {\n if (entry._oid === false) {\n const map = await this.mapPromise;\n const obj = map.get(entry._fullpath);\n entry._oid = obj.oid;\n }\n return entry._oid\n }\n}\n\n// @ts-check\n\n/**\n * @param {object} args\n * @param {string} [args.ref='HEAD']\n * @returns {Walker}\n */\nfunction TREE({ ref = 'HEAD' } = {}) {\n const o = Object.create(null);\n Object.defineProperty(o, GitWalkSymbol, {\n value: function({ fs, gitdir, cache }) {\n return new GitWalkerRepo({ fs, gitdir, ref, cache })\n },\n });\n Object.freeze(o);\n return o\n}\n\n// @ts-check\n\nclass GitWalkerFs {\n constructor({ fs, dir, gitdir, cache }) {\n this.fs = fs;\n this.cache = cache;\n this.dir = dir;\n this.gitdir = gitdir;\n\n this.config = null;\n const walker = this;\n this.ConstructEntry = class WorkdirEntry {\n constructor(fullpath) {\n this._fullpath = fullpath;\n this._type = false;\n this._mode = false;\n this._stat = false;\n this._content = false;\n this._oid = false;\n }\n\n async type() {\n return walker.type(this)\n }\n\n async mode() {\n return walker.mode(this)\n }\n\n async stat() {\n return walker.stat(this)\n }\n\n async content() {\n return walker.content(this)\n }\n\n async oid() {\n return walker.oid(this)\n }\n };\n }\n\n async readdir(entry) {\n const filepath = entry._fullpath;\n const { fs, dir } = this;\n const names = await fs.readdir(join(dir, filepath));\n if (names === null) return null\n return names.map(name => join(filepath, name))\n }\n\n async type(entry) {\n if (entry._type === false) {\n await entry.stat();\n }\n return entry._type\n }\n\n async mode(entry) {\n if (entry._mode === false) {\n await entry.stat();\n }\n return entry._mode\n }\n\n async stat(entry) {\n if (entry._stat === false) {\n const { fs, dir } = this;\n let stat = await fs.lstat(`${dir}/${entry._fullpath}`);\n if (!stat) {\n throw new Error(\n `ENOENT: no such file or directory, lstat '${entry._fullpath}'`\n )\n }\n let type = stat.isDirectory() ? 'tree' : 'blob';\n if (type === 'blob' && !stat.isFile() && !stat.isSymbolicLink()) {\n type = 'special';\n }\n entry._type = type;\n stat = normalizeStats(stat);\n entry._mode = stat.mode;\n // workaround for a BrowserFS edge case\n if (stat.size === -1 && entry._actualSize) {\n stat.size = entry._actualSize;\n }\n entry._stat = stat;\n }\n return entry._stat\n }\n\n async content(entry) {\n if (entry._content === false) {\n const { fs, dir, gitdir } = this;\n if ((await entry.type()) === 'tree') {\n entry._content = undefined;\n } else {\n const config = await this._getGitConfig(fs, gitdir);\n const autocrlf = await config.get('core.autocrlf');\n const content = await fs.read(`${dir}/${entry._fullpath}`, { autocrlf });\n // workaround for a BrowserFS edge case\n entry._actualSize = content.length;\n if (entry._stat && entry._stat.size === -1) {\n entry._stat.size = entry._actualSize;\n }\n entry._content = new Uint8Array(content);\n }\n }\n return entry._content\n }\n\n async oid(entry) {\n if (entry._oid === false) {\n const self = this;\n const { fs, gitdir, cache } = this;\n let oid;\n // See if we can use the SHA1 hash in the index.\n await GitIndexManager.acquire({ fs, gitdir, cache }, async function(\n index\n ) {\n const stage = index.entriesMap.get(entry._fullpath);\n const stats = await entry.stat();\n const config = await self._getGitConfig(fs, gitdir);\n const filemode = await config.get('core.filemode');\n const trustino =\n typeof process !== 'undefined'\n ? !(process.platform === 'win32')\n : true;\n if (!stage || compareStats(stats, stage, filemode, trustino)) {\n const content = await entry.content();\n if (content === undefined) {\n oid = undefined;\n } else {\n oid = await shasum(\n GitObject.wrap({ type: 'blob', object: content })\n );\n // Update the stats in the index so we will get a \"cache hit\" next time\n // 1) if we can (because the oid and mode are the same)\n // 2) and only if we need to (because other stats differ)\n if (\n stage &&\n oid === stage.oid &&\n (!filemode || stats.mode === stage.mode) &&\n compareStats(stats, stage, filemode, trustino)\n ) {\n index.insert({\n filepath: entry._fullpath,\n stats,\n oid: oid,\n });\n }\n }\n } else {\n // Use the index SHA1 rather than compute it\n oid = stage.oid;\n }\n });\n entry._oid = oid;\n }\n return entry._oid\n }\n\n async _getGitConfig(fs, gitdir) {\n if (this.config) {\n return this.config\n }\n this.config = await GitConfigManager.get({ fs, gitdir });\n return this.config\n }\n}\n\n// @ts-check\n\n/**\n * @returns {Walker}\n */\nfunction WORKDIR() {\n const o = Object.create(null);\n Object.defineProperty(o, GitWalkSymbol, {\n value: function({ fs, dir, gitdir, cache }) {\n return new GitWalkerFs({ fs, dir, gitdir, cache })\n },\n });\n Object.freeze(o);\n return o\n}\n\n// @ts-check\n\n// https://dev.to/namirsab/comment/2050\nfunction arrayRange(start, end) {\n const length = end - start;\n return Array.from({ length }, (_, i) => start + i)\n}\n\n// TODO: Should I just polyfill Array.flat?\nconst flat =\n typeof Array.prototype.flat === 'undefined'\n ? entries => entries.reduce((acc, x) => acc.concat(x), [])\n : entries => entries.flat();\n\n// This is convenient for computing unions/joins of sorted lists.\nclass RunningMinimum {\n constructor() {\n // Using a getter for 'value' would just bloat the code.\n // You know better than to set it directly right?\n this.value = null;\n }\n\n consider(value) {\n if (value === null || value === undefined) return\n if (this.value === null) {\n this.value = value;\n } else if (value < this.value) {\n this.value = value;\n }\n }\n\n reset() {\n this.value = null;\n }\n}\n\n// Take an array of length N of\n// iterators of length Q_n\n// of strings\n// and return an iterator of length max(Q_n) for all n\n// of arrays of length N\n// of string|null who all have the same string value\nfunction* unionOfIterators(sets) {\n /* NOTE: We can assume all arrays are sorted.\n * Indexes are sorted because they are defined that way:\n *\n * > Index entries are sorted in ascending order on the name field,\n * > interpreted as a string of unsigned bytes (i.e. memcmp() order, no\n * > localization, no special casing of directory separator '/'). Entries\n * > with the same name are sorted by their stage field.\n *\n * Trees should be sorted because they are created directly from indexes.\n * They definitely should be sorted, or else they wouldn't have a unique SHA1.\n * So that would be very naughty on the part of the tree-creator.\n *\n * Lastly, the working dir entries are sorted because I choose to sort them\n * in my FileSystem.readdir() implementation.\n */\n\n // Init\n const min = new RunningMinimum();\n let minimum;\n const heads = [];\n const numsets = sets.length;\n for (let i = 0; i < numsets; i++) {\n // Abuse the fact that iterators continue to return 'undefined' for value\n // once they are done\n heads[i] = sets[i].next().value;\n if (heads[i] !== undefined) {\n min.consider(heads[i]);\n }\n }\n if (min.value === null) return\n // Iterate\n while (true) {\n const result = [];\n minimum = min.value;\n min.reset();\n for (let i = 0; i < numsets; i++) {\n if (heads[i] !== undefined && heads[i] === minimum) {\n result[i] = heads[i];\n heads[i] = sets[i].next().value;\n } else {\n // A little hacky, but eh\n result[i] = null;\n }\n if (heads[i] !== undefined) {\n min.consider(heads[i]);\n }\n }\n yield result;\n if (min.value === null) return\n }\n}\n\n// @ts-check\n\n/**\n * @param {object} args\n * @param {import('../models/FileSystem.js').FileSystem} args.fs\n * @param {object} args.cache\n * @param {string} [args.dir]\n * @param {string} [args.gitdir=join(dir,'.git')]\n * @param {Walker[]} args.trees\n * @param {WalkerMap} [args.map]\n * @param {WalkerReduce} [args.reduce]\n * @param {WalkerIterate} [args.iterate]\n *\n * @returns {Promise<any>} The finished tree-walking result\n *\n * @see {WalkerMap}\n *\n */\nasync function _walk({\n fs,\n cache,\n dir,\n gitdir,\n trees,\n // @ts-ignore\n map = async (_, entry) => entry,\n // The default reducer is a flatmap that filters out undefineds.\n reduce = async (parent, children) => {\n const flatten = flat(children);\n if (parent !== undefined) flatten.unshift(parent);\n return flatten\n },\n // The default iterate function walks all children concurrently\n iterate = (walk, children) => Promise.all([...children].map(walk)),\n}) {\n const walkers = trees.map(proxy =>\n proxy[GitWalkSymbol]({ fs, dir, gitdir, cache })\n );\n\n const root = new Array(walkers.length).fill('.');\n const range = arrayRange(0, walkers.length);\n const unionWalkerFromReaddir = async entries => {\n range.map(i => {\n const entry = entries[i];\n entries[i] = entry && new walkers[i].ConstructEntry(entry);\n });\n const subdirs = await Promise.all(\n range.map(i => {\n const entry = entries[i];\n return entry ? walkers[i].readdir(entry) : []\n })\n );\n // Now process child directories\n const iterators = subdirs.map(array => {\n return (array === null ? [] : array)[Symbol.iterator]()\n });\n\n return {\n entries,\n children: unionOfIterators(iterators),\n }\n };\n\n const walk = async root => {\n const { entries, children } = await unionWalkerFromReaddir(root);\n const fullpath = entries.find(entry => entry && entry._fullpath)._fullpath;\n const parent = await map(fullpath, entries);\n if (parent !== null) {\n let walkedChildren = await iterate(walk, children);\n walkedChildren = walkedChildren.filter(x => x !== undefined);\n return reduce(parent, walkedChildren)\n }\n };\n return walk(root)\n}\n\n/**\n * Removes the directory at the specified filepath recursively. Used internally to replicate the behavior of\n * fs.promises.rm({ recursive: true, force: true }) from Node.js 14 and above when not available. If the provided\n * filepath resolves to a file, it will be removed.\n *\n * @param {import('../models/FileSystem.js').FileSystem} fs\n * @param {string} filepath - The file or directory to remove.\n */\nasync function rmRecursive(fs, filepath) {\n const entries = await fs.readdir(filepath);\n if (entries == null) {\n await fs.rm(filepath);\n } else if (entries.length) {\n await Promise.all(\n entries.map(entry => {\n const subpath = join(filepath, entry);\n return fs.lstat(subpath).then(stat => {\n if (!stat) return\n return stat.isDirectory() ? rmRecursive(fs, subpath) : fs.rm(subpath)\n })\n })\n ).then(() => fs.rmdir(filepath));\n } else {\n await fs.rmdir(filepath);\n }\n}\n\nfunction isPromiseLike(obj) {\n return isObject(obj) && isFunction(obj.then) && isFunction(obj.catch)\n}\n\nfunction isObject(obj) {\n return obj && typeof obj === 'object'\n}\n\nfunction isFunction(obj) {\n return typeof obj === 'function'\n}\n\nfunction isPromiseFs(fs) {\n const test = targetFs => {\n try {\n // If readFile returns a promise then we can probably assume the other\n // commands do as well\n return targetFs.readFile().catch(e => e)\n } catch (e) {\n return e\n }\n };\n return isPromiseLike(test(fs))\n}\n\n// List of commands all filesystems are expected to provide. `rm` is not\n// included since it may not exist and must be handled as a special case\nconst commands = [\n 'readFile',\n 'writeFile',\n 'mkdir',\n 'rmdir',\n 'unlink',\n 'stat',\n 'lstat',\n 'readdir',\n 'readlink',\n 'symlink',\n];\n\nfunction bindFs(target, fs) {\n if (isPromiseFs(fs)) {\n for (const command of commands) {\n target[`_${command}`] = fs[command].bind(fs);\n }\n } else {\n for (const command of commands) {\n target[`_${command}`] = pify(fs[command].bind(fs));\n }\n }\n\n // Handle the special case of `rm`\n if (isPromiseFs(fs)) {\n if (fs.rm) target._rm = fs.rm.bind(fs);\n else if (fs.rmdir.length > 1) target._rm = fs.rmdir.bind(fs);\n else target._rm = rmRecursive.bind(null, target);\n } else {\n if (fs.rm) target._rm = pify(fs.rm.bind(fs));\n else if (fs.rmdir.length > 2) target._rm = pify(fs.rmdir.bind(fs));\n else target._rm = rmRecursive.bind(null, target);\n }\n}\n\n/**\n * This is just a collection of helper functions really. At least that's how it started.\n */\nclass FileSystem {\n constructor(fs) {\n if (typeof fs._original_unwrapped_fs !== 'undefined') return fs\n\n const promises = Object.getOwnPropertyDescriptor(fs, 'promises');\n if (promises && promises.enumerable) {\n bindFs(this, fs.promises);\n } else {\n bindFs(this, fs);\n }\n this._original_unwrapped_fs = fs;\n }\n\n /**\n * Return true if a file exists, false if it doesn't exist.\n * Rethrows errors that aren't related to file existence.\n */\n async exists(filepath, options = {}) {\n try {\n await this._stat(filepath);\n return true\n } catch (err) {\n if (\n err.code === 'ENOENT' ||\n err.code === 'ENOTDIR' ||\n (err.code || '').includes('ENS')\n ) {\n return false\n } else {\n console.log('Unhandled error in \"FileSystem.exists()\" function', err);\n throw err\n }\n }\n }\n\n /**\n * Return the contents of a file if it exists, otherwise returns null.\n *\n * @param {string} filepath\n * @param {object} [options]\n *\n * @returns {Promise<Buffer|string|null>}\n */\n async read(filepath, options = {}) {\n try {\n let buffer = await this._readFile(filepath, options);\n if (options.autocrlf === 'true') {\n try {\n buffer = new TextDecoder('utf8', { fatal: true }).decode(buffer);\n buffer = buffer.replace(/\\r\\n/g, '\\n');\n buffer = new TextEncoder().encode(buffer);\n } catch (error) {\n // non utf8 file\n }\n }\n // Convert plain ArrayBuffers to Buffers\n if (typeof buffer !== 'string') {\n buffer = Buffer.from(buffer);\n }\n return buffer\n } catch (err) {\n return null\n }\n }\n\n /**\n * Write a file (creating missing directories if need be) without throwing errors.\n *\n * @param {string} filepath\n * @param {Buffer|Uint8Array|string} contents\n * @param {object|string} [options]\n */\n async write(filepath, contents, options = {}) {\n try {\n await this._writeFile(filepath, contents, options);\n return\n } catch (err) {\n // Hmm. Let's try mkdirp and try again.\n await this.mkdir(dirname(filepath));\n await this._writeFile(filepath, contents, options);\n }\n }\n\n /**\n * Make a directory (or series of nested directories) without throwing an error if it already exists.\n */\n async mkdir(filepath, _selfCall = false) {\n try {\n await this._mkdir(filepath);\n return\n } catch (err) {\n // If err is null then operation succeeded!\n if (err === null) return\n // If the directory already exists, that's OK!\n if (err.code === 'EEXIST') return\n // Avoid infinite loops of failure\n if (_selfCall) throw err\n // If we got a \"no such file or directory error\" backup and try again.\n if (err.code === 'ENOENT') {\n const parent = dirname(filepath);\n // Check to see if we've gone too far\n if (parent === '.' || parent === '/' || parent === filepath) throw err\n // Infinite recursion, what could go wrong?\n await this.mkdir(parent);\n await this.mkdir(filepath, true);\n }\n }\n }\n\n /**\n * Delete a file without throwing an error if it is already deleted.\n */\n async rm(filepath) {\n try {\n await this._unlink(filepath);\n } catch (err) {\n if (err.code !== 'ENOENT') throw err\n }\n }\n\n /**\n * Delete a directory without throwing an error if it is already deleted.\n */\n async rmdir(filepath, opts) {\n try {\n if (opts && opts.recursive) {\n await this._rm(filepath, opts);\n } else {\n await this._rmdir(filepath);\n }\n } catch (err) {\n if (err.code !== 'ENOENT') throw err\n }\n }\n\n /**\n * Read a directory without throwing an error is the directory doesn't exist\n */\n async readdir(filepath) {\n try {\n const names = await this._readdir(filepath);\n // Ordering is not guaranteed, and system specific (Windows vs Unix)\n // so we must sort them ourselves.\n names.sort(compareStrings);\n return names\n } catch (err) {\n if (err.code === 'ENOTDIR') return null\n return []\n }\n }\n\n /**\n * Return a flast list of all the files nested inside a directory\n *\n * Based on an elegant concurrent recursive solution from SO\n * https://stackoverflow.com/a/45130990/2168416\n */\n async readdirDeep(dir) {\n const subdirs = await this._readdir(dir);\n const files = await Promise.all(\n subdirs.map(async subdir => {\n const res = dir + '/' + subdir;\n return (await this._stat(res)).isDirectory()\n ? this.readdirDeep(res)\n : res\n })\n );\n return files.reduce((a, f) => a.concat(f), [])\n }\n\n /**\n * Return the Stats of a file/symlink if it exists, otherwise returns null.\n * Rethrows errors that aren't related to file existence.\n */\n async lstat(filename) {\n try {\n const stats = await this._lstat(filename);\n return stats\n } catch (err) {\n if (err.code === 'ENOENT' || (err.code || '').includes('ENS')) {\n return null\n }\n throw err\n }\n }\n\n /**\n * Reads the contents of a symlink if it exists, otherwise returns null.\n * Rethrows errors that aren't related to file existence.\n */\n async readlink(filename, opts = { encoding: 'buffer' }) {\n // Note: FileSystem.readlink returns a buffer by default\n // so we can dump it into GitObject.write just like any other file.\n try {\n const link = await this._readlink(filename, opts);\n return Buffer.isBuffer(link) ? link : Buffer.from(link)\n } catch (err) {\n if (err.code === 'ENOENT' || (err.code || '').includes('ENS')) {\n return null\n }\n throw err\n }\n }\n\n /**\n * Write the contents of buffer to a symlink.\n */\n async writelink(filename, buffer) {\n return this._symlink(buffer.toString('utf8'), filename)\n }\n}\n\nfunction assertParameter(name, value) {\n if (value === undefined) {\n throw new MissingParameterError(name)\n }\n}\n\n// @ts-check\n/**\n *\n * @param {WalkerEntry} entry\n * @param {WalkerEntry} base\n *\n */\nasync function modified(entry, base) {\n if (!entry && !base) return false\n if (entry && !base) return true\n if (!entry && base) return true\n if ((await entry.type()) === 'tree' && (await base.type()) === 'tree') {\n return false\n }\n if (\n (await entry.type()) === (await base.type()) &&\n (await entry.mode()) === (await base.mode()) &&\n (await entry.oid()) === (await base.oid())\n ) {\n return false\n }\n return true\n}\n\n// @ts-check\n\n/**\n * Abort a merge in progress.\n *\n * Based on the behavior of git reset --merge, i.e. \"Resets the index and updates the files in the working tree that are different between <commit> and HEAD, but keeps those which are different between the index and working tree (i.e. which have changes which have not been added). If a file that is different between <commit> and the index has unstaged changes, reset is aborted.\"\n *\n * Essentially, abortMerge will reset any files affected by merge conflicts to their last known good version at HEAD.\n * Any unstaged changes are saved and any staged changes are reset as well.\n *\n * NOTE: The behavior of this command differs slightly from canonical git in that an error will be thrown if a file exists in the index and nowhere else.\n * Canonical git will reset the file and continue aborting the merge in this case.\n *\n * **WARNING:** Running git merge with non-trivial uncommitted changes is discouraged: while possible, it may leave you in a state that is hard to back out of in the case of a conflict.\n * If there were uncommitted changes when the merge started (and especially if those changes were further modified after the merge was started), `git.abortMerge` will in some cases be unable to reconstruct the original (pre-merge) changes.\n *\n * @param {object} args\n * @param {FsClient} args.fs - a file system implementation\n * @param {string} args.dir - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {string} [args.commit='HEAD'] - commit to reset the index and worktree to, defaults to HEAD\n * @param {object} [args.cache] - a [cache](cache.md) object\n *\n * @returns {Promise<void>} Resolves successfully once the git index has been updated\n *\n */\nasync function abortMerge({\n fs: _fs,\n dir,\n gitdir = join(dir, '.git'),\n commit = 'HEAD',\n cache = {},\n}) {\n try {\n assertParameter('fs', _fs);\n assertParameter('dir', dir);\n assertParameter('gitdir', gitdir);\n\n const fs = new FileSystem(_fs);\n const trees = [TREE({ ref: commit }), WORKDIR(), STAGE()];\n let unmergedPaths = [];\n\n await GitIndexManager.acquire({ fs, gitdir, cache }, async function(index) {\n unmergedPaths = index.unmergedPaths;\n });\n\n const results = await _walk({\n fs,\n cache,\n dir,\n gitdir,\n trees,\n map: async function(path, [head, workdir, index]) {\n const staged = !(await modified(workdir, index));\n const unmerged = unmergedPaths.includes(path);\n const unmodified = !(await modified(index, head));\n\n if (staged || unmerged) {\n return head\n ? {\n path,\n mode: await head.mode(),\n oid: await head.oid(),\n type: await head.type(),\n content: await head.content(),\n }\n : undefined\n }\n\n if (unmodified) return false\n else throw new IndexResetError(path)\n },\n });\n\n await GitIndexManager.acquire({ fs, gitdir, cache }, async function(index) {\n // Reset paths in index and worktree, this can't be done in _walk because the\n // STAGE walker acquires its own index lock.\n\n for (const entry of results) {\n if (entry === false) continue\n\n // entry is not false, so from here we can assume index = workdir\n if (!entry) {\n await fs.rmdir(`${dir}/${entry.path}`, { recursive: true });\n index.delete({ filepath: entry.path });\n continue\n }\n\n if (entry.type === 'blob') {\n const content = new TextDecoder().decode(entry.content);\n await fs.write(`${dir}/${entry.path}`, content, { mode: entry.mode });\n index.insert({\n filepath: entry.path,\n oid: entry.oid,\n stage: 0,\n });\n }\n }\n });\n } catch (err) {\n err.caller = 'git.abortMerge';\n throw err\n }\n}\n\n// I'm putting this in a Manager because I reckon it could benefit\n// from a LOT of caching.\nclass GitIgnoreManager {\n static async isIgnored({ fs, dir, gitdir = join(dir, '.git'), filepath }) {\n // ALWAYS ignore \".git\" folders.\n if (basename(filepath) === '.git') return true\n // '.' is not a valid gitignore entry, so '.' is never ignored\n if (filepath === '.') return false\n // Check and load exclusion rules from project exclude file (.git/info/exclude)\n let excludes = '';\n const excludesFile = join(gitdir, 'info', 'exclude');\n if (await fs.exists(excludesFile)) {\n excludes = await fs.read(excludesFile, 'utf8');\n }\n // Find all the .gitignore files that could affect this file\n const pairs = [\n {\n gitignore: join(dir, '.gitignore'),\n filepath,\n },\n ];\n const pieces = filepath.split('/').filter(Boolean);\n for (let i = 1; i < pieces.length; i++) {\n const folder = pieces.slice(0, i).join('/');\n const file = pieces.slice(i).join('/');\n pairs.push({\n gitignore: join(dir, folder, '.gitignore'),\n filepath: file,\n });\n }\n let ignoredStatus = false;\n for (const p of pairs) {\n let file;\n try {\n file = await fs.read(p.gitignore, 'utf8');\n } catch (err) {\n if (err.code === 'NOENT') continue\n }\n const ign = ignore().add(excludes);\n ign.add(file);\n // If the parent directory is excluded, we are done.\n // \"It is not possible to re-include a file if a parent directory of that file is excluded. Git doesn’t list excluded directories for performance reasons, so any patterns on contained files have no effect, no matter where they are defined.\"\n // source: https://git-scm.com/docs/gitignore\n const parentdir = dirname(p.filepath);\n if (parentdir !== '.' && ign.ignores(parentdir)) return true\n // If the file is currently ignored, test for UNignoring.\n if (ignoredStatus) {\n ignoredStatus = !ign.test(p.filepath).unignored;\n } else {\n ignoredStatus = ign.test(p.filepath).ignored;\n }\n }\n return ignoredStatus\n }\n}\n\nasync function writeObjectLoose({ fs, gitdir, object, format, oid }) {\n if (format !== 'deflated') {\n throw new InternalError(\n 'GitObjectStoreLoose expects objects to write to be in deflated format'\n )\n }\n const source = `objects/${oid.slice(0, 2)}/${oid.slice(2)}`;\n const filepath = `${gitdir}/${source}`;\n // Don't overwrite existing git objects - this helps avoid EPERM errors.\n // Although I don't know how we'd fix corrupted objects then. Perhaps delete them\n // on read?\n if (!(await fs.exists(filepath))) await fs.write(filepath, object);\n}\n\n/* eslint-env node, browser */\n\nlet supportsCompressionStream = null;\n\nasync function deflate(buffer) {\n if (supportsCompressionStream === null) {\n supportsCompressionStream = testCompressionStream();\n }\n return supportsCompressionStream\n ? browserDeflate(buffer)\n : pako.deflate(buffer)\n}\n\nasync function browserDeflate(buffer) {\n const cs = new CompressionStream('deflate');\n const c = new Blob([buffer]).stream().pipeThrough(cs);\n return new Uint8Array(await new Response(c).arrayBuffer())\n}\n\nfunction testCompressionStream() {\n try {\n const cs = new CompressionStream('deflate');\n cs.writable.close();\n // Test if `Blob.stream` is present. React Native does not have the `stream` method\n const stream = new Blob([]).stream();\n stream.cancel();\n return true\n } catch (_) {\n return false\n }\n}\n\nasync function _writeObject({\n fs,\n gitdir,\n type,\n object,\n format = 'content',\n oid = undefined,\n dryRun = false,\n}) {\n if (format !== 'deflated') {\n if (format !== 'wrapped') {\n object = GitObject.wrap({ type, object });\n }\n oid = await shasum(object);\n object = Buffer.from(await deflate(object));\n }\n if (!dryRun) {\n await writeObjectLoose({ fs, gitdir, object, format: 'deflated', oid });\n }\n return oid\n}\n\nfunction posixifyPathBuffer(buffer) {\n let idx;\n while (~(idx = buffer.indexOf(92))) buffer[idx] = 47;\n return buffer\n}\n\n// @ts-check\n\n/**\n * Add a file to the git index (aka staging area)\n *\n * @param {object} args\n * @param {FsClient} args.fs - a file system implementation\n * @param {string} args.dir - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {string|string[]} args.filepath - The path to the file to add to the index\n * @param {object} [args.cache] - a [cache](cache.md) object\n * @param {boolean} [args.force=false] - add to index even if matches gitignore. Think `git add --force`\n * @param {boolean} [args.parallel=false] - process each input file in parallel. Parallel processing will result in more memory consumption but less process time\n *\n * @returns {Promise<void>} Resolves successfully once the git index has been updated\n *\n * @example\n * await fs.promises.writeFile('/tutorial/README.md', `# TEST`)\n * await git.add({ fs, dir: '/tutorial', filepath: 'README.md' })\n * console.log('done')\n *\n */\nasync function add({\n fs: _fs,\n dir,\n gitdir = join(dir, '.git'),\n filepath,\n cache = {},\n force = false,\n parallel = true,\n}) {\n try {\n assertParameter('fs', _fs);\n assertParameter('dir', dir);\n assertParameter('gitdir', gitdir);\n assertParameter('filepath', filepath);\n\n const fs = new FileSystem(_fs);\n await GitIndexManager.acquire({ fs, gitdir, cache }, async index => {\n const config = await GitConfigManager.get({ fs, gitdir });\n const autocrlf = await config.get('core.autocrlf');\n return addToIndex({\n dir,\n gitdir,\n fs,\n filepath,\n index,\n force,\n parallel,\n autocrlf,\n })\n });\n } catch (err) {\n err.caller = 'git.add';\n throw err\n }\n}\n\nasync function addToIndex({\n dir,\n gitdir,\n fs,\n filepath,\n index,\n force,\n parallel,\n autocrlf,\n}) {\n // TODO: Should ignore UNLESS it's already in the index.\n filepath = Array.isArray(filepath) ? filepath : [filepath];\n const promises = filepath.map(async currentFilepath => {\n if (!force) {\n const ignored = await GitIgnoreManager.isIgnored({\n fs,\n dir,\n gitdir,\n filepath: currentFilepath,\n });\n if (ignored) return\n }\n const stats = await fs.lstat(join(dir, currentFilepath));\n if (!stats) throw new NotFoundError(currentFilepath)\n\n if (stats.isDirectory()) {\n const children = await fs.readdir(join(dir, currentFilepath));\n if (parallel) {\n const promises = children.map(child =>\n addToIndex({\n dir,\n gitdir,\n fs,\n filepath: [join(currentFilepath, child)],\n index,\n force,\n parallel,\n autocrlf,\n })\n );\n await Promise.all(promises);\n } else {\n for (const child of children) {\n await addToIndex({\n dir,\n gitdir,\n fs,\n filepath: [join(currentFilepath, child)],\n index,\n force,\n parallel,\n autocrlf,\n });\n }\n }\n } else {\n const object = stats.isSymbolicLink()\n ? await fs.readlink(join(dir, currentFilepath)).then(posixifyPathBuffer)\n : await fs.read(join(dir, currentFilepath), { autocrlf });\n if (object === null) throw new NotFoundError(currentFilepath)\n const oid = await _writeObject({ fs, gitdir, type: 'blob', object });\n index.insert({ filepath: currentFilepath, stats, oid });\n }\n });\n\n const settledPromises = await Promise.allSettled(promises);\n const rejectedPromises = settledPromises\n .filter(settle => settle.status === 'rejected')\n .map(settle => settle.reason);\n if (rejectedPromises.length > 1) {\n throw new MultipleGitError(rejectedPromises)\n }\n if (rejectedPromises.length === 1) {\n throw rejectedPromises[0]\n }\n\n const fulfilledPromises = settledPromises\n .filter(settle => settle.status === 'fulfilled' && settle.value)\n .map(settle => settle.value);\n\n return fulfilledPromises\n}\n\n// @ts-check\n\n/**\n * @param {Object} args\n * @param {import('../models/FileSystem.js').FileSystem} args.fs\n * @param {string} args.gitdir\n * @param {string} args.path\n *\n * @returns {Promise<any>} Resolves with the config value\n *\n * @example\n * // Read config value\n * let value = await git.getConfig({\n * dir: '$input((/))',\n * path: '$input((user.name))'\n * })\n * console.log(value)\n *\n */\nasync function _getConfig({ fs, gitdir, path }) {\n const config = await GitConfigManager.get({ fs, gitdir });\n return config.get(path)\n}\n\n// Like Object.assign but ignore properties with undefined values\n// ref: https://stackoverflow.com/q/39513815\nfunction assignDefined(target, ...sources) {\n for (const source of sources) {\n if (source) {\n for (const key of Object.keys(source)) {\n const val = source[key];\n if (val !== undefined) {\n target[key] = val;\n }\n }\n }\n }\n return target\n}\n\n/**\n * Return author object by using properties following this priority:\n * (1) provided author object\n * -> (2) author of provided commit object\n * -> (3) Config and current date/time\n *\n * @param {Object} args\n * @param {FsClient} args.fs - a file system implementation\n * @param {string} [args.gitdir] - The [git directory](dir-vs-gitdir.md) path\n * @param {Object} [args.author] - The author object.\n * @param {CommitObject} [args.commit] - A commit object.\n *\n * @returns {Promise<void | {name: string, email: string, timestamp: number, timezoneOffset: number }>}\n */\nasync function normalizeAuthorObject({ fs, gitdir, author, commit }) {\n const timestamp = Math.floor(Date.now() / 1000);\n\n const defaultAuthor = {\n name: await _getConfig({ fs, gitdir, path: 'user.name' }),\n email: (await _getConfig({ fs, gitdir, path: 'user.email' })) || '', // author.email is allowed to be empty string\n timestamp,\n timezoneOffset: new Date(timestamp * 1000).getTimezoneOffset(),\n };\n\n // Populate author object by using properties with this priority:\n // (1) provided author object\n // -> (2) author of provided commit object\n // -> (3) default author\n const normalizedAuthor = assignDefined(\n {},\n defaultAuthor,\n commit ? commit.author : undefined,\n author\n );\n\n if (normalizedAuthor.name === undefined) {\n return undefined\n }\n\n return normalizedAuthor\n}\n\n/**\n * Return committer object by using properties with this priority:\n * (1) provided committer object\n * -> (2) provided author object\n * -> (3) committer of provided commit object\n * -> (4) Config and current date/time\n *\n * @param {Object} args\n * @param {FsClient} args.fs - a file system implementation\n * @param {string} [args.gitdir] - The [git directory](dir-vs-gitdir.md) path\n * @param {Object} [args.author] - The author object.\n * @param {Object} [args.committer] - The committer object.\n * @param {CommitObject} [args.commit] - A commit object.\n *\n * @returns {Promise<void | {name: string, email: string, timestamp: number, timezoneOffset: number }>}\n */\nasync function normalizeCommitterObject({\n fs,\n gitdir,\n author,\n committer,\n commit,\n}) {\n const timestamp = Math.floor(Date.now() / 1000);\n\n const defaultCommitter = {\n name: await _getConfig({ fs, gitdir, path: 'user.name' }),\n email: (await _getConfig({ fs, gitdir, path: 'user.email' })) || '', // committer.email is allowed to be empty string\n timestamp,\n timezoneOffset: new Date(timestamp * 1000).getTimezoneOffset(),\n };\n\n const normalizedCommitter = assignDefined(\n {},\n defaultCommitter,\n commit ? commit.committer : undefined,\n author,\n committer\n );\n\n if (normalizedCommitter.name === undefined) {\n return undefined\n }\n return normalizedCommitter\n}\n\nasync function resolveCommit({ fs, cache, gitdir, oid }) {\n const { type, object } = await _readObject({ fs, cache, gitdir, oid });\n // Resolve annotated tag objects to whatever\n if (type === 'tag') {\n oid = GitAnnotatedTag.from(object).parse().object;\n return resolveCommit({ fs, cache, gitdir, oid })\n }\n if (type !== 'commit') {\n throw new ObjectTypeError(oid, type, 'commit')\n }\n return { commit: GitCommit.from(object), oid }\n}\n\n// @ts-check\n\n/**\n * @param {object} args\n * @param {import('../models/FileSystem.js').FileSystem} args.fs\n * @param {any} args.cache\n * @param {string} args.gitdir\n * @param {string} args.oid\n *\n * @returns {Promise<ReadCommitResult>} Resolves successfully with a git commit object\n * @see ReadCommitResult\n * @see CommitObject\n *\n */\nasync function _readCommit({ fs, cache, gitdir, oid }) {\n const { commit, oid: commitOid } = await resolveCommit({\n fs,\n cache,\n gitdir,\n oid,\n });\n const result = {\n oid: commitOid,\n commit: commit.parse(),\n payload: commit.withoutSignature(),\n };\n // @ts-ignore\n return result\n}\n\n// @ts-check\n\n/**\n *\n * @param {Object} args\n * @param {import('../models/FileSystem.js').FileSystem} args.fs\n * @param {object} args.cache\n * @param {SignCallback} [args.onSign]\n * @param {string} args.gitdir\n * @param {string} [args.message]\n * @param {Object} [args.author]\n * @param {string} [args.author.name]\n * @param {string} [args.author.email]\n * @param {number} [args.author.timestamp]\n * @param {number} [args.author.timezoneOffset]\n * @param {Object} [args.committer]\n * @param {string} [args.committer.name]\n * @param {string} [args.committer.email]\n * @param {number} [args.committer.timestamp]\n * @param {number} [args.committer.timezoneOffset]\n * @param {string} [args.signingKey]\n * @param {boolean} [args.amend = false]\n * @param {boolean} [args.dryRun = false]\n * @param {boolean} [args.noUpdateBranch = false]\n * @param {string} [args.ref]\n * @param {string[]} [args.parent]\n * @param {string} [args.tree]\n *\n * @returns {Promise<string>} Resolves successfully with the SHA-1 object id of the newly created commit.\n */\nasync function _commit({\n fs,\n cache,\n onSign,\n gitdir,\n message,\n author: _author,\n committer: _committer,\n signingKey,\n amend = false,\n dryRun = false,\n noUpdateBranch = false,\n ref,\n parent,\n tree,\n}) {\n // Determine ref and the commit pointed to by ref, and if it is the initial commit\n let initialCommit = false;\n if (!ref) {\n ref = await GitRefManager.resolve({\n fs,\n gitdir,\n ref: 'HEAD',\n depth: 2,\n });\n }\n\n let refOid, refCommit;\n try {\n refOid = await GitRefManager.resolve({\n fs,\n gitdir,\n ref,\n });\n refCommit = await _readCommit({ fs, gitdir, oid: refOid, cache: {} });\n } catch {\n // We assume that there's no commit and this is the initial commit\n initialCommit = true;\n }\n\n if (amend && initialCommit) {\n throw new NoCommitError(ref)\n }\n\n // Determine author and committer information\n const author = !amend\n ? await normalizeAuthorObject({ fs, gitdir, author: _author })\n : await normalizeAuthorObject({\n fs,\n gitdir,\n author: _author,\n commit: refCommit.commit,\n });\n if (!author) throw new MissingNameError('author')\n\n const committer = !amend\n ? await normalizeCommitterObject({\n fs,\n gitdir,\n author,\n committer: _committer,\n })\n : await normalizeCommitterObject({\n fs,\n gitdir,\n author,\n committer: _committer,\n commit: refCommit.commit,\n });\n if (!committer) throw new MissingNameError('committer')\n\n return GitIndexManager.acquire(\n { fs, gitdir, cache, allowUnmerged: false },\n async function(index) {\n const inodes = flatFileListToDirectoryStructure(index.entries);\n const inode = inodes.get('.');\n if (!tree) {\n tree = await constructTree({ fs, gitdir, inode, dryRun });\n }\n\n // Determine parents of this commit\n if (!parent) {\n if (!amend) {\n parent = refOid ? [refOid] : [];\n } else {\n parent = refCommit.commit.parent;\n }\n } else {\n // ensure that the parents are oids, not refs\n parent = await Promise.all(\n parent.map(p => {\n return GitRefManager.resolve({ fs, gitdir, ref: p })\n })\n );\n }\n\n // Determine message of this commit\n if (!message) {\n if (!amend) {\n throw new MissingParameterError('message')\n } else {\n message = refCommit.commit.message;\n }\n }\n\n // Create and write new Commit object\n let comm = GitCommit.from({\n tree,\n parent,\n author,\n committer,\n message,\n });\n if (signingKey) {\n comm = await GitCommit.sign(comm, onSign, signingKey);\n }\n const oid = await _writeObject({\n fs,\n gitdir,\n type: 'commit',\n object: comm.toObject(),\n dryRun,\n });\n if (!noUpdateBranch && !dryRun) {\n // Update branch pointer\n await GitRefManager.writeRef({\n fs,\n gitdir,\n ref,\n value: oid,\n });\n }\n return oid\n }\n )\n}\n\nasync function constructTree({ fs, gitdir, inode, dryRun }) {\n // use depth first traversal\n const children = inode.children;\n for (const inode of children) {\n if (inode.type === 'tree') {\n inode.metadata.mode = '040000';\n inode.metadata.oid = await constructTree({ fs, gitdir, inode, dryRun });\n }\n }\n const entries = children.map(inode => ({\n mode: inode.metadata.mode,\n path: inode.basename,\n oid: inode.metadata.oid,\n type: inode.type,\n }));\n const tree = GitTree.from(entries);\n const oid = await _writeObject({\n fs,\n gitdir,\n type: 'tree',\n object: tree.toObject(),\n dryRun,\n });\n return oid\n}\n\n// @ts-check\n\nasync function resolveFilepath({ fs, cache, gitdir, oid, filepath }) {\n // Ensure there are no leading or trailing directory separators.\n // I was going to do this automatically, but then found that the Git Terminal for Windows\n // auto-expands --filepath=/src/utils to --filepath=C:/Users/Will/AppData/Local/Programs/Git/src/utils\n // so I figured it would be wise to promote the behavior in the application layer not just the library layer.\n if (filepath.startsWith('/')) {\n throw new InvalidFilepathError('leading-slash')\n } else if (filepath.endsWith('/')) {\n throw new InvalidFilepathError('trailing-slash')\n }\n const _oid = oid;\n const result = await resolveTree({ fs, cache, gitdir, oid });\n const tree = result.tree;\n if (filepath === '') {\n oid = result.oid;\n } else {\n const pathArray = filepath.split('/');\n oid = await _resolveFilepath({\n fs,\n cache,\n gitdir,\n tree,\n pathArray,\n oid: _oid,\n filepath,\n });\n }\n return oid\n}\n\nasync function _resolveFilepath({\n fs,\n cache,\n gitdir,\n tree,\n pathArray,\n oid,\n filepath,\n}) {\n const name = pathArray.shift();\n for (const entry of tree) {\n if (entry.path === name) {\n if (pathArray.length === 0) {\n return entry.oid\n } else {\n const { type, object } = await _readObject({\n fs,\n cache,\n gitdir,\n oid: entry.oid,\n });\n if (type !== 'tree') {\n throw new ObjectTypeError(oid, type, 'tree', filepath)\n }\n tree = GitTree.from(object);\n return _resolveFilepath({\n fs,\n cache,\n gitdir,\n tree,\n pathArray,\n oid,\n filepath,\n })\n }\n }\n }\n throw new NotFoundError(`file or directory found at \"${oid}:${filepath}\"`)\n}\n\n// @ts-check\n\n/**\n *\n * @typedef {Object} ReadTreeResult - The object returned has the following schema:\n * @property {string} oid - SHA-1 object id of this tree\n * @property {TreeObject} tree - the parsed tree object\n */\n\n/**\n * @param {object} args\n * @param {import('../models/FileSystem.js').FileSystem} args.fs\n * @param {any} args.cache\n * @param {string} args.gitdir\n * @param {string} args.oid\n * @param {string} [args.filepath]\n *\n * @returns {Promise<ReadTreeResult>}\n */\nasync function _readTree({\n fs,\n cache,\n gitdir,\n oid,\n filepath = undefined,\n}) {\n if (filepath !== undefined) {\n oid = await resolveFilepath({ fs, cache, gitdir, oid, filepath });\n }\n const { tree, oid: treeOid } = await resolveTree({ fs, cache, gitdir, oid });\n const result = {\n oid: treeOid,\n tree: tree.entries(),\n };\n return result\n}\n\n// @ts-check\n\n/**\n * @param {object} args\n * @param {import('../models/FileSystem.js').FileSystem} args.fs\n * @param {string} args.gitdir\n * @param {TreeObject} args.tree\n *\n * @returns {Promise<string>}\n */\nasync function _writeTree({ fs, gitdir, tree }) {\n // Convert object to buffer\n const object = GitTree.from(tree).toObject();\n const oid = await _writeObject({\n fs,\n gitdir,\n type: 'tree',\n object,\n format: 'content',\n });\n return oid\n}\n\n// @ts-check\n\n/**\n * @param {object} args\n * @param {import('../models/FileSystem.js').FileSystem} args.fs\n * @param {object} args.cache\n * @param {SignCallback} [args.onSign]\n * @param {string} args.gitdir\n * @param {string} args.ref\n * @param {string} args.oid\n * @param {string|Uint8Array} args.note\n * @param {boolean} [args.force]\n * @param {Object} args.author\n * @param {string} args.author.name\n * @param {string} args.author.email\n * @param {number} args.author.timestamp\n * @param {number} args.author.timezoneOffset\n * @param {Object} args.committer\n * @param {string} args.committer.name\n * @param {string} args.committer.email\n * @param {number} args.committer.timestamp\n * @param {number} args.committer.timezoneOffset\n * @param {string} [args.signingKey]\n *\n * @returns {Promise<string>}\n */\n\nasync function _addNote({\n fs,\n cache,\n onSign,\n gitdir,\n ref,\n oid,\n note,\n force,\n author,\n committer,\n signingKey,\n}) {\n // Get the current note commit\n let parent;\n try {\n parent = await GitRefManager.resolve({ gitdir, fs, ref });\n } catch (err) {\n if (!(err instanceof NotFoundError)) {\n throw err\n }\n }\n\n // I'm using the \"empty tree\" magic number here for brevity\n const result = await _readTree({\n fs,\n cache,\n gitdir,\n oid: parent || '4b825dc642cb6eb9a060e54bf8d69288fbee4904',\n });\n let tree = result.tree;\n\n // Handle the case where a note already exists\n if (force) {\n tree = tree.filter(entry => entry.path !== oid);\n } else {\n for (const entry of tree) {\n if (entry.path === oid) {\n throw new AlreadyExistsError('note', oid)\n }\n }\n }\n\n // Create the note blob\n if (typeof note === 'string') {\n note = Buffer.from(note, 'utf8');\n }\n const noteOid = await _writeObject({\n fs,\n gitdir,\n type: 'blob',\n object: note,\n format: 'content',\n });\n\n // Create the new note tree\n tree.push({ mode: '100644', path: oid, oid: noteOid, type: 'blob' });\n const treeOid = await _writeTree({\n fs,\n gitdir,\n tree,\n });\n\n // Create the new note commit\n const commitOid = await _commit({\n fs,\n cache,\n onSign,\n gitdir,\n ref,\n tree: treeOid,\n parent: parent && [parent],\n message: `Note added by 'isomorphic-git addNote'\\n`,\n author,\n committer,\n signingKey,\n });\n\n return commitOid\n}\n\n// @ts-check\n\n/**\n * Add or update an object note\n *\n * @param {object} args\n * @param {FsClient} args.fs - a file system implementation\n * @param {SignCallback} [args.onSign] - a PGP signing implementation\n * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {string} [args.ref] - The notes ref to look under\n * @param {string} args.oid - The SHA-1 object id of the object to add the note to.\n * @param {string|Uint8Array} args.note - The note to add\n * @param {boolean} [args.force] - Over-write note if it already exists.\n * @param {Object} [args.author] - The details about the author.\n * @param {string} [args.author.name] - Default is `user.name` config.\n * @param {string} [args.author.email] - Default is `user.email` config.\n * @param {number} [args.author.timestamp=Math.floor(Date.now()/1000)] - Set the author timestamp field. This is the integer number of seconds since the Unix epoch (1970-01-01 00:00:00).\n * @param {number} [args.author.timezoneOffset] - Set the author timezone offset field. This is the difference, in minutes, from the current timezone to UTC. Default is `(new Date()).getTimezoneOffset()`.\n * @param {Object} [args.committer = author] - The details about the note committer, in the same format as the author parameter. If not specified, the author details are used.\n * @param {string} [args.committer.name] - Default is `user.name` config.\n * @param {string} [args.committer.email] - Default is `user.email` config.\n * @param {number} [args.committer.timestamp=Math.floor(Date.now()/1000)] - Set the committer timestamp field. This is the integer number of seconds since the Unix epoch (1970-01-01 00:00:00).\n * @param {number} [args.committer.timezoneOffset] - Set the committer timezone offset field. This is the difference, in minutes, from the current timezone to UTC. Default is `(new Date()).getTimezoneOffset()`.\n * @param {string} [args.signingKey] - Sign the note commit using this private PGP key.\n * @param {object} [args.cache] - a [cache](cache.md) object\n *\n * @returns {Promise<string>} Resolves successfully with the SHA-1 object id of the commit object for the added note.\n */\n\nasync function addNote({\n fs: _fs,\n onSign,\n dir,\n gitdir = join(dir, '.git'),\n ref = 'refs/notes/commits',\n oid,\n note,\n force,\n author: _author,\n committer: _committer,\n signingKey,\n cache = {},\n}) {\n try {\n assertParameter('fs', _fs);\n assertParameter('gitdir', gitdir);\n assertParameter('oid', oid);\n assertParameter('note', note);\n if (signingKey) {\n assertParameter('onSign', onSign);\n }\n const fs = new FileSystem(_fs);\n\n const author = await normalizeAuthorObject({ fs, gitdir, author: _author });\n if (!author) throw new MissingNameError('author')\n\n const committer = await normalizeCommitterObject({\n fs,\n gitdir,\n author,\n committer: _committer,\n });\n if (!committer) throw new MissingNameError('committer')\n\n return await _addNote({\n fs: new FileSystem(fs),\n cache,\n onSign,\n gitdir,\n ref,\n oid,\n note,\n force,\n author,\n committer,\n signingKey,\n })\n } catch (err) {\n err.caller = 'git.addNote';\n throw err\n }\n}\n\n// @ts-check\n\n/**\n * @param {object} args\n * @param {import('../models/FileSystem.js').FileSystem} args.fs\n * @param {string} args.gitdir\n * @param {string} args.remote\n * @param {string} args.url\n * @param {boolean} args.force\n *\n * @returns {Promise<void>}\n *\n */\nasync function _addRemote({ fs, gitdir, remote, url, force }) {\n if (remote !== cleanGitRef.clean(remote)) {\n throw new InvalidRefNameError(remote, cleanGitRef.clean(remote))\n }\n const config = await GitConfigManager.get({ fs, gitdir });\n if (!force) {\n // Check that setting it wouldn't overwrite.\n const remoteNames = await config.getSubsections('remote');\n if (remoteNames.includes(remote)) {\n // Throw an error if it would overwrite an existing remote,\n // but not if it's simply setting the same value again.\n if (url !== (await config.get(`remote.${remote}.url`))) {\n throw new AlreadyExistsError('remote', remote)\n }\n }\n }\n await config.set(`remote.${remote}.url`, url);\n await config.set(\n `remote.${remote}.fetch`,\n `+refs/heads/*:refs/remotes/${remote}/*`\n );\n await GitConfigManager.save({ fs, gitdir, config });\n}\n\n// @ts-check\n\n/**\n * Add or update a remote\n *\n * @param {object} args\n * @param {FsClient} args.fs - a file system implementation\n * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {string} args.remote - The name of the remote\n * @param {string} args.url - The URL of the remote\n * @param {boolean} [args.force = false] - Instead of throwing an error if a remote named `remote` already exists, overwrite the existing remote.\n *\n * @returns {Promise<void>} Resolves successfully when filesystem operations are complete\n *\n * @example\n * await git.addRemote({\n * fs,\n * dir: '/tutorial',\n * remote: 'upstream',\n * url: 'https://github.com/isomorphic-git/isomorphic-git'\n * })\n * console.log('done')\n *\n */\nasync function addRemote({\n fs,\n dir,\n gitdir = join(dir, '.git'),\n remote,\n url,\n force = false,\n}) {\n try {\n assertParameter('fs', fs);\n assertParameter('gitdir', gitdir);\n assertParameter('remote', remote);\n assertParameter('url', url);\n return await _addRemote({\n fs: new FileSystem(fs),\n gitdir,\n remote,\n url,\n force,\n })\n } catch (err) {\n err.caller = 'git.addRemote';\n throw err\n }\n}\n\n// @ts-check\n\n/**\n * Create an annotated tag.\n *\n * @param {object} args\n * @param {import('../models/FileSystem.js').FileSystem} args.fs\n * @param {any} args.cache\n * @param {SignCallback} [args.onSign]\n * @param {string} args.gitdir\n * @param {string} args.ref\n * @param {string} [args.message = ref]\n * @param {string} [args.object = 'HEAD']\n * @param {object} [args.tagger]\n * @param {string} args.tagger.name\n * @param {string} args.tagger.email\n * @param {number} args.tagger.timestamp\n * @param {number} args.tagger.timezoneOffset\n * @param {string} [args.gpgsig]\n * @param {string} [args.signingKey]\n * @param {boolean} [args.force = false]\n *\n * @returns {Promise<void>} Resolves successfully when filesystem operations are complete\n *\n * @example\n * await git.annotatedTag({\n * dir: '$input((/))',\n * ref: '$input((test-tag))',\n * message: '$input((This commit is awesome))',\n * tagger: {\n * name: '$input((Mr. Test))',\n * email: '$input((mrtest@example.com))'\n * }\n * })\n * console.log('done')\n *\n */\nasync function _annotatedTag({\n fs,\n cache,\n onSign,\n gitdir,\n ref,\n tagger,\n message = ref,\n gpgsig,\n object,\n signingKey,\n force = false,\n}) {\n ref = ref.startsWith('refs/tags/') ? ref : `refs/tags/${ref}`;\n\n if (!force && (await GitRefManager.exists({ fs, gitdir, ref }))) {\n throw new AlreadyExistsError('tag', ref)\n }\n\n // Resolve passed value\n const oid = await GitRefManager.resolve({\n fs,\n gitdir,\n ref: object || 'HEAD',\n });\n\n const { type } = await _readObject({ fs, cache, gitdir, oid });\n let tagObject = GitAnnotatedTag.from({\n object: oid,\n type,\n tag: ref.replace('refs/tags/', ''),\n tagger,\n message,\n gpgsig,\n });\n if (signingKey) {\n tagObject = await GitAnnotatedTag.sign(tagObject, onSign, signingKey);\n }\n const value = await _writeObject({\n fs,\n gitdir,\n type: 'tag',\n object: tagObject.toObject(),\n });\n\n await GitRefManager.writeRef({ fs, gitdir, ref, value });\n}\n\n// @ts-check\n\n/**\n * Create an annotated tag.\n *\n * @param {object} args\n * @param {FsClient} args.fs - a file system implementation\n * @param {SignCallback} [args.onSign] - a PGP signing implementation\n * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {string} args.ref - What to name the tag\n * @param {string} [args.message = ref] - The tag message to use.\n * @param {string} [args.object = 'HEAD'] - The SHA-1 object id the tag points to. (Will resolve to a SHA-1 object id if value is a ref.) By default, the commit object which is referred by the current `HEAD` is used.\n * @param {object} [args.tagger] - The details about the tagger.\n * @param {string} [args.tagger.name] - Default is `user.name` config.\n * @param {string} [args.tagger.email] - Default is `user.email` config.\n * @param {number} [args.tagger.timestamp=Math.floor(Date.now()/1000)] - Set the tagger timestamp field. This is the integer number of seconds since the Unix epoch (1970-01-01 00:00:00).\n * @param {number} [args.tagger.timezoneOffset] - Set the tagger timezone offset field. This is the difference, in minutes, from the current timezone to UTC. Default is `(new Date()).getTimezoneOffset()`.\n * @param {string} [args.gpgsig] - The gpgsig attached to the tag object. (Mutually exclusive with the `signingKey` option.)\n * @param {string} [args.signingKey] - Sign the tag object using this private PGP key. (Mutually exclusive with the `gpgsig` option.)\n * @param {boolean} [args.force = false] - Instead of throwing an error if a tag named `ref` already exists, overwrite the existing tag. Note that this option does not modify the original tag object itself.\n * @param {object} [args.cache] - a [cache](cache.md) object\n *\n * @returns {Promise<void>} Resolves successfully when filesystem operations are complete\n *\n * @example\n * await git.annotatedTag({\n * fs,\n * dir: '/tutorial',\n * ref: 'test-tag',\n * message: 'This commit is awesome',\n * tagger: {\n * name: 'Mr. Test',\n * email: 'mrtest@example.com'\n * }\n * })\n * console.log('done')\n *\n */\nasync function annotatedTag({\n fs: _fs,\n onSign,\n dir,\n gitdir = join(dir, '.git'),\n ref,\n tagger: _tagger,\n message = ref,\n gpgsig,\n object,\n signingKey,\n force = false,\n cache = {},\n}) {\n try {\n assertParameter('fs', _fs);\n assertParameter('gitdir', gitdir);\n assertParameter('ref', ref);\n if (signingKey) {\n assertParameter('onSign', onSign);\n }\n const fs = new FileSystem(_fs);\n\n // Fill in missing arguments with default values\n const tagger = await normalizeAuthorObject({ fs, gitdir, author: _tagger });\n if (!tagger) throw new MissingNameError('tagger')\n\n return await _annotatedTag({\n fs,\n cache,\n onSign,\n gitdir,\n ref,\n tagger,\n message,\n gpgsig,\n object,\n signingKey,\n force,\n })\n } catch (err) {\n err.caller = 'git.annotatedTag';\n throw err\n }\n}\n\n// @ts-check\n\n/**\n * Create a branch\n *\n * @param {object} args\n * @param {import('../models/FileSystem.js').FileSystem} args.fs\n * @param {string} args.gitdir\n * @param {string} args.ref\n * @param {string} [args.object = 'HEAD']\n * @param {boolean} [args.checkout = false]\n * @param {boolean} [args.force = false]\n *\n * @returns {Promise<void>} Resolves successfully when filesystem operations are complete\n *\n * @example\n * await git.branch({ dir: '$input((/))', ref: '$input((develop))' })\n * console.log('done')\n *\n */\nasync function _branch({\n fs,\n gitdir,\n ref,\n object,\n checkout = false,\n force = false,\n}) {\n if (ref !== cleanGitRef.clean(ref)) {\n throw new InvalidRefNameError(ref, cleanGitRef.clean(ref))\n }\n\n const fullref = `refs/heads/${ref}`;\n\n if (!force) {\n const exist = await GitRefManager.exists({ fs, gitdir, ref: fullref });\n if (exist) {\n throw new AlreadyExistsError('branch', ref, false)\n }\n }\n\n // Get current HEAD tree oid\n let oid;\n try {\n oid = await GitRefManager.resolve({ fs, gitdir, ref: object || 'HEAD' });\n } catch (e) {\n // Probably an empty repo\n }\n\n // Create a new ref that points at the current commit\n if (oid) {\n await GitRefManager.writeRef({ fs, gitdir, ref: fullref, value: oid });\n }\n\n if (checkout) {\n // Update HEAD\n await GitRefManager.writeSymbolicRef({\n fs,\n gitdir,\n ref: 'HEAD',\n value: fullref,\n });\n }\n}\n\n// @ts-check\n\n/**\n * Create a branch\n *\n * @param {object} args\n * @param {FsClient} args.fs - a file system implementation\n * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {string} args.ref - What to name the branch\n * @param {string} [args.object = 'HEAD'] - What oid to use as the start point. Accepts a symbolic ref.\n * @param {boolean} [args.checkout = false] - Update `HEAD` to point at the newly created branch\n * @param {boolean} [args.force = false] - Instead of throwing an error if a branched named `ref` already exists, overwrite the existing branch.\n *\n * @returns {Promise<void>} Resolves successfully when filesystem operations are complete\n *\n * @example\n * await git.branch({ fs, dir: '/tutorial', ref: 'develop' })\n * console.log('done')\n *\n */\nasync function branch({\n fs,\n dir,\n gitdir = join(dir, '.git'),\n ref,\n object,\n checkout = false,\n force = false,\n}) {\n try {\n assertParameter('fs', fs);\n assertParameter('gitdir', gitdir);\n assertParameter('ref', ref);\n return await _branch({\n fs: new FileSystem(fs),\n gitdir,\n ref,\n object,\n checkout,\n force,\n })\n } catch (err) {\n err.caller = 'git.branch';\n throw err\n }\n}\n\nconst worthWalking = (filepath, root) => {\n if (filepath === '.' || root == null || root.length === 0 || root === '.') {\n return true\n }\n if (root.length >= filepath.length) {\n return root.startsWith(filepath)\n } else {\n return filepath.startsWith(root)\n }\n};\n\n// @ts-check\n\n/**\n * @param {object} args\n * @param {import('../models/FileSystem.js').FileSystem} args.fs\n * @param {any} args.cache\n * @param {ProgressCallback} [args.onProgress]\n * @param {PostCheckoutCallback} [args.onPostCheckout]\n * @param {string} args.dir\n * @param {string} args.gitdir\n * @param {string} args.ref\n * @param {string[]} [args.filepaths]\n * @param {string} args.remote\n * @param {boolean} args.noCheckout\n * @param {boolean} [args.noUpdateHead]\n * @param {boolean} [args.dryRun]\n * @param {boolean} [args.force]\n * @param {boolean} [args.track]\n *\n * @returns {Promise<void>} Resolves successfully when filesystem operations are complete\n *\n */\nasync function _checkout({\n fs,\n cache,\n onProgress,\n onPostCheckout,\n dir,\n gitdir,\n remote,\n ref,\n filepaths,\n noCheckout,\n noUpdateHead,\n dryRun,\n force,\n track = true,\n}) {\n // oldOid is defined only if onPostCheckout hook is attached\n let oldOid;\n if (onPostCheckout) {\n try {\n oldOid = await GitRefManager.resolve({ fs, gitdir, ref: 'HEAD' });\n } catch (err) {\n oldOid = '0000000000000000000000000000000000000000';\n }\n }\n\n // Get tree oid\n let oid;\n try {\n oid = await GitRefManager.resolve({ fs, gitdir, ref });\n // TODO: Figure out what to do if both 'ref' and 'remote' are specified, ref already exists,\n // and is configured to track a different remote.\n } catch (err) {\n if (ref === 'HEAD') throw err\n // If `ref` doesn't exist, create a new remote tracking branch\n // Figure out the commit to checkout\n const remoteRef = `${remote}/${ref}`;\n oid = await GitRefManager.resolve({\n fs,\n gitdir,\n ref: remoteRef,\n });\n if (track) {\n // Set up remote tracking branch\n const config = await GitConfigManager.get({ fs, gitdir });\n await config.set(`branch.${ref}.remote`, remote);\n await config.set(`branch.${ref}.merge`, `refs/heads/${ref}`);\n await GitConfigManager.save({ fs, gitdir, config });\n }\n // Create a new branch that points at that same commit\n await GitRefManager.writeRef({\n fs,\n gitdir,\n ref: `refs/heads/${ref}`,\n value: oid,\n });\n }\n\n // Update working dir\n if (!noCheckout) {\n let ops;\n // First pass - just analyze files (not directories) and figure out what needs to be done\n try {\n ops = await analyze({\n fs,\n cache,\n onProgress,\n dir,\n gitdir,\n ref,\n force,\n filepaths,\n });\n } catch (err) {\n // Throw a more helpful error message for this common mistake.\n if (err instanceof NotFoundError && err.data.what === oid) {\n throw new CommitNotFetchedError(ref, oid)\n } else {\n throw err\n }\n }\n\n // Report conflicts\n const conflicts = ops\n .filter(([method]) => method === 'conflict')\n .map(([method, fullpath]) => fullpath);\n if (conflicts.length > 0) {\n throw new CheckoutConflictError(conflicts)\n }\n\n // Collect errors\n const errors = ops\n .filter(([method]) => method === 'error')\n .map(([method, fullpath]) => fullpath);\n if (errors.length > 0) {\n throw new InternalError(errors.join(', '))\n }\n\n if (dryRun) {\n // Since the format of 'ops' is in flux, I really would rather folk besides myself not start relying on it\n // return ops\n\n if (onPostCheckout) {\n await onPostCheckout({\n previousHead: oldOid,\n newHead: oid,\n type: filepaths != null && filepaths.length > 0 ? 'file' : 'branch',\n });\n }\n return\n }\n\n // Second pass - execute planned changes\n // The cheapest semi-parallel solution without computing a full dependency graph will be\n // to just do ops in 4 dumb phases: delete files, delete dirs, create dirs, write files\n\n let count = 0;\n const total = ops.length;\n await GitIndexManager.acquire({ fs, gitdir, cache }, async function(index) {\n await Promise.all(\n ops\n .filter(\n ([method]) => method === 'delete' || method === 'delete-index'\n )\n .map(async function([method, fullpath]) {\n const filepath = `${dir}/${fullpath}`;\n if (method === 'delete') {\n await fs.rm(filepath);\n }\n index.delete({ filepath: fullpath });\n if (onProgress) {\n await onProgress({\n phase: 'Updating workdir',\n loaded: ++count,\n total,\n });\n }\n })\n );\n });\n\n // Note: this is cannot be done naively in parallel\n await GitIndexManager.acquire({ fs, gitdir, cache }, async function(index) {\n for (const [method, fullpath] of ops) {\n if (method === 'rmdir' || method === 'rmdir-index') {\n const filepath = `${dir}/${fullpath}`;\n try {\n if (method === 'rmdir-index') {\n index.delete({ filepath: fullpath });\n }\n await fs.rmdir(filepath);\n if (onProgress) {\n await onProgress({\n phase: 'Updating workdir',\n loaded: ++count,\n total,\n });\n }\n } catch (e) {\n if (e.code === 'ENOTEMPTY') {\n console.log(\n `Did not delete ${fullpath} because directory is not empty`\n );\n } else {\n throw e\n }\n }\n }\n }\n });\n\n await Promise.all(\n ops\n .filter(([method]) => method === 'mkdir' || method === 'mkdir-index')\n .map(async function([_, fullpath]) {\n const filepath = `${dir}/${fullpath}`;\n await fs.mkdir(filepath);\n if (onProgress) {\n await onProgress({\n phase: 'Updating workdir',\n loaded: ++count,\n total,\n });\n }\n })\n );\n\n await GitIndexManager.acquire({ fs, gitdir, cache }, async function(index) {\n await Promise.all(\n ops\n .filter(\n ([method]) =>\n method === 'create' ||\n method === 'create-index' ||\n method === 'update' ||\n method === 'mkdir-index'\n )\n .map(async function([method, fullpath, oid, mode, chmod]) {\n const filepath = `${dir}/${fullpath}`;\n try {\n if (method !== 'create-index' && method !== 'mkdir-index') {\n const { object } = await _readObject({ fs, cache, gitdir, oid });\n if (chmod) {\n // Note: the mode option of fs.write only works when creating files,\n // not updating them. Since the `fs` plugin doesn't expose `chmod` this\n // is our only option.\n await fs.rm(filepath);\n }\n if (mode === 0o100644) {\n // regular file\n await fs.write(filepath, object);\n } else if (mode === 0o100755) {\n // executable file\n await fs.write(filepath, object, { mode: 0o777 });\n } else if (mode === 0o120000) {\n // symlink\n await fs.writelink(filepath, object);\n } else {\n throw new InternalError(\n `Invalid mode 0o${mode.toString(8)} detected in blob ${oid}`\n )\n }\n }\n\n const stats = await fs.lstat(filepath);\n // We can't trust the executable bit returned by lstat on Windows,\n // so we need to preserve this value from the TREE.\n // TODO: Figure out how git handles this internally.\n if (mode === 0o100755) {\n stats.mode = 0o755;\n }\n // Submodules are present in the git index but use a unique mode different from trees\n if (method === 'mkdir-index') {\n stats.mode = 0o160000;\n }\n index.insert({\n filepath: fullpath,\n stats,\n oid,\n });\n if (onProgress) {\n await onProgress({\n phase: 'Updating workdir',\n loaded: ++count,\n total,\n });\n }\n } catch (e) {\n console.log(e);\n }\n })\n );\n });\n\n if (onPostCheckout) {\n await onPostCheckout({\n previousHead: oldOid,\n newHead: oid,\n type: filepaths != null && filepaths.length > 0 ? 'file' : 'branch',\n });\n }\n }\n\n // Update HEAD\n if (!noUpdateHead) {\n const fullRef = await GitRefManager.expand({ fs, gitdir, ref });\n if (fullRef.startsWith('refs/heads')) {\n await GitRefManager.writeSymbolicRef({\n fs,\n gitdir,\n ref: 'HEAD',\n value: fullRef,\n });\n } else {\n // detached head\n await GitRefManager.writeRef({ fs, gitdir, ref: 'HEAD', value: oid });\n }\n }\n}\n\nasync function analyze({\n fs,\n cache,\n onProgress,\n dir,\n gitdir,\n ref,\n force,\n filepaths,\n}) {\n let count = 0;\n return _walk({\n fs,\n cache,\n dir,\n gitdir,\n trees: [TREE({ ref }), WORKDIR(), STAGE()],\n map: async function(fullpath, [commit, workdir, stage]) {\n if (fullpath === '.') return\n // match against base paths\n if (filepaths && !filepaths.some(base => worthWalking(fullpath, base))) {\n return null\n }\n // Emit progress event\n if (onProgress) {\n await onProgress({ phase: 'Analyzing workdir', loaded: ++count });\n }\n\n // This is a kind of silly pattern but it worked so well for me in the past\n // and it makes intuitively demonstrating exhaustiveness so *easy*.\n // This checks for the presence and/or absence of each of the 3 entries,\n // converts that to a 3-bit binary representation, and then handles\n // every possible combination (2^3 or 8 cases) with a lookup table.\n const key = [!!stage, !!commit, !!workdir].map(Number).join('');\n switch (key) {\n // Impossible case.\n case '000':\n return\n // Ignore workdir files that are not tracked and not part of the new commit.\n case '001':\n // OK, make an exception for explicitly named files.\n if (force && filepaths && filepaths.includes(fullpath)) {\n return ['delete', fullpath]\n }\n return\n // New entries\n case '010': {\n switch (await commit.type()) {\n case 'tree': {\n return ['mkdir', fullpath]\n }\n case 'blob': {\n return [\n 'create',\n fullpath,\n await commit.oid(),\n await commit.mode(),\n ]\n }\n case 'commit': {\n return [\n 'mkdir-index',\n fullpath,\n await commit.oid(),\n await commit.mode(),\n ]\n }\n default: {\n return [\n 'error',\n `new entry Unhandled type ${await commit.type()}`,\n ]\n }\n }\n }\n // New entries but there is already something in the workdir there.\n case '011': {\n switch (`${await commit.type()}-${await workdir.type()}`) {\n case 'tree-tree': {\n return // noop\n }\n case 'tree-blob':\n case 'blob-tree': {\n return ['conflict', fullpath]\n }\n case 'blob-blob': {\n // Is the incoming file different?\n if ((await commit.oid()) !== (await workdir.oid())) {\n if (force) {\n return [\n 'update',\n fullpath,\n await commit.oid(),\n await commit.mode(),\n (await commit.mode()) !== (await workdir.mode()),\n ]\n } else {\n return ['conflict', fullpath]\n }\n } else {\n // Is the incoming file a different mode?\n if ((await commit.mode()) !== (await workdir.mode())) {\n if (force) {\n return [\n 'update',\n fullpath,\n await commit.oid(),\n await commit.mode(),\n true,\n ]\n } else {\n return ['conflict', fullpath]\n }\n } else {\n return [\n 'create-index',\n fullpath,\n await commit.oid(),\n await commit.mode(),\n ]\n }\n }\n }\n case 'commit-tree': {\n // TODO: submodule\n // We'll ignore submodule directories for now.\n // Users prefer we not throw an error for lack of submodule support.\n // gitlinks\n return\n }\n case 'commit-blob': {\n // TODO: submodule\n // But... we'll complain if there is a *file* where we would\n // put a submodule if we had submodule support.\n return ['conflict', fullpath]\n }\n default: {\n return ['error', `new entry Unhandled type ${commit.type}`]\n }\n }\n }\n // Something in stage but not in the commit OR the workdir.\n // Note: I verified this behavior against canonical git.\n case '100': {\n return ['delete-index', fullpath]\n }\n // Deleted entries\n // TODO: How to handle if stage type and workdir type mismatch?\n case '101': {\n switch (await stage.type()) {\n case 'tree': {\n return ['rmdir', fullpath]\n }\n case 'blob': {\n // Git checks that the workdir.oid === stage.oid before deleting file\n if ((await stage.oid()) !== (await workdir.oid())) {\n if (force) {\n return ['delete', fullpath]\n } else {\n return ['conflict', fullpath]\n }\n } else {\n return ['delete', fullpath]\n }\n }\n case 'commit': {\n return ['rmdir-index', fullpath]\n }\n default: {\n return [\n 'error',\n `delete entry Unhandled type ${await stage.type()}`,\n ]\n }\n }\n }\n /* eslint-disable no-fallthrough */\n // File missing from workdir\n case '110':\n // Possibly modified entries\n case '111': {\n /* eslint-enable no-fallthrough */\n switch (`${await stage.type()}-${await commit.type()}`) {\n case 'tree-tree': {\n return\n }\n case 'blob-blob': {\n // If the file hasn't changed, there is no need to do anything.\n // Existing file modifications in the workdir can be be left as is.\n if (\n (await stage.oid()) === (await commit.oid()) &&\n (await stage.mode()) === (await commit.mode()) &&\n !force\n ) {\n return\n }\n\n // Check for local changes that would be lost\n if (workdir) {\n // Note: canonical git only compares with the stage. But we're smart enough\n // to compare to the stage AND the incoming commit.\n if (\n (await workdir.oid()) !== (await stage.oid()) &&\n (await workdir.oid()) !== (await commit.oid())\n ) {\n if (force) {\n return [\n 'update',\n fullpath,\n await commit.oid(),\n await commit.mode(),\n (await commit.mode()) !== (await workdir.mode()),\n ]\n } else {\n return ['conflict', fullpath]\n }\n }\n } else if (force) {\n return [\n 'update',\n fullpath,\n await commit.oid(),\n await commit.mode(),\n (await commit.mode()) !== (await stage.mode()),\n ]\n }\n // Has file mode changed?\n if ((await commit.mode()) !== (await stage.mode())) {\n return [\n 'update',\n fullpath,\n await commit.oid(),\n await commit.mode(),\n true,\n ]\n }\n // TODO: HANDLE SYMLINKS\n // Has the file content changed?\n if ((await commit.oid()) !== (await stage.oid())) {\n return [\n 'update',\n fullpath,\n await commit.oid(),\n await commit.mode(),\n false,\n ]\n } else {\n return\n }\n }\n case 'tree-blob': {\n return ['update-dir-to-blob', fullpath, await commit.oid()]\n }\n case 'blob-tree': {\n return ['update-blob-to-tree', fullpath]\n }\n case 'commit-commit': {\n return [\n 'mkdir-index',\n fullpath,\n await commit.oid(),\n await commit.mode(),\n ]\n }\n default: {\n return [\n 'error',\n `update entry Unhandled type ${await stage.type()}-${await commit.type()}`,\n ]\n }\n }\n }\n }\n },\n // Modify the default flat mapping\n reduce: async function(parent, children) {\n children = flat(children);\n if (!parent) {\n return children\n } else if (parent && parent[0] === 'rmdir') {\n children.push(parent);\n return children\n } else {\n children.unshift(parent);\n return children\n }\n },\n })\n}\n\n// @ts-check\n\n/**\n * Checkout a branch\n *\n * If the branch already exists it will check out that branch. Otherwise, it will create a new remote tracking branch set to track the remote branch of that name.\n *\n * @param {object} args\n * @param {FsClient} args.fs - a file system implementation\n * @param {ProgressCallback} [args.onProgress] - optional progress event callback\n * @param {PostCheckoutCallback} [args.onPostCheckout] - optional post-checkout hook callback\n * @param {string} args.dir - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {string} [args.ref = 'HEAD'] - Source to checkout files from\n * @param {string[]} [args.filepaths] - Limit the checkout to the given files and directories\n * @param {string} [args.remote = 'origin'] - Which remote repository to use\n * @param {boolean} [args.noCheckout = false] - If true, will update HEAD but won't update the working directory\n * @param {boolean} [args.noUpdateHead] - If true, will update the working directory but won't update HEAD. Defaults to `false` when `ref` is provided, and `true` if `ref` is not provided.\n * @param {boolean} [args.dryRun = false] - If true, simulates a checkout so you can test whether it would succeed.\n * @param {boolean} [args.force = false] - If true, conflicts will be ignored and files will be overwritten regardless of local changes.\n * @param {boolean} [args.track = true] - If false, will not set the remote branch tracking information. Defaults to true.\n * @param {object} [args.cache] - a [cache](cache.md) object\n *\n * @returns {Promise<void>} Resolves successfully when filesystem operations are complete\n *\n * @example\n * // switch to the main branch\n * await git.checkout({\n * fs,\n * dir: '/tutorial',\n * ref: 'main'\n * })\n * console.log('done')\n *\n * @example\n * // restore the 'docs' and 'src/docs' folders to the way they were, overwriting any changes\n * await git.checkout({\n * fs,\n * dir: '/tutorial',\n * force: true,\n * filepaths: ['docs', 'src/docs']\n * })\n * console.log('done')\n *\n * @example\n * // restore the 'docs' and 'src/docs' folders to the way they are in the 'develop' branch, overwriting any changes\n * await git.checkout({\n * fs,\n * dir: '/tutorial',\n * ref: 'develop',\n * noUpdateHead: true,\n * force: true,\n * filepaths: ['docs', 'src/docs']\n * })\n * console.log('done')\n */\nasync function checkout({\n fs,\n onProgress,\n onPostCheckout,\n dir,\n gitdir = join(dir, '.git'),\n remote = 'origin',\n ref: _ref,\n filepaths,\n noCheckout = false,\n noUpdateHead = _ref === undefined,\n dryRun = false,\n force = false,\n track = true,\n cache = {},\n}) {\n try {\n assertParameter('fs', fs);\n assertParameter('dir', dir);\n assertParameter('gitdir', gitdir);\n\n const ref = _ref || 'HEAD';\n return await _checkout({\n fs: new FileSystem(fs),\n cache,\n onProgress,\n onPostCheckout,\n dir,\n gitdir,\n remote,\n ref,\n filepaths,\n noCheckout,\n noUpdateHead,\n dryRun,\n force,\n track,\n })\n } catch (err) {\n err.caller = 'git.checkout';\n throw err\n }\n}\n\n// @see https://git-scm.com/docs/git-rev-parse.html#_specifying_revisions\nconst abbreviateRx = new RegExp('^refs/(heads/|tags/|remotes/)?(.*)');\n\nfunction abbreviateRef(ref) {\n const match = abbreviateRx.exec(ref);\n if (match) {\n if (match[1] === 'remotes/' && ref.endsWith('/HEAD')) {\n return match[2].slice(0, -5)\n } else {\n return match[2]\n }\n }\n return ref\n}\n\n// @ts-check\n\n/**\n * @param {Object} args\n * @param {import('../models/FileSystem.js').FileSystem} args.fs\n * @param {string} args.gitdir\n * @param {boolean} [args.fullname = false] - Return the full path (e.g. \"refs/heads/main\") instead of the abbreviated form.\n * @param {boolean} [args.test = false] - If the current branch doesn't actually exist (such as right after git init) then return `undefined`.\n *\n * @returns {Promise<string|void>} The name of the current branch or undefined if the HEAD is detached.\n *\n */\nasync function _currentBranch({\n fs,\n gitdir,\n fullname = false,\n test = false,\n}) {\n const ref = await GitRefManager.resolve({\n fs,\n gitdir,\n ref: 'HEAD',\n depth: 2,\n });\n if (test) {\n try {\n await GitRefManager.resolve({ fs, gitdir, ref });\n } catch (_) {\n return\n }\n }\n // Return `undefined` for detached HEAD\n if (!ref.startsWith('refs/')) return\n return fullname ? ref : abbreviateRef(ref)\n}\n\nfunction translateSSHtoHTTP(url) {\n // handle \"shorter scp-like syntax\"\n url = url.replace(/^git@([^:]+):/, 'https://$1/');\n // handle proper SSH URLs\n url = url.replace(/^ssh:\\/\\//, 'https://');\n return url\n}\n\nfunction calculateBasicAuthHeader({ username = '', password = '' }) {\n return `Basic ${Buffer.from(`${username}:${password}`).toString('base64')}`\n}\n\n// Currently 'for await' upsets my linters.\nasync function forAwait(iterable, cb) {\n const iter = getIterator(iterable);\n while (true) {\n const { value, done } = await iter.next();\n if (value) await cb(value);\n if (done) break\n }\n if (iter.return) iter.return();\n}\n\nasync function collect(iterable) {\n let size = 0;\n const buffers = [];\n // This will be easier once `for await ... of` loops are available.\n await forAwait(iterable, value => {\n buffers.push(value);\n size += value.byteLength;\n });\n const result = new Uint8Array(size);\n let nextIndex = 0;\n for (const buffer of buffers) {\n result.set(buffer, nextIndex);\n nextIndex += buffer.byteLength;\n }\n return result\n}\n\nfunction extractAuthFromUrl(url) {\n // For whatever reason, the `fetch` API does not convert credentials embedded in the URL\n // into Basic Authentication headers automatically. Instead it throws an error!\n // So we must manually parse the URL, rip out the user:password portion if it is present\n // and compute the Authorization header.\n // Note: I tried using new URL(url) but that throws a security exception in Edge. :rolleyes:\n let userpass = url.match(/^https?:\\/\\/([^/]+)@/);\n // No credentials, return the url unmodified and an empty auth object\n if (userpass == null) return { url, auth: {} }\n userpass = userpass[1];\n const [username, password] = userpass.split(':');\n // Remove credentials from URL\n url = url.replace(`${userpass}@`, '');\n // Has credentials, return the fetch-safe URL and the parsed credentials\n return { url, auth: { username, password } }\n}\n\nfunction padHex(b, n) {\n const s = n.toString(16);\n return '0'.repeat(b - s.length) + s\n}\n\n/**\npkt-line Format\n---------------\n\nMuch (but not all) of the payload is described around pkt-lines.\n\nA pkt-line is a variable length binary string. The first four bytes\nof the line, the pkt-len, indicates the total length of the line,\nin hexadecimal. The pkt-len includes the 4 bytes used to contain\nthe length's hexadecimal representation.\n\nA pkt-line MAY contain binary data, so implementers MUST ensure\npkt-line parsing/formatting routines are 8-bit clean.\n\nA non-binary line SHOULD BE terminated by an LF, which if present\nMUST be included in the total length. Receivers MUST treat pkt-lines\nwith non-binary data the same whether or not they contain the trailing\nLF (stripping the LF if present, and not complaining when it is\nmissing).\n\nThe maximum length of a pkt-line's data component is 65516 bytes.\nImplementations MUST NOT send pkt-line whose length exceeds 65520\n(65516 bytes of payload + 4 bytes of length data).\n\nImplementations SHOULD NOT send an empty pkt-line (\"0004\").\n\nA pkt-line with a length field of 0 (\"0000\"), called a flush-pkt,\nis a special case and MUST be handled differently than an empty\npkt-line (\"0004\").\n\n----\n pkt-line = data-pkt / flush-pkt\n\n data-pkt = pkt-len pkt-payload\n pkt-len = 4*(HEXDIG)\n pkt-payload = (pkt-len - 4)*(OCTET)\n\n flush-pkt = \"0000\"\n----\n\nExamples (as C-style strings):\n\n----\n pkt-line actual value\n ---------------------------------\n \"0006a\\n\" \"a\\n\"\n \"0005a\" \"a\"\n \"000bfoobar\\n\" \"foobar\\n\"\n \"0004\" \"\"\n----\n*/\n\n// I'm really using this more as a namespace.\n// There's not a lot of \"state\" in a pkt-line\n\nclass GitPktLine {\n static flush() {\n return Buffer.from('0000', 'utf8')\n }\n\n static delim() {\n return Buffer.from('0001', 'utf8')\n }\n\n static encode(line) {\n if (typeof line === 'string') {\n line = Buffer.from(line);\n }\n const length = line.length + 4;\n const hexlength = padHex(4, length);\n return Buffer.concat([Buffer.from(hexlength, 'utf8'), line])\n }\n\n static streamReader(stream) {\n const reader = new StreamReader(stream);\n return async function read() {\n try {\n let length = await reader.read(4);\n if (length == null) return true\n length = parseInt(length.toString('utf8'), 16);\n if (length === 0) return null\n if (length === 1) return null // delim packets\n const buffer = await reader.read(length - 4);\n if (buffer == null) return true\n return buffer\n } catch (err) {\n stream.error = err;\n return true\n }\n }\n }\n}\n\n// @ts-check\n\n/**\n * @param {function} read\n */\nasync function parseCapabilitiesV2(read) {\n /** @type {Object<string, string | true>} */\n const capabilities2 = {};\n\n let line;\n while (true) {\n line = await read();\n if (line === true) break\n if (line === null) continue\n line = line.toString('utf8').replace(/\\n$/, '');\n const i = line.indexOf('=');\n if (i > -1) {\n const key = line.slice(0, i);\n const value = line.slice(i + 1);\n capabilities2[key] = value;\n } else {\n capabilities2[line] = true;\n }\n }\n return { protocolVersion: 2, capabilities2 }\n}\n\nasync function parseRefsAdResponse(stream, { service }) {\n const capabilities = new Set();\n const refs = new Map();\n const symrefs = new Map();\n\n // There is probably a better way to do this, but for now\n // let's just throw the result parser inline here.\n const read = GitPktLine.streamReader(stream);\n let lineOne = await read();\n // skip past any flushes\n while (lineOne === null) lineOne = await read();\n\n if (lineOne === true) throw new EmptyServerResponseError()\n\n // Handle protocol v2 responses (Bitbucket Server doesn't include a `# service=` line)\n if (lineOne.includes('version 2')) {\n return parseCapabilitiesV2(read)\n }\n\n // Clients MUST ignore an LF at the end of the line.\n if (lineOne.toString('utf8').replace(/\\n$/, '') !== `# service=${service}`) {\n throw new ParseError(`# service=${service}\\\\n`, lineOne.toString('utf8'))\n }\n let lineTwo = await read();\n // skip past any flushes\n while (lineTwo === null) lineTwo = await read();\n // In the edge case of a brand new repo, zero refs (and zero capabilities)\n // are returned.\n if (lineTwo === true) return { capabilities, refs, symrefs }\n lineTwo = lineTwo.toString('utf8');\n\n // Handle protocol v2 responses\n if (lineTwo.includes('version 2')) {\n return parseCapabilitiesV2(read)\n }\n\n const [firstRef, capabilitiesLine] = splitAndAssert(lineTwo, '\\x00', '\\\\x00');\n capabilitiesLine.split(' ').map(x => capabilities.add(x));\n // see no-refs in https://git-scm.com/docs/pack-protocol#_reference_discovery (since git 2.41.0)\n if (firstRef !== '0000000000000000000000000000000000000000 capabilities^{}') {\n const [ref, name] = splitAndAssert(firstRef, ' ', ' ');\n refs.set(name, ref);\n while (true) {\n const line = await read();\n if (line === true) break\n if (line !== null) {\n const [ref, name] = splitAndAssert(line.toString('utf8'), ' ', ' ');\n refs.set(name, ref);\n }\n }\n }\n // Symrefs are thrown into the \"capabilities\" unfortunately.\n for (const cap of capabilities) {\n if (cap.startsWith('symref=')) {\n const m = cap.match(/symref=([^:]+):(.*)/);\n if (m.length === 3) {\n symrefs.set(m[1], m[2]);\n }\n }\n }\n return { protocolVersion: 1, capabilities, refs, symrefs }\n}\n\nfunction splitAndAssert(line, sep, expected) {\n const split = line.trim().split(sep);\n if (split.length !== 2) {\n throw new ParseError(\n `Two strings separated by '${expected}'`,\n line.toString('utf8')\n )\n }\n return split\n}\n\n// Try to accommodate known CORS proxy implementations:\n// - https://jcubic.pl/proxy.php? <-- uses query string\n// - https://cors.isomorphic-git.org <-- uses path\nconst corsProxify = (corsProxy, url) =>\n corsProxy.endsWith('?')\n ? `${corsProxy}${url}`\n : `${corsProxy}/${url.replace(/^https?:\\/\\//, '')}`;\n\nconst updateHeaders = (headers, auth) => {\n // Update the basic auth header\n if (auth.username || auth.password) {\n headers.Authorization = calculateBasicAuthHeader(auth);\n }\n // but any manually provided headers take precedence\n if (auth.headers) {\n Object.assign(headers, auth.headers);\n }\n};\n\n/**\n * @param {GitHttpResponse} res\n *\n * @returns {{ preview: string, response: string, data: Buffer }}\n */\nconst stringifyBody = async res => {\n try {\n // Some services provide a meaningful error message in the body of 403s like \"token lacks the scopes necessary to perform this action\"\n const data = Buffer.from(await collect(res.body));\n const response = data.toString('utf8');\n const preview =\n response.length < 256 ? response : response.slice(0, 256) + '...';\n return { preview, response, data }\n } catch (e) {\n return {}\n }\n};\n\nclass GitRemoteHTTP {\n static async capabilities() {\n return ['discover', 'connect']\n }\n\n /**\n * @param {Object} args\n * @param {HttpClient} args.http\n * @param {ProgressCallback} [args.onProgress]\n * @param {AuthCallback} [args.onAuth]\n * @param {AuthFailureCallback} [args.onAuthFailure]\n * @param {AuthSuccessCallback} [args.onAuthSuccess]\n * @param {string} [args.corsProxy]\n * @param {string} args.service\n * @param {string} args.url\n * @param {Object<string, string>} args.headers\n * @param {1 | 2} args.protocolVersion - Git Protocol Version\n */\n static async discover({\n http,\n onProgress,\n onAuth,\n onAuthSuccess,\n onAuthFailure,\n corsProxy,\n service,\n url: _origUrl,\n headers,\n protocolVersion,\n }) {\n let { url, auth } = extractAuthFromUrl(_origUrl);\n const proxifiedURL = corsProxy ? corsProxify(corsProxy, url) : url;\n if (auth.username || auth.password) {\n headers.Authorization = calculateBasicAuthHeader(auth);\n }\n if (protocolVersion === 2) {\n headers['Git-Protocol'] = 'version=2';\n }\n\n let res;\n let tryAgain;\n let providedAuthBefore = false;\n do {\n res = await http.request({\n onProgress,\n method: 'GET',\n url: `${proxifiedURL}/info/refs?service=${service}`,\n headers,\n });\n\n // the default loop behavior\n tryAgain = false;\n\n // 401 is the \"correct\" response for access denied. 203 is Non-Authoritative Information and comes from Azure DevOps, which\n // apparently doesn't realize this is a git request and is returning the HTML for the \"Azure DevOps Services | Sign In\" page.\n if (res.statusCode === 401 || res.statusCode === 203) {\n // On subsequent 401s, call `onAuthFailure` instead of `onAuth`.\n // This is so that naive `onAuth` callbacks that return a fixed value don't create an infinite loop of retrying.\n const getAuth = providedAuthBefore ? onAuthFailure : onAuth;\n if (getAuth) {\n // Acquire credentials and try again\n // TODO: read `useHttpPath` value from git config and pass along?\n auth = await getAuth(url, {\n ...auth,\n headers: { ...headers },\n });\n if (auth && auth.cancel) {\n throw new UserCanceledError()\n } else if (auth) {\n updateHeaders(headers, auth);\n providedAuthBefore = true;\n tryAgain = true;\n }\n }\n } else if (\n res.statusCode === 200 &&\n providedAuthBefore &&\n onAuthSuccess\n ) {\n await onAuthSuccess(url, auth);\n }\n } while (tryAgain)\n\n if (res.statusCode !== 200) {\n const { response } = await stringifyBody(res);\n throw new HttpError(res.statusCode, res.statusMessage, response)\n }\n // Git \"smart\" HTTP servers should respond with the correct Content-Type header.\n if (\n res.headers['content-type'] === `application/x-${service}-advertisement`\n ) {\n const remoteHTTP = await parseRefsAdResponse(res.body, { service });\n remoteHTTP.auth = auth;\n return remoteHTTP\n } else {\n // If they don't send the correct content-type header, that's a good indicator it is either a \"dumb\" HTTP\n // server, or the user specified an incorrect remote URL and the response is actually an HTML page.\n // In this case, we save the response as plain text so we can generate a better error message if needed.\n const { preview, response, data } = await stringifyBody(res);\n // For backwards compatibility, try to parse it anyway.\n // TODO: maybe just throw instead of trying?\n try {\n const remoteHTTP = await parseRefsAdResponse([data], { service });\n remoteHTTP.auth = auth;\n return remoteHTTP\n } catch (e) {\n throw new SmartHttpError(preview, response)\n }\n }\n }\n\n /**\n * @param {Object} args\n * @param {HttpClient} args.http\n * @param {ProgressCallback} [args.onProgress]\n * @param {string} [args.corsProxy]\n * @param {string} args.service\n * @param {string} args.url\n * @param {Object<string, string>} [args.headers]\n * @param {any} args.body\n * @param {any} args.auth\n */\n static async connect({\n http,\n onProgress,\n corsProxy,\n service,\n url,\n auth,\n body,\n headers,\n }) {\n // We already have the \"correct\" auth value at this point, but\n // we need to strip out the username/password from the URL yet again.\n const urlAuth = extractAuthFromUrl(url);\n if (urlAuth) url = urlAuth.url;\n\n if (corsProxy) url = corsProxify(corsProxy, url);\n\n headers['content-type'] = `application/x-${service}-request`;\n headers.accept = `application/x-${service}-result`;\n updateHeaders(headers, auth);\n\n const res = await http.request({\n onProgress,\n method: 'POST',\n url: `${url}/${service}`,\n body,\n headers,\n });\n if (res.statusCode !== 200) {\n const { response } = stringifyBody(res);\n throw new HttpError(res.statusCode, res.statusMessage, response)\n }\n return res\n }\n}\n\nfunction parseRemoteUrl({ url }) {\n // the stupid \"shorter scp-like syntax\"\n if (url.startsWith('git@')) {\n return {\n transport: 'ssh',\n address: url,\n }\n }\n const matches = url.match(/(\\w+)(:\\/\\/|::)(.*)/);\n if (matches === null) return\n /*\n * When git encounters a URL of the form <transport>://<address>, where <transport> is\n * a protocol that it cannot handle natively, it automatically invokes git remote-<transport>\n * with the full URL as the second argument.\n *\n * @see https://git-scm.com/docs/git-remote-helpers\n */\n if (matches[2] === '://') {\n return {\n transport: matches[1],\n address: matches[0],\n }\n }\n /*\n * A URL of the form <transport>::<address> explicitly instructs git to invoke\n * git remote-<transport> with <address> as the second argument.\n *\n * @see https://git-scm.com/docs/git-remote-helpers\n */\n if (matches[2] === '::') {\n return {\n transport: matches[1],\n address: matches[3],\n }\n }\n}\n\nclass GitRemoteManager {\n static getRemoteHelperFor({ url }) {\n // TODO: clean up the remoteHelper API and move into PluginCore\n const remoteHelpers = new Map();\n remoteHelpers.set('http', GitRemoteHTTP);\n remoteHelpers.set('https', GitRemoteHTTP);\n\n const parts = parseRemoteUrl({ url });\n if (!parts) {\n throw new UrlParseError(url)\n }\n if (remoteHelpers.has(parts.transport)) {\n return remoteHelpers.get(parts.transport)\n }\n throw new UnknownTransportError(\n url,\n parts.transport,\n parts.transport === 'ssh' ? translateSSHtoHTTP(url) : undefined\n )\n }\n}\n\nlet lock$2 = null;\n\nclass GitShallowManager {\n static async read({ fs, gitdir }) {\n if (lock$2 === null) lock$2 = new AsyncLock();\n const filepath = join(gitdir, 'shallow');\n const oids = new Set();\n await lock$2.acquire(filepath, async function() {\n const text = await fs.read(filepath, { encoding: 'utf8' });\n if (text === null) return oids // no file\n if (text.trim() === '') return oids // empty file\n text\n .trim()\n .split('\\n')\n .map(oid => oids.add(oid));\n });\n return oids\n }\n\n static async write({ fs, gitdir, oids }) {\n if (lock$2 === null) lock$2 = new AsyncLock();\n const filepath = join(gitdir, 'shallow');\n if (oids.size > 0) {\n const text = [...oids].join('\\n') + '\\n';\n await lock$2.acquire(filepath, async function() {\n await fs.write(filepath, text, {\n encoding: 'utf8',\n });\n });\n } else {\n // No shallows\n await lock$2.acquire(filepath, async function() {\n await fs.rm(filepath);\n });\n }\n }\n}\n\nasync function hasObjectLoose({ fs, gitdir, oid }) {\n const source = `objects/${oid.slice(0, 2)}/${oid.slice(2)}`;\n return fs.exists(`${gitdir}/${source}`)\n}\n\nasync function hasObjectPacked({\n fs,\n cache,\n gitdir,\n oid,\n getExternalRefDelta,\n}) {\n // Check to see if it's in a packfile.\n // Iterate through all the .idx files\n let list = await fs.readdir(join(gitdir, 'objects/pack'));\n list = list.filter(x => x.endsWith('.idx'));\n for (const filename of list) {\n const indexFile = `${gitdir}/objects/pack/${filename}`;\n const p = await readPackIndex({\n fs,\n cache,\n filename: indexFile,\n getExternalRefDelta,\n });\n if (p.error) throw new InternalError(p.error)\n // If the packfile DOES have the oid we're looking for...\n if (p.offsets.has(oid)) {\n return true\n }\n }\n // Failed to find it\n return false\n}\n\nasync function hasObject({\n fs,\n cache,\n gitdir,\n oid,\n format = 'content',\n}) {\n // Curry the current read method so that the packfile un-deltification\n // process can acquire external ref-deltas.\n const getExternalRefDelta = oid => _readObject({ fs, cache, gitdir, oid });\n\n // Look for it in the loose object directory.\n let result = await hasObjectLoose({ fs, gitdir, oid });\n // Check to see if it's in a packfile.\n if (!result) {\n result = await hasObjectPacked({\n fs,\n cache,\n gitdir,\n oid,\n getExternalRefDelta,\n });\n }\n // Finally\n return result\n}\n\n// TODO: make a function that just returns obCount. then emptyPackfile = () => sizePack(pack) === 0\nfunction emptyPackfile(pack) {\n const pheader = '5041434b';\n const version = '00000002';\n const obCount = '00000000';\n const header = pheader + version + obCount;\n return pack.slice(0, 12).toString('hex') === header\n}\n\nfunction filterCapabilities(server, client) {\n const serverNames = server.map(cap => cap.split('=', 1)[0]);\n return client.filter(cap => {\n const name = cap.split('=', 1)[0];\n return serverNames.includes(name)\n })\n}\n\nconst pkg = {\n name: 'isomorphic-git',\n version: '1.30.1',\n agent: 'git/isomorphic-git@1.30.1',\n};\n\nclass FIFO {\n constructor() {\n this._queue = [];\n }\n\n write(chunk) {\n if (this._ended) {\n throw Error('You cannot write to a FIFO that has already been ended!')\n }\n if (this._waiting) {\n const resolve = this._waiting;\n this._waiting = null;\n resolve({ value: chunk });\n } else {\n this._queue.push(chunk);\n }\n }\n\n end() {\n this._ended = true;\n if (this._waiting) {\n const resolve = this._waiting;\n this._waiting = null;\n resolve({ done: true });\n }\n }\n\n destroy(err) {\n this.error = err;\n this.end();\n }\n\n async next() {\n if (this._queue.length > 0) {\n return { value: this._queue.shift() }\n }\n if (this._ended) {\n return { done: true }\n }\n if (this._waiting) {\n throw Error(\n 'You cannot call read until the previous call to read has returned!'\n )\n }\n return new Promise(resolve => {\n this._waiting = resolve;\n })\n }\n}\n\n// Note: progress messages are designed to be written directly to the terminal,\n// so they are often sent with just a carriage return to overwrite the last line of output.\n// But there are also messages delimited with newlines.\n// I also include CRLF just in case.\nfunction findSplit(str) {\n const r = str.indexOf('\\r');\n const n = str.indexOf('\\n');\n if (r === -1 && n === -1) return -1\n if (r === -1) return n + 1 // \\n\n if (n === -1) return r + 1 // \\r\n if (n === r + 1) return n + 1 // \\r\\n\n return Math.min(r, n) + 1 // \\r or \\n\n}\n\nfunction splitLines(input) {\n const output = new FIFO();\n let tmp = ''\n ;(async () => {\n await forAwait(input, chunk => {\n chunk = chunk.toString('utf8');\n tmp += chunk;\n while (true) {\n const i = findSplit(tmp);\n if (i === -1) break\n output.write(tmp.slice(0, i));\n tmp = tmp.slice(i);\n }\n });\n if (tmp.length > 0) {\n output.write(tmp);\n }\n output.end();\n })();\n return output\n}\n\n/*\nIf 'side-band' or 'side-band-64k' capabilities have been specified by\nthe client, the server will send the packfile data multiplexed.\n\nEach packet starting with the packet-line length of the amount of data\nthat follows, followed by a single byte specifying the sideband the\nfollowing data is coming in on.\n\nIn 'side-band' mode, it will send up to 999 data bytes plus 1 control\ncode, for a total of up to 1000 bytes in a pkt-line. In 'side-band-64k'\nmode it will send up to 65519 data bytes plus 1 control code, for a\ntotal of up to 65520 bytes in a pkt-line.\n\nThe sideband byte will be a '1', '2' or a '3'. Sideband '1' will contain\npackfile data, sideband '2' will be used for progress information that the\nclient will generally print to stderr and sideband '3' is used for error\ninformation.\n\nIf no 'side-band' capability was specified, the server will stream the\nentire packfile without multiplexing.\n*/\n\nclass GitSideBand {\n static demux(input) {\n const read = GitPktLine.streamReader(input);\n // And now for the ridiculous side-band or side-band-64k protocol\n const packetlines = new FIFO();\n const packfile = new FIFO();\n const progress = new FIFO();\n // TODO: Use a proper through stream?\n const nextBit = async function() {\n const line = await read();\n // Skip over flush packets\n if (line === null) return nextBit()\n // A made up convention to signal there's no more to read.\n if (line === true) {\n packetlines.end();\n progress.end();\n input.error ? packfile.destroy(input.error) : packfile.end();\n return\n }\n // Examine first byte to determine which output \"stream\" to use\n switch (line[0]) {\n case 1: {\n // pack data\n packfile.write(line.slice(1));\n break\n }\n case 2: {\n // progress message\n progress.write(line.slice(1));\n break\n }\n case 3: {\n // fatal error message just before stream aborts\n const error = line.slice(1);\n progress.write(error);\n packetlines.end();\n progress.end();\n packfile.destroy(new Error(error.toString('utf8')));\n return\n }\n default: {\n // Not part of the side-band-64k protocol\n packetlines.write(line);\n }\n }\n // Careful not to blow up the stack.\n // I think Promises in a tail-call position should be OK.\n nextBit();\n };\n nextBit();\n return {\n packetlines,\n packfile,\n progress,\n }\n }\n // static mux ({\n // protocol, // 'side-band' or 'side-band-64k'\n // packetlines,\n // packfile,\n // progress,\n // error\n // }) {\n // const MAX_PACKET_LENGTH = protocol === 'side-band-64k' ? 999 : 65519\n // let output = new PassThrough()\n // packetlines.on('data', data => {\n // if (data === null) {\n // output.write(GitPktLine.flush())\n // } else {\n // output.write(GitPktLine.encode(data))\n // }\n // })\n // let packfileWasEmpty = true\n // let packfileEnded = false\n // let progressEnded = false\n // let errorEnded = false\n // let goodbye = Buffer.concat([\n // GitPktLine.encode(Buffer.from('010A', 'hex')),\n // GitPktLine.flush()\n // ])\n // packfile\n // .on('data', data => {\n // packfileWasEmpty = false\n // const buffers = splitBuffer(data, MAX_PACKET_LENGTH)\n // for (const buffer of buffers) {\n // output.write(\n // GitPktLine.encode(Buffer.concat([Buffer.from('01', 'hex'), buffer]))\n // )\n // }\n // })\n // .on('end', () => {\n // packfileEnded = true\n // if (!packfileWasEmpty) output.write(goodbye)\n // if (progressEnded && errorEnded) output.end()\n // })\n // progress\n // .on('data', data => {\n // const buffers = splitBuffer(data, MAX_PACKET_LENGTH)\n // for (const buffer of buffers) {\n // output.write(\n // GitPktLine.encode(Buffer.concat([Buffer.from('02', 'hex'), buffer]))\n // )\n // }\n // })\n // .on('end', () => {\n // progressEnded = true\n // if (packfileEnded && errorEnded) output.end()\n // })\n // error\n // .on('data', data => {\n // const buffers = splitBuffer(data, MAX_PACKET_LENGTH)\n // for (const buffer of buffers) {\n // output.write(\n // GitPktLine.encode(Buffer.concat([Buffer.from('03', 'hex'), buffer]))\n // )\n // }\n // })\n // .on('end', () => {\n // errorEnded = true\n // if (progressEnded && packfileEnded) output.end()\n // })\n // return output\n // }\n}\n\nasync function parseUploadPackResponse(stream) {\n const { packetlines, packfile, progress } = GitSideBand.demux(stream);\n const shallows = [];\n const unshallows = [];\n const acks = [];\n let nak = false;\n let done = false;\n return new Promise((resolve, reject) => {\n // Parse the response\n forAwait(packetlines, data => {\n const line = data.toString('utf8').trim();\n if (line.startsWith('shallow')) {\n const oid = line.slice(-41).trim();\n if (oid.length !== 40) {\n reject(new InvalidOidError(oid));\n }\n shallows.push(oid);\n } else if (line.startsWith('unshallow')) {\n const oid = line.slice(-41).trim();\n if (oid.length !== 40) {\n reject(new InvalidOidError(oid));\n }\n unshallows.push(oid);\n } else if (line.startsWith('ACK')) {\n const [, oid, status] = line.split(' ');\n acks.push({ oid, status });\n if (!status) done = true;\n } else if (line.startsWith('NAK')) {\n nak = true;\n done = true;\n } else {\n done = true;\n nak = true;\n }\n if (done) {\n stream.error\n ? reject(stream.error)\n : resolve({ shallows, unshallows, acks, nak, packfile, progress });\n }\n }).finally(() => {\n if (!done) {\n stream.error\n ? reject(stream.error)\n : resolve({ shallows, unshallows, acks, nak, packfile, progress });\n }\n });\n })\n}\n\nfunction writeUploadPackRequest({\n capabilities = [],\n wants = [],\n haves = [],\n shallows = [],\n depth = null,\n since = null,\n exclude = [],\n}) {\n const packstream = [];\n wants = [...new Set(wants)]; // remove duplicates\n let firstLineCapabilities = ` ${capabilities.join(' ')}`;\n for (const oid of wants) {\n packstream.push(GitPktLine.encode(`want ${oid}${firstLineCapabilities}\\n`));\n firstLineCapabilities = '';\n }\n for (const oid of shallows) {\n packstream.push(GitPktLine.encode(`shallow ${oid}\\n`));\n }\n if (depth !== null) {\n packstream.push(GitPktLine.encode(`deepen ${depth}\\n`));\n }\n if (since !== null) {\n packstream.push(\n GitPktLine.encode(`deepen-since ${Math.floor(since.valueOf() / 1000)}\\n`)\n );\n }\n for (const oid of exclude) {\n packstream.push(GitPktLine.encode(`deepen-not ${oid}\\n`));\n }\n packstream.push(GitPktLine.flush());\n for (const oid of haves) {\n packstream.push(GitPktLine.encode(`have ${oid}\\n`));\n }\n packstream.push(GitPktLine.encode(`done\\n`));\n return packstream\n}\n\n// @ts-check\n\n/**\n *\n * @typedef {object} FetchResult - The object returned has the following schema:\n * @property {string | null} defaultBranch - The branch that is cloned if no branch is specified\n * @property {string | null} fetchHead - The SHA-1 object id of the fetched head commit\n * @property {string | null} fetchHeadDescription - a textual description of the branch that was fetched\n * @property {Object<string, string>} [headers] - The HTTP response headers returned by the git server\n * @property {string[]} [pruned] - A list of branches that were pruned, if you provided the `prune` parameter\n *\n */\n\n/**\n * @param {object} args\n * @param {import('../models/FileSystem.js').FileSystem} args.fs\n * @param {any} args.cache\n * @param {HttpClient} args.http\n * @param {ProgressCallback} [args.onProgress]\n * @param {MessageCallback} [args.onMessage]\n * @param {AuthCallback} [args.onAuth]\n * @param {AuthFailureCallback} [args.onAuthFailure]\n * @param {AuthSuccessCallback} [args.onAuthSuccess]\n * @param {string} args.gitdir\n * @param {string|void} [args.url]\n * @param {string} [args.corsProxy]\n * @param {string} [args.ref]\n * @param {string} [args.remoteRef]\n * @param {string} [args.remote]\n * @param {boolean} [args.singleBranch = false]\n * @param {boolean} [args.tags = false]\n * @param {number} [args.depth]\n * @param {Date} [args.since]\n * @param {string[]} [args.exclude = []]\n * @param {boolean} [args.relative = false]\n * @param {Object<string, string>} [args.headers]\n * @param {boolean} [args.prune]\n * @param {boolean} [args.pruneTags]\n *\n * @returns {Promise<FetchResult>}\n * @see FetchResult\n */\nasync function _fetch({\n fs,\n cache,\n http,\n onProgress,\n onMessage,\n onAuth,\n onAuthSuccess,\n onAuthFailure,\n gitdir,\n ref: _ref,\n remoteRef: _remoteRef,\n remote: _remote,\n url: _url,\n corsProxy,\n depth = null,\n since = null,\n exclude = [],\n relative = false,\n tags = false,\n singleBranch = false,\n headers = {},\n prune = false,\n pruneTags = false,\n}) {\n const ref = _ref || (await _currentBranch({ fs, gitdir, test: true }));\n const config = await GitConfigManager.get({ fs, gitdir });\n // Figure out what remote to use.\n const remote =\n _remote || (ref && (await config.get(`branch.${ref}.remote`))) || 'origin';\n // Lookup the URL for the given remote.\n const url = _url || (await config.get(`remote.${remote}.url`));\n if (typeof url === 'undefined') {\n throw new MissingParameterError('remote OR url')\n }\n // Figure out what remote ref to use.\n const remoteRef =\n _remoteRef ||\n (ref && (await config.get(`branch.${ref}.merge`))) ||\n _ref ||\n 'HEAD';\n\n if (corsProxy === undefined) {\n corsProxy = await config.get('http.corsProxy');\n }\n\n const GitRemoteHTTP = GitRemoteManager.getRemoteHelperFor({ url });\n const remoteHTTP = await GitRemoteHTTP.discover({\n http,\n onAuth,\n onAuthSuccess,\n onAuthFailure,\n corsProxy,\n service: 'git-upload-pack',\n url,\n headers,\n protocolVersion: 1,\n });\n const auth = remoteHTTP.auth; // hack to get new credentials from CredentialManager API\n const remoteRefs = remoteHTTP.refs;\n // For the special case of an empty repository with no refs, return null.\n if (remoteRefs.size === 0) {\n return {\n defaultBranch: null,\n fetchHead: null,\n fetchHeadDescription: null,\n }\n }\n // Check that the remote supports the requested features\n if (depth !== null && !remoteHTTP.capabilities.has('shallow')) {\n throw new RemoteCapabilityError('shallow', 'depth')\n }\n if (since !== null && !remoteHTTP.capabilities.has('deepen-since')) {\n throw new RemoteCapabilityError('deepen-since', 'since')\n }\n if (exclude.length > 0 && !remoteHTTP.capabilities.has('deepen-not')) {\n throw new RemoteCapabilityError('deepen-not', 'exclude')\n }\n if (relative === true && !remoteHTTP.capabilities.has('deepen-relative')) {\n throw new RemoteCapabilityError('deepen-relative', 'relative')\n }\n // Figure out the SHA for the requested ref\n const { oid, fullref } = GitRefManager.resolveAgainstMap({\n ref: remoteRef,\n map: remoteRefs,\n });\n // Filter out refs we want to ignore: only keep ref we're cloning, HEAD, branches, and tags (if we're keeping them)\n for (const remoteRef of remoteRefs.keys()) {\n if (\n remoteRef === fullref ||\n remoteRef === 'HEAD' ||\n remoteRef.startsWith('refs/heads/') ||\n (tags && remoteRef.startsWith('refs/tags/'))\n ) {\n continue\n }\n remoteRefs.delete(remoteRef);\n }\n // Assemble the application/x-git-upload-pack-request\n const capabilities = filterCapabilities(\n [...remoteHTTP.capabilities],\n [\n 'multi_ack_detailed',\n 'no-done',\n 'side-band-64k',\n // Note: I removed 'thin-pack' option since our code doesn't \"fatten\" packfiles,\n // which is necessary for compatibility with git. It was the cause of mysterious\n // 'fatal: pack has [x] unresolved deltas' errors that plagued us for some time.\n // isomorphic-git is perfectly happy with thin packfiles in .git/objects/pack but\n // canonical git it turns out is NOT.\n 'ofs-delta',\n `agent=${pkg.agent}`,\n ]\n );\n if (relative) capabilities.push('deepen-relative');\n // Start figuring out which oids from the remote we want to request\n const wants = singleBranch ? [oid] : remoteRefs.values();\n // Come up with a reasonable list of oids to tell the remote we already have\n // (preferably oids that are close ancestors of the branch heads we're fetching)\n const haveRefs = singleBranch\n ? [ref]\n : await GitRefManager.listRefs({\n fs,\n gitdir,\n filepath: `refs`,\n });\n let haves = [];\n for (let ref of haveRefs) {\n try {\n ref = await GitRefManager.expand({ fs, gitdir, ref });\n const oid = await GitRefManager.resolve({ fs, gitdir, ref });\n if (await hasObject({ fs, cache, gitdir, oid })) {\n haves.push(oid);\n }\n } catch (err) {}\n }\n haves = [...new Set(haves)];\n const oids = await GitShallowManager.read({ fs, gitdir });\n const shallows = remoteHTTP.capabilities.has('shallow') ? [...oids] : [];\n const packstream = writeUploadPackRequest({\n capabilities,\n wants,\n haves,\n shallows,\n depth,\n since,\n exclude,\n });\n // CodeCommit will hang up if we don't send a Content-Length header\n // so we can't stream the body.\n const packbuffer = Buffer.from(await collect(packstream));\n const raw = await GitRemoteHTTP.connect({\n http,\n onProgress,\n corsProxy,\n service: 'git-upload-pack',\n url,\n auth,\n body: [packbuffer],\n headers,\n });\n const response = await parseUploadPackResponse(raw.body);\n if (raw.headers) {\n response.headers = raw.headers;\n }\n // Apply all the 'shallow' and 'unshallow' commands\n for (const oid of response.shallows) {\n if (!oids.has(oid)) {\n // this is in a try/catch mostly because my old test fixtures are missing objects\n try {\n // server says it's shallow, but do we have the parents?\n const { object } = await _readObject({ fs, cache, gitdir, oid });\n const commit = new GitCommit(object);\n const hasParents = await Promise.all(\n commit\n .headers()\n .parent.map(oid => hasObject({ fs, cache, gitdir, oid }))\n );\n const haveAllParents =\n hasParents.length === 0 || hasParents.every(has => has);\n if (!haveAllParents) {\n oids.add(oid);\n }\n } catch (err) {\n oids.add(oid);\n }\n }\n }\n for (const oid of response.unshallows) {\n oids.delete(oid);\n }\n await GitShallowManager.write({ fs, gitdir, oids });\n // Update local remote refs\n if (singleBranch) {\n const refs = new Map([[fullref, oid]]);\n // But wait, maybe it was a symref, like 'HEAD'!\n // We need to save all the refs in the symref chain (sigh).\n const symrefs = new Map();\n let bail = 10;\n let key = fullref;\n while (bail--) {\n const value = remoteHTTP.symrefs.get(key);\n if (value === undefined) break\n symrefs.set(key, value);\n key = value;\n }\n // final value must not be a symref but a real ref\n const realRef = remoteRefs.get(key);\n // There may be no ref at all if we've fetched a specific commit hash\n if (realRef) {\n refs.set(key, realRef);\n }\n const { pruned } = await GitRefManager.updateRemoteRefs({\n fs,\n gitdir,\n remote,\n refs,\n symrefs,\n tags,\n prune,\n });\n if (prune) {\n response.pruned = pruned;\n }\n } else {\n const { pruned } = await GitRefManager.updateRemoteRefs({\n fs,\n gitdir,\n remote,\n refs: remoteRefs,\n symrefs: remoteHTTP.symrefs,\n tags,\n prune,\n pruneTags,\n });\n if (prune) {\n response.pruned = pruned;\n }\n }\n // We need this value later for the `clone` command.\n response.HEAD = remoteHTTP.symrefs.get('HEAD');\n // AWS CodeCommit doesn't list HEAD as a symref, but we can reverse engineer it\n // Find the SHA of the branch called HEAD\n if (response.HEAD === undefined) {\n const { oid } = GitRefManager.resolveAgainstMap({\n ref: 'HEAD',\n map: remoteRefs,\n });\n // Use the name of the first branch that's not called HEAD that has\n // the same SHA as the branch called HEAD.\n for (const [key, value] of remoteRefs.entries()) {\n if (key !== 'HEAD' && value === oid) {\n response.HEAD = key;\n break\n }\n }\n }\n const noun = fullref.startsWith('refs/tags') ? 'tag' : 'branch';\n response.FETCH_HEAD = {\n oid,\n description: `${noun} '${abbreviateRef(fullref)}' of ${url}`,\n };\n\n if (onProgress || onMessage) {\n const lines = splitLines(response.progress);\n forAwait(lines, async line => {\n if (onMessage) await onMessage(line);\n if (onProgress) {\n const matches = line.match(/([^:]*).*\\((\\d+?)\\/(\\d+?)\\)/);\n if (matches) {\n await onProgress({\n phase: matches[1].trim(),\n loaded: parseInt(matches[2], 10),\n total: parseInt(matches[3], 10),\n });\n }\n }\n });\n }\n const packfile = Buffer.from(await collect(response.packfile));\n if (raw.body.error) throw raw.body.error\n const packfileSha = packfile.slice(-20).toString('hex');\n const res = {\n defaultBranch: response.HEAD,\n fetchHead: response.FETCH_HEAD.oid,\n fetchHeadDescription: response.FETCH_HEAD.description,\n };\n if (response.headers) {\n res.headers = response.headers;\n }\n if (prune) {\n res.pruned = response.pruned;\n }\n // This is a quick fix for the empty .git/objects/pack/pack-.pack file error,\n // which due to the way `git-list-pack` works causes the program to hang when it tries to read it.\n // TODO: Longer term, we should actually:\n // a) NOT concatenate the entire packfile into memory (line 78),\n // b) compute the SHA of the stream except for the last 20 bytes, using the same library used in push.js, and\n // c) compare the computed SHA with the last 20 bytes of the stream before saving to disk, and throwing a \"packfile got corrupted during download\" error if the SHA doesn't match.\n if (packfileSha !== '' && !emptyPackfile(packfile)) {\n res.packfile = `objects/pack/pack-${packfileSha}.pack`;\n const fullpath = join(gitdir, res.packfile);\n await fs.write(fullpath, packfile);\n const getExternalRefDelta = oid => _readObject({ fs, cache, gitdir, oid });\n const idx = await GitPackIndex.fromPack({\n pack: packfile,\n getExternalRefDelta,\n onProgress,\n });\n await fs.write(fullpath.replace(/\\.pack$/, '.idx'), await idx.toBuffer());\n }\n return res\n}\n\n// @ts-check\n\n/**\n * Initialize a new repository\n *\n * @param {object} args\n * @param {import('../models/FileSystem.js').FileSystem} args.fs\n * @param {string} [args.dir]\n * @param {string} [args.gitdir]\n * @param {boolean} [args.bare = false]\n * @param {string} [args.defaultBranch = 'master']\n * @returns {Promise<void>}\n */\nasync function _init({\n fs,\n bare = false,\n dir,\n gitdir = bare ? dir : join(dir, '.git'),\n defaultBranch = 'master',\n}) {\n // Don't overwrite an existing config\n if (await fs.exists(gitdir + '/config')) return\n\n let folders = [\n 'hooks',\n 'info',\n 'objects/info',\n 'objects/pack',\n 'refs/heads',\n 'refs/tags',\n ];\n folders = folders.map(dir => gitdir + '/' + dir);\n for (const folder of folders) {\n await fs.mkdir(folder);\n }\n\n await fs.write(\n gitdir + '/config',\n '[core]\\n' +\n '\\trepositoryformatversion = 0\\n' +\n '\\tfilemode = false\\n' +\n `\\tbare = ${bare}\\n` +\n (bare ? '' : '\\tlogallrefupdates = true\\n') +\n '\\tsymlinks = false\\n' +\n '\\tignorecase = true\\n'\n );\n await fs.write(gitdir + '/HEAD', `ref: refs/heads/${defaultBranch}\\n`);\n}\n\n// @ts-check\n\n/**\n * @param {object} args\n * @param {import('../models/FileSystem.js').FileSystem} args.fs\n * @param {object} args.cache\n * @param {HttpClient} args.http\n * @param {ProgressCallback} [args.onProgress]\n * @param {MessageCallback} [args.onMessage]\n * @param {AuthCallback} [args.onAuth]\n * @param {AuthFailureCallback} [args.onAuthFailure]\n * @param {AuthSuccessCallback} [args.onAuthSuccess]\n * @param {PostCheckoutCallback} [args.onPostCheckout]\n * @param {string} [args.dir]\n * @param {string} args.gitdir\n * @param {string} args.url\n * @param {string} args.corsProxy\n * @param {string} args.ref\n * @param {boolean} args.singleBranch\n * @param {boolean} args.noCheckout\n * @param {boolean} args.noTags\n * @param {string} args.remote\n * @param {number} args.depth\n * @param {Date} args.since\n * @param {string[]} args.exclude\n * @param {boolean} args.relative\n * @param {Object<string, string>} args.headers\n *\n * @returns {Promise<void>} Resolves successfully when clone completes\n *\n */\nasync function _clone({\n fs,\n cache,\n http,\n onProgress,\n onMessage,\n onAuth,\n onAuthSuccess,\n onAuthFailure,\n onPostCheckout,\n dir,\n gitdir,\n url,\n corsProxy,\n ref,\n remote,\n depth,\n since,\n exclude,\n relative,\n singleBranch,\n noCheckout,\n noTags,\n headers,\n}) {\n try {\n await _init({ fs, gitdir });\n await _addRemote({ fs, gitdir, remote, url, force: false });\n if (corsProxy) {\n const config = await GitConfigManager.get({ fs, gitdir });\n await config.set(`http.corsProxy`, corsProxy);\n await GitConfigManager.save({ fs, gitdir, config });\n }\n const { defaultBranch, fetchHead } = await _fetch({\n fs,\n cache,\n http,\n onProgress,\n onMessage,\n onAuth,\n onAuthSuccess,\n onAuthFailure,\n gitdir,\n ref,\n remote,\n corsProxy,\n depth,\n since,\n exclude,\n relative,\n singleBranch,\n headers,\n tags: !noTags,\n });\n if (fetchHead === null) return\n ref = ref || defaultBranch;\n ref = ref.replace('refs/heads/', '');\n // Checkout that branch\n await _checkout({\n fs,\n cache,\n onProgress,\n onPostCheckout,\n dir,\n gitdir,\n ref,\n remote,\n noCheckout,\n });\n } catch (err) {\n // Remove partial local repository, see #1283\n // Ignore any error as we are already failing.\n // The catch is necessary so the original error is not masked.\n await fs\n .rmdir(gitdir, { recursive: true, maxRetries: 10 })\n .catch(() => undefined);\n throw err\n }\n}\n\n// @ts-check\n\n/**\n * Clone a repository\n *\n * @param {object} args\n * @param {FsClient} args.fs - a file system implementation\n * @param {HttpClient} args.http - an HTTP client\n * @param {ProgressCallback} [args.onProgress] - optional progress event callback\n * @param {MessageCallback} [args.onMessage] - optional message event callback\n * @param {AuthCallback} [args.onAuth] - optional auth fill callback\n * @param {AuthFailureCallback} [args.onAuthFailure] - optional auth rejected callback\n * @param {AuthSuccessCallback} [args.onAuthSuccess] - optional auth approved callback\n * @param {PostCheckoutCallback} [args.onPostCheckout] - optional post-checkout hook callback\n * @param {string} args.dir - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {string} args.url - The URL of the remote repository\n * @param {string} [args.corsProxy] - Optional [CORS proxy](https://www.npmjs.com/%40isomorphic-git/cors-proxy). Value is stored in the git config file for that repo.\n * @param {string} [args.ref] - Which branch to checkout. By default this is the designated \"main branch\" of the repository.\n * @param {boolean} [args.singleBranch = false] - Instead of the default behavior of fetching all the branches, only fetch a single branch.\n * @param {boolean} [args.noCheckout = false] - If true, clone will only fetch the repo, not check out a branch. Skipping checkout can save a lot of time normally spent writing files to disk.\n * @param {boolean} [args.noTags = false] - By default clone will fetch all tags. `noTags` disables that behavior.\n * @param {string} [args.remote = 'origin'] - What to name the remote that is created.\n * @param {number} [args.depth] - Integer. Determines how much of the git repository's history to retrieve\n * @param {Date} [args.since] - Only fetch commits created after the given date. Mutually exclusive with `depth`.\n * @param {string[]} [args.exclude = []] - A list of branches or tags. Instructs the remote server not to send us any commits reachable from these refs.\n * @param {boolean} [args.relative = false] - Changes the meaning of `depth` to be measured from the current shallow depth rather than from the branch tip.\n * @param {Object<string, string>} [args.headers = {}] - Additional headers to include in HTTP requests, similar to git's `extraHeader` config\n * @param {object} [args.cache] - a [cache](cache.md) object\n *\n * @returns {Promise<void>} Resolves successfully when clone completes\n *\n * @example\n * await git.clone({\n * fs,\n * http,\n * dir: '/tutorial',\n * corsProxy: 'https://cors.isomorphic-git.org',\n * url: 'https://github.com/isomorphic-git/isomorphic-git',\n * singleBranch: true,\n * depth: 1\n * })\n * console.log('done')\n *\n */\nasync function clone({\n fs,\n http,\n onProgress,\n onMessage,\n onAuth,\n onAuthSuccess,\n onAuthFailure,\n onPostCheckout,\n dir,\n gitdir = join(dir, '.git'),\n url,\n corsProxy = undefined,\n ref = undefined,\n remote = 'origin',\n depth = undefined,\n since = undefined,\n exclude = [],\n relative = false,\n singleBranch = false,\n noCheckout = false,\n noTags = false,\n headers = {},\n cache = {},\n}) {\n try {\n assertParameter('fs', fs);\n assertParameter('http', http);\n assertParameter('gitdir', gitdir);\n if (!noCheckout) {\n assertParameter('dir', dir);\n }\n assertParameter('url', url);\n\n return await _clone({\n fs: new FileSystem(fs),\n cache,\n http,\n onProgress,\n onMessage,\n onAuth,\n onAuthSuccess,\n onAuthFailure,\n onPostCheckout,\n dir,\n gitdir,\n url,\n corsProxy,\n ref,\n remote,\n depth,\n since,\n exclude,\n relative,\n singleBranch,\n noCheckout,\n noTags,\n headers,\n })\n } catch (err) {\n err.caller = 'git.clone';\n throw err\n }\n}\n\n// @ts-check\n/**\n * Create a new commit\n *\n * @param {Object} args\n * @param {FsClient} args.fs - a file system implementation\n * @param {SignCallback} [args.onSign] - a PGP signing implementation\n * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {string} [args.message] - The commit message to use. Required, unless `amend === true`\n * @param {Object} [args.author] - The details about the author.\n * @param {string} [args.author.name] - Default is `user.name` config.\n * @param {string} [args.author.email] - Default is `user.email` config.\n * @param {number} [args.author.timestamp=Math.floor(Date.now()/1000)] - Set the author timestamp field. This is the integer number of seconds since the Unix epoch (1970-01-01 00:00:00).\n * @param {number} [args.author.timezoneOffset] - Set the author timezone offset field. This is the difference, in minutes, from the current timezone to UTC. Default is `(new Date()).getTimezoneOffset()`.\n * @param {Object} [args.committer = author] - The details about the commit committer, in the same format as the author parameter. If not specified, the author details are used.\n * @param {string} [args.committer.name] - Default is `user.name` config.\n * @param {string} [args.committer.email] - Default is `user.email` config.\n * @param {number} [args.committer.timestamp=Math.floor(Date.now()/1000)] - Set the committer timestamp field. This is the integer number of seconds since the Unix epoch (1970-01-01 00:00:00).\n * @param {number} [args.committer.timezoneOffset] - Set the committer timezone offset field. This is the difference, in minutes, from the current timezone to UTC. Default is `(new Date()).getTimezoneOffset()`.\n * @param {string} [args.signingKey] - Sign the tag object using this private PGP key.\n * @param {boolean} [args.amend = false] - If true, replaces the last commit pointed to by `ref` with a new commit.\n * @param {boolean} [args.dryRun = false] - If true, simulates making a commit so you can test whether it would succeed. Implies `noUpdateBranch`.\n * @param {boolean} [args.noUpdateBranch = false] - If true, does not update the branch pointer after creating the commit.\n * @param {string} [args.ref] - The fully expanded name of the branch to commit to. Default is the current branch pointed to by HEAD. (TODO: fix it so it can expand branch names without throwing if the branch doesn't exist yet.)\n * @param {string[]} [args.parent] - The SHA-1 object ids of the commits to use as parents. If not specified, the commit pointed to by `ref` is used.\n * @param {string} [args.tree] - The SHA-1 object id of the tree to use. If not specified, a new tree object is created from the current git index.\n * @param {object} [args.cache] - a [cache](cache.md) object\n *\n * @returns {Promise<string>} Resolves successfully with the SHA-1 object id of the newly created commit.\n *\n * @example\n * let sha = await git.commit({\n * fs,\n * dir: '/tutorial',\n * author: {\n * name: 'Mr. Test',\n * email: 'mrtest@example.com',\n * },\n * message: 'Added the a.txt file'\n * })\n * console.log(sha)\n *\n */\nasync function commit({\n fs: _fs,\n onSign,\n dir,\n gitdir = join(dir, '.git'),\n message,\n author,\n committer,\n signingKey,\n amend = false,\n dryRun = false,\n noUpdateBranch = false,\n ref,\n parent,\n tree,\n cache = {},\n}) {\n try {\n assertParameter('fs', _fs);\n if (!amend) {\n assertParameter('message', message);\n }\n if (signingKey) {\n assertParameter('onSign', onSign);\n }\n const fs = new FileSystem(_fs);\n\n return await _commit({\n fs,\n cache,\n onSign,\n gitdir,\n message,\n author,\n committer,\n signingKey,\n amend,\n dryRun,\n noUpdateBranch,\n ref,\n parent,\n tree,\n })\n } catch (err) {\n err.caller = 'git.commit';\n throw err\n }\n}\n\n// @ts-check\n\n/**\n * Get the name of the branch currently pointed to by .git/HEAD\n *\n * @param {Object} args\n * @param {FsClient} args.fs - a file system implementation\n * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {boolean} [args.fullname = false] - Return the full path (e.g. \"refs/heads/main\") instead of the abbreviated form.\n * @param {boolean} [args.test = false] - If the current branch doesn't actually exist (such as right after git init) then return `undefined`.\n *\n * @returns {Promise<string|void>} The name of the current branch or undefined if the HEAD is detached.\n *\n * @example\n * // Get the current branch name\n * let branch = await git.currentBranch({\n * fs,\n * dir: '/tutorial',\n * fullname: false\n * })\n * console.log(branch)\n *\n */\nasync function currentBranch({\n fs,\n dir,\n gitdir = join(dir, '.git'),\n fullname = false,\n test = false,\n}) {\n try {\n assertParameter('fs', fs);\n assertParameter('gitdir', gitdir);\n return await _currentBranch({\n fs: new FileSystem(fs),\n gitdir,\n fullname,\n test,\n })\n } catch (err) {\n err.caller = 'git.currentBranch';\n throw err\n }\n}\n\n// @ts-check\n\n/**\n * @param {Object} args\n * @param {import('../models/FileSystem.js').FileSystem} args.fs\n * @param {string} args.gitdir\n * @param {string} args.ref\n *\n * @returns {Promise<void>}\n */\nasync function _deleteBranch({ fs, gitdir, ref }) {\n ref = ref.startsWith('refs/heads/') ? ref : `refs/heads/${ref}`;\n const exist = await GitRefManager.exists({ fs, gitdir, ref });\n if (!exist) {\n throw new NotFoundError(ref)\n }\n\n const fullRef = await GitRefManager.expand({ fs, gitdir, ref });\n const currentRef = await _currentBranch({ fs, gitdir, fullname: true });\n if (fullRef === currentRef) {\n // detach HEAD\n const value = await GitRefManager.resolve({ fs, gitdir, ref: fullRef });\n await GitRefManager.writeRef({ fs, gitdir, ref: 'HEAD', value });\n }\n\n // Delete a specified branch\n await GitRefManager.deleteRef({ fs, gitdir, ref: fullRef });\n\n // Delete branch config entries\n const abbrevRef = abbreviateRef(ref);\n const config = await GitConfigManager.get({ fs, gitdir });\n await config.deleteSection('branch', abbrevRef);\n await GitConfigManager.save({ fs, gitdir, config });\n}\n\n// @ts-check\n\n/**\n * Delete a local branch\n *\n * > Note: This only deletes loose branches - it should be fixed in the future to delete packed branches as well.\n *\n * @param {Object} args\n * @param {FsClient} args.fs - a file system implementation\n * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {string} args.ref - The branch to delete\n *\n * @returns {Promise<void>} Resolves successfully when filesystem operations are complete\n *\n * @example\n * await git.deleteBranch({ fs, dir: '/tutorial', ref: 'local-branch' })\n * console.log('done')\n *\n */\nasync function deleteBranch({\n fs,\n dir,\n gitdir = join(dir, '.git'),\n ref,\n}) {\n try {\n assertParameter('fs', fs);\n assertParameter('ref', ref);\n return await _deleteBranch({\n fs: new FileSystem(fs),\n gitdir,\n ref,\n })\n } catch (err) {\n err.caller = 'git.deleteBranch';\n throw err\n }\n}\n\n// @ts-check\n\n/**\n * Delete a local ref\n *\n * @param {Object} args\n * @param {FsClient} args.fs - a file system implementation\n * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {string} args.ref - The ref to delete\n *\n * @returns {Promise<void>} Resolves successfully when filesystem operations are complete\n *\n * @example\n * await git.deleteRef({ fs, dir: '/tutorial', ref: 'refs/tags/test-tag' })\n * console.log('done')\n *\n */\nasync function deleteRef({ fs, dir, gitdir = join(dir, '.git'), ref }) {\n try {\n assertParameter('fs', fs);\n assertParameter('ref', ref);\n await GitRefManager.deleteRef({ fs: new FileSystem(fs), gitdir, ref });\n } catch (err) {\n err.caller = 'git.deleteRef';\n throw err\n }\n}\n\n// @ts-check\n\n/**\n * @param {Object} args\n * @param {import('../models/FileSystem.js').FileSystem} args.fs\n * @param {string} args.gitdir\n * @param {string} args.remote\n *\n * @returns {Promise<void>}\n */\nasync function _deleteRemote({ fs, gitdir, remote }) {\n const config = await GitConfigManager.get({ fs, gitdir });\n await config.deleteSection('remote', remote);\n await GitConfigManager.save({ fs, gitdir, config });\n}\n\n// @ts-check\n\n/**\n * Removes the local config entry for a given remote\n *\n * @param {Object} args\n * @param {FsClient} args.fs - a file system implementation\n * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {string} args.remote - The name of the remote to delete\n *\n * @returns {Promise<void>} Resolves successfully when filesystem operations are complete\n *\n * @example\n * await git.deleteRemote({ fs, dir: '/tutorial', remote: 'upstream' })\n * console.log('done')\n *\n */\nasync function deleteRemote({\n fs,\n dir,\n gitdir = join(dir, '.git'),\n remote,\n}) {\n try {\n assertParameter('fs', fs);\n assertParameter('remote', remote);\n return await _deleteRemote({\n fs: new FileSystem(fs),\n gitdir,\n remote,\n })\n } catch (err) {\n err.caller = 'git.deleteRemote';\n throw err\n }\n}\n\n// @ts-check\n\n/**\n * Delete a local tag ref\n *\n * @param {Object} args\n * @param {import('../models/FileSystem.js').FileSystem} args.fs\n * @param {string} args.gitdir\n * @param {string} args.ref - The tag to delete\n *\n * @returns {Promise<void>} Resolves successfully when filesystem operations are complete\n *\n * @example\n * await git.deleteTag({ dir: '$input((/))', ref: '$input((test-tag))' })\n * console.log('done')\n *\n */\nasync function _deleteTag({ fs, gitdir, ref }) {\n ref = ref.startsWith('refs/tags/') ? ref : `refs/tags/${ref}`;\n await GitRefManager.deleteRef({ fs, gitdir, ref });\n}\n\n// @ts-check\n\n/**\n * Delete a local tag ref\n *\n * @param {Object} args\n * @param {FsClient} args.fs - a file system implementation\n * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {string} args.ref - The tag to delete\n *\n * @returns {Promise<void>} Resolves successfully when filesystem operations are complete\n *\n * @example\n * await git.deleteTag({ fs, dir: '/tutorial', ref: 'test-tag' })\n * console.log('done')\n *\n */\nasync function deleteTag({ fs, dir, gitdir = join(dir, '.git'), ref }) {\n try {\n assertParameter('fs', fs);\n assertParameter('ref', ref);\n return await _deleteTag({\n fs: new FileSystem(fs),\n gitdir,\n ref,\n })\n } catch (err) {\n err.caller = 'git.deleteTag';\n throw err\n }\n}\n\nasync function expandOidLoose({ fs, gitdir, oid: short }) {\n const prefix = short.slice(0, 2);\n const objectsSuffixes = await fs.readdir(`${gitdir}/objects/${prefix}`);\n return objectsSuffixes\n .map(suffix => `${prefix}${suffix}`)\n .filter(_oid => _oid.startsWith(short))\n}\n\nasync function expandOidPacked({\n fs,\n cache,\n gitdir,\n oid: short,\n getExternalRefDelta,\n}) {\n // Iterate through all the .pack files\n const results = [];\n let list = await fs.readdir(join(gitdir, 'objects/pack'));\n list = list.filter(x => x.endsWith('.idx'));\n for (const filename of list) {\n const indexFile = `${gitdir}/objects/pack/${filename}`;\n const p = await readPackIndex({\n fs,\n cache,\n filename: indexFile,\n getExternalRefDelta,\n });\n if (p.error) throw new InternalError(p.error)\n // Search through the list of oids in the packfile\n for (const oid of p.offsets.keys()) {\n if (oid.startsWith(short)) results.push(oid);\n }\n }\n return results\n}\n\nasync function _expandOid({ fs, cache, gitdir, oid: short }) {\n // Curry the current read method so that the packfile un-deltification\n // process can acquire external ref-deltas.\n const getExternalRefDelta = oid => _readObject({ fs, cache, gitdir, oid });\n\n const results = await expandOidLoose({ fs, gitdir, oid: short });\n const packedOids = await expandOidPacked({\n fs,\n cache,\n gitdir,\n oid: short,\n getExternalRefDelta,\n });\n // Objects can exist in a pack file as well as loose, make sure we only get a list of unique oids.\n for (const packedOid of packedOids) {\n if (results.indexOf(packedOid) === -1) {\n results.push(packedOid);\n }\n }\n\n if (results.length === 1) {\n return results[0]\n }\n if (results.length > 1) {\n throw new AmbiguousError('oids', short, results)\n }\n throw new NotFoundError(`an object matching \"${short}\"`)\n}\n\n// @ts-check\n\n/**\n * Expand and resolve a short oid into a full oid\n *\n * @param {Object} args\n * @param {FsClient} args.fs - a file system implementation\n * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {string} args.oid - The shortened oid prefix to expand (like \"0414d2a\")\n * @param {object} [args.cache] - a [cache](cache.md) object\n *\n * @returns {Promise<string>} Resolves successfully with the full oid (like \"0414d2a286d7bbc7a4a326a61c1f9f888a8ab87f\")\n *\n * @example\n * let oid = await git.expandOid({ fs, dir: '/tutorial', oid: '0414d2a'})\n * console.log(oid)\n *\n */\nasync function expandOid({\n fs,\n dir,\n gitdir = join(dir, '.git'),\n oid,\n cache = {},\n}) {\n try {\n assertParameter('fs', fs);\n assertParameter('gitdir', gitdir);\n assertParameter('oid', oid);\n return await _expandOid({\n fs: new FileSystem(fs),\n cache,\n gitdir,\n oid,\n })\n } catch (err) {\n err.caller = 'git.expandOid';\n throw err\n }\n}\n\n// @ts-check\n\n/**\n * Expand an abbreviated ref to its full name\n *\n * @param {Object} args\n * @param {FsClient} args.fs - a file system implementation\n * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {string} args.ref - The ref to expand (like \"v1.0.0\")\n *\n * @returns {Promise<string>} Resolves successfully with a full ref name (\"refs/tags/v1.0.0\")\n *\n * @example\n * let fullRef = await git.expandRef({ fs, dir: '/tutorial', ref: 'main'})\n * console.log(fullRef)\n *\n */\nasync function expandRef({ fs, dir, gitdir = join(dir, '.git'), ref }) {\n try {\n assertParameter('fs', fs);\n assertParameter('gitdir', gitdir);\n assertParameter('ref', ref);\n return await GitRefManager.expand({\n fs: new FileSystem(fs),\n gitdir,\n ref,\n })\n } catch (err) {\n err.caller = 'git.expandRef';\n throw err\n }\n}\n\n// @ts-check\n\n/**\n * @param {object} args\n * @param {import('../models/FileSystem.js').FileSystem} args.fs\n * @param {any} args.cache\n * @param {string} args.gitdir\n * @param {string[]} args.oids\n *\n */\nasync function _findMergeBase({ fs, cache, gitdir, oids }) {\n // Note: right now, the tests are geared so that the output should match that of\n // `git merge-base --all --octopus`\n // because without the --octopus flag, git's output seems to depend on the ORDER of the oids,\n // and computing virtual merge bases is just too much for me to fathom right now.\n\n // If we start N independent walkers, one at each of the given `oids`, and walk backwards\n // through ancestors, eventually we'll discover a commit where each one of these N walkers\n // has passed through. So we just need to keep track of which walkers have visited each commit\n // until we find a commit that N distinct walkers has visited.\n const visits = {};\n const passes = oids.length;\n let heads = oids.map((oid, index) => ({ index, oid }));\n while (heads.length) {\n // Count how many times we've passed each commit\n const result = new Set();\n for (const { oid, index } of heads) {\n if (!visits[oid]) visits[oid] = new Set();\n visits[oid].add(index);\n if (visits[oid].size === passes) {\n result.add(oid);\n }\n }\n if (result.size > 0) {\n return [...result]\n }\n // We haven't found a common ancestor yet\n const newheads = new Map();\n for (const { oid, index } of heads) {\n try {\n const { object } = await _readObject({ fs, cache, gitdir, oid });\n const commit = GitCommit.from(object);\n const { parent } = commit.parseHeaders();\n for (const oid of parent) {\n if (!visits[oid] || !visits[oid].has(index)) {\n newheads.set(oid + ':' + index, { oid, index });\n }\n }\n } catch (err) {\n // do nothing\n }\n }\n heads = Array.from(newheads.values());\n }\n return []\n}\n\nconst LINEBREAKS = /^.*(\\r?\\n|$)/gm;\n\nfunction mergeFile({ branches, contents }) {\n const ourName = branches[1];\n const theirName = branches[2];\n\n const baseContent = contents[0];\n const ourContent = contents[1];\n const theirContent = contents[2];\n\n const ours = ourContent.match(LINEBREAKS);\n const base = baseContent.match(LINEBREAKS);\n const theirs = theirContent.match(LINEBREAKS);\n\n // Here we let the diff3 library do the heavy lifting.\n const result = diff3Merge(ours, base, theirs);\n\n const markerSize = 7;\n\n // Here we note whether there are conflicts and format the results\n let mergedText = '';\n let cleanMerge = true;\n\n for (const item of result) {\n if (item.ok) {\n mergedText += item.ok.join('');\n }\n if (item.conflict) {\n cleanMerge = false;\n mergedText += `${'<'.repeat(markerSize)} ${ourName}\\n`;\n mergedText += item.conflict.a.join('');\n\n mergedText += `${'='.repeat(markerSize)}\\n`;\n mergedText += item.conflict.b.join('');\n mergedText += `${'>'.repeat(markerSize)} ${theirName}\\n`;\n }\n }\n return { cleanMerge, mergedText }\n}\n\n// @ts-check\n\n/**\n * Create a merged tree\n *\n * @param {Object} args\n * @param {import('../models/FileSystem.js').FileSystem} args.fs\n * @param {object} args.cache\n * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {string} args.ourOid - The SHA-1 object id of our tree\n * @param {string} args.baseOid - The SHA-1 object id of the base tree\n * @param {string} args.theirOid - The SHA-1 object id of their tree\n * @param {string} [args.ourName='ours'] - The name to use in conflicted files for our hunks\n * @param {string} [args.baseName='base'] - The name to use in conflicted files (in diff3 format) for the base hunks\n * @param {string} [args.theirName='theirs'] - The name to use in conflicted files for their hunks\n * @param {boolean} [args.dryRun=false]\n * @param {boolean} [args.abortOnConflict=false]\n * @param {MergeDriverCallback} [args.mergeDriver]\n *\n * @returns {Promise<string>} - The SHA-1 object id of the merged tree\n *\n */\nasync function mergeTree({\n fs,\n cache,\n dir,\n gitdir = join(dir, '.git'),\n index,\n ourOid,\n baseOid,\n theirOid,\n ourName = 'ours',\n baseName = 'base',\n theirName = 'theirs',\n dryRun = false,\n abortOnConflict = true,\n mergeDriver,\n}) {\n const ourTree = TREE({ ref: ourOid });\n const baseTree = TREE({ ref: baseOid });\n const theirTree = TREE({ ref: theirOid });\n\n const unmergedFiles = [];\n const bothModified = [];\n const deleteByUs = [];\n const deleteByTheirs = [];\n\n const results = await _walk({\n fs,\n cache,\n dir,\n gitdir,\n trees: [ourTree, baseTree, theirTree],\n map: async function(filepath, [ours, base, theirs]) {\n const path = basename(filepath);\n // What we did, what they did\n const ourChange = await modified(ours, base);\n const theirChange = await modified(theirs, base);\n switch (`${ourChange}-${theirChange}`) {\n case 'false-false': {\n return {\n mode: await base.mode(),\n path,\n oid: await base.oid(),\n type: await base.type(),\n }\n }\n case 'false-true': {\n return theirs\n ? {\n mode: await theirs.mode(),\n path,\n oid: await theirs.oid(),\n type: await theirs.type(),\n }\n : undefined\n }\n case 'true-false': {\n return ours\n ? {\n mode: await ours.mode(),\n path,\n oid: await ours.oid(),\n type: await ours.type(),\n }\n : undefined\n }\n case 'true-true': {\n // Modifications\n if (\n ours &&\n base &&\n theirs &&\n (await ours.type()) === 'blob' &&\n (await base.type()) === 'blob' &&\n (await theirs.type()) === 'blob'\n ) {\n return mergeBlobs({\n fs,\n gitdir,\n path,\n ours,\n base,\n theirs,\n ourName,\n baseName,\n theirName,\n mergeDriver,\n }).then(async r => {\n if (!r.cleanMerge) {\n unmergedFiles.push(filepath);\n bothModified.push(filepath);\n if (!abortOnConflict) {\n const baseOid = await base.oid();\n const ourOid = await ours.oid();\n const theirOid = await theirs.oid();\n\n index.delete({ filepath });\n\n index.insert({ filepath, oid: baseOid, stage: 1 });\n index.insert({ filepath, oid: ourOid, stage: 2 });\n index.insert({ filepath, oid: theirOid, stage: 3 });\n }\n } else if (!abortOnConflict) {\n index.insert({ filepath, oid: r.mergeResult.oid, stage: 0 });\n }\n return r.mergeResult\n })\n }\n\n // deleted by us\n if (\n base &&\n !ours &&\n theirs &&\n (await base.type()) === 'blob' &&\n (await theirs.type()) === 'blob'\n ) {\n unmergedFiles.push(filepath);\n deleteByUs.push(filepath);\n if (!abortOnConflict) {\n const baseOid = await base.oid();\n const theirOid = await theirs.oid();\n\n index.delete({ filepath });\n\n index.insert({ filepath, oid: baseOid, stage: 1 });\n index.insert({ filepath, oid: theirOid, stage: 3 });\n }\n\n return {\n mode: await theirs.mode(),\n oid: await theirs.oid(),\n type: 'blob',\n path,\n }\n }\n\n // deleted by theirs\n if (\n base &&\n ours &&\n !theirs &&\n (await base.type()) === 'blob' &&\n (await ours.type()) === 'blob'\n ) {\n unmergedFiles.push(filepath);\n deleteByTheirs.push(filepath);\n if (!abortOnConflict) {\n const baseOid = await base.oid();\n const ourOid = await ours.oid();\n\n index.delete({ filepath });\n\n index.insert({ filepath, oid: baseOid, stage: 1 });\n index.insert({ filepath, oid: ourOid, stage: 2 });\n }\n\n return {\n mode: await ours.mode(),\n oid: await ours.oid(),\n type: 'blob',\n path,\n }\n }\n\n // deleted by both\n if (base && !ours && !theirs && (await base.type()) === 'blob') {\n return undefined\n }\n\n // all other types of conflicts fail\n // TODO: Merge conflicts involving additions\n throw new MergeNotSupportedError()\n }\n }\n },\n /**\n * @param {TreeEntry} [parent]\n * @param {Array<TreeEntry>} children\n */\n reduce:\n unmergedFiles.length !== 0 && (!dir || abortOnConflict)\n ? undefined\n : async (parent, children) => {\n const entries = children.filter(Boolean); // remove undefineds\n\n // if the parent was deleted, the children have to go\n if (!parent) return\n\n // automatically delete directories if they have been emptied\n if (parent && parent.type === 'tree' && entries.length === 0) return\n\n if (entries.length > 0) {\n const tree = new GitTree(entries);\n const object = tree.toObject();\n const oid = await _writeObject({\n fs,\n gitdir,\n type: 'tree',\n object,\n dryRun,\n });\n parent.oid = oid;\n }\n return parent\n },\n });\n\n if (unmergedFiles.length !== 0) {\n if (dir && !abortOnConflict) {\n await _walk({\n fs,\n cache,\n dir,\n gitdir,\n trees: [TREE({ ref: results.oid })],\n map: async function(filepath, [entry]) {\n const path = `${dir}/${filepath}`;\n if ((await entry.type()) === 'blob') {\n const mode = await entry.mode();\n const content = new TextDecoder().decode(await entry.content());\n await fs.write(path, content, { mode });\n }\n return true\n },\n });\n }\n return new MergeConflictError(\n unmergedFiles,\n bothModified,\n deleteByUs,\n deleteByTheirs\n )\n }\n\n return results.oid\n}\n\n/**\n *\n * @param {Object} args\n * @param {import('../models/FileSystem').FileSystem} args.fs\n * @param {string} args.gitdir\n * @param {string} args.path\n * @param {WalkerEntry} args.ours\n * @param {WalkerEntry} args.base\n * @param {WalkerEntry} args.theirs\n * @param {string} [args.ourName]\n * @param {string} [args.baseName]\n * @param {string} [args.theirName]\n * @param {boolean} [args.dryRun = false]\n * @param {MergeDriverCallback} [args.mergeDriver]\n *\n */\nasync function mergeBlobs({\n fs,\n gitdir,\n path,\n ours,\n base,\n theirs,\n ourName,\n theirName,\n baseName,\n dryRun,\n mergeDriver = mergeFile,\n}) {\n const type = 'blob';\n // Compute the new mode.\n // Since there are ONLY two valid blob modes ('100755' and '100644') it boils down to this\n const mode =\n (await base.mode()) === (await ours.mode())\n ? await theirs.mode()\n : await ours.mode();\n // The trivial case: nothing to merge except maybe mode\n if ((await ours.oid()) === (await theirs.oid())) {\n return {\n cleanMerge: true,\n mergeResult: { mode, path, oid: await ours.oid(), type },\n }\n }\n // if only one side made oid changes, return that side's oid\n if ((await ours.oid()) === (await base.oid())) {\n return {\n cleanMerge: true,\n mergeResult: { mode, path, oid: await theirs.oid(), type },\n }\n }\n if ((await theirs.oid()) === (await base.oid())) {\n return {\n cleanMerge: true,\n mergeResult: { mode, path, oid: await ours.oid(), type },\n }\n }\n // if both sides made changes do a merge\n const ourContent = Buffer.from(await ours.content()).toString('utf8');\n const baseContent = Buffer.from(await base.content()).toString('utf8');\n const theirContent = Buffer.from(await theirs.content()).toString('utf8');\n const { mergedText, cleanMerge } = await mergeDriver({\n branches: [baseName, ourName, theirName],\n contents: [baseContent, ourContent, theirContent],\n path,\n });\n const oid = await _writeObject({\n fs,\n gitdir,\n type: 'blob',\n object: Buffer.from(mergedText, 'utf8'),\n dryRun,\n });\n\n return { cleanMerge, mergeResult: { mode, path, oid, type } }\n}\n\n// @ts-check\n\n// import diff3 from 'node-diff3'\n/**\n *\n * @typedef {Object} MergeResult - Returns an object with a schema like this:\n * @property {string} [oid] - The SHA-1 object id that is now at the head of the branch. Absent only if `dryRun` was specified and `mergeCommit` is true.\n * @property {boolean} [alreadyMerged] - True if the branch was already merged so no changes were made\n * @property {boolean} [fastForward] - True if it was a fast-forward merge\n * @property {boolean} [mergeCommit] - True if merge resulted in a merge commit\n * @property {string} [tree] - The SHA-1 object id of the tree resulting from a merge commit\n *\n */\n\n/**\n * @param {object} args\n * @param {import('../models/FileSystem.js').FileSystem} args.fs\n * @param {object} args.cache\n * @param {string} args.gitdir\n * @param {string} [args.ours]\n * @param {string} args.theirs\n * @param {boolean} args.fastForward\n * @param {boolean} args.fastForwardOnly\n * @param {boolean} args.dryRun\n * @param {boolean} args.noUpdateBranch\n * @param {boolean} args.abortOnConflict\n * @param {string} [args.message]\n * @param {Object} args.author\n * @param {string} args.author.name\n * @param {string} args.author.email\n * @param {number} args.author.timestamp\n * @param {number} args.author.timezoneOffset\n * @param {Object} args.committer\n * @param {string} args.committer.name\n * @param {string} args.committer.email\n * @param {number} args.committer.timestamp\n * @param {number} args.committer.timezoneOffset\n * @param {string} [args.signingKey]\n * @param {SignCallback} [args.onSign] - a PGP signing implementation\n * @param {MergeDriverCallback} [args.mergeDriver]\n *\n * @returns {Promise<MergeResult>} Resolves to a description of the merge operation\n *\n */\nasync function _merge({\n fs,\n cache,\n dir,\n gitdir,\n ours,\n theirs,\n fastForward = true,\n fastForwardOnly = false,\n dryRun = false,\n noUpdateBranch = false,\n abortOnConflict = true,\n message,\n author,\n committer,\n signingKey,\n onSign,\n mergeDriver,\n}) {\n if (ours === undefined) {\n ours = await _currentBranch({ fs, gitdir, fullname: true });\n }\n ours = await GitRefManager.expand({\n fs,\n gitdir,\n ref: ours,\n });\n theirs = await GitRefManager.expand({\n fs,\n gitdir,\n ref: theirs,\n });\n const ourOid = await GitRefManager.resolve({\n fs,\n gitdir,\n ref: ours,\n });\n const theirOid = await GitRefManager.resolve({\n fs,\n gitdir,\n ref: theirs,\n });\n // find most recent common ancestor of ref a and ref b\n const baseOids = await _findMergeBase({\n fs,\n cache,\n gitdir,\n oids: [ourOid, theirOid],\n });\n if (baseOids.length !== 1) {\n // TODO: Recursive Merge strategy\n throw new MergeNotSupportedError()\n }\n const baseOid = baseOids[0];\n // handle fast-forward case\n if (baseOid === theirOid) {\n return {\n oid: ourOid,\n alreadyMerged: true,\n }\n }\n if (fastForward && baseOid === ourOid) {\n if (!dryRun && !noUpdateBranch) {\n await GitRefManager.writeRef({ fs, gitdir, ref: ours, value: theirOid });\n }\n return {\n oid: theirOid,\n fastForward: true,\n }\n } else {\n // not a simple fast-forward\n if (fastForwardOnly) {\n throw new FastForwardError()\n }\n // try a fancier merge\n const tree = await GitIndexManager.acquire(\n { fs, gitdir, cache, allowUnmerged: false },\n async index => {\n return mergeTree({\n fs,\n cache,\n dir,\n gitdir,\n index,\n ourOid,\n theirOid,\n baseOid,\n ourName: abbreviateRef(ours),\n baseName: 'base',\n theirName: abbreviateRef(theirs),\n dryRun,\n abortOnConflict,\n mergeDriver,\n })\n }\n );\n\n // Defer throwing error until the index lock is relinquished and index is\n // written to filsesystem\n if (tree instanceof MergeConflictError) throw tree\n\n if (!message) {\n message = `Merge branch '${abbreviateRef(theirs)}' into ${abbreviateRef(\n ours\n )}`;\n }\n const oid = await _commit({\n fs,\n cache,\n gitdir,\n message,\n ref: ours,\n tree,\n parent: [ourOid, theirOid],\n author,\n committer,\n signingKey,\n onSign,\n dryRun,\n noUpdateBranch,\n });\n return {\n oid,\n tree,\n mergeCommit: true,\n }\n }\n}\n\n// @ts-check\n\n/**\n * @param {object} args\n * @param {import('../models/FileSystem.js').FileSystem} args.fs\n * @param {object} args.cache\n * @param {HttpClient} args.http\n * @param {ProgressCallback} [args.onProgress]\n * @param {MessageCallback} [args.onMessage]\n * @param {AuthCallback} [args.onAuth]\n * @param {AuthFailureCallback} [args.onAuthFailure]\n * @param {AuthSuccessCallback} [args.onAuthSuccess]\n * @param {string} args.dir\n * @param {string} args.gitdir\n * @param {string} args.ref\n * @param {string} [args.url]\n * @param {string} [args.remote]\n * @param {string} [args.remoteRef]\n * @param {boolean} [args.prune]\n * @param {boolean} [args.pruneTags]\n * @param {string} [args.corsProxy]\n * @param {boolean} args.singleBranch\n * @param {boolean} args.fastForward\n * @param {boolean} args.fastForwardOnly\n * @param {Object<string, string>} [args.headers]\n * @param {Object} args.author\n * @param {string} args.author.name\n * @param {string} args.author.email\n * @param {number} args.author.timestamp\n * @param {number} args.author.timezoneOffset\n * @param {Object} args.committer\n * @param {string} args.committer.name\n * @param {string} args.committer.email\n * @param {number} args.committer.timestamp\n * @param {number} args.committer.timezoneOffset\n * @param {string} [args.signingKey]\n *\n * @returns {Promise<void>} Resolves successfully when pull operation completes\n *\n */\nasync function _pull({\n fs,\n cache,\n http,\n onProgress,\n onMessage,\n onAuth,\n onAuthSuccess,\n onAuthFailure,\n dir,\n gitdir,\n ref,\n url,\n remote,\n remoteRef,\n prune,\n pruneTags,\n fastForward,\n fastForwardOnly,\n corsProxy,\n singleBranch,\n headers,\n author,\n committer,\n signingKey,\n}) {\n try {\n // If ref is undefined, use 'HEAD'\n if (!ref) {\n const head = await _currentBranch({ fs, gitdir });\n // TODO: use a better error.\n if (!head) {\n throw new MissingParameterError('ref')\n }\n ref = head;\n }\n\n const { fetchHead, fetchHeadDescription } = await _fetch({\n fs,\n cache,\n http,\n onProgress,\n onMessage,\n onAuth,\n onAuthSuccess,\n onAuthFailure,\n gitdir,\n corsProxy,\n ref,\n url,\n remote,\n remoteRef,\n singleBranch,\n headers,\n prune,\n pruneTags,\n });\n // Merge the remote tracking branch into the local one.\n await _merge({\n fs,\n cache,\n gitdir,\n ours: ref,\n theirs: fetchHead,\n fastForward,\n fastForwardOnly,\n message: `Merge ${fetchHeadDescription}`,\n author,\n committer,\n signingKey,\n dryRun: false,\n noUpdateBranch: false,\n });\n await _checkout({\n fs,\n cache,\n onProgress,\n dir,\n gitdir,\n ref,\n remote,\n noCheckout: false,\n });\n } catch (err) {\n err.caller = 'git.pull';\n throw err\n }\n}\n\n// @ts-check\n\n/**\n * Like `pull`, but hard-coded with `fastForward: true` so there is no need for an `author` parameter.\n *\n * @param {object} args\n * @param {FsClient} args.fs - a file system client\n * @param {HttpClient} args.http - an HTTP client\n * @param {ProgressCallback} [args.onProgress] - optional progress event callback\n * @param {MessageCallback} [args.onMessage] - optional message event callback\n * @param {AuthCallback} [args.onAuth] - optional auth fill callback\n * @param {AuthFailureCallback} [args.onAuthFailure] - optional auth rejected callback\n * @param {AuthSuccessCallback} [args.onAuthSuccess] - optional auth approved callback\n * @param {string} args.dir] - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {string} [args.ref] - Which branch to merge into. By default this is the currently checked out branch.\n * @param {string} [args.url] - (Added in 1.1.0) The URL of the remote repository. The default is the value set in the git config for that remote.\n * @param {string} [args.remote] - (Added in 1.1.0) If URL is not specified, determines which remote to use.\n * @param {string} [args.remoteRef] - (Added in 1.1.0) The name of the branch on the remote to fetch. By default this is the configured remote tracking branch.\n * @param {string} [args.corsProxy] - Optional [CORS proxy](https://www.npmjs.com/%40isomorphic-git/cors-proxy). Overrides value in repo config.\n * @param {boolean} [args.singleBranch = false] - Instead of the default behavior of fetching all the branches, only fetch a single branch.\n * @param {Object<string, string>} [args.headers] - Additional headers to include in HTTP requests, similar to git's `extraHeader` config\n * @param {object} [args.cache] - a [cache](cache.md) object\n *\n * @returns {Promise<void>} Resolves successfully when pull operation completes\n *\n * @example\n * await git.fastForward({\n * fs,\n * http,\n * dir: '/tutorial',\n * ref: 'main',\n * singleBranch: true\n * })\n * console.log('done')\n *\n */\nasync function fastForward({\n fs,\n http,\n onProgress,\n onMessage,\n onAuth,\n onAuthSuccess,\n onAuthFailure,\n dir,\n gitdir = join(dir, '.git'),\n ref,\n url,\n remote,\n remoteRef,\n corsProxy,\n singleBranch,\n headers = {},\n cache = {},\n}) {\n try {\n assertParameter('fs', fs);\n assertParameter('http', http);\n assertParameter('gitdir', gitdir);\n\n const thisWillNotBeUsed = {\n name: '',\n email: '',\n timestamp: Date.now(),\n timezoneOffset: 0,\n };\n\n return await _pull({\n fs: new FileSystem(fs),\n cache,\n http,\n onProgress,\n onMessage,\n onAuth,\n onAuthSuccess,\n onAuthFailure,\n dir,\n gitdir,\n ref,\n url,\n remote,\n remoteRef,\n fastForwardOnly: true,\n corsProxy,\n singleBranch,\n headers,\n author: thisWillNotBeUsed,\n committer: thisWillNotBeUsed,\n })\n } catch (err) {\n err.caller = 'git.fastForward';\n throw err\n }\n}\n\n// @ts-check\n\n/**\n *\n * @typedef {object} FetchResult - The object returned has the following schema:\n * @property {string | null} defaultBranch - The branch that is cloned if no branch is specified\n * @property {string | null} fetchHead - The SHA-1 object id of the fetched head commit\n * @property {string | null} fetchHeadDescription - a textual description of the branch that was fetched\n * @property {Object<string, string>} [headers] - The HTTP response headers returned by the git server\n * @property {string[]} [pruned] - A list of branches that were pruned, if you provided the `prune` parameter\n *\n */\n\n/**\n * Fetch commits from a remote repository\n *\n * @param {object} args\n * @param {FsClient} args.fs - a file system client\n * @param {HttpClient} args.http - an HTTP client\n * @param {ProgressCallback} [args.onProgress] - optional progress event callback\n * @param {MessageCallback} [args.onMessage] - optional message event callback\n * @param {AuthCallback} [args.onAuth] - optional auth fill callback\n * @param {AuthFailureCallback} [args.onAuthFailure] - optional auth rejected callback\n * @param {AuthSuccessCallback} [args.onAuthSuccess] - optional auth approved callback\n * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {string} [args.url] - The URL of the remote repository. The default is the value set in the git config for that remote.\n * @param {string} [args.remote] - If URL is not specified, determines which remote to use.\n * @param {boolean} [args.singleBranch = false] - Instead of the default behavior of fetching all the branches, only fetch a single branch.\n * @param {string} [args.ref] - Which branch to fetch if `singleBranch` is true. By default this is the current branch or the remote's default branch.\n * @param {string} [args.remoteRef] - The name of the branch on the remote to fetch if `singleBranch` is true. By default this is the configured remote tracking branch.\n * @param {boolean} [args.tags = false] - Also fetch tags\n * @param {number} [args.depth] - Integer. Determines how much of the git repository's history to retrieve\n * @param {boolean} [args.relative = false] - Changes the meaning of `depth` to be measured from the current shallow depth rather than from the branch tip.\n * @param {Date} [args.since] - Only fetch commits created after the given date. Mutually exclusive with `depth`.\n * @param {string[]} [args.exclude = []] - A list of branches or tags. Instructs the remote server not to send us any commits reachable from these refs.\n * @param {boolean} [args.prune = false] - Delete local remote-tracking branches that are not present on the remote\n * @param {boolean} [args.pruneTags = false] - Prune local tags that don’t exist on the remote, and force-update those tags that differ\n * @param {string} [args.corsProxy] - Optional [CORS proxy](https://www.npmjs.com/%40isomorphic-git/cors-proxy). Overrides value in repo config.\n * @param {Object<string, string>} [args.headers] - Additional headers to include in HTTP requests, similar to git's `extraHeader` config\n * @param {object} [args.cache] - a [cache](cache.md) object\n *\n * @returns {Promise<FetchResult>} Resolves successfully when fetch completes\n * @see FetchResult\n *\n * @example\n * let result = await git.fetch({\n * fs,\n * http,\n * dir: '/tutorial',\n * corsProxy: 'https://cors.isomorphic-git.org',\n * url: 'https://github.com/isomorphic-git/isomorphic-git',\n * ref: 'main',\n * depth: 1,\n * singleBranch: true,\n * tags: false\n * })\n * console.log(result)\n *\n */\nasync function fetch({\n fs,\n http,\n onProgress,\n onMessage,\n onAuth,\n onAuthSuccess,\n onAuthFailure,\n dir,\n gitdir = join(dir, '.git'),\n ref,\n remote,\n remoteRef,\n url,\n corsProxy,\n depth = null,\n since = null,\n exclude = [],\n relative = false,\n tags = false,\n singleBranch = false,\n headers = {},\n prune = false,\n pruneTags = false,\n cache = {},\n}) {\n try {\n assertParameter('fs', fs);\n assertParameter('http', http);\n assertParameter('gitdir', gitdir);\n\n return await _fetch({\n fs: new FileSystem(fs),\n cache,\n http,\n onProgress,\n onMessage,\n onAuth,\n onAuthSuccess,\n onAuthFailure,\n gitdir,\n ref,\n remote,\n remoteRef,\n url,\n corsProxy,\n depth,\n since,\n exclude,\n relative,\n tags,\n singleBranch,\n headers,\n prune,\n pruneTags,\n })\n } catch (err) {\n err.caller = 'git.fetch';\n throw err\n }\n}\n\n// @ts-check\n\n/**\n * Find the merge base for a set of commits\n *\n * @param {object} args\n * @param {FsClient} args.fs - a file system client\n * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {string[]} args.oids - Which commits\n * @param {object} [args.cache] - a [cache](cache.md) object\n *\n */\nasync function findMergeBase({\n fs,\n dir,\n gitdir = join(dir, '.git'),\n oids,\n cache = {},\n}) {\n try {\n assertParameter('fs', fs);\n assertParameter('gitdir', gitdir);\n assertParameter('oids', oids);\n\n return await _findMergeBase({\n fs: new FileSystem(fs),\n cache,\n gitdir,\n oids,\n })\n } catch (err) {\n err.caller = 'git.findMergeBase';\n throw err\n }\n}\n\n// @ts-check\n\n/**\n * Find the root git directory\n *\n * Starting at `filepath`, walks upward until it finds a directory that contains a subdirectory called '.git'.\n *\n * @param {Object} args\n * @param {import('../models/FileSystem.js').FileSystem} args.fs\n * @param {string} args.filepath\n *\n * @returns {Promise<string>} Resolves successfully with a root git directory path\n */\nasync function _findRoot({ fs, filepath }) {\n if (await fs.exists(join(filepath, '.git'))) {\n return filepath\n } else {\n const parent = dirname(filepath);\n if (parent === filepath) {\n throw new NotFoundError(`git root for ${filepath}`)\n }\n return _findRoot({ fs, filepath: parent })\n }\n}\n\n// @ts-check\n\n/**\n * Find the root git directory\n *\n * Starting at `filepath`, walks upward until it finds a directory that contains a subdirectory called '.git'.\n *\n * @param {Object} args\n * @param {FsClient} args.fs - a file system client\n * @param {string} args.filepath - The file directory to start searching in.\n *\n * @returns {Promise<string>} Resolves successfully with a root git directory path\n * @throws {NotFoundError}\n *\n * @example\n * let gitroot = await git.findRoot({\n * fs,\n * filepath: '/tutorial/src/utils'\n * })\n * console.log(gitroot)\n *\n */\nasync function findRoot({ fs, filepath }) {\n try {\n assertParameter('fs', fs);\n assertParameter('filepath', filepath);\n\n return await _findRoot({ fs: new FileSystem(fs), filepath })\n } catch (err) {\n err.caller = 'git.findRoot';\n throw err\n }\n}\n\n// @ts-check\n\n/**\n * Read an entry from the git config files.\n *\n * *Caveats:*\n * - Currently only the local `$GIT_DIR/config` file can be read or written. However support for the global `~/.gitconfig` and system `$(prefix)/etc/gitconfig` will be added in the future.\n * - The current parser does not support the more exotic features of the git-config file format such as `[include]` and `[includeIf]`.\n *\n * @param {Object} args\n * @param {FsClient} args.fs - a file system implementation\n * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {string} args.path - The key of the git config entry\n *\n * @returns {Promise<any>} Resolves with the config value\n *\n * @example\n * // Read config value\n * let value = await git.getConfig({\n * fs,\n * dir: '/tutorial',\n * path: 'remote.origin.url'\n * })\n * console.log(value)\n *\n */\nasync function getConfig({ fs, dir, gitdir = join(dir, '.git'), path }) {\n try {\n assertParameter('fs', fs);\n assertParameter('gitdir', gitdir);\n assertParameter('path', path);\n\n return await _getConfig({\n fs: new FileSystem(fs),\n gitdir,\n path,\n })\n } catch (err) {\n err.caller = 'git.getConfig';\n throw err\n }\n}\n\n// @ts-check\n\n/**\n * @param {Object} args\n * @param {import('../models/FileSystem.js').FileSystem} args.fs\n * @param {string} args.gitdir\n * @param {string} args.path\n *\n * @returns {Promise<Array<any>>} Resolves with an array of the config value\n *\n */\nasync function _getConfigAll({ fs, gitdir, path }) {\n const config = await GitConfigManager.get({ fs, gitdir });\n return config.getall(path)\n}\n\n// @ts-check\n\n/**\n * Read a multi-valued entry from the git config files.\n *\n * *Caveats:*\n * - Currently only the local `$GIT_DIR/config` file can be read or written. However support for the global `~/.gitconfig` and system `$(prefix)/etc/gitconfig` will be added in the future.\n * - The current parser does not support the more exotic features of the git-config file format such as `[include]` and `[includeIf]`.\n *\n * @param {Object} args\n * @param {FsClient} args.fs - a file system implementation\n * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {string} args.path - The key of the git config entry\n *\n * @returns {Promise<Array<any>>} Resolves with the config value\n *\n */\nasync function getConfigAll({\n fs,\n dir,\n gitdir = join(dir, '.git'),\n path,\n}) {\n try {\n assertParameter('fs', fs);\n assertParameter('gitdir', gitdir);\n assertParameter('path', path);\n\n return await _getConfigAll({\n fs: new FileSystem(fs),\n gitdir,\n path,\n })\n } catch (err) {\n err.caller = 'git.getConfigAll';\n throw err\n }\n}\n\n// @ts-check\n\n/**\n *\n * @typedef {Object} GetRemoteInfoResult - The object returned has the following schema:\n * @property {string[]} capabilities - The list of capabilities returned by the server (part of the Git protocol)\n * @property {Object} [refs]\n * @property {string} [HEAD] - The default branch of the remote\n * @property {Object<string, string>} [refs.heads] - The branches on the remote\n * @property {Object<string, string>} [refs.pull] - The special branches representing pull requests (non-standard)\n * @property {Object<string, string>} [refs.tags] - The tags on the remote\n *\n */\n\n/**\n * List a remote servers branches, tags, and capabilities.\n *\n * This is a rare command that doesn't require an `fs`, `dir`, or even `gitdir` argument.\n * It just communicates to a remote git server, using the first step of the `git-upload-pack` handshake, but stopping short of fetching the packfile.\n *\n * @param {object} args\n * @param {HttpClient} args.http - an HTTP client\n * @param {AuthCallback} [args.onAuth] - optional auth fill callback\n * @param {AuthFailureCallback} [args.onAuthFailure] - optional auth rejected callback\n * @param {AuthSuccessCallback} [args.onAuthSuccess] - optional auth approved callback\n * @param {string} args.url - The URL of the remote repository. Will be gotten from gitconfig if absent.\n * @param {string} [args.corsProxy] - Optional [CORS proxy](https://www.npmjs.com/%40isomorphic-git/cors-proxy). Overrides value in repo config.\n * @param {boolean} [args.forPush = false] - By default, the command queries the 'fetch' capabilities. If true, it will ask for the 'push' capabilities.\n * @param {Object<string, string>} [args.headers] - Additional headers to include in HTTP requests, similar to git's `extraHeader` config\n *\n * @returns {Promise<GetRemoteInfoResult>} Resolves successfully with an object listing the branches, tags, and capabilities of the remote.\n * @see GetRemoteInfoResult\n *\n * @example\n * let info = await git.getRemoteInfo({\n * http,\n * url:\n * \"https://cors.isomorphic-git.org/github.com/isomorphic-git/isomorphic-git.git\"\n * });\n * console.log(info);\n *\n */\nasync function getRemoteInfo({\n http,\n onAuth,\n onAuthSuccess,\n onAuthFailure,\n corsProxy,\n url,\n headers = {},\n forPush = false,\n}) {\n try {\n assertParameter('http', http);\n assertParameter('url', url);\n\n const GitRemoteHTTP = GitRemoteManager.getRemoteHelperFor({ url });\n const remote = await GitRemoteHTTP.discover({\n http,\n onAuth,\n onAuthSuccess,\n onAuthFailure,\n corsProxy,\n service: forPush ? 'git-receive-pack' : 'git-upload-pack',\n url,\n headers,\n protocolVersion: 1,\n });\n\n // Note: remote.capabilities, remote.refs, and remote.symrefs are Set and Map objects,\n // but one of the objectives of the public API is to always return JSON-compatible objects\n // so we must JSONify them.\n const result = {\n capabilities: [...remote.capabilities],\n };\n // Convert the flat list into an object tree, because I figure 99% of the time\n // that will be easier to use.\n for (const [ref, oid] of remote.refs) {\n const parts = ref.split('/');\n const last = parts.pop();\n let o = result;\n for (const part of parts) {\n o[part] = o[part] || {};\n o = o[part];\n }\n o[last] = oid;\n }\n // Merge symrefs on top of refs to more closely match actual git repo layouts\n for (const [symref, ref] of remote.symrefs) {\n const parts = symref.split('/');\n const last = parts.pop();\n let o = result;\n for (const part of parts) {\n o[part] = o[part] || {};\n o = o[part];\n }\n o[last] = ref;\n }\n return result\n } catch (err) {\n err.caller = 'git.getRemoteInfo';\n throw err\n }\n}\n\n// @ts-check\n\n/**\n * @param {any} remote\n * @param {string} prefix\n * @param {boolean} symrefs\n * @param {boolean} peelTags\n * @returns {ServerRef[]}\n */\nfunction formatInfoRefs(remote, prefix, symrefs, peelTags) {\n const refs = [];\n for (const [key, value] of remote.refs) {\n if (prefix && !key.startsWith(prefix)) continue\n\n if (key.endsWith('^{}')) {\n if (peelTags) {\n const _key = key.replace('^{}', '');\n // Peeled tags are almost always listed immediately after the original tag\n const last = refs[refs.length - 1];\n const r = last.ref === _key ? last : refs.find(x => x.ref === _key);\n if (r === undefined) {\n throw new Error('I did not expect this to happen')\n }\n r.peeled = value;\n }\n continue\n }\n /** @type ServerRef */\n const ref = { ref: key, oid: value };\n if (symrefs) {\n if (remote.symrefs.has(key)) {\n ref.target = remote.symrefs.get(key);\n }\n }\n refs.push(ref);\n }\n return refs\n}\n\n// @ts-check\n\n/**\n * @typedef {Object} GetRemoteInfo2Result - This object has the following schema:\n * @property {1 | 2} protocolVersion - Git protocol version the server supports\n * @property {Object<string, string | true>} capabilities - An object of capabilities represented as keys and values\n * @property {ServerRef[]} [refs] - Server refs (they get returned by protocol version 1 whether you want them or not)\n */\n\n/**\n * List a remote server's capabilities.\n *\n * This is a rare command that doesn't require an `fs`, `dir`, or even `gitdir` argument.\n * It just communicates to a remote git server, determining what protocol version, commands, and features it supports.\n *\n * > The successor to [`getRemoteInfo`](./getRemoteInfo.md), this command supports Git Wire Protocol Version 2.\n * > Therefore its return type is more complicated as either:\n * >\n * > - v1 capabilities (and refs) or\n * > - v2 capabilities (and no refs)\n * >\n * > are returned.\n * > If you just care about refs, use [`listServerRefs`](./listServerRefs.md)\n *\n * @param {object} args\n * @param {HttpClient} args.http - an HTTP client\n * @param {AuthCallback} [args.onAuth] - optional auth fill callback\n * @param {AuthFailureCallback} [args.onAuthFailure] - optional auth rejected callback\n * @param {AuthSuccessCallback} [args.onAuthSuccess] - optional auth approved callback\n * @param {string} args.url - The URL of the remote repository. Will be gotten from gitconfig if absent.\n * @param {string} [args.corsProxy] - Optional [CORS proxy](https://www.npmjs.com/%40isomorphic-git/cors-proxy). Overrides value in repo config.\n * @param {boolean} [args.forPush = false] - By default, the command queries the 'fetch' capabilities. If true, it will ask for the 'push' capabilities.\n * @param {Object<string, string>} [args.headers] - Additional headers to include in HTTP requests, similar to git's `extraHeader` config\n * @param {1 | 2} [args.protocolVersion = 2] - Which version of the Git Protocol to use.\n *\n * @returns {Promise<GetRemoteInfo2Result>} Resolves successfully with an object listing the capabilities of the remote.\n * @see GetRemoteInfo2Result\n * @see ServerRef\n *\n * @example\n * let info = await git.getRemoteInfo2({\n * http,\n * corsProxy: \"https://cors.isomorphic-git.org\",\n * url: \"https://github.com/isomorphic-git/isomorphic-git.git\"\n * });\n * console.log(info);\n *\n */\nasync function getRemoteInfo2({\n http,\n onAuth,\n onAuthSuccess,\n onAuthFailure,\n corsProxy,\n url,\n headers = {},\n forPush = false,\n protocolVersion = 2,\n}) {\n try {\n assertParameter('http', http);\n assertParameter('url', url);\n\n const GitRemoteHTTP = GitRemoteManager.getRemoteHelperFor({ url });\n const remote = await GitRemoteHTTP.discover({\n http,\n onAuth,\n onAuthSuccess,\n onAuthFailure,\n corsProxy,\n service: forPush ? 'git-receive-pack' : 'git-upload-pack',\n url,\n headers,\n protocolVersion,\n });\n\n if (remote.protocolVersion === 2) {\n /** @type GetRemoteInfo2Result */\n return {\n protocolVersion: remote.protocolVersion,\n capabilities: remote.capabilities2,\n }\n }\n\n // Note: remote.capabilities, remote.refs, and remote.symrefs are Set and Map objects,\n // but one of the objectives of the public API is to always return JSON-compatible objects\n // so we must JSONify them.\n /** @type Object<string, true> */\n const capabilities = {};\n for (const cap of remote.capabilities) {\n const [key, value] = cap.split('=');\n if (value) {\n capabilities[key] = value;\n } else {\n capabilities[key] = true;\n }\n }\n /** @type GetRemoteInfo2Result */\n return {\n protocolVersion: 1,\n capabilities,\n refs: formatInfoRefs(remote, undefined, true, true),\n }\n } catch (err) {\n err.caller = 'git.getRemoteInfo2';\n throw err\n }\n}\n\nasync function hashObject({\n type,\n object,\n format = 'content',\n oid = undefined,\n}) {\n if (format !== 'deflated') {\n if (format !== 'wrapped') {\n object = GitObject.wrap({ type, object });\n }\n oid = await shasum(object);\n }\n return { oid, object }\n}\n\n// @ts-check\n\n/**\n *\n * @typedef {object} HashBlobResult - The object returned has the following schema:\n * @property {string} oid - The SHA-1 object id\n * @property {'blob'} type - The type of the object\n * @property {Uint8Array} object - The wrapped git object (the thing that is hashed)\n * @property {'wrapped'} format - The format of the object\n *\n */\n\n/**\n * Compute what the SHA-1 object id of a file would be\n *\n * @param {object} args\n * @param {Uint8Array|string} args.object - The object to write. If `object` is a String then it will be converted to a Uint8Array using UTF-8 encoding.\n *\n * @returns {Promise<HashBlobResult>} Resolves successfully with the SHA-1 object id and the wrapped object Uint8Array.\n * @see HashBlobResult\n *\n * @example\n * let { oid, type, object, format } = await git.hashBlob({\n * object: 'Hello world!',\n * })\n *\n * console.log('oid', oid)\n * console.log('type', type)\n * console.log('object', object)\n * console.log('format', format)\n *\n */\nasync function hashBlob({ object }) {\n try {\n assertParameter('object', object);\n\n // Convert object to buffer\n if (typeof object === 'string') {\n object = Buffer.from(object, 'utf8');\n } else {\n object = Buffer.from(object);\n }\n\n const type = 'blob';\n const { oid, object: _object } = await hashObject({\n type: 'blob',\n format: 'content',\n object,\n });\n return { oid, type, object: new Uint8Array(_object), format: 'wrapped' }\n } catch (err) {\n err.caller = 'git.hashBlob';\n throw err\n }\n}\n\n// @ts-check\n\n/**\n * @param {object} args\n * @param {import('../models/FileSystem.js').FileSystem} args.fs\n * @param {any} args.cache\n * @param {ProgressCallback} [args.onProgress]\n * @param {string} args.dir\n * @param {string} args.gitdir\n * @param {string} args.filepath\n *\n * @returns {Promise<{oids: string[]}>}\n */\nasync function _indexPack({\n fs,\n cache,\n onProgress,\n dir,\n gitdir,\n filepath,\n}) {\n try {\n filepath = join(dir, filepath);\n const pack = await fs.read(filepath);\n const getExternalRefDelta = oid => _readObject({ fs, cache, gitdir, oid });\n const idx = await GitPackIndex.fromPack({\n pack,\n getExternalRefDelta,\n onProgress,\n });\n await fs.write(filepath.replace(/\\.pack$/, '.idx'), await idx.toBuffer());\n return {\n oids: [...idx.hashes],\n }\n } catch (err) {\n err.caller = 'git.indexPack';\n throw err\n }\n}\n\n// @ts-check\n\n/**\n * Create the .idx file for a given .pack file\n *\n * @param {object} args\n * @param {FsClient} args.fs - a file system client\n * @param {ProgressCallback} [args.onProgress] - optional progress event callback\n * @param {string} args.dir - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {string} args.filepath - The path to the .pack file to index\n * @param {object} [args.cache] - a [cache](cache.md) object\n *\n * @returns {Promise<{oids: string[]}>} Resolves with a list of the SHA-1 object ids contained in the packfile\n *\n * @example\n * let packfiles = await fs.promises.readdir('/tutorial/.git/objects/pack')\n * packfiles = packfiles.filter(name => name.endsWith('.pack'))\n * console.log('packfiles', packfiles)\n *\n * const { oids } = await git.indexPack({\n * fs,\n * dir: '/tutorial',\n * filepath: `.git/objects/pack/${packfiles[0]}`,\n * async onProgress (evt) {\n * console.log(`${evt.phase}: ${evt.loaded} / ${evt.total}`)\n * }\n * })\n * console.log(oids)\n *\n */\nasync function indexPack({\n fs,\n onProgress,\n dir,\n gitdir = join(dir, '.git'),\n filepath,\n cache = {},\n}) {\n try {\n assertParameter('fs', fs);\n assertParameter('dir', dir);\n assertParameter('gitdir', dir);\n assertParameter('filepath', filepath);\n\n return await _indexPack({\n fs: new FileSystem(fs),\n cache,\n onProgress,\n dir,\n gitdir,\n filepath,\n })\n } catch (err) {\n err.caller = 'git.indexPack';\n throw err\n }\n}\n\n// @ts-check\n\n/**\n * Initialize a new repository\n *\n * @param {object} args\n * @param {FsClient} args.fs - a file system client\n * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {boolean} [args.bare = false] - Initialize a bare repository\n * @param {string} [args.defaultBranch = 'master'] - The name of the default branch (might be changed to a required argument in 2.0.0)\n * @returns {Promise<void>} Resolves successfully when filesystem operations are complete\n *\n * @example\n * await git.init({ fs, dir: '/tutorial' })\n * console.log('done')\n *\n */\nasync function init({\n fs,\n bare = false,\n dir,\n gitdir = bare ? dir : join(dir, '.git'),\n defaultBranch = 'master',\n}) {\n try {\n assertParameter('fs', fs);\n assertParameter('gitdir', gitdir);\n if (!bare) {\n assertParameter('dir', dir);\n }\n\n return await _init({\n fs: new FileSystem(fs),\n bare,\n dir,\n gitdir,\n defaultBranch,\n })\n } catch (err) {\n err.caller = 'git.init';\n throw err\n }\n}\n\n// @ts-check\n\n/**\n * @param {object} args\n * @param {import('../models/FileSystem.js').FileSystem} args.fs\n * @param {any} args.cache\n * @param {string} args.gitdir\n * @param {string} args.oid\n * @param {string} args.ancestor\n * @param {number} args.depth - Maximum depth to search before giving up. -1 means no maximum depth.\n *\n * @returns {Promise<boolean>}\n */\nasync function _isDescendent({\n fs,\n cache,\n gitdir,\n oid,\n ancestor,\n depth,\n}) {\n const shallows = await GitShallowManager.read({ fs, gitdir });\n if (!oid) {\n throw new MissingParameterError('oid')\n }\n if (!ancestor) {\n throw new MissingParameterError('ancestor')\n }\n // If you don't like this behavior, add your own check.\n // Edge cases are hard to define a perfect solution.\n if (oid === ancestor) return false\n // We do not use recursion here, because that would lead to depth-first traversal,\n // and we want to maintain a breadth-first traversal to avoid hitting shallow clone depth cutoffs.\n const queue = [oid];\n const visited = new Set();\n let searchdepth = 0;\n while (queue.length) {\n if (searchdepth++ === depth) {\n throw new MaxDepthError(depth)\n }\n const oid = queue.shift();\n const { type, object } = await _readObject({\n fs,\n cache,\n gitdir,\n oid,\n });\n if (type !== 'commit') {\n throw new ObjectTypeError(oid, type, 'commit')\n }\n const commit = GitCommit.from(object).parse();\n // Are any of the parents the sought-after ancestor?\n for (const parent of commit.parent) {\n if (parent === ancestor) return true\n }\n // If not, add them to heads (unless we know this is a shallow commit)\n if (!shallows.has(oid)) {\n for (const parent of commit.parent) {\n if (!visited.has(parent)) {\n queue.push(parent);\n visited.add(parent);\n }\n }\n }\n // Eventually, we'll travel entire tree to the roots where all the parents are empty arrays,\n // or hit the shallow depth and throw an error. Excluding the possibility of grafts, or\n // different branches cloned to different depths, you would hit this error at the same time\n // for all parents, so trying to continue is futile.\n }\n return false\n}\n\n// @ts-check\n\n/**\n * Check whether a git commit is descended from another\n *\n * @param {object} args\n * @param {FsClient} args.fs - a file system client\n * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {string} args.oid - The descendent commit\n * @param {string} args.ancestor - The (proposed) ancestor commit\n * @param {number} [args.depth = -1] - Maximum depth to search before giving up. -1 means no maximum depth.\n * @param {object} [args.cache] - a [cache](cache.md) object\n *\n * @returns {Promise<boolean>} Resolves to true if `oid` is a descendent of `ancestor`\n *\n * @example\n * let oid = await git.resolveRef({ fs, dir: '/tutorial', ref: 'main' })\n * let ancestor = await git.resolveRef({ fs, dir: '/tutorial', ref: 'v0.20.0' })\n * console.log(oid, ancestor)\n * await git.isDescendent({ fs, dir: '/tutorial', oid, ancestor, depth: -1 })\n *\n */\nasync function isDescendent({\n fs,\n dir,\n gitdir = join(dir, '.git'),\n oid,\n ancestor,\n depth = -1,\n cache = {},\n}) {\n try {\n assertParameter('fs', fs);\n assertParameter('gitdir', gitdir);\n assertParameter('oid', oid);\n assertParameter('ancestor', ancestor);\n\n return await _isDescendent({\n fs: new FileSystem(fs),\n cache,\n gitdir,\n oid,\n ancestor,\n depth,\n })\n } catch (err) {\n err.caller = 'git.isDescendent';\n throw err\n }\n}\n\n// @ts-check\n\n/**\n * Test whether a filepath should be ignored (because of .gitignore or .git/exclude)\n *\n * @param {object} args\n * @param {FsClient} args.fs - a file system client\n * @param {string} args.dir - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {string} args.filepath - The filepath to test\n *\n * @returns {Promise<boolean>} Resolves to true if the file should be ignored\n *\n * @example\n * await git.isIgnored({ fs, dir: '/tutorial', filepath: 'docs/add.md' })\n *\n */\nasync function isIgnored({\n fs,\n dir,\n gitdir = join(dir, '.git'),\n filepath,\n}) {\n try {\n assertParameter('fs', fs);\n assertParameter('dir', dir);\n assertParameter('gitdir', gitdir);\n assertParameter('filepath', filepath);\n\n return GitIgnoreManager.isIgnored({\n fs: new FileSystem(fs),\n dir,\n gitdir,\n filepath,\n })\n } catch (err) {\n err.caller = 'git.isIgnored';\n throw err\n }\n}\n\n// @ts-check\n\n/**\n * List branches\n *\n * By default it lists local branches. If a 'remote' is specified, it lists the remote's branches. When listing remote branches, the HEAD branch is not filtered out, so it may be included in the list of results.\n *\n * Note that specifying a remote does not actually contact the server and update the list of branches.\n * If you want an up-to-date list, first do a `fetch` to that remote.\n * (Which branch you fetch doesn't matter - the list of branches available on the remote is updated during the fetch handshake.)\n *\n * Also note, that a branch is a reference to a commit. If you initialize a new repository it has no commits, so the\n * `listBranches` function will return an empty list, until you create the first commit.\n *\n * @param {object} args\n * @param {FsClient} args.fs - a file system client\n * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {string} [args.remote] - Instead of the branches in `refs/heads`, list the branches in `refs/remotes/${remote}`.\n *\n * @returns {Promise<Array<string>>} Resolves successfully with an array of branch names\n *\n * @example\n * let branches = await git.listBranches({ fs, dir: '/tutorial' })\n * console.log(branches)\n * let remoteBranches = await git.listBranches({ fs, dir: '/tutorial', remote: 'origin' })\n * console.log(remoteBranches)\n *\n */\nasync function listBranches({\n fs,\n dir,\n gitdir = join(dir, '.git'),\n remote,\n}) {\n try {\n assertParameter('fs', fs);\n assertParameter('gitdir', gitdir);\n\n return GitRefManager.listBranches({\n fs: new FileSystem(fs),\n gitdir,\n remote,\n })\n } catch (err) {\n err.caller = 'git.listBranches';\n throw err\n }\n}\n\n// @ts-check\n\n/**\n * @param {object} args\n * @param {import('../models/FileSystem.js').FileSystem} args.fs\n * @param {object} args.cache\n * @param {string} args.gitdir\n * @param {string} [args.ref]\n *\n * @returns {Promise<Array<string>>}\n */\nasync function _listFiles({ fs, gitdir, ref, cache }) {\n if (ref) {\n const oid = await GitRefManager.resolve({ gitdir, fs, ref });\n const filenames = [];\n await accumulateFilesFromOid({\n fs,\n cache,\n gitdir,\n oid,\n filenames,\n prefix: '',\n });\n return filenames\n } else {\n return GitIndexManager.acquire({ fs, gitdir, cache }, async function(\n index\n ) {\n return index.entries.map(x => x.path)\n })\n }\n}\n\nasync function accumulateFilesFromOid({\n fs,\n cache,\n gitdir,\n oid,\n filenames,\n prefix,\n}) {\n const { tree } = await _readTree({ fs, cache, gitdir, oid });\n // TODO: Use `walk` to do this. Should be faster.\n for (const entry of tree) {\n if (entry.type === 'tree') {\n await accumulateFilesFromOid({\n fs,\n cache,\n gitdir,\n oid: entry.oid,\n filenames,\n prefix: join(prefix, entry.path),\n });\n } else {\n filenames.push(join(prefix, entry.path));\n }\n }\n}\n\n// @ts-check\n\n/**\n * List all the files in the git index or a commit\n *\n * > Note: This function is efficient for listing the files in the staging area, but listing all the files in a commit requires recursively walking through the git object store.\n * > If you do not require a complete list of every file, better performance can be achieved by using [walk](./walk) and ignoring subdirectories you don't care about.\n *\n * @param {object} args\n * @param {FsClient} args.fs - a file system client\n * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {string} [args.ref] - Return a list of all the files in the commit at `ref` instead of the files currently in the git index (aka staging area)\n * @param {object} [args.cache] - a [cache](cache.md) object\n *\n * @returns {Promise<Array<string>>} Resolves successfully with an array of filepaths\n *\n * @example\n * // All the files in the previous commit\n * let files = await git.listFiles({ fs, dir: '/tutorial', ref: 'HEAD' })\n * console.log(files)\n * // All the files in the current staging area\n * files = await git.listFiles({ fs, dir: '/tutorial' })\n * console.log(files)\n *\n */\nasync function listFiles({\n fs,\n dir,\n gitdir = join(dir, '.git'),\n ref,\n cache = {},\n}) {\n try {\n assertParameter('fs', fs);\n assertParameter('gitdir', gitdir);\n\n return await _listFiles({\n fs: new FileSystem(fs),\n cache,\n gitdir,\n ref,\n })\n } catch (err) {\n err.caller = 'git.listFiles';\n throw err\n }\n}\n\n// @ts-check\n\n/**\n * List all the object notes\n *\n * @param {object} args\n * @param {import('../models/FileSystem.js').FileSystem} args.fs\n * @param {any} args.cache\n * @param {string} args.gitdir\n * @param {string} args.ref\n *\n * @returns {Promise<Array<{target: string, note: string}>>}\n */\n\nasync function _listNotes({ fs, cache, gitdir, ref }) {\n // Get the current note commit\n let parent;\n try {\n parent = await GitRefManager.resolve({ gitdir, fs, ref });\n } catch (err) {\n if (err instanceof NotFoundError) {\n return []\n }\n }\n\n // Create the current note tree\n const result = await _readTree({\n fs,\n cache,\n gitdir,\n oid: parent,\n });\n\n // Format the tree entries\n const notes = result.tree.map(entry => ({\n target: entry.path,\n note: entry.oid,\n }));\n return notes\n}\n\n// @ts-check\n\n/**\n * List all the object notes\n *\n * @param {object} args\n * @param {FsClient} args.fs - a file system client\n * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {string} [args.ref] - The notes ref to look under\n * @param {object} [args.cache] - a [cache](cache.md) object\n *\n * @returns {Promise<Array<{target: string, note: string}>>} Resolves successfully with an array of entries containing SHA-1 object ids of the note and the object the note targets\n */\n\nasync function listNotes({\n fs,\n dir,\n gitdir = join(dir, '.git'),\n ref = 'refs/notes/commits',\n cache = {},\n}) {\n try {\n assertParameter('fs', fs);\n assertParameter('gitdir', gitdir);\n assertParameter('ref', ref);\n\n return await _listNotes({\n fs: new FileSystem(fs),\n cache,\n gitdir,\n ref,\n })\n } catch (err) {\n err.caller = 'git.listNotes';\n throw err\n }\n}\n\n// @ts-check\n\n/**\n * List refs\n *\n * @param {object} args\n * @param {FsClient} args.fs - a file system client\n * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {string} [args.filepath] - [required] The refs path to list\n *\n * @returns {Promise<Array<string>>} Resolves successfully with an array of ref names below the supplied `filepath`\n *\n * @example\n * let refs = await git.listRefs({ fs, dir: '/tutorial', filepath: 'refs/heads' })\n * console.log(refs)\n *\n */\nasync function listRefs({\n fs,\n dir,\n gitdir = join(dir, '.git'),\n filepath,\n}) {\n try {\n assertParameter('fs', fs);\n assertParameter('gitdir', gitdir);\n return GitRefManager.listRefs({ fs: new FileSystem(fs), gitdir, filepath })\n } catch (err) {\n err.caller = 'git.listRefs';\n throw err\n }\n}\n\n// @ts-check\n\n/**\n * @param {object} args\n * @param {import('../models/FileSystem.js').FileSystem} args.fs\n * @param {string} args.gitdir\n *\n * @returns {Promise<Array<{remote: string, url: string}>>}\n */\nasync function _listRemotes({ fs, gitdir }) {\n const config = await GitConfigManager.get({ fs, gitdir });\n const remoteNames = await config.getSubsections('remote');\n const remotes = Promise.all(\n remoteNames.map(async remote => {\n const url = await config.get(`remote.${remote}.url`);\n return { remote, url }\n })\n );\n return remotes\n}\n\n// @ts-check\n\n/**\n * List remotes\n *\n * @param {object} args\n * @param {FsClient} args.fs - a file system client\n * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n *\n * @returns {Promise<Array<{remote: string, url: string}>>} Resolves successfully with an array of `{remote, url}` objects\n *\n * @example\n * let remotes = await git.listRemotes({ fs, dir: '/tutorial' })\n * console.log(remotes)\n *\n */\nasync function listRemotes({ fs, dir, gitdir = join(dir, '.git') }) {\n try {\n assertParameter('fs', fs);\n assertParameter('gitdir', gitdir);\n\n return await _listRemotes({\n fs: new FileSystem(fs),\n gitdir,\n })\n } catch (err) {\n err.caller = 'git.listRemotes';\n throw err\n }\n}\n\n/**\n * @typedef {Object} ServerRef - This object has the following schema:\n * @property {string} ref - The name of the ref\n * @property {string} oid - The SHA-1 object id the ref points to\n * @property {string} [target] - The target ref pointed to by a symbolic ref\n * @property {string} [peeled] - If the oid is the SHA-1 object id of an annotated tag, this is the SHA-1 object id that the annotated tag points to\n */\n\nasync function parseListRefsResponse(stream) {\n const read = GitPktLine.streamReader(stream);\n\n // TODO: when we re-write everything to minimize memory usage,\n // we could make this a generator\n const refs = [];\n\n let line;\n while (true) {\n line = await read();\n if (line === true) break\n if (line === null) continue\n line = line.toString('utf8').replace(/\\n$/, '');\n const [oid, ref, ...attrs] = line.split(' ');\n const r = { ref, oid };\n for (const attr of attrs) {\n const [name, value] = attr.split(':');\n if (name === 'symref-target') {\n r.target = value;\n } else if (name === 'peeled') {\n r.peeled = value;\n }\n }\n refs.push(r);\n }\n\n return refs\n}\n\n/**\n * @param {object} args\n * @param {string} [args.prefix] - Only list refs that start with this prefix\n * @param {boolean} [args.symrefs = false] - Include symbolic ref targets\n * @param {boolean} [args.peelTags = false] - Include peeled tags values\n * @returns {Uint8Array[]}\n */\nasync function writeListRefsRequest({ prefix, symrefs, peelTags }) {\n const packstream = [];\n // command\n packstream.push(GitPktLine.encode('command=ls-refs\\n'));\n // capability-list\n packstream.push(GitPktLine.encode(`agent=${pkg.agent}\\n`));\n // [command-args]\n if (peelTags || symrefs || prefix) {\n packstream.push(GitPktLine.delim());\n }\n if (peelTags) packstream.push(GitPktLine.encode('peel'));\n if (symrefs) packstream.push(GitPktLine.encode('symrefs'));\n if (prefix) packstream.push(GitPktLine.encode(`ref-prefix ${prefix}`));\n packstream.push(GitPktLine.flush());\n return packstream\n}\n\n// @ts-check\n\n/**\n * Fetch a list of refs (branches, tags, etc) from a server.\n *\n * This is a rare command that doesn't require an `fs`, `dir`, or even `gitdir` argument.\n * It just requires an `http` argument.\n *\n * ### About `protocolVersion`\n *\n * There's a rather fun trade-off between Git Protocol Version 1 and Git Protocol Version 2.\n * Version 2 actually requires 2 HTTP requests instead of 1, making it similar to fetch or push in that regard.\n * However, version 2 supports server-side filtering by prefix, whereas that filtering is done client-side in version 1.\n * Which protocol is most efficient therefore depends on the number of refs on the remote, the latency of the server, and speed of the network connection.\n * For an small repos (or fast Internet connections), the requirement to make two trips to the server makes protocol 2 slower.\n * But for large repos (or slow Internet connections), the decreased payload size of the second request makes up for the additional request.\n *\n * Hard numbers vary by situation, but here's some numbers from my machine:\n *\n * Using isomorphic-git in a browser, with a CORS proxy, listing only the branches (refs/heads) of https://github.com/isomorphic-git/isomorphic-git\n * - Protocol Version 1 took ~300ms and transferred 84 KB.\n * - Protocol Version 2 took ~500ms and transferred 4.1 KB.\n *\n * Using isomorphic-git in a browser, with a CORS proxy, listing only the branches (refs/heads) of https://gitlab.com/gitlab-org/gitlab\n * - Protocol Version 1 took ~4900ms and transferred 9.41 MB.\n * - Protocol Version 2 took ~1280ms and transferred 433 KB.\n *\n * Finally, there is a fun quirk regarding the `symrefs` parameter.\n * Protocol Version 1 will generally only return the `HEAD` symref and not others.\n * Historically, this meant that servers don't use symbolic refs except for `HEAD`, which is used to point at the \"default branch\".\n * However Protocol Version 2 can return *all* the symbolic refs on the server.\n * So if you are running your own git server, you could take advantage of that I guess.\n *\n * #### TL;DR\n * If you are _not_ taking advantage of `prefix` I would recommend `protocolVersion: 1`.\n * Otherwise, I recommend to use the default which is `protocolVersion: 2`.\n *\n * @param {object} args\n * @param {HttpClient} args.http - an HTTP client\n * @param {AuthCallback} [args.onAuth] - optional auth fill callback\n * @param {AuthFailureCallback} [args.onAuthFailure] - optional auth rejected callback\n * @param {AuthSuccessCallback} [args.onAuthSuccess] - optional auth approved callback\n * @param {string} args.url - The URL of the remote repository. Will be gotten from gitconfig if absent.\n * @param {string} [args.corsProxy] - Optional [CORS proxy](https://www.npmjs.com/%40isomorphic-git/cors-proxy). Overrides value in repo config.\n * @param {boolean} [args.forPush = false] - By default, the command queries the 'fetch' capabilities. If true, it will ask for the 'push' capabilities.\n * @param {Object<string, string>} [args.headers] - Additional headers to include in HTTP requests, similar to git's `extraHeader` config\n * @param {1 | 2} [args.protocolVersion = 2] - Which version of the Git Protocol to use.\n * @param {string} [args.prefix] - Only list refs that start with this prefix\n * @param {boolean} [args.symrefs = false] - Include symbolic ref targets\n * @param {boolean} [args.peelTags = false] - Include annotated tag peeled targets\n *\n * @returns {Promise<ServerRef[]>} Resolves successfully with an array of ServerRef objects\n * @see ServerRef\n *\n * @example\n * // List all the branches on a repo\n * let refs = await git.listServerRefs({\n * http,\n * corsProxy: \"https://cors.isomorphic-git.org\",\n * url: \"https://github.com/isomorphic-git/isomorphic-git.git\",\n * prefix: \"refs/heads/\",\n * });\n * console.log(refs);\n *\n * @example\n * // Get the default branch on a repo\n * let refs = await git.listServerRefs({\n * http,\n * corsProxy: \"https://cors.isomorphic-git.org\",\n * url: \"https://github.com/isomorphic-git/isomorphic-git.git\",\n * prefix: \"HEAD\",\n * symrefs: true,\n * });\n * console.log(refs);\n *\n * @example\n * // List all the tags on a repo\n * let refs = await git.listServerRefs({\n * http,\n * corsProxy: \"https://cors.isomorphic-git.org\",\n * url: \"https://github.com/isomorphic-git/isomorphic-git.git\",\n * prefix: \"refs/tags/\",\n * peelTags: true,\n * });\n * console.log(refs);\n *\n * @example\n * // List all the pull requests on a repo\n * let refs = await git.listServerRefs({\n * http,\n * corsProxy: \"https://cors.isomorphic-git.org\",\n * url: \"https://github.com/isomorphic-git/isomorphic-git.git\",\n * prefix: \"refs/pull/\",\n * });\n * console.log(refs);\n *\n */\nasync function listServerRefs({\n http,\n onAuth,\n onAuthSuccess,\n onAuthFailure,\n corsProxy,\n url,\n headers = {},\n forPush = false,\n protocolVersion = 2,\n prefix,\n symrefs,\n peelTags,\n}) {\n try {\n assertParameter('http', http);\n assertParameter('url', url);\n\n const remote = await GitRemoteHTTP.discover({\n http,\n onAuth,\n onAuthSuccess,\n onAuthFailure,\n corsProxy,\n service: forPush ? 'git-receive-pack' : 'git-upload-pack',\n url,\n headers,\n protocolVersion,\n });\n\n if (remote.protocolVersion === 1) {\n return formatInfoRefs(remote, prefix, symrefs, peelTags)\n }\n\n // Protocol Version 2\n const body = await writeListRefsRequest({ prefix, symrefs, peelTags });\n\n const res = await GitRemoteHTTP.connect({\n http,\n auth: remote.auth,\n headers,\n corsProxy,\n service: forPush ? 'git-receive-pack' : 'git-upload-pack',\n url,\n body,\n });\n\n return parseListRefsResponse(res.body)\n } catch (err) {\n err.caller = 'git.listServerRefs';\n throw err\n }\n}\n\n// @ts-check\n\n/**\n * List tags\n *\n * @param {object} args\n * @param {FsClient} args.fs - a file system client\n * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n *\n * @returns {Promise<Array<string>>} Resolves successfully with an array of tag names\n *\n * @example\n * let tags = await git.listTags({ fs, dir: '/tutorial' })\n * console.log(tags)\n *\n */\nasync function listTags({ fs, dir, gitdir = join(dir, '.git') }) {\n try {\n assertParameter('fs', fs);\n assertParameter('gitdir', gitdir);\n return GitRefManager.listTags({ fs: new FileSystem(fs), gitdir })\n } catch (err) {\n err.caller = 'git.listTags';\n throw err\n }\n}\n\nfunction compareAge(a, b) {\n return a.committer.timestamp - b.committer.timestamp\n}\n\n// @ts-check\n\n// the empty file content object id\nconst EMPTY_OID = 'e69de29bb2d1d6434b8b29ae775ad8c2e48c5391';\n\nasync function resolveFileIdInTree({ fs, cache, gitdir, oid, fileId }) {\n if (fileId === EMPTY_OID) return\n const _oid = oid;\n let filepath;\n const result = await resolveTree({ fs, cache, gitdir, oid });\n const tree = result.tree;\n if (fileId === result.oid) {\n filepath = result.path;\n } else {\n filepath = await _resolveFileId({\n fs,\n cache,\n gitdir,\n tree,\n fileId,\n oid: _oid,\n });\n if (Array.isArray(filepath)) {\n if (filepath.length === 0) filepath = undefined;\n else if (filepath.length === 1) filepath = filepath[0];\n }\n }\n return filepath\n}\n\nasync function _resolveFileId({\n fs,\n cache,\n gitdir,\n tree,\n fileId,\n oid,\n filepaths = [],\n parentPath = '',\n}) {\n const walks = tree.entries().map(function(entry) {\n let result;\n if (entry.oid === fileId) {\n result = join(parentPath, entry.path);\n filepaths.push(result);\n } else if (entry.type === 'tree') {\n result = _readObject({\n fs,\n cache,\n gitdir,\n oid: entry.oid,\n }).then(function({ object }) {\n return _resolveFileId({\n fs,\n cache,\n gitdir,\n tree: GitTree.from(object),\n fileId,\n oid,\n filepaths,\n parentPath: join(parentPath, entry.path),\n })\n });\n }\n return result\n });\n\n await Promise.all(walks);\n return filepaths\n}\n\n// @ts-check\n\n/**\n * Get commit descriptions from the git history\n *\n * @param {object} args\n * @param {import('../models/FileSystem.js').FileSystem} args.fs\n * @param {any} args.cache\n * @param {string} args.gitdir\n * @param {string=} args.filepath optional get the commit for the filepath only\n * @param {string} args.ref\n * @param {number|void} args.depth\n * @param {boolean=} [args.force=false] do not throw error if filepath is not exist (works only for a single file). defaults to false\n * @param {boolean=} [args.follow=false] Continue listing the history of a file beyond renames (works only for a single file). defaults to false\n * @param {boolean=} args.follow Continue listing the history of a file beyond renames (works only for a single file). defaults to false\n *\n * @returns {Promise<Array<ReadCommitResult>>} Resolves to an array of ReadCommitResult objects\n * @see ReadCommitResult\n * @see CommitObject\n *\n * @example\n * let commits = await git.log({ dir: '$input((/))', depth: $input((5)), ref: '$input((master))' })\n * console.log(commits)\n *\n */\nasync function _log({\n fs,\n cache,\n gitdir,\n filepath,\n ref,\n depth,\n since,\n force,\n follow,\n}) {\n const sinceTimestamp =\n typeof since === 'undefined'\n ? undefined\n : Math.floor(since.valueOf() / 1000);\n // TODO: In the future, we may want to have an API where we return a\n // async iterator that emits commits.\n const commits = [];\n const shallowCommits = await GitShallowManager.read({ fs, gitdir });\n const oid = await GitRefManager.resolve({ fs, gitdir, ref });\n const tips = [await _readCommit({ fs, cache, gitdir, oid })];\n let lastFileOid;\n let lastCommit;\n let isOk;\n\n function endCommit(commit) {\n if (isOk && filepath) commits.push(commit);\n }\n\n while (tips.length > 0) {\n const commit = tips.pop();\n\n // Stop the log if we've hit the age limit\n if (\n sinceTimestamp !== undefined &&\n commit.commit.committer.timestamp <= sinceTimestamp\n ) {\n break\n }\n\n if (filepath) {\n let vFileOid;\n try {\n vFileOid = await resolveFilepath({\n fs,\n cache,\n gitdir,\n oid: commit.commit.tree,\n filepath,\n });\n if (lastCommit && lastFileOid !== vFileOid) {\n commits.push(lastCommit);\n }\n lastFileOid = vFileOid;\n lastCommit = commit;\n isOk = true;\n } catch (e) {\n if (e instanceof NotFoundError) {\n let found = follow && lastFileOid;\n if (found) {\n found = await resolveFileIdInTree({\n fs,\n cache,\n gitdir,\n oid: commit.commit.tree,\n fileId: lastFileOid,\n });\n if (found) {\n if (Array.isArray(found)) {\n if (lastCommit) {\n const lastFound = await resolveFileIdInTree({\n fs,\n cache,\n gitdir,\n oid: lastCommit.commit.tree,\n fileId: lastFileOid,\n });\n if (Array.isArray(lastFound)) {\n found = found.filter(p => lastFound.indexOf(p) === -1);\n if (found.length === 1) {\n found = found[0];\n filepath = found;\n if (lastCommit) commits.push(lastCommit);\n } else {\n found = false;\n if (lastCommit) commits.push(lastCommit);\n break\n }\n }\n }\n } else {\n filepath = found;\n if (lastCommit) commits.push(lastCommit);\n }\n }\n }\n if (!found) {\n if (isOk && lastFileOid) {\n commits.push(lastCommit);\n if (!force) break\n }\n if (!force && !follow) throw e\n }\n lastCommit = commit;\n isOk = false;\n } else throw e\n }\n } else {\n commits.push(commit);\n }\n\n // Stop the loop if we have enough commits now.\n if (depth !== undefined && commits.length === depth) {\n endCommit(commit);\n break\n }\n\n // If this is not a shallow commit...\n if (!shallowCommits.has(commit.oid)) {\n // Add the parents of this commit to the queue\n // Note: for the case of a commit with no parents, it will concat an empty array, having no net effect.\n for (const oid of commit.commit.parent) {\n const commit = await _readCommit({ fs, cache, gitdir, oid });\n if (!tips.map(commit => commit.oid).includes(commit.oid)) {\n tips.push(commit);\n }\n }\n }\n\n // Stop the loop if there are no more commit parents\n if (tips.length === 0) {\n endCommit(commit);\n }\n\n // Process tips in order by age\n tips.sort((a, b) => compareAge(a.commit, b.commit));\n }\n return commits\n}\n\n// @ts-check\n\n/**\n * Get commit descriptions from the git history\n *\n * @param {object} args\n * @param {FsClient} args.fs - a file system client\n * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {string=} args.filepath optional get the commit for the filepath only\n * @param {string} [args.ref = 'HEAD'] - The commit to begin walking backwards through the history from\n * @param {number=} [args.depth] - Limit the number of commits returned. No limit by default.\n * @param {Date} [args.since] - Return history newer than the given date. Can be combined with `depth` to get whichever is shorter.\n * @param {boolean=} [args.force=false] do not throw error if filepath is not exist (works only for a single file). defaults to false\n * @param {boolean=} [args.follow=false] Continue listing the history of a file beyond renames (works only for a single file). defaults to false\n * @param {object} [args.cache] - a [cache](cache.md) object\n *\n * @returns {Promise<Array<ReadCommitResult>>} Resolves to an array of ReadCommitResult objects\n * @see ReadCommitResult\n * @see CommitObject\n *\n * @example\n * let commits = await git.log({\n * fs,\n * dir: '/tutorial',\n * depth: 5,\n * ref: 'main'\n * })\n * console.log(commits)\n *\n */\nasync function log({\n fs,\n dir,\n gitdir = join(dir, '.git'),\n filepath,\n ref = 'HEAD',\n depth,\n since, // Date\n force,\n follow,\n cache = {},\n}) {\n try {\n assertParameter('fs', fs);\n assertParameter('gitdir', gitdir);\n assertParameter('ref', ref);\n\n return await _log({\n fs: new FileSystem(fs),\n cache,\n gitdir,\n filepath,\n ref,\n depth,\n since,\n force,\n follow,\n })\n } catch (err) {\n err.caller = 'git.log';\n throw err\n }\n}\n\n// @ts-check\n\n/**\n *\n * @typedef {Object} MergeResult - Returns an object with a schema like this:\n * @property {string} [oid] - The SHA-1 object id that is now at the head of the branch. Absent only if `dryRun` was specified and `mergeCommit` is true.\n * @property {boolean} [alreadyMerged] - True if the branch was already merged so no changes were made\n * @property {boolean} [fastForward] - True if it was a fast-forward merge\n * @property {boolean} [mergeCommit] - True if merge resulted in a merge commit\n * @property {string} [tree] - The SHA-1 object id of the tree resulting from a merge commit\n *\n */\n\n/**\n * Merge two branches\n *\n * Currently it will fail if multiple candidate merge bases are found. (It doesn't yet implement the recursive merge strategy.)\n *\n * Currently it does not support selecting alternative merge strategies.\n *\n * Currently it is not possible to abort an incomplete merge. To restore the worktree to a clean state, you will need to checkout an earlier commit.\n *\n * Currently it does not directly support the behavior of `git merge --continue`. To complete a merge after manual conflict resolution, you will need to add and commit the files manually, and specify the appropriate parent commits.\n *\n * ## Manually resolving merge conflicts\n * By default, if isomorphic-git encounters a merge conflict it cannot resolve using the builtin diff3 algorithm or provided merge driver, it will abort and throw a `MergeNotSupportedError`.\n * This leaves the index and working tree untouched.\n *\n * When `abortOnConflict` is set to `false`, and a merge conflict cannot be automatically resolved, a `MergeConflictError` is thrown and the results of the incomplete merge will be written to the working directory.\n * This includes conflict markers in files with unresolved merge conflicts.\n *\n * To complete the merge, edit the conflicting files as you see fit, and then add and commit the resolved merge.\n *\n * For a proper merge commit, be sure to specify the branches or commits you are merging in the `parent` argument to `git.commit`.\n * For example, say we are merging the branch `feature` into the branch `main` and there is a conflict we want to resolve manually.\n * The flow would look like this:\n *\n * ```\n * await git.merge({\n * fs,\n * dir,\n * ours: 'main',\n * theirs: 'feature',\n * abortOnConflict: false,\n * }).catch(e => {\n * if (e instanceof Errors.MergeConflictError) {\n * console.log(\n * 'Automatic merge failed for the following files: '\n * + `${e.data}. `\n * + 'Resolve these conflicts and then commit your changes.'\n * )\n * } else throw e\n * })\n *\n * // This is the where we manually edit the files that have been written to the working directory\n * // ...\n * // Files have been edited and we are ready to commit\n *\n * await git.add({\n * fs,\n * dir,\n * filepath: '.',\n * })\n *\n * await git.commit({\n * fs,\n * dir,\n * ref: 'main',\n * message: \"Merge branch 'feature' into main\",\n * parent: ['main', 'feature'], // Be sure to specify the parents when creating a merge commit\n * })\n * ```\n *\n * @param {object} args\n * @param {FsClient} args.fs - a file system client\n * @param {SignCallback} [args.onSign] - a PGP signing implementation\n * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {string} [args.ours] - The branch receiving the merge. If undefined, defaults to the current branch.\n * @param {string} args.theirs - The branch to be merged\n * @param {boolean} [args.fastForward = true] - If false, create a merge commit in all cases.\n * @param {boolean} [args.fastForwardOnly = false] - If true, then non-fast-forward merges will throw an Error instead of performing a merge.\n * @param {boolean} [args.dryRun = false] - If true, simulates a merge so you can test whether it would succeed.\n * @param {boolean} [args.noUpdateBranch = false] - If true, does not update the branch pointer after creating the commit.\n * @param {boolean} [args.abortOnConflict = true] - If true, merges with conflicts will not update the worktree or index.\n * @param {string} [args.message] - Overrides the default auto-generated merge commit message\n * @param {Object} [args.author] - passed to [commit](commit.md) when creating a merge commit\n * @param {string} [args.author.name] - Default is `user.name` config.\n * @param {string} [args.author.email] - Default is `user.email` config.\n * @param {number} [args.author.timestamp=Math.floor(Date.now()/1000)] - Set the author timestamp field. This is the integer number of seconds since the Unix epoch (1970-01-01 00:00:00).\n * @param {number} [args.author.timezoneOffset] - Set the author timezone offset field. This is the difference, in minutes, from the current timezone to UTC. Default is `(new Date()).getTimezoneOffset()`.\n * @param {Object} [args.committer] - passed to [commit](commit.md) when creating a merge commit\n * @param {string} [args.committer.name] - Default is `user.name` config.\n * @param {string} [args.committer.email] - Default is `user.email` config.\n * @param {number} [args.committer.timestamp=Math.floor(Date.now()/1000)] - Set the committer timestamp field. This is the integer number of seconds since the Unix epoch (1970-01-01 00:00:00).\n * @param {number} [args.committer.timezoneOffset] - Set the committer timezone offset field. This is the difference, in minutes, from the current timezone to UTC. Default is `(new Date()).getTimezoneOffset()`.\n * @param {string} [args.signingKey] - passed to [commit](commit.md) when creating a merge commit\n * @param {object} [args.cache] - a [cache](cache.md) object\n * @param {MergeDriverCallback} [args.mergeDriver] - a [merge driver](mergeDriver.md) implementation\n *\n * @returns {Promise<MergeResult>} Resolves to a description of the merge operation\n * @see MergeResult\n *\n * @example\n * let m = await git.merge({\n * fs,\n * dir: '/tutorial',\n * ours: 'main',\n * theirs: 'remotes/origin/main'\n * })\n * console.log(m)\n *\n */\nasync function merge({\n fs: _fs,\n onSign,\n dir,\n gitdir = join(dir, '.git'),\n ours,\n theirs,\n fastForward = true,\n fastForwardOnly = false,\n dryRun = false,\n noUpdateBranch = false,\n abortOnConflict = true,\n message,\n author: _author,\n committer: _committer,\n signingKey,\n cache = {},\n mergeDriver,\n}) {\n try {\n assertParameter('fs', _fs);\n if (signingKey) {\n assertParameter('onSign', onSign);\n }\n const fs = new FileSystem(_fs);\n\n const author = await normalizeAuthorObject({ fs, gitdir, author: _author });\n if (!author && (!fastForwardOnly || !fastForward)) {\n throw new MissingNameError('author')\n }\n\n const committer = await normalizeCommitterObject({\n fs,\n gitdir,\n author,\n committer: _committer,\n });\n if (!committer && (!fastForwardOnly || !fastForward)) {\n throw new MissingNameError('committer')\n }\n\n return await _merge({\n fs,\n cache,\n dir,\n gitdir,\n ours,\n theirs,\n fastForward,\n fastForwardOnly,\n dryRun,\n noUpdateBranch,\n abortOnConflict,\n message,\n author,\n committer,\n signingKey,\n onSign,\n mergeDriver,\n })\n } catch (err) {\n err.caller = 'git.merge';\n throw err\n }\n}\n\n/**\n * @enum {number}\n */\nconst types = {\n commit: 0b0010000,\n tree: 0b0100000,\n blob: 0b0110000,\n tag: 0b1000000,\n ofs_delta: 0b1100000,\n ref_delta: 0b1110000,\n};\n\n/**\n * @param {object} args\n * @param {import('../models/FileSystem.js').FileSystem} args.fs\n * @param {any} args.cache\n * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {string[]} args.oids\n */\nasync function _pack({\n fs,\n cache,\n dir,\n gitdir = join(dir, '.git'),\n oids,\n}) {\n const hash = new Hash();\n const outputStream = [];\n function write(chunk, enc) {\n const buff = Buffer.from(chunk, enc);\n outputStream.push(buff);\n hash.update(buff);\n }\n async function writeObject({ stype, object }) {\n // Object type is encoded in bits 654\n const type = types[stype];\n // The length encoding gets complicated.\n let length = object.length;\n // Whether the next byte is part of the variable-length encoded number\n // is encoded in bit 7\n let multibyte = length > 0b1111 ? 0b10000000 : 0b0;\n // Last four bits of length is encoded in bits 3210\n const lastFour = length & 0b1111;\n // Discard those bits\n length = length >>> 4;\n // The first byte is then (1-bit multibyte?), (3-bit type), (4-bit least sig 4-bits of length)\n let byte = (multibyte | type | lastFour).toString(16);\n write(byte, 'hex');\n // Now we keep chopping away at length 7-bits at a time until its zero,\n // writing out the bytes in what amounts to little-endian order.\n while (multibyte) {\n multibyte = length > 0b01111111 ? 0b10000000 : 0b0;\n byte = multibyte | (length & 0b01111111);\n write(padHex(2, byte), 'hex');\n length = length >>> 7;\n }\n // Lastly, we can compress and write the object.\n write(Buffer.from(await deflate(object)));\n }\n write('PACK');\n write('00000002', 'hex');\n // Write a 4 byte (32-bit) int\n write(padHex(8, oids.length), 'hex');\n for (const oid of oids) {\n const { type, object } = await _readObject({ fs, cache, gitdir, oid });\n await writeObject({ write, object, stype: type });\n }\n // Write SHA1 checksum\n const digest = hash.digest();\n outputStream.push(digest);\n return outputStream\n}\n\n// @ts-check\n\n/**\n *\n * @typedef {Object} PackObjectsResult The packObjects command returns an object with two properties:\n * @property {string} filename - The suggested filename for the packfile if you want to save it to disk somewhere. It includes the packfile SHA.\n * @property {Uint8Array} [packfile] - The packfile contents. Not present if `write` parameter was true, in which case the packfile was written straight to disk.\n */\n\n/**\n * @param {object} args\n * @param {import('../models/FileSystem.js').FileSystem} args.fs\n * @param {any} args.cache\n * @param {string} args.gitdir\n * @param {string[]} args.oids\n * @param {boolean} args.write\n *\n * @returns {Promise<PackObjectsResult>}\n * @see PackObjectsResult\n */\nasync function _packObjects({ fs, cache, gitdir, oids, write }) {\n const buffers = await _pack({ fs, cache, gitdir, oids });\n const packfile = Buffer.from(await collect(buffers));\n const packfileSha = packfile.slice(-20).toString('hex');\n const filename = `pack-${packfileSha}.pack`;\n if (write) {\n await fs.write(join(gitdir, `objects/pack/${filename}`), packfile);\n return { filename }\n }\n return {\n filename,\n packfile: new Uint8Array(packfile),\n }\n}\n\n// @ts-check\n\n/**\n *\n * @typedef {Object} PackObjectsResult The packObjects command returns an object with two properties:\n * @property {string} filename - The suggested filename for the packfile if you want to save it to disk somewhere. It includes the packfile SHA.\n * @property {Uint8Array} [packfile] - The packfile contents. Not present if `write` parameter was true, in which case the packfile was written straight to disk.\n */\n\n/**\n * Create a packfile from an array of SHA-1 object ids\n *\n * @param {object} args\n * @param {FsClient} args.fs - a file system client\n * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {string[]} args.oids - An array of SHA-1 object ids to be included in the packfile\n * @param {boolean} [args.write = false] - Whether to save the packfile to disk or not\n * @param {object} [args.cache] - a [cache](cache.md) object\n *\n * @returns {Promise<PackObjectsResult>} Resolves successfully when the packfile is ready with the filename and buffer\n * @see PackObjectsResult\n *\n * @example\n * // Create a packfile containing only an empty tree\n * let { packfile } = await git.packObjects({\n * fs,\n * dir: '/tutorial',\n * oids: ['4b825dc642cb6eb9a060e54bf8d69288fbee4904']\n * })\n * console.log(packfile)\n *\n */\nasync function packObjects({\n fs,\n dir,\n gitdir = join(dir, '.git'),\n oids,\n write = false,\n cache = {},\n}) {\n try {\n assertParameter('fs', fs);\n assertParameter('gitdir', gitdir);\n assertParameter('oids', oids);\n\n return await _packObjects({\n fs: new FileSystem(fs),\n cache,\n gitdir,\n oids,\n write,\n })\n } catch (err) {\n err.caller = 'git.packObjects';\n throw err\n }\n}\n\n// @ts-check\n\n/**\n * Fetch and merge commits from a remote repository\n *\n * @param {object} args\n * @param {FsClient} args.fs - a file system client\n * @param {HttpClient} args.http - an HTTP client\n * @param {ProgressCallback} [args.onProgress] - optional progress event callback\n * @param {MessageCallback} [args.onMessage] - optional message event callback\n * @param {AuthCallback} [args.onAuth] - optional auth fill callback\n * @param {AuthFailureCallback} [args.onAuthFailure] - optional auth rejected callback\n * @param {AuthSuccessCallback} [args.onAuthSuccess] - optional auth approved callback\n * @param {string} args.dir] - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {string} [args.ref] - Which branch to merge into. By default this is the currently checked out branch.\n * @param {string} [args.url] - (Added in 1.1.0) The URL of the remote repository. The default is the value set in the git config for that remote.\n * @param {string} [args.remote] - (Added in 1.1.0) If URL is not specified, determines which remote to use.\n * @param {string} [args.remoteRef] - (Added in 1.1.0) The name of the branch on the remote to fetch. By default this is the configured remote tracking branch.\n * @param {boolean} [args.prune = false] - Delete local remote-tracking branches that are not present on the remote\n * @param {boolean} [args.pruneTags = false] - Prune local tags that don’t exist on the remote, and force-update those tags that differ\n * @param {string} [args.corsProxy] - Optional [CORS proxy](https://www.npmjs.com/%40isomorphic-git/cors-proxy). Overrides value in repo config.\n * @param {boolean} [args.singleBranch = false] - Instead of the default behavior of fetching all the branches, only fetch a single branch.\n * @param {boolean} [args.fastForward = true] - If false, only create merge commits.\n * @param {boolean} [args.fastForwardOnly = false] - Only perform simple fast-forward merges. (Don't create merge commits.)\n * @param {Object<string, string>} [args.headers] - Additional headers to include in HTTP requests, similar to git's `extraHeader` config\n * @param {Object} [args.author] - The details about the author.\n * @param {string} [args.author.name] - Default is `user.name` config.\n * @param {string} [args.author.email] - Default is `user.email` config.\n * @param {number} [args.author.timestamp=Math.floor(Date.now()/1000)] - Set the author timestamp field. This is the integer number of seconds since the Unix epoch (1970-01-01 00:00:00).\n * @param {number} [args.author.timezoneOffset] - Set the author timezone offset field. This is the difference, in minutes, from the current timezone to UTC. Default is `(new Date()).getTimezoneOffset()`.\n * @param {Object} [args.committer = author] - The details about the commit committer, in the same format as the author parameter. If not specified, the author details are used.\n * @param {string} [args.committer.name] - Default is `user.name` config.\n * @param {string} [args.committer.email] - Default is `user.email` config.\n * @param {number} [args.committer.timestamp=Math.floor(Date.now()/1000)] - Set the committer timestamp field. This is the integer number of seconds since the Unix epoch (1970-01-01 00:00:00).\n * @param {number} [args.committer.timezoneOffset] - Set the committer timezone offset field. This is the difference, in minutes, from the current timezone to UTC. Default is `(new Date()).getTimezoneOffset()`.\n * @param {string} [args.signingKey] - passed to [commit](commit.md) when creating a merge commit\n * @param {object} [args.cache] - a [cache](cache.md) object\n *\n * @returns {Promise<void>} Resolves successfully when pull operation completes\n *\n * @example\n * await git.pull({\n * fs,\n * http,\n * dir: '/tutorial',\n * ref: 'main',\n * singleBranch: true\n * })\n * console.log('done')\n *\n */\nasync function pull({\n fs: _fs,\n http,\n onProgress,\n onMessage,\n onAuth,\n onAuthSuccess,\n onAuthFailure,\n dir,\n gitdir = join(dir, '.git'),\n ref,\n url,\n remote,\n remoteRef,\n prune = false,\n pruneTags = false,\n fastForward = true,\n fastForwardOnly = false,\n corsProxy,\n singleBranch,\n headers = {},\n author: _author,\n committer: _committer,\n signingKey,\n cache = {},\n}) {\n try {\n assertParameter('fs', _fs);\n assertParameter('gitdir', gitdir);\n\n const fs = new FileSystem(_fs);\n\n const author = await normalizeAuthorObject({ fs, gitdir, author: _author });\n if (!author) throw new MissingNameError('author')\n\n const committer = await normalizeCommitterObject({\n fs,\n gitdir,\n author,\n committer: _committer,\n });\n if (!committer) throw new MissingNameError('committer')\n\n return await _pull({\n fs,\n cache,\n http,\n onProgress,\n onMessage,\n onAuth,\n onAuthSuccess,\n onAuthFailure,\n dir,\n gitdir,\n ref,\n url,\n remote,\n remoteRef,\n fastForward,\n fastForwardOnly,\n corsProxy,\n singleBranch,\n headers,\n author,\n committer,\n signingKey,\n prune,\n pruneTags,\n })\n } catch (err) {\n err.caller = 'git.pull';\n throw err\n }\n}\n\n/**\n * @param {object} args\n * @param {import('../models/FileSystem.js').FileSystem} args.fs\n * @param {any} args.cache\n * @param {string} [args.dir]\n * @param {string} args.gitdir\n * @param {Iterable<string>} args.start\n * @param {Iterable<string>} args.finish\n * @returns {Promise<Set<string>>}\n */\nasync function listCommitsAndTags({\n fs,\n cache,\n dir,\n gitdir = join(dir, '.git'),\n start,\n finish,\n}) {\n const shallows = await GitShallowManager.read({ fs, gitdir });\n const startingSet = new Set();\n const finishingSet = new Set();\n for (const ref of start) {\n startingSet.add(await GitRefManager.resolve({ fs, gitdir, ref }));\n }\n for (const ref of finish) {\n // We may not have these refs locally so we must try/catch\n try {\n const oid = await GitRefManager.resolve({ fs, gitdir, ref });\n finishingSet.add(oid);\n } catch (err) {}\n }\n const visited = new Set();\n // Because git commits are named by their hash, there is no\n // way to construct a cycle. Therefore we won't worry about\n // setting a default recursion limit.\n async function walk(oid) {\n visited.add(oid);\n const { type, object } = await _readObject({ fs, cache, gitdir, oid });\n // Recursively resolve annotated tags\n if (type === 'tag') {\n const tag = GitAnnotatedTag.from(object);\n const commit = tag.headers().object;\n return walk(commit)\n }\n if (type !== 'commit') {\n throw new ObjectTypeError(oid, type, 'commit')\n }\n if (!shallows.has(oid)) {\n const commit = GitCommit.from(object);\n const parents = commit.headers().parent;\n for (oid of parents) {\n if (!finishingSet.has(oid) && !visited.has(oid)) {\n await walk(oid);\n }\n }\n }\n }\n // Let's go walking!\n for (const oid of startingSet) {\n await walk(oid);\n }\n return visited\n}\n\n/**\n * @param {object} args\n * @param {import('../models/FileSystem.js').FileSystem} args.fs\n * @param {any} args.cache\n * @param {string} [args.dir]\n * @param {string} args.gitdir\n * @param {Iterable<string>} args.oids\n * @returns {Promise<Set<string>>}\n */\nasync function listObjects({\n fs,\n cache,\n dir,\n gitdir = join(dir, '.git'),\n oids,\n}) {\n const visited = new Set();\n // We don't do the purest simplest recursion, because we can\n // avoid reading Blob objects entirely since the Tree objects\n // tell us which oids are Blobs and which are Trees.\n async function walk(oid) {\n if (visited.has(oid)) return\n visited.add(oid);\n const { type, object } = await _readObject({ fs, cache, gitdir, oid });\n if (type === 'tag') {\n const tag = GitAnnotatedTag.from(object);\n const obj = tag.headers().object;\n await walk(obj);\n } else if (type === 'commit') {\n const commit = GitCommit.from(object);\n const tree = commit.headers().tree;\n await walk(tree);\n } else if (type === 'tree') {\n const tree = GitTree.from(object);\n for (const entry of tree) {\n // add blobs to the set\n // skip over submodules whose type is 'commit'\n if (entry.type === 'blob') {\n visited.add(entry.oid);\n }\n // recurse for trees\n if (entry.type === 'tree') {\n await walk(entry.oid);\n }\n }\n }\n }\n // Let's go walking!\n for (const oid of oids) {\n await walk(oid);\n }\n return visited\n}\n\nasync function parseReceivePackResponse(packfile) {\n /** @type PushResult */\n const result = {};\n let response = '';\n const read = GitPktLine.streamReader(packfile);\n let line = await read();\n while (line !== true) {\n if (line !== null) response += line.toString('utf8') + '\\n';\n line = await read();\n }\n\n const lines = response.toString('utf8').split('\\n');\n // We're expecting \"unpack {unpack-result}\"\n line = lines.shift();\n if (!line.startsWith('unpack ')) {\n throw new ParseError('unpack ok\" or \"unpack [error message]', line)\n }\n result.ok = line === 'unpack ok';\n if (!result.ok) {\n result.error = line.slice('unpack '.length);\n }\n result.refs = {};\n for (const line of lines) {\n if (line.trim() === '') continue\n const status = line.slice(0, 2);\n const refAndMessage = line.slice(3);\n let space = refAndMessage.indexOf(' ');\n if (space === -1) space = refAndMessage.length;\n const ref = refAndMessage.slice(0, space);\n const error = refAndMessage.slice(space + 1);\n result.refs[ref] = {\n ok: status === 'ok',\n error,\n };\n }\n return result\n}\n\nasync function writeReceivePackRequest({\n capabilities = [],\n triplets = [],\n}) {\n const packstream = [];\n let capsFirstLine = `\\x00 ${capabilities.join(' ')}`;\n for (const trip of triplets) {\n packstream.push(\n GitPktLine.encode(\n `${trip.oldoid} ${trip.oid} ${trip.fullRef}${capsFirstLine}\\n`\n )\n );\n capsFirstLine = '';\n }\n packstream.push(GitPktLine.flush());\n return packstream\n}\n\n// @ts-check\n\n/**\n * @param {object} args\n * @param {import('../models/FileSystem.js').FileSystem} args.fs\n * @param {any} args.cache\n * @param {HttpClient} args.http\n * @param {ProgressCallback} [args.onProgress]\n * @param {MessageCallback} [args.onMessage]\n * @param {AuthCallback} [args.onAuth]\n * @param {AuthFailureCallback} [args.onAuthFailure]\n * @param {AuthSuccessCallback} [args.onAuthSuccess]\n * @param {PrePushCallback} [args.onPrePush]\n * @param {string} args.gitdir\n * @param {string} [args.ref]\n * @param {string} [args.remoteRef]\n * @param {string} [args.remote]\n * @param {boolean} [args.force = false]\n * @param {boolean} [args.delete = false]\n * @param {string} [args.url]\n * @param {string} [args.corsProxy]\n * @param {Object<string, string>} [args.headers]\n *\n * @returns {Promise<PushResult>}\n */\nasync function _push({\n fs,\n cache,\n http,\n onProgress,\n onMessage,\n onAuth,\n onAuthSuccess,\n onAuthFailure,\n onPrePush,\n gitdir,\n ref: _ref,\n remoteRef: _remoteRef,\n remote,\n url: _url,\n force = false,\n delete: _delete = false,\n corsProxy,\n headers = {},\n}) {\n const ref = _ref || (await _currentBranch({ fs, gitdir }));\n if (typeof ref === 'undefined') {\n throw new MissingParameterError('ref')\n }\n const config = await GitConfigManager.get({ fs, gitdir });\n // Figure out what remote to use.\n remote =\n remote ||\n (await config.get(`branch.${ref}.pushRemote`)) ||\n (await config.get('remote.pushDefault')) ||\n (await config.get(`branch.${ref}.remote`)) ||\n 'origin';\n // Lookup the URL for the given remote.\n const url =\n _url ||\n (await config.get(`remote.${remote}.pushurl`)) ||\n (await config.get(`remote.${remote}.url`));\n if (typeof url === 'undefined') {\n throw new MissingParameterError('remote OR url')\n }\n // Figure out what remote ref to use.\n const remoteRef = _remoteRef || (await config.get(`branch.${ref}.merge`));\n if (typeof url === 'undefined') {\n throw new MissingParameterError('remoteRef')\n }\n\n if (corsProxy === undefined) {\n corsProxy = await config.get('http.corsProxy');\n }\n\n const fullRef = await GitRefManager.expand({ fs, gitdir, ref });\n const oid = _delete\n ? '0000000000000000000000000000000000000000'\n : await GitRefManager.resolve({ fs, gitdir, ref: fullRef });\n\n /** @type typeof import(\"../managers/GitRemoteHTTP\").GitRemoteHTTP */\n const GitRemoteHTTP = GitRemoteManager.getRemoteHelperFor({ url });\n const httpRemote = await GitRemoteHTTP.discover({\n http,\n onAuth,\n onAuthSuccess,\n onAuthFailure,\n corsProxy,\n service: 'git-receive-pack',\n url,\n headers,\n protocolVersion: 1,\n });\n const auth = httpRemote.auth; // hack to get new credentials from CredentialManager API\n let fullRemoteRef;\n if (!remoteRef) {\n fullRemoteRef = fullRef;\n } else {\n try {\n fullRemoteRef = await GitRefManager.expandAgainstMap({\n ref: remoteRef,\n map: httpRemote.refs,\n });\n } catch (err) {\n if (err instanceof NotFoundError) {\n // The remote reference doesn't exist yet.\n // If it is fully specified, use that value. Otherwise, treat it as a branch.\n fullRemoteRef = remoteRef.startsWith('refs/')\n ? remoteRef\n : `refs/heads/${remoteRef}`;\n } else {\n throw err\n }\n }\n }\n const oldoid =\n httpRemote.refs.get(fullRemoteRef) ||\n '0000000000000000000000000000000000000000';\n\n if (onPrePush) {\n const hookCancel = await onPrePush({\n remote,\n url,\n localRef: { ref: _delete ? '(delete)' : fullRef, oid: oid },\n remoteRef: { ref: fullRemoteRef, oid: oldoid },\n });\n if (!hookCancel) throw new UserCanceledError()\n }\n\n // Remotes can always accept thin-packs UNLESS they specify the 'no-thin' capability\n const thinPack = !httpRemote.capabilities.has('no-thin');\n\n let objects = new Set();\n if (!_delete) {\n const finish = [...httpRemote.refs.values()];\n let skipObjects = new Set();\n\n // If remote branch is present, look for a common merge base.\n if (oldoid !== '0000000000000000000000000000000000000000') {\n // trick to speed up common force push scenarios\n const mergebase = await _findMergeBase({\n fs,\n cache,\n gitdir,\n oids: [oid, oldoid],\n });\n for (const oid of mergebase) finish.push(oid);\n if (thinPack) {\n skipObjects = await listObjects({ fs, cache, gitdir, oids: mergebase });\n }\n }\n\n // If remote does not have the commit, figure out the objects to send\n if (!finish.includes(oid)) {\n const commits = await listCommitsAndTags({\n fs,\n cache,\n gitdir,\n start: [oid],\n finish,\n });\n objects = await listObjects({ fs, cache, gitdir, oids: commits });\n }\n\n if (thinPack) {\n // If there's a default branch for the remote lets skip those objects too.\n // Since this is an optional optimization, we just catch and continue if there is\n // an error (because we can't find a default branch, or can't find a commit, etc)\n try {\n // Sadly, the discovery phase with 'forPush' doesn't return symrefs, so we have to\n // rely on existing ones.\n const ref = await GitRefManager.resolve({\n fs,\n gitdir,\n ref: `refs/remotes/${remote}/HEAD`,\n depth: 2,\n });\n const { oid } = await GitRefManager.resolveAgainstMap({\n ref: ref.replace(`refs/remotes/${remote}/`, ''),\n fullref: ref,\n map: httpRemote.refs,\n });\n const oids = [oid];\n for (const oid of await listObjects({ fs, cache, gitdir, oids })) {\n skipObjects.add(oid);\n }\n } catch (e) {}\n\n // Remove objects that we know the remote already has\n for (const oid of skipObjects) {\n objects.delete(oid);\n }\n }\n\n if (oid === oldoid) force = true;\n if (!force) {\n // Is it a tag that already exists?\n if (\n fullRef.startsWith('refs/tags') &&\n oldoid !== '0000000000000000000000000000000000000000'\n ) {\n throw new PushRejectedError('tag-exists')\n }\n // Is it a non-fast-forward commit?\n if (\n oid !== '0000000000000000000000000000000000000000' &&\n oldoid !== '0000000000000000000000000000000000000000' &&\n !(await _isDescendent({\n fs,\n cache,\n gitdir,\n oid,\n ancestor: oldoid,\n depth: -1,\n }))\n ) {\n throw new PushRejectedError('not-fast-forward')\n }\n }\n }\n // We can only safely use capabilities that the server also understands.\n // For instance, AWS CodeCommit aborts a push if you include the `agent`!!!\n const capabilities = filterCapabilities(\n [...httpRemote.capabilities],\n ['report-status', 'side-band-64k', `agent=${pkg.agent}`]\n );\n const packstream1 = await writeReceivePackRequest({\n capabilities,\n triplets: [{ oldoid, oid, fullRef: fullRemoteRef }],\n });\n const packstream2 = _delete\n ? []\n : await _pack({\n fs,\n cache,\n gitdir,\n oids: [...objects],\n });\n const res = await GitRemoteHTTP.connect({\n http,\n onProgress,\n corsProxy,\n service: 'git-receive-pack',\n url,\n auth,\n headers,\n body: [...packstream1, ...packstream2],\n });\n const { packfile, progress } = await GitSideBand.demux(res.body);\n if (onMessage) {\n const lines = splitLines(progress);\n forAwait(lines, async line => {\n await onMessage(line);\n });\n }\n // Parse the response!\n const result = await parseReceivePackResponse(packfile);\n if (res.headers) {\n result.headers = res.headers;\n }\n\n // Update the local copy of the remote ref\n if (\n remote &&\n result.ok &&\n result.refs[fullRemoteRef].ok &&\n !fullRef.startsWith('refs/tags')\n ) {\n // TODO: I think this should actually be using a refspec transform rather than assuming 'refs/remotes/{remote}'\n const ref = `refs/remotes/${remote}/${fullRemoteRef.replace(\n 'refs/heads',\n ''\n )}`;\n if (_delete) {\n await GitRefManager.deleteRef({ fs, gitdir, ref });\n } else {\n await GitRefManager.writeRef({ fs, gitdir, ref, value: oid });\n }\n }\n if (result.ok && Object.values(result.refs).every(result => result.ok)) {\n return result\n } else {\n const prettyDetails = Object.entries(result.refs)\n .filter(([k, v]) => !v.ok)\n .map(([k, v]) => `\\n - ${k}: ${v.error}`)\n .join('');\n throw new GitPushError(prettyDetails, result)\n }\n}\n\n// @ts-check\n\n/**\n * Push a branch or tag\n *\n * The push command returns an object that describes the result of the attempted push operation.\n * *Notes:* If there were no errors, then there will be no `errors` property. There can be a mix of `ok` messages and `errors` messages.\n *\n * | param | type [= default] | description |\n * | ------ | ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n * | ok | Array\\<string\\> | The first item is \"unpack\" if the overall operation was successful. The remaining items are the names of refs that were updated successfully. |\n * | errors | Array\\<string\\> | If the overall operation threw and error, the first item will be \"unpack {Overall error message}\". The remaining items are individual refs that failed to be updated in the format \"{ref name} {error message}\". |\n *\n * @param {object} args\n * @param {FsClient} args.fs - a file system client\n * @param {HttpClient} args.http - an HTTP client\n * @param {ProgressCallback} [args.onProgress] - optional progress event callback\n * @param {MessageCallback} [args.onMessage] - optional message event callback\n * @param {AuthCallback} [args.onAuth] - optional auth fill callback\n * @param {AuthFailureCallback} [args.onAuthFailure] - optional auth rejected callback\n * @param {AuthSuccessCallback} [args.onAuthSuccess] - optional auth approved callback\n * @param {PrePushCallback} [args.onPrePush] - optional pre-push hook callback\n * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {string} [args.ref] - Which branch or tag to push. By default this is the currently checked out branch.\n * @param {string} [args.url] - The URL of the remote repository. The default is the value set in the git config for that remote.\n * @param {string} [args.remote] - If URL is not specified, determines which remote to use.\n * @param {string} [args.remoteRef] - The name of the receiving branch on the remote. By default this is the configured remote tracking branch.\n * @param {boolean} [args.force = false] - If true, behaves the same as `git push --force`\n * @param {boolean} [args.delete = false] - If true, delete the remote ref\n * @param {string} [args.corsProxy] - Optional [CORS proxy](https://www.npmjs.com/%40isomorphic-git/cors-proxy). Overrides value in repo config.\n * @param {Object<string, string>} [args.headers] - Additional headers to include in HTTP requests, similar to git's `extraHeader` config\n * @param {object} [args.cache] - a [cache](cache.md) object\n *\n * @returns {Promise<PushResult>} Resolves successfully when push completes with a detailed description of the operation from the server.\n * @see PushResult\n * @see RefUpdateStatus\n *\n * @example\n * let pushResult = await git.push({\n * fs,\n * http,\n * dir: '/tutorial',\n * remote: 'origin',\n * ref: 'main',\n * onAuth: () => ({ username: process.env.GITHUB_TOKEN }),\n * })\n * console.log(pushResult)\n *\n */\nasync function push({\n fs,\n http,\n onProgress,\n onMessage,\n onAuth,\n onAuthSuccess,\n onAuthFailure,\n onPrePush,\n dir,\n gitdir = join(dir, '.git'),\n ref,\n remoteRef,\n remote = 'origin',\n url,\n force = false,\n delete: _delete = false,\n corsProxy,\n headers = {},\n cache = {},\n}) {\n try {\n assertParameter('fs', fs);\n assertParameter('http', http);\n assertParameter('gitdir', gitdir);\n\n return await _push({\n fs: new FileSystem(fs),\n cache,\n http,\n onProgress,\n onMessage,\n onAuth,\n onAuthSuccess,\n onAuthFailure,\n onPrePush,\n gitdir,\n ref,\n remoteRef,\n remote,\n url,\n force,\n delete: _delete,\n corsProxy,\n headers,\n })\n } catch (err) {\n err.caller = 'git.push';\n throw err\n }\n}\n\nasync function resolveBlob({ fs, cache, gitdir, oid }) {\n const { type, object } = await _readObject({ fs, cache, gitdir, oid });\n // Resolve annotated tag objects to whatever\n if (type === 'tag') {\n oid = GitAnnotatedTag.from(object).parse().object;\n return resolveBlob({ fs, cache, gitdir, oid })\n }\n if (type !== 'blob') {\n throw new ObjectTypeError(oid, type, 'blob')\n }\n return { oid, blob: new Uint8Array(object) }\n}\n\n// @ts-check\n\n/**\n *\n * @typedef {Object} ReadBlobResult - The object returned has the following schema:\n * @property {string} oid\n * @property {Uint8Array} blob\n *\n */\n\n/**\n * @param {object} args\n * @param {import('../models/FileSystem.js').FileSystem} args.fs\n * @param {any} args.cache\n * @param {string} args.gitdir\n * @param {string} args.oid\n * @param {string} [args.filepath]\n *\n * @returns {Promise<ReadBlobResult>} Resolves successfully with a blob object description\n * @see ReadBlobResult\n */\nasync function _readBlob({\n fs,\n cache,\n gitdir,\n oid,\n filepath = undefined,\n}) {\n if (filepath !== undefined) {\n oid = await resolveFilepath({ fs, cache, gitdir, oid, filepath });\n }\n const blob = await resolveBlob({\n fs,\n cache,\n gitdir,\n oid,\n });\n return blob\n}\n\n// @ts-check\n\n/**\n *\n * @typedef {Object} ReadBlobResult - The object returned has the following schema:\n * @property {string} oid\n * @property {Uint8Array} blob\n *\n */\n\n/**\n * Read a blob object directly\n *\n * @param {object} args\n * @param {FsClient} args.fs - a file system client\n * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {string} args.oid - The SHA-1 object id to get. Annotated tags, commits, and trees are peeled.\n * @param {string} [args.filepath] - Don't return the object with `oid` itself, but resolve `oid` to a tree and then return the blob object at that filepath.\n * @param {object} [args.cache] - a [cache](cache.md) object\n *\n * @returns {Promise<ReadBlobResult>} Resolves successfully with a blob object description\n * @see ReadBlobResult\n *\n * @example\n * // Get the contents of 'README.md' in the main branch.\n * let commitOid = await git.resolveRef({ fs, dir: '/tutorial', ref: 'main' })\n * console.log(commitOid)\n * let { blob } = await git.readBlob({\n * fs,\n * dir: '/tutorial',\n * oid: commitOid,\n * filepath: 'README.md'\n * })\n * console.log(Buffer.from(blob).toString('utf8'))\n *\n */\nasync function readBlob({\n fs,\n dir,\n gitdir = join(dir, '.git'),\n oid,\n filepath,\n cache = {},\n}) {\n try {\n assertParameter('fs', fs);\n assertParameter('gitdir', gitdir);\n assertParameter('oid', oid);\n\n return await _readBlob({\n fs: new FileSystem(fs),\n cache,\n gitdir,\n oid,\n filepath,\n })\n } catch (err) {\n err.caller = 'git.readBlob';\n throw err\n }\n}\n\n// @ts-check\n\n/**\n * Read a commit object directly\n *\n * @param {object} args\n * @param {FsClient} args.fs - a file system client\n * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {string} args.oid - The SHA-1 object id to get. Annotated tags are peeled.\n * @param {object} [args.cache] - a [cache](cache.md) object\n *\n * @returns {Promise<ReadCommitResult>} Resolves successfully with a git commit object\n * @see ReadCommitResult\n * @see CommitObject\n *\n * @example\n * // Read a commit object\n * let sha = await git.resolveRef({ fs, dir: '/tutorial', ref: 'main' })\n * console.log(sha)\n * let commit = await git.readCommit({ fs, dir: '/tutorial', oid: sha })\n * console.log(commit)\n *\n */\nasync function readCommit({\n fs,\n dir,\n gitdir = join(dir, '.git'),\n oid,\n cache = {},\n}) {\n try {\n assertParameter('fs', fs);\n assertParameter('gitdir', gitdir);\n assertParameter('oid', oid);\n\n return await _readCommit({\n fs: new FileSystem(fs),\n cache,\n gitdir,\n oid,\n })\n } catch (err) {\n err.caller = 'git.readCommit';\n throw err\n }\n}\n\n// @ts-check\n\n/**\n * Read the contents of a note\n *\n * @param {object} args\n * @param {import('../models/FileSystem.js').FileSystem} args.fs\n * @param {any} args.cache\n * @param {string} args.gitdir\n * @param {string} [args.ref] - The notes ref to look under\n * @param {string} args.oid\n *\n * @returns {Promise<Uint8Array>} Resolves successfully with note contents as a Buffer.\n */\n\nasync function _readNote({\n fs,\n cache,\n gitdir,\n ref = 'refs/notes/commits',\n oid,\n}) {\n const parent = await GitRefManager.resolve({ gitdir, fs, ref });\n const { blob } = await _readBlob({\n fs,\n cache,\n gitdir,\n oid: parent,\n filepath: oid,\n });\n\n return blob\n}\n\n// @ts-check\n\n/**\n * Read the contents of a note\n *\n * @param {object} args\n * @param {FsClient} args.fs - a file system client\n * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {string} [args.ref] - The notes ref to look under\n * @param {string} args.oid - The SHA-1 object id of the object to get the note for.\n * @param {object} [args.cache] - a [cache](cache.md) object\n *\n * @returns {Promise<Uint8Array>} Resolves successfully with note contents as a Buffer.\n */\n\nasync function readNote({\n fs,\n dir,\n gitdir = join(dir, '.git'),\n ref = 'refs/notes/commits',\n oid,\n cache = {},\n}) {\n try {\n assertParameter('fs', fs);\n assertParameter('gitdir', gitdir);\n assertParameter('ref', ref);\n assertParameter('oid', oid);\n\n return await _readNote({\n fs: new FileSystem(fs),\n cache,\n gitdir,\n ref,\n oid,\n })\n } catch (err) {\n err.caller = 'git.readNote';\n throw err\n }\n}\n\n// @ts-check\n\n/**\n *\n * @typedef {Object} DeflatedObject\n * @property {string} oid\n * @property {'deflated'} type\n * @property {'deflated'} format\n * @property {Uint8Array} object\n * @property {string} [source]\n *\n */\n\n/**\n *\n * @typedef {Object} WrappedObject\n * @property {string} oid\n * @property {'wrapped'} type\n * @property {'wrapped'} format\n * @property {Uint8Array} object\n * @property {string} [source]\n *\n */\n\n/**\n *\n * @typedef {Object} RawObject\n * @property {string} oid\n * @property {'blob'|'commit'|'tree'|'tag'} type\n * @property {'content'} format\n * @property {Uint8Array} object\n * @property {string} [source]\n *\n */\n\n/**\n *\n * @typedef {Object} ParsedBlobObject\n * @property {string} oid\n * @property {'blob'} type\n * @property {'parsed'} format\n * @property {string} object\n * @property {string} [source]\n *\n */\n\n/**\n *\n * @typedef {Object} ParsedCommitObject\n * @property {string} oid\n * @property {'commit'} type\n * @property {'parsed'} format\n * @property {CommitObject} object\n * @property {string} [source]\n *\n */\n\n/**\n *\n * @typedef {Object} ParsedTreeObject\n * @property {string} oid\n * @property {'tree'} type\n * @property {'parsed'} format\n * @property {TreeObject} object\n * @property {string} [source]\n *\n */\n\n/**\n *\n * @typedef {Object} ParsedTagObject\n * @property {string} oid\n * @property {'tag'} type\n * @property {'parsed'} format\n * @property {TagObject} object\n * @property {string} [source]\n *\n */\n\n/**\n *\n * @typedef {ParsedBlobObject | ParsedCommitObject | ParsedTreeObject | ParsedTagObject} ParsedObject\n */\n\n/**\n *\n * @typedef {DeflatedObject | WrappedObject | RawObject | ParsedObject } ReadObjectResult\n */\n\n/**\n * Read a git object directly by its SHA-1 object id\n *\n * Regarding `ReadObjectResult`:\n *\n * - `oid` will be the same as the `oid` argument unless the `filepath` argument is provided, in which case it will be the oid of the tree or blob being returned.\n * - `type` of deflated objects is `'deflated'`, and `type` of wrapped objects is `'wrapped'`\n * - `format` is usually, but not always, the format you requested. Packfiles do not store each object individually compressed so if you end up reading the object from a packfile it will be returned in format 'content' even if you requested 'deflated' or 'wrapped'.\n * - `object` will be an actual Object if format is 'parsed' and the object is a commit, tree, or annotated tag. Blobs are still formatted as Buffers unless an encoding is provided in which case they'll be strings. If format is anything other than 'parsed', object will be a Buffer.\n * - `source` is the name of the packfile or loose object file where the object was found.\n *\n * The `format` parameter can have the following values:\n *\n * | param | description |\n * | ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n * | 'deflated' | Return the raw deflate-compressed buffer for an object if possible. Useful for efficiently shuffling around loose objects when you don't care about the contents and can save time by not inflating them. |\n * | 'wrapped' | Return the inflated object buffer wrapped in the git object header if possible. This is the raw data used when calculating the SHA-1 object id of a git object. |\n * | 'content' | Return the object buffer without the git header. |\n * | 'parsed' | Returns a parsed representation of the object. |\n *\n * The result will be in one of the following schemas:\n *\n * ## `'deflated'` format\n *\n * {@link DeflatedObject typedef}\n *\n * ## `'wrapped'` format\n *\n * {@link WrappedObject typedef}\n *\n * ## `'content'` format\n *\n * {@link RawObject typedef}\n *\n * ## `'parsed'` format\n *\n * ### parsed `'blob'` type\n *\n * {@link ParsedBlobObject typedef}\n *\n * ### parsed `'commit'` type\n *\n * {@link ParsedCommitObject typedef}\n * {@link CommitObject typedef}\n *\n * ### parsed `'tree'` type\n *\n * {@link ParsedTreeObject typedef}\n * {@link TreeObject typedef}\n * {@link TreeEntry typedef}\n *\n * ### parsed `'tag'` type\n *\n * {@link ParsedTagObject typedef}\n * {@link TagObject typedef}\n *\n * @deprecated\n * > This command is overly complicated.\n * >\n * > If you know the type of object you are reading, use [`readBlob`](./readBlob.md), [`readCommit`](./readCommit.md), [`readTag`](./readTag.md), or [`readTree`](./readTree.md).\n *\n * @param {object} args\n * @param {FsClient} args.fs - a file system client\n * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {string} args.oid - The SHA-1 object id to get\n * @param {'deflated' | 'wrapped' | 'content' | 'parsed'} [args.format = 'parsed'] - What format to return the object in. The choices are described in more detail below.\n * @param {string} [args.filepath] - Don't return the object with `oid` itself, but resolve `oid` to a tree and then return the object at that filepath. To return the root directory of a tree set filepath to `''`\n * @param {string} [args.encoding] - A convenience argument that only affects blobs. Instead of returning `object` as a buffer, it returns a string parsed using the given encoding.\n * @param {object} [args.cache] - a [cache](cache.md) object\n *\n * @returns {Promise<ReadObjectResult>} Resolves successfully with a git object description\n * @see ReadObjectResult\n *\n * @example\n * // Given a ransom SHA-1 object id, figure out what it is\n * let { type, object } = await git.readObject({\n * fs,\n * dir: '/tutorial',\n * oid: '0698a781a02264a6f37ba3ff41d78067eaf0f075'\n * })\n * switch (type) {\n * case 'commit': {\n * console.log(object)\n * break\n * }\n * case 'tree': {\n * console.log(object)\n * break\n * }\n * case 'blob': {\n * console.log(object)\n * break\n * }\n * case 'tag': {\n * console.log(object)\n * break\n * }\n * }\n *\n */\nasync function readObject({\n fs: _fs,\n dir,\n gitdir = join(dir, '.git'),\n oid,\n format = 'parsed',\n filepath = undefined,\n encoding = undefined,\n cache = {},\n}) {\n try {\n assertParameter('fs', _fs);\n assertParameter('gitdir', gitdir);\n assertParameter('oid', oid);\n\n const fs = new FileSystem(_fs);\n if (filepath !== undefined) {\n oid = await resolveFilepath({\n fs,\n cache,\n gitdir,\n oid,\n filepath,\n });\n }\n // GitObjectManager does not know how to parse content, so we tweak that parameter before passing it.\n const _format = format === 'parsed' ? 'content' : format;\n const result = await _readObject({\n fs,\n cache,\n gitdir,\n oid,\n format: _format,\n });\n result.oid = oid;\n if (format === 'parsed') {\n result.format = 'parsed';\n switch (result.type) {\n case 'commit':\n result.object = GitCommit.from(result.object).parse();\n break\n case 'tree':\n result.object = GitTree.from(result.object).entries();\n break\n case 'blob':\n // Here we consider returning a raw Buffer as the 'content' format\n // and returning a string as the 'parsed' format\n if (encoding) {\n result.object = result.object.toString(encoding);\n } else {\n result.object = new Uint8Array(result.object);\n result.format = 'content';\n }\n break\n case 'tag':\n result.object = GitAnnotatedTag.from(result.object).parse();\n break\n default:\n throw new ObjectTypeError(\n result.oid,\n result.type,\n 'blob|commit|tag|tree'\n )\n }\n } else if (result.format === 'deflated' || result.format === 'wrapped') {\n result.type = result.format;\n }\n return result\n } catch (err) {\n err.caller = 'git.readObject';\n throw err\n }\n}\n\n// @ts-check\n\n/**\n *\n * @typedef {Object} ReadTagResult - The object returned has the following schema:\n * @property {string} oid - SHA-1 object id of this tag\n * @property {TagObject} tag - the parsed tag object\n * @property {string} payload - PGP signing payload\n */\n\n/**\n * @param {object} args\n * @param {import('../models/FileSystem.js').FileSystem} args.fs\n * @param {any} args.cache\n * @param {string} args.gitdir\n * @param {string} args.oid\n *\n * @returns {Promise<ReadTagResult>}\n */\nasync function _readTag({ fs, cache, gitdir, oid }) {\n const { type, object } = await _readObject({\n fs,\n cache,\n gitdir,\n oid,\n format: 'content',\n });\n if (type !== 'tag') {\n throw new ObjectTypeError(oid, type, 'tag')\n }\n const tag = GitAnnotatedTag.from(object);\n const result = {\n oid,\n tag: tag.parse(),\n payload: tag.payload(),\n };\n // @ts-ignore\n return result\n}\n\n/**\n *\n * @typedef {Object} ReadTagResult - The object returned has the following schema:\n * @property {string} oid - SHA-1 object id of this tag\n * @property {TagObject} tag - the parsed tag object\n * @property {string} payload - PGP signing payload\n */\n\n/**\n * Read an annotated tag object directly\n *\n * @param {object} args\n * @param {FsClient} args.fs - a file system client\n * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {string} args.oid - The SHA-1 object id to get\n * @param {object} [args.cache] - a [cache](cache.md) object\n *\n * @returns {Promise<ReadTagResult>} Resolves successfully with a git object description\n * @see ReadTagResult\n * @see TagObject\n *\n */\nasync function readTag({\n fs,\n dir,\n gitdir = join(dir, '.git'),\n oid,\n cache = {},\n}) {\n try {\n assertParameter('fs', fs);\n assertParameter('gitdir', gitdir);\n assertParameter('oid', oid);\n\n return await _readTag({\n fs: new FileSystem(fs),\n cache,\n gitdir,\n oid,\n })\n } catch (err) {\n err.caller = 'git.readTag';\n throw err\n }\n}\n\n// @ts-check\n\n/**\n *\n * @typedef {Object} ReadTreeResult - The object returned has the following schema:\n * @property {string} oid - SHA-1 object id of this tree\n * @property {TreeObject} tree - the parsed tree object\n */\n\n/**\n * Read a tree object directly\n *\n * @param {object} args\n * @param {FsClient} args.fs - a file system client\n * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {string} args.oid - The SHA-1 object id to get. Annotated tags and commits are peeled.\n * @param {string} [args.filepath] - Don't return the object with `oid` itself, but resolve `oid` to a tree and then return the tree object at that filepath.\n * @param {object} [args.cache] - a [cache](cache.md) object\n *\n * @returns {Promise<ReadTreeResult>} Resolves successfully with a git tree object\n * @see ReadTreeResult\n * @see TreeObject\n * @see TreeEntry\n *\n */\nasync function readTree({\n fs,\n dir,\n gitdir = join(dir, '.git'),\n oid,\n filepath = undefined,\n cache = {},\n}) {\n try {\n assertParameter('fs', fs);\n assertParameter('gitdir', gitdir);\n assertParameter('oid', oid);\n\n return await _readTree({\n fs: new FileSystem(fs),\n cache,\n gitdir,\n oid,\n filepath,\n })\n } catch (err) {\n err.caller = 'git.readTree';\n throw err\n }\n}\n\n// @ts-check\n\n/**\n * Remove a file from the git index (aka staging area)\n *\n * Note that this does NOT delete the file in the working directory.\n *\n * @param {object} args\n * @param {FsClient} args.fs - a file system client\n * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {string} args.filepath - The path to the file to remove from the index\n * @param {object} [args.cache] - a [cache](cache.md) object\n *\n * @returns {Promise<void>} Resolves successfully once the git index has been updated\n *\n * @example\n * await git.remove({ fs, dir: '/tutorial', filepath: 'README.md' })\n * console.log('done')\n *\n */\nasync function remove({\n fs: _fs,\n dir,\n gitdir = join(dir, '.git'),\n filepath,\n cache = {},\n}) {\n try {\n assertParameter('fs', _fs);\n assertParameter('gitdir', gitdir);\n assertParameter('filepath', filepath);\n\n await GitIndexManager.acquire(\n { fs: new FileSystem(_fs), gitdir, cache },\n async function(index) {\n index.delete({ filepath });\n }\n );\n } catch (err) {\n err.caller = 'git.remove';\n throw err\n }\n}\n\n// @ts-check\n\n/**\n * @param {object} args\n * @param {import('../models/FileSystem.js').FileSystem} args.fs\n * @param {object} args.cache\n * @param {SignCallback} [args.onSign]\n * @param {string} [args.dir]\n * @param {string} [args.gitdir=join(dir,'.git')]\n * @param {string} [args.ref]\n * @param {string} args.oid\n * @param {Object} args.author\n * @param {string} args.author.name\n * @param {string} args.author.email\n * @param {number} args.author.timestamp\n * @param {number} args.author.timezoneOffset\n * @param {Object} args.committer\n * @param {string} args.committer.name\n * @param {string} args.committer.email\n * @param {number} args.committer.timestamp\n * @param {number} args.committer.timezoneOffset\n * @param {string} [args.signingKey]\n *\n * @returns {Promise<string>}\n */\n\nasync function _removeNote({\n fs,\n cache,\n onSign,\n gitdir,\n ref = 'refs/notes/commits',\n oid,\n author,\n committer,\n signingKey,\n}) {\n // Get the current note commit\n let parent;\n try {\n parent = await GitRefManager.resolve({ gitdir, fs, ref });\n } catch (err) {\n if (!(err instanceof NotFoundError)) {\n throw err\n }\n }\n\n // I'm using the \"empty tree\" magic number here for brevity\n const result = await _readTree({\n fs,\n gitdir,\n oid: parent || '4b825dc642cb6eb9a060e54bf8d69288fbee4904',\n });\n let tree = result.tree;\n\n // Remove the note blob entry from the tree\n tree = tree.filter(entry => entry.path !== oid);\n\n // Create the new note tree\n const treeOid = await _writeTree({\n fs,\n gitdir,\n tree,\n });\n\n // Create the new note commit\n const commitOid = await _commit({\n fs,\n cache,\n onSign,\n gitdir,\n ref,\n tree: treeOid,\n parent: parent && [parent],\n message: `Note removed by 'isomorphic-git removeNote'\\n`,\n author,\n committer,\n signingKey,\n });\n\n return commitOid\n}\n\n// @ts-check\n\n/**\n * Remove an object note\n *\n * @param {object} args\n * @param {FsClient} args.fs - a file system client\n * @param {SignCallback} [args.onSign] - a PGP signing implementation\n * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {string} [args.ref] - The notes ref to look under\n * @param {string} args.oid - The SHA-1 object id of the object to remove the note from.\n * @param {Object} [args.author] - The details about the author.\n * @param {string} [args.author.name] - Default is `user.name` config.\n * @param {string} [args.author.email] - Default is `user.email` config.\n * @param {number} [args.author.timestamp=Math.floor(Date.now()/1000)] - Set the author timestamp field. This is the integer number of seconds since the Unix epoch (1970-01-01 00:00:00).\n * @param {number} [args.author.timezoneOffset] - Set the author timezone offset field. This is the difference, in minutes, from the current timezone to UTC. Default is `(new Date()).getTimezoneOffset()`.\n * @param {Object} [args.committer = author] - The details about the note committer, in the same format as the author parameter. If not specified, the author details are used.\n * @param {string} [args.committer.name] - Default is `user.name` config.\n * @param {string} [args.committer.email] - Default is `user.email` config.\n * @param {number} [args.committer.timestamp=Math.floor(Date.now()/1000)] - Set the committer timestamp field. This is the integer number of seconds since the Unix epoch (1970-01-01 00:00:00).\n * @param {number} [args.committer.timezoneOffset] - Set the committer timezone offset field. This is the difference, in minutes, from the current timezone to UTC. Default is `(new Date()).getTimezoneOffset()`.\n * @param {string} [args.signingKey] - Sign the tag object using this private PGP key.\n * @param {object} [args.cache] - a [cache](cache.md) object\n *\n * @returns {Promise<string>} Resolves successfully with the SHA-1 object id of the commit object for the note removal.\n */\n\nasync function removeNote({\n fs: _fs,\n onSign,\n dir,\n gitdir = join(dir, '.git'),\n ref = 'refs/notes/commits',\n oid,\n author: _author,\n committer: _committer,\n signingKey,\n cache = {},\n}) {\n try {\n assertParameter('fs', _fs);\n assertParameter('gitdir', gitdir);\n assertParameter('oid', oid);\n\n const fs = new FileSystem(_fs);\n\n const author = await normalizeAuthorObject({ fs, gitdir, author: _author });\n if (!author) throw new MissingNameError('author')\n\n const committer = await normalizeCommitterObject({\n fs,\n gitdir,\n author,\n committer: _committer,\n });\n if (!committer) throw new MissingNameError('committer')\n\n return await _removeNote({\n fs,\n cache,\n onSign,\n gitdir,\n ref,\n oid,\n author,\n committer,\n signingKey,\n })\n } catch (err) {\n err.caller = 'git.removeNote';\n throw err\n }\n}\n\n// @ts-check\n\n/**\n * Rename a branch\n *\n * @param {object} args\n * @param {import('../models/FileSystem.js').FileSystem} args.fs\n * @param {string} args.gitdir\n * @param {string} args.ref - The name of the new branch\n * @param {string} args.oldref - The name of the old branch\n * @param {boolean} [args.checkout = false]\n *\n * @returns {Promise<void>} Resolves successfully when filesystem operations are complete\n */\nasync function _renameBranch({\n fs,\n gitdir,\n oldref,\n ref,\n checkout = false,\n}) {\n if (ref !== cleanGitRef.clean(ref)) {\n throw new InvalidRefNameError(ref, cleanGitRef.clean(ref))\n }\n\n if (oldref !== cleanGitRef.clean(oldref)) {\n throw new InvalidRefNameError(oldref, cleanGitRef.clean(oldref))\n }\n\n const fulloldref = `refs/heads/${oldref}`;\n const fullnewref = `refs/heads/${ref}`;\n\n const newexist = await GitRefManager.exists({ fs, gitdir, ref: fullnewref });\n\n if (newexist) {\n throw new AlreadyExistsError('branch', ref, false)\n }\n\n const value = await GitRefManager.resolve({\n fs,\n gitdir,\n ref: fulloldref,\n depth: 1,\n });\n\n await GitRefManager.writeRef({ fs, gitdir, ref: fullnewref, value });\n await GitRefManager.deleteRef({ fs, gitdir, ref: fulloldref });\n\n const fullCurrentBranchRef = await _currentBranch({\n fs,\n gitdir,\n fullname: true,\n });\n const isCurrentBranch = fullCurrentBranchRef === fulloldref;\n\n if (checkout || isCurrentBranch) {\n // Update HEAD\n await GitRefManager.writeSymbolicRef({\n fs,\n gitdir,\n ref: 'HEAD',\n value: fullnewref,\n });\n }\n}\n\n// @ts-check\n\n/**\n * Rename a branch\n *\n * @param {object} args\n * @param {FsClient} args.fs - a file system implementation\n * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {string} args.ref - What to name the branch\n * @param {string} args.oldref - What the name of the branch was\n * @param {boolean} [args.checkout = false] - Update `HEAD` to point at the newly created branch\n *\n * @returns {Promise<void>} Resolves successfully when filesystem operations are complete\n *\n * @example\n * await git.renameBranch({ fs, dir: '/tutorial', ref: 'main', oldref: 'master' })\n * console.log('done')\n *\n */\nasync function renameBranch({\n fs,\n dir,\n gitdir = join(dir, '.git'),\n ref,\n oldref,\n checkout = false,\n}) {\n try {\n assertParameter('fs', fs);\n assertParameter('gitdir', gitdir);\n assertParameter('ref', ref);\n assertParameter('oldref', oldref);\n return await _renameBranch({\n fs: new FileSystem(fs),\n gitdir,\n ref,\n oldref,\n checkout,\n })\n } catch (err) {\n err.caller = 'git.renameBranch';\n throw err\n }\n}\n\nasync function hashObject$1({ gitdir, type, object }) {\n return shasum(GitObject.wrap({ type, object }))\n}\n\n// @ts-check\n\n/**\n * Reset a file in the git index (aka staging area)\n *\n * Note that this does NOT modify the file in the working directory.\n *\n * @param {object} args\n * @param {FsClient} args.fs - a file system client\n * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {string} args.filepath - The path to the file to reset in the index\n * @param {string} [args.ref = 'HEAD'] - A ref to the commit to use\n * @param {object} [args.cache] - a [cache](cache.md) object\n *\n * @returns {Promise<void>} Resolves successfully once the git index has been updated\n *\n * @example\n * await git.resetIndex({ fs, dir: '/tutorial', filepath: 'README.md' })\n * console.log('done')\n *\n */\nasync function resetIndex({\n fs: _fs,\n dir,\n gitdir = join(dir, '.git'),\n filepath,\n ref,\n cache = {},\n}) {\n try {\n assertParameter('fs', _fs);\n assertParameter('gitdir', gitdir);\n assertParameter('filepath', filepath);\n\n const fs = new FileSystem(_fs);\n\n let oid;\n let workdirOid;\n\n try {\n // Resolve commit\n oid = await GitRefManager.resolve({ fs, gitdir, ref: ref || 'HEAD' });\n } catch (e) {\n if (ref) {\n // Only throw the error if a ref is explicitly provided\n throw e\n }\n }\n\n // Not having an oid at this point means `resetIndex()` was called without explicit `ref` on a new git\n // repository. If that happens, we can skip resolving the file path.\n if (oid) {\n try {\n // Resolve blob\n oid = await resolveFilepath({\n fs,\n cache,\n gitdir,\n oid,\n filepath,\n });\n } catch (e) {\n // This means we're resetting the file to a \"deleted\" state\n oid = null;\n }\n }\n\n // For files that aren't in the workdir use zeros\n let stats = {\n ctime: new Date(0),\n mtime: new Date(0),\n dev: 0,\n ino: 0,\n mode: 0,\n uid: 0,\n gid: 0,\n size: 0,\n };\n // If the file exists in the workdir...\n const object = dir && (await fs.read(join(dir, filepath)));\n if (object) {\n // ... and has the same hash as the desired state...\n workdirOid = await hashObject$1({\n gitdir,\n type: 'blob',\n object,\n });\n if (oid === workdirOid) {\n // ... use the workdir Stats object\n stats = await fs.lstat(join(dir, filepath));\n }\n }\n await GitIndexManager.acquire({ fs, gitdir, cache }, async function(index) {\n index.delete({ filepath });\n if (oid) {\n index.insert({ filepath, stats, oid });\n }\n });\n } catch (err) {\n err.caller = 'git.reset';\n throw err\n }\n}\n\n// @ts-check\n\n/**\n * Get the value of a symbolic ref or resolve a ref to its SHA-1 object id\n *\n * @param {object} args\n * @param {FsClient} args.fs - a file system client\n * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {string} args.ref - The ref to resolve\n * @param {number} [args.depth = undefined] - How many symbolic references to follow before returning\n *\n * @returns {Promise<string>} Resolves successfully with a SHA-1 object id or the value of a symbolic ref\n *\n * @example\n * let currentCommit = await git.resolveRef({ fs, dir: '/tutorial', ref: 'HEAD' })\n * console.log(currentCommit)\n * let currentBranch = await git.resolveRef({ fs, dir: '/tutorial', ref: 'HEAD', depth: 2 })\n * console.log(currentBranch)\n *\n */\nasync function resolveRef({\n fs,\n dir,\n gitdir = join(dir, '.git'),\n ref,\n depth,\n}) {\n try {\n assertParameter('fs', fs);\n assertParameter('gitdir', gitdir);\n assertParameter('ref', ref);\n\n const oid = await GitRefManager.resolve({\n fs: new FileSystem(fs),\n gitdir,\n ref,\n depth,\n });\n return oid\n } catch (err) {\n err.caller = 'git.resolveRef';\n throw err\n }\n}\n\n// @ts-check\n\n/**\n * Write an entry to the git config files.\n *\n * *Caveats:*\n * - Currently only the local `$GIT_DIR/config` file can be read or written. However support for the global `~/.gitconfig` and system `$(prefix)/etc/gitconfig` will be added in the future.\n * - The current parser does not support the more exotic features of the git-config file format such as `[include]` and `[includeIf]`.\n *\n * @param {Object} args\n * @param {FsClient} args.fs - a file system implementation\n * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {string} args.path - The key of the git config entry\n * @param {string | boolean | number | void} args.value - A value to store at that path. (Use `undefined` as the value to delete a config entry.)\n * @param {boolean} [args.append = false] - If true, will append rather than replace when setting (use with multi-valued config options).\n *\n * @returns {Promise<void>} Resolves successfully when operation completed\n *\n * @example\n * // Write config value\n * await git.setConfig({\n * fs,\n * dir: '/tutorial',\n * path: 'user.name',\n * value: 'Mr. Test'\n * })\n *\n * // Print out config file\n * let file = await fs.promises.readFile('/tutorial/.git/config', 'utf8')\n * console.log(file)\n *\n * // Delete a config entry\n * await git.setConfig({\n * fs,\n * dir: '/tutorial',\n * path: 'user.name',\n * value: undefined\n * })\n *\n * // Print out config file\n * file = await fs.promises.readFile('/tutorial/.git/config', 'utf8')\n * console.log(file)\n */\nasync function setConfig({\n fs: _fs,\n dir,\n gitdir = join(dir, '.git'),\n path,\n value,\n append = false,\n}) {\n try {\n assertParameter('fs', _fs);\n assertParameter('gitdir', gitdir);\n assertParameter('path', path);\n // assertParameter('value', value) // We actually allow 'undefined' as a value to unset/delete\n\n const fs = new FileSystem(_fs);\n const config = await GitConfigManager.get({ fs, gitdir });\n if (append) {\n await config.append(path, value);\n } else {\n await config.set(path, value);\n }\n await GitConfigManager.save({ fs, gitdir, config });\n } catch (err) {\n err.caller = 'git.setConfig';\n throw err\n }\n}\n\n// @ts-check\n\n/**\n * @param {object} args\n * @param {import('../models/FileSystem.js').FileSystem} args.fs\n * @param {string} args.gitdir\n * @param {CommitObject} args.commit\n *\n * @returns {Promise<string>}\n * @see CommitObject\n *\n */\nasync function _writeCommit({ fs, gitdir, commit }) {\n // Convert object to buffer\n const object = GitCommit.from(commit).toObject();\n const oid = await _writeObject({\n fs,\n gitdir,\n type: 'commit',\n object,\n format: 'content',\n });\n return oid\n}\n\nclass GitRefStash {\n // constructor removed\n\n static get timezoneOffsetForRefLogEntry() {\n const offsetMinutes = new Date().getTimezoneOffset();\n const offsetHours = Math.abs(Math.floor(offsetMinutes / 60));\n const offsetMinutesFormatted = Math.abs(offsetMinutes % 60)\n .toString()\n .padStart(2, '0');\n const sign = offsetMinutes > 0 ? '-' : '+';\n return `${sign}${offsetHours\n .toString()\n .padStart(2, '0')}${offsetMinutesFormatted}`\n }\n\n static createStashReflogEntry(author, stashCommit, message) {\n const nameNoSpace = author.name.replace(/\\s/g, '');\n const z40 = '0000000000000000000000000000000000000000'; // hard code for now, works with `git stash list`\n const timestamp = Math.floor(Date.now() / 1000);\n const timezoneOffset = GitRefStash.timezoneOffsetForRefLogEntry;\n return `${z40} ${stashCommit} ${nameNoSpace} ${author.email} ${timestamp} ${timezoneOffset}\\t${message}\\n`\n }\n\n static getStashReflogEntry(reflogString, parsed = false) {\n const reflogLines = reflogString.split('\\n');\n const entries = reflogLines\n .filter(l => l)\n .reverse()\n .map((line, idx) =>\n parsed ? `stash@{${idx}}: ${line.split('\\t')[1]}` : line\n );\n return entries\n }\n}\n\nconst _TreeMap = {\n stage: STAGE,\n workdir: WORKDIR,\n};\n\nlet lock$3;\nasync function acquireLock$1(ref, callback) {\n if (lock$3 === undefined) lock$3 = new AsyncLock();\n return lock$3.acquire(ref, callback)\n}\n\n// make sure filepath, blob type and blob object (from loose objects) plus oid are in sync and valid\nasync function checkAndWriteBlob(fs, gitdir, dir, filepath, oid = null) {\n const currentFilepath = join(dir, filepath);\n const stats = await fs.lstat(currentFilepath);\n if (!stats) throw new NotFoundError(currentFilepath)\n if (stats.isDirectory())\n throw new InternalError(\n `${currentFilepath}: file expected, but found directory`\n )\n\n // Look for it in the loose object directory.\n const objContent = oid\n ? await readObjectLoose({ fs, gitdir, oid })\n : undefined;\n let retOid = objContent ? oid : undefined;\n if (!objContent) {\n await acquireLock$1({ fs, gitdir, currentFilepath }, async () => {\n const object = stats.isSymbolicLink()\n ? await fs.readlink(currentFilepath).then(posixifyPathBuffer)\n : await fs.read(currentFilepath);\n\n if (object === null) throw new NotFoundError(currentFilepath)\n\n retOid = await _writeObject({ fs, gitdir, type: 'blob', object });\n });\n }\n\n return retOid\n}\n\nasync function processTreeEntries({ fs, dir, gitdir, entries }) {\n // make sure each tree entry has valid oid\n async function processTreeEntry(entry) {\n if (entry.type === 'tree') {\n if (!entry.oid) {\n // Process children entries if the current entry is a tree\n const children = await Promise.all(entry.children.map(processTreeEntry));\n // Write the tree with the processed children\n entry.oid = await _writeTree({\n fs,\n gitdir,\n tree: children,\n });\n entry.mode = 0o40000; // directory\n }\n } else if (entry.type === 'blob') {\n entry.oid = await checkAndWriteBlob(\n fs,\n gitdir,\n dir,\n entry.path,\n entry.oid\n );\n entry.mode = 0o100644; // file\n }\n\n // remove path from entry.path\n entry.path = entry.path.split('/').pop();\n return entry\n }\n\n return Promise.all(entries.map(processTreeEntry))\n}\n\nasync function writeTreeChanges({\n fs,\n dir,\n gitdir,\n treePair, // [TREE({ ref: 'HEAD' }), 'STAGE'] would be the equivalent of `git write-tree`\n}) {\n const isStage = treePair[1] === 'stage';\n const trees = treePair.map(t => (typeof t === 'string' ? _TreeMap[t]() : t));\n\n const changedEntries = [];\n // transform WalkerEntry objects into the desired format\n const map = async (filepath, [head, stage]) => {\n if (\n filepath === '.' ||\n (await GitIgnoreManager.isIgnored({ fs, dir, gitdir, filepath }))\n ) {\n return\n }\n\n if (stage) {\n if (\n !head ||\n ((await head.oid()) !== (await stage.oid()) &&\n (await stage.oid()) !== undefined)\n ) {\n changedEntries.push([head, stage]);\n }\n return {\n mode: await stage.mode(),\n path: filepath,\n oid: await stage.oid(),\n type: await stage.type(),\n }\n }\n };\n\n // combine mapped entries with their parent results\n const reduce = async (parent, children) => {\n children = children.filter(Boolean); // Remove undefined entries\n if (!parent) {\n return children.length > 0 ? children : undefined\n } else {\n parent.children = children;\n return parent\n }\n };\n\n // if parent is skipped, skip the children\n const iterate = async (walk, children) => {\n const filtered = [];\n for (const child of children) {\n const [head, stage] = child;\n if (isStage) {\n if (stage) {\n // for deleted file in work dir, it also needs to be added on stage\n if (await fs.exists(`${dir}/${stage.toString()}`)) {\n filtered.push(child);\n } else {\n changedEntries.push([null, stage]); // record the change (deletion) while stop the iteration\n }\n }\n } else if (head) {\n // for deleted file in workdir, \"stage\" (workdir in our case) will be undefined\n if (!stage) {\n changedEntries.push([head, null]); // record the change (deletion) while stop the iteration\n } else {\n filtered.push(child); // workdir, tracked only\n }\n }\n }\n return filtered.length ? Promise.all(filtered.map(walk)) : []\n };\n\n const entries = await _walk({\n fs,\n cache: {},\n dir,\n gitdir,\n trees,\n map,\n reduce,\n iterate,\n });\n\n if (changedEntries.length === 0 || entries.length === 0) {\n return null // no changes found to stash\n }\n\n const processedEntries = await processTreeEntries({\n fs,\n dir,\n gitdir,\n entries,\n });\n\n const treeEntries = processedEntries.filter(Boolean).map(entry => ({\n mode: entry.mode,\n path: entry.path,\n oid: entry.oid,\n type: entry.type,\n }));\n\n return _writeTree({ fs, gitdir, tree: treeEntries })\n}\n\nasync function applyTreeChanges({\n fs,\n dir,\n gitdir,\n stashCommit,\n parentCommit,\n wasStaged,\n}) {\n const dirRemoved = [];\n const stageUpdated = [];\n\n // analyze the changes\n const ops = await _walk({\n fs,\n cache: {},\n dir,\n gitdir,\n trees: [TREE({ ref: parentCommit }), TREE({ ref: stashCommit })],\n map: async (filepath, [parent, stash]) => {\n if (\n filepath === '.' ||\n (await GitIgnoreManager.isIgnored({ fs, dir, gitdir, filepath }))\n ) {\n return\n }\n const type = stash ? await stash.type() : await parent.type();\n if (type !== 'tree' && type !== 'blob') {\n return\n }\n\n // deleted tree or blob\n if (!stash && parent) {\n const method = type === 'tree' ? 'rmdir' : 'rm';\n if (type === 'tree') dirRemoved.push(filepath);\n if (type === 'blob' && wasStaged)\n stageUpdated.push({ filepath, oid: await parent.oid() }); // stats is undefined, will stage the deletion with index.insert\n return { method, filepath }\n }\n\n const oid = await stash.oid();\n if (!parent || (await parent.oid()) !== oid) {\n // only apply changes if changed from the parent commit or doesn't exist in the parent commit\n if (type === 'tree') {\n return { method: 'mkdir', filepath }\n } else {\n if (wasStaged)\n stageUpdated.push({\n filepath,\n oid,\n stats: await fs.lstat(join(dir, filepath)),\n });\n return {\n method: 'write',\n filepath,\n oid,\n }\n }\n }\n },\n });\n\n // apply the changes to work dir\n await acquireLock$1({ fs, gitdir, dirRemoved, ops }, async () => {\n for (const op of ops) {\n const currentFilepath = join(dir, op.filepath);\n switch (op.method) {\n case 'rmdir':\n await fs.rmdir(currentFilepath);\n break\n case 'mkdir':\n await fs.mkdir(currentFilepath);\n break\n case 'rm':\n await fs.rm(currentFilepath);\n break\n case 'write':\n // only writes if file is not in the removedDirs\n if (\n !dirRemoved.some(removedDir =>\n currentFilepath.startsWith(removedDir)\n )\n ) {\n const { object } = await _readObject({\n fs,\n cache: {},\n gitdir,\n oid: op.oid,\n });\n // just like checkout, since mode only applicable to create, not update, delete first\n if (await fs.exists(currentFilepath)) {\n await fs.rm(currentFilepath);\n }\n await fs.write(currentFilepath, object); // only handles regular files for now\n }\n break\n }\n }\n });\n\n // update the stage\n await GitIndexManager.acquire({ fs, gitdir, cache: {} }, async index => {\n stageUpdated.forEach(({ filepath, stats, oid }) => {\n index.insert({ filepath, stats, oid });\n });\n });\n}\n\nclass GitStashManager {\n constructor({ fs, dir, gitdir = join(dir, '.git') }) {\n Object.assign(this, {\n fs,\n dir,\n gitdir,\n _author: null,\n });\n }\n\n static get refStash() {\n return 'refs/stash'\n }\n\n static get refLogsStash() {\n return 'logs/refs/stash'\n }\n\n get refStashPath() {\n return join(this.gitdir, GitStashManager.refStash)\n }\n\n get refLogsStashPath() {\n return join(this.gitdir, GitStashManager.refLogsStash)\n }\n\n async getAuthor() {\n if (!this._author) {\n this._author = await normalizeAuthorObject({\n fs: this.fs,\n gitdir: this.gitdir,\n author: {},\n });\n if (!this._author) throw new MissingNameError('author')\n }\n return this._author\n }\n\n async getStashSHA(refIdx, stashEntries) {\n if (!(await this.fs.exists(this.refStashPath))) {\n return null\n }\n\n const entries =\n stashEntries || (await this.readStashReflogs({ parsed: false }));\n return entries[refIdx].split(' ')[1]\n }\n\n async writeStashCommit({ message, tree, parent }) {\n return _writeCommit({\n fs: this.fs,\n gitdir: this.gitdir,\n commit: {\n message,\n tree,\n parent,\n author: await this.getAuthor(),\n committer: await this.getAuthor(),\n },\n })\n }\n\n async readStashCommit(refIdx) {\n const stashEntries = await this.readStashReflogs({ parsed: false });\n if (refIdx !== 0) {\n // non-default case, throw exceptions if not valid\n if (refIdx < 0 || refIdx > stashEntries.length - 1) {\n throw new InvalidRefNameError(\n `stash@${refIdx}`,\n 'number that is in range of [0, num of stash pushed]'\n )\n }\n }\n\n const stashSHA = await this.getStashSHA(refIdx, stashEntries);\n if (!stashSHA) {\n return {} // no stash found\n }\n\n // get the stash commit object\n return _readCommit({\n fs: this.fs,\n cache: {},\n gitdir: this.gitdir,\n oid: stashSHA,\n })\n }\n\n async writeStashRef(stashCommit) {\n return GitRefManager.writeRef({\n fs: this.fs,\n gitdir: this.gitdir,\n ref: GitStashManager.refStash,\n value: stashCommit,\n })\n }\n\n async writeStashReflogEntry({ stashCommit, message }) {\n const author = await this.getAuthor();\n const entry = GitRefStash.createStashReflogEntry(\n author,\n stashCommit,\n message\n );\n const filepath = this.refLogsStashPath;\n\n await acquireLock$1({ filepath, entry }, async () => {\n const appendTo = (await this.fs.exists(filepath))\n ? await this.fs.read(filepath, 'utf8')\n : '';\n await this.fs.write(filepath, appendTo + entry, 'utf8');\n });\n }\n\n async readStashReflogs({ parsed = false }) {\n if (!(await this.fs.exists(this.refLogsStashPath))) {\n return []\n }\n\n const reflogBuffer = await this.fs.read(this.refLogsStashPath);\n const reflogString = reflogBuffer.toString();\n\n return GitRefStash.getStashReflogEntry(reflogString, parsed)\n }\n}\n\n// @ts-check\n\nasync function _stashPush({ fs, dir, gitdir, message = '' }) {\n const stashMgr = new GitStashManager({ fs, dir, gitdir });\n\n await stashMgr.getAuthor(); // ensure there is an author\n const branch = await _currentBranch({\n fs,\n gitdir,\n fullname: false,\n });\n\n // prepare the stash commit: first parent is the current branch HEAD\n const headCommit = await GitRefManager.resolve({\n fs,\n gitdir,\n ref: 'HEAD',\n });\n\n const headCommitObj = await readCommit({ fs, dir, gitdir, oid: headCommit });\n const headMsg = headCommitObj.commit.message;\n\n const stashCommitParents = [headCommit];\n let stashCommitTree = null;\n let workDirCompareBase = TREE({ ref: 'HEAD' });\n\n const indexTree = await writeTreeChanges({\n fs,\n dir,\n gitdir,\n treePair: [TREE({ ref: 'HEAD' }), 'stage'],\n });\n if (indexTree) {\n // this indexTree will be the tree of the stash commit\n // create a commit from the index tree, which has one parent, the current branch HEAD\n const stashCommitOne = await stashMgr.writeStashCommit({\n message: `stash-Index: WIP on ${branch} - ${new Date().toISOString()}`,\n tree: indexTree, // stashCommitTree\n parent: stashCommitParents,\n });\n stashCommitParents.push(stashCommitOne);\n stashCommitTree = indexTree;\n workDirCompareBase = STAGE();\n }\n\n const workingTree = await writeTreeChanges({\n fs,\n dir,\n gitdir,\n treePair: [workDirCompareBase, 'workdir'],\n });\n if (workingTree) {\n // create a commit from the working directory tree, which has one parent, either the one we just had, or the headCommit\n const workingHeadCommit = await stashMgr.writeStashCommit({\n message: `stash-WorkDir: WIP on ${branch} - ${new Date().toISOString()}`,\n tree: workingTree,\n parent: [stashCommitParents[stashCommitParents.length - 1]],\n });\n\n stashCommitParents.push(workingHeadCommit);\n stashCommitTree = workingTree;\n }\n\n if (!stashCommitTree || (!indexTree && !workingTree)) {\n throw new NotFoundError('changes, nothing to stash')\n }\n\n // create another commit from the tree, which has three parents: HEAD and the commit we just made:\n const stashMsg =\n (message.trim() || `WIP on ${branch}`) +\n `: ${headCommit.substring(0, 7)} ${headMsg}`;\n\n const stashCommit = await stashMgr.writeStashCommit({\n message: stashMsg,\n tree: stashCommitTree,\n parent: stashCommitParents,\n });\n\n // next, write this commit into .git/refs/stash:\n await stashMgr.writeStashRef(stashCommit);\n\n // write the stash commit to the logs\n await stashMgr.writeStashReflogEntry({\n stashCommit,\n message: stashMsg,\n });\n\n // finally, go back to a clean working directory\n await checkout({\n fs,\n dir,\n gitdir,\n ref: branch,\n track: false,\n force: true, // force checkout to discard changes\n });\n\n return stashCommit\n}\n\nasync function _stashApply({ fs, dir, gitdir, refIdx = 0 }) {\n const stashMgr = new GitStashManager({ fs, dir, gitdir });\n\n // get the stash commit object\n const stashCommit = await stashMgr.readStashCommit(refIdx);\n const { parent: stashParents = null } = stashCommit.commit\n ? stashCommit.commit\n : {};\n if (!stashParents || !Array.isArray(stashParents)) {\n return // no stash found\n }\n\n // compare the stash commit tree with its parent commit\n for (let i = 0; i < stashParents.length - 1; i++) {\n const applyingCommit = await _readCommit({\n fs,\n cache: {},\n gitdir,\n oid: stashParents[i + 1],\n });\n const wasStaged = applyingCommit.commit.message.startsWith('stash-Index');\n\n await applyTreeChanges({\n fs,\n dir,\n gitdir,\n stashCommit: stashParents[i + 1],\n parentCommit: stashParents[i],\n wasStaged,\n });\n }\n}\n\nasync function _stashDrop({ fs, dir, gitdir, refIdx = 0 }) {\n const stashMgr = new GitStashManager({ fs, dir, gitdir });\n const stashCommit = await stashMgr.readStashCommit(refIdx);\n if (!stashCommit.commit) {\n return // no stash found\n }\n // remove stash ref first\n const stashRefPath = stashMgr.refStashPath;\n await acquireLock$1(stashRefPath, async () => {\n if (await fs.exists(stashRefPath)) {\n await fs.rm(stashRefPath);\n }\n });\n\n // read from stash reflog and list the stash commits\n const reflogEntries = await stashMgr.readStashReflogs({ parsed: false });\n if (!reflogEntries.length) {\n return // no stash reflog entry\n }\n\n // remove the specified stash reflog entry from reflogEntries, then update the stash reflog\n reflogEntries.splice(refIdx, 1);\n\n const stashReflogPath = stashMgr.refLogsStashPath;\n await acquireLock$1({ reflogEntries, stashReflogPath, stashMgr }, async () => {\n if (reflogEntries.length) {\n await fs.write(stashReflogPath, reflogEntries.join('\\n'), 'utf8');\n const lastStashCommit = reflogEntries[reflogEntries.length - 1].split(\n ' '\n )[1];\n await stashMgr.writeStashRef(lastStashCommit);\n } else {\n // remove the stash reflog file if no entry left\n await fs.rm(stashReflogPath);\n }\n });\n}\n\nasync function _stashList({ fs, dir, gitdir }) {\n const stashMgr = new GitStashManager({ fs, dir, gitdir });\n return stashMgr.readStashReflogs({ parsed: true })\n}\n\nasync function _stashClear({ fs, dir, gitdir }) {\n const stashMgr = new GitStashManager({ fs, dir, gitdir });\n const stashRefPath = [stashMgr.refStashPath, stashMgr.refLogsStashPath];\n\n await acquireLock$1(stashRefPath, async () => {\n await Promise.all(\n stashRefPath.map(async path => {\n if (await fs.exists(path)) {\n return fs.rm(path)\n }\n })\n );\n });\n}\n\nasync function _stashPop({ fs, dir, gitdir, refIdx = 0 }) {\n await _stashApply({ fs, dir, gitdir, refIdx });\n await _stashDrop({ fs, dir, gitdir, refIdx });\n}\n\n// @ts-check\n\n/**\n * stash api, supports {'push' | 'pop' | 'apply' | 'drop' | 'list' | 'clear'} StashOp\n * _note_,\n * - all stash operations are done on tracked files only with loose objects, no packed objects\n * - when op === 'push', both working directory and index (staged) changes will be stashed, tracked files only\n * - when op === 'push', message is optional, and only applicable when op === 'push'\n * - when op === 'apply | pop', the stashed changes will overwrite the working directory, no abort when conflicts\n *\n * @param {object} args\n * @param {FsClient} args.fs - [required] a file system client\n * @param {string} [args.dir] - [required] The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir,'.git')] - [optional] The [git directory](dir-vs-gitdir.md) path\n * @param {'push' | 'pop' | 'apply' | 'drop' | 'list' | 'clear'} [args.op = 'push'] - [optional] name of stash operation, default to 'push'\n * @param {string} [args.message = ''] - [optional] message to be used for the stash entry, only applicable when op === 'push'\n * @param {number} [args.refIdx = 0] - [optional - Number] stash ref index of entry, only applicable when op === ['apply' | 'drop' | 'pop'], refIdx >= 0 and < num of stash pushed\n * @returns {Promise<string | void>} Resolves successfully when stash operations are complete\n *\n * @example\n * // stash changes in the working directory and index\n * let dir = '/tutorial'\n * await fs.promises.writeFile(`${dir}/a.txt`, 'original content - a')\n * await fs.promises.writeFile(`${dir}/b.js`, 'original content - b')\n * await git.add({ fs, dir, filepath: [`a.txt`,`b.txt`] })\n * let sha = await git.commit({\n * fs,\n * dir,\n * author: {\n * name: 'Mr. Stash',\n * email: 'mstasher@stash.com',\n * },\n * message: 'add a.txt and b.txt to test stash'\n * })\n * console.log(sha)\n *\n * await fs.promises.writeFile(`${dir}/a.txt`, 'stashed chang- a')\n * await git.add({ fs, dir, filepath: `${dir}/a.txt` })\n * await fs.promises.writeFile(`${dir}/b.js`, 'work dir change. not stashed - b')\n *\n * await git.stash({ fs, dir }) // default gitdir and op\n *\n * console.log(await git.status({ fs, dir, filepath: 'a.txt' })) // 'unmodified'\n * console.log(await git.status({ fs, dir, filepath: 'b.txt' })) // 'unmodified'\n *\n * const refLog = await git.stash({ fs, dir, op: 'list' })\n * console.log(refLog) // [{stash{#} message}]\n *\n * await git.stash({ fs, dir, op: 'apply' }) // apply the stash\n *\n * console.log(await git.status({ fs, dir, filepath: 'a.txt' })) // 'modified'\n * console.log(await git.status({ fs, dir, filepath: 'b.txt' })) // '*modified'\n */\n\nasync function stash({\n fs,\n dir,\n gitdir = join(dir, '.git'),\n op = 'push',\n message = '',\n refIdx = 0,\n}) {\n assertParameter('fs', fs);\n assertParameter('dir', dir);\n assertParameter('gitdir', gitdir);\n assertParameter('op', op);\n\n const stashMap = {\n push: _stashPush,\n apply: _stashApply,\n drop: _stashDrop,\n list: _stashList,\n clear: _stashClear,\n pop: _stashPop,\n };\n\n const opsNeedRefIdx = ['apply', 'drop', 'pop'];\n\n try {\n const _fs = new FileSystem(fs);\n const folders = ['refs', 'logs', 'logs/refs'];\n folders\n .map(f => join(gitdir, f))\n .forEach(async folder => {\n if (!(await _fs.exists(folder))) {\n await _fs.mkdir(folder);\n }\n });\n\n const opFunc = stashMap[op];\n if (opFunc) {\n if (opsNeedRefIdx.includes(op) && refIdx < 0) {\n throw new InvalidRefNameError(\n `stash@${refIdx}`,\n 'number that is in range of [0, num of stash pushed]'\n )\n }\n return await opFunc({ fs: _fs, dir, gitdir, message, refIdx })\n }\n throw new Error(`To be implemented: ${op}`)\n } catch (err) {\n err.caller = 'git.stash';\n throw err\n }\n}\n\n// @ts-check\n\n/**\n * Tell whether a file has been changed\n *\n * The possible resolve values are:\n *\n * | status | description |\n * | --------------------- | ------------------------------------------------------------------------------------- |\n * | `\"ignored\"` | file ignored by a .gitignore rule |\n * | `\"unmodified\"` | file unchanged from HEAD commit |\n * | `\"*modified\"` | file has modifications, not yet staged |\n * | `\"*deleted\"` | file has been removed, but the removal is not yet staged |\n * | `\"*added\"` | file is untracked, not yet staged |\n * | `\"absent\"` | file not present in HEAD commit, staging area, or working dir |\n * | `\"modified\"` | file has modifications, staged |\n * | `\"deleted\"` | file has been removed, staged |\n * | `\"added\"` | previously untracked file, staged |\n * | `\"*unmodified\"` | working dir and HEAD commit match, but index differs |\n * | `\"*absent\"` | file not present in working dir or HEAD commit, but present in the index |\n * | `\"*undeleted\"` | file was deleted from the index, but is still in the working dir |\n * | `\"*undeletemodified\"` | file was deleted from the index, but is present with modifications in the working dir |\n *\n * @param {object} args\n * @param {FsClient} args.fs - a file system client\n * @param {string} args.dir - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {string} args.filepath - The path to the file to query\n * @param {object} [args.cache] - a [cache](cache.md) object\n *\n * @returns {Promise<'ignored'|'unmodified'|'*modified'|'*deleted'|'*added'|'absent'|'modified'|'deleted'|'added'|'*unmodified'|'*absent'|'*undeleted'|'*undeletemodified'>} Resolves successfully with the file's git status\n *\n * @example\n * let status = await git.status({ fs, dir: '/tutorial', filepath: 'README.md' })\n * console.log(status)\n *\n */\nasync function status({\n fs: _fs,\n dir,\n gitdir = join(dir, '.git'),\n filepath,\n cache = {},\n}) {\n try {\n assertParameter('fs', _fs);\n assertParameter('gitdir', gitdir);\n assertParameter('filepath', filepath);\n\n const fs = new FileSystem(_fs);\n const ignored = await GitIgnoreManager.isIgnored({\n fs,\n gitdir,\n dir,\n filepath,\n });\n if (ignored) {\n return 'ignored'\n }\n const headTree = await getHeadTree({ fs, cache, gitdir });\n const treeOid = await getOidAtPath({\n fs,\n cache,\n gitdir,\n tree: headTree,\n path: filepath,\n });\n const indexEntry = await GitIndexManager.acquire(\n { fs, gitdir, cache },\n async function(index) {\n for (const entry of index) {\n if (entry.path === filepath) return entry\n }\n return null\n }\n );\n const stats = await fs.lstat(join(dir, filepath));\n\n const H = treeOid !== null; // head\n const I = indexEntry !== null; // index\n const W = stats !== null; // working dir\n\n const getWorkdirOid = async () => {\n if (I && !compareStats(indexEntry, stats)) {\n return indexEntry.oid\n } else {\n const object = await fs.read(join(dir, filepath));\n const workdirOid = await hashObject$1({\n gitdir,\n type: 'blob',\n object,\n });\n // If the oid in the index === working dir oid but stats differed update cache\n if (I && indexEntry.oid === workdirOid) {\n // and as long as our fs.stats aren't bad.\n // size of -1 happens over a BrowserFS HTTP Backend that doesn't serve Content-Length headers\n // (like the Karma webserver) because BrowserFS HTTP Backend uses HTTP HEAD requests to do fs.stat\n if (stats.size !== -1) {\n // We don't await this so we can return faster for one-off cases.\n GitIndexManager.acquire({ fs, gitdir, cache }, async function(\n index\n ) {\n index.insert({ filepath, stats, oid: workdirOid });\n });\n }\n }\n return workdirOid\n }\n };\n\n if (!H && !W && !I) return 'absent' // ---\n if (!H && !W && I) return '*absent' // -A-\n if (!H && W && !I) return '*added' // --A\n if (!H && W && I) {\n const workdirOid = await getWorkdirOid();\n // @ts-ignore\n return workdirOid === indexEntry.oid ? 'added' : '*added' // -AA : -AB\n }\n if (H && !W && !I) return 'deleted' // A--\n if (H && !W && I) {\n // @ts-ignore\n return treeOid === indexEntry.oid ? '*deleted' : '*deleted' // AA- : AB-\n }\n if (H && W && !I) {\n const workdirOid = await getWorkdirOid();\n return workdirOid === treeOid ? '*undeleted' : '*undeletemodified' // A-A : A-B\n }\n if (H && W && I) {\n const workdirOid = await getWorkdirOid();\n if (workdirOid === treeOid) {\n // @ts-ignore\n return workdirOid === indexEntry.oid ? 'unmodified' : '*unmodified' // AAA : ABA\n } else {\n // @ts-ignore\n return workdirOid === indexEntry.oid ? 'modified' : '*modified' // ABB : AAB\n }\n }\n /*\n ---\n -A-\n --A\n -AA\n -AB\n A--\n AA-\n AB-\n A-A\n A-B\n AAA\n ABA\n ABB\n AAB\n */\n } catch (err) {\n err.caller = 'git.status';\n throw err\n }\n}\n\nasync function getOidAtPath({ fs, cache, gitdir, tree, path }) {\n if (typeof path === 'string') path = path.split('/');\n const dirname = path.shift();\n for (const entry of tree) {\n if (entry.path === dirname) {\n if (path.length === 0) {\n return entry.oid\n }\n const { type, object } = await _readObject({\n fs,\n cache,\n gitdir,\n oid: entry.oid,\n });\n if (type === 'tree') {\n const tree = GitTree.from(object);\n return getOidAtPath({ fs, cache, gitdir, tree, path })\n }\n if (type === 'blob') {\n throw new ObjectTypeError(entry.oid, type, 'blob', path.join('/'))\n }\n }\n }\n return null\n}\n\nasync function getHeadTree({ fs, cache, gitdir }) {\n // Get the tree from the HEAD commit.\n let oid;\n try {\n oid = await GitRefManager.resolve({ fs, gitdir, ref: 'HEAD' });\n } catch (e) {\n // Handle fresh branches with no commits\n if (e instanceof NotFoundError) {\n return []\n }\n }\n const { tree } = await _readTree({ fs, cache, gitdir, oid });\n return tree\n}\n\n// @ts-check\n\n/**\n * Efficiently get the status of multiple files at once.\n *\n * The returned `StatusMatrix` is admittedly not the easiest format to read.\n * However it conveys a large amount of information in dense format that should make it easy to create reports about the current state of the repository;\n * without having to do multiple, time-consuming isomorphic-git calls.\n * My hope is that the speed and flexibility of the function will make up for the learning curve of interpreting the return value.\n *\n * ```js live\n * // get the status of all the files in 'src'\n * let status = await git.statusMatrix({\n * fs,\n * dir: '/tutorial',\n * filter: f => f.startsWith('src/')\n * })\n * console.log(status)\n * ```\n *\n * ```js live\n * // get the status of all the JSON and Markdown files\n * let status = await git.statusMatrix({\n * fs,\n * dir: '/tutorial',\n * filter: f => f.endsWith('.json') || f.endsWith('.md')\n * })\n * console.log(status)\n * ```\n *\n * The result is returned as a 2D array.\n * The outer array represents the files and/or blobs in the repo, in alphabetical order.\n * The inner arrays describe the status of the file:\n * the first value is the filepath, and the next three are integers\n * representing the HEAD status, WORKDIR status, and STAGE status of the entry.\n *\n * ```js\n * // example StatusMatrix\n * [\n * [\"a.txt\", 0, 2, 0], // new, untracked\n * [\"b.txt\", 0, 2, 2], // added, staged\n * [\"c.txt\", 0, 2, 3], // added, staged, with unstaged changes\n * [\"d.txt\", 1, 1, 1], // unmodified\n * [\"e.txt\", 1, 2, 1], // modified, unstaged\n * [\"f.txt\", 1, 2, 2], // modified, staged\n * [\"g.txt\", 1, 2, 3], // modified, staged, with unstaged changes\n * [\"h.txt\", 1, 0, 1], // deleted, unstaged\n * [\"i.txt\", 1, 0, 0], // deleted, staged\n * [\"j.txt\", 1, 2, 0], // deleted, staged, with unstaged-modified changes (new file of the same name)\n * [\"k.txt\", 1, 1, 0], // deleted, staged, with unstaged changes (new file of the same name)\n * ]\n * ```\n *\n * - The HEAD status is either absent (0) or present (1).\n * - The WORKDIR status is either absent (0), identical to HEAD (1), or different from HEAD (2).\n * - The STAGE status is either absent (0), identical to HEAD (1), identical to WORKDIR (2), or different from WORKDIR (3).\n *\n * ```ts\n * type Filename = string\n * type HeadStatus = 0 | 1\n * type WorkdirStatus = 0 | 1 | 2\n * type StageStatus = 0 | 1 | 2 | 3\n *\n * type StatusRow = [Filename, HeadStatus, WorkdirStatus, StageStatus]\n *\n * type StatusMatrix = StatusRow[]\n * ```\n *\n * > Think of the natural progression of file modifications as being from HEAD (previous) -> WORKDIR (current) -> STAGE (next).\n * > Then HEAD is \"version 1\", WORKDIR is \"version 2\", and STAGE is \"version 3\".\n * > Then, imagine a \"version 0\" which is before the file was created.\n * > Then the status value in each column corresponds to the oldest version of the file it is identical to.\n * > (For a file to be identical to \"version 0\" means the file is deleted.)\n *\n * Here are some examples of queries you can answer using the result:\n *\n * #### Q: What files have been deleted?\n * ```js\n * const FILE = 0, WORKDIR = 2\n *\n * const filenames = (await statusMatrix({ dir }))\n * .filter(row => row[WORKDIR] === 0)\n * .map(row => row[FILE])\n * ```\n *\n * #### Q: What files have unstaged changes?\n * ```js\n * const FILE = 0, WORKDIR = 2, STAGE = 3\n *\n * const filenames = (await statusMatrix({ dir }))\n * .filter(row => row[WORKDIR] !== row[STAGE])\n * .map(row => row[FILE])\n * ```\n *\n * #### Q: What files have been modified since the last commit?\n * ```js\n * const FILE = 0, HEAD = 1, WORKDIR = 2\n *\n * const filenames = (await statusMatrix({ dir }))\n * .filter(row => row[HEAD] !== row[WORKDIR])\n * .map(row => row[FILE])\n * ```\n *\n * #### Q: What files will NOT be changed if I commit right now?\n * ```js\n * const FILE = 0, HEAD = 1, STAGE = 3\n *\n * const filenames = (await statusMatrix({ dir }))\n * .filter(row => row[HEAD] === row[STAGE])\n * .map(row => row[FILE])\n * ```\n *\n * For reference, here are all possible combinations:\n *\n * | HEAD | WORKDIR | STAGE | `git status --short` equivalent |\n * | ---- | ------- | ----- | ------------------------------- |\n * | 0 | 0 | 0 | `` |\n * | 0 | 0 | 3 | `AD` |\n * | 0 | 2 | 0 | `??` |\n * | 0 | 2 | 2 | `A ` |\n * | 0 | 2 | 3 | `AM` |\n * | 1 | 0 | 0 | `D ` |\n * | 1 | 0 | 1 | ` D` |\n * | 1 | 0 | 3 | `MD` |\n * | 1 | 1 | 0 | `D ` + `??` |\n * | 1 | 1 | 1 | `` |\n * | 1 | 1 | 3 | `MM` |\n * | 1 | 2 | 0 | `D ` + `??` |\n * | 1 | 2 | 1 | ` M` |\n * | 1 | 2 | 2 | `M ` |\n * | 1 | 2 | 3 | `MM` |\n *\n * @param {object} args\n * @param {FsClient} args.fs - a file system client\n * @param {string} args.dir - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {string} [args.ref = 'HEAD'] - Optionally specify a different commit to compare against the workdir and stage instead of the HEAD\n * @param {string[]} [args.filepaths = ['.']] - Limit the query to the given files and directories\n * @param {function(string): boolean} [args.filter] - Filter the results to only those whose filepath matches a function.\n * @param {object} [args.cache] - a [cache](cache.md) object\n * @param {boolean} [args.ignored = false] - include ignored files in the result\n *\n * @returns {Promise<Array<StatusRow>>} Resolves with a status matrix, described below.\n * @see StatusRow\n */\nasync function statusMatrix({\n fs: _fs,\n dir,\n gitdir = join(dir, '.git'),\n ref = 'HEAD',\n filepaths = ['.'],\n filter,\n cache = {},\n ignored: shouldIgnore = false,\n}) {\n try {\n assertParameter('fs', _fs);\n assertParameter('gitdir', gitdir);\n assertParameter('ref', ref);\n\n const fs = new FileSystem(_fs);\n return await _walk({\n fs,\n cache,\n dir,\n gitdir,\n trees: [TREE({ ref }), WORKDIR(), STAGE()],\n map: async function(filepath, [head, workdir, stage]) {\n // Ignore ignored files, but only if they are not already tracked.\n if (!head && !stage && workdir) {\n if (!shouldIgnore) {\n const isIgnored = await GitIgnoreManager.isIgnored({\n fs,\n dir,\n filepath,\n });\n if (isIgnored) {\n return null\n }\n }\n }\n // match against base paths\n if (!filepaths.some(base => worthWalking(filepath, base))) {\n return null\n }\n // Late filter against file names\n if (filter) {\n if (!filter(filepath)) return\n }\n\n const [headType, workdirType, stageType] = await Promise.all([\n head && head.type(),\n workdir && workdir.type(),\n stage && stage.type(),\n ]);\n\n const isBlob = [headType, workdirType, stageType].includes('blob');\n\n // For now, bail on directories unless the file is also a blob in another tree\n if ((headType === 'tree' || headType === 'special') && !isBlob) return\n if (headType === 'commit') return null\n\n if ((workdirType === 'tree' || workdirType === 'special') && !isBlob)\n return\n\n if (stageType === 'commit') return null\n if ((stageType === 'tree' || stageType === 'special') && !isBlob) return\n\n // Figure out the oids for files, using the staged oid for the working dir oid if the stats match.\n const headOid = headType === 'blob' ? await head.oid() : undefined;\n const stageOid = stageType === 'blob' ? await stage.oid() : undefined;\n let workdirOid;\n if (\n headType !== 'blob' &&\n workdirType === 'blob' &&\n stageType !== 'blob'\n ) {\n // We don't actually NEED the sha. Any sha will do\n // TODO: update this logic to handle N trees instead of just 3.\n workdirOid = '42';\n } else if (workdirType === 'blob') {\n workdirOid = await workdir.oid();\n }\n const entry = [undefined, headOid, workdirOid, stageOid];\n const result = entry.map(value => entry.indexOf(value));\n result.shift(); // remove leading undefined entry\n return [filepath, ...result]\n },\n })\n } catch (err) {\n err.caller = 'git.statusMatrix';\n throw err\n }\n}\n\n// @ts-check\n\n/**\n * Create a lightweight tag\n *\n * @param {object} args\n * @param {FsClient} args.fs - a file system client\n * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {string} args.ref - What to name the tag\n * @param {string} [args.object = 'HEAD'] - What oid the tag refers to. (Will resolve to oid if value is a ref.) By default, the commit object which is referred by the current `HEAD` is used.\n * @param {boolean} [args.force = false] - Instead of throwing an error if a tag named `ref` already exists, overwrite the existing tag.\n *\n * @returns {Promise<void>} Resolves successfully when filesystem operations are complete\n *\n * @example\n * await git.tag({ fs, dir: '/tutorial', ref: 'test-tag' })\n * console.log('done')\n *\n */\nasync function tag({\n fs: _fs,\n dir,\n gitdir = join(dir, '.git'),\n ref,\n object,\n force = false,\n}) {\n try {\n assertParameter('fs', _fs);\n assertParameter('gitdir', gitdir);\n assertParameter('ref', ref);\n\n const fs = new FileSystem(_fs);\n\n if (ref === undefined) {\n throw new MissingParameterError('ref')\n }\n\n ref = ref.startsWith('refs/tags/') ? ref : `refs/tags/${ref}`;\n\n // Resolve passed object\n const value = await GitRefManager.resolve({\n fs,\n gitdir,\n ref: object || 'HEAD',\n });\n\n if (!force && (await GitRefManager.exists({ fs, gitdir, ref }))) {\n throw new AlreadyExistsError('tag', ref)\n }\n\n await GitRefManager.writeRef({ fs, gitdir, ref, value });\n } catch (err) {\n err.caller = 'git.tag';\n throw err\n }\n}\n\n// @ts-check\n\n/**\n * Register file contents in the working tree or object database to the git index (aka staging area).\n *\n * @param {object} args\n * @param {FsClient} args.fs - a file system client\n * @param {string} args.dir - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {string} args.filepath - File to act upon.\n * @param {string} [args.oid] - OID of the object in the object database to add to the index with the specified filepath.\n * @param {number} [args.mode = 100644] - The file mode to add the file to the index.\n * @param {boolean} [args.add] - Adds the specified file to the index if it does not yet exist in the index.\n * @param {boolean} [args.remove] - Remove the specified file from the index if it does not exist in the workspace anymore.\n * @param {boolean} [args.force] - Remove the specified file from the index, even if it still exists in the workspace.\n * @param {object} [args.cache] - a [cache](cache.md) object\n *\n * @returns {Promise<string | void>} Resolves successfully with the SHA-1 object id of the object written or updated in the index, or nothing if the file was removed.\n *\n * @example\n * await git.updateIndex({\n * fs,\n * dir: '/tutorial',\n * filepath: 'readme.md'\n * })\n *\n * @example\n * // Manually create a blob in the object database.\n * let oid = await git.writeBlob({\n * fs,\n * dir: '/tutorial',\n * blob: new Uint8Array([])\n * })\n *\n * // Write the object in the object database to the index.\n * await git.updateIndex({\n * fs,\n * dir: '/tutorial',\n * add: true,\n * filepath: 'readme.md',\n * oid\n * })\n */\nasync function updateIndex({\n fs: _fs,\n dir,\n gitdir = join(dir, '.git'),\n cache = {},\n filepath,\n oid,\n mode,\n add,\n remove,\n force,\n}) {\n try {\n assertParameter('fs', _fs);\n assertParameter('gitdir', gitdir);\n assertParameter('filepath', filepath);\n\n const fs = new FileSystem(_fs);\n\n if (remove) {\n return await GitIndexManager.acquire(\n { fs, gitdir, cache },\n async function(index) {\n if (!force) {\n // Check if the file is still present in the working directory\n const fileStats = await fs.lstat(join(dir, filepath));\n\n if (fileStats) {\n if (fileStats.isDirectory()) {\n // Removing directories should not work\n throw new InvalidFilepathError('directory')\n }\n\n // Do nothing if we don't force and the file still exists in the workdir\n return\n }\n }\n\n // Directories are not allowed, so we make sure the provided filepath exists in the index\n if (index.has({ filepath })) {\n index.delete({\n filepath,\n });\n }\n }\n )\n }\n\n // Test if it is a file and exists on disk if `remove` is not provided, only of no oid is provided\n let fileStats;\n\n if (!oid) {\n fileStats = await fs.lstat(join(dir, filepath));\n\n if (!fileStats) {\n throw new NotFoundError(\n `file at \"${filepath}\" on disk and \"remove\" not set`\n )\n }\n\n if (fileStats.isDirectory()) {\n throw new InvalidFilepathError('directory')\n }\n }\n\n return await GitIndexManager.acquire({ fs, gitdir, cache }, async function(\n index\n ) {\n if (!add && !index.has({ filepath })) {\n // If the index does not contain the filepath yet and `add` is not set, we should throw\n throw new NotFoundError(\n `file at \"${filepath}\" in index and \"add\" not set`\n )\n }\n\n let stats;\n if (!oid) {\n stats = fileStats;\n\n // Write the file to the object database\n const object = stats.isSymbolicLink()\n ? await fs.readlink(join(dir, filepath))\n : await fs.read(join(dir, filepath));\n\n oid = await _writeObject({\n fs,\n gitdir,\n type: 'blob',\n format: 'content',\n object,\n });\n } else {\n // By default we use 0 for the stats of the index file\n stats = {\n ctime: new Date(0),\n mtime: new Date(0),\n dev: 0,\n ino: 0,\n mode,\n uid: 0,\n gid: 0,\n size: 0,\n };\n }\n\n index.insert({\n filepath,\n oid: oid,\n stats,\n });\n\n return oid\n })\n } catch (err) {\n err.caller = 'git.updateIndex';\n throw err\n }\n}\n\n// @ts-check\n\n/**\n * Return the version number of isomorphic-git\n *\n * I don't know why you might need this. I added it just so I could check that I was getting\n * the correct version of the library and not a cached version.\n *\n * @returns {string} the version string taken from package.json at publication time\n *\n * @example\n * console.log(git.version())\n *\n */\nfunction version() {\n try {\n return pkg.version\n } catch (err) {\n err.caller = 'git.version';\n throw err\n }\n}\n\n// @ts-check\n\n/**\n * @callback WalkerMap\n * @param {string} filename\n * @param {Array<WalkerEntry | null>} entries\n * @returns {Promise<any>}\n */\n\n/**\n * @callback WalkerReduce\n * @param {any} parent\n * @param {any[]} children\n * @returns {Promise<any>}\n */\n\n/**\n * @callback WalkerIterateCallback\n * @param {WalkerEntry[]} entries\n * @returns {Promise<any[]>}\n */\n\n/**\n * @callback WalkerIterate\n * @param {WalkerIterateCallback} walk\n * @param {IterableIterator<WalkerEntry[]>} children\n * @returns {Promise<any[]>}\n */\n\n/**\n * A powerful recursive tree-walking utility.\n *\n * The `walk` API simplifies gathering detailed information about a tree or comparing all the filepaths in two or more trees.\n * Trees can be git commits, the working directory, or the or git index (staging area).\n * As long as a file or directory is present in at least one of the trees, it will be traversed.\n * Entries are traversed in alphabetical order.\n *\n * The arguments to `walk` are the `trees` you want to traverse, and 3 optional transform functions:\n * `map`, `reduce`, and `iterate`.\n *\n * ## `TREE`, `WORKDIR`, and `STAGE`\n *\n * Tree walkers are represented by three separate functions that can be imported:\n *\n * ```js\n * import { TREE, WORKDIR, STAGE } from 'isomorphic-git'\n * ```\n *\n * These functions return opaque handles called `Walker`s.\n * The only thing that `Walker` objects are good for is passing into `walk`.\n * Here are the three `Walker`s passed into `walk` by the `statusMatrix` command for example:\n *\n * ```js\n * let ref = 'HEAD'\n *\n * let trees = [TREE({ ref }), WORKDIR(), STAGE()]\n * ```\n *\n * For the arguments, see the doc pages for [TREE](./TREE.md), [WORKDIR](./WORKDIR.md), and [STAGE](./STAGE.md).\n *\n * `map`, `reduce`, and `iterate` allow you control the recursive walk by pruning and transforming `WalkerEntry`s into the desired result.\n *\n * ## WalkerEntry\n *\n * {@link WalkerEntry typedef}\n *\n * `map` receives an array of `WalkerEntry[]` as its main argument, one `WalkerEntry` for each `Walker` in the `trees` argument.\n * The methods are memoized per `WalkerEntry` so calling them multiple times in a `map` function does not adversely impact performance.\n * By only computing these values if needed, you build can build lean, mean, efficient walking machines.\n *\n * ### WalkerEntry#type()\n *\n * Returns the kind as a string. This is normally either `tree` or `blob`.\n *\n * `TREE`, `STAGE`, and `WORKDIR` walkers all return a string.\n *\n * Possible values:\n *\n * - `'tree'` directory\n * - `'blob'` file\n * - `'special'` used by `WORKDIR` to represent irregular files like sockets and FIFOs\n * - `'commit'` used by `TREE` to represent submodules\n *\n * ```js\n * await entry.type()\n * ```\n *\n * ### WalkerEntry#mode()\n *\n * Returns the file mode as a number. Use this to distinguish between regular files, symlinks, and executable files.\n *\n * `TREE`, `STAGE`, and `WORKDIR` walkers all return a number for all `type`s of entries.\n *\n * It has been normalized to one of the 4 values that are allowed in git commits:\n *\n * - `0o40000` directory\n * - `0o100644` file\n * - `0o100755` file (executable)\n * - `0o120000` symlink\n *\n * Tip: to make modes more readable, you can print them to octal using `.toString(8)`.\n *\n * ```js\n * await entry.mode()\n * ```\n *\n * ### WalkerEntry#oid()\n *\n * Returns the SHA-1 object id for blobs and trees.\n *\n * `TREE` walkers return a string for `blob` and `tree` entries.\n *\n * `STAGE` and `WORKDIR` walkers return a string for `blob` entries and `undefined` for `tree` entries.\n *\n * ```js\n * await entry.oid()\n * ```\n *\n * ### WalkerEntry#content()\n *\n * Returns the file contents as a Buffer.\n *\n * `TREE` and `WORKDIR` walkers return a Buffer for `blob` entries and `undefined` for `tree` entries.\n *\n * `STAGE` walkers always return `undefined` since the file contents are never stored in the stage.\n *\n * ```js\n * await entry.content()\n * ```\n *\n * ### WalkerEntry#stat()\n *\n * Returns a normalized subset of filesystem Stat data.\n *\n * `WORKDIR` walkers return a `Stat` for `blob` and `tree` entries.\n *\n * `STAGE` walkers return a `Stat` for `blob` entries and `undefined` for `tree` entries.\n *\n * `TREE` walkers return `undefined` for all entry types.\n *\n * ```js\n * await entry.stat()\n * ```\n *\n * {@link Stat typedef}\n *\n * ## map(string, Array<WalkerEntry|null>) => Promise<any>\n *\n * {@link WalkerMap typedef}\n *\n * This is the function that is called once per entry BEFORE visiting the children of that node.\n *\n * If you return `null` for a `tree` entry, then none of the children of that `tree` entry will be walked.\n *\n * This is a good place for query logic, such as examining the contents of a file.\n * Ultimately, compare all the entries and return any values you are interested in.\n * If you do not return a value (or return undefined) that entry will be filtered from the results.\n *\n * Example 1: Find all the files containing the word 'foo'.\n * ```js\n * async function map(filepath, [head, workdir]) {\n * let content = (await workdir.content()).toString('utf8')\n * if (content.contains('foo')) {\n * return {\n * filepath,\n * content\n * }\n * }\n * }\n * ```\n *\n * Example 2: Return the difference between the working directory and the HEAD commit\n * ```js\n * const map = async (filepath, [head, workdir]) => {\n * return {\n * filepath,\n * oid: await head?.oid(),\n * diff: diff(\n * (await head?.content())?.toString('utf8') || '',\n * (await workdir?.content())?.toString('utf8') || ''\n * )\n * }\n * }\n * ```\n *\n * Example 3:\n * ```js\n * let path = require('path')\n * // Only examine files in the directory `cwd`\n * let cwd = 'src/app'\n * async function map (filepath, [head, workdir, stage]) {\n * if (\n * // don't skip the root directory\n * head.fullpath !== '.' &&\n * // return true for 'src' and 'src/app'\n * !cwd.startsWith(filepath) &&\n * // return true for 'src/app/*'\n * path.dirname(filepath) !== cwd\n * ) {\n * return null\n * } else {\n * return filepath\n * }\n * }\n * ```\n *\n * ## reduce(parent, children)\n *\n * {@link WalkerReduce typedef}\n *\n * This is the function that is called once per entry AFTER visiting the children of that node.\n *\n * Default: `async (parent, children) => parent === undefined ? children.flat() : [parent, children].flat()`\n *\n * The default implementation of this function returns all directories and children in a giant flat array.\n * You can define a different accumulation method though.\n *\n * Example: Return a hierarchical structure\n * ```js\n * async function reduce (parent, children) {\n * return Object.assign(parent, { children })\n * }\n * ```\n *\n * ## iterate(walk, children)\n *\n * {@link WalkerIterate typedef}\n *\n * {@link WalkerIterateCallback typedef}\n *\n * Default: `(walk, children) => Promise.all([...children].map(walk))`\n *\n * The default implementation recurses all children concurrently using Promise.all.\n * However you could use a custom function to traverse children serially or use a global queue to throttle recursion.\n *\n * @param {object} args\n * @param {FsClient} args.fs - a file system client\n * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {Walker[]} args.trees - The trees you want to traverse\n * @param {WalkerMap} [args.map] - Transform `WalkerEntry`s into a result form\n * @param {WalkerReduce} [args.reduce] - Control how mapped entries are combined with their parent result\n * @param {WalkerIterate} [args.iterate] - Fine-tune how entries within a tree are iterated over\n * @param {object} [args.cache] - a [cache](cache.md) object\n *\n * @returns {Promise<any>} The finished tree-walking result\n */\nasync function walk({\n fs,\n dir,\n gitdir = join(dir, '.git'),\n trees,\n map,\n reduce,\n iterate,\n cache = {},\n}) {\n try {\n assertParameter('fs', fs);\n assertParameter('gitdir', gitdir);\n assertParameter('trees', trees);\n\n return await _walk({\n fs: new FileSystem(fs),\n cache,\n dir,\n gitdir,\n trees,\n map,\n reduce,\n iterate,\n })\n } catch (err) {\n err.caller = 'git.walk';\n throw err\n }\n}\n\n// @ts-check\n\n/**\n * Write a blob object directly\n *\n * @param {object} args\n * @param {FsClient} args.fs - a file system client\n * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {Uint8Array} args.blob - The blob object to write\n *\n * @returns {Promise<string>} Resolves successfully with the SHA-1 object id of the newly written object\n *\n * @example\n * // Manually create a blob.\n * let oid = await git.writeBlob({\n * fs,\n * dir: '/tutorial',\n * blob: new Uint8Array([])\n * })\n *\n * console.log('oid', oid) // should be 'e69de29bb2d1d6434b8b29ae775ad8c2e48c5391'\n *\n */\nasync function writeBlob({ fs, dir, gitdir = join(dir, '.git'), blob }) {\n try {\n assertParameter('fs', fs);\n assertParameter('gitdir', gitdir);\n assertParameter('blob', blob);\n\n return await _writeObject({\n fs: new FileSystem(fs),\n gitdir,\n type: 'blob',\n object: blob,\n format: 'content',\n })\n } catch (err) {\n err.caller = 'git.writeBlob';\n throw err\n }\n}\n\n// @ts-check\n\n/**\n * Write a commit object directly\n *\n * @param {object} args\n * @param {FsClient} args.fs - a file system client\n * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {CommitObject} args.commit - The object to write\n *\n * @returns {Promise<string>} Resolves successfully with the SHA-1 object id of the newly written object\n * @see CommitObject\n *\n */\nasync function writeCommit({\n fs,\n dir,\n gitdir = join(dir, '.git'),\n commit,\n}) {\n try {\n assertParameter('fs', fs);\n assertParameter('gitdir', gitdir);\n assertParameter('commit', commit);\n\n return await _writeCommit({\n fs: new FileSystem(fs),\n gitdir,\n commit,\n })\n } catch (err) {\n err.caller = 'git.writeCommit';\n throw err\n }\n}\n\n// @ts-check\n\n/**\n * Write a git object directly\n *\n * `format` can have the following values:\n *\n * | param | description |\n * | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n * | 'deflated' | Treat `object` as the raw deflate-compressed buffer for an object, meaning can be written to `.git/objects/**` as-is. |\n * | 'wrapped' | Treat `object` as the inflated object buffer wrapped in the git object header. This is the raw buffer used when calculating the SHA-1 object id of a git object. |\n * | 'content' | Treat `object` as the object buffer without the git header. |\n * | 'parsed' | Treat `object` as a parsed representation of the object. |\n *\n * If `format` is `'parsed'`, then `object` must match one of the schemas for `CommitObject`, `TreeObject`, `TagObject`, or a `string` (for blobs).\n *\n * {@link CommitObject typedef}\n *\n * {@link TreeObject typedef}\n *\n * {@link TagObject typedef}\n *\n * If `format` is `'content'`, `'wrapped'`, or `'deflated'`, `object` should be a `Uint8Array`.\n *\n * @deprecated\n * > This command is overly complicated.\n * >\n * > If you know the type of object you are writing, use [`writeBlob`](./writeBlob.md), [`writeCommit`](./writeCommit.md), [`writeTag`](./writeTag.md), or [`writeTree`](./writeTree.md).\n *\n * @param {object} args\n * @param {FsClient} args.fs - a file system client\n * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {string | Uint8Array | CommitObject | TreeObject | TagObject} args.object - The object to write.\n * @param {'blob'|'tree'|'commit'|'tag'} [args.type] - The kind of object to write.\n * @param {'deflated' | 'wrapped' | 'content' | 'parsed'} [args.format = 'parsed'] - What format the object is in. The possible choices are listed below.\n * @param {string} [args.oid] - If `format` is `'deflated'` then this param is required. Otherwise it is calculated.\n * @param {string} [args.encoding] - If `type` is `'blob'` then `object` will be converted to a Uint8Array using `encoding`.\n *\n * @returns {Promise<string>} Resolves successfully with the SHA-1 object id of the newly written object.\n *\n * @example\n * // Manually create an annotated tag.\n * let sha = await git.resolveRef({ fs, dir: '/tutorial', ref: 'HEAD' })\n * console.log('commit', sha)\n *\n * let oid = await git.writeObject({\n * fs,\n * dir: '/tutorial',\n * type: 'tag',\n * object: {\n * object: sha,\n * type: 'commit',\n * tag: 'my-tag',\n * tagger: {\n * name: 'your name',\n * email: 'email@example.com',\n * timestamp: Math.floor(Date.now()/1000),\n * timezoneOffset: new Date().getTimezoneOffset()\n * },\n * message: 'Optional message'\n * }\n * })\n *\n * console.log('tag', oid)\n *\n */\nasync function writeObject({\n fs: _fs,\n dir,\n gitdir = join(dir, '.git'),\n type,\n object,\n format = 'parsed',\n oid,\n encoding = undefined,\n}) {\n try {\n const fs = new FileSystem(_fs);\n // Convert object to buffer\n if (format === 'parsed') {\n switch (type) {\n case 'commit':\n object = GitCommit.from(object).toObject();\n break\n case 'tree':\n object = GitTree.from(object).toObject();\n break\n case 'blob':\n object = Buffer.from(object, encoding);\n break\n case 'tag':\n object = GitAnnotatedTag.from(object).toObject();\n break\n default:\n throw new ObjectTypeError(oid || '', type, 'blob|commit|tag|tree')\n }\n // GitObjectManager does not know how to serialize content, so we tweak that parameter before passing it.\n format = 'content';\n }\n oid = await _writeObject({\n fs,\n gitdir,\n type,\n object,\n oid,\n format,\n });\n return oid\n } catch (err) {\n err.caller = 'git.writeObject';\n throw err\n }\n}\n\n// @ts-check\n\n/**\n * Write a ref which refers to the specified SHA-1 object id, or a symbolic ref which refers to the specified ref.\n *\n * @param {object} args\n * @param {FsClient} args.fs - a file system client\n * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {string} args.ref - The name of the ref to write\n * @param {string} args.value - When `symbolic` is false, a ref or an SHA-1 object id. When true, a ref starting with `refs/`.\n * @param {boolean} [args.force = false] - Instead of throwing an error if a ref named `ref` already exists, overwrite the existing ref.\n * @param {boolean} [args.symbolic = false] - Whether the ref is symbolic or not.\n *\n * @returns {Promise<void>} Resolves successfully when filesystem operations are complete\n *\n * @example\n * await git.writeRef({\n * fs,\n * dir: '/tutorial',\n * ref: 'refs/heads/another-branch',\n * value: 'HEAD'\n * })\n * await git.writeRef({\n * fs,\n * dir: '/tutorial',\n * ref: 'HEAD',\n * value: 'refs/heads/another-branch',\n * force: true,\n * symbolic: true\n * })\n * console.log('done')\n *\n */\nasync function writeRef({\n fs: _fs,\n dir,\n gitdir = join(dir, '.git'),\n ref,\n value,\n force = false,\n symbolic = false,\n}) {\n try {\n assertParameter('fs', _fs);\n assertParameter('gitdir', gitdir);\n assertParameter('ref', ref);\n assertParameter('value', value);\n\n const fs = new FileSystem(_fs);\n\n if (ref !== cleanGitRef.clean(ref)) {\n throw new InvalidRefNameError(ref, cleanGitRef.clean(ref))\n }\n\n if (!force && (await GitRefManager.exists({ fs, gitdir, ref }))) {\n throw new AlreadyExistsError('ref', ref)\n }\n\n if (symbolic) {\n await GitRefManager.writeSymbolicRef({\n fs,\n gitdir,\n ref,\n value,\n });\n } else {\n value = await GitRefManager.resolve({\n fs,\n gitdir,\n ref: value,\n });\n await GitRefManager.writeRef({\n fs,\n gitdir,\n ref,\n value,\n });\n }\n } catch (err) {\n err.caller = 'git.writeRef';\n throw err\n }\n}\n\n// @ts-check\n\n/**\n * @param {object} args\n * @param {import('../models/FileSystem.js').FileSystem} args.fs\n * @param {string} args.gitdir\n * @param {TagObject} args.tag\n *\n * @returns {Promise<string>}\n */\nasync function _writeTag({ fs, gitdir, tag }) {\n // Convert object to buffer\n const object = GitAnnotatedTag.from(tag).toObject();\n const oid = await _writeObject({\n fs,\n gitdir,\n type: 'tag',\n object,\n format: 'content',\n });\n return oid\n}\n\n// @ts-check\n\n/**\n * Write an annotated tag object directly\n *\n * @param {object} args\n * @param {FsClient} args.fs - a file system client\n * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {TagObject} args.tag - The object to write\n *\n * @returns {Promise<string>} Resolves successfully with the SHA-1 object id of the newly written object\n * @see TagObject\n *\n * @example\n * // Manually create an annotated tag.\n * let sha = await git.resolveRef({ fs, dir: '/tutorial', ref: 'HEAD' })\n * console.log('commit', sha)\n *\n * let oid = await git.writeTag({\n * fs,\n * dir: '/tutorial',\n * tag: {\n * object: sha,\n * type: 'commit',\n * tag: 'my-tag',\n * tagger: {\n * name: 'your name',\n * email: 'email@example.com',\n * timestamp: Math.floor(Date.now()/1000),\n * timezoneOffset: new Date().getTimezoneOffset()\n * },\n * message: 'Optional message'\n * }\n * })\n *\n * console.log('tag', oid)\n *\n */\nasync function writeTag({ fs, dir, gitdir = join(dir, '.git'), tag }) {\n try {\n assertParameter('fs', fs);\n assertParameter('gitdir', gitdir);\n assertParameter('tag', tag);\n\n return await _writeTag({\n fs: new FileSystem(fs),\n gitdir,\n tag,\n })\n } catch (err) {\n err.caller = 'git.writeTag';\n throw err\n }\n}\n\n// @ts-check\n\n/**\n * Write a tree object directly\n *\n * @param {object} args\n * @param {FsClient} args.fs - a file system client\n * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path\n * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path\n * @param {TreeObject} args.tree - The object to write\n *\n * @returns {Promise<string>} Resolves successfully with the SHA-1 object id of the newly written object.\n * @see TreeObject\n * @see TreeEntry\n *\n */\nasync function writeTree({ fs, dir, gitdir = join(dir, '.git'), tree }) {\n try {\n assertParameter('fs', fs);\n assertParameter('gitdir', gitdir);\n assertParameter('tree', tree);\n\n return await _writeTree({\n fs: new FileSystem(fs),\n gitdir,\n tree,\n })\n } catch (err) {\n err.caller = 'git.writeTree';\n throw err\n }\n}\n\n// default export\nvar index = {\n Errors,\n STAGE,\n TREE,\n WORKDIR,\n add,\n abortMerge,\n addNote,\n addRemote,\n annotatedTag,\n branch,\n checkout,\n clone,\n commit,\n getConfig,\n getConfigAll,\n setConfig,\n currentBranch,\n deleteBranch,\n deleteRef,\n deleteRemote,\n deleteTag,\n expandOid,\n expandRef,\n fastForward,\n fetch,\n findMergeBase,\n findRoot,\n getRemoteInfo,\n getRemoteInfo2,\n hashBlob,\n indexPack,\n init,\n isDescendent,\n isIgnored,\n listBranches,\n listFiles,\n listNotes,\n listRefs,\n listRemotes,\n listServerRefs,\n listTags,\n log,\n merge,\n packObjects,\n pull,\n push,\n readBlob,\n readCommit,\n readNote,\n readObject,\n readTag,\n readTree,\n remove,\n removeNote,\n renameBranch,\n resetIndex,\n updateIndex,\n resolveRef,\n status,\n statusMatrix,\n tag,\n version,\n walk,\n writeBlob,\n writeCommit,\n writeObject,\n writeRef,\n writeTag,\n writeTree,\n stash,\n};\n\nexport default index;\nexport { Errors, STAGE, TREE, WORKDIR, abortMerge, add, addNote, addRemote, annotatedTag, branch, checkout, clone, commit, currentBranch, deleteBranch, deleteRef, deleteRemote, deleteTag, expandOid, expandRef, fastForward, fetch, findMergeBase, findRoot, getConfig, getConfigAll, getRemoteInfo, getRemoteInfo2, hashBlob, indexPack, init, isDescendent, isIgnored, listBranches, listFiles, listNotes, listRefs, listRemotes, listServerRefs, listTags, log, merge, packObjects, pull, push, readBlob, readCommit, readNote, readObject, readTag, readTree, remove, removeNote, renameBranch, resetIndex, resolveRef, setConfig, stash, status, statusMatrix, tag, updateIndex, version, walk, writeBlob, writeCommit, writeObject, writeRef, writeTag, writeTree };\n"],"names":["AsyncLock","opts","this","Promise","queues","Object","create","domainReentrant","process","domain","Error","domains","timeout","DEFAULT_TIMEOUT","maxOccupationTime","DEFAULT_MAX_OCCUPATION_TIME","maxExecutionTime","DEFAULT_MAX_EXECUTION_TIME","maxPending","Infinity","Number","isInteger","DEFAULT_MAX_PENDING","prototype","acquire","key","fn","cb","Array","isArray","_acquireBatch","deferredResolve","deferredReject","deferred","resolve","reject","resolved","timer","occupationTimer","executionTimer","self","done","locked","err","ret","clearTimeout","length","shift","exec","setTimeout","called","_promiseTry","then","undefined","error","bind","taskFn","skipQueue","unshift","push","keys","fnx","reduceRight","prev","getFn","isBusy","e","asyncLock","Buffer","require$$0","safeBuffer","Hash","blockSize","finalSize","_block","alloc","_finalSize","_blockSize","_len","update","data","enc","from","block","accum","offset","assigned","remainder","Math","min","i","_update","digest","rem","fill","bits","writeUInt32BE","lowBits","highBits","hash","_hash","toString","K","W","Sha1","init","_w","call","rotl1","num","rotl5","rotl30","ft","s","b","c","d","inherits","_a","_b","_c","_d","_e","M","a","readInt32BE","j","t","H","allocUnsafe","writeInt32BE","sha1","assertPath","path","TypeError","JSON","stringify","normalizeStringPosix","allowAboveRoot","code","res","lastSegmentLength","lastSlash","dots","charCodeAt","lastSlashIndex","lastIndexOf","slice","posix","cwd","resolvedPath","resolvedAbsolute","arguments","normalize","isAbsolute","trailingSeparator","join","joined","arg","relative","to","fromStart","fromEnd","fromLen","toStart","toLen","lastCommonSep","fromCode","out","_makeLong","dirname","hasRoot","end","matchedSlash","basename","ext","start","extIdx","firstNonSlashEnd","extname","startDot","startPart","preDotState","format","pathObject","sep","dir","root","base","name","_format","parse","delimiter","win32","pathBrowserify","factory","DO_NOT_EXPORT_CRC","exports","CRC32","version","T","table","n","Int32Array","signed_crc_table","bstr","seed","C","L","buf","crc32_buf_8","str","TYPED_OK","Uint8Array","Uint16Array","_has","obj","hasOwnProperty","assign","sources","source","p","shrinkBuf","size","subarray","fnTyped","arraySet","dest","src","src_offs","len","dest_offs","set","flattenChunks","chunks","l","pos","chunk","result","fnUntyped","concat","apply","setTyped","on","Buf8","Buf16","Buf32","zero","LITERALS","L_CODES","D_CODES","MAX_BITS","extra_lbits","extra_dbits","extra_blbits","bl_order","static_ltree","static_dtree","_dist_code","_length_code","MAX_MATCH","base_length","static_l_desc","static_d_desc","static_bl_desc","base_dist","StaticTreeDesc","static_tree","extra_bits","extra_base","elems","max_length","has_stree","TreeDesc","dyn_tree","stat_desc","max_code","d_code","dist","put_short","w","pending_buf","pending","send_bits","value","bi_valid","bi_buf","send_code","tree","bi_reverse","gen_codes","bl_count","next_code","init_block","dyn_ltree","dyn_dtree","bl_tree","END_BLOCK","opt_len","static_len","last_lit","matches","bi_windup","smaller","m","depth","_n2","_m2","pqdownheap","k","v","heap","heap_len","compress_block","ltree","dtree","lc","extra","lx","d_buf","l_buf","build_tree","desc","node","stree","heap_max","h","xbits","f","overflow","gen_bitlen","scan_tree","curlen","prevlen","nextlen","count","max_count","min_count","REP_3_6","REPZ_3_10","REPZ_11_138","send_tree","static_init_done","_tr_stored_block","stored_len","last","header","utils","window","copy_block","_tr_flush_block_1","opt_lenb","static_lenb","max_blindex","level","strm","data_type","black_mask","detect_data_type","l_desc","d_desc","bl_desc","BL_CODES","build_bl_tree","strategy","lcodes","dcodes","blcodes","rank","send_all_trees","LENGTH_CODES","tr_static_init","lit_bufsize","STATIC_TREES","bi_flush","adler32_1","adler","s1","s2","crcTable","makeTable","configuration_table","crc32_1","crc","messages","Z_STREAM_ERROR","MIN_LOOKAHEAD","HCRC_STATE","BUSY_STATE","FINISH_STATE","errorCode","msg","flush_pending","state","avail_out","output","pending_out","next_out","total_out","flush_block_only","trees","_tr_flush_block","block_start","strstart","put_byte","putShortMSB","longest_match","cur_match","match","chain_length","max_chain_length","scan","best_len","prev_length","nice_match","limit","w_size","_win","wmask","w_mask","strend","scan_end1","scan_end","good_match","lookahead","match_start","fill_window","more","_w_size","window_size","hash_size","head","avail_in","input","next_in","wrap","adler32","crc32","total_in","insert","ins_h","hash_shift","hash_mask","deflate_fast","flush","hash_head","bflush","match_length","_tr_tally","max_lazy_match","MIN_MATCH","deflate_slow","max_insert","prev_match","match_available","Config","good_length","max_lazy","nice_length","max_chain","func","DeflateState","status","pending_buf_size","gzhead","gzindex","method","last_flush","w_bits","hash_bits","HEAP_SIZE","deflateResetKeep","_tr_init","deflateReset","deflateInit2","windowBits","memLevel","max_block_size","max_start","deflateEnd_1","old_flush","beg","val","text","hcrc","comment","time","os","bstate","deflate_huff","deflate_rle","_tr_align","dictionary","avail","next","tmpDict","dictLength","STR_APPLY_OK","STR_APPLY_UIA_OK","String","fromCharCode","__","_utf8len","q","buf2binstring","c2","m_pos","str_len","buf_len","max","c_len","utf16buf","zstream","Deflate","options","chunkSize","opt","raw","gzip","ended","ZStream","zlib_deflate","deflateSetHeader","dict","strings","deflateSetDictionary","_dict_set","deflate","deflator","mode","_mode","onEnd","onData","deflateEnd","inffast","_in","_out","dmax","wsize","whave","wnext","s_window","hold","lcode","dcode","lmask","dmask","here","op","from_source","lencode","distcode","lenbits","distbits","top","dolen","sane","MAXBITS","lbase","lext","dbase","dext","inftrees","type","lens","lens_index","codes","table_index","work","incr","low","mask","here_bits","here_op","here_val","sym","curr","drop","left","used","huff","base_index","offs","extra_index","TYPE","BAD","zswap32","InflateState","havedict","flags","check","total","wbits","ncode","nlen","ndist","have","lendyn","distdyn","back","was","inflateResetKeep","inflateReset","inflateReset2","inflateInit2","lenfix","distfix","virgin","fixedtables","inflate_table","updatewindow","copy","put","last_bits","last_op","last_val","hbuf","order","inf_leave","xflags","extra_len","inflate_fast","constants","Z_NO_FLUSH","Z_PARTIAL_FLUSH","Z_SYNC_FLUSH","Z_FULL_FLUSH","Z_FINISH","Z_BLOCK","Z_TREES","Z_OK","Z_STREAM_END","Z_NEED_DICT","Z_ERRNO","Z_DATA_ERROR","Z_BUF_ERROR","Z_NO_COMPRESSION","Z_BEST_SPEED","Z_BEST_COMPRESSION","Z_DEFAULT_COMPRESSION","Z_FILTERED","Z_HUFFMAN_ONLY","Z_RLE","Z_FIXED","Z_DEFAULT_STRATEGY","Z_BINARY","Z_TEXT","Z_UNKNOWN","Z_DEFLATED","gzheader","Inflate","zlib_inflate","GZheader","inflateGetHeader","inflateSetDictionary","inflate","inflator","next_out_utf8","tail","utf8str","allowBufError","inflateEnd","pako","pako_1","processFn","args","P","promiseModule","multiArgs","errorFirst","pify","exclude","objType","filter","pattern","test","include","some","excludeMain","getPrototypeOf","property","makeArray","subject","REGEX_TEST_BLANK_LINE","REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION","REGEX_REPLACE_LEADING_EXCAPED_HASH","REGEX_SPLITALL_CRLF","REGEX_TEST_INVALID_PATH","KEY_IGNORE","Symbol","for","REGEX_REGEXP_RANGE","REPLACERS","indexOf","_","index","p1","leadEscape","range","endEscape","close","slashes","cleanRangeBackSlash","replace","sanitizeRange","regexCache","isString","IgnoreRule","constructor","origin","negative","regex","createRule","ignorecase","substr","r","reduce","current","RegExp","makeRegex","throwError","message","Ctor","checkPath","originalPath","doThrow","isNotRelative","RangeError","convert","Ignore","object","_rules","_ignorecase","defineProperty","_initCache","_ignoreCache","_testCache","_addPattern","_added","checkPattern","rule","add","split","splitPattern","forEach","addPattern","_testOne","checkUnignored","ignored","unignored","_test","cache","slices","_t","pop","parent","ignores","createFilter","paths","returnFalse","isPathValid","default","ignore","env","IGNORE_TEST_WIN32","platform","makePosix","REGIX_IS_WINDOWS_PATH_ABSOLUTE","replaceAll","search","replacement","lib","clean","onp","a_","b_","tmp1","tmp2","reverse","ed","pathposi","ses","lcs","x","y","seselem","elem","snake","pp","SES_DELETE","SES_COMMON","SES_ADD","editdistance","getlcs","getses","compose","delta","fp","epc","px_idx","py_idx","recordseq","diffIndices","file1","file2","tail1","tail2","candidate","diff","file1RevIdx","file2RevIdx","chain","file1index","file2index","longestCommonSubsequence","mismatchLength1","mismatchLength2","diff3","o","files","indices","m1","m2","hunks","addHunk","side","sort","commonOffset","copyCommon","targetOffset","hunkIndex","firstHunkIndex","hunk","regionLhs","regionRhs","maybeOverlapping","maybeLhs","regions","oLhs","oRhs","abLhs","abRhs","aLhs","aRhs","bLhs","bRhs","diff3MergeIndices","okLines","flushOk","ok","pushOk","xs","isTrueConflict","rec","aoff","boff","conflict","aIndex","oIndex","bIndex","BaseError","super","caller","toJSON","stack","fromJSON","json","isIsomorphicGitError","UnmergedPathsError","filepaths","InternalError","UnsafeFilepathError","filepath","BufferCursor","buffer","_start","eof","tell","seek","write","readUInt8","writeUInt8","readUInt16BE","writeUInt16BE","readUInt32BE","compareStrings","comparePath","normalizeMode","permissions","MAX_UINT32","SecondsNanoseconds","givenSeconds","givenNanoseconds","milliseconds","date","valueOf","seconds","floor","normalizeStats","ctimeSeconds","ctimeNanoseconds","ctimeMs","ctime","mtimeSeconds","mtimeNanoseconds","mtimeMs","mtime","dev","ino","uid","gid","supportsSubtleSHA1","async","shasum","subtleSHA1","testSubtleSHA1","shasumSync","hex","byte","toHex","crypto","subtle","GitIndex","entries","unmergedPaths","_dirty","_unmergedPaths","Set","_entries","Map","_addEntry","entry","stage","stages","delete","existingEntry","get","isBuffer","fromBuffer","reader","magic","shaComputed","shaClaimed","numEntries","oid","assumeValid","Boolean","extended","nameLength","pathlength","includes","padding","tmp","values","entriesMap","entriesFlat","flatMap","iterator","stats","bfilepath","has","startsWith","clear","render","map","_entryToBuffer","bpath","ceil","written","writer","stat","renderCacheEntryFlags","toObject","entryBuffers","all","body","main","sum","compareStats","filemode","trustino","lock","IndexCache","GitIndexManager","fs","gitdir","allowUnmerged","closure","theIndexCache","savedStats","currStats","lstat","isIndexStale","rawIndexFile","read","updateCachedIndexFile","flatFileListToDirectoryStructure","inodes","mkdir","fullpath","metadata","children","mkfile","file","GitWalkerIndex","treePromise","walker","ConstructEntry","_fullpath","_type","_stat","_oid","content","readdir","inode","names","mode2type","_entry","GitWalkSymbol","STAGE","freeze","NotFoundError","what","ObjectTypeError","actual","expected","InvalidOidError","NoRefspecError","remote","GitPackedRefs","refs","parsedConfig","trim","line","ref","peeled","GitRefSpec","remotePath","localPath","force","matchPrefix","refspec","forceMatch","remoteGlobMatch","localGlobMatch","remoteIsGlob","translate","remoteBranch","reverseTranslate","localBranch","GitRefSpecSet","rules","refspecs","remoteRefs","remoteRef","localRef","translateOne","localNamespaces","compareRefNames","endsWith","bool","toLowerCase","schema","core","bare","logallrefupdates","symlinks","bigFileThreshold","parseInt","SECTION_LINE_REGEX","SECTION_REGEX","VARIABLE_LINE_REGEX","VARIABLE_NAME_REGEX","VARIABLE_VALUE_COMMENT_REGEX","removeComments","rawValue","commentMatches","valueWithoutComment","hasOddNumberOfQuotes","removeQuotes","newText","idx","isQuote","isEscapeForQuote","lower","getPath","section","subsection","normalizePath","pathSegments","sectionPath","isSection","GitConfig","trimmedLine","extractedSection","extractSectionLine","extractedVariable","valueWithoutComments","extractVariableLine","getall","normalizedPath","allValues","config","getSubsections","deleteSection","append","configIndex","array","callback","lastIndex","item","splice","modifiedConfig","modified","sectionIndex","findIndex","newConfig","newSection","GitConfigManager","encoding","save","refpaths","GIT_FILES","lock$1","acquireLock","GitRefManager","updateRemoteRefs","symrefs","tags","prune","pruneTags","actualRefsToWrite","listRefs","deleteRefs","tag","serverRef","exists","refTranslations","translatedRef","symrefTranslations","symtarget","pruned","writeRef","writeSymbolicRef","deleteRef","rm","packed","beforeSize","packedMap","packedRefs","allpaths","sha","expand","expandAgainstMap","resolveAgainstMap","fullref","readdirDeep","listBranches","listTags","compareTreeEntryPath","appendSlashIfDir","mode2type$1","nudgeIntoShape","limitModeToAllowed","GitTree","cursor","space","nullchar","parseBuffer","GitObject","byteLength","unwrap","actualLength","readObjectLoose","readVarIntLE","readCompactLE","readOp","getIterator","iterable","asyncIterator","queue","return","fromValue","StreamReader","stream","undoCursor","started","_ended","_discardedBytes","_init","_loadnext","_moveCursor","_trim","_accumulate","skip","undo","_next","buffers","lengthBuffers","nextbuffer","acc","parseHeader","ofs","reference","bytes","GitPackIndex","stuff","offsetCache","fromIdx","getExternalRefDelta","hashes","offsets","packfileSha","crcs","fromPack","pack","onProgress","listpackTypes","offsetToObject","totalObjectCount","lastPercent","PACK","numObjects","listpack","percent","phase","loaded","offsetArray","objectsByDepth","readDepth","externalReadDepth","readSlice","toBuffer","fanoutBuffer","crcsBuffer","offsetsBuffer","totalBuffer","shaBuffer","load","unload","btype","lastFour","startWith","otherVarIntDecode","multibyte","lastSeven","decodeVarInt","baseOffset","sourceSize","targetSize","target","firstOp","applyDelta","PackfileCache","readPackIndex","filename","emitter","emitterPrefix","loadPackIndex","_readObject","list","indexFile","packFile","readObjectPacked","AlreadyExistsError","noun","where","canForce","AmbiguousError","nouns","short","CheckoutConflictError","CommitNotFetchedError","EmptyServerResponseError","FastForwardError","GitPushError","prettyDetails","HttpError","statusCode","statusMessage","response","InvalidFilepathError","reason","InvalidRefNameError","suggestion","MaxDepthError","MergeNotSupportedError","MergeConflictError","bothModified","deleteByUs","deleteByTheirs","MissingNameError","role","MissingParameterError","parameter","MultipleGitError","errors","ParseError","PushRejectedError","RemoteCapabilityError","capability","SmartHttpError","preview","UnknownTransportError","url","transport","UrlParseError","UserCanceledError","IndexResetError","NoCommitError","Errors","__proto__","formatAuthor","email","timestamp","timezoneOffset","minutes","sign","is","simpleSign","abs","hours","strHours","strMinutes","formatTimezoneOffset","normalizeNewlines","parseAuthor","author","parseTimezoneOffset","GitAnnotatedTag","_tag","tagger","gpgsig","justHeaders","withoutSignature","headers","hs","committer","payload","secretKey","signature","signedTag","indent","GitCommit","commit","_commit","fromPayloadSignature","justMessage","parseHeaders","renderHeaders","isolateSignature","signedCommit","resolveTree","GitWalkerRepo","mapPromise","_content","TREE","GitWalkerFs","isDirectory","isFile","isSymbolicLink","_actualSize","_getGitConfig","autocrlf","WORKDIR","flat","RunningMinimum","consider","reset","unionOfIterators","sets","minimum","heads","numsets","_walk","flatten","iterate","walk","walkers","proxy","arrayRange","iterators","unionWalkerFromReaddir","find","walkedChildren","rmRecursive","subpath","rmdir","isFunction","isPromiseFs","isObject","targetFs","readFile","catch","commands","bindFs","command","_rm","FileSystem","_original_unwrapped_fs","promises","getOwnPropertyDescriptor","enumerable","console","log","_readFile","TextDecoder","fatal","decode","TextEncoder","encode","contents","_writeFile","_selfCall","_mkdir","_unlink","recursive","_rmdir","_readdir","subdirs","subdir","_lstat","readlink","link","_readlink","writelink","_symlink","assertParameter","abortMerge","_fs","results","workdir","staged","unmerged","unmodified","GitIgnoreManager","isIgnored","excludes","excludesFile","pairs","gitignore","pieces","folder","ignoredStatus","ign","parentdir","supportsCompressionStream","CompressionStream","writable","Blob","cancel","testCompressionStream","cs","pipeThrough","Response","arrayBuffer","browserDeflate","_writeObject","dryRun","writeObjectLoose","posixifyPathBuffer","parallel","addToIndex","currentFilepath","child","settledPromises","allSettled","rejectedPromises","settle","_getConfig","assignDefined","normalizeAuthorObject","Date","now","normalizedAuthor","getTimezoneOffset","normalizeCommitterObject","normalizedCommitter","resolveCommit","_readCommit","commitOid","onSign","_author","_committer","signingKey","amend","noUpdateBranch","refOid","refCommit","initialCommit","constructTree","comm","resolveFilepath","pathArray","_resolveFilepath","_readTree","treeOid","_writeTree","addNote","note","noteOid","_addNote","_addRemote","cleanGitRef","addRemote","annotatedTag","_tagger","tagObject","_annotatedTag","branch","checkout","_branch","worthWalking","_checkout","onPostCheckout","noCheckout","noUpdateHead","track","oldOid","ops","analyze","conflicts","previousHead","newHead","chmod","fullRef","_ref","abbreviateRx","abbreviateRef","_currentBranch","fullname","calculateBasicAuthHeader","username","password","forAwait","iter","collect","nextIndex","extractAuthFromUrl","userpass","auth","padHex","repeat","GitPktLine","delim","hexlength","streamReader","parseCapabilitiesV2","capabilities2","protocolVersion","parseRefsAdResponse","service","capabilities","lineOne","lineTwo","firstRef","capabilitiesLine","splitAndAssert","cap","corsProxify","corsProxy","updateHeaders","Authorization","stringifyBody","GitRemoteHTTP","discover","http","onAuth","onAuthSuccess","onAuthFailure","_origUrl","proxifiedURL","tryAgain","providedAuthBefore","request","getAuth","remoteHTTP","connect","urlAuth","accept","GitRemoteManager","getRemoteHelperFor","remoteHelpers","parts","address","parseRemoteUrl","translateSSHtoHTTP","lock$2","GitShallowManager","oids","hasObject","hasObjectLoose","hasObjectPacked","filterCapabilities","server","client","serverNames","pkg","FIFO","_queue","_waiting","destroy","findSplit","splitLines","GitSideBand","demux","packetlines","packfile","progress","nextBit","_fetch","onMessage","_remoteRef","_remote","_url","since","singleBranch","defaultBranch","fetchHead","fetchHeadDescription","wants","haveRefs","haves","packstream","shallows","firstLineCapabilities","writeUploadPackRequest","packbuffer","unshallows","acks","nak","finally","parseUploadPackResponse","hasParents","every","bail","realRef","HEAD","FETCH_HEAD","description","pheader","folders","clone","noTags","maxRetries","_clone","currentBranch","deleteBranch","abbrevRef","_deleteBranch","deleteRemote","_deleteRemote","deleteTag","_deleteTag","_expandOid","prefix","suffix","expandOidLoose","packedOids","expandOidPacked","packedOid","expandOid","expandRef","_findMergeBase","visits","passes","newheads","LINEBREAKS","mergeFile","branches","ourName","theirName","baseContent","ourContent","theirContent","ours","theirs","diff3Merge","mergedText","cleanMerge","mergeTree","ourOid","baseOid","theirOid","baseName","abortOnConflict","mergeDriver","ourTree","baseTree","theirTree","unmergedFiles","mergeResult","mergeBlobs","_merge","fastForward","fastForwardOnly","baseOids","alreadyMerged","mergeCommit","_pull","thisWillNotBeUsed","fetch","findMergeBase","_findRoot","findRoot","getConfig","getConfigAll","_getConfigAll","getRemoteInfo","forPush","part","symref","formatInfoRefs","peelTags","_key","getRemoteInfo2","hashBlob","_object","hashObject","indexPack","_indexPack","_isDescendent","ancestor","visited","searchdepth","isDescendent","_listFiles","filenames","accumulateFilesFromOid","listFiles","listNotes","_listNotes","listRemotes","remoteNames","_listRemotes","listServerRefs","writeListRefsRequest","attrs","attr","parseListRefsResponse","compareAge","resolveFileIdInTree","fileId","_resolveFileId","parentPath","walks","follow","sinceTimestamp","commits","shallowCommits","tips","lastFileOid","lastCommit","isOk","endCommit","vFileOid","found","lastFound","_log","merge","types","blob","ofs_delta","ref_delta","_pack","outputStream","buff","writeObject","stype","packObjects","_packObjects","pull","listObjects","_push","onPrePush","_delete","httpRemote","fullRemoteRef","oldoid","thinPack","objects","finish","skipObjects","mergebase","startingSet","finishingSet","parents","listCommitsAndTags","packstream1","triplets","capsFirstLine","trip","writeReceivePackRequest","packstream2","lines","refAndMessage","parseReceivePackResponse","resolveBlob","_readBlob","readBlob","readCommit","readNote","_readNote","readObject","readTag","_readTag","readTree","remove","removeNote","_removeNote","renameBranch","oldref","fulloldref","fullnewref","fullCurrentBranchRef","_renameBranch","hashObject$1","resetIndex","workdirOid","resolveRef","setConfig","_writeCommit","GitRefStash","timezoneOffsetForRefLogEntry","offsetMinutes","offsetHours","offsetMinutesFormatted","padStart","createStashReflogEntry","stashCommit","nameNoSpace","getStashReflogEntry","reflogString","parsed","_TreeMap","lock$3","acquireLock$1","processTreeEntries","processTreeEntry","objContent","retOid","checkAndWriteBlob","writeTreeChanges","treePair","isStage","changedEntries","filtered","treeEntries","applyTreeChanges","parentCommit","wasStaged","dirRemoved","stageUpdated","stash","removedDir","GitStashManager","refStash","refLogsStash","refStashPath","refLogsStashPath","getAuthor","getStashSHA","refIdx","stashEntries","readStashReflogs","writeStashCommit","readStashCommit","stashSHA","writeStashRef","writeStashReflogEntry","appendTo","_stashPush","stashMgr","headCommit","headMsg","stashCommitParents","stashCommitTree","workDirCompareBase","indexTree","stashCommitOne","toISOString","workingTree","workingHeadCommit","stashMsg","substring","_stashApply","stashParents","_stashDrop","stashRefPath","reflogEntries","stashReflogPath","lastStashCommit","_stashList","_stashClear","_stashPop","stashMap","opsNeedRefIdx","opFunc","headTree","getHeadTree","getOidAtPath","indexEntry","I","getWorkdirOid","statusMatrix","shouldIgnore","headType","workdirType","stageType","isBlob","headOid","stageOid","updateIndex","fileStats","writeBlob","writeCommit","symbolic","writeTag","_writeTag","writeTree"],"mappings":"oKAEA,IAAIA,EAAY,SAAUC,GAWzB,GAVAA,EAAOA,GAAQ,GAEfC,KAAKC,QAAUF,EAAKE,SAAWA,QAI/BD,KAAKE,OAASC,OAAOC,OAAO,MAG5BJ,KAAKK,gBAAkBN,EAAKM,kBAAmB,EAC3CL,KAAKK,gBAAiB,CACzB,GAAuB,oBAAZC,cAAqD,IAAnBA,QAAQC,OACpD,M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