@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.
- package/README.md +168 -152
- package/build/bundle-worker-image-decoder.js +1 -1
- package/build/bundle-worker-terrain.js +1 -1
- package/package.json +3 -2
- package/src/REVIEW_2026_08_06.md +610 -610
- package/src/avif/encode_image_source.d.ts +70 -0
- package/src/avif/encode_image_source.d.ts.map +1 -0
- package/src/avif/encode_image_source.js +117 -0
- package/src/avif/encoder_worker.js +15 -126
- package/src/avif/index.d.ts +4 -2
- package/src/avif/index.js +21 -2
- package/src/avif/native/DECISIONS.md +537 -0
- package/src/avif/native/NOTICE.md +61 -0
- package/src/avif/native/api/AvifDecoder.d.ts +67 -0
- package/src/avif/native/api/AvifDecoder.d.ts.map +1 -0
- package/src/avif/native/api/AvifDecoder.js +121 -0
- package/src/avif/native/api/apply_transformations.d.ts +30 -0
- package/src/avif/native/api/apply_transformations.d.ts.map +1 -0
- package/src/avif/native/api/apply_transformations.js +120 -0
- package/src/avif/native/api/avif_to_sampler2d.d.ts +25 -0
- package/src/avif/native/api/avif_to_sampler2d.d.ts.map +1 -0
- package/src/avif/native/api/avif_to_sampler2d.js +42 -0
- package/src/avif/native/api/convert_to_rgba.d.ts +54 -0
- package/src/avif/native/api/convert_to_rgba.d.ts.map +1 -0
- package/src/avif/native/api/convert_to_rgba.js +204 -0
- package/src/avif/native/api/decode_avif.d.ts +24 -0
- package/src/avif/native/api/decode_avif.d.ts.map +1 -0
- package/src/avif/native/api/decode_avif.js +111 -0
- package/src/avif/native/api/decode_image_item.d.ts +18 -0
- package/src/avif/native/api/decode_image_item.d.ts.map +1 -0
- package/src/avif/native/api/decode_image_item.js +234 -0
- package/src/avif/native/api/encode_avif.d.ts +73 -0
- package/src/avif/native/api/encode_avif.d.ts.map +1 -0
- package/src/avif/native/api/encode_avif.js +488 -0
- package/src/avif/native/api/sampler2d_to_avif.d.ts +22 -0
- package/src/avif/native/api/sampler2d_to_avif.d.ts.map +1 -0
- package/src/avif/native/api/sampler2d_to_avif.js +108 -0
- package/src/avif/native/av1/decode/Av1FrameContext.d.ts +286 -0
- package/src/avif/native/av1/decode/Av1FrameContext.d.ts.map +1 -0
- package/src/avif/native/av1/decode/Av1FrameContext.js +622 -0
- package/src/avif/native/av1/decode/block_decoded.d.ts +27 -0
- package/src/avif/native/av1/decode/block_decoded.d.ts.map +1 -0
- package/src/avif/native/av1/decode/block_decoded.js +59 -0
- package/src/avif/native/av1/decode/decode_av1_still.d.ts +22 -0
- package/src/avif/native/av1/decode/decode_av1_still.d.ts.map +1 -0
- package/src/avif/native/av1/decode/decode_av1_still.js +309 -0
- package/src/avif/native/av1/decode/decode_coefficients.d.ts +20 -0
- package/src/avif/native/av1/decode/decode_coefficients.d.ts.map +1 -0
- package/src/avif/native/av1/decode/decode_coefficients.js +259 -0
- package/src/avif/native/av1/decode/decode_palette.d.ts +28 -0
- package/src/avif/native/av1/decode/decode_palette.d.ts.map +1 -0
- package/src/avif/native/av1/decode/decode_palette.js +442 -0
- package/src/avif/native/av1/decode/decode_tile.d.ts +14 -0
- package/src/avif/native/av1/decode/decode_tile.d.ts.map +1 -0
- package/src/avif/native/av1/decode/decode_tile.js +1213 -0
- package/src/avif/native/av1/decode/get_scan.d.ts +16 -0
- package/src/avif/native/av1/decode/get_scan.d.ts.map +1 -0
- package/src/avif/native/av1/decode/get_scan.js +138 -0
- package/src/avif/native/av1/decode/read_lr.d.ts +35 -0
- package/src/avif/native/av1/decode/read_lr.d.ts.map +1 -0
- package/src/avif/native/av1/decode/read_lr.js +277 -0
- package/src/avif/native/av1/decode/read_transform_type.d.ts +19 -0
- package/src/avif/native/av1/decode/read_transform_type.d.ts.map +1 -0
- package/src/avif/native/av1/decode/read_transform_type.js +92 -0
- package/src/avif/native/av1/decode/reconstruct.d.ts +36 -0
- package/src/avif/native/av1/decode/reconstruct.d.ts.map +1 -0
- package/src/avif/native/av1/decode/reconstruct.js +241 -0
- package/src/avif/native/av1/decode/transform_type.d.ts +49 -0
- package/src/avif/native/av1/decode/transform_type.d.ts.map +1 -0
- package/src/avif/native/av1/decode/transform_type.js +137 -0
- package/src/avif/native/av1/encode/Av1BlockSnapshot.d.ts +81 -0
- package/src/avif/native/av1/encode/Av1BlockSnapshot.d.ts.map +1 -0
- package/src/avif/native/av1/encode/Av1BlockSnapshot.js +299 -0
- package/src/avif/native/av1/encode/Av1EncodeContext.d.ts +384 -0
- package/src/avif/native/av1/encode/Av1EncodeContext.d.ts.map +1 -0
- package/src/avif/native/av1/encode/Av1EncodeContext.js +590 -0
- package/src/avif/native/av1/encode/build_headers.d.ts +50 -0
- package/src/avif/native/av1/encode/build_headers.d.ts.map +1 -0
- package/src/avif/native/av1/encode/build_headers.js +359 -0
- package/src/avif/native/av1/encode/choose_chroma_alpha.d.ts +26 -0
- package/src/avif/native/av1/encode/choose_chroma_alpha.d.ts.map +1 -0
- package/src/avif/native/av1/encode/choose_chroma_alpha.js +90 -0
- package/src/avif/native/av1/encode/choose_filters.d.ts +21 -0
- package/src/avif/native/av1/encode/choose_filters.d.ts.map +1 -0
- package/src/avif/native/av1/encode/choose_filters.js +318 -0
- package/src/avif/native/av1/encode/choose_restoration.d.ts +35 -0
- package/src/avif/native/av1/encode/choose_restoration.d.ts.map +1 -0
- package/src/avif/native/av1/encode/choose_restoration.js +616 -0
- package/src/avif/native/av1/encode/decode_effort.d.ts +57 -0
- package/src/avif/native/av1/encode/decode_effort.d.ts.map +1 -0
- package/src/avif/native/av1/encode/decode_effort.js +59 -0
- package/src/avif/native/av1/encode/encode_av1_still.d.ts +17 -0
- package/src/avif/native/av1/encode/encode_av1_still.d.ts.map +1 -0
- package/src/avif/native/av1/encode/encode_av1_still.js +194 -0
- package/src/avif/native/av1/encode/encode_effort.d.ts +56 -0
- package/src/avif/native/av1/encode/encode_effort.d.ts.map +1 -0
- package/src/avif/native/av1/encode/encode_effort.js +97 -0
- package/src/avif/native/av1/encode/encode_tile.d.ts +26 -0
- package/src/avif/native/av1/encode/encode_tile.d.ts.map +1 -0
- package/src/avif/native/av1/encode/encode_tile.js +2331 -0
- package/src/avif/native/av1/encode/quantise.d.ts +51 -0
- package/src/avif/native/av1/encode/quantise.d.ts.map +1 -0
- package/src/avif/native/av1/encode/quantise.js +212 -0
- package/src/avif/native/av1/encode/write_coefficients.d.ts +42 -0
- package/src/avif/native/av1/encode/write_coefficients.d.ts.map +1 -0
- package/src/avif/native/av1/encode/write_coefficients.js +367 -0
- package/src/avif/native/av1/encode/write_lr.d.ts +33 -0
- package/src/avif/native/av1/encode/write_lr.d.ts.map +1 -0
- package/src/avif/native/av1/encode/write_lr.js +174 -0
- package/src/avif/native/av1/encode/write_transform_type.d.ts +21 -0
- package/src/avif/native/av1/encode/write_transform_type.d.ts.map +1 -0
- package/src/avif/native/av1/encode/write_transform_type.js +70 -0
- package/src/avif/native/av1/entropy/CdfContext.d.ts +167 -0
- package/src/avif/native/av1/entropy/CdfContext.d.ts.map +1 -0
- package/src/avif/native/av1/entropy/CdfContext.js +433 -0
- package/src/avif/native/av1/entropy/SymbolReader.d.ts +103 -0
- package/src/avif/native/av1/entropy/SymbolReader.d.ts.map +1 -0
- package/src/avif/native/av1/entropy/SymbolReader.js +317 -0
- package/src/avif/native/av1/entropy/SymbolWriter.d.ts +107 -0
- package/src/avif/native/av1/entropy/SymbolWriter.d.ts.map +1 -0
- package/src/avif/native/av1/entropy/SymbolWriter.js +352 -0
- package/src/avif/native/av1/entropy/coefficient_context.d.ts +71 -0
- package/src/avif/native/av1/entropy/coefficient_context.d.ts.map +1 -0
- package/src/avif/native/av1/entropy/coefficient_context.js +325 -0
- package/src/avif/native/av1/entropy/partition_cdf.d.ts +54 -0
- package/src/avif/native/av1/entropy/partition_cdf.d.ts.map +1 -0
- package/src/avif/native/av1/entropy/partition_cdf.js +98 -0
- package/src/avif/native/av1/entropy/symbol_cost.d.ts +37 -0
- package/src/avif/native/av1/entropy/symbol_cost.d.ts.map +1 -0
- package/src/avif/native/av1/entropy/symbol_cost.js +76 -0
- package/src/avif/native/av1/filter/cdef.d.ts +15 -0
- package/src/avif/native/av1/filter/cdef.d.ts.map +1 -0
- package/src/avif/native/av1/filter/cdef.js +313 -0
- package/src/avif/native/av1/filter/loop_filter.d.ts +14 -0
- package/src/avif/native/av1/filter/loop_filter.d.ts.map +1 -0
- package/src/avif/native/av1/filter/loop_filter.js +377 -0
- package/src/avif/native/av1/filter/loop_restoration.d.ts +42 -0
- package/src/avif/native/av1/filter/loop_restoration.d.ts.map +1 -0
- package/src/avif/native/av1/filter/loop_restoration.js +451 -0
- package/src/avif/native/av1/filter/superres.d.ts +18 -0
- package/src/avif/native/av1/filter/superres.d.ts.map +1 -0
- package/src/avif/native/av1/filter/superres.js +86 -0
- package/src/avif/native/av1/grain/FilmGrainState.d.ts +62 -0
- package/src/avif/native/av1/grain/FilmGrainState.d.ts.map +1 -0
- package/src/avif/native/av1/grain/FilmGrainState.js +87 -0
- package/src/avif/native/av1/grain/film_grain.d.ts +16 -0
- package/src/avif/native/av1/grain/film_grain.d.ts.map +1 -0
- package/src/avif/native/av1/grain/film_grain.js +623 -0
- package/src/avif/native/av1/obu/FrameHeader.d.ts +248 -0
- package/src/avif/native/av1/obu/FrameHeader.d.ts.map +1 -0
- package/src/avif/native/av1/obu/FrameHeader.js +381 -0
- package/src/avif/native/av1/obu/ObuHeader.d.ts +53 -0
- package/src/avif/native/av1/obu/ObuHeader.d.ts.map +1 -0
- package/src/avif/native/av1/obu/ObuHeader.js +62 -0
- package/src/avif/native/av1/obu/SequenceHeader.d.ts +157 -0
- package/src/avif/native/av1/obu/SequenceHeader.d.ts.map +1 -0
- package/src/avif/native/av1/obu/SequenceHeader.js +225 -0
- package/src/avif/native/av1/obu/for_each_obu.d.ts +24 -0
- package/src/avif/native/av1/obu/for_each_obu.d.ts.map +1 -0
- package/src/avif/native/av1/obu/for_each_obu.js +50 -0
- package/src/avif/native/av1/obu/parse_frame_header.d.ts +18 -0
- package/src/avif/native/av1/obu/parse_frame_header.d.ts.map +1 -0
- package/src/avif/native/av1/obu/parse_frame_header.js +841 -0
- package/src/avif/native/av1/obu/parse_obu_header.d.ts +23 -0
- package/src/avif/native/av1/obu/parse_obu_header.d.ts.map +1 -0
- package/src/avif/native/av1/obu/parse_obu_header.js +69 -0
- package/src/avif/native/av1/obu/parse_sequence_header.d.ts +17 -0
- package/src/avif/native/av1/obu/parse_sequence_header.d.ts.map +1 -0
- package/src/avif/native/av1/obu/parse_sequence_header.js +263 -0
- package/src/avif/native/av1/obu/write_frame_header.d.ts +16 -0
- package/src/avif/native/av1/obu/write_frame_header.d.ts.map +1 -0
- package/src/avif/native/av1/obu/write_frame_header.js +579 -0
- package/src/avif/native/av1/obu/write_sequence_header.d.ts +17 -0
- package/src/avif/native/av1/obu/write_sequence_header.d.ts.map +1 -0
- package/src/avif/native/av1/obu/write_sequence_header.js +189 -0
- package/src/avif/native/av1/predict/IntraPredictionState.d.ts +49 -0
- package/src/avif/native/av1/predict/IntraPredictionState.d.ts.map +1 -0
- package/src/avif/native/av1/predict/IntraPredictionState.js +58 -0
- package/src/avif/native/av1/predict/intra_filter_type.d.ts +17 -0
- package/src/avif/native/av1/predict/intra_filter_type.d.ts.map +1 -0
- package/src/avif/native/av1/predict/intra_filter_type.js +79 -0
- package/src/avif/native/av1/predict/predict_chroma_from_luma.d.ts +50 -0
- package/src/avif/native/av1/predict/predict_chroma_from_luma.d.ts.map +1 -0
- package/src/avif/native/av1/predict/predict_chroma_from_luma.js +153 -0
- package/src/avif/native/av1/predict/predict_intra.d.ts +42 -0
- package/src/avif/native/av1/predict/predict_intra.d.ts.map +1 -0
- package/src/avif/native/av1/predict/predict_intra.js +803 -0
- package/src/avif/native/av1/predict/predict_palette.d.ts +23 -0
- package/src/avif/native/av1/predict/predict_palette.d.ts.map +1 -0
- package/src/avif/native/av1/predict/predict_palette.js +36 -0
- package/src/avif/native/av1/tables/av1_symbols.d.ts +411 -0
- package/src/avif/native/av1/tables/av1_symbols.d.ts.map +1 -0
- package/src/avif/native/av1/tables/av1_symbols.js +419 -0
- package/src/avif/native/av1/tables/block_tables.d.ts +181 -0
- package/src/avif/native/av1/tables/block_tables.d.ts.map +1 -0
- package/src/avif/native/av1/tables/block_tables.js +270 -0
- package/src/avif/native/av1/tables/cdf_tables.d.ts +961 -0
- package/src/avif/native/av1/tables/cdf_tables.d.ts.map +1 -0
- package/src/avif/native/av1/tables/cdf_tables.js +1893 -0
- package/src/avif/native/av1/tables/coefficient_tables.d.ts +41 -0
- package/src/avif/native/av1/tables/coefficient_tables.d.ts.map +1 -0
- package/src/avif/native/av1/tables/coefficient_tables.js +82 -0
- package/src/avif/native/av1/tables/derived_block_tables.d.ts +15 -0
- package/src/avif/native/av1/tables/derived_block_tables.d.ts.map +1 -0
- package/src/avif/native/av1/tables/derived_block_tables.js +23 -0
- package/src/avif/native/av1/tables/filter_tables.d.ts +171 -0
- package/src/avif/native/av1/tables/filter_tables.d.ts.map +1 -0
- package/src/avif/native/av1/tables/filter_tables.js +313 -0
- package/src/avif/native/av1/tables/grain_tables.d.ts +11 -0
- package/src/avif/native/av1/tables/grain_tables.d.ts.map +1 -0
- package/src/avif/native/av1/tables/grain_tables.js +190 -0
- package/src/avif/native/av1/tables/prediction_tables.d.ts +141 -0
- package/src/avif/native/av1/tables/prediction_tables.d.ts.map +1 -0
- package/src/avif/native/av1/tables/prediction_tables.js +223 -0
- package/src/avif/native/av1/tables/quantizer_matrix_tables.d.ts +21 -0
- package/src/avif/native/av1/tables/quantizer_matrix_tables.d.ts.map +1 -0
- package/src/avif/native/av1/tables/quantizer_matrix_tables.js +38 -0
- package/src/avif/native/av1/tables/quantizer_tables.d.ts +21 -0
- package/src/avif/native/av1/tables/quantizer_tables.d.ts.map +1 -0
- package/src/avif/native/av1/tables/quantizer_tables.js +160 -0
- package/src/avif/native/av1/tables/scan_tables.d.ts +321 -0
- package/src/avif/native/av1/tables/scan_tables.d.ts.map +1 -0
- package/src/avif/native/av1/tables/scan_tables.js +727 -0
- package/src/avif/native/av1/tables/segmentation_tables.d.ts +31 -0
- package/src/avif/native/av1/tables/segmentation_tables.d.ts.map +1 -0
- package/src/avif/native/av1/tables/segmentation_tables.js +48 -0
- package/src/avif/native/av1/tables/transform_tables.d.ts +91 -0
- package/src/avif/native/av1/tables/transform_tables.d.ts.map +1 -0
- package/src/avif/native/av1/tables/transform_tables.js +140 -0
- package/src/avif/native/av1/tables/unpack_table.d.ts +33 -0
- package/src/avif/native/av1/tables/unpack_table.d.ts.map +1 -0
- package/src/avif/native/av1/tables/unpack_table.js +73 -0
- package/src/avif/native/av1/transform/forward_transform_2d.d.ts +61 -0
- package/src/avif/native/av1/transform/forward_transform_2d.d.ts.map +1 -0
- package/src/avif/native/av1/transform/forward_transform_2d.js +574 -0
- package/src/avif/native/av1/transform/inverse_transform_1d.d.ts +76 -0
- package/src/avif/native/av1/transform/inverse_transform_1d.d.ts.map +1 -0
- package/src/avif/native/av1/transform/inverse_transform_1d.js +590 -0
- package/src/avif/native/av1/transform/inverse_transform_2d.d.ts +46 -0
- package/src/avif/native/av1/transform/inverse_transform_2d.d.ts.map +1 -0
- package/src/avif/native/av1/transform/inverse_transform_2d.js +180 -0
- package/src/avif/native/av1/util/ceil_log2.d.ts +13 -0
- package/src/avif/native/av1/util/ceil_log2.d.ts.map +1 -0
- package/src/avif/native/av1/util/ceil_log2.js +18 -0
- package/src/avif/native/av1/util/floor_log2.d.ts +20 -0
- package/src/avif/native/av1/util/floor_log2.d.ts.map +1 -0
- package/src/avif/native/av1/util/floor_log2.js +20 -0
- package/src/avif/native/av1/util/round2.d.ts +22 -0
- package/src/avif/native/av1/util/round2.d.ts.map +1 -0
- package/src/avif/native/av1/util/round2.js +27 -0
- package/src/avif/native/av1/util/round2_signed.d.ts +14 -0
- package/src/avif/native/av1/util/round2_signed.d.ts.map +1 -0
- package/src/avif/native/av1/util/round2_signed.js +17 -0
- package/src/avif/native/av1/util/tile_log2.d.ts +16 -0
- package/src/avif/native/av1/util/tile_log2.d.ts.map +1 -0
- package/src/avif/native/av1/util/tile_log2.js +23 -0
- package/src/avif/native/bitstream/BitReader.d.ts +174 -0
- package/src/avif/native/bitstream/BitReader.d.ts.map +1 -0
- package/src/avif/native/bitstream/BitReader.js +391 -0
- package/src/avif/native/bitstream/BitWriter.d.ts +122 -0
- package/src/avif/native/bitstream/BitWriter.d.ts.map +1 -0
- package/src/avif/native/bitstream/BitWriter.js +351 -0
- package/src/avif/native/color/ColourTransform.d.ts +62 -0
- package/src/avif/native/color/ColourTransform.d.ts.map +1 -0
- package/src/avif/native/color/ColourTransform.js +189 -0
- package/src/avif/native/color/YuvImage.d.ts +51 -0
- package/src/avif/native/color/YuvImage.d.ts.map +1 -0
- package/src/avif/native/color/YuvImage.js +66 -0
- package/src/avif/native/color/clamp_sample.d.ts +18 -0
- package/src/avif/native/color/clamp_sample.d.ts.map +1 -0
- package/src/avif/native/color/clamp_sample.js +25 -0
- package/src/avif/native/color/linear_to_transfer.d.ts +24 -0
- package/src/avif/native/color/linear_to_transfer.d.ts.map +1 -0
- package/src/avif/native/color/linear_to_transfer.js +126 -0
- package/src/avif/native/color/primaries.d.ts +20 -0
- package/src/avif/native/color/primaries.d.ts.map +1 -0
- package/src/avif/native/color/primaries.js +94 -0
- package/src/avif/native/color/rgb_row_to_ycbcr.d.ts +20 -0
- package/src/avif/native/color/rgb_row_to_ycbcr.d.ts.map +1 -0
- package/src/avif/native/color/rgb_row_to_ycbcr.js +78 -0
- package/src/avif/native/color/transfer_to_linear.d.ts +49 -0
- package/src/avif/native/color/transfer_to_linear.d.ts.map +1 -0
- package/src/avif/native/color/transfer_to_linear.js +171 -0
- package/src/avif/native/color/upsample_chroma_row.d.ts +35 -0
- package/src/avif/native/color/upsample_chroma_row.d.ts.map +1 -0
- package/src/avif/native/color/upsample_chroma_row.js +89 -0
- package/src/avif/native/color/ycbcr_row_to_rgb.d.ts +23 -0
- package/src/avif/native/color/ycbcr_row_to_rgb.d.ts.map +1 -0
- package/src/avif/native/color/ycbcr_row_to_rgb.js +78 -0
- package/src/avif/native/heif/AvifFile.d.ts +112 -0
- package/src/avif/native/heif/AvifFile.d.ts.map +1 -0
- package/src/avif/native/heif/AvifFile.js +142 -0
- package/src/avif/native/heif/ItemProperty.d.ts +244 -0
- package/src/avif/native/heif/ItemProperty.d.ts.map +1 -0
- package/src/avif/native/heif/ItemProperty.js +321 -0
- package/src/avif/native/heif/find_item_property.d.ts +17 -0
- package/src/avif/native/heif/find_item_property.d.ts.map +1 -0
- package/src/avif/native/heif/find_item_property.js +28 -0
- package/src/avif/native/heif/find_item_references.d.ts +16 -0
- package/src/avif/native/heif/find_item_references.d.ts.map +1 -0
- package/src/avif/native/heif/find_item_references.js +29 -0
- package/src/avif/native/heif/find_items_referencing.d.ts +17 -0
- package/src/avif/native/heif/find_items_referencing.d.ts.map +1 -0
- package/src/avif/native/heif/find_items_referencing.js +36 -0
- package/src/avif/native/heif/parse_avif_file.d.ts +15 -0
- package/src/avif/native/heif/parse_avif_file.d.ts.map +1 -0
- package/src/avif/native/heif/parse_avif_file.js +383 -0
- package/src/avif/native/heif/parse_image_grid.d.ts +18 -0
- package/src/avif/native/heif/parse_image_grid.d.ts.map +1 -0
- package/src/avif/native/heif/parse_image_grid.js +48 -0
- package/src/avif/native/heif/parse_item_property.d.ts +18 -0
- package/src/avif/native/heif/parse_item_property.d.ts.map +1 -0
- package/src/avif/native/heif/parse_item_property.js +243 -0
- package/src/avif/native/heif/read_item_data.d.ts +22 -0
- package/src/avif/native/heif/read_item_data.d.ts.map +1 -0
- package/src/avif/native/heif/read_item_data.js +97 -0
- package/src/avif/native/heif/write_avif_file.d.ts +50 -0
- package/src/avif/native/heif/write_avif_file.d.ts.map +1 -0
- package/src/avif/native/heif/write_avif_file.js +348 -0
- package/src/avif/native/heif/write_item_property.d.ts +16 -0
- package/src/avif/native/heif/write_item_property.d.ts.map +1 -0
- package/src/avif/native/heif/write_item_property.js +182 -0
- package/src/avif/native/index.d.ts +14 -0
- package/src/avif/native/index.d.ts.map +1 -0
- package/src/avif/native/index.js +56 -0
- package/src/avif/native/isobmff/BoxHeader.d.ts +50 -0
- package/src/avif/native/isobmff/BoxHeader.d.ts.map +1 -0
- package/src/avif/native/isobmff/BoxHeader.js +57 -0
- package/src/avif/native/isobmff/BoxWriter.d.ts +118 -0
- package/src/avif/native/isobmff/BoxWriter.d.ts.map +1 -0
- package/src/avif/native/isobmff/BoxWriter.js +264 -0
- package/src/avif/native/isobmff/ByteCursor.d.ts +125 -0
- package/src/avif/native/isobmff/ByteCursor.d.ts.map +1 -0
- package/src/avif/native/isobmff/ByteCursor.js +298 -0
- package/src/avif/native/isobmff/for_each_box.d.ts +23 -0
- package/src/avif/native/isobmff/for_each_box.d.ts.map +1 -0
- package/src/avif/native/isobmff/for_each_box.js +39 -0
- package/src/avif/native/isobmff/read_box_header.d.ts +22 -0
- package/src/avif/native/isobmff/read_box_header.d.ts.map +1 -0
- package/src/avif/native/isobmff/read_box_header.js +59 -0
- package/src/avif/native/isobmff/read_full_box_header.d.ts +26 -0
- package/src/avif/native/isobmff/read_full_box_header.d.ts.map +1 -0
- package/src/avif/native/isobmff/read_full_box_header.js +33 -0
- package/src/avif/threaded_image_encoder.d.ts +7 -2
- package/src/avif/threaded_image_encoder.d.ts.map +1 -1
- package/src/avif/threaded_image_encoder.js +107 -21
- package/src/core/binary/BinaryBuffer.d.ts +40 -0
- package/src/core/binary/BinaryBuffer.d.ts.map +1 -1
- package/src/core/binary/BinaryBuffer.js +100 -0
- package/src/core/binary/hash/crc32.d.ts +16 -0
- package/src/core/binary/hash/crc32.d.ts.map +1 -0
- package/src/core/binary/hash/crc32.js +96 -0
- package/src/core/binary/utf8/utf8_decode.d.ts +21 -0
- package/src/core/binary/utf8/utf8_decode.d.ts.map +1 -0
- package/src/core/binary/utf8/utf8_decode.js +43 -0
- package/src/core/binary/utf8/utf8_encode_into.d.ts +20 -0
- package/src/core/binary/utf8/utf8_encode_into.d.ts.map +1 -0
- package/src/core/binary/utf8/utf8_encode_into.js +48 -0
- package/src/core/binary/utf8/utf8_encoded_length.d.ts +14 -0
- package/src/core/binary/utf8/utf8_encoded_length.d.ts.map +1 -0
- package/src/core/binary/utf8/utf8_encoded_length.js +36 -0
- package/src/core/color/COLOR_FIX_PLAN_2026_08_28.md +417 -0
- package/src/core/color/COLOR_REVIEW_2026_08_28.md +779 -0
- package/src/core/color/Color.d.ts +128 -20
- package/src/core/color/Color.d.ts.map +1 -1
- package/src/core/color/Color.js +959 -866
- package/src/core/color/PQ/PQ_constants.d.ts +10 -0
- package/src/core/color/PQ/PQ_constants.d.ts.map +1 -1
- package/src/core/color/PQ/PQ_constants.js +10 -0
- package/src/core/color/PQ/linear_to_PQ.d.ts.map +1 -1
- package/src/core/color/PQ/linear_to_PQ.js +6 -0
- package/src/core/color/REC709_PRIMARIES.d.ts +50 -0
- package/src/core/color/REC709_PRIMARIES.d.ts.map +1 -0
- package/src/core/color/REC709_PRIMARIES.js +53 -0
- package/src/core/color/construct/color_from_hex.d.ts +21 -0
- package/src/core/color/construct/color_from_hex.d.ts.map +1 -0
- package/src/core/color/construct/color_from_hex.js +33 -0
- package/src/core/color/construct/color_from_temperature.d.ts +22 -0
- package/src/core/color/construct/color_from_temperature.d.ts.map +1 -0
- package/src/core/color/construct/color_from_temperature.js +33 -0
- package/src/core/color/construct/color_from_uint24.d.ts +19 -0
- package/src/core/color/construct/color_from_uint24.d.ts.map +1 -0
- package/src/core/color/construct/color_from_uint24.js +26 -0
- package/src/core/color/construct/color_from_uint32.d.ts +20 -0
- package/src/core/color/construct/color_from_uint32.d.ts.map +1 -0
- package/src/core/color/construct/color_from_uint32.js +39 -0
- package/src/core/color/construct/color_gray.d.ts +17 -0
- package/src/core/color/construct/color_gray.d.ts.map +1 -0
- package/src/core/color/construct/color_gray.js +22 -0
- package/src/core/color/hex/hex2rgb.d.ts +1 -11
- package/src/core/color/hex/hex2rgb.d.ts.map +1 -1
- package/src/core/color/hex/hex2rgb.js +7 -24
- package/src/core/color/hex/hex_to_rgb.d.ts +18 -0
- package/src/core/color/hex/hex_to_rgb.d.ts.map +1 -0
- package/src/core/color/hex/hex_to_rgb.js +62 -0
- package/src/core/color/hex/rgb2hex.d.ts +1 -8
- package/src/core/color/hex/rgb2hex.d.ts.map +1 -1
- package/src/core/color/hex/rgb2hex.js +7 -13
- package/src/core/color/hex/rgb_to_hex.d.ts +9 -0
- package/src/core/color/hex/rgb_to_hex.d.ts.map +1 -0
- package/src/core/color/hex/rgb_to_hex.js +13 -0
- package/src/core/color/hex/rgba_to_hex.d.ts +19 -0
- package/src/core/color/hex/rgba_to_hex.d.ts.map +1 -0
- package/src/core/color/hex/rgba_to_hex.js +23 -0
- package/src/core/color/hsv/hsv2rgb.d.ts +1 -12
- package/src/core/color/hsv/hsv2rgb.d.ts.map +1 -1
- package/src/core/color/hsv/hsv2rgb.js +8 -21
- package/src/core/color/hsv/hsv2rgb_float.d.ts +1 -12
- package/src/core/color/hsv/hsv2rgb_float.d.ts.map +1 -1
- package/src/core/color/hsv/hsv2rgb_float.js +8 -56
- package/src/core/color/hsv/hsv_to_rgb.d.ts +13 -0
- package/src/core/color/hsv/hsv_to_rgb.d.ts.map +1 -0
- package/src/core/color/hsv/hsv_to_rgb.js +39 -0
- package/src/core/color/hsv/hsv_to_rgb_uint8.d.ts +13 -0
- package/src/core/color/hsv/hsv_to_rgb_uint8.d.ts.map +1 -0
- package/src/core/color/hsv/hsv_to_rgb_uint8.js +21 -0
- package/src/core/color/hsv/hue_to_rgb_sextant.d.ts +24 -0
- package/src/core/color/hsv/hue_to_rgb_sextant.d.ts.map +1 -0
- package/src/core/color/hsv/hue_to_rgb_sextant.js +67 -0
- package/src/core/color/hsv/rgb2hsv.d.ts +1 -12
- package/src/core/color/hsv/rgb2hsv.d.ts.map +1 -1
- package/src/core/color/hsv/rgb2hsv.js +7 -42
- package/src/core/color/hsv/rgb_to_hsv.d.ts +13 -0
- package/src/core/color/hsv/rgb_to_hsv.d.ts.map +1 -0
- package/src/core/color/hsv/rgb_to_hsv.js +42 -0
- package/src/core/color/hunt/hpe_to_xyz.d.ts +2 -0
- package/src/core/color/hunt/hpe_to_xyz.d.ts.map +1 -0
- package/src/core/color/hunt/hpe_to_xyz.js +4 -0
- package/src/core/color/hunt/xyz_to_hpe.d.ts +1 -6
- package/src/core/color/hunt/xyz_to_hpe.d.ts.map +1 -1
- package/src/core/color/hunt/xyz_to_hpe.js +12 -15
- package/src/core/color/illuminant/D65_spd_tabulated.d.ts.map +1 -1
- package/src/core/color/illuminant/D65_spd_tabulated.js +107 -104
- package/src/core/color/int2rgb.d.ts +1 -10
- package/src/core/color/int2rgb.d.ts.map +1 -1
- package/src/core/color/int2rgb.js +7 -12
- package/src/core/color/int_to_rgb.d.ts +21 -0
- package/src/core/color/int_to_rgb.d.ts.map +1 -0
- package/src/core/color/int_to_rgb.js +33 -0
- package/src/core/color/kelvin/kelvin_to_rgb.d.ts.map +1 -1
- package/src/core/color/kelvin/kelvin_to_rgb.js +22 -2
- package/src/core/color/kelvin/rgb_to_kelvin.d.ts +22 -2
- package/src/core/color/kelvin/rgb_to_kelvin.d.ts.map +1 -1
- package/src/core/color/kelvin/rgb_to_kelvin.js +22 -2
- package/src/core/color/lab/lab_to_xyz.d.ts +20 -0
- package/src/core/color/lab/lab_to_xyz.d.ts.map +1 -0
- package/src/core/color/lab/lab_to_xyz.js +69 -0
- package/src/core/color/oklab/gamut_clip_adaptive_l0.d.ts +34 -0
- package/src/core/color/oklab/gamut_clip_adaptive_l0.d.ts.map +1 -0
- package/src/core/color/oklab/gamut_clip_adaptive_l0.js +46 -0
- package/src/core/color/oklab/gamut_clip_at_l0.d.ts +33 -0
- package/src/core/color/oklab/gamut_clip_at_l0.d.ts.map +1 -0
- package/src/core/color/oklab/gamut_clip_at_l0.js +84 -0
- package/src/core/color/oklab/gamut_clip_preserve_chroma.d.ts +24 -0
- package/src/core/color/oklab/gamut_clip_preserve_chroma.d.ts.map +1 -0
- package/src/core/color/oklab/gamut_clip_preserve_chroma.js +37 -0
- package/src/core/color/oklab/gamut_clip_project_to_lcusp.d.ts +23 -0
- package/src/core/color/oklab/gamut_clip_project_to_lcusp.d.ts.map +1 -0
- package/src/core/color/oklab/gamut_clip_project_to_lcusp.js +46 -0
- package/src/core/color/oklab/linear_srgb_to_okhsl.d.ts +19 -0
- package/src/core/color/oklab/linear_srgb_to_okhsl.d.ts.map +1 -0
- package/src/core/color/oklab/linear_srgb_to_okhsl.js +93 -0
- package/src/core/color/oklab/linear_srgb_to_okhsv.d.ts +12 -4
- package/src/core/color/oklab/linear_srgb_to_okhsv.d.ts.map +1 -1
- package/src/core/color/oklab/linear_srgb_to_okhsv.js +108 -84
- package/src/core/color/oklab/linear_srgb_to_oklab.d.ts +13 -4
- package/src/core/color/oklab/linear_srgb_to_oklab.d.ts.map +1 -1
- package/src/core/color/oklab/linear_srgb_to_oklab.js +28 -19
- package/src/core/color/oklab/okhsl_chroma_bounds.d.ts +51 -0
- package/src/core/color/oklab/okhsl_chroma_bounds.d.ts.map +1 -0
- package/src/core/color/oklab/okhsl_chroma_bounds.js +128 -0
- package/src/core/color/oklab/okhsl_to_linear_srgb.d.ts +19 -0
- package/src/core/color/oklab/okhsl_to_linear_srgb.d.ts.map +1 -0
- package/src/core/color/oklab/okhsl_to_linear_srgb.js +85 -0
- package/src/core/color/oklab/oklab_to_oklch.d.ts +24 -0
- package/src/core/color/oklab/oklab_to_oklch.d.ts.map +1 -0
- package/src/core/color/oklab/oklab_to_oklch.js +35 -0
- package/src/core/color/oklab/oklch_to_oklab.d.ts +18 -0
- package/src/core/color/oklab/oklch_to_oklab.d.ts.map +1 -0
- package/src/core/color/oklab/oklch_to_oklab.js +26 -0
- package/src/core/color/oklab/toe.d.ts +12 -0
- package/src/core/color/oklab/toe.d.ts.map +1 -1
- package/src/core/color/oklab/toe.js +34 -22
- package/src/core/color/operations/color_add.d.ts +21 -0
- package/src/core/color/operations/color_add.d.ts.map +1 -0
- package/src/core/color/operations/color_add.js +23 -0
- package/src/core/color/operations/color_add_scaled.d.ts +20 -0
- package/src/core/color/operations/color_add_scaled.d.ts.map +1 -0
- package/src/core/color/operations/color_add_scaled.js +30 -0
- package/src/core/color/operations/color_clamp.d.ts +22 -0
- package/src/core/color/operations/color_clamp.d.ts.map +1 -0
- package/src/core/color/operations/color_clamp.js +25 -0
- package/src/core/color/operations/color_darken.d.ts +2 -1
- package/src/core/color/operations/color_darken.d.ts.map +1 -1
- package/src/core/color/operations/color_darken.js +25 -24
- package/src/core/color/operations/color_desaturate.d.ts +2 -1
- package/src/core/color/operations/color_desaturate.d.ts.map +1 -1
- package/src/core/color/operations/color_desaturate.js +25 -24
- package/src/core/color/operations/color_get_hsl.d.ts +18 -0
- package/src/core/color/operations/color_get_hsl.d.ts.map +1 -0
- package/src/core/color/operations/color_get_hsl.js +60 -0
- package/src/core/color/operations/color_is_in_gamut.d.ts +20 -0
- package/src/core/color/operations/color_is_in_gamut.d.ts.map +1 -0
- package/src/core/color/operations/color_is_in_gamut.js +30 -0
- package/src/core/color/operations/color_lerp.d.ts +12 -3
- package/src/core/color/operations/color_lerp.d.ts.map +1 -1
- package/src/core/color/operations/color_lerp.js +55 -46
- package/src/core/color/operations/color_lighten.d.ts +9 -5
- package/src/core/color/operations/color_lighten.d.ts.map +1 -1
- package/src/core/color/operations/color_lighten.js +29 -24
- package/src/core/color/operations/color_mix_okhsv_channel.d.ts +24 -0
- package/src/core/color/operations/color_mix_okhsv_channel.d.ts.map +1 -0
- package/src/core/color/operations/color_mix_okhsv_channel.js +48 -0
- package/src/core/color/operations/color_multiply_rgb.d.ts +21 -0
- package/src/core/color/operations/color_multiply_rgb.d.ts.map +1 -0
- package/src/core/color/operations/color_multiply_rgb.js +26 -0
- package/src/core/color/operations/color_saturate.d.ts +9 -5
- package/src/core/color/operations/color_saturate.d.ts.map +1 -1
- package/src/core/color/operations/color_saturate.js +29 -24
- package/src/core/color/operations/color_scale_okhsv_channel.d.ts +1 -1
- package/src/core/color/operations/color_scale_okhsv_channel.d.ts.map +1 -1
- package/src/core/color/operations/color_scale_okhsv_channel.js +58 -45
- package/src/core/color/operations/color_srgb_apply.d.ts +28 -0
- package/src/core/color/operations/color_srgb_apply.d.ts.map +1 -0
- package/src/core/color/operations/color_srgb_apply.js +40 -0
- package/src/core/color/operations/color_sub.d.ts +16 -0
- package/src/core/color/operations/color_sub.d.ts.map +1 -0
- package/src/core/color/operations/color_sub.js +18 -0
- package/src/core/color/parse_color.d.ts +10 -1
- package/src/core/color/parse_color.d.ts.map +1 -1
- package/src/core/color/parse_color.js +100 -84
- package/src/core/color/parse_color_normalized.d.ts +24 -0
- package/src/core/color/parse_color_normalized.d.ts.map +1 -0
- package/src/core/color/parse_color_normalized.js +38 -0
- package/src/core/color/rgb2uint24.d.ts +1 -8
- package/src/core/color/rgb2uint24.d.ts.map +1 -1
- package/src/core/color/rgb2uint24.js +7 -20
- package/src/core/color/rgb2uint32.d.ts +1 -9
- package/src/core/color/rgb2uint32.d.ts.map +1 -1
- package/src/core/color/rgb2uint32.js +7 -18
- package/src/core/color/rgb_to_luminance.d.ts +14 -5
- package/src/core/color/rgb_to_luminance.d.ts.map +1 -1
- package/src/core/color/rgb_to_luminance.js +24 -13
- package/src/core/color/rgb_to_uint24.d.ts +9 -0
- package/src/core/color/rgb_to_uint24.d.ts.map +1 -0
- package/src/core/color/rgb_to_uint24.js +20 -0
- package/src/core/color/rgb_to_uint32.d.ts +10 -0
- package/src/core/color/rgb_to_uint32.d.ts.map +1 -0
- package/src/core/color/rgb_to_uint32.js +21 -0
- package/src/core/color/sRGB/linear_to_sRGB.d.ts +7 -0
- package/src/core/color/sRGB/linear_to_sRGB.d.ts.map +1 -1
- package/src/core/color/sRGB/linear_to_sRGB.js +39 -32
- package/src/core/color/xyz/hpe_to_xyz.d.ts +24 -0
- package/src/core/color/xyz/hpe_to_xyz.d.ts.map +1 -0
- package/src/core/color/xyz/hpe_to_xyz.js +39 -0
- package/src/core/color/xyz/rgb_to_xyz.d.ts +17 -2
- package/src/core/color/xyz/rgb_to_xyz.d.ts.map +1 -1
- package/src/core/color/xyz/rgb_to_xyz.js +44 -18
- package/src/core/color/xyz/xyz_cmf_tabulated.d.ts.map +1 -1
- package/src/core/color/xyz/xyz_cmf_tabulated.js +217 -211
- package/src/core/color/xyz/xyz_cmf_wyman.d.ts +4 -0
- package/src/core/color/xyz/xyz_cmf_wyman.d.ts.map +1 -1
- package/src/core/color/xyz/xyz_cmf_wyman.js +74 -65
- package/src/core/color/xyz/xyz_to_hpe.d.ts +18 -0
- package/src/core/color/xyz/xyz_to_hpe.d.ts.map +1 -0
- package/src/core/color/xyz/xyz_to_hpe.js +33 -0
- package/src/core/color/xyz/xyz_to_rgb.d.ts +17 -2
- package/src/core/color/xyz/xyz_to_rgb.d.ts.map +1 -1
- package/src/core/color/xyz/xyz_to_rgb.js +39 -16
- package/src/core/color/ycxcz/xyz_to_ycxcz.d.ts +7 -2
- package/src/core/color/ycxcz/xyz_to_ycxcz.d.ts.map +1 -1
- package/src/core/color/ycxcz/xyz_to_ycxcz.js +33 -28
- package/src/core/events/signal/Signal.js +820 -820
- package/src/core/geom/3d/shape/ConvexHullShape3D.d.ts.map +1 -1
- package/src/core/geom/3d/shape/ConvexHullShape3D.js +28 -4
- package/src/core/math/clamp_index.d.ts +18 -0
- package/src/core/math/clamp_index.d.ts.map +1 -0
- package/src/core/math/clamp_index.js +23 -0
- package/src/engine/asset/loaders/image/IMAGE_CODEC_REVIEW_2026_08_28.md +803 -0
- package/src/engine/asset/loaders/image/jpeg/JpegFrame.d.ts +5 -3
- package/src/engine/asset/loaders/image/jpeg/JpegFrame.d.ts.map +1 -1
- package/src/engine/asset/loaders/image/jpeg/JpegFrame.js +5 -3
- package/src/engine/asset/loaders/image/jpeg/JpegFrameComponent.d.ts +2 -1
- package/src/engine/asset/loaders/image/jpeg/JpegFrameComponent.d.ts.map +1 -1
- package/src/engine/asset/loaders/image/jpeg/JpegFrameComponent.js +2 -1
- package/src/engine/asset/loaders/image/jpeg/JpegImage.d.ts +17 -0
- package/src/engine/asset/loaders/image/jpeg/JpegImage.d.ts.map +1 -1
- package/src/engine/asset/loaders/image/jpeg/JpegImage.js +197 -157
- package/src/engine/asset/loaders/image/jpeg/idct8x8_float.d.ts +0 -1
- package/src/engine/asset/loaders/image/jpeg/idct8x8_float.d.ts.map +1 -1
- package/src/engine/asset/loaders/image/jpeg/idct8x8_float.js +0 -1
- package/src/engine/asset/loaders/image/jpeg/jpeg_component_row.d.ts +28 -0
- package/src/engine/asset/loaders/image/jpeg/jpeg_component_row.d.ts.map +1 -0
- package/src/engine/asset/loaders/image/jpeg/jpeg_component_row.js +31 -0
- package/src/engine/asset/loaders/image/png/PNG.d.ts +3 -18
- package/src/engine/asset/loaders/image/png/PNG.d.ts.map +1 -1
- package/src/engine/asset/loaders/image/png/PNG.js +3 -139
- package/src/engine/asset/loaders/image/png/PNGReader.d.ts +16 -16
- package/src/engine/asset/loaders/image/png/PNGReader.d.ts.map +1 -1
- package/src/engine/asset/loaders/image/png/PNGReader.js +143 -160
- package/src/engine/asset/loaders/image/png/chunk/png_chunk_decode_iTXt.js +3 -3
- package/src/engine/asset/loaders/image/png/chunk/png_chunk_decode_zTXt.js +3 -3
- package/src/engine/asset/loaders/image/png/crc32.d.ts +1 -15
- package/src/engine/asset/loaders/image/png/crc32.d.ts.map +1 -1
- package/src/engine/asset/loaders/image/png/crc32.js +5 -89
- package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterNone.d.ts +12 -10
- package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterNone.d.ts.map +1 -1
- package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterNone.js +20 -45
- package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterSub.d.ts +2 -1
- package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterSub.d.ts.map +1 -1
- package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterSub.js +2 -0
- package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterUp.d.ts +2 -1
- package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterUp.d.ts.map +1 -1
- package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterUp.js +2 -0
- package/src/engine/asset/loaders/image/png/filter/png_unfilter.d.ts +22 -0
- package/src/engine/asset/loaders/image/png/filter/png_unfilter.d.ts.map +1 -0
- package/src/engine/asset/loaders/image/png/filter/png_unfilter.js +68 -0
- package/src/engine/asset/loaders/image/png/png_inflate.d.ts +20 -0
- package/src/engine/asset/loaders/image/png/png_inflate.d.ts.map +1 -0
- package/src/engine/asset/loaders/image/png/png_inflate.js +85 -0
- package/src/engine/asset/loaders/image/png/png_unpack_samples.d.ts +22 -0
- package/src/engine/asset/loaders/image/png/png_unpack_samples.d.ts.map +1 -0
- package/src/engine/asset/loaders/image/png/png_unpack_samples.js +38 -0
- package/src/engine/graphics/ecs/sprite/SpriteSystemPE.d.ts.map +1 -1
- package/src/engine/graphics/ecs/sprite/SpriteSystemPE.js +135 -132
- package/src/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.d.ts +16 -3
- package/src/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.d.ts.map +1 -1
- package/src/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.js +1157 -1149
- package/src/engine/graphics/render/frame_graph/FrameGraph.d.ts +26 -0
- package/src/engine/graphics/render/frame_graph/FrameGraph.d.ts.map +1 -1
- package/src/engine/graphics/render/frame_graph/FrameGraph.js +947 -900
- package/src/engine/physics/ecs/PhysicsSystem.d.ts +69 -81
- package/src/engine/physics/ecs/PhysicsSystem.d.ts.map +1 -1
- package/src/engine/physics/ecs/PhysicsSystem.js +83 -77
- package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
- package/src/shade/device/IMMEDIATE_DATA_PLAN_2026_08_28.md +451 -0
- package/src/shade/device/ShadeGPUCommandContext.d.ts +21 -0
- package/src/shade/device/ShadeGPUCommandContext.d.ts.map +1 -1
- package/src/shade/device/ShadeGPUCommandContext.js +940 -749
- package/src/shade/device/timing/GPUTimerArray.d.ts +22 -4
- package/src/shade/device/timing/GPUTimerArray.d.ts.map +1 -1
- package/src/shade/device/timing/GPUTimerArray.js +88 -14
- package/src/shade/device/timing/GPU_PROFILER_PROPOSAL_2026_08_28.md +876 -0
- package/src/shade/device/timing/profile/GPUFrameRecorder.d.ts +93 -0
- package/src/shade/device/timing/profile/GPUFrameRecorder.d.ts.map +1 -0
- package/src/shade/device/timing/profile/GPUFrameRecorder.js +297 -0
- package/src/shade/device/timing/profile/GPUProfileCapture.d.ts +62 -0
- package/src/shade/device/timing/profile/GPUProfileCapture.d.ts.map +1 -0
- package/src/shade/device/timing/profile/GPUProfileCapture.js +77 -0
- package/src/shade/device/timing/profile/GPUProfileFrame.d.ts +73 -0
- package/src/shade/device/timing/profile/GPUProfileFrame.d.ts.map +1 -0
- package/src/shade/device/timing/profile/GPUProfileFrame.js +88 -0
- package/src/shade/device/timing/profile/GPUProfileLevel.d.ts +20 -0
- package/src/shade/device/timing/profile/GPUProfileLevel.d.ts.map +1 -0
- package/src/shade/device/timing/profile/GPUProfileLevel.js +50 -0
- package/src/shade/device/timing/profile/GPUProfileMeta.d.ts +63 -0
- package/src/shade/device/timing/profile/GPUProfileMeta.d.ts.map +1 -0
- package/src/shade/device/timing/profile/GPUProfileMeta.js +73 -0
- package/src/shade/device/timing/profile/GPUProfileSession.d.ts +173 -0
- package/src/shade/device/timing/profile/GPUProfileSession.d.ts.map +1 -0
- package/src/shade/device/timing/profile/GPUProfileSession.js +470 -0
- package/src/shade/device/timing/profile/GPUProfileSpan.d.ts +60 -0
- package/src/shade/device/timing/profile/GPUProfileSpan.d.ts.map +1 -0
- package/src/shade/device/timing/profile/GPUProfileSpan.js +65 -0
- package/src/shade/device/timing/profile/GPUProfileSpanKind.d.ts +19 -0
- package/src/shade/device/timing/profile/GPUProfileSpanKind.d.ts.map +1 -0
- package/src/shade/device/timing/profile/GPUProfileSpanKind.js +25 -0
- package/src/shade/device/timing/profile/GPUProfileTopology.d.ts +159 -0
- package/src/shade/device/timing/profile/GPUProfileTopology.d.ts.map +1 -0
- package/src/shade/device/timing/profile/GPUProfileTopology.js +202 -0
- package/src/shade/device/timing/profile/GPUProfileWork.d.ts +90 -0
- package/src/shade/device/timing/profile/GPUProfileWork.d.ts.map +1 -0
- package/src/shade/device/timing/profile/GPUProfileWork.js +115 -0
- package/src/shade/device/timing/profile/SGPTDefect.d.ts +43 -0
- package/src/shade/device/timing/profile/SGPTDefect.d.ts.map +1 -0
- package/src/shade/device/timing/profile/SGPTDefect.js +65 -0
- package/src/shade/device/timing/profile/SGPTHeader.d.ts +38 -0
- package/src/shade/device/timing/profile/SGPTHeader.d.ts.map +1 -0
- package/src/shade/device/timing/profile/SGPTHeader.js +46 -0
- package/src/shade/device/timing/profile/SGPTRecordRef.d.ts +37 -0
- package/src/shade/device/timing/profile/SGPTRecordRef.d.ts.map +1 -0
- package/src/shade/device/timing/profile/SGPTRecordRef.js +45 -0
- package/src/shade/device/timing/profile/SGPTWriteStream.d.ts +103 -0
- package/src/shade/device/timing/profile/SGPTWriteStream.d.ts.map +1 -0
- package/src/shade/device/timing/profile/SGPTWriteStream.js +287 -0
- package/src/shade/device/timing/profile/SGPT_DEFECT.d.ts +19 -0
- package/src/shade/device/timing/profile/SGPT_DEFECT.d.ts.map +1 -0
- package/src/shade/device/timing/profile/SGPT_DEFECT.js +26 -0
- package/src/shade/device/timing/profile/SGPT_FLAG.d.ts +8 -0
- package/src/shade/device/timing/profile/SGPT_FLAG.d.ts.map +1 -0
- package/src/shade/device/timing/profile/SGPT_FLAG.js +15 -0
- package/src/shade/device/timing/profile/SGPT_FORMAT.md +345 -0
- package/src/shade/device/timing/profile/SGPT_FORMAT_VERSION.d.ts +10 -0
- package/src/shade/device/timing/profile/SGPT_FORMAT_VERSION.d.ts.map +1 -0
- package/src/shade/device/timing/profile/SGPT_FORMAT_VERSION.js +9 -0
- package/src/shade/device/timing/profile/SGPT_FRAME_SLACK.d.ts +17 -0
- package/src/shade/device/timing/profile/SGPT_FRAME_SLACK.d.ts.map +1 -0
- package/src/shade/device/timing/profile/SGPT_FRAME_SLACK.js +16 -0
- package/src/shade/device/timing/profile/SGPT_HEADER_CHECKSUM_COVERAGE.d.ts +16 -0
- package/src/shade/device/timing/profile/SGPT_HEADER_CHECKSUM_COVERAGE.d.ts.map +1 -0
- package/src/shade/device/timing/profile/SGPT_HEADER_CHECKSUM_COVERAGE.js +15 -0
- package/src/shade/device/timing/profile/SGPT_HEADER_OFFSET.d.ts +15 -0
- package/src/shade/device/timing/profile/SGPT_HEADER_OFFSET.d.ts.map +1 -0
- package/src/shade/device/timing/profile/SGPT_HEADER_OFFSET.js +29 -0
- package/src/shade/device/timing/profile/SGPT_HEADER_SIZE.d.ts +7 -0
- package/src/shade/device/timing/profile/SGPT_HEADER_SIZE.d.ts.map +1 -0
- package/src/shade/device/timing/profile/SGPT_HEADER_SIZE.js +6 -0
- package/src/shade/device/timing/profile/SGPT_MAGIC.d.ts +7 -0
- package/src/shade/device/timing/profile/SGPT_MAGIC.d.ts.map +1 -0
- package/src/shade/device/timing/profile/SGPT_MAGIC.js +6 -0
- package/src/shade/device/timing/profile/SGPT_MIN_READER_VERSION.d.ts +16 -0
- package/src/shade/device/timing/profile/SGPT_MIN_READER_VERSION.d.ts.map +1 -0
- package/src/shade/device/timing/profile/SGPT_MIN_READER_VERSION.js +15 -0
- package/src/shade/device/timing/profile/SGPT_RECORD_HEADER_SIZE.d.ts +7 -0
- package/src/shade/device/timing/profile/SGPT_RECORD_HEADER_SIZE.d.ts.map +1 -0
- package/src/shade/device/timing/profile/SGPT_RECORD_HEADER_SIZE.js +6 -0
- package/src/shade/device/timing/profile/SGPT_RECORD_OFFSET.d.ts +13 -0
- package/src/shade/device/timing/profile/SGPT_RECORD_OFFSET.d.ts.map +1 -0
- package/src/shade/device/timing/profile/SGPT_RECORD_OFFSET.js +23 -0
- package/src/shade/device/timing/profile/SGPT_RECORD_SYNC.d.ts +12 -0
- package/src/shade/device/timing/profile/SGPT_RECORD_SYNC.d.ts.map +1 -0
- package/src/shade/device/timing/profile/SGPT_RECORD_SYNC.js +11 -0
- package/src/shade/device/timing/profile/SGPT_RECORD_TYPE.d.ts +18 -0
- package/src/shade/device/timing/profile/SGPT_RECORD_TYPE.d.ts.map +1 -0
- package/src/shade/device/timing/profile/SGPT_RECORD_TYPE.js +46 -0
- package/src/shade/device/timing/profile/frame_graph_extract_topology.d.ts +20 -0
- package/src/shade/device/timing/profile/frame_graph_extract_topology.d.ts.map +1 -0
- package/src/shade/device/timing/profile/frame_graph_extract_topology.js +174 -0
- package/src/shade/device/timing/profile/make_profiling_pass_encoder.d.ts +21 -0
- package/src/shade/device/timing/profile/make_profiling_pass_encoder.d.ts.map +1 -0
- package/src/shade/device/timing/profile/make_profiling_pass_encoder.js +114 -0
- package/src/shade/device/timing/profile/parse_workgroup_size.d.ts +20 -0
- package/src/shade/device/timing/profile/parse_workgroup_size.d.ts.map +1 -0
- package/src/shade/device/timing/profile/parse_workgroup_size.js +43 -0
- package/src/shade/device/timing/profile/sgpt_fourcc.d.ts +18 -0
- package/src/shade/device/timing/profile/sgpt_fourcc.d.ts.map +1 -0
- package/src/shade/device/timing/profile/sgpt_fourcc.js +34 -0
- package/src/shade/device/timing/profile/sgpt_frame_codec.d.ts +42 -0
- package/src/shade/device/timing/profile/sgpt_frame_codec.d.ts.map +1 -0
- package/src/shade/device/timing/profile/sgpt_frame_codec.js +172 -0
- package/src/shade/device/timing/profile/sgpt_meta_codec.d.ts +20 -0
- package/src/shade/device/timing/profile/sgpt_meta_codec.d.ts.map +1 -0
- package/src/shade/device/timing/profile/sgpt_meta_codec.js +65 -0
- package/src/shade/device/timing/profile/sgpt_read_capture.d.ts +19 -0
- package/src/shade/device/timing/profile/sgpt_read_capture.d.ts.map +1 -0
- package/src/shade/device/timing/profile/sgpt_read_capture.js +134 -0
- package/src/shade/device/timing/profile/sgpt_read_header.d.ts +22 -0
- package/src/shade/device/timing/profile/sgpt_read_header.d.ts.map +1 -0
- package/src/shade/device/timing/profile/sgpt_read_header.js +94 -0
- package/src/shade/device/timing/profile/sgpt_read_records.d.ts +27 -0
- package/src/shade/device/timing/profile/sgpt_read_records.d.ts.map +1 -0
- package/src/shade/device/timing/profile/sgpt_read_records.js +153 -0
- package/src/shade/device/timing/profile/sgpt_topology_codec.d.ts +54 -0
- package/src/shade/device/timing/profile/sgpt_topology_codec.d.ts.map +1 -0
- package/src/shade/device/timing/profile/sgpt_topology_codec.js +329 -0
- package/src/shade/device/timing/profile/sgpt_write_header.d.ts +22 -0
- package/src/shade/device/timing/profile/sgpt_write_header.d.ts.map +1 -0
- package/src/shade/device/timing/profile/sgpt_write_header.js +47 -0
- package/src/shade/device/timing/profile/sgpt_write_record.d.ts +23 -0
- package/src/shade/device/timing/profile/sgpt_write_record.d.ts.map +1 -0
- package/src/shade/device/timing/profile/sgpt_write_record.js +62 -0
- package/src/shade/renderer/Renderer.d.ts +21 -0
- package/src/shade/renderer/Renderer.d.ts.map +1 -1
- package/src/shade/renderer/Renderer.js +2513 -2455
- package/src/shade/renderer/postprocess/nss/NSS.d.ts +1 -1
- package/src/shade/renderer/scene/serialization/decode_image_source_hdr.d.ts +14 -3
- package/src/shade/renderer/scene/serialization/decode_image_source_hdr.d.ts.map +1 -1
- package/src/shade/renderer/scene/serialization/decode_image_source_hdr.js +50 -51
- package/src/shade/renderer/scene/serialization/deserialize_scene.d.ts.map +1 -1
- package/src/shade/renderer/scene/serialization/deserialize_scene.js +531 -521
- package/src/shade/renderer/scene/serialization/write_image_source.d.ts.map +1 -1
- package/src/shade/renderer/scene/serialization/write_image_source.js +6 -4
- package/src/shade/renderer/shader/chunk/color/chunk_rgb_to_luminance.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/color/chunk_rgb_to_luminance.js +34 -32
- package/src/shade/renderer/shader/chunk/color/iCtCp/chunk_eotf_st2084.d.ts +31 -0
- package/src/shade/renderer/shader/chunk/color/iCtCp/chunk_eotf_st2084.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/color/iCtCp/chunk_eotf_st2084.js +62 -31
- package/src/shade/renderer/shader/chunk/color/iCtCp/chunk_inverse_eotf_st2084.d.ts +10 -0
- package/src/shade/renderer/shader/chunk/color/iCtCp/chunk_inverse_eotf_st2084.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/color/iCtCp/chunk_inverse_eotf_st2084.js +32 -22
- package/src/shade/renderer/shader/chunk/color/sRGB/chunk_sRGBTransferOETF.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/color/sRGB/chunk_sRGBTransferOETF.js +22 -21
- package/src/shade/renderer/shader/chunk/color/tonemap/gt7/chunk_tonemap_gt7.d.ts +6 -0
- package/src/shade/renderer/shader/chunk/color/tonemap/gt7/chunk_tonemap_gt7.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/color/tonemap/gt7/chunk_tonemap_gt7.js +110 -104
- package/src/shade/renderer/shader/chunk/color/xyz/chunk_rgb_to_xyz.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/color/xyz/chunk_rgb_to_xyz.js +23 -21
- package/src/view/elements/ColorPickerView.js +296 -296
- package/src/avif/codec/dec/Readme.md +0 -14
- package/src/avif/codec/dec/avif_dec.cpp +0 -234
- package/src/avif/codec/dec/avif_dec.d.ts +0 -3
- package/src/avif/codec/dec/avif_dec.d.ts.map +0 -1
- package/src/avif/codec/dec/avif_dec.js +0 -16
- package/src/avif/codec/dec/avif_dec.wasm +0 -0
- package/src/avif/codec/enc/README.md +0 -37
- package/src/avif/codec/enc/avif_enc.cpp +0 -216
- package/src/avif/codec/enc/avif_enc.d.ts +0 -3
- package/src/avif/codec/enc/avif_enc.d.ts.map +0 -1
- package/src/avif/codec/enc/avif_enc.js +0 -6144
- package/src/avif/codec/enc/avif_enc.wasm +0 -0
- package/src/avif/codec/enc/avif_enc_mt.d.ts +0 -3
- package/src/avif/codec/enc/avif_enc_mt.d.ts.map +0 -1
- package/src/avif/codec/enc/avif_enc_mt.js +0 -6811
- package/src/avif/codec/enc/avif_enc_mt.wasm +0 -0
- package/src/avif/codec/enc/avif_enc_mt.worker.d.mts +0 -2
- package/src/avif/codec/enc/avif_enc_mt.worker.d.mts.map +0 -1
- package/src/avif/codec/enc/avif_enc_mt.worker.d.ts +0 -11
- package/src/avif/codec/enc/avif_enc_mt.worker.d.ts.map +0 -1
- package/src/avif/codec/enc/avif_enc_mt.worker.js +0 -171
- package/src/avif/codec/enc/avif_enc_mt.worker.mjs +0 -1
- package/src/avif/decode.d.ts +0 -3
- package/src/avif/decode.d.ts.map +0 -1
- package/src/avif/decode.js +0 -42
- package/src/avif/encode.d.ts +0 -3
- package/src/avif/encode.d.ts.map +0 -1
- package/src/avif/encode.js +0 -75
- package/src/avif/meta.d.ts +0 -24
- package/src/avif/meta.d.ts.map +0 -1
- package/src/avif/meta.js +0 -23
- package/src/avif/tsconfig.tsbuildinfo +0 -1
- package/src/avif/utils.d.ts +0 -17
- package/src/avif/utils.d.ts.map +0 -1
- package/src/avif/utils.js +0 -31
- package/src/engine/asset/loaders/image/jpeg/idct8x8_fixed.d.ts +0 -23
- package/src/engine/asset/loaders/image/jpeg/idct8x8_fixed.d.ts.map +0 -1
- package/src/engine/asset/loaders/image/jpeg/idct8x8_fixed.js +0 -214
- package/src/engine/asset/loaders/image/png/inflate.d.ts +0 -7
- package/src/engine/asset/loaders/image/png/inflate.d.ts.map +0 -1
- package/src/engine/asset/loaders/image/png/inflate.js +0 -20
- package/src/engine/save/GameStateLoader.d.ts +0 -49
- package/src/engine/save/GameStateLoader.d.ts.map +0 -1
- 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",
|
|
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",
|
|
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;
|