@univerjs/action-recorder 0.20.1 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/lib/cjs/index.js +657 -1
  2. package/lib/cjs/locale/ca-ES.js +12 -1
  3. package/lib/cjs/locale/en-US.js +27 -1
  4. package/lib/cjs/locale/es-ES.js +12 -1
  5. package/lib/cjs/locale/fa-IR.js +12 -1
  6. package/lib/cjs/locale/fr-FR.js +12 -1
  7. package/lib/cjs/locale/ja-JP.js +12 -1
  8. package/lib/cjs/locale/ko-KR.js +12 -1
  9. package/lib/cjs/locale/ru-RU.js +12 -1
  10. package/lib/cjs/locale/sk-SK.js +12 -1
  11. package/lib/cjs/locale/vi-VN.js +12 -1
  12. package/lib/cjs/locale/zh-CN.js +12 -1
  13. package/lib/cjs/locale/zh-TW.js +12 -1
  14. package/lib/es/index.js +639 -1
  15. package/lib/es/locale/ca-ES.js +11 -1
  16. package/lib/es/locale/en-US.js +26 -1
  17. package/lib/es/locale/es-ES.js +11 -1
  18. package/lib/es/locale/fa-IR.js +11 -1
  19. package/lib/es/locale/fr-FR.js +11 -1
  20. package/lib/es/locale/ja-JP.js +11 -1
  21. package/lib/es/locale/ko-KR.js +11 -1
  22. package/lib/es/locale/ru-RU.js +11 -1
  23. package/lib/es/locale/sk-SK.js +11 -1
  24. package/lib/es/locale/vi-VN.js +11 -1
  25. package/lib/es/locale/zh-CN.js +11 -1
  26. package/lib/es/locale/zh-TW.js +11 -1
  27. package/lib/index.js +639 -1
  28. package/lib/locale/ca-ES.js +11 -1
  29. package/lib/locale/en-US.js +26 -1
  30. package/lib/locale/es-ES.js +11 -1
  31. package/lib/locale/fa-IR.js +11 -1
  32. package/lib/locale/fr-FR.js +11 -1
  33. package/lib/locale/ja-JP.js +11 -1
  34. package/lib/locale/ko-KR.js +11 -1
  35. package/lib/locale/ru-RU.js +11 -1
  36. package/lib/locale/sk-SK.js +11 -1
  37. package/lib/locale/vi-VN.js +11 -1
  38. package/lib/locale/zh-CN.js +11 -1
  39. package/lib/locale/zh-TW.js +11 -1
  40. package/lib/umd/index.js +1 -1
  41. package/package.json +9 -9
