-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimjoy-rpc.js.map
1 lines (1 loc) · 196 KB
/
imjoy-rpc.js.map
1
{"version":3,"sources":["webpack://[name]/webpack/universalModuleDefinition","webpack://[name]/webpack/bootstrap","webpack://[name]/./node_modules/worker-loader/dist/workers/InlineWorker.js","webpack://[name]/./src/main.js","webpack://[name]/./src/plugin.webworker.js","webpack://[name]/./src/pluginCore.js","webpack://[name]/./src/pluginIframe.js","webpack://[name]/./src/rpc.js","webpack://[name]/./src/utils.js"],"names":["_inIframe","window","self","top","e","_inWebWorker","WorkerGlobalScope","setupWebWorker","config","allow_execution","Error","broadcastChannel","BroadcastChannel","worker","PluginWorker","fallbackTimeout","setTimeout","terminate","console","warn","setupIframe","peer_id","randId","addEventListener","transferables","undefined","m","data","type","postMessage","clearTimeout","Object","assign","origin","location","dispatchEvent","CustomEvent","detail","cache_requirements","requirements","__transferables__","parent","target_origin","debug","log","waitForInitialization","globalThis","enable_service_worker","setupServiceWorker","base_url","targetOrigin","credential_required","verify_credential","done","removeEventListener","handleEvent","name","cfg","credential","then","result","auth","error","setupRPC","normalizeConfig","Promise","resolve","reject","api","expose_api_globally","includes","connectRPC","connection","codecs","rpc","RPC","on","launchConnected","getRemote","registerCodec","k","keys","init","setInterface","setup","disposeObject","obj","export","_interface","onLoad","handler","checkHandler","connected","connectedHandlers","push","dispose","disconnect","_rpc","pop","msg","_htmlToElement","html","template","document","createElement","trim","innerHTML","content","firstChild","executeEsModule","dataUri","encodeURIComponent","Connection","MessageEmitter","constructor","connect","emit","_fire","execute","code","loadRequirementsInWindow","src","script_node","setAttribute","attrs","head","appendChild","lang","eval","node","createTextNode","body","style_node","link_node_","rel","href","stack","String","dedicated_thread","api_version","API_VERSION","conn","ArrayBufferView","getPrototypeOf","Uint8Array","_appendBuffer","buffer1","buffer2","tmp","byteLength","set","buffer","indexObject","is","split","length","slice","_connection","_codecs","_object_store","_method_weakmap","WeakMap","_object_weakmap","_local_api","_remote_set","_store","ReferenceStore","_method_refs","onReady","onBusy","_setupMessageHanlders","setConfig","getRemoteCallStack","getStack","_remote_interface","description","forwarding_functions","func_name","_remote","args","Function","prototype","sendInterface","once","_encode","_disposeObject","objectId","has","get","object_id","catch","method","method_this","promise","_unwrap","intf_index","join","apply","err","fetch","id","_setRemoteInterface","requestRemote","_ndarray","typedArray","shape","dtype","_dtype","typedArrayToDtype","_rtype","_rvalue","_rshape","_rdtype","_decode","intf","_reportRemoteSet","_genRemoteMethod","targetId","me","remoteMethod","put","wrapped_resolve","arguments","wrapped_reject","encodedPromise","_wrap","__promise_pair","Array","call","argLength","withKwargs","_rkwargs","target_id","with_kwargs","__remote_method","aObject","asInterface","aType","ArrayBuffer","bObject","_rtarget_id","_rintf","cid","_rname","temp","_transfer","isarray","isArray","tp","codec","encoder","encodedObj","tf","Tensor","v_buffer","dataSync","nj","NdArray","selection","toString","File","_rpath","_path","webkitRelativePath","Boolean","Date","RegExp","ImageData","FileList","FileSystemDirectoryHandle","FileSystemFileHandle","FileSystemHandle","FileSystemWritableFileStream","_rmime","Blob","DataView","Set","from","Map","getOwnPropertyNames","concat","hasFunction","startsWith","withPromise","decoder","_genRemoteCallback","array","reduce","Uint8","reshape","arraytype","dtypeToTypedArray","tensor","hasOwnProperty","v","remoteCallback","reset","_event_handlers","_once_handlers","_indices","_readyHandler","_busyHandler","readyHandler","busyHandler","_genId","shift","_releaseId","i","splice","Math","random","substr","getTime","int8","Int8Array","int16","Int16Array","int32","Int32Array","uint8","uint16","Uint16Array","uint32","Uint32Array","float32","Float32Array","float64","Float64Array","_importScript","url","scriptTag","onload","onreadystatechange","readyState","onerror","importScripts","len","link_node","toLowerCase","endsWith","loadRequirementsInWebworker","loadRequirements","version","p","c","typedArrayToDtypeMapping","typedArrayToDtypeKeys","arrType","pt","cacheUrlInServiceWorker","message","command","navigator","serviceWorker","register","messageChannel","MessageChannel","port1","onmessage","event","controller","port2","cacheRequirements","req","baseUrl","cacheCallback","registration","scope","urlJoin","replace","_debug","___event_run_once","off","idx","indexOf"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;QCVA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;;QAGA;QACA;;;;;;;;;;;;;AClFa;;AAEb;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA,OAAO;AACP;AACA;AACA;;AAEA;AACA,KAAK;AACL;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA,E;;;;;;;;;;;;;;;;;;;;;;;ACpCA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;;AAEA,SAASA,SAAT,GAAqB;AACnB,MAAI;AACF,WAAOC,MAAM,CAACC,IAAP,KAAgBD,MAAM,CAACE,GAA9B;AACD,GAFD,CAEE,OAAOC,CAAP,EAAU;AACV,WAAO,IAAP;AACD;AACF;;AAED,SAASC,YAAT,GAAwB;AACtB,SACE,OAAOC,iBAAP,KAA6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,eAAL,CAAqB8D,KAArB,EAA4B5M,MAApC;;AACA,aAAOwJ,CAAC,EAAR,EAAY;AACV,cAAMzN,OAAO,GAAG,KAAK+M,eAAL,CAAqB8D,KAArB,EAA4BpD,CAA5B,CAAhB;;AACA,YAAI;AACFzN,iBAAO,CAAC/D,IAAD,CAAP;AACD,SAFD,CAEE,OAAOvB,CAAP,EAAU;AACVc,iBAAO,CAAC4C,KAAR,CAAc1D,CAAd;AACD,SAJD,SAIU;AACR,cAAIsF,OAAO,CAACyR,iBAAZ,EAA+B;AAC7B,iBAAK1E,eAAL,CAAqB8D,KAArB,EAA4BnD,MAA5B,CAAmCD,CAAnC,EAAsC,CAAtC;AACD;AACF;AACF;AACF,KAdD,MAcO;AACL,UAAI,KAAK+D,MAAT,EAAiB;AACfhW,eAAO,CAACC,IAAR,CAAa,iBAAb,EAAgCoV,KAAhC,EAAuC5U,IAAvC;AACD;AACF;AACF;;AAxDyB,C","file":"imjoy-rpc.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"imjoyRPC\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"imjoyRPC\"] = factory();\n\telse\n\t\troot[\"imjoyRPC\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./src/main.js\");\n","'use strict';\n\n// http://stackoverflow.com/questions/10343913/how-to-create-a-web-worker-from-a-string\n\nvar URL = window.URL || window.webkitURL;\n\nmodule.exports = function (content, url) {\n try {\n try {\n var blob;\n\n try {\n // BlobBuilder = Deprecated, but widely implemented\n var BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder || window.MSBlobBuilder;\n\n blob = new BlobBuilder();\n\n blob.append(content);\n\n blob = blob.getBlob();\n } catch (e) {\n // The proposed API\n blob = new Blob([content]);\n }\n\n return new Worker(URL.createObjectURL(blob));\n } catch (e) {\n return new Worker('data:application/javascript,' + encodeURIComponent(content));\n }\n } catch (e) {\n if (!url) {\n throw Error('Inline worker is not supported');\n }\n\n return new Worker(url);\n }\n};","/**\n * Contains the code executed in the sandboxed frame under web-browser\n *\n * Tries to create a Web-Worker inside the frame and set up the\n * communication between the worker and the parent window. Some\n * browsers restrict creating a worker inside a sandboxed iframe - if\n * this happens, the plugin initialized right inside the frame (in the\n * same thread)\n */\nimport PluginWorker from \"./plugin.webworker.js\";\nimport setupIframe from \"./pluginIframe.js\";\nimport {\n randId,\n normalizeConfig,\n setupServiceWorker,\n loadRequirements\n} from \"./utils.js\";\n\nexport { RPC, API_VERSION } from \"./rpc.js\";\nexport { version as VERSION } from \"../package.json\";\nexport { loadRequirements };\n\nfunction _inIframe() {\n try {\n return window.self !== window.top;\n } catch (e) {\n return true;\n }\n}\n\nfunction _inWebWorker() {\n return (\n typeof WorkerGlobalScope !== \"undefined\" &&\n self instanceof WorkerGlobalScope\n );\n}\n\n/**\n * Initializes the plugin inside a web worker. May throw an exception\n * in case this was not permitted by the browser.\n */\nfunction setupWebWorker(config) {\n if (!config.allow_execution)\n throw new Error(\n \"web-worker plugin can only work with allow_execution=true\"\n );\n let broadcastChannel = null;\n if (config.broadcastChannel) {\n broadcastChannel = new BroadcastChannel(config.broadcastChannel);\n }\n const worker = new PluginWorker();\n // mixed content warning in Chrome silently skips worker\n // initialization without exception, handling this with timeout\n const fallbackTimeout = setTimeout(function() {\n worker.terminate();\n console.warn(\n `Plugin failed to start as a web-worker, running in an iframe instead.`\n );\n setupIframe(config);\n }, 2000);\n const peer_id = randId();\n\n // forwarding messages between the worker and parent window\n worker.addEventListener(\"message\", function(e) {\n let transferables = undefined;\n const m = e.data;\n if (m.type === \"worker-ready\") {\n // send config to the worker\n worker.postMessage({ type: \"connectRPC\", config: config });\n clearTimeout(fallbackTimeout);\n return;\n } else if (m.type === \"initialized\") {\n // complete the missing fields\n m.config = Object.assign({}, config, m.config);\n m.origin = window.location.origin;\n m.peer_id = peer_id;\n } else if (m.type === \"imjoy_remote_api_ready\") {\n // if it's a webworker, there will be no api object returned\n window.dispatchEvent(\n new CustomEvent(\"imjoy_remote_api_ready\", { detail: null })\n );\n } else if (\n m.type === \"cacheRequirements\" &&\n typeof cache_requirements === \"function\"\n ) {\n cache_requirements(m.requirements);\n } else if (m.type === \"disconnect\") {\n worker.terminate();\n } else {\n if (m.__transferables__) {\n transferables = m.__transferables__;\n delete m.__transferables__;\n }\n }\n if (broadcastChannel) broadcastChannel.postMessage(m);\n else parent.postMessage(m, config.target_origin || \"*\", transferables);\n });\n\n (broadcastChannel || window).addEventListener(\"message\", function(e) {\n if (\n e.type === \"message\" &&\n (broadcastChannel ||\n config.target_origin === \"*\" ||\n e.origin === config.target_origin)\n ) {\n let transferables = undefined;\n const m = e.data;\n if (m.__transferables__) {\n transferables = m.__transferables__;\n delete m.__transferables__;\n }\n if (m.peer_id === peer_id) {\n worker.postMessage(m, transferables);\n } else if (config.debug) {\n console.log(`connection peer id mismatch ${m.peer_id} !== ${peer_id}`);\n }\n }\n });\n}\n\nexport function waitForInitialization(config) {\n if (_inWebWorker()) {\n globalThis.parent = self;\n }\n config = config || {};\n if (config.enable_service_worker) {\n setupServiceWorker(\n config.base_url,\n config.target_origin,\n config.cache_requirements\n );\n config.enable_service_worker = false;\n }\n if (config.cache_requirements) {\n delete config.cache_requirements;\n }\n const targetOrigin = config.target_origin || \"*\";\n if (\n config.credential_required &&\n typeof config.verify_credential !== \"function\"\n ) {\n throw new Error(\n \"Please also provide the `verify_credential` function with `credential_required`.\"\n );\n }\n if (config.credential_required && targetOrigin === \"*\") {\n throw new Error(\n \"`target_origin` was set to `*` with `credential_required=true`, there is a security risk that you may leak the credential to website from other origin. Please specify the `target_origin` explicitly.\"\n );\n }\n const done = () => {\n globalThis.removeEventListener(\"message\", handleEvent);\n };\n const peer_id = randId();\n const handleEvent = e => {\n if (\n e.type === \"message\" &&\n (!e.origin || targetOrigin === \"*\" || e.origin === targetOrigin)\n ) {\n if (e.data.type === \"initialize\") {\n done();\n if (e.data.peer_id !== peer_id) {\n // TODO: throw an error when we are sure all the peers will send the peer_id\n console.warn(\n `${e.data.config &&\n e.data.config.name}: connection peer id mismatch ${\n e.data.peer_id\n } !== ${peer_id}`\n );\n }\n const cfg = e.data.config;\n // override the target_origin setting if it's configured by the rpc client\n // otherwise take the setting from the core\n if (targetOrigin !== \"*\") {\n cfg.target_origin = targetOrigin;\n }\n if (config.credential_required) {\n config.verify_credential(cfg.credential).then(result => {\n if (result && result.auth && !result.error) {\n // pass the authentication information with tokens\n cfg.auth = result.auth;\n setupRPC(cfg).then(() => {\n console.log(\"ImJoy RPC loaded successfully!\");\n });\n } else {\n throw new Error(\n \"Failed to verify the credentail:\" + (result && result.error)\n );\n }\n });\n } else {\n setupRPC(cfg).then(() => {\n console.log(\"ImJoy RPC loaded successfully!\");\n });\n }\n } else {\n throw new Error(`unrecognized message: ${e.data}`);\n }\n }\n };\n globalThis.addEventListener(\"message\", handleEvent);\n\n if (_inWebWorker()) {\n parent.postMessage({\n type: \"imjoyRPCReady\",\n config: config,\n peer_id: peer_id\n });\n } else {\n parent.postMessage(\n { type: \"imjoyRPCReady\", config: config, peer_id: peer_id },\n \"*\"\n );\n }\n}\n\nexport function setupRPC(config) {\n config = config || {};\n config.name = config.name || randId();\n config = normalizeConfig(config);\n if (config.enable_service_worker) {\n setupServiceWorker(\n config.base_url,\n config.target_origin,\n config.cache_requirements\n );\n }\n if (config.cache_requirements) {\n delete config.cache_requirements;\n }\n return new Promise((resolve, reject) => {\n const handleEvent = e => {\n const api = e.detail;\n if (config.expose_api_globally) {\n globalThis.api = api;\n }\n // imjoy plugin api\n resolve(api);\n globalThis.removeEventListener(\"imjoy_remote_api_ready\", handleEvent);\n };\n if (_inIframe()) {\n if (config.type === \"web-worker\") {\n try {\n setupWebWorker(config);\n } catch (e) {\n // fallback to iframe\n setupIframe(config);\n }\n } else if (\n [\"rpc-window\", \"rpc-worker\", \"iframe\", \"window\"].includes(config.type)\n ) {\n setupIframe(config);\n } else {\n console.error(\"Unsupported plugin type: \" + config.type);\n reject(\"Unsupported plugin type: \" + config.type);\n return;\n }\n globalThis.addEventListener(\"imjoy_remote_api_ready\", handleEvent);\n } else if (_inWebWorker()) {\n // inside a webworker\n setupIframe(config);\n } else {\n reject(\n new Error(\"imjoy-rpc should only run inside an iframe or a webworker.\")\n );\n }\n });\n}\n","module.exports = function() {\n return require(\"!!/home/runner/work/imjoy-rpc/imjoy-rpc/javascript/node_modules/worker-loader/dist/workers/InlineWorker.js\")(\"/******/ (function(modules) { // webpackBootstrap\\n/******/ \\t// The module cache\\n/******/ \\tvar installedModules = {};\\n/******/\\n/******/ \\t// The require function\\n/******/ \\tfunction __webpack_require__(moduleId) {\\n/******/\\n/******/ \\t\\t// Check if module is in cache\\n/******/ \\t\\tif(installedModules[moduleId]) {\\n/******/ \\t\\t\\treturn installedModules[moduleId].exports;\\n/******/ \\t\\t}\\n/******/ \\t\\t// Create a new module (and put it into the cache)\\n/******/ \\t\\tvar module = installedModules[moduleId] = {\\n/******/ \\t\\t\\ti: moduleId,\\n/******/ \\t\\t\\tl: false,\\n/******/ \\t\\t\\texports: {}\\n/******/ \\t\\t};\\n/******/\\n/******/ \\t\\t// Execute the module function\\n/******/ \\t\\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\\n/******/\\n/******/ \\t\\t// Flag the module as loaded\\n/******/ \\t\\tmodule.l = true;\\n/******/\\n/******/ \\t\\t// Return the exports of the module\\n/******/ \\t\\treturn module.exports;\\n/******/ \\t}\\n/******/\\n/******/\\n/******/ \\t// expose the modules object (__webpack_modules__)\\n/******/ \\t__webpack_require__.m = modules;\\n/******/\\n/******/ \\t// expose the module cache\\n/******/ \\t__webpack_require__.c = installedModules;\\n/******/\\n/******/ \\t// define getter function for harmony exports\\n/******/ \\t__webpack_require__.d = function(exports, name, getter) {\\n/******/ \\t\\tif(!__webpack_require__.o(exports, name)) {\\n/******/ \\t\\t\\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\\n/******/ \\t\\t}\\n/******/ \\t};\\n/******/\\n/******/ \\t// define __esModule on exports\\n/******/ \\t__webpack_require__.r = function(exports) {\\n/******/ \\t\\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\\n/******/ \\t\\t\\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\\n/******/ \\t\\t}\\n/******/ \\t\\tObject.defineProperty(exports, '__esModule', { value: true });\\n/******/ \\t};\\n/******/\\n/******/ \\t// create a fake namespace object\\n/******/ \\t// mode & 1: value is a module id, require it\\n/******/ \\t// mode & 2: merge all properties of value into the ns\\n/******/ \\t// mode & 4: return value when already ns object\\n/******/ \\t// mode & 8|1: behave like require\\n/******/ \\t__webpack_require__.t = function(value, mode) {\\n/******/ \\t\\tif(mode & 1) value = __webpack_require__(value);\\n/******/ \\t\\tif(mode & 8) return value;\\n/******/ \\t\\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\\n/******/ \\t\\tvar ns = Object.create(null);\\n/******/ \\t\\t__webpack_require__.r(ns);\\n/******/ \\t\\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\\n/******/ \\t\\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\\n/******/ \\t\\treturn ns;\\n/******/ \\t};\\n/******/\\n/******/ \\t// getDefaultExport function for compatibility with non-harmony modules\\n/******/ \\t__webpack_require__.n = function(module) {\\n/******/ \\t\\tvar getter = module && module.__esModule ?\\n/******/ \\t\\t\\tfunction getDefault() { return module['default']; } :\\n/******/ \\t\\t\\tfunction getModuleExports() { return module; };\\n/******/ \\t\\t__webpack_require__.d(getter, 'a', getter);\\n/******/ \\t\\treturn getter;\\n/******/ \\t};\\n/******/\\n/******/ \\t// Object.prototype.hasOwnProperty.call\\n/******/ \\t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\\n/******/\\n/******/ \\t// __webpack_public_path__\\n/******/ \\t__webpack_require__.p = \\\"\\\";\\n/******/\\n/******/\\n/******/ \\t// Load entry module and return exports\\n/******/ \\treturn __webpack_require__(__webpack_require__.s = \\\"./src/plugin.webworker.js\\\");\\n/******/ })\\n/************************************************************************/\\n/******/ ({\\n\\n/***/ \\\"./src/plugin.webworker.js\\\":\\n/*!*********************************!*\\\\\\n !*** ./src/plugin.webworker.js ***!\\n \\\\*********************************/\\n/*! no exports provided */\\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\\n\\n\\\"use strict\\\";\\n__webpack_require__.r(__webpack_exports__);\\n/* harmony import */ var _pluginCore_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./pluginCore.js */ \\\"./src/pluginCore.js\\\");\\n/* harmony import */ var _rpc_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rpc.js */ \\\"./src/rpc.js\\\");\\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./utils.js */ \\\"./src/utils.js\\\");\\n/**\\n * Contains the routines loaded by the plugin Worker under web-browser.\\n *\\n * Initializes the web environment version of the platform-dependent\\n * connection object for the plugin site\\n */\\n\\n\\n\\n\\n// make sure this runs inside a webworker\\nif (\\n typeof WorkerGlobalScope === \\\"undefined\\\" ||\\n !self ||\\n !(self instanceof WorkerGlobalScope)\\n) {\\n throw new Error(\\\"This script can only loaded in a webworker\\\");\\n}\\n\\nasync function executeEsModule(content) {\\n const dataUri =\\n \\\"data:text/javascript;charset=utf-8,\\\" + encodeURIComponent(content);\\n await import(/* webpackIgnore: true */ dataUri);\\n}\\n\\n/**\\n * Connection object provided to the RPC constructor,\\n * plugin site implementation for the web-based environment.\\n * Global will be then cleared to prevent exposure into the\\n * Worker, so we put this local connection object into a closure\\n */\\nclass Connection extends _utils_js__WEBPACK_IMPORTED_MODULE_2__[\\\"MessageEmitter\\\"] {\\n constructor(config) {\\n super(config && config.debug);\\n this.config = config || {};\\n }\\n connect() {\\n self.addEventListener(\\\"message\\\", e => {\\n this._fire(e.data.type, e.data);\\n });\\n this.emit({\\n type: \\\"initialized\\\",\\n config: this.config\\n });\\n }\\n disconnect() {\\n this._fire(\\\"beforeDisconnect\\\");\\n self.close();\\n this._fire(\\\"disconnected\\\");\\n }\\n emit(data) {\\n let transferables = undefined;\\n if (data.__transferables__) {\\n transferables = data.__transferables__;\\n delete data.__transferables__;\\n }\\n self.postMessage(data, transferables);\\n }\\n async execute(code) {\\n if (code.type === \\\"requirements\\\") {\\n await Object(_utils_js__WEBPACK_IMPORTED_MODULE_2__[\\\"loadRequirementsInWebworker\\\"])(code.requirements);\\n } else if (code.type === \\\"script\\\") {\\n try {\\n if (code.attrs.type === \\\"module\\\") {\\n await executeEsModule(code.content);\\n } else {\\n eval(code.content);\\n }\\n } catch (e) {\\n console.error(e.message, e.stack);\\n throw e;\\n }\\n } else {\\n throw \\\"unsupported code type.\\\";\\n }\\n if (code.type === \\\"requirements\\\") {\\n self.postMessage({\\n type: \\\"cacheRequirements\\\",\\n requirements: code.requirements\\n });\\n }\\n }\\n}\\nconst config = {\\n type: \\\"web-worker\\\",\\n dedicated_thread: true,\\n allow_execution: true,\\n lang: \\\"javascript\\\",\\n api_version: _rpc_js__WEBPACK_IMPORTED_MODULE_1__[\\\"API_VERSION\\\"]\\n};\\nconst conn = new Connection(config);\\nconn.on(\\\"connectRPC\\\", data => {\\n Object(_pluginCore_js__WEBPACK_IMPORTED_MODULE_0__[\\\"connectRPC\\\"])(conn, Object.assign(data.config, config));\\n});\\nconn.connect();\\nself.postMessage({\\n type: \\\"worker-ready\\\"\\n});\\n\\n\\n/***/ }),\\n\\n/***/ \\\"./src/pluginCore.js\\\":\\n/*!***************************!*\\\\\\n !*** ./src/pluginCore.js ***!\\n \\\\***************************/\\n/*! exports provided: connectRPC */\\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\\n\\n\\\"use strict\\\";\\n__webpack_require__.r(__webpack_exports__);\\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \\\"connectRPC\\\", function() { return connectRPC; });\\n/* harmony import */ var _rpc_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./rpc.js */ \\\"./src/rpc.js\\\");\\n/**\\n * Core plugin script loaded into the plugin process/thread.\\n *\\n * Initializes the plugin-site API global methods.\\n */\\n\\nfunction connectRPC(connection, config) {\\n config = config || {};\\n const codecs = {};\\n const rpc = new _rpc_js__WEBPACK_IMPORTED_MODULE_0__[\\\"RPC\\\"](connection, config, codecs);\\n rpc.on(\\\"getInterface\\\", function () {\\n launchConnected();\\n });\\n rpc.on(\\\"remoteReady\\\", function () {\\n const api = rpc.getRemote() || {};\\n\\n api.registerCodec = function (config) {\\n if (!config[\\\"name\\\"] || !config[\\\"encoder\\\"] && !config[\\\"decoder\\\"]) {\\n throw new Error(\\\"Invalid codec format, please make sure you provide a name, type, encoder and decoder.\\\");\\n } else {\\n if (config.type) {\\n for (let k of Object.keys(codecs)) {\\n if (codecs[k].type === config.type || k === config.name) {\\n delete codecs[k];\\n console.warn(\\\"Remove duplicated codec: \\\" + k);\\n }\\n }\\n }\\n\\n codecs[config[\\\"name\\\"]] = config;\\n }\\n };\\n\\n api.init = function (config) {\\n // register a minimal plugin api\\n rpc.setInterface({\\n setup() {}\\n\\n }, config);\\n };\\n\\n api.disposeObject = function (obj) {\\n rpc.disposeObject(obj);\\n };\\n\\n api.export = function (_interface, config) {\\n rpc.setInterface(_interface, config);\\n };\\n\\n api.onLoad = function (handler) {\\n handler = checkHandler(handler);\\n\\n if (connected) {\\n handler();\\n } else {\\n connectedHandlers.push(handler);\\n }\\n };\\n\\n api.dispose = function (_interface) {\\n rpc.disconnect();\\n };\\n\\n api._rpc = rpc;\\n\\n if (typeof WorkerGlobalScope !== \\\"undefined\\\" && self instanceof WorkerGlobalScope) {\\n self.api = api;\\n self.postMessage({\\n type: \\\"imjoy_remote_api_ready\\\"\\n });\\n self.dispatchEvent(new CustomEvent(\\\"imjoy_remote_api_ready\\\", {\\n detail: api\\n }));\\n } else if (typeof window) {\\n window.dispatchEvent(new CustomEvent(\\\"imjoy_remote_api_ready\\\", {\\n detail: api\\n }));\\n }\\n });\\n let connected = false;\\n const connectedHandlers = [];\\n\\n const launchConnected = function () {\\n if (!connected) {\\n connected = true;\\n let handler;\\n\\n while (handler = connectedHandlers.pop()) {\\n handler();\\n }\\n }\\n };\\n\\n const checkHandler = function (handler) {\\n const type = typeof handler;\\n\\n if (type !== \\\"function\\\") {\\n const msg = \\\"A function may only be subsribed to the event, \\\" + type + \\\" was provided instead\\\";\\n throw new Error(msg);\\n }\\n\\n return handler;\\n };\\n\\n return rpc;\\n}\\n\\n/***/ }),\\n\\n/***/ \\\"./src/rpc.js\\\":\\n/*!********************!*\\\\\\n !*** ./src/rpc.js ***!\\n \\\\********************/\\n/*! exports provided: API_VERSION, RPC */\\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\\n\\n\\\"use strict\\\";\\n__webpack_require__.r(__webpack_exports__);\\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \\\"API_VERSION\\\", function() { return API_VERSION; });\\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \\\"RPC\\\", function() { return RPC; });\\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ \\\"./src/utils.js\\\");\\n/**\\n * Contains the RPC object used both by the application\\n * site, and by each plugin\\n */\\n\\nconst API_VERSION = \\\"0.2.3\\\";\\nconst ArrayBufferView = Object.getPrototypeOf(Object.getPrototypeOf(new Uint8Array())).constructor;\\n\\nfunction _appendBuffer(buffer1, buffer2) {\\n const tmp = new Uint8Array(buffer1.byteLength + buffer2.byteLength);\\n tmp.set(new Uint8Array(buffer1), 0);\\n tmp.set(new Uint8Array(buffer2), buffer1.byteLength);\\n return tmp.buffer;\\n}\\n\\nfunction indexObject(obj, is) {\\n if (!is) throw new Error(\\\"undefined index\\\");\\n if (typeof is === \\\"string\\\") return indexObject(obj, is.split(\\\".\\\"));else if (is.length === 0) return obj;else return indexObject(obj[is[0]], is.slice(1));\\n}\\n/**\\n * RPC object represents a single site in the\\n * communication protocol between the application and the plugin\\n *\\n * @param {Object} connection a special object allowing to send\\n * and receive messages from the opposite site (basically it\\n * should only provide send() and onMessage() methods)\\n */\\n\\n\\nclass RPC extends _utils_js__WEBPACK_IMPORTED_MODULE_0__[\\\"MessageEmitter\\\"] {\\n constructor(connection, config, codecs) {\\n super(config && config.debug);\\n this._connection = connection;\\n this.config = config || {};\\n this._codecs = codecs || {};\\n this._object_store = {};\\n this._method_weakmap = new WeakMap();\\n this._object_weakmap = new WeakMap();\\n this._local_api = null;\\n this._remote_set = false; // make sure there is an execute function\\n\\n const name = this.config.name;\\n\\n this._connection.execute = this._connection.execute || function () {\\n throw new Error(`connection.execute not implemented (in \\\"${name}\\\")`);\\n };\\n\\n this._store = new ReferenceStore();\\n this._method_refs = new ReferenceStore();\\n\\n this._method_refs.onReady(() => {\\n this._fire(\\\"remoteIdle\\\");\\n });\\n\\n this._method_refs.onBusy(() => {\\n this._fire(\\\"remoteBusy\\\");\\n });\\n\\n this._setupMessageHanlders();\\n }\\n\\n init() {\\n this._connection.emit({\\n type: \\\"initialized\\\",\\n config: this.config,\\n peer_id: this._connection.peer_id\\n });\\n }\\n\\n setConfig(config) {\\n if (config) for (const k of Object.keys(config)) {\\n this.config[k] = config[k];\\n }\\n }\\n /**\\n * Set a handler to be called when received a responce from the\\n * remote site reporting that the previously provided interface\\n * has been successfully set as remote for that site\\n *\\n * @param {Function} handler\\n */\\n\\n\\n getRemoteCallStack() {\\n return this._method_refs.getStack();\\n }\\n /**\\n * @returns {Object} set of remote interface methods\\n */\\n\\n\\n getRemote() {\\n return this._remote_interface;\\n }\\n /**\\n * Sets the interface of this site making it available to the\\n * remote site by sending a message with a set of methods names\\n *\\n * @param {Object} _interface to set\\n */\\n\\n\\n setInterface(_interface, config) {\\n config = config || {};\\n this.config.name = config.name || this.config.name;\\n this.config.description = config.description || this.config.description;\\n\\n if (this.config.forwarding_functions) {\\n for (let func_name of this.config.forwarding_functions) {\\n const _remote = this._remote_interface;\\n\\n if (_remote[func_name]) {\\n if (_interface.constructor === Object) {\\n if (!_interface[func_name]) {\\n _interface[func_name] = (...args) => {\\n _remote[func_name](...args);\\n };\\n }\\n } else if (_interface.constructor.constructor === Function) {\\n if (!_interface.constructor.prototype[func_name]) {\\n _interface.constructor.prototype[func_name] = (...args) => {\\n _remote[func_name](...args);\\n };\\n }\\n }\\n }\\n }\\n }\\n\\n this._local_api = _interface;\\n if (!this._remote_set) this._fire(\\\"interfaceAvailable\\\");else this.sendInterface();\\n return new Promise(resolve => {\\n this.once(\\\"interfaceSetAsRemote\\\", resolve);\\n });\\n }\\n /**\\n * Sends the actual interface to the remote site upon it was\\n * updated or by a special request of the remote site\\n */\\n\\n\\n sendInterface() {\\n if (!this._local_api) {\\n throw new Error(\\\"interface is not set.\\\");\\n }\\n\\n this._encode(this._local_api, true).then(api => {\\n this._connection.emit({\\n type: \\\"setInterface\\\",\\n api: api\\n });\\n });\\n }\\n\\n _disposeObject(objectId) {\\n if (this._object_store[objectId]) {\\n delete this._object_store[objectId];\\n } else {\\n throw new Error(`Object (id=${objectId}) not found.`);\\n }\\n }\\n\\n disposeObject(obj) {\\n return new Promise((resolve, reject) => {\\n if (this._object_weakmap.has(obj)) {\\n const objectId = this._object_weakmap.get(obj);\\n\\n this._connection.once(\\\"disposed\\\", data => {\\n if (data.error) reject(new Error(data.error));else resolve();\\n });\\n\\n this._connection.emit({\\n type: \\\"disposeObject\\\",\\n object_id: objectId\\n });\\n } else {\\n throw new Error(\\\"Invalid object\\\");\\n }\\n });\\n }\\n /**\\n * Handles a message from the remote site\\n */\\n\\n\\n _setupMessageHanlders() {\\n this._connection.on(\\\"init\\\", this.init);\\n\\n this._connection.on(\\\"execute\\\", data => {\\n Promise.resolve(this._connection.execute(data.code)).then(() => {\\n this._connection.emit({\\n type: \\\"executed\\\"\\n });\\n }).catch(e => {\\n console.error(e);\\n\\n this._connection.emit({\\n type: \\\"executed\\\",\\n error: String(e)\\n });\\n });\\n });\\n\\n this._connection.on(\\\"method\\\", async data => {\\n let resolve, reject, method, method_this, args, result;\\n\\n try {\\n if (data.promise) {\\n [resolve, reject] = await this._unwrap(data.promise, false);\\n }\\n\\n const _interface = this._object_store[data.object_id];\\n method = indexObject(_interface, data.name);\\n\\n if (data.name.includes(\\\".\\\")) {\\n const tmp = data.name.split(\\\".\\\");\\n const intf_index = tmp.slice(0, tmp.length - 1).join(\\\".\\\");\\n method_this = indexObject(_interface, intf_index);\\n } else {\\n method_this = _interface;\\n }\\n\\n args = await this._unwrap(data.args, true);\\n\\n if (data.promise) {\\n result = method.apply(method_this, args);\\n\\n if (result instanceof Promise || method.constructor && method.constructor.name === \\\"AsyncFunction\\\") {\\n result.then(resolve).catch(reject);\\n } else {\\n resolve(result);\\n }\\n } else {\\n method.apply(method_this, args);\\n }\\n } catch (err) {\\n console.error(this.config.name, err);\\n\\n if (reject) {\\n reject(err);\\n }\\n }\\n });\\n\\n this._connection.on(\\\"callback\\\", async data => {\\n let resolve, reject, method, args, result;\\n\\n try {\\n if (data.promise) {\\n [resolve, reject] = await this._unwrap(data.promise, false);\\n }\\n\\n if (data.promise) {\\n method = this._store.fetch(data.id);\\n args = await this._unwrap(data.args, true);\\n\\n if (!method) {\\n throw new Error(\\\"Callback function can only called once, if you want to call a function for multiple times, please make it as a plugin api function. See https://imjoy.io/docs for more details.\\\");\\n }\\n\\n result = method.apply(null, args);\\n\\n if (result instanceof Promise || method.constructor && method.constructor.name === \\\"AsyncFunction\\\") {\\n result.then(resolve).catch(reject);\\n } else {\\n resolve(result);\\n }\\n } else {\\n method = this._store.fetch(data.id);\\n args = await this._unwrap(data.args, true);\\n\\n if (!method) {\\n throw new Error(\\\"Please notice that callback function can only called once, if you want to call a function for multiple times, please make it as a plugin api function. See https://imjoy.io/docs for more details.\\\");\\n }\\n\\n method.apply(null, args);\\n }\\n } catch (err) {\\n console.error(this.config.name, err);\\n\\n if (reject) {\\n reject(err);\\n }\\n }\\n });\\n\\n this._connection.on(\\\"disposeObject\\\", data => {\\n try {\\n this._disposeObject(data.object_id);\\n\\n this._connection.emit({\\n type: \\\"disposed\\\"\\n });\\n } catch (e) {\\n console.error(e);\\n\\n this._connection.emit({\\n type: \\\"disposed\\\",\\n error: String(e)\\n });\\n }\\n });\\n\\n this._connection.on(\\\"setInterface\\\", data => {\\n this._setRemoteInterface(data.api);\\n });\\n\\n this._connection.on(\\\"getInterface\\\", () => {\\n this._fire(\\\"getInterface\\\");\\n\\n if (this._local_api) {\\n this.sendInterface();\\n } else {\\n this.once(\\\"interfaceAvailable\\\", () => {\\n this.sendInterface();\\n });\\n }\\n });\\n\\n this._connection.on(\\\"interfaceSetAsRemote\\\", () => {\\n this._remote_set = true;\\n\\n this._fire(\\\"interfaceSetAsRemote\\\");\\n });\\n\\n this._connection.on(\\\"disconnect\\\", () => {\\n this._fire(\\\"beforeDisconnect\\\");\\n\\n this._connection.disconnect();\\n\\n this._fire(\\\"disconnected\\\");\\n });\\n }\\n /**\\n * Sends a requests to the remote site asking it to provide its\\n * current interface\\n */\\n\\n\\n requestRemote() {\\n this._connection.emit({\\n type: \\\"getInterface\\\"\\n });\\n }\\n\\n _ndarray(typedArray, shape, dtype) {\\n const _dtype = Object(_utils_js__WEBPACK_IMPORTED_MODULE_0__[\\\"typedArrayToDtype\\\"])(typedArray);\\n\\n if (dtype && dtype !== _dtype) {\\n throw \\\"dtype doesn't match the type of the array: \\\" + _dtype + \\\" != \\\" + dtype;\\n }\\n\\n shape = shape || [typedArray.length];\\n return {\\n _rtype: \\\"ndarray\\\",\\n _rvalue: typedArray.buffer,\\n _rshape: shape,\\n _rdtype: _dtype\\n };\\n }\\n /**\\n * Sets the new remote interface provided by the other site\\n *\\n * @param {Array} names list of function names\\n */\\n\\n\\n _setRemoteInterface(api) {\\n this._decode(api).then(intf => {\\n // update existing interface instead of recreating it\\n // this will preserve the object reference\\n if (this._remote_interface) {\\n // clear the interface\\n for (let k in this._remote_interface) delete this._remote_interface[k]; // then assign the new interfaces\\n\\n\\n Object.assign(this._remote_interface, intf);\\n } else this._remote_interface = intf;\\n\\n this._fire(\\\"remoteReady\\\");\\n\\n this._reportRemoteSet();\\n });\\n }\\n /**\\n * Generates the wrapped function corresponding to a single remote\\n * method. When the generated function is called, it will send the\\n * corresponding message to the remote site asking it to execute\\n * the particular method of its interface\\n *\\n * @param {String} name of the remote method\\n *\\n * @returns {Function} wrapped remote method\\n */\\n\\n\\n _genRemoteMethod(targetId, name, objectId) {\\n const me = this;\\n\\n const remoteMethod = function () {\\n return new Promise(async (resolve, reject) => {\\n let id = null;\\n\\n try {\\n id = me._method_refs.put(objectId ? objectId + \\\"/\\\" + name : name);\\n\\n const wrapped_resolve = function () {\\n if (id !== null) me._method_refs.fetch(id);\\n return resolve.apply(this, arguments);\\n };\\n\\n const wrapped_reject = function () {\\n if (id !== null) me._method_refs.fetch(id);\\n return reject.apply(this, arguments);\\n };\\n\\n const encodedPromise = await me._wrap([wrapped_resolve, wrapped_reject]); // store the key id for removing them from the reference store together\\n\\n wrapped_resolve.__promise_pair = encodedPromise[1]._rvalue;\\n wrapped_reject.__promise_pair = encodedPromise[0]._rvalue;\\n let args = Array.prototype.slice.call(arguments);\\n const argLength = args.length; // if the last argument is an object, mark it as kwargs\\n\\n const withKwargs = argLength > 0 && typeof args[argLength - 1] === \\\"object\\\" && args[argLength - 1] !== null && args[argLength - 1]._rkwargs;\\n if (withKwargs) delete args[argLength - 1]._rkwargs;\\n\\n if (name === \\\"register\\\" || name === \\\"registerService\\\" || name === \\\"register_service\\\" || name === \\\"export\\\" || name === \\\"on\\\") {\\n args = await me._wrap(args, true);\\n } else {\\n args = await me._wrap(args);\\n }\\n\\n const transferables = args.__transferables__;\\n if (transferables) delete args.__transferables__;\\n\\n me._connection.emit({\\n type: \\\"method\\\",\\n target_id: targetId,\\n name: name,\\n object_id: objectId,\\n args: args,\\n promise: encodedPromise,\\n with_kwargs: withKwargs\\n }, transferables);\\n } catch (e) {\\n if (id) me._method_refs.fetch(id);\\n reject(`Failed to exectue remote method (interface: ${objectId || me.id}, method: ${name}), error: ${e}`);\\n }\\n });\\n };\\n\\n remoteMethod.__remote_method = true;\\n return remoteMethod;\\n }\\n /**\\n * Sends a responce reporting that interface just provided by the\\n * remote site was successfully set by this site as remote\\n */\\n\\n\\n _reportRemoteSet() {\\n this._connection.emit({\\n type: \\\"interfaceSetAsRemote\\\"\\n });\\n }\\n /**\\n * Prepares the provided set of remote method arguments for\\n * sending to the remote site, replaces all the callbacks with\\n * identifiers\\n *\\n * @param {Array} args to wrap\\n *\\n * @returns {Array} wrapped arguments\\n */\\n\\n\\n async _encode(aObject, asInterface, objectId) {\\n const aType = typeof aObject;\\n\\n if (aType === \\\"number\\\" || aType === \\\"string\\\" || aType === \\\"boolean\\\" || aObject === null || aObject === undefined || aObject instanceof ArrayBuffer) {\\n return aObject;\\n }\\n\\n let bObject;\\n\\n if (typeof aObject === \\\"function\\\") {\\n if (asInterface) {\\n if (!objectId) throw new Error(\\\"objectId is not specified.\\\");\\n bObject = {\\n _rtype: \\\"interface\\\",\\n _rtarget_id: this._connection.peer_id,\\n _rintf: objectId,\\n _rvalue: asInterface\\n };\\n\\n this._method_weakmap.set(aObject, bObject);\\n } else if (this._method_weakmap.has(aObject)) {\\n bObject = this._method_weakmap.get(aObject);\\n } else {\\n const cid = this._store.put(aObject);\\n\\n bObject = {\\n _rtype: \\\"callback\\\",\\n _rtarget_id: this._connection.peer_id,\\n _rname: aObject.constructor && aObject.constructor.name || cid,\\n _rvalue: cid\\n };\\n }\\n\\n return bObject;\\n } // skip if already encoded\\n\\n\\n if (aObject.constructor instanceof Object && aObject._rtype) {\\n // make sure the interface functions are encoded\\n if (aObject._rintf) {\\n const temp = aObject._rtype;\\n delete aObject._rtype;\\n bObject = await this._encode(aObject, asInterface, objectId);\\n bObject._rtype = temp;\\n } else {\\n bObject = aObject;\\n }\\n\\n return bObject;\\n }\\n\\n const transferables = [];\\n const _transfer = aObject._transfer;\\n const isarray = Array.isArray(aObject);\\n\\n for (let tp of Object.keys(this._codecs)) {\\n const codec = this._codecs[tp];\\n\\n if (codec.encoder && aObject instanceof codec.type) {\\n // TODO: what if multiple encoders found\\n let encodedObj = await Promise.resolve(codec.encoder(aObject));\\n if (encodedObj && !encodedObj._rtype) encodedObj._rtype = codec.name; // encode the functions in the interface object\\n\\n if (encodedObj && encodedObj._rintf) {\\n const temp = encodedObj._rtype;\\n delete encodedObj._rtype;\\n encodedObj = await this._encode(encodedObj, asInterface, objectId);\\n encodedObj._rtype = temp;\\n }\\n\\n bObject = encodedObj;\\n return bObject;\\n }\\n }\\n\\n if (\\n /*global tf*/\\n typeof tf !== \\\"undefined\\\" && tf.Tensor && aObject instanceof tf.Tensor) {\\n const v_buffer = aObject.dataSync();\\n\\n if (aObject._transfer || _transfer) {\\n transferables.push(v_buffer.buffer);\\n delete aObject._transfer;\\n }\\n\\n bObject = {\\n _rtype: \\\"ndarray\\\",\\n _rvalue: v_buffer.buffer,\\n _rshape: aObject.shape,\\n _rdtype: aObject.dtype\\n };\\n } else if (\\n /*global nj*/\\n typeof nj !== \\\"undefined\\\" && nj.NdArray && aObject instanceof nj.NdArray) {\\n const dtype = Object(_utils_js__WEBPACK_IMPORTED_MODULE_0__[\\\"typedArrayToDtype\\\"])(aObject.selection.data);\\n\\n if (aObject._transfer || _transfer) {\\n transferables.push(aObject.selection.data.buffer);\\n delete aObject._transfer;\\n }\\n\\n bObject = {\\n _rtype: \\\"ndarray\\\",\\n _rvalue: aObject.selection.data.buffer,\\n _rshape: aObject.shape,\\n _rdtype: dtype\\n };\\n } else if (aObject instanceof Error) {\\n console.error(aObject);\\n bObject = {\\n _rtype: \\\"error\\\",\\n _rvalue: aObject.toString()\\n };\\n } else if (typeof File !== \\\"undefined\\\" && aObject instanceof File) {\\n bObject = {\\n _rtype: \\\"file\\\",\\n _rvalue: aObject,\\n _rpath: aObject._path || aObject.webkitRelativePath\\n };\\n } // send objects supported by structure clone algorithm\\n // https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm\\n else if (aObject !== Object(aObject) || aObject instanceof Boolean || aObject instanceof String || aObject instanceof Date || aObject instanceof RegExp || aObject instanceof ImageData || typeof FileList !== \\\"undefined\\\" && aObject instanceof FileList || typeof FileSystemDirectoryHandle !== \\\"undefined\\\" && aObject instanceof FileSystemDirectoryHandle || typeof FileSystemFileHandle !== \\\"undefined\\\" && aObject instanceof FileSystemFileHandle || typeof FileSystemHandle !== \\\"undefined\\\" && aObject instanceof FileSystemHandle || typeof FileSystemWritableFileStream !== \\\"undefined\\\" && aObject instanceof FileSystemWritableFileStream) {\\n bObject = aObject; // TODO: avoid object such as DynamicPlugin instance.\\n } else if (typeof File !== \\\"undefined\\\" && aObject instanceof File) {\\n bObject = {\\n _rtype: \\\"file\\\",\\n _rname: aObject.name,\\n _rmime: aObject.type,\\n _rvalue: aObject,\\n _rpath: aObject._path || aObject.webkitRelativePath\\n };\\n } else if (aObject instanceof Blob) {\\n bObject = {\\n _rtype: \\\"blob\\\",\\n _rvalue: aObject\\n };\\n } else if (aObject instanceof ArrayBufferView) {\\n if (aObject._transfer || _transfer) {\\n transferables.push(aObject.buffer);\\n delete aObject._transfer;\\n }\\n\\n const dtype = Object(_utils_js__WEBPACK_IMPORTED_MODULE_0__[\\\"typedArrayToDtype\\\"])(aObject);\\n bObject = {\\n _rtype: \\\"typedarray\\\",\\n _rvalue: aObject.buffer,\\n _rdtype: dtype\\n };\\n } else if (aObject instanceof DataView) {\\n if (aObject._transfer || _transfer) {\\n transferables.push(aObject.buffer);\\n delete aObject._transfer;\\n }\\n\\n bObject = {\\n _rtype: \\\"memoryview\\\",\\n _rvalue: aObject.buffer\\n };\\n } else if (aObject instanceof Set) {\\n bObject = {\\n _rtype: \\\"set\\\",\\n _rvalue: await this._encode(Array.from(aObject), asInterface)\\n };\\n } else if (aObject instanceof Map) {\\n bObject = {\\n _rtype: \\\"orderedmap\\\",\\n _rvalue: await this._encode(Array.from(aObject), asInterface)\\n };\\n } else if (aObject.constructor instanceof Object || Array.isArray(aObject)) {\\n bObject = isarray ? [] : {};\\n let keys; // an object/array\\n\\n if (aObject.constructor === Object || Array.isArray(aObject)) {\\n keys = Object.keys(aObject);\\n } // a class\\n else if (aObject.constructor === Function) {\\n throw new Error(\\\"Please instantiate the class before exportting it.\\\");\\n } // instance of a class\\n else if (aObject.constructor.constructor === Function) {\\n keys = Object.getOwnPropertyNames(Object.getPrototypeOf(aObject)).concat(Object.keys(aObject)); // TODO: use a proxy object to represent the actual object\\n // always encode class instance as interface\\n\\n asInterface = true;\\n } else {\\n throw Error(\\\"Unsupported interface type\\\");\\n }\\n\\n let hasFunction = false; // encode interfaces\\n\\n if (aObject._rintf || asInterface) {\\n if (!objectId) {\\n if (typeof aObject._rintf === \\\"string\\\" && aObject._rintf.length > 0) {\\n objectId = aObject._rintf; // enable custom object id\\n } else {\\n objectId = Object(_utils_js__WEBPACK_IMPORTED_MODULE_0__[\\\"randId\\\"])();\\n } // Note: object with the same id will be overwritten\\n\\n\\n if (this._object_store[objectId]) console.warn(`Overwritting interface object with the same id: ${objectId}`);\\n this._object_store[objectId] = aObject;\\n }\\n\\n for (let k of keys) {\\n if (k === \\\"constructor\\\") continue;\\n\\n if (k.startsWith(\\\"_\\\")) {\\n continue;\\n }\\n\\n bObject[k] = await this._encode(aObject[k], typeof asInterface === \\\"string\\\" ? asInterface + \\\".\\\" + k : k, objectId);\\n\\n if (typeof aObject[k] === \\\"function\\\") {\\n hasFunction = true;\\n }\\n } // object id for dispose the object remotely\\n\\n\\n if (hasFunction) bObject._rintf = objectId; // remove interface when closed\\n\\n if (aObject.on && typeof aObject.on === \\\"function\\\") {\\n aObject.on(\\\"close\\\", () => {\\n delete this._object_store[objectId];\\n });\\n }\\n } else {\\n for (let k of keys) {\\n if ([\\\"hasOwnProperty\\\", \\\"constructor\\\"].includes(k)) continue;\\n bObject[k] = await this._encode(aObject[k]);\\n }\\n } // for example, browserFS object\\n\\n } else if (typeof aObject === \\\"object\\\") {\\n const keys = Object.getOwnPropertyNames(Object.getPrototypeOf(aObject)).concat(Object.keys(aObject));\\n const objectId = Object(_utils_js__WEBPACK_IMPORTED_MODULE_0__[\\\"randId\\\"])();\\n\\n for (let k of keys) {\\n if ([\\\"hasOwnProperty\\\", \\\"constructor\\\"].includes(k)) continue; // encode as interface\\n\\n bObject[k] = await this._encode(aObject[k], k, bObject);\\n } // object id, used for dispose the object\\n\\n\\n bObject._rintf = objectId;\\n } else {\\n throw \\\"imjoy-rpc: Unsupported data type:\\\" + aObject;\\n }\\n\\n if (transferables.length > 0) {\\n bObject.__transferables__ = transferables;\\n }\\n\\n if (!bObject) {\\n throw new Error(\\\"Failed to encode object\\\");\\n }\\n\\n return bObject;\\n }\\n\\n async _decode(aObject, withPromise) {\\n if (!aObject) {\\n return aObject;\\n }\\n\\n let bObject;\\n\\n if (aObject[\\\"_rtype\\\"]) {\\n if (this._codecs[aObject._rtype] && this._codecs[aObject._rtype].decoder) {\\n if (aObject._rintf) {\\n const temp = aObject._rtype;\\n delete aObject._rtype;\\n aObject = await this._decode(aObject, withPromise);\\n aObject._rtype = temp;\\n }\\n\\n bObject = await Promise.resolve(this._codecs[aObject._rtype].decoder(aObject));\\n } else if (aObject._rtype === \\\"callback\\\") {\\n bObject = this._genRemoteCallback(aObject._rtarget_id, aObject._rvalue, withPromise);\\n } else if (aObject._rtype === \\\"interface\\\") {\\n bObject = this._genRemoteMethod(aObject._rtarget_id, aObject._rvalue, aObject._rintf);\\n } else if (aObject._rtype === \\\"ndarray\\\") {\\n /*global nj tf*/\\n //create build array/tensor if used in the plugin\\n if (typeof nj !== \\\"undefined\\\" && nj.array) {\\n if (Array.isArray(aObject._rvalue)) {\\n aObject._rvalue = aObject._rvalue.reduce(_appendBuffer);\\n }\\n\\n bObject = nj.array(new Uint8(aObject._rvalue), aObject._rdtype).reshape(aObject._rshape);\\n } else if (typeof tf !== \\\"undefined\\\" && tf.Tensor) {\\n if (Array.isArray(aObject._rvalue)) {\\n aObject._rvalue = aObject._rvalue.reduce(_appendBuffer);\\n }\\n\\n const arraytype = _utils_js__WEBPACK_IMPORTED_MODULE_0__[\\\"dtypeToTypedArray\\\"][aObject._rdtype];\\n bObject = tf.tensor(new arraytype(aObject._rvalue), aObject._rshape, aObject._rdtype);\\n } else {\\n //keep it as regular if transfered to the main app\\n bObject = aObject;\\n }\\n } else if (aObject._rtype === \\\"error\\\") {\\n bObject = new Error(aObject._rvalue);\\n } else if (aObject._rtype === \\\"file\\\") {\\n if (aObject._rvalue instanceof File) {\\n bObject = aObject._rvalue; //patch _path\\n\\n bObject._path = aObject._rpath;\\n } else {\\n bObject = new File([aObject._rvalue], aObject._rname, {\\n type: aObject._rmime\\n });\\n bObject._path = aObject._rpath;\\n }\\n } else if (aObject._rtype === \\\"typedarray\\\") {\\n const arraytype = _utils_js__WEBPACK_IMPORTED_MODULE_0__[\\\"dtypeToTypedArray\\\"][aObject._rdtype];\\n if (!arraytype) throw new Error(\\\"unsupported dtype: \\\" + aObject._rdtype);\\n bObject = new arraytype(aObject._rvalue);\\n } else if (aObject._rtype === \\\"memoryview\\\") {\\n bObject = new DataView(aObject._rvalue);\\n } else if (aObject._rtype === \\\"blob\\\") {\\n if (aObject._rvalue instanceof Blob) {\\n bObject = aObject._rvalue;\\n } else {\\n bObject = new Blob([aObject._rvalue], {\\n type: aObject._rmime\\n });\\n }\\n } else if (aObject._rtype === \\\"orderedmap\\\") {\\n bObject = new Map(await this._decode(aObject._rvalue, withPromise));\\n } else if (aObject._rtype === \\\"set\\\") {\\n bObject = new Set(await this._decode(aObject._rvalue, withPromise));\\n } else {\\n // make sure all the interface functions are decoded\\n if (aObject._rintf) {\\n const temp = aObject._rtype;\\n delete aObject._rtype;\\n bObject = await this._decode(aObject, withPromise);\\n bObject._rtype = temp;\\n } else bObject = aObject;\\n }\\n } else if (aObject.constructor === Object || Array.isArray(aObject)) {\\n const isarray = Array.isArray(aObject);\\n bObject = isarray ? [] : {};\\n\\n for (let k of Object.keys(aObject)) {\\n if (isarray || aObject.hasOwnProperty(k)) {\\n const v = aObject[k];\\n bObject[k] = await this._decode(v, withPromise);\\n }\\n }\\n } else {\\n bObject = aObject;\\n }\\n\\n if (bObject === undefined) {\\n throw new Error(\\\"Failed to decode object\\\");\\n } // store the object id for dispose\\n\\n\\n if (aObject._rintf) {\\n this._object_weakmap.set(bObject, aObject._rintf);\\n }\\n\\n return bObject;\\n }\\n\\n async _wrap(args, asInterface) {\\n return await this._encode(args, asInterface);\\n }\\n /**\\n * Unwraps the set of arguments delivered from the remote site,\\n * replaces all callback identifiers with a function which will\\n * initiate sending that callback identifier back to other site\\n *\\n * @param {Object} args to unwrap\\n *\\n * @param {Boolean} withPromise is true means this the callback should contain a promise\\n *\\n * @returns {Array} unwrapped args\\n */\\n\\n\\n async _unwrap(args, withPromise) {\\n return await this._decode(args, withPromise);\\n }\\n /**\\n * Generates the wrapped function corresponding to a single remote\\n * callback. When the generated function is called, it will send\\n * the corresponding message to the remote site asking it to\\n * execute the particular callback previously saved during a call\\n * by the remote site a method from the interface of this site\\n *\\n * @param {Number} id of the remote callback to execute\\n * @param {Number} argNum argument index of the callback\\n * @param {Boolean} withPromise is true means this the callback should contain a promise\\n *\\n * @returns {Function} wrapped remote callback\\n */\\n\\n\\n _genRemoteCallback(targetId, cid, withPromise) {\\n const me = this;\\n let remoteCallback;\\n\\n if (withPromise) {\\n remoteCallback = function () {\\n return new Promise(async (resolve, reject) => {\\n const args = await me._wrap(Array.prototype.slice.call(arguments));\\n const argLength = args.length; // if the last argument is an object, mark it as kwargs\\n\\n const withKwargs = argLength > 0 && typeof args[argLength - 1] === \\\"object\\\" && args[argLength - 1] !== null && args[argLength - 1]._rkwargs;\\n if (withKwargs) delete args[argLength - 1]._rkwargs;\\n const transferables = args.__transferables__;\\n if (transferables) delete args.__transferables__;\\n const encodedPromise = await me._wrap([resolve, reject]); // store the key id for removing them from the reference store together\\n\\n resolve.__promise_pair = encodedPromise[1]._rvalue;\\n reject.__promise_pair = encodedPromise[0]._rvalue;\\n\\n try {\\n me._connection.emit({\\n type: \\\"callback\\\",\\n target_id: targetId,\\n id: cid,\\n args: args,\\n promise: encodedPromise,\\n with_kwargs: withKwargs\\n }, transferables);\\n } catch (e) {\\n reject(`Failed to exectue remote callback ( id: ${cid}).`);\\n }\\n });\\n };\\n\\n return remoteCallback;\\n } else {\\n remoteCallback = async function () {\\n const args = await me._wrap(Array.prototype.slice.call(arguments));\\n const argLength = args.length; // if the last argument is an object, mark it as kwargs\\n\\n const withKwargs = argLength > 0 && typeof args[argLength - 1] === \\\"object\\\" && args[argLength - 1] !== null && args[argLength - 1]._rkwargs;\\n if (withKwargs) delete args[argLength - 1]._rkwargs;\\n const transferables = args.__transferables__;\\n if (transferables) delete args.__transferables__;\\n return me._connection.emit({\\n type: \\\"callback\\\",\\n target_id: targetId,\\n id: cid,\\n args: args,\\n with_kwargs: withKwargs\\n }, transferables);\\n };\\n\\n return remoteCallback;\\n }\\n }\\n\\n reset() {\\n this._event_handlers = {};\\n this._once_handlers = {};\\n this._remote_interface = null;\\n this._object_store = {};\\n this._method_weakmap = new WeakMap();\\n this._object_weakmap = new WeakMap();\\n this._local_api = null;\\n this._store = new ReferenceStore();\\n this._method_refs = new ReferenceStore();\\n }\\n /**\\n * Sends the notification message and breaks the connection\\n */\\n\\n\\n disconnect() {\\n this._connection.emit({\\n type: \\\"disconnect\\\"\\n });\\n\\n this.reset();\\n setTimeout(() => {\\n this._connection.disconnect();\\n }, 2000);\\n }\\n\\n}\\n/**\\n * ReferenceStore is a special object which stores other objects\\n * and provides the references (number) instead. This reference\\n * may then be sent over a json-based communication channel (IPC\\n * to another Node.js process or a message to the Worker). Other\\n * site may then provide the reference in the responce message\\n * implying the given object should be activated.\\n *\\n * Primary usage for the ReferenceStore is a storage for the\\n * callbacks, which therefore makes it possible to initiate a\\n * callback execution by the opposite site (which normally cannot\\n * directly execute functions over the communication channel).\\n *\\n * Each stored object can only be fetched once and is not\\n * available for the second time. Each stored object must be\\n * fetched, since otherwise it will remain stored forever and\\n * consume memory.\\n *\\n * Stored object indeces are simply the numbers, which are however\\n * released along with the objects, and are later reused again (in\\n * order to postpone the overflow, which should not likely happen,\\n * but anyway).\\n */\\n\\nclass ReferenceStore {\\n constructor() {\\n this._store = {}; // stored object\\n\\n this._indices = [0]; // smallest available indices\\n\\n this._readyHandler = function () {};\\n\\n this._busyHandler = function () {};\\n\\n this._readyHandler();\\n }\\n /**\\n * call handler when the store is empty\\n *\\n * @param {FUNCTION} id of a handler\\n */\\n\\n\\n onReady(readyHandler) {\\n this._readyHandler = readyHandler || function () {};\\n }\\n /**\\n * call handler when the store is not empty\\n *\\n * @param {FUNCTION} id of a handler\\n */\\n\\n\\n onBusy(busyHandler) {\\n this._busyHandler = busyHandler || function () {};\\n }\\n /**\\n * get the length of the store\\n *\\n */\\n\\n\\n getStack() {\\n return Object.keys(this._store).length;\\n }\\n /**\\n * @function _genId() generates the new reference id\\n *\\n * @returns {Number} smallest available id and reserves it\\n */\\n\\n\\n _genId() {\\n let id;\\n\\n if (this._indices.length === 1) {\\n id = this._indices[0]++;\\n } else {\\n id = this._indices.shift();\\n }\\n\\n return id;\\n }\\n /**\\n * Releases the given reference id so that it will be available by\\n * another object stored\\n *\\n * @param {Number} id to release\\n */\\n\\n\\n _releaseId(id) {\\n for (let i = 0; i < this._indices.length; i++) {\\n if (id < this._indices[i]) {\\n this._indices.splice(i, 0, id);\\n\\n break;\\n }\\n } // cleaning-up the sequence tail\\n\\n\\n for (let i = this._indices.length - 1; i >= 0; i--) {\\n if (this._indices[i] - 1 === this._indices[i - 1]) {\\n this._indices.pop();\\n } else {\\n break;\\n }\\n }\\n }\\n /**\\n * Stores the given object and returns the refernce id instead\\n *\\n * @param {Object} obj to store\\n *\\n * @returns {Number} reference id of the stored object\\n */\\n\\n\\n put(obj) {\\n if (this._busyHandler && Object.keys(this._store).length === 0) {\\n this._busyHandler();\\n }\\n\\n const id = this._genId();\\n\\n this._store[id] = obj;\\n return id;\\n }\\n /**\\n * Retrieves previously stored object and releases its reference\\n *\\n * @param {Number} id of an object to retrieve\\n */\\n\\n\\n fetch(id) {\\n const obj = this._store[id];\\n\\n if (obj && !obj.__remote_method) {\\n delete this._store[id];\\n\\n this._releaseId(id);\\n\\n if (this._readyHandler && Object.keys(this._store).length === 0) {\\n this._readyHandler();\\n }\\n }\\n\\n if (obj && obj.__promise_pair) {\\n this.fetch(obj.__promise_pair);\\n }\\n\\n return obj;\\n }\\n\\n}\\n\\n/***/ }),\\n\\n/***/ \\\"./src/utils.js\\\":\\n/*!**********************!*\\\\\\n !*** ./src/utils.js ***!\\n \\\\**********************/\\n/*! exports provided: randId, dtypeToTypedArray, loadRequirementsInWindow, loadRequirementsInWebworker, loadRequirements, normalizeConfig, typedArrayToDtypeMapping, typedArrayToDtype, cacheRequirements, setupServiceWorker, urlJoin, MessageEmitter */\\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\\n\\n\\\"use strict\\\";\\n__webpack_require__.r(__webpack_exports__);\\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \\\"randId\\\", function() { return randId; });\\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \\\"dtypeToTypedArray\\\", function() { return dtypeToTypedArray; });\\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \\\"loadRequirementsInWindow\\\", function() { return loadRequirementsInWindow; });\\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \\\"loadRequirementsInWebworker\\\", function() { return loadRequirementsInWebworker; });\\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \\\"loadRequirements\\\", function() { return loadRequirements; });\\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \\\"normalizeConfig\\\", function() { return normalizeConfig; });\\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \\\"typedArrayToDtypeMapping\\\", function() { return typedArrayToDtypeMapping; });\\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \\\"typedArrayToDtype\\\", function() { return typedArrayToDtype; });\\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \\\"cacheRequirements\\\", function() { return cacheRequirements; });\\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \\\"setupServiceWorker\\\", function() { return setupServiceWorker; });\\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \\\"urlJoin\\\", function() { return urlJoin; });\\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \\\"MessageEmitter\\\", function() { return MessageEmitter; });\\nfunction randId() {\\n return Math.random().toString(36).substr(2, 10) + new Date().getTime();\\n}\\nconst dtypeToTypedArray = {\\n int8: Int8Array,\\n int16: Int16Array,\\n int32: Int32Array,\\n uint8: Uint8Array,\\n uint16: Uint16Array,\\n uint32: Uint32Array,\\n float32: Float32Array,\\n float64: Float64Array,\\n array: Array\\n};\\nasync function loadRequirementsInWindow(requirements) {\\n function _importScript(url) {\\n //url is URL of external file, implementationCode is the code\\n //to be called from the file, location is the location to\\n //insert the <script> element\\n return new Promise((resolve, reject) => {\\n var scriptTag = document.createElement(\\\"script\\\");\\n scriptTag.src = url;\\n scriptTag.type = \\\"text/javascript\\\";\\n scriptTag.onload = resolve;\\n\\n scriptTag.onreadystatechange = function () {\\n if (this.readyState === \\\"loaded\\\" || this.readyState === \\\"complete\\\") {\\n resolve();\\n }\\n };\\n\\n scriptTag.onerror = reject;\\n document.head.appendChild(scriptTag);\\n });\\n } // support importScripts outside web worker\\n\\n\\n async function importScripts() {\\n var args = Array.prototype.slice.call(arguments),\\n len = args.length,\\n i = 0;\\n\\n for (; i < len; i++) {\\n await _importScript(args[i]);\\n }\\n }\\n\\n if (requirements && (Array.isArray(requirements) || typeof requirements === \\\"string\\\")) {\\n try {\\n var link_node;\\n requirements = typeof requirements === \\\"string\\\" ? [requirements] : requirements;\\n\\n if (Array.isArray(requirements)) {\\n for (var i = 0; i < requirements.length; i++) {\\n if (requirements[i].toLowerCase().endsWith(\\\".css\\\") || requirements[i].startsWith(\\\"css:\\\")) {\\n if (requirements[i].startsWith(\\\"css:\\\")) {\\n requirements[i] = requirements[i].slice(4);\\n }\\n\\n link_node = document.createElement(\\\"link\\\");\\n link_node.rel = \\\"stylesheet\\\";\\n link_node.href = requirements[i];\\n document.head.appendChild(link_node);\\n } else if (requirements[i].toLowerCase().endsWith(\\\".mjs\\\") || requirements[i].startsWith(\\\"mjs:\\\")) {\\n // import esmodule\\n if (requirements[i].startsWith(\\\"mjs:\\\")) {\\n requirements[i] = requirements[i].slice(4);\\n }\\n\\n await import(\\n /* webpackIgnore: true */\\n requirements[i]);\\n } else if (requirements[i].toLowerCase().endsWith(\\\".js\\\") || requirements[i].startsWith(\\\"js:\\\")) {\\n if (requirements[i].startsWith(\\\"js:\\\")) {\\n requirements[i] = requirements[i].slice(3);\\n }\\n\\n await importScripts(requirements[i]);\\n } else if (requirements[i].startsWith(\\\"http\\\")) {\\n await importScripts(requirements[i]);\\n } else if (requirements[i].startsWith(\\\"cache:\\\")) {//ignore cache\\n } else {\\n console.log(\\\"Unprocessed requirements url: \\\" + requirements[i]);\\n }\\n }\\n } else {\\n throw \\\"unsupported requirements definition\\\";\\n }\\n } catch (e) {\\n throw \\\"failed to import required scripts: \\\" + requirements.toString();\\n }\\n }\\n}\\nasync function loadRequirementsInWebworker(requirements) {\\n if (requirements && (Array.isArray(requirements) || typeof requirements === \\\"string\\\")) {\\n try {\\n if (!Array.isArray(requirements)) {\\n requirements = [requirements];\\n }\\n\\n for (var i = 0; i < requirements.length; i++) {\\n if (requirements[i].toLowerCase().endsWith(\\\".css\\\") || requirements[i].startsWith(\\\"css:\\\")) {\\n throw \\\"unable to import css in a webworker\\\";\\n } else if (requirements[i].toLowerCase().endsWith(\\\".js\\\") || requirements[i].startsWith(\\\"js:\\\")) {\\n if (requirements[i].startsWith(\\\"js:\\\")) {\\n requirements[i] = requirements[i].slice(3);\\n }\\n\\n importScripts(requirements[i]);\\n } else if (requirements[i].startsWith(\\\"http\\\")) {\\n importScripts(requirements[i]);\\n } else if (requirements[i].startsWith(\\\"cache:\\\")) {//ignore cache\\n } else {\\n console.log(\\\"Unprocessed requirements url: \\\" + requirements[i]);\\n }\\n }\\n } catch (e) {\\n throw \\\"failed to import required scripts: \\\" + requirements.toString();\\n }\\n }\\n}\\nfunction loadRequirements(requirements) {\\n if (typeof WorkerGlobalScope !== \\\"undefined\\\" && self instanceof WorkerGlobalScope) {\\n return loadRequirementsInWebworker(requirements);\\n } else {\\n return loadRequirementsInWindow(requirements);\\n }\\n}\\nfunction normalizeConfig(config) {\\n config.version = config.version || \\\"0.1.0\\\";\\n config.description = config.description || `[TODO: add description for ${config.name} ]`;\\n config.type = config.type || \\\"rpc-window\\\";\\n config.id = config.id || randId();\\n config.target_origin = config.target_origin || \\\"*\\\";\\n config.allow_execution = config.allow_execution || false; // remove functions\\n\\n config = Object.keys(config).reduce((p, c) => {\\n if (typeof config[c] !== \\\"function\\\") p[c] = config[c];\\n return p;\\n }, {});\\n return config;\\n}\\nconst typedArrayToDtypeMapping = {\\n Int8Array: \\\"int8\\\",\\n Int16Array: \\\"int16\\\",\\n Int32Array: \\\"int32\\\",\\n Uint8Array: \\\"uint8\\\",\\n Uint16Array: \\\"uint16\\\",\\n Uint32Array: \\\"uint32\\\",\\n Float32Array: \\\"float32\\\",\\n Float64Array: \\\"float64\\\",\\n Array: \\\"array\\\"\\n};\\nconst typedArrayToDtypeKeys = [];\\n\\nfor (const arrType of Object.keys(typedArrayToDtypeMapping)) {\\n typedArrayToDtypeKeys.push(eval(arrType));\\n}\\n\\nfunction typedArrayToDtype(obj) {\\n let dtype = typedArrayToDtypeMapping[obj.constructor.name];\\n\\n if (!dtype) {\\n const pt = Object.getPrototypeOf(obj);\\n\\n for (const arrType of typedArrayToDtypeKeys) {\\n if (pt instanceof arrType) {\\n dtype = typedArrayToDtypeMapping[arrType.name];\\n break;\\n }\\n }\\n }\\n\\n return dtype;\\n}\\n\\nfunction cacheUrlInServiceWorker(url) {\\n return new Promise(function (resolve, reject) {\\n const message = {\\n command: \\\"add\\\",\\n url: url\\n };\\n\\n if (!navigator.serviceWorker || !navigator.serviceWorker.register) {\\n reject(\\\"Service worker is not supported.\\\");\\n return;\\n }\\n\\n const messageChannel = new MessageChannel();\\n\\n messageChannel.port1.onmessage = function (event) {\\n if (event.data && event.data.error) {\\n reject(event.data.error);\\n } else {\\n resolve(event.data && event.data.result);\\n }\\n };\\n\\n if (navigator.serviceWorker && navigator.serviceWorker.controller) {\\n navigator.serviceWorker.controller.postMessage(message, [messageChannel.port2]);\\n } else {\\n reject(\\\"Service worker controller is not available\\\");\\n }\\n });\\n}\\n\\nasync function cacheRequirements(requirements) {\\n requirements = requirements || [];\\n\\n if (!Array.isArray(requirements)) {\\n requirements = [requirements];\\n }\\n\\n for (let req of requirements) {\\n //remove prefix\\n if (req.startsWith(\\\"js:\\\")) req = req.slice(3);\\n if (req.startsWith(\\\"css:\\\")) req = req.slice(4);\\n if (req.startsWith(\\\"cache:\\\")) req = req.slice(6);\\n if (!req.startsWith(\\\"http\\\")) continue;\\n await cacheUrlInServiceWorker(req).catch(e => {\\n console.error(e);\\n });\\n }\\n}\\nfunction setupServiceWorker(baseUrl, targetOrigin, cacheCallback) {\\n // register service worker for offline access\\n if (\\\"serviceWorker\\\" in navigator) {\\n baseUrl = baseUrl || \\\"/\\\";\\n navigator.serviceWorker.register(baseUrl + \\\"plugin-service-worker.js\\\").then(function (registration) {\\n // Registration was successful\\n console.log(\\\"ServiceWorker registration successful with scope: \\\", registration.scope);\\n }, function (err) {\\n // registration failed :(\\n console.log(\\\"ServiceWorker registration failed: \\\", err);\\n });\\n targetOrigin = targetOrigin || \\\"*\\\";\\n cacheCallback = cacheCallback || cacheRequirements;\\n\\n if (cacheCallback && typeof cacheCallback !== \\\"function\\\") {\\n throw new Error(\\\"config.cache_requirements must be a function\\\");\\n }\\n\\n window.addEventListener(\\\"message\\\", function (e) {\\n if (targetOrigin === \\\"*\\\" || e.origin === targetOrigin) {\\n const m = e.data;\\n\\n if (m.type === \\\"cacheRequirements\\\") {\\n cacheCallback(m.requirements);\\n }\\n }\\n });\\n }\\n} //#Source https://bit.ly/2neWfJ2\\n\\nfunction urlJoin(...args) {\\n return args.join(\\\"/\\\").replace(/[\\\\/]+/g, \\\"/\\\").replace(/^(.+):\\\\//, \\\"$1://\\\").replace(/^file:/, \\\"file:/\\\").replace(/\\\\/(\\\\?|&|#[^!])/g, \\\"$1\\\").replace(/\\\\?/g, \\\"&\\\").replace(\\\"&\\\", \\\"?\\\");\\n}\\nclass MessageEmitter {\\n constructor(debug) {\\n this._event_handlers = {};\\n this._once_handlers = {};\\n this._debug = debug;\\n }\\n\\n emit() {\\n throw new Error(\\\"emit is not implemented\\\");\\n }\\n\\n on(event, handler) {\\n if (!this._event_handlers[event]) {\\n this._event_handlers[event] = [];\\n }\\n\\n this._event_handlers[event].push(handler);\\n }\\n\\n once(event, handler) {\\n handler.___event_run_once = true;\\n this.on(event, handler);\\n }\\n\\n off(event, handler) {\\n if (!event && !handler) {\\n // remove all events handlers\\n this._event_handlers = {};\\n } else if (event && !handler) {\\n // remove all hanlders for the event\\n if (this._event_handlers[event]) this._event_handlers[event] = [];\\n } else {\\n // remove a specific handler\\n if (this._event_handlers[event]) {\\n const idx = this._event_handlers[event].indexOf(handler);\\n\\n if (idx >= 0) {\\n this._event_handlers[event].splice(idx, 1);\\n }\\n }\\n }\\n }\\n\\n _fire(event, data) {\\n if (this._event_handlers[event]) {\\n var i = this._event_handlers[event].length;\\n\\n while (i--) {\\n const handler = this._event_handlers[event][i];\\n\\n try {\\n handler(data);\\n } catch (e) {\\n console.error(e);\\n } finally {\\n if (handler.___event_run_once) {\\n this._event_handlers[event].splice(i, 1);\\n }\\n }\\n }\\n } else {\\n if (this._debug) {\\n console.warn(\\\"unhandled event\\\", event, data);\\n }\\n }\\n }\\n\\n}\\n\\n/***/ })\\n\\n/******/ });\\n//# sourceMappingURL=plugin.webworker.js.map\", null);\n};","/**\n * Core plugin script loaded into the plugin process/thread.\n *\n * Initializes the plugin-site API global methods.\n */\nimport { RPC } from \"./rpc.js\";\n\nexport function connectRPC(connection, config) {\n config = config || {};\n const codecs = {};\n\n const rpc = new RPC(connection, config, codecs);\n rpc.on(\"getInterface\", function() {\n launchConnected();\n });\n\n rpc.on(\"remoteReady\", function() {\n const api = rpc.getRemote() || {};\n api.registerCodec = function(config) {\n if (!config[\"name\"] || (!config[\"encoder\"] && !config[\"decoder\"])) {\n throw new Error(\n \"Invalid codec format, please make sure you provide a name, type, encoder and decoder.\"\n );\n } else {\n if (config.type) {\n for (let k of Object.keys(codecs)) {\n if (codecs[k].type === config.type || k === config.name) {\n delete codecs[k];\n console.warn(\"Remove duplicated codec: \" + k);\n }\n }\n }\n codecs[config[\"name\"]] = config;\n }\n };\n api.init = function(config) {\n // register a minimal plugin api\n rpc.setInterface({ setup() {} }, config);\n };\n api.disposeObject = function(obj) {\n rpc.disposeObject(obj);\n };\n api.export = function(_interface, config) {\n rpc.setInterface(_interface, config);\n };\n api.onLoad = function(handler) {\n handler = checkHandler(handler);\n if (connected) {\n handler();\n } else {\n connectedHandlers.push(handler);\n }\n };\n api.dispose = function(_interface) {\n rpc.disconnect();\n };\n api._rpc = rpc;\n\n if (\n typeof WorkerGlobalScope !== \"undefined\" &&\n self instanceof WorkerGlobalScope\n ) {\n self.api = api;\n self.postMessage({\n type: \"imjoy_remote_api_ready\"\n });\n self.dispatchEvent(\n new CustomEvent(\"imjoy_remote_api_ready\", { detail: api })\n );\n } else if (typeof window) {\n window.dispatchEvent(\n new CustomEvent(\"imjoy_remote_api_ready\", { detail: api })\n );\n }\n });\n\n let connected = false;\n const connectedHandlers = [];\n\n const launchConnected = function() {\n if (!connected) {\n connected = true;\n\n let handler;\n while ((handler = connectedHandlers.pop())) {\n handler();\n }\n }\n };\n\n const checkHandler = function(handler) {\n const type = typeof handler;\n if (type !== \"function\") {\n const msg =\n \"A function may only be subsribed to the event, \" +\n type +\n \" was provided instead\";\n throw new Error(msg);\n }\n return handler;\n };\n\n return rpc;\n}\n","/**\n * Contains the routines loaded by the plugin iframe under web-browser\n * in case when worker failed to initialize\n *\n * Initializes the web environment version of the platform-dependent\n * connection object for the plugin site\n */\nimport { connectRPC } from \"./pluginCore.js\";\nimport { API_VERSION } from \"./rpc.js\";\nimport { loadRequirementsInWindow, MessageEmitter, randId } from \"./utils.js\";\n// Create a new, plain <span> element\nfunction _htmlToElement(html) {\n var template = document.createElement(\"template\");\n html = html.trim(); // Never return a text node of whitespace as the result\n template.innerHTML = html;\n return template.content.firstChild;\n}\n\nconst _inWebWorker =\n typeof WorkerGlobalScope !== \"undefined\" && self instanceof WorkerGlobalScope;\n\nasync function executeEsModule(content) {\n const dataUri =\n \"data:text/javascript;charset=utf-8,\" + encodeURIComponent(content);\n await import(/* webpackIgnore: true */ dataUri);\n}\n\nexport class Connection extends MessageEmitter {\n constructor(config) {\n super(config && config.debug);\n this.config = config || {};\n this.peer_id = randId();\n }\n connect() {\n this.config.target_origin = this.config.target_origin || \"*\";\n // this will call handleEvent function\n if (this.config.broadcastChannel) {\n this.broadcastChannel = new BroadcastChannel(\n this.config.broadcastChannel\n );\n } else {\n this.broadcastChannel = null;\n }\n if (this.broadcastChannel)\n this.broadcastChannel.addEventListener(\"message\", this);\n else globalThis.addEventListener(\"message\", this);\n this.emit({\n type: \"initialized\",\n config: this.config,\n origin: globalThis.location.origin,\n peer_id: this.peer_id\n });\n this._fire(\"connected\");\n }\n handleEvent(e) {\n if (\n e.type === \"message\" &&\n (this.broadcastChannel ||\n this.config.target_origin === \"*\" ||\n !e.origin ||\n e.origin === this.config.target_origin)\n ) {\n if (e.data.peer_id === this.peer_id) {\n this._fire(e.data.type, e.data);\n } else if (this.config.debug) {\n console.log(\n `connection peer id mismatch ${e.data.peer_id} !== ${this.peer_id}`\n );\n }\n }\n }\n disconnect() {\n this._fire(\"beforeDisconnect\");\n globalThis.removeEventListener(\"message\", this);\n this._fire(\"disconnected\");\n }\n emit(data) {\n let transferables;\n if (this.broadcastChannel) this.broadcastChannel.postMessage(data);\n else {\n if (data.__transferables__) {\n transferables = data.__transferables__;\n delete data.__transferables__;\n } else if (_inWebWorker) self.postMessage(data, transferables);\n else parent.postMessage(data, this.config.target_origin, transferables);\n }\n }\n async execute(code) {\n try {\n if (code.type === \"requirements\") {\n await loadRequirementsInWindow(code.requirements);\n } else if (code.type === \"script\") {\n if (code.src) {\n var script_node = document.createElement(\"script\");\n script_node.setAttribute(\"type\", code.attrs.type);\n script_node.setAttribute(\"src\", code.src);\n document.head.appendChild(script_node);\n } else {\n if (code.content && code.attrs.lang === \"javascript\") {\n // document.addEventListener(\"DOMContentLoaded\", function(){\n if (code.attrs.type === \"module\") {\n await executeEsModule(code.content);\n } else {\n eval(code.content);\n }\n // });\n } else {\n var node = document.createElement(\"script\");\n for (let k in code.attrs) {\n node.setAttribute(k, code.attrs[k]);\n }\n node.appendChild(document.createTextNode(code.content));\n document.body.appendChild(node);\n }\n }\n } else if (code.type === \"style\") {\n const style_node = document.createElement(\"style\");\n if (code.src) {\n style_node.src = code.src;\n }\n style_node.innerHTML = code.content;\n document.head.appendChild(style_node);\n } else if (code.type === \"link\") {\n const link_node_ = document.createElement(\"link\");\n if (code.rel) {\n link_node_.rel = code.rel;\n }\n if (code.href) {\n link_node_.href = code.href;\n }\n if (code.attrs && code.attrs.type) {\n link_node_.type = code.attrs.type;\n }\n document.head.appendChild(link_node_);\n } else if (code.type === \"html\") {\n document.body.appendChild(_htmlToElement(code.content));\n } else {\n throw \"unsupported code type.\";\n }\n if (_inWebWorker) self.postMessage({ type: \"executed\" });\n else parent.postMessage({ type: \"executed\" }, this.config.target_origin);\n } catch (e) {\n console.error(\"failed to execute scripts: \", code, e);\n if (_inWebWorker)\n self.postMessage({ type: \"executed\", error: e.stack || String(e) });\n else\n parent.postMessage(\n { type: \"executed\", error: e.stack || String(e) },\n this.config.target_origin\n );\n }\n }\n}\n\nexport default function setupIframe(config) {\n config = config || {};\n config.dedicated_thread = false;\n config.lang = \"javascript\";\n config.api_version = API_VERSION;\n const conn = new Connection(config);\n connectRPC(conn, config);\n conn.connect();\n}\n","/**\n * Contains the RPC object used both by the application\n * site, and by each plugin\n */\nimport {\n randId,\n typedArrayToDtype,\n dtypeToTypedArray,\n MessageEmitter\n} from \"./utils.js\";\n\nexport const API_VERSION = \"0.2.3\";\n\nconst ArrayBufferView = Object.getPrototypeOf(\n Object.getPrototypeOf(new Uint8Array())\n).constructor;\n\nfunction _appendBuffer(buffer1, buffer2) {\n const tmp = new Uint8Array(buffer1.byteLength + buffer2.byteLength);\n tmp.set(new Uint8Array(buffer1), 0);\n tmp.set(new Uint8Array(buffer2), buffer1.byteLength);\n return tmp.buffer;\n}\n\nfunction indexObject(obj, is) {\n if (!is) throw new Error(\"undefined index\");\n if (typeof is === \"string\") return indexObject(obj, is.split(\".\"));\n else if (is.length === 0) return obj;\n else return indexObject(obj[is[0]], is.slice(1));\n}\n\n/**\n * RPC object represents a single site in the\n * communication protocol between the application and the plugin\n *\n * @param {Object} connection a special object allowing to send\n * and receive messages from the opposite site (basically it\n * should only provide send() and onMessage() methods)\n */\nexport class RPC extends MessageEmitter {\n constructor(connection, config, codecs) {\n super(config && config.debug);\n this._connection = connection;\n this.config = config || {};\n this._codecs = codecs || {};\n this._object_store = {};\n this._method_weakmap = new WeakMap();\n this._object_weakmap = new WeakMap();\n this._local_api = null;\n this._remote_set = false;\n // make sure there is an execute function\n const name = this.config.name;\n this._connection.execute =\n this._connection.execute ||\n function() {\n throw new Error(`connection.execute not implemented (in \"${name}\")`);\n };\n this._store = new ReferenceStore();\n this._method_refs = new ReferenceStore();\n this._method_refs.onReady(() => {\n this._fire(\"remoteIdle\");\n });\n this._method_refs.onBusy(() => {\n this._fire(\"remoteBusy\");\n });\n this._setupMessageHanlders();\n }\n\n init() {\n this._connection.emit({\n type: \"initialized\",\n config: this.config,\n peer_id: this._connection.peer_id\n });\n }\n\n setConfig(config) {\n if (config)\n for (const k of Object.keys(config)) {\n this.config[k] = config[k];\n }\n }\n /**\n * Set a handler to be called when received a responce from the\n * remote site reporting that the previously provided interface\n * has been successfully set as remote for that site\n *\n * @param {Function} handler\n */\n\n getRemoteCallStack() {\n return this._method_refs.getStack();\n }\n\n /**\n * @returns {Object} set of remote interface methods\n */\n getRemote() {\n return this._remote_interface;\n }\n\n /**\n * Sets the interface of this site making it available to the\n * remote site by sending a message with a set of methods names\n *\n * @param {Object} _interface to set\n */\n setInterface(_interface, config) {\n config = config || {};\n this.config.name = config.name || this.config.name;\n this.config.description = config.description || this.config.description;\n if (this.config.forwarding_functions) {\n for (let func_name of this.config.forwarding_functions) {\n const _remote = this._remote_interface;\n if (_remote[func_name]) {\n if (_interface.constructor === Object) {\n if (!_interface[func_name]) {\n _interface[func_name] = (...args) => {\n _remote[func_name](...args);\n };\n }\n } else if (_interface.constructor.constructor === Function) {\n if (!_interface.constructor.prototype[func_name]) {\n _interface.constructor.prototype[func_name] = (...args) => {\n _remote[func_name](...args);\n };\n }\n }\n }\n }\n }\n this._local_api = _interface;\n if (!this._remote_set) this._fire(\"interfaceAvailable\");\n else this.sendInterface();\n return new Promise(resolve => {\n this.once(\"interfaceSetAsRemote\", resolve);\n });\n }\n\n /**\n * Sends the actual interface to the remote site upon it was\n * updated or by a special request of the remote site\n */\n sendInterface() {\n if (!this._local_api) {\n throw new Error(\"interface is not set.\");\n }\n this._encode(this._local_api, true).then(api => {\n this._connection.emit({ type: \"setInterface\", api: api });\n });\n }\n\n _disposeObject(objectId) {\n if (this._object_store[objectId]) {\n delete this._object_store[objectId];\n } else {\n throw new Error(`Object (id=${objectId}) not found.`);\n }\n }\n\n disposeObject(obj) {\n return new Promise((resolve, reject) => {\n if (this._object_weakmap.has(obj)) {\n const objectId = this._object_weakmap.get(obj);\n this._connection.once(\"disposed\", data => {\n if (data.error) reject(new Error(data.error));\n else resolve();\n });\n this._connection.emit({\n type: \"disposeObject\",\n object_id: objectId\n });\n } else {\n throw new Error(\"Invalid object\");\n }\n });\n }\n\n /**\n * Handles a message from the remote site\n */\n _setupMessageHanlders() {\n this._connection.on(\"init\", this.init);\n this._connection.on(\"execute\", data => {\n Promise.resolve(this._connection.execute(data.code))\n .then(() => {\n this._connection.emit({ type: \"executed\" });\n })\n .catch(e => {\n console.error(e);\n this._connection.emit({\n type: \"executed\",\n error: String(e)\n });\n });\n });\n\n this._connection.on(\"method\", async data => {\n let resolve, reject, method, method_this, args, result;\n try {\n if (data.promise) {\n [resolve, reject] = await this._unwrap(data.promise, false);\n }\n const _interface = this._object_store[data.object_id];\n method = indexObject(_interface, data.name);\n if (data.name.includes(\".\")) {\n const tmp = data.name.split(\".\");\n const intf_index = tmp.slice(0, tmp.length - 1).join(\".\");\n method_this = indexObject(_interface, intf_index);\n } else {\n method_this = _interface;\n }\n args = await this._unwrap(data.args, true);\n if (data.promise) {\n result = method.apply(method_this, args);\n if (\n result instanceof Promise ||\n (method.constructor && method.constructor.name === \"AsyncFunction\")\n ) {\n result.then(resolve).catch(reject);\n } else {\n resolve(result);\n }\n } else {\n method.apply(method_this, args);\n }\n } catch (err) {\n console.error(this.config.name, err);\n if (reject) {\n reject(err);\n }\n }\n });\n\n this._connection.on(\"callback\", async data => {\n let resolve, reject, method, args, result;\n try {\n if (data.promise) {\n [resolve, reject] = await this._unwrap(data.promise, false);\n }\n if (data.promise) {\n method = this._store.fetch(data.id);\n args = await this._unwrap(data.args, true);\n if (!method) {\n throw new Error(\n \"Callback function can only called once, if you want to call a function for multiple times, please make it as a plugin api function. See https://imjoy.io/docs for more details.\"\n );\n }\n result = method.apply(null, args);\n if (\n result instanceof Promise ||\n (method.constructor && method.constructor.name === \"AsyncFunction\")\n ) {\n result.then(resolve).catch(reject);\n } else {\n resolve(result);\n }\n } else {\n method = this._store.fetch(data.id);\n args = await this._unwrap(data.args, true);\n if (!method) {\n throw new Error(\n \"Please notice that callback function can only called once, if you want to call a function for multiple times, please make it as a plugin api function. See https://imjoy.io/docs for more details.\"\n );\n }\n method.apply(null, args);\n }\n } catch (err) {\n console.error(this.config.name, err);\n if (reject) {\n reject(err);\n }\n }\n });\n this._connection.on(\"disposeObject\", data => {\n try {\n this._disposeObject(data.object_id);\n this._connection.emit({\n type: \"disposed\"\n });\n } catch (e) {\n console.error(e);\n this._connection.emit({\n type: \"disposed\",\n error: String(e)\n });\n }\n });\n this._connection.on(\"setInterface\", data => {\n this._setRemoteInterface(data.api);\n });\n this._connection.on(\"getInterface\", () => {\n this._fire(\"getInterface\");\n if (this._local_api) {\n this.sendInterface();\n } else {\n this.once(\"interfaceAvailable\", () => {\n this.sendInterface();\n });\n }\n });\n this._connection.on(\"interfaceSetAsRemote\", () => {\n this._remote_set = true;\n this._fire(\"interfaceSetAsRemote\");\n });\n this._connection.on(\"disconnect\", () => {\n this._fire(\"beforeDisconnect\");\n this._connection.disconnect();\n this._fire(\"disconnected\");\n });\n }\n\n /**\n * Sends a requests to the remote site asking it to provide its\n * current interface\n */\n requestRemote() {\n this._connection.emit({ type: \"getInterface\" });\n }\n\n _ndarray(typedArray, shape, dtype) {\n const _dtype = typedArrayToDtype(typedArray);\n if (dtype && dtype !== _dtype) {\n throw \"dtype doesn't match the type of the array: \" +\n _dtype +\n \" != \" +\n dtype;\n }\n shape = shape || [typedArray.length];\n return {\n _rtype: \"ndarray\",\n _rvalue: typedArray.buffer,\n _rshape: shape,\n _rdtype: _dtype\n };\n }\n\n /**\n * Sets the new remote interface provided by the other site\n *\n * @param {Array} names list of function names\n */\n _setRemoteInterface(api) {\n this._decode(api).then(intf => {\n // update existing interface instead of recreating it\n // this will preserve the object reference\n if (this._remote_interface) {\n // clear the interface\n for (let k in this._remote_interface) delete this._remote_interface[k];\n // then assign the new interfaces\n Object.assign(this._remote_interface, intf);\n } else this._remote_interface = intf;\n this._fire(\"remoteReady\");\n this._reportRemoteSet();\n });\n }\n\n /**\n * Generates the wrapped function corresponding to a single remote\n * method. When the generated function is called, it will send the\n * corresponding message to the remote site asking it to execute\n * the particular method of its interface\n *\n * @param {String} name of the remote method\n *\n * @returns {Function} wrapped remote method\n */\n _genRemoteMethod(targetId, name, objectId) {\n const me = this;\n const remoteMethod = function() {\n return new Promise(async (resolve, reject) => {\n let id = null;\n try {\n id = me._method_refs.put(objectId ? objectId + \"/\" + name : name);\n const wrapped_resolve = function() {\n if (id !== null) me._method_refs.fetch(id);\n return resolve.apply(this, arguments);\n };\n const wrapped_reject = function() {\n if (id !== null) me._method_refs.fetch(id);\n return reject.apply(this, arguments);\n };\n\n const encodedPromise = await me._wrap([\n wrapped_resolve,\n wrapped_reject\n ]);\n\n // store the key id for removing them from the reference store together\n wrapped_resolve.__promise_pair = encodedPromise[1]._rvalue;\n wrapped_reject.__promise_pair = encodedPromise[0]._rvalue;\n\n let args = Array.prototype.slice.call(arguments);\n const argLength = args.length;\n // if the last argument is an object, mark it as kwargs\n const withKwargs =\n argLength > 0 &&\n typeof args[argLength - 1] === \"object\" &&\n args[argLength - 1] !== null &&\n args[argLength - 1]._rkwargs;\n if (withKwargs) delete args[argLength - 1]._rkwargs;\n if (\n name === \"register\" ||\n name === \"registerService\" ||\n name === \"register_service\" ||\n name === \"export\" ||\n name === \"on\"\n ) {\n args = await me._wrap(args, true);\n } else {\n args = await me._wrap(args);\n }\n const transferables = args.__transferables__;\n if (transferables) delete args.__transferables__;\n me._connection.emit(\n {\n type: \"method\",\n target_id: targetId,\n name: name,\n object_id: objectId,\n args: args,\n promise: encodedPromise,\n with_kwargs: withKwargs\n },\n transferables\n );\n } catch (e) {\n if (id) me._method_refs.fetch(id);\n reject(\n `Failed to exectue remote method (interface: ${objectId ||\n me.id}, method: ${name}), error: ${e}`\n );\n }\n });\n };\n remoteMethod.__remote_method = true;\n return remoteMethod;\n }\n\n /**\n * Sends a responce reporting that interface just provided by the\n * remote site was successfully set by this site as remote\n */\n _reportRemoteSet() {\n this._connection.emit({ type: \"interfaceSetAsRemote\" });\n }\n\n /**\n * Prepares the provided set of remote method arguments for\n * sending to the remote site, replaces all the callbacks with\n * identifiers\n *\n * @param {Array} args to wrap\n *\n * @returns {Array} wrapped arguments\n */\n async _encode(aObject, asInterface, objectId) {\n const aType = typeof aObject;\n if (\n aType === \"number\" ||\n aType === \"string\" ||\n aType === \"boolean\" ||\n aObject === null ||\n aObject === undefined ||\n aObject instanceof ArrayBuffer\n ) {\n return aObject;\n }\n\n let bObject;\n if (typeof aObject === \"function\") {\n if (asInterface) {\n if (!objectId) throw new Error(\"objectId is not specified.\");\n bObject = {\n _rtype: \"interface\",\n _rtarget_id: this._connection.peer_id,\n _rintf: objectId,\n _rvalue: asInterface\n };\n this._method_weakmap.set(aObject, bObject);\n } else if (this._method_weakmap.has(aObject)) {\n bObject = this._method_weakmap.get(aObject);\n } else {\n const cid = this._store.put(aObject);\n bObject = {\n _rtype: \"callback\",\n _rtarget_id: this._connection.peer_id,\n _rname: (aObject.constructor && aObject.constructor.name) || cid,\n _rvalue: cid\n };\n }\n return bObject;\n }\n\n // skip if already encoded\n if (aObject.constructor instanceof Object && aObject._rtype) {\n // make sure the interface functions are encoded\n if (aObject._rintf) {\n const temp = aObject._rtype;\n delete aObject._rtype;\n\n bObject = await this._encode(aObject, asInterface, objectId);\n bObject._rtype = temp;\n } else {\n bObject = aObject;\n }\n return bObject;\n }\n\n const transferables = [];\n const _transfer = aObject._transfer;\n const isarray = Array.isArray(aObject);\n\n for (let tp of Object.keys(this._codecs)) {\n const codec = this._codecs[tp];\n if (codec.encoder && aObject instanceof codec.type) {\n // TODO: what if multiple encoders found\n let encodedObj = await Promise.resolve(codec.encoder(aObject));\n if (encodedObj && !encodedObj._rtype) encodedObj._rtype = codec.name;\n // encode the functions in the interface object\n if (encodedObj && encodedObj._rintf) {\n const temp = encodedObj._rtype;\n delete encodedObj._rtype;\n encodedObj = await this._encode(encodedObj, asInterface, objectId);\n encodedObj._rtype = temp;\n }\n bObject = encodedObj;\n return bObject;\n }\n }\n\n if (\n /*global tf*/\n typeof tf !== \"undefined\" &&\n tf.Tensor &&\n aObject instanceof tf.Tensor\n ) {\n const v_buffer = aObject.dataSync();\n if (aObject._transfer || _transfer) {\n transferables.push(v_buffer.buffer);\n delete aObject._transfer;\n }\n bObject = {\n _rtype: \"ndarray\",\n _rvalue: v_buffer.buffer,\n _rshape: aObject.shape,\n _rdtype: aObject.dtype\n };\n } else if (\n /*global nj*/\n typeof nj !== \"undefined\" &&\n nj.NdArray &&\n aObject instanceof nj.NdArray\n ) {\n const dtype = typedArrayToDtype(aObject.selection.data);\n if (aObject._transfer || _transfer) {\n transferables.push(aObject.selection.data.buffer);\n delete aObject._transfer;\n }\n bObject = {\n _rtype: \"ndarray\",\n _rvalue: aObject.selection.data.buffer,\n _rshape: aObject.shape,\n _rdtype: dtype\n };\n } else if (aObject instanceof Error) {\n console.error(aObject);\n bObject = { _rtype: \"error\", _rvalue: aObject.toString() };\n } else if (typeof File !== \"undefined\" && aObject instanceof File) {\n bObject = {\n _rtype: \"file\",\n _rvalue: aObject,\n _rpath: aObject._path || aObject.webkitRelativePath\n };\n }\n // send objects supported by structure clone algorithm\n // https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm\n else if (\n aObject !== Object(aObject) ||\n aObject instanceof Boolean ||\n aObject instanceof String ||\n aObject instanceof Date ||\n aObject instanceof RegExp ||\n aObject instanceof ImageData ||\n (typeof FileList !== \"undefined\" && aObject instanceof FileList) ||\n (typeof FileSystemDirectoryHandle !== \"undefined\" &&\n aObject instanceof FileSystemDirectoryHandle) ||\n (typeof FileSystemFileHandle !== \"undefined\" &&\n aObject instanceof FileSystemFileHandle) ||\n (typeof FileSystemHandle !== \"undefined\" &&\n aObject instanceof FileSystemHandle) ||\n (typeof FileSystemWritableFileStream !== \"undefined\" &&\n aObject instanceof FileSystemWritableFileStream)\n ) {\n bObject = aObject;\n // TODO: avoid object such as DynamicPlugin instance.\n } else if (typeof File !== \"undefined\" && aObject instanceof File) {\n bObject = {\n _rtype: \"file\",\n _rname: aObject.name,\n _rmime: aObject.type,\n _rvalue: aObject,\n _rpath: aObject._path || aObject.webkitRelativePath\n };\n } else if (aObject instanceof Blob) {\n bObject = { _rtype: \"blob\", _rvalue: aObject };\n } else if (aObject instanceof ArrayBufferView) {\n if (aObject._transfer || _transfer) {\n transferables.push(aObject.buffer);\n delete aObject._transfer;\n }\n const dtype = typedArrayToDtype(aObject);\n bObject = {\n _rtype: \"typedarray\",\n _rvalue: aObject.buffer,\n _rdtype: dtype\n };\n } else if (aObject instanceof DataView) {\n if (aObject._transfer || _transfer) {\n transferables.push(aObject.buffer);\n delete aObject._transfer;\n }\n bObject = { _rtype: \"memoryview\", _rvalue: aObject.buffer };\n } else if (aObject instanceof Set) {\n bObject = {\n _rtype: \"set\",\n _rvalue: await this._encode(Array.from(aObject), asInterface)\n };\n } else if (aObject instanceof Map) {\n bObject = {\n _rtype: \"orderedmap\",\n _rvalue: await this._encode(Array.from(aObject), asInterface)\n };\n } else if (\n aObject.constructor instanceof Object ||\n Array.isArray(aObject)\n ) {\n bObject = isarray ? [] : {};\n let keys;\n // an object/array\n if (aObject.constructor === Object || Array.isArray(aObject)) {\n keys = Object.keys(aObject);\n }\n // a class\n else if (aObject.constructor === Function) {\n throw new Error(\"Please instantiate the class before exportting it.\");\n }\n // instance of a class\n else if (aObject.constructor.constructor === Function) {\n keys = Object.getOwnPropertyNames(\n Object.getPrototypeOf(aObject)\n ).concat(Object.keys(aObject));\n // TODO: use a proxy object to represent the actual object\n // always encode class instance as interface\n asInterface = true;\n } else {\n throw Error(\"Unsupported interface type\");\n }\n\n let hasFunction = false;\n // encode interfaces\n if (aObject._rintf || asInterface) {\n if (!objectId) {\n if (typeof aObject._rintf === \"string\" && aObject._rintf.length > 0) {\n objectId = aObject._rintf; // enable custom object id\n } else {\n objectId = randId();\n }\n // Note: object with the same id will be overwritten\n if (this._object_store[objectId])\n console.warn(\n `Overwritting interface object with the same id: ${objectId}`\n );\n this._object_store[objectId] = aObject;\n }\n for (let k of keys) {\n if (k === \"constructor\") continue;\n if (k.startsWith(\"_\")) {\n continue;\n }\n bObject[k] = await this._encode(\n aObject[k],\n typeof asInterface === \"string\" ? asInterface + \".\" + k : k,\n objectId\n );\n if (typeof aObject[k] === \"function\") {\n hasFunction = true;\n }\n }\n // object id for dispose the object remotely\n if (hasFunction) bObject._rintf = objectId;\n // remove interface when closed\n if (aObject.on && typeof aObject.on === \"function\") {\n aObject.on(\"close\", () => {\n delete this._object_store[objectId];\n });\n }\n } else {\n for (let k of keys) {\n if ([\"hasOwnProperty\", \"constructor\"].includes(k)) continue;\n bObject[k] = await this._encode(aObject[k]);\n }\n }\n // for example, browserFS object\n } else if (typeof aObject === \"object\") {\n const keys = Object.getOwnPropertyNames(\n Object.getPrototypeOf(aObject)\n ).concat(Object.keys(aObject));\n const objectId = randId();\n\n for (let k of keys) {\n if ([\"hasOwnProperty\", \"constructor\"].includes(k)) continue;\n // encode as interface\n bObject[k] = await this._encode(aObject[k], k, bObject);\n }\n // object id, used for dispose the object\n bObject._rintf = objectId;\n } else {\n throw \"imjoy-rpc: Unsupported data type:\" + aObject;\n }\n\n if (transferables.length > 0) {\n bObject.__transferables__ = transferables;\n }\n if (!bObject) {\n throw new Error(\"Failed to encode object\");\n }\n return bObject;\n }\n\n async _decode(aObject, withPromise) {\n if (!aObject) {\n return aObject;\n }\n let bObject;\n if (aObject[\"_rtype\"]) {\n if (\n this._codecs[aObject._rtype] &&\n this._codecs[aObject._rtype].decoder\n ) {\n if (aObject._rintf) {\n const temp = aObject._rtype;\n delete aObject._rtype;\n aObject = await this._decode(aObject, withPromise);\n aObject._rtype = temp;\n }\n bObject = await Promise.resolve(\n this._codecs[aObject._rtype].decoder(aObject)\n );\n } else if (aObject._rtype === \"callback\") {\n bObject = this._genRemoteCallback(\n aObject._rtarget_id,\n aObject._rvalue,\n withPromise\n );\n } else if (aObject._rtype === \"interface\") {\n bObject = this._genRemoteMethod(\n aObject._rtarget_id,\n aObject._rvalue,\n aObject._rintf\n );\n } else if (aObject._rtype === \"ndarray\") {\n /*global nj tf*/\n //create build array/tensor if used in the plugin\n if (typeof nj !== \"undefined\" && nj.array) {\n if (Array.isArray(aObject._rvalue)) {\n aObject._rvalue = aObject._rvalue.reduce(_appendBuffer);\n }\n bObject = nj\n .array(new Uint8(aObject._rvalue), aObject._rdtype)\n .reshape(aObject._rshape);\n } else if (typeof tf !== \"undefined\" && tf.Tensor) {\n if (Array.isArray(aObject._rvalue)) {\n aObject._rvalue = aObject._rvalue.reduce(_appendBuffer);\n }\n const arraytype = dtypeToTypedArray[aObject._rdtype];\n bObject = tf.tensor(\n new arraytype(aObject._rvalue),\n aObject._rshape,\n aObject._rdtype\n );\n } else {\n //keep it as regular if transfered to the main app\n bObject = aObject;\n }\n } else if (aObject._rtype === \"error\") {\n bObject = new Error(aObject._rvalue);\n } else if (aObject._rtype === \"file\") {\n if (aObject._rvalue instanceof File) {\n bObject = aObject._rvalue;\n //patch _path\n bObject._path = aObject._rpath;\n } else {\n bObject = new File([aObject._rvalue], aObject._rname, {\n type: aObject._rmime\n });\n bObject._path = aObject._rpath;\n }\n } else if (aObject._rtype === \"typedarray\") {\n const arraytype = dtypeToTypedArray[aObject._rdtype];\n if (!arraytype)\n throw new Error(\"unsupported dtype: \" + aObject._rdtype);\n bObject = new arraytype(aObject._rvalue);\n } else if (aObject._rtype === \"memoryview\") {\n bObject = new DataView(aObject._rvalue);\n } else if (aObject._rtype === \"blob\") {\n if (aObject._rvalue instanceof Blob) {\n bObject = aObject._rvalue;\n } else {\n bObject = new Blob([aObject._rvalue], { type: aObject._rmime });\n }\n } else if (aObject._rtype === \"orderedmap\") {\n bObject = new Map(await this._decode(aObject._rvalue, withPromise));\n } else if (aObject._rtype === \"set\") {\n bObject = new Set(await this._decode(aObject._rvalue, withPromise));\n } else {\n // make sure all the interface functions are decoded\n if (aObject._rintf) {\n const temp = aObject._rtype;\n delete aObject._rtype;\n bObject = await this._decode(aObject, withPromise);\n bObject._rtype = temp;\n } else bObject = aObject;\n }\n } else if (aObject.constructor === Object || Array.isArray(aObject)) {\n const isarray = Array.isArray(aObject);\n bObject = isarray ? [] : {};\n for (let k of Object.keys(aObject)) {\n if (isarray || aObject.hasOwnProperty(k)) {\n const v = aObject[k];\n bObject[k] = await this._decode(v, withPromise);\n }\n }\n } else {\n bObject = aObject;\n }\n if (bObject === undefined) {\n throw new Error(\"Failed to decode object\");\n }\n // store the object id for dispose\n if (aObject._rintf) {\n this._object_weakmap.set(bObject, aObject._rintf);\n }\n return bObject;\n }\n\n async _wrap(args, asInterface) {\n return await this._encode(args, asInterface);\n }\n\n /**\n * Unwraps the set of arguments delivered from the remote site,\n * replaces all callback identifiers with a function which will\n * initiate sending that callback identifier back to other site\n *\n * @param {Object} args to unwrap\n *\n * @param {Boolean} withPromise is true means this the callback should contain a promise\n *\n * @returns {Array} unwrapped args\n */\n async _unwrap(args, withPromise) {\n return await this._decode(args, withPromise);\n }\n\n /**\n * Generates the wrapped function corresponding to a single remote\n * callback. When the generated function is called, it will send\n * the corresponding message to the remote site asking it to\n * execute the particular callback previously saved during a call\n * by the remote site a method from the interface of this site\n *\n * @param {Number} id of the remote callback to execute\n * @param {Number} argNum argument index of the callback\n * @param {Boolean} withPromise is true means this the callback should contain a promise\n *\n * @returns {Function} wrapped remote callback\n */\n _genRemoteCallback(targetId, cid, withPromise) {\n const me = this;\n let remoteCallback;\n if (withPromise) {\n remoteCallback = function() {\n return new Promise(async (resolve, reject) => {\n const args = await me._wrap(Array.prototype.slice.call(arguments));\n const argLength = args.length;\n // if the last argument is an object, mark it as kwargs\n const withKwargs =\n argLength > 0 &&\n typeof args[argLength - 1] === \"object\" &&\n args[argLength - 1] !== null &&\n args[argLength - 1]._rkwargs;\n if (withKwargs) delete args[argLength - 1]._rkwargs;\n const transferables = args.__transferables__;\n if (transferables) delete args.__transferables__;\n\n const encodedPromise = await me._wrap([resolve, reject]);\n // store the key id for removing them from the reference store together\n resolve.__promise_pair = encodedPromise[1]._rvalue;\n reject.__promise_pair = encodedPromise[0]._rvalue;\n try {\n me._connection.emit(\n {\n type: \"callback\",\n target_id: targetId,\n id: cid,\n args: args,\n promise: encodedPromise,\n with_kwargs: withKwargs\n },\n transferables\n );\n } catch (e) {\n reject(`Failed to exectue remote callback ( id: ${cid}).`);\n }\n });\n };\n return remoteCallback;\n } else {\n remoteCallback = async function() {\n const args = await me._wrap(Array.prototype.slice.call(arguments));\n const argLength = args.length;\n // if the last argument is an object, mark it as kwargs\n const withKwargs =\n argLength > 0 &&\n typeof args[argLength - 1] === \"object\" &&\n args[argLength - 1] !== null &&\n args[argLength - 1]._rkwargs;\n if (withKwargs) delete args[argLength - 1]._rkwargs;\n const transferables = args.__transferables__;\n if (transferables) delete args.__transferables__;\n return me._connection.emit(\n {\n type: \"callback\",\n target_id: targetId,\n id: cid,\n args: args,\n with_kwargs: withKwargs\n },\n transferables\n );\n };\n return remoteCallback;\n }\n }\n\n reset() {\n this._event_handlers = {};\n this._once_handlers = {};\n this._remote_interface = null;\n this._object_store = {};\n this._method_weakmap = new WeakMap();\n this._object_weakmap = new WeakMap();\n this._local_api = null;\n this._store = new ReferenceStore();\n this._method_refs = new ReferenceStore();\n }\n\n /**\n * Sends the notification message and breaks the connection\n */\n disconnect() {\n this._connection.emit({ type: \"disconnect\" });\n this.reset();\n setTimeout(() => {\n this._connection.disconnect();\n }, 2000);\n }\n}\n\n/**\n * ReferenceStore is a special object which stores other objects\n * and provides the references (number) instead. This reference\n * may then be sent over a json-based communication channel (IPC\n * to another Node.js process or a message to the Worker). Other\n * site may then provide the reference in the responce message\n * implying the given object should be activated.\n *\n * Primary usage for the ReferenceStore is a storage for the\n * callbacks, which therefore makes it possible to initiate a\n * callback execution by the opposite site (which normally cannot\n * directly execute functions over the communication channel).\n *\n * Each stored object can only be fetched once and is not\n * available for the second time. Each stored object must be\n * fetched, since otherwise it will remain stored forever and\n * consume memory.\n *\n * Stored object indeces are simply the numbers, which are however\n * released along with the objects, and are later reused again (in\n * order to postpone the overflow, which should not likely happen,\n * but anyway).\n */\nclass ReferenceStore {\n constructor() {\n this._store = {}; // stored object\n this._indices = [0]; // smallest available indices\n this._readyHandler = function() {};\n this._busyHandler = function() {};\n this._readyHandler();\n }\n\n /**\n * call handler when the store is empty\n *\n * @param {FUNCTION} id of a handler\n */\n onReady(readyHandler) {\n this._readyHandler = readyHandler || function() {};\n }\n\n /**\n * call handler when the store is not empty\n *\n * @param {FUNCTION} id of a handler\n */\n onBusy(busyHandler) {\n this._busyHandler = busyHandler || function() {};\n }\n\n /**\n * get the length of the store\n *\n */\n getStack() {\n return Object.keys(this._store).length;\n }\n\n /**\n * @function _genId() generates the new reference id\n *\n * @returns {Number} smallest available id and reserves it\n */\n _genId() {\n let id;\n if (this._indices.length === 1) {\n id = this._indices[0]++;\n } else {\n id = this._indices.shift();\n }\n\n return id;\n }\n\n /**\n * Releases the given reference id so that it will be available by\n * another object stored\n *\n * @param {Number} id to release\n */\n _releaseId(id) {\n for (let i = 0; i < this._indices.length; i++) {\n if (id < this._indices[i]) {\n this._indices.splice(i, 0, id);\n break;\n }\n }\n\n // cleaning-up the sequence tail\n for (let i = this._indices.length - 1; i >= 0; i--) {\n if (this._indices[i] - 1 === this._indices[i - 1]) {\n this._indices.pop();\n } else {\n break;\n }\n }\n }\n\n /**\n * Stores the given object and returns the refernce id instead\n *\n * @param {Object} obj to store\n *\n * @returns {Number} reference id of the stored object\n */\n put(obj) {\n if (this._busyHandler && Object.keys(this._store).length === 0) {\n this._busyHandler();\n }\n const id = this._genId();\n this._store[id] = obj;\n return id;\n }\n\n /**\n * Retrieves previously stored object and releases its reference\n *\n * @param {Number} id of an object to retrieve\n */\n fetch(id) {\n const obj = this._store[id];\n if (obj && !obj.__remote_method) {\n delete this._store[id];\n this._releaseId(id);\n if (this._readyHandler && Object.keys(this._store).length === 0) {\n this._readyHandler();\n }\n }\n if (obj && obj.__promise_pair) {\n this.fetch(obj.__promise_pair);\n }\n return obj;\n }\n}\n","export function randId() {\n return (\n Math.random()\n .toString(36)\n .substr(2, 10) + new Date().getTime()\n );\n}\n\nexport const dtypeToTypedArray = {\n int8: Int8Array,\n int16: Int16Array,\n int32: Int32Array,\n uint8: Uint8Array,\n uint16: Uint16Array,\n uint32: Uint32Array,\n float32: Float32Array,\n float64: Float64Array,\n array: Array\n};\n\nexport async function loadRequirementsInWindow(requirements) {\n function _importScript(url) {\n //url is URL of external file, implementationCode is the code\n //to be called from the file, location is the location to\n //insert the <script> element\n return new Promise((resolve, reject) => {\n var scriptTag = document.createElement(\"script\");\n scriptTag.src = url;\n scriptTag.type = \"text/javascript\";\n scriptTag.onload = resolve;\n scriptTag.onreadystatechange = function() {\n if (this.readyState === \"loaded\" || this.readyState === \"complete\") {\n resolve();\n }\n };\n scriptTag.onerror = reject;\n document.head.appendChild(scriptTag);\n });\n }\n\n // support importScripts outside web worker\n async function importScripts() {\n var args = Array.prototype.slice.call(arguments),\n len = args.length,\n i = 0;\n for (; i < len; i++) {\n await _importScript(args[i]);\n }\n }\n\n if (\n requirements &&\n (Array.isArray(requirements) || typeof requirements === \"string\")\n ) {\n try {\n var link_node;\n requirements =\n typeof requirements === \"string\" ? [requirements] : requirements;\n if (Array.isArray(requirements)) {\n for (var i = 0; i < requirements.length; i++) {\n if (\n requirements[i].toLowerCase().endsWith(\".css\") ||\n requirements[i].startsWith(\"css:\")\n ) {\n if (requirements[i].startsWith(\"css:\")) {\n requirements[i] = requirements[i].slice(4);\n }\n link_node = document.createElement(\"link\");\n link_node.rel = \"stylesheet\";\n link_node.href = requirements[i];\n document.head.appendChild(link_node);\n } else if (\n requirements[i].toLowerCase().endsWith(\".mjs\") ||\n requirements[i].startsWith(\"mjs:\")\n ) {\n // import esmodule\n if (requirements[i].startsWith(\"mjs:\")) {\n requirements[i] = requirements[i].slice(4);\n }\n await import(/* webpackIgnore: true */ requirements[i]);\n } else if (\n requirements[i].toLowerCase().endsWith(\".js\") ||\n requirements[i].startsWith(\"js:\")\n ) {\n if (requirements[i].startsWith(\"js:\")) {\n requirements[i] = requirements[i].slice(3);\n }\n await importScripts(requirements[i]);\n } else if (requirements[i].startsWith(\"http\")) {\n await importScripts(requirements[i]);\n } else if (requirements[i].startsWith(\"cache:\")) {\n //ignore cache\n } else {\n console.log(\"Unprocessed requirements url: \" + requirements[i]);\n }\n }\n } else {\n throw \"unsupported requirements definition\";\n }\n } catch (e) {\n throw \"failed to import required scripts: \" + requirements.toString();\n }\n }\n}\n\nexport async function loadRequirementsInWebworker(requirements) {\n if (\n requirements &&\n (Array.isArray(requirements) || typeof requirements === \"string\")\n ) {\n try {\n if (!Array.isArray(requirements)) {\n requirements = [requirements];\n }\n for (var i = 0; i < requirements.length; i++) {\n if (\n requirements[i].toLowerCase().endsWith(\".css\") ||\n requirements[i].startsWith(\"css:\")\n ) {\n throw \"unable to import css in a webworker\";\n } else if (\n requirements[i].toLowerCase().endsWith(\".js\") ||\n requirements[i].startsWith(\"js:\")\n ) {\n if (requirements[i].startsWith(\"js:\")) {\n requirements[i] = requirements[i].slice(3);\n }\n importScripts(requirements[i]);\n } else if (requirements[i].startsWith(\"http\")) {\n importScripts(requirements[i]);\n } else if (requirements[i].startsWith(\"cache:\")) {\n //ignore cache\n } else {\n console.log(\"Unprocessed requirements url: \" + requirements[i]);\n }\n }\n } catch (e) {\n throw \"failed to import required scripts: \" + requirements.toString();\n }\n }\n}\n\nexport function loadRequirements(requirements) {\n if (\n typeof WorkerGlobalScope !== \"undefined\" &&\n self instanceof WorkerGlobalScope\n ) {\n return loadRequirementsInWebworker(requirements);\n } else {\n return loadRequirementsInWindow(requirements);\n }\n}\n\nexport function normalizeConfig(config) {\n config.version = config.version || \"0.1.0\";\n config.description =\n config.description || `[TODO: add description for ${config.name} ]`;\n config.type = config.type || \"rpc-window\";\n config.id = config.id || randId();\n config.target_origin = config.target_origin || \"*\";\n config.allow_execution = config.allow_execution || false;\n // remove functions\n config = Object.keys(config).reduce((p, c) => {\n if (typeof config[c] !== \"function\") p[c] = config[c];\n return p;\n }, {});\n return config;\n}\nexport const typedArrayToDtypeMapping = {\n Int8Array: \"int8\",\n Int16Array: \"int16\",\n Int32Array: \"int32\",\n Uint8Array: \"uint8\",\n Uint16Array: \"uint16\",\n Uint32Array: \"uint32\",\n Float32Array: \"float32\",\n Float64Array: \"float64\",\n Array: \"array\"\n};\n\nconst typedArrayToDtypeKeys = [];\nfor (const arrType of Object.keys(typedArrayToDtypeMapping)) {\n typedArrayToDtypeKeys.push(eval(arrType));\n}\n\nexport function typedArrayToDtype(obj) {\n let dtype = typedArrayToDtypeMapping[obj.constructor.name];\n if (!dtype) {\n const pt = Object.getPrototypeOf(obj);\n for (const arrType of typedArrayToDtypeKeys) {\n if (pt instanceof arrType) {\n dtype = typedArrayToDtypeMapping[arrType.name];\n break;\n }\n }\n }\n return dtype;\n}\n\nfunction cacheUrlInServiceWorker(url) {\n return new Promise(function(resolve, reject) {\n const message = {\n command: \"add\",\n url: url\n };\n if (!navigator.serviceWorker || !navigator.serviceWorker.register) {\n reject(\"Service worker is not supported.\");\n return;\n }\n const messageChannel = new MessageChannel();\n messageChannel.port1.onmessage = function(event) {\n if (event.data && event.data.error) {\n reject(event.data.error);\n } else {\n resolve(event.data && event.data.result);\n }\n };\n\n if (navigator.serviceWorker && navigator.serviceWorker.controller) {\n navigator.serviceWorker.controller.postMessage(message, [\n messageChannel.port2\n ]);\n } else {\n reject(\"Service worker controller is not available\");\n }\n });\n}\n\nexport async function cacheRequirements(requirements) {\n requirements = requirements || [];\n if (!Array.isArray(requirements)) {\n requirements = [requirements];\n }\n for (let req of requirements) {\n //remove prefix\n if (req.startsWith(\"js:\")) req = req.slice(3);\n if (req.startsWith(\"css:\")) req = req.slice(4);\n if (req.startsWith(\"cache:\")) req = req.slice(6);\n if (!req.startsWith(\"http\")) continue;\n\n await cacheUrlInServiceWorker(req).catch(e => {\n console.error(e);\n });\n }\n}\n\nexport function setupServiceWorker(baseUrl, targetOrigin, cacheCallback) {\n // register service worker for offline access\n if (\"serviceWorker\" in navigator) {\n baseUrl = baseUrl || \"/\";\n navigator.serviceWorker.register(baseUrl + \"plugin-service-worker.js\").then(\n function(registration) {\n // Registration was successful\n console.log(\n \"ServiceWorker registration successful with scope: \",\n registration.scope\n );\n },\n function(err) {\n // registration failed :(\n console.log(\"ServiceWorker registration failed: \", err);\n }\n );\n targetOrigin = targetOrigin || \"*\";\n cacheCallback = cacheCallback || cacheRequirements;\n if (cacheCallback && typeof cacheCallback !== \"function\") {\n throw new Error(\"config.cache_requirements must be a function\");\n }\n window.addEventListener(\"message\", function(e) {\n if (targetOrigin === \"*\" || e.origin === targetOrigin) {\n const m = e.data;\n if (m.type === \"cacheRequirements\") {\n cacheCallback(m.requirements);\n }\n }\n });\n }\n}\n\n//#Source https://bit.ly/2neWfJ2\nexport function urlJoin(...args) {\n return args\n .join(\"/\")\n .replace(/[\\/]+/g, \"/\")\n .replace(/^(.+):\\//, \"$1://\")\n .replace(/^file:/, \"file:/\")\n .replace(/\\/(\\?|&|#[^!])/g, \"$1\")\n .replace(/\\?/g, \"&\")\n .replace(\"&\", \"?\");\n}\n\nexport class MessageEmitter {\n constructor(debug) {\n this._event_handlers = {};\n this._once_handlers = {};\n this._debug = debug;\n }\n emit() {\n throw new Error(\"emit is not implemented\");\n }\n on(event, handler) {\n if (!this._event_handlers[event]) {\n this._event_handlers[event] = [];\n }\n this._event_handlers[event].push(handler);\n }\n once(event, handler) {\n handler.___event_run_once = true;\n this.on(event, handler);\n }\n off(event, handler) {\n if (!event && !handler) {\n // remove all events handlers\n this._event_handlers = {};\n } else if (event && !handler) {\n // remove all hanlders for the event\n if (this._event_handlers[event]) this._event_handlers[event] = [];\n } else {\n // remove a specific handler\n if (this._event_handlers[event]) {\n const idx = this._event_handlers[event].indexOf(handler);\n if (idx >= 0) {\n this._event_handlers[event].splice(idx, 1);\n }\n }\n }\n }\n _fire(event, data) {\n if (this._event_handlers[event]) {\n var i = this._event_handlers[event].length;\n while (i--) {\n const handler = this._event_handlers[event][i];\n try {\n handler(data);\n } catch (e) {\n console.error(e);\n } finally {\n if (handler.___event_run_once) {\n this._event_handlers[event].splice(i, 1);\n }\n }\n }\n } else {\n if (this._debug) {\n console.warn(\"unhandled event\", event, data);\n }\n }\n }\n}\n"],"sourceRoot":""}