@difizen/libro-core 0.3.8 → 0.3.9
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/cell/libro-cell-service.d.ts +2 -0
- package/es/cell/libro-cell-service.d.ts.map +1 -1
- package/es/cell/libro-cell-service.js +9 -2
- package/es/cell/libro-cell-view.d.ts +2 -0
- package/es/cell/libro-cell-view.d.ts.map +1 -1
- package/es/cell/libro-cell-view.js +24 -0
- package/es/cell/libro-edit-cell-view.d.ts.map +1 -1
- package/es/cell/libro-edit-cell-view.js +3 -0
- package/es/command/libro-command-contribution.d.ts +4 -0
- package/es/command/libro-command-contribution.d.ts.map +1 -1
- package/es/command/libro-command-contribution.js +40 -26
- package/es/libro-protocol.d.ts +6 -2
- package/es/libro-protocol.d.ts.map +1 -1
- package/es/libro-protocol.js +0 -1
- package/es/libro-service.d.ts +2 -0
- package/es/libro-service.d.ts.map +1 -1
- package/es/libro-service.js +33 -19
- package/es/libro-setting.d.ts +1 -0
- package/es/libro-setting.d.ts.map +1 -1
- package/es/libro-setting.js +10 -0
- package/es/libro-view-tracker.d.ts +26 -1
- package/es/libro-view-tracker.d.ts.map +1 -1
- package/es/libro-view-tracker.js +92 -8
- package/es/libro-view.d.ts +2 -0
- package/es/libro-view.d.ts.map +1 -1
- package/es/libro-view.js +59 -20
- package/package.json +5 -5
- package/src/cell/libro-cell-service.ts +2 -0
- package/src/cell/libro-cell-view.tsx +30 -0
- package/src/cell/libro-edit-cell-view.tsx +1 -0
- package/src/command/libro-command-contribution.ts +37 -23
- package/src/libro-protocol.ts +7 -3
- package/src/libro-service.ts +7 -1
- package/src/libro-setting.ts +11 -0
- package/src/libro-view-tracker.ts +73 -2
- package/src/libro-view.tsx +34 -1
package/es/libro-setting.js
CHANGED
|
@@ -98,4 +98,14 @@ export var SupportCodeFormat = {
|
|
|
98
98
|
schema: {
|
|
99
99
|
type: 'boolean'
|
|
100
100
|
}
|
|
101
|
+
};
|
|
102
|
+
export var SpmReporter = {
|
|
103
|
+
id: 'libro.spm.reporter',
|
|
104
|
+
description: l10n.t('是否支持数据日志'),
|
|
105
|
+
title: l10n.t('是否支持数据日志'),
|
|
106
|
+
type: 'checkbox',
|
|
107
|
+
defaultValue: false,
|
|
108
|
+
schema: {
|
|
109
|
+
type: 'boolean'
|
|
110
|
+
}
|
|
101
111
|
};
|
|
@@ -1,6 +1,31 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Emitter, ConfigurationService } from '@difizen/mana-app';
|
|
2
|
+
import type { ITracker, NotebookModel, NotebookView, Options } from './libro-protocol.js';
|
|
3
|
+
export declare class Tracker implements ITracker {
|
|
4
|
+
[key: string]: any;
|
|
5
|
+
startTime?: number;
|
|
6
|
+
endTime?: number;
|
|
7
|
+
extra?: any;
|
|
8
|
+
id: string;
|
|
9
|
+
constructor(id?: string, extra?: any);
|
|
10
|
+
clearAll(): void;
|
|
11
|
+
getDuration(): number | undefined;
|
|
12
|
+
log(): {
|
|
13
|
+
id: string;
|
|
14
|
+
startTime: number | undefined;
|
|
15
|
+
endTime: number | undefined;
|
|
16
|
+
duration: number | undefined;
|
|
17
|
+
extra: any;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
2
20
|
export declare class LibroViewTracker {
|
|
3
21
|
viewCache: Map<string, NotebookView>;
|
|
4
22
|
modelCache: Map<string, NotebookModel>;
|
|
23
|
+
spmTracker: Map<string, Tracker>;
|
|
24
|
+
protected configurationService: ConfigurationService;
|
|
25
|
+
isEnabledSpmReporter: boolean;
|
|
26
|
+
protected onTrackerEmitter: Emitter<ITracker>;
|
|
27
|
+
get onTracker(): import("@difizen/mana-app").Event<ITracker>;
|
|
28
|
+
getOrCreateSpmTracker(options: Options): Tracker;
|
|
29
|
+
tracker(tracker: Tracker): void;
|
|
5
30
|
}
|
|
6
31
|
//# sourceMappingURL=libro-view-tracker.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"libro-view-tracker.d.ts","sourceRoot":"","sources":["../src/libro-view-tracker.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"libro-view-tracker.d.ts","sourceRoot":"","sources":["../src/libro-view-tracker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,OAAO,EAAE,oBAAoB,EAAU,MAAM,mBAAmB,CAAC;AAGrF,OAAO,KAAK,EACV,QAAQ,EACR,aAAa,EACb,YAAY,EACZ,OAAO,EACR,MAAM,qBAAqB,CAAC;AAE7B,qBAAa,OAAQ,YAAW,QAAQ;IACtC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,EAAE,EAAE,MAAM,CAAC;gBAEC,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAMpC,QAAQ;IAKR,WAAW;IAOX,GAAG;;;;;;;CAWJ;AAED,qBACa,gBAAgB;IAC3B,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAa;IACjD,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAa;IACnD,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAa;IACf,SAAS,CAAC,oBAAoB,EAAE,oBAAoB,CAAC;IACnF,oBAAoB,EAAE,OAAO,CAAC;IAE9B,SAAS,CAAC,gBAAgB,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAiB;IAC9D,IAAI,SAAS,gDAEZ;IAED,qBAAqB,CAAC,OAAO,EAAE,OAAO;IActC,OAAO,CAAC,OAAO,EAAE,OAAO;CAIzB"}
|
package/es/libro-view-tracker.js
CHANGED
|
@@ -1,13 +1,97 @@
|
|
|
1
|
+
var _dec, _dec2, _class, _class2, _descriptor;
|
|
1
2
|
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
|
-
|
|
3
|
+
function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }
|
|
4
|
+
function _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; }
|
|
5
|
+
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.'); }
|
|
6
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
3
7
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
4
8
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
5
9
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
10
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
export var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
import { singleton, Emitter, ConfigurationService, inject } from '@difizen/mana-app';
|
|
12
|
+
import { v4 } from 'uuid';
|
|
13
|
+
export var Tracker = /*#__PURE__*/function () {
|
|
14
|
+
function Tracker(id, extra) {
|
|
15
|
+
_classCallCheck(this, Tracker);
|
|
16
|
+
this.startTime = void 0;
|
|
17
|
+
this.endTime = void 0;
|
|
18
|
+
this.extra = void 0;
|
|
19
|
+
this.id = void 0;
|
|
20
|
+
this.id = id || v4();
|
|
21
|
+
this.startTime = Date.now();
|
|
22
|
+
this.extra = extra || {};
|
|
23
|
+
}
|
|
24
|
+
_createClass(Tracker, [{
|
|
25
|
+
key: "clearAll",
|
|
26
|
+
value: function clearAll() {
|
|
27
|
+
this.startTime = undefined;
|
|
28
|
+
this.endTime = undefined;
|
|
29
|
+
}
|
|
30
|
+
}, {
|
|
31
|
+
key: "getDuration",
|
|
32
|
+
value: function getDuration() {
|
|
33
|
+
if (this.endTime && this.startTime) {
|
|
34
|
+
return this.endTime - this.startTime;
|
|
35
|
+
}
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
}, {
|
|
39
|
+
key: "log",
|
|
40
|
+
value: function log() {
|
|
41
|
+
var result = {
|
|
42
|
+
id: this.id,
|
|
43
|
+
startTime: this.startTime,
|
|
44
|
+
endTime: this.endTime,
|
|
45
|
+
duration: this.getDuration(),
|
|
46
|
+
extra: this.extra
|
|
47
|
+
};
|
|
48
|
+
this.clearAll();
|
|
49
|
+
return result;
|
|
50
|
+
}
|
|
51
|
+
}]);
|
|
52
|
+
return Tracker;
|
|
53
|
+
}();
|
|
54
|
+
export var LibroViewTracker = (_dec = singleton(), _dec2 = inject(ConfigurationService), _dec(_class = (_class2 = /*#__PURE__*/function () {
|
|
55
|
+
function LibroViewTracker() {
|
|
56
|
+
_classCallCheck(this, LibroViewTracker);
|
|
57
|
+
this.viewCache = new Map();
|
|
58
|
+
this.modelCache = new Map();
|
|
59
|
+
this.spmTracker = new Map();
|
|
60
|
+
_initializerDefineProperty(this, "configurationService", _descriptor, this);
|
|
61
|
+
this.isEnabledSpmReporter = void 0;
|
|
62
|
+
this.onTrackerEmitter = new Emitter();
|
|
63
|
+
}
|
|
64
|
+
_createClass(LibroViewTracker, [{
|
|
65
|
+
key: "onTracker",
|
|
66
|
+
get: function get() {
|
|
67
|
+
return this.onTrackerEmitter.event;
|
|
68
|
+
}
|
|
69
|
+
}, {
|
|
70
|
+
key: "getOrCreateSpmTracker",
|
|
71
|
+
value: function getOrCreateSpmTracker(options) {
|
|
72
|
+
var id = options.id || v4();
|
|
73
|
+
var exist = this.spmTracker.get(id);
|
|
74
|
+
if (exist) {
|
|
75
|
+
if (!exist.startTime) {
|
|
76
|
+
exist.startTime = Date.now();
|
|
77
|
+
}
|
|
78
|
+
return exist;
|
|
79
|
+
}
|
|
80
|
+
var tracker = new Tracker(id);
|
|
81
|
+
this.spmTracker.set(id, tracker);
|
|
82
|
+
return tracker;
|
|
83
|
+
}
|
|
84
|
+
}, {
|
|
85
|
+
key: "tracker",
|
|
86
|
+
value: function tracker(_tracker) {
|
|
87
|
+
var trackerLog = _tracker.log();
|
|
88
|
+
this.onTrackerEmitter.fire(trackerLog);
|
|
89
|
+
}
|
|
90
|
+
}]);
|
|
91
|
+
return LibroViewTracker;
|
|
92
|
+
}(), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "configurationService", [_dec2], {
|
|
93
|
+
configurable: true,
|
|
94
|
+
enumerable: true,
|
|
95
|
+
writable: true,
|
|
96
|
+
initializer: null
|
|
97
|
+
})), _class2)) || _class);
|
package/es/libro-view.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { LibroContextKey } from './libro-context-key.js';
|
|
|
9
9
|
import { NotebookService } from './libro-protocol.js';
|
|
10
10
|
import type { CellOptions, CellView, DndContentProps, DndItemProps, NotebookView, NotebookModel, NotebookOption } from './libro-protocol.js';
|
|
11
11
|
import { LibroService } from './libro-service.js';
|
|
12
|
+
import { LibroViewTracker } from './libro-view-tracker.js';
|
|
12
13
|
import { LibroSlotManager } from './slot/index.js';
|
|
13
14
|
import { VirtualizedManagerHelper } from './virtualized-manager-helper.js';
|
|
14
15
|
import type { VirtualizedManager } from './virtualized-manager.js';
|
|
@@ -38,6 +39,7 @@ export declare class LibroView extends BaseView implements NotebookView {
|
|
|
38
39
|
libroService: LibroService;
|
|
39
40
|
libroSlotManager: LibroSlotManager;
|
|
40
41
|
contextKey: LibroContextKey;
|
|
42
|
+
protected libroViewTracker: LibroViewTracker;
|
|
41
43
|
protected viewManager: ViewManager;
|
|
42
44
|
protected configurationService: ConfigurationService;
|
|
43
45
|
protected virtualizedManager: VirtualizedManager;
|
package/es/libro-view.d.ts.map
CHANGED
|
@@ -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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AqChD;;;;;;;;;OASG;IACH,sBAAsB,IAClB;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAChC;QAAE,IAAI,EAAE,IAAI,CAAC;QAAC,MAAM,EAAE,IAAI,CAAA;KAAE;IAsBhC,qBAAqB,SAAU,QAAQ,UAYrC;IAEF,sBAAsB,SAAU,QAAQ,UAatC;IAEF,yBAAyB,aAOvB;IAEF,wBAAwB,aAOtB;IAEF,QAAQ,UAAS;IAER,OAAO;IAShB,gBAAgB,cAAe,OAAO,UAUpC;IAEF,aAAa,aAIX;IAEF,cAAc,SAAU,QAAQ,UAO9B;IAEF,YAAY,SAAU,QAAQ,UAO5B;IAEF,cAAc,SAAgB,QAAQ,mBA+BpC;IAEF,cAAc,SAAgB,QAAQ,mBA8BpC;IAEF,UAAU,SAAgB,QAAQ,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
|
@@ -1,5 +1,5 @@
|
|
|
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, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _dec10, _dec11, _dec12, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7, _descriptor8, _descriptor9, _descriptor10;
|
|
2
|
+
var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _dec10, _dec11, _dec12, _dec13, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7, _descriptor8, _descriptor9, _descriptor10, _descriptor11;
|
|
3
3
|
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; }
|
|
4
4
|
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; }
|
|
5
5
|
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; }
|
|
@@ -45,6 +45,7 @@ import { LibroModel } from "./libro-model.js";
|
|
|
45
45
|
import { NotebookService, notebookViewFactoryId } from "./libro-protocol.js";
|
|
46
46
|
import { LibroService } from "./libro-service.js";
|
|
47
47
|
import { AutoInsertWhenNoCell, EnterEditModeWhenAddCell, HeaderToolbarVisible, RightContentFixed } from "./libro-setting.js";
|
|
48
|
+
import { LibroViewTracker } from "./libro-view-tracker.js";
|
|
48
49
|
import { LibroSlotManager, LibroSlotView } from "./slot/index.js";
|
|
49
50
|
import { useSize } from "./utils/index.js";
|
|
50
51
|
import { VirtualizedManagerHelper } from "./virtualized-manager-helper.js";
|
|
@@ -207,7 +208,7 @@ export var LibroRender = /*#__PURE__*/forwardRef(function LibroRender(props, ref
|
|
|
207
208
|
children: /*#__PURE__*/_jsx(LibroContentComponent, {})
|
|
208
209
|
});
|
|
209
210
|
});
|
|
210
|
-
export var LibroView = (_dec = transient(), _dec2 = view(notebookViewFactoryId), _dec3 = prop(), _dec4 = inject(CellService), _dec5 = inject(LibroService), _dec6 = inject(LibroSlotManager), _dec7 = inject(LibroContextKey), _dec8 = inject(
|
|
211
|
+
export var LibroView = (_dec = transient(), _dec2 = view(notebookViewFactoryId), _dec3 = prop(), _dec4 = inject(CellService), _dec5 = inject(LibroService), _dec6 = inject(LibroSlotManager), _dec7 = inject(LibroContextKey), _dec8 = inject(LibroViewTracker), _dec9 = inject(ViewManager), _dec10 = inject(ConfigurationService), _dec11 = prop(), _dec12 = prop(), _dec13 = prop(), _dec(_class = _dec2(_class = (_class2 = /*#__PURE__*/function (_BaseView) {
|
|
211
212
|
_inherits(LibroView, _BaseView);
|
|
212
213
|
var _super = _createSuper(LibroView);
|
|
213
214
|
function LibroView(_options, collapseServiceFactory, notebookService, virtualizedManagerHelper) {
|
|
@@ -233,17 +234,18 @@ export var LibroView = (_dec = transient(), _dec2 = view(notebookViewFactoryId),
|
|
|
233
234
|
_initializerDefineProperty(_this, "libroService", _descriptor3, _assertThisInitialized(_this));
|
|
234
235
|
_initializerDefineProperty(_this, "libroSlotManager", _descriptor4, _assertThisInitialized(_this));
|
|
235
236
|
_initializerDefineProperty(_this, "contextKey", _descriptor5, _assertThisInitialized(_this));
|
|
236
|
-
_initializerDefineProperty(_this, "
|
|
237
|
-
_initializerDefineProperty(_this, "
|
|
237
|
+
_initializerDefineProperty(_this, "libroViewTracker", _descriptor6, _assertThisInitialized(_this));
|
|
238
|
+
_initializerDefineProperty(_this, "viewManager", _descriptor7, _assertThisInitialized(_this));
|
|
239
|
+
_initializerDefineProperty(_this, "configurationService", _descriptor8, _assertThisInitialized(_this));
|
|
238
240
|
_this.virtualizedManager = void 0;
|
|
239
241
|
_this.virtualizedManagerHelper = void 0;
|
|
240
242
|
_this.notebookService = void 0;
|
|
241
243
|
_this.collapseService = void 0;
|
|
242
244
|
_this.isDragging = false;
|
|
243
245
|
_this.clipboard = void 0;
|
|
244
|
-
_initializerDefineProperty(_this, "collapserVisible",
|
|
245
|
-
_initializerDefineProperty(_this, "outputsScroll",
|
|
246
|
-
_initializerDefineProperty(_this, "saving",
|
|
246
|
+
_initializerDefineProperty(_this, "collapserVisible", _descriptor9, _assertThisInitialized(_this));
|
|
247
|
+
_initializerDefineProperty(_this, "outputsScroll", _descriptor10, _assertThisInitialized(_this));
|
|
248
|
+
_initializerDefineProperty(_this, "saving", _descriptor11, _assertThisInitialized(_this));
|
|
247
249
|
_this.onSaveEmitter = new Emitter();
|
|
248
250
|
_this.onCellContentChangedEmitter = new Emitter();
|
|
249
251
|
_this.runCellEmitter = new Emitter();
|
|
@@ -320,16 +322,24 @@ export var LibroView = (_dec = transient(), _dec2 = view(notebookViewFactoryId),
|
|
|
320
322
|
};
|
|
321
323
|
_this.addCell = /*#__PURE__*/function () {
|
|
322
324
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(option, position) {
|
|
323
|
-
var cellView;
|
|
325
|
+
var id, libroTracker, cellView;
|
|
324
326
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
325
327
|
while (1) switch (_context3.prev = _context3.next) {
|
|
326
328
|
case 0:
|
|
327
|
-
|
|
329
|
+
if (_this.libroViewTracker.isEnabledSpmReporter && option.id) {
|
|
330
|
+
id = option.id + _this.id;
|
|
331
|
+
libroTracker = _this.libroViewTracker.getOrCreateSpmTracker({
|
|
332
|
+
id: id
|
|
333
|
+
});
|
|
334
|
+
libroTracker.extra.cellsCount = _this.model.cells.length;
|
|
335
|
+
libroTracker.extra.cellOperation = 'add';
|
|
336
|
+
}
|
|
337
|
+
_context3.next = 3;
|
|
328
338
|
return _this.getCellViewByOption(option);
|
|
329
|
-
case
|
|
339
|
+
case 3:
|
|
330
340
|
cellView = _context3.sent;
|
|
331
341
|
_this.model.addCell(cellView, position);
|
|
332
|
-
case
|
|
342
|
+
case 5:
|
|
333
343
|
case "end":
|
|
334
344
|
return _context3.stop();
|
|
335
345
|
}
|
|
@@ -341,16 +351,24 @@ export var LibroView = (_dec = transient(), _dec2 = view(notebookViewFactoryId),
|
|
|
341
351
|
}();
|
|
342
352
|
_this.addCellAbove = /*#__PURE__*/function () {
|
|
343
353
|
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(option, position) {
|
|
344
|
-
var cellView;
|
|
354
|
+
var id, libroTracker, cellView;
|
|
345
355
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
346
356
|
while (1) switch (_context4.prev = _context4.next) {
|
|
347
357
|
case 0:
|
|
348
|
-
|
|
358
|
+
if (_this.libroViewTracker.isEnabledSpmReporter && option.id) {
|
|
359
|
+
id = option.id + _this.id;
|
|
360
|
+
libroTracker = _this.libroViewTracker.getOrCreateSpmTracker({
|
|
361
|
+
id: id
|
|
362
|
+
});
|
|
363
|
+
libroTracker.extra.cellsCount = _this.model.cells.length;
|
|
364
|
+
libroTracker.extra.cellOperation = 'add';
|
|
365
|
+
}
|
|
366
|
+
_context4.next = 3;
|
|
349
367
|
return _this.getCellViewByOption(option);
|
|
350
|
-
case
|
|
368
|
+
case 3:
|
|
351
369
|
cellView = _context4.sent;
|
|
352
370
|
_this.model.addCell(cellView, position, 'above');
|
|
353
|
-
case
|
|
371
|
+
case 5:
|
|
354
372
|
case "end":
|
|
355
373
|
return _context4.stop();
|
|
356
374
|
}
|
|
@@ -371,6 +389,14 @@ export var LibroView = (_dec = transient(), _dec2 = view(notebookViewFactoryId),
|
|
|
371
389
|
return -1;
|
|
372
390
|
};
|
|
373
391
|
_this.deleteCell = function (cell) {
|
|
392
|
+
if (_this.libroViewTracker.isEnabledSpmReporter && cell.model.id) {
|
|
393
|
+
var id = cell.model.id + _this.id;
|
|
394
|
+
var libroTracker = _this.libroViewTracker.getOrCreateSpmTracker({
|
|
395
|
+
id: id
|
|
396
|
+
});
|
|
397
|
+
libroTracker.extra.cellsCount = _this.model.cells.length;
|
|
398
|
+
libroTracker.extra.cellOperation = 'delete';
|
|
399
|
+
}
|
|
374
400
|
var deleteIndex = _this.model.getCells().findIndex(function (item) {
|
|
375
401
|
return equals(item, cell);
|
|
376
402
|
});
|
|
@@ -1800,6 +1826,14 @@ export var LibroView = (_dec = transient(), _dec2 = view(notebookViewFactoryId),
|
|
|
1800
1826
|
var _this2$model$onChange, _this2$model;
|
|
1801
1827
|
(_this2$model$onChange = (_this2$model = _this2.model).onChange) === null || _this2$model$onChange === void 0 || _this2$model$onChange.call(_this2$model);
|
|
1802
1828
|
}));
|
|
1829
|
+
if (_this2.libroViewTracker.isEnabledSpmReporter) {
|
|
1830
|
+
var libroTracker = _this2.libroViewTracker.getOrCreateSpmTracker({
|
|
1831
|
+
id: _this2.id
|
|
1832
|
+
});
|
|
1833
|
+
libroTracker.endTime = Date.now();
|
|
1834
|
+
libroTracker.extra.cellsCount = _this2.model.cells.length;
|
|
1835
|
+
_this2.libroViewTracker.tracker(libroTracker);
|
|
1836
|
+
}
|
|
1803
1837
|
_this2.initializedDefer.resolve();
|
|
1804
1838
|
}, 0);
|
|
1805
1839
|
case 8:
|
|
@@ -2052,31 +2086,36 @@ export var LibroView = (_dec = transient(), _dec2 = view(notebookViewFactoryId),
|
|
|
2052
2086
|
enumerable: true,
|
|
2053
2087
|
writable: true,
|
|
2054
2088
|
initializer: null
|
|
2055
|
-
}), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, "
|
|
2089
|
+
}), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, "libroViewTracker", [_dec8], {
|
|
2090
|
+
configurable: true,
|
|
2091
|
+
enumerable: true,
|
|
2092
|
+
writable: true,
|
|
2093
|
+
initializer: null
|
|
2094
|
+
}), _descriptor7 = _applyDecoratedDescriptor(_class2.prototype, "viewManager", [_dec9], {
|
|
2056
2095
|
configurable: true,
|
|
2057
2096
|
enumerable: true,
|
|
2058
2097
|
writable: true,
|
|
2059
2098
|
initializer: null
|
|
2060
|
-
}),
|
|
2099
|
+
}), _descriptor8 = _applyDecoratedDescriptor(_class2.prototype, "configurationService", [_dec10], {
|
|
2061
2100
|
configurable: true,
|
|
2062
2101
|
enumerable: true,
|
|
2063
2102
|
writable: true,
|
|
2064
2103
|
initializer: null
|
|
2065
|
-
}),
|
|
2104
|
+
}), _descriptor9 = _applyDecoratedDescriptor(_class2.prototype, "collapserVisible", [_dec11], {
|
|
2066
2105
|
configurable: true,
|
|
2067
2106
|
enumerable: true,
|
|
2068
2107
|
writable: true,
|
|
2069
2108
|
initializer: function initializer() {
|
|
2070
2109
|
return false;
|
|
2071
2110
|
}
|
|
2072
|
-
}),
|
|
2111
|
+
}), _descriptor10 = _applyDecoratedDescriptor(_class2.prototype, "outputsScroll", [_dec12], {
|
|
2073
2112
|
configurable: true,
|
|
2074
2113
|
enumerable: true,
|
|
2075
2114
|
writable: true,
|
|
2076
2115
|
initializer: function initializer() {
|
|
2077
2116
|
return false;
|
|
2078
2117
|
}
|
|
2079
|
-
}),
|
|
2118
|
+
}), _descriptor11 = _applyDecoratedDescriptor(_class2.prototype, "saving", [_dec13], {
|
|
2080
2119
|
configurable: true,
|
|
2081
2120
|
enumerable: true,
|
|
2082
2121
|
writable: true,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@difizen/libro-core",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.9",
|
|
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.
|
|
38
|
-
"@difizen/libro-common": "^0.3.
|
|
39
|
-
"@difizen/libro-shared-model": "^0.3.
|
|
40
|
-
"@difizen/libro-virtualized": "^0.3.
|
|
37
|
+
"@difizen/libro-code-editor": "^0.3.9",
|
|
38
|
+
"@difizen/libro-common": "^0.3.9",
|
|
39
|
+
"@difizen/libro-shared-model": "^0.3.9",
|
|
40
|
+
"@difizen/libro-virtualized": "^0.3.9",
|
|
41
41
|
"@difizen/mana-app": "latest",
|
|
42
42
|
"@difizen/mana-l10n": "latest",
|
|
43
43
|
"@difizen/mana-react": "latest",
|
|
@@ -5,6 +5,7 @@ import { contrib, inject, singleton } from '@difizen/mana-app';
|
|
|
5
5
|
|
|
6
6
|
import type { CellView, CellModel, CellOptions } from '../libro-protocol.js';
|
|
7
7
|
import { LibroService } from '../libro-service.js';
|
|
8
|
+
import { LibroViewTracker } from '../libro-view-tracker.js';
|
|
8
9
|
|
|
9
10
|
import type { CellMeta } from './libro-cell-protocol.js';
|
|
10
11
|
import {
|
|
@@ -24,6 +25,7 @@ export class LibroCellService implements CellService, ApplicationContribution {
|
|
|
24
25
|
protected cellTypeToModelContribution: Map<string, CellModelContribution> = new Map();
|
|
25
26
|
protected readonly viewManager: ViewManager;
|
|
26
27
|
protected modelCache: Map<string, Map<string, CellModel>> = new Map();
|
|
28
|
+
@inject(LibroViewTracker) libroViewTracker: LibroViewTracker;
|
|
27
29
|
|
|
28
30
|
libroService: LibroService;
|
|
29
31
|
constructor(
|
|
@@ -12,6 +12,7 @@ import type { CellView, NotebookView } from '../libro-protocol.js';
|
|
|
12
12
|
|
|
13
13
|
import { CellService } from './libro-cell-protocol.js';
|
|
14
14
|
import type { LibroCell } from './libro-cell-protocol.js';
|
|
15
|
+
import type { LibroCellService } from './libro-cell-service.js';
|
|
15
16
|
import { ExecutableCellModel } from './libro-executable-cell-model.js';
|
|
16
17
|
|
|
17
18
|
export const LibroCellComponent = React.forwardRef(function LibroCellComponent() {
|
|
@@ -83,6 +84,35 @@ export class LibroCellView extends BaseView implements CellView {
|
|
|
83
84
|
this.cellWatch();
|
|
84
85
|
}
|
|
85
86
|
|
|
87
|
+
override onViewMount(): void {
|
|
88
|
+
if (
|
|
89
|
+
(this.cellService as LibroCellService).libroViewTracker.isEnabledSpmReporter &&
|
|
90
|
+
this.options.id
|
|
91
|
+
) {
|
|
92
|
+
const cellTracker = (
|
|
93
|
+
this.cellService as LibroCellService
|
|
94
|
+
).libroViewTracker.getOrCreateSpmTracker({
|
|
95
|
+
id: this.options.id + this.parent.id,
|
|
96
|
+
});
|
|
97
|
+
cellTracker.endTime = Date.now();
|
|
98
|
+
cellTracker.extra.cellType = this.model.type;
|
|
99
|
+
(this.cellService as LibroCellService).libroViewTracker.tracker(cellTracker);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
override onViewUnmount(): void {
|
|
104
|
+
if ((this.cellService as LibroCellService).libroViewTracker.isEnabledSpmReporter) {
|
|
105
|
+
const cellTracker = (
|
|
106
|
+
this.cellService as LibroCellService
|
|
107
|
+
).libroViewTracker.getOrCreateSpmTracker({
|
|
108
|
+
id: this.model.id + this.parent.id,
|
|
109
|
+
});
|
|
110
|
+
cellTracker.endTime = Date.now();
|
|
111
|
+
cellTracker.extra.cellType = this.model.type;
|
|
112
|
+
(this.cellService as LibroCellService).libroViewTracker.tracker(cellTracker);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
86
116
|
cellWatch() {
|
|
87
117
|
this.toDispose.push(
|
|
88
118
|
watch(this.model, 'value', () => {
|
|
@@ -9,13 +9,19 @@ import {
|
|
|
9
9
|
import { equals } from '@difizen/mana-app';
|
|
10
10
|
import { v4 } from 'uuid';
|
|
11
11
|
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
LibroCellView,
|
|
14
|
+
ExecutableCellModel,
|
|
15
|
+
EditorCellView,
|
|
16
|
+
LibroCellService,
|
|
17
|
+
} from '../cell/index.js';
|
|
13
18
|
import type { LibroEditorCellView } from '../cell/index.js';
|
|
14
19
|
import { LibroContextKey } from '../libro-context-key.js';
|
|
15
20
|
import type { LibroModel } from '../libro-model.js';
|
|
16
21
|
import type { CellView, NotebookView } from '../libro-protocol.js';
|
|
17
22
|
import { LibroToolbarArea } from '../libro-protocol.js';
|
|
18
23
|
import { LibroService } from '../libro-service.js';
|
|
24
|
+
import { LibroViewTracker } from '../libro-view-tracker.js';
|
|
19
25
|
import { LibroView } from '../libro-view.js';
|
|
20
26
|
import { SettingsModal } from '../settings/settings-modal.js';
|
|
21
27
|
import { RestartClearOutputModal } from '../toolbar/restart-clear-outputs-modal.js';
|
|
@@ -30,7 +36,9 @@ export class LibroCommandContribution implements CommandContribution {
|
|
|
30
36
|
@inject(ModalService) protected readonly modalService: ModalService;
|
|
31
37
|
@inject(LibroCommandRegister) protected readonly libroCommand: LibroCommandRegister;
|
|
32
38
|
@inject(LibroService) protected readonly libroService: LibroService;
|
|
39
|
+
@inject(LibroCellService) protected readonly cellService: LibroCellService;
|
|
33
40
|
@inject(LibroContextKey) protected readonly libroContextKey: LibroContextKey;
|
|
41
|
+
@inject(LibroViewTracker) protected libroViewTracker: LibroViewTracker;
|
|
34
42
|
|
|
35
43
|
registerCommands(command: CommandRegistry): void {
|
|
36
44
|
this.libroCommand.registerLibroCommand(command, NotebookCommands['EnterEditMode'], {
|
|
@@ -250,23 +258,31 @@ export class LibroCommandContribution implements CommandContribution {
|
|
|
250
258
|
if (!libro || !(libro instanceof LibroView)) {
|
|
251
259
|
return;
|
|
252
260
|
}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
261
|
+
const createNewCell = (cellType: string) => ({
|
|
262
|
+
id: v4(),
|
|
263
|
+
cell: { cell_type: cellType, source: '', metadata: {} },
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
const newCell =
|
|
267
|
+
!cell || !(cell instanceof LibroCellView)
|
|
268
|
+
? createNewCell('code')
|
|
269
|
+
: createNewCell(cell.model.type);
|
|
270
|
+
|
|
271
|
+
const insertIndex =
|
|
272
|
+
!cell || !(cell instanceof LibroCellView)
|
|
273
|
+
? 0
|
|
274
|
+
: libro.model.cells.findIndex((item) => equals(item, cell)) + 1;
|
|
275
|
+
|
|
276
|
+
libro.addCell(newCell, insertIndex);
|
|
277
|
+
if (this.libroViewTracker.isEnabledSpmReporter) {
|
|
278
|
+
const id = newCell.id + libro.id;
|
|
279
|
+
const libroTracker = this.libroViewTracker.getOrCreateSpmTracker({
|
|
280
|
+
id,
|
|
281
|
+
});
|
|
282
|
+
libroTracker.extra.cellsCount = libro.model.cells.length;
|
|
283
|
+
libroTracker.extra.cellOperation = 'add';
|
|
267
284
|
}
|
|
268
285
|
},
|
|
269
|
-
// isVisible: () => false,
|
|
270
286
|
isVisible: (cell, libro, path) => {
|
|
271
287
|
if (!libro || !(libro instanceof LibroView)) {
|
|
272
288
|
return false;
|
|
@@ -296,13 +312,11 @@ export class LibroCommandContribution implements CommandContribution {
|
|
|
296
312
|
}
|
|
297
313
|
const cellIndex = libro.model.cells.findIndex((item) => equals(item, cell));
|
|
298
314
|
if (cellIndex > -1) {
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
cellIndex,
|
|
305
|
-
);
|
|
315
|
+
const cellOptions = {
|
|
316
|
+
id: v4(),
|
|
317
|
+
cell: { cell_type: cell.model.type, source: '', metadata: {} },
|
|
318
|
+
};
|
|
319
|
+
libro.addCellAbove(cellOptions, cellIndex);
|
|
306
320
|
}
|
|
307
321
|
},
|
|
308
322
|
isEnabled: (cell, libro) => {
|
package/src/libro-protocol.ts
CHANGED
|
@@ -39,9 +39,6 @@ export interface NotebookOption extends Options {
|
|
|
39
39
|
[key: string]: any;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
export const PerformaceStatisticOption = Symbol('PerformaceStatisticOption');
|
|
43
|
-
export type PerformaceStatisticOption = Options;
|
|
44
|
-
|
|
45
42
|
export const ModelFactory = Symbol('ModelFactory');
|
|
46
43
|
export type ModelFactory<T = NotebookOption> = (options: T) => NotebookModel;
|
|
47
44
|
|
|
@@ -58,6 +55,13 @@ export type Options = {
|
|
|
58
55
|
[key: string]: any;
|
|
59
56
|
};
|
|
60
57
|
|
|
58
|
+
export interface ITracker {
|
|
59
|
+
id: string;
|
|
60
|
+
[key: string]: any;
|
|
61
|
+
startTime?: number;
|
|
62
|
+
endTime?: number;
|
|
63
|
+
}
|
|
64
|
+
|
|
61
65
|
export interface ScrollParams {
|
|
62
66
|
cellIndex: number;
|
|
63
67
|
cellOffset?: number;
|
package/src/libro-service.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Disposable } from '@difizen/mana-app';
|
|
2
2
|
import { DisposableCollection, Emitter } from '@difizen/mana-app';
|
|
3
3
|
import { ThemeService, ViewManager } from '@difizen/mana-app';
|
|
4
|
-
import { inject, singleton } from '@difizen/mana-app';
|
|
4
|
+
import { inject, singleton, ConfigurationService } from '@difizen/mana-app';
|
|
5
5
|
import { prop } from '@difizen/mana-app';
|
|
6
6
|
|
|
7
7
|
import type {
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
ModelFactory,
|
|
16
16
|
NotebookService,
|
|
17
17
|
} from './libro-protocol.js';
|
|
18
|
+
import { SpmReporter } from './libro-setting.js';
|
|
18
19
|
import { LibroViewTracker } from './libro-view-tracker.js';
|
|
19
20
|
|
|
20
21
|
export interface NotebookViewChange {
|
|
@@ -37,6 +38,7 @@ export class LibroService implements NotebookService, Disposable {
|
|
|
37
38
|
protected toDispose = new DisposableCollection();
|
|
38
39
|
@inject(ModelFactory) protected libroModelFactory: ModelFactory;
|
|
39
40
|
@inject(ViewManager) protected viewManager: ViewManager;
|
|
41
|
+
@inject(ConfigurationService) configurationService: ConfigurationService;
|
|
40
42
|
@inject(LibroViewTracker) protected libroViewTracker: LibroViewTracker;
|
|
41
43
|
protected themeService: ThemeService;
|
|
42
44
|
@prop()
|
|
@@ -142,6 +144,10 @@ export class LibroService implements NotebookService, Disposable {
|
|
|
142
144
|
return model;
|
|
143
145
|
}
|
|
144
146
|
async getOrCreateView(options: NotebookOption): Promise<NotebookView> {
|
|
147
|
+
const isEnabledSpmReporter = await this.configurationService.get(SpmReporter);
|
|
148
|
+
if (isEnabledSpmReporter) {
|
|
149
|
+
this.libroViewTracker.getOrCreateSpmTracker(options);
|
|
150
|
+
}
|
|
145
151
|
const model = this.getOrCreateModel(options);
|
|
146
152
|
const notebookViewPromise = this.viewManager.getOrCreateView<NotebookView>(
|
|
147
153
|
notebookViewFactoryId,
|
package/src/libro-setting.ts
CHANGED
|
@@ -108,3 +108,14 @@ export const SupportCodeFormat: ConfigurationNode<boolean> = {
|
|
|
108
108
|
type: 'boolean',
|
|
109
109
|
},
|
|
110
110
|
};
|
|
111
|
+
|
|
112
|
+
export const SpmReporter: ConfigurationNode<boolean> = {
|
|
113
|
+
id: 'libro.spm.reporter',
|
|
114
|
+
description: l10n.t('是否支持数据日志'),
|
|
115
|
+
title: l10n.t('是否支持数据日志'),
|
|
116
|
+
type: 'checkbox',
|
|
117
|
+
defaultValue: false,
|
|
118
|
+
schema: {
|
|
119
|
+
type: 'boolean',
|
|
120
|
+
},
|
|
121
|
+
};
|