@difizen/libro-app 0.2.45
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/app-file-command-contribution.d.ts +19 -0
- package/es/app-file-command-contribution.d.ts.map +1 -0
- package/es/app-file-command-contribution.js +100 -0
- package/es/app-open-handler.d.ts +15 -0
- package/es/app-open-handler.d.ts.map +1 -0
- package/es/app-open-handler.js +102 -0
- package/es/app-view.d.ts +19 -0
- package/es/app-view.d.ts.map +1 -0
- package/es/app-view.js +191 -0
- package/es/app-viewer.d.ts +21 -0
- package/es/app-viewer.d.ts.map +1 -0
- package/es/app-viewer.js +99 -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 +147 -0
- package/es/module.d.ts +3 -0
- package/es/module.d.ts.map +1 -0
- package/es/module.js +6 -0
- package/es/protocol.d.ts +2 -0
- package/es/protocol.d.ts.map +1 -0
- package/es/protocol.js +1 -0
- package/package.json +61 -0
- package/src/app-file-command-contribution.tsx +75 -0
- package/src/app-open-handler.ts +46 -0
- package/src/app-view.tsx +142 -0
- package/src/app-viewer.tsx +85 -0
- package/src/index.less +147 -0
- package/src/index.spec.ts +8 -0
- package/src/index.ts +1 -0
- package/src/module.ts +13 -0
- package/src/protocol.ts +1 -0
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 @@
|
|
|
1
|
+
# libro-app
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { JupyterFileService } from '@difizen/libro-jupyter';
|
|
2
|
+
import type { CommandRegistry, MenuRegistry, ViewManager } from '@difizen/mana-app';
|
|
3
|
+
import { ConfigurationService, CommandContribution, MenuContribution, ModalService, OpenerService } from '@difizen/mana-app';
|
|
4
|
+
export declare const AppFileCommands: {
|
|
5
|
+
OPEN_FILE_BY_LIBRO_APP: {
|
|
6
|
+
id: string;
|
|
7
|
+
label: string;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export declare class AppFileCommandContribution implements CommandContribution, MenuContribution {
|
|
11
|
+
protected viewManager: ViewManager;
|
|
12
|
+
fileService: JupyterFileService;
|
|
13
|
+
modalService: ModalService;
|
|
14
|
+
protected openService: OpenerService;
|
|
15
|
+
configurationService: ConfigurationService;
|
|
16
|
+
registerMenus(menu: MenuRegistry): void;
|
|
17
|
+
registerCommands(command: CommandRegistry): void;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=app-file-command-contribution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-file-command-contribution.d.ts","sourceRoot":"","sources":["../src/app-file-command-contribution.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA6B,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACvF,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACpF,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EAGnB,gBAAgB,EAChB,YAAY,EACZ,aAAa,EAEd,MAAM,mBAAmB,CAAC;AAI3B,eAAO,MAAM,eAAe;;;;;CAK3B,CAAC;AAEF,qBAGa,0BACX,YAAW,mBAAmB,EAAE,gBAAgB;IAEhD,SAAS,CAAC,WAAW,EAAE,WAAW,CAAC;IACP,WAAW,EAAE,kBAAkB,CAAC;IACtC,YAAY,EAAE,YAAY,CAAC;IAC1B,SAAS,CAAC,WAAW,EAAE,aAAa,CAAC;IAC9B,oBAAoB,EAAE,oBAAoB,CAAC;IAEzE,aAAa,CAAC,IAAI,EAAE,YAAY;IAQhC,gBAAgB,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI;CAgCjD"}
|
|
@@ -0,0 +1,100 @@
|
|
|
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(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
8
|
+
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); }
|
|
9
|
+
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; }
|
|
10
|
+
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.'); }
|
|
11
|
+
import { FileTreeContextMenuGroups, JupyterFileService } from '@difizen/libro-jupyter';
|
|
12
|
+
import { ConfigurationService, CommandContribution, FileStatNode, inject, MenuContribution, ModalService, OpenerService, singleton } from '@difizen/mana-app';
|
|
13
|
+
import { l10n } from '@difizen/mana-l10n';
|
|
14
|
+
import { message } from 'antd';
|
|
15
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
|
+
export var AppFileCommands = {
|
|
17
|
+
OPEN_FILE_BY_LIBRO_APP: {
|
|
18
|
+
id: 'fileTree.command.openfilebyapp',
|
|
19
|
+
label: '以报告的形式打开'
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
export var AppFileCommandContribution = (_dec = singleton({
|
|
23
|
+
contrib: [CommandContribution, MenuContribution]
|
|
24
|
+
}), _dec2 = inject(JupyterFileService), _dec3 = inject(ModalService), _dec4 = inject(OpenerService), _dec5 = inject(ConfigurationService), _dec(_class = (_class2 = /*#__PURE__*/function () {
|
|
25
|
+
function AppFileCommandContribution() {
|
|
26
|
+
_classCallCheck(this, AppFileCommandContribution);
|
|
27
|
+
_initializerDefineProperty(this, "fileService", _descriptor, this);
|
|
28
|
+
_initializerDefineProperty(this, "modalService", _descriptor2, this);
|
|
29
|
+
_initializerDefineProperty(this, "openService", _descriptor3, this);
|
|
30
|
+
_initializerDefineProperty(this, "configurationService", _descriptor4, this);
|
|
31
|
+
}
|
|
32
|
+
_createClass(AppFileCommandContribution, [{
|
|
33
|
+
key: "registerMenus",
|
|
34
|
+
value: function registerMenus(menu) {
|
|
35
|
+
menu.registerMenuAction(FileTreeContextMenuGroups['new'], {
|
|
36
|
+
id: AppFileCommands.OPEN_FILE_BY_LIBRO_APP.id,
|
|
37
|
+
command: AppFileCommands.OPEN_FILE_BY_LIBRO_APP.id,
|
|
38
|
+
label: function label() {
|
|
39
|
+
return /*#__PURE__*/_jsx("div", {
|
|
40
|
+
children: l10n.t(AppFileCommands.OPEN_FILE_BY_LIBRO_APP.label)
|
|
41
|
+
});
|
|
42
|
+
},
|
|
43
|
+
order: 'e'
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}, {
|
|
47
|
+
key: "registerCommands",
|
|
48
|
+
value: function registerCommands(command) {
|
|
49
|
+
var _this = this;
|
|
50
|
+
command.registerCommand(AppFileCommands.OPEN_FILE_BY_LIBRO_APP, {
|
|
51
|
+
execute: function execute(node) {
|
|
52
|
+
try {
|
|
53
|
+
if (node.fileStat.isFile) {
|
|
54
|
+
_this.openService.getOpener(node.uri, {
|
|
55
|
+
isApp: true
|
|
56
|
+
}).then(function (opener) {
|
|
57
|
+
if (opener) {
|
|
58
|
+
opener.open(node.uri, {
|
|
59
|
+
viewOptions: {
|
|
60
|
+
name: node.fileStat.name
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
return;
|
|
65
|
+
}).catch(function () {
|
|
66
|
+
throw Error();
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
} catch (_unused) {
|
|
70
|
+
message.error(l10n.t('文件打开失败'));
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
isVisible: function isVisible(node) {
|
|
74
|
+
return FileStatNode.is(node) && node.fileStat.isFile;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}]);
|
|
79
|
+
return AppFileCommandContribution;
|
|
80
|
+
}(), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "fileService", [_dec2], {
|
|
81
|
+
configurable: true,
|
|
82
|
+
enumerable: true,
|
|
83
|
+
writable: true,
|
|
84
|
+
initializer: null
|
|
85
|
+
}), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "modalService", [_dec3], {
|
|
86
|
+
configurable: true,
|
|
87
|
+
enumerable: true,
|
|
88
|
+
writable: true,
|
|
89
|
+
initializer: null
|
|
90
|
+
}), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "openService", [_dec4], {
|
|
91
|
+
configurable: true,
|
|
92
|
+
enumerable: true,
|
|
93
|
+
writable: true,
|
|
94
|
+
initializer: null
|
|
95
|
+
}), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "configurationService", [_dec5], {
|
|
96
|
+
configurable: true,
|
|
97
|
+
enumerable: true,
|
|
98
|
+
writable: true,
|
|
99
|
+
initializer: null
|
|
100
|
+
})), _class2)) || _class);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { URI, ViewOpenHandlerOptions } from '@difizen/mana-app';
|
|
2
|
+
import { ConfigurationService } from '@difizen/mana-app';
|
|
3
|
+
import { NavigatableViewOpenHandler } from '@difizen/mana-app';
|
|
4
|
+
import type { LibroAppViewer } from './app-viewer.js';
|
|
5
|
+
interface AppOpenHandlerOptions extends ViewOpenHandlerOptions {
|
|
6
|
+
isApp?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare class LibroAppOpenHandler extends NavigatableViewOpenHandler<LibroAppViewer> {
|
|
9
|
+
protected configurationService: ConfigurationService;
|
|
10
|
+
id: string;
|
|
11
|
+
canHandle(uri: URI, _options?: AppOpenHandlerOptions): number;
|
|
12
|
+
open(uri: URI, options?: AppOpenHandlerOptions): Promise<LibroAppViewer>;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=app-open-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-open-handler.d.ts","sourceRoot":"","sources":["../src/app-open-handler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAU,MAAM,mBAAmB,CAAC;AACjE,OAAO,EACL,0BAA0B,EAI3B,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGtD,UAAU,qBAAsB,SAAQ,sBAAsB;IAC5D,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AACD,qBACa,mBAAoB,SAAQ,0BAA0B,CAAC,cAAc,CAAC;IACnD,SAAS,CAAC,oBAAoB,EAAE,oBAAoB,CAAC;IAEnF,EAAE,SAAoB;IAGtB,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,CAAC,EAAE,qBAAqB;IAOrC,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,GAAE,qBAA0B;CAelE"}
|
|
@@ -0,0 +1,102 @@
|
|
|
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 _excluded = ["viewOptions"];
|
|
3
|
+
var _dec, _dec2, _class, _class2, _descriptor;
|
|
4
|
+
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; }
|
|
5
|
+
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; }
|
|
6
|
+
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; }
|
|
7
|
+
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; }
|
|
8
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
9
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
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 _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 }); }
|
|
13
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
14
|
+
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); } }
|
|
15
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
16
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
17
|
+
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); }
|
|
18
|
+
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); }
|
|
19
|
+
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
|
20
|
+
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); }
|
|
21
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
22
|
+
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); }; }
|
|
23
|
+
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); }
|
|
24
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
25
|
+
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; } }
|
|
26
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
27
|
+
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; }
|
|
28
|
+
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.'); }
|
|
29
|
+
import { LibroJupyterConfiguration } from '@difizen/libro-jupyter';
|
|
30
|
+
import { ConfigurationService, inject } from '@difizen/mana-app';
|
|
31
|
+
import { NavigatableViewOpenHandler, OpenHandler, singleton, Priority } from '@difizen/mana-app';
|
|
32
|
+
import { AppViewerFactory } from "./protocol.js";
|
|
33
|
+
export var LibroAppOpenHandler = (_dec = singleton({
|
|
34
|
+
contrib: OpenHandler
|
|
35
|
+
}), _dec2 = inject(ConfigurationService), _dec(_class = (_class2 = /*#__PURE__*/function (_NavigatableViewOpenH) {
|
|
36
|
+
_inherits(LibroAppOpenHandler, _NavigatableViewOpenH);
|
|
37
|
+
var _super = _createSuper(LibroAppOpenHandler);
|
|
38
|
+
function LibroAppOpenHandler() {
|
|
39
|
+
var _this;
|
|
40
|
+
_classCallCheck(this, LibroAppOpenHandler);
|
|
41
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
42
|
+
args[_key] = arguments[_key];
|
|
43
|
+
}
|
|
44
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
45
|
+
_initializerDefineProperty(_this, "configurationService", _descriptor, _assertThisInitialized(_this));
|
|
46
|
+
_this.id = AppViewerFactory;
|
|
47
|
+
return _this;
|
|
48
|
+
}
|
|
49
|
+
_createClass(LibroAppOpenHandler, [{
|
|
50
|
+
key: "canHandle",
|
|
51
|
+
value:
|
|
52
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
53
|
+
function canHandle(uri, _options) {
|
|
54
|
+
if (uri.scheme === 'file' && uri.path.ext === '.ipynb' && _options !== null && _options !== void 0 && _options.isApp) {
|
|
55
|
+
return Priority.PRIOR + 2;
|
|
56
|
+
}
|
|
57
|
+
return Priority.IDLE;
|
|
58
|
+
}
|
|
59
|
+
}, {
|
|
60
|
+
key: "open",
|
|
61
|
+
value: function () {
|
|
62
|
+
var _open = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(uri) {
|
|
63
|
+
var options,
|
|
64
|
+
viewOptions,
|
|
65
|
+
extra,
|
|
66
|
+
slot,
|
|
67
|
+
_args = arguments;
|
|
68
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
69
|
+
while (1) switch (_context.prev = _context.next) {
|
|
70
|
+
case 0:
|
|
71
|
+
options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
|
|
72
|
+
viewOptions = options.viewOptions, extra = _objectWithoutProperties(options, _excluded);
|
|
73
|
+
_context.next = 4;
|
|
74
|
+
return this.configurationService.get(LibroJupyterConfiguration['OpenSlot']);
|
|
75
|
+
case 4:
|
|
76
|
+
slot = _context.sent;
|
|
77
|
+
return _context.abrupt("return", _get(_getPrototypeOf(LibroAppOpenHandler.prototype), "open", this).call(this, uri, _objectSpread({
|
|
78
|
+
slot: slot,
|
|
79
|
+
viewOptions: _objectSpread({
|
|
80
|
+
path: uri.path.toString()
|
|
81
|
+
}, viewOptions),
|
|
82
|
+
reveal: true
|
|
83
|
+
}, extra)));
|
|
84
|
+
case 6:
|
|
85
|
+
case "end":
|
|
86
|
+
return _context.stop();
|
|
87
|
+
}
|
|
88
|
+
}, _callee, this);
|
|
89
|
+
}));
|
|
90
|
+
function open(_x) {
|
|
91
|
+
return _open.apply(this, arguments);
|
|
92
|
+
}
|
|
93
|
+
return open;
|
|
94
|
+
}()
|
|
95
|
+
}]);
|
|
96
|
+
return LibroAppOpenHandler;
|
|
97
|
+
}(NavigatableViewOpenHandler), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "configurationService", [_dec2], {
|
|
98
|
+
configurable: true,
|
|
99
|
+
enumerable: true,
|
|
100
|
+
writable: true,
|
|
101
|
+
initializer: null
|
|
102
|
+
})), _class2)) || _class);
|
package/es/app-view.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/// <reference types="react" resolution-mode="require"/>
|
|
2
|
+
import type { LibroView } from '@difizen/libro-jupyter';
|
|
3
|
+
import { LibroService } from '@difizen/libro-jupyter';
|
|
4
|
+
import { BaseView } from '@difizen/mana-app';
|
|
5
|
+
import './index.less';
|
|
6
|
+
export declare const AppViewComponent: import("react").ForwardRefExoticComponent<import("react").RefAttributes<unknown>>;
|
|
7
|
+
export declare class LibroAppView extends BaseView {
|
|
8
|
+
protected libroService: LibroService;
|
|
9
|
+
view: import("react").ForwardRefExoticComponent<import("react").RefAttributes<unknown>>;
|
|
10
|
+
libroView?: LibroView;
|
|
11
|
+
path: string;
|
|
12
|
+
mode: string;
|
|
13
|
+
constructor(options: {
|
|
14
|
+
path: string;
|
|
15
|
+
});
|
|
16
|
+
onViewMount(): void;
|
|
17
|
+
protected getOrCreateLibroView(): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=app-view.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-view.d.ts","sourceRoot":"","sources":["../src/app-view.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAEL,YAAY,EAKb,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,QAAQ,EAST,MAAM,mBAAmB,CAAC;AAM3B,OAAO,cAAc,CAAC;AAEtB,eAAO,MAAM,gBAAgB,mFA2E3B,CAAC;AAEH,qBAEa,YAAa,SAAQ,QAAQ;IAClB,SAAS,CAAC,YAAY,EAAE,YAAY,CAAC;IAClD,IAAI,oFAAoB;IAEzB,SAAS,CAAC,EAAE,SAAS,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC;IAGb,IAAI,SAAS;gBAEmB,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE;IAKhD,WAAW,IAAI,IAAI;cAIZ,oBAAoB;CAgBrC"}
|
package/es/app-view.js
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
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;
|
|
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(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
11
|
+
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); }
|
|
12
|
+
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); }
|
|
13
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
14
|
+
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); }; }
|
|
15
|
+
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); }
|
|
16
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
17
|
+
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; } }
|
|
18
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
19
|
+
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; }
|
|
20
|
+
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.'); }
|
|
21
|
+
import { ExecutableCellView, LibroService, CellCollapsible, ArrowDown, ArrowRight, PlusOutlined } from '@difizen/libro-jupyter';
|
|
22
|
+
import { BaseView, inject, prop, transient, useInject, view, ViewInstance, ViewOption, ViewRender } from '@difizen/mana-app';
|
|
23
|
+
import { l10n } from '@difizen/mana-l10n';
|
|
24
|
+
import { Radio, Button } from 'antd';
|
|
25
|
+
import { forwardRef } from 'react';
|
|
26
|
+
import "./index.less";
|
|
27
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
28
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
29
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
30
|
+
export var AppViewComponent = /*#__PURE__*/forwardRef(function LibroAppComponent() {
|
|
31
|
+
var instance = useInject(ViewInstance);
|
|
32
|
+
if (!instance.libroView || !instance.libroView.view) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
var handleSizeChange = function handleSizeChange(e) {
|
|
36
|
+
instance.mode = e.target.value;
|
|
37
|
+
};
|
|
38
|
+
var children = null;
|
|
39
|
+
if (instance.mode === 'notebook') {
|
|
40
|
+
children = instance.libroView ? /*#__PURE__*/_jsx(ViewRender, {
|
|
41
|
+
view: instance.libroView
|
|
42
|
+
}) : null;
|
|
43
|
+
} else {
|
|
44
|
+
var _instance$libroView;
|
|
45
|
+
children = /*#__PURE__*/_jsx("div", {
|
|
46
|
+
className: "libro-app-cell-list",
|
|
47
|
+
children: (_instance$libroView = instance.libroView) === null || _instance$libroView === void 0 ? void 0 : _instance$libroView.model.cells.map(function (cell) {
|
|
48
|
+
if (cell.collapsedHidden) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
if (ExecutableCellView.is(cell)) {
|
|
52
|
+
return /*#__PURE__*/_jsx(ViewRender, {
|
|
53
|
+
view: cell.outputArea
|
|
54
|
+
}, cell.id);
|
|
55
|
+
} else {
|
|
56
|
+
var _instance$libroView2;
|
|
57
|
+
var isCollapsible = CellCollapsible.is(cell);
|
|
58
|
+
return /*#__PURE__*/_jsx(_Fragment, {
|
|
59
|
+
children: ((_instance$libroView2 = instance.libroView) === null || _instance$libroView2 === void 0 ? void 0 : _instance$libroView2.collapserVisible) && isCollapsible && /*#__PURE__*/_jsxs("div", {
|
|
60
|
+
className: "libro-app-cell-container",
|
|
61
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
62
|
+
className: "libro-markdown-collapser",
|
|
63
|
+
onClick: function onClick() {
|
|
64
|
+
var _instance$libroView3;
|
|
65
|
+
(_instance$libroView3 = instance.libroView) === null || _instance$libroView3 === void 0 || _instance$libroView3.collapseCell(cell, !cell.headingCollapsed);
|
|
66
|
+
},
|
|
67
|
+
children: cell.headingCollapsed ? /*#__PURE__*/_jsx(ArrowRight, {}) : /*#__PURE__*/_jsx(ArrowDown, {})
|
|
68
|
+
}), /*#__PURE__*/_jsx(ViewRender, {
|
|
69
|
+
view: cell
|
|
70
|
+
}), isCollapsible && cell.headingCollapsed && cell.collapsibleChildNumber > 0 && /*#__PURE__*/_jsx("div", {
|
|
71
|
+
className: "libro-cell-collapsed-expander",
|
|
72
|
+
children: /*#__PURE__*/_jsxs(Button, {
|
|
73
|
+
className: "libro-cell-expand-button",
|
|
74
|
+
onClick: function onClick() {
|
|
75
|
+
var _instance$libroView4;
|
|
76
|
+
return (_instance$libroView4 = instance.libroView) === null || _instance$libroView4 === void 0 ? void 0 : _instance$libroView4.collapseCell(cell, false);
|
|
77
|
+
},
|
|
78
|
+
icon: /*#__PURE__*/_jsx(PlusOutlined, {
|
|
79
|
+
className: ""
|
|
80
|
+
}),
|
|
81
|
+
type: "default",
|
|
82
|
+
children: [cell.collapsibleChildNumber, " cell hidden"]
|
|
83
|
+
})
|
|
84
|
+
})]
|
|
85
|
+
})
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
})
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
92
|
+
className: "libro-app-container",
|
|
93
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
94
|
+
className: "libro-app-container-header",
|
|
95
|
+
children: /*#__PURE__*/_jsxs(Radio.Group, {
|
|
96
|
+
value: instance.mode,
|
|
97
|
+
onChange: handleSizeChange,
|
|
98
|
+
children: [/*#__PURE__*/_jsx(Radio.Button, {
|
|
99
|
+
value: "app",
|
|
100
|
+
children: l10n.t('报告预览')
|
|
101
|
+
}), /*#__PURE__*/_jsx(Radio.Button, {
|
|
102
|
+
value: "notebook",
|
|
103
|
+
children: "notebook"
|
|
104
|
+
})]
|
|
105
|
+
})
|
|
106
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
107
|
+
className: "libro-app-container-content",
|
|
108
|
+
children: children
|
|
109
|
+
})]
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
export var LibroAppView = (_dec = transient(), _dec2 = view('libro-app'), _dec3 = inject(LibroService), _dec4 = prop(), _dec5 = prop(), _dec(_class = _dec2(_class = (_class2 = /*#__PURE__*/function (_BaseView) {
|
|
113
|
+
_inherits(LibroAppView, _BaseView);
|
|
114
|
+
var _super = _createSuper(LibroAppView);
|
|
115
|
+
function LibroAppView(options) {
|
|
116
|
+
var _this;
|
|
117
|
+
_classCallCheck(this, LibroAppView);
|
|
118
|
+
_this = _super.call(this);
|
|
119
|
+
_initializerDefineProperty(_this, "libroService", _descriptor, _assertThisInitialized(_this));
|
|
120
|
+
_this.view = AppViewComponent;
|
|
121
|
+
_initializerDefineProperty(_this, "libroView", _descriptor2, _assertThisInitialized(_this));
|
|
122
|
+
_initializerDefineProperty(_this, "mode", _descriptor3, _assertThisInitialized(_this));
|
|
123
|
+
_this.path = options.path;
|
|
124
|
+
return _this;
|
|
125
|
+
}
|
|
126
|
+
LibroAppView = inject(ViewOption)(LibroAppView, undefined, 0) || LibroAppView;
|
|
127
|
+
_createClass(LibroAppView, [{
|
|
128
|
+
key: "onViewMount",
|
|
129
|
+
value: function onViewMount() {
|
|
130
|
+
this.getOrCreateLibroView();
|
|
131
|
+
}
|
|
132
|
+
}, {
|
|
133
|
+
key: "getOrCreateLibroView",
|
|
134
|
+
value: function () {
|
|
135
|
+
var _getOrCreateLibroView = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
136
|
+
var libroView;
|
|
137
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
138
|
+
while (1) switch (_context.prev = _context.next) {
|
|
139
|
+
case 0:
|
|
140
|
+
_context.next = 2;
|
|
141
|
+
return this.libroService.getOrCreateView({
|
|
142
|
+
id: this.path,
|
|
143
|
+
resource: this.path
|
|
144
|
+
});
|
|
145
|
+
case 2:
|
|
146
|
+
libroView = _context.sent;
|
|
147
|
+
if (libroView) {
|
|
148
|
+
_context.next = 5;
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
return _context.abrupt("return");
|
|
152
|
+
case 5:
|
|
153
|
+
libroView.model.cellsEditable = false;
|
|
154
|
+
libroView.model.runnable = false;
|
|
155
|
+
libroView.model.inputEditable = false;
|
|
156
|
+
libroView.model.outputEditable = false;
|
|
157
|
+
libroView.model.savable = false;
|
|
158
|
+
this.libroView = libroView;
|
|
159
|
+
_context.next = 13;
|
|
160
|
+
return this.libroView.initialized;
|
|
161
|
+
case 13:
|
|
162
|
+
case "end":
|
|
163
|
+
return _context.stop();
|
|
164
|
+
}
|
|
165
|
+
}, _callee, this);
|
|
166
|
+
}));
|
|
167
|
+
function getOrCreateLibroView() {
|
|
168
|
+
return _getOrCreateLibroView.apply(this, arguments);
|
|
169
|
+
}
|
|
170
|
+
return getOrCreateLibroView;
|
|
171
|
+
}()
|
|
172
|
+
}]);
|
|
173
|
+
return LibroAppView;
|
|
174
|
+
}(BaseView), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "libroService", [_dec3], {
|
|
175
|
+
configurable: true,
|
|
176
|
+
enumerable: true,
|
|
177
|
+
writable: true,
|
|
178
|
+
initializer: null
|
|
179
|
+
}), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "libroView", [_dec4], {
|
|
180
|
+
configurable: true,
|
|
181
|
+
enumerable: true,
|
|
182
|
+
writable: true,
|
|
183
|
+
initializer: null
|
|
184
|
+
}), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "mode", [_dec5], {
|
|
185
|
+
configurable: true,
|
|
186
|
+
enumerable: true,
|
|
187
|
+
writable: true,
|
|
188
|
+
initializer: function initializer() {
|
|
189
|
+
return 'app';
|
|
190
|
+
}
|
|
191
|
+
})), _class2)) || _class) || _class);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/// <reference types="react" resolution-mode="require"/>
|
|
2
|
+
import type { NavigatableView } from '@difizen/mana-app';
|
|
3
|
+
import { ViewManager } from '@difizen/mana-app';
|
|
4
|
+
import { BaseView, LabelProvider, Deferred, URI, CommandRegistry } from '@difizen/mana-app';
|
|
5
|
+
import './index.less';
|
|
6
|
+
import { LibroAppView } from './app-view.js';
|
|
7
|
+
export declare const AppViewerComponent: import("react").ForwardRefExoticComponent<import("react").RefAttributes<unknown>>;
|
|
8
|
+
export declare class LibroAppViewer extends BaseView implements NavigatableView {
|
|
9
|
+
commandRegistry: CommandRegistry;
|
|
10
|
+
view: import("react").ForwardRefExoticComponent<import("react").RefAttributes<unknown>>;
|
|
11
|
+
appView?: LibroAppView;
|
|
12
|
+
filePath?: string;
|
|
13
|
+
protected defer: Deferred<void>;
|
|
14
|
+
get ready(): Promise<void>;
|
|
15
|
+
constructor(options: {
|
|
16
|
+
path: string;
|
|
17
|
+
}, labelProvider: LabelProvider, viewManager: ViewManager);
|
|
18
|
+
getResourceUri(): URI | undefined;
|
|
19
|
+
createMoveToUri(resourceUri: URI): URI | undefined;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=app-viewer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-viewer.d.ts","sourceRoot":"","sources":["../src/app-viewer.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAc,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EACL,QAAQ,EAER,aAAa,EASb,QAAQ,EACR,GAAG,EACH,eAAe,EAChB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,cAAc,CAAC;AACtB,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAG7C,eAAO,MAAM,kBAAkB,mFAQ7B,CAAC;AAEH,qBAEa,cAAe,SAAQ,QAAS,YAAW,eAAe;IAC5C,eAAe,EAAE,eAAe,CAAC;IAEjD,IAAI,oFAAsB;IAGnC,OAAO,CAAC,EAAE,YAAY,CAAC;IAEf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAE1B,SAAS,CAAC,KAAK,iBAAwB;IAEvC,IAAI,KAAK,kBAER;gBAGqB,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,EACtB,aAAa,EAAE,aAAa,EAC9B,WAAW,EAAE,WAAW;IAqB/C,cAAc,IAAI,GAAG,GAAG,SAAS;IAIjC,eAAe,CAAC,WAAW,EAAE,GAAG,GAAG,GAAG,GAAG,SAAS;CAInD"}
|