mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-26 09:44:06 +00:00
[Cleanup] Assorted minor code clean-up (#943)
Adds one warning log for an extreme edge case.
This commit is contained in:
@@ -936,9 +936,11 @@ export class LGraphCanvas implements ConnectionColorContext {
|
||||
canvas.graph.beforeChange()
|
||||
const node = LiteGraph.createNode(value.value)
|
||||
if (node) {
|
||||
if (!first_event) throw new TypeError("Context menu event was null. This should not occure in normal usage.")
|
||||
if (!first_event) throw new TypeError("Context menu event was null. This should not occur in normal usage.")
|
||||
node.pos = canvas.convertEventToCanvasOffset(first_event)
|
||||
canvas.graph.add(node)
|
||||
} else {
|
||||
console.warn("Failed to create node of type:", value.value)
|
||||
}
|
||||
|
||||
callback?.(node)
|
||||
@@ -5518,6 +5520,7 @@ export class LGraphCanvas implements ConnectionColorContext {
|
||||
allow_searchbox: this.allow_searchbox,
|
||||
showSearchBox: this.showSearchBox,
|
||||
}, optPass || {})
|
||||
const dirty = () => this.#dirty()
|
||||
const that = this
|
||||
const { graph } = this
|
||||
const { afterRerouteId } = opts
|
||||
@@ -5594,11 +5597,8 @@ export class LGraphCanvas implements ConnectionColorContext {
|
||||
callback: inner_clicked,
|
||||
})
|
||||
|
||||
const dirty = () => this.#dirty()
|
||||
|
||||
// callback
|
||||
function inner_clicked(v: string | undefined, options: IContextMenuOptions<string, INodeInputSlot | INodeOutputSlot>, e: MouseEvent) {
|
||||
// console.log("Process showConnectionMenu selection");
|
||||
switch (v) {
|
||||
case "Add Node":
|
||||
LGraphCanvas.onMenuAdd(null, null, e, menu, function (node) {
|
||||
|
||||
@@ -18,13 +18,12 @@ const randomStorage = new Uint32Array(31)
|
||||
*/
|
||||
export function createUuidv4(): UUID {
|
||||
if (typeof crypto?.randomUUID === "function") return crypto.randomUUID()
|
||||
// Assertion: `replaceAll` returns `string`; UUID format must be asserted below
|
||||
if (typeof crypto?.getRandomValues === "function") {
|
||||
const random = crypto.getRandomValues(randomStorage)
|
||||
let i = 0
|
||||
return "10000000-1000-4000-8000-100000000000".replaceAll(/[018]/g, a =>
|
||||
(Number(a) ^ ((random[i++] * 3.725_290_298_461_914e-9) >> (Number(a) * 0.25))).toString(16)) as UUID
|
||||
(Number(a) ^ ((random[i++] * 3.725_290_298_461_914e-9) >> (Number(a) * 0.25))).toString(16))
|
||||
}
|
||||
return "10000000-1000-4000-8000-100000000000".replaceAll(/[018]/g, a =>
|
||||
(Number(a) ^ ((Math.random() * 16) >> (Number(a) * 0.25))).toString(16)) as UUID
|
||||
(Number(a) ^ ((Math.random() * 16) >> (Number(a) * 0.25))).toString(16))
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MovingRenderLink } from "@/canvas/MovingRenderLink"
|
||||
import type { MovingInputLink } from "@/canvas/MovingInputLink"
|
||||
import type { LinkNetwork } from "@/interfaces"
|
||||
import type { ISlotType } from "@/interfaces"
|
||||
|
||||
@@ -248,7 +248,7 @@ describe("LinkConnector", () => {
|
||||
fromDirection: LinkDirection.RIGHT,
|
||||
toType: "input",
|
||||
link: new LLink(1, "number", 1, 0, 2, 0),
|
||||
} as MovingRenderLink
|
||||
} as MovingInputLink
|
||||
|
||||
connector.events.dispatch("input-moved", mockRenderLink)
|
||||
expect(listener).toHaveBeenCalled()
|
||||
|
||||
Reference in New Issue
Block a user