@univerjs/uniscript 0.25.0-insiders.20260623-012b5a8 → 0.25.1

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/LICENSE ADDED
@@ -0,0 +1,176 @@
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
package/lib/cjs/index.js CHANGED
@@ -2,15 +2,15 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  let _univerjs_core = require("@univerjs/core");
3
3
  let _univerjs_ui = require("@univerjs/ui");
4
4
  let rxjs = require("rxjs");
5
+ let _univerjs_sheets = require("@univerjs/sheets");
6
+ let _univerjs_sheets_ui = require("@univerjs/sheets-ui");
5
7
  let _univerjs_design = require("@univerjs/design");
6
8
  let monaco_editor = require("monaco-editor");
7
9
  let react = require("react");
8
10
  let _univerjs_core_facade = require("@univerjs/core/facade");
9
11
  let react_jsx_runtime = require("react/jsx-runtime");
10
- let _univerjs_sheets = require("@univerjs/sheets");
11
- let _univerjs_sheets_ui = require("@univerjs/sheets-ui");
12
12
 
13
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
13
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/typeof.js
14
14
  function _typeof(o) {
15
15
  "@babel/helpers - typeof";
16
16
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -21,7 +21,7 @@ function _typeof(o) {
21
21
  }
22
22
 
23
23
  //#endregion
24
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
24
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPrimitive.js
25
25
  function toPrimitive(t, r) {
26
26
  if ("object" != _typeof(t) || !t) return t;
27
27
  var e = t[Symbol.toPrimitive];
@@ -34,14 +34,14 @@ function toPrimitive(t, r) {
34
34
  }
35
35
 
36
36
  //#endregion
37
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
37
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPropertyKey.js
38
38
  function toPropertyKey(t) {
39
39
  var i = toPrimitive(t, "string");
40
40
  return "symbol" == _typeof(i) ? i : i + "";
41
41
  }
42
42
 
43
43
  //#endregion
44
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
44
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/defineProperty.js
45
45
  function _defineProperty(e, r, t) {
46
46
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
47
47
  value: t,
@@ -117,7 +117,7 @@ const ToggleScriptPanelOperation = {
117
117
  //#endregion
118
118
  //#region package.json
119
119
  var name = "@univerjs/uniscript";
120
- var version = "0.25.0-insiders.20260623-012b5a8";
120
+ var version = "0.25.1";
121
121
 
122
122
  //#endregion
123
123
  //#region src/config/config.ts
@@ -126,7 +126,36 @@ const configSymbol = Symbol(UNISCRIPT_PLUGIN_CONFIG_KEY);
126
126
  const defaultPluginConfig = {};
127
127
 
128
128
  //#endregion
129
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
129
+ //#region src/menu/menu.ts
130
+ function UniscriptMenuItemFactory(accessor) {
131
+ return {
132
+ id: ToggleScriptPanelOperation.id,
133
+ title: "toggle-script-panel",
134
+ tooltip: "uniscript.tooltip.menu-button",
135
+ icon: "CodeIcon",
136
+ type: _univerjs_ui.MenuItemType.BUTTON,
137
+ hidden$: (0, _univerjs_ui.getMenuHiddenObservable)(accessor, _univerjs_core.UniverInstanceType.UNIVER_SHEET),
138
+ disabled$: (0, _univerjs_sheets_ui.getCurrentRangeDisable$)(accessor, {
139
+ workbookTypes: [_univerjs_sheets.WorkbookEditablePermission],
140
+ worksheetTypes: [
141
+ _univerjs_sheets.WorksheetEditPermission,
142
+ _univerjs_sheets.WorksheetSetCellStylePermission,
143
+ _univerjs_sheets.WorksheetSetCellValuePermission
144
+ ],
145
+ rangeTypes: [_univerjs_sheets.RangeProtectionPermissionEditPoint]
146
+ })
147
+ };
148
+ }
149
+
150
+ //#endregion
151
+ //#region src/menu/schema.ts
152
+ const menuSchema = { [_univerjs_ui.RibbonOthersGroup.OTHERS]: { [ToggleScriptPanelOperation.id]: {
153
+ order: 0,
154
+ menuItemFactory: UniscriptMenuItemFactory
155
+ } } };
156
+
157
+ //#endregion
158
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorateParam.js
130
159
  function __decorateParam(paramIndex, decorator) {
131
160
  return function(target, key) {
132
161
  decorator(target, key, paramIndex);
@@ -134,7 +163,7 @@ function __decorateParam(paramIndex, decorator) {
134
163
  }
135
164
 
136
165
  //#endregion
137
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
166
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorate.js
138
167
  function __decorate(decorators, target, key, desc) {
139
168
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
140
169
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -260,7 +289,7 @@ function ScriptEditorPanel() {
260
289
  disposableCollection === null || disposableCollection === void 0 || disposableCollection.dispose();
261
290
  };
262
291
  }, [editorService, shortcutService]);
263
- const startExecution = useExecution((0, react.useCallback)(() => monacoEditorRef.current, []));
292
+ const startExecution = useExecution(monacoEditorRef);
264
293
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
265
294
  className: "univer-h-full",
266
295
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
@@ -277,13 +306,13 @@ function ScriptEditorPanel() {
277
306
  })]
278
307
  });
279
308
  }
