@difizen/libro-lab 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/es/command/lab-command.d.ts +4 -0
  2. package/es/command/lab-command.d.ts.map +1 -1
  3. package/es/command/lab-command.js +4 -0
  4. package/es/command/lab-menu-contribution.d.ts +3 -2
  5. package/es/command/lab-menu-contribution.d.ts.map +1 -1
  6. package/es/command/lab-menu-contribution.js +151 -110
  7. package/es/config/config.d.ts +2 -0
  8. package/es/config/config.d.ts.map +1 -1
  9. package/es/config/config.js +12 -1
  10. package/es/guide/content-contribution.d.ts +7 -0
  11. package/es/guide/content-contribution.d.ts.map +1 -0
  12. package/es/guide/content-contribution.js +74 -0
  13. package/es/guide/guide-view.d.ts +19 -0
  14. package/es/guide/guide-view.d.ts.map +1 -0
  15. package/es/guide/guide-view.js +141 -0
  16. package/es/guide/index.d.ts +3 -0
  17. package/es/guide/index.d.ts.map +1 -0
  18. package/es/guide/index.js +2 -0
  19. package/es/guide/index.less +8 -0
  20. package/es/guide/libro_guide_book.json +333 -0
  21. package/es/guide/libro_guide_book_zh.json +331 -0
  22. package/es/lab-app.d.ts.map +1 -1
  23. package/es/lab-app.js +51 -27
  24. package/es/module.d.ts.map +1 -1
  25. package/es/module.js +3 -1
  26. package/package.json +14 -14
  27. package/src/command/lab-command.ts +4 -0
  28. package/src/command/lab-menu-contribution.tsx +15 -2
  29. package/src/config/config.ts +12 -0
  30. package/src/guide/content-contribution.ts +50 -0
  31. package/src/guide/guide-view.tsx +77 -0
  32. package/src/guide/index.less +8 -0
  33. package/src/guide/index.ts +2 -0
  34. package/src/guide/libro_guide_book.json +333 -0
  35. package/src/guide/libro_guide_book_zh.json +331 -0
  36. package/src/lab-app.ts +10 -2
  37. package/src/module.tsx +4 -0
@@ -1,8 +1,10 @@
1
1
  import type { ConfigurationNode } from '@difizen/mana-app';
2
2
  export declare const LibroLabKernelAndTerminalPanelEnabled: ConfigurationNode<boolean>;
3
3
  export declare const LibroLabTocPanelEnabled: ConfigurationNode<boolean>;
4
+ export declare const LibroLabGuideViewEnabled: ConfigurationNode<boolean>;
4
5
  export declare const LibroLabConfiguration: {
5
6
  LibroLabKernelAndTerminalPanelEnabled: ConfigurationNode<boolean>;
6
7
  LibroLabTocPanelEnabled: ConfigurationNode<boolean>;
8
+ LibroLabGuideViewEnabled: ConfigurationNode<boolean>;
7
9
  };
8
10
  //# sourceMappingURL=config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAG3D,eAAO,MAAM,qCAAqC,EAAE,iBAAiB,CAAC,OAAO,CAS5E,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,iBAAiB,CAAC,OAAO,CAS9D,CAAC;AAEF,eAAO,MAAM,qBAAqB;;;CAGjC,CAAC"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAG3D,eAAO,MAAM,qCAAqC,EAAE,iBAAiB,CAAC,OAAO,CAS5E,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,iBAAiB,CAAC,OAAO,CAS9D,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,iBAAiB,CAAC,OAAO,CAS/D,CAAC;AAEF,eAAO,MAAM,qBAAqB;;;;CAIjC,CAAC"}
@@ -19,7 +19,18 @@ export var LibroLabTocPanelEnabled = {
19
19
  type: 'boolean'
20
20
  }
21
21
  };
22
+ export var LibroLabGuideViewEnabled = {
23
+ id: 'libro.lab.guide.view.enabled',
24
+ description: 'whether enable guide view ',
25
+ title: l10n.t('是否激活使用指南'),
26
+ type: 'checkbox',
27
+ defaultValue: false,
28
+ schema: {
29
+ type: 'boolean'
30
+ }
31
+ };
22
32
  export var LibroLabConfiguration = {
23
33
  LibroLabKernelAndTerminalPanelEnabled: LibroLabKernelAndTerminalPanelEnabled,
24
- LibroLabTocPanelEnabled: LibroLabTocPanelEnabled
34
+ LibroLabTocPanelEnabled: LibroLabTocPanelEnabled,
35
+ LibroLabGuideViewEnabled: LibroLabGuideViewEnabled
25
36
  };
