Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {DOCUMENT} from '@angular/common';
import {Inject, Injectable} from '@angular/core';
import {NavigationEnd, NavigationStart, Router} from '@angular/router';
import {BehaviorSubject, NEVER, Observable, of, from} from 'rxjs';
import {BehaviorSubject, NEVER, Observable, of} from 'rxjs';
import {
catchError,
filter,
Expand Down Expand Up @@ -167,7 +167,7 @@ export class TransferStateService {
/**
* starts monitoring the router, and keep the url from the last completed navigation handy.
*/
setupStartNavMonitoring() {
private setupStartNavMonitoring() {
if (!isScullyGenerated()) {
return;
}
Expand All @@ -176,7 +176,14 @@ export class TransferStateService {
this.nextUrl.subscribe();
}

async fetchTransferState(): Promise<void> {
useScullyTransferState<T>(name: string, originalState: Observable<T>): Observable<T> {
if (isScullyGenerated()) {
return this.getState(name);
}
return originalState.pipe(tap(state => this.setState(name, state)));
}

private async fetchTransferState(): Promise<void> {
/** helper to read the part before the first slash (ignores leading slash) */
const base = (url: string) => url.split('/').filter(part => part.trim() !== '')[0];
/** put this in the next event cycle so the correct route can be read */
Expand Down
2 changes: 2 additions & 0 deletions scully/utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {logError, logWarn, yellow} from './log';
import {validateConfig} from './validateConfig';
import {compileConfig} from './compileConfig';
import {readAngularJson} from './read-anguar-json';
import {cpus} from 'os';
export const angularRoot = findAngularJsonPath();
export const scullyConfig: ScullyConfig = {} as ScullyConfig;

Expand Down Expand Up @@ -46,6 +47,7 @@ const loadIt = async () => {
projectRoot: projectConfig.root,
distFolder,
inlineStateOnly: false,
maxRenderThreads: cpus().length,
appPort: /** 1864 */ 'herodevs'.split('').reduce((sum, token) => (sum += token.charCodeAt(0)), 1000),
staticport: /** 1668 */ 'scully'.split('').reduce((sum, token) => (sum += token.charCodeAt(0)), 1000),
reloadPort: /** 2667 */ 'scullyLiveReload'
Expand Down
4 changes: 2 additions & 2 deletions scully/utils/handlers/renderParallel.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import {cpus} from 'os';
import {performance} from 'perf_hooks';
import {routeContentRenderer} from '../../renderPlugins/routeContentRenderer';
import {writeToFs} from '../../systemPlugins/writeToFs.plugin';
import {asyncPool} from '../asyncPool';
import {scullyConfig} from '../config';
import {performanceIds} from '../performanceIds';

export async function renderParallel(dataRoutes) {
const renderRoute = route =>
routeContentRenderer(route).then((html: string) => writeToFs(route.route, html));
performance.mark('startRender');
performanceIds.add('Render');
const renderPool = await asyncPool(cpus().length, dataRoutes, renderRoute);
const renderPool = await asyncPool(scullyConfig.maxRenderThreads, dataRoutes, renderRoute);
performance.mark('stopRender');
return renderPool;
}
2 changes: 2 additions & 0 deletions scully/utils/interfacesandenums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ export interface ScullyConfig {
hostUrl?: string;
/** optional guessParserOptions, if this is provided we are going to pass those options to the guess parser. */
guessParserOptions?: GuessParserOptions;
/** the maximum of concurrent puppeteer tabs open. defaults to the available amounts of cores */
maxRenderThreads: number;
}

interface RouteConfig {
Expand Down