@eggjs/mock 6.1.0-beta.9 → 7.0.0-beta.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/README.zh_CN.md +1 -1
- package/dist/_virtual/rolldown_runtime.js +1 -24
- package/dist/inject_mocha.d.ts +1 -1
- package/dist/inject_mocha.js +2 -3
- package/dist/lib/context.js +1 -3
- package/package.json +8 -11
- package/dist/node_modules/.pnpm/ansi-styles@4.3.0/node_modules/ansi-styles/index.js +0 -142
- package/dist/node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/index.js +0 -157
- package/dist/node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/templates.js +0 -97
- package/dist/node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/util.js +0 -40
- package/dist/node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/conversions.js +0 -814
- package/dist/node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/index.js +0 -50
- package/dist/node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/route.js +0 -68
- package/dist/node_modules/.pnpm/color-name@1.1.4/node_modules/color-name/index.js +0 -752
- package/dist/node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/browser.js +0 -203
- package/dist/node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/common.js +0 -209
- package/dist/node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/index.js +0 -18
- package/dist/node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/node.js +0 -215
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/convert/dmp.js +0 -24
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/convert/xml.js +0 -33
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/array.js +0 -29
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/base.js +0 -185
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/character.js +0 -23
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/css.js +0 -26
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/json.js +0 -83
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/line.js +0 -51
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/sentence.js +0 -26
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/word.js +0 -151
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/index.js +0 -178
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/apply.js +0 -168
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/create.js +0 -301
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/line-endings.js +0 -137
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/merge.js +0 -367
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/parse.js +0 -91
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/reverse.js +0 -99
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/util/array.js +0 -23
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/util/distance-iterator.js +0 -30
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/util/params.js +0 -22
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/util/string.js +0 -97
- package/dist/node_modules/.pnpm/escape-string-regexp@4.0.0/node_modules/escape-string-regexp/index.js +0 -14
- package/dist/node_modules/.pnpm/has-flag@4.0.0/node_modules/has-flag/index.js +0 -16
- package/dist/node_modules/.pnpm/he@1.2.0/node_modules/he/he.js +0 -4093
- package/dist/node_modules/.pnpm/is-unicode-supported@0.1.0/node_modules/is-unicode-supported/index.js +0 -14
- package/dist/node_modules/.pnpm/log-symbols@4.1.0/node_modules/log-symbols/index.js +0 -27
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/index.js +0 -12
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/context.js +0 -83
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/error-constants.js +0 -35
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/errors.js +0 -392
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/hook.js +0 -86
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/bdd.js +0 -104
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/common.js +0 -99
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/exports.js +0 -65
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/index.js +0 -18
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/qunit.js +0 -95
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/tdd.js +0 -105
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/mocha.js +0 -1037
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/mocharc.js +0 -24
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/buffered-worker-pool.js +0 -152
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/esm-utils.js +0 -74
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/file-unloader.js +0 -22
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/parallel-buffered-runner.js +0 -329
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/serializer.js +0 -314
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/pending.js +0 -22
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/base.js +0 -417
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/doc.js +0 -79
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/dot.js +0 -75
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/html.js +0 -283
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/index.js +0 -40
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/json-stream.js +0 -90
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/json.js +0 -145
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/landing.js +0 -107
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/list.js +0 -77
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/markdown.js +0 -106
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/min.js +0 -57
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/nyan.js +0 -233
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/progress.js +0 -92
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/spec.js +0 -91
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/tap.js +0 -261
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/xunit.js +0 -166
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/runnable.js +0 -346
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/runner.js +0 -922
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/stats-collector.js +0 -72
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/suite.js +0 -517
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/test.js +0 -105
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/utils.js +0 -505
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/package.js +0 -225
- package/dist/node_modules/.pnpm/ms@2.1.3/node_modules/ms/index.js +0 -124
- package/dist/node_modules/.pnpm/randombytes@2.1.0/node_modules/randombytes/index.js +0 -11
- package/dist/node_modules/.pnpm/serialize-javascript@6.0.2/node_modules/serialize-javascript/index.js +0 -114
- package/dist/node_modules/.pnpm/supports-color@7.2.0/node_modules/supports-color/index.js +0 -76
- package/dist/node_modules/.pnpm/supports-color@8.1.1/node_modules/supports-color/index.js +0 -89
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/Pool.js +0 -366
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/Promise.js +0 -248
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/WorkerHandler.js +0 -419
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/debug-port-allocator.js +0 -27
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/environment.js +0 -18
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/generated/embeddedWorker.js +0 -16
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/index.js +0 -63
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/transfer.js +0 -21
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/validateOptions.js +0 -9
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/worker.js +0 -277
|
@@ -1,277 +0,0 @@
|
|
|
1
|
-
import { __commonJS, __require } from "../../../../../../_virtual/rolldown_runtime.js";
|
|
2
|
-
import { require_Promise } from "./Promise.js";
|
|
3
|
-
import { require_transfer } from "./transfer.js";
|
|
4
|
-
|
|
5
|
-
//#region ../../node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/worker.js
|
|
6
|
-
var require_worker = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/worker.js": ((exports) => {
|
|
7
|
-
/**
|
|
8
|
-
* worker must be started as a child process or a web worker.
|
|
9
|
-
* It listens for RPC messages from the parent process.
|
|
10
|
-
*/
|
|
11
|
-
var Transfer = require_transfer();
|
|
12
|
-
/**
|
|
13
|
-
* worker must handle async cleanup handlers. Use custom Promise implementation.
|
|
14
|
-
*/
|
|
15
|
-
var Promise$1 = require_Promise().Promise;
|
|
16
|
-
/**
|
|
17
|
-
* Special message sent by parent which causes the worker to terminate itself.
|
|
18
|
-
* Not a "message object"; this string is the entire message.
|
|
19
|
-
*/
|
|
20
|
-
var TERMINATE_METHOD_ID = "__workerpool-terminate__";
|
|
21
|
-
/**
|
|
22
|
-
* Special message by parent which causes a child process worker to perform cleaup
|
|
23
|
-
* steps before determining if the child process worker should be terminated.
|
|
24
|
-
*/
|
|
25
|
-
var CLEANUP_METHOD_ID = "__workerpool-cleanup__";
|
|
26
|
-
var TIMEOUT_DEFAULT = 1e3;
|
|
27
|
-
var worker = { exit: function() {} };
|
|
28
|
-
var publicWorker = {
|
|
29
|
-
addAbortListener: function(listener) {
|
|
30
|
-
worker.abortListeners.push(listener);
|
|
31
|
-
},
|
|
32
|
-
emit: worker.emit
|
|
33
|
-
};
|
|
34
|
-
if (typeof self !== "undefined" && typeof postMessage === "function" && typeof addEventListener === "function") {
|
|
35
|
-
worker.on = function(event, callback) {
|
|
36
|
-
addEventListener(event, function(message) {
|
|
37
|
-
callback(message.data);
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
worker.send = function(message, transfer) {
|
|
41
|
-
transfer ? postMessage(message, transfer) : postMessage(message);
|
|
42
|
-
};
|
|
43
|
-
} else if (typeof process !== "undefined") {
|
|
44
|
-
var WorkerThreads;
|
|
45
|
-
try {
|
|
46
|
-
WorkerThreads = __require("worker_threads");
|
|
47
|
-
} catch (error) {
|
|
48
|
-
if (typeof error === "object" && error !== null && error.code === "MODULE_NOT_FOUND") {} else throw error;
|
|
49
|
-
}
|
|
50
|
-
if (WorkerThreads && WorkerThreads.parentPort !== null) {
|
|
51
|
-
var parentPort = WorkerThreads.parentPort;
|
|
52
|
-
worker.send = parentPort.postMessage.bind(parentPort);
|
|
53
|
-
worker.on = parentPort.on.bind(parentPort);
|
|
54
|
-
worker.exit = process.exit.bind(process);
|
|
55
|
-
} else {
|
|
56
|
-
worker.on = process.on.bind(process);
|
|
57
|
-
worker.send = function(message) {
|
|
58
|
-
process.send(message);
|
|
59
|
-
};
|
|
60
|
-
worker.on("disconnect", function() {
|
|
61
|
-
process.exit(1);
|
|
62
|
-
});
|
|
63
|
-
worker.exit = process.exit.bind(process);
|
|
64
|
-
}
|
|
65
|
-
} else throw new Error("Script must be executed as a worker");
|
|
66
|
-
function convertError(error) {
|
|
67
|
-
if (error && error.toJSON) return JSON.parse(JSON.stringify(error));
|
|
68
|
-
return JSON.parse(JSON.stringify(error, Object.getOwnPropertyNames(error)));
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Test whether a value is a Promise via duck typing.
|
|
72
|
-
* @param {*} value
|
|
73
|
-
* @returns {boolean} Returns true when given value is an object
|
|
74
|
-
* having functions `then` and `catch`.
|
|
75
|
-
*/
|
|
76
|
-
function isPromise(value) {
|
|
77
|
-
return value && typeof value.then === "function" && typeof value.catch === "function";
|
|
78
|
-
}
|
|
79
|
-
worker.methods = {};
|
|
80
|
-
/**
|
|
81
|
-
* Execute a function with provided arguments
|
|
82
|
-
* @param {String} fn Stringified function
|
|
83
|
-
* @param {Array} [args] Function arguments
|
|
84
|
-
* @returns {*}
|
|
85
|
-
*/
|
|
86
|
-
worker.methods.run = function run(fn, args) {
|
|
87
|
-
var f = new Function("return (" + fn + ").apply(this, arguments);");
|
|
88
|
-
f.worker = publicWorker;
|
|
89
|
-
return f.apply(f, args);
|
|
90
|
-
};
|
|
91
|
-
/**
|
|
92
|
-
* Get a list with methods available on this worker
|
|
93
|
-
* @return {String[]} methods
|
|
94
|
-
*/
|
|
95
|
-
worker.methods.methods = function methods() {
|
|
96
|
-
return Object.keys(worker.methods);
|
|
97
|
-
};
|
|
98
|
-
/**
|
|
99
|
-
* Custom handler for when the worker is terminated.
|
|
100
|
-
*/
|
|
101
|
-
worker.terminationHandler = void 0;
|
|
102
|
-
worker.abortListenerTimeout = TIMEOUT_DEFAULT;
|
|
103
|
-
/**
|
|
104
|
-
* Abort handlers for resolving errors which may cause a timeout or cancellation
|
|
105
|
-
* to occur from a worker context
|
|
106
|
-
*/
|
|
107
|
-
worker.abortListeners = [];
|
|
108
|
-
/**
|
|
109
|
-
* Cleanup and exit the worker.
|
|
110
|
-
* @param {Number} code
|
|
111
|
-
* @returns {Promise<void>}
|
|
112
|
-
*/
|
|
113
|
-
worker.terminateAndExit = function(code) {
|
|
114
|
-
var _exit = function() {
|
|
115
|
-
worker.exit(code);
|
|
116
|
-
};
|
|
117
|
-
if (!worker.terminationHandler) return _exit();
|
|
118
|
-
var result = worker.terminationHandler(code);
|
|
119
|
-
if (isPromise(result)) {
|
|
120
|
-
result.then(_exit, _exit);
|
|
121
|
-
return result;
|
|
122
|
-
} else {
|
|
123
|
-
_exit();
|
|
124
|
-
return new Promise$1(function(_resolve, reject) {
|
|
125
|
-
reject(/* @__PURE__ */ new Error("Worker terminating"));
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
/**
|
|
130
|
-
* Called within the worker message handler to run abort handlers if registered to perform cleanup operations.
|
|
131
|
-
* @param {Integer} [requestId] id of task which is currently executing in the worker
|
|
132
|
-
* @return {Promise<void>}
|
|
133
|
-
*/
|
|
134
|
-
worker.cleanup = function(requestId) {
|
|
135
|
-
if (!worker.abortListeners.length) {
|
|
136
|
-
worker.send({
|
|
137
|
-
id: requestId,
|
|
138
|
-
method: CLEANUP_METHOD_ID,
|
|
139
|
-
error: convertError(/* @__PURE__ */ new Error("Worker terminating"))
|
|
140
|
-
});
|
|
141
|
-
return new Promise$1(function(resolve) {
|
|
142
|
-
resolve();
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
var _exit = function() {
|
|
146
|
-
worker.exit();
|
|
147
|
-
};
|
|
148
|
-
var _abort = function() {
|
|
149
|
-
if (!worker.abortListeners.length) worker.abortListeners = [];
|
|
150
|
-
};
|
|
151
|
-
const promises = worker.abortListeners.map((listener) => listener());
|
|
152
|
-
let timerId;
|
|
153
|
-
const timeoutPromise = new Promise$1((_resolve, reject) => {
|
|
154
|
-
timerId = setTimeout(function() {
|
|
155
|
-
reject(/* @__PURE__ */ new Error("Timeout occured waiting for abort handler, killing worker"));
|
|
156
|
-
}, worker.abortListenerTimeout);
|
|
157
|
-
});
|
|
158
|
-
const settlePromise = Promise$1.all(promises).then(function() {
|
|
159
|
-
clearTimeout(timerId);
|
|
160
|
-
_abort();
|
|
161
|
-
}, function() {
|
|
162
|
-
clearTimeout(timerId);
|
|
163
|
-
_exit();
|
|
164
|
-
});
|
|
165
|
-
return new Promise$1(function(resolve, reject) {
|
|
166
|
-
settlePromise.then(resolve, reject);
|
|
167
|
-
timeoutPromise.then(resolve, reject);
|
|
168
|
-
}).then(function() {
|
|
169
|
-
worker.send({
|
|
170
|
-
id: requestId,
|
|
171
|
-
method: CLEANUP_METHOD_ID,
|
|
172
|
-
error: null
|
|
173
|
-
});
|
|
174
|
-
}, function(err) {
|
|
175
|
-
worker.send({
|
|
176
|
-
id: requestId,
|
|
177
|
-
method: CLEANUP_METHOD_ID,
|
|
178
|
-
error: err ? convertError(err) : null
|
|
179
|
-
});
|
|
180
|
-
});
|
|
181
|
-
};
|
|
182
|
-
var currentRequestId = null;
|
|
183
|
-
worker.on("message", function(request) {
|
|
184
|
-
if (request === TERMINATE_METHOD_ID) return worker.terminateAndExit(0);
|
|
185
|
-
if (request.method === CLEANUP_METHOD_ID) return worker.cleanup(request.id);
|
|
186
|
-
try {
|
|
187
|
-
var method = worker.methods[request.method];
|
|
188
|
-
if (method) {
|
|
189
|
-
currentRequestId = request.id;
|
|
190
|
-
var result = method.apply(method, request.params);
|
|
191
|
-
if (isPromise(result)) result.then(function(result$1) {
|
|
192
|
-
if (result$1 instanceof Transfer) worker.send({
|
|
193
|
-
id: request.id,
|
|
194
|
-
result: result$1.message,
|
|
195
|
-
error: null
|
|
196
|
-
}, result$1.transfer);
|
|
197
|
-
else worker.send({
|
|
198
|
-
id: request.id,
|
|
199
|
-
result: result$1,
|
|
200
|
-
error: null
|
|
201
|
-
});
|
|
202
|
-
currentRequestId = null;
|
|
203
|
-
}).catch(function(err) {
|
|
204
|
-
worker.send({
|
|
205
|
-
id: request.id,
|
|
206
|
-
result: null,
|
|
207
|
-
error: convertError(err)
|
|
208
|
-
});
|
|
209
|
-
currentRequestId = null;
|
|
210
|
-
});
|
|
211
|
-
else {
|
|
212
|
-
if (result instanceof Transfer) worker.send({
|
|
213
|
-
id: request.id,
|
|
214
|
-
result: result.message,
|
|
215
|
-
error: null
|
|
216
|
-
}, result.transfer);
|
|
217
|
-
else worker.send({
|
|
218
|
-
id: request.id,
|
|
219
|
-
result,
|
|
220
|
-
error: null
|
|
221
|
-
});
|
|
222
|
-
currentRequestId = null;
|
|
223
|
-
}
|
|
224
|
-
} else throw new Error("Unknown method \"" + request.method + "\"");
|
|
225
|
-
} catch (err) {
|
|
226
|
-
worker.send({
|
|
227
|
-
id: request.id,
|
|
228
|
-
result: null,
|
|
229
|
-
error: convertError(err)
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
});
|
|
233
|
-
/**
|
|
234
|
-
* Register methods to the worker
|
|
235
|
-
* @param {Object} [methods]
|
|
236
|
-
* @param {import('./types.js').WorkerRegisterOptions} [options]
|
|
237
|
-
*/
|
|
238
|
-
worker.register = function(methods, options) {
|
|
239
|
-
if (methods) {
|
|
240
|
-
for (var name in methods) if (methods.hasOwnProperty(name)) {
|
|
241
|
-
worker.methods[name] = methods[name];
|
|
242
|
-
worker.methods[name].worker = publicWorker;
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
if (options) {
|
|
246
|
-
worker.terminationHandler = options.onTerminate;
|
|
247
|
-
worker.abortListenerTimeout = options.abortListenerTimeout || TIMEOUT_DEFAULT;
|
|
248
|
-
}
|
|
249
|
-
worker.send("ready");
|
|
250
|
-
};
|
|
251
|
-
worker.emit = function(payload) {
|
|
252
|
-
if (currentRequestId) {
|
|
253
|
-
if (payload instanceof Transfer) {
|
|
254
|
-
worker.send({
|
|
255
|
-
id: currentRequestId,
|
|
256
|
-
isEvent: true,
|
|
257
|
-
payload: payload.message
|
|
258
|
-
}, payload.transfer);
|
|
259
|
-
return;
|
|
260
|
-
}
|
|
261
|
-
worker.send({
|
|
262
|
-
id: currentRequestId,
|
|
263
|
-
isEvent: true,
|
|
264
|
-
payload
|
|
265
|
-
});
|
|
266
|
-
}
|
|
267
|
-
};
|
|
268
|
-
if (typeof exports !== "undefined") {
|
|
269
|
-
exports.add = worker.register;
|
|
270
|
-
exports.emit = worker.emit;
|
|
271
|
-
}
|
|
272
|
-
}) });
|
|
273
|
-
|
|
274
|
-
//#endregion
|
|
275
|
-
export default require_worker();
|
|
276
|
-
|
|
277
|
-
export { require_worker };
|