Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
psd-parse-web
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
劳工
psd-parse-web
Commits
b26e948e
Commit
b26e948e
authored
Jul 03, 2020
by
任建锋
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
--
parent
ef98d1a8
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
7 additions
and
7 deletions
+7
-7
index.es.js
dist/index.es.js
+1
-1
index.es.js.map
dist/index.es.js.map
+1
-1
index.js
dist/index.js
+1
-1
index.js.map
dist/index.js.map
+1
-1
index.umd.js
dist/index.umd.js
+1
-1
index.umd.js.map
dist/index.umd.js.map
+1
-1
psd-tree.js
src/psd-tree.js
+1
-1
No files found.
dist/index.es.js
View file @
b26e948e
...
...
@@ -25,7 +25,7 @@ function walk(psNode, dataNode) {
const
x
=
left
-
pLeft
;
const
y
=
top
-
pTop
;
Object
.
assign
(
dataNode
,
{
x
,
y
,
width
,
height
,
alpha
:
opacity
/
255
,
visible
,
name
,
origin
:
psNode
,
label
:
`
${
name
}
> [
${
x
}
,
${
y
}
,
${
width
}
,
${
height
}
]`
});
Object
.
assign
(
dataNode
,
{
x
,
y
,
width
,
height
,
opacity
:
opacity
/
255
,
visible
,
name
,
origin
:
psNode
,
label
:
`
${
name
}
> [
${
x
}
,
${
y
}
,
${
width
}
,
${
height
}
]`
});
if
(
psNode
.
children
()
&&
psNode
.
children
().
length
>
0
){
dataNode
.
children
=
[];
}
...
...
dist/index.es.js.map
View file @
b26e948e
{
"version"
:
3
,
"file"
:
"index.es.js"
,
"sources"
:
[
"../src/psd-tree.js"
,
"../src/utils.js"
,
"../src/zeroing.js"
],
"sourcesContent"
:
[
"/**
\n
* Created by rockyl on 2019-08-09.
\n
*/
\n\n
const PSD = window['require']('psd');
\n\n
export async function getTree(file) {\n
\t
let psd = await PSD.fromDroppedFile(file);
\n\n\t
const root = {};
\n\t
walk(psd.tree(), root);
\n\n\t
return root;
\n
}
\n\n
function walk(psNode, dataNode) {\n
\t
const {left: pLeft = 0, top: pTop = 0,} = psNode.parent || {};
\n\t
const {left, top, width, height, name, layer: {opacity, visible}} = psNode;
\n\t
const x = left - pLeft;
\n\t
const y = top - pTop;
\n\n\t
Object.assign(dataNode, {x, y, width, height, alpha: opacity / 255, visible, name, origin: psNode, label: `${name} > [${x}, ${y}, ${width}, ${height}]`});
\n\t
if (psNode.children() && psNode.children().length > 0){\n
\t\t
dataNode.children = [];
\n\t
}
\n\n\t
let children = psNode.children();
\n\t
for (let i = children.length - 1; i >= 0; i--) {\n
\t\t
const childPsNode = children[i];
\n\n\t\t
const childDataNode = {};
\n\t\t
dataNode.children.push(childDataNode);
\n\t\t
walk(childPsNode, childDataNode)
\n\t
}
\n
}
\n
"
,
"/**
\n
* Created by rockyl on 2019-08-10.
\n
*/
\n\n
export async function walkNode(node, callback, includeSelf = false) {\n
\t
if (includeSelf) {\n
\t\t
await callback(node, null);
\n\t
}
\n\t
if (node.children && node.children.length > 0) {\n
\t\t
for (let childNode of node.children) {\n
\t\t\t
await callback(childNode, node);
\n\t\t\t
const result = await walkNode(childNode, callback);
\n\t\t\t
if (result === true)
{
\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n
}
\n\n
export async function walkObject(obj, callback) {\n
\t
if(typeof obj ===
\"
object
\"
){\n
\t\t
for (let key of Object.keys(obj)) {\n
\t\t\t
const value = obj[key];
\n\t\t\t
await callback(key, value, obj);
\n\t\t\t
const result = await walkObject(value, callback);
\n\t\t\t
if (result === true)
{
\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n
}
\n
"
,
"/**
\n
* Created by renjianfeng on 2020-06-11.
\n
*
\n
* 导出spark的视图
\n
*/
\n\n
import
{
getTree
}
from
\"
./psd-tree
\"
;
\n
import
{
walkNode
}
from
\"
./utils
\"
;
\n
import path from 'path'
\n
import Color from 'color'
\n
import generateUUID from 'uuid/v4'
\n
import hash from 'object-hash';
\n
import zlib from 'zlib';
\n\n
const relativePosPrefixMap = {\n
\t
l: {field: 'left',},
\n\t
t: {field: 'top',},
\n\t
r: {field: 'right',},
\n\t
b: {field: 'bottom',},
\n\t
h: {field: 'horizonCenter',},
\n\t
v: {field: 'verticalCenter',},
\n\t
wp: {field: 'width', },
\n\t
hp: {field: 'height', },
\n\t
lp: {field: 'left', },
\n\t
tp: {field: 'top', },
\n\t
rp: {field: 'right', },
\n\t
bp: {field: 'bottom', },
\n
};
\n\n
export async function execute(psdFile, options) {\n
\t
const tree = await getTree(psdFile);
\n\t
const offset = options ? options.offset : {x: 0, y: 0};
\n\n\t
let viewRoot = {\n
\t\t
name: path.basename(psdFile.name, '.psd'),
\n\t\t
componentName : 'Div',
\n\t\t
uuid: generateUUID(),
\n\t
};
\n\n\t
const assets = [];
\n\t
const imageHashMap = {};
\n\n\t
let {width: stageWidth, height: stageHeight} = tree;
\n\t
stageWidth -= offset.x || 0;
\n\t
stageHeight -= offset.y || 0;
\n\n\t
await walkNode(tree, async function (node, parent) {\n
\t\t
let
{
name
}
= node;
\n\t\t
const {x, y, width, height, opacity, display, origin: {layer, layer: {typeTool, solidColor}}} = node;
\n\t\t
//console.log('walk node:', name);
\n\t\t
let properties = {\n
\t\t\t
style:{\n
\t\t\t\t
width, height, opacity,display ,
\n\t\t\t
},
\n\t\t\t
attrs:
{
\n\n\t\t\t},\n\t\t\tclassName:\"\"\n\t\t
}
;
\n\t\t
const isSecondLayer = !parent.origin.parent;
\n\n\t\t
if (name.includes('|')) {\n
\t\t\t
try {\n
\t\t\t\t
let arr = name.split('|');
\n\t\t\t\t
name = arr[0];
\n\t\t\t\t
let paramsStr = arr[1];
\n\t\t\t\t
let params = paramsStr.split(';');
\n\t\t\t\t
let relativePos = params[0];
\n\t\t\t\t
if (relativePos) {\n
\t\t\t\t\t
let items = relativePos.split(',');
\n\t\t\t\t\t
for (let item of items) {\n
\t\t\t\t\t\t
let result = item.match(/[a-zA-Z]+/);
\n\t\t\t\t\t\t
if(!result)
{
\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t
}
\n\t\t\t\t\t\t
let prefix = result[0];
\n\t\t\t\t\t\t
let mapItem = relativePosPrefixMap[prefix];
\n\t\t\t\t\t\t
if (mapItem) {\n
\t\t\t\t\t\t\t
let
{
field,
}
= mapItem;
\n\t\t\t\t\t\t\t
let value = item.substr(prefix.length);
\n\t\t\t\t\t\t\t
let hasValue = value.length > 0;
\n\t\t\t\t\t\t\t
let fieldChar = prefix[0];
\n\t\t\t\t\t\t\t
if(!hasValue){\n
\t\t\t\t\t\t\t\t
switch(fieldChar){\n
\t\t\t\t\t\t\t\t\t
case 'l':
\n\t\t\t\t\t\t\t\t\t\t
value = x - offset.x;
\n\t\t\t\t\t\t\t\t\t\t
break;
\n\t\t\t\t\t\t\t\t\t
case 't':
\n\t\t\t\t\t\t\t\t\t\t
value = y - offset.y;
\n\t\t\t\t\t\t\t\t\t\t
break;
\n\t\t\t\t\t\t\t\t\t
case 'r':
\n\t\t\t\t\t\t\t\t\t\t
value = stageWidth - width;
\n\t\t\t\t\t\t\t\t\t\t
break;
\n\t\t\t\t\t\t\t\t\t
case 'b':
\n\t\t\t\t\t\t\t\t\t\t
value = stageHeight - height;
\n\t\t\t\t\t\t\t\t\t\t
break;
\n\t\t\t\t\t\t\t\t\t
case 'h':
\n\t\t\t\t\t\t\t\t\t\t
value = x + width / 2 - stageWidth / 2;
\n\t\t\t\t\t\t\t\t\t\t
break;
\n\t\t\t\t\t\t\t\t\t
case 'v':
\n\t\t\t\t\t\t\t\t\t\t
value = y + height / 2 - stageHeight / 2;
\n\t\t\t\t\t\t\t\t\t\t
break;
\n\t\t\t\t\t\t\t\t
}
\n\t\t\t\t\t\t\t
}
\n\t\t\t\t\t\t\t
let isPercent = prefix.endsWith('p');
\n\t\t\t\t\t\t\t
if (isPercent) {\n
\t\t\t\t\t\t\t\t
if(!hasValue){\n
\t\t\t\t\t\t\t\t\t
switch(fieldChar){\n
\t\t\t\t\t\t\t\t\t\t
case 'l':
\n\t\t\t\t\t\t\t\t\t\t
case 'r':
\n\t\t\t\t\t\t\t\t\t\t\t
value /= stageWidth;
\n\t\t\t\t\t\t\t\t\t\t\t
break;
\n\t\t\t\t\t\t\t\t\t\t
case 't':
\n\t\t\t\t\t\t\t\t\t\t
case 'b':
\n\t\t\t\t\t\t\t\t\t\t\t
value /= stageHeight;
\n\t\t\t\t\t\t\t\t\t\t\t
break;
\n\t\t\t\t\t\t\t\t\t
}
\n\t\t\t\t\t\t\t\t\t
value = Math.floor(value * 100);
\n\t\t\t\t\t\t\t\t
}
\n\t\t\t\t\t\t\t\t
value += '%';
\n\t\t\t\t\t\t\t
} else {\n
\t\t\t\t\t\t\t\t
value = parseFloat(value);
\n\t\t\t\t\t\t\t\t
if (isNaN(value)) {\n
\t\t\t\t\t\t\t\t\t
value = 0;
\n\t\t\t\t\t\t\t\t
}
\n\t\t\t\t\t\t\t
}
\n\t\t\t\t\t\t\t
console.log(properties)
\n\t\t\t\t\t\t\t
properties.style[field] = value;
\n\t\t\t\t\t\t
}
\n\t\t\t\t\t
}
\n\t\t\t\t
}
\n\t\t\t
}catch (e)
{
\n\t\t\t\tconsole.log(e);\n\t\t\t}\n\t\t
}
\n\n\t\t
let viewNode = {\n
\t\t\t
name,
\n\t\t\t
properties,
\n\t\t\t
uuid: generateUUID(),
\n\t\t
};
\n\t\t
let dealLater = true;
\n\t\t
if (x !== 0) {\n
\t\t\t
console.log(properties)
\n\t\t\t
if(!properties.style.left){\n
\t\t\t\t
properties.style.left = x - (isSecondLayer ? offset.x : 0);
\n\t\t\t
}
\n\t\t\t\n\t\t
}
\n\t\t
if (y !== 0) {\n
\t\t\t
if(!properties.style.top){\n
\t\t\t\t
properties.style.top = y - (isSecondLayer ? offset.y : 0);
\n\t\t\t
}
\n\t\t
}
\n\t\t
properties.style.position=
\"
absolute
\"\n\t\t
viewNode.rect={\n
\t\t\t
x: properties.style.left?properties.style.left:0,
\n\t\t\t
y: properties.style.top?properties.style.top:0,
\n\t\t\t
width: properties.style.width,
\n\t\t\t
height: properties.style.height
\n\t\t
}
\n\n\t\t
if (typeTool) {\n
\t\t\t
let fontInfo = typeTool();
\n\t\t\t
properties.attrs.text = fontInfo.textValue;
\n\t\t\t
const sizes = fontInfo.sizes();
\n\t\t\t
const colors = fontInfo.colors();
\n\t\t\t
properties.style.fontSize = sizes ? sizes[0] || 20 : 20;
\n\t\t\t
let [r, g, b, a] = colors[0];
\n\t\t\t
console.log(
\"
color
\"
,[r, g, b, a])
\n\t\t\t
properties.style.color = `rgba(${r}, ${g}, ${b}, ${a / 255})`;
\n\t\t\t
viewNode.componentName = 'Label';
\n\t\t\t
dealLater = false;
\n\t\t
} else if (solidColor && layer.vectorMask) {\n
\t\t\t
let paths = layer.vectorMask().paths;
\n\t\t\t
if (paths[2].numPoints === 4) {\n
\t\t\t\t
let isRect = true;
\n\t\t\t\t
for (let i = 3; i < paths.length; i++) {\n
\t\t\t\t\t
if (paths[i].recordType !== 2) {\n
\t\t\t\t\t\t
isRect = false;
\n\t\t\t\t\t\t
break;
\n\t\t\t\t\t
}
\n\t\t\t\t
}
\n\t\t\t\t
if (isRect) {\n
\t\t\t\t\t
viewNode.componentName = 'Div';
\n\t\t\t\t\t
const {r, g, b} = solidColor();
\n\t\t\t\t\t
properties.style.backgroundColor = `rgba(${r}, ${g}, ${b}, 1)`;
\n\t\t\t\t\t
dealLater = false;
\n\t\t\t\t
}
\n\t\t\t
}
\n\t\t
}
\n\n\t\t
if (dealLater) {\n
\t\t\t
if (node.hasOwnProperty('children')) {\n
\t\t\t\t
viewNode.componentName = 'Div';
\n\t\t\t
} else {\n
\t\t\t\t
viewNode.componentName = 'Image';
\n\n\t\t\t\t
let uuid = generateUUID();
\n\t\t\t\t
const ext = '.png';
\n\n\t\t\t\t
let dataUrl;
\n\t\t\t\t
try {\n
\t\t\t\t\t
let img = node.origin.toPng();
\n\t\t\t\t\t
dataUrl = img.src;
\n\t\t\t\t
} catch (e)
{
\n\n\t\t\t\t
}
\n\n\t\t\t\t
if (dataUrl) {\n
\t\t\t\t\t
let base64Data = dataUrl.replace(/^data:image
\\
/
\\
w+;base64,/,
\"\"
);
\n\t\t\t\t\t
let buffer = new Buffer(base64Data, 'base64');
\n\t\t\t\t\t
const fileNameHash = hash(buffer);
\n\t\t\t\t\t
if (imageHashMap.hasOwnProperty(fileNameHash)) {\n
\t\t\t\t\t\t
uuid = imageHashMap[fileNameHash];
\n\t\t\t\t\t
} else {\n
\t\t\t\t\t\t
imageHashMap[fileNameHash] = uuid;
\n\t\t\t\t\t\t
assets.push({\n
\t\t\t\t\t\t\t
name,
\n\t\t\t\t\t\t\t
ext,
\n\t\t\t\t\t\t\t
uuid,
\n\t\t\t\t\t\t\t
base64Data,
\n\t\t\t\t\t\t\t
hash: fileNameHash,
\n\t\t\t\t\t\t
});
\n\t\t\t\t\t
}
\n\n\t\t\t\t\t
properties.attrs.source = 'asset://' + uuid;
\n\t\t\t\t
}
\n\t\t\t
}
\n\t\t
}
\n\n\t\t
let viewParent = parent.view || viewRoot;
\n\t\t
if (!viewParent.hasOwnProperty('children')) {\n
\t\t\t
viewParent.children = [];
\n\t\t
}
\n\t\t
viewParent.children.push(viewNode);
\n\n\t\t
node.view = viewNode;
\n\t
});
\n
console.log(psdFile)
\n\t
let data = {\n
\t\t
pluginVersion:
\"
0.0.1
\"
,
\n\t\t
reference:
\"
psd
\"
,
\n\t\t
fileName:psdFile.name,
\n\t\t
assets,
\n\t\t
view: viewRoot,
\n\t
};
\n\n\t
let dataString = JSON.stringify(data);
\n\n\t
let buf = new Buffer(dataString);
\n\t
return await new Promise((resolve, reject) => {\n
\t\t
zlib.gzip(buf, function (err, res) {\n
\t\t\t
if (err)
{
\n\t\t\t\treject(err);\n\t\t\t
}
else
{
\n\t\t\t\tconsole.log(res.length);\n\t\t\t\tresolve(res);\n\t\t\t}\n\t\t});\n\t})\n}\n"],"names":[],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA,MAAM,GAAG,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,CAAC;AACrC;AACO,eAAe,OAAO,CAAC,IAAI,EAAE;AACpC,CAAC,IAAI,GAAG,GAAG,MAAM,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;AAC3C;AACA,CAAC,MAAM,IAAI,GAAG,EAAE,CAAC;AACjB,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,IAAI,CAAC,CAAC;AACxB;AACA,CAAC,OAAO,IAAI,CAAC;AACb,CAAC;AACD;AACA,SAAS,IAAI,CAAC,MAAM,EAAE,QAAQ,EAAE;AAChC,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,GAAG,CAAC,EAAE,GAAG,EAAE,IAAI,GAAG,CAAC,EAAE,GAAG,MAAM,CAAC,MAAM,IAAI,EAAE,CAAC;AAC/D,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,GAAG,MAAM,CAAC;AAC5E,CAAC,MAAM,CAAC,GAAG,IAAI,GAAG,KAAK,CAAC;AACxB,CAAC,MAAM,CAAC,GAAG,GAAG,GAAG,IAAI,CAAC;AACtB;AACA,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,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AACvC;AACA,CAAC,IAAI,GAAG,GAAG,IAAI,MAAM,CAAC,UAAU,CAAC,CAAC;AAClC,CAAC,OAAO,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK;AAC/C,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,UAAU,GAAG,EAAE,GAAG,EAAE;AACrC,GAAG,IAAI,GAAG,EAAE;AACZ,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC;AAChB,IAAI,MAAM;AACV,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AAC5B,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC;AACjB,IAAI;AACJ,GAAG,CAAC,CAAC;AACL,EAAE,CAAC;AACH;;;;"
}
\ No newline at end of file
{
"version"
:
3
,
"file"
:
"index.es.js"
,
"sources"
:
[
"../src/psd-tree.js"
,
"../src/utils.js"
,
"../src/zeroing.js"
],
"sourcesContent"
:
[
"/**
\n
* Created by rockyl on 2019-08-09.
\n
*/
\n\n
const PSD = window['require']('psd');
\n\n
export async function getTree(file) {\n
\t
let psd = await PSD.fromDroppedFile(file);
\n\n\t
const root = {};
\n\t
walk(psd.tree(), root);
\n\n\t
return root;
\n
}
\n\n
function walk(psNode, dataNode) {\n
\t
const {left: pLeft = 0, top: pTop = 0,} = psNode.parent || {};
\n\t
const {left, top, width, height, name, layer: {opacity, visible}} = psNode;
\n\t
const x = left - pLeft;
\n\t
const y = top - pTop;
\n\n\t
Object.assign(dataNode, {x, y, width, height, opacity: opacity / 255, visible, name, origin: psNode, label: `${name} > [${x}, ${y}, ${width}, ${height}]`});
\n\t
if (psNode.children() && psNode.children().length > 0){\n
\t\t
dataNode.children = [];
\n\t
}
\n\n\t
let children = psNode.children();
\n\t
for (let i = children.length - 1; i >= 0; i--) {\n
\t\t
const childPsNode = children[i];
\n\n\t\t
const childDataNode = {};
\n\t\t
dataNode.children.push(childDataNode);
\n\t\t
walk(childPsNode, childDataNode)
\n\t
}
\n
}
\n
"
,
"/**
\n
* Created by rockyl on 2019-08-10.
\n
*/
\n\n
export async function walkNode(node, callback, includeSelf = false) {\n
\t
if (includeSelf) {\n
\t\t
await callback(node, null);
\n\t
}
\n\t
if (node.children && node.children.length > 0) {\n
\t\t
for (let childNode of node.children) {\n
\t\t\t
await callback(childNode, node);
\n\t\t\t
const result = await walkNode(childNode, callback);
\n\t\t\t
if (result === true)
{
\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n
}
\n\n
export async function walkObject(obj, callback) {\n
\t
if(typeof obj ===
\"
object
\"
){\n
\t\t
for (let key of Object.keys(obj)) {\n
\t\t\t
const value = obj[key];
\n\t\t\t
await callback(key, value, obj);
\n\t\t\t
const result = await walkObject(value, callback);
\n\t\t\t
if (result === true)
{
\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n
}
\n
"
,
"/**
\n
* Created by renjianfeng on 2020-06-11.
\n
*
\n
* 导出spark的视图
\n
*/
\n\n
import
{
getTree
}
from
\"
./psd-tree
\"
;
\n
import
{
walkNode
}
from
\"
./utils
\"
;
\n
import path from 'path'
\n
import Color from 'color'
\n
import generateUUID from 'uuid/v4'
\n
import hash from 'object-hash';
\n
import zlib from 'zlib';
\n\n
const relativePosPrefixMap = {\n
\t
l: {field: 'left',},
\n\t
t: {field: 'top',},
\n\t
r: {field: 'right',},
\n\t
b: {field: 'bottom',},
\n\t
h: {field: 'horizonCenter',},
\n\t
v: {field: 'verticalCenter',},
\n\t
wp: {field: 'width', },
\n\t
hp: {field: 'height', },
\n\t
lp: {field: 'left', },
\n\t
tp: {field: 'top', },
\n\t
rp: {field: 'right', },
\n\t
bp: {field: 'bottom', },
\n
};
\n\n
export async function execute(psdFile, options) {\n
\t
const tree = await getTree(psdFile);
\n\t
const offset = options ? options.offset : {x: 0, y: 0};
\n\n\t
let viewRoot = {\n
\t\t
name: path.basename(psdFile.name, '.psd'),
\n\t\t
componentName : 'Div',
\n\t\t
uuid: generateUUID(),
\n\t
};
\n\n\t
const assets = [];
\n\t
const imageHashMap = {};
\n\n\t
let {width: stageWidth, height: stageHeight} = tree;
\n\t
stageWidth -= offset.x || 0;
\n\t
stageHeight -= offset.y || 0;
\n\n\t
await walkNode(tree, async function (node, parent) {\n
\t\t
let
{
name
}
= node;
\n\t\t
const {x, y, width, height, opacity, display, origin: {layer, layer: {typeTool, solidColor}}} = node;
\n\t\t
//console.log('walk node:', name);
\n\t\t
let properties = {\n
\t\t\t
style:{\n
\t\t\t\t
width, height, opacity,display ,
\n\t\t\t
},
\n\t\t\t
attrs:
{
\n\n\t\t\t},\n\t\t\tclassName:\"\"\n\t\t
}
;
\n\t\t
const isSecondLayer = !parent.origin.parent;
\n\n\t\t
if (name.includes('|')) {\n
\t\t\t
try {\n
\t\t\t\t
let arr = name.split('|');
\n\t\t\t\t
name = arr[0];
\n\t\t\t\t
let paramsStr = arr[1];
\n\t\t\t\t
let params = paramsStr.split(';');
\n\t\t\t\t
let relativePos = params[0];
\n\t\t\t\t
if (relativePos) {\n
\t\t\t\t\t
let items = relativePos.split(',');
\n\t\t\t\t\t
for (let item of items) {\n
\t\t\t\t\t\t
let result = item.match(/[a-zA-Z]+/);
\n\t\t\t\t\t\t
if(!result)
{
\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t
}
\n\t\t\t\t\t\t
let prefix = result[0];
\n\t\t\t\t\t\t
let mapItem = relativePosPrefixMap[prefix];
\n\t\t\t\t\t\t
if (mapItem) {\n
\t\t\t\t\t\t\t
let
{
field,
}
= mapItem;
\n\t\t\t\t\t\t\t
let value = item.substr(prefix.length);
\n\t\t\t\t\t\t\t
let hasValue = value.length > 0;
\n\t\t\t\t\t\t\t
let fieldChar = prefix[0];
\n\t\t\t\t\t\t\t
if(!hasValue){\n
\t\t\t\t\t\t\t\t
switch(fieldChar){\n
\t\t\t\t\t\t\t\t\t
case 'l':
\n\t\t\t\t\t\t\t\t\t\t
value = x - offset.x;
\n\t\t\t\t\t\t\t\t\t\t
break;
\n\t\t\t\t\t\t\t\t\t
case 't':
\n\t\t\t\t\t\t\t\t\t\t
value = y - offset.y;
\n\t\t\t\t\t\t\t\t\t\t
break;
\n\t\t\t\t\t\t\t\t\t
case 'r':
\n\t\t\t\t\t\t\t\t\t\t
value = stageWidth - width;
\n\t\t\t\t\t\t\t\t\t\t
break;
\n\t\t\t\t\t\t\t\t\t
case 'b':
\n\t\t\t\t\t\t\t\t\t\t
value = stageHeight - height;
\n\t\t\t\t\t\t\t\t\t\t
break;
\n\t\t\t\t\t\t\t\t\t
case 'h':
\n\t\t\t\t\t\t\t\t\t\t
value = x + width / 2 - stageWidth / 2;
\n\t\t\t\t\t\t\t\t\t\t
break;
\n\t\t\t\t\t\t\t\t\t
case 'v':
\n\t\t\t\t\t\t\t\t\t\t
value = y + height / 2 - stageHeight / 2;
\n\t\t\t\t\t\t\t\t\t\t
break;
\n\t\t\t\t\t\t\t\t
}
\n\t\t\t\t\t\t\t
}
\n\t\t\t\t\t\t\t
let isPercent = prefix.endsWith('p');
\n\t\t\t\t\t\t\t
if (isPercent) {\n
\t\t\t\t\t\t\t\t
if(!hasValue){\n
\t\t\t\t\t\t\t\t\t
switch(fieldChar){\n
\t\t\t\t\t\t\t\t\t\t
case 'l':
\n\t\t\t\t\t\t\t\t\t\t
case 'r':
\n\t\t\t\t\t\t\t\t\t\t\t
value /= stageWidth;
\n\t\t\t\t\t\t\t\t\t\t\t
break;
\n\t\t\t\t\t\t\t\t\t\t
case 't':
\n\t\t\t\t\t\t\t\t\t\t
case 'b':
\n\t\t\t\t\t\t\t\t\t\t\t
value /= stageHeight;
\n\t\t\t\t\t\t\t\t\t\t\t
break;
\n\t\t\t\t\t\t\t\t\t
}
\n\t\t\t\t\t\t\t\t\t
value = Math.floor(value * 100);
\n\t\t\t\t\t\t\t\t
}
\n\t\t\t\t\t\t\t\t
value += '%';
\n\t\t\t\t\t\t\t
} else {\n
\t\t\t\t\t\t\t\t
value = parseFloat(value);
\n\t\t\t\t\t\t\t\t
if (isNaN(value)) {\n
\t\t\t\t\t\t\t\t\t
value = 0;
\n\t\t\t\t\t\t\t\t
}
\n\t\t\t\t\t\t\t
}
\n\t\t\t\t\t\t\t
console.log(properties)
\n\t\t\t\t\t\t\t
properties.style[field] = value;
\n\t\t\t\t\t\t
}
\n\t\t\t\t\t
}
\n\t\t\t\t
}
\n\t\t\t
}catch (e)
{
\n\t\t\t\tconsole.log(e);\n\t\t\t}\n\t\t
}
\n\n\t\t
let viewNode = {\n
\t\t\t
name,
\n\t\t\t
properties,
\n\t\t\t
uuid: generateUUID(),
\n\t\t
};
\n\t\t
let dealLater = true;
\n\t\t
if (x !== 0) {\n
\t\t\t
console.log(properties)
\n\t\t\t
if(!properties.style.left){\n
\t\t\t\t
properties.style.left = x - (isSecondLayer ? offset.x : 0);
\n\t\t\t
}
\n\t\t\t\n\t\t
}
\n\t\t
if (y !== 0) {\n
\t\t\t
if(!properties.style.top){\n
\t\t\t\t
properties.style.top = y - (isSecondLayer ? offset.y : 0);
\n\t\t\t
}
\n\t\t
}
\n\t\t
properties.style.position=
\"
absolute
\"\n\t\t
viewNode.rect={\n
\t\t\t
x: properties.style.left?properties.style.left:0,
\n\t\t\t
y: properties.style.top?properties.style.top:0,
\n\t\t\t
width: properties.style.width,
\n\t\t\t
height: properties.style.height
\n\t\t
}
\n\n\t\t
if (typeTool) {\n
\t\t\t
let fontInfo = typeTool();
\n\t\t\t
properties.attrs.text = fontInfo.textValue;
\n\t\t\t
const sizes = fontInfo.sizes();
\n\t\t\t
const colors = fontInfo.colors();
\n\t\t\t
properties.style.fontSize = sizes ? sizes[0] || 20 : 20;
\n\t\t\t
let [r, g, b, a] = colors[0];
\n\t\t\t
console.log(
\"
color
\"
,[r, g, b, a])
\n\t\t\t
properties.style.color = `rgba(${r}, ${g}, ${b}, ${a / 255})`;
\n\t\t\t
viewNode.componentName = 'Label';
\n\t\t\t
dealLater = false;
\n\t\t
} else if (solidColor && layer.vectorMask) {\n
\t\t\t
let paths = layer.vectorMask().paths;
\n\t\t\t
if (paths[2].numPoints === 4) {\n
\t\t\t\t
let isRect = true;
\n\t\t\t\t
for (let i = 3; i < paths.length; i++) {\n
\t\t\t\t\t
if (paths[i].recordType !== 2) {\n
\t\t\t\t\t\t
isRect = false;
\n\t\t\t\t\t\t
break;
\n\t\t\t\t\t
}
\n\t\t\t\t
}
\n\t\t\t\t
if (isRect) {\n
\t\t\t\t\t
viewNode.componentName = 'Div';
\n\t\t\t\t\t
const {r, g, b} = solidColor();
\n\t\t\t\t\t
properties.style.backgroundColor = `rgba(${r}, ${g}, ${b}, 1)`;
\n\t\t\t\t\t
dealLater = false;
\n\t\t\t\t
}
\n\t\t\t
}
\n\t\t
}
\n\n\t\t
if (dealLater) {\n
\t\t\t
if (node.hasOwnProperty('children')) {\n
\t\t\t\t
viewNode.componentName = 'Div';
\n\t\t\t
} else {\n
\t\t\t\t
viewNode.componentName = 'Image';
\n\n\t\t\t\t
let uuid = generateUUID();
\n\t\t\t\t
const ext = '.png';
\n\n\t\t\t\t
let dataUrl;
\n\t\t\t\t
try {\n
\t\t\t\t\t
let img = node.origin.toPng();
\n\t\t\t\t\t
dataUrl = img.src;
\n\t\t\t\t
} catch (e)
{
\n\n\t\t\t\t
}
\n\n\t\t\t\t
if (dataUrl) {\n
\t\t\t\t\t
let base64Data = dataUrl.replace(/^data:image
\\
/
\\
w+;base64,/,
\"\"
);
\n\t\t\t\t\t
let buffer = new Buffer(base64Data, 'base64');
\n\t\t\t\t\t
const fileNameHash = hash(buffer);
\n\t\t\t\t\t
if (imageHashMap.hasOwnProperty(fileNameHash)) {\n
\t\t\t\t\t\t
uuid = imageHashMap[fileNameHash];
\n\t\t\t\t\t
} else {\n
\t\t\t\t\t\t
imageHashMap[fileNameHash] = uuid;
\n\t\t\t\t\t\t
assets.push({\n
\t\t\t\t\t\t\t
name,
\n\t\t\t\t\t\t\t
ext,
\n\t\t\t\t\t\t\t
uuid,
\n\t\t\t\t\t\t\t
base64Data,
\n\t\t\t\t\t\t\t
hash: fileNameHash,
\n\t\t\t\t\t\t
});
\n\t\t\t\t\t
}
\n\n\t\t\t\t\t
properties.attrs.source = 'asset://' + uuid;
\n\t\t\t\t
}
\n\t\t\t
}
\n\t\t
}
\n\n\t\t
let viewParent = parent.view || viewRoot;
\n\t\t
if (!viewParent.hasOwnProperty('children')) {\n
\t\t\t
viewParent.children = [];
\n\t\t
}
\n\t\t
viewParent.children.push(viewNode);
\n\n\t\t
node.view = viewNode;
\n\t
});
\n
console.log(psdFile)
\n\t
let data = {\n
\t\t
pluginVersion:
\"
0.0.1
\"
,
\n\t\t
reference:
\"
psd
\"
,
\n\t\t
fileName:psdFile.name,
\n\t\t
assets,
\n\t\t
view: viewRoot,
\n\t
};
\n\n\t
let dataString = JSON.stringify(data);
\n\n\t
let buf = new Buffer(dataString);
\n\t
return await new Promise((resolve, reject) => {\n
\t\t
zlib.gzip(buf, function (err, res) {\n
\t\t\t
if (err)
{
\n\t\t\t\treject(err);\n\t\t\t
}
else
{
\n\t\t\t\tconsole.log(res.length);\n\t\t\t\tresolve(res);\n\t\t\t}\n\t\t});\n\t})\n}\n"],"names":[],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA,MAAM,GAAG,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,CAAC;AACrC;AACO,eAAe,OAAO,CAAC,IAAI,EAAE;AACpC,CAAC,IAAI,GAAG,GAAG,MAAM,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;AAC3C;AACA,CAAC,MAAM,IAAI,GAAG,EAAE,CAAC;AACjB,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,IAAI,CAAC,CAAC;AACxB;AACA,CAAC,OAAO,IAAI,CAAC;AACb,CAAC;AACD;AACA,SAAS,IAAI,CAAC,MAAM,EAAE,QAAQ,EAAE;AAChC,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,GAAG,CAAC,EAAE,GAAG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,QAAQ,GAAG,EAAE,CAAC;AAC5B,GAAG;AACH,EAAE,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AACrC;AACA,EAAE,IAAI,CAAC,IAAI,GAAG,QAAQ,CAAC;AACvB,EAAE,CAAC,CAAC;AACJ,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,EAAC;AACxB,CAAC,IAAI,IAAI,GAAG;AACZ,EAAE,aAAa,CAAC,OAAO;AACvB,EAAE,SAAS,CAAC,KAAK;AACjB,EAAE,QAAQ,CAAC,OAAO,CAAC,IAAI;AACvB,EAAE,MAAM;AACR,EAAE,IAAI,EAAE,QAAQ;AAChB,EAAE,CAAC;AACH;AACA,CAAC,IAAI,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;AACvC;AACA,CAAC,IAAI,GAAG,GAAG,IAAI,MAAM,CAAC,UAAU,CAAC,CAAC;AAClC,CAAC,OAAO,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK;AAC/C,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,UAAU,GAAG,EAAE,GAAG,EAAE;AACrC,GAAG,IAAI,GAAG,EAAE;AACZ,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC;AAChB,IAAI,MAAM;AACV,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AAC5B,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC;AACjB,IAAI;AACJ,GAAG,CAAC,CAAC;AACL,EAAE,CAAC;AACH;;;;"
}
\ No newline at end of file
dist/index.js
View file @
b26e948e
...
...
@@ -31,7 +31,7 @@ function walk(psNode, dataNode) {
const
x
=
left
-
pLeft
;
const
y
=
top
-
pTop
;
Object
.
assign
(
dataNode
,
{
x
,
y
,
width
,
height
,
alpha
:
opacity
/
255
,
visible
,
name
,
origin
:
psNode
,
label
:
`
${
name
}
> [
${
x
}
,
${
y
}
,
${
width
}
,
${
height
}
]`
});
Object
.
assign
(
dataNode
,
{
x
,
y
,
width
,
height
,
opacity
:
opacity
/
255
,
visible
,
name
,
origin
:
psNode
,
label
:
`
${
name
}
> [
${
x
}
,
${
y
}
,
${
width
}
,
${
height
}
]`
});
if
(
psNode
.
children
()
&&
psNode
.
children
().
length
>
0
){
dataNode
.
children
=
[];
}
...
...
dist/index.js.map
View file @
b26e948e
{
"version"
:
3
,
"file"
:
"index.js"
,
"sources"
:
[
"../src/psd-tree.js"
,
"../src/utils.js"
,
"../src/zeroing.js"
],
"sourcesContent"
:
[
"/**
\n
* Created by rockyl on 2019-08-09.
\n
*/
\n\n
const PSD = window['require']('psd');
\n\n
export async function getTree(file) {\n
\t
let psd = await PSD.fromDroppedFile(file);
\n\n\t
const root = {};
\n\t
walk(psd.tree(), root);
\n\n\t
return root;
\n
}
\n\n
function walk(psNode, dataNode) {\n
\t
const {left: pLeft = 0, top: pTop = 0,} = psNode.parent || {};
\n\t
const {left, top, width, height, name, layer: {opacity, visible}} = psNode;
\n\t
const x = left - pLeft;
\n\t
const y = top - pTop;
\n\n\t
Object.assign(dataNode, {x, y, width, height, alpha: opacity / 255, visible, name, origin: psNode, label: `${name} > [${x}, ${y}, ${width}, ${height}]`});
\n\t
if (psNode.children() && psNode.children().length > 0){\n
\t\t
dataNode.children = [];
\n\t
}
\n\n\t
let children = psNode.children();
\n\t
for (let i = children.length - 1; i >= 0; i--) {\n
\t\t
const childPsNode = children[i];
\n\n\t\t
const childDataNode = {};
\n\t\t
dataNode.children.push(childDataNode);
\n\t\t
walk(childPsNode, childDataNode)
\n\t
}
\n
}
\n
"
,
"/**
\n
* Created by rockyl on 2019-08-10.
\n
*/
\n\n
export async function walkNode(node, callback, includeSelf = false) {\n
\t
if (includeSelf) {\n
\t\t
await callback(node, null);
\n\t
}
\n\t
if (node.children && node.children.length > 0) {\n
\t\t
for (let childNode of node.children) {\n
\t\t\t
await callback(childNode, node);
\n\t\t\t
const result = await walkNode(childNode, callback);
\n\t\t\t
if (result === true)
{
\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n
}
\n\n
export async function walkObject(obj, callback) {\n
\t
if(typeof obj ===
\"
object
\"
){\n
\t\t
for (let key of Object.keys(obj)) {\n
\t\t\t
const value = obj[key];
\n\t\t\t
await callback(key, value, obj);
\n\t\t\t
const result = await walkObject(value, callback);
\n\t\t\t
if (result === true)
{
\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n
}
\n
"
,
"/**
\n
* Created by renjianfeng on 2020-06-11.
\n
*
\n
* 导出spark的视图
\n
*/
\n\n
import
{
getTree
}
from
\"
./psd-tree
\"
;
\n
import
{
walkNode
}
from
\"
./utils
\"
;
\n
import path from 'path'
\n
import Color from 'color'
\n
import generateUUID from 'uuid/v4'
\n
import hash from 'object-hash';
\n
import zlib from 'zlib';
\n\n
const relativePosPrefixMap = {\n
\t
l: {field: 'left',},
\n\t
t: {field: 'top',},
\n\t
r: {field: 'right',},
\n\t
b: {field: 'bottom',},
\n\t
h: {field: 'horizonCenter',},
\n\t
v: {field: 'verticalCenter',},
\n\t
wp: {field: 'width', },
\n\t
hp: {field: 'height', },
\n\t
lp: {field: 'left', },
\n\t
tp: {field: 'top', },
\n\t
rp: {field: 'right', },
\n\t
bp: {field: 'bottom', },
\n
};
\n\n
export async function execute(psdFile, options) {\n
\t
const tree = await getTree(psdFile);
\n\t
const offset = options ? options.offset : {x: 0, y: 0};
\n\n\t
let viewRoot = {\n
\t\t
name: path.basename(psdFile.name, '.psd'),
\n\t\t
componentName : 'Div',
\n\t\t
uuid: generateUUID(),
\n\t
};
\n\n\t
const assets = [];
\n\t
const imageHashMap = {};
\n\n\t
let {width: stageWidth, height: stageHeight} = tree;
\n\t
stageWidth -= offset.x || 0;
\n\t
stageHeight -= offset.y || 0;
\n\n\t
await walkNode(tree, async function (node, parent) {\n
\t\t
let
{
name
}
= node;
\n\t\t
const {x, y, width, height, opacity, display, origin: {layer, layer: {typeTool, solidColor}}} = node;
\n\t\t
//console.log('walk node:', name);
\n\t\t
let properties = {\n
\t\t\t
style:{\n
\t\t\t\t
width, height, opacity,display ,
\n\t\t\t
},
\n\t\t\t
attrs:
{
\n\n\t\t\t},\n\t\t\tclassName:\"\"\n\t\t
}
;
\n\t\t
const isSecondLayer = !parent.origin.parent;
\n\n\t\t
if (name.includes('|')) {\n
\t\t\t
try {\n
\t\t\t\t
let arr = name.split('|');
\n\t\t\t\t
name = arr[0];
\n\t\t\t\t
let paramsStr = arr[1];
\n\t\t\t\t
let params = paramsStr.split(';');
\n\t\t\t\t
let relativePos = params[0];
\n\t\t\t\t
if (relativePos) {\n
\t\t\t\t\t
let items = relativePos.split(',');
\n\t\t\t\t\t
for (let item of items) {\n
\t\t\t\t\t\t
let result = item.match(/[a-zA-Z]+/);
\n\t\t\t\t\t\t
if(!result)
{
\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t
}
\n\t\t\t\t\t\t
let prefix = result[0];
\n\t\t\t\t\t\t
let mapItem = relativePosPrefixMap[prefix];
\n\t\t\t\t\t\t
if (mapItem) {\n
\t\t\t\t\t\t\t
let
{
field,
}
= mapItem;
\n\t\t\t\t\t\t\t
let value = item.substr(prefix.length);
\n\t\t\t\t\t\t\t
let hasValue = value.length > 0;
\n\t\t\t\t\t\t\t
let fieldChar = prefix[0];
\n\t\t\t\t\t\t\t
if(!hasValue){\n
\t\t\t\t\t\t\t\t
switch(fieldChar){\n
\t\t\t\t\t\t\t\t\t
case 'l':
\n\t\t\t\t\t\t\t\t\t\t
value = x - offset.x;
\n\t\t\t\t\t\t\t\t\t\t
break;
\n\t\t\t\t\t\t\t\t\t
case 't':
\n\t\t\t\t\t\t\t\t\t\t
value = y - offset.y;
\n\t\t\t\t\t\t\t\t\t\t
break;
\n\t\t\t\t\t\t\t\t\t
case 'r':
\n\t\t\t\t\t\t\t\t\t\t
value = stageWidth - width;
\n\t\t\t\t\t\t\t\t\t\t
break;
\n\t\t\t\t\t\t\t\t\t
case 'b':
\n\t\t\t\t\t\t\t\t\t\t
value = stageHeight - height;
\n\t\t\t\t\t\t\t\t\t\t
break;
\n\t\t\t\t\t\t\t\t\t
case 'h':
\n\t\t\t\t\t\t\t\t\t\t
value = x + width / 2 - stageWidth / 2;
\n\t\t\t\t\t\t\t\t\t\t
break;
\n\t\t\t\t\t\t\t\t\t
case 'v':
\n\t\t\t\t\t\t\t\t\t\t
value = y + height / 2 - stageHeight / 2;
\n\t\t\t\t\t\t\t\t\t\t
break;
\n\t\t\t\t\t\t\t\t
}
\n\t\t\t\t\t\t\t
}
\n\t\t\t\t\t\t\t
let isPercent = prefix.endsWith('p');
\n\t\t\t\t\t\t\t
if (isPercent) {\n
\t\t\t\t\t\t\t\t
if(!hasValue){\n
\t\t\t\t\t\t\t\t\t
switch(fieldChar){\n
\t\t\t\t\t\t\t\t\t\t
case 'l':
\n\t\t\t\t\t\t\t\t\t\t
case 'r':
\n\t\t\t\t\t\t\t\t\t\t\t
value /= stageWidth;
\n\t\t\t\t\t\t\t\t\t\t\t
break;
\n\t\t\t\t\t\t\t\t\t\t
case 't':
\n\t\t\t\t\t\t\t\t\t\t
case 'b':
\n\t\t\t\t\t\t\t\t\t\t\t
value /= stageHeight;
\n\t\t\t\t\t\t\t\t\t\t\t
break;
\n\t\t\t\t\t\t\t\t\t
}
\n\t\t\t\t\t\t\t\t\t
value = Math.floor(value * 100);
\n\t\t\t\t\t\t\t\t
}
\n\t\t\t\t\t\t\t\t
value += '%';
\n\t\t\t\t\t\t\t
} else {\n
\t\t\t\t\t\t\t\t
value = parseFloat(value);
\n\t\t\t\t\t\t\t\t
if (isNaN(value)) {\n
\t\t\t\t\t\t\t\t\t
value = 0;
\n\t\t\t\t\t\t\t\t
}
\n\t\t\t\t\t\t\t
}
\n\t\t\t\t\t\t\t
console.log(properties)
\n\t\t\t\t\t\t\t
properties.style[field] = value;
\n\t\t\t\t\t\t
}
\n\t\t\t\t\t
}
\n\t\t\t\t
}
\n\t\t\t
}catch (e)
{
\n\t\t\t\tconsole.log(e);\n\t\t\t}\n\t\t
}
\n\n\t\t
let viewNode = {\n
\t\t\t
name,
\n\t\t\t
properties,
\n\t\t\t
uuid: generateUUID(),
\n\t\t
};
\n\t\t
let dealLater = true;
\n\t\t
if (x !== 0) {\n
\t\t\t
console.log(properties)
\n\t\t\t
if(!properties.style.left){\n
\t\t\t\t
properties.style.left = x - (isSecondLayer ? offset.x : 0);
\n\t\t\t
}
\n\t\t\t\n\t\t
}
\n\t\t
if (y !== 0) {\n
\t\t\t
if(!properties.style.top){\n
\t\t\t\t
properties.style.top = y - (isSecondLayer ? offset.y : 0);
\n\t\t\t
}
\n\t\t
}
\n\t\t
properties.style.position=
\"
absolute
\"\n\t\t
viewNode.rect={\n
\t\t\t
x: properties.style.left?properties.style.left:0,
\n\t\t\t
y: properties.style.top?properties.style.top:0,
\n\t\t\t
width: properties.style.width,
\n\t\t\t
height: properties.style.height
\n\t\t
}
\n\n\t\t
if (typeTool) {\n
\t\t\t
let fontInfo = typeTool();
\n\t\t\t
properties.attrs.text = fontInfo.textValue;
\n\t\t\t
const sizes = fontInfo.sizes();
\n\t\t\t
const colors = fontInfo.colors();
\n\t\t\t
properties.style.fontSize = sizes ? sizes[0] || 20 : 20;
\n\t\t\t
let [r, g, b, a] = colors[0];
\n\t\t\t
console.log(
\"
color
\"
,[r, g, b, a])
\n\t\t\t
properties.style.color = `rgba(${r}, ${g}, ${b}, ${a / 255})`;
\n\t\t\t
viewNode.componentName = 'Label';
\n\t\t\t
dealLater = false;
\n\t\t
} else if (solidColor && layer.vectorMask) {\n
\t\t\t
let paths = layer.vectorMask().paths;
\n\t\t\t
if (paths[2].numPoints === 4) {\n
\t\t\t\t
let isRect = true;
\n\t\t\t\t
for (let i = 3; i < paths.length; i++) {\n
\t\t\t\t\t
if (paths[i].recordType !== 2) {\n
\t\t\t\t\t\t
isRect = false;
\n\t\t\t\t\t\t
break;
\n\t\t\t\t\t
}
\n\t\t\t\t
}
\n\t\t\t\t
if (isRect) {\n
\t\t\t\t\t
viewNode.componentName = 'Div';
\n\t\t\t\t\t
const {r, g, b} = solidColor();
\n\t\t\t\t\t
properties.style.backgroundColor = `rgba(${r}, ${g}, ${b}, 1)`;
\n\t\t\t\t\t
dealLater = false;
\n\t\t\t\t
}
\n\t\t\t
}
\n\t\t
}
\n\n\t\t
if (dealLater) {\n
\t\t\t
if (node.hasOwnProperty('children')) {\n
\t\t\t\t
viewNode.componentName = 'Div';
\n\t\t\t
} else {\n
\t\t\t\t
viewNode.componentName = 'Image';
\n\n\t\t\t\t
let uuid = generateUUID();
\n\t\t\t\t
const ext = '.png';
\n\n\t\t\t\t
let dataUrl;
\n\t\t\t\t
try {\n
\t\t\t\t\t
let img = node.origin.toPng();
\n\t\t\t\t\t
dataUrl = img.src;
\n\t\t\t\t
} catch (e)
{
\n\n\t\t\t\t
}
\n\n\t\t\t\t
if (dataUrl) {\n
\t\t\t\t\t
let base64Data = dataUrl.replace(/^data:image
\\
/
\\
w+;base64,/,
\"\"
);
\n\t\t\t\t\t
let buffer = new Buffer(base64Data, 'base64');
\n\t\t\t\t\t
const fileNameHash = hash(buffer);
\n\t\t\t\t\t
if (imageHashMap.hasOwnProperty(fileNameHash)) {\n
\t\t\t\t\t\t
uuid = imageHashMap[fileNameHash];
\n\t\t\t\t\t
} else {\n
\t\t\t\t\t\t
imageHashMap[fileNameHash] = uuid;
\n\t\t\t\t\t\t
assets.push({\n
\t\t\t\t\t\t\t
name,
\n\t\t\t\t\t\t\t
ext,
\n\t\t\t\t\t\t\t
uuid,
\n\t\t\t\t\t\t\t
base64Data,
\n\t\t\t\t\t\t\t
hash: fileNameHash,
\n\t\t\t\t\t\t
});
\n\t\t\t\t\t
}
\n\n\t\t\t\t\t
properties.attrs.source = 'asset://' + uuid;
\n\t\t\t\t
}
\n\t\t\t
}
\n\t\t
}
\n\n\t\t
let viewParent = parent.view || viewRoot;
\n\t\t
if (!viewParent.hasOwnProperty('children')) {\n
\t\t\t
viewParent.children = [];
\n\t\t
}
\n\t\t
viewParent.children.push(viewNode);
\n\n\t\t
node.view = viewNode;
\n\t
});
\n
console.log(psdFile)
\n\t
let data = {\n
\t\t
pluginVersion:
\"
0.0.1
\"
,
\n\t\t
reference:
\"
psd
\"
,
\n\t\t
fileName:psdFile.name,
\n\t\t
assets,
\n\t\t
view: viewRoot,
\n\t
};
\n\n\t
let dataString = JSON.stringify(data);
\n\n\t
let buf = new Buffer(dataString);
\n\t
return await new Promise((resolve, reject) => {\n
\t\t
zlib.gzip(buf, function (err, res) {\n
\t\t\t
if (err)
{
\n\t\t\t\treject(err);\n\t\t\t
}
else
{
\n\t\t\t\tconsole.log(res.length);\n\t\t\t\tresolve(res);\n\t\t\t}\n\t\t});\n\t})\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA,MAAM,GAAG,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,CAAC;AACrC;AACO,eAAe,OAAO,CAAC,IAAI,EAAE;AACpC,CAAC,IAAI,GAAG,GAAG,MAAM,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;AAC3C;AACA,CAAC,MAAM,IAAI,GAAG,EAAE,CAAC;AACjB,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,IAAI,CAAC,CAAC;AACxB;AACA,CAAC,OAAO,IAAI,CAAC;AACb,CAAC;AACD;AACA,SAAS,IAAI,CAAC,MAAM,EAAE,QAAQ,EAAE;AAChC,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,GAAG,CAAC,EAAE,GAAG,EAAE,IAAI,GAAG,CAAC,EAAE,GAAG,MAAM,CAAC,MAAM,IAAI,EAAE,CAAC;AAC/D,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,GAAG,MAAM,CAAC;AAC5E,CAA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xB,CAAC,IAAI,IAAI,GAAG;AACZ,EAAE,aAAa,CAAC,OAAO;AACvB,EAAE,SAAS,CAAC,KAAK;AACjB,EAAE,QAAQ,CAAC,OAAO,CAAC,IAAI;AACvB,EAAE,MAAM;AACR,EAAE,IAAI,EAAE,QAAQ;AAChB,EAAE,CAAC;AACH;AACA,CAAC,IAAI,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;AACvC;AACA,CAAC,IAAI,GAAG,GAAG,IAAI,MAAM,CAAC,UAAU,CAAC,CAAC;AAClC,CAAC,OAAO,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK;AAC/C,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,UAAU,GAAG,EAAE,GAAG,EAAE;AACrC,GAAG,IAAI,GAAG,EAAE;AACZ,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC;AAChB,IAAI,MAAM;AACV,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AAC5B,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC;AACjB,IAAI;AACJ,GAAG,CAAC,CAAC;AACL,EAAE,CAAC;AACH;;;;;"
}
\ No newline at end of file
{
"version"
:
3
,
"file"
:
"index.js"
,
"sources"
:
[
"../src/psd-tree.js"
,
"../src/utils.js"
,
"../src/zeroing.js"
],
"sourcesContent"
:
[
"/**
\n
* Created by rockyl on 2019-08-09.
\n
*/
\n\n
const PSD = window['require']('psd');
\n\n
export async function getTree(file) {\n
\t
let psd = await PSD.fromDroppedFile(file);
\n\n\t
const root = {};
\n\t
walk(psd.tree(), root);
\n\n\t
return root;
\n
}
\n\n
function walk(psNode, dataNode) {\n
\t
const {left: pLeft = 0, top: pTop = 0,} = psNode.parent || {};
\n\t
const {left, top, width, height, name, layer: {opacity, visible}} = psNode;
\n\t
const x = left - pLeft;
\n\t
const y = top - pTop;
\n\n\t
Object.assign(dataNode, {x, y, width, height, opacity: opacity / 255, visible, name, origin: psNode, label: `${name} > [${x}, ${y}, ${width}, ${height}]`});
\n\t
if (psNode.children() && psNode.children().length > 0){\n
\t\t
dataNode.children = [];
\n\t
}
\n\n\t
let children = psNode.children();
\n\t
for (let i = children.length - 1; i >= 0; i--) {\n
\t\t
const childPsNode = children[i];
\n\n\t\t
const childDataNode = {};
\n\t\t
dataNode.children.push(childDataNode);
\n\t\t
walk(childPsNode, childDataNode)
\n\t
}
\n
}
\n
"
,
"/**
\n
* Created by rockyl on 2019-08-10.
\n
*/
\n\n
export async function walkNode(node, callback, includeSelf = false) {\n
\t
if (includeSelf) {\n
\t\t
await callback(node, null);
\n\t
}
\n\t
if (node.children && node.children.length > 0) {\n
\t\t
for (let childNode of node.children) {\n
\t\t\t
await callback(childNode, node);
\n\t\t\t
const result = await walkNode(childNode, callback);
\n\t\t\t
if (result === true)
{
\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n
}
\n\n
export async function walkObject(obj, callback) {\n
\t
if(typeof obj ===
\"
object
\"
){\n
\t\t
for (let key of Object.keys(obj)) {\n
\t\t\t
const value = obj[key];
\n\t\t\t
await callback(key, value, obj);
\n\t\t\t
const result = await walkObject(value, callback);
\n\t\t\t
if (result === true)
{
\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n
}
\n
"
,
"/**
\n
* Created by renjianfeng on 2020-06-11.
\n
*
\n
* 导出spark的视图
\n
*/
\n\n
import
{
getTree
}
from
\"
./psd-tree
\"
;
\n
import
{
walkNode
}
from
\"
./utils
\"
;
\n
import path from 'path'
\n
import Color from 'color'
\n
import generateUUID from 'uuid/v4'
\n
import hash from 'object-hash';
\n
import zlib from 'zlib';
\n\n
const relativePosPrefixMap = {\n
\t
l: {field: 'left',},
\n\t
t: {field: 'top',},
\n\t
r: {field: 'right',},
\n\t
b: {field: 'bottom',},
\n\t
h: {field: 'horizonCenter',},
\n\t
v: {field: 'verticalCenter',},
\n\t
wp: {field: 'width', },
\n\t
hp: {field: 'height', },
\n\t
lp: {field: 'left', },
\n\t
tp: {field: 'top', },
\n\t
rp: {field: 'right', },
\n\t
bp: {field: 'bottom', },
\n
};
\n\n
export async function execute(psdFile, options) {\n
\t
const tree = await getTree(psdFile);
\n\t
const offset = options ? options.offset : {x: 0, y: 0};
\n\n\t
let viewRoot = {\n
\t\t
name: path.basename(psdFile.name, '.psd'),
\n\t\t
componentName : 'Div',
\n\t\t
uuid: generateUUID(),
\n\t
};
\n\n\t
const assets = [];
\n\t
const imageHashMap = {};
\n\n\t
let {width: stageWidth, height: stageHeight} = tree;
\n\t
stageWidth -= offset.x || 0;
\n\t
stageHeight -= offset.y || 0;
\n\n\t
await walkNode(tree, async function (node, parent) {\n
\t\t
let
{
name
}
= node;
\n\t\t
const {x, y, width, height, opacity, display, origin: {layer, layer: {typeTool, solidColor}}} = node;
\n\t\t
//console.log('walk node:', name);
\n\t\t
let properties = {\n
\t\t\t
style:{\n
\t\t\t\t
width, height, opacity,display ,
\n\t\t\t
},
\n\t\t\t
attrs:
{
\n\n\t\t\t},\n\t\t\tclassName:\"\"\n\t\t
}
;
\n\t\t
const isSecondLayer = !parent.origin.parent;
\n\n\t\t
if (name.includes('|')) {\n
\t\t\t
try {\n
\t\t\t\t
let arr = name.split('|');
\n\t\t\t\t
name = arr[0];
\n\t\t\t\t
let paramsStr = arr[1];
\n\t\t\t\t
let params = paramsStr.split(';');
\n\t\t\t\t
let relativePos = params[0];
\n\t\t\t\t
if (relativePos) {\n
\t\t\t\t\t
let items = relativePos.split(',');
\n\t\t\t\t\t
for (let item of items) {\n
\t\t\t\t\t\t
let result = item.match(/[a-zA-Z]+/);
\n\t\t\t\t\t\t
if(!result)
{
\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t
}
\n\t\t\t\t\t\t
let prefix = result[0];
\n\t\t\t\t\t\t
let mapItem = relativePosPrefixMap[prefix];
\n\t\t\t\t\t\t
if (mapItem) {\n
\t\t\t\t\t\t\t
let
{
field,
}
= mapItem;
\n\t\t\t\t\t\t\t
let value = item.substr(prefix.length);
\n\t\t\t\t\t\t\t
let hasValue = value.length > 0;
\n\t\t\t\t\t\t\t
let fieldChar = prefix[0];
\n\t\t\t\t\t\t\t
if(!hasValue){\n
\t\t\t\t\t\t\t\t
switch(fieldChar){\n
\t\t\t\t\t\t\t\t\t
case 'l':
\n\t\t\t\t\t\t\t\t\t\t
value = x - offset.x;
\n\t\t\t\t\t\t\t\t\t\t
break;
\n\t\t\t\t\t\t\t\t\t
case 't':
\n\t\t\t\t\t\t\t\t\t\t
value = y - offset.y;
\n\t\t\t\t\t\t\t\t\t\t
break;
\n\t\t\t\t\t\t\t\t\t
case 'r':
\n\t\t\t\t\t\t\t\t\t\t
value = stageWidth - width;
\n\t\t\t\t\t\t\t\t\t\t
break;
\n\t\t\t\t\t\t\t\t\t
case 'b':
\n\t\t\t\t\t\t\t\t\t\t
value = stageHeight - height;
\n\t\t\t\t\t\t\t\t\t\t
break;
\n\t\t\t\t\t\t\t\t\t
case 'h':
\n\t\t\t\t\t\t\t\t\t\t
value = x + width / 2 - stageWidth / 2;
\n\t\t\t\t\t\t\t\t\t\t
break;
\n\t\t\t\t\t\t\t\t\t
case 'v':
\n\t\t\t\t\t\t\t\t\t\t
value = y + height / 2 - stageHeight / 2;
\n\t\t\t\t\t\t\t\t\t\t
break;
\n\t\t\t\t\t\t\t\t
}
\n\t\t\t\t\t\t\t
}
\n\t\t\t\t\t\t\t
let isPercent = prefix.endsWith('p');
\n\t\t\t\t\t\t\t
if (isPercent) {\n
\t\t\t\t\t\t\t\t
if(!hasValue){\n
\t\t\t\t\t\t\t\t\t
switch(fieldChar){\n
\t\t\t\t\t\t\t\t\t\t
case 'l':
\n\t\t\t\t\t\t\t\t\t\t
case 'r':
\n\t\t\t\t\t\t\t\t\t\t\t
value /= stageWidth;
\n\t\t\t\t\t\t\t\t\t\t\t
break;
\n\t\t\t\t\t\t\t\t\t\t
case 't':
\n\t\t\t\t\t\t\t\t\t\t
case 'b':
\n\t\t\t\t\t\t\t\t\t\t\t
value /= stageHeight;
\n\t\t\t\t\t\t\t\t\t\t\t
break;
\n\t\t\t\t\t\t\t\t\t
}
\n\t\t\t\t\t\t\t\t\t
value = Math.floor(value * 100);
\n\t\t\t\t\t\t\t\t
}
\n\t\t\t\t\t\t\t\t
value += '%';
\n\t\t\t\t\t\t\t
} else {\n
\t\t\t\t\t\t\t\t
value = parseFloat(value);
\n\t\t\t\t\t\t\t\t
if (isNaN(value)) {\n
\t\t\t\t\t\t\t\t\t
value = 0;
\n\t\t\t\t\t\t\t\t
}
\n\t\t\t\t\t\t\t
}
\n\t\t\t\t\t\t\t
console.log(properties)
\n\t\t\t\t\t\t\t
properties.style[field] = value;
\n\t\t\t\t\t\t
}
\n\t\t\t\t\t
}
\n\t\t\t\t
}
\n\t\t\t
}catch (e)
{
\n\t\t\t\tconsole.log(e);\n\t\t\t}\n\t\t
}
\n\n\t\t
let viewNode = {\n
\t\t\t
name,
\n\t\t\t
properties,
\n\t\t\t
uuid: generateUUID(),
\n\t\t
};
\n\t\t
let dealLater = true;
\n\t\t
if (x !== 0) {\n
\t\t\t
console.log(properties)
\n\t\t\t
if(!properties.style.left){\n
\t\t\t\t
properties.style.left = x - (isSecondLayer ? offset.x : 0);
\n\t\t\t
}
\n\t\t\t\n\t\t
}
\n\t\t
if (y !== 0) {\n
\t\t\t
if(!properties.style.top){\n
\t\t\t\t
properties.style.top = y - (isSecondLayer ? offset.y : 0);
\n\t\t\t
}
\n\t\t
}
\n\t\t
properties.style.position=
\"
absolute
\"\n\t\t
viewNode.rect={\n
\t\t\t
x: properties.style.left?properties.style.left:0,
\n\t\t\t
y: properties.style.top?properties.style.top:0,
\n\t\t\t
width: properties.style.width,
\n\t\t\t
height: properties.style.height
\n\t\t
}
\n\n\t\t
if (typeTool) {\n
\t\t\t
let fontInfo = typeTool();
\n\t\t\t
properties.attrs.text = fontInfo.textValue;
\n\t\t\t
const sizes = fontInfo.sizes();
\n\t\t\t
const colors = fontInfo.colors();
\n\t\t\t
properties.style.fontSize = sizes ? sizes[0] || 20 : 20;
\n\t\t\t
let [r, g, b, a] = colors[0];
\n\t\t\t
console.log(
\"
color
\"
,[r, g, b, a])
\n\t\t\t
properties.style.color = `rgba(${r}, ${g}, ${b}, ${a / 255})`;
\n\t\t\t
viewNode.componentName = 'Label';
\n\t\t\t
dealLater = false;
\n\t\t
} else if (solidColor && layer.vectorMask) {\n
\t\t\t
let paths = layer.vectorMask().paths;
\n\t\t\t
if (paths[2].numPoints === 4) {\n
\t\t\t\t
let isRect = true;
\n\t\t\t\t
for (let i = 3; i < paths.length; i++) {\n
\t\t\t\t\t
if (paths[i].recordType !== 2) {\n
\t\t\t\t\t\t
isRect = false;
\n\t\t\t\t\t\t
break;
\n\t\t\t\t\t
}
\n\t\t\t\t
}
\n\t\t\t\t
if (isRect) {\n
\t\t\t\t\t
viewNode.componentName = 'Div';
\n\t\t\t\t\t
const {r, g, b} = solidColor();
\n\t\t\t\t\t
properties.style.backgroundColor = `rgba(${r}, ${g}, ${b}, 1)`;
\n\t\t\t\t\t
dealLater = false;
\n\t\t\t\t
}
\n\t\t\t
}
\n\t\t
}
\n\n\t\t
if (dealLater) {\n
\t\t\t
if (node.hasOwnProperty('children')) {\n
\t\t\t\t
viewNode.componentName = 'Div';
\n\t\t\t
} else {\n
\t\t\t\t
viewNode.componentName = 'Image';
\n\n\t\t\t\t
let uuid = generateUUID();
\n\t\t\t\t
const ext = '.png';
\n\n\t\t\t\t
let dataUrl;
\n\t\t\t\t
try {\n
\t\t\t\t\t
let img = node.origin.toPng();
\n\t\t\t\t\t
dataUrl = img.src;
\n\t\t\t\t
} catch (e)
{
\n\n\t\t\t\t
}
\n\n\t\t\t\t
if (dataUrl) {\n
\t\t\t\t\t
let base64Data = dataUrl.replace(/^data:image
\\
/
\\
w+;base64,/,
\"\"
);
\n\t\t\t\t\t
let buffer = new Buffer(base64Data, 'base64');
\n\t\t\t\t\t
const fileNameHash = hash(buffer);
\n\t\t\t\t\t
if (imageHashMap.hasOwnProperty(fileNameHash)) {\n
\t\t\t\t\t\t
uuid = imageHashMap[fileNameHash];
\n\t\t\t\t\t
} else {\n
\t\t\t\t\t\t
imageHashMap[fileNameHash] = uuid;
\n\t\t\t\t\t\t
assets.push({\n
\t\t\t\t\t\t\t
name,
\n\t\t\t\t\t\t\t
ext,
\n\t\t\t\t\t\t\t
uuid,
\n\t\t\t\t\t\t\t
base64Data,
\n\t\t\t\t\t\t\t
hash: fileNameHash,
\n\t\t\t\t\t\t
});
\n\t\t\t\t\t
}
\n\n\t\t\t\t\t
properties.attrs.source = 'asset://' + uuid;
\n\t\t\t\t
}
\n\t\t\t
}
\n\t\t
}
\n\n\t\t
let viewParent = parent.view || viewRoot;
\n\t\t
if (!viewParent.hasOwnProperty('children')) {\n
\t\t\t
viewParent.children = [];
\n\t\t
}
\n\t\t
viewParent.children.push(viewNode);
\n\n\t\t
node.view = viewNode;
\n\t
});
\n
console.log(psdFile)
\n\t
let data = {\n
\t\t
pluginVersion:
\"
0.0.1
\"
,
\n\t\t
reference:
\"
psd
\"
,
\n\t\t
fileName:psdFile.name,
\n\t\t
assets,
\n\t\t
view: viewRoot,
\n\t
};
\n\n\t
let dataString = JSON.stringify(data);
\n\n\t
let buf = new Buffer(dataString);
\n\t
return await new Promise((resolve, reject) => {\n
\t\t
zlib.gzip(buf, function (err, res) {\n
\t\t\t
if (err)
{
\n\t\t\t\treject(err);\n\t\t\t
}
else
{
\n\t\t\t\tconsole.log(res.length);\n\t\t\t\tresolve(res);\n\t\t\t}\n\t\t});\n\t})\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA,MAAM,GAAG,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,CAAC;AACrC;AACO,eAAe,OAAO,CAAC,IAAI,EAAE;AACpC,CAAC,IAAI,GAAG,GAAG,MAAM,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;AAC3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,CAAC,CAAC;AACL,EAAE,CAAC;AACH;;;;;"
}
\ No newline at end of file
dist/index.umd.js
View file @
b26e948e
...
...
@@ -31,7 +31,7 @@
const
x
=
left
-
pLeft
;
const
y
=
top
-
pTop
;
Object
.
assign
(
dataNode
,
{
x
,
y
,
width
,
height
,
alpha
:
opacity
/
255
,
visible
,
name
,
origin
:
psNode
,
label
:
`
${
name
}
> [
${
x
}
,
${
y
}
,
${
width
}
,
${
height
}
]`
});
Object
.
assign
(
dataNode
,
{
x
,
y
,
width
,
height
,
opacity
:
opacity
/
255
,
visible
,
name
,
origin
:
psNode
,
label
:
`
${
name
}
> [
${
x
}
,
${
y
}
,
${
width
}
,
${
height
}
]`
});
if
(
psNode
.
children
()
&&
psNode
.
children
().
length
>
0
){
dataNode
.
children
=
[];
}
...
...
dist/index.umd.js.map
View file @
b26e948e
{
"version"
:
3
,
"file"
:
"index.umd.js"
,
"sources"
:
[
"../src/psd-tree.js"
,
"../src/utils.js"
,
"../src/zeroing.js"
],
"sourcesContent"
:
[
"/**
\n
* Created by rockyl on 2019-08-09.
\n
*/
\n\n
const PSD = window['require']('psd');
\n\n
export async function getTree(file) {\n
\t
let psd = await PSD.fromDroppedFile(file);
\n\n\t
const root = {};
\n\t
walk(psd.tree(), root);
\n\n\t
return root;
\n
}
\n\n
function walk(psNode, dataNode) {\n
\t
const {left: pLeft = 0, top: pTop = 0,} = psNode.parent || {};
\n\t
const {left, top, width, height, name, layer: {opacity, visible}} = psNode;
\n\t
const x = left - pLeft;
\n\t
const y = top - pTop;
\n\n\t
Object.assign(dataNode, {x, y, width, height, alpha: opacity / 255, visible, name, origin: psNode, label: `${name} > [${x}, ${y}, ${width}, ${height}]`});
\n\t
if (psNode.children() && psNode.children().length > 0){\n
\t\t
dataNode.children = [];
\n\t
}
\n\n\t
let children = psNode.children();
\n\t
for (let i = children.length - 1; i >= 0; i--) {\n
\t\t
const childPsNode = children[i];
\n\n\t\t
const childDataNode = {};
\n\t\t
dataNode.children.push(childDataNode);
\n\t\t
walk(childPsNode, childDataNode)
\n\t
}
\n
}
\n
"
,
"/**
\n
* Created by rockyl on 2019-08-10.
\n
*/
\n\n
export async function walkNode(node, callback, includeSelf = false) {\n
\t
if (includeSelf) {\n
\t\t
await callback(node, null);
\n\t
}
\n\t
if (node.children && node.children.length > 0) {\n
\t\t
for (let childNode of node.children) {\n
\t\t\t
await callback(childNode, node);
\n\t\t\t
const result = await walkNode(childNode, callback);
\n\t\t\t
if (result === true)
{
\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n
}
\n\n
export async function walkObject(obj, callback) {\n
\t
if(typeof obj ===
\"
object
\"
){\n
\t\t
for (let key of Object.keys(obj)) {\n
\t\t\t
const value = obj[key];
\n\t\t\t
await callback(key, value, obj);
\n\t\t\t
const result = await walkObject(value, callback);
\n\t\t\t
if (result === true)
{
\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n
}
\n
"
,
"/**
\n
* Created by renjianfeng on 2020-06-11.
\n
*
\n
* 导出spark的视图
\n
*/
\n\n
import
{
getTree
}
from
\"
./psd-tree
\"
;
\n
import
{
walkNode
}
from
\"
./utils
\"
;
\n
import path from 'path'
\n
import Color from 'color'
\n
import generateUUID from 'uuid/v4'
\n
import hash from 'object-hash';
\n
import zlib from 'zlib';
\n\n
const relativePosPrefixMap = {\n
\t
l: {field: 'left',},
\n\t
t: {field: 'top',},
\n\t
r: {field: 'right',},
\n\t
b: {field: 'bottom',},
\n\t
h: {field: 'horizonCenter',},
\n\t
v: {field: 'verticalCenter',},
\n\t
wp: {field: 'width', },
\n\t
hp: {field: 'height', },
\n\t
lp: {field: 'left', },
\n\t
tp: {field: 'top', },
\n\t
rp: {field: 'right', },
\n\t
bp: {field: 'bottom', },
\n
};
\n\n
export async function execute(psdFile, options) {\n
\t
const tree = await getTree(psdFile);
\n\t
const offset = options ? options.offset : {x: 0, y: 0};
\n\n\t
let viewRoot = {\n
\t\t
name: path.basename(psdFile.name, '.psd'),
\n\t\t
componentName : 'Div',
\n\t\t
uuid: generateUUID(),
\n\t
};
\n\n\t
const assets = [];
\n\t
const imageHashMap = {};
\n\n\t
let {width: stageWidth, height: stageHeight} = tree;
\n\t
stageWidth -= offset.x || 0;
\n\t
stageHeight -= offset.y || 0;
\n\n\t
await walkNode(tree, async function (node, parent) {\n
\t\t
let
{
name
}
= node;
\n\t\t
const {x, y, width, height, opacity, display, origin: {layer, layer: {typeTool, solidColor}}} = node;
\n\t\t
//console.log('walk node:', name);
\n\t\t
let properties = {\n
\t\t\t
style:{\n
\t\t\t\t
width, height, opacity,display ,
\n\t\t\t
},
\n\t\t\t
attrs:
{
\n\n\t\t\t},\n\t\t\tclassName:\"\"\n\t\t
}
;
\n\t\t
const isSecondLayer = !parent.origin.parent;
\n\n\t\t
if (name.includes('|')) {\n
\t\t\t
try {\n
\t\t\t\t
let arr = name.split('|');
\n\t\t\t\t
name = arr[0];
\n\t\t\t\t
let paramsStr = arr[1];
\n\t\t\t\t
let params = paramsStr.split(';');
\n\t\t\t\t
let relativePos = params[0];
\n\t\t\t\t
if (relativePos) {\n
\t\t\t\t\t
let items = relativePos.split(',');
\n\t\t\t\t\t
for (let item of items) {\n
\t\t\t\t\t\t
let result = item.match(/[a-zA-Z]+/);
\n\t\t\t\t\t\t
if(!result)
{
\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t
}
\n\t\t\t\t\t\t
let prefix = result[0];
\n\t\t\t\t\t\t
let mapItem = relativePosPrefixMap[prefix];
\n\t\t\t\t\t\t
if (mapItem) {\n
\t\t\t\t\t\t\t
let
{
field,
}
= mapItem;
\n\t\t\t\t\t\t\t
let value = item.substr(prefix.length);
\n\t\t\t\t\t\t\t
let hasValue = value.length > 0;
\n\t\t\t\t\t\t\t
let fieldChar = prefix[0];
\n\t\t\t\t\t\t\t
if(!hasValue){\n
\t\t\t\t\t\t\t\t
switch(fieldChar){\n
\t\t\t\t\t\t\t\t\t
case 'l':
\n\t\t\t\t\t\t\t\t\t\t
value = x - offset.x;
\n\t\t\t\t\t\t\t\t\t\t
break;
\n\t\t\t\t\t\t\t\t\t
case 't':
\n\t\t\t\t\t\t\t\t\t\t
value = y - offset.y;
\n\t\t\t\t\t\t\t\t\t\t
break;
\n\t\t\t\t\t\t\t\t\t
case 'r':
\n\t\t\t\t\t\t\t\t\t\t
value = stageWidth - width;
\n\t\t\t\t\t\t\t\t\t\t
break;
\n\t\t\t\t\t\t\t\t\t
case 'b':
\n\t\t\t\t\t\t\t\t\t\t
value = stageHeight - height;
\n\t\t\t\t\t\t\t\t\t\t
break;
\n\t\t\t\t\t\t\t\t\t
case 'h':
\n\t\t\t\t\t\t\t\t\t\t
value = x + width / 2 - stageWidth / 2;
\n\t\t\t\t\t\t\t\t\t\t
break;
\n\t\t\t\t\t\t\t\t\t
case 'v':
\n\t\t\t\t\t\t\t\t\t\t
value = y + height / 2 - stageHeight / 2;
\n\t\t\t\t\t\t\t\t\t\t
break;
\n\t\t\t\t\t\t\t\t
}
\n\t\t\t\t\t\t\t
}
\n\t\t\t\t\t\t\t
let isPercent = prefix.endsWith('p');
\n\t\t\t\t\t\t\t
if (isPercent) {\n
\t\t\t\t\t\t\t\t
if(!hasValue){\n
\t\t\t\t\t\t\t\t\t
switch(fieldChar){\n
\t\t\t\t\t\t\t\t\t\t
case 'l':
\n\t\t\t\t\t\t\t\t\t\t
case 'r':
\n\t\t\t\t\t\t\t\t\t\t\t
value /= stageWidth;
\n\t\t\t\t\t\t\t\t\t\t\t
break;
\n\t\t\t\t\t\t\t\t\t\t
case 't':
\n\t\t\t\t\t\t\t\t\t\t
case 'b':
\n\t\t\t\t\t\t\t\t\t\t\t
value /= stageHeight;
\n\t\t\t\t\t\t\t\t\t\t\t
break;
\n\t\t\t\t\t\t\t\t\t
}
\n\t\t\t\t\t\t\t\t\t
value = Math.floor(value * 100);
\n\t\t\t\t\t\t\t\t
}
\n\t\t\t\t\t\t\t\t
value += '%';
\n\t\t\t\t\t\t\t
} else {\n
\t\t\t\t\t\t\t\t
value = parseFloat(value);
\n\t\t\t\t\t\t\t\t
if (isNaN(value)) {\n
\t\t\t\t\t\t\t\t\t
value = 0;
\n\t\t\t\t\t\t\t\t
}
\n\t\t\t\t\t\t\t
}
\n\t\t\t\t\t\t\t
console.log(properties)
\n\t\t\t\t\t\t\t
properties.style[field] = value;
\n\t\t\t\t\t\t
}
\n\t\t\t\t\t
}
\n\t\t\t\t
}
\n\t\t\t
}catch (e)
{
\n\t\t\t\tconsole.log(e);\n\t\t\t}\n\t\t
}
\n\n\t\t
let viewNode = {\n
\t\t\t
name,
\n\t\t\t
properties,
\n\t\t\t
uuid: generateUUID(),
\n\t\t
};
\n\t\t
let dealLater = true;
\n\t\t
if (x !== 0) {\n
\t\t\t
console.log(properties)
\n\t\t\t
if(!properties.style.left){\n
\t\t\t\t
properties.style.left = x - (isSecondLayer ? offset.x : 0);
\n\t\t\t
}
\n\t\t\t\n\t\t
}
\n\t\t
if (y !== 0) {\n
\t\t\t
if(!properties.style.top){\n
\t\t\t\t
properties.style.top = y - (isSecondLayer ? offset.y : 0);
\n\t\t\t
}
\n\t\t
}
\n\t\t
properties.style.position=
\"
absolute
\"\n\t\t
viewNode.rect={\n
\t\t\t
x: properties.style.left?properties.style.left:0,
\n\t\t\t
y: properties.style.top?properties.style.top:0,
\n\t\t\t
width: properties.style.width,
\n\t\t\t
height: properties.style.height
\n\t\t
}
\n\n\t\t
if (typeTool) {\n
\t\t\t
let fontInfo = typeTool();
\n\t\t\t
properties.attrs.text = fontInfo.textValue;
\n\t\t\t
const sizes = fontInfo.sizes();
\n\t\t\t
const colors = fontInfo.colors();
\n\t\t\t
properties.style.fontSize = sizes ? sizes[0] || 20 : 20;
\n\t\t\t
let [r, g, b, a] = colors[0];
\n\t\t\t
console.log(
\"
color
\"
,[r, g, b, a])
\n\t\t\t
properties.style.color = `rgba(${r}, ${g}, ${b}, ${a / 255})`;
\n\t\t\t
viewNode.componentName = 'Label';
\n\t\t\t
dealLater = false;
\n\t\t
} else if (solidColor && layer.vectorMask) {\n
\t\t\t
let paths = layer.vectorMask().paths;
\n\t\t\t
if (paths[2].numPoints === 4) {\n
\t\t\t\t
let isRect = true;
\n\t\t\t\t
for (let i = 3; i < paths.length; i++) {\n
\t\t\t\t\t
if (paths[i].recordType !== 2) {\n
\t\t\t\t\t\t
isRect = false;
\n\t\t\t\t\t\t
break;
\n\t\t\t\t\t
}
\n\t\t\t\t
}
\n\t\t\t\t
if (isRect) {\n
\t\t\t\t\t
viewNode.componentName = 'Div';
\n\t\t\t\t\t
const {r, g, b} = solidColor();
\n\t\t\t\t\t
properties.style.backgroundColor = `rgba(${r}, ${g}, ${b}, 1)`;
\n\t\t\t\t\t
dealLater = false;
\n\t\t\t\t
}
\n\t\t\t
}
\n\t\t
}
\n\n\t\t
if (dealLater) {\n
\t\t\t
if (node.hasOwnProperty('children')) {\n
\t\t\t\t
viewNode.componentName = 'Div';
\n\t\t\t
} else {\n
\t\t\t\t
viewNode.componentName = 'Image';
\n\n\t\t\t\t
let uuid = generateUUID();
\n\t\t\t\t
const ext = '.png';
\n\n\t\t\t\t
let dataUrl;
\n\t\t\t\t
try {\n
\t\t\t\t\t
let img = node.origin.toPng();
\n\t\t\t\t\t
dataUrl = img.src;
\n\t\t\t\t
} catch (e)
{
\n\n\t\t\t\t
}
\n\n\t\t\t\t
if (dataUrl) {\n
\t\t\t\t\t
let base64Data = dataUrl.replace(/^data:image
\\
/
\\
w+;base64,/,
\"\"
);
\n\t\t\t\t\t
let buffer = new Buffer(base64Data, 'base64');
\n\t\t\t\t\t
const fileNameHash = hash(buffer);
\n\t\t\t\t\t
if (imageHashMap.hasOwnProperty(fileNameHash)) {\n
\t\t\t\t\t\t
uuid = imageHashMap[fileNameHash];
\n\t\t\t\t\t
} else {\n
\t\t\t\t\t\t
imageHashMap[fileNameHash] = uuid;
\n\t\t\t\t\t\t
assets.push({\n
\t\t\t\t\t\t\t
name,
\n\t\t\t\t\t\t\t
ext,
\n\t\t\t\t\t\t\t
uuid,
\n\t\t\t\t\t\t\t
base64Data,
\n\t\t\t\t\t\t\t
hash: fileNameHash,
\n\t\t\t\t\t\t
});
\n\t\t\t\t\t
}
\n\n\t\t\t\t\t
properties.attrs.source = 'asset://' + uuid;
\n\t\t\t\t
}
\n\t\t\t
}
\n\t\t
}
\n\n\t\t
let viewParent = parent.view || viewRoot;
\n\t\t
if (!viewParent.hasOwnProperty('children')) {\n
\t\t\t
viewParent.children = [];
\n\t\t
}
\n\t\t
viewParent.children.push(viewNode);
\n\n\t\t
node.view = viewNode;
\n\t
});
\n
console.log(psdFile)
\n\t
let data = {\n
\t\t
pluginVersion:
\"
0.0.1
\"
,
\n\t\t
reference:
\"
psd
\"
,
\n\t\t
fileName:psdFile.name,
\n\t\t
assets,
\n\t\t
view: viewRoot,
\n\t
};
\n\n\t
let dataString = JSON.stringify(data);
\n\n\t
let buf = new Buffer(dataString);
\n\t
return await new Promise((resolve, reject) => {\n
\t\t
zlib.gzip(buf, function (err, res) {\n
\t\t\t
if (err)
{
\n\t\t\t\treject(err);\n\t\t\t
}
else
{
\n\t\t\t\tconsole.log(res.length);\n\t\t\t\tresolve(res);\n\t\t\t}\n\t\t});\n\t})\n}\n"],"names":[],"mappings":";;;;;;;;;;;;CAAA;CACA;CACA;AACA;CACA,MAAM,GAAG,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,CAAC;AACrC;CACO,eAAe,OAAO,CAAC,IAAI,EAAE;CACpC,CAAC,IAAI,GAAG,GAAG,MAAM,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;AAC3C;CACA,CAAC,MAAM,IAAI,GAAG,EAAE,CAAC;CACjB,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,IAAI,CAAC,CAAC;AACxB;CACA,CAAC,OAAO,IAAI,CAAC;CACb,CAAC;AACD;CACA,SAAS,IAAI,CAAC,MAAM,EAAE,QAAQ,EAAE;CAChC,CAAC,MAAM,CAAC,IAA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,CAAC,EAAE;CAC9C,GAAG,UAAU,CAAC,QAAQ,GAAG,EAAE,CAAC;CAC5B,GAAG;CACH,EAAE,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AACrC;CACA,EAAE,IAAI,CAAC,IAAI,GAAG,QAAQ,CAAC;CACvB,EAAE,CAAC,CAAC;CACJ,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,EAAC;CACxB,CAAC,IAAI,IAAI,GAAG;CACZ,EAAE,aAAa,CAAC,OAAO;CACvB,EAAE,SAAS,CAAC,KAAK;CACjB,EAAE,QAAQ,CAAC,OAAO,CAAC,IAAI;CACvB,EAAE,MAAM;CACR,EAAE,IAAI,EAAE,QAAQ;CAChB,EAAE,CAAC;AACH;CACA,CAAC,IAAI,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;AACvC;CACA,CAAC,IAAI,GAAG,GAAG,IAAI,MAAM,CAAC,UAAU,CAAC,CAAC;CAClC,CAAC,OAAO,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK;CAC/C,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,UAAU,GAAG,EAAE,GAAG,EAAE;CACrC,GAAG,IAAI,GAAG,EAAE;CACZ,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC;CAChB,IAAI,MAAM;CACV,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;CAC5B,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC;CACjB,IAAI;CACJ,GAAG,CAAC,CAAC;CACL,EAAE,CAAC;CACH;;;;;;;;;;;;;"
}
\ No newline at end of file
{
"version"
:
3
,
"file"
:
"index.umd.js"
,
"sources"
:
[
"../src/psd-tree.js"
,
"../src/utils.js"
,
"../src/zeroing.js"
],
"sourcesContent"
:
[
"/**
\n
* Created by rockyl on 2019-08-09.
\n
*/
\n\n
const PSD = window['require']('psd');
\n\n
export async function getTree(file) {\n
\t
let psd = await PSD.fromDroppedFile(file);
\n\n\t
const root = {};
\n\t
walk(psd.tree(), root);
\n\n\t
return root;
\n
}
\n\n
function walk(psNode, dataNode) {\n
\t
const {left: pLeft = 0, top: pTop = 0,} = psNode.parent || {};
\n\t
const {left, top, width, height, name, layer: {opacity, visible}} = psNode;
\n\t
const x = left - pLeft;
\n\t
const y = top - pTop;
\n\n\t
Object.assign(dataNode, {x, y, width, height, opacity: opacity / 255, visible, name, origin: psNode, label: `${name} > [${x}, ${y}, ${width}, ${height}]`});
\n\t
if (psNode.children() && psNode.children().length > 0){\n
\t\t
dataNode.children = [];
\n\t
}
\n\n\t
let children = psNode.children();
\n\t
for (let i = children.length - 1; i >= 0; i--) {\n
\t\t
const childPsNode = children[i];
\n\n\t\t
const childDataNode = {};
\n\t\t
dataNode.children.push(childDataNode);
\n\t\t
walk(childPsNode, childDataNode)
\n\t
}
\n
}
\n
"
,
"/**
\n
* Created by rockyl on 2019-08-10.
\n
*/
\n\n
export async function walkNode(node, callback, includeSelf = false) {\n
\t
if (includeSelf) {\n
\t\t
await callback(node, null);
\n\t
}
\n\t
if (node.children && node.children.length > 0) {\n
\t\t
for (let childNode of node.children) {\n
\t\t\t
await callback(childNode, node);
\n\t\t\t
const result = await walkNode(childNode, callback);
\n\t\t\t
if (result === true)
{
\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n
}
\n\n
export async function walkObject(obj, callback) {\n
\t
if(typeof obj ===
\"
object
\"
){\n
\t\t
for (let key of Object.keys(obj)) {\n
\t\t\t
const value = obj[key];
\n\t\t\t
await callback(key, value, obj);
\n\t\t\t
const result = await walkObject(value, callback);
\n\t\t\t
if (result === true)
{
\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n
}
\n
"
,
"/**
\n
* Created by renjianfeng on 2020-06-11.
\n
*
\n
* 导出spark的视图
\n
*/
\n\n
import
{
getTree
}
from
\"
./psd-tree
\"
;
\n
import
{
walkNode
}
from
\"
./utils
\"
;
\n
import path from 'path'
\n
import Color from 'color'
\n
import generateUUID from 'uuid/v4'
\n
import hash from 'object-hash';
\n
import zlib from 'zlib';
\n\n
const relativePosPrefixMap = {\n
\t
l: {field: 'left',},
\n\t
t: {field: 'top',},
\n\t
r: {field: 'right',},
\n\t
b: {field: 'bottom',},
\n\t
h: {field: 'horizonCenter',},
\n\t
v: {field: 'verticalCenter',},
\n\t
wp: {field: 'width', },
\n\t
hp: {field: 'height', },
\n\t
lp: {field: 'left', },
\n\t
tp: {field: 'top', },
\n\t
rp: {field: 'right', },
\n\t
bp: {field: 'bottom', },
\n
};
\n\n
export async function execute(psdFile, options) {\n
\t
const tree = await getTree(psdFile);
\n\t
const offset = options ? options.offset : {x: 0, y: 0};
\n\n\t
let viewRoot = {\n
\t\t
name: path.basename(psdFile.name, '.psd'),
\n\t\t
componentName : 'Div',
\n\t\t
uuid: generateUUID(),
\n\t
};
\n\n\t
const assets = [];
\n\t
const imageHashMap = {};
\n\n\t
let {width: stageWidth, height: stageHeight} = tree;
\n\t
stageWidth -= offset.x || 0;
\n\t
stageHeight -= offset.y || 0;
\n\n\t
await walkNode(tree, async function (node, parent) {\n
\t\t
let
{
name
}
= node;
\n\t\t
const {x, y, width, height, opacity, display, origin: {layer, layer: {typeTool, solidColor}}} = node;
\n\t\t
//console.log('walk node:', name);
\n\t\t
let properties = {\n
\t\t\t
style:{\n
\t\t\t\t
width, height, opacity,display ,
\n\t\t\t
},
\n\t\t\t
attrs:
{
\n\n\t\t\t},\n\t\t\tclassName:\"\"\n\t\t
}
;
\n\t\t
const isSecondLayer = !parent.origin.parent;
\n\n\t\t
if (name.includes('|')) {\n
\t\t\t
try {\n
\t\t\t\t
let arr = name.split('|');
\n\t\t\t\t
name = arr[0];
\n\t\t\t\t
let paramsStr = arr[1];
\n\t\t\t\t
let params = paramsStr.split(';');
\n\t\t\t\t
let relativePos = params[0];
\n\t\t\t\t
if (relativePos) {\n
\t\t\t\t\t
let items = relativePos.split(',');
\n\t\t\t\t\t
for (let item of items) {\n
\t\t\t\t\t\t
let result = item.match(/[a-zA-Z]+/);
\n\t\t\t\t\t\t
if(!result)
{
\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t
}
\n\t\t\t\t\t\t
let prefix = result[0];
\n\t\t\t\t\t\t
let mapItem = relativePosPrefixMap[prefix];
\n\t\t\t\t\t\t
if (mapItem) {\n
\t\t\t\t\t\t\t
let
{
field,
}
= mapItem;
\n\t\t\t\t\t\t\t
let value = item.substr(prefix.length);
\n\t\t\t\t\t\t\t
let hasValue = value.length > 0;
\n\t\t\t\t\t\t\t
let fieldChar = prefix[0];
\n\t\t\t\t\t\t\t
if(!hasValue){\n
\t\t\t\t\t\t\t\t
switch(fieldChar){\n
\t\t\t\t\t\t\t\t\t
case 'l':
\n\t\t\t\t\t\t\t\t\t\t
value = x - offset.x;
\n\t\t\t\t\t\t\t\t\t\t
break;
\n\t\t\t\t\t\t\t\t\t
case 't':
\n\t\t\t\t\t\t\t\t\t\t
value = y - offset.y;
\n\t\t\t\t\t\t\t\t\t\t
break;
\n\t\t\t\t\t\t\t\t\t
case 'r':
\n\t\t\t\t\t\t\t\t\t\t
value = stageWidth - width;
\n\t\t\t\t\t\t\t\t\t\t
break;
\n\t\t\t\t\t\t\t\t\t
case 'b':
\n\t\t\t\t\t\t\t\t\t\t
value = stageHeight - height;
\n\t\t\t\t\t\t\t\t\t\t
break;
\n\t\t\t\t\t\t\t\t\t
case 'h':
\n\t\t\t\t\t\t\t\t\t\t
value = x + width / 2 - stageWidth / 2;
\n\t\t\t\t\t\t\t\t\t\t
break;
\n\t\t\t\t\t\t\t\t\t
case 'v':
\n\t\t\t\t\t\t\t\t\t\t
value = y + height / 2 - stageHeight / 2;
\n\t\t\t\t\t\t\t\t\t\t
break;
\n\t\t\t\t\t\t\t\t
}
\n\t\t\t\t\t\t\t
}
\n\t\t\t\t\t\t\t
let isPercent = prefix.endsWith('p');
\n\t\t\t\t\t\t\t
if (isPercent) {\n
\t\t\t\t\t\t\t\t
if(!hasValue){\n
\t\t\t\t\t\t\t\t\t
switch(fieldChar){\n
\t\t\t\t\t\t\t\t\t\t
case 'l':
\n\t\t\t\t\t\t\t\t\t\t
case 'r':
\n\t\t\t\t\t\t\t\t\t\t\t
value /= stageWidth;
\n\t\t\t\t\t\t\t\t\t\t\t
break;
\n\t\t\t\t\t\t\t\t\t\t
case 't':
\n\t\t\t\t\t\t\t\t\t\t
case 'b':
\n\t\t\t\t\t\t\t\t\t\t\t
value /= stageHeight;
\n\t\t\t\t\t\t\t\t\t\t\t
break;
\n\t\t\t\t\t\t\t\t\t
}
\n\t\t\t\t\t\t\t\t\t
value = Math.floor(value * 100);
\n\t\t\t\t\t\t\t\t
}
\n\t\t\t\t\t\t\t\t
value += '%';
\n\t\t\t\t\t\t\t
} else {\n
\t\t\t\t\t\t\t\t
value = parseFloat(value);
\n\t\t\t\t\t\t\t\t
if (isNaN(value)) {\n
\t\t\t\t\t\t\t\t\t
value = 0;
\n\t\t\t\t\t\t\t\t
}
\n\t\t\t\t\t\t\t
}
\n\t\t\t\t\t\t\t
console.log(properties)
\n\t\t\t\t\t\t\t
properties.style[field] = value;
\n\t\t\t\t\t\t
}
\n\t\t\t\t\t
}
\n\t\t\t\t
}
\n\t\t\t
}catch (e)
{
\n\t\t\t\tconsole.log(e);\n\t\t\t}\n\t\t
}
\n\n\t\t
let viewNode = {\n
\t\t\t
name,
\n\t\t\t
properties,
\n\t\t\t
uuid: generateUUID(),
\n\t\t
};
\n\t\t
let dealLater = true;
\n\t\t
if (x !== 0) {\n
\t\t\t
console.log(properties)
\n\t\t\t
if(!properties.style.left){\n
\t\t\t\t
properties.style.left = x - (isSecondLayer ? offset.x : 0);
\n\t\t\t
}
\n\t\t\t\n\t\t
}
\n\t\t
if (y !== 0) {\n
\t\t\t
if(!properties.style.top){\n
\t\t\t\t
properties.style.top = y - (isSecondLayer ? offset.y : 0);
\n\t\t\t
}
\n\t\t
}
\n\t\t
properties.style.position=
\"
absolute
\"\n\t\t
viewNode.rect={\n
\t\t\t
x: properties.style.left?properties.style.left:0,
\n\t\t\t
y: properties.style.top?properties.style.top:0,
\n\t\t\t
width: properties.style.width,
\n\t\t\t
height: properties.style.height
\n\t\t
}
\n\n\t\t
if (typeTool) {\n
\t\t\t
let fontInfo = typeTool();
\n\t\t\t
properties.attrs.text = fontInfo.textValue;
\n\t\t\t
const sizes = fontInfo.sizes();
\n\t\t\t
const colors = fontInfo.colors();
\n\t\t\t
properties.style.fontSize = sizes ? sizes[0] || 20 : 20;
\n\t\t\t
let [r, g, b, a] = colors[0];
\n\t\t\t
console.log(
\"
color
\"
,[r, g, b, a])
\n\t\t\t
properties.style.color = `rgba(${r}, ${g}, ${b}, ${a / 255})`;
\n\t\t\t
viewNode.componentName = 'Label';
\n\t\t\t
dealLater = false;
\n\t\t
} else if (solidColor && layer.vectorMask) {\n
\t\t\t
let paths = layer.vectorMask().paths;
\n\t\t\t
if (paths[2].numPoints === 4) {\n
\t\t\t\t
let isRect = true;
\n\t\t\t\t
for (let i = 3; i < paths.length; i++) {\n
\t\t\t\t\t
if (paths[i].recordType !== 2) {\n
\t\t\t\t\t\t
isRect = false;
\n\t\t\t\t\t\t
break;
\n\t\t\t\t\t
}
\n\t\t\t\t
}
\n\t\t\t\t
if (isRect) {\n
\t\t\t\t\t
viewNode.componentName = 'Div';
\n\t\t\t\t\t
const {r, g, b} = solidColor();
\n\t\t\t\t\t
properties.style.backgroundColor = `rgba(${r}, ${g}, ${b}, 1)`;
\n\t\t\t\t\t
dealLater = false;
\n\t\t\t\t
}
\n\t\t\t
}
\n\t\t
}
\n\n\t\t
if (dealLater) {\n
\t\t\t
if (node.hasOwnProperty('children')) {\n
\t\t\t\t
viewNode.componentName = 'Div';
\n\t\t\t
} else {\n
\t\t\t\t
viewNode.componentName = 'Image';
\n\n\t\t\t\t
let uuid = generateUUID();
\n\t\t\t\t
const ext = '.png';
\n\n\t\t\t\t
let dataUrl;
\n\t\t\t\t
try {\n
\t\t\t\t\t
let img = node.origin.toPng();
\n\t\t\t\t\t
dataUrl = img.src;
\n\t\t\t\t
} catch (e)
{
\n\n\t\t\t\t
}
\n\n\t\t\t\t
if (dataUrl) {\n
\t\t\t\t\t
let base64Data = dataUrl.replace(/^data:image
\\
/
\\
w+;base64,/,
\"\"
);
\n\t\t\t\t\t
let buffer = new Buffer(base64Data, 'base64');
\n\t\t\t\t\t
const fileNameHash = hash(buffer);
\n\t\t\t\t\t
if (imageHashMap.hasOwnProperty(fileNameHash)) {\n
\t\t\t\t\t\t
uuid = imageHashMap[fileNameHash];
\n\t\t\t\t\t
} else {\n
\t\t\t\t\t\t
imageHashMap[fileNameHash] = uuid;
\n\t\t\t\t\t\t
assets.push({\n
\t\t\t\t\t\t\t
name,
\n\t\t\t\t\t\t\t
ext,
\n\t\t\t\t\t\t\t
uuid,
\n\t\t\t\t\t\t\t
base64Data,
\n\t\t\t\t\t\t\t
hash: fileNameHash,
\n\t\t\t\t\t\t
});
\n\t\t\t\t\t
}
\n\n\t\t\t\t\t
properties.attrs.source = 'asset://' + uuid;
\n\t\t\t\t
}
\n\t\t\t
}
\n\t\t
}
\n\n\t\t
let viewParent = parent.view || viewRoot;
\n\t\t
if (!viewParent.hasOwnProperty('children')) {\n
\t\t\t
viewParent.children = [];
\n\t\t
}
\n\t\t
viewParent.children.push(viewNode);
\n\n\t\t
node.view = viewNode;
\n\t
});
\n
console.log(psdFile)
\n\t
let data = {\n
\t\t
pluginVersion:
\"
0.0.1
\"
,
\n\t\t
reference:
\"
psd
\"
,
\n\t\t
fileName:psdFile.name,
\n\t\t
assets,
\n\t\t
view: viewRoot,
\n\t
};
\n\n\t
let dataString = JSON.stringify(data);
\n\n\t
let buf = new Buffer(dataString);
\n\t
return await new Promise((resolve, reject) => {\n
\t\t
zlib.gzip(buf, function (err, res) {\n
\t\t\t
if (err)
{
\n\t\t\t\treject(err);\n\t\t\t
}
else
{
\n\t\t\t\tconsole.log(res.length);\n\t\t\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AAI,CAAC,IAAI,CAAC,GAAG,EAAE,UAAU,GAAG,EAAE,GAAG,EAAE;CACrC,GAAG,IAAI,GAAG,EAAE;CACZ,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC;CAChB,IAAI,MAAM;CACV,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;CAC5B,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC;CACjB,IAAI;CACJ,GAAG,CAAC,CAAC;CACL,EAAE,CAAC;CACH;;;;;;;;;;;;;"
}
\ No newline at end of file
src/psd-tree.js
View file @
b26e948e
...
...
@@ -19,7 +19,7 @@ function walk(psNode, dataNode) {
const
x
=
left
-
pLeft
;
const
y
=
top
-
pTop
;
Object
.
assign
(
dataNode
,
{
x
,
y
,
width
,
height
,
alpha
:
opacity
/
255
,
visible
,
name
,
origin
:
psNode
,
label
:
`
${
name
}
> [
${
x
}
,
${
y
}
,
${
width
}
,
${
height
}
]`
});
Object
.
assign
(
dataNode
,
{
x
,
y
,
width
,
height
,
opacity
:
opacity
/
255
,
visible
,
name
,
origin
:
psNode
,
label
:
`
${
name
}
> [
${
x
}
,
${
y
}
,
${
width
}
,
${
height
}
]`
});
if
(
psNode
.
children
()
&&
psNode
.
children
().
length
>
0
){
dataNode
.
children
=
[];
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment