@corellium/corellium-cli 1.0.3 → 1.0.6

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