Compare commits

..

64 Commits

Author SHA1 Message Date
b0c6fb662d 1.0.37 2023-05-01 14:42:57 +02:00
2a8c0dec5f fix(core): update 2023-05-01 14:42:57 +02:00
bb5f70a28e 1.0.36 2023-05-01 14:38:54 +02:00
e87833c59f fix(core): update 2023-05-01 14:38:53 +02:00
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
344e213c41 1.0.31 2021-08-16 17:47:21 +02:00
0ae13c970e fix(core): update 2021-08-16 17:47:20 +02:00
0502e7bc99 1.0.30 2021-08-16 16:26:13 +02:00
c0a425e16d fix(core): update 2021-08-16 16:26:13 +02:00
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
6b381d6115 1.0.24 2021-01-15 14:22:50 +00:00
25006901d9 fix(core): update 2021-01-15 14:22:49 +00:00
ee613836d1 1.0.23 2021-01-15 07:17:08 +00:00
4b53173618 fix(core): update 2021-01-15 07:17:08 +00:00
46a0220273 1.0.22 2021-01-12 15:17:31 +00:00
46a6c903e1 fix(core): update 2021-01-12 15:17:31 +00:00
134151eb70 1.0.21 2021-01-12 15:07:45 +00:00
ac1c3ac53d fix(core): update 2021-01-12 15:07:45 +00:00
09c23d04f4 1.0.20 2021-01-12 14:18:17 +00:00
3f359cb58c fix(core): update 2021-01-12 14:18:16 +00:00
a85eb48343 1.0.19 2021-01-09 01:48:37 +00:00
7c851b5ed2 fix(core): update 2021-01-09 01:48:36 +00:00
bcd69059f8 1.0.18 2021-01-08 22:08:02 +00:00
acba539a6f fix(core): update 2021-01-08 22:08:01 +00:00
446b4c38ea 1.0.17 2021-01-08 22:06:26 +00:00
bc6d3f45f8 fix(core): update 2021-01-08 22:06:25 +00:00
bd381ff23f 1.0.16 2020-08-06 17:50:03 +00:00
7e5bdf8521 fix(core): update 2020-08-06 17:50:00 +00:00
f427141c7c 1.0.15 2020-08-06 15:30:54 +00:00
e8191187a1 fix(core): update 2020-08-06 15:30:54 +00:00
6e1dcccd81 1.0.14 2020-08-06 15:18:54 +00:00
f8eee10a40 1.0.13 2020-08-06 15:18:48 +00:00
a6492a5465 1.0.12 2020-08-06 15:18:40 +00:00
eb9c2bd284 1.0.11 2020-08-06 15:17:01 +00:00
9991e234ce fix(core): update 2020-08-06 15:17:01 +00:00
d6ba1bbed7 1.0.10 2020-08-06 15:14:56 +00:00
46aefbde48 1.0.9 2020-08-06 15:13:57 +00:00
6087c08c0a 1.0.8 2020-08-06 15:13:39 +00:00
2158b366cb fix(core): update 2020-08-06 15:13:38 +00:00
b0e17be31e 1.0.7 2020-03-01 13:50:29 +00:00
a5151b6c89 fix(core): update 2020-03-01 13:50:28 +00:00
c8fc842869 1.0.6 2020-03-01 13:41:21 +00:00
2b2a0ee758 fix(core): update 2020-03-01 13:41:20 +00:00
c5740db2cd 1.0.5 2020-02-25 07:48:54 +00:00
989634d276 fix(core): update 2020-02-25 07:48:54 +00:00
e6a87e408e 1.0.4 2020-02-12 21:38:05 +00:00
637170ecd2 fix(core): update 2020-02-12 21:38:04 +00:00
23b4c1cf89 1.0.3 2020-02-12 21:32:26 +00:00
714073d1c6 fix(core): update 2020-02-12 21:32:25 +00:00
19 changed files with 4727 additions and 2027 deletions

4
.gitignore vendored
View File

@ -15,8 +15,6 @@ node_modules/
# builds # builds
dist/ dist/
dist_web/ dist_*/
dist_serve/
dist_ts_web/
# custom # custom

View File

