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AC3C,IAAM,EACL,EAAY,YACZ,EAAY,WAAW,6BACpB,MAAM,KACP,EAAY,WAAW,6BAA6B,EAAQ,KAE3D,KAMA,GAJH,GAAgB,EAAa,OAAS,EACnC,EAAa,GACb,EAAQ,GAAG,aAEO,mBAClB,EAAW,EAAY,OAAO,EAAO,MAAM,SAC3C,EAAU,OAAO,KAAK,MAAM,IAAQ,IAIpC,EAAQ,OACX,EAAO,IAAP,iCAA8C,KAAK,UAAU,GAA7D,MAEQ,EAAQ,WAChB,EAAO,IAAP,GAAgB,KAAK,UAAU,EAAQ,WAAa,EAAO,MAG3D,EAAO,IAAP,6BAA0C,KAAK,UAAU,EAAO,OAGxC,IAArB,EAAQ,iBACJ,EAAK,aAAa,OAAO,EAAO,MAGxC,IAAI,EAAY,EAAO,IAQvB,OAPI,EAAQ,SACX,EAAS,oCAAsC,EAAtC,2BAMH,EAAG,KAAD,sCACmB,YAAY,iBAAiB,EAAM,KAAK,QAAQ,UAAW,mBAD9E,4BAEQ,KAAK,UAAU,GAFvB,yEAIc,EAJd,aAIoC,KAAK,UAAU,GAJnD,sCAKe,EALf,oDAOJ,EAAQ,MAAQ,yFAA2F,IAPvG,0C,CAaV,OAAO,EAAG,KAAM,K,GAEjB,E","file":"/npm/workerize-loader@2.0.2/dist/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.37.0.\n * Original file: /npm/workerize-loader@2.0.2/dist/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","import path from 'path';\nimport loaderUtils from 'loader-utils';\n\nimport NodeTargetPlugin from 'webpack/lib/node/NodeTargetPlugin';\nimport SingleEntryPlugin from 'webpack/lib/SingleEntryPlugin';\nimport WebWorkerTemplatePlugin from 'webpack/lib/webworker/WebWorkerTemplatePlugin';\n\nexport default function loader() {}\n\nconst CACHE = {};\nconst tapName = 'workerize-loader';\n\nfunction compilationHook(compiler, handler) {\n\tif (compiler.hooks) {\n\t\treturn compiler.hooks.compilation.tap(tapName, handler);\n\t}\n\treturn compiler.plugin('compilation', handler);\n}\n\nfunction parseHook(data, handler) {\n\tif (data.normalModuleFactory.hooks) {\n\t\treturn data.normalModuleFactory.hooks.parser.for('javascript/auto').tap(tapName, handler);\n\t}\n\treturn data.normalModuleFactory.plugin('parser', handler);\n}\n\nfunction exportDeclarationHook(parser, handler) {\n\tif (parser.hooks) {\n\t\treturn parser.hooks.exportDeclaration.tap(tapName, handler);\n\t}\n\treturn parser.plugin('export declaration', handler);\n}\n\nloader.pitch = function(request) {\n\tthis.cacheable(false);\n\n\tconst options = loaderUtils.getOptions(this) || {};\n\n\tconst cb = this.async();\n\n\tconst compilerOptions = this._compiler.options || {};\n\n\tconst filename = (options.name || '[fullhash]') + '.worker.js';\n\n\tconst worker = {};\n\n\tworker.options = {\n\t\tfilename,\n\t\tchunkFilename: filename,\n\t\tpublicPath: options.publicPath || compilerOptions.output.publicPath,\n\t\tglobalObject: 'self'\n\t};\n\n\tif (compilerOptions.output && compilerOptions.output.globalObject==='window') {\n\t\tconsole.warn('Warning (workerize-loader): output.globalObject is set to \"window\". It should be set to \"self\" or \"this\" to support HMR in Workers.');\n\t}\n\n\tworker.compiler = this._compilation.createChildCompiler(`worker ${request}`, worker.options);\n\n\t(new WebWorkerTemplatePlugin(worker.options)).apply(worker.compiler);\n\n\tif (this.target!=='webworker' && this.target!=='web') {\n\t\t(new NodeTargetPlugin()).apply(worker.compiler);\n\t}\n\n\t// webpack >= v4 supports webassembly\n\tlet wasmPluginPath = null;\n\ttry {\n\t\twasmPluginPath = require.resolve(\n\t\t\t'webpack/lib/web/FetchCompileWasmTemplatePlugin'\n\t\t);\n\t}\n\tcatch (_err) {\n\t\t// webpack <= v3, skipping\n\t}\n\n\tif (wasmPluginPath) {\n\t\t// eslint-disable-next-line global-require\n\t\tconst FetchCompileWasmTemplatePlugin = require(wasmPluginPath);\n\t\tnew FetchCompileWasmTemplatePlugin({\n\t\t\tmangleImports: this._compiler.options.optimization.mangleWasmImports\n\t\t}).apply(worker.compiler);\n\t}\n\n\tconst bundleName = path.parse(this.resourcePath).name;\n\n\t(new SingleEntryPlugin(this.context, `!!${path.resolve(__dirname, 'rpc-worker-loader.js')}!${request}`, bundleName)).apply(worker.compiler);\n\n\tcompilationHook(worker.compiler, (compilation, data) => {\n\t\tparseHook(data, (parser, options) => {\n\t\t\texportDeclarationHook(parser, expr => {\n\t\t\t\tlet decl = expr.declaration || expr;\n\t\t\t\tlet\t{ compilation, current } = parser.state;\n\n\t\t\t\tlet entryModule =\n\t\t\t\t\tcompilation.entries instanceof Map\n\t\t\t\t\t\t? compilation.moduleGraph.getModule(\n\t\t\t\t\t\t\tcompilation.entries.get(bundleName).dependencies[0]\n\t\t\t\t\t\t  )\n\t\t\t\t\t\t: compilation.entries[0];\n\n\t\t\t\t// only process entry exports\n\t\t\t\tif (current.resource!==entryModule.resource) return;\n\n\t\t\t\tlet key = current.nameForCondition();\n\t\t\t\tlet exports = CACHE[key] || (CACHE[key] = {});\n\t\t\t\tif (decl.id) {\n\t\t\t\t\texports[decl.id.name] = true;\n\t\t\t\t}\n\t\t\t\telse if (decl.declarations) {\n\t\t\t\t\tfor (let i=0; i<decl.declarations.length; i++) {\n\t\t\t\t\t\texports[decl.declarations[i].id.name] = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tconsole.warn('[workerize] unknown export declaration: ', expr);\n\t\t\t\t}\n\n\t\t\t\t// This is for Webpack 5: mark the exports as used so it does not get tree-shaken away on production build\n\t\t\t\tif (compilation.moduleGraph) {\n\t\t\t\t\tconst { getEntryRuntime } = require('webpack/lib/util/runtime');\n\t\t\t\t\tconst { UsageState } = require('webpack');\n\t\t\t\t\tconst runtime = getEntryRuntime(compilation, bundleName);\n\t\t\t\t\tfor (const exportName of Object.keys(exports)) {\n\t\t\t\t\t\tconst exportInfo = compilation.moduleGraph.getExportInfo(entryModule, exportName);\n\t\t\t\t\t\texportInfo.setUsed(UsageState.Used, runtime);\n\t\t\t\t\t\texportInfo.canMangleUse = false;\n\t\t\t\t\t\texportInfo.canMangleProvide = false;\n\t\t\t\t\t}\n\t\t\t\t\tcompilation.moduleGraph.addExtraReason(entryModule, 'used by workerize-loader');\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t});\n\n\tworker.compiler.runAsChild((err, entries, compilation) => {\n\t\tif (err) return cb(err);\n\n\t\tif (entries[0]) {\n\t\t\tworker.file = Array.from(entries[0].files)[0];\n\t\t\tconst entryModules =\n\t\t\t\tcompilation.chunkGraph &&\n\t\t\t\tcompilation.chunkGraph.getChunkEntryModulesIterable\n\t\t\t\t\t? Array.from(\n\t\t\t\t\t\tcompilation.chunkGraph.getChunkEntryModulesIterable(entries[0])\n\t\t\t\t\t  )\n\t\t\t\t\t: null;\n\t\t\tconst entryModule =\n\t\t\t\tentryModules && entryModules.length > 0\n\t\t\t\t\t? entryModules[0]\n\t\t\t\t\t: entries[0].entryModule;\n\n\t\t\tlet key = entryModule.nameForCondition();\n\t\t\tlet contents = compilation.assets[worker.file].source();\n\t\t\tlet exports = Object.keys(CACHE[key] || {});\n\n\t\t\t// console.log('Workerized exports: ', exports.join(', '));\n\n\t\t\tif (options.inline) {\n\t\t\t\tworker.url = `URL.createObjectURL(new Blob([${JSON.stringify(contents)}]))`;\n\t\t\t}\n\t\t\telse if (options.publicPath) {\n\t\t\t\tworker.url = `${JSON.stringify(options.publicPath + worker.file)}`;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tworker.url = `__webpack_public_path__ + ${JSON.stringify(worker.file)}`;\n\t\t\t}\n\n\t\t\tif (options.fallback === false) {\n\t\t\t\tdelete this._compilation.assets[worker.file];\n\t\t\t}\n\n\t\t\tlet workerUrl = worker.url;\n\t\t\tif (options.import) {\n\t\t\t\tworkerUrl = `\"data:,importScripts('\"+new URL(${workerUrl},location.origin)+\"')\"`;\n\t\t\t}\n\n\t\t\t// workerUrl will be URL.revokeObjectURL() to avoid memory leaks on browsers\n\t\t\t// https://github.com/webpack-contrib/worker-loader/issues/208\n\n\t\t\treturn cb(null, `\n\t\t\t\tvar addMethods = require(${loaderUtils.stringifyRequest(this, path.resolve(__dirname, 'rpc-wrapper.js'))})\n\t\t\t\tvar methods = ${JSON.stringify(exports)}\n\t\t\t\tmodule.exports = function() {\n\t\t\t\t\tvar w = new Worker(${workerUrl}, { name: ${JSON.stringify(filename)} })\n\t\t\t\t\tURL.revokeObjectURL(${workerUrl});\n\t\t\t\t\taddMethods(w, methods)\n\t\t\t\t\t${ options.ready ? 'w.ready = new Promise(function(r) { w.addEventListener(\"ready\", function(){ r(w) }) })' : '' }\n\t\t\t\t\treturn w\n\t\t\t\t}\n\t\t\t`);\n\t\t}\n\n\t\treturn cb(null, null);\n\t});\n};\n"]}