@@ -5,7 +5,7 @@ import { ConvexReactClient } from "convex/react";
55import FloatingPanel from "./components/FloatingPanel.tsx" ;
66import contentStyles from "./content.css?inline" ;
77
8- const convex = new ConvexReactClient ( import . meta. env . VITE_CONVEX_URL as string ) ;
8+ const convexUrl = import . meta. env . VITE_CONVEX_URL as string | undefined ;
99
1010function loadFonts ( ) {
1111 if ( document . getElementById ( "cornell-loop-fonts" ) ) return ;
@@ -18,8 +18,18 @@ function loadFonts() {
1818}
1919
2020function mount ( ) {
21+ if ( ! convexUrl ) {
22+ console . warn (
23+ "[Cornell Loop] VITE_CONVEX_URL is not set. " +
24+ "Create apps/extension/.env.local with VITE_CONVEX_URL=<your-convex-url> and rebuild." ,
25+ ) ;
26+ return ;
27+ }
28+
2129 if ( document . getElementById ( "cornell-loop-host" ) ) return ;
2230
31+ const convex = new ConvexReactClient ( convexUrl ) ;
32+
2333 loadFonts ( ) ;
2434
2535 const host = document . createElement ( "div" ) ;
@@ -33,13 +43,12 @@ function mount() {
3343
3444 const shadow = host . attachShadow ( { mode : "open" } ) ;
3545
36- // Inject processed Tailwind + token styles into the shadow root so they
37- // aren't blocked by shadow DOM style encapsulation.
38- console . log ( "[cornell-loop] styles length:" , contentStyles . length ) ;
39-
40- const sheet = new CSSStyleSheet ( ) ;
41- sheet . replaceSync ( contentStyles ) ;
42- shadow . adoptedStyleSheets = [ sheet ] ;
46+ // Use a <style> node instead of adoptedStyleSheets + replaceSync: constructable
47+ // stylesheets disallow @import (Tailwind may emit them) and can mishandle
48+ // @property compared to a document stylesheet.
49+ const styleEl = document . createElement ( "style" ) ;
50+ styleEl . textContent = contentStyles ;
51+ shadow . appendChild ( styleEl ) ;
4352
4453 const mountPoint = document . createElement ( "div" ) ;
4554 mountPoint . style . pointerEvents = "auto" ;
0 commit comments