@difizen/libro-kernel 0.0.0-snapshot-20241017072317

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.
Files changed (188) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -0
  3. package/es/basemanager.d.ts +94 -0
  4. package/es/basemanager.d.ts.map +1 -0
  5. package/es/basemanager.js +110 -0
  6. package/es/contents/contents-drive.d.ts +189 -0
  7. package/es/contents/contents-drive.d.ts.map +1 -0
  8. package/es/contents/contents-drive.js +802 -0
  9. package/es/contents/contents-manager.d.ts +229 -0
  10. package/es/contents/contents-manager.d.ts.map +1 -0
  11. package/es/contents/contents-manager.js +551 -0
  12. package/es/contents/contents-module.d.ts +3 -0
  13. package/es/contents/contents-module.d.ts.map +1 -0
  14. package/es/contents/contents-module.js +4 -0
  15. package/es/contents/contents-protocol.d.ts +487 -0
  16. package/es/contents/contents-protocol.d.ts.map +1 -0
  17. package/es/contents/contents-protocol.js +1 -0
  18. package/es/contents/index.d.ts +6 -0
  19. package/es/contents/index.d.ts.map +1 -0
  20. package/es/contents/index.js +5 -0
  21. package/es/contents/validate.d.ts +10 -0
  22. package/es/contents/validate.d.ts.map +1 -0
  23. package/es/contents/validate.js +22 -0
  24. package/es/index.d.ts +10 -0
  25. package/es/index.d.ts.map +1 -0
  26. package/es/index.js +9 -0
  27. package/es/kernel/comm.d.ts +92 -0
  28. package/es/kernel/comm.d.ts.map +1 -0
  29. package/es/kernel/comm.js +216 -0
  30. package/es/kernel/future.d.ts +178 -0
  31. package/es/kernel/future.d.ts.map +1 -0
  32. package/es/kernel/future.js +593 -0
  33. package/es/kernel/index.d.ts +8 -0
  34. package/es/kernel/index.d.ts.map +1 -0
  35. package/es/kernel/index.js +8 -0
  36. package/es/kernel/kernel-connection.d.ts +553 -0
  37. package/es/kernel/kernel-connection.d.ts.map +1 -0
  38. package/es/kernel/kernel-connection.js +1974 -0
  39. package/es/kernel/kernel-module.d.ts +3 -0
  40. package/es/kernel/kernel-module.d.ts.map +1 -0
  41. package/es/kernel/kernel-module.js +32 -0
  42. package/es/kernel/libro-kernel-manager.d.ts +89 -0
  43. package/es/kernel/libro-kernel-manager.d.ts.map +1 -0
  44. package/es/kernel/libro-kernel-manager.js +469 -0
  45. package/es/kernel/libro-kernel-protocol.d.ts +678 -0
  46. package/es/kernel/libro-kernel-protocol.d.ts.map +1 -0
  47. package/es/kernel/libro-kernel-protocol.js +60 -0
  48. package/es/kernel/libro-kernel-utils.d.ts +95 -0
  49. package/es/kernel/libro-kernel-utils.d.ts.map +1 -0
  50. package/es/kernel/libro-kernel-utils.js +130 -0
  51. package/es/kernel/libro-kernel.d.ts +14 -0
  52. package/es/kernel/libro-kernel.d.ts.map +1 -0
  53. package/es/kernel/libro-kernel.js +54 -0
  54. package/es/kernel/messages.d.ts +845 -0
  55. package/es/kernel/messages.d.ts.map +1 -0
  56. package/es/kernel/messages.js +513 -0
  57. package/es/kernel/restapi.d.ts +78 -0
  58. package/es/kernel/restapi.d.ts.map +1 -0
  59. package/es/kernel/restapi.js +372 -0
  60. package/es/kernel/serialize.d.ts +10 -0
  61. package/es/kernel/serialize.d.ts.map +1 -0
  62. package/es/kernel/serialize.js +213 -0
  63. package/es/kernel/validate.d.ts +15 -0
  64. package/es/kernel/validate.d.ts.map +1 -0
  65. package/es/kernel/validate.js +125 -0
  66. package/es/kernelspec/index.d.ts +5 -0
  67. package/es/kernelspec/index.d.ts.map +1 -0
  68. package/es/kernelspec/index.js +4 -0
  69. package/es/kernelspec/kernelspec-module.d.ts +3 -0
  70. package/es/kernelspec/kernelspec-module.d.ts.map +1 -0
  71. package/es/kernelspec/kernelspec-module.js +4 -0
  72. package/es/kernelspec/kernelspec.d.ts +33 -0
  73. package/es/kernelspec/kernelspec.d.ts.map +1 -0
  74. package/es/kernelspec/kernelspec.js +1 -0
  75. package/es/kernelspec/manager.d.ts +81 -0
  76. package/es/kernelspec/manager.d.ts.map +1 -0
  77. package/es/kernelspec/manager.js +245 -0
  78. package/es/kernelspec/restapi.d.ts +71 -0
  79. package/es/kernelspec/restapi.d.ts.map +1 -0
  80. package/es/kernelspec/restapi.js +107 -0
  81. package/es/kernelspec/validate.d.ts +10 -0
  82. package/es/kernelspec/validate.d.ts.map +1 -0
  83. package/es/kernelspec/validate.js +70 -0
  84. package/es/libro-kernel-connection-manager.d.ts +20 -0
  85. package/es/libro-kernel-connection-manager.d.ts.map +1 -0
  86. package/es/libro-kernel-connection-manager.js +146 -0
  87. package/es/module.d.ts +3 -0
  88. package/es/module.d.ts.map +1 -0
  89. package/es/module.js +9 -0
  90. package/es/page-config.d.ts +36 -0
  91. package/es/page-config.d.ts.map +1 -0
  92. package/es/page-config.js +129 -0
  93. package/es/protocol.d.ts +13 -0
  94. package/es/protocol.d.ts.map +1 -0
  95. package/es/protocol.js +8 -0
  96. package/es/server/connection-error.d.ts +36 -0
  97. package/es/server/connection-error.d.ts.map +1 -0
  98. package/es/server/connection-error.js +109 -0
  99. package/es/server/index.d.ts +6 -0
  100. package/es/server/index.d.ts.map +1 -0
  101. package/es/server/index.js +5 -0
  102. package/es/server/server-connection-protocol.d.ts +49 -0
  103. package/es/server/server-connection-protocol.d.ts.map +1 -0
  104. package/es/server/server-connection-protocol.js +0 -0
  105. package/es/server/server-connection.d.ts +25 -0
  106. package/es/server/server-connection.d.ts.map +1 -0
  107. package/es/server/server-connection.js +159 -0
  108. package/es/server/server-manager.d.ts +23 -0
  109. package/es/server/server-manager.d.ts.map +1 -0
  110. package/es/server/server-manager.js +178 -0
  111. package/es/server/server-module.d.ts +3 -0
  112. package/es/server/server-module.d.ts.map +1 -0
  113. package/es/server/server-module.js +4 -0
  114. package/es/session/index.d.ts +5 -0
  115. package/es/session/index.d.ts.map +1 -0
  116. package/es/session/index.js +4 -0
  117. package/es/session/libro-session-manager.d.ts +73 -0
  118. package/es/session/libro-session-manager.d.ts.map +1 -0
  119. package/es/session/libro-session-manager.js +568 -0
  120. package/es/session/libro-session-protocol.d.ts +50 -0
  121. package/es/session/libro-session-protocol.d.ts.map +1 -0
  122. package/es/session/libro-session-protocol.js +21 -0
  123. package/es/session/libro-session.d.ts +12 -0
  124. package/es/session/libro-session.d.ts.map +1 -0
  125. package/es/session/libro-session.js +19 -0
  126. package/es/session/restapi.d.ts +28 -0
  127. package/es/session/restapi.d.ts.map +1 -0
  128. package/es/session/restapi.js +215 -0
  129. package/es/session/session-module.d.ts +3 -0
  130. package/es/session/session-module.d.ts.map +1 -0
  131. package/es/session/session-module.js +18 -0
  132. package/es/session/validate.d.ts +14 -0
  133. package/es/session/validate.d.ts.map +1 -0
  134. package/es/session/validate.js +38 -0
  135. package/es/utils.d.ts +4 -0
  136. package/es/utils.d.ts.map +1 -0
  137. package/es/utils.js +29 -0
  138. package/es/validate-property.d.ts +2 -0
  139. package/es/validate-property.d.ts.map +1 -0
  140. package/es/validate-property.js +35 -0
  141. package/package.json +62 -0
  142. package/src/basemanager.ts +133 -0
  143. package/src/contents/contents-drive.ts +496 -0
  144. package/src/contents/contents-manager.ts +465 -0
  145. package/src/contents/contents-module.ts +6 -0
  146. package/src/contents/contents-protocol.ts +604 -0
  147. package/src/contents/index.ts +5 -0
  148. package/src/contents/validate.ts +29 -0
  149. package/src/index.spec.ts +16 -0
  150. package/src/index.tsx +9 -0
  151. package/src/kernel/comm.ts +220 -0
  152. package/src/kernel/future.ts +477 -0
  153. package/src/kernel/index.ts +7 -0
  154. package/src/kernel/kernel-connection.ts +1780 -0
  155. package/src/kernel/kernel-module.ts +50 -0
  156. package/src/kernel/libro-kernel-manager.ts +274 -0
  157. package/src/kernel/libro-kernel-protocol.ts +861 -0
  158. package/src/kernel/libro-kernel-utils.ts +152 -0
  159. package/src/kernel/libro-kernel.ts +39 -0
  160. package/src/kernel/messages.ts +1104 -0
  161. package/src/kernel/restapi.ts +183 -0
  162. package/src/kernel/serialize.ts +262 -0
  163. package/src/kernel/validate.ts +101 -0
  164. package/src/kernelspec/index.ts +5 -0
  165. package/src/kernelspec/kernelspec-module.ts +9 -0
  166. package/src/kernelspec/kernelspec.ts +37 -0
  167. package/src/kernelspec/manager.ts +162 -0
  168. package/src/kernelspec/restapi.ts +104 -0
  169. package/src/kernelspec/validate.ts +80 -0
  170. package/src/libro-kernel-connection-manager.ts +76 -0
  171. package/src/module.ts +19 -0
  172. package/src/page-config.ts +106 -0
  173. package/src/protocol.ts +24 -0
  174. package/src/server/connection-error.ts +60 -0
  175. package/src/server/index.ts +5 -0
  176. package/src/server/server-connection-protocol.ts +57 -0
  177. package/src/server/server-connection.ts +144 -0
  178. package/src/server/server-manager.ts +90 -0
  179. package/src/server/server-module.ts +9 -0
  180. package/src/session/index.ts +4 -0
  181. package/src/session/libro-session-manager.ts +406 -0
  182. package/src/session/libro-session-protocol.ts +61 -0
  183. package/src/session/libro-session.ts +33 -0
  184. package/src/session/restapi.ts +126 -0
  185. package/src/session/session-module.ts +26 -0
  186. package/src/session/validate.ts +39 -0
  187. package/src/utils.ts +28 -0
  188. package/src/validate-property.ts +38 -0
