Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[add] Polyfill module for non-DOM environments #7

Merged
merged 2 commits into from
Oct 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,32 @@ on:
jobs:
Build-and-Publish:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v2
- uses: pnpm/action-setup@v4
with:
version: 9
- uses: actions/setup-node@v3

- uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20
registry-url: https://registry.npmjs.org
cache: pnpm

- name: Install Dependencies
run: pnpm i --frozen-lockfile

- name: Build & Publish
run: npm publish
run: npm publish --access public --provenance
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Update document
uses: peaceiris/actions-gh-pages@v3
uses: peaceiris/actions-gh-pages@v4
with:
publish_dir: ./docs
personal_token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
20 changes: 16 additions & 4 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,29 @@ console.log(newVNode);

### Node.js & Bun

```jsx
import { Readable } from 'stream';
import { createServer } from 'http';
#### `view.tsx`

```tsx
import { DOMRenderer } from 'dom-renderer';

const renderer = new DOMRenderer();

const Hello = () => <h1>Hello, JSX SSR!</h1>;

export const generateStream = () => renderer.renderToReadableStream(<Hello />);
```

#### `index.ts`

```js
import { Readable } from 'stream';
import { createServer } from 'http';
import 'dom-renderer/polyfill';

import { generateStream } from './view';

createServer((request, response) => {
const stream = renderer.renderToReadableStream(<Hello />);
const stream = generateStream();

Readable.fromWeb(stream).pipe(response);
}).listen(8080);
Expand Down
26 changes: 15 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dom-renderer",
"version": "2.3.0",
"version": "2.3.1",
"license": "LGPL-3.0-or-later",
"author": "shiy2008@gmail.com",
"description": "A light-weight DOM Renderer supports Web components standard & TypeScript language",
Expand All @@ -25,23 +25,27 @@
"main": "dist/index.js",
"dependencies": {
"declarative-shadow-dom-polyfill": "^0.4.0",
"tslib": "^2.6.3",
"tslib": "^2.8.0",
"web-streams-polyfill": "^4.0.0",
"web-utility": "^4.4.0"
"web-utility": "^4.4.1"
},
"peerDependencies": {
"happy-dom": "^14"
},
"devDependencies": {
"@happy-dom/jest-environment": "^14.12.3",
"@types/jest": "^29.5.12",
"@types/node": "^18.19.42",
"husky": "^9.1.2",
"@types/jest": "^29.5.14",
"@types/node": "^20.17.1",
"happy-dom": "^14.12.3",
"husky": "^9.1.6",
"jest": "^29.7.0",
"lint-staged": "^15.2.7",
"lint-staged": "^15.2.10",
"open-cli": "^8.0.0",
"prettier": "^3.3.3",
"ts-jest": "^29.2.3",
"typedoc": "^0.26.5",
"typedoc-plugin-mdn-links": "^3.2.5",
"typescript": "~5.5.4"
"ts-jest": "^29.2.5",
"typedoc": "^0.26.10",
"typedoc-plugin-mdn-links": "^3.3.4",
"typescript": "~5.6.3"
},
"prettier": {
"singleQuote": true,
Expand Down
Loading