Skip to content

Commit 6e74bbe

Browse files
committed
init
0 parents  commit 6e74bbe

File tree

9 files changed

+11827
-0
lines changed

9 files changed

+11827
-0
lines changed

.gitignore

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
lerna-debug.log*
8+
9+
# Diagnostic reports (https://nodejs.org/api/report.html)
10+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
11+
12+
# Runtime data
13+
pids
14+
*.pid
15+
*.seed
16+
*.pid.lock
17+
18+
# Directory for instrumented libs generated by jscoverage/JSCover
19+
lib-cov
20+
21+
# Coverage directory used by tools like istanbul
22+
coverage
23+
*.lcov
24+
25+
# nyc test coverage
26+
.nyc_output
27+
28+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
29+
.grunt
30+
31+
# Bower dependency directory (https://bower.io/)
32+
bower_components
33+
34+
# node-waf configuration
35+
.lock-wscript
36+
37+
# Compiled binary addons (https://nodejs.org/api/addons.html)
38+
build/Release
39+
40+
# Dependency directories
41+
node_modules/
42+
jspm_packages/
43+
44+
# TypeScript v1 declaration files
45+
typings/
46+
47+
# TypeScript cache
48+
*.tsbuildinfo
49+
50+
# Optional npm cache directory
51+
.npm
52+
53+
# Optional eslint cache
54+
.eslintcache
55+
56+
# Microbundle cache
57+
.rpt2_cache/
58+
.rts2_cache_cjs/
59+
.rts2_cache_es/
60+
.rts2_cache_umd/
61+
62+
# Optional REPL history
63+
.node_repl_history
64+
65+
# Output of 'npm pack'
66+
*.tgz
67+
68+
# Yarn Integrity file
69+
.yarn-integrity
70+
71+
# dotenv environment variables file
72+
.env
73+
.env.test
74+
75+
# parcel-bundler cache (https://parceljs.org/)
76+
.cache
77+
78+
# Next.js build output
79+
.next
80+
dist
81+
82+
# Nuxt.js build / generate output
83+
.nuxt
84+
85+
# Gatsby files
86+
.cache/
87+
# Comment in the public line in if your project uses Gatsby and *not* Next.js
88+
# https://nextjs.org/blog/next-9-1#public-directory-support
89+
# public
90+
91+
# vuepress build output
92+
.vuepress/dist
93+
94+
# Serverless directories
95+
.serverless/
96+
97+
# FuseBox cache
98+
.fusebox/
99+
100+
# DynamoDB Local files
101+
.dynamodb/
102+
103+
# TernJS port file
104+
.tern-port

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
# style-parser
2+
3+
> This project was create with [create-expression-lib](https://github.com/motiondeveloper/create-expression-lib)
4+
5+
## Use the library
6+
7+
1. Download the latest version from the releases page.
8+
2. Import into After Effects and reference in your expressions
9+
10+
Learn more about writing `.jsx` files for After Effects here: https://motiondeveloper.com/blog/write-expressions-external-files/
11+
12+
## Development
13+
14+
1. **Clone project locally**
15+
16+
```sh
17+
git clone repoUrl.git
18+
cd style-parser
19+
```
20+
21+
2. **Start Rollup**
22+
23+
Start Rollup in watch mode to automatically refresh your code as you make changes, by running:
24+
25+
```sh
26+
npm run watch
27+
```
28+
29+
_You can run also run a once off build:_ `npm run build`
30+
31+
3. **Edit the `src` files**
32+
33+
_The `index.ts` contains an example expression setup._
34+
35+
Any values exported from this file will be included in your library, for example:
36+
37+
```js
38+
export { someValue };
39+
```
40+
41+
4. **Import the `dist` file into After Effects**
42+
43+
Use the compiled output file as you would any other `.jsx` library. Any changes to the `src` files will be live updated, and After Effects will update the result of your expression.
44+
45+
5. **Distribute releases**
46+
47+
To distribute your output file using Github releases (via [Hub](https://github.com/github/hub)), use the command:
48+
49+
```sh
50+
npm run release
51+
```
52+
53+
This will use the GitHub CLI to create a new tag and release
54+
55+
The release version number is the `"version"` in `package.json`, and it will attach the `"main"` file to the release.
56+
57+
> You can add this version to the output file by placing the string `_npmVersion` in your code, which will be replaced with the version number in `package.json` at build time.
58+
59+
## After Effects API
60+
61+
> This template uses the [`expression-globals-typescript`](https://github.com/motiondeveloper/expression-globals-typescript) package to provide types for the expressions API.
62+
63+
### Classes
64+
65+
To create layers, compositions and properties, you can use the classes exported from the library. For example:
66+
67+
```ts
68+
import { Comp, Layer } from 'expression-globals-typescript';
69+
const thisComp = new Comp();
70+
const thisLayer = new Layer();
71+
```
72+
73+
To create properties (such as position or scale), you can use the `Property` class.
74+
75+
```ts
76+
import { Property, Vector } from 'expression-globals-typescript';
77+
const thisProperty = new Property<Vector>([0, 100]);
78+
```
79+
80+
> The `Property` constructor takes a value to set as the property value, and a type (`<>`) to set as the type for the property.
81+
82+
### After Effects Types
83+
84+
You can import After Effect's specific types such as `Color` and `Vector` from the package to properly type your expressions.
85+
86+
#### _To see all the Types and Base Objects available, see the [`expression-globals-typescript`](https://github.com/motiondeveloper/expression-globals-typescript) source code._
87+
88+
## Testing
89+
90+
You can test your expression library code using [Jest](https://jestjs.io/), which comes pre-configured in this template repo.
91+
92+
You write tests in the `index.test.ts` file, importing the code you want to test from `index.ts`, for example:
93+
94+
```ts
95+
import { welcome } from './index';
96+
97+
test('returns correct welcome string', () => {
98+
expect(welcome('test')).toEqual('Welcome test!');
99+
});
100+
```
101+
102+
And then run the test suite:
103+
104+
```sh
105+
npm run test
106+
```
107+
108+
Which will run Jest in watch mode.
109+
110+
> You can learn more about testing using Jest from the [Jest docs](https://jestjs.io/docs/en/getting-started).
111+
112+
## Configuration
113+
114+
There a couple of files you may wish to change to reflect the content of your project:
115+
116+
- `package.json`:
117+
- `version`: The current version of the library, which is used for releases and added to `dist` files.
118+
- `main`: The build output file which will be attached to releases
119+
- `rollup.config.js`:
120+
- `input`: The source file to be built
121+
- `typescript()`: Custom typescript compiler options
122+
123+
## How
124+
125+
- [expression-globals-typescript](https://github.com/motiondeveloper/expression-globals-typescript) mocks the After Effects expressions API in typescript, so you can use global functions and objects such as `linear()` and `time`, while also providing expression specific types such as `Layer`.
126+
127+
- [Rollup](https://rollupjs.org/) is a lightweight module bundler that handles outputting the `.jsx` file via the plugins below.
128+
129+
- The Rollup [Typescript plugin](https://www.npmjs.com/package/@rollup/plugin-typescript) runs the TypeScript compiler
130+
131+
- The Rollup plugin [rollup-plugin-ae-jsx](https://www.npmjs.com/package/rollup-plugin-ae-jsx) transforms the JavaScript output into After Effects JSON (`.jsx`) compliant syntax
132+
133+
- Testing via [Jest](https://jestjs.io/), and [ts-jest](https://github.com/kulshekhar/ts-jest)

jest.config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
preset: 'ts-jest',
3+
testEnvironment: 'node',
4+
};

0 commit comments

Comments
 (0)