Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ module.exports = {

// variables
"@typescript-eslint/no-unused-vars": [ "warn" ], // draw yellow line under unused vars
"no-undef": [ "warn" ], // draws yellow line under undefined vars
// "no-undef": [ "warn" ], // draws yellow line under undefined vars // it doesn't work on typescript sometimes
"no-var": [ "error" ], // fuck you, var
"prefer-const": [ "error" ], // const is better than let

Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/dist
/docs
/types
/ts*
/node_modules
**/*.log
**/*.log
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
"repository": "https://github.com/FMS-Cat/automaton",
"author": "FMS-Cat",
"types": "types/index.d.ts",
"typesVersions": {
"<3.8": { "*": [ "ts3.4/*" ] }
},
"license": "MIT",
"scripts": {
"dev": "webpack-dev-server --hot --mode development",
Expand All @@ -15,7 +18,7 @@
"build": "yarn build-dev && yarn build-prod && yarn types",
"build-dev": "webpack --mode development",
"build-prod": "webpack --mode production",
"types": "tsc --emitDeclarationOnly",
"types": "tsc --emitDeclarationOnly && downlevel-dts . ts3.4",
"docs": "typedoc --out docs --mode file --excludeNotExported",
"lint": "eslint \"src/**/*.ts\"",
"test": "jest"
Expand All @@ -31,6 +34,7 @@
"@types/jest": "^25.1.4",
"@typescript-eslint/eslint-plugin": "^2.23.0",
"@typescript-eslint/parser": "^2.23.0",
"downlevel-dts": "^0.4.0",
"eslint": "^6.8.0",
"eslint-plugin-jest": "^23.8.2",
"fork-ts-checker-webpack-plugin": "^4.1.0",
Expand All @@ -40,7 +44,7 @@
"rimraf": "^3.0.2",
"ts-jest": "^25.2.1",
"ts-loader": "^6.2.1",
"typedoc": "^0.16.11",
"typedoc": "^0.17.6",
"typescript": "^3.8.3",
"webpack": "^4.42.0",
"webpack-cli": "^3.3.11",
Expand Down
7 changes: 4 additions & 3 deletions src/Automaton.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Channel, ChannelUpdateEvent } from './Channel';
import { Channel } from './Channel';
import type { ChannelUpdateEvent } from './types/ChannelUpdateEvent';
import { Curve } from './Curve';
import { FxDefinition } from './types/FxDefinition';
import { SerializedAutomaton } from './types/SerializedAutomaton';
import type { FxDefinition } from './types/FxDefinition';
import type { SerializedAutomaton } from './types/SerializedAutomaton';

/**
* IT'S AUTOMATON!
Expand Down
33 changes: 2 additions & 31 deletions src/Channel.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,7 @@
import { Automaton } from './Automaton';
import { ChannelItem } from './ChannelItem';
import { SerializedChannel } from './types/SerializedChannel';

/**
* Represent an event that is emitted by [[Channel.update]].
*/
export interface ChannelUpdateEvent {
/**
* Current time in the current item.
*/
time: number;

/**
* Current value of the channel.
*/
value: number;

/**
* `true` if the update was the first call of the item.
*/
init?: true;

/**
* `true` if the update was the last call of the item.
*/
uninit?: true;

/**
* The progress of the item.
*/
progress: number;
}
import type { ChannelUpdateEvent } from './types/ChannelUpdateEvent';
import type { SerializedChannel } from './types/SerializedChannel';

/**
* It represents a channel of Automaton.
Expand Down
2 changes: 1 addition & 1 deletion src/ChannelItem.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Automaton, Curve } from '.';
import { SerializedChannelItem } from './types/SerializedChannelItem';
import type { SerializedChannelItem } from './types/SerializedChannelItem';

/**
* Represents an item of a [[Channel]].
Expand Down
8 changes: 4 additions & 4 deletions src/Curve.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Automaton } from './Automaton';
import { BezierNode } from './types/BezierNode';
import { FxContext } from './types/FxDefinition';
import { FxSection } from './types/FxSection';
import { SerializedCurve } from './types/SerializedCurve';
import type { BezierNode } from './types/BezierNode';
import type { FxContext } from './types/FxDefinition';
import type { FxSection } from './types/FxSection';
import type { SerializedCurve } from './types/SerializedCurve';
import { bezierEasing } from './utils/bezierEasing';

/**
Expand Down
13 changes: 11 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
export * from './types';
export type { BezierControlPoint, BezierNode, SerializedBezierNode } from './types/BezierNode';
export type { FxContext, FxDefinition, FxParam } from './types/FxDefinition';
export type { FxSection, SerializedFxSection } from './types/FxSection';
export type { SerializedAutomaton } from './types/SerializedAutomaton';
export type { SerializedChannel } from './types/SerializedChannel';
export type { SerializedChannelItem } from './types/SerializedChannelItem';
export type { SerializedCurve } from './types/SerializedCurve';

export { Automaton } from './Automaton';
export { Channel, ChannelUpdateEvent } from './Channel';
export { Channel } from './Channel';
export { ChannelItem } from './ChannelItem';
export { Curve } from './Curve';

import { Automaton } from './Automaton';
export default Automaton;
4 changes: 2 additions & 2 deletions src/tests/Automaton.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-env jest */

import { Automaton } from '../Automaton';
import { ChannelUpdateEvent } from '../Channel';
import { SerializedAutomaton } from '../types';
import type { ChannelUpdateEvent } from '../types/ChannelUpdateEvent';
import type { SerializedAutomaton } from '../types/SerializedAutomaton';

const data: SerializedAutomaton = {
resolution: 100.0,
Expand Down
3 changes: 2 additions & 1 deletion src/tests/Channel.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
/* eslint-env jest */

import { SerializedAutomaton, SerializedChannel } from '../types';
import { Automaton } from '../Automaton';
import { Channel } from '../Channel';
import type { SerializedAutomaton } from '../types/SerializedAutomaton';
import type { SerializedChannel } from '../types/SerializedChannel';

const data: SerializedAutomaton = {
resolution: 100.0,
Expand Down
29 changes: 29 additions & 0 deletions src/types/ChannelUpdateEvent.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* Represent an event that is emitted by [[Channel.update]].
*/
export interface ChannelUpdateEvent {
/**
* Current time in the current item.
*/
time: number;

/**
* Current value of the channel.
*/
value: number;

/**
* `true` if the update was the first call of the item.
*/
init?: true;

/**
* `true` if the update was the last call of the item.
*/
uninit?: true;

/**
* The progress of the item.
*/
progress: number;
}
4 changes: 2 additions & 2 deletions src/types/SerializedAutomaton.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SerializedChannel } from './SerializedChannel';
import { SerializedCurve } from './SerializedCurve';
import type { SerializedChannel } from './SerializedChannel';
import type { SerializedCurve } from './SerializedCurve';

/**
* Interface of serialized automaton data.
Expand Down
2 changes: 1 addition & 1 deletion src/types/SerializedChannel.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SerializedChannelItem } from './SerializedChannelItem';
import type { SerializedChannelItem } from './SerializedChannelItem';

/**
* Interface of a serialized channel.
Expand Down
4 changes: 2 additions & 2 deletions src/types/SerializedCurve.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SerializedBezierNode } from './BezierNode';
import { SerializedFxSection } from './FxSection';
import type { SerializedBezierNode } from './BezierNode';
import type { SerializedFxSection } from './FxSection';

/**
* Interface of a serialized curve.
Expand Down
7 changes: 0 additions & 7 deletions src/types/index.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/utils/bezierEasing.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BezierNode } from '../types/BezierNode';
import type { BezierNode } from '../types/BezierNode';

interface CubicBezierControlPoints {
p0: number;
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
"declarationDir": "./types"
},
"include": [ "src" ],
"exclude": [ "node_modules" ]
"exclude": [ "node_modules", "**/tests/**/*" ]
}
Loading