Compare commits

...

7 Commits

Author SHA1 Message Date
cc5f93305b 1.0.35 2021-08-17 23:33:47 +02:00
67052baad0 1.0.34 2021-08-17 23:18:45 +02:00
08fc62d06f fix(core): update 2021-08-17 23:18:44 +02:00
975e463fd6 1.0.33 2021-08-17 15:42:38 +02:00
3bc93871f9 fix(core): update 2021-08-17 15:42:37 +02:00
49db495bb9 1.0.32 2021-08-17 12:54:20 +02:00
d0ee536301 fix(core): update 2021-08-17 12:54:19 +02:00
5 changed files with 6277 additions and 8636 deletions

14883
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.31",
"version": "1.0.35",
"private": false,
"description": "a smart server side renderer supporting shadow dom",
"main": "dist_ts/index.js",
@ -13,19 +13,19 @@
"serve": "tsrun scripts/serve.ts"
},
"devDependencies": {
"@gitzone/tsbuild": "^2.1.25",
"@gitzone/tsbuild": "^2.1.26",
"@gitzone/tstest": "^1.0.54",
"@pushrocks/smartserve": "^1.1.41",
"@pushrocks/tapbundle": "^3.2.14",
"@types/node": "^15.3.0",
"@types/node": "^16.6.1",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.15.0"
},
"dependencies": {
"@pushrocks/smartdelay": "^2.0.10",
"@pushrocks/smartdelay": "^2.0.13",
"@pushrocks/smartfile": "^8.0.10",
"@pushrocks/smartpromise": "^3.1.5",
"@pushrocks/smartpuppeteer": "^1.0.21",
"@pushrocks/smartpromise": "^3.1.6",
"@pushrocks/smartpuppeteer": "^1.0.27",
"@pushrocks/smarttime": "^3.0.38"
},
"files": [

View File

@ -13,11 +13,11 @@ tap.test('should render central.eu', async (tools) => {
await testSSRInstance.renderPage('https://lossless.com');
});
tap.skip.test('should render lossless.com', async () => {
tap.test('should render lossless.com', async () => {
await testSSRInstance.renderPage('https://lossless.com');
});
tap.skip.test('should render https://lossless.gmbh', async () => {
tap.test('should render https://lossless.gmbh', async () => {
const renderedPage = await testSSRInstance.renderPage('https://lossless.gmbh');
console.log(renderedPage);
});

View File

@ -55,7 +55,7 @@ export class SmartSSR {
if (this.options.debug) {
screenshotBuffer = await page.screenshot({
encoding: 'binary',
});
}) as Buffer;
}
await page.$eval('body', serializeFunction);
@ -69,6 +69,8 @@ export class SmartSSR {
await context.close();
} catch (e) {
console.log(e);
await browser.stop();
return;
}
await browser.stop();

View File

@ -1,5 +1,5 @@
declare var document: Document;
export function serializeFunction(rootNode) {
export function serializeFunction(rootNode: Node) {
const uuidv4 = () => {
return 'unixxxxxxxxxxx'.replace(/[xy]/g, (c) => {
const r = (Math.random() * 16) | 0;
@ -26,7 +26,7 @@ export function serializeFunction(rootNode) {
};
const loopProtection: any[] = [];
function serializeNode(nodeArg: HTMLElement, logThis = false) {
function serializeNode(nodeArg: HTMLElement | any, logThis = false) {
if (loopProtection.includes(nodeArg)) {
return;
}
@ -45,12 +45,12 @@ export function serializeFunction(rootNode) {
// handle slot element
const slotsForMove: HTMLSlotElement[] = [];
slots.forEach((slot) => {
slots.forEach((slot: any) => {
slotsForMove.push(slot);
});
for (const slot of slotsForMove) {
const slottedLightNodesForMove = [];
const slottedLightNodesForMove: any[] = [];
slot.assignedNodes().forEach((lightNode) => slottedLightNodesForMove.push(lightNode));
slottedLightNodesForMove.forEach((lightNode) =>
slot.parentNode.insertBefore(lightNode, slot)
@ -74,7 +74,7 @@ export function serializeFunction(rootNode) {
}
}
childNodes.forEach((childNode) => {
childNodes.forEach((childNode: ChildNode) => {
if (childNode instanceof HTMLElement) {
if (childNode.tagName === 'STYLE') {
childNode.textContent = prependCss(nodeUUID, childNode.textContent);