From 4e89196712c01f80cf080b823247bb19372949e7 Mon Sep 17 00:00:00 2001 From: Philipp Kunz Date: Sun, 14 Apr 2024 18:23:21 +0200 Subject: [PATCH] update tsconfig --- npmextra.json | 15 ++++-- package.json | 15 ++++-- readme.hints.md | 1 + readme.md | 130 ++++++++++++++++++++++++++++++++++++++---------- 4 files changed, 130 insertions(+), 31 deletions(-) create mode 100644 readme.hints.md diff --git a/npmextra.json b/npmextra.json index 2fdf1db..1824379 100644 --- a/npmextra.json +++ b/npmextra.json @@ -5,17 +5,26 @@ "githost": "code.foss.global", "gitscope": "push.rocks", "gitrepo": "smartssr", - "description": "a smart server side renderer supporting shadow dom", + "description": "A smart server-side renderer that supports shadow DOM.", "npmPackagename": "@push.rocks/smartssr", "license": "MIT", - "projectDomain": "push.rocks" + "projectDomain": "push.rocks", + "keywords": [ + "server-side rendering", + "shadow DOM", + "TypeScript", + "puppeteer", + "serialization", + "web development", + "node.js" + ] } }, "npmci": { "npmGlobalTools": [], "npmAccessLevel": "public" }, - "tsdocs": { + "tsdoc": { "legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n" } } \ No newline at end of file diff --git a/package.json b/package.json index 1fc09ae..698763e 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@push.rocks/smartssr", "version": "1.0.38", "private": false, - "description": "a smart server side renderer supporting shadow dom", + "description": "A smart server-side renderer that supports shadow DOM.", "main": "dist_ts/index.js", "typings": "dist_ts/index.d.ts", "author": "Lossless GmbH", @@ -43,5 +43,14 @@ "browserslist": [ "last 1 chrome versions" ], - "type": "module" -} + "type": "module", + "keywords": [ + "server-side rendering", + "shadow DOM", + "TypeScript", + "puppeteer", + "serialization", + "web development", + "node.js" + ] +} \ No newline at end of file diff --git a/readme.hints.md b/readme.hints.md new file mode 100644 index 0000000..0519ecb --- /dev/null +++ b/readme.hints.md @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/readme.md b/readme.md index 06a4d66..51e4f78 100644 --- a/readme.md +++ b/readme.md @@ -1,37 +1,117 @@ # @push.rocks/smartssr a smart server side renderer supporting shadow dom -## Availabililty and Links -* [npmjs.org (npm package)](https://www.npmjs.com/package/@push.rocks/smartssr) -* [gitlab.com (source)](https://gitlab.com/push.rocks/smartssr) -* [github.com (source mirror)](https://github.com/push.rocks/smartssr) -* [docs (typedoc)](https://push.rocks.gitlab.io/smartssr/) +## Install +To install `@push.rocks/smartssr`, use the following command with npm: -## Status for master +```bash +npm install @push.rocks/smartssr --save +``` -Status Category | Status Badge --- | -- -GitLab Pipelines | [![pipeline status](https://gitlab.com/push.rocks/smartssr/badges/master/pipeline.svg)](https://lossless.cloud) -GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/push.rocks/smartssr/badges/master/coverage.svg)](https://lossless.cloud) -npm | [![npm downloads per month](https://badgen.net/npm/dy/@push.rocks/smartssr)](https://lossless.cloud) -Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/push.rocks/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/@push.rocks/smartssr)](https://lossless.cloud) -PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@push.rocks/smartssr)](https://lossless.cloud) -BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@push.rocks/smartssr)](https://lossless.cloud) +Or with yarn: + +```bash +yarn add @push.rocks/smartssr +``` + +This will add `@push.rocks/smartssr` to your project's dependencies and make it available for import in your TypeScript files. ## Usage +### Introduction +`@push.rocks/smartssr` is a powerful package designed to facilitate server-side rendering with support for shadow DOM, making it an ideal choice for projects where SEO or initial load performance is critical while maintaining the benefits of Web Components. Below, we'll dive deep into how you can leverage `@push.rocks/smartssr` in your TypeScript projects. -Use TypeScript for best in class intellisense +### Getting Started +Before you can use `@push.rocks/smartssr`, ensure you have a TypeScript environment set up and configured to support ECMAScript modules (ESM). -## Contribution +#### Setting Up Your Project +1. Initialize your project (if you haven't already): -We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :) +```bash +npm init +``` -For further information read the linked docs at the top of this readme. +2. Add TypeScript to your project: -## 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) +```bash +npm install typescript --save-dev +``` + +3. Initialize TypeScript in your project: + +```bash +npx tsc --init +``` + +Make sure your `tsconfig.json` is configured to use ECMAScript modules by setting `"module": "ESNext"`. + +### Basic Usage + +First, import `SmartSSR` from the package: + +```typescript +import { SmartSSR } from '@push.rocks/smartssr'; +``` + +Create an instance of `SmartSSR`. You can pass options to the constructor to customize behavior, for instance, enabling debug mode: + +```typescript +const smartSSR = new SmartSSR({ + debug: true // Enables debug mode for additional logging +}); +``` + +### Rendering a Web Page +With `SmartSSR`, you can render any webpage, including those utilizing shadow DOM, and retrieve its HTML content as a string. This feature is particularly useful for SEO purposes and can be used to pre-render contents of single-page applications (SPAs) or web components. + +The `renderPage` method accepts a URL as a parameter and returns a Promise that resolves with the rendered HTML content of the page. + +```typescript +(async () => { + try { + const renderedHTML = await smartSSR.renderPage('https://example.com'); + console.log(renderedHTML); // Outputs the rendered HTML content + } catch (error) { + console.error(`Error rendering page: ${error}`); + } +})(); +``` + +### Advanced Usage + +#### Customizing Rendering Behavior +The `SmartSSR` constructor accepts various options allowing you to customize the behavior of the rendering process. For instance, setting the `debug` option to `true` enables additional logging, which can be helpful for development and debugging purposes. + +#### Handling Complex Scenarios +In more complex scenarios, such as when rendering web applications that rely heavily on dynamic content or client-side scripts, you might need to customize your rendering process further. This could involve manipulating the page or waiting for specific elements or data before considering the rendering process complete. + +`smartssr` leverages Puppeteer under the hood, which means you can use any Puppeteer functionality within your rendering logic if needed. For example, you could wait for a specific element to appear on the page before capturing the rendered content: + +```typescript +// Custom rendering logic +await page.waitForSelector('#dynamic-content-loaded', { timeout: 5000 }); +const dynamicContentHTML = await smartSSR.renderPage('https://dynamic-content-example.com'); +``` + +### Conclusion +`@push.rocks/smartssr` offers a streamlined and effective solution for server-side rendering with shadow DOM support, enabling improved SEO and performance for web applications. Whether you're rendering simple static pages or complex SPAs with dynamic content, `smartssr` provides the tools necessary to achieve your objectives efficiently. + +For further information and advanced configurations, refer to the [official documentation](https://push.rocks.gitlab.io/smartssr/) and explore the full capabilities of `@push.rocks/smartssr`. + +## License and Legal Information + +This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. + +**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file. + +### Trademarks + +This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH. + +### Company Information + +Task Venture Capital GmbH +Registered at District court Bremen HRB 35230 HB, Germany + +For any legal inquiries or if you require further information, please contact us via email at hello@task.vc. + +By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.