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