@corellium/corellium-cli 1.4.0 → 1.5.0

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 (614) hide show
  1. package/.eslintrc.js +12 -16
  2. package/.gitlab-ci.yml +13 -13
  3. package/.nvmrc +1 -1
  4. package/.nycrc +14 -14
  5. package/.prettierrc.js +8 -7
  6. package/README.md +13 -6
  7. package/docs/OVERVIEW.md +57 -27
  8. package/index.js +8 -8
  9. package/lint-staged.config.js +3 -6
  10. package/node_modules/@babel/cli/README.md +1 -1
  11. package/node_modules/@babel/cli/bin/babel-external-helpers.mjs +3 -0
  12. package/node_modules/@babel/cli/bin/babel.mjs +3 -0
  13. package/node_modules/@babel/cli/lib/babel/dir.js +23 -73
  14. package/node_modules/@babel/cli/lib/babel/dir.js.map +1 -0
  15. package/node_modules/@babel/cli/lib/babel/file.js +27 -72
  16. package/node_modules/@babel/cli/lib/babel/file.js.map +1 -0
  17. package/node_modules/@babel/cli/lib/babel/index.js +6 -8
  18. package/node_modules/@babel/cli/lib/babel/index.js.map +1 -0
  19. package/node_modules/@babel/cli/lib/babel/options.js +70 -143
  20. package/node_modules/@babel/cli/lib/babel/options.js.map +1 -0
  21. package/node_modules/@babel/cli/lib/babel/util.js +39 -59
  22. package/node_modules/@babel/cli/lib/babel/util.js.map +1 -0
  23. package/node_modules/@babel/cli/lib/babel/watcher.js +19 -52
  24. package/node_modules/@babel/cli/lib/babel/watcher.js.map +1 -0
  25. package/node_modules/@babel/cli/lib/babel-external-helpers.js +14 -21
  26. package/node_modules/@babel/cli/lib/babel-external-helpers.js.map +1 -0
  27. package/node_modules/@babel/cli/package.json +11 -9
  28. package/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.mjs +19 -29
  29. package/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.mjs.map +1 -1
  30. package/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.umd.js +19 -29
  31. package/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.umd.js.map +1 -1
  32. package/node_modules/@jridgewell/resolve-uri/package.json +2 -2
  33. package/node_modules/@jridgewell/sourcemap-codec/README.md +147 -83
  34. package/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs +351 -91
  35. package/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs.map +1 -1
  36. package/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.umd.js +354 -90
  37. package/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.umd.js.map +1 -1
  38. package/node_modules/@jridgewell/sourcemap-codec/dist/types/scopes.d.ts +49 -0
  39. package/node_modules/@jridgewell/sourcemap-codec/dist/types/sourcemap-codec.d.ts +2 -0
  40. package/node_modules/@jridgewell/sourcemap-codec/dist/types/strings.d.ts +15 -0
  41. package/node_modules/@jridgewell/sourcemap-codec/dist/types/vlq.d.ts +6 -0
  42. package/node_modules/@jridgewell/sourcemap-codec/package.json +7 -7
  43. package/node_modules/@jridgewell/trace-mapping/README.md +5 -0
  44. package/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs +202 -174
  45. package/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs.map +1 -1
  46. package/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.umd.js +216 -182
  47. package/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.umd.js.map +1 -1
  48. package/node_modules/@jridgewell/trace-mapping/dist/types/any-map.d.ts +1 -1
  49. package/node_modules/@jridgewell/trace-mapping/dist/types/binary-search.d.ts +1 -1
  50. package/node_modules/@jridgewell/trace-mapping/dist/types/by-source.d.ts +1 -1
  51. package/node_modules/@jridgewell/trace-mapping/dist/types/sourcemap-segment.d.ts +8 -8
  52. package/node_modules/@jridgewell/trace-mapping/dist/types/trace-mapping.d.ts +33 -28
  53. package/node_modules/@jridgewell/trace-mapping/dist/types/types.d.ts +23 -16
  54. package/node_modules/@jridgewell/trace-mapping/package.json +20 -18
  55. package/node_modules/anymatch/index.d.ts +1 -0
  56. package/node_modules/anymatch/index.js +1 -1
  57. package/node_modules/anymatch/package.json +1 -1
  58. package/node_modules/{form-data/README.md.bak → axios/node_modules/form-data/Readme.md} +4 -4
  59. package/node_modules/{superagent → axios}/node_modules/form-data/lib/form_data.js +8 -5
  60. package/node_modules/{superagent → axios}/node_modules/form-data/package.json +9 -6
  61. package/node_modules/binary-extensions/binary-extensions.json +3 -0
  62. package/node_modules/binary-extensions/license +2 -1
  63. package/node_modules/binary-extensions/package.json +4 -2
  64. package/node_modules/binary-extensions/readme.md +2 -18
  65. package/node_modules/braces/LICENSE +1 -1
  66. package/node_modules/braces/README.md +91 -98
  67. package/node_modules/braces/index.js +3 -3
  68. package/node_modules/braces/lib/compile.js +14 -11
  69. package/node_modules/braces/lib/constants.js +1 -1
  70. package/node_modules/braces/lib/expand.js +9 -9
  71. package/node_modules/braces/lib/parse.js +14 -16
  72. package/node_modules/braces/lib/stringify.js +4 -4
  73. package/node_modules/braces/lib/utils.js +13 -3
  74. package/node_modules/braces/package.json +2 -2
  75. package/node_modules/{call-bind → call-bind-apply-helpers}/.eslintrc +0 -1
  76. package/node_modules/call-bind-apply-helpers/.github/FUNDING.yml +12 -0
  77. package/node_modules/call-bind-apply-helpers/.nycrc +9 -0
  78. package/node_modules/call-bind-apply-helpers/CHANGELOG.md +23 -0
  79. package/node_modules/{call-bind → call-bind-apply-helpers}/LICENSE +1 -1
  80. package/node_modules/call-bind-apply-helpers/README.md +62 -0
  81. package/node_modules/call-bind-apply-helpers/actualApply.d.ts +1 -0
  82. package/node_modules/call-bind-apply-helpers/actualApply.js +10 -0
  83. package/node_modules/call-bind-apply-helpers/applyBind.d.ts +19 -0
  84. package/node_modules/call-bind-apply-helpers/applyBind.js +10 -0
  85. package/node_modules/call-bind-apply-helpers/functionApply.d.ts +1 -0
  86. package/node_modules/call-bind-apply-helpers/functionApply.js +4 -0
  87. package/node_modules/call-bind-apply-helpers/functionCall.d.ts +1 -0
  88. package/node_modules/call-bind-apply-helpers/functionCall.js +4 -0
  89. package/node_modules/call-bind-apply-helpers/index.d.ts +46 -0
  90. package/node_modules/call-bind-apply-helpers/index.js +15 -0
  91. package/node_modules/call-bind-apply-helpers/package.json +85 -0
  92. package/node_modules/call-bind-apply-helpers/reflectApply.d.ts +3 -0
  93. package/node_modules/call-bind-apply-helpers/reflectApply.js +4 -0
  94. package/node_modules/call-bind-apply-helpers/test/index.js +63 -0
  95. package/node_modules/call-bind-apply-helpers/tsconfig.json +9 -0
  96. package/node_modules/call-bound/.eslintrc +13 -0
  97. package/node_modules/call-bound/.github/FUNDING.yml +12 -0
  98. package/node_modules/call-bound/.nycrc +9 -0
  99. package/node_modules/call-bound/CHANGELOG.md +34 -0
  100. package/node_modules/call-bound/LICENSE +21 -0
  101. package/node_modules/call-bound/README.md +53 -0
  102. package/node_modules/call-bound/index.d.ts +13 -0
  103. package/node_modules/call-bound/index.js +18 -0
  104. package/node_modules/call-bound/package.json +99 -0
  105. package/node_modules/{call-bind/test/callBound.js → call-bound/test/index.js} +1 -2
  106. package/node_modules/call-bound/tsconfig.json +9 -0
  107. package/node_modules/chokidar/README.md +1 -1
  108. package/node_modules/chokidar/index.js +1 -1
  109. package/node_modules/chokidar/lib/constants.js +1 -0
  110. package/node_modules/chokidar/lib/fsevents-handler.js +2 -0
  111. package/node_modules/chokidar/package.json +5 -20
  112. package/node_modules/chokidar/types/index.d.ts +4 -0
  113. package/node_modules/cliui/CHANGELOG.md +18 -0
  114. package/node_modules/cliui/build/index.d.cts +43 -0
  115. package/node_modules/cliui/package.json +6 -6
  116. package/node_modules/commander/CHANGELOG.md +361 -0
  117. package/node_modules/{@babel/cli/node_modules/commander → commander}/Readme.md +243 -165
  118. package/node_modules/commander/index.js +1881 -0
  119. package/node_modules/{@babel/cli/node_modules/commander → commander}/package.json +19 -9
  120. package/node_modules/commander/typings/index.d.ts +410 -0
  121. package/node_modules/component-emitter/LICENSE +24 -24
  122. package/node_modules/component-emitter/Readme.md +74 -74
  123. package/node_modules/component-emitter/index.js +175 -175
  124. package/node_modules/component-emitter/package.json +3 -2
  125. package/node_modules/convert-source-map/README.md +97 -11
  126. package/node_modules/convert-source-map/index.js +127 -30
  127. package/node_modules/convert-source-map/package.json +3 -9
  128. package/node_modules/cookiejar/cookiejar.js +5 -0
  129. package/node_modules/cookiejar/package.json +1 -1
  130. package/node_modules/debug/README.md +1 -1
  131. package/node_modules/debug/package.json +10 -4
  132. package/node_modules/debug/src/browser.js +4 -1
  133. package/node_modules/debug/src/common.js +57 -39
  134. package/node_modules/debug/src/node.js +2 -2
  135. package/node_modules/dotenv/CHANGELOG.md +133 -1
  136. package/node_modules/dotenv/README-es.md +448 -0
  137. package/node_modules/dotenv/README.md +309 -66
  138. package/node_modules/dotenv/lib/cli-options.js +1 -1
  139. package/node_modules/dotenv/lib/env-options.js +4 -0
  140. package/node_modules/dotenv/lib/main.d.ts +85 -5
  141. package/node_modules/dotenv/lib/main.js +287 -35
  142. package/node_modules/dotenv/package.json +19 -14
  143. package/node_modules/dunder-proto/.eslintrc +5 -0
  144. package/node_modules/dunder-proto/.github/FUNDING.yml +12 -0
  145. package/node_modules/dunder-proto/CHANGELOG.md +24 -0
  146. package/node_modules/dunder-proto/LICENSE +21 -0
  147. package/node_modules/dunder-proto/README.md +54 -0
  148. package/node_modules/dunder-proto/get.d.ts +5 -0
  149. package/node_modules/dunder-proto/get.js +30 -0
  150. package/node_modules/dunder-proto/package.json +76 -0
  151. package/node_modules/dunder-proto/set.d.ts +5 -0
  152. package/node_modules/dunder-proto/set.js +35 -0
  153. package/node_modules/dunder-proto/test/get.js +34 -0
  154. package/node_modules/dunder-proto/test/index.js +4 -0
  155. package/node_modules/dunder-proto/test/set.js +50 -0
  156. package/node_modules/dunder-proto/tsconfig.json +9 -0
  157. package/node_modules/es-define-property/.eslintrc +13 -0
  158. package/node_modules/es-define-property/.github/FUNDING.yml +12 -0
  159. package/node_modules/es-define-property/.nycrc +9 -0
  160. package/node_modules/es-define-property/CHANGELOG.md +29 -0
  161. package/node_modules/es-define-property/LICENSE +21 -0
  162. package/node_modules/es-define-property/README.md +49 -0
  163. package/node_modules/es-define-property/index.d.ts +3 -0
  164. package/node_modules/es-define-property/index.js +14 -0
  165. package/node_modules/es-define-property/package.json +81 -0
  166. package/node_modules/es-define-property/test/index.js +56 -0
  167. package/node_modules/es-define-property/tsconfig.json +10 -0
  168. package/node_modules/es-errors/.eslintrc +5 -0
  169. package/node_modules/es-errors/.github/FUNDING.yml +12 -0
  170. package/node_modules/es-errors/CHANGELOG.md +40 -0
  171. package/node_modules/es-errors/LICENSE +21 -0
  172. package/node_modules/es-errors/README.md +55 -0
  173. package/node_modules/es-errors/eval.d.ts +3 -0
  174. package/node_modules/es-errors/eval.js +4 -0
  175. package/node_modules/es-errors/index.d.ts +3 -0
  176. package/node_modules/es-errors/index.js +4 -0
  177. package/node_modules/es-errors/package.json +80 -0
  178. package/node_modules/es-errors/range.d.ts +3 -0
  179. package/node_modules/es-errors/range.js +4 -0
  180. package/node_modules/es-errors/ref.d.ts +3 -0
  181. package/node_modules/es-errors/ref.js +4 -0
  182. package/node_modules/es-errors/syntax.d.ts +3 -0
  183. package/node_modules/es-errors/syntax.js +4 -0
  184. package/node_modules/es-errors/test/index.js +19 -0
  185. package/node_modules/es-errors/tsconfig.json +49 -0
  186. package/node_modules/es-errors/type.d.ts +3 -0
  187. package/node_modules/es-errors/type.js +4 -0
  188. package/node_modules/es-errors/uri.d.ts +3 -0
  189. package/node_modules/es-errors/uri.js +4 -0
  190. package/node_modules/es-object-atoms/.eslintrc +16 -0
  191. package/node_modules/es-object-atoms/.github/FUNDING.yml +12 -0
  192. package/node_modules/es-object-atoms/CHANGELOG.md +37 -0
  193. package/node_modules/es-object-atoms/LICENSE +21 -0
  194. package/node_modules/es-object-atoms/README.md +63 -0
  195. package/node_modules/es-object-atoms/RequireObjectCoercible.d.ts +3 -0
  196. package/node_modules/es-object-atoms/RequireObjectCoercible.js +11 -0
  197. package/node_modules/es-object-atoms/ToObject.d.ts +7 -0
  198. package/node_modules/es-object-atoms/ToObject.js +10 -0
  199. package/node_modules/es-object-atoms/index.d.ts +3 -0
  200. package/node_modules/es-object-atoms/index.js +4 -0
  201. package/node_modules/es-object-atoms/isObject.d.ts +3 -0
  202. package/node_modules/es-object-atoms/isObject.js +6 -0
  203. package/node_modules/es-object-atoms/package.json +80 -0
  204. package/node_modules/es-object-atoms/test/index.js +38 -0
  205. package/node_modules/es-object-atoms/tsconfig.json +6 -0
  206. package/node_modules/escalade/index.d.mts +11 -0
  207. package/node_modules/escalade/index.d.ts +14 -2
  208. package/node_modules/escalade/package.json +18 -5
  209. package/node_modules/escalade/readme.md +1 -1
  210. package/node_modules/escalade/sync/index.d.mts +9 -0
  211. package/node_modules/escalade/sync/index.d.ts +13 -2
  212. package/node_modules/fill-range/index.js +4 -5
  213. package/node_modules/fill-range/package.json +8 -3
  214. package/node_modules/follow-redirects/index.js +186 -98
  215. package/node_modules/follow-redirects/package.json +3 -4
  216. package/node_modules/form-data/Readme.md +5 -7
  217. package/node_modules/form-data/lib/form_data.js +5 -8
  218. package/node_modules/form-data/package.json +9 -6
  219. package/node_modules/function-bind/.eslintrc +11 -5
  220. package/node_modules/function-bind/.github/FUNDING.yml +12 -0
  221. package/node_modules/function-bind/.github/SECURITY.md +3 -0
  222. package/node_modules/function-bind/.nycrc +13 -0
  223. package/node_modules/function-bind/CHANGELOG.md +136 -0
  224. package/node_modules/function-bind/README.md +25 -27
  225. package/node_modules/function-bind/implementation.js +44 -12
  226. package/node_modules/function-bind/package.json +38 -14
  227. package/node_modules/get-intrinsic/.eslintrc +1 -0
  228. package/node_modules/get-intrinsic/CHANGELOG.md +87 -0
  229. package/node_modules/get-intrinsic/index.js +75 -32
  230. package/node_modules/get-intrinsic/package.json +31 -22
  231. package/node_modules/get-intrinsic/test/GetIntrinsic.js +3 -3
  232. package/node_modules/get-proto/.eslintrc +10 -0
  233. package/node_modules/{call-bind → get-proto}/.github/FUNDING.yml +1 -1
  234. package/node_modules/get-proto/.nycrc +9 -0
  235. package/node_modules/get-proto/CHANGELOG.md +21 -0
  236. package/node_modules/get-proto/LICENSE +21 -0
  237. package/node_modules/get-proto/Object.getPrototypeOf.d.ts +5 -0
  238. package/node_modules/get-proto/Object.getPrototypeOf.js +6 -0
  239. package/node_modules/get-proto/README.md +50 -0
  240. package/node_modules/get-proto/Reflect.getPrototypeOf.d.ts +3 -0
  241. package/node_modules/get-proto/Reflect.getPrototypeOf.js +4 -0
  242. package/node_modules/get-proto/index.d.ts +5 -0
  243. package/node_modules/get-proto/index.js +27 -0
  244. package/node_modules/get-proto/package.json +81 -0
  245. package/node_modules/get-proto/test/index.js +68 -0
  246. package/node_modules/get-proto/tsconfig.json +9 -0
  247. package/node_modules/gopd/.eslintrc +16 -0
  248. package/node_modules/gopd/.github/FUNDING.yml +12 -0
  249. package/node_modules/gopd/CHANGELOG.md +45 -0
  250. package/node_modules/gopd/LICENSE +21 -0
  251. package/node_modules/gopd/README.md +40 -0
  252. package/node_modules/gopd/gOPD.d.ts +1 -0
  253. package/node_modules/gopd/gOPD.js +4 -0
  254. package/node_modules/gopd/index.d.ts +5 -0
  255. package/node_modules/gopd/index.js +15 -0
  256. package/node_modules/gopd/package.json +77 -0
  257. package/node_modules/gopd/test/index.js +36 -0
  258. package/node_modules/gopd/tsconfig.json +9 -0
  259. package/node_modules/has-symbols/CHANGELOG.md +16 -0
  260. package/node_modules/has-symbols/index.d.ts +3 -0
  261. package/node_modules/has-symbols/index.js +1 -0
  262. package/node_modules/has-symbols/package.json +19 -9
  263. package/node_modules/has-symbols/shams.d.ts +3 -0
  264. package/node_modules/has-symbols/shams.js +5 -2
  265. package/node_modules/has-symbols/test/shams/core-js.js +1 -0
  266. package/node_modules/has-symbols/test/shams/get-own-property-symbols.js +1 -0
  267. package/node_modules/has-symbols/test/tests.js +4 -2
  268. package/node_modules/has-symbols/tsconfig.json +10 -0
  269. package/node_modules/hasown/.eslintrc +5 -0
  270. package/node_modules/hasown/.github/FUNDING.yml +12 -0
  271. package/node_modules/hasown/.nycrc +13 -0
  272. package/node_modules/hasown/CHANGELOG.md +40 -0
  273. package/node_modules/hasown/LICENSE +21 -0
  274. package/node_modules/hasown/README.md +40 -0
  275. package/node_modules/hasown/index.d.ts +3 -0
  276. package/node_modules/hasown/index.js +8 -0
  277. package/node_modules/hasown/package.json +92 -0
  278. package/node_modules/hasown/tsconfig.json +6 -0
  279. package/node_modules/make-dir/node_modules/semver/package.json +38 -0
  280. package/node_modules/{@babel/cli → make-dir}/node_modules/semver/semver.js +68 -26
  281. package/node_modules/math-intrinsics/.eslintrc +16 -0
  282. package/node_modules/math-intrinsics/.github/FUNDING.yml +12 -0
  283. package/node_modules/math-intrinsics/CHANGELOG.md +24 -0
  284. package/node_modules/math-intrinsics/LICENSE +21 -0
  285. package/node_modules/math-intrinsics/README.md +50 -0
  286. package/node_modules/math-intrinsics/abs.d.ts +1 -0
  287. package/node_modules/math-intrinsics/abs.js +4 -0
  288. package/node_modules/math-intrinsics/constants/maxArrayLength.d.ts +3 -0
  289. package/node_modules/math-intrinsics/constants/maxArrayLength.js +4 -0
  290. package/node_modules/math-intrinsics/constants/maxSafeInteger.d.ts +3 -0
  291. package/node_modules/math-intrinsics/constants/maxSafeInteger.js +5 -0
  292. package/node_modules/math-intrinsics/constants/maxValue.d.ts +3 -0
  293. package/node_modules/math-intrinsics/constants/maxValue.js +5 -0
  294. package/node_modules/math-intrinsics/floor.d.ts +1 -0
  295. package/node_modules/math-intrinsics/floor.js +4 -0
  296. package/node_modules/math-intrinsics/isFinite.d.ts +3 -0
  297. package/node_modules/math-intrinsics/isFinite.js +12 -0
  298. package/node_modules/math-intrinsics/isInteger.d.ts +3 -0
  299. package/node_modules/math-intrinsics/isInteger.js +16 -0
  300. package/node_modules/math-intrinsics/isNaN.d.ts +1 -0
  301. package/node_modules/math-intrinsics/isNaN.js +6 -0
  302. package/node_modules/math-intrinsics/isNegativeZero.d.ts +3 -0
  303. package/node_modules/math-intrinsics/isNegativeZero.js +6 -0
  304. package/node_modules/math-intrinsics/max.d.ts +1 -0
  305. package/node_modules/math-intrinsics/max.js +4 -0
  306. package/node_modules/math-intrinsics/min.d.ts +1 -0
  307. package/node_modules/math-intrinsics/min.js +4 -0
  308. package/node_modules/math-intrinsics/mod.d.ts +3 -0
  309. package/node_modules/math-intrinsics/mod.js +9 -0
  310. package/node_modules/math-intrinsics/package.json +86 -0
  311. package/node_modules/math-intrinsics/pow.d.ts +1 -0
  312. package/node_modules/math-intrinsics/pow.js +4 -0
  313. package/node_modules/math-intrinsics/round.d.ts +1 -0
  314. package/node_modules/math-intrinsics/round.js +4 -0
  315. package/node_modules/math-intrinsics/sign.d.ts +3 -0
  316. package/node_modules/math-intrinsics/sign.js +11 -0
  317. package/node_modules/math-intrinsics/test/index.js +192 -0
  318. package/node_modules/math-intrinsics/tsconfig.json +3 -0
  319. package/node_modules/ms/index.js +1 -1
  320. package/node_modules/ms/license.md +1 -1
  321. package/node_modules/ms/package.json +5 -4
  322. package/node_modules/ms/readme.md +1 -2
  323. package/node_modules/object-inspect/CHANGELOG.md +56 -0
  324. package/node_modules/object-inspect/index.js +38 -9
  325. package/node_modules/object-inspect/package.json +23 -13
  326. package/node_modules/object-inspect/readme.markdown +9 -11
  327. package/node_modules/object-inspect/test/global.js +17 -0
  328. package/node_modules/object-inspect/test/quoteStyle.js +9 -0
  329. package/node_modules/qs/.editorconfig +3 -0
  330. package/node_modules/qs/.eslintrc +3 -2
  331. package/node_modules/qs/CHANGELOG.md +81 -5
  332. package/node_modules/qs/README.md +158 -50
  333. package/node_modules/qs/dist/qs.js +90 -2003
  334. package/node_modules/qs/lib/parse.js +89 -24
  335. package/node_modules/qs/lib/stringify.js +61 -31
  336. package/node_modules/qs/lib/utils.js +54 -38
  337. package/node_modules/qs/package.json +29 -13
  338. package/node_modules/qs/test/empty-keys-cases.js +267 -0
  339. package/node_modules/qs/test/parse.js +468 -47
  340. package/node_modules/qs/test/stringify.js +454 -57
  341. package/node_modules/qs/test/utils.js +126 -0
  342. package/node_modules/side-channel/.editorconfig +9 -0
  343. package/node_modules/side-channel/.eslintrc +2 -1
  344. package/node_modules/side-channel/CHANGELOG.md +45 -0
  345. package/node_modules/side-channel/README.md +60 -1
  346. package/node_modules/side-channel/index.d.ts +14 -0
  347. package/node_modules/side-channel/index.js +21 -102
  348. package/node_modules/side-channel/package.json +40 -22
  349. package/node_modules/side-channel/test/index.js +78 -52
  350. package/node_modules/side-channel/tsconfig.json +9 -0
  351. package/node_modules/{function-bind → side-channel-list}/.editorconfig +3 -14
  352. package/node_modules/side-channel-list/.eslintrc +11 -0
  353. package/node_modules/side-channel-list/.github/FUNDING.yml +12 -0
  354. package/node_modules/side-channel-list/.nycrc +13 -0
  355. package/node_modules/side-channel-list/CHANGELOG.md +15 -0
  356. package/node_modules/side-channel-list/LICENSE +21 -0
  357. package/node_modules/side-channel-list/README.md +62 -0
  358. package/node_modules/side-channel-list/index.d.ts +13 -0
  359. package/node_modules/side-channel-list/index.js +113 -0
  360. package/node_modules/side-channel-list/list.d.ts +14 -0
  361. package/node_modules/side-channel-list/package.json +77 -0
  362. package/node_modules/side-channel-list/test/index.js +104 -0
  363. package/node_modules/side-channel-list/tsconfig.json +9 -0
  364. package/node_modules/side-channel-map/.editorconfig +9 -0
  365. package/node_modules/side-channel-map/.eslintrc +11 -0
  366. package/node_modules/side-channel-map/.github/FUNDING.yml +12 -0
  367. package/node_modules/side-channel-map/.nycrc +13 -0
  368. package/node_modules/side-channel-map/CHANGELOG.md +22 -0
  369. package/node_modules/side-channel-map/LICENSE +21 -0
  370. package/node_modules/side-channel-map/README.md +62 -0
  371. package/node_modules/side-channel-map/index.d.ts +15 -0
  372. package/node_modules/side-channel-map/index.js +68 -0
  373. package/node_modules/side-channel-map/package.json +80 -0
  374. package/node_modules/side-channel-map/test/index.js +114 -0
  375. package/node_modules/side-channel-map/tsconfig.json +9 -0
  376. package/node_modules/side-channel-weakmap/.editorconfig +9 -0
  377. package/node_modules/side-channel-weakmap/.eslintrc +12 -0
  378. package/node_modules/side-channel-weakmap/.github/FUNDING.yml +12 -0
  379. package/node_modules/side-channel-weakmap/.nycrc +13 -0
  380. package/node_modules/side-channel-weakmap/CHANGELOG.md +28 -0
  381. package/node_modules/side-channel-weakmap/LICENSE +21 -0
  382. package/node_modules/side-channel-weakmap/README.md +62 -0
  383. package/node_modules/side-channel-weakmap/index.d.ts +15 -0
  384. package/node_modules/side-channel-weakmap/index.js +84 -0
  385. package/node_modules/side-channel-weakmap/package.json +87 -0
  386. package/node_modules/side-channel-weakmap/test/index.js +114 -0
  387. package/node_modules/side-channel-weakmap/tsconfig.json +9 -0
  388. package/node_modules/superagent/node_modules/readable-stream/README.md +1 -1
  389. package/node_modules/superagent/node_modules/readable-stream/lib/_stream_duplex.js +12 -25
  390. package/node_modules/superagent/node_modules/readable-stream/lib/_stream_passthrough.js +2 -4
  391. package/node_modules/superagent/node_modules/readable-stream/lib/_stream_readable.js +176 -273
  392. package/node_modules/superagent/node_modules/readable-stream/lib/_stream_transform.js +26 -37
  393. package/node_modules/superagent/node_modules/readable-stream/lib/_stream_writable.js +118 -174
  394. package/node_modules/superagent/node_modules/readable-stream/lib/internal/streams/async_iterator.js +10 -37
  395. package/node_modules/superagent/node_modules/readable-stream/lib/internal/streams/buffer_list.js +20 -47
  396. package/node_modules/superagent/node_modules/readable-stream/lib/internal/streams/destroy.js +8 -17
  397. package/node_modules/superagent/node_modules/readable-stream/lib/internal/streams/end-of-stream.js +1 -19
  398. package/node_modules/superagent/node_modules/readable-stream/lib/internal/streams/from.js +12 -24
  399. package/node_modules/superagent/node_modules/readable-stream/lib/internal/streams/pipeline.js +5 -16
  400. package/node_modules/superagent/node_modules/readable-stream/lib/internal/streams/state.js +2 -7
  401. package/node_modules/superagent/node_modules/readable-stream/package.json +1 -1
  402. package/node_modules/{semver → superagent/node_modules/semver}/README.md +132 -36
  403. package/node_modules/{semver → superagent/node_modules/semver}/bin/semver.js +22 -16
  404. package/node_modules/{semver → superagent/node_modules/semver}/classes/comparator.js +39 -34
  405. package/node_modules/{semver → superagent/node_modules/semver}/classes/range.js +72 -37
  406. package/node_modules/{semver → superagent/node_modules/semver}/classes/semver.js +49 -19
  407. package/node_modules/{semver → superagent/node_modules/semver}/functions/coerce.js +14 -6
  408. package/node_modules/superagent/node_modules/semver/functions/diff.js +58 -0
  409. package/node_modules/{semver → superagent/node_modules/semver}/functions/inc.js +3 -2
  410. package/node_modules/superagent/node_modules/semver/functions/parse.js +16 -0
  411. package/node_modules/superagent/node_modules/semver/index.js +89 -0
  412. package/node_modules/{semver → superagent/node_modules/semver}/internal/constants.js +20 -2
  413. package/node_modules/superagent/node_modules/semver/internal/lrucache.js +40 -0
  414. package/node_modules/superagent/node_modules/semver/internal/parse-options.js +15 -0
  415. package/node_modules/{semver → superagent/node_modules/semver}/internal/re.js +41 -6
  416. package/node_modules/{semver → superagent/node_modules/semver}/package.json +29 -26
  417. package/node_modules/{semver → superagent/node_modules/semver}/ranges/intersects.js +1 -1
  418. package/node_modules/{semver → superagent/node_modules/semver}/ranges/subset.js +6 -3
  419. package/node_modules/yargs/browser.d.ts +5 -0
  420. package/node_modules/yargs/build/index.cjs +1 -1
  421. package/node_modules/yargs/build/lib/command.js +2 -0
  422. package/node_modules/yargs/build/lib/completion.js +19 -12
  423. package/node_modules/yargs/build/lib/usage.js +9 -4
  424. package/node_modules/yargs/build/lib/yargs-factory.js +18 -3
  425. package/node_modules/yargs/locales/cs.json +51 -0
  426. package/node_modules/yargs/locales/en.json +4 -0
  427. package/node_modules/yargs/locales/fi.json +1 -1
  428. package/node_modules/yargs/package.json +4 -4
  429. package/node_modules/yargs-parser/CHANGELOG.md +21 -0
  430. package/node_modules/yargs-parser/build/index.cjs +6 -4
  431. package/node_modules/yargs-parser/build/lib/index.js +4 -2
  432. package/node_modules/yargs-parser/build/lib/yargs-parser.js +2 -2
  433. package/node_modules/yargs-parser/package.json +10 -6
  434. package/output/e3e8277b426d4bc636a8ed30e66dd056e6cc9691-corellium-cli-build.tar.gz +0 -0
  435. package/package.json +1 -1
  436. package/renovate.json +11 -58
  437. package/src/clients/Agent.js +40 -37
  438. package/src/clients/Client.js +42 -40
  439. package/src/clients/Instance.js +24 -24
  440. package/src/clients/Webplayer.js +23 -24
  441. package/src/commands/extensions/delete.js +26 -26
  442. package/src/commands/extensions/index.js +6 -11
  443. package/src/commands/extensions/list.js +25 -25
  444. package/src/commands/extensions/load.js +51 -50
  445. package/src/commands/extensions/validate.js +33 -38
  446. package/src/commands/firmware/index.js +6 -9
  447. package/src/commands/firmware/list.js +49 -38
  448. package/src/commands/firmware/load.js +45 -42
  449. package/src/commands/images/create.js +30 -29
  450. package/src/commands/images/delete.js +21 -21
  451. package/src/commands/images/index.js +6 -10
  452. package/src/commands/images/list.js +21 -20
  453. package/src/commands/index.js +2 -2
  454. package/src/commands/instances/apps/index.js +26 -23
  455. package/src/commands/instances/apps/install.js +14 -14
  456. package/src/commands/instances/apps/open.js +17 -17
  457. package/src/commands/instances/create.js +35 -38
  458. package/src/commands/instances/delete.js +24 -25
  459. package/src/commands/instances/file.js +36 -32
  460. package/src/commands/instances/get.js +23 -16
  461. package/src/commands/instances/index.js +8 -8
  462. package/src/commands/instances/input.js +16 -17
  463. package/src/commands/instances/list.js +38 -28
  464. package/src/commands/instances/netmon/disable.js +17 -15
  465. package/src/commands/instances/netmon/download.js +18 -16
  466. package/src/commands/instances/netmon/enable.js +30 -23
  467. package/src/commands/instances/netmon/index.js +6 -11
  468. package/src/commands/instances/netmon/stream.js +18 -16
  469. package/src/commands/instances/ready.js +30 -27
  470. package/src/commands/instances/restoreBackup.js +39 -36
  471. package/src/commands/instances/rotate.js +20 -21
  472. package/src/commands/instances/start.js +23 -24
  473. package/src/commands/instances/stop.js +20 -21
  474. package/src/commands/instances/unlock.js +17 -19
  475. package/src/commands/instances/upgrade.js +38 -34
  476. package/src/commands/login.js +67 -67
  477. package/src/commands/logout.js +10 -12
  478. package/src/commands/mast/constants.js +2 -2
  479. package/src/commands/mast/create-assessment.js +16 -16
  480. package/src/commands/mast/delete-assessment.js +15 -15
  481. package/src/commands/mast/download-report.js +18 -15
  482. package/src/commands/mast/get-assessment.js +14 -14
  483. package/src/commands/mast/get-assessments.js +13 -13
  484. package/src/commands/mast/index.js +7 -7
  485. package/src/commands/mast/start-monitor.js +15 -15
  486. package/src/commands/mast/stop-monitor.js +15 -15
  487. package/src/commands/mast/test.js +19 -16
  488. package/src/commands/projects/create.js +33 -32
  489. package/src/commands/projects/delete.js +26 -26
  490. package/src/commands/projects/index.js +6 -11
  491. package/src/commands/projects/list.js +21 -19
  492. package/src/commands/projects/vpnConfig.js +29 -26
  493. package/src/commands/webplayer/create.js +57 -50
  494. package/src/commands/webplayer/destroy.js +31 -28
  495. package/src/commands/webplayer/index.js +6 -11
  496. package/src/commands/webplayer/list.js +41 -42
  497. package/src/commands/webplayer/login.js +31 -28
  498. package/src/corellium-api.js +11 -11
  499. package/src/error.js +20 -18
  500. package/src/logging.js +15 -15
  501. package/src/profile.js +22 -22
  502. package/src/progress.js +6 -6
  503. package/src/resumable.js +606 -664
  504. package/src/table.js +20 -22
  505. package/src/upload.js +38 -38
  506. package/src/utils.js +63 -64
  507. package/test/test.js +47 -48
  508. package/coverage/cobertura-coverage.xml +0 -9
  509. package/coverage/lcov-report/base.css +0 -224
  510. package/coverage/lcov-report/block-navigation.js +0 -87
  511. package/coverage/lcov-report/favicon.png +0 -0
  512. package/coverage/lcov-report/index.html +0 -101
  513. package/coverage/lcov-report/prettify.css +0 -1
  514. package/coverage/lcov-report/prettify.js +0 -2
  515. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  516. package/coverage/lcov-report/sorter.js +0 -196
  517. package/coverage/lcov.info +0 -0
  518. package/node_modules/@babel/cli/node_modules/commander/CHANGELOG.md +0 -436
  519. package/node_modules/@babel/cli/node_modules/commander/index.js +0 -1649
  520. package/node_modules/@babel/cli/node_modules/commander/typings/index.d.ts +0 -311
  521. package/node_modules/@babel/cli/node_modules/semver/CHANGELOG.md +0 -39
  522. package/node_modules/@babel/cli/node_modules/semver/package.json +0 -28
  523. package/node_modules/@jridgewell/sourcemap-codec/src/sourcemap-codec.ts +0 -198
  524. package/node_modules/braces/CHANGELOG.md +0 -184
  525. package/node_modules/call-bind/.eslintignore +0 -1
  526. package/node_modules/call-bind/CHANGELOG.md +0 -42
  527. package/node_modules/call-bind/README.md +0 -2
  528. package/node_modules/call-bind/callBound.js +0 -15
  529. package/node_modules/call-bind/index.js +0 -47
  530. package/node_modules/call-bind/package.json +0 -80
  531. package/node_modules/call-bind/test/index.js +0 -66
  532. package/node_modules/component-emitter/History.md +0 -75
  533. package/node_modules/function-bind/.jscs.json +0 -176
  534. package/node_modules/function-bind/.npmignore +0 -22
  535. package/node_modules/function-bind/.travis.yml +0 -168
  536. package/node_modules/has/LICENSE-MIT +0 -22
  537. package/node_modules/has/README.md +0 -18
  538. package/node_modules/has/package.json +0 -48
  539. package/node_modules/has/src/index.js +0 -5
  540. package/node_modules/has/test/index.js +0 -10
  541. package/node_modules/lru-cache/README.md +0 -166
  542. package/node_modules/lru-cache/index.js +0 -334
  543. package/node_modules/lru-cache/package.json +0 -34
  544. package/node_modules/semver/LICENSE +0 -15
  545. package/node_modules/semver/functions/diff.js +0 -23
  546. package/node_modules/semver/functions/parse.js +0 -33
  547. package/node_modules/semver/index.js +0 -48
  548. package/node_modules/semver/internal/parse-options.js +0 -11
  549. package/node_modules/side-channel/.eslintignore +0 -1
  550. package/node_modules/superagent/node_modules/form-data/README.md.bak +0 -356
  551. package/node_modules/superagent/node_modules/form-data/Readme.md +0 -356
  552. package/node_modules/yallist/LICENSE +0 -15
  553. package/node_modules/yallist/README.md +0 -204
  554. package/node_modules/yallist/iterator.js +0 -8
  555. package/node_modules/yallist/package.json +0 -29
  556. package/node_modules/yallist/yallist.js +0 -426
  557. /package/node_modules/{superagent → axios}/node_modules/form-data/License +0 -0
  558. /package/node_modules/{superagent → axios}/node_modules/form-data/index.d.ts +0 -0
  559. /package/node_modules/{superagent → axios}/node_modules/form-data/lib/browser.js +0 -0
  560. /package/node_modules/{superagent → axios}/node_modules/form-data/lib/populate.js +0 -0
  561. /package/node_modules/{@babel/cli/node_modules/commander → commander}/LICENSE +0 -0
  562. /package/node_modules/{call-bind → dunder-proto}/.nycrc +0 -0
  563. /package/node_modules/{@babel/cli/node_modules/make-dir → make-dir}/index.d.ts +0 -0
  564. /package/node_modules/{@babel/cli/node_modules/make-dir → make-dir}/index.js +0 -0
  565. /package/node_modules/{@babel/cli/node_modules/make-dir → make-dir}/license +0 -0
  566. /package/node_modules/{@babel/cli → make-dir}/node_modules/semver/LICENSE +0 -0
  567. /package/node_modules/{@babel/cli → make-dir}/node_modules/semver/README.md +0 -0
  568. /package/node_modules/{@babel/cli → make-dir}/node_modules/semver/bin/semver +0 -0
  569. /package/node_modules/{@babel/cli → make-dir}/node_modules/semver/range.bnf +0 -0
  570. /package/node_modules/{@babel/cli/node_modules/make-dir → make-dir}/package.json +0 -0
  571. /package/node_modules/{@babel/cli/node_modules/make-dir → make-dir}/readme.md +0 -0
  572. /package/node_modules/{@babel/cli/node_modules/pify → pify}/index.js +0 -0
  573. /package/node_modules/{@babel/cli/node_modules/pify → pify}/license +0 -0
  574. /package/node_modules/{@babel/cli/node_modules/pify → pify}/package.json +0 -0
  575. /package/node_modules/{@babel/cli/node_modules/pify → pify}/readme.md +0 -0
  576. /package/node_modules/{@babel/cli/node_modules/slash → slash}/index.js +0 -0
  577. /package/node_modules/{@babel/cli/node_modules/slash → slash}/license +0 -0
  578. /package/node_modules/{@babel/cli/node_modules/slash → slash}/package.json +0 -0
  579. /package/node_modules/{@babel/cli/node_modules/slash → slash}/readme.md +0 -0
  580. /package/node_modules/{lru-cache → superagent/node_modules/semver}/LICENSE +0 -0
  581. /package/node_modules/{semver → superagent/node_modules/semver}/classes/index.js +0 -0
  582. /package/node_modules/{semver → superagent/node_modules/semver}/functions/clean.js +0 -0
  583. /package/node_modules/{semver → superagent/node_modules/semver}/functions/cmp.js +0 -0
  584. /package/node_modules/{semver → superagent/node_modules/semver}/functions/compare-build.js +0 -0
  585. /package/node_modules/{semver → superagent/node_modules/semver}/functions/compare-loose.js +0 -0
  586. /package/node_modules/{semver → superagent/node_modules/semver}/functions/compare.js +0 -0
  587. /package/node_modules/{semver → superagent/node_modules/semver}/functions/eq.js +0 -0
  588. /package/node_modules/{semver → superagent/node_modules/semver}/functions/gt.js +0 -0
  589. /package/node_modules/{semver → superagent/node_modules/semver}/functions/gte.js +0 -0
  590. /package/node_modules/{semver → superagent/node_modules/semver}/functions/lt.js +0 -0
  591. /package/node_modules/{semver → superagent/node_modules/semver}/functions/lte.js +0 -0
  592. /package/node_modules/{semver → superagent/node_modules/semver}/functions/major.js +0 -0
  593. /package/node_modules/{semver → superagent/node_modules/semver}/functions/minor.js +0 -0
  594. /package/node_modules/{semver → superagent/node_modules/semver}/functions/neq.js +0 -0
  595. /package/node_modules/{semver → superagent/node_modules/semver}/functions/patch.js +0 -0
  596. /package/node_modules/{semver → superagent/node_modules/semver}/functions/prerelease.js +0 -0
  597. /package/node_modules/{semver → superagent/node_modules/semver}/functions/rcompare.js +0 -0
  598. /package/node_modules/{semver → superagent/node_modules/semver}/functions/rsort.js +0 -0
  599. /package/node_modules/{semver → superagent/node_modules/semver}/functions/satisfies.js +0 -0
  600. /package/node_modules/{semver → superagent/node_modules/semver}/functions/sort.js +0 -0
  601. /package/node_modules/{semver → superagent/node_modules/semver}/functions/valid.js +0 -0
  602. /package/node_modules/{semver → superagent/node_modules/semver}/internal/debug.js +0 -0
  603. /package/node_modules/{semver → superagent/node_modules/semver}/internal/identifiers.js +0 -0
  604. /package/node_modules/{semver → superagent/node_modules/semver}/preload.js +0 -0
  605. /package/node_modules/{semver → superagent/node_modules/semver}/range.bnf +0 -0
  606. /package/node_modules/{semver → superagent/node_modules/semver}/ranges/gtr.js +0 -0
  607. /package/node_modules/{semver → superagent/node_modules/semver}/ranges/ltr.js +0 -0
  608. /package/node_modules/{semver → superagent/node_modules/semver}/ranges/max-satisfying.js +0 -0
  609. /package/node_modules/{semver → superagent/node_modules/semver}/ranges/min-satisfying.js +0 -0
  610. /package/node_modules/{semver → superagent/node_modules/semver}/ranges/min-version.js +0 -0
  611. /package/node_modules/{semver → superagent/node_modules/semver}/ranges/outside.js +0 -0
  612. /package/node_modules/{semver → superagent/node_modules/semver}/ranges/simplify.js +0 -0
  613. /package/node_modules/{semver → superagent/node_modules/semver}/ranges/to-comparators.js +0 -0
  614. /package/node_modules/{semver → superagent/node_modules/semver}/ranges/valid.js +0 -0
