Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
cc5f93305b | |||
67052baad0 | |||
08fc62d06f | |||
975e463fd6 | |||
3bc93871f9 | |||
49db495bb9 | |||
d0ee536301 |
14883
package-lock.json
generated
14883
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
12
package.json
12
package.json
@ -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": [
|
||||
|
@ -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);
|
||||
});
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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);
|
||||
|
Reference in New Issue
Block a user