@difizen/libro-core 0.3.16 → 0.3.18

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.
@@ -1 +1 @@
1
- {"version":3,"file":"libro-service.d.ts","sourceRoot":"","sources":["../src/libro-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAqB,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAG5E,OAAO,KAAK,EACV,QAAQ,EACR,kBAAkB,EAClB,cAAc,EACd,YAAY,EACb,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAEL,YAAY,EACZ,eAAe,EAChB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,YAAY,CAAC;IACxB,cAAc,EAAE,KAAK,CAAC;QACpB,KAAK,EAAE;YACL,KAAK,EAAE,MAAM,CAAC;YACd,GAAG,EAAE,MAAM,CAAC;SACb,CAAC;QACF,UAAU,EAAE,QAAQ,EAAE,CAAC;QACvB,YAAY,EAAE,QAAQ,EAAE,CAAC;KAC1B,CAAC,CAAC;IACH,WAAW,EAAE,KAAK,CAAC;QACjB,IAAI,EAAE,QAAQ,CAAC;KAChB,CAAC,CAAC;CACJ;AAED,qBACa,YAAa,YAAW,eAAe,EAAE,UAAU;IAC9D,SAAS,CAAC,SAAS,uBAA8B;IAC3B,SAAS,CAAC,iBAAiB,EAAE,YAAY,CAAC;IAC3C,SAAS,CAAC,WAAW,EAAE,WAAW,CAAC;IAC1B,oBAAoB,EAAE,oBAAoB,CAAC;IAC/C,SAAS,CAAC,gBAAgB,EAAE,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R"}
@@ -157,23 +157,34 @@ export var LibroService = (_dec = singleton({
157
157
  key: "getOrCreateView",
158
158
  value: function () {
159
159
  var _getOrCreateView = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
160
- var notebookViewPromise, notebookView;
160
+ var exist, notebookViewPromise, notebookView;
161
161
  return _regeneratorRuntime().wrap(function _callee$(_context) {
162
162
  while (1) switch (_context.prev = _context.next) {
163
163
  case 0:
164
+ if (!options.id) {
165
+ _context.next = 4;
166
+ break;
167
+ }
168
+ exist = this.libroViewTracker.viewCache.get(options.id);
169
+ if (!exist) {
170
+ _context.next = 4;
171
+ break;
172
+ }
173
+ return _context.abrupt("return", exist);
174
+ case 4:
164
175
  notebookViewPromise = this.viewManager.getOrCreateView(notebookViewFactoryId, _objectSpread(_objectSpread({}, options || {}), {}, {
165
176
  modelId: options.modelId || options.id
166
177
  }));
167
- _context.next = 3;
178
+ _context.next = 7;
168
179
  return notebookViewPromise;
169
- case 3:
180
+ case 7:
170
181
  notebookView = _context.sent;
171
182
  if (!this.libroViewTracker.viewCache.has(notebookView.id)) {
172
183
  this.watchNotebookView(notebookView);
173
184
  }
174
185
  this.libroViewTracker.viewCache.set(notebookView.id, notebookView);
175
186
  return _context.abrupt("return", notebookViewPromise);
176
- case 7:
187
+ case 11:
177
188
  case "end":
178
189
  return _context.stop();
179
190
  }
@@ -24,6 +24,7 @@ export declare class FpsTracker implements ITracker {
24
24
  avgFPS: number;
25
25
  maxFrameTime: number;
26
26
  totalDropped: number;
27
+ cellsCount: number;
27
28
  constructor(id?: string, extra?: any);
28
29
  log(): {
29
30
  id: string;
@@ -31,6 +32,7 @@ export declare class FpsTracker implements ITracker {
31
32
  maxFrameTime: number;
32
33
  totalDropped: number;
33
34
  extra: any;
35
+ cellsCount: number;
34
36
  };
35
37
  }
36
38
  export declare class LibroViewTracker {
@@ -1 +1 @@
1
- {"version":3,"file":"libro-view-tracker.d.ts","sourceRoot":"","sources":["../src/libro-view-tracker.ts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AAgB,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAiB;IACzE,IAAI,SAAS,2DAEZ;IAED,mBAAmB,CAAC,OAAO,EAAE,OAAO;IAepC,OAAO,CAAC,OAAO,EAAE,QAAQ;IAMzB,UAAU,CAAC,EAAE,EAAE,MAAM;CAGtB"}
@@ -56,6 +56,7 @@ export var FpsTracker = /*#__PURE__*/function () {
56
56
  this.avgFPS = void 0;
57
57
  this.maxFrameTime = void 0;
58
58
  this.totalDropped = void 0;
59
+ this.cellsCount = void 0;
59
60
  this.id = id || v4();
60
61
  this.extra = extra || {};
61
62
  }
@@ -67,7 +68,8 @@ export var FpsTracker = /*#__PURE__*/function () {
67
68
  avgFPS: this.avgFPS,
68
69
  maxFrameTime: this.maxFrameTime,
69
70
  totalDropped: this.totalDropped,
70
- extra: this.extra
71
+ extra: this.extra,
72
+ cellsCount: this.cellsCount
71
73
  };
72
74
  return result;
73
75
  }
@@ -1,4 +1,5 @@
1
1
  import type { IModelContentChange } from '@difizen/libro-code-editor';
2
+ import type { MultilineString } from '@difizen/libro-common';
2
3
  import { BaseView, ViewManager, Deferred, DisposableCollection, Emitter, ConfigurationService } from '@difizen/mana-app';
3
4
  import type { FC, ForwardRefExoticComponent, RefAttributes } from 'react';
4
5
  import { CellService } from './cell/index.js';
@@ -61,12 +62,21 @@ export declare class LibroView extends BaseView implements NotebookView {
61
62
  get onRunCell(): import("@difizen/mana-app").Event<CellView>;
62
63
  cellScrollEmitter: Emitter<void>;
63
64
  get onCellScroll(): import("@difizen/mana-app").Event<void>;
65
+ outputRenderTabEmitter: Emitter<{
66
+ mimeType: string;
67
+ data: MultilineString | null;
68
+ }>;
69
+ get onOutputRenderTab(): import("@difizen/mana-app").Event<{
70
+ mimeType: string;
71
+ data: MultilineString | null;
72
+ }>;
64
73
  protected initializedDefer: Deferred<void>;
65
74
  get initialized(): Promise<void>;
66
75
  constructor(options: NotebookOption, collapseServiceFactory: CollapseServiceFactory, notebookService: NotebookService, virtualizedManagerHelper: VirtualizedManagerHelper);
67
76
  initView(): void;
68
77
  initialize(): Promise<void>;
69
78
  view: ForwardRefExoticComponent<RefAttributes<HTMLDivElement>>;
79
+ addLargeFileWarning: () => void;
70
80
  onViewMount: () => void;
71
81
  onViewUnmount: () => void;
72
82
  getCellViewByOption(option: CellOptions): Promise<CellView>;
@@ -1 +1 @@
1
- {"version":3,"file":"libro-view.d.ts","sourceRoot":"","sources":["../src/libro-view.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAMtE,OAAO,EAKL,QAAQ,EAIR,WAAW,EAEX,QAAQ,EAER,oBAAoB,EACpB,OAAO,EAIP,oBAAoB,EAErB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,EAAE,EAAE,yBAAyB,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAI1E,OAAO,EACL,WAAW,EAIZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAG7D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,EAAE,eAAe,EAAyB,MAAM,qBAAqB,CAAC;AAC7E,OAAO,KAAK,EACV,WAAW,EACX,QAAQ,EACR,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,cAAc,EACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAOlD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAiB,MAAM,iBAAiB,CAAC;AAElE,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAA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,mBAgChC;IACF,aAAa,aAEX;IAEF,SAAS,SAAgB,QAAQ,mBA0C/B;IACF,kBAAkB,aAKhB;IAEF,gBAAgB,aAId;IAEF;;OAEG;IACH,iBAAiB,SAAgB,QAAQ,SAAS,MAAM,mBAqEtD;IAEF,YAAY,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO;IAI9C,IAAI;CAYL"}
package/es/libro-view.js CHANGED
@@ -262,8 +262,40 @@ export var LibroView = (_dec = transient(), _dec2 = view(notebookViewFactoryId),
262
262
  _this.onCellContentChangedEmitter = new Emitter();
263
263
  _this.runCellEmitter = new Emitter();
264
264
  _this.cellScrollEmitter = new Emitter();
265
+ _this.outputRenderTabEmitter = new Emitter();
265
266
  _this.initializedDefer = new Deferred();
266
267
  _this.view = LibroRender;
268
+ _this.addLargeFileWarning = function () {
269
+ var skipWarning = localStorage.getItem('largefile' + "".concat(_this.options.modelId || _this.options.id)) === 'true';
270
+ if (!skipWarning) {
271
+ var _warningBox$querySele;
272
+ var warningBox = document.createElement('div');
273
+ warningBox.style.position = 'fixed';
274
+ warningBox.style.top = '20px';
275
+ warningBox.style.left = '50%';
276
+ warningBox.style.display = 'flex';
277
+ warningBox.style.alignItems = 'center';
278
+ warningBox.style.color = '#000000E0';
279
+ warningBox.style.transform = 'translateX(-50%)';
280
+ warningBox.style.fontSize = '14px';
281
+ warningBox.style.background = '#ffffff';
282
+ warningBox.style.padding = '9px 12px';
283
+ warningBox.style.zIndex = '9999';
284
+ warningBox.style.borderRadius = '8px';
285
+ warningBox.style.boxShadow = '0 6px 16px 0 rgba(0, 0, 0, 0.08),0 3px 6px -4px rgba(0, 0, 0, 0.12),0 9px 28px 8px rgba(0, 0, 0, 0.05)';
286
+ warningBox.innerHTML = "\n <svg style=\"display: inline-block; margin-right: 8px\" viewBox=\"64 64 896 896\" focusable=\"false\" data-icon=\"exclamation-circle\" width=\"1em\" height=\"1em\" fill=\"#faad14\" aria-hidden=\"true\" data-macaca-recorder-select-tag=\"true\"><path d=\"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm-32 232c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8v272c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V296zm32 440a48.01 48.01 0 010-96 48.01 48.01 0 010 96z\"></path></svg>\n <span style =\"line-height: 32px\">\u5373\u5C06\u6253\u5F00\u7684\u6587\u4EF6(\u5185\u5BB9\u8FC7\u5927 / cell \u8FC7\u591A)\uFF0C\u53EF\u80FD\u4F1A\u5BFC\u81F4\u64CD\u4F5C\u5361\u987F\uFF0C\u8BF7\u8010\u5FC3\u7B49\u5F85\uFF5E</span>\n <a style=\"margin-left: 8px; color: #1677ff;\">\u6211\u77E5\u9053\u4E86</a>\n ";
287
+ (_warningBox$querySele = warningBox.querySelector('a')) === null || _warningBox$querySele === void 0 || _warningBox$querySele.addEventListener('click', function () {
288
+ // 将用户偏好保存到 localStorage
289
+ localStorage.setItem('largefile' + "".concat(_this.options.modelId || _this.options.id), 'true');
290
+ document.body.removeChild(warningBox);
291
+ });
292
+ document.body.appendChild(warningBox);
293
+ // 可选:自动移除提示框
294
+ setTimeout(function () {
295
+ document.body.removeChild(warningBox);
296
+ }, 2000);
297
+ }
298
+ };
267
299
  _this.onViewMount = function () {
268
300
  _this.libroService.active = _assertThisInitialized(_this);
269
301
  _this.libroSlotManager.setup(_assertThisInitialized(_this));
@@ -272,6 +304,9 @@ export var LibroView = (_dec = transient(), _dec2 = view(notebookViewFactoryId),
272
304
  id: _this.options.modelId || _this.options.id
273
305
  });
274
306
  }
307
+ if (_this.model.isInitialized && (_this.model.cells.length > 30 || (_this.model.options['fileSize'] || 0) / (1024 * 1024) >= 5)) {
308
+ _this.addLargeFileWarning();
309
+ }
275
310
  // this.libroService.libroPerformanceStatistics.setRenderEnd(new Date());
276
311
 
277
312
  // console.log(
@@ -1771,6 +1806,11 @@ export var LibroView = (_dec = transient(), _dec2 = view(notebookViewFactoryId),
1771
1806
  get: function get() {
1772
1807
  return this.cellScrollEmitter.event;
1773
1808
  }
1809
+ }, {
1810
+ key: "onOutputRenderTab",
1811
+ get: function get() {
1812
+ return this.outputRenderTabEmitter.event;
1813
+ }
1774
1814
  }, {
1775
1815
  key: "initialized",
1776
1816
  get: function get() {
@@ -1805,6 +1845,9 @@ export var LibroView = (_dec = transient(), _dec2 = view(notebookViewFactoryId),
1805
1845
  return this.model.initialize();
1806
1846
  case 3:
1807
1847
  options = _context22.sent;
1848
+ if (options.length > 30 || (this.model.options['fileSize'] || 0) / (1024 * 1024) >= 5) {
1849
+ this.addLargeFileWarning();
1850
+ }
1808
1851
  this.configurationService.get(AutoInsertWhenNoCell).then(function (value) {
1809
1852
  var isAutoInsertWhenNoCell = value;
1810
1853
  if (isAutoInsertWhenNoCell && options.length === 0) {
@@ -1821,9 +1864,9 @@ export var LibroView = (_dec = transient(), _dec2 = view(notebookViewFactoryId),
1821
1864
  }).catch(function (e) {
1822
1865
  //
1823
1866
  });
1824
- _context22.next = 7;
1867
+ _context22.next = 8;
1825
1868
  return this.insertCells(options);
1826
- case 7:
1869
+ case 8:
1827
1870
  // 第一次insert不需要历史
1828
1871
  setTimeout(function () {
1829
1872
  _this2.model.sharedModel.clearUndoHistory();
@@ -1845,7 +1888,7 @@ export var LibroView = (_dec = transient(), _dec2 = view(notebookViewFactoryId),
1845
1888
  }));
1846
1889
  _this2.initializedDefer.resolve();
1847
1890
  }, 0);
1848
- case 8:
1891
+ case 9:
1849
1892
  case "end":
1850
1893
  return _context22.stop();
1851
1894
  }
@@ -15,6 +15,8 @@ export declare class LibroOutputArea extends BaseView implements BaseOutputArea
15
15
  get length(): number;
16
16
  protected clearNext: boolean;
17
17
  protected lastStream: string;
18
+ protected lastDisplayStream: string[];
19
+ protected isFirstLastOverHeight: boolean;
18
20
  protected lastName?: 'stdout' | 'stderr';
19
21
  /**
20
22
  * @internal
@@ -25,7 +27,7 @@ export declare class LibroOutputArea extends BaseView implements BaseOutputArea
25
27
  protected doCreateOutput(options: IOutput): Promise<BaseOutputView>;
26
28
  add: (output: IOutput) => Promise<number>;
27
29
  protected remove(model: BaseOutputView): void;
28
- set: (index: number, output: IOutput) => Promise<void>;
30
+ set: (index: number, output: IOutput, shouldReplace?: boolean) => Promise<void>;
29
31
  clear(wait?: boolean | undefined): void;
30
32
  fromJSON: (values: IOutput[]) => Promise<void>;
31
33
  toJSON: () => IOutput[];
@@ -1 +1 @@
1
- {"version":3,"file":"output-area.d.ts","sourceRoot":"","sources":["../../src/output/output-area.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAErD,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAIL,QAAQ,EAKT,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,OAAO,EAAoC,MAAM,mBAAmB,CAAC;AAK9E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,iBAAiB,EAClB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAuC1D,qBAEa,eAAgB,SAAQ,QAAS,YAAW,cAAc;IAC5D,IAAI,EAAE,aAAa,CAAyB;IAErD,cAAc,EAAE,YAAY,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC;IAC1D,IAAI,EAAE,QAAQ,CAAC;IAEf,OAAO,EAAE,cAAc,EAAE,CAAM;gBAIC,MAAM,EAAE,iBAAiB;IAIzD,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAE/B,IAAI,MAAM,WAET;IAED,SAAS,CAAC,SAAS,UAAS;IAC5B,SAAS,CAAC,UAAU,SAAM;IAE1B,SAAS,CAAC,QAAQ,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;I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F,aAAa,CAAC,IAAI,EAAE,QAAQ;IAI5B,SAAS,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,kBAAkB;IAS5D;;;;;OAKG;IAEH,SAAS,CAAC,aAAa,CAAC,OAAO,EAAE;QAC/B,MAAM,EAAE,OAAO,CAAC;QAChB,SAAS,EAAE,cAAc,CAAC;KAC3B,GAAG,OAAO;CAGZ;AAoCD,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE3D;AAoBD;;GAEG;AAEH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,MAAM,CAK1D;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAQtD"}
@@ -1,13 +1,10 @@
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
2
  var _dec, _dec2, _dec3, _dec4, _class, _class2, _descriptor, _descriptor2;
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; }
3
4
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
4
5
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
5
6
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
6
7
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
7
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
8
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
9
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
10
- 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; }
11
8
  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); } }
12
9
  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); }); }; }
13
10
  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 }); }
@@ -28,18 +25,18 @@ function _initializerWarningHelper(descriptor, context) { throw new Error('Decor
28
25
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
29
26
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
30
27
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
28
+ import { concatMultilineString } from '@difizen/libro-common';
29
+ import { getBundleOptions } from '@difizen/libro-common';
31
30
  import { isError, isStream } from '@difizen/libro-common';
32
31
  import { ViewOption, getOrigin, ViewRender, BaseView, Priority, useInject, view, ViewInstance } from '@difizen/mana-app';
33
32
  import { Emitter, prop, contrib, inject, transient } from '@difizen/mana-app';
34
33
  import { useEffect, forwardRef } from 'react';
35
- import { v4 } from 'uuid';
36
34
  import { ExecutableCellView } from "../cell/index.js";
37
35
  import { OutputContribution } from "./output-protocol.js";
38
36
  import { jsx as _jsx } from "react/jsx-runtime";
39
37
  import { jsxs as _jsxs } from "react/jsx-runtime";
40
38
  var LibroOutputAreaRender = /*#__PURE__*/forwardRef(function LibroOutputAreaRender(props, ref) {
41
39
  var outputArea = useInject(ViewInstance);
42
-
43
40
  // const cellModel = outputArea.cell.model;
44
41
  // const executing = ExecutableCellModel.is(cellModel) && cellModel.executing;
45
42
 
@@ -84,8 +81,6 @@ var LibroOutputAreaRender = /*#__PURE__*/forwardRef(function LibroOutputAreaRend
84
81
  export var LibroOutputArea = (_dec = transient(), _dec2 = view('libro-output-area'), _dec3 = contrib(OutputContribution), _dec4 = prop(), _dec(_class = _dec2(_class = (_class2 = /*#__PURE__*/function (_BaseView) {
85
82
  _inherits(LibroOutputArea, _BaseView);
86
83
  var _super = _createSuper(LibroOutputArea);
87
- // lastOutputContainerHeight?: number;
88
-
89
84
  function LibroOutputArea(option) {
90
85
  var _this;
91
86
  _classCallCheck(this, LibroOutputArea);
@@ -97,6 +92,8 @@ export var LibroOutputArea = (_dec = transient(), _dec2 = view('libro-output-are
97
92
  _this.disposed = void 0;
98
93
  _this.clearNext = false;
99
94
  _this.lastStream = '';
95
+ _this.lastDisplayStream = [];
96
+ _this.isFirstLastOverHeight = true;
100
97
  _this.lastName = void 0;
101
98
  /**
102
99
  * @internal
@@ -104,7 +101,7 @@ export var LibroOutputArea = (_dec = transient(), _dec2 = view('libro-output-are
104
101
  _this.onUpdateEmitter = new Emitter();
105
102
  _this.add = /*#__PURE__*/function () {
106
103
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(output) {
107
- var index, outputModel, model;
104
+ var _outputModel$containe, normalizeOutput, index, _outputModel, containerRec, text, split_text, outputModel, normalizedOutput, model;
108
105
  return _regeneratorRuntime().wrap(function _callee$(_context) {
109
106
  while (1) switch (_context.prev = _context.next) {
110
107
  case 0:
@@ -117,38 +114,66 @@ export var LibroOutputArea = (_dec = transient(), _dec2 = view('libro-output-are
117
114
  output: output,
118
115
  lastModel: _this.outputs[_this.length - 1]
119
116
  }))) {
120
- _context.next = 8;
117
+ _context.next = 12;
121
118
  break;
122
119
  }
123
120
  // In order to get a list change event, we add the previous
124
121
  // text to the current item and replace the previous item.
125
122
  // This also replaces the metadata of the last item.
126
- _this.lastStream += normalize(output.text);
123
+ normalizeOutput = normalize(output.text);
124
+ _this.lastStream += normalizeOutput;
127
125
  _this.lastStream = removeOverwrittenChars(_this.lastStream);
128
126
  output.text = _this.lastStream;
129
127
  index = _this.length - 1;
130
- _this.set(index, output);
128
+ _outputModel = _this.outputs[index];
129
+ containerRec = (_outputModel$containe = _outputModel.container) === null || _outputModel$containe === void 0 || (_outputModel$containe = _outputModel$containe.current) === null || _outputModel$containe === void 0 ? void 0 : _outputModel$containe.getBoundingClientRect();
130
+ if (((containerRec === null || containerRec === void 0 ? void 0 : containerRec.height) || 0) > 240) {
131
+ if (_this.isFirstLastOverHeight) {
132
+ _this.lastDisplayStream = [concatMultilineString(_this.lastStream)];
133
+ _this.lastDisplayStream.push('\n...\n');
134
+ _this.isFirstLastOverHeight = false;
135
+ } else {
136
+ _this.lastDisplayStream = [].concat(_toConsumableArray(_this.lastDisplayStream), _toConsumableArray(splitWithNewline(normalizeOutput)));
137
+ }
138
+ output['is_over_height'] = true;
139
+ output['display_text'] = _this.lastDisplayStream;
140
+ }
141
+ _this.set(index, output, true);
131
142
  return _context.abrupt("return", _this.length);
132
- case 8:
143
+ case 12:
144
+ _this.isFirstLastOverHeight = true;
133
145
  if (isStream(output)) {
134
- output.text = removeOverwrittenChars(normalize(output.text));
146
+ text = removeOverwrittenChars(normalize(output.text));
147
+ output.text = text;
148
+ split_text = splitWithNewline(text);
149
+ if (_this.isFirstLastOverHeight && split_text.length > 15) {
150
+ _this.lastDisplayStream = [concatMultilineString(split_text.slice(0, 15))];
151
+ _this.lastDisplayStream.push('\n...\n');
152
+ _this.lastDisplayStream = [].concat(_toConsumableArray(_this.lastDisplayStream), _toConsumableArray(split_text.slice(15)));
153
+ _this.isFirstLastOverHeight = false;
154
+ output['is_over_height'] = true;
155
+ output['display_text'] = _this.lastDisplayStream;
156
+ }
135
157
  }
136
158
  outputModel = _this.doCreateOutput(output); // Update the stream information.
137
159
  if (isStream(output)) {
138
- _this.lastStream = normalize(output.text);
160
+ normalizedOutput = normalize(output.text);
161
+ _this.lastStream = normalizedOutput;
139
162
  _this.lastName = output.name;
140
163
  } else {
141
164
  _this.lastStream = '';
165
+ _this.lastDisplayStream = [];
166
+ _this.isFirstLastOverHeight = true;
142
167
  }
143
- _context.next = 13;
168
+ _context.next = 18;
144
169
  return outputModel;
145
- case 13:
170
+ case 18:
146
171
  model = _context.sent;
147
172
  model.onDisposed(function () {
148
173
  _this.remove(model);
149
174
  });
150
175
  return _context.abrupt("return", _this.outputs.push(model));
151
- case 16:
176
+ case 21:
152
177
  case "end":
153
178
  return _context.stop();
154
179
  }
@@ -159,29 +184,42 @@ export var LibroOutputArea = (_dec = transient(), _dec2 = view('libro-output-are
159
184
  };
160
185
  }();
161
186
  _this.set = /*#__PURE__*/function () {
162
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(index, output) {
163
- var outputModel, current, model;
187
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(index, output, shouldReplace) {
188
+ var outputModel, _getBundleOptions, data, _outputModel2, current, model;
164
189
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
165
190
  while (1) switch (_context2.prev = _context2.next) {
166
191
  case 0:
167
- outputModel = _this.doCreateOutput(output);
192
+ if (!shouldReplace) {
193
+ _context2.next = 8;
194
+ break;
195
+ }
196
+ outputModel = _this.outputs[index];
197
+ _getBundleOptions = getBundleOptions(output), data = _getBundleOptions.data;
198
+ outputModel.raw = output;
199
+ outputModel.data = data;
200
+ outputModel.onUpdateEmitter.fire();
201
+ // outputModel.data
202
+ _context2.next = 16;
203
+ break;
204
+ case 8:
205
+ _outputModel2 = _this.doCreateOutput(output);
168
206
  current = _this.outputs[index];
169
207
  current.dispose();
170
- _context2.next = 5;
171
- return outputModel;
172
- case 5:
208
+ _context2.next = 13;
209
+ return _outputModel2;
210
+ case 13:
173
211
  model = _context2.sent;
174
212
  model.onDisposed(function () {
175
213
  _this.remove(model);
176
214
  });
177
215
  _this.outputs[index] = model;
178
- case 8:
216
+ case 16:
179
217
  case "end":
180
218
  return _context2.stop();
181
219
  }
182
220
  }, _callee2);
183
221
  }));
184
- return function (_x2, _x3) {
222
+ return function (_x2, _x3, _x4) {
185
223
  return _ref2.apply(this, arguments);
186
224
  };
187
225
  }();
@@ -229,7 +267,7 @@ export var LibroOutputArea = (_dec = transient(), _dec2 = view('libro-output-are
229
267
  }
230
268
  }, _callee3, null, [[3, 13, 16, 19]]);
231
269
  }));
232
- return function (_x4) {
270
+ return function (_x5) {
233
271
  return _ref3.apply(this, arguments);
234
272
  };
235
273
  }();
@@ -265,9 +303,7 @@ export var LibroOutputArea = (_dec = transient(), _dec2 = view('libro-output-are
265
303
  value: function doCreateOutput(options) {
266
304
  var provider = this.findProvider(options);
267
305
  return provider.factory({
268
- output: _objectSpread({
269
- _librOutputId: v4()
270
- }, options),
306
+ output: options,
271
307
  trusted: this.cell.model.trusted,
272
308
  cell: this.cell
273
309
  });
@@ -285,6 +321,8 @@ export var LibroOutputArea = (_dec = transient(), _dec2 = view('libro-output-are
285
321
  key: "clear",
286
322
  value: function clear(wait) {
287
323
  this.lastStream = '';
324
+ this.lastDisplayStream = [];
325
+ this.isFirstLastOverHeight = true;
288
326
  if (wait) {
289
327
  this.clearNext = true;
290
328
  return;
@@ -375,6 +413,21 @@ function fixCarriageReturn(txt) {
375
413
  export function removeOverwrittenChars(text) {
376
414
  return fixCarriageReturn(fixBackspace(text));
377
415
  }
416
+ function splitWithNewline(input) {
417
+ var parts = input.split(/(\n)/);
418
+ var result = [];
419
+ for (var i = 0; i < parts.length; i += 2) {
420
+ var text = parts[i];
421
+ var newline = parts[i + 1] || '';
422
+ var combined = text + newline;
423
+
424
+ // 仅保留非空项
425
+ if (text || newline) {
426
+ result.push(combined);
427
+ }
428
+ }
429
+ return result;
430
+ }
378
431
 
379
432
  /**
380
433
  * Normalize an output.
@@ -1,5 +1,5 @@
1
1
  import type { IOutput, JSONObject, PartialJSONObject } from '@difizen/libro-common';
2
- import { BaseView } from '@difizen/mana-app';
2
+ import { BaseView, Emitter } from '@difizen/mana-app';
3
3
  import type { FC } from 'react';
4
4
  import type { CellView } from '../libro-protocol.js';
5
5
  import type { IOutputOptions } from './output-protocol.js';
@@ -10,6 +10,8 @@ export declare class LibroOutputView extends BaseView implements BaseOutputView
10
10
  raw: IOutput;
11
11
  allowClear: boolean;
12
12
  data: JSONObject;
13
+ onUpdateEmitter: Emitter<void>;
14
+ get onUpdate(): import("@difizen/mana-app").Event<void>;
13
15
  metadata: PartialJSONObject;
14
16
  type: string;
15
17
  trusted: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"output-model.d.ts","sourceRoot":"","sources":["../../src/output/output-model.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AACpF,OAAO,EAAE,QAAQ,EAA0B,MAAM,mBAAmB,CAAC;AAErE,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAGhC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAS5E,qBAEa,eAAgB,SAAQ,QAAS,YAAW,cAAc;IAC5D,EAAE,SAAQ;IAGnB,IAAI,EAAE,QAAQ,CAAC;IAGf,GAAG,EAAE,OAAO,CAAC;IAGb,UAAU,UAAQ;IAGlB,IAAI,EAAE,UAAU,CAAC;IAEjB,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;gBACe,OAAO,EAAE,cAAc;IAUvD,MAAM,EAAE,EAAE,CAAC;QAAE,MAAM,EAAE,cAAc,CAAA;KAAE,CAAC,CAA0B;IAEvD,OAAO;IAGhB,MAAM;IAGN,OAAO,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI;CAQxC;AAED;;GAEG;AACH,eAAO,MAAM,gBAAgB,wBAAkB,CAAC"}
1
+ {"version":3,"file":"output-model.d.ts","sourceRoot":"","sources":["../../src/output/output-model.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AACpF,OAAO,EAAE,QAAQ,EAAE,OAAO,EAA0B,MAAM,mBAAmB,CAAC;AAE9E,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAGhC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAS5E,qBAEa,eAAgB,SAAQ,QAAS,YAAW,cAAc;IAC5D,EAAE,SAAQ;IAGnB,IAAI,EAAE,QAAQ,CAAC;IAGf,GAAG,EAAE,OAAO,CAAC;IAGb,UAAU,UAAQ;IAGlB,IAAI,EAAE,UAAU,CAAC;IAEjB,eAAe,gBAAuB;IAEtC,IAAI,QAAQ,4CAEX;IAGD,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;gBACe,OAAO,EAAE,cAAc;IAavD,MAAM,EAAE,EAAE,CAAC;QAAE,MAAM,EAAE,cAAc,CAAA;KAAE,CAAC,CAA0B;IAEvD,OAAO;IAGhB,MAAM;IAGN,OAAO,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI;CAQxC;AAED;;GAEG;AACH,eAAO,MAAM,gBAAgB,wBAAkB,CAAC"}
@@ -17,7 +17,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
17
17
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
18
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
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.'); }
20
- import { BaseView, prop, view, ViewOption } from '@difizen/mana-app';
20
+ import { BaseView, Emitter, prop, view, ViewOption } from '@difizen/mana-app';
21
21
  import { inject, transient } from '@difizen/mana-app';
22
22
  import { v4 } from 'uuid';
23
23
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -40,6 +40,7 @@ export var LibroOutputView = (_dec = transient(), _dec2 = view('libro-output-mod
40
40
  _initializerDefineProperty(_this, "raw", _descriptor, _assertThisInitialized(_this));
41
41
  _initializerDefineProperty(_this, "allowClear", _descriptor2, _assertThisInitialized(_this));
42
42
  _initializerDefineProperty(_this, "data", _descriptor3, _assertThisInitialized(_this));
43
+ _this.onUpdateEmitter = new Emitter();
43
44
  _initializerDefineProperty(_this, "metadata", _descriptor4, _assertThisInitialized(_this));
44
45
  _this.type = void 0;
45
46
  _this.trusted = void 0;
@@ -50,10 +51,19 @@ export var LibroOutputView = (_dec = transient(), _dec2 = view('libro-output-mod
50
51
  _this.type = 'libro-default-output';
51
52
  _this.data = {};
52
53
  _this.metadata = {};
54
+ _this.onUpdate(function () {
55
+ var _this$cell$parent$mod, _this$cell$parent$mod2;
56
+ (_this$cell$parent$mod = (_this$cell$parent$mod2 = _this.cell.parent.model).onChange) === null || _this$cell$parent$mod === void 0 || _this$cell$parent$mod.call(_this$cell$parent$mod2);
57
+ });
53
58
  return _this;
54
59
  }
55
60
  LibroOutputView = inject(ViewOption)(LibroOutputView, undefined, 0) || LibroOutputView;
56
61
  _createClass(LibroOutputView, [{
62
+ key: "onUpdate",
63
+ get: function get() {
64
+ return this.onUpdateEmitter.event;
65
+ }
66
+ }, {
57
67
  key: "dispose",
58
68
  value: function dispose() {
59
69
  _get(_getPrototypeOf(LibroOutputView.prototype), "dispose", this).call(this);
@@ -1,5 +1,5 @@
1
1
  import type { IOutput, ReadonlyPartialJSONObject, JSONObject } from '@difizen/libro-common';
2
- import type { Event } from '@difizen/mana-app';
2
+ import type { Emitter, Event } from '@difizen/mana-app';
3
3
  import type { View } from '@difizen/mana-app';
4
4
  import { Syringe } from '@difizen/mana-app';
5
5
  import type { CellView } from '../libro-protocol.js';
@@ -75,7 +75,11 @@ export interface BaseOutputView extends View {
75
75
  /**
76
76
  * The data associated with the model.
77
77
  */
78
- readonly data: JSONObject;
78
+ data: JSONObject;
79
+ onUpdateEmitter: Emitter<void>;
80
+ onUpdate: Event<void>;
81
+ isLargeOutputDisplay?: boolean;
82
+ isTabRender?: boolean;
79
83
  /**
80
84
  * The metadata associated with the model.
81
85
  *
@@ -1 +1 @@
1
- {"version":3,"file":"output-protocol.d.ts","sourceRoot":"","sources":["../../src/output/output-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,yBAAyB,EACzB,UAAU,EACX,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAErD,eAAO,MAAM,UAAU,eAAuB,CAAC;AAE/C,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,QAAQ,CAAC;CAChB;AAED,MAAM,WAAW,cAAe,S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,KAAK,CAAC,IAAI,CAAC,CAAC;IAEtB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAE/B,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,EAAE,yBAAyB,CAAC;IAC7C;;OAEG;IACH,OAAO,EAAE,MAAM,IAAI,CAAC;IAEpB;;OAEG;IACH,MAAM,EAAE,MAAM,OAAO,CAAC;IAEtB;;;;;OAKG;IACH,OAAO,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI,CAAC;IAExC;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,cAAc,CAAC;AAE7C;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,IAAI,CAAC,EAAE,UAAU,CAAC;IAElB;;OAEG;IACH,QAAQ,CAAC,EAAE,UAAU,CAAC;CACvB;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,QAAQ,CAAC;CAChB;AAED,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,EAAE,cAAc,KAAK,OAAO,CAAC,eAAe,CAAC,CAAC;AAEvF,eAAO,MAAM,kBAAkB,sBAA4C,CAAC;AAC5E,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,MAAM,CAAC;IACvC,OAAO,EAAE,kBAAkB,CAAC;CAC7B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@difizen/libro-core",
3
- "version": "0.3.16",
3
+ "version": "0.3.18",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "libro",
@@ -34,10 +34,10 @@
34
34
  ],
35
35
  "dependencies": {
36
36
  "@ant-design/icons": "^5.1.0",
37
- "@difizen/libro-code-editor": "^0.3.16",
38
- "@difizen/libro-common": "^0.3.16",
39
- "@difizen/libro-shared-model": "^0.3.16",
40
- "@difizen/libro-virtualized": "^0.3.16",
37
+ "@difizen/libro-code-editor": "^0.3.18",
38
+ "@difizen/libro-common": "^0.3.18",
39
+ "@difizen/libro-shared-model": "^0.3.18",
40
+ "@difizen/libro-virtualized": "^0.3.18",
41
41
  "@difizen/mana-app": "latest",
42
42
  "@difizen/mana-l10n": "latest",
43
43
  "@difizen/mana-react": "latest",
@@ -144,6 +144,12 @@ export class LibroService implements NotebookService, Disposable {
144
144
  return model;
145
145
  }
146
146
  async getOrCreateView(options: NotebookOption): Promise<NotebookView> {
147
+ if (options.id) {
148
+ const exist = this.libroViewTracker.viewCache.get(options.id);
149
+ if (exist) {
150
+ return exist;
151
+ }
152
+ }
147
153
  const notebookViewPromise = this.viewManager.getOrCreateView<NotebookView>(
148
154
  notebookViewFactoryId,
149
155
  {
@@ -53,6 +53,7 @@ export class FpsTracker implements ITracker {
53
53
  avgFPS: number;
54
54
  maxFrameTime: number;
55
55
  totalDropped: number;
56
+ cellsCount: number;
56
57
 
57
58
  constructor(id?: string, extra?: any) {
58
59
  this.id = id || v4();
@@ -66,6 +67,7 @@ export class FpsTracker implements ITracker {
66
67
  maxFrameTime: this.maxFrameTime,
67
68
  totalDropped: this.totalDropped,
68
69
  extra: this.extra,
70
+ cellsCount: this.cellsCount,
69
71
  };
70
72
  return result;
71
73
  }
@@ -1,5 +1,6 @@
1
1
  import { ToTopOutlined } from '@ant-design/icons';
2
2
  import type { IModelContentChange } from '@difizen/libro-code-editor';
3
+ import type { MultilineString } from '@difizen/libro-common';
3
4
  import {
4
5
  concatMultilineString,
5
6
  copy2clipboard,
@@ -26,7 +27,8 @@ import {
26
27
  ConfigurationService,
27
28
  useConfigurationValue,
28
29
  } from '@difizen/mana-app';
29
- import { FloatButton, Button, Spin } from 'antd';
30
+ import { l10n } from '@difizen/mana-l10n';
31
+ import { FloatButton, Button, Spin, message } from 'antd';
30
32
  import type { FC, ForwardRefExoticComponent, RefAttributes } from 'react';
31
33
  import { forwardRef, memo, useCallback, useEffect, useRef } from 'react';
32
34
  import { v4 } from 'uuid';
@@ -385,6 +387,14 @@ export class LibroView extends BaseView implements NotebookView {
385
387
  return this.cellScrollEmitter.event;
386
388
  }
387
389
 
390
+ outputRenderTabEmitter = new Emitter<{
391
+ mimeType: string;
392
+ data: MultilineString | null;
393
+ }>();
394
+ get onOutputRenderTab() {
395
+ return this.outputRenderTabEmitter.event;
396
+ }
397
+
388
398
  protected initializedDefer = new Deferred<void>();
389
399
 
390
400
  get initialized() {
@@ -431,6 +441,12 @@ export class LibroView extends BaseView implements NotebookView {
431
441
  async initialize() {
432
442
  this.model.isInitialized = false;
433
443
  const options = await this.model.initialize();
444
+ if (
445
+ options.length > 30 ||
446
+ (this.model.options['fileSize'] || 0) / (1024 * 1024) >= 5
447
+ ) {
448
+ this.addLargeFileWarning();
449
+ }
434
450
  this.configurationService
435
451
  .get(AutoInsertWhenNoCell)
436
452
  .then((value) => {
@@ -476,14 +492,64 @@ export class LibroView extends BaseView implements NotebookView {
476
492
 
477
493
  override view = LibroRender;
478
494
 
495
+ addLargeFileWarning = () => {
496
+ const skipWarning =
497
+ localStorage.getItem(
498
+ 'largefile' + `${this.options.modelId || this.options.id}`,
499
+ ) === 'true';
500
+ if (!skipWarning) {
501
+ const warningBox = document.createElement('div');
502
+ warningBox.style.position = 'fixed';
503
+ warningBox.style.top = '20px';
504
+ warningBox.style.left = '50%';
505
+ warningBox.style.display = 'flex';
506
+ warningBox.style.alignItems = 'center';
507
+ warningBox.style.color = '#000000E0';
508
+ warningBox.style.transform = 'translateX(-50%)';
509
+ warningBox.style.fontSize = '14px';
510
+ warningBox.style.background = '#ffffff';
511
+ warningBox.style.padding = '9px 12px';
512
+ warningBox.style.zIndex = '9999';
513
+ warningBox.style.borderRadius = '8px';
514
+ warningBox.style.boxShadow =
515
+ '0 6px 16px 0 rgba(0, 0, 0, 0.08),0 3px 6px -4px rgba(0, 0, 0, 0.12),0 9px 28px 8px rgba(0, 0, 0, 0.05)';
516
+ warningBox.innerHTML = `
517
+ <svg style="display: inline-block; margin-right: 8px" viewBox="64 64 896 896" focusable="false" data-icon="exclamation-circle" width="1em" height="1em" fill="#faad14" aria-hidden="true" data-macaca-recorder-select-tag="true"><path d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm-32 232c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8v272c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V296zm32 440a48.01 48.01 0 010-96 48.01 48.01 0 010 96z"></path></svg>
518
+ <span style ="line-height: 32px">即将打开的文件(内容过大 / cell 过多),可能会导致操作卡顿,请耐心等待~</span>
519
+ <a style="margin-left: 8px; color: #1677ff;">我知道了</a>
520
+ `;
521
+ warningBox.querySelector('a')?.addEventListener('click', () => {
522
+ // 将用户偏好保存到 localStorage
523
+ localStorage.setItem(
524
+ 'largefile' + `${this.options.modelId || this.options.id}`,
525
+ 'true',
526
+ );
527
+ document.body.removeChild(warningBox);
528
+ });
529
+ document.body.appendChild(warningBox);
530
+ // 可选:自动移除提示框
531
+ setTimeout(() => {
532
+ document.body.removeChild(warningBox);
533
+ }, 2000);
534
+ }
535
+ };
536
+
479
537
  override onViewMount = () => {
480
538
  this.libroService.active = this;
481
539
  this.libroSlotManager.setup(this);
540
+
482
541
  if (this.libroViewTracker.isEnabledSpmReporter) {
483
542
  this.libroViewTracker.getOrCreateTrackers({
484
543
  id: this.options.modelId || this.options.id,
485
544
  });
486
545
  }
546
+ if (
547
+ this.model.isInitialized &&
548
+ (this.model.cells.length > 30 ||
549
+ (this.model.options['fileSize'] || 0) / (1024 * 1024) >= 5)
550
+ ) {
551
+ this.addLargeFileWarning();
552
+ }
487
553
  // this.libroService.libroPerformanceStatistics.setRenderEnd(new Date());
488
554
 
489
555
  // console.log(
@@ -1,4 +1,6 @@
1
- import type { IOutput } from '@difizen/libro-common';
1
+ import type { IOutput, JSONObject } from '@difizen/libro-common';
2
+ import { concatMultilineString } from '@difizen/libro-common';
3
+ import { getBundleOptions } from '@difizen/libro-common';
2
4
  import { isError, isStream } from '@difizen/libro-common';
3
5
  import type { ViewComponent, Contribution } from '@difizen/mana-app';
4
6
  import {
@@ -13,7 +15,6 @@ import {
13
15
  } from '@difizen/mana-app';
14
16
  import { Emitter, prop, contrib, inject, transient } from '@difizen/mana-app';
15
17
  import { useEffect, forwardRef } from 'react';
16
- import { v4 } from 'uuid';
17
18
 
18
19
  import { ExecutableCellView } from '../cell/index.js';
19
20
  import type { CellView } from '../libro-protocol.js';
@@ -28,7 +29,6 @@ import { OutputContribution } from './output-protocol.js';
28
29
  const LibroOutputAreaRender = forwardRef<HTMLDivElement>(
29
30
  function LibroOutputAreaRender(props, ref) {
30
31
  const outputArea = useInject<LibroOutputArea>(ViewInstance);
31
-
32
32
  // const cellModel = outputArea.cell.model;
33
33
  // const executing = ExecutableCellModel.is(cellModel) && cellModel.executing;
34
34
 
@@ -72,8 +72,6 @@ export class LibroOutputArea extends BaseView implements BaseOutputArea {
72
72
  @prop()
73
73
  outputs: BaseOutputView[] = [];
74
74
 
75
- // lastOutputContainerHeight?: number;
76
-
77
75
  constructor(@inject(ViewOption) option: IOutputAreaOption) {
78
76
  super();
79
77
  this.cell = option.cell;
@@ -86,6 +84,8 @@ export class LibroOutputArea extends BaseView implements BaseOutputArea {
86
84
 
87
85
  protected clearNext = false;
88
86
  protected lastStream = '';
87
+ protected lastDisplayStream: string[] = [];
88
+ protected isFirstLastOverHeight = true;
89
89
 
90
90
  protected lastName?: 'stdout' | 'stderr';
91
91
 
@@ -108,7 +108,7 @@ export class LibroOutputArea extends BaseView implements BaseOutputArea {
108
108
  const provider = this.findProvider(options);
109
109
 
110
110
  return provider.factory({
111
- output: { _librOutputId: v4(), ...options },
111
+ output: options,
112
112
  trusted: this.cell.model.trusted,
113
113
  cell: this.cell,
114
114
  });
@@ -131,26 +131,56 @@ export class LibroOutputArea extends BaseView implements BaseOutputArea {
131
131
  // In order to get a list change event, we add the previous
132
132
  // text to the current item and replace the previous item.
133
133
  // This also replaces the metadata of the last item.
134
- this.lastStream += normalize(output.text);
134
+ const normalizeOutput = normalize(output.text);
135
+ this.lastStream += normalizeOutput;
135
136
  this.lastStream = removeOverwrittenChars(this.lastStream);
136
137
  output.text = this.lastStream;
137
138
  const index = this.length - 1;
138
- this.set(index, output);
139
+ const outputModel = this.outputs[index];
140
+ const containerRec = outputModel.container?.current?.getBoundingClientRect();
141
+
142
+ if ((containerRec?.height || 0) > 240) {
143
+ if (this.isFirstLastOverHeight) {
144
+ this.lastDisplayStream = [concatMultilineString(this.lastStream)];
145
+ this.lastDisplayStream.push('\n...\n');
146
+ this.isFirstLastOverHeight = false;
147
+ } else {
148
+ this.lastDisplayStream = [
149
+ ...this.lastDisplayStream,
150
+ ...splitWithNewline(normalizeOutput), //考虑有可能一次性输出多个带换行符的内容
151
+ ];
152
+ }
153
+ output['is_over_height'] = true;
154
+ output['display_text'] = this.lastDisplayStream;
155
+ }
156
+ this.set(index, output, true);
139
157
  return this.length;
140
158
  }
141
-
159
+ this.isFirstLastOverHeight = true;
142
160
  if (isStream(output)) {
143
- output.text = removeOverwrittenChars(normalize(output.text));
161
+ const text = removeOverwrittenChars(normalize(output.text));
162
+ output.text = text;
163
+ const split_text = splitWithNewline(text);
164
+ if (this.isFirstLastOverHeight && split_text.length > 15) {
165
+ this.lastDisplayStream = [concatMultilineString(split_text.slice(0, 15))];
166
+ this.lastDisplayStream.push('\n...\n');
167
+ this.lastDisplayStream = [...this.lastDisplayStream, ...split_text.slice(15)];
168
+ this.isFirstLastOverHeight = false;
169
+ output['is_over_height'] = true;
170
+ output['display_text'] = this.lastDisplayStream;
171
+ }
144
172
  }
145
-
146
173
  const outputModel = this.doCreateOutput(output);
147
174
 
148
175
  // Update the stream information.
149
176
  if (isStream(output)) {
150
- this.lastStream = normalize(output.text);
177
+ const normalizedOutput = normalize(output.text);
178
+ this.lastStream = normalizedOutput;
151
179
  this.lastName = output.name;
152
180
  } else {
153
181
  this.lastStream = '';
182
+ this.lastDisplayStream = [];
183
+ this.isFirstLastOverHeight = true;
154
184
  }
155
185
  const model = await outputModel;
156
186
  model.onDisposed(() => {
@@ -165,18 +195,29 @@ export class LibroOutputArea extends BaseView implements BaseOutputArea {
165
195
  this.outputs = outputs;
166
196
  }
167
197
 
168
- set = async (index: number, output: IOutput) => {
169
- const outputModel = this.doCreateOutput(output);
170
- const current = this.outputs[index];
171
- current.dispose();
172
- const model = await outputModel;
173
- model.onDisposed(() => {
174
- this.remove(model);
175
- });
176
- this.outputs[index] = model;
198
+ set = async (index: number, output: IOutput, shouldReplace?: boolean) => {
199
+ if (shouldReplace) {
200
+ const outputModel = this.outputs[index];
201
+ const { data } = getBundleOptions(output);
202
+ outputModel.raw = output;
203
+ outputModel.data = data as JSONObject;
204
+ outputModel.onUpdateEmitter.fire();
205
+ // outputModel.data
206
+ } else {
207
+ const outputModel = this.doCreateOutput(output);
208
+ const current = this.outputs[index];
209
+ current.dispose();
210
+ const model = await outputModel;
211
+ model.onDisposed(() => {
212
+ this.remove(model);
213
+ });
214
+ this.outputs[index] = model;
215
+ }
177
216
  };
178
217
  clear(wait?: boolean | undefined) {
179
218
  this.lastStream = '';
219
+ this.lastDisplayStream = [];
220
+ this.isFirstLastOverHeight = true;
180
221
  if (wait) {
181
222
  this.clearNext = true;
182
223
  return;
@@ -264,6 +305,24 @@ export function removeOverwrittenChars(text: string): string {
264
305
  return fixCarriageReturn(fixBackspace(text));
265
306
  }
266
307
 
308
+ function splitWithNewline(input: string): string[] {
309
+ const parts = input.split(/(\n)/);
310
+ const result: string[] = [];
311
+
312
+ for (let i = 0; i < parts.length; i += 2) {
313
+ const text = parts[i];
314
+ const newline = parts[i + 1] || '';
315
+ const combined = text + newline;
316
+
317
+ // 仅保留非空项
318
+ if (text || newline) {
319
+ result.push(combined);
320
+ }
321
+ }
322
+
323
+ return result;
324
+ }
325
+
267
326
  /**
268
327
  * Normalize an output.
269
328
  */
@@ -1,5 +1,5 @@
1
1
  import type { IOutput, JSONObject, PartialJSONObject } from '@difizen/libro-common';
2
- import { BaseView, prop, view, ViewOption } from '@difizen/mana-app';
2
+ import { BaseView, Emitter, prop, view, ViewOption } from '@difizen/mana-app';
3
3
  import { inject, transient } from '@difizen/mana-app';
4
4
  import type { FC } from 'react';
5
5
  import { v4 } from 'uuid';
@@ -32,6 +32,13 @@ export class LibroOutputView extends BaseView implements BaseOutputView {
32
32
 
33
33
  @prop()
34
34
  data: JSONObject;
35
+
36
+ onUpdateEmitter = new Emitter<void>();
37
+
38
+ get onUpdate() {
39
+ return this.onUpdateEmitter.event;
40
+ }
41
+
35
42
  @prop()
36
43
  metadata: PartialJSONObject;
37
44
  type: string;
@@ -44,6 +51,9 @@ export class LibroOutputView extends BaseView implements BaseOutputView {
44
51
  this.type = 'libro-default-output';
45
52
  this.data = {};
46
53
  this.metadata = {};
54
+ this.onUpdate(() => {
55
+ this.cell.parent.model.onChange?.();
56
+ });
47
57
  }
48
58
 
49
59
  render: FC<{ output: BaseOutputView }> = LibroOutputModelRender;
@@ -3,7 +3,7 @@ import type {
3
3
  ReadonlyPartialJSONObject,
4
4
  JSONObject,
5
5
  } from '@difizen/libro-common';
6
- import type { Event } from '@difizen/mana-app';
6
+ import type { Emitter, Event } from '@difizen/mana-app';
7
7
  import type { View } from '@difizen/mana-app';
8
8
  import { Syringe } from '@difizen/mana-app';
9
9
 
@@ -100,7 +100,15 @@ export interface BaseOutputView extends View {
100
100
  /**
101
101
  * The data associated with the model.
102
102
  */
103
- readonly data: JSONObject;
103
+ data: JSONObject;
104
+
105
+ onUpdateEmitter: Emitter<void>;
106
+
107
+ onUpdate: Event<void>;
108
+
109
+ isLargeOutputDisplay?: boolean;
110
+
111
+ isTabRender?: boolean;
104
112
 
105
113
  /**
106
114
  * The metadata associated with the model.