Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
bd381ff23f | |||
7e5bdf8521 | |||
f427141c7c | |||
e8191187a1 | |||
6e1dcccd81 | |||
f8eee10a40 | |||
a6492a5465 |
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartssr",
|
"name": "@pushrocks/smartssr",
|
||||||
"version": "1.0.11",
|
"version": "1.0.16",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartssr",
|
"name": "@pushrocks/smartssr",
|
||||||
"version": "1.0.11",
|
"version": "1.0.16",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "a smart server side renderer supporting shadow dom",
|
"description": "a smart server side renderer supporting shadow dom",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
|
@ -13,13 +13,13 @@ tap.test('should start the smartssr instance', async () => {
|
|||||||
await testSSRInstance.start();
|
await testSSRInstance.start();
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should render central.eu', async (tools) => {
|
tap.skip.test('should render central.eu', async (tools) => {
|
||||||
await testSSRInstance.renderPage(
|
await testSSRInstance.renderPage(
|
||||||
'https://central.eu/article/5e76873b9cf69b7bf6bc78bc/Introducing%3A%20central.eu'
|
'https://central.eu/article/5e76873b9cf69b7bf6bc78bc/Introducing%3A%20central.eu'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.skip.test('should render lossless.com', async () => {
|
tap.test('should render lossless.com', async () => {
|
||||||
await testSSRInstance.renderPage('https://lossless.com');
|
await testSSRInstance.renderPage('https://lossless.com');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -46,8 +46,12 @@ export class SmartSSR {
|
|||||||
console.log(`${urlArg}: ${msg.text()}`);
|
console.log(`${urlArg}: ${msg.text()}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
page.on('load', async (...args) => {
|
const renderTimeMeasurement = new plugins.smarttime.HrtMeasurement();
|
||||||
await plugins.smartdelay.delayFor(5000);
|
renderTimeMeasurement.start();
|
||||||
|
await page.goto(urlArg, {
|
||||||
|
waitUntil: 'networkidle2',
|
||||||
|
});
|
||||||
|
|
||||||
let screenshotBuffer: Buffer;
|
let screenshotBuffer: Buffer;
|
||||||
|
|
||||||
if (this.options.debug) {
|
if (this.options.debug) {
|
||||||
@ -61,19 +65,7 @@ export class SmartSSR {
|
|||||||
const renderedPageString = pageContent;
|
const renderedPageString = pageContent;
|
||||||
resultDeferred.resolve(renderedPageString);
|
resultDeferred.resolve(renderedPageString);
|
||||||
|
|
||||||
if (this.options.debug) {
|
|
||||||
plugins.smartfile.memory.toFsSync(
|
|
||||||
renderedPageString,
|
|
||||||
plugins.path.join(paths.noGitDir, 'test.html')
|
|
||||||
);
|
|
||||||
const fs = await import('fs');
|
|
||||||
fs.writeFileSync(plugins.path.join(paths.noGitDir, 'test.png'), screenshotBuffer);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const renderTimeMeasurement = new plugins.smarttime.HrtMeasurement();
|
|
||||||
renderTimeMeasurement.start();
|
|
||||||
await page.goto(urlArg);
|
|
||||||
const result = await resultDeferred.promise;
|
const result = await resultDeferred.promise;
|
||||||
renderTimeMeasurement.stop();
|
renderTimeMeasurement.stop();
|
||||||
|
|
||||||
@ -87,6 +79,17 @@ export class SmartSSR {
|
|||||||
console.log(
|
console.log(
|
||||||
`The rendering alone took ${renderTimeMeasurement.milliSeconds} milliseconds for ${urlArg}`
|
`The rendering alone took ${renderTimeMeasurement.milliSeconds} milliseconds for ${urlArg}`
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// debug
|
||||||
|
if (this.options.debug) {
|
||||||
|
plugins.smartfile.memory.toFsSync(
|
||||||
|
renderedPageString,
|
||||||
|
plugins.path.join(paths.noGitDir, 'test.html')
|
||||||
|
);
|
||||||
|
const fs = await import('fs');
|
||||||
|
fs.writeFileSync(plugins.path.join(paths.noGitDir, 'test.png'), screenshotBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,11 +42,18 @@ export function serializeFunction(rootNode) {
|
|||||||
const slots = nodeArg.shadowRoot.querySelectorAll('slot');
|
const slots = nodeArg.shadowRoot.querySelectorAll('slot');
|
||||||
|
|
||||||
// handle slot element
|
// handle slot element
|
||||||
|
const slotsForMove: HTMLSlotElement[] = [];
|
||||||
slots.forEach((slot) => {
|
slots.forEach((slot) => {
|
||||||
nodeArg.childNodes.forEach((lightNode) => slot.parentNode.insertBefore(lightNode, slot));
|
slotsForMove.push(slot);
|
||||||
slot.parentNode.removeChild(slot);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
for (const slot of slotsForMove) {
|
||||||
|
const slottedLightNodesForMove = [];
|
||||||
|
slot.assignedNodes().forEach((lightNode) => slottedLightNodesForMove.push(lightNode));
|
||||||
|
slottedLightNodesForMove.forEach((lightNode) => slot.parentNode.insertBefore(lightNode, slot));
|
||||||
|
}
|
||||||
|
|
||||||
// lets modify the css
|
// lets modify the css
|
||||||
const childNodes = nodeArg.shadowRoot.childNodes;
|
const childNodes = nodeArg.shadowRoot.childNodes;
|
||||||
// tslint:disable-next-line: prefer-for-of
|
// tslint:disable-next-line: prefer-for-of
|
||||||
@ -56,9 +63,6 @@ export function serializeFunction(rootNode) {
|
|||||||
if (childNode.tagName === 'STYLE') {
|
if (childNode.tagName === 'STYLE') {
|
||||||
childNode.textContent = prependCss(nodeUUID, childNode.textContent);
|
childNode.textContent = prependCss(nodeUUID, childNode.textContent);
|
||||||
} else {
|
} else {
|
||||||
if (nodeArg.tagName?.includes('ARTICLEGRID')) {
|
|
||||||
console.log('hello ' + childNode.id);
|
|
||||||
}
|
|
||||||
serializeNode(childNode, logThis);
|
serializeNode(childNode, logThis);
|
||||||
}
|
}
|
||||||
noteForAppending.push(childNode);
|
noteForAppending.push(childNode);
|
||||||
|
Reference in New Issue
Block a user