package/src/resumable.js CHANGED
@@ -10,26 +10,26 @@
10
10
  const XMLHttpRequest = require('xhr2').XMLHttpRequest;
11
11
 
12
12
  (function () {
13
- 'use strict'
13
+ 'use strict';
14
14
 
15
15
  var Resumable = function (opts) {
16
16
  if (!(this instanceof Resumable)) {
17
- return new Resumable(opts)
17
+ return new Resumable(opts);
18
18
  }
19
- this.version = 1.0
19
+ this.version = 1.0;
20
20
  // SUPPORTED BY BROWSER?
21
21
  // Check if these features are support by the browser:
22
22
  // - File object type
23
23
  // - Blob object type
24
24
  // - FileList object type
25
25
  // - slicing files
26
- this.support = true
27
- if (!this.support) return false
28
- const window = { setTimeout }
26
+ this.support = true;
27
+ if (!this.support) return false;
28
+ const window = { setTimeout };
29
29
 
30
30
  // PROPERTIES
31
- const $ = this
32
- $.files = []
31
+ const $ = this;
32
+ $.files = [];
33
33
  $.defaults = {
34
34
  chunkSize: 1 * 1024 * 1024,
35
35
  forceChunkSize: false,
@@ -70,345 +70,329 @@ const XMLHttpRequest = require('xhr2').XMLHttpRequest;
70
70
  chunkFormat: 'blob',
71
71
  setChunkTypeFromFile: false,
72
72
  maxFilesErrorCallback: function (files, errorCount) {
73
- const maxFiles = $.getOpt('maxFiles')
74
- alert(
75
- 'Please upload no more than ' +
76
- maxFiles +
77
- ' file' +
78
- (maxFiles === 1 ? '' : 's') +
79
- ' at a time.'
80
- )
73
+ const maxFiles = $.getOpt('maxFiles');
74
+ alert('Please upload no more than ' + maxFiles + ' file' + (maxFiles === 1 ? '' : 's') + ' at a time.');
81
75
  },
82
76
  minFileSize: 1,
83
77
  minFileSizeErrorCallback: function (file, errorCount) {
84
78
  alert(
85
79
  file.fileName ||
86
- file.name +
87
- ' is too small, please upload files larger than ' +
88
- $h.formatSize($.getOpt('minFileSize')) +
89
- '.'
90
- )
80
+ file.name +
81
+ ' is too small, please upload files larger than ' +
82
+ $h.formatSize($.getOpt('minFileSize')) +
83
+ '.',
84
+ );
91
85
  },
92
86
  maxFileSize: undefined,
93
87
  maxFileSizeErrorCallback: function (file, errorCount) {
94
88
  alert(
95
89
  file.fileName ||
96
- file.name +
97
- ' is too large, please upload files less than ' +
98
- $h.formatSize($.getOpt('maxFileSize')) +
99
- '.'
100
- )
90
+ file.name + ' is too large, please upload files less than ' + $h.formatSize($.getOpt('maxFileSize')) + '.',
91
+ );
101
92
  },
102
93
  fileType: [],
103
94
  fileTypeErrorCallback: function (file, errorCount) {
104
95
  alert(
105
96
  file.fileName ||
106
- file.name +
107
- ' has type not allowed, please upload files of type ' +
108
- $.getOpt('fileType') +
109
- '.'
110
- )
111
- }
112
- }
113
- $.opts = opts || {}
97
+ file.name + ' has type not allowed, please upload files of type ' + $.getOpt('fileType') + '.',
98
+ );
99
+ },
100
+ };
101
+ $.opts = opts || {};
114
102
  $.getOpt = function (o) {
115
- let $opt = this
103
+ let $opt = this;
116
104
  // Get multiple option if passed an array
117
105
  if (o instanceof Array) {
118
- const options = {}
106
+ const options = {};
119
107
  $h.each(o, function (option) {
120
- options[option] = $opt.getOpt(option)
121
- })
122
- return options
108
+ options[option] = $opt.getOpt(option);
109
+ });
110
+ return options;
123
111
  }
