Initial commit
This commit is contained in:
commit
0164914750
10 changed files with 377 additions and 0 deletions
11
src/index.test.ts
Normal file
11
src/index.test.ts
Normal file
|
@ -0,0 +1,11 @@
|
|||
import { welcome } from './index';
|
||||
|
||||
jest.mock('expression-globals-typescript', () => ({
|
||||
Layer: jest.fn(),
|
||||
Comp: jest.fn(),
|
||||
Property: jest.fn(),
|
||||
}));
|
||||
|
||||
test('returns correct welcome string', () => {
|
||||
expect(welcome('test')).toEqual('Welcome test!');
|
||||
});
|
31
src/index.ts
Normal file
31
src/index.ts
Normal file
|
@ -0,0 +1,31 @@
|
|||
// Importing object bases (CompBase, LayerBase, PropertyBase)
|
||||
// TypeScript types (Layer, Comp, Value, Color etc)
|
||||
// and global functions from 'expression-globals-typescript'
|
||||
import { Comp, Layer } from 'expression-globals-typescript';
|
||||
import { fromOtherFile } from './otherFile';
|
||||
|
||||
// Creating a new composition object from CompBase
|
||||
const thisComp = new Comp();
|
||||
const thisLayer = new Layer();
|
||||
|
||||
// Using the expression types in a function
|
||||
function getLayerDuration(layerName: string) {
|
||||
const layer: Layer = thisComp.layer(layerName);
|
||||
return layer.outPoint - layer.inPoint;
|
||||
}
|
||||
|
||||
// Using expressions global functions
|
||||
function remap(value: number) {
|
||||
return thisLayer.linear(value, 0, 10, 0, 1);
|
||||
}
|
||||
|
||||
function welcome(name: string): string {
|
||||
return `Welcome ${name}!`;
|
||||
}
|
||||
|
||||
const someValue: number = 2;
|
||||
|
||||
const version: string = '_npmVersion';
|
||||
|
||||
// Export values to appear in jsx files
|
||||
export { getLayerDuration, remap, welcome, someValue, version, fromOtherFile };
|
1
src/otherFile.ts
Normal file
1
src/otherFile.ts
Normal file
|
@ -0,0 +1 @@
|
|||
export const fromOtherFile = 'value in another file';
|
Loading…
Add table
Add a link
Reference in a new issue