280
- function useExecution(getMonacoEditor) {
309
+ function useExecution(monacoEditorRef) {
281
310
  const scriptService = (0, _univerjs_ui.useDependency)(IUniscriptExecutionService);
282
311
  const messageService = (0, _univerjs_ui.useDependency)(_univerjs_ui.IMessageService);
283
312
  const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
284
313
  return (0, react.useCallback)(() => {
285
- var _getMonacoEditor;
286
- const model = (_getMonacoEditor = getMonacoEditor()) === null || _getMonacoEditor === void 0 ? void 0 : _getMonacoEditor.getModel();
314
+ var _monacoEditorRef$curr;
315
+ const model = (_monacoEditorRef$curr = monacoEditorRef.current) === null || _monacoEditorRef$curr === void 0 ? void 0 : _monacoEditorRef$curr.getModel();
287
316
  if (model) scriptService.execute(model.getValue()).then(() => {
288
317
  messageService.show({
289
318
  content: localeService.t("uniscript.message.success"),
@@ -296,71 +325,13 @@ function useExecution(getMonacoEditor) {
296
325
  });
297
326
  });
298
327
  }, [
299
- getMonacoEditor,
300
328
  localeService,
301
329
  messageService,
330
+ monacoEditorRef,
302
331
  scriptService
303
332
  ]);
304
333
  }
305
334
 
306
- //#endregion
307
- //#region src/controllers/components.controller.ts
308
- /**
309
- * Copyright 2023-present DreamNum Co., Ltd.
310
- *
311
- * Licensed under the Apache License, Version 2.0 (the "License");
312
- * you may not use this file except in compliance with the License.
313
- * You may obtain a copy of the License at
314
- *
315
- * http://www.apache.org/licenses/LICENSE-2.0
316
- *
317
- * Unless required by applicable law or agreed to in writing, software
318
- * distributed under the License is distributed on an "AS IS" BASIS,
319
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
320
- * See the License for the specific language governing permissions and
321
- * limitations under the License.
322
- */
323
- let ComponentsController = class ComponentsController extends _univerjs_core.Disposable {
324
- constructor(_componentManager) {
325
- super();
326
- this._componentManager = _componentManager;
327
- this._registerComponents();
328
- }
329
- _registerComponents() {
330
- this.disposeWithMe(this._componentManager.register(ScriptPanelComponentName, ScriptEditorPanel));
331
- }
332
- };
333
- ComponentsController = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_ui.ComponentManager))], ComponentsController);
334
-
335
- //#endregion
336
- //#region src/menu/menu.ts
337
- function UniscriptMenuItemFactory(accessor) {
338
- return {
339
- id: ToggleScriptPanelOperation.id,
340
- title: "uniscript.title",
341
- tooltip: "uniscript.tooltip.menu-button",
342
- icon: "CodeIcon",
343
- type: _univerjs_ui.MenuItemType.BUTTON,
344
- hidden$: (0, _univerjs_ui.getMenuHiddenObservable)(accessor, _univerjs_core.UniverInstanceType.UNIVER_SHEET),
345
- disabled$: (0, _univerjs_sheets_ui.getCurrentRangeDisable$)(accessor, {
346
- workbookTypes: [_univerjs_sheets.WorkbookEditablePermission],
347
- worksheetTypes: [
348
- _univerjs_sheets.WorksheetEditPermission,
349
- _univerjs_sheets.WorksheetSetCellStylePermission,
350
- _univerjs_sheets.WorksheetSetCellValuePermission
351
- ],
352
- rangeTypes: [_univerjs_sheets.RangeProtectionPermissionEditPoint]
353
- })
354
- };
355
- }
356
-
357
- //#endregion
358
- //#region src/menu/schema.ts
359
- const menuSchema = { [_univerjs_ui.RibbonOthersGroup.OTHERS]: { [ToggleScriptPanelOperation.id]: {
360
- order: 0,
361
- menuItemFactory: UniscriptMenuItemFactory
362
- } } };
363
-
364
335
  //#endregion
365
336
  //#region src/controllers/uniscript.controller.ts
366
337
  /**
@@ -379,14 +350,19 @@ const menuSchema = { [_univerjs_ui.RibbonOthersGroup.OTHERS]: { [ToggleScriptPan
379
350
  * limitations under the License.
380
351
  */
381
352
  let UniscriptController = class UniscriptController extends _univerjs_core.Disposable {
382
- constructor(_menuManagerService, commandService) {
353
+ constructor(_menuManagerService, commandService, componentManager) {
383
354
  super();
384
355
  this._menuManagerService = _menuManagerService;
385
356
  this._menuManagerService.mergeMenu(menuSchema);
357
+ this.disposeWithMe(componentManager.register(ScriptPanelComponentName, ScriptEditorPanel));
386
358
  this.disposeWithMe(commandService.registerCommand(ToggleScriptPanelOperation));
387
359
  }
388
360
  };
389
- UniscriptController = __decorate([__decorateParam(0, _univerjs_ui.IMenuManagerService), __decorateParam(1, _univerjs_core.ICommandService)], UniscriptController);
361
+ UniscriptController = __decorate([
362
+ __decorateParam(0, _univerjs_ui.IMenuManagerService),
363
+ __decorateParam(1, _univerjs_core.ICommandService),
364
+ __decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_ui.ComponentManager))
365
+ ], UniscriptController);
390
366
 
