@mce/psd 0.28.1 → 0.29.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.js +5 -7
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { definePlugin } from "mce";
|
|
1
|
+
import { definePlugin, matchSource } from "mce";
|
|
2
2
|
//#region src/convert.ts
|
|
3
3
|
async function psdToFrame(psd, resolveImage, name) {
|
|
4
4
|
const children = [];
|
|
@@ -46,7 +46,6 @@ async function psdToFrame(psd, resolveImage, name) {
|
|
|
46
46
|
}
|
|
47
47
|
//#endregion
|
|
48
48
|
//#region src/plugin.ts
|
|
49
|
-
var PSD_RE = /\.psd$/i;
|
|
50
49
|
function canvasToBlob(canvas) {
|
|
51
50
|
return new Promise((resolve, reject) => {
|
|
52
51
|
canvas.toBlob((blob) => blob ? resolve(blob) : reject(/* @__PURE__ */ new Error("PSD layer canvas.toBlob failed")), "image/png");
|
|
@@ -64,11 +63,10 @@ function plugin() {
|
|
|
64
63
|
loaders: [{
|
|
65
64
|
name: "psd",
|
|
66
65
|
accept: ".psd",
|
|
67
|
-
test: (
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
},
|
|
66
|
+
test: matchSource({
|
|
67
|
+
ext: /\.psd$/i,
|
|
68
|
+
mime: ["image/vnd.adobe.photoshop", "application/x-photoshop"]
|
|
69
|
+
}),
|
|
72
70
|
load: async (source) => {
|
|
73
71
|
const { readPsd } = await import("ag-psd");
|
|
74
72
|
const frame = await psdToFrame(readPsd(await source.arrayBuffer(), { useImageData: false }), async (canvas, layer) => upload(new File([await canvasToBlob(canvas)], `${layer.name || "layer"}.png`, { type: "image/png" })), source.name);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mce/psd",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.29.0",
|
|
5
5
|
"description": "PSD (Photoshop) import plugin for mce",
|
|
6
6
|
"author": "wxm",
|
|
7
7
|
"license": "MIT",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"ag-psd": "^30.2.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"mce": "0.
|
|
53
|
+
"mce": "0.29.0"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"mce": "^0"
|