render(opts) {
        var _a;
        return __awaiter(this, void 0, void 0, function* () {
            const { inlineCriticalCss = true } = opts;
            if (opts.publicPath && opts.documentFilePath && opts.url !== undefined) {
                const url = new URL(opts.url);
                // Remove leading forward slash.
                const pathname = url.pathname.substring(1);
                const pagePath = resolve(opts.publicPath, pathname, 'index.html');
                if (pagePath !== resolve(opts.documentFilePath)) {
                    // View path doesn't match with prerender path.
                    let pageExists = this.pageExists.get(pagePath);
                    if (pageExists === undefined) {
                        pageExists = yield exists(pagePath);
                        this.pageExists.set(pagePath, pageExists);
                    }
                    if (pageExists) {
                        // Serve pre-rendered page.
                        return fs.promises.readFile(pagePath, 'utf-8');
                    }
                }
            }
            // if opts.document dosen't exist then opts.documentFilePath must
            const extraProviders = [...(opts.providers || []), ...(this.providers || [])];
            let doc = opts.document;
            if (!doc && opts.documentFilePath) {
                doc = yield this.getDocument(opts.documentFilePath);
            }
            if (doc) {
                extraProviders.push({
                    provide: INITIAL_CONFIG,
                    useValue: {
                        document: inlineCriticalCss
                            ? // Workaround for https://github.com/GoogleChromeLabs/critters/issues/64
                                doc.replace(/ media=\"print\" onload=\"this\.media='all'"><noscript><link .+?><\/noscript>/g, '>')
                            : doc,
                        url: opts.url,
                    },
                });
            }
            const moduleOrFactory = this.moduleOrFactory || opts.bootstrap;
            const factory = yield this.getFactory(moduleOrFactory);
            const html = yield renderModuleFactory(factory, { extraProviders });
            if (!inlineCriticalCss) {
                return html;
            }
            const { content, errors, warnings } = yield this.inlineCriticalCssProcessor.process(html, {
                outputPath: (_a = opts.publicPath) !== null && _a !== void 0 ? _a : (opts.documentFilePath ? dirname(opts.documentFilePath) : undefined),
            });
            // tslint:disable-next-line: no-console
            warnings === null || warnings === void 0 ? void 0 : warnings.forEach((m) => console.warn(m));
            // tslint:disable-next-line: no-console
            errors === null || errors === void 0 ? void 0 : errors.forEach((m) => console.error(m));
            return content;
        });
    }
/**
     * Render an HTML document for a specific URL with specified
     * render options
     */
Render an HTML document for a specific URL with specified
render options
Render an HTML document for a specific URL with specified render options
render(opts) {
        var _a;
        return __awaiter(this, void 0, void 0, function* () {
            const { inlineCriticalCss = true } = opts;
            if (opts.publicPath && opts.documentFilePath && opts.url !== undefined) {
                const url = new URL(opts.url);
                const pathname = url.pathname.substring(1);
                const pagePath = resolve(opts.publicPath, pathname, 'index.html');
                if (pagePath !== resolve(opts.documentFilePath)) {
                    let pageExists = this.pageExists.get(pagePath);
                    if (pageExists === undefined) {
                        pageExists = yield exists(pagePath);
                        this.pageExists.set(pagePath, pageExists);
                    }
                    if (pageExists) {
                        return fs.promises.readFile(pagePath, 'utf-8');
                    }
                }
            }
            const extraProviders = [...(opts.providers || []), ...(this.providers || [])];
            let doc = opts.document;
            if (!doc && opts.documentFilePath) {
                doc = yield this.getDocument(opts.documentFilePath);
            }
            if (doc) {
                extraProviders.push({
                    provide: INITIAL_CONFIG,
                    useValue: {
                        document: inlineCriticalCss
                            ? 
                                doc.replace(/ media=\"print\" onload=\"this\.media='all'"><noscript><link .+?><\/noscript>/g, '>')
                            : doc,
                        url: opts.url,
                    },
                });
            }
            const moduleOrFactory = this.moduleOrFactory || opts.bootstrap;
            const factory = yield this.getFactory(moduleOrFactory);
            const html = yield renderModuleFactory(factory, { extraProviders });
            if (!inlineCriticalCss) {
                return html;
            }
            const { content, errors, warnings } = yield this.inlineCriticalCssProcessor.process(html, {
                outputPath: (_a = opts.publicPath) !== null && _a !== void 0 ? _a : (opts.documentFilePath ? dirname(opts.documentFilePath) : undefined),
            });
            warnings === null || warnings === void 0 ? void 0 : warnings.forEach((m) => console.warn(m));
            errors === null || errors === void 0 ? void 0 : errors.forEach((m) => console.error(m));
            return content;
        });
    }
render ( opts ) { var _a ; return __awaiter ( this , void 0 , void 0 , function * ( ) { const { inlineCriticalCss = true } = opts ; if ( opts . publicPath && opts . documentFilePath && opts . url !== undefined ) { const url = new URL ( opts . url ) ; const pathname = url . pathname . substring ( 1 ) ; const pagePath = resolve ( opts . publicPath , pathname , 'index.html' ) ; if ( pagePath !== resolve ( opts . documentFilePath ) ) { let pageExists = this . pageExists . get ( pagePath ) ; if ( pageExists === undefined ) { pageExists = yield exists ( pagePath ) ; this . pageExists . set ( pagePath , pageExists ) ; } if ( pageExists ) { return fs . promises . readFile ( pagePath , 'utf-8' ) ; } } } const extraProviders = [ ... ( opts . providers || [ ] ) , ... ( this . providers || [ ] ) ] ; let doc = opts . document ; if ( ! doc && opts . documentFilePath ) { doc = yield this . getDocument ( opts . documentFilePath ) ; } if ( doc ) { extraProviders . push ( { provide : INITIAL_CONFIG , useValue : { document : inlineCriticalCss ? doc . replace ( /  media=\"print\" onload=\"this\.media='all'"><noscript><link .+?><\/noscript> / g , '>' ) : doc , url : opts . url , } , } ) ; } const moduleOrFactory = this . moduleOrFactory || opts . bootstrap ; const factory = yield this . getFactory ( moduleOrFactory ) ; const html = yield renderModuleFactory ( factory , { extraProviders } ) ; if ( ! inlineCriticalCss ) { return html ; } const { content , errors , warnings } = yield this . inlineCriticalCssProcessor . process ( html , { outputPath : ( _a = opts . publicPath ) !== null && _a !== void 0 ? _a : ( opts . documentFilePath ? dirname ( opts . documentFilePath ) : undefined ) , } ) ; warnings === null || warnings === void 0 ? void 0 : warnings . forEach ( ( m ) => console . warn ( m ) ) ; errors === null || errors === void 0 ? void 0 : errors . forEach ( ( m ) => console . error ( m ) ) ; return content ; } ) ; }
Render an HTML document for a specific URL with specified
 render options
Render an HTML document for a specific URL with specified render options
// Remove leading forward slash. // View path doesn't match with prerender path. // Serve pre-rendered page. // if opts.document dosen't exist then opts.documentFilePath must // Workaround for https://github.com/GoogleChromeLabs/critters/issues/64 // tslint:disable-next-line: no-console // tslint:disable-next-line: no-console