391
367
  //#endregion
392
368
  //#region src/plugin.ts
@@ -403,13 +379,11 @@ let UniverUniscriptPlugin = class UniverUniscriptPlugin extends _univerjs_core.P
403
379
  onStarting() {
404
380
  const injector = this._injector;
405
381
  [
406
- [ComponentsController],
407
382
  [UniscriptController],
408
383
  [ScriptEditorService],
409
384
  [ScriptPanelService]
410
385
  ].forEach((d) => injector.add(d));
411
386
  this.registerExecution();
412
- this._injector.get(ComponentsController);
413
387
  }
414
388
  onSteady() {
415
389
  this._injector.get(UniscriptController);
package/lib/es/index.js CHANGED
@@ -1,15 +1,15 @@
1
1
  import { CommandType, Disposable, DisposableCollection, ICommandService, IConfigService, ILogService, Inject, Injector, LocaleService, Plugin, ThemeService, UniverInstanceType, createIdentifier, merge, toDisposable } from "@univerjs/core";
2
2
  import { ComponentManager, IMenuManagerService, IMessageService, IShortcutService, ISidebarService, MenuItemType, RibbonOthersGroup, getMenuHiddenObservable, useDependency } from "@univerjs/ui";
3
3
  import { BehaviorSubject, distinctUntilChanged } from "rxjs";
4
+ import { RangeProtectionPermissionEditPoint, WorkbookEditablePermission, WorksheetEditPermission, WorksheetSetCellStylePermission, WorksheetSetCellValuePermission } from "@univerjs/sheets";
5
+ import { getCurrentRangeDisable$ } from "@univerjs/sheets-ui";
4
6
  import { Button, MessageType } from "@univerjs/design";
5
7
  import { editor } from "monaco-editor";
6
8
  import { useCallback, useEffect, useRef } from "react";
7
9
  import { FUniver } from "@univerjs/core/facade";
8
10
  import { jsx, jsxs } from "react/jsx-runtime";
9
- import { RangeProtectionPermissionEditPoint, WorkbookEditablePermission, WorksheetEditPermission, WorksheetSetCellStylePermission, WorksheetSetCellValuePermission } from "@univerjs/sheets";
10
- import { getCurrentRangeDisable$ } from "@univerjs/sheets-ui";
11
11
 
12
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
12
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/typeof.js
13
13
  function _typeof(o) {
14
14
  "@babel/helpers - typeof";
15
15
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -20,7 +20,7 @@ function _typeof(o) {
20
20
  }
21
21
 
22
22
  //#endregion
23
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
23
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPrimitive.js
24
24
  function toPrimitive(t, r) {
25
25
  if ("object" != _typeof(t) || !t) return t;
26
26
  var e = t[Symbol.toPrimitive];
@@ -33,14 +33,14 @@ function toPrimitive(t, r) {
33
33
  }
34
34
 
35
35
  //#endregion
36
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
36
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPropertyKey.js
37
37
  function toPropertyKey(t) {
38
38
  var i = toPrimitive(t, "string");
39
39
  return "symbol" == _typeof(i) ? i : i + "";
40
40
  }
41
41
 
42
42
  //#endregion
43
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
43
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/defineProperty.js
44
44
  function _defineProperty(e, r, t) {
45
45
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
46
46
  value: t,
@@ -116,7 +116,7 @@ const ToggleScriptPanelOperation = {
116
116
  //#endregion
117
117
  //#region package.json
118
118
  var name = "@univerjs/uniscript";
119
- var version = "0.25.0-insiders.20260623-012b5a8";
119
+ var version = "0.25.1";
120
120
 
121
121
  //#endregion
122
122
  //#region src/config/config.ts
@@ -125,7 +125,36 @@ const configSymbol = Symbol(UNISCRIPT_PLUGIN_CONFIG_KEY);
125
125
  const defaultPluginConfig = {};
126
126
 
127
127
  //#endregion
128
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
128
+ //#region src/menu/menu.ts
129
+ function UniscriptMenuItemFactory(accessor) {
130
+ return {
131
+ id: ToggleScriptPanelOperation.id,
132
+ title: "toggle-script-panel",
133
+ tooltip: "uniscript.tooltip.menu-button",
134
+ icon: "CodeIcon",
135
+ type: MenuItemType.BUTTON,
136
+ hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
137
+ disabled$: getCurrentRangeDisable$(accessor, {
138
+ workbookTypes: [WorkbookEditablePermission],
139
+ worksheetTypes: [
140
+ WorksheetEditPermission,
141
+ WorksheetSetCellStylePermission,
142
+ WorksheetSetCellValuePermission
143
+ ],
144
+ rangeTypes: [RangeProtectionPermissionEditPoint]
145
+ })
146
+ };
147
+ }
148
+
149
+ //#endregion
150
+ //#region src/menu/schema.ts
151
+ const menuSchema = { [RibbonOthersGroup.OTHERS]: { [ToggleScriptPanelOperation.id]: {
152
+ order: 0,
153
+ menuItemFactory: UniscriptMenuItemFactory
154
+ } } };
155
+
156
+ //#endregion
157
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorateParam.js
129
158
  function __decorateParam(paramIndex, decorator) {
130
159
  return function(target, key) {
131
160
  decorator(target, key, paramIndex);
@@ -133,7 +162,7 @@ function __decorateParam(paramIndex, decorator) {
133
162
  }
134
163
 
135
164
  //#endregion
136
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
165
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorate.js
137
166
  function __decorate(decorators, target, key, desc) {
138
167
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
139
168
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -259,7 +288,7 @@ function ScriptEditorPanel() {
259
288
  disposableCollection === null || disposableCollection === void 0 || disposableCollection.dispose();
260
289
  };
261
290
  }, [editorService, shortcutService]);
262
- const startExecution = useExecution(useCallback(() => monacoEditorRef.current, []));
291
+ const startExecution = useExecution(monacoEditorRef);
263
292
  return /* @__PURE__ */ jsxs("div", {
264
293
  className: "univer-h-full",
265
294
  children: [/* @__PURE__ */ jsx("div", {
@@ -276,13 +305,13 @@ function ScriptEditorPanel() {
276
305
  })]
277
306
  });
278
307
  }
279
- function useExecution(getMonacoEditor) {
308
+ function useExecution(monacoEditorRef) {
280
309
  const scriptService = useDependency(IUniscriptExecutionService);
281
310
  const messageService = useDependency(IMessageService);
282
311
  const localeService = useDependency(LocaleService);
283
312
  return useCallback(() => {
284
- var _getMonacoEditor;
285
- const model = (_getMonacoEditor = getMonacoEditor()) === null || _getMonacoEditor === void 0 ? void 0 : _getMonacoEditor.getModel();
313
+ var _monacoEditorRef$curr;
314
+ const model = (_monacoEditorRef$curr = monacoEditorRef.current) === null || _monacoEditorRef$curr === void 0 ? void 0 : _monacoEditorRef$curr.getModel();
286
315
  if (model) scriptService.execute(model.getValue()).then(() => {
287
316
  messageService.show({
288
317
  content: localeService.t("uniscript.message.success"),
@@ -295,71 +324,13 @@ function useExecution(getMonacoEditor) {
295
324
  });
296
325
  });
297
326
  }, [
298
- getMonacoEditor,
299
327
  localeService,
300
328
  messageService,
329
+ monacoEditorRef,
301
330
  scriptService
302
331
  ]);
303
332
  }
304
333
 
305
- //#endregion
306
- //#region src/controllers/components.controller.ts
307
- /**
308
- * Copyright 2023-present DreamNum Co., Ltd.
309
- *
310
- * Licensed under the Apache License, Version 2.0 (the "License");
311
- * you may not use this file except in compliance with the License.
312
- * You may obtain a copy of the License at
313
- *
314
- * http://www.apache.org/licenses/LICENSE-2.0
315
- *
316
- * Unless required by applicable law or agreed to in writing, software
317
- * distributed under the License is distributed on an "AS IS" BASIS,
318
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
319
- * See the License for the specific language governing permissions and
320
- * limitations under the License.
321
- */
322
- let ComponentsController = class ComponentsController extends Disposable {
323
- constructor(_componentManager) {
324
- super();
325
- this._componentManager = _componentManager;
326
- this._registerComponents();
327
- }
328
- _registerComponents() {
329
- this.disposeWithMe(this._componentManager.register(ScriptPanelComponentName, ScriptEditorPanel));
330
- }
331
- };
332
- ComponentsController = __decorate([__decorateParam(0, Inject(ComponentManager))], ComponentsController);
333
-
334
- //#endregion
335
- //#region src/menu/menu.ts
336
- function UniscriptMenuItemFactory(accessor) {
337
- return {
338
- id: ToggleScriptPanelOperation.id,
339
- title: "uniscript.title",
340
- tooltip: "uniscript.tooltip.menu-button",
341
- icon: "CodeIcon",
342
- type: MenuItemType.BUTTON,
343
- hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
344
- disabled$: getCurrentRangeDisable$(accessor, {
345
- workbookTypes: [WorkbookEditablePermission],
346
- worksheetTypes: [
347
- WorksheetEditPermission,
348
- WorksheetSetCellStylePermission,
349
- WorksheetSetCellValuePermission
350
- ],
351
- rangeTypes: [RangeProtectionPermissionEditPoint]
352
- })
353
- };
354
- }
355
-
356
- //#endregion
357
- //#region src/menu/schema.ts
358
- const menuSchema = { [RibbonOthersGroup.OTHERS]: { [ToggleScriptPanelOperation.id]: {
359
- order: 0,
360
- menuItemFactory: UniscriptMenuItemFactory
361
- } } };
362
-
363
334
  //#endregion
364
335
  //#region src/controllers/uniscript.controller.ts
365
336
  /**
@@ -378,14 +349,19 @@ const menuSchema = { [RibbonOthersGroup.OTHERS]: { [ToggleScriptPanelOperation.i
378
349
  * limitations under the License.
379
350
  */
380
351
  let UniscriptController = class UniscriptController extends Disposable {
381
- constructor(_menuManagerService, commandService) {
352
+ constructor(_menuManagerService, commandService, componentManager) {
382
353
  super();
383
354
  this._menuManagerService = _menuManagerService;
384
355
  this._menuManagerService.mergeMenu(menuSchema);
356
+ this.disposeWithMe(componentManager.register(ScriptPanelComponentName, ScriptEditorPanel));
385
357
  this.disposeWithMe(commandService.registerCommand(ToggleScriptPanelOperation));
386
358
  }
387
359
  };
388
- UniscriptController = __decorate([__decorateParam(0, IMenuManagerService), __decorateParam(1, ICommandService)], UniscriptController);
360
+ UniscriptController = __decorate([
361
+ __decorateParam(0, IMenuManagerService),
362
+ __decorateParam(1, ICommandService),
363
+ __decorateParam(2, Inject(ComponentManager))
364
+ ], UniscriptController);
389
365
 
390
366
  //#endregion
391
367
  //#region src/plugin.ts
@@ -402,13 +378,11 @@ let UniverUniscriptPlugin = class UniverUniscriptPlugin extends Plugin {
402
378
  onStarting() {
403
379
  const injector = this._injector;
404
380
  [
405
- [ComponentsController],
406
381
  [UniscriptController],
407
382
  [ScriptEditorService],
408
383
  [ScriptPanelService]
409
384
  ].forEach((d) => injector.add(d));
410
385
  this.registerExecution();
411
- this._injector.get(ComponentsController);
412
386
  }
413
387
  onSteady() {
414
388
  this._injector.get(UniscriptController);
package/lib/index.js CHANGED
@@ -1,15 +1,15 @@
1
1
  import { CommandType, Disposable, DisposableCollection, ICommandService, IConfigService, ILogService, Inject, Injector, LocaleService, Plugin, ThemeService, UniverInstanceType, createIdentifier, merge, toDisposable } from "@univerjs/core";
2
2
  import { ComponentManager, IMenuManagerService, IMessageService, IShortcutService, ISidebarService, MenuItemType, RibbonOthersGroup, getMenuHiddenObservable, useDependency } from "@univerjs/ui";
3
3
  import { BehaviorSubject, distinctUntilChanged } from "rxjs";
4
+ import { RangeProtectionPermissionEditPoint, WorkbookEditablePermission, WorksheetEditPermission, WorksheetSetCellStylePermission, WorksheetSetCellValuePermission } from "@univerjs/sheets";
5
+ import { getCurrentRangeDisable$ } from "@univerjs/sheets-ui";
4
6
  import { Button, MessageType } from "@univerjs/design";
5
7
  import { editor } from "monaco-editor";
6
8
  import { useCallback, useEffect, useRef } from "react";
7
9
  import { FUniver } from "@univerjs/core/facade";
8
10
  import { jsx, jsxs } from "react/jsx-runtime";
9
- import { RangeProtectionPermissionEditPoint, WorkbookEditablePermission, WorksheetEditPermission, WorksheetSetCellStylePermission, WorksheetSetCellValuePermission } from "@univerjs/sheets";
10
- import { getCurrentRangeDisable$ } from "@univerjs/sheets-ui";
11
11
 
12
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
12
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/typeof.js
13
13
  function _typeof(o) {
14
14
  "@babel/helpers - typeof";
15
15
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -20,7 +20,7 @@ function _typeof(o) {
20
20
  }
21
21
 
22
22
  //#endregion
23
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
23
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPrimitive.js
24
24
  function toPrimitive(t, r) {
25
25
  if ("object" != _typeof(t) || !t) return t;
26
26
  var e = t[Symbol.toPrimitive];
@@ -33,14 +33,14 @@ function toPrimitive(t, r) {
33
33
  }
34
34
 
35
35
  //#endregion
36
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
36
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPropertyKey.js
37
37
  function toPropertyKey(t) {
38
38
  var i = toPrimitive(t, "string");
39
39
  return "symbol" == _typeof(i) ? i : i + "";
40
40
  }
41
41
 
42
42
  //#endregion
43
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
43
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/defineProperty.js
44
44
  function _defineProperty(e, r, t) {
45
45
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
46
46
  value: t,
@@ -116,7 +116,7 @@ const ToggleScriptPanelOperation = {
116
116
  //#endregion
117
117
  //#region package.json
118
118
  var name = "@univerjs/uniscript";
119
- var version = "0.25.0-insiders.20260623-012b5a8";
119
+ var version = "0.25.1";
120
120
 
121
121
  //#endregion
122
122
  //#region src/config/config.ts
@@ -125,7 +125,36 @@ const configSymbol = Symbol(UNISCRIPT_PLUGIN_CONFIG_KEY);
125
125
  const defaultPluginConfig = {};
126
126
 
127
127
  //#endregion
128
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
128
+ //#region src/menu/menu.ts
129
+ function UniscriptMenuItemFactory(accessor) {
130
+ return {
131
+ id: ToggleScriptPanelOperation.id,
132
+ title: "toggle-script-panel",
133
+ tooltip: "uniscript.tooltip.menu-button",
134
+ icon: "CodeIcon",
135
+ type: MenuItemType.BUTTON,
136
+ hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
137
+ disabled$: getCurrentRangeDisable$(accessor, {
138
+ workbookTypes: [WorkbookEditablePermission],
139
+ worksheetTypes: [
140
+ WorksheetEditPermission,
141
+ WorksheetSetCellStylePermission,
142
+ WorksheetSetCellValuePermission
143
+ ],
144
+ rangeTypes: [RangeProtectionPermissionEditPoint]
145
+ })
146
+ };
147
+ }
148
+
149
+ //#endregion
150
+ //#region src/menu/schema.ts
151
+ const menuSchema = { [RibbonOthersGroup.OTHERS]: { [ToggleScriptPanelOperation.id]: {
152
+ order: 0,
153
+ menuItemFactory: UniscriptMenuItemFactory
154
+ } } };
155
+
156
+ //#endregion
157
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorateParam.js
129
158
  function __decorateParam(paramIndex, decorator) {
130
159
  return function(target, key) {
131
160
  decorator(target, key, paramIndex);
@@ -133,7 +162,7 @@ function __decorateParam(paramIndex, decorator) {
133
162
  }
134
163
 
135
164
  //#endregion
136
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
165
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorate.js
137
166
  function __decorate(decorators, target, key, desc) {
138
167
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
139
168
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -259,7 +288,7 @@ function ScriptEditorPanel() {
259
288
  disposableCollection === null || disposableCollection === void 0 || disposableCollection.dispose();
260
289
  };
261
290
  }, [editorService, shortcutService]);
262
- const startExecution = useExecution(useCallback(() => monacoEditorRef.current, []));
291
+ const startExecution = useExecution(monacoEditorRef);
263
292
  return /* @__PURE__ */ jsxs("div", {
264
293
  className: "univer-h-full",
265
294
  children: [/* @__PURE__ */ jsx("div", {
@@ -276,13 +305,13 @@ function ScriptEditorPanel() {
276
305
  })]
277
306
  });
278
307
  }
279
- function useExecution(getMonacoEditor) {
308
+ function useExecution(monacoEditorRef) {
280
309
  const scriptService = useDependency(IUniscriptExecutionService);
281
310
  const messageService = useDependency(IMessageService);
282
311
  const localeService = useDependency(LocaleService);
283
312
  return useCallback(() => {
284
- var _getMonacoEditor;
285
- const model = (_getMonacoEditor = getMonacoEditor()) === null || _getMonacoEditor === void 0 ? void 0 : _getMonacoEditor.getModel();
313
+ var _monacoEditorRef$curr;
314
+ const model = (_monacoEditorRef$curr = monacoEditorRef.current) === null || _monacoEditorRef$curr === void 0 ? void 0 : _monacoEditorRef$curr.getModel();
286
315
  if (model) scriptService.execute(model.getValue()).then(() => {
287
316
  messageService.show({
288
317
  content: localeService.t("uniscript.message.success"),
@@ -295,71 +324,13 @@ function useExecution(getMonacoEditor) {
295
324
  });
296
325
  });
297
326
  }, [
298
- getMonacoEditor,
299
327
  localeService,
300
328
  messageService,
329
+ monacoEditorRef,
301
330
  scriptService
302
331
  ]);
303
332
  }
304
333
 
305
- //#endregion
306
- //#region src/controllers/components.controller.ts
307
- /**
308
- * Copyright 2023-present DreamNum Co., Ltd.
309
- *
310
- * Licensed under the Apache License, Version 2.0 (the "License");
311
- * you may not use this file except in compliance with the License.
312
- * You may obtain a copy of the License at
313
- *
314
- * http://www.apache.org/licenses/LICENSE-2.0
315
- *
316
- * Unless required by applicable law or agreed to in writing, software
317
- * distributed under the License is distributed on an "AS IS" BASIS,
318
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
319
- * See the License for the specific language governing permissions and
320
- * limitations under the License.
321
- */
322
- let ComponentsController = class ComponentsController extends Disposable {
323
- constructor(_componentManager) {
324
- super();
325
- this._componentManager = _componentManager;
326
- this._registerComponents();
327
- }
328
- _registerComponents() {
329
- this.disposeWithMe(this._componentManager.register(ScriptPanelComponentName, ScriptEditorPanel));
330
- }
331
- };
332
- ComponentsController = __decorate([__decorateParam(0, Inject(ComponentManager))], ComponentsController);
333
-
334
- //#endregion
335
- //#region src/menu/menu.ts
336
- function UniscriptMenuItemFactory(accessor) {
337
- return {
338
- id: ToggleScriptPanelOperation.id,
339
- title: "uniscript.title",
340
- tooltip: "uniscript.tooltip.menu-button",
341
- icon: "CodeIcon",
342
- type: MenuItemType.BUTTON,
343
- hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
344
- disabled$: getCurrentRangeDisable$(accessor, {
345
- workbookTypes: [WorkbookEditablePermission],
346
- worksheetTypes: [
347
- WorksheetEditPermission,
348
- WorksheetSetCellStylePermission,
349
- WorksheetSetCellValuePermission
350
- ],
351
- rangeTypes: [RangeProtectionPermissionEditPoint]
352
- })
353
- };
354
- }
355
-
356
- //#endregion
357
- //#region src/menu/schema.ts
358
- const menuSchema = { [RibbonOthersGroup.OTHERS]: { [ToggleScriptPanelOperation.id]: {
359
- order: 0,
360
- menuItemFactory: UniscriptMenuItemFactory
361
- } } };
362
-
363
334
  //#endregion
364
335
  //#region src/controllers/uniscript.controller.ts
365
336
  /**
@@ -378,14 +349,19 @@ const menuSchema = { [RibbonOthersGroup.OTHERS]: { [ToggleScriptPanelOperation.i
378
349
  * limitations under the License.
379
350
  */
380
351
  let UniscriptController = class UniscriptController extends Disposable {
381
- constructor(_menuManagerService, commandService) {
352
+ constructor(_menuManagerService, commandService, componentManager) {
382
353
  super();
383
354
  this._menuManagerService = _menuManagerService;
384
355
  this._menuManagerService.mergeMenu(menuSchema);
356
+ this.disposeWithMe(componentManager.register(ScriptPanelComponentName, ScriptEditorPanel));
385
357
  this.disposeWithMe(commandService.registerCommand(ToggleScriptPanelOperation));
386
358
  }
387
359
  };
388
- UniscriptController = __decorate([__decorateParam(0, IMenuManagerService), __decorateParam(1, ICommandService)], UniscriptController);
360
+ UniscriptController = __decorate([
361
+ __decorateParam(0, IMenuManagerService),
362
+ __decorateParam(1, ICommandService),
363
+ __decorateParam(2, Inject(ComponentManager))
364
+ ], UniscriptController);
389
365
 
390
366
  //#endregion
391
367
  //#region src/plugin.ts
@@ -402,13 +378,11 @@ let UniverUniscriptPlugin = class UniverUniscriptPlugin extends Plugin {
402
378
  onStarting() {
403
379
  const injector = this._injector;
404
380
  [
405
- [ComponentsController],
406
381
  [UniscriptController],
407
382
  [ScriptEditorService],
408
383
  [ScriptPanelService]
409
384
  ].forEach((d) => injector.add(d));
410
385
  this.registerExecution();
411
- this._injector.get(ComponentsController);
412
386
  }
413
387
  onSteady() {
414
388
  this._injector.get(UniscriptController);
@@ -14,8 +14,8 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import { Disposable, ICommandService } from '@univerjs/core';
17
- import { IMenuManagerService } from '@univerjs/ui';
17
+ import { ComponentManager, IMenuManagerService } from '@univerjs/ui';
18
18
  export declare class UniscriptController extends Disposable {
19
19
  private readonly _menuManagerService;
20
- constructor(_menuManagerService: IMenuManagerService, commandService: ICommandService);
20
+ constructor(_menuManagerService: IMenuManagerService, commandService: ICommandService, componentManager: ComponentManager);
21
21
  }
@@ -15,5 +15,4 @@
15
15
  */
16
16
  import type { IAccessor } from '@univerjs/core';
17
17
  import type { IMenuButtonItem } from '@univerjs/ui';
18
- import type { LocaleKey } from '../locale/types';
19
- export declare function UniscriptMenuItemFactory(accessor: IAccessor): IMenuButtonItem<LocaleKey>;
18
+ export declare function UniscriptMenuItemFactory(accessor: IAccessor): IMenuButtonItem;
@@ -13,4 +13,4 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- export declare function ScriptEditorPanel(): import("react").JSX.Element;
16
+ export declare function ScriptEditorPanel(): import("react/jsx-runtime").JSX.Element;
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=`0.25.0-insiders.20260623-012b5a8`;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}})});
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/sheets"),require("@univerjs/sheets-ui"),require("@univerjs/design"),require("monaco-editor"),require("react"),require("@univerjs/core/facade"),require("react/jsx-runtime")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/ui`,`rxjs`,`@univerjs/sheets`,`@univerjs/sheets-ui`,`@univerjs/design`,`monaco-editor`,`react`,`@univerjs/core/facade`,`react/jsx-runtime`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverUniscript={},e.UniverCore,e.UniverUi,e.rxjs,e.UniverSheets,e.UniverSheetsUi,e.UniverDesign,e.monaco,e.React,e.UniverCoreFacade,e.React))})(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=`0.25.1`;let b=`uniscript.config`,x={};function S(e){return{id:_.id,title:`toggle-script-panel`,tooltip:`uniscript.tooltip.menu-button`,icon:`CodeIcon`,type:n.MenuItemType.BUTTON,hidden$:(0,n.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_SHEET),disabled$:(0,a.getCurrentRangeDisable$)(e,{workbookTypes:[i.WorkbookEditablePermission],worksheetTypes:[i.WorksheetEditPermission,i.WorksheetSetCellStylePermission,i.WorksheetSetCellValuePermission],rangeTypes:[i.RangeProtectionPermissionEditPoint]})}}let C={[n.RibbonOthersGroup.OTHERS]:{[_.id]:{order:0,menuItemFactory:S}}};function w(e,t){return function(n,r){t(n,r,e)}}function T(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 E=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}}}};E=T([w(0,t.IConfigService)],E);let D=(0,t.createIdentifier)(`univer.uniscript.execution-service`),O=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=l.FUniver.newAPI(this._injector),n=Function(`univerAPI`,`(() => {${e}})()`);try{return n(t),!0}catch(e){return this._logService.error(e),!1}}};O=T([w(0,t.ILogService),w(1,(0,t.Inject)(t.Injector))],O);function k(){let e=(0,c.useRef)(null),r=(0,c.useRef)(null),i=(0,c.useRef)(null),a=(0,n.useDependency)(t.LocaleService),l=(0,n.useDependency)(n.IShortcutService),d=(0,n.useDependency)(E),f=(0,n.useDependency)(t.ThemeService);(0,c.useEffect)(()=>{let n=r.current,a=e.current,o=null,c=null;if(n&&a){d.requireVscodeEditor();let e=i.current=s.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}=a.getBoundingClientRect();e.layout({width:r,height:n}),t=void 0})}),c.observe(a);let r;o=new t.DisposableCollection,o.add(d.setEditorInstance(e)),o.add(e.onDidFocusEditorWidget(()=>{r=l.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&&a&&c.unobserve(a),o==null||o.dispose()}},[d,l]);let p=A(i);return(0,u.jsxs)(`div`,{className:`univer-h-full`,children:[(0,u.jsx)(`div`,{ref:e,className:`univer-h-[calc(100%-60px)] univer-w-full univer-overflow-hidden`,children:(0,u.jsx)(`div`,{ref:r})}),(0,u.jsx)(`div`,{className:`univer-mt-2.5`,children:(0,u.jsx)(o.Button,{variant:`primary`,onClick:p,children:a.t(`uniscript.panel.execute`)})})]})}function A(e){let r=(0,n.useDependency)(D),i=(0,n.useDependency)(n.IMessageService),a=(0,n.useDependency)(t.LocaleService);return(0,c.useCallback)(()=>{var t;let n=(t=e.current)==null?void 0:t.getModel();n&&r.execute(n.getValue()).then(()=>{i.show({content:a.t(`uniscript.message.success`),type:o.MessageType.Success})}).catch(()=>{i.show({content:a.t(`uniscript.message.failed`),type:o.MessageType.Error})})},[a,i,e,r])}let j=class extends t.Disposable{constructor(e,t,n){super(),this._menuManagerService=e,this._menuManagerService.mergeMenu(C),this.disposeWithMe(n.register(g,k)),this.disposeWithMe(t.registerCommand(_))}};j=T([w(0,n.IMenuManagerService),w(1,t.ICommandService),w(2,(0,t.Inject)(n.ComponentManager))],j);let M=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;[[j],[E],[h]].forEach(t=>e.add(t)),this.registerExecution()}onSteady(){this._injector.get(j)}registerExecution(){this._injector.add([D,{useClass:O}])}};m(M,`pluginName`,`UNIVER_UNISCRIPT_PLUGIN`),m(M,`packageName`,v),m(M,`version`,y),M=T([w(1,(0,t.Inject)(t.Injector)),w(2,t.IConfigService)],M),e.IUniscriptExecutionService=D,Object.defineProperty(e,"ScriptEditorService",{enumerable:!0,get:function(){return E}}),e.ToggleScriptPanelOperation=_,Object.defineProperty(e,"UniverUniscriptPlugin",{enumerable:!0,get:function(){return M}})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/uniscript",
3
- "version": "0.25.0-insiders.20260623-012b5a8",
3
+ "version": "0.25.1",
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,11 +59,11 @@
59
59
  },
60
60
  "dependencies": {
61
61
  "monaco-editor": "0.55.1",
62
- "@univerjs/core": "0.25.0-insiders.20260623-012b5a8",
63
- "@univerjs/design": "0.25.0-insiders.20260623-012b5a8",
64
- "@univerjs/sheets": "0.25.0-insiders.20260623-012b5a8",
65
- "@univerjs/ui": "0.25.0-insiders.20260623-012b5a8",
66
- "@univerjs/sheets-ui": "0.25.0-insiders.20260623-012b5a8"
62
+ "@univerjs/core": "0.25.1",
63
+ "@univerjs/design": "0.25.1",
64
+ "@univerjs/sheets": "0.25.1",
65
+ "@univerjs/sheets-ui": "0.25.1",
66
+ "@univerjs/ui": "0.25.1"
67
67
  },
68
68
  "devDependencies": {
69
69
  "postcss": "^8.5.15",
@@ -71,8 +71,8 @@
71
71
  "rxjs": "^7.8.2",
72
72
  "tailwindcss": "3.4.18",
73
73
  "typescript": "^6.0.3",
74
- "vitest": "^4.1.9",
75
- "@univerjs-infra/shared": "0.25.0"
74
+ "vitest": "^4.1.7",
75
+ "@univerjs-infra/shared": "0.25.1"
76
76
  },
77
77
  "scripts": {
78
78
  "test": "vitest run",
@@ -1,22 +0,0 @@
1
- /**
2
- * Copyright 2023-present DreamNum Co., Ltd.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- import { Disposable } from '@univerjs/core';
17
- import { ComponentManager } from '@univerjs/ui';
18
- export declare class ComponentsController extends Disposable {
19
- private readonly _componentManager;
20
- constructor(_componentManager: ComponentManager);
21
- private _registerComponents;
22
- }
@@ -1,18 +0,0 @@
1
- /**
2
- * Copyright 2023-present DreamNum Co., Ltd.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- import type { LocaleLeafKeys } from '@univerjs/core';
17
- import type enUS from './en-US';
18
- export type LocaleKey = LocaleLeafKeys<typeof enUS>;
@@ -1,16 +0,0 @@
1
- /**
2
- * Copyright 2023-present DreamNum Co., Ltd.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- export {};