@difizen/libro-output 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/display-data-output/display-data-output-model.d.ts +5 -0
- package/es/display-data-output/display-data-output-model.d.ts.map +1 -1
- package/es/display-data-output/display-data-output-model.js +37 -7
- package/es/stream-output/stream-output-model.d.ts +4 -0
- package/es/stream-output/stream-output-model.d.ts.map +1 -1
- package/es/stream-output/stream-output-model.js +26 -7
- package/package.json +5 -5
- package/src/display-data-output/display-data-output-model.tsx +24 -9
- package/src/stream-output/stream-output-model.tsx +16 -8
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
/// <reference types="react" resolution-mode="require"/>
|
|
2
2
|
import { LibroOutputView } from '@difizen/libro-core';
|
|
3
3
|
import type { BaseOutputView, IOutputOptions } from '@difizen/libro-core';
|
|
4
|
+
import type { IRenderMimeRegistry, IRendererFactory } from '@difizen/libro-rendermime';
|
|
4
5
|
import '../index.less';
|
|
5
6
|
export declare class DisplayDataOutputModel extends LibroOutputView implements BaseOutputView {
|
|
7
|
+
renderMimeRegistry: IRenderMimeRegistry;
|
|
8
|
+
renderFactory?: IRendererFactory;
|
|
6
9
|
constructor(options: IOutputOptions);
|
|
10
|
+
getRenderFactory(): IRendererFactory | undefined;
|
|
7
11
|
view: import("react").ForwardRefExoticComponent<import("react").RefAttributes<HTMLDivElement>>;
|
|
8
12
|
toJSON(): {
|
|
9
13
|
output_type: string;
|
|
@@ -18,5 +22,6 @@ export declare class DisplayDataOutputModel extends LibroOutputView implements B
|
|
|
18
22
|
metadata: import("@difizen/libro-common").PartialJSONValue | import("@difizen/libro-common").PartialJSONObject | undefined;
|
|
19
23
|
execution_count?: undefined;
|
|
20
24
|
};
|
|
25
|
+
dispose(force?: boolean): void;
|
|
21
26
|
}
|
|
22
27
|
//# sourceMappingURL=display-data-output-model.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"display-data-output-model.d.ts","sourceRoot":"","sources":["../../src/display-data-output/display-data-output-model.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"display-data-output-model.d.ts","sourceRoot":"","sources":["../../src/display-data-output/display-data-output-model.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1E,OAAO,KAAK,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAYvF,OAAO,eAAe,CAAC;AAmBvB,qBAEa,sBAAuB,SAAQ,eAAgB,YAAW,cAAc;IACvD,kBAAkB,EAAE,mBAAmB,CAAC;IACpE,aAAa,CAAC,EAAE,gBAAgB,CAAC;gBACD,OAAO,EAAE,cAAc;IAQvD,gBAAgB;IAUP,IAAI,2FAAgC;IACpC,MAAM;;;;;;;;;;;;;IAgBN,OAAO,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,IAAI;CAMxC"}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
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;
|
|
2
|
+
var _dec, _dec2, _dec3, _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 }); }
|
|
3
4
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
4
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); } }
|
|
5
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; }
|
|
6
7
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
7
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 _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
|
|
10
|
+
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
|
8
11
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
9
12
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
10
13
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
@@ -12,6 +15,8 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
|
|
|
12
15
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
13
16
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
14
17
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
18
|
+
function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
|
|
19
|
+
function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
|
|
15
20
|
import { LibroOutputView } from '@difizen/libro-core';
|
|
16
21
|
import { RenderMimeRegistry } from '@difizen/libro-rendermime';
|
|
17
22
|
import { getOrigin, useInject, view, ViewInstance, ViewOption } from '@difizen/mana-app';
|
|
@@ -22,12 +27,11 @@ import "../index.less";
|
|
|
22
27
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
23
28
|
var DisplayDataOutputModelRender = /*#__PURE__*/forwardRef(function DisplayDataOutputModelRender(_props, ref) {
|
|
24
29
|
var output = useInject(ViewInstance);
|
|
25
|
-
var defaultRenderMime = useInject(RenderMimeRegistry);
|
|
26
30
|
var model = getOrigin(output);
|
|
27
|
-
var
|
|
31
|
+
var factory = model.getRenderFactory();
|
|
28
32
|
var children = null;
|
|
29
|
-
if (
|
|
30
|
-
var OutputRender =
|
|
33
|
+
if (factory) {
|
|
34
|
+
var OutputRender = factory.render;
|
|
31
35
|
children = /*#__PURE__*/_jsx(OutputRender, {
|
|
32
36
|
model: model
|
|
33
37
|
});
|
|
@@ -38,13 +42,14 @@ var DisplayDataOutputModelRender = /*#__PURE__*/forwardRef(function DisplayDataO
|
|
|
38
42
|
children: children
|
|
39
43
|
});
|
|
40
44
|
});
|
|
41
|
-
export var DisplayDataOutputModel = (_dec = transient(), _dec2 = view('libro-display-data-output-model'), _dec(_class = _dec2(_class = /*#__PURE__*/function (_LibroOutputView) {
|
|
45
|
+
export var DisplayDataOutputModel = (_dec = transient(), _dec2 = view('libro-display-data-output-model'), _dec3 = inject(RenderMimeRegistry), _dec(_class = _dec2(_class = (_class2 = /*#__PURE__*/function (_LibroOutputView) {
|
|
42
46
|
_inherits(DisplayDataOutputModel, _LibroOutputView);
|
|
43
47
|
var _super = _createSuper(DisplayDataOutputModel);
|
|
44
48
|
function DisplayDataOutputModel(options) {
|
|
45
49
|
var _this;
|
|
46
50
|
_classCallCheck(this, DisplayDataOutputModel);
|
|
47
51
|
_this = _super.call(this, options);
|
|
52
|
+
_initializerDefineProperty(_this, "renderMimeRegistry", _descriptor, _assertThisInitialized(_this));
|
|
48
53
|
_this.view = DisplayDataOutputModelRender;
|
|
49
54
|
var _getBundleOptions = getBundleOptions(options.output),
|
|
50
55
|
data = _getBundleOptions.data,
|
|
@@ -56,6 +61,18 @@ export var DisplayDataOutputModel = (_dec = transient(), _dec2 = view('libro-dis
|
|
|
56
61
|
}
|
|
57
62
|
DisplayDataOutputModel = inject(ViewOption)(DisplayDataOutputModel, undefined, 0) || DisplayDataOutputModel;
|
|
58
63
|
_createClass(DisplayDataOutputModel, [{
|
|
64
|
+
key: "getRenderFactory",
|
|
65
|
+
value: function getRenderFactory() {
|
|
66
|
+
var renderMimeType = this.renderMimeRegistry.preferredMimeType(this);
|
|
67
|
+
if (renderMimeType) {
|
|
68
|
+
var renderMime = this.renderMimeRegistry.createRenderer(renderMimeType, this);
|
|
69
|
+
this.renderFactory = getOrigin(renderMime);
|
|
70
|
+
this.allowClear = renderMime.allowClear === false ? false : true;
|
|
71
|
+
return renderMime;
|
|
72
|
+
}
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
75
|
+
}, {
|
|
59
76
|
key: "toJSON",
|
|
60
77
|
value: function toJSON() {
|
|
61
78
|
if (this.raw.execution_count !== undefined) {
|
|
@@ -72,6 +89,19 @@ export var DisplayDataOutputModel = (_dec = transient(), _dec2 = view('libro-dis
|
|
|
72
89
|
metadata: this.raw.metadata
|
|
73
90
|
};
|
|
74
91
|
}
|
|
92
|
+
}, {
|
|
93
|
+
key: "dispose",
|
|
94
|
+
value: function dispose(force) {
|
|
95
|
+
if (!force && this.allowClear === false) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
_get(_getPrototypeOf(DisplayDataOutputModel.prototype), "dispose", this).call(this);
|
|
99
|
+
}
|
|
75
100
|
}]);
|
|
76
101
|
return DisplayDataOutputModel;
|
|
77
|
-
}(LibroOutputView)
|
|
102
|
+
}(LibroOutputView), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "renderMimeRegistry", [_dec3], {
|
|
103
|
+
configurable: true,
|
|
104
|
+
enumerable: true,
|
|
105
|
+
writable: true,
|
|
106
|
+
initializer: null
|
|
107
|
+
})), _class2)) || _class) || _class);
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
/// <reference types="react" resolution-mode="require"/>
|
|
2
2
|
import { LibroOutputView } from '@difizen/libro-core';
|
|
3
3
|
import type { BaseOutputView, IOutputOptions } from '@difizen/libro-core';
|
|
4
|
+
import type { IRenderMimeRegistry, IRendererFactory } from '@difizen/libro-rendermime';
|
|
4
5
|
import '../index.less';
|
|
5
6
|
export declare class StreamOutputModel extends LibroOutputView implements BaseOutputView {
|
|
7
|
+
renderMimeRegistry: IRenderMimeRegistry;
|
|
8
|
+
renderFactory?: IRendererFactory;
|
|
6
9
|
constructor(options: IOutputOptions);
|
|
10
|
+
getRenderFactory(): IRendererFactory | undefined;
|
|
7
11
|
view: import("react").ForwardRefExoticComponent<import("react").RefAttributes<HTMLDivElement>>;
|
|
8
12
|
toJSON(): {
|
|
9
13
|
output_type: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream-output-model.d.ts","sourceRoot":"","sources":["../../src/stream-output/stream-output-model.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"stream-output-model.d.ts","sourceRoot":"","sources":["../../src/stream-output/stream-output-model.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1E,OAAO,KAAK,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAWvF,OAAO,eAAe,CAAC;AAsBvB,qBAEa,iBAAkB,SAAQ,eAAgB,YAAW,cAAc;IAClD,kBAAkB,EAAE,mBAAmB,CAAC;IACpE,aAAa,CAAC,EAAE,gBAAgB,CAAC;gBAED,OAAO,EAAE,cAAc;IAOvD,gBAAgB;IASP,IAAI,2FAA2B;IAC/B,MAAM;;;;;;;;;CAOhB"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
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;
|
|
2
|
+
var _dec, _dec2, _dec3, _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 }); }
|
|
3
4
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
4
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); } }
|
|
5
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; }
|
|
@@ -12,6 +13,8 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
|
|
|
12
13
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
13
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; } }
|
|
14
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.'); }
|
|
15
18
|
import { LibroOutputView } from '@difizen/libro-core';
|
|
16
19
|
import { RenderMimeRegistry } from '@difizen/libro-rendermime';
|
|
17
20
|
import { inject, transient } from '@difizen/mana-app';
|
|
@@ -23,10 +26,9 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
23
26
|
var StreamOutputModelRender = /*#__PURE__*/forwardRef(function StreamOutputModelRender(_props, ref) {
|
|
24
27
|
var output = useInject(ViewInstance);
|
|
25
28
|
var model = getOrigin(output);
|
|
26
|
-
var
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
var OutputRender = defaultRenderMime.createRenderer(defaultRenderMimeType, model);
|
|
29
|
+
var factory = model.getRenderFactory();
|
|
30
|
+
if (factory) {
|
|
31
|
+
var OutputRender = factory.render;
|
|
30
32
|
var children = /*#__PURE__*/_jsx(OutputRender, {
|
|
31
33
|
model: model
|
|
32
34
|
});
|
|
@@ -39,13 +41,14 @@ var StreamOutputModelRender = /*#__PURE__*/forwardRef(function StreamOutputModel
|
|
|
39
41
|
return null;
|
|
40
42
|
}
|
|
41
43
|
});
|
|
42
|
-
export var StreamOutputModel = (_dec = transient(), _dec2 = view('libro-stream-output-model'), _dec(_class = _dec2(_class = /*#__PURE__*/function (_LibroOutputView) {
|
|
44
|
+
export var StreamOutputModel = (_dec = transient(), _dec2 = view('libro-stream-output-model'), _dec3 = inject(RenderMimeRegistry), _dec(_class = _dec2(_class = (_class2 = /*#__PURE__*/function (_LibroOutputView) {
|
|
43
45
|
_inherits(StreamOutputModel, _LibroOutputView);
|
|
44
46
|
var _super = _createSuper(StreamOutputModel);
|
|
45
47
|
function StreamOutputModel(options) {
|
|
46
48
|
var _this;
|
|
47
49
|
_classCallCheck(this, StreamOutputModel);
|
|
48
50
|
_this = _super.call(this, options);
|
|
51
|
+
_initializerDefineProperty(_this, "renderMimeRegistry", _descriptor, _assertThisInitialized(_this));
|
|
49
52
|
_this.view = StreamOutputModelRender;
|
|
50
53
|
var _getBundleOptions = getBundleOptions(options.output),
|
|
51
54
|
data = _getBundleOptions.data,
|
|
@@ -57,6 +60,17 @@ export var StreamOutputModel = (_dec = transient(), _dec2 = view('libro-stream-o
|
|
|
57
60
|
}
|
|
58
61
|
StreamOutputModel = inject(ViewOption)(StreamOutputModel, undefined, 0) || StreamOutputModel;
|
|
59
62
|
_createClass(StreamOutputModel, [{
|
|
63
|
+
key: "getRenderFactory",
|
|
64
|
+
value: function getRenderFactory() {
|
|
65
|
+
var renderMimeType = this.renderMimeRegistry.preferredMimeType(this);
|
|
66
|
+
if (renderMimeType) {
|
|
67
|
+
var renderMime = this.renderMimeRegistry.createRenderer(renderMimeType, this);
|
|
68
|
+
this.renderFactory = getOrigin(renderMime);
|
|
69
|
+
return renderMime;
|
|
70
|
+
}
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
}, {
|
|
60
74
|
key: "toJSON",
|
|
61
75
|
value: function toJSON() {
|
|
62
76
|
return {
|
|
@@ -67,4 +81,9 @@ export var StreamOutputModel = (_dec = transient(), _dec2 = view('libro-stream-o
|
|
|
67
81
|
}
|
|
68
82
|
}]);
|
|
69
83
|
return StreamOutputModel;
|
|
70
|
-
}(LibroOutputView)
|
|
84
|
+
}(LibroOutputView), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "renderMimeRegistry", [_dec3], {
|
|
85
|
+
configurable: true,
|
|
86
|
+
enumerable: true,
|
|
87
|
+
writable: true,
|
|
88
|
+
initializer: null
|
|
89
|
+
})), _class2)) || _class) || _class);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@difizen/libro-output",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"libro",
|
|
@@ -32,15 +32,15 @@
|
|
|
32
32
|
"src"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@difizen/libro-common": "^0.2.
|
|
36
|
-
"@difizen/libro-core": "^0.2.
|
|
37
|
-
"@difizen/libro-rendermime": "^0.2.
|
|
35
|
+
"@difizen/libro-common": "^0.2.2",
|
|
36
|
+
"@difizen/libro-core": "^0.2.2",
|
|
37
|
+
"@difizen/libro-rendermime": "^0.2.2",
|
|
38
38
|
"@difizen/mana-app": "latest",
|
|
39
39
|
"markdown-it": "^13.0.1"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"antd": "^5.8.6",
|
|
43
|
-
"react": "
|
|
43
|
+
"react": ">=16"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@types/react": "^18.2.25",
|
|
@@ -2,7 +2,7 @@ import type { JSONObject } from '@difizen/libro-common';
|
|
|
2
2
|
import { LibroOutputView } from '@difizen/libro-core';
|
|
3
3
|
import type { BaseOutputView, IOutputOptions } from '@difizen/libro-core';
|
|
4
4
|
import { RenderMimeRegistry } from '@difizen/libro-rendermime';
|
|
5
|
-
import type { IRenderMimeRegistry } from '@difizen/libro-rendermime';
|
|
5
|
+
import type { IRenderMimeRegistry, IRendererFactory } from '@difizen/libro-rendermime';
|
|
6
6
|
import {
|
|
7
7
|
getOrigin,
|
|
8
8
|
useInject,
|
|
@@ -19,16 +19,11 @@ import '../index.less';
|
|
|
19
19
|
const DisplayDataOutputModelRender = forwardRef<HTMLDivElement>(
|
|
20
20
|
function DisplayDataOutputModelRender(_props, ref) {
|
|
21
21
|
const output = useInject<DisplayDataOutputModel>(ViewInstance);
|
|
22
|
-
const defaultRenderMime = useInject<IRenderMimeRegistry>(RenderMimeRegistry);
|
|
23
|
-
|
|
24
22
|
const model = getOrigin(output);
|
|
25
|
-
const
|
|
23
|
+
const factory = model.getRenderFactory();
|
|
26
24
|
let children = null;
|
|
27
|
-
if (
|
|
28
|
-
const OutputRender =
|
|
29
|
-
defaultRenderMimeType,
|
|
30
|
-
model,
|
|
31
|
-
);
|
|
25
|
+
if (factory) {
|
|
26
|
+
const OutputRender = factory.render;
|
|
32
27
|
children = <OutputRender model={model} />;
|
|
33
28
|
}
|
|
34
29
|
return (
|
|
@@ -41,6 +36,8 @@ const DisplayDataOutputModelRender = forwardRef<HTMLDivElement>(
|
|
|
41
36
|
@transient()
|
|
42
37
|
@view('libro-display-data-output-model')
|
|
43
38
|
export class DisplayDataOutputModel extends LibroOutputView implements BaseOutputView {
|
|
39
|
+
@inject(RenderMimeRegistry) renderMimeRegistry: IRenderMimeRegistry;
|
|
40
|
+
renderFactory?: IRendererFactory;
|
|
44
41
|
constructor(@inject(ViewOption) options: IOutputOptions) {
|
|
45
42
|
super(options);
|
|
46
43
|
const { data, metadata } = getBundleOptions(options.output);
|
|
@@ -48,6 +45,17 @@ export class DisplayDataOutputModel extends LibroOutputView implements BaseOutpu
|
|
|
48
45
|
this.data = data as JSONObject;
|
|
49
46
|
this.metadata = metadata;
|
|
50
47
|
}
|
|
48
|
+
|
|
49
|
+
getRenderFactory() {
|
|
50
|
+
const renderMimeType = this.renderMimeRegistry.preferredMimeType(this);
|
|
51
|
+
if (renderMimeType) {
|
|
52
|
+
const renderMime = this.renderMimeRegistry.createRenderer(renderMimeType, this);
|
|
53
|
+
this.renderFactory = getOrigin(renderMime);
|
|
54
|
+
this.allowClear = renderMime.allowClear === false ? false : true;
|
|
55
|
+
return renderMime;
|
|
56
|
+
}
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
51
59
|
override view = DisplayDataOutputModelRender;
|
|
52
60
|
override toJSON() {
|
|
53
61
|
if (this.raw.execution_count !== undefined) {
|
|
@@ -64,4 +72,11 @@ export class DisplayDataOutputModel extends LibroOutputView implements BaseOutpu
|
|
|
64
72
|
metadata: this.raw.metadata,
|
|
65
73
|
};
|
|
66
74
|
}
|
|
75
|
+
|
|
76
|
+
override dispose(force?: boolean): void {
|
|
77
|
+
if (!force && this.allowClear === false) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
super.dispose();
|
|
81
|
+
}
|
|
67
82
|
}
|
|
@@ -2,7 +2,7 @@ import type { JSONObject } from '@difizen/libro-common';
|
|
|
2
2
|
import { LibroOutputView } from '@difizen/libro-core';
|
|
3
3
|
import type { BaseOutputView, IOutputOptions } from '@difizen/libro-core';
|
|
4
4
|
import { RenderMimeRegistry } from '@difizen/libro-rendermime';
|
|
5
|
-
import type { IRenderMimeRegistry } from '@difizen/libro-rendermime';
|
|
5
|
+
import type { IRenderMimeRegistry, IRendererFactory } from '@difizen/libro-rendermime';
|
|
6
6
|
import { inject, transient } from '@difizen/mana-app';
|
|
7
7
|
import {
|
|
8
8
|
getOrigin,
|
|
@@ -21,13 +21,9 @@ const StreamOutputModelRender = forwardRef<HTMLDivElement>(
|
|
|
21
21
|
function StreamOutputModelRender(_props, ref) {
|
|
22
22
|
const output = useInject<StreamOutputModel>(ViewInstance);
|
|
23
23
|
const model = getOrigin(output);
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const OutputRender = defaultRenderMime.createRenderer(
|
|
28
|
-
defaultRenderMimeType,
|
|
29
|
-
model,
|
|
30
|
-
);
|
|
24
|
+
const factory = model.getRenderFactory();
|
|
25
|
+
if (factory) {
|
|
26
|
+
const OutputRender = factory.render;
|
|
31
27
|
const children = <OutputRender model={model} />;
|
|
32
28
|
return (
|
|
33
29
|
<div ref={ref} className={'libro-stream-container'}>
|
|
@@ -42,6 +38,9 @@ const StreamOutputModelRender = forwardRef<HTMLDivElement>(
|
|
|
42
38
|
@transient()
|
|
43
39
|
@view('libro-stream-output-model')
|
|
44
40
|
export class StreamOutputModel extends LibroOutputView implements BaseOutputView {
|
|
41
|
+
@inject(RenderMimeRegistry) renderMimeRegistry: IRenderMimeRegistry;
|
|
42
|
+
renderFactory?: IRendererFactory;
|
|
43
|
+
|
|
45
44
|
constructor(@inject(ViewOption) options: IOutputOptions) {
|
|
46
45
|
super(options);
|
|
47
46
|
const { data, metadata } = getBundleOptions(options.output);
|
|
@@ -49,6 +48,15 @@ export class StreamOutputModel extends LibroOutputView implements BaseOutputView
|
|
|
49
48
|
this.data = data as JSONObject;
|
|
50
49
|
this.metadata = metadata;
|
|
51
50
|
}
|
|
51
|
+
getRenderFactory() {
|
|
52
|
+
const renderMimeType = this.renderMimeRegistry.preferredMimeType(this);
|
|
53
|
+
if (renderMimeType) {
|
|
54
|
+
const renderMime = this.renderMimeRegistry.createRenderer(renderMimeType, this);
|
|
55
|
+
this.renderFactory = getOrigin(renderMime);
|
|
56
|
+
return renderMime;
|
|
57
|
+
}
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
52
60
|
override view = StreamOutputModelRender;
|
|
53
61
|
override toJSON() {
|
|
54
62
|
return {
|