Initial commit

This commit is contained in:
MMaker 2021-04-13 16:06:13 -04:00 committed by stysmmaker
commit 0164914750
Signed by: mmaker
GPG key ID: CCE79B8FEDA40FB2
10 changed files with 377 additions and 0 deletions

11
src/index.test.ts Normal file
View 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
View 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
View file

@ -0,0 +1 @@
export const fromOtherFile = 'value in another file';