opal-js_wrap-three 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (503) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -0
  3. data/Gemfile.lock +4 -4
  4. data/lib/opal/js_wrap/three/version.rb +1 -1
  5. data/lib-opal/js_wrap/three/WebGL.js +102 -0
  6. data/lib-opal/js_wrap/three/animation/AnimationClipCreator.js +116 -0
  7. data/lib-opal/js_wrap/three/animation/CCDIKSolver.js +436 -0
  8. data/lib-opal/js_wrap/three/animation/MMDAnimationHelper.js +941 -0
  9. data/lib-opal/js_wrap/three/animation/MMDPhysics.js +1183 -0
  10. data/lib-opal/js_wrap/three/cameras/CinematicCamera.js +204 -0
  11. data/lib-opal/js_wrap/three/controls/ArcballControls.js +2649 -0
  12. data/lib-opal/js_wrap/three/controls/DragControls.js +234 -0
  13. data/lib-opal/js_wrap/three/controls/FirstPersonControls.js +301 -0
  14. data/lib-opal/js_wrap/three/controls/FlyControls.js +357 -0
  15. data/lib-opal/js_wrap/three/controls/OrbitControls.js +908 -0
  16. data/lib-opal/js_wrap/three/controls/PointerLockControls.js +173 -0
  17. data/lib-opal/js_wrap/three/controls/TrackballControls.js +666 -0
  18. data/lib-opal/js_wrap/three/controls/TransformControls.js +1210 -0
  19. data/lib-opal/js_wrap/three/controls/experimental/CameraControls.js +860 -0
  20. data/lib-opal/js_wrap/three/csm/CSM.js +346 -0
  21. data/lib-opal/js_wrap/three/csm/CSMFrustum.js +123 -0
  22. data/lib-opal/js_wrap/three/csm/CSMHelper.js +197 -0
  23. data/lib-opal/js_wrap/three/csm/CSMShader.js +29 -0
  24. data/lib-opal/js_wrap/three/curves/CurveExtras.js +544 -0
  25. data/lib-opal/js_wrap/three/curves/NURBSCurve.js +122 -0
  26. data/lib-opal/js_wrap/three/curves/NURBSSurface.js +78 -0
  27. data/lib-opal/js_wrap/three/curves/NURBSUtils.js +413 -0
  28. data/lib-opal/js_wrap/three/deprecated/Geometry.js +1373 -0
  29. data/lib-opal/js_wrap/three/effects/AnaglyphEffect.js +113 -0
  30. data/lib-opal/js_wrap/three/effects/AsciiEffect.js +267 -0
  31. data/lib-opal/js_wrap/three/effects/OutlineEffect.js +400 -0
  32. data/lib-opal/js_wrap/three/effects/ParallaxBarrierEffect.js +90 -0
  33. data/lib-opal/js_wrap/three/effects/PeppersGhostEffect.js +160 -0
  34. data/lib-opal/js_wrap/three/effects/StereoEffect.js +63 -0
  35. data/lib-opal/js_wrap/three/environments/DebugEnvironment.js +107 -0
  36. data/lib-opal/js_wrap/three/environments/RoomEnvironment.js +166 -0
  37. data/lib-opal/js_wrap/three/exporters/ColladaExporter.js +442 -0
  38. data/lib-opal/js_wrap/three/exporters/DRACOExporter.js +205 -0
  39. data/lib-opal/js_wrap/three/exporters/GLTFExporter.js +2042 -0
  40. data/lib-opal/js_wrap/three/exporters/MMDExporter.js +189 -0
  41. data/lib-opal/js_wrap/three/exporters/OBJExporter.js +241 -0
  42. data/lib-opal/js_wrap/three/exporters/PLYExporter.js +370 -0
  43. data/lib-opal/js_wrap/three/exporters/STLExporter.js +186 -0
  44. data/lib-opal/js_wrap/three/exporters/USDZExporter.js +402 -0
  45. data/lib-opal/js_wrap/three/geometries/BoxLineGeometry.js +106 -0
  46. data/lib-opal/js_wrap/three/geometries/ConvexGeometry.js +88 -0
  47. data/lib-opal/js_wrap/three/geometries/DecalGeometry.js +302 -0
  48. data/lib-opal/js_wrap/three/geometries/LightningStrike.js +817 -0
  49. data/lib-opal/js_wrap/three/geometries/ParametricGeometries.js +280 -0
  50. data/lib-opal/js_wrap/three/geometries/ParametricGeometry.js +146 -0
  51. data/lib-opal/js_wrap/three/geometries/RoundedBoxGeometry.js +183 -0
  52. data/lib-opal/js_wrap/three/geometries/TeapotGeometry.js +352 -0
  53. data/lib-opal/js_wrap/three/geometries/TextGeometry.js +76 -0
  54. data/lib-opal/js_wrap/three/helpers/LightProbeHelper.js +95 -0
  55. data/lib-opal/js_wrap/three/helpers/PositionalAudioHelper.js +138 -0
  56. data/lib-opal/js_wrap/three/helpers/RectAreaLightHelper.js +115 -0
  57. data/lib-opal/js_wrap/three/helpers/VertexNormalsHelper.js +131 -0
  58. data/lib-opal/js_wrap/three/helpers/VertexTangentsHelper.js +118 -0
  59. data/lib-opal/js_wrap/three/interactive/HTMLMesh.js +307 -0
  60. data/lib-opal/js_wrap/three/interactive/InteractiveGroup.js +138 -0
  61. data/lib-opal/js_wrap/three/interactive/SelectionBox.js +264 -0
  62. data/lib-opal/js_wrap/three/interactive/SelectionHelper.js +88 -0
  63. data/lib-opal/js_wrap/three/libs/OimoPhysics/OimoPhysics.js +46059 -0
  64. data/lib-opal/js_wrap/three/libs/OimoPhysics/index.js +92 -0
  65. data/lib-opal/js_wrap/three/libs/chevrotain.module.min.js +6947 -0
  66. data/lib-opal/js_wrap/three/libs/ecsy.module.js +1999 -0
  67. data/lib-opal/js_wrap/three/libs/fflate.module.js +3002 -0
  68. data/lib-opal/js_wrap/three/libs/flow.module.js +3033 -0
  69. data/lib-opal/js_wrap/three/libs/ktx-parse.module.js +392 -0
  70. data/lib-opal/js_wrap/three/libs/lil-gui.module.min.js +821 -0
  71. data/lib-opal/js_wrap/three/libs/meshopt_decoder.module.js +136 -0
  72. data/lib-opal/js_wrap/three/libs/mmdparser.module.js +11022 -0
  73. data/lib-opal/js_wrap/three/libs/motion-controllers.module.js +589 -0
  74. data/lib-opal/js_wrap/three/libs/opentype.module.min.js +6132 -0
  75. data/lib-opal/js_wrap/three/libs/potpack.module.js +171 -0
  76. data/lib-opal/js_wrap/three/libs/rhino3dm/rhino3dm.js +6781 -0
  77. data/lib-opal/js_wrap/three/libs/rhino3dm/rhino3dm.module.js +6783 -0
  78. data/lib-opal/js_wrap/three/libs/stats.module.js +139 -0
  79. data/lib-opal/js_wrap/three/libs/tween.module.min.js +349 -0
  80. data/lib-opal/js_wrap/three/lights/LightProbeGenerator.js +233 -0
  81. data/lib-opal/js_wrap/three/lights/RectAreaLightUniformsLib.js +75 -0
  82. data/lib-opal/js_wrap/three/lines/Line2.js +66 -0
  83. data/lib-opal/js_wrap/three/lines/LineGeometry.js +122 -0
  84. data/lib-opal/js_wrap/three/lines/LineMaterial.js +227 -0
  85. data/lib-opal/js_wrap/three/lines/LineSegments2.js +312 -0
  86. data/lib-opal/js_wrap/three/lines/LineSegmentsGeometry.js +238 -0
  87. data/lib-opal/js_wrap/three/lines/Wireframe.js +98 -0
  88. data/lib-opal/js_wrap/three/lines/WireframeGeometry2.js +65 -0
  89. data/lib-opal/js_wrap/three/loaders/3DMLoader.js +1230 -0
  90. data/lib-opal/js_wrap/three/loaders/3MFLoader.js +1123 -0
  91. data/lib-opal/js_wrap/three/loaders/AMFLoader.js +445 -0
  92. data/lib-opal/js_wrap/three/loaders/BVHLoader.js +365 -0
  93. data/lib-opal/js_wrap/three/loaders/BasisTextureLoader.js +692 -0
  94. data/lib-opal/js_wrap/three/loaders/ColladaLoader.js +3046 -0
  95. data/lib-opal/js_wrap/three/loaders/DDSLoader.js +264 -0
  96. data/lib-opal/js_wrap/three/loaders/DRACOLoader.js +531 -0
  97. data/lib-opal/js_wrap/three/loaders/EXRLoader.js +1834 -0
  98. data/lib-opal/js_wrap/three/loaders/FBXLoader.js +3125 -0
  99. data/lib-opal/js_wrap/three/loaders/FontLoader.js +201 -0
  100. data/lib-opal/js_wrap/three/loaders/GCodeLoader.js +248 -0
  101. data/lib-opal/js_wrap/three/loaders/GLTFLoader.js +3334 -0
  102. data/lib-opal/js_wrap/three/loaders/HDRCubeTextureLoader.js +144 -0
  103. data/lib-opal/js_wrap/three/loaders/IFCLoader.js +2395 -0
  104. data/lib-opal/js_wrap/three/loaders/KMZLoader.js +142 -0
  105. data/lib-opal/js_wrap/three/loaders/KTX2Loader.js +535 -0
  106. data/lib-opal/js_wrap/three/loaders/KTXLoader.js +202 -0
  107. data/lib-opal/js_wrap/three/loaders/LDrawLoader.js +1737 -0
  108. data/lib-opal/js_wrap/three/loaders/LUT3dlLoader.js +163 -0
  109. data/lib-opal/js_wrap/three/loaders/LUTCubeLoader.js +171 -0
  110. data/lib-opal/js_wrap/three/loaders/LWOLoader.js +831 -0
  111. data/lib-opal/js_wrap/three/loaders/LogLuvLoader.js +713 -0
  112. data/lib-opal/js_wrap/three/loaders/LottieLoader.js +103 -0
  113. data/lib-opal/js_wrap/three/loaders/MD2Loader.js +258 -0
  114. data/lib-opal/js_wrap/three/loaders/MDDLoader.js +116 -0
  115. data/lib-opal/js_wrap/three/loaders/MMDLoader.js +1687 -0
  116. data/lib-opal/js_wrap/three/loaders/MTLLoader.js +465 -0
  117. data/lib-opal/js_wrap/three/loaders/NRRDLoader.js +554 -0
  118. data/lib-opal/js_wrap/three/loaders/NodeMaterialLoader.js +248 -0
  119. data/lib-opal/js_wrap/three/loaders/OBJLoader.js +673 -0
  120. data/lib-opal/js_wrap/three/loaders/PCDLoader.js +322 -0
  121. data/lib-opal/js_wrap/three/loaders/PDBLoader.js +318 -0
  122. data/lib-opal/js_wrap/three/loaders/PLYLoader.js +489 -0
  123. data/lib-opal/js_wrap/three/loaders/PRWMLoader.js +247 -0
  124. data/lib-opal/js_wrap/three/loaders/PVRLoader.js +240 -0
  125. data/lib-opal/js_wrap/three/loaders/RGBELoader.js +462 -0
  126. data/lib-opal/js_wrap/three/loaders/RGBMLoader.js +1169 -0
  127. data/lib-opal/js_wrap/three/loaders/STLLoader.js +345 -0
  128. data/lib-opal/js_wrap/three/loaders/SVGLoader.js +2162 -0
  129. data/lib-opal/js_wrap/three/loaders/TDSLoader.js +982 -0
  130. data/lib-opal/js_wrap/three/loaders/TGALoader.js +444 -0
  131. data/lib-opal/js_wrap/three/loaders/TTFLoader.js +210 -0
  132. data/lib-opal/js_wrap/three/loaders/TiltLoader.js +391 -0
  133. data/lib-opal/js_wrap/three/loaders/VOXLoader.js +272 -0
  134. data/lib-opal/js_wrap/three/loaders/VRMLLoader.js +2685 -0
  135. data/lib-opal/js_wrap/three/loaders/VRMLoader.js +103 -0
  136. data/lib-opal/js_wrap/three/loaders/VTKLoader.js +894 -0
  137. data/lib-opal/js_wrap/three/loaders/XYZLoader.js +136 -0
  138. data/lib-opal/js_wrap/three/loaders/ifc/web-ifc-api.js +60504 -0
  139. data/lib-opal/js_wrap/three/loaders/lwo/IFFParser.js +931 -0
  140. data/lib-opal/js_wrap/three/loaders/lwo/LWO2Parser.js +450 -0
  141. data/lib-opal/js_wrap/three/loaders/lwo/LWO3Parser.js +406 -0
  142. data/lib-opal/js_wrap/three/math/Capsule.js +133 -0
  143. data/lib-opal/js_wrap/three/math/ColorConverter.js +104 -0
  144. data/lib-opal/js_wrap/three/math/ConvexHull.js +924 -0
  145. data/lib-opal/js_wrap/three/math/ImprovedNoise.js +86 -0
  146. data/lib-opal/js_wrap/three/math/Lut.js +170 -0
  147. data/lib-opal/js_wrap/three/math/MeshSurfaceSampler.js +187 -0
  148. data/lib-opal/js_wrap/three/math/OBB.js +345 -0
  149. data/lib-opal/js_wrap/three/math/Octree.js +409 -0
  150. data/lib-opal/js_wrap/three/math/SimplexNoise.js +425 -0
  151. data/lib-opal/js_wrap/three/misc/ConvexObjectBreaker.js +447 -0
  152. data/lib-opal/js_wrap/three/misc/GPUComputationRenderer.js +322 -0
  153. data/lib-opal/js_wrap/three/misc/Gyroscope.js +94 -0
  154. data/lib-opal/js_wrap/three/misc/MD2Character.js +225 -0
  155. data/lib-opal/js_wrap/three/misc/MD2CharacterComplex.js +424 -0
  156. data/lib-opal/js_wrap/three/misc/MorphAnimMesh.js +109 -0
  157. data/lib-opal/js_wrap/three/misc/MorphBlendMesh.js +283 -0
  158. data/lib-opal/js_wrap/three/misc/ProgressiveLightMap.js +324 -0
  159. data/lib-opal/js_wrap/three/misc/RollerCoaster.js +489 -0
  160. data/lib-opal/js_wrap/three/misc/TubePainter.js +158 -0
  161. data/lib-opal/js_wrap/three/misc/Volume.js +427 -0
  162. data/lib-opal/js_wrap/three/misc/VolumeSlice.js +210 -0
  163. data/lib-opal/js_wrap/three/modifiers/CurveModifier.js +291 -0
  164. data/lib-opal/js_wrap/three/modifiers/EdgeSplitModifier.js +308 -0
  165. data/lib-opal/js_wrap/three/modifiers/SimplifyModifier.js +435 -0
  166. data/lib-opal/js_wrap/three/modifiers/TessellateModifier.js +264 -0
  167. data/lib-opal/js_wrap/three/node-editor/NodeEditor.js +402 -0
  168. data/lib-opal/js_wrap/three/node-editor/accessors/NormalEditor.js +80 -0
  169. data/lib-opal/js_wrap/three/node-editor/accessors/PositionEditor.js +80 -0
  170. data/lib-opal/js_wrap/three/node-editor/accessors/UVEditor.js +71 -0
  171. data/lib-opal/js_wrap/three/node-editor/display/BlendEditor.js +78 -0
  172. data/lib-opal/js_wrap/three/node-editor/inputs/ColorEditor.js +111 -0
  173. data/lib-opal/js_wrap/three/node-editor/inputs/FloatEditor.js +69 -0
  174. data/lib-opal/js_wrap/three/node-editor/inputs/SliderEditor.js +97 -0
  175. data/lib-opal/js_wrap/three/node-editor/inputs/Vector2Editor.js +73 -0
  176. data/lib-opal/js_wrap/three/node-editor/inputs/Vector3Editor.js +75 -0
  177. data/lib-opal/js_wrap/three/node-editor/inputs/Vector4Editor.js +77 -0
  178. data/lib-opal/js_wrap/three/node-editor/materials/StandardMaterialEditor.js +121 -0
  179. data/lib-opal/js_wrap/three/node-editor/math/DotEditor.js +76 -0
  180. data/lib-opal/js_wrap/three/node-editor/math/InvertEditor.js +80 -0
  181. data/lib-opal/js_wrap/three/node-editor/math/LimiterEditor.js +85 -0
  182. data/lib-opal/js_wrap/three/node-editor/math/NormalizeEditor.js +69 -0
  183. data/lib-opal/js_wrap/three/node-editor/math/OperatorEditor.js +91 -0
  184. data/lib-opal/js_wrap/three/node-editor/math/PowerEditor.js +73 -0
  185. data/lib-opal/js_wrap/three/node-editor/math/TrigonometryEditor.js +83 -0
  186. data/lib-opal/js_wrap/three/node-editor/procedural/CheckerEditor.js +69 -0
  187. data/lib-opal/js_wrap/three/node-editor/utils/OscillatorEditor.js +87 -0
  188. data/lib-opal/js_wrap/three/node-editor/utils/TimerEditor.js +89 -0
  189. data/lib-opal/js_wrap/three/nodes/Nodes.js +481 -0
  190. data/lib-opal/js_wrap/three/nodes/accessors/CameraNode.js +222 -0
  191. data/lib-opal/js_wrap/three/nodes/accessors/ColorsNode.js +99 -0
  192. data/lib-opal/js_wrap/three/nodes/accessors/LightNode.js +100 -0
  193. data/lib-opal/js_wrap/three/nodes/accessors/NormalNode.js +152 -0
  194. data/lib-opal/js_wrap/three/nodes/accessors/PositionNode.js +163 -0
  195. data/lib-opal/js_wrap/three/nodes/accessors/ReflectNode.js +161 -0
  196. data/lib-opal/js_wrap/three/nodes/accessors/ResolutionNode.js +99 -0
  197. data/lib-opal/js_wrap/three/nodes/accessors/ScreenUVNode.js +101 -0
  198. data/lib-opal/js_wrap/three/nodes/accessors/UVNode.js +105 -0
  199. data/lib-opal/js_wrap/three/nodes/core/AttributeNode.js +106 -0
  200. data/lib-opal/js_wrap/three/nodes/core/ConstNode.js +149 -0
  201. data/lib-opal/js_wrap/three/nodes/core/ExpressionNode.js +57 -0
  202. data/lib-opal/js_wrap/three/nodes/core/FunctionCallNode.js +138 -0
  203. data/lib-opal/js_wrap/three/nodes/core/FunctionNode.js +259 -0
  204. data/lib-opal/js_wrap/three/nodes/core/InputNode.js +124 -0
  205. data/lib-opal/js_wrap/three/nodes/core/Node.js +193 -0
  206. data/lib-opal/js_wrap/three/nodes/core/NodeBuilder.js +782 -0
  207. data/lib-opal/js_wrap/three/nodes/core/NodeFrame.js +69 -0
  208. data/lib-opal/js_wrap/three/nodes/core/NodeLib.js +56 -0
  209. data/lib-opal/js_wrap/three/nodes/core/NodeUniform.js +53 -0
  210. data/lib-opal/js_wrap/three/nodes/core/NodeUtils.js +60 -0
  211. data/lib-opal/js_wrap/three/nodes/core/StructNode.js +131 -0
  212. data/lib-opal/js_wrap/three/nodes/core/TempNode.js +160 -0
  213. data/lib-opal/js_wrap/three/nodes/core/VarNode.js +105 -0
  214. data/lib-opal/js_wrap/three/nodes/effects/BlurNode.js +160 -0
  215. data/lib-opal/js_wrap/three/nodes/effects/ColorAdjustmentNode.js +139 -0
  216. data/lib-opal/js_wrap/three/nodes/effects/LuminanceNode.js +106 -0
  217. data/lib-opal/js_wrap/three/nodes/inputs/BoolNode.js +95 -0
  218. data/lib-opal/js_wrap/three/nodes/inputs/ColorNode.js +99 -0
  219. data/lib-opal/js_wrap/three/nodes/inputs/CubeTextureNode.js +136 -0
  220. data/lib-opal/js_wrap/three/nodes/inputs/FloatNode.js +95 -0
  221. data/lib-opal/js_wrap/three/nodes/inputs/IntNode.js +95 -0
  222. data/lib-opal/js_wrap/three/nodes/inputs/Matrix3Node.js +102 -0
  223. data/lib-opal/js_wrap/three/nodes/inputs/Matrix4Node.js +102 -0
  224. data/lib-opal/js_wrap/three/nodes/inputs/PropertyNode.js +85 -0
  225. data/lib-opal/js_wrap/three/nodes/inputs/RTTNode.js +164 -0
  226. data/lib-opal/js_wrap/three/nodes/inputs/ReflectorNode.js +111 -0
  227. data/lib-opal/js_wrap/three/nodes/inputs/ScreenNode.js +69 -0
  228. data/lib-opal/js_wrap/three/nodes/inputs/TextureNode.js +140 -0
  229. data/lib-opal/js_wrap/three/nodes/inputs/Vector2Node.js +98 -0
  230. data/lib-opal/js_wrap/three/nodes/inputs/Vector3Node.js +99 -0
  231. data/lib-opal/js_wrap/three/nodes/inputs/Vector4Node.js +100 -0
  232. data/lib-opal/js_wrap/three/nodes/materials/BasicNodeMaterial.js +63 -0
  233. data/lib-opal/js_wrap/three/nodes/materials/MeshStandardNodeMaterial.js +63 -0
  234. data/lib-opal/js_wrap/three/nodes/materials/NodeMaterial.js +202 -0
  235. data/lib-opal/js_wrap/three/nodes/materials/PhongNodeMaterial.js +63 -0
  236. data/lib-opal/js_wrap/three/nodes/materials/SpriteNodeMaterial.js +63 -0
  237. data/lib-opal/js_wrap/three/nodes/materials/StandardNodeMaterial.js +63 -0
  238. data/lib-opal/js_wrap/three/nodes/materials/nodes/BasicNode.js +146 -0
  239. data/lib-opal/js_wrap/three/nodes/materials/nodes/MeshStandardNode.js +133 -0
  240. data/lib-opal/js_wrap/three/nodes/materials/nodes/PhongNode.js +273 -0
  241. data/lib-opal/js_wrap/three/nodes/materials/nodes/RawNode.js +101 -0
  242. data/lib-opal/js_wrap/three/nodes/materials/nodes/SpriteNode.js +176 -0
  243. data/lib-opal/js_wrap/three/nodes/materials/nodes/StandardNode.js +397 -0
  244. data/lib-opal/js_wrap/three/nodes/math/CondNode.js +151 -0
  245. data/lib-opal/js_wrap/three/nodes/math/MathNode.js +266 -0
  246. data/lib-opal/js_wrap/three/nodes/math/OperatorNode.js +120 -0
  247. data/lib-opal/js_wrap/three/nodes/misc/BumpMapNode.js +139 -0
  248. data/lib-opal/js_wrap/three/nodes/misc/NormalMapNode.js +122 -0
  249. data/lib-opal/js_wrap/three/nodes/misc/TextureCubeNode.js +107 -0
  250. data/lib-opal/js_wrap/three/nodes/misc/TextureCubeUVNode.js +191 -0
  251. data/lib-opal/js_wrap/three/nodes/postprocessing/NodePass.js +117 -0
  252. data/lib-opal/js_wrap/three/nodes/postprocessing/NodePostProcessing.js +128 -0
  253. data/lib-opal/js_wrap/three/nodes/procedural/CheckerNode.js +104 -0
  254. data/lib-opal/js_wrap/three/nodes/procedural/Fractal3DNode.js +121 -0
  255. data/lib-opal/js_wrap/three/nodes/procedural/Noise2DNode.js +115 -0
  256. data/lib-opal/js_wrap/three/nodes/procedural/Noise3DNode.js +112 -0
  257. data/lib-opal/js_wrap/three/nodes/utils/BypassNode.js +115 -0
  258. data/lib-opal/js_wrap/three/nodes/utils/ColorSpaceNode.js +214 -0
  259. data/lib-opal/js_wrap/three/nodes/utils/JoinNode.js +138 -0
  260. data/lib-opal/js_wrap/three/nodes/utils/MaxMIPLevelNode.js +88 -0
  261. data/lib-opal/js_wrap/three/nodes/utils/RemapNode.js +117 -0
  262. data/lib-opal/js_wrap/three/nodes/utils/SpecularMIPLevelNode.js +121 -0
  263. data/lib-opal/js_wrap/three/nodes/utils/SubSlotNode.js +112 -0
  264. data/lib-opal/js_wrap/three/nodes/utils/SwitchNode.js +129 -0
  265. data/lib-opal/js_wrap/three/nodes/utils/TimerNode.js +126 -0
  266. data/lib-opal/js_wrap/three/nodes/utils/UVTransformNode.js +104 -0
  267. data/lib-opal/js_wrap/three/nodes/utils/VelocityNode.js +181 -0
  268. data/lib-opal/js_wrap/three/objects/Lensflare.js +285 -0
  269. data/lib-opal/js_wrap/three/objects/LightningStorm.js +238 -0
  270. data/lib-opal/js_wrap/three/objects/MarchingCubes.js +667 -0
  271. data/lib-opal/js_wrap/three/objects/Reflector.js +205 -0
  272. data/lib-opal/js_wrap/three/objects/ReflectorForSSRPass.js +288 -0
  273. data/lib-opal/js_wrap/three/objects/ReflectorRTT.js +63 -0
  274. data/lib-opal/js_wrap/three/objects/Refractor.js +243 -0
  275. data/lib-opal/js_wrap/three/objects/ShadowMesh.js +100 -0
  276. data/lib-opal/js_wrap/three/objects/Sky.js +107 -0
  277. data/lib-opal/js_wrap/three/objects/Water.js +246 -0
  278. data/lib-opal/js_wrap/three/objects/Water2.js +238 -0
  279. data/lib-opal/js_wrap/three/offscreen/jank.js +51 -0
  280. data/lib-opal/js_wrap/three/offscreen/offscreen.js +24 -0
  281. data/lib-opal/js_wrap/three/offscreen/scene.js +99 -0
  282. data/lib-opal/js_wrap/three/physics/AmmoPhysics.js +266 -0
  283. data/lib-opal/js_wrap/three/physics/OimoPhysics.js +214 -0
  284. data/lib-opal/js_wrap/three/postprocessing/AdaptiveToneMappingPass.js +307 -0
  285. data/lib-opal/js_wrap/three/postprocessing/AfterimagePass.js +116 -0
  286. data/lib-opal/js_wrap/three/postprocessing/BloomPass.js +132 -0
  287. data/lib-opal/js_wrap/three/postprocessing/BokehPass.js +143 -0
  288. data/lib-opal/js_wrap/three/postprocessing/ClearPass.js +85 -0
  289. data/lib-opal/js_wrap/three/postprocessing/CubeTexturePass.js +104 -0
  290. data/lib-opal/js_wrap/three/postprocessing/DotScreenPass.js +90 -0
  291. data/lib-opal/js_wrap/three/postprocessing/EffectComposer.js +272 -0
  292. data/lib-opal/js_wrap/three/postprocessing/FilmPass.js +91 -0
  293. data/lib-opal/js_wrap/three/postprocessing/GlitchPass.js +140 -0
  294. data/lib-opal/js_wrap/three/postprocessing/HalftonePass.js +108 -0
  295. data/lib-opal/js_wrap/three/postprocessing/LUTPass.js +132 -0
  296. data/lib-opal/js_wrap/three/postprocessing/MaskPass.js +142 -0
  297. data/lib-opal/js_wrap/three/postprocessing/OutlinePass.js +480 -0
  298. data/lib-opal/js_wrap/three/postprocessing/Pass.js +101 -0
  299. data/lib-opal/js_wrap/three/postprocessing/RenderPass.js +109 -0
  300. data/lib-opal/js_wrap/three/postprocessing/SAOPass.js +384 -0
  301. data/lib-opal/js_wrap/three/postprocessing/SMAAPass.js +199 -0
  302. data/lib-opal/js_wrap/three/postprocessing/SSAARenderPass.js +186 -0
  303. data/lib-opal/js_wrap/three/postprocessing/SSAOPass.js +388 -0
  304. data/lib-opal/js_wrap/three/postprocessing/SSRPass.js +537 -0
  305. data/lib-opal/js_wrap/three/postprocessing/SSRrPass.js +481 -0
  306. data/lib-opal/js_wrap/three/postprocessing/SavePass.js +96 -0
  307. data/lib-opal/js_wrap/three/postprocessing/ShaderPass.js +98 -0
  308. data/lib-opal/js_wrap/three/postprocessing/TAARenderPass.js +159 -0
  309. data/lib-opal/js_wrap/three/postprocessing/TexturePass.js +91 -0
  310. data/lib-opal/js_wrap/three/postprocessing/UnrealBloomPass.js +335 -0
  311. data/lib-opal/js_wrap/three/renderers/CSS2DRenderer.js +213 -0
  312. data/lib-opal/js_wrap/three/renderers/CSS3DRenderer.js +277 -0
  313. data/lib-opal/js_wrap/three/renderers/Projector.js +733 -0
  314. data/lib-opal/js_wrap/three/renderers/SVGRenderer.js +470 -0
  315. data/lib-opal/js_wrap/three/renderers/nodes/Nodes.js +531 -0
  316. data/lib-opal/js_wrap/three/renderers/nodes/ShaderNode.js +386 -0
  317. data/lib-opal/js_wrap/three/renderers/nodes/accessors/CameraNode.js +114 -0
  318. data/lib-opal/js_wrap/three/renderers/nodes/accessors/MaterialNode.js +140 -0
  319. data/lib-opal/js_wrap/three/renderers/nodes/accessors/MaterialReferenceNode.js +79 -0
  320. data/lib-opal/js_wrap/three/renderers/nodes/accessors/ModelNode.js +62 -0
  321. data/lib-opal/js_wrap/three/renderers/nodes/accessors/ModelViewProjectionNode.js +80 -0
  322. data/lib-opal/js_wrap/three/renderers/nodes/accessors/NormalNode.js +113 -0
  323. data/lib-opal/js_wrap/three/renderers/nodes/accessors/Object3DNode.js +136 -0
  324. data/lib-opal/js_wrap/three/renderers/nodes/accessors/PointUVNode.js +70 -0
  325. data/lib-opal/js_wrap/three/renderers/nodes/accessors/PositionNode.js +117 -0
  326. data/lib-opal/js_wrap/three/renderers/nodes/accessors/ReferenceNode.js +124 -0
  327. data/lib-opal/js_wrap/three/renderers/nodes/accessors/SkinningNode.js +129 -0
  328. data/lib-opal/js_wrap/three/renderers/nodes/accessors/UVNode.js +77 -0
  329. data/lib-opal/js_wrap/three/renderers/nodes/core/ArrayInputNode.js +74 -0
  330. data/lib-opal/js_wrap/three/renderers/nodes/core/AttributeNode.js +97 -0
  331. data/lib-opal/js_wrap/three/renderers/nodes/core/BypassNode.js +84 -0
  332. data/lib-opal/js_wrap/three/renderers/nodes/core/CodeNode.js +131 -0
  333. data/lib-opal/js_wrap/three/renderers/nodes/core/ContextNode.js +84 -0
  334. data/lib-opal/js_wrap/three/renderers/nodes/core/ExpressionNode.js +81 -0
  335. data/lib-opal/js_wrap/three/renderers/nodes/core/FunctionCallNode.js +123 -0
  336. data/lib-opal/js_wrap/three/renderers/nodes/core/FunctionNode.js +126 -0
  337. data/lib-opal/js_wrap/three/renderers/nodes/core/InputNode.js +103 -0
  338. data/lib-opal/js_wrap/three/renderers/nodes/core/Node.js +120 -0
  339. data/lib-opal/js_wrap/three/renderers/nodes/core/NodeAttribute.js +37 -0
  340. data/lib-opal/js_wrap/three/renderers/nodes/core/NodeBuilder.js +650 -0
  341. data/lib-opal/js_wrap/three/renderers/nodes/core/NodeCode.js +42 -0
  342. data/lib-opal/js_wrap/three/renderers/nodes/core/NodeFrame.js +70 -0
  343. data/lib-opal/js_wrap/three/renderers/nodes/core/NodeFunction.js +55 -0
  344. data/lib-opal/js_wrap/three/renderers/nodes/core/NodeFunctionInput.js +44 -0
  345. data/lib-opal/js_wrap/three/renderers/nodes/core/NodeKeywords.js +117 -0
  346. data/lib-opal/js_wrap/three/renderers/nodes/core/NodeParser.js +46 -0
  347. data/lib-opal/js_wrap/three/renderers/nodes/core/NodeUniform.js +55 -0
  348. data/lib-opal/js_wrap/three/renderers/nodes/core/NodeVar.js +37 -0
  349. data/lib-opal/js_wrap/three/renderers/nodes/core/NodeVary.js +37 -0
  350. data/lib-opal/js_wrap/three/renderers/nodes/core/PropertyNode.js +90 -0
  351. data/lib-opal/js_wrap/three/renderers/nodes/core/TempNode.js +89 -0
  352. data/lib-opal/js_wrap/three/renderers/nodes/core/VarNode.js +101 -0
  353. data/lib-opal/js_wrap/three/renderers/nodes/core/VaryNode.js +101 -0
  354. data/lib-opal/js_wrap/three/renderers/nodes/core/constants.js +42 -0
  355. data/lib-opal/js_wrap/three/renderers/nodes/display/ColorSpaceNode.js +165 -0
  356. data/lib-opal/js_wrap/three/renderers/nodes/display/NormalMapNode.js +120 -0
  357. data/lib-opal/js_wrap/three/renderers/nodes/functions/BSDFs.js +133 -0
  358. data/lib-opal/js_wrap/three/renderers/nodes/inputs/BufferNode.js +78 -0
  359. data/lib-opal/js_wrap/three/renderers/nodes/inputs/ColorNode.js +67 -0
  360. data/lib-opal/js_wrap/three/renderers/nodes/inputs/FloatNode.js +67 -0
  361. data/lib-opal/js_wrap/three/renderers/nodes/inputs/IntNode.js +67 -0
  362. data/lib-opal/js_wrap/three/renderers/nodes/inputs/Matrix3Node.js +67 -0
  363. data/lib-opal/js_wrap/three/renderers/nodes/inputs/Matrix4Node.js +67 -0
  364. data/lib-opal/js_wrap/three/renderers/nodes/inputs/TextureNode.js +120 -0
  365. data/lib-opal/js_wrap/three/renderers/nodes/inputs/Vector2Node.js +67 -0
  366. data/lib-opal/js_wrap/three/renderers/nodes/inputs/Vector3Node.js +67 -0
  367. data/lib-opal/js_wrap/three/renderers/nodes/inputs/Vector4Node.js +67 -0
  368. data/lib-opal/js_wrap/three/renderers/nodes/lights/LightContextNode.js +103 -0
  369. data/lib-opal/js_wrap/three/renderers/nodes/lights/LightNode.js +115 -0
  370. data/lib-opal/js_wrap/three/renderers/nodes/lights/LightsNode.js +117 -0
  371. data/lib-opal/js_wrap/three/renderers/nodes/materials/LineBasicNodeMaterial.js +82 -0
  372. data/lib-opal/js_wrap/three/renderers/nodes/materials/Materials.js +49 -0
  373. data/lib-opal/js_wrap/three/renderers/nodes/materials/MeshBasicNodeMaterial.js +82 -0
  374. data/lib-opal/js_wrap/three/renderers/nodes/materials/MeshStandardNodeMaterial.js +96 -0
  375. data/lib-opal/js_wrap/three/renderers/nodes/materials/PointsNodeMaterial.js +84 -0
  376. data/lib-opal/js_wrap/three/renderers/nodes/math/CondNode.js +98 -0
  377. data/lib-opal/js_wrap/three/renderers/nodes/math/MathNode.js +255 -0
  378. data/lib-opal/js_wrap/three/renderers/nodes/math/OperatorNode.js +163 -0
  379. data/lib-opal/js_wrap/three/renderers/nodes/parsers/GLSLNodeFunction.js +158 -0
  380. data/lib-opal/js_wrap/three/renderers/nodes/parsers/GLSLNodeParser.js +68 -0
  381. data/lib-opal/js_wrap/three/renderers/nodes/parsers/WGSLNodeFunction.js +126 -0
  382. data/lib-opal/js_wrap/three/renderers/nodes/parsers/WGSLNodeParser.js +68 -0
  383. data/lib-opal/js_wrap/three/renderers/nodes/procedural/CheckerNode.js +84 -0
  384. data/lib-opal/js_wrap/three/renderers/nodes/utils/ArrayElementNode.js +79 -0
  385. data/lib-opal/js_wrap/three/renderers/nodes/utils/ConvertNode.js +82 -0
  386. data/lib-opal/js_wrap/three/renderers/nodes/utils/JoinNode.js +88 -0
  387. data/lib-opal/js_wrap/three/renderers/nodes/utils/OscNode.js +105 -0
  388. data/lib-opal/js_wrap/three/renderers/nodes/utils/SplitNode.js +96 -0
  389. data/lib-opal/js_wrap/three/renderers/nodes/utils/SpriteSheetUVNode.js +98 -0
  390. data/lib-opal/js_wrap/three/renderers/nodes/utils/TimerNode.js +93 -0
  391. data/lib-opal/js_wrap/three/renderers/webgl/nodes/SlotNode.js +72 -0
  392. data/lib-opal/js_wrap/three/renderers/webgl/nodes/WebGLNodeBuilder.js +463 -0
  393. data/lib-opal/js_wrap/three/renderers/webgl/nodes/WebGLNodes.js +62 -0
  394. data/lib-opal/js_wrap/three/renderers/webgl/nodes/WebGLPhysicalContextNode.js +95 -0
  395. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPU.js +62 -0
  396. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUAttributes.js +118 -0
  397. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUBackground.js +109 -0
  398. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUBinding.js +52 -0
  399. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUBindings.js +254 -0
  400. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUBufferUtils.js +39 -0
  401. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUComputePipelines.js +82 -0
  402. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUGeometries.js +84 -0
  403. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUInfo.js +86 -0
  404. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUObjects.js +64 -0
  405. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUProgrammableStage.js +46 -0
  406. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUProperties.js +63 -0
  407. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPURenderLists.js +180 -0
  408. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPURenderPipeline.js +662 -0
  409. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPURenderPipelines.js +275 -0
  410. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPURenderer.js +883 -0
  411. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUSampledTexture.js +139 -0
  412. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUSampler.js +76 -0
  413. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUStorageBuffer.js +69 -0
  414. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUTextureRenderer.js +64 -0
  415. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUTextureUtils.js +125 -0
  416. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUTextures.js +681 -0
  417. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUUniform.js +237 -0
  418. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUUniformBuffer.js +90 -0
  419. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUUniformsGroup.js +294 -0
  420. data/lib-opal/js_wrap/three/renderers/webgpu/constants.js +263 -0
  421. data/lib-opal/js_wrap/three/renderers/webgpu/nodes/WebGPUNodeBuilder.js +619 -0
  422. data/lib-opal/js_wrap/three/renderers/webgpu/nodes/WebGPUNodeSampledTexture.js +67 -0
  423. data/lib-opal/js_wrap/three/renderers/webgpu/nodes/WebGPUNodeSampler.js +71 -0
  424. data/lib-opal/js_wrap/three/renderers/webgpu/nodes/WebGPUNodeUniform.js +229 -0
  425. data/lib-opal/js_wrap/three/renderers/webgpu/nodes/WebGPUNodeUniformsGroup.js +68 -0
  426. data/lib-opal/js_wrap/three/renderers/webgpu/nodes/WebGPUNodes.js +106 -0
  427. data/lib-opal/js_wrap/three/shaders/ACESFilmicToneMappingShader.js +45 -0
  428. data/lib-opal/js_wrap/three/shaders/AfterimageShader.js +46 -0
  429. data/lib-opal/js_wrap/three/shaders/BasicShader.js +34 -0
  430. data/lib-opal/js_wrap/three/shaders/BleachBypassShader.js +43 -0
  431. data/lib-opal/js_wrap/three/shaders/BlendShader.js +47 -0
  432. data/lib-opal/js_wrap/three/shaders/BokehShader.js +65 -0
  433. data/lib-opal/js_wrap/three/shaders/BokehShader2.js +125 -0
  434. data/lib-opal/js_wrap/three/shaders/BrightnessContrastShader.js +47 -0
  435. data/lib-opal/js_wrap/three/shaders/ColorCorrectionShader.js +47 -0
  436. data/lib-opal/js_wrap/three/shaders/ColorifyShader.js +41 -0
  437. data/lib-opal/js_wrap/three/shaders/ConvolutionShader.js +75 -0
  438. data/lib-opal/js_wrap/three/shaders/CopyShader.js +41 -0
  439. data/lib-opal/js_wrap/three/shaders/DOFMipMapShader.js +49 -0
  440. data/lib-opal/js_wrap/three/shaders/DepthLimitedBlurShader.js +95 -0
  441. data/lib-opal/js_wrap/three/shaders/DigitalGlitch.js +79 -0
  442. data/lib-opal/js_wrap/three/shaders/DotScreenShader.js +52 -0
  443. data/lib-opal/js_wrap/three/shaders/FXAAShader.js +78 -0
  444. data/lib-opal/js_wrap/three/shaders/FilmShader.js +69 -0
  445. data/lib-opal/js_wrap/three/shaders/FocusShader.js +52 -0
  446. data/lib-opal/js_wrap/three/shaders/FreiChenShader.js +44 -0
  447. data/lib-opal/js_wrap/three/shaders/GammaCorrectionShader.js +39 -0
  448. data/lib-opal/js_wrap/three/shaders/GodRaysShader.js +140 -0
  449. data/lib-opal/js_wrap/three/shaders/HalftoneShader.js +77 -0
  450. data/lib-opal/js_wrap/three/shaders/HorizontalBlurShader.js +47 -0
  451. data/lib-opal/js_wrap/three/shaders/HorizontalTiltShiftShader.js +49 -0
  452. data/lib-opal/js_wrap/three/shaders/HueSaturationShader.js +47 -0
  453. data/lib-opal/js_wrap/three/shaders/KaleidoShader.js +50 -0
  454. data/lib-opal/js_wrap/three/shaders/LuminosityHighPassShader.js +52 -0
  455. data/lib-opal/js_wrap/three/shaders/LuminosityShader.js +39 -0
  456. data/lib-opal/js_wrap/three/shaders/MMDToonShader.js +48 -0
  457. data/lib-opal/js_wrap/three/shaders/MirrorShader.js +44 -0
  458. data/lib-opal/js_wrap/three/shaders/NormalMapShader.js +48 -0
  459. data/lib-opal/js_wrap/three/shaders/PixelShader.js +44 -0
  460. data/lib-opal/js_wrap/three/shaders/RGBShiftShader.js +50 -0
  461. data/lib-opal/js_wrap/three/shaders/SAOShader.js +85 -0
  462. data/lib-opal/js_wrap/three/shaders/SMAAShader.js +95 -0
  463. data/lib-opal/js_wrap/three/shaders/SSAOShader.js +113 -0
  464. data/lib-opal/js_wrap/three/shaders/SSRShader.js +126 -0
  465. data/lib-opal/js_wrap/three/shaders/SSRrShader.js +106 -0
  466. data/lib-opal/js_wrap/three/shaders/SepiaShader.js +43 -0
  467. data/lib-opal/js_wrap/three/shaders/SobelOperatorShader.js +44 -0
  468. data/lib-opal/js_wrap/three/shaders/SubsurfaceScatteringShader.js +64 -0
  469. data/lib-opal/js_wrap/three/shaders/TechnicolorShader.js +41 -0
  470. data/lib-opal/js_wrap/three/shaders/ToneMapShader.js +53 -0
  471. data/lib-opal/js_wrap/three/shaders/ToonShader.js +148 -0
  472. data/lib-opal/js_wrap/three/shaders/TriangleBlurShader.js +47 -0
  473. data/lib-opal/js_wrap/three/shaders/UnpackDepthRGBAShader.js +42 -0
  474. data/lib-opal/js_wrap/three/shaders/VerticalBlurShader.js +47 -0
  475. data/lib-opal/js_wrap/three/shaders/VerticalTiltShiftShader.js +49 -0
  476. data/lib-opal/js_wrap/three/shaders/VignetteShader.js +46 -0
  477. data/lib-opal/js_wrap/three/shaders/VolumeShader.js +55 -0
  478. data/lib-opal/js_wrap/three/shaders/WaterRefractionShader.js +46 -0
  479. data/lib-opal/js_wrap/three/textures/FlakesTexture.js +61 -0
  480. data/lib-opal/js_wrap/three/utils/BufferGeometryUtils.js +683 -0
  481. data/lib-opal/js_wrap/three/utils/CameraUtils.js +97 -0
  482. data/lib-opal/js_wrap/three/utils/GPUStatsPanel.js +154 -0
  483. data/lib-opal/js_wrap/three/utils/GeometryCompressionUtils.js +468 -0
  484. data/lib-opal/js_wrap/three/utils/GeometryUtils.js +192 -0
  485. data/lib-opal/js_wrap/three/utils/PackedPhongMaterial.js +77 -0
  486. data/lib-opal/js_wrap/three/utils/RoughnessMipmapper.js +169 -0
  487. data/lib-opal/js_wrap/three/utils/SceneUtils.js +62 -0
  488. data/lib-opal/js_wrap/three/utils/ShadowMapViewer.js +182 -0
  489. data/lib-opal/js_wrap/three/utils/SkeletonUtils.js +400 -0
  490. data/lib-opal/js_wrap/three/utils/UVsDebug.js +132 -0
  491. data/lib-opal/js_wrap/three/utils/WorkerPool.js +130 -0
  492. data/lib-opal/js_wrap/three/webxr/ARButton.js +203 -0
  493. data/lib-opal/js_wrap/three/webxr/OculusHandModel.js +131 -0
  494. data/lib-opal/js_wrap/three/webxr/OculusHandPointerModel.js +328 -0
  495. data/lib-opal/js_wrap/three/webxr/Text2D.js +54 -0
  496. data/lib-opal/js_wrap/three/webxr/VRButton.js +181 -0
  497. data/lib-opal/js_wrap/three/webxr/XRControllerModelFactory.js +266 -0
  498. data/lib-opal/js_wrap/three/webxr/XREstimatedLight.js +221 -0
  499. data/lib-opal/js_wrap/three/webxr/XRHandMeshModel.js +93 -0
  500. data/lib-opal/js_wrap/three/webxr/XRHandModelFactory.js +127 -0
  501. data/lib-opal/js_wrap/three/webxr/XRHandPrimitiveModel.js +85 -0
  502. data/opal-js_wrap-three.gemspec +4 -4
  503. metadata +502 -5