@ -12,29 +12,38 @@ stages:
- release - release
- metadata - metadata
before_script:
- pnpm install -g pnpm
- pnpm install -g @shipzone/npmci
- npmci npm prepare
# ==================== # ====================
# security stage # security stage
# ==================== # ====================
mirror: # ====================
# security stage
# ====================
auditProductionDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security stage: security
script: script:
- npmci git mirror - npmci command npm config set registry https://registry.npmjs.org
- npmci command pnpm audit --audit-level=high --prod
tags: tags:
- lossless - lossless
- docker - docker
- notpriv allow_failure: true
snyk: auditDevDependencies:
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 command npm config set registry https://registry.npmjs.org
- npmci command npm install --ignore-scripts - npmci command pnpm audit --audit-level=high --dev
- npmci command snyk test
tags: tags:
- lossless - lossless
- docker - docker
- notpriv allow_failure: true
# ==================== # ====================
# test stage # test stage
@ -43,28 +52,22 @@ snyk:
testStable: testStable:
stage: test stage: test
script: script:
- npmci npm prepare
- npmci node install stable - npmci node install stable
- npmci npm install - npmci npm install
- 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
script: script:
- npmci npm prepare
- npmci node install stable - npmci node install stable
- npmci npm install - npmci npm install
- npmci command npm run build - npmci npm build
coverage: /\d+.?\d+?\%\s*coverage/ coverage: /\d+.?\d+?\%\s*coverage/
tags: tags:
- lossless
- docker - docker
- notpriv
release: release:
stage: release stage: release
@ -84,11 +87,12 @@ 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 typescript
- npmci npm prepare - npmci npm prepare
- npmci npm install - npmci npm install
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
tags: tags:
- lossless - lossless
- docker - docker
@ -108,11 +112,9 @@ trigger:
pages: pages:
stage: metadata stage: metadata
script: script:
- npmci node install lts - npmci node install stable
- npmci command npm install -g @gitzone/tsdoc
- npmci npm prepare
- npmci npm install - npmci npm install
- npmci command tsdoc - npmci command npm run buildDocs
tags: tags:
- lossless - lossless
- docker - docker

24
.vscode/launch.json vendored
View File

@ -2,28 +2,10 @@
"version": "0.2.0", "version": "0.2.0",
"configurations": [ "configurations": [
{ {
"name": "current file", "command": "npm test",
"type": "node", "name": "Run npm test",
"request": "launch", "request": "launch",
"args": [ "type": "node-terminal"
"${relativeFile}"
],
"runtimeArgs": ["-r", "@gitzone/tsrun"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": "test.ts",
"type": "node",
"request": "launch",
"args": [
"test/test.ts"
],
"runtimeArgs": ["-r", "@gitzone/tsrun"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
} }
] ]
} }

View File

@ -15,7 +15,7 @@
"properties": { "properties": {
"projectType": { "projectType": {
"type": "string", "type": "string",
"enum": ["website", "element", "service", "npm"] "enum": ["website", "element", "service", "npm", "wcc"]
} }
} }
} }

View File

@ -5,7 +5,7 @@
"githost": "gitlab.com", "githost": "gitlab.com",
"gitscope": "pushrocks", "gitscope": "pushrocks",
"gitrepo": "smartssr", "gitrepo": "smartssr",
"shortDescription": "a smart server side renderer supporting shadow dom", "description": "a smart server side renderer supporting shadow dom",
"npmPackagename": "@pushrocks/smartssr", "npmPackagename": "@pushrocks/smartssr",
"license": "MIT", "license": "MIT",
"projectDomain": "push.rocks" "projectDomain": "push.rocks"

1841
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,40 +1,50 @@
{ {
"name": "@pushrocks/smartssr", "name": "@pushrocks/smartssr",
"version": "1.0.2", "version": "1.0.37",
"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": {
"test": "(tstest test/ --web)", "test": "(tstest test/ --web)",
"build": "(tsbuild --web)", "build": "(tsbuild --web --allowimplicitany)",
"format": "(gitzone format)" "serve": "tsrun scripts/serve.ts",
"buildDocs": "tsdoc"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.0.22", "@gitzone/tsbuild": "^2.1.65",
"@gitzone/tstest": "^1.0.15", "@gitzone/tsrun": "^1.2.39",
"@pushrocks/tapbundle": "^3.0.7", "@gitzone/tstest": "^1.0.74",
"@types/node": "^10.11.7", "@pushrocks/smartserve": "^2.0.33",
"tslint": "^5.11.0", "@pushrocks/tapbundle": "^5.0.4",
"tslint-config-prettier": "^1.15.0" "@types/node": "^18.16.3",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0"
}, },
"dependencies": { "dependencies": {
"@pushrocks/smartdelay": "^2.0.6", "@pushrocks/smartdelay": "^3.0.1",
"@pushrocks/smartfile": "^7.0.8", "@pushrocks/smartfile": "^10.0.7",
"@pushrocks/smartpromise": "^3.0.6", "@pushrocks/smartpath": "^5.0.5",
"@pushrocks/smartpuppeteer": "^1.0.14" "@pushrocks/smartpromise": "^4.0.2",
"@pushrocks/smartpuppeteer": "^2.0.2",
"@pushrocks/smarttime": "^4.0.1"
}, },
"files": [ "files": [
"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"
],
"type": "module"
} }

