1- const STORE_SYMBOL_LISTENERS = Symbol . for ( '@ui5/webcomponents-react/StyleStore/Listeners' ) ;
2- const STORE_SYMBOL = Symbol . for ( '@ui5/webcomponents-react/StyleStore' ) ;
1+ import { getCurrentRuntimeIndex } from '@ui5/webcomponents-base/dist/Runtimes.js' ;
2+
3+ globalThis [ '@ui5/webcomponents-react' ] ??= { } ;
4+ const STORE_LOCATION = globalThis [ '@ui5/webcomponents-react' ] ;
5+
6+ function getStyleStoreListenersSymbol ( ) {
7+ return Symbol . for ( `@ui5/webcomponents-react/StyleStore-${ getCurrentRuntimeIndex ( ) } /Listeners` ) ;
8+ }
9+
10+ function getStyleStoreSymbol ( ) {
11+ return Symbol . for ( `@ui5/webcomponents-react/StyleStore-${ getCurrentRuntimeIndex ( ) } ` ) ;
12+ }
313
414interface IStyleStore {
515 staticCssInjected : boolean ;
@@ -12,8 +22,8 @@ const initialStore: IStyleStore = {
1222} ;
1323
1424function getListeners ( ) : Array < ( ) => void > {
15- globalThis [ STORE_SYMBOL_LISTENERS ] ??= [ ] ;
16- return globalThis [ STORE_SYMBOL_LISTENERS ] ;
25+ STORE_LOCATION [ getStyleStoreListenersSymbol ( ) ] ??= [ ] ;
26+ return STORE_LOCATION [ getStyleStoreListenersSymbol ( ) ] ;
1727}
1828
1929function emitChange ( ) {
@@ -23,15 +33,15 @@ function emitChange() {
2333}
2434
2535function getSnapshot ( ) : IStyleStore {
26- globalThis [ STORE_SYMBOL ] ??= initialStore ;
27- return globalThis [ STORE_SYMBOL ] ;
36+ STORE_LOCATION [ getStyleStoreSymbol ( ) ] ??= initialStore ;
37+ return STORE_LOCATION [ getStyleStoreSymbol ( ) ] ;
2838}
2939
3040function subscribe ( listener : ( ) => void ) {
3141 const listeners = getListeners ( ) ;
32- globalThis [ STORE_SYMBOL_LISTENERS ] = [ ...listeners , listener ] ;
42+ STORE_LOCATION [ getStyleStoreListenersSymbol ( ) ] = [ ...listeners , listener ] ;
3343 return ( ) => {
34- globalThis [ STORE_SYMBOL_LISTENERS ] = listeners . filter ( ( l ) => l !== listener ) ;
44+ STORE_LOCATION [ getStyleStoreListenersSymbol ( ) ] = listeners . filter ( ( l ) => l !== listener ) ;
3545 } ;
3646}
3747
@@ -43,7 +53,7 @@ export const StyleStore = {
4353 } ,
4454 setStaticCssInjected : ( staticCssInjected : boolean ) => {
4555 const curr = getSnapshot ( ) ;
46- globalThis [ STORE_SYMBOL ] = {
56+ STORE_LOCATION [ getStyleStoreSymbol ( ) ] = {
4757 ...curr ,
4858 staticCssInjected
4959 } ;
0 commit comments