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
90f70ab9
Commit
90f70ab9
authored
Jul 14, 2021
by
rockyl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
。。。
parent
9552a48b
Changes
8
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
45 additions
and
36 deletions
+45
-36
index.es.js
dist/index.es.js
+2
-1
index.es.js.map
dist/index.es.js.map
+1
-1
index.js
dist/index.js
+19
-13
index.js.map
dist/index.js.map
+1
-1
index.umd.js
dist/index.umd.js
+17
-15
index.umd.js.map
dist/index.umd.js.map
+1
-1
psd-parse-web.iml
psd-parse-web.iml
+2
-3
zeroing.js
src/zeroing.js
+2
-1
No files found.
dist/index.es.js
View file @
90f70ab9
...
@@ -86,6 +86,7 @@ const enterChar = String.fromCharCode(13);
...
@@ -86,6 +86,7 @@ const enterChar = String.fromCharCode(13);
async
function
execute
(
psdFile
,
options
)
{
async
function
execute
(
psdFile
,
options
)
{
const
tree
=
await
getTree
(
psdFile
);
const
tree
=
await
getTree
(
psdFile
);
console
.
log
(
'got tree:'
,
tree
);
const
{
mode
=
'none'
,
singleView
=
true
}
=
options
;
const
{
mode
=
'none'
,
singleView
=
true
}
=
options
;
let
offset
=
{
x
:
0
,
y
:
0
};
let
offset
=
{
x
:
0
,
y
:
0
};
let
cutSize
=
{
x
:
0
,
y
:
0
};
let
cutSize
=
{
x
:
0
,
y
:
0
};
...
@@ -119,7 +120,7 @@ async function execute(psdFile, options) {
...
@@ -119,7 +120,7 @@ async function execute(psdFile, options) {
await
walkNode
(
tree
,
async
function
(
node
,
parent
)
{
await
walkNode
(
tree
,
async
function
(
node
,
parent
)
{
let
{
name
}
=
node
;
let
{
name
}
=
node
;
const
{
x
,
y
,
width
,
height
,
alpha
,
visible
,
origin
:
{
layer
,
layer
:
{
typeTool
,
solidColor
}}}
=
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
=
{
let
properties
=
{
width
,
height
,
alpha
,
visible
,
width
,
height
,
alpha
,
visible
,
};
};
...
...
dist/index.es.js.map
View file @
90f70ab9
This diff is collapsed.
Click to expand it.
dist/index.js
View file @
90f70ab9
...
@@ -2,13 +2,18 @@
...
@@ -2,13 +2,18 @@
Object
.
defineProperty
(
exports
,
'__esModule'
,
{
value
:
true
});
Object
.
defineProperty
(
exports
,
'__esModule'
,
{
value
:
true
});
function
_interopDefault
(
ex
)
{
return
(
ex
&&
(
typeof
ex
===
'object'
)
&&
'default'
in
ex
)
?
ex
[
'default'
]
:
ex
;
}
var
path
=
require
(
'path'
);
var
path
=
_interopDefault
(
require
(
'path'
));
require
(
'color'
);
require
(
'color'
);
var
generateUUID
=
_interopDefault
(
require
(
'uuid/v4'
));
var
generateUUID
=
require
(
'uuid/v4'
);
var
hash
=
_interopDefault
(
require
(
'object-hash'
));
var
hash
=
require
(
'object-hash'
);
var
zlib
=
_interopDefault
(
require
(
'zlib'
));
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.
* Created by rockyl on 2019-08-09.
...
@@ -92,6 +97,7 @@ const enterChar = String.fromCharCode(13);
...
@@ -92,6 +97,7 @@ const enterChar = String.fromCharCode(13);
async
function
execute
(
psdFile
,
options
)
{
async
function
execute
(
psdFile
,
options
)
{
const
tree
=
await
getTree
(
psdFile
);
const
tree
=
await
getTree
(
psdFile
);
console
.
log
(
'got tree:'
,
tree
);
const
{
mode
=
'none'
,
singleView
=
true
}
=
options
;
const
{
mode
=
'none'
,
singleView
=
true
}
=
options
;
let
offset
=
{
x
:
0
,
y
:
0
};
let
offset
=
{
x
:
0
,
y
:
0
};
let
cutSize
=
{
x
:
0
,
y
:
0
};
let
cutSize
=
{
x
:
0
,
y
:
0
};
...
@@ -110,9 +116,9 @@ async function execute(psdFile, options) {
...
@@ -110,9 +116,9 @@ async function execute(psdFile, options) {
const
isCenter
=
mode
===
'center'
;
const
isCenter
=
mode
===
'center'
;
let
viewRoot
=
{
let
viewRoot
=
{
name
:
path
.
basename
(
psdFile
.
name
,
'.psd'
),
name
:
path
__default
[
'default'
]
.
basename
(
psdFile
.
name
,
'.psd'
),
type
:
'node'
,
type
:
'node'
,
uuid
:
generateUUID
(),
uuid
:
generateUUID
__default
[
'default'
]
(),
};
};
const
assets
=
[];
const
assets
=
[];
...
@@ -125,7 +131,7 @@ async function execute(psdFile, options) {
...
@@ -125,7 +131,7 @@ async function execute(psdFile, options) {
await
walkNode
(
tree
,
async
function
(
node
,
parent
)
{
await
walkNode
(
tree
,
async
function
(
node
,
parent
)
{
let
{
name
}
=
node
;
let
{
name
}
=
node
;
const
{
x
,
y
,
width
,
height
,
alpha
,
visible
,
origin
:
{
layer
,
layer
:
{
typeTool
,
solidColor
}}}
=
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
=
{
let
properties
=
{
width
,
height
,
alpha
,
visible
,
width
,
height
,
alpha
,
visible
,
};
};
...
@@ -214,7 +220,7 @@ async function execute(psdFile, options) {
...
@@ -214,7 +220,7 @@ async function execute(psdFile, options) {
let
viewNode
=
{
let
viewNode
=
{
name
,
name
,
properties
,
properties
,
uuid
:
generateUUID
(),
uuid
:
generateUUID
__default
[
'default'
]
(),
};
};
let
dealLater
=
true
;
let
dealLater
=
true
;
let
px
=
x
;
// - (!singleView && isSecondLayer ? offset.x : 0);
let
px
=
x
;
// - (!singleView && isSecondLayer ? offset.x : 0);
...
@@ -266,7 +272,7 @@ async function execute(psdFile, options) {
...
@@ -266,7 +272,7 @@ async function execute(psdFile, options) {
}
else
{
}
else
{
viewNode
.
type
=
'image'
;
viewNode
.
type
=
'image'
;
let
uuid
=
generateUUID
();
let
uuid
=
generateUUID
__default
[
'default'
]
();
const
ext
=
'.png'
;
const
ext
=
'.png'
;
let
dataUrl
;
let
dataUrl
;
...
@@ -280,7 +286,7 @@ async function execute(psdFile, options) {
...
@@ -280,7 +286,7 @@ async function execute(psdFile, options) {
if
(
dataUrl
)
{
if
(
dataUrl
)
{
let
base64Data
=
dataUrl
.
replace
(
/^data:image
\/\w
+;base64,/
,
""
);
let
base64Data
=
dataUrl
.
replace
(
/^data:image
\/\w
+;base64,/
,
""
);
let
buffer
=
new
Buffer
(
base64Data
,
'base64'
);
let
buffer
=
new
Buffer
(
base64Data
,
'base64'
);
const
fileNameHash
=
hash
(
buffer
);
const
fileNameHash
=
hash
__default
[
'default'
]
(
buffer
);
if
(
imageHashMap
.
hasOwnProperty
(
fileNameHash
))
{
if
(
imageHashMap
.
hasOwnProperty
(
fileNameHash
))
{
uuid
=
imageHashMap
[
fileNameHash
];
uuid
=
imageHashMap
[
fileNameHash
];
}
else
{
}
else
{
...
@@ -317,7 +323,7 @@ async function execute(psdFile, options) {
...
@@ -317,7 +323,7 @@ async function execute(psdFile, options) {
let
buf
=
new
Buffer
(
dataString
);
let
buf
=
new
Buffer
(
dataString
);
return
await
new
Promise
((
resolve
,
reject
)
=>
{
return
await
new
Promise
((
resolve
,
reject
)
=>
{
zlib
.
gzip
(
buf
,
function
(
err
,
res
)
{
zlib
__default
[
'default'
]
.
gzip
(
buf
,
function
(
err
,
res
)
{
if
(
err
)
{
if
(
err
)
{
reject
(
err
);
reject
(
err
);
}
else
{
}
else
{
...
...
dist/index.js.map
View file @
90f70ab9
This diff is collapsed.
Click to expand it.
dist/index.umd.js
View file @
90f70ab9
(
function
(
global
,
factory
)
{
(
function
(
global
,
factory
)
{
typeof
exports
===
'object'
&&
typeof
module
!==
'undefined'
?
factory
(
exports
,
require
(
'path'
),
require
(
'color'
),
require
(
'uuid/v4'
),
require
(
'object-hash'
),
require
(
'zlib'
))
:
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
)
:
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
));
(
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'
;
}(
this
,
(
function
(
exports
,
path
,
color
,
generateUUID
,
hash
,
zlib
)
{
'use strict'
;
path
=
path
&&
path
.
hasOwnProperty
(
'default'
)
?
path
[
'default'
]
:
path
;
function
_interopDefaultLegacy
(
e
)
{
return
e
&&
typeof
e
===
'object'
&&
'default'
in
e
?
e
:
{
'default'
:
e
};
}
color
=
color
&&
color
.
hasOwnProperty
(
'default'
)
?
color
[
'default'
]
:
color
;
generateUUID
=
generateUUID
&&
generateUUID
.
hasOwnProperty
(
'default'
)
?
generateUUID
[
'default'
]
:
generateUUID
;
var
path__default
=
/*#__PURE__*/
_interopDefaultLegacy
(
path
);
hash
=
hash
&&
hash
.
hasOwnProperty
(
'default'
)
?
hash
[
'default'
]
:
hash
;
var
generateUUID__default
=
/*#__PURE__*/
_interopDefaultLegacy
(
generateUUID
);
zlib
=
zlib
&&
zlib
.
hasOwnProperty
(
'default'
)
?
zlib
[
'default'
]
:
zlib
;
var
hash__default
=
/*#__PURE__*/
_interopDefaultLegacy
(
hash
);
var
zlib__default
=
/*#__PURE__*/
_interopDefaultLegacy
(
zlib
);
/**
/**
* Created by rockyl on 2019-08-09.
* Created by rockyl on 2019-08-09.
...
@@ -92,6 +93,7 @@
...
@@ -92,6 +93,7 @@
async
function
execute
(
psdFile
,
options
)
{
async
function
execute
(
psdFile
,
options
)
{
const
tree
=
await
getTree
(
psdFile
);
const
tree
=
await
getTree
(
psdFile
);
console
.
log
(
'got tree:'
,
tree
);
const
{
mode
=
'none'
,
singleView
=
true
}
=
options
;
const
{
mode
=
'none'
,
singleView
=
true
}
=
options
;
let
offset
=
{
x
:
0
,
y
:
0
};
let
offset
=
{
x
:
0
,
y
:
0
};
let
cutSize
=
{
x
:
0
,
y
:
0
};
let
cutSize
=
{
x
:
0
,
y
:
0
};
...
@@ -110,9 +112,9 @@
...
@@ -110,9 +112,9 @@
const
isCenter
=
mode
===
'center'
;
const
isCenter
=
mode
===
'center'
;
let
viewRoot
=
{
let
viewRoot
=
{
name
:
path
.
basename
(
psdFile
.
name
,
'.psd'
),
name
:
path
__default
[
'default'
]
.
basename
(
psdFile
.
name
,
'.psd'
),
type
:
'node'
,
type
:
'node'
,
uuid
:
generateUUID
(),
uuid
:
generateUUID
__default
[
'default'
]
(),
};
};
const
assets
=
[];
const
assets
=
[];
...
@@ -125,7 +127,7 @@
...
@@ -125,7 +127,7 @@
await
walkNode
(
tree
,
async
function
(
node
,
parent
)
{
await
walkNode
(
tree
,
async
function
(
node
,
parent
)
{
let
{
name
}
=
node
;
let
{
name
}
=
node
;
const
{
x
,
y
,
width
,
height
,
alpha
,
visible
,
origin
:
{
layer
,
layer
:
{
typeTool
,
solidColor
}}}
=
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
=
{
let
properties
=
{
width
,
height
,
alpha
,
visible
,
width
,
height
,
alpha
,
visible
,
};
};
...
@@ -214,7 +216,7 @@
...
@@ -214,7 +216,7 @@
let
viewNode
=
{
let
viewNode
=
{
name
,
name
,
properties
,
properties
,
uuid
:
generateUUID
(),
uuid
:
generateUUID
__default
[
'default'
]
(),
};
};
let
dealLater
=
true
;
let
dealLater
=
true
;
let
px
=
x
;
// - (!singleView && isSecondLayer ? offset.x : 0);
let
px
=
x
;
// - (!singleView && isSecondLayer ? offset.x : 0);
...
@@ -266,7 +268,7 @@
...
@@ -266,7 +268,7 @@
}
else
{
}
else
{
viewNode
.
type
=
'image'
;
viewNode
.
type
=
'image'
;
let
uuid
=
generateUUID
();
let
uuid
=
generateUUID
__default
[
'default'
]
();
const
ext
=
'.png'
;
const
ext
=
'.png'
;
let
dataUrl
;
let
dataUrl
;
...
@@ -280,7 +282,7 @@
...
@@ -280,7 +282,7 @@
if
(
dataUrl
)
{
if
(
dataUrl
)
{
let
base64Data
=
dataUrl
.
replace
(
/^data:image
\/\w
+;base64,/
,
""
);
let
base64Data
=
dataUrl
.
replace
(
/^data:image
\/\w
+;base64,/
,
""
);
let
buffer
=
new
Buffer
(
base64Data
,
'base64'
);
let
buffer
=
new
Buffer
(
base64Data
,
'base64'
);
const
fileNameHash
=
hash
(
buffer
);
const
fileNameHash
=
hash
__default
[
'default'
]
(
buffer
);
if
(
imageHashMap
.
hasOwnProperty
(
fileNameHash
))
{
if
(
imageHashMap
.
hasOwnProperty
(
fileNameHash
))
{
uuid
=
imageHashMap
[
fileNameHash
];
uuid
=
imageHashMap
[
fileNameHash
];
}
else
{
}
else
{
...
@@ -317,7 +319,7 @@
...
@@ -317,7 +319,7 @@
let
buf
=
new
Buffer
(
dataString
);
let
buf
=
new
Buffer
(
dataString
);
return
await
new
Promise
((
resolve
,
reject
)
=>
{
return
await
new
Promise
((
resolve
,
reject
)
=>
{
zlib
.
gzip
(
buf
,
function
(
err
,
res
)
{
zlib
__default
[
'default'
]
.
gzip
(
buf
,
function
(
err
,
res
)
{
if
(
err
)
{
if
(
err
)
{
reject
(
err
);
reject
(
err
);
}
else
{
}
else
{
...
@@ -333,5 +335,5 @@
...
@@ -333,5 +335,5 @@
Object
.
defineProperty
(
exports
,
'__esModule'
,
{
value
:
true
});
Object
.
defineProperty
(
exports
,
'__esModule'
,
{
value
:
true
});
}));
}))
)
;
//# sourceMappingURL=index.umd.js.map
//# sourceMappingURL=index.umd.js.map
dist/index.umd.js.map
View file @
90f70ab9
This diff is collapsed.
Click to expand it.
psd-parse-web.iml
View file @
90f70ab9
...
@@ -2,9 +2,8 @@
...
@@ -2,9 +2,8 @@
<module
type=
"WEB_MODULE"
version=
"4"
>
<module
type=
"WEB_MODULE"
version=
"4"
>
<component
name=
"NewModuleRootManager"
inherit-compiler-output=
"true"
>
<component
name=
"NewModuleRootManager"
inherit-compiler-output=
"true"
>
<exclude-output
/>
<exclude-output
/>
<content
url=
"file://$MODULE_DIR$"
>
<content
url=
"file://$MODULE_DIR$"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/dist"
/>
<orderEntry
type=
"inheritedJdk"
/>
</content>
<orderEntry
type=
"sourceFolder"
forTests=
"false"
/>
<orderEntry
type=
"sourceFolder"
forTests=
"false"
/>
</component>
</component>
</module>
</module>
\ No newline at end of file
src/zeroing.js
View file @
90f70ab9
...
@@ -33,6 +33,7 @@ const enterChar = String.fromCharCode(13);
...
@@ -33,6 +33,7 @@ const enterChar = String.fromCharCode(13);
export
async
function
execute
(
psdFile
,
options
)
{
export
async
function
execute
(
psdFile
,
options
)
{
const
tree
=
await
getTree
(
psdFile
);
const
tree
=
await
getTree
(
psdFile
);
console
.
log
(
'got tree:'
,
tree
);
const
{
mode
=
'none'
,
singleView
=
true
}
=
options
;
const
{
mode
=
'none'
,
singleView
=
true
}
=
options
;
let
offset
=
{
x
:
0
,
y
:
0
};
let
offset
=
{
x
:
0
,
y
:
0
};
let
cutSize
=
{
x
:
0
,
y
:
0
};
let
cutSize
=
{
x
:
0
,
y
:
0
};
...
@@ -66,7 +67,7 @@ export async function execute(psdFile, options) {
...
@@ -66,7 +67,7 @@ export async function execute(psdFile, options) {
await
walkNode
(
tree
,
async
function
(
node
,
parent
)
{
await
walkNode
(
tree
,
async
function
(
node
,
parent
)
{
let
{
name
}
=
node
;
let
{
name
}
=
node
;
const
{
x
,
y
,
width
,
height
,
alpha
,
visible
,
origin
:
{
layer
,
layer
:
{
typeTool
,
solidColor
}}}
=
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
=
{
let
properties
=
{
width
,
height
,
alpha
,
visible
,
width
,
height
,
alpha
,
visible
,
};
};
...
...
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