fix(core): update
This commit is contained in:
parent
d6ba1bbed7
commit
9991e234ce
4
.gitignore
vendored
4
.gitignore
vendored
@ -15,8 +15,6 @@ node_modules/
|
|||||||
|
|
||||||
# builds
|
# builds
|
||||||
dist/
|
dist/
|
||||||
dist_web/
|
dist_*/
|
||||||
dist_serve/
|
|
||||||
dist_ts_web/
|
|
||||||
|
|
||||||
# custom
|
# custom
|
@ -19,22 +19,23 @@ mirror:
|
|||||||
stage: security
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci git mirror
|
- npmci git mirror
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
|
|
||||||
snyk:
|
audit:
|
||||||
image: registry.gitlab.com/hosttoday/ht-docker-node:snyk
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
stage: security
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci command npm install --ignore-scripts
|
- npmci command npm install --ignore-scripts
|
||||||
- npmci command snyk test
|
- npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
- npmci command npm audit --audit-level=high
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
# test stage
|
# test stage
|
||||||
@ -49,9 +50,7 @@ testStable:
|
|||||||
- npmci npm test
|
- npmci npm test
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
|
||||||
- docker
|
- docker
|
||||||
- priv
|
|
||||||
|
|
||||||
testBuild:
|
testBuild:
|
||||||
stage: test
|
stage: test
|
||||||
@ -62,9 +61,7 @@ testBuild:
|
|||||||
- npmci command npm run build
|
- npmci command npm run build
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
|
||||||
|
|
||||||
release:
|
release:
|
||||||
stage: release
|
stage: release
|
||||||
@ -84,6 +81,8 @@ release:
|
|||||||
codequality:
|
codequality:
|
||||||
stage: metadata
|
stage: metadata
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
script:
|
script:
|
||||||
- npmci command npm install -g tslint typescript
|
- npmci command npm install -g tslint typescript
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
|
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@ -15,7 +15,7 @@
|
|||||||
"properties": {
|
"properties": {
|
||||||
"projectType": {
|
"projectType": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": ["website", "element", "service", "npm"]
|
"enum": ["website", "element", "service", "npm", "wcc"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
12
package.json
12
package.json
@ -3,8 +3,8 @@
|
|||||||
"version": "1.0.10",
|
"version": "1.0.10",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "a smart server side renderer supporting shadow dom",
|
"description": "a smart server side renderer supporting shadow dom",
|
||||||
"main": "dist/index.js",
|
"main": "dist_ts/index.js",
|
||||||
"typings": "dist/index.d.ts",
|
"typings": "dist_ts/index.d.ts",
|
||||||
"author": "Lossless GmbH",
|
"author": "Lossless GmbH",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@ -32,11 +32,15 @@
|
|||||||
"ts/**/*",
|
"ts/**/*",
|
||||||
"ts_web/**/*",
|
"ts_web/**/*",
|
||||||
"dist/**/*",
|
"dist/**/*",
|
||||||
"dist_web/**/*",
|
"dist_*/**/*",
|
||||||
|
"dist_ts/**/*",
|
||||||
"dist_ts_web/**/*",
|
"dist_ts_web/**/*",
|
||||||
"assets/**/*",
|
"assets/**/*",
|
||||||
"cli.js",
|
"cli.js",
|
||||||
"npmextra.json",
|
"npmextra.json",
|
||||||
"readme.md"
|
"readme.md"
|
||||||
|
],
|
||||||
|
"browserslist": [
|
||||||
|
"last 1 chrome versions"
|
||||||
]
|
]
|
||||||
}
|
}
|
21
readme.md
21
readme.md
@ -8,13 +8,20 @@ a smart server side renderer supporting shadow dom
|
|||||||
* [docs (typedoc)](https://pushrocks.gitlab.io/smartssr/)
|
* [docs (typedoc)](https://pushrocks.gitlab.io/smartssr/)
|
||||||
|
|
||||||
## Status for master
|
## Status for master
|
||||||
[![pipeline status](https://gitlab.com/pushrocks/smartssr/badges/master/pipeline.svg)](https://gitlab.com/pushrocks/smartssr/commits/master)
|
|
||||||
[![coverage report](https://gitlab.com/pushrocks/smartssr/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartssr/commits/master)
|
Status Category | Status Badge
|
||||||
[![npm downloads per month](https://img.shields.io/npm/dm/@pushrocks/smartssr.svg)](https://www.npmjs.com/package/@pushrocks/smartssr)
|
-- | --
|
||||||
[![Known Vulnerabilities](https://snyk.io/test/npm/@pushrocks/smartssr/badge.svg)](https://snyk.io/test/npm/@pushrocks/smartssr)
|
GitLab Pipelines | [![pipeline status](https://gitlab.com/pushrocks/smartssr/badges/master/pipeline.svg)](https://lossless.cloud)
|
||||||
[![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/pushrocks/smartssr/badges/master/coverage.svg)](https://lossless.cloud)
|
||||||
[![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
npm | [![npm downloads per month](https://badgen.net/npm/dy/@pushrocks/smartssr)](https://lossless.cloud)
|
||||||
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-prettier-ff69b4.svg)](https://prettier.io/)
|
Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/pushrocks/smartssr)](https://lossless.cloud)
|
||||||
|
TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
|
||||||
|
node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
|
Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
|
||||||
|
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@pushrocks/smartssr)](https://lossless.cloud)
|
||||||
|
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@pushrocks/smartssr)](https://lossless.cloud)
|
||||||
|
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@pushrocks/smartssr)](https://lossless.cloud)
|
||||||
|
Platform support | [![Supports Windows 10](https://badgen.net/badge/supports%20Windows%2010/yes/green?icon=windows)](https://lossless.cloud) [![Supports Mac OS X](https://badgen.net/badge/supports%20Mac%20OS%20X/yes/green?icon=apple)](https://lossless.cloud)
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ let testSSRInstance: smartssr.SmartSSR;
|
|||||||
|
|
||||||
tap.test('should create a valid smartssr instance', async () => {
|
tap.test('should create a valid smartssr instance', async () => {
|
||||||
testSSRInstance = new smartssr.SmartSSR({
|
testSSRInstance = new smartssr.SmartSSR({
|
||||||
debug: true
|
debug: true,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -13,8 +13,10 @@ tap.test('should start the smartssr instance', async () => {
|
|||||||
await testSSRInstance.start();
|
await testSSRInstance.start();
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should render central.eu', async tools => {
|
tap.test('should render central.eu', async (tools) => {
|
||||||
await testSSRInstance.renderPage('https://central.eu/article/5e76873b9cf69b7bf6bc78bc/Introducing%3A%20central.eu');
|
await testSSRInstance.renderPage(
|
||||||
|
'https://central.eu/article/5e76873b9cf69b7bf6bc78bc/Introducing%3A%20central.eu'
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.skip.test('should render lossless.com', async () => {
|
tap.skip.test('should render lossless.com', async () => {
|
||||||
|
@ -16,10 +16,10 @@ export class SmartSSR {
|
|||||||
|
|
||||||
constructor(optionsArg?: ISmartSSROptions) {
|
constructor(optionsArg?: ISmartSSROptions) {
|
||||||
this.options = {
|
this.options = {
|
||||||
... {
|
...{
|
||||||
debug: false
|
debug: false,
|
||||||
},
|
},
|
||||||
...optionsArg
|
...optionsArg,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,17 +42,17 @@ export class SmartSSR {
|
|||||||
const resultDeferred = plugins.smartpromise.defer<string>();
|
const resultDeferred = plugins.smartpromise.defer<string>();
|
||||||
const context = await this.browser.createIncognitoBrowserContext();
|
const context = await this.browser.createIncognitoBrowserContext();
|
||||||
const page = await context.newPage();
|
const page = await context.newPage();
|
||||||
page.on('console', msg => {
|
page.on('console', (msg) => {
|
||||||
console.log(`${urlArg}: ${msg.text()}`);
|
console.log(`${urlArg}: ${msg.text()}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
page.on('load', async (...args) => {
|
page.on('load', async (...args) => {
|
||||||
await plugins.smartdelay.delayFor(5000);
|
await plugins.smartdelay.delayFor(5000);
|
||||||
let screenshotBuffer: Buffer;
|
let screenshotBuffer: Buffer;
|
||||||
|
|
||||||
if (this.options.debug) {
|
if (this.options.debug) {
|
||||||
screenshotBuffer = await page.screenshot({
|
screenshotBuffer = await page.screenshot({
|
||||||
encoding: 'binary'
|
encoding: 'binary',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ export class SmartSSR {
|
|||||||
const pageContent = await page.content();
|
const pageContent = await page.content();
|
||||||
const renderedPageString = pageContent;
|
const renderedPageString = pageContent;
|
||||||
resultDeferred.resolve(renderedPageString);
|
resultDeferred.resolve(renderedPageString);
|
||||||
|
|
||||||
if (this.options.debug) {
|
if (this.options.debug) {
|
||||||
plugins.smartfile.memory.toFsSync(
|
plugins.smartfile.memory.toFsSync(
|
||||||
renderedPageString,
|
renderedPageString,
|
||||||
@ -69,7 +69,6 @@ export class SmartSSR {
|
|||||||
const fs = await import('fs');
|
const fs = await import('fs');
|
||||||
fs.writeFileSync(plugins.path.join(paths.noGitDir, 'test.png'), screenshotBuffer);
|
fs.writeFileSync(plugins.path.join(paths.noGitDir, 'test.png'), screenshotBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const renderTimeMeasurement = new plugins.smarttime.HrtMeasurement();
|
const renderTimeMeasurement = new plugins.smarttime.HrtMeasurement();
|
||||||
@ -82,8 +81,12 @@ export class SmartSSR {
|
|||||||
context.close();
|
context.close();
|
||||||
|
|
||||||
overallTimeMeasurement.stop();
|
overallTimeMeasurement.stop();
|
||||||
console.log(`Overall it took ${overallTimeMeasurement.milliSeconds} milliseconds to render ${urlArg}`);
|
console.log(
|
||||||
console.log(`The rendering alone took ${renderTimeMeasurement.milliSeconds} milliseconds for ${urlArg}`)
|
`Overall it took ${overallTimeMeasurement.milliSeconds} milliseconds to render ${urlArg}`
|
||||||
|
);
|
||||||
|
console.log(
|
||||||
|
`The rendering alone took ${renderTimeMeasurement.milliSeconds} milliseconds for ${urlArg}`
|
||||||
|
);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ export function serializeFunction(rootNode) {
|
|||||||
// console.log(nodeArg.nodeName);
|
// console.log(nodeArg.nodeName);
|
||||||
if (nodeArg.shadowRoot) {
|
if (nodeArg.shadowRoot) {
|
||||||
nodeArg.setAttribute('smartssr', 'yes');
|
nodeArg.setAttribute('smartssr', 'yes');
|
||||||
|
|
||||||
// lets handle the current node
|
// lets handle the current node
|
||||||
const nodeUUID = uuidv4();
|
const nodeUUID = uuidv4();
|
||||||
|
|
||||||
@ -64,7 +64,7 @@ export function serializeFunction(rootNode) {
|
|||||||
noteForAppending.push(childNode);
|
noteForAppending.push(childNode);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
noteForAppending.forEach(childNode => {
|
noteForAppending.forEach((childNode) => {
|
||||||
nodeArg.append(childNode);
|
nodeArg.append(childNode);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user