@univerjs/ui-adapter-vue3 1.0.0-alpha.1 → 1.0.0-alpha.3

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 CHANGED
@@ -3,9 +3,30 @@ let _univerjs_core = require("@univerjs/core");
3
3
  let _univerjs_ui = require("@univerjs/ui");
4
4
  let vue = require("vue");
5
5
 
6
+ //#region src/config/config.ts
7
+ /**
8
+ * Copyright 2023-present DreamNum Co., Ltd.
9
+ *
10
+ * Licensed under the Apache License, Version 2.0 (the "License");
11
+ * you may not use this file except in compliance with the License.
12
+ * You may obtain a copy of the License at
13
+ *
14
+ * http://www.apache.org/licenses/LICENSE-2.0
15
+ *
16
+ * Unless required by applicable law or agreed to in writing, software
17
+ * distributed under the License is distributed on an "AS IS" BASIS,
18
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ * See the License for the specific language governing permissions and
20
+ * limitations under the License.
21
+ */
22
+ const UI_ADAPTER_VUE3_PLUGIN_CONFIG_KEY = "ui-adapter-vue3.config";
23
+ const configSymbol = Symbol(UI_ADAPTER_VUE3_PLUGIN_CONFIG_KEY);
24
+ const defaultPluginConfig = {};
25
+
26
+ //#endregion
6
27
  //#region package.json
7
28
  var name = "@univerjs/ui-adapter-vue3";
8
- var version = "1.0.0-alpha.1";
29
+ var version = "1.0.0-alpha.3";
9
30
 
10
31
  //#endregion
11
32
  //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
