-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhypha-rpc-websocket.min.js.map
1 lines (1 loc) · 192 KB
/
hypha-rpc-websocket.min.js.map
1
{"version":3,"sources":["webpack://[name]/webpack/universalModuleDefinition","webpack://[name]/webpack/bootstrap","webpack://[name]/./src/hypha/utils.js","webpack://[name]/./node_modules/@msgpack/msgpack/dist.es5+esm/utils/prettyByte.mjs","webpack://[name]/./node_modules/@msgpack/msgpack/dist.es5+esm/ExtData.mjs","webpack://[name]/./node_modules/@msgpack/msgpack/dist.es5+esm/DecodeError.mjs","webpack://[name]/./node_modules/@msgpack/msgpack/dist.es5+esm/utils/int.mjs","webpack://[name]/./node_modules/@msgpack/msgpack/dist.es5+esm/timestamp.mjs","webpack://[name]/./node_modules/@msgpack/msgpack/dist.es5+esm/ExtensionCodec.mjs","webpack://[name]/./node_modules/@msgpack/msgpack/dist.es5+esm/utils/utf8.mjs","webpack://[name]/./node_modules/@msgpack/msgpack/dist.es5+esm/utils/typedArrays.mjs","webpack://[name]/./node_modules/@msgpack/msgpack/dist.es5+esm/CachedKeyDecoder.mjs","webpack://[name]/./node_modules/@msgpack/msgpack/dist.es5+esm/Decoder.mjs","webpack://[name]/./node_modules/@msgpack/msgpack/dist.es5+esm/decode.mjs","webpack://[name]/./node_modules/@msgpack/msgpack/dist.es5+esm/Encoder.mjs","webpack://[name]/./node_modules/@msgpack/msgpack/dist.es5+esm/encode.mjs","webpack://[name]/./src/hypha/rpc.js","webpack://[name]/./src/hypha/websocket-client.js"],"names":["root","factory","exports","module","define","amd","window","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","randId","Math","random","toString","substr","Date","getTime","dtypeToTypedArray","int8","Int8Array","int16","Int16Array","int32","Int32Array","uint8","Uint8Array","uint16","Uint16Array","uint32","Uint32Array","float32","Float32Array","float64","Float64Array","array","Array","async","loadRequirementsInWindow","requirements","_importScript","url","Promise","resolve","reject","scriptTag","document","createElement","src","type","onload","onreadystatechange","this","readyState","onerror","head","appendChild","importScripts","args","slice","arguments","len","length","isArray","link_node","toLowerCase","endsWith","startsWith","rel","href","import","console","log","e","loadRequirementsInWebworker","loadRequirements","WorkerGlobalScope","self","normalizeConfig","config","version","description","id","target_origin","allow_execution","keys","reduce","typedArrayToDtypeMapping","typedArrayToDtypeKeys","arrType","push","eval","typedArrayToDtype","obj","dtype","constructor","pt","getPrototypeOf","cacheUrlInServiceWorker","message","command","navigator","serviceWorker","register","messageChannel","MessageChannel","port1","onmessage","event","data","error","result","controller","postMessage","port2","cacheRequirements","req","catch","setupServiceWorker","baseUrl","targetOrigin","cacheCallback","then","registration","scope","err","Error","addEventListener","origin","assert","condition","urlJoin","join","replace","waitFor","prom","time","timer","race","_r","rej","setTimeout","finally","clearTimeout","MessageEmitter","debug","_event_handlers","_once_handlers","_debug","emit","on","handler","once","___event_run_once","off","idx","indexOf","splice","_fire","warn","prettyByte","byte","abs","padStart","extendStatics","ExtData","__extends","b","setPrototypeOf","__proto__","TypeError","String","__","DecodeError","_super","_this","proto","configurable","setInt64","view","offset","high","floor","low","setUint32","getInt64","getInt32","getUint32","timestampExtension","encode","msec","sec","nsec","nsecInSec","_a","rv","DataView","buffer","secHigh","secLow","encodeTimeSpecToTimestamp","decode","timeSpec","byteOffset","byteLength","nsec30AndSecHigh2","decodeTimestampToTimeSpec","ExtensionCodec","builtInEncoders","builtInDecoders","encoders","decoders","index","tryToEncode","context","encodeExt","decodeExt","defaultCodec","TEXT_ENCODING_AVAILABLE","process","env","TextEncoder","TextDecoder","utf8Count","str","strLength","pos","charCodeAt","extra","sharedTextEncoder","undefined","TEXT_ENCODER_THRESHOLD","utf8EncodeTE","encodeInto","output","outputOffset","subarray","set","utf8DecodeJs","bytes","inputOffset","end","units","byte1","byte2","byte3","unit","fromCharCode","apply","sharedTextDecoder","TEXT_DECODER_THRESHOLD","ensureUint8Array","ArrayBuffer","isView","from","CachedKeyDecoder","maxKeyLength","maxLengthPerKey","hit","miss","caches","canBeCached","find","FIND_CHUNK","_i","records_1","record","recordBytes","j","store","records","cachedValue","slicedCopyOfBytes","__awaiter","thisArg","_arguments","P","generator","fulfilled","step","next","rejected","done","__generator","body","f","y","g","_","label","sent","trys","ops","verb","iterator","v","op","pop","__asyncValues","asyncIterator","__values","settle","__await","__asyncGenerator","q","a","resume","fulfill","shift","EMPTY_VIEW","EMPTY_BYTES","DataViewIndexOutOfBoundsError","getInt8","MORE_DATA","sharedCachedKeyDecoder","Decoder","extensionCodec","maxStrLength","maxBinLength","maxArrayLength","maxMapLength","maxExtLength","keyDecoder","totalPos","headByte","stack","reinitializeState","setBuffer","bufferView","createDataView","appendBuffer","hasRemaining","remainingData","newData","newBuffer","size","createExtraByteError","posToShow","RangeError","doDecodeSync","decodeMulti","decodeAsync","stream","stream_1","stream_1_1","e_1","decoded","e_1_1","_b","_c","return","decodeArrayStream","decodeMultiAsync","decodeStream","isArrayHeaderRequired","arrayItemsLeft","stream_2","stream_2_1","e_2","e_3_1","e_3","readArraySize","complete","DECODE","readHeadByte","pushMapState","pushArrayState","decodeUtf8String","readF32","readF64","readU8","readU16","readU32","readU64","readI8","readI16","readI32","readI64","lookU8","lookU16","lookU32","decodeBinary","decodeExtension","state","position","keyType","map","readCount","headerOffset","stateIsMapKey","stringBytes","utf8DecodeTD","headOffset","extType","getUint8","getUint16","getInt16","getFloat32","getFloat64","defaultDecodeOptions","options","Encoder","maxDepth","initialBufferSize","sortKeys","forceFloat32","ignoreUndefined","forceIntegerToFloat","getUint8Array","doEncode","depth","encodeNil","encodeBoolean","encodeNumber","encodeString","encodeObject","ensureBufferSizeToWrite","sizeToWrite","requiredSize","resizeBuffer","newSize","newBytes","newView","writeU8","Number","isSafeInteger","writeU16","writeU32","writeU64","writeI8","writeI16","writeI32","writeI64","writeF32","writeF64","writeStringHeader","utf8EncodeJs","ext","encodeExtension","encodeArray","encodeBinary","encodeMap","writeU8a","object_1","item","countWithoutUndefined","count","keys_1","sort","keys_2","setUint8","values","setInt8","setUint16","setInt16","setInt32","setFloat32","setFloat64","setUint64","defaultEncodeOptions","API_VERSION","ArrayBufferView","_appendBuffer","buffer1","buffer2","tmp","indexObject","is","split","Timer","timeout","callback","_timeout","_callback","_args","_label","_task","started","start","clear","reset","RPC","connection","client_id","manager_id","default_context","codecs","method_timeout","max_message_buffer_size","super","_codecs","_client_id","_name","_connection_info","_workspace","_method_annotations","WeakMap","_manager_service","_max_message_buffer_size","_chunk_store","_method_timeout","_services","_object_store","services","add_service","require_context","visibility","ping","_ping","get_service","get_local_service","register_service","message_cache","_create_message","append","_append_message","_process_message","remove","_remove_message","_handle_method","emit_message","on_message","_emit_message","_on_message","_connection","_get_connection_info","get_manager_service","get_connection_info","reconnection_token","set_reconnection_token","reconnection_expires_in","info","_get_connection_info_task","exp","register_codec","k","msg","method","_generate_remote_method","_rtarget","_rmethod","_rpromise","heartbeat","overwrite","cache","buffers","buffersLengths","totalBufferlength","unit8Arr","unpacker","main","assign","to","user","JSON","parse","stringify","get_remote_service","get_all_local_services","service_id","ws","service","service_uri","includes","provider","_annotate_service_methods","aObject","object_id","run_in_executor","method_name","method_id","val","__rpc_object__","api","normApi","props","getOwnPropertyNames","concat","notify","workspace","_notify_service_update","_ndarray","typedArray","shape","_dtype","_rtype","_rvalue","_rshape","_rdtype","_encode_callback","session_id","clear_after_called","local_workspace","encoded","_get_session_store","_encode","interval","target_id","remote_services","message_id","total_size","chunk_num","ceil","start_byte","encoded_method","remote_parent","local_parent","remote_workspace","with_promise","remote_method","local_session_id","argLength","withKwargs","_rkwargs","main_message","extra_data","_encode_promise","message_package","msgpack_packb","CHUNK_SIZE","_send_chunks","update_client_info","get_client_info","heartbeat_task","parent","promise","_decode","session","setInterval","has","session_target_id","ctx","clearInterval","levels","last_index","level","aType","bObject","temp","annotation","__name__","isarray","tp","codec","encoder","encodedObj","tf","Tensor","v_buffer","dataSync","nj","NdArray","selection","Boolean","RegExp","ImageData","FileList","FileSystemDirectoryHandle","FileSystemFileHandle","FileSystemHandle","FileSystemWritableFileStream","Blob","_current_pos","_rnative","path","_path","webkitRelativePath","read","blob","ret","arrayBuffer","seek","Set","Map","decoder","Uint8","reshape","arraytype","tensor","WebsocketRPCConnection","server_url","token","_websocket","_handle_message","_reconnection_token","_server_url","WebSocket","binaryType","onclose","open","send","reason","close","connectToServer","clientId","rpc","connection_type","wm","export","getPlugin","query","listPlugins","listServices","disconnect","registerCodec"],"mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,uBAAwB,GAAIH,GACT,iBAAZC,QACdA,QAA8B,qBAAID,IAElCD,EAA2B,qBAAIC,IARjC,CASGK,QAAQ,WACX,O,YCTE,IAAIC,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUP,QAGnC,IAAIC,EAASI,EAAiBE,GAAY,CACzCC,EAAGD,EACHE,GAAG,EACHT,QAAS,IAUV,OANAU,EAAQH,GAAUI,KAAKV,EAAOD,QAASC,EAAQA,EAAOD,QAASM,GAG/DL,EAAOQ,GAAI,EAGJR,EAAOD,QA0Df,OArDAM,EAAoBM,EAAIF,EAGxBJ,EAAoBO,EAAIR,EAGxBC,EAAoBQ,EAAI,SAASd,EAASe,EAAMC,GAC3CV,EAAoBW,EAAEjB,EAASe,IAClCG,OAAOC,eAAenB,EAASe,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEV,EAAoBgB,EAAI,SAAStB,GACX,oBAAXuB,QAA0BA,OAAOC,aAC1CN,OAAOC,eAAenB,EAASuB,OAAOC,YAAa,CAAEC,MAAO,WAE7DP,OAAOC,eAAenB,EAAS,aAAc,CAAEyB,OAAO,KAQvDnB,EAAoBoB,EAAI,SAASD,EAAOE,GAE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0lB,MACP1lB,EAAOwZ,gBAAkB,SAErBL,EAAW+M,OACjB,MAAMM,EAAM,IAAItN,MAAIC,EAAY,CAC9BC,UAAWmN,EACXlN,WAAY,oBACZC,gBAAiB,CAAEmN,gBAAiB,aACpCtsB,KAAM6F,EAAO7F,KACbqf,eAAgBxZ,EAAOwZ,iBAEnBkN,QAAWF,EAAI1I,mBAAmB,6BA2BxC,OA1BA4I,EAAGF,IAAMA,EAqBTE,EAAGC,OAnBHrpB,eAAuBwhB,GACrBA,EAAI3e,GAAK,UACT2e,EAAI3kB,KAAO6F,EAAO7F,MAAQ2kB,EAAI3e,SACxBqmB,EAAIxL,iBAAiB8D,GAAK,IAiBlC4H,EAAGE,UAVHtpB,eAAyBupB,GACvB,aAAaH,EAAG5L,YAAY+L,EAAQ,aAUtCH,EAAGI,YAAcJ,EAAGK,aACpBL,EAAGM,WARH1pB,uBACQkpB,EAAIQ,mBACJ7N,EAAW6N,cAOnBN,EAAGO,cAAgBT,EAAIjK,eAAenhB,KAAKorB,GACpCE,I","file":"hypha-rpc-websocket.min.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(\"hyphaWebsocketClient\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"hyphaWebsocketClient\"] = factory();\n\telse\n\t\troot[\"hyphaWebsocketClient\"] = 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 = 28);\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\nexport function assert(condition, message) {\n if (!condition) {\n throw new Error(message || \"Assertion failed\");\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 function waitFor(prom, time, error) {\n let timer;\n return Promise.race([\n prom,\n new Promise(\n (_r, rej) =>\n (timer = setTimeout(() => {\n rej(error || \"Timeout Error\");\n }, time * 1000))\n )\n ]).finally(() => clearTimeout(timer));\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","export function prettyByte(byte) {\n return (byte < 0 ? \"-\" : \"\") + \"0x\" + Math.abs(byte).toString(16).padStart(2, \"0\");\n}\n//# sourceMappingURL=prettyByte.mjs.map","/**\n * ExtData is used to handle Extension Types that are not registered to ExtensionCodec.\n */\nvar ExtData = /** @class */ (function () {\n function ExtData(type, data) {\n this.type = type;\n this.data = data;\n }\n return ExtData;\n}());\nexport { ExtData };\n//# sourceMappingURL=ExtData.mjs.map","var __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nvar DecodeError = /** @class */ (function (_super) {\n __extends(DecodeError, _super);\n function DecodeError(message) {\n var _this = _super.call(this, message) || this;\n // fix the prototype chain in a cross-platform way\n var proto = Object.create(DecodeError.prototype);\n Object.setPrototypeOf(_this, proto);\n Object.defineProperty(_this, \"name\", {\n configurable: true,\n enumerable: false,\n value: DecodeError.name,\n });\n return _this;\n }\n return DecodeError;\n}(Error));\nexport { DecodeError };\n//# sourceMappingURL=DecodeError.mjs.map","// Integer Utility\nexport var UINT32_MAX = 4294967295;\n// DataView extension to handle int64 / uint64,\n// where the actual range is 53-bits integer (a.k.a. safe integer)\nexport function setUint64(view, offset, value) {\n var high = value / 4294967296;\n var low = value; // high bits are truncated by DataView\n view.setUint32(offset, high);\n view.setUint32(offset + 4, low);\n}\nexport function setInt64(view, offset, value) {\n var high = Math.floor(value / 4294967296);\n var low = value; // high bits are truncated by DataView\n view.setUint32(offset, high);\n view.setUint32(offset + 4, low);\n}\nexport function getInt64(view, offset) {\n var high = view.getInt32(offset);\n var low = view.getUint32(offset + 4);\n return high * 4294967296 + low;\n}\nexport function getUint64(view, offset) {\n var high = view.getUint32(offset);\n var low = view.getUint32(offset + 4);\n return high * 4294967296 + low;\n}\n//# sourceMappingURL=int.mjs.map","// https://github.com/msgpack/msgpack/blob/master/spec.md#timestamp-extension-type\nimport { DecodeError } from \"./DecodeError.mjs\";\nimport { getInt64, setInt64 } from \"./utils/int.mjs\";\nexport var EXT_TIMESTAMP = -1;\nvar TIMESTAMP32_MAX_SEC = 0x100000000 - 1; // 32-bit unsigned int\nvar TIMESTAMP64_MAX_SEC = 0x400000000 - 1; // 34-bit unsigned int\nexport function encodeTimeSpecToTimestamp(_a) {\n var sec = _a.sec, nsec = _a.nsec;\n if (sec >= 0 && nsec >= 0 && sec <= TIMESTAMP64_MAX_SEC) {\n // Here sec >= 0 && nsec >= 0\n if (nsec === 0 && sec <= TIMESTAMP32_MAX_SEC) {\n // timestamp 32 = { sec32 (unsigned) }\n var rv = new Uint8Array(4);\n var view = new DataView(rv.buffer);\n view.setUint32(0, sec);\n return rv;\n }\n else {\n // timestamp 64 = { nsec30 (unsigned), sec34 (unsigned) }\n var secHigh = sec / 0x100000000;\n var secLow = sec & 0xffffffff;\n var rv = new Uint8Array(8);\n var view = new DataView(rv.buffer);\n // nsec30 | secHigh2\n view.setUint32(0, (nsec << 2) | (secHigh & 0x3));\n // secLow32\n view.setUint32(4, secLow);\n return rv;\n }\n }\n else {\n // timestamp 96 = { nsec32 (unsigned), sec64 (signed) }\n var rv = new Uint8Array(12);\n var view = new DataView(rv.buffer);\n view.setUint32(0, nsec);\n setInt64(view, 4, sec);\n return rv;\n }\n}\nexport function encodeDateToTimeSpec(date) {\n var msec = date.getTime();\n var sec = Math.floor(msec / 1e3);\n var nsec = (msec - sec * 1e3) * 1e6;\n // Normalizes { sec, nsec } to ensure nsec is unsigned.\n var nsecInSec = Math.floor(nsec / 1e9);\n return {\n sec: sec + nsecInSec,\n nsec: nsec - nsecInSec * 1e9,\n };\n}\nexport function encodeTimestampExtension(object) {\n if (object instanceof Date) {\n var timeSpec = encodeDateToTimeSpec(object);\n return encodeTimeSpecToTimestamp(timeSpec);\n }\n else {\n return null;\n }\n}\nexport function decodeTimestampToTimeSpec(data) {\n var view = new DataView(data.buffer, data.byteOffset, data.byteLength);\n // data may be 32, 64, or 96 bits\n switch (data.byteLength) {\n case 4: {\n // timestamp 32 = { sec32 }\n var sec = view.getUint32(0);\n var nsec = 0;\n return { sec: sec, nsec: nsec };\n }\n case 8: {\n // timestamp 64 = { nsec30, sec34 }\n var nsec30AndSecHigh2 = view.getUint32(0);\n var secLow32 = view.getUint32(4);\n var sec = (nsec30AndSecHigh2 & 0x3) * 0x100000000 + secLow32;\n var nsec = nsec30AndSecHigh2 >>> 2;\n return { sec: sec, nsec: nsec };\n }\n case 12: {\n // timestamp 96 = { nsec32 (unsigned), sec64 (signed) }\n var sec = getInt64(view, 4);\n var nsec = view.getUint32(0);\n return { sec: sec, nsec: nsec };\n }\n default:\n throw new DecodeError(\"Unrecognized data size for timestamp (expected 4, 8, or 12): \" + data.length);\n }\n}\nexport function decodeTimestampExtension(data) {\n var timeSpec = decodeTimestampToTimeSpec(data);\n return new Date(timeSpec.sec * 1e3 + timeSpec.nsec / 1e6);\n}\nexport var timestampExtension = {\n type: EXT_TIMESTAMP,\n encode: encodeTimestampExtension,\n decode: decodeTimestampExtension,\n};\n//# sourceMappingURL=timestamp.mjs.map","// ExtensionCodec to handle MessagePack extensions\nimport { ExtData } from \"./ExtData.mjs\";\nimport { timestampExtension } from \"./timestamp.mjs\";\nvar ExtensionCodec = /** @class */ (function () {\n function ExtensionCodec() {\n // built-in extensions\n this.builtInEncoders = [];\n this.builtInDecoders = [];\n // custom extensions\n this.encoders = [];\n this.decoders = [];\n this.register(timestampExtension);\n }\n ExtensionCodec.prototype.register = function (_a) {\n var type = _a.type, encode = _a.encode, decode = _a.decode;\n if (type >= 0) {\n // custom extensions\n this.encoders[type] = encode;\n this.decoders[type] = decode;\n }\n else {\n // built-in extensions\n var index = 1 + type;\n this.builtInEncoders[index] = encode;\n this.builtInDecoders[index] = decode;\n }\n };\n ExtensionCodec.prototype.tryToEncode = function (object, context) {\n // built-in extensions\n for (var i = 0; i < this.builtInEncoders.length; i++) {\n var encodeExt = this.builtInEncoders[i];\n if (encodeExt != null) {\n var data = encodeExt(object, context);\n if (data != null) {\n var type = -1 - i;\n return new ExtData(type, data);\n }\n }\n }\n // custom extensions\n for (var i = 0; i < this.encoders.length; i++) {\n var encodeExt = this.encoders[i];\n if (encodeExt != null) {\n var data = encodeExt(object, context);\n if (data != null) {\n var type = i;\n return new ExtData(type, data);\n }\n }\n }\n if (object instanceof ExtData) {\n // to keep ExtData as is\n return object;\n }\n return null;\n };\n ExtensionCodec.prototype.decode = function (data, type, context) {\n var decodeExt = type < 0 ? this.builtInDecoders[-1 - type] : this.decoders[type];\n if (decodeExt) {\n return decodeExt(data, type, context);\n }\n else {\n // decode() does not fail, returns ExtData instead.\n return new ExtData(type, data);\n }\n };\n ExtensionCodec.defaultCodec = new ExtensionCodec();\n return ExtensionCodec;\n}());\nexport { ExtensionCodec };\n//# sourceMappingURL=ExtensionCodec.mjs.map","import { UINT32_MAX } from \"./int.mjs\";\nvar TEXT_ENCODING_AVAILABLE = (typeof process === \"undefined\" || process.env[\"TEXT_ENCODING\"] !== \"never\") &&\n typeof TextEncoder !== \"undefined\" &&\n typeof TextDecoder !== \"undefined\";\nexport function utf8Count(str) {\n var strLength = str.length;\n var byteLength = 0;\n var pos = 0;\n while (pos < strLength) {\n var value = str.charCodeAt(pos++);\n if ((value & 0xffffff80) === 0) {\n // 1-byte\n byteLength++;\n continue;\n }\n else if ((value & 0xfffff800) === 0) {\n // 2-bytes\n byteLength += 2;\n }\n else {\n // handle surrogate pair\n if (value >= 0xd800 && value <= 0xdbff) {\n // high surrogate\n if (pos < strLength) {\n var extra = str.charCodeAt(pos);\n if ((extra & 0xfc00) === 0xdc00) {\n ++pos;\n value = ((value & 0x3ff) << 10) + (extra & 0x3ff) + 0x10000;\n }\n }\n }\n if ((value & 0xffff0000) === 0) {\n // 3-byte\n byteLength += 3;\n }\n else {\n // 4-byte\n byteLength += 4;\n }\n }\n }\n return byteLength;\n}\nexport function utf8EncodeJs(str, output, outputOffset) {\n var strLength = str.length;\n var offset = outputOffset;\n var pos = 0;\n while (pos < strLength) {\n var value = str.charCodeAt(pos++);\n if ((value & 0xffffff80) === 0) {\n // 1-byte\n output[offset++] = value;\n continue;\n }\n else if ((value & 0xfffff800) === 0) {\n // 2-bytes\n output[offset++] = ((value >> 6) & 0x1f) | 0xc0;\n }\n else {\n // handle surrogate pair\n if (value >= 0xd800 && value <= 0xdbff) {\n // high surrogate\n if (pos < strLength) {\n var extra = str.charCodeAt(pos);\n if ((extra & 0xfc00) === 0xdc00) {\n ++pos;\n value = ((value & 0x3ff) << 10) + (extra & 0x3ff) + 0x10000;\n }\n }\n }\n if ((value & 0xffff0000) === 0) {\n // 3-byte\n output[offset++] = ((value >> 12) & 0x0f) | 0xe0;\n output[offset++] = ((value >> 6) & 0x3f) | 0x80;\n }\n else {\n // 4-byte\n output[offset++] = ((value >> 18) & 0x07) | 0xf0;\n output[offset++] = ((value >> 12) & 0x3f) | 0x80;\n output[offset++] = ((value >> 6) & 0x3f) | 0x80;\n }\n }\n output[offset++] = (value & 0x3f) | 0x80;\n }\n}\nvar sharedTextEncoder = TEXT_ENCODING_AVAILABLE ? new TextEncoder() : undefined;\nexport var TEXT_ENCODER_THRESHOLD = !TEXT_ENCODING_AVAILABLE\n ? UINT32_MAX\n : typeof process !== \"undefined\" && process.env[\"TEXT_ENCODING\"] !== \"force\"\n ? 200\n : 0;\nfunction utf8EncodeTEencode(str, output, outputOffset) {\n output.set(sharedTextEncoder.encode(str), outputOffset);\n}\nfunction utf8EncodeTEencodeInto(str, output, outputOffset) {\n sharedTextEncoder.encodeInto(str, output.subarray(outputOffset));\n}\nexport var utf8EncodeTE = (sharedTextEncoder === null || sharedTextEncoder === void 0 ? void 0 : sharedTextEncoder.encodeInto) ? utf8EncodeTEencodeInto : utf8EncodeTEencode;\nvar CHUNK_SIZE = 4096;\nexport function utf8DecodeJs(bytes, inputOffset, byteLength) {\n var offset = inputOffset;\n var end = offset + byteLength;\n var units = [];\n var result = \"\";\n while (offset < end) {\n var byte1 = bytes[offset++];\n if ((byte1 & 0x80) === 0) {\n // 1 byte\n units.push(byte1);\n }\n else if ((byte1 & 0xe0) === 0xc0) {\n // 2 bytes\n var byte2 = bytes[offset++] & 0x3f;\n units.push(((byte1 & 0x1f) << 6) | byte2);\n }\n else if ((byte1 & 0xf0) === 0xe0) {\n // 3 bytes\n var byte2 = bytes[offset++] & 0x3f;\n var byte3 = bytes[offset++] & 0x3f;\n units.push(((byte1 & 0x1f) << 12) | (byte2 << 6) | byte3);\n }\n else if ((byte1 & 0xf8) === 0xf0) {\n // 4 bytes\n var byte2 = bytes[offset++] & 0x3f;\n var byte3 = bytes[offset++] & 0x3f;\n var byte4 = bytes[offset++] & 0x3f;\n var unit = ((byte1 & 0x07) << 0x12) | (byte2 << 0x0c) | (byte3 << 0x06) | byte4;\n if (unit > 0xffff) {\n unit -= 0x10000;\n units.push(((unit >>> 10) & 0x3ff) | 0xd800);\n unit = 0xdc00 | (unit & 0x3ff);\n }\n units.push(unit);\n }\n else {\n units.push(byte1);\n }\n if (units.length >= CHUNK_SIZE) {\n result += String.fromCharCode.apply(String, units);\n units.length = 0;\n }\n }\n if (units.length > 0) {\n result += String.fromCharCode.apply(String, units);\n }\n return result;\n}\nvar sharedTextDecoder = TEXT_ENCODING_AVAILABLE ? new TextDecoder() : null;\nexport var TEXT_DECODER_THRESHOLD = !TEXT_ENCODING_AVAILABLE\n ? UINT32_MAX\n : typeof process !== \"undefined\" && process.env[\"TEXT_DECODER\"] !== \"force\"\n ? 200\n : 0;\nexport function utf8DecodeTD(bytes, inputOffset, byteLength) {\n var stringBytes = bytes.subarray(inputOffset, inputOffset + byteLength);\n return sharedTextDecoder.decode(stringBytes);\n}\n//# sourceMappingURL=utf8.mjs.map","export function ensureUint8Array(buffer) {\n if (buffer instanceof Uint8Array) {\n return buffer;\n }\n else if (ArrayBuffer.isView(buffer)) {\n return new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);\n }\n else if (buffer instanceof ArrayBuffer) {\n return new Uint8Array(buffer);\n }\n else {\n // ArrayLike<number>\n return Uint8Array.from(buffer);\n }\n}\nexport function createDataView(buffer) {\n if (buffer instanceof ArrayBuffer) {\n return new DataView(buffer);\n }\n var bufferView = ensureUint8Array(buffer);\n return new DataView(bufferView.buffer, bufferView.byteOffset, bufferView.byteLength);\n}\n//# sourceMappingURL=typedArrays.mjs.map","import { utf8DecodeJs } from \"./utils/utf8.mjs\";\nvar DEFAULT_MAX_KEY_LENGTH = 16;\nvar DEFAULT_MAX_LENGTH_PER_KEY = 16;\nvar CachedKeyDecoder = /** @class */ (function () {\n function CachedKeyDecoder(maxKeyLength, maxLengthPerKey) {\n if (maxKeyLength === void 0) { maxKeyLength = DEFAULT_MAX_KEY_LENGTH; }\n if (maxLengthPerKey === void 0) { maxLengthPerKey = DEFAULT_MAX_LENGTH_PER_KEY; }\n this.maxKeyLength = maxKeyLength;\n this.maxLengthPerKey = maxLengthPerKey;\n this.hit = 0;\n this.miss = 0;\n // avoid `new Array(N)`, which makes a sparse array,\n // because a sparse array is typically slower than a non-sparse array.\n this.caches = [];\n for (var i = 0; i < this.maxKeyLength; i++) {\n this.caches.push([]);\n }\n }\n CachedKeyDecoder.prototype.canBeCached = function (byteLength) {\n return byteLength > 0 && byteLength <= this.maxKeyLength;\n };\n CachedKeyDecoder.prototype.find = function (bytes, inputOffset, byteLength) {\n var records = this.caches[byteLength - 1];\n FIND_CHUNK: for (var _i = 0, records_1 = records; _i < records_1.length; _i++) {\n var record = records_1[_i];\n var recordBytes = record.bytes;\n for (var j = 0; j < byteLength; j++) {\n if (recordBytes[j] !== bytes[inputOffset + j]) {\n continue FIND_CHUNK;\n }\n }\n return record.str;\n }\n return null;\n };\n CachedKeyDecoder.prototype.store = function (bytes, value) {\n var records = this.caches[bytes.length - 1];\n var record = { bytes: bytes, str: value };\n if (records.length >= this.maxLengthPerKey) {\n // `records` are full!\n // Set `record` to an arbitrary position.\n records[(Math.random() * records.length) | 0] = record;\n }\n else {\n records.push(record);\n }\n };\n CachedKeyDecoder.prototype.decode = function (bytes, inputOffset, byteLength) {\n var cachedValue = this.find(bytes, inputOffset, byteLength);\n if (cachedValue != null) {\n this.hit++;\n return cachedValue;\n }\n this.miss++;\n var str = utf8DecodeJs(bytes, inputOffset, byteLength);\n // Ensure to copy a slice of bytes because the byte may be NodeJS Buffer and Buffer#slice() returns a reference to its internal ArrayBuffer.\n var slicedCopyOfBytes = Uint8Array.prototype.slice.call(bytes, inputOffset, inputOffset + byteLength);\n this.store(slicedCopyOfBytes, str);\n return str;\n };\n return CachedKeyDecoder;\n}());\nexport { CachedKeyDecoder };\n//# sourceMappingURL=CachedKeyDecoder.mjs.map","var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nvar __asyncValues = (this && this.__asyncValues) || function (o) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var m = o[Symbol.asyncIterator], i;\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\n};\nvar __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }\nvar __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\n};\nimport { prettyByte } from \"./utils/prettyByte.mjs\";\nimport { ExtensionCodec } from \"./ExtensionCodec.mjs\";\nimport { getInt64, getUint64, UINT32_MAX } from \"./utils/int.mjs\";\nimport { utf8DecodeJs, TEXT_DECODER_THRESHOLD, utf8DecodeTD } from \"./utils/utf8.mjs\";\nimport { createDataView, ensureUint8Array } from \"./utils/typedArrays.mjs\";\nimport { CachedKeyDecoder } from \"./CachedKeyDecoder.mjs\";\nimport { DecodeError } from \"./DecodeError.mjs\";\nvar isValidMapKeyType = function (key) {\n var keyType = typeof key;\n return keyType === \"string\" || keyType === \"number\";\n};\nvar HEAD_BYTE_REQUIRED = -1;\nvar EMPTY_VIEW = new DataView(new ArrayBuffer(0));\nvar EMPTY_BYTES = new Uint8Array(EMPTY_VIEW.buffer);\n// IE11: Hack to support IE11.\n// IE11: Drop this hack and just use RangeError when IE11 is obsolete.\nexport var DataViewIndexOutOfBoundsError = (function () {\n try {\n // IE11: The spec says it should throw RangeError,\n // IE11: but in IE11 it throws TypeError.\n EMPTY_VIEW.getInt8(0);\n }\n catch (e) {\n return e.constructor;\n }\n throw new Error(\"never reached\");\n})();\nvar MORE_DATA = new DataViewIndexOutOfBoundsError(\"Insufficient data\");\nvar sharedCachedKeyDecoder = new CachedKeyDecoder();\nvar Decoder = /** @class */ (function () {\n function Decoder(extensionCodec, context, maxStrLength, maxBinLength, maxArrayLength, maxMapLength, maxExtLength, keyDecoder) {\n if (extensionCodec === void 0) { extensionCodec = ExtensionCodec.defaultCodec; }\n if (context === void 0) { context = undefined; }\n if (maxStrLength === void 0) { maxStrLength = UINT32_MAX; }\n if (maxBinLength === void 0) { maxBinLength = UINT32_MAX; }\n if (maxArrayLength === void 0) { maxArrayLength = UINT32_MAX; }\n if (maxMapLength === void 0) { maxMapLength = UINT32_MAX; }\n if (maxExtLength === void 0) { maxExtLength = UINT32_MAX; }\n if (keyDecoder === void 0) { keyDecoder = sharedCachedKeyDecoder; }\n this.extensionCodec = extensionCodec;\n this.context = context;\n this.maxStrLength = maxStrLength;\n this.maxBinLength = maxBinLength;\n this.maxArrayLength = maxArrayLength;\n this.maxMapLength = maxMapLength;\n this.maxExtLength = maxExtLength;\n this.keyDecoder = keyDecoder;\n this.totalPos = 0;\n this.pos = 0;\n this.view = EMPTY_VIEW;\n this.bytes = EMPTY_BYTES;\n this.headByte = HEAD_BYTE_REQUIRED;\n this.stack = [];\n }\n Decoder.prototype.reinitializeState = function () {\n this.totalPos = 0;\n this.headByte = HEAD_BYTE_REQUIRED;\n this.stack.length = 0;\n // view, bytes, and pos will be re-initialized in setBuffer()\n };\n Decoder.prototype.setBuffer = function (buffer) {\n this.bytes = ensureUint8Array(buffer);\n this.view = createDataView(this.bytes);\n this.pos = 0;\n };\n Decoder.prototype.appendBuffer = function (buffer) {\n if (this.headByte === HEAD_BYTE_REQUIRED && !this.hasRemaining(1)) {\n this.setBuffer(buffer);\n }\n else {\n var remainingData = this.bytes.subarray(this.pos);\n var newData = ensureUint8Array(buffer);\n // concat remainingData + newData\n var newBuffer = new Uint8Array(remainingData.length + newData.length);\n newBuffer.set(remainingData);\n newBuffer.set(newData, remainingData.length);\n this.setBuffer(newBuffer);\n }\n };\n Decoder.prototype.hasRemaining = function (size) {\n return this.view.byteLength - this.pos >= size;\n };\n Decoder.prototype.createExtraByteError = function (posToShow) {\n var _a = this, view = _a.view, pos = _a.pos;\n return new RangeError(\"Extra \" + (view.byteLength - pos) + \" of \" + view.byteLength + \" byte(s) found at buffer[\" + posToShow + \"]\");\n };\n /**\n * @throws {DecodeError}\n * @throws {RangeError}\n */\n Decoder.prototype.decode = function (buffer) {\n this.reinitializeState();\n this.setBuffer(buffer);\n var object = this.doDecodeSync();\n if (this.hasRemaining(1)) {\n throw this.createExtraByteError(this.pos);\n }\n return object;\n };\n Decoder.prototype.decodeMulti = function (buffer) {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n this.reinitializeState();\n this.setBuffer(buffer);\n _a.label = 1;\n case 1:\n if (!this.hasRemaining(1)) return [3 /*break*/, 3];\n return [4 /*yield*/, this.doDecodeSync()];\n case 2:\n _a.sent();\n return [3 /*break*/, 1];\n case 3: return [2 /*return*/];\n }\n });\n };\n Decoder.prototype.decodeAsync = function (stream) {\n var stream_1, stream_1_1;\n var e_1, _a;\n return __awaiter(this, void 0, void 0, function () {\n var decoded, object, buffer, e_1_1, _b, headByte, pos, totalPos;\n return __generator(this, function (_c) {\n switch (_c.label) {\n case 0:\n decoded = false;\n _c.label = 1;\n case 1:\n _c.trys.push([1, 6, 7, 12]);\n stream_1 = __asyncValues(stream);\n _c.label = 2;\n case 2: return [4 /*yield*/, stream_1.next()];\n case 3:\n if (!(stream_1_1 = _c.sent(), !stream_1_1.done)) return [3 /*break*/, 5];\n buffer = stream_1_1.value;\n if (decoded) {\n throw this.createExtraByteError(this.totalPos);\n }\n this.appendBuffer(buffer);\n try {\n object = this.doDecodeSync();\n decoded = true;\n }\n catch (e) {\n if (!(e instanceof DataViewIndexOutOfBoundsError)) {\n throw e; // rethrow\n }\n // fallthrough\n }\n this.totalPos += this.pos;\n _c.label = 4;\n case 4: return [3 /*break*/, 2];\n case 5: return [3 /*break*/, 12];\n case 6:\n e_1_1 = _c.sent();\n e_1 = { error: e_1_1 };\n return [3 /*break*/, 12];\n case 7:\n _c.trys.push([7, , 10, 11]);\n if (!(stream_1_1 && !stream_1_1.done && (_a = stream_1.return))) return [3 /*break*/, 9];\n return [4 /*yield*/, _a.call(stream_1)];\n case 8:\n _c.sent();\n _c.label = 9;\n case 9: return [3 /*break*/, 11];\n case 10:\n if (e_1) throw e_1.error;\n return [7 /*endfinally*/];\n case 11: return [7 /*endfinally*/];\n case 12:\n if (decoded) {\n if (this.hasRemaining(1)) {\n throw this.createExtraByteError(this.totalPos);\n }\n return [2 /*return*/, object];\n }\n _b = this, headByte = _b.headByte, pos = _b.pos, totalPos = _b.totalPos;\n throw new RangeError(\"Insufficient data in parsing \" + prettyByte(headByte) + \" at \" + totalPos + \" (\" + pos + \" in the current buffer)\");\n }\n });\n });\n };\n Decoder.prototype.decodeArrayStream = function (stream) {\n return this.decodeMultiAsync(stream, true);\n };\n Decoder.prototype.decodeStream = function (stream) {\n return this.decodeMultiAsync(stream, false);\n };\n Decoder.prototype.decodeMultiAsync = function (stream, isArray) {\n return __asyncGenerator(this, arguments, function decodeMultiAsync_1() {\n var isArrayHeaderRequired, arrayItemsLeft, stream_2, stream_2_1, buffer, e_2, e_3_1;\n var e_3, _a;\n return __generator(this, function (_b) {\n switch (_b.label) {\n case 0:\n isArrayHeaderRequired = isArray;\n arrayItemsLeft = -1;\n _b.label = 1;\n case 1:\n _b.trys.push([1, 13, 14, 19]);\n stream_2 = __asyncValues(stream);\n _b.label = 2;\n case 2: return [4 /*yield*/, __await(stream_2.next())];\n case 3:\n if (!(stream_2_1 = _b.sent(), !stream_2_1.done)) return [3 /*break*/, 12];\n buffer = stream_2_1.value;\n if (isArray && arrayItemsLeft === 0) {\n throw this.createExtraByteError(this.totalPos);\n }\n this.appendBuffer(buffer);\n if (isArrayHeaderRequired) {\n arrayItemsLeft = this.readArraySize();\n isArrayHeaderRequired = false;\n this.complete();\n }\n _b.label = 4;\n case 4:\n _b.trys.push([4, 9, , 10]);\n _b.label = 5;\n case 5:\n if (!true) return [3 /*break*/, 8];\n return [4 /*yield*/, __await(this.doDecodeSync())];\n case 6: return [4 /*yield*/, _b.sent()];\n case 7:\n _b.sent();\n if (--arrayItemsLeft === 0) {\n return [3 /*break*/, 8];\n }\n return [3 /*break*/, 5];\n case 8: return [3 /*break*/, 10];\n case 9:\n e_2 = _b.sent();\n if (!(e_2 instanceof DataViewIndexOutOfBoundsError)) {\n throw e_2; // rethrow\n }\n return [3 /*break*/, 10];\n case 10:\n this.totalPos += this.pos;\n _b.label = 11;\n case 11: return [3 /*break*/, 2];\n case 12: return [3 /*break*/, 19];\n case 13:\n e_3_1 = _b.sent();\n e_3 = { error: e_3_1 };\n return [3 /*break*/, 19];\n case 14:\n _b.trys.push([14, , 17, 18]);\n if (!(stream_2_1 && !stream_2_1.done && (_a = stream_2.return))) return [3 /*break*/, 16];\n return [4 /*yield*/, __await(_a.call(stream_2))];\n case 15:\n _b.sent();\n _b.label = 16;\n case 16: return [3 /*break*/, 18];\n case 17:\n if (e_3) throw e_3.error;\n return [7 /*endfinally*/];\n case 18: return [7 /*endfinally*/];\n case 19: return [2 /*return*/];\n }\n });\n });\n };\n Decoder.prototype.doDecodeSync = function () {\n DECODE: while (true) {\n var headByte = this.readHeadByte();\n var object = void 0;\n if (headByte >= 0xe0) {\n // negative fixint (111x xxxx) 0xe0 - 0xff\n object = headByte - 0x100;\n }\n else if (headByte < 0xc0) {\n if (headByte < 0x80) {\n // positive fixint (0xxx xxxx) 0x00 - 0x7f\n object = headByte;\n }\n else if (headByte < 0x90) {\n // fixmap (1000 xxxx) 0x80 - 0x8f\n var size = headByte - 0x80;\n if (size !== 0) {\n this.pushMapState(size);\n this.complete();\n continue DECODE;\n }\n else {\n object = {};\n }\n }\n else if (headByte < 0xa0) {\n // fixarray (1001 xxxx) 0x90 - 0x9f\n var size = headByte - 0x90;\n if (size !== 0) {\n this.pushArrayState(size);\n this.complete();\n continue DECODE;\n }\n else {\n object = [];\n }\n }\n else {\n // fixstr (101x xxxx) 0xa0 - 0xbf\n var byteLength = headByte - 0xa0;\n object = this.decodeUtf8String(byteLength, 0);\n }\n }\n else if (headByte === 0xc0) {\n // nil\n object = null;\n }\n else if (headByte === 0xc2) {\n // false\n object = false;\n }\n else if (headByte === 0xc3) {\n // true\n object = true;\n }\n else if (headByte === 0xca) {\n // float 32\n object = this.readF32();\n }\n else if (headByte === 0xcb) {\n // float 64\n object = this.readF64();\n }\n else if (headByte === 0xcc) {\n // uint 8\n object = this.readU8();\n }\n else if (headByte === 0xcd) {\n // uint 16\n object = this.readU16();\n }\n else if (headByte === 0xce) {\n // uint 32\n object = this.readU32();\n }\n else if (headByte === 0xcf) {\n // uint 64\n object = this.readU64();\n }\n else if (headByte === 0xd0) {\n // int 8\n object = this.readI8();\n }\n else if (headByte === 0xd1) {\n // int 16\n object = this.readI16();\n }\n else if (headByte === 0xd2) {\n // int 32\n object = this.readI32();\n }\n else if (headByte === 0xd3) {\n // int 64\n object = this.readI64();\n }\n else if (headByte === 0xd9) {\n // str 8\n var byteLength = this.lookU8();\n object = this.decodeUtf8String(byteLength, 1);\n }\n else if (headByte === 0xda) {\n // str 16\n var byteLength = this.lookU16();\n object = this.decodeUtf8String(byteLength, 2);\n }\n else if (headByte === 0xdb) {\n // str 32\n var byteLength = this.lookU32();\n object = this.decodeUtf8String(byteLength, 4);\n }\n else if (headByte === 0xdc) {\n // array 16\n var size = this.readU16();\n if (size !== 0) {\n this.pushArrayState(size);\n this.complete();\n continue DECODE;\n }\n else {\n object = [];\n }\n }\n else if (headByte === 0xdd) {\n // array 32\n var size = this.readU32();\n if (size !== 0) {\n this.pushArrayState(size);\n this.complete();\n continue DECODE;\n }\n else {\n object = [];\n }\n }\n else if (headByte === 0xde) {\n // map 16\n var size = this.readU16();\n if (size !== 0) {\n this.pushMapState(size);\n this.complete();\n continue DECODE;\n }\n else {\n object = {};\n }\n }\n else if (headByte === 0xdf) {\n // map 32\n var size = this.readU32();\n if (size !== 0) {\n this.pushMapState(size);\n this.complete();\n continue DECODE;\n }\n else {\n object = {};\n }\n }\n else if (headByte === 0xc4) {\n // bin 8\n var size = this.lookU8();\n object = this.decodeBinary(size, 1);\n }\n else if (headByte === 0xc5) {\n // bin 16\n var size = this.lookU16();\n object = this.decodeBinary(size, 2);\n }\n else if (headByte === 0xc6) {\n // bin 32\n var size = this.lookU32();\n object = this.decodeBinary(size, 4);\n }\n else if (headByte === 0xd4) {\n // fixext 1\n object = this.decodeExtension(1, 0);\n }\n else if (headByte === 0xd5) {\n // fixext 2\n object = this.decodeExtension(2, 0);\n }\n else if (headByte === 0xd6) {\n // fixext 4\n object = this.decodeExtension(4, 0);\n }\n else if (headByte === 0xd7) {\n // fixext 8\n object = this.decodeExtension(8, 0);\n }\n else if (headByte === 0xd8) {\n // fixext 16\n object = this.decodeExtension(16, 0);\n }\n else if (headByte === 0xc7) {\n // ext 8\n var size = this.lookU8();\n object = this.decodeExtension(size, 1);\n }\n else if (headByte === 0xc8) {\n // ext 16\n var size = this.lookU16();\n object = this.decodeExtension(size, 2);\n }\n else if (headByte === 0xc9) {\n // ext 32\n var size = this.lookU32();\n object = this.decodeExtension(size, 4);\n }\n else {\n throw new DecodeError(\"Unrecognized type byte: \" + prettyByte(headByte));\n }\n this.complete();\n var stack = this.stack;\n while (stack.length > 0) {\n // arrays and maps\n var state = stack[stack.length - 1];\n if (state.type === 0 /* ARRAY */) {\n state.array[state.position] = object;\n state.position++;\n if (state.position === state.size) {\n stack.pop();\n object = state.array;\n }\n else {\n continue DECODE;\n }\n }\n else if (state.type === 1 /* MAP_KEY */) {\n if (!isValidMapKeyType(object)) {\n throw new DecodeError(\"The type of key must be string or number but \" + typeof object);\n }\n if (object === \"__proto__\") {\n throw new DecodeError(\"The key __proto__ is not allowed\");\n }\n state.key = object;\n state.type = 2 /* MAP_VALUE */;\n continue DECODE;\n }\n else {\n // it must be `state.type === State.MAP_VALUE` here\n state.map[state.key] = object;\n state.readCount++;\n if (state.readCount === state.size) {\n stack.pop();\n object = state.map;\n }\n else {\n state.key = null;\n state.type = 1 /* MAP_KEY */;\n continue DECODE;\n }\n }\n }\n return object;\n }\n };\n Decoder.prototype.readHeadByte = function () {\n if (this.headByte === HEAD_BYTE_REQUIRED) {\n this.headByte = this.readU8();\n // console.log(\"headByte\", prettyByte(this.headByte));\n }\n return this.headByte;\n };\n Decoder.prototype.complete = function () {\n this.headByte = HEAD_BYTE_REQUIRED;\n };\n Decoder.prototype.readArraySize = function () {\n var headByte = this.readHeadByte();\n switch (headByte) {\n case 0xdc:\n return this.readU16();\n case 0xdd:\n return this.readU32();\n default: {\n if (headByte < 0xa0) {\n return headByte - 0x90;\n }\n else {\n throw new DecodeError(\"Unrecognized array type byte: \" + prettyByte(headByte));\n }\n }\n }\n };\n Decoder.prototype.pushMapState = function (size) {\n if (size > this.maxMapLength) {\n throw new DecodeError(\"Max length exceeded: map length (\" + size + \") > maxMapLengthLength (\" + this.maxMapLength + \")\");\n }\n this.stack.push({\n type: 1 /* MAP_KEY */,\n size: size,\n key: null,\n readCount: 0,\n map: {},\n });\n };\n Decoder.prototype.pushArrayState = function (size) {\n if (size > this.maxArrayLength) {\n throw new DecodeError(\"Max length exceeded: array length (\" + size + \") > maxArrayLength (\" + this.maxArrayLength + \")\");\n }\n this.stack.push({\n type: 0 /* ARRAY */,\n size: size,\n array: new Array(size),\n position: 0,\n });\n };\n Decoder.prototype.decodeUtf8String = function (byteLength, headerOffset) {\n var _a;\n if (byteLength > this.maxStrLength) {\n throw new DecodeError(\"Max length exceeded: UTF-8 byte length (\" + byteLength + \") > maxStrLength (\" + this.maxStrLength + \")\");\n }\n if (this.bytes.byteLength < this.pos + headerOffset + byteLength) {\n throw MORE_DATA;\n }\n var offset = this.pos + headerOffset;\n var object;\n if (this.stateIsMapKey() && ((_a = this.keyDecoder) === null || _a === void 0 ? void 0 : _a.canBeCached(byteLength))) {\n object = this.keyDecoder.decode(this.bytes, offset, byteLength);\n }\n else if (byteLength > TEXT_DECODER_THRESHOLD) {\n object = utf8DecodeTD(this.bytes, offset, byteLength);\n }\n else {\n object = utf8DecodeJs(this.bytes, offset, byteLength);\n }\n this.pos += headerOffset + byteLength;\n return object;\n };\n Decoder.prototype.stateIsMapKey = function () {\n if (this.stack.length > 0) {\n var state = this.stack[this.stack.length - 1];\n return state.type === 1 /* MAP_KEY */;\n }\n return false;\n };\n Decoder.prototype.decodeBinary = function (byteLength, headOffset) {\n if (byteLength > this.maxBinLength) {\n throw new DecodeError(\"Max length exceeded: bin length (\" + byteLength + \") > maxBinLength (\" + this.maxBinLength + \")\");\n }\n if (!this.hasRemaining(byteLength + headOffset)) {\n throw MORE_DATA;\n }\n var offset = this.pos + headOffset;\n var object = this.bytes.subarray(offset, offset + byteLength);\n this.pos += headOffset + byteLength;\n return object;\n };\n Decoder.prototype.decodeExtension = function (size, headOffset) {\n if (size > this.maxExtLength) {\n throw new DecodeError(\"Max length exceeded: ext length (\" + size + \") > maxExtLength (\" + this.maxExtLength + \")\");\n }\n var extType = this.view.getInt8(this.pos + headOffset);\n var data = this.decodeBinary(size, headOffset + 1 /* extType */);\n return this.extensionCodec.decode(data, extType, this.context);\n };\n Decoder.prototype.lookU8 = function () {\n return this.view.getUint8(this.pos);\n };\n Decoder.prototype.lookU16 = function () {\n return this.view.getUint16(this.pos);\n };\n Decoder.prototype.lookU32 = function () {\n return this.view.getUint32(this.pos);\n };\n Decoder.prototype.readU8 = function () {\n var value = this.view.getUint8(this.pos);\n this.pos++;\n return value;\n };\n Decoder.prototype.readI8 = function () {\n var value = this.view.getInt8(this.pos);\n this.pos++;\n return value;\n };\n Decoder.prototype.readU16 = function () {\n var value = this.view.getUint16(this.pos);\n this.pos += 2;\n return value;\n };\n Decoder.prototype.readI16 = function () {\n var value = this.view.getInt16(this.pos);\n this.pos += 2;\n return value;\n };\n Decoder.prototype.readU32 = function () {\n var value = this.view.getUint32(this.pos);\n this.pos += 4;\n return value;\n };\n Decoder.prototype.readI32 = function () {\n var value = this.view.getInt32(this.pos);\n this.pos += 4;\n return value;\n };\n Decoder.prototype.readU64 = function () {\n var value = getUint64(this.view, this.pos);\n this.pos += 8;\n return value;\n };\n Decoder.prototype.readI64 = function () {\n var value = getInt64(this.view, this.pos);\n this.pos += 8;\n return value;\n };\n Decoder.prototype.readF32 = function () {\n var value = this.view.getFloat32(this.pos);\n this.pos += 4;\n return value;\n };\n Decoder.prototype.readF64 = function () {\n var value = this.view.getFloat64(this.pos);\n this.pos += 8;\n return value;\n };\n return Decoder;\n}());\nexport { Decoder };\n//# sourceMappingURL=Decoder.mjs.map","import { Decoder } from \"./Decoder.mjs\";\nexport var defaultDecodeOptions = {};\n/**\n * It decodes a single MessagePack object in a buffer.\n *\n * This is a synchronous decoding function.\n * See other variants for asynchronous decoding: {@link decodeAsync()}, {@link decodeStream()}, or {@link decodeArrayStream()}.\n */\nexport function decode(buffer, options) {\n if (options === void 0) { options = defaultDecodeOptions; }\n var decoder = new Decoder(options.extensionCodec, options.context, options.maxStrLength, options.maxBinLength, options.maxArrayLength, options.maxMapLength, options.maxExtLength);\n return decoder.decode(buffer);\n}\n/**\n * It decodes multiple MessagePack objects in a buffer.\n * This is corresponding to {@link decodeMultiStream()}.\n */\nexport function decodeMulti(buffer, options) {\n if (options === void 0) { options = defaultDecodeOptions; }\n var decoder = new Decoder(options.extensionCodec, options.context, options.maxStrLength, options.maxBinLength, options.maxArrayLength, options.maxMapLength, options.maxExtLength);\n return decoder.decodeMulti(buffer);\n}\n//# sourceMappingURL=decode.mjs.map","import { utf8EncodeJs, utf8Count, TEXT_ENCODER_THRESHOLD, utf8EncodeTE } from \"./utils/utf8.mjs\";\nimport { ExtensionCodec } from \"./ExtensionCodec.mjs\";\nimport { setInt64, setUint64 } from \"./utils/int.mjs\";\nimport { ensureUint8Array } from \"./utils/typedArrays.mjs\";\nexport var DEFAULT_MAX_DEPTH = 100;\nexport var DEFAULT_INITIAL_BUFFER_SIZE = 2048;\nvar Encoder = /** @class */ (function () {\n function Encoder(extensionCodec, context, maxDepth, initialBufferSize, sortKeys, forceFloat32, ignoreUndefined, forceIntegerToFloat) {\n if (extensionCodec === void 0) { extensionCodec = ExtensionCodec.defaultCodec; }\n if (context === void 0) { context = undefined; }\n if (maxDepth === void 0) { maxDepth = DEFAULT_MAX_DEPTH; }\n if (initialBufferSize === void 0) { initialBufferSize = DEFAULT_INITIAL_BUFFER_SIZE; }\n if (sortKeys === void 0) { sortKeys = false; }\n if (forceFloat32 === void 0) { forceFloat32 = false; }\n if (ignoreUndefined === void 0) { ignoreUndefined = false; }\n if (forceIntegerToFloat === void 0) { forceIntegerToFloat = false; }\n this.extensionCodec = extensionCodec;\n this.context = context;\n this.maxDepth = maxDepth;\n this.initialBufferSize = initialBufferSize;\n this.sortKeys = sortKeys;\n this.forceFloat32 = forceFloat32;\n this.ignoreUndefined = ignoreUndefined;\n this.forceIntegerToFloat = forceIntegerToFloat;\n this.pos = 0;\n this.view = new DataView(new ArrayBuffer(this.initialBufferSize));\n this.bytes = new Uint8Array(this.view.buffer);\n }\n Encoder.prototype.getUint8Array = function () {\n return this.bytes.subarray(0, this.pos);\n };\n Encoder.prototype.reinitializeState = function () {\n this.pos = 0;\n };\n Encoder.prototype.encode = function (object) {\n this.reinitializeState();\n this.doEncode(object, 1);\n return this.getUint8Array();\n };\n Encoder.prototype.doEncode = function (object, depth) {\n if (depth > this.maxDepth) {\n throw new Error(\"Too deep objects in depth \" + depth);\n }\n if (object == null) {\n this.encodeNil();\n }\n else if (typeof object === \"boolean\") {\n this.encodeBoolean(object);\n }\n else if (typeof object === \"number\") {\n this.encodeNumber(object);\n }\n else if (typeof object === \"string\") {\n this.encodeString(object);\n }\n else {\n this.encodeObject(object, depth);\n }\n };\n Encoder.prototype.ensureBufferSizeToWrite = function (sizeToWrite) {\n var requiredSize = this.pos + sizeToWrite;\n if (this.view.byteLength < requiredSize) {\n this.resizeBuffer(requiredSize * 2);\n }\n };\n Encoder.prototype.resizeBuffer = function (newSize) {\n var newBuffer = new ArrayBuffer(newSize);\n var newBytes = new Uint8Array(newBuffer);\n var newView = new DataView(newBuffer);\n newBytes.set(this.bytes);\n this.view = newView;\n this.bytes = newBytes;\n };\n Encoder.prototype.encodeNil = function () {\n this.writeU8(0xc0);\n };\n Encoder.prototype.encodeBoolean = function (object) {\n if (object === false) {\n this.writeU8(0xc2);\n }\n else {\n this.writeU8(0xc3);\n }\n };\n Encoder.prototype.encodeNumber = function (object) {\n if (Number.isSafeInteger(object) && !this.forceIntegerToFloat) {\n if (object >= 0) {\n if (object < 0x80) {\n // positive fixint\n this.writeU8(object);\n }\n else if (object < 0x100) {\n // uint 8\n this.writeU8(0xcc);\n this.writeU8(object);\n }\n else if (object < 0x10000) {\n // uint 16\n this.writeU8(0xcd);\n this.writeU16(object);\n }\n else if (object < 0x100000000) {\n // uint 32\n this.writeU8(0xce);\n this.writeU32(object);\n }\n else {\n // uint 64\n this.writeU8(0xcf);\n this.writeU64(object);\n }\n }\n else {\n if (object >= -0x20) {\n // negative fixint\n this.writeU8(0xe0 | (object + 0x20));\n }\n else if (object >= -0x80) {\n // int 8\n this.writeU8(0xd0);\n this.writeI8(object);\n }\n else if (object >= -0x8000) {\n // int 16\n this.writeU8(0xd1);\n this.writeI16(object);\n }\n else if (object >= -0x80000000) {\n // int 32\n this.writeU8(0xd2);\n this.writeI32(object);\n }\n else {\n // int 64\n this.writeU8(0xd3);\n this.writeI64(object);\n }\n }\n }\n else {\n // non-integer numbers\n if (this.forceFloat32) {\n // float 32\n this.writeU8(0xca);\n this.writeF32(object);\n }\n else {\n // float 64\n this.writeU8(0xcb);\n this.writeF64(object);\n }\n }\n };\n Encoder.prototype.writeStringHeader = function (byteLength) {\n if (byteLength < 32) {\n // fixstr\n this.writeU8(0xa0 + byteLength);\n }\n else if (byteLength < 0x100) {\n // str 8\n this.writeU8(0xd9);\n this.writeU8(byteLength);\n }\n else if (byteLength < 0x10000) {\n // str 16\n this.writeU8(0xda);\n this.writeU16(byteLength);\n }\n else if (byteLength < 0x100000000) {\n // str 32\n this.writeU8(0xdb);\n this.writeU32(byteLength);\n }\n else {\n throw new Error(\"Too long string: \" + byteLength + \" bytes in UTF-8\");\n }\n };\n Encoder.prototype.encodeString = function (object) {\n var maxHeaderSize = 1 + 4;\n var strLength = object.length;\n if (strLength > TEXT_ENCODER_THRESHOLD) {\n var byteLength = utf8Count(object);\n this.ensureBufferSizeToWrite(maxHeaderSize + byteLength);\n this.writeStringHeader(byteLength);\n utf8EncodeTE(object, this.bytes, this.pos);\n this.pos += byteLength;\n }\n else {\n var byteLength = utf8Count(object);\n this.ensureBufferSizeToWrite(maxHeaderSize + byteLength);\n this.writeStringHeader(byteLength);\n utf8EncodeJs(object, this.bytes, this.pos);\n this.pos += byteLength;\n }\n };\n Encoder.prototype.encodeObject = function (object, depth) {\n // try to encode objects with custom codec first of non-primitives\n var ext = this.extensionCodec.tryToEncode(object, this.context);\n if (ext != null) {\n this.encodeExtension(ext);\n }\n else if (Array.isArray(object)) {\n this.encodeArray(object, depth);\n }\n else if (ArrayBuffer.isView(object)) {\n this.encodeBinary(object);\n }\n else if (typeof object === \"object\") {\n this.encodeMap(object, depth);\n }\n else {\n // symbol, function and other special object come here unless extensionCodec handles them.\n throw new Error(\"Unrecognized object: \" + Object.prototype.toString.apply(object));\n }\n };\n Encoder.prototype.encodeBinary = function (object) {\n var size = object.byteLength;\n if (size < 0x100) {\n // bin 8\n this.writeU8(0xc4);\n this.writeU8(size);\n }\n else if (size < 0x10000) {\n // bin 16\n this.writeU8(0xc5);\n this.writeU16(size);\n }\n else if (size < 0x100000000) {\n // bin 32\n this.writeU8(0xc6);\n this.writeU32(size);\n }\n else {\n throw new Error(\"Too large binary: \" + size);\n }\n var bytes = ensureUint8Array(object);\n this.writeU8a(bytes);\n };\n Encoder.prototype.encodeArray = function (object, depth) {\n var size = object.length;\n if (size < 16) {\n // fixarray\n this.writeU8(0x90 + size);\n }\n else if (size < 0x10000) {\n // array 16\n this.writeU8(0xdc);\n this.writeU16(size);\n }\n else if (size < 0x100000000) {\n // array 32\n this.writeU8(0xdd);\n this.writeU32(size);\n }\n else {\n throw new Error(\"Too large array: \" + size);\n }\n for (var _i = 0, object_1 = object; _i < object_1.length; _i++) {\n var item = object_1[_i];\n this.doEncode(item, depth + 1);\n }\n };\n Encoder.prototype.countWithoutUndefined = function (object, keys) {\n var count = 0;\n for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) {\n var key = keys_1[_i];\n if (object[key] !== undefined) {\n count++;\n }\n }\n return count;\n };\n Encoder.prototype.encodeMap = function (object, depth) {\n var keys = Object.keys(object);\n if (this.sortKeys) {\n keys.sort();\n }\n var size = this.ignoreUndefined ? this.countWithoutUndefined(object, keys) : keys.length;\n if (size < 16) {\n // fixmap\n this.writeU8(0x80 + size);\n }\n else if (size < 0x10000) {\n // map 16\n this.writeU8(0xde);\n this.writeU16(size);\n }\n else if (size < 0x100000000) {\n // map 32\n this.writeU8(0xdf);\n this.writeU32(size);\n }\n else {\n throw new Error(\"Too large map object: \" + size);\n }\n for (var _i = 0, keys_2 = keys; _i < keys_2.length; _i++) {\n var key = keys_2[_i];\n var value = object[key];\n if (!(this.ignoreUndefined && value === undefined)) {\n this.encodeString(key);\n this.doEncode(value, depth + 1);\n }\n }\n };\n Encoder.prototype.encodeExtension = function (ext) {\n var size = ext.data.length;\n if (size === 1) {\n // fixext 1\n this.writeU8(0xd4);\n }\n else if (size === 2) {\n // fixext 2\n this.writeU8(0xd5);\n }\n else if (size === 4) {\n // fixext 4\n this.writeU8(0xd6);\n }\n else if (size === 8) {\n // fixext 8\n this.writeU8(0xd7);\n }\n else if (size === 16) {\n // fixext 16\n this.writeU8(0xd8);\n }\n else if (size < 0x100) {\n // ext 8\n this.writeU8(0xc7);\n this.writeU8(size);\n }\n else if (size < 0x10000) {\n // ext 16\n this.writeU8(0xc8);\n this.writeU16(size);\n }\n else if (size < 0x100000000) {\n // ext 32\n this.writeU8(0xc9);\n this.writeU32(size);\n }\n else {\n throw new Error(\"Too large extension object: \" + size);\n }\n this.writeI8(ext.type);\n this.writeU8a(ext.data);\n };\n Encoder.prototype.writeU8 = function (value) {\n this.ensureBufferSizeToWrite(1);\n this.view.setUint8(this.pos, value);\n this.pos++;\n };\n Encoder.prototype.writeU8a = function (values) {\n var size = values.length;\n this.ensureBufferSizeToWrite(size);\n this.bytes.set(values, this.pos);\n this.pos += size;\n };\n Encoder.prototype.writeI8 = function (value) {\n this.ensureBufferSizeToWrite(1);\n this.view.setInt8(this.pos, value);\n this.pos++;\n };\n Encoder.prototype.writeU16 = function (value) {\n this.ensureBufferSizeToWrite(2);\n this.view.setUint16(this.pos, value);\n this.pos += 2;\n };\n Encoder.prototype.writeI16 = function (value) {\n this.ensureBufferSizeToWrite(2);\n this.view.setInt16(this.pos, value);\n this.pos += 2;\n };\n Encoder.prototype.writeU32 = function (value) {\n this.ensureBufferSizeToWrite(4);\n this.view.setUint32(this.pos, value);\n this.pos += 4;\n };\n Encoder.prototype.writeI32 = function (value) {\n this.ensureBufferSizeToWrite(4);\n this.view.setInt32(this.pos, value);\n this.pos += 4;\n };\n Encoder.prototype.writeF32 = function (value) {\n this.ensureBufferSizeToWrite(4);\n this.view.setFloat32(this.pos, value);\n this.pos += 4;\n };\n Encoder.prototype.writeF64 = function (value) {\n this.ensureBufferSizeToWrite(8);\n this.view.setFloat64(this.pos, value);\n this.pos += 8;\n };\n Encoder.prototype.writeU64 = function (value) {\n this.ensureBufferSizeToWrite(8);\n setUint64(this.view, this.pos, value);\n this.pos += 8;\n };\n Encoder.prototype.writeI64 = function (value) {\n this.ensureBufferSizeToWrite(8);\n setInt64(this.view, this.pos, value);\n this.pos += 8;\n };\n return Encoder;\n}());\nexport { Encoder };\n//# sourceMappingURL=Encoder.mjs.map","import { Encoder } from \"./Encoder.mjs\";\nvar defaultEncodeOptions = {};\n/**\n * It encodes `value` in the MessagePack format and\n * returns a byte buffer.\n *\n * The returned buffer is a slice of a larger `ArrayBuffer`, so you have to use its `#byteOffset` and `#byteLength` in order to convert it to another typed arrays including NodeJS `Buffer`.\n */\nexport function encode(value, options) {\n if (options === void 0) { options = defaultEncodeOptions; }\n var encoder = new Encoder(options.extensionCodec, options.context, options.maxDepth, options.initialBufferSize, options.sortKeys, options.forceFloat32, options.ignoreUndefined, options.forceIntegerToFloat);\n return encoder.encode(value);\n}\n//# sourceMappingURL=encode.mjs.map","/**\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 assert,\n waitFor\n} from \"./utils.js\";\n\nimport { encode as msgpack_packb, decodeMulti } from \"@msgpack/msgpack\";\n\nexport const API_VERSION = \"0.3.0\";\nconst CHUNK_SIZE = 1024 * 500;\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\nfunction concatArrayBuffers(buffers) {\n var buffersLengths = buffers.map(function(b) {\n return b.byteLength;\n }),\n totalBufferlength = buffersLengths.reduce(function(p, c) {\n return p + c;\n }, 0),\n unit8Arr = new Uint8Array(totalBufferlength);\n buffersLengths.reduce(function(p, c, i) {\n unit8Arr.set(new Uint8Array(buffers[i]), p);\n return p + c;\n }, 0);\n return unit8Arr.buffer;\n}\n\nclass Timer {\n constructor(timeout, callback, args, label) {\n this._timeout = timeout;\n this._callback = callback;\n this._args = args;\n this._label = label || \"timer\";\n this._task = null;\n this.started = false;\n }\n\n start() {\n this._task = setTimeout(() => {\n this._callback.apply(this, this._args);\n }, this._timeout * 1000);\n this.started = true;\n }\n\n clear() {\n if (this._task) {\n clearTimeout(this._task);\n this._task = null;\n this.started = false;\n } else {\n console.warn(`Clearing a timer (${this._label}) which is not started`);\n }\n }\n\n reset() {\n assert(this._task, `Timer (${this._label}) is not started`);\n clearTimeout(this._task);\n this.start();\n }\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(\n connection,\n {\n client_id = null,\n manager_id = null,\n default_context = null,\n name = null,\n codecs = null,\n method_timeout = null,\n max_message_buffer_size = 0,\n debug = false\n }\n ) {\n super(debug);\n this._codecs = codecs || {};\n assert(client_id && typeof client_id === \"string\");\n assert(client_id, \"client_id is required\");\n this._client_id = client_id;\n this._name = name;\n this._connection_info = null;\n this._workspace = null;\n this.manager_id = manager_id;\n this.default_context = default_context || {};\n this._method_annotations = new WeakMap();\n this._manager_service = null;\n this._max_message_buffer_size = max_message_buffer_size;\n this._chunk_store = {};\n this._method_timeout = method_timeout || 20;\n\n // make sure there is an execute function\n this._services = {};\n this._object_store = {\n services: this._services\n };\n\n if (connection) {\n this.add_service({\n id: \"built-in\",\n type: \"built-in\",\n name: \"RPC built-in services\",\n config: { require_context: true, visibility: \"public\" },\n ping: this._ping.bind(this),\n get_service: this.get_local_service.bind(this),\n register_service: this.register_service.bind(this),\n message_cache: {\n create: this._create_message.bind(this),\n append: this._append_message.bind(this),\n process: this._process_message.bind(this),\n remove: this._remove_message.bind(this)\n }\n });\n this.on(\"method\", this._handle_method.bind(this));\n\n assert(connection.emit_message && connection.on_message);\n this._emit_message = connection.emit_message.bind(connection);\n connection.on_message(this._on_message.bind(this));\n this._connection = connection;\n // Update the server and obtain client info\n this._get_connection_info();\n } else {\n this._emit_message = function() {\n console.log(\"No connection to emit message\");\n };\n }\n }\n\n async _get_connection_info() {\n if (this.manager_id) {\n // try to get the root service\n try {\n await this.get_manager_service(5.0);\n assert(this._manager_service);\n this._connection_info = await this._manager_service.get_connection_info();\n if (\n this._connection_info.reconnection_token &&\n this._connection.set_reconnection_token\n ) {\n this._connection.set_reconnection_token(\n this._connection_info.reconnection_token\n );\n const reconnection_expires_in =\n this._connection_info.reconnection_expires_in * 0.8;\n console.info(\n `Reconnection token obtained: ${this._connection_info.reconnection_token}, will be refreshed in ${reconnection_expires_in} seconds`\n );\n this._get_connection_info_task = setTimeout(\n this._get_connection_info.bind(this),\n reconnection_expires_in * 1000\n );\n }\n } catch (exp) {\n console.warn(\"Failed to fetch user info from \", this.manager_id, exp);\n }\n }\n }\n\n register_codec(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(this._codecs)) {\n if (this._codecs[k].type === config.type || k === config.name) {\n delete this._codecs[k];\n console.warn(\"Remove duplicated codec: \" + k);\n }\n }\n }\n this._codecs[config[\"name\"]] = config;\n }\n }\n\n async _ping(msg, context) {\n assert(msg == \"ping\");\n return \"pong\";\n }\n\n async ping(client_id, timeout) {\n let method = this._generate_remote_method({\n _rtarget: client_id,\n _rmethod: \"services.built-in.ping\",\n _rpromise: true\n });\n assert((await method(\"ping\", timeout)) == \"pong\");\n }\n\n _create_message(key, heartbeat, overwrite, context) {\n if (heartbeat) {\n if (!this._object_store[key]) {\n throw new Error(`session does not exist anymore: ${key}`);\n }\n this._object_store[key][\"timer\"].reset();\n }\n\n if (!this._object_store[\"message_cache\"]) {\n this._object_store[\"message_cache\"] = {};\n }\n if (!overwrite && this._object_store[\"message_cache\"][key]) {\n throw new Error(\n `Message with the same key (${key}) already exists in the cache store, please use overwrite=true or remove it first.`\n );\n }\n\n this._object_store[\"message_cache\"][key] = [];\n }\n\n _append_message(key, data, heartbeat, context) {\n if (heartbeat) {\n if (!this._object_store[key]) {\n throw new Error(`session does not exist anymore: ${key}`);\n }\n this._object_store[key][\"timer\"].reset();\n }\n const cache = this._object_store[\"message_cache\"];\n if (!cache[key]) {\n throw new Error(`Message with key ${key} does not exists.`);\n }\n assert(data instanceof ArrayBufferView);\n cache[key].push(data);\n }\n\n _remove_message(key, context) {\n const cache = this._object_store[\"message_cache\"];\n if (!cache[key]) {\n throw new Error(`Message with key ${key} does not exists.`);\n }\n delete cache[key];\n }\n\n _process_message(key, heartbeat, context) {\n if (heartbeat) {\n if (!this._object_store[key]) {\n throw new Error(`session does not exist anymore: ${key}`);\n }\n this._object_store[key][\"timer\"].reset();\n }\n const cache = this._object_store[\"message_cache\"];\n assert(!!context, \"Context is required\");\n if (!cache[key]) {\n throw new Error(`Message with key ${key} does not exists.`);\n }\n cache[key] = concatArrayBuffers(cache[key]);\n console.debug(`Processing message ${key} (size=${cache[key].length})`);\n let unpacker = decodeMulti(cache[key]);\n const { done, value } = unpacker.next();\n const main = value;\n // Make sure the fields are from trusted source\n Object.assign(main, {\n from: context.from,\n to: context.to,\n user: context.user\n });\n main[\"ctx\"] = JSON.parse(JSON.stringify(main));\n Object.assign(main[\"ctx\"], this.default_context);\n if (!done) {\n let extra = unpacker.next();\n Object.assign(main, extra.value);\n }\n this._fire(main[\"type\"], main);\n delete cache[key];\n }\n\n _on_message(message) {\n assert(message instanceof ArrayBuffer);\n let unpacker = decodeMulti(message);\n const { done, value } = unpacker.next();\n const main = value;\n // Add trusted context to the method call\n main[\"ctx\"] = JSON.parse(JSON.stringify(main));\n Object.assign(main[\"ctx\"], this.default_context);\n if (!done) {\n let extra = unpacker.next();\n Object.assign(main, extra.value);\n }\n this._fire(main[\"type\"], main);\n }\n\n reset() {\n this._event_handlers = {};\n this._services = {};\n }\n\n async disconnect() {\n if (this._get_connection_info_task) {\n clearTimeout(this._get_connection_info_task);\n this._get_connection_info_task = null;\n }\n this._fire(\"disconnect\");\n }\n\n async get_manager_service(timeout) {\n if (this.manager_id && !this._manager_service) {\n this._manager_service = await this.get_remote_service(\n `${this.manager_id}:default`,\n timeout\n );\n }\n }\n\n get_all_local_services() {\n return this._services;\n }\n get_local_service(service_id, context) {\n assert(service_id);\n const [ws, client_id] = context[\"to\"].split(\"/\");\n assert(client_id === this._client_id);\n\n const service = this._services[service_id];\n if (!service) {\n throw new Error(\"Service not found: \" + service_id);\n }\n\n // allow access for the same workspace\n if (service.config.visibility == \"public\") {\n return service;\n }\n\n // allow access for the same workspace\n if (context[\"from\"].startsWith(ws + \"/\")) {\n return service;\n }\n\n throw new Error(\"Permission denied for service: \" + service_id);\n }\n async get_remote_service(service_uri, timeout) {\n timeout = timeout === undefined ? 5 : timeout;\n if (!service_uri && this.manager_id) {\n service_uri = this.manager_id;\n } else if (!service_uri.includes(\":\")) {\n service_uri = this._client_id + \":\" + service_uri;\n }\n const provider = service_uri.split(\":\")[0];\n assert(provider);\n try {\n const method = this._generate_remote_method({\n _rtarget: provider,\n _rmethod: \"services.built-in.get_service\",\n _rpromise: true\n });\n return await waitFor(\n method(service_uri.split(\":\")[1]),\n timeout,\n \"Timeout Error: Failed to get remote service: \" + service_uri\n );\n } catch (e) {\n console.error(\"Failed to get remote service: \" + service_uri, e);\n throw e;\n }\n }\n _annotate_service_methods(\n aObject,\n object_id,\n require_context,\n run_in_executor,\n visibility\n ) {\n if (typeof aObject === \"function\") {\n // mark the method as a remote method that requires context\n let method_name = object_id.split(\".\")[1];\n this._method_annotations.set(aObject, {\n require_context: Array.isArray(require_context)\n ? require_context.includes(method_name)\n : !!require_context,\n run_in_executor: run_in_executor,\n method_id: \"services.\" + object_id,\n visibility: visibility\n });\n } else if (aObject instanceof Array || aObject instanceof Object) {\n for (let key of Object.keys(aObject)) {\n let val = aObject[key];\n if (typeof val === \"function\" && val.__rpc_object__) {\n let client_id = val.__rpc_object__._rtarget;\n if (client_id.includes(\"/\")) {\n client_id = client_id.split(\"/\")[1];\n }\n if (this._client_id === client_id) {\n if (aObject instanceof Array) {\n aObject = aObject.slice();\n }\n // recover local method\n aObject[key] = indexObject(\n this._object_store,\n val.__rpc_object__._rmethod\n );\n val = aObject[key]; // make sure it's annotated later\n } else {\n throw new Error(\n `Local method not found: ${val.__rpc_object__._rmethod}, client id mismatch ${this._client_id} != ${client_id}`\n );\n }\n }\n this._annotate_service_methods(\n val,\n object_id + \".\" + key,\n require_context,\n run_in_executor,\n visibility\n );\n }\n }\n }\n add_service(api, overwrite) {\n if (!api || Array.isArray(api)) throw new Error(\"Invalid service object\");\n if (api.constructor === Object) {\n api = Object.assign({}, api);\n } else {\n const normApi = {};\n const props = Object.getOwnPropertyNames(api).concat(\n Object.getOwnPropertyNames(Object.getPrototypeOf(api))\n );\n for (let k of props) {\n if (k !== \"constructor\") {\n if (typeof api[k] === \"function\") normApi[k] = api[k].bind(api);\n else normApi[k] = api[k];\n }\n }\n // For class instance, we need set a default id\n api.id = api.id || \"default\";\n api = normApi;\n }\n assert(\n api.id && typeof api.id === \"string\",\n `Service id not found: ${api}`\n );\n if (!api.name) {\n api.name = api.id;\n }\n if (!api.config) {\n api.config = {};\n }\n if (!api.type) {\n api.type = \"generic\";\n }\n // require_context only applies to the top-level functions\n let require_context = false,\n run_in_executor = false;\n if (api.config.require_context)\n require_context = api.config.require_context;\n if (api.config.run_in_executor) run_in_executor = true;\n const visibility = api.config.visibility || \"protected\";\n assert([\"protected\", \"public\"].includes(visibility));\n this._annotate_service_methods(\n api,\n api[\"id\"],\n require_context,\n run_in_executor,\n visibility\n );\n\n if (this._services[api.id]) {\n if (overwrite) {\n delete this._services[api.id];\n } else {\n throw new Error(\n `Service already exists: ${api.id}, please specify a different id (not ${api.id}) or overwrite=true`\n );\n }\n }\n this._services[api.id] = api;\n return api;\n }\n\n async register_service(api, overwrite, notify, context) {\n if (notify === undefined) notify = true;\n if (context) {\n // If this function is called from remote, we need to make sure\n const [workspace, client_id] = context[\"to\"].split(\"/\");\n assert(client_id === this._client_id);\n assert(\n workspace === context[\"from\"].split(\"/\")[0],\n \"Services can only be registered from the same workspace\"\n );\n }\n const service = this.add_service(api, overwrite);\n if (notify) {\n this._fire(\"service-updated\", {\n service_id: service[\"id\"],\n api: service,\n type: \"add\"\n });\n await this._notify_service_update();\n }\n return {\n id: `${this._client_id}:${service[\"id\"]}`,\n type: service[\"type\"],\n name: service[\"name\"],\n config: service[\"config\"]\n };\n }\n async unregister_service(service, notify) {\n if (service instanceof Object) {\n service = service.id;\n }\n if (!this._services[service]) {\n throw new Error(`Service not found: ${service}`);\n }\n const api = this._services[service];\n delete this._services[service];\n this._fire(\"service-updated\", {\n service_id: service,\n api: api,\n type: \"remove\"\n });\n await this._notify_service_update();\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 _encode_callback(\n name,\n callback,\n session_id,\n clear_after_called,\n timer,\n local_workspace\n ) {\n let method_id = `${session_id}.${name}`;\n let encoded = {\n _rtype: \"method\",\n _rtarget: local_workspace\n ? `${local_workspace}/${this._client_id}`\n : this._client_id,\n _rmethod: method_id,\n _rpromise: false\n };\n\n const self = this;\n let wrapped_callback = function() {\n try {\n callback.apply(null, Array.prototype.slice.call(arguments));\n } catch (error) {\n console.error(\"Error in callback:\", method_id, error);\n } finally {\n if (clear_after_called && self._object_store[session_id]) {\n console.log(\"Deleting session\", session_id, \"from\", self._client_id);\n delete self._object_store[session_id];\n }\n if (timer && timer.started) {\n timer.clear();\n }\n }\n };\n\n return [encoded, wrapped_callback];\n }\n\n async _encode_promise(\n resolve,\n reject,\n session_id,\n clear_after_called,\n timer,\n local_workspace\n ) {\n let store = this._get_session_store(session_id, true);\n assert(\n store,\n `Failed to create session store ${session_id} due to invalid parent`\n );\n let encoded = {};\n\n if (timer && reject && this._method_timeout) {\n encoded.heartbeat = await this._encode(\n timer.reset.bind(timer),\n session_id,\n local_workspace\n );\n encoded.interval = this._method_timeout / 2;\n store.timer = timer;\n } else {\n timer = null;\n }\n\n [encoded.resolve, store.resolve] = this._encode_callback(\n \"resolve\",\n resolve,\n session_id,\n clear_after_called,\n timer,\n local_workspace\n );\n [encoded.reject, store.reject] = this._encode_callback(\n \"reject\",\n reject,\n session_id,\n clear_after_called,\n timer,\n local_workspace\n );\n return encoded;\n }\n\n async _send_chunks(data, target_id, session_id) {\n let remote_services = await this.get_remote_service(\n `${target_id}:built-in`\n );\n assert(\n remote_services.message_cache,\n \"Remote client does not support message caching for long message.\"\n );\n let message_cache = remote_services.message_cache;\n let message_id = session_id || randId();\n await message_cache.create(message_id, !!session_id);\n let total_size = data.length;\n let chunk_num = Math.ceil(total_size / CHUNK_SIZE);\n for (let idx = 0; idx < chunk_num; idx++) {\n let start_byte = idx * CHUNK_SIZE;\n await message_cache.append(\n message_id,\n data.slice(start_byte, start_byte + CHUNK_SIZE),\n !!session_id\n );\n console.log(\n `Sending chunk ${idx + 1}/${chunk_num} (${total_size} bytes)`\n );\n }\n console.log(`All chunks sent (${chunk_num})`);\n await message_cache.process(message_id, !!session_id);\n }\n\n _generate_remote_method(\n encoded_method,\n remote_parent,\n local_parent,\n remote_workspace,\n local_workspace\n ) {\n let target_id = encoded_method._rtarget;\n if (remote_workspace && !target_id.includes(\"/\")) {\n target_id = remote_workspace + \"/\" + target_id;\n // Fix the target id to be an absolute id\n encoded_method._rtarget = target_id;\n }\n let method_id = encoded_method._rmethod;\n let with_promise = encoded_method._rpromise;\n const self = this;\n\n function remote_method() {\n return new Promise(async (resolve, reject) => {\n let local_session_id = randId();\n if (local_parent) {\n // Store the children session under the parent\n local_session_id = local_parent + \".\" + local_session_id;\n }\n let store = self._get_session_store(local_session_id, true);\n if (!store) {\n reject(\n new Error(\n `Runtime Error: Failed to get session store ${local_session_id}`\n )\n );\n return;\n }\n store[\"target_id\"] = target_id;\n const args = await self._encode(\n Array.prototype.slice.call(arguments),\n local_session_id,\n local_workspace\n );\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 let main_message = {\n type: \"method\",\n from: self._client_id,\n to: target_id,\n method: method_id\n };\n let extra_data = {};\n if (args) {\n extra_data[\"args\"] = args;\n }\n if (withKwargs) {\n extra_data[\"with_kwargs\"] = withKwargs;\n }\n\n console.log(\n `Calling remote method ${target_id}:${method_id}, session: ${local_session_id}`\n );\n if (remote_parent) {\n // Set the parent session\n // Note: It's a session id for the remote, not the current client\n main_message[\"parent\"] = remote_parent;\n }\n\n let timer = null;\n if (with_promise) {\n // Only pass the current session id to the remote\n // if we want to received the result\n // I.e. the session id won't be passed for promises themselves\n main_message[\"session\"] = local_session_id;\n let method_name = `${target_id}:${method_id}`;\n timer = new Timer(\n self._method_timeout,\n reject,\n [`Method call time out: ${method_name}`],\n method_name\n );\n extra_data[\"promise\"] = await self._encode_promise(\n resolve,\n reject,\n local_session_id,\n true,\n timer,\n local_workspace\n );\n }\n // The message consists of two segments, the main message and extra data\n let message_package = msgpack_packb(main_message);\n if (extra_data) {\n const extra = msgpack_packb(extra_data);\n message_package = new Uint8Array([...message_package, ...extra]);\n }\n let total_size = message_package.length;\n if (total_size <= CHUNK_SIZE + 1024) {\n self._emit_message(message_package).then(function() {\n if (timer) {\n console.log(`Start watchdog timer.`);\n // Only start the timer after we send the message successfully\n timer.start();\n }\n });\n } else {\n // send chunk by chunk\n self\n ._send_chunks(message_package, target_id, remote_parent)\n .then(function() {\n if (timer) {\n console.log(`Start watchdog timer.`);\n // Only start the timer after we send the message successfully\n timer.start();\n }\n });\n }\n });\n }\n\n // Generate debugging information for the method\n remote_method.__rpc_object__ = encoded_method;\n return remote_method;\n }\n\n async _notify_service_update() {\n if (this.manager_id) {\n // try to get the root service\n try {\n await this.get_manager_service(5.0);\n assert(this._manager_service);\n await this._manager_service.update_client_info(this.get_client_info());\n } catch (exp) {\n // pylint: disable=broad-except\n console.warn(\n \"Failed to notify service update to\",\n this.manager_id,\n exp\n );\n }\n }\n }\n\n get_client_info() {\n const services = [];\n for (let service of Object.values(this._services)) {\n services.push({\n id: `${this._client_id}:${service[\"id\"]}`,\n type: service[\"type\"],\n name: service[\"name\"],\n config: service[\"config\"]\n });\n }\n\n return {\n id: this._client_id,\n services: services\n };\n }\n\n async _handle_method(data) {\n let reject = null;\n let heartbeat_task = null;\n try {\n assert(data[\"method\"] && data[\"ctx\"] && data[\"from\"]);\n const method_name = data.from + \":\" + data.method;\n const remote_workspace = data.from.split(\"/\")[0];\n const local_workspace = data.to.split(\"/\")[0];\n const local_parent = data.parent;\n\n let resolve, reject;\n if (data.promise) {\n // Decode the promise with the remote session id\n // Such that the session id will be passed to the remote as a parent session id\n const promise = await this._decode(\n data.promise,\n data.session,\n local_parent,\n remote_workspace,\n local_workspace\n );\n resolve = promise.resolve;\n reject = promise.reject;\n if (promise.heartbeat && promise.interval) {\n async function heartbeat() {\n try {\n console.log(\"Reset heartbeat timer: \" + data.method);\n await promise.heartbeat();\n } catch (err) {\n console.error(err);\n }\n }\n heartbeat_task = setInterval(heartbeat, promise.interval * 1000);\n }\n }\n\n let method;\n\n try {\n method = indexObject(this._object_store, data[\"method\"]);\n } catch (e) {\n console.debug(\"Failed to find method\", method_name, e);\n throw new Error(`Method not found: ${method_name}`);\n }\n\n assert(\n method && typeof method === \"function\",\n \"Invalid method: \" + method_name\n );\n\n // Check permission\n if (this._method_annotations.has(method)) {\n // For services, it should not be protected\n if (this._method_annotations.get(method).visibility === \"protected\") {\n if (local_workspace !== remote_workspace) {\n throw new Error(\n \"Permission denied for protected method \" +\n method_name +\n \", workspace mismatch: \" +\n local_workspace +\n \" != \" +\n remote_workspace\n );\n }\n }\n } else {\n // For sessions, the target_id should match exactly\n let session_target_id = this._object_store[data.method.split(\".\")[0]]\n .target_id;\n if (\n local_workspace === remote_workspace &&\n session_target_id &&\n session_target_id.indexOf(\"/\") === -1\n ) {\n session_target_id = local_workspace + \"/\" + session_target_id;\n }\n if (session_target_id !== data.from) {\n throw new Error(\n \"Access denied for method call (\" +\n method_name +\n \") from \" +\n data.from\n );\n }\n }\n\n // Make sure the parent session is still open\n if (local_parent) {\n // The parent session should be a session that generate the current method call\n assert(\n this._get_session_store(local_parent, true) !== null,\n \"Parent session was closed: \" + local_parent\n );\n }\n let args;\n if (data.args) {\n args = await this._decode(\n data.args,\n data.session,\n null,\n remote_workspace,\n null\n );\n } else {\n args = [];\n }\n if (\n this._method_annotations.has(method) &&\n this._method_annotations.get(method).require_context\n ) {\n args.push(data.ctx);\n }\n console.log(\"Executing method: \" + method_name);\n if (data.promise) {\n const result = method.apply(null, args);\n if (result instanceof Promise) {\n result\n .then(result => {\n resolve(result);\n clearInterval(heartbeat_task);\n })\n .catch(err => {\n reject(err);\n clearInterval(heartbeat_task);\n });\n } else {\n resolve(result);\n clearInterval(heartbeat_task);\n }\n } else {\n method.apply(null, args);\n clearInterval(heartbeat_task);\n }\n } catch (err) {\n if (reject) {\n reject(err);\n console.debug(\"Error during calling method: \", err);\n } else {\n console.error(\"Error during calling method: \", err);\n }\n // make sure we clear the heartbeat timer\n clearInterval(heartbeat_task);\n }\n }\n\n encode(aObject, session_id) {\n return this._encode(aObject, session_id);\n }\n\n _get_session_store(session_id, create) {\n let store = this._object_store;\n const levels = session_id.split(\".\");\n if (create) {\n const last_index = levels.length - 1;\n for (let level of levels.slice(0, last_index)) {\n if (!store[level]) {\n return null;\n }\n store = store[level];\n }\n // Create the last level\n if (!store[levels[last_index]]) {\n store[levels[last_index]] = {};\n }\n return store[levels[last_index]];\n } else {\n for (let level of levels) {\n if (!store[level]) {\n return null;\n }\n store = store[level];\n }\n return store;\n }\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, session_id, local_workspace) {\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 Uint8Array\n ) {\n return aObject;\n }\n if (aObject instanceof ArrayBuffer) {\n return {\n _rtype: \"memoryview\",\n _rvalue: new Uint8Array(aObject)\n };\n }\n // Reuse the remote object\n if (aObject.__rpc_object__) {\n return aObject.__rpc_object__;\n }\n\n let bObject;\n\n // skip if already encoded\n if (aObject.constructor instanceof Object && aObject._rtype) {\n // make sure the interface functions are encoded\n const temp = aObject._rtype;\n delete aObject._rtype;\n bObject = await this._encode(aObject, session_id, local_workspace);\n bObject._rtype = temp;\n return bObject;\n }\n\n if (typeof aObject === \"function\") {\n if (this._method_annotations.has(aObject)) {\n let annotation = this._method_annotations.get(aObject);\n bObject = {\n _rtype: \"method\",\n _rtarget: this._client_id,\n _rmethod: annotation.method_id,\n _rpromise: true\n };\n } else {\n assert(typeof session_id === \"string\");\n let object_id;\n if (aObject.__name__) {\n object_id = `${randId()}-${aObject.__name__}`;\n } else {\n object_id = randId();\n }\n bObject = {\n _rtype: \"method\",\n _rtarget: this._client_id,\n _rmethod: `${session_id}.${object_id}`,\n _rpromise: true\n };\n let store = this._get_session_store(session_id, true);\n assert(\n store !== null,\n `Failed to create session store ${session_id} due to invalid parent`\n );\n store[object_id] = aObject;\n }\n return bObject;\n }\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 (typeof encodedObj === \"object\") {\n const temp = encodedObj._rtype;\n delete encodedObj._rtype;\n encodedObj = await this._encode(\n encodedObj,\n session_id,\n local_workspace\n );\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 bObject = {\n _rtype: \"ndarray\",\n _rvalue: new Uint8Array(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 bObject = {\n _rtype: \"ndarray\",\n _rvalue: new Uint8Array(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 }\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 (aObject instanceof Blob) {\n let _current_pos = 0;\n async function read(length) {\n let blob;\n if (length) {\n blob = aObject.slice(_current_pos, _current_pos + length);\n } else {\n blob = aObject.slice(_current_pos);\n }\n const ret = new Uint8Array(await blob.arrayBuffer());\n _current_pos = _current_pos + ret.byteLength;\n return ret;\n }\n function seek(pos) {\n _current_pos = pos;\n }\n bObject = {\n _rtype: \"iostream\",\n _rnative: \"js:blob\",\n type: aObject.type,\n name: aObject.name,\n size: aObject.size,\n path: aObject._path || aObject.webkitRelativePath,\n read: await this._encode(read, session_id, local_workspace),\n seek: await this._encode(seek, session_id, local_workspace)\n };\n } else if (aObject instanceof ArrayBufferView) {\n const dtype = typedArrayToDtype(aObject);\n bObject = {\n _rtype: \"typedarray\",\n _rvalue: new Uint8Array(aObject.buffer),\n _rdtype: dtype\n };\n } else if (aObject instanceof DataView) {\n bObject = {\n _rtype: \"memoryview\",\n _rvalue: new Uint8Array(aObject.buffer)\n };\n } else if (aObject instanceof Set) {\n bObject = {\n _rtype: \"set\",\n _rvalue: await this._encode(\n Array.from(aObject),\n session_id,\n local_workspace\n )\n };\n } else if (aObject instanceof Map) {\n bObject = {\n _rtype: \"orderedmap\",\n _rvalue: await this._encode(\n Array.from(aObject),\n session_id,\n local_workspace\n )\n };\n } else if (\n aObject.constructor instanceof Object ||\n Array.isArray(aObject)\n ) {\n bObject = isarray ? [] : {};\n const keys = Object.keys(aObject);\n for (let k of keys) {\n bObject[k] = await this._encode(\n aObject[k],\n session_id,\n local_workspace\n );\n }\n } else {\n throw `imjoy-rpc: Unsupported data type: ${aObject}, you can register a custom codec to encode/decode the object.`;\n }\n\n if (!bObject) {\n throw new Error(\"Failed to encode object\");\n }\n return bObject;\n }\n\n async decode(aObject) {\n return await this._decode(aObject);\n }\n\n async _decode(\n aObject,\n remote_parent,\n local_parent,\n remote_workspace,\n local_workspace\n ) {\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 const temp = aObject._rtype;\n delete aObject._rtype;\n aObject = await this._decode(\n aObject,\n remote_parent,\n local_parent,\n remote_workspace,\n local_workspace\n );\n aObject._rtype = temp;\n\n bObject = await Promise.resolve(\n this._codecs[aObject._rtype].decoder(aObject)\n );\n } else if (aObject._rtype === \"method\") {\n bObject = this._generate_remote_method(\n aObject,\n remote_parent,\n local_parent,\n remote_workspace,\n local_workspace\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 === \"typedarray\") {\n const arraytype = dtypeToTypedArray[aObject._rdtype];\n if (!arraytype)\n throw new Error(\"unsupported dtype: \" + aObject._rdtype);\n const buffer = aObject._rvalue.buffer.slice(\n aObject._rvalue.byteOffset,\n aObject._rvalue.byteOffset + aObject._rvalue.byteLength\n );\n bObject = new arraytype(buffer);\n } else if (aObject._rtype === \"memoryview\") {\n bObject = aObject._rvalue.buffer.slice(\n aObject._rvalue.byteOffset,\n aObject._rvalue.byteOffset + aObject._rvalue.byteLength\n ); // ArrayBuffer\n } else if (aObject._rtype === \"iostream\") {\n if (aObject._rnative === \"js:blob\") {\n const read = await this._generate_remote_method(\n aObject.read,\n remote_parent,\n local_parent,\n remote_workspace,\n local_workspace\n );\n const bytes = await read();\n bObject = new Blob([bytes], {\n type: aObject.type,\n name: aObject.name\n });\n } else {\n bObject = {};\n for (let k of Object.keys(aObject)) {\n if (!k.startsWith(\"_\")) {\n bObject[k] = await this._decode(\n aObject[k],\n remote_parent,\n local_parent,\n remote_workspace,\n local_workspace\n );\n }\n }\n }\n bObject[\"__rpc_object__\"] = aObject;\n } else if (aObject._rtype === \"orderedmap\") {\n bObject = new Map(\n await this._decode(\n aObject._rvalue,\n remote_parent,\n local_parent,\n remote_workspace,\n local_workspace\n )\n );\n } else if (aObject._rtype === \"set\") {\n bObject = new Set(\n await this._decode(\n aObject._rvalue,\n remote_parent,\n local_parent,\n remote_workspace,\n local_workspace\n )\n );\n } else {\n const temp = aObject._rtype;\n delete aObject._rtype;\n bObject = await this._decode(\n aObject,\n remote_parent,\n local_parent,\n remote_workspace,\n local_workspace\n );\n bObject._rtype = temp;\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(\n v,\n remote_parent,\n local_parent,\n remote_workspace,\n local_workspace\n );\n }\n }\n } else {\n bObject = aObject;\n }\n if (bObject === undefined) {\n throw new Error(\"Failed to decode object\");\n }\n return bObject;\n }\n}\n","import { RPC, API_VERSION } from \"./rpc.js\";\nimport { assert, loadRequirements, randId, waitFor } from \"./utils.js\";\n\nexport { RPC, API_VERSION };\nexport { version as VERSION } from \"../../package.json\";\nexport { loadRequirements };\n\nclass WebsocketRPCConnection {\n constructor(server_url, client_id, workspace, token, timeout) {\n assert(server_url && client_id, \"server_url and client_id are required\");\n server_url = server_url + \"?client_id=\" + client_id;\n if (workspace) {\n server_url += \"&workspace=\" + workspace;\n }\n if (token) {\n server_url += \"&token=\" + token;\n }\n this._websocket = null;\n this._handle_message = null;\n this._reconnection_token = null;\n this._server_url = server_url;\n this._timeout = timeout || 5; // 5s\n }\n\n set_reconnection_token(token) {\n this._reconnection_token = token;\n }\n\n on_message(handler) {\n assert(handler, \"handler is required\");\n this._handle_message = handler;\n }\n\n async open() {\n const server_url = this._reconnection_token\n ? `${this._server_url}&reconnection_token=${this._reconnection_token}`\n : this._server_url;\n console.info(\"Receating a new connection to \", server_url.split(\"?\")[0]);\n this._websocket = new WebSocket(server_url);\n this._websocket.binaryType = \"arraybuffer\";\n this._websocket.onmessage = event => {\n const data = event.data;\n this._handle_message(data);\n };\n const self = this;\n this._websocket.onclose = function() {\n console.log(\"websocket closed\");\n self._websocket = null;\n };\n const promise = await new Promise(resolve => {\n this._websocket.addEventListener(\"open\", resolve);\n });\n return await waitFor(\n promise,\n this._timeout,\n \"Timeout Error: Failed connect to the server \" + server_url.split(\"?\")[0]\n );\n }\n\n async emit_message(data) {\n assert(this._handle_message, \"No handler for message\");\n if (!this._websocket) {\n await this.open();\n }\n try {\n if (data.buffer) data = data.buffer;\n this._websocket.send(data);\n } catch (exp) {\n // data = msgpack_unpackb(data);\n console.error(`Failed to send data, error: ${exp}`);\n throw exp;\n }\n }\n\n async disconnect(reason) {\n const ws = this._websocket;\n this._websocket = null;\n if (ws) {\n ws.close(1000, reason);\n }\n console.info(`Websocket connection disconnected (${reason})`);\n }\n}\n\nexport async function connectToServer(config) {\n let clientId = config.client_id;\n if (!clientId) {\n clientId = randId();\n }\n let server_url = config.server_url;\n if (server_url.startsWith(\"http://\")) {\n server_url =\n server_url.replace(\"http://\", \"ws://\").replace(/\\/$/, \"\") + \"/ws\";\n } else if (server_url.startsWith(\"https://\")) {\n server_url =\n server_url.replace(\"https://\", \"wss://\").replace(/\\/$/, \"\") + \"/ws\";\n }\n let connection = new WebsocketRPCConnection(\n server_url,\n clientId,\n config.workspace,\n config.token,\n config.method_timeout || 5\n );\n await connection.open();\n const rpc = new RPC(connection, {\n client_id: clientId,\n manager_id: \"workspace-manager\",\n default_context: { connection_type: \"websocket\" },\n name: config.name,\n method_timeout: config.method_timeout\n });\n const wm = await rpc.get_remote_service(\"workspace-manager:default\");\n wm.rpc = rpc;\n\n async function _export(api) {\n api.id = \"default\";\n api.name = config.name || api.id;\n await rpc.register_service(api, true);\n // const svc = await rpc.get_remote_service(rpc._client_id + \":default\");\n // if (svc.setup) {\n // await svc.setup();\n // }\n }\n\n async function getPlugin(query) {\n return await wm.get_service(query + \":default\");\n }\n\n async function disconnect() {\n await rpc.disconnect();\n await connection.disconnect();\n }\n\n wm.export = _export;\n wm.getPlugin = getPlugin;\n wm.listPlugins = wm.listServices;\n wm.disconnect = disconnect;\n wm.registerCodec = rpc.register_codec.bind(rpc);\n return wm;\n}\n"],"sourceRoot":""}