@difizen/libro-sql-cell 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.
- package/LICENSE +21 -0
- package/README.md +1 -0
- package/es/index.d.ts +2 -0
- package/es/index.d.ts.map +1 -0
- package/es/index.js +1 -0
- package/es/index.less +116 -0
- package/es/libro-formatter-sql-magic-contribution.d.ts +25 -0
- package/es/libro-formatter-sql-magic-contribution.d.ts.map +1 -0
- package/es/libro-formatter-sql-magic-contribution.js +50 -0
- package/es/libro-formatter-sql-trans-contribution.d.ts +13 -0
- package/es/libro-formatter-sql-trans-contribution.d.ts.map +1 -0
- package/es/libro-formatter-sql-trans-contribution.js +26 -0
- package/es/libro-sql-cell-color-registry.d.ts +6 -0
- package/es/libro-sql-cell-color-registry.d.ts.map +1 -0
- package/es/libro-sql-cell-color-registry.js +57 -0
- package/es/libro-sql-cell-contribution.d.ts +15 -0
- package/es/libro-sql-cell-contribution.d.ts.map +1 -0
- package/es/libro-sql-cell-contribution.js +75 -0
- package/es/libro-sql-cell-model.d.ts +33 -0
- package/es/libro-sql-cell-model.d.ts.map +1 -0
- package/es/libro-sql-cell-model.js +161 -0
- package/es/libro-sql-cell-protocol.d.ts +16 -0
- package/es/libro-sql-cell-protocol.d.ts.map +1 -0
- package/es/libro-sql-cell-protocol.js +1 -0
- package/es/libro-sql-cell-script.d.ts +4 -0
- package/es/libro-sql-cell-script.d.ts.map +1 -0
- package/es/libro-sql-cell-script.js +12 -0
- package/es/libro-sql-cell-view.d.ts +42 -0
- package/es/libro-sql-cell-view.d.ts.map +1 -0
- package/es/libro-sql-cell-view.js +583 -0
- package/es/libro-sql-utils.d.ts +3 -0
- package/es/libro-sql-utils.d.ts.map +1 -0
- package/es/libro-sql-utils.js +33 -0
- package/es/module.d.ts +3 -0
- package/es/module.d.ts.map +1 -0
- package/es/module.js +25 -0
- package/package.json +65 -0
- package/src/index.less +120 -0
- package/src/index.spec.ts +9 -0
- package/src/index.ts +1 -0
- package/src/libro-formatter-sql-magic-contribution.ts +66 -0
- package/src/libro-formatter-sql-trans-contribution.ts +22 -0
- package/src/libro-sql-cell-color-registry.ts +35 -0
- package/src/libro-sql-cell-contribution.ts +46 -0
- package/src/libro-sql-cell-model.ts +115 -0
- package/src/libro-sql-cell-protocol.ts +20 -0
- package/src/libro-sql-cell-script.ts +6 -0
- package/src/libro-sql-cell-view.tsx +560 -0
- package/src/libro-sql-utils.ts +22 -0
- package/src/module.ts +38 -0
|
@@ -0,0 +1,583 @@
|
|
|
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, _dec6, _dec7, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5;
|
|
3
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
|
+
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; }
|
|
6
|
+
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; }
|
|
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(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
14
|
+
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); }
|
|
15
|
+
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); }
|
|
16
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
17
|
+
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); }; }
|
|
18
|
+
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); }
|
|
19
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
20
|
+
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; } }
|
|
21
|
+
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); }
|
|
22
|
+
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
|
23
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
24
|
+
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; }
|
|
25
|
+
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.'); }
|
|
26
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
27
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
28
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
29
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
30
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
31
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
32
|
+
import { EditFilled, DatabaseOutlined } from '@ant-design/icons';
|
|
33
|
+
import { CodeEditorManager } from '@difizen/libro-code-editor';
|
|
34
|
+
import { isOutput } from '@difizen/libro-common';
|
|
35
|
+
import { CellService, EditorStatus, LibroContextKey, LibroEditableExecutableCellView, LibroViewTracker, VirtualizedManagerHelper, KernelError, LibroJupyterModel, LibroOutputArea } from '@difizen/libro-jupyter';
|
|
36
|
+
import { Deferred, getOrigin, inject, prop, transient, useInject, view, ViewInstance, ViewManager, ViewOption, ViewRender } from '@difizen/mana-app';
|
|
37
|
+
import { l10n } from '@difizen/mana-l10n';
|
|
38
|
+
import { Input, Popover } from 'antd';
|
|
39
|
+
import React from 'react';
|
|
40
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
41
|
+
import "./index.less";
|
|
42
|
+
import { LibroSqlCellModel } from "./libro-sql-cell-model.js";
|
|
43
|
+
import { SqlScript } from "./libro-sql-cell-script.js";
|
|
44
|
+
import { getDfVariableName } from "./libro-sql-utils.js";
|
|
45
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
46
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
47
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
48
|
+
function countLines(inputString) {
|
|
49
|
+
var lines = inputString.split('\n');
|
|
50
|
+
return lines.length;
|
|
51
|
+
}
|
|
52
|
+
var CellEditor = function CellEditor() {
|
|
53
|
+
var _instance$editorView3;
|
|
54
|
+
var instance = useInject(ViewInstance);
|
|
55
|
+
var virtualizedManagerHelper = useInject(VirtualizedManagerHelper);
|
|
56
|
+
var virtualizedManager = virtualizedManagerHelper.getOrCreate(instance.parent.model);
|
|
57
|
+
var editorRef = useRef(null);
|
|
58
|
+
useEffect(function () {
|
|
59
|
+
var _instance$editorView;
|
|
60
|
+
if ((_instance$editorView = instance.editorView) !== null && _instance$editorView !== void 0 && _instance$editorView.editor) {
|
|
61
|
+
var _instance$editorView2;
|
|
62
|
+
instance.editor = getOrigin((_instance$editorView2 = instance.editorView) === null || _instance$editorView2 === void 0 ? void 0 : _instance$editorView2.editor);
|
|
63
|
+
}
|
|
64
|
+
}, [instance, (_instance$editorView3 = instance.editorView) === null || _instance$editorView3 === void 0 ? void 0 : _instance$editorView3.editor]);
|
|
65
|
+
if (virtualizedManager.isVirtualized) {
|
|
66
|
+
instance.renderEditorIntoVirtualized = true;
|
|
67
|
+
var editorAreaHeight = instance.calcEditorAreaHeight();
|
|
68
|
+
if (instance.setEditorHost) {
|
|
69
|
+
instance.setEditorHost(editorRef);
|
|
70
|
+
}
|
|
71
|
+
return /*#__PURE__*/_jsx("div", {
|
|
72
|
+
style: {
|
|
73
|
+
height: "".concat(editorAreaHeight || 0, "px"),
|
|
74
|
+
width: '100%'
|
|
75
|
+
},
|
|
76
|
+
ref: editorRef
|
|
77
|
+
});
|
|
78
|
+
} else {
|
|
79
|
+
return /*#__PURE__*/_jsx(_Fragment, {
|
|
80
|
+
children: instance.editorView && /*#__PURE__*/_jsx(ViewRender, {
|
|
81
|
+
view: instance.editorView
|
|
82
|
+
})
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
var LibroSqlVariableNameInput = function LibroSqlVariableNameInput(_ref) {
|
|
87
|
+
var handCancel = _ref.handCancel;
|
|
88
|
+
var cellView = useInject(ViewInstance);
|
|
89
|
+
var _useState = useState(true),
|
|
90
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
91
|
+
resultVariableAvailable = _useState2[0],
|
|
92
|
+
setVariableNameAvailable = _useState2[1];
|
|
93
|
+
var _useState3 = useState(cellView.model.resultVariable),
|
|
94
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
95
|
+
resultVariable = _useState4[0],
|
|
96
|
+
setVariableName = _useState4[1];
|
|
97
|
+
var handleValueChange = useCallback(function (e) {
|
|
98
|
+
if (cellView.parent.model.cells.findIndex(function (cell) {
|
|
99
|
+
return cell.model instanceof LibroSqlCellModel && cell.model.resultVariable === e.target.value;
|
|
100
|
+
}) > -1) {
|
|
101
|
+
setVariableNameAvailable(false);
|
|
102
|
+
} else {
|
|
103
|
+
setVariableNameAvailable(true);
|
|
104
|
+
}
|
|
105
|
+
setVariableName(e.target.value);
|
|
106
|
+
}, [cellView.parent.model.cells]);
|
|
107
|
+
var handValueSave = useCallback(function () {
|
|
108
|
+
cellView.model.resultVariable = getDfVariableName(cellView.parent.model.cells.filter(function (cell) {
|
|
109
|
+
return cell.model.type === 'sql';
|
|
110
|
+
}));
|
|
111
|
+
cellView.model.resultVariable = resultVariable;
|
|
112
|
+
if (cellView.parent.model.onChange) {
|
|
113
|
+
cellView.parent.model.onChange();
|
|
114
|
+
}
|
|
115
|
+
handCancel();
|
|
116
|
+
}, [cellView.model, cellView.parent.model, handCancel, resultVariable]);
|
|
117
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
118
|
+
children: [/*#__PURE__*/_jsx(Input, {
|
|
119
|
+
status: "".concat(resultVariableAvailable ? '' : 'warning'),
|
|
120
|
+
className: "libro-sql-variable-name-input",
|
|
121
|
+
onChange: handleValueChange,
|
|
122
|
+
defaultValue: cellView.model.resultVariable
|
|
123
|
+
}), !resultVariableAvailable && /*#__PURE__*/_jsx("span", {
|
|
124
|
+
className: "libro-sql-input-warning-text",
|
|
125
|
+
children: l10n.t('当前变量名已存在')
|
|
126
|
+
}), /*#__PURE__*/_jsxs("div", {
|
|
127
|
+
className: "libro-sql-input-button",
|
|
128
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
129
|
+
onClick: handCancel,
|
|
130
|
+
className: "libro-sql-input-cancel",
|
|
131
|
+
children: l10n.t('取消')
|
|
132
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
133
|
+
onClick: handValueSave,
|
|
134
|
+
className: "libro-sql-input-save",
|
|
135
|
+
children: l10n.t('保存')
|
|
136
|
+
})]
|
|
137
|
+
})]
|
|
138
|
+
});
|
|
139
|
+
};
|
|
140
|
+
export var LibroSqlCell = /*#__PURE__*/React.forwardRef(function SqlEditorViewComponent(props, ref) {
|
|
141
|
+
var _useState5 = useState(false),
|
|
142
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
143
|
+
isVariableNameEdit = _useState6[0],
|
|
144
|
+
setIsVariableNameEdit = _useState6[1];
|
|
145
|
+
var instance = useInject(ViewInstance);
|
|
146
|
+
var contextKey = useInject(LibroContextKey);
|
|
147
|
+
var handCancelEdit = function handCancelEdit() {
|
|
148
|
+
contextKey.enableCommandMode();
|
|
149
|
+
setIsVariableNameEdit(false);
|
|
150
|
+
};
|
|
151
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
152
|
+
tabIndex: 10,
|
|
153
|
+
ref: ref,
|
|
154
|
+
className: instance.className,
|
|
155
|
+
children: [/*#__PURE__*/_jsxs("div", {
|
|
156
|
+
className: "libro-sql-cell-header",
|
|
157
|
+
children: [/*#__PURE__*/_jsxs("div", {
|
|
158
|
+
className: "libro-sql-source",
|
|
159
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
160
|
+
className: "libro-sql-source-title",
|
|
161
|
+
children: /*#__PURE__*/_jsx(DatabaseOutlined, {})
|
|
162
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
163
|
+
className: "libro-sql-source-content",
|
|
164
|
+
children: instance.databaseConfig ? instance.databaseConfig.db_type + ': ' + instance.databaseConfig.database : '暂未配置数据库'
|
|
165
|
+
})]
|
|
166
|
+
}), /*#__PURE__*/_jsxs("div", {
|
|
167
|
+
className: "libro-sql-variable-name",
|
|
168
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
169
|
+
className: "libro-sql-variable-name-title",
|
|
170
|
+
children: "Name: "
|
|
171
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
172
|
+
className: "libro-sql-variable-content",
|
|
173
|
+
children: instance.model.resultVariable
|
|
174
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
175
|
+
className: "libro-sql-variable-name-popover",
|
|
176
|
+
style: {
|
|
177
|
+
display: 'inline-block'
|
|
178
|
+
},
|
|
179
|
+
children: /*#__PURE__*/_jsx(Popover, {
|
|
180
|
+
content: /*#__PURE__*/_jsx(LibroSqlVariableNameInput, {
|
|
181
|
+
handCancel: handCancelEdit
|
|
182
|
+
}),
|
|
183
|
+
placement: "bottomLeft",
|
|
184
|
+
open: instance.parent.model.inputEditable ? isVariableNameEdit : false,
|
|
185
|
+
onOpenChange: function onOpenChange(visible) {
|
|
186
|
+
if (visible) {
|
|
187
|
+
contextKey.disableCommandMode();
|
|
188
|
+
} else {
|
|
189
|
+
contextKey.enableCommandMode();
|
|
190
|
+
}
|
|
191
|
+
setIsVariableNameEdit(visible);
|
|
192
|
+
},
|
|
193
|
+
getPopupContainer: function getPopupContainer() {
|
|
194
|
+
var _instance$container;
|
|
195
|
+
return (_instance$container = instance.container) === null || _instance$container === void 0 || (_instance$container = _instance$container.current) === null || _instance$container === void 0 ? void 0 : _instance$container.getElementsByClassName('libro-sql-variable-name')[0];
|
|
196
|
+
},
|
|
197
|
+
trigger: "click",
|
|
198
|
+
overlayClassName: "libro-sql-popover-container",
|
|
199
|
+
children: /*#__PURE__*/_jsx(EditFilled, {
|
|
200
|
+
className: "libro-sql-edit-icon"
|
|
201
|
+
})
|
|
202
|
+
})
|
|
203
|
+
})]
|
|
204
|
+
})]
|
|
205
|
+
}), /*#__PURE__*/_jsx(CellEditor, {})]
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
export var LibroSqlCellView = (_dec = transient(), _dec2 = view('libro-sql-cell-view'), _dec3 = prop(), _dec4 = prop(), _dec5 = prop(), _dec6 = prop(), _dec7 = inject(SqlScript), _dec(_class = _dec2(_class = (_class2 = /*#__PURE__*/function (_LibroEditableExecuta) {
|
|
209
|
+
_inherits(LibroSqlCellView, _LibroEditableExecuta);
|
|
210
|
+
var _super = _createSuper(LibroSqlCellView);
|
|
211
|
+
function LibroSqlCellView(options, cellService, viewManager, libroViewTracker, codeEditorManager) {
|
|
212
|
+
var _options$cell;
|
|
213
|
+
var _this;
|
|
214
|
+
_classCallCheck(this, LibroSqlCellView);
|
|
215
|
+
_this = _super.call(this, options, cellService);
|
|
216
|
+
_this.view = LibroSqlCell;
|
|
217
|
+
_this.libroViewTracker = void 0;
|
|
218
|
+
_this.outputs = void 0;
|
|
219
|
+
_initializerDefineProperty(_this, "databaseConfig", _descriptor, _assertThisInitialized(_this));
|
|
220
|
+
_initializerDefineProperty(_this, "editorStatus", _descriptor2, _assertThisInitialized(_this));
|
|
221
|
+
_initializerDefineProperty(_this, "editorAreaHeight", _descriptor3, _assertThisInitialized(_this));
|
|
222
|
+
_initializerDefineProperty(_this, "noEditorAreaHeight", _descriptor4, _assertThisInitialized(_this));
|
|
223
|
+
_initializerDefineProperty(_this, "sqlScript", _descriptor5, _assertThisInitialized(_this));
|
|
224
|
+
_this.editorViewReadyDeferred = new Deferred();
|
|
225
|
+
_this.renderEditor = function () {
|
|
226
|
+
if (_this.editorView) {
|
|
227
|
+
return /*#__PURE__*/_jsx(ViewRender, {
|
|
228
|
+
view: _this.editorView
|
|
229
|
+
});
|
|
230
|
+
} else {
|
|
231
|
+
return null;
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
_this.outputAreaDeferred = new Deferred();
|
|
235
|
+
_this.onViewMount = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
236
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
237
|
+
while (1) switch (_context.prev = _context.next) {
|
|
238
|
+
case 0:
|
|
239
|
+
_context.next = 2;
|
|
240
|
+
return _this.createEditor();
|
|
241
|
+
case 2:
|
|
242
|
+
case "end":
|
|
243
|
+
return _context.stop();
|
|
244
|
+
}
|
|
245
|
+
}, _callee);
|
|
246
|
+
}));
|
|
247
|
+
_this.onViewResize = function (size) {
|
|
248
|
+
// 把 header 部分高度也放在这部分,用来撑开高度
|
|
249
|
+
if (size.height) {
|
|
250
|
+
_this.editorAreaHeight = size.height + 36;
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
_this.focus = function (toEdit) {
|
|
254
|
+
if (toEdit) {
|
|
255
|
+
_this.focusEditor();
|
|
256
|
+
_this.getDatabaseConfig();
|
|
257
|
+
} else {
|
|
258
|
+
var _this$container, _this$container2;
|
|
259
|
+
if ((_this$container = _this.container) !== null && _this$container !== void 0 && (_this$container = _this$container.current) !== null && _this$container !== void 0 && (_this$container = _this$container.parentElement) !== null && _this$container !== void 0 && _this$container.contains(document.activeElement)) {
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
(_this$container2 = _this.container) === null || _this$container2 === void 0 || (_this$container2 = _this$container2.current) === null || _this$container2 === void 0 || (_this$container2 = _this$container2.parentElement) === null || _this$container2 === void 0 || _this$container2.focus();
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
_this.clearExecution = function () {
|
|
266
|
+
_this.model.clearExecution();
|
|
267
|
+
_this.outputArea.clear();
|
|
268
|
+
};
|
|
269
|
+
_this.fetch = /*#__PURE__*/function () {
|
|
270
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(content, ioCallback) {
|
|
271
|
+
var _this$parent;
|
|
272
|
+
var model, connection, future;
|
|
273
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
274
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
275
|
+
case 0:
|
|
276
|
+
model = (_this$parent = _this.parent) === null || _this$parent === void 0 ? void 0 : _this$parent.model;
|
|
277
|
+
_context2.next = 3;
|
|
278
|
+
return model.kcReady;
|
|
279
|
+
case 3:
|
|
280
|
+
connection = model.kernelConnection;
|
|
281
|
+
future = connection.requestExecute(content);
|
|
282
|
+
future.onIOPub = function (msg) {
|
|
283
|
+
ioCallback(msg);
|
|
284
|
+
};
|
|
285
|
+
return _context2.abrupt("return", future.done);
|
|
286
|
+
case 7:
|
|
287
|
+
case "end":
|
|
288
|
+
return _context2.stop();
|
|
289
|
+
}
|
|
290
|
+
}, _callee2);
|
|
291
|
+
}));
|
|
292
|
+
return function (_x, _x2) {
|
|
293
|
+
return _ref3.apply(this, arguments);
|
|
294
|
+
};
|
|
295
|
+
}();
|
|
296
|
+
_this.handleQueryResponse = function (response, cb) {
|
|
297
|
+
var msgType = response.header.msg_type;
|
|
298
|
+
switch (msgType) {
|
|
299
|
+
case 'execute_result':
|
|
300
|
+
case 'display_data':
|
|
301
|
+
{
|
|
302
|
+
var payload = response;
|
|
303
|
+
var content = payload.content.data['text/plain'];
|
|
304
|
+
if (content.slice(0, 1) === "'" || content.slice(0, 1) === '"') {
|
|
305
|
+
content = content.slice(1, -1);
|
|
306
|
+
content = content.replace(/\\"/g, '"').replace(/\\'/g, "'");
|
|
307
|
+
}
|
|
308
|
+
cb(content);
|
|
309
|
+
break;
|
|
310
|
+
}
|
|
311
|
+
case 'stream':
|
|
312
|
+
{
|
|
313
|
+
var payloadDisplay = response;
|
|
314
|
+
var contentStream = payloadDisplay.content.text;
|
|
315
|
+
if (contentStream.slice(0, 1) === "'" || contentStream.slice(0, 1) === '"') {
|
|
316
|
+
contentStream = contentStream.slice(1, -1);
|
|
317
|
+
contentStream = contentStream.replace(/\\"/g, '"').replace(/\\'/g, "'");
|
|
318
|
+
}
|
|
319
|
+
cb(contentStream);
|
|
320
|
+
break;
|
|
321
|
+
}
|
|
322
|
+
default:
|
|
323
|
+
break;
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
_this.getDatabaseConfig = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
327
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
328
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
329
|
+
case 0:
|
|
330
|
+
return _context3.abrupt("return", _this.fetch({
|
|
331
|
+
code: _this.sqlScript.getDbConfig,
|
|
332
|
+
store_history: false
|
|
333
|
+
}, function (msg) {
|
|
334
|
+
return _this.handleQueryResponse(msg, function (result) {
|
|
335
|
+
try {
|
|
336
|
+
_this.databaseConfig = JSON.parse(result);
|
|
337
|
+
} catch (e) {
|
|
338
|
+
_this.databaseConfig = undefined;
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
}));
|
|
342
|
+
case 1:
|
|
343
|
+
case "end":
|
|
344
|
+
return _context3.stop();
|
|
345
|
+
}
|
|
346
|
+
}, _callee3);
|
|
347
|
+
}));
|
|
348
|
+
_this.codeEditorManager = codeEditorManager;
|
|
349
|
+
_this.outputs = (_options$cell = options.cell) === null || _options$cell === void 0 ? void 0 : _options$cell.outputs;
|
|
350
|
+
_this.className = _this.className + ' sql';
|
|
351
|
+
viewManager.getOrCreateView(LibroOutputArea, {
|
|
352
|
+
cellId: _this.id,
|
|
353
|
+
cell: _assertThisInitialized(_this)
|
|
354
|
+
}).then( /*#__PURE__*/function () {
|
|
355
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(outputArea) {
|
|
356
|
+
var output;
|
|
357
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
358
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
359
|
+
case 0:
|
|
360
|
+
_this.outputArea = outputArea;
|
|
361
|
+
output = _this.outputs;
|
|
362
|
+
if (!isOutput(output)) {
|
|
363
|
+
_context4.next = 5;
|
|
364
|
+
break;
|
|
365
|
+
}
|
|
366
|
+
_context4.next = 5;
|
|
367
|
+
return _this.outputArea.fromJSON(output);
|
|
368
|
+
case 5:
|
|
369
|
+
_this.outputAreaDeferred.resolve(outputArea);
|
|
370
|
+
_this.outputWatch();
|
|
371
|
+
return _context4.abrupt("return");
|
|
372
|
+
case 8:
|
|
373
|
+
case "end":
|
|
374
|
+
return _context4.stop();
|
|
375
|
+
}
|
|
376
|
+
}, _callee4);
|
|
377
|
+
}));
|
|
378
|
+
return function (_x3) {
|
|
379
|
+
return _ref5.apply(this, arguments);
|
|
380
|
+
};
|
|
381
|
+
}()).catch(function () {
|
|
382
|
+
//
|
|
383
|
+
});
|
|
384
|
+
_this.libroViewTracker = libroViewTracker;
|
|
385
|
+
if (!_this.model.resultVariable) {
|
|
386
|
+
var _this$libroViewTracke;
|
|
387
|
+
_this.model.resultVariable = getDfVariableName((_this$libroViewTracke = _this.libroViewTracker.viewCache.get(options.parentId)) === null || _this$libroViewTracke === void 0 ? void 0 : _this$libroViewTracke.model.cells.filter(function (cell) {
|
|
388
|
+
return cell.model.type === 'sql';
|
|
389
|
+
}));
|
|
390
|
+
}
|
|
391
|
+
return _this;
|
|
392
|
+
}
|
|
393
|
+
LibroSqlCellView = inject(CodeEditorManager)(LibroSqlCellView, undefined, 4) || LibroSqlCellView;
|
|
394
|
+
LibroSqlCellView = inject(LibroViewTracker)(LibroSqlCellView, undefined, 3) || LibroSqlCellView;
|
|
395
|
+
LibroSqlCellView = inject(ViewManager)(LibroSqlCellView, undefined, 2) || LibroSqlCellView;
|
|
396
|
+
LibroSqlCellView = inject(CellService)(LibroSqlCellView, undefined, 1) || LibroSqlCellView;
|
|
397
|
+
LibroSqlCellView = inject(ViewOption)(LibroSqlCellView, undefined, 0) || LibroSqlCellView;
|
|
398
|
+
_createClass(LibroSqlCellView, [{
|
|
399
|
+
key: "editorReady",
|
|
400
|
+
get: function get() {
|
|
401
|
+
return this.editorViewReadyDeferred.promise;
|
|
402
|
+
}
|
|
403
|
+
}, {
|
|
404
|
+
key: "calcEditorOffset",
|
|
405
|
+
value:
|
|
406
|
+
// 计算编辑器区相对于编辑器区垂直方向的偏移量
|
|
407
|
+
function calcEditorOffset() {
|
|
408
|
+
return _get(_getPrototypeOf(LibroSqlCellView.prototype), "calcEditorOffset", this).call(this) + 36;
|
|
409
|
+
}
|
|
410
|
+
}, {
|
|
411
|
+
key: "calcEditorAreaHeight",
|
|
412
|
+
value: function calcEditorAreaHeight() {
|
|
413
|
+
if (this.editorStatus === EditorStatus.NOTLOADED || this.editorStatus === EditorStatus.LOADING) {
|
|
414
|
+
var _this$codeEditorManag = this.codeEditorManager.getUserEditorConfig(this.model),
|
|
415
|
+
lineHeight = _this$codeEditorManag.lineHeight,
|
|
416
|
+
paddingTop = _this$codeEditorManag.paddingTop,
|
|
417
|
+
paddingBottom = _this$codeEditorManag.paddingBottom;
|
|
418
|
+
var codeHeight = countLines(this.model.value) * lineHeight;
|
|
419
|
+
var editorPadding = paddingTop + paddingBottom;
|
|
420
|
+
var scrollbarHeight = 12;
|
|
421
|
+
|
|
422
|
+
// TODO: 滚动条有条件显示
|
|
423
|
+
|
|
424
|
+
var editorAreaHeight = codeHeight + editorPadding + scrollbarHeight;
|
|
425
|
+
this.editorAreaHeight = editorAreaHeight;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
// 编辑器已经加载的情况下cell高度都由对它的高度监听得到。
|
|
429
|
+
return this.editorAreaHeight;
|
|
430
|
+
}
|
|
431
|
+
}, {
|
|
432
|
+
key: "outputAreaReady",
|
|
433
|
+
get: function get() {
|
|
434
|
+
return this.outputAreaDeferred.promise;
|
|
435
|
+
}
|
|
436
|
+
}, {
|
|
437
|
+
key: "setEditorHost",
|
|
438
|
+
value: function setEditorHost(ref) {
|
|
439
|
+
var editorHostId = this.parent.id + this.id;
|
|
440
|
+
this.codeEditorManager.setEditorHostRef(editorHostId, ref);
|
|
441
|
+
}
|
|
442
|
+
}, {
|
|
443
|
+
key: "toJSON",
|
|
444
|
+
value: function toJSON() {
|
|
445
|
+
var _meta$source, _this$outputArea$toJS, _this$outputArea;
|
|
446
|
+
var meta = _get(_getPrototypeOf(LibroSqlCellView.prototype), "toJSON", this).call(this);
|
|
447
|
+
return _objectSpread(_objectSpread({}, meta), {}, {
|
|
448
|
+
source: (_meta$source = meta.source) !== null && _meta$source !== void 0 ? _meta$source : this.options.cell.source,
|
|
449
|
+
outputs: (_this$outputArea$toJS = (_this$outputArea = this.outputArea) === null || _this$outputArea === void 0 ? void 0 : _this$outputArea.toJSON()) !== null && _this$outputArea$toJS !== void 0 ? _this$outputArea$toJS : this.outputs
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
}, {
|
|
453
|
+
key: "run",
|
|
454
|
+
value: function () {
|
|
455
|
+
var _run = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
456
|
+
var _this2 = this;
|
|
457
|
+
var libroModel, kernelConnection, cellContent, future, startTimeStr, msgPromise, endTimeStr;
|
|
458
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
459
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
460
|
+
case 0:
|
|
461
|
+
libroModel = this.parent.model;
|
|
462
|
+
if (!(!libroModel || !(libroModel instanceof LibroJupyterModel) || !libroModel.kernelConnection || libroModel.kernelConnection.isDisposed)) {
|
|
463
|
+
_context5.next = 3;
|
|
464
|
+
break;
|
|
465
|
+
}
|
|
466
|
+
return _context5.abrupt("return", false);
|
|
467
|
+
case 3:
|
|
468
|
+
kernelConnection = getOrigin(libroModel.kernelConnection);
|
|
469
|
+
cellContent = this.model.source;
|
|
470
|
+
_context5.prev = 5;
|
|
471
|
+
// Promise.resolve().then(() => {
|
|
472
|
+
this.clearExecution();
|
|
473
|
+
// });
|
|
474
|
+
future = kernelConnection.requestExecute({
|
|
475
|
+
code: cellContent
|
|
476
|
+
});
|
|
477
|
+
startTimeStr = null;
|
|
478
|
+
this.model.executing = true;
|
|
479
|
+
this.model.metadata['execution'] = {
|
|
480
|
+
'shell.execute_reply.started': '',
|
|
481
|
+
'shell.execute_reply.end': '',
|
|
482
|
+
to_execute: new Date().toISOString()
|
|
483
|
+
};
|
|
484
|
+
// Handle iopub messages
|
|
485
|
+
future.onIOPub = function (msg) {
|
|
486
|
+
_this2.model.msgChangeEmitter.fire(msg);
|
|
487
|
+
if (msg.header.msg_type === 'execute_input') {
|
|
488
|
+
_this2.model.kernelExecuting = true;
|
|
489
|
+
startTimeStr = msg.header.date;
|
|
490
|
+
var meta = _this2.model.metadata['execution'];
|
|
491
|
+
if (meta) {
|
|
492
|
+
meta['shell.execute_reply.started'] = startTimeStr;
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
if (msg.header.msg_type === 'execute_result') {
|
|
496
|
+
_this2.model.metadata['isVariableSaved'] = msg.content.data['application/vnd.libro.sql+json'].isVariableSaved;
|
|
497
|
+
}
|
|
498
|
+
if (msg.header.msg_type === 'error') {
|
|
499
|
+
_this2.model.hasExecutedError = true;
|
|
500
|
+
}
|
|
501
|
+
};
|
|
502
|
+
_context5.next = 14;
|
|
503
|
+
return future.done;
|
|
504
|
+
case 14:
|
|
505
|
+
msgPromise = _context5.sent;
|
|
506
|
+
this.model.executing = false;
|
|
507
|
+
this.model.kernelExecuting = false;
|
|
508
|
+
this.model.hasExecutedSuccess = !this.model.hasExecutedError;
|
|
509
|
+
startTimeStr = msgPromise.metadata['started']; // 更新startTimeStr
|
|
510
|
+
endTimeStr = msgPromise.header.date;
|
|
511
|
+
this.model.metadata['execution']['shell.execute_reply.started'] = startTimeStr;
|
|
512
|
+
this.model.metadata['execution']['shell.execute_reply.end'] = endTimeStr;
|
|
513
|
+
if (msgPromise) {
|
|
514
|
+
_context5.next = 24;
|
|
515
|
+
break;
|
|
516
|
+
}
|
|
517
|
+
return _context5.abrupt("return", true);
|
|
518
|
+
case 24:
|
|
519
|
+
if (!(msgPromise.content.status === 'ok')) {
|
|
520
|
+
_context5.next = 28;
|
|
521
|
+
break;
|
|
522
|
+
}
|
|
523
|
+
return _context5.abrupt("return", true);
|
|
524
|
+
case 28:
|
|
525
|
+
throw new KernelError(msgPromise.content);
|
|
526
|
+
case 29:
|
|
527
|
+
_context5.next = 36;
|
|
528
|
+
break;
|
|
529
|
+
case 31:
|
|
530
|
+
_context5.prev = 31;
|
|
531
|
+
_context5.t0 = _context5["catch"](5);
|
|
532
|
+
if (!_context5.t0.message.startsWith('Canceled')) {
|
|
533
|
+
_context5.next = 35;
|
|
534
|
+
break;
|
|
535
|
+
}
|
|
536
|
+
return _context5.abrupt("return", false);
|
|
537
|
+
case 35:
|
|
538
|
+
throw _context5.t0;
|
|
539
|
+
case 36:
|
|
540
|
+
case "end":
|
|
541
|
+
return _context5.stop();
|
|
542
|
+
}
|
|
543
|
+
}, _callee5, this, [[5, 31]]);
|
|
544
|
+
}));
|
|
545
|
+
function run() {
|
|
546
|
+
return _run.apply(this, arguments);
|
|
547
|
+
}
|
|
548
|
+
return run;
|
|
549
|
+
}()
|
|
550
|
+
}]);
|
|
551
|
+
return LibroSqlCellView;
|
|
552
|
+
}(LibroEditableExecutableCellView), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "databaseConfig", [_dec3], {
|
|
553
|
+
configurable: true,
|
|
554
|
+
enumerable: true,
|
|
555
|
+
writable: true,
|
|
556
|
+
initializer: null
|
|
557
|
+
}), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "editorStatus", [_dec4], {
|
|
558
|
+
configurable: true,
|
|
559
|
+
enumerable: true,
|
|
560
|
+
writable: true,
|
|
561
|
+
initializer: function initializer() {
|
|
562
|
+
return EditorStatus.NOTLOADED;
|
|
563
|
+
}
|
|
564
|
+
}), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "editorAreaHeight", [_dec5], {
|
|
565
|
+
configurable: true,
|
|
566
|
+
enumerable: true,
|
|
567
|
+
writable: true,
|
|
568
|
+
initializer: function initializer() {
|
|
569
|
+
return 0;
|
|
570
|
+
}
|
|
571
|
+
}), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "noEditorAreaHeight", [_dec6], {
|
|
572
|
+
configurable: true,
|
|
573
|
+
enumerable: true,
|
|
574
|
+
writable: true,
|
|
575
|
+
initializer: function initializer() {
|
|
576
|
+
return 0;
|
|
577
|
+
}
|
|
578
|
+
}), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "sqlScript", [_dec7], {
|
|
579
|
+
configurable: true,
|
|
580
|
+
enumerable: true,
|
|
581
|
+
writable: true,
|
|
582
|
+
initializer: null
|
|
583
|
+
})), _class2)) || _class) || _class);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"libro-sql-utils.d.ts","sourceRoot":"","sources":["../src/libro-sql-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,eAAO,MAAM,iBAAiB,UAAW,gBAAgB,EAAE,WAmB1D,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
2
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
3
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
4
|
+
export var getDfVariableName = function getDfVariableName(cells) {
|
|
5
|
+
var maxNumber = 0; // 记录目前找到的最大数字
|
|
6
|
+
|
|
7
|
+
// 遍历数组中的每个变量名
|
|
8
|
+
var _iterator = _createForOfIteratorHelper(cells),
|
|
9
|
+
_step;
|
|
10
|
+
try {
|
|
11
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
12
|
+
var _cell$model$resultVar;
|
|
13
|
+
var cell = _step.value;
|
|
14
|
+
// 检查变量名是否符合 "df_" 开头,并且后面跟着数字的格式
|
|
15
|
+
if ((_cell$model$resultVar = cell.model.resultVariable) !== null && _cell$model$resultVar !== void 0 && _cell$model$resultVar.startsWith('df_')) {
|
|
16
|
+
var numberPart = cell.model.resultVariable.slice(3); // 提取 "df_" 后面的部分
|
|
17
|
+
var num = parseInt(numberPart, 10); // 将提取出来的部分转成数字
|
|
18
|
+
|
|
19
|
+
// 确保提取出来的是有效数字,并更新最大数字
|
|
20
|
+
if (!isNaN(num)) {
|
|
21
|
+
maxNumber = Math.max(maxNumber, num);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// 返回下一个可用的变量名
|
|
27
|
+
} catch (err) {
|
|
28
|
+
_iterator.e(err);
|
|
29
|
+
} finally {
|
|
30
|
+
_iterator.f();
|
|
31
|
+
}
|
|
32
|
+
return "df_".concat(maxNumber + 1);
|
|
33
|
+
};
|
package/es/module.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAW/C,eAAO,MAAM,kBAAkB,YAwBgB,CAAC"}
|