diff options
| author | nexxeln <[email protected]> | 2025-11-22 07:04:05 +0000 |
|---|---|---|
| committer | nexxeln <[email protected]> | 2025-11-22 07:04:05 +0000 |
| commit | 895f37ac899597dc66c40fb94f9e5bb43d60a42a (patch) | |
| tree | d0825db4ba52cdf5f404058135a8f88961f77a6a /packages/memory-graph/src/lib/inject-styles.ts | |
| parent | package the graph (#563) (diff) | |
| download | supermemory-proxy-graph-requests.tar.xz supermemory-proxy-graph-requests.zip | |
runtime styles injection + let user proxy requests for data in graph package + new playground (#588)proxy-graph-requests
Diffstat (limited to 'packages/memory-graph/src/lib/inject-styles.ts')
| -rw-r--r-- | packages/memory-graph/src/lib/inject-styles.ts | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/packages/memory-graph/src/lib/inject-styles.ts b/packages/memory-graph/src/lib/inject-styles.ts new file mode 100644 index 00000000..1a6bf4eb --- /dev/null +++ b/packages/memory-graph/src/lib/inject-styles.ts @@ -0,0 +1,36 @@ +/** + * Runtime CSS injection for universal bundler support + * The CSS content is injected by the build plugin + */ + +// This will be replaced by the build plugin with the actual CSS content +declare const __MEMORY_GRAPH_CSS__: string; + +// Track injection state +let injected = false; + +/** + * Inject memory-graph styles into the document head. + * Safe to call multiple times - will only inject once. + */ +export function injectStyles(): void { + // Only run in browser + if (typeof document === "undefined") return; + + // Only inject once + if (injected) return; + + // Check if already injected (e.g., by another instance) + if (document.querySelector('style[data-memory-graph]')) { + injected = true; + return; + } + + injected = true; + + // Create and inject style element + const style = document.createElement("style"); + style.setAttribute("data-memory-graph", ""); + style.textContent = __MEMORY_GRAPH_CSS__; + document.head.appendChild(style); +} |