@ngxpert/hot-toast
Version:
Smoking hot Notifications for Angular. Lightweight, customizable and beautiful by default.
37 lines • 1.79 kB
JavaScript
;
/**
* @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
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = default_1;
const schematics_1 = require("@angular-devkit/schematics");
const utility_1 = require("@schematics/angular/utility");
const rxjs_1 = require("rxjs");
const operators_1 = require("rxjs/operators");
const theming_1 = require("./theming/theming");
function default_1(options) {
return (0, schematics_1.chain)([addHotToastConfig(options), (0, theming_1.addThemeToAppStyles)(options)]);
}
function addHotToastConfig(options) {
// @ts-expect-error ignore the error
return (host, context) => {
const hotToastConfigRule = (0, utility_1.addRootProvider)(options.project, ({ code, external }) => {
return code `${external('provideHotToastConfig', '@ngxpert/hot-toast')}()`;
});
// The `addRootProvider` rule can throw in some custom scenarios (see #28640).
// Add some error handling around it so the setup isn't interrupted.
// @ts-expect-error ignore the error
return (0, schematics_1.callRule)(hotToastConfigRule, host, context).pipe(
// @ts-expect-error ignore the error
(0, operators_1.catchError)(() => {
context.logger.error('Failed to add @ngxpert/hot-toast config to project. Continuing with the @ngxpert/hot-toast setup.');
context.logger.info('Read more about setting up the config manually: https://github.com/ngxpert/hot-toast?tab=readme-ov-file#standalone-setup');
return (0, rxjs_1.of)(host);
}));
};
}
//# sourceMappingURL=setup-project.js.map