@@ -0,0 +1,3002 @@
1
+ (function (global, factory) {
2
+ if (typeof define === "function" && define.amd) {
3
+ define(["exports"], factory);
4
+ } else if (typeof exports !== "undefined") {
5
+ factory(exports);
6
+ } else {
7
+ var mod = {
8
+ exports: {}
9
+ };
10
+ factory(mod.exports);
11
+ global.fflateModule = mod.exports;
12
+ }
13
+ })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) {
14
+ "use strict";
15
+
16
+ Object.defineProperty(_exports, "__esModule", {
17
+ value: true
18
+ });
19
+ _exports.Zlib = _exports.ZipPassThrough = _exports.ZipDeflate = _exports.Zip = _exports.Unzlib = _exports.UnzipPassThrough = _exports.UnzipInflate = _exports.Unzip = _exports.Inflate = _exports.Gzip = _exports.Gunzip = _exports.EncodeUTF8 = _exports.Deflate = _exports.Decompress = _exports.DecodeUTF8 = _exports.Compress = _exports.AsyncZlib = _exports.AsyncZipDeflate = _exports.AsyncUnzlib = _exports.AsyncUnzipInflate = _exports.AsyncInflate = _exports.AsyncGzip = _exports.AsyncGunzip = _exports.AsyncDeflate = _exports.AsyncDecompress = _exports.AsyncCompress = void 0;
20
+ _exports.decompress = decompress;
21
+ _exports.decompressSync = decompressSync;
22
+ _exports.deflate = deflate;
23
+ _exports.deflateSync = deflateSync;
24
+ _exports.gunzip = gunzip;
25
+ _exports.gunzipSync = gunzipSync;
26
+ _exports.compress = _exports.gzip = gzip;
27
+ _exports.compressSync = _exports.gzipSync = gzipSync;
28
+ _exports.inflate = inflate;
29
+ _exports.inflateSync = inflateSync;
30
+ _exports.strFromU8 = strFromU8;
31
+ _exports.strToU8 = strToU8;
32
+ _exports.unzip = unzip;
33
+ _exports.unzipSync = unzipSync;
34
+ _exports.unzlib = unzlib;
35
+ _exports.unzlibSync = unzlibSync;
36
+ _exports.zip = zip;
37
+ _exports.zipSync = zipSync;
38
+ _exports.zlib = zlib;
39
+ _exports.zlibSync = zlibSync;
40
+
41
+ /*!
42
+ fflate - fast JavaScript compression/decompression
43
+ <https://101arrowz.github.io/fflate>
44
+ Licensed under MIT. https://github.com/101arrowz/fflate/blob/master/LICENSE
45
+ version 0.6.9
46
+ */
47
+ // DEFLATE is a complex format; to read this code, you should probably check the RFC first:
48
+ // https://tools.ietf.org/html/rfc1951
49
+ // You may also wish to take a look at the guide I made about this program:
50
+ // https://gist.github.com/101arrowz/253f31eb5abc3d9275ab943003ffecad
51
+ // Some of the following code is similar to that of UZIP.js:
52
+ // https://github.com/photopea/UZIP.js
53
+ // However, the vast majority of the codebase has diverged from UZIP.js to increase performance and reduce bundle size.
54
+ // Sometimes 0 will appear where -1 would be more appropriate. This is because using a uint
55
+ // is better for memory in most engines (I *think*).
56
+ var ch2 = {};
57
+
58
+ var durl = function durl(c) {
59
+ return URL.createObjectURL(new Blob([c], {
60
+ type: 'text/javascript'
61
+ }));
62
+ };
63
+
64
+ var cwk = function cwk(u) {
65
+ return new Worker(u);
66
+ };
67
+
68
+ try {
69
+ URL.revokeObjectURL(durl(''));
70
+ } catch (e) {
71
+ // We're in Deno or a very old browser
72
+ durl = function durl(c) {
73
+ return 'data:application/javascript;charset=UTF-8,' + encodeURI(c);
74
+ }; // If Deno, this is necessary; if not, this changes nothing
75
+
76
+
77
+ cwk = function cwk(u) {
78
+ return new Worker(u, {
79
+ type: 'module'
80
+ });
81
+ };
82
+ }
83
+
84
+ var wk = function wk(c, id, msg, transfer, cb) {
85
+ var w = cwk(ch2[id] || (ch2[id] = durl(c)));
86
+
87
+ w.onerror = function (e) {
88
+ return cb(e.error, null);
89
+ };
90
+
91
+ w.onmessage = function (e) {
92
+ return cb(null, e.data);
93
+ };
94
+
95
+ w.postMessage(msg, transfer);
96
+ return w;
97
+ }; // aliases for shorter compressed code (most minifers don't do this)
98
+
99
+
100
+ var u8 = Uint8Array,
101
+ u16 = Uint16Array,
102
+ u32 = Uint32Array; // fixed length extra bits
103
+
104
+ var fleb = new u8([0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0,
105
+ /* unused */
106
+ 0, 0,
107
+ /* impossible */
108
+ 0]); // fixed distance extra bits
109
+ // see fleb note
110
+
111
+ var fdeb = new u8([0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13,
112
+ /* unused */
113
+ 0, 0]); // code length index map
114
+
115
+ var clim = new u8([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]); // get base, reverse index map from extra bits
116
+
117
+ var freb = function freb(eb, start) {
118
+ var b = new u16(31);
119
+
120
+ for (var i = 0; i < 31; ++i) {
121
+ b[i] = start += 1 << eb[i - 1];
122
+ } // numbers here are at max 18 bits
123
+
124
+
125
+ var r = new u32(b[30]);
126
+
127
+ for (var i = 1; i < 30; ++i) {
128
+ for (var j = b[i]; j < b[i + 1]; ++j) {
129
+ r[j] = j - b[i] << 5 | i;
130
+ }
131
+ }
132
+
133
+ return [b, r];
134
+ };
135
+
136
+ var _a = freb(fleb, 2),
137
+ fl = _a[0],
138
+ revfl = _a[1]; // we can ignore the fact that the other numbers are wrong; they never happen anyway
139
+
140
+
141
+ fl[28] = 258, revfl[258] = 28;
142
+
143
+ var _b = freb(fdeb, 0),
144
+ fd = _b[0],
145
+ revfd = _b[1]; // map of value to reverse (assuming 16 bits)
146
+
147
+
148
+ var rev = new u16(32768);
149
+
150
+ for (var i = 0; i < 32768; ++i) {
151
+ // reverse table algorithm from SO
152
+ var x = (i & 0xAAAA) >>> 1 | (i & 0x5555) << 1;
153
+ x = (x & 0xCCCC) >>> 2 | (x & 0x3333) << 2;
154
+ x = (x & 0xF0F0) >>> 4 | (x & 0x0F0F) << 4;
155
+ rev[i] = ((x & 0xFF00) >>> 8 | (x & 0x00FF) << 8) >>> 1;
156
+ } // create huffman tree from u8 "map": index -> code length for code index
157
+ // mb (max bits) must be at most 15
158
+ // TODO: optimize/split up?
159
+
160
+
161
+ var hMap = function hMap(cd, mb, r) {
162
+ var s = cd.length; // index
163
+
164
+ var i = 0; // u16 "map": index -> # of codes with bit length = index
165
+
166
+ var l = new u16(mb); // length of cd must be 288 (total # of codes)
167
+
168
+ for (; i < s; ++i) {
169
+ ++l[cd[i] - 1];
170
+ } // u16 "map": index -> minimum code for bit length = index
171
+
172
+
173
+ var le = new u16(mb);
174
+
175
+ for (i = 0; i < mb; ++i) {
176
+ le[i] = le[i - 1] + l[i - 1] << 1;
177
+ }
178
+
179
+ var co;
180
+
181
+ if (r) {
182
+ // u16 "map": index -> number of actual bits, symbol for code
183
+ co = new u16(1 << mb); // bits to remove for reverser
184
+
185
+ var rvb = 15 - mb;
186
+
187
+ for (i = 0; i < s; ++i) {
188
+ // ignore 0 lengths
189
+ if (cd[i]) {
190
+ // num encoding both symbol and bits read
191
+ var sv = i << 4 | cd[i]; // free bits
192
+
193
+ var r_1 = mb - cd[i]; // start value
194
+
195
+ var v = le[cd[i] - 1]++ << r_1; // m is end value
196
+
197
+ for (var m = v | (1 << r_1) - 1; v <= m; ++v) {
198
+ // every 16 bit value starting with the code yields the same result
199
+ co[rev[v] >>> rvb] = sv;
200
+ }
201
+ }
202
+ }
203
+ } else {
204
+ co = new u16(s);
205
+
206
+ for (i = 0; i < s; ++i) {
207
+ if (cd[i]) {
208
+ co[i] = rev[le[cd[i] - 1]++] >>> 15 - cd[i];
209
+ }
210
+ }
211
+ }
212
+
213
+ return co;
214
+ }; // fixed length tree
215
+
216
+
217
+ var flt = new u8(288);
218
+
219
+ for (var i = 0; i < 144; ++i) {
220
+ flt[i] = 8;
221
+ }
222
+
223
+ for (var i = 144; i < 256; ++i) {
224
+ flt[i] = 9;
225
+ }
226
+
227
+ for (var i = 256; i < 280; ++i) {
228
+ flt[i] = 7;
229
+ }
230
+
231
+ for (var i = 280; i < 288; ++i) {
232
+ flt[i] = 8;
233
+ } // fixed distance tree
234
+
235
+
236
+ var fdt = new u8(32);
237
+
238
+ for (var i = 0; i < 32; ++i) {
239
+ fdt[i] = 5;
240
+ } // fixed length map
241
+
242
+
243
+ var flm = /*#__PURE__*/hMap(flt, 9, 0),
244
+ flrm = /*#__PURE__*/hMap(flt, 9, 1); // fixed distance map
245
+
246
+ var fdm = /*#__PURE__*/hMap(fdt, 5, 0),
247
+ fdrm = /*#__PURE__*/hMap(fdt, 5, 1); // find max of array
248
+
249
+ var max = function max(a) {
250
+ var m = a[0];
251
+
252
+ for (var i = 1; i < a.length; ++i) {
253
+ if (a[i] > m) m = a[i];
254
+ }
255
+
256
+ return m;
257
+ }; // read d, starting at bit p and mask with m
258
+
259
+
260
+ var bits = function bits(d, p, m) {
261
+ var o = p / 8 | 0;
262
+ return (d[o] | d[o + 1] << 8) >> (p & 7) & m;
263
+ }; // read d, starting at bit p continuing for at least 16 bits
264
+
265
+
266
+ var bits16 = function bits16(d, p) {
267
+ var o = p / 8 | 0;
268
+ return (d[o] | d[o + 1] << 8 | d[o + 2] << 16) >> (p & 7);
269
+ }; // get end of byte
270
+
271
+
272
+ var shft = function shft(p) {
273
+ return (p / 8 | 0) + (p & 7 && 1);
274
+ }; // typed array slice - allows garbage collector to free original reference,
275
+ // while being more compatible than .slice
276
+
277
+
278
+ var slc = function slc(v, s, e) {
279
+ if (s == null || s < 0) s = 0;
280
+ if (e == null || e > v.length) e = v.length; // can't use .constructor in case user-supplied
281
+
282
+ var n = new (v instanceof u16 ? u16 : v instanceof u32 ? u32 : u8)(e - s);
283
+ n.set(v.subarray(s, e));
284
+ return n;
285
+ }; // expands raw DEFLATE data
286
+
287
+
288
+ var inflt = function inflt(dat, buf, st) {
289
+ // source length
290
+ var sl = dat.length;
291
+ if (!sl || st && !st.l && sl < 5) return buf || new u8(0); // have to estimate size
292
+
293
+ var noBuf = !buf || st; // no state
294
+
295
+ var noSt = !st || st.i;
296
+ if (!st) st = {}; // Assumes roughly 33% compression ratio average
297
+
298
+ if (!buf) buf = new u8(sl * 3); // ensure buffer can fit at least l elements
299
+
300
+ var cbuf = function cbuf(l) {
301
+ var bl = buf.length; // need to increase size to fit
302
+
303
+ if (l > bl) {
304
+ // Double or set to necessary, whichever is greater
305
+ var nbuf = new u8(Math.max(bl * 2, l));
306
+ nbuf.set(buf);
307
+ buf = nbuf;
308
+ }
309
+ }; // last chunk bitpos bytes
310
+
311
+
312
+ var final = st.f || 0,
313
+ pos = st.p || 0,
314
+ bt = st.b || 0,
315
+ lm = st.l,
316
+ dm = st.d,
317
+ lbt = st.m,
318
+ dbt = st.n; // total bits
319
+
320
+ var tbts = sl * 8;
321
+
322
+ do {
323
+ if (!lm) {
324
+ // BFINAL - this is only 1 when last chunk is next
325
+ st.f = final = bits(dat, pos, 1); // type: 0 = no compression, 1 = fixed huffman, 2 = dynamic huffman
326
+
327
+ var type = bits(dat, pos + 1, 3);
328
+ pos += 3;
329
+
330
+ if (!type) {
331
+ // go to end of byte boundary
332
+ var s = shft(pos) + 4,
333
+ l = dat[s - 4] | dat[s - 3] << 8,
334
+ t = s + l;
335
+
336
+ if (t > sl) {
337
+ if (noSt) throw 'unexpected EOF';
338
+ break;
339
+ } // ensure size
340
+
341
+
342
+ if (noBuf) cbuf(bt + l); // Copy over uncompressed data
343
+
344
+ buf.set(dat.subarray(s, t), bt); // Get new bitpos, update byte count
345
+
346
+ st.b = bt += l, st.p = pos = t * 8;
347
+ continue;
348
+ } else if (type == 1) lm = flrm, dm = fdrm, lbt = 9, dbt = 5;else if (type == 2) {
349
+ // literal lengths
350
+ var hLit = bits(dat, pos, 31) + 257,
351
+ hcLen = bits(dat, pos + 10, 15) + 4;
352
+ var tl = hLit + bits(dat, pos + 5, 31) + 1;
353
+ pos += 14; // length+distance tree
354
+
355
+ var ldt = new u8(tl); // code length tree
356
+
357
+ var clt = new u8(19);
358
+
359
+ for (var i = 0; i < hcLen; ++i) {
360
+ // use index map to get real code
361
+ clt[clim[i]] = bits(dat, pos + i * 3, 7);
362
+ }
363
+
364
+ pos += hcLen * 3; // code lengths bits
365
+
366
+ var clb = max(clt),
367
+ clbmsk = (1 << clb) - 1; // code lengths map
368
+
369
+ var clm = hMap(clt, clb, 1);
370
+
371
+ for (var i = 0; i < tl;) {
372
+ var r = clm[bits(dat, pos, clbmsk)]; // bits read
373
+
374
+ pos += r & 15; // symbol
375
+
376
+ var s = r >>> 4; // code length to copy
377
+
378
+ if (s < 16) {
379
+ ldt[i++] = s;
380
+ } else {
381
+ // copy count
382
+ var c = 0,
383
+ n = 0;
384
+ if (s == 16) n = 3 + bits(dat, pos, 3), pos += 2, c = ldt[i - 1];else if (s == 17) n = 3 + bits(dat, pos, 7), pos += 3;else if (s == 18) n = 11 + bits(dat, pos, 127), pos += 7;
385
+
386
+ while (n--) {
387
+ ldt[i++] = c;
388
+ }
389
+ }
390
+ } // length tree distance tree
391
+
392
+
393
+ var lt = ldt.subarray(0, hLit),
394
+ dt = ldt.subarray(hLit); // max length bits
395
+
396
+ lbt = max(lt); // max dist bits
397
+
398
+ dbt = max(dt);
399
+ lm = hMap(lt, lbt, 1);
400
+ dm = hMap(dt, dbt, 1);
401
+ } else throw 'invalid block type';
402
+
403
+ if (pos > tbts) {
404
+ if (noSt) throw 'unexpected EOF';
405
+ break;
406
+ }
407
+ } // Make sure the buffer can hold this + the largest possible addition
408
+ // Maximum chunk size (practically, theoretically infinite) is 2^17;
409
+
410
+
411
+ if (noBuf) cbuf(bt + 131072);
412
+ var lms = (1 << lbt) - 1,
413
+ dms = (1 << dbt) - 1;
414
+ var lpos = pos;
415
+
416
+ for (;; lpos = pos) {
417
+ // bits read, code
418
+ var c = lm[bits16(dat, pos) & lms],
419
+ sym = c >>> 4;
420
+ pos += c & 15;
421
+
422
+ if (pos > tbts) {
423
+ if (noSt) throw 'unexpected EOF';
424
+ break;
425
+ }
426
+
427
+ if (!c) throw 'invalid length/literal';
428
+ if (sym < 256) buf[bt++] = sym;else if (sym == 256) {
429
+ lpos = pos, lm = null;
430
+ break;
431
+ } else {
432
+ var add = sym - 254; // no extra bits needed if less
433
+
434
+ if (sym > 264) {
435
+ // index
436
+ var i = sym - 257,
437
+ b = fleb[i];
438
+ add = bits(dat, pos, (1 << b) - 1) + fl[i];
439
+ pos += b;
440
+ } // dist
441
+
442
+
443
+ var d = dm[bits16(dat, pos) & dms],
444
+ dsym = d >>> 4;
445
+ if (!d) throw 'invalid distance';
446
+ pos += d & 15;
447
+ var dt = fd[dsym];
448
+
449
+ if (dsym > 3) {
450
+ var b = fdeb[dsym];
451
+ dt += bits16(dat, pos) & (1 << b) - 1, pos += b;
452
+ }
453
+
454
+ if (pos > tbts) {
455
+ if (noSt) throw 'unexpected EOF';
456
+ break;
457
+ }
458
+
459
+ if (noBuf) cbuf(bt + 131072);
460
+ var end = bt + add;
461
+
462
+ for (; bt < end; bt += 4) {
463
+ buf[bt] = buf[bt - dt];
464
+ buf[bt + 1] = buf[bt + 1 - dt];
465
+ buf[bt + 2] = buf[bt + 2 - dt];
466
+ buf[bt + 3] = buf[bt + 3 - dt];
467
+ }
468
+
469
+ bt = end;
470
+ }
471
+ }
472
+
473
+ st.l = lm, st.p = lpos, st.b = bt;
474
+ if (lm) final = 1, st.m = lbt, st.d = dm, st.n = dbt;
475
+ } while (!final);
476
+
477
+ return bt == buf.length ? buf : slc(buf, 0, bt);
478
+ }; // starting at p, write the minimum number of bits that can hold v to d
479
+
480
+
481
+ var wbits = function wbits(d, p, v) {
482
+ v <<= p & 7;
483
+ var o = p / 8 | 0;
484
+ d[o] |= v;
485
+ d[o + 1] |= v >>> 8;
486
+ }; // starting at p, write the minimum number of bits (>8) that can hold v to d
487
+
488
+
489
+ var wbits16 = function wbits16(d, p, v) {
490
+ v <<= p & 7;
491
+ var o = p / 8 | 0;
492
+ d[o] |= v;
493
+ d[o + 1] |= v >>> 8;
494
+ d[o + 2] |= v >>> 16;
495
+ }; // creates code lengths from a frequency table
496
+
497
+
498
+ var hTree = function hTree(d, mb) {
499
+ // Need extra info to make a tree
500
+ var t = [];
501
+
502
+ for (var i = 0; i < d.length; ++i) {
503
+ if (d[i]) t.push({
504
+ s: i,
505
+ f: d[i]
506
+ });
507
+ }
508
+
509
+ var s = t.length;
510
+ var t2 = t.slice();
511
+ if (!s) return [et, 0];
512
+
513
+ if (s == 1) {
514
+ var v = new u8(t[0].s + 1);
515
+ v[t[0].s] = 1;
516
+ return [v, 1];
517
+ }
518
+
519
+ t.sort(function (a, b) {
520
+ return a.f - b.f;
521
+ }); // after i2 reaches last ind, will be stopped
522
+ // freq must be greater than largest possible number of symbols
523
+
524
+ t.push({
525
+ s: -1,
526
+ f: 25001
527
+ });
528
+ var l = t[0],
529
+ r = t[1],
530
+ i0 = 0,
531
+ i1 = 1,
532
+ i2 = 2;
533
+ t[0] = {
534
+ s: -1,
535
+ f: l.f + r.f,
536
+ l: l,
537
+ r: r
538
+ }; // efficient algorithm from UZIP.js
539
+ // i0 is lookbehind, i2 is lookahead - after processing two low-freq
540
+ // symbols that combined have high freq, will start processing i2 (high-freq,
541
+ // non-composite) symbols instead
542
+ // see https://reddit.com/r/photopea/comments/ikekht/uzipjs_questions/
543
+
544
+ while (i1 != s - 1) {
545
+ l = t[t[i0].f < t[i2].f ? i0++ : i2++];
546
+ r = t[i0 != i1 && t[i0].f < t[i2].f ? i0++ : i2++];
547
+ t[i1++] = {
548
+ s: -1,
549
+ f: l.f + r.f,
550
+ l: l,
551
+ r: r
552
+ };
553
+ }
554
+
555
+ var maxSym = t2[0].s;
556
+
557
+ for (var i = 1; i < s; ++i) {
558
+ if (t2[i].s > maxSym) maxSym = t2[i].s;
559
+ } // code lengths
560
+
561
+
562
+ var tr = new u16(maxSym + 1); // max bits in tree
563
+
564
+ var mbt = ln(t[i1 - 1], tr, 0);
565
+
566
+ if (mbt > mb) {
567
+ // more algorithms from UZIP.js
568
+ // TODO: find out how this code works (debt)
569
+ // ind debt
570
+ var i = 0,
571
+ dt = 0; // left cost
572
+
573
+ var lft = mbt - mb,
574
+ cst = 1 << lft;
575
+ t2.sort(function (a, b) {
576
+ return tr[b.s] - tr[a.s] || a.f - b.f;
577
+ });
578
+
579
+ for (; i < s; ++i) {
580
+ var i2_1 = t2[i].s;
581
+
582
+ if (tr[i2_1] > mb) {
583
+ dt += cst - (1 << mbt - tr[i2_1]);
584
+ tr[i2_1] = mb;
585
+ } else break;
586
+ }
587
+
588
+ dt >>>= lft;
589
+
590
+ while (dt > 0) {
591
+ var i2_2 = t2[i].s;
592
+ if (tr[i2_2] < mb) dt -= 1 << mb - tr[i2_2]++ - 1;else ++i;
593
+ }
594
+
595
+ for (; i >= 0 && dt; --i) {
596
+ var i2_3 = t2[i].s;
597
+
598
+ if (tr[i2_3] == mb) {
599
+ --tr[i2_3];
600
+ ++dt;
601
+ }
602
+ }
603
+
604
+ mbt = mb;
605
+ }
606
+
607
+ return [new u8(tr), mbt];
608
+ }; // get the max length and assign length codes
609
+
610
+
611
+ var ln = function ln(n, l, d) {
612
+ return n.s == -1 ? Math.max(ln(n.l, l, d + 1), ln(n.r, l, d + 1)) : l[n.s] = d;
613
+ }; // length codes generation
614
+
615
+
616
+ var lc = function lc(c) {
617
+ var s = c.length; // Note that the semicolon was intentional
618
+
619
+ while (s && !c[--s]) {
620
+ ;
621
+ }
622
+
623
+ var cl = new u16(++s); // ind num streak
624
+
625
+ var cli = 0,
626
+ cln = c[0],
627
+ cls = 1;
628
+
629
+ var w = function w(v) {
630
+ cl[cli++] = v;
631
+ };
632
+
633
+ for (var i = 1; i <= s; ++i) {
634
+ if (c[i] == cln && i != s) ++cls;else {
635
+ if (!cln && cls > 2) {
636
+ for (; cls > 138; cls -= 138) {
637
+ w(32754);
638
+ }
639
+
640
+ if (cls > 2) {
641
+ w(cls > 10 ? cls - 11 << 5 | 28690 : cls - 3 << 5 | 12305);
642
+ cls = 0;
643
+ }
644
+ } else if (cls > 3) {
645
+ w(cln), --cls;
646
+
647
+ for (; cls > 6; cls -= 6) {
648
+ w(8304);
649
+ }
650
+
651
+ if (cls > 2) w(cls - 3 << 5 | 8208), cls = 0;
652
+ }
653
+
654
+ while (cls--) {
655
+ w(cln);
656
+ }
657
+
658
+ cls = 1;
659
+ cln = c[i];
660
+ }
661
+ }
662
+
663
+ return [cl.subarray(0, cli), s];
664
+ }; // calculate the length of output from tree, code lengths
665
+
666
+
667
+ var clen = function clen(cf, cl) {
668
+ var l = 0;
669
+
670
+ for (var i = 0; i < cl.length; ++i) {
671
+ l += cf[i] * cl[i];
672
+ }
673
+
674
+ return l;
675
+ }; // writes a fixed block
676
+ // returns the new bit pos
677
+
678
+
679
+ var wfblk = function wfblk(out, pos, dat) {
680
+ // no need to write 00 as type: TypedArray defaults to 0
681
+ var s = dat.length;
682
+ var o = shft(pos + 2);
683
+ out[o] = s & 255;
684
+ out[o + 1] = s >>> 8;
685
+ out[o + 2] = out[o] ^ 255;
686
+ out[o + 3] = out[o + 1] ^ 255;
687
+
688
+ for (var i = 0; i < s; ++i) {
689
+ out[o + i + 4] = dat[i];
690
+ }
691
+
692
+ return (o + 4 + s) * 8;
693
+ }; // writes a block
694
+
695
+
696
+ var wblk = function wblk(dat, out, final, syms, lf, df, eb, li, bs, bl, p) {
697
+ wbits(out, p++, final);
698
+ ++lf[256];
699
+
700
+ var _a = hTree(lf, 15),
701
+ dlt = _a[0],
702
+ mlb = _a[1];
703
+
704
+ var _b = hTree(df, 15),
705
+ ddt = _b[0],
706
+ mdb = _b[1];
707
+
708
+ var _c = lc(dlt),
709
+ lclt = _c[0],
710
+ nlc = _c[1];
711
+
712
+ var _d = lc(ddt),
713
+ lcdt = _d[0],
714
+ ndc = _d[1];
715
+
716
+ var lcfreq = new u16(19);
717
+
718
+ for (var i = 0; i < lclt.length; ++i) {
719
+ lcfreq[lclt[i] & 31]++;
720
+ }
721
+
722
+ for (var i = 0; i < lcdt.length; ++i) {
723
+ lcfreq[lcdt[i] & 31]++;
724
+ }
725
+
726
+ var _e = hTree(lcfreq, 7),
727
+ lct = _e[0],
728
+ mlcb = _e[1];
729
+
730
+ var nlcc = 19;
731
+
732
+ for (; nlcc > 4 && !lct[clim[nlcc - 1]]; --nlcc) {
733
+ ;
734
+ }
735
+
736
+ var flen = bl + 5 << 3;
737
+ var ftlen = clen(lf, flt) + clen(df, fdt) + eb;
738
+ var dtlen = clen(lf, dlt) + clen(df, ddt) + eb + 14 + 3 * nlcc + clen(lcfreq, lct) + (2 * lcfreq[16] + 3 * lcfreq[17] + 7 * lcfreq[18]);
739
+ if (flen <= ftlen && flen <= dtlen) return wfblk(out, p, dat.subarray(bs, bs + bl));
740
+ var lm, ll, dm, dl;
741
+ wbits(out, p, 1 + (dtlen < ftlen)), p += 2;
742
+
743
+ if (dtlen < ftlen) {
744
+ lm = hMap(dlt, mlb, 0), ll = dlt, dm = hMap(ddt, mdb, 0), dl = ddt;
745
+ var llm = hMap(lct, mlcb, 0);
746
+ wbits(out, p, nlc - 257);
747
+ wbits(out, p + 5, ndc - 1);
748
+ wbits(out, p + 10, nlcc - 4);
749
+ p += 14;
750
+
751
+ for (var i = 0; i < nlcc; ++i) {
752
+ wbits(out, p + 3 * i, lct[clim[i]]);
753
+ }
754
+
755
+ p += 3 * nlcc;
756
+ var lcts = [lclt, lcdt];
757
+
758
+ for (var it = 0; it < 2; ++it) {
759
+ var clct = lcts[it];
760
+
761
+ for (var i = 0; i < clct.length; ++i) {
762
+ var len = clct[i] & 31;
763
+ wbits(out, p, llm[len]), p += lct[len];
764
+ if (len > 15) wbits(out, p, clct[i] >>> 5 & 127), p += clct[i] >>> 12;
765
+ }
766
+ }
767
+ } else {
768
+ lm = flm, ll = flt, dm = fdm, dl = fdt;
769
+ }
770
+
771
+ for (var i = 0; i < li; ++i) {
772
+ if (syms[i] > 255) {
773
+ var len = syms[i] >>> 18 & 31;
774
+ wbits16(out, p, lm[len + 257]), p += ll[len + 257];
775
+ if (len > 7) wbits(out, p, syms[i] >>> 23 & 31), p += fleb[len];
776
+ var dst = syms[i] & 31;
777
+ wbits16(out, p, dm[dst]), p += dl[dst];
778
+ if (dst > 3) wbits16(out, p, syms[i] >>> 5 & 8191), p += fdeb[dst];
779
+ } else {
780
+ wbits16(out, p, lm[syms[i]]), p += ll[syms[i]];
781
+ }
782
+ }
783
+
784
+ wbits16(out, p, lm[256]);
785
+ return p + ll[256];
786
+ }; // deflate options (nice << 13) | chain
787
+
788
+
789
+ var deo = /*#__PURE__*/new u32([65540, 131080, 131088, 131104, 262176, 1048704, 1048832, 2114560, 2117632]); // empty
790
+
791
+ var et = /*#__PURE__*/new u8(0); // compresses data into a raw DEFLATE buffer
792
+
793
+ var dflt = function dflt(dat, lvl, plvl, pre, post, lst) {
794
+ var s = dat.length;
795
+ var o = new u8(pre + s + 5 * (1 + Math.ceil(s / 7000)) + post); // writing to this writes to the output buffer
796
+
797
+ var w = o.subarray(pre, o.length - post);
798
+ var pos = 0;
799
+
800
+ if (!lvl || s < 8) {
801
+ for (var i = 0; i <= s; i += 65535) {
802
+ // end
803
+ var e = i + 65535;
804
+
805
+ if (e < s) {
806
+ // write full block
807
+ pos = wfblk(w, pos, dat.subarray(i, e));
808
+ } else {
809
+ // write final block
810
+ w[i] = lst;
811
+ pos = wfblk(w, pos, dat.subarray(i, s));
812
+ }
813
+ }
814
+ } else {
815
+ var opt = deo[lvl - 1];
816
+ var n = opt >>> 13,
817
+ c = opt & 8191;
818
+ var msk_1 = (1 << plvl) - 1; // prev 2-byte val map curr 2-byte val map
819
+
820
+ var prev = new u16(32768),
821
+ head = new u16(msk_1 + 1);
822
+ var bs1_1 = Math.ceil(plvl / 3),
823
+ bs2_1 = 2 * bs1_1;
824
+
825
+ var hsh = function hsh(i) {
826
+ return (dat[i] ^ dat[i + 1] << bs1_1 ^ dat[i + 2] << bs2_1) & msk_1;
827
+ }; // 24576 is an arbitrary number of maximum symbols per block
828
+ // 424 buffer for last block
829
+
830
+
831
+ var syms = new u32(25000); // length/literal freq distance freq
832
+
833
+ var lf = new u16(288),
834
+ df = new u16(32); // l/lcnt exbits index l/lind waitdx bitpos
835
+
836
+ var lc_1 = 0,
837
+ eb = 0,
838
+ i = 0,
839
+ li = 0,
840
+ wi = 0,
841
+ bs = 0;
842
+
843
+ for (; i < s; ++i) {
844
+ // hash value
845
+ // deopt when i > s - 3 - at end, deopt acceptable
846
+ var hv = hsh(i); // index mod 32768 previous index mod
847
+
848
+ var imod = i & 32767,
849
+ pimod = head[hv];
850
+ prev[imod] = pimod;
851
+ head[hv] = imod; // We always should modify head and prev, but only add symbols if
852
+ // this data is not yet processed ("wait" for wait index)
853
+
854
+ if (wi <= i) {
855
+ // bytes remaining
856
+ var rem = s - i;
857
+
858
+ if ((lc_1 > 7000 || li > 24576) && rem > 423) {
859
+ pos = wblk(dat, w, 0, syms, lf, df, eb, li, bs, i - bs, pos);
860
+ li = lc_1 = eb = 0, bs = i;
861
+
862
+ for (var j = 0; j < 286; ++j) {
863
+ lf[j] = 0;
864
+ }
865
+
866
+ for (var j = 0; j < 30; ++j) {
867
+ df[j] = 0;
868
+ }
869
+ } // len dist chain
870
+
871
+
872
+ var l = 2,
873
+ d = 0,
874
+ ch_1 = c,
875
+ dif = imod - pimod & 32767;
876
+
877
+ if (rem > 2 && hv == hsh(i - dif)) {
878
+ var maxn = Math.min(n, rem) - 1;
879
+ var maxd = Math.min(32767, i); // max possible length
880
+ // not capped at dif because decompressors implement "rolling" index population
881
+
882
+ var ml = Math.min(258, rem);
883
+
884
+ while (dif <= maxd && --ch_1 && imod != pimod) {
885
+ if (dat[i + l] == dat[i + l - dif]) {
886
+ var nl = 0;
887
+
888
+ for (; nl < ml && dat[i + nl] == dat[i + nl - dif]; ++nl) {
889
+ ;
890
+ }
891
+
892
+ if (nl > l) {
893
+ l = nl, d = dif; // break out early when we reach "nice" (we are satisfied enough)
894
+
895
+ if (nl > maxn) break; // now, find the rarest 2-byte sequence within this
896
+ // length of literals and search for that instead.
897
+ // Much faster than just using the start
898
+
899
+ var mmd = Math.min(dif, nl - 2);
900
+ var md = 0;
901
+
902
+ for (var j = 0; j < mmd; ++j) {
903
+ var ti = i - dif + j + 32768 & 32767;
904
+ var pti = prev[ti];
905
+ var cd = ti - pti + 32768 & 32767;
906
+ if (cd > md) md = cd, pimod = ti;
907
+ }
908
+ }
909
+ } // check the previous match
910
+
911
+
912
+ imod = pimod, pimod = prev[imod];
913
+ dif += imod - pimod + 32768 & 32767;
914
+ }
915
+ } // d will be nonzero only when a match was found
916
+
917
+
918
+ if (d) {
919
+ // store both dist and len data in one Uint32
920
+ // Make sure this is recognized as a len/dist with 28th bit (2^28)
921
+ syms[li++] = 268435456 | revfl[l] << 18 | revfd[d];
922
+ var lin = revfl[l] & 31,
923
+ din = revfd[d] & 31;
924
+ eb += fleb[lin] + fdeb[din];
925
+ ++lf[257 + lin];
926
+ ++df[din];
927
+ wi = i + l;
928
+ ++lc_1;
929
+ } else {
930
+ syms[li++] = dat[i];
931
+ ++lf[dat[i]];
932
+ }
933
+ }
934
+ }
935
+
936
+ pos = wblk(dat, w, lst, syms, lf, df, eb, li, bs, i - bs, pos); // this is the easiest way to avoid needing to maintain state
937
+
938
+ if (!lst && pos & 7) pos = wfblk(w, pos + 1, et);
939
+ }
940
+
941
+ return slc(o, 0, pre + shft(pos) + post);
942
+ }; // CRC32 table
943
+
944
+
945
+ var crct = /*#__PURE__*/function () {
946
+ var t = new u32(256);
947
+
948
+ for (var i = 0; i < 256; ++i) {
949
+ var c = i,
950
+ k = 9;
951
+
952
+ while (--k) {
953
+ c = (c & 1 && 0xEDB88320) ^ c >>> 1;
954
+ }
955
+
956
+ t[i] = c;
957
+ }
958
+
959
+ return t;
960
+ }(); // CRC32
961
+
962
+
963
+ var crc = function crc() {
964
+ var c = -1;
965
+ return {
966
+ p: function p(d) {
967
+ // closures have awful performance
968
+ var cr = c;
969
+
970
+ for (var i = 0; i < d.length; ++i) {
971
+ cr = crct[cr & 255 ^ d[i]] ^ cr >>> 8;
972
+ }
973
+
974
+ c = cr;
975
+ },
976
+ d: function d() {
977
+ return ~c;
978
+ }
979
+ };
980
+ }; // Alder32
981
+
982
+
983
+ var adler = function adler() {
984
+ var a = 1,
985
+ b = 0;
986
+ return {
987
+ p: function p(d) {
988
+ // closures have awful performance
989
+ var n = a,
990
+ m = b;
991
+ var l = d.length;
992
+
993
+ for (var i = 0; i != l;) {
994
+ var e = Math.min(i + 2655, l);
995
+
996
+ for (; i < e; ++i) {
997
+ m += n += d[i];
998
+ }
999
+
1000
+ n = (n & 65535) + 15 * (n >> 16), m = (m & 65535) + 15 * (m >> 16);
1001
+ }
1002
+
1003
+ a = n, b = m;
1004
+ },
1005
+ d: function d() {
1006
+ a %= 65521, b %= 65521;
1007
+ return (a & 255) << 24 | a >>> 8 << 16 | (b & 255) << 8 | b >>> 8;
1008
+ }
1009
+ };
1010
+ };
1011
+
1012
+ ; // deflate with opts
1013
+
1014
+ var dopt = function dopt(dat, opt, pre, post, st) {
1015
+ return dflt(dat, opt.level == null ? 6 : opt.level, opt.mem == null ? Math.ceil(Math.max(8, Math.min(13, Math.log(dat.length))) * 1.5) : 12 + opt.mem, pre, post, !st);
1016
+ }; // Walmart object spread
1017
+
1018
+
1019
+ var mrg = function mrg(a, b) {
1020
+ var o = {};
1021
+
1022
+ for (var k in a) {
1023
+ o[k] = a[k];
1024
+ }
1025
+
1026
+ for (var k in b) {
1027
+ o[k] = b[k];
1028
+ }
1029
+
1030
+ return o;
1031
+ }; // worker clone
1032
+ // This is possibly the craziest part of the entire codebase, despite how simple it may seem.
1033
+ // The only parameter to this function is a closure that returns an array of variables outside of the function scope.
1034
+ // We're going to try to figure out the variable names used in the closure as strings because that is crucial for workerization.
1035
+ // We will return an object mapping of true variable name to value (basically, the current scope as a JS object).
1036
+ // The reason we can't just use the original variable names is minifiers mangling the toplevel scope.
1037
+ // This took me three weeks to figure out how to do.
1038
+
1039
+
1040
+ var wcln = function wcln(fn, fnStr, td) {
1041
+ var dt = fn();
1042
+ var st = fn.toString();
1043
+ var ks = st.slice(st.indexOf('[') + 1, st.lastIndexOf(']')).replace(/ /g, '').split(',');
1044
+
1045
+ for (var i = 0; i < dt.length; ++i) {
1046
+ var v = dt[i],
1047
+ k = ks[i];
1048
+
1049
+ if (typeof v == 'function') {
1050
+ fnStr += ';' + k + '=';
1051
+ var st_1 = v.toString();
1052
+
1053
+ if (v.prototype) {
1054
+ // for global objects
1055
+ if (st_1.indexOf('[native code]') != -1) {
1056
+ var spInd = st_1.indexOf(' ', 8) + 1;
1057
+ fnStr += st_1.slice(spInd, st_1.indexOf('(', spInd));
1058
+ } else {
1059
+ fnStr += st_1;
1060
+
1061
+ for (var t in v.prototype) {
1062
+ fnStr += ';' + k + '.prototype.' + t + '=' + v.prototype[t].toString();
1063
+ }
1064
+ }
1065
+ } else fnStr += st_1;
1066
+ } else td[k] = v;
1067
+ }
1068
+
1069
+ return [fnStr, td];
1070
+ };
1071
+
1072
+ var ch = []; // clone bufs
1073
+
1074
+ var cbfs = function cbfs(v) {
1075
+ var tl = [];
1076
+
1077
+ for (var k in v) {
1078
+ if (v[k] instanceof u8 || v[k] instanceof u16 || v[k] instanceof u32) tl.push((v[k] = new v[k].constructor(v[k])).buffer);
1079
+ }
1080
+
1081
+ return tl;
1082
+ }; // use a worker to execute code
1083
+
1084
+
1085
+ var wrkr = function wrkr(fns, init, id, cb) {
1086
+ var _a;
1087
+
1088
+ if (!ch[id]) {
1089
+ var fnStr = '',
1090
+ td_1 = {},
1091
+ m = fns.length - 1;
1092
+
1093
+ for (var i = 0; i < m; ++i) {
1094
+ _a = wcln(fns[i], fnStr, td_1), fnStr = _a[0], td_1 = _a[1];
1095
+ }
1096
+
1097
+ ch[id] = wcln(fns[m], fnStr, td_1);
1098
+ }
1099
+
1100
+ var td = mrg({}, ch[id][1]);
1101
+ return wk(ch[id][0] + ';onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage=' + init.toString() + '}', id, td, cbfs(td), cb);
1102
+ }; // base async inflate fn
1103
+
1104
+
1105
+ var bInflt = function bInflt() {
1106
+ return [u8, u16, u32, fleb, fdeb, clim, fl, fd, flrm, fdrm, rev, hMap, max, bits, bits16, shft, slc, inflt, inflateSync, pbf, gu8];
1107
+ };
1108
+
1109
+ var bDflt = function bDflt() {
1110
+ return [u8, u16, u32, fleb, fdeb, clim, revfl, revfd, flm, flt, fdm, fdt, rev, deo, et, hMap, wbits, wbits16, hTree, ln, lc, clen, wfblk, wblk, shft, slc, dflt, dopt, deflateSync, pbf];
1111
+ }; // gzip extra
1112
+
1113
+
1114
+ var gze = function gze() {
1115
+ return [gzh, gzhl, wbytes, crc, crct];
1116
+ }; // gunzip extra
1117
+
1118
+
1119
+ var guze = function guze() {
1120
+ return [gzs, gzl];
1121
+ }; // zlib extra
1122
+
1123
+
1124
+ var zle = function zle() {
1125
+ return [zlh, wbytes, adler];
1126
+ }; // unzlib extra
1127
+
1128
+
1129
+ var zule = function zule() {
1130
+ return [zlv];
1131
+ }; // post buf
1132
+
1133
+
1134
+ var pbf = function pbf(msg) {
1135
+ return postMessage(msg, [msg.buffer]);
1136
+ }; // get u8
1137
+
1138
+
1139
+ var gu8 = function gu8(o) {
1140
+ return o && o.size && new u8(o.size);
1141
+ }; // async helper
1142
+
1143
+
1144
+ var cbify = function cbify(dat, opts, fns, init, id, cb) {
1145
+ var w = wrkr(fns, init, id, function (err, dat) {
1146
+ w.terminate();
1147
+ cb(err, dat);
1148
+ });
1149
+ w.postMessage([dat, opts], opts.consume ? [dat.buffer] : []);
1150
+ return function () {
1151
+ w.terminate();
1152
+ };
1153
+ }; // auto stream
1154
+
1155
+
1156
+ var astrm = function astrm(strm) {
1157
+ strm.ondata = function (dat, final) {
1158
+ return postMessage([dat, final], [dat.buffer]);
1159
+ };
1160
+
1161
+ return function (ev) {
1162
+ return strm.push(ev.data[0], ev.data[1]);
1163
+ };
1164
+ }; // async stream attach
1165
+
1166
+
1167
+ var astrmify = function astrmify(fns, strm, opts, init, id) {
1168
+ var t;
1169
+ var w = wrkr(fns, init, id, function (err, dat) {
1170
+ if (err) w.terminate(), strm.ondata.call(strm, err);else {
1171
+ if (dat[1]) w.terminate();
1172
+ strm.ondata.call(strm, err, dat[0], dat[1]);
1173
+ }
1174
+ });
1175
+ w.postMessage(opts);
1176
+
1177
+ strm.push = function (d, f) {
1178
+ if (t) throw 'stream finished';
1179
+ if (!strm.ondata) throw 'no stream handler';
1180
+ w.postMessage([d, t = f], [d.buffer]);
1181
+ };
1182
+
1183
+ strm.terminate = function () {
1184
+ w.terminate();
1185
+ };
1186
+ }; // read 2 bytes
1187
+
1188
+
1189
+ var b2 = function b2(d, b) {
1190
+ return d[b] | d[b + 1] << 8;
1191
+ }; // read 4 bytes
1192
+
1193
+
1194
+ var b4 = function b4(d, b) {
1195
+ return (d[b] | d[b + 1] << 8 | d[b + 2] << 16 | d[b + 3] << 24) >>> 0;
1196
+ };
1197
+
1198
+ var b8 = function b8(d, b) {
1199
+ return b4(d, b) + b4(d, b + 4) * 4294967296;
1200
+ }; // write bytes
1201
+
1202
+
1203
+ var wbytes = function wbytes(d, b, v) {
1204
+ for (; v; ++b) {
1205
+ d[b] = v, v >>>= 8;
1206
+ }
1207
+ }; // gzip header
1208
+
1209
+
1210
+ var gzh = function gzh(c, o) {
1211
+ var fn = o.filename;
1212
+ c[0] = 31, c[1] = 139, c[2] = 8, c[8] = o.level < 2 ? 4 : o.level == 9 ? 2 : 0, c[9] = 3; // assume Unix
1213
+
1214
+ if (o.mtime != 0) wbytes(c, 4, Math.floor(new Date(o.mtime || Date.now()) / 1000));
1215
+
1216
+ if (fn) {
1217
+ c[3] = 8;
1218
+
1219
+ for (var i = 0; i <= fn.length; ++i) {
1220
+ c[i + 10] = fn.charCodeAt(i);
1221
+ }
1222
+ }
1223
+ }; // gzip footer: -8 to -4 = CRC, -4 to -0 is length
1224
+ // gzip start
1225
+
1226
+
1227
+ var gzs = function gzs(d) {
1228
+ if (d[0] != 31 || d[1] != 139 || d[2] != 8) throw 'invalid gzip data';
1229
+ var flg = d[3];
1230
+ var st = 10;
1231
+ if (flg & 4) st += d[10] | (d[11] << 8) + 2;
1232
+
1233
+ for (var zs = (flg >> 3 & 1) + (flg >> 4 & 1); zs > 0; zs -= !d[st++]) {
1234
+ ;
1235
+ }
1236
+
1237
+ return st + (flg & 2);
1238
+ }; // gzip length
1239
+
1240
+
1241
+ var gzl = function gzl(d) {
1242
+ var l = d.length;
1243
+ return (d[l - 4] | d[l - 3] << 8 | d[l - 2] << 16 | d[l - 1] << 24) >>> 0;
1244
+ }; // gzip header length
1245
+
1246
+
1247
+ var gzhl = function gzhl(o) {
1248
+ return 10 + (o.filename && o.filename.length + 1 || 0);
1249
+ }; // zlib header
1250
+
1251
+
1252
+ var zlh = function zlh(c, o) {
1253
+ var lv = o.level,
1254
+ fl = lv == 0 ? 0 : lv < 6 ? 1 : lv == 9 ? 3 : 2;
1255
+ c[0] = 120, c[1] = fl << 6 | (fl ? 32 - 2 * fl : 1);
1256
+ }; // zlib valid
1257
+
1258
+
1259
+ var zlv = function zlv(d) {
1260
+ if ((d[0] & 15) != 8 || d[0] >>> 4 > 7 || (d[0] << 8 | d[1]) % 31) throw 'invalid zlib data';
1261
+ if (d[1] & 32) throw 'invalid zlib data: preset dictionaries not supported';
1262
+ };
1263
+
1264
+ function AsyncCmpStrm(opts, cb) {
1265
+ if (!cb && typeof opts == 'function') cb = opts, opts = {};
1266
+ this.ondata = cb;
1267
+ return opts;
1268
+ } // zlib footer: -4 to -0 is Adler32
1269
+
1270
+ /**
1271
+ * Streaming DEFLATE compression
1272
+ */
1273
+
1274
+
1275
+ var Deflate = /*#__PURE__*/function () {
1276
+ function Deflate(opts, cb) {
1277
+ if (!cb && typeof opts == 'function') cb = opts, opts = {};
1278
+ this.ondata = cb;
1279
+ this.o = opts || {};
1280
+ }
1281
+
1282
+ Deflate.prototype.p = function (c, f) {
1283
+ this.ondata(dopt(c, this.o, 0, 0, !f), f);
1284
+ };
1285
+ /**
1286
+ * Pushes a chunk to be deflated
1287
+ * @param chunk The chunk to push
1288
+ * @param final Whether this is the last chunk
1289
+ */
1290
+
1291
+
1292
+ Deflate.prototype.push = function (chunk, final) {
1293
+ if (this.d) throw 'stream finished';
1294
+ if (!this.ondata) throw 'no stream handler';
1295
+ this.d = final;
1296
+ this.p(chunk, final || false);
1297
+ };
1298
+
1299
+ return Deflate;
1300
+ }();
1301
+
1302
+ _exports.Deflate = Deflate;
1303
+
1304
+ /**
1305
+ * Asynchronous streaming DEFLATE compression
1306
+ */
1307
+ var AsyncDeflate = /*#__PURE__*/function () {
1308
+ function AsyncDeflate(opts, cb) {
1309
+ astrmify([bDflt, function () {
1310
+ return [astrm, Deflate];
1311
+ }], this, AsyncCmpStrm.call(this, opts, cb), function (ev) {
1312
+ var strm = new Deflate(ev.data);
1313
+ onmessage = astrm(strm);
1314
+ }, 6);
1315
+ }
1316
+
1317
+ return AsyncDeflate;
1318
+ }();
1319
+
1320
+ _exports.AsyncDeflate = AsyncDeflate;
1321
+
1322
+ function deflate(data, opts, cb) {
1323
+ if (!cb) cb = opts, opts = {};
1324
+ if (typeof cb != 'function') throw 'no callback';
1325
+ return cbify(data, opts, [bDflt], function (ev) {
1326
+ return pbf(deflateSync(ev.data[0], ev.data[1]));
1327
+ }, 0, cb);
1328
+ }
1329
+ /**
1330
+ * Compresses data with DEFLATE without any wrapper
1331
+ * @param data The data to compress
1332
+ * @param opts The compression options
1333
+ * @returns The deflated version of the data
1334
+ */
1335
+
1336
+
1337
+ function deflateSync(data, opts) {
1338
+ return dopt(data, opts || {}, 0, 0);
1339
+ }
1340
+ /**
1341
+ * Streaming DEFLATE decompression
1342
+ */
1343
+
1344
+
1345
+ var Inflate = /*#__PURE__*/function () {
1346
+ /**
1347
+ * Creates an inflation stream
1348
+ * @param cb The callback to call whenever data is inflated
1349
+ */
1350
+ function Inflate(cb) {
1351
+ this.s = {};
1352
+ this.p = new u8(0);
1353
+ this.ondata = cb;
1354
+ }
1355
+
1356
+ Inflate.prototype.e = function (c) {
1357
+ if (this.d) throw 'stream finished';
1358
+ if (!this.ondata) throw 'no stream handler';
1359
+ var l = this.p.length;
1360
+ var n = new u8(l + c.length);
1361
+ n.set(this.p), n.set(c, l), this.p = n;
1362
+ };
1363
+
1364
+ Inflate.prototype.c = function (final) {
1365
+ this.d = this.s.i = final || false;
1366
+ var bts = this.s.b;
1367
+ var dt = inflt(this.p, this.o, this.s);
1368
+ this.ondata(slc(dt, bts, this.s.b), this.d);
1369
+ this.o = slc(dt, this.s.b - 32768), this.s.b = this.o.length;
1370
+ this.p = slc(this.p, this.s.p / 8 | 0), this.s.p &= 7;
1371
+ };
1372
+ /**
1373
+ * Pushes a chunk to be inflated
1374
+ * @param chunk The chunk to push
1375
+ * @param final Whether this is the final chunk
1376
+ */
1377
+
1378
+
1379
+ Inflate.prototype.push = function (chunk, final) {
1380
+ this.e(chunk), this.c(final);
1381
+ };
1382
+
1383
+ return Inflate;
1384
+ }();
1385
+
1386
+ _exports.Inflate = Inflate;
1387
+
1388
+ /**
1389
+ * Asynchronous streaming DEFLATE decompression
1390
+ */
1391
+ var AsyncInflate = /*#__PURE__*/function () {
1392
+ /**
1393
+ * Creates an asynchronous inflation stream
1394
+ * @param cb The callback to call whenever data is deflated
1395
+ */
1396
+ function AsyncInflate(cb) {
1397
+ this.ondata = cb;
1398
+ astrmify([bInflt, function () {
1399
+ return [astrm, Inflate];
1400
+ }], this, 0, function () {
1401
+ var strm = new Inflate();
1402
+ onmessage = astrm(strm);
1403
+ }, 7);
1404
+ }
1405
+
1406
+ return AsyncInflate;
1407
+ }();
1408
+
1409
+ _exports.AsyncInflate = AsyncInflate;
1410
+
1411
+ function inflate(data, opts, cb) {
1412
+ if (!cb) cb = opts, opts = {};
1413
+ if (typeof cb != 'function') throw 'no callback';
1414
+ return cbify(data, opts, [bInflt], function (ev) {
1415
+ return pbf(inflateSync(ev.data[0], gu8(ev.data[1])));
1416
+ }, 1, cb);
1417
+ }
1418
+ /**
1419
+ * Expands DEFLATE data with no wrapper
1420
+ * @param data The data to decompress
1421
+ * @param out Where to write the data. Saves memory if you know the decompressed size and provide an output buffer of that length.
1422
+ * @returns The decompressed version of the data
1423
+ */
1424
+
1425
+
1426
+ function inflateSync(data, out) {
1427
+ return inflt(data, out);
1428
+ } // before you yell at me for not just using extends, my reason is that TS inheritance is hard to workerize.
1429
+
1430
+ /**
1431
+ * Streaming GZIP compression
1432
+ */
1433
+
1434
+
1435
+ var Gzip = /*#__PURE__*/function () {
1436
+ function Gzip(opts, cb) {
1437
+ this.c = crc();
1438
+ this.l = 0;
1439
+ this.v = 1;
1440
+ Deflate.call(this, opts, cb);
1441
+ }
1442
+ /**
1443
+ * Pushes a chunk to be GZIPped
1444
+ * @param chunk The chunk to push
1445
+ * @param final Whether this is the last chunk
1446
+ */
1447
+
1448
+
1449
+ Gzip.prototype.push = function (chunk, final) {
1450
+ Deflate.prototype.push.call(this, chunk, final);
1451
+ };
1452
+
1453
+ Gzip.prototype.p = function (c, f) {
1454
+ this.c.p(c);
1455
+ this.l += c.length;
1456
+ var raw = dopt(c, this.o, this.v && gzhl(this.o), f && 8, !f);
1457
+ if (this.v) gzh(raw, this.o), this.v = 0;
1458
+ if (f) wbytes(raw, raw.length - 8, this.c.d()), wbytes(raw, raw.length - 4, this.l);
1459
+ this.ondata(raw, f);
1460
+ };
1461
+
1462
+ return Gzip;
1463
+ }();
1464
+
1465
+ _exports.Compress = _exports.Gzip = Gzip;
1466
+
1467
+ /**
1468
+ * Asynchronous streaming GZIP compression
1469
+ */
1470
+ var AsyncGzip = /*#__PURE__*/function () {
1471
+ function AsyncGzip(opts, cb) {
1472
+ astrmify([bDflt, gze, function () {
1473
+ return [astrm, Deflate, Gzip];
1474
+ }], this, AsyncCmpStrm.call(this, opts, cb), function (ev) {
1475
+ var strm = new Gzip(ev.data);
1476
+ onmessage = astrm(strm);
1477
+ }, 8);
1478
+ }
1479
+
1480
+ return AsyncGzip;
1481
+ }();
1482
+
1483
+ _exports.AsyncCompress = _exports.AsyncGzip = AsyncGzip;
1484
+
1485
+ function gzip(data, opts, cb) {
1486
+ if (!cb) cb = opts, opts = {};
1487
+ if (typeof cb != 'function') throw 'no callback';
1488
+ return cbify(data, opts, [bDflt, gze, function () {
1489
+ return [gzipSync];
1490
+ }], function (ev) {
1491
+ return pbf(gzipSync(ev.data[0], ev.data[1]));
1492
+ }, 2, cb);
1493
+ }
1494
+ /**
1495
+ * Compresses data with GZIP
1496
+ * @param data The data to compress
1497
+ * @param opts The compression options
1498
+ * @returns The gzipped version of the data
1499
+ */
1500
+
1501
+
1502
+ function gzipSync(data, opts) {
1503
+ if (!opts) opts = {};
1504
+ var c = crc(),
1505
+ l = data.length;
1506
+ c.p(data);
1507
+ var d = dopt(data, opts, gzhl(opts), 8),
1508
+ s = d.length;
1509
+ return gzh(d, opts), wbytes(d, s - 8, c.d()), wbytes(d, s - 4, l), d;
1510
+ }
1511
+ /**
1512
+ * Streaming GZIP decompression
1513
+ */
1514
+
1515
+
1516
+ var Gunzip = /*#__PURE__*/function () {
1517
+ /**
1518
+ * Creates a GUNZIP stream
1519
+ * @param cb The callback to call whenever data is inflated
1520
+ */
1521
+ function Gunzip(cb) {
1522
+ this.v = 1;
1523
+ Inflate.call(this, cb);
1524
+ }
1525
+ /**
1526
+ * Pushes a chunk to be GUNZIPped
1527
+ * @param chunk The chunk to push
1528
+ * @param final Whether this is the last chunk
1529
+ */
1530
+
1531
+
1532
+ Gunzip.prototype.push = function (chunk, final) {
1533
+ Inflate.prototype.e.call(this, chunk);
1534
+
1535
+ if (this.v) {
1536
+ var s = this.p.length > 3 ? gzs(this.p) : 4;
1537
+ if (s >= this.p.length && !final) return;
1538
+ this.p = this.p.subarray(s), this.v = 0;
1539
+ }
1540
+
1541
+ if (final) {
1542
+ if (this.p.length < 8) throw 'invalid gzip stream';
1543
+ this.p = this.p.subarray(0, -8);
1544
+ } // necessary to prevent TS from using the closure value
1545
+ // This allows for workerization to function correctly
1546
+
1547
+
1548
+ Inflate.prototype.c.call(this, final);
1549
+ };
1550
+
1551
+ return Gunzip;
1552
+ }();
1553
+
1554
+ _exports.Gunzip = Gunzip;
1555
+
1556
+ /**
1557
+ * Asynchronous streaming GZIP decompression
1558
+ */
1559
+ var AsyncGunzip = /*#__PURE__*/function () {
1560
+ /**
1561
+ * Creates an asynchronous GUNZIP stream
1562
+ * @param cb The callback to call whenever data is deflated
1563
+ */
1564
+ function AsyncGunzip(cb) {
1565
+ this.ondata = cb;
1566
+ astrmify([bInflt, guze, function () {
1567
+ return [astrm, Inflate, Gunzip];
1568
+ }], this, 0, function () {
1569
+ var strm = new Gunzip();
1570
+ onmessage = astrm(strm);
1571
+ }, 9);
1572
+ }
1573
+
1574
+ return AsyncGunzip;
1575
+ }();
1576
+
1577
+ _exports.AsyncGunzip = AsyncGunzip;
1578
+
1579
+ function gunzip(data, opts, cb) {
1580
+ if (!cb) cb = opts, opts = {};
1581
+ if (typeof cb != 'function') throw 'no callback';
1582
+ return cbify(data, opts, [bInflt, guze, function () {
1583
+ return [gunzipSync];
1584
+ }], function (ev) {
1585
+ return pbf(gunzipSync(ev.data[0]));
1586
+ }, 3, cb);
1587
+ }
1588
+ /**
1589
+ * Expands GZIP data
1590
+ * @param data The data to decompress
1591
+ * @param out Where to write the data. GZIP already encodes the output size, so providing this doesn't save memory.
1592
+ * @returns The decompressed version of the data
1593
+ */
1594
+
1595
+
1596
+ function gunzipSync(data, out) {
1597
+ return inflt(data.subarray(gzs(data), -8), out || new u8(gzl(data)));
1598
+ }
1599
+ /**
1600
+ * Streaming Zlib compression
1601
+ */
1602
+
1603
+
1604
+ var Zlib = /*#__PURE__*/function () {
1605
+ function Zlib(opts, cb) {
1606
+ this.c = adler();
1607
+ this.v = 1;
1608
+ Deflate.call(this, opts, cb);
1609
+ }
1610
+ /**
1611
+ * Pushes a chunk to be zlibbed
1612
+ * @param chunk The chunk to push
1613
+ * @param final Whether this is the last chunk
1614
+ */
1615
+
1616
+
1617
+ Zlib.prototype.push = function (chunk, final) {
1618
+ Deflate.prototype.push.call(this, chunk, final);
1619
+ };
1620
+
1621
+ Zlib.prototype.p = function (c, f) {
1622
+ this.c.p(c);
1623
+ var raw = dopt(c, this.o, this.v && 2, f && 4, !f);
1624
+ if (this.v) zlh(raw, this.o), this.v = 0;
1625
+ if (f) wbytes(raw, raw.length - 4, this.c.d());
1626
+ this.ondata(raw, f);
1627
+ };
1628
+
1629
+ return Zlib;
1630
+ }();
1631
+
1632
+ _exports.Zlib = Zlib;
1633
+
1634
+ /**
1635
+ * Asynchronous streaming Zlib compression
1636
+ */
1637
+ var AsyncZlib = /*#__PURE__*/function () {
1638
+ function AsyncZlib(opts, cb) {
1639
+ astrmify([bDflt, zle, function () {
1640
+ return [astrm, Deflate, Zlib];
1641
+ }], this, AsyncCmpStrm.call(this, opts, cb), function (ev) {
1642
+ var strm = new Zlib(ev.data);
1643
+ onmessage = astrm(strm);
1644
+ }, 10);
1645
+ }
1646
+
1647
+ return AsyncZlib;
1648
+ }();
1649
+
1650
+ _exports.AsyncZlib = AsyncZlib;
1651
+
1652
+ function zlib(data, opts, cb) {
1653
+ if (!cb) cb = opts, opts = {};
1654
+ if (typeof cb != 'function') throw 'no callback';
1655
+ return cbify(data, opts, [bDflt, zle, function () {
1656
+ return [zlibSync];
1657
+ }], function (ev) {
1658
+ return pbf(zlibSync(ev.data[0], ev.data[1]));
1659
+ }, 4, cb);
1660
+ }
1661
+ /**
1662
+ * Compress data with Zlib
1663
+ * @param data The data to compress
1664
+ * @param opts The compression options
1665
+ * @returns The zlib-compressed version of the data
1666
+ */
1667
+
1668
+
1669
+ function zlibSync(data, opts) {
1670
+ if (!opts) opts = {};
1671
+ var a = adler();
1672
+ a.p(data);
1673
+ var d = dopt(data, opts, 2, 4);
1674
+ return zlh(d, opts), wbytes(d, d.length - 4, a.d()), d;
1675
+ }
1676
+ /**
1677
+ * Streaming Zlib decompression
1678
+ */
1679
+
1680
+
1681
+ var Unzlib = /*#__PURE__*/function () {
1682
+ /**
1683
+ * Creates a Zlib decompression stream
1684
+ * @param cb The callback to call whenever data is inflated
1685
+ */
1686
+ function Unzlib(cb) {
1687
+ this.v = 1;
1688
+ Inflate.call(this, cb);
1689
+ }
1690
+ /**
1691
+ * Pushes a chunk to be unzlibbed
1692
+ * @param chunk The chunk to push
1693
+ * @param final Whether this is the last chunk
1694
+ */
1695
+
1696
+
1697
+ Unzlib.prototype.push = function (chunk, final) {
1698
+ Inflate.prototype.e.call(this, chunk);
1699
+
1700
+ if (this.v) {
1701
+ if (this.p.length < 2 && !final) return;
1702
+ this.p = this.p.subarray(2), this.v = 0;
1703
+ }
1704
+
1705
+ if (final) {
1706
+ if (this.p.length < 4) throw 'invalid zlib stream';
1707
+ this.p = this.p.subarray(0, -4);
1708
+ } // necessary to prevent TS from using the closure value
1709
+ // This allows for workerization to function correctly
1710
+
1711
+
1712
+ Inflate.prototype.c.call(this, final);
1713
+ };
1714
+
1715
+ return Unzlib;
1716
+ }();
1717
+
1718
+ _exports.Unzlib = Unzlib;
1719
+
1720
+ /**
1721
+ * Asynchronous streaming Zlib decompression
1722
+ */
1723
+ var AsyncUnzlib = /*#__PURE__*/function () {
1724
+ /**
1725
+ * Creates an asynchronous Zlib decompression stream
1726
+ * @param cb The callback to call whenever data is deflated
1727
+ */
1728
+ function AsyncUnzlib(cb) {
1729
+ this.ondata = cb;
1730
+ astrmify([bInflt, zule, function () {
1731
+ return [astrm, Inflate, Unzlib];
1732
+ }], this, 0, function () {
1733
+ var strm = new Unzlib();
1734
+ onmessage = astrm(strm);
1735
+ }, 11);
1736
+ }
1737
+
1738
+ return AsyncUnzlib;
1739
+ }();
1740
+
1741
+ _exports.AsyncUnzlib = AsyncUnzlib;
1742
+
1743
+ function unzlib(data, opts, cb) {
1744
+ if (!cb) cb = opts, opts = {};
1745
+ if (typeof cb != 'function') throw 'no callback';
1746
+ return cbify(data, opts, [bInflt, zule, function () {
1747
+ return [unzlibSync];
1748
+ }], function (ev) {
1749
+ return pbf(unzlibSync(ev.data[0], gu8(ev.data[1])));
1750
+ }, 5, cb);
1751
+ }
1752
+ /**
1753
+ * Expands Zlib data
1754
+ * @param data The data to decompress
1755
+ * @param out Where to write the data. Saves memory if you know the decompressed size and provide an output buffer of that length.
1756
+ * @returns The decompressed version of the data
1757
+ */
1758
+
1759
+
1760
+ function unzlibSync(data, out) {
1761
+ return inflt((zlv(data), data.subarray(2, -4)), out);
1762
+ } // Default algorithm for compression (used because having a known output size allows faster decompression)
1763
+
1764
+
1765
+ /**
1766
+ * Streaming GZIP, Zlib, or raw DEFLATE decompression
1767
+ */
1768
+ var Decompress = /*#__PURE__*/function () {
1769
+ /**
1770
+ * Creates a decompression stream
1771
+ * @param cb The callback to call whenever data is decompressed
1772
+ */
1773
+ function Decompress(cb) {
1774
+ this.G = Gunzip;
1775
+ this.I = Inflate;
1776
+ this.Z = Unzlib;
1777
+ this.ondata = cb;
1778
+ }
1779
+ /**
1780
+ * Pushes a chunk to be decompressed
1781
+ * @param chunk The chunk to push
1782
+ * @param final Whether this is the last chunk
1783
+ */
1784
+
1785
+
1786
+ Decompress.prototype.push = function (chunk, final) {
1787
+ if (!this.ondata) throw 'no stream handler';
1788
+
1789
+ if (!this.s) {
1790
+ if (this.p && this.p.length) {
1791
+ var n = new u8(this.p.length + chunk.length);
1792
+ n.set(this.p), n.set(chunk, this.p.length);
1793
+ } else this.p = chunk;
1794
+
1795
+ if (this.p.length > 2) {
1796
+ var _this_1 = this;
1797
+
1798
+ var cb = function cb() {
1799
+ _this_1.ondata.apply(_this_1, arguments);
1800
+ };
1801
+
1802
+ this.s = this.p[0] == 31 && this.p[1] == 139 && this.p[2] == 8 ? new this.G(cb) : (this.p[0] & 15) != 8 || this.p[0] >> 4 > 7 || (this.p[0] << 8 | this.p[1]) % 31 ? new this.I(cb) : new this.Z(cb);
1803
+ this.s.push(this.p, final);
1804
+ this.p = null;
1805
+ }
1806
+ } else this.s.push(chunk, final);
1807
+ };
1808
+
1809
+ return Decompress;
1810
+ }();
1811
+
1812
+ _exports.Decompress = Decompress;
1813
+
1814
+ /**
1815
+ * Asynchronous streaming GZIP, Zlib, or raw DEFLATE decompression
1816
+ */
1817
+ var AsyncDecompress = /*#__PURE__*/function () {
1818
+ /**
1819
+ * Creates an asynchronous decompression stream
1820
+ * @param cb The callback to call whenever data is decompressed
1821
+ */
1822
+ function AsyncDecompress(cb) {
1823
+ this.G = AsyncGunzip;
1824
+ this.I = AsyncInflate;
1825
+ this.Z = AsyncUnzlib;
1826
+ this.ondata = cb;
1827
+ }
1828
+ /**
1829
+ * Pushes a chunk to be decompressed
1830
+ * @param chunk The chunk to push
1831
+ * @param final Whether this is the last chunk
1832
+ */
1833
+
1834
+
1835
+ AsyncDecompress.prototype.push = function (chunk, final) {
1836
+ Decompress.prototype.push.call(this, chunk, final);
1837
+ };
1838
+
1839
+ return AsyncDecompress;
1840
+ }();
1841
+
1842
+ _exports.AsyncDecompress = AsyncDecompress;
1843
+
1844
+ function decompress(data, opts, cb) {
1845
+ if (!cb) cb = opts, opts = {};
1846
+ if (typeof cb != 'function') throw 'no callback';
1847
+ return data[0] == 31 && data[1] == 139 && data[2] == 8 ? gunzip(data, opts, cb) : (data[0] & 15) != 8 || data[0] >> 4 > 7 || (data[0] << 8 | data[1]) % 31 ? inflate(data, opts, cb) : unzlib(data, opts, cb);
1848
+ }
1849
+ /**
1850
+ * Expands compressed GZIP, Zlib, or raw DEFLATE data, automatically detecting the format
1851
+ * @param data The data to decompress
1852
+ * @param out Where to write the data. Saves memory if you know the decompressed size and provide an output buffer of that length.
1853
+ * @returns The decompressed version of the data
1854
+ */
1855
+
1856
+
1857
+ function decompressSync(data, out) {
1858
+ return data[0] == 31 && data[1] == 139 && data[2] == 8 ? gunzipSync(data, out) : (data[0] & 15) != 8 || data[0] >> 4 > 7 || (data[0] << 8 | data[1]) % 31 ? inflateSync(data, out) : unzlibSync(data, out);
1859
+ } // flatten a directory structure
1860
+
1861
+
1862
+ var fltn = function fltn(d, p, t, o) {
1863
+ for (var k in d) {
1864
+ var val = d[k],
1865
+ n = p + k;
1866
+ if (val instanceof u8) t[n] = [val, o];else if (Array.isArray(val)) t[n] = [val[0], mrg(o, val[1])];else fltn(val, n + '/', t, o);
1867
+ }
1868
+ }; // text encoder
1869
+
1870
+
1871
+ var te = typeof TextEncoder != 'undefined' && /*#__PURE__*/new TextEncoder(); // text decoder
1872
+
1873
+ var td = typeof TextDecoder != 'undefined' && /*#__PURE__*/new TextDecoder(); // text decoder stream
1874
+
1875
+ var tds = 0;
1876
+
1877
+ try {
1878
+ td.decode(et, {
1879
+ stream: true
1880
+ });
1881
+ tds = 1;
1882
+ } catch (e) {} // decode UTF8
1883
+
1884
+
1885
+ var dutf8 = function dutf8(d) {
1886
+ for (var r = '', i = 0;;) {
1887
+ var c = d[i++];
1888
+ var eb = (c > 127) + (c > 223) + (c > 239);
1889
+ if (i + eb > d.length) return [r, slc(d, i - 1)];
1890
+ if (!eb) r += String.fromCharCode(c);else if (eb == 3) {
1891
+ c = ((c & 15) << 18 | (d[i++] & 63) << 12 | (d[i++] & 63) << 6 | d[i++] & 63) - 65536, r += String.fromCharCode(55296 | c >> 10, 56320 | c & 1023);
1892
+ } else if (eb & 1) r += String.fromCharCode((c & 31) << 6 | d[i++] & 63);else r += String.fromCharCode((c & 15) << 12 | (d[i++] & 63) << 6 | d[i++] & 63);
1893
+ }
1894
+ };
1895
+ /**
1896
+ * Streaming UTF-8 decoding
1897
+ */
1898
+
1899
+
1900
+ var DecodeUTF8 = /*#__PURE__*/function () {
1901
+ /**
1902
+ * Creates a UTF-8 decoding stream
1903
+ * @param cb The callback to call whenever data is decoded
1904
+ */
1905
+ function DecodeUTF8(cb) {
1906
+ this.ondata = cb;
1907
+ if (tds) this.t = new TextDecoder();else this.p = et;
1908
+ }
1909
+ /**
1910
+ * Pushes a chunk to be decoded from UTF-8 binary
1911
+ * @param chunk The chunk to push
1912
+ * @param final Whether this is the last chunk
1913
+ */
1914
+
1915
+
1916
+ DecodeUTF8.prototype.push = function (chunk, final) {
1917
+ if (!this.ondata) throw 'no callback';
1918
+ final = !!final;
1919
+
1920
+ if (this.t) {
1921
+ this.ondata(this.t.decode(chunk, {
1922
+ stream: true
1923
+ }), final);
1924
+
1925
+ if (final) {
1926
+ if (this.t.decode().length) throw 'invalid utf-8 data';
1927
+ this.t = null;
1928
+ }
1929
+
1930
+ return;
1931
+ }
1932
+
1933
+ if (!this.p) throw 'stream finished';
1934
+ var dat = new u8(this.p.length + chunk.length);
1935
+ dat.set(this.p);
1936
+ dat.set(chunk, this.p.length);
1937
+
1938
+ var _a = dutf8(dat),
1939
+ ch = _a[0],
1940
+ np = _a[1];
1941
+
1942
+ if (final) {
1943
+ if (np.length) throw 'invalid utf-8 data';
1944
+ this.p = null;
1945
+ } else this.p = np;
1946
+
1947
+ this.ondata(ch, final);
1948
+ };
1949
+
1950
+ return DecodeUTF8;
1951
+ }();
1952
+
1953
+ _exports.DecodeUTF8 = DecodeUTF8;
1954
+
1955
+ /**
1956
+ * Streaming UTF-8 encoding
1957
+ */
1958
+ var EncodeUTF8 = /*#__PURE__*/function () {
1959
+ /**
1960
+ * Creates a UTF-8 decoding stream
1961
+ * @param cb The callback to call whenever data is encoded
1962
+ */
1963
+ function EncodeUTF8(cb) {
1964
+ this.ondata = cb;
1965
+ }
1966
+ /**
1967
+ * Pushes a chunk to be encoded to UTF-8
1968
+ * @param chunk The string data to push
1969
+ * @param final Whether this is the last chunk
1970
+ */
1971
+
1972
+
1973
+ EncodeUTF8.prototype.push = function (chunk, final) {
1974
+ if (!this.ondata) throw 'no callback';
1975
+ if (this.d) throw 'stream finished';
1976
+ this.ondata(strToU8(chunk), this.d = final || false);
1977
+ };
1978
+
1979
+ return EncodeUTF8;
1980
+ }();
1981
+
1982
+ _exports.EncodeUTF8 = EncodeUTF8;
1983
+
1984
+ /**
1985
+ * Converts a string into a Uint8Array for use with compression/decompression methods
1986
+ * @param str The string to encode
1987
+ * @param latin1 Whether or not to interpret the data as Latin-1. This should
1988
+ * not need to be true unless decoding a binary string.
1989
+ * @returns The string encoded in UTF-8/Latin-1 binary
1990
+ */
1991
+ function strToU8(str, latin1) {
1992
+ if (latin1) {
1993
+ var ar_1 = new u8(str.length);
1994
+
1995
+ for (var i = 0; i < str.length; ++i) {
1996
+ ar_1[i] = str.charCodeAt(i);
1997
+ }
1998
+
1999
+ return ar_1;
2000
+ }
2001
+
2002
+ if (te) return te.encode(str);
2003
+ var l = str.length;
2004
+ var ar = new u8(str.length + (str.length >> 1));
2005
+ var ai = 0;
2006
+
2007
+ var w = function w(v) {
2008
+ ar[ai++] = v;
2009
+ };
2010
+
2011
+ for (var i = 0; i < l; ++i) {
2012
+ if (ai + 5 > ar.length) {
2013
+ var n = new u8(ai + 8 + (l - i << 1));
2014
+ n.set(ar);
2015
+ ar = n;
2016
+ }
2017
+
2018
+ var c = str.charCodeAt(i);
2019
+ if (c < 128 || latin1) w(c);else if (c < 2048) w(192 | c >> 6), w(128 | c & 63);else if (c > 55295 && c < 57344) c = 65536 + (c & 1023 << 10) | str.charCodeAt(++i) & 1023, w(240 | c >> 18), w(128 | c >> 12 & 63), w(128 | c >> 6 & 63), w(128 | c & 63);else w(224 | c >> 12), w(128 | c >> 6 & 63), w(128 | c & 63);
2020
+ }
2021
+
2022
+ return slc(ar, 0, ai);
2023
+ }
2024
+ /**
2025
+ * Converts a Uint8Array to a string
2026
+ * @param dat The data to decode to string
2027
+ * @param latin1 Whether or not to interpret the data as Latin-1. This should
2028
+ * not need to be true unless encoding to binary string.
2029
+ * @returns The original UTF-8/Latin-1 string
2030
+ */
2031
+
2032
+
2033
+ function strFromU8(dat, latin1) {
2034
+ if (latin1) {
2035
+ var r = '';
2036
+
2037
+ for (var i = 0; i < dat.length; i += 16384) {
2038
+ r += String.fromCharCode.apply(null, dat.subarray(i, i + 16384));
2039
+ }
2040
+
2041
+ return r;
2042
+ } else if (td) return td.decode(dat);else {
2043
+ var _a = dutf8(dat),
2044
+ out = _a[0],
2045
+ ext = _a[1];
2046
+
2047
+ if (ext.length) throw 'invalid utf-8 data';
2048
+ return out;
2049
+ }
2050
+ }
2051
+
2052
+ ; // deflate bit flag
2053
+
2054
+ var dbf = function dbf(l) {
2055
+ return l == 1 ? 3 : l < 6 ? 2 : l == 9 ? 1 : 0;
2056
+ }; // skip local zip header
2057
+
2058
+
2059
+ var slzh = function slzh(d, b) {
2060
+ return b + 30 + b2(d, b + 26) + b2(d, b + 28);
2061
+ }; // read zip header
2062
+
2063
+
2064
+ var zh = function zh(d, b, z) {
2065
+ var fnl = b2(d, b + 28),
2066
+ fn = strFromU8(d.subarray(b + 46, b + 46 + fnl), !(b2(d, b + 8) & 2048)),
2067
+ es = b + 46 + fnl,
2068
+ bs = b4(d, b + 20);
2069
+
2070
+ var _a = z && bs == 4294967295 ? z64e(d, es) : [bs, b4(d, b + 24), b4(d, b + 42)],
2071
+ sc = _a[0],
2072
+ su = _a[1],
2073
+ off = _a[2];
2074
+
2075
+ return [b2(d, b + 10), sc, su, fn, es + b2(d, b + 30) + b2(d, b + 32), off];
2076
+ }; // read zip64 extra field
2077
+
2078
+
2079
+ var z64e = function z64e(d, b) {
2080
+ for (; b2(d, b) != 1; b += 4 + b2(d, b + 2)) {
2081
+ ;
2082
+ }
2083
+
2084
+ return [b8(d, b + 12), b8(d, b + 4), b8(d, b + 20)];
2085
+ }; // extra field length
2086
+
2087
+
2088
+ var exfl = function exfl(ex) {
2089
+ var le = 0;
2090
+
2091
+ if (ex) {
2092
+ for (var k in ex) {
2093
+ var l = ex[k].length;
2094
+ if (l > 65535) throw 'extra field too long';
2095
+ le += l + 4;
2096
+ }
2097
+ }
2098
+
2099
+ return le;
2100
+ }; // write zip header
2101
+
2102
+
2103
+ var wzh = function wzh(d, b, f, fn, u, c, ce, co) {
2104
+ var fl = fn.length,
2105
+ ex = f.extra,
2106
+ col = co && co.length;
2107
+ var exl = exfl(ex);
2108
+ wbytes(d, b, ce != null ? 0x2014B50 : 0x4034B50), b += 4;
2109
+ if (ce != null) d[b++] = 20, d[b++] = f.os;
2110
+ d[b] = 20, b += 2; // spec compliance? what's that?
2111
+
2112
+ d[b++] = f.flag << 1 | (c == null && 8), d[b++] = u && 8;
2113
+ d[b++] = f.compression & 255, d[b++] = f.compression >> 8;
2114
+ var dt = new Date(f.mtime == null ? Date.now() : f.mtime),
2115
+ y = dt.getFullYear() - 1980;
2116
+ if (y < 0 || y > 119) throw 'date not in range 1980-2099';
2117
+ wbytes(d, b, y << 25 | dt.getMonth() + 1 << 21 | dt.getDate() << 16 | dt.getHours() << 11 | dt.getMinutes() << 5 | dt.getSeconds() >>> 1), b += 4;
2118
+
2119
+ if (c != null) {
2120
+ wbytes(d, b, f.crc);
2121
+ wbytes(d, b + 4, c);
2122
+ wbytes(d, b + 8, f.size);
2123
+ }
2124
+
2125
+ wbytes(d, b + 12, fl);
2126
+ wbytes(d, b + 14, exl), b += 16;
2127
+
2128
+ if (ce != null) {
2129
+ wbytes(d, b, col);
2130
+ wbytes(d, b + 6, f.attrs);
2131
+ wbytes(d, b + 10, ce), b += 14;
2132
+ }
2133
+
2134
+ d.set(fn, b);
2135
+ b += fl;
2136
+
2137
+ if (exl) {
2138
+ for (var k in ex) {
2139
+ var exf = ex[k],
2140
+ l = exf.length;
2141
+ wbytes(d, b, +k);
2142
+ wbytes(d, b + 2, l);
2143
+ d.set(exf, b + 4), b += 4 + l;
2144
+ }
2145
+ }
2146
+
2147
+ if (col) d.set(co, b), b += col;
2148
+ return b;
2149
+ }; // write zip footer (end of central directory)
2150
+
2151
+
2152
+ var wzf = function wzf(o, b, c, d, e) {
2153
+ wbytes(o, b, 0x6054B50); // skip disk
2154
+
2155
+ wbytes(o, b + 8, c);
2156
+ wbytes(o, b + 10, c);
2157
+ wbytes(o, b + 12, d);
2158
+ wbytes(o, b + 16, e);
2159
+ };
2160
+ /**
2161
+ * A pass-through stream to keep data uncompressed in a ZIP archive.
2162
+ */
2163
+
2164
+
2165
+ var ZipPassThrough = /*#__PURE__*/function () {
2166
+ /**
2167
+ * Creates a pass-through stream that can be added to ZIP archives
2168
+ * @param filename The filename to associate with this data stream
2169
+ */
2170
+ function ZipPassThrough(filename) {
2171
+ this.filename = filename;
2172
+ this.c = crc();
2173
+ this.size = 0;
2174
+ this.compression = 0;
2175
+ }
2176
+ /**
2177
+ * Processes a chunk and pushes to the output stream. You can override this
2178
+ * method in a subclass for custom behavior, but by default this passes
2179
+ * the data through. You must call this.ondata(err, chunk, final) at some
2180
+ * point in this method.
2181
+ * @param chunk The chunk to process
2182
+ * @param final Whether this is the last chunk
2183
+ */
2184
+
2185
+
2186
+ ZipPassThrough.prototype.process = function (chunk, final) {
2187
+ this.ondata(null, chunk, final);
2188
+ };
2189
+ /**
2190
+ * Pushes a chunk to be added. If you are subclassing this with a custom
2191
+ * compression algorithm, note that you must push data from the source
2192
+ * file only, pre-compression.
2193
+ * @param chunk The chunk to push
2194
+ * @param final Whether this is the last chunk
2195
+ */
2196
+
2197
+
2198
+ ZipPassThrough.prototype.push = function (chunk, final) {
2199
+ if (!this.ondata) throw 'no callback - add to ZIP archive before pushing';
2200
+ this.c.p(chunk);
2201
+ this.size += chunk.length;
2202
+ if (final) this.crc = this.c.d();
2203
+ this.process(chunk, final || false);
2204
+ };
2205
+
2206
+ return ZipPassThrough;
2207
+ }();
2208
+
2209
+ _exports.ZipPassThrough = ZipPassThrough;
2210
+
2211
+ // I don't extend because TypeScript extension adds 1kB of runtime bloat
2212
+
2213
+ /**
2214
+ * Streaming DEFLATE compression for ZIP archives. Prefer using AsyncZipDeflate
2215
+ * for better performance
2216
+ */
2217
+ var ZipDeflate = /*#__PURE__*/function () {
2218
+ /**
2219
+ * Creates a DEFLATE stream that can be added to ZIP archives
2220
+ * @param filename The filename to associate with this data stream
2221
+ * @param opts The compression options
2222
+ */
2223
+ function ZipDeflate(filename, opts) {
2224
+ var _this_1 = this;
2225
+
2226
+ if (!opts) opts = {};
2227
+ ZipPassThrough.call(this, filename);
2228
+ this.d = new Deflate(opts, function (dat, final) {
2229
+ _this_1.ondata(null, dat, final);
2230
+ });
2231
+ this.compression = 8;
2232
+ this.flag = dbf(opts.level);
2233
+ }
2234
+
2235
+ ZipDeflate.prototype.process = function (chunk, final) {
2236
+ try {
2237
+ this.d.push(chunk, final);
2238
+ } catch (e) {
2239
+ this.ondata(e, null, final);
2240
+ }
2241
+ };
2242
+ /**
2243
+ * Pushes a chunk to be deflated
2244
+ * @param chunk The chunk to push
2245
+ * @param final Whether this is the last chunk
2246
+ */
2247
+
2248
+
2249
+ ZipDeflate.prototype.push = function (chunk, final) {
2250
+ ZipPassThrough.prototype.push.call(this, chunk, final);
2251
+ };
2252
+
2253
+ return ZipDeflate;
2254
+ }();
2255
+
2256
+ _exports.ZipDeflate = ZipDeflate;
2257
+
2258
+ /**
2259
+ * Asynchronous streaming DEFLATE compression for ZIP archives
2260
+ */
2261
+ var AsyncZipDeflate = /*#__PURE__*/function () {
2262
+ /**
2263
+ * Creates a DEFLATE stream that can be added to ZIP archives
2264
+ * @param filename The filename to associate with this data stream
2265
+ * @param opts The compression options
2266
+ */
2267
+ function AsyncZipDeflate(filename, opts) {
2268
+ var _this_1 = this;
2269
+
2270
+ if (!opts) opts = {};
2271
+ ZipPassThrough.call(this, filename);
2272
+ this.d = new AsyncDeflate(opts, function (err, dat, final) {
2273
+ _this_1.ondata(err, dat, final);
2274
+ });
2275
+ this.compression = 8;
2276
+ this.flag = dbf(opts.level);
2277
+ this.terminate = this.d.terminate;
2278
+ }
2279
+
2280
+ AsyncZipDeflate.prototype.process = function (chunk, final) {
2281
+ this.d.push(chunk, final);
2282
+ };
2283
+ /**
2284
+ * Pushes a chunk to be deflated
2285
+ * @param chunk The chunk to push
2286
+ * @param final Whether this is the last chunk
2287
+ */
2288
+
2289
+
2290
+ AsyncZipDeflate.prototype.push = function (chunk, final) {
2291
+ ZipPassThrough.prototype.push.call(this, chunk, final);
2292
+ };
2293
+
2294
+ return AsyncZipDeflate;
2295
+ }();
2296
+
2297
+ _exports.AsyncZipDeflate = AsyncZipDeflate;
2298
+
2299
+ // TODO: Better tree shaking
2300
+
2301
+ /**
2302
+ * A zippable archive to which files can incrementally be added
2303
+ */
2304
+ var Zip = /*#__PURE__*/function () {
2305
+ /**
2306
+ * Creates an empty ZIP archive to which files can be added
2307
+ * @param cb The callback to call whenever data for the generated ZIP archive
2308
+ * is available
2309
+ */
2310
+ function Zip(cb) {
2311
+ this.ondata = cb;
2312
+ this.u = [];
2313
+ this.d = 1;
2314
+ }
2315
+ /**
2316
+ * Adds a file to the ZIP archive
2317
+ * @param file The file stream to add
2318
+ */
2319
+
2320
+
2321
+ Zip.prototype.add = function (file) {
2322
+ var _this_1 = this;
2323
+
2324
+ if (this.d & 2) throw 'stream finished';
2325
+ var f = strToU8(file.filename),
2326
+ fl = f.length;
2327
+ var com = file.comment,
2328
+ o = com && strToU8(com);
2329
+ var u = fl != file.filename.length || o && com.length != o.length;
2330
+ var hl = fl + exfl(file.extra) + 30;
2331
+ if (fl > 65535) throw 'filename too long';
2332
+ var header = new u8(hl);
2333
+ wzh(header, 0, file, f, u);
2334
+ var chks = [header];
2335
+
2336
+ var pAll = function pAll() {
2337
+ for (var _i = 0, chks_1 = chks; _i < chks_1.length; _i++) {
2338
+ var chk = chks_1[_i];
2339
+
2340
+ _this_1.ondata(null, chk, false);
2341
+ }
2342
+
2343
+ chks = [];
2344
+ };
2345
+
2346
+ var tr = this.d;
2347
+ this.d = 0;
2348
+ var ind = this.u.length;
2349
+ var uf = mrg(file, {
2350
+ f: f,
2351
+ u: u,
2352
+ o: o,
2353
+ t: function t() {
2354
+ if (file.terminate) file.terminate();
2355
+ },
2356
+ r: function r() {
2357
+ pAll();
2358
+
2359
+ if (tr) {
2360
+ var nxt = _this_1.u[ind + 1];
2361
+ if (nxt) nxt.r();else _this_1.d = 1;
2362
+ }
2363
+
2364
+ tr = 1;
2365
+ }
2366
+ });
2367
+ var cl = 0;
2368
+
2369
+ file.ondata = function (err, dat, final) {
2370
+ if (err) {
2371
+ _this_1.ondata(err, dat, final);
2372
+
2373
+ _this_1.terminate();
2374
+ } else {
2375
+ cl += dat.length;
2376
+ chks.push(dat);
2377
+
2378
+ if (final) {
2379
+ var dd = new u8(16);
2380
+ wbytes(dd, 0, 0x8074B50);
2381
+ wbytes(dd, 4, file.crc);
2382
+ wbytes(dd, 8, cl);
2383
+ wbytes(dd, 12, file.size);
2384
+ chks.push(dd);
2385
+ uf.c = cl, uf.b = hl + cl + 16, uf.crc = file.crc, uf.size = file.size;
2386
+ if (tr) uf.r();
2387
+ tr = 1;
2388
+ } else if (tr) pAll();
2389
+ }
2390
+ };
2391
+
2392
+ this.u.push(uf);
2393
+ };
2394
+ /**
2395
+ * Ends the process of adding files and prepares to emit the final chunks.
2396
+ * This *must* be called after adding all desired files for the resulting
2397
+ * ZIP file to work properly.
2398
+ */
2399
+
2400
+
2401
+ Zip.prototype.end = function () {
2402
+ var _this_1 = this;
2403
+
2404
+ if (this.d & 2) {
2405
+ if (this.d & 1) throw 'stream finishing';
2406
+ throw 'stream finished';
2407
+ }
2408
+
2409
+ if (this.d) this.e();else this.u.push({
2410
+ r: function r() {
2411
+ if (!(_this_1.d & 1)) return;
2412
+
2413
+ _this_1.u.splice(-1, 1);
2414
+
2415
+ _this_1.e();
2416
+ },
2417
+ t: function t() {}
2418
+ });
2419
+ this.d = 3;
2420
+ };
2421
+
2422
+ Zip.prototype.e = function () {
2423
+ var bt = 0,
2424
+ l = 0,
2425
+ tl = 0;
2426
+
2427
+ for (var _i = 0, _a = this.u; _i < _a.length; _i++) {
2428
+ var f = _a[_i];
2429
+ tl += 46 + f.f.length + exfl(f.extra) + (f.o ? f.o.length : 0);
2430
+ }
2431
+
2432
+ var out = new u8(tl + 22);
2433
+
2434
+ for (var _b = 0, _c = this.u; _b < _c.length; _b++) {
2435
+ var f = _c[_b];
2436
+ wzh(out, bt, f, f.f, f.u, f.c, l, f.o);
2437
+ bt += 46 + f.f.length + exfl(f.extra) + (f.o ? f.o.length : 0), l += f.b;
2438
+ }
2439
+
2440
+ wzf(out, bt, this.u.length, tl, l);
2441
+ this.ondata(null, out, true);
2442
+ this.d = 2;
2443
+ };
2444
+ /**
2445
+ * A method to terminate any internal workers used by the stream. Subsequent
2446
+ * calls to add() will fail.
2447
+ */
2448
+
2449
+
2450
+ Zip.prototype.terminate = function () {
2451
+ for (var _i = 0, _a = this.u; _i < _a.length; _i++) {
2452
+ var f = _a[_i];
2453
+ f.t();
2454
+ }
2455
+
2456
+ this.d = 2;
2457
+ };
2458
+
2459
+ return Zip;
2460
+ }();
2461
+
2462
+ _exports.Zip = Zip;
2463
+
2464
+ function zip(data, opts, cb) {
2465
+ if (!cb) cb = opts, opts = {};
2466
+ if (typeof cb != 'function') throw 'no callback';
2467
+ var r = {};
2468
+ fltn(data, '', r, opts);
2469
+ var k = Object.keys(r);
2470
+ var lft = k.length,
2471
+ o = 0,
2472
+ tot = 0;
2473
+ var slft = lft,
2474
+ files = new Array(lft);
2475
+ var term = [];
2476
+
2477
+ var tAll = function tAll() {
2478
+ for (var i = 0; i < term.length; ++i) {
2479
+ term[i]();
2480
+ }
2481
+ };
2482
+
2483
+ var cbf = function cbf() {
2484
+ var out = new u8(tot + 22),
2485
+ oe = o,
2486
+ cdl = tot - o;
2487
+ tot = 0;
2488
+
2489
+ for (var i = 0; i < slft; ++i) {
2490
+ var f = files[i];
2491
+
2492
+ try {
2493
+ var l = f.c.length;
2494
+ wzh(out, tot, f, f.f, f.u, l);
2495
+ var badd = 30 + f.f.length + exfl(f.extra);
2496
+ var loc = tot + badd;
2497
+ out.set(f.c, loc);
2498
+ wzh(out, o, f, f.f, f.u, l, tot, f.m), o += 16 + badd + (f.m ? f.m.length : 0), tot = loc + l;
2499
+ } catch (e) {
2500
+ return cb(e, null);
2501
+ }
2502
+ }
2503
+
2504
+ wzf(out, o, files.length, cdl, oe);
2505
+ cb(null, out);
2506
+ };
2507
+
2508
+ if (!lft) cbf();
2509
+
2510
+ var _loop_1 = function _loop_1(i) {
2511
+ var fn = k[i];
2512
+ var _a = r[fn],
2513
+ file = _a[0],
2514
+ p = _a[1];
2515
+ var c = crc(),
2516
+ size = file.length;
2517
+ c.p(file);
2518
+ var f = strToU8(fn),
2519
+ s = f.length;
2520
+ var com = p.comment,
2521
+ m = com && strToU8(com),
2522
+ ms = m && m.length;
2523
+ var exl = exfl(p.extra);
2524
+ var compression = p.level == 0 ? 0 : 8;
2525
+
2526
+ var cbl = function cbl(e, d) {
2527
+ if (e) {
2528
+ tAll();
2529
+ cb(e, null);
2530
+ } else {
2531
+ var l = d.length;
2532
+ files[i] = mrg(p, {
2533
+ size: size,
2534
+ crc: c.d(),
2535
+ c: d,
2536
+ f: f,
2537
+ m: m,
2538
+ u: s != fn.length || m && com.length != ms,
2539
+ compression: compression
2540
+ });
2541
+ o += 30 + s + exl + l;
2542
+ tot += 76 + 2 * (s + exl) + (ms || 0) + l;
2543
+ if (! --lft) cbf();
2544
+ }
2545
+ };
2546
+
2547
+ if (s > 65535) cbl('filename too long', null);
2548
+ if (!compression) cbl(null, file);else if (size < 160000) {
2549
+ try {
2550
+ cbl(null, deflateSync(file, p));
2551
+ } catch (e) {
2552
+ cbl(e, null);
2553
+ }
2554
+ } else term.push(deflate(file, p, cbl));
2555
+ }; // Cannot use lft because it can decrease
2556
+
2557
+
2558
+ for (var i = 0; i < slft; ++i) {
2559
+ _loop_1(i);
2560
+ }
2561
+
2562
+ return tAll;
2563
+ }
2564
+ /**
2565
+ * Synchronously creates a ZIP file. Prefer using `zip` for better performance
2566
+ * with more than one file.
2567
+ * @param data The directory structure for the ZIP archive
2568
+ * @param opts The main options, merged with per-file options
2569
+ * @returns The generated ZIP archive
2570
+ */
2571
+
2572
+
2573
+ function zipSync(data, opts) {
2574
+ if (!opts) opts = {};
2575
+ var r = {};
2576
+ var files = [];
2577
+ fltn(data, '', r, opts);
2578
+ var o = 0;
2579
+ var tot = 0;
2580
+
2581
+ for (var fn in r) {
2582
+ var _a = r[fn],
2583
+ file = _a[0],
2584
+ p = _a[1];
2585
+ var compression = p.level == 0 ? 0 : 8;
2586
+ var f = strToU8(fn),
2587
+ s = f.length;
2588
+ var com = p.comment,
2589
+ m = com && strToU8(com),
2590
+ ms = m && m.length;
2591
+ var exl = exfl(p.extra);
2592
+ if (s > 65535) throw 'filename too long';
2593
+ var d = compression ? deflateSync(file, p) : file,
2594
+ l = d.length;
2595
+ var c = crc();
2596
+ c.p(file);
2597
+ files.push(mrg(p, {
2598
+ size: file.length,
2599
+ crc: c.d(),
2600
+ c: d,
2601
+ f: f,
2602
+ m: m,
2603
+ u: s != fn.length || m && com.length != ms,
2604
+ o: o,
2605
+ compression: compression
2606
+ }));
2607
+ o += 30 + s + exl + l;
2608
+ tot += 76 + 2 * (s + exl) + (ms || 0) + l;
2609
+ }
2610
+
2611
+ var out = new u8(tot + 22),
2612
+ oe = o,
2613
+ cdl = tot - o;
2614
+
2615
+ for (var i = 0; i < files.length; ++i) {
2616
+ var f = files[i];
2617
+ wzh(out, f.o, f, f.f, f.u, f.c.length);
2618
+ var badd = 30 + f.f.length + exfl(f.extra);
2619
+ out.set(f.c, f.o + badd);
2620
+ wzh(out, o, f, f.f, f.u, f.c.length, f.o, f.m), o += 16 + badd + (f.m ? f.m.length : 0);
2621
+ }
2622
+
2623
+ wzf(out, o, files.length, cdl, oe);
2624
+ return out;
2625
+ }
2626
+ /**
2627
+ * Streaming pass-through decompression for ZIP archives
2628
+ */
2629
+
2630
+
2631
+ var UnzipPassThrough = /*#__PURE__*/function () {
2632
+ function UnzipPassThrough() {}
2633
+
2634
+ UnzipPassThrough.prototype.push = function (data, final) {
2635
+ this.ondata(null, data, final);
2636
+ };
2637
+
2638
+ UnzipPassThrough.compression = 0;
2639
+ return UnzipPassThrough;
2640
+ }();
2641
+
2642
+ _exports.UnzipPassThrough = UnzipPassThrough;
2643
+
2644
+ /**
2645
+ * Streaming DEFLATE decompression for ZIP archives. Prefer AsyncZipInflate for
2646
+ * better performance.
2647
+ */
2648
+ var UnzipInflate = /*#__PURE__*/function () {
2649
+ /**
2650
+ * Creates a DEFLATE decompression that can be used in ZIP archives
2651
+ */
2652
+ function UnzipInflate() {
2653
+ var _this_1 = this;
2654
+
2655
+ this.i = new Inflate(function (dat, final) {
2656
+ _this_1.ondata(null, dat, final);
2657
+ });
2658
+ }
2659
+
2660
+ UnzipInflate.prototype.push = function (data, final) {
2661
+ try {
2662
+ this.i.push(data, final);
2663
+ } catch (e) {
2664
+ this.ondata(e, data, final);
2665
+ }
2666
+ };
2667
+
2668
+ UnzipInflate.compression = 8;
2669
+ return UnzipInflate;
2670
+ }();
2671
+
2672
+ _exports.UnzipInflate = UnzipInflate;
2673
+
2674
+ /**
2675
+ * Asynchronous streaming DEFLATE decompression for ZIP archives
2676
+ */
2677
+ var AsyncUnzipInflate = /*#__PURE__*/function () {
2678
+ /**
2679
+ * Creates a DEFLATE decompression that can be used in ZIP archives
2680
+ */
2681
+ function AsyncUnzipInflate(_, sz) {
2682
+ var _this_1 = this;
2683
+
2684
+ if (sz < 320000) {
2685
+ this.i = new Inflate(function (dat, final) {
2686
+ _this_1.ondata(null, dat, final);
2687
+ });
2688
+ } else {
2689
+ this.i = new AsyncInflate(function (err, dat, final) {
2690
+ _this_1.ondata(err, dat, final);
2691
+ });
2692
+ this.terminate = this.i.terminate;
2693
+ }
2694
+ }
2695
+
2696
+ AsyncUnzipInflate.prototype.push = function (data, final) {
2697
+ if (this.i.terminate) data = slc(data, 0);
2698
+ this.i.push(data, final);
2699
+ };
2700
+
2701
+ AsyncUnzipInflate.compression = 8;
2702
+ return AsyncUnzipInflate;
2703
+ }();
2704
+
2705
+ _exports.AsyncUnzipInflate = AsyncUnzipInflate;
2706
+
2707
+ /**
2708
+ * A ZIP archive decompression stream that emits files as they are discovered
2709
+ */
2710
+ var Unzip = /*#__PURE__*/function () {
2711
+ /**
2712
+ * Creates a ZIP decompression stream
2713
+ * @param cb The callback to call whenever a file in the ZIP archive is found
2714
+ */
2715
+ function Unzip(cb) {
2716
+ this.onfile = cb;
2717
+ this.k = [];
2718
+ this.o = {
2719
+ 0: UnzipPassThrough
2720
+ };
2721
+ this.p = et;
2722
+ }
2723
+ /**
2724
+ * Pushes a chunk to be unzipped
2725
+ * @param chunk The chunk to push
2726
+ * @param final Whether this is the last chunk
2727
+ */
2728
+
2729
+
2730
+ Unzip.prototype.push = function (chunk, final) {
2731
+ var _this_1 = this;
2732
+
2733
+ if (!this.onfile) throw 'no callback';
2734
+ if (!this.p) throw 'stream finished';
2735
+
2736
+ if (this.c > 0) {
2737
+ var len = Math.min(this.c, chunk.length);
2738
+ var toAdd = chunk.subarray(0, len);
2739
+ this.c -= len;
2740
+ if (this.d) this.d.push(toAdd, !this.c);else this.k[0].push(toAdd);
2741
+ chunk = chunk.subarray(len);
2742
+ if (chunk.length) return this.push(chunk, final);
2743
+ } else {
2744
+ var f = 0,
2745
+ i = 0,
2746
+ is = void 0,
2747
+ buf = void 0;
2748
+ if (!this.p.length) buf = chunk;else if (!chunk.length) buf = this.p;else {
2749
+ buf = new u8(this.p.length + chunk.length);
2750
+ buf.set(this.p), buf.set(chunk, this.p.length);
2751
+ }
2752
+ var l = buf.length,
2753
+ oc = this.c,
2754
+ add = oc && this.d;
2755
+
2756
+ var _loop_2 = function _loop_2() {
2757
+ var _a;
2758
+
2759
+ var sig = b4(buf, i);
2760
+
2761
+ if (sig == 0x4034B50) {
2762
+ f = 1, is = i;
2763
+ this_1.d = null;
2764
+ this_1.c = 0;
2765
+ var bf = b2(buf, i + 6),
2766
+ cmp_1 = b2(buf, i + 8),
2767
+ u = bf & 2048,
2768
+ dd = bf & 8,
2769
+ fnl = b2(buf, i + 26),
2770
+ es = b2(buf, i + 28);
2771
+
2772
+ if (l > i + 30 + fnl + es) {
2773
+ var chks_2 = [];
2774
+ this_1.k.unshift(chks_2);
2775
+ f = 2;
2776
+ var sc_1 = b4(buf, i + 18),
2777
+ su_1 = b4(buf, i + 22);
2778
+ var fn_1 = strFromU8(buf.subarray(i + 30, i += 30 + fnl), !u);
2779
+
2780
+ if (sc_1 == 4294967295) {
2781
+ _a = dd ? [-2] : z64e(buf, i), sc_1 = _a[0], su_1 = _a[1];
2782
+ } else if (dd) sc_1 = -1;
2783
+
2784
+ i += es;
2785
+ this_1.c = sc_1;
2786
+ var d_1;
2787
+ var file_1 = {
2788
+ name: fn_1,
2789
+ compression: cmp_1,
2790
+ start: function start() {
2791
+ if (!file_1.ondata) throw 'no callback';
2792
+ if (!sc_1) file_1.ondata(null, et, true);else {
2793
+ var ctr = _this_1.o[cmp_1];
2794
+ if (!ctr) throw 'unknown compression type ' + cmp_1;
2795
+ d_1 = sc_1 < 0 ? new ctr(fn_1) : new ctr(fn_1, sc_1, su_1);
2796
+
2797
+ d_1.ondata = function (err, dat, final) {
2798
+ file_1.ondata(err, dat, final);
2799
+ };
2800
+
2801
+ for (var _i = 0, chks_3 = chks_2; _i < chks_3.length; _i++) {
2802
+ var dat = chks_3[_i];
2803
+ d_1.push(dat, false);
2804
+ }
2805
+
2806
+ if (_this_1.k[0] == chks_2 && _this_1.c) _this_1.d = d_1;else d_1.push(et, true);
2807
+ }
2808
+ },
2809
+ terminate: function terminate() {
2810
+ if (d_1 && d_1.terminate) d_1.terminate();
2811
+ }
2812
+ };
2813
+ if (sc_1 >= 0) file_1.size = sc_1, file_1.originalSize = su_1;
2814
+ this_1.onfile(file_1);
2815
+ }
2816
+
2817
+ return "break";
2818
+ } else if (oc) {
2819
+ if (sig == 0x8074B50) {
2820
+ is = i += 12 + (oc == -2 && 8), f = 3, this_1.c = 0;
2821
+ return "break";
2822
+ } else if (sig == 0x2014B50) {
2823
+ is = i -= 4, f = 3, this_1.c = 0;
2824
+ return "break";
2825
+ }
2826
+ }
2827
+ };
2828
+
2829
+ var this_1 = this;
2830
+
2831
+ for (; i < l - 4; ++i) {
2832
+ var state_1 = _loop_2();
2833
+
2834
+ if (state_1 === "break") break;
2835
+ }
2836
+
2837
+ this.p = et;
2838
+
2839
+ if (oc < 0) {
2840
+ var dat = f ? buf.subarray(0, is - 12 - (oc == -2 && 8) - (b4(buf, is - 16) == 0x8074B50 && 4)) : buf.subarray(0, i);
2841
+ if (add) add.push(dat, !!f);else this.k[+(f == 2)].push(dat);
2842
+ }
2843
+
2844
+ if (f & 2) return this.push(buf.subarray(i), final);
2845
+ this.p = buf.subarray(i);
2846
+ }
2847
+
2848
+ if (final) {
2849
+ if (this.c) throw 'invalid zip file';
2850
+ this.p = null;
2851
+ }
2852
+ };
2853
+ /**
2854
+ * Registers a decoder with the stream, allowing for files compressed with
2855
+ * the compression type provided to be expanded correctly
2856
+ * @param decoder The decoder constructor
2857
+ */
2858
+
2859
+
2860
+ Unzip.prototype.register = function (decoder) {
2861
+ this.o[decoder.compression] = decoder;
2862
+ };
2863
+
2864
+ return Unzip;
2865
+ }();
2866
+
2867
+ _exports.Unzip = Unzip;
2868
+
2869
+ /**
2870
+ * Asynchronously decompresses a ZIP archive
2871
+ * @param data The raw compressed ZIP file
2872
+ * @param cb The callback to call with the decompressed files
2873
+ * @returns A function that can be used to immediately terminate the unzipping
2874
+ */
2875
+ function unzip(data, cb) {
2876
+ if (typeof cb != 'function') throw 'no callback';
2877
+ var term = [];
2878
+
2879
+ var tAll = function tAll() {
2880
+ for (var i = 0; i < term.length; ++i) {
2881
+ term[i]();
2882
+ }
2883
+ };
2884
+
2885
+ var files = {};
2886
+ var e = data.length - 22;
2887
+
2888
+ for (; b4(data, e) != 0x6054B50; --e) {
2889
+ if (!e || data.length - e > 65558) {
2890
+ cb('invalid zip file', null);
2891
+ return;
2892
+ }
2893
+ }
2894
+
2895
+ ;
2896
+ var lft = b2(data, e + 8);
2897
+ if (!lft) cb(null, {});
2898
+ var c = lft;
2899
+ var o = b4(data, e + 16);
2900
+ var z = o == 4294967295;
2901
+
2902
+ if (z) {
2903
+ e = b4(data, e - 12);
2904
+
2905
+ if (b4(data, e) != 0x6064B50) {
2906
+ cb('invalid zip file', null);
2907
+ return;
2908
+ }
2909
+
2910
+ c = lft = b4(data, e + 32);
2911
+ o = b4(data, e + 48);
2912
+ }
2913
+
2914
+ var _loop_3 = function _loop_3(i) {
2915
+ var _a = zh(data, o, z),
2916
+ c_1 = _a[0],
2917
+ sc = _a[1],
2918
+ su = _a[2],
2919
+ fn = _a[3],
2920
+ no = _a[4],
2921
+ off = _a[5],
2922
+ b = slzh(data, off);
2923
+
2924
+ o = no;
2925
+
2926
+ var cbl = function cbl(e, d) {
2927
+ if (e) {
2928
+ tAll();
2929
+ cb(e, null);
2930
+ } else {
2931
+ files[fn] = d;
2932
+ if (! --lft) cb(null, files);
2933
+ }
2934
+ };
2935
+
2936
+ if (!c_1) cbl(null, slc(data, b, b + sc));else if (c_1 == 8) {
2937
+ var infl = data.subarray(b, b + sc);
2938
+
2939
+ if (sc < 320000) {
2940
+ try {
2941
+ cbl(null, inflateSync(infl, new u8(su)));
2942
+ } catch (e) {
2943
+ cbl(e, null);
2944
+ }
2945
+ } else term.push(inflate(infl, {
2946
+ size: su
2947
+ }, cbl));
2948
+ } else cbl('unknown compression type ' + c_1, null);
2949
+ };
2950
+
2951
+ for (var i = 0; i < c; ++i) {
2952
+ _loop_3(i);
2953
+ }
2954
+
2955
+ return tAll;
2956
+ }
2957
+ /**
2958
+ * Synchronously decompresses a ZIP archive. Prefer using `unzip` for better
2959
+ * performance with more than one file.
2960
+ * @param data The raw compressed ZIP file
2961
+ * @returns The decompressed files
2962
+ */
2963
+
2964
+
2965
+ function unzipSync(data) {
2966
+ var files = {};
2967
+ var e = data.length - 22;
2968
+
2969
+ for (; b4(data, e) != 0x6054B50; --e) {
2970
+ if (!e || data.length - e > 65558) throw 'invalid zip file';
2971
+ }
2972
+
2973
+ ;
2974
+ var c = b2(data, e + 8);
2975
+ if (!c) return {};
2976
+ var o = b4(data, e + 16);
2977
+ var z = o == 4294967295;
2978
+
2979
+ if (z) {
2980
+ e = b4(data, e - 12);
2981
+ if (b4(data, e) != 0x6064B50) throw 'invalid zip file';
2982
+ c = b4(data, e + 32);
2983
+ o = b4(data, e + 48);
2984
+ }
2985
+
2986
+ for (var i = 0; i < c; ++i) {
2987
+ var _a = zh(data, o, z),
2988
+ c_2 = _a[0],
2989
+ sc = _a[1],
2990
+ su = _a[2],
2991
+ fn = _a[3],
2992
+ no = _a[4],
2993
+ off = _a[5],
2994
+ b = slzh(data, off);
2995
+
2996
+ o = no;
2997
+ if (!c_2) files[fn] = slc(data, b, b + sc);else if (c_2 == 8) files[fn] = inflateSync(data.subarray(b, b + sc), new u8(su));else throw 'unknown compression type ' + c_2;
2998
+ }
2999
+
3000
+ return files;
3001
+ }
3002
+ });