@@ -0,0 +1,593 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
3
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
4
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
5
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
6
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
7
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
8
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
9
+ 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 e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
10
+ 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); } }
11
+ 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); }); }; }
12
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
13
+ 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); } }
14
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
15
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
16
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
17
+ import { Disposable } from '@difizen/mana-app';
18
+ import { Deferred } from '@difizen/mana-app';
19
+ import { isStatusMsg } from "./libro-kernel-utils.js";
20
+ var Private;
21
+ (function (_Private) {
22
+ var noOp = _Private.noOp = function () {
23
+ /* no-op */
24
+ };
25
+ /**
26
+ * Defer a computation.
27
+ *
28
+ * #### NOTES
29
+ * We can't just use requestAnimationFrame since it is not available in node.
30
+ * This implementation is from Phosphor:
31
+ * https://github.com/phosphorjs/phosphor/blob/e88e4321289bb1198f3098e7bda40736501f2ed8/tests/test-messaging/src/index.spec.ts#L63
32
+ */
33
+ var defer = function () {
34
+ var ok = typeof requestAnimationFrame === 'function';
35
+ return ok ? requestAnimationFrame : setImmediate;
36
+ }();
37
+ var HookList = /*#__PURE__*/function () {
38
+ function HookList() {
39
+ _classCallCheck(this, HookList);
40
+ this._hooks = [];
41
+ }
42
+ _createClass(HookList, [{
43
+ key: "add",
44
+ value:
45
+ /**
46
+ * Register a hook.
47
+ *
48
+ * @param hook - The callback to register.
49
+ */
50
+ function add(hook) {
51
+ this.remove(hook);
52
+ this._hooks.push(hook);
53
+ }
54
+
55
+ /**
56
+ * Remove a hook, if it exists in the hook list.
57
+ *
58
+ * @param hook - The callback to remove.
59
+ */
60
+ }, {
61
+ key: "remove",
62
+ value: function remove(hook) {
63
+ var index = this._hooks.indexOf(hook);
64
+ if (index >= 0) {
65
+ this._hooks[index] = null;
66
+ this._scheduleCompact();
67
+ }
68
+ }
69
+
70
+ /**
71
+ * Process a message through the hooks.
72
+ *
73
+ * @returns a promise resolving to false if any hook resolved as false,
74
+ * otherwise true
75
+ *
76
+ * #### Notes
77
+ * The most recently registered hook is run first. A hook can return a
78
+ * boolean or a promise to a boolean, in which case processing pauses until
79
+ * the promise is fulfilled. If a hook return value resolves to false, any
80
+ * later hooks will not run and the function will return a promise resolving
81
+ * to false. If a hook throws an error, the error is logged to the console
82
+ * and the next hook is run. If a hook is registered during the hook
83
+ * processing, it will not run until the next message. If a hook is removed
84
+ * during the hook processing, it will be deactivated immediately.
85
+ */
86
+ }, {
87
+ key: "process",
88
+ value: (function () {
89
+ var _process = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(msg) {
90
+ var processing, continueHandling, i, hook;
91
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
92
+ while (1) switch (_context5.prev = _context5.next) {
93
+ case 0:
94
+ _context5.next = 2;
95
+ return this._processing;
96
+ case 2:
97
+ // Start the next process run.
98
+ processing = new Deferred();
99
+ this._processing = processing.promise;
100
+ i = this._hooks.length - 1;
101
+ case 5:
102
+ if (!(i >= 0)) {
103
+ _context5.next = 25;
104
+ break;
105
+ }
106
+ hook = this._hooks[i]; // If the hook has been removed, continue to the next one.
107
+ if (!(hook === null)) {
108
+ _context5.next = 9;
109
+ break;
110
+ }
111
+ return _context5.abrupt("continue", 22);
112
+ case 9:
113
+ _context5.prev = 9;
114
+ _context5.next = 12;
115
+ return hook(msg);
116
+ case 12:
117
+ continueHandling = _context5.sent;
118
+ _context5.next = 19;
119
+ break;
120
+ case 15:
121
+ _context5.prev = 15;
122
+ _context5.t0 = _context5["catch"](9);
123
+ continueHandling = true;
124
+ console.error(_context5.t0);
125
+ case 19:
126
+ if (!(continueHandling === false)) {
127
+ _context5.next = 22;
128
+ break;
129
+ }
130
+ processing.resolve(undefined);
131
+ return _context5.abrupt("return", false);
132
+ case 22:
133
+ i--;
134
+ _context5.next = 5;
135
+ break;
136
+ case 25:
137
+ // All hooks returned true (or errored out), so return true.
138
+ processing.resolve(undefined);
139
+ return _context5.abrupt("return", true);
140
+ case 27:
141
+ case "end":
142
+ return _context5.stop();
143
+ }
144
+ }, _callee5, this, [[9, 15]]);
145
+ }));
146
+ function process(_x5) {
147
+ return _process.apply(this, arguments);
148
+ }
149
+ return process;
150
+ }()
151
+ /**
152
+ * Schedule a cleanup of the list, removing any hooks that have been nulled out.
153
+ */
154
+ )
155
+ }, {
156
+ key: "_scheduleCompact",
157
+ value: function _scheduleCompact() {
158
+ var _this2 = this;
159
+ if (!this._compactScheduled) {
160
+ this._compactScheduled = true;
161
+
162
+ // Schedule a compaction in between processing runs. We do the
163
+ // scheduling in an animation frame to rate-limit our compactions. If we
164
+ // need to compact more frequently, we can change this to directly
165
+ // schedule the compaction.
166
+ defer(function () {
167
+ _this2._processing = _this2._processing.then(function () {
168
+ _this2._compactScheduled = false;
169
+ _this2._compact();
170
+ return;
171
+ });
172
+ });
173
+ }
174
+ }
175
+
176
+ /**
177
+ * Compact the list, removing any nulls.
178
+ */
179
+ }, {
180
+ key: "_compact",
181
+ value: function _compact() {
182
+ var numNulls = 0;
183
+ for (var i = 0, len = this._hooks.length; i < len; i++) {
184
+ var hook = this._hooks[i];
185
+ if (this._hooks[i] === null) {
186
+ numNulls++;
187
+ } else {
188
+ this._hooks[i - numNulls] = hook;
189
+ }
190
+ }
191
+ this._hooks.length -= numNulls;
192
+ }
193
+ }]);
194
+ return HookList;
195
+ }();
196
+ _Private.HookList = HookList;
197
+ var KernelFutureFlag = /*#__PURE__*/function (KernelFutureFlag) {
198
+ KernelFutureFlag[KernelFutureFlag["GotReply"] = 1] = "GotReply";
199
+ KernelFutureFlag[KernelFutureFlag["GotIdle"] = 2] = "GotIdle";
200
+ KernelFutureFlag[KernelFutureFlag["IsDone"] = 4] = "IsDone";
201
+ KernelFutureFlag[KernelFutureFlag["DisposeOnDone"] = 8] = "DisposeOnDone";
202
+ return KernelFutureFlag;
203
+ }({});
204
+ _Private.KernelFutureFlag = KernelFutureFlag;
205
+ })(Private || (Private = {}));
206
+ /**
207
+ * Implementation of a kernel future.
208
+ *
209
+ * If a reply is expected, the Future is considered done when both a `reply`
210
+ * message and an `idle` iopub status message have been received. Otherwise, it
211
+ * is considered done when the `idle` status is received.
212
+ *
213
+ */
214
+ export var KernelFutureHandler = /*#__PURE__*/function () {
215
+ /**
216
+ * Construct a new KernelFutureHandler.
217
+ */
218
+ function KernelFutureHandler(cb, msg, expectReply, disposeOnDone, kernel) {
219
+ _classCallCheck(this, KernelFutureHandler);
220
+ this.disposed = false;
221
+ this._status = 0;
222
+ this._stdin = Private.noOp;
223
+ this._iopub = Private.noOp;
224
+ this._reply = Private.noOp;
225
+ this._done = new Deferred();
226
+ this._hooks = new Private.HookList();
227
+ this._disposeOnDone = true;
228
+ this.disposeCb = cb;
229
+ this._msg = msg;
230
+ if (!expectReply) {
231
+ this._setFlag(Private.KernelFutureFlag.GotReply);
232
+ }
233
+ this._disposeOnDone = disposeOnDone;
234
+ this._kernel = kernel;
235
+ }
236
+
237
+ /**
238
+ * Get the original outgoing message.
239
+ */
240
+ _createClass(KernelFutureHandler, [{
241
+ key: "msg",
242
+ get: function get() {
243
+ return this._msg;
244
+ }
245
+
246
+ /**
247
+ * A promise that resolves when the future is done.
248
+ */
249
+ }, {
250
+ key: "done",
251
+ get: function get() {
252
+ return this._done.promise;
253
+ }
254
+
255
+ /**
256
+ * Get the reply handler.
257
+ */
258
+ }, {
259
+ key: "onReply",
260
+ get: function get() {
261
+ return this._reply;
262
+ }
263
+
264
+ /**
265
+ * Set the reply handler.
266
+ */,
267
+ set: function set(cb) {
268
+ this._reply = cb;
269
+ }
270
+
271
+ /**
272
+ * Get the iopub handler.
273
+ */
274
+ }, {
275
+ key: "onIOPub",
276
+ get: function get() {
277
+ return this._iopub;
278
+ }
279
+
280
+ /**
281
+ * Set the iopub handler.
282
+ */,
283
+ set: function set(cb) {
284
+ this._iopub = cb;
285
+ }
286
+
287
+ /**
288
+ * Get the stdin handler.
289
+ */
290
+ }, {
291
+ key: "onStdin",
292
+ get: function get() {
293
+ return this._stdin;
294
+ }
295
+
296
+ /**
297
+ * Set the stdin handler.
298
+ */,
299
+ set: function set(cb) {
300
+ this._stdin = cb;
301
+ }
302
+
303
+ /**
304
+ * Register hook for IOPub messages.
305
+ *
306
+ * @param hook - The callback invoked for an IOPub message.
307
+ *
308
+ * #### Notes
309
+ * The IOPub hook system allows you to preempt the handlers for IOPub
310
+ * messages handled by the future.
311
+ *
312
+ * The most recently registered hook is run first. A hook can return a
313
+ * boolean or a promise to a boolean, in which case all kernel message
314
+ * processing pauses until the promise is fulfilled. If a hook return value
315
+ * resolves to false, any later hooks will not run and the function will
316
+ * return a promise resolving to false. If a hook throws an error, the error
317
+ * is logged to the console and the next hook is run. If a hook is
318
+ * registered during the hook processing, it will not run until the next
319
+ * message. If a hook is removed during the hook processing, it will be
320
+ * deactivated immediately.
321
+ */
322
+ }, {
323
+ key: "registerMessageHook",
324
+ value: function registerMessageHook(hook) {
325
+ var _this = this;
326
+ if (this.disposed) {
327
+ throw new Error('Kernel future is disposed');
328
+ }
329
+ this._hooks.add(hook);
330
+ return Disposable.create(function () {
331
+ _this.removeMessageHook(hook);
332
+ });
333
+ }
334
+
335
+ /**
336
+ * Remove a hook for IOPub messages.
337
+ *
338
+ * @param hook - The hook to remove.
339
+ *
340
+ * #### Notes
341
+ * If a hook is removed during the hook processing, it will be deactivated immediately.
342
+ */
343
+ }, {
344
+ key: "removeMessageHook",
345
+ value: function removeMessageHook(hook) {
346
+ if (this.disposed) {
347
+ return;
348
+ }
349
+ this._hooks.remove(hook);
350
+ }
351
+
352
+ /**
353
+ * Send an `input_reply` message.
354
+ */
355
+ }, {
356
+ key: "sendInputReply",
357
+ value: function sendInputReply(content, parent_header) {
358
+ this._kernel.sendInputReply(content, parent_header);
359
+ }
360
+
361
+ /**
362
+ * Dispose and unregister the future.
363
+ */
364
+ }, {
365
+ key: "dispose",
366
+ value: function dispose() {
367
+ this._stdin = Private.noOp;
368
+ this._iopub = Private.noOp;
369
+ this._reply = Private.noOp;
370
+ this._hooks = null;
371
+ if (!this._testFlag(Private.KernelFutureFlag.IsDone)) {
372
+ // TODO: Uncomment the following logging code, and check for any tests that trigger it.
373
+ // let status = [];
374
+ // if (!this._testFlag(Private.KernelFutureFlag.GotIdle)) {
375
+ // status.push('idle');
376
+ // }
377
+ // if (!this._testFlag(Private.KernelFutureFlag.GotReply)) {
378
+ // status.push('reply');
379
+ // }
380
+ // console.warn(
381
+ // `*************** DISPOSED BEFORE DONE: K${this._kernel.id.slice(
382
+ // 0,
383
+ // 6
384
+ // )} M${this._msg.header.msg_id.slice(0, 6)} missing ${status.join(' ')}`
385
+ // );
386
+
387
+ // Reject the `done` promise, but catch its error here in case no one else
388
+ // is waiting for the promise to resolve. This prevents the error from
389
+ // being displayed in the console, but does not prevent it from being
390
+ // caught by a client who is waiting for it.
391
+ this._done.promise.catch(function () {
392
+ /* no-op */
393
+ });
394
+ this._done.reject(new Error("Canceled future for ".concat(this.msg.header.msg_type, " message before replies were done")));
395
+ }
396
+ this.disposeCb();
397
+ this.disposed = true;
398
+ }
399
+
400
+ /**
401
+ * Handle an incoming kernel message.
402
+ */
403
+ }, {
404
+ key: "handleMsg",
405
+ value: (function () {
406
+ var _handleMsg = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(msg) {
407
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
408
+ while (1) switch (_context.prev = _context.next) {
409
+ case 0:
410
+ _context.t0 = msg.channel;
411
+ _context.next = _context.t0 === 'control' ? 3 : _context.t0 === 'shell' ? 3 : _context.t0 === 'stdin' ? 7 : _context.t0 === 'iopub' ? 10 : 13;
412
+ break;
413
+ case 3:
414
+ if (!(msg.channel === this.msg.channel && msg.parent_header.msg_id === this.msg.header.msg_id)) {
415
+ _context.next = 6;
416
+ break;
417
+ }
418
+ _context.next = 6;
419
+ return this._handleReply(msg);
420
+ case 6:
421
+ return _context.abrupt("break", 14);
422
+ case 7:
423
+ _context.next = 9;
424
+ return this._handleStdin(msg);
425
+ case 9:
426
+ return _context.abrupt("break", 14);
427
+ case 10:
428
+ _context.next = 12;
429
+ return this._handleIOPub(msg);
430
+ case 12:
431
+ return _context.abrupt("break", 14);
432
+ case 13:
433
+ return _context.abrupt("break", 14);
434
+ case 14:
435
+ case "end":
436
+ return _context.stop();
437
+ }
438
+ }, _callee, this);
439
+ }));
440
+ function handleMsg(_x) {
441
+ return _handleMsg.apply(this, arguments);
442
+ }
443
+ return handleMsg;
444
+ }())
445
+ }, {
446
+ key: "_handleReply",
447
+ value: function () {
448
+ var _handleReply2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(msg) {
449
+ var reply;
450
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
451
+ while (1) switch (_context2.prev = _context2.next) {
452
+ case 0:
453
+ reply = this._reply;
454
+ if (!reply) {
455
+ _context2.next = 4;
456
+ break;
457
+ }
458
+ _context2.next = 4;
459
+ return reply(msg);
460
+ case 4:
461
+ this._replyMsg = msg;
462
+ this._setFlag(Private.KernelFutureFlag.GotReply);
463
+ if (this._testFlag(Private.KernelFutureFlag.GotIdle)) {
464
+ this._handleDone();
465
+ }
466
+ case 7:
467
+ case "end":
468
+ return _context2.stop();
469
+ }
470
+ }, _callee2, this);
471
+ }));
472
+ function _handleReply(_x2) {
473
+ return _handleReply2.apply(this, arguments);
474
+ }
475
+ return _handleReply;
476
+ }()
477
+ }, {
478
+ key: "_handleStdin",
479
+ value: function () {
480
+ var _handleStdin2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(msg) {
481
+ var stdin;
482
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
483
+ while (1) switch (_context3.prev = _context3.next) {
484
+ case 0:
485
+ this._kernel.hasPendingInput = true;
486
+ stdin = this._stdin;
487
+ if (!stdin) {
488
+ _context3.next = 5;
489
+ break;
490
+ }
491
+ _context3.next = 5;
492
+ return stdin(msg);
493
+ case 5:
494
+ case "end":
495
+ return _context3.stop();
496
+ }
497
+ }, _callee3, this);
498
+ }));
499
+ function _handleStdin(_x3) {
500
+ return _handleStdin2.apply(this, arguments);
501
+ }
502
+ return _handleStdin;
503
+ }()
504
+ }, {
505
+ key: "_handleIOPub",
506
+ value: function () {
507
+ var _handleIOPub2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(msg) {
508
+ var process, iopub;
509
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
510
+ while (1) switch (_context4.prev = _context4.next) {
511
+ case 0:
512
+ _context4.next = 2;
513
+ return this._hooks.process(msg);
514
+ case 2:
515
+ process = _context4.sent;
516
+ iopub = this._iopub;
517
+ if (!(process && iopub)) {
518
+ _context4.next = 7;
519
+ break;
520
+ }
521
+ _context4.next = 7;
522
+ return iopub(msg);
523
+ case 7:
524
+ if (isStatusMsg(msg) && msg.content.execution_state === 'idle') {
525
+ this._setFlag(Private.KernelFutureFlag.GotIdle);
526
+ if (this._testFlag(Private.KernelFutureFlag.GotReply)) {
527
+ this._handleDone();
528
+ }
529
+ }
530
+ case 8:
531
+ case "end":
532
+ return _context4.stop();
533
+ }
534
+ }, _callee4, this);
535
+ }));
536
+ function _handleIOPub(_x4) {
537
+ return _handleIOPub2.apply(this, arguments);
538
+ }
539
+ return _handleIOPub;
540
+ }()
541
+ }, {
542
+ key: "_handleDone",
543
+ value: function _handleDone() {
544
+ if (this._testFlag(Private.KernelFutureFlag.IsDone)) {
545
+ return;
546
+ }
547
+ this._setFlag(Private.KernelFutureFlag.IsDone);
548
+ this._done.resolve(this._replyMsg);
549
+ if (this._disposeOnDone) {
550
+ this.dispose();
551
+ }
552
+ }
553
+
554
+ /**
555
+ * Test whether the given future flag is set.
556
+ */
557
+ }, {
558
+ key: "_testFlag",
559
+ value: function _testFlag(flag) {
560
+ // tslint:disable-next-line
561
+ return (this._status & flag) !== 0;
562
+ }
563
+
564
+ /**
565
+ * Set the given future flag.
566
+ */
567
+ }, {
568
+ key: "_setFlag",
569
+ value: function _setFlag(flag) {
570
+ // tslint:disable-next-line
571
+ this._status |= flag;
572
+ }
573
+ }]);
574
+ return KernelFutureHandler;
575
+ }();
576
+ export var KernelControlFutureHandler = /*#__PURE__*/function (_ref) {
577
+ _inherits(KernelControlFutureHandler, _ref);
578
+ var _super = _createSuper(KernelControlFutureHandler);
579
+ function KernelControlFutureHandler() {
580
+ _classCallCheck(this, KernelControlFutureHandler);
581
+ return _super.apply(this, arguments);
582
+ }
583
+ return _createClass(KernelControlFutureHandler);
584
+ }(KernelFutureHandler);
585
+ export var KernelShellFutureHandler = /*#__PURE__*/function (_ref2) {
586
+ _inherits(KernelShellFutureHandler, _ref2);
587
+ var _super2 = _createSuper(KernelShellFutureHandler);
588
+ function KernelShellFutureHandler() {
589
+ _classCallCheck(this, KernelShellFutureHandler);
590
+ return _super2.apply(this, arguments);
591
+ }
592
+ return _createClass(KernelShellFutureHandler);
593
+ }(KernelFutureHandler);
@@ -0,0 +1,8 @@
1
+ export * from './kernel-connection.js';
2
+ export * from './kernel-module.js';
3
+ export * as KernelMessage from './messages.js';
4
+ export * from './libro-kernel-manager.js';
5
+ export * from './libro-kernel-protocol.js';
6
+ export * from './libro-kernel-utils.js';
7
+ export * from './restapi.js';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/kernel/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,OAAO,KAAK,aAAa,MAAM,eAAe,CAAC;AAC/C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yBAAyB,CAAC;AACxC,cAAc,cAAc,CAAC"}
@@ -0,0 +1,8 @@
1
+ export * from "./kernel-connection.js";
2
+ export * from "./kernel-module.js";
3
+ import * as _KernelMessage from "./messages.js";
4
+ export { _KernelMessage as KernelMessage };
5
+ export * from "./libro-kernel-manager.js";
6
+ export * from "./libro-kernel-protocol.js";
7
+ export * from "./libro-kernel-utils.js";
8
+ export * from "./restapi.js";