124
112
  // Otherwise, just return a simple option
125
113
  if ($opt instanceof ResumableChunk) {
126
114
  if (typeof $opt.opts[o] !== 'undefined') {
127
- return $opt.opts[o]
115
+ return $opt.opts[o];
128
116
  } else {
129
- $opt = $opt.fileObj
117
+ $opt = $opt.fileObj;
130
118
  }
131
119
  }
132
120
  if ($opt instanceof ResumableFile) {
133
121
  if (typeof $opt.opts[o] !== 'undefined') {
134
- return $opt.opts[o]
122
+ return $opt.opts[o];
135
123
  } else {
136
- $opt = $opt.resumableObj
124
+ $opt = $opt.resumableObj;
137
125
  }
138
126
  }
139
127
  if ($opt instanceof Resumable) {
140
128
  if (typeof $opt.opts[o] !== 'undefined') {
141
- return $opt.opts[o]
129
+ return $opt.opts[o];
142
130
  } else {
143
- return $opt.defaults[o]
131
+ return $opt.defaults[o];
144
132
  }
145
133
  }
146
- }
134
+ };
147
135
  $.indexOf = function (array, obj) {
148
136
  if (array.indexOf) {
149
- return array.indexOf(obj)
137
+ return array.indexOf(obj);
150
138
  }
151
139
  for (let i = 0; i < array.length; i++) {
152
140
  if (array[i] === obj) {
153
- return i
141
+ return i;
154
142
  }
155
143
  }
156
- return -1
157
- }
144
+ return -1;
145
+ };
158
146
 
