refactor: remove autobind-decorator dep
This commit is contained in:
@@ -19,7 +19,6 @@
|
||||
"@tabler/icons-webfont": "2.12.0",
|
||||
"@vitejs/plugin-vue": "4.1.0",
|
||||
"@vue/compiler-sfc": "3.2.47",
|
||||
"autobind-decorator": "2.4.0",
|
||||
"autosize": "5.0.2",
|
||||
"blurhash": "2.0.5",
|
||||
"broadcast-channel": "4.20.2",
|
||||
|
@@ -1,5 +1,4 @@
|
||||
import { defineAsyncComponent, Directive, ref } from 'vue';
|
||||
import autobind from 'autobind-decorator';
|
||||
import { popup } from '@/os';
|
||||
|
||||
export class UserPreview {
|
||||
@@ -15,9 +14,16 @@ export class UserPreview {
|
||||
this.user = user;
|
||||
|
||||
this.attach();
|
||||
|
||||
this.show = this.show.bind(this);
|
||||
this.close = this.close.bind(this);
|
||||
this.onMouseover = this.onMouseover.bind(this);
|
||||
this.onMouseleave = this.onMouseleave.bind(this);
|
||||
this.onClick = this.onClick.bind(this);
|
||||
this.attach = this.attach.bind(this);
|
||||
this.detach = this.detach.bind(this);
|
||||
}
|
||||
|
||||
@autobind
|
||||
private show() {
|
||||
if (!document.body.contains(this.el)) return;
|
||||
if (this.promise) return;
|
||||
@@ -53,7 +59,6 @@ export class UserPreview {
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
@autobind
|
||||
private close() {
|
||||
if (this.promise) {
|
||||
window.clearInterval(this.checkTimer);
|
||||
@@ -62,34 +67,29 @@ export class UserPreview {
|
||||
}
|
||||
}
|
||||
|
||||
@autobind
|
||||
private onMouseover() {
|
||||
window.clearTimeout(this.showTimer);
|
||||
window.clearTimeout(this.hideTimer);
|
||||
this.showTimer = window.setTimeout(this.show, 500);
|
||||
}
|
||||
|
||||
@autobind
|
||||
private onMouseleave() {
|
||||
window.clearTimeout(this.showTimer);
|
||||
window.clearTimeout(this.hideTimer);
|
||||
this.hideTimer = window.setTimeout(this.close, 500);
|
||||
}
|
||||
|
||||
@autobind
|
||||
private onClick() {
|
||||
window.clearTimeout(this.showTimer);
|
||||
this.close();
|
||||
}
|
||||
|
||||
@autobind
|
||||
public attach() {
|
||||
this.el.addEventListener('mouseover', this.onMouseover);
|
||||
this.el.addEventListener('mouseleave', this.onMouseleave);
|
||||
this.el.addEventListener('click', this.onClick);
|
||||
}
|
||||
|
||||
@autobind
|
||||
public detach() {
|
||||
this.el.removeEventListener('mouseover', this.onMouseover);
|
||||
this.el.removeEventListener('mouseleave', this.onMouseleave);
|
||||
|
@@ -1,4 +1,3 @@
|
||||
import autobind from 'autobind-decorator';
|
||||
import { ref, Ref, unref } from 'vue';
|
||||
import { collectPageVars } from '../collect-page-vars';
|
||||
import { initHpmlLib } from './lib';
|
||||
@@ -51,7 +50,6 @@ export class Hpml {
|
||||
this.eval();
|
||||
}
|
||||
|
||||
@autobind
|
||||
public eval() {
|
||||
try {
|
||||
this.vars.value = this.evaluateVars();
|
||||
@@ -60,7 +58,6 @@ export class Hpml {
|
||||
}
|
||||
}
|
||||
|
||||
@autobind
|
||||
public interpolate(str: string) {
|
||||
if (str == null) return null;
|
||||
return str.replace(/{(.+?)}/g, match => {
|
||||
@@ -69,12 +66,10 @@ export class Hpml {
|
||||
});
|
||||
}
|
||||
|
||||
@autobind
|
||||
public registerCanvas(id: string, canvas: any) {
|
||||
this.canvases[id] = canvas;
|
||||
}
|
||||
|
||||
@autobind
|
||||
public updatePageVar(name: string, value: any) {
|
||||
const pageVar = this.pageVars.find(v => v.name === name);
|
||||
if (pageVar !== undefined) {
|
||||
@@ -84,13 +79,11 @@ export class Hpml {
|
||||
}
|
||||
}
|
||||
|
||||
@autobind
|
||||
public updateRandomSeed(seed: string) {
|
||||
this.opts.randomSeed = seed;
|
||||
this.envVars.SEED = seed;
|
||||
}
|
||||
|
||||
@autobind
|
||||
private _interpolateScope(str: string, scope: HpmlScope) {
|
||||
return str.replace(/{(.+?)}/g, match => {
|
||||
const v = scope.getState(match.slice(1, -1).trim());
|
||||
@@ -98,7 +91,6 @@ export class Hpml {
|
||||
});
|
||||
}
|
||||
|
||||
@autobind
|
||||
public evaluateVars(): Record<string, any> {
|
||||
const values: Record<string, any> = {};
|
||||
|
||||
@@ -117,7 +109,6 @@ export class Hpml {
|
||||
return values;
|
||||
}
|
||||
|
||||
@autobind
|
||||
private evaluate(expr: Expr, scope: HpmlScope): any {
|
||||
if (isLiteralValue(expr)) {
|
||||
if (expr.type === null) {
|
||||
|
@@ -2,7 +2,6 @@
|
||||
* Hpml
|
||||
*/
|
||||
|
||||
import autobind from 'autobind-decorator';
|
||||
import { Hpml } from './evaluator';
|
||||
import { funcDefs } from './lib';
|
||||
|
||||
@@ -61,7 +60,6 @@ export class HpmlScope {
|
||||
this.name = name ?? 'anonymous';
|
||||
}
|
||||
|
||||
@autobind
|
||||
public createChildScope(states: Record<string, any>, name?: HpmlScope['name']): HpmlScope {
|
||||
const layer = [states, ...this.layerdStates];
|
||||
return new HpmlScope(layer, name);
|
||||
@@ -71,7 +69,6 @@ export class HpmlScope {
|
||||
* 指定した名前の変数の値を取得します
|
||||
* @param name 変数名
|
||||
*/
|
||||
@autobind
|
||||
public getState(name: string): any {
|
||||
for (const later of this.layerdStates) {
|
||||
const state = later[name];
|
||||
|
@@ -1,4 +1,3 @@
|
||||
import autobind from 'autobind-decorator';
|
||||
import { isLiteralValue } from './expr';
|
||||
import { funcDefs } from './lib';
|
||||
import { envVarsDef } from '.';
|
||||
@@ -23,7 +22,6 @@ export class HpmlTypeChecker {
|
||||
this.pageVars = pageVars;
|
||||
}
|
||||
|
||||
@autobind
|
||||
public typeCheck(v: Expr): TypeError | null {
|
||||
if (isLiteralValue(v)) return null;
|
||||
|
||||
@@ -61,7 +59,6 @@ export class HpmlTypeChecker {
|
||||
return null;
|
||||
}
|
||||
|
||||
@autobind
|
||||
public getExpectedType(v: Expr, slot: number): Type {
|
||||
const def = funcDefs[v.type ?? ''];
|
||||
if (def == null) {
|
||||
@@ -89,7 +86,6 @@ export class HpmlTypeChecker {
|
||||
}
|
||||
}
|
||||
|
||||
@autobind
|
||||
public infer(v: Expr): Type {
|
||||
if (v.type === null) return null;
|
||||
if (v.type === 'text') return 'string';
|
||||
@@ -144,7 +140,6 @@ export class HpmlTypeChecker {
|
||||
}
|
||||
}
|
||||
|
||||
@autobind
|
||||
public getVarByName(name: string): Variable {
|
||||
const v = this.variables.find(x => x.name === name);
|
||||
if (v !== undefined) {
|
||||
@@ -154,25 +149,21 @@ export class HpmlTypeChecker {
|
||||
}
|
||||
}
|
||||
|
||||
@autobind
|
||||
public getVarsByType(type: Type): Variable[] {
|
||||
if (type == null) return this.variables;
|
||||
return this.variables.filter(x => (this.infer(x) === null) || (this.infer(x) === type));
|
||||
}
|
||||
|
||||
@autobind
|
||||
public getEnvVarsByType(type: Type): string[] {
|
||||
if (type == null) return Object.keys(envVarsDef);
|
||||
return Object.entries(envVarsDef).filter(([k, v]) => v === null || type === v).map(([k, v]) => k);
|
||||
}
|
||||
|
||||
@autobind
|
||||
public getPageVarsByType(type: Type): string[] {
|
||||
if (type == null) return this.pageVars.map(v => v.name);
|
||||
return this.pageVars.filter(v => type === v.type).map(v => v.name);
|
||||
}
|
||||
|
||||
@autobind
|
||||
public isUsedName(name: string) {
|
||||
if (this.variables.some(v => v.name === name)) {
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user