@difizen/libro-jupyter 0.1.32 → 0.1.34

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 (114) hide show
  1. package/es/cell/jupyter-code-cell-view.d.ts +3 -1
  2. package/es/cell/jupyter-code-cell-view.d.ts.map +1 -1
  3. package/es/cell/jupyter-code-cell-view.js +9 -0
  4. package/es/components/icons.js +1 -1
  5. package/es/index.d.ts +1 -0
  6. package/es/index.d.ts.map +1 -1
  7. package/es/index.js +2 -1
  8. package/es/keybind-instructions/index.less +0 -5
  9. package/es/keybind-instructions/keybind-instructions-view.d.ts.map +1 -1
  10. package/es/keybind-instructions/keybind-instructions-view.js +67 -61
  11. package/es/module.d.ts.map +1 -1
  12. package/es/module.js +2 -3
  13. package/es/output/libro-jupyter-outputarea.d.ts.map +1 -1
  14. package/es/output/libro-jupyter-outputarea.js +60 -56
  15. package/es/toolbar/save-file-error.d.ts.map +1 -1
  16. package/es/toolbar/save-file-error.js +20 -13
  17. package/es/widget/box/contribution.d.ts +10 -0
  18. package/es/widget/box/contribution.d.ts.map +1 -0
  19. package/es/widget/box/contribution.js +48 -0
  20. package/es/widget/box/index.d.ts +3 -0
  21. package/es/widget/box/index.d.ts.map +1 -0
  22. package/es/widget/box/index.js +2 -0
  23. package/es/widget/box/index.less +3 -0
  24. package/es/widget/box/view.d.ts +19 -0
  25. package/es/widget/box/view.d.ts.map +1 -0
  26. package/es/widget/box/view.js +114 -0
  27. package/es/widget/comm.d.ts +65 -0
  28. package/es/widget/comm.d.ts.map +1 -0
  29. package/es/widget/comm.js +153 -0
  30. package/es/widget/index.d.ts +7 -0
  31. package/es/widget/index.d.ts.map +1 -1
  32. package/es/widget/index.js +8 -1
  33. package/es/widget/instance-progress/contribution.d.ts +10 -0
  34. package/es/widget/instance-progress/contribution.d.ts.map +1 -0
  35. package/es/widget/instance-progress/contribution.js +39 -0
  36. package/es/widget/instance-progress/index.d.ts +3 -0
  37. package/es/widget/instance-progress/index.d.ts.map +1 -0
  38. package/es/widget/instance-progress/index.js +2 -0
  39. package/es/widget/instance-progress/view.d.ts +30 -0
  40. package/es/widget/instance-progress/view.d.ts.map +1 -0
  41. package/es/widget/instance-progress/view.js +180 -0
  42. package/es/widget/libro-widgets.d.ts +84 -0
  43. package/es/widget/libro-widgets.d.ts.map +1 -0
  44. package/es/widget/libro-widgets.js +307 -0
  45. package/es/widget/module.d.ts +4 -0
  46. package/es/widget/module.d.ts.map +1 -0
  47. package/es/widget/module.js +38 -0
  48. package/es/widget/progress/contribution.d.ts +10 -0
  49. package/es/widget/progress/contribution.d.ts.map +1 -0
  50. package/es/widget/progress/contribution.js +39 -0
  51. package/es/widget/progress/index.d.ts +3 -0
  52. package/es/widget/progress/index.d.ts.map +1 -0
  53. package/es/widget/progress/index.js +2 -0
  54. package/es/widget/progress/progressBar.d.ts +15 -0
  55. package/es/widget/progress/progressBar.d.ts.map +1 -0
  56. package/es/widget/progress/progressBar.js +20 -0
  57. package/es/widget/progress/view.d.ts +19 -0
  58. package/es/widget/progress/view.d.ts.map +1 -0
  59. package/es/widget/progress/view.js +74 -0
  60. package/es/widget/protocol.d.ts +193 -0
  61. package/es/widget/protocol.d.ts.map +1 -0
  62. package/es/widget/protocol.js +33 -0
  63. package/es/widget/utils.d.ts +27 -0
  64. package/es/widget/utils.d.ts.map +1 -0
  65. package/es/widget/utils.js +59 -0
  66. package/es/widget/version.d.ts +3 -0
  67. package/es/widget/version.d.ts.map +1 -0
  68. package/es/widget/version.js +2 -0
  69. package/es/widget/widget-manager.d.ts +19 -0
  70. package/es/widget/widget-manager.d.ts.map +1 -0
  71. package/es/widget/widget-manager.js +77 -0
  72. package/es/widget/widget-render.d.ts.map +1 -1
  73. package/es/widget/widget-render.js +7 -3
  74. package/es/widget/widget-rendermime-contribution.d.ts +2 -1
  75. package/es/widget/widget-rendermime-contribution.d.ts.map +1 -1
  76. package/es/widget/widget-rendermime-contribution.js +2 -1
  77. package/es/widget/widget-view-contribution.d.ts +10 -0
  78. package/es/widget/widget-view-contribution.d.ts.map +1 -0
  79. package/es/widget/widget-view-contribution.js +36 -0
  80. package/es/widget/widget-view.d.ts +71 -0
  81. package/es/widget/widget-view.d.ts.map +1 -0
  82. package/es/widget/widget-view.js +273 -0
  83. package/package.json +17 -18
  84. package/src/cell/jupyter-code-cell-view.tsx +10 -1
  85. package/src/components/icons.tsx +1 -1
  86. package/src/index.ts +1 -0
  87. package/src/keybind-instructions/index.less +0 -5
  88. package/src/keybind-instructions/keybind-instructions-view.tsx +70 -60
  89. package/src/module.ts +1 -3
  90. package/src/output/libro-jupyter-outputarea.tsx +56 -49
  91. package/src/toolbar/save-file-error.tsx +25 -15
  92. package/src/widget/box/contribution.ts +29 -0
  93. package/src/widget/box/index.less +3 -0
  94. package/src/widget/box/index.ts +2 -0
  95. package/src/widget/box/view.tsx +112 -0
  96. package/src/widget/comm.ts +152 -0
  97. package/src/widget/index.ts +7 -0
  98. package/src/widget/instance-progress/contribution.ts +20 -0
  99. package/src/widget/instance-progress/index.ts +2 -0
  100. package/src/widget/instance-progress/view.tsx +155 -0
  101. package/src/widget/libro-widgets.ts +223 -0
  102. package/src/widget/module.ts +73 -0
  103. package/src/widget/progress/contribution.ts +24 -0
  104. package/src/widget/progress/index.ts +2 -0
  105. package/src/widget/progress/progressBar.tsx +29 -0
  106. package/src/widget/progress/view.tsx +70 -0
  107. package/src/widget/protocol.ts +255 -0
  108. package/src/widget/utils.ts +67 -0
  109. package/src/widget/version.ts +2 -0
  110. package/src/widget/widget-manager.ts +45 -0
  111. package/src/widget/widget-render.tsx +10 -5
  112. package/src/widget/widget-rendermime-contribution.ts +2 -1
  113. package/src/widget/widget-view-contribution.ts +14 -0
  114. package/src/widget/widget-view.tsx +259 -0
