@woosh/meep-engine 3.45.0 → 3.46.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (216) hide show
  1. package/build/bundle-worker-terrain.js +1 -1
  2. package/package.json +1 -1
  3. package/src/core/assert.d.ts.map +1 -1
  4. package/src/core/assert.js +5 -1
  5. package/src/core/binary/hash/XXH128Hash.d.ts +1 -37
  6. package/src/core/binary/hash/XXH128Hash.d.ts.map +1 -1
  7. package/src/core/binary/hash/XXH128Hash.js +4 -55
  8. package/src/core/binary/hash/XXH3_SECRET.d.ts +1 -12
  9. package/src/core/binary/hash/XXH3_SECRET.d.ts.map +1 -1
  10. package/src/core/binary/hash/XXH3_SECRET.js +4 -25
  11. package/src/core/binary/hash/crc32.d.ts +1 -15
  12. package/src/core/binary/hash/crc32.d.ts.map +1 -1
  13. package/src/core/binary/hash/crc32.js +4 -96
  14. package/src/core/binary/hash/xxh3_128.d.ts +1 -9
  15. package/src/core/binary/hash/xxh3_128.d.ts.map +1 -1
  16. package/src/core/binary/hash/xxh3_128.js +4 -341
  17. package/src/core/binary/hash/xxh3_64.d.ts +1 -8
  18. package/src/core/binary/hash/xxh3_64.d.ts.map +1 -1
  19. package/src/core/binary/hash/xxh3_64.js +4 -241
  20. package/src/core/binary/hash/xxh3_common.d.ts +1 -223
  21. package/src/core/binary/hash/xxh3_common.d.ts.map +1 -1
  22. package/src/core/binary/hash/xxh3_common.js +90 -476
  23. package/src/core/collection/array/combine_hash.d.ts +6 -0
  24. package/src/core/collection/array/combine_hash.d.ts.map +1 -1
  25. package/src/core/collection/array/combine_hash.js +6 -0
  26. package/src/core/function/FunctionCompiler.js +2 -2
  27. package/src/core/geom/3d/mat4/m4_multiply.d.ts +3 -0
  28. package/src/core/geom/3d/mat4/m4_multiply.d.ts.map +1 -1
  29. package/src/core/geom/3d/mat4/m4_multiply.js +3 -0
  30. package/src/core/geom/3d/mat4/m4_multiply_f64.d.ts +30 -0
  31. package/src/core/geom/3d/mat4/m4_multiply_f64.d.ts.map +1 -0
  32. package/src/core/geom/3d/mat4/m4_multiply_f64.js +106 -0
  33. package/src/core/geom/ConicRay.js +2 -2
  34. package/src/core/geom/Vector4.d.ts.map +1 -1
  35. package/src/core/geom/Vector4.js +8 -5
  36. package/src/core/math/hash/XXH128Hash.d.ts +38 -0
  37. package/src/core/math/hash/XXH128Hash.d.ts.map +1 -0
  38. package/src/core/math/hash/XXH128Hash.js +55 -0
  39. package/src/core/math/hash/XXH3_SECRET.d.ts +13 -0
  40. package/src/core/math/hash/XXH3_SECRET.d.ts.map +1 -0
  41. package/src/core/math/hash/XXH3_SECRET.js +25 -0
  42. package/src/core/math/hash/crc32.d.ts +16 -0
  43. package/src/core/math/hash/crc32.d.ts.map +1 -0
  44. package/src/core/math/hash/crc32.js +96 -0
  45. package/src/core/math/hash/xxh3_128.d.ts +10 -0
  46. package/src/core/math/hash/xxh3_128.d.ts.map +1 -0
  47. package/src/core/math/hash/xxh3_128.js +341 -0
  48. package/src/core/math/hash/xxh3_64.d.ts +9 -0
  49. package/src/core/math/hash/xxh3_64.d.ts.map +1 -0
  50. package/src/core/math/hash/xxh3_64.js +241 -0
  51. package/src/core/math/hash/xxh3_common.d.ts +224 -0
  52. package/src/core/math/hash/xxh3_common.d.ts.map +1 -0
  53. package/src/core/math/hash/xxh3_common.js +476 -0
  54. package/src/core/math/lookup/ParameterLookupTable.js +2 -2
  55. package/src/core/model/node-graph/node/NodeInstancePortReference.js +2 -2
  56. package/src/core/model/reactive/model/ReactiveBinaryExpression.js +2 -2
  57. package/src/core/model/reactive/model/terminal/ReactiveReference.js +2 -2
  58. package/src/engine/asset/AssetDescription.js +2 -2
  59. package/src/engine/ecs/animation/Animation.js +2 -2
  60. package/src/engine/ecs/animation/AnimationClip.d.ts.map +1 -1
  61. package/src/engine/ecs/animation/AnimationClip.js +7 -5
  62. package/src/engine/ecs/gui/GUIElement.d.ts.map +1 -1
  63. package/src/engine/ecs/gui/GUIElement.js +7 -5
  64. package/src/engine/ecs/gui/hud/HeadsUpDisplay.js +2 -2
  65. package/src/engine/ecs/gui/position/ViewportPosition.d.ts.map +1 -1
  66. package/src/engine/ecs/gui/position/ViewportPosition.js +11 -7
  67. package/src/engine/ecs/transform/Transform64.d.ts +1 -1
  68. package/src/engine/ecs/transform/Transform64.d.ts.map +1 -1
  69. package/src/engine/ecs/transform/Transform64.js +5 -4
  70. package/src/engine/graphics/ecs/animation/animator/AnimationClip.d.ts.map +1 -1
  71. package/src/engine/graphics/ecs/animation/animator/AnimationClip.js +8 -5
  72. package/src/engine/graphics/ecs/animation/animator/AnimationClipDefinition.js +2 -2
  73. package/src/engine/graphics/ecs/animation/animator/AnimationNotification.js +2 -2
  74. package/src/engine/graphics/ecs/animation/animator/AnimationNotificationDefinition.js +2 -2
  75. package/src/engine/graphics/ecs/animation/animator/graph/definition/AnimationGraphDefinition.js +2 -2
  76. package/src/engine/graphics/ecs/animation/animator/graph/definition/AnimationStateDefinition.js +2 -2
  77. package/src/engine/graphics/ecs/animation/animator/graph/definition/AnimationTransitionDefinition.d.ts.map +1 -1
  78. package/src/engine/graphics/ecs/animation/animator/graph/definition/AnimationTransitionDefinition.js +8 -5
  79. package/src/engine/graphics/ecs/decal/v2/Decal.d.ts.map +1 -1
  80. package/src/engine/graphics/ecs/decal/v2/Decal.js +9 -8
  81. package/src/engine/graphics/render/frame_graph/resource/TextureResourceDescriptor.d.ts.map +1 -1
  82. package/src/engine/graphics/render/frame_graph/resource/TextureResourceDescriptor.js +9 -6
  83. package/src/engine/graphics3/ParticipatingMedia.js +204 -204
  84. package/src/engine/graphics3/animation/AnimationClips.d.ts +5 -0
  85. package/src/engine/graphics3/animation/AnimationClips.d.ts.map +1 -1
  86. package/src/engine/graphics3/animation/AnimationClips.js +5 -0
  87. package/src/engine/grid/obstacle/GridObstacle.js +2 -2
  88. package/src/engine/intelligence/behavior/selector/WeightedElement.js +2 -2
  89. package/src/engine/interpolation/Interpolated.js +2 -2
  90. package/src/engine/physics/cloth/ecs/Cloth.d.ts.map +1 -1
  91. package/src/engine/physics/cloth/ecs/Cloth.js +7 -5
  92. package/src/engine/physics/cloth/ecs/ClothCollider.d.ts.map +1 -1
  93. package/src/engine/physics/cloth/ecs/ClothCollider.js +7 -5
  94. package/src/engine/physics/cloth/ecs/ClothDynamics.d.ts.map +1 -1
  95. package/src/engine/physics/cloth/ecs/ClothDynamics.js +20 -11
  96. package/src/engine/physics/fluid/FluidField.d.ts.map +1 -1
  97. package/src/engine/physics/fluid/FluidField.js +7 -5
  98. package/src/engine/physics/fluid/ecs/FluidComponent.d.ts.map +1 -1
  99. package/src/engine/physics/fluid/ecs/FluidComponent.js +19 -11
  100. package/src/engine/physics/fluid/effector/AbstractFluidEffector.d.ts +2 -2
  101. package/src/engine/physics/fluid/effector/AbstractFluidEffector.js +2 -2
  102. package/src/engine/physics/fluid/effector/GlobalFluidEffector.d.ts.map +1 -1
  103. package/src/engine/physics/fluid/effector/GlobalFluidEffector.js +11 -7
  104. package/src/engine/physics/fluid/effector/ImpulseFluidEffector.d.ts.map +1 -1
  105. package/src/engine/physics/fluid/effector/ImpulseFluidEffector.js +11 -7
  106. package/src/engine/physics/fluid/effector/WakeFluidEffector.d.ts.map +1 -1
  107. package/src/engine/physics/fluid/effector/WakeFluidEffector.js +16 -9
  108. package/src/engine/sound/ecs/audio/AudioEmitter.d.ts.map +1 -1
  109. package/src/engine/sound/ecs/audio/AudioEmitter.js +12 -7
  110. package/src/engine/sound/ecs/trigger/AudioEventTrigger.d.ts.map +1 -1
  111. package/src/engine/sound/ecs/trigger/AudioEventTrigger.js +192 -191
  112. package/src/engine/sound/simulation/core/AcousticMedium.js +2 -2
  113. package/src/engine/sound/simulation/definition/AcousticDirectivity.js +2 -2
  114. package/src/engine/sound/simulation/definition/AcousticMaterial.d.ts.map +1 -1
  115. package/src/engine/sound/simulation/definition/AcousticMaterial.js +11 -7
  116. package/src/engine/sound/sopra/definition/BusDefinition.d.ts.map +1 -1
  117. package/src/engine/sound/sopra/definition/BusDefinition.js +5 -4
  118. package/src/engine/sound/sopra/definition/DuckingRule.d.ts.map +1 -1
  119. package/src/engine/sound/sopra/definition/DuckingRule.js +7 -5
  120. package/src/engine/sound/sopra/definition/EventDescription.d.ts.map +1 -1
  121. package/src/engine/sound/sopra/definition/EventDescription.js +23 -13
  122. package/src/engine/sound/sopra/definition/MixerSnapshot.js +2 -2
  123. package/src/engine/sound/sopra/definition/ParameterDefinition.d.ts.map +1 -1
  124. package/src/engine/sound/sopra/definition/ParameterDefinition.js +7 -5
  125. package/src/engine/sound/sopra/definition/clip/AbstractAudioClip.js +2 -2
  126. package/src/engine/sound/sopra/definition/clip/BlendContainerAudioClip.d.ts.map +1 -1
  127. package/src/engine/sound/sopra/definition/clip/BlendContainerAudioClip.js +4 -3
  128. package/src/engine/sound/sopra/definition/clip/ContainerAudioClip.js +2 -2
  129. package/src/engine/sound/sopra/definition/clip/RandomContainerAudioClip.js +3 -3
  130. package/src/engine/sound/sopra/definition/clip/SampleAudioClip.d.ts.map +1 -1
  131. package/src/engine/sound/sopra/definition/clip/SampleAudioClip.js +16 -9
  132. package/src/engine/sound/sopra/definition/clip/SilenceAudioClip.js +2 -2
  133. package/src/engine/sound/sopra/definition/clip/SwitchContainerAudioClip.d.ts +1 -1
  134. package/src/engine/sound/sopra/definition/clip/SwitchContainerAudioClip.d.ts.map +1 -1
  135. package/src/engine/sound/sopra/definition/clip/SwitchContainerAudioClip.js +2 -2
  136. package/src/engine/sound/sopra/definition/effect/CompressorEffect.d.ts.map +1 -1
  137. package/src/engine/sound/sopra/definition/effect/CompressorEffect.js +7 -5
  138. package/src/engine/sound/sopra/definition/effect/EqEffect.d.ts.map +1 -1
  139. package/src/engine/sound/sopra/definition/effect/EqEffect.js +8 -5
  140. package/src/engine/sound/sopra/definition/effect/ReverbEffect.js +2 -2
  141. package/src/engine/sound/sopra/legacy/SoundEmitter.d.ts.map +1 -1
  142. package/src/engine/sound/sopra/legacy/SoundEmitter.js +357 -352
  143. package/src/engine/sound/sopra/legacy/SoundTrack.d.ts.map +1 -1
  144. package/src/engine/sound/sopra/legacy/SoundTrack.js +281 -278
  145. package/src/format/image/png/PNGReader.js +644 -644
  146. package/src/format/image/png/crc32.d.ts +1 -1
  147. package/src/format/image/png/crc32.js +7 -8
  148. package/src/shade/descriptor/binding/BindGroupLayoutDescriptor.js +2 -2
  149. package/src/shade/descriptor/binding/BindGroupLayoutEntry.d.ts.map +1 -1
  150. package/src/shade/descriptor/binding/BindGroupLayoutEntry.js +12 -8
  151. package/src/shade/descriptor/binding/StorageTextureBindingLayout.js +2 -2
  152. package/src/shade/descriptor/binding/TextureBindingLayout.js +2 -2
  153. package/src/shade/descriptor/blend/BlendComponent.js +2 -2
  154. package/src/shade/descriptor/pipeline/PipelineDescriptorBase.js +2 -2
  155. package/src/shade/descriptor/pipeline/PipelineLayoutDescriptor.js +2 -2
  156. package/src/shade/descriptor/pipeline/ProgrammableStage.js +2 -2
  157. package/src/shade/descriptor/pipeline/compute/ComputePipelineDescriptor.js +2 -2
  158. package/src/shade/descriptor/pipeline/render/ColorTargetState.js +2 -2
  159. package/src/shade/descriptor/pipeline/render/FragmentState.js +2 -2
  160. package/src/shade/descriptor/pipeline/render/PrimitiveState.js +2 -2
  161. package/src/shade/descriptor/pipeline/render/RenderPipelineDescriptor.d.ts.map +1 -1
  162. package/src/shade/descriptor/pipeline/render/RenderPipelineDescriptor.js +8 -5
  163. package/src/shade/descriptor/pipeline/render/VertexAttribute.js +2 -2
  164. package/src/shade/descriptor/texture/SamplerDescriptor.d.ts.map +1 -1
  165. package/src/shade/descriptor/texture/SamplerDescriptor.js +20 -12
  166. package/src/shade/descriptor/texture/TextureDescriptor.d.ts.map +1 -1
  167. package/src/shade/descriptor/texture/TextureDescriptor.js +11 -7
  168. package/src/shade/device/graph/BufferResourceDescriptor.d.ts.map +1 -1
  169. package/src/shade/device/graph/BufferResourceDescriptor.js +196 -193
  170. package/src/shade/device/graph/TextureResourceDescriptor.d.ts.map +1 -1
  171. package/src/shade/device/graph/TextureResourceDescriptor.js +178 -173
  172. package/src/shade/device/timing/profile/sgpt_read_header.js +1 -1
  173. package/src/shade/device/timing/profile/sgpt_read_records.js +1 -1
  174. package/src/shade/device/timing/profile/sgpt_write_header.js +1 -1
  175. package/src/shade/device/timing/profile/sgpt_write_record.js +1 -1
  176. package/src/shade/renderer/binding/BufferBinding.js +2 -2
  177. package/src/shade/renderer/camera/Camera.js +2 -2
  178. package/src/shade/renderer/geometry/Attribute.js +2 -2
  179. package/src/shade/renderer/geometry/Geometry.js +2 -2
  180. package/src/shade/renderer/geometry/geometry_deduplicate_vertices.js +2 -2
  181. package/src/shade/renderer/geometry/meshlet/MeshletBatch.js +2 -2
  182. package/src/shade/renderer/geometry/virtual/format/checksum/vgeo_compute_asset_id.js +13 -13
  183. package/src/shade/renderer/geometry/virtual/format/checksum/vgeo_compute_directory_block_checksum.js +41 -41
  184. package/src/shade/renderer/geometry/virtual/format/checksum/vgeo_compute_frame_checksum.js +41 -41
  185. package/src/shade/renderer/geometry/virtual/format/checksum/vgeo_compute_header_checksum.js +25 -25
  186. package/src/shade/renderer/material/StandardShadeMaterial.d.ts.map +1 -1
  187. package/src/shade/renderer/material/StandardShadeMaterial.js +13 -8
  188. package/src/shade/renderer/scene/optimization/geometry/internal/triangle_fingerprint_stream.d.ts.map +1 -1
  189. package/src/shade/renderer/scene/optimization/geometry/internal/triangle_fingerprint_stream.js +14 -5
  190. package/src/shade/renderer/scene/optimization/sampler2d_from_image_bitmap.js +1 -1
  191. package/src/shade/renderer/shader/type/WGSLStructField.js +2 -2
  192. package/src/shade/renderer/shader/type/WebGPUArray.js +2 -2
  193. package/src/shade/renderer/shader/type/WebGPUStruct.d.ts.map +1 -1
  194. package/src/shade/renderer/shader/type/WebGPUStruct.js +9 -6
  195. package/src/shade/renderer/texture/ShadeTexture.d.ts.map +1 -1
  196. package/src/shade/renderer/texture/ShadeTexture.js +17 -10
  197. package/src/shade/renderer/texture/mipmaps/WebGPUMipmapGenerator.js +2 -2
  198. package/src/shade/renderer/water/surface/chunk_water_surface_sample.d.ts +4 -4
  199. package/src/shade/renderer/water/surface/chunk_water_surface_sample.js +6 -6
  200. package/src/shade/renderer/water/surface/particles/GPUWaterParticles.d.ts.map +1 -1
  201. package/src/shade/renderer/water/surface/particles/GPUWaterParticles.js +46 -55
  202. package/src/shade/renderer/water/surface/particles/WATER_PARTICLE_STRUCT.d.ts +3 -3
  203. package/src/shade/renderer/water/surface/particles/WATER_PARTICLE_STRUCT.d.ts.map +1 -1
  204. package/src/shade/renderer/water/surface/particles/WATER_PARTICLE_STRUCT.js +14 -4
  205. package/src/shade/renderer/water/surface/particles/chunk_water_particle.d.ts +10 -1
  206. package/src/shade/renderer/water/surface/particles/chunk_water_particle.d.ts.map +1 -1
  207. package/src/shade/renderer/water/surface/particles/chunk_water_particle.js +82 -40
  208. package/src/shade/renderer/water/surface/particles/chunk_water_particle_step.d.ts +4 -1
  209. package/src/shade/renderer/water/surface/particles/chunk_water_particle_step.d.ts.map +1 -1
  210. package/src/shade/renderer/water/surface/particles/chunk_water_particle_step.js +8 -4
  211. package/src/shade/renderer/water/surface/particles/shader_water_particles.d.ts +98 -86
  212. package/src/shade/renderer/water/surface/particles/shader_water_particles.d.ts.map +1 -1
  213. package/src/shade/renderer/water/surface/particles/shader_water_particles.js +440 -298
  214. package/src/view/common/HTMLElementCacheKey.d.ts.map +1 -1
  215. package/src/view/common/HTMLElementCacheKey.js +4 -3
  216. package/src/view/minimap/MinimapMarker.js +2 -2
