@@ -73,7 +73,8 @@ export type DataSchemaCompilerOptions = {
7373 nativeInstance : NativeInstance ;
7474 cubeFactory : Function ;
7575 cubeDictionary : CubeDictionary ;
76- cubeSymbols : CubeSymbols ;
76+ cubeOnlySymbols : CubeSymbols ;
77+ cubeAndViewSymbols : CubeSymbols ;
7778 cubeCompilers ?: CompilerInterface [ ] ;
7879 contextCompilers ?: CompilerInterface [ ] ;
7980 transpilers ?: TranspilerInterface [ ] ;
@@ -131,7 +132,9 @@ export class DataSchemaCompiler {
131132
132133 private readonly cubeDictionary : CubeDictionary ;
133134
134- private readonly cubeSymbols : CubeSymbols ;
135+ private readonly cubeOnlySymbols : CubeSymbols ;
136+
137+ private readonly cubeAndViewSymbols : CubeSymbols ;
135138
136139 // Actually should be something like
137140 // createCube(cubeDefinition: CubeDefinition): CubeDefinitionExtended
@@ -187,7 +190,8 @@ export class DataSchemaCompiler {
187190 this . cubeNameCompilers = options . cubeNameCompilers || [ ] ;
188191 this . extensions = options . extensions || { } ;
189192 this . cubeDictionary = options . cubeDictionary ;
190- this . cubeSymbols = options . cubeSymbols ;
193+ this . cubeOnlySymbols = options . cubeOnlySymbols ;
194+ this . cubeAndViewSymbols = options . cubeAndViewSymbols ;
191195 this . cubeFactory = options . cubeFactory ;
192196 this . filesToCompile = options . filesToCompile || [ ] ;
193197 this . omitErrors = options . omitErrors || false ;
@@ -531,7 +535,8 @@ export class DataSchemaCompiler {
531535 // Free unneeded resources
532536 this . compileV8ContextCache = null ;
533537 this . cubeDictionary . free ( ) ;
534- this . cubeSymbols . free ( ) ;
538+ this . cubeOnlySymbols . free ( ) ;
539+ this . cubeAndViewSymbols . free ( ) ;
535540 return res ;
536541 } ) ;
537542 }
@@ -563,14 +568,23 @@ export class DataSchemaCompiler {
563568 // The structured clone algorithm (@see https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm)
564569 // which doesn't allow passing any function objects, so we need to sanitize the symbols.
565570 // Communication with native backend also involves deserialization.
566- const cubeSymbols : Record < string , Record < string , boolean > > = Object . fromEntries (
567- Object . entries ( this . cubeSymbols . symbols as Record < string , Record < string , any > > )
571+ const cubeOnlySymbols : Record < string , Record < string , boolean > > = Object . fromEntries (
572+ Object . entries ( this . cubeOnlySymbols . symbols as Record < string , Record < string , any > > )
573+ . map (
574+ ( [ key , value ] : [ string , Record < string , any > ] ) => [ key , Object . fromEntries (
575+ Object . keys ( value ) . map ( ( k ) => [ k , true ] ) ,
576+ ) ] ,
577+ ) ,
578+ ) ;
579+ const cubeViewSymbols : Record < string , Record < string , boolean > > = Object . fromEntries (
580+ Object . entries ( this . cubeAndViewSymbols . symbols as Record < string , Record < string , any > > )
568581 . map (
569582 ( [ key , value ] : [ string , Record < string , any > ] ) => [ key , Object . fromEntries (
570583 Object . keys ( value ) . map ( ( k ) => [ k , true ] ) ,
571584 ) ] ,
572585 ) ,
573586 ) ;
587+ const cubeSymbols = { ...cubeOnlySymbols , ...cubeViewSymbols } ;
574588
575589 // Transpilers are the same for all files within phase.
576590 const transpilerNames : string [ ] = this . transpilers . map ( t => t . constructor . name ) ;
0 commit comments