@@ -1 +1 @@
1
- {"version":3,"file":"widget-render.d.ts","sourceRoot":"","sources":["../../src/widget/widget-render.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAK1D,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,cAAc,CAAC;AAItB,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,KAAK,EAAE,cAAc,CAAA;CAAE,CAoC5D,CAAC"}
1
+ {"version":3,"file":"widget-render.d.ts","sourceRoot":"","sources":["../../src/widget/widget-render.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAmB,MAAM,qBAAqB,CAAC;AAI3E,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,cAAc,CAAC;AAKtB,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,KAAK,EAAE,cAAc,CAAA;CAAE,CAwC5D,CAAC"}
@@ -1,12 +1,15 @@
1
1
  import { RenderMimeRegistry } from '@difizen/libro-rendermime';
2
- import { LibroWidgetManager } from '@difizen/libro-widget';
3
- import { getOrigin, useInject, ViewRender } from '@difizen/mana-app';
2
+ import { getOrigin, useInject, ViewInstance, ViewRender } from '@difizen/mana-app';
4
3
  import React from 'react';
5
4
  import "./index.less";
6
5
  import { LibroJupyterModel } from "../libro-jupyter-model.js";
6
+ import { LibroWidgetManager } from "./widget-manager.js";
7
7
  import { jsx as _jsx } from "react/jsx-runtime";
8
8
  export var WidgetRender = function WidgetRender(props) {
9
9
  var model = props.model;
10
+
11
+ // The widget will be rendered in the output through the MIME mechanism, obtaining the output context.
12
+ var output = useInject(ViewInstance);
10
13
  var widgetManager = useInject(LibroWidgetManager);
11
14
  var defaultRenderMime = useInject(RenderMimeRegistry);
12
15
  var libro = model.cell.parent;
@@ -19,6 +22,7 @@ export var WidgetRender = function WidgetRender(props) {
19
22
  var model_id = JSON.parse(JSON.stringify(model.data[mimeType])).model_id;
20
23
  if (model_id) {
21
24
  var widgetView = widgets.getModel(model_id);
25
+ widgetView.setCell(getOrigin(output.cell));
22
26
  if (widgetView.isCommClosed) {
23
27
  return null;
24
28
  }
@@ -36,7 +40,7 @@ export var WidgetRender = function WidgetRender(props) {
36
40
  return /*#__PURE__*/_jsx("div", {
37
41
  className: "libro-widget-render-container",
38
42
  children: /*#__PURE__*/_jsx("div", {
39
- className: "libro-widget-render"
43
+ className: "libro-widget-render empty"
40
44
  })
41
45
  });
42
46
  };
@@ -1,13 +1,14 @@
1
1
  /// <reference types="react" resolution-mode="require"/>
2
2
  import type { BaseOutputView } from '@difizen/libro-core';
3
3
  import { RenderMimeContribution } from '@difizen/libro-rendermime';
4
- import { LibroWidgetManager } from '@difizen/libro-widget';
4
+ import { LibroWidgetManager } from './widget-manager.js';
5
5
  export declare class LibroWidgetMimeContribution implements RenderMimeContribution {
6
6
  libroWidgetManager: LibroWidgetManager;
7
7
  canHandle: (model: BaseOutputView) => number;
8
8
  renderType: string;
9
9
  safe: boolean;
10
10
  mimeTypes: string[];
11
+ allowClear: boolean;
11
12
  render: import("react").FC<{
12
13
  model: BaseOutputView;
13
14
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"widget-rendermime-contribution.d.ts","sourceRoot":"","sources":["../../src/widget/widget-rendermime-contribution.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAO3D,qBACa,2BAA4B,YAAW,sBAAsB;IAC5C,kBAAkB,EAAE,kBAAkB,CAAC;IACnE,SAAS,UAAW,cAAc,YAiBhC;IACF,UAAU,SAAoB;IAC9B,IAAI,UAAQ;IACZ,SAAS,WAAgD;IACzD,MAAM;;OAAgB;CACvB"}
1
+ {"version":3,"file":"widget-rendermime-contribution.d.ts","sourceRoot":"","sources":["../../src/widget/widget-rendermime-contribution.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAKnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAGzD,qBACa,2BAA4B,YAAW,sBAAsB;IAC5C,kBAAkB,EAAE,kBAAkB,CAAC;IACnE,SAAS,UAAW,cAAc,YAiBhC;IACF,UAAU,SAAoB;IAC9B,IAAI,UAAQ;IACZ,SAAS,WAAgD;IACzD,UAAU,UAAS;IACnB,MAAM;;OAAgB;CACvB"}
@@ -9,9 +9,9 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
9
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
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
11
  import { RenderMimeContribution } from '@difizen/libro-rendermime';
12
- import { LibroWidgetManager } from '@difizen/libro-widget';
13
12
  import { inject, singleton } from '@difizen/mana-app';
14
13
  import { LibroJupyterModel } from "../libro-jupyter-model.js";
14
+ import { LibroWidgetManager } from "./widget-manager.js";
15
15
  import { WidgetRender } from "./widget-render.js";
16
16
  export var LibroWidgetMimeContribution = (_dec = singleton({
17
17
  contrib: RenderMimeContribution
@@ -40,6 +40,7 @@ export var LibroWidgetMimeContribution = (_dec = singleton({
40
40
  this.renderType = 'widgetRenderer';
41
41
  this.safe = true;
42
42
  this.mimeTypes = ['application/vnd.jupyter.widget-view+json'];
43
+ this.allowClear = false;
43
44
  this.render = WidgetRender;
44
45
  }), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "libroWidgetManager", [_dec2], {
45
46
  configurable: true,
@@ -0,0 +1,10 @@
1
+ import { ViewManager } from '@difizen/mana-app';
2
+ import type { IWidgetViewProps } from './protocol.js';
3
+ import { WidgetViewContribution } from './protocol.js';
4
+ import { WidgetView } from './widget-view.js';
5
+ export declare class DefaultWidgetViewContribution implements WidgetViewContribution {
6
+ viewManager: ViewManager;
7
+ canHandle: () => number;
8
+ factory(props: IWidgetViewProps): Promise<WidgetView>;
9
+ }
10
+ //# sourceMappingURL=widget-view-contribution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"widget-view-contribution.d.ts","sourceRoot":"","sources":["../../src/widget/widget-view-contribution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAqB,MAAM,mBAAmB,CAAC;AAEnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,qBACa,6BAA8B,YAAW,sBAAsB;IACrD,WAAW,EAAE,WAAW,CAAC;IAC9C,SAAS,eAAW;IACpB,OAAO,CAAC,KAAK,EAAE,gBAAgB;CAGhC"}
@@ -0,0 +1,36 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ var _dec, _dec2, _class, _class2, _descriptor;
3
+ function _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 { ViewManager, inject, singleton } from '@difizen/mana-app';
12
+ import { WidgetViewContribution } from "./protocol.js";
13
+ import { WidgetView } from "./widget-view.js";
14
+ export var DefaultWidgetViewContribution = (_dec = singleton({
15
+ contrib: WidgetViewContribution
16
+ }), _dec2 = inject(ViewManager), _dec(_class = (_class2 = /*#__PURE__*/function () {
17
+ function DefaultWidgetViewContribution() {
18
+ _classCallCheck(this, DefaultWidgetViewContribution);
19
+ _initializerDefineProperty(this, "viewManager", _descriptor, this);
20
+ this.canHandle = function () {
21
+ return 1;
22
+ };
23
+ }
24
+ _createClass(DefaultWidgetViewContribution, [{
25
+ key: "factory",
26
+ value: function factory(props) {
27
+ return this.viewManager.getOrCreateView(WidgetView, props);
28
+ }
29
+ }]);
30
+ return DefaultWidgetViewContribution;
31
+ }(), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "viewManager", [_dec2], {
32
+ configurable: true,
33
+ enumerable: true,
34
+ writable: true,
35
+ initializer: null
36
+ })), _class2)) || _class);
@@ -0,0 +1,71 @@
1
+ /// <reference types="react" resolution-mode="require"/>
2
+ import type { JSONObject, JSONValue } from '@difizen/libro-common';
3
+ import type { CellView, LibroExecutableCellView } from '@difizen/libro-core';
4
+ import { LibroContextKey } from '@difizen/libro-core';
5
+ import type { KernelMessage } from '@difizen/libro-kernel';
6
+ import { BaseView } from '@difizen/mana-app';
7
+ import type { ViewComponent, Disposable } from '@difizen/mana-app';
8
+ import type { Dict, IWidgets, IWidgetView, IClassicComm, ICallbacks, IWidgetViewProps, WidgetState } from './protocol.js';
9
+ import { LibroWidgetManager } from './widget-manager.js';
10
+ export declare const LibroWidgetComponent: import("react").ForwardRefExoticComponent<import("react").RefAttributes<HTMLDivElement>>;
11
+ export declare class WidgetView extends BaseView implements IWidgetView {
12
+ view: ViewComponent;
13
+ libroContextKey: LibroContextKey;
14
+ widgetsId: string;
15
+ protected _msgHook: (msg: KernelMessage.IIOPubMessage) => boolean;
16
+ libroWidgetManager: LibroWidgetManager;
17
+ state: JSONObject & WidgetState;
18
+ cell?: LibroExecutableCellView;
19
+ get outputs(): import("@difizen/libro-core").BaseOutputArea | undefined;
20
+ disableCommandMode: boolean;
21
+ toDisposeOnMsgChanged?: Disposable;
22
+ constructor(props: IWidgetViewProps, libroContextKey: LibroContextKey);
23
+ setCell(cell: CellView): void;
24
+ /**
25
+ * Register a new kernel
26
+ */
27
+ handleKernelChanged: () => void;
28
+ /**
29
+ * Reset the message id.
30
+ */
31
+ resetMsgId(): void;
32
+ addFromMessage(msg: KernelMessage.IIOPubMessage): void;
33
+ clearOutput(wait?: boolean): void;
34
+ onViewMount(): void;
35
+ /**
36
+ * Handle incoming comm msg.
37
+ */
38
+ handleCommMsg(msg: KernelMessage.ICommMsgMsg): Promise<void>;
39
+ handleCommClosed: () => void;
40
+ /**
41
+ * Handle when a widget is updated from the backend.
42
+ *
43
+ * This function is meant for internal use only. Values set here will not be propagated on a sync.
44
+ */
45
+ setState(state: Dict<any>): void;
46
+ /**
47
+ * Serialize the model. See the deserialization function at the top of this file
48
+ * and the kernel-side serializer/deserializer.
49
+ */
50
+ toJSON(): string;
51
+ toModelKey(): string;
52
+ /**
53
+ * Send a custom msg over the comm.
54
+ */
55
+ send: (data: JSONValue, callbacks?: ICallbacks, buffers?: ArrayBuffer[] | ArrayBufferView[]) => string | undefined;
56
+ comm: IClassicComm;
57
+ widgets?: IWidgets;
58
+ model_id: string;
59
+ state_change: Promise<any>;
60
+ name: string;
61
+ module: string;
62
+ isCommClosed: boolean;
63
+ model_module: string;
64
+ model_name: string;
65
+ model_module_version: string;
66
+ view_module: string;
67
+ view_name: string | null;
68
+ view_module_version: string;
69
+ view_count: number | null;
70
+ }
71
+ //# sourceMappingURL=widget-view.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"widget-view.d.ts","sourceRoot":"","sources":["../../src/widget/widget-view.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAuB,MAAM,uBAAuB,CAAC;AACxF,OAAO,KAAK,EAAE,QAAQ,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAE7E,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAKL,QAAQ,EAGT,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAMnE,OAAO,KAAK,EACV,IAAI,EACJ,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,UAAU,EACV,gBAAgB,EAChB,WAAW,EACZ,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD,eAAO,MAAM,oBAAoB,0FAIhC,CAAC;AAEF,qBAEa,UAAW,SAAQ,QAAS,YAAW,WAAW;IACpD,IAAI,EAAE,aAAa,CAAwB;IACpD,eAAe,EAAE,eAAe,CAAC;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,aAAa,CAAC,aAAa,KAAK,OAAO,CAAC;IAEtC,kBAAkB,EAAE,kBAAkB,CAAC;IAGnE,KAAK,EAAE,UAAU,GAAG,WAAW,CAAsB;IAErD,IAAI,CAAC,EAAE,uBAAuB,CAAC;IAE/B,IAAI,OAAO,6DAKV;IAED,kBAAkB,UAAQ;IAE1B,qBAAqB,CAAC,EAAE,UAAU,CAAC;gBAGb,KAAK,EAAE,gBAAgB,EAClB,eAAe,EAAE,eAAe;IAqC3D,OAAO,CAAC,IAAI,EAAE,QAAQ;IAiBtB;;OAEG;IACH,mBAAmB,QAAO,IAAI,CAE5B;IAEF;;OAEG;IACH,UAAU,IAAI,IAAI;IAelB,cAAc,CAAC,GAAG,EAAE,aAAa,CAAC,aAAa;IAoB/C,WAAW,CAAC,IAAI,UAAQ,GAAG,IAAI;IAItB,WAAW;IAiBpB;;OAEG;IACH,aAAa,CAAC,GAAG,EAAE,aAAa,CAAC,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAW5D,gBAAgB,aAEd;IACF;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI;IAUhC;;;OAGG;IACH,MAAM,IAAI,MAAM;IAIhB,UAAU,IAAI,MAAM;IAIpB;;OAEG;IACH,IAAI,SACI,SAAS,cACH,UAAU,YACZ,WAAW,EAAE,GAAG,eAAe,EAAE,wBAM3C;IAEF,IAAI,EAAE,YAAY,CAAC;IACX,OAAO,CAAC,EAAE,QAAQ,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,UAAS;IAErB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B"}
@@ -0,0 +1,273 @@
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 _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 _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); }
10
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
11
+ 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); }; }
12
+ 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); }
13
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
14
+ 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; } }
15
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
16
+ 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; }
17
+ 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.'); }
18
+ import { ExecutableCellView } from '@difizen/libro-core';
19
+ import { LibroContextKey } from '@difizen/libro-core';
20
+ import { inject, transient, ViewOption, view, BaseView, prop, watch } from '@difizen/mana-app';
21
+ import { forwardRef } from 'react';
22
+ import { LibroJupyterModel } from "../libro-jupyter-model.js";
23
+ import { defaultWidgetState } from "./protocol.js";
24
+ import { LibroWidgetManager } from "./widget-manager.js";
25
+ import { Fragment as _Fragment } from "react/jsx-runtime";
26
+ import { jsx as _jsx } from "react/jsx-runtime";
27
+ export var LibroWidgetComponent = /*#__PURE__*/forwardRef(function LibroWidgetComponent() {
28
+ return /*#__PURE__*/_jsx(_Fragment, {});
29
+ });
30
+ export var WidgetView = (_dec = transient(), _dec2 = view('libro-widget-view'), _dec3 = inject(LibroWidgetManager), _dec4 = prop(), _dec5 = prop(), _dec(_class = _dec2(_class = (_class2 = /*#__PURE__*/function (_BaseView) {
31
+ _inherits(WidgetView, _BaseView);
32
+ var _super = _createSuper(WidgetView);
33
+ function WidgetView(props, libroContextKey) {
34
+ var _this;
35
+ _classCallCheck(this, WidgetView);
36
+ _this = _super.call(this);
37
+ _this.view = LibroWidgetComponent;
38
+ _this.libroContextKey = void 0;
39
+ _this.widgetsId = void 0;
40
+ _this._msgHook = void 0;
41
+ _initializerDefineProperty(_this, "libroWidgetManager", _descriptor, _assertThisInitialized(_this));
42
+ _initializerDefineProperty(_this, "state", _descriptor2, _assertThisInitialized(_this));
43
+ _this.cell = void 0;
44
+ _this.disableCommandMode = true;
45
+ _this.toDisposeOnMsgChanged = void 0;
46
+ /**
47
+ * Register a new kernel
48
+ */
49
+ _this.handleKernelChanged = function () {
50
+ _this.setState({
51
+ msg_id: undefined
52
+ });
53
+ };
54
+ _this.handleCommClosed = function () {
55
+ _this.isCommClosed = true;
56
+ };
57
+ /**
58
+ * Send a custom msg over the comm.
59
+ */
60
+ _this.send = function (data, callbacks, buffers) {
61
+ if (_this.comm !== undefined) {
62
+ return _this.comm.send(data, callbacks, {}, buffers);
63
+ }
64
+ return undefined;
65
+ };
66
+ _this.comm = void 0;
67
+ _initializerDefineProperty(_this, "widgets", _descriptor3, _assertThisInitialized(_this));
68
+ _this.model_id = void 0;
69
+ _this.state_change = void 0;
70
+ _this.name = void 0;
71
+ _this.module = void 0;
72
+ _this.isCommClosed = false;
73
+ _this.model_module = void 0;
74
+ _this.model_name = void 0;
75
+ _this.model_module_version = void 0;
76
+ _this.view_module = void 0;
77
+ _this.view_name = void 0;
78
+ _this.view_module_version = void 0;
79
+ _this.view_count = void 0;
80
+ _this.widgetsId = props.widgetsId;
81
+ var attributes = props.attributes;
82
+ _this.model_module = attributes._model_module;
83
+ _this.model_name = attributes._model_name;
84
+ _this.model_module_version = attributes._model_module_version;
85
+ _this.view_module = attributes._view_module;
86
+ _this.view_name = attributes._view_name;
87
+ _this.view_module_version = attributes._view_module_version;
88
+ _this.view_count = attributes._view_count;
89
+ _this._msgHook = function (msg) {
90
+ _this.addFromMessage(msg);
91
+ return false;
92
+ };
93
+
94
+ // Attributes should be initialized here, since user initialization may depend on it
95
+ var comm = props.options.comm;
96
+ if (comm) {
97
+ // Remember comm associated with the model.
98
+ _this.comm = comm;
99
+
100
+ // Hook comm messages up to model.
101
+ comm.onClose(_this.handleCommClosed.bind(_assertThisInitialized(_this)));
102
+ comm.onMsg(_this.handleCommMsg.bind(_assertThisInitialized(_this)));
103
+ } else {
104
+ _this.isCommClosed = false;
105
+ }
106
+ _this.model_id = props.options.model_id;
107
+ _this.state_change = Promise.resolve();
108
+ _this.setState(attributes);
109
+ _this.libroContextKey = libroContextKey;
110
+ return _this;
111
+ }
112
+ WidgetView = inject(LibroContextKey)(WidgetView, undefined, 1) || WidgetView;
113
+ WidgetView = inject(ViewOption)(WidgetView, undefined, 0) || WidgetView;
114
+ _createClass(WidgetView, [{
115
+ key: "outputs",
116
+ get: function get() {
117
+ if (this.cell) {
118
+ return this.cell.outputArea;
119
+ }
120
+ return undefined;
121
+ }
122
+ }, {
123
+ key: "setCell",
124
+ value: function setCell(cell) {
125
+ var _this2 = this;
126
+ if (ExecutableCellView.is(cell)) {
127
+ this.cell = cell;
128
+ if (this.cell) {
129
+ this.cell.parentReady.then(function () {
130
+ var _this2$cell;
131
+ var notebookModel = (_this2$cell = _this2.cell) === null || _this2$cell === void 0 ? void 0 : _this2$cell.parent.model;
132
+ if (notebookModel instanceof LibroJupyterModel) {
133
+ watch(notebookModel, 'kernelConnection', _this2.handleKernelChanged);
134
+ }
135
+ return;
136
+ }).catch(console.error);
137
+ }
138
+ }
139
+ }
140
+ }, {
141
+ key: "resetMsgId",
142
+ value:
143
+ /**
144
+ * Reset the message id.
145
+ */
146
+ function resetMsgId() {
147
+ var _this$toDisposeOnMsgC, _this$cell;
148
+ (_this$toDisposeOnMsgC = this.toDisposeOnMsgChanged) === null || _this$toDisposeOnMsgC === void 0 || _this$toDisposeOnMsgC.dispose();
149
+ var notebookModel = (_this$cell = this.cell) === null || _this$cell === void 0 || (_this$cell = _this$cell.parent) === null || _this$cell === void 0 ? void 0 : _this$cell.model;
150
+ if (notebookModel instanceof LibroJupyterModel) {
151
+ var kernel = notebookModel.kernelConnection;
152
+ if (kernel && this.state['msg_id']) {
153
+ this.toDisposeOnMsgChanged = kernel.registerMessageHook(this.state['msg_id'], this._msgHook);
154
+ }
155
+ }
156
+ }
157
+ }, {
158
+ key: "addFromMessage",
159
+ value: function addFromMessage(msg) {
160
+ var msgType = msg.header.msg_type;
161
+ switch (msgType) {
162
+ case 'execute_result':
163
+ case 'display_data':
164
+ case 'stream':
165
+ case 'error':
166
+ {
167
+ var _this$outputs;
168
+ var model = msg.content;
169
+ model.output_type = msgType;
170
+ (_this$outputs = this.outputs) === null || _this$outputs === void 0 || _this$outputs.add(model);
171
+ break;
172
+ }
173
+ case 'clear_output':
174
+ this.clearOutput(msg.content.wait);
175
+ break;
176
+ default:
177
+ break;
178
+ }
179
+ }
180
+ }, {
181
+ key: "clearOutput",
182
+ value: function clearOutput() {
183
+ var _this$outputs2;
184
+ var wait = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
185
+ (_this$outputs2 = this.outputs) === null || _this$outputs2 === void 0 || _this$outputs2.clear(wait);
186
+ }
187
+ }, {
188
+ key: "onViewMount",
189
+ value: function onViewMount() {
190
+ var _this3 = this;
191
+ this.widgets = this.libroWidgetManager.getWidgets(this.widgetsId);
192
+ if (this.container && this.container.current && this.disableCommandMode) {
193
+ this.container.current.addEventListener('focusin', function () {
194
+ _this3.libroContextKey.disableCommandMode();
195
+ });
196
+ this.container.current.addEventListener('blur', function (e) {
197
+ var _this3$container;
198
+ if ((_this3$container = _this3.container) !== null && _this3$container !== void 0 && (_this3$container = _this3$container.current) !== null && _this3$container !== void 0 && _this3$container.contains(e.relatedTarget)) {
199
+ _this3.libroContextKey.disableCommandMode();
200
+ } else {
201
+ _this3.libroContextKey.enableCommandMode();
202
+ }
203
+ });
204
+ }
205
+ }
206
+
207
+ /**
208
+ * Handle incoming comm msg.
209
+ */
210
+ }, {
211
+ key: "handleCommMsg",
212
+ value: function handleCommMsg(msg) {
213
+ var data = msg.content.data;
214
+ var method = data.method;
215
+ switch (method) {
216
+ case 'update':
217
+ case 'echo_update':
218
+ this.setState(data.state);
219
+ }
220
+ return Promise.resolve();
221
+ }
222
+ }, {
223
+ key: "setState",
224
+ value:
225
+ /**
226
+ * Handle when a widget is updated from the backend.
227
+ *
228
+ * This function is meant for internal use only. Values set here will not be propagated on a sync.
229
+ */
230
+ function setState(state) {
231
+ for (var key in state) {
232
+ var oldMsgId = this.state['msg_id'];
233
+ this.state[key] = state[key];
234
+ if (key === 'msg_id' && oldMsgId !== state['msg_id']) {
235
+ this.resetMsgId();
236
+ }
237
+ }
238
+ }
239
+
240
+ /**
241
+ * Serialize the model. See the deserialization function at the top of this file
242
+ * and the kernel-side serializer/deserializer.
243
+ */
244
+ }, {
245
+ key: "toJSON",
246
+ value: function toJSON() {
247
+ return this.toModelKey();
248
+ }
249
+ }, {
250
+ key: "toModelKey",
251
+ value: function toModelKey() {
252
+ return "IPY_MODEL_".concat(this.model_id);
253
+ }
254
+ }]);
255
+ return WidgetView;
256
+ }(BaseView), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "libroWidgetManager", [_dec3], {
257
+ configurable: true,
258
+ enumerable: true,
259
+ writable: true,
260
+ initializer: null
261
+ }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "state", [_dec4], {
262
+ configurable: true,
263
+ enumerable: true,
264
+ writable: true,
265
+ initializer: function initializer() {
266
+ return defaultWidgetState;
267
+ }
268
+ }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "widgets", [_dec5], {
269
+ configurable: true,
270
+ enumerable: true,
271
+ writable: true,
272
+ initializer: null
273
+ })), _class2)) || _class) || _class);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@difizen/libro-jupyter",
3
- "version": "0.1.32",
3
+ "version": "0.1.34",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "libro"
@@ -31,23 +31,22 @@
31
31
  "src"
