@difizen/libro-kernel 0.0.2-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +1 -0
- package/es/basemanager.d.ts +94 -0
- package/es/basemanager.d.ts.map +1 -0
- package/es/basemanager.js +110 -0
- package/es/contents/contents-drive.d.ts +189 -0
- package/es/contents/contents-drive.d.ts.map +1 -0
- package/es/contents/contents-drive.js +792 -0
- package/es/contents/contents-manager.d.ts +229 -0
- package/es/contents/contents-manager.d.ts.map +1 -0
- package/es/contents/contents-manager.js +551 -0
- package/es/contents/contents-module.d.ts +3 -0
- package/es/contents/contents-module.d.ts.map +1 -0
- package/es/contents/contents-module.js +4 -0
- package/es/contents/contents-protocol.d.ts +487 -0
- package/es/contents/contents-protocol.d.ts.map +1 -0
- package/es/contents/contents-protocol.js +1 -0
- package/es/contents/index.d.ts +6 -0
- package/es/contents/index.d.ts.map +1 -0
- package/es/contents/index.js +5 -0
- package/es/contents/validate.d.ts +10 -0
- package/es/contents/validate.d.ts.map +1 -0
- package/es/contents/validate.js +22 -0
- package/es/index.d.ts +10 -0
- package/es/index.d.ts.map +1 -0
- package/es/index.js +9 -0
- package/es/index.less +0 -0
- package/es/kernel/comm.d.ts +92 -0
- package/es/kernel/comm.d.ts.map +1 -0
- package/es/kernel/comm.js +216 -0
- package/es/kernel/future.d.ts +178 -0
- package/es/kernel/future.d.ts.map +1 -0
- package/es/kernel/future.js +587 -0
- package/es/kernel/index.d.ts +8 -0
- package/es/kernel/index.d.ts.map +1 -0
- package/es/kernel/index.js +8 -0
- package/es/kernel/kernel-connection.d.ts +550 -0
- package/es/kernel/kernel-connection.d.ts.map +1 -0
- package/es/kernel/kernel-connection.js +1957 -0
- package/es/kernel/kernel-module.d.ts +3 -0
- package/es/kernel/kernel-module.d.ts.map +1 -0
- package/es/kernel/kernel-module.js +32 -0
- package/es/kernel/libro-kernel-manager.d.ts +69 -0
- package/es/kernel/libro-kernel-manager.d.ts.map +1 -0
- package/es/kernel/libro-kernel-manager.js +349 -0
- package/es/kernel/libro-kernel-protocol.d.ts +675 -0
- package/es/kernel/libro-kernel-protocol.d.ts.map +1 -0
- package/es/kernel/libro-kernel-protocol.js +60 -0
- package/es/kernel/libro-kernel-utils.d.ts +95 -0
- package/es/kernel/libro-kernel-utils.d.ts.map +1 -0
- package/es/kernel/libro-kernel-utils.js +130 -0
- package/es/kernel/libro-kernel.d.ts +14 -0
- package/es/kernel/libro-kernel.d.ts.map +1 -0
- package/es/kernel/libro-kernel.js +54 -0
- package/es/kernel/messages.d.ts +845 -0
- package/es/kernel/messages.d.ts.map +1 -0
- package/es/kernel/messages.js +457 -0
- package/es/kernel/restapi.d.ts +78 -0
- package/es/kernel/restapi.d.ts.map +1 -0
- package/es/kernel/restapi.js +367 -0
- package/es/kernel/serialize.d.ts +10 -0
- package/es/kernel/serialize.d.ts.map +1 -0
- package/es/kernel/serialize.js +214 -0
- package/es/kernel/validate.d.ts +15 -0
- package/es/kernel/validate.d.ts.map +1 -0
- package/es/kernel/validate.js +125 -0
- package/es/kernelspec/index.d.ts +5 -0
- package/es/kernelspec/index.d.ts.map +1 -0
- package/es/kernelspec/index.js +4 -0
- package/es/kernelspec/kernelspec-module.d.ts +3 -0
- package/es/kernelspec/kernelspec-module.d.ts.map +1 -0
- package/es/kernelspec/kernelspec-module.js +4 -0
- package/es/kernelspec/kernelspec.d.ts +33 -0
- package/es/kernelspec/kernelspec.d.ts.map +1 -0
- package/es/kernelspec/kernelspec.js +1 -0
- package/es/kernelspec/manager.d.ts +81 -0
- package/es/kernelspec/manager.d.ts.map +1 -0
- package/es/kernelspec/manager.js +248 -0
- package/es/kernelspec/restapi.d.ts +71 -0
- package/es/kernelspec/restapi.d.ts.map +1 -0
- package/es/kernelspec/restapi.js +107 -0
- package/es/kernelspec/validate.d.ts +10 -0
- package/es/kernelspec/validate.d.ts.map +1 -0
- package/es/kernelspec/validate.js +69 -0
- package/es/libro-kernel-connection-manager.d.ts +19 -0
- package/es/libro-kernel-connection-manager.d.ts.map +1 -0
- package/es/libro-kernel-connection-manager.js +142 -0
- package/es/module.d.ts +3 -0
- package/es/module.d.ts.map +1 -0
- package/es/module.js +9 -0
- package/es/page-config.d.ts +36 -0
- package/es/page-config.d.ts.map +1 -0
- package/es/page-config.js +129 -0
- package/es/protocol.d.ts +13 -0
- package/es/protocol.d.ts.map +1 -0
- package/es/protocol.js +8 -0
- package/es/server/connection-error.d.ts +36 -0
- package/es/server/connection-error.d.ts.map +1 -0
- package/es/server/connection-error.js +109 -0
- package/es/server/index.d.ts +6 -0
- package/es/server/index.d.ts.map +1 -0
- package/es/server/index.js +5 -0
- package/es/server/server-connection-protocol.d.ts +49 -0
- package/es/server/server-connection-protocol.d.ts.map +1 -0
- package/es/server/server-connection-protocol.js +0 -0
- package/es/server/server-connection.d.ts +25 -0
- package/es/server/server-connection.d.ts.map +1 -0
- package/es/server/server-connection.js +159 -0
- package/es/server/server-manager.d.ts +22 -0
- package/es/server/server-manager.d.ts.map +1 -0
- package/es/server/server-manager.js +163 -0
- package/es/server/server-module.d.ts +3 -0
- package/es/server/server-module.d.ts.map +1 -0
- package/es/server/server-module.js +4 -0
- package/es/session/index.d.ts +5 -0
- package/es/session/index.d.ts.map +1 -0
- package/es/session/index.js +4 -0
- package/es/session/libro-session-manager.d.ts +71 -0
- package/es/session/libro-session-manager.d.ts.map +1 -0
- package/es/session/libro-session-manager.js +539 -0
- package/es/session/libro-session-protocol.d.ts +50 -0
- package/es/session/libro-session-protocol.d.ts.map +1 -0
- package/es/session/libro-session-protocol.js +21 -0
- package/es/session/libro-session.d.ts +12 -0
- package/es/session/libro-session.d.ts.map +1 -0
- package/es/session/libro-session.js +19 -0
- package/es/session/restapi.d.ts +28 -0
- package/es/session/restapi.d.ts.map +1 -0
- package/es/session/restapi.js +214 -0
- package/es/session/session-module.d.ts +3 -0
- package/es/session/session-module.d.ts.map +1 -0
- package/es/session/session-module.js +18 -0
- package/es/session/validate.d.ts +14 -0
- package/es/session/validate.d.ts.map +1 -0
- package/es/session/validate.js +37 -0
- package/es/utils.d.ts +4 -0
- package/es/utils.d.ts.map +1 -0
- package/es/utils.js +29 -0
- package/es/validate-property.d.ts +2 -0
- package/es/validate-property.d.ts.map +1 -0
- package/es/validate-property.js +35 -0
- package/package.json +62 -0
- package/src/basemanager.ts +133 -0
- package/src/contents/contents-drive.ts +495 -0
- package/src/contents/contents-manager.ts +465 -0
- package/src/contents/contents-module.ts +6 -0
- package/src/contents/contents-protocol.ts +604 -0
- package/src/contents/index.ts +5 -0
- package/src/contents/validate.ts +29 -0
- package/src/index.tsx +9 -0
- package/src/kernel/comm.ts +220 -0
- package/src/kernel/future.ts +474 -0
- package/src/kernel/index.ts +7 -0
- package/src/kernel/kernel-connection.ts +1770 -0
- package/src/kernel/kernel-module.ts +50 -0
- package/src/kernel/libro-kernel-manager.ts +199 -0
- package/src/kernel/libro-kernel-protocol.ts +858 -0
- package/src/kernel/libro-kernel-utils.ts +152 -0
- package/src/kernel/libro-kernel.ts +39 -0
- package/src/kernel/messages.ts +1104 -0
- package/src/kernel/restapi.ts +183 -0
- package/src/kernel/serialize.ts +262 -0
- package/src/kernel/validate.ts +101 -0
- package/src/kernelspec/index.ts +5 -0
- package/src/kernelspec/kernelspec-module.ts +9 -0
- package/src/kernelspec/kernelspec.ts +37 -0
- package/src/kernelspec/manager.ts +173 -0
- package/src/kernelspec/restapi.ts +104 -0
- package/src/kernelspec/validate.ts +80 -0
- package/src/libro-kernel-connection-manager.ts +73 -0
- package/src/module.ts +19 -0
- package/src/page-config.ts +106 -0
- package/src/protocol.ts +24 -0
- package/src/server/connection-error.ts +60 -0
- package/src/server/index.ts +5 -0
- package/src/server/server-connection-protocol.ts +57 -0
- package/src/server/server-connection.ts +144 -0
- package/src/server/server-manager.ts +76 -0
- package/src/server/server-module.ts +9 -0
- package/src/session/index.ts +4 -0
- package/src/session/libro-session-manager.ts +377 -0
- package/src/session/libro-session-protocol.ts +61 -0
- package/src/session/libro-session.ts +33 -0
- package/src/session/restapi.ts +126 -0
- package/src/session/session-module.ts +26 -0
- package/src/session/validate.ts +39 -0
- package/src/utils.ts +28 -0
- package/src/validate-property.ts +38 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
var _dec, _dec2, _class, _class2, _descriptor;
|
|
3
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
4
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
5
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
7
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
8
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
9
|
+
function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }
|
|
10
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
11
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
12
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
13
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
14
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
15
|
+
function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
|
|
16
|
+
function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
|
|
17
|
+
// import { URL } from '@difizen/libro-common';
|
|
18
|
+
|
|
19
|
+
import { inject, singleton } from '@difizen/mana-app';
|
|
20
|
+
import { createResponseError } from "../server/connection-error.js";
|
|
21
|
+
import { ServerConnection } from "../server/server-connection.js";
|
|
22
|
+
import { validateSpecModels } from "./validate.js";
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The url for the kernelspec service.
|
|
26
|
+
*/
|
|
27
|
+
var KERNELSPEC_SERVICE_URL = 'api/kernelspecs';
|
|
28
|
+
export var KernelSpecRestAPI = (_dec = singleton(), _dec2 = inject(ServerConnection), _dec(_class = (_class2 = /*#__PURE__*/function () {
|
|
29
|
+
function KernelSpecRestAPI() {
|
|
30
|
+
_classCallCheck(this, KernelSpecRestAPI);
|
|
31
|
+
_initializerDefineProperty(this, "serverConnection", _descriptor, this);
|
|
32
|
+
}
|
|
33
|
+
_createClass(KernelSpecRestAPI, [{
|
|
34
|
+
key: "getSpecs",
|
|
35
|
+
value:
|
|
36
|
+
/**
|
|
37
|
+
* Fetch all of the kernel specs.
|
|
38
|
+
*
|
|
39
|
+
* @param settings - The optional server settings.
|
|
40
|
+
* @param useCache - Whether to use the cache. If false, always request.
|
|
41
|
+
*
|
|
42
|
+
* @returns A promise that resolves with the kernel specs.
|
|
43
|
+
*
|
|
44
|
+
* #### Notes
|
|
45
|
+
* Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/notebook/master/notebook/services/api/api.yaml#!/kernelspecs).
|
|
46
|
+
*/
|
|
47
|
+
function () {
|
|
48
|
+
var _getSpecs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(serverSettings) {
|
|
49
|
+
var settings, url, response, err, data;
|
|
50
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
51
|
+
while (1) switch (_context.prev = _context.next) {
|
|
52
|
+
case 0:
|
|
53
|
+
settings = _objectSpread(_objectSpread({}, this.serverConnection.settings), serverSettings);
|
|
54
|
+
url = settings.baseUrl + KERNELSPEC_SERVICE_URL; // TODO: 当前URL.join 方法是坏的
|
|
55
|
+
// const url = URL.join(settings.baseUrl, KERNELSPEC_SERVICE_URL);
|
|
56
|
+
_context.next = 4;
|
|
57
|
+
return this.serverConnection.makeRequest(url, {}, settings);
|
|
58
|
+
case 4:
|
|
59
|
+
response = _context.sent;
|
|
60
|
+
if (!(response.status !== 200)) {
|
|
61
|
+
_context.next = 10;
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
_context.next = 8;
|
|
65
|
+
return createResponseError(response);
|
|
66
|
+
case 8:
|
|
67
|
+
err = _context.sent;
|
|
68
|
+
throw err;
|
|
69
|
+
case 10:
|
|
70
|
+
_context.next = 12;
|
|
71
|
+
return response.json();
|
|
72
|
+
case 12:
|
|
73
|
+
data = _context.sent;
|
|
74
|
+
return _context.abrupt("return", validateSpecModels(data));
|
|
75
|
+
case 14:
|
|
76
|
+
case "end":
|
|
77
|
+
return _context.stop();
|
|
78
|
+
}
|
|
79
|
+
}, _callee, this);
|
|
80
|
+
}));
|
|
81
|
+
function getSpecs(_x) {
|
|
82
|
+
return _getSpecs.apply(this, arguments);
|
|
83
|
+
}
|
|
84
|
+
return getSpecs;
|
|
85
|
+
}()
|
|
86
|
+
}]);
|
|
87
|
+
return KernelSpecRestAPI;
|
|
88
|
+
}(), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "serverConnection", [_dec2], {
|
|
89
|
+
configurable: true,
|
|
90
|
+
enumerable: true,
|
|
91
|
+
writable: true,
|
|
92
|
+
initializer: null
|
|
93
|
+
})), _class2)) || _class);
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Kernel Spec interface.
|
|
97
|
+
*
|
|
98
|
+
* #### Notes
|
|
99
|
+
* See [Kernel specs](https://jupyter-client.readthedocs.io/en/latest/kernels.html#kernelspecs).
|
|
100
|
+
*/
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* The available kernelSpec models.
|
|
104
|
+
*
|
|
105
|
+
* #### Notes
|
|
106
|
+
* See the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/notebook/master/notebook/services/api/api.yaml#!/kernelspecs).
|
|
107
|
+
*/
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ISpecModel, ISpecModels } from './restapi.js';
|
|
2
|
+
/**
|
|
3
|
+
* Validate a server kernelspec model to a client side model.
|
|
4
|
+
*/
|
|
5
|
+
export declare function validateSpecModel(data: any): ISpecModel;
|
|
6
|
+
/**
|
|
7
|
+
* Validate a `Kernel.ISpecModels` object.
|
|
8
|
+
*/
|
|
9
|
+
export declare function validateSpecModels(data: any): ISpecModels;
|
|
10
|
+
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/kernelspec/validate.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE5D;;GAEG;AAEH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,GAAG,GAAG,UAAU,CA+BvD;AAED;;GAEG;AAEH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,GAAG,GAAG,WAAW,CAiCzD"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/* eslint-disable no-prototype-builtins */
|
|
2
|
+
import { validateProperty } from "../validate-property.js";
|
|
3
|
+
/**
|
|
4
|
+
* Validate a server kernelspec model to a client side model.
|
|
5
|
+
*/ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
6
|
+
export function validateSpecModel(data) {
|
|
7
|
+
var spec = data.spec;
|
|
8
|
+
if (!spec) {
|
|
9
|
+
throw new Error('Invalid kernel spec');
|
|
10
|
+
}
|
|
11
|
+
validateProperty(data, 'name', 'string');
|
|
12
|
+
validateProperty(data, 'resources', 'object');
|
|
13
|
+
validateProperty(spec, 'language', 'string');
|
|
14
|
+
validateProperty(spec, 'display_name', 'string');
|
|
15
|
+
validateProperty(spec, 'argv', 'array');
|
|
16
|
+
var metadata = null;
|
|
17
|
+
if (spec.hasOwnProperty('metadata')) {
|
|
18
|
+
validateProperty(spec, 'metadata', 'object');
|
|
19
|
+
metadata = spec.metadata;
|
|
20
|
+
}
|
|
21
|
+
var env = null;
|
|
22
|
+
if (spec.hasOwnProperty('env')) {
|
|
23
|
+
validateProperty(spec, 'env', 'object');
|
|
24
|
+
env = spec.env;
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
name: data.name,
|
|
28
|
+
resources: data.resources,
|
|
29
|
+
language: spec.language,
|
|
30
|
+
display_name: spec.display_name,
|
|
31
|
+
argv: spec.argv,
|
|
32
|
+
metadata: metadata,
|
|
33
|
+
env: env
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Validate a `Kernel.ISpecModels` object.
|
|
39
|
+
*/
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
41
|
+
export function validateSpecModels(data) {
|
|
42
|
+
if (!data.hasOwnProperty('kernelspecs')) {
|
|
43
|
+
throw new Error('No kernelspecs found');
|
|
44
|
+
}
|
|
45
|
+
var keys = Object.keys(data.kernelspecs);
|
|
46
|
+
var kernelspecs = Object.create(null);
|
|
47
|
+
var defaultSpec = data.default;
|
|
48
|
+
for (var i = 0; i < keys.length; i++) {
|
|
49
|
+
var ks = data.kernelspecs[keys[i]];
|
|
50
|
+
try {
|
|
51
|
+
kernelspecs[keys[i]] = validateSpecModel(ks);
|
|
52
|
+
} catch (err) {
|
|
53
|
+
// Remove the errant kernel spec.
|
|
54
|
+
console.warn("Removing errant kernel spec: ".concat(keys[i]));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
keys = Object.keys(kernelspecs);
|
|
58
|
+
if (!keys.length) {
|
|
59
|
+
throw new Error('No valid kernelspecs found');
|
|
60
|
+
}
|
|
61
|
+
if (!defaultSpec || typeof defaultSpec !== 'string' || !(defaultSpec in kernelspecs)) {
|
|
62
|
+
defaultSpec = keys[0];
|
|
63
|
+
console.warn("Default kernel not found, using '".concat(keys[0], "'"));
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
default: defaultSpec,
|
|
67
|
+
kernelspecs: kernelspecs
|
|
68
|
+
};
|
|
69
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { IContentsModel } from './contents/index.js';
|
|
2
|
+
import { LibroKernelManager } from './kernel/libro-kernel-manager.js';
|
|
3
|
+
import type { IKernelConnection } from './kernel/libro-kernel-protocol.js';
|
|
4
|
+
import { LibroSessionManager } from './session/libro-session-manager.js';
|
|
5
|
+
export declare class LibroKernelConnectionManager {
|
|
6
|
+
protected sessionManager: LibroSessionManager;
|
|
7
|
+
protected kernelManager: LibroKernelManager;
|
|
8
|
+
private kernelConnectionMap;
|
|
9
|
+
constructor(sessionManager: LibroSessionManager, kernelManager: LibroKernelManager);
|
|
10
|
+
startNew(fileInfo: IContentsModel): Promise<IKernelConnection | undefined>;
|
|
11
|
+
changeKernel(fileInfo: IContentsModel, reuseKernelInfo: {
|
|
12
|
+
id?: string;
|
|
13
|
+
name: string;
|
|
14
|
+
}): Promise<IKernelConnection>;
|
|
15
|
+
shutdownKC(fileInfo: IContentsModel): Promise<void>;
|
|
16
|
+
getAllKernelConnections(): Map<string, IKernelConnection>;
|
|
17
|
+
getKernelConnection(fileInfo: IContentsModel): IKernelConnection | undefined;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=libro-kernel-connection-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"libro-kernel-connection-manager.d.ts","sourceRoot":"","sources":["../src/libro-kernel-connection-manager.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAC3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAEzE,qBACa,4BAA4B;IACvC,SAAS,CAAC,cAAc,EAAE,mBAAmB,CAAC;IAC9C,SAAS,CAAC,aAAa,EAAE,kBAAkB,CAAC;IAG5C,OAAO,CAAC,mBAAmB,CAAiC;gBAG7B,cAAc,EAAE,mBAAmB,EACpC,aAAa,EAAE,kBAAkB;IAOzD,QAAQ,CAAC,QAAQ,EAAE,cAAc,GAAG,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC;IAS1E,YAAY,CAChB,QAAQ,EAAE,cAAc,EACxB,eAAe,EAAE;QAAE,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE;IAa1C,UAAU,CAAC,QAAQ,EAAE,cAAc;IAYzC,uBAAuB;IAIvB,mBAAmB,CAAC,QAAQ,EAAE,cAAc;CAO7C"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
var _dec, _dec2, _class, _class2, _descriptor;
|
|
3
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
4
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
5
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
6
|
+
function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }
|
|
7
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
8
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
9
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
10
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
11
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
12
|
+
function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
|
|
13
|
+
function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
|
|
14
|
+
import { inject, singleton } from '@difizen/mana-app';
|
|
15
|
+
import { prop } from '@difizen/mana-app';
|
|
16
|
+
import { LibroKernelManager } from "./kernel/libro-kernel-manager.js";
|
|
17
|
+
import { LibroSessionManager } from "./session/libro-session-manager.js";
|
|
18
|
+
export var LibroKernelConnectionManager = (_dec = singleton(), _dec2 = prop(), _dec(_class = (_class2 = /*#__PURE__*/function () {
|
|
19
|
+
function LibroKernelConnectionManager(sessionManager, kernelManager) {
|
|
20
|
+
_classCallCheck(this, LibroKernelConnectionManager);
|
|
21
|
+
_initializerDefineProperty(this, "kernelConnectionMap", _descriptor, this);
|
|
22
|
+
this.sessionManager = sessionManager;
|
|
23
|
+
this.kernelManager = kernelManager;
|
|
24
|
+
this.kernelConnectionMap = new Map();
|
|
25
|
+
}
|
|
26
|
+
LibroKernelConnectionManager = inject(LibroKernelManager)(LibroKernelConnectionManager, undefined, 1) || LibroKernelConnectionManager;
|
|
27
|
+
LibroKernelConnectionManager = inject(LibroSessionManager)(LibroKernelConnectionManager, undefined, 0) || LibroKernelConnectionManager;
|
|
28
|
+
_createClass(LibroKernelConnectionManager, [{
|
|
29
|
+
key: "startNew",
|
|
30
|
+
value: function () {
|
|
31
|
+
var _startNew = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(fileInfo) {
|
|
32
|
+
var connection;
|
|
33
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
34
|
+
while (1) switch (_context.prev = _context.next) {
|
|
35
|
+
case 0:
|
|
36
|
+
_context.next = 2;
|
|
37
|
+
return this.sessionManager.startNew(fileInfo);
|
|
38
|
+
case 2:
|
|
39
|
+
connection = _context.sent;
|
|
40
|
+
if (connection) {
|
|
41
|
+
_context.next = 5;
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
throw new Error('start new kernel connection failed');
|
|
45
|
+
case 5:
|
|
46
|
+
this.kernelConnectionMap.set(fileInfo.name, connection);
|
|
47
|
+
return _context.abrupt("return", connection);
|
|
48
|
+
case 7:
|
|
49
|
+
case "end":
|
|
50
|
+
return _context.stop();
|
|
51
|
+
}
|
|
52
|
+
}, _callee, this);
|
|
53
|
+
}));
|
|
54
|
+
function startNew(_x) {
|
|
55
|
+
return _startNew.apply(this, arguments);
|
|
56
|
+
}
|
|
57
|
+
return startNew;
|
|
58
|
+
}()
|
|
59
|
+
}, {
|
|
60
|
+
key: "changeKernel",
|
|
61
|
+
value: function () {
|
|
62
|
+
var _changeKernel = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(fileInfo, reuseKernelInfo) {
|
|
63
|
+
var connection;
|
|
64
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
65
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
66
|
+
case 0:
|
|
67
|
+
_context2.next = 2;
|
|
68
|
+
return this.sessionManager.changeKernel(fileInfo, reuseKernelInfo);
|
|
69
|
+
case 2:
|
|
70
|
+
connection = _context2.sent;
|
|
71
|
+
if (connection) {
|
|
72
|
+
_context2.next = 5;
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
throw new Error('change kernel connection failed');
|
|
76
|
+
case 5:
|
|
77
|
+
this.kernelConnectionMap.set(fileInfo.name, connection);
|
|
78
|
+
return _context2.abrupt("return", connection);
|
|
79
|
+
case 7:
|
|
80
|
+
case "end":
|
|
81
|
+
return _context2.stop();
|
|
82
|
+
}
|
|
83
|
+
}, _callee2, this);
|
|
84
|
+
}));
|
|
85
|
+
function changeKernel(_x2, _x3) {
|
|
86
|
+
return _changeKernel.apply(this, arguments);
|
|
87
|
+
}
|
|
88
|
+
return changeKernel;
|
|
89
|
+
}()
|
|
90
|
+
}, {
|
|
91
|
+
key: "shutdownKC",
|
|
92
|
+
value: function () {
|
|
93
|
+
var _shutdownKC = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(fileInfo) {
|
|
94
|
+
var fileName, kc;
|
|
95
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
96
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
97
|
+
case 0:
|
|
98
|
+
fileName = fileInfo.name;
|
|
99
|
+
kc = this.kernelConnectionMap.get(fileName);
|
|
100
|
+
if (kc) {
|
|
101
|
+
_context3.next = 4;
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
throw new Error('interrupt connection failed');
|
|
105
|
+
case 4:
|
|
106
|
+
_context3.next = 6;
|
|
107
|
+
return this.sessionManager.shutdownKC(fileInfo, kc);
|
|
108
|
+
case 6:
|
|
109
|
+
this.kernelConnectionMap.delete(fileName);
|
|
110
|
+
case 7:
|
|
111
|
+
case "end":
|
|
112
|
+
return _context3.stop();
|
|
113
|
+
}
|
|
114
|
+
}, _callee3, this);
|
|
115
|
+
}));
|
|
116
|
+
function shutdownKC(_x4) {
|
|
117
|
+
return _shutdownKC.apply(this, arguments);
|
|
118
|
+
}
|
|
119
|
+
return shutdownKC;
|
|
120
|
+
}()
|
|
121
|
+
}, {
|
|
122
|
+
key: "getAllKernelConnections",
|
|
123
|
+
value: function getAllKernelConnections() {
|
|
124
|
+
return this.kernelConnectionMap;
|
|
125
|
+
}
|
|
126
|
+
}, {
|
|
127
|
+
key: "getKernelConnection",
|
|
128
|
+
value: function getKernelConnection(fileInfo) {
|
|
129
|
+
var connection = this.kernelConnectionMap.get(fileInfo.name);
|
|
130
|
+
if (connection && !connection.isDisposed) {
|
|
131
|
+
return connection;
|
|
132
|
+
}
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
}]);
|
|
136
|
+
return LibroKernelConnectionManager;
|
|
137
|
+
}(), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "kernelConnectionMap", [_dec2], {
|
|
138
|
+
configurable: true,
|
|
139
|
+
enumerable: true,
|
|
140
|
+
writable: true,
|
|
141
|
+
initializer: null
|
|
142
|
+
})), _class2)) || _class);
|
package/es/module.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAU/C,eAAO,MAAM,uBAAuB,YAQkB,CAAC"}
|
package/es/module.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ManaModule } from '@difizen/mana-app';
|
|
2
|
+
import { BaseManager } from "./basemanager.js";
|
|
3
|
+
import { LibroContentsModule } from "./contents/contents-module.js";
|
|
4
|
+
import { LibroKernelModule } from "./kernel/kernel-module.js";
|
|
5
|
+
import { LibroKernelSpecModule } from "./kernelspec/index.js";
|
|
6
|
+
import { LibroKernelConnectionManager } from "./libro-kernel-connection-manager.js";
|
|
7
|
+
import { LibroServerModule } from "./server/index.js";
|
|
8
|
+
import { LibroSessionModule } from "./session/session-module.js";
|
|
9
|
+
export var LibroKernelManageModule = ManaModule.create().dependOn(LibroSessionModule, LibroKernelModule, LibroServerModule, LibroKernelSpecModule, LibroContentsModule).register(BaseManager, LibroKernelConnectionManager);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export declare class PageConfig {
|
|
2
|
+
static defaultWorkspace: string;
|
|
3
|
+
/**
|
|
4
|
+
* Get a url-encoded item from `body.data` and decode it
|
|
5
|
+
* We should never have any encoded URLs anywhere else in code
|
|
6
|
+
* until we are building an actual request.
|
|
7
|
+
*/
|
|
8
|
+
static getBodyData(key: string): string;
|
|
9
|
+
static getOption(name: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Set global configuration data for the Jupyter application.
|
|
12
|
+
*
|
|
13
|
+
* @param name - The name of the configuration option.
|
|
14
|
+
* @param value - The value to set the option to.
|
|
15
|
+
*
|
|
16
|
+
* @returns The last config value or an empty string if it doesn't exist.
|
|
17
|
+
*/
|
|
18
|
+
static setOption(name: string, value: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* Get the base url for a Jupyter application, or the base url of the page.
|
|
21
|
+
*/
|
|
22
|
+
static getBaseUrl(): string;
|
|
23
|
+
/**
|
|
24
|
+
* Get the base websocket url for a Jupyter application, or an empty string.
|
|
25
|
+
*/
|
|
26
|
+
static getWsUrl(baseUrl?: string): string;
|
|
27
|
+
/**
|
|
28
|
+
* Get the authorization token for a Jupyter application.
|
|
29
|
+
*/
|
|
30
|
+
static getToken(): string;
|
|
31
|
+
/**
|
|
32
|
+
* Get the Notebook version info [major, minor, patch].
|
|
33
|
+
*/
|
|
34
|
+
static getNotebookVersion(): [number, number, number];
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=page-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page-config.d.ts","sourceRoot":"","sources":["../src/page-config.ts"],"names":[],"mappings":"AAQA,qBAAa,UAAU;IACrB,MAAM,CAAC,gBAAgB,SAAa;IACpC;;;;OAIG;IACH,MAAM,CAAC,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAUvC,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IA0BtC;;;;;;;OAOG;IACH,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM;IAOrD;;OAEG;IACH,MAAM,CAAC,UAAU,IAAI,MAAM;IAI3B;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM;IAYzC;;OAEG;IACH,MAAM,CAAC,QAAQ,IAAI,MAAM;IAIzB;;OAEG;IACH,MAAM,CAAC,kBAAkB,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;CAOtD"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
3
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
4
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
5
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
7
|
+
import { isObject, URL } from '@difizen/libro-common';
|
|
8
|
+
import { isWeb } from '@difizen/mana-app';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* page config data for the Jupyter application.
|
|
12
|
+
*/
|
|
13
|
+
var configData = null;
|
|
14
|
+
export var PageConfig = /*#__PURE__*/function () {
|
|
15
|
+
function PageConfig() {
|
|
16
|
+
_classCallCheck(this, PageConfig);
|
|
17
|
+
}
|
|
18
|
+
_createClass(PageConfig, null, [{
|
|
19
|
+
key: "getBodyData",
|
|
20
|
+
value:
|
|
21
|
+
/**
|
|
22
|
+
* Get a url-encoded item from `body.data` and decode it
|
|
23
|
+
* We should never have any encoded URLs anywhere else in code
|
|
24
|
+
* until we are building an actual request.
|
|
25
|
+
*/
|
|
26
|
+
function getBodyData(key) {
|
|
27
|
+
if (typeof document === 'undefined' || !document.body) {
|
|
28
|
+
return '';
|
|
29
|
+
}
|
|
30
|
+
var val = document.body.dataset[key];
|
|
31
|
+
if (typeof val === 'undefined') {
|
|
32
|
+
return '';
|
|
33
|
+
}
|
|
34
|
+
return decodeURIComponent(val);
|
|
35
|
+
}
|
|
36
|
+
}, {
|
|
37
|
+
key: "getOption",
|
|
38
|
+
value: function getOption(name) {
|
|
39
|
+
if (configData) {
|
|
40
|
+
return configData[name] || PageConfig.getBodyData(name);
|
|
41
|
+
}
|
|
42
|
+
configData = Object.create(null);
|
|
43
|
+
// Use script tag if available.
|
|
44
|
+
if (isWeb) {
|
|
45
|
+
var el = document.getElementById('jupyter-config-data');
|
|
46
|
+
if (el) {
|
|
47
|
+
configData = JSON.parse(el.textContent || '');
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (!isObject(configData)) {
|
|
51
|
+
configData = Object.create(null);
|
|
52
|
+
} else {
|
|
53
|
+
for (var key in configData) {
|
|
54
|
+
// PageConfig expects strings
|
|
55
|
+
if (typeof configData[key] !== 'string') {
|
|
56
|
+
configData[key] = JSON.stringify(configData[key]);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return configData[name] || PageConfig.getBodyData(name);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Set global configuration data for the Jupyter application.
|
|
65
|
+
*
|
|
66
|
+
* @param name - The name of the configuration option.
|
|
67
|
+
* @param value - The value to set the option to.
|
|
68
|
+
*
|
|
69
|
+
* @returns The last config value or an empty string if it doesn't exist.
|
|
70
|
+
*/
|
|
71
|
+
}, {
|
|
72
|
+
key: "setOption",
|
|
73
|
+
value: function setOption(name, value) {
|
|
74
|
+
var last = PageConfig.getOption(name);
|
|
75
|
+
configData[name] = value;
|
|
76
|
+
return last;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Get the base url for a Jupyter application, or the base url of the page.
|
|
81
|
+
*/
|
|
82
|
+
}, {
|
|
83
|
+
key: "getBaseUrl",
|
|
84
|
+
value: function getBaseUrl() {
|
|
85
|
+
return URL.normalize(PageConfig.getOption('baseUrl') || '/');
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Get the base websocket url for a Jupyter application, or an empty string.
|
|
90
|
+
*/
|
|
91
|
+
}, {
|
|
92
|
+
key: "getWsUrl",
|
|
93
|
+
value: function getWsUrl(baseUrl) {
|
|
94
|
+
var wsUrl = PageConfig.getOption('wsUrl');
|
|
95
|
+
if (!wsUrl) {
|
|
96
|
+
baseUrl = baseUrl ? URL.normalize(baseUrl) : PageConfig.getBaseUrl();
|
|
97
|
+
if (baseUrl.indexOf('http') !== 0) {
|
|
98
|
+
return '';
|
|
99
|
+
}
|
|
100
|
+
wsUrl = 'ws' + baseUrl.slice(4);
|
|
101
|
+
}
|
|
102
|
+
return URL.normalize(wsUrl);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Get the authorization token for a Jupyter application.
|
|
107
|
+
*/
|
|
108
|
+
}, {
|
|
109
|
+
key: "getToken",
|
|
110
|
+
value: function getToken() {
|
|
111
|
+
return PageConfig.getOption('token') || PageConfig.getBodyData('jupyterApiToken');
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Get the Notebook version info [major, minor, patch].
|
|
116
|
+
*/
|
|
117
|
+
}, {
|
|
118
|
+
key: "getNotebookVersion",
|
|
119
|
+
value: function getNotebookVersion() {
|
|
120
|
+
var notebookVersion = PageConfig.getOption('notebookVersion');
|
|
121
|
+
if (notebookVersion === '') {
|
|
122
|
+
return [0, 0, 0];
|
|
123
|
+
}
|
|
124
|
+
return JSON.parse(notebookVersion);
|
|
125
|
+
}
|
|
126
|
+
}]);
|
|
127
|
+
return PageConfig;
|
|
128
|
+
}();
|
|
129
|
+
PageConfig.defaultWorkspace = 'default';
|
package/es/protocol.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { NotebookModel } from '@difizen/libro-core';
|
|
2
|
+
import type { IContentsModel } from './contents/index.js';
|
|
3
|
+
import type { IKernelConnection } from './kernel/index.js';
|
|
4
|
+
export declare const ExecutableNotebookModel: {
|
|
5
|
+
is: (arg: Record<any, any> | undefined) => arg is ExecutableNotebookModel;
|
|
6
|
+
};
|
|
7
|
+
export interface ExecutableNotebookModel extends NotebookModel {
|
|
8
|
+
filePath: string;
|
|
9
|
+
currentFileContents: IContentsModel;
|
|
10
|
+
kernelConnection?: IKernelConnection;
|
|
11
|
+
kcReady: Promise<IKernelConnection>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE3D,eAAO,MAAM,uBAAuB;cACxB,OAAO,GAAG,EAAE,GAAG,CAAC,GAAG,SAAS;CAUvC,CAAC;AAEF,MAAM,WAAW,uBAAwB,SAAQ,aAAa;IAC5D,QAAQ,EAAE,MAAM,CAAC;IACjB,mBAAmB,EAAE,cAAc,CAAC;IACpC,gBAAgB,CAAC,EAAE,iBAAiB,CAAC;IACrC,OAAO,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC;CACrC"}
|
package/es/protocol.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
export var ExecutableNotebookModel = {
|
|
3
|
+
is: function is(arg) {
|
|
4
|
+
return !!arg &&
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6
|
+
'filePath' in arg && typeof arg.filePath === 'string' && 'currentFileContents' in arg && _typeof(arg.currentFileContents) === 'object';
|
|
7
|
+
}
|
|
8
|
+
};
|