box-content-preview 3.40.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 (339) hide show
  1. package/LICENSE +397 -0
  2. package/README.md +435 -0
  3. package/dist/lib/237.js +34 -0
  4. package/dist/lib/274.js +103 -0
  5. package/dist/lib/2a7d8bfaf2d43f53bd71.mjs +21 -0
  6. package/dist/lib/3683cfffdcbd73685ff2.svg +8 -0
  7. package/dist/lib/42e4e1954f25f8c7b965.svg +6 -0
  8. package/dist/lib/492.js +34 -0
  9. package/dist/lib/59fe962b3e6bd8bfdda7.svg +3 -0
  10. package/dist/lib/5ea0869845becef03a06.svg +4 -0
  11. package/dist/lib/671.js +34 -0
  12. package/dist/lib/76692c54994797ddfb04.svg +3 -0
  13. package/dist/lib/815.js +34 -0
  14. package/dist/lib/8475f8e672ed83e24520.svg +6 -0
  15. package/dist/lib/88.css +23 -0
  16. package/dist/lib/9fb032a1799ca2a1c751.svg +3 -0
  17. package/dist/lib/assets/loading_ghost.gif +0 -0
  18. package/dist/lib/bb72d81b39be40898db2.svg +3 -0
  19. package/dist/lib/cmaps/78-EUC-H.bcmap +0 -0
  20. package/dist/lib/cmaps/78-EUC-V.bcmap +0 -0
  21. package/dist/lib/cmaps/78-H.bcmap +0 -0
  22. package/dist/lib/cmaps/78-RKSJ-H.bcmap +0 -0
  23. package/dist/lib/cmaps/78-RKSJ-V.bcmap +0 -0
  24. package/dist/lib/cmaps/78-V.bcmap +0 -0
  25. package/dist/lib/cmaps/78ms-RKSJ-H.bcmap +0 -0
  26. package/dist/lib/cmaps/78ms-RKSJ-V.bcmap +0 -0
  27. package/dist/lib/cmaps/83pv-RKSJ-H.bcmap +0 -0
  28. package/dist/lib/cmaps/90ms-RKSJ-H.bcmap +0 -0
  29. package/dist/lib/cmaps/90ms-RKSJ-V.bcmap +0 -0
  30. package/dist/lib/cmaps/90msp-RKSJ-H.bcmap +0 -0
  31. package/dist/lib/cmaps/90msp-RKSJ-V.bcmap +0 -0
  32. package/dist/lib/cmaps/90pv-RKSJ-H.bcmap +0 -0
  33. package/dist/lib/cmaps/90pv-RKSJ-V.bcmap +0 -0
  34. package/dist/lib/cmaps/Add-H.bcmap +0 -0
  35. package/dist/lib/cmaps/Add-RKSJ-H.bcmap +0 -0
  36. package/dist/lib/cmaps/Add-RKSJ-V.bcmap +0 -0
  37. package/dist/lib/cmaps/Add-V.bcmap +0 -0
  38. package/dist/lib/cmaps/Adobe-CNS1-0.bcmap +0 -0
  39. package/dist/lib/cmaps/Adobe-CNS1-1.bcmap +0 -0
  40. package/dist/lib/cmaps/Adobe-CNS1-2.bcmap +0 -0
  41. package/dist/lib/cmaps/Adobe-CNS1-3.bcmap +0 -0
  42. package/dist/lib/cmaps/Adobe-CNS1-4.bcmap +0 -0
  43. package/dist/lib/cmaps/Adobe-CNS1-5.bcmap +0 -0
  44. package/dist/lib/cmaps/Adobe-CNS1-6.bcmap +0 -0
  45. package/dist/lib/cmaps/Adobe-CNS1-UCS2.bcmap +0 -0
  46. package/dist/lib/cmaps/Adobe-GB1-0.bcmap +0 -0
  47. package/dist/lib/cmaps/Adobe-GB1-1.bcmap +0 -0
  48. package/dist/lib/cmaps/Adobe-GB1-2.bcmap +0 -0
  49. package/dist/lib/cmaps/Adobe-GB1-3.bcmap +0 -0
  50. package/dist/lib/cmaps/Adobe-GB1-4.bcmap +0 -0
  51. package/dist/lib/cmaps/Adobe-GB1-5.bcmap +0 -0
  52. package/dist/lib/cmaps/Adobe-GB1-UCS2.bcmap +0 -0
  53. package/dist/lib/cmaps/Adobe-Japan1-0.bcmap +0 -0
  54. package/dist/lib/cmaps/Adobe-Japan1-1.bcmap +0 -0
  55. package/dist/lib/cmaps/Adobe-Japan1-2.bcmap +0 -0
  56. package/dist/lib/cmaps/Adobe-Japan1-3.bcmap +0 -0
  57. package/dist/lib/cmaps/Adobe-Japan1-4.bcmap +0 -0
  58. package/dist/lib/cmaps/Adobe-Japan1-5.bcmap +0 -0
  59. package/dist/lib/cmaps/Adobe-Japan1-6.bcmap +0 -0
  60. package/dist/lib/cmaps/Adobe-Japan1-UCS2.bcmap +0 -0
  61. package/dist/lib/cmaps/Adobe-Korea1-0.bcmap +0 -0
  62. package/dist/lib/cmaps/Adobe-Korea1-1.bcmap +0 -0
  63. package/dist/lib/cmaps/Adobe-Korea1-2.bcmap +0 -0
  64. package/dist/lib/cmaps/Adobe-Korea1-UCS2.bcmap +0 -0
  65. package/dist/lib/cmaps/B5-H.bcmap +0 -0
  66. package/dist/lib/cmaps/B5-V.bcmap +0 -0
  67. package/dist/lib/cmaps/B5pc-H.bcmap +0 -0
  68. package/dist/lib/cmaps/B5pc-V.bcmap +0 -0
  69. package/dist/lib/cmaps/CNS-EUC-H.bcmap +0 -0
  70. package/dist/lib/cmaps/CNS-EUC-V.bcmap +0 -0
  71. package/dist/lib/cmaps/CNS1-H.bcmap +0 -0
  72. package/dist/lib/cmaps/CNS1-V.bcmap +0 -0
  73. package/dist/lib/cmaps/CNS2-H.bcmap +0 -0
  74. package/dist/lib/cmaps/CNS2-V.bcmap +3 -0
  75. package/dist/lib/cmaps/ETHK-B5-H.bcmap +0 -0
  76. package/dist/lib/cmaps/ETHK-B5-V.bcmap +0 -0
  77. package/dist/lib/cmaps/ETen-B5-H.bcmap +0 -0
  78. package/dist/lib/cmaps/ETen-B5-V.bcmap +0 -0
  79. package/dist/lib/cmaps/ETenms-B5-H.bcmap +3 -0
  80. package/dist/lib/cmaps/ETenms-B5-V.bcmap +0 -0
  81. package/dist/lib/cmaps/EUC-H.bcmap +0 -0
  82. package/dist/lib/cmaps/EUC-V.bcmap +0 -0
  83. package/dist/lib/cmaps/Ext-H.bcmap +0 -0
  84. package/dist/lib/cmaps/Ext-RKSJ-H.bcmap +0 -0
  85. package/dist/lib/cmaps/Ext-RKSJ-V.bcmap +0 -0
  86. package/dist/lib/cmaps/Ext-V.bcmap +0 -0
  87. package/dist/lib/cmaps/GB-EUC-H.bcmap +0 -0
  88. package/dist/lib/cmaps/GB-EUC-V.bcmap +0 -0
  89. package/dist/lib/cmaps/GB-H.bcmap +4 -0
  90. package/dist/lib/cmaps/GB-V.bcmap +0 -0
  91. package/dist/lib/cmaps/GBK-EUC-H.bcmap +0 -0
  92. package/dist/lib/cmaps/GBK-EUC-V.bcmap +0 -0
  93. package/dist/lib/cmaps/GBK2K-H.bcmap +0 -0
  94. package/dist/lib/cmaps/GBK2K-V.bcmap +0 -0
  95. package/dist/lib/cmaps/GBKp-EUC-H.bcmap +0 -0
  96. package/dist/lib/cmaps/GBKp-EUC-V.bcmap +0 -0
  97. package/dist/lib/cmaps/GBT-EUC-H.bcmap +0 -0
  98. package/dist/lib/cmaps/GBT-EUC-V.bcmap +0 -0
  99. package/dist/lib/cmaps/GBT-H.bcmap +0 -0
  100. package/dist/lib/cmaps/GBT-V.bcmap +0 -0
  101. package/dist/lib/cmaps/GBTpc-EUC-H.bcmap +0 -0
  102. package/dist/lib/cmaps/GBTpc-EUC-V.bcmap +0 -0
  103. package/dist/lib/cmaps/GBpc-EUC-H.bcmap +0 -0
  104. package/dist/lib/cmaps/GBpc-EUC-V.bcmap +0 -0
  105. package/dist/lib/cmaps/H.bcmap +0 -0
  106. package/dist/lib/cmaps/HKdla-B5-H.bcmap +0 -0
  107. package/dist/lib/cmaps/HKdla-B5-V.bcmap +0 -0
  108. package/dist/lib/cmaps/HKdlb-B5-H.bcmap +0 -0
  109. package/dist/lib/cmaps/HKdlb-B5-V.bcmap +0 -0
  110. package/dist/lib/cmaps/HKgccs-B5-H.bcmap +0 -0
  111. package/dist/lib/cmaps/HKgccs-B5-V.bcmap +0 -0
  112. package/dist/lib/cmaps/HKm314-B5-H.bcmap +0 -0
  113. package/dist/lib/cmaps/HKm314-B5-V.bcmap +0 -0
  114. package/dist/lib/cmaps/HKm471-B5-H.bcmap +0 -0
  115. package/dist/lib/cmaps/HKm471-B5-V.bcmap +0 -0
  116. package/dist/lib/cmaps/HKscs-B5-H.bcmap +0 -0
  117. package/dist/lib/cmaps/HKscs-B5-V.bcmap +0 -0
  118. package/dist/lib/cmaps/Hankaku.bcmap +0 -0
  119. package/dist/lib/cmaps/Hiragana.bcmap +0 -0
  120. package/dist/lib/cmaps/KSC-EUC-H.bcmap +0 -0
  121. package/dist/lib/cmaps/KSC-EUC-V.bcmap +0 -0
  122. package/dist/lib/cmaps/KSC-H.bcmap +0 -0
  123. package/dist/lib/cmaps/KSC-Johab-H.bcmap +0 -0
  124. package/dist/lib/cmaps/KSC-Johab-V.bcmap +0 -0
  125. package/dist/lib/cmaps/KSC-V.bcmap +0 -0
  126. package/dist/lib/cmaps/KSCms-UHC-H.bcmap +0 -0
  127. package/dist/lib/cmaps/KSCms-UHC-HW-H.bcmap +0 -0
  128. package/dist/lib/cmaps/KSCms-UHC-HW-V.bcmap +0 -0
  129. package/dist/lib/cmaps/KSCms-UHC-V.bcmap +0 -0
  130. package/dist/lib/cmaps/KSCpc-EUC-H.bcmap +0 -0
  131. package/dist/lib/cmaps/KSCpc-EUC-V.bcmap +0 -0
  132. package/dist/lib/cmaps/Katakana.bcmap +0 -0
  133. package/dist/lib/cmaps/LICENSE +36 -0
  134. package/dist/lib/cmaps/NWP-H.bcmap +0 -0
  135. package/dist/lib/cmaps/NWP-V.bcmap +0 -0
  136. package/dist/lib/cmaps/RKSJ-H.bcmap +0 -0
  137. package/dist/lib/cmaps/RKSJ-V.bcmap +0 -0
  138. package/dist/lib/cmaps/Roman.bcmap +0 -0
  139. package/dist/lib/cmaps/UniCNS-UCS2-H.bcmap +0 -0
  140. package/dist/lib/cmaps/UniCNS-UCS2-V.bcmap +0 -0
  141. package/dist/lib/cmaps/UniCNS-UTF16-H.bcmap +0 -0
  142. package/dist/lib/cmaps/UniCNS-UTF16-V.bcmap +0 -0
  143. package/dist/lib/cmaps/UniCNS-UTF32-H.bcmap +0 -0
  144. package/dist/lib/cmaps/UniCNS-UTF32-V.bcmap +0 -0
  145. package/dist/lib/cmaps/UniCNS-UTF8-H.bcmap +0 -0
  146. package/dist/lib/cmaps/UniCNS-UTF8-V.bcmap +0 -0
  147. package/dist/lib/cmaps/UniGB-UCS2-H.bcmap +0 -0
  148. package/dist/lib/cmaps/UniGB-UCS2-V.bcmap +0 -0
  149. package/dist/lib/cmaps/UniGB-UTF16-H.bcmap +0 -0
  150. package/dist/lib/cmaps/UniGB-UTF16-V.bcmap +0 -0
  151. package/dist/lib/cmaps/UniGB-UTF32-H.bcmap +0 -0
  152. package/dist/lib/cmaps/UniGB-UTF32-V.bcmap +0 -0
  153. package/dist/lib/cmaps/UniGB-UTF8-H.bcmap +0 -0
  154. package/dist/lib/cmaps/UniGB-UTF8-V.bcmap +0 -0
  155. package/dist/lib/cmaps/UniJIS-UCS2-H.bcmap +0 -0
  156. package/dist/lib/cmaps/UniJIS-UCS2-HW-H.bcmap +0 -0
  157. package/dist/lib/cmaps/UniJIS-UCS2-HW-V.bcmap +0 -0
  158. package/dist/lib/cmaps/UniJIS-UCS2-V.bcmap +0 -0
  159. package/dist/lib/cmaps/UniJIS-UTF16-H.bcmap +0 -0
  160. package/dist/lib/cmaps/UniJIS-UTF16-V.bcmap +0 -0
  161. package/dist/lib/cmaps/UniJIS-UTF32-H.bcmap +0 -0
  162. package/dist/lib/cmaps/UniJIS-UTF32-V.bcmap +0 -0
  163. package/dist/lib/cmaps/UniJIS-UTF8-H.bcmap +0 -0
  164. package/dist/lib/cmaps/UniJIS-UTF8-V.bcmap +0 -0
  165. package/dist/lib/cmaps/UniJIS2004-UTF16-H.bcmap +0 -0
  166. package/dist/lib/cmaps/UniJIS2004-UTF16-V.bcmap +0 -0
  167. package/dist/lib/cmaps/UniJIS2004-UTF32-H.bcmap +0 -0
  168. package/dist/lib/cmaps/UniJIS2004-UTF32-V.bcmap +0 -0
  169. package/dist/lib/cmaps/UniJIS2004-UTF8-H.bcmap +0 -0
  170. package/dist/lib/cmaps/UniJIS2004-UTF8-V.bcmap +0 -0
  171. package/dist/lib/cmaps/UniJISPro-UCS2-HW-V.bcmap +0 -0
  172. package/dist/lib/cmaps/UniJISPro-UCS2-V.bcmap +0 -0
  173. package/dist/lib/cmaps/UniJISPro-UTF8-V.bcmap +0 -0
  174. package/dist/lib/cmaps/UniJISX0213-UTF32-H.bcmap +0 -0
  175. package/dist/lib/cmaps/UniJISX0213-UTF32-V.bcmap +0 -0
  176. package/dist/lib/cmaps/UniJISX02132004-UTF32-H.bcmap +0 -0
  177. package/dist/lib/cmaps/UniJISX02132004-UTF32-V.bcmap +0 -0
  178. package/dist/lib/cmaps/UniKS-UCS2-H.bcmap +0 -0
  179. package/dist/lib/cmaps/UniKS-UCS2-V.bcmap +0 -0
  180. package/dist/lib/cmaps/UniKS-UTF16-H.bcmap +0 -0
  181. package/dist/lib/cmaps/UniKS-UTF16-V.bcmap +0 -0
  182. package/dist/lib/cmaps/UniKS-UTF32-H.bcmap +0 -0
  183. package/dist/lib/cmaps/UniKS-UTF32-V.bcmap +0 -0
  184. package/dist/lib/cmaps/UniKS-UTF8-H.bcmap +0 -0
  185. package/dist/lib/cmaps/UniKS-UTF8-V.bcmap +0 -0
  186. package/dist/lib/cmaps/V.bcmap +0 -0
  187. package/dist/lib/cmaps/WP-Symbol.bcmap +0 -0
  188. package/dist/lib/exif/exif-reader.min.js +8 -0
  189. package/dist/lib/exif/exif.js +822 -0
  190. package/dist/lib/exif/exif.min.js +21 -0
  191. package/dist/lib/fde82a50e6de20239861.svg +5 -0
  192. package/dist/lib/ff2dfa442d903d9d5e30.gif +0 -0
  193. package/dist/lib/index.css +84 -0
  194. package/dist/lib/index.d.ts +147 -0
  195. package/dist/lib/index.js +41639 -0
  196. package/dist/lib/pdfjs-lib.js +46 -0
  197. package/dist/lib/pdfjs-viewer-css.js +36 -0
  198. package/dist/lib/pdfjs-viewer.js +8118 -0
  199. package/dist/lib/third-party/media/0.127.0/shaka-player.compiled.js +371 -0
  200. package/dist/lib/third-party/media/1.30.0/shaka-player.compiled.js +438 -0
  201. package/dist/lib/third-party/media/1.33.0/shaka-player.compiled.js +438 -0
  202. package/dist/lib/third-party/media/1.8.0/shaka-player.compiled.js +376 -0
  203. package/dist/lib/third-party/media/2.14.0/shaka-player.compiled.js +609 -0
  204. package/dist/lib/third-party/media/2.66.0/manifest.json +8 -0
  205. package/dist/lib/third-party/media/2.66.0/shaka-player.compiled.js +752 -0
  206. package/dist/lib/third-party/media/2.93.0/manifest.json +8 -0
  207. package/dist/lib/third-party/media/2.93.0/shaka-player.compiled.js +975 -0
  208. package/dist/lib/third-party/media/3.25.0/manifest.json +8 -0
  209. package/dist/lib/third-party/media/3.25.0/shaka-player.compiled.js +1780 -0
  210. package/dist/lib/third-party/model3d/1.10.1/WebVR/VRConfig.js +49 -0
  211. package/dist/lib/third-party/model3d/1.10.1/WebVR/oculusTouchCommon/1024/1.jpg +0 -0
  212. package/dist/lib/third-party/model3d/1.10.1/WebVR/oculusTouchCommon/256/3.jpg +0 -0
  213. package/dist/lib/third-party/model3d/1.10.1/WebVR/oculusTouchCommon/512/2.jpg +0 -0
  214. package/dist/lib/third-party/model3d/1.10.1/WebVR/oculusTouchCommon/64/1.jpg +0 -0
  215. package/dist/lib/third-party/model3d/1.10.1/WebVR/oculusTouchCommon/64/2.jpg +0 -0
  216. package/dist/lib/third-party/model3d/1.10.1/WebVR/oculusTouchCommon/entities.json +322 -0
  217. package/dist/lib/third-party/model3d/1.10.1/WebVR/oculusTouchLeft/entities.json +755 -0
  218. package/dist/lib/third-party/model3d/1.10.1/WebVR/oculusTouchLeft/geometry.bin +0 -0
  219. package/dist/lib/third-party/model3d/1.10.1/WebVR/oculusTouchRight/entities.json +746 -0
  220. package/dist/lib/third-party/model3d/1.10.1/WebVR/oculusTouchRight/geometry.bin +0 -0
  221. package/dist/lib/third-party/model3d/1.10.1/WebVR/viveController/entities.json +1811 -0
  222. package/dist/lib/third-party/model3d/1.10.1/WebVR/viveController/geometry.bin +0 -0
  223. package/dist/lib/third-party/model3d/1.10.1/WebVR/viveController/images/1024/1.png +0 -0
  224. package/dist/lib/third-party/model3d/1.10.1/WebVR/viveController/images/1024/2.jpg +0 -0
  225. package/dist/lib/third-party/model3d/1.10.1/WebVR/viveController/images/1024/3.jpg +0 -0
  226. package/dist/lib/third-party/model3d/1.10.1/WebVR/viveController/images/64/1.png +0 -0
  227. package/dist/lib/third-party/model3d/1.10.1/WebVR/viveController/images/64/2.jpg +0 -0
  228. package/dist/lib/third-party/model3d/1.10.1/WebVR/viveController/images/64/3.jpg +0 -0
  229. package/dist/lib/third-party/model3d/1.10.1/WebVR/viveController/images/64/4.png +0 -0
  230. package/dist/lib/third-party/model3d/1.10.1/box3d-player.json +1 -0
  231. package/dist/lib/third-party/model3d/1.10.1/box3d-runtime.min.js +2 -0
  232. package/dist/lib/third-party/model3d/1.10.1/boxsdk.min.js +2 -0
  233. package/dist/lib/third-party/model3d/1.10.1/matcap.png +0 -0
  234. package/dist/lib/third-party/model3d/1.10.1/three.min.js +882 -0
  235. package/dist/lib/third-party/model3d/1.10.1/webvr-polyfill.js +6341 -0
  236. package/dist/lib/third-party/model3d/1.12.0/WebVR/VRConfig.js +49 -0
  237. package/dist/lib/third-party/model3d/1.12.0/WebVR/oculusTouchCommon/1024/1.jpg +0 -0
  238. package/dist/lib/third-party/model3d/1.12.0/WebVR/oculusTouchCommon/256/3.jpg +0 -0
  239. package/dist/lib/third-party/model3d/1.12.0/WebVR/oculusTouchCommon/512/2.jpg +0 -0
  240. package/dist/lib/third-party/model3d/1.12.0/WebVR/oculusTouchCommon/64/1.jpg +0 -0
  241. package/dist/lib/third-party/model3d/1.12.0/WebVR/oculusTouchCommon/64/2.jpg +0 -0
  242. package/dist/lib/third-party/model3d/1.12.0/WebVR/oculusTouchCommon/entities.json +322 -0
  243. package/dist/lib/third-party/model3d/1.12.0/WebVR/oculusTouchLeft/entities.json +755 -0
  244. package/dist/lib/third-party/model3d/1.12.0/WebVR/oculusTouchLeft/geometry.bin +0 -0
  245. package/dist/lib/third-party/model3d/1.12.0/WebVR/oculusTouchRight/entities.json +746 -0
  246. package/dist/lib/third-party/model3d/1.12.0/WebVR/oculusTouchRight/geometry.bin +0 -0
  247. package/dist/lib/third-party/model3d/1.12.0/WebVR/viveController/entities.json +1811 -0
  248. package/dist/lib/third-party/model3d/1.12.0/WebVR/viveController/geometry.bin +0 -0
  249. package/dist/lib/third-party/model3d/1.12.0/WebVR/viveController/images/1024/1.png +0 -0
  250. package/dist/lib/third-party/model3d/1.12.0/WebVR/viveController/images/1024/2.jpg +0 -0
  251. package/dist/lib/third-party/model3d/1.12.0/WebVR/viveController/images/1024/3.jpg +0 -0
  252. package/dist/lib/third-party/model3d/1.12.0/WebVR/viveController/images/64/1.png +0 -0
  253. package/dist/lib/third-party/model3d/1.12.0/WebVR/viveController/images/64/2.jpg +0 -0
  254. package/dist/lib/third-party/model3d/1.12.0/WebVR/viveController/images/64/3.jpg +0 -0
  255. package/dist/lib/third-party/model3d/1.12.0/WebVR/viveController/images/64/4.png +0 -0
  256. package/dist/lib/third-party/model3d/1.12.0/box3d-player.json +1 -0
  257. package/dist/lib/third-party/model3d/1.12.0/box3d-runtime.min.js +2 -0
  258. package/dist/lib/third-party/model3d/1.12.0/boxsdk.min.js +2 -0
  259. package/dist/lib/third-party/model3d/1.12.0/matcap.png +0 -0
  260. package/dist/lib/third-party/model3d/1.12.0/three.min.js +882 -0
  261. package/dist/lib/third-party/model3d/1.12.0/webvr-polyfill.js +6341 -0
  262. package/dist/lib/third-party/model3d/1.6.1/WebVR/VRConfig.js +49 -0
  263. package/dist/lib/third-party/model3d/1.6.1/WebVR/oculusTouchCommon/1024/1.jpg +0 -0
  264. package/dist/lib/third-party/model3d/1.6.1/WebVR/oculusTouchCommon/256/3.jpg +0 -0
  265. package/dist/lib/third-party/model3d/1.6.1/WebVR/oculusTouchCommon/512/2.jpg +0 -0
  266. package/dist/lib/third-party/model3d/1.6.1/WebVR/oculusTouchCommon/64/1.jpg +0 -0
  267. package/dist/lib/third-party/model3d/1.6.1/WebVR/oculusTouchCommon/64/2.jpg +0 -0
  268. package/dist/lib/third-party/model3d/1.6.1/WebVR/oculusTouchCommon/entities.json +439 -0
  269. package/dist/lib/third-party/model3d/1.6.1/WebVR/oculusTouchLeft/entities.json +755 -0
  270. package/dist/lib/third-party/model3d/1.6.1/WebVR/oculusTouchLeft/geometry.bin +0 -0
  271. package/dist/lib/third-party/model3d/1.6.1/WebVR/oculusTouchRight/entities.json +746 -0
  272. package/dist/lib/third-party/model3d/1.6.1/WebVR/oculusTouchRight/geometry.bin +0 -0
  273. package/dist/lib/third-party/model3d/1.6.1/WebVR/viveController/entities.json +1869 -0
  274. package/dist/lib/third-party/model3d/1.6.1/WebVR/viveController/geometry.bin +0 -0
  275. package/dist/lib/third-party/model3d/1.6.1/WebVR/viveController/images/1024/1.png +0 -0
  276. package/dist/lib/third-party/model3d/1.6.1/WebVR/viveController/images/1024/2.jpg +0 -0
  277. package/dist/lib/third-party/model3d/1.6.1/WebVR/viveController/images/1024/3.jpg +0 -0
  278. package/dist/lib/third-party/model3d/1.6.1/WebVR/viveController/images/64/1.png +0 -0
  279. package/dist/lib/third-party/model3d/1.6.1/WebVR/viveController/images/64/2.jpg +0 -0
  280. package/dist/lib/third-party/model3d/1.6.1/WebVR/viveController/images/64/3.jpg +0 -0
  281. package/dist/lib/third-party/model3d/1.6.1/WebVR/viveController/images/64/4.png +0 -0
  282. package/dist/lib/third-party/model3d/1.6.1/box3d-player.json +1 -0
  283. package/dist/lib/third-party/model3d/1.6.1/box3d-runtime.min.js +2 -0
  284. package/dist/lib/third-party/model3d/1.6.1/boxsdk.min.js +2 -0
  285. package/dist/lib/third-party/model3d/1.6.1/matcap.png +0 -0
  286. package/dist/lib/third-party/model3d/1.6.1/three.min.js +43300 -0
  287. package/dist/lib/third-party/model3d/1.6.1/webvr-polyfill.js +6341 -0
  288. package/dist/lib/third-party/model3d/1.9.1/WebVR/VRConfig.js +49 -0
  289. package/dist/lib/third-party/model3d/1.9.1/WebVR/oculusTouchCommon/1024/1.jpg +0 -0
  290. package/dist/lib/third-party/model3d/1.9.1/WebVR/oculusTouchCommon/256/3.jpg +0 -0
  291. package/dist/lib/third-party/model3d/1.9.1/WebVR/oculusTouchCommon/512/2.jpg +0 -0
  292. package/dist/lib/third-party/model3d/1.9.1/WebVR/oculusTouchCommon/64/1.jpg +0 -0
  293. package/dist/lib/third-party/model3d/1.9.1/WebVR/oculusTouchCommon/64/2.jpg +0 -0
  294. package/dist/lib/third-party/model3d/1.9.1/WebVR/oculusTouchCommon/entities.json +439 -0
  295. package/dist/lib/third-party/model3d/1.9.1/WebVR/oculusTouchLeft/entities.json +755 -0
  296. package/dist/lib/third-party/model3d/1.9.1/WebVR/oculusTouchLeft/geometry.bin +0 -0
  297. package/dist/lib/third-party/model3d/1.9.1/WebVR/oculusTouchRight/entities.json +746 -0
  298. package/dist/lib/third-party/model3d/1.9.1/WebVR/oculusTouchRight/geometry.bin +0 -0
  299. package/dist/lib/third-party/model3d/1.9.1/WebVR/viveController/entities.json +1869 -0
  300. package/dist/lib/third-party/model3d/1.9.1/WebVR/viveController/geometry.bin +0 -0
  301. package/dist/lib/third-party/model3d/1.9.1/WebVR/viveController/images/1024/1.png +0 -0
  302. package/dist/lib/third-party/model3d/1.9.1/WebVR/viveController/images/1024/2.jpg +0 -0
  303. package/dist/lib/third-party/model3d/1.9.1/WebVR/viveController/images/1024/3.jpg +0 -0
  304. package/dist/lib/third-party/model3d/1.9.1/WebVR/viveController/images/64/1.png +0 -0
  305. package/dist/lib/third-party/model3d/1.9.1/WebVR/viveController/images/64/2.jpg +0 -0
  306. package/dist/lib/third-party/model3d/1.9.1/WebVR/viveController/images/64/3.jpg +0 -0
  307. package/dist/lib/third-party/model3d/1.9.1/WebVR/viveController/images/64/4.png +0 -0
  308. package/dist/lib/third-party/model3d/1.9.1/box3d-player.json +1 -0
  309. package/dist/lib/third-party/model3d/1.9.1/box3d-runtime.min.js +2 -0
  310. package/dist/lib/third-party/model3d/1.9.1/boxsdk.min.js +2 -0
  311. package/dist/lib/third-party/model3d/1.9.1/matcap.png +0 -0
  312. package/dist/lib/third-party/model3d/1.9.1/three.min.js +882 -0
  313. package/dist/lib/third-party/model3d/1.9.1/webvr-polyfill.js +6341 -0
  314. package/dist/lib/third-party/swf/0.112.0/swfobject.js +6 -0
  315. package/dist/lib/third-party/text/0.112.0/github-markdown.css +681 -0
  316. package/dist/lib/third-party/text/0.112.0/github.css +123 -0
  317. package/dist/lib/third-party/text/0.112.0/highlight.min.js +3 -0
  318. package/dist/lib/third-party/text/0.112.0/papaparse.js +1457 -0
  319. package/dist/lib/third-party/text/0.112.0/papaparse.min.js +34 -0
  320. package/dist/lib/third-party/text/0.112.0/remarkable.min.js +4 -0
  321. package/dist/lib/third-party/text/0.114.0/github-markdown.css +681 -0
  322. package/dist/lib/third-party/text/0.114.0/github-markdown.min.css +1 -0
  323. package/dist/lib/third-party/text/0.114.0/github.css +123 -0
  324. package/dist/lib/third-party/text/0.114.0/github.min.css +1 -0
  325. package/dist/lib/third-party/text/0.114.0/highlight.min.js +3 -0
  326. package/dist/lib/third-party/text/0.114.0/manifest.json +10 -0
  327. package/dist/lib/third-party/text/0.114.0/papaparse.js +1457 -0
  328. package/dist/lib/third-party/text/0.114.0/papaparse.min.js +34 -0
  329. package/dist/lib/third-party/text/0.114.0/remarkable.min.js +4 -0
  330. package/dist/lib/third-party/text/2.65.0/github-markdown.css +681 -0
  331. package/dist/lib/third-party/text/2.65.0/github-markdown.min.css +1 -0
  332. package/dist/lib/third-party/text/2.65.0/github.css +99 -0
  333. package/dist/lib/third-party/text/2.65.0/github.min.css +1 -0
  334. package/dist/lib/third-party/text/2.65.0/highlight.min.js +2 -0
  335. package/dist/lib/third-party/text/2.65.0/manifest.json +10 -0
  336. package/dist/lib/third-party/text/2.65.0/papaparse.js +1897 -0
  337. package/dist/lib/third-party/text/2.65.0/papaparse.min.js +7 -0
  338. package/dist/lib/third-party/text/2.65.0/remarkable.min.js +1 -0
  339. package/package.json +198 -0