159
147
  // EVENTS
160
148
  // catchAll(event, ...)
161
149
  // fileSuccess(file), fileProgress(file), fileAdded(file, event), filesAdded(files, filesSkipped), fileRetry(file),
162
150
  // fileError(file, message), complete(), progress(), error(message, file), pause()
163
- $.events = []
151
+ $.events = [];
164
152
  $.on = function (event, callback) {
165
- $.events.push(event.toLowerCase(), callback)
166
- }
153
+ $.events.push(event.toLowerCase(), callback);
154
+ };
167
155
  $.fire = function () {
168
156
  // `arguments` is an object, not array, in FF, so:
169
- const args = []
170
- for (var i = 0; i < arguments.length; i++) args.push(arguments[i])
157
+ const args = [];
158
+ for (var i = 0; i < arguments.length; i++) args.push(arguments[i]);
171
159
  // Find event listeners, and support pseudo-event `catchAll`
172
- const event = args[0].toLowerCase()
160
+ const event = args[0].toLowerCase();
173
161
  for (var i = 0; i <= $.events.length; i += 2) {
174
- if ($.events[i] == event) $.events[i + 1].apply($, args.slice(1))
175
- if ($.events[i] == 'catchall') $.events[i + 1].apply(null, args)
162
+ if ($.events[i] == event) $.events[i + 1].apply($, args.slice(1));
163
+ if ($.events[i] == 'catchall') $.events[i + 1].apply(null, args);
176
164
  }
177
- if (event == 'fileerror') $.fire('error', args[2], args[1])
178
- if (event == 'fileprogress') $.fire('progress')
179
- }
165
+ if (event == 'fileerror') $.fire('error', args[2], args[1]);
166
+ if (event == 'fileprogress') $.fire('progress');
167
+ };
180
168
 
181
169
  // INTERNAL HELPER METHODS (handy, but ultimately not part of uploading)
182
170
  var $h = {
183
171
  stopEvent: function (e) {
184
- e.stopPropagation()
185
- e.preventDefault()
172
+ e.stopPropagation();
173
+ e.preventDefault();
186
174
  },
187
175
  each: function (o, callback) {
188
176
  if (typeof o.length !== 'undefined') {
189
177
  for (var i = 0; i < o.length; i++) {
190
178
  // Array or FileList
191
- if (callback(o[i]) === false) return
179
+ if (callback(o[i]) === false) return;
192
180
  }
193
181
  } else {
194
182
  for (i in o) {
195
183
  // Object
196
- if (callback(i, o[i]) === false) return
184
+ if (callback(i, o[i]) === false) return;
197
185
  }
198
186
  }
199
187
  },
200
188
  generateUniqueIdentifier: function (file, event) {
201
- const custom = $.getOpt('generateUniqueIdentifier')
189
+ const custom = $.getOpt('generateUniqueIdentifier');
202
190
  if (typeof custom === 'function') {
203
- return custom(file, event)
191
+ return custom(file, event);
204
192
  }
205
- const relativePath =
206
- file.webkitRelativePath || file.relativePath || file.fileName || file.name // Some confusion in different versions of Firefox
207
- const size = file.size
208
- return size + '-' + relativePath.replace(/[^0-9a-zA-Z_-]/gim, '')
193
+ const relativePath = file.webkitRelativePath || file.relativePath || file.fileName || file.name; // Some confusion in different versions of Firefox
194
+ const size = file.size;
195
+ return size + '-' + relativePath.replace(/[^0-9a-zA-Z_-]/gim, '');
209
196
  },
210
197
  contains: function (array, test) {
211
- let result = false
198
+ let result = false;
212
199
 
213
200
  $h.each(array, function (value) {
214
201
  if (value == test) {
215
- result = true
216
- return false
202
+ result = true;
203
+ return false;
217
204
  }
218
- return true
219
- })
205
+ return true;
206
+ });
220
207
 
221
- return result
208
+ return result;
222
209
  },
223
210
  formatSize: function (size) {
224
211
  if (size < 1024) {
225
- return size + ' bytes'
212
+ return size + ' bytes';
226
213
  } else if (size < 1024 * 1024) {
227
- return (size / 1024.0).toFixed(0) + ' KB'
214
+ return (size / 1024.0).toFixed(0) + ' KB';
228
215
  } else if (size < 1024 * 1024 * 1024) {
229
- return (size / 1024.0 / 1024.0).toFixed(1) + ' MB'
216
+ return (size / 1024.0 / 1024.0).toFixed(1) + ' MB';
230
217
  } else {
231
- return (size / 1024.0 / 1024.0 / 1024.0).toFixed(1) + ' GB'
218
+ return (size / 1024.0 / 1024.0 / 1024.0).toFixed(1) + ' GB';
232
219
  }
233
220
  },
234
221
  getTarget: function (request, params) {
235
- let target = $.getOpt('target')
222
+ let target = $.getOpt('target');
236
223
 
237
224
  if (request === 'test' && $.getOpt('testTarget')) {
238
- target =
239
- $.getOpt('testTarget') === '/'
240
- ? $.getOpt('target')
241
- : $.getOpt('testTarget')
225
+ target = $.getOpt('testTarget') === '/' ? $.getOpt('target') : $.getOpt('testTarget');
242
226
  }
243
227
 
244
228
  if (typeof target === 'function') {
245
- return target(params)
229
+ return target(params);
246
230
  }
247
231
 
248
- const separator = target.indexOf('?') < 0 ? '?' : '&'
249
- const joinedParams = params.join('&')
232
+ const separator = target.indexOf('?') < 0 ? '?' : '&';
233
+ const joinedParams = params.join('&');
250
234
 
251
- if (joinedParams) target = target + separator + joinedParams
235
+ if (joinedParams) target = target + separator + joinedParams;
252
236
 
253
- return target
254
- }
255
- }
237
+ return target;
238
+ },
239
+ };
256
240
 
257
241
  const onDrop = function (e) {
258
- e.currentTarget.classList.remove($.getOpt('dragOverClass'))
259
- $h.stopEvent(e)
242
+ e.currentTarget.classList.remove($.getOpt('dragOverClass'));
243
+ $h.stopEvent(e);
260
244
 
261
245
  // handle dropped things as items if we can (this lets us deal with folders nicer in some cases)
262
246
  if (e.dataTransfer && e.dataTransfer.items) {
263
- loadFiles(e.dataTransfer.items, e)
247
+ loadFiles(e.dataTransfer.items, e);
264
248
  }
265
249
  // else handle them as files
266
250
  else if (e.dataTransfer && e.dataTransfer.files) {
267
- loadFiles(e.dataTransfer.files, e)
251
+ loadFiles(e.dataTransfer.files, e);
268
252
  }
269
- }
253
+ };
270
254
  const onDragLeave = function (e) {
271
- e.currentTarget.classList.remove($.getOpt('dragOverClass'))
272
- }
255
+ e.currentTarget.classList.remove($.getOpt('dragOverClass'));
256
+ };
273
257
  const onDragOverEnter = function (e) {
274
- e.preventDefault()
275
- const dt = e.dataTransfer
258
+ e.preventDefault();
259
+ const dt = e.dataTransfer;
276
260
  if ($.indexOf(dt.types, 'Files') >= 0) {
277
261
  // only for file drop
278
- e.stopPropagation()
279
- dt.dropEffect = 'copy'
280
- dt.effectAllowed = 'copy'
281
- e.currentTarget.classList.add($.getOpt('dragOverClass'))
262
+ e.stopPropagation();
263
+ dt.dropEffect = 'copy';
264
+ dt.effectAllowed = 'copy';
265
+ e.currentTarget.classList.add($.getOpt('dragOverClass'));
282
266
  } else {
283
267
  // not work on IE/Edge....
284
- dt.dropEffect = 'none'
285
- dt.effectAllowed = 'none'
268
+ dt.dropEffect = 'none';
269
+ dt.effectAllowed = 'none';
286
270
  }
287
- }
271
+ };
288
272
 