@@ -69,11 +90,14 @@ function _defineProperty(e, r, t) {
69
90
  //#endregion
70
91
  //#region src/plugin.ts
71
92
  let UniverVue3AdapterPlugin = class UniverVue3AdapterPlugin extends _univerjs_core.Plugin {
72
- constructor(_config = {}, _injector, _componentManager) {
93
+ constructor(_config = defaultPluginConfig, _injector, _configService, _componentManager) {
73
94
  super();
74
95
  this._config = _config;
75
96
  this._injector = _injector;
97
+ this._configService = _configService;
76
98
  this._componentManager = _componentManager;
99
+ const { ...rest } = (0, _univerjs_core.merge)({}, defaultPluginConfig, this._config);
100
+ this._configService.setConfig(UI_ADAPTER_VUE3_PLUGIN_CONFIG_KEY, rest);
77
101
  }
78
102
  onStarting() {
79
103
  const { createElement, useEffect, useRef } = this._componentManager.reactUtils;
@@ -99,7 +123,8 @@ _defineProperty(UniverVue3AdapterPlugin, "version", version);
99
123
  UniverVue3AdapterPlugin = __decorate([
100
124
  (0, _univerjs_core.DependentOn)(_univerjs_ui.UniverUIPlugin),
101
125
  __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
102
- __decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_ui.ComponentManager))
126
+ __decorateParam(2, _univerjs_core.IConfigService),
127
+ __decorateParam(3, (0, _univerjs_core.Inject)(_univerjs_ui.ComponentManager))
103
128
  ], UniverVue3AdapterPlugin);
104
129
  function VueComponentWrapper(options) {
105
130
  const { component, props, reactUtils } = options;
@@ -116,6 +141,7 @@ function VueComponentWrapper(options) {
116
141
  }
117
142
 
118
143
  //#endregion
144
+ exports.UI_ADAPTER_VUE3_PLUGIN_CONFIG_KEY = UI_ADAPTER_VUE3_PLUGIN_CONFIG_KEY;
119
145
  Object.defineProperty(exports, 'UniverVue3AdapterPlugin', {
120
146
  enumerable: true,
121
147
  get: function () {
package/lib/es/index.js CHANGED
@@ -1,10 +1,31 @@
1
- import { DependentOn, Inject, Injector, Plugin } from "@univerjs/core";
1
+ import { DependentOn, IConfigService, Inject, Injector, Plugin, merge } from "@univerjs/core";
2
2
  import { ComponentManager, UniverUIPlugin } from "@univerjs/ui";
3
3
  import { h, render } from "vue";
4
4
 
5
+ //#region src/config/config.ts
6
+ /**
7
+ * Copyright 2023-present DreamNum Co., Ltd.
8
+ *
9
+ * Licensed under the Apache License, Version 2.0 (the "License");
10
+ * you may not use this file except in compliance with the License.
11
+ * You may obtain a copy of the License at
12
+ *
13
+ * http://www.apache.org/licenses/LICENSE-2.0
14
+ *
15
+ * Unless required by applicable law or agreed to in writing, software
16
+ * distributed under the License is distributed on an "AS IS" BASIS,
17
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ * See the License for the specific language governing permissions and
19
+ * limitations under the License.
20
+ */
21
+ const UI_ADAPTER_VUE3_PLUGIN_CONFIG_KEY = "ui-adapter-vue3.config";
22
+ const configSymbol = Symbol(UI_ADAPTER_VUE3_PLUGIN_CONFIG_KEY);
23
+ const defaultPluginConfig = {};
24
+
25
+ //#endregion
5
26
  //#region package.json
6
27
  var name = "@univerjs/ui-adapter-vue3";
7
- var version = "1.0.0-alpha.1";
28
+ var version = "1.0.0-alpha.3";
8
29
 
9
30
  //#endregion
10
31
  //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
@@ -68,11 +89,14 @@ function _defineProperty(e, r, t) {
68
89
  //#endregion
69
90
  //#region src/plugin.ts
70
91
  let UniverVue3AdapterPlugin = class UniverVue3AdapterPlugin extends Plugin {
71
- constructor(_config = {}, _injector, _componentManager) {
92
+ constructor(_config = defaultPluginConfig, _injector, _configService, _componentManager) {
72
93
  super();
73
94
  this._config = _config;
74
95
  this._injector = _injector;
96
+ this._configService = _configService;
75
97
  this._componentManager = _componentManager;
98
+ const { ...rest } = merge({}, defaultPluginConfig, this._config);
99
+ this._configService.setConfig(UI_ADAPTER_VUE3_PLUGIN_CONFIG_KEY, rest);
76
100
  }
77
101
  onStarting() {
78
102
  const { createElement, useEffect, useRef } = this._componentManager.reactUtils;
@@ -98,7 +122,8 @@ _defineProperty(UniverVue3AdapterPlugin, "version", version);
98
122
  UniverVue3AdapterPlugin = __decorate([
99
123
  DependentOn(UniverUIPlugin),
100
124
  __decorateParam(1, Inject(Injector)),
101
- __decorateParam(2, Inject(ComponentManager))
125
+ __decorateParam(2, IConfigService),
126
+ __decorateParam(3, Inject(ComponentManager))
102
127
  ], UniverVue3AdapterPlugin);
103
128
  function VueComponentWrapper(options) {
104
129
  const { component, props, reactUtils } = options;
@@ -115,4 +140,4 @@ function VueComponentWrapper(options) {
115
140
  }
116
141
 
117
142
  //#endregion
118
- export { UniverVue3AdapterPlugin };
143
+ export { UI_ADAPTER_VUE3_PLUGIN_CONFIG_KEY, UniverVue3AdapterPlugin };
package/lib/index.js CHANGED
@@ -1,10 +1,31 @@
1
- import { DependentOn, Inject, Injector, Plugin } from "@univerjs/core";
1
+ import { DependentOn, IConfigService, Inject, Injector, Plugin, merge } from "@univerjs/core";
2
2
  import { ComponentManager, UniverUIPlugin } from "@univerjs/ui";
3
3
  import { h, render } from "vue";
4
4
 
5
+ //#region src/config/config.ts
6
+ /**
7
+ * Copyright 2023-present DreamNum Co., Ltd.
8
+ *
9
+ * Licensed under the Apache License, Version 2.0 (the "License");
10
+ * you may not use this file except in compliance with the License.
11
+ * You may obtain a copy of the License at
12
+ *
13
+ * http://www.apache.org/licenses/LICENSE-2.0
14
+ *
15
+ * Unless required by applicable law or agreed to in writing, software
16
+ * distributed under the License is distributed on an "AS IS" BASIS,
17
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ * See the License for the specific language governing permissions and
19
+ * limitations under the License.
20
+ */
21
+ const UI_ADAPTER_VUE3_PLUGIN_CONFIG_KEY = "ui-adapter-vue3.config";
22
+ const configSymbol = Symbol(UI_ADAPTER_VUE3_PLUGIN_CONFIG_KEY);
23
+ const defaultPluginConfig = {};
24
+
25
+ //#endregion
5
26
  //#region package.json
6
27
  var name = "@univerjs/ui-adapter-vue3";
7
- var version = "1.0.0-alpha.1";
28
+ var version = "1.0.0-alpha.3";
8
29
 
9
30
  //#endregion
10
31
  //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
@@ -68,11 +89,14 @@ function _defineProperty(e, r, t) {
68
89
  //#endregion
69
90
  //#region src/plugin.ts
70
91
  let UniverVue3AdapterPlugin = class UniverVue3AdapterPlugin extends Plugin {
71
- constructor(_config = {}, _injector, _componentManager) {
92
+ constructor(_config = defaultPluginConfig, _injector, _configService, _componentManager) {
72
93
  super();
73
94
  this._config = _config;
74
95
  this._injector = _injector;
96
+ this._configService = _configService;
75
97
  this._componentManager = _componentManager;
98
+ const { ...rest } = merge({}, defaultPluginConfig, this._config);
99
+ this._configService.setConfig(UI_ADAPTER_VUE3_PLUGIN_CONFIG_KEY, rest);
76
100
  }
77
101
  onStarting() {
78
102
  const { createElement, useEffect, useRef } = this._componentManager.reactUtils;
@@ -98,7 +122,8 @@ _defineProperty(UniverVue3AdapterPlugin, "version", version);
98
122
  UniverVue3AdapterPlugin = __decorate([
99
123
  DependentOn(UniverUIPlugin),
100
124
  __decorateParam(1, Inject(Injector)),
101
- __decorateParam(2, Inject(ComponentManager))
125
+ __decorateParam(2, IConfigService),
126
+ __decorateParam(3, Inject(ComponentManager))
102
127
  ], UniverVue3AdapterPlugin);
103
128
  function VueComponentWrapper(options) {
104
129
  const { component, props, reactUtils } = options;
@@ -115,4 +140,4 @@ function VueComponentWrapper(options) {
115
140
  }
116
141
 
117
142
  //#endregion
118
- export { UniverVue3AdapterPlugin };
143
+ export { UI_ADAPTER_VUE3_PLUGIN_CONFIG_KEY, UniverVue3AdapterPlugin };
@@ -0,0 +1,20 @@
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 declare const UI_ADAPTER_VUE3_PLUGIN_CONFIG_KEY = "ui-adapter-vue3.config";
17
+ export declare const configSymbol: unique symbol;
18
+ export interface IUniverVue3AdapterConfig {
19
+ }
20
+ export declare const defaultPluginConfig: IUniverVue3AdapterConfig;
@@ -13,4 +13,6 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ export { UI_ADAPTER_VUE3_PLUGIN_CONFIG_KEY } from './config/config';
17
+ export type { IUniverVue3AdapterConfig } from './config/config';
16
18
  export { UniverVue3AdapterPlugin } from './plugin';
@@ -14,7 +14,8 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import type { defineComponent } from 'vue';
17
- import { Injector, Plugin } from '@univerjs/core';
17
+ import type { IUniverVue3AdapterConfig } from './config/config';
18
+ import { IConfigService, Injector, Plugin } from '@univerjs/core';
18
19
  import { ComponentManager } from '@univerjs/ui';
19
20
  /**
20
21
  * The plugin that allows Univer to use Vue 3 components as UI components.
@@ -22,11 +23,12 @@ import { ComponentManager } from '@univerjs/ui';
22
23
  export declare class UniverVue3AdapterPlugin extends Plugin {
23
24
  private readonly _config;
24
25
  protected readonly _injector: Injector;
26
+ private readonly _configService;
25
27
  protected readonly _componentManager: ComponentManager;
26
28
  static pluginName: string;
27
29
  static packageName: string;
28
30
  static version: string;
29
- constructor(_config: {} | undefined, _injector: Injector, _componentManager: ComponentManager);
31
+ constructor(_config: Partial<IUniverVue3AdapterConfig> | undefined, _injector: Injector, _configService: IConfigService, _componentManager: ComponentManager);
30
32
  onStarting(): void;
31
33
  }
32
34
  export declare function VueComponentWrapper(options: {
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("vue")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/ui`,`vue`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverUiAdapterVue3={},e.UniverCore,e.UniverUi,e.Vue))})(this,function(e,t,n,r){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var i=`@univerjs/ui-adapter-vue3`,a=`1.0.0-alpha.1`;function o(e,t){return function(n,r){t(n,r,e)}}function s(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}function c(e){"@babel/helpers - typeof";return c=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},c(e)}function l(e,t){if(c(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(c(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function u(e){var t=l(e,`string`);return c(t)==`symbol`?t:t+``}function d(e,t,n){return(t=u(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let f=class extends t.Plugin{constructor(e={},t,n){super(),this._config=e,this._injector=t,this._componentManager=n}onStarting(){let{createElement:e,useEffect:t,useRef:n}=this._componentManager.reactUtils;this._componentManager.setHandler(`vue3`,r=>i=>e(p,{component:r,props:Object.keys(i).reduce((e,t)=>(t!==`key`&&(e[t]=i[t]),e),{}),reactUtils:{createElement:e,useEffect:t,useRef:n}}))}};d(f,`pluginName`,`UNIVER_UI_ADAPTER_VUE3_PLUGIN`),d(f,`packageName`,i),d(f,`version`,a),f=s([(0,t.DependentOn)(n.UniverUIPlugin),o(1,(0,t.Inject)(t.Injector)),o(2,(0,t.Inject)(n.ComponentManager))],f);function p(e){let{component:t,props:n,reactUtils:i}=e,{createElement:a,useEffect:o,useRef:s}=i,c=s(null);return o(()=>{if(c.current)return(0,r.render)((0,r.h)(t,n),c.current),()=>{c.current&&(0,r.render)(null,c.current)}},[n]),a(`div`,{ref:c})}Object.defineProperty(e,"UniverVue3AdapterPlugin",{enumerable:!0,get:function(){return f}})});
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("@univerjs/ui"),require("vue")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/ui`,`vue`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverUiAdapterVue3={},e.UniverCore,e.UniverUi,e.Vue))})(this,function(e,t,n,r){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});let i=`ui-adapter-vue3.config`,a={};var o=`@univerjs/ui-adapter-vue3`,s=`1.0.0-alpha.3`;function c(e,t){return function(n,r){t(n,r,e)}}function l(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}function u(e){"@babel/helpers - typeof";return u=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},u(e)}function d(e,t){if(u(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(u(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function f(e){var t=d(e,`string`);return u(t)==`symbol`?t:t+``}function p(e,t,n){return(t=f(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let m=class extends t.Plugin{constructor(e=a,n,r,o){super(),this._config=e,this._injector=n,this._configService=r,this._componentManager=o;let{...s}=(0,t.merge)({},a,this._config);this._configService.setConfig(i,s)}onStarting(){let{createElement:e,useEffect:t,useRef:n}=this._componentManager.reactUtils;this._componentManager.setHandler(`vue3`,r=>i=>e(h,{component:r,props:Object.keys(i).reduce((e,t)=>(t!==`key`&&(e[t]=i[t]),e),{}),reactUtils:{createElement:e,useEffect:t,useRef:n}}))}};p(m,`pluginName`,`UNIVER_UI_ADAPTER_VUE3_PLUGIN`),p(m,`packageName`,o),p(m,`version`,s),m=l([(0,t.DependentOn)(n.UniverUIPlugin),c(1,(0,t.Inject)(t.Injector)),c(2,t.IConfigService),c(3,(0,t.Inject)(n.ComponentManager))],m);function h(e){let{component:t,props:n,reactUtils:i}=e,{createElement:a,useEffect:o,useRef:s}=i,c=s(null);return o(()=>{if(c.current)return(0,r.render)((0,r.h)(t,n),c.current),()=>{c.current&&(0,r.render)(null,c.current)}},[n]),a(`div`,{ref:c})}e.UI_ADAPTER_VUE3_PLUGIN_CONFIG_KEY=i,Object.defineProperty(e,"UniverVue3AdapterPlugin",{enumerable:!0,get:function(){return m}})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/ui-adapter-vue3",
3
- "version": "1.0.0-alpha.1",
3
+ "version": "1.0.0-alpha.3",
4
4
  "private": false,
5
5
  "description": "Vue 3 adapter for Univer UI services.",
6
6
  "author": "DreamNum Co., Ltd. <developer@univer.ai>",
@@ -52,14 +52,14 @@
52
52
  "vue": ">=3.0.0"
53
53
  },
54
54
  "dependencies": {
55
- "@univerjs/core": "1.0.0-alpha.1",
56
- "@univerjs/ui": "1.0.0-alpha.1"
55
+ "@univerjs/ui": "1.0.0-alpha.3",
56
+ "@univerjs/core": "1.0.0-alpha.3"
57
57
  },
58
58
  "devDependencies": {
59
59
  "typescript": "^6.0.3",
60
- "vitest": "^4.1.9",
61
- "vue": "^3.5.38",
62
- "@univerjs-infra/shared": "1.0.0-alpha.1"
60
+ "vitest": "^4.1.10",
61
+ "vue": "^3.5.39",
62
+ "@univerjs-infra/shared": "1.0.0-alpha.3"
63
63
  },
64
64
  "scripts": {
65
65
  "test": "vitest run",