@effectionx/worker 0.2.0 → 0.3.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/{script/deps/jsr.io/@std/assert/1.0.14 → esm/deps/jsr.io/@std/assert/1.0.16}/almost_equals.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/array_includes.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/array_includes.js +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/assert.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/assertion_error.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/1.0.16/equal.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/equal.js +5 -2
- package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/equals.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/equals.js +6 -5
- package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/exists.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/fail.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/false.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/greater.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/greater.js +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/greater_or_equal.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/greater_or_equal.js +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/instance_of.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/is_error.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/is_error.js +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/less.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/less.js +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/less_or_equal.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/less_or_equal.js +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/match.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/mod.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/not_equals.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/not_equals.js +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/not_instance_of.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/not_match.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/not_strict_equals.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/not_strict_equals.js +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/object_match.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/rejects.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/strict_equals.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/strict_equals.js +7 -6
- package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/string_includes.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/throws.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/unimplemented.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/unreachable.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/internal/{1.0.10 → 1.0.12}/build_message.d.ts +3 -5
- package/esm/deps/jsr.io/@std/internal/1.0.12/build_message.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/internal/{1.0.10 → 1.0.12}/build_message.js +13 -7
- package/esm/deps/jsr.io/@std/internal/{1.0.10 → 1.0.12}/diff.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/internal/1.0.12/diff_str.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/internal/{1.0.10 → 1.0.12}/format.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/internal/{1.0.10 → 1.0.12}/styles.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/internal/1.0.12/types.d.ts +25 -0
- package/esm/deps/jsr.io/@std/internal/1.0.12/types.d.ts.map +1 -0
- package/esm/message-channel.d.ts +3 -0
- package/esm/message-channel.d.ts.map +1 -0
- package/esm/message-channel.js +13 -0
- package/esm/mod.d.ts +1 -0
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +1 -0
- package/esm/types.d.ts +33 -0
- package/esm/types.d.ts.map +1 -0
- package/esm/types.js +1 -0
- package/esm/worker-main.d.ts +84 -0
- package/esm/worker-main.d.ts.map +1 -0
- package/esm/worker-main.js +186 -0
- package/esm/worker.d.ts +2 -74
- package/esm/worker.d.ts.map +1 -1
- package/esm/worker.js +4 -120
- package/package.json +3 -2
- package/{esm/deps/jsr.io/@std/assert/1.0.14 → script/deps/jsr.io/@std/assert/1.0.16}/almost_equals.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/array_includes.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/array_includes.js +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/assert.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/assertion_error.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/1.0.16/equal.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/equal.js +5 -2
- package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/equals.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/equals.js +6 -5
- package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/exists.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/fail.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/false.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/greater.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/greater.js +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/greater_or_equal.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/greater_or_equal.js +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/instance_of.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/is_error.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/is_error.js +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/less.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/less.js +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/less_or_equal.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/less_or_equal.js +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/match.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/mod.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/not_equals.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/not_equals.js +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/not_instance_of.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/not_match.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/not_strict_equals.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/not_strict_equals.js +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/object_match.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/rejects.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/strict_equals.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/strict_equals.js +7 -6
- package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/string_includes.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/throws.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/unimplemented.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/unreachable.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/internal/{1.0.10 → 1.0.12}/build_message.d.ts +3 -5
- package/script/deps/jsr.io/@std/internal/1.0.12/build_message.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/internal/{1.0.10 → 1.0.12}/build_message.js +13 -7
- package/script/deps/jsr.io/@std/internal/{1.0.10 → 1.0.12}/diff.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/internal/1.0.12/diff_str.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/internal/{1.0.10 → 1.0.12}/format.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/internal/{1.0.10 → 1.0.12}/styles.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/internal/1.0.12/types.d.ts +25 -0
- package/script/deps/jsr.io/@std/internal/1.0.12/types.d.ts.map +1 -0
- package/script/message-channel.d.ts +3 -0
- package/script/message-channel.d.ts.map +1 -0
- package/script/message-channel.js +16 -0
- package/script/mod.d.ts +1 -0
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +1 -0
- package/script/types.d.ts +33 -0
- package/script/types.d.ts.map +1 -0
- package/script/types.js +2 -0
- package/script/worker-main.d.ts +84 -0
- package/script/worker-main.d.ts.map +1 -0
- package/script/worker-main.js +190 -0
- package/script/worker.d.ts +2 -74
- package/script/worker.d.ts.map +1 -1
- package/script/worker.js +4 -121
- package/esm/deps/jsr.io/@std/assert/1.0.14/equal.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/internal/1.0.10/build_message.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/internal/1.0.10/diff_str.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/internal/1.0.10/types.d.ts +0 -16
- package/esm/deps/jsr.io/@std/internal/1.0.10/types.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.14/equal.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/internal/1.0.10/build_message.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/internal/1.0.10/diff_str.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/internal/1.0.10/types.d.ts +0 -16
- package/script/deps/jsr.io/@std/internal/1.0.10/types.d.ts.map +0 -1
- /package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/almost_equals.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/almost_equals.js +0 -0
- /package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/array_includes.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/assert.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/assert.js +0 -0
- /package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/assertion_error.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/assertion_error.js +0 -0
- /package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/equal.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/equals.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/exists.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/exists.js +0 -0
- /package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/fail.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/fail.js +0 -0
- /package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/false.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/false.js +0 -0
- /package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/greater.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/greater_or_equal.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/instance_of.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/instance_of.js +0 -0
- /package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/is_error.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/less.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/less_or_equal.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/match.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/match.js +0 -0
- /package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/mod.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/mod.js +0 -0
- /package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/not_equals.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/not_instance_of.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/not_instance_of.js +0 -0
- /package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/not_match.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/not_match.js +0 -0
- /package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/not_strict_equals.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/object_match.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/object_match.js +0 -0
- /package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/rejects.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/rejects.js +0 -0
- /package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/strict_equals.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/string_includes.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/string_includes.js +0 -0
- /package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/throws.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/throws.js +0 -0
- /package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/unimplemented.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/unimplemented.js +0 -0
- /package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/unreachable.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/unreachable.js +0 -0
- /package/esm/deps/jsr.io/@std/internal/{1.0.10 → 1.0.12}/diff.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/internal/{1.0.10 → 1.0.12}/diff.js +0 -0
- /package/esm/deps/jsr.io/@std/internal/{1.0.10 → 1.0.12}/diff_str.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/internal/{1.0.10 → 1.0.12}/diff_str.js +0 -0
- /package/esm/deps/jsr.io/@std/internal/{1.0.10 → 1.0.12}/format.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/internal/{1.0.10 → 1.0.12}/format.js +0 -0
- /package/esm/deps/jsr.io/@std/internal/{1.0.10 → 1.0.12}/styles.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/internal/{1.0.10 → 1.0.12}/styles.js +0 -0
- /package/esm/deps/jsr.io/@std/internal/{1.0.10 → 1.0.12}/types.js +0 -0
- /package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/almost_equals.d.ts +0 -0
- /package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/almost_equals.js +0 -0
- /package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/array_includes.d.ts +0 -0
- /package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/assert.d.ts +0 -0
- /package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/assert.js +0 -0
- /package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/assertion_error.d.ts +0 -0
- /package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/assertion_error.js +0 -0
- /package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/equal.d.ts +0 -0
- /package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/equals.d.ts +0 -0
- /package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/exists.d.ts +0 -0
- /package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/exists.js +0 -0
- /package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/fail.d.ts +0 -0
- /package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/fail.js +0 -0
- /package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/false.d.ts +0 -0
- /package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/false.js +0 -0
- /package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/greater.d.ts +0 -0
- /package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/greater_or_equal.d.ts +0 -0
- /package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/instance_of.d.ts +0 -0
- /package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/instance_of.js +0 -0
- /package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/is_error.d.ts +0 -0
- /package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/less.d.ts +0 -0
- /package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/less_or_equal.d.ts +0 -0
- /package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/match.d.ts +0 -0
- /package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/match.js +0 -0
- /package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/mod.d.ts +0 -0
- /package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/mod.js +0 -0
- /package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/not_equals.d.ts +0 -0
- /package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/not_instance_of.d.ts +0 -0
- /package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/not_instance_of.js +0 -0
- /package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/not_match.d.ts +0 -0
- /package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/not_match.js +0 -0
- /package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/not_strict_equals.d.ts +0 -0
- /package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/object_match.d.ts +0 -0
- /package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/object_match.js +0 -0
- /package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/rejects.d.ts +0 -0
- /package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/rejects.js +0 -0
- /package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/strict_equals.d.ts +0 -0
- /package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/string_includes.d.ts +0 -0
- /package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/string_includes.js +0 -0
- /package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/throws.d.ts +0 -0
- /package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/throws.js +0 -0
- /package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/unimplemented.d.ts +0 -0
- /package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/unimplemented.js +0 -0
- /package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/unreachable.d.ts +0 -0
- /package/script/deps/jsr.io/@std/assert/{1.0.14 → 1.0.16}/unreachable.js +0 -0
- /package/script/deps/jsr.io/@std/internal/{1.0.10 → 1.0.12}/diff.d.ts +0 -0
- /package/script/deps/jsr.io/@std/internal/{1.0.10 → 1.0.12}/diff.js +0 -0
- /package/script/deps/jsr.io/@std/internal/{1.0.10 → 1.0.12}/diff_str.d.ts +0 -0
- /package/script/deps/jsr.io/@std/internal/{1.0.10 → 1.0.12}/diff_str.js +0 -0
- /package/script/deps/jsr.io/@std/internal/{1.0.10 → 1.0.12}/format.d.ts +0 -0
- /package/script/deps/jsr.io/@std/internal/{1.0.10 → 1.0.12}/format.js +0 -0
- /package/script/deps/jsr.io/@std/internal/{1.0.10 → 1.0.12}/styles.d.ts +0 -0
- /package/script/deps/jsr.io/@std/internal/{1.0.10 → 1.0.12}/styles.js +0 -0
- /package/script/deps/jsr.io/@std/internal/{1.0.10 → 1.0.12}/types.js +0 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { ValueSignal } from "@effectionx/signals";
|
|
2
|
+
import { type Operation, type Task } from "effection";
|
|
3
|
+
import type { WorkerMainOptions } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Entrypoint used in the worker that estaliblishes communication
|
|
6
|
+
* with the main thread. It can be used to return a value,
|
|
7
|
+
* respond to messages or both.
|
|
8
|
+
*
|
|
9
|
+
* @example Returning a value
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { workerMain } from "../worker.ts";
|
|
12
|
+
*
|
|
13
|
+
* await workerMain(function* ({ data }) {
|
|
14
|
+
* return data;
|
|
15
|
+
* });
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @example Responding to messages
|
|
19
|
+
* ```ts
|
|
20
|
+
* import { workerMain } from "../worker.ts";
|
|
21
|
+
*
|
|
22
|
+
* await workerMain(function* ({ messages }) {
|
|
23
|
+
* yield* messages.forEach(function* (message) {
|
|
24
|
+
* return message;
|
|
25
|
+
* });
|
|
26
|
+
* });
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @example Responding to messages and return a value
|
|
30
|
+
* ```ts
|
|
31
|
+
* import { workerMain } from "../worker.ts";
|
|
32
|
+
*
|
|
33
|
+
* await workerMain<number, number, number, number>(
|
|
34
|
+
* function* ({ messages, data: initial }) {
|
|
35
|
+
* let counter = initial;
|
|
36
|
+
*
|
|
37
|
+
* yield* messages.forEach(function* (message) {
|
|
38
|
+
* counter += message;
|
|
39
|
+
* return counter; // returns a value after each message
|
|
40
|
+
* });
|
|
41
|
+
*
|
|
42
|
+
* return counter; // returns the final value
|
|
43
|
+
* },
|
|
44
|
+
* );
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* @template TSend - value main thread will send to the worker
|
|
48
|
+
* @template TRecv - value main thread will receive from the worker
|
|
49
|
+
* @template TReturn - worker operation return value
|
|
50
|
+
* @template TData - data passed from the main thread to the worker during initialization
|
|
51
|
+
* @param {(options: WorkerMainOptions<TSend, TRecv, TData>) => Operation<TReturn>} body
|
|
52
|
+
* @returns {Promise<void>}
|
|
53
|
+
*/
|
|
54
|
+
export declare function workerMain<TSend, TRecv, TReturn, TData>(body: (options: WorkerMainOptions<TSend, TRecv, TData>) => Operation<TReturn>): Promise<void>;
|
|
55
|
+
type New = {
|
|
56
|
+
type: "new";
|
|
57
|
+
};
|
|
58
|
+
type Running = {
|
|
59
|
+
type: "running";
|
|
60
|
+
task: Task<void>;
|
|
61
|
+
};
|
|
62
|
+
type Complete = {
|
|
63
|
+
type: "complete";
|
|
64
|
+
value: unknown;
|
|
65
|
+
};
|
|
66
|
+
type Errored = {
|
|
67
|
+
type: "error";
|
|
68
|
+
error: Error;
|
|
69
|
+
};
|
|
70
|
+
type Interrupted = {
|
|
71
|
+
type: "interrupted";
|
|
72
|
+
error: Error;
|
|
73
|
+
};
|
|
74
|
+
type WorkerState = New | Running | Complete | Errored | Interrupted;
|
|
75
|
+
interface WorkerStateSignal extends ValueSignal<WorkerState> {
|
|
76
|
+
state: WorkerState["type"];
|
|
77
|
+
start(task: Task<void>): Running | Complete;
|
|
78
|
+
complete(value: unknown): Complete;
|
|
79
|
+
crash(error: Error): Errored;
|
|
80
|
+
interrupt(): Interrupted;
|
|
81
|
+
}
|
|
82
|
+
export declare function createWorkerStatesSignal(): Operation<WorkerStateSignal>;
|
|
83
|
+
export {};
|
|
84
|
+
//# sourceMappingURL=worker-main.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker-main.d.ts","sourceRoot":"","sources":["../src/worker-main.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAOL,KAAK,SAAS,EAGd,KAAK,IAAI,EACV,MAAM,WAAW,CAAC;AAEnB,OAAO,KAAK,EAAiB,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,wBAAsB,UAAU,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAC3D,IAAI,EAAE,CAAC,OAAO,EAAE,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,SAAS,CAAC,OAAO,CAAC,GAC5E,OAAO,CAAC,IAAI,CAAC,CAqEf;AAED,KAAK,GAAG,GAAG;IAAE,IAAI,EAAE,KAAK,CAAA;CAAE,CAAC;AAC3B,KAAK,OAAO,GAAG;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAA;CAAE,CAAC;AACrD,KAAK,QAAQ,GAAG;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC;AACrD,KAAK,OAAO,GAAG;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,CAAC;AAC/C,KAAK,WAAW,GAAG;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,CAAC;AAEzD,KAAK,WAAW,GAAG,GAAG,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,WAAW,CAAC;AAEpE,UAAU,iBAAkB,SAAQ,WAAW,CAAC,WAAW,CAAC;IAC1D,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC3B,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,OAAO,GAAG,QAAQ,CAAC;IAC5C,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,QAAQ,CAAC;IACnC,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC;IAC7B,SAAS,IAAI,WAAW,CAAC;CAC1B;AAED,wBAAgB,wBAAwB,IAAI,SAAS,CAAC,iBAAiB,CAAC,CAkEvE"}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { createSignal, each, Err, main, Ok, on, resource, spawn, } from "effection";
|
|
2
|
+
/**
|
|
3
|
+
* Entrypoint used in the worker that estaliblishes communication
|
|
4
|
+
* with the main thread. It can be used to return a value,
|
|
5
|
+
* respond to messages or both.
|
|
6
|
+
*
|
|
7
|
+
* @example Returning a value
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { workerMain } from "../worker.ts";
|
|
10
|
+
*
|
|
11
|
+
* await workerMain(function* ({ data }) {
|
|
12
|
+
* return data;
|
|
13
|
+
* });
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @example Responding to messages
|
|
17
|
+
* ```ts
|
|
18
|
+
* import { workerMain } from "../worker.ts";
|
|
19
|
+
*
|
|
20
|
+
* await workerMain(function* ({ messages }) {
|
|
21
|
+
* yield* messages.forEach(function* (message) {
|
|
22
|
+
* return message;
|
|
23
|
+
* });
|
|
24
|
+
* });
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @example Responding to messages and return a value
|
|
28
|
+
* ```ts
|
|
29
|
+
* import { workerMain } from "../worker.ts";
|
|
30
|
+
*
|
|
31
|
+
* await workerMain<number, number, number, number>(
|
|
32
|
+
* function* ({ messages, data: initial }) {
|
|
33
|
+
* let counter = initial;
|
|
34
|
+
*
|
|
35
|
+
* yield* messages.forEach(function* (message) {
|
|
36
|
+
* counter += message;
|
|
37
|
+
* return counter; // returns a value after each message
|
|
38
|
+
* });
|
|
39
|
+
*
|
|
40
|
+
* return counter; // returns the final value
|
|
41
|
+
* },
|
|
42
|
+
* );
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* @template TSend - value main thread will send to the worker
|
|
46
|
+
* @template TRecv - value main thread will receive from the worker
|
|
47
|
+
* @template TReturn - worker operation return value
|
|
48
|
+
* @template TData - data passed from the main thread to the worker during initialization
|
|
49
|
+
* @param {(options: WorkerMainOptions<TSend, TRecv, TData>) => Operation<TReturn>} body
|
|
50
|
+
* @returns {Promise<void>}
|
|
51
|
+
*/
|
|
52
|
+
export async function workerMain(body) {
|
|
53
|
+
await main(function* () {
|
|
54
|
+
let sent = createSignal();
|
|
55
|
+
let worker = yield* createWorkerStatesSignal();
|
|
56
|
+
yield* spawn(function* () {
|
|
57
|
+
for (const message of yield* each(on(self, "message"))) {
|
|
58
|
+
const control = message.data;
|
|
59
|
+
switch (control.type) {
|
|
60
|
+
case "init": {
|
|
61
|
+
worker.start(yield* spawn(function* () {
|
|
62
|
+
try {
|
|
63
|
+
let value = yield* body({
|
|
64
|
+
data: control.data,
|
|
65
|
+
messages: {
|
|
66
|
+
*forEach(fn) {
|
|
67
|
+
for (let { value, response } of yield* each(sent)) {
|
|
68
|
+
yield* spawn(function* () {
|
|
69
|
+
try {
|
|
70
|
+
let result = yield* fn(value);
|
|
71
|
+
response.postMessage(Ok(result));
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
response.postMessage(Err(error));
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
yield* each.next();
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
worker.complete(value);
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
worker.crash(error);
|
|
86
|
+
}
|
|
87
|
+
}));
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
case "send": {
|
|
91
|
+
let { value, response } = control;
|
|
92
|
+
sent.send({ value, response });
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
case "close": {
|
|
96
|
+
const current = worker.valueOf();
|
|
97
|
+
if (current.type === "running") {
|
|
98
|
+
yield* current.task.halt();
|
|
99
|
+
worker.interrupt();
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
yield* each.next();
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
for (const state of yield* each(worker)) {
|
|
107
|
+
if (state.type === "new") {
|
|
108
|
+
postMessage({ type: "open" });
|
|
109
|
+
}
|
|
110
|
+
else if (state.type === "interrupted" || state.type === "error") {
|
|
111
|
+
postMessage({ type: "close", result: Err(state.error) });
|
|
112
|
+
}
|
|
113
|
+
else if (state.type === "complete") {
|
|
114
|
+
postMessage({ type: "close", result: Ok(state.value) });
|
|
115
|
+
}
|
|
116
|
+
yield* each.next();
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
export function createWorkerStatesSignal() {
|
|
121
|
+
return resource(function* (provide) {
|
|
122
|
+
let ref = {
|
|
123
|
+
current: { type: "new" },
|
|
124
|
+
};
|
|
125
|
+
const signal = createSignal();
|
|
126
|
+
const set = (value) => {
|
|
127
|
+
signal.send(ref.current = value);
|
|
128
|
+
return value;
|
|
129
|
+
};
|
|
130
|
+
const update = (updater) => set(updater(ref.current));
|
|
131
|
+
const interrupt = () => {
|
|
132
|
+
let next = {
|
|
133
|
+
type: "interrupted",
|
|
134
|
+
error: new Error(`worker terminated`),
|
|
135
|
+
};
|
|
136
|
+
set(next);
|
|
137
|
+
return next;
|
|
138
|
+
};
|
|
139
|
+
try {
|
|
140
|
+
yield* provide({
|
|
141
|
+
*[Symbol.iterator]() {
|
|
142
|
+
let subscription = yield* signal;
|
|
143
|
+
signal.send(ref.current);
|
|
144
|
+
return subscription;
|
|
145
|
+
},
|
|
146
|
+
get state() {
|
|
147
|
+
return ref.current.type;
|
|
148
|
+
},
|
|
149
|
+
set,
|
|
150
|
+
update,
|
|
151
|
+
valueOf() {
|
|
152
|
+
return ref.current;
|
|
153
|
+
},
|
|
154
|
+
start(task) {
|
|
155
|
+
if (ref.current.type === "complete") {
|
|
156
|
+
return ref.current;
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
const next = { type: "running", task };
|
|
160
|
+
set(next);
|
|
161
|
+
return next;
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
complete(value) {
|
|
165
|
+
let next = { type: "complete", value };
|
|
166
|
+
set(next);
|
|
167
|
+
return next;
|
|
168
|
+
},
|
|
169
|
+
crash(error) {
|
|
170
|
+
let next = { type: "error", error };
|
|
171
|
+
set(next);
|
|
172
|
+
return next;
|
|
173
|
+
},
|
|
174
|
+
interrupt: interrupt,
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
finally {
|
|
178
|
+
if (ref.current.type === "running") {
|
|
179
|
+
interrupt();
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
function postMessage(message) {
|
|
185
|
+
self.postMessage(message);
|
|
186
|
+
}
|
package/esm/worker.d.ts
CHANGED
|
@@ -1,18 +1,4 @@
|
|
|
1
1
|
import { type Operation } from "effection";
|
|
2
|
-
export interface WorkerResource<TSend, TRecv, TReturn> extends Operation<TReturn> {
|
|
3
|
-
send(data: TSend): Operation<TRecv>;
|
|
4
|
-
}
|
|
5
|
-
/**
|
|
6
|
-
* Object that represents messages the main thread
|
|
7
|
-
* sends to the worker. It provides function for
|
|
8
|
-
* handling messages.
|
|
9
|
-
*
|
|
10
|
-
* @template TSend - value main thread will send to the worker
|
|
11
|
-
* @template TRecv - value main thread will receive from the worker
|
|
12
|
-
*/
|
|
13
|
-
export interface WorkerMessages<TSend, TRecv> {
|
|
14
|
-
forEach(fn: (message: TSend) => Operation<TRecv>): Operation<void>;
|
|
15
|
-
}
|
|
16
2
|
/**
|
|
17
3
|
* Argument received by workerMain function
|
|
18
4
|
*
|
|
@@ -20,67 +6,9 @@ export interface WorkerMessages<TSend, TRecv> {
|
|
|
20
6
|
* @template TRecv - value main thread will receive from the worker
|
|
21
7
|
* @template TData - data passed from the main thread to the worker during initialization
|
|
22
8
|
*/
|
|
23
|
-
export interface
|
|
24
|
-
|
|
25
|
-
* Namespace that provides APIs for working with incoming messages
|
|
26
|
-
*/
|
|
27
|
-
messages: WorkerMessages<TSend, TRecv>;
|
|
28
|
-
/**
|
|
29
|
-
* Initial data received by the worker from the main thread used for initialization.
|
|
30
|
-
*/
|
|
31
|
-
data: TData;
|
|
9
|
+
export interface WorkerResource<TSend, TRecv, TReturn> extends Operation<TReturn> {
|
|
10
|
+
send(data: TSend): Operation<TRecv>;
|
|
32
11
|
}
|
|
33
|
-
/**
|
|
34
|
-
* Entrypoint used in the worker that estaliblishes communication
|
|
35
|
-
* with the main thread. It can be used to return a value,
|
|
36
|
-
* respond to messages or both.
|
|
37
|
-
*
|
|
38
|
-
* @example Returning a value
|
|
39
|
-
* ```ts
|
|
40
|
-
* import { workerMain } from "../worker.ts";
|
|
41
|
-
*
|
|
42
|
-
* await workerMain(function* ({ data }) {
|
|
43
|
-
* return data;
|
|
44
|
-
* });
|
|
45
|
-
* ```
|
|
46
|
-
*
|
|
47
|
-
* @example Responding to messages
|
|
48
|
-
* ```ts
|
|
49
|
-
* import { workerMain } from "../worker.ts";
|
|
50
|
-
*
|
|
51
|
-
* await workerMain(function* ({ messages }) {
|
|
52
|
-
* yield* messages.forEach(function* (message) {
|
|
53
|
-
* return message;
|
|
54
|
-
* });
|
|
55
|
-
* });
|
|
56
|
-
* ```
|
|
57
|
-
*
|
|
58
|
-
* @example Responding to messages and return a value
|
|
59
|
-
* ```ts
|
|
60
|
-
* import { workerMain } from "../worker.ts";
|
|
61
|
-
*
|
|
62
|
-
* await workerMain<number, number, number, number>(
|
|
63
|
-
* function* ({ messages, data: initial }) {
|
|
64
|
-
* let counter = initial;
|
|
65
|
-
*
|
|
66
|
-
* yield* messages.forEach(function* (message) {
|
|
67
|
-
* counter += message;
|
|
68
|
-
* return counter; // returns a value after each message
|
|
69
|
-
* });
|
|
70
|
-
*
|
|
71
|
-
* return counter; // returns the final value
|
|
72
|
-
* },
|
|
73
|
-
* );
|
|
74
|
-
* ```
|
|
75
|
-
*
|
|
76
|
-
* @template TSend - value main thread will send to the worker
|
|
77
|
-
* @template TRecv - value main thread will receive from the worker
|
|
78
|
-
* @template TReturn - worker operation return value
|
|
79
|
-
* @template TData - data passed from the main thread to the worker during initialization
|
|
80
|
-
* @param {(options: WorkerMainOptions<TSend, TRecv, TData>) => Operation<TReturn>} body
|
|
81
|
-
* @returns {Promise<void>}
|
|
82
|
-
*/
|
|
83
|
-
export declare function workerMain<TSend, TRecv, TReturn, TData>(body: (options: WorkerMainOptions<TSend, TRecv, TData>) => Operation<TReturn>): Promise<void>;
|
|
84
12
|
/**
|
|
85
13
|
* Use on the main thread to create and exeecute a well behaved web worker.
|
|
86
14
|
*
|
package/esm/worker.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../src/worker.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../src/worker.ts"],"names":[],"mappings":"AACA,OAAO,EAKL,KAAK,SAAS,EAKf,MAAM,WAAW,CAAC;AAInB;;;;;;GAMG;AACH,MAAM,WAAW,cAAc,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CACnD,SAAQ,SAAS,CAAC,OAAO,CAAC;IAC1B,IAAI,CAAC,IAAI,EAAE,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;CACrC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EACpD,GAAG,EAAE,MAAM,GAAG,GAAG,EACjB,OAAO,CAAC,EAAE,aAAa,GAAG;IAAE,IAAI,CAAC,EAAE,KAAK,CAAA;CAAE,GACzC,SAAS,CAAC,cAAc,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAgElD"}
|
package/esm/worker.js
CHANGED
|
@@ -1,110 +1,6 @@
|
|
|
1
|
-
import { assert } from "./deps/jsr.io/@std/assert/1.0.
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
* Entrypoint used in the worker that estaliblishes communication
|
|
5
|
-
* with the main thread. It can be used to return a value,
|
|
6
|
-
* respond to messages or both.
|
|
7
|
-
*
|
|
8
|
-
* @example Returning a value
|
|
9
|
-
* ```ts
|
|
10
|
-
* import { workerMain } from "../worker.ts";
|
|
11
|
-
*
|
|
12
|
-
* await workerMain(function* ({ data }) {
|
|
13
|
-
* return data;
|
|
14
|
-
* });
|
|
15
|
-
* ```
|
|
16
|
-
*
|
|
17
|
-
* @example Responding to messages
|
|
18
|
-
* ```ts
|
|
19
|
-
* import { workerMain } from "../worker.ts";
|
|
20
|
-
*
|
|
21
|
-
* await workerMain(function* ({ messages }) {
|
|
22
|
-
* yield* messages.forEach(function* (message) {
|
|
23
|
-
* return message;
|
|
24
|
-
* });
|
|
25
|
-
* });
|
|
26
|
-
* ```
|
|
27
|
-
*
|
|
28
|
-
* @example Responding to messages and return a value
|
|
29
|
-
* ```ts
|
|
30
|
-
* import { workerMain } from "../worker.ts";
|
|
31
|
-
*
|
|
32
|
-
* await workerMain<number, number, number, number>(
|
|
33
|
-
* function* ({ messages, data: initial }) {
|
|
34
|
-
* let counter = initial;
|
|
35
|
-
*
|
|
36
|
-
* yield* messages.forEach(function* (message) {
|
|
37
|
-
* counter += message;
|
|
38
|
-
* return counter; // returns a value after each message
|
|
39
|
-
* });
|
|
40
|
-
*
|
|
41
|
-
* return counter; // returns the final value
|
|
42
|
-
* },
|
|
43
|
-
* );
|
|
44
|
-
* ```
|
|
45
|
-
*
|
|
46
|
-
* @template TSend - value main thread will send to the worker
|
|
47
|
-
* @template TRecv - value main thread will receive from the worker
|
|
48
|
-
* @template TReturn - worker operation return value
|
|
49
|
-
* @template TData - data passed from the main thread to the worker during initialization
|
|
50
|
-
* @param {(options: WorkerMainOptions<TSend, TRecv, TData>) => Operation<TReturn>} body
|
|
51
|
-
* @returns {Promise<void>}
|
|
52
|
-
*/
|
|
53
|
-
export async function workerMain(body) {
|
|
54
|
-
await main(function* () {
|
|
55
|
-
let sent = createSignal();
|
|
56
|
-
let controls = yield* on(self, "message");
|
|
57
|
-
let outcome = withResolvers();
|
|
58
|
-
self.postMessage({ type: "open" });
|
|
59
|
-
let result = yield* scoped(function* () {
|
|
60
|
-
yield* spawn(function* () {
|
|
61
|
-
let next = yield* controls.next();
|
|
62
|
-
while (true) {
|
|
63
|
-
let control = next.value.data;
|
|
64
|
-
if (control.type === "init") {
|
|
65
|
-
yield* spawn(function* () {
|
|
66
|
-
try {
|
|
67
|
-
let value = yield* body({
|
|
68
|
-
data: control.data,
|
|
69
|
-
messages: {
|
|
70
|
-
*forEach(fn) {
|
|
71
|
-
for (let { value, response } of yield* each(sent)) {
|
|
72
|
-
yield* spawn(function* () {
|
|
73
|
-
try {
|
|
74
|
-
let result = yield* fn(value);
|
|
75
|
-
response.postMessage(Ok(result));
|
|
76
|
-
}
|
|
77
|
-
catch (error) {
|
|
78
|
-
response.postMessage(Err(error));
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
yield* each.next();
|
|
82
|
-
}
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
});
|
|
86
|
-
outcome.resolve(Ok(value));
|
|
87
|
-
}
|
|
88
|
-
catch (error) {
|
|
89
|
-
outcome.resolve(Err(error));
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
else if (control.type === "send") {
|
|
94
|
-
let { value, response } = control;
|
|
95
|
-
sent.send({ value, response });
|
|
96
|
-
}
|
|
97
|
-
else if (control.type === "close") {
|
|
98
|
-
outcome.resolve(Err(new Error(`worker terminated`)));
|
|
99
|
-
}
|
|
100
|
-
next = yield* controls.next();
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
return yield* outcome.operation;
|
|
104
|
-
});
|
|
105
|
-
self.postMessage({ type: "close", result });
|
|
106
|
-
});
|
|
107
|
-
}
|
|
1
|
+
import { assert } from "./deps/jsr.io/@std/assert/1.0.16/mod.js";
|
|
2
|
+
import { Err, Ok, on, once, resource, spawn, withResolvers, } from "effection";
|
|
3
|
+
import { useMessageChannel } from "./message-channel.js";
|
|
108
4
|
/**
|
|
109
5
|
* Use on the main thread to create and exeecute a well behaved web worker.
|
|
110
6
|
*
|
|
@@ -210,24 +106,12 @@ export function useWorker(url, options) {
|
|
|
210
106
|
}
|
|
211
107
|
});
|
|
212
108
|
}
|
|
213
|
-
function useMessageChannel() {
|
|
214
|
-
return resource(function* (provide) {
|
|
215
|
-
let channel = new MessageChannel();
|
|
216
|
-
try {
|
|
217
|
-
yield* provide(channel);
|
|
218
|
-
}
|
|
219
|
-
finally {
|
|
220
|
-
channel.port1.close();
|
|
221
|
-
channel.port2.close();
|
|
222
|
-
}
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
109
|
function settled(operation) {
|
|
226
110
|
return {
|
|
227
111
|
*[Symbol.iterator]() {
|
|
228
112
|
try {
|
|
229
113
|
yield* operation;
|
|
230
|
-
return Ok();
|
|
114
|
+
return Ok(void 0);
|
|
231
115
|
}
|
|
232
116
|
catch (error) {
|
|
233
117
|
return Err(error);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effectionx/worker",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"author": "engineering@frontside.com",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
},
|
|
25
25
|
"sideEffects": false,
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"
|
|
27
|
+
"@effectionx/signals": "0.3.0",
|
|
28
|
+
"effection": "^3 || ^4.0.0-0"
|
|
28
29
|
},
|
|
29
30
|
"_generatedBy": "dnt@dev"
|
|
30
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"almost_equals.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.
|
|
1
|
+
{"version":3,"file":"almost_equals.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.16/almost_equals.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,SAAS,CAAC,EAAE,MAAM,EAClB,GAAG,CAAC,EAAE,MAAM,QAmBb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array_includes.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.
|
|
1
|
+
{"version":3,"file":"array_includes.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.16/array_includes.ts"],"names":[],"mappings":"AAMA,0FAA0F;AAC1F,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EACnC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,EACvB,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC,EACzB,GAAG,CAAC,EAAE,MAAM,QAwBb"}
|
|
@@ -4,7 +4,7 @@ exports.assertArrayIncludes = assertArrayIncludes;
|
|
|
4
4
|
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
5
5
|
// This module is browser compatible.
|
|
6
6
|
const equal_js_1 = require("./equal.js");
|
|
7
|
-
const format_js_1 = require("../../internal/1.0.
|
|
7
|
+
const format_js_1 = require("../../internal/1.0.12/format.js");
|
|
8
8
|
const assertion_error_js_1 = require("./assertion_error.js");
|
|
9
9
|
/**
|
|
10
10
|
* Make an assertion that `actual` includes the `expected` values. If not then
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assert.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.
|
|
1
|
+
{"version":3,"file":"assert.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.16/assert.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,SAAK,GAAG,OAAO,CAAC,IAAI,CAI5D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assertion_error.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.
|
|
1
|
+
{"version":3,"file":"assertion_error.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.16/assertion_error.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,cAAe,SAAQ,KAAK;IACvC;;;;OAIG;gBACS,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;CAIpD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"equal.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.16/equal.ts"],"names":[],"mappings":"AA0FA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CAgHrD"}
|
|
@@ -70,8 +70,7 @@ function getKeysDeep(obj) {
|
|
|
70
70
|
return keys;
|
|
71
71
|
}
|
|
72
72
|
// deno-lint-ignore no-explicit-any
|
|
73
|
-
const Temporal = dntShim.dntGlobalThis.Temporal ??
|
|
74
|
-
new Proxy({}, { get: () => { } });
|
|
73
|
+
const Temporal = dntShim.dntGlobalThis.Temporal ?? Object.create(null);
|
|
75
74
|
/** A non-exhaustive list of prototypes that can be accurately fast-path compared with `String(instance)` */
|
|
76
75
|
const stringComparablePrototypes = new Set([
|
|
77
76
|
Intl.Locale,
|
|
@@ -141,6 +140,10 @@ function equal(a, b) {
|
|
|
141
140
|
if (a instanceof TypedArray) {
|
|
142
141
|
return compareTypedArrays(a, b);
|
|
143
142
|
}
|
|
143
|
+
if (a instanceof ArrayBuffer ||
|
|
144
|
+
(globalThis.SharedArrayBuffer && a instanceof SharedArrayBuffer)) {
|
|
145
|
+
return compareTypedArrays(new Uint8Array(a), new Uint8Array(b));
|
|
146
|
+
}
|
|
144
147
|
if (a instanceof WeakMap) {
|
|
145
148
|
throw new TypeError("Cannot compare WeakMap instances");
|
|
146
149
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"equals.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.
|
|
1
|
+
{"version":3,"file":"equals.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.16/equals.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAC5B,MAAM,EAAE,CAAC,EACT,QAAQ,EAAE,CAAC,EACX,GAAG,CAAC,EAAE,MAAM,QAmBb"}
|
|
@@ -4,10 +4,10 @@ exports.assertEquals = assertEquals;
|
|
|
4
4
|
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
5
5
|
// This module is browser compatible.
|
|
6
6
|
const equal_js_1 = require("./equal.js");
|
|
7
|
-
const build_message_js_1 = require("../../internal/1.0.
|
|
8
|
-
const diff_js_1 = require("../../internal/1.0.
|
|
9
|
-
const diff_str_js_1 = require("../../internal/1.0.
|
|
10
|
-
const format_js_1 = require("../../internal/1.0.
|
|
7
|
+
const build_message_js_1 = require("../../internal/1.0.12/build_message.js");
|
|
8
|
+
const diff_js_1 = require("../../internal/1.0.12/diff.js");
|
|
9
|
+
const diff_str_js_1 = require("../../internal/1.0.12/diff_str.js");
|
|
10
|
+
const format_js_1 = require("../../internal/1.0.12/format.js");
|
|
11
11
|
const assertion_error_js_1 = require("./assertion_error.js");
|
|
12
12
|
/**
|
|
13
13
|
* Make an assertion that `actual` and `expected` are equal, deeply. If not
|
|
@@ -55,7 +55,8 @@ function assertEquals(actual, expected, msg) {
|
|
|
55
55
|
const diffResult = stringDiff
|
|
56
56
|
? (0, diff_str_js_1.diffStr)(actual, expected)
|
|
57
57
|
: (0, diff_js_1.diff)(actualString.split("\n"), expectedString.split("\n"));
|
|
58
|
-
const diffMsg = (0, build_message_js_1.buildMessage)(diffResult, { stringDiff })
|
|
58
|
+
const diffMsg = (0, build_message_js_1.buildMessage)(diffResult, { stringDiff }, arguments[3])
|
|
59
|
+
.join("\n");
|
|
59
60
|
message = `${message}\n${diffMsg}`;
|
|
60
61
|
throw new assertion_error_js_1.AssertionError(message);
|
|
61
62
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exists.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.
|
|
1
|
+
{"version":3,"file":"exists.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.16/exists.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAC5B,MAAM,EAAE,CAAC,EACT,GAAG,CAAC,EAAE,MAAM,GACX,OAAO,CAAC,MAAM,IAAI,WAAW,CAAC,CAAC,CAAC,CAOlC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fail.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.
|
|
1
|
+
{"version":3,"file":"fail.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.16/fail.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;GAYG;AACH,wBAAgB,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,KAAK,CAGxC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"false.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.
|
|
1
|
+
{"version":3,"file":"false.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.16/false.ts"],"names":[],"mappings":"AAIA,uDAAuD;AACvD,MAAM,MAAM,KAAK,GAAG,KAAK,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,GAAG,SAAS,CAAC;AAE3D;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,SAAK,GAAG,OAAO,CAAC,IAAI,IAAI,KAAK,CAI1E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"greater.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.
|
|
1
|
+
{"version":3,"file":"greater.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.16/greater.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,QAMpE"}
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.assertGreater = assertGreater;
|
|
4
4
|
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
5
5
|
// This module is browser compatible.
|
|
6
|
-
const format_js_1 = require("../../internal/1.0.
|
|
6
|
+
const format_js_1 = require("../../internal/1.0.12/format.js");
|
|
7
7
|
const assertion_error_js_1 = require("./assertion_error.js");
|
|
8
8
|
/**
|
|
9
9
|
* Make an assertion that `actual` is greater than `expected`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"greater_or_equal.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.
|
|
1
|
+
{"version":3,"file":"greater_or_equal.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.16/greater_or_equal.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EACpC,MAAM,EAAE,CAAC,EACT,QAAQ,EAAE,CAAC,EACX,GAAG,CAAC,EAAE,MAAM,QASb"}
|