shwimple 4.0.0 → 4.1.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/README.md +96 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +2 -2
- package/dist/src/Shwimple.d.ts +2 -2
- package/dist/src/ShwimpleElements.d.ts +3 -0
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -54,6 +54,8 @@ npm run example:standard
|
|
|
54
54
|
npm run example:docs
|
|
55
55
|
npm run example:landing
|
|
56
56
|
npm run example:charts
|
|
57
|
+
npm run example:htmx
|
|
58
|
+
npm run example:alpine
|
|
57
59
|
```
|
|
58
60
|
|
|
59
61
|
## Example: Chart.js from CDN
|
|
@@ -61,7 +63,7 @@ npm run example:charts
|
|
|
61
63
|
This example pulls Chart.js from a CDN and renders a few charts with fake data.
|
|
62
64
|
|
|
63
65
|
```ts
|
|
64
|
-
import { definePageWithBoilerplate, head, body, main, el, h1, p, script } from 'shwimple';
|
|
66
|
+
import { definePageWithBoilerplate, head, body, main, el, h1, p, script, style } from 'shwimple';
|
|
65
67
|
|
|
66
68
|
const Charts = () =>
|
|
67
69
|
el(
|
|
@@ -126,6 +128,99 @@ const page = definePageWithBoilerplate(
|
|
|
126
128
|
const html = page.renderToString();
|
|
127
129
|
```
|
|
128
130
|
|
|
131
|
+
## Reactivity (3rd-party scripts)
|
|
132
|
+
|
|
133
|
+
shwimple keeps the core non-reactive. For interactive behavior, use lightweight libraries such as htmx or Alpine.js.
|
|
134
|
+
|
|
135
|
+
```ts
|
|
136
|
+
import { el, dataAttrs, ariaAttrs } from 'shwimple';
|
|
137
|
+
|
|
138
|
+
const button = el(
|
|
139
|
+
'button',
|
|
140
|
+
{
|
|
141
|
+
className: 'btn',
|
|
142
|
+
attrs: {
|
|
143
|
+
...dataAttrs({ action: 'toggle', target: 'details' }),
|
|
144
|
+
...ariaAttrs({ expanded: false, controls: 'details' }),
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
'Toggle'
|
|
148
|
+
);
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Example: htmx (CDN)
|
|
152
|
+
|
|
153
|
+
```ts
|
|
154
|
+
import { definePageWithBoilerplate, head, body, main, el, h1, p, script } from 'shwimple';
|
|
155
|
+
|
|
156
|
+
const HtmxDemo = () =>
|
|
157
|
+
el(
|
|
158
|
+
'section',
|
|
159
|
+
{ id: 'htmx-demo', className: 'demo' },
|
|
160
|
+
h1('htmx Demo'),
|
|
161
|
+
p('This button uses htmx attributes.'),
|
|
162
|
+
el(
|
|
163
|
+
'button',
|
|
164
|
+
{
|
|
165
|
+
className: 'btn',
|
|
166
|
+
attrs: {
|
|
167
|
+
'hx-get': '/demo',
|
|
168
|
+
'hx-target': '#htmx-output',
|
|
169
|
+
'hx-swap': 'innerHTML',
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
'Load content'
|
|
173
|
+
),
|
|
174
|
+
el('div', { id: 'htmx-output', className: 'output' }, 'Waiting for response...')
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
const page = definePageWithBoilerplate(
|
|
178
|
+
'standard',
|
|
179
|
+
'htmx Demo',
|
|
180
|
+
head(() => [
|
|
181
|
+
style(`
|
|
182
|
+
body { font-family: system-ui, sans-serif; padding: 2rem; }
|
|
183
|
+
.demo { display: grid; gap: 0.75rem; max-width: 480px; }
|
|
184
|
+
.btn { background: #2563eb; color: white; border: none; padding: 0.5rem 0.75rem; border-radius: 0.5rem; }
|
|
185
|
+
.output { padding: 0.5rem 0.75rem; background: #f3f4f6; border-radius: 0.5rem; }
|
|
186
|
+
`),
|
|
187
|
+
script({ attrs: { src: 'https://unpkg.com/htmx.org@1.9.10' } }),
|
|
188
|
+
]),
|
|
189
|
+
body(main(HtmxDemo))
|
|
190
|
+
);
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Example: Alpine.js (CDN)
|
|
194
|
+
|
|
195
|
+
```ts
|
|
196
|
+
import { definePageWithBoilerplate, head, body, main, el, h1, p, script, style } from 'shwimple';
|
|
197
|
+
|
|
198
|
+
const AlpineDemo = () =>
|
|
199
|
+
el(
|
|
200
|
+
'section',
|
|
201
|
+
{ id: 'alpine-demo', className: 'demo', attrs: { 'x-data': '{ count: 0 }' } },
|
|
202
|
+
h1('Alpine.js Demo'),
|
|
203
|
+
p('A simple counter with x-data and x-on.'),
|
|
204
|
+
el('button', { className: 'btn', attrs: { 'x-on:click': 'count++' } }, 'Increment'),
|
|
205
|
+
el('span', { className: 'count', attrs: { 'x-text': 'count' } })
|
|
206
|
+
);
|
|
207
|
+
|
|
208
|
+
const page = definePageWithBoilerplate(
|
|
209
|
+
'standard',
|
|
210
|
+
'Alpine Demo',
|
|
211
|
+
head(() => [
|
|
212
|
+
style(`
|
|
213
|
+
body { font-family: system-ui, sans-serif; padding: 2rem; }
|
|
214
|
+
.demo { display: grid; gap: 0.75rem; max-width: 480px; }
|
|
215
|
+
.btn { background: #111827; color: white; border: none; padding: 0.5rem 0.75rem; border-radius: 0.5rem; }
|
|
216
|
+
.count { font-weight: 600; }
|
|
217
|
+
`),
|
|
218
|
+
script({ attrs: { defer: '', src: 'https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js' } }),
|
|
219
|
+
]),
|
|
220
|
+
body(main(AlpineDemo))
|
|
221
|
+
);
|
|
222
|
+
```
|
|
223
|
+
|
|
129
224
|
## TODO
|
|
130
225
|
|
|
131
226
|
- Add HTML escaping for text and attributes
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var m=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??""),c=new d("header","header-section","header-section"),u=new d("main","content-section","content-section"),b=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");c.appendChild(h)}if(i.bodyNode.appendChild(c),i.bodyNode.appendChild(u),t==="docs"){let h=new d("aside","aside-section","aside-section");i.bodyNode.appendChild(h)}return i.bodyNode.appendChild(b),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 a){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 a=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=m.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(c=>c.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 x=r=>!(!r||typeof r!="object"||r instanceof s||r instanceof a),y=r=>{let e=[];return r.forEach(t=>{if(!(t==null||t===!1)){if(t instanceof s){e.push(t);return}e.push(new a(String(t)))}}),e};var N=(r,e,...t)=>{let i,o=[];x(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,c=[i?.className,p].filter(Boolean).join(" ")||void 0,u=i?new d(r,i.id??"",c):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"),R=n("header"),T=n("footer"),D=n("nav"),P=n("h1"),H=n("h2"),L=n("h3"),M=n("p"),v=n("ul"),$=n("ol"),j=n("li"),z=n("a"),V=n("img"),q=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,m 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
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,KAAK,WAAW,KAAK,KAAK,QAAQ,EAClC,KAAK,WAAW,KAAK,KAAK,QAAQ,CACtC,CAEA,OAAO,0BAA4B,CAACC,EAAgBC,EAAoC,aAAe,CACnG,IAAMC,EAAM,IAAIN,EACVO,EAAc,IAAIN,EAAa,OAAQ,OAAW,CAAE,QAAS,OAAQ,CAAC,EACtEO,EAAe,IAAI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EAAe,EACxD,OAAIH,IACA,KAAK,eAAe,OAAOA,EAAO,EAAGD,CAAI,EACzCG,EAAO,QAAU,IAGdA,CACX,EACA,gCAAkC,CAACH,EAA6BE,IAAsB,CAC7EF,EAAK,KACNA,EAAK,GAAK,QAGd,IAAMG,EAA2B,CAAE,QAAS,GAAO,GAAIH,EAAK,EAAG,EAEzDI,EAAe,KAAK,eAAe,UAAWC,GAAOA,EAAG,KAAOH,CAAS,EACxEI,EAAmB,KAAK,eAAe,OAAS,EAChDL,EAAQG,EAAe,EAAIE,EAAmBA,EAAmBF,EAAe,EACtF,OAAIH,IACA,KAAK,eAAe,OAAOA,EAAO,EAAGD,CAAI,EACzCG,EAAO,QAAU,IAGdA,CACX,EACQ,QAAUZ,EAAU,GAAG,KAAK,cAAc,EAClD,MAAQ,IACA,KAAK,eAAe,QAAU,EAC9B,OAGYA,EAAU,GAAG,KAAK,cAAc,EAEjC,KAAK,IAAI,EAE5B,cAAgB,IACR,KAAK,eAAe,QAAU,EAC9B,OAGYA,EAAU,GAAG,KAAK,cAAc,EAEtB,KAAK,IAAI,EAClB,gBAAgB,CAEzC,
|
|
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;\nexport type ShwimpleAttributeMap = Record<string, 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\nconst normalizeAttributeValue = (value: string | number | boolean | null | undefined) => {\n if (value === null || value === undefined || value === false) {\n return undefined;\n }\n\n if (value === true) {\n return '';\n }\n\n return String(value);\n};\n\nconst prefixAttributes = (prefix: string, attrs: ShwimpleAttributeMap) =>\n Object.entries(attrs).reduce<Record<string, string>>((result, [key, value]) => {\n const normalizedValue = normalizeAttributeValue(value);\n\n if (normalizedValue === undefined) {\n return result;\n }\n\n result[`${prefix}${key}`] = normalizedValue;\n return result;\n }, {});\n\nexport const dataAttrs = (attrs: ShwimpleAttributeMap) => prefixAttributes('data-', attrs);\nexport const ariaAttrs = (attrs: ShwimpleAttributeMap) => prefixAttributes('aria-', attrs);\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,KAAK,WAAW,KAAK,KAAK,QAAQ,EAClC,KAAK,WAAW,KAAK,KAAK,QAAQ,CACtC,CAEA,OAAO,0BAA4B,CAACC,EAAgBC,EAAoC,aAAe,CACnG,IAAMC,EAAM,IAAIN,EACVO,EAAc,IAAIN,EAAa,OAAQ,OAAW,CAAE,QAAS,OAAQ,CAAC,EACtEO,EAAe,IAAIP,EAAa,OAAQ,OAAW,CACrD,KAAM,WACN,QAAS,qCACb,CAAC,EACKQ,EAAY,IAAIR,EAAa,QAASG,GAAS,EAAE,EACjDM,EAAoB,IAAIC,EAAoB,SAAU,iBAAkB,gBAAgB,EACxFC,EAAqB,IAAID,EAAoB,OAAQ,kBAAmB,iBAAiB,EACzFE,EAAoB,IAAIF,EAAoB,SAAU,iBAAkB,gBAAgB,EAK9F,GAJAL,EAAI,SAAS,YAAYC,CAAW,EACpCD,EAAI,SAAS,YAAYE,CAAY,EACrCF,EAAI,SAAS,YAAYG,CAAS,EAE9BJ,IAAW,UAAW,CACtB,IAAMS,EAAiB,IAAIH,EAAoB,MAAO,cAAe,aAAa,EAClFD,EAAkB,YAAYI,CAAc,CACh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GAAUJ,EAAK,YAAYI,CAAK,CAAC,EAEtDJ,CACX,EAEMK,EACDf,GACD,CAACC,KAAsDG,IACnDL,EAAGC,EAAKC,EAAoD,GAAGG,CAAQ,EAElEY,EAAMD,EAAqB,KAAK,EAChCE,EAAOF,EAAqB,MAAM,EAClCG,EAAUH,EAAqB,SAAS,EACxCI,EAAcJ,EAAqB,MAAM,EACzCK,EAAUL,EAAqB,SAAS,EACxCM,EAAQN,EAAqB,OAAO,EACpCO,EAASP,EAAqB,QAAQ,EACtCQ,EAASR,EAAqB,QAAQ,EACtCS,EAAMT,EAAqB,KAAK,EAChCU,EAAKV,EAAqB,IAAI,EAC9BW,EAAKX,EAAqB,IAAI,EAC9BY,EAAKZ,EAAqB,IAAI,EAC9Ba,EAAIb,EAAqB,GAAG,EAC5Bc,EAAKd,EAAqB,IAAI,EAC9Be,EAAKf,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
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,5 +1,5 @@
|
|
|
1
1
|
import { ShwimpleBuildFunction, ShwimplePageBuilder, TryAddFuncResult } from './ShwimplePageBuilder';
|
|
2
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';
|
|
3
|
+
import { ShwimpleAttributes, ShwimpleChild, ShwimpleClassValue, ShwimpleAttributeMap, cx, dataAttrs, ariaAttrs, 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
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, };
|
|
5
|
+
export { ShwimpleBuildFunction, ShwimplePageBuilder, TryAddFuncResult, ShwimpleDocument, ShwimpleNode, ShwimpleElementNode, ShwimpleHeadNode, ShwimpleBodyNode, ShwimpleTextNode, ShwimpleBoilerplateLayout, ShwimpleAttributes, ShwimpleChild, ShwimpleClassValue, ShwimpleAttributeMap, cx, dataAttrs, ariaAttrs, 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, };
|
|
@@ -7,8 +7,11 @@ export type ShwimpleAttributes = {
|
|
|
7
7
|
};
|
|
8
8
|
export type ShwimpleChild = ShwimpleNode | string | number | boolean | null | undefined;
|
|
9
9
|
export type ShwimpleClassValue = string | number | boolean | null | undefined;
|
|
10
|
+
export type ShwimpleAttributeMap = Record<string, string | number | boolean | null | undefined>;
|
|
10
11
|
type ElementFactory = (attrsOrChild?: ShwimpleAttributes | ShwimpleChild, ...children: ShwimpleChild[]) => ShwimpleNode;
|
|
11
12
|
export declare const cx: (...values: ShwimpleClassValue[]) => string;
|
|
13
|
+
export declare const dataAttrs: (attrs: ShwimpleAttributeMap) => Record<string, string>;
|
|
14
|
+
export declare const ariaAttrs: (attrs: ShwimpleAttributeMap) => Record<string, string>;
|
|
12
15
|
export declare const text: (value: string | number | boolean) => ShwimpleTextNode;
|
|
13
16
|
export declare const el: (tag: string, attrsOrChild?: ShwimpleAttributes | ShwimpleChild, ...restChildren: ShwimpleChild[]) => ShwimpleNode;
|
|
14
17
|
export declare const div: ElementFactory;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shwimple",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "shwimple - a simple HTML writer",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
"example:docs": "npm run build && node ./examples/layout-docs.js",
|
|
15
15
|
"example:landing": "npm run build && node ./examples/layout-landing.js",
|
|
16
16
|
"example:charts": "npm run build && node ./examples/chartjs-cdn.js",
|
|
17
|
+
"example:htmx": "npm run build && node ./examples/htmx-cdn.js",
|
|
18
|
+
"example:alpine": "npm run build && node ./examples/alpine-cdn.js",
|
|
17
19
|
"prepublishOnly": "npm run build"
|
|
18
20
|
},
|
|
19
21
|
"repository": {
|