32
32
  ],
33
33
  "dependencies": {
34
- "@difizen/libro-cofine-editor": "^0.1.32",
35
- "@difizen/libro-code-editor": "^0.1.32",
36
- "@difizen/libro-code-cell": "^0.1.32",
37
- "@difizen/libro-codemirror": "^0.1.32",
38
- "@difizen/libro-rendermime": "^0.1.32",
39
- "@difizen/libro-common": "^0.1.32",
40
- "@difizen/libro-core": "^0.1.32",
41
- "@difizen/libro-kernel": "^0.1.32",
42
- "@difizen/libro-l10n": "^0.1.32",
43
- "@difizen/libro-output": "^0.1.32",
44
- "@difizen/libro-search": "^0.1.32",
45
- "@difizen/libro-search-code-cell": "^0.1.32",
46
- "@difizen/libro-lsp": "^0.1.32",
47
- "@difizen/libro-markdown-cell": "^0.1.32",
48
- "@difizen/libro-raw-cell": "^0.1.32",
49
- "@difizen/libro-language-client": "^0.1.32",
50
- "@difizen/libro-widget": "^0.1.32",
34
+ "@difizen/libro-cofine-editor": "^0.1.34",
35
+ "@difizen/libro-code-editor": "^0.1.34",
36
+ "@difizen/libro-code-cell": "^0.1.34",
37
+ "@difizen/libro-codemirror": "^0.1.34",
38
+ "@difizen/libro-rendermime": "^0.1.34",
39
+ "@difizen/libro-common": "^0.1.34",
40
+ "@difizen/libro-core": "^0.1.34",
41
+ "@difizen/libro-kernel": "^0.1.34",
42
+ "@difizen/libro-l10n": "^0.1.34",
43
+ "@difizen/libro-output": "^0.1.34",
44
+ "@difizen/libro-search": "^0.1.34",
45
+ "@difizen/libro-search-code-cell": "^0.1.34",
46
+ "@difizen/libro-lsp": "^0.1.34",
47
+ "@difizen/libro-markdown-cell": "^0.1.34",
48
+ "@difizen/libro-raw-cell": "^0.1.34",
49
+ "@difizen/libro-language-client": "^0.1.34",
51
50
  "@difizen/mana-app": "latest",
52
51
  "@difizen/mana-l10n": "latest",
53
52
  "@ant-design/colors": "^7.0.0",
@@ -39,7 +39,16 @@ const JupyterCodeCellComponent = forwardRef<HTMLDivElement>(
39
39
  @transient()
40
40
  @view('jupyter-code-cell-view')
41
41
  export class JupyterCodeCellView extends LibroCodeCellView {
42
- declare parent: LibroJupyterView;
42
+ protected declare _parent: LibroJupyterView;
43
+
44
+ override get parent() {
45
+ return this._parent;
46
+ }
47
+ override set parent(value: LibroJupyterView) {
48
+ this._parent = value;
49
+ this.parentDefer.resolve(this.parent);
50
+ }
51
+
43
52
  override view = JupyterCodeCellComponent;
44
53
  declare model: JupyterCodeCellModel;
45
54
 
@@ -100,7 +100,7 @@ export const Location: React.FC = () => (
100
100
  <g
101
101
  id="2.0-kernel-启动前"
102
102
  transform="translate(-738.000000, -80.000000)"
103
- fill="#7B7B7B"
103
+ fill="currentColor"
104
104
  // fillRule="nonzero"
105
105
  >
106
106
  <g id="编组-24" transform="translate(637.000000, 80.000000)">
package/src/index.ts CHANGED
@@ -32,3 +32,4 @@ export * from './toolbar/index.js';
32
32
  export * from './file/index.js';
33
33
  export * from './libro-jupyter-view.js';
34
34
  export * from './config/index.js';
35
+ export * from './widget/index.js';
@@ -42,11 +42,6 @@
42
42
  .@{ant-prefix}-segmented-item-label {
43
43
  color: var(--mana-libro-drawer-title-color);
44
44
  }
45
- .@{ant-prefix}-segmented-item-selected {
46
- .@{ant-prefix}-segmented-item-label {
47
- color: rgba(0, 10, 26, 89%);
48
- }
49
- }
50
45
  .@{ant-prefix}-drawer-mask {
51
46
  opacity: 0;
52
47
  }