@pooder/vue 4.1.1 → 4.2.0
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/dist/index.es.js +194 -98
- package/dist/index.umd.js +1 -1
- package/dist/vue/src/PooderEditor.vue.d.ts +41 -2
- package/dist/vue.css +1 -1
- package/package.json +3 -3
package/dist/index.es.js
CHANGED
|
@@ -1,80 +1,138 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { Pooder as
|
|
1
|
+
import { defineComponent as T, ref as M, onMounted as U, onUnmounted as B, createElementBlock as E, openBlock as O, createElementVNode as V, provide as G, createVNode as J } from "vue";
|
|
2
|
+
import { Pooder as $ } from "@pooder/core";
|
|
3
3
|
export * from "@pooder/core";
|
|
4
|
-
import { CanvasService as
|
|
4
|
+
import { CanvasService as q, BackgroundTool as K, SizeTool as Q, SceneLayoutService as Z, SceneVisibilityService as ee, ImageTool as te, WhiteInkTool as ne, MirrorTool as ae, DielineTool as ie, RulerTool as oe, FeatureTool as ce } from "@pooder/kit";
|
|
5
5
|
export * from "@pooder/kit";
|
|
6
|
-
const
|
|
6
|
+
const se = /* @__PURE__ */ T({
|
|
7
7
|
__name: "CanvasArea",
|
|
8
8
|
emits: ["canvas-ready", "resize"],
|
|
9
|
-
setup(
|
|
10
|
-
const
|
|
11
|
-
let
|
|
12
|
-
return
|
|
13
|
-
if (
|
|
14
|
-
const { clientWidth:
|
|
15
|
-
|
|
16
|
-
for (const
|
|
17
|
-
const { width:
|
|
18
|
-
|
|
9
|
+
setup(p, { emit: v }) {
|
|
10
|
+
const u = v, c = M(null), s = M(null);
|
|
11
|
+
let r = null;
|
|
12
|
+
return U(() => {
|
|
13
|
+
if (c.value && s.value) {
|
|
14
|
+
const { clientWidth: h, clientHeight: w } = c.value;
|
|
15
|
+
s.value.width = h, s.value.height = w, u("canvas-ready", s.value), r = new ResizeObserver((b) => {
|
|
16
|
+
for (const C of b) {
|
|
17
|
+
const { width: x, height: S } = C.contentRect;
|
|
18
|
+
u("resize", x, S);
|
|
19
19
|
}
|
|
20
|
-
}),
|
|
20
|
+
}), r.observe(c.value);
|
|
21
21
|
}
|
|
22
|
-
}),
|
|
23
|
-
|
|
24
|
-
}), (
|
|
22
|
+
}), B(() => {
|
|
23
|
+
r && r.disconnect();
|
|
24
|
+
}), (h, w) => (O(), E("div", {
|
|
25
25
|
ref_key: "container",
|
|
26
|
-
ref:
|
|
26
|
+
ref: c,
|
|
27
27
|
class: "pooder-canvas-area"
|
|
28
28
|
}, [
|
|
29
|
-
|
|
29
|
+
V("canvas", {
|
|
30
30
|
ref_key: "canvas",
|
|
31
|
-
ref:
|
|
31
|
+
ref: s
|
|
32
32
|
}, null, 512)
|
|
33
33
|
], 512));
|
|
34
34
|
}
|
|
35
|
-
}),
|
|
36
|
-
const
|
|
37
|
-
for (const [
|
|
38
|
-
|
|
39
|
-
return
|
|
40
|
-
},
|
|
35
|
+
}), k = (p, v) => {
|
|
36
|
+
const u = p.__vccOpts || p;
|
|
37
|
+
for (const [c, s] of v)
|
|
38
|
+
u[c] = s;
|
|
39
|
+
return u;
|
|
40
|
+
}, re = /* @__PURE__ */ k(se, [["__scopeId", "data-v-dc60e8d6"]]), de = { class: "pooder-editor" }, me = "image.user", ue = /* @__PURE__ */ T({
|
|
41
41
|
__name: "PooderEditor",
|
|
42
42
|
emits: ["image-change"],
|
|
43
|
-
setup(
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
const
|
|
47
|
-
e.key === "image.items" &&
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
43
|
+
setup(p, { expose: v, emit: u }) {
|
|
44
|
+
const c = new $();
|
|
45
|
+
G("pooder", c);
|
|
46
|
+
const s = c.getService("CommandService"), r = c.getService("ConfigurationService"), h = c.getService("WorkbenchService"), w = u, b = r.onAnyChange((e) => {
|
|
47
|
+
e.key === "image.items" && w("image-change", e.value);
|
|
48
|
+
}), C = (e) => {
|
|
49
|
+
r.import(e);
|
|
50
|
+
}, x = () => r.export(), S = () => r.get("image.items", []), A = async () => await s.executeCommand("exportCutImage"), I = async (e, t) => await s.executeCommand("upsertImage", e, {
|
|
51
|
+
id: t?.id,
|
|
52
|
+
mode: t?.mode,
|
|
53
|
+
createIfMissing: t?.createIfMissing,
|
|
54
|
+
addOptions: t?.addOptions,
|
|
55
|
+
fitOnAdd: t?.fitOnAdd
|
|
56
|
+
}), F = async (e, t) => (await I(e, {
|
|
57
|
+
mode: "add",
|
|
58
|
+
addOptions: t,
|
|
59
|
+
fitOnAdd: !0
|
|
60
|
+
})).id, R = async (e, t) => await s.executeCommand("updateImage", e, t), z = async () => await s.executeCommand("clearImages"), D = (e) => Math.max(-1, Math.min(2, e)), X = (e) => {
|
|
61
|
+
const t = e?.cutRect;
|
|
62
|
+
if (!t) return null;
|
|
63
|
+
const n = Number(t.width), a = Number(t.height), i = Number(t.left), o = Number(t.top);
|
|
64
|
+
return !Number.isFinite(n) || !Number.isFinite(a) || !Number.isFinite(i) || !Number.isFinite(o) || n <= 0 || a <= 0 ? null : { left: i, top: o, width: n, height: a };
|
|
65
|
+
}, y = (e) => {
|
|
66
|
+
if (!e) return [];
|
|
67
|
+
const t = e.canvas.getObjects(), n = [];
|
|
68
|
+
for (const a of t) {
|
|
69
|
+
if (a?.data?.layerId !== me) continue;
|
|
70
|
+
const i = a?.data?.id;
|
|
71
|
+
if (typeof i != "string") continue;
|
|
72
|
+
const o = a.getCenterPoint ? a.getCenterPoint() : null, d = Number(o?.x ?? a.left), m = Number(o?.y ?? a.top), f = Number(a.scaleX), g = Number(a.width), l = Number(a.height);
|
|
73
|
+
!Number.isFinite(d) || !Number.isFinite(m) || !Number.isFinite(f) || !Number.isFinite(g) || !Number.isFinite(l) || g <= 0 || l <= 0 || n.push({
|
|
74
|
+
id: i,
|
|
75
|
+
centerX: d,
|
|
76
|
+
centerY: m,
|
|
77
|
+
objectScale: f,
|
|
78
|
+
sourceWidth: g,
|
|
79
|
+
sourceHeight: l
|
|
71
80
|
});
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
81
|
+
}
|
|
82
|
+
return n;
|
|
83
|
+
}, _ = (e) => {
|
|
84
|
+
r.update("dieline.shape", "custom"), r.update("dieline.pathData", e.pathData), r.update("size.cutMode", "trim"), r.update("size.cutMarginMm", 0);
|
|
85
|
+
}, Y = (e, t) => {
|
|
86
|
+
const n = e.rawBounds || e.baseBounds, a = Number(e.imageWidth ?? 0), i = Number(e.imageHeight ?? 0);
|
|
87
|
+
if (!n || !Number.isFinite(n.x) || !Number.isFinite(n.y) || !Number.isFinite(n.width) || !Number.isFinite(n.height) || n.width <= 0 || n.height <= 0 || a <= 0 || i <= 0)
|
|
88
|
+
return { shiftX: 0, shiftY: 0 };
|
|
89
|
+
const o = t.width / n.width, d = t.height / n.height, m = n.x + n.width / 2, f = n.y + n.height / 2, g = a / 2, l = i / 2;
|
|
90
|
+
return {
|
|
91
|
+
shiftX: (m - g) * o,
|
|
92
|
+
shiftY: (f - l) * d
|
|
93
|
+
};
|
|
94
|
+
}, N = async (e, t, n = !1) => {
|
|
95
|
+
if (!t.length) return;
|
|
96
|
+
const a = await s.executeCommand("getSceneLayout"), i = X(a);
|
|
97
|
+
if (!i) return;
|
|
98
|
+
const { shiftX: o, shiftY: d } = Y(e, i);
|
|
99
|
+
n && console.info("[PooderEditor] detectDieline alignment", {
|
|
100
|
+
frame: i,
|
|
101
|
+
shiftX: o,
|
|
102
|
+
shiftY: d,
|
|
103
|
+
snapshotCount: t.length,
|
|
104
|
+
baseBounds: e.baseBounds,
|
|
105
|
+
rawBounds: e.rawBounds,
|
|
106
|
+
imageWidth: e.imageWidth,
|
|
107
|
+
imageHeight: e.imageHeight
|
|
108
|
+
});
|
|
109
|
+
for (const m of t) {
|
|
110
|
+
const f = Math.max(
|
|
111
|
+
i.width / Math.max(1, m.sourceWidth),
|
|
112
|
+
i.height / Math.max(1, m.sourceHeight)
|
|
113
|
+
), g = Math.max(0.05, m.objectScale / f), l = m.centerX - o, H = m.centerY - d, P = D(
|
|
114
|
+
(l - i.left) / Math.max(1, i.width)
|
|
115
|
+
), L = D(
|
|
116
|
+
(H - i.top) / Math.max(1, i.height)
|
|
117
|
+
);
|
|
118
|
+
await s.executeCommand("updateImage", m.id, {
|
|
119
|
+
scale: g,
|
|
120
|
+
left: P,
|
|
121
|
+
top: L
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
v({
|
|
126
|
+
importConfig: C,
|
|
127
|
+
exportConfig: x,
|
|
128
|
+
getImages: S,
|
|
129
|
+
generateCutImage: A,
|
|
130
|
+
addImage: F,
|
|
131
|
+
upsertImage: I,
|
|
132
|
+
updateImage: R,
|
|
133
|
+
clearImages: z,
|
|
76
134
|
detectDieline: async (e) => {
|
|
77
|
-
const n = await
|
|
135
|
+
const t = c.getService("CanvasService"), n = y(t), a = await s.executeCommand("detectEdge", e, {
|
|
78
136
|
expand: 10,
|
|
79
137
|
// 安全距离(像素)
|
|
80
138
|
smoothing: !0,
|
|
@@ -82,56 +140,94 @@ const $ = /* @__PURE__ */ w({
|
|
|
82
140
|
simplifyTolerance: 2
|
|
83
141
|
// 平滑度容差,值越大越圆润
|
|
84
142
|
});
|
|
85
|
-
if (
|
|
86
|
-
|
|
87
|
-
|
|
143
|
+
if (a) {
|
|
144
|
+
_(a);
|
|
145
|
+
const o = (r.get("image.items") || []).find((d) => d.url === e);
|
|
146
|
+
if (o?.id) {
|
|
147
|
+
const d = n.filter(
|
|
148
|
+
(m) => m.id === o.id
|
|
149
|
+
);
|
|
150
|
+
await N(a, d);
|
|
151
|
+
}
|
|
152
|
+
return a.pathData;
|
|
88
153
|
}
|
|
89
154
|
return null;
|
|
90
155
|
},
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
156
|
+
detectDielineFromFrame: async (e) => {
|
|
157
|
+
const t = e?.detect?.debug === !0, n = c.getService("CanvasService"), a = y(n), { url: i } = await s.executeCommand("exportImageFrameUrl", {
|
|
158
|
+
multiplier: 2,
|
|
159
|
+
format: "png"
|
|
160
|
+
});
|
|
161
|
+
try {
|
|
162
|
+
const o = await s.executeCommand("detectEdge", i, {
|
|
163
|
+
expand: e?.detect?.expand ?? 30,
|
|
164
|
+
smoothing: e?.detect?.smoothing ?? !0,
|
|
165
|
+
simplifyTolerance: e?.detect?.simplifyTolerance ?? 2,
|
|
166
|
+
debug: t
|
|
167
|
+
});
|
|
168
|
+
return o ? (e?.commit === !1 || (_(o), await N(o, a, t)), o) : null;
|
|
169
|
+
} finally {
|
|
170
|
+
i && URL.revokeObjectURL(i);
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
uploadAndDetectEdge: async (e, t) => {
|
|
174
|
+
const n = c.getService("CanvasService"), a = await F(e), i = y(n).filter(
|
|
175
|
+
(d) => d.id === a
|
|
176
|
+
), o = await s.executeCommand("detectEdge", e, {
|
|
177
|
+
expand: t?.expand ?? 10,
|
|
178
|
+
smoothing: t?.smoothing ?? !0,
|
|
179
|
+
simplifyTolerance: t?.simplifyTolerance ?? 2
|
|
180
|
+
});
|
|
181
|
+
return o ? (_(o), await N(o, i), { imageId: a, url: e, pathData: o.pathData }) : null;
|
|
182
|
+
},
|
|
183
|
+
activateTool: async (e) => await h.switchTool(e),
|
|
184
|
+
deactivateTool: async () => await h.deactivate(),
|
|
185
|
+
on: (e, t) => c.eventBus.on(e, t),
|
|
186
|
+
off: (e, t) => c.eventBus.off(e, t),
|
|
187
|
+
emit: (e, t) => c.eventBus.emit(e, t),
|
|
188
|
+
executeCommand: (e, ...t) => s.executeCommand(e, ...t),
|
|
189
|
+
getConfig: (e) => r.get(e),
|
|
190
|
+
updateConfig: (e, t) => r.update(e, t),
|
|
98
191
|
services: {
|
|
99
|
-
workbench:
|
|
100
|
-
command:
|
|
101
|
-
config:
|
|
192
|
+
workbench: h,
|
|
193
|
+
command: s,
|
|
194
|
+
config: r
|
|
102
195
|
}
|
|
103
196
|
});
|
|
104
|
-
const
|
|
105
|
-
const
|
|
106
|
-
eventBus:
|
|
197
|
+
const W = (e) => {
|
|
198
|
+
const t = new q(e, {
|
|
199
|
+
eventBus: c.eventBus
|
|
107
200
|
});
|
|
108
|
-
|
|
109
|
-
new
|
|
110
|
-
new
|
|
201
|
+
c.registerService(t, "CanvasService"), [
|
|
202
|
+
new K(),
|
|
203
|
+
new Q(),
|
|
204
|
+
new Z(),
|
|
205
|
+
new ee(),
|
|
206
|
+
new te(),
|
|
111
207
|
// new FilmTool(),
|
|
112
|
-
|
|
113
|
-
new
|
|
114
|
-
new
|
|
115
|
-
new
|
|
116
|
-
new
|
|
117
|
-
].forEach((
|
|
118
|
-
|
|
208
|
+
new ne(),
|
|
209
|
+
new ae(),
|
|
210
|
+
new ie(),
|
|
211
|
+
new oe(),
|
|
212
|
+
new ce()
|
|
213
|
+
].forEach((a) => {
|
|
214
|
+
c.extensionManager.register(a);
|
|
119
215
|
});
|
|
120
|
-
},
|
|
121
|
-
const
|
|
122
|
-
|
|
216
|
+
}, j = (e, t) => {
|
|
217
|
+
const n = c.getService("CanvasService");
|
|
218
|
+
n && n.resize(e, t);
|
|
123
219
|
};
|
|
124
|
-
return
|
|
125
|
-
const e =
|
|
126
|
-
e && e.dispose(),
|
|
127
|
-
}), (e,
|
|
128
|
-
|
|
129
|
-
onCanvasReady:
|
|
130
|
-
onResize:
|
|
220
|
+
return B(() => {
|
|
221
|
+
const e = c.getService("CanvasService");
|
|
222
|
+
e && e.dispose(), b.dispose(), c.extensionManager.destroy();
|
|
223
|
+
}), (e, t) => (O(), E("div", de, [
|
|
224
|
+
J(re, {
|
|
225
|
+
onCanvasReady: W,
|
|
226
|
+
onResize: j
|
|
131
227
|
})
|
|
132
228
|
]));
|
|
133
229
|
}
|
|
134
|
-
}),
|
|
230
|
+
}), we = /* @__PURE__ */ k(ue, [["__scopeId", "data-v-74b112ea"]]);
|
|
135
231
|
export {
|
|
136
|
-
|
|
232
|
+
we as PooderEditor
|
|
137
233
|
};
|
package/dist/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(u,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("vue"),require("@pooder/core"),require("@pooder/kit")):typeof define=="function"&&define.amd?define(["exports","vue","@pooder/core","@pooder/kit"],s):(u=typeof globalThis<"u"?globalThis:u||self,s(u.PooderVue={},u.Vue,u.PooderCore,u.PooderKit))})(this,(function(u,s,S,g){"use strict";const j=s.defineComponent({__name:"CanvasArea",emits:["canvas-ready","resize"],setup(m,{emit:y}){const h=y,c=s.ref(null),r=s.ref(null);let d=null;return s.onMounted(()=>{if(c.value&&r.value){const{clientWidth:b,clientHeight:C}=c.value;r.value.width=b,r.value.height=C,h("canvas-ready",r.value),d=new ResizeObserver(x=>{for(const _ of x){const{width:N,height:I}=_.contentRect;h("resize",N,I)}}),d.observe(c.value)}}),s.onUnmounted(()=>{d&&d.disconnect()}),(b,C)=>(s.openBlock(),s.createElementBlock("div",{ref_key:"container",ref:c,class:"pooder-canvas-area"},[s.createElementVNode("canvas",{ref_key:"canvas",ref:r},null,512)],512))}}),T=(m,y)=>{const h=m.__vccOpts||m;for(const[c,r]of y)h[c]=r;return h},P=T(j,[["__scopeId","data-v-dc60e8d6"]]),A={class:"pooder-editor"},R="image.user",z=T(s.defineComponent({__name:"PooderEditor",emits:["image-change"],setup(m,{expose:y,emit:h}){const c=new S.Pooder;s.provide("pooder",c);const r=c.getService("CommandService"),d=c.getService("ConfigurationService"),b=c.getService("WorkbenchService"),C=h,x=d.onAnyChange(e=>{e.key==="image.items"&&C("image-change",e.value)}),_=e=>{d.import(e)},N=()=>d.export(),I=()=>d.get("image.items",[]),X=async()=>await r.executeCommand("exportCutImage"),M=async(e,t)=>await r.executeCommand("upsertImage",e,{id:t?.id,mode:t?.mode,createIfMissing:t?.createIfMissing,addOptions:t?.addOptions,fitOnAdd:t?.fitOnAdd}),E=async(e,t)=>(await M(e,{mode:"add",addOptions:t,fitOnAdd:!0})).id,Y=async(e,t)=>await r.executeCommand("updateImage",e,t),W=async()=>await r.executeCommand("clearImages"),B=e=>Math.max(-1,Math.min(2,e)),H=e=>{const t=e?.cutRect;if(!t)return null;const n=Number(t.width),o=Number(t.height),i=Number(t.left),a=Number(t.top);return!Number.isFinite(n)||!Number.isFinite(o)||!Number.isFinite(i)||!Number.isFinite(a)||n<=0||o<=0?null:{left:i,top:a,width:n,height:o}},F=e=>{if(!e)return[];const t=e.canvas.getObjects(),n=[];for(const o of t){if(o?.data?.layerId!==R)continue;const i=o?.data?.id;if(typeof i!="string")continue;const a=o.getCenterPoint?o.getCenterPoint():null,l=Number(a?.x??o.left),f=Number(a?.y??o.top),w=Number(o.scaleX),p=Number(o.width),v=Number(o.height);!Number.isFinite(l)||!Number.isFinite(f)||!Number.isFinite(w)||!Number.isFinite(p)||!Number.isFinite(v)||p<=0||v<=0||n.push({id:i,centerX:l,centerY:f,objectScale:w,sourceWidth:p,sourceHeight:v})}return n},O=e=>{d.update("dieline.shape","custom"),d.update("dieline.pathData",e.pathData),d.update("size.cutMode","trim"),d.update("size.cutMarginMm",0)},L=(e,t)=>{const n=e.rawBounds||e.baseBounds,o=Number(e.imageWidth??0),i=Number(e.imageHeight??0);if(!n||!Number.isFinite(n.x)||!Number.isFinite(n.y)||!Number.isFinite(n.width)||!Number.isFinite(n.height)||n.width<=0||n.height<=0||o<=0||i<=0)return{shiftX:0,shiftY:0};const a=t.width/n.width,l=t.height/n.height,f=n.x+n.width/2,w=n.y+n.height/2,p=o/2,v=i/2;return{shiftX:(f-p)*a,shiftY:(w-v)*l}},D=async(e,t,n=!1)=>{if(!t.length)return;const o=await r.executeCommand("getSceneLayout"),i=H(o);if(!i)return;const{shiftX:a,shiftY:l}=L(e,i);n&&console.info("[PooderEditor] detectDieline alignment",{frame:i,shiftX:a,shiftY:l,snapshotCount:t.length,baseBounds:e.baseBounds,rawBounds:e.rawBounds,imageWidth:e.imageWidth,imageHeight:e.imageHeight});for(const f of t){const w=Math.max(i.width/Math.max(1,f.sourceWidth),i.height/Math.max(1,f.sourceHeight)),p=Math.max(.05,f.objectScale/w),v=f.centerX-a,q=f.centerY-l,G=B((v-i.left)/Math.max(1,i.width)),J=B((q-i.top)/Math.max(1,i.height));await r.executeCommand("updateImage",f.id,{scale:p,left:G,top:J})}};y({importConfig:_,exportConfig:N,getImages:I,generateCutImage:X,addImage:E,upsertImage:M,updateImage:Y,clearImages:W,detectDieline:async e=>{const t=c.getService("CanvasService"),n=F(t),o=await r.executeCommand("detectEdge",e,{expand:10,smoothing:!0,simplifyTolerance:2});if(o){O(o);const a=(d.get("image.items")||[]).find(l=>l.url===e);if(a?.id){const l=n.filter(f=>f.id===a.id);await D(o,l)}return o.pathData}return null},detectDielineFromFrame:async e=>{const t=e?.detect?.debug===!0,n=c.getService("CanvasService"),o=F(n),{url:i}=await r.executeCommand("exportImageFrameUrl",{multiplier:2,format:"png"});try{const a=await r.executeCommand("detectEdge",i,{expand:e?.detect?.expand??30,smoothing:e?.detect?.smoothing??!0,simplifyTolerance:e?.detect?.simplifyTolerance??2,debug:t});return a?(e?.commit===!1||(O(a),await D(a,o,t)),a):null}finally{i&&URL.revokeObjectURL(i)}},uploadAndDetectEdge:async(e,t)=>{const n=c.getService("CanvasService"),o=await E(e),i=F(n).filter(l=>l.id===o),a=await r.executeCommand("detectEdge",e,{expand:t?.expand??10,smoothing:t?.smoothing??!0,simplifyTolerance:t?.simplifyTolerance??2});return a?(O(a),await D(a,i),{imageId:o,url:e,pathData:a.pathData}):null},activateTool:async e=>await b.switchTool(e),deactivateTool:async()=>await b.deactivate(),on:(e,t)=>c.eventBus.on(e,t),off:(e,t)=>c.eventBus.off(e,t),emit:(e,t)=>c.eventBus.emit(e,t),executeCommand:(e,...t)=>r.executeCommand(e,...t),getConfig:e=>d.get(e),updateConfig:(e,t)=>d.update(e,t),services:{workbench:b,command:r,config:d}});const U=e=>{const t=new g.CanvasService(e,{eventBus:c.eventBus});c.registerService(t,"CanvasService"),[new g.BackgroundTool,new g.SizeTool,new g.SceneLayoutService,new g.SceneVisibilityService,new g.ImageTool,new g.WhiteInkTool,new g.MirrorTool,new g.DielineTool,new g.RulerTool,new g.FeatureTool].forEach(o=>{c.extensionManager.register(o)})},V=(e,t)=>{const n=c.getService("CanvasService");n&&n.resize(e,t)};return s.onUnmounted(()=>{const e=c.getService("CanvasService");e&&e.dispose(),x.dispose(),c.extensionManager.destroy()}),(e,t)=>(s.openBlock(),s.createElementBlock("div",A,[s.createVNode(P,{onCanvasReady:U,onResize:V})]))}}),[["__scopeId","data-v-74b112ea"]]);u.PooderEditor=z,Object.keys(S).forEach(m=>{m!=="default"&&!Object.prototype.hasOwnProperty.call(u,m)&&Object.defineProperty(u,m,{enumerable:!0,get:()=>S[m]})}),Object.keys(g).forEach(m=>{m!=="default"&&!Object.prototype.hasOwnProperty.call(u,m)&&Object.defineProperty(u,m,{enumerable:!0,get:()=>g[m]})}),Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})}));
|
|
@@ -1,14 +1,53 @@
|
|
|
1
1
|
import { CommandService, ConfigurationService, WorkbenchService } from '../../core/src/index.ts';
|
|
2
|
+
interface DetectBounds {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
}
|
|
8
|
+
interface DetectEdgeResult {
|
|
9
|
+
pathData: string;
|
|
10
|
+
rawBounds?: DetectBounds;
|
|
11
|
+
baseBounds?: DetectBounds;
|
|
12
|
+
imageWidth?: number;
|
|
13
|
+
imageHeight?: number;
|
|
14
|
+
}
|
|
2
15
|
declare const _default: import('vue').DefineComponent<{}, {
|
|
3
16
|
importConfig: (config: Record<string, any>) => void;
|
|
4
17
|
exportConfig: () => Record<string, any>;
|
|
5
18
|
getImages: () => never[];
|
|
6
19
|
generateCutImage: () => Promise<any>;
|
|
7
20
|
addImage: (url: string, options?: any) => Promise<any>;
|
|
21
|
+
upsertImage: (url: string, options?: {
|
|
22
|
+
id?: string;
|
|
23
|
+
mode?: "auto" | "replace" | "add";
|
|
24
|
+
createIfMissing?: boolean;
|
|
25
|
+
addOptions?: any;
|
|
26
|
+
fitOnAdd?: boolean;
|
|
27
|
+
}) => Promise<any>;
|
|
8
28
|
updateImage: (id: string, options?: any) => Promise<any>;
|
|
9
29
|
clearImages: () => Promise<any>;
|
|
10
|
-
detectDieline: (url: string) => Promise<
|
|
11
|
-
|
|
30
|
+
detectDieline: (url: string) => Promise<string | null>;
|
|
31
|
+
detectDielineFromFrame: (options?: {
|
|
32
|
+
detect?: {
|
|
33
|
+
expand?: number;
|
|
34
|
+
smoothing?: boolean;
|
|
35
|
+
simplifyTolerance?: number;
|
|
36
|
+
debug?: boolean;
|
|
37
|
+
};
|
|
38
|
+
commit?: boolean;
|
|
39
|
+
}) => Promise<DetectEdgeResult | null>;
|
|
40
|
+
uploadAndDetectEdge: (url: string, options?: {
|
|
41
|
+
expand?: number;
|
|
42
|
+
smoothing?: boolean;
|
|
43
|
+
simplifyTolerance?: number;
|
|
44
|
+
}) => Promise<{
|
|
45
|
+
imageId: any;
|
|
46
|
+
url: string;
|
|
47
|
+
pathData: string;
|
|
48
|
+
} | null>;
|
|
49
|
+
activateTool: (id: string | null) => Promise<import('../../core/src/index.ts/src/services/WorkbenchService').ToolSwitchResult>;
|
|
50
|
+
deactivateTool: () => Promise<import('../../core/src/index.ts/src/services/WorkbenchService').ToolSwitchResult>;
|
|
12
51
|
on: (event: string, handler: any) => void;
|
|
13
52
|
off: (event: string, handler: any) => void;
|
|
14
53
|
emit: (event: string, data: any) => void;
|
package/dist/vue.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.pooder-canvas-area[data-v-
|
|
1
|
+
.pooder-canvas-area[data-v-dc60e8d6]{flex:1;width:100%;height:100%;min-height:650px;min-width:650px;overflow:hidden;background:#f5f5f5;position:relative}canvas[data-v-dc60e8d6]{display:block}.pooder-editor[data-v-74b112ea]{display:flex;width:100%;height:100%;overflow:hidden}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pooder/vue",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"main": "./dist/index.umd.js",
|
|
5
5
|
"module": "./dist/index.es.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"access": "public"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@pooder/core": "2.
|
|
23
|
-
"@pooder/kit": "
|
|
22
|
+
"@pooder/core": "2.1.0",
|
|
23
|
+
"@pooder/kit": "5.0.0"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"vue": "^3.0.0"
|