@univerjs/uniscript 1.0.0-alpha.0 → 1.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +1 -1
- package/lib/es/index.js +1 -1
- package/lib/index.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +8 -8
package/lib/cjs/index.js
CHANGED
package/lib/es/index.js
CHANGED
package/lib/index.js
CHANGED
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/design"),require("monaco-editor"),require("react"),require("@univerjs/core/facade"),require("react/jsx-runtime"),require("@univerjs/sheets"),require("@univerjs/sheets-ui")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/ui`,`rxjs`,`@univerjs/design`,`monaco-editor`,`react`,`@univerjs/core/facade`,`react/jsx-runtime`,`@univerjs/sheets`,`@univerjs/sheets-ui`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverUniscript={},e.UniverCore,e.UniverUi,e.rxjs,e.UniverDesign,e.monaco,e.React,e.UniverCoreFacade,e.React,e.UniverSheets,e.UniverSheetsUi))})(this,function(e,t,n,r,i,a,o,s,c,l,u){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function d(e){"@babel/helpers - typeof";return d=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},d(e)}function f(e,t){if(d(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(d(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function p(e){var t=f(e,`string`);return d(t)==`symbol`?t:t+``}function m(e,t,n){return(t=p(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var h=class extends t.Disposable{constructor(...e){super(...e),m(this,`_open$`,new r.BehaviorSubject(!1)),m(this,`open$`,this._open$.pipe((0,r.distinctUntilChanged)()))}get isOpen(){return this._open$.getValue()}dispose(){super.dispose(),this._open$.next(!1),this._open$.complete()}open(){this._open$.next(!0)}close(){this._open$.next(!1)}};let g=`ScriptPanel`,_={type:t.CommandType.OPERATION,id:`univer.operation.toggle-script-panel`,handler:e=>{let t=e.get(h),r=e.get(n.ISidebarService);return t.isOpen?(t.close(),r.close()):(t.open(),r.open({header:{title:`uniscript.title`},children:{label:g},width:600})),!0}};var v=`@univerjs/uniscript`,y=`1.0.0-alpha.
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/design"),require("monaco-editor"),require("react"),require("@univerjs/core/facade"),require("react/jsx-runtime"),require("@univerjs/sheets"),require("@univerjs/sheets-ui")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/ui`,`rxjs`,`@univerjs/design`,`monaco-editor`,`react`,`@univerjs/core/facade`,`react/jsx-runtime`,`@univerjs/sheets`,`@univerjs/sheets-ui`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverUniscript={},e.UniverCore,e.UniverUi,e.rxjs,e.UniverDesign,e.monaco,e.React,e.UniverCoreFacade,e.React,e.UniverSheets,e.UniverSheetsUi))})(this,function(e,t,n,r,i,a,o,s,c,l,u){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function d(e){"@babel/helpers - typeof";return d=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},d(e)}function f(e,t){if(d(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(d(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function p(e){var t=f(e,`string`);return d(t)==`symbol`?t:t+``}function m(e,t,n){return(t=p(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var h=class extends t.Disposable{constructor(...e){super(...e),m(this,`_open$`,new r.BehaviorSubject(!1)),m(this,`open$`,this._open$.pipe((0,r.distinctUntilChanged)()))}get isOpen(){return this._open$.getValue()}dispose(){super.dispose(),this._open$.next(!1),this._open$.complete()}open(){this._open$.next(!0)}close(){this._open$.next(!1)}};let g=`ScriptPanel`,_={type:t.CommandType.OPERATION,id:`univer.operation.toggle-script-panel`,handler:e=>{let t=e.get(h),r=e.get(n.ISidebarService);return t.isOpen?(t.close(),r.close()):(t.open(),r.open({header:{title:`uniscript.title`},children:{label:g},width:600})),!0}};var v=`@univerjs/uniscript`,y=`1.0.0-alpha.2`;let b=`uniscript.config`,x={};function S(e,t){return function(n,r){t(n,r,e)}}function C(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let w=class extends t.Disposable{constructor(e){super(),this._configService=e,m(this,`_editorInstance`,null)}dispose(){super.dispose(),this._editorInstance&&this._editorInstance.dispose()}setEditorInstance(e){return this._editorInstance=e,(0,t.toDisposable)(()=>this._editorInstance=null)}getEditorInstance(){return this._editorInstance}requireVscodeEditor(){if(!window.MonacoEnvironment){let e=this._configService.getConfig(b);window.MonacoEnvironment={getWorkerUrl:e==null?void 0:e.getWorkerUrl}}}};w=C([S(0,t.IConfigService)],w);let T=(0,t.createIdentifier)(`univer.uniscript.execution-service`),E=class extends t.Disposable{constructor(e,t){super(),this._logService=e,this._injector=t}async execute(e){this._logService.log(`[UniscriptExecutionService]`,`executing Uniscript...`);let t=s.FUniver.newAPI(this._injector),n=Function(`univerAPI`,`(() => {${e}})()`);try{return n(t),!0}catch(e){return this._logService.error(e),!1}}};E=C([S(0,t.ILogService),S(1,(0,t.Inject)(t.Injector))],E);function D(){let e=(0,o.useRef)(null),r=(0,o.useRef)(null),s=(0,o.useRef)(null),l=(0,n.useDependency)(t.LocaleService),u=(0,n.useDependency)(n.IShortcutService),d=(0,n.useDependency)(w),f=(0,n.useDependency)(t.ThemeService);(0,o.useEffect)(()=>{let n=r.current,i=e.current,o=null,c=null;if(n&&i){d.requireVscodeEditor();let e=s.current=a.editor.create(n,{value:``,language:`javascript`,theme:f.darkMode?`vs-dark`:`vs-light`});c=new ResizeObserver(()=>{let t=requestIdleCallback(()=>{if(!t)return;let{height:n,width:r}=i.getBoundingClientRect();e.layout({width:r,height:n}),t=void 0})}),c.observe(i);let r;o=new t.DisposableCollection,o.add(d.setEditorInstance(e)),o.add(e.onDidFocusEditorWidget(()=>{r=u.forceEscape()})),o.add(e.onDidBlurEditorWidget(()=>{r==null||r.dispose(),r=void 0})),o.add((0,t.toDisposable)(()=>r==null?void 0:r.dispose()))}return()=>{c&&i&&c.unobserve(i),o==null||o.dispose()}},[d,u]);let p=O((0,o.useCallback)(()=>s.current,[]));return(0,c.jsxs)(`div`,{className:`univer-h-full`,children:[(0,c.jsx)(`div`,{ref:e,className:`univer-h-[calc(100%-60px)] univer-w-full univer-overflow-hidden`,children:(0,c.jsx)(`div`,{ref:r})}),(0,c.jsx)(`div`,{className:`univer-mt-2.5`,children:(0,c.jsx)(i.Button,{variant:`primary`,onClick:p,children:l.t(`uniscript.panel.execute`)})})]})}function O(e){let r=(0,n.useDependency)(T),a=(0,n.useDependency)(n.IMessageService),s=(0,n.useDependency)(t.LocaleService);return(0,o.useCallback)(()=>{var t;let n=(t=e())==null?void 0:t.getModel();n&&r.execute(n.getValue()).then(()=>{a.show({content:s.t(`uniscript.message.success`),type:i.MessageType.Success})}).catch(()=>{a.show({content:s.t(`uniscript.message.failed`),type:i.MessageType.Error})})},[e,s,a,r])}let k=class extends t.Disposable{constructor(e){super(),this._componentManager=e,this._registerComponents()}_registerComponents(){this.disposeWithMe(this._componentManager.register(g,D))}};k=C([S(0,(0,t.Inject)(n.ComponentManager))],k);function A(e){return{id:_.id,title:`uniscript.title`,tooltip:`uniscript.tooltip.menu-button`,icon:`CodeIcon`,type:n.MenuItemType.BUTTON,hidden$:(0,n.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_SHEET),disabled$:(0,u.getCurrentRangeDisable$)(e,{workbookTypes:[l.WorkbookEditablePermission],worksheetTypes:[l.WorksheetEditPermission,l.WorksheetSetCellStylePermission,l.WorksheetSetCellValuePermission],rangeTypes:[l.RangeProtectionPermissionEditPoint]})}}let j={[n.RibbonOthersGroup.OTHERS]:{[_.id]:{order:0,menuItemFactory:A}}},M=class extends t.Disposable{constructor(e,t){super(),this._menuManagerService=e,this._menuManagerService.mergeMenu(j),this.disposeWithMe(t.registerCommand(_))}};M=C([S(0,n.IMenuManagerService),S(1,t.ICommandService)],M);let N=class extends t.Plugin{constructor(e=x,n,r){super(),this._config=e,this._injector=n,this._configService=r;let{menu:i,...a}=(0,t.merge)({},x,this._config);i&&this._configService.setConfig(`menu`,i,{merge:!0}),this._configService.setConfig(b,a)}onStarting(){let e=this._injector;[[k],[M],[w],[h]].forEach(t=>e.add(t)),this.registerExecution(),this._injector.get(k)}onSteady(){this._injector.get(M)}registerExecution(){this._injector.add([T,{useClass:E}])}};m(N,`pluginName`,`UNIVER_UNISCRIPT_PLUGIN`),m(N,`packageName`,v),m(N,`version`,y),N=C([S(1,(0,t.Inject)(t.Injector)),S(2,t.IConfigService)],N),e.IUniscriptExecutionService=T,Object.defineProperty(e,"ScriptEditorService",{enumerable:!0,get:function(){return w}}),e.ToggleScriptPanelOperation=_,Object.defineProperty(e,"UniverUniscriptPlugin",{enumerable:!0,get:function(){return N}})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/uniscript",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Monaco-based scripting editor for operating Univer through Facade APIs.",
|
|
6
6
|
"author": "DreamNum Co., Ltd. <developer@univer.ai>",
|
|
@@ -59,20 +59,20 @@
|
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
61
|
"monaco-editor": "0.55.1",
|
|
62
|
-
"@univerjs/core": "1.0.0-alpha.
|
|
63
|
-
"@univerjs/design": "1.0.0-alpha.
|
|
64
|
-
"@univerjs/sheets": "1.0.0-alpha.
|
|
65
|
-
"@univerjs/
|
|
66
|
-
"@univerjs/ui": "1.0.0-alpha.
|
|
62
|
+
"@univerjs/core": "1.0.0-alpha.2",
|
|
63
|
+
"@univerjs/design": "1.0.0-alpha.2",
|
|
64
|
+
"@univerjs/sheets": "1.0.0-alpha.2",
|
|
65
|
+
"@univerjs/ui": "1.0.0-alpha.2",
|
|
66
|
+
"@univerjs/sheets-ui": "1.0.0-alpha.2"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
|
-
"postcss": "^8.5.
|
|
69
|
+
"postcss": "^8.5.16",
|
|
70
70
|
"react": "18.3.1",
|
|
71
71
|
"rxjs": "^7.8.2",
|
|
72
72
|
"tailwindcss": "3.4.18",
|
|
73
73
|
"typescript": "^6.0.3",
|
|
74
74
|
"vitest": "^4.1.9",
|
|
75
|
-
"@univerjs-infra/shared": "1.0.0-alpha.
|
|
75
|
+
"@univerjs-infra/shared": "1.0.0-alpha.2"
|
|
76
76
|
},
|
|
77
77
|
"scripts": {
|
|
78
78
|
"test": "vitest run",
|