Remove getTime workaround and Node.js type bleeding (#723)

- Removes legacy timer workaround (redundant on Chrome v6 / Node.js v16)
- Removes old type workarounds
- Improves type inference speed
This commit is contained in:
filtered
2025-03-09 00:27:49 +11:00
committed by GitHub
parent 7119480f84
commit 68945cb54d
5 changed files with 9 additions and 28 deletions

View File

@@ -375,7 +375,6 @@ export class LGraph implements LinkNetwork, Serialisable<SerialisableGraph> {
on_frame()
} else {
// execute every 'interval' ms
// @ts-expect-error
this.execution_timer_id = setInterval(() => {
// execute
this.onBeforeStep?.()

View File

@@ -1166,7 +1166,7 @@ export class LGraphCanvas implements ConnectionColorContext {
input.focus()
let dialogCloseTimer: ReturnType<typeof setTimeout>
let dialogCloseTimer: number
dialog.addEventListener("mouseleave", function () {
if (LiteGraph.dialog_close_on_mouse_leave) {
if (!dialog.is_modified && LiteGraph.dialog_close_on_mouse_leave) {
@@ -5872,7 +5872,7 @@ export class LGraphCanvas implements ConnectionColorContext {
if (this.ds.scale > 1) dialog.style.transform = `scale(${this.ds.scale})`
let dialogCloseTimer: ReturnType<typeof setTimeout>
let dialogCloseTimer: number
let prevent_timeout = 0
LiteGraph.pointerListenerAdd(dialog, "leave", function () {
if (prevent_timeout) return
@@ -6058,7 +6058,7 @@ export class LGraphCanvas implements ConnectionColorContext {
if (options.hide_on_mouse_leave) {
// FIXME: Remove "any" kludge
let prevent_timeout: any = false
let timeout_close: ReturnType<typeof setTimeout> | null = null
let timeout_close: number | null = null
LiteGraph.pointerListenerAdd(dialog, "enter", function () {
if (timeout_close) {
clearTimeout(timeout_close)
@@ -6103,7 +6103,7 @@ export class LGraphCanvas implements ConnectionColorContext {
that.search_box = dialog
let first: string | null = null
let timeout: ReturnType<typeof setTimeout> | null = null
let timeout: number | null = null
let selected: ChildNode | null = null
const maybeInput = dialog.querySelector("input")
@@ -6713,7 +6713,7 @@ export class LGraphCanvas implements ConnectionColorContext {
}
}
let dialogCloseTimer: ReturnType<typeof setTimeout>
let dialogCloseTimer: number
let prevent_timeout = 0
dialog.addEventListener("mouseleave", function () {
if (prevent_timeout) return

View File

@@ -284,24 +284,6 @@ export class LiteGraphGlobal {
}
}
constructor() {
// timer that works everywhere
if (typeof performance != "undefined") {
this.getTime = performance.now.bind(performance)
} else if (typeof Date != "undefined" && Date.now) {
this.getTime = Date.now.bind(Date)
} else if (typeof process != "undefined") {
this.getTime = function () {
const t = process.hrtime()
return t[0] * 0.001 + t[1] * 1e-6
}
} else {
this.getTime = function () {
return Date.now()
}
}
}
/**
* Register a node class so it can be listed when the user wants to create a new one
* @param type name of the node and path
@@ -734,7 +716,9 @@ export class LiteGraphGlobal {
}
}
getTime: () => number
getTime(): number {
return performance.now()
}
distance = distance

View File

@@ -150,7 +150,6 @@ LiteGraphGlobal {
"dialog_close_on_mouse_leave_delay": 500,
"distance": [Function],
"do_add_triggers_slots": false,
"getTime": [Function],
"highlight_selected_group": true,
"isInsideRectangle": [Function],
"middle_click_slot_add_default_node": false,

View File

@@ -26,8 +26,7 @@
"paths": {
"@/*": ["src/*"]
},
// TODO: Remove workaround from initial vite impl: public/src
"typeRoots": ["src/types", "node_modules/@types", "public/src"],
"typeRoots": [],
"outDir": "./dist",
"rootDir": "./"
},