Skip to content

Visualize Your Ideas With Code

ci: add pull request verification

aarthificial1f348564ef60
diff --git a/.eslintrc.json b/.eslintrc.json
index 708075a7..68c2e855 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -3,6 +3,7 @@
"browser": true,
"es2021": true
},
+ "ignorePatterns": ["**/*.js"],
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml
new file mode 100644
index 00000000..f51d6b68
--- /dev/null
+++ b/.github/workflows/verify.yml
@@ -0,0 +1,17 @@
+name: Test and Build the Package
+
+on:
+ pull_request: {}
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ - uses: actions/setup-node@v3
+ with:
+ node-version: 16
+ - run: npm ci
+ - run: npm run lint
+ - run: npm run prettier
+ - run: npm run build
diff --git a/package.json b/package.json
index ce89e56a..c1f76283 100644
--- a/package.json
+++ b/package.json
@@ -10,6 +10,8 @@
"watch": "tsc -w",
"lint": "eslint \"src/**/*.ts?(x)\"",
"lint:fix": "eslint --fix \"src/**/*.ts?(x)\"",
+ "prettier": "prettier --check \"src/**/*\"",
+ "prettier:fix": "prettier --write \"src/**/*\"",
"release": "semantic-release"
},
"publishConfig": {
diff --git a/src/components/Connection.ts b/src/components/Connection.ts
index 52cbb64b..3538b3e3 100644
--- a/src/components/Connection.ts
+++ b/src/components/Connection.ts
@@ -152,7 +152,12 @@ export class Connection extends Group {
}
public isDirty(): boolean {
- return this.attrs.dirty || this.start.wasDirty() || this.end.wasDirty() || this.crossing?.wasDirty();
+ return (
+ this.attrs.dirty ||
+ this.start.wasDirty() ||
+ this.end.wasDirty() ||
+ this.crossing?.wasDirty()
+ );
}
public updateLayout() {
diff --git a/src/components/LayoutText.ts b/src/components/LayoutText.ts
index 0d197f9e..98edec49 100644
--- a/src/components/LayoutText.ts
+++ b/src/components/LayoutText.ts
@@ -38,13 +38,13 @@ export class LayoutText extends Text {
size = {
width: this.textWidth,
height: this.textHeight,
- }
+ };
this.text(text);
} else {
size = {
width: this.textWidth,
height: this.textHeight,
- }
+ };
}
return {
diff --git a/src/components/Sprite.ts b/src/components/Sprite.ts
index 25fe4f11..7d306d0f 100644
--- a/src/components/Sprite.ts
+++ b/src/components/Sprite.ts
@@ -256,7 +256,7 @@ export class Sprite extends Shape {
g: this.imageData.data[id + 1],
b: this.imageData.data[id + 2],
a: this.imageData.data[id + 3],
- }
+ };
}
public positionToId(position: Vector2d): number {
diff --git a/src/components/ThreeView.ts b/src/components/ThreeView.ts
index 0d281e01..84d28970 100644
--- a/src/components/ThreeView.ts
+++ b/src/components/ThreeView.ts
@@ -3,7 +3,7 @@ import {Util} from 'konva/lib/Util';
import {Context} from 'konva/lib/Context';
import * as THREE from 'three';
import {CanvasHelper} from '../helpers';
-import {GetSet} from "konva/lib/types";
+import {GetSet} from 'konva/lib/types';
import {getset, KonvaNode} from '../decorators';
import {Shape, ShapeConfig} from 'konva/lib/Shape';
@@ -47,19 +47,19 @@ const rendererPool = new RendererPool();
@KonvaNode()
export class ThreeView extends Shape {
@getset(null)
- public scene: GetSet<ThreeViewConfig['scene'], this>
+ public scene: GetSet<ThreeViewConfig['scene'], this>;
@getset(null)
- public camera: GetSet<ThreeViewConfig['camera'], this>
+ public camera: GetSet<ThreeViewConfig['camera'], this>;
@getset({width: 0, height: 0}, ThreeView.prototype.handleCanvasSizeChange)
- public canvasSize: GetSet<ThreeViewConfig['canvasSize'], this>
+ public canvasSize: GetSet<ThreeViewConfig['canvasSize'], this>;
@getset(1, ThreeView.prototype.handleCanvasSizeChange)
- public cameraScale: GetSet<ThreeViewConfig['cameraScale'], this>
+ public cameraScale: GetSet<ThreeViewConfig['cameraScale'], this>;
@getset(1, ThreeView.prototype.handleCanvasSizeChange)
- public quality: GetSet<ThreeViewConfig['quality'], this>
+ public quality: GetSet<ThreeViewConfig['quality'], this>;
@getset(0)
- public skipFrames: GetSet<ThreeViewConfig['skipFrames'], this>
+ public skipFrames: GetSet<ThreeViewConfig['skipFrames'], this>;
@getset(0)
- public radius: GetSet<ThreeViewConfig['radius'], this>
+ public radius: GetSet<ThreeViewConfig['radius'], this>;
private readonly renderer: THREE.WebGLRenderer;
private readonly context: WebGLRenderingContext;
diff --git a/src/components/Video.tsx b/src/components/Video.tsx
index 73d29c00..3149efdd 100644
--- a/src/components/Video.tsx
+++ b/src/components/Video.tsx
@@ -41,8 +41,8 @@ export class Video extends Shape {
0,
this.width(),
this.height(),
- this.radius()
- )
+ this.radius(),
+ ),
);
if (frames.length) {
context.drawImage(frames[this.frame() % frames.length], 0, 0);
diff --git a/src/components/index.ts b/src/components/index.ts
index 3127362d..b0911220 100644
--- a/src/components/index.ts
+++ b/src/components/index.ts
@@ -14,4 +14,4 @@ export * from './Range';
export * from './Sprite';
export * from './Surface';
export * from './ThreeView';
-export * from './Video';
\ No newline at end of file
+export * from './Video';
diff --git a/src/decorators/decorate.ts b/src/decorators/decorate.ts
index ff359501..053a7b68 100644
--- a/src/decorators/decorate.ts
+++ b/src/decorators/decorate.ts
@@ -1,7 +1,4 @@
-export function decorate(
- fn: Callback,
- ...decorators: MethodDecorator[]
-) {
+export function decorate(fn: Callback, ...decorators: MethodDecorator[]) {
const target = {[fn.name]: fn};
const descriptor = Object.getOwnPropertyDescriptor(target, fn.name);
for (let i = decorators.length - 1; i >= 0; i--) {
diff --git a/src/flow/every.ts b/src/flow/every.ts
index 6363b967..b19f8ede 100644
--- a/src/flow/every.ts
+++ b/src/flow/every.ts
@@ -1,6 +1,6 @@
import {ThreadGenerator} from '../threading';
import {decorate, threadable} from '../decorators';
-import { useProject } from "../utils";
+import {useProject} from '../utils';
export function every(seconds: number, callback: (frame: number) => void) {
let changed = false;
diff --git a/src/jsx-runtime.ts b/src/jsx-runtime.ts
index 64cc0b84..fa55a42e 100644
--- a/src/jsx-runtime.ts
+++ b/src/jsx-runtime.ts
@@ -4,8 +4,10 @@ import type {Reference} from './utils';
import {Container} from 'konva/lib/Container';
import {Surface} from './components';
-// eslint-disable-next-line @typescript-eslint/ban-types
-function isConstructor(fn: Function): fn is new (...args: unknown[]) => unknown {
+function isConstructor(
+ // eslint-disable-next-line @typescript-eslint/ban-types
+ fn: Function,
+): fn is new (...args: unknown[]) => unknown {
return !!fn.prototype?.name;
}
diff --git a/src/player/index.ts b/src/player/index.ts
index 38112423..3d0862b6 100644
--- a/src/player/index.ts
+++ b/src/player/index.ts
@@ -1 +1 @@
-export * from './Player';
\ No newline at end of file
+export * from './Player';
diff --git a/src/styles/index.ts b/src/styles/index.ts
index 766e846d..d7807416 100644
--- a/src/styles/index.ts
+++ b/src/styles/index.ts
@@ -1 +1 @@
-export * from './Style';
\ No newline at end of file
+export * from './Style';
diff --git a/src/symbols.ts b/src/symbols.ts
index 71b7ba68..bd245087 100644
--- a/src/symbols.ts
+++ b/src/symbols.ts
@@ -1,2 +1,2 @@
export const ANIMATE = Symbol.for('ANIMATE');
-export const NODE_ID = Symbol.for('NODE_ID');
\ No newline at end of file
+export const NODE_ID = Symbol.for('NODE_ID');
diff --git a/src/themes/index.ts b/src/themes/index.ts
index b0a9eeb9..d18a4e09 100644
--- a/src/themes/index.ts
+++ b/src/themes/index.ts
@@ -1 +1 @@
-export * from './code';
\ No newline at end of file
+export * from './code';
diff --git a/src/threading/cancel.ts b/src/threading/cancel.ts
index 8e139dc2..7b195e2a 100644
--- a/src/threading/cancel.ts
+++ b/src/threading/cancel.ts
@@ -7,7 +7,9 @@ export interface CancelYieldResult {
[THREAD_CANCEL]: ThreadGenerator[];
}
-export function isCancelYieldResult(value: unknown): value is CancelYieldResult {
+export function isCancelYieldResult(
+ value: unknown,
+): value is CancelYieldResult {
return typeof value === 'object' && THREAD_CANCEL in value;
}
diff --git a/src/tweening/tween.ts b/src/tweening/tween.ts
index 595a47b0..b88ada5c 100644
--- a/src/tweening/tween.ts
+++ b/src/tweening/tween.ts
@@ -1,6 +1,6 @@
import {decorate, threadable} from '../decorators';
import {ThreadGenerator} from '../threading';
-import { useProject } from "../utils";
+import {useProject} from '../utils';
decorate(tween, threadable());
export function* tween(
diff --git a/src/types/Origin.ts b/src/types/Origin.ts
index 7c08c88d..b4e5aba4 100644
--- a/src/types/Origin.ts
+++ b/src/types/Origin.ts
@@ -1,4 +1,4 @@
-import {Vector2d} from "konva/lib/types";
+import {Vector2d} from 'konva/lib/types';
import {Size} from './Size';
export enum Center {
@@ -50,7 +50,11 @@ export function flipOrigin(
return origin;
}
-export function originPosition(origin: Origin | Direction, width = 1 , height = 1): Vector2d {
+export function originPosition(
+ origin: Origin | Direction,
+ width = 1,
+ height = 1,
+): Vector2d {
const position: Vector2d = {x: 0, y: 0};
if (origin === Origin.Middle) {
@@ -87,4 +91,4 @@ export function getOriginDelta(size: Size, from: Origin, to: Origin) {
x: toOffset.x - fromOffset.x,
y: toOffset.y - fromOffset.y,
};
-}
\ No newline at end of file
+}
diff --git a/src/types/Size.ts b/src/types/Size.ts
index 82637b39..a6a439b5 100644
--- a/src/types/Size.ts
+++ b/src/types/Size.ts
@@ -1,4 +1,4 @@
export interface Size {
width: number;
height: number;
-}
\ No newline at end of file
+}
diff --git a/src/types/index.ts b/src/types/index.ts
index 9b96017f..f62a8403 100644
--- a/src/types/index.ts
+++ b/src/types/index.ts
@@ -1,3 +1,3 @@
export * from './Origin';
export * from './Size';
-export * from './Spacing';
\ No newline at end of file
+export * from './Spacing';
diff --git a/src/utils/useAnimator.ts b/src/utils/useAnimator.ts
index 54a5a13d..ccb5708b 100644
--- a/src/utils/useAnimator.ts
+++ b/src/utils/useAnimator.ts
@@ -1,4 +1,4 @@
-import { Animator } from "../tweening";
+import {Animator} from '../tweening';
export function useAnimator<T>(initial: T, onUpdate: (value: T) => void) {
const object = {
@@ -13,4 +13,4 @@ export function useAnimator<T>(initial: T, onUpdate: (value: T) => void) {
};
return () => new Animator<T, typeof object>(object, 'value');
-}
\ No newline at end of file
+}
diff --git a/src/utils/useProject.ts b/src/utils/useProject.ts
index 7d2c7753..20e83e59 100644
--- a/src/utils/useProject.ts
+++ b/src/utils/useProject.ts
@@ -1,5 +1,5 @@
-import { useScene } from "./useScene";
+import {useScene} from './useScene';
export function useProject() {
return useScene().project;
-}
\ No newline at end of file
+}
diff --git a/src/video/MP4Demuxer.js b/src/video/MP4Demuxer.js
index 5e24743e..467aef34 100644
--- a/src/video/MP4Demuxer.js
+++ b/src/video/MP4Demuxer.js
@@ -13,7 +13,7 @@ class MP4Source {
let mp4File = this.file;
function appendBuffers({done, value}) {
- if(done) {
+ if (done) {
mp4File.flush();
return;
}
@@ -29,7 +29,7 @@ class MP4Source {
}
return reader.read().then(appendBuffers);
- })
+ });
this.info = null;
this._info_resolver = null;
@@ -46,15 +46,16 @@ class MP4Source {
}
getInfo() {
- if (this.info)
- return Promise.resolve(this.info);
+ if (this.info) return Promise.resolve(this.info);
- return new Promise((resolver) => { this._info_resolver = resolver; });
+ return new Promise(resolver => {
+ this._info_resolver = resolver;
+ });
}
getAvccBox() {
// TODO: make sure this is coming from the right track.
- return this.file.moov.traks[0].mdia.minf.stbl.stsd.entries[0].avcC
+ return this.file.moov.traks[0].mdia.minf.stbl.stsd.entries[0].avcC;
}
start(track, onChunk) {
@@ -65,13 +66,13 @@ class MP4Source {
onSamples(track_id, ref, samples) {
for (const sample of samples) {
- const type = sample.is_sync ? "key" : "delta";
+ const type = sample.is_sync ? 'key' : 'delta';
const chunk = new EncodedVideoChunk({
type: type,
timestamp: sample.cts,
duration: sample.duration,
- data: sample.data
+ data: sample.data,
});
this._onChunk(chunk);
@@ -87,8 +88,8 @@ class Writer {
}
getData() {
- if(this.idx != this.size)
- throw "Mismatch between size reserved and sized used"
+ if (this.idx != this.size)
+ throw 'Mismatch between size reserved and sized used';
return this.data.slice(0, this.idx);
}
@@ -104,7 +105,7 @@ class Writer {
arr[0] = value;
var buffer = new Uint8Array(arr.buffer);
this.data.set([buffer[1], buffer[0]], this.idx);
- this.idx +=2;
+ this.idx += 2;
}
writeUint8Array(value) {
@@ -123,11 +124,11 @@ export class MP4Demuxer {
var size = 7;
for (i = 0; i < avccBox.SPS.length; i++) {
// nalu length is encoded as a uint16.
- size+= 2 + avccBox.SPS[i].length;
+ size += 2 + avccBox.SPS[i].length;
}
for (i = 0; i < avccBox.PPS.length; i++) {
// nalu length is encoded as a uint16.
- size+= 2 + avccBox.PPS[i].length;
+ size += 2 + avccBox.PPS[i].length;
}
var writer = new Writer(size);
@@ -136,9 +137,9 @@ export class MP4Demuxer {
writer.writeUint8(avccBox.AVCProfileIndication);
writer.writeUint8(avccBox.profile_compatibility);
writer.writeUint8(avccBox.AVCLevelIndication);
- writer.writeUint8(avccBox.lengthSizeMinusOne + (63<<2));
+ writer.writeUint8(avccBox.lengthSizeMinusOne + (63 << 2));
- writer.writeUint8(avccBox.nb_SPS_nalus + (7<<5));
+ writer.writeUint8(avccBox.nb_SPS_nalus + (7 << 5));
for (i = 0; i < avccBox.SPS.length; i++) {
writer.writeUint16(avccBox.SPS[i].length);
writer.writeUint8Array(avccBox.SPS[i].nalu);
@@ -164,7 +165,7 @@ export class MP4Demuxer {
codedHeight: this.track.video.height,
codedWidth: this.track.video.width,
description: extradata,
- }
+ };
return Promise.resolve(config);
}
@@ -172,4 +173,4 @@ export class MP4Demuxer {
start(onChunk) {
this.source.start(this.track, onChunk);
}
-}
\ No newline at end of file
+}