@@ -0,0 +1,7 @@
1
+ import type { NotebookModel, NotebookOption } from '@difizen/libro-core';
2
+ import { ContentContribution } from '@difizen/libro-core';
3
+ export declare class LibroGuidebookContentContribution implements ContentContribution {
4
+ canHandle: (options: NotebookOption) => 50 | 1;
5
+ loadContent(options: NotebookOption, model: NotebookModel): Promise<any>;
6
+ }
7
+ //# sourceMappingURL=content-contribution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-contribution.d.ts","sourceRoot":"","sources":["../../src/guide/content-contribution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAa1D,qBACa,iCAAkC,YAAW,mBAAmB;IAC3E,SAAS,YAAa,cAAc,YAKlC;IACI,WAAW,CAAC,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,aAAa;CA2BhE"}
@@ -0,0 +1,74 @@
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, _class;
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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
7
+ 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); } }
8
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
9
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
10
+ 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); }
11
+ import { ContentContribution } from '@difizen/libro-core';
12
+ import { URI } from '@difizen/mana-app';
13
+ import { singleton } from '@difizen/mana-app';
14
+ import { l10n, L10nLang } from '@difizen/mana-l10n';
15
+ import contentJson from "./libro_guide_book.json";
16
+ import contentZhJson from "./libro_guide_book_zh.json";
17
+ export var LibroGuidebookContentContribution = (_dec = singleton({
18
+ contrib: ContentContribution
19
+ }), _dec(_class = /*#__PURE__*/function () {
20
+ function LibroGuidebookContentContribution() {
21
+ _classCallCheck(this, LibroGuidebookContentContribution);
22
+ this.canHandle = function (options) {
23
+ if (options['loadType'] === 'libro-guide-book') {
24
+ return 50;
25
+ }
26
+ return 1;
27
+ };
28
+ }
29
+ _createClass(LibroGuidebookContentContribution, [{
30
+ key: "loadContent",
31
+ value: function () {
32
+ var _loadContent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(options, model) {
33
+ var jupyterModel, fireUri, filePath, notebookContent, currentFileContents;
34
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
35
+ while (1) switch (_context.prev = _context.next) {
36
+ case 0:
37
+ jupyterModel = model;
38
+ fireUri = new URI(options['resource']);
39
+ filePath = fireUri.path.toString();
40
+ notebookContent = {
41
+ cells: [],
42
+ metadata: {},
43
+ nbformat: 4,
44
+ nbformat_minor: 5
45
+ };
46
+ notebookContent = l10n.getLang() === L10nLang.zhCN ? contentZhJson : contentJson;
47
+ currentFileContents = {
48
+ name: 'Guide book',
49
+ path: filePath,
50
+ type: 'notebook',
51
+ writable: true,
52
+ created: 'libro',
53
+ last_modified: 'libro',
54
+ content: notebookContent
55
+ };
56
+ currentFileContents.content.nbformat_minor = 5;
57
+ jupyterModel.currentFileContents = currentFileContents;
58
+ jupyterModel.filePath = currentFileContents.path;
59
+ jupyterModel.lastModified = jupyterModel.currentFileContents.last_modified;
60
+ return _context.abrupt("return", jupyterModel.currentFileContents.content);
61
+ case 11:
62
+ case "end":
63
+ return _context.stop();
64
+ }
65
+ }, _callee);
66
+ }));
67
+ function loadContent(_x, _x2) {
68
+ return _loadContent.apply(this, arguments);
69
+ }
70
+ return loadContent;
71
+ }()
72
+ }]);
73
+ return LibroGuidebookContentContribution;
74
+ }()) || _class);
@@ -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 { Deferred } from '@difizen/mana-app';
5
+ import { BaseView } from '@difizen/mana-app';
6
+ import './index.less';
7
+ export declare const GuideComponent: import("react").ForwardRefExoticComponent<import("react").RefAttributes<unknown>>;
8
+ export declare class GuideView extends BaseView {
9
+ view: import("react").ForwardRefExoticComponent<import("react").RefAttributes<unknown>>;
10
+ libroView?: LibroView;
11
+ filePath?: string;
12
+ protected libroService: LibroService;
13
+ protected defer: Deferred<void>;
14
+ get ready(): Promise<void>;
15
+ constructor();
16
+ onViewMount(): Promise<void>;
17
+ protected getOrCreateLibroView(): Promise<void>;
18
+ }
19
+ //# sourceMappingURL=guide-view.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guide-view.d.ts","sourceRoot":"","sources":["../../src/guide/guide-view.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EACL,QAAQ,EAQT,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAG7C,OAAO,cAAc,CAAC;AAItB,eAAO,MAAM,cAAc,mFAOzB,CAAC;AAEH,qBAEa,SAAU,SAAQ,QAAQ;IAC5B,IAAI,oFAAkB;IAG/B,SAAS,CAAC,EAAE,SAAS,CAAC;IAEd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAEJ,SAAS,CAAC,YAAY,EAAE,YAAY,CAAC;IAE3D,SAAS,CAAC,KAAK,iBAAwB;IAEvC,IAAI,KAAK,kBAER;;IAac,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;cAI3B,oBAAoB;CAerC"}
@@ -0,0 +1,141 @@
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 { LibroService } from '@difizen/libro-jupyter';
22
+ import { Deferred, inject, prop, singleton, useInject, view, ViewInstance, ViewRender } from '@difizen/mana-app';
23
+ import { BaseView } from '@difizen/mana-app';
24
+ import { l10n, L10nLang } from '@difizen/mana-l10n';
25
+ import { forwardRef } from 'react';
26
+ import "./index.less";
27
+ import { Logo } from "../common/icon.js";
28
+ import { jsx as _jsx } from "react/jsx-runtime";
29
+ export var GuideComponent = /*#__PURE__*/forwardRef(function WelcomeComponent() {
30
+ var instance = useInject(ViewInstance);
31
+ if (!instance.libroView) {
32
+ return null;
33
+ }
34
+ return /*#__PURE__*/_jsx(ViewRender, {
35
+ view: instance.libroView
36
+ }, instance.filePath);
37
+ });
38
+ export var GuideView = (_dec = singleton(), _dec2 = view('guide-view'), _dec3 = prop(), _dec4 = prop(), _dec5 = inject(LibroService), _dec(_class = _dec2(_class = (_class2 = /*#__PURE__*/function (_BaseView) {
39
+ _inherits(GuideView, _BaseView);
40
+ var _super = _createSuper(GuideView);
41
+ function GuideView() {
42
+ var _this;
43
+ _classCallCheck(this, GuideView);
44
+ _this = _super.call(this);
45
+ _this.view = GuideComponent;
46
+ _initializerDefineProperty(_this, "libroView", _descriptor, _assertThisInitialized(_this));
47
+ _initializerDefineProperty(_this, "filePath", _descriptor2, _assertThisInitialized(_this));
48
+ _initializerDefineProperty(_this, "libroService", _descriptor3, _assertThisInitialized(_this));
49
+ _this.defer = new Deferred();
50
+ _this.title.icon = /*#__PURE__*/_jsx(Logo, {});
51
+ _this.title.label = function () {
52
+ return /*#__PURE__*/_jsx("div", {
53
+ children: l10n.t('使用指南')
54
+ });
55
+ };
56
+ _this.title.closable = true;
57
+ _this.filePath = l10n.getLang() === L10nLang.zhCN ? 'libro_guide_book_zh.json' : 'libro_guide_book.json';
58
+ return _this;
59
+ }
60
+ _createClass(GuideView, [{
61
+ key: "ready",
62
+ get: function get() {
63
+ return this.defer.promise;
64
+ }
65
+ }, {
66
+ key: "onViewMount",
67
+ value: function () {
68
+ var _onViewMount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
69
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
70
+ while (1) switch (_context.prev = _context.next) {
71
+ case 0:
72
+ this.getOrCreateLibroView();
73
+ case 1:
74
+ case "end":
75
+ return _context.stop();
76
+ }
77
+ }, _callee, this);
78
+ }));
79
+ function onViewMount() {
80
+ return _onViewMount.apply(this, arguments);
81
+ }
82
+ return onViewMount;
83
+ }()
84
+ }, {
85
+ key: "getOrCreateLibroView",
86
+ value: function () {
87
+ var _getOrCreateLibroView = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
88
+ var libroView;
89
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
90
+ while (1) switch (_context2.prev = _context2.next) {
91
+ case 0:
92
+ _context2.next = 2;
93
+ return this.libroService.getOrCreateView({
94
+ id: this.filePath,
95
+ resource: this.filePath,
96
+ loadType: 'libro-guide-book'
97
+ });
98
+ case 2:
99
+ libroView = _context2.sent;
100
+ if (libroView) {
101
+ _context2.next = 5;
102
+ break;
103
+ }
104
+ return _context2.abrupt("return");
105
+ case 5:
106
+ this.libroView = libroView;
107
+ _context2.next = 8;
108
+ return this.libroView.initialized;
109
+ case 8:
110
+ this.libroView.model.savable = false;
111
+ this.libroView.focus();
112
+ this.defer.resolve();
113
+ case 11:
114
+ case "end":
115
+ return _context2.stop();
116
+ }
117
+ }, _callee2, this);
118
+ }));
119
+ function getOrCreateLibroView() {
120
+ return _getOrCreateLibroView.apply(this, arguments);
121
+ }
122
+ return getOrCreateLibroView;
123
+ }()
124
+ }]);
125
+ return GuideView;
126
+ }(BaseView), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "libroView", [_dec3], {
127
+ configurable: true,
128
+ enumerable: true,
129
+ writable: true,
130
+ initializer: null
131
+ }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "filePath", [_dec4], {
132
+ configurable: true,
133
+ enumerable: true,
134
+ writable: true,
135
+ initializer: null
136
+ }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "libroService", [_dec5], {
137
+ configurable: true,
138
+ enumerable: true,
139
+ writable: true,
140
+ initializer: null
141
+ })), _class2)) || _class) || _class);
@@ -0,0 +1,3 @@
1
+ export * from './content-contribution.js';
2
+ export * from './guide-view.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/guide/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./content-contribution.js";
2
+ export * from "./guide-view.js";
@@ -0,0 +1,8 @@
1
+ .libro-lab-content-layout-main {
2
+ .mana-tab-icon {
3
+ svg {
4
+ display: inline-block;
5
+ width: 14px;
6
+ }
7
+ }
8
+ }