289
273
  /**
290
- * processes a single upload item (file or directory)
291
- * @param {Object} item item to upload, may be file or directory entry
292
- * @param {string} path current file path
293
- * @param {File[]} items list of files to append new items to
294
- * @param {Function} cb callback invoked when item is processed
295
- */
296
- function processItem (item, path, items, cb) {
297
- let entry
274
+ * processes a single upload item (file or directory)
275
+ * @param {Object} item item to upload, may be file or directory entry
276
+ * @param {string} path current file path
277
+ * @param {File[]} items list of files to append new items to
278
+ * @param {Function} cb callback invoked when item is processed
279
+ */
280
+ function processItem(item, path, items, cb) {
281
+ let entry;
298
282
  if (item.isFile) {
299
283
  // file provided
300
284
  return item.file(function (file) {
301
- file.relativePath = path + file.name
302
- items.push(file)
303
- cb()
304
- })
285
+ file.relativePath = path + file.name;
286
+ items.push(file);
287
+ cb();
288
+ });
305
289
  } else if (item.isDirectory) {
306
290
  // item is already a directory entry, just assign
307
- entry = item
291
+ entry = item;
308
292
  } else if (item instanceof File) {
309
- items.push(item)
293
+ items.push(item);
310
294
  }
311
295
  if (typeof item.webkitGetAsEntry === 'function') {
312
296
  // get entry from file object
313
- entry = item.webkitGetAsEntry()
297
+ entry = item.webkitGetAsEntry();
314
298
  }
315
299
  if (entry && entry.isDirectory) {
316
300
  // directory provided, process it
317
- return processDirectory(entry, path + entry.name + '/', items, cb)
301
+ return processDirectory(entry, path + entry.name + '/', items, cb);
318
302
  }
319
303
  if (typeof item.getAsFile === 'function') {
320
304
  // item represents a File object, convert it
321
- item = item.getAsFile()
305
+ item = item.getAsFile();
322
306
  if (item instanceof File) {
323
- item.relativePath = path + item.name
324
- items.push(item)
307
+ item.relativePath = path + item.name;
308
+ items.push(item);
325
309
  }
326
310
  }
327
- cb() // indicate processing is done
311
+ cb(); // indicate processing is done
328
312
  }
329
313
 
330
314
  /**
331
- * cps-style list iteration.
332
- * invokes all functions in list and waits for their callback to be
333
- * triggered.
334
- * @param {Function[]} items list of functions expecting callback parameter
335
- * @param {Function} cb callback to trigger after the last callback has been invoked
336
- */
337
- function processCallbacks (items, cb) {
315
+ * cps-style list iteration.
316
+ * invokes all functions in list and waits for their callback to be
317
+ * triggered.
318
+ * @param {Function[]} items list of functions expecting callback parameter
319
+ * @param {Function} cb callback to trigger after the last callback has been invoked
320
+ */
321
+ function processCallbacks(items, cb) {
338
322
  if (!items || items.length === 0) {
339
323
  // empty or no list, invoke callback
340
- return cb()
324
+ return cb();
341
325
  }
342
326
  // invoke current function, pass the next part as continuation
343
327
  items[0](function () {
344
- processCallbacks(items.slice(1), cb)
345
- })
328
+ processCallbacks(items.slice(1), cb);
329
+ });
346
330
  }
347
331
 
348
332
  /**
349
- * recursively traverse directory and collect files to upload
350
- * @param {Object} directory directory to process
351
- * @param {string} path current path
352
- * @param {File[]} items target list of items
353
- * @param {Function} cb callback invoked after traversing directory
354
- */
355
- function processDirectory (directory, path, items, cb) {
356
- const dirReader = directory.createReader()
357
- let allEntries = []
333
+ * recursively traverse directory and collect files to upload
334
+ * @param {Object} directory directory to process
335
+ * @param {string} path current path
336
+ * @param {File[]} items target list of items
337
+ * @param {Function} cb callback invoked after traversing directory
338
+ */
339
+ function processDirectory(directory, path, items, cb) {
340
+ const dirReader = directory.createReader();
341
+ let allEntries = [];
358
342
 
359
- function readEntries () {
343
+ function readEntries() {
360
344
  dirReader.readEntries(function (entries) {
361
345
  if (entries.length) {
362
- allEntries = allEntries.concat(entries)
363
- return readEntries()
346
+ allEntries = allEntries.concat(entries);
347
+ return readEntries();
364
348
  }
365
349
 
366
350
  // process all conversion callbacks, finally invoke own one
367
351
  processCallbacks(
368
352
  allEntries.map(function (entry) {
369
353
  // bind all properties except for callback
370
- return processItem.bind(null, entry, path, items)
354
+ return processItem.bind(null, entry, path, items);
371
355
  }),
372
- cb
373
- )
374
- })
356
+ cb,
357
+ );
358
+ });
375
359
  }
376
360
 
377
- readEntries()
361
+ readEntries();
378
362
  }
379
363
 
380
364
  /**
381
- * process items to extract files to be uploaded
382
- * @param {File[]} items items to process
383
- * @param {Event} event event that led to upload
384
- */
385
- function loadFiles (items, event) {
365
+ * process items to extract files to be uploaded
366
+ * @param {File[]} items items to process
367
+ * @param {Event} event event that led to upload
368
+ */
369
+ function loadFiles(items, event) {
386
370
  if (!items.length) {
387
- return // nothing to do
371
+ return; // nothing to do
388
372
  }
389
- $.fire('beforeAdd')
390
- const files = []
373
+ $.fire('beforeAdd');
374
+ const files = [];
391
375
  processCallbacks(
392
376
  Array.prototype.map.call(items, function (item) {
393
377
  // bind all properties except for callback
394
- let entry = item
378
+ let entry = item;
395
379
  if (typeof item.webkitGetAsEntry === 'function') {
396
- entry = item.webkitGetAsEntry()
380
+ entry = item.webkitGetAsEntry();
397
381
  }
398
- return processItem.bind(null, entry, '', files)
382
+ return processItem.bind(null, entry, '', files);
399
383
  }),
400
384
  function () {
401
385
  if (files.length) {
402
386
  // at least one file found
403
- appendFilesFromFileList(files, event)
387
+ appendFilesFromFileList(files, event);
404
388
  }
405
- }
406
- )
389
+ },
390
+ );
407
391
  }
408
392
 
409
393
  var appendFilesFromFileList = function (fileList, event) {
410
394
  // check for uploading too many files
411
- let errorCount = 0
395
+ let errorCount = 0;
412
396
  const o = $.getOpt([
413
397
  'maxFiles',
414
398
  'minFileSize',
@@ -417,372 +401,357 @@ const XMLHttpRequest = require('xhr2').XMLHttpRequest;
417
401
  'minFileSizeErrorCallback',
418
402
  'maxFileSizeErrorCallback',
419
403
  'fileType',
420
- 'fileTypeErrorCallback'
421
- ])
422
- if (
423
- typeof o.maxFiles !== 'undefined' &&
424
- o.maxFiles < fileList.length + $.files.length
425
- ) {
404
+ 'fileTypeErrorCallback',
405
+ ]);
406
+ if (typeof o.maxFiles !== 'undefined' && o.maxFiles < fileList.length + $.files.length) {
426
407
  // if single-file upload, file is already added, and trying to add 1 new file, simply replace the already-added file
427
408
  if (o.maxFiles === 1 && $.files.length === 1 && fileList.length === 1) {
428
- $.removeFile($.files[0])
409
+ $.removeFile($.files[0]);
429
410
  } else {
430
- o.maxFilesErrorCallback(fileList, errorCount++)
431
- return false
411
+ o.maxFilesErrorCallback(fileList, errorCount++);
412
+ return false;
432
413
  }
433
414
  }
434
- const files = []
435
- const filesSkipped = []
436
- let remaining = fileList.length
415
+ const files = [];
416
+ const filesSkipped = [];
417
+ let remaining = fileList.length;
437
418
  const decreaseReamining = function () {
438
419
  if (!--remaining) {
439
420
  // all files processed, trigger event
440
421
  if (!files.length && !filesSkipped.length) {
441
422
  // no succeeded files, just skip
442
- return
423
+ return;
443
424
  }
444
425
  window.setTimeout(function () {
445
- $.fire('filesAdded', files, filesSkipped)
446
- }, 0)
426
+ $.fire('filesAdded', files, filesSkipped);
427
+ }, 0);
447
428
  }
448
- }
429
+ };
449
430
  $h.each(fileList, function (file) {
450
- const fileName = file.name
451
- const fileType = file.type // e.g video/mp4
431
+ const fileName = file.name;
432
+ const fileType = file.type; // e.g video/mp4
452
433
  if (o.fileType.length > 0) {
453
- let fileTypeFound = false
434
+ let fileTypeFound = false;
454
435
  for (const index in o.fileType) {
455
436
  // For good behaviour we do some inital sanitizing. Remove spaces and lowercase all
456
- o.fileType[index] = o.fileType[index].replace(/\s/g, '').toLowerCase()
437
+ o.fileType[index] = o.fileType[index].replace(/\s/g, '').toLowerCase();
457
438
 
458
439
  // Allowing for both [extension, .extension, mime/type, mime/*]
459
- const extension =
460
- (o.fileType[index].match(/^[^.][^/]+$/) ? '.' : '') + o.fileType[index]
440
+ const extension = (o.fileType[index].match(/^[^.][^/]+$/) ? '.' : '') + o.fileType[index];
461
441
 
462
442
  if (
463
443
  fileName.substr(-1 * extension.length).toLowerCase() === extension ||
464
- // If MIME type, check for wildcard or if extension matches the files tiletype
465
- (extension.indexOf('/') !== -1 &&
466
- ((extension.indexOf('*') !== -1 &&
467
- fileType.substr(0, extension.indexOf('*')) ===
468
- extension.substr(0, extension.indexOf('*'))) ||
469
- fileType === extension))
444
+ // If MIME type, check for wildcard or if extension matches the files tiletype
445
+ (extension.indexOf('/') !== -1 &&
446
+ ((extension.indexOf('*') !== -1 &&
447
+ fileType.substr(0, extension.indexOf('*')) === extension.substr(0, extension.indexOf('*'))) ||
448
+ fileType === extension))
470
449
  ) {
471
- fileTypeFound = true
472
- break
450
+ fileTypeFound = true;
451
+ break;
473
452
  }
474
453
  }
475
454
  if (!fileTypeFound) {
476
- o.fileTypeErrorCallback(file, errorCount++)
477
- return true
455
+ o.fileTypeErrorCallback(file, errorCount++);
456
+ return true;
478
457
  }
479
458
  }
480
459
 
481
460
  if (typeof o.minFileSize !== 'undefined' && file.size < o.minFileSize) {
482
- o.minFileSizeErrorCallback(file, errorCount++)
483
- return true
461
+ o.minFileSizeErrorCallback(file, errorCount++);
462
+ return true;
484
463
  }
485
464
  if (typeof o.maxFileSize !== 'undefined' && file.size > o.maxFileSize) {
486
- o.maxFileSizeErrorCallback(file, errorCount++)
487
- return true
465
+ o.maxFileSizeErrorCallback(file, errorCount++);
466
+ return true;
488
467
  }
489
468
 
490
- function addFile (uniqueIdentifier) {
469
+ function addFile(uniqueIdentifier) {
491
470
  if (!$.getFromUniqueIdentifier(uniqueIdentifier)) {
492
471
  (function () {
493
- file.uniqueIdentifier = uniqueIdentifier
494
- const f = new ResumableFile($, file, uniqueIdentifier)
495
- $.files.push(f)
496
- files.push(f)
497
- f.container = typeof event !== 'undefined' ? event.srcElement : null
472
+ file.uniqueIdentifier = uniqueIdentifier;
473
+ const f = new ResumableFile($, file, uniqueIdentifier);
474
+ $.files.push(f);
475
+ files.push(f);
476
+ f.container = typeof event !== 'undefined' ? event.srcElement : null;
498
477
  window.setTimeout(function () {
499
- $.fire('fileAdded', f, event)
500
- }, 0)
501
- })()
478
+ $.fire('fileAdded', f, event);
479
+ }, 0);
480
+ })();
502
481
  } else {
503
- filesSkipped.push(file)
482
+ filesSkipped.push(file);
504
483
  }
505
- decreaseReamining()
484
+ decreaseReamining();
506
485
  }
507
486
  // directories have size == 0
508
- const uniqueIdentifier = $h.generateUniqueIdentifier(file, event)
487
+ const uniqueIdentifier = $h.generateUniqueIdentifier(file, event);
509
488
  if (uniqueIdentifier && typeof uniqueIdentifier.then === 'function') {
510
489
  // Promise or Promise-like object provided as unique identifier
511
490
  uniqueIdentifier.then(
512
491
  function (uniqueIdentifier) {
513
492
  // unique identifier generation succeeded
514
- addFile(uniqueIdentifier)
493
+ addFile(uniqueIdentifier);
515
494
  },
516
495
  function () {
517
496
  // unique identifier generation failed
518
497
  // skip further processing, only decrease file count
519
- decreaseReamining()
520
- }
521
- )
498
+ decreaseReamining();
499
+ },
500
+ );
522
501
  } else {
523
502
  // non-Promise provided as unique identifier, process synchronously
524
- addFile(uniqueIdentifier)
503
+ addFile(uniqueIdentifier);
525
504
  }
526
- })
527
- }
505
+ });
506
+ };
528
507
 
529
508
  // INTERNAL OBJECT TYPES
