@difizen/libro-code-cell 0.1.2

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023-present Difizen Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # libro-notebook
2
+
3
+ cell
@@ -0,0 +1,12 @@
1
+ import { CellModelContribution, CellViewContribution } from '@difizen/libro-core';
2
+ import type { CellMeta, CellModel, CellOptions } from '@difizen/libro-core';
3
+ import { CodeCellModelFactory } from './code-cell-protocol.js';
4
+ import { LibroCodeCellView } from './code-cell-view.js';
5
+ export declare class CodeEditorCellContribution implements CellModelContribution, CellViewContribution {
6
+ libroCellModelFactory: CodeCellModelFactory;
7
+ cellMeta: CellMeta;
8
+ canHandle(options: CellOptions): number;
9
+ createModel(options: CellOptions): Promise<CellModel>;
10
+ view: typeof LibroCodeCellView;
11
+ }
12
+ //# sourceMappingURL=code-cell-contribution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-cell-contribution.d.ts","sourceRoot":"","sources":["../src/code-cell-contribution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAClF,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAG5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,qBACa,0BACX,YAAW,qBAAqB,EAAE,oBAAoB;IAExB,qBAAqB,EAAE,oBAAoB,CAAC;IAE1E,QAAQ,EAAE,QAAQ,CAIhB;IAEF,SAAS,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM;IAIjC,WAAW,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,SAAS,CAAC;IAO3D,IAAI,2BAAqB;CAC1B"}
@@ -0,0 +1,66 @@
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
+ 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 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; }
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 { CellModelContribution, CellViewContribution } from '@difizen/libro-core';
15
+ import { inject, singleton } from '@difizen/mana-app';
16
+ import { CodeCellModelFactory } from "./code-cell-protocol.js";
17
+ import { LibroCodeCellView } from "./code-cell-view.js";
18
+ export var CodeEditorCellContribution = (_dec = singleton({
19
+ contrib: [CellModelContribution, CellViewContribution]
20
+ }), _dec2 = inject(CodeCellModelFactory), _dec(_class = (_class2 = /*#__PURE__*/function () {
21
+ function CodeEditorCellContribution() {
22
+ _classCallCheck(this, CodeEditorCellContribution);
23
+ _initializerDefineProperty(this, "libroCellModelFactory", _descriptor, this);
24
+ this.cellMeta = {
25
+ type: 'code',
26
+ name: 'Python',
27
+ order: 'b'
28
+ };
29
+ this.view = LibroCodeCellView;
30
+ }
31
+ _createClass(CodeEditorCellContribution, [{
32
+ key: "canHandle",
33
+ value: function canHandle(options) {
34
+ var _options$cell;
35
+ return (options === null || options === void 0 || (_options$cell = options.cell) === null || _options$cell === void 0 ? void 0 : _options$cell.cell_type) === this.cellMeta.type ? 1000 : 1;
36
+ }
37
+ }, {
38
+ key: "createModel",
39
+ value: function () {
40
+ var _createModel = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
41
+ var model;
42
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
43
+ while (1) switch (_context.prev = _context.next) {
44
+ case 0:
45
+ model = this.libroCellModelFactory(options); // await model.outputAreaReady;
46
+ // model.outputArea.setupCellModel(model);
47
+ return _context.abrupt("return", model);
48
+ case 2:
49
+ case "end":
50
+ return _context.stop();
51
+ }
52
+ }, _callee, this);
53
+ }));
54
+ function createModel(_x) {
55
+ return _createModel.apply(this, arguments);
56
+ }
57
+ return createModel;
58
+ }()
59
+ }]);
60
+ return CodeEditorCellContribution;
61
+ }(), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "libroCellModelFactory", [_dec2], {
62
+ configurable: true,
63
+ enumerable: true,
64
+ writable: true,
65
+ initializer: null
66
+ })), _class2)) || _class);
@@ -0,0 +1,26 @@
1
+ import type { ExecutionCount } from '@difizen/libro-common';
2
+ import type { ICodeCell } from '@difizen/libro-common';
3
+ import type { ExecutableCellModel } from '@difizen/libro-core';
4
+ import { CellOptions, LibroCellModel } from '@difizen/libro-core';
5
+ import type { Event as ManaEvent } from '@difizen/mana-app';
6
+ import { ViewManager } from '@difizen/mana-app';
7
+ import { Emitter } from '@difizen/mana-app';
8
+ /**
9
+ * 基础的可执行代码的cell, 带有执行能力
10
+ */
11
+ export declare class LibroCodeCellModel extends LibroCellModel implements ExecutableCellModel {
12
+ executeCount: ExecutionCount;
13
+ executing: boolean;
14
+ hasOutputHidden: boolean;
15
+ hasOutputsScrolled: boolean;
16
+ libroFormatType: string;
17
+ viewManager: ViewManager;
18
+ msgChangeEmitter: Emitter<any>;
19
+ get msgChange(): ManaEvent<any>;
20
+ constructor(options: CellOptions, viewManager: ViewManager);
21
+ toJSON(): Omit<ICodeCell, 'outputs'>;
22
+ clearExecution: () => void;
23
+ dispose(): void;
24
+ getSource(): string;
25
+ }
26
+ //# sourceMappingURL=code-cell-model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-cell-model.d.ts","sourceRoot":"","sources":["../src/code-cell-model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,KAAK,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAA2B,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C;;GAEG;AACH,qBACa,kBAAmB,SAAQ,cAAe,YAAW,mBAAmB;IAEnF,YAAY,EAAE,cAAc,CAAC;IAE7B,SAAS,EAAE,OAAO,CAAC;IAEnB,eAAe,EAAE,OAAO,CAAC;IAEzB,kBAAkB,EAAE,OAAO,CAAC;IAEpB,eAAe,EAAE,MAAM,CAAC;IAEhC,WAAW,EAAE,WAAW,CAAC;IAGzB,gBAAgB,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;IAE/B,IAAI,SAAS,IAAI,SAAS,CAAC,GAAG,CAAC,CAE9B;gBAGsB,OAAO,EAAE,WAAW,EACpB,WAAW,EAAE,WAAW;IAYtC,MAAM,IAAI,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC;IAY7C,cAAc,aAGZ;IAEO,OAAO;IAKhB,SAAS;CAGV"}
@@ -0,0 +1,107 @@
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
+ var _dec, _dec2, _dec3, _dec4, _dec5, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4;
3
+ 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 }); }
4
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
5
+ 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); } }
6
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
7
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
8
+ 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); }
9
+ function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
10
+ function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
11
+ 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); }
12
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
13
+ 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); }; }
14
+ 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); }
15
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
16
+ 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; } }
17
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
18
+ 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; }
19
+ 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.'); }
20
+ import { CellOptions, LibroCellModel } from '@difizen/libro-core';
21
+ import { inject, prop, transient, ViewManager } from '@difizen/mana-app';
22
+ import { Emitter } from '@difizen/mana-app';
23
+
24
+ /**
25
+ * 基础的可执行代码的cell, 带有执行能力
26
+ */
27
+ export var LibroCodeCellModel = (_dec = transient(), _dec2 = prop(), _dec3 = prop(), _dec4 = prop(), _dec5 = prop(), _dec(_class = (_class2 = /*#__PURE__*/function (_LibroCellModel) {
28
+ _inherits(LibroCodeCellModel, _LibroCellModel);
29
+ var _super = _createSuper(LibroCodeCellModel);
30
+ function LibroCodeCellModel(options, viewManager) {
31
+ var _this;
32
+ _classCallCheck(this, LibroCodeCellModel);
33
+ _this = _super.call(this, options);
34
+ _initializerDefineProperty(_this, "executeCount", _descriptor, _assertThisInitialized(_this));
35
+ _initializerDefineProperty(_this, "executing", _descriptor2, _assertThisInitialized(_this));
36
+ _initializerDefineProperty(_this, "hasOutputHidden", _descriptor3, _assertThisInitialized(_this));
37
+ _initializerDefineProperty(_this, "hasOutputsScrolled", _descriptor4, _assertThisInitialized(_this));
38
+ _this.viewManager = void 0;
39
+ // Emitter Msg
40
+ _this.msgChangeEmitter = void 0;
41
+ _this.clearExecution = function () {
42
+ _this.executeCount = null;
43
+ _this.executing = false;
44
+ };
45
+ _this.executing = false;
46
+ _this.msgChangeEmitter = new Emitter();
47
+ _this.executeCount = options.cell.execution_count || null;
48
+ _this.mimeType = 'text/x-python';
49
+ _this.hasOutputHidden = false;
50
+ _this.hasOutputsScrolled = false;
51
+ _this.viewManager = viewManager;
52
+ return _this;
53
+ }
54
+ LibroCodeCellModel = inject(ViewManager)(LibroCodeCellModel, undefined, 1) || LibroCodeCellModel;
55
+ LibroCodeCellModel = inject(CellOptions)(LibroCodeCellModel, undefined, 0) || LibroCodeCellModel;
56
+ _createClass(LibroCodeCellModel, [{
57
+ key: "msgChange",
58
+ get: function get() {
59
+ return this.msgChangeEmitter.event;
60
+ }
61
+ }, {
62
+ key: "toJSON",
63
+ value: function toJSON() {
64
+ // const outputs = this.outputArea?.toJSON() ?? this.outputs;
65
+ return {
66
+ id: this.id,
67
+ cell_type: this.type,
68
+ source: this.source,
69
+ metadata: this.metadata,
70
+ execution_count: this.executeCount
71
+ // outputs: this.outputs,
72
+ };
73
+ }
74
+ }, {
75
+ key: "dispose",
76
+ value: function dispose() {
77
+ _get(_getPrototypeOf(LibroCodeCellModel.prototype), "dispose", this).call(this);
78
+ this.msgChangeEmitter.dispose();
79
+ }
80
+ }, {
81
+ key: "getSource",
82
+ value: function getSource() {
83
+ return this.value;
84
+ }
85
+ }]);
86
+ return LibroCodeCellModel;
87
+ }(LibroCellModel), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "executeCount", [_dec2], {
88
+ configurable: true,
89
+ enumerable: true,
90
+ writable: true,
91
+ initializer: null
92
+ }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "executing", [_dec3], {
93
+ configurable: true,
94
+ enumerable: true,
95
+ writable: true,
96
+ initializer: null
97
+ }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "hasOutputHidden", [_dec4], {
98
+ configurable: true,
99
+ enumerable: true,
100
+ writable: true,
101
+ initializer: null
102
+ }), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "hasOutputsScrolled", [_dec5], {
103
+ configurable: true,
104
+ enumerable: true,
105
+ writable: true,
106
+ initializer: null
107
+ })), _class2)) || _class);
@@ -0,0 +1,5 @@
1
+ import type { CellOptions } from '@difizen/libro-core';
2
+ import type { LibroCodeCellModel } from './code-cell-model.js';
3
+ export type CodeCellModelFactory = (options: CellOptions) => LibroCodeCellModel;
4
+ export declare const CodeCellModelFactory: unique symbol;
5
+ //# sourceMappingURL=code-cell-protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-cell-protocol.d.ts","sourceRoot":"","sources":["../src/code-cell-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE/D,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,EAAE,WAAW,KAAK,kBAAkB,CAAC;AAChF,eAAO,MAAM,oBAAoB,eAAiC,CAAC"}
@@ -0,0 +1 @@
1
+ export var CodeCellModelFactory = Symbol('CodeCellModelFactory');
@@ -0,0 +1,42 @@
1
+ /// <reference types="react" resolution-mode="require"/>
2
+ import type { CodeEditorViewOptions, CodeEditorView } from '@difizen/libro-code-editor';
3
+ import { CodeEditorManager, CodeEditorSettings } from '@difizen/libro-code-editor';
4
+ import type { IOutput } from '@difizen/libro-common';
5
+ import type { LibroCell, CellViewOptions } from '@difizen/libro-core';
6
+ import { CellService, EditorStatus, LibroExecutableCellView, LibroOutputArea } from '@difizen/libro-core';
7
+ import { ViewManager } from '@difizen/mana-app';
8
+ import { Deferred } from '@difizen/mana-app';
9
+ import type { LibroCodeCellModel } from './code-cell-model.js';
10
+ export declare const CellEditorMemo: import("react").NamedExoticComponent<{}>;
11
+ export declare class LibroCodeCellView extends LibroExecutableCellView {
12
+ view: import("react").ForwardRefExoticComponent<import("react").RefAttributes<HTMLDivElement>>;
13
+ viewManager: ViewManager;
14
+ codeEditorManager: CodeEditorManager;
15
+ model: LibroCodeCellModel;
16
+ outputs: IOutput[];
17
+ editorView?: CodeEditorView;
18
+ editorAreaHeight: number;
19
+ noEditorAreaHeight: number;
20
+ cellViewTopPos: number;
21
+ editorStatus: EditorStatus;
22
+ protected editorViewReadyDeferred: Deferred<void>;
23
+ get editorReady(): Promise<void>;
24
+ protected outputAreaDeferred: Deferred<LibroOutputArea>;
25
+ get outputAreaReady(): Promise<LibroOutputArea>;
26
+ protected codeEditorSettings: CodeEditorSettings;
27
+ renderEditor: () => import("react/jsx-runtime").JSX.Element | null;
28
+ calcEditorAreaHeight(): number;
29
+ constructor(options: CellViewOptions, cellService: CellService, viewManager: ViewManager, codeEditorManager: CodeEditorManager, codeEditorSettings: CodeEditorSettings);
30
+ outputWatch(): void;
31
+ toJSON(): LibroCell;
32
+ onViewMount(): void;
33
+ setEditorHost(ref: any): void;
34
+ protected getEditorOption(): CodeEditorViewOptions;
35
+ protected createEditor(): Promise<void>;
36
+ protected afterEditorReady(): Promise<void>;
37
+ shouldEnterEditorMode(e: React.FocusEvent<HTMLElement>): boolean;
38
+ blur: () => void;
39
+ focus: (toEdit: boolean) => void;
40
+ clearExecution: () => void;
41
+ }
42
+ //# sourceMappingURL=code-cell-view.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-cell-view.d.ts","sourceRoot":"","sources":["../src/code-cell-view.tsx"],"names":[],"mappings":";AAGA,OAAO,KAAK,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACxF,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACnF,OAAO,KAAK,EAAa,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEhE,OAAO,KAAK,EAEV,SAAS,EACT,eAAe,EAChB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,WAAW,EACX,YAAY,EACZ,uBAAuB,EACvB,eAAe,EAEhB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAQL,WAAW,EAIZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAG7C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AA6C/D,eAAO,MAAM,cAAc,0CAAmB,CAAC;AAmB/C,qBAEa,iBAAkB,SAAQ,uBAAuB;IACnD,IAAI,2FAA2B;IAExC,WAAW,EAAE,WAAW,CAAC;IAEzB,iBAAiB,EAAE,iBAAiB,CAAC;IAE7B,KAAK,EAAE,kBAAkB,CAAC;IAElC,OAAO,EAAE,OAAO,EAAE,CAAC;IAGnB,UAAU,CAAC,EAAE,cAAc,CAAC;IAG5B,gBAAgB,SAAK;IAGZ,kBAAkB,SAAK;IAGvB,cAAc,SAAK;IAGnB,YAAY,EAAE,YAAY,CAA0B;IAE7D,SAAS,CAAC,uBAAuB,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAwB;IAEzE,IAAI,WAAW,kBAEd;IAED,SAAS,CAAC,kBAAkB,4BAAmC;IAC/D,IAAI,eAAe,6BAElB;IAED,SAAS,CAAC,kBAAkB,EAAE,kBAAkB,CAAC;IAExC,YAAY,uDAKnB;IAMF,oBAAoB;gBAqBE,OAAO,EAAE,eAAe,EACvB,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,WAAW,EAClB,iBAAiB,EAAE,iBAAiB,EACnC,kBAAkB,EAAE,kBAAkB;IA8B3D,WAAW;IAQX,MAAM,IAAI,SAAS;IAQnB,WAAW;IAQpB,aAAa,CAAC,GAAG,EAAE,GAAG;IAMtB,SAAS,CAAC,eAAe,IAAI,qBAAqB;cAalC,YAAY;cAoBZ,gBAAgB;IAUvB,qBAAqB,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC;IAMtD,IAAI,aAGX;IAEO,KAAK,WAAY,OAAO,UAkC/B;IAEO,cAAc,aAGrB;CACH"}