UNPKG

2.58 kBJavaScriptView Raw
1"use strict";
2/**
3 * @fileoverview added by tsickle
4 * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
5 */
6Object.defineProperty(exports, "__esModule", { value: true });
7const common_1 = require("@angular/common");
8const core_1 = require("@angular/core");
9const platform_server_1 = require("@angular/platform-server");
10const hydrate_1 = require("@ionic/core/hydrate");
11// @dynamic
12class IonicServerModule {
13}
14IonicServerModule.decorators = [
15 { type: core_1.NgModule, args: [{
16 providers: [
17 {
18 provide: platform_server_1.BEFORE_APP_SERIALIZED,
19 useFactory: hydrateIonicComponents,
20 multi: true,
21 deps: [common_1.DOCUMENT, core_1.APP_ID]
22 }
23 ]
24 },] },
25];
26exports.IonicServerModule = IonicServerModule;
27// @dynamic
28/**
29 * @param {?} doc
30 * @param {?} appId
31 * @return {?}
32 */
33function hydrateIonicComponents(doc, appId) {
34 return (/**
35 * @return {?}
36 */
37 () => {
38 return hydrate_1.hydrateDocument(doc, {
39 clientHydrateAnnotations: false
40 })
41 .then((/**
42 * @param {?} hydrateResults
43 * @return {?}
44 */
45 hydrateResults => {
46 hydrateResults.diagnostics.forEach((/**
47 * @param {?} d
48 * @return {?}
49 */
50 d => {
51 if (d.type === 'error') {
52 console.error(d.messageText);
53 }
54 else if (d.type === 'debug') {
55 console.debug(d.messageText);
56 }
57 else {
58 console.log(d.messageText);
59 }
60 }));
61 if (doc.head != null) {
62 /** @type {?} */
63 const styleElms = (/** @type {?} */ (doc.head.querySelectorAll('style[data-styles]')));
64 for (let i = 0; i < styleElms.length; i++) {
65 styleElms[i].setAttribute('ng-transition', appId);
66 }
67 }
68 if (doc.body != null) {
69 /** @type {?} */
70 const ionPages = (/** @type {?} */ (doc.body.querySelectorAll('.ion-page.ion-page-invisible')));
71 for (let i = 0; i < ionPages.length; i++) {
72 ionPages[i].classList.remove('ion-page-invisible');
73 }
74 }
75 }));
76 });
77}
78exports.hydrateIonicComponents = hydrateIonicComponents;