@@ -21,10 +21,22 @@ function makeCanvasId(canvasName: string, instanceId: string): CanvasId {
2121export function getCanvasStoreUnguarded (
2222 canvasName : string ,
2323 instanceId : string ,
24+ allowUnvalidatedSpec ?: boolean ,
2425) : CanvasStore | undefined {
2526 const id = makeCanvasId ( canvasName , instanceId ) ;
27+ const store = canvasRegistry . get ( id ) ;
28+
29+ if (
30+ store &&
31+ allowUnvalidatedSpec !== undefined &&
32+ store . canvasEntity . allowUnvalidatedSpec !== allowUnvalidatedSpec
33+ ) {
34+ store . canvasEntity . unsubscribe ( ) ;
35+ canvasRegistry . delete ( id ) ;
36+ return undefined ;
37+ }
2638
27- return canvasRegistry . get ( id ) ;
39+ return store ;
2840}
2941
3042export function getCanvasStore (
@@ -65,11 +77,18 @@ export function setCanvasStore(
6577) : CanvasStore {
6678 const id = makeCanvasId ( canvasName , instanceId ) ;
6779
68- if ( canvasRegistry . has ( id ) ) {
80+ const existingStore = canvasRegistry . get ( id ) ;
81+ if (
82+ existingStore &&
83+ existingStore . canvasEntity . allowUnvalidatedSpec !== allowUnvalidatedSpec
84+ ) {
85+ existingStore . canvasEntity . unsubscribe ( ) ;
86+ canvasRegistry . delete ( id ) ;
87+ } else if ( existingStore ) {
6988 console . warn (
7089 `Canvas store for ID ${ id } already exists. Returning existing store.` ,
7190 ) ;
72- return canvasRegistry . get ( id ) ! ;
91+ return existingStore ;
7392 }
7493
7594 const canvasEntity = new CanvasEntity (
0 commit comments