Skip to content

Commit 62f8206

Browse files
committed
add basic readme
1 parent d337b20 commit 62f8206

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# expression-globals-typescript
2+
3+
This library mocks the After Effects expressions API in TypeScript, providing types and the available global functions and variables.
4+
5+
> To be used with [rollup-plugin-ae-jsx](https://www.npmjs.com/package/rollup-plugin-ae-jsx), which will convert the code to After Effects friendly `.jsx` files and remove the globals imported from this package.
6+
7+
## Usage
8+
9+
1. Install
10+
11+
```sh
12+
npm install expression-globals-typescript --save-dev
13+
```
14+
15+
Found in our [Expressions Library Template](https://github.com/motiondeveloper/expressions-library-template).
16+
17+
2. Import globals functions as needed
18+
19+
```js
20+
import {
21+
timeToFrames,
22+
add,
23+
length,
24+
random,
25+
} from "expression-globals-typescript";
26+
```
27+
28+
3. Import object bases to create layer, comp, and property mocks
29+
30+
```js
31+
import {
32+
PropertyBase,
33+
LayerBase,
34+
CompBase,
35+
} from "expression-globals-typescript";
36+
37+
const thisProperty = Object.create(PropertyBase);
38+
const thisLayer = Object.create(LayerBase);
39+
const thisComp = Object.create(CompBase);
40+
```
41+
42+
You can then use the properties and methods of these objects as you would within expressions.
43+
44+
## Why?
45+
46+
When writing expressions in **Typescript** using our [Expressions Library Template](https://github.com/motiondeveloper/expressions-library-template) and [rollup-plugin-ae-jsx](https://www.npmjs.com/package/rollup-plugin-ae-jsx), TypeScript will complain if you try to use the global functions and objects available in expressions.
47+
48+
This is because they aren't defined in the development environment.
49+
50+
`expression-globals-typescript` solves this by mocking the entire expressions API in TypeScript, so you can import and use these globals, with the advantages of them being fully typed.

0 commit comments

Comments
 (0)