Commit 90f70ab9 authored by rockyl's avatar rockyl

。。。

parent 9552a48b
......@@ -86,6 +86,7 @@ const enterChar = String.fromCharCode(13);
async function execute(psdFile, options) {
const tree = await getTree(psdFile);
console.log('got tree:', tree);
const {mode = 'none', singleView = true} = options;
let offset = {x: 0, y: 0};
let cutSize = {x: 0, y: 0};
......@@ -119,7 +120,7 @@ async function execute(psdFile, options) {
await walkNode(tree, async function (node, parent) {
let {name} = node;
const {x, y, width, height, alpha, visible, origin: {layer, layer: {typeTool, solidColor}}} = node;
//console.log('walk node:', name);
console.log('walk node:', name);
let properties = {
width, height, alpha, visible,
};
......
This diff is collapsed.
......@@ -2,13 +2,18 @@
Object.defineProperty(exports, '__esModule', { value: true });
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var path = _interopDefault(require('path'));
var path = require('path');
require('color');
var generateUUID = _interopDefault(require('uuid/v4'));
var hash = _interopDefault(require('object-hash'));
var zlib = _interopDefault(require('zlib'));
var generateUUID = require('uuid/v4');
var hash = require('object-hash');
var zlib = require('zlib');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
var generateUUID__default = /*#__PURE__*/_interopDefaultLegacy(generateUUID);
var hash__default = /*#__PURE__*/_interopDefaultLegacy(hash);
var zlib__default = /*#__PURE__*/_interopDefaultLegacy(zlib);
/**
* Created by rockyl on 2019-08-09.
......@@ -92,6 +97,7 @@ const enterChar = String.fromCharCode(13);
async function execute(psdFile, options) {
const tree = await getTree(psdFile);
console.log('got tree:', tree);
const {mode = 'none', singleView = true} = options;
let offset = {x: 0, y: 0};
let cutSize = {x: 0, y: 0};
......@@ -110,9 +116,9 @@ async function execute(psdFile, options) {
const isCenter = mode === 'center';
let viewRoot = {
name: path.basename(psdFile.name, '.psd'),
name: path__default['default'].basename(psdFile.name, '.psd'),
type: 'node',
uuid: generateUUID(),
uuid: generateUUID__default['default'](),
};
const assets = [];
......@@ -125,7 +131,7 @@ async function execute(psdFile, options) {
await walkNode(tree, async function (node, parent) {
let {name} = node;
const {x, y, width, height, alpha, visible, origin: {layer, layer: {typeTool, solidColor}}} = node;
//console.log('walk node:', name);
console.log('walk node:', name);
let properties = {
width, height, alpha, visible,
};
......@@ -214,7 +220,7 @@ async function execute(psdFile, options) {
let viewNode = {
name,
properties,
uuid: generateUUID(),
uuid: generateUUID__default['default'](),
};
let dealLater = true;
let px = x;// - (!singleView && isSecondLayer ? offset.x : 0);
......@@ -266,7 +272,7 @@ async function execute(psdFile, options) {
} else {
viewNode.type = 'image';
let uuid = generateUUID();
let uuid = generateUUID__default['default']();
const ext = '.png';
let dataUrl;
......@@ -280,7 +286,7 @@ async function execute(psdFile, options) {
if (dataUrl) {
let base64Data = dataUrl.replace(/^data:image\/\w+;base64,/, "");
let buffer = new Buffer(base64Data, 'base64');
const fileNameHash = hash(buffer);
const fileNameHash = hash__default['default'](buffer);
if (imageHashMap.hasOwnProperty(fileNameHash)) {
uuid = imageHashMap[fileNameHash];
} else {
......@@ -317,7 +323,7 @@ async function execute(psdFile, options) {
let buf = new Buffer(dataString);
return await new Promise((resolve, reject) => {
zlib.gzip(buf, function (err, res) {
zlib__default['default'].gzip(buf, function (err, res) {
if (err) {
reject(err);
} else {
......
This diff is collapsed.
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('path'), require('color'), require('uuid/v4'), require('object-hash'), require('zlib')) :
typeof define === 'function' && define.amd ? define(['exports', 'path', 'color', 'uuid/v4', 'object-hash', 'zlib'], factory) :
(global = global || self, factory(global['psd-parse-web'] = {}, global.path, global.color, global.generateUUID, global.hash, global.zlib));
}(this, function (exports, path, color, generateUUID, hash, zlib) { 'use strict';
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global['psd-parse-web'] = {}, global.path, null, global.generateUUID, global.hash, global.zlib));
}(this, (function (exports, path, color, generateUUID, hash, zlib) { 'use strict';
path = path && path.hasOwnProperty('default') ? path['default'] : path;
color = color && color.hasOwnProperty('default') ? color['default'] : color;
generateUUID = generateUUID && generateUUID.hasOwnProperty('default') ? generateUUID['default'] : generateUUID;
hash = hash && hash.hasOwnProperty('default') ? hash['default'] : hash;
zlib = zlib && zlib.hasOwnProperty('default') ? zlib['default'] : zlib;
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
var generateUUID__default = /*#__PURE__*/_interopDefaultLegacy(generateUUID);
var hash__default = /*#__PURE__*/_interopDefaultLegacy(hash);
var zlib__default = /*#__PURE__*/_interopDefaultLegacy(zlib);
/**
* Created by rockyl on 2019-08-09.
......@@ -92,6 +93,7 @@
async function execute(psdFile, options) {
const tree = await getTree(psdFile);
console.log('got tree:', tree);
const {mode = 'none', singleView = true} = options;
let offset = {x: 0, y: 0};
let cutSize = {x: 0, y: 0};
......@@ -110,9 +112,9 @@
const isCenter = mode === 'center';
let viewRoot = {
name: path.basename(psdFile.name, '.psd'),
name: path__default['default'].basename(psdFile.name, '.psd'),
type: 'node',
uuid: generateUUID(),
uuid: generateUUID__default['default'](),
};
const assets = [];
......@@ -125,7 +127,7 @@
await walkNode(tree, async function (node, parent) {
let {name} = node;
const {x, y, width, height, alpha, visible, origin: {layer, layer: {typeTool, solidColor}}} = node;
//console.log('walk node:', name);
console.log('walk node:', name);
let properties = {
width, height, alpha, visible,
};
......@@ -214,7 +216,7 @@
let viewNode = {
name,
properties,
uuid: generateUUID(),
uuid: generateUUID__default['default'](),
};
let dealLater = true;
let px = x;// - (!singleView && isSecondLayer ? offset.x : 0);
......@@ -266,7 +268,7 @@
} else {
viewNode.type = 'image';
let uuid = generateUUID();
let uuid = generateUUID__default['default']();
const ext = '.png';
let dataUrl;
......@@ -280,7 +282,7 @@
if (dataUrl) {
let base64Data = dataUrl.replace(/^data:image\/\w+;base64,/, "");
let buffer = new Buffer(base64Data, 'base64');
const fileNameHash = hash(buffer);
const fileNameHash = hash__default['default'](buffer);
if (imageHashMap.hasOwnProperty(fileNameHash)) {
uuid = imageHashMap[fileNameHash];
} else {
......@@ -317,7 +319,7 @@
let buf = new Buffer(dataString);
return await new Promise((resolve, reject) => {
zlib.gzip(buf, function (err, res) {
zlib__default['default'].gzip(buf, function (err, res) {
if (err) {
reject(err);
} else {
......@@ -333,5 +335,5 @@
Object.defineProperty(exports, '__esModule', { value: true });
}));
})));
//# sourceMappingURL=index.umd.js.map
This diff is collapsed.
......@@ -2,9 +2,8 @@
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/dist" />
</content>
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
......@@ -33,6 +33,7 @@ const enterChar = String.fromCharCode(13);
export async function execute(psdFile, options) {
const tree = await getTree(psdFile);
console.log('got tree:', tree);
const {mode = 'none', singleView = true} = options;
let offset = {x: 0, y: 0};
let cutSize = {x: 0, y: 0};
......@@ -66,7 +67,7 @@ export async function execute(psdFile, options) {
await walkNode(tree, async function (node, parent) {
let {name} = node;
const {x, y, width, height, alpha, visible, origin: {layer, layer: {typeTool, solidColor}}} = node;
//console.log('walk node:', name);
console.log('walk node:', name);
let properties = {
width, height, alpha, visible,
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment