@effectionx/worker 0.3.2 → 0.4.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/dist/message-channel.d.ts.map +1 -0
- package/dist/mod.d.ts +4 -0
- package/dist/mod.d.ts.map +1 -0
- package/dist/test-simple-worker.d.ts +2 -0
- package/dist/test-simple-worker.d.ts.map +1 -0
- package/dist/test-simple-worker.js +11 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types.d.ts.map +1 -0
- package/{esm → dist}/worker-main.d.ts +1 -1
- package/dist/worker-main.d.ts.map +1 -0
- package/{esm → dist}/worker-main.js +34 -16
- package/dist/worker.d.ts.map +1 -0
- package/{esm → dist}/worker.js +3 -4
- package/message-channel.ts +13 -0
- package/mod.ts +3 -0
- package/package.json +22 -16
- package/test-assets/boom-result-worker.ts +5 -0
- package/test-assets/boom-worker.ts +7 -0
- package/test-assets/counter-worker.ts +15 -0
- package/test-assets/crash-worker.ts +1 -0
- package/test-assets/echo-worker.ts +7 -0
- package/test-assets/result-worker.ts +5 -0
- package/test-assets/shutdown-worker.ts +24 -0
- package/test-assets/suspend-worker.ts +4 -0
- package/test-simple-worker.ts +12 -0
- package/tsconfig.json +20 -0
- package/types.ts +38 -0
- package/worker-main.ts +248 -0
- package/worker.test.ts +179 -0
- package/worker.ts +159 -0
- package/esm/_dnt.shims.d.ts +0 -2
- package/esm/_dnt.shims.d.ts.map +0 -1
- package/esm/_dnt.shims.js +0 -57
- package/esm/deps/jsr.io/@std/assert/1.0.16/almost_equals.d.ts +0 -29
- package/esm/deps/jsr.io/@std/assert/1.0.16/almost_equals.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.16/almost_equals.js +0 -46
- package/esm/deps/jsr.io/@std/assert/1.0.16/array_includes.d.ts +0 -24
- package/esm/deps/jsr.io/@std/assert/1.0.16/array_includes.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.16/array_includes.js +0 -46
- package/esm/deps/jsr.io/@std/assert/1.0.16/assert.d.ts +0 -16
- package/esm/deps/jsr.io/@std/assert/1.0.16/assert.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.16/assert.js +0 -22
- package/esm/deps/jsr.io/@std/assert/1.0.16/assertion_error.d.ts +0 -26
- package/esm/deps/jsr.io/@std/assert/1.0.16/assertion_error.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.16/assertion_error.js +0 -30
- package/esm/deps/jsr.io/@std/assert/1.0.16/equal.d.ts +0 -17
- package/esm/deps/jsr.io/@std/assert/1.0.16/equal.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.16/equal.js +0 -186
- package/esm/deps/jsr.io/@std/assert/1.0.16/equals.d.ts +0 -35
- package/esm/deps/jsr.io/@std/assert/1.0.16/equals.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.16/equals.js +0 -59
- package/esm/deps/jsr.io/@std/assert/1.0.16/exists.d.ts +0 -18
- package/esm/deps/jsr.io/@std/assert/1.0.16/exists.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.16/exists.js +0 -27
- package/esm/deps/jsr.io/@std/assert/1.0.16/fail.d.ts +0 -15
- package/esm/deps/jsr.io/@std/assert/1.0.16/fail.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.16/fail.js +0 -20
- package/esm/deps/jsr.io/@std/assert/1.0.16/false.d.ts +0 -18
- package/esm/deps/jsr.io/@std/assert/1.0.16/false.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.16/false.js +0 -22
- package/esm/deps/jsr.io/@std/assert/1.0.16/greater.d.ts +0 -20
- package/esm/deps/jsr.io/@std/assert/1.0.16/greater.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.16/greater.js +0 -29
- package/esm/deps/jsr.io/@std/assert/1.0.16/greater_or_equal.d.ts +0 -20
- package/esm/deps/jsr.io/@std/assert/1.0.16/greater_or_equal.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.16/greater_or_equal.js +0 -29
- package/esm/deps/jsr.io/@std/assert/1.0.16/instance_of.d.ts +0 -23
- package/esm/deps/jsr.io/@std/assert/1.0.16/instance_of.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.16/instance_of.js +0 -52
- package/esm/deps/jsr.io/@std/assert/1.0.16/is_error.d.ts +0 -25
- package/esm/deps/jsr.io/@std/assert/1.0.16/is_error.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.16/is_error.js +0 -53
- package/esm/deps/jsr.io/@std/assert/1.0.16/less.d.ts +0 -19
- package/esm/deps/jsr.io/@std/assert/1.0.16/less.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.16/less.js +0 -28
- package/esm/deps/jsr.io/@std/assert/1.0.16/less_or_equal.d.ts +0 -20
- package/esm/deps/jsr.io/@std/assert/1.0.16/less_or_equal.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.16/less_or_equal.js +0 -29
- package/esm/deps/jsr.io/@std/assert/1.0.16/match.d.ts +0 -18
- package/esm/deps/jsr.io/@std/assert/1.0.16/match.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.16/match.js +0 -26
- package/esm/deps/jsr.io/@std/assert/1.0.16/mod.d.ts +0 -44
- package/esm/deps/jsr.io/@std/assert/1.0.16/mod.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.16/mod.js +0 -45
- package/esm/deps/jsr.io/@std/assert/1.0.16/not_equals.d.ts +0 -21
- package/esm/deps/jsr.io/@std/assert/1.0.16/not_equals.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.16/not_equals.js +0 -33
- package/esm/deps/jsr.io/@std/assert/1.0.16/not_instance_of.d.ts +0 -20
- package/esm/deps/jsr.io/@std/assert/1.0.16/not_instance_of.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.16/not_instance_of.js +0 -29
- package/esm/deps/jsr.io/@std/assert/1.0.16/not_match.d.ts +0 -18
- package/esm/deps/jsr.io/@std/assert/1.0.16/not_match.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.16/not_match.js +0 -26
- package/esm/deps/jsr.io/@std/assert/1.0.16/not_strict_equals.d.ts +0 -23
- package/esm/deps/jsr.io/@std/assert/1.0.16/not_strict_equals.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.16/not_strict_equals.js +0 -32
- package/esm/deps/jsr.io/@std/assert/1.0.16/object_match.d.ts +0 -29
- package/esm/deps/jsr.io/@std/assert/1.0.16/object_match.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.16/object_match.js +0 -167
- package/esm/deps/jsr.io/@std/assert/1.0.16/rejects.d.ts +0 -42
- package/esm/deps/jsr.io/@std/assert/1.0.16/rejects.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.16/rejects.js +0 -53
- package/esm/deps/jsr.io/@std/assert/1.0.16/strict_equals.d.ts +0 -24
- package/esm/deps/jsr.io/@std/assert/1.0.16/strict_equals.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.16/strict_equals.js +0 -58
- package/esm/deps/jsr.io/@std/assert/1.0.16/string_includes.d.ts +0 -18
- package/esm/deps/jsr.io/@std/assert/1.0.16/string_includes.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.16/string_includes.js +0 -26
- package/esm/deps/jsr.io/@std/assert/1.0.16/throws.d.ts +0 -45
- package/esm/deps/jsr.io/@std/assert/1.0.16/throws.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.16/throws.js +0 -44
- package/esm/deps/jsr.io/@std/assert/1.0.16/unimplemented.d.ts +0 -15
- package/esm/deps/jsr.io/@std/assert/1.0.16/unimplemented.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.16/unimplemented.js +0 -20
- package/esm/deps/jsr.io/@std/assert/1.0.16/unreachable.d.ts +0 -15
- package/esm/deps/jsr.io/@std/assert/1.0.16/unreachable.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.16/unreachable.js +0 -20
- package/esm/deps/jsr.io/@std/internal/1.0.12/build_message.d.ts +0 -80
- package/esm/deps/jsr.io/@std/internal/1.0.12/build_message.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/internal/1.0.12/build_message.js +0 -116
- package/esm/deps/jsr.io/@std/internal/1.0.12/diff.d.ts +0 -140
- package/esm/deps/jsr.io/@std/internal/1.0.12/diff.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/internal/1.0.12/diff.js +0 -276
- package/esm/deps/jsr.io/@std/internal/1.0.12/diff_str.d.ts +0 -99
- package/esm/deps/jsr.io/@std/internal/1.0.12/diff_str.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/internal/1.0.12/diff_str.js +0 -182
- package/esm/deps/jsr.io/@std/internal/1.0.12/format.d.ts +0 -29
- package/esm/deps/jsr.io/@std/internal/1.0.12/format.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/internal/1.0.12/format.js +0 -70
- package/esm/deps/jsr.io/@std/internal/1.0.12/styles.d.ts +0 -159
- package/esm/deps/jsr.io/@std/internal/1.0.12/styles.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/internal/1.0.12/styles.js +0 -207
- package/esm/deps/jsr.io/@std/internal/1.0.12/types.d.ts +0 -25
- package/esm/deps/jsr.io/@std/internal/1.0.12/types.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/internal/1.0.12/types.js +0 -3
- package/esm/message-channel.d.ts.map +0 -1
- package/esm/mod.d.ts +0 -4
- package/esm/mod.d.ts.map +0 -1
- package/esm/package.json +0 -3
- package/esm/types.d.ts.map +0 -1
- package/esm/worker-main.d.ts.map +0 -1
- package/esm/worker.d.ts.map +0 -1
- package/script/_dnt.shims.d.ts +0 -2
- package/script/_dnt.shims.d.ts.map +0 -1
- package/script/_dnt.shims.js +0 -60
- package/script/deps/jsr.io/@std/assert/1.0.16/almost_equals.d.ts +0 -29
- package/script/deps/jsr.io/@std/assert/1.0.16/almost_equals.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.16/almost_equals.js +0 -49
- package/script/deps/jsr.io/@std/assert/1.0.16/array_includes.d.ts +0 -24
- package/script/deps/jsr.io/@std/assert/1.0.16/array_includes.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.16/array_includes.js +0 -49
- package/script/deps/jsr.io/@std/assert/1.0.16/assert.d.ts +0 -16
- package/script/deps/jsr.io/@std/assert/1.0.16/assert.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.16/assert.js +0 -25
- package/script/deps/jsr.io/@std/assert/1.0.16/assertion_error.d.ts +0 -26
- package/script/deps/jsr.io/@std/assert/1.0.16/assertion_error.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.16/assertion_error.js +0 -34
- package/script/deps/jsr.io/@std/assert/1.0.16/equal.d.ts +0 -17
- package/script/deps/jsr.io/@std/assert/1.0.16/equal.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.16/equal.js +0 -222
- package/script/deps/jsr.io/@std/assert/1.0.16/equals.d.ts +0 -35
- package/script/deps/jsr.io/@std/assert/1.0.16/equals.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.16/equals.js +0 -62
- package/script/deps/jsr.io/@std/assert/1.0.16/exists.d.ts +0 -18
- package/script/deps/jsr.io/@std/assert/1.0.16/exists.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.16/exists.js +0 -30
- package/script/deps/jsr.io/@std/assert/1.0.16/fail.d.ts +0 -15
- package/script/deps/jsr.io/@std/assert/1.0.16/fail.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.16/fail.js +0 -23
- package/script/deps/jsr.io/@std/assert/1.0.16/false.d.ts +0 -18
- package/script/deps/jsr.io/@std/assert/1.0.16/false.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.16/false.js +0 -25
- package/script/deps/jsr.io/@std/assert/1.0.16/greater.d.ts +0 -20
- package/script/deps/jsr.io/@std/assert/1.0.16/greater.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.16/greater.js +0 -32
- package/script/deps/jsr.io/@std/assert/1.0.16/greater_or_equal.d.ts +0 -20
- package/script/deps/jsr.io/@std/assert/1.0.16/greater_or_equal.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.16/greater_or_equal.js +0 -32
- package/script/deps/jsr.io/@std/assert/1.0.16/instance_of.d.ts +0 -23
- package/script/deps/jsr.io/@std/assert/1.0.16/instance_of.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.16/instance_of.js +0 -55
- package/script/deps/jsr.io/@std/assert/1.0.16/is_error.d.ts +0 -25
- package/script/deps/jsr.io/@std/assert/1.0.16/is_error.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.16/is_error.js +0 -56
- package/script/deps/jsr.io/@std/assert/1.0.16/less.d.ts +0 -19
- package/script/deps/jsr.io/@std/assert/1.0.16/less.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.16/less.js +0 -31
- package/script/deps/jsr.io/@std/assert/1.0.16/less_or_equal.d.ts +0 -20
- package/script/deps/jsr.io/@std/assert/1.0.16/less_or_equal.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.16/less_or_equal.js +0 -32
- package/script/deps/jsr.io/@std/assert/1.0.16/match.d.ts +0 -18
- package/script/deps/jsr.io/@std/assert/1.0.16/match.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.16/match.js +0 -29
- package/script/deps/jsr.io/@std/assert/1.0.16/mod.d.ts +0 -44
- package/script/deps/jsr.io/@std/assert/1.0.16/mod.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.16/mod.js +0 -61
- package/script/deps/jsr.io/@std/assert/1.0.16/not_equals.d.ts +0 -21
- package/script/deps/jsr.io/@std/assert/1.0.16/not_equals.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.16/not_equals.js +0 -36
- package/script/deps/jsr.io/@std/assert/1.0.16/not_instance_of.d.ts +0 -20
- package/script/deps/jsr.io/@std/assert/1.0.16/not_instance_of.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.16/not_instance_of.js +0 -32
- package/script/deps/jsr.io/@std/assert/1.0.16/not_match.d.ts +0 -18
- package/script/deps/jsr.io/@std/assert/1.0.16/not_match.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.16/not_match.js +0 -29
- package/script/deps/jsr.io/@std/assert/1.0.16/not_strict_equals.d.ts +0 -23
- package/script/deps/jsr.io/@std/assert/1.0.16/not_strict_equals.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.16/not_strict_equals.js +0 -35
- package/script/deps/jsr.io/@std/assert/1.0.16/object_match.d.ts +0 -29
- package/script/deps/jsr.io/@std/assert/1.0.16/object_match.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.16/object_match.js +0 -170
- package/script/deps/jsr.io/@std/assert/1.0.16/rejects.d.ts +0 -42
- package/script/deps/jsr.io/@std/assert/1.0.16/rejects.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.16/rejects.js +0 -56
- package/script/deps/jsr.io/@std/assert/1.0.16/strict_equals.d.ts +0 -24
- package/script/deps/jsr.io/@std/assert/1.0.16/strict_equals.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.16/strict_equals.js +0 -61
- package/script/deps/jsr.io/@std/assert/1.0.16/string_includes.d.ts +0 -18
- package/script/deps/jsr.io/@std/assert/1.0.16/string_includes.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.16/string_includes.js +0 -29
- package/script/deps/jsr.io/@std/assert/1.0.16/throws.d.ts +0 -45
- package/script/deps/jsr.io/@std/assert/1.0.16/throws.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.16/throws.js +0 -47
- package/script/deps/jsr.io/@std/assert/1.0.16/unimplemented.d.ts +0 -15
- package/script/deps/jsr.io/@std/assert/1.0.16/unimplemented.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.16/unimplemented.js +0 -23
- package/script/deps/jsr.io/@std/assert/1.0.16/unreachable.d.ts +0 -15
- package/script/deps/jsr.io/@std/assert/1.0.16/unreachable.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.16/unreachable.js +0 -23
- package/script/deps/jsr.io/@std/internal/1.0.12/build_message.d.ts +0 -80
- package/script/deps/jsr.io/@std/internal/1.0.12/build_message.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/internal/1.0.12/build_message.js +0 -121
- package/script/deps/jsr.io/@std/internal/1.0.12/diff.d.ts +0 -140
- package/script/deps/jsr.io/@std/internal/1.0.12/diff.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/internal/1.0.12/diff.js +0 -283
- package/script/deps/jsr.io/@std/internal/1.0.12/diff_str.d.ts +0 -99
- package/script/deps/jsr.io/@std/internal/1.0.12/diff_str.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/internal/1.0.12/diff_str.js +0 -188
- package/script/deps/jsr.io/@std/internal/1.0.12/format.d.ts +0 -29
- package/script/deps/jsr.io/@std/internal/1.0.12/format.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/internal/1.0.12/format.js +0 -106
- package/script/deps/jsr.io/@std/internal/1.0.12/styles.d.ts +0 -159
- package/script/deps/jsr.io/@std/internal/1.0.12/styles.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/internal/1.0.12/styles.js +0 -252
- package/script/deps/jsr.io/@std/internal/1.0.12/types.d.ts +0 -25
- package/script/deps/jsr.io/@std/internal/1.0.12/types.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/internal/1.0.12/types.js +0 -4
- package/script/message-channel.d.ts +0 -3
- package/script/message-channel.d.ts.map +0 -1
- package/script/message-channel.js +0 -16
- package/script/mod.d.ts +0 -4
- package/script/mod.d.ts.map +0 -1
- package/script/mod.js +0 -19
- package/script/package.json +0 -3
- package/script/types.d.ts +0 -33
- package/script/types.d.ts.map +0 -1
- package/script/types.js +0 -2
- package/script/worker-main.d.ts +0 -84
- package/script/worker-main.d.ts.map +0 -1
- package/script/worker-main.js +0 -190
- package/script/worker.d.ts +0 -63
- package/script/worker.d.ts.map +0 -1
- package/script/worker.js +0 -124
- /package/{esm → dist}/message-channel.d.ts +0 -0
- /package/{esm → dist}/message-channel.js +0 -0
- /package/{esm → dist}/mod.js +0 -0
- /package/{esm → dist}/types.d.ts +0 -0
- /package/{esm → dist}/types.js +0 -0
- /package/{esm → dist}/worker.d.ts +0 -0
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
3
|
-
// This module is browser compatible.
|
|
4
|
-
// A module to print ANSI terminal colors. Inspired by chalk, kleur, and colors
|
|
5
|
-
// on npm.
|
|
6
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
-
if (k2 === undefined) k2 = k;
|
|
8
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
-
}
|
|
12
|
-
Object.defineProperty(o, k2, desc);
|
|
13
|
-
}) : (function(o, m, k, k2) {
|
|
14
|
-
if (k2 === undefined) k2 = k;
|
|
15
|
-
o[k2] = m[k];
|
|
16
|
-
}));
|
|
17
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
-
}) : function(o, v) {
|
|
20
|
-
o["default"] = v;
|
|
21
|
-
});
|
|
22
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
23
|
-
var ownKeys = function(o) {
|
|
24
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
25
|
-
var ar = [];
|
|
26
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
27
|
-
return ar;
|
|
28
|
-
};
|
|
29
|
-
return ownKeys(o);
|
|
30
|
-
};
|
|
31
|
-
return function (mod) {
|
|
32
|
-
if (mod && mod.__esModule) return mod;
|
|
33
|
-
var result = {};
|
|
34
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
35
|
-
__setModuleDefault(result, mod);
|
|
36
|
-
return result;
|
|
37
|
-
};
|
|
38
|
-
})();
|
|
39
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
-
exports.bold = bold;
|
|
41
|
-
exports.red = red;
|
|
42
|
-
exports.green = green;
|
|
43
|
-
exports.yellow = yellow;
|
|
44
|
-
exports.white = white;
|
|
45
|
-
exports.gray = gray;
|
|
46
|
-
exports.brightBlack = brightBlack;
|
|
47
|
-
exports.bgRed = bgRed;
|
|
48
|
-
exports.bgGreen = bgGreen;
|
|
49
|
-
exports.stripAnsiCode = stripAnsiCode;
|
|
50
|
-
// This code is vendored from `fmt/colors.ts`.
|
|
51
|
-
// deno-lint-ignore no-explicit-any
|
|
52
|
-
const dntShim = __importStar(require("../../../../../_dnt.shims.js"));
|
|
53
|
-
const { Deno } = dntShim.dntGlobalThis;
|
|
54
|
-
const noColor = typeof Deno?.noColor === "boolean"
|
|
55
|
-
? Deno.noColor
|
|
56
|
-
: false;
|
|
57
|
-
const enabled = !noColor;
|
|
58
|
-
function code(open, close) {
|
|
59
|
-
return {
|
|
60
|
-
open: `\x1b[${open.join(";")}m`,
|
|
61
|
-
close: `\x1b[${close}m`,
|
|
62
|
-
regexp: new RegExp(`\\x1b\\[${close}m`, "g"),
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
function run(str, code) {
|
|
66
|
-
return enabled
|
|
67
|
-
? `${code.open}${str.replace(code.regexp, code.open)}${code.close}`
|
|
68
|
-
: str;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Sets the style of text to be printed to bold.
|
|
72
|
-
*
|
|
73
|
-
* Disable by setting the `NO_COLOR` environmental variable.
|
|
74
|
-
*
|
|
75
|
-
* @param str Text to make bold
|
|
76
|
-
*
|
|
77
|
-
* @returns Bold text for printing
|
|
78
|
-
*
|
|
79
|
-
* @example Usage
|
|
80
|
-
* ```ts no-assert
|
|
81
|
-
* import { bold } from "@std/internal/styles";
|
|
82
|
-
*
|
|
83
|
-
* console.log(bold("Hello, world!")); // Prints "Hello, world!" in bold
|
|
84
|
-
* ```
|
|
85
|
-
*/
|
|
86
|
-
function bold(str) {
|
|
87
|
-
return run(str, code([1], 22));
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Sets the color of text to be printed to red.
|
|
91
|
-
*
|
|
92
|
-
* Disable by setting the `NO_COLOR` environmental variable.
|
|
93
|
-
*
|
|
94
|
-
* @param str Text to make red
|
|
95
|
-
*
|
|
96
|
-
* @returns Red text for printing
|
|
97
|
-
*
|
|
98
|
-
* @example Usage
|
|
99
|
-
* ```ts no-assert
|
|
100
|
-
* import { red } from "@std/internal/styles";
|
|
101
|
-
*
|
|
102
|
-
* console.log(red("Hello, world!")); // Prints "Hello, world!" in red
|
|
103
|
-
* ```
|
|
104
|
-
*/
|
|
105
|
-
function red(str) {
|
|
106
|
-
return run(str, code([31], 39));
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Sets the color of text to be printed to green.
|
|
110
|
-
*
|
|
111
|
-
* Disable by setting the `NO_COLOR` environmental variable.
|
|
112
|
-
*
|
|
113
|
-
* @param str Text to make green
|
|
114
|
-
*
|
|
115
|
-
* @returns Green text for print
|
|
116
|
-
*
|
|
117
|
-
* @example Usage
|
|
118
|
-
* ```ts no-assert
|
|
119
|
-
* import { green } from "@std/internal/styles";
|
|
120
|
-
*
|
|
121
|
-
* console.log(green("Hello, world!")); // Prints "Hello, world!" in green
|
|
122
|
-
* ```
|
|
123
|
-
*/
|
|
124
|
-
function green(str) {
|
|
125
|
-
return run(str, code([32], 39));
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Sets the color of text to be printed to yellow.
|
|
129
|
-
*
|
|
130
|
-
* Disable by setting the `NO_COLOR` environmental variable.
|
|
131
|
-
*
|
|
132
|
-
* @param str Text to make yellow
|
|
133
|
-
*
|
|
134
|
-
* @returns Yellow text for print
|
|
135
|
-
*
|
|
136
|
-
* @example Usage
|
|
137
|
-
* ```ts no-assert
|
|
138
|
-
* import { yellow } from "@std/internal/styles";
|
|
139
|
-
*
|
|
140
|
-
* console.log(yellow("Hello, world!")); // Prints "Hello, world!" in yellow
|
|
141
|
-
* ```
|
|
142
|
-
*/
|
|
143
|
-
function yellow(str) {
|
|
144
|
-
return run(str, code([33], 39));
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Sets the color of text to be printed to white.
|
|
148
|
-
*
|
|
149
|
-
* @param str Text to make white
|
|
150
|
-
*
|
|
151
|
-
* @returns White text for print
|
|
152
|
-
*
|
|
153
|
-
* @example Usage
|
|
154
|
-
* ```ts no-assert
|
|
155
|
-
* import { white } from "@std/internal/styles";
|
|
156
|
-
*
|
|
157
|
-
* console.log(white("Hello, world!")); // Prints "Hello, world!" in white
|
|
158
|
-
* ```
|
|
159
|
-
*/
|
|
160
|
-
function white(str) {
|
|
161
|
-
return run(str, code([37], 39));
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Sets the color of text to be printed to gray.
|
|
165
|
-
*
|
|
166
|
-
* @param str Text to make gray
|
|
167
|
-
*
|
|
168
|
-
* @returns Gray text for print
|
|
169
|
-
*
|
|
170
|
-
* @example Usage
|
|
171
|
-
* ```ts no-assert
|
|
172
|
-
* import { gray } from "@std/internal/styles";
|
|
173
|
-
*
|
|
174
|
-
* console.log(gray("Hello, world!")); // Prints "Hello, world!" in gray
|
|
175
|
-
* ```
|
|
176
|
-
*/
|
|
177
|
-
function gray(str) {
|
|
178
|
-
return brightBlack(str);
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* Sets the color of text to be printed to bright-black.
|
|
182
|
-
*
|
|
183
|
-
* @param str Text to make bright-black
|
|
184
|
-
*
|
|
185
|
-
* @returns Bright-black text for print
|
|
186
|
-
*
|
|
187
|
-
* @example Usage
|
|
188
|
-
* ```ts no-assert
|
|
189
|
-
* import { brightBlack } from "@std/internal/styles";
|
|
190
|
-
*
|
|
191
|
-
* console.log(brightBlack("Hello, world!")); // Prints "Hello, world!" in bright-black
|
|
192
|
-
* ```
|
|
193
|
-
*/
|
|
194
|
-
function brightBlack(str) {
|
|
195
|
-
return run(str, code([90], 39));
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* Sets the background color of text to be printed to red.
|
|
199
|
-
*
|
|
200
|
-
* @param str Text to make its background red
|
|
201
|
-
*
|
|
202
|
-
* @returns Red background text for print
|
|
203
|
-
*
|
|
204
|
-
* @example Usage
|
|
205
|
-
* ```ts no-assert
|
|
206
|
-
* import { bgRed } from "@std/internal/styles";
|
|
207
|
-
*
|
|
208
|
-
* console.log(bgRed("Hello, world!")); // Prints "Hello, world!" with red background
|
|
209
|
-
* ```
|
|
210
|
-
*/
|
|
211
|
-
function bgRed(str) {
|
|
212
|
-
return run(str, code([41], 49));
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* Sets the background color of text to be printed to green.
|
|
216
|
-
*
|
|
217
|
-
* @param str Text to make its background green
|
|
218
|
-
*
|
|
219
|
-
* @returns Green background text for print
|
|
220
|
-
*
|
|
221
|
-
* @example Usage
|
|
222
|
-
* ```ts no-assert
|
|
223
|
-
* import { bgGreen } from "@std/internal/styles";
|
|
224
|
-
*
|
|
225
|
-
* console.log(bgGreen("Hello, world!")); // Prints "Hello, world!" with green background
|
|
226
|
-
* ```
|
|
227
|
-
*/
|
|
228
|
-
function bgGreen(str) {
|
|
229
|
-
return run(str, code([42], 49));
|
|
230
|
-
}
|
|
231
|
-
// https://github.com/chalk/ansi-regex/blob/02fa893d619d3da85411acc8fd4e2eea0e95a9d9/index.js
|
|
232
|
-
const ANSI_PATTERN = new RegExp([
|
|
233
|
-
"[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
|
|
234
|
-
"(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TXZcf-nq-uy=><~]))",
|
|
235
|
-
].join("|"), "g");
|
|
236
|
-
/**
|
|
237
|
-
* Remove ANSI escape codes from the string.
|
|
238
|
-
*
|
|
239
|
-
* @param string Text to remove ANSI escape codes from
|
|
240
|
-
*
|
|
241
|
-
* @returns Text without ANSI escape codes
|
|
242
|
-
*
|
|
243
|
-
* @example Usage
|
|
244
|
-
* ```ts no-assert
|
|
245
|
-
* import { red, stripAnsiCode } from "@std/internal/styles";
|
|
246
|
-
*
|
|
247
|
-
* console.log(stripAnsiCode(red("Hello, world!"))); // Prints "Hello, world!"
|
|
248
|
-
* ```
|
|
249
|
-
*/
|
|
250
|
-
function stripAnsiCode(string) {
|
|
251
|
-
return string.replace(ANSI_PATTERN, "");
|
|
252
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/** Ways that lines in a diff can be different. */
|
|
2
|
-
export type DiffType = DiffResult<unknown>["type"];
|
|
3
|
-
/**
|
|
4
|
-
* Represents the result of a diff operation.
|
|
5
|
-
* @typeParam T The type of the value in the diff result.
|
|
6
|
-
*/
|
|
7
|
-
export type DiffResult<T> = ChangedDiffResult<T> | CommonDiffResult<T>;
|
|
8
|
-
/**
|
|
9
|
-
* Represents the result of a common diff operation.
|
|
10
|
-
* @typeParam T The type of the value in the diff result.
|
|
11
|
-
*/
|
|
12
|
-
export type CommonDiffResult<T> = {
|
|
13
|
-
type: "common" | "truncation";
|
|
14
|
-
value: T;
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* Represents the result of a changed diff operation.
|
|
18
|
-
* @typeParam T The type of the value in the diff result.
|
|
19
|
-
*/
|
|
20
|
-
export type ChangedDiffResult<T> = {
|
|
21
|
-
type: "removed" | "added";
|
|
22
|
-
value: T;
|
|
23
|
-
details?: DiffResult<T>[];
|
|
24
|
-
};
|
|
25
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/internal/1.0.12/types.ts"],"names":[],"mappings":"AAGA,kDAAkD;AAClD,MAAM,MAAM,QAAQ,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC;AAEnD;;;GAGG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI,iBAAiB,CAAC,CAAC,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC;AAEvE;;;GAGG;AACH,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI;IAChC,IAAI,EAAE,QAAQ,GAAG,YAAY,CAAC;IAC9B,KAAK,EAAE,CAAC,CAAC;CACV,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC;IAC1B,KAAK,EAAE,CAAC,CAAC;IACT,OAAO,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC;CAC3B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"message-channel.d.ts","sourceRoot":"","sources":["../src/message-channel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAY,MAAM,WAAW,CAAC;AAErD,wBAAgB,iBAAiB,IAAI,SAAS,CAAC,cAAc,CAAC,CAU7D"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useMessageChannel = useMessageChannel;
|
|
4
|
-
const effection_1 = require("effection");
|
|
5
|
-
function useMessageChannel() {
|
|
6
|
-
return (0, effection_1.resource)(function* (provide) {
|
|
7
|
-
let channel = new MessageChannel();
|
|
8
|
-
try {
|
|
9
|
-
yield* provide(channel);
|
|
10
|
-
}
|
|
11
|
-
finally {
|
|
12
|
-
channel.port1.close();
|
|
13
|
-
channel.port2.close();
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
}
|
package/script/mod.d.ts
DELETED
package/script/mod.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC"}
|
package/script/mod.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./worker.js"), exports);
|
|
18
|
-
__exportStar(require("./worker-main.js"), exports);
|
|
19
|
-
__exportStar(require("./types.js"), exports);
|
package/script/package.json
DELETED
package/script/types.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { Operation } from "effection";
|
|
2
|
-
export type WorkerControl<TSend, TData> = {
|
|
3
|
-
type: "init";
|
|
4
|
-
data: TData;
|
|
5
|
-
} | {
|
|
6
|
-
type: "send";
|
|
7
|
-
value: TSend;
|
|
8
|
-
response: MessagePort;
|
|
9
|
-
} | {
|
|
10
|
-
type: "close";
|
|
11
|
-
};
|
|
12
|
-
export interface WorkerMainOptions<TSend, TRecv, TData> {
|
|
13
|
-
/**
|
|
14
|
-
* Namespace that provides APIs for working with incoming messages
|
|
15
|
-
*/
|
|
16
|
-
messages: WorkerMessages<TSend, TRecv>;
|
|
17
|
-
/**
|
|
18
|
-
* Initial data received by the worker from the main thread used for initialization.
|
|
19
|
-
*/
|
|
20
|
-
data: TData;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Object that represents messages the main thread
|
|
24
|
-
* sends to the worker. It provides function for
|
|
25
|
-
* handling messages.
|
|
26
|
-
*
|
|
27
|
-
* @template TSend - value main thread will send to the worker
|
|
28
|
-
* @template TRecv - value main thread will receive from the worker
|
|
29
|
-
*/
|
|
30
|
-
export interface WorkerMessages<TSend, TRecv> {
|
|
31
|
-
forEach(fn: (message: TSend) => Operation<TRecv>): Operation<void>;
|
|
32
|
-
}
|
|
33
|
-
//# sourceMappingURL=types.d.ts.map
|
package/script/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C,MAAM,MAAM,aAAa,CAAC,KAAK,EAAE,KAAK,IAAI;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,KAAK,CAAC;CACb,GAAG;IACF,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,EAAE,WAAW,CAAC;CACvB,GAAG;IACF,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAEF,MAAM,WAAW,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK;IACpD;;OAEG;IACH,QAAQ,EAAE,cAAc,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACvC;;OAEG;IACH,IAAI,EAAE,KAAK,CAAC;CACb;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,cAAc,CAAC,KAAK,EAAE,KAAK;IAC1C,OAAO,CAAC,EAAE,EAAE,CAAC,OAAO,EAAE,KAAK,KAAK,SAAS,CAAC,KAAK,CAAC,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;CACpE"}
|
package/script/types.js
DELETED
package/script/worker-main.d.ts
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/script/worker-main.js
DELETED
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.workerMain = workerMain;
|
|
4
|
-
exports.createWorkerStatesSignal = createWorkerStatesSignal;
|
|
5
|
-
const effection_1 = require("effection");
|
|
6
|
-
/**
|
|
7
|
-
* Entrypoint used in the worker that estaliblishes communication
|
|
8
|
-
* with the main thread. It can be used to return a value,
|
|
9
|
-
* respond to messages or both.
|
|
10
|
-
*
|
|
11
|
-
* @example Returning a value
|
|
12
|
-
* ```ts
|
|
13
|
-
* import { workerMain } from "../worker.ts";
|
|
14
|
-
*
|
|
15
|
-
* await workerMain(function* ({ data }) {
|
|
16
|
-
* return data;
|
|
17
|
-
* });
|
|
18
|
-
* ```
|
|
19
|
-
*
|
|
20
|
-
* @example Responding to messages
|
|
21
|
-
* ```ts
|
|
22
|
-
* import { workerMain } from "../worker.ts";
|
|
23
|
-
*
|
|
24
|
-
* await workerMain(function* ({ messages }) {
|
|
25
|
-
* yield* messages.forEach(function* (message) {
|
|
26
|
-
* return message;
|
|
27
|
-
* });
|
|
28
|
-
* });
|
|
29
|
-
* ```
|
|
30
|
-
*
|
|
31
|
-
* @example Responding to messages and return a value
|
|
32
|
-
* ```ts
|
|
33
|
-
* import { workerMain } from "../worker.ts";
|
|
34
|
-
*
|
|
35
|
-
* await workerMain<number, number, number, number>(
|
|
36
|
-
* function* ({ messages, data: initial }) {
|
|
37
|
-
* let counter = initial;
|
|
38
|
-
*
|
|
39
|
-
* yield* messages.forEach(function* (message) {
|
|
40
|
-
* counter += message;
|
|
41
|
-
* return counter; // returns a value after each message
|
|
42
|
-
* });
|
|
43
|
-
*
|
|
44
|
-
* return counter; // returns the final value
|
|
45
|
-
* },
|
|
46
|
-
* );
|
|
47
|
-
* ```
|
|
48
|
-
*
|
|
49
|
-
* @template TSend - value main thread will send to the worker
|
|
50
|
-
* @template TRecv - value main thread will receive from the worker
|
|
51
|
-
* @template TReturn - worker operation return value
|
|
52
|
-
* @template TData - data passed from the main thread to the worker during initialization
|
|
53
|
-
* @param {(options: WorkerMainOptions<TSend, TRecv, TData>) => Operation<TReturn>} body
|
|
54
|
-
* @returns {Promise<void>}
|
|
55
|
-
*/
|
|
56
|
-
async function workerMain(body) {
|
|
57
|
-
await (0, effection_1.main)(function* () {
|
|
58
|
-
let sent = (0, effection_1.createSignal)();
|
|
59
|
-
let worker = yield* createWorkerStatesSignal();
|
|
60
|
-
yield* (0, effection_1.spawn)(function* () {
|
|
61
|
-
for (const message of yield* (0, effection_1.each)((0, effection_1.on)(self, "message"))) {
|
|
62
|
-
const control = message.data;
|
|
63
|
-
switch (control.type) {
|
|
64
|
-
case "init": {
|
|
65
|
-
worker.start(yield* (0, effection_1.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* (0, effection_1.each)(sent)) {
|
|
72
|
-
yield* (0, effection_1.spawn)(function* () {
|
|
73
|
-
try {
|
|
74
|
-
let result = yield* fn(value);
|
|
75
|
-
response.postMessage((0, effection_1.Ok)(result));
|
|
76
|
-
}
|
|
77
|
-
catch (error) {
|
|
78
|
-
response.postMessage((0, effection_1.Err)(error));
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
yield* effection_1.each.next();
|
|
82
|
-
}
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
});
|
|
86
|
-
worker.complete(value);
|
|
87
|
-
}
|
|
88
|
-
catch (error) {
|
|
89
|
-
worker.crash(error);
|
|
90
|
-
}
|
|
91
|
-
}));
|
|
92
|
-
break;
|
|
93
|
-
}
|
|
94
|
-
case "send": {
|
|
95
|
-
let { value, response } = control;
|
|
96
|
-
sent.send({ value, response });
|
|
97
|
-
break;
|
|
98
|
-
}
|
|
99
|
-
case "close": {
|
|
100
|
-
const current = worker.valueOf();
|
|
101
|
-
if (current.type === "running") {
|
|
102
|
-
yield* current.task.halt();
|
|
103
|
-
worker.interrupt();
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
yield* effection_1.each.next();
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
for (const state of yield* (0, effection_1.each)(worker)) {
|
|
111
|
-
if (state.type === "new") {
|
|
112
|
-
postMessage({ type: "open" });
|
|
113
|
-
}
|
|
114
|
-
else if (state.type === "interrupted" || state.type === "error") {
|
|
115
|
-
postMessage({ type: "close", result: (0, effection_1.Err)(state.error) });
|
|
116
|
-
}
|
|
117
|
-
else if (state.type === "complete") {
|
|
118
|
-
postMessage({ type: "close", result: (0, effection_1.Ok)(state.value) });
|
|
119
|
-
}
|
|
120
|
-
yield* effection_1.each.next();
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
function createWorkerStatesSignal() {
|
|
125
|
-
return (0, effection_1.resource)(function* (provide) {
|
|
126
|
-
let ref = {
|
|
127
|
-
current: { type: "new" },
|
|
128
|
-
};
|
|
129
|
-
const signal = (0, effection_1.createSignal)();
|
|
130
|
-
const set = (value) => {
|
|
131
|
-
signal.send(ref.current = value);
|
|
132
|
-
return value;
|
|
133
|
-
};
|
|
134
|
-
const update = (updater) => set(updater(ref.current));
|
|
135
|
-
const interrupt = () => {
|
|
136
|
-
let next = {
|
|
137
|
-
type: "interrupted",
|
|
138
|
-
error: new Error(`worker terminated`),
|
|
139
|
-
};
|
|
140
|
-
set(next);
|
|
141
|
-
return next;
|
|
142
|
-
};
|
|
143
|
-
try {
|
|
144
|
-
yield* provide({
|
|
145
|
-
*[Symbol.iterator]() {
|
|
146
|
-
let subscription = yield* signal;
|
|
147
|
-
signal.send(ref.current);
|
|
148
|
-
return subscription;
|
|
149
|
-
},
|
|
150
|
-
get state() {
|
|
151
|
-
return ref.current.type;
|
|
152
|
-
},
|
|
153
|
-
set,
|
|
154
|
-
update,
|
|
155
|
-
valueOf() {
|
|
156
|
-
return ref.current;
|
|
157
|
-
},
|
|
158
|
-
start(task) {
|
|
159
|
-
if (ref.current.type === "complete") {
|
|
160
|
-
return ref.current;
|
|
161
|
-
}
|
|
162
|
-
else {
|
|
163
|
-
const next = { type: "running", task };
|
|
164
|
-
set(next);
|
|
165
|
-
return next;
|
|
166
|
-
}
|
|
167
|
-
},
|
|
168
|
-
complete(value) {
|
|
169
|
-
let next = { type: "complete", value };
|
|
170
|
-
set(next);
|
|
171
|
-
return next;
|
|
172
|
-
},
|
|
173
|
-
crash(error) {
|
|
174
|
-
let next = { type: "error", error };
|
|
175
|
-
set(next);
|
|
176
|
-
return next;
|
|
177
|
-
},
|
|
178
|
-
interrupt: interrupt,
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
finally {
|
|
182
|
-
if (ref.current.type === "running") {
|
|
183
|
-
interrupt();
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
function postMessage(message) {
|
|
189
|
-
self.postMessage(message);
|
|
190
|
-
}
|