@ionic/angular-server
Version:
Angular SSR Module for Ionic
97 lines (93 loc) • 3.77 kB
JavaScript
import { DOCUMENT } from '@angular/common';
import * as i0 from '@angular/core';
import { APP_ID, NgModule } from '@angular/core';
import { BEFORE_APP_SERIALIZED } from '@angular/platform-server';
import { hydrateDocument } from '@ionic/core/hydrate';
// @dynamic
class IonicServerModule {
/** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: IonicServerModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
/** @nocollapse */ static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.2.12", ngImport: i0, type: IonicServerModule });
/** @nocollapse */ static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: IonicServerModule, providers: [
{
provide: BEFORE_APP_SERIALIZED,
useFactory: hydrateIonicComponents,
multi: true,
deps: [DOCUMENT, APP_ID],
},
] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: IonicServerModule, decorators: [{
type: NgModule,
args: [{
providers: [
{
provide: BEFORE_APP_SERIALIZED,
useFactory: hydrateIonicComponents,
multi: true,
deps: [DOCUMENT, APP_ID],
},
],
}]
}] });
// @dynamic
function hydrateIonicComponents(doc, appId) {
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
return () => {
return hydrateDocument(doc, {
clientHydrateAnnotations: false,
excludeComponents: [
// overlays
'ion-action-sheet',
'ion-alert',
'ion-loading',
'ion-modal',
'ion-picker-legacy',
'ion-popover',
'ion-toast',
'ion-toast',
// navigation
'ion-router',
'ion-route',
'ion-route-redirect',
'ion-router-link',
'ion-router-outlet',
// tabs
'ion-tabs',
'ion-tab',
// auxiliar
'ion-picker-legacy-column',
],
}).then((hydrateResults) => {
hydrateResults.diagnostics.forEach((d) => {
if (d.type === 'error') {
console.error(d.messageText);
}
else if (d.type === 'debug') {
console.debug(d.messageText);
}
else {
console.log(d.messageText);
}
});
if (doc.head != null) {
const styleElms = doc.head.querySelectorAll('style[data-styles]');
// eslint-disable-next-line @typescript-eslint/prefer-for-of
for (let i = 0; i < styleElms.length; i++) {
styleElms[i].setAttribute('ng-transition', appId);
}
}
if (doc.body != null) {
const ionPages = doc.body.querySelectorAll('.ion-page.ion-page-invisible');
// eslint-disable-next-line @typescript-eslint/prefer-for-of
for (let i = 0; i < ionPages.length; i++) {
ionPages[i].classList.remove('ion-page-invisible');
}
}
});
};
}
/**
* Generated bundle index. Do not edit.
*/
export { IonicServerModule };
//# sourceMappingURL=ionic-angular-server.mjs.map