amis-rpc-design/node_modules/@babel/register/lib/worker-client.js.map

1 line
7.0 KiB
Plaintext
Raw Normal View History

2023-10-07 19:42:30 +08:00
{"version":3,"names":["path","require","ACTIONS","GET_DEFAULT_EXTENSIONS","SET_OPTIONS","TRANSFORM","TRANSFORM_SYNC","_send","WeakMap","_eCache","Client","constructor","send","_classPrivateFieldInitSpec","writable","value","_classPrivateFieldSet","getDefaultExtensions","_classPrivateFieldGet2","_classPrivateFieldGet","call","undefined","setOptions","options","transform","code","filename","exports","WorkerClient","_worker","_signal","_class2","action","payload","subChannel","_classStaticPrivateFieldSpecGet","_worker_threads","MessageChannel","postMessage","signal","port","port1","Atomics","wait","message","receiveMessageOnPort","port2","error","Object","assign","errorData","result","Worker","resolve","__dirname","env","_markInRegisterWorker","process","Int32Array","SharedArrayBuffer","unref","get","_get_markInRegisterWorker","set","_get_worker_threads","markInRegisterWorker","_class3","_handleMessage","LocalClient","_classStaticPrivateFi","_classStaticPrivateFieldSpecSet","isLocalClient"],"sources":["../src/worker-client.js"],"sourcesContent":["const path = require(\"path\");\n\nconst ACTIONS = {\n GET_DEFAULT_EXTENSIONS: \"GET_DEFAULT_EXTENSIONS\",\n SET_OPTIONS: \"SET_OPTIONS\",\n TRANSFORM: \"TRANSFORM\",\n TRANSFORM_SYNC: \"TRANSFORM_SYNC\",\n};\n\nclass Client {\n #send;\n\n constructor(send) {\n this.#send = send;\n }\n\n #eCache;\n /** @return {string[]} */\n getDefaultExtensions() {\n return (this.#eCache ??= this.#send(\n ACTIONS.GET_DEFAULT_EXTENSIONS,\n undefined,\n ));\n }\n\n /**\n * @param {object} options\n * @return {void}\n */\n setOptions(options) {\n return this.#send(ACTIONS.SET_OPTIONS, options);\n }\n\n /**\n * @param {string} code\n * @param {string} filename\n * @return {{ code: string, map: object } | null}\n */\n transform(code, filename) {\n return this.#send(ACTIONS.TRANSFORM, { code, filename });\n }\n}\n\n// We need to run Babel in a worker because require hooks must\n// run synchronously, but many steps of Babel's config loading\n// (which is done for each file) can be asynchronous\nexports.WorkerClient = class WorkerClient extends Client {\n // These two require() calls are in deferred so that they are not imported in\n // older Node.js versions (which don't support workers).\n // TODO: Hoist them in Babel 8.\n\n /** @type {typeof import(\"worker_threads\")} */\n static get #worker_threads() {\n return require(\"worker_threads\");\n }\n\n static get #markInRegisterWorker() {\n return require(\"./is-in-register-worker.js\").markInRegisterWorker;\n }\n\n #worker = new WorkerClient.#worker_threads.Worker(\n path.resolve(__dirname, \"./worker/index.js\"),\n { env: WorkerClient.#markInRegisterWorker(process.env) },\n );\n\n #signal = new Int32Array(new SharedArrayBuffer(4));\n\n constructor() {\n super((action, payload) => {\n this.#signal[0] = 0;\n const subChannel = new WorkerClient.#worker_threads.MessageChannel();\n\n this.#worker.postMessage(\n { signal: this.#signal, port: subChannel.port1, action, payload },\n [subChannel.port1],\n );\n\n Atomics.wait(this.#signal, 0, 0);\n const { message } = WorkerClient.#worker_threads.receiveMessageOnPort(\n subChannel.port2,\n );\n\n if (message.error) throw Object.assign(message.error, message.errorData);\n else return message.result;\n });\n\n // The worker will never exit by itself. Prevent it from keeping\n // the main process alive.\n this.#worker.unref();\n }\n};\n\nif (!process.env.BABEL_8_BREAKING) {\n exports.LocalClient = class LocalClient extends Client {\n isLocalClient = true;\n\n static #handleMessage;\n\n constructor() {\n LocalClient.#handleMessage ??= require(\"./worker/handle-message.js\");\n\n super((action, payload) => {\n return LocalClient.#handleMessage(\n action === ACTIONS.TRANSFORM ? ACTIONS.TRANSFORM_SYNC : action,\n payload,\n );\n });\n }\n };\n}\n"],"mappings":";;;;;;;;;;;;AAAA,MAAMA,IAAI,GAAGC,OAAO,C