@pooder/vue 3.2.0 → 3.3.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 +83 -62
- package/dist/index.umd.js +1 -1
- package/dist/vue/src/PooderEditor.vue.d.ts +6 -1
- package/dist/vue.css +1 -1
- package/package.json +2 -2
package/dist/index.es.js
CHANGED
|
@@ -1,87 +1,108 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { Pooder as
|
|
1
|
+
import { defineComponent as C, ref as _, onMounted as b, onUnmounted as w, createElementBlock as x, openBlock as I, createElementVNode as H, provide as M, createVNode as B } from "vue";
|
|
2
|
+
import { Pooder as D } from "@pooder/core";
|
|
3
3
|
export * from "@pooder/core";
|
|
4
|
-
import { CanvasService as
|
|
4
|
+
import { CanvasService as P, BackgroundTool as W, ImageTool as N, MirrorTool as V, DielineTool as G, RulerTool as U, HoleTool as $ } from "@pooder/kit";
|
|
5
5
|
export * from "@pooder/kit";
|
|
6
|
-
const
|
|
6
|
+
const j = /* @__PURE__ */ C({
|
|
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(d, { emit: m }) {
|
|
10
|
+
const s = m, e = _(null), a = _(null);
|
|
11
|
+
let n = null;
|
|
12
|
+
return b(() => {
|
|
13
|
+
if (e.value && a.value) {
|
|
14
|
+
const { clientWidth: v, clientHeight: g } = e.value;
|
|
15
|
+
a.value.width = v, a.value.height = g, s("canvas-ready", a.value), n = new ResizeObserver((l) => {
|
|
16
|
+
for (const f of l) {
|
|
17
|
+
const { width: u, height: p } = f.contentRect;
|
|
18
|
+
s("resize", u, p);
|
|
19
19
|
}
|
|
20
|
-
}),
|
|
20
|
+
}), n.observe(e.value);
|
|
21
21
|
}
|
|
22
|
-
}),
|
|
23
|
-
|
|
24
|
-
}), (
|
|
22
|
+
}), w(() => {
|
|
23
|
+
n && n.disconnect();
|
|
24
|
+
}), (v, g) => (I(), x("div", {
|
|
25
25
|
ref_key: "container",
|
|
26
|
-
ref:
|
|
26
|
+
ref: e,
|
|
27
27
|
class: "pooder-canvas-area"
|
|
28
28
|
}, [
|
|
29
|
-
|
|
29
|
+
H("canvas", {
|
|
30
30
|
ref_key: "canvas",
|
|
31
|
-
ref:
|
|
31
|
+
ref: a
|
|
32
32
|
}, null, 512)
|
|
33
33
|
], 512));
|
|
34
34
|
}
|
|
35
|
-
}),
|
|
36
|
-
const
|
|
37
|
-
for (const [
|
|
38
|
-
e
|
|
39
|
-
return
|
|
40
|
-
},
|
|
35
|
+
}), S = (d, m) => {
|
|
36
|
+
const s = d.__vccOpts || d;
|
|
37
|
+
for (const [e, a] of m)
|
|
38
|
+
s[e] = a;
|
|
39
|
+
return s;
|
|
40
|
+
}, q = /* @__PURE__ */ S(j, [["__scopeId", "data-v-dc60e8d6"]]), F = { class: "pooder-editor" }, J = /* @__PURE__ */ C({
|
|
41
41
|
__name: "PooderEditor",
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
42
|
+
emits: ["image-change"],
|
|
43
|
+
setup(d, { expose: m, emit: s }) {
|
|
44
|
+
const e = new D();
|
|
45
|
+
M("pooder", e);
|
|
46
|
+
const a = e.getService("CommandService"), n = e.getService("ConfigurationService"), v = s, g = n.onAnyChange((t) => {
|
|
47
|
+
t.key === "image.items" && v("image-change", t.value);
|
|
48
|
+
});
|
|
49
|
+
m({
|
|
50
|
+
importConfig: (t) => {
|
|
51
|
+
n.import(t);
|
|
52
|
+
},
|
|
53
|
+
exportConfig: () => n.export(),
|
|
54
|
+
getImages: () => n.get("image.items", []),
|
|
55
|
+
generateCutImage: async () => await a.executeCommand("exportCutImage"),
|
|
56
|
+
addImage: async (t, o) => {
|
|
57
|
+
const r = await a.executeCommand("addImage", t, o), c = await a.executeCommand("getGeometry"), i = e.getService("CanvasService");
|
|
58
|
+
if (c && i) {
|
|
59
|
+
const k = i.canvas.width, O = i.canvas.height, h = (n.get("dieline.offset") || 0) * c.scale, z = c.width + 2 * h, A = c.height + 2 * h, E = c.x / k, R = c.y / O;
|
|
60
|
+
await a.executeCommand("fitImageToArea", r, {
|
|
61
|
+
width: z,
|
|
62
|
+
height: A,
|
|
63
|
+
left: E,
|
|
64
|
+
top: R
|
|
65
|
+
});
|
|
66
|
+
} else i && await a.executeCommand("fitImageToArea", r, {
|
|
67
|
+
width: i.canvas.width,
|
|
68
|
+
height: i.canvas.height,
|
|
69
|
+
left: 0.5,
|
|
70
|
+
top: 0.5
|
|
71
|
+
});
|
|
72
|
+
return r;
|
|
49
73
|
},
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
addImage: async (o, a) => await n.executeCommand("addImage", o, a),
|
|
53
|
-
updateImage: async (o, a) => await n.executeCommand("updateImage", o, a),
|
|
54
|
-
clearImages: async () => await n.executeCommand("clearImages")
|
|
74
|
+
updateImage: async (t, o) => await a.executeCommand("updateImage", t, o),
|
|
75
|
+
clearImages: async () => await a.executeCommand("clearImages")
|
|
55
76
|
});
|
|
56
|
-
const
|
|
57
|
-
const
|
|
58
|
-
e.registerService(
|
|
59
|
-
new
|
|
60
|
-
new
|
|
77
|
+
const y = (t) => {
|
|
78
|
+
const o = new P(t);
|
|
79
|
+
e.registerService(o, "CanvasService"), [
|
|
80
|
+
new W(),
|
|
81
|
+
new N(),
|
|
61
82
|
// new FilmTool(),
|
|
62
83
|
// new WhiteInkTool(),
|
|
63
|
-
new
|
|
64
|
-
new
|
|
65
|
-
new
|
|
66
|
-
new
|
|
67
|
-
].forEach((
|
|
68
|
-
e.extensionManager.register(
|
|
84
|
+
new V(),
|
|
85
|
+
new G(),
|
|
86
|
+
new U(),
|
|
87
|
+
new $()
|
|
88
|
+
].forEach((c) => {
|
|
89
|
+
e.extensionManager.register(c);
|
|
69
90
|
});
|
|
70
|
-
},
|
|
71
|
-
const
|
|
72
|
-
|
|
91
|
+
}, T = (t, o) => {
|
|
92
|
+
const r = e.getService("CanvasService");
|
|
93
|
+
r && r.canvas.setDimensions({ width: t, height: o });
|
|
73
94
|
};
|
|
74
|
-
return
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
}), (
|
|
78
|
-
|
|
79
|
-
onCanvasReady:
|
|
80
|
-
onResize:
|
|
95
|
+
return w(() => {
|
|
96
|
+
const t = e.getService("CanvasService");
|
|
97
|
+
t && t.dispose(), g.dispose(), e.extensionManager.destroy();
|
|
98
|
+
}), (t, o) => (I(), x("div", F, [
|
|
99
|
+
B(q, {
|
|
100
|
+
onCanvasReady: y,
|
|
101
|
+
onResize: T
|
|
81
102
|
})
|
|
82
103
|
]));
|
|
83
104
|
}
|
|
84
|
-
}),
|
|
105
|
+
}), te = /* @__PURE__ */ S(J, [["__scopeId", "data-v-56106d22"]]);
|
|
85
106
|
export {
|
|
86
|
-
|
|
107
|
+
te as PooderEditor
|
|
87
108
|
};
|
package/dist/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(c,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("@pooder/core"),require("@pooder/kit")):typeof define=="function"&&define.amd?define(["exports","vue","@pooder/core","@pooder/kit"],e):(c=typeof globalThis<"u"?globalThis:c||self,e(c.PooderVue={},c.Vue,c.PooderCore,c.PooderKit))})(this,(function(c,e,p,s){"use strict";const I=e.defineComponent({__name:"CanvasArea",emits:["canvas-ready","resize"],setup(a,{emit:l}){const m=l,t=e.ref(null),o=e.ref(null);let r=null;return e.onMounted(()=>{if(t.value&&o.value){const{clientWidth:u,clientHeight:v}=t.value;o.value.width=u,o.value.height=v,m("canvas-ready",o.value),r=new ResizeObserver(_=>{for(const y of _){const{width:C,height:w}=y.contentRect;m("resize",C,w)}}),r.observe(t.value)}}),e.onUnmounted(()=>{r&&r.disconnect()}),(u,v)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"container",ref:t,class:"pooder-canvas-area"},[e.createElementVNode("canvas",{ref_key:"canvas",ref:o},null,512)],512))}}),h=(a,l)=>{const m=a.__vccOpts||a;for(const[t,o]of l)m[t]=o;return m},x=h(I,[["__scopeId","data-v-dc60e8d6"]]),O={class:"pooder-editor"},b=h(e.defineComponent({__name:"PooderEditor",emits:["image-change"],setup(a,{expose:l,emit:m}){const t=new p.Pooder;e.provide("pooder",t);const o=t.getService("CommandService"),r=t.getService("ConfigurationService"),u=m,v=r.onAnyChange(n=>{n.key==="image.items"&&u("image-change",n.value)});l({importConfig:n=>{r.import(n)},exportConfig:()=>r.export(),getImages:()=>r.get("image.items",[]),generateCutImage:async()=>await o.executeCommand("exportCutImage"),addImage:async(n,i)=>{const f=await o.executeCommand("addImage",n,i),d=await o.executeCommand("getGeometry"),g=t.getService("CanvasService");if(d&&g){const E=g.canvas.width,j=g.canvas.height,S=(r.get("dieline.offset")||0)*d.scale,z=d.width+2*S,A=d.height+2*S,B=d.x/E,M=d.y/j;await o.executeCommand("fitImageToArea",f,{width:z,height:A,left:B,top:M})}else g&&await o.executeCommand("fitImageToArea",f,{width:g.canvas.width,height:g.canvas.height,left:.5,top:.5});return f},updateImage:async(n,i)=>await o.executeCommand("updateImage",n,i),clearImages:async()=>await o.executeCommand("clearImages")});const P=n=>{const i=new s.CanvasService(n);t.registerService(i,"CanvasService"),[new s.BackgroundTool,new s.ImageTool,new s.MirrorTool,new s.DielineTool,new s.RulerTool,new s.HoleTool].forEach(d=>{t.extensionManager.register(d)})},T=(n,i)=>{const f=t.getService("CanvasService");f&&f.canvas.setDimensions({width:n,height:i})};return e.onUnmounted(()=>{const n=t.getService("CanvasService");n&&n.dispose(),v.dispose(),t.extensionManager.destroy()}),(n,i)=>(e.openBlock(),e.createElementBlock("div",O,[e.createVNode(x,{onCanvasReady:P,onResize:T})]))}}),[["__scopeId","data-v-56106d22"]]);c.PooderEditor=b,Object.keys(p).forEach(a=>{a!=="default"&&!Object.prototype.hasOwnProperty.call(c,a)&&Object.defineProperty(c,a,{enumerable:!0,get:()=>p[a]})}),Object.keys(s).forEach(a=>{a!=="default"&&!Object.prototype.hasOwnProperty.call(c,a)&&Object.defineProperty(c,a,{enumerable:!0,get:()=>s[a]})}),Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})}));
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
declare const _default: import('vue').DefineComponent<{}, {
|
|
2
2
|
importConfig: (config: Record<string, any>) => void;
|
|
3
3
|
exportConfig: () => Record<string, any>;
|
|
4
|
+
getImages: () => never[];
|
|
4
5
|
generateCutImage: () => Promise<any>;
|
|
5
6
|
addImage: (url: string, options?: any) => Promise<any>;
|
|
6
7
|
updateImage: (id: string, options?: any) => Promise<any>;
|
|
7
8
|
clearImages: () => Promise<any>;
|
|
8
|
-
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}
|
|
9
|
+
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
10
|
+
"image-change": (images: any[]) => any;
|
|
11
|
+
}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{
|
|
12
|
+
"onImage-change"?: ((images: any[]) => any) | undefined;
|
|
13
|
+
}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, HTMLDivElement>;
|
|
9
14
|
export default _default;
|
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-56106d22]{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": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"main": "./dist/index.umd.js",
|
|
5
5
|
"module": "./dist/index.es.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"access": "public"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@pooder/kit": "3.
|
|
22
|
+
"@pooder/kit": "3.4.0",
|
|
23
23
|
"@pooder/core": "1.2.0"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|