Skip to content

Commit 70f7953

Browse files
ff6347lumenn-home
andauthored
Feature extendscript es5 shim (#53)
Feature extendscript es5 shim Co-authored-by: lumenn-home <[email protected]>
2 parents ebd1ea8 + 46423e7 commit 70f7953

File tree

6 files changed

+89
-10
lines changed

6 files changed

+89
-10
lines changed

.all-contributorsrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,16 @@
6464
"contributions": [
6565
"maintenance"
6666
]
67+
},
68+
{
69+
"login": "lumenn",
70+
"name": "silmelumenn",
71+
"avatar_url": "https://avatars0.githubusercontent.com/u/15074603?v=4",
72+
"profile": "http://lumenn.pl",
73+
"contributions": [
74+
"code",
75+
"test"
76+
]
6777
}
6878
],
6979
"commitConvention": "none"

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# Extendscriptr
22

3-
[![All Contributors](https://img.shields.io/badge/all_contributors-6-orange.svg?style=flat-square)](#contributors) [![npm version](https://badge.fury.io/js/extendscriptr.svg?style=flat-square)](https://badge.fury.io/js/extendscriptr) [![Join the chat at https://gitter.im/vogelino/extendscriptr](https://badges.gitter.im/vogelino/extendscriptr.svg?style=flat-square)](https://gitter.im/vogelino/extendscriptr?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![travis](https://travis-ci.org/ExtendScript/extendscriptr.svg?style=flat-square)](https://travis-ci.org/ExtendScript/extendscriptr)
3+
[![All Contributors](https://img.shields.io/badge/all_contributors-7-orange.svg?style=flat-square)](#contributors) [![npm version](https://badge.fury.io/js/extendscriptr.svg?style=flat-square)](https://badge.fury.io/js/extendscriptr) [![Join the chat at https://gitter.im/vogelino/extendscriptr](https://badges.gitter.im/vogelino/extendscriptr.svg?style=flat-square)](https://gitter.im/vogelino/extendscriptr?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![travis](https://travis-ci.org/ExtendScript/extendscriptr.svg?style=flat-square)](https://travis-ci.org/ExtendScript/extendscriptr)
44

55
Extendscriptr is NPM CLI module that allows you to benefit of many modern javascript features of es5 and es6 in a es3 extendscript environment.
66

77
## Why
88

99
Building scripts for Adobe products (mostly used for After Effects, InDesign, Photoshop or Illustrator) can be pain for the finger nails if you are used to proper javascript environments.
1010

11-
Extendscriptr relies on [`extendscript.prototypes`](https://github.com/fabiantheblind/extendscript.prototypes) and focuses on mostly used prototypes as a priority that are tested in the different Adobe applications. This dependency will be improved over time to covers always more es5 and es6 features. Contributions are welcome!
11+
Extendscriptr relies on [`extendscript-es5-shim`](https://github.com/ExtendScript/extendscript-es5-shim) and focuses on mostly used prototypes as a priority that are tested in the different Adobe applications. This dependency will be improved over time to covers always more es5 and es6 features. Contributions are welcome!
1212

1313
Extendscriptr doesn't use an existing full-stack polyfills like `babel-polyfill`, `es5-shim` or `shim.js` as they are intended for the browser and don't work well in adobe applications.
1414

@@ -56,7 +56,7 @@ WTFPL - Do whatever the fuck you want
5656

5757
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
5858
<!-- prettier-ignore -->
59-
<table><tr><td align="center"><a href="http://www.vogelino.com"><img src="https://avatars0.githubusercontent.com/u/2759340?v=4" width="50px;" alt="Lucas Vogel"/><br /><sub><b>Lucas Vogel</b></sub></a><br /><a href="https://github.com/ExtendScript/extendscriptr/commits?author=vogelino" title="Code">💻</a> <a href="#design-vogelino" title="Design">🎨</a></td><td align="center"><a href="https://fabianmoronzirfas.me"><img src="https://avatars3.githubusercontent.com/u/315106?v=4" width="50px;" alt="Fabian Morón Zirfas"/><br /><sub><b>Fabian Morón Zirfas</b></sub></a><br /><a href="#question-fabianmoronzirfas" title="Answering Questions">💬</a> <a href="#design-fabianmoronzirfas" title="Design">🎨</a></td><td align="center"><a href="http://brunoherfst.com"><img src="https://avatars2.githubusercontent.com/u/1421477?v=4" width="50px;" alt="Bruno Herfst"/><br /><sub><b>Bruno Herfst</b></sub></a><br /><a href="https://github.com/ExtendScript/extendscriptr/commits?author=GitBruno" title="Code">💻</a></td><td align="center"><a href="http://andydayton.com"><img src="https://avatars1.githubusercontent.com/u/151084?v=4" width="50px;" alt="Andy Dayton"/><br /><sub><b>Andy Dayton</b></sub></a><br /><a href="https://github.com/ExtendScript/extendscriptr/commits?author=andyinabox" title="Code">💻</a></td><td align="center"><a href="https://github.com/stefanomasini"><img src="https://avatars2.githubusercontent.com/u/1584765?v=4" width="50px;" alt="Stefano Masini"/><br /><sub><b>Stefano Masini</b></sub></a><br /><a href="https://github.com/ExtendScript/extendscriptr/commits?author=stefanomasini" title="Code">💻</a></td><td align="center"><a href="https://bsky.moe"><img src="https://avatars3.githubusercontent.com/u/38746192?v=4" width="50px;" alt="bsky"/><br /><sub><b>bsky</b></sub></a><br /><a href="#maintenance-imbsky" title="Maintenance">🚧</a></td></tr></table>
59+
<table><tr><td align="center"><a href="http://www.vogelino.com"><img src="https://avatars0.githubusercontent.com/u/2759340?v=4" width="50px;" alt="Lucas Vogel"/><br /><sub><b>Lucas Vogel</b></sub></a><br /><a href="https://github.com/ExtendScript/extendscriptr/commits?author=vogelino" title="Code">💻</a> <a href="#design-vogelino" title="Design">🎨</a></td><td align="center"><a href="https://fabianmoronzirfas.me"><img src="https://avatars3.githubusercontent.com/u/315106?v=4" width="50px;" alt="Fabian Morón Zirfas"/><br /><sub><b>Fabian Morón Zirfas</b></sub></a><br /><a href="#question-fabianmoronzirfas" title="Answering Questions">💬</a> <a href="#design-fabianmoronzirfas" title="Design">🎨</a></td><td align="center"><a href="http://brunoherfst.com"><img src="https://avatars2.githubusercontent.com/u/1421477?v=4" width="50px;" alt="Bruno Herfst"/><br /><sub><b>Bruno Herfst</b></sub></a><br /><a href="https://github.com/ExtendScript/extendscriptr/commits?author=GitBruno" title="Code">💻</a></td><td align="center"><a href="http://andydayton.com"><img src="https://avatars1.githubusercontent.com/u/151084?v=4" width="50px;" alt="Andy Dayton"/><br /><sub><b>Andy Dayton</b></sub></a><br /><a href="https://github.com/ExtendScript/extendscriptr/commits?author=andyinabox" title="Code">💻</a></td><td align="center"><a href="https://github.com/stefanomasini"><img src="https://avatars2.githubusercontent.com/u/1584765?v=4" width="50px;" alt="Stefano Masini"/><br /><sub><b>Stefano Masini</b></sub></a><br /><a href="https://github.com/ExtendScript/extendscriptr/commits?author=stefanomasini" title="Code">💻</a></td><td align="center"><a href="https://bsky.moe"><img src="https://avatars3.githubusercontent.com/u/38746192?v=4" width="50px;" alt="bsky"/><br /><sub><b>bsky</b></sub></a><br /><a href="#maintenance-imbsky" title="Maintenance">🚧</a></td><td align="center"><a href="http://lumenn.pl"><img src="https://avatars0.githubusercontent.com/u/15074603?v=4" width="50px;" alt="silmelumenn"/><br /><sub><b>silmelumenn</b></sub></a><br /><a href="https://github.com/ExtendScript/extendscriptr/commits?author=lumenn" title="Code">💻</a> <a href="https://github.com/ExtendScript/extendscriptr/commits?author=lumenn" title="Tests">⚠️</a></td></tr></table>
6060

6161
<!-- ALL-CONTRIBUTORS-LIST:END -->
6262

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ extendscriptr.options.forEach(function(opt) {
2727
);
2828
});
2929

30-
var prototypePolyfills = fs.readFileSync(require.resolve('extendscript.prototypes'), 'utf8');
30+
var prototypePolyfills = fs.readFileSync(require.resolve('extendscript-es5-shim'), 'utf8');
3131
var browserifyPlugins = [ [ prependify, prototypePolyfills ] ];
3232

3333
var adobeTarget = String(extendscriptr.target).toLowerCase();

package-lock.json

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"browserify": "^16.2.3",
5252
"commander": "^2.15.1",
5353
"contributors": "^0.5.1",
54-
"extendscript.prototypes": "0.1.1",
54+
"extendscript-es5-shim": "^0.2.0",
5555
"prependify": "^1.3.0"
5656
},
5757
"devDependencies": {

test/src/illustrator.js

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,74 @@ feel more connected, bringing delight in big and \
2424
small ways, and empowering them to affect change."';
2525

2626
const fontStyle = text1.textRange.characterAttributes;
27-
fontStyle.textFont = app.textFonts.getByName("Courier");
27+
fontStyle.textFont = app.textFonts.getByName("MyriadPro-Bold");
2828
fontStyle.size = 2.5;
29+
30+
// Tests for Array methods
31+
32+
lib.write('### TESTING ARRAY METHODS ###');
33+
34+
lib.write('Testing map function');
35+
const testArray = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1];
36+
testArray.map(number => lib.write(`map = ${number} out of ${testArray.length - 1} = ${number * 4}`));
37+
38+
const reduceResult = testArray.reduce((acc, curr) => acc + curr, 0);
39+
lib.write(`Testing reduce function = ${reduceResult}`);
40+
41+
lib.write('Testing forEach function');
42+
testArray.forEach(value => lib.write(`forEach = ${value}`));
43+
44+
45+
lib.write('Testing filter function');
46+
47+
const filteredArray = testArray.filter( (number) => {
48+
if(number % 2 === 0) {
49+
return true;
50+
}
51+
return false;
52+
});
53+
54+
filteredArray.forEach(number => lib.write(`Filter = ${number}`));
55+
56+
lib.write('Testing every function');
57+
testArray.every(number => {
58+
if (number < 3) {
59+
lib.write(`Every = ${number}`);
60+
return true;
61+
}
62+
return false;
63+
});
64+
65+
lib.write('Testing indexOf function');
66+
lib.write(testArray.indexOf(4));
67+
68+
lib.write('Testing isArray function');
69+
const notArray = 10;
70+
lib.write(Array.isArray(notArray));
71+
lib.write(Array.isArray(testArray));
72+
73+
lib.write('Testing lastIndexOf function');
74+
lib.write(testArray.lastIndexOf(1));
75+
76+
lib.write('Testing reduceRight function');
77+
const reduceRightResult = testArray.reduceRight((acc, curr) => acc + curr, 0);
78+
lib.write(`Testing reduce function = ${reduceRightResult}`);
79+
80+
81+
// Tests for Date methods
82+
lib.write('### TESTING Date METHODS ###');
83+
84+
const today = new Date();
85+
lib.write(today.toISOString());
86+
87+
// Tests for Date methods
88+
lib.write('### TESTING Function METHODS ###');
89+
lib.write('### TESTING Object METHODS ###');
90+
91+
//TODO implement testing Fuction and Object methods
92+
93+
lib.write('### TESTING String METHODS ###');
94+
const newString = ' ThisIsSomeWordToTrim ';
95+
96+
lib.write(`Before trimming: ${newString}`);
97+
lib.write(`After trimming: ${newString.trim()}`);

0 commit comments

Comments
 (0)