@woosh/meep-engine 3.9.0 → 3.11.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 (832) hide show
  1. package/README.md +168 -152
  2. package/build/bundle-worker-image-decoder.js +1 -1
  3. package/build/bundle-worker-terrain.js +1 -1
  4. package/package.json +3 -2
  5. package/src/REVIEW_2026_08_06.md +610 -610
  6. package/src/avif/encode_image_source.d.ts +70 -0
  7. package/src/avif/encode_image_source.d.ts.map +1 -0
  8. package/src/avif/encode_image_source.js +117 -0
  9. package/src/avif/encoder_worker.js +15 -126
  10. package/src/avif/index.d.ts +4 -2
  11. package/src/avif/index.js +21 -2
  12. package/src/avif/native/DECISIONS.md +537 -0
  13. package/src/avif/native/NOTICE.md +61 -0
  14. package/src/avif/native/api/AvifDecoder.d.ts +67 -0
  15. package/src/avif/native/api/AvifDecoder.d.ts.map +1 -0
  16. package/src/avif/native/api/AvifDecoder.js +121 -0
  17. package/src/avif/native/api/apply_transformations.d.ts +30 -0
  18. package/src/avif/native/api/apply_transformations.d.ts.map +1 -0
  19. package/src/avif/native/api/apply_transformations.js +120 -0
  20. package/src/avif/native/api/avif_to_sampler2d.d.ts +25 -0
  21. package/src/avif/native/api/avif_to_sampler2d.d.ts.map +1 -0
  22. package/src/avif/native/api/avif_to_sampler2d.js +42 -0
  23. package/src/avif/native/api/convert_to_rgba.d.ts +54 -0
  24. package/src/avif/native/api/convert_to_rgba.d.ts.map +1 -0
  25. package/src/avif/native/api/convert_to_rgba.js +204 -0
  26. package/src/avif/native/api/decode_avif.d.ts +24 -0
  27. package/src/avif/native/api/decode_avif.d.ts.map +1 -0
  28. package/src/avif/native/api/decode_avif.js +111 -0
  29. package/src/avif/native/api/decode_image_item.d.ts +18 -0
  30. package/src/avif/native/api/decode_image_item.d.ts.map +1 -0
  31. package/src/avif/native/api/decode_image_item.js +234 -0
  32. package/src/avif/native/api/encode_avif.d.ts +73 -0
  33. package/src/avif/native/api/encode_avif.d.ts.map +1 -0
  34. package/src/avif/native/api/encode_avif.js +488 -0
  35. package/src/avif/native/api/sampler2d_to_avif.d.ts +22 -0
  36. package/src/avif/native/api/sampler2d_to_avif.d.ts.map +1 -0
  37. package/src/avif/native/api/sampler2d_to_avif.js +108 -0
  38. package/src/avif/native/av1/decode/Av1FrameContext.d.ts +286 -0
  39. package/src/avif/native/av1/decode/Av1FrameContext.d.ts.map +1 -0
  40. package/src/avif/native/av1/decode/Av1FrameContext.js +622 -0
  41. package/src/avif/native/av1/decode/block_decoded.d.ts +27 -0
  42. package/src/avif/native/av1/decode/block_decoded.d.ts.map +1 -0
  43. package/src/avif/native/av1/decode/block_decoded.js +59 -0
  44. package/src/avif/native/av1/decode/decode_av1_still.d.ts +22 -0
  45. package/src/avif/native/av1/decode/decode_av1_still.d.ts.map +1 -0
  46. package/src/avif/native/av1/decode/decode_av1_still.js +309 -0
  47. package/src/avif/native/av1/decode/decode_coefficients.d.ts +20 -0
  48. package/src/avif/native/av1/decode/decode_coefficients.d.ts.map +1 -0
  49. package/src/avif/native/av1/decode/decode_coefficients.js +259 -0
  50. package/src/avif/native/av1/decode/decode_palette.d.ts +28 -0
  51. package/src/avif/native/av1/decode/decode_palette.d.ts.map +1 -0
  52. package/src/avif/native/av1/decode/decode_palette.js +442 -0
  53. package/src/avif/native/av1/decode/decode_tile.d.ts +14 -0
  54. package/src/avif/native/av1/decode/decode_tile.d.ts.map +1 -0
  55. package/src/avif/native/av1/decode/decode_tile.js +1213 -0
  56. package/src/avif/native/av1/decode/get_scan.d.ts +16 -0
  57. package/src/avif/native/av1/decode/get_scan.d.ts.map +1 -0
  58. package/src/avif/native/av1/decode/get_scan.js +138 -0
  59. package/src/avif/native/av1/decode/read_lr.d.ts +35 -0
  60. package/src/avif/native/av1/decode/read_lr.d.ts.map +1 -0
  61. package/src/avif/native/av1/decode/read_lr.js +277 -0
  62. package/src/avif/native/av1/decode/read_transform_type.d.ts +19 -0
  63. package/src/avif/native/av1/decode/read_transform_type.d.ts.map +1 -0
  64. package/src/avif/native/av1/decode/read_transform_type.js +92 -0
  65. package/src/avif/native/av1/decode/reconstruct.d.ts +36 -0
  66. package/src/avif/native/av1/decode/reconstruct.d.ts.map +1 -0
  67. package/src/avif/native/av1/decode/reconstruct.js +241 -0
  68. package/src/avif/native/av1/decode/transform_type.d.ts +49 -0
  69. package/src/avif/native/av1/decode/transform_type.d.ts.map +1 -0
  70. package/src/avif/native/av1/decode/transform_type.js +137 -0
  71. package/src/avif/native/av1/encode/Av1BlockSnapshot.d.ts +81 -0
  72. package/src/avif/native/av1/encode/Av1BlockSnapshot.d.ts.map +1 -0
  73. package/src/avif/native/av1/encode/Av1BlockSnapshot.js +299 -0
  74. package/src/avif/native/av1/encode/Av1EncodeContext.d.ts +384 -0
  75. package/src/avif/native/av1/encode/Av1EncodeContext.d.ts.map +1 -0
  76. package/src/avif/native/av1/encode/Av1EncodeContext.js +590 -0
  77. package/src/avif/native/av1/encode/build_headers.d.ts +50 -0
  78. package/src/avif/native/av1/encode/build_headers.d.ts.map +1 -0
  79. package/src/avif/native/av1/encode/build_headers.js +359 -0
  80. package/src/avif/native/av1/encode/choose_chroma_alpha.d.ts +26 -0
  81. package/src/avif/native/av1/encode/choose_chroma_alpha.d.ts.map +1 -0
  82. package/src/avif/native/av1/encode/choose_chroma_alpha.js +90 -0
  83. package/src/avif/native/av1/encode/choose_filters.d.ts +21 -0
  84. package/src/avif/native/av1/encode/choose_filters.d.ts.map +1 -0
  85. package/src/avif/native/av1/encode/choose_filters.js +318 -0
  86. package/src/avif/native/av1/encode/choose_restoration.d.ts +35 -0
  87. package/src/avif/native/av1/encode/choose_restoration.d.ts.map +1 -0
  88. package/src/avif/native/av1/encode/choose_restoration.js +616 -0
  89. package/src/avif/native/av1/encode/decode_effort.d.ts +57 -0
  90. package/src/avif/native/av1/encode/decode_effort.d.ts.map +1 -0
  91. package/src/avif/native/av1/encode/decode_effort.js +59 -0
  92. package/src/avif/native/av1/encode/encode_av1_still.d.ts +17 -0
  93. package/src/avif/native/av1/encode/encode_av1_still.d.ts.map +1 -0
  94. package/src/avif/native/av1/encode/encode_av1_still.js +194 -0
  95. package/src/avif/native/av1/encode/encode_effort.d.ts +56 -0
  96. package/src/avif/native/av1/encode/encode_effort.d.ts.map +1 -0
  97. package/src/avif/native/av1/encode/encode_effort.js +97 -0
  98. package/src/avif/native/av1/encode/encode_tile.d.ts +26 -0
  99. package/src/avif/native/av1/encode/encode_tile.d.ts.map +1 -0
  100. package/src/avif/native/av1/encode/encode_tile.js +2331 -0
  101. package/src/avif/native/av1/encode/quantise.d.ts +51 -0
  102. package/src/avif/native/av1/encode/quantise.d.ts.map +1 -0
  103. package/src/avif/native/av1/encode/quantise.js +212 -0
  104. package/src/avif/native/av1/encode/write_coefficients.d.ts +42 -0
  105. package/src/avif/native/av1/encode/write_coefficients.d.ts.map +1 -0
  106. package/src/avif/native/av1/encode/write_coefficients.js +367 -0
  107. package/src/avif/native/av1/encode/write_lr.d.ts +33 -0
  108. package/src/avif/native/av1/encode/write_lr.d.ts.map +1 -0
  109. package/src/avif/native/av1/encode/write_lr.js +174 -0
  110. package/src/avif/native/av1/encode/write_transform_type.d.ts +21 -0
  111. package/src/avif/native/av1/encode/write_transform_type.d.ts.map +1 -0
  112. package/src/avif/native/av1/encode/write_transform_type.js +70 -0
  113. package/src/avif/native/av1/entropy/CdfContext.d.ts +167 -0
  114. package/src/avif/native/av1/entropy/CdfContext.d.ts.map +1 -0
  115. package/src/avif/native/av1/entropy/CdfContext.js +433 -0
  116. package/src/avif/native/av1/entropy/SymbolReader.d.ts +103 -0
  117. package/src/avif/native/av1/entropy/SymbolReader.d.ts.map +1 -0
  118. package/src/avif/native/av1/entropy/SymbolReader.js +317 -0
  119. package/src/avif/native/av1/entropy/SymbolWriter.d.ts +107 -0
  120. package/src/avif/native/av1/entropy/SymbolWriter.d.ts.map +1 -0
  121. package/src/avif/native/av1/entropy/SymbolWriter.js +352 -0
  122. package/src/avif/native/av1/entropy/coefficient_context.d.ts +71 -0
  123. package/src/avif/native/av1/entropy/coefficient_context.d.ts.map +1 -0
  124. package/src/avif/native/av1/entropy/coefficient_context.js +325 -0
  125. package/src/avif/native/av1/entropy/partition_cdf.d.ts +54 -0
  126. package/src/avif/native/av1/entropy/partition_cdf.d.ts.map +1 -0
  127. package/src/avif/native/av1/entropy/partition_cdf.js +98 -0
  128. package/src/avif/native/av1/entropy/symbol_cost.d.ts +37 -0
  129. package/src/avif/native/av1/entropy/symbol_cost.d.ts.map +1 -0
  130. package/src/avif/native/av1/entropy/symbol_cost.js +76 -0
  131. package/src/avif/native/av1/filter/cdef.d.ts +15 -0
  132. package/src/avif/native/av1/filter/cdef.d.ts.map +1 -0
  133. package/src/avif/native/av1/filter/cdef.js +313 -0
  134. package/src/avif/native/av1/filter/loop_filter.d.ts +14 -0
  135. package/src/avif/native/av1/filter/loop_filter.d.ts.map +1 -0
  136. package/src/avif/native/av1/filter/loop_filter.js +377 -0
  137. package/src/avif/native/av1/filter/loop_restoration.d.ts +42 -0
  138. package/src/avif/native/av1/filter/loop_restoration.d.ts.map +1 -0
  139. package/src/avif/native/av1/filter/loop_restoration.js +451 -0
  140. package/src/avif/native/av1/filter/superres.d.ts +18 -0
  141. package/src/avif/native/av1/filter/superres.d.ts.map +1 -0
  142. package/src/avif/native/av1/filter/superres.js +86 -0
  143. package/src/avif/native/av1/grain/FilmGrainState.d.ts +62 -0
  144. package/src/avif/native/av1/grain/FilmGrainState.d.ts.map +1 -0
  145. package/src/avif/native/av1/grain/FilmGrainState.js +87 -0
  146. package/src/avif/native/av1/grain/film_grain.d.ts +16 -0
  147. package/src/avif/native/av1/grain/film_grain.d.ts.map +1 -0
  148. package/src/avif/native/av1/grain/film_grain.js +623 -0
  149. package/src/avif/native/av1/obu/FrameHeader.d.ts +248 -0
  150. package/src/avif/native/av1/obu/FrameHeader.d.ts.map +1 -0
  151. package/src/avif/native/av1/obu/FrameHeader.js +381 -0
  152. package/src/avif/native/av1/obu/ObuHeader.d.ts +53 -0
  153. package/src/avif/native/av1/obu/ObuHeader.d.ts.map +1 -0
  154. package/src/avif/native/av1/obu/ObuHeader.js +62 -0
  155. package/src/avif/native/av1/obu/SequenceHeader.d.ts +157 -0
  156. package/src/avif/native/av1/obu/SequenceHeader.d.ts.map +1 -0
  157. package/src/avif/native/av1/obu/SequenceHeader.js +225 -0
  158. package/src/avif/native/av1/obu/for_each_obu.d.ts +24 -0
  159. package/src/avif/native/av1/obu/for_each_obu.d.ts.map +1 -0
  160. package/src/avif/native/av1/obu/for_each_obu.js +50 -0
  161. package/src/avif/native/av1/obu/parse_frame_header.d.ts +18 -0
  162. package/src/avif/native/av1/obu/parse_frame_header.d.ts.map +1 -0
  163. package/src/avif/native/av1/obu/parse_frame_header.js +841 -0
  164. package/src/avif/native/av1/obu/parse_obu_header.d.ts +23 -0
  165. package/src/avif/native/av1/obu/parse_obu_header.d.ts.map +1 -0
  166. package/src/avif/native/av1/obu/parse_obu_header.js +69 -0
  167. package/src/avif/native/av1/obu/parse_sequence_header.d.ts +17 -0
  168. package/src/avif/native/av1/obu/parse_sequence_header.d.ts.map +1 -0
  169. package/src/avif/native/av1/obu/parse_sequence_header.js +263 -0
  170. package/src/avif/native/av1/obu/write_frame_header.d.ts +16 -0
  171. package/src/avif/native/av1/obu/write_frame_header.d.ts.map +1 -0
  172. package/src/avif/native/av1/obu/write_frame_header.js +579 -0
  173. package/src/avif/native/av1/obu/write_sequence_header.d.ts +17 -0
  174. package/src/avif/native/av1/obu/write_sequence_header.d.ts.map +1 -0
  175. package/src/avif/native/av1/obu/write_sequence_header.js +189 -0
  176. package/src/avif/native/av1/predict/IntraPredictionState.d.ts +49 -0
  177. package/src/avif/native/av1/predict/IntraPredictionState.d.ts.map +1 -0
  178. package/src/avif/native/av1/predict/IntraPredictionState.js +58 -0
  179. package/src/avif/native/av1/predict/intra_filter_type.d.ts +17 -0
  180. package/src/avif/native/av1/predict/intra_filter_type.d.ts.map +1 -0
  181. package/src/avif/native/av1/predict/intra_filter_type.js +79 -0
  182. package/src/avif/native/av1/predict/predict_chroma_from_luma.d.ts +50 -0
  183. package/src/avif/native/av1/predict/predict_chroma_from_luma.d.ts.map +1 -0
  184. package/src/avif/native/av1/predict/predict_chroma_from_luma.js +153 -0
  185. package/src/avif/native/av1/predict/predict_intra.d.ts +42 -0
  186. package/src/avif/native/av1/predict/predict_intra.d.ts.map +1 -0
  187. package/src/avif/native/av1/predict/predict_intra.js +803 -0
  188. package/src/avif/native/av1/predict/predict_palette.d.ts +23 -0
  189. package/src/avif/native/av1/predict/predict_palette.d.ts.map +1 -0
  190. package/src/avif/native/av1/predict/predict_palette.js +36 -0
  191. package/src/avif/native/av1/tables/av1_symbols.d.ts +411 -0
  192. package/src/avif/native/av1/tables/av1_symbols.d.ts.map +1 -0
  193. package/src/avif/native/av1/tables/av1_symbols.js +419 -0
  194. package/src/avif/native/av1/tables/block_tables.d.ts +181 -0
  195. package/src/avif/native/av1/tables/block_tables.d.ts.map +1 -0
  196. package/src/avif/native/av1/tables/block_tables.js +270 -0
  197. package/src/avif/native/av1/tables/cdf_tables.d.ts +961 -0
  198. package/src/avif/native/av1/tables/cdf_tables.d.ts.map +1 -0
  199. package/src/avif/native/av1/tables/cdf_tables.js +1893 -0
  200. package/src/avif/native/av1/tables/coefficient_tables.d.ts +41 -0
  201. package/src/avif/native/av1/tables/coefficient_tables.d.ts.map +1 -0
  202. package/src/avif/native/av1/tables/coefficient_tables.js +82 -0
  203. package/src/avif/native/av1/tables/derived_block_tables.d.ts +15 -0
  204. package/src/avif/native/av1/tables/derived_block_tables.d.ts.map +1 -0
  205. package/src/avif/native/av1/tables/derived_block_tables.js +23 -0
  206. package/src/avif/native/av1/tables/filter_tables.d.ts +171 -0
  207. package/src/avif/native/av1/tables/filter_tables.d.ts.map +1 -0
  208. package/src/avif/native/av1/tables/filter_tables.js +313 -0
  209. package/src/avif/native/av1/tables/grain_tables.d.ts +11 -0
  210. package/src/avif/native/av1/tables/grain_tables.d.ts.map +1 -0
  211. package/src/avif/native/av1/tables/grain_tables.js +190 -0
  212. package/src/avif/native/av1/tables/prediction_tables.d.ts +141 -0
  213. package/src/avif/native/av1/tables/prediction_tables.d.ts.map +1 -0
  214. package/src/avif/native/av1/tables/prediction_tables.js +223 -0
  215. package/src/avif/native/av1/tables/quantizer_matrix_tables.d.ts +21 -0
  216. package/src/avif/native/av1/tables/quantizer_matrix_tables.d.ts.map +1 -0
  217. package/src/avif/native/av1/tables/quantizer_matrix_tables.js +38 -0
  218. package/src/avif/native/av1/tables/quantizer_tables.d.ts +21 -0
  219. package/src/avif/native/av1/tables/quantizer_tables.d.ts.map +1 -0
  220. package/src/avif/native/av1/tables/quantizer_tables.js +160 -0
  221. package/src/avif/native/av1/tables/scan_tables.d.ts +321 -0
  222. package/src/avif/native/av1/tables/scan_tables.d.ts.map +1 -0
  223. package/src/avif/native/av1/tables/scan_tables.js +727 -0
  224. package/src/avif/native/av1/tables/segmentation_tables.d.ts +31 -0
  225. package/src/avif/native/av1/tables/segmentation_tables.d.ts.map +1 -0
  226. package/src/avif/native/av1/tables/segmentation_tables.js +48 -0
  227. package/src/avif/native/av1/tables/transform_tables.d.ts +91 -0
  228. package/src/avif/native/av1/tables/transform_tables.d.ts.map +1 -0
  229. package/src/avif/native/av1/tables/transform_tables.js +140 -0
  230. package/src/avif/native/av1/tables/unpack_table.d.ts +33 -0
  231. package/src/avif/native/av1/tables/unpack_table.d.ts.map +1 -0
  232. package/src/avif/native/av1/tables/unpack_table.js +73 -0
  233. package/src/avif/native/av1/transform/forward_transform_2d.d.ts +61 -0
  234. package/src/avif/native/av1/transform/forward_transform_2d.d.ts.map +1 -0
  235. package/src/avif/native/av1/transform/forward_transform_2d.js +574 -0
  236. package/src/avif/native/av1/transform/inverse_transform_1d.d.ts +76 -0
  237. package/src/avif/native/av1/transform/inverse_transform_1d.d.ts.map +1 -0
  238. package/src/avif/native/av1/transform/inverse_transform_1d.js +590 -0
  239. package/src/avif/native/av1/transform/inverse_transform_2d.d.ts +46 -0
  240. package/src/avif/native/av1/transform/inverse_transform_2d.d.ts.map +1 -0
  241. package/src/avif/native/av1/transform/inverse_transform_2d.js +180 -0
  242. package/src/avif/native/av1/util/ceil_log2.d.ts +13 -0
  243. package/src/avif/native/av1/util/ceil_log2.d.ts.map +1 -0
  244. package/src/avif/native/av1/util/ceil_log2.js +18 -0
  245. package/src/avif/native/av1/util/floor_log2.d.ts +20 -0
  246. package/src/avif/native/av1/util/floor_log2.d.ts.map +1 -0
  247. package/src/avif/native/av1/util/floor_log2.js +20 -0
  248. package/src/avif/native/av1/util/round2.d.ts +22 -0
  249. package/src/avif/native/av1/util/round2.d.ts.map +1 -0
  250. package/src/avif/native/av1/util/round2.js +27 -0
  251. package/src/avif/native/av1/util/round2_signed.d.ts +14 -0
  252. package/src/avif/native/av1/util/round2_signed.d.ts.map +1 -0
  253. package/src/avif/native/av1/util/round2_signed.js +17 -0
  254. package/src/avif/native/av1/util/tile_log2.d.ts +16 -0
  255. package/src/avif/native/av1/util/tile_log2.d.ts.map +1 -0
  256. package/src/avif/native/av1/util/tile_log2.js +23 -0
  257. package/src/avif/native/bitstream/BitReader.d.ts +174 -0
  258. package/src/avif/native/bitstream/BitReader.d.ts.map +1 -0
  259. package/src/avif/native/bitstream/BitReader.js +391 -0
  260. package/src/avif/native/bitstream/BitWriter.d.ts +122 -0
  261. package/src/avif/native/bitstream/BitWriter.d.ts.map +1 -0
  262. package/src/avif/native/bitstream/BitWriter.js +351 -0
  263. package/src/avif/native/color/ColourTransform.d.ts +62 -0
  264. package/src/avif/native/color/ColourTransform.d.ts.map +1 -0
  265. package/src/avif/native/color/ColourTransform.js +189 -0
  266. package/src/avif/native/color/YuvImage.d.ts +51 -0
  267. package/src/avif/native/color/YuvImage.d.ts.map +1 -0
  268. package/src/avif/native/color/YuvImage.js +66 -0
  269. package/src/avif/native/color/clamp_sample.d.ts +18 -0
  270. package/src/avif/native/color/clamp_sample.d.ts.map +1 -0
  271. package/src/avif/native/color/clamp_sample.js +25 -0
  272. package/src/avif/native/color/linear_to_transfer.d.ts +24 -0
  273. package/src/avif/native/color/linear_to_transfer.d.ts.map +1 -0
  274. package/src/avif/native/color/linear_to_transfer.js +126 -0
  275. package/src/avif/native/color/primaries.d.ts +20 -0
  276. package/src/avif/native/color/primaries.d.ts.map +1 -0
  277. package/src/avif/native/color/primaries.js +94 -0
  278. package/src/avif/native/color/rgb_row_to_ycbcr.d.ts +20 -0
  279. package/src/avif/native/color/rgb_row_to_ycbcr.d.ts.map +1 -0
  280. package/src/avif/native/color/rgb_row_to_ycbcr.js +78 -0
  281. package/src/avif/native/color/transfer_to_linear.d.ts +49 -0
  282. package/src/avif/native/color/transfer_to_linear.d.ts.map +1 -0
  283. package/src/avif/native/color/transfer_to_linear.js +171 -0
  284. package/src/avif/native/color/upsample_chroma_row.d.ts +35 -0
  285. package/src/avif/native/color/upsample_chroma_row.d.ts.map +1 -0
  286. package/src/avif/native/color/upsample_chroma_row.js +89 -0
  287. package/src/avif/native/color/ycbcr_row_to_rgb.d.ts +23 -0
  288. package/src/avif/native/color/ycbcr_row_to_rgb.d.ts.map +1 -0
  289. package/src/avif/native/color/ycbcr_row_to_rgb.js +78 -0
  290. package/src/avif/native/heif/AvifFile.d.ts +112 -0
  291. package/src/avif/native/heif/AvifFile.d.ts.map +1 -0
  292. package/src/avif/native/heif/AvifFile.js +142 -0
  293. package/src/avif/native/heif/ItemProperty.d.ts +244 -0
  294. package/src/avif/native/heif/ItemProperty.d.ts.map +1 -0
  295. package/src/avif/native/heif/ItemProperty.js +321 -0
  296. package/src/avif/native/heif/find_item_property.d.ts +17 -0
  297. package/src/avif/native/heif/find_item_property.d.ts.map +1 -0
  298. package/src/avif/native/heif/find_item_property.js +28 -0
  299. package/src/avif/native/heif/find_item_references.d.ts +16 -0
  300. package/src/avif/native/heif/find_item_references.d.ts.map +1 -0
  301. package/src/avif/native/heif/find_item_references.js +29 -0
  302. package/src/avif/native/heif/find_items_referencing.d.ts +17 -0
  303. package/src/avif/native/heif/find_items_referencing.d.ts.map +1 -0
  304. package/src/avif/native/heif/find_items_referencing.js +36 -0
  305. package/src/avif/native/heif/parse_avif_file.d.ts +15 -0
  306. package/src/avif/native/heif/parse_avif_file.d.ts.map +1 -0
  307. package/src/avif/native/heif/parse_avif_file.js +383 -0
  308. package/src/avif/native/heif/parse_image_grid.d.ts +18 -0
  309. package/src/avif/native/heif/parse_image_grid.d.ts.map +1 -0
  310. package/src/avif/native/heif/parse_image_grid.js +48 -0
  311. package/src/avif/native/heif/parse_item_property.d.ts +18 -0
  312. package/src/avif/native/heif/parse_item_property.d.ts.map +1 -0
  313. package/src/avif/native/heif/parse_item_property.js +243 -0
  314. package/src/avif/native/heif/read_item_data.d.ts +22 -0
  315. package/src/avif/native/heif/read_item_data.d.ts.map +1 -0
  316. package/src/avif/native/heif/read_item_data.js +97 -0
  317. package/src/avif/native/heif/write_avif_file.d.ts +50 -0
  318. package/src/avif/native/heif/write_avif_file.d.ts.map +1 -0
  319. package/src/avif/native/heif/write_avif_file.js +348 -0
  320. package/src/avif/native/heif/write_item_property.d.ts +16 -0
  321. package/src/avif/native/heif/write_item_property.d.ts.map +1 -0
  322. package/src/avif/native/heif/write_item_property.js +182 -0
  323. package/src/avif/native/index.d.ts +14 -0
  324. package/src/avif/native/index.d.ts.map +1 -0
  325. package/src/avif/native/index.js +56 -0
  326. package/src/avif/native/isobmff/BoxHeader.d.ts +50 -0
  327. package/src/avif/native/isobmff/BoxHeader.d.ts.map +1 -0
  328. package/src/avif/native/isobmff/BoxHeader.js +57 -0
  329. package/src/avif/native/isobmff/BoxWriter.d.ts +118 -0
  330. package/src/avif/native/isobmff/BoxWriter.d.ts.map +1 -0
  331. package/src/avif/native/isobmff/BoxWriter.js +264 -0
  332. package/src/avif/native/isobmff/ByteCursor.d.ts +125 -0
  333. package/src/avif/native/isobmff/ByteCursor.d.ts.map +1 -0
  334. package/src/avif/native/isobmff/ByteCursor.js +298 -0
  335. package/src/avif/native/isobmff/for_each_box.d.ts +23 -0
  336. package/src/avif/native/isobmff/for_each_box.d.ts.map +1 -0
  337. package/src/avif/native/isobmff/for_each_box.js +39 -0
  338. package/src/avif/native/isobmff/read_box_header.d.ts +22 -0
  339. package/src/avif/native/isobmff/read_box_header.d.ts.map +1 -0
  340. package/src/avif/native/isobmff/read_box_header.js +59 -0
  341. package/src/avif/native/isobmff/read_full_box_header.d.ts +26 -0
  342. package/src/avif/native/isobmff/read_full_box_header.d.ts.map +1 -0
  343. package/src/avif/native/isobmff/read_full_box_header.js +33 -0
  344. package/src/avif/threaded_image_encoder.d.ts +7 -2
  345. package/src/avif/threaded_image_encoder.d.ts.map +1 -1
  346. package/src/avif/threaded_image_encoder.js +107 -21
  347. package/src/core/binary/BinaryBuffer.d.ts +40 -0
  348. package/src/core/binary/BinaryBuffer.d.ts.map +1 -1
  349. package/src/core/binary/BinaryBuffer.js +100 -0
  350. package/src/core/binary/hash/crc32.d.ts +16 -0
  351. package/src/core/binary/hash/crc32.d.ts.map +1 -0
  352. package/src/core/binary/hash/crc32.js +96 -0
  353. package/src/core/binary/utf8/utf8_decode.d.ts +21 -0
  354. package/src/core/binary/utf8/utf8_decode.d.ts.map +1 -0
  355. package/src/core/binary/utf8/utf8_decode.js +43 -0
  356. package/src/core/binary/utf8/utf8_encode_into.d.ts +20 -0
  357. package/src/core/binary/utf8/utf8_encode_into.d.ts.map +1 -0
  358. package/src/core/binary/utf8/utf8_encode_into.js +48 -0
  359. package/src/core/binary/utf8/utf8_encoded_length.d.ts +14 -0
  360. package/src/core/binary/utf8/utf8_encoded_length.d.ts.map +1 -0
  361. package/src/core/binary/utf8/utf8_encoded_length.js +36 -0
  362. package/src/core/color/COLOR_FIX_PLAN_2026_08_28.md +417 -0
  363. package/src/core/color/COLOR_REVIEW_2026_08_28.md +779 -0
  364. package/src/core/color/Color.d.ts +128 -20
  365. package/src/core/color/Color.d.ts.map +1 -1
  366. package/src/core/color/Color.js +959 -866
  367. package/src/core/color/PQ/PQ_constants.d.ts +10 -0
  368. package/src/core/color/PQ/PQ_constants.d.ts.map +1 -1
  369. package/src/core/color/PQ/PQ_constants.js +10 -0
  370. package/src/core/color/PQ/linear_to_PQ.d.ts.map +1 -1
  371. package/src/core/color/PQ/linear_to_PQ.js +6 -0
  372. package/src/core/color/REC709_PRIMARIES.d.ts +50 -0
  373. package/src/core/color/REC709_PRIMARIES.d.ts.map +1 -0
  374. package/src/core/color/REC709_PRIMARIES.js +53 -0
  375. package/src/core/color/construct/color_from_hex.d.ts +21 -0
  376. package/src/core/color/construct/color_from_hex.d.ts.map +1 -0
  377. package/src/core/color/construct/color_from_hex.js +33 -0
  378. package/src/core/color/construct/color_from_temperature.d.ts +22 -0
  379. package/src/core/color/construct/color_from_temperature.d.ts.map +1 -0
  380. package/src/core/color/construct/color_from_temperature.js +33 -0
  381. package/src/core/color/construct/color_from_uint24.d.ts +19 -0
  382. package/src/core/color/construct/color_from_uint24.d.ts.map +1 -0
  383. package/src/core/color/construct/color_from_uint24.js +26 -0
  384. package/src/core/color/construct/color_from_uint32.d.ts +20 -0
  385. package/src/core/color/construct/color_from_uint32.d.ts.map +1 -0
  386. package/src/core/color/construct/color_from_uint32.js +39 -0
  387. package/src/core/color/construct/color_gray.d.ts +17 -0
  388. package/src/core/color/construct/color_gray.d.ts.map +1 -0
  389. package/src/core/color/construct/color_gray.js +22 -0
  390. package/src/core/color/hex/hex2rgb.d.ts +1 -11
  391. package/src/core/color/hex/hex2rgb.d.ts.map +1 -1
  392. package/src/core/color/hex/hex2rgb.js +7 -24
  393. package/src/core/color/hex/hex_to_rgb.d.ts +18 -0
  394. package/src/core/color/hex/hex_to_rgb.d.ts.map +1 -0
  395. package/src/core/color/hex/hex_to_rgb.js +62 -0
  396. package/src/core/color/hex/rgb2hex.d.ts +1 -8
  397. package/src/core/color/hex/rgb2hex.d.ts.map +1 -1
  398. package/src/core/color/hex/rgb2hex.js +7 -13
  399. package/src/core/color/hex/rgb_to_hex.d.ts +9 -0
  400. package/src/core/color/hex/rgb_to_hex.d.ts.map +1 -0
  401. package/src/core/color/hex/rgb_to_hex.js +13 -0
  402. package/src/core/color/hex/rgba_to_hex.d.ts +19 -0
  403. package/src/core/color/hex/rgba_to_hex.d.ts.map +1 -0
  404. package/src/core/color/hex/rgba_to_hex.js +23 -0
  405. package/src/core/color/hsv/hsv2rgb.d.ts +1 -12
  406. package/src/core/color/hsv/hsv2rgb.d.ts.map +1 -1
  407. package/src/core/color/hsv/hsv2rgb.js +8 -21
  408. package/src/core/color/hsv/hsv2rgb_float.d.ts +1 -12
  409. package/src/core/color/hsv/hsv2rgb_float.d.ts.map +1 -1
  410. package/src/core/color/hsv/hsv2rgb_float.js +8 -56
  411. package/src/core/color/hsv/hsv_to_rgb.d.ts +13 -0
  412. package/src/core/color/hsv/hsv_to_rgb.d.ts.map +1 -0
  413. package/src/core/color/hsv/hsv_to_rgb.js +39 -0
  414. package/src/core/color/hsv/hsv_to_rgb_uint8.d.ts +13 -0
  415. package/src/core/color/hsv/hsv_to_rgb_uint8.d.ts.map +1 -0
  416. package/src/core/color/hsv/hsv_to_rgb_uint8.js +21 -0
  417. package/src/core/color/hsv/hue_to_rgb_sextant.d.ts +24 -0
  418. package/src/core/color/hsv/hue_to_rgb_sextant.d.ts.map +1 -0
  419. package/src/core/color/hsv/hue_to_rgb_sextant.js +67 -0
  420. package/src/core/color/hsv/rgb2hsv.d.ts +1 -12
  421. package/src/core/color/hsv/rgb2hsv.d.ts.map +1 -1
  422. package/src/core/color/hsv/rgb2hsv.js +7 -42
  423. package/src/core/color/hsv/rgb_to_hsv.d.ts +13 -0
  424. package/src/core/color/hsv/rgb_to_hsv.d.ts.map +1 -0
  425. package/src/core/color/hsv/rgb_to_hsv.js +42 -0
  426. package/src/core/color/hunt/hpe_to_xyz.d.ts +2 -0
  427. package/src/core/color/hunt/hpe_to_xyz.d.ts.map +1 -0
  428. package/src/core/color/hunt/hpe_to_xyz.js +4 -0
  429. package/src/core/color/hunt/xyz_to_hpe.d.ts +1 -6
  430. package/src/core/color/hunt/xyz_to_hpe.d.ts.map +1 -1
  431. package/src/core/color/hunt/xyz_to_hpe.js +12 -15
  432. package/src/core/color/illuminant/D65_spd_tabulated.d.ts.map +1 -1
  433. package/src/core/color/illuminant/D65_spd_tabulated.js +107 -104
  434. package/src/core/color/int2rgb.d.ts +1 -10
  435. package/src/core/color/int2rgb.d.ts.map +1 -1
  436. package/src/core/color/int2rgb.js +7 -12
  437. package/src/core/color/int_to_rgb.d.ts +21 -0
  438. package/src/core/color/int_to_rgb.d.ts.map +1 -0
  439. package/src/core/color/int_to_rgb.js +33 -0
  440. package/src/core/color/kelvin/kelvin_to_rgb.d.ts.map +1 -1
  441. package/src/core/color/kelvin/kelvin_to_rgb.js +22 -2
  442. package/src/core/color/kelvin/rgb_to_kelvin.d.ts +22 -2
  443. package/src/core/color/kelvin/rgb_to_kelvin.d.ts.map +1 -1
  444. package/src/core/color/kelvin/rgb_to_kelvin.js +22 -2
  445. package/src/core/color/lab/lab_to_xyz.d.ts +20 -0
  446. package/src/core/color/lab/lab_to_xyz.d.ts.map +1 -0
  447. package/src/core/color/lab/lab_to_xyz.js +69 -0
  448. package/src/core/color/oklab/gamut_clip_adaptive_l0.d.ts +34 -0
  449. package/src/core/color/oklab/gamut_clip_adaptive_l0.d.ts.map +1 -0
  450. package/src/core/color/oklab/gamut_clip_adaptive_l0.js +46 -0
  451. package/src/core/color/oklab/gamut_clip_at_l0.d.ts +33 -0
  452. package/src/core/color/oklab/gamut_clip_at_l0.d.ts.map +1 -0
  453. package/src/core/color/oklab/gamut_clip_at_l0.js +84 -0
  454. package/src/core/color/oklab/gamut_clip_preserve_chroma.d.ts +24 -0
  455. package/src/core/color/oklab/gamut_clip_preserve_chroma.d.ts.map +1 -0
  456. package/src/core/color/oklab/gamut_clip_preserve_chroma.js +37 -0
  457. package/src/core/color/oklab/gamut_clip_project_to_lcusp.d.ts +23 -0
  458. package/src/core/color/oklab/gamut_clip_project_to_lcusp.d.ts.map +1 -0
  459. package/src/core/color/oklab/gamut_clip_project_to_lcusp.js +46 -0
  460. package/src/core/color/oklab/linear_srgb_to_okhsl.d.ts +19 -0
  461. package/src/core/color/oklab/linear_srgb_to_okhsl.d.ts.map +1 -0
  462. package/src/core/color/oklab/linear_srgb_to_okhsl.js +93 -0
  463. package/src/core/color/oklab/linear_srgb_to_okhsv.d.ts +12 -4
  464. package/src/core/color/oklab/linear_srgb_to_okhsv.d.ts.map +1 -1
  465. package/src/core/color/oklab/linear_srgb_to_okhsv.js +108 -84
  466. package/src/core/color/oklab/linear_srgb_to_oklab.d.ts +13 -4
  467. package/src/core/color/oklab/linear_srgb_to_oklab.d.ts.map +1 -1
  468. package/src/core/color/oklab/linear_srgb_to_oklab.js +28 -19
  469. package/src/core/color/oklab/okhsl_chroma_bounds.d.ts +51 -0
  470. package/src/core/color/oklab/okhsl_chroma_bounds.d.ts.map +1 -0
  471. package/src/core/color/oklab/okhsl_chroma_bounds.js +128 -0
  472. package/src/core/color/oklab/okhsl_to_linear_srgb.d.ts +19 -0
  473. package/src/core/color/oklab/okhsl_to_linear_srgb.d.ts.map +1 -0
  474. package/src/core/color/oklab/okhsl_to_linear_srgb.js +85 -0
  475. package/src/core/color/oklab/oklab_to_oklch.d.ts +24 -0
  476. package/src/core/color/oklab/oklab_to_oklch.d.ts.map +1 -0
  477. package/src/core/color/oklab/oklab_to_oklch.js +35 -0
  478. package/src/core/color/oklab/oklch_to_oklab.d.ts +18 -0
  479. package/src/core/color/oklab/oklch_to_oklab.d.ts.map +1 -0
  480. package/src/core/color/oklab/oklch_to_oklab.js +26 -0
  481. package/src/core/color/oklab/toe.d.ts +12 -0
  482. package/src/core/color/oklab/toe.d.ts.map +1 -1
  483. package/src/core/color/oklab/toe.js +34 -22
  484. package/src/core/color/operations/color_add.d.ts +21 -0
  485. package/src/core/color/operations/color_add.d.ts.map +1 -0
  486. package/src/core/color/operations/color_add.js +23 -0
  487. package/src/core/color/operations/color_add_scaled.d.ts +20 -0
  488. package/src/core/color/operations/color_add_scaled.d.ts.map +1 -0
  489. package/src/core/color/operations/color_add_scaled.js +30 -0
  490. package/src/core/color/operations/color_clamp.d.ts +22 -0
  491. package/src/core/color/operations/color_clamp.d.ts.map +1 -0
  492. package/src/core/color/operations/color_clamp.js +25 -0
  493. package/src/core/color/operations/color_darken.d.ts +2 -1
  494. package/src/core/color/operations/color_darken.d.ts.map +1 -1
  495. package/src/core/color/operations/color_darken.js +25 -24
  496. package/src/core/color/operations/color_desaturate.d.ts +2 -1
  497. package/src/core/color/operations/color_desaturate.d.ts.map +1 -1
  498. package/src/core/color/operations/color_desaturate.js +25 -24
  499. package/src/core/color/operations/color_get_hsl.d.ts +18 -0
  500. package/src/core/color/operations/color_get_hsl.d.ts.map +1 -0
  501. package/src/core/color/operations/color_get_hsl.js +60 -0
  502. package/src/core/color/operations/color_is_in_gamut.d.ts +20 -0
  503. package/src/core/color/operations/color_is_in_gamut.d.ts.map +1 -0
  504. package/src/core/color/operations/color_is_in_gamut.js +30 -0
  505. package/src/core/color/operations/color_lerp.d.ts +12 -3
  506. package/src/core/color/operations/color_lerp.d.ts.map +1 -1
  507. package/src/core/color/operations/color_lerp.js +55 -46
  508. package/src/core/color/operations/color_lighten.d.ts +9 -5
  509. package/src/core/color/operations/color_lighten.d.ts.map +1 -1
  510. package/src/core/color/operations/color_lighten.js +29 -24
  511. package/src/core/color/operations/color_mix_okhsv_channel.d.ts +24 -0
  512. package/src/core/color/operations/color_mix_okhsv_channel.d.ts.map +1 -0
  513. package/src/core/color/operations/color_mix_okhsv_channel.js +48 -0
  514. package/src/core/color/operations/color_multiply_rgb.d.ts +21 -0
  515. package/src/core/color/operations/color_multiply_rgb.d.ts.map +1 -0
  516. package/src/core/color/operations/color_multiply_rgb.js +26 -0
  517. package/src/core/color/operations/color_saturate.d.ts +9 -5
  518. package/src/core/color/operations/color_saturate.d.ts.map +1 -1
  519. package/src/core/color/operations/color_saturate.js +29 -24
  520. package/src/core/color/operations/color_scale_okhsv_channel.d.ts +1 -1
  521. package/src/core/color/operations/color_scale_okhsv_channel.d.ts.map +1 -1
  522. package/src/core/color/operations/color_scale_okhsv_channel.js +58 -45
  523. package/src/core/color/operations/color_srgb_apply.d.ts +28 -0
  524. package/src/core/color/operations/color_srgb_apply.d.ts.map +1 -0
  525. package/src/core/color/operations/color_srgb_apply.js +40 -0
  526. package/src/core/color/operations/color_sub.d.ts +16 -0
  527. package/src/core/color/operations/color_sub.d.ts.map +1 -0
  528. package/src/core/color/operations/color_sub.js +18 -0
  529. package/src/core/color/parse_color.d.ts +10 -1
  530. package/src/core/color/parse_color.d.ts.map +1 -1
  531. package/src/core/color/parse_color.js +100 -84
  532. package/src/core/color/parse_color_normalized.d.ts +24 -0
  533. package/src/core/color/parse_color_normalized.d.ts.map +1 -0
  534. package/src/core/color/parse_color_normalized.js +38 -0
  535. package/src/core/color/rgb2uint24.d.ts +1 -8
  536. package/src/core/color/rgb2uint24.d.ts.map +1 -1
  537. package/src/core/color/rgb2uint24.js +7 -20
  538. package/src/core/color/rgb2uint32.d.ts +1 -9
  539. package/src/core/color/rgb2uint32.d.ts.map +1 -1
  540. package/src/core/color/rgb2uint32.js +7 -18
  541. package/src/core/color/rgb_to_luminance.d.ts +14 -5
  542. package/src/core/color/rgb_to_luminance.d.ts.map +1 -1
  543. package/src/core/color/rgb_to_luminance.js +24 -13
  544. package/src/core/color/rgb_to_uint24.d.ts +9 -0
  545. package/src/core/color/rgb_to_uint24.d.ts.map +1 -0
  546. package/src/core/color/rgb_to_uint24.js +20 -0
  547. package/src/core/color/rgb_to_uint32.d.ts +10 -0
  548. package/src/core/color/rgb_to_uint32.d.ts.map +1 -0
  549. package/src/core/color/rgb_to_uint32.js +21 -0
  550. package/src/core/color/sRGB/linear_to_sRGB.d.ts +7 -0
  551. package/src/core/color/sRGB/linear_to_sRGB.d.ts.map +1 -1
  552. package/src/core/color/sRGB/linear_to_sRGB.js +39 -32
  553. package/src/core/color/xyz/hpe_to_xyz.d.ts +24 -0
  554. package/src/core/color/xyz/hpe_to_xyz.d.ts.map +1 -0
  555. package/src/core/color/xyz/hpe_to_xyz.js +39 -0
  556. package/src/core/color/xyz/rgb_to_xyz.d.ts +17 -2
  557. package/src/core/color/xyz/rgb_to_xyz.d.ts.map +1 -1
  558. package/src/core/color/xyz/rgb_to_xyz.js +44 -18
  559. package/src/core/color/xyz/xyz_cmf_tabulated.d.ts.map +1 -1
  560. package/src/core/color/xyz/xyz_cmf_tabulated.js +217 -211
  561. package/src/core/color/xyz/xyz_cmf_wyman.d.ts +4 -0
  562. package/src/core/color/xyz/xyz_cmf_wyman.d.ts.map +1 -1
  563. package/src/core/color/xyz/xyz_cmf_wyman.js +74 -65
  564. package/src/core/color/xyz/xyz_to_hpe.d.ts +18 -0
  565. package/src/core/color/xyz/xyz_to_hpe.d.ts.map +1 -0
  566. package/src/core/color/xyz/xyz_to_hpe.js +33 -0
  567. package/src/core/color/xyz/xyz_to_rgb.d.ts +17 -2
  568. package/src/core/color/xyz/xyz_to_rgb.d.ts.map +1 -1
  569. package/src/core/color/xyz/xyz_to_rgb.js +39 -16
  570. package/src/core/color/ycxcz/xyz_to_ycxcz.d.ts +7 -2
  571. package/src/core/color/ycxcz/xyz_to_ycxcz.d.ts.map +1 -1
  572. package/src/core/color/ycxcz/xyz_to_ycxcz.js +33 -28
  573. package/src/core/events/signal/Signal.js +820 -820
  574. package/src/core/geom/3d/shape/ConvexHullShape3D.d.ts.map +1 -1
  575. package/src/core/geom/3d/shape/ConvexHullShape3D.js +28 -4
  576. package/src/core/math/clamp_index.d.ts +18 -0
  577. package/src/core/math/clamp_index.d.ts.map +1 -0
  578. package/src/core/math/clamp_index.js +23 -0
  579. package/src/engine/asset/loaders/image/IMAGE_CODEC_REVIEW_2026_08_28.md +803 -0
  580. package/src/engine/asset/loaders/image/jpeg/JpegFrame.d.ts +5 -3
  581. package/src/engine/asset/loaders/image/jpeg/JpegFrame.d.ts.map +1 -1
  582. package/src/engine/asset/loaders/image/jpeg/JpegFrame.js +5 -3
  583. package/src/engine/asset/loaders/image/jpeg/JpegFrameComponent.d.ts +2 -1
  584. package/src/engine/asset/loaders/image/jpeg/JpegFrameComponent.d.ts.map +1 -1
  585. package/src/engine/asset/loaders/image/jpeg/JpegFrameComponent.js +2 -1
  586. package/src/engine/asset/loaders/image/jpeg/JpegImage.d.ts +17 -0
  587. package/src/engine/asset/loaders/image/jpeg/JpegImage.d.ts.map +1 -1
  588. package/src/engine/asset/loaders/image/jpeg/JpegImage.js +197 -157
  589. package/src/engine/asset/loaders/image/jpeg/idct8x8_float.d.ts +0 -1
  590. package/src/engine/asset/loaders/image/jpeg/idct8x8_float.d.ts.map +1 -1
  591. package/src/engine/asset/loaders/image/jpeg/idct8x8_float.js +0 -1
  592. package/src/engine/asset/loaders/image/jpeg/jpeg_component_row.d.ts +28 -0
  593. package/src/engine/asset/loaders/image/jpeg/jpeg_component_row.d.ts.map +1 -0
  594. package/src/engine/asset/loaders/image/jpeg/jpeg_component_row.js +31 -0
  595. package/src/engine/asset/loaders/image/png/PNG.d.ts +3 -18
  596. package/src/engine/asset/loaders/image/png/PNG.d.ts.map +1 -1
  597. package/src/engine/asset/loaders/image/png/PNG.js +3 -139
  598. package/src/engine/asset/loaders/image/png/PNGReader.d.ts +16 -16
  599. package/src/engine/asset/loaders/image/png/PNGReader.d.ts.map +1 -1
  600. package/src/engine/asset/loaders/image/png/PNGReader.js +143 -160
  601. package/src/engine/asset/loaders/image/png/chunk/png_chunk_decode_iTXt.js +3 -3
  602. package/src/engine/asset/loaders/image/png/chunk/png_chunk_decode_zTXt.js +3 -3
  603. package/src/engine/asset/loaders/image/png/crc32.d.ts +1 -15
  604. package/src/engine/asset/loaders/image/png/crc32.d.ts.map +1 -1
  605. package/src/engine/asset/loaders/image/png/crc32.js +5 -89
  606. package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterNone.d.ts +12 -10
  607. package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterNone.d.ts.map +1 -1
  608. package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterNone.js +20 -45
  609. package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterSub.d.ts +2 -1
  610. package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterSub.d.ts.map +1 -1
  611. package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterSub.js +2 -0
  612. package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterUp.d.ts +2 -1
  613. package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterUp.d.ts.map +1 -1
  614. package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterUp.js +2 -0
  615. package/src/engine/asset/loaders/image/png/filter/png_unfilter.d.ts +22 -0
  616. package/src/engine/asset/loaders/image/png/filter/png_unfilter.d.ts.map +1 -0
  617. package/src/engine/asset/loaders/image/png/filter/png_unfilter.js +68 -0
  618. package/src/engine/asset/loaders/image/png/png_inflate.d.ts +20 -0
  619. package/src/engine/asset/loaders/image/png/png_inflate.d.ts.map +1 -0
  620. package/src/engine/asset/loaders/image/png/png_inflate.js +85 -0
  621. package/src/engine/asset/loaders/image/png/png_unpack_samples.d.ts +22 -0
  622. package/src/engine/asset/loaders/image/png/png_unpack_samples.d.ts.map +1 -0
  623. package/src/engine/asset/loaders/image/png/png_unpack_samples.js +38 -0
  624. package/src/engine/graphics/ecs/sprite/SpriteSystemPE.d.ts.map +1 -1
  625. package/src/engine/graphics/ecs/sprite/SpriteSystemPE.js +135 -132
  626. package/src/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.d.ts +16 -3
  627. package/src/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.d.ts.map +1 -1
  628. package/src/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.js +1157 -1149
  629. package/src/engine/graphics/render/frame_graph/FrameGraph.d.ts +26 -0
  630. package/src/engine/graphics/render/frame_graph/FrameGraph.d.ts.map +1 -1
  631. package/src/engine/graphics/render/frame_graph/FrameGraph.js +947 -900
  632. package/src/engine/physics/ecs/PhysicsSystem.d.ts +69 -81
  633. package/src/engine/physics/ecs/PhysicsSystem.d.ts.map +1 -1
  634. package/src/engine/physics/ecs/PhysicsSystem.js +83 -77
  635. package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
  636. package/src/shade/device/IMMEDIATE_DATA_PLAN_2026_08_28.md +451 -0
  637. package/src/shade/device/ShadeGPUCommandContext.d.ts +21 -0
  638. package/src/shade/device/ShadeGPUCommandContext.d.ts.map +1 -1
  639. package/src/shade/device/ShadeGPUCommandContext.js +940 -749
  640. package/src/shade/device/timing/GPUTimerArray.d.ts +22 -4
  641. package/src/shade/device/timing/GPUTimerArray.d.ts.map +1 -1
  642. package/src/shade/device/timing/GPUTimerArray.js +88 -14
  643. package/src/shade/device/timing/GPU_PROFILER_PROPOSAL_2026_08_28.md +876 -0
  644. package/src/shade/device/timing/profile/GPUFrameRecorder.d.ts +93 -0
  645. package/src/shade/device/timing/profile/GPUFrameRecorder.d.ts.map +1 -0
  646. package/src/shade/device/timing/profile/GPUFrameRecorder.js +297 -0
  647. package/src/shade/device/timing/profile/GPUProfileCapture.d.ts +62 -0
  648. package/src/shade/device/timing/profile/GPUProfileCapture.d.ts.map +1 -0
  649. package/src/shade/device/timing/profile/GPUProfileCapture.js +77 -0
  650. package/src/shade/device/timing/profile/GPUProfileFrame.d.ts +73 -0
  651. package/src/shade/device/timing/profile/GPUProfileFrame.d.ts.map +1 -0
  652. package/src/shade/device/timing/profile/GPUProfileFrame.js +88 -0
  653. package/src/shade/device/timing/profile/GPUProfileLevel.d.ts +20 -0
  654. package/src/shade/device/timing/profile/GPUProfileLevel.d.ts.map +1 -0
  655. package/src/shade/device/timing/profile/GPUProfileLevel.js +50 -0
  656. package/src/shade/device/timing/profile/GPUProfileMeta.d.ts +63 -0
  657. package/src/shade/device/timing/profile/GPUProfileMeta.d.ts.map +1 -0
  658. package/src/shade/device/timing/profile/GPUProfileMeta.js +73 -0
  659. package/src/shade/device/timing/profile/GPUProfileSession.d.ts +173 -0
  660. package/src/shade/device/timing/profile/GPUProfileSession.d.ts.map +1 -0
  661. package/src/shade/device/timing/profile/GPUProfileSession.js +470 -0
  662. package/src/shade/device/timing/profile/GPUProfileSpan.d.ts +60 -0
  663. package/src/shade/device/timing/profile/GPUProfileSpan.d.ts.map +1 -0
  664. package/src/shade/device/timing/profile/GPUProfileSpan.js +65 -0
  665. package/src/shade/device/timing/profile/GPUProfileSpanKind.d.ts +19 -0
  666. package/src/shade/device/timing/profile/GPUProfileSpanKind.d.ts.map +1 -0
  667. package/src/shade/device/timing/profile/GPUProfileSpanKind.js +25 -0
  668. package/src/shade/device/timing/profile/GPUProfileTopology.d.ts +159 -0
  669. package/src/shade/device/timing/profile/GPUProfileTopology.d.ts.map +1 -0
  670. package/src/shade/device/timing/profile/GPUProfileTopology.js +202 -0
  671. package/src/shade/device/timing/profile/GPUProfileWork.d.ts +90 -0
  672. package/src/shade/device/timing/profile/GPUProfileWork.d.ts.map +1 -0
  673. package/src/shade/device/timing/profile/GPUProfileWork.js +115 -0
  674. package/src/shade/device/timing/profile/SGPTDefect.d.ts +43 -0
  675. package/src/shade/device/timing/profile/SGPTDefect.d.ts.map +1 -0
  676. package/src/shade/device/timing/profile/SGPTDefect.js +65 -0
  677. package/src/shade/device/timing/profile/SGPTHeader.d.ts +38 -0
  678. package/src/shade/device/timing/profile/SGPTHeader.d.ts.map +1 -0
  679. package/src/shade/device/timing/profile/SGPTHeader.js +46 -0
  680. package/src/shade/device/timing/profile/SGPTRecordRef.d.ts +37 -0
  681. package/src/shade/device/timing/profile/SGPTRecordRef.d.ts.map +1 -0
  682. package/src/shade/device/timing/profile/SGPTRecordRef.js +45 -0
  683. package/src/shade/device/timing/profile/SGPTWriteStream.d.ts +103 -0
  684. package/src/shade/device/timing/profile/SGPTWriteStream.d.ts.map +1 -0
  685. package/src/shade/device/timing/profile/SGPTWriteStream.js +287 -0
  686. package/src/shade/device/timing/profile/SGPT_DEFECT.d.ts +19 -0
  687. package/src/shade/device/timing/profile/SGPT_DEFECT.d.ts.map +1 -0
  688. package/src/shade/device/timing/profile/SGPT_DEFECT.js +26 -0
  689. package/src/shade/device/timing/profile/SGPT_FLAG.d.ts +8 -0
  690. package/src/shade/device/timing/profile/SGPT_FLAG.d.ts.map +1 -0
  691. package/src/shade/device/timing/profile/SGPT_FLAG.js +15 -0
  692. package/src/shade/device/timing/profile/SGPT_FORMAT.md +345 -0
  693. package/src/shade/device/timing/profile/SGPT_FORMAT_VERSION.d.ts +10 -0
  694. package/src/shade/device/timing/profile/SGPT_FORMAT_VERSION.d.ts.map +1 -0
  695. package/src/shade/device/timing/profile/SGPT_FORMAT_VERSION.js +9 -0
  696. package/src/shade/device/timing/profile/SGPT_FRAME_SLACK.d.ts +17 -0
  697. package/src/shade/device/timing/profile/SGPT_FRAME_SLACK.d.ts.map +1 -0
  698. package/src/shade/device/timing/profile/SGPT_FRAME_SLACK.js +16 -0
  699. package/src/shade/device/timing/profile/SGPT_HEADER_CHECKSUM_COVERAGE.d.ts +16 -0
  700. package/src/shade/device/timing/profile/SGPT_HEADER_CHECKSUM_COVERAGE.d.ts.map +1 -0
  701. package/src/shade/device/timing/profile/SGPT_HEADER_CHECKSUM_COVERAGE.js +15 -0
  702. package/src/shade/device/timing/profile/SGPT_HEADER_OFFSET.d.ts +15 -0
  703. package/src/shade/device/timing/profile/SGPT_HEADER_OFFSET.d.ts.map +1 -0
  704. package/src/shade/device/timing/profile/SGPT_HEADER_OFFSET.js +29 -0
  705. package/src/shade/device/timing/profile/SGPT_HEADER_SIZE.d.ts +7 -0
  706. package/src/shade/device/timing/profile/SGPT_HEADER_SIZE.d.ts.map +1 -0
  707. package/src/shade/device/timing/profile/SGPT_HEADER_SIZE.js +6 -0
  708. package/src/shade/device/timing/profile/SGPT_MAGIC.d.ts +7 -0
  709. package/src/shade/device/timing/profile/SGPT_MAGIC.d.ts.map +1 -0
  710. package/src/shade/device/timing/profile/SGPT_MAGIC.js +6 -0
  711. package/src/shade/device/timing/profile/SGPT_MIN_READER_VERSION.d.ts +16 -0
  712. package/src/shade/device/timing/profile/SGPT_MIN_READER_VERSION.d.ts.map +1 -0
  713. package/src/shade/device/timing/profile/SGPT_MIN_READER_VERSION.js +15 -0
  714. package/src/shade/device/timing/profile/SGPT_RECORD_HEADER_SIZE.d.ts +7 -0
  715. package/src/shade/device/timing/profile/SGPT_RECORD_HEADER_SIZE.d.ts.map +1 -0
  716. package/src/shade/device/timing/profile/SGPT_RECORD_HEADER_SIZE.js +6 -0
  717. package/src/shade/device/timing/profile/SGPT_RECORD_OFFSET.d.ts +13 -0
  718. package/src/shade/device/timing/profile/SGPT_RECORD_OFFSET.d.ts.map +1 -0
  719. package/src/shade/device/timing/profile/SGPT_RECORD_OFFSET.js +23 -0
  720. package/src/shade/device/timing/profile/SGPT_RECORD_SYNC.d.ts +12 -0
  721. package/src/shade/device/timing/profile/SGPT_RECORD_SYNC.d.ts.map +1 -0
  722. package/src/shade/device/timing/profile/SGPT_RECORD_SYNC.js +11 -0
  723. package/src/shade/device/timing/profile/SGPT_RECORD_TYPE.d.ts +18 -0
  724. package/src/shade/device/timing/profile/SGPT_RECORD_TYPE.d.ts.map +1 -0
  725. package/src/shade/device/timing/profile/SGPT_RECORD_TYPE.js +46 -0
  726. package/src/shade/device/timing/profile/frame_graph_extract_topology.d.ts +20 -0
  727. package/src/shade/device/timing/profile/frame_graph_extract_topology.d.ts.map +1 -0
  728. package/src/shade/device/timing/profile/frame_graph_extract_topology.js +174 -0
  729. package/src/shade/device/timing/profile/make_profiling_pass_encoder.d.ts +21 -0
  730. package/src/shade/device/timing/profile/make_profiling_pass_encoder.d.ts.map +1 -0
  731. package/src/shade/device/timing/profile/make_profiling_pass_encoder.js +114 -0
  732. package/src/shade/device/timing/profile/parse_workgroup_size.d.ts +20 -0
  733. package/src/shade/device/timing/profile/parse_workgroup_size.d.ts.map +1 -0
  734. package/src/shade/device/timing/profile/parse_workgroup_size.js +43 -0
  735. package/src/shade/device/timing/profile/sgpt_fourcc.d.ts +18 -0
  736. package/src/shade/device/timing/profile/sgpt_fourcc.d.ts.map +1 -0
  737. package/src/shade/device/timing/profile/sgpt_fourcc.js +34 -0
  738. package/src/shade/device/timing/profile/sgpt_frame_codec.d.ts +42 -0
  739. package/src/shade/device/timing/profile/sgpt_frame_codec.d.ts.map +1 -0
  740. package/src/shade/device/timing/profile/sgpt_frame_codec.js +172 -0
  741. package/src/shade/device/timing/profile/sgpt_meta_codec.d.ts +20 -0
  742. package/src/shade/device/timing/profile/sgpt_meta_codec.d.ts.map +1 -0
  743. package/src/shade/device/timing/profile/sgpt_meta_codec.js +65 -0
  744. package/src/shade/device/timing/profile/sgpt_read_capture.d.ts +19 -0
  745. package/src/shade/device/timing/profile/sgpt_read_capture.d.ts.map +1 -0
  746. package/src/shade/device/timing/profile/sgpt_read_capture.js +134 -0
  747. package/src/shade/device/timing/profile/sgpt_read_header.d.ts +22 -0
  748. package/src/shade/device/timing/profile/sgpt_read_header.d.ts.map +1 -0
  749. package/src/shade/device/timing/profile/sgpt_read_header.js +94 -0
  750. package/src/shade/device/timing/profile/sgpt_read_records.d.ts +27 -0
  751. package/src/shade/device/timing/profile/sgpt_read_records.d.ts.map +1 -0
  752. package/src/shade/device/timing/profile/sgpt_read_records.js +153 -0
  753. package/src/shade/device/timing/profile/sgpt_topology_codec.d.ts +54 -0
  754. package/src/shade/device/timing/profile/sgpt_topology_codec.d.ts.map +1 -0
  755. package/src/shade/device/timing/profile/sgpt_topology_codec.js +329 -0
  756. package/src/shade/device/timing/profile/sgpt_write_header.d.ts +22 -0
  757. package/src/shade/device/timing/profile/sgpt_write_header.d.ts.map +1 -0
  758. package/src/shade/device/timing/profile/sgpt_write_header.js +47 -0
  759. package/src/shade/device/timing/profile/sgpt_write_record.d.ts +23 -0
  760. package/src/shade/device/timing/profile/sgpt_write_record.d.ts.map +1 -0
  761. package/src/shade/device/timing/profile/sgpt_write_record.js +62 -0
  762. package/src/shade/renderer/Renderer.d.ts +21 -0
  763. package/src/shade/renderer/Renderer.d.ts.map +1 -1
  764. package/src/shade/renderer/Renderer.js +2513 -2455
  765. package/src/shade/renderer/postprocess/nss/NSS.d.ts +1 -1
  766. package/src/shade/renderer/scene/serialization/decode_image_source_hdr.d.ts +14 -3
  767. package/src/shade/renderer/scene/serialization/decode_image_source_hdr.d.ts.map +1 -1
  768. package/src/shade/renderer/scene/serialization/decode_image_source_hdr.js +50 -51
  769. package/src/shade/renderer/scene/serialization/deserialize_scene.d.ts.map +1 -1
  770. package/src/shade/renderer/scene/serialization/deserialize_scene.js +531 -521
  771. package/src/shade/renderer/scene/serialization/write_image_source.d.ts.map +1 -1
  772. package/src/shade/renderer/scene/serialization/write_image_source.js +6 -4
  773. package/src/shade/renderer/shader/chunk/color/chunk_rgb_to_luminance.d.ts.map +1 -1
  774. package/src/shade/renderer/shader/chunk/color/chunk_rgb_to_luminance.js +34 -32
  775. package/src/shade/renderer/shader/chunk/color/iCtCp/chunk_eotf_st2084.d.ts +31 -0
  776. package/src/shade/renderer/shader/chunk/color/iCtCp/chunk_eotf_st2084.d.ts.map +1 -1
  777. package/src/shade/renderer/shader/chunk/color/iCtCp/chunk_eotf_st2084.js +62 -31
  778. package/src/shade/renderer/shader/chunk/color/iCtCp/chunk_inverse_eotf_st2084.d.ts +10 -0
  779. package/src/shade/renderer/shader/chunk/color/iCtCp/chunk_inverse_eotf_st2084.d.ts.map +1 -1
  780. package/src/shade/renderer/shader/chunk/color/iCtCp/chunk_inverse_eotf_st2084.js +32 -22
  781. package/src/shade/renderer/shader/chunk/color/sRGB/chunk_sRGBTransferOETF.d.ts.map +1 -1
  782. package/src/shade/renderer/shader/chunk/color/sRGB/chunk_sRGBTransferOETF.js +22 -21
  783. package/src/shade/renderer/shader/chunk/color/tonemap/gt7/chunk_tonemap_gt7.d.ts +6 -0
  784. package/src/shade/renderer/shader/chunk/color/tonemap/gt7/chunk_tonemap_gt7.d.ts.map +1 -1
  785. package/src/shade/renderer/shader/chunk/color/tonemap/gt7/chunk_tonemap_gt7.js +110 -104
  786. package/src/shade/renderer/shader/chunk/color/xyz/chunk_rgb_to_xyz.d.ts.map +1 -1
  787. package/src/shade/renderer/shader/chunk/color/xyz/chunk_rgb_to_xyz.js +23 -21
  788. package/src/view/elements/ColorPickerView.js +296 -296
  789. package/src/avif/codec/dec/Readme.md +0 -14
  790. package/src/avif/codec/dec/avif_dec.cpp +0 -234
  791. package/src/avif/codec/dec/avif_dec.d.ts +0 -3
  792. package/src/avif/codec/dec/avif_dec.d.ts.map +0 -1
  793. package/src/avif/codec/dec/avif_dec.js +0 -16
  794. package/src/avif/codec/dec/avif_dec.wasm +0 -0
  795. package/src/avif/codec/enc/README.md +0 -37
  796. package/src/avif/codec/enc/avif_enc.cpp +0 -216
  797. package/src/avif/codec/enc/avif_enc.d.ts +0 -3
  798. package/src/avif/codec/enc/avif_enc.d.ts.map +0 -1
  799. package/src/avif/codec/enc/avif_enc.js +0 -6144
  800. package/src/avif/codec/enc/avif_enc.wasm +0 -0
  801. package/src/avif/codec/enc/avif_enc_mt.d.ts +0 -3
  802. package/src/avif/codec/enc/avif_enc_mt.d.ts.map +0 -1
  803. package/src/avif/codec/enc/avif_enc_mt.js +0 -6811
  804. package/src/avif/codec/enc/avif_enc_mt.wasm +0 -0
  805. package/src/avif/codec/enc/avif_enc_mt.worker.d.mts +0 -2
  806. package/src/avif/codec/enc/avif_enc_mt.worker.d.mts.map +0 -1
  807. package/src/avif/codec/enc/avif_enc_mt.worker.d.ts +0 -11
  808. package/src/avif/codec/enc/avif_enc_mt.worker.d.ts.map +0 -1
  809. package/src/avif/codec/enc/avif_enc_mt.worker.js +0 -171
  810. package/src/avif/codec/enc/avif_enc_mt.worker.mjs +0 -1
  811. package/src/avif/decode.d.ts +0 -3
  812. package/src/avif/decode.d.ts.map +0 -1
  813. package/src/avif/decode.js +0 -42
  814. package/src/avif/encode.d.ts +0 -3
  815. package/src/avif/encode.d.ts.map +0 -1
  816. package/src/avif/encode.js +0 -75
  817. package/src/avif/meta.d.ts +0 -24
  818. package/src/avif/meta.d.ts.map +0 -1
  819. package/src/avif/meta.js +0 -23
  820. package/src/avif/tsconfig.tsbuildinfo +0 -1
  821. package/src/avif/utils.d.ts +0 -17
  822. package/src/avif/utils.d.ts.map +0 -1
  823. package/src/avif/utils.js +0 -31
  824. package/src/engine/asset/loaders/image/jpeg/idct8x8_fixed.d.ts +0 -23
  825. package/src/engine/asset/loaders/image/jpeg/idct8x8_fixed.d.ts.map +0 -1
  826. package/src/engine/asset/loaders/image/jpeg/idct8x8_fixed.js +0 -214
  827. package/src/engine/asset/loaders/image/png/inflate.d.ts +0 -7
  828. package/src/engine/asset/loaders/image/png/inflate.d.ts.map +0 -1
  829. package/src/engine/asset/loaders/image/png/inflate.js +0 -20
  830. package/src/engine/save/GameStateLoader.d.ts +0 -49
  831. package/src/engine/save/GameStateLoader.d.ts.map +0 -1
  832. package/src/engine/save/GameStateLoader.js +0 -168
