@@ -18,8 +18,13 @@ interface LegacyTplPropProxy extends CustomTemplateProxyBasicProperty {
1818 refTransform ?: unknown ;
1919}
2020
21- class CustomTemplateRegistry {
21+ export class CustomTemplateRegistry {
2222 readonly #registry = new Map < string , CustomTemplate > ( ) ;
23+ readonly #isolated: boolean | undefined ;
24+
25+ constructor ( isolated ?: boolean ) {
26+ this . #isolated = isolated ;
27+ }
2328
2429 define ( tagName : string , constructor : CustomTemplateConstructor ) : void {
2530 let registered = this . #registry. has ( tagName ) ;
@@ -179,7 +184,6 @@ class CustomTemplateRegistry {
179184 }
180185 Object . defineProperty ( TplElement . prototype , propName , {
181186 get ( this : RuntimeBrickElement ) {
182- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
183187 return this . $$tplStateStore ! . getValue ( propName ) ;
184188 } ,
185189 set ( this : RuntimeBrickElement , value : unknown ) {
@@ -194,7 +198,6 @@ class CustomTemplateRegistry {
194198 for ( const [ from , to ] of validProxyProps ) {
195199 Object . defineProperty ( TplElement . prototype , from , {
196200 get ( this : TplElement ) {
197- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
198201 const element = this . $$getElementByRef ! ( to . ref ) as unknown as Record <
199202 string ,
200203 unknown
@@ -218,7 +221,6 @@ class CustomTemplateRegistry {
218221 for ( const [ from , to ] of proxyMethods ) {
219222 Object . defineProperty ( TplElement . prototype , from , {
220223 value ( this : TplElement , ...args : unknown [ ] ) {
221- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
222224 const element = this . $$getElementByRef ! ( to . ref ) as unknown as Record <
223225 string ,
224226 Function
@@ -235,6 +237,12 @@ class CustomTemplateRegistry {
235237 get ( tagName : string ) {
236238 return this . #registry. get ( tagName ) ;
237239 }
240+
241+ clearIsolatedRegistry ( ) {
242+ if ( this . #isolated) {
243+ this . #registry. clear ( ) ;
244+ }
245+ }
238246}
239247
240248function getExposedStates ( state : ContextConf [ ] | undefined ) : string [ ] {
0 commit comments