defuss 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 - 2024 Aron Homberg
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,89 @@
1
+ <h1 align="center">defuss</h1>
2
+
3
+ > Explicit simplicity for the web.
4
+
5
+ <h2 align="center">The Complexity Problem</h2>
6
+
7
+ Modern web frontend development is complex, but it must not be.
8
+ While others pile layers of complexity, changing APIs like underwear
9
+ and drive poor developers crazy, `defuss` brings back the feeling
10
+ of simple web development.
11
+
12
+ <h2 align="center">Features</h2>
13
+
14
+ - ✅ Does render JSX/TSX on client and server - DOM (`render`) and HTML (`renderToString`)
15
+ - ✅ Allows to render `Function`al components like `<Foo />`
16
+ - ✅ Supports every JSX feature you know, including Fragments `<></>`, Refs `ref={}` and `onMount={fn}`
17
+ - ✅ Allows to render a whole HTML document server-side, starting with `<html>`
18
+ - ✅ Available as a simple API
19
+ - ✅ Supports `dangerouslySetInnerHTML={{ __html: '<... />' }`
20
+ - ✅ Just `1113 byte` nano sized (ESM, gizpped) on client
21
+ - ✅ Just `1254 byte` nano sized (ESM, gizpped) on server
22
+ - ✅ Tree-shakable and side-effect free
23
+ - ✅ First class TypeScript support
24
+ - ✅ 100% Unit Test coverage
25
+
26
+ <img src="./coverage_report.png" />
27
+
28
+ <h2 align="center">Example usage</h2>
29
+
30
+ <h3 align="center">Setup</h3>
31
+
32
+ - yarn: `yarn add @jsheaven/render`
33
+ - npm: `npm install @jsheaven/render`
34
+
35
+ <h3 align="center">ESM</h3>
36
+
37
+ Configure the following values in your `tsconfig.json` or likewise,
38
+ in the configuration options of your favourite bundler:
39
+
40
+ ```json
41
+ {
42
+ ...
43
+ "jsx": "react",
44
+ "jsxFactory": "tsx",
45
+ "jsxFragmentFactory": "Fragment",
46
+ ...
47
+ }
48
+ ```
49
+
50
+ This will make sure that the JSX syntax is correctly transformed into a
51
+ JavaScript object tree (AOT, at compile time) that can be rendered by this library
52
+ at runtime (SSG, SSR or even, if desired, in-browser).
53
+
54
+ <h4 align="center">Server-side usage:</h4>
55
+
56
+ ```tsx
57
+ import { render, renderToString, tsx, Fragment } from '@jsheaven/render/dist/server.esm.js'
58
+
59
+ // HTMLElement
60
+ const dom: Node = render(
61
+ <html>
62
+ <head></head>
63
+ <body></body>
64
+ </html>,
65
+ )
66
+
67
+ // <html><head></head><body></body></html>
68
+ const html: string = renderToString(dom)
69
+ ```
70
+
71
+ <h4 align="center">Client-side/in-browser usage:</h4>
72
+
73
+ ```tsx
74
+ import { render, renderToString, tsx, Fragment } from '@jsheaven/render/dist/client.esm.js'
75
+
76
+ // HTMLParagraphElement
77
+ const dom: Node = render(<p>Some paragraph</p>)
78
+
79
+ // <p>Some paragraph</p>
80
+ const html: string = renderToString(dom)
81
+ ```
82
+
83
+ <h3 align="center">CommonJS</h3>
84
+
85
+ ```ts
86
+ const { render, renderToString, tsx } = require('@jsheaven/render/client.cjs.js')
87
+
88
+ // same API like ESM variant
89
+ ```
Binary file
@@ -0,0 +1 @@
1
+ "use strict";var i=Object.defineProperty;var t=(e,n)=>i(e,"name",{value:n,configurable:!0});var r=require("./index.cjs");const o=t((e,n=document.documentElement)=>r.renderIsomorphic(e,n,window),"render"),d=t(e=>new XMLSerializer().serializeToString(e),"renderToString");exports.Fragment=r.Fragment,exports.getRenderer=r.getRenderer,exports.renderIsomorphic=r.renderIsomorphic,exports.tsx=r.tsx,exports.render=o,exports.renderToString=d;
@@ -0,0 +1,9 @@
1
+ import { R as RenderInput, a as RenderResult } from './index-BFLjZCxl.js';
2
+ export { C as CSSProperties, m as Children, D as DomAbstractionImpl, F as FontFaceProperties, q as Fragment, G as Globals, K as KeyFrameProperties, P as Props, b as Ref, n as RenderNodeInput, o as RenderResultNode, U as UpdateFn, c as VAttributes, e as VNode, d as VNodeAttributes, k as VNodeChild, l as VNodeChildren, g as VNodeKey, j as VNodeRef, i as VNodeRefCallback, h as VNodeRefObject, f as VNodeType, V as VRef, p as getRenderer, r as renderIsomorphic, t as tsx } from './index-BFLjZCxl.js';
3
+ import * as CSS from 'csstype';
4
+ export { CSS };
5
+
6
+ declare const render: <T extends RenderInput>(virtualNode: T, parentDomElement?: Element | Document) => RenderResult<T>;
7
+ declare const renderToString: (el: Node) => string;
8
+
9
+ export { RenderInput, RenderResult, render, renderToString };
@@ -0,0 +1,9 @@
1
+ import { R as RenderInput, a as RenderResult } from './index-BFLjZCxl.js';
2
+ export { C as CSSProperties, m as Children, D as DomAbstractionImpl, F as FontFaceProperties, q as Fragment, G as Globals, K as KeyFrameProperties, P as Props, b as Ref, n as RenderNodeInput, o as RenderResultNode, U as UpdateFn, c as VAttributes, e as VNode, d as VNodeAttributes, k as VNodeChild, l as VNodeChildren, g as VNodeKey, j as VNodeRef, i as VNodeRefCallback, h as VNodeRefObject, f as VNodeType, V as VRef, p as getRenderer, r as renderIsomorphic, t as tsx } from './index-BFLjZCxl.js';
3
+ import * as CSS from 'csstype';
4
+ export { CSS };
5
+
6
+ declare const render: <T extends RenderInput>(virtualNode: T, parentDomElement?: Element | Document) => RenderResult<T>;
7
+ declare const renderToString: (el: Node) => string;
8
+
9
+ export { RenderInput, RenderResult, render, renderToString };
@@ -0,0 +1 @@
1
+ var t=Object.defineProperty;var n=(e,r)=>t(e,"name",{value:r,configurable:!0});import{renderIsomorphic as o}from"./index.mjs";import{Fragment as p,getRenderer as a,tsx as l}from"./index.mjs";const i=n((e,r=document.documentElement)=>o(e,r,window),"render"),m=n(e=>new XMLSerializer().serializeToString(e),"renderToString");export{p as Fragment,a as getRenderer,i as render,o as renderIsomorphic,m as renderToString,l as tsx};