@pooder/vue 4.2.0 → 4.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.es.js +88 -74
- package/dist/index.umd.js +1 -1
- package/dist/vue/src/PooderEditor.vue.d.ts +3 -1
- package/dist/vue.css +1 -1
- package/package.json +3 -3
package/dist/index.es.js
CHANGED
|
@@ -1,67 +1,81 @@
|
|
|
1
|
-
import { defineComponent as T, ref as M, onMounted as U, onUnmounted as
|
|
1
|
+
import { defineComponent as T, ref as M, onMounted as U, onUnmounted as E, createElementBlock as B, openBlock as O, createElementVNode as V, provide as G, createVNode as J } from "vue";
|
|
2
2
|
import { Pooder as $ } from "@pooder/core";
|
|
3
3
|
export * from "@pooder/core";
|
|
4
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 re = /* @__PURE__ */ T({
|
|
7
7
|
__name: "CanvasArea",
|
|
8
8
|
emits: ["canvas-ready", "resize"],
|
|
9
9
|
setup(p, { emit: v }) {
|
|
10
|
-
const u = v,
|
|
11
|
-
let
|
|
10
|
+
const u = v, o = M(null), r = M(null);
|
|
11
|
+
let s = null;
|
|
12
12
|
return U(() => {
|
|
13
|
-
if (
|
|
14
|
-
const { clientWidth: h, clientHeight: w } =
|
|
15
|
-
|
|
16
|
-
for (const
|
|
17
|
-
const { width:
|
|
18
|
-
u("resize",
|
|
13
|
+
if (o.value && r.value) {
|
|
14
|
+
const { clientWidth: h, clientHeight: w } = o.value;
|
|
15
|
+
r.value.width = h, r.value.height = w, u("canvas-ready", r.value), s = new ResizeObserver((C) => {
|
|
16
|
+
for (const b of C) {
|
|
17
|
+
const { width: S, height: x } = b.contentRect;
|
|
18
|
+
u("resize", S, x);
|
|
19
19
|
}
|
|
20
|
-
}),
|
|
20
|
+
}), s.observe(o.value);
|
|
21
21
|
}
|
|
22
|
-
}),
|
|
23
|
-
|
|
24
|
-
}), (h, w) => (O(),
|
|
22
|
+
}), E(() => {
|
|
23
|
+
s && s.disconnect();
|
|
24
|
+
}), (h, w) => (O(), B("div", {
|
|
25
25
|
ref_key: "container",
|
|
26
|
-
ref:
|
|
26
|
+
ref: o,
|
|
27
27
|
class: "pooder-canvas-area"
|
|
28
28
|
}, [
|
|
29
29
|
V("canvas", {
|
|
30
30
|
ref_key: "canvas",
|
|
31
|
-
ref:
|
|
31
|
+
ref: r
|
|
32
32
|
}, null, 512)
|
|
33
33
|
], 512));
|
|
34
34
|
}
|
|
35
35
|
}), k = (p, v) => {
|
|
36
36
|
const u = p.__vccOpts || p;
|
|
37
|
-
for (const [
|
|
38
|
-
u[
|
|
37
|
+
for (const [o, r] of v)
|
|
38
|
+
u[o] = r;
|
|
39
39
|
return u;
|
|
40
|
-
},
|
|
40
|
+
}, se = /* @__PURE__ */ k(re, [["__scopeId", "data-v-dc60e8d6"]]), de = { class: "pooder-editor" }, me = "image.user", ue = /* @__PURE__ */ T({
|
|
41
41
|
__name: "PooderEditor",
|
|
42
42
|
emits: ["image-change"],
|
|
43
43
|
setup(p, { expose: v, emit: u }) {
|
|
44
|
-
const
|
|
45
|
-
G("pooder",
|
|
46
|
-
const
|
|
44
|
+
const o = new $();
|
|
45
|
+
G("pooder", o);
|
|
46
|
+
const r = o.getService("CommandService"), s = o.getService("ConfigurationService"), h = o.getService("WorkbenchService"), w = u, C = s.onAnyChange((e) => {
|
|
47
47
|
e.key === "image.items" && w("image-change", e.value);
|
|
48
|
-
}),
|
|
49
|
-
|
|
50
|
-
},
|
|
48
|
+
}), b = (e) => {
|
|
49
|
+
s.import(e);
|
|
50
|
+
}, S = () => s.export(), x = () => s.get("image.items", []), A = async (e) => {
|
|
51
|
+
try {
|
|
52
|
+
const t = await r.executeCommand(
|
|
53
|
+
"exportCutImage",
|
|
54
|
+
e
|
|
55
|
+
);
|
|
56
|
+
return t || console.warn("[PooderEditor] generateCutImage returned null", {
|
|
57
|
+
options: e,
|
|
58
|
+
imageCount: (s.get("image.items") || []).length,
|
|
59
|
+
hasCanvasService: !!o.getService("CanvasService")
|
|
60
|
+
}), t;
|
|
61
|
+
} catch (t) {
|
|
62
|
+
throw console.error("[PooderEditor] generateCutImage failed", t), t;
|
|
63
|
+
}
|
|
64
|
+
}, N = async (e, t) => await r.executeCommand("upsertImage", e, {
|
|
51
65
|
id: t?.id,
|
|
52
66
|
mode: t?.mode,
|
|
53
67
|
createIfMissing: t?.createIfMissing,
|
|
54
68
|
addOptions: t?.addOptions,
|
|
55
69
|
fitOnAdd: t?.fitOnAdd
|
|
56
|
-
}), F = async (e, t) => (await
|
|
70
|
+
}), F = async (e, t) => (await N(e, {
|
|
57
71
|
mode: "add",
|
|
58
72
|
addOptions: t,
|
|
59
73
|
fitOnAdd: !0
|
|
60
|
-
})).id, R = async (e, t) => await
|
|
74
|
+
})).id, R = async (e, t) => await r.executeCommand("updateImage", e, t), z = async () => await r.executeCommand("clearImages"), D = (e) => Math.max(-1, Math.min(2, e)), X = (e) => {
|
|
61
75
|
const t = e?.cutRect;
|
|
62
76
|
if (!t) return null;
|
|
63
|
-
const n = Number(t.width), a = Number(t.height), i = Number(t.left),
|
|
64
|
-
return !Number.isFinite(n) || !Number.isFinite(a) || !Number.isFinite(i) || !Number.isFinite(
|
|
77
|
+
const n = Number(t.width), a = Number(t.height), i = Number(t.left), c = Number(t.top);
|
|
78
|
+
return !Number.isFinite(n) || !Number.isFinite(a) || !Number.isFinite(i) || !Number.isFinite(c) || n <= 0 || a <= 0 ? null : { left: i, top: c, width: n, height: a };
|
|
65
79
|
}, y = (e) => {
|
|
66
80
|
if (!e) return [];
|
|
67
81
|
const t = e.canvas.getObjects(), n = [];
|
|
@@ -69,7 +83,7 @@ const se = /* @__PURE__ */ T({
|
|
|
69
83
|
if (a?.data?.layerId !== me) continue;
|
|
70
84
|
const i = a?.data?.id;
|
|
71
85
|
if (typeof i != "string") continue;
|
|
72
|
-
const
|
|
86
|
+
const c = a.getCenterPoint ? a.getCenterPoint() : null, d = Number(c?.x ?? a.left), m = Number(c?.y ?? a.top), f = Number(a.scaleX), g = Number(a.width), l = Number(a.height);
|
|
73
87
|
!Number.isFinite(d) || !Number.isFinite(m) || !Number.isFinite(f) || !Number.isFinite(g) || !Number.isFinite(l) || g <= 0 || l <= 0 || n.push({
|
|
74
88
|
id: i,
|
|
75
89
|
centerX: d,
|
|
@@ -81,24 +95,24 @@ const se = /* @__PURE__ */ T({
|
|
|
81
95
|
}
|
|
82
96
|
return n;
|
|
83
97
|
}, _ = (e) => {
|
|
84
|
-
|
|
98
|
+
s.update("dieline.shape", "custom"), s.update("dieline.pathData", e.pathData), s.update("size.cutMode", "trim"), s.update("size.cutMarginMm", 0);
|
|
85
99
|
}, Y = (e, t) => {
|
|
86
100
|
const n = e.rawBounds || e.baseBounds, a = Number(e.imageWidth ?? 0), i = Number(e.imageHeight ?? 0);
|
|
87
101
|
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
102
|
return { shiftX: 0, shiftY: 0 };
|
|
89
|
-
const
|
|
103
|
+
const c = 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
104
|
return {
|
|
91
|
-
shiftX: (m - g) *
|
|
105
|
+
shiftX: (m - g) * c,
|
|
92
106
|
shiftY: (f - l) * d
|
|
93
107
|
};
|
|
94
|
-
},
|
|
108
|
+
}, I = async (e, t, n = !1) => {
|
|
95
109
|
if (!t.length) return;
|
|
96
|
-
const a = await
|
|
110
|
+
const a = await r.executeCommand("getSceneLayout"), i = X(a);
|
|
97
111
|
if (!i) return;
|
|
98
|
-
const { shiftX:
|
|
112
|
+
const { shiftX: c, shiftY: d } = Y(e, i);
|
|
99
113
|
n && console.info("[PooderEditor] detectDieline alignment", {
|
|
100
114
|
frame: i,
|
|
101
|
-
shiftX:
|
|
115
|
+
shiftX: c,
|
|
102
116
|
shiftY: d,
|
|
103
117
|
snapshotCount: t.length,
|
|
104
118
|
baseBounds: e.baseBounds,
|
|
@@ -110,29 +124,29 @@ const se = /* @__PURE__ */ T({
|
|
|
110
124
|
const f = Math.max(
|
|
111
125
|
i.width / Math.max(1, m.sourceWidth),
|
|
112
126
|
i.height / Math.max(1, m.sourceHeight)
|
|
113
|
-
), g = Math.max(0.05, m.objectScale / f), l = m.centerX -
|
|
127
|
+
), g = Math.max(0.05, m.objectScale / f), l = m.centerX - c, P = m.centerY - d, H = D(
|
|
114
128
|
(l - i.left) / Math.max(1, i.width)
|
|
115
129
|
), L = D(
|
|
116
|
-
(
|
|
130
|
+
(P - i.top) / Math.max(1, i.height)
|
|
117
131
|
);
|
|
118
|
-
await
|
|
132
|
+
await r.executeCommand("updateImage", m.id, {
|
|
119
133
|
scale: g,
|
|
120
|
-
left:
|
|
134
|
+
left: H,
|
|
121
135
|
top: L
|
|
122
136
|
});
|
|
123
137
|
}
|
|
124
138
|
};
|
|
125
139
|
v({
|
|
126
|
-
importConfig:
|
|
127
|
-
exportConfig:
|
|
128
|
-
getImages:
|
|
140
|
+
importConfig: b,
|
|
141
|
+
exportConfig: S,
|
|
142
|
+
getImages: x,
|
|
129
143
|
generateCutImage: A,
|
|
130
144
|
addImage: F,
|
|
131
|
-
upsertImage:
|
|
145
|
+
upsertImage: N,
|
|
132
146
|
updateImage: R,
|
|
133
147
|
clearImages: z,
|
|
134
148
|
detectDieline: async (e) => {
|
|
135
|
-
const t =
|
|
149
|
+
const t = o.getService("CanvasService"), n = y(t), a = await r.executeCommand("detectEdge", e, {
|
|
136
150
|
expand: 10,
|
|
137
151
|
// 安全距离(像素)
|
|
138
152
|
smoothing: !0,
|
|
@@ -142,63 +156,63 @@ const se = /* @__PURE__ */ T({
|
|
|
142
156
|
});
|
|
143
157
|
if (a) {
|
|
144
158
|
_(a);
|
|
145
|
-
const
|
|
146
|
-
if (
|
|
159
|
+
const c = (s.get("image.items") || []).find((d) => d.url === e);
|
|
160
|
+
if (c?.id) {
|
|
147
161
|
const d = n.filter(
|
|
148
|
-
(m) => m.id ===
|
|
162
|
+
(m) => m.id === c.id
|
|
149
163
|
);
|
|
150
|
-
await
|
|
164
|
+
await I(a, d);
|
|
151
165
|
}
|
|
152
166
|
return a.pathData;
|
|
153
167
|
}
|
|
154
168
|
return null;
|
|
155
169
|
},
|
|
156
170
|
detectDielineFromFrame: async (e) => {
|
|
157
|
-
const t = e?.detect?.debug === !0, n =
|
|
171
|
+
const t = e?.detect?.debug === !0, n = o.getService("CanvasService"), a = y(n), { url: i } = await r.executeCommand("exportImageFrameUrl", {
|
|
158
172
|
multiplier: 2,
|
|
159
173
|
format: "png"
|
|
160
174
|
});
|
|
161
175
|
try {
|
|
162
|
-
const
|
|
176
|
+
const c = await r.executeCommand("detectEdge", i, {
|
|
163
177
|
expand: e?.detect?.expand ?? 30,
|
|
164
178
|
smoothing: e?.detect?.smoothing ?? !0,
|
|
165
179
|
simplifyTolerance: e?.detect?.simplifyTolerance ?? 2,
|
|
166
180
|
debug: t
|
|
167
181
|
});
|
|
168
|
-
return
|
|
182
|
+
return c ? (e?.commit === !1 || (_(c), await I(c, a, t)), c) : null;
|
|
169
183
|
} finally {
|
|
170
184
|
i && URL.revokeObjectURL(i);
|
|
171
185
|
}
|
|
172
186
|
},
|
|
173
187
|
uploadAndDetectEdge: async (e, t) => {
|
|
174
|
-
const n =
|
|
188
|
+
const n = o.getService("CanvasService"), a = await F(e), i = y(n).filter(
|
|
175
189
|
(d) => d.id === a
|
|
176
|
-
),
|
|
190
|
+
), c = await r.executeCommand("detectEdge", e, {
|
|
177
191
|
expand: t?.expand ?? 10,
|
|
178
192
|
smoothing: t?.smoothing ?? !0,
|
|
179
193
|
simplifyTolerance: t?.simplifyTolerance ?? 2
|
|
180
194
|
});
|
|
181
|
-
return
|
|
195
|
+
return c ? (_(c), await I(c, i), { imageId: a, url: e, pathData: c.pathData }) : null;
|
|
182
196
|
},
|
|
183
197
|
activateTool: async (e) => await h.switchTool(e),
|
|
184
198
|
deactivateTool: async () => await h.deactivate(),
|
|
185
|
-
on: (e, t) =>
|
|
186
|
-
off: (e, t) =>
|
|
187
|
-
emit: (e, t) =>
|
|
188
|
-
executeCommand: (e, ...t) =>
|
|
189
|
-
getConfig: (e) =>
|
|
190
|
-
updateConfig: (e, t) =>
|
|
199
|
+
on: (e, t) => o.eventBus.on(e, t),
|
|
200
|
+
off: (e, t) => o.eventBus.off(e, t),
|
|
201
|
+
emit: (e, t) => o.eventBus.emit(e, t),
|
|
202
|
+
executeCommand: (e, ...t) => r.executeCommand(e, ...t),
|
|
203
|
+
getConfig: (e) => s.get(e),
|
|
204
|
+
updateConfig: (e, t) => s.update(e, t),
|
|
191
205
|
services: {
|
|
192
206
|
workbench: h,
|
|
193
|
-
command:
|
|
194
|
-
config:
|
|
207
|
+
command: r,
|
|
208
|
+
config: s
|
|
195
209
|
}
|
|
196
210
|
});
|
|
197
211
|
const W = (e) => {
|
|
198
212
|
const t = new q(e, {
|
|
199
|
-
eventBus:
|
|
213
|
+
eventBus: o.eventBus
|
|
200
214
|
});
|
|
201
|
-
|
|
215
|
+
o.registerService(t, "CanvasService"), [
|
|
202
216
|
new K(),
|
|
203
217
|
new Q(),
|
|
204
218
|
new Z(),
|
|
@@ -211,23 +225,23 @@ const se = /* @__PURE__ */ T({
|
|
|
211
225
|
new oe(),
|
|
212
226
|
new ce()
|
|
213
227
|
].forEach((a) => {
|
|
214
|
-
|
|
228
|
+
o.extensionManager.register(a);
|
|
215
229
|
});
|
|
216
230
|
}, j = (e, t) => {
|
|
217
|
-
const n =
|
|
231
|
+
const n = o.getService("CanvasService");
|
|
218
232
|
n && n.resize(e, t);
|
|
219
233
|
};
|
|
220
|
-
return
|
|
221
|
-
const e =
|
|
222
|
-
e && e.dispose(),
|
|
223
|
-
}), (e, t) => (O(),
|
|
224
|
-
J(
|
|
234
|
+
return E(() => {
|
|
235
|
+
const e = o.getService("CanvasService");
|
|
236
|
+
e && e.dispose(), C.dispose(), o.extensionManager.destroy();
|
|
237
|
+
}), (e, t) => (O(), B("div", de, [
|
|
238
|
+
J(se, {
|
|
225
239
|
onCanvasReady: W,
|
|
226
240
|
onResize: j
|
|
227
241
|
})
|
|
228
242
|
]));
|
|
229
243
|
}
|
|
230
|
-
}), we = /* @__PURE__ */ k(ue, [["__scopeId", "data-v-
|
|
244
|
+
}), we = /* @__PURE__ */ k(ue, [["__scopeId", "data-v-234847f9"]]);
|
|
231
245
|
export {
|
|
232
246
|
we as PooderEditor
|
|
233
247
|
};
|
package/dist/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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
|
|
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 P=s.defineComponent({__name:"CanvasArea",emits:["canvas-ready","resize"],setup(m,{emit:y}){const h=y,i=s.ref(null),c=s.ref(null);let d=null;return s.onMounted(()=>{if(i.value&&c.value){const{clientWidth:b,clientHeight:C}=i.value;c.value.width=b,c.value.height=C,h("canvas-ready",c.value),d=new ResizeObserver(x=>{for(const _ of x){const{width:I,height:N}=_.contentRect;h("resize",I,N)}}),d.observe(i.value)}}),s.onUnmounted(()=>{d&&d.disconnect()}),(b,C)=>(s.openBlock(),s.createElementBlock("div",{ref_key:"container",ref:i,class:"pooder-canvas-area"},[s.createElementVNode("canvas",{ref_key:"canvas",ref:c},null,512)],512))}}),E=(m,y)=>{const h=m.__vccOpts||m;for(const[i,c]of y)h[i]=c;return h},j=E(P,[["__scopeId","data-v-dc60e8d6"]]),A={class:"pooder-editor"},R="image.user",z=E(s.defineComponent({__name:"PooderEditor",emits:["image-change"],setup(m,{expose:y,emit:h}){const i=new S.Pooder;s.provide("pooder",i);const c=i.getService("CommandService"),d=i.getService("ConfigurationService"),b=i.getService("WorkbenchService"),C=h,x=d.onAnyChange(e=>{e.key==="image.items"&&C("image-change",e.value)}),_=e=>{d.import(e)},I=()=>d.export(),N=()=>d.get("image.items",[]),X=async e=>{try{const t=await c.executeCommand("exportCutImage",e);return t||console.warn("[PooderEditor] generateCutImage returned null",{options:e,imageCount:(d.get("image.items")||[]).length,hasCanvasService:!!i.getService("CanvasService")}),t}catch(t){throw console.error("[PooderEditor] generateCutImage failed",t),t}},T=async(e,t)=>await c.executeCommand("upsertImage",e,{id:t?.id,mode:t?.mode,createIfMissing:t?.createIfMissing,addOptions:t?.addOptions,fitOnAdd:t?.fitOnAdd}),M=async(e,t)=>(await T(e,{mode:"add",addOptions:t,fitOnAdd:!0})).id,Y=async(e,t)=>await c.executeCommand("updateImage",e,t),W=async()=>await c.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),a=Number(t.left),r=Number(t.top);return!Number.isFinite(n)||!Number.isFinite(o)||!Number.isFinite(a)||!Number.isFinite(r)||n<=0||o<=0?null:{left:a,top:r,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 a=o?.data?.id;if(typeof a!="string")continue;const r=o.getCenterPoint?o.getCenterPoint():null,l=Number(r?.x??o.left),f=Number(r?.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:a,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),a=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||a<=0)return{shiftX:0,shiftY:0};const r=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=a/2;return{shiftX:(f-p)*r,shiftY:(w-v)*l}},D=async(e,t,n=!1)=>{if(!t.length)return;const o=await c.executeCommand("getSceneLayout"),a=H(o);if(!a)return;const{shiftX:r,shiftY:l}=L(e,a);n&&console.info("[PooderEditor] detectDieline alignment",{frame:a,shiftX:r,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(a.width/Math.max(1,f.sourceWidth),a.height/Math.max(1,f.sourceHeight)),p=Math.max(.05,f.objectScale/w),v=f.centerX-r,q=f.centerY-l,G=B((v-a.left)/Math.max(1,a.width)),J=B((q-a.top)/Math.max(1,a.height));await c.executeCommand("updateImage",f.id,{scale:p,left:G,top:J})}};y({importConfig:_,exportConfig:I,getImages:N,generateCutImage:X,addImage:M,upsertImage:T,updateImage:Y,clearImages:W,detectDieline:async e=>{const t=i.getService("CanvasService"),n=F(t),o=await c.executeCommand("detectEdge",e,{expand:10,smoothing:!0,simplifyTolerance:2});if(o){O(o);const r=(d.get("image.items")||[]).find(l=>l.url===e);if(r?.id){const l=n.filter(f=>f.id===r.id);await D(o,l)}return o.pathData}return null},detectDielineFromFrame:async e=>{const t=e?.detect?.debug===!0,n=i.getService("CanvasService"),o=F(n),{url:a}=await c.executeCommand("exportImageFrameUrl",{multiplier:2,format:"png"});try{const r=await c.executeCommand("detectEdge",a,{expand:e?.detect?.expand??30,smoothing:e?.detect?.smoothing??!0,simplifyTolerance:e?.detect?.simplifyTolerance??2,debug:t});return r?(e?.commit===!1||(O(r),await D(r,o,t)),r):null}finally{a&&URL.revokeObjectURL(a)}},uploadAndDetectEdge:async(e,t)=>{const n=i.getService("CanvasService"),o=await M(e),a=F(n).filter(l=>l.id===o),r=await c.executeCommand("detectEdge",e,{expand:t?.expand??10,smoothing:t?.smoothing??!0,simplifyTolerance:t?.simplifyTolerance??2});return r?(O(r),await D(r,a),{imageId:o,url:e,pathData:r.pathData}):null},activateTool:async e=>await b.switchTool(e),deactivateTool:async()=>await b.deactivate(),on:(e,t)=>i.eventBus.on(e,t),off:(e,t)=>i.eventBus.off(e,t),emit:(e,t)=>i.eventBus.emit(e,t),executeCommand:(e,...t)=>c.executeCommand(e,...t),getConfig:e=>d.get(e),updateConfig:(e,t)=>d.update(e,t),services:{workbench:b,command:c,config:d}});const U=e=>{const t=new g.CanvasService(e,{eventBus:i.eventBus});i.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=>{i.extensionManager.register(o)})},V=(e,t)=>{const n=i.getService("CanvasService");n&&n.resize(e,t)};return s.onUnmounted(()=>{const e=i.getService("CanvasService");e&&e.dispose(),x.dispose(),i.extensionManager.destroy()}),(e,t)=>(s.openBlock(),s.createElementBlock("div",A,[s.createVNode(j,{onCanvasReady:U,onResize:V})]))}}),[["__scopeId","data-v-234847f9"]]);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"})}));
|
|
@@ -16,7 +16,9 @@ declare const _default: import('vue').DefineComponent<{}, {
|
|
|
16
16
|
importConfig: (config: Record<string, any>) => void;
|
|
17
17
|
exportConfig: () => Record<string, any>;
|
|
18
18
|
getImages: () => never[];
|
|
19
|
-
generateCutImage: (
|
|
19
|
+
generateCutImage: (options?: {
|
|
20
|
+
debug?: boolean;
|
|
21
|
+
}) => Promise<string | null>;
|
|
20
22
|
addImage: (url: string, options?: any) => Promise<any>;
|
|
21
23
|
upsertImage: (url: string, options?: {
|
|
22
24
|
id?: string;
|
package/dist/vue.css
CHANGED
|
@@ -1 +1 @@
|
|
|
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-
|
|
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-234847f9]{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.2.
|
|
3
|
+
"version": "4.2.2",
|
|
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/
|
|
23
|
-
"@pooder/
|
|
22
|
+
"@pooder/kit": "5.0.2",
|
|
23
|
+
"@pooder/core": "2.1.0"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"vue": "^3.0.0"
|