@univerjs/action-recorder 0.6.1 → 0.6.2-nightly.202503031606
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/lib/cjs/index.js +1 -1
- package/lib/es/index.js +94 -108
- package/lib/umd/index.js +1 -1
- package/package.json +11 -12
- package/LICENSE +0 -176
package/lib/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var J=Object.defineProperty;var G=(e,n,r)=>n in e?J(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r;var S=(e,n,r)=>G(e,typeof n!="symbol"?n+"":n,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("@univerjs/core"),a=require("@univerjs/sheets"),x=require("@univerjs/sheets-filter"),l=require("@univerjs/sheets-ui"),d=require("@univerjs/ui"),A=require("rxjs"),C=require("@univerjs/design"),v=require("react/jsx-runtime"),p=require("react");var f=function(){return f=Object.assign||function(e){for(var n,r=1,t=arguments.length;r<t;r++){n=arguments[r];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},f.apply(this,arguments)},Z=function(e,n){var r={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&n.indexOf(t)<0&&(r[t]=e[t]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,t=Object.getOwnPropertySymbols(e);o<t.length;o++)n.indexOf(t[o])<0&&Object.prototype.propertyIsEnumerable.call(e,t[o])&&(r[t[o]]=e[t[o]]);return r},L=p.forwardRef(function(e,n){var r=e.icon,t=e.id,o=e.className,c=e.extend,i=Z(e,["icon","id","className","extend"]),m="univerjs-icon univerjs-icon-".concat(t," ").concat(o||"").trim(),u=p.useRef("_".concat(Q()));return B(r,"".concat(t),{defIds:r.defIds,idSuffix:u.current},f({ref:n,className:m},i),c)});function B(e,n,r,t,o){return p.createElement(e.tag,f(f({key:n},K(e,r,o)),t),(Y(e,r).children||[]).map(function(c,i){return B(c,"".concat(n,"-").concat(e.tag,"-").concat(i),r,void 0,o)}))}function K(e,n,r){var t=f({},e.attrs);r!=null&&r.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=r.colorChannel1),e.tag==="mask"&&t.id&&(t.id=t.id+n.idSuffix),Object.entries(t).forEach(function(c){var i=c[0],m=c[1];i==="mask"&&typeof m=="string"&&(t[i]=m.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))});var o=n.defIds;return!o||o.length===0||(e.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+n.idSuffix),Object.entries(t).forEach(function(c){var i=c[0],m=c[1];typeof m=="string"&&(t[i]=m.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))})),t}function Y(e,n){var r,t=n.defIds;return!t||t.length===0?e:e.tag==="defs"&&(!((r=e.children)===null||r===void 0)&&r.length)?f(f({},e),{children:e.children.map(function(o){return typeof o.attrs.id=="string"&&t&&t.indexOf(o.attrs.id)>-1?f(f({},o),{attrs:f(f({},o.attrs),{id:o.attrs.id+n.idSuffix})}):o})}):e}function Q(){return Math.random().toString(36).substring(2,8)}L.displayName="UniverIcon";var X={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"g",attrs:{fill:"currentColor",clipPath:"url(#record-single_clip0_1559_19)"},children:[{tag:"path",attrs:{d:"M7.60303 10C8.7076 10 9.60303 9.10457 9.60303 8C9.60303 6.89543 8.7076 6 7.60303 6C6.49846 6 5.60303 6.89543 5.60303 8C5.60303 9.10457 6.49846 10 7.60303 10Z"}},{tag:"path",attrs:{d:"M1.66943 5.29023C1.66941 3.85426 2.83349 2.69017 4.26946 2.69019L10.9362 2.69026C12.3192 2.69028 13.45 3.77008 13.5315 5.13259L14.5692 4.55638C15.3024 4.14929 16.2032 4.67947 16.2032 5.51809V10.4819C16.2032 11.3205 15.3024 11.8507 14.5692 11.4436L13.5315 10.8674C13.45 12.2299 12.3192 13.3097 10.9362 13.3097H4.26953C2.83361 13.3097 1.66956 12.1457 1.66953 10.7098L1.66943 5.29023ZM13.5362 9.49743L15.0032 10.312V5.68799L13.5362 6.50254V9.49743ZM4.26945 3.89019C3.49623 3.89018 2.86942 4.517 2.86943 5.29021L2.86953 10.7098C2.86955 11.483 3.49634 12.1097 4.26953 12.1097H10.9362C11.7094 12.1097 12.3362 11.4829 12.3362 10.7097V5.29026C12.3362 4.51707 11.7094 3.89027 10.9362 3.89026L4.26945 3.89019Z",fillRule:"evenodd",clipRule:"evenodd"}}]},{tag:"defs",attrs:{},children:[{tag:"clipPath",attrs:{id:"record-single_clip0_1559_19"},children:[{tag:"path",attrs:{fill:"#fff",d:"M0 0H16V16H0z",transform:"translate(.94)"}}]}]}],defIds:["record-single_clip0_1559_19"]},U=p.forwardRef(function(e,n){return p.createElement(L,Object.assign({},e,{id:"record-single",ref:n,icon:X}))});U.displayName="RecordSingle";var ee=Object.getOwnPropertyDescriptor,re=(e,n,r,t)=>{for(var o=t>1?void 0:t?ee(n,r):n,c=e.length-1,i;c>=0;c--)(i=e[c])&&(o=i(o)||o);return o},b=(e,n)=>(r,t)=>n(r,t,e);exports.ActionRecorderService=class extends s.Disposable{constructor(r,t,o,c){super();S(this,"_shouldRecordCommands",new Set);S(this,"_panelOpened$",new A.BehaviorSubject(!1));S(this,"panelOpened$",this._panelOpened$.asObservable());S(this,"_recorder",null);S(this,"_recording$",new A.BehaviorSubject(!1));S(this,"recording$",this._recording$.asObservable());S(this,"_recorded$",new A.BehaviorSubject([]));S(this,"_recordedCommands$",new A.BehaviorSubject([]));S(this,"recordedCommands$",this._recordedCommands$.asObservable());this._commandSrv=r,this._logService=t,this._localFileService=o,this._instanceService=c}get recording(){return this._recording$.getValue()}get _recorded(){return this._recorded$.getValue()}get _recordedCommands(){return this._recordedCommands$.getValue()}registerRecordedCommand(r){if(r.type===s.CommandType.MUTATION)throw new Error("[CommandRecorderService] Cannot record mutation commands.");this._shouldRecordCommands.add(r.id)}togglePanel(r){this._panelOpened$.next(r),r===!1&&this.stopRecording()}startRecording(r=!1){this._recorder=this._commandSrv.onCommandExecuted(t=>{var o,c;if(this._shouldRecordCommands.has(t.id)){const i=this._recorded,m=this._recordedCommands;let u={...t};const y=(o=this._instanceService.getFocusedUnit())==null?void 0:o.getUnitId(),{unitId:h=y,subUnitId:g}=u==null?void 0:u.params;if(r&&h&&g){const P=(c=this._instanceService.getUnit(h).getSheetBySheetId(g))==null?void 0:c.getName();u={...u,params:{...u.params,subUnitId:P}}}u.id===a.SetSelectionsOperation.id&&i.length>0&&i[i.length-1].id===a.SetSelectionsOperation.id?i[i.length-1]=u:(i.push(u),this._recorded$.next(i),u.type===s.CommandType.COMMAND&&(m.push(u),this._recordedCommands$.next(m)))}}),this._recording$.next(!0)}stopRecording(){var r;(r=this._recorder)==null||r.dispose(),this._recorder=null,this._recorded$.next([]),this._recordedCommands$.next([]),this._recording$.next(!1)}completeRecording(){const r=this._recorded.slice();this._localFileService.downloadFile(new Blob([JSON.stringify(r,null,2)]),"recorded-commands.json"),this._logService.error("Recorded commands:",r),this.stopRecording()}};exports.ActionRecorderService=re([b(0,s.ICommandService),b(1,s.ILogService),b(2,d.ILocalFileService),b(3,s.IUniverInstanceService)],exports.ActionRecorderService);const k={id:"action-recorder.command.start-recording",type:s.CommandType.COMMAND,handler:(e,n)=>(e.get(exports.ActionRecorderService).startRecording(!!(n!=null&&n.replaceId)),!0)},V={id:"action-recorder.command.complete-recording",type:s.CommandType.COMMAND,handler:e=>(e.get(exports.ActionRecorderService).completeRecording(),!0)},W={id:"action-recorder.command.stop-recording",type:s.CommandType.COMMAND,handler:e=>(e.get(exports.ActionRecorderService).completeRecording(),!0)};var te=Object.getOwnPropertyDescriptor,ne=(e,n,r,t)=>{for(var o=t>1?void 0:t?te(n,r):n,c=e.length-1,i;c>=0;c--)(i=e[c])&&(o=i(o)||o);return o},I=(e,n)=>(r,t)=>n(r,t,e),N=(e=>(e.DEFAULT="default",e.NAME="name",e.ACTIVE="active",e))(N||{});exports.ActionReplayService=class extends s.Disposable{constructor(n,r,t,o,c){super(),this._messageService=n,this._instanceService=r,this._localFileService=t,this._logService=o,this._commandService=c}async replayLocalJSON(n="default"){const r=await this._localFileService.openFile({multiple:!1,accept:".json"});if(r.length!==1)return!1;const t=r[0];try{return this.replayCommands(JSON.parse(await t.text()),{mode:n})}catch{return this._messageService.show({type:C.MessageType.Error,content:`Failed to replay commands from local file ${t.name}.`}),!1}}async replayCommands(n,r){var c,i,m;const t=(c=this._instanceService.getFocusedUnit())==null?void 0:c.getUnitId();t||this._logService.error("[ReplayService]","no focused unit to replay commands");const{mode:o}=r||{};for(const u of n){const{id:y,params:h}=u,g=h;if(g){if(typeof g.unitId<"u"&&(g.unitId=t),o==="name"&&g.subUnitId!=="undefined"){const _=(i=this._instanceService.getFocusedUnit().getSheetBySheetName(g.subUnitId))==null?void 0:i.getSheetId();_?g.subUnitId=_:this._logService.error("[ReplayService]",`failed to find subunit by subUnitName = ${g.subUnitId}`)}if(o==="active"&&g.subUnitId!=="undefined"){const _=(m=this._instanceService.getFocusedUnit().getActiveSheet())==null?void 0:m.getSheetId();_?g.subUnitId=_:this._logService.error("[ReplayService]","failed to find active subunit")}if(!await this._commandService.executeCommand(y,h))return!1}else if(!await this._commandService.executeCommand(y))return!1}return!0}async replayCommandsWithDelay(n){var t;const r=(t=this._instanceService.getFocusedUnit())==null?void 0:t.getUnitId();r||this._logService.error("[ReplayService]","no focused unit to replay commands");for(const o of n){await s.awaitTime(oe());const{id:c,params:i}=o;if(i){if(typeof i.unitId<"u"&&(i.unitId=r),!await this._commandService.executeCommand(c,i))return!1}else if(!await this._commandService.executeCommand(c))return!1}return!0}};exports.ActionReplayService=ne([I(0,d.IMessageService),I(1,s.IUniverInstanceService),I(2,d.ILocalFileService),I(3,s.ILogService),I(4,s.ICommandService)],exports.ActionReplayService);function oe(){return Math.floor(Math.random()*800)+200}const j={id:"action-recorder.command.replay-local-records",type:s.CommandType.COMMAND,handler:async e=>{const r=await e.get(exports.ActionReplayService).replayLocalJSON();return r&&e.get(d.IMessageService).show({type:C.MessageType.Success,content:"Successfully replayed local records"}),r}},w={id:"action-recorder.command.replay-local-records-name",type:s.CommandType.COMMAND,handler:async e=>{const r=await e.get(exports.ActionReplayService).replayLocalJSON(N.NAME);return r&&e.get(d.IMessageService).show({type:C.MessageType.Success,content:"Successfully replayed local records"}),r}},$={id:"action-recorder.command.replay-local-records-active",type:s.CommandType.COMMAND,handler:async e=>{const r=await e.get(exports.ActionReplayService).replayLocalJSON(N.ACTIVE);return r&&e.get(d.IMessageService).show({type:C.MessageType.Success,content:"Successfully replayed local records"}),r}},F={id:"action-recorder.operation.open-panel",type:s.CommandType.OPERATION,handler(e){return e.get(exports.ActionRecorderService).togglePanel(!0),!0}},q={id:"action-recorder.operation.close-panel",type:s.CommandType.OPERATION,handler(e){return e.get(exports.ActionRecorderService).togglePanel(!1),!0}};function z(e){var n,r,t="";if(typeof e=="string"||typeof e=="number")t+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(n=0;n<o;n++)e[n]&&(r=z(e[n]))&&(t&&(t+=" "),t+=r)}else for(r in e)e[r]&&(t&&(t+=" "),t+=r);return t}function ce(){for(var e,n,r=0,t="",o=arguments.length;r<o;r++)(e=arguments[r])&&(n=z(e))&&(t&&(t+=" "),t+=n);return t}const ie="univer-action-recorder-panel",ae="univer-action-recorder-panel-icon",se="univer-action-recorder-panel-icon-recording",de="univer-action-recorder-panel-title",le="univer-action-recorder-panel-actions",O={actionRecorderPanel:ie,actionRecorderPanelIcon:ae,actionRecorderPanelIconRecording:se,actionRecorderPanelTitle:de,actionRecorderPanelActions:le};function me(){const e=d.useDependency(exports.ActionRecorderService);return d.useObservable(e.panelOpened$)?v.jsx(ue,{}):null}function ue(){var h;const e=d.useDependency(s.ICommandService),n=d.useDependency(exports.ActionRecorderService),r=d.useObservable(n.recording$),t=d.useObservable(n.recordedCommands$),o=(h=t==null?void 0:t.length)!=null?h:0,c=p.useCallback(()=>{r||e.executeCommand(q.id)},[e,r]),i=p.useCallback(g=>{r||e.executeCommand(k.id,{replaceId:g})},[e,r]),m=p.useCallback(()=>{r&&e.executeCommand(V.id)},[e,r]),u=p.useCallback(()=>{r&&e.executeCommand(W.id)},[e,r]),y=r?o===0?"Recording...":`${o}: ${t[o-1].id}`:"Start Recording";return v.jsxs("div",{className:O.actionRecorderPanel,children:[v.jsx("div",{className:ce(O.actionRecorderPanelIcon,r?O.actionRecorderPanelIconRecording:!1),children:v.jsx(U,{})}),v.jsx("div",{className:O.actionRecorderPanelTitle,children:y}),v.jsxs("div",{className:O.actionRecorderPanelActions,children:[v.jsx(C.Button,{type:"default",size:"small",onClick:r?u:c,children:r?"Cancel":"Close"}),v.jsx(C.Button,{type:"primary",size:"small",onClick:r?m:()=>i(),children:r?"Save":"Start"}),!r&&v.jsx(C.Button,{type:"primary",size:"small",onClick:()=>i(!0),children:"Start(N)"})]})]})}const H="RECORD_MENU_ITEM";function ge(){return{id:H,type:d.MenuItemType.SUBITEMS,icon:"RecordSingle",tooltip:"action-recorder.menu.title"}}function fe(e){const n=e.get(exports.ActionRecorderService);return{id:F.id,title:"action-recorder.menu.record",type:d.MenuItemType.BUTTON,disabled$:n.panelOpened$}}function Se(){return{id:j.id,title:"action-recorder.menu.replay-local",type:d.MenuItemType.BUTTON}}function ve(){return{id:w.id,title:"action-recorder.menu.replay-local-name",type:d.MenuItemType.BUTTON}}function pe(){return{id:$.id,title:"action-recorder.menu.replay-local-active",type:d.MenuItemType.BUTTON}}const he={[d.RibbonStartGroup.OTHERS]:{[H]:{order:10,menuItemFactory:ge,[F.id]:{order:1,menuItemFactory:fe},[j.id]:{order:2,menuItemFactory:Se},[w.id]:{order:3,menuItemFactory:ve},[$.id]:{order:4,menuItemFactory:pe}}}};var Ce=Object.getOwnPropertyDescriptor,ye=(e,n,r,t)=>{for(var o=t>1?void 0:t?Ce(n,r):n,c=e.length-1,i;c>=0;c--)(i=e[c])&&(o=i(o)||o);return o},R=(e,n)=>(r,t)=>n(r,t,e);let M=class extends s.Disposable{constructor(e,n,r,t,o,c){super(),this._commandSrv=e,this._uiPartsSrv=n,this._menuManagerService=r,this._componentManager=t,this._actionRecorderService=o,this._injector=c,this._initCommands(),this._initUI(),this._initSheetsCommands(),this._initDocsCommands()}_initCommands(){[k,W,V,F,q,j,w,$].forEach(e=>this._commandSrv.registerCommand(e))}_initUI(){this._uiPartsSrv.registerComponent(d.BuiltInUIPart.GLOBAL,()=>d.connectInjector(me,this._injector)),this._componentManager.register("RecordSingle",U),this._menuManagerService.mergeMenu(he)}_initSheetsCommands(){[a.CopySheetCommand,a.DeleteRangeMoveLeftCommand,a.DeleteRangeMoveUpCommand,a.DeltaColumnWidthCommand,a.DeltaRowHeightCommand,a.InsertSheetCommand,a.InsertColAfterCommand,a.InsertColBeforeCommand,a.InsertRowAfterCommand,a.InsertRowBeforeCommand,a.RemoveSheetCommand,a.SetStyleCommand,a.AddWorksheetMergeCommand,a.AddWorksheetMergeAllCommand,a.AddWorksheetMergeVerticalCommand,a.AddWorksheetMergeHorizontalCommand,a.SetFrozenCommand,a.CancelFrozenCommand,a.SetHorizontalTextAlignCommand,a.SetOverlineCommand,l.SetRangeBoldCommand,l.SetRangeFontFamilyCommand,l.SetRangeFontSizeCommand,l.SetRangeItalicCommand,l.SetRangeStrickThroughCommand,l.SetRangeSubscriptCommand,l.SetRangeSuperscriptCommand,l.SetRangeTextColorCommand,l.SetRangeUnderlineCommand,a.SetRangeValuesCommand,a.SetStrikeThroughCommand,a.SetTextColorCommand,a.SetTextRotationCommand,a.SetTextWrapCommand,a.SetVerticalTextAlignCommand,l.SheetCopyCommand,l.SheetCutCommand,l.SheetPasteBesidesBorderCommand,l.SheetPasteColWidthCommand,l.SheetPasteCommand,l.SheetPasteFormatCommand,l.SheetPasteShortKeyCommand,l.SheetPasteValueCommand,l.AutoFillCommand,l.RefillCommand,a.SetWorksheetActivateCommand,a.SetWorksheetActiveOperation,a.SetSelectionsOperation,x.SetSheetFilterRangeCommand,x.SetSheetsFilterCriteriaCommand,x.RemoveSheetFilterCommand].forEach(e=>this._actionRecorderService.registerRecordedCommand(e))}_initDocsCommands(){}};M=ye([R(0,s.ICommandService),R(1,d.IUIPartsService),R(2,d.IMenuManagerService),R(3,s.Inject(d.ComponentManager)),R(4,s.Inject(exports.ActionRecorderService)),R(5,s.Inject(s.Injector))],M);const Re="action-recorder.config",D={};var _e=Object.getOwnPropertyDescriptor,Ie=(e,n,r,t)=>{for(var o=t>1?void 0:t?_e(n,r):n,c=e.length-1,i;c>=0;c--)(i=e[c])&&(o=i(o)||o);return o},E=(e,n)=>(r,t)=>n(r,t,e),T;exports.UniverActionRecorderPlugin=(T=class extends s.Plugin{constructor(n=D,r,t){super(),this._config=n,this._injector=r,this._configService=t;const{menu:o,...c}=s.merge({},D,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(Re,c)}onStarting(){(this._config.replayOnly?[[exports.ActionReplayService]]:[[exports.ActionRecorderService],[exports.ActionReplayService],[M]]).forEach(r=>this._injector.add(r))}onSteady(){this._config.replayOnly||this._injector.get(M)}},S(T,"pluginName","UNIVER_ACTION_RECORDER_PLUGIN"),T);exports.UniverActionRecorderPlugin=Ie([E(1,s.Inject(s.Injector)),E(2,s.IConfigService)],exports.UniverActionRecorderPlugin);
|
|
1
|
+
"use strict";var H=Object.defineProperty;var J=(e,n,t)=>n in e?H(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;var f=(e,n,t)=>J(e,typeof n!="symbol"?n+"":n,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("@univerjs/core"),a=require("@univerjs/sheets"),x=require("@univerjs/sheets-filter"),l=require("@univerjs/sheets-ui"),d=require("@univerjs/ui"),A=require("rxjs"),C=require("@univerjs/design"),v=require("react/jsx-runtime"),p=require("react");var S=function(){return S=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++){n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},S.apply(this,arguments)},G=function(e,n){var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&n.indexOf(r)<0&&(t[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)n.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(t[r[o]]=e[r[o]]);return t},L=p.forwardRef(function(e,n){var t=e.icon,r=e.id,o=e.className,c=e.extend,i=G(e,["icon","id","className","extend"]),m="univerjs-icon univerjs-icon-".concat(r," ").concat(o||"").trim(),u=p.useRef("_".concat(Y()));return B(t,"".concat(r),{defIds:t.defIds,idSuffix:u.current},S({ref:n,className:m},i),c)});function B(e,n,t,r,o){return p.createElement(e.tag,S(S({key:n},Z(e,t,o)),r),(K(e,t).children||[]).map(function(c,i){return B(c,"".concat(n,"-").concat(e.tag,"-").concat(i),t,void 0,o)}))}function Z(e,n,t){var r=S({},e.attrs);t!=null&&t.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=t.colorChannel1),e.tag==="mask"&&r.id&&(r.id=r.id+n.idSuffix),Object.entries(r).forEach(function(c){var i=c[0],m=c[1];i==="mask"&&typeof m=="string"&&(r[i]=m.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))});var o=n.defIds;return!o||o.length===0||(e.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+n.idSuffix),Object.entries(r).forEach(function(c){var i=c[0],m=c[1];typeof m=="string"&&(r[i]=m.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))})),r}function K(e,n){var t,r=n.defIds;return!r||r.length===0?e:e.tag==="defs"&&(!((t=e.children)===null||t===void 0)&&t.length)?S(S({},e),{children:e.children.map(function(o){return typeof o.attrs.id=="string"&&r&&r.indexOf(o.attrs.id)>-1?S(S({},o),{attrs:S(S({},o.attrs),{id:o.attrs.id+n.idSuffix})}):o})}):e}function Y(){return Math.random().toString(36).substring(2,8)}L.displayName="UniverIcon";var Q={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"g",attrs:{fill:"currentColor",clipPath:"url(#record-single_clip0_1559_19)"},children:[{tag:"path",attrs:{d:"M7.60303 10C8.7076 10 9.60303 9.10457 9.60303 8C9.60303 6.89543 8.7076 6 7.60303 6C6.49846 6 5.60303 6.89543 5.60303 8C5.60303 9.10457 6.49846 10 7.60303 10Z"}},{tag:"path",attrs:{d:"M1.66943 5.29023C1.66941 3.85426 2.83349 2.69017 4.26946 2.69019L10.9362 2.69026C12.3192 2.69028 13.45 3.77008 13.5315 5.13259L14.5692 4.55638C15.3024 4.14929 16.2032 4.67947 16.2032 5.51809V10.4819C16.2032 11.3205 15.3024 11.8507 14.5692 11.4436L13.5315 10.8674C13.45 12.2299 12.3192 13.3097 10.9362 13.3097H4.26953C2.83361 13.3097 1.66956 12.1457 1.66953 10.7098L1.66943 5.29023ZM13.5362 9.49743L15.0032 10.312V5.68799L13.5362 6.50254V9.49743ZM4.26945 3.89019C3.49623 3.89018 2.86942 4.517 2.86943 5.29021L2.86953 10.7098C2.86955 11.483 3.49634 12.1097 4.26953 12.1097H10.9362C11.7094 12.1097 12.3362 11.4829 12.3362 10.7097V5.29026C12.3362 4.51707 11.7094 3.89027 10.9362 3.89026L4.26945 3.89019Z",fillRule:"evenodd",clipRule:"evenodd"}}]},{tag:"defs",attrs:{},children:[{tag:"clipPath",attrs:{id:"record-single_clip0_1559_19"},children:[{tag:"path",attrs:{fill:"#fff",d:"M0 0H16V16H0z",transform:"translate(.94)"}}]}]}],defIds:["record-single_clip0_1559_19"]},U=p.forwardRef(function(e,n){return p.createElement(L,Object.assign({},e,{id:"record-single",ref:n,icon:Q}))});U.displayName="RecordSingle";var X=Object.getOwnPropertyDescriptor,ee=(e,n,t,r)=>{for(var o=r>1?void 0:r?X(n,t):n,c=e.length-1,i;c>=0;c--)(i=e[c])&&(o=i(o)||o);return o},b=(e,n)=>(t,r)=>n(t,r,e);exports.ActionRecorderService=class extends s.Disposable{constructor(t,r,o,c){super();f(this,"_shouldRecordCommands",new Set);f(this,"_panelOpened$",new A.BehaviorSubject(!1));f(this,"panelOpened$",this._panelOpened$.asObservable());f(this,"_recorder",null);f(this,"_recording$",new A.BehaviorSubject(!1));f(this,"recording$",this._recording$.asObservable());f(this,"_recorded$",new A.BehaviorSubject([]));f(this,"_recordedCommands$",new A.BehaviorSubject([]));f(this,"recordedCommands$",this._recordedCommands$.asObservable());this._commandSrv=t,this._logService=r,this._localFileService=o,this._instanceService=c}get recording(){return this._recording$.getValue()}get _recorded(){return this._recorded$.getValue()}get _recordedCommands(){return this._recordedCommands$.getValue()}registerRecordedCommand(t){if(t.type===s.CommandType.MUTATION)throw new Error("[CommandRecorderService] Cannot record mutation commands.");this._shouldRecordCommands.add(t.id)}togglePanel(t){this._panelOpened$.next(t),t===!1&&this.stopRecording()}startRecording(t=!1){this._recorder=this._commandSrv.onCommandExecuted(r=>{var o,c;if(this._shouldRecordCommands.has(r.id)){const i=this._recorded,m=this._recordedCommands;let u={...r};const y=(o=this._instanceService.getFocusedUnit())==null?void 0:o.getUnitId(),{unitId:h=y,subUnitId:g}=u==null?void 0:u.params;if(t&&h&&g){const P=(c=this._instanceService.getUnit(h).getSheetBySheetId(g))==null?void 0:c.getName();u={...u,params:{...u.params,subUnitId:P}}}u.id===a.SetSelectionsOperation.id&&i.length>0&&i[i.length-1].id===a.SetSelectionsOperation.id?i[i.length-1]=u:(i.push(u),this._recorded$.next(i),u.type===s.CommandType.COMMAND&&(m.push(u),this._recordedCommands$.next(m)))}}),this._recording$.next(!0)}stopRecording(){var t;(t=this._recorder)==null||t.dispose(),this._recorder=null,this._recorded$.next([]),this._recordedCommands$.next([]),this._recording$.next(!1)}completeRecording(){const t=this._recorded.slice();this._localFileService.downloadFile(new Blob([JSON.stringify(t,null,2)]),"recorded-commands.json"),this._logService.error("Recorded commands:",t),this.stopRecording()}};exports.ActionRecorderService=ee([b(0,s.ICommandService),b(1,s.ILogService),b(2,d.ILocalFileService),b(3,s.IUniverInstanceService)],exports.ActionRecorderService);const k={id:"action-recorder.command.start-recording",type:s.CommandType.COMMAND,handler:(e,n)=>(e.get(exports.ActionRecorderService).startRecording(!!(n!=null&&n.replaceId)),!0)},V={id:"action-recorder.command.complete-recording",type:s.CommandType.COMMAND,handler:e=>(e.get(exports.ActionRecorderService).completeRecording(),!0)},W={id:"action-recorder.command.stop-recording",type:s.CommandType.COMMAND,handler:e=>(e.get(exports.ActionRecorderService).completeRecording(),!0)};var te=Object.getOwnPropertyDescriptor,re=(e,n,t,r)=>{for(var o=r>1?void 0:r?te(n,t):n,c=e.length-1,i;c>=0;c--)(i=e[c])&&(o=i(o)||o);return o},I=(e,n)=>(t,r)=>n(t,r,e),N=(e=>(e.DEFAULT="default",e.NAME="name",e.ACTIVE="active",e))(N||{});exports.ActionReplayService=class extends s.Disposable{constructor(n,t,r,o,c){super(),this._messageService=n,this._instanceService=t,this._localFileService=r,this._logService=o,this._commandService=c}async replayLocalJSON(n="default"){const t=await this._localFileService.openFile({multiple:!1,accept:".json"});if(t.length!==1)return!1;const r=t[0];try{return this.replayCommands(JSON.parse(await r.text()),{mode:n})}catch{return this._messageService.show({type:C.MessageType.Error,content:`Failed to replay commands from local file ${r.name}.`}),!1}}async replayCommands(n,t){var c,i,m;const r=(c=this._instanceService.getFocusedUnit())==null?void 0:c.getUnitId();r||this._logService.error("[ReplayService]","no focused unit to replay commands");const{mode:o}=t||{};for(const u of n){const{id:y,params:h}=u,g=h;if(g){if(typeof g.unitId<"u"&&(g.unitId=r),o==="name"&&g.subUnitId!=="undefined"){const _=(i=this._instanceService.getFocusedUnit().getSheetBySheetName(g.subUnitId))==null?void 0:i.getSheetId();_?g.subUnitId=_:this._logService.error("[ReplayService]",`failed to find subunit by subUnitName = ${g.subUnitId}`)}if(o==="active"&&g.subUnitId!=="undefined"){const _=(m=this._instanceService.getFocusedUnit().getActiveSheet())==null?void 0:m.getSheetId();_?g.subUnitId=_:this._logService.error("[ReplayService]","failed to find active subunit")}if(!await this._commandService.executeCommand(y,h))return!1}else if(!await this._commandService.executeCommand(y))return!1}return!0}async replayCommandsWithDelay(n){var r;const t=(r=this._instanceService.getFocusedUnit())==null?void 0:r.getUnitId();t||this._logService.error("[ReplayService]","no focused unit to replay commands");for(const o of n){await s.awaitTime(ne());const{id:c,params:i}=o;if(i){if(typeof i.unitId<"u"&&(i.unitId=t),!await this._commandService.executeCommand(c,i))return!1}else if(!await this._commandService.executeCommand(c))return!1}return!0}};exports.ActionReplayService=re([I(0,d.IMessageService),I(1,s.IUniverInstanceService),I(2,d.ILocalFileService),I(3,s.ILogService),I(4,s.ICommandService)],exports.ActionReplayService);function ne(){return Math.floor(Math.random()*800)+200}const j={id:"action-recorder.command.replay-local-records",type:s.CommandType.COMMAND,handler:async e=>{const t=await e.get(exports.ActionReplayService).replayLocalJSON();return t&&e.get(d.IMessageService).show({type:C.MessageType.Success,content:"Successfully replayed local records"}),t}},w={id:"action-recorder.command.replay-local-records-name",type:s.CommandType.COMMAND,handler:async e=>{const t=await e.get(exports.ActionReplayService).replayLocalJSON(N.NAME);return t&&e.get(d.IMessageService).show({type:C.MessageType.Success,content:"Successfully replayed local records"}),t}},$={id:"action-recorder.command.replay-local-records-active",type:s.CommandType.COMMAND,handler:async e=>{const t=await e.get(exports.ActionReplayService).replayLocalJSON(N.ACTIVE);return t&&e.get(d.IMessageService).show({type:C.MessageType.Success,content:"Successfully replayed local records"}),t}},F={id:"action-recorder.operation.open-panel",type:s.CommandType.OPERATION,handler(e){return e.get(exports.ActionRecorderService).togglePanel(!0),!0}},q={id:"action-recorder.operation.close-panel",type:s.CommandType.OPERATION,handler(e){return e.get(exports.ActionRecorderService).togglePanel(!1),!0}},oe="univer-action-recorder-panel",ce="univer-action-recorder-panel-icon",ie="univer-action-recorder-panel-icon-recording",ae="univer-action-recorder-panel-title",se="univer-action-recorder-panel-actions",O={actionRecorderPanel:oe,actionRecorderPanelIcon:ce,actionRecorderPanelIconRecording:ie,actionRecorderPanelTitle:ae,actionRecorderPanelActions:se};function de(){const e=d.useDependency(exports.ActionRecorderService);return d.useObservable(e.panelOpened$)?v.jsx(le,{}):null}function le(){var h;const e=d.useDependency(s.ICommandService),n=d.useDependency(exports.ActionRecorderService),t=d.useObservable(n.recording$),r=d.useObservable(n.recordedCommands$),o=(h=r==null?void 0:r.length)!=null?h:0,c=p.useCallback(()=>{t||e.executeCommand(q.id)},[e,t]),i=p.useCallback(g=>{t||e.executeCommand(k.id,{replaceId:g})},[e,t]),m=p.useCallback(()=>{t&&e.executeCommand(V.id)},[e,t]),u=p.useCallback(()=>{t&&e.executeCommand(W.id)},[e,t]),y=t?o===0?"Recording...":`${o}: ${r[o-1].id}`:"Start Recording";return v.jsxs("div",{className:O.actionRecorderPanel,children:[v.jsx("div",{className:C.clsx(O.actionRecorderPanelIcon,t?O.actionRecorderPanelIconRecording:!1),children:v.jsx(U,{})}),v.jsx("div",{className:O.actionRecorderPanelTitle,children:y}),v.jsxs("div",{className:O.actionRecorderPanelActions,children:[v.jsx(C.Button,{type:"default",size:"small",onClick:t?u:c,children:t?"Cancel":"Close"}),v.jsx(C.Button,{type:"primary",size:"small",onClick:t?m:()=>i(),children:t?"Save":"Start"}),!t&&v.jsx(C.Button,{type:"primary",size:"small",onClick:()=>i(!0),children:"Start(N)"})]})]})}const z="RECORD_MENU_ITEM";function me(){return{id:z,type:d.MenuItemType.SUBITEMS,icon:"RecordSingle",tooltip:"action-recorder.menu.title"}}function ue(e){const n=e.get(exports.ActionRecorderService);return{id:F.id,title:"action-recorder.menu.record",type:d.MenuItemType.BUTTON,disabled$:n.panelOpened$}}function ge(){return{id:j.id,title:"action-recorder.menu.replay-local",type:d.MenuItemType.BUTTON}}function Se(){return{id:w.id,title:"action-recorder.menu.replay-local-name",type:d.MenuItemType.BUTTON}}function fe(){return{id:$.id,title:"action-recorder.menu.replay-local-active",type:d.MenuItemType.BUTTON}}const ve={[d.RibbonStartGroup.OTHERS]:{[z]:{order:10,menuItemFactory:me,[F.id]:{order:1,menuItemFactory:ue},[j.id]:{order:2,menuItemFactory:ge},[w.id]:{order:3,menuItemFactory:Se},[$.id]:{order:4,menuItemFactory:fe}}}};var pe=Object.getOwnPropertyDescriptor,he=(e,n,t,r)=>{for(var o=r>1?void 0:r?pe(n,t):n,c=e.length-1,i;c>=0;c--)(i=e[c])&&(o=i(o)||o);return o},R=(e,n)=>(t,r)=>n(t,r,e);let M=class extends s.Disposable{constructor(e,n,t,r,o,c){super(),this._commandSrv=e,this._uiPartsSrv=n,this._menuManagerService=t,this._componentManager=r,this._actionRecorderService=o,this._injector=c,this._initCommands(),this._initUI(),this._initSheetsCommands(),this._initDocsCommands()}_initCommands(){[k,W,V,F,q,j,w,$].forEach(e=>this._commandSrv.registerCommand(e))}_initUI(){this._uiPartsSrv.registerComponent(d.BuiltInUIPart.GLOBAL,()=>d.connectInjector(de,this._injector)),this._componentManager.register("RecordSingle",U),this._menuManagerService.mergeMenu(ve)}_initSheetsCommands(){[a.CopySheetCommand,a.DeleteRangeMoveLeftCommand,a.DeleteRangeMoveUpCommand,a.DeltaColumnWidthCommand,a.DeltaRowHeightCommand,a.InsertSheetCommand,a.InsertColAfterCommand,a.InsertColBeforeCommand,a.InsertRowAfterCommand,a.InsertRowBeforeCommand,a.RemoveSheetCommand,a.SetStyleCommand,a.AddWorksheetMergeCommand,a.AddWorksheetMergeAllCommand,a.AddWorksheetMergeVerticalCommand,a.AddWorksheetMergeHorizontalCommand,a.SetFrozenCommand,a.CancelFrozenCommand,a.SetHorizontalTextAlignCommand,a.SetOverlineCommand,l.SetRangeBoldCommand,l.SetRangeFontFamilyCommand,l.SetRangeFontSizeCommand,l.SetRangeItalicCommand,l.SetRangeStrickThroughCommand,l.SetRangeSubscriptCommand,l.SetRangeSuperscriptCommand,l.SetRangeTextColorCommand,l.SetRangeUnderlineCommand,a.SetRangeValuesCommand,a.SetStrikeThroughCommand,a.SetTextColorCommand,a.SetTextRotationCommand,a.SetTextWrapCommand,a.SetVerticalTextAlignCommand,l.SheetCopyCommand,l.SheetCutCommand,l.SheetPasteBesidesBorderCommand,l.SheetPasteColWidthCommand,l.SheetPasteCommand,l.SheetPasteFormatCommand,l.SheetPasteShortKeyCommand,l.SheetPasteValueCommand,l.AutoFillCommand,l.RefillCommand,a.SetWorksheetActivateCommand,a.SetWorksheetActiveOperation,a.SetSelectionsOperation,x.SetSheetFilterRangeCommand,x.SetSheetsFilterCriteriaCommand,x.RemoveSheetFilterCommand].forEach(e=>this._actionRecorderService.registerRecordedCommand(e))}_initDocsCommands(){}};M=he([R(0,s.ICommandService),R(1,d.IUIPartsService),R(2,d.IMenuManagerService),R(3,s.Inject(d.ComponentManager)),R(4,s.Inject(exports.ActionRecorderService)),R(5,s.Inject(s.Injector))],M);const Ce="action-recorder.config",D={};var ye=Object.getOwnPropertyDescriptor,Re=(e,n,t,r)=>{for(var o=r>1?void 0:r?ye(n,t):n,c=e.length-1,i;c>=0;c--)(i=e[c])&&(o=i(o)||o);return o},E=(e,n)=>(t,r)=>n(t,r,e),T;exports.UniverActionRecorderPlugin=(T=class extends s.Plugin{constructor(n=D,t,r){super(),this._config=n,this._injector=t,this._configService=r;const{menu:o,...c}=s.merge({},D,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(Ce,c)}onStarting(){(this._config.replayOnly?[[exports.ActionReplayService]]:[[exports.ActionRecorderService],[exports.ActionReplayService],[M]]).forEach(t=>this._injector.add(t))}onSteady(){this._config.replayOnly||this._injector.get(M)}},f(T,"pluginName","UNIVER_ACTION_RECORDER_PLUGIN"),T);exports.UniverActionRecorderPlugin=Re([E(1,s.Inject(s.Injector)),E(2,s.IConfigService)],exports.UniverActionRecorderPlugin);
|
package/lib/es/index.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var m = (e, t, r) =>
|
|
4
|
-
import { Disposable as E, CommandType as u, ICommandService as
|
|
5
|
-
import { SetSelectionsOperation as $, CopySheetCommand as
|
|
6
|
-
import { SetSheetFilterRangeCommand as
|
|
7
|
-
import { SetRangeBoldCommand as
|
|
8
|
-
import { ILocalFileService as Y, IMessageService as
|
|
1
|
+
var ce = Object.defineProperty;
|
|
2
|
+
var ae = (e, t, r) => t in e ? ce(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
|
+
var m = (e, t, r) => ae(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
+
import { Disposable as E, CommandType as u, ICommandService as b, ILogService as G, IUniverInstanceService as Z, awaitTime as de, Inject as M, Injector as K, IConfigService as se, Plugin as le, merge as me } from "@univerjs/core";
|
|
5
|
+
import { SetSelectionsOperation as $, CopySheetCommand as ue, DeleteRangeMoveLeftCommand as fe, DeleteRangeMoveUpCommand as ge, DeltaColumnWidthCommand as he, DeltaRowHeightCommand as pe, InsertSheetCommand as Se, InsertColAfterCommand as ve, InsertColBeforeCommand as Ce, InsertRowAfterCommand as _e, InsertRowBeforeCommand as ye, RemoveSheetCommand as Re, SetStyleCommand as Ie, AddWorksheetMergeCommand as Oe, AddWorksheetMergeAllCommand as Pe, AddWorksheetMergeVerticalCommand as Me, AddWorksheetMergeHorizontalCommand as Ne, SetFrozenCommand as be, CancelFrozenCommand as xe, SetHorizontalTextAlignCommand as Ae, SetOverlineCommand as Ue, SetRangeValuesCommand as we, SetStrikeThroughCommand as $e, SetTextColorCommand as Te, SetTextRotationCommand as Fe, SetTextWrapCommand as Ee, SetVerticalTextAlignCommand as De, SetWorksheetActivateCommand as je, SetWorksheetActiveOperation as Le } from "@univerjs/sheets";
|
|
6
|
+
import { SetSheetFilterRangeCommand as Be, SetSheetsFilterCriteriaCommand as ke, RemoveSheetFilterCommand as Ve } from "@univerjs/sheets-filter";
|
|
7
|
+
import { SetRangeBoldCommand as We, SetRangeFontFamilyCommand as ze, SetRangeFontSizeCommand as He, SetRangeItalicCommand as Je, SetRangeStrickThroughCommand as Ge, SetRangeSubscriptCommand as Ze, SetRangeSuperscriptCommand as Ke, SetRangeTextColorCommand as Ye, SetRangeUnderlineCommand as qe, SheetCopyCommand as Qe, SheetCutCommand as Xe, SheetPasteBesidesBorderCommand as et, SheetPasteColWidthCommand as tt, SheetPasteCommand as rt, SheetPasteFormatCommand as nt, SheetPasteShortKeyCommand as ot, SheetPasteValueCommand as it, AutoFillCommand as ct, RefillCommand as at } from "@univerjs/sheets-ui";
|
|
8
|
+
import { ILocalFileService as Y, IMessageService as x, useDependency as T, useObservable as F, RibbonStartGroup as dt, MenuItemType as R, IUIPartsService as st, IMenuManagerService as lt, ComponentManager as mt, BuiltInUIPart as ut, connectInjector as ft } from "@univerjs/ui";
|
|
9
9
|
import { BehaviorSubject as I } from "rxjs";
|
|
10
|
-
import { MessageType as
|
|
10
|
+
import { MessageType as A, clsx as gt, Button as U } from "@univerjs/design";
|
|
11
11
|
import { jsx as h, jsxs as W } from "react/jsx-runtime";
|
|
12
12
|
import { forwardRef as q, useRef as ht, createElement as Q, useCallback as O } from "react";
|
|
13
|
-
var
|
|
14
|
-
return
|
|
13
|
+
var s = function() {
|
|
14
|
+
return s = Object.assign || function(e) {
|
|
15
15
|
for (var t, r = 1, n = arguments.length; r < n; r++) {
|
|
16
16
|
t = arguments[r];
|
|
17
17
|
for (var o in t) Object.prototype.hasOwnProperty.call(t, o) && (e[o] = t[o]);
|
|
18
18
|
}
|
|
19
19
|
return e;
|
|
20
|
-
},
|
|
20
|
+
}, s.apply(this, arguments);
|
|
21
21
|
}, pt = function(e, t) {
|
|
22
22
|
var r = {};
|
|
23
23
|
for (var n in e) Object.prototype.hasOwnProperty.call(e, n) && t.indexOf(n) < 0 && (r[n] = e[n]);
|
|
@@ -27,15 +27,15 @@ var d = function() {
|
|
|
27
27
|
return r;
|
|
28
28
|
}, X = q(function(e, t) {
|
|
29
29
|
var r = e.icon, n = e.id, o = e.className, i = e.extend, c = pt(e, ["icon", "id", "className", "extend"]), a = "univerjs-icon univerjs-icon-".concat(n, " ").concat(o || "").trim(), f = ht("_".concat(Ct()));
|
|
30
|
-
return ee(r, "".concat(n), { defIds: r.defIds, idSuffix: f.current },
|
|
30
|
+
return ee(r, "".concat(n), { defIds: r.defIds, idSuffix: f.current }, s({ ref: t, className: a }, c), i);
|
|
31
31
|
});
|
|
32
32
|
function ee(e, t, r, n, o) {
|
|
33
|
-
return Q(e.tag,
|
|
33
|
+
return Q(e.tag, s(s({ key: t }, St(e, r, o)), n), (vt(e, r).children || []).map(function(i, c) {
|
|
34
34
|
return ee(i, "".concat(t, "-").concat(e.tag, "-").concat(c), r, void 0, o);
|
|
35
35
|
}));
|
|
36
36
|
}
|
|
37
37
|
function St(e, t, r) {
|
|
38
|
-
var n =
|
|
38
|
+
var n = s({}, e.attrs);
|
|
39
39
|
r != null && r.colorChannel1 && n.fill === "colorChannel1" && (n.fill = r.colorChannel1), e.tag === "mask" && n.id && (n.id = n.id + t.idSuffix), Object.entries(n).forEach(function(i) {
|
|
40
40
|
var c = i[0], a = i[1];
|
|
41
41
|
c === "mask" && typeof a == "string" && (n[c] = a.replace(/url\(#(.*)\)/, "url(#$1".concat(t.idSuffix, ")")));
|
|
@@ -48,8 +48,8 @@ function St(e, t, r) {
|
|
|
48
48
|
}
|
|
49
49
|
function vt(e, t) {
|
|
50
50
|
var r, n = t.defIds;
|
|
51
|
-
return !n || n.length === 0 ? e : e.tag === "defs" && (!((r = e.children) === null || r === void 0) && r.length) ?
|
|
52
|
-
return typeof o.attrs.id == "string" && n && n.indexOf(o.attrs.id) > -1 ?
|
|
51
|
+
return !n || n.length === 0 ? e : e.tag === "defs" && (!((r = e.children) === null || r === void 0) && r.length) ? s(s({}, e), { children: e.children.map(function(o) {
|
|
52
|
+
return typeof o.attrs.id == "string" && n && n.indexOf(o.attrs.id) > -1 ? s(s({}, o), { attrs: s(s({}, o.attrs), { id: o.attrs.id + t.idSuffix }) }) : o;
|
|
53
53
|
}) }) : e;
|
|
54
54
|
}
|
|
55
55
|
function Ct() {
|
|
@@ -105,9 +105,9 @@ let l = class extends E {
|
|
|
105
105
|
if (this._shouldRecordCommands.has(r.id)) {
|
|
106
106
|
const i = this._recorded, c = this._recordedCommands;
|
|
107
107
|
let a = { ...r };
|
|
108
|
-
const f = (n = this._instanceService.getFocusedUnit()) == null ? void 0 : n.getUnitId(), { unitId: g = f, subUnitId:
|
|
109
|
-
if (t && g &&
|
|
110
|
-
const v = (o = this._instanceService.getUnit(g).getSheetBySheetId(
|
|
108
|
+
const f = (n = this._instanceService.getFocusedUnit()) == null ? void 0 : n.getUnitId(), { unitId: g = f, subUnitId: d } = a == null ? void 0 : a.params;
|
|
109
|
+
if (t && g && d) {
|
|
110
|
+
const v = (o = this._instanceService.getUnit(g).getSheetBySheetId(d)) == null ? void 0 : o.getName();
|
|
111
111
|
a = {
|
|
112
112
|
...a,
|
|
113
113
|
params: {
|
|
@@ -130,7 +130,7 @@ let l = class extends E {
|
|
|
130
130
|
}
|
|
131
131
|
};
|
|
132
132
|
l = Rt([
|
|
133
|
-
P(0,
|
|
133
|
+
P(0, b),
|
|
134
134
|
P(1, G),
|
|
135
135
|
P(2, Y),
|
|
136
136
|
P(3, Z)
|
|
@@ -168,7 +168,7 @@ let p = class extends E {
|
|
|
168
168
|
return this.replayCommands(JSON.parse(await r.text()), { mode: e });
|
|
169
169
|
} catch {
|
|
170
170
|
return this._messageService.show({
|
|
171
|
-
type:
|
|
171
|
+
type: A.Error,
|
|
172
172
|
content: `Failed to replay commands from local file ${r.name}.`
|
|
173
173
|
}), !1;
|
|
174
174
|
}
|
|
@@ -184,15 +184,15 @@ let p = class extends E {
|
|
|
184
184
|
r || this._logService.error("[ReplayService]", "no focused unit to replay commands");
|
|
185
185
|
const { mode: n } = t || {};
|
|
186
186
|
for (const a of e) {
|
|
187
|
-
const { id: f, params: g } = a,
|
|
188
|
-
if (
|
|
189
|
-
if (typeof
|
|
190
|
-
const C = (i = this._instanceService.getFocusedUnit().getSheetBySheetName(
|
|
191
|
-
C ?
|
|
187
|
+
const { id: f, params: g } = a, d = g;
|
|
188
|
+
if (d) {
|
|
189
|
+
if (typeof d.unitId < "u" && (d.unitId = r), n === "name" && d.subUnitId !== "undefined") {
|
|
190
|
+
const C = (i = this._instanceService.getFocusedUnit().getSheetBySheetName(d.subUnitId)) == null ? void 0 : i.getSheetId();
|
|
191
|
+
C ? d.subUnitId = C : this._logService.error("[ReplayService]", `failed to find subunit by subUnitName = ${d.subUnitId}`);
|
|
192
192
|
}
|
|
193
|
-
if (n === "active" &&
|
|
193
|
+
if (n === "active" && d.subUnitId !== "undefined") {
|
|
194
194
|
const C = (c = this._instanceService.getFocusedUnit().getActiveSheet()) == null ? void 0 : c.getSheetId();
|
|
195
|
-
C ?
|
|
195
|
+
C ? d.subUnitId = C : this._logService.error("[ReplayService]", "failed to find active subunit");
|
|
196
196
|
}
|
|
197
197
|
if (!await this._commandService.executeCommand(f, g)) return !1;
|
|
198
198
|
} else if (!await this._commandService.executeCommand(f)) return !1;
|
|
@@ -218,11 +218,11 @@ let p = class extends E {
|
|
|
218
218
|
}
|
|
219
219
|
};
|
|
220
220
|
p = Ot([
|
|
221
|
-
_(0,
|
|
221
|
+
_(0, x),
|
|
222
222
|
_(1, Z),
|
|
223
223
|
_(2, Y),
|
|
224
224
|
_(3, G),
|
|
225
|
-
_(4,
|
|
225
|
+
_(4, b)
|
|
226
226
|
], p);
|
|
227
227
|
function Pt() {
|
|
228
228
|
return Math.floor(Math.random() * 800) + 200;
|
|
@@ -232,8 +232,8 @@ const L = {
|
|
|
232
232
|
type: u.COMMAND,
|
|
233
233
|
handler: async (e) => {
|
|
234
234
|
const r = await e.get(p).replayLocalJSON();
|
|
235
|
-
return r && e.get(
|
|
236
|
-
type:
|
|
235
|
+
return r && e.get(x).show({
|
|
236
|
+
type: A.Success,
|
|
237
237
|
content: "Successfully replayed local records"
|
|
238
238
|
}), r;
|
|
239
239
|
}
|
|
@@ -242,8 +242,8 @@ const L = {
|
|
|
242
242
|
type: u.COMMAND,
|
|
243
243
|
handler: async (e) => {
|
|
244
244
|
const r = await e.get(p).replayLocalJSON(j.NAME);
|
|
245
|
-
return r && e.get(
|
|
246
|
-
type:
|
|
245
|
+
return r && e.get(x).show({
|
|
246
|
+
type: A.Success,
|
|
247
247
|
content: "Successfully replayed local records"
|
|
248
248
|
}), r;
|
|
249
249
|
}
|
|
@@ -252,8 +252,8 @@ const L = {
|
|
|
252
252
|
type: u.COMMAND,
|
|
253
253
|
handler: async (e) => {
|
|
254
254
|
const r = await e.get(p).replayLocalJSON(j.ACTIVE);
|
|
255
|
-
return r && e.get(
|
|
256
|
-
type:
|
|
255
|
+
return r && e.get(x).show({
|
|
256
|
+
type: A.Success,
|
|
257
257
|
content: "Successfully replayed local records"
|
|
258
258
|
}), r;
|
|
259
259
|
}
|
|
@@ -269,34 +269,20 @@ const L = {
|
|
|
269
269
|
handler(e) {
|
|
270
270
|
return e.get(l).togglePanel(!1), !0;
|
|
271
271
|
}
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
else if (typeof e == "object") if (Array.isArray(e)) {
|
|
277
|
-
var o = e.length;
|
|
278
|
-
for (t = 0; t < o; t++) e[t] && (r = ie(e[t])) && (n && (n += " "), n += r);
|
|
279
|
-
} else for (r in e) e[r] && (n && (n += " "), n += r);
|
|
280
|
-
return n;
|
|
281
|
-
}
|
|
282
|
-
function Mt() {
|
|
283
|
-
for (var e, t, r = 0, n = "", o = arguments.length; r < o; r++) (e = arguments[r]) && (t = ie(e)) && (n && (n += " "), n += t);
|
|
284
|
-
return n;
|
|
285
|
-
}
|
|
286
|
-
const bt = "univer-action-recorder-panel", At = "univer-action-recorder-panel-icon", Nt = "univer-action-recorder-panel-icon-recording", xt = "univer-action-recorder-panel-title", Ut = "univer-action-recorder-panel-actions", y = {
|
|
287
|
-
actionRecorderPanel: bt,
|
|
288
|
-
actionRecorderPanelIcon: At,
|
|
289
|
-
actionRecorderPanelIconRecording: Nt,
|
|
272
|
+
}, Mt = "univer-action-recorder-panel", Nt = "univer-action-recorder-panel-icon", bt = "univer-action-recorder-panel-icon-recording", xt = "univer-action-recorder-panel-title", At = "univer-action-recorder-panel-actions", y = {
|
|
273
|
+
actionRecorderPanel: Mt,
|
|
274
|
+
actionRecorderPanelIcon: Nt,
|
|
275
|
+
actionRecorderPanelIconRecording: bt,
|
|
290
276
|
actionRecorderPanelTitle: xt,
|
|
291
|
-
actionRecorderPanelActions:
|
|
277
|
+
actionRecorderPanelActions: At
|
|
292
278
|
};
|
|
293
|
-
function
|
|
279
|
+
function Ut() {
|
|
294
280
|
const e = T(l);
|
|
295
|
-
return F(e.panelOpened$) ? /* @__PURE__ */ h(
|
|
281
|
+
return F(e.panelOpened$) ? /* @__PURE__ */ h(wt, {}) : null;
|
|
296
282
|
}
|
|
297
|
-
function
|
|
298
|
-
var
|
|
299
|
-
const e = T(
|
|
283
|
+
function wt() {
|
|
284
|
+
var d;
|
|
285
|
+
const e = T(b), t = T(l), r = F(t.recording$), n = F(t.recordedCommands$), o = (d = n == null ? void 0 : n.length) != null ? d : 0, i = O(() => {
|
|
300
286
|
r || e.executeCommand(oe.id);
|
|
301
287
|
}, [e, r]), c = O((v) => {
|
|
302
288
|
r || e.executeCommand(te.id, { replaceId: v });
|
|
@@ -306,7 +292,7 @@ function $t() {
|
|
|
306
292
|
r && e.executeCommand(ne.id);
|
|
307
293
|
}, [e, r]), g = r ? o === 0 ? "Recording..." : `${o}: ${n[o - 1].id}` : "Start Recording";
|
|
308
294
|
return /* @__PURE__ */ W("div", { className: y.actionRecorderPanel, children: [
|
|
309
|
-
/* @__PURE__ */ h("div", { className:
|
|
295
|
+
/* @__PURE__ */ h("div", { className: gt(y.actionRecorderPanelIcon, r ? y.actionRecorderPanelIconRecording : !1), children: /* @__PURE__ */ h(D, {}) }),
|
|
310
296
|
/* @__PURE__ */ h("div", { className: y.actionRecorderPanelTitle, children: g }),
|
|
311
297
|
/* @__PURE__ */ W("div", { className: y.actionRecorderPanelActions, children: [
|
|
312
298
|
/* @__PURE__ */ h(U, { type: "default", size: "small", onClick: r ? f : i, children: r ? "Cancel" : "Close" }),
|
|
@@ -315,16 +301,16 @@ function $t() {
|
|
|
315
301
|
] })
|
|
316
302
|
] });
|
|
317
303
|
}
|
|
318
|
-
const
|
|
319
|
-
function
|
|
304
|
+
const ie = "RECORD_MENU_ITEM";
|
|
305
|
+
function $t() {
|
|
320
306
|
return {
|
|
321
|
-
id:
|
|
307
|
+
id: ie,
|
|
322
308
|
type: R.SUBITEMS,
|
|
323
309
|
icon: "RecordSingle",
|
|
324
310
|
tooltip: "action-recorder.menu.title"
|
|
325
311
|
};
|
|
326
312
|
}
|
|
327
|
-
function
|
|
313
|
+
function Tt(e) {
|
|
328
314
|
const t = e.get(l);
|
|
329
315
|
return {
|
|
330
316
|
id: V.id,
|
|
@@ -333,57 +319,57 @@ function Ft(e) {
|
|
|
333
319
|
disabled$: t.panelOpened$
|
|
334
320
|
};
|
|
335
321
|
}
|
|
336
|
-
function
|
|
322
|
+
function Ft() {
|
|
337
323
|
return {
|
|
338
324
|
id: L.id,
|
|
339
325
|
title: "action-recorder.menu.replay-local",
|
|
340
326
|
type: R.BUTTON
|
|
341
327
|
};
|
|
342
328
|
}
|
|
343
|
-
function
|
|
329
|
+
function Et() {
|
|
344
330
|
return {
|
|
345
331
|
id: B.id,
|
|
346
332
|
title: "action-recorder.menu.replay-local-name",
|
|
347
333
|
type: R.BUTTON
|
|
348
334
|
};
|
|
349
335
|
}
|
|
350
|
-
function
|
|
336
|
+
function Dt() {
|
|
351
337
|
return {
|
|
352
338
|
id: k.id,
|
|
353
339
|
title: "action-recorder.menu.replay-local-active",
|
|
354
340
|
type: R.BUTTON
|
|
355
341
|
};
|
|
356
342
|
}
|
|
357
|
-
const
|
|
343
|
+
const jt = {
|
|
358
344
|
[dt.OTHERS]: {
|
|
359
|
-
[
|
|
345
|
+
[ie]: {
|
|
360
346
|
order: 10,
|
|
361
|
-
menuItemFactory:
|
|
347
|
+
menuItemFactory: $t,
|
|
362
348
|
[V.id]: {
|
|
363
349
|
order: 1,
|
|
364
|
-
menuItemFactory:
|
|
350
|
+
menuItemFactory: Tt
|
|
365
351
|
},
|
|
366
352
|
[L.id]: {
|
|
367
353
|
order: 2,
|
|
368
|
-
menuItemFactory:
|
|
354
|
+
menuItemFactory: Ft
|
|
369
355
|
},
|
|
370
356
|
[B.id]: {
|
|
371
357
|
order: 3,
|
|
372
|
-
menuItemFactory:
|
|
358
|
+
menuItemFactory: Et
|
|
373
359
|
},
|
|
374
360
|
[k.id]: {
|
|
375
361
|
order: 4,
|
|
376
|
-
menuItemFactory:
|
|
362
|
+
menuItemFactory: Dt
|
|
377
363
|
}
|
|
378
364
|
}
|
|
379
365
|
}
|
|
380
366
|
};
|
|
381
|
-
var
|
|
382
|
-
for (var o = n > 1 ? void 0 : n ?
|
|
367
|
+
var Lt = Object.getOwnPropertyDescriptor, Bt = (e, t, r, n) => {
|
|
368
|
+
for (var o = n > 1 ? void 0 : n ? Lt(t, r) : t, i = e.length - 1, c; i >= 0; i--)
|
|
383
369
|
(c = e[i]) && (o = c(o) || o);
|
|
384
370
|
return o;
|
|
385
371
|
}, S = (e, t) => (r, n) => t(r, n, e);
|
|
386
|
-
let
|
|
372
|
+
let N = class extends E {
|
|
387
373
|
constructor(e, t, r, n, o, i) {
|
|
388
374
|
super(), this._commandSrv = e, this._uiPartsSrv = t, this._menuManagerService = r, this._componentManager = n, this._actionRecorderService = o, this._injector = i, this._initCommands(), this._initUI(), this._initSheetsCommands(), this._initDocsCommands();
|
|
389
375
|
}
|
|
@@ -400,13 +386,14 @@ let b = class extends E {
|
|
|
400
386
|
].forEach((e) => this._commandSrv.registerCommand(e));
|
|
401
387
|
}
|
|
402
388
|
_initUI() {
|
|
403
|
-
this._uiPartsSrv.registerComponent(
|
|
389
|
+
this._uiPartsSrv.registerComponent(ut.GLOBAL, () => ft(Ut, this._injector)), this._componentManager.register("RecordSingle", D), this._menuManagerService.mergeMenu(jt);
|
|
404
390
|
}
|
|
405
391
|
_initSheetsCommands() {
|
|
406
392
|
[
|
|
407
393
|
// InsertColCommand,
|
|
408
394
|
// InsertRowCommand,
|
|
409
395
|
// #region basic commands
|
|
396
|
+
ue,
|
|
410
397
|
fe,
|
|
411
398
|
ge,
|
|
412
399
|
he,
|
|
@@ -421,19 +408,19 @@ let b = class extends E {
|
|
|
421
408
|
Oe,
|
|
422
409
|
Pe,
|
|
423
410
|
Me,
|
|
424
|
-
|
|
425
|
-
Ae,
|
|
411
|
+
Ne,
|
|
426
412
|
// ResetBackgroundColorCommand,
|
|
427
413
|
// ResetTextColorCommand,
|
|
428
414
|
// SetBackgroundColorCommand,
|
|
429
415
|
// SetBoldCommand,
|
|
430
416
|
// SetFontFamilyCommand,
|
|
431
417
|
// SetFontSizeCommand,
|
|
432
|
-
|
|
418
|
+
be,
|
|
433
419
|
xe,
|
|
434
|
-
|
|
420
|
+
Ae,
|
|
435
421
|
// SetItalicCommand,
|
|
436
|
-
|
|
422
|
+
Ue,
|
|
423
|
+
We,
|
|
437
424
|
ze,
|
|
438
425
|
He,
|
|
439
426
|
Je,
|
|
@@ -442,14 +429,14 @@ let b = class extends E {
|
|
|
442
429
|
Ke,
|
|
443
430
|
Ye,
|
|
444
431
|
qe,
|
|
445
|
-
|
|
432
|
+
we,
|
|
446
433
|
$e,
|
|
447
434
|
Te,
|
|
448
435
|
Fe,
|
|
449
436
|
Ee,
|
|
450
|
-
De,
|
|
451
437
|
// SetUnderlineCommand,
|
|
452
|
-
|
|
438
|
+
De,
|
|
439
|
+
Qe,
|
|
453
440
|
Xe,
|
|
454
441
|
et,
|
|
455
442
|
tt,
|
|
@@ -459,9 +446,8 @@ let b = class extends E {
|
|
|
459
446
|
it,
|
|
460
447
|
ct,
|
|
461
448
|
at,
|
|
462
|
-
|
|
449
|
+
je,
|
|
463
450
|
Le,
|
|
464
|
-
Be,
|
|
465
451
|
$,
|
|
466
452
|
// #endregion
|
|
467
453
|
// #region data validation command
|
|
@@ -469,53 +455,53 @@ let b = class extends E {
|
|
|
469
455
|
// #region conditional formatting command
|
|
470
456
|
// #endregion
|
|
471
457
|
// #region filter command
|
|
458
|
+
Be,
|
|
472
459
|
ke,
|
|
473
|
-
Ve
|
|
474
|
-
We
|
|
460
|
+
Ve
|
|
475
461
|
// #endregion
|
|
476
462
|
].forEach((e) => this._actionRecorderService.registerRecordedCommand(e));
|
|
477
463
|
}
|
|
478
464
|
_initDocsCommands() {
|
|
479
465
|
}
|
|
480
466
|
};
|
|
481
|
-
|
|
482
|
-
S(0,
|
|
483
|
-
S(1,
|
|
484
|
-
S(2,
|
|
485
|
-
S(3, M(
|
|
467
|
+
N = Bt([
|
|
468
|
+
S(0, b),
|
|
469
|
+
S(1, st),
|
|
470
|
+
S(2, lt),
|
|
471
|
+
S(3, M(mt)),
|
|
486
472
|
S(4, M(l)),
|
|
487
473
|
S(5, M(K))
|
|
488
|
-
],
|
|
489
|
-
const
|
|
490
|
-
var
|
|
491
|
-
for (var o = n > 1 ? void 0 : n ?
|
|
474
|
+
], N);
|
|
475
|
+
const kt = "action-recorder.config", z = {};
|
|
476
|
+
var Vt = Object.getOwnPropertyDescriptor, Wt = (e, t, r, n) => {
|
|
477
|
+
for (var o = n > 1 ? void 0 : n ? Vt(t, r) : t, i = e.length - 1, c; i >= 0; i--)
|
|
492
478
|
(c = e[i]) && (o = c(o) || o);
|
|
493
479
|
return o;
|
|
494
480
|
}, H = (e, t) => (r, n) => t(r, n, e), w;
|
|
495
|
-
let J = (w = class extends
|
|
481
|
+
let J = (w = class extends le {
|
|
496
482
|
constructor(e = z, t, r) {
|
|
497
483
|
super(), this._config = e, this._injector = t, this._configService = r;
|
|
498
|
-
const { menu: n, ...o } =
|
|
484
|
+
const { menu: n, ...o } = me(
|
|
499
485
|
{},
|
|
500
486
|
z,
|
|
501
487
|
this._config
|
|
502
488
|
);
|
|
503
|
-
n && this._configService.setConfig("menu", n, { merge: !0 }), this._configService.setConfig(
|
|
489
|
+
n && this._configService.setConfig("menu", n, { merge: !0 }), this._configService.setConfig(kt, o);
|
|
504
490
|
}
|
|
505
491
|
onStarting() {
|
|
506
492
|
(this._config.replayOnly ? [[p]] : [
|
|
507
493
|
[l],
|
|
508
494
|
[p],
|
|
509
|
-
[
|
|
495
|
+
[N]
|
|
510
496
|
]).forEach((t) => this._injector.add(t));
|
|
511
497
|
}
|
|
512
498
|
onSteady() {
|
|
513
|
-
this._config.replayOnly || this._injector.get(
|
|
499
|
+
this._config.replayOnly || this._injector.get(N);
|
|
514
500
|
}
|
|
515
501
|
}, m(w, "pluginName", "UNIVER_ACTION_RECORDER_PLUGIN"), w);
|
|
516
|
-
J =
|
|
502
|
+
J = Wt([
|
|
517
503
|
H(1, M(K)),
|
|
518
|
-
H(2,
|
|
504
|
+
H(2, se)
|
|
519
505
|
], J);
|
|
520
506
|
export {
|
|
521
507
|
l as ActionRecorderService,
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(i,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("@univerjs/sheets-filter"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/design"),require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","@univerjs/sheets-filter","@univerjs/sheets-ui","@univerjs/ui","rxjs","@univerjs/design","react/jsx-runtime","react"],a):(i=typeof globalThis<"u"?globalThis:i||self,a(i.UniverActionRecorder={},i.UniverCore,i.UniverSheets,i.UniverSheetsFilter,i.UniverSheetsUi,i.UniverUi,i.rxjs,i.UniverDesign,i.React,i.React))})(this,function(i,a,l,b,m,s,P,h,p,C){"use strict";var Ce=Object.defineProperty;var ye=(i,a,l)=>a in i?Ce(i,a,{enumerable:!0,configurable:!0,writable:!0,value:l}):i[a]=l;var g=(i,a,l)=>ye(i,typeof a!="symbol"?a+"":a,l);var F;var S=function(){return S=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++){t=arguments[n];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},S.apply(this,arguments)},G=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n},L=C.forwardRef(function(e,t){var n=e.icon,r=e.id,o=e.className,c=e.extend,d=G(e,["icon","id","className","extend"]),u="univerjs-icon univerjs-icon-".concat(r," ").concat(o||"").trim(),f=C.useRef("_".concat(Y()));return x(n,"".concat(r),{defIds:n.defIds,idSuffix:f.current},S({ref:t,className:u},d),c)});function x(e,t,n,r,o){return C.createElement(e.tag,S(S({key:t},Z(e,n,o)),r),(K(e,n).children||[]).map(function(c,d){return x(c,"".concat(t,"-").concat(e.tag,"-").concat(d),n,void 0,o)}))}function Z(e,t,n){var r=S({},e.attrs);n!=null&&n.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=n.colorChannel1),e.tag==="mask"&&r.id&&(r.id=r.id+t.idSuffix),Object.entries(r).forEach(function(c){var d=c[0],u=c[1];d==="mask"&&typeof u=="string"&&(r[d]=u.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var o=t.defIds;return!o||o.length===0||(e.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+t.idSuffix),Object.entries(r).forEach(function(c){var d=c[0],u=c[1];typeof u=="string"&&(r[d]=u.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),r}function K(e,t){var n,r=t.defIds;return!r||r.length===0?e:e.tag==="defs"&&(!((n=e.children)===null||n===void 0)&&n.length)?S(S({},e),{children:e.children.map(function(o){return typeof o.attrs.id=="string"&&r&&r.indexOf(o.attrs.id)>-1?S(S({},o),{attrs:S(S({},o.attrs),{id:o.attrs.id+t.idSuffix})}):o})}):e}function Y(){return Math.random().toString(36).substring(2,8)}L.displayName="UniverIcon";var Q={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"g",attrs:{fill:"currentColor",clipPath:"url(#record-single_clip0_1559_19)"},children:[{tag:"path",attrs:{d:"M7.60303 10C8.7076 10 9.60303 9.10457 9.60303 8C9.60303 6.89543 8.7076 6 7.60303 6C6.49846 6 5.60303 6.89543 5.60303 8C5.60303 9.10457 6.49846 10 7.60303 10Z"}},{tag:"path",attrs:{d:"M1.66943 5.29023C1.66941 3.85426 2.83349 2.69017 4.26946 2.69019L10.9362 2.69026C12.3192 2.69028 13.45 3.77008 13.5315 5.13259L14.5692 4.55638C15.3024 4.14929 16.2032 4.67947 16.2032 5.51809V10.4819C16.2032 11.3205 15.3024 11.8507 14.5692 11.4436L13.5315 10.8674C13.45 12.2299 12.3192 13.3097 10.9362 13.3097H4.26953C2.83361 13.3097 1.66956 12.1457 1.66953 10.7098L1.66943 5.29023ZM13.5362 9.49743L15.0032 10.312V5.68799L13.5362 6.50254V9.49743ZM4.26945 3.89019C3.49623 3.89018 2.86942 4.517 2.86943 5.29021L2.86953 10.7098C2.86955 11.483 3.49634 12.1097 4.26953 12.1097H10.9362C11.7094 12.1097 12.3362 11.4829 12.3362 10.7097V5.29026C12.3362 4.51707 11.7094 3.89027 10.9362 3.89026L4.26945 3.89019Z",fillRule:"evenodd",clipRule:"evenodd"}}]},{tag:"defs",attrs:{},children:[{tag:"clipPath",attrs:{id:"record-single_clip0_1559_19"},children:[{tag:"path",attrs:{fill:"#fff",d:"M0 0H16V16H0z",transform:"translate(.94)"}}]}]}],defIds:["record-single_clip0_1559_19"]},j=C.forwardRef(function(e,t){return C.createElement(L,Object.assign({},e,{id:"record-single",ref:t,icon:Q}))});j.displayName="RecordSingle";var X=Object.getOwnPropertyDescriptor,ee=(e,t,n,r)=>{for(var o=r>1?void 0:r?X(t,n):t,c=e.length-1,d;c>=0;c--)(d=e[c])&&(o=d(o)||o);return o},M=(e,t)=>(n,r)=>t(n,r,e);i.ActionRecorderService=class extends a.Disposable{constructor(n,r,o,c){super();g(this,"_shouldRecordCommands",new Set);g(this,"_panelOpened$",new P.BehaviorSubject(!1));g(this,"panelOpened$",this._panelOpened$.asObservable());g(this,"_recorder",null);g(this,"_recording$",new P.BehaviorSubject(!1));g(this,"recording$",this._recording$.asObservable());g(this,"_recorded$",new P.BehaviorSubject([]));g(this,"_recordedCommands$",new P.BehaviorSubject([]));g(this,"recordedCommands$",this._recordedCommands$.asObservable());this._commandSrv=n,this._logService=r,this._localFileService=o,this._instanceService=c}get recording(){return this._recording$.getValue()}get _recorded(){return this._recorded$.getValue()}get _recordedCommands(){return this._recordedCommands$.getValue()}registerRecordedCommand(n){if(n.type===a.CommandType.MUTATION)throw new Error("[CommandRecorderService] Cannot record mutation commands.");this._shouldRecordCommands.add(n.id)}togglePanel(n){this._panelOpened$.next(n),n===!1&&this.stopRecording()}startRecording(n=!1){this._recorder=this._commandSrv.onCommandExecuted(r=>{var o,c;if(this._shouldRecordCommands.has(r.id)){const d=this._recorded,u=this._recordedCommands;let f={...r};const _=(o=this._instanceService.getFocusedUnit())==null?void 0:o.getUnitId(),{unitId:y=_,subUnitId:v}=f==null?void 0:f.params;if(n&&y&&v){const E=(c=this._instanceService.getUnit(y).getSheetBySheetId(v))==null?void 0:c.getName();f={...f,params:{...f.params,subUnitId:E}}}f.id===l.SetSelectionsOperation.id&&d.length>0&&d[d.length-1].id===l.SetSelectionsOperation.id?d[d.length-1]=f:(d.push(f),this._recorded$.next(d),f.type===a.CommandType.COMMAND&&(u.push(f),this._recordedCommands$.next(u)))}}),this._recording$.next(!0)}stopRecording(){var n;(n=this._recorder)==null||n.dispose(),this._recorder=null,this._recorded$.next([]),this._recordedCommands$.next([]),this._recording$.next(!1)}completeRecording(){const n=this._recorded.slice();this._localFileService.downloadFile(new Blob([JSON.stringify(n,null,2)]),"recorded-commands.json"),this._logService.error("Recorded commands:",n),this.stopRecording()}},i.ActionRecorderService=ee([M(0,a.ICommandService),M(1,a.ILogService),M(2,s.ILocalFileService),M(3,a.IUniverInstanceService)],i.ActionRecorderService);const B={id:"action-recorder.command.start-recording",type:a.CommandType.COMMAND,handler:(e,t)=>(e.get(i.ActionRecorderService).startRecording(!!(t!=null&&t.replaceId)),!0)},k={id:"action-recorder.command.complete-recording",type:a.CommandType.COMMAND,handler:e=>(e.get(i.ActionRecorderService).completeRecording(),!0)},V={id:"action-recorder.command.stop-recording",type:a.CommandType.COMMAND,handler:e=>(e.get(i.ActionRecorderService).completeRecording(),!0)};var ne=Object.getOwnPropertyDescriptor,re=(e,t,n,r)=>{for(var o=r>1?void 0:r?ne(t,n):t,c=e.length-1,d;c>=0;c--)(d=e[c])&&(o=d(o)||o);return o},I=(e,t)=>(n,r)=>t(n,r,e),N=(e=>(e.DEFAULT="default",e.NAME="name",e.ACTIVE="active",e))(N||{});i.ActionReplayService=class extends a.Disposable{constructor(t,n,r,o,c){super(),this._messageService=t,this._instanceService=n,this._localFileService=r,this._logService=o,this._commandService=c}async replayLocalJSON(t="default"){const n=await this._localFileService.openFile({multiple:!1,accept:".json"});if(n.length!==1)return!1;const r=n[0];try{return this.replayCommands(JSON.parse(await r.text()),{mode:t})}catch{return this._messageService.show({type:h.MessageType.Error,content:`Failed to replay commands from local file ${r.name}.`}),!1}}async replayCommands(t,n){var c,d,u;const r=(c=this._instanceService.getFocusedUnit())==null?void 0:c.getUnitId();r||this._logService.error("[ReplayService]","no focused unit to replay commands");const{mode:o}=n||{};for(const f of t){const{id:_,params:y}=f,v=y;if(v){if(typeof v.unitId<"u"&&(v.unitId=r),o==="name"&&v.subUnitId!=="undefined"){const A=(d=this._instanceService.getFocusedUnit().getSheetBySheetName(v.subUnitId))==null?void 0:d.getSheetId();A?v.subUnitId=A:this._logService.error("[ReplayService]",`failed to find subunit by subUnitName = ${v.subUnitId}`)}if(o==="active"&&v.subUnitId!=="undefined"){const A=(u=this._instanceService.getFocusedUnit().getActiveSheet())==null?void 0:u.getSheetId();A?v.subUnitId=A:this._logService.error("[ReplayService]","failed to find active subunit")}if(!await this._commandService.executeCommand(_,y))return!1}else if(!await this._commandService.executeCommand(_))return!1}return!0}async replayCommandsWithDelay(t){var r;const n=(r=this._instanceService.getFocusedUnit())==null?void 0:r.getUnitId();n||this._logService.error("[ReplayService]","no focused unit to replay commands");for(const o of t){await a.awaitTime(te());const{id:c,params:d}=o;if(d){if(typeof d.unitId<"u"&&(d.unitId=n),!await this._commandService.executeCommand(c,d))return!1}else if(!await this._commandService.executeCommand(c))return!1}return!0}},i.ActionReplayService=re([I(0,s.IMessageService),I(1,a.IUniverInstanceService),I(2,s.ILocalFileService),I(3,a.ILogService),I(4,a.ICommandService)],i.ActionReplayService);function te(){return Math.floor(Math.random()*800)+200}const w={id:"action-recorder.command.replay-local-records",type:a.CommandType.COMMAND,handler:async e=>{const n=await e.get(i.ActionReplayService).replayLocalJSON();return n&&e.get(s.IMessageService).show({type:h.MessageType.Success,content:"Successfully replayed local records"}),n}},U={id:"action-recorder.command.replay-local-records-name",type:a.CommandType.COMMAND,handler:async e=>{const n=await e.get(i.ActionReplayService).replayLocalJSON(N.NAME);return n&&e.get(s.IMessageService).show({type:h.MessageType.Success,content:"Successfully replayed local records"}),n}},$={id:"action-recorder.command.replay-local-records-active",type:a.CommandType.COMMAND,handler:async e=>{const n=await e.get(i.ActionReplayService).replayLocalJSON(N.ACTIVE);return n&&e.get(s.IMessageService).show({type:h.MessageType.Success,content:"Successfully replayed local records"}),n}},D={id:"action-recorder.operation.open-panel",type:a.CommandType.OPERATION,handler(e){return e.get(i.ActionRecorderService).togglePanel(!0),!0}},W={id:"action-recorder.operation.close-panel",type:a.CommandType.OPERATION,handler(e){return e.get(i.ActionRecorderService).togglePanel(!1),!0}};function q(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(n=q(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function oe(){for(var e,t,n=0,r="",o=arguments.length;n<o;n++)(e=arguments[n])&&(t=q(e))&&(r&&(r+=" "),r+=t);return r}const O={actionRecorderPanel:"univer-action-recorder-panel",actionRecorderPanelIcon:"univer-action-recorder-panel-icon",actionRecorderPanelIconRecording:"univer-action-recorder-panel-icon-recording",actionRecorderPanelTitle:"univer-action-recorder-panel-title",actionRecorderPanelActions:"univer-action-recorder-panel-actions"};function ie(){const e=s.useDependency(i.ActionRecorderService);return s.useObservable(e.panelOpened$)?p.jsx(ce,{}):null}function ce(){var y;const e=s.useDependency(a.ICommandService),t=s.useDependency(i.ActionRecorderService),n=s.useObservable(t.recording$),r=s.useObservable(t.recordedCommands$),o=(y=r==null?void 0:r.length)!=null?y:0,c=C.useCallback(()=>{n||e.executeCommand(W.id)},[e,n]),d=C.useCallback(v=>{n||e.executeCommand(B.id,{replaceId:v})},[e,n]),u=C.useCallback(()=>{n&&e.executeCommand(k.id)},[e,n]),f=C.useCallback(()=>{n&&e.executeCommand(V.id)},[e,n]),_=n?o===0?"Recording...":`${o}: ${r[o-1].id}`:"Start Recording";return p.jsxs("div",{className:O.actionRecorderPanel,children:[p.jsx("div",{className:oe(O.actionRecorderPanelIcon,n?O.actionRecorderPanelIconRecording:!1),children:p.jsx(j,{})}),p.jsx("div",{className:O.actionRecorderPanelTitle,children:_}),p.jsxs("div",{className:O.actionRecorderPanelActions,children:[p.jsx(h.Button,{type:"default",size:"small",onClick:n?f:c,children:n?"Cancel":"Close"}),p.jsx(h.Button,{type:"primary",size:"small",onClick:n?u:()=>d(),children:n?"Save":"Start"}),!n&&p.jsx(h.Button,{type:"primary",size:"small",onClick:()=>d(!0),children:"Start(N)"})]})]})}const z="RECORD_MENU_ITEM";function ae(){return{id:z,type:s.MenuItemType.SUBITEMS,icon:"RecordSingle",tooltip:"action-recorder.menu.title"}}function de(e){const t=e.get(i.ActionRecorderService);return{id:D.id,title:"action-recorder.menu.record",type:s.MenuItemType.BUTTON,disabled$:t.panelOpened$}}function le(){return{id:w.id,title:"action-recorder.menu.replay-local",type:s.MenuItemType.BUTTON}}function se(){return{id:U.id,title:"action-recorder.menu.replay-local-name",type:s.MenuItemType.BUTTON}}function me(){return{id:$.id,title:"action-recorder.menu.replay-local-active",type:s.MenuItemType.BUTTON}}const ue={[s.RibbonStartGroup.OTHERS]:{[z]:{order:10,menuItemFactory:ae,[D.id]:{order:1,menuItemFactory:de},[w.id]:{order:2,menuItemFactory:le},[U.id]:{order:3,menuItemFactory:se},[$.id]:{order:4,menuItemFactory:me}}}};var fe=Object.getOwnPropertyDescriptor,ve=(e,t,n,r)=>{for(var o=r>1?void 0:r?fe(t,n):t,c=e.length-1,d;c>=0;c--)(d=e[c])&&(o=d(o)||o);return o},R=(e,t)=>(n,r)=>t(n,r,e);let T=class extends a.Disposable{constructor(e,t,n,r,o,c){super(),this._commandSrv=e,this._uiPartsSrv=t,this._menuManagerService=n,this._componentManager=r,this._actionRecorderService=o,this._injector=c,this._initCommands(),this._initUI(),this._initSheetsCommands(),this._initDocsCommands()}_initCommands(){[B,V,k,D,W,w,U,$].forEach(e=>this._commandSrv.registerCommand(e))}_initUI(){this._uiPartsSrv.registerComponent(s.BuiltInUIPart.GLOBAL,()=>s.connectInjector(ie,this._injector)),this._componentManager.register("RecordSingle",j),this._menuManagerService.mergeMenu(ue)}_initSheetsCommands(){[l.CopySheetCommand,l.DeleteRangeMoveLeftCommand,l.DeleteRangeMoveUpCommand,l.DeltaColumnWidthCommand,l.DeltaRowHeightCommand,l.InsertSheetCommand,l.InsertColAfterCommand,l.InsertColBeforeCommand,l.InsertRowAfterCommand,l.InsertRowBeforeCommand,l.RemoveSheetCommand,l.SetStyleCommand,l.AddWorksheetMergeCommand,l.AddWorksheetMergeAllCommand,l.AddWorksheetMergeVerticalCommand,l.AddWorksheetMergeHorizontalCommand,l.SetFrozenCommand,l.CancelFrozenCommand,l.SetHorizontalTextAlignCommand,l.SetOverlineCommand,m.SetRangeBoldCommand,m.SetRangeFontFamilyCommand,m.SetRangeFontSizeCommand,m.SetRangeItalicCommand,m.SetRangeStrickThroughCommand,m.SetRangeSubscriptCommand,m.SetRangeSuperscriptCommand,m.SetRangeTextColorCommand,m.SetRangeUnderlineCommand,l.SetRangeValuesCommand,l.SetStrikeThroughCommand,l.SetTextColorCommand,l.SetTextRotationCommand,l.SetTextWrapCommand,l.SetVerticalTextAlignCommand,m.SheetCopyCommand,m.SheetCutCommand,m.SheetPasteBesidesBorderCommand,m.SheetPasteColWidthCommand,m.SheetPasteCommand,m.SheetPasteFormatCommand,m.SheetPasteShortKeyCommand,m.SheetPasteValueCommand,m.AutoFillCommand,m.RefillCommand,l.SetWorksheetActivateCommand,l.SetWorksheetActiveOperation,l.SetSelectionsOperation,b.SetSheetFilterRangeCommand,b.SetSheetsFilterCriteriaCommand,b.RemoveSheetFilterCommand].forEach(e=>this._actionRecorderService.registerRecordedCommand(e))}_initDocsCommands(){}};T=ve([R(0,a.ICommandService),R(1,s.IUIPartsService),R(2,s.IMenuManagerService),R(3,a.Inject(s.ComponentManager)),R(4,a.Inject(i.ActionRecorderService)),R(5,a.Inject(a.Injector))],T);const Se="action-recorder.config",H={};var ge=Object.getOwnPropertyDescriptor,pe=(e,t,n,r)=>{for(var o=r>1?void 0:r?ge(t,n):t,c=e.length-1,d;c>=0;c--)(d=e[c])&&(o=d(o)||o);return o},J=(e,t)=>(n,r)=>t(n,r,e);i.UniverActionRecorderPlugin=(F=class extends a.Plugin{constructor(t=H,n,r){super(),this._config=t,this._injector=n,this._configService=r;const{menu:o,...c}=a.merge({},H,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(Se,c)}onStarting(){(this._config.replayOnly?[[i.ActionReplayService]]:[[i.ActionRecorderService],[i.ActionReplayService],[T]]).forEach(n=>this._injector.add(n))}onSteady(){this._config.replayOnly||this._injector.get(T)}},g(F,"pluginName","UNIVER_ACTION_RECORDER_PLUGIN"),F),i.UniverActionRecorderPlugin=pe([J(1,a.Inject(a.Injector)),J(2,a.IConfigService)],i.UniverActionRecorderPlugin),Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(c,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("@univerjs/sheets-filter"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/design"),require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","@univerjs/sheets-filter","@univerjs/sheets-ui","@univerjs/ui","rxjs","@univerjs/design","react/jsx-runtime","react"],a):(c=typeof globalThis<"u"?globalThis:c||self,a(c.UniverActionRecorder={},c.UniverCore,c.UniverSheets,c.UniverSheetsFilter,c.UniverSheetsUi,c.UniverUi,c.rxjs,c.UniverDesign,c.React,c.React))})(this,function(c,a,l,b,m,s,P,y,p,C){"use strict";var ge=Object.defineProperty;var pe=(c,a,l)=>a in c?ge(c,a,{enumerable:!0,configurable:!0,writable:!0,value:l}):c[a]=l;var g=(c,a,l)=>pe(c,typeof a!="symbol"?a+"":a,l);var F;var S=function(){return S=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++){t=arguments[n];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},S.apply(this,arguments)},J=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n},L=C.forwardRef(function(e,t){var n=e.icon,r=e.id,o=e.className,i=e.extend,d=J(e,["icon","id","className","extend"]),u="univerjs-icon univerjs-icon-".concat(r," ").concat(o||"").trim(),v=C.useRef("_".concat(K()));return x(n,"".concat(r),{defIds:n.defIds,idSuffix:v.current},S({ref:t,className:u},d),i)});function x(e,t,n,r,o){return C.createElement(e.tag,S(S({key:t},G(e,n,o)),r),(Z(e,n).children||[]).map(function(i,d){return x(i,"".concat(t,"-").concat(e.tag,"-").concat(d),n,void 0,o)}))}function G(e,t,n){var r=S({},e.attrs);n!=null&&n.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=n.colorChannel1),e.tag==="mask"&&r.id&&(r.id=r.id+t.idSuffix),Object.entries(r).forEach(function(i){var d=i[0],u=i[1];d==="mask"&&typeof u=="string"&&(r[d]=u.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var o=t.defIds;return!o||o.length===0||(e.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+t.idSuffix),Object.entries(r).forEach(function(i){var d=i[0],u=i[1];typeof u=="string"&&(r[d]=u.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),r}function Z(e,t){var n,r=t.defIds;return!r||r.length===0?e:e.tag==="defs"&&(!((n=e.children)===null||n===void 0)&&n.length)?S(S({},e),{children:e.children.map(function(o){return typeof o.attrs.id=="string"&&r&&r.indexOf(o.attrs.id)>-1?S(S({},o),{attrs:S(S({},o.attrs),{id:o.attrs.id+t.idSuffix})}):o})}):e}function K(){return Math.random().toString(36).substring(2,8)}L.displayName="UniverIcon";var Y={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"g",attrs:{fill:"currentColor",clipPath:"url(#record-single_clip0_1559_19)"},children:[{tag:"path",attrs:{d:"M7.60303 10C8.7076 10 9.60303 9.10457 9.60303 8C9.60303 6.89543 8.7076 6 7.60303 6C6.49846 6 5.60303 6.89543 5.60303 8C5.60303 9.10457 6.49846 10 7.60303 10Z"}},{tag:"path",attrs:{d:"M1.66943 5.29023C1.66941 3.85426 2.83349 2.69017 4.26946 2.69019L10.9362 2.69026C12.3192 2.69028 13.45 3.77008 13.5315 5.13259L14.5692 4.55638C15.3024 4.14929 16.2032 4.67947 16.2032 5.51809V10.4819C16.2032 11.3205 15.3024 11.8507 14.5692 11.4436L13.5315 10.8674C13.45 12.2299 12.3192 13.3097 10.9362 13.3097H4.26953C2.83361 13.3097 1.66956 12.1457 1.66953 10.7098L1.66943 5.29023ZM13.5362 9.49743L15.0032 10.312V5.68799L13.5362 6.50254V9.49743ZM4.26945 3.89019C3.49623 3.89018 2.86942 4.517 2.86943 5.29021L2.86953 10.7098C2.86955 11.483 3.49634 12.1097 4.26953 12.1097H10.9362C11.7094 12.1097 12.3362 11.4829 12.3362 10.7097V5.29026C12.3362 4.51707 11.7094 3.89027 10.9362 3.89026L4.26945 3.89019Z",fillRule:"evenodd",clipRule:"evenodd"}}]},{tag:"defs",attrs:{},children:[{tag:"clipPath",attrs:{id:"record-single_clip0_1559_19"},children:[{tag:"path",attrs:{fill:"#fff",d:"M0 0H16V16H0z",transform:"translate(.94)"}}]}]}],defIds:["record-single_clip0_1559_19"]},j=C.forwardRef(function(e,t){return C.createElement(L,Object.assign({},e,{id:"record-single",ref:t,icon:Y}))});j.displayName="RecordSingle";var Q=Object.getOwnPropertyDescriptor,X=(e,t,n,r)=>{for(var o=r>1?void 0:r?Q(t,n):t,i=e.length-1,d;i>=0;i--)(d=e[i])&&(o=d(o)||o);return o},M=(e,t)=>(n,r)=>t(n,r,e);c.ActionRecorderService=class extends a.Disposable{constructor(n,r,o,i){super();g(this,"_shouldRecordCommands",new Set);g(this,"_panelOpened$",new P.BehaviorSubject(!1));g(this,"panelOpened$",this._panelOpened$.asObservable());g(this,"_recorder",null);g(this,"_recording$",new P.BehaviorSubject(!1));g(this,"recording$",this._recording$.asObservable());g(this,"_recorded$",new P.BehaviorSubject([]));g(this,"_recordedCommands$",new P.BehaviorSubject([]));g(this,"recordedCommands$",this._recordedCommands$.asObservable());this._commandSrv=n,this._logService=r,this._localFileService=o,this._instanceService=i}get recording(){return this._recording$.getValue()}get _recorded(){return this._recorded$.getValue()}get _recordedCommands(){return this._recordedCommands$.getValue()}registerRecordedCommand(n){if(n.type===a.CommandType.MUTATION)throw new Error("[CommandRecorderService] Cannot record mutation commands.");this._shouldRecordCommands.add(n.id)}togglePanel(n){this._panelOpened$.next(n),n===!1&&this.stopRecording()}startRecording(n=!1){this._recorder=this._commandSrv.onCommandExecuted(r=>{var o,i;if(this._shouldRecordCommands.has(r.id)){const d=this._recorded,u=this._recordedCommands;let v={...r};const _=(o=this._instanceService.getFocusedUnit())==null?void 0:o.getUnitId(),{unitId:h=_,subUnitId:f}=v==null?void 0:v.params;if(n&&h&&f){const E=(i=this._instanceService.getUnit(h).getSheetBySheetId(f))==null?void 0:i.getName();v={...v,params:{...v.params,subUnitId:E}}}v.id===l.SetSelectionsOperation.id&&d.length>0&&d[d.length-1].id===l.SetSelectionsOperation.id?d[d.length-1]=v:(d.push(v),this._recorded$.next(d),v.type===a.CommandType.COMMAND&&(u.push(v),this._recordedCommands$.next(u)))}}),this._recording$.next(!0)}stopRecording(){var n;(n=this._recorder)==null||n.dispose(),this._recorder=null,this._recorded$.next([]),this._recordedCommands$.next([]),this._recording$.next(!1)}completeRecording(){const n=this._recorded.slice();this._localFileService.downloadFile(new Blob([JSON.stringify(n,null,2)]),"recorded-commands.json"),this._logService.error("Recorded commands:",n),this.stopRecording()}},c.ActionRecorderService=X([M(0,a.ICommandService),M(1,a.ILogService),M(2,s.ILocalFileService),M(3,a.IUniverInstanceService)],c.ActionRecorderService);const B={id:"action-recorder.command.start-recording",type:a.CommandType.COMMAND,handler:(e,t)=>(e.get(c.ActionRecorderService).startRecording(!!(t!=null&&t.replaceId)),!0)},k={id:"action-recorder.command.complete-recording",type:a.CommandType.COMMAND,handler:e=>(e.get(c.ActionRecorderService).completeRecording(),!0)},V={id:"action-recorder.command.stop-recording",type:a.CommandType.COMMAND,handler:e=>(e.get(c.ActionRecorderService).completeRecording(),!0)};var ee=Object.getOwnPropertyDescriptor,ne=(e,t,n,r)=>{for(var o=r>1?void 0:r?ee(t,n):t,i=e.length-1,d;i>=0;i--)(d=e[i])&&(o=d(o)||o);return o},I=(e,t)=>(n,r)=>t(n,r,e),N=(e=>(e.DEFAULT="default",e.NAME="name",e.ACTIVE="active",e))(N||{});c.ActionReplayService=class extends a.Disposable{constructor(t,n,r,o,i){super(),this._messageService=t,this._instanceService=n,this._localFileService=r,this._logService=o,this._commandService=i}async replayLocalJSON(t="default"){const n=await this._localFileService.openFile({multiple:!1,accept:".json"});if(n.length!==1)return!1;const r=n[0];try{return this.replayCommands(JSON.parse(await r.text()),{mode:t})}catch{return this._messageService.show({type:y.MessageType.Error,content:`Failed to replay commands from local file ${r.name}.`}),!1}}async replayCommands(t,n){var i,d,u;const r=(i=this._instanceService.getFocusedUnit())==null?void 0:i.getUnitId();r||this._logService.error("[ReplayService]","no focused unit to replay commands");const{mode:o}=n||{};for(const v of t){const{id:_,params:h}=v,f=h;if(f){if(typeof f.unitId<"u"&&(f.unitId=r),o==="name"&&f.subUnitId!=="undefined"){const A=(d=this._instanceService.getFocusedUnit().getSheetBySheetName(f.subUnitId))==null?void 0:d.getSheetId();A?f.subUnitId=A:this._logService.error("[ReplayService]",`failed to find subunit by subUnitName = ${f.subUnitId}`)}if(o==="active"&&f.subUnitId!=="undefined"){const A=(u=this._instanceService.getFocusedUnit().getActiveSheet())==null?void 0:u.getSheetId();A?f.subUnitId=A:this._logService.error("[ReplayService]","failed to find active subunit")}if(!await this._commandService.executeCommand(_,h))return!1}else if(!await this._commandService.executeCommand(_))return!1}return!0}async replayCommandsWithDelay(t){var r;const n=(r=this._instanceService.getFocusedUnit())==null?void 0:r.getUnitId();n||this._logService.error("[ReplayService]","no focused unit to replay commands");for(const o of t){await a.awaitTime(re());const{id:i,params:d}=o;if(d){if(typeof d.unitId<"u"&&(d.unitId=n),!await this._commandService.executeCommand(i,d))return!1}else if(!await this._commandService.executeCommand(i))return!1}return!0}},c.ActionReplayService=ne([I(0,s.IMessageService),I(1,a.IUniverInstanceService),I(2,s.ILocalFileService),I(3,a.ILogService),I(4,a.ICommandService)],c.ActionReplayService);function re(){return Math.floor(Math.random()*800)+200}const w={id:"action-recorder.command.replay-local-records",type:a.CommandType.COMMAND,handler:async e=>{const n=await e.get(c.ActionReplayService).replayLocalJSON();return n&&e.get(s.IMessageService).show({type:y.MessageType.Success,content:"Successfully replayed local records"}),n}},U={id:"action-recorder.command.replay-local-records-name",type:a.CommandType.COMMAND,handler:async e=>{const n=await e.get(c.ActionReplayService).replayLocalJSON(N.NAME);return n&&e.get(s.IMessageService).show({type:y.MessageType.Success,content:"Successfully replayed local records"}),n}},$={id:"action-recorder.command.replay-local-records-active",type:a.CommandType.COMMAND,handler:async e=>{const n=await e.get(c.ActionReplayService).replayLocalJSON(N.ACTIVE);return n&&e.get(s.IMessageService).show({type:y.MessageType.Success,content:"Successfully replayed local records"}),n}},D={id:"action-recorder.operation.open-panel",type:a.CommandType.OPERATION,handler(e){return e.get(c.ActionRecorderService).togglePanel(!0),!0}},W={id:"action-recorder.operation.close-panel",type:a.CommandType.OPERATION,handler(e){return e.get(c.ActionRecorderService).togglePanel(!1),!0}},O={actionRecorderPanel:"univer-action-recorder-panel",actionRecorderPanelIcon:"univer-action-recorder-panel-icon",actionRecorderPanelIconRecording:"univer-action-recorder-panel-icon-recording",actionRecorderPanelTitle:"univer-action-recorder-panel-title",actionRecorderPanelActions:"univer-action-recorder-panel-actions"};function te(){const e=s.useDependency(c.ActionRecorderService);return s.useObservable(e.panelOpened$)?p.jsx(oe,{}):null}function oe(){var h;const e=s.useDependency(a.ICommandService),t=s.useDependency(c.ActionRecorderService),n=s.useObservable(t.recording$),r=s.useObservable(t.recordedCommands$),o=(h=r==null?void 0:r.length)!=null?h:0,i=C.useCallback(()=>{n||e.executeCommand(W.id)},[e,n]),d=C.useCallback(f=>{n||e.executeCommand(B.id,{replaceId:f})},[e,n]),u=C.useCallback(()=>{n&&e.executeCommand(k.id)},[e,n]),v=C.useCallback(()=>{n&&e.executeCommand(V.id)},[e,n]),_=n?o===0?"Recording...":`${o}: ${r[o-1].id}`:"Start Recording";return p.jsxs("div",{className:O.actionRecorderPanel,children:[p.jsx("div",{className:y.clsx(O.actionRecorderPanelIcon,n?O.actionRecorderPanelIconRecording:!1),children:p.jsx(j,{})}),p.jsx("div",{className:O.actionRecorderPanelTitle,children:_}),p.jsxs("div",{className:O.actionRecorderPanelActions,children:[p.jsx(y.Button,{type:"default",size:"small",onClick:n?v:i,children:n?"Cancel":"Close"}),p.jsx(y.Button,{type:"primary",size:"small",onClick:n?u:()=>d(),children:n?"Save":"Start"}),!n&&p.jsx(y.Button,{type:"primary",size:"small",onClick:()=>d(!0),children:"Start(N)"})]})]})}const q="RECORD_MENU_ITEM";function ce(){return{id:q,type:s.MenuItemType.SUBITEMS,icon:"RecordSingle",tooltip:"action-recorder.menu.title"}}function ie(e){const t=e.get(c.ActionRecorderService);return{id:D.id,title:"action-recorder.menu.record",type:s.MenuItemType.BUTTON,disabled$:t.panelOpened$}}function ae(){return{id:w.id,title:"action-recorder.menu.replay-local",type:s.MenuItemType.BUTTON}}function de(){return{id:U.id,title:"action-recorder.menu.replay-local-name",type:s.MenuItemType.BUTTON}}function le(){return{id:$.id,title:"action-recorder.menu.replay-local-active",type:s.MenuItemType.BUTTON}}const se={[s.RibbonStartGroup.OTHERS]:{[q]:{order:10,menuItemFactory:ce,[D.id]:{order:1,menuItemFactory:ie},[w.id]:{order:2,menuItemFactory:ae},[U.id]:{order:3,menuItemFactory:de},[$.id]:{order:4,menuItemFactory:le}}}};var me=Object.getOwnPropertyDescriptor,ue=(e,t,n,r)=>{for(var o=r>1?void 0:r?me(t,n):t,i=e.length-1,d;i>=0;i--)(d=e[i])&&(o=d(o)||o);return o},R=(e,t)=>(n,r)=>t(n,r,e);let T=class extends a.Disposable{constructor(e,t,n,r,o,i){super(),this._commandSrv=e,this._uiPartsSrv=t,this._menuManagerService=n,this._componentManager=r,this._actionRecorderService=o,this._injector=i,this._initCommands(),this._initUI(),this._initSheetsCommands(),this._initDocsCommands()}_initCommands(){[B,V,k,D,W,w,U,$].forEach(e=>this._commandSrv.registerCommand(e))}_initUI(){this._uiPartsSrv.registerComponent(s.BuiltInUIPart.GLOBAL,()=>s.connectInjector(te,this._injector)),this._componentManager.register("RecordSingle",j),this._menuManagerService.mergeMenu(se)}_initSheetsCommands(){[l.CopySheetCommand,l.DeleteRangeMoveLeftCommand,l.DeleteRangeMoveUpCommand,l.DeltaColumnWidthCommand,l.DeltaRowHeightCommand,l.InsertSheetCommand,l.InsertColAfterCommand,l.InsertColBeforeCommand,l.InsertRowAfterCommand,l.InsertRowBeforeCommand,l.RemoveSheetCommand,l.SetStyleCommand,l.AddWorksheetMergeCommand,l.AddWorksheetMergeAllCommand,l.AddWorksheetMergeVerticalCommand,l.AddWorksheetMergeHorizontalCommand,l.SetFrozenCommand,l.CancelFrozenCommand,l.SetHorizontalTextAlignCommand,l.SetOverlineCommand,m.SetRangeBoldCommand,m.SetRangeFontFamilyCommand,m.SetRangeFontSizeCommand,m.SetRangeItalicCommand,m.SetRangeStrickThroughCommand,m.SetRangeSubscriptCommand,m.SetRangeSuperscriptCommand,m.SetRangeTextColorCommand,m.SetRangeUnderlineCommand,l.SetRangeValuesCommand,l.SetStrikeThroughCommand,l.SetTextColorCommand,l.SetTextRotationCommand,l.SetTextWrapCommand,l.SetVerticalTextAlignCommand,m.SheetCopyCommand,m.SheetCutCommand,m.SheetPasteBesidesBorderCommand,m.SheetPasteColWidthCommand,m.SheetPasteCommand,m.SheetPasteFormatCommand,m.SheetPasteShortKeyCommand,m.SheetPasteValueCommand,m.AutoFillCommand,m.RefillCommand,l.SetWorksheetActivateCommand,l.SetWorksheetActiveOperation,l.SetSelectionsOperation,b.SetSheetFilterRangeCommand,b.SetSheetsFilterCriteriaCommand,b.RemoveSheetFilterCommand].forEach(e=>this._actionRecorderService.registerRecordedCommand(e))}_initDocsCommands(){}};T=ue([R(0,a.ICommandService),R(1,s.IUIPartsService),R(2,s.IMenuManagerService),R(3,a.Inject(s.ComponentManager)),R(4,a.Inject(c.ActionRecorderService)),R(5,a.Inject(a.Injector))],T);const ve="action-recorder.config",z={};var fe=Object.getOwnPropertyDescriptor,Se=(e,t,n,r)=>{for(var o=r>1?void 0:r?fe(t,n):t,i=e.length-1,d;i>=0;i--)(d=e[i])&&(o=d(o)||o);return o},H=(e,t)=>(n,r)=>t(n,r,e);c.UniverActionRecorderPlugin=(F=class extends a.Plugin{constructor(t=z,n,r){super(),this._config=t,this._injector=n,this._configService=r;const{menu:o,...i}=a.merge({},z,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(ve,i)}onStarting(){(this._config.replayOnly?[[c.ActionReplayService]]:[[c.ActionRecorderService],[c.ActionReplayService],[T]]).forEach(n=>this._injector.add(n))}onSteady(){this._config.replayOnly||this._injector.get(T)}},g(F,"pluginName","UNIVER_ACTION_RECORDER_PLUGIN"),F),c.UniverActionRecorderPlugin=Se([H(1,a.Inject(a.Injector)),H(2,a.IConfigService)],c.UniverActionRecorderPlugin),Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/action-recorder",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2-nightly.202503031606",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -53,23 +53,22 @@
|
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@univerjs/icons": "^0.2.20",
|
|
56
|
-
"
|
|
57
|
-
"@univerjs/
|
|
58
|
-
"@univerjs/
|
|
59
|
-
"@univerjs/sheets": "0.6.
|
|
60
|
-
"@univerjs/
|
|
61
|
-
"@univerjs/
|
|
62
|
-
"@univerjs/sheets-ui": "0.6.1"
|
|
56
|
+
"@univerjs/core": "0.6.2-nightly.202503031606",
|
|
57
|
+
"@univerjs/design": "0.6.2-nightly.202503031606",
|
|
58
|
+
"@univerjs/sheets": "0.6.2-nightly.202503031606",
|
|
59
|
+
"@univerjs/sheets-ui": "0.6.2-nightly.202503031606",
|
|
60
|
+
"@univerjs/ui": "0.6.2-nightly.202503031606",
|
|
61
|
+
"@univerjs/sheets-filter": "0.6.2-nightly.202503031606"
|
|
63
62
|
},
|
|
64
63
|
"devDependencies": {
|
|
65
64
|
"less": "^4.2.2",
|
|
66
65
|
"react": "18.3.1",
|
|
67
66
|
"rxjs": "^7.8.1",
|
|
68
67
|
"tailwindcss": "^3.4.17",
|
|
69
|
-
"typescript": "^5.
|
|
70
|
-
"vite": "^6.
|
|
71
|
-
"vitest": "^3.0.
|
|
72
|
-
"@univerjs-infra/shared": "0.6.
|
|
68
|
+
"typescript": "^5.8.2",
|
|
69
|
+
"vite": "^6.2.0",
|
|
70
|
+
"vitest": "^3.0.7",
|
|
71
|
+
"@univerjs-infra/shared": "0.6.2"
|
|
73
72
|
},
|
|
74
73
|
"scripts": {
|
|
75
74
|
"test": "vitest run",
|
package/LICENSE
DELETED
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
Apache License
|
|
2
|
-
Version 2.0, January 2004
|
|
3
|
-
http://www.apache.org/licenses/
|
|
4
|
-
|
|
5
|
-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
-
|
|
7
|
-
1. Definitions.
|
|
8
|
-
|
|
9
|
-
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
-
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
-
|
|
12
|
-
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
-
the copyright owner that is granting the License.
|
|
14
|
-
|
|
15
|
-
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
-
other entities that control, are controlled by, or are under common
|
|
17
|
-
control with that entity. For the purposes of this definition,
|
|
18
|
-
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
-
direction or management of such entity, whether by contract or
|
|
20
|
-
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
-
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
-
|
|
23
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
-
exercising permissions granted by this License.
|
|
25
|
-
|
|
26
|
-
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
-
including but not limited to software source code, documentation
|
|
28
|
-
source, and configuration files.
|
|
29
|
-
|
|
30
|
-
"Object" form shall mean any form resulting from mechanical
|
|
31
|
-
transformation or translation of a Source form, including but
|
|
32
|
-
not limited to compiled object code, generated documentation,
|
|
33
|
-
and conversions to other media types.
|
|
34
|
-
|
|
35
|
-
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
-
Object form, made available under the License, as indicated by a
|
|
37
|
-
copyright notice that is included in or attached to the work
|
|
38
|
-
(an example is provided in the Appendix below).
|
|
39
|
-
|
|
40
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
-
form, that is based on (or derived from) the Work and for which the
|
|
42
|
-
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
-
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
-
of this License, Derivative Works shall not include works that remain
|
|
45
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
-
the Work and Derivative Works thereof.
|
|
47
|
-
|
|
48
|
-
"Contribution" shall mean any work of authorship, including
|
|
49
|
-
the original version of the Work and any modifications or additions
|
|
50
|
-
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
-
means any form of electronic, verbal, or written communication sent
|
|
55
|
-
to the Licensor or its representatives, including but not limited to
|
|
56
|
-
communication on electronic mailing lists, source code control systems,
|
|
57
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
-
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
-
excluding communication that is conspicuously marked or otherwise
|
|
60
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
-
|
|
62
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
-
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
-
subsequently incorporated within the Work.
|
|
65
|
-
|
|
66
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
-
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
-
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
-
Work and such Derivative Works in Source or Object form.
|
|
72
|
-
|
|
73
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
-
(except as stated in this section) patent license to make, have made,
|
|
77
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
-
where such license applies only to those patent claims licensable
|
|
79
|
-
by such Contributor that are necessarily infringed by their
|
|
80
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
-
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
-
institute patent litigation against any entity (including a
|
|
83
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
-
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
-
or contributory patent infringement, then any patent licenses
|
|
86
|
-
granted to You under this License for that Work shall terminate
|
|
87
|
-
as of the date such litigation is filed.
|
|
88
|
-
|
|
89
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
-
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
-
modifications, and in Source or Object form, provided that You
|
|
92
|
-
meet the following conditions:
|
|
93
|
-
|
|
94
|
-
(a) You must give any other recipients of the Work or
|
|
95
|
-
Derivative Works a copy of this License; and
|
|
96
|
-
|
|
97
|
-
(b) You must cause any modified files to carry prominent notices
|
|
98
|
-
stating that You changed the files; and
|
|
99
|
-
|
|
100
|
-
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
-
that You distribute, all copyright, patent, trademark, and
|
|
102
|
-
attribution notices from the Source form of the Work,
|
|
103
|
-
excluding those notices that do not pertain to any part of
|
|
104
|
-
the Derivative Works; and
|
|
105
|
-
|
|
106
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
-
distribution, then any Derivative Works that You distribute must
|
|
108
|
-
include a readable copy of the attribution notices contained
|
|
109
|
-
within such NOTICE file, excluding those notices that do not
|
|
110
|
-
pertain to any part of the Derivative Works, in at least one
|
|
111
|
-
of the following places: within a NOTICE text file distributed
|
|
112
|
-
as part of the Derivative Works; within the Source form or
|
|
113
|
-
documentation, if provided along with the Derivative Works; or,
|
|
114
|
-
within a display generated by the Derivative Works, if and
|
|
115
|
-
wherever such third-party notices normally appear. The contents
|
|
116
|
-
of the NOTICE file are for informational purposes only and
|
|
117
|
-
do not modify the License. You may add Your own attribution
|
|
118
|
-
notices within Derivative Works that You distribute, alongside
|
|
119
|
-
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
-
that such additional attribution notices cannot be construed
|
|
121
|
-
as modifying the License.
|
|
122
|
-
|
|
123
|
-
You may add Your own copyright statement to Your modifications and
|
|
124
|
-
may provide additional or different license terms and conditions
|
|
125
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
-
the conditions stated in this License.
|
|
129
|
-
|
|
130
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
-
this License, without any additional terms or conditions.
|
|
134
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
-
the terms of any separate license agreement you may have executed
|
|
136
|
-
with Licensor regarding such Contributions.
|
|
137
|
-
|
|
138
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
-
except as required for reasonable and customary use in describing the
|
|
141
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
-
|
|
143
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
-
implied, including, without limitation, any warranties or conditions
|
|
148
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
-
appropriateness of using or redistributing the Work and assume any
|
|
151
|
-
risks associated with Your exercise of permissions under this License.
|
|
152
|
-
|
|
153
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
-
unless required by applicable law (such as deliberate and grossly
|
|
156
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
-
liable to You for damages, including any direct, indirect, special,
|
|
158
|
-
incidental, or consequential damages of any character arising as a
|
|
159
|
-
result of this License or out of the use or inability to use the
|
|
160
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
-
other commercial damages or losses), even if such Contributor
|
|
163
|
-
has been advised of the possibility of such damages.
|
|
164
|
-
|
|
165
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
-
or other liability obligations and/or rights consistent with this
|
|
169
|
-
License. However, in accepting such obligations, You may act only
|
|
170
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
-
defend, and hold each Contributor harmless for any liability
|
|
173
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
-
of your accepting any such warranty or additional liability.
|
|
175
|
-
|
|
176
|
-
END OF TERMS AND CONDITIONS
|