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
+ }
3
13
4
14
interface IStyleStore {
5
15
staticCssInjected : boolean ;
@@ -12,8 +22,8 @@ const initialStore: IStyleStore = {
12
22
} ;
13
23
14
24
function getListeners ( ) : Array < ( ) => void > {
15
- globalThis [ STORE_SYMBOL_LISTENERS ] ??= [ ] ;
16
- return globalThis [ STORE_SYMBOL_LISTENERS ] ;
25
+ STORE_LOCATION [ getStyleStoreListenersSymbol ( ) ] ??= [ ] ;
26
+ return STORE_LOCATION [ getStyleStoreListenersSymbol ( ) ] ;
17
27
}
18
28
19
29
function emitChange ( ) {
@@ -23,15 +33,15 @@ function emitChange() {
23
33
}
24
34
25
35
function getSnapshot ( ) : IStyleStore {
26
- globalThis [ STORE_SYMBOL ] ??= initialStore ;
27
- return globalThis [ STORE_SYMBOL ] ;
36
+ STORE_LOCATION [ getStyleStoreSymbol ( ) ] ??= initialStore ;
37
+ return STORE_LOCATION [ getStyleStoreSymbol ( ) ] ;
28
38
}
29
39
30
40
function subscribe ( listener : ( ) => void ) {
31
41
const listeners = getListeners ( ) ;
32
- globalThis [ STORE_SYMBOL_LISTENERS ] = [ ...listeners , listener ] ;
42
+ STORE_LOCATION [ getStyleStoreListenersSymbol ( ) ] = [ ...listeners , listener ] ;
33
43
return ( ) => {
34
- globalThis [ STORE_SYMBOL_LISTENERS ] = listeners . filter ( ( l ) => l !== listener ) ;
44
+ STORE_LOCATION [ getStyleStoreListenersSymbol ( ) ] = listeners . filter ( ( l ) => l !== listener ) ;
35
45
} ;
36
46
}
37
47
@@ -43,7 +53,7 @@ export const StyleStore = {
43
53
} ,
44
54
setStaticCssInjected : ( staticCssInjected : boolean ) => {
45
55
const curr = getSnapshot ( ) ;
46
- globalThis [ STORE_SYMBOL ] = {
56
+ STORE_LOCATION [ getStyleStoreSymbol ( ) ] = {
47
57
...curr ,
48
58
staticCssInjected
49
59
} ;
0 commit comments