@angular/cdk
Version:
Angular Material Component Development Kit
1 lines • 4.16 kB
Source Map (JSON)
{"version":3,"file":"_style-loader-chunk.mjs","sources":["../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/src/cdk/private/style-loader.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {\n ApplicationRef,\n ComponentRef,\n createComponent,\n EnvironmentInjector,\n inject,\n Injectable,\n Injector,\n Type,\n} from '@angular/core';\n\n/** Apps in which we've loaded styles. */\nconst appsWithLoaders = new WeakMap<\n ApplicationRef,\n {\n /** Style loaders that have been added. */\n loaders: Set<Type<unknown>>;\n\n /** References to the instantiated loaders. */\n refs: ComponentRef<unknown>[];\n }\n>();\n\n/**\n * Service that loads structural styles dynamically\n * and ensures that they're only loaded once per app.\n */\n@Injectable({providedIn: 'root'})\nexport class _CdkPrivateStyleLoader {\n private _appRef: ApplicationRef | undefined;\n private _injector = inject(Injector);\n private _environmentInjector = inject(EnvironmentInjector);\n\n /**\n * Loads a set of styles.\n * @param loader Component which will be instantiated to load the styles.\n */\n load(loader: Type<unknown>): void {\n // Resolve the app ref lazily to avoid circular dependency errors if this is called too early.\n const appRef = (this._appRef = this._appRef || this._injector.get(ApplicationRef));\n let data = appsWithLoaders.get(appRef);\n\n // If we haven't loaded for this app before, we have to initialize it.\n if (!data) {\n data = {loaders: new Set(), refs: []};\n appsWithLoaders.set(appRef, data);\n\n // When the app is destroyed, we need to clean up all the related loaders.\n appRef.onDestroy(() => {\n appsWithLoaders.get(appRef)?.refs.forEach(ref => ref.destroy());\n appsWithLoaders.delete(appRef);\n });\n }\n\n // If the loader hasn't been loaded before, we need to instatiate it.\n if (!data.loaders.has(loader)) {\n data.loaders.add(loader);\n data.refs.push(createComponent(loader, {environmentInjector: this._environmentInjector}));\n }\n }\n}\n"],"names":["appsWithLoaders","WeakMap","_CdkPrivateStyleLoader","_appRef","_injector","inject","Injector","_environmentInjector","EnvironmentInjector","load","loader","appRef","get","ApplicationRef","data","loaders","Set","refs","set","onDestroy","forEach","ref","destroy","delete","has","add","push","createComponent","environmentInjector","deps","target","i0","ɵɵFactoryTarget","Injectable","ɵprov","ɵɵngDeclareInjectable","minVersion","version","ngImport","type","decorators","providedIn"],"mappings":";;;AAoBA,MAAMA,eAAe,GAAG,IAAIC,OAAO,EAShC;MAOUC,sBAAsB,CAAA;EACzBC,OAAO;AACPC,EAAAA,SAAS,GAAGC,MAAM,CAACC,QAAQ,CAAC;AAC5BC,EAAAA,oBAAoB,GAAGF,MAAM,CAACG,mBAAmB,CAAC;EAM1DC,IAAIA,CAACC,MAAqB,EAAA;AAExB,IAAA,MAAMC,MAAM,GAAI,IAAI,CAACR,OAAO,GAAG,IAAI,CAACA,OAAO,IAAI,IAAI,CAACC,SAAS,CAACQ,GAAG,CAACC,cAAc,CAAE;AAClF,IAAA,IAAIC,IAAI,GAAGd,eAAe,CAACY,GAAG,CAACD,MAAM,CAAC;IAGtC,IAAI,CAACG,IAAI,EAAE;AACTA,MAAAA,IAAI,GAAG;AAACC,QAAAA,OAAO,EAAE,IAAIC,GAAG,EAAE;AAAEC,QAAAA,IAAI,EAAE;OAAG;AACrCjB,MAAAA,eAAe,CAACkB,GAAG,CAACP,MAAM,EAAEG,IAAI,CAAC;MAGjCH,MAAM,CAACQ,SAAS,CAAC,MAAK;AACpBnB,QAAAA,eAAe,CAACY,GAAG,CAACD,MAAM,CAAC,EAAEM,IAAI,CAACG,OAAO,CAACC,GAAG,IAAIA,GAAG,CAACC,OAAO,EAAE,CAAC;AAC/DtB,QAAAA,eAAe,CAACuB,MAAM,CAACZ,MAAM,CAAC;AAChC,OAAC,CAAC;AACJ;IAGA,IAAI,CAACG,IAAI,CAACC,OAAO,CAACS,GAAG,CAACd,MAAM,CAAC,EAAE;AAC7BI,MAAAA,IAAI,CAACC,OAAO,CAACU,GAAG,CAACf,MAAM,CAAC;MACxBI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