shwimple 3.0.0 → 4.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 +20 -20
- package/README.md +133 -12
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +4 -4
- package/dist/src/Shwimple.d.ts +5 -3
- package/dist/src/ShwimpleConvenience.d.ts +26 -0
- package/dist/src/ShwimpleDocument.d.ts +84 -77
- package/dist/src/ShwimpleElements.d.ts +46 -0
- package/dist/src/ShwimplePageBuilder.d.ts +21 -21
- package/dist/src/utils/IsNullOrEmpty.d.ts +1 -1
- package/package.json +15 -6
- package/index.ts +0 -10
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2021 wooffet
|
|
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
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 wooffet
|
|
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
21
|
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,12 +1,133 @@
|
|
|
1
|
-
# shwimple
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
# shwimple
|
|
2
|
+
|
|
3
|
+
shwimple - an opinionated, backend-first HTML builder for composing pages without a frontend framework
|
|
4
|
+
|
|
5
|
+
npm: <https://www.npmjs.com/package/shwimple>
|
|
6
|
+
demo app: <https://github.com/wooffet/shwimple-demo>
|
|
7
|
+
|
|
8
|
+
SemVer: Starting from `4.0.0`, releases follow semantic versioning.
|
|
9
|
+
|
|
10
|
+
## What is it?
|
|
11
|
+
|
|
12
|
+
shwimple lets you assemble HTML documents using reusable functions (components) on the server. It favors a simple, consistent structure so you can build full pages without writing frontend JavaScript logic or a separate templating layer.
|
|
13
|
+
|
|
14
|
+
## Usage (component-style helpers)
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
import { definePage, component, head, body, main, el, h1, p, title, cx } from 'shwimple';
|
|
18
|
+
|
|
19
|
+
const Hero = component('Hero', () =>
|
|
20
|
+
el(
|
|
21
|
+
'section',
|
|
22
|
+
{ id: 'hero', className: cx('hero', 'text-center', 'mt-10') },
|
|
23
|
+
h1('Build from the backend'),
|
|
24
|
+
p('No frontend logic required.')
|
|
25
|
+
)
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
const SiteHead = component('SiteHead', () => title('Shwimple Demo'));
|
|
29
|
+
|
|
30
|
+
const page = definePage('Shwimple Demo', head(SiteHead), body(main(Hero)));
|
|
31
|
+
const html = page.renderToString();
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Boilerplate layouts
|
|
35
|
+
|
|
36
|
+
Built-in layouts: `standard`, `docs`, `landing`.
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
import { definePageWithBoilerplate, head, body, main } from 'shwimple';
|
|
40
|
+
|
|
41
|
+
const page = definePageWithBoilerplate(
|
|
42
|
+
'docs',
|
|
43
|
+
'Docs Site',
|
|
44
|
+
head(() => null),
|
|
45
|
+
body(main(() => null))
|
|
46
|
+
);
|
|
47
|
+
const html = page.renderToString();
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Run layout examples
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
npm run example:standard
|
|
54
|
+
npm run example:docs
|
|
55
|
+
npm run example:landing
|
|
56
|
+
npm run example:charts
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Example: Chart.js from CDN
|
|
60
|
+
|
|
61
|
+
This example pulls Chart.js from a CDN and renders a few charts with fake data.
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
import { definePageWithBoilerplate, head, body, main, el, h1, p, script } from 'shwimple';
|
|
65
|
+
|
|
66
|
+
const Charts = () =>
|
|
67
|
+
el(
|
|
68
|
+
'section',
|
|
69
|
+
{ id: 'charts', className: 'charts' },
|
|
70
|
+
h1('Charts Demo'),
|
|
71
|
+
p('Chart.js loaded from CDN'),
|
|
72
|
+
el(
|
|
73
|
+
'div',
|
|
74
|
+
{ className: 'grid' },
|
|
75
|
+
el('canvas', { id: 'salesChart' }),
|
|
76
|
+
el('canvas', { id: 'trafficChart' }),
|
|
77
|
+
el('canvas', { id: 'regionChart' })
|
|
78
|
+
)
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
const page = definePageWithBoilerplate(
|
|
82
|
+
'standard',
|
|
83
|
+
'Charts Demo',
|
|
84
|
+
head(() => [
|
|
85
|
+
script({ attrs: { src: 'https://cdn.jsdelivr.net/npm/chart.js' } }),
|
|
86
|
+
script(
|
|
87
|
+
{
|
|
88
|
+
attrs: { type: 'text/javascript' },
|
|
89
|
+
},
|
|
90
|
+
`
|
|
91
|
+
window.addEventListener('load', () => {
|
|
92
|
+
const sales = document.getElementById('salesChart');
|
|
93
|
+
const traffic = document.getElementById('trafficChart');
|
|
94
|
+
const region = document.getElementById('regionChart');
|
|
95
|
+
|
|
96
|
+
new Chart(sales, {
|
|
97
|
+
type: 'bar',
|
|
98
|
+
data: {
|
|
99
|
+
labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May'],
|
|
100
|
+
datasets: [{ label: 'Sales', data: [12, 19, 7, 14, 9] }]
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
new Chart(traffic, {
|
|
105
|
+
type: 'line',
|
|
106
|
+
data: {
|
|
107
|
+
labels: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'],
|
|
108
|
+
datasets: [{ label: 'Visitors', data: [120, 180, 90, 200, 160] }]
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
new Chart(region, {
|
|
113
|
+
type: 'pie',
|
|
114
|
+
data: {
|
|
115
|
+
labels: ['Americas', 'EMEA', 'APAC'],
|
|
116
|
+
datasets: [{ label: 'Regions', data: [45, 30, 25] }]
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
`
|
|
121
|
+
),
|
|
122
|
+
]),
|
|
123
|
+
body(main(Charts))
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
const html = page.renderToString();
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## TODO
|
|
130
|
+
|
|
131
|
+
- Add HTML escaping for text and attributes
|
|
132
|
+
- Implement recursive query helpers (e.g., `querySelectorById`)
|
|
133
|
+
- Add convenience helpers for head metadata (charset, viewport, stylesheet)
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { ShwimpleBuildFunction, ShwimplePageBuilder, TryAddFuncResult, ShwimpleDocument, ShwimpleNode, ShwimpleElementNode, ShwimpleHeadNode, ShwimpleBodyNode, } from './src/Shwimple';
|
|
1
|
+
export { ShwimpleBuildFunction, ShwimplePageBuilder, TryAddFuncResult, ShwimpleDocument, ShwimpleNode, ShwimpleElementNode, ShwimpleHeadNode, ShwimpleBodyNode, } from './src/Shwimple';
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var w=
|
|
1
|
+
var a=class r{mainNode;headNode;bodyNode;childNodes;constructor(){this.childNodes=[],this.mainNode=new s("html"),this.headNode=new w,this.bodyNode=new S,this.childNodes.push(this.headNode),this.childNodes.push(this.bodyNode)}static createBoilerplateDocument=(e,t="standard")=>{let i=new r,o=new s("meta",void 0,{charset:"utf-8"}),l=new s("meta",void 0,{name:"viewport",content:"width=device-width, initial-scale=1"}),p=new s("title",e??""),m=new d("header","header-section","header-section"),u=new d("main","content-section","content-section"),x=new d("footer","footer-section","footer-section");if(i.headNode.appendChild(o),i.headNode.appendChild(l),i.headNode.appendChild(p),t!=="landing"){let h=new d("nav","nav-section","nav-section");m.appendChild(h)}if(i.bodyNode.appendChild(m),i.bodyNode.appendChild(u),t==="docs"){let h=new d("aside","aside-section","aside-section");i.bodyNode.appendChild(h)}return i.bodyNode.appendChild(x),i};static createEmptyDocument=()=>new r;createElement=(e,t,i)=>new d(e,t,i);querySelectorById=e=>{let t,i=this.childNodes.find(o=>o instanceof d&&o.id===e);return i&&(t=i),t};querySelectorByIndex=e=>{let t;if(e>this.childNodes.length)return t;let i=this.childNodes[e];return i&&(t=i),t};getHead=()=>this.headNode;getBody=()=>this.bodyNode;html="";getHtmlAsString=()=>{if(this.mainNode)return this.html=`<${this.mainNode.tag}>`,this.childNodes.forEach(e=>{this.parseChildNodes(e)}),this.html+=`</${this.mainNode.tag}>`,this.html};parseChildNodes=e=>{if(e instanceof c){e.textContent&&(this.html+=e.textContent);return}let t=this.getAttributes(e);this.html+=`<${e.tag}${t}>`,e.textContent&&(this.html+=e.textContent),e.children&&e.children.length>0&&e.children.forEach(i=>{this.parseChildNodes(i)}),this.html+=`</${e.tag}>`};getAttributes=e=>{let t={...e.attributes??{}};e instanceof d&&(e.id&&(t.id=e.id),e.className&&(t.class=e.className));let i=Object.entries(t).filter(([,o])=>o!==void 0&&o!=="").map(([o,l])=>`${o==="className"?"class":o}="${l}"`);return i.length===0?"":` ${i.join(" ")}`}},s=class{children;tag;textContent;attributes;constructor(e,t,i){this.tag=e,this.textContent=t,this.attributes=i}appendChild=e=>{this.children||(this.children=[]),this.children.push(e)};insertBefore=(e,t)=>{};insertAfter=(e,t)=>{};getParent=()=>this},d=class extends s{className;id;constructor(e,t,i,o,l){super(e,o,l),this.id=t,this.className=i}};var c=class extends s{constructor(e){super("#text",e)}};var w=class extends s{constructor(){super("head")}},S=class extends s{constructor(){super("body")}};var f=(...r)=>e=>r.reduce((t,i)=>i(t),e),g=class{page;buildFunctions=[];constructor(e,t="standard"){this.page=a.createBoilerplateDocument(e,t)}addRenderFunction=e=>(e.id||(e.id="blah"),this.buildFunctions.push(e),e.id);addRenderFunctionAt=(e,t)=>(e.id||(e.id="blah"),this.buildFunctions.splice(t,0,e),e.id);tryAddRenderFunctionBeforeFuncId=(e,t)=>{e.id||(e.id="blah");let i={success:!1,id:e.id},o=this.buildFunctions.findIndex(p=>p.id===t),l=o-1<0?0:o-1;return l&&(this.buildFunctions.splice(l,0,e),i.success=!0),i};tryAddRenderFunctionAfterFuncId=(e,t)=>{e.id||(e.id="blah");let i={success:!1,id:e.id},o=this.buildFunctions.findIndex(m=>m.id===t),l=this.buildFunctions.length-1,p=o+1>l?l:o-1;return p&&(this.buildFunctions.splice(p,0,e),i.success=!0),i};builder=f(...this.buildFunctions);build=()=>this.buildFunctions.length<=0?void 0:f(...this.buildFunctions)(this.page);buildAsString=()=>this.buildFunctions.length<=0?void 0:f(...this.buildFunctions)(this.page).getHtmlAsString()};var b=r=>!(!r||typeof r!="object"||r instanceof s||r instanceof c),y=r=>{let e=[];return r.forEach(t=>{if(!(t==null||t===!1)){if(t instanceof s){e.push(t);return}e.push(new c(String(t)))}}),e};var N=(r,e,...t)=>{let i,o=[];b(e)?(i=e,o=t):e!==void 0?o=[e,...t]:o=t;let l=i?.classList?.filter(h=>h&&h.trim().length>0)??[],p=l.length>0?l.join(" "):void 0,m=[i?.className,p].filter(Boolean).join(" ")||void 0,u=i?new d(r,i.id??"",m):new s(r);return i?.attrs&&(u.attributes={...i.attrs}),y(o).forEach(h=>u.appendChild(h)),u},n=r=>(e,...t)=>N(r,e,...t),C=n("div"),B=n("span"),F=n("section"),A=n("main"),I=n("article"),E=n("aside"),T=n("header"),D=n("footer"),R=n("nav"),P=n("h1"),v=n("h2"),H=n("h3"),L=n("p"),M=n("ul"),$=n("ol"),j=n("li"),z=n("a"),q=n("img"),V=n("button"),k=n("input"),K=n("form"),W=n("label"),G=n("strong"),J=n("em"),Q=n("code"),U=n("pre"),X=n("br"),Y=n("title"),Z=n("meta"),_=n("link"),O=n("script"),ee=n("style");export{S as ShwimpleBodyNode,a as ShwimpleDocument,d as ShwimpleElementNode,w as ShwimpleHeadNode,s as ShwimpleNode,g as ShwimplePageBuilder};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/ShwimpleDocument.ts", "../src/ShwimplePageBuilder.ts"],
|
|
4
|
-
"sourcesContent": ["export interface IShwimpleDocument {\r\n mainNode: ShwimpleMainNode;\r\n headNode: ShwimpleHeadNode;\r\n bodyNode: ShwimpleBodyNode;\r\n childNodes: ShwimpleNode[];\r\n createElement: (tag: string, id: string, className?: string) => ShwimpleNode;\r\n querySelectorById: (nodeId: string) => ShwimpleNode | undefined;\r\n querySelectorByIndex: (nodeIndex: number) => ShwimpleNode | undefined;\r\n getHead: () => ShwimpleNode;\r\n getBody: () => ShwimpleNode;\r\n getHtmlAsString: () => string | undefined;\r\n}\r\n\r\nexport interface IShwimpleNode {\r\n appendChild: (child: ShwimpleNode) => void;\r\n children?: ShwimpleNode[];\r\n insertBefore: (nodeToInsert: ShwimpleNode, locatorNode: ShwimpleNode) => void;\r\n insertAfter: (nodeToInsert: ShwimpleNode, locatorNode: ShwimpleNode) => void;\r\n getParent: () => ShwimpleNode; // TODO: Always return top level node if already main parent node e.g. <html></html>\r\n tag: string;\r\n textContent?: string;\r\n}\r\n\r\nexport interface IShwimpleElementNode extends IShwimpleNode {\r\n className?: string;\r\n id: string;\r\n}\r\n\r\nexport interface IShwimpleHeadElementNode extends IShwimpleNode {\r\n rel?: string;\r\n typeName?: string;\r\n href?: string;\r\n}\r\n\r\nexport class ShwimpleDocument implements IShwimpleDocument {\r\n mainNode: ShwimpleNode;\r\n headNode: ShwimpleHeadNode;\r\n bodyNode: ShwimpleBodyNode;\r\n childNodes: ShwimpleNode[];\r\n\r\n constructor() {\r\n this.childNodes = [];\r\n this.mainNode = new ShwimpleNode('html');\r\n this.headNode = new ShwimpleHeadNode();\r\n this.bodyNode = new ShwimpleBodyNode();\r\n this.childNodes.push(this.headNode);\r\n this.childNodes.push(this.bodyNode);\r\n }\r\n\r\n static createBoilerplateDocument = (title?: string) => {\r\n const doc = new ShwimpleDocument();\r\n const titleNode = new ShwimpleNode('title', title);\r\n const headerSectionNode = new ShwimpleElementNode('div', 'header-section', 'header-section');\r\n const contentSectionNode = new ShwimpleElementNode('div', 'content-section', 'content-section');\r\n doc.headNode.appendChild(titleNode);\r\n doc.bodyNode.appendChild(headerSectionNode);\r\n doc.bodyNode.appendChild(contentSectionNode);\r\n return doc;\r\n };\r\n static createEmptyDocument = () => {\r\n return new ShwimpleDocument();\r\n };\r\n createElement = (tag: string, id: string, className?: string) => {\r\n return new ShwimpleElementNode(tag, id, className);\r\n };\r\n querySelectorById = (nodeId: string) => {\r\n let result: ShwimpleNode | undefined = undefined;\r\n const node = this.childNodes.find((n) => n instanceof ShwimpleElementNode && n.id === nodeId);\r\n\r\n if (node) {\r\n result = node;\r\n }\r\n\r\n return result;\r\n };\r\n querySelectorByIndex = (nodeIndex: number) => {\r\n let result: ShwimpleNode | undefined = undefined;\r\n\r\n if (nodeIndex > this.childNodes.length) {\r\n return result;\r\n }\r\n\r\n const node = this.childNodes[nodeIndex];\r\n if (node) {\r\n result = node;\r\n }\r\n\r\n return result;\r\n };\r\n getHead = () => this.headNode;\r\n getBody = () => this.bodyNode;\r\n\r\n private html: string = '';\r\n getHtmlAsString = () => {\r\n if (!this.mainNode) {\r\n return undefined;\r\n }\r\n\r\n this.html = `<${this.mainNode.tag}>`;\r\n\r\n this.childNodes.forEach((node) => {\r\n this.parseChildNodes(node);\r\n });\r\n\r\n this.html += `</${this.mainNode.tag}>`;\r\n\r\n return this.html;\r\n };\r\n\r\n private parseChildNodes = (node: ShwimpleNode) => {\r\n this.html += `<${node.tag}>`;\r\n\r\n if (node.textContent) {\r\n this.html += node.textContent;\r\n }\r\n\r\n if (node.children && node.children.length > 0) {\r\n node.children.forEach((child) => {\r\n this.parseChildNodes(child);\r\n });\r\n }\r\n\r\n this.html += `</${node.tag}>`;\r\n };\r\n}\r\n\r\nexport class ShwimpleNode implements IShwimpleNode {\r\n children?: ShwimpleNode[];\r\n tag: string;\r\n textContent?: string;\r\n\r\n constructor(tag: string, textContent?: string) {\r\n this.tag = tag;\r\n this.textContent = textContent;\r\n }\r\n\r\n appendChild = (child: ShwimpleNode) => {\r\n if (!this.children) {\r\n this.children = [];\r\n }\r\n\r\n this.children.push(child);\r\n };\r\n insertBefore = (nodeToInsert: ShwimpleNode, locatorNode: ShwimpleNode) => {};\r\n insertAfter = (nodeToInsert: ShwimpleNode, locatorNode: ShwimpleNode) => {};\r\n getParent = () => {\r\n return this;\r\n };\r\n}\r\n\r\nexport class ShwimpleElementNode extends ShwimpleNode implements IShwimpleElementNode {\r\n className?: string;\r\n id: string;\r\n\r\n constructor(tag: string, id: string, className?: string, textContent?: string) {\r\n super(tag, textContent);\r\n this.id = id;\r\n this.className = className;\r\n }\r\n}\r\n\r\nexport class ShwimpleHeadElementNode extends ShwimpleNode implements IShwimpleHeadElementNode {\r\n rel?: string;\r\n typeName?: string;\r\n href?: string;\r\n\r\n constructor(rel?: string, typeName?: string, href?: string, textContent?: string) {\r\n super('head', textContent);\r\n this.rel = rel;\r\n this.typeName = typeName;\r\n this.href = href;\r\n }\r\n}\r\n\r\nexport class ShwimpleMainNode extends ShwimpleNode implements IShwimpleNode {\r\n constructor() {\r\n super('html');\r\n }\r\n}\r\n\r\nexport class ShwimpleHeadNode extends ShwimpleNode implements IShwimpleNode {\r\n constructor() {\r\n super('head');\r\n }\r\n}\r\n\r\nexport class ShwimpleBodyNode extends ShwimpleNode implements IShwimpleNode {\r\n constructor() {\r\n super('body');\r\n }\r\n}\r\n", "import { ShwimpleDocument } from './ShwimpleDocument';\r\n\r\nexport type ShwimpleBuildFunction = {\r\n id?: string;\r\n (value: ShwimpleDocument): ShwimpleDocument;\r\n};\r\n\r\nexport type TryAddFuncResult = {\r\n success: boolean;\r\n id: string;\r\n};\r\n\r\nconst buildPipe =\r\n (...fns: ShwimpleBuildFunction[]) =>\r\n (arg: ShwimpleDocument) =>\r\n fns.reduce((value, fn) => fn(value), arg);\r\n\r\nexport class ShwimplePageBuilder {\r\n page: ShwimpleDocument;\r\n buildFunctions: ShwimpleBuildFunction[] = [];\r\n\r\n constructor(title?: string) {\r\n this.page = ShwimpleDocument.createBoilerplateDocument(title);\r\n }\r\n\r\n addRenderFunction = (func: ShwimpleBuildFunction) => {\r\n // TODO: This check can probably be refactored somehow\r\n if (!func.id) {\r\n func.id = 'blah'; // TODO: implement proper uuid generation\r\n }\r\n\r\n this.buildFunctions.push(func);\r\n return func.id;\r\n };\r\n addRenderFunctionAt = (func: ShwimpleBuildFunction, index: number) => {\r\n if (!func.id) {\r\n func.id = 'blah'; // TODO: implement proper uuid generation\r\n }\r\n\r\n this.buildFunctions.splice(index, 0, func);\r\n return func.id;\r\n };\r\n tryAddRenderFunctionBeforeFuncId = (func: ShwimpleBuildFunction, locatorId: string) => {\r\n if (!func.id) {\r\n func.id = 'blah'; // TODO: implement proper uuid generation\r\n }\r\n\r\n const result: TryAddFuncResult = { success: false, id: func.id };\r\n\r\n const funcLocation = this.buildFunctions.findIndex((bf) => bf.id === locatorId);\r\n const index = funcLocation - 1 < 0 ? 0 : funcLocation - 1;\r\n if (index) {\r\n this.buildFunctions.splice(index, 0, func);\r\n result.success = true;\r\n }\r\n\r\n return result;\r\n };\r\n tryAddRenderFunctionAfterFuncId = (func: ShwimpleBuildFunction, locatorId: string) => {\r\n if (!func.id) {\r\n func.id = 'blah'; // TODO: implement proper uuid generation\r\n }\r\n\r\n const result: TryAddFuncResult = { success: false, id: func.id };\r\n\r\n const funcLocation = this.buildFunctions.findIndex((bf) => bf.id === locatorId);\r\n const currentLastIndex = this.buildFunctions.length - 1;\r\n const index = funcLocation + 1 > currentLastIndex ? currentLastIndex : funcLocation - 1;\r\n if (index) {\r\n this.buildFunctions.splice(index, 0, func);\r\n result.success = true;\r\n }\r\n\r\n return result;\r\n };\r\n private builder = buildPipe(...this.buildFunctions);\r\n build = () => {\r\n if (this.buildFunctions.length <= 0) {\r\n return undefined;\r\n }\r\n\r\n const builder = buildPipe(...this.buildFunctions);\r\n\r\n return builder(this.page);\r\n };\r\n buildAsString = () => {\r\n if (this.buildFunctions.length <= 0) {\r\n return undefined;\r\n }\r\n\r\n const builder = buildPipe(...this.buildFunctions);\r\n\r\n const builtPage = builder(this.page);\r\n return builtPage.getHtmlAsString();\r\n };\r\n}\r\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": []
|
|
3
|
+
"sources": ["../src/ShwimpleDocument.ts", "../src/ShwimplePageBuilder.ts", "../src/ShwimpleElements.ts"],
|
|
4
|
+
"sourcesContent": ["export interface IShwimpleDocument {\n mainNode: ShwimpleMainNode;\n headNode: ShwimpleHeadNode;\n bodyNode: ShwimpleBodyNode;\n childNodes: ShwimpleNode[];\n createElement: (tag: string, id: string, className?: string) => ShwimpleNode;\n querySelectorById: (nodeId: string) => ShwimpleNode | undefined;\n querySelectorByIndex: (nodeIndex: number) => ShwimpleNode | undefined;\n getHead: () => ShwimpleNode;\n getBody: () => ShwimpleNode;\n getHtmlAsString: () => string | undefined;\n}\n\nexport interface IShwimpleNode {\n appendChild: (child: ShwimpleNode) => void;\n children?: ShwimpleNode[];\n insertBefore: (nodeToInsert: ShwimpleNode, locatorNode: ShwimpleNode) => void;\n insertAfter: (nodeToInsert: ShwimpleNode, locatorNode: ShwimpleNode) => void;\n getParent: () => ShwimpleNode; // TODO: Always return top level node if already main parent node e.g. <html></html>\n tag: string;\n textContent?: string;\n attributes?: Record<string, string>;\n}\n\nexport interface IShwimpleElementNode extends IShwimpleNode {\n className?: string;\n id: string;\n}\n\nexport interface IShwimpleHeadElementNode extends IShwimpleNode {\n rel?: string;\n typeName?: string;\n href?: string;\n}\n\nexport type ShwimpleBoilerplateLayout = 'standard' | 'docs' | 'landing';\n\nexport class ShwimpleDocument implements IShwimpleDocument {\n mainNode: ShwimpleNode;\n headNode: ShwimpleHeadNode;\n bodyNode: ShwimpleBodyNode;\n childNodes: ShwimpleNode[];\n\n constructor() {\n this.childNodes = [];\n this.mainNode = new ShwimpleNode('html');\n this.headNode = new ShwimpleHeadNode();\n this.bodyNode = new ShwimpleBodyNode();\n this.childNodes.push(this.headNode);\n this.childNodes.push(this.bodyNode);\n }\n\n static createBoilerplateDocument = (title?: string, layout: ShwimpleBoilerplateLayout = 'standard') => {\n const doc = new ShwimpleDocument();\n const charsetNode = new ShwimpleNode('meta', undefined, { charset: 'utf-8' });\n const viewportNode = new ShwimpleNode('meta', undefined, {\n name: 'viewport',\n content: 'width=device-width, initial-scale=1',\n });\n const titleNode = new ShwimpleNode('title', title ?? '');\n const headerSectionNode = new ShwimpleElementNode('header', 'header-section', 'header-section');\n const contentSectionNode = new ShwimpleElementNode('main', 'content-section', 'content-section');\n const footerSectionNode = new ShwimpleElementNode('footer', 'footer-section', 'footer-section');\n doc.headNode.appendChild(charsetNode);\n doc.headNode.appendChild(viewportNode);\n doc.headNode.appendChild(titleNode);\n\n if (layout !== 'landing') {\n const navSectionNode = new ShwimpleElementNode('nav', 'nav-section', 'nav-section');\n headerSectionNode.appendChild(navSectionNode);\n }\n\n doc.bodyNode.appendChild(headerSectionNode);\n doc.bodyNode.appendChild(contentSectionNode);\n\n if (layout === 'docs') {\n const asideSectionNode = new ShwimpleElementNode('aside', 'aside-section', 'aside-section');\n doc.bodyNode.appendChild(asideSectionNode);\n }\n\n doc.bodyNode.appendChild(footerSectionNode);\n return doc;\n };\n static createEmptyDocument = () => {\n return new ShwimpleDocument();\n };\n createElement = (tag: string, id: string, className?: string) => {\n return new ShwimpleElementNode(tag, id, className);\n };\n querySelectorById = (nodeId: string) => {\n let result: ShwimpleNode | undefined = undefined;\n const node = this.childNodes.find((n) => n instanceof ShwimpleElementNode && n.id === nodeId);\n\n if (node) {\n result = node;\n }\n\n return result;\n };\n querySelectorByIndex = (nodeIndex: number) => {\n let result: ShwimpleNode | undefined = undefined;\n\n if (nodeIndex > this.childNodes.length) {\n return result;\n }\n\n const node = this.childNodes[nodeIndex];\n if (node) {\n result = node;\n }\n\n return result;\n };\n getHead = () => this.headNode;\n getBody = () => this.bodyNode;\n\n private html: string = '';\n getHtmlAsString = () => {\n if (!this.mainNode) {\n return undefined;\n }\n\n this.html = `<${this.mainNode.tag}>`;\n\n this.childNodes.forEach((node) => {\n this.parseChildNodes(node);\n });\n\n this.html += `</${this.mainNode.tag}>`;\n\n return this.html;\n };\n\n private parseChildNodes = (node: ShwimpleNode) => {\n if (node instanceof ShwimpleTextNode) {\n if (node.textContent) {\n this.html += node.textContent;\n }\n\n return;\n }\n\n const attributes = this.getAttributes(node);\n this.html += `<${node.tag}${attributes}>`;\n\n if (node.textContent) {\n this.html += node.textContent;\n }\n\n if (node.children && node.children.length > 0) {\n node.children.forEach((child) => {\n this.parseChildNodes(child);\n });\n }\n\n this.html += `</${node.tag}>`;\n };\n\n private getAttributes = (node: ShwimpleNode) => {\n const attributes: Record<string, string> = { ...(node.attributes ?? {}) };\n\n if (node instanceof ShwimpleElementNode) {\n if (node.id) {\n attributes.id = node.id;\n }\n\n if (node.className) {\n attributes.class = node.className;\n }\n }\n\n const pairs = Object.entries(attributes)\n .filter(([, value]) => value !== undefined && value !== '')\n .map(([key, value]) => {\n const attributeKey = key === 'className' ? 'class' : key;\n return `${attributeKey}=\"${value}\"`;\n });\n\n if (pairs.length === 0) {\n return '';\n }\n\n return ` ${pairs.join(' ')}`;\n };\n}\n\nexport class ShwimpleNode implements IShwimpleNode {\n children?: ShwimpleNode[];\n tag: string;\n textContent?: string;\n attributes?: Record<string, string>;\n\n constructor(tag: string, textContent?: string, attributes?: Record<string, string>) {\n this.tag = tag;\n this.textContent = textContent;\n this.attributes = attributes;\n }\n\n appendChild = (child: ShwimpleNode) => {\n if (!this.children) {\n this.children = [];\n }\n\n this.children.push(child);\n };\n insertBefore = (nodeToInsert: ShwimpleNode, locatorNode: ShwimpleNode) => {};\n insertAfter = (nodeToInsert: ShwimpleNode, locatorNode: ShwimpleNode) => {};\n getParent = () => {\n return this;\n };\n}\n\nexport class ShwimpleElementNode extends ShwimpleNode implements IShwimpleElementNode {\n className?: string;\n id: string;\n\n constructor(tag: string, id: string, className?: string, textContent?: string, attributes?: Record<string, string>) {\n super(tag, textContent, attributes);\n this.id = id;\n this.className = className;\n }\n}\n\nexport class ShwimpleHeadElementNode extends ShwimpleNode implements IShwimpleHeadElementNode {\n rel?: string;\n typeName?: string;\n href?: string;\n\n constructor(rel?: string, typeName?: string, href?: string, textContent?: string) {\n super('head', textContent);\n this.rel = rel;\n this.typeName = typeName;\n this.href = href;\n }\n}\n\nexport class ShwimpleTextNode extends ShwimpleNode implements IShwimpleNode {\n constructor(textContent: string) {\n super('#text', textContent);\n }\n}\n\nexport class ShwimpleMainNode extends ShwimpleNode implements IShwimpleNode {\n constructor() {\n super('html');\n }\n}\n\nexport class ShwimpleHeadNode extends ShwimpleNode implements IShwimpleNode {\n constructor() {\n super('head');\n }\n}\n\nexport class ShwimpleBodyNode extends ShwimpleNode implements IShwimpleNode {\n constructor() {\n super('body');\n }\n}\n", "import { ShwimpleBoilerplateLayout, ShwimpleDocument } from './ShwimpleDocument';\n\nexport type ShwimpleBuildFunction = {\n id?: string;\n (value: ShwimpleDocument): ShwimpleDocument;\n};\n\nexport type TryAddFuncResult = {\n success: boolean;\n id: string;\n};\n\nconst buildPipe =\n (...fns: ShwimpleBuildFunction[]) =>\n (arg: ShwimpleDocument) =>\n fns.reduce((value, fn) => fn(value), arg);\n\nexport class ShwimplePageBuilder {\n page: ShwimpleDocument;\n buildFunctions: ShwimpleBuildFunction[] = [];\n\n constructor(title?: string, layout: ShwimpleBoilerplateLayout = 'standard') {\n this.page = ShwimpleDocument.createBoilerplateDocument(title, layout);\n }\n\n addRenderFunction = (func: ShwimpleBuildFunction) => {\n // TODO: This check can probably be refactored somehow\n if (!func.id) {\n func.id = 'blah'; // TODO: implement proper uuid generation\n }\n\n this.buildFunctions.push(func);\n return func.id;\n };\n addRenderFunctionAt = (func: ShwimpleBuildFunction, index: number) => {\n if (!func.id) {\n func.id = 'blah'; // TODO: implement proper uuid generation\n }\n\n this.buildFunctions.splice(index, 0, func);\n return func.id;\n };\n tryAddRenderFunctionBeforeFuncId = (func: ShwimpleBuildFunction, locatorId: string) => {\n if (!func.id) {\n func.id = 'blah'; // TODO: implement proper uuid generation\n }\n\n const result: TryAddFuncResult = { success: false, id: func.id };\n\n const funcLocation = this.buildFunctions.findIndex((bf) => bf.id === locatorId);\n const index = funcLocation - 1 < 0 ? 0 : funcLocation - 1;\n if (index) {\n this.buildFunctions.splice(index, 0, func);\n result.success = true;\n }\n\n return result;\n };\n tryAddRenderFunctionAfterFuncId = (func: ShwimpleBuildFunction, locatorId: string) => {\n if (!func.id) {\n func.id = 'blah'; // TODO: implement proper uuid generation\n }\n\n const result: TryAddFuncResult = { success: false, id: func.id };\n\n const funcLocation = this.buildFunctions.findIndex((bf) => bf.id === locatorId);\n const currentLastIndex = this.buildFunctions.length - 1;\n const index = funcLocation + 1 > currentLastIndex ? currentLastIndex : funcLocation - 1;\n if (index) {\n this.buildFunctions.splice(index, 0, func);\n result.success = true;\n }\n\n return result;\n };\n private builder = buildPipe(...this.buildFunctions);\n build = () => {\n if (this.buildFunctions.length <= 0) {\n return undefined;\n }\n\n const builder = buildPipe(...this.buildFunctions);\n\n return builder(this.page);\n };\n buildAsString = () => {\n if (this.buildFunctions.length <= 0) {\n return undefined;\n }\n\n const builder = buildPipe(...this.buildFunctions);\n\n const builtPage = builder(this.page);\n return builtPage.getHtmlAsString();\n };\n}\n", "import { ShwimpleElementNode, ShwimpleNode, ShwimpleTextNode } from './ShwimpleDocument';\n\nexport type ShwimpleAttributes = {\n id?: string;\n className?: string;\n classList?: string[];\n attrs?: Record<string, string>;\n};\n\nexport type ShwimpleChild = ShwimpleNode | string | number | boolean | null | undefined;\n\nexport type ShwimpleClassValue = string | number | boolean | null | undefined;\n\ntype ElementFactory = (attrsOrChild?: ShwimpleAttributes | ShwimpleChild, ...children: ShwimpleChild[]) => ShwimpleNode;\n\nconst isAttributes = (value: unknown): value is ShwimpleAttributes => {\n if (!value || typeof value !== 'object') {\n return false;\n }\n\n if (value instanceof ShwimpleNode || value instanceof ShwimpleTextNode) {\n return false;\n }\n\n return true;\n};\n\nconst normalizeChildren = (children: ShwimpleChild[]) => {\n const nodes: ShwimpleNode[] = [];\n\n children.forEach((child) => {\n if (child === null || child === undefined || child === false) {\n return;\n }\n\n if (child instanceof ShwimpleNode) {\n nodes.push(child);\n return;\n }\n\n nodes.push(new ShwimpleTextNode(String(child)));\n });\n\n return nodes;\n};\n\nexport const cx = (...values: ShwimpleClassValue[]) =>\n values\n .flatMap((value) => {\n if (value === null || value === undefined || value === false) {\n return [];\n }\n\n if (typeof value === 'number') {\n return [String(value)];\n }\n\n if (typeof value === 'boolean') {\n return [];\n }\n\n return String(value)\n .split(' ')\n .map((entry) => entry.trim())\n .filter((entry) => entry.length > 0);\n })\n .join(' ');\n\nexport const text = (value: string | number | boolean) => new ShwimpleTextNode(String(value));\n\nexport const el = (tag: string, attrsOrChild?: ShwimpleAttributes | ShwimpleChild, ...restChildren: ShwimpleChild[]) => {\n let attrs: ShwimpleAttributes | undefined;\n let children: ShwimpleChild[] = [];\n\n if (isAttributes(attrsOrChild)) {\n attrs = attrsOrChild;\n children = restChildren;\n } else if (attrsOrChild !== undefined) {\n children = [attrsOrChild, ...restChildren];\n } else {\n children = restChildren;\n }\n\n const normalizedClassList = attrs?.classList?.filter((value) => value && value.trim().length > 0) ?? [];\n const classListValue = normalizedClassList.length > 0 ? normalizedClassList.join(' ') : undefined;\n const combinedClassName = [attrs?.className, classListValue].filter(Boolean).join(' ') || undefined;\n\n const node = attrs ? new ShwimpleElementNode(tag, attrs.id ?? '', combinedClassName) : new ShwimpleNode(tag);\n\n if (attrs?.attrs) {\n node.attributes = { ...attrs.attrs };\n }\n\n const normalizedChildren = normalizeChildren(children);\n normalizedChildren.forEach((child) => node.appendChild(child));\n\n return node;\n};\n\nconst createElementFactory =\n (tag: string): ElementFactory =>\n (attrsOrChild?: ShwimpleAttributes | ShwimpleChild, ...children: ShwimpleChild[]) =>\n el(tag, attrsOrChild as ShwimpleAttributes | ShwimpleChild, ...children);\n\nexport const div = createElementFactory('div');\nexport const span = createElementFactory('span');\nexport const section = createElementFactory('section');\nexport const mainElement = createElementFactory('main');\nexport const article = createElementFactory('article');\nexport const aside = createElementFactory('aside');\nexport const header = createElementFactory('header');\nexport const footer = createElementFactory('footer');\nexport const nav = createElementFactory('nav');\nexport const h1 = createElementFactory('h1');\nexport const h2 = createElementFactory('h2');\nexport const h3 = createElementFactory('h3');\nexport const p = createElementFactory('p');\nexport const ul = createElementFactory('ul');\nexport const ol = createElementFactory('ol');\nexport const li = createElementFactory('li');\nexport const a = createElementFactory('a');\nexport const img = createElementFactory('img');\nexport const button = createElementFactory('button');\nexport const input = createElementFactory('input');\nexport const form = createElementFactory('form');\nexport const label = createElementFactory('label');\nexport const strong = createElementFactory('strong');\nexport const em = createElementFactory('em');\nexport const code = createElementFactory('code');\nexport const pre = createElementFactory('pre');\nexport const br = createElementFactory('br');\nexport const title = createElementFactory('title');\nexport const meta = createElementFactory('meta');\nexport const link = createElementFactory('link');\nexport const script = createElementFactory('script');\nexport const style = createElementFactory('style');\n"],
|
|
5
|
+
"mappings": "AAqCO,IAAMA,EAAN,MAAMC,CAA8C,CACvD,SACA,SACA,SACA,WAEA,aAAc,CACV,KAAK,WAAa,CAAC,EACnB,KAAK,SAAW,IAAIC,EAAa,MAAM,EACvC,KAAK,SAAW,IAAIC,EACpB,KAAK,SAAW,IAAIC,EACpB,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f,EAAqB,IAAI,EAC9BgB,EAAKhB,EAAqB,IAAI,EAC9BiB,EAAIjB,EAAqB,GAAG,EAC5BkB,EAAMlB,EAAqB,KAAK,EAChCmB,EAASnB,EAAqB,QAAQ,EACtCoB,EAAQpB,EAAqB,OAAO,EACpCqB,EAAOrB,EAAqB,MAAM,EAClCsB,EAAQtB,EAAqB,OAAO,EACpCuB,EAASvB,EAAqB,QAAQ,EACtCwB,EAAKxB,EAAqB,IAAI,EAC9ByB,EAAOzB,EAAqB,MAAM,EAClC0B,EAAM1B,EAAqB,KAAK,EAChC2B,EAAK3B,EAAqB,IAAI,EAC9B4B,EAAQ5B,EAAqB,OAAO,EACpC6B,EAAO7B,EAAqB,MAAM,EAClC8B,EAAO9B,EAAqB,MAAM,EAClC+B,EAAS/B,EAAqB,QAAQ,EACtCgC,GAAQhC,EAAqB,OAAO",
|
|
6
|
+
"names": ["ShwimpleDocument", "_ShwimpleDocument", "ShwimpleNode", "ShwimpleHeadNode", "ShwimpleBodyNode", "title", "layout", "doc", "charsetNode", "viewportNode", "titleNode", "headerSectionNode", "ShwimpleElementNode", "contentSectionNode", "footerSectionNode", "navSectionNode", "asideSectionNode", "tag", "id", "className", "nodeId", "result", "node", "n", "nodeIndex", "ShwimpleTextNode", "attributes", "child", "pairs", "value", "key", "textContent", "nodeToInsert", "locatorNode", "ShwimpleTextNode", "ShwimpleNode", "textContent", "ShwimpleHeadNode", "ShwimpleNode", "ShwimpleBodyNode", "buildPipe", "fns", "arg", "value", "fn", "ShwimplePageBuilder", "title", "layout", "ShwimpleDocument", "func", "index", "locatorId", "result", "funcLocation", "bf", "currentLastIndex", "isAttributes", "value", "ShwimpleNode", "ShwimpleTextNode", "normalizeChildren", "children", "nodes", "child", "el", "tag", "attrsOrChild", "restChildren", "attrs", "children", "isAttributes", "normalizedClassList", "value", "classListValue", "combinedClassName", "node", "ShwimpleElementNode", "ShwimpleNode", "normalizeChildren", "child", "createElementFactory", "div", "span", "section", "mainElement", "article", "aside", "header", "footer", "nav", "h1", "h2", "h3", "p", "ul", "ol", "li", "a", "img", "button", "input", "form", "label", "strong", "em", "code", "pre", "br", "title", "meta", "link", "script", "style"]
|
|
7
7
|
}
|
package/dist/src/Shwimple.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import { ShwimpleBuildFunction, ShwimplePageBuilder, TryAddFuncResult } from './ShwimplePageBuilder';
|
|
2
|
-
import { ShwimpleDocument, ShwimpleNode, ShwimpleElementNode, ShwimpleHeadNode, ShwimpleBodyNode } from './ShwimpleDocument';
|
|
3
|
-
|
|
1
|
+
import { ShwimpleBuildFunction, ShwimplePageBuilder, TryAddFuncResult } from './ShwimplePageBuilder';
|
|
2
|
+
import { ShwimpleDocument, ShwimpleNode, ShwimpleElementNode, ShwimpleHeadNode, ShwimpleBodyNode, ShwimpleTextNode, ShwimpleBoilerplateLayout } from './ShwimpleDocument';
|
|
3
|
+
import { ShwimpleAttributes, ShwimpleChild, ShwimpleClassValue, cx, el, text, div, span, section, mainElement, article, aside, header, footer, nav, h1, h2, h3, p, ul, ol, li, a, img, button, input, form, label, strong, em, code, pre, br, title, meta, link, script, style } from './ShwimpleElements';
|
|
4
|
+
import { definePage, definePageWithBoilerplate, component, head, body, main, ShwimpleComponent, ShwimpleContext, ShwimpleMountTarget, ShwimplePage } from './ShwimpleConvenience';
|
|
5
|
+
export { ShwimpleBuildFunction, ShwimplePageBuilder, TryAddFuncResult, ShwimpleDocument, ShwimpleNode, ShwimpleElementNode, ShwimpleHeadNode, ShwimpleBodyNode, ShwimpleTextNode, ShwimpleBoilerplateLayout, ShwimpleAttributes, ShwimpleChild, ShwimpleClassValue, cx, el, text, div, span, section, mainElement, article, aside, header, footer, nav, h1, h2, h3, p, ul, ol, li, a, img, button, input, form, label, strong, em, code, pre, br, title, meta, link, script, style, definePage, definePageWithBoilerplate, component, head, body, main, ShwimpleComponent, ShwimpleContext, ShwimpleMountTarget, ShwimplePage, };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ShwimpleBodyNode, ShwimpleBoilerplateLayout, ShwimpleDocument, ShwimpleHeadNode, ShwimpleNode } from './ShwimpleDocument';
|
|
2
|
+
import { ShwimpleBuildFunction, ShwimplePageBuilder } from './ShwimplePageBuilder';
|
|
3
|
+
import { el, text } from './ShwimpleElements';
|
|
4
|
+
export type ShwimpleMountTarget = 'head' | 'body' | 'main';
|
|
5
|
+
export type ShwimpleContext = {
|
|
6
|
+
document: ShwimpleDocument;
|
|
7
|
+
head: ShwimpleHeadNode;
|
|
8
|
+
body: ShwimpleBodyNode;
|
|
9
|
+
el: typeof el;
|
|
10
|
+
text: typeof text;
|
|
11
|
+
mount: (target: ShwimpleMountTarget, nodes: ShwimpleNode | ShwimpleNode[]) => void;
|
|
12
|
+
};
|
|
13
|
+
export type ShwimpleComponent = (context: ShwimpleContext) => ShwimpleNode | ShwimpleNode[] | void;
|
|
14
|
+
export type ShwimplePage = {
|
|
15
|
+
render: () => ShwimpleDocument | undefined;
|
|
16
|
+
renderToString: () => string | undefined;
|
|
17
|
+
builder: ShwimplePageBuilder;
|
|
18
|
+
};
|
|
19
|
+
export declare const component: (name: string, fn: ShwimpleComponent) => ShwimpleComponent & {
|
|
20
|
+
displayName?: string;
|
|
21
|
+
};
|
|
22
|
+
export declare const head: (...components: ShwimpleComponent[]) => ShwimpleBuildFunction;
|
|
23
|
+
export declare const body: (...components: ShwimpleComponent[]) => ShwimpleBuildFunction;
|
|
24
|
+
export declare const main: (...components: ShwimpleComponent[]) => ShwimpleBuildFunction;
|
|
25
|
+
export declare const definePage: (titleOrSection?: string | ShwimpleBuildFunction, ...sections: ShwimpleBuildFunction[]) => ShwimplePage;
|
|
26
|
+
export declare const definePageWithBoilerplate: (layout: ShwimpleBoilerplateLayout, titleOrSection?: string | ShwimpleBuildFunction, ...sections: ShwimpleBuildFunction[]) => ShwimplePage;
|
|
@@ -1,77 +1,84 @@
|
|
|
1
|
-
export interface IShwimpleDocument {
|
|
2
|
-
mainNode: ShwimpleMainNode;
|
|
3
|
-
headNode: ShwimpleHeadNode;
|
|
4
|
-
bodyNode: ShwimpleBodyNode;
|
|
5
|
-
childNodes: ShwimpleNode[];
|
|
6
|
-
createElement: (tag: string, id: string, className?: string) => ShwimpleNode;
|
|
7
|
-
querySelectorById: (nodeId: string) => ShwimpleNode | undefined;
|
|
8
|
-
querySelectorByIndex: (nodeIndex: number) => ShwimpleNode | undefined;
|
|
9
|
-
getHead: () => ShwimpleNode;
|
|
10
|
-
getBody: () => ShwimpleNode;
|
|
11
|
-
getHtmlAsString: () => string | undefined;
|
|
12
|
-
}
|
|
13
|
-
export interface IShwimpleNode {
|
|
14
|
-
appendChild: (child: ShwimpleNode) => void;
|
|
15
|
-
children?: ShwimpleNode[];
|
|
16
|
-
insertBefore: (nodeToInsert: ShwimpleNode, locatorNode: ShwimpleNode) => void;
|
|
17
|
-
insertAfter: (nodeToInsert: ShwimpleNode, locatorNode: ShwimpleNode) => void;
|
|
18
|
-
getParent: () => ShwimpleNode;
|
|
19
|
-
tag: string;
|
|
20
|
-
textContent?: string;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
private
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
1
|
+
export interface IShwimpleDocument {
|
|
2
|
+
mainNode: ShwimpleMainNode;
|
|
3
|
+
headNode: ShwimpleHeadNode;
|
|
4
|
+
bodyNode: ShwimpleBodyNode;
|
|
5
|
+
childNodes: ShwimpleNode[];
|
|
6
|
+
createElement: (tag: string, id: string, className?: string) => ShwimpleNode;
|
|
7
|
+
querySelectorById: (nodeId: string) => ShwimpleNode | undefined;
|
|
8
|
+
querySelectorByIndex: (nodeIndex: number) => ShwimpleNode | undefined;
|
|
9
|
+
getHead: () => ShwimpleNode;
|
|
10
|
+
getBody: () => ShwimpleNode;
|
|
11
|
+
getHtmlAsString: () => string | undefined;
|
|
12
|
+
}
|
|
13
|
+
export interface IShwimpleNode {
|
|
14
|
+
appendChild: (child: ShwimpleNode) => void;
|
|
15
|
+
children?: ShwimpleNode[];
|
|
16
|
+
insertBefore: (nodeToInsert: ShwimpleNode, locatorNode: ShwimpleNode) => void;
|
|
17
|
+
insertAfter: (nodeToInsert: ShwimpleNode, locatorNode: ShwimpleNode) => void;
|
|
18
|
+
getParent: () => ShwimpleNode;
|
|
19
|
+
tag: string;
|
|
20
|
+
textContent?: string;
|
|
21
|
+
attributes?: Record<string, string>;
|
|
22
|
+
}
|
|
23
|
+
export interface IShwimpleElementNode extends IShwimpleNode {
|
|
24
|
+
className?: string;
|
|
25
|
+
id: string;
|
|
26
|
+
}
|
|
27
|
+
export interface IShwimpleHeadElementNode extends IShwimpleNode {
|
|
28
|
+
rel?: string;
|
|
29
|
+
typeName?: string;
|
|
30
|
+
href?: string;
|
|
31
|
+
}
|
|
32
|
+
export type ShwimpleBoilerplateLayout = 'standard' | 'docs' | 'landing';
|
|
33
|
+
export declare class ShwimpleDocument implements IShwimpleDocument {
|
|
34
|
+
mainNode: ShwimpleNode;
|
|
35
|
+
headNode: ShwimpleHeadNode;
|
|
36
|
+
bodyNode: ShwimpleBodyNode;
|
|
37
|
+
childNodes: ShwimpleNode[];
|
|
38
|
+
constructor();
|
|
39
|
+
static createBoilerplateDocument: (title?: string, layout?: ShwimpleBoilerplateLayout) => ShwimpleDocument;
|
|
40
|
+
static createEmptyDocument: () => ShwimpleDocument;
|
|
41
|
+
createElement: (tag: string, id: string, className?: string) => ShwimpleElementNode;
|
|
42
|
+
querySelectorById: (nodeId: string) => ShwimpleNode | undefined;
|
|
43
|
+
querySelectorByIndex: (nodeIndex: number) => ShwimpleNode | undefined;
|
|
44
|
+
getHead: () => ShwimpleHeadNode;
|
|
45
|
+
getBody: () => ShwimpleBodyNode;
|
|
46
|
+
private html;
|
|
47
|
+
getHtmlAsString: () => string | undefined;
|
|
48
|
+
private parseChildNodes;
|
|
49
|
+
private getAttributes;
|
|
50
|
+
}
|
|
51
|
+
export declare class ShwimpleNode implements IShwimpleNode {
|
|
52
|
+
children?: ShwimpleNode[];
|
|
53
|
+
tag: string;
|
|
54
|
+
textContent?: string;
|
|
55
|
+
attributes?: Record<string, string>;
|
|
56
|
+
constructor(tag: string, textContent?: string, attributes?: Record<string, string>);
|
|
57
|
+
appendChild: (child: ShwimpleNode) => void;
|
|
58
|
+
insertBefore: (nodeToInsert: ShwimpleNode, locatorNode: ShwimpleNode) => void;
|
|
59
|
+
insertAfter: (nodeToInsert: ShwimpleNode, locatorNode: ShwimpleNode) => void;
|
|
60
|
+
getParent: () => this;
|
|
61
|
+
}
|
|
62
|
+
export declare class ShwimpleElementNode extends ShwimpleNode implements IShwimpleElementNode {
|
|
63
|
+
className?: string;
|
|
64
|
+
id: string;
|
|
65
|
+
constructor(tag: string, id: string, className?: string, textContent?: string, attributes?: Record<string, string>);
|
|
66
|
+
}
|
|
67
|
+
export declare class ShwimpleHeadElementNode extends ShwimpleNode implements IShwimpleHeadElementNode {
|
|
68
|
+
rel?: string;
|
|
69
|
+
typeName?: string;
|
|
70
|
+
href?: string;
|
|
71
|
+
constructor(rel?: string, typeName?: string, href?: string, textContent?: string);
|
|
72
|
+
}
|
|
73
|
+
export declare class ShwimpleTextNode extends ShwimpleNode implements IShwimpleNode {
|
|
74
|
+
constructor(textContent: string);
|
|
75
|
+
}
|
|
76
|
+
export declare class ShwimpleMainNode extends ShwimpleNode implements IShwimpleNode {
|
|
77
|
+
constructor();
|
|
78
|
+
}
|
|
79
|
+
export declare class ShwimpleHeadNode extends ShwimpleNode implements IShwimpleNode {
|
|
80
|
+
constructor();
|
|
81
|
+
}
|
|
82
|
+
export declare class ShwimpleBodyNode extends ShwimpleNode implements IShwimpleNode {
|
|
83
|
+
constructor();
|
|
84
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ShwimpleNode, ShwimpleTextNode } from './ShwimpleDocument';
|
|
2
|
+
export type ShwimpleAttributes = {
|
|
3
|
+
id?: string;
|
|
4
|
+
className?: string;
|
|
5
|
+
classList?: string[];
|
|
6
|
+
attrs?: Record<string, string>;
|
|
7
|
+
};
|
|
8
|
+
export type ShwimpleChild = ShwimpleNode | string | number | boolean | null | undefined;
|
|
9
|
+
export type ShwimpleClassValue = string | number | boolean | null | undefined;
|
|
10
|
+
type ElementFactory = (attrsOrChild?: ShwimpleAttributes | ShwimpleChild, ...children: ShwimpleChild[]) => ShwimpleNode;
|
|
11
|
+
export declare const cx: (...values: ShwimpleClassValue[]) => string;
|
|
12
|
+
export declare const text: (value: string | number | boolean) => ShwimpleTextNode;
|
|
13
|
+
export declare const el: (tag: string, attrsOrChild?: ShwimpleAttributes | ShwimpleChild, ...restChildren: ShwimpleChild[]) => ShwimpleNode;
|
|
14
|
+
export declare const div: ElementFactory;
|
|
15
|
+
export declare const span: ElementFactory;
|
|
16
|
+
export declare const section: ElementFactory;
|
|
17
|
+
export declare const mainElement: ElementFactory;
|
|
18
|
+
export declare const article: ElementFactory;
|
|
19
|
+
export declare const aside: ElementFactory;
|
|
20
|
+
export declare const header: ElementFactory;
|
|
21
|
+
export declare const footer: ElementFactory;
|
|
22
|
+
export declare const nav: ElementFactory;
|
|
23
|
+
export declare const h1: ElementFactory;
|
|
24
|
+
export declare const h2: ElementFactory;
|
|
25
|
+
export declare const h3: ElementFactory;
|
|
26
|
+
export declare const p: ElementFactory;
|
|
27
|
+
export declare const ul: ElementFactory;
|
|
28
|
+
export declare const ol: ElementFactory;
|
|
29
|
+
export declare const li: ElementFactory;
|
|
30
|
+
export declare const a: ElementFactory;
|
|
31
|
+
export declare const img: ElementFactory;
|
|
32
|
+
export declare const button: ElementFactory;
|
|
33
|
+
export declare const input: ElementFactory;
|
|
34
|
+
export declare const form: ElementFactory;
|
|
35
|
+
export declare const label: ElementFactory;
|
|
36
|
+
export declare const strong: ElementFactory;
|
|
37
|
+
export declare const em: ElementFactory;
|
|
38
|
+
export declare const code: ElementFactory;
|
|
39
|
+
export declare const pre: ElementFactory;
|
|
40
|
+
export declare const br: ElementFactory;
|
|
41
|
+
export declare const title: ElementFactory;
|
|
42
|
+
export declare const meta: ElementFactory;
|
|
43
|
+
export declare const link: ElementFactory;
|
|
44
|
+
export declare const script: ElementFactory;
|
|
45
|
+
export declare const style: ElementFactory;
|
|
46
|
+
export {};
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { ShwimpleDocument } from './ShwimpleDocument';
|
|
2
|
-
export
|
|
3
|
-
id?: string;
|
|
4
|
-
(value: ShwimpleDocument): ShwimpleDocument;
|
|
5
|
-
};
|
|
6
|
-
export
|
|
7
|
-
success: boolean;
|
|
8
|
-
id: string;
|
|
9
|
-
};
|
|
10
|
-
export declare class ShwimplePageBuilder {
|
|
11
|
-
page: ShwimpleDocument;
|
|
12
|
-
buildFunctions: ShwimpleBuildFunction[];
|
|
13
|
-
constructor(title?: string);
|
|
14
|
-
addRenderFunction: (func: ShwimpleBuildFunction) => string;
|
|
15
|
-
addRenderFunctionAt: (func: ShwimpleBuildFunction, index: number) => string;
|
|
16
|
-
tryAddRenderFunctionBeforeFuncId: (func: ShwimpleBuildFunction, locatorId: string) => TryAddFuncResult;
|
|
17
|
-
tryAddRenderFunctionAfterFuncId: (func: ShwimpleBuildFunction, locatorId: string) => TryAddFuncResult;
|
|
18
|
-
private builder;
|
|
19
|
-
build: () => ShwimpleDocument | undefined;
|
|
20
|
-
buildAsString: () => string | undefined;
|
|
21
|
-
}
|
|
1
|
+
import { ShwimpleBoilerplateLayout, ShwimpleDocument } from './ShwimpleDocument';
|
|
2
|
+
export type ShwimpleBuildFunction = {
|
|
3
|
+
id?: string;
|
|
4
|
+
(value: ShwimpleDocument): ShwimpleDocument;
|
|
5
|
+
};
|
|
6
|
+
export type TryAddFuncResult = {
|
|
7
|
+
success: boolean;
|
|
8
|
+
id: string;
|
|
9
|
+
};
|
|
10
|
+
export declare class ShwimplePageBuilder {
|
|
11
|
+
page: ShwimpleDocument;
|
|
12
|
+
buildFunctions: ShwimpleBuildFunction[];
|
|
13
|
+
constructor(title?: string, layout?: ShwimpleBoilerplateLayout);
|
|
14
|
+
addRenderFunction: (func: ShwimpleBuildFunction) => string;
|
|
15
|
+
addRenderFunctionAt: (func: ShwimpleBuildFunction, index: number) => string;
|
|
16
|
+
tryAddRenderFunctionBeforeFuncId: (func: ShwimpleBuildFunction, locatorId: string) => TryAddFuncResult;
|
|
17
|
+
tryAddRenderFunctionAfterFuncId: (func: ShwimpleBuildFunction, locatorId: string) => TryAddFuncResult;
|
|
18
|
+
private builder;
|
|
19
|
+
build: () => ShwimpleDocument | undefined;
|
|
20
|
+
buildAsString: () => string | undefined;
|
|
21
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const isNullOrEmpty: (value: string) => boolean;
|
|
1
|
+
export declare const isNullOrEmpty: (value: string) => boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shwimple",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "shwimple - a simple HTML writer",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -8,7 +8,13 @@
|
|
|
8
8
|
"type": "module",
|
|
9
9
|
"scripts": {
|
|
10
10
|
"ts-types": " tsc --emitDeclarationOnly --outDir dist",
|
|
11
|
-
"build": "rimraf dist && node ./esbuild.js && npm run ts-types"
|
|
11
|
+
"build": "rimraf dist && node ./esbuild.js && npm run ts-types",
|
|
12
|
+
"example": "npm run build && node ./examples/quickstart.js",
|
|
13
|
+
"example:standard": "npm run build && node ./examples/layout-standard.js",
|
|
14
|
+
"example:docs": "npm run build && node ./examples/layout-docs.js",
|
|
15
|
+
"example:landing": "npm run build && node ./examples/layout-landing.js",
|
|
16
|
+
"example:charts": "npm run build && node ./examples/chartjs-cdn.js",
|
|
17
|
+
"prepublishOnly": "npm run build"
|
|
12
18
|
},
|
|
13
19
|
"repository": {
|
|
14
20
|
"type": "git",
|
|
@@ -27,12 +33,15 @@
|
|
|
27
33
|
"url": "https://github.com/wooffet/shwimple/issues"
|
|
28
34
|
},
|
|
29
35
|
"homepage": "https://github.com/wooffet/shwimple#readme",
|
|
36
|
+
"files": [
|
|
37
|
+
"dist"
|
|
38
|
+
],
|
|
30
39
|
"devDependencies": {
|
|
31
|
-
"esbuild": "^0.
|
|
32
|
-
"rimraf": "^
|
|
33
|
-
"typescript": "^
|
|
40
|
+
"esbuild": "^0.27.2",
|
|
41
|
+
"rimraf": "^6.1.2",
|
|
42
|
+
"typescript": "^5.9.3"
|
|
34
43
|
},
|
|
35
44
|
"engines": {
|
|
36
|
-
"node": ">=
|
|
45
|
+
"node": ">=22.0.0"
|
|
37
46
|
}
|
|
38
47
|
}
|