@woosh/meep-engine 3.64.1 → 3.65.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +85 -0
- package/build/bundle-worker-image-decoder.js +1 -1
- package/build/bundle-worker-terrain.js +1 -1
- package/package.json +1 -1
- package/src/core/binary/BinaryBuffer.d.ts +5 -0
- package/src/core/binary/BinaryBuffer.d.ts.map +1 -1
- package/src/core/binary/BinaryBuffer.js +39 -5
- package/src/core/geom/3d/topology/struct/binary/io/bt_boundary_loop.d.ts +65 -6
- package/src/core/geom/3d/topology/struct/binary/io/bt_boundary_loop.d.ts.map +1 -1
- package/src/core/geom/3d/topology/struct/binary/io/bt_boundary_loop.js +451 -101
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_close_boundary_holes.d.ts +4 -2
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_close_boundary_holes.d.ts.map +1 -1
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_close_boundary_holes.js +4 -2
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_fill_small_holes.d.ts +8 -1
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_fill_small_holes.d.ts.map +1 -1
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_fill_small_holes.js +45 -10
- package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_face_find_path_polyanya.d.ts.map +1 -1
- package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_face_find_path_polyanya.js +237 -119
- package/src/engine/graphics/ecs/grass/GrassSpecies.d.ts +143 -0
- package/src/engine/graphics/ecs/grass/GrassSpecies.d.ts.map +1 -0
- package/src/engine/graphics/ecs/grass/GrassSpecies.js +189 -0
- package/src/engine/graphics/ecs/grass/GrassSurface.d.ts +25 -0
- package/src/engine/graphics/ecs/grass/GrassSurface.d.ts.map +1 -0
- package/src/engine/graphics/ecs/grass/GrassSurface.js +32 -0
- package/src/engine/graphics/ecs/grass/GroundCover.d.ts +68 -0
- package/src/engine/graphics/ecs/grass/GroundCover.d.ts.map +1 -0
- package/src/engine/graphics/ecs/grass/GroundCover.js +85 -0
- package/src/engine/graphics3/GrassSurfaceSystem.d.ts +153 -0
- package/src/engine/graphics3/GrassSurfaceSystem.d.ts.map +1 -0
- package/src/engine/graphics3/GrassSurfaceSystem.js +1076 -0
- package/src/engine/graphics3/GroundCoverSystem.d.ts +33 -0
- package/src/engine/graphics3/GroundCoverSystem.d.ts.map +1 -0
- package/src/engine/graphics3/GroundCoverSystem.js +58 -0
- package/src/engine/network/NetworkSession.d.ts.map +1 -1
- package/src/engine/network/NetworkSession.js +372 -110
- package/src/engine/network/orchestrator/NetworkPeer.d.ts.map +1 -1
- package/src/engine/network/orchestrator/NetworkPeer.js +6 -1
- package/src/engine/network/orchestrator/ServerAuthoritativeClient.d.ts.map +1 -1
- package/src/engine/network/orchestrator/ServerAuthoritativeClient.js +9 -2
- package/src/engine/network/orchestrator/ServerAuthoritativeServer.d.ts.map +1 -1
- package/src/engine/network/orchestrator/ServerAuthoritativeServer.js +325 -140
- package/src/engine/network/sim/SimActionExecutor.d.ts +4 -1
- package/src/engine/network/sim/SimActionExecutor.d.ts.map +1 -1
- package/src/engine/network/sim/SimActionExecutor.js +65 -9
- package/src/engine/network/state/PredictionHistory.d.ts.map +1 -1
- package/src/engine/network/state/PredictionHistory.js +6 -1
- package/src/engine/network/time/AdaptiveRenderDelay.d.ts +25 -14
- package/src/engine/network/time/AdaptiveRenderDelay.d.ts.map +1 -1
- package/src/engine/network/time/AdaptiveRenderDelay.js +38 -20
- package/src/engine/network/time/RenderPlayout.d.ts +23 -3
- package/src/engine/network/time/RenderPlayout.d.ts.map +1 -1
- package/src/engine/network/time/RenderPlayout.js +40 -4
- package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
- package/src/engine/physics/fluid/obstacle/chunk_fluid_obstacle_record.d.ts +5 -1
- package/src/engine/physics/fluid/obstacle/chunk_fluid_obstacle_record.d.ts.map +1 -1
- package/src/engine/physics/fluid/obstacle/chunk_fluid_obstacle_record.js +27 -1
- package/src/shade/device/shader/ShaderModuleCompiler.d.ts +2 -0
- package/src/shade/device/shader/ShaderModuleCompiler.d.ts.map +1 -1
- package/src/shade/device/shader/ShaderModuleCompiler.js +25 -2
- package/src/shade/playground/grass_surfaces/index.html +75 -0
- package/src/shade/playground/grass_surfaces/main.d.ts +2 -0
- package/src/shade/playground/grass_surfaces/main.d.ts.map +1 -0
- package/src/shade/playground/grass_surfaces/main.js +593 -0
- package/src/shade/playground/grass_surfaces/read_grass_surfaces.d.ts +62 -0
- package/src/shade/playground/grass_surfaces/read_grass_surfaces.d.ts.map +1 -0
- package/src/shade/playground/grass_surfaces/read_grass_surfaces.js +188 -0
- package/src/shade/playground/probe_clipmap_box/README.md +5 -1
- package/src/shade/playground/probe_clipmap_box/index.html +12 -0
- package/src/shade/playground/probe_clipmap_box/main.d.ts.map +1 -1
- package/src/shade/playground/probe_clipmap_box/main.js +15 -0
- package/src/shade/playground/probe_clipmap_box/scene.d.ts +8 -1
- package/src/shade/playground/probe_clipmap_box/scene.d.ts.map +1 -1
- package/src/shade/playground/probe_clipmap_box/scene.js +74 -6
- package/src/shade/renderer/Renderer.d.ts.map +1 -1
- package/src/shade/renderer/Renderer.js +47 -43
- package/src/shade/renderer/extension/ViewTextures.d.ts +12 -5
- package/src/shade/renderer/extension/ViewTextures.d.ts.map +1 -1
- package/src/shade/renderer/extension/ViewTextures.js +19 -5
- package/src/shade/renderer/fluid/GPUFluidCascadeStack.d.ts +3 -1
- package/src/shade/renderer/fluid/GPUFluidCascadeStack.d.ts.map +1 -1
- package/src/shade/renderer/fluid/GPUFluidCascadeStack.js +6 -1
- package/src/shade/renderer/fluid/forcing/GPUFluidForcing.d.ts +7 -0
- package/src/shade/renderer/fluid/forcing/GPUFluidForcing.d.ts.map +1 -1
- package/src/shade/renderer/fluid/forcing/GPUFluidForcing.js +10 -0
- package/src/shade/renderer/geometry/sdf/GPUGeometrySDFManager.d.ts +7 -1
- package/src/shade/renderer/geometry/sdf/GPUGeometrySDFManager.d.ts.map +1 -1
- package/src/shade/renderer/geometry/sdf/GPUGeometrySDFManager.js +46 -15
- package/src/shade/renderer/geometry/sdf/bundle/ModelCacheBundle.d.ts +3 -2
- package/src/shade/renderer/geometry/sdf/bundle/ModelCacheBundle.d.ts.map +1 -1
- package/src/shade/renderer/geometry/sdf/bundle/ModelCacheBundle.js +3 -2
- package/src/shade/renderer/geometry/sdf/bundle/model_cache_bundle_sort_morton.d.ts +22 -0
- package/src/shade/renderer/geometry/sdf/bundle/model_cache_bundle_sort_morton.d.ts.map +1 -0
- package/src/shade/renderer/geometry/sdf/bundle/model_cache_bundle_sort_morton.js +247 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/GPUProbeClipmapGI.d.ts +50 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/GPUProbeClipmapGI.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/GPUProbeClipmapGI.js +101 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/ProbeClipmapSettings.d.ts +2 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/ProbeClipmapSettings.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/ProbeClipmapSettings.js +2 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/GPUBrickClipmap.d.ts +8 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/GPUBrickClipmap.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/GPUBrickClipmap.js +12 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.d.ts +12 -6
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.js +35 -29
- package/src/shade/renderer/global_illumination/probe_clipmap/debug/graph_probe_clipmap_debug_brick_clipmap.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/debug/graph_probe_clipmap_debug_brick_clipmap.js +4 -2
- package/src/shade/renderer/global_illumination/probe_clipmap/debug/graph_probe_clipmap_debug_brick_material.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/debug/graph_probe_clipmap_debug_brick_material.js +6 -4
- package/src/shade/renderer/global_illumination/probe_clipmap/material/GPUBrickMaterial.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/material/GPUBrickMaterial.js +2 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/material/chunk_brick_material.d.ts +6 -5
- package/src/shade/renderer/global_illumination/probe_clipmap/material/chunk_brick_material.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/material/chunk_brick_material.js +15 -14
- package/src/shade/renderer/global_illumination/probe_clipmap/material/shader_brick_material_gather.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/material/shader_brick_material_gather.js +4 -2
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/GPUProbeClipmap.d.ts +19 -2
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/GPUProbeClipmap.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/GPUProbeClipmap.js +128 -10
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/PROBE_CLIPMAP.d.ts +19 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/PROBE_CLIPMAP.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/PROBE_CLIPMAP.js +27 -2
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/ProbeClipmapScreenWants.d.ts +19 -11
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/ProbeClipmapScreenWants.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/ProbeClipmapScreenWants.js +35 -11
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap.js +3 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_box_cages.d.ts +40 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_box_cages.d.ts.map +1 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_box_cages.js +174 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_hit_material.d.ts +4 -4
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_hit_material.js +10 -10
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_parallax.d.ts +31 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_parallax.d.ts.map +1 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_parallax.js +54 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_sample_radiance.d.ts +8 -4
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_sample_radiance.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_sample_radiance.js +10 -21
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_want.d.ts +7 -2
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_want.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_want.js +33 -29
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/graph_probe_clipmap_want_meshlets.d.ts +28 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/graph_probe_clipmap_want_meshlets.d.ts.map +1 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/graph_probe_clipmap_want_meshlets.js +138 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_due.d.ts +13 -9
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_due.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_due.js +18 -11
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_light.js +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_relocate.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_relocate.js +4 -2
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_retire.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_retire.js +2 -3
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_schedule.d.ts +5 -3
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_schedule.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_schedule.js +15 -30
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_shade.js +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_trace.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_trace.js +4 -2
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_want.d.ts +11 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_want.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_want.js +29 -2
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_want_late.d.ts +40 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_want_late.d.ts.map +1 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_want_late.js +126 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_want_meshlets.d.ts +36 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_want_meshlets.d.ts.map +1 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_want_meshlets.js +221 -0
- package/src/shade/renderer/gpu_primitive/age_eviction/chunk_age_eviction.d.ts +40 -0
- package/src/shade/renderer/gpu_primitive/age_eviction/chunk_age_eviction.d.ts.map +1 -0
- package/src/shade/renderer/gpu_primitive/age_eviction/chunk_age_eviction.js +86 -0
- package/src/shade/renderer/grass/blade/GPUGrassBlades.d.ts +135 -0
- package/src/shade/renderer/grass/blade/GPUGrassBlades.d.ts.map +1 -0
- package/src/shade/renderer/grass/blade/GPUGrassBlades.js +676 -0
- package/src/shade/renderer/grass/blade/GRASS_BLADE.d.ts +145 -0
- package/src/shade/renderer/grass/blade/GRASS_BLADE.d.ts.map +1 -0
- package/src/shade/renderer/grass/blade/GRASS_BLADE.js +179 -0
- package/src/shade/renderer/grass/blade/chunk_grass_blade.d.ts +63 -0
- package/src/shade/renderer/grass/blade/chunk_grass_blade.d.ts.map +1 -0
- package/src/shade/renderer/grass/blade/chunk_grass_blade.js +244 -0
- package/src/shade/renderer/grass/blade/chunk_grass_blade_wind.d.ts +58 -0
- package/src/shade/renderer/grass/blade/chunk_grass_blade_wind.d.ts.map +1 -0
- package/src/shade/renderer/grass/blade/chunk_grass_blade_wind.js +174 -0
- package/src/shade/renderer/grass/blade/grass_blade_id_draw.d.ts +25 -0
- package/src/shade/renderer/grass/blade/grass_blade_id_draw.d.ts.map +1 -0
- package/src/shade/renderer/grass/blade/grass_blade_id_draw.js +133 -0
- package/src/shade/renderer/grass/blade/grass_blade_mechanics.d.ts +80 -0
- package/src/shade/renderer/grass/blade/grass_blade_mechanics.d.ts.map +1 -0
- package/src/shade/renderer/grass/blade/grass_blade_mechanics.js +92 -0
- package/src/shade/renderer/grass/blade/grass_blade_resolve.d.ts +29 -0
- package/src/shade/renderer/grass/blade/grass_blade_resolve.d.ts.map +1 -0
- package/src/shade/renderer/grass/blade/grass_blade_resolve.js +175 -0
- package/src/shade/renderer/grass/blade/shader_grass_blade_draw_args.d.ts +14 -0
- package/src/shade/renderer/grass/blade/shader_grass_blade_draw_args.d.ts.map +1 -0
- package/src/shade/renderer/grass/blade/shader_grass_blade_draw_args.js +45 -0
- package/src/shade/renderer/grass/blade/shader_grass_blade_expand.d.ts +61 -0
- package/src/shade/renderer/grass/blade/shader_grass_blade_expand.d.ts.map +1 -0
- package/src/shade/renderer/grass/blade/shader_grass_blade_expand.js +340 -0
- package/src/shade/renderer/grass/blade/shader_grass_cell_count.d.ts +46 -0
- package/src/shade/renderer/grass/blade/shader_grass_cell_count.d.ts.map +1 -0
- package/src/shade/renderer/grass/blade/shader_grass_cell_count.js +280 -0
- package/src/shade/renderer/grass/population/chunk_grass_population.d.ts +60 -0
- package/src/shade/renderer/grass/population/chunk_grass_population.d.ts.map +1 -0
- package/src/shade/renderer/grass/population/chunk_grass_population.js +171 -0
- package/src/shade/renderer/grass/press/GPUGrassPress.d.ts +99 -0
- package/src/shade/renderer/grass/press/GPUGrassPress.d.ts.map +1 -0
- package/src/shade/renderer/grass/press/GPUGrassPress.js +436 -0
- package/src/shade/renderer/grass/press/GRASS_PRESS.d.ts +179 -0
- package/src/shade/renderer/grass/press/GRASS_PRESS.d.ts.map +1 -0
- package/src/shade/renderer/grass/press/GRASS_PRESS.js +217 -0
- package/src/shade/renderer/grass/press/chunk_grass_press.d.ts +65 -0
- package/src/shade/renderer/grass/press/chunk_grass_press.d.ts.map +1 -0
- package/src/shade/renderer/grass/press/chunk_grass_press.js +296 -0
- package/src/shade/renderer/grass/press/shader_grass_press_mark.d.ts +31 -0
- package/src/shade/renderer/grass/press/shader_grass_press_mark.d.ts.map +1 -0
- package/src/shade/renderer/grass/press/shader_grass_press_mark.js +169 -0
- package/src/shade/renderer/grass/press/shader_grass_press_stamp.d.ts +27 -0
- package/src/shade/renderer/grass/press/shader_grass_press_stamp.d.ts.map +1 -0
- package/src/shade/renderer/grass/press/shader_grass_press_stamp.js +183 -0
- package/src/shade/renderer/grass/surface/GPUGrassSurfaces.d.ts +193 -0
- package/src/shade/renderer/grass/surface/GPUGrassSurfaces.d.ts.map +1 -0
- package/src/shade/renderer/grass/surface/GPUGrassSurfaces.js +1253 -0
- package/src/shade/renderer/grass/surface/GRASS_SURFACE.d.ts +211 -0
- package/src/shade/renderer/grass/surface/GRASS_SURFACE.d.ts.map +1 -0
- package/src/shade/renderer/grass/surface/GRASS_SURFACE.js +241 -0
- package/src/shade/renderer/grass/surface/GRASS_SURFACE_VIEW.d.ts +82 -0
- package/src/shade/renderer/grass/surface/GRASS_SURFACE_VIEW.d.ts.map +1 -0
- package/src/shade/renderer/grass/surface/GRASS_SURFACE_VIEW.js +111 -0
- package/src/shade/renderer/grass/surface/chunk_grass_column_cross.d.ts +39 -0
- package/src/shade/renderer/grass/surface/chunk_grass_column_cross.d.ts.map +1 -0
- package/src/shade/renderer/grass/surface/chunk_grass_column_cross.js +85 -0
- package/src/shade/renderer/grass/surface/chunk_grass_directory.d.ts +29 -0
- package/src/shade/renderer/grass/surface/chunk_grass_directory.d.ts.map +1 -0
- package/src/shade/renderer/grass/surface/chunk_grass_directory.js +112 -0
- package/src/shade/renderer/grass/surface/chunk_grass_slot.d.ts +27 -0
- package/src/shade/renderer/grass/surface/chunk_grass_slot.d.ts.map +1 -0
- package/src/shade/renderer/grass/surface/chunk_grass_slot.js +50 -0
- package/src/shade/renderer/grass/surface/chunk_grass_surface_frame.d.ts +21 -0
- package/src/shade/renderer/grass/surface/chunk_grass_surface_frame.d.ts.map +1 -0
- package/src/shade/renderer/grass/surface/chunk_grass_surface_frame.js +41 -0
- package/src/shade/renderer/grass/surface/chunk_grass_surface_window.d.ts +32 -0
- package/src/shade/renderer/grass/surface/chunk_grass_surface_window.d.ts.map +1 -0
- package/src/shade/renderer/grass/surface/chunk_grass_surface_window.js +136 -0
- package/src/shade/renderer/grass/surface/chunk_grass_surfel.d.ts +37 -0
- package/src/shade/renderer/grass/surface/chunk_grass_surfel.d.ts.map +1 -0
- package/src/shade/renderer/grass/surface/chunk_grass_surfel.js +85 -0
- package/src/shade/renderer/grass/surface/chunk_grass_tile.d.ts +25 -0
- package/src/shade/renderer/grass/surface/chunk_grass_tile.d.ts.map +1 -0
- package/src/shade/renderer/grass/surface/chunk_grass_tile.js +52 -0
- package/src/shade/renderer/grass/surface/shader_grass_directory_fill.d.ts +23 -0
- package/src/shade/renderer/grass/surface/shader_grass_directory_fill.d.ts.map +1 -0
- package/src/shade/renderer/grass/surface/shader_grass_directory_fill.js +87 -0
- package/src/shade/renderer/grass/surface/shader_grass_surface_bake.d.ts +43 -0
- package/src/shade/renderer/grass/surface/shader_grass_surface_bake.d.ts.map +1 -0
- package/src/shade/renderer/grass/surface/shader_grass_surface_bake.js +265 -0
- package/src/shade/renderer/grass/surface/shader_grass_surface_bake_command.d.ts +13 -0
- package/src/shade/renderer/grass/surface/shader_grass_surface_bake_command.d.ts.map +1 -0
- package/src/shade/renderer/grass/surface/shader_grass_surface_bake_command.js +49 -0
- package/src/shade/renderer/grass/surface/shader_grass_surface_invalidate.d.ts +62 -0
- package/src/shade/renderer/grass/surface/shader_grass_surface_invalidate.d.ts.map +1 -0
- package/src/shade/renderer/grass/surface/shader_grass_surface_invalidate.js +162 -0
- package/src/shade/renderer/grass/surface/shader_grass_surface_retire.d.ts +40 -0
- package/src/shade/renderer/grass/surface/shader_grass_surface_retire.d.ts.map +1 -0
- package/src/shade/renderer/grass/surface/shader_grass_surface_retire.js +155 -0
- package/src/shade/renderer/grass/surface/shader_grass_surface_schedule.d.ts +19 -0
- package/src/shade/renderer/grass/surface/shader_grass_surface_schedule.d.ts.map +1 -0
- package/src/shade/renderer/grass/surface/shader_grass_surface_schedule.js +58 -0
- package/src/shade/renderer/grass/surface/shader_grass_surface_want.d.ts +30 -0
- package/src/shade/renderer/grass/surface/shader_grass_surface_want.d.ts.map +1 -0
- package/src/shade/renderer/grass/surface/shader_grass_surface_want.js +251 -0
- package/src/shade/renderer/grass/surface/shader_grass_surface_window_count.d.ts +21 -0
- package/src/shade/renderer/grass/surface/shader_grass_surface_window_count.d.ts.map +1 -0
- package/src/shade/renderer/grass/surface/shader_grass_surface_window_count.js +75 -0
- package/src/shade/renderer/postprocess/velocity/graph_add_per_object_velocity.d.ts.map +1 -1
- package/src/shade/renderer/postprocess/velocity/graph_add_per_object_velocity.js +4 -23
- package/src/shade/renderer/postprocess/velocity/view_velocity_matrices.d.ts +12 -0
- package/src/shade/renderer/postprocess/velocity/view_velocity_matrices.d.ts.map +1 -0
- package/src/shade/renderer/postprocess/velocity/view_velocity_matrices.js +29 -0
- package/src/shade/renderer/rasterize/native/avboit/graph_rasterize_meshes_transparent_avboit.d.ts.map +1 -1
- package/src/shade/renderer/rasterize/native/avboit/graph_rasterize_meshes_transparent_avboit.js +22 -0
- package/src/shade/renderer/scene/GPUSceneContext.d.ts.map +1 -1
- package/src/shade/renderer/scene/GPUSceneContext.js +3 -0
- package/src/shade/renderer/scene/GRASS_SURFACE_PARAMS_STRUCT.d.ts +27 -0
- package/src/shade/renderer/scene/GRASS_SURFACE_PARAMS_STRUCT.d.ts.map +1 -0
- package/src/shade/renderer/scene/GRASS_SURFACE_PARAMS_STRUCT.js +38 -0
- package/src/shade/renderer/scene/MESH_GROUND_COVER_STRUCT.d.ts +28 -0
- package/src/shade/renderer/scene/MESH_GROUND_COVER_STRUCT.d.ts.map +1 -0
- package/src/shade/renderer/scene/MESH_GROUND_COVER_STRUCT.js +58 -0
- package/src/shade/renderer/scene/SCENE_DATABASE_SPEC.d.ts.map +1 -1
- package/src/shade/renderer/scene/SCENE_DATABASE_SPEC.js +8 -0
- package/src/shade/renderer/shader/chunk/geometry/ray/chunk_ray_query_nearest_among.d.ts +37 -0
- package/src/shade/renderer/shader/chunk/geometry/ray/chunk_ray_query_nearest_among.d.ts.map +1 -0
- package/src/shade/renderer/shader/chunk/geometry/ray/chunk_ray_query_nearest_among.js +148 -0
- package/src/shade/renderer/shader/chunk/sdf/chunk_shape_record_line_span.d.ts +20 -0
- package/src/shade/renderer/shader/chunk/sdf/chunk_shape_record_line_span.d.ts.map +1 -0
- package/src/shade/renderer/shader/chunk/sdf/chunk_shape_record_line_span.js +169 -0
- package/src/shade/renderer/texture/atlas/chunk_tile_atlas_slot_origin.d.ts +18 -0
- package/src/shade/renderer/texture/atlas/chunk_tile_atlas_slot_origin.d.ts.map +1 -1
- package/src/shade/renderer/texture/atlas/chunk_tile_atlas_slot_origin.js +28 -0
- package/src/shade/renderer/texture/atlas/tile_atlas_slot_shift.d.ts +13 -0
- package/src/shade/renderer/texture/atlas/tile_atlas_slot_shift.d.ts.map +1 -0
- package/src/shade/renderer/texture/atlas/tile_atlas_slot_shift.js +22 -0
- package/src/shade/renderer/water/GPUWaterRenderer.d.ts.map +1 -1
- package/src/shade/renderer/water/GPUWaterRenderer.js +4 -0
- package/src/shade/renderer/wind/GPUSceneWind.d.ts +52 -5
- package/src/shade/renderer/wind/GPUSceneWind.d.ts.map +1 -1
- package/src/shade/renderer/wind/GPUSceneWind.js +164 -8
- package/src/shade/renderer/wind/WIND_FIELD_UNIFORM.d.ts +3 -1
- package/src/shade/renderer/wind/WIND_FIELD_UNIFORM.d.ts.map +1 -1
- package/src/shade/renderer/wind/WIND_FIELD_UNIFORM.js +3 -1
- package/src/shade/renderer/wind/chunk_wind_field_sample_cascades.d.ts +2 -1
- package/src/shade/renderer/wind/chunk_wind_field_sample_cascades.d.ts.map +1 -1
- package/src/shade/renderer/wind/chunk_wind_field_sample_cascades.js +18 -13
- package/src/shade/renderer/wind/chunk_wind_field_sample_previous.d.ts +13 -0
- package/src/shade/renderer/wind/chunk_wind_field_sample_previous.d.ts.map +1 -0
- package/src/shade/renderer/wind/chunk_wind_field_sample_previous.js +23 -0
- package/src/shade/renderer/wind/chunk_wind_field_sample_uniform.d.ts +1 -0
- package/src/shade/renderer/wind/chunk_wind_field_sample_uniform.d.ts.map +1 -1
- package/src/shade/renderer/wind/chunk_wind_field_sample_uniform.js +6 -1
- package/src/shade/renderer/wind/wind_field_add_resources.d.ts +11 -0
- package/src/shade/renderer/wind/wind_field_add_resources.d.ts.map +1 -1
- package/src/shade/renderer/wind/wind_field_add_resources.js +15 -0
- package/src/shade/wgsl/emulator/WGSLJavaScriptCompiler.js +1 -1
- package/src/shade/wgsl/emulator/WGSLLanguageCore.d.ts.map +1 -1
- package/src/shade/wgsl/emulator/WGSLLanguageCore.js +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,91 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
### Network: the render delay comes down by the clock, and starts over after a wait of the client's own (SW_303, SW_304)
|
|
6
|
+
|
|
7
|
+
- **Breaking:** `AdaptiveRenderDelay`'s `decay_per_sample_ms` is replaced by `decay_rate`: milliseconds of delay shed
|
|
8
|
+
per millisecond between arrivals, 0.05 by default. An options object that still names `decay_per_sample_ms` has it
|
|
9
|
+
ignored. The delay came down by 1 ms for every frame applied, which is 3.2% of real time at 32 Hz, 6% at 60 Hz, and
|
|
10
|
+
less than either when few frames carry anything. A `NetworkSession` passes its time dilation's `max_dilation`: the
|
|
11
|
+
playout catches up with a calming link no faster than the client's clock is steered. At 32 Hz the delay is back
|
|
12
|
+
within a frame of where it was 17 s after a 0.5 s link hold, where it took 26 s, and the playout runs at most 5%
|
|
13
|
+
fast meanwhile (3% before). On steady links the settled delay is the same or lower (8.6 to 7.5 frames at 25% loss)
|
|
14
|
+
and nothing hitches. A spike is remembered for less: on a link that holds for 150 ms every 10 s, 13 drawn frames
|
|
15
|
+
in three minutes froze where 2 did.
|
|
16
|
+
- **Changed:** `AdaptiveRenderDelay.reset()` returns the delay to its initial value. It kept the delay it had.
|
|
17
|
+
- **Fixed:** the render delay rose to its largest value after a join whose snapshot took several steps to arrive,
|
|
18
|
+
and stayed up for tens of seconds: the frames held while the world arrived were applied at once and read as that
|
|
19
|
+
late. The playout now starts when the held frames are released, as a new stream. With 4,000 entities at 32 Hz the
|
|
20
|
+
delay peaked at 938 ms and was back at its floor 28 s after the join; it now peaks at the initial 188 ms, whatever
|
|
21
|
+
the world's size, and is at its floor 2.2 s after.
|
|
22
|
+
- **Fixed:** a client that drew nothing for longer than the largest render delay came back with the delay at its
|
|
23
|
+
largest value. `RenderPlayout` resets its delay when it starts the playhead again. After 5 s away at 32 Hz the
|
|
24
|
+
host's entities are drawn 126-185 ms behind in the following seconds, where they were 901-932 ms behind.
|
|
25
|
+
- Not covered: a stall or a link hold shorter than the largest delay (half a second, say) still raises the delay to
|
|
26
|
+
its largest value, and it is 17 s coming down at 32 Hz.
|
|
27
|
+
|
|
28
|
+
### Network: a client draws what moves after a pause on time (SW_304)
|
|
29
|
+
|
|
30
|
+
- **Fixed:** a host entity that stood still and then moved was drawn late on a client, and then fast-forwarded. The
|
|
31
|
+
host sends nothing of a frame in which nothing replicated changed, and the render playout took the newest frame
|
|
32
|
+
that carried something for where the host was: through a pause its playhead stopped, and what moved next was as
|
|
33
|
+
far ahead of it as the pause was long. At 32 Hz, an entity that stood for 0.5 s was first drawn moving 460 ms
|
|
34
|
+
after it moved on the host, one that stood for 4 s 1,760 ms after, and it took 5 to 9 s to be drawn on time again.
|
|
35
|
+
The playhead now follows the frame the host names every tick, and the entity is drawn 120 ms after, the same as
|
|
36
|
+
while it walked, however long it stood.
|
|
37
|
+
- **Fixed:** a client that drew nothing for a while (a hidden tab, a debugger) came back drawing the host's entities
|
|
38
|
+
seconds in the past, and caught up over about 10 s. A playhead further behind its target than the largest render
|
|
39
|
+
delay (`AdaptiveRenderDelay.max_delay_frames`) now starts again at its target: after 5 s away at 32 Hz, 0.9 s
|
|
40
|
+
behind where it was 3.5 s.
|
|
41
|
+
- **Added:** `RenderPlayout.advance_head(frame_number)`, for a sender's word of the frame it has reached when it
|
|
42
|
+
sends nothing else of it. It moves the head and is no sample for the delay.
|
|
43
|
+
- **Changed:** `RenderPlayout.record_arrival` takes a frame's lateness as a sample whether or not the head has
|
|
44
|
+
already passed that frame; it skipped frames at or below the head before. `RenderPlayout`'s playhead starts again
|
|
45
|
+
as above for every stream it plays, the scene editor's presence included.
|
|
46
|
+
|
|
47
|
+
### Probe clipmap: water and transparent meshes ask for their probes
|
|
48
|
+
|
|
49
|
+
- **Fixed:** under `ShadeIndirectLightingMode.ProbeClipmap`, water showed flat, hard-edged squares where its
|
|
50
|
+
missed reflections and its sky light fell back to the indirect lighting, and transparent meshes were lit
|
|
51
|
+
from whatever probes happened to be near. Only the G-buffer's pixels asked for probes, so a surface drawn
|
|
52
|
+
apart from it read a patchwork. The water's interface and the transparent meshes' meshlets now ask for the
|
|
53
|
+
probes they read; a probe a surface newly reads arrives a frame after the surface does.
|
|
54
|
+
- **Changed:** with their probes there, the water's optics and the transparent meshes' draw pay the probes'
|
|
55
|
+
pick at every fragment, where most fragments fell back to the environment before. On an AMD RDNA2 iGPU at
|
|
56
|
+
1280×720 the optics of a lake that fills the lower half of the view went from 28.6 to 38.1 ms. The wants
|
|
57
|
+
themselves cost 88 µs for the water and 28–132 µs for 1 to 5,028 transparent meshlets there.
|
|
58
|
+
- **Changed:** more probes are held, those of the surfaces now read, and the probes' update period lengthens
|
|
59
|
+
with them. A transparent meshlet many probe spacings across and not flat asks for more probes than its
|
|
60
|
+
surface crosses.
|
|
61
|
+
- **Added:** `GPUProbeClipmapGI.graph_want_surface` and `graph_want_meshlets`, for a pass that picks the
|
|
62
|
+
frustum's probes at a surface the G-buffer does not hold; `GPUProbeClipmap.write_want_bindings`;
|
|
63
|
+
`chunk_probe_clipmap_box_cages`; `probe_clipmap_want_cage` in `chunk_probe_clipmap_want`.
|
|
64
|
+
- Not covered: transparent meshes under `ShadeTransparencyMode.MBOIT`.
|
|
65
|
+
|
|
66
|
+
### Network: a steady tick allocates a tenth of what it did (SW_289)
|
|
67
|
+
|
|
68
|
+
- **Changed:** what a warm tick of a host and one client allocates, with assertions stripped as a game ships them
|
|
69
|
+
(`v8.GCProfiler`, 16 owned entities each moved by one action a frame): 66.0 KB → 7.0 KB when the client reconciles
|
|
70
|
+
by comparison (the default), 282.7 KB → 7.0 KB when it reconciles by replay. With one owned entity, 7.8 KB → 2.6 KB.
|
|
71
|
+
What is left is mostly not the network's: `InterpolationSystem`'s per-step Map of displaced entities (1.5 KB at 16
|
|
72
|
+
entities), `DeferredTransport`'s copy of each received packet, and the loopback transport the measurement runs on.
|
|
73
|
+
`tick_allocation_budget.spec` holds both scenes under 9 KB.
|
|
74
|
+
- **Fixed:** `SimActionExecutor.execute` and `record` called from inside another action (from `affected_components`,
|
|
75
|
+
`authorize`, `apply`, an announcement or `on_component_written`) now fail an assertion. Until now it was only
|
|
76
|
+
documented as illegal: started from `affected_components`, the outer action silently captured prior state for the
|
|
77
|
+
inner action's entity in place of its own, and a rewind no longer restored it.
|
|
78
|
+
- **Changed:** `SimActionExecutor` keeps its scratch between actions (about 300 B per executed action before).
|
|
79
|
+
- **Changed:** `BinaryBuffer.writeBytes` copies part of a typed array shorter than 2,048 bytes byte by byte, without
|
|
80
|
+
the `subarray` view it allocated per call. A longer part still goes through a view: the byte loop is the slower copy
|
|
81
|
+
from 32 bytes up (83 ns against 24 ns at 128 bytes, 1.3 µs against 0.04 µs at 2 KB).
|
|
82
|
+
- **Changed:** a `NetworkSession` client records the actions its input sampler returns in
|
|
83
|
+
`session.client.input_ring`, the orchestrator's per-frame input, and sizes that ring to `frame_capacity + 1` frames
|
|
84
|
+
(it was 256 and unused by the session). A game that also writes the same frames through the `input_writer` its own
|
|
85
|
+
`client.onPredict` handler is given would write over them.
|
|
86
|
+
- **Changed:** the host copies an arriving action record only once it has taken it (a re-sent copy of one it already
|
|
87
|
+
holds costs nothing), into pooled arrays, and orders a frame's input with a counting sort by sender; the client's
|
|
88
|
+
reconciliation by comparison keeps one reused state per network id. No behaviour change.
|
|
89
|
+
|
|
5
90
|
### Colour grading in the tone-mapping LUT
|
|
6
91
|
|
|
7
92
|
- **Added:** `ColorGrade`, as `renderer.tone_mapper.grade`, neutral by default and baked into the tone mapper's LUTs
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const t=!1,i=!0,e=new Float32Array(1),n=new Int32Array(e.buffer);class s{endianness=i;position=0;get length(){throw new Error("Deprecated, use 'capacity' instead")}set length(t){throw new Error("Deprecated, use 'capacity' instead")}capacity=1024;data=new ArrayBuffer(1024);dataView=new DataView(this.data);__data_uint8=new Uint8Array(this.data);__growFactor=1.1;get raw_bytes(){return this.__data_uint8}fromArrayBuffer(t){this.data=t,this.dataView=new DataView(t),this.__data_uint8=new Uint8Array(t),this.capacity=t.byteLength,this.position=0}trim(){return this.setCapacity(this.position),this}skip(t){this.position+=t}setCapacity(t){if(t<this.position)throw new Error(`Attempting to set capacity(=${t}) below current position(=${this.position})`);if(this.capacity===t)return;const i=this.__data_uint8,e=new Uint8Array(t),n=Math.min(i.buffer.byteLength,e.buffer.byteLength);n>0&&function(t,i,e,n,s){let r,o;const a=function(t,i,e){const n=0|e;return 3&n?1&n?1:2:4}(0,0,s);4===a?(r=new Uint32Array(t,0,s>>>2),o=new Uint32Array(e,0,s>>>2)):2===a?(r=new Uint16Array(t,0,s>>>1),o=new Uint16Array(e,0,s>>>1)):(r=new Uint8Array(t,0,s),o=new Uint8Array(e,0,s)),o.set(r)}(i.buffer,0,e.buffer,0,n),this.data=e.buffer,this.__data_uint8=e,this.dataView=new DataView(this.data),this.capacity=t}ensureCapacity(t){const i=this.capacity;if(i>=t)return;const e=(n=Math.ceil(Math.max(t,i*this.__growFactor,i+1024)))+(4-n%4)%4;var n;this.setCapacity(e)}readFloat16(){return function(t){let i=0;const e=(31744&t)>>10,n=1023&t;let s=1;return t>>15&&(s=-1),i=0!==e?31===e?0!==n?NaN:Infinity*s:s*Math.pow(2,e-15)*(1+n/1024):s*(n/1024*6103515625e-14),i}(this.readUint16())}readFloat32(){const t=this.dataView.getFloat32(this.position,this.endianness);return this.position+=4,t}readFloat64(){const t=this.dataView.getFloat64(this.position,this.endianness);return this.position+=8,t}readInt8(){const t=this.dataView.getInt8(this.position);return this.position+=1,t}readInt16(){const t=this.dataView.getInt16(this.position,this.endianness);return this.position+=2,t}readInt16LE(){const t=this.dataView.getInt16(this.position,i);return this.position+=2,t}readInt16BE(){const i=this.dataView.getInt16(this.position,t);return this.position+=2,i}readInt32(){const t=this.dataView.getInt32(this.position,this.endianness);return this.position+=4,t}readInt32LE(){const t=this.dataView.getInt32(this.position,i);return this.position+=4,t}readInt32BE(){const i=this.dataView.getInt32(this.position,t);return this.position+=4,i}readInt64(){const t=this.dataView.getBigInt64(this.position,this.endianness);return this.position+=8,t}readUint8(){const t=this.dataView.getUint8(this.position);return this.position+=1,t}readUint16(){const t=this.dataView.getUint16(this.position,this.endianness);return this.position+=2,t}readUint16LE(){const t=this.dataView.getUint16(this.position,i);return this.position+=2,t}readUint16BE(){const i=this.dataView.getUint16(this.position,t);return this.position+=2,i}readUint24(){return this.endianness===t?this.readUint24BE():this.readUint24LE()}readUint24LE(){const t=this.dataView.getUint8(this.position),i=this.dataView.getUint8(this.position+1),e=this.dataView.getUint8(this.position+2);return this.position+=3,t|i<<8|e<<16}readUint24BE(){const t=this.dataView.getUint8(this.position),i=this.dataView.getUint8(this.position+1),e=this.dataView.getUint8(this.position+2);return this.position+=3,e|i<<8|t<<16}readUint32(){const t=this.dataView.getUint32(this.position,this.endianness);return this.position+=4,t}readUint32LE(){const t=this.dataView.getUint32(this.position,i);return this.position+=4,t}readUint32BE(){const i=this.dataView.getUint32(this.position,t);return this.position+=4,i}readUint64(){const t=this.dataView.getBigUint64(this.position,this.endianness);return this.position+=8,t}readUint8Array(t,i,e){for(let n=0;n<e;n++)t[n+i]=this.readUint8()}readUint16Array(t,i,e){for(let n=0;n<e;n++)t[n+i]=this.readUint16()}readUint32Array(t,i,e){for(let n=0;n<e;n++)t[n+i]=this.readUint32()}readInt8Array(t,i,e){for(let n=0;n<e;n++)t[n+i]=this.readInt8()}readInt16Array(t,i,e){for(let n=0;n<e;n++)t[n+i]=this.readInt16()}readInt32Array(t,i,e){for(let n=0;n<e;n++)t[n+i]=this.readInt32()}readFloat32Array(t,i,e){for(let n=0;n<e;n++)t[n+i]=this.readFloat32()}readFloat64Array(t,i,e){for(let n=0;n<e;n++)t[n+i]=this.readFloat64()}writeFloat32Array(t,i,e){for(let n=0;n<e;n++)this.writeFloat32(t[n+i])}writeFloat64Array(t,i,e){const n=this.position+8*e;this.ensureCapacity(n);const s=this.dataView,r=this.endianness;let o=this.position;for(let n=0;n<e;n++)s.setFloat64(o,t[i+n],r),o+=8;this.position=n}writeFloat16Array(t,i,e){for(let n=0;n<e;n++)this.writeFloat16(t[n+i])}readFloat16Array(t,i,e){for(let n=0;n<e;n++)t[n+i]=this.readFloat16()}writeFloat16(t){const i=function(t){let i=t;Number.isFinite(i)&&(i>65504||i<-65504)&&(i=i>0?65504:-65504),e[0]=i;const s=n[0];let r=s>>16&32768,o=s>>12&2047;const a=s>>23&255;return a<103?r:a>142?(r|=31744,255===a&&8388607&s&&(r|=512),r):a<113?(o|=2048,r|=(o>>114-a)+(o>>113-a&1),r):(r|=a-112<<10|o>>1,r+=1&o,r)}(t);this.writeUint16(i)}writeFloat32(t){const i=this.position+4;this.ensureCapacity(i),this.dataView.setFloat32(this.position,t,this.endianness),this.position=i}writeFloat64(t){const i=this.position+8;this.ensureCapacity(i),this.dataView.setFloat64(this.position,t,this.endianness),this.position=i}writeInt8(t){const i=this.position+1;this.ensureCapacity(i),this.dataView.setInt8(this.position,t),this.position=i}writeInt16(t){const i=this.position+2;this.ensureCapacity(i),this.dataView.setInt16(this.position,t,this.endianness),this.position=i}writeInt16BE(i){const e=this.position+2;this.ensureCapacity(e),this.dataView.setInt16(this.position,i,t),this.position=e}writeInt16LE(t){const e=this.position+2;this.ensureCapacity(e),this.dataView.setInt16(this.position,t,i),this.position=e}writeInt32(t){const i=this.position+4;this.ensureCapacity(i),this.dataView.setInt32(this.position,t,this.endianness),this.position=i}writeInt32BE(i){const e=this.position+4;this.ensureCapacity(e),this.dataView.setInt32(this.position,i,t),this.position=e}writeInt32LE(t){const e=this.position+4;this.ensureCapacity(e),this.dataView.setInt32(this.position,t,i),this.position=e}writeInt64(t){const i=this.position+8;this.ensureCapacity(i),this.dataView.setBigInt64(this.position,t,this.endianness),this.position=i}writeInt8Array(t,i,e){this.ensureCapacity(this.position+e);for(let n=0;n<e;n++)this.writeInt8(t[i+n])}writeInt16Array(t,i,e){this.ensureCapacity(this.position+2*e);for(let n=0;n<e;n++)this.writeInt16(t[i+n])}writeInt32Array(t,i,e){this.ensureCapacity(this.position+4*e);for(let n=0;n<e;n++)this.writeInt32(t[i+n])}writeUint8(t){const i=this.position+1;this.ensureCapacity(i),this.dataView.setUint8(this.position,t),this.position=i}writeUint8Array(t,i,e){for(let n=0;n<e;n++)this.writeUint8(t[i+n])}writeUint16(t){const i=this.position+2;this.ensureCapacity(i),this.dataView.setUint16(this.position,t,this.endianness),this.position=i}writeUint16BE(i){const e=this.position+2;this.ensureCapacity(e),this.dataView.setUint16(this.position,i,t),this.position=e}writeUint16LE(t){const e=this.position+2;this.ensureCapacity(e),this.dataView.setUint16(this.position,t,i),this.position=e}writeUint16Array(t,i,e){for(let n=0;n<e;n++)this.writeUint16(t[i+n])}writeUint24(i){this.endianness===t?this.writeUint24BE(i):this.writeUint24LE(i)}writeUint24BE(t){const i=this.position+3;this.ensureCapacity(i);const e=255&t,n=t>>8&255,s=t>>16&255;this.dataView.setUint8(this.position,s),this.dataView.setUint8(this.position+1,n),this.dataView.setUint8(this.position+2,e),this.position=i}writeUint24LE(t){const i=this.position+3;this.ensureCapacity(i);const e=255&t,n=t>>8&255,s=t>>16&255;this.dataView.setUint8(this.position,e),this.dataView.setUint8(this.position+1,n),this.dataView.setUint8(this.position+2,s),this.position=i}writeUintVar(t){if((0|t)!==t||t<0)throw new RangeError(`value=[${t}] must be an integer in [0, 2147483647]`);let i=!0,e=t;for(;i||0!==e;){i=!1;let t=127&e;e>>=7,e>0&&(t|=128),this.writeUint8(t)}}readUintVar(){let t=!0,i=0,e=0;for(;t;){let n=this.readUint8();if(t=!!(128&n),i+=(127&n)*2**e,e+=7,t&&e>28)throw new Error("uintVar is too long, more than 5 bytes")}return i}writeUint32(t){const i=this.position+4;this.ensureCapacity(i),this.dataView.setUint32(this.position,t,this.endianness),this.position=i}writeUint32BE(i){const e=this.position+4;this.ensureCapacity(e),this.dataView.setUint32(this.position,i,t),this.position=e}writeUint32LE(t){const e=this.position+4;this.ensureCapacity(e),this.dataView.setUint32(this.position,t,i),this.position=e}writeUint64(t){const i=this.position+8;this.ensureCapacity(i),this.dataView.setBigUint64(this.position,t,this.endianness),this.position=i}writeUint32Array(t,i,e){this.ensureCapacity(this.position+4*e);for(let n=0;n<e;n++)this.writeUint32(t[i+n])}writeBytes(t,i,e){const n=i+e,s=this.position,r=s+e;if(this.ensureCapacity(r),0===i&&t.length===e)this.__data_uint8.set(t,s);else if("function"==typeof t.subarray)this.__data_uint8.set(t.subarray(i,n),s);else for(let n=0;n<e;n++)this.__data_uint8[s+n]=t[i+n];this.position=r}readBytes(t,i,e){const n=this.position,s=n+e,r=this.__data_uint8;if(e<0||s>this.capacity)throw new Error(`Attempting to read ${e} bytes at position ${n}, only ${this.capacity-n} available`);e<128?function(t,i,e,n,s){if(ArrayBuffer.isView(t)&&ArrayBuffer.isView(e)&&t.buffer===e.buffer&&void 0!==t.BYTES_PER_ELEMENT&&void 0!==e.BYTES_PER_ELEMENT){const r=t.byteOffset+i*t.BYTES_PER_ELEMENT,o=e.byteOffset+n*e.BYTES_PER_ELEMENT;if(r<o+s*e.BYTES_PER_ELEMENT&&o<r+s*t.BYTES_PER_ELEMENT)return void e.set(t.subarray(i,i+s),n)}if(t===e&&n>i&&n<i+s){for(let r=s-1;r>=0;r--)e[n+r]=t[i+r];return}let r,o,a;for(a=0;a<s;a++)r=i+a,o=n+a,e[o]=t[r]}(r,n,t,i,e):t.set(r.subarray(n,s),i),this.position=s}writeUTF8String(t){if(null===t)return void this.writeUint32(4294967295);if(void 0===t)return void this.writeUint32(4294967294);let i=0;const e=t.length;if(e>=4294967294)throw new Error("String is too long");this.writeUint32(e);let n=this.position;const s=Math.max(32,e+(e>>1)+7);this.ensureCapacity(s+n);let r=this.__data_uint8,o=this.capacity;for(;i<e;){let s=t.charCodeAt(i++);if(s>=55296&&s<=56319){if(i<e){const e=t.charCodeAt(i);56320==(64512&e)&&(++i,s=((1023&s)<<10)+(1023&e)+65536)}s>=55296&&s<=56319&&(s=65533)}if(n+4>o&&(this.position=n,this.ensureCapacity(n+4),o=this.capacity,r=this.__data_uint8),4294967168&s){if(4294965248&s)if(4294901760&s){if(4292870144&s)continue;r[n++]=s>>18&7|240,r[n++]=s>>12&63|128,r[n++]=s>>6&63|128}else r[n++]=s>>12&15|224,r[n++]=s>>6&63|128;else r[n++]=s>>6&31|192;r[n++]=63&s|128}else r[n++]=s}this.position=n}readUTF8String(){const t=this.readUint32();if(4294967295===t)return null;if(4294967294===t)return;const i=this.__data_uint8;let e="",n=this.position,s=0;for(;n<this.capacity&&s<t;){const t=i[n++];let r;128&t?192==(224&t)?r=(31&t)<<6|63&i[n++]:224==(240&t)?r=(31&t)<<12|(63&i[n++])<<6|63&i[n++]:240==(248&t)&&(r=(7&t)<<18|(63&i[n++])<<12|(63&i[n++])<<6|63&i[n++],r>65535&&(r-=65536,e+=String.fromCharCode(r>>>10&1023|55296),s++,r=56320|1023&r)):r=t,s++,e+=String.fromCharCode(r)}return this.position=n,e}writeASCIIString(t){const i=t.length,e=this.position,n=e+i;this.ensureCapacity(n);for(let n=0;n<i;n++){const i=t.charCodeAt(n);if(i>127)throw new Error(`Character ${String.fromCharCode(i)} can't be represented by a US-ASCII byte.`);this.__data_uint8[e+n]=i}this.position=n}readASCIICharacters(t,i=!1){let e="";for(let n=0;n<t;n++){const t=this.readUint8();if(i&&0===t)break;e+=String.fromCharCode(t)}return e}toString(){return`BinaryBuffer[position=${this.position}, capacity=${this.capacity}, endianness=${this.endianness}]`}toHexString(){const t=this.__data_uint8,i=Math.min(t.length,this.position);let e="";for(let n=0;n<i;n++)e+=t[n].toString(16).padStart(2,"0").toUpperCase();return e}static fromEndianness(t){const i=new s;return i.endianness=t,i}static fromArrayBuffer(t){const i=new s;return i.fromArrayBuffer(t),i}static copyUTF8String(t,i){const e=t.readUTF8String();return i.writeUTF8String(e),e}static copyUintVar(t,i){const e=t.readUintVar();return i.writeUintVar(e),e}static copyUint8(t,i){const e=t.readUint8();return i.writeUint8(e),e}static copyUint16(t,i){const e=t.readUint16();return i.writeUint16(e),e}static copyUint32(t,i){const e=t.readUint32();return i.writeUint32(e),e}static copyFloat32(t,i){const e=t.readFloat32();return i.writeFloat32(e),e}static copyFloat64(t,i){const e=t.readFloat64();return i.writeFloat64(e),e}static copyBytes(t,i,e){const n=new Uint8Array(e);return t.readBytes(n,0,e),i.writeBytes(n,0,e),n}}s.prototype.isBinaryBuffer=!0;let r=i,o=!1;function a(t,i=0,e=t.length){let n="",s=i;for(;s<e;){const i=t[s++];if(i<128)n+=String.fromCharCode(i);else if(i<224)n+=String.fromCharCode((31&i)<<6|(s<e?63&t[s++]:0));else if(i<240)n+=String.fromCharCode((15&i)<<12|(s<e?63&t[s++]:0)<<6|(s<e?63&t[s++]:0));else{const r=((7&i)<<18|(s<e?63&t[s++]:0)<<12|(s<e?63&t[s++]:0)<<6|(s<e?63&t[s++]:0))-65536;n+=String.fromCharCode(55296+(r>>10),56320+(1023&r))}}return n}async function h(t,i="deflate"){const e=function(t){let i=0;return new ReadableStream({pull(e){i===t.length?e.close():e.enqueue(t[i++])}})}(t).pipeThrough(new DecompressionStream(i));return new Uint8Array(await new Response(e).arrayBuffer())}async function c(t,i=!1){try{return await h(t)}catch(e){if(i){const i=function(t){const i=t.length;if(1===i)return t[0];let e=0;for(let n=0;n<i;n++)e+=t[n].length;const n=new Uint8Array(e);let s=0;for(let e=0;e<i;e++)n.set(t[e],s),s+=t[e].length;return n}(t),e=i[0],n=i[1];if(i.length>=6&&8==(15&e)&&e>>>4<=7&&(e<<8|n)%31==0&&!(32&n))try{return await h([i.subarray(2,i.length-4)],"deflate-raw")}catch{}}throw new Error(`failed to inflate zlib stream: ${e?.message||"invalid or truncated data"}`)}}const p=new Uint32Array(256);for(let t=0;t<256;t++){let i=t;for(let t=0;t<8;t++)1&i?i=3988292384^i>>>1:i>>>=1;p[t]=i}const d=Object.freeze([function(t,i,e,n,s,r,o){for(let n=0;n<o;n++)e[s+n]=t[i+n]},function(t,i,e,n,s,r,o){let a=0;for(;a<n;a++)e[s+a]=t[a+i];for(;a<o;a++){const r=s+a;e[r]=t[a+i]+e[r-n]&255}},function(t,i,e,n,s,r,o){let a,h,c=0;if(r<0)for(;c<o;c++)e[s+c]=t[c+i];else for(;c<o;c++)a=t[c+i],h=e[r+c],e[s+c]=a+h&255},function(t,i,e,n,s,r,o){let a,h,c,p=0;if(r<0){for(;p<n;p++)e[s+p]=t[p+i];for(;p<o;p++){const r=s+p;e[r]=t[p+i]+(e[r-n]>>1)&255}}else{for(;p<n;p++)e[s+p]=t[p+i]+(e[r+p]>>1)&255;for(;p<o;p++)a=t[p+i],h=e[s+p-n],c=e[r+p],e[s+p]=a+(h+c>>1)&255}},function(t,i,e,n,s,r,o){let a,h,c,p,d,f,l,u,w,y=0;if(r<0){for(;y<n;y++)e[s+y]=t[y+i];for(;y<o;y++)e[s+y]=t[y+i]+e[s+y-n]&255}else{for(;y<n;y++)e[s+y]=t[y+i]+e[r+y]&255;for(;y<o;y++)a=t[y+i],p=e[r+y-n],c=e[r+y],h=e[s+y-n],d=h+c-p,f=Math.abs(d-h),l=Math.abs(d-c),u=Math.abs(d-p),w=f<=l&&f<=u?h:l<=u?c:p,e[s+y]=a+w&255}}]);function f(t,i,e,n,s,r,o,a){const h=d[t];if(void 0===h)throw new Error(`unknown filtered scanline type '${t}'`);h(i,e,n,s,r,o,a)}function l(t,i,e,n,s,r){if(1!==e&&2!==e&&4!==e)throw new Error(`only bit depths below 8 are packed, got ${e}`);const o=(1<<e)-1;for(let a=0;a<n;a++){const n=a*e,h=t[i+(n>>3)],c=8-e-(7&n);s[r+a]=h>>>c&o}}class u{width=0;height=0;bitDepth=0;colorType=0;compressionMethod=0;filterMethod=0;interlaceMethod=0;colors=0;alpha=!1;palette=null;pixels=null;transparency_lookup=null;text={};getWidth(){return this.width}setWidth(t){this.width=t}getHeight(){return this.height}setHeight(t){this.height=t}getBitDepth(){return this.bitDepth}setBitDepth(t){if(-1===[1,2,4,8,16].indexOf(t))throw new Error("invalid bith depth "+t);this.bitDepth=t}getColorType(){return this.colorType}setColorType(t){let i=0,e=!1;switch(t){case 0:case 3:i=1;break;case 2:i=3;break;case 4:i=2,e=!0;break;case 6:i=4,e=!0;break;default:throw new Error("invalid color type")}this.colors=i,this.alpha=e,this.colorType=t}setCompressionMethod(t){if(0!==t)throw new Error("invalid compression method "+t);this.compressionMethod=t}setFilterMethod(t){if(0!==t)throw new Error("invalid filter method "+t);this.filterMethod=t}getInterlaceMethod(){return this.interlaceMethod}setInterlaceMethod(t){if(0!==t&&1!==t)throw new Error("invalid interlace method "+t);this.interlaceMethod=t}setPalette(t){if(t.length%3!=0)throw new Error("incorrect PLTE chunk length");if(t.length>3*Math.pow(2,this.bitDepth))throw new Error("palette has more colors than 2^bitdepth");this.palette=t}getUint8Data_case3(){const t=this.width*this.height;let i;const e=this.transparency_lookup;i=null!==e?4:3;const n=new Uint8Array(t*i),s=this.pixels,r=this.palette,o=this.colors*Math.ceil(this.bitDepth/8);for(let e=0;e<t;e++){const t=e*i,a=3*s[e*o];n[t]=r[a],n[t+1]=r[a+1],n[t+2]=r[a+2]}if(null!==e){const i=e.length;for(let r=0;r<t;r++){const t=s[r*o];n[4*r+3]=t>=i?255:e[t]}}return{data:n,itemSize:i}}getUint8Data(){let t,i=0;switch(this.colorType){case 0:t=this.pixels,i=1;break;case 2:t=this.pixels,i=3;break;case 3:const e=this.getUint8Data_case3();t=e.data,i=e.itemSize;break;case 4:t=this.pixels,i=2;break;case 6:t=this.pixels,i=4;break;default:throw new Error("Unsupported color type")}return{data:t,itemSize:i}}}const w=[137,80,78,71,13,10,26,10];function y(t,i){return t[i]<<24|t[i+1]<<16|t[i+2]<<8|t[i+3]}function g(t,i){return t[i]}function U(i){this.png=new u,this.dataChunks=[],this.buffer=new s,this.buffer.endianness=t,this.buffer.fromArrayBuffer(i),this.crc_enabled=!1}U.prototype.readBytes=function(t){const i=this.buffer,e=new Uint8Array(i.data,i.position,t);return i.skip(t),e},U.prototype.decodeHeader=function(){const t=this.buffer,i=new Uint8Array(w.length);if(t.readBytes(i,0,i.length),!function(t,i){const e=t.length;if(e!==i.length)return!1;for(let n=0;n<e;n++)if(t[n]!==i[n])return!1;return!0}(i,w))throw new Error("invalid PNGReader file (bad signature)")},U.prototype.decodeChunk=async function(){const t=this.buffer,i=t.readUint32();if(i<0)throw new Error("Bad chunk length "+(4294967295&i));const e=t.position,n=t.readASCIICharacters(4),r=this.readBytes(i);switch(t.readUint32(),this.crc_enabled&&function(t,i=0,e=t.length){!function(t,i,e,n){let s=4294967295;const r=e+n;for(let t=e;t<r;t++){const e=i[t];s=p[255&(s^e)]^s>>>8}}(0,t,i,e)}(t.raw_bytes,e,i+4),n){case"IHDR":this.decodeIHDR(r);break;case"PLTE":this.decodePLTE(r);break;case"IDAT":this.decodeIDAT(r);break;case"tRNS":this.decodeTRNS(r);break;case"IEND":this.decodeIEND(r);break;case"sRGB":this.decodesRGB(r);break;case"tIME":this.decodetIME(r);break;case"zTXt":await async function(t){const i=t.byteLength,e=t.buffer,n=t.byteOffset,r=s.fromArrayBuffer(e);r.position=n;const o=r.readASCIICharacters(79,!0),a=r.readUint8();let h;if(0!==a)throw new Error(`Unsupported compression method '${a}'`);{const t=r.position-n,s=new Uint8Array(e,r.position,i-t),o=await c([s]);r.fromArrayBuffer(o.buffer),h=r.readASCIICharacters(o.byteLength)}return{keyword:o,text:h}}(r);break;case"iTXt":await async function(t){const i=t.byteLength,e=t.buffer,n=t.byteOffset,r=n+i,o=s.fromArrayBuffer(e);o.position=n;const h=o.readASCIICharacters(80,!0);if(h.length>79)throw new Error("iTXt keyword exceeds 79 bytes");const p=o.readUint8(),d=o.readUint8(),f=o.readASCIICharacters(Number.MAX_SAFE_INTEGER,!0),l=o.position-n;let u=l;for(;u<i&&0!==t[u];)u++;if(u>=i)throw new Error("iTXt translated keyword is not terminated");const w=a(t,l,u);o.position=n+u+1;const y=r-o.position;let g;if(0===p)g=a(t,o.position-n,i);else{if(1!==p)throw new Error(`Invalid compression flag value '${p}'`);if(0!==d)throw new Error("only compression_method 0 is supported");g=a(await c([new Uint8Array(o.data,o.position,y)]))}return{keyword:h,language_tag:f,translated_keyword:w,text:g}}(r)}return n},U.prototype.decodesRGB=function(t){g(t,0)},U.prototype.decodetIME=function(t){g(t,0),g(t,1),g(t,2),g(t,3),g(t,4),g(t,5),g(t,6)},U.prototype.decodetEXt=function(t){const i=s.fromArrayBuffer(t.buffer),e=i.readASCIICharacters(Number.POSITIVE_INFINITY,!0),n=i.readASCIICharacters(e.length-1,!1);this.png.text[e]=n},U.prototype.decodeiEXt=function(t){const i=s.fromArrayBuffer(t.buffer),e=i.readASCIICharacters(Number.POSITIVE_INFINITY,!0);if(i.readUint8(),i.readUint8(),i.readASCIICharacters(Number.POSITIVE_INFINITY,!0),i.readUTF8String(),0!==i.readUint8())throw new Error("Expected Null Separator after Translated keyword");const n=i.readUTF8String();this.png.text[e]=n},U.prototype.decodeIHDR=function(t){const i=this.png;i.setWidth(y(t,0)),i.setHeight(y(t,4)),i.setBitDepth(g(t,8)),i.setColorType(g(t,9)),i.setCompressionMethod(g(t,10)),i.setFilterMethod(g(t,11)),i.setInterlaceMethod(g(t,12))},U.prototype.decodePLTE=function(t){this.png.setPalette(t)},U.prototype.decodeIDAT=function(t){this.dataChunks.push(t)},U.prototype.decodeTRNS=function(t){this.png.transparency_lookup=t},U.prototype.decodeIEND=function(){},U.prototype.decodePixels=async function(){const e=this.png,n=await c(this.dataChunks,!0);if(0===e.getInterlaceMethod()?this.png.pixels=this.interlaceNone(n):this.png.pixels=this.interlaceAdam7(n),16===e.bitDepth&&function(){if(o)return r;const e=new ArrayBuffer(2),n=new Uint8Array(e),s=new Uint16Array(e);return n[0]=19,r=19==(255&s[0])?i:t,o=!0,r}()===i){const t=this.png.pixels;for(let i=0;i<t.length;i+=2){const e=t[i];t[i]=t[i+1],t[i+1]=e}}},U.prototype.interlaceNone=function(t){const i=this.png,e=i.bitDepth,n=i.colors,s=i.width,r=i.height,o=Math.max(1,Math.ceil(n*e/8)),a=Math.ceil(n*e*s/8);if(e<8)return function(t,i,e,n,s,r){const o=new Uint8Array(e*r),a=new Uint8Array(2*s),h=Math.floor(t.length/(s+1)),c=r<h?r:h;let p=0,d=-1;for(let r=0;r<c;r++){const h=(1&r)*s;f(t[p++],t,p,a,n,h,d,s),p+=s,l(a,h,i,e,o,r*e),d=h}return o}(t,e,n*s,o,a,r);const h=new Uint8Array(a*r);let c=0;const p=t.length;for(let i=0;i<p;i+=a+1){const e=i+1;f(t[i],t,e,h,o,c,c-a,a),c+=a}return h},U.prototype.interlaceAdam7=function(t){const i=this.png,e=i.bitDepth,n=i.colors,s=i.width,r=i.height,o=e<8,a=Math.max(1,Math.ceil(n*e/8)),h=n*(16===e?2:1),c=new Uint8Array(h*s*r),p=[{x:0,y:0,xStep:8,yStep:8},{x:4,y:0,xStep:8,yStep:8},{x:0,y:4,xStep:4,yStep:8},{x:2,y:0,xStep:4,yStep:4},{x:0,y:2,xStep:2,yStep:4},{x:1,y:0,xStep:2,yStep:2},{x:0,y:1,xStep:1,yStep:2}];let d=0;const u=new Uint8Array(2*Math.ceil(n*e*s/8)),w=o?new Uint8Array(n*s):null;for(let i=0;i<7;i++){const y=p[i],g=Math.ceil((s-y.x)/y.xStep),U=Math.ceil((r-y.y)/y.yStep);if(g<=0||U<=0)continue;const E=n*g,I=Math.ceil(E*e/8);let b=-1;for(let i=0;i<U;i++){const n=i%2*I;f(t[d++],t,d,u,a,n,b,I),d+=I,b=n;let p=u,U=n;o&&(l(u,n,e,E,w,0),p=w,U=0);for(let t=0;t<g;t++){const e=y.x+t*y.xStep,n=y.y+i*y.yStep;if(!(e>=s||n>=r))for(let i=0;i<h;i++)c[(n*s+e)*h+i]=p[U+t*h+i]}}}return c},U.prototype.unFilter=function(t,i,e,n,s,r,o,a){f(t,i,e,n,s,r,o,a)},U.prototype.parse=async function(){for(this.decodeHeader();"IEND"!==await this.decodeChunk(););return await this.decodePixels(),this.png},self.Lib={decode:async function(t,i="png"){if(!(t instanceof ArrayBuffer))throw new Error(".data argument must be an ArrayBuffer, instead was something else");if("png"===i.toLowerCase())return await async function(t){const i=await new U(t).parse(),e=i.getUint8Data();return{data:e.data.buffer,width:i.getWidth(),height:i.getHeight(),itemSize:e.itemSize,bitDepth:i.getBitDepth()}}(t);throw new Error("Unsupported type")}};
|
|
1
|
+
const t=!1,i=!0,e=new Float32Array(1),n=new Int32Array(e.buffer);class s{endianness=i;position=0;get length(){throw new Error("Deprecated, use 'capacity' instead")}set length(t){throw new Error("Deprecated, use 'capacity' instead")}capacity=1024;data=new ArrayBuffer(1024);dataView=new DataView(this.data);__data_uint8=new Uint8Array(this.data);__growFactor=1.1;get raw_bytes(){return this.__data_uint8}fromArrayBuffer(t){this.data=t,this.dataView=new DataView(t),this.__data_uint8=new Uint8Array(t),this.capacity=t.byteLength,this.position=0}trim(){return this.setCapacity(this.position),this}skip(t){this.position+=t}setCapacity(t){if(t<this.position)throw new Error(`Attempting to set capacity(=${t}) below current position(=${this.position})`);if(this.capacity===t)return;const i=this.__data_uint8,e=new Uint8Array(t),n=Math.min(i.buffer.byteLength,e.buffer.byteLength);n>0&&function(t,i,e,n,s){let r,o;const a=function(t,i,e){const n=0|e;return 3&n?1&n?1:2:4}(0,0,s);4===a?(r=new Uint32Array(t,0,s>>>2),o=new Uint32Array(e,0,s>>>2)):2===a?(r=new Uint16Array(t,0,s>>>1),o=new Uint16Array(e,0,s>>>1)):(r=new Uint8Array(t,0,s),o=new Uint8Array(e,0,s)),o.set(r)}(i.buffer,0,e.buffer,0,n),this.data=e.buffer,this.__data_uint8=e,this.dataView=new DataView(this.data),this.capacity=t}ensureCapacity(t){const i=this.capacity;if(i>=t)return;const e=(n=Math.ceil(Math.max(t,i*this.__growFactor,i+1024)))+(4-n%4)%4;var n;this.setCapacity(e)}readFloat16(){return function(t){let i=0;const e=(31744&t)>>10,n=1023&t;let s=1;return t>>15&&(s=-1),i=0!==e?31===e?0!==n?NaN:Infinity*s:s*Math.pow(2,e-15)*(1+n/1024):s*(n/1024*6103515625e-14),i}(this.readUint16())}readFloat32(){const t=this.dataView.getFloat32(this.position,this.endianness);return this.position+=4,t}readFloat64(){const t=this.dataView.getFloat64(this.position,this.endianness);return this.position+=8,t}readInt8(){const t=this.dataView.getInt8(this.position);return this.position+=1,t}readInt16(){const t=this.dataView.getInt16(this.position,this.endianness);return this.position+=2,t}readInt16LE(){const t=this.dataView.getInt16(this.position,i);return this.position+=2,t}readInt16BE(){const i=this.dataView.getInt16(this.position,t);return this.position+=2,i}readInt32(){const t=this.dataView.getInt32(this.position,this.endianness);return this.position+=4,t}readInt32LE(){const t=this.dataView.getInt32(this.position,i);return this.position+=4,t}readInt32BE(){const i=this.dataView.getInt32(this.position,t);return this.position+=4,i}readInt64(){const t=this.dataView.getBigInt64(this.position,this.endianness);return this.position+=8,t}readUint8(){const t=this.dataView.getUint8(this.position);return this.position+=1,t}readUint16(){const t=this.dataView.getUint16(this.position,this.endianness);return this.position+=2,t}readUint16LE(){const t=this.dataView.getUint16(this.position,i);return this.position+=2,t}readUint16BE(){const i=this.dataView.getUint16(this.position,t);return this.position+=2,i}readUint24(){return this.endianness===t?this.readUint24BE():this.readUint24LE()}readUint24LE(){const t=this.dataView.getUint8(this.position),i=this.dataView.getUint8(this.position+1),e=this.dataView.getUint8(this.position+2);return this.position+=3,t|i<<8|e<<16}readUint24BE(){const t=this.dataView.getUint8(this.position),i=this.dataView.getUint8(this.position+1),e=this.dataView.getUint8(this.position+2);return this.position+=3,e|i<<8|t<<16}readUint32(){const t=this.dataView.getUint32(this.position,this.endianness);return this.position+=4,t}readUint32LE(){const t=this.dataView.getUint32(this.position,i);return this.position+=4,t}readUint32BE(){const i=this.dataView.getUint32(this.position,t);return this.position+=4,i}readUint64(){const t=this.dataView.getBigUint64(this.position,this.endianness);return this.position+=8,t}readUint8Array(t,i,e){for(let n=0;n<e;n++)t[n+i]=this.readUint8()}readUint16Array(t,i,e){for(let n=0;n<e;n++)t[n+i]=this.readUint16()}readUint32Array(t,i,e){for(let n=0;n<e;n++)t[n+i]=this.readUint32()}readInt8Array(t,i,e){for(let n=0;n<e;n++)t[n+i]=this.readInt8()}readInt16Array(t,i,e){for(let n=0;n<e;n++)t[n+i]=this.readInt16()}readInt32Array(t,i,e){for(let n=0;n<e;n++)t[n+i]=this.readInt32()}readFloat32Array(t,i,e){for(let n=0;n<e;n++)t[n+i]=this.readFloat32()}readFloat64Array(t,i,e){for(let n=0;n<e;n++)t[n+i]=this.readFloat64()}writeFloat32Array(t,i,e){for(let n=0;n<e;n++)this.writeFloat32(t[n+i])}writeFloat64Array(t,i,e){const n=this.position+8*e;this.ensureCapacity(n);const s=this.dataView,r=this.endianness;let o=this.position;for(let n=0;n<e;n++)s.setFloat64(o,t[i+n],r),o+=8;this.position=n}writeFloat16Array(t,i,e){for(let n=0;n<e;n++)this.writeFloat16(t[n+i])}readFloat16Array(t,i,e){for(let n=0;n<e;n++)t[n+i]=this.readFloat16()}writeFloat16(t){const i=function(t){let i=t;Number.isFinite(i)&&(i>65504||i<-65504)&&(i=i>0?65504:-65504),e[0]=i;const s=n[0];let r=s>>16&32768,o=s>>12&2047;const a=s>>23&255;return a<103?r:a>142?(r|=31744,255===a&&8388607&s&&(r|=512),r):a<113?(o|=2048,r|=(o>>114-a)+(o>>113-a&1),r):(r|=a-112<<10|o>>1,r+=1&o,r)}(t);this.writeUint16(i)}writeFloat32(t){const i=this.position+4;this.ensureCapacity(i),this.dataView.setFloat32(this.position,t,this.endianness),this.position=i}writeFloat64(t){const i=this.position+8;this.ensureCapacity(i),this.dataView.setFloat64(this.position,t,this.endianness),this.position=i}writeInt8(t){const i=this.position+1;this.ensureCapacity(i),this.dataView.setInt8(this.position,t),this.position=i}writeInt16(t){const i=this.position+2;this.ensureCapacity(i),this.dataView.setInt16(this.position,t,this.endianness),this.position=i}writeInt16BE(i){const e=this.position+2;this.ensureCapacity(e),this.dataView.setInt16(this.position,i,t),this.position=e}writeInt16LE(t){const e=this.position+2;this.ensureCapacity(e),this.dataView.setInt16(this.position,t,i),this.position=e}writeInt32(t){const i=this.position+4;this.ensureCapacity(i),this.dataView.setInt32(this.position,t,this.endianness),this.position=i}writeInt32BE(i){const e=this.position+4;this.ensureCapacity(e),this.dataView.setInt32(this.position,i,t),this.position=e}writeInt32LE(t){const e=this.position+4;this.ensureCapacity(e),this.dataView.setInt32(this.position,t,i),this.position=e}writeInt64(t){const i=this.position+8;this.ensureCapacity(i),this.dataView.setBigInt64(this.position,t,this.endianness),this.position=i}writeInt8Array(t,i,e){this.ensureCapacity(this.position+e);for(let n=0;n<e;n++)this.writeInt8(t[i+n])}writeInt16Array(t,i,e){this.ensureCapacity(this.position+2*e);for(let n=0;n<e;n++)this.writeInt16(t[i+n])}writeInt32Array(t,i,e){this.ensureCapacity(this.position+4*e);for(let n=0;n<e;n++)this.writeInt32(t[i+n])}writeUint8(t){const i=this.position+1;this.ensureCapacity(i),this.dataView.setUint8(this.position,t),this.position=i}writeUint8Array(t,i,e){for(let n=0;n<e;n++)this.writeUint8(t[i+n])}writeUint16(t){const i=this.position+2;this.ensureCapacity(i),this.dataView.setUint16(this.position,t,this.endianness),this.position=i}writeUint16BE(i){const e=this.position+2;this.ensureCapacity(e),this.dataView.setUint16(this.position,i,t),this.position=e}writeUint16LE(t){const e=this.position+2;this.ensureCapacity(e),this.dataView.setUint16(this.position,t,i),this.position=e}writeUint16Array(t,i,e){for(let n=0;n<e;n++)this.writeUint16(t[i+n])}writeUint24(i){this.endianness===t?this.writeUint24BE(i):this.writeUint24LE(i)}writeUint24BE(t){const i=this.position+3;this.ensureCapacity(i);const e=255&t,n=t>>8&255,s=t>>16&255;this.dataView.setUint8(this.position,s),this.dataView.setUint8(this.position+1,n),this.dataView.setUint8(this.position+2,e),this.position=i}writeUint24LE(t){const i=this.position+3;this.ensureCapacity(i);const e=255&t,n=t>>8&255,s=t>>16&255;this.dataView.setUint8(this.position,e),this.dataView.setUint8(this.position+1,n),this.dataView.setUint8(this.position+2,s),this.position=i}writeUintVar(t){if((0|t)!==t||t<0)throw new RangeError(`value=[${t}] must be an integer in [0, 2147483647]`);let i=!0,e=t;for(;i||0!==e;){i=!1;let t=127&e;e>>=7,e>0&&(t|=128),this.writeUint8(t)}}readUintVar(){let t=!0,i=0,e=0;for(;t;){let n=this.readUint8();if(t=!!(128&n),i+=(127&n)*2**e,e+=7,t&&e>28)throw new Error("uintVar is too long, more than 5 bytes")}return i}writeUint32(t){const i=this.position+4;this.ensureCapacity(i),this.dataView.setUint32(this.position,t,this.endianness),this.position=i}writeUint32BE(i){const e=this.position+4;this.ensureCapacity(e),this.dataView.setUint32(this.position,i,t),this.position=e}writeUint32LE(t){const e=this.position+4;this.ensureCapacity(e),this.dataView.setUint32(this.position,t,i),this.position=e}writeUint64(t){const i=this.position+8;this.ensureCapacity(i),this.dataView.setBigUint64(this.position,t,this.endianness),this.position=i}writeUint32Array(t,i,e){this.ensureCapacity(this.position+4*e);for(let n=0;n<e;n++)this.writeUint32(t[i+n])}writeBytes(t,i,e){const n=i+e,s=this.position,r=s+e;if(this.ensureCapacity(r),0===i&&t.length===e)this.__data_uint8.set(t,s);else if(e>=2048&&"function"==typeof t.subarray)this.__data_uint8.set(t.subarray(i,n),s);else{const n=this.__data_uint8;if(t.byteOffset+i>=n.byteOffset+s)for(let r=0;r<e;r++)n[s+r]=t[i+r];else for(let r=e-1;r>=0;r--)n[s+r]=t[i+r]}this.position=r}readBytes(t,i,e){const n=this.position,s=n+e,r=this.__data_uint8;if(e<0||s>this.capacity)throw new Error(`Attempting to read ${e} bytes at position ${n}, only ${this.capacity-n} available`);e<128?function(t,i,e,n,s){if(ArrayBuffer.isView(t)&&ArrayBuffer.isView(e)&&t.buffer===e.buffer&&void 0!==t.BYTES_PER_ELEMENT&&void 0!==e.BYTES_PER_ELEMENT){const r=t.byteOffset+i*t.BYTES_PER_ELEMENT,o=e.byteOffset+n*e.BYTES_PER_ELEMENT;if(r<o+s*e.BYTES_PER_ELEMENT&&o<r+s*t.BYTES_PER_ELEMENT)return void e.set(t.subarray(i,i+s),n)}if(t===e&&n>i&&n<i+s){for(let r=s-1;r>=0;r--)e[n+r]=t[i+r];return}let r,o,a;for(a=0;a<s;a++)r=i+a,o=n+a,e[o]=t[r]}(r,n,t,i,e):t.set(r.subarray(n,s),i),this.position=s}writeUTF8String(t){if(null===t)return void this.writeUint32(4294967295);if(void 0===t)return void this.writeUint32(4294967294);let i=0;const e=t.length;if(e>=4294967294)throw new Error("String is too long");this.writeUint32(e);let n=this.position;const s=Math.max(32,e+(e>>1)+7);this.ensureCapacity(s+n);let r=this.__data_uint8,o=this.capacity;for(;i<e;){let s=t.charCodeAt(i++);if(s>=55296&&s<=56319){if(i<e){const e=t.charCodeAt(i);56320==(64512&e)&&(++i,s=((1023&s)<<10)+(1023&e)+65536)}s>=55296&&s<=56319&&(s=65533)}if(n+4>o&&(this.position=n,this.ensureCapacity(n+4),o=this.capacity,r=this.__data_uint8),4294967168&s){if(4294965248&s)if(4294901760&s){if(4292870144&s)continue;r[n++]=s>>18&7|240,r[n++]=s>>12&63|128,r[n++]=s>>6&63|128}else r[n++]=s>>12&15|224,r[n++]=s>>6&63|128;else r[n++]=s>>6&31|192;r[n++]=63&s|128}else r[n++]=s}this.position=n}readUTF8String(){const t=this.readUint32();if(4294967295===t)return null;if(4294967294===t)return;const i=this.__data_uint8;let e="",n=this.position,s=0;for(;n<this.capacity&&s<t;){const t=i[n++];let r;128&t?192==(224&t)?r=(31&t)<<6|63&i[n++]:224==(240&t)?r=(31&t)<<12|(63&i[n++])<<6|63&i[n++]:240==(248&t)&&(r=(7&t)<<18|(63&i[n++])<<12|(63&i[n++])<<6|63&i[n++],r>65535&&(r-=65536,e+=String.fromCharCode(r>>>10&1023|55296),s++,r=56320|1023&r)):r=t,s++,e+=String.fromCharCode(r)}return this.position=n,e}writeASCIIString(t){const i=t.length,e=this.position,n=e+i;this.ensureCapacity(n);for(let n=0;n<i;n++){const i=t.charCodeAt(n);if(i>127)throw new Error(`Character ${String.fromCharCode(i)} can't be represented by a US-ASCII byte.`);this.__data_uint8[e+n]=i}this.position=n}readASCIICharacters(t,i=!1){let e="";for(let n=0;n<t;n++){const t=this.readUint8();if(i&&0===t)break;e+=String.fromCharCode(t)}return e}toString(){return`BinaryBuffer[position=${this.position}, capacity=${this.capacity}, endianness=${this.endianness}]`}toHexString(){const t=this.__data_uint8,i=Math.min(t.length,this.position);let e="";for(let n=0;n<i;n++)e+=t[n].toString(16).padStart(2,"0").toUpperCase();return e}static fromEndianness(t){const i=new s;return i.endianness=t,i}static fromArrayBuffer(t){const i=new s;return i.fromArrayBuffer(t),i}static copyUTF8String(t,i){const e=t.readUTF8String();return i.writeUTF8String(e),e}static copyUintVar(t,i){const e=t.readUintVar();return i.writeUintVar(e),e}static copyUint8(t,i){const e=t.readUint8();return i.writeUint8(e),e}static copyUint16(t,i){const e=t.readUint16();return i.writeUint16(e),e}static copyUint32(t,i){const e=t.readUint32();return i.writeUint32(e),e}static copyFloat32(t,i){const e=t.readFloat32();return i.writeFloat32(e),e}static copyFloat64(t,i){const e=t.readFloat64();return i.writeFloat64(e),e}static copyBytes(t,i,e){const n=new Uint8Array(e);return t.readBytes(n,0,e),i.writeBytes(n,0,e),n}}s.prototype.isBinaryBuffer=!0;let r=i,o=!1;function a(t,i=0,e=t.length){let n="",s=i;for(;s<e;){const i=t[s++];if(i<128)n+=String.fromCharCode(i);else if(i<224)n+=String.fromCharCode((31&i)<<6|(s<e?63&t[s++]:0));else if(i<240)n+=String.fromCharCode((15&i)<<12|(s<e?63&t[s++]:0)<<6|(s<e?63&t[s++]:0));else{const r=((7&i)<<18|(s<e?63&t[s++]:0)<<12|(s<e?63&t[s++]:0)<<6|(s<e?63&t[s++]:0))-65536;n+=String.fromCharCode(55296+(r>>10),56320+(1023&r))}}return n}async function h(t,i="deflate"){const e=function(t){let i=0;return new ReadableStream({pull(e){i===t.length?e.close():e.enqueue(t[i++])}})}(t).pipeThrough(new DecompressionStream(i));return new Uint8Array(await new Response(e).arrayBuffer())}async function c(t,i=!1){try{return await h(t)}catch(e){if(i){const i=function(t){const i=t.length;if(1===i)return t[0];let e=0;for(let n=0;n<i;n++)e+=t[n].length;const n=new Uint8Array(e);let s=0;for(let e=0;e<i;e++)n.set(t[e],s),s+=t[e].length;return n}(t),e=i[0],n=i[1];if(i.length>=6&&8==(15&e)&&e>>>4<=7&&(e<<8|n)%31==0&&!(32&n))try{return await h([i.subarray(2,i.length-4)],"deflate-raw")}catch{}}throw new Error(`failed to inflate zlib stream: ${e?.message||"invalid or truncated data"}`)}}const p=new Uint32Array(256);for(let t=0;t<256;t++){let i=t;for(let t=0;t<8;t++)1&i?i=3988292384^i>>>1:i>>>=1;p[t]=i}const d=Object.freeze([function(t,i,e,n,s,r,o){for(let n=0;n<o;n++)e[s+n]=t[i+n]},function(t,i,e,n,s,r,o){let a=0;for(;a<n;a++)e[s+a]=t[a+i];for(;a<o;a++){const r=s+a;e[r]=t[a+i]+e[r-n]&255}},function(t,i,e,n,s,r,o){let a,h,c=0;if(r<0)for(;c<o;c++)e[s+c]=t[c+i];else for(;c<o;c++)a=t[c+i],h=e[r+c],e[s+c]=a+h&255},function(t,i,e,n,s,r,o){let a,h,c,p=0;if(r<0){for(;p<n;p++)e[s+p]=t[p+i];for(;p<o;p++){const r=s+p;e[r]=t[p+i]+(e[r-n]>>1)&255}}else{for(;p<n;p++)e[s+p]=t[p+i]+(e[r+p]>>1)&255;for(;p<o;p++)a=t[p+i],h=e[s+p-n],c=e[r+p],e[s+p]=a+(h+c>>1)&255}},function(t,i,e,n,s,r,o){let a,h,c,p,d,f,l,u,w,y=0;if(r<0){for(;y<n;y++)e[s+y]=t[y+i];for(;y<o;y++)e[s+y]=t[y+i]+e[s+y-n]&255}else{for(;y<n;y++)e[s+y]=t[y+i]+e[r+y]&255;for(;y<o;y++)a=t[y+i],p=e[r+y-n],c=e[r+y],h=e[s+y-n],d=h+c-p,f=Math.abs(d-h),l=Math.abs(d-c),u=Math.abs(d-p),w=f<=l&&f<=u?h:l<=u?c:p,e[s+y]=a+w&255}}]);function f(t,i,e,n,s,r,o,a){const h=d[t];if(void 0===h)throw new Error(`unknown filtered scanline type '${t}'`);h(i,e,n,s,r,o,a)}function l(t,i,e,n,s,r){if(1!==e&&2!==e&&4!==e)throw new Error(`only bit depths below 8 are packed, got ${e}`);const o=(1<<e)-1;for(let a=0;a<n;a++){const n=a*e,h=t[i+(n>>3)],c=8-e-(7&n);s[r+a]=h>>>c&o}}class u{width=0;height=0;bitDepth=0;colorType=0;compressionMethod=0;filterMethod=0;interlaceMethod=0;colors=0;alpha=!1;palette=null;pixels=null;transparency_lookup=null;text={};getWidth(){return this.width}setWidth(t){this.width=t}getHeight(){return this.height}setHeight(t){this.height=t}getBitDepth(){return this.bitDepth}setBitDepth(t){if(-1===[1,2,4,8,16].indexOf(t))throw new Error("invalid bith depth "+t);this.bitDepth=t}getColorType(){return this.colorType}setColorType(t){let i=0,e=!1;switch(t){case 0:case 3:i=1;break;case 2:i=3;break;case 4:i=2,e=!0;break;case 6:i=4,e=!0;break;default:throw new Error("invalid color type")}this.colors=i,this.alpha=e,this.colorType=t}setCompressionMethod(t){if(0!==t)throw new Error("invalid compression method "+t);this.compressionMethod=t}setFilterMethod(t){if(0!==t)throw new Error("invalid filter method "+t);this.filterMethod=t}getInterlaceMethod(){return this.interlaceMethod}setInterlaceMethod(t){if(0!==t&&1!==t)throw new Error("invalid interlace method "+t);this.interlaceMethod=t}setPalette(t){if(t.length%3!=0)throw new Error("incorrect PLTE chunk length");if(t.length>3*Math.pow(2,this.bitDepth))throw new Error("palette has more colors than 2^bitdepth");this.palette=t}getUint8Data_case3(){const t=this.width*this.height;let i;const e=this.transparency_lookup;i=null!==e?4:3;const n=new Uint8Array(t*i),s=this.pixels,r=this.palette,o=this.colors*Math.ceil(this.bitDepth/8);for(let e=0;e<t;e++){const t=e*i,a=3*s[e*o];n[t]=r[a],n[t+1]=r[a+1],n[t+2]=r[a+2]}if(null!==e){const i=e.length;for(let r=0;r<t;r++){const t=s[r*o];n[4*r+3]=t>=i?255:e[t]}}return{data:n,itemSize:i}}getUint8Data(){let t,i=0;switch(this.colorType){case 0:t=this.pixels,i=1;break;case 2:t=this.pixels,i=3;break;case 3:const e=this.getUint8Data_case3();t=e.data,i=e.itemSize;break;case 4:t=this.pixels,i=2;break;case 6:t=this.pixels,i=4;break;default:throw new Error("Unsupported color type")}return{data:t,itemSize:i}}}const w=[137,80,78,71,13,10,26,10];function y(t,i){return t[i]<<24|t[i+1]<<16|t[i+2]<<8|t[i+3]}function g(t,i){return t[i]}function U(i){this.png=new u,this.dataChunks=[],this.buffer=new s,this.buffer.endianness=t,this.buffer.fromArrayBuffer(i),this.crc_enabled=!1}U.prototype.readBytes=function(t){const i=this.buffer,e=new Uint8Array(i.data,i.position,t);return i.skip(t),e},U.prototype.decodeHeader=function(){const t=this.buffer,i=new Uint8Array(w.length);if(t.readBytes(i,0,i.length),!function(t,i){const e=t.length;if(e!==i.length)return!1;for(let n=0;n<e;n++)if(t[n]!==i[n])return!1;return!0}(i,w))throw new Error("invalid PNGReader file (bad signature)")},U.prototype.decodeChunk=async function(){const t=this.buffer,i=t.readUint32();if(i<0)throw new Error("Bad chunk length "+(4294967295&i));const e=t.position,n=t.readASCIICharacters(4),r=this.readBytes(i);switch(t.readUint32(),this.crc_enabled&&function(t,i=0,e=t.length){!function(t,i,e,n){let s=4294967295;const r=e+n;for(let t=e;t<r;t++){const e=i[t];s=p[255&(s^e)]^s>>>8}}(0,t,i,e)}(t.raw_bytes,e,i+4),n){case"IHDR":this.decodeIHDR(r);break;case"PLTE":this.decodePLTE(r);break;case"IDAT":this.decodeIDAT(r);break;case"tRNS":this.decodeTRNS(r);break;case"IEND":this.decodeIEND(r);break;case"sRGB":this.decodesRGB(r);break;case"tIME":this.decodetIME(r);break;case"zTXt":await async function(t){const i=t.byteLength,e=t.buffer,n=t.byteOffset,r=s.fromArrayBuffer(e);r.position=n;const o=r.readASCIICharacters(79,!0),a=r.readUint8();let h;if(0!==a)throw new Error(`Unsupported compression method '${a}'`);{const t=r.position-n,s=new Uint8Array(e,r.position,i-t),o=await c([s]);r.fromArrayBuffer(o.buffer),h=r.readASCIICharacters(o.byteLength)}return{keyword:o,text:h}}(r);break;case"iTXt":await async function(t){const i=t.byteLength,e=t.buffer,n=t.byteOffset,r=n+i,o=s.fromArrayBuffer(e);o.position=n;const h=o.readASCIICharacters(80,!0);if(h.length>79)throw new Error("iTXt keyword exceeds 79 bytes");const p=o.readUint8(),d=o.readUint8(),f=o.readASCIICharacters(Number.MAX_SAFE_INTEGER,!0),l=o.position-n;let u=l;for(;u<i&&0!==t[u];)u++;if(u>=i)throw new Error("iTXt translated keyword is not terminated");const w=a(t,l,u);o.position=n+u+1;const y=r-o.position;let g;if(0===p)g=a(t,o.position-n,i);else{if(1!==p)throw new Error(`Invalid compression flag value '${p}'`);if(0!==d)throw new Error("only compression_method 0 is supported");g=a(await c([new Uint8Array(o.data,o.position,y)]))}return{keyword:h,language_tag:f,translated_keyword:w,text:g}}(r)}return n},U.prototype.decodesRGB=function(t){g(t,0)},U.prototype.decodetIME=function(t){g(t,0),g(t,1),g(t,2),g(t,3),g(t,4),g(t,5),g(t,6)},U.prototype.decodetEXt=function(t){const i=s.fromArrayBuffer(t.buffer),e=i.readASCIICharacters(Number.POSITIVE_INFINITY,!0),n=i.readASCIICharacters(e.length-1,!1);this.png.text[e]=n},U.prototype.decodeiEXt=function(t){const i=s.fromArrayBuffer(t.buffer),e=i.readASCIICharacters(Number.POSITIVE_INFINITY,!0);if(i.readUint8(),i.readUint8(),i.readASCIICharacters(Number.POSITIVE_INFINITY,!0),i.readUTF8String(),0!==i.readUint8())throw new Error("Expected Null Separator after Translated keyword");const n=i.readUTF8String();this.png.text[e]=n},U.prototype.decodeIHDR=function(t){const i=this.png;i.setWidth(y(t,0)),i.setHeight(y(t,4)),i.setBitDepth(g(t,8)),i.setColorType(g(t,9)),i.setCompressionMethod(g(t,10)),i.setFilterMethod(g(t,11)),i.setInterlaceMethod(g(t,12))},U.prototype.decodePLTE=function(t){this.png.setPalette(t)},U.prototype.decodeIDAT=function(t){this.dataChunks.push(t)},U.prototype.decodeTRNS=function(t){this.png.transparency_lookup=t},U.prototype.decodeIEND=function(){},U.prototype.decodePixels=async function(){const e=this.png,n=await c(this.dataChunks,!0);if(0===e.getInterlaceMethod()?this.png.pixels=this.interlaceNone(n):this.png.pixels=this.interlaceAdam7(n),16===e.bitDepth&&function(){if(o)return r;const e=new ArrayBuffer(2),n=new Uint8Array(e),s=new Uint16Array(e);return n[0]=19,r=19==(255&s[0])?i:t,o=!0,r}()===i){const t=this.png.pixels;for(let i=0;i<t.length;i+=2){const e=t[i];t[i]=t[i+1],t[i+1]=e}}},U.prototype.interlaceNone=function(t){const i=this.png,e=i.bitDepth,n=i.colors,s=i.width,r=i.height,o=Math.max(1,Math.ceil(n*e/8)),a=Math.ceil(n*e*s/8);if(e<8)return function(t,i,e,n,s,r){const o=new Uint8Array(e*r),a=new Uint8Array(2*s),h=Math.floor(t.length/(s+1)),c=r<h?r:h;let p=0,d=-1;for(let r=0;r<c;r++){const h=(1&r)*s;f(t[p++],t,p,a,n,h,d,s),p+=s,l(a,h,i,e,o,r*e),d=h}return o}(t,e,n*s,o,a,r);const h=new Uint8Array(a*r);let c=0;const p=t.length;for(let i=0;i<p;i+=a+1){const e=i+1;f(t[i],t,e,h,o,c,c-a,a),c+=a}return h},U.prototype.interlaceAdam7=function(t){const i=this.png,e=i.bitDepth,n=i.colors,s=i.width,r=i.height,o=e<8,a=Math.max(1,Math.ceil(n*e/8)),h=n*(16===e?2:1),c=new Uint8Array(h*s*r),p=[{x:0,y:0,xStep:8,yStep:8},{x:4,y:0,xStep:8,yStep:8},{x:0,y:4,xStep:4,yStep:8},{x:2,y:0,xStep:4,yStep:4},{x:0,y:2,xStep:2,yStep:4},{x:1,y:0,xStep:2,yStep:2},{x:0,y:1,xStep:1,yStep:2}];let d=0;const u=new Uint8Array(2*Math.ceil(n*e*s/8)),w=o?new Uint8Array(n*s):null;for(let i=0;i<7;i++){const y=p[i],g=Math.ceil((s-y.x)/y.xStep),U=Math.ceil((r-y.y)/y.yStep);if(g<=0||U<=0)continue;const E=n*g,I=Math.ceil(E*e/8);let b=-1;for(let i=0;i<U;i++){const n=i%2*I;f(t[d++],t,d,u,a,n,b,I),d+=I,b=n;let p=u,U=n;o&&(l(u,n,e,E,w,0),p=w,U=0);for(let t=0;t<g;t++){const e=y.x+t*y.xStep,n=y.y+i*y.yStep;if(!(e>=s||n>=r))for(let i=0;i<h;i++)c[(n*s+e)*h+i]=p[U+t*h+i]}}}return c},U.prototype.unFilter=function(t,i,e,n,s,r,o,a){f(t,i,e,n,s,r,o,a)},U.prototype.parse=async function(){for(this.decodeHeader();"IEND"!==await this.decodeChunk(););return await this.decodePixels(),this.png},self.Lib={decode:async function(t,i="png"){if(!(t instanceof ArrayBuffer))throw new Error(".data argument must be an ArrayBuffer, instead was something else");if("png"===i.toLowerCase())return await async function(t){const i=await new U(t).parse(),e=i.getUint8Data();return{data:e.data.buffer,width:i.getWidth(),height:i.getHeight(),itemSize:e.itemSize,bitDepth:i.getBitDepth()}}(t);throw new Error("Unsupported type")}};
|