@@ -0,0 +1,224 @@
1
+ /**
2
+ * Truncate to 64 bits.
3
+ * @param {bigint} v
4
+ * @returns {bigint}
5
+ */
6
+ export function u64(v: bigint): bigint;
7
+ /**
8
+ * @param {bigint} a
9
+ * @param {bigint} b
10
+ * @returns {bigint}
11
+ */
12
+ export function mul64(a: bigint, b: bigint): bigint;
13
+ /**
14
+ * @param {bigint} a
15
+ * @param {bigint} b
16
+ * @returns {bigint}
17
+ */
18
+ export function add64(a: bigint, b: bigint): bigint;
19
+ /**
20
+ * Two's-complement 64-bit subtraction.
21
+ * @param {bigint} a
22
+ * @param {bigint} b
23
+ * @returns {bigint}
24
+ */
25
+ export function sub64(a: bigint, b: bigint): bigint;
26
+ /**
27
+ * @param {bigint} v
28
+ * @param {number} bits
29
+ * @returns {bigint}
30
+ */
31
+ export function rotl64(v: bigint, bits: number): bigint;
32
+ /**
33
+ * Rotate within 32 bits, as the reference's `XXH_rotl32`.
34
+ * @param {bigint} v
35
+ * @param {number} bits
36
+ * @returns {bigint}
37
+ */
38
+ export function rotl32(v: bigint, bits: number): bigint;
39
+ /**
40
+ * @param {bigint} v
41
+ * @param {number} bits
42
+ * @returns {bigint}
43
+ */
44
+ export function xorshift64(v: bigint, bits: number): bigint;
45
+ /**
46
+ * Byte-reverse a 32-bit value, as the reference's `XXH_swap32`.
47
+ * @param {bigint} v
48
+ * @returns {bigint}
49
+ */
50
+ export function swap32(v: bigint): bigint;
51
+ /**
52
+ * Byte-reverse a 64-bit value, as the reference's `XXH_swap64`.
53
+ * @param {bigint} v
54
+ * @returns {bigint}
55
+ */
56
+ export function swap64(v: bigint): bigint;
57
+ /**
58
+ * Widening 32x32 -> 64 multiply of the low halves of both operands, as the reference's
59
+ * `XXH_mult32to64`.
60
+ *
61
+ * @param {bigint} a
62
+ * @param {bigint} b
63
+ * @returns {bigint}
64
+ */
65
+ export function mult32to64(a: bigint, b: bigint): bigint;
66
+ /**
67
+ * 64x64 -> 128 multiply, folded down by XOR of the two halves.
68
+ *
69
+ * @param {bigint} a
70
+ * @param {bigint} b
71
+ * @returns {bigint}
72
+ */
73
+ export function mul128_fold64(a: bigint, b: bigint): bigint;
74
+ /**
75
+ * The fast finalizing mix, for input whose bits are already partially mixed.
76
+ * @param {bigint} h64
77
+ * @returns {bigint}
78
+ */
79
+ export function xxh3_avalanche(h64: bigint): bigint;
80
+ /**
81
+ * The stronger finalizing mix (after Pelle Evensen's rrmxmx), for input that has not been mixed yet.
82
+ * @param {bigint} h64
83
+ * @param {number} len
84
+ * @returns {bigint}
85
+ */
86
+ export function xxh3_rrmxmx(h64: bigint, len: number): bigint;
87
+ /**
88
+ * XXH64's finalizing mix, which XXH3 reuses for its shortest inputs.
89
+ * @param {bigint} hash
90
+ * @returns {bigint}
91
+ */
92
+ export function xxh64_avalanche(hash: bigint): bigint;
93
+ /**
94
+ * Read a little-endian u32 at `offset`.
95
+ *
96
+ * @param {Uint8Array} bytes
97
+ * @param {number} offset
98
+ * @returns {bigint}
99
+ */
100
+ export function read_u32(bytes: Uint8Array, offset: number): bigint;
101
+ /**
102
+ * Read a little-endian u64 at `offset`.
103
+ *
104
+ * @param {Uint8Array} bytes
105
+ * @param {number} offset
106
+ * @returns {bigint}
107
+ */
108
+ export function read_u64(bytes: Uint8Array, offset: number): bigint;
109
+ /**
110
+ * Write a little-endian u64 at `offset`.
111
+ *
112
+ * @param {Uint8Array} bytes
113
+ * @param {number} offset
114
+ * @param {bigint} value
115
+ */
116
+ export function write_u64(bytes: Uint8Array, offset: number, value: bigint): void;
117
+ /**
118
+ * The 16-byte mixing step shared by every mid-size path.
119
+ *
120
+ * @param {Uint8Array} input
121
+ * @param {number} input_offset
122
+ * @param {Uint8Array} secret
123
+ * @param {number} secret_offset
124
+ * @param {bigint} seed
125
+ * @returns {bigint}
126
+ */
127
+ export function xxh3_mix16b(input: Uint8Array, input_offset: number, secret: Uint8Array, secret_offset: number, seed: bigint): bigint;
128
+ /**
129
+ * Derive a 192-byte secret from `seed`, as the reference's `XXH3_initCustomSecret`. This is what
130
+ * makes a seeded hash of a long input differ from the unseeded one.
131
+ *
132
+ * @param {bigint} seed
133
+ * @returns {Uint8Array} freshly allocated, {@link XXH3_SECRET}'s length
134
+ */
135
+ export function xxh3_init_custom_secret(seed: bigint): Uint8Array;
136
+ /**
137
+ * Run the whole long-input accumulator loop: whole blocks with a scramble after each, then the
138
+ * trailing partial block, then the (possibly overlapping) final stripe.
139
+ *
140
+ * @param {BigUint64Array} acc
141
+ * @param {Uint8Array} input
142
+ * @param {Uint8Array} secret
143
+ */
144
+ export function xxh3_hash_long_loop(acc: BigUint64Array, input: Uint8Array, secret: Uint8Array): void;
145
+ /**
146
+ * Fold the eight lanes down to one 64-bit value.
147
+ *
148
+ * @param {BigUint64Array} acc
149
+ * @param {Uint8Array} secret
150
+ * @param {number} secret_offset
151
+ * @param {bigint} start
152
+ * @returns {bigint}
153
+ */
154
+ export function xxh3_merge_accs(acc: BigUint64Array, secret: Uint8Array, secret_offset: number, start: bigint): bigint;
155
+ /**
156
+ * The accumulator lanes' initial state.
157
+ * @returns {BigUint64Array} freshly allocated, {@link XXH_ACC_NB} lanes
158
+ */
159
+ export function xxh3_init_acc(): BigUint64Array;
160
+ /**
161
+ * The secret a seeded hash of a long input runs against: the default one for seed 0, a derived one
162
+ * otherwise. Shared by both variants so they agree on the seed-0 shortcut.
163
+ *
164
+ * @param {bigint} seed
165
+ * @returns {Uint8Array}
166
+ */
167
+ export function xxh3_long_secret(seed: bigint): Uint8Array;
168
+ /**
169
+ * Common argument checks for the public entry points.
170
+ *
171
+ * @param {Uint8Array} input
172
+ * @param {bigint} seed
173
+ */
174
+ export function xxh3_assert_arguments(input: Uint8Array, seed: bigint): void;
175
+ /**
176
+ * The pieces of xxHash3 that the 64-bit and 128-bit variants share: the primes, the mixing stages,
177
+ * and the long-input accumulator loop. Everything here is a direct transcription of the reference
178
+ * implementation's scalar path — the vectorized paths produce identical results by construction, so
179
+ * the scalar one is the whole specification.
180
+ *
181
+ * Arithmetic is `BigInt` masked to 64 bits after every operation. This is a build-time hash (asset
182
+ * identity, container checksums), never a per-frame one, so clarity against the reference wins over
183
+ * the 32-bit-lane decomposition a runtime implementation would need.
184
+ *
185
+ * @see https://github.com/Cyan4973/xxHash/blob/dev/xxhash.h
186
+ *
187
+ * @author Alex Goldring
188
+ * @copyright Company Named Limited (c) 2026
189
+ */
190
+ /**
191
+ * @readonly
192
+ * @type {bigint}
193
+ */
194
+ export const XXH_MASK_64: bigint;
195
+ export const XXH_PRIME32_1: 2654435761n;
196
+ export const XXH_PRIME32_2: 2246822519n;
197
+ export const XXH_PRIME32_3: 3266489917n;
198
+ export const XXH_PRIME64_1: 11400714785074694791n;
199
+ export const XXH_PRIME64_2: 14029467366897019727n;
200
+ export const XXH_PRIME64_3: 1609587929392839161n;
201
+ export const XXH_PRIME64_4: 9650029242287828579n;
202
+ export const XXH_PRIME64_5: 2870177450012600261n;
203
+ export const XXH_PRIME_MX1: 1609587791953885689n;
204
+ export const XXH_PRIME_MX2: 11507291218515648293n;
205
+ /**
206
+ * Shortest secret any variant accepts, and the anchor for the mid-size tail offsets.
207
+ * @readonly
208
+ * @type {number}
209
+ */
210
+ export const XXH3_SECRET_SIZE_MIN: number;
211
+ /**
212
+ * Longest input still handled by the "mid size" single-shot paths.
213
+ * @readonly
214
+ * @type {number}
215
+ */
216
+ export const XXH3_MIDSIZE_MAX: number;
217
+ export const XXH3_MIDSIZE_STARTOFFSET: 3;
218
+ export const XXH3_MIDSIZE_LASTOFFSET: 17;
219
+ export const XXH_STRIPE_LEN: 64;
220
+ export const XXH_SECRET_CONSUME_RATE: 8;
221
+ export const XXH_ACC_NB: 8;
222
+ export const XXH_SECRET_LASTACC_START: 7;
223
+ export const XXH_SECRET_MERGEACCS_START: 11;
224
+ //# sourceMappingURL=xxh3_common.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xxh3_common.d.ts","sourceRoot":"","sources":["../../../../../src/core/math/hash/xxh3_common.js"],"names":[],"mappings":"AA+DA;;;;GAIG;AACH,uBAHW,MAAM,GACJ,MAAM,CAIlB;AAED;;;;GAIG;AACH,yBAJW,MAAM,KACN,MAAM,GACJ,MAAM,CAIlB;AAED;;;;GAIG;AACH,yBAJW,MAAM,KACN,MAAM,GACJ,MAAM,CAIlB;AAED;;;;;GAKG;AACH,yBAJW,MAAM,KACN,MAAM,GACJ,MAAM,CAIlB;AAED;;;;GAIG;AACH,0BAJW,MAAM,QACN,MAAM,GACJ,MAAM,CAMlB;AAED;;;;;GAKG;AACH,0BAJW,MAAM,QACN,MAAM,GACJ,MAAM,CAOlB;AAED;;;;GAIG;AACH,8BAJW,MAAM,QACN,MAAM,GACJ,MAAM,CAIlB;AAED;;;;GAIG;AACH,0BAHW,MAAM,GACJ,MAAM,CAMlB;AAED;;;;GAIG;AACH,0BAHW,MAAM,GACJ,MAAM,CAWlB;AAED;;;;;;;GAOG;AACH,8BAJW,MAAM,KACN,MAAM,GACJ,MAAM,CAIlB;AAED;;;;;;GAMG;AACH,iCAJW,MAAM,KACN,MAAM,GACJ,MAAM,CAMlB;AAED;;;;GAIG;AACH,oCAHW,MAAM,GACJ,MAAM,CASlB;AAED;;;;;GAKG;AACH,iCAJW,MAAM,OACN,MAAM,GACJ,MAAM,CAUlB;AAED;;;;GAIG;AACH,sCAHW,MAAM,GACJ,MAAM,CAWlB;AAED;;;;;;GAMG;AACH,gCAJW,UAAU,UACV,MAAM,GACJ,MAAM,CASlB;AAED;;;;;;GAMG;AACH,gCAJW,UAAU,UACV,MAAM,GACJ,MAAM,CAIlB;AAED;;;;;;GAMG;AACH,iCAJW,UAAU,UACV,MAAM,SACN,MAAM,QAShB;AAED;;;;;;;;;GASG;AACH,mCAPW,UAAU,gBACV,MAAM,UACN,UAAU,iBACV,MAAM,QACN,MAAM,GACJ,MAAM,CAUlB;AAED;;;;;;GAMG;AACH,8CAHW,MAAM,GACJ,UAAU,CAgBtB;AA6DD;;;;;;;GAOG;AACH,yCAJW,cAAc,SACd,UAAU,UACV,UAAU,QAwBpB;AAED;;;;;;;;GAQG;AACH,qCANW,cAAc,UACd,UAAU,iBACV,MAAM,SACN,MAAM,GACJ,MAAM,CAalB;AAED;;;GAGG;AACH,iCAFa,cAAc,CAe1B;AAED;;;;;;GAMG;AACH,uCAHW,MAAM,GACJ,UAAU,CAQtB;AAED;;;;;GAKG;AACH,6CAHW,UAAU,QACV,MAAM,QAOhB;AAxdD;;;;;;;;;;;;;;GAcG;AAEH;;;GAGG;AACH,0BAFU,MAAM,CAE+B;AAI/C,wCAAyC;AACzC,wCAAyC;AACzC,wCAAyC;AAEzC,kDAAiD;AACjD,kDAAiD;AACjD,iDAAiD;AACjD,iDAAiD;AACjD,iDAAiD;AAEjD,iDAAiD;AACjD,kDAAiD;AAEjD;;;;GAIG;AACH,mCAFU,MAAM,CAEwB;AAExC;;;;GAIG;AACH,+BAFU,MAAM,CAEoB;AAEpC,yCAA0C;AAC1C,yCAA0C;AAE1C,gCAAiC;AACjC,wCAAyC;AACzC,2BAA4B;AAC5B,yCAA0C;AAC1C,4CAA6C"}
@@ -0,0 +1,476 @@
1
+ import { assert } from "../../assert.js";
2
+ import { XXH3_SECRET } from "./XXH3_SECRET.js";
3
+
4
+ /**
5
+ * The pieces of xxHash3 that the 64-bit and 128-bit variants share: the primes, the mixing stages,
6
+ * and the long-input accumulator loop. Everything here is a direct transcription of the reference
7
+ * implementation's scalar path — the vectorized paths produce identical results by construction, so
8
+ * the scalar one is the whole specification.
9
+ *
10
+ * Arithmetic is `BigInt` masked to 64 bits after every operation. This is a build-time hash (asset
11
+ * identity, container checksums), never a per-frame one, so clarity against the reference wins over
12
+ * the 32-bit-lane decomposition a runtime implementation would need.
13
+ *
14
+ * @see https://github.com/Cyan4973/xxHash/blob/dev/xxhash.h
15
+ *
16
+ * @author Alex Goldring
17
+ * @copyright Company Named Limited (c) 2026
18
+ */
19
+
20
+ /**
21
+ * @readonly
22
+ * @type {bigint}
23
+ */
24
+ export const XXH_MASK_64 = 0xFFFFFFFFFFFFFFFFn;
25
+
26
+ const MASK_32 = 0xFFFFFFFFn;
27
+
28
+ export const XXH_PRIME32_1 = 0x9E3779B1n;
29
+ export const XXH_PRIME32_2 = 0x85EBCA77n;
30
+ export const XXH_PRIME32_3 = 0xC2B2AE3Dn;
31
+
32
+ export const XXH_PRIME64_1 = 0x9E3779B185EBCA87n;
33
+ export const XXH_PRIME64_2 = 0xC2B2AE3D27D4EB4Fn;
34
+ export const XXH_PRIME64_3 = 0x165667B19E3779F9n;
35
+ export const XXH_PRIME64_4 = 0x85EBCA77C2B2AE63n;
36
+ export const XXH_PRIME64_5 = 0x27D4EB2F165667C5n;
37
+
38
+ export const XXH_PRIME_MX1 = 0x165667919E3779F9n;
39
+ export const XXH_PRIME_MX2 = 0x9FB21C651E98DF25n;
40
+
41
+ /**
42
+ * Shortest secret any variant accepts, and the anchor for the mid-size tail offsets.
43
+ * @readonly
44
+ * @type {number}
45
+ */
46
+ export const XXH3_SECRET_SIZE_MIN = 136;
47
+
48
+ /**
49
+ * Longest input still handled by the "mid size" single-shot paths.
50
+ * @readonly
51
+ * @type {number}
52
+ */
53
+ export const XXH3_MIDSIZE_MAX = 240;
54
+
55
+ export const XXH3_MIDSIZE_STARTOFFSET = 3;
56
+ export const XXH3_MIDSIZE_LASTOFFSET = 17;
57
+
58
+ export const XXH_STRIPE_LEN = 64;
59
+ export const XXH_SECRET_CONSUME_RATE = 8;
60
+ export const XXH_ACC_NB = 8;
61
+ export const XXH_SECRET_LASTACC_START = 7;
62
+ export const XXH_SECRET_MERGEACCS_START = 11;
63
+
64
+ /**
65
+ * Truncate to 64 bits.
66
+ * @param {bigint} v
67
+ * @returns {bigint}
68
+ */
69
+ export function u64(v) {
70
+ return v & XXH_MASK_64;
71
+ }
72
+
73
+ /**
74
+ * @param {bigint} a
75
+ * @param {bigint} b
76
+ * @returns {bigint}
77
+ */
78
+ export function mul64(a, b) {
79
+ return (a * b) & XXH_MASK_64;
80
+ }
81
+
82
+ /**
83
+ * @param {bigint} a
84
+ * @param {bigint} b
85
+ * @returns {bigint}
86
+ */
87
+ export function add64(a, b) {
88
+ return (a + b) & XXH_MASK_64;
89
+ }
90
+
91
+ /**
92
+ * Two's-complement 64-bit subtraction.
93
+ * @param {bigint} a
94
+ * @param {bigint} b
95
+ * @returns {bigint}
96
+ */
97
+ export function sub64(a, b) {
98
+ return (a - b) & XXH_MASK_64;
99
+ }
100
+
101
+ /**
102
+ * @param {bigint} v
103
+ * @param {number} bits
104
+ * @returns {bigint}
105
+ */
106
+ export function rotl64(v, bits) {
107
+ const n = BigInt(bits);
108
+
109
+ return ((v << n) | (v >> (64n - n))) & XXH_MASK_64;
110
+ }
111
+
112
+ /**
113
+ * Rotate within 32 bits, as the reference's `XXH_rotl32`.
114
+ * @param {bigint} v
115
+ * @param {number} bits
116
+ * @returns {bigint}
117
+ */
118
+ export function rotl32(v, bits) {
119
+ const x = v & MASK_32;
120
+ const n = BigInt(bits);
121
+
122
+ return ((x << n) | (x >> (32n - n))) & MASK_32;
123
+ }
124
+
125
+ /**
126
+ * @param {bigint} v
127
+ * @param {number} bits
128
+ * @returns {bigint}
129
+ */
130
+ export function xorshift64(v, bits) {
131
+ return v ^ (v >> BigInt(bits));
132
+ }
133
+
134
+ /**
135
+ * Byte-reverse a 32-bit value, as the reference's `XXH_swap32`.
136
+ * @param {bigint} v
137
+ * @returns {bigint}
138
+ */
139
+ export function swap32(v) {
140
+ const x = v & MASK_32;
141
+
142
+ return ((x << 24n) | ((x & 0xFF00n) << 8n) | ((x >> 8n) & 0xFF00n) | (x >> 24n)) & MASK_32;
143
+ }
144
+
145
+ /**
146
+ * Byte-reverse a 64-bit value, as the reference's `XXH_swap64`.
147
+ * @param {bigint} v
148
+ * @returns {bigint}
149
+ */
150
+ export function swap64(v) {
151
+ return ((v & 0x00000000000000FFn) << 56n)
152
+ | ((v & 0x000000000000FF00n) << 40n)
153
+ | ((v & 0x0000000000FF0000n) << 24n)
154
+ | ((v & 0x00000000FF000000n) << 8n)
155
+ | ((v & 0x000000FF00000000n) >> 8n)
156
+ | ((v & 0x0000FF0000000000n) >> 24n)
157
+ | ((v & 0x00FF000000000000n) >> 40n)
158
+ | ((v & 0xFF00000000000000n) >> 56n);
159
+ }
160
+
161
+ /**
162
+ * Widening 32x32 -> 64 multiply of the low halves of both operands, as the reference's
163
+ * `XXH_mult32to64`.
164
+ *
165
+ * @param {bigint} a
166
+ * @param {bigint} b
167
+ * @returns {bigint}
168
+ */
169
+ export function mult32to64(a, b) {
170
+ return (a & MASK_32) * (b & MASK_32);
171
+ }
172
+
173
+ /**
174
+ * 64x64 -> 128 multiply, folded down by XOR of the two halves.
175
+ *
176
+ * @param {bigint} a
177
+ * @param {bigint} b
178
+ * @returns {bigint}
179
+ */
180
+ export function mul128_fold64(a, b) {
181
+ const product = a * b;
182
+
183
+ return (product ^ (product >> 64n)) & XXH_MASK_64;
184
+ }
185
+
186
+ /**
187
+ * The fast finalizing mix, for input whose bits are already partially mixed.
188
+ * @param {bigint} h64
189
+ * @returns {bigint}
190
+ */
191
+ export function xxh3_avalanche(h64) {
192
+ let h = xorshift64(h64, 37);
193
+
194
+ h = mul64(h, XXH_PRIME_MX1);
195
+ h = xorshift64(h, 32);
196
+
197
+ return h & XXH_MASK_64;
198
+ }
199
+
200
+ /**
201
+ * The stronger finalizing mix (after Pelle Evensen's rrmxmx), for input that has not been mixed yet.
202
+ * @param {bigint} h64
203
+ * @param {number} len
204
+ * @returns {bigint}
205
+ */
206
+ export function xxh3_rrmxmx(h64, len) {
207
+ let h = h64 ^ rotl64(h64, 49) ^ rotl64(h64, 24);
208
+
209
+ h = mul64(h, XXH_PRIME_MX2);
210
+ h = u64(h ^ add64(h >> 35n, BigInt(len)));
211
+ h = mul64(h, XXH_PRIME_MX2);
212
+
213
+ return xorshift64(h, 28) & XXH_MASK_64;
214
+ }
215
+
216
+ /**
217
+ * XXH64's finalizing mix, which XXH3 reuses for its shortest inputs.
218
+ * @param {bigint} hash
219
+ * @returns {bigint}
220
+ */
221
+ export function xxh64_avalanche(hash) {
222
+ let h = hash ^ (hash >> 33n);
223
+
224
+ h = mul64(h, XXH_PRIME64_2);
225
+ h ^= h >> 29n;
226
+ h = mul64(h, XXH_PRIME64_3);
227
+ h ^= h >> 32n;
228
+
229
+ return h & XXH_MASK_64;
230
+ }
231
+
232
+ /**
233
+ * Read a little-endian u32 at `offset`.
234
+ *
235
+ * @param {Uint8Array} bytes
236
+ * @param {number} offset
237
+ * @returns {bigint}
238
+ */
239
+ export function read_u32(bytes, offset) {
240
+ return BigInt(
241
+ bytes[offset]
242
+ | (bytes[offset + 1] << 8)
243
+ | (bytes[offset + 2] << 16)
244
+ | (bytes[offset + 3] << 24)
245
+ ) & MASK_32;
246
+ }
247
+
248
+ /**
249
+ * Read a little-endian u64 at `offset`.
250
+ *
251
+ * @param {Uint8Array} bytes
252
+ * @param {number} offset
253
+ * @returns {bigint}
254
+ */
255
+ export function read_u64(bytes, offset) {
256
+ return read_u32(bytes, offset) | (read_u32(bytes, offset + 4) << 32n);
257
+ }
258
+
259
+ /**
260
+ * Write a little-endian u64 at `offset`.
261
+ *
262
+ * @param {Uint8Array} bytes
263
+ * @param {number} offset
264
+ * @param {bigint} value
265
+ */
266
+ export function write_u64(bytes, offset, value) {
267
+ let v = value & XXH_MASK_64;
268
+
269
+ for (let i = 0; i < 8; i++) {
270
+ bytes[offset + i] = Number(v & 0xFFn);
271
+ v >>= 8n;
272
+ }
273
+ }
274
+
275
+ /**
276
+ * The 16-byte mixing step shared by every mid-size path.
277
+ *
278
+ * @param {Uint8Array} input
279
+ * @param {number} input_offset
280
+ * @param {Uint8Array} secret
281
+ * @param {number} secret_offset
282
+ * @param {bigint} seed
283
+ * @returns {bigint}
284
+ */
285
+ export function xxh3_mix16b(input, input_offset, secret, secret_offset, seed) {
286
+ const input_lo = read_u64(input, input_offset);
287
+ const input_hi = read_u64(input, input_offset + 8);
288
+
289
+ return mul128_fold64(
290
+ input_lo ^ add64(read_u64(secret, secret_offset), seed),
291
+ input_hi ^ sub64(read_u64(secret, secret_offset + 8), seed)
292
+ );
293
+ }
294
+
295
+ /**
296
+ * Derive a 192-byte secret from `seed`, as the reference's `XXH3_initCustomSecret`. This is what
297
+ * makes a seeded hash of a long input differ from the unseeded one.
298
+ *
299
+ * @param {bigint} seed
300
+ * @returns {Uint8Array} freshly allocated, {@link XXH3_SECRET}'s length
301
+ */
302
+ export function xxh3_init_custom_secret(seed) {
303
+ const result = new Uint8Array(XXH3_SECRET.length);
304
+
305
+ const pair_count = XXH3_SECRET.length / 16;
306
+
307
+ for (let i = 0; i < pair_count; i++) {
308
+ const lo = add64(read_u64(XXH3_SECRET, 16 * i), seed);
309
+ const hi = sub64(read_u64(XXH3_SECRET, 16 * i + 8), seed);
310
+
311
+ write_u64(result, 16 * i, lo);
312
+ write_u64(result, 16 * i + 8, hi);
313
+ }
314
+
315
+ return result;
316
+ }
317
+
318
+ /**
319
+ * Accumulate one 64-byte stripe into the eight lanes.
320
+ *
321
+ * @param {BigUint64Array} acc
322
+ * @param {Uint8Array} input
323
+ * @param {number} input_offset
324
+ * @param {Uint8Array} secret
325
+ * @param {number} secret_offset
326
+ */
327
+ function accumulate_512(acc, input, input_offset, secret, secret_offset) {
328
+ for (let lane = 0; lane < XXH_ACC_NB; lane++) {
329
+ const data_val = read_u64(input, input_offset + lane * 8);
330
+ const data_key = data_val ^ read_u64(secret, secret_offset + lane * 8);
331
+
332
+ acc[lane ^ 1] = add64(acc[lane ^ 1], data_val);
333
+ acc[lane] = add64(mult32to64(data_key, data_key >> 32n), acc[lane]);
334
+ }
335
+ }
336
+
337
+ /**
338
+ * Accumulate `stripe_count` consecutive stripes, advancing the secret by
339
+ * {@link XXH_SECRET_CONSUME_RATE} per stripe.
340
+ *
341
+ * @param {BigUint64Array} acc
342
+ * @param {Uint8Array} input
343
+ * @param {number} input_offset
344
+ * @param {Uint8Array} secret
345
+ * @param {number} stripe_count
346
+ */
347
+ function accumulate(acc, input, input_offset, secret, stripe_count) {
348
+ for (let n = 0; n < stripe_count; n++) {
349
+ accumulate_512(
350
+ acc,
351
+ input, input_offset + n * XXH_STRIPE_LEN,
352
+ secret, n * XXH_SECRET_CONSUME_RATE
353
+ );
354
+ }
355
+ }
356
+
357
+ /**
358
+ * Scramble the lanes between blocks, so that a block's contribution cannot be undone by a later one.
359
+ *
360
+ * @param {BigUint64Array} acc
361
+ * @param {Uint8Array} secret
362
+ * @param {number} secret_offset
363
+ */
364
+ function scramble_acc(acc, secret, secret_offset) {
365
+ for (let lane = 0; lane < XXH_ACC_NB; lane++) {
366
+ const key64 = read_u64(secret, secret_offset + lane * 8);
367
+
368
+ let acc64 = xorshift64(acc[lane], 47);
369
+
370
+ acc64 ^= key64;
371
+ acc64 = mul64(acc64, XXH_PRIME32_1);
372
+
373
+ acc[lane] = acc64;
374
+ }
375
+ }
376
+
377
+ /**
378
+ * Run the whole long-input accumulator loop: whole blocks with a scramble after each, then the
379
+ * trailing partial block, then the (possibly overlapping) final stripe.
380
+ *
381
+ * @param {BigUint64Array} acc
382
+ * @param {Uint8Array} input
383
+ * @param {Uint8Array} secret
384
+ */
385
+ export function xxh3_hash_long_loop(acc, input, secret) {
386
+ const len = input.length;
387
+ const secret_size = secret.length;
388
+
389
+ const stripes_per_block = ((secret_size - XXH_STRIPE_LEN) / XXH_SECRET_CONSUME_RATE) | 0;
390
+ const block_len = XXH_STRIPE_LEN * stripes_per_block;
391
+ const block_count = ((len - 1) / block_len) | 0;
392
+
393
+ for (let n = 0; n < block_count; n++) {
394
+ accumulate(acc, input, n * block_len, secret, stripes_per_block);
395
+ scramble_acc(acc, secret, secret_size - XXH_STRIPE_LEN);
396
+ }
397
+
398
+ const trailing_stripes = (((len - 1) - (block_len * block_count)) / XXH_STRIPE_LEN) | 0;
399
+
400
+ accumulate(acc, input, block_count * block_len, secret, trailing_stripes);
401
+
402
+ accumulate_512(
403
+ acc,
404
+ input, len - XXH_STRIPE_LEN,
405
+ secret, secret_size - XXH_STRIPE_LEN - XXH_SECRET_LASTACC_START
406
+ );
407
+ }
408
+
409
+ /**
410
+ * Fold the eight lanes down to one 64-bit value.
411
+ *
412
+ * @param {BigUint64Array} acc
413
+ * @param {Uint8Array} secret
414
+ * @param {number} secret_offset
415
+ * @param {bigint} start
416
+ * @returns {bigint}
417
+ */
418
+ export function xxh3_merge_accs(acc, secret, secret_offset, start) {
419
+ let result = start & XXH_MASK_64;
420
+
421
+ for (let i = 0; i < 4; i++) {
422
+ result = add64(result, mul128_fold64(
423
+ acc[2 * i] ^ read_u64(secret, secret_offset + 16 * i),
424
+ acc[2 * i + 1] ^ read_u64(secret, secret_offset + 16 * i + 8)
425
+ ));
426
+ }
427
+
428
+ return xxh3_avalanche(result);
429
+ }
430
+
431
+ /**
432
+ * The accumulator lanes' initial state.
433
+ * @returns {BigUint64Array} freshly allocated, {@link XXH_ACC_NB} lanes
434
+ */
435
+ export function xxh3_init_acc() {
436
+ const acc = new BigUint64Array(XXH_ACC_NB);
437
+
438
+ acc[0] = XXH_PRIME32_3;
439
+ acc[1] = XXH_PRIME64_1;
440
+ acc[2] = XXH_PRIME64_2;
441
+ acc[3] = XXH_PRIME64_3;
442
+ acc[4] = XXH_PRIME64_4;
443
+ acc[5] = XXH_PRIME32_2;
444
+ acc[6] = XXH_PRIME64_5;
445
+ acc[7] = XXH_PRIME32_1;
446
+
447
+ return acc;
448
+ }
449
+
450
+ /**
451
+ * The secret a seeded hash of a long input runs against: the default one for seed 0, a derived one
452
+ * otherwise. Shared by both variants so they agree on the seed-0 shortcut.
453
+ *
454
+ * @param {bigint} seed
455
+ * @returns {Uint8Array}
456
+ */
457
+ export function xxh3_long_secret(seed) {
458
+ if (seed === 0n) {
459
+ return XXH3_SECRET;
460
+ }
461
+
462
+ return xxh3_init_custom_secret(seed);
463
+ }
464
+
465
+ /**
466
+ * Common argument checks for the public entry points.
467
+ *
468
+ * @param {Uint8Array} input
469
+ * @param {bigint} seed
470
+ */
471
+ export function xxh3_assert_arguments(input, seed) {
472
+ assert.defined(input, 'input');
473
+ assert.notNull(input, 'input');
474
+ assert.isArrayLike(input, 'input');
475
+ assert.equal(typeof seed, 'bigint', `seed must be a bigint, instead was '${typeof seed}'`);
476
+ }