From e7eb385b8f1a08cb6b35f3df42179c968a0306bf Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Fri, 17 Jan 2025 20:21:31 +0200 Subject: [PATCH] refactor(deps): integrate force-graph into webpack --- bin/copy-dist.ts | 1 - src/public/app/services/library_loader.ts | 5 ----- src/public/app/widgets/note_map.js | 4 +--- src/routes/assets.ts | 1 - 4 files changed, 1 insertion(+), 10 deletions(-) diff --git a/bin/copy-dist.ts b/bin/copy-dist.ts index fc2e3b2ff..39ddd6cdf 100644 --- a/bin/copy-dist.ts +++ b/bin/copy-dist.ts @@ -76,7 +76,6 @@ const copy = async () => { "node_modules/@excalidraw/excalidraw/dist/", "node_modules/katex/dist/", "node_modules/dayjs/", - "node_modules/force-graph/dist/", "node_modules/boxicons/css/", "node_modules/boxicons/fonts/", "node_modules/mermaid/dist/", diff --git a/src/public/app/services/library_loader.ts b/src/public/app/services/library_loader.ts index d94e6bed7..2fa6b950e 100644 --- a/src/public/app/services/library_loader.ts +++ b/src/public/app/services/library_loader.ts @@ -68,10 +68,6 @@ const WHEEL_ZOOM: Library = { js: ["node_modules/vanilla-js-wheel-zoom/dist/wheel-zoom.min.js"] }; -const FORCE_GRAPH: Library = { - js: ["node_modules/force-graph/dist/force-graph.min.js"] -}; - const MERMAID: Library = { js: ["node_modules/mermaid/dist/mermaid.min.js"] }; @@ -201,7 +197,6 @@ export default { CALENDAR_WIDGET, KATEX, WHEEL_ZOOM, - FORCE_GRAPH, MERMAID, EXCALIDRAW, MARKJS, diff --git a/src/public/app/widgets/note_map.js b/src/public/app/widgets/note_map.js index 6e91ff2ed..cde0d07ee 100644 --- a/src/public/app/widgets/note_map.js +++ b/src/public/app/widgets/note_map.js @@ -1,4 +1,3 @@ -import libraryLoader from "../services/library_loader.js"; import server from "../services/server.js"; import attributeService from "../services/attributes.js"; import hoistedNoteService from "../services/hoisted_note.js"; @@ -149,14 +148,13 @@ export default class NoteMapWidget extends NoteContextAwareWidget { this.mapType = this.note.getLabelValue("mapType") === "tree" ? "tree" : "link"; - await libraryLoader.requireLibrary(libraryLoader.FORCE_GRAPH); - //variables for the hover effekt. We have to save the neighbours of a hovered node in a set. Also we need to save the links as well as the hovered node itself let hoverNode = null; const highlightLinks = new Set(); const neighbours = new Set(); + const ForceGraph = (await import("force-graph")).default; this.graph = ForceGraph()(this.$container[0]) .width(this.$container.width()) .height(this.$container.height()) diff --git a/src/routes/assets.ts b/src/routes/assets.ts index 6cf0202a0..ff31da432 100644 --- a/src/routes/assets.ts +++ b/src/routes/assets.ts @@ -63,7 +63,6 @@ async function register(app: express.Application) { app.use(`/${assetPath}/node_modules/katex/dist/`, persistentCacheStatic(path.join(srcRoot, "..", "node_modules/katex/dist/"))); app.use(`/${assetPath}/node_modules/dayjs/`, persistentCacheStatic(path.join(srcRoot, "..", "node_modules/dayjs/"))); - app.use(`/${assetPath}/node_modules/force-graph/dist/`, persistentCacheStatic(path.join(srcRoot, "..", "node_modules/force-graph/dist/"))); app.use(`/${assetPath}/node_modules/boxicons/css/`, persistentCacheStatic(path.join(srcRoot, "..", "node_modules/boxicons/css/"))); app.use(`/${assetPath}/node_modules/boxicons/fonts/`, persistentCacheStatic(path.join(srcRoot, "..", "node_modules/boxicons/fonts/")));