530
- function ResumableFile (resumableObj, file, uniqueIdentifier) {
531
- const $ = this
532
- $.opts = {}
533
- $.getOpt = resumableObj.getOpt
534
- $._prevProgress = 0
535
- $.resumableObj = resumableObj
536
- $.file = file
537
- $.fileName = file.fileName || file.name // Some confusion in different versions of Firefox
538
- $.size = file.size
539
- $.relativePath = file.relativePath || file.webkitRelativePath || $.fileName
540
- $.uniqueIdentifier = uniqueIdentifier
541
- $._pause = false
542
- $.container = ''
543
- $.preprocessState = 0 // 0 = unprocessed, 1 = processing, 2 = finished
544
- let _error = uniqueIdentifier !== undefined
509
+ function ResumableFile(resumableObj, file, uniqueIdentifier) {
510
+ const $ = this;
511
+ $.opts = {};
512
+ $.getOpt = resumableObj.getOpt;
513
+ $._prevProgress = 0;
514
+ $.resumableObj = resumableObj;
515
+ $.file = file;
516
+ $.fileName = file.fileName || file.name; // Some confusion in different versions of Firefox
517
+ $.size = file.size;
518
+ $.relativePath = file.relativePath || file.webkitRelativePath || $.fileName;
519
+ $.uniqueIdentifier = uniqueIdentifier;
520
+ $._pause = false;
521
+ $.container = '';
522
+ $.preprocessState = 0; // 0 = unprocessed, 1 = processing, 2 = finished
523
+ let _error = uniqueIdentifier !== undefined;
545
524
 
546
525
  // Callback when something happens within the chunk
547
526
  const chunkEvent = function (event, message) {
548
527
  // event can be 'progress', 'success', 'error' or 'retry'
549
528
  switch (event) {
550
529
  case 'progress':
551
- $.resumableObj.fire('fileProgress', $, message)
552
- break
530
+ $.resumableObj.fire('fileProgress', $, message);
531
+ break;
553
532
  case 'error':
554
- $.abort()
555
- _error = true
556
- $.chunks = []
557
- $.resumableObj.fire('fileError', $, message)
558
- break
533
+ $.abort();
534
+ _error = true;
535
+ $.chunks = [];
536
+ $.resumableObj.fire('fileError', $, message);
537
+ break;
559
538
  case 'success':
560
- if (_error) return
561
- $.resumableObj.fire('fileProgress', $, message) // it's at least progress
539
+ if (_error) return;
540
+ $.resumableObj.fire('fileProgress', $, message); // it's at least progress
562
541
  if ($.isComplete()) {
563
- $.resumableObj.fire('fileSuccess', $, message)
542
+ $.resumableObj.fire('fileSuccess', $, message);
564
543
  }
565
- break
544
+ break;
566
545
  case 'retry':
567
- $.resumableObj.fire('fileRetry', $)
568
- break
546
+ $.resumableObj.fire('fileRetry', $);
547
+ break;
569
548
  }
570
- }
549
+ };
571
550
 
572
551
  // Main code to set up a file object with chunks,
573
552
  // packaged to be able to handle retries if needed.
574
- $.chunks = []
553
+ $.chunks = [];
575
554
  $.abort = function () {
576
555
  // Stop current uploads
577
- let abortCount = 0
556
+ let abortCount = 0;
578
557
  $h.each($.chunks, function (c) {
579
558
  if (c.status() == 'uploading') {
580
- c.abort()
581
- abortCount++
559
+ c.abort();
560
+ abortCount++;
582
561
  }
583
- })
584
- if (abortCount > 0) $.resumableObj.fire('fileProgress', $)
585
- }
562
+ });
563
+ if (abortCount > 0) $.resumableObj.fire('fileProgress', $);
564
+ };
586
565
  $.cancel = function () {
587
566
  // Reset this file to be void
588
- const _chunks = $.chunks
589
- $.chunks = []
567
+ const _chunks = $.chunks;
568
+ $.chunks = [];
590
569
  // Stop current uploads
591
570
  $h.each(_chunks, function (c) {
592
571
  if (c.status() == 'uploading') {
593
- c.abort()
594
- $.resumableObj.uploadNextChunk()
572
+ c.abort();
573
+ $.resumableObj.uploadNextChunk();
595
574
  }
596
- })
597
- $.resumableObj.removeFile($)
598
- $.resumableObj.fire('fileProgress', $)
599
- }
575
+ });
576
+ $.resumableObj.removeFile($);
577
+ $.resumableObj.fire('fileProgress', $);
578
+ };
600
579
  $.retry = function () {
601
- $.bootstrap()
602
- let firedRetry = false
580
+ $.bootstrap();
581
+ let firedRetry = false;
603
582
  $.resumableObj.on('chunkingComplete', function () {
604
- if (!firedRetry) $.resumableObj.upload()
605
- firedRetry = true
606
- })
607
- }
583
+ if (!firedRetry) $.resumableObj.upload();
584
+ firedRetry = true;
585
+ });
586
+ };
608
587
  $.bootstrap = function () {
609
- $.abort()
610
- _error = false
588
+ $.abort();
589
+ _error = false;
611
590
  // Rebuild stack of chunks from file
612
- $.chunks = []
613
- $._prevProgress = 0
614
- const round = $.getOpt('forceChunkSize') ? Math.ceil : Math.floor
615
- const maxOffset = Math.max(round($.file.size / $.getOpt('chunkSize')), 1)
591
+ $.chunks = [];
592
+ $._prevProgress = 0;
593
+ const round = $.getOpt('forceChunkSize') ? Math.ceil : Math.floor;
594
+ const maxOffset = Math.max(round($.file.size / $.getOpt('chunkSize')), 1);
616
595
  for (let offset = 0; offset < maxOffset; offset++) {
617
596
  (function (offset) {
618
597
  window.setTimeout(function () {
619
- $.chunks.push(
620
- new ResumableChunk($.resumableObj, $, offset, chunkEvent)
621
- )
622
- $.resumableObj.fire('chunkingProgress', $, offset / maxOffset)
623
- }, 0)
624
- })(offset)
598
+ $.chunks.push(new ResumableChunk($.resumableObj, $, offset, chunkEvent));
599
+ $.resumableObj.fire('chunkingProgress', $, offset / maxOffset);
600
+ }, 0);
601
+ })(offset);
625
602
  }
626
603
  window.setTimeout(function () {
627
- $.resumableObj.fire('chunkingComplete', $)
628
- }, 0)
629
- }
604
+ $.resumableObj.fire('chunkingComplete', $);
605
+ }, 0);
606
+ };
630
607
  $.progress = function () {
631
- if (_error) return 1
608
+ if (_error) return 1;
632
609
  // Sum up progress across everything
633
- let ret = 0
634
- let error = false
610
+ let ret = 0;
611
+ let error = false;
635
612
  $h.each($.chunks, function (c) {
636
- if (c.status() == 'error') error = true
637
- ret += c.progress(true) // get chunk progress relative to entire file
638
- })
639
- ret = error ? 1 : ret > 0.99999 ? 1 : ret
640
- ret = Math.max($._prevProgress, ret) // We don't want to lose percentages when an upload is paused
641
- $._prevProgress = ret
642
- return ret
643
- }
613
+ if (c.status() == 'error') error = true;
614
+ ret += c.progress(true); // get chunk progress relative to entire file
615
+ });
616
+ ret = error ? 1 : ret > 0.99999 ? 1 : ret;
617
+ ret = Math.max($._prevProgress, ret); // We don't want to lose percentages when an upload is paused
618
+ $._prevProgress = ret;
619
+ return ret;
620
+ };
644
621
  $.isUploading = function () {
645
- let uploading = false
622
+ let uploading = false;
646
623
  $h.each($.chunks, function (chunk) {
647
624
  if (chunk.status() == 'uploading') {
648
- uploading = true
649
- return false
625
+ uploading = true;
626
+ return false;
650
627
  }
651
- })
652
- return uploading
653
- }
628
+ });
629
+ return uploading;
630
+ };
654
631
  $.isComplete = function () {
655
- let outstanding = false
632
+ let outstanding = false;
656
633
  if ($.preprocessState === 1) {
657
- return false
634
+ return false;
658
635
  }
659
636
  $h.each($.chunks, function (chunk) {
660
- const status = chunk.status()
661
- if (
662
- status == 'pending' ||
663
- status == 'uploading' ||
664
- chunk.preprocessState === 1
665
- ) {
666
- outstanding = true
667
- return false
637
+ const status = chunk.status();
638
+ if (status == 'pending' || status == 'uploading' || chunk.preprocessState === 1) {
639
+ outstanding = true;
640
+ return false;
668
641
  }
669
- })
670
- return !outstanding
671
- }
642
+ });
643
+ return !outstanding;
644
+ };
672
645
  $.pause = function (pause) {
673
646
  if (typeof pause === 'undefined') {
674
- $._pause = !$._pause
647
+ $._pause = !$._pause;
675
648
  } else {
676
- $._pause = pause
649
+ $._pause = pause;
677
650
  }
678
- }
651
+ };
679
652
  $.isPaused = function () {
680
- return $._pause
681
- }
653
+ return $._pause;
654
+ };
682
655
  $.preprocessFinished = function () {
683
- $.preprocessState = 2
684
- $.upload()
685
- }
656
+ $.preprocessState = 2;
657
+ $.upload();
658
+ };
686
659
  $.upload = function () {
687
- let found = false
660
+ let found = false;
688
661
  if ($.isPaused() === false) {
689
- const preprocess = $.getOpt('preprocessFile')
662
+ const preprocess = $.getOpt('preprocessFile');
690
663
  if (typeof preprocess === 'function') {
691
664
  switch ($.preprocessState) {
692
665
  case 0:
693
- $.preprocessState = 1
694
- preprocess($)
695
- return true
666
+ $.preprocessState = 1;
667
+ preprocess($);
668
+ return true;
696
669
  case 1:
697
- return true
670
+ return true;
698
671
  case 2:
699
- break
672
+ break;
700
673
  }
701
674
  }
702
675
  $h.each($.chunks, function (chunk) {
703
676
  if (chunk.status() == 'pending' && chunk.preprocessState !== 1) {
704
- chunk.send()
705
- found = true
706
- return false
677
+ chunk.send();
678
+ found = true;
679
+ return false;
707
680
  }
708
- })
681
+ });
709
682
  }
710
- return found
711
- }
683
+ return found;
684
+ };
712
685
  $.markChunksCompleted = function (chunkNumber) {
713
686
  if (!$.chunks || $.chunks.length <= chunkNumber) {
714
- return
687
+ return;
715
688
  }
716
689
  for (let num = 0; num < chunkNumber; num++) {
717
- $.chunks[num].markComplete = true
690
+ $.chunks[num].markComplete = true;
718
691
  }
719
- }
692
+ };
720
693
 
721
694
  // Bootstrap and return
722
- $.resumableObj.fire('chunkingStart', $)
723
- $.bootstrap()
724
- return this
695
+ $.resumableObj.fire('chunkingStart', $);
696
+ $.bootstrap();
697
+ return this;
725
698
  }
726
699
 
727
- function ResumableChunk (resumableObj, fileObj, offset, callback) {
728
- const $ = this
729
- $.opts = {}
730
- $.getOpt = resumableObj.getOpt
731
- $.resumableObj = resumableObj
732
- $.fileObj = fileObj
733
- $.fileObjSize = fileObj.size
734
- $.fileObjType = fileObj.file.type
735
- $.offset = offset
736
- $.callback = callback
737
- $.lastProgressCallback = new Date()
738
- $.tested = false
739
- $.retries = 0
740
- $.pendingRetry = false
741
- $.preprocessState = 0 // 0 = unprocessed, 1 = processing, 2 = finished
742
- $.markComplete = false
700
+ function ResumableChunk(resumableObj, fileObj, offset, callback) {
701
+ const $ = this;
702
+ $.opts = {};
703
+ $.getOpt = resumableObj.getOpt;
704
+ $.resumableObj = resumableObj;
705
+ $.fileObj = fileObj;
706
+ $.fileObjSize = fileObj.size;
707
+ $.fileObjType = fileObj.file.type;
708
+ $.offset = offset;
709
+ $.callback = callback;
710
+ $.lastProgressCallback = new Date();
711
+ $.tested = false;
712
+ $.retries = 0;
713
+ $.pendingRetry = false;
714
+ $.preprocessState = 0; // 0 = unprocessed, 1 = processing, 2 = finished
715
+ $.markComplete = false;
743
716
 
744
717
  // Computed properties
745
- const chunkSize = $.getOpt('chunkSize')
746
- $.loaded = 0
747
- $.startByte = $.offset * chunkSize
748
- $.endByte = Math.min($.fileObjSize, ($.offset + 1) * chunkSize)
718
+ const chunkSize = $.getOpt('chunkSize');
719
+ $.loaded = 0;
720
+ $.startByte = $.offset * chunkSize;
721
+ $.endByte = Math.min($.fileObjSize, ($.offset + 1) * chunkSize);
749
722
  if ($.fileObjSize - $.endByte < chunkSize && !$.getOpt('forceChunkSize')) {
750
723
  // The last chunk will be bigger than the chunk size, but less than 2*chunkSize
751
- $.endByte = $.fileObjSize
724
+ $.endByte = $.fileObjSize;
752
725
  }
753
- $.xhr = null
726
+ $.xhr = null;
754
727
 
755
728
  // test() makes a GET request without any data to see if the chunk has already been uploaded in a previous session
756
729
  $.test = function () {
757
730
  // Set up request and listen for event
758
- $.xhr = new XMLHttpRequest()
731
+ $.xhr = new XMLHttpRequest();
759
732
 
760
733
  const testHandler = function (e) {
761
- $.tested = true
762
- const status = $.status()
734
+ $.tested = true;
735
+ const status = $.status();
763
736
  if (status == 'success') {
764
- $.callback(status, $.message())
765
- $.resumableObj.uploadNextChunk()
737
+ $.callback(status, $.message());
738
+ $.resumableObj.uploadNextChunk();
766
739
  } else {
767
- $.send()
740
+ $.send();
768
741
  }
769
- }
770
- $.xhr.addEventListener('load', testHandler, false)
771
- $.xhr.addEventListener('error', testHandler, false)
772
- $.xhr.addEventListener('timeout', testHandler, false)
742
+ };
743
+ $.xhr.addEventListener('load', testHandler, false);
744
+ $.xhr.addEventListener('error', testHandler, false);
745
+ $.xhr.addEventListener('timeout', testHandler, false);
773
746
 
774
747
  // Add data from the query options
775
- let params = []
776
- const parameterNamespace = $.getOpt('parameterNamespace')
777
- let customQuery = $.getOpt('query')
778
- if (typeof customQuery === 'function') customQuery = customQuery($.fileObj, $)
748
+ let params = [];
749
+ const parameterNamespace = $.getOpt('parameterNamespace');
750
+ let customQuery = $.getOpt('query');
751
+ if (typeof customQuery === 'function') customQuery = customQuery($.fileObj, $);
779
752
  $h.each(customQuery, function (k, v) {
780
- params.push(
781
- [encodeURIComponent(parameterNamespace + k), encodeURIComponent(v)].join(
782
- '='
783
- )
784
- )
785
- })
753
+ params.push([encodeURIComponent(parameterNamespace + k), encodeURIComponent(v)].join('='));
754
+ });
786
755
  // Add extra data to identify chunk
787
756
  params = params.concat(
788
757
  [
@@ -795,105 +764,99 @@ const XMLHttpRequest = require('xhr2').XMLHttpRequest;
795
764
  ['identifierParameterName', $.fileObj.uniqueIdentifier],
796
765
  ['fileNameParameterName', $.fileObj.fileName],
797
766
  ['relativePathParameterName', $.fileObj.relativePath],
798
- ['totalChunksParameterName', $.fileObj.chunks.length]
767
+ ['totalChunksParameterName', $.fileObj.chunks.length],
799
768
  ]
800
769
  .filter(function (pair) {
801
770
  // include items that resolve to truthy values
802
771
  // i.e. exclude false, null, undefined and empty strings
803
- return $.getOpt(pair[0])
772
+ return $.getOpt(pair[0]);
804
773
  })
805
774
  .map(function (pair) {
806
775
  // map each key/value pair to its final form
807
- return [
808
- parameterNamespace + $.getOpt(pair[0]),
809
- encodeURIComponent(pair[1])
810
- ].join('=')
811
- })
812
- )
776
+ return [parameterNamespace + $.getOpt(pair[0]), encodeURIComponent(pair[1])].join('=');
777
+ }),
778
+ );
813
779
  // Append the relevant chunk and send it