@@ -0,0 +1,1457 @@
1
+ /*!
2
+ Papa Parse
3
+ v4.1.2
4
+ https://github.com/mholt/PapaParse
5
+ */
6
+ (function(root, factory)
7
+ {
8
+ if (typeof define === 'function' && define.amd)
9
+ {
10
+ // AMD. Register as an anonymous module.
11
+ define([], factory);
12
+ }
13
+ else if (typeof module === 'object' && module.exports)
14
+ {
15
+ // Node. Does not work with strict CommonJS, but
16
+ // only CommonJS-like environments that support module.exports,
17
+ // like Node.
18
+ module.exports = factory();
19
+ }
20
+ else
21
+ {
22
+ // Browser globals (root is window)
23
+ root.Papa = factory();
24
+ }
25
+ }(this, function()
26
+ {
27
+ 'use strict';
28
+
29
+ var global = Function('return this')();
30
+ var IS_WORKER = !global.document && !!global.postMessage,
31
+ // @NOTE(tjin): Box-specific code to fix blob'd workers
32
+ IS_PAPA_WORKER = IS_WORKER && typeof global.WorkerGlobalScope !== 'undefined' && self instanceof global.WorkerGlobalScope,
33
+ LOADED_SYNC = false, AUTO_SCRIPT_PATH;
34
+ var workers = {}, workerIdCounter = 0;
35
+
36
+ var Papa = {};
37
+
38
+ Papa.parse = CsvToJson;
39
+ Papa.unparse = JsonToCsv;
40
+
41
+ Papa.RECORD_SEP = String.fromCharCode(30);
42
+ Papa.UNIT_SEP = String.fromCharCode(31);
43
+ Papa.BYTE_ORDER_MARK = '\ufeff';
44
+ Papa.BAD_DELIMITERS = ['\r', '\n', '"', Papa.BYTE_ORDER_MARK];
45
+ Papa.WORKERS_SUPPORTED = !IS_WORKER && !!global.Worker;
46
+ Papa.SCRIPT_PATH = null; // Must be set by your code if you use workers and this lib is loaded asynchronously
47
+
48
+ // Configurable chunk sizes for local and remote files, respectively
49
+ Papa.LocalChunkSize = 1024 * 1024 * 10; // 10 MB
50
+ Papa.RemoteChunkSize = 1024 * 1024 * 5; // 5 MB
51
+ Papa.DefaultDelimiter = ','; // Used if not specified and detection fails
52
+
53
+ // Exposed for testing and development only
54
+ Papa.Parser = Parser;
55
+ Papa.ParserHandle = ParserHandle;
56
+ Papa.NetworkStreamer = NetworkStreamer;
57
+ Papa.FileStreamer = FileStreamer;
58
+ Papa.StringStreamer = StringStreamer;
59
+
60
+ if (global.jQuery)
61
+ {
62
+ var $ = global.jQuery;
63
+ $.fn.parse = function(options)
64
+ {
65
+ var config = options.config || {};
66
+ var queue = [];
67
+
68
+ this.each(function(idx)
69
+ {
70
+ var supported = $(this).prop('tagName').toUpperCase() === 'INPUT'
71
+ && $(this).attr('type').toLowerCase() === 'file'
72
+ && global.FileReader;
73
+
74
+ if (!supported || !this.files || this.files.length === 0)
75
+ return true; // continue to next input element
76
+
77
+ for (var i = 0; i < this.files.length; i++)
78
+ {
79
+ queue.push({
80
+ file: this.files[i],
81
+ inputElem: this,
82
+ instanceConfig: $.extend({}, config)
83
+ });
84
+ }
85
+ });
86
+
87
+ parseNextFile(); // begin parsing
88
+ return this; // maintains chainability
89
+
90
+
91
+ function parseNextFile()
92
+ {
93
+ if (queue.length === 0)
94
+ {
95
+ if (isFunction(options.complete))
96
+ options.complete();
97
+ return;
98
+ }
99
+
100
+ var f = queue[0];
101
+
102
+ if (isFunction(options.before))
103
+ {
104
+ var returned = options.before(f.file, f.inputElem);
105
+
106
+ if (typeof returned === 'object')
107
+ {
108
+ if (returned.action === 'abort')
109
+ {
110
+ error('AbortError', f.file, f.inputElem, returned.reason);
111
+ return; // Aborts all queued files immediately
112
+ }
113
+ else if (returned.action === 'skip')
114
+ {
115
+ fileComplete(); // parse the next file in the queue, if any
116
+ return;
117
+ }
118
+ else if (typeof returned.config === 'object')
119
+ f.instanceConfig = $.extend(f.instanceConfig, returned.config);
120
+ }
121
+ else if (returned === 'skip')
122
+ {
123
+ fileComplete(); // parse the next file in the queue, if any
124
+ return;
125
+ }
126
+ }
127
+
128
+ // Wrap up the user's complete callback, if any, so that ours also gets executed
129
+ var userCompleteFunc = f.instanceConfig.complete;
130
+ f.instanceConfig.complete = function(results)
131
+ {
132
+ if (isFunction(userCompleteFunc))
133
+ userCompleteFunc(results, f.file, f.inputElem);
134
+ fileComplete();
135
+ };
136
+
137
+ Papa.parse(f.file, f.instanceConfig);
138
+ }
139
+
140
+ function error(name, file, elem, reason)
141
+ {
142
+ if (isFunction(options.error))
143
+ options.error({name: name}, file, elem, reason);
144
+ }
145
+
146
+ function fileComplete()
147
+ {
148
+ queue.splice(0, 1);
149
+ parseNextFile();
150
+ }
151
+ }
152
+ }
153
+
154
+
155
+ if (IS_PAPA_WORKER)
156
+ {
157
+ global.onmessage = workerThreadReceivedMessage;
158
+ }
159
+ else if (Papa.WORKERS_SUPPORTED)
160
+ {
161
+ AUTO_SCRIPT_PATH = getScriptPath();
162
+
163
+ // Check if the script was loaded synchronously
164
+ if (!document.body)
165
+ {
166
+ // Body doesn't exist yet, must be synchronous
167
+ LOADED_SYNC = true;
168
+ }
169
+ else
170
+ {
171
+ document.addEventListener('DOMContentLoaded', function () {
172
+ LOADED_SYNC = true;
173
+ }, true);
174
+ }
175
+ }
176
+
177
+
178
+
179
+
180
+ function CsvToJson(_input, _config)
181
+ {
182
+ _config = _config || {};
183
+ _config.dynamicTyping = _config.dynamicTyping || false;
184
+
185
+ if (_config.worker && Papa.WORKERS_SUPPORTED)
186
+ {
187
+ var w = newWorker();
188
+
189
+ w.userStep = _config.step;
190
+ w.userChunk = _config.chunk;
191
+ w.userComplete = _config.complete;
192
+ w.userError = _config.error;
193
+
194
+ _config.step = isFunction(_config.step);
195
+ _config.chunk = isFunction(_config.chunk);
196
+ _config.complete = isFunction(_config.complete);
197
+ _config.error = isFunction(_config.error);
198
+ delete _config.worker; // prevent infinite loop
199
+
200
+ w.postMessage({
201
+ input: _input,
202
+ config: _config,
203
+ workerId: w.id
204
+ });
205
+
206
+ return;
207
+ }
208
+
209
+ var streamer = null;
210
+ if (typeof _input === 'string')
211
+ {
212
+ if (_config.download)
213
+ streamer = new NetworkStreamer(_config);
214
+ else
215
+ streamer = new StringStreamer(_config);
216
+ }
217
+ else if ((global.File && _input instanceof File) || _input instanceof Object) // ...Safari. (see issue #106)
218
+ streamer = new FileStreamer(_config);
219
+
220
+ return streamer.stream(_input);
221
+ }
222
+
223
+
224
+
225
+
226
+
227
+
228
+ function JsonToCsv(_input, _config)
229
+ {
230
+ var _output = '';
231
+ var _fields = [];
232
+
233
+ // Default configuration
234
+
235
+ /** whether to surround every datum with quotes */
236
+ var _quotes = false;
237
+
238
+ /** whether to write headers */
239
+ var _writeHeader = true;
240
+
241
+ /** delimiting character */
242
+ var _delimiter = ',';
243
+
244
+ /** newline character(s) */
245
+ var _newline = '\r\n';
246
+
247
+ /** quote character */
248
+ var _quoteChar = '"';
249
+
250
+ unpackConfig();
251
+
252
+ var quoteCharRegex = new RegExp(_quoteChar, 'g');
253
+
254
+ if (typeof _input === 'string')
255
+ _input = JSON.parse(_input);
256
+
257
+ if (_input instanceof Array)
258
+ {
259
+ if (!_input.length || _input[0] instanceof Array)
260
+ return serialize(null, _input);
261
+ else if (typeof _input[0] === 'object')
262
+ return serialize(objectKeys(_input[0]), _input);
263
+ }
264
+ else if (typeof _input === 'object')
265
+ {
266
+ if (typeof _input.data === 'string')
267
+ _input.data = JSON.parse(_input.data);
268
+
269
+ if (_input.data instanceof Array)
270
+ {
271
+ if (!_input.fields)
272
+ _input.fields = _input.meta && _input.meta.fields;
273
+
274
+ if (!_input.fields)
275
+ _input.fields = _input.data[0] instanceof Array
276
+ ? _input.fields
277
+ : objectKeys(_input.data[0]);
278
+
279
+ if (!(_input.data[0] instanceof Array) && typeof _input.data[0] !== 'object')
280
+ _input.data = [_input.data]; // handles input like [1,2,3] or ['asdf']
281
+ }
282
+
283
+ return serialize(_input.fields || [], _input.data || []);
284
+ }
285
+
286
+ // Default (any valid paths should return before this)
287
+ throw 'exception: Unable to serialize unrecognized input';
288
+
289
+
290
+ function unpackConfig()
291
+ {
292
+ if (typeof _config !== 'object')
293
+ return;
294
+
295
+ if (typeof _config.delimiter === 'string'
296
+ && _config.delimiter.length === 1
297
+ && Papa.BAD_DELIMITERS.indexOf(_config.delimiter) === -1)
298
+ {
299
+ _delimiter = _config.delimiter;
300
+ }
301
+
302
+ if (typeof _config.quotes === 'boolean'
303
+ || _config.quotes instanceof Array)
304
+ _quotes = _config.quotes;
305
+
306
+ if (typeof _config.newline === 'string')
307
+ _newline = _config.newline;
308
+
309
+ if (typeof _config.quoteChar === 'string')
310
+ _quoteChar = _config.quoteChar;
311
+
312
+ if (typeof _config.header === 'boolean')
313
+ _writeHeader = _config.header;
314
+ }
315
+
316
+
317
+ /** Turns an object's keys into an array */
318
+ function objectKeys(obj)
319
+ {
320
+ if (typeof obj !== 'object')
321
+ return [];
322
+ var keys = [];
323
+ for (var key in obj)
324
+ keys.push(key);
325
+ return keys;
326
+ }
327
+
328
+ /** The double for loop that iterates the data and writes out a CSV string including header row */
329
+ function serialize(fields, data)
330
+ {
331
+ var csv = '';
332
+
333
+ if (typeof fields === 'string')
334
+ fields = JSON.parse(fields);
335
+ if (typeof data === 'string')
336
+ data = JSON.parse(data);
337
+
338
+ var hasHeader = fields instanceof Array && fields.length > 0;
339
+ var dataKeyedByField = !(data[0] instanceof Array);
340
+
341
+ // If there a header row, write it first
342
+ if (hasHeader && _writeHeader)
343
+ {
344
+ for (var i = 0; i < fields.length; i++)
345
+ {
346
+ if (i > 0)
347
+ csv += _delimiter;
348
+ csv += safe(fields[i], i);
349
+ }
350
+ if (data.length > 0)
351
+ csv += _newline;
352
+ }
353
+
354
+ // Then write out the data
355
+ for (var row = 0; row < data.length; row++)
356
+ {
357
+ var maxCol = hasHeader ? fields.length : data[row].length;
358
+
359
+ for (var col = 0; col < maxCol; col++)
360
+ {
361
+ if (col > 0)
362
+ csv += _delimiter;
363
+ var colIdx = hasHeader && dataKeyedByField ? fields[col] : col;
364
+ csv += safe(data[row][colIdx], col);
365
+ }
366
+
367
+ if (row < data.length - 1)
368
+ csv += _newline;
369
+ }
370
+
371
+ return csv;
372
+ }
373
+
374
+ /** Encloses a value around quotes if needed (makes a value safe for CSV insertion) */
375
+ function safe(str, col)
376
+ {
377
+ if (typeof str === 'undefined' || str === null)
378
+ return '';
379
+
380
+ str = str.toString().replace(quoteCharRegex, _quoteChar+_quoteChar);
381
+
382
+ var needsQuotes = (typeof _quotes === 'boolean' && _quotes)
383
+ || (_quotes instanceof Array && _quotes[col])
384
+ || hasAny(str, Papa.BAD_DELIMITERS)
385
+ || str.indexOf(_delimiter) > -1
386
+ || str.charAt(0) === ' '
387
+ || str.charAt(str.length - 1) === ' ';
388
+
389
+ return needsQuotes ? _quoteChar + str + _quoteChar : str;
390
+ }
391
+
392
+ function hasAny(str, substrings)
393
+ {
394
+ for (var i = 0; i < substrings.length; i++)
395
+ if (str.indexOf(substrings[i]) > -1)
396
+ return true;
397
+ return false;
398
+ }
399
+ }
400
+
401
+ /** ChunkStreamer is the base prototype for various streamer implementations. */
402
+ function ChunkStreamer(config)
403
+ {
404
+ this._handle = null;
405
+ this._paused = false;
406
+ this._finished = false;
407
+ this._input = null;
408
+ this._baseIndex = 0;
409
+ this._partialLine = '';
410
+ this._rowCount = 0;
411
+ this._start = 0;
412
+ this._nextChunk = null;
413
+ this.isFirstChunk = true;
414
+ this._completeResults = {
415
+ data: [],
416
+ errors: [],
417
+ meta: {}
418
+ };
419
+ replaceConfig.call(this, config);
420
+
421
+ this.parseChunk = function(chunk)
422
+ {
423
+ // First chunk pre-processing
424
+ if (this.isFirstChunk && isFunction(this._config.beforeFirstChunk))
425
+ {
426
+ var modifiedChunk = this._config.beforeFirstChunk(chunk);
427
+ if (modifiedChunk !== undefined)
428
+ chunk = modifiedChunk;
429
+ }
430
+ this.isFirstChunk = false;
431
+
432
+ // Rejoin the line we likely just split in two by chunking the file
433
+ var aggregate = this._partialLine + chunk;
434
+ this._partialLine = '';
435
+
436
+ var results = this._handle.parse(aggregate, this._baseIndex, !this._finished);
437
+
438
+ if (this._handle.paused() || this._handle.aborted())
439
+ return;
440
+
441
+ var lastIndex = results.meta.cursor;
442
+
443
+ if (!this._finished)
444
+ {
445
+ this._partialLine = aggregate.substring(lastIndex - this._baseIndex);
446
+ this._baseIndex = lastIndex;
447
+ }
448
+
449
+ if (results && results.data)
450
+ this._rowCount += results.data.length;
451
+
452
+ var finishedIncludingPreview = this._finished || (this._config.preview && this._rowCount >= this._config.preview);
453
+
454
+ if (IS_PAPA_WORKER)
455
+ {
456
+ global.postMessage({
457
+ results: results,
458
+ workerId: Papa.WORKER_ID,
459
+ finished: finishedIncludingPreview
460
+ });
461
+ }
462
+ else if (isFunction(this._config.chunk))
463
+ {
464
+ this._config.chunk(results, this._handle);
465
+ if (this._paused)
466
+ return;
467
+ results = undefined;
468
+ this._completeResults = undefined;
469
+ }
470
+
471
+ if (!this._config.step && !this._config.chunk) {
472
+ this._completeResults.data = this._completeResults.data.concat(results.data);
473
+ this._completeResults.errors = this._completeResults.errors.concat(results.errors);
474
+ this._completeResults.meta = results.meta;
475
+ }
476
+
477
+ if (finishedIncludingPreview && isFunction(this._config.complete) && (!results || !results.meta.aborted))
478
+ this._config.complete(this._completeResults, this._input);
479
+
480
+ if (!finishedIncludingPreview && (!results || !results.meta.paused))
481
+ this._nextChunk();
482
+
483
+ return results;
484
+ };
485
+
486
+ this._sendError = function(error)
487
+ {
488
+ if (isFunction(this._config.error))
489
+ this._config.error(error);
490
+ else if (IS_PAPA_WORKER && this._config.error)
491
+ {
492
+ global.postMessage({
493
+ workerId: Papa.WORKER_ID,
494
+ error: error,
495
+ finished: false
496
+ });
497
+ }
498
+ };
499
+
500
+ function replaceConfig(config)
501
+ {
502
+ // Deep-copy the config so we can edit it
503
+ var configCopy = copy(config);
504
+ configCopy.chunkSize = parseInt(configCopy.chunkSize); // parseInt VERY important so we don't concatenate strings!
505
+ if (!config.step && !config.chunk)
506
+ configCopy.chunkSize = null; // disable Range header if not streaming; bad values break IIS - see issue #196
507
+ this._handle = new ParserHandle(configCopy);
508
+ this._handle.streamer = this;
509
+ this._config = configCopy; // persist the copy to the caller
510
+ }
511
+ }
512
+
513
+
514
+ function NetworkStreamer(config)
515
+ {
516
+ config = config || {};
517
+ if (!config.chunkSize)
518
+ config.chunkSize = Papa.RemoteChunkSize;
519
+ ChunkStreamer.call(this, config);
520
+
521
+ var xhr;
522
+
523
+ if (IS_WORKER)
524
+ {
525
+ this._nextChunk = function()
526
+ {
527
+ this._readChunk();
528
+ this._chunkLoaded();
529
+ };
530
+ }
531
+ else
532
+ {
533
+ this._nextChunk = function()
534
+ {
535
+ this._readChunk();
536
+ };
537
+ }
538
+
539
+ this.stream = function(url)
540
+ {
541
+ this._input = url;
542
+ this._nextChunk(); // Starts streaming
543
+ };
544
+
545
+ this._readChunk = function()
546
+ {
547
+ if (this._finished)
548
+ {
549
+ this._chunkLoaded();
550
+ return;
551
+ }
552
+
553
+ xhr = new XMLHttpRequest();
554
+
555
+ if (this._config.withCredentials)
556
+ {
557
+ xhr.withCredentials = this._config.withCredentials;
558
+ }
559
+
560
+ if (!IS_WORKER)
561
+ {
562
+ xhr.onload = bindFunction(this._chunkLoaded, this);
563
+ xhr.onerror = bindFunction(this._chunkError, this);
564
+ }
565
+
566
+ xhr.open('GET', this._input, !IS_WORKER);
567
+
568
+ if (this._config.chunkSize)
569
+ {
570
+ var end = this._start + this._config.chunkSize - 1; // minus one because byte range is inclusive
571
+ xhr.setRequestHeader('Range', 'bytes='+this._start+'-'+end);
572
+ xhr.setRequestHeader('If-None-Match', 'webkit-no-cache'); // https://bugs.webkit.org/show_bug.cgi?id=82672
573
+ }
574
+
575
+ try {
576
+ xhr.send();
577
+ }
578
+ catch (err) {
579
+ this._chunkError(err.message);
580
+ }
581
+
582
+ if (IS_WORKER && xhr.status === 0)
583
+ this._chunkError();
584
+ else
585
+ this._start += this._config.chunkSize;
586
+ }
587
+
588
+ this._chunkLoaded = function()
589
+ {
590
+ if (xhr.readyState != 4)
591
+ return;
592
+
593
+ if (xhr.status < 200 || xhr.status >= 400)
594
+ {
595
+ this._chunkError();
596
+ return;
597
+ }
598
+
599
+ this._finished = !this._config.chunkSize || this._start > getFileSize(xhr);
600
+ this.parseChunk(xhr.responseText);
601
+ }
602
+
603
+ this._chunkError = function(errorMessage)
604
+ {
605
+ var errorText = xhr.statusText || errorMessage;
606
+ this._sendError(errorText);
607
+ }
608
+
609
+ function getFileSize(xhr)
610
+ {
611
+ var contentRange = xhr.getResponseHeader('Content-Range');
612
+ if (contentRange === null) { // no content range, then finish!
613
+ return -1;
614
+ }
615
+ return parseInt(contentRange.substr(contentRange.lastIndexOf('/') + 1));
616
+ }
617
+ }
618
+ NetworkStreamer.prototype = Object.create(ChunkStreamer.prototype);
619
+ NetworkStreamer.prototype.constructor = NetworkStreamer;
620
+
621
+
622
+ function FileStreamer(config)
623
+ {
624
+ config = config || {};
625
+ if (!config.chunkSize)
626
+ config.chunkSize = Papa.LocalChunkSize;
627
+ ChunkStreamer.call(this, config);
628
+
629
+ var reader, slice;
630
+
631
+ // FileReader is better than FileReaderSync (even in worker) - see http://stackoverflow.com/q/24708649/1048862
632
+ // But Firefox is a pill, too - see issue #76: https://github.com/mholt/PapaParse/issues/76
633
+ var usingAsyncReader = typeof FileReader !== 'undefined'; // Safari doesn't consider it a function - see issue #105
634
+
635
+ this.stream = function(file)
636
+ {
637
+ this._input = file;
638
+ slice = file.slice || file.webkitSlice || file.mozSlice;
639
+
640
+ if (usingAsyncReader)
641
+ {
642
+ reader = new FileReader(); // Preferred method of reading files, even in workers
643
+ reader.onload = bindFunction(this._chunkLoaded, this);
644
+ reader.onerror = bindFunction(this._chunkError, this);
645
+ }
646
+ else
647
+ reader = new FileReaderSync(); // Hack for running in a web worker in Firefox
648
+
649
+ this._nextChunk(); // Starts streaming
650
+ };
651
+
652
+ this._nextChunk = function()
653
+ {
654
+ if (!this._finished && (!this._config.preview || this._rowCount < this._config.preview))
655
+ this._readChunk();
656
+ }
657
+
658
+ this._readChunk = function()
659
+ {
660
+ var input = this._input;
661
+ if (this._config.chunkSize)
662
+ {
663
+ var end = Math.min(this._start + this._config.chunkSize, this._input.size);
664
+ input = slice.call(input, this._start, end);
665
+ }
666
+ var txt = reader.readAsText(input, this._config.encoding);
667
+ if (!usingAsyncReader)
668
+ this._chunkLoaded({ target: { result: txt } }); // mimic the async signature
669
+ }
670
+
671
+ this._chunkLoaded = function(event)
672
+ {
673
+ // Very important to increment start each time before handling results
674
+ this._start += this._config.chunkSize;
675
+ this._finished = !this._config.chunkSize || this._start >= this._input.size;
676
+ this.parseChunk(event.target.result);
677
+ }
678
+
679
+ this._chunkError = function()
680
+ {
681
+ this._sendError(reader.error);
682
+ }
683
+
684
+ }
685
+ FileStreamer.prototype = Object.create(ChunkStreamer.prototype);
686
+ FileStreamer.prototype.constructor = FileStreamer;
687
+
688
+
689
+ function StringStreamer(config)
690
+ {
691
+ config = config || {};
692
+ ChunkStreamer.call(this, config);
693
+
694
+ var string;
695
+ var remaining;
696
+ this.stream = function(s)
697
+ {
698
+ string = s;
699
+ remaining = s;
700
+ return this._nextChunk();
701
+ }
702
+ this._nextChunk = function()
703
+ {
704
+ if (this._finished) return;
705
+ var size = this._config.chunkSize;
706
+ var chunk = size ? remaining.substr(0, size) : remaining;
707
+ remaining = size ? remaining.substr(size) : '';
708
+ this._finished = !remaining;
709
+ return this.parseChunk(chunk);
710
+ }
711
+ }
712
+ StringStreamer.prototype = Object.create(StringStreamer.prototype);
713
+ StringStreamer.prototype.constructor = StringStreamer;
714
+
715
+
716
+
717
+ // Use one ParserHandle per entire CSV file or string
718
+ function ParserHandle(_config)
719
+ {
720
+ // One goal is to minimize the use of regular expressions...
721
+ var FLOAT = /^\s*-?(\d*\.?\d+|\d+\.?\d*)(e[-+]?\d+)?\s*$/i;
722
+
723
+ var self = this;
724
+ var _stepCounter = 0; // Number of times step was called (number of rows parsed)
725
+ var _input; // The input being parsed
726
+ var _parser; // The core parser being used
727
+ var _paused = false; // Whether we are paused or not
728
+ var _aborted = false; // Whether the parser has aborted or not
729
+ var _delimiterError; // Temporary state between delimiter detection and processing results
730
+ var _fields = []; // Fields are from the header row of the input, if there is one
731
+ var _results = { // The last results returned from the parser
732
+ data: [],
733
+ errors: [],
734
+ meta: {}
735
+ };
736
+
737
+ if (isFunction(_config.step))
738
+ {
739
+ var userStep = _config.step;
740
+ _config.step = function(results)
741
+ {
742
+ _results = results;
743
+
744
+ if (needsHeaderRow())
745
+ processResults();
746
+ else // only call user's step function after header row
747
+ {
748
+ processResults();
749
+
750
+ // It's possbile that this line was empty and there's no row here after all
751
+ if (_results.data.length === 0)
752
+ return;
753
+
754
+ _stepCounter += results.data.length;
755
+ if (_config.preview && _stepCounter > _config.preview)
756
+ _parser.abort();
757
+ else
758
+ userStep(_results, self);
759
+ }
760
+ };
761
+ }
762
+
763
+ /**
764
+ * Parses input. Most users won't need, and shouldn't mess with, the baseIndex
765
+ * and ignoreLastRow parameters. They are used by streamers (wrapper functions)
766
+ * when an input comes in multiple chunks, like from a file.
767
+ */
768
+ this.parse = function(input, baseIndex, ignoreLastRow)
769
+ {
770
+ if (!_config.newline)
771
+ _config.newline = guessLineEndings(input);
772
+
773
+ _delimiterError = false;
774
+ if (!_config.delimiter)
775
+ {
776
+ var delimGuess = guessDelimiter(input, _config.newline);
777
+ if (delimGuess.successful)
778
+ _config.delimiter = delimGuess.bestDelimiter;
779
+ else
780
+ {
781
+ _delimiterError = true; // add error after parsing (otherwise it would be overwritten)
782
+ _config.delimiter = Papa.DefaultDelimiter;
783
+ }
784
+ _results.meta.delimiter = _config.delimiter;
785
+ }
786
+ else if(typeof _config.delimiter === 'function')
787
+ {
788
+ _config.delimiter = _config.delimiter(input);
789
+ _results.meta.delimiter = _config.delimiter;
790
+ }
791
+
792
+ var parserConfig = copy(_config);
793
+ if (_config.preview && _config.header)
794
+ parserConfig.preview++; // to compensate for header row
795
+
796
+ _input = input;
797
+ _parser = new Parser(parserConfig);
798
+ _results = _parser.parse(_input, baseIndex, ignoreLastRow);
799
+ processResults();
800
+ return _paused ? { meta: { paused: true } } : (_results || { meta: { paused: false } });
801
+ };
802
+
803
+ this.paused = function()
804
+ {
805
+ return _paused;
806
+ };
807
+
808
+ this.pause = function()
809
+ {
810
+ _paused = true;
811
+ _parser.abort();
812
+ _input = _input.substr(_parser.getCharIndex());
813
+ };
814
+
815
+ this.resume = function()
816
+ {
817
+ _paused = false;
818
+ self.streamer.parseChunk(_input);
819
+ };
820
+
821
+ this.aborted = function ()
822
+ {
823
+ return _aborted;
824
+ };
825
+
826
+ this.abort = function()
827
+ {
828
+ _aborted = true;
829
+ _parser.abort();
830
+ _results.meta.aborted = true;
831
+ if (isFunction(_config.complete))
832
+ _config.complete(_results);
833
+ _input = '';
834
+ };
835
+
836
+ function processResults()
837
+ {
838
+ if (_results && _delimiterError)
839
+ {
840
+ addError('Delimiter', 'UndetectableDelimiter', 'Unable to auto-detect delimiting character; defaulted to \''+Papa.DefaultDelimiter+'\'');
841
+ _delimiterError = false;
842
+ }
843
+
844
+ if (_config.skipEmptyLines)
845
+ {
846
+ for (var i = 0; i < _results.data.length; i++)
847
+ if (_results.data[i].length === 1 && _results.data[i][0] === '')
848
+ _results.data.splice(i--, 1);
849
+ }
850
+
851
+ if (needsHeaderRow())
852
+ fillHeaderFields();
853
+
854
+ return applyHeaderAndDynamicTyping();
855
+ }
856
+
857
+ function needsHeaderRow()
858
+ {
859
+ return _config.header && _fields.length === 0;
860
+ }
861
+
862
+ function fillHeaderFields()
863
+ {
864
+ if (!_results)
865
+ return;
866
+ for (var i = 0; needsHeaderRow() && i < _results.data.length; i++)
867
+ for (var j = 0; j < _results.data[i].length; j++)
868
+ _fields.push(_results.data[i][j]);
869
+ _results.data.splice(0, 1);
870
+ }
871
+
872
+ function parseDynamic(field, value)
873
+ {
874
+ if ((_config.dynamicTyping[field] || _config.dynamicTyping) === true)
875
+ {
876
+ if (value === 'true' || value === 'TRUE')
877
+ return true;
878
+ else if (value === 'false' || value === 'FALSE')
879
+ return false;
880
+ else
881
+ return tryParseFloat(value);
882
+ }
883
+ return value;
884
+ }
885
+
886
+ function applyHeaderAndDynamicTyping()
887
+ {
888
+ if (!_results || (!_config.header && !_config.dynamicTyping))
889
+ return _results;
890
+
891
+ for (var i = 0; i < _results.data.length; i++)
892
+ {
893
+ var row = _config.header ? {} : [];
894
+
895
+ for (var j = 0; j < _results.data[i].length; j++)
896
+ {
897
+ var field = j;
898
+ var value = _results.data[i][j];
899
+
900
+ if (_config.header)
901
+ field = j >= _fields.length ? '__parsed_extra' : _fields[j];
902
+
903
+ value = parseDynamic(field, value);
904
+
905
+ if (field === '__parsed_extra')
906
+ {
907
+ row[field] = row[field] || [];
908
+ row[field].push(value);
909
+ }
910
+ else
911
+ row[field] = value;
912
+ }
913
+
914
+ _results.data[i] = row;
915
+
916
+ if (_config.header)
917
+ {
918
+ if (j > _fields.length)
919
+ addError('FieldMismatch', 'TooManyFields', 'Too many fields: expected ' + _fields.length + ' fields but parsed ' + j, i);
920
+ else if (j < _fields.length)
921
+ addError('FieldMismatch', 'TooFewFields', 'Too few fields: expected ' + _fields.length + ' fields but parsed ' + j, i);
922
+ }
923
+ }
924
+
925
+ if (_config.header && _results.meta)
926
+ _results.meta.fields = _fields;
927
+ return _results;
928
+ }
929
+
930
+ function guessDelimiter(input, newline)
931
+ {
932
+ var delimChoices = [',', '\t', '|', ';', Papa.RECORD_SEP, Papa.UNIT_SEP];
933
+ var bestDelim, bestDelta, fieldCountPrevRow;
934
+
935
+ for (var i = 0; i < delimChoices.length; i++)
936
+ {
937
+ var delim = delimChoices[i];
938
+ var delta = 0, avgFieldCount = 0;
939
+ fieldCountPrevRow = undefined;
940
+
941
+ var preview = new Parser({
942
+ delimiter: delim,
943
+ newline: newline,
944
+ preview: 10
945
+ }).parse(input);
946
+
947
+ for (var j = 0; j < preview.data.length; j++)
948
+ {
949
+ var fieldCount = preview.data[j].length;
950
+ avgFieldCount += fieldCount;
951
+
952
+ if (typeof fieldCountPrevRow === 'undefined')
953
+ {
954
+ fieldCountPrevRow = fieldCount;
955
+ continue;
956
+ }
957
+ else if (fieldCount > 1)
958
+ {
959
+ delta += Math.abs(fieldCount - fieldCountPrevRow);
960
+ fieldCountPrevRow = fieldCount;
961
+ }
962
+ }
963
+
964
+ if (preview.data.length > 0)
965
+ avgFieldCount /= preview.data.length;
966
+
967
+ if ((typeof bestDelta === 'undefined' || delta < bestDelta)
968
+ && avgFieldCount > 1.99)
969
+ {
970
+ bestDelta = delta;
971
+ bestDelim = delim;
972
+ }
973
+ }
974
+
975
+ _config.delimiter = bestDelim;
976
+
977
+ return {
978
+ successful: !!bestDelim,
979
+ bestDelimiter: bestDelim
980
+ }
981
+ }
982
+
983
+ function guessLineEndings(input)
984
+ {
985
+ input = input.substr(0, 1024*1024); // max length 1 MB
986
+
987
+ var r = input.split('\r');
988
+
989
+ var n = input.split('\n');
990
+
991
+ var nAppearsFirst = (n.length > 1 && n[0].length < r[0].length);
992
+
993
+ if (r.length === 1 || nAppearsFirst)
994
+ return '\n';
995
+
996
+ var numWithN = 0;
997
+ for (var i = 0; i < r.length; i++)
998
+ {
999
+ if (r[i][0] === '\n')
1000
+ numWithN++;
1001
+ }
1002
+
1003
+ return numWithN >= r.length / 2 ? '\r\n' : '\r';
1004
+ }
1005
+
1006
+ function tryParseFloat(val)
1007
+ {
1008
+ var isNumber = FLOAT.test(val);
1009
+ return isNumber ? parseFloat(val) : val;
1010
+ }
1011
+
1012
+ function addError(type, code, msg, row)
1013
+ {
1014
+ _results.errors.push({
1015
+ type: type,
1016
+ code: code,
1017
+ message: msg,
1018
+ row: row
1019
+ });
1020
+ }
1021
+ }
1022
+
1023
+
1024
+
1025
+
1026
+
1027
+ /** The core parser implements speedy and correct CSV parsing */
1028
+ function Parser(config)
1029
+ {
1030
+ // Unpack the config object
1031
+ config = config || {};
1032
+ var delim = config.delimiter;
1033
+ var newline = config.newline;
1034
+ var comments = config.comments;
1035
+ var step = config.step;
1036
+ var preview = config.preview;
1037
+ var fastMode = config.fastMode;
1038
+ var quoteChar = config.quoteChar || '"';
1039
+
1040
+ // Delimiter must be valid
1041
+ if (typeof delim !== 'string'
1042
+ || Papa.BAD_DELIMITERS.indexOf(delim) > -1)
1043
+ delim = ',';
1044
+
1045
+ // Comment character must be valid
1046
+ if (comments === delim)
1047
+ throw 'Comment character same as delimiter';
1048
+ else if (comments === true)
1049
+ comments = '#';
1050
+ else if (typeof comments !== 'string'
1051
+ || Papa.BAD_DELIMITERS.indexOf(comments) > -1)
1052
+ comments = false;
1053
+
1054
+ // Newline must be valid: \r, \n, or \r\n
1055
+ if (newline != '\n' && newline != '\r' && newline != '\r\n')
1056
+ newline = '\n';
1057
+
1058
+ // We're gonna need these at the Parser scope
1059
+ var cursor = 0;
1060
+ var aborted = false;
1061
+
1062
+ this.parse = function(input, baseIndex, ignoreLastRow)
1063
+ {
1064
+ // For some reason, in Chrome, this speeds things up (!?)
1065
+ if (typeof input !== 'string')
1066
+ throw 'Input must be a string';
1067
+
1068
+ // We don't need to compute some of these every time parse() is called,
1069
+ // but having them in a more local scope seems to perform better
1070
+ var inputLen = input.length,
1071
+ delimLen = delim.length,
1072
+ newlineLen = newline.length,
1073
+ commentsLen = comments.length;
1074
+ var stepIsFunction = typeof step === 'function';
1075
+
1076
+ // Establish starting state
1077
+ cursor = 0;
1078
+ var data = [], errors = [], row = [], lastCursor = 0;
1079
+
1080
+ if (!input)
1081
+ return returnable();
1082
+
1083
+ if (fastMode || (fastMode !== false && input.indexOf(quoteChar) === -1))
1084
+ {
1085
+ var rows = input.split(newline);
1086
+ for (var i = 0; i < rows.length; i++)
1087
+ {
1088
+ var row = rows[i];
1089
+ cursor += row.length;
1090
+ if (i !== rows.length - 1)
1091
+ cursor += newline.length;
1092
+ else if (ignoreLastRow)
1093
+ return returnable();
1094
+ if (comments && row.substr(0, commentsLen) === comments)
1095
+ continue;
1096
+ if (stepIsFunction)
1097
+ {
1098
+ data = [];
1099
+ pushRow(row.split(delim));
1100
+ doStep();
1101
+ if (aborted)
1102
+ return returnable();
1103
+ }
1104
+ else
1105
+ pushRow(row.split(delim));
1106
+ if (preview && i >= preview)
1107
+ {
1108
+ data = data.slice(0, preview);
1109
+ return returnable(true);
1110
+ }
1111
+ }
1112
+ return returnable();
1113
+ }
1114
+
1115
+ var nextDelim = input.indexOf(delim, cursor);
1116
+ var nextNewline = input.indexOf(newline, cursor);
1117
+ var quoteCharRegex = new RegExp(quoteChar+quoteChar, 'g');
1118
+
1119
+ // Parser loop
1120
+ for (;;)
1121
+ {
1122
+ // Field has opening quote
1123
+ if (input[cursor] === quoteChar)
1124
+ {
1125
+ // Start our search for the closing quote where the cursor is
1126
+ var quoteSearch = cursor;
1127
+
1128
+ // Skip the opening quote
1129
+ cursor++;
1130
+
1131
+ for (;;)
1132
+ {
1133
+ // Find closing quote
1134
+ var quoteSearch = input.indexOf(quoteChar, quoteSearch+1);
1135
+
1136
+ if (quoteSearch === -1)
1137
+ {
1138
+ if (!ignoreLastRow) {
1139
+ // No closing quote... what a pity
1140
+ errors.push({
1141
+ type: 'Quotes',
1142
+ code: 'MissingQuotes',
1143
+ message: 'Quoted field unterminated',
1144
+ row: data.length, // row has yet to be inserted
1145
+ index: cursor
1146
+ });
1147
+ }
1148
+ return finish();
1149
+ }
1150
+
1151
+ if (quoteSearch === inputLen-1)
1152
+ {
1153
+ // Closing quote at EOF
1154
+ var value = input.substring(cursor, quoteSearch).replace(quoteCharRegex, quoteChar);
1155
+ return finish(value);
1156
+ }
1157
+
1158
+ // If this quote is escaped, it's part of the data; skip it
1159
+ if (input[quoteSearch+1] === quoteChar)
1160
+ {
1161
+ quoteSearch++;
1162
+ continue;
1163
+ }
1164
+
1165
+ if (input[quoteSearch+1] === delim)
1166
+ {
1167
+ // Closing quote followed by delimiter
1168
+ row.push(input.substring(cursor, quoteSearch).replace(quoteCharRegex, quoteChar));
1169
+ cursor = quoteSearch + 1 + delimLen;
1170
+ nextDelim = input.indexOf(delim, cursor);
1171
+ nextNewline = input.indexOf(newline, cursor);
1172
+ break;
1173
+ }
1174
+
1175
+ if (input.substr(quoteSearch+1, newlineLen) === newline)
1176
+ {
1177
+ // Closing quote followed by newline
1178
+ row.push(input.substring(cursor, quoteSearch).replace(quoteCharRegex, quoteChar));
1179
+ saveRow(quoteSearch + 1 + newlineLen);
1180
+ nextDelim = input.indexOf(delim, cursor); // because we may have skipped the nextDelim in the quoted field
1181
+
1182
+ if (stepIsFunction)
1183
+ {
1184
+ doStep();
1185
+ if (aborted)
1186
+ return returnable();
1187
+ }
1188
+
1189
+ if (preview && data.length >= preview)
1190
+ return returnable(true);
1191
+
1192
+ break;
1193
+ }
1194
+ }
1195
+
1196
+ continue;
1197
+ }
1198
+
1199
+ // Comment found at start of new line
1200
+ if (comments && row.length === 0 && input.substr(cursor, commentsLen) === comments)
1201
+ {
1202
+ if (nextNewline === -1) // Comment ends at EOF
1203
+ return returnable();
1204
+ cursor = nextNewline + newlineLen;
1205
+ nextNewline = input.indexOf(newline, cursor);
1206
+ nextDelim = input.indexOf(delim, cursor);
1207
+ continue;
1208
+ }
1209
+
1210
+ // Next delimiter comes before next newline, so we've reached end of field
1211
+ if (nextDelim !== -1 && (nextDelim < nextNewline || nextNewline === -1))
1212
+ {
1213
+ row.push(input.substring(cursor, nextDelim));
1214
+ cursor = nextDelim + delimLen;
1215
+ nextDelim = input.indexOf(delim, cursor);
1216
+ continue;
1217
+ }
1218
+
1219
+ // End of row
1220
+ if (nextNewline !== -1)
1221
+ {
1222
+ row.push(input.substring(cursor, nextNewline));
1223
+ saveRow(nextNewline + newlineLen);
1224
+
1225
+ if (stepIsFunction)
1226
+ {
1227
+ doStep();
1228
+ if (aborted)
1229
+ return returnable();
1230
+ }
1231
+
1232
+ if (preview && data.length >= preview)
1233
+ return returnable(true);
1234
+
1235
+ continue;
1236
+ }
1237
+
1238
+ break;
1239
+ }
1240
+
1241
+
1242
+ return finish();
1243
+
1244
+
1245
+ function pushRow(row)
1246
+ {
1247
+ data.push(row);
1248
+ lastCursor = cursor;
1249
+ }
1250
+
1251
+ /**
1252
+ * Appends the remaining input from cursor to the end into
1253
+ * row, saves the row, calls step, and returns the results.
1254
+ */
1255
+ function finish(value)
1256
+ {
1257
+ if (ignoreLastRow)
1258
+ return returnable();
1259
+ if (typeof value === 'undefined')
1260
+ value = input.substr(cursor);
1261
+ row.push(value);
1262
+ cursor = inputLen; // important in case parsing is paused
1263
+ pushRow(row);
1264
+ if (stepIsFunction)
1265
+ doStep();
1266
+ return returnable();
1267
+ }
1268
+
1269
+ /**
1270
+ * Appends the current row to the results. It sets the cursor
1271
+ * to newCursor and finds the nextNewline. The caller should
1272
+ * take care to execute user's step function and check for
1273
+ * preview and end parsing if necessary.
1274
+ */
1275
+ function saveRow(newCursor)
1276
+ {
1277
+ cursor = newCursor;
1278
+ pushRow(row);
1279
+ row = [];
1280
+ nextNewline = input.indexOf(newline, cursor);
1281
+ }
1282
+
1283
+ /** Returns an object with the results, errors, and meta. */
1284
+ function returnable(stopped)
1285
+ {
1286
+ return {
1287
+ data: data,
1288
+ errors: errors,
1289
+ meta: {
1290
+ delimiter: delim,
1291
+ linebreak: newline,
1292
+ aborted: aborted,
1293
+ truncated: !!stopped,
1294
+ cursor: lastCursor + (baseIndex || 0)
1295
+ }
1296
+ };
1297
+ }
1298
+
1299
+ /** Executes the user's step function and resets data & errors. */
1300
+ function doStep()
1301
+ {
1302
+ step(returnable());
1303
+ data = [], errors = [];
1304
+ }
1305
+ };
1306
+
1307
+ /** Sets the abort flag */
1308
+ this.abort = function()
1309
+ {
1310
+ aborted = true;
1311
+ };
1312
+
1313
+ /** Gets the cursor position */
1314
+ this.getCharIndex = function()
1315
+ {
1316
+ return cursor;
1317
+ };
1318
+ }
1319
+
1320
+
1321
+ // If you need to load Papa Parse asynchronously and you also need worker threads, hard-code
1322
+ // the script path here. See: https://github.com/mholt/PapaParse/issues/87#issuecomment-57885358
1323
+ function getScriptPath()
1324
+ {
1325
+ var scripts = document.getElementsByTagName('script');
1326
+ return scripts.length ? scripts[scripts.length - 1].src : '';
1327
+ }
1328
+
1329
+ function newWorker()
1330
+ {
1331
+ if (!Papa.WORKERS_SUPPORTED)
1332
+ return false;
1333
+ if (!LOADED_SYNC && Papa.SCRIPT_PATH === null)
1334
+ throw new Error(
1335
+ 'Script path cannot be determined automatically when Papa Parse is loaded asynchronously. ' +
1336
+ 'You need to set Papa.SCRIPT_PATH manually.'
1337
+ );
1338
+ var workerUrl = Papa.SCRIPT_PATH || AUTO_SCRIPT_PATH;
1339
+ // Append 'papaworker' to the search string to tell papaparse that this is our worker.
1340
+ workerUrl += (workerUrl.indexOf('?') !== -1 ? '&' : '?') + 'papaworker';
1341
+ var w = new global.Worker(workerUrl);
1342
+ w.onmessage = mainThreadReceivedMessage;
1343
+ w.id = workerIdCounter++;
1344
+ workers[w.id] = w;
1345
+ return w;
1346
+ }
1347
+
1348
+ /** Callback when main thread receives a message */
1349
+ function mainThreadReceivedMessage(e)
1350
+ {
1351
+ var msg = e.data;
1352
+ var worker = workers[msg.workerId];
1353
+ var aborted = false;
1354
+
1355
+ if (msg.error)
1356
+ worker.userError(msg.error, msg.file);
1357
+ else if (msg.results && msg.results.data)
1358
+ {
1359
+ var abort = function() {
1360
+ aborted = true;
1361
+ completeWorker(msg.workerId, { data: [], errors: [], meta: { aborted: true } });
1362
+ };
1363
+
1364
+ var handle = {
1365
+ abort: abort,
1366
+ pause: notImplemented,
1367
+ resume: notImplemented
1368
+ };
1369
+
1370
+ if (isFunction(worker.userStep))
1371
+ {
1372
+ for (var i = 0; i < msg.results.data.length; i++)
1373
+ {
1374
+ worker.userStep({
1375
+ data: [msg.results.data[i]],
1376
+ errors: msg.results.errors,
1377
+ meta: msg.results.meta
1378
+ }, handle);
1379
+ if (aborted)
1380
+ break;
1381
+ }
1382
+ delete msg.results; // free memory ASAP
1383
+ }
1384
+ else if (isFunction(worker.userChunk))
1385
+ {
1386
+ worker.userChunk(msg.results, handle, msg.file);
1387
+ delete msg.results;
1388
+ }
1389
+ }
1390
+
1391
+ if (msg.finished && !aborted)
1392
+ completeWorker(msg.workerId, msg.results);
1393
+ }
1394
+
1395
+ function completeWorker(workerId, results) {
1396
+ var worker = workers[workerId];
1397
+ if (isFunction(worker.userComplete))
1398
+ worker.userComplete(results);
1399
+ worker.terminate();
1400
+ delete workers[workerId];
1401
+ }
1402
+
1403
+ function notImplemented() {
1404
+ throw 'Not implemented.';
1405
+ }
1406
+
1407
+ /** Callback when worker thread receives a message */
1408
+ function workerThreadReceivedMessage(e)
1409
+ {
1410
+ var msg = e.data;
1411
+
1412
+ if (typeof Papa.WORKER_ID === 'undefined' && msg)
1413
+ Papa.WORKER_ID = msg.workerId;
1414
+
1415
+ if (typeof msg.input === 'string')
1416
+ {
1417
+ global.postMessage({
1418
+ workerId: Papa.WORKER_ID,
1419
+ results: Papa.parse(msg.input, msg.config),
1420
+ finished: true
1421
+ });
1422
+ }
1423
+ else if ((global.File && msg.input instanceof File) || msg.input instanceof Object) // thank you, Safari (see issue #106)
1424
+ {
1425
+ var results = Papa.parse(msg.input, msg.config);
1426
+ if (results)
1427
+ global.postMessage({
1428
+ workerId: Papa.WORKER_ID,
1429
+ results: results,
1430
+ finished: true
1431
+ });
1432
+ }
1433
+ }
1434
+
1435
+ /** Makes a deep copy of an array or object (mostly) */
1436
+ function copy(obj)
1437
+ {
1438
+ if (typeof obj !== 'object')
1439
+ return obj;
1440
+ var cpy = obj instanceof Array ? [] : {};
1441
+ for (var key in obj)
1442
+ cpy[key] = copy(obj[key]);
1443
+ return cpy;
1444
+ }
1445
+
1446
+ function bindFunction(f, self)
1447
+ {
1448
+ return function() { f.apply(self, arguments); };
1449
+ }
1450
+
1451
+ function isFunction(func)
1452
+ {
1453
+ return typeof func === 'function';
1454
+ }
1455
+
1456
+ return Papa;
1457
+ }));