Skip to content

Commit

Permalink
fix: execute prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
xpadev-net committed Oct 19, 2023
1 parent 512f323 commit 6b04c0b
Show file tree
Hide file tree
Showing 17 changed files with 41 additions and 41 deletions.
2 changes: 1 addition & 1 deletion src/contexts/commentHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const addHandler = (
scopes: T_scope[],
trace: A_ANY[],
time: number,
duration?: number
duration?: number,
) => {
handlers.push({
script,
Expand Down
2 changes: 1 addition & 1 deletion src/contexts/queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const addQueue = (
script: A_ANY,
offset: number,
scopes: T_scope[],
trace: A_ANY[]
trace: A_ANY[],
) => {
queue.push({
script,
Expand Down
2 changes: 1 addition & 1 deletion src/definition/fonts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const build = (fonts: FontItem[]): FontItem => {
pv.font += `, ${val.font}`;
return pv;
},
{ font: "", offset: 0, weight: 600 }
{ font: "", offset: 0, weight: 600 },
);
};

Expand Down
4 changes: 2 additions & 2 deletions src/functions/commentTrigger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ const processCommentTrigger: IrFunction = (script, scopes, _, trace) => {
scopes,
["then", "timer"],
trace,
false
false,
);
addHandler(
args.then as A_ANY,
scopes,
trace,
currentTime,
args.timer ? Number(Core.execute(args.timer, scopes, trace)) : undefined
args.timer ? Number(Core.execute(args.timer, scopes, trace)) : undefined,
);
};

Expand Down
4 changes: 2 additions & 2 deletions src/functions/drawShape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const processDrawShape: IrFunction = (
script: A_CallExpression,
scopes: T_scope[],
_,
trace
trace,
) => {
const args = Core.utils.argumentParser(
script.arguments,
Expand All @@ -38,7 +38,7 @@ const processDrawShape: IrFunction = (
"rotation",
"mover",
],
trace
trace,
);
return new IrShape(args);
};
Expand Down
4 changes: 2 additions & 2 deletions src/functions/drawText.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const processDrawText: IrFunction = (
script: A_CallExpression,
scopes: T_scope[],
_,
trace
trace,
) => {
const args = Core.utils.argumentParser(
script.arguments,
Expand All @@ -37,7 +37,7 @@ const processDrawText: IrFunction = (
"mover",
"scale",
],
trace
trace,
);
return new IrText(args);
};
Expand Down
2 changes: 1 addition & 1 deletion src/functions/rand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const processRand: IrFunction = (
script: A_CallExpression,
scopes: T_scope[],
_,
trace: A_ANY[]
trace: A_ANY[],
) => {
if (script.arguments[0]) {
return rand(Core.execute(script.arguments[0], scopes, trace));
Expand Down
6 changes: 3 additions & 3 deletions src/functions/timer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ const processTimer: IrFunction = (
script: A_CallExpression,
scopes: T_scope[],
_,
trace: A_ANY[]
trace: A_ANY[],
) => {
const args = Core.utils.argumentParser(
script.arguments,
scopes,
["timer", "then"],
trace,
false
false,
);
typeof args.then === "object" &&
addQueue(
args.then as A_ANY,
Number(Core.execute(args.timer, scopes, trace)),
scopes,
[...trace]
[...trace],
);
};

Expand Down
6 changes: 3 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Niwango {
private lastVpos: number;
constructor(
targetElement: HTMLCanvasElement | HTMLDivElement,
comments: Comment[]
comments: Comment[],
) {
setup();
initConfig();
Expand Down Expand Up @@ -104,7 +104,7 @@ class Niwango {
}
}
const tasks = [...getQueue(i), ...getScripts(i), ...getComments(i)].sort(
nativeSort("time")
nativeSort("time"),
);
while (tasks.length > 0) {
const queue = tasks.shift();
Expand All @@ -129,7 +129,7 @@ class Niwango {
queue.type === "queue"
? queue.scopes
: [globalScope, environmentScope, Core.prototypeScope],
trace
trace,
);
} catch (e) {
console.error(e);
Expand Down
12 changes: 6 additions & 6 deletions src/objects/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ abstract class IrObject {
this.options.x = input;
if (this.mover === "") return;
const lastQueue = this.moverQueue.filter(
(queue) => queue.vpos === currentTime
(queue) => queue.vpos === currentTime,
)[0];
let currentPos, targetPos;
if (!lastQueue) {
Expand All @@ -91,7 +91,7 @@ abstract class IrObject {
}
console.log(
`mover-x: ${JSON.stringify(currentPos)} to ${JSON.stringify(targetPos)}`,
this.mover
this.mover,
);
this.__updateMoverQueue(lastQueue, currentPos, targetPos);
}
Expand Down Expand Up @@ -149,7 +149,7 @@ abstract class IrObject {
this.options.y = input;
if (this.mover === "") return;
const lastQueue = this.moverQueue.filter(
(queue) => queue.vpos === currentTime
(queue) => queue.vpos === currentTime,
)[0];
let currentPos, targetPos;
if (!lastQueue) {
Expand All @@ -161,7 +161,7 @@ abstract class IrObject {
}
console.log(
`mover-y: ${JSON.stringify(currentPos)} to ${JSON.stringify(targetPos)}`,
this.mover
this.mover,
);
this.__updateMoverQueue(lastQueue, currentPos, targetPos);
}
Expand Down Expand Up @@ -263,7 +263,7 @@ abstract class IrObject {
protected __updateMoverQueue(
lastQueue: IrObjectMoverItem | undefined,
currentPos: IrObjectPos,
targetPos: IrObjectPos
targetPos: IrObjectPos,
) {
const diff = {
x: targetPos.x - currentPos.x,
Expand Down Expand Up @@ -301,7 +301,7 @@ abstract class IrObject {
protected __filterMoverQueue() {
if (this.mover === "") return;
this.moverQueue = this.moverQueue.filter(
(item) => item.vpos + item.duration > currentTime
(item) => item.vpos + item.duration > currentTime,
);
const currentItem = this.moverQueue[0];
if (this.mover !== "hopping" && this.moverQueue.length > 4 && currentItem) {
Expand Down
2 changes: 1 addition & 1 deletion src/objects/shape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ class IrShape extends IrObject {
this.height / 2,
0,
0,
360
360,
);
context.fill();
}
Expand Down
12 changes: 6 additions & 6 deletions src/objects/text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class IrText extends IrObject {

__updateFont() {
getCanvas(
this.__id
this.__id,
).context.font = `normal 600 ${this.__size}px Arial, "MS Pゴシック", "MS PGothic", MSPGothic, MS-PGothic`;
}

Expand Down Expand Up @@ -238,14 +238,14 @@ class IrText extends IrObject {
posX,
posY,
part.width * this.__size,
this.__size * config.lineHeight
this.__size * config.lineHeight,
);
}
context.fillRect(
posX,
posY,
part.width * this.__size,
this.__size * config.lineHeight
this.__size * config.lineHeight,
);
break;
}
Expand Down Expand Up @@ -300,7 +300,7 @@ class IrText extends IrObject {
0,
0,
canvasBlur025.width,
canvasBlur025.height
canvasBlur025.height,
);
canvasBlur050
.getContext("2d")
Expand All @@ -313,7 +313,7 @@ class IrText extends IrObject {
0,
0,
canvasBlur050.width,
canvasBlur050.height
canvasBlur050.height,
);
context.clearRect(0, 0, canvas.width, canvas.height);
context.drawImage(
Expand All @@ -325,7 +325,7 @@ class IrText extends IrObject {
0,
0,
canvas.width,
canvas.height
canvas.height,
);
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/render/canvas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class CanvasRender implements IRender {
this.renderContext = renderContext;
this.renderContext.scale(
1920 / config.canvasWidth,
1080 / config.canvasHeight
1080 / config.canvasHeight,
);
}

Expand Down Expand Up @@ -56,7 +56,7 @@ class CanvasRender implements IRender {
options.targetX,
options.targetY,
options.targetWidth,
options.targetHeight
options.targetHeight,
);
} else {
this.renderContext.drawImage(image, options.targetX, options.targetY);
Expand All @@ -69,7 +69,7 @@ class CanvasRender implements IRender {
0,
0,
this.targetCanvas.width,
this.targetCanvas.height
this.targetCanvas.height,
);
if (!isWide) this.drawLetterBox();
this.targetContext.drawImage(
Expand All @@ -81,7 +81,7 @@ class CanvasRender implements IRender {
0,
0,
this.targetCanvas.width,
this.targetCanvas.height
this.targetCanvas.height,
);
}

Expand All @@ -93,7 +93,7 @@ class CanvasRender implements IRender {
config.canvasWidth - letterBoxWidth,
0,
letterBoxWidth,
config.stageHeight
config.stageHeight,
);
}

Expand All @@ -102,7 +102,7 @@ class CanvasRender implements IRender {
0,
0,
this.renderCanvas.width,
this.renderCanvas.height
this.renderCanvas.height,
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/testUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const run = (niwango: string) => {
return Core.execute(
ast,
[globalScope, environmentScope, Core.prototypeScope],
[ast]
[ast],
);
};
export { run };
6 changes: 3 additions & 3 deletions src/utils/flashText.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const getFontName = (font: string): commentFlashFont => {
*/
const splitContents = (string: string) => {
return Array.from(string.match(/[\n\r]|[^\n\r]+/g) || []).map((val) =>
Array.from(val.match(/[ -~-]+|[^ -~-]+/g) || [])
Array.from(val.match(/[ -~-]+|[^ -~-]+/g) || []),
);
};

Expand Down Expand Up @@ -83,7 +83,7 @@ const parse = (string: string, compat = false): parsedComment => {
...lineContent.map((val) => {
val.font ||= firstContent.font;
return val;
})
}),
);
} else {
content.push(...lineContent);
Expand Down Expand Up @@ -246,7 +246,7 @@ const parseFullStr = (string: string): commentContentItem[] => {
*/
const measure = (
context: CanvasRenderingContext2D,
comment: measureTextInput
comment: measureTextInput,
) => {
const width_arr = [];
let currentWidth = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/utils/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const getDistance = (pos1: IrObjectPos, pos2: IrObjectPos) => {

const getOptions = <T extends IObjectOptions>(
defaultOptions: T,
options: Partial<T>
options: Partial<T>,
) => {
let result = { ...defaultOptions };
for (const _key of Object.keys(defaultOptions)) {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const getValue = <T>(value: T | undefined, fallback: T): T => {

const format = (
options: { [key: string]: unknown },
types: { [key: string]: ValueType }
types: { [key: string]: ValueType },
) => {
for (const key of Object.keys(options)) {
const value = options[key];
Expand Down

0 comments on commit 6b04c0b

Please sign in to comment.