814
- $.xhr.open($.getOpt('testMethod'), $h.getTarget('test', params))
815
- $.xhr.timeout = $.getOpt('xhrTimeout')
816
- $.xhr.withCredentials = $.getOpt('withCredentials')
780
+ $.xhr.open($.getOpt('testMethod'), $h.getTarget('test', params));
781
+ $.xhr.timeout = $.getOpt('xhrTimeout');
782
+ $.xhr.withCredentials = $.getOpt('withCredentials');
817
783
  // Add data from header options
818
- let customHeaders = $.getOpt('headers')
784
+ let customHeaders = $.getOpt('headers');
819
785
  if (typeof customHeaders === 'function') {
820
- customHeaders = customHeaders($.fileObj, $)
786
+ customHeaders = customHeaders($.fileObj, $);
821
787
  }
822
788
  $h.each(customHeaders, function (k, v) {
823
- $.xhr.setRequestHeader(k, v)
824
- })
825
- $.xhr.send(null)
826
- }
789
+ $.xhr.setRequestHeader(k, v);
790
+ });
791
+ $.xhr.send(null);
792
+ };
827
793
 
828
794
  $.preprocessFinished = function () {
829
- $.preprocessState = 2
830
- $.send()
831
- }
795
+ $.preprocessState = 2;
796
+ $.send();
797
+ };
832
798
 
833
799
  // send() uploads the actual data in a POST call
834
800
  $.send = function () {
835
- const preprocess = $.getOpt('preprocess')
801
+ const preprocess = $.getOpt('preprocess');
836
802
  if (typeof preprocess === 'function') {
837
803
  switch ($.preprocessState) {
838
804
  case 0:
839
- $.preprocessState = 1
840
- preprocess($)
841
- return
805
+ $.preprocessState = 1;
806
+ preprocess($);
807
+ return;
842
808
  case 1:
843
- return
809
+ return;
844
810
  case 2:
845
- break
811
+ break;
846
812
  }
847
813
  }
848
814
  if ($.getOpt('testChunks') && !$.tested) {
849
- $.test()
850
- return
815
+ $.test();
816
+ return;
851
817
  }
852
818
 
853
819
  // Set up request and listen for event
854
- $.xhr = new XMLHttpRequest()
820
+ $.xhr = new XMLHttpRequest();
855
821
 
856
822
  // Progress
857
823
  $.xhr.upload.addEventListener(
858
824
  'progress',
859
825
  function (e) {
860
- if (
861
- new Date() - $.lastProgressCallback >
862
- $.getOpt('throttleProgressCallbacks') * 1000
863
- ) {
864
- $.callback('progress')
865
- $.lastProgressCallback = new Date()
826
+ if (new Date() - $.lastProgressCallback > $.getOpt('throttleProgressCallbacks') * 1000) {
827
+ $.callback('progress');
828
+ $.lastProgressCallback = new Date();
866
829
  }
867
- $.loaded = e.loaded || 0
830
+ $.loaded = e.loaded || 0;
868
831
  },
869
- false
870
- )
871
- $.loaded = 0
872
- $.pendingRetry = false
873
- $.callback('progress')
832
+ false,
833
+ );
834
+ $.loaded = 0;
835
+ $.pendingRetry = false;
836
+ $.callback('progress');
874
837
 
875
838
  // Done (either done, failed or retry)
876
839
  const doneHandler = function (e) {
877
- const status = $.status()
840
+ const status = $.status();
878
841
  if (status == 'success' || status == 'error') {
879
- $.callback(status, $.message())
880
- $.resumableObj.uploadNextChunk()
842
+ $.callback(status, $.message());
843
+ $.resumableObj.uploadNextChunk();
881
844
  } else {
882
- $.callback('retry', $.message())
883
- $.abort()
884
- $.retries++
885
- const retryInterval = $.getOpt('chunkRetryInterval')
845
+ $.callback('retry', $.message());
846
+ $.abort();
847
+ $.retries++;
848
+ const retryInterval = $.getOpt('chunkRetryInterval');
886
849
  if (retryInterval !== undefined) {
887
- $.pendingRetry = true
888
- setTimeout($.send, retryInterval)
850
+ $.pendingRetry = true;
851
+ setTimeout($.send, retryInterval);
889
852
  } else {
890
- $.send()
853
+ $.send();
891
854
  }
892
855
  }
893
- }
894
- $.xhr.addEventListener('load', doneHandler, false)
895
- $.xhr.addEventListener('error', doneHandler, false)
896
- $.xhr.addEventListener('timeout', doneHandler, false)
856
+ };
857
+ $.xhr.addEventListener('load', doneHandler, false);
858
+ $.xhr.addEventListener('error', doneHandler, false);
859
+ $.xhr.addEventListener('timeout', doneHandler, false);
897
860
 
898
861
  // Set up the basic query data from Resumable
899
862
  const query = [
@@ -905,24 +868,24 @@ const XMLHttpRequest = require('xhr2').XMLHttpRequest;
905
868
  ['identifierParameterName', $.fileObj.uniqueIdentifier],
906
869
  ['fileNameParameterName', $.fileObj.fileName],
907
870
  ['relativePathParameterName', $.fileObj.relativePath],
908
- ['totalChunksParameterName', $.fileObj.chunks.length]
871
+ ['totalChunksParameterName', $.fileObj.chunks.length],
909
872
  ]
910
873
  .filter(function (pair) {
911
874
  // include items that resolve to truthy values
912
875
  // i.e. exclude false, null, undefined and empty strings
913
- return $.getOpt(pair[0])
876
+ return $.getOpt(pair[0]);
914
877
  })
915
878
  .reduce(function (query, pair) {
916
879
  // assign query key/value
917
- query[$.getOpt(pair[0])] = pair[1]
918
- return query
919
- }, {})
880
+ query[$.getOpt(pair[0])] = pair[1];
881
+ return query;
882
+ }, {});
920
883
  // Mix in custom data
921
- let customQuery = $.getOpt('query')
922
- if (typeof customQuery === 'function') customQuery = customQuery($.fileObj, $)
884
+ let customQuery = $.getOpt('query');
885
+ if (typeof customQuery === 'function') customQuery = customQuery($.fileObj, $);
923
886
  $h.each(customQuery, function (k, v) {
924
- query[k] = v
925
- })
887
+ query[k] = v;
888
+ });
926
889
 
927
890
  const func = $.fileObj.file.slice
928
891
  ? 'slice'
@@ -930,385 +893,364 @@ const XMLHttpRequest = require('xhr2').XMLHttpRequest;
930
893
  ? 'mozSlice'
931
894
  : $.fileObj.file.webkitSlice
932
895
  ? 'webkitSlice'
933
- : 'slice'
896
+ : 'slice';
934
897
  const bytes = $.fileObj.file[func](
935
898
  $.startByte,
936
899
  $.endByte,
937
- $.getOpt('setChunkTypeFromFile') ? $.fileObj.file.type : ''
938
- )
939
- let data = null
940
- const params = []
900
+ $.getOpt('setChunkTypeFromFile') ? $.fileObj.file.type : '',
901
+ );
902
+ let data = null;
903
+ const params = [];
941
904
 
942
- const parameterNamespace = $.getOpt('parameterNamespace')
905
+ const parameterNamespace = $.getOpt('parameterNamespace');
943
906
  if ($.getOpt('method') === 'octet') {
944
907
  // Add data from the query options
945
- data = bytes
908
+ data = bytes;
946
909
  $h.each(query, function (k, v) {
947
- params.push(
948
- [
949
- encodeURIComponent(parameterNamespace + k),
950
- encodeURIComponent(v)
951
- ].join('=')
952
- )
953
- })
910
+ params.push([encodeURIComponent(parameterNamespace + k), encodeURIComponent(v)].join('='));
911
+ });
954
912
  } else {
955
913
  // Add data from the query options
956
- data = new FormData()
914
+ data = new FormData();
957
915
  $h.each(query, function (k, v) {
958
- data.append(parameterNamespace + k, v)
959
- params.push(
960
- [
961
- encodeURIComponent(parameterNamespace + k),
962
- encodeURIComponent(v)
963
- ].join('=')
964
- )
965
- })
916
+ data.append(parameterNamespace + k, v);
917
+ params.push([encodeURIComponent(parameterNamespace + k), encodeURIComponent(v)].join('='));
918
+ });
966
919
  if ($.getOpt('chunkFormat') == 'blob') {
967
- data.append(
968
- parameterNamespace + $.getOpt('fileParameterName'),
969
- bytes,
970
- $.fileObj.fileName
971
- )
920
+ data.append(parameterNamespace + $.getOpt('fileParameterName'), bytes, $.fileObj.fileName);
972
921
  } else if ($.getOpt('chunkFormat') == 'base64') {
973
- const fr = new FileReader()
922
+ const fr = new FileReader();
974
923
  fr.onload = function (e) {
975
- data.append(
976
- parameterNamespace + $.getOpt('fileParameterName'),
977
- fr.result
978
- )
979
- $.xhr.send(data)
980
- }
981
- fr.readAsDataURL(bytes)
924
+ data.append(parameterNamespace + $.getOpt('fileParameterName'), fr.result);
925
+ $.xhr.send(data);
926
+ };
927
+ fr.readAsDataURL(bytes);
982
928
  }
983
929
  }
984
930
 
985
- const target = $h.getTarget('upload', params)
986
- const method = $.getOpt('uploadMethod')
931
+ const target = $h.getTarget('upload', params);
932
+ const method = $.getOpt('uploadMethod');
987
933
 
988
- $.xhr.open(method, target)
934
+ $.xhr.open(method, target);
989
935
  if ($.getOpt('method') === 'octet') {
990
- $.xhr.setRequestHeader('Content-Type', 'application/octet-stream')
936
+ $.xhr.setRequestHeader('Content-Type', 'application/octet-stream');
991
937
  }
992
- $.xhr.timeout = $.getOpt('xhrTimeout')
993
- $.xhr.withCredentials = $.getOpt('withCredentials')
938
+ $.xhr.timeout = $.getOpt('xhrTimeout');
939
+ $.xhr.withCredentials = $.getOpt('withCredentials');
994
940
  // Add data from header options
995
- let customHeaders = $.getOpt('headers')
941
+ let customHeaders = $.getOpt('headers');
996
942
  if (typeof customHeaders === 'function') {
997
- customHeaders = customHeaders($.fileObj, $)
943
+ customHeaders = customHeaders($.fileObj, $);
998
944
  }
999
945
 
1000
946
  $h.each(customHeaders, function (k, v) {
1001
- $.xhr.setRequestHeader(k, v)
1002
- })
947
+ $.xhr.setRequestHeader(k, v);
948
+ });
1003
949
 
1004
950
  if ($.getOpt('chunkFormat') == 'blob') {
1005
951
  if (data.on) {
1006
- const chunks = []
952
+ const chunks = [];
1007
953
  data.on('data', (chunk) => {
1008
- chunks.push(chunk)
1009
- })
954
+ chunks.push(chunk);
955
+ });
1010
956
  data.on('end', () => {
1011
- $.xhr.send(Buffer.concat(chunks))
1012
- })
957
+ $.xhr.send(Buffer.concat(chunks));
958
+ });
1013
959
  data.on('error', (error) => {
1014
- doneHandler()
1015
- })
1016
- } else $.xhr.send(data)
960
+ doneHandler();
961
+ });
962
+ } else $.xhr.send(data);
1017
963
  }
1018
- }
964
+ };
1019
965
  $.abort = function () {
1020
966
  // Abort and reset
1021
- if ($.xhr) $.xhr.abort()
1022
- $.xhr = null
1023
- }
967
+ if ($.xhr) $.xhr.abort();
968
+ $.xhr = null;
969
+ };
1024
970
  $.status = function () {
1025
971
  // Returns: 'pending', 'uploading', 'success', 'error'
1026
972
  if ($.pendingRetry) {
1027
973
  // if pending retry then that's effectively the same as actively uploading,
1028
974
  // there might just be a slight delay before the retry starts
1029
- return 'uploading'
975
+ return 'uploading';
1030
976
  } else if ($.markComplete) {
1031
- return 'success'
977
+ return 'success';
1032
978
  } else if (!$.xhr) {
1033
- return 'pending'
979
+ return 'pending';
1034
980
  } else if ($.xhr.readyState < 4) {
1035
981
  // Status is really 'OPENED', 'HEADERS_RECEIVED' or 'LOADING' - meaning that stuff is happening
1036
- return 'uploading'
982
+ return 'uploading';
1037
983
  } else {
1038
984
  if ($.xhr.status == 200 || $.xhr.status == 201) {
1039
985
  // HTTP 200, 201 (created)
1040
- return 'success'
986
+ return 'success';
1041
987
  } else if (
1042
988
  $h.contains($.getOpt('permanentErrors'), $.xhr.status) ||
1043
- $.retries >= $.getOpt('maxChunkRetries')
989
+ $.retries >= $.getOpt('maxChunkRetries')
1044
990
  ) {
1045
991
  // HTTP 400, 404, 409, 415, 500, 501 (permanent error)
1046
- return 'error'
992
+ return 'error';
1047
993
  } else {
1048
994
  // this should never happen, but we'll reset and queue a retry
1049
995
  // a likely case for this would be 503 service unavailable
1050
- $.abort()
1051
- return 'pending'
996
+ $.abort();
997
+ return 'pending';
1052
998
  }
1053
999
  }
1054
- }
1000
+ };
1055
1001
  $.message = function () {
1056
- return $.xhr ? $.xhr.responseText : ''
1057
- }
1002
+ return $.xhr ? $.xhr.responseText : '';
1003
+ };
1058
1004
  $.progress = function (relative) {
1059
- if (typeof relative === 'undefined') relative = false
1060
- let factor = relative ? ($.endByte - $.startByte) / $.fileObjSize : 1
1061
- if ($.pendingRetry) return 0
1062
- if ((!$.xhr || !$.xhr.status) && !$.markComplete) factor *= 0.95
1063
- const s = $.status()
1005
+ if (typeof relative === 'undefined') relative = false;
1006
+ let factor = relative ? ($.endByte - $.startByte) / $.fileObjSize : 1;
1007
+ if ($.pendingRetry) return 0;
1008
+ if ((!$.xhr || !$.xhr.status) && !$.markComplete) factor *= 0.95;
1009
+ const s = $.status();
1064
1010
  switch (s) {
1065
1011
  case 'success':
1066
1012
  case 'error':
1067
- return 1 * factor
1013
+ return 1 * factor;
1068
1014
  case 'pending':
1069
- return 0 * factor
1015
+ return 0 * factor;
1070
1016
  default:
1071
- return ($.loaded / ($.endByte - $.startByte)) * factor
1017
+ return ($.loaded / ($.endByte - $.startByte)) * factor;
1072
1018
  }
1073
- }
1074
- return this
1019
+ };
1020
+ return this;
1075
1021
  }
