Compare commits

..

10 Commits

Author SHA1 Message Date
90089357cf 1.0.29 2021-08-16 10:31:39 +02:00
e36aed4b2b fix(core): update 2021-08-16 10:31:38 +02:00
4d2aa7a0ee 1.0.28 2021-08-16 10:30:46 +02:00
759fa1ff43 fix(core): update 2021-08-16 10:30:46 +02:00
042caeeeb5 1.0.27 2021-05-19 15:21:48 +00:00
6ddfaffbff fix(core): update 2021-05-19 15:21:47 +00:00
567507c88b 1.0.26 2021-05-19 11:32:13 +00:00
35f7bdd984 fix(core): update 2021-05-19 11:32:12 +00:00
602fa2b7ff 1.0.25 2021-05-19 01:33:59 +00:00
b1aae3e5b9 fix(core): update 2021-05-19 01:33:58 +00:00
6 changed files with 18580 additions and 1260 deletions

View File

@ -36,6 +36,7 @@ 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

19770
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"name": "@pushrocks/smartssr",
"version": "1.0.24",
"version": "1.0.29",
"private": false,
"description": "a smart server side renderer supporting shadow dom",
"main": "dist_ts/index.js",
@ -10,21 +10,21 @@
"scripts": {
"test": "(tstest test/ --web)",
"build": "(tsbuild --web)",
"format": "(gitzone format)"
"serve": "tsrun scripts/serve.ts"
},
"devDependencies": {
"@gitzone/tsbuild": "^2.1.25",
"@gitzone/tstest": "^1.0.52",
"@gitzone/tstest": "^1.0.54",
"@pushrocks/smartserve": "^1.1.41",
"@pushrocks/tapbundle": "^3.2.9",
"@types/node": "^14.14.20",
"@pushrocks/tapbundle": "^3.2.14",
"@types/node": "^15.3.0",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.15.0"
},
"dependencies": {
"@pushrocks/smartdelay": "^2.0.10",
"@pushrocks/smartfile": "^8.0.8",
"@pushrocks/smartpromise": "^3.1.3",
"@pushrocks/smartfile": "^8.0.10",
"@pushrocks/smartpromise": "^3.1.5",
"@pushrocks/smartpuppeteer": "^1.0.21",
"@pushrocks/smarttime": "^3.0.38"
},

View File

@ -9,12 +9,8 @@ tap.test('should create a valid smartssr instance', async () => {
});
});
tap.test('should start the smartssr instance', async () => {
await testSSRInstance.start();
});
tap.test('should render central.eu', async (tools) => {
await testSSRInstance.renderPage('https://in.work');
await testSSRInstance.renderPage('https://lossless.com');
});
tap.skip.test('should render lossless.com', async () => {
@ -23,10 +19,7 @@ tap.skip.test('should render lossless.com', async () => {
tap.skip.test('should render https://lossless.gmbh', async () => {
const renderedPage = await testSSRInstance.renderPage('https://lossless.gmbh');
});
tap.test('should stop the smartssr instance', async () => {
await testSSRInstance.stop();
console.log(renderedPage);
});
tap.start();

View File

@ -11,7 +11,6 @@ export interface ISmartSSROptions {
*
*/
export class SmartSSR {
public browser: plugins.smartpuppeteer.IncognitoBrowser;
public options: ISmartSSROptions;
constructor(optionsArg?: ISmartSSROptions) {
@ -23,26 +22,25 @@ export class SmartSSR {
};
}
public async start() {
this.browser = new plugins.smartpuppeteer.IncognitoBrowser();
await this.browser.start();
}
public async stop() {
if (this.browser) {
await plugins.smartdelay.delayFor(3000);
await this.browser.stop();
this.browser = null;
} else {
console.log('browser was not in started mode');
}
}
public async renderPage(urlArg: string) {
const overallTimeMeasurement = new plugins.smarttime.HrtMeasurement();
overallTimeMeasurement.start();
const resultDeferred = plugins.smartpromise.defer<string>();
const context = await this.browser.getNewIncognitoContext();
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()}`);
});
@ -71,7 +69,9 @@ export class SmartSSR {
renderTimeMeasurement.stop();
// lets clean up async
await page.close();
await context.close();
await browser.stop();
overallTimeMeasurement.stop();
console.log(

View File

@ -39,6 +39,8 @@ export function serializeFunction(rootNode) {
const nodeUUID = uuidv4();
nodeArg.classList.add(nodeUUID);
// find all slots
const slots = nodeArg.shadowRoot.querySelectorAll('slot');
// handle slot element
@ -59,6 +61,16 @@ export function serializeFunction(rootNode) {
const childNodes = nodeArg.shadowRoot.childNodes;
// tslint:disable-next-line: prefer-for-of
const noteForAppending: HTMLElement[] = [];
// lets care about static css first
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);
noteForAppending.push(styleTag);
}
}
childNodes.forEach((childNode) => {
if (childNode instanceof HTMLElement) {
if (childNode.tagName === 'STYLE') {