@@ -1,820 +1,820 @@
1
- import { assert } from "../../assert.js";
2
- import { signal_handler_list_find } from "./signal_handler_list_find.js";
3
- import { SignalFlags } from "./SignalFlags.js";
4
- import { SignalHandler, SignalHandlerFlags } from "./SignalHandler.js";
5
-
6
-
7
- /**
8
- * Signal is a type of event bus. You can subscribe to events using {@link add} method and dispatch using sendN method where N is the number of arguments you wish to pass.
9
- * Signal is different from a normal event bus in that 1 signal corresponds to 1 event type. For example, in HTML you have `addEventListener` which lets you subscribe to any kind of event, let's use "mousedown" as a reference.
10
- * Using a Signal you would instead have a signal corresponding to "mousedown" and dispatch this signal only for this event.
11
- * @example
12
- * const mouseDown = new Signal<MouseEvent>();
13
- * mouseDown.send1(myMouseEvent);
14
- */
15
- export class Signal {
16
- /**
17
- * Map is used to speed up lookup when removing handlers in case of large number of listeners.
18
- * @private
19
- * @type {Map<function,SignalHandler>}
20
- */
21
- handlers = new Map();
22
-
23
- /**
24
- * Internal flag bitmask
25
- * @private
26
- * @type {number}
27
- */
28
- flags = 0;
29
-
30
- /**
31
- * Used to track dispatches, handlers that have the same generation ID as the signal will not be dispatched
32
- * @type {number}
33
- */
34
- generation = 0;
35
-
36
- /**
37
- *
38
- * @returns {boolean}
39
- */
40
- get silent() {
41
- return this.getFlag(SignalFlags.Silent);
42
- }
43
-
44
-
45
- /**
46
- *
47
- * @param {boolean} v
48
- */
49
- set silent(v) {
50
- this.writeFlag(SignalFlags.Silent, v);
51
- }
52
-
53
-
54
- /**
55
- *
56
- * @param {number|SignalFlags} flag
57
- * @returns {void}
58
- */
59
- setFlag(flag) {
60
- this.flags |= flag;
61
- }
62
-
63
- /**
64
- *
65
- * @param {number|SignalFlags} flag
66
- * @returns {void}
67
- */
68
- clearFlag(flag) {
69
- this.flags &= ~flag;
70
- }
71
-
72
- /**
73
- *
74
- * @param {number|SignalFlags} flag
75
- * @param {boolean} value
76
- */
77
- writeFlag(flag, value) {
78
- if (value) {
79
- this.setFlag(flag);
80
- } else {
81
- this.clearFlag(flag);
82
- }
83
- }
84
-
85
- /**
86
- *
87
- * @param {number|SignalFlags} flag
88
- * @returns {boolean}
89
- */
90
- getFlag(flag) {
91
- return (this.flags & flag) === flag;
92
- }
93
-
94
-
95
- /**
96
- * Checks if a given signal handler is present or not
97
- * @param {function} handler
98
- * @param {*} [thisArg] if not present, will not be considered
99
- * @returns {boolean}
100
- */
101
- contains(handler, thisArg) {
102
- const handlers = this.handlers;
103
-
104
- const sh = handlers.get(handler);
105
-
106
- if (sh === undefined) {
107
- return false;
108
- }
109
-
110
- const existing = signal_handler_list_find(sh, handler, thisArg);
111
-
112
- return existing !== null;
113
- }
114
-
115
- mute() {
116
- this.setFlag(SignalFlags.Silent);
117
- }
118
-
119
- unmute() {
120
- this.clearFlag(SignalFlags.Silent);
121
- }
122
-
123
- /**
124
- * Tells if there are any handlers attached to the signal or not
125
- * @returns {boolean}
126
- */
127
- hasHandlers() {
128
- return this.handlers.size > 0;
129
- }
130
-
131
- /**
132
- * Handler will only be run once, it will be removed automatically after the first execution
133
- * @param {function} h
134
- * @param {*} [context]
135
- */
136
- addOne(h, context) {
137
- assert.isFunction(h, "handler");
138
-
139
- const handler = new SignalHandler(h, context);
140
-
141
- handler.setFlag(SignalHandlerFlags.RemoveAfterExecution);
142
-
143
- this.#add_handler(handler);
144
- }
145
-
146
- /**
147
- *
148
- * @param {function} h
149
- * @param {*} [context]
150
- */
151
- add(h, context) {
152
- assert.isFunction(h, "handler");
153
-
154
- const handler = new SignalHandler(h, context);
155
-
156
- this.#add_handler(handler);
157
-
158
- }
159
-
160
- /**
161
- *
162
- * @param {SignalHandler} handler
163
- */
164
- #add_handler(handler) {
165
-
166
- handler.generation = this.generation;
167
-
168
- const f = handler.handle;
169
- const first = this.handlers.get(f);
170
-
171
- if (first === undefined) {
172
- this.handlers.set(f, handler);
173
- } else {
174
-
175
- handler.next = first;
176
- this.handlers.set(f, handler);
177
-
178
- // const last = signal_handler_list_last(first);
179
-
180
- // last.next = handler;
181
-
182
- // assert.ok(signal_handler_list_validate(first, console.error), 'invalid configuration');
183
-
184
- }
185
-
186
- }
187
-
188
- /**
189
- *
190
- * @param {function} h
191
- * @param {*} [thisArg] if supplied, will match handlers with a specific context only
192
- * @returns {boolean} true if a handler was removed, false otherwise
193
- */
194
- remove(h, thisArg) {
195
- assert.isFunction(h, "handler");
196
-
197
- const first = this.handlers.get(h);
198
-
199
- if (first === undefined) {
200
- return false;
201
- }
202
-
203
- if (first.handle === h && first.context === thisArg) {
204
- if (first.next === null) {
205
- this.handlers.delete(h);
206
- } else {
207
- this.handlers.set(h, first.next)
208
- // assert.ok(signal_handler_list_validate(first.next, console.error), 'invalid configuration');
209
- }
210
-
211
- return true;
212
- }
213
-
214
- let previous = first;
215
- let n = first.next;
216
-
217
- while (n !== null) {
218
-
219
- if (n.handle === h && n.context === thisArg) {
220
-
221
- previous.next = n.next;
222
-
223
- // assert.ok(signal_handler_list_validate(first, console.error), 'invalid configuration');
224
-
225
- return true;
226
-
227
- }
228
-
229
- previous = n;
230
- n = n.next;
231
-
232
- }
233
-
234
- return false;
235
- }
236
-
237
- /**
238
- * **UNSAFE**
239
- *
240
- * Remove all handlers.
241
- * Please note that this will remove even all handlers, irrespective of where they were added from. If another script is attaching to the same signal, using this method will potentially break that code.
242
- * For most use cases, prefer to use {@link remove} method instead, or make use of {@link SignalBinding} if you need to keep track of multiple handlers
243
- * NOTE: Consider this method to be unsafe, only use it when you understand the implications
244
- * @deprecated
245
- */
246
- removeAll() {
247
- this.handlers.clear();
248
- }
249
-
250
- /**
251
- *
252
- * @param {SignalHandler} handler
253
- */
254
- #remove_handler_internal(handler) {
255
-
256
- const first = this.handlers.get(handler.handle);
257
-
258
- if (first === undefined) {
259
- // nothing
260
- return false;
261
- }
262
-
263
- // special case for first
264
- if (first === handler) {
265
-
266
- if (first.next === null) {
267
- // was the only one
268
- this.handlers.delete(handler.handle);
269
- } else {
270
- this.handlers.set(handler.handle, first.next);
271
- // assert.ok(signal_handler_list_validate(first.next, console.error), 'invalid configuration');
272
- }
273
-
274
- return true;
275
- }
276
-
277
- let previous = first;
278
- let n = first.next;
279
-
280
- while (n !== null) {
281
-
282
- const next = n.next;
283
-
284
- if (n === handler) {
285
- previous.next = next;
286
-
287
- // assert.ok(signal_handler_list_validate(first, console.error), 'invalid configuration');
288
-
289
- return true;
290
- }
291
-
292
- previous = n;
293
- n = next;
294
-
295
- }
296
-
297
- // not found
298
- return false;
299
- }
300
-
301
- /**
302
- * Utility method, useful in asynchronous programming.
303
- * Will resolve at the next {@link dispatch}/{@link send0}/etc.
304
- * @return {Promise<[]>}
305
- * @see addOne
306
- *
307
- * @example
308
- * const s = new Signal<number,number>();
309
- *
310
- * // ...
311
- * const [x,y] = await s.promise(); // will trigger at the next dispatch
312
- *
313
- * // ... then somewhere else
314
- * s.send2(7,-3);
315
- */
316
- promise(){
317
- return new Promise((resolve, reject)=>{
318
- this.addOne((...args)=>{
319
- resolve(args);
320
- })
321
- });
322
- }
323
-
324
- /**
325
- * NOTE: because of polymorphic call-site nature of this method, it's always better for performance to use monomorphic methods like `send0`, `send1` etc.
326
- * @param {...*} args
327
- */
328
- dispatch(...args) {
329
- if ((this.flags & SignalFlags.Silent) !== 0) {
330
- //don't dispatch any events while silent
331
- return;
332
- }
333
-
334
- this.generation++;
335
-
336
- const handlers = this.handlers;
337
-
338
- for (const handle of handlers.values()) {
339
-
340
- let _h = handle;
341
-
342
- do {
343
-
344
- const next = _h.next;
345
-
346
- if(_h.generation < this.generation) {
347
- // only process if handler was attached before this dispatch
348
-
349
- if (_h.getFlag(SignalHandlerFlags.RemoveAfterExecution)) {
350
- //handler should be cut
351
- this.#remove_handler_internal(_h);
352
- }
353
-
354
- const _f = _h.handle;
355
-
356
- try {
357
- _f.apply(_h.context, args)
358
- } catch (e) {
359
- console.error("Failed to dispatch handler", _f, e);
360
- }
361
-
362
- }
363
-
364
- _h = next;
365
-
366
- } while (_h !== null);
367
-
368
-
369
- }
370
-
371
- }
372
-
373
-
374
- /**
375
- * dispatch without a value.
376
- * Allows JS engine to optimize for monomorphic call sites
377
- */
378
- send0() {
379
-
380
- assert.equal(arguments.length, 0, "send0 should not have any arguments")
381
-
382
- if ((this.flags & SignalFlags.Silent) !== 0) {
383
- //don't dispatch any events while silent
384
- return;
385
- }
386
-
387
- this.generation++;
388
-
389
- const handlers = this.handlers;
390
-
391
- for (const handle of handlers.values()) {
392
-
393
- let _h = handle;
394
-
395
- do {
396
-
397
- const next = _h.next;
398
-
399
- if(_h.generation < this.generation) {
400
- // only process if handler was attached before this dispatch
401
-
402
- if (_h.getFlag(SignalHandlerFlags.RemoveAfterExecution)) {
403
- //handler should be cut
404
- this.#remove_handler_internal(_h);
405
- }
406
-
407
- const _f = _h.handle;
408
-
409
- try {
410
- _f.call(_h.context)
411
- } catch (e) {
412
- console.error("Failed to dispatch handler", _f, e);
413
- }
414
- }
415
-
416
- _h = next;
417
-
418
- } while (_h !== null);
419
-
420
-
421
- }
422
-
423
- }
424
-
425
- /**
426
- * dispatch with a single value.
427
- * Allows JS engine to optimize for monomorphic call sites
428
- * @param {*} arg
429
- */
430
- send1(arg) {
431
-
432
- assert.equal(arguments.length, 1, "send1 expects exactly 1 argument")
433
-
434
- if ((this.flags & SignalFlags.Silent) !== 0) {
435
- //don't dispatch any events while silent
436
- return;
437
- }
438
-
439
- this.generation++;
440
-
441
- const handlers = this.handlers;
442
-
443
- for (const handle of handlers.values()) {
444
-
445
- let _h = handle;
446
-
447
- do {
448
-
449
- const next = _h.next;
450
-
451
- if(_h.generation < this.generation) {
452
- // only process if handler was attached before this dispatch
453
- if (_h.getFlag(SignalHandlerFlags.RemoveAfterExecution)) {
454
- //handler should be cut
455
- this.#remove_handler_internal(_h);
456
- }
457
-
458
- const _f = _h.handle;
459
-
460
- try {
461
- _f.call(_h.context, arg)
462
- } catch (e) {
463
- console.error("Failed to dispatch handler", _f, e);
464
- }
465
- }
466
-
467
- _h = next;
468
-
469
- } while (_h !== null);
470
-
471
-
472
- }
473
-
474
- }
475
-
476
- /**
477
- *
478
- * @param {*} a
479
- * @param {*} b
480
- */
481
- send2(a, b) {
482
-
483
- assert.equal(arguments.length, 2, "send2 expects exactly 2 arguments")
484
-
485
- if ((this.flags & SignalFlags.Silent) !== 0) {
486
- //don't dispatch any events while silent
487
- return;
488
- }
489
-
490
- this.generation++;
491
-
492
- const handlers = this.handlers;
493
-
494
- for (const handle of handlers.values()) {
495
-
496
- let _h = handle;
497
-
498
- do {
499
-
500
- const next = _h.next;
501
-
502
- if(_h.generation < this.generation) {
503
- // only process if handler was attached before this dispatch
504
- if (_h.getFlag(SignalHandlerFlags.RemoveAfterExecution)) {
505
- //handler should be cut
506
- this.#remove_handler_internal(_h);
507
- }
508
-
509
- const _f = _h.handle;
510
-
511
- try {
512
- _f.call(_h.context, a, b)
513
- } catch (e) {
514
- console.error("Failed to dispatch handler", _f, e);
515
- }
516
- }
517
-
518
- _h = next;
519
-
520
- } while (_h !== null);
521
-
522
-
523
- }
524
- }
525
-
526
- /**
527
- *
528
- * @param {*} a
529
- * @param {*} b
530
- * @param {*} c
531
- */
532
- send3(a, b, c) {
533
-
534
- assert.equal(arguments.length, 3, "send3 expects exactly 3 arguments")
535
-
536
- if ((this.flags & SignalFlags.Silent) !== 0) {
537
- //don't dispatch any events while silent
538
- return;
539
- }
540
-
541
- this.generation++;
542
-
543
- const handlers = this.handlers;
544
-
545
- for (const handle of handlers.values()) {
546
-
547
- let _h = handle;
548
-
549
- do {
550
-
551
- const next = _h.next;
552
-
553
- if(_h.generation < this.generation) {
554
- // only process if handler was attached before this dispatch
555
- if (_h.getFlag(SignalHandlerFlags.RemoveAfterExecution)) {
556
- //handler should be cut
557
- this.#remove_handler_internal(_h);
558
- }
559
-
560
- const _f = _h.handle;
561
-
562
- try {
563
- _f.call(_h.context, a, b, c)
564
- } catch (e) {
565
- console.error("Failed to dispatch handler", _f, e);
566
- }
567
- }
568
-
569
- _h = next;
570
-
571
- } while (_h !== null);
572
-
573
-
574
- }
575
- }
576
-
577
- /**
578
- *
579
- * @param {*} a
580
- * @param {*} b
581
- * @param {*} c
582
- * @param {*} d
583
- */
584
- send4(a, b, c, d) {
585
-
586
- assert.equal(arguments.length, 4, "send4 expects exactly 4 arguments")
587
-
588
- if ((this.flags & SignalFlags.Silent) !== 0) {
589
- //don't dispatch any events while silent
590
- return;
591
- }
592
-
593
- this.generation++;
594
-
595
- const handlers = this.handlers;
596
-
597
- for (const handle of handlers.values()) {
598
-
599
- let _h = handle;
600
-
601
- do {
602
-
603
- const next = _h.next;
604
-
605
- if(_h.generation < this.generation) {
606
- // only process if handler was attached before this dispatch
607
- if (_h.getFlag(SignalHandlerFlags.RemoveAfterExecution)) {
608
- //handler should be cut
609
- this.#remove_handler_internal(_h);
610
- }
611
-
612
- const _f = _h.handle;
613
-
614
- try {
615
- _f.call(_h.context, a, b, c, d)
616
- } catch (e) {
617
- console.error("Failed to dispatch handler", _f, e);
618
- }
619
- }
620
-
621
- _h = next;
622
-
623
- } while (_h !== null);
624
-
625
-
626
- }
627
- }
628
-
629
- /**
630
- *
631
- * @param {*} a
632
- * @param {*} b
633
- * @param {*} c
634
- * @param {*} d
635
- * @param {*} e
636
- */
637
- send5(a, b, c, d, e) {
638
-
639
- assert.equal(arguments.length, 5, "send5 expects exactly 5 arguments")
640
-
641
- if ((this.flags & SignalFlags.Silent) !== 0) {
642
- //don't dispatch any events while silent
643
- return;
644
- }
645
-
646
- this.generation++;
647
-
648
- const handlers = this.handlers;
649
-
650
- for (const handle of handlers.values()) {
651
-
652
- let _h = handle;
653
-
654
- do {
655
-
656
- const next = _h.next;
657
-
658
- if(_h.generation < this.generation) {
659
- // only process if handler was attached before this dispatch
660
- if (_h.getFlag(SignalHandlerFlags.RemoveAfterExecution)) {
661
- //handler should be cut
662
- this.#remove_handler_internal(_h);
663
- }
664
-
665
- const _f = _h.handle;
666
-
667
- try {
668
- _f.call(_h.context, a, b, c, d, e)
669
- } catch (e) {
670
- console.error("Failed to dispatch handler", _f, e);
671
- }
672
- }
673
-
674
- _h = next;
675
-
676
- } while (_h !== null);
677
-
678
-
679
- }
680
- }
681
-
682
- /**
683
- *
684
- * @param {*} a
685
- * @param {*} b
686
- * @param {*} c
687
- * @param {*} d
688
- * @param {*} e
689
- * @param {*} f
690
- */
691
- send6(a, b, c, d, e, f) {
692
-
693
- assert.equal(arguments.length, 6, "send6 expects exactly 6 arguments")
694
-
695
- if ((this.flags & SignalFlags.Silent) !== 0) {
696
- //don't dispatch any events while silent
697
- return;
698
- }
699
-
700
- this.generation++;
701
-
702
- const handlers = this.handlers;
703
-
704
- for (const handle of handlers.values()) {
705
-
706
- let _h = handle;
707
-
708
- do {
709
-
710
- const next = _h.next;
711
-
712
- if(_h.generation < this.generation) {
713
- // only process if handler was attached before this dispatch
714
- if (_h.getFlag(SignalHandlerFlags.RemoveAfterExecution)) {
715
- //handler should be cut
716
- this.#remove_handler_internal(_h);
717
- }
718
-
719
- const _f = _h.handle;
720
-
721
- try {
722
- _f.call(_h.context, a, b, c, d, e, f)
723
- } catch (e) {
724
- console.error("Failed to dispatch handler", f, e);
725
- }
726
- }
727
-
728
- _h = next;
729
-
730
- } while (_h !== null);
731
-
732
-
733
- }
734
- }
735
-
736
- /**
737
- *
738
- * @param {*} a
739
- * @param {*} b
740
- * @param {*} c
741
- * @param {*} d
742
- * @param {*} e
743
- * @param {*} f
744
- * @param {*} g
745
- * @param {*} h
746
- */
747
- send8(a, b, c, d, e, f, g, h) {
748
-
749
- assert.equal(arguments.length, 8, "send8 expects exactly 8 arguments")
750
-
751
- if ((this.flags & SignalFlags.Silent) !== 0) {
752
- //don't dispatch any events while silent
753
- return;
754
- }
755
-
756
- this.generation++;
757
-
758
- const handlers = this.handlers;
759
-
760
- for (const handle of handlers.values()) {
761
-
762
- let _h = handle;
763
-
764
- do {
765
-
766
- const next = _h.next;
767
-
768
- if(_h.generation < this.generation) {
769
- // only process if handler was attached before this dispatch
770
- if (_h.getFlag(SignalHandlerFlags.RemoveAfterExecution)) {
771
- //handler should be cut
772
- this.#remove_handler_internal(_h);
773
- }
774
-
775
- const _f = _h.handle;
776
-
777
- try {
778
- _f.call(_h.context, a, b, c, d, e, f, g, h)
779
- } catch (e) {
780
- console.error("Failed to dispatch handler", f, e);
781
- }
782
- }
783
-
784
- _h = next;
785
-
786
- } while (_h !== null);
787
-
788
-
789
- }
790
- }
791
-
792
- /**
793
- *
794
- * @param {Signal} other
795
- * @returns {Signal} merged signal combining events from this and other
796
- */
797
- merge(other) {
798
- const result = new Signal();
799
-
800
- function handler() {
801
- // spread: dispatch takes varargs, so passing the arguments object
802
- // forwards it as a single argument to every subscriber
803
- result.dispatch(...arguments);
804
- }
805
-
806
- this.add(handler);
807
- other.add(handler);
808
-
809
- return result;
810
- }
811
- }
812
-
813
-
814
- /**
815
- * @readonly
816
- * @type {boolean}
817
- */
818
- Signal.prototype.isSignal = true;
819
-
820
- export default Signal;
1
+ import { assert } from "../../assert.js";
2
+ import { signal_handler_list_find } from "./signal_handler_list_find.js";
3
+ import { SignalFlags } from "./SignalFlags.js";
4
+ import { SignalHandler, SignalHandlerFlags } from "./SignalHandler.js";
5
+
6
+
7
+ /**
8
+ * Signal is a type of event bus. You can subscribe to events using {@link add} method and dispatch using sendN method where N is the number of arguments you wish to pass.
9
+ * Signal is different from a normal event bus in that 1 signal corresponds to 1 event type. For example, in HTML you have `addEventListener` which lets you subscribe to any kind of event, let's use "mousedown" as a reference.
10
+ * Using a Signal you would instead have a signal corresponding to "mousedown" and dispatch this signal only for this event.
11
+ * @example
12
+ * const mouseDown = new Signal<MouseEvent>();
13
+ * mouseDown.send1(myMouseEvent);
14
+ */
15
+ export class Signal {
16
+ /**
17
+ * Map is used to speed up lookup when removing handlers in case of large number of listeners.
18
+ * @private
19
+ * @type {Map<function,SignalHandler>}
20
+ */
21
+ handlers = new Map();
22
+
23
+ /**
24
+ * Internal flag bitmask
25
+ * @private
26
+ * @type {number}
27
+ */
28
+ flags = 0;
29
+
30
+ /**
31
+ * Used to track dispatches, handlers that have the same generation ID as the signal will not be dispatched
32
+ * @type {number}
33
+ */
34
+ generation = 0;
35
+
36
+ /**
37
+ *
38
+ * @returns {boolean}
39
+ */
40
+ get silent() {
41
+ return this.getFlag(SignalFlags.Silent);
42
+ }
43
+
44
+
45
+ /**
46
+ *
47
+ * @param {boolean} v
48
+ */
49
+ set silent(v) {
50
+ this.writeFlag(SignalFlags.Silent, v);
51
+ }
52
+
53
+
54
+ /**
55
+ *
56
+ * @param {number|SignalFlags} flag
57
+ * @returns {void}
58
+ */
59
+ setFlag(flag) {
60
+ this.flags |= flag;
61
+ }
62
+
63
+ /**
64
+ *
65
+ * @param {number|SignalFlags} flag
66
+ * @returns {void}
67
+ */
68
+ clearFlag(flag) {
69
+ this.flags &= ~flag;
70
+ }
71
+
72
+ /**
73
+ *
74
+ * @param {number|SignalFlags} flag
75
+ * @param {boolean} value
76
+ */
77
+ writeFlag(flag, value) {
78
+ if (value) {
79
+ this.setFlag(flag);
80
+ } else {
81
+ this.clearFlag(flag);
82
+ }
83
+ }
84
+
85
+ /**
86
+ *
87
+ * @param {number|SignalFlags} flag
88
+ * @returns {boolean}
89
+ */
90
+ getFlag(flag) {
91
+ return (this.flags & flag) === flag;
92
+ }
93
+
94
+
95
+ /**
96
+ * Checks if a given signal handler is present or not
97
+ * @param {function} handler
98
+ * @param {*} [thisArg] if not present, will not be considered
99
+ * @returns {boolean}
100
+ */
101
+ contains(handler, thisArg) {
102
+ const handlers = this.handlers;
103
+
104
+ const sh = handlers.get(handler);
105
+
106
+ if (sh === undefined) {
107
+ return false;
108
+ }
109
+
110
+ const existing = signal_handler_list_find(sh, handler, thisArg);
111
+
112
+ return existing !== null;
113
+ }
114
+
115
+ mute() {
116
+ this.setFlag(SignalFlags.Silent);
117
+ }
118
+
119
+ unmute() {
120
+ this.clearFlag(SignalFlags.Silent);
121
+ }
122
+
123
+ /**
124
+ * Tells if there are any handlers attached to the signal or not
125
+ * @returns {boolean}
126
+ */
127
+ hasHandlers() {
128
+ return this.handlers.size > 0;
129
+ }
130
+
131
+ /**
132
+ * Handler will only be run once, it will be removed automatically after the first execution
133
+ * @param {function} h
134
+ * @param {*} [context]
135
+ */
136
+ addOne(h, context) {
137
+ assert.isFunction(h, "handler");
138
+
139
+ const handler = new SignalHandler(h, context);
140
+
141
+ handler.setFlag(SignalHandlerFlags.RemoveAfterExecution);
142
+
143
+ this.#add_handler(handler);
144
+ }
145
+
146
+ /**
147
+ *
148
+ * @param {function} h
149
+ * @param {*} [context]
150
+ */
151
+ add(h, context) {
152
+ assert.isFunction(h, "handler");
153
+
154
+ const handler = new SignalHandler(h, context);
155
+
156
+ this.#add_handler(handler);
157
+
158
+ }
159
+
160
+ /**
161
+ *
162
+ * @param {SignalHandler} handler
163
+ */
164
+ #add_handler(handler) {
165
+
166
+ handler.generation = this.generation;
167
+
168
+ const f = handler.handle;
169
+ const first = this.handlers.get(f);
170
+
171
+ if (first === undefined) {
172
+ this.handlers.set(f, handler);
173
+ } else {
174
+
175
+ handler.next = first;
176
+ this.handlers.set(f, handler);
177
+
178
+ // const last = signal_handler_list_last(first);
179
+
180
+ // last.next = handler;
181
+
182
+ // assert.ok(signal_handler_list_validate(first, console.error), 'invalid configuration');
183
+
184
+ }
185
+
186
+ }
187
+
188
+ /**
189
+ *
190
+ * @param {function} h
191
+ * @param {*} [thisArg] if supplied, will match handlers with a specific context only
192
+ * @returns {boolean} true if a handler was removed, false otherwise
193
+ */
194
+ remove(h, thisArg) {
195
+ assert.isFunction(h, "handler");
196
+
197
+ const first = this.handlers.get(h);
198
+
199
+ if (first === undefined) {
200
+ return false;
201
+ }
202
+
203
+ if (first.handle === h && first.context === thisArg) {
204
+ if (first.next === null) {
205
+ this.handlers.delete(h);
206
+ } else {
207
+ this.handlers.set(h, first.next)
208
+ // assert.ok(signal_handler_list_validate(first.next, console.error), 'invalid configuration');
209
+ }
210
+
211
+ return true;
212
+ }
213
+
214
+ let previous = first;
215
+ let n = first.next;
216
+
217
+ while (n !== null) {
218
+
219
+ if (n.handle === h && n.context === thisArg) {
220
+
221
+ previous.next = n.next;
222
+
223
+ // assert.ok(signal_handler_list_validate(first, console.error), 'invalid configuration');
224
+
225
+ return true;
226
+
227
+ }
228
+
229
+ previous = n;
230
+ n = n.next;
231
+
232
+ }
233
+
234
+ return false;
235
+ }
236
+
237
+ /**
238
+ * **UNSAFE**
239
+ *
240
+ * Remove all handlers.
241
+ * Please note that this will remove even all handlers, irrespective of where they were added from. If another script is attaching to the same signal, using this method will potentially break that code.
242
+ * For most use cases, prefer to use {@link remove} method instead, or make use of {@link SignalBinding} if you need to keep track of multiple handlers
243
+ * NOTE: Consider this method to be unsafe, only use it when you understand the implications
244
+ * @deprecated
245
+ */
246
+ removeAll() {
247
+ this.handlers.clear();
248
+ }
249
+
250
+ /**
251
+ *
252
+ * @param {SignalHandler} handler
253
+ */
254
+ #remove_handler_internal(handler) {
255
+
256
+ const first = this.handlers.get(handler.handle);
257
+
258
+ if (first === undefined) {
259
+ // nothing
260
+ return false;
261
+ }
262
+
263
+ // special case for first
264
+ if (first === handler) {
265
+
266
+ if (first.next === null) {
267
+ // was the only one
268
+ this.handlers.delete(handler.handle);
269
+ } else {
270
+ this.handlers.set(handler.handle, first.next);
271
+ // assert.ok(signal_handler_list_validate(first.next, console.error), 'invalid configuration');
272
+ }
273
+
274
+ return true;
275
+ }
276
+
277
+ let previous = first;
278
+ let n = first.next;
279
+
280
+ while (n !== null) {
281
+
282
+ const next = n.next;
283
+
284
+ if (n === handler) {
285
+ previous.next = next;
286
+
287
+ // assert.ok(signal_handler_list_validate(first, console.error), 'invalid configuration');
288
+
289
+ return true;
290
+ }
291
+
292
+ previous = n;
293
+ n = next;
294
+
295
+ }
296
+
297
+ // not found
298
+ return false;
299
+ }
300
+
301
+ /**
302
+ * Utility method, useful in asynchronous programming.
303
+ * Will resolve at the next {@link dispatch}/{@link send0}/etc.
304
+ * @return {Promise<[]>}
305
+ * @see addOne
306
+ *
307
+ * @example
308
+ * const s = new Signal<number,number>();
309
+ *
310
+ * // ...
311
+ * const [x,y] = await s.promise(); // will trigger at the next dispatch
312
+ *
313
+ * // ... then somewhere else
314
+ * s.send2(7,-3);
315
+ */
316
+ promise(){
317
+ return new Promise((resolve, reject)=>{
318
+ this.addOne((...args)=>{
319
+ resolve(args);
320
+ })
321
+ });
322
+ }
323
+
324
+ /**
325
+ * NOTE: because of polymorphic call-site nature of this method, it's always better for performance to use monomorphic methods like `send0`, `send1` etc.
326
+ * @param {...*} args
327
+ */
328
+ dispatch(...args) {
329
+ if ((this.flags & SignalFlags.Silent) !== 0) {
330
+ //don't dispatch any events while silent
331
+ return;
332
+ }
333
+
334
+ this.generation++;
335
+
336
+ const handlers = this.handlers;
337
+
338
+ for (const handle of handlers.values()) {
339
+
340
+ let _h = handle;
341
+
342
+ do {
343
+
344
+ const next = _h.next;
345
+
346
+ if(_h.generation < this.generation) {
347
+ // only process if handler was attached before this dispatch
348
+
349
+ if (_h.getFlag(SignalHandlerFlags.RemoveAfterExecution)) {
350
+ //handler should be cut
351
+ this.#remove_handler_internal(_h);
352
+ }
353
+
354
+ const _f = _h.handle;
355
+
356
+ try {
357
+ _f.apply(_h.context, args)
358
+ } catch (e) {
359
+ console.error("Failed to dispatch handler", _f, e);
360
+ }
361
+
362
+ }
363
+
364
+ _h = next;
365
+
366
+ } while (_h !== null);
367
+
368
+
369
+ }
370
+
371
+ }
372
+
373
+
374
+ /**
375
+ * dispatch without a value.
376
+ * Allows JS engine to optimize for monomorphic call sites
377
+ */
378
+ send0() {
379
+
380
+ assert.equal(arguments.length, 0, "send0 should not have any arguments")
381
+
382
+ if ((this.flags & SignalFlags.Silent) !== 0) {
383
+ //don't dispatch any events while silent
384
+ return;
385
+ }
386
+
387
+ this.generation++;
388
+
389
+ const handlers = this.handlers;
390
+
391
+ for (const handle of handlers.values()) {
392
+
393
+ let _h = handle;
394
+
395
+ do {
396
+
397
+ const next = _h.next;
398
+
399
+ if(_h.generation < this.generation) {
400
+ // only process if handler was attached before this dispatch
401
+
402
+ if (_h.getFlag(SignalHandlerFlags.RemoveAfterExecution)) {
403
+ //handler should be cut
404
+ this.#remove_handler_internal(_h);
405
+ }
406
+
407
+ const _f = _h.handle;
408
+
409
+ try {
410
+ _f.call(_h.context)
411
+ } catch (e) {
412
+ console.error("Failed to dispatch handler", _f, e);
413
+ }
414
+ }
415
+
416
+ _h = next;
417
+
418
+ } while (_h !== null);
419
+
420
+
421
+ }
422
+
423
+ }
424
+
425
+ /**
426
+ * dispatch with a single value.
427
+ * Allows JS engine to optimize for monomorphic call sites
428
+ * @param {*} arg
429
+ */
430
+ send1(arg) {
431
+
432
+ assert.equal(arguments.length, 1, "send1 expects exactly 1 argument")
433
+
434
+ if ((this.flags & SignalFlags.Silent) !== 0) {
435
+ //don't dispatch any events while silent
436
+ return;
437
+ }
438
+
439
+ this.generation++;
440
+
441
+ const handlers = this.handlers;
442
+
443
+ for (const handle of handlers.values()) {
444
+
445
+ let _h = handle;
446
+
447
+ do {
448
+
449
+ const next = _h.next;
450
+
451
+ if(_h.generation < this.generation) {
452
+ // only process if handler was attached before this dispatch
453
+ if (_h.getFlag(SignalHandlerFlags.RemoveAfterExecution)) {
454
+ //handler should be cut
455
+ this.#remove_handler_internal(_h);
456
+ }
457
+
458
+ const _f = _h.handle;
459
+
460
+ try {
461
+ _f.call(_h.context, arg)
462
+ } catch (e) {
463
+ console.error("Failed to dispatch handler", _f, e);
464
+ }
465
+ }
466
+
467
+ _h = next;
468
+
469
+ } while (_h !== null);
470
+
471
+
472
+ }
473
+
474
+ }
475
+
476
+ /**
477
+ *
478
+ * @param {*} a
479
+ * @param {*} b
480
+ */
481
+ send2(a, b) {
482
+
483
+ assert.equal(arguments.length, 2, "send2 expects exactly 2 arguments")
484
+
485
+ if ((this.flags & SignalFlags.Silent) !== 0) {
486
+ //don't dispatch any events while silent
487
+ return;
488
+ }
489
+
490
+ this.generation++;
491
+
492
+ const handlers = this.handlers;
493
+
494
+ for (const handle of handlers.values()) {
495
+
496
+ let _h = handle;
497
+
498
+ do {
499
+
500
+ const next = _h.next;
501
+
502
+ if(_h.generation < this.generation) {
503
+ // only process if handler was attached before this dispatch
504
+ if (_h.getFlag(SignalHandlerFlags.RemoveAfterExecution)) {
505
+ //handler should be cut
506
+ this.#remove_handler_internal(_h);
507
+ }
508
+
509
+ const _f = _h.handle;
510
+
511
+ try {
512
+ _f.call(_h.context, a, b)
513
+ } catch (e) {
514
+ console.error("Failed to dispatch handler", _f, e);
515
+ }
516
+ }
517
+
518
+ _h = next;
519
+
520
+ } while (_h !== null);
521
+
522
+
523
+ }
524
+ }
525
+
526
+ /**
527
+ *
528
+ * @param {*} a
529
+ * @param {*} b
530
+ * @param {*} c
531
+ */
532
+ send3(a, b, c) {
533
+
534
+ assert.equal(arguments.length, 3, "send3 expects exactly 3 arguments")
535
+
536
+ if ((this.flags & SignalFlags.Silent) !== 0) {
537
+ //don't dispatch any events while silent
538
+ return;
539
+ }
540
+
541
+ this.generation++;
542
+
543
+ const handlers = this.handlers;
544
+
545
+ for (const handle of handlers.values()) {
546
+
547
+ let _h = handle;
548
+
549
+ do {
550
+
551
+ const next = _h.next;
552
+
553
+ if(_h.generation < this.generation) {
554
+ // only process if handler was attached before this dispatch
555
+ if (_h.getFlag(SignalHandlerFlags.RemoveAfterExecution)) {
556
+ //handler should be cut
557
+ this.#remove_handler_internal(_h);
558
+ }
559
+
560
+ const _f = _h.handle;
561
+
562
+ try {
563
+ _f.call(_h.context, a, b, c)
564
+ } catch (e) {
565
+ console.error("Failed to dispatch handler", _f, e);
566
+ }
567
+ }
568
+
569
+ _h = next;
570
+
571
+ } while (_h !== null);
572
+
573
+
574
+ }
575
+ }
576
+
577
+ /**
578
+ *
579
+ * @param {*} a
580
+ * @param {*} b
581
+ * @param {*} c
582
+ * @param {*} d
583
+ */
584
+ send4(a, b, c, d) {
585
+
586
+ assert.equal(arguments.length, 4, "send4 expects exactly 4 arguments")
587
+
588
+ if ((this.flags & SignalFlags.Silent) !== 0) {
589
+ //don't dispatch any events while silent
590
+ return;
591
+ }
592
+
593
+ this.generation++;
594
+
595
+ const handlers = this.handlers;
596
+
597
+ for (const handle of handlers.values()) {
598
+
599
+ let _h = handle;
600
+
601
+ do {
602
+
603
+ const next = _h.next;
604
+
605
+ if(_h.generation < this.generation) {
606
+ // only process if handler was attached before this dispatch
607
+ if (_h.getFlag(SignalHandlerFlags.RemoveAfterExecution)) {
608
+ //handler should be cut
609
+ this.#remove_handler_internal(_h);
610
+ }
611
+
612
+ const _f = _h.handle;
613
+
614
+ try {
615
+ _f.call(_h.context, a, b, c, d)
616
+ } catch (e) {
617
+ console.error("Failed to dispatch handler", _f, e);
618
+ }
619
+ }
620
+
621
+ _h = next;
622
+
623
+ } while (_h !== null);
624
+
625
+
626
+ }
627
+ }
628
+
629
+ /**
630
+ *
631
+ * @param {*} a
632
+ * @param {*} b
633
+ * @param {*} c
634
+ * @param {*} d
635
+ * @param {*} e
636
+ */
637
+ send5(a, b, c, d, e) {
638
+
639
+ assert.equal(arguments.length, 5, "send5 expects exactly 5 arguments")
640
+
641
+ if ((this.flags & SignalFlags.Silent) !== 0) {
642
+ //don't dispatch any events while silent
643
+ return;
644
+ }
645
+
646
+ this.generation++;
647
+
648
+ const handlers = this.handlers;
649
+
650
+ for (const handle of handlers.values()) {
651
+
652
+ let _h = handle;
653
+
654
+ do {
655
+
656
+ const next = _h.next;
657
+
658
+ if(_h.generation < this.generation) {
659
+ // only process if handler was attached before this dispatch
660
+ if (_h.getFlag(SignalHandlerFlags.RemoveAfterExecution)) {
661
+ //handler should be cut
662
+ this.#remove_handler_internal(_h);
663
+ }
664
+
665
+ const _f = _h.handle;
666
+
667
+ try {
668
+ _f.call(_h.context, a, b, c, d, e)
669
+ } catch (e) {
670
+ console.error("Failed to dispatch handler", _f, e);
671
+ }
672
+ }
673
+
674
+ _h = next;
675
+
676
+ } while (_h !== null);
677
+
678
+
679
+ }
680
+ }
681
+
682
+ /**
683
+ *
684
+ * @param {*} a
685
+ * @param {*} b
686
+ * @param {*} c
687
+ * @param {*} d
688
+ * @param {*} e
689
+ * @param {*} f
690
+ */
691
+ send6(a, b, c, d, e, f) {
692
+
693
+ assert.equal(arguments.length, 6, "send6 expects exactly 6 arguments")
694
+
695
+ if ((this.flags & SignalFlags.Silent) !== 0) {
696
+ //don't dispatch any events while silent
697
+ return;
698
+ }
699
+
700
+ this.generation++;
701
+
702
+ const handlers = this.handlers;
703
+
704
+ for (const handle of handlers.values()) {
705
+
706
+ let _h = handle;
707
+
708
+ do {
709
+
710
+ const next = _h.next;
711
+
712
+ if(_h.generation < this.generation) {
713
+ // only process if handler was attached before this dispatch
714
+ if (_h.getFlag(SignalHandlerFlags.RemoveAfterExecution)) {
715
+ //handler should be cut
716
+ this.#remove_handler_internal(_h);
717
+ }
718
+
719
+ const _f = _h.handle;
720
+
721
+ try {
722
+ _f.call(_h.context, a, b, c, d, e, f)
723
+ } catch (e) {
724
+ console.error("Failed to dispatch handler", _f, e);
725
+ }
726
+ }
727
+
728
+ _h = next;
729
+
730
+ } while (_h !== null);
731
+
732
+
733
+ }
734
+ }
735
+
736
+ /**
737
+ *
738
+ * @param {*} a
739
+ * @param {*} b
740
+ * @param {*} c
741
+ * @param {*} d
742
+ * @param {*} e
743
+ * @param {*} f
744
+ * @param {*} g
745
+ * @param {*} h
746
+ */
747
+ send8(a, b, c, d, e, f, g, h) {
748
+
749
+ assert.equal(arguments.length, 8, "send8 expects exactly 8 arguments")
750
+
751
+ if ((this.flags & SignalFlags.Silent) !== 0) {
752
+ //don't dispatch any events while silent
753
+ return;
754
+ }
755
+
756
+ this.generation++;
757
+
758
+ const handlers = this.handlers;
759
+
760
+ for (const handle of handlers.values()) {
761
+
762
+ let _h = handle;
763
+
764
+ do {
765
+
766
+ const next = _h.next;
767
+
768
+ if(_h.generation < this.generation) {
769
+ // only process if handler was attached before this dispatch
770
+ if (_h.getFlag(SignalHandlerFlags.RemoveAfterExecution)) {
771
+ //handler should be cut
772
+ this.#remove_handler_internal(_h);
773
+ }
774
+
775
+ const _f = _h.handle;
776
+
777
+ try {
778
+ _f.call(_h.context, a, b, c, d, e, f, g, h)
779
+ } catch (e) {
780
+ console.error("Failed to dispatch handler", _f, e);
781
+ }
782
+ }
783
+
784
+ _h = next;
785
+
786
+ } while (_h !== null);
787
+
788
+
789
+ }
790
+ }
791
+
792
+ /**
793
+ *
794
+ * @param {Signal} other
795
+ * @returns {Signal} merged signal combining events from this and other
796
+ */
797
+ merge(other) {
798
+ const result = new Signal();
799
+
800
+ function handler() {
801
+ // spread: dispatch takes varargs, so passing the arguments object
802
+ // forwards it as a single argument to every subscriber
803
+ result.dispatch(...arguments);
804
+ }
805
+
806
+ this.add(handler);
807
+ other.add(handler);
808
+
809
+ return result;
810
+ }
811
+ }
812
+
813
+
814
+ /**
815
+ * @readonly
816
+ * @type {boolean}
817
+ */
818
+ Signal.prototype.isSignal = true;
819
+
820
+ export default Signal;