fix(core): update
This commit is contained in:
parent
90089357cf
commit
c0a425e16d
@ -36,7 +36,6 @@ auditProductionDependencies:
|
||||
- npmci command npm audit --audit-level=high --only=prod --production
|
||||
tags:
|
||||
- docker
|
||||
allow_failure: true
|
||||
|
||||
auditDevDependencies:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
|
@ -43,4 +43,4 @@
|
||||
"browserslist": [
|
||||
"last 1 chrome versions"
|
||||
]
|
||||
}
|
||||
}
|
@ -27,50 +27,57 @@ export class SmartSSR {
|
||||
overallTimeMeasurement.start();
|
||||
const resultDeferred = plugins.smartpromise.defer<string>();
|
||||
const browser = new plugins.smartpuppeteer.IncognitoBrowser();
|
||||
await browser.start();
|
||||
const context = await browser.getNewIncognitoContext();
|
||||
const page = await context.newPage();
|
||||
|
||||
// lets protext against left open tabs
|
||||
plugins.smartdelay.delayFor(30000).then(() => {
|
||||
if (!page.isClosed) {
|
||||
page.close();
|
||||
context.close();
|
||||
throw new Error(`failed to render ${urlArg}`);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
page.on('console', (msg) => {
|
||||
console.log(`${urlArg}: ${msg.text()}`);
|
||||
});
|
||||
|
||||
const renderTimeMeasurement = new plugins.smarttime.HrtMeasurement();
|
||||
renderTimeMeasurement.start();
|
||||
await page.goto(urlArg, {
|
||||
waitUntil: 'networkidle2',
|
||||
timeout: 30000,
|
||||
});
|
||||
|
||||
let renderedPageString: string;
|
||||
let screenshotBuffer: Buffer;
|
||||
await browser.start();
|
||||
try {
|
||||
const context = await browser.getNewIncognitoContext();
|
||||
const page = await context.newPage();
|
||||
|
||||
if (this.options.debug) {
|
||||
screenshotBuffer = await page.screenshot({
|
||||
encoding: 'binary',
|
||||
// lets protect against left open tabs
|
||||
plugins.smartdelay.delayFor(30000).then(async () => {
|
||||
if (!page.isClosed) {
|
||||
try {
|
||||
await page.close();
|
||||
await context.close();
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
} finally {
|
||||
await browser.stop();
|
||||
}
|
||||
throw new Error(`failed to render ${urlArg}`);
|
||||
}
|
||||
});
|
||||
|
||||
page.on('console', (msg) => {
|
||||
console.log(`${urlArg}: ${msg.text()}`);
|
||||
});
|
||||
|
||||
renderTimeMeasurement.start();
|
||||
await page.goto(urlArg, {
|
||||
waitUntil: 'networkidle2',
|
||||
timeout: 30000,
|
||||
});
|
||||
|
||||
if (this.options.debug) {
|
||||
screenshotBuffer = await page.screenshot({
|
||||
encoding: 'binary',
|
||||
});
|
||||
}
|
||||
|
||||
await page.$eval('body', serializeFunction);
|
||||
const pageContent = await page.content();
|
||||
renderedPageString = pageContent;
|
||||
resultDeferred.resolve(renderedPageString);
|
||||
renderTimeMeasurement.stop();
|
||||
|
||||
// lets clean up async
|
||||
await page.close();
|
||||
await context.close();
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
|
||||
await page.$eval('body', serializeFunction);
|
||||
const pageContent = await page.content();
|
||||
const renderedPageString = pageContent;
|
||||
resultDeferred.resolve(renderedPageString);
|
||||
|
||||
const result = await resultDeferred.promise;
|
||||
renderTimeMeasurement.stop();
|
||||
|
||||
// lets clean up async
|
||||
await page.close();
|
||||
await context.close();
|
||||
await browser.stop();
|
||||
|
||||
overallTimeMeasurement.stop();
|
||||
@ -91,6 +98,6 @@ export class SmartSSR {
|
||||
fs.writeFileSync(plugins.path.join(paths.noGitDir, 'test.png'), screenshotBuffer);
|
||||
}
|
||||
|
||||
return result;
|
||||
return resultDeferred.promise;
|
||||
}
|
||||
}
|
||||
|
@ -63,7 +63,10 @@ export function serializeFunction(rootNode) {
|
||||
const noteForAppending: HTMLElement[] = [];
|
||||
|
||||
// lets care about static css first
|
||||
if ((nodeArg.constructor as any).styles && (nodeArg.constructor as any).styles instanceof Array) {
|
||||
if (
|
||||
(nodeArg.constructor as any).styles &&
|
||||
(nodeArg.constructor as any).styles instanceof Array
|
||||
) {
|
||||
for (const objectArg of (nodeArg.constructor as any).styles) {
|
||||
const styleTag = document.createElement('style');
|
||||
styleTag.textContent = prependCss(nodeUUID, objectArg.cssText);
|
||||
|
Loading…
Reference in New Issue
Block a user