| 1 | "use strict";
|
|---|
| 2 |
|
|---|
| 3 | function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|---|
| 4 | function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|---|
| 5 | const babel = require("./babel-core.cjs");
|
|---|
| 6 | const handleMessage = require("./handle-message.cjs");
|
|---|
| 7 | const worker_threads = require("worker_threads");
|
|---|
| 8 | worker_threads.parentPort.addListener("message", _asyncToGenerator(function* ({
|
|---|
| 9 | signal,
|
|---|
| 10 | port,
|
|---|
| 11 | action,
|
|---|
| 12 | payload
|
|---|
| 13 | }) {
|
|---|
| 14 | let response;
|
|---|
| 15 | try {
|
|---|
| 16 | if (babel.init) yield babel.init;
|
|---|
| 17 | response = {
|
|---|
| 18 | result: yield handleMessage(action, payload)
|
|---|
| 19 | };
|
|---|
| 20 | } catch (error) {
|
|---|
| 21 | response = {
|
|---|
| 22 | error,
|
|---|
| 23 | errorData: Object.assign({}, error)
|
|---|
| 24 | };
|
|---|
| 25 | }
|
|---|
| 26 | try {
|
|---|
| 27 | port.postMessage(response);
|
|---|
| 28 | } catch (_unused) {
|
|---|
| 29 | port.postMessage({
|
|---|
| 30 | error: new Error("Cannot serialize worker response")
|
|---|
| 31 | });
|
|---|
| 32 | } finally {
|
|---|
| 33 | port.close();
|
|---|
| 34 | Atomics.store(signal, 0, 1);
|
|---|
| 35 | Atomics.notify(signal, 0);
|
|---|
| 36 | }
|
|---|
| 37 | }));
|
|---|
| 38 |
|
|---|
| 39 | //# sourceMappingURL=index.cjs.map
|
|---|