1076
1022
 
1077
1023
  // QUEUE
1078
1024
  $.uploadNextChunk = function () {
1079
- let found = false
1025
+ let found = false;
1080
1026
 
1081
1027
  // In some cases (such as videos) it's really handy to upload the first
1082
1028
  // and last chunk of a file quickly; this let's the server check the file's
1083
1029
  // metadata and determine if there's even a point in continuing.
1084
1030
  if ($.getOpt('prioritizeFirstAndLastChunk')) {
1085
1031
  $h.each($.files, function (file) {
1086
- if (
1087
- file.chunks.length &&
1088
- file.chunks[0].status() == 'pending' &&
1089
- file.chunks[0].preprocessState === 0
1090
- ) {
1091
- file.chunks[0].send()
1092
- found = true
1093
- return false
1032
+ if (file.chunks.length && file.chunks[0].status() == 'pending' && file.chunks[0].preprocessState === 0) {
1033
+ file.chunks[0].send();
1034
+ found = true;
1035
+ return false;
1094
1036
  }
1095
1037
  if (
1096
1038
  file.chunks.length > 1 &&
1097
- file.chunks[file.chunks.length - 1].status() == 'pending' &&
1098
- file.chunks[file.chunks.length - 1].preprocessState === 0
1039
+ file.chunks[file.chunks.length - 1].status() == 'pending' &&
1040
+ file.chunks[file.chunks.length - 1].preprocessState === 0
1099
1041
  ) {
1100
- file.chunks[file.chunks.length - 1].send()
1101
- found = true
1102
- return false
1042
+ file.chunks[file.chunks.length - 1].send();
1043
+ found = true;
1044
+ return false;
1103
1045
  }
1104
- })
1105
- if (found) return true
1046
+ });
1047
+ if (found) return true;
1106
1048
  }
1107
1049
 
1108
1050
  // Now, simply look for the next, best thing to upload
1109
1051
  $h.each($.files, function (file) {
1110
- found = file.upload()
1111
- if (found) return false
1112
- })
1113
- if (found) return true
1052
+ found = file.upload();
1053
+ if (found) return false;
1054
+ });
1055
+ if (found) return true;
1114
1056
 
1115
1057
  // The are no more outstanding chunks to upload, check is everything is done
1116
- let outstanding = false
1058
+ let outstanding = false;
1117
1059
  $h.each($.files, function (file) {
1118
1060
  if (!file.isComplete()) {
1119
- outstanding = true
1120
- return false
1061
+ outstanding = true;
1062
+ return false;
1121
1063
  }
1122
- })
1064
+ });
1123
1065
  if (!outstanding) {
1124
1066
  // All chunks have been uploaded, complete
1125
- $.fire('complete')
1067
+ $.fire('complete');
1126
1068
  }
1127
- return false
1128
- }
1069
+ return false;
1070
+ };
1129
1071
 
1130
1072
  // PUBLIC METHODS FOR RESUMABLE.JS
1131
1073
  $.assignBrowse = function (domNodes, isDirectory) {
1132
- if (typeof domNodes.length === 'undefined') domNodes = [domNodes]
1074
+ if (typeof domNodes.length === 'undefined') domNodes = [domNodes];
1133
1075
  $h.each(domNodes, function (domNode) {
1134
- let input
1076
+ let input;
1135
1077
  if (domNode.tagName === 'INPUT' && domNode.type === 'file') {
1136
- input = domNode
1078
+ input = domNode;
1137
1079
  } else {
1138
- input = document.createElement('input')
1139
- input.setAttribute('type', 'file')
1140
- input.style.display = 'none'
1080
+ input = document.createElement('input');
1081
+ input.setAttribute('type', 'file');
1082
+ input.style.display = 'none';
1141
1083
  domNode.addEventListener(
1142
1084
  'click',
1143
1085
  function () {
1144
- input.style.opacity = 0
1145
- input.style.display = 'block'
1146
- input.focus()
1147
- input.click()
1148
- input.style.display = 'none'
1086
+ input.style.opacity = 0;
1087
+ input.style.display = 'block';
1088
+ input.focus();
1089
+ input.click();
1090
+ input.style.display = 'none';
1149
1091
  },
1150
- false
1151
- )
1152
- domNode.appendChild(input)
1092
+ false,
1093
+ );
1094
+ domNode.appendChild(input);
1153
1095
  }
1154
- const maxFiles = $.getOpt('maxFiles')
1096
+ const maxFiles = $.getOpt('maxFiles');
1155
1097
  if (typeof maxFiles === 'undefined' || maxFiles != 1) {
1156
- input.setAttribute('multiple', 'multiple')
1098
+ input.setAttribute('multiple', 'multiple');
1157
1099
  } else {
1158
- input.removeAttribute('multiple')
1100
+ input.removeAttribute('multiple');
1159
1101
  }
1160
1102
  if (isDirectory) {
1161
- input.setAttribute('webkitdirectory', 'webkitdirectory')
1103
+ input.setAttribute('webkitdirectory', 'webkitdirectory');
1162
1104
  } else {
1163
- input.removeAttribute('webkitdirectory')
1105
+ input.removeAttribute('webkitdirectory');
1164
1106
  }
1165
- const fileTypes = $.getOpt('fileType')
1107
+ const fileTypes = $.getOpt('fileType');
1166
1108
  if (typeof fileTypes !== 'undefined' && fileTypes.length >= 1) {
1167
1109
  input.setAttribute(
1168
1110
  'accept',
1169
1111
  fileTypes
1170
1112
  .map(function (e) {
1171
- e = e.replace(/\s/g, '').toLowerCase()
1113
+ e = e.replace(/\s/g, '').toLowerCase();
1172
1114
  if (e.match(/^[^.][^/]+$/)) {
1173
- e = '.' + e
1115
+ e = '.' + e;
1174
1116
  }
1175
- return e
1117
+ return e;
1176
1118
  })
1177
- .join(',')
1178
- )
1119
+ .join(','),
1120
+ );
1179
1121
  } else {
1180
- input.removeAttribute('accept')
1122
+ input.removeAttribute('accept');
1181
1123
  }
1182
1124
  // When new files are added, simply append them to the overall list
1183
1125
  input.addEventListener(
1184
1126
  'change',
1185
1127
  function (e) {
1186
- appendFilesFromFileList(e.target.files, e)
1187
- const clearInput = $.getOpt('clearInput')
1128
+ appendFilesFromFileList(e.target.files, e);
1129
+ const clearInput = $.getOpt('clearInput');
1188
1130
  if (clearInput) {
1189
- e.target.value = ''
1131
+ e.target.value = '';
1190
1132
  }
1191
1133
  },
1192
- false
1193
- )
1194
- })
1195
- }
1134
+ false,
1135
+ );
1136
+ });
1137
+ };
1196
1138
  $.assignDrop = function (domNodes) {
1197
- if (typeof domNodes.length === 'undefined') domNodes = [domNodes]
1139
+ if (typeof domNodes.length === 'undefined') domNodes = [domNodes];
1198
1140
 
1199
1141
  $h.each(domNodes, function (domNode) {
1200
- domNode.addEventListener('dragover', onDragOverEnter, false)
1201
- domNode.addEventListener('dragenter', onDragOverEnter, false)
1202
- domNode.addEventListener('dragleave', onDragLeave, false)
1203
- domNode.addEventListener('drop', onDrop, false)
1204
- })
1205
- }
1142
+ domNode.addEventListener('dragover', onDragOverEnter, false);
1143
+ domNode.addEventListener('dragenter', onDragOverEnter, false);
1144
+ domNode.addEventListener('dragleave', onDragLeave, false);
1145
+ domNode.addEventListener('drop', onDrop, false);
1146
+ });
1147
+ };
1206
1148
  $.unAssignDrop = function (domNodes) {
1207
- if (typeof domNodes.length === 'undefined') domNodes = [domNodes]
1149
+ if (typeof domNodes.length === 'undefined') domNodes = [domNodes];
1208
1150
 
1209
1151
  $h.each(domNodes, function (domNode) {
1210
- domNode.removeEventListener('dragover', onDragOverEnter)
1211
- domNode.removeEventListener('dragenter', onDragOverEnter)
1212
- domNode.removeEventListener('dragleave', onDragLeave)
1213
- domNode.removeEventListener('drop', onDrop)
1214
- })
1215
- }
1152
+ domNode.removeEventListener('dragover', onDragOverEnter);
1153
+ domNode.removeEventListener('dragenter', onDragOverEnter);
1154
+ domNode.removeEventListener('dragleave', onDragLeave);
1155
+ domNode.removeEventListener('drop', onDrop);
1156
+ });
1157
+ };
1216
1158
  $.isUploading = function () {
1217
- let uploading = false
1159
+ let uploading = false;
1218
1160
  $h.each($.files, function (file) {
1219
1161
  if (file.isUploading()) {
1220
- uploading = true
1221
- return false
1162
+ uploading = true;
1163
+ return false;
1222
1164
  }
1223
- })
1224
- return uploading
1225
- }
1165
+ });
1166
+ return uploading;
1167
+ };
1226
1168
  $.upload = function () {
1227
1169
  // Make sure we don't start too many uploads at once
1228
- if ($.isUploading()) return
1170
+ if ($.isUploading()) return;
1229
1171
  // Kick off the queue
1230
- $.fire('uploadStart')
1172
+ $.fire('uploadStart');
1231
1173
  for (let num = 1; num <= $.getOpt('simultaneousUploads'); num++) {
1232
- $.uploadNextChunk()
1174
+ $.uploadNextChunk();
1233
1175
  }
1234
- }
1176
+ };
1235
1177
  $.pause = function () {
1236
1178
  // Resume all chunks currently being uploaded
1237
1179
  $h.each($.files, function (file) {
1238
- file.abort()
1239
- })
1240
- $.fire('pause')
1241
- }
1180
+ file.abort();
1181
+ });
1182
+ $.fire('pause');
1183
+ };
1242
1184
  $.cancel = function () {
1243
- $.fire('beforeCancel')
1185
+ $.fire('beforeCancel');
1244
1186
  for (let i = $.files.length - 1; i >= 0; i--) {
1245
- $.files[i].cancel()
1187
+ $.files[i].cancel();
1246
1188
  }
1247
- $.fire('cancel')
1248
- }
1189
+ $.fire('cancel');
1190
+ };
1249
1191
  $.progress = function () {
1250
- let totalDone = 0
1251
- let totalSize = 0
1192
+ let totalDone = 0;
1193
+ let totalSize = 0;
1252
1194
  // Resume all chunks currently being uploaded
1253
1195
  $h.each($.files, function (file) {
1254
- totalDone += file.progress() * file.size
1255
- totalSize += file.size
1256
- })
1257
- return totalSize > 0 ? totalDone / totalSize : 0
1258
- }
1196
+ totalDone += file.progress() * file.size;
1197
+ totalSize += file.size;
1198
+ });
1199
+ return totalSize > 0 ? totalDone / totalSize : 0;
1200
+ };
1259
1201
  $.addFile = function (file, event) {
1260
- appendFilesFromFileList([file], event)
1261
- }
1202
+ appendFilesFromFileList([file], event);
1203
+ };
1262
1204
  $.addFiles = function (files, event) {
1263
- appendFilesFromFileList(files, event)
1264
- }
1205
+ appendFilesFromFileList(files, event);
1206
+ };
1265
1207
  $.removeFile = function (file) {
1266
1208
  for (let i = $.files.length - 1; i >= 0; i--) {
1267
1209
  if ($.files[i] === file) {
1268
- $.files.splice(i, 1)
1210
+ $.files.splice(i, 1);
1269
1211
  }
1270
1212
  }
1271
- }
1213
+ };
1272
1214
  $.getFromUniqueIdentifier = function (uniqueIdentifier) {
1273
- let ret = false
1215
+ let ret = false;
1274
1216
  $h.each($.files, function (f) {
1275
- if (f.uniqueIdentifier == uniqueIdentifier) ret = f
1276
- })
1277
- return ret
1278
- }
1217
+ if (f.uniqueIdentifier == uniqueIdentifier) ret = f;
1218
+ });
1219
+ return ret;
1220
+ };
1279
1221
  $.getSize = function () {
1280
- let totalSize = 0
1222
+ let totalSize = 0;
1281
1223
  $h.each($.files, function (file) {
1282
- totalSize += file.size
1283
- })
1284
- return totalSize
1285
- }
1224
+ totalSize += file.size;
1225
+ });
1226
+ return totalSize;
1227
+ };
1286
1228
  $.handleDropEvent = function (e) {
1287
- onDrop(e)
1288
- }
1229
+ onDrop(e);
1230
+ };
1289
1231
  $.handleChangeEvent = function (e) {
1290
- appendFilesFromFileList(e.target.files, e)
1291
- e.target.value = ''
1292
- }
1232
+ appendFilesFromFileList(e.target.files, e);
1233
+ e.target.value = '';
1234
+ };
1293
1235
  $.updateQuery = function (query) {
1294
- $.opts.query = query
1295
- }
1236
+ $.opts.query = query;
1237
+ };
1296
1238
 
1297
- return this
1298
- }
1239
+ return this;
1240
+ };
1299
1241
 
1300
1242
  // Node.js-style export for Node and Component
1301
1243
  if (typeof module !== 'undefined') {
1302
1244
  // left here for backwards compatibility
1303
- module.exports = Resumable
1304
- module.exports.Resumable = Resumable
1245
+ module.exports = Resumable;
1246
+ module.exports.Resumable = Resumable;
1305
1247
  } else if (typeof define === 'function' && define.amd) {
1306
1248
  // AMD/requirejs: Define the module
1307
1249
  define(function () {
1308
- return Resumable
1309
- })
1250
+ return Resumable;
1251
+ });
1310
1252
  } else {
1311
1253
  // Browser: Expose to window
1312
- window.Resumable = Resumable
1254
+ window.Resumable = Resumable;
1313
1255
  }
1314
- })()
1256
+ })();