Skip to content

Commit 429a986

Browse files
committed
Refactor workflow
1 parent 45d5e03 commit 429a986

File tree

8 files changed

+88
-41
lines changed

8 files changed

+88
-41
lines changed

dist/explode_shape_layer.jsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
1+
var configs = {
2+
title: 'Explode layer tool',
3+
log : true,
4+
itemAmountWarning : 50,
5+
};
6+
17
function consLog(text) {
28
if (configs.log)
39
$.writeln(text);
410
}
511

612
function listMatchNames(object) {
7-
consLog("LISTING ?")
13+
814
for(var i=1; i <= object.numProperties; i++) {
915

1016
var prop = object.property(i);
@@ -277,10 +283,4 @@ function createUI(thisObj) {
277283

278284
}
279285

280-
var configs = {
281-
title: 'Explode layer tool',
282-
log : true,
283-
itemAmountWarning : 50,
284-
};
285-
286286
var myToolsPanel = createUI(this);

dist/explode_shape_layer.min.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
function consLog(e){configs.log&&$.writeln(e)}function listMatchNames(e){consLog("LISTING ?");for(var o=1;o<=e.numProperties;o++){var r=e.property(o);consLog(r.matchName+"("+r.name+")")}}function explodeLayer(e){if(consLog("==============\n=============="),e.length>1)alert("Select a single shape layer");else{var o=e[0];if(void 0!=o&&"ADBE Vector Layer"===o.matchName){var r=o.containingComp,t=o.property("Contents"),p=[];if(!(t.numProperties>configs.itemAmountWarning)||confirm("You have more than "+configs.itemAmountWarning+" elements. Execution time might be long, are you sure you want to continue ?")){for(n=t.numProperties;n>0;n--){var c=t.property(n);if(c.enabled){var a=r.layers.addShape();a.name=c.name,a.enabled=!1,p.push(a),copyLayerTransform(o,a),insertPropertyToContents(c,a.property("Contents"),"")}}for(var n=0;n<p.length;n++)p[n].enabled=!0}}else alert("Select a shape layer")}}function insertPropertyToContents(e,o,r){if(!o.canAddProperty(e.matchName))return!1;for(var t=o.addProperty(e.matchName),p=1;p<=e.numProperties;p++){var c=e.property(p);if(c.enabled&&t.canAddProperty(c.matchName)){consLog(r+c.matchName);var a=t.property(c.matchName)?t.property(c.matchName):t.addProperty(c.matchName);switch(c.matchName){case"ADBE Vector Filter - Merge":copyProperty("mode",c,a);break;case"ADBE Vector Materials Group":consLog(r+"-- skipped");break;case"ADBE Vector Graphic - Stroke":copyPropertyStroke(c,a);break;case"ADBE Vector Graphic - Fill":copyPropertyFill(c,a);break;case"ADBE Vector Transform Group":copyPropertyTransform(c,a);break;case"ADBE Vector Shape - Rect":copyPropertyRect(c,a);break;case"ADBE Vector Shape - Ellipse":copyPropertyEllipse(c,a);break;case"ADBE Vector Shape - Star":copyPropertyStar(c,a);break;case"ADBE Root Vectors Group":case"ADBE Vectors Group":case"ADBE Vector Group":insertPropertyToContents(c,t,r+=" ");break;case"ADBE Vector Shape - Group":copyPropertyShape(c,a);break;default:a.setValue(c.value)}}}}function copyProperty(e,o,r){r[e].setValue(o[e].value)}function copyPropertyShape(e,o){o.property("ADBE Vector Shape").setValue(e.property("ADBE Vector Shape").value)}function copyPropertyStroke(e,o){copyProperty("composite",e,o),copyProperty("color",e,o),copyProperty("strokeWidth",e,o),copyProperty("lineCap",e,o),copyProperty("lineJoin",e,o),copyProperty("miterLimit",e,o)}function copyPropertyFill(e,o){copyProperty("composite",e,o),copyProperty("fillRule",e,o),copyProperty("color",e,o)}function copyPropertyTransform(e,o){copyProperty("anchorPoint",e,o),copyProperty("position",e,o),copyProperty("scale",e,o),copyProperty("skew",e,o),copyProperty("skewAxis",e,o),copyProperty("rotation",e,o),copyProperty("opacity",e,o)}function copyLayerTransform(e,o){copyProperty("anchorPoint",e,o),copyProperty("position",e,o),copyProperty("scale",e,o),copyProperty("rotation",e,o),copyProperty("opacity",e,o)}function copyPropertyRect(e,o){copyProperty("shapeDirection",e,o),copyProperty("size",e,o),copyProperty("position",e,o),copyProperty("roundness",e,o)}function copyPropertyEllipse(e,o){copyProperty("shapeDirection",e,o),copyProperty("size",e,o),copyProperty("position",e,o)}function copyPropertyStar(e,o){copyProperty("shapeDirection",e,o),copyProperty("type",e,o),copyProperty("points",e,o),copyProperty("position",e,o),copyProperty("rotation",e,o),copyProperty("innerRadius",e,o),copyProperty("outerRadius",e,o),copyProperty("innerRoundness",e,o),copyProperty("outerRoundness",e,o)}function createUI(e){if(e instanceof Panel)var o=e;else(o=new Window("palette",configs.title,void 0,{resizeable:!0})).show();var r=o.add("button",[10,10,100,30],"Explode layer");return o.text=configs.title,o.bounds.width=120,o.bounds.height=40,r.onClick=function(){var e=(new Date).getTime();explodeLayer(app.project.activeItem.selectedLayers),consLog("Execution time : "+((new Date).getTime()-e)+"ms")},o}var configs={title:"Explode layer tool",log:!0,itemAmountWarning:50},myToolsPanel=createUI(this);
1+
function consLog(e){configs.log&&$.writeln(e)}function listMatchNames(e){for(var o=1;o<=e.numProperties;o++){var r=e.property(o);consLog(r.matchName+"("+r.name+")")}}function explodeLayer(e){if(consLog("==============\n=============="),e.length>1)alert("Select a single shape layer");else{var o=e[0];if(void 0!=o&&"ADBE Vector Layer"===o.matchName){var r=o.containingComp,t=o.property("Contents"),p=[];if(!(t.numProperties>configs.itemAmountWarning)||confirm("You have more than "+configs.itemAmountWarning+" elements. Execution time might be long, are you sure you want to continue ?")){for(n=t.numProperties;n>0;n--){var c=t.property(n);if(c.enabled){var a=r.layers.addShape();a.name=c.name,a.enabled=!1,p.push(a),copyLayerTransform(o,a),insertPropertyToContents(c,a.property("Contents"),"")}}for(var n=0;n<p.length;n++)p[n].enabled=!0}}else alert("Select a shape layer")}}function insertPropertyToContents(e,o,r){if(!o.canAddProperty(e.matchName))return!1;for(var t=o.addProperty(e.matchName),p=1;p<=e.numProperties;p++){var c=e.property(p);if(c.enabled&&t.canAddProperty(c.matchName)){consLog(r+c.matchName);var a=t.property(c.matchName)?t.property(c.matchName):t.addProperty(c.matchName);switch(c.matchName){case"ADBE Vector Filter - Merge":copyProperty("mode",c,a);break;case"ADBE Vector Materials Group":consLog(r+"-- skipped");break;case"ADBE Vector Graphic - Stroke":copyPropertyStroke(c,a);break;case"ADBE Vector Graphic - Fill":copyPropertyFill(c,a);break;case"ADBE Vector Transform Group":copyPropertyTransform(c,a);break;case"ADBE Vector Shape - Rect":copyPropertyRect(c,a);break;case"ADBE Vector Shape - Ellipse":copyPropertyEllipse(c,a);break;case"ADBE Vector Shape - Star":copyPropertyStar(c,a);break;case"ADBE Root Vectors Group":case"ADBE Vectors Group":case"ADBE Vector Group":insertPropertyToContents(c,t,r+=" ");break;case"ADBE Vector Shape - Group":copyPropertyShape(c,a);break;default:a.setValue(c.value)}}}}function copyProperty(e,o,r){r[e].setValue(o[e].value)}function copyPropertyShape(e,o){o.property("ADBE Vector Shape").setValue(e.property("ADBE Vector Shape").value)}function copyPropertyStroke(e,o){copyProperty("composite",e,o),copyProperty("color",e,o),copyProperty("strokeWidth",e,o),copyProperty("lineCap",e,o),copyProperty("lineJoin",e,o),copyProperty("miterLimit",e,o)}function copyPropertyFill(e,o){copyProperty("composite",e,o),copyProperty("fillRule",e,o),copyProperty("color",e,o)}function copyPropertyTransform(e,o){copyProperty("anchorPoint",e,o),copyProperty("position",e,o),copyProperty("scale",e,o),copyProperty("skew",e,o),copyProperty("skewAxis",e,o),copyProperty("rotation",e,o),copyProperty("opacity",e,o)}function copyLayerTransform(e,o){copyProperty("anchorPoint",e,o),copyProperty("position",e,o),copyProperty("scale",e,o),copyProperty("rotation",e,o),copyProperty("opacity",e,o)}function copyPropertyRect(e,o){copyProperty("shapeDirection",e,o),copyProperty("size",e,o),copyProperty("position",e,o),copyProperty("roundness",e,o)}function copyPropertyEllipse(e,o){copyProperty("shapeDirection",e,o),copyProperty("size",e,o),copyProperty("position",e,o)}function copyPropertyStar(e,o){copyProperty("shapeDirection",e,o),copyProperty("type",e,o),copyProperty("points",e,o),copyProperty("position",e,o),copyProperty("rotation",e,o),copyProperty("innerRadius",e,o),copyProperty("outerRadius",e,o),copyProperty("innerRoundness",e,o),copyProperty("outerRoundness",e,o)}function createUI(e){if(e instanceof Panel)var o=e;else(o=new Window("palette",configs.title,void 0,{resizeable:!0})).show();var r=o.add("button",[10,10,100,30],"Explode layer");return o.text=configs.title,o.bounds.width=120,o.bounds.height=40,r.onClick=function(){var e=(new Date).getTime();explodeLayer(app.project.activeItem.selectedLayers),consLog("Execution time : "+((new Date).getTime()-e)+"ms")},o}var configs={title:"Explode layer tool",log:!0,itemAmountWarning:50},myToolsPanel=createUI(this);

gulpfile.js

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,46 @@
11
var gulp = require('gulp');
2+
var pump = require('pump');
23
var rename = require('gulp-rename');
34
var uglify = require('gulp-uglify');
45
var resolveDependencies = require('gulp-resolve-dependencies');
56
var concat = require('gulp-concat');
67

7-
gulp.task('prod', function () {
8+
gulp.task('dev', function (cb) {
89

9-
gulp.src('src/explode_shape_layer.jsx')
10-
.pipe(resolveDependencies({
11-
pattern: /\* @requires [\s-]*(.*\.jsx)/g
12-
}))
13-
.on('error', function(err) { console.log(err.message); })
14-
.pipe(concat('explode_shape_layer.jsx'))
15-
.pipe(rename('./explode_shape_layer.jsx'))
16-
.pipe(gulp.dest('dist/'))
17-
.pipe(rename('./explode_shape_layer.min.jsx'))
18-
.pipe(uglify())
19-
.pipe(gulp.dest('dist/'));
10+
pump(
11+
[
12+
gulp.src(['src/config-dev.jsx', 'src/explode_shape_layer.jsx']),
13+
resolveDependencies({ pattern: /\* @requires [\s-]*(.*\.jsx)/g }),
14+
concat('explode_shape_layer.jsx'),
15+
gulp.dest('dist/'),
16+
rename('explode_shape_layer.min.jsx'),
17+
uglify(),
18+
gulp.dest('dist/')
19+
],
20+
cb
21+
);
2022

2123
});
2224

23-
gulp.task('watch', ['prod'], function () {
25+
gulp.task('prod', function (cb) {
2426

25-
gulp.watch('src/*', ['prod']);
27+
pump(
28+
[
29+
gulp.src(['src/config-prod.jsx', 'src/explode_shape_layer.jsx']),
30+
resolveDependencies({ pattern: /\* @requires [\s-]*(.*\.jsx)/g }),
31+
concat('explode_shape_layer.jsx'),
32+
gulp.dest('dist/'),
33+
rename('explode_shape_layer.min.jsx'),
34+
uglify(),
35+
gulp.dest('dist/')
36+
],
37+
cb
38+
);
39+
40+
});
41+
42+
gulp.task('watch', ['dev'], function () {
43+
44+
gulp.watch('src/*', ['dev']);
2645

2746
});

package-lock.json

Lines changed: 36 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/config-dev.jsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
var configs = {
2+
title: 'Explode layer tool',
3+
log : true,
4+
itemAmountWarning : 50,
5+
};

src/config-prod.jsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
var configs = {
2+
title: 'Explode layer tool',
3+
log : false,
4+
itemAmountWarning : 50,
5+
};

src/explode_shape_layer.jsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -261,10 +261,4 @@ function createUI(thisObj) {
261261

262262
}
263263

264-
var configs = {
265-
title: 'Explode layer tool',
266-
log : true,
267-
itemAmountWarning : 50,
268-
};
269-
270264
var myToolsPanel = createUI(this);

src/utils.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ function consLog(text) {
44
}
55

66
function listMatchNames(object) {
7-
consLog("LISTING ?")
7+
88
for(var i=1; i <= object.numProperties; i++) {
99

1010
var prop = object.property(i);

0 commit comments

Comments
 (0)