4467
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -8,13 +8,19 @@ 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)
## Usage ## Usage
@ -26,7 +32,6 @@ We are always happy for code contributions. If you are not the code contributing
For further information read the linked docs at the top of this readme. For further information read the linked docs at the top of this readme.
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh) ## Legal
> MIT licensed | **©** [Task Venture Capital GmbH](https://task.vc)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy) | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com)

9
scripts/serve.ts Normal file
View File

@ -0,0 +1,9 @@
import * as smartserve from '@pushrocks/smartserve';
import * as path from 'path';
const smartserveInstance = new smartserve.SmartServe({
injectReload: true,
serveDir: path.join(__dirname, '../.nogit/')
});
smartserveInstance.start();

View File

@ -1,18 +1,16 @@
import { expect, tap } from '@pushrocks/tapbundle'; import { expect, tap } from '@pushrocks/tapbundle';
import * as smartssr from '../ts/index'; import * as smartssr from '../ts/index.js';
let testSSRInstance: smartssr.SmartSSR; 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,
});
tap.test('should start the smartssr instance', async () => {
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'); await testSSRInstance.renderPage('https://lossless.com');
}); });
tap.test('should render lossless.com', async () => { tap.test('should render lossless.com', async () => {
@ -20,11 +18,8 @@ tap.test('should render lossless.com', async () => {
}); });
tap.test('should render https://lossless.gmbh', async () => { tap.test('should render https://lossless.gmbh', async () => {
await testSSRInstance.renderPage('https://lossless.gmbh'); const renderedPage = await testSSRInstance.renderPage('https://lossless.gmbh');
}); console.log(renderedPage);
tap.test('should stop the smartssr instacne', async () => {
await testSSRInstance.stop();
}); });
tap.start(); tap.start();

8
ts/00_commitinfo_data.ts Normal file
View File

@ -0,0 +1,8 @@
/**
* autocreated commitinfo by @pushrocks/commitinfo
*/
export const commitinfo = {
name: '@pushrocks/smartssr',
version: '1.0.37',
description: 'a smart server side renderer supporting shadow dom'
}

View File

@ -1 +1 @@
export * from './smartssr.classes.smartssr'; export * from './smartssr.classes.smartssr.js';

View File

@ -1,43 +1,97 @@
import * as plugins from './smartssr.plugins'; import * as plugins from './smartssr.plugins.js';
import * as paths from './smartssr.paths'; import * as paths from './smartssr.paths.js';
import { serializeFunction } from './smartssr.function.serialize'; import { serializeFunction } from './smartssr.function.serialize.js';
export interface ISmartSSROptions {
debug: boolean;
}
/** /**
* *
*/ */
export class SmartSSR { export class SmartSSR {
public browser: plugins.smartpuppeteer.puppeteer.Browser; public options: ISmartSSROptions;
public async start() {
this.browser = await plugins.smartpuppeteer.getEnvAwareBrowserInstance(); constructor(optionsArg?: ISmartSSROptions) {
} this.options = {
public async stop() { ...{
if (this.browser) { debug: false,
await plugins.smartdelay.delayFor(3000); },
await this.browser.close(); ...optionsArg,
this.browser = null; };
} else {
console.log('browser was not in started mode');
}
} }
public async renderPage(urlArg: string) { public async renderPage(urlArg: string) {
const overallTimeMeasurement = new plugins.smarttime.HrtMeasurement();
overallTimeMeasurement.start();
const resultDeferred = plugins.smartpromise.defer<string>(); const resultDeferred = plugins.smartpromise.defer<string>();
const page = await this.browser.newPage(); const browser = new plugins.smartpuppeteer.IncognitoBrowser();
page.on('console', (event: any) => console.log(event._text)); const renderTimeMeasurement = new plugins.smarttime.HrtMeasurement();
let renderedPageString: string;
let screenshotBuffer: Buffer;
await browser.start();
try {
const context = await browser.getNewIncognitoContext();
const page = await context.newPage();
page.on('load', async (...args) => { // lets protect against left open tabs
// await plugins.smartdelay.delayFor(2000); plugins.smartdelay.delayFor(30000).then(async () => {
await page.$eval('body', serializeFunction); try {
const pageContent = await page.content(); await browser.stop();
const renderedPageString = pageContent; } catch {}
resultDeferred.resolve(renderedPageString);
plugins.smartfile.memory.toFsSync(renderedPageString, plugins.path.join(paths.noGitDir, 'test.html'));
}); });
await page.goto(urlArg); page.on('console', (msg) => {
const result = await resultDeferred.promise; console.log(`${urlArg}: ${msg.text()}`);
page.close(); });
return result;
renderTimeMeasurement.start();
await page.goto(urlArg, {
waitUntil: 'networkidle2',
timeout: 30000,
});
if (this.options.debug) {
screenshotBuffer = (await page.screenshot({
encoding: 'binary',
})) as Buffer;
}
await page.$eval('body', serializeFunction);
const pageContent = await page.content();
renderedPageString = pageContent;
resultDeferred.resolve(renderedPageString);
renderTimeMeasurement.stop();
// lets clean up async
await page.close();
await context.close();
} catch (e) {
console.log(e);
await browser.stop();
return;
}
await browser.stop();
overallTimeMeasurement.stop();
console.log(
`Overall it took ${overallTimeMeasurement.milliSeconds} milliseconds to render ${urlArg}`
);
console.log(
`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 resultDeferred.promise;
} }
} }

View File

@ -1,7 +1,7 @@
declare var document: Document; declare var document: Document;
export function serializeFunction(rootNode) { export function serializeFunction(rootNode: Node) {
const uuidv4 = () => { const uuidv4 = () => {
return 'unixxxxxxxxxxx'.replace(/[xy]/g, c => { return 'unixxxxxxxxxxx'.replace(/[xy]/g, (c) => {
const r = (Math.random() * 16) | 0; const r = (Math.random() * 16) | 0;
const v = c === 'x' ? r : (r & 0x3) | 0x8; const v = c === 'x' ? r : (r & 0x3) | 0x8;
return v.toString(16); return v.toString(16);
@ -24,55 +24,80 @@ export function serializeFunction(rootNode) {
styleTemplate = styleTemplate.replace(/}[ \t\n]+div/g, `}\n\n.${uuidID} div`); styleTemplate = styleTemplate.replace(/}[ \t\n]+div/g, `}\n\n.${uuidID} div`);
return styleTemplate; return styleTemplate;
}; };
const loopProtection: any[] = [];
function serializeNode(node: HTMLElement) { function serializeNode(nodeArg: HTMLElement | any, logThis = false) {
if (!node.tagName.includes('-')) { if (loopProtection.includes(nodeArg)) {
return; return;
} }
if (node.hasAttribute('smartssr')) { loopProtection.push(nodeArg);
console.log(`${node.tagName} is already serialized`); // console.log(nodeArg.nodeName);
return; if (nodeArg.shadowRoot) {
} nodeArg.setAttribute('smartssr', 'yes');
node.setAttribute('smartssr', 'yes');
// lets handle the current node // lets handle the current node
const nodeUUID = uuidv4(); const nodeUUID = uuidv4();
try { nodeArg.classList.add(nodeUUID);
node.classList.add(nodeUUID);
// find all slots
const slots = nodeArg.shadowRoot.querySelectorAll('slot');
// handle slot element
const slotsForMove: HTMLSlotElement[] = [];
slots.forEach((slot: any) => {
slotsForMove.push(slot);
});
for (const slot of slotsForMove) {
const slottedLightNodesForMove: any[] = [];
slot.assignedNodes().forEach((lightNode) => slottedLightNodesForMove.push(lightNode));
slottedLightNodesForMove.forEach((lightNode) =>
slot.parentNode.insertBefore(lightNode, slot)
);
}
// lets modify the css // lets modify the css
const children: HTMLElement[] = node.shadowRoot.children as any; const childNodes = nodeArg.shadowRoot.childNodes;
for (const childElement of children) { // tslint:disable-next-line: prefer-for-of
if (childElement.tagName === 'STYLE') { const noteForAppending: HTMLElement[] = [];
childElement.textContent = prependCss(nodeUUID, childElement.textContent);
}
serializeFunction(childElement);
}
const templateDom = document.createElement('template'); // lets care about static css first
templateDom.innerHTML = node.innerHTML; if (
(nodeArg.constructor as any).styles &&
const slot = node.shadowRoot.querySelector('slot'); (nodeArg.constructor as any).styles instanceof Array
node.childNodes.forEach(lightNode => slot.parentNode.insertBefore(lightNode, slot)); ) {
// remove slot element for (const objectArg of (nodeArg.constructor as any).styles) {
if (slot) { const styleTag = document.createElement('style');
slot.parentNode.removeChild(slot); styleTag.textContent = prependCss(nodeUUID, objectArg.cssText);
} noteForAppending.push(styleTag);
// move shadowDom into root node
node.shadowRoot.childNodes.forEach(shadowNode => node.appendChild(shadowNode));
// add original lightDom as template
if (templateDom.innerHTML !== '') {
node.appendChild(templateDom);
}
} catch (err) {
console.log('error:', err);
console.log(node.tagName);
} }
} }
[...rootNode.querySelectorAll('*')] childNodes.forEach((childNode: ChildNode) => {
.filter(element => /-/.test(element.nodeName)) if (childNode instanceof HTMLElement) {
.forEach(serializeNode); if (childNode.tagName === 'STYLE') {
childNode.textContent = prependCss(nodeUUID, childNode.textContent);
} else {
serializeNode(childNode, logThis);
}
noteForAppending.push(childNode);
}
});
while (nodeArg.firstChild) {
nodeArg.removeChild(nodeArg.firstChild);
}
noteForAppending.forEach((childNode) => {
nodeArg.append(childNode);
});
} else {
nodeArg.childNodes.forEach((nodeArg2: any) => {
serializeNode(nodeArg2, logThis);
});
}
}
rootNode.childNodes.forEach((nodeArg) => {
serializeNode(nodeArg);
});
} }

View File

@ -1,5 +1,5 @@
import * as plugins from './smartssr.plugins'; import * as plugins from './smartssr.plugins.js';
export const packageDir = plugins.path.join(__dirname, '../'); export const packageDir = plugins.path.join(plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url), '../');
export const noGitDir = plugins.path.join(packageDir, './.nogit'); export const noGitDir = plugins.path.join(packageDir, './.nogit');
plugins.smartfile.fs.ensureDirSync(noGitDir);

View File

@ -1,21 +1,14 @@
// node native // node native
import * as path from 'path'; import * as path from 'path';
import * as fs from 'fs';
export { export { path };
path,
fs
};
// @pushrocks scope // @pushrocks scope
import * as smartdelay from '@pushrocks/smartdelay'; import * as smartdelay from '@pushrocks/smartdelay';
import * as smartfile from '@pushrocks/smartfile'; import * as smartfile from '@pushrocks/smartfile';
import * as smartpuppeteer from '@pushrocks/smartpuppeteer'; import * as smartpuppeteer from '@pushrocks/smartpuppeteer';
import * as smartpath from '@pushrocks/smartpath';
import * as smartpromise from '@pushrocks/smartpromise'; import * as smartpromise from '@pushrocks/smartpromise';
import * as smarttime from '@pushrocks/smarttime';
export { export { smartdelay, smartfile, smartpath, smartpuppeteer, smartpromise, smarttime };
smartdelay,
smartfile,
smartpuppeteer,
smartpromise
};

10
tsconfig.json Normal file
View File

@ -0,0 +1,10 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"useDefineForClassFields": false,
"target": "ES2022",
"module": "ES2022",
"moduleResolution": "nodenext",
"esModuleInterop": true
}
}

View File

@ -1,17 +0,0 @@
{
"extends": ["tslint:latest", "tslint-config-prettier"],
"rules": {
"semicolon": [true, "always"],
"no-console": false,
"ordered-imports": false,
"object-literal-sort-keys": false,
"member-ordering": {
"options":{
"order": [
"static-method"
]
}
}
},
"defaultSeverity": "warning"
}