mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
Instead of relying on Microsoft's API extractor for `d.ts` bundling, we are switching to Rollup-based `.d.ts` bundling. This allows us to support code spliting, even for `.d.ts` files, allowing for relative imports to be used between entry-points, without ending up duplicating `.d.ts` definitions in two files. This would otherwise cause problems with assignability of types. It also nicely integrates into our existing rollup configuration, and overall simplifies the `ng_package` rule even further! Notably `tsup` also uses this rollup plugin, and it seems to work well. Keep in mind that Microsoft's API extractor is pretty hard to integrate, caused many problems in the past, and isn't capable of code splitting. This aligns our d.ts bundling with the .mjs bundling (great alignment). PR Close #60321
43 lines
1 KiB
TypeScript
43 lines
1 KiB
TypeScript
/*!
|
|
* @license
|
|
* Copyright Google LLC All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
* found in the LICENSE file at https://angular.dev/license
|
|
*/
|
|
|
|
declare global {
|
|
interface Window {
|
|
gtag?(...args: any[]): void;
|
|
}
|
|
}
|
|
|
|
export const setCookieConsent = (state: 'denied' | 'granted'): void => {
|
|
try {
|
|
if (window.gtag) {
|
|
const consentOptions = {
|
|
ad_user_data: state,
|
|
ad_personalization: state,
|
|
ad_storage: state,
|
|
analytics_storage: state,
|
|
};
|
|
|
|
if (state === 'denied') {
|
|
window.gtag('consent', 'default', {
|
|
...consentOptions,
|
|
wait_for_update: 500,
|
|
});
|
|
} else if (state === 'granted') {
|
|
window.gtag('consent', 'update', {
|
|
...consentOptions,
|
|
});
|
|
}
|
|
}
|
|
} catch {
|
|
if (state === 'denied') {
|
|
console.error('Unable to set default cookie consent.');
|
|
} else if (state === 'granted') {
|
|
console.error('Unable to grant cookie consent.');
|
|
}
|
|
}
|
|
};
|