package/lib/cjs/index.js CHANGED
@@ -1 +1,657 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`@univerjs/core`),t=require(`@univerjs/icons`),n=require(`@univerjs/sheets`),r=require(`@univerjs/sheets-filter`),i=require(`@univerjs/sheets-ui`),a=require(`@univerjs/ui`),o=require(`rxjs`),s=require(`@univerjs/design`),c=require(`react`),l=require(`react/jsx-runtime`);var u=`@univerjs/action-recorder`,d=`0.20.1`;const f=`action-recorder.config`;Symbol(f);const p={};function m(e){"@babel/helpers - typeof";return m=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},m(e)}function h(e,t){if(m(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(m(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function g(e){var t=h(e,`string`);return m(t)==`symbol`?t:t+``}function _(e,t,n){return(t=g(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function v(e,t){return function(n,r){t(n,r,e)}}function y(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let b=class extends e.Disposable{get recording(){return this._recording$.getValue()}get _recorded(){return this._recorded$.getValue()}get _recordedCommands(){return this._recordedCommands$.getValue()}constructor(e,t,n,r){super(),this._commandSrv=e,this._logService=t,this._localFileService=n,this._instanceService=r,_(this,`_shouldRecordCommands`,new Set),_(this,`_panelOpened$`,new o.BehaviorSubject(!1)),_(this,`panelOpened$`,this._panelOpened$.asObservable()),_(this,`_recorder`,null),_(this,`_recording$`,new o.BehaviorSubject(!1)),_(this,`recording$`,this._recording$.asObservable()),_(this,`_recorded$`,new o.BehaviorSubject([])),_(this,`_recordedCommands$`,new o.BehaviorSubject([])),_(this,`recordedCommands$`,this._recordedCommands$.asObservable())}registerRecordedCommand(t){if(t.type===e.CommandType.MUTATION)throw Error(`[CommandRecorderService] Cannot record mutation commands.`);this._shouldRecordCommands.add(t.id)}togglePanel(e){this._panelOpened$.next(e),e===!1&&this.stopRecording()}startRecording(t=!1){this._recorder=this._commandSrv.onCommandExecuted(r=>{if(this._shouldRecordCommands.has(r.id)){var i;let o=this._recorded,s=this._recordedCommands,c={...r},l=(i=this._instanceService.getFocusedUnit())==null?void 0:i.getUnitId(),{unitId:u=l,subUnitId:d}=c==null?void 0:c.params;if(t&&u&&d){var a;let e=(a=this._instanceService.getUnit(u).getSheetBySheetId(d))==null?void 0:a.getName();c={...c,params:{...c.params,subUnitId:e}}}c.id===n.SetSelectionsOperation.id&&o.length>0&&o[o.length-1].id===n.SetSelectionsOperation.id?o[o.length-1]=c:(o.push(c),this._recorded$.next(o),c.type===e.CommandType.COMMAND&&(s.push(c),this._recordedCommands$.next(s)))}}),this._recording$.next(!0)}stopRecording(){var e;(e=this._recorder)==null||e.dispose(),this._recorder=null,this._recorded$.next([]),this._recordedCommands$.next([]),this._recording$.next(!1)}completeRecording(){let e=this._recorded.slice();this._localFileService.downloadFile(new Blob([JSON.stringify(e,null,2)]),`recorded-commands.json`),this._logService.error(`Recorded commands:`,e),this.stopRecording()}};b=y([v(0,e.ICommandService),v(1,e.ILogService),v(2,a.ILocalFileService),v(3,e.IUniverInstanceService)],b);const x={id:`action-recorder.command.start-recording`,type:e.CommandType.COMMAND,handler:(e,t)=>(e.get(b).startRecording(!!(t!=null&&t.replaceId)),!0)},S={id:`action-recorder.command.complete-recording`,type:e.CommandType.COMMAND,handler:e=>(e.get(b).completeRecording(),!0)},C={id:`action-recorder.command.stop-recording`,type:e.CommandType.COMMAND,handler:e=>(e.get(b).completeRecording(),!0)};let w=function(e){return e.DEFAULT=`default`,e.NAME=`name`,e.ACTIVE=`active`,e}({}),T=class extends e.Disposable{constructor(e,t,n,r,i){super(),this._messageService=e,this._instanceService=t,this._localFileService=n,this._logService=r,this._commandService=i}async replayLocalJSON(e=w.DEFAULT){let t=await this._localFileService.openFile({multiple:!1,accept:`.json`});if(t.length!==1)return!1;let n=t[0];try{return this.replayCommands(JSON.parse(await n.text()),{mode:e})}catch{return this._messageService.show({type:s.MessageType.Error,content:`Failed to replay commands from local file ${n.name}.`}),!1}}async replayCommands(e,t){var n;let r=(n=this._instanceService.getFocusedUnit())==null?void 0:n.getUnitId();r||this._logService.error(`[ReplayService]`,`no focused unit to replay commands`);let{mode:i}=t||{};for(let t of e){let{id:e,params:n}=t,s=n;if(s){if(s.unitId!==void 0&&(s.unitId=r),i===w.NAME&&s.subUnitId!==`undefined`){var a;let e=(a=this._instanceService.getFocusedUnit().getSheetBySheetName(s.subUnitId))==null?void 0:a.getSheetId();e?s.subUnitId=e:this._logService.error(`[ReplayService]`,`failed to find subunit by subUnitName = ${s.subUnitId}`)}if(i===w.ACTIVE&&s.subUnitId!==`undefined`){var o;let e=(o=this._instanceService.getFocusedUnit().getActiveSheet())==null?void 0:o.getSheetId();e?s.subUnitId=e:this._logService.error(`[ReplayService]`,`failed to find active subunit`)}if(!await this._commandService.executeCommand(e,n))return!1}else if(!await this._commandService.executeCommand(e))return!1}return!0}async replayCommandsWithDelay(t){var n;let r=(n=this._instanceService.getFocusedUnit())==null?void 0:n.getUnitId();r||this._logService.error(`[ReplayService]`,`no focused unit to replay commands`);for(let n of t){await(0,e.awaitTime)(E());let{id:t,params:i}=n;if(i){if(i.unitId!==void 0&&(i.unitId=r),!await this._commandService.executeCommand(t,i))return!1}else if(!await this._commandService.executeCommand(t))return!1}return!0}};T=y([v(0,a.IMessageService),v(1,e.IUniverInstanceService),v(2,a.ILocalFileService),v(3,e.ILogService),v(4,e.ICommandService)],T);function E(){return Math.floor(Math.random()*800)+200}const D={id:`action-recorder.command.replay-local-records`,type:e.CommandType.COMMAND,handler:async e=>{let t=await e.get(T).replayLocalJSON();return t&&e.get(a.IMessageService).show({type:s.MessageType.Success,content:`Successfully replayed local records`}),t}},O={id:`action-recorder.command.replay-local-records-name`,type:e.CommandType.COMMAND,handler:async e=>{let t=await e.get(T).replayLocalJSON(w.NAME);return t&&e.get(a.IMessageService).show({type:s.MessageType.Success,content:`Successfully replayed local records`}),t}},k={id:`action-recorder.command.replay-local-records-active`,type:e.CommandType.COMMAND,handler:async e=>{let t=await e.get(T).replayLocalJSON(w.ACTIVE);return t&&e.get(a.IMessageService).show({type:s.MessageType.Success,content:`Successfully replayed local records`}),t}},A={id:`action-recorder.operation.open-panel`,type:e.CommandType.OPERATION,handler(e){return e.get(b).togglePanel(!0),!0}},j={id:`action-recorder.operation.close-panel`,type:e.CommandType.OPERATION,handler(e){return e.get(b).togglePanel(!1),!0}},M=`RECORD_MENU_ITEM`;function N(){return{id:M,type:a.MenuItemType.SUBITEMS,icon:`RecordIcon`,tooltip:`action-recorder.menu.title`}}function P(e){let t=e.get(b);return{id:A.id,title:`action-recorder.menu.record`,type:a.MenuItemType.BUTTON,disabled$:t.panelOpened$}}function F(){return{id:D.id,title:`action-recorder.menu.replay-local`,type:a.MenuItemType.BUTTON}}function I(){return{id:O.id,title:`action-recorder.menu.replay-local-name`,type:a.MenuItemType.BUTTON}}function L(){return{id:k.id,title:`action-recorder.menu.replay-local-active`,type:a.MenuItemType.BUTTON}}const R={[a.RibbonOthersGroup.OTHERS]:{[M]:{order:1,menuItemFactory:N,[A.id]:{order:1,menuItemFactory:P},[D.id]:{order:2,menuItemFactory:F},[O.id]:{order:3,menuItemFactory:I},[k.id]:{order:4,menuItemFactory:L}}}};function z(){return(0,a.useObservable)((0,a.useDependency)(b).panelOpened$)?(0,l.jsx)(B,{}):null}function B(){var n;let r=(0,a.useDependency)(e.ICommandService),i=(0,a.useDependency)(b),o=(0,a.useObservable)(i.recording$),u=(0,a.useObservable)(i.recordedCommands$),d=(n=u==null?void 0:u.length)==null?0:n,f=(0,c.useCallback)(()=>{o||r.executeCommand(j.id)},[r,o]),p=(0,c.useCallback)(e=>{o||r.executeCommand(x.id,{replaceId:e})},[r,o]),m=(0,c.useCallback)(()=>{o&&r.executeCommand(S.id)},[r,o]),h=(0,c.useCallback)(()=>{o&&r.executeCommand(C.id)},[r,o]),g=o?d===0?`Recording...`:`${d}: ${u[d-1].id}`:`Start Recording`;return(0,l.jsxs)(`div`,{className:`univer-fixed univer-bottom-20 univer-left-1/2 univer-z-[1000] univer-flex univer-h-16 univer-w-[512px] -univer-translate-x-1/2 univer-items-center univer-rounded-lg univer-bg-white univer-px-5 univer-shadow-lg`,children:[(0,l.jsx)(`div`,{className:`univer-mr-2 univer-size-5 univer-shrink-0 univer-grow-0 univer-text-xl`,children:(0,l.jsx)(t.RecordIcon,{})}),(0,l.jsx)(`div`,{className:`univer-flex-1 univer-text-sm`,children:g}),(0,l.jsxs)(`div`,{className:`univer-flex univer-w-64 univer-shrink-0 univer-grow-0 univer-justify-between`,children:[(0,l.jsx)(s.Button,{className:`univer-w-20`,onClick:o?h:f,children:o?`Cancel`:`Close`}),(0,l.jsx)(s.Button,{className:`univer-w-20`,variant:`primary`,onClick:o?m:()=>p(),children:o?`Save`:`Start`}),!o&&(0,l.jsx)(s.Button,{variant:`primary`,onClick:()=>p(!0),children:`Start(N)`})]})]})}let V=class extends e.Disposable{constructor(e,t,n,r,i,a){super(),this._commandSrv=e,this._uiPartsSrv=t,this._menuManagerService=n,this._componentManager=r,this._actionRecorderService=i,this._injector=a,this._initCommands(),this._initUI(),this._initSheetsCommands(),this._initDocsCommands()}_initCommands(){[x,C,S,A,j,D,O,k].forEach(e=>this._commandSrv.registerCommand(e))}_initUI(){this._uiPartsSrv.registerComponent(a.BuiltInUIPart.GLOBAL,()=>(0,a.connectInjector)(z,this._injector)),this.disposeWithMe(this._componentManager.register(`RecordIcon`,t.RecordIcon)),this._menuManagerService.mergeMenu(R)}_initSheetsCommands(){[n.CopySheetCommand,n.DeleteRangeMoveLeftCommand,n.DeleteRangeMoveUpCommand,n.DeltaColumnWidthCommand,n.DeltaRowHeightCommand,n.InsertSheetCommand,n.InsertColAfterCommand,n.InsertColBeforeCommand,n.InsertRowAfterCommand,n.InsertRowBeforeCommand,n.RemoveSheetCommand,n.SetStyleCommand,n.AddWorksheetMergeCommand,n.AddWorksheetMergeAllCommand,n.AddWorksheetMergeVerticalCommand,n.AddWorksheetMergeHorizontalCommand,n.SetFrozenCommand,n.CancelFrozenCommand,n.SetHorizontalTextAlignCommand,n.SetOverlineCommand,i.SetRangeBoldCommand,i.SetRangeFontFamilyCommand,i.SetRangeFontSizeCommand,i.SetRangeItalicCommand,i.SetRangeStrickThroughCommand,i.SetRangeSubscriptCommand,i.SetRangeSuperscriptCommand,i.SetRangeTextColorCommand,i.SetRangeUnderlineCommand,n.SetRangeValuesCommand,n.SetStrikeThroughCommand,n.SetTextColorCommand,n.SetTextRotationCommand,n.SetTextWrapCommand,n.SetVerticalTextAlignCommand,i.SheetCopyCommand,i.SheetCutCommand,i.SheetPasteBesidesBorderCommand,i.SheetPasteColWidthCommand,i.SheetPasteCommand,i.SheetPasteFormatCommand,i.SheetPasteShortKeyCommand,i.SheetPasteValueCommand,n.AutoFillCommand,n.RefillCommand,n.SetWorksheetActivateCommand,n.SetWorksheetActiveOperation,n.SetSelectionsOperation,r.SetSheetFilterRangeCommand,r.SetSheetsFilterCriteriaCommand,r.RemoveSheetFilterCommand].forEach(e=>this._actionRecorderService.registerRecordedCommand(e))}_initDocsCommands(){}};V=y([v(0,e.ICommandService),v(1,a.IUIPartsService),v(2,a.IMenuManagerService),v(3,(0,e.Inject)(a.ComponentManager)),v(4,(0,e.Inject)(b)),v(5,(0,e.Inject)(e.Injector))],V);let H=class extends e.Plugin{constructor(t=p,n,r){super(),this._config=t,this._injector=n,this._configService=r;let{menu:i,...a}=(0,e.merge)({},p,this._config);i&&this._configService.setConfig(`menu`,i,{merge:!0}),this._configService.setConfig(f,a)}onStarting(){(this._config.replayOnly?[[T]]:[[b],[T],[V]]).forEach(e=>this._injector.add(e))}onSteady(){this._config.replayOnly||this._injector.get(V)}};_(H,`pluginName`,`UNIVER_ACTION_RECORDER_PLUGIN`),_(H,`packageName`,u),_(H,`version`,d),H=y([v(1,(0,e.Inject)(e.Injector)),v(2,e.IConfigService)],H),Object.defineProperty(exports,`ActionRecorderService`,{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,`ActionReplayService`,{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,`UniverActionRecorderPlugin`,{enumerable:!0,get:function(){return H}});
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ let _univerjs_core = require("@univerjs/core");
3
+ let _univerjs_icons = require("@univerjs/icons");
4
+ let _univerjs_sheets = require("@univerjs/sheets");
5
+ let _univerjs_sheets_filter = require("@univerjs/sheets-filter");
6
+ let _univerjs_sheets_ui = require("@univerjs/sheets-ui");
7
+ let _univerjs_ui = require("@univerjs/ui");
8
+ let rxjs = require("rxjs");
9
+ let _univerjs_design = require("@univerjs/design");
10
+ let react = require("react");
11
+ let react_jsx_runtime = require("react/jsx-runtime");
12
+
13
+ //#region package.json
14
+ var name = "@univerjs/action-recorder";
15
+ var version = "0.21.0";
16
+
17
+ //#endregion
18
+ //#region src/config/config.ts
19
+ const ACTION_RECORDER_PLUGIN_CONFIG_KEY = "action-recorder.config";
20
+ const configSymbol = Symbol(ACTION_RECORDER_PLUGIN_CONFIG_KEY);
21
+ const defaultPluginConfig = {};
22
+
23
+ //#endregion
24
+ //#region \0@oxc-project+runtime@0.124.0/helpers/typeof.js
25
+ function _typeof(o) {
26
+ "@babel/helpers - typeof";
27
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
28
+ return typeof o;
29
+ } : function(o) {
30
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
31
+ }, _typeof(o);
32
+ }
33
+
34
+ //#endregion
35
+ //#region \0@oxc-project+runtime@0.124.0/helpers/toPrimitive.js
36
+ function toPrimitive(t, r) {
37
+ if ("object" != _typeof(t) || !t) return t;
38
+ var e = t[Symbol.toPrimitive];
39
+ if (void 0 !== e) {
40
+ var i = e.call(t, r || "default");
41
+ if ("object" != _typeof(i)) return i;
42
+ throw new TypeError("@@toPrimitive must return a primitive value.");
43
+ }
44
+ return ("string" === r ? String : Number)(t);
45
+ }
46
+
47
+ //#endregion
48
+ //#region \0@oxc-project+runtime@0.124.0/helpers/toPropertyKey.js
49
+ function toPropertyKey(t) {
50
+ var i = toPrimitive(t, "string");
51
+ return "symbol" == _typeof(i) ? i : i + "";
52
+ }
53
+
54
+ //#endregion
55
+ //#region \0@oxc-project+runtime@0.124.0/helpers/defineProperty.js
56
+ function _defineProperty(e, r, t) {
57
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
58
+ value: t,
59
+ enumerable: !0,
60
+ configurable: !0,
61
+ writable: !0
62
+ }) : e[r] = t, e;
63
+ }
64
+
65
+ //#endregion
66
+ //#region \0@oxc-project+runtime@0.124.0/helpers/decorateParam.js
67
+ function __decorateParam(paramIndex, decorator) {
68
+ return function(target, key) {
69
+ decorator(target, key, paramIndex);
70
+ };
71
+ }
72
+
73
+ //#endregion
74
+ //#region \0@oxc-project+runtime@0.124.0/helpers/decorate.js
75
+ function __decorate(decorators, target, key, desc) {
76
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
77
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
78
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
79
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
80
+ }
81
+
82
+ //#endregion
83
+ //#region src/services/action-recorder.service.ts
84
+ let ActionRecorderService = class ActionRecorderService extends _univerjs_core.Disposable {
85
+ get recording() {
86
+ return this._recording$.getValue();
87
+ }
88
+ get _recorded() {
89
+ return this._recorded$.getValue();
90
+ }
91
+ get _recordedCommands() {
92
+ return this._recordedCommands$.getValue();
93
+ }
94
+ constructor(_commandSrv, _logService, _localFileService, _instanceService) {
95
+ super();
96
+ this._commandSrv = _commandSrv;
97
+ this._logService = _logService;
98
+ this._localFileService = _localFileService;
99
+ this._instanceService = _instanceService;
100
+ _defineProperty(this, "_shouldRecordCommands", /* @__PURE__ */ new Set());
101
+ _defineProperty(this, "_panelOpened$", new rxjs.BehaviorSubject(false));
102
+ _defineProperty(this, "panelOpened$", this._panelOpened$.asObservable());
103
+ _defineProperty(this, "_recorder", null);
104
+ _defineProperty(this, "_recording$", new rxjs.BehaviorSubject(false));
105
+ _defineProperty(this, "recording$", this._recording$.asObservable());
106
+ _defineProperty(this, "_recorded$", new rxjs.BehaviorSubject([]));
107
+ _defineProperty(this, "_recordedCommands$", new rxjs.BehaviorSubject([]));
108
+ _defineProperty(this, "recordedCommands$", this._recordedCommands$.asObservable());
109
+ }
110
+ registerRecordedCommand(command) {
111
+ if (command.type === _univerjs_core.CommandType.MUTATION) throw new Error("[CommandRecorderService] Cannot record mutation commands.");
112
+ this._shouldRecordCommands.add(command.id);
113
+ }
114
+ togglePanel(visible) {
115
+ this._panelOpened$.next(visible);
116
+ if (visible === false) this.stopRecording();
117
+ }
118
+ startRecording(replaceId = false) {
119
+ this._recorder = this._commandSrv.onCommandExecuted((rawCommandInfo) => {
120
+ if (this._shouldRecordCommands.has(rawCommandInfo.id)) {
121
+ var _this$_instanceServic;
122
+ const recorded = this._recorded;
123
+ const commands = this._recordedCommands;
124
+ let commandInfo = { ...rawCommandInfo };
125
+ const focusUnitId = (_this$_instanceServic = this._instanceService.getFocusedUnit()) === null || _this$_instanceServic === void 0 ? void 0 : _this$_instanceServic.getUnitId();
126
+ const { unitId = focusUnitId, subUnitId } = commandInfo === null || commandInfo === void 0 ? void 0 : commandInfo.params;
127
+ if (replaceId && unitId && subUnitId) {
128
+ var _getSheetBySheetId;
129
+ const subUnitName = (_getSheetBySheetId = this._instanceService.getUnit(unitId).getSheetBySheetId(subUnitId)) === null || _getSheetBySheetId === void 0 ? void 0 : _getSheetBySheetId.getName();
130
+ commandInfo = {
131
+ ...commandInfo,
132
+ params: {
133
+ ...commandInfo.params,
134
+ subUnitId: subUnitName
135
+ }
136
+ };
137
+ }
138
+ if (commandInfo.id === _univerjs_sheets.SetSelectionsOperation.id && recorded.length > 0 && recorded[recorded.length - 1].id === _univerjs_sheets.SetSelectionsOperation.id) recorded[recorded.length - 1] = commandInfo;
139
+ else {
140
+ recorded.push(commandInfo);
141
+ this._recorded$.next(recorded);
142
+ if (commandInfo.type === _univerjs_core.CommandType.COMMAND) {
143
+ commands.push(commandInfo);
144
+ this._recordedCommands$.next(commands);
145
+ }
146
+ }
147
+ }
148
+ });
149
+ this._recording$.next(true);
150
+ }
151
+ stopRecording() {
152
+ var _this$_recorder;
153
+ (_this$_recorder = this._recorder) === null || _this$_recorder === void 0 || _this$_recorder.dispose();
154
+ this._recorder = null;
155
+ this._recorded$.next([]);
156
+ this._recordedCommands$.next([]);
157
+ this._recording$.next(false);
158
+ }
159
+ completeRecording() {
160
+ const commands = this._recorded.slice();
161
+ this._localFileService.downloadFile(new Blob([JSON.stringify(commands, null, 2)]), "recorded-commands.json");
162
+ this._logService.error("Recorded commands:", commands);
163
+ this.stopRecording();
164
+ }
165
+ };
166
+ ActionRecorderService = __decorate([
167
+ __decorateParam(0, _univerjs_core.ICommandService),
168
+ __decorateParam(1, _univerjs_core.ILogService),
169
+ __decorateParam(2, _univerjs_ui.ILocalFileService),
170
+ __decorateParam(3, _univerjs_core.IUniverInstanceService)
171
+ ], ActionRecorderService);
172
+
173
+ //#endregion
174
+ //#region src/commands/commands/record.command.ts
175
+ const StartRecordingActionCommand = {
176
+ id: "action-recorder.command.start-recording",
177
+ type: _univerjs_core.CommandType.COMMAND,
178
+ handler: (accessor, params) => {
179
+ accessor.get(ActionRecorderService).startRecording(!!(params === null || params === void 0 ? void 0 : params.replaceId));
180
+ return true;
181
+ }
182
+ };
183
+ const CompleteRecordingActionCommand = {
184
+ id: "action-recorder.command.complete-recording",
185
+ type: _univerjs_core.CommandType.COMMAND,
186
+ handler: (accessor) => {
187
+ accessor.get(ActionRecorderService).completeRecording();
188
+ return true;
189
+ }
190
+ };
191
+ const StopRecordingActionCommand = {
192
+ id: "action-recorder.command.stop-recording",
193
+ type: _univerjs_core.CommandType.COMMAND,
194
+ handler: (accessor) => {
195
+ accessor.get(ActionRecorderService).completeRecording();
196
+ return true;
197
+ }
198
+ };
199
+
200
+ //#endregion
201
+ //#region src/services/replay.service.ts
202
+ let ReplayMode = /* @__PURE__ */ function(ReplayMode) {
203
+ ReplayMode["DEFAULT"] = "default";
204
+ ReplayMode["NAME"] = "name";
205
+ ReplayMode["ACTIVE"] = "active";
206
+ return ReplayMode;
207
+ }({});
208
+ let ActionReplayService = class ActionReplayService extends _univerjs_core.Disposable {
209
+ constructor(_messageService, _instanceService, _localFileService, _logService, _commandService) {
210
+ super();
211
+ this._messageService = _messageService;
212
+ this._instanceService = _instanceService;
213
+ this._localFileService = _localFileService;
214
+ this._logService = _logService;
215
+ this._commandService = _commandService;
216
+ }
217
+ /**
218
+ * Read a local file and try to replay commands in this JSON.
219
+ */
220
+ async replayLocalJSON(mode = ReplayMode.DEFAULT) {
221
+ const files = await this._localFileService.openFile({
222
+ multiple: false,
223
+ accept: ".json"
224
+ });
225
+ if (files.length !== 1) return false;
226
+ const file = files[0];
227
+ try {
228
+ return this.replayCommands(JSON.parse(await file.text()), { mode });
229
+ } catch {
230
+ this._messageService.show({
231
+ type: _univerjs_design.MessageType.Error,
232
+ content: `Failed to replay commands from local file ${file.name}.`
233
+ });
234
+ return false;
235
+ }
236
+ }
237
+ /**
238
+ * Replay a list of commands. Note that `unitId` of these commands would be changed to the focused unit.
239
+ * @param commands - The commands to replay.
240
+ * @returns If the replay is successful.
241
+ */
242
+ async replayCommands(commands, options) {
243
+ var _this$_instanceServic;
244
+ const focusedUnitId = (_this$_instanceServic = this._instanceService.getFocusedUnit()) === null || _this$_instanceServic === void 0 ? void 0 : _this$_instanceServic.getUnitId();
245
+ if (!focusedUnitId) this._logService.error("[ReplayService]", "no focused unit to replay commands");
246
+ const { mode } = options || {};
247
+ for (const command of commands) {
248
+ const { id, params } = command;
249
+ const commandParams = params;
250
+ if (commandParams) {
251
+ if (typeof commandParams.unitId !== "undefined") commandParams.unitId = focusedUnitId;
252
+ if (mode === ReplayMode.NAME && commandParams.subUnitId !== "undefined") {
253
+ var _getSheetBySheetName;
254
+ const realSubUnitId = (_getSheetBySheetName = this._instanceService.getFocusedUnit().getSheetBySheetName(commandParams.subUnitId)) === null || _getSheetBySheetName === void 0 ? void 0 : _getSheetBySheetName.getSheetId();
255
+ if (realSubUnitId) commandParams.subUnitId = realSubUnitId;
256
+ else this._logService.error("[ReplayService]", `failed to find subunit by subUnitName = ${commandParams.subUnitId}`);
257
+ }
258
+ if (mode === ReplayMode.ACTIVE && commandParams.subUnitId !== "undefined") {
259
+ var _getActiveSheet;
260
+ const realSubUnitId = (_getActiveSheet = this._instanceService.getFocusedUnit().getActiveSheet()) === null || _getActiveSheet === void 0 ? void 0 : _getActiveSheet.getSheetId();
261
+ if (realSubUnitId) commandParams.subUnitId = realSubUnitId;
262
+ else this._logService.error("[ReplayService]", "failed to find active subunit");
263
+ }
264
+ if (!await this._commandService.executeCommand(id, params)) return false;
265
+ } else if (!await this._commandService.executeCommand(id)) return false;
266
+ }
267
+ return true;
268
+ }
269
+ /**
270
+ * Replay a list of commands with a random delay between each command.
271
+ * @param commands - The commands to replay.
272
+ */
273
+ async replayCommandsWithDelay(commands) {
274
+ var _this$_instanceServic2;
275
+ const focusedUnitId = (_this$_instanceServic2 = this._instanceService.getFocusedUnit()) === null || _this$_instanceServic2 === void 0 ? void 0 : _this$_instanceServic2.getUnitId();
276
+ if (!focusedUnitId) this._logService.error("[ReplayService]", "no focused unit to replay commands");
277
+ for (const command of commands) {
278
+ await (0, _univerjs_core.awaitTime)(randomBetween200And1k());
279
+ const { id, params } = command;
280
+ if (params) {
281
+ if (typeof params.unitId !== "undefined") params.unitId = focusedUnitId;
282
+ if (!await this._commandService.executeCommand(id, params)) return false;
283
+ } else if (!await this._commandService.executeCommand(id)) return false;
284
+ }
285
+ return true;
286
+ }
287
+ };
288
+ ActionReplayService = __decorate([
289
+ __decorateParam(0, _univerjs_ui.IMessageService),
290
+ __decorateParam(1, _univerjs_core.IUniverInstanceService),
291
+ __decorateParam(2, _univerjs_ui.ILocalFileService),
292
+ __decorateParam(3, _univerjs_core.ILogService),
293
+ __decorateParam(4, _univerjs_core.ICommandService)
294
+ ], ActionReplayService);
295
+ function randomBetween200And1k() {
296
+ return Math.floor(Math.random() * 800) + 200;
297
+ }
298
+
299
+ //#endregion
300
+ //#region src/commands/commands/replay.command.ts
301
+ const ReplayLocalRecordCommand = {
302
+ id: "action-recorder.command.replay-local-records",
303
+ type: _univerjs_core.CommandType.COMMAND,
304
+ handler: async (accessor) => {
305
+ const result = await accessor.get(ActionReplayService).replayLocalJSON();
306
+ if (result) accessor.get(_univerjs_ui.IMessageService).show({
307
+ type: _univerjs_design.MessageType.Success,
308
+ content: "Successfully replayed local records"
309
+ });
310
+ return result;
311
+ }
312
+ };
313
+ const ReplayLocalRecordOnNamesakeCommand = {
314
+ id: "action-recorder.command.replay-local-records-name",
315
+ type: _univerjs_core.CommandType.COMMAND,
316
+ handler: async (accessor) => {
317
+ const result = await accessor.get(ActionReplayService).replayLocalJSON(ReplayMode.NAME);
318
+ if (result) accessor.get(_univerjs_ui.IMessageService).show({
319
+ type: _univerjs_design.MessageType.Success,
320
+ content: "Successfully replayed local records"
321
+ });
322
+ return result;
323
+ }
324
+ };
325
+ const ReplayLocalRecordOnActiveCommand = {
326
+ id: "action-recorder.command.replay-local-records-active",
327
+ type: _univerjs_core.CommandType.COMMAND,
328
+ handler: async (accessor) => {
329
+ const result = await accessor.get(ActionReplayService).replayLocalJSON(ReplayMode.ACTIVE);
330
+ if (result) accessor.get(_univerjs_ui.IMessageService).show({
331
+ type: _univerjs_design.MessageType.Success,
332
+ content: "Successfully replayed local records"
333
+ });
334
+ return result;
335
+ }
336
+ };
337
+
338
+ //#endregion
339
+ //#region src/commands/operations/operation.ts
340
+ const OpenRecordPanelOperation = {
341
+ id: "action-recorder.operation.open-panel",
342
+ type: _univerjs_core.CommandType.OPERATION,
343
+ handler(accessor) {
344
+ accessor.get(ActionRecorderService).togglePanel(true);
345
+ return true;
346
+ }
347
+ };
348
+ const CloseRecordPanelOperation = {
349
+ id: "action-recorder.operation.close-panel",
350
+ type: _univerjs_core.CommandType.OPERATION,
351
+ handler(accessor) {
352
+ accessor.get(ActionRecorderService).togglePanel(false);
353
+ return true;
354
+ }
355
+ };
356
+
357
+ //#endregion
358
+ //#region src/menu/action-recorder.menu.ts
359
+ const RECORD_MENU_ITEM_ID = "RECORD_MENU_ITEM";
360
+ function RecordMenuItemFactory() {
361
+ return {
362
+ id: RECORD_MENU_ITEM_ID,
363
+ type: _univerjs_ui.MenuItemType.SUBITEMS,
364
+ icon: "RecordIcon",
365
+ tooltip: "action-recorder.menu.title"
366
+ };
367
+ }
368
+ function OpenRecorderMenuItemFactory(accessor) {
369
+ const actionRecorderService = accessor.get(ActionRecorderService);
370
+ return {
371
+ id: OpenRecordPanelOperation.id,
372
+ title: "action-recorder.menu.record",
373
+ type: _univerjs_ui.MenuItemType.BUTTON,
374
+ disabled$: actionRecorderService.panelOpened$
375
+ };
376
+ }
377
+ function ReplayLocalRecordMenuItemFactory() {
378
+ return {
379
+ id: ReplayLocalRecordCommand.id,
380
+ title: "action-recorder.menu.replay-local",
381
+ type: _univerjs_ui.MenuItemType.BUTTON
382
+ };
383
+ }
384
+ function ReplayLocalRecordOnNamesakeMenuItemFactory() {
385
+ return {
386
+ id: ReplayLocalRecordOnNamesakeCommand.id,
387
+ title: "action-recorder.menu.replay-local-name",
388
+ type: _univerjs_ui.MenuItemType.BUTTON
389
+ };
390
+ }
391
+ function ReplayLocalRecordOnActiveMenuItemFactory() {
392
+ return {
393
+ id: ReplayLocalRecordOnActiveCommand.id,
394
+ title: "action-recorder.menu.replay-local-active",
395
+ type: _univerjs_ui.MenuItemType.BUTTON
396
+ };
397
+ }
398
+ const menuSchema = { [_univerjs_ui.RibbonOthersGroup.OTHERS]: { [RECORD_MENU_ITEM_ID]: {
399
+ order: 1,
400
+ menuItemFactory: RecordMenuItemFactory,
401
+ [OpenRecordPanelOperation.id]: {
402
+ order: 1,
403
+ menuItemFactory: OpenRecorderMenuItemFactory
404
+ },
405
+ [ReplayLocalRecordCommand.id]: {
406
+ order: 2,
407
+ menuItemFactory: ReplayLocalRecordMenuItemFactory
408
+ },
409
+ [ReplayLocalRecordOnNamesakeCommand.id]: {
410
+ order: 3,
411
+ menuItemFactory: ReplayLocalRecordOnNamesakeMenuItemFactory
412
+ },
413
+ [ReplayLocalRecordOnActiveCommand.id]: {
414
+ order: 4,
415
+ menuItemFactory: ReplayLocalRecordOnActiveMenuItemFactory
416
+ }
417
+ } } };
418
+
419
+ //#endregion
420
+ //#region src/views/components/RecorderPanel.tsx
421
+ /**
422
+ * Copyright 2023-present DreamNum Co., Ltd.
423
+ *
424
+ * Licensed under the Apache License, Version 2.0 (the "License");
425
+ * you may not use this file except in compliance with the License.
426
+ * You may obtain a copy of the License at
427
+ *
428
+ * http://www.apache.org/licenses/LICENSE-2.0
429
+ *
430
+ * Unless required by applicable law or agreed to in writing, software
431
+ * distributed under the License is distributed on an "AS IS" BASIS,
432
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
433
+ * See the License for the specific language governing permissions and
434
+ * limitations under the License.
435
+ */
436
+ function RecorderPanel() {
437
+ if (!(0, _univerjs_ui.useObservable)((0, _univerjs_ui.useDependency)(ActionRecorderService).panelOpened$)) return null;
438
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RecordPanelImpl, {});
439
+ }
440
+ function RecordPanelImpl() {
441
+ var _recordedCommands$len;
442
+ const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
443
+ const actionRecorderService = (0, _univerjs_ui.useDependency)(ActionRecorderService);
444
+ const recording = (0, _univerjs_ui.useObservable)(actionRecorderService.recording$);
445
+ const recordedCommands = (0, _univerjs_ui.useObservable)(actionRecorderService.recordedCommands$);
446
+ const len = (_recordedCommands$len = recordedCommands === null || recordedCommands === void 0 ? void 0 : recordedCommands.length) !== null && _recordedCommands$len !== void 0 ? _recordedCommands$len : 0;
447
+ const closePanel = (0, react.useCallback)(() => {
448
+ if (!recording) commandService.executeCommand(CloseRecordPanelOperation.id);
449
+ }, [commandService, recording]);
450
+ const startRecording = (0, react.useCallback)((replaceId) => {
451
+ if (!recording) commandService.executeCommand(StartRecordingActionCommand.id, { replaceId });
452
+ }, [commandService, recording]);
453
+ const completeRecording = (0, react.useCallback)(() => {
454
+ if (recording) commandService.executeCommand(CompleteRecordingActionCommand.id);
455
+ }, [commandService, recording]);
456
+ const stopRecording = (0, react.useCallback)(() => {
457
+ if (recording) commandService.executeCommand(StopRecordingActionCommand.id);
458
+ }, [commandService, recording]);
459
+ const titleText = recording ? len === 0 ? "Recording..." : `${len}: ${recordedCommands[len - 1].id}` : "Start Recording";
460
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
461
+ className: "univer-fixed univer-bottom-20 univer-left-1/2 univer-z-[1000] univer-flex univer-h-16 univer-w-[512px] -univer-translate-x-1/2 univer-items-center univer-rounded-lg univer-bg-white univer-px-5 univer-shadow-lg",
462
+ children: [
463
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
464
+ className: "univer-mr-2 univer-size-5 univer-shrink-0 univer-grow-0 univer-text-xl",
465
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.RecordIcon, {})
466
+ }),
467
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
468
+ className: "univer-flex-1 univer-text-sm",
469
+ children: titleText
470
+ }),
471
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
472
+ className: "univer-flex univer-w-64 univer-shrink-0 univer-grow-0 univer-justify-between",
473
+ children: [
474
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
475
+ className: "univer-w-20",
476
+ onClick: recording ? stopRecording : closePanel,
477
+ children: recording ? "Cancel" : "Close"
478
+ }),
479
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
480
+ className: "univer-w-20",
481
+ variant: "primary",
482
+ onClick: recording ? completeRecording : () => startRecording(),
483
+ children: recording ? "Save" : "Start"
484
+ }),
485
+ !recording && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
486
+ variant: "primary",
487
+ onClick: () => startRecording(true),
488
+ children: "Start(N)"
489
+ })
490
+ ]
491
+ })
492
+ ]
493
+ });
494
+ }
495
+
496
+ //#endregion
497
+ //#region src/controllers/action-recorder.controller.tsx
498
+ /**
499
+ * Copyright 2023-present DreamNum Co., Ltd.
500
+ *
501
+ * Licensed under the Apache License, Version 2.0 (the "License");
502
+ * you may not use this file except in compliance with the License.
503
+ * You may obtain a copy of the License at
504
+ *
505
+ * http://www.apache.org/licenses/LICENSE-2.0
506
+ *
507
+ * Unless required by applicable law or agreed to in writing, software
508
+ * distributed under the License is distributed on an "AS IS" BASIS,
509
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
510
+ * See the License for the specific language governing permissions and
511
+ * limitations under the License.
512
+ */
513
+ let ActionRecorderController = class ActionRecorderController extends _univerjs_core.Disposable {
514
+ constructor(_commandSrv, _uiPartsSrv, _menuManagerService, _componentManager, _actionRecorderService, _injector) {
515
+ super();
516
+ this._commandSrv = _commandSrv;
517
+ this._uiPartsSrv = _uiPartsSrv;
518
+ this._menuManagerService = _menuManagerService;
519
+ this._componentManager = _componentManager;
520
+ this._actionRecorderService = _actionRecorderService;
521
+ this._injector = _injector;
522
+ this._initCommands();
523
+ this._initUI();
524
+ this._initSheetsCommands();
525
+ this._initDocsCommands();
526
+ }
527
+ _initCommands() {
528
+ [
529
+ StartRecordingActionCommand,
530
+ StopRecordingActionCommand,
531
+ CompleteRecordingActionCommand,
532
+ OpenRecordPanelOperation,
533
+ CloseRecordPanelOperation,
534
+ ReplayLocalRecordCommand,
535
+ ReplayLocalRecordOnNamesakeCommand,
536
+ ReplayLocalRecordOnActiveCommand
537
+ ].forEach((command) => this._commandSrv.registerCommand(command));
538
+ }
539
+ _initUI() {
540
+ this._uiPartsSrv.registerComponent(_univerjs_ui.BuiltInUIPart.GLOBAL, () => (0, _univerjs_ui.connectInjector)(RecorderPanel, this._injector));
541
+ this.disposeWithMe(this._componentManager.register("RecordIcon", _univerjs_icons.RecordIcon));
542
+ this._menuManagerService.mergeMenu(menuSchema);
543
+ }
544
+ _initSheetsCommands() {
545
+ [
546
+ _univerjs_sheets.CopySheetCommand,
547
+ _univerjs_sheets.DeleteRangeMoveLeftCommand,
548
+ _univerjs_sheets.DeleteRangeMoveUpCommand,
549
+ _univerjs_sheets.DeltaColumnWidthCommand,
550
+ _univerjs_sheets.DeltaRowHeightCommand,
551
+ _univerjs_sheets.InsertSheetCommand,
552
+ _univerjs_sheets.InsertColAfterCommand,
553
+ _univerjs_sheets.InsertColBeforeCommand,
554
+ _univerjs_sheets.InsertRowAfterCommand,
555
+ _univerjs_sheets.InsertRowBeforeCommand,
556
+ _univerjs_sheets.RemoveSheetCommand,
557
+ _univerjs_sheets.SetStyleCommand,
558
+ _univerjs_sheets.AddWorksheetMergeCommand,
559
+ _univerjs_sheets.AddWorksheetMergeAllCommand,
560
+ _univerjs_sheets.AddWorksheetMergeVerticalCommand,
561
+ _univerjs_sheets.AddWorksheetMergeHorizontalCommand,
562
+ _univerjs_sheets.SetFrozenCommand,
563
+ _univerjs_sheets.CancelFrozenCommand,
564
+ _univerjs_sheets.SetHorizontalTextAlignCommand,
565
+ _univerjs_sheets.SetOverlineCommand,
566
+ _univerjs_sheets_ui.SetRangeBoldCommand,
567
+ _univerjs_sheets_ui.SetRangeFontFamilyCommand,
568
+ _univerjs_sheets_ui.SetRangeFontSizeCommand,
569
+ _univerjs_sheets_ui.SetRangeItalicCommand,
570
+ _univerjs_sheets_ui.SetRangeStrickThroughCommand,
571
+ _univerjs_sheets_ui.SetRangeSubscriptCommand,
572
+ _univerjs_sheets_ui.SetRangeSuperscriptCommand,
573
+ _univerjs_sheets_ui.SetRangeTextColorCommand,
574
+ _univerjs_sheets_ui.SetRangeUnderlineCommand,
575
+ _univerjs_sheets.SetRangeValuesCommand,
576
+ _univerjs_sheets.SetStrikeThroughCommand,
577
+ _univerjs_sheets.SetTextColorCommand,
578
+ _univerjs_sheets.SetTextRotationCommand,
579
+ _univerjs_sheets.SetTextWrapCommand,
580
+ _univerjs_sheets.SetVerticalTextAlignCommand,
581
+ _univerjs_sheets_ui.SheetCopyCommand,
582
+ _univerjs_sheets_ui.SheetCutCommand,
583
+ _univerjs_sheets_ui.SheetPasteBesidesBorderCommand,
584
+ _univerjs_sheets_ui.SheetPasteColWidthCommand,
585
+ _univerjs_sheets_ui.SheetPasteCommand,
586
+ _univerjs_sheets_ui.SheetPasteFormatCommand,
587
+ _univerjs_sheets_ui.SheetPasteShortKeyCommand,
588
+ _univerjs_sheets_ui.SheetPasteValueCommand,
589
+ _univerjs_sheets.AutoFillCommand,
590
+ _univerjs_sheets.RefillCommand,
591
+ _univerjs_sheets.SetWorksheetActivateCommand,
592
+ _univerjs_sheets.SetWorksheetActiveOperation,
593
+ _univerjs_sheets.SetSelectionsOperation,
594
+ _univerjs_sheets_filter.SetSheetFilterRangeCommand,
595
+ _univerjs_sheets_filter.SetSheetsFilterCriteriaCommand,
596
+ _univerjs_sheets_filter.RemoveSheetFilterCommand
597
+ ].forEach((command) => this._actionRecorderService.registerRecordedCommand(command));
598
+ }
599
+ _initDocsCommands() {}
600
+ };
601
+ ActionRecorderController = __decorate([
602
+ __decorateParam(0, _univerjs_core.ICommandService),
603
+ __decorateParam(1, _univerjs_ui.IUIPartsService),
604
+ __decorateParam(2, _univerjs_ui.IMenuManagerService),
605
+ __decorateParam(3, (0, _univerjs_core.Inject)(_univerjs_ui.ComponentManager)),
606
+ __decorateParam(4, (0, _univerjs_core.Inject)(ActionRecorderService)),
607
+ __decorateParam(5, (0, _univerjs_core.Inject)(_univerjs_core.Injector))
608
+ ], ActionRecorderController);
609
+
610
+ //#endregion
611
+ //#region src/plugin.ts
612
+ let UniverActionRecorderPlugin = class UniverActionRecorderPlugin extends _univerjs_core.Plugin {
613
+ constructor(_config = defaultPluginConfig, _injector, _configService) {
614
+ super();
615
+ this._config = _config;
616
+ this._injector = _injector;
617
+ this._configService = _configService;
618
+ const { menu, ...rest } = (0, _univerjs_core.merge)({}, defaultPluginConfig, this._config);
619
+ if (menu) this._configService.setConfig("menu", menu, { merge: true });
620
+ this._configService.setConfig(ACTION_RECORDER_PLUGIN_CONFIG_KEY, rest);
621
+ }
622
+ onStarting() {
623
+ (this._config.replayOnly ? [[ActionReplayService]] : [
624
+ [ActionRecorderService],
625
+ [ActionReplayService],
626
+ [ActionRecorderController]
627
+ ]).forEach((d) => this._injector.add(d));
628
+ }
629
+ onSteady() {
630
+ if (this._config.replayOnly) return;
631
+ this._injector.get(ActionRecorderController);
632
+ }
633
+ };
634
+ _defineProperty(UniverActionRecorderPlugin, "pluginName", "UNIVER_ACTION_RECORDER_PLUGIN");
635
+ _defineProperty(UniverActionRecorderPlugin, "packageName", name);
636
+ _defineProperty(UniverActionRecorderPlugin, "version", version);
637
+ UniverActionRecorderPlugin = __decorate([__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector)), __decorateParam(2, _univerjs_core.IConfigService)], UniverActionRecorderPlugin);
638
+
639
+ //#endregion
640
+ Object.defineProperty(exports, 'ActionRecorderService', {
641
+ enumerable: true,
642
+ get: function () {
643
+ return ActionRecorderService;
644
+ }
645
+ });
646
+ Object.defineProperty(exports, 'ActionReplayService', {
647
+ enumerable: true,
648
+ get: function () {
649
+ return ActionReplayService;
650
+ }
651
+ });
652
+ Object.defineProperty(exports, 'UniverActionRecorderPlugin', {
653
+ enumerable: true,
654
+ get: function () {
655
+ return UniverActionRecorderPlugin;
656
+ }
657
+ });