@univerjs/docs-drawing 0.4.2-nightly.202411061606 → 0.4.2-nightly.202411081606

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.
@@ -0,0 +1 @@
1
+ "use strict";var S=Object.defineProperty;var f=(t,r,e)=>r in t?S(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e;var _=(t,r,e)=>f(t,typeof r!="symbol"?r+"":r,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@univerjs/core"),h=require("@univerjs/drawing"),p="docs-drawing.config",U={};class v extends h.UnitDrawingService{}const d=c.createIdentifier("univer.doc.plugin.doc-drawing.service");var I=Object.defineProperty,O=Object.getOwnPropertyDescriptor,P=(t,r,e,n)=>{for(var i=n>1?void 0:n?O(r,e):r,a=t.length-1,s;a>=0;a--)(s=t[a])&&(i=(n?s(r,e,i):s(i))||i);return n&&i&&I(r,e,i),i},o=(t,r)=>(e,n)=>r(e,n,t);const u="DOC_DRAWING_PLUGIN";let D=class extends c.Disposable{constructor(t,r,e,n){super(),this._docDrawingService=t,this._drawingManagerService=r,this._resourceManagerService=e,this._univerInstanceService=n,this._init()}_init(){this._initSnapshot()}_initSnapshot(){const t=e=>{const n=this._univerInstanceService.getUnit(e,c.UniverInstanceType.UNIVER_DOC);if(n){const i=n.getSnapshot().drawings,a=n.getSnapshot().drawingsOrder,s={data:i!=null?i:{},order:a!=null?a:[]};return JSON.stringify(s)}return""},r=e=>{if(!e)return{data:{},order:[]};try{return JSON.parse(e)}catch{return{data:{},order:[]}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:u,businesses:[c.UniverInstanceType.UNIVER_DOC],toJson:e=>t(e),parseJson:e=>r(e),onUnLoad:e=>{this._setDrawingDataForUnit(e,{data:{},order:[]})},onLoad:(e,n)=>{var i,a;this._setDrawingDataForUnit(e,{data:(i=n.data)!=null?i:{},order:(a=n.order)!=null?a:[]})}}))}_setDrawingDataForUnit(t,r){const e=this._univerInstanceService.getUnit(t);e!=null&&(e.resetDrawing(r.data,r.order),this._initDataLoader(t))}_initDataLoader(t){const r=this._univerInstanceService.getUnit(t,c.UniverInstanceType.UNIVER_DOC);if(!r)return!1;const e=t,n=r.getDrawings(),i=r.getDrawingsOrder();if(!n||!i)return!1;Object.keys(n).forEach(s=>{const w=n[s];n[s]={...w}});const a={[e]:{unitId:t,subUnitId:e,data:n,order:i}};return this._docDrawingService.registerDrawingData(t,a),this._drawingManagerService.registerDrawingData(t,a),!0}};D=P([o(0,d),o(1,h.IDrawingManagerService),o(2,c.IResourceManagerService),o(3,c.IUniverInstanceService)],D);var N=Object.defineProperty,C=Object.getOwnPropertyDescriptor,M=(t,r,e,n)=>{for(var i=n>1?void 0:n?C(r,e):r,a=t.length-1,s;a>=0;a--)(s=t[a])&&(i=(n?s(r,e,i):s(i))||i);return n&&i&&N(r,e,i),i},l=(t,r)=>(e,n)=>r(e,n,t),g;exports.UniverDocsDrawingPlugin=(g=class extends c.Plugin{constructor(r=U,e,n){super(),this._config=r,this._injector=e,this._configService=n;const{...i}=this._config;this._configService.setConfig(p,i)}onStarting(){[[D],[v],[d,{useClass:v}]].forEach(r=>this._injector.add(r)),this._injector.get(D)}},_(g,"pluginName",u),_(g,"type",c.UniverInstanceType.UNIVER_DOC),g);exports.UniverDocsDrawingPlugin=M([l(1,c.Inject(c.Injector)),l(2,c.IConfigService)],exports.UniverDocsDrawingPlugin);exports.DOCS_DRAWING_PLUGIN=u;exports.DocDrawingService=v;exports.IDocDrawingService=d;
package/lib/es/index.js CHANGED
@@ -1,122 +1,119 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
3
- var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
4
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
5
- import { createIdentifier, Disposable, UniverInstanceType, IResourceManagerService, IUniverInstanceService, Plugin, Inject, Injector, IConfigService } from "@univerjs/core";
6
- import { UnitDrawingService, IDrawingManagerService } from "@univerjs/drawing";
7
- const PLUGIN_CONFIG_KEY = "docs-drawing.config", defaultPluginConfig = {}, _DocDrawingService = class _DocDrawingService extends UnitDrawingService {
8
- };
9
- __name(_DocDrawingService, "DocDrawingService");
10
- let DocDrawingService = _DocDrawingService;
11
- const IDocDrawingService = createIdentifier("univer.doc.plugin.doc-drawing.service");
12
- var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
13
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
14
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
15
- return kind && result && __defProp$1(target, key, result), result;
16
- }, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1");
17
- const DOCS_DRAWING_PLUGIN = "DOC_DRAWING_PLUGIN";
18
- var _a;
19
- let DocDrawingController = (_a = class extends Disposable {
20
- constructor(_docDrawingService, _drawingManagerService, _resourceManagerService, _univerInstanceService) {
21
- super(), this._docDrawingService = _docDrawingService, this._drawingManagerService = _drawingManagerService, this._resourceManagerService = _resourceManagerService, this._univerInstanceService = _univerInstanceService, this._init();
1
+ var p = Object.defineProperty;
2
+ var S = (t, r, e) => r in t ? p(t, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[r] = e;
3
+ var D = (t, r, e) => S(t, typeof r != "symbol" ? r + "" : r, e);
4
+ import { createIdentifier as w, Disposable as O, UniverInstanceType as g, IResourceManagerService as U, IUniverInstanceService as I, Plugin as P, Inject as C, Injector as N, IConfigService as M } from "@univerjs/core";
5
+ import { UnitDrawingService as b, IDrawingManagerService as j } from "@univerjs/drawing";
6
+ const m = "docs-drawing.config", R = {};
7
+ class d extends b {
8
+ }
9
+ const h = w("univer.doc.plugin.doc-drawing.service");
10
+ var E = Object.defineProperty, L = Object.getOwnPropertyDescriptor, G = (t, r, e, n) => {
11
+ for (var i = n > 1 ? void 0 : n ? L(r, e) : r, s = t.length - 1, a; s >= 0; s--)
12
+ (a = t[s]) && (i = (n ? a(r, e, i) : a(i)) || i);
13
+ return n && i && E(r, e, i), i;
14
+ }, o = (t, r) => (e, n) => r(e, n, t);
15
+ const f = "DOC_DRAWING_PLUGIN";
16
+ let _ = class extends O {
17
+ constructor(t, r, e, n) {
18
+ super(), this._docDrawingService = t, this._drawingManagerService = r, this._resourceManagerService = e, this._univerInstanceService = n, this._init();
22
19
  }
23
20
  _init() {
24
21
  this._initSnapshot();
25
22
  }
26
23
  _initSnapshot() {
27
- const toJson = /* @__PURE__ */ __name((unitId) => {
28
- const doc = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_DOC);
29
- if (doc) {
30
- const drawings = doc.getSnapshot().drawings, drawingOrder = doc.getSnapshot().drawingsOrder, data = {
31
- data: drawings != null ? drawings : {},
32
- order: drawingOrder != null ? drawingOrder : []
24
+ const t = (e) => {
25
+ const n = this._univerInstanceService.getUnit(e, g.UNIVER_DOC);
26
+ if (n) {
27
+ const i = n.getSnapshot().drawings, s = n.getSnapshot().drawingsOrder, a = {
28
+ data: i != null ? i : {},
29
+ order: s != null ? s : []
33
30
  };
34
- return JSON.stringify(data);
31
+ return JSON.stringify(a);
35
32
  }
36
33
  return "";
37
- }, "toJson"), parseJson = /* @__PURE__ */ __name((json) => {
38
- if (!json)
34
+ }, r = (e) => {
35
+ if (!e)
39
36
  return { data: {}, order: [] };
40
37
  try {
41
- return JSON.parse(json);
38
+ return JSON.parse(e);
42
39
  } catch {
43
40
  return { data: {}, order: [] };
44
41
  }
45
- }, "parseJson");
42
+ };
46
43
  this.disposeWithMe(
47
44
  this._resourceManagerService.registerPluginResource({
48
- pluginName: DOCS_DRAWING_PLUGIN,
49
- businesses: [UniverInstanceType.UNIVER_DOC],
50
- toJson: /* @__PURE__ */ __name((unitId) => toJson(unitId), "toJson"),
51
- parseJson: /* @__PURE__ */ __name((json) => parseJson(json), "parseJson"),
52
- onUnLoad: /* @__PURE__ */ __name((unitId) => {
53
- this._setDrawingDataForUnit(unitId, { data: {}, order: [] });
54
- }, "onUnLoad"),
55
- onLoad: /* @__PURE__ */ __name((unitId, value) => {
56
- var _a3, _b;
57
- this._setDrawingDataForUnit(unitId, { data: (_a3 = value.data) != null ? _a3 : {}, order: (_b = value.order) != null ? _b : [] });
58
- }, "onLoad")
45
+ pluginName: f,
46
+ businesses: [g.UNIVER_DOC],
47
+ toJson: (e) => t(e),
48
+ parseJson: (e) => r(e),
49
+ onUnLoad: (e) => {
50
+ this._setDrawingDataForUnit(e, { data: {}, order: [] });
51
+ },
52
+ onLoad: (e, n) => {
53
+ var i, s;
54
+ this._setDrawingDataForUnit(e, { data: (i = n.data) != null ? i : {}, order: (s = n.order) != null ? s : [] });
55
+ }
59
56
  })
60
57
  );
61
58
  }
62
- _setDrawingDataForUnit(unitId, drawingMapItem) {
63
- const documentDataModel = this._univerInstanceService.getUnit(unitId);
64
- documentDataModel != null && (documentDataModel.resetDrawing(drawingMapItem.data, drawingMapItem.order), this._initDataLoader(unitId));
59
+ _setDrawingDataForUnit(t, r) {
60
+ const e = this._univerInstanceService.getUnit(t);
61
+ e != null && (e.resetDrawing(r.data, r.order), this._initDataLoader(t));
65
62
  }
66
- _initDataLoader(unitId) {
67
- const dataModel = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_DOC);
68
- if (!dataModel)
63
+ _initDataLoader(t) {
64
+ const r = this._univerInstanceService.getUnit(t, g.UNIVER_DOC);
65
+ if (!r)
69
66
  return !1;
70
- const subUnitId = unitId, drawingDataModels = dataModel.getDrawings(), drawingOrderModel = dataModel.getDrawingsOrder();
71
- if (!drawingDataModels || !drawingOrderModel)
67
+ const e = t, n = r.getDrawings(), i = r.getDrawingsOrder();
68
+ if (!n || !i)
72
69
  return !1;
73
- Object.keys(drawingDataModels).forEach((drawingId) => {
74
- const drawingDataModel = drawingDataModels[drawingId];
75
- drawingDataModels[drawingId] = { ...drawingDataModel };
70
+ Object.keys(n).forEach((a) => {
71
+ const l = n[a];
72
+ n[a] = { ...l };
76
73
  });
77
- const subDrawings = {
78
- [subUnitId]: {
79
- unitId,
80
- subUnitId,
81
- data: drawingDataModels,
82
- order: drawingOrderModel
74
+ const s = {
75
+ [e]: {
76
+ unitId: t,
77
+ subUnitId: e,
78
+ data: n,
79
+ order: i
83
80
  }
84
81
  };
85
- return this._docDrawingService.registerDrawingData(unitId, subDrawings), this._drawingManagerService.registerDrawingData(unitId, subDrawings), !0;
82
+ return this._docDrawingService.registerDrawingData(t, s), this._drawingManagerService.registerDrawingData(t, s), !0;
86
83
  }
87
- }, __name(_a, "DocDrawingController"), _a);
88
- DocDrawingController = __decorateClass$1([
89
- __decorateParam$1(0, IDocDrawingService),
90
- __decorateParam$1(1, IDrawingManagerService),
91
- __decorateParam$1(2, IResourceManagerService),
92
- __decorateParam$1(3, IUniverInstanceService)
93
- ], DocDrawingController);
94
- var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
95
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
96
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
97
- return kind && result && __defProp2(target, key, result), result;
98
- }, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam"), _a2;
99
- let UniverDocsDrawingPlugin = (_a2 = class extends Plugin {
100
- constructor(_config = defaultPluginConfig, _injector, _configService) {
101
- super(), this._config = _config, this._injector = _injector, this._configService = _configService;
102
- const { ...rest } = this._config;
103
- this._configService.setConfig(PLUGIN_CONFIG_KEY, rest);
84
+ };
85
+ _ = G([
86
+ o(0, h),
87
+ o(1, j),
88
+ o(2, U),
89
+ o(3, I)
90
+ ], _);
91
+ var J = Object.defineProperty, y = Object.getOwnPropertyDescriptor, x = (t, r, e, n) => {
92
+ for (var i = n > 1 ? void 0 : n ? y(r, e) : r, s = t.length - 1, a; s >= 0; s--)
93
+ (a = t[s]) && (i = (n ? a(r, e, i) : a(i)) || i);
94
+ return n && i && J(r, e, i), i;
95
+ }, v = (t, r) => (e, n) => r(e, n, t), c;
96
+ let u = (c = class extends P {
97
+ constructor(t = R, r, e) {
98
+ super(), this._config = t, this._injector = r, this._configService = e;
99
+ const { ...n } = this._config;
100
+ this._configService.setConfig(m, n);
104
101
  }
105
102
  onStarting() {
106
103
  [
107
- [DocDrawingController],
108
- [DocDrawingService],
109
- [IDocDrawingService, { useClass: DocDrawingService }]
110
- ].forEach((dependency) => this._injector.add(dependency)), this._injector.get(DocDrawingController);
104
+ [_],
105
+ [d],
106
+ [h, { useClass: d }]
107
+ ].forEach((t) => this._injector.add(t)), this._injector.get(_);
111
108
  }
112
- }, __name(_a2, "UniverDocsDrawingPlugin"), __publicField(_a2, "pluginName", DOCS_DRAWING_PLUGIN), __publicField(_a2, "type", UniverInstanceType.UNIVER_DOC), _a2);
113
- UniverDocsDrawingPlugin = __decorateClass([
114
- __decorateParam(1, Inject(Injector)),
115
- __decorateParam(2, IConfigService)
116
- ], UniverDocsDrawingPlugin);
109
+ }, D(c, "pluginName", f), D(c, "type", g.UNIVER_DOC), c);
110
+ u = x([
111
+ v(1, C(N)),
112
+ v(2, M)
113
+ ], u);
117
114
  export {
118
- DOCS_DRAWING_PLUGIN,
119
- DocDrawingService,
120
- IDocDrawingService,
121
- UniverDocsDrawingPlugin
115
+ f as DOCS_DRAWING_PLUGIN,
116
+ d as DocDrawingService,
117
+ h as IDocDrawingService,
118
+ u as UniverDocsDrawingPlugin
122
119
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/docs-drawing",
3
- "version": "0.4.2-nightly.202411061606",
3
+ "version": "0.4.2-nightly.202411081606",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -21,10 +21,12 @@
21
21
  "exports": {
22
22
  ".": {
23
23
  "import": "./lib/es/index.js",
24
+ "require": "./lib/cjs/index.js",
24
25
  "types": "./lib/types/index.d.ts"
25
26
  },
26
27
  "./*": {
27
28
  "import": "./lib/es/*",
29
+ "require": "./lib/cjs/*",
28
30
  "types": "./lib/types/index.d.ts"
29
31
  },
30
32
  "./lib/*": "./lib/*"
@@ -42,8 +44,8 @@
42
44
  ],
43
45
  "dependencies": {
44
46
  "@vitejs/plugin-react": "4.3.3",
45
- "@univerjs/drawing": "0.4.2-nightly.202411061606",
46
- "@univerjs/core": "0.4.2-nightly.202411061606"
47
+ "@univerjs/core": "0.4.2-nightly.202411081606",
48
+ "@univerjs/drawing": "0.4.2-nightly.202411081606"
47
49
  },
48
50
  "devDependencies": {
49
51
  "typescript": "^5.6.3",
@@ -51,13 +53,15 @@
51
53
  "vitest": "^2.1.4",
52
54
  "@univerjs-infra/shared": "0.4.2"
53
55
  },
54
- "univerSpace": {
56
+ "space": {
55
57
  ".": {
56
58
  "import": "./lib/es/index.js",
59
+ "require": "./lib/cjs/index.js",
57
60
  "types": "./lib/types/index.d.ts"
58
61
  },
59
62
  "./*": {
60
63
  "import": "./lib/es/*",
64
+ "require": "./lib/cjs/*",
61
65
  "types": "./lib/types/index.d.ts"
62
66
  },
63
67
  "./lib/*": "./lib/*"
@@ -67,7 +71,7 @@
67
71
  "test:watch": "vitest",
68
72
  "coverage": "vitest run --coverage",
69
73
  "lint:types": "tsc --noEmit",
70
- "build": "tsc && vite build"
74
+ "build": "tsx build.ts"
71
75
  },
72
76
  "module": "